inline DiscountFactor ForwardRateStructure::discountImpl(Time t) const { if (t == 0.0) // this acts as a safe guard in cases where return 1.0; // zeroYieldImpl(0.0) would throw. Rate r = zeroYieldImpl(t); return DiscountFactor(std::exp(-r*t)); }
/// Computation of the payoff at the final time of the tree (ie the option maturity) static void BermudianSwaption_InitialPayoffHW1D(int swaption_start, TreeHW1dG* Meth, ModelHW1dG* HW1dG_Parameters, ZCMarketData* ZCMarket, PnlVect* OptionPriceVect2, NumFunc_1 *p, double periodicity,double contract_maturity, double SwaptionFixedRate) { double sigma; int jminprev, jmaxprev; // jmin[i], jmax [i] int i,j; double delta_x1; // delta_x1 = space step of the process x at time i double delta_t1; // time step double ZCPrice, SumZC; double current_rate; int NumberOfPayments; double Ti; ZCPrice = 0.0; ///** Calcul du vecteur des payoffs a l'instant de maturite de l'option jminprev = pnl_vect_int_get(Meth->Jminimum, swaption_start); // jmin(swaption_start) jmaxprev = pnl_vect_int_get(Meth->Jmaximum, swaption_start); // jmax(swaption_start) pnl_vect_resize(OptionPriceVect2, jmaxprev-jminprev+1); delta_t1 = GET(Meth->t, swaption_start) - GET(Meth->t,swaption_start-1); sigma = Current_VolatilityHW1dG(HW1dG_Parameters, GET(Meth->t, swaption_start)); delta_x1 = SpaceStepHW1dG(delta_t1, sigma);//SpaceStepHW1dG(delta_t1, a, sigma); NumberOfPayments = (int) floor((contract_maturity-GET(Meth->t, swaption_start) )/periodicity + 0.2); p->Par[0].Val.V_DOUBLE = 1.0; for( j = jminprev ; j<=jmaxprev ; j++) { current_rate = j * delta_x1 + GET(Meth->alpha, swaption_start); // rate(Ngrid, j ) SumZC = 0; for(i=1; i<=NumberOfPayments; i++) { Ti = GET(Meth->t, swaption_start) + i*periodicity; ZCPrice = DiscountFactor(ZCMarket, HW1dG_Parameters, GET(Meth->t, swaption_start), Ti, current_rate); SumZC += ZCPrice; } LET(OptionPriceVect2, j-jminprev) = ((p->Compute)(p->Par, periodicity * SwaptionFixedRate * SumZC + ZCPrice)); } }