Optimize Jamshidian root finding - #2664
Conversation
|
Thanks! May you work out the math a bit more in the comments in the code? |
For exercise time (t_e), value time (T_0), and fixed-payment time (T_i), The bond-price ratio used in Jamshidian’s root finder is therefore Thus, the ratio has the exact exponential-affine form Evaluating it at (r=0) and (r=1) gives Therefore, for any rate (r), This corresponds to the precomputation in the PR: discountRatios_[i] = R_i(0);
rateCoefficients_[i] = std::log(R_i(1) / R_i(0));Each root-function evaluation then uses discountBondRatio(i, r) = discountRatios_[i] * std::exp(rateCoefficients_[i] * r);Jamshidian’s root equation itself is unchanged: If Brent performs (E) evaluations for (m) fixed-leg cash flows, the previous implementation makes approximately calls to The new implementation makes only |
Optimize
JamshidianSwaptionEngineby caching affine discount-bond ratio coefficients before running the Brent root solver.I already patched my engine and works pretty well.
For a one-factor affine model, each discount-bond ratio has the form:
P(t,T,x) / P(t,S,x) = c * exp(d * x)The coefficients are now computed once from rates 0 and 1. Root evaluations therefore require only an exponential instead of repeatedly calling the model for every cash flow.
The cached ratios are also reused when calculating the final bond-option strikes.
Local benchmark using 20,000 recalculations of a 5Y×10Y Hull–White European swaption: