Skip to content

Commit

Permalink
Allow determination of whether an IBOR coupon has fixed as of a certa…
Browse files Browse the repository at this point in the history
…in date
  • Loading branch information
tomwhoiscontrary committed Sep 8, 2023
1 parent aa86428 commit 404d876
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
30 changes: 18 additions & 12 deletions ql/cashflows/iborcoupon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,29 @@ namespace QuantLib {
return spanningTimeIndexMaturity_;
}

bool IborCoupon::hasFixed() const {
Date today = QuantLib::Settings::instance().evaluationDate();
bool IborCoupon::hasFixed(Date refDate) const {
if (refDate == Date()) {
refDate = QuantLib::Settings::instance().evaluationDate();
}

if (fixingDate_ > today) {
if (fixingDate_ > refDate) {
return false;
} else if (fixingDate_ < today) {
} else if (fixingDate_ < refDate) {
return true;
} else {
// fixingDate_ == today
if (QuantLib::Settings::instance().enforcesTodaysHistoricFixings()) {
return true;
} else {
try {
return index_->pastFixing(fixingDate_) != Null<Real>();
} catch (const Error&) {
return false; // fall through and forecast
// fixingDate_ == refDate
if (refDate == QuantLib::Settings::instance().evaluationDate()) {
if (QuantLib::Settings::instance().enforcesTodaysHistoricFixings()) {
return true;
} else {
try {
return index_->pastFixing(fixingDate_) != Null<Real>();
} catch (const Error&) {
return false; // fall through and forecast
}
}
} else {
return false;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ql/cashflows/iborcoupon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace QuantLib {
//@{
const ext::shared_ptr<IborIndex>& iborIndex() const { return iborIndex_; }
//@}
bool hasFixed() const;
bool hasFixed(Date refDate = Date()) const;
//! \name FloatingRateCoupon interface
//@{
// implemented in order to manage the case of par coupon
Expand Down

0 comments on commit 404d876

Please sign in to comment.