public void MakeDeltaGamma(Tree SpotT, Pricer PriceT, ZeroCurve myZero, DivList myDiv) { SetParam(SpotT, PriceT); Tree treeD = new Tree { Gridsteps = Gridsteps + 2, Spot = spot, Sig = sig, Tau = tau * (1 + 2 / Gridsteps) }; treeD.MakeGrid(myZero, myDiv); PriceT.MakeGrid(treeD); double[] S = new double[3]; double[] C = new double[3]; for (int i = 0; i <= 2; ++i) { S[i] = treeD.GetSpotMatrix(2, i); C[i] = PriceT.Get_PriceMatrix(2, i); } Delta = (S[0] * (2 * S[1] - S[0]) * (C[1] - C[2]) + (S[1] * S[1]) * (C[2] - C[0]) + S[2] * (2 * S[1] - S[2]) * (C[0] - C[1])) / (S[1] - S[0]) / (S[2] - S[0]) / (S[2] - S[1]); Gamma = 2 * (S[0] * (C[1] - C[2]) + S[1] * (C[2] - C[0]) + S[2] * (C[0] - C[1])) / (S[1] - S[0]) / (S[2] - S[0]) / (S[2] - S[1]); }
public void MakeTheta(Tree SpotT, Pricer PriceT, ZeroCurve myZero, DivList myDiv) { SetParam(SpotT, PriceT); Tree T1 = new Tree(), T2 = new Tree(); T1.Tau = tau; T1.Gridsteps = Gridsteps; T1.Sig = sig; T1.Spot = spot; T1.MakeGrid(myZero, myDiv); PriceT.MakeGrid(T1); double P1 = PriceT.Price(); double t = tau - 1.00 / 365.00; T2.Tau = t; T2.Gridsteps = Gridsteps; T2.Sig = sig; T2.Spot = spot; T2.MakeGrid(myZero, myDiv); PriceT.MakeGrid(T2); double P2 = PriceT.Price(); Theta = (P2 - P1); }
public void MakeVega(Tree SpotT, Pricer PriceT, ZeroCurve myZero, DivList myDiv) { SetParam(SpotT, PriceT); Tree T1 = new Tree(), T2 = new Tree(); T1.Tau = tau; T1.Gridsteps = Gridsteps; T1.Sig = .99 * sig; T1.Spot = spot; T1.MakeGrid(myZero, myDiv); PriceT.MakeGrid(T1); double P1 = PriceT.Price(); T2.Tau = tau; T2.Gridsteps = Gridsteps; T2.Sig = 1.01 * sig; T2.Spot = spot; T2.MakeGrid(myZero, myDiv); PriceT.MakeGrid(T2); double P2 = PriceT.Price(); if (sig != 0) { Vega = 0.01 * (P2 - P1) / (2 * 0.01 * sig); } }
private void SetParam(Tree SpotT, Pricer PriceT) { if ((SpotT != null) && (PriceT != null)) { Gridsteps = SpotT.Gridsteps; tau = SpotT.Tau; sig = SpotT.Sig; spot = SpotT.Spot; Strike = PriceT.Strike; Style = PriceT.Style; Payoff = PriceT.Payoff; Smoothing = PriceT.Smoothing; } }
public static double FindPrice(ZeroCurve myZero, DivList myDiv, OrcWingVol myVol, double t, double strike, double spot, string style, string paystyle, double gridsteps) { //get the atfwd double atFwd = GetATMfwd(myZero, myDiv, spot, t); //set up the tree var myTree = new Tree(); int nGridsteps = (gridsteps < 20.0) ? 20 : Convert.ToInt32(gridsteps); myTree.Gridsteps = nGridsteps; myTree.Tau = t; myTree.Sig = myVol.orcvol(atFwd, strike); myTree.Spot = spot; myTree.MakeGrid(myZero, myDiv); //create pricer var myPrice = new Pricer { Strike = strike, Payoff = paystyle, Smoothing = "y", Style = style }; myPrice.MakeGrid(myTree); double pr = myPrice.Price(); return(pr); }