Skip to content

Commit

Permalink
Simplify getting the fixing for an IBOR coupon by first checking if i…
Browse files Browse the repository at this point in the history
…t has fixed or not
  • Loading branch information
tomwhoiscontrary committed Jun 14, 2024
1 parent 33fcd31 commit f9c5f08
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions ql/cashflows/iborcoupon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,34 +114,15 @@ namespace QuantLib {
1) allows to save date/time recalculations, and
2) takes into account par coupon needs
*/
Date today = QuantLib::Settings::instance().evaluationDate();

if (fixingDate_>today)
return iborIndex_->forecastFixing(fixingValueDate_,
fixingEndDate_,
spanningTime_);

if (fixingDate_<today ||
QuantLib::Settings::instance().enforcesTodaysHistoricFixings()) {
// do not catch exceptions
if (hasFixed()) {
Rate result = index_->pastFixing(fixingDate_);
QL_REQUIRE(result != Null<Real>(),
"Missing " << index_->name() << " fixing for " << fixingDate_);
return result;
} else {
return iborIndex_->forecastFixing(fixingValueDate_, fixingEndDate_, spanningTime_);
}

try {
Rate result = index_->pastFixing(fixingDate_);
if (result!=Null<Real>())
return result;
else
; // fall through and forecast
} catch (Error&) {
; // fall through and forecast
}
return iborIndex_->forecastFixing(fixingValueDate_,
fixingEndDate_,
spanningTime_);
}

void IborCoupon::setPricer(const ext::shared_ptr<FloatingRateCouponPricer>& pricer) {
Expand Down

0 comments on commit f9c5f08

Please sign in to comment.