private void MakeDivArray(ZeroCurve myZero, DivList myDivList) { double dt = Tau / GridSteps; if ((myDivList != null) && (myZero != null)) { for (int idx = 0; idx < GridSteps; idx++) { double temp = 0.0; for (int kdx = 0; kdx < myDivList.Divpoints; kdx++) { if ((myDivList.GetT(kdx) > idx * dt) && (myDivList.GetT(kdx) < Tau)) { temp += myDivList.GetD(kdx) * Math.Exp(-myZero.ForwardRate(idx * dt, myDivList.GetT(kdx)) * (myDivList.GetT(kdx) - idx * dt)); } } SetDividends(idx, temp, dt * idx); } } else //missing either div or zero, load in 0 for _div on tree { for (int idx = 0; idx <= GridSteps; idx++) { SetDividends(idx, 0.0, dt * idx); } } }
public static double GetATMfwd(ZeroCurve myZero, DivList myDivList, double spot, double t) { double spotStart = spot; //compute the discounted dividends and take off spot if ((myDivList != null) && (myZero != null)) { for (int idx = 0; idx < myDivList.Divpoints; idx++) { if (myDivList.GetT(idx) <= t) { double d1 = myDivList.GetD(idx); double r1 = myZero.LinInterp(myDivList.GetT(idx)); double t1 = Math.Exp(-r1 * myDivList.GetT(idx)); spotStart -= d1 * t1; } } } //gross up to expiry to get atfwd if (myZero != null) { double r = myZero.LinInterp(t); return(spotStart * Math.Exp(r * t)); } return(0); }
//compute Sstar for the BC's private double ComputeDiscDiv(double tTemp, double T, ZeroCurve myZero, DivList mydiv) { double temp = 0.0; for (int idx = 0; idx < mydiv.Divpoints; idx++) { if ((tTemp < mydiv.GetT(idx)) && (mydiv.GetT(idx) < T)) { double fwdRate = myZero.ForwardRate(tTemp, mydiv.GetT(idx)); temp += mydiv.GetD(idx) * Math.Exp(-fwdRate * (mydiv.GetT(idx) - tTemp)); } } return temp; }
//determine if dt needs adjusted because a div occurs in proposed interval private double CheckBetweenDiv(double t1, double t2, ref double discDiv, DivList myDiv) //t1 & t2 are real times { double temp = t2-t1; for (int idx = 0; idx < myDiv.Divpoints; idx++) { if ((t1 <= myDiv.GetT(idx)) && (t2 > myDiv.GetT(idx))) { temp = t2 - myDiv.GetT(idx); discDiv = myDiv.GetD(idx); break; } } return temp; }
private void MakeSpotStar(ZeroCurve myZero, DivList myDivList) { SpotStart = Spot; if ((myDivList != null) && (myZero != null)) { for (int idx = 0; idx < myDivList.Divpoints; idx++) { if (myDivList.GetT(idx) <= Tau) { double d1 = myDivList.GetD(idx); double r1 = myZero.LinInterp(myDivList.GetT(idx)); double t1 = Math.Exp(-r1 * myDivList.GetT(idx)); SpotStart -= d1 * t1; } } } }