Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
FixingDateGetter Class Reference

#include <ored/portfolio/fixingdates.hpp>

+ Inheritance diagram for FixingDateGetter:
+ Collaboration diagram for FixingDateGetter:

Public Member Functions

 FixingDateGetter (RequiredFixings &requiredFixings)
 Constructor. More...
 

Visitor interface

RequiredFixingsrequiredFixings_
 
bool requireFixingStartDates_ = false
 
QuantLib::ext::shared_ptr< QuantExt::FxIndexadditionalFxIndex_
 
void visit (QuantLib::CashFlow &c) override
 
void visit (QuantLib::FloatingRateCoupon &c) override
 
void visit (QuantLib::IborCoupon &c) override
 
void visit (QuantLib::CappedFlooredCoupon &c) override
 
void visit (QuantLib::IndexedCashFlow &c) override
 
void visit (QuantLib::CPICashFlow &c) override
 
void visit (QuantLib::CPICoupon &c) override
 
void visit (QuantLib::YoYInflationCoupon &c) override
 
void visit (QuantExt::NonStandardYoYInflationCoupon &c) override
 
void visit (QuantLib::OvernightIndexedCoupon &c) override
 
void visit (QuantExt::OvernightIndexedCoupon &c) override
 
void visit (QuantExt::CappedFlooredOvernightIndexedCoupon &c) override
 
void visit (QuantLib::AverageBMACoupon &c) override
 
void visit (QuantExt::CappedFlooredAverageBMACoupon &c) override
 
void visit (QuantLib::CmsSpreadCoupon &c) override
 
void visit (QuantLib::DigitalCoupon &c) override
 
void visit (QuantLib::StrippedCappedFlooredCoupon &c) override
 
void visit (QuantExt::AverageONIndexedCoupon &c) override
 
void visit (QuantExt::CappedFlooredAverageONIndexedCoupon &c) override
 
void visit (QuantExt::EquityCoupon &c) override
 
void visit (QuantExt::FloatingRateFXLinkedNotionalCoupon &c) override
 
void visit (QuantExt::FXLinkedCashFlow &c) override
 
void visit (QuantExt::AverageFXLinkedCashFlow &c) override
 
void visit (QuantExt::SubPeriodsCoupon1 &c) override
 
void visit (QuantExt::IndexedCoupon &c) override
 
void visit (QuantExt::IndexWrappedCashFlow &c) override
 
void visit (QuantExt::CmbCoupon &c) override
 
void visit (QuantExt::EquityMarginCoupon &c) override
 
void visit (QuantExt::CommodityCashFlow &c) override
 
void visit (QuantExt::BondTRSCashFlow &c) override
 
void visit (QuantExt::TRSCashFlow &c) override
 
void setRequireFixingStartDates (const bool b)
 
void setAdditionalFxIndex (const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &i)
 
std::string oreIndexName (const std::string &qlIndexName) const
 

Detailed Description

Helper Class that gets relevant fixing dates from coupons and add them to a RequiredFixings instance.

Each type of FloatingRateCoupon that we wish to cover should be added here and a visit method implemented against it.

Definition at line 260 of file fixingdates.hpp.

Constructor & Destructor Documentation

◆ FixingDateGetter()

FixingDateGetter ( RequiredFixings requiredFixings)

Constructor.

Definition at line 295 of file fixingdates.hpp.

295: requiredFixings_(requiredFixings) {}
RequiredFixings & requiredFixings_

Member Function Documentation

◆ visit() [1/31]

void visit ( QuantLib::CashFlow &  c)
override

◆ visit() [2/31]

void visit ( QuantLib::FloatingRateCoupon &  c)
override

◆ visit() [3/31]

void visit ( QuantLib::IborCoupon &  c)
override

◆ visit() [4/31]

void visit ( QuantLib::CappedFlooredCoupon &  c)
override

◆ visit() [5/31]

void visit ( QuantLib::IndexedCashFlow &  c)
override

◆ visit() [6/31]

void visit ( QuantLib::CPICashFlow &  c)
override

Not added in QuantLib so will never be hit automatically! Managed by passing off from IndexedCashFlow.

◆ visit() [7/31]

void visit ( QuantLib::CPICoupon &  c)
override

◆ visit() [8/31]

void visit ( QuantLib::YoYInflationCoupon &  c)
override

◆ visit() [9/31]

void visit ( QuantExt::NonStandardYoYInflationCoupon c)
override

Definition at line 657 of file fixingdates.cpp.

657 {
658
659 bool isInterpolated = c.isInterpolated();
661 c.fixingDateNumerator(), IndexNameTranslator::instance().oreName(c.cpiIndex()->name()), isInterpolated,
662 c.cpiIndex()->frequency(), c.cpiIndex()->availabilityLag(), CPI::Flat, c.cpiIndex()->frequency(), c.date());
664 c.fixingDateDenumerator(), IndexNameTranslator::instance().oreName(c.cpiIndex()->name()), isInterpolated,
665 c.cpiIndex()->frequency(), c.cpiIndex()->availabilityLag(), CPI::Flat, c.cpiIndex()->frequency(), c.date());
666}
virtual Date fixingDateNumerator() const
virtual ext::shared_ptr< ZeroInflationIndex > cpiIndex() const
virtual Date fixingDateDenumerator() const
void addZeroInflationFixingDate(const QuantLib::Date &fixingDate, const std::string &indexName, const bool indexInterpolated, const Frequency indexFrequency, const Period &indexAvailabilityLag, const CPI::InterpolationType coupopnInterpolation, const Frequency couponFrequency, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
+ Here is the call graph for this function:

◆ visit() [10/31]

void visit ( QuantLib::OvernightIndexedCoupon &  c)
override

Definition at line 562 of file fixingdates.cpp.

562 {
563 requiredFixings_.addFixingDates(c.fixingDates(), IndexNameTranslator::instance().oreName(c.index()->name()),
564 c.date());
565}
void addFixingDates(const std::vector< std::pair< QuantLib::Date, bool > > &fixingDates, const std::string &indexName, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false)
+ Here is the call graph for this function:

◆ visit() [11/31]

void visit ( QuantExt::OvernightIndexedCoupon c)
override

Definition at line 567 of file fixingdates.cpp.

567 {
568 auto fallback = QuantLib::ext::dynamic_pointer_cast<FallbackOvernightIndex>(c.index());
569 string indexName;
570 if (fallback && c.fixingDate() >= fallback->switchDate())
571 indexName = fallback->rfrIndex()->name();
572 else
573 indexName = c.index()->name();
574 requiredFixings_.addFixingDates(c.fixingDates(), IndexNameTranslator::instance().oreName(indexName), c.date());
575}
const std::vector< Date > & fixingDates() const
Date fixingDate() const override
+ Here is the call graph for this function:

◆ visit() [12/31]

void visit ( QuantExt::CappedFlooredOvernightIndexedCoupon c)
override

Definition at line 577 of file fixingdates.cpp.

577{ c.underlying()->accept(*this); }
ext::shared_ptr< OvernightIndexedCoupon > underlying() const
+ Here is the call graph for this function:

◆ visit() [13/31]

void visit ( QuantLib::AverageBMACoupon &  c)
override

◆ visit() [14/31]

void visit ( QuantExt::CappedFlooredAverageBMACoupon c)
override

Definition at line 584 of file fixingdates.cpp.

584{ c.underlying()->accept(*this); }
ext::shared_ptr< AverageBMACoupon > underlying() const
+ Here is the call graph for this function:

◆ visit() [15/31]

void visit ( QuantLib::CmsSpreadCoupon &  c)
override

◆ visit() [16/31]

void visit ( QuantLib::DigitalCoupon &  c)
override

◆ visit() [17/31]

void visit ( QuantLib::StrippedCappedFlooredCoupon &  c)
override

◆ visit() [18/31]

void visit ( QuantExt::AverageONIndexedCoupon c)
override

Definition at line 600 of file fixingdates.cpp.

600 {
601 requiredFixings_.addFixingDates(c.fixingDates(), IndexNameTranslator::instance().oreName(c.index()->name()),
602 c.date());
603}
const std::vector< Date > & fixingDates() const
+ Here is the call graph for this function:

◆ visit() [19/31]

void visit ( QuantExt::CappedFlooredAverageONIndexedCoupon c)
override

Definition at line 605 of file fixingdates.cpp.

605{ c.underlying()->accept(*this); }
ext::shared_ptr< AverageONIndexedCoupon > underlying() const
+ Here is the call graph for this function:

◆ visit() [20/31]

void visit ( QuantExt::EquityCoupon c)
override

Definition at line 607 of file fixingdates.cpp.

607 {
608 requiredFixings_.addFixingDates(c.fixingDates(), IndexNameTranslator::instance().oreName(c.equityCurve()->name()),
609 c.date());
610 if (c.fxIndex() != nullptr) {
612 IndexNameTranslator::instance().oreName(c.fxIndex()->name()), c.date());
613 requiredFixings_.addFixingDate(c.fixingEndDate(), IndexNameTranslator::instance().oreName(c.fxIndex()->name()),
614 c.date());
615 }
616}
const boost::shared_ptr< FxIndex > & fxIndex() const
std::vector< Date > fixingDates() const
Date fixingEndDate() const
const boost::shared_ptr< QuantExt::EquityIndex2 > & equityCurve() const
Date fixingStartDate() const
void addFixingDate(const QuantLib::Date &fixingDate, const std::string &indexName, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
+ Here is the call graph for this function:

◆ visit() [21/31]

void visit ( QuantExt::FloatingRateFXLinkedNotionalCoupon c)
override

Definition at line 618 of file fixingdates.cpp.

618 {
619 requiredFixings_.addFixingDate(c.fxFixingDate(), IndexNameTranslator::instance().oreName(c.fxIndex()->name()),
620 c.date());
621 c.underlying()->accept(*this);
622}
const boost::shared_ptr< FxIndex > & fxIndex() const
Date fxFixingDate() const
boost::shared_ptr< FloatingRateCoupon > underlying() const
+ Here is the call graph for this function:

◆ visit() [22/31]

void visit ( QuantExt::FXLinkedCashFlow c)
override

Definition at line 624 of file fixingdates.cpp.

624 {
625 requiredFixings_.addFixingDate(c.fxFixingDate(), IndexNameTranslator::instance().oreName(c.fxIndex()->name()),
626 c.date());
627}
Date date() const override
+ Here is the call graph for this function:

◆ visit() [23/31]

void visit ( QuantExt::AverageFXLinkedCashFlow c)
override

Definition at line 629 of file fixingdates.cpp.

629 {
630 requiredFixings_.addFixingDates(c.fxFixingDates(), IndexNameTranslator::instance().oreName(c.fxIndex()->name()),
631 c.date());
632}
Date date() const override
const boost::shared_ptr< FxIndex > & fxIndex() const
const std::vector< Date > & fxFixingDates() const
+ Here is the call graph for this function:

◆ visit() [24/31]

void visit ( QuantExt::SubPeriodsCoupon1 c)
override

Definition at line 634 of file fixingdates.cpp.

634 {
635 requiredFixings_.addFixingDates(c.fixingDates(), IndexNameTranslator::instance().oreName(c.index()->name()),
636 c.date());
637}
const std::vector< Date > & fixingDates() const
+ Here is the call graph for this function:

◆ visit() [25/31]

void visit ( QuantExt::IndexedCoupon c)
override

Definition at line 639 of file fixingdates.cpp.

639 {
640 // the coupon's index might be null if an initial fixing is provided
641 if (c.index())
642 requiredFixings_.addFixingDate(c.fixingDate(), IndexNameTranslator::instance().oreName(c.index()->name()),
643 c.date());
644 QL_REQUIRE(c.underlying(), "FixingDateGetter::visit(IndexedCoupon): underlying() is null");
645 c.underlying()->accept(*this);
646}
boost::shared_ptr< Coupon > underlying() const
boost::shared_ptr< Index > index() const
const Date & fixingDate() const
+ Here is the call graph for this function:

◆ visit() [26/31]

void visit ( QuantExt::IndexWrappedCashFlow c)
override

Definition at line 648 of file fixingdates.cpp.

648 {
649 // the cf's index might be null if an initial fixing is provided
650 if (c.index())
651 requiredFixings_.addFixingDate(c.fixingDate(), IndexNameTranslator::instance().oreName(c.index()->name()),
652 c.date());
653 QL_REQUIRE(c.underlying(), "FixingDateGetter::visit(IndexWrappedCashFlow): underlying() is null");
654 c.underlying()->accept(*this);
655}
boost::shared_ptr< Index > index() const
boost::shared_ptr< CashFlow > underlying() const
Date date() const override
const Date & fixingDate() const
+ Here is the call graph for this function:

◆ visit() [27/31]

void visit ( QuantExt::CmbCoupon c)
override

Definition at line 668 of file fixingdates.cpp.

668 {
669 requiredFixings_.addFixingDate(c.fixingDate(), IndexNameTranslator::instance().oreName(c.bondIndex()->name()),
670 c.date());
671}
const ext::shared_ptr< ConstantMaturityBondIndex > & bondIndex() const
+ Here is the call graph for this function:

◆ visit() [28/31]

void visit ( QuantExt::EquityMarginCoupon c)
override

Definition at line 673 of file fixingdates.cpp.

673 {
674 requiredFixings_.addFixingDates(c.fixingDates(), IndexNameTranslator::instance().oreName(c.equityCurve()->name()),
675 c.date());
676 if (c.fxIndex() != nullptr)
678 IndexNameTranslator::instance().oreName(c.fxIndex()->name()), c.date());
679}
const boost::shared_ptr< FxIndex > & fxIndex() const
std::vector< Date > fixingDates() const
const boost::shared_ptr< QuantExt::EquityIndex2 > & equityCurve() const
+ Here is the call graph for this function:

◆ visit() [29/31]

void visit ( QuantExt::CommodityCashFlow c)
override

Definition at line 681 of file fixingdates.cpp.

681 {
682 auto indices = c.indices();
683 for (const auto& [pricingDate, index] : indices) {
684 // todays fixing is not mandatory, we will fallback to estimate it if its not there.
685 bool isTodaysFixing = Settings::instance().evaluationDate() == pricingDate;
686 if (auto powerIndex = QuantLib::ext::dynamic_pointer_cast<OffPeakPowerIndex>(index)) {
687 // if powerindex, we need the offpeak index fixing and the peak index fixings
688 requiredFixings_.addFixingDate(pricingDate, powerIndex->offPeakIndex()->name(), c.date(), false,
689 !isTodaysFixing);
690 bool isOffPeakDay = powerIndex->peakCalendar().isHoliday(pricingDate);
691 requiredFixings_.addFixingDate(pricingDate, powerIndex->peakIndex()->name(), c.date(), false,
692 isOffPeakDay && !isTodaysFixing);
693 // if the pricing date is > future expiry, add the future expiry itself as well
694 if (auto d = index->expiryDate(); d != Date() && d < pricingDate) {
695 requiredFixings_.addFixingDate(d, powerIndex->offPeakIndex()->name(), c.date(), false, !isTodaysFixing);
696 requiredFixings_.addFixingDate(d, powerIndex->peakIndex()->name(), c.date(), false,
697 isOffPeakDay && !isTodaysFixing);
698 }
699 } else {
700 requiredFixings_.addFixingDate(pricingDate, index->name(), c.date(), false, !isTodaysFixing);
701 // if the pricing date is > future expiry, add the future expiry itself as well
702 if (auto d = index->expiryDate(); d != Date() && d < pricingDate) {
703 requiredFixings_.addFixingDate(d, index->name(), c.date(), false, !isTodaysFixing);
704 }
705 }
706 if (auto baseFutureIndex = QuantLib::ext::dynamic_pointer_cast<CommodityBasisFutureIndex>(index)) {
707 RequiredFixings tmpFixings;
708 FixingDateGetter baseCashflowGetter(tmpFixings);
709 baseFutureIndex->baseCashflow(c.date())->accept(baseCashflowGetter);
710 auto optionalFixings = tmpFixings.makeCopyWithMandatoryOverride(false);
711 requiredFixings_.addData(optionalFixings);
712 }
713 }
714}
virtual const std::vector< std::pair< QuantLib::Date, ext::shared_ptr< CommodityIndex > > > & indices() const=0
FixingDateGetter(RequiredFixings &requiredFixings)
Constructor.
void addData(const RequiredFixings &requiredFixings)
+ Here is the call graph for this function:

◆ visit() [30/31]

void visit ( QuantExt::BondTRSCashFlow c)
override

Definition at line 716 of file fixingdates.cpp.

716 {
717 if (bc.initialPrice() == Null<Real>() || requireFixingStartDates_) {
718 requiredFixings_.addFixingDate(bc.fixingStartDate(), bc.index()->name(), bc.date());
719 }
720 requiredFixings_.addFixingDate(bc.fixingEndDate(), bc.index()->name(), bc.date());
721 if (bc.fxIndex()) {
722 requiredFixings_.addFixingDate(bc.fxIndex()->fixingCalendar().adjust(bc.fixingStartDate(), Preceding),
723 IndexNameTranslator::instance().oreName(bc.fxIndex()->name()), bc.date());
724 requiredFixings_.addFixingDate(bc.fxIndex()->fixingCalendar().adjust(bc.fixingEndDate(), Preceding),
725 IndexNameTranslator::instance().oreName(bc.fxIndex()->name()), bc.date());
726 }
727}
+ Here is the call graph for this function:

◆ visit() [31/31]

void visit ( QuantExt::TRSCashFlow c)
override

Definition at line 729 of file fixingdates.cpp.

729 {
730 vector<QuantLib::ext::shared_ptr<Index>> indexes;
731 vector<QuantLib::ext::shared_ptr<FxIndex>> fxIndexes;
732
733 if (auto e = QuantLib::ext::dynamic_pointer_cast<QuantExt::CompositeIndex>(bc.index())) {
734 indexes = e->indices();
735 fxIndexes = e->fxConversion();
736
737 // Dividends date can require FX fixings for conversion, add any required fixing
738 std::vector<std::pair<QuantLib::Date, std::string>> fixings =
739 e->dividendFixingDates(bc.fixingStartDate(), bc.fixingEndDate());
740
741 for (const auto& f : fixings)
742 requiredFixings_.addFixingDate(f.first, ore::data::IndexNameTranslator::instance().oreName(f.second));
743 } else {
744 indexes.push_back(bc.index());
745 }
746
747 // always add the top level fxIndex, for a CompositeIndex we may need to convert underlyings to the CompositeIndex
748 // ccy and then to the leg currency
749 fxIndexes.push_back(bc.fxIndex());
751 fxIndexes.push_back(additionalFxIndex_);
752
753 for (const auto& ind : indexes) {
754 if (ind) {
755 auto startDate = ind->fixingCalendar().adjust(bc.fixingStartDate(), Preceding);
756 auto endDate = ind->fixingCalendar().adjust(bc.fixingEndDate(), Preceding);
757
758 auto gi = QuantLib::ext::dynamic_pointer_cast<QuantExt::GenericIndex>(ind);
759
760 if (!gi || gi->expiry() == Date() || startDate < gi->expiry()) {
761 if (bc.initialPrice() == Null<Real>() || requireFixingStartDates_)
762 requiredFixings_.addFixingDate(startDate, IndexNameTranslator::instance().oreName(ind->name()),
763 bc.date());
764 }
765
766 if (!gi || gi->expiry() == Date() || endDate < gi->expiry())
767 requiredFixings_.addFixingDate(endDate, IndexNameTranslator::instance().oreName(ind->name()),
768 bc.date());
769 }
770 }
771
772 for (const auto& fx : fxIndexes) {
773 if (fx) {
774 requiredFixings_.addFixingDate(fx->fixingCalendar().adjust(bc.fixingStartDate(), Preceding),
775 IndexNameTranslator::instance().oreName(fx->name()), bc.date());
776 requiredFixings_.addFixingDate(fx->fixingCalendar().adjust(bc.fixingEndDate(), Preceding),
777 IndexNameTranslator::instance().oreName(fx->name()), bc.date());
778
779 // also add using the underlyingIndex calendar, as FX Conversion is done within a CompositeIndex
780 // for a basket of underlyings
781 requiredFixings_.addFixingDate(bc.index()->fixingCalendar().adjust(bc.fixingStartDate(), Preceding),
782 IndexNameTranslator::instance().oreName(fx->name()), bc.date(), false);
783 requiredFixings_.addFixingDate(bc.index()->fixingCalendar().adjust(bc.fixingEndDate(), Preceding),
784 IndexNameTranslator::instance().oreName(fx->name()), bc.date(), false);
785 }
786 }
787}
QuantLib::ext::shared_ptr< QuantExt::FxIndex > additionalFxIndex_
+ Here is the call graph for this function:

◆ setRequireFixingStartDates()

void setRequireFixingStartDates ( const bool  b)

Definition at line 335 of file fixingdates.hpp.

◆ setAdditionalFxIndex()

void setAdditionalFxIndex ( const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &  i)

Definition at line 336 of file fixingdates.hpp.

336{ additionalFxIndex_ = i; }

◆ oreIndexName()

std::string oreIndexName ( const std::string &  qlIndexName) const
protected

Member Data Documentation

◆ requiredFixings_

RequiredFixings& requiredFixings_
protected

Definition at line 340 of file fixingdates.hpp.

◆ requireFixingStartDates_

bool requireFixingStartDates_ = false
private

Definition at line 344 of file fixingdates.hpp.

◆ additionalFxIndex_

QuantLib::ext::shared_ptr<QuantExt::FxIndex> additionalFxIndex_
private

Definition at line 346 of file fixingdates.hpp.