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

Rate helper for bootstrapping using Overnight Indexed Swaps. More...

#include <qle/termstructures/oisratehelper.hpp>

+ Inheritance diagram for DatedOISRateHelper:
+ Collaboration diagram for DatedOISRateHelper:

Public Member Functions

 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())
 
RateHelper interface
Real impliedQuote () const override
 
void setTermStructure (YieldTermStructure *) override
 

Visitability

QuantLib::ext::shared_ptr< OvernightIndex > overnightIndex_
 
DayCounter fixedDayCounter_
 
Calendar fixedCalendar_
 
Natural paymentLag_
 
Frequency paymentFrequency_
 
BusinessDayConvention fixedConvention_
 
BusinessDayConvention paymentAdjustment_
 
DateGeneration::Rule rule_
 
QuantLib::ext::shared_ptr< OvernightIndexedSwap > swap_
 
RelinkableHandle< YieldTermStructure > termStructureHandle_
 
Handle< YieldTermStructure > discountHandle_
 
RelinkableHandle< YieldTermStructure > discountRelinkableHandle_
 
bool telescopicValueDates_
 
Pillar::Choice pillarChoice_
 
void accept (AcyclicVisitor &) override
 

Detailed Description

Rate helper for bootstrapping using Overnight Indexed Swaps.

Definition at line 86 of file oisratehelper.hpp.

Constructor & Destructor Documentation

◆ DatedOISRateHelper()

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() 
)

Definition at line 141 of file oisratehelper.cpp.

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) {
152
153 pillarDate_ = customPillarDate;
154
155 bool onIndexHasCurve = !overnightIndex_->forwardingTermStructure().empty();
156 bool haveDiscountCurve = !discountHandle_.empty();
157 QL_REQUIRE(!(onIndexHasCurve && haveDiscountCurve), "Have both curves nothing to solve for.");
158
159 if (!onIndexHasCurve) {
160 QuantLib::ext::shared_ptr<IborIndex> clonedIborIndex(overnightIndex_->clone(termStructureHandle_));
161 overnightIndex_ = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(clonedIborIndex);
162 overnightIndex_->unregisterWith(termStructureHandle_);
163 }
164
165 registerWith(overnightIndex_);
166 registerWith(discountHandle_);
167
168 swap_ = MakeOIS(Period(), overnightIndex_, 0.0)
169 .withEffectiveDate(startDate)
170 .withTerminationDate(endDate)
171 .withFixedLegDayCount(fixedDayCounter_)
172 .withPaymentFrequency(paymentFrequency_)
173 .withRule(rule_)
174 // TODO: patch QL
175 //.withFixedAccrualConvention(fixedConvention_)
176 // .withFixedCalendar(fixedCalendar_)
177 .withPaymentCalendar(overnightIndex_->fixingCalendar())
178 .withPaymentAdjustment(paymentAdjustment_)
179 .withPaymentLag(paymentLag_)
180 .withDiscountingTermStructure(termStructureHandle_)
181 .withTelescopicValueDates(telescopicValueDates_);
182
183 earliestDate_ = swap_->startDate();
184 maturityDate_ = swap_->maturityDate();
185
186 Date lastPaymentDate = std::max(swap_->overnightLeg().back()->date(), swap_->fixedLeg().back()->date());
187 latestRelevantDate_ = std::max(maturityDate_, lastPaymentDate);
188
189 switch (pillarChoice_) {
190 case Pillar::MaturityDate:
191 pillarDate_ = maturityDate_;
192 break;
193 case Pillar::LastRelevantDate:
194 pillarDate_ = latestRelevantDate_;
195 break;
196 case Pillar::CustomDate:
197 // pillarDate_ already assigned at construction time
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 ("
203 << pillarDate_
204 << ") must be before "
205 "or equal to the instrument's latest relevant date ("
206 << latestRelevantDate_ << ")");
207 break;
208 default:
209 QL_FAIL("unknown Pillar::Choice(" << Integer(pillarChoice_) << ")");
210 }
211
212 // for backwards compatibility
213 latestDate_ = pillarDate_;
214}
BusinessDayConvention paymentAdjustment_
BusinessDayConvention fixedConvention_
QuantLib::ext::shared_ptr< OvernightIndex > overnightIndex_
RelinkableHandle< YieldTermStructure > termStructureHandle_
Handle< YieldTermStructure > discountHandle_
QuantLib::ext::shared_ptr< OvernightIndexedSwap > swap_
DateGeneration::Rule rule_

Member Function Documentation

◆ impliedQuote()

Real impliedQuote ( ) const
override

Definition at line 232 of file oisratehelper.cpp.

232 {
233 QL_REQUIRE(termStructure_ != 0, "term structure not set");
234 // we didn't register as observers - force calculation
235 swap_->deepUpdate();
236 return swap_->fairRate();
237}

◆ setTermStructure()

void setTermStructure ( YieldTermStructure *  t)
override

Definition at line 216 of file oisratehelper.cpp.

216 {
217 // do not set the relinkable handle as an observer -
218 // force recalculation when needed
219 bool observer = false;
220
221 QuantLib::ext::shared_ptr<YieldTermStructure> temp(t, null_deleter());
222 termStructureHandle_.linkTo(temp, observer);
223
224 if (discountHandle_.empty())
225 discountRelinkableHandle_.linkTo(temp, observer);
226 else
228
229 RateHelper::setTermStructure(t);
230}
RelinkableHandle< YieldTermStructure > discountRelinkableHandle_

◆ accept()

void accept ( AcyclicVisitor &  v)
override

Definition at line 239 of file oisratehelper.cpp.

239 {
240 Visitor<DatedOISRateHelper>* v1 = dynamic_cast<Visitor<DatedOISRateHelper>*>(&v);
241 if (v1 != 0)
242 v1->visit(*this);
243 else
244 RateHelper::accept(v);
245}

Member Data Documentation

◆ overnightIndex_

QuantLib::ext::shared_ptr<OvernightIndex> overnightIndex_
protected

Definition at line 108 of file oisratehelper.hpp.

◆ fixedDayCounter_

DayCounter fixedDayCounter_
protected

Definition at line 109 of file oisratehelper.hpp.

◆ fixedCalendar_

Calendar fixedCalendar_
protected

Definition at line 110 of file oisratehelper.hpp.

◆ paymentLag_

Natural paymentLag_
protected

Definition at line 111 of file oisratehelper.hpp.

◆ paymentFrequency_

Frequency paymentFrequency_
protected

Definition at line 112 of file oisratehelper.hpp.

◆ fixedConvention_

BusinessDayConvention fixedConvention_
protected

Definition at line 113 of file oisratehelper.hpp.

◆ paymentAdjustment_

BusinessDayConvention paymentAdjustment_
protected

Definition at line 114 of file oisratehelper.hpp.

◆ rule_

DateGeneration::Rule rule_
protected

Definition at line 115 of file oisratehelper.hpp.

◆ swap_

QuantLib::ext::shared_ptr<OvernightIndexedSwap> swap_
protected

Definition at line 117 of file oisratehelper.hpp.

◆ termStructureHandle_

RelinkableHandle<YieldTermStructure> termStructureHandle_
protected

Definition at line 118 of file oisratehelper.hpp.

◆ discountHandle_

Handle<YieldTermStructure> discountHandle_
protected

Definition at line 119 of file oisratehelper.hpp.

◆ discountRelinkableHandle_

RelinkableHandle<YieldTermStructure> discountRelinkableHandle_
protected

Definition at line 120 of file oisratehelper.hpp.

◆ telescopicValueDates_

bool telescopicValueDates_
protected

Definition at line 121 of file oisratehelper.hpp.

◆ pillarChoice_

Pillar::Choice pillarChoice_
protected

Definition at line 122 of file oisratehelper.hpp.