private static double Alpha(Bergomi2FModel b2F) { var correl = Correl(b2F); var thetaVect = new[] { 1.0 - b2F.Theta, b2F.Theta }; return(1.0 / Math.Sqrt(correl.BilinearProd(thetaVect, thetaVect))); }
public static double[] AtmfSkewApprox(Bergomi2FModel b2F, double[] maturities) { var alpha = Alpha(b2F); double coeffX = b2F.Nu * alpha * (1.0 - b2F.Theta) * b2F.RhoSX; double coeffY = b2F.Nu * alpha * b2F.Theta * b2F.RhoSY; return(maturities.Map(t => coeffX * DoubleExpInt(b2F.K1, t) + coeffY * DoubleExpInt(b2F.K2, t))); }
public static double[,] FwdVolInstantCovariance(Bergomi2FModel b2F, double[] fwdVolStart, double[] fwdVolEnd) { Debug.Assert(fwdVolStart.Length == fwdVolEnd.Length); var correl = Correl(b2F); var varSwapDeformations = VarSwapDeformation(b2F, fwdVolStart, fwdVolEnd); return(ArrayUtils.CartesianProd(varSwapDeformations, varSwapDeformations, (varSwapDef1, varSwapDef2) => correl.BilinearProd(varSwapDef1, varSwapDef2))); }
public static double[] FwdVolInstantVol(Bergomi2FModel b2F, double[] fwdVolStart, double[] fwdVolEnd) { Debug.Assert(fwdVolStart.Length == fwdVolEnd.Length); var correl = Correl(b2F); var varSwapDeformations = VarSwapDeformation(b2F, fwdVolStart, fwdVolEnd); return(EnumerableUtils.For(0, fwdVolStart.Length, i => { var varSwapDef = varSwapDeformations[i]; return Math.Sqrt(correl.BilinearProd(varSwapDef, varSwapDef)); })); }
private static double[][] VarSwapDeformation(Bergomi2FModel b2F, double[] fwdVolStart, double[] fwdVolEnd) { Debug.Assert(fwdVolStart.Length == fwdVolEnd.Length); var initCurve = b2F.Xi.Integral(0.0); var factor1 = (b2F.Xi * RrFunctions.Exp(-b2F.K1)).Integral(0.0); var factor2 = (b2F.Xi * RrFunctions.Exp(-b2F.K2)).Integral(0.0); var alpha = Alpha(b2F); return(EnumerableUtils.For(0, fwdVolStart.Length, i => { double volMatStart = fwdVolStart[i]; double volMatEnd = fwdVolEnd[i]; double initFwdVariance = initCurve.Eval(volMatEnd) - initCurve.Eval(volMatStart); double def1 = factor1.Eval(volMatEnd) - factor1.Eval(volMatStart); double def2 = factor2.Eval(volMatEnd) - factor2.Eval(volMatStart); return new[] { (1.0 - b2F.Theta) * def1, b2F.Theta * def2 }.Mult(b2F.Nu * alpha / initFwdVariance); })); }
private static double[,] Correl(Bergomi2FModel b2F) { return(new[, ] { { 1.0, b2F.RhoXY }, { b2F.RhoXY, 1.0 } }); }