public EuropeanCallOption(string name, object stockP, object strike, object riskFree, object maturity, object sigma = null, object price = null) : base(name, maturity) { this.StockPrice = Input(stockP); this.Strike = Input(strike); this.RiskFree = Input(riskFree); if (sigma != null) { this.Sigma = Input(sigma); this.Price = GenericOption.PriceFunc( () => Math.Exp(-this.StockDivd() * this.Maturity()) * this.StockPrice(), () => Math.Exp(-this.RiskFree() * this.Maturity()) * this.Strike(), this.Sigma, this.Maturity); } else if (price != null) { this.Price = Input(price); this.Sigma = () => { var t = new EuropeanCallOption(string.Empty, this.StockPrice, this.Strike, this.RiskFree, this.Maturity, sigma: 0); return(Bisection.Search(t.RemoteLink(nameof(t.Sigma), nameof(t.Price)), this.Price(), (0, 1))); }; } else { throw new ArgumentNullException(nameof(sigma), "sigma and price can't be both null"); } }
/// <summary> /// Initial instance of <see cref="ExchangeOption"/> from two <see cref="Stock"/>s. Use Margrabe Formula to price. /// </summary> /// <param name="name">Name of the deferred exchange option</param> /// <param name="s1">Asset to be received</param> /// <param name="s2">Asset to be delivered</param> /// <param name="rho">Correlation between two assets</param> /// <param name="maturity">Time to maturity of option</param> public ExchangeOption(string name, Stock s1, Stock s2, object rho, object maturity) : base(name, maturity) { this.Rho = Input(rho); this.Price = GenericOption.PriceFunc(() => Math.Exp(-s1.Divd() * this.Maturity()) * s1.Price(), () => Math.Exp(-s2.Divd() * this.Maturity()) * s2.Price(), () => Math.Sqrt( Math.Pow(s1.Sigma(), 2) + Math.Pow(s2.Sigma(), 2) - 2 * this.Rho() * s1.Sigma() * s2.Sigma()), this.Maturity); }
/// <summary> /// Initial instance of <see cref="DeferredExchangeOption"/> from two <see cref="Stock"/>s. Use Margrabe Formula to price. /// </summary> /// <param name="name">Name of the deferred exchange option</param> /// <param name="s1">Asset to be received</param> /// <param name="s2">Asset to be delivered</param> /// <param name="rho">Correlation between two assets</param> /// <param name="optionMaturity">Time to maturity of option</param> /// <param name="exchangeMaturity">Time until exchange >= TOption</param> public DeferredExchangeOption(string name, Stock s1, Stock s2, object rho, object optionMaturity, object exchangeMaturity) : base(name, s1, s2, rho, optionMaturity) { this.ExchangeMaturity = Input(exchangeMaturity); this.Price = GenericOption.PriceFunc(() => Math.Exp(-s1.Divd() * this.ExchangeMaturity()) * s1.Price(), () => Math.Exp(-s2.Divd() * this.ExchangeMaturity()) * s2.Price(), () => Math.Sqrt( Math.Pow(s1.Sigma(), 2) + Math.Pow(s2.Sigma(), 2) - 2 * this.Rho() * s1.Sigma() * s2.Sigma()), this.Maturity); }