Skip to content

Commit

Permalink
Expose swap() on DatedOISRateHelper (#2097)
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio authored Oct 16, 2024
2 parents 6e125f2 + 3f00ac4 commit 065e2c7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ql/experimental/termstructures/basisswapratehelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ namespace QuantLib {

Real impliedQuote() const override;
void accept(AcyclicVisitor&) override;
// NOLINTNEXTLINE(cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
ext::shared_ptr<Swap> swap() const { return swap_; }
private:
void initializeDates() override;
void setTermStructure(YieldTermStructure*) override;
Expand Down Expand Up @@ -94,6 +96,8 @@ namespace QuantLib {

Real impliedQuote() const override;
void accept(AcyclicVisitor&) override;
// NOLINTNEXTLINE(cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
ext::shared_ptr<Swap> swap() const { return swap_; }
private:
void initializeDates() override;
void setTermStructure(YieldTermStructure*) override;
Expand Down
7 changes: 3 additions & 4 deletions ql/termstructures/yield/oisratehelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace QuantLib {

Date lastPaymentDate = std::max(swap_->overnightLeg().back()->date(),
swap_->fixedLeg().back()->date());
latestRelevantDate_ = std::max(maturityDate_, lastPaymentDate);
latestRelevantDate_ = latestDate_ = std::max(maturityDate_, lastPaymentDate);

switch (pillarChoice_) {
case Pillar::MaturityDate:
Expand All @@ -135,8 +135,6 @@ namespace QuantLib {
default:
QL_FAIL("unknown Pillar::Choice(" << Integer(pillarChoice_) << ")");
}

latestDate_ = std::max(swap_->maturityDate(), lastPaymentDate);
}

void OISRateHelper::setTermStructure(YieldTermStructure* t) {
Expand Down Expand Up @@ -233,9 +231,10 @@ namespace QuantLib {
setCouponPricer(swap_->overnightLeg(), pricer);

earliestDate_ = swap_->startDate();
maturityDate_ = swap_->maturityDate();
Date lastPaymentDate = std::max(swap_->overnightLeg().back()->date(),
swap_->fixedLeg().back()->date());
latestDate_ = std::max(swap_->maturityDate(), lastPaymentDate);
latestRelevantDate_ = latestDate_ = std::max(maturityDate_, lastPaymentDate);
}

DatedOISRateHelper::DatedOISRateHelper(const Date& startDate,
Expand Down
6 changes: 6 additions & 0 deletions ql/termstructures/yield/oisratehelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ namespace QuantLib {
Real impliedQuote() const override;
void setTermStructure(YieldTermStructure*) override;
//@}
//! \name inspectors
//@{
// NOLINTNEXTLINE(cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
ext::shared_ptr<OvernightIndexedSwap> swap() const { return swap_; }
//@}
//@}
//! \name Visitability
//@{
void accept(AcyclicVisitor&) override;
Expand Down

0 comments on commit 065e2c7

Please sign in to comment.