public void DeltaStrikeMappingFacts() { var today = DateTime.Parse("2017-02-07"); var expiry = DateTime.Parse("2017-12-06"); var delivery = DateTime.Parse("2017-12-20"); var tExp = DayCountBasis.Act_365F.CalculateYearFraction(today, expiry); var tDel = DayCountBasis.Act_365F.CalculateYearFraction(today, delivery); var k = 100; var f = 100; var vol = 0.32; var cp = OptionType.P; //black forward delta matches var delta = LMEFunctions.LMEBlackDelta(f, k, tExp, vol, cp); var absolute = LMEFunctions.AbsoluteStrikefromDeltaKAnalytic(f, delta, tExp, vol); Assert.Equal(k, absolute, 10); }
public void DeltaGammaFacts() { var today = DateTime.Parse("2017-02-07"); var expiry = DateTime.Parse("2017-12-06"); var delivery = DateTime.Parse("2017-12-20"); var tExp = DayCountBasis.Act_365F.CalculateYearFraction(today, expiry); var tDel = DayCountBasis.Act_365F.CalculateYearFraction(today, delivery); var k = 100; var f = 100; var vol = 0.32; var rf = 0.05; var cp = OptionType.P; //delta closely matches numerical estimate var PV1 = LMEFunctions.LMEBlackPV(f + 0.000005, k, rf, tExp, tDel, vol, cp); var PV2 = LMEFunctions.LMEBlackPV(f - 0.000005, k, rf, tExp, tDel, vol, cp); var deltaEst = System.Math.Exp(tDel * rf) * (PV1 - PV2) / 0.00001; //undiscount the delta var delta = LMEFunctions.LMEBlackDelta(f, k, tExp, vol, cp); Assert.Equal(deltaEst, delta, 6); //zero-strike call has fwd delta of 1.0 k = 0; cp = OptionType.C; delta = LMEFunctions.LMEBlackDelta(f, k, tExp, vol, cp); Assert.Equal(1.0, delta, 10); //put-call parity k = 100; var deltaCall = LMEFunctions.LMEBlackDelta(f, k, tExp, vol, OptionType.C); var deltaPut = LMEFunctions.LMEBlackDelta(f, k, tExp, vol, OptionType.P); var syntheticFwdDelta = deltaCall - deltaPut; Assert.Equal(1.0, syntheticFwdDelta, 10); //gamma closely matches numerical estimate var delta1 = LMEFunctions.LMEBlackDelta(f + 0.000005, k, tExp, vol, cp); var delta2 = LMEFunctions.LMEBlackDelta(f - 0.000005, k, tExp, vol, cp); var gammaEst = (delta1 - delta2) / 0.00001; var gamma = LMEFunctions.LMEBlackGamma(f, k, tExp, vol); Assert.Equal(gammaEst, gamma, 6); }