Skip to content

Commit

Permalink
Avoid interpolation if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Sep 16, 2024
1 parent 3e2f9e0 commit 6de585e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ql/indexes/inflationindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ namespace QuantLib {
QL_REQUIRE(YY0 != Null<Rate>(),
"Missing " << name() << " fixing for " << periodStart);

if (interpolated()) { // NOT ratio, IS interpolated
if (!interpolated() || /* degenerate case */ fixingDate == periodStart) {

return YY0;

} else {

Real dp = periodEnd + 1 - periodStart;
Real dl = fixingDate - periodStart;
Expand All @@ -271,10 +275,6 @@ namespace QuantLib {
"Missing " << name() << " fixing for " << periodEnd+1);
return YY0 + (YY1 - YY0) * dl / dp;

} else { // NOT ratio, NOT interpolated

return YY0;

}
}
}
Expand Down

0 comments on commit 6de585e

Please sign in to comment.