private BlackScholeCalculator ConfigureCalculator(IOption option, IMarketCondition market, double expiryDayRemainingLife = double.NaN, double timeIncrement = 0.0) { var trade = (BinaryOption)option; var exerciseDate = trade.ExerciseDates.Last(); var maturityDate = trade.UnderlyingMaturityDate; var riskFreeRate = market.DiscountCurve.Value.ZeroRate(market.ValuationDate, exerciseDate); var riskfreeDfAtMaturity = market.DiscountCurve.Value.ZeroRate(market.ValuationDate, maturityDate); var riskfreeDfAtExercise = market.DiscountCurve.Value.ZeroRate(market.ValuationDate, exerciseDate); var spot = market.SpotPrices.Value.Values.First(); double sigma = AnalyticalOptionPricerUtil.pricingVol(volSurf: market.VolSurfaces.Value.Values.First(), exerciseDate: exerciseDate, option: option, spot: spot); var dividendCurveInput = market.DividendCurves.Value.Values.First().ZeroRate(market.ValuationDate, exerciseDate); var dividendInput = AnalyticalOptionPricerUtil.dividendYieldOutput(dividendCurveInput, riskFreeRate, option.Dividends, spot, market.ValuationDate, trade.ExerciseDates.Last(), option.DayCount); var dividendRate = AnalyticalOptionPricerUtil.dividenRate(trade.UnderlyingProductType, dividendInput, riskfreeDfAtExercise); var exerciseInYears = AnalyticalOptionPricerUtil.timeToMaturityFraction(market.ValuationDate, exerciseDate, trade) + timeIncrement; var maturityInYears = AnalyticalOptionPricerUtil.timeToMaturityFraction(market.ValuationDate, maturityDate, trade) + timeIncrement; var _isDelayedPay = exerciseInYears.AlmostEqual(maturityInYears); var calculator = new BlackScholeCalculator(trade.OptionType, trade.BinaryOptionPayoffType, strike: option.IsMoneynessOption ? trade.Strike * trade.InitialSpotPrice : trade.Strike, spotPrice: spot, sigma: sigma, dividendRate: dividendRate, riskfreeRateAtExercise: riskfreeDfAtExercise, riskfreeRateAtMaturity: riskfreeDfAtMaturity, curveDayCount: market.DiscountCurve.Value.DayCount, cashOrNothingAmount: trade.CashOrNothingAmount, exerciseDate: exerciseDate, maturityDate: maturityDate, valuationDate: market.ValuationDate, trade: trade, underlyingInstrumentType: trade.UnderlyingProductType, notional: trade.Notional, isDelayedPay: _isDelayedPay, expiryDayRemainingLife: expiryDayRemainingLife, timeIncrement: timeIncrement); this._calculator = calculator; return(calculator); }
private BlackScholeCalculator ConfigureCalculator(IOption option, IMarketCondition market, double expiryDayRemainingLife = double.NaN, double timeIncrement = 0.0) { var trade = (VanillaOption)option; var exerciseDate = trade.ExerciseDates.Last(); var maturityDate = trade.UnderlyingMaturityDate; var spot = market.SpotPrices.Value.Values.First(); double sigma = AnalyticalOptionPricerUtil.pricingVol(volSurf: market.VolSurfaces.Value.Values.First(), exerciseDate: exerciseDate, option: option, spot: spot); var riskfreeRateAtExercise = market.DiscountCurve.Value.ZeroRate(market.ValuationDate, exerciseDate); var riskfreeRateAtMaturity = market.DiscountCurve.Value.ZeroRate(market.ValuationDate, maturityDate); var riskFreeRate = market.DiscountCurve.Value.ZeroRate(market.ValuationDate, exerciseDate); var dividendCurveInput = market.DividendCurves.Value.Values.First().ZeroRate(market.ValuationDate, exerciseDate); var dividendInput = AnalyticalOptionPricerUtil.dividendYieldOutput(dividendCurveInput, riskFreeRate, option.Dividends, spot, market.ValuationDate, trade.ExerciseDates.Last(), option.DayCount); var dividendRate = AnalyticalOptionPricerUtil.dividenRate(trade.UnderlyingProductType, dividendInput, riskFreeRate); var BSCalculator = new BlackScholeCalculator(trade.OptionType, strike: option.IsMoneynessOption? trade.Strike * trade.InitialSpotPrice: trade.Strike, spotPrice: spot, sigma: sigma, riskfreeRateAtExercise: riskfreeRateAtExercise, riskfreeRateAtMaturity: riskfreeRateAtMaturity, curveDayCount: market.DiscountCurve.Value.DayCount, dividendRate: dividendRate, maturityDate: trade.UnderlyingMaturityDate, //maturity of underlying, i.e. option on futures exerciseDate: trade.ExerciseDates.Last(), valuationDate: market.ValuationDate, trade: trade, underlyingInstrumentType: trade.UnderlyingProductType, notional: trade.Notional, expiryDayRemainingLife: expiryDayRemainingLife, timeIncrement: timeIncrement); _calculator = BSCalculator; return(BSCalculator); }
public SolveBlackScholesExpiry(BlackScholeCalculator calculator, double targetPremium) { this.bs = calculator; this.target = targetPremium; }