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

overnight coupon More...

#include <qle/cashflows/overnightindexedcoupon.hpp>

+ Inheritance diagram for OvernightIndexedCoupon:
+ Collaboration diagram for OvernightIndexedCoupon:

Public Member Functions

 OvernightIndexedCoupon (const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, const ext::shared_ptr< OvernightIndex > &overnightIndex, Real gearing=1.0, Spread spread=0.0, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date(), const DayCounter &dayCounter=DayCounter(), bool telescopicValueDates=false, bool includeSpread=false, const Period &lookback=0 *Days, const Natural rateCutoff=0, const Natural fixingDays=Null< Size >(), const Date &rateComputationStartDate=Null< Date >(), const Date &rateComputationEndDate=Null< Date >())
 
Inspectors
const std::vector< Date > & fixingDates () const
 fixing dates for the rates to be compounded More...
 
const std::vector< Time > & dt () const
 accrual (compounding) periods More...
 
const std::vector< Rate > & indexFixings () const
 fixings to be compounded More...
 
const std::vector< Date > & valueDates () const
 value dates for the rates to be compounded More...
 
bool includeSpread () const
 include spread in compounding? More...
 
Real effectiveSpread () const
 
Real effectiveIndexFixing () const
 
const Period & lookback () const
 lookback period More...
 
Natural rateCutoff () const
 rate cutoff More...
 
const Date & rateComputationStartDate () const
 rate computation start date More...
 
const Date & rateComputationEndDate () const
 rate computation end date More...
 
const ext::shared_ptr< OvernightIndex > & overnightIndex () const
 the underlying index More...
 
FloatingRateCoupon interface
Date fixingDate () const override
 the date when the coupon is fully determined More...
 

Visitability

QuantLib::ext::shared_ptr< OvernightIndex > overnightIndex_
 
std::vector< Date > valueDates_
 
std::vector< Date > fixingDates_
 
std::vector< Rate > fixings_
 
Size n_
 
std::vector< Time > dt_
 
bool includeSpread_
 
Period lookback_
 
Natural rateCutoff_
 
Date rateComputationStartDate_
 
Date rateComputationEndDate_
 
void accept (AcyclicVisitor &) override
 

Detailed Description

overnight coupon

Coupon paying the compounded interest due to daily overnight fixings.

Warning:
telescopicValueDates optimizes the schedule for calculation speed, but might fail to produce correct results if the coupon ages by more than a grace period of 7 days. It is therefore recommended not to set this flag to true unless you know exactly what you are doing. The intended use is rather by the OISRateHelper which is safe, since it reinitialises the instrument each time the evaluation date changes.

if includeSpread = true, the spread is included in the daily compounding, otherwise it is added to the effective coupon rate after the compounding

Definition at line 72 of file overnightindexedcoupon.hpp.

Constructor & Destructor Documentation

◆ OvernightIndexedCoupon()

OvernightIndexedCoupon ( const Date &  paymentDate,
Real  nominal,
const Date &  startDate,
const Date &  endDate,
const ext::shared_ptr< OvernightIndex > &  overnightIndex,
Real  gearing = 1.0,
Spread  spread = 0.0,
const Date &  refPeriodStart = Date(),
const Date &  refPeriodEnd = Date(),
const DayCounter &  dayCounter = DayCounter(),
bool  telescopicValueDates = false,
bool  includeSpread = false,
const Period &  lookback = 0 * Days,
const Natural  rateCutoff = 0,
const Natural  fixingDays = Null<Size>(),
const Date &  rateComputationStartDate = Null<Date>(),
const Date &  rateComputationEndDate = Null<Date>() 
)

Definition at line 54 of file overnightindexedcoupon.cpp.

62 : FloatingRateCoupon(paymentDate, nominal, startDate, endDate, fixingDays, overnightIndex, gearing, spread,
63 refPeriodStart, refPeriodEnd, dayCounter, false),
66
67 Date valueStart = rateComputationStartDate_ == Null<Date>() ? startDate : rateComputationStartDate_;
68 Date valueEnd = rateComputationEndDate_ == Null<Date>() ? endDate : rateComputationEndDate_;
69 if (lookback != 0 * Days) {
70 BusinessDayConvention bdc = lookback.length() > 0 ? Preceding : Following;
71 valueStart = overnightIndex->fixingCalendar().advance(valueStart, -lookback, bdc);
72 valueEnd = overnightIndex->fixingCalendar().advance(valueEnd, -lookback, bdc);
73 }
74
75 // value dates
76 Date tmpEndDate = valueEnd;
77
78 /* For the coupon's valuation only the first and last future valuation
79 dates matter, therefore we can avoid to construct the whole series
80 of valuation dates, a front and back stub will do. However notice
81 that if the global evaluation date moves forward it might run past
82 the front stub of valuation dates we build here (which incorporates
83 a grace period of 7 business after the evaluation date). This will
84 lead to false coupon projections (see the warning the class header). */
85
86 if (telescopicValueDates) {
87 // build optimised value dates schedule: front stub goes
88 // from start date to max(evalDate,valueStart) + 7bd
89 Date evalDate = Settings::instance().evaluationDate();
90 tmpEndDate = overnightIndex->fixingCalendar().advance(std::max(valueStart, evalDate), 7, Days, Following);
91 tmpEndDate = std::min(tmpEndDate, valueEnd);
92 }
93 Schedule sch = MakeSchedule()
94 .from(valueStart)
95 // .to(valueEnd)
96 .to(tmpEndDate)
97 .withTenor(1 * Days)
98 .withCalendar(overnightIndex->fixingCalendar())
99 .withConvention(overnightIndex->businessDayConvention())
100 .backwards();
101 valueDates_ = sch.dates();
102
103 if (telescopicValueDates) {
104 // build optimised value dates schedule: back stub
105 // contains at least two dates and enough periods to cover rate cutoff
106 Date tmp2 = overnightIndex->fixingCalendar().adjust(valueEnd, overnightIndex->businessDayConvention());
107 Date tmp1 = overnightIndex->fixingCalendar().advance(tmp2, -std::max<Size>(rateCutoff_, 1), Days, Preceding);
108 while (tmp1 <= tmp2) {
109 if (tmp1 > valueDates_.back())
110 valueDates_.push_back(tmp1);
111 tmp1 = overnightIndex->fixingCalendar().advance(tmp1, 1, Days, Following);
112 }
113 }
114
115 QL_ENSURE(valueDates_.size() >= 2 + rateCutoff_, "degenerate schedule");
116
117 // the first and last value date should be the unadjusted input value dates
118 if (valueDates_.front() != valueStart)
119 valueDates_.front() = valueStart;
120 if (valueDates_.back() != valueEnd)
121 valueDates_.back() = valueEnd;
122
123 n_ = valueDates_.size() - 1;
124
125 QL_REQUIRE(valueDates_[0] != valueDates_[1],
126 "internal error: first two value dates of on coupon are equal: " << valueDates_[0]);
127 QL_REQUIRE(valueDates_[n_] != valueDates_[n_ - 1],
128 "internal error: last two value dates of on coupon are equal: " << valueDates_[n_]);
129
130 // fixing dates
131 fixingDates_.resize(n_);
132 for (Size i = 0; i < n_; ++i)
133 fixingDates_[i] = overnightIndex->fixingCalendar().advance(
134 valueDates_[i], -static_cast<Integer>(FloatingRateCoupon::fixingDays()), Days, Preceding);
135
136 // accrual (compounding) periods
137 dt_.resize(n_);
138 const DayCounter& dc = overnightIndex->dayCounter();
139 for (Size i = 0; i < n_; ++i)
140 dt_[i] = dc.yearFraction(valueDates_[i], valueDates_[i + 1]);
141
142 setPricer(ext::shared_ptr<FloatingRateCouponPricer>(new OvernightIndexedCouponPricer));
143
144 // check that rate cutoff is < number of fixing dates
145 QL_REQUIRE(rateCutoff_ < n_,
146 "rate cutoff (" << rateCutoff_ << ") must be less than number of fixings in period (" << n_ << ")");
147}
QuantLib::ext::shared_ptr< OvernightIndex > overnightIndex_
bool includeSpread() const
include spread in compounding?
const ext::shared_ptr< OvernightIndex > & overnightIndex() const
the underlying index
const Date & rateComputationStartDate() const
rate computation start date
const Date & rateComputationEndDate() const
rate computation end date
const Period & lookback() const
lookback period
+ Here is the call graph for this function:

Member Function Documentation

◆ fixingDates()

const std::vector< Date > & fixingDates ( ) const

fixing dates for the rates to be compounded

Definition at line 84 of file overnightindexedcoupon.hpp.

84{ return fixingDates_; }
+ Here is the caller graph for this function:

◆ dt()

const std::vector< Time > & dt ( ) const

accrual (compounding) periods

Definition at line 86 of file overnightindexedcoupon.hpp.

86{ return dt_; }
+ Here is the caller graph for this function:

◆ indexFixings()

const vector< Rate > & indexFixings ( ) const

fixings to be compounded

Definition at line 149 of file overnightindexedcoupon.cpp.

149 {
150 fixings_.resize(n_);
151 Size i;
152 for (i = 0; i < n_ - rateCutoff_; ++i) {
153 fixings_[i] = index_->fixing(fixingDates_[i]);
154 }
155 Rate cutoffFixing = fixings_[i - 1];
156 while (i < n_) {
157 fixings_[i] = cutoffFixing;
158 i++;
159 }
160 return fixings_;
161}

◆ valueDates()

const std::vector< Date > & valueDates ( ) const

value dates for the rates to be compounded

Definition at line 90 of file overnightindexedcoupon.hpp.

90{ return valueDates_; }
+ Here is the caller graph for this function:

◆ includeSpread()

bool includeSpread ( ) const

include spread in compounding?

Definition at line 92 of file overnightindexedcoupon.hpp.

92{ return includeSpread_; }

◆ effectiveSpread()

Real effectiveSpread ( ) const

effectiveSpread and effectiveIndexFixing are set such that coupon amount = notional * accrualPeriod * ( gearing * effectiveIndexFixing + effectiveSpread ) notice that

  • gearing = 1 is required if includeSpread = true
  • effectiveSpread = spread() if includeSpread = false

Definition at line 172 of file overnightindexedcoupon.cpp.

172 {
173 if (!includeSpread_)
174 return spread();
175 auto p = ext::dynamic_pointer_cast<OvernightIndexedCouponPricer>(pricer());
176 QL_REQUIRE(p, "OvernightIndexedCoupon::effectiveSpread(): expected OvernightIndexedCouponPricer");
177 p->initialize(*this);
178 return p->effectiveSpread();
179}

◆ effectiveIndexFixing()

Real effectiveIndexFixing ( ) const

Definition at line 181 of file overnightindexedcoupon.cpp.

181 {
182 auto p = ext::dynamic_pointer_cast<OvernightIndexedCouponPricer>(pricer());
183 QL_REQUIRE(p, "OvernightIndexedCoupon::effectiveSpread(): expected OvernightIndexedCouponPricer");
184 p->initialize(*this);
185 return p->effectiveIndexFixing();
186}

◆ lookback()

const Period & lookback ( ) const

lookback period

Definition at line 101 of file overnightindexedcoupon.hpp.

101{ return lookback_; }
+ Here is the caller graph for this function:

◆ rateCutoff()

Natural rateCutoff ( ) const

rate cutoff

Definition at line 103 of file overnightindexedcoupon.hpp.

103{ return rateCutoff_; }
+ Here is the caller graph for this function:

◆ rateComputationStartDate()

const Date & rateComputationStartDate ( ) const

rate computation start date

Definition at line 105 of file overnightindexedcoupon.hpp.

◆ rateComputationEndDate()

const Date & rateComputationEndDate ( ) const

rate computation end date

Definition at line 107 of file overnightindexedcoupon.hpp.

107{ return rateComputationEndDate_; }

◆ overnightIndex()

const ext::shared_ptr< OvernightIndex > & overnightIndex ( ) const

the underlying index

Definition at line 109 of file overnightindexedcoupon.hpp.

109{ return overnightIndex_; }
+ Here is the caller graph for this function:

◆ fixingDate()

Date fixingDate ( ) const
override

the date when the coupon is fully determined

Definition at line 114 of file overnightindexedcoupon.hpp.

114{ return fixingDates_[fixingDates_.size() - 1 - rateCutoff_]; }

◆ accept()

void accept ( AcyclicVisitor &  v)
override

Definition at line 163 of file overnightindexedcoupon.cpp.

163 {
164 Visitor<OvernightIndexedCoupon>* v1 = dynamic_cast<Visitor<OvernightIndexedCoupon>*>(&v);
165 if (v1 != 0) {
166 v1->visit(*this);
167 } else {
168 FloatingRateCoupon::accept(v);
169 }
170}

Member Data Documentation

◆ overnightIndex_

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

Definition at line 121 of file overnightindexedcoupon.hpp.

◆ valueDates_

std::vector<Date> valueDates_
private

Definition at line 122 of file overnightindexedcoupon.hpp.

◆ fixingDates_

std::vector<Date> fixingDates_
private

Definition at line 122 of file overnightindexedcoupon.hpp.

◆ fixings_

std::vector<Rate> fixings_
mutableprivate

Definition at line 123 of file overnightindexedcoupon.hpp.

◆ n_

Size n_
private

Definition at line 124 of file overnightindexedcoupon.hpp.

◆ dt_

std::vector<Time> dt_
private

Definition at line 125 of file overnightindexedcoupon.hpp.

◆ includeSpread_

bool includeSpread_
private

Definition at line 126 of file overnightindexedcoupon.hpp.

◆ lookback_

Period lookback_
private

Definition at line 127 of file overnightindexedcoupon.hpp.

◆ rateCutoff_

Natural rateCutoff_
private

Definition at line 128 of file overnightindexedcoupon.hpp.

◆ rateComputationStartDate_

Date rateComputationStartDate_
private

Definition at line 129 of file overnightindexedcoupon.hpp.

◆ rateComputationEndDate_

Date rateComputationEndDate_
private

Definition at line 129 of file overnightindexedcoupon.hpp.