19#include <ql/cashflows/cashflows.hpp>
20#include <ql/instruments/makeois.hpp>
21#include <ql/pricingengines/swap/discountingswapengine.hpp>
22#include <ql/utilities/null_deleter.hpp>
29 const QuantLib::ext::shared_ptr<OvernightIndex>& overnightIndex,
const DayCounter& fixedDayCounter,
30 const Calendar& fixedCalendar, Natural paymentLag,
bool endOfMonth,
31 Frequency paymentFrequency, BusinessDayConvention fixedConvention,
32 BusinessDayConvention paymentAdjustment, DateGeneration::Rule rule,
33 const Handle<YieldTermStructure>& discountingCurve,
bool telescopicValueDates,
34 Pillar::Choice pillar, Date customPillarDate)
36 overnightIndex_(overnightIndex), fixedDayCounter_(fixedDayCounter), fixedCalendar_(fixedCalendar),
37 paymentLag_(paymentLag), endOfMonth_(endOfMonth), paymentFrequency_(paymentFrequency),
38 fixedConvention_(fixedConvention), paymentAdjustment_(paymentAdjustment), rule_(rule),
39 discountHandle_(discountingCurve), telescopicValueDates_(telescopicValueDates), pillarChoice_(pillar) {
41 pillarDate_ = customPillarDate;
43 bool onIndexHasCurve = !
overnightIndex_->forwardingTermStructure().empty();
45 QL_REQUIRE(!(onIndexHasCurve && haveDiscountCurve),
"Have both curves nothing to solve for.");
47 if (!onIndexHasCurve) {
49 overnightIndex_ = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(clonedIborIndex);
68 .withPaymentCalendar(paymentCalendar_)
77 earliestDate_ =
swap_->startDate();
78 maturityDate_ =
swap_->maturityDate();
80 Date lastPaymentDate = std::max(
swap_->overnightLeg().back()->date(),
swap_->fixedLeg().back()->date());
81 latestRelevantDate_ = std::max(maturityDate_, lastPaymentDate);
84 case Pillar::MaturityDate:
85 pillarDate_ = maturityDate_;
87 case Pillar::LastRelevantDate:
88 pillarDate_ = latestRelevantDate_;
90 case Pillar::CustomDate:
92 QL_REQUIRE(pillarDate_ >= earliestDate_,
"pillar date (" << pillarDate_
94 "than or equal to the instrument's earliest date ("
95 << earliestDate_ <<
")");
96 QL_REQUIRE(pillarDate_ <= latestRelevantDate_,
"pillar date ("
98 <<
") must be before "
99 "or equal to the instrument's latest relevant date ("
100 << latestRelevantDate_ <<
")");
103 QL_FAIL(
"unknown Pillar::Choice(" << Integer(
pillarChoice_) <<
")");
107 latestDate_ = pillarDate_;
113 bool observer =
false;
115 QuantLib::ext::shared_ptr<YieldTermStructure> temp(t, null_deleter());
123 RelativeDateRateHelper::setTermStructure(t);
127 QL_REQUIRE(termStructure_ != 0,
"term structure not set");
130 return swap_->fairRate();
134 Visitor<OISRateHelper>* v1 =
dynamic_cast<Visitor<OISRateHelper>*
>(&v);
138 RateHelper::accept(v);
142 const QuantLib::ext::shared_ptr<OvernightIndex>& overnightIndex,
143 const DayCounter& fixedDayCounter,
const Calendar& fixedCalendar,
144 Natural paymentLag, Frequency paymentFrequency,
145 BusinessDayConvention fixedConvention, BusinessDayConvention paymentAdjustment,
146 DateGeneration::Rule rule,
const Handle<YieldTermStructure>& discountingCurve,
147 bool telescopicValueDates, Pillar::Choice pillar, Date customPillarDate)
148 : RateHelper(fixedRate), overnightIndex_(overnightIndex), fixedDayCounter_(fixedDayCounter),
149 fixedCalendar_(fixedCalendar), paymentLag_(paymentLag), paymentFrequency_(paymentFrequency),
150 fixedConvention_(fixedConvention), paymentAdjustment_(paymentAdjustment), rule_(rule),
151 discountHandle_(discountingCurve), telescopicValueDates_(telescopicValueDates), pillarChoice_(pillar) {
153 pillarDate_ = customPillarDate;
155 bool onIndexHasCurve = !
overnightIndex_->forwardingTermStructure().empty();
157 QL_REQUIRE(!(onIndexHasCurve && haveDiscountCurve),
"Have both curves nothing to solve for.");
159 if (!onIndexHasCurve) {
161 overnightIndex_ = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(clonedIborIndex);
169 .withEffectiveDate(startDate)
170 .withTerminationDate(endDate)
183 earliestDate_ =
swap_->startDate();
184 maturityDate_ =
swap_->maturityDate();
186 Date lastPaymentDate = std::max(
swap_->overnightLeg().back()->date(),
swap_->fixedLeg().back()->date());
187 latestRelevantDate_ = std::max(maturityDate_, lastPaymentDate);
190 case Pillar::MaturityDate:
191 pillarDate_ = maturityDate_;
193 case Pillar::LastRelevantDate:
194 pillarDate_ = latestRelevantDate_;
196 case Pillar::CustomDate:
198 QL_REQUIRE(pillarDate_ >= earliestDate_,
"pillar date (" << pillarDate_
199 <<
") must be later "
200 "than or equal to the instrument's earliest date ("
201 << earliestDate_ <<
")");
202 QL_REQUIRE(pillarDate_ <= latestRelevantDate_,
"pillar date ("
204 <<
") must be before "
205 "or equal to the instrument's latest relevant date ("
206 << latestRelevantDate_ <<
")");
209 QL_FAIL(
"unknown Pillar::Choice(" << Integer(
pillarChoice_) <<
")");
213 latestDate_ = pillarDate_;
219 bool observer =
false;
221 QuantLib::ext::shared_ptr<YieldTermStructure> temp(t, null_deleter());
229 RateHelper::setTermStructure(t);
233 QL_REQUIRE(termStructure_ != 0,
"term structure not set");
236 return swap_->fairRate();
240 Visitor<DatedOISRateHelper>* v1 =
dynamic_cast<Visitor<DatedOISRateHelper>*
>(&v);
244 RateHelper::accept(v);
BusinessDayConvention paymentAdjustment_
RelinkableHandle< YieldTermStructure > discountRelinkableHandle_
void setTermStructure(YieldTermStructure *) override
QuantLib::ext::shared_ptr< OvernightIndex > overnightIndex_
bool telescopicValueDates_
DatedOISRateHelper(const Date &startDate, const Date &endDate, const Handle< Quote > &fixedRate, const QuantLib::ext::shared_ptr< OvernightIndex > &overnightIndex, const DayCounter &fixedDayCounter, const Calendar &fixedCalendar, Natural paymentLag=0, Frequency paymentFrequency=Annual, BusinessDayConvention fixedConvention=Following, BusinessDayConvention paymentAdjustment=Following, DateGeneration::Rule rule=DateGeneration::Backward, const Handle< YieldTermStructure > &discountingCurve=Handle< YieldTermStructure >(), bool telescopicValueDates=false, Pillar::Choice pillar=Pillar::LastRelevantDate, Date customPillarDate=Date())
DayCounter fixedDayCounter_
RelinkableHandle< YieldTermStructure > termStructureHandle_
Pillar::Choice pillarChoice_
Handle< YieldTermStructure > discountHandle_
QuantLib::ext::shared_ptr< OvernightIndexedSwap > swap_
void accept(AcyclicVisitor &) override
DateGeneration::Rule rule_
Real impliedQuote() const override
Frequency paymentFrequency_
BusinessDayConvention paymentAdjustment_
RelinkableHandle< YieldTermStructure > discountRelinkableHandle_
void setTermStructure(YieldTermStructure *) override
QuantLib::ext::shared_ptr< OvernightIndex > overnightIndex_
bool telescopicValueDates_
DayCounter fixedDayCounter_
RelinkableHandle< YieldTermStructure > termStructureHandle_
Pillar::Choice pillarChoice_
Handle< YieldTermStructure > discountHandle_
QuantLib::ext::shared_ptr< OvernightIndexedSwap > swap_
void accept(AcyclicVisitor &) override
DateGeneration::Rule rule_
void initializeDates() override
Real impliedQuote() const override
Frequency paymentFrequency_
OISRateHelper(Natural settlementDays, const Period &swapTenor, const Handle< Quote > &fixedRate, const QuantLib::ext::shared_ptr< OvernightIndex > &overnightIndex, const DayCounter &fixedDayCounter, const Calendar &fixedCalendar, Natural paymentLag=0, bool endOfMonth=false, Frequency paymentFrequency=Annual, BusinessDayConvention fixedConvention=Following, BusinessDayConvention paymentAdjustment=Following, DateGeneration::Rule rule=DateGeneration::Backward, const Handle< YieldTermStructure > &discountingCurve=Handle< YieldTermStructure >(), bool telescopicValueDates=false, Pillar::Choice pillar=Pillar::LastRelevantDate, Date customPillarDate=Date())
Overnight Indexed Swap (aka OIS) rate helpers.