public void TestExtrapolate2() { IStock stockASXParent = LoadStock("AGK"); IStock stockASXChild = LoadStock("ANZ"); IStock stockSDParent = LoadStock("BHP"); IVolatilitySurface child = CreateNullVolSurface(); ExtrapolationHelper extrapHelper = new ExtrapolationHelper(); double factor = 0.314843 / 0.290393; double parentVol1 = 0.394634; double scal = extrapHelper.CalcExtrapFactor(stockASXParent, stockASXChild, new DateTime(2009, 9, 30)); Assert.AreEqual(scal, factor, 0.001); double parentVol2 = 0.38754555; double parentVol3 = 0.71063645; if (stockASXParent.VolatilitySurface.Expiries[0].Strikes[0].InterpModel.GetType() == typeof(WingInterp)) { extrapHelper.DoExtrap(stockASXParent, stockASXChild, stockSDParent, child); //moneyness = 0.3; Assert.AreEqual(Convert.ToDouble(child.NodalExpiries[2].Strikes[0].Volatility.Value), factor * parentVol3, 0.001); //moneyness = 1.0; Assert.AreEqual(Convert.ToDouble(child.NodalExpiries[2].Strikes[1].Volatility.Value), factor * parentVol1, 0.001); //moneyness = 1.2; Assert.AreEqual(Convert.ToDouble(child.NodalExpiries[2].Strikes[2].Volatility.Value), factor * parentVol2, 0.001); } }
public void TestGetVolWithTimeInterp() { IStock stockASXParent = LoadStock("AGK"); ExtrapolationHelper extrapHelper = new ExtrapolationHelper(); double vol0 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 30), 0.05); double vol1 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 30), 1.00); double vol2 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 30), 2.00); //Extrap below Assert.AreEqual(0.592322, vol0, 0.001); Assert.AreEqual(0.290393, vol1, 0.001); Assert.AreEqual(0.360499, vol2, 0.001); }
public void TestExtrapolate3() { IStock stockASXParent = LoadStock("AGK"); IStock stockASXChild = LoadStock("ANZ"); IStock stockSDParent = LoadStock("BHP"); IVolatilitySurface child = CreateOnePointChild(); ExtrapolationHelper extrapHelper = new ExtrapolationHelper(); double scal = extrapHelper.CalcExtrapFactor(stockASXParent, stockASXChild, new DateTime(2009, 9, 10)); Assert.AreEqual(scal, 1.05239899198348, 0.001); //OLD 0.314301/0.298668 //1.06102304848855 extrapHelper.DoExtrap(stockASXParent, stockASXChild, stockSDParent, child); Assert.AreEqual(Convert.ToDouble(child.Expiries[0].Strikes[0].Volatility.Value), 0.997545918986369, 0.001); //0.930043543995147 }
public void TestExtrapolate1() { IStock stockASXParent = LoadStock("AGK"); IStock stockASXChild = LoadStock("ANZ"); IStock stockSDParent = LoadStock("AGK"); IVolatilitySurface child = CreateTestVolSurface(); ExtrapolationHelper extrapHelper = new ExtrapolationHelper(); if (stockASXParent.VolatilitySurface.Expiries[0].Strikes[0].InterpModel.GetType() == typeof(WingInterp)) { extrapHelper.DoExtrap(stockASXParent, stockASXChild, stockSDParent, child); Assert.AreEqual(Convert.ToDouble(child.NodalExpiries[0].Strikes[0].Volatility.Value), 0.295126142, 0.0001); } }
public void TestHistoricalExtrapolate() { IStock stockASXParent = LoadStock("AGK"); IVolatilitySurface stockASXChild = CreateNullVolSurface(); IVolatilitySurface targetChild = CreateNullVolSurface(); IStock stockSDParent = LoadStock("AGK"); stockASXParent.Valuations.Add(new Valuation(new DateTime(2008, 8, 28), 1208)); stockASXParent.Valuations.Add(new Valuation(new DateTime(2008, 8, 29), 1221)); stockASXParent.Valuations.Add(new Valuation(new DateTime(2008, 8, 30), 1218)); stockASXParent.Valuations.Add(new Valuation(new DateTime(2008, 8, 31), 1207)); stockASXParent.Valuations.Add(new Valuation(new DateTime(2008, 9, 1), 1250)); RateCurve rateCurve = CreateRateCurve(); List <Dividend> divCurve = CreateDividends(); IStock nullASXChild = new Stock(new DateTime(2009, 9, 9), 200.0M, "ZZZ", "ZZZ", rateCurve, divCurve); nullASXChild.VolatilitySurface = stockASXChild; nullASXChild.Valuations.Add(new Valuation(new DateTime(2008, 12, 12), 208)); nullASXChild.Valuations.Add(new Valuation(new DateTime(2008, 12, 13), 221)); nullASXChild.Valuations.Add(new Valuation(new DateTime(2008, 12, 14), 218)); nullASXChild.Valuations.Add(new Valuation(new DateTime(2008, 12, 15), 207)); nullASXChild.Valuations.Add(new Valuation(new DateTime(2008, 12, 16), 201)); ExtrapolationHelper extrap = new ExtrapolationHelper(); decimal histvol1 = extrap.DoHistVolCalc(stockASXParent); decimal histvol2 = extrap.DoHistVolCalc(nullASXChild); Assert.AreEqual(0.375846, Convert.ToDouble(histvol1), 0.0001); Assert.AreEqual(0.770018, Convert.ToDouble(histvol2), 0.0001); extrap.PopulateHistoricalVols(stockASXParent, nullASXChild, targetChild); double scalFactor = Convert.ToDouble(extrap.GetHistoricalScalFactor(stockASXParent, nullASXChild)); Assert.AreEqual(scalFactor, 2.0487573, 0.0001); //Spreadsheet fit SD parent to (5d, 1.000 * F) point, flatline endpoints. decimal SDParentVol0 = 0.296175M; // Spreadsheet fit SD parent to (7d,0.867 * F) point decimal SDParentVol1 = 0.320240M; // Spreadsheet fit SD parent to (21d,1.00 * F) point decimal SDParentVol2 = 0.287656M; double childExtrapVol0 = scalFactor * Convert.ToDouble(SDParentVol0); double childExtrapVol1 = scalFactor * Convert.ToDouble(SDParentVol1); double childExtrapVol2 = scalFactor * Convert.ToDouble(SDParentVol2); Assert.AreEqual(Convert.ToDouble(SDParentVol0 * histvol2 / histvol1), childExtrapVol0, 0.001); Assert.AreEqual(Convert.ToDouble(SDParentVol1 * histvol2 / histvol1), childExtrapVol1, 0.001); Assert.AreEqual(Convert.ToDouble(SDParentVol2 * histvol2 / histvol1), childExtrapVol2, 0.001); }
public void TestGetVol() { IStock stockASXParent = LoadStock("AGK"); ExtrapolationHelper extrapHelper = new ExtrapolationHelper(); double vol0 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 16), 0.05); double vol1 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 16), 0.60); double vol2 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 16), 0.80); double vol3 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 16), 1.00); double vol4 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 16), 2.00); double vol5 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 16), 3.00); //Extrap below Assert.AreEqual(0.6413, vol0, 0.001); Assert.AreEqual(0.5950, vol1, 0.001); Assert.AreEqual(0.3545, vol2, 0.001); Assert.AreEqual(0.2962, vol3, 0.001); Assert.AreEqual(0.3765, vol4, 0.001); //Extrap above Assert.AreEqual(0.3765, vol5, 0.001); }