Skip to content

Commit

Permalink
Precompute annuities
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorTurintech committed May 6, 2024
1 parent 41b7ddc commit 5f3b8e0
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,19 @@ namespace QuantLib {
// assuming terminal bond measure
// eq 5.4-5.7
const std::vector<Time>& taus=cs.rateTaus();
std::vector<Real> annuities(numberOfRates_);

for (Size j=0; j<numberOfRates_; ++j) {
annuities[j] = cs.coterminalSwapAnnuity(numberOfRates_, j);
}
for (Size k=0; k<numberOfFactors_; ++k) {
// taken care in the constructor
// wkpj1_[k][numberOfRates_-1]= 0.0;
// wkaj_[k][numberOfRates_-1] = 0.0;
for (Integer j=numberOfRates_-2; j>=static_cast<Integer>(alive_)-1; --j) {
// < W(k) | P(j+1)/P(n) > =
// = SR(j+1) a(j+1,k) A(j+1) / P(n) + SR(j+1) < W(k) | A(j+1)/P(n) >
Real annuity = cs.coterminalSwapAnnuity(numberOfRates_,j+1);
Real annuity = annuities[j+1];
wkpj_[k][j+1]= SR[j+1] *
( pseudo_[j+1][k] * annuity + wkaj_[k][j+1] )+
pseudo_[j+1][k]*displacements_[j+1]* annuity;
Expand Down

0 comments on commit 5f3b8e0

Please sign in to comment.