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

average overnight coupon More...

#include <qle/cashflows/averageonindexedcoupon.hpp>

+ Inheritance diagram for AverageONIndexedCoupon:
+ Collaboration diagram for AverageONIndexedCoupon:

Public Member Functions

 AverageONIndexedCoupon (const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, const QuantLib::ext::shared_ptr< OvernightIndex > &overnightIndex, Real gearing=1.0, Spread spread=0.0, Natural rateCutoff=0, const DayCounter &dayCounter=DayCounter(), const Period &lookback=0 *Days, const Size fixingDays=Null< Size >(), const Date &rateComputationStartDate=Null< Date >(), const Date &rateComputationEndDate=Null< Date >(), const bool telescopicValueDates=false)
 
Inspectors
const std::vector< Date > & fixingDates () const
 fixing dates for the rates to be averaged More...
 
const std::vector< Time > & dt () const
 accrual periods for the averaging More...
 
const std::vector< Rate > & indexFixings () const
 fixings to be averaged More...
 
const std::vector< Date > & valueDates () const
 value dates for the rates to be averaged More...
 
Natural rateCutoff () const
 rate cutoff associated with the coupon More...
 
const Period & lookback () const
 lookback period 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 numPeriods_
 
std::vector< Time > dt_
 
Natural rateCutoff_
 
Period lookback_
 
Date rateComputationStartDate_
 
Date rateComputationEndDate_
 
void accept (AcyclicVisitor &) override
 

Detailed Description

average overnight coupon

Coupon paying the interest due to the weighted average of daily overnight fixings. The rateCutoff counts the number of fixing dates starting at the end date whose fixings are not taken into account, but rather replaced by the last known fixing before.

    \ingroup cashflows

Definition at line 48 of file averageonindexedcoupon.hpp.

Constructor & Destructor Documentation

◆ AverageONIndexedCoupon()

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

Definition at line 35 of file averageonindexedcoupon.cpp.

42 : FloatingRateCoupon(paymentDate, nominal, startDate, endDate, fixingDays, overnightIndex, gearing, spread, Date(),
43 Date(), dayCounter, false),
46
47 Date valueStart = rateComputationStartDate_ == Null<Date>() ? startDate : rateComputationStartDate_;
48 Date valueEnd = rateComputationEndDate_ == Null<Date>() ? endDate : rateComputationEndDate_;
49 if (lookback != 0 * Days) {
50 BusinessDayConvention bdc = lookback.length() > 0 ? Preceding : Following;
51 valueStart = overnightIndex->fixingCalendar().advance(valueStart, -lookback, bdc);
52 valueEnd = overnightIndex->fixingCalendar().advance(valueEnd, -lookback, bdc);
53 }
54
55 // Populate the value dates.
56 Date tmpEndDate = valueEnd;
57 if(telescopicValueDates) {
58 // same optimization as in OvernightIndexedCoupon
59 Date evalDate = Settings::instance().evaluationDate();
60 tmpEndDate = overnightIndex->fixingCalendar().advance(std::max(valueStart, evalDate), 7, Days, Following);
61 tmpEndDate = std::min(tmpEndDate, valueEnd);
62 }
63
64 Schedule sch = MakeSchedule()
65 .from(valueStart)
66 .to(tmpEndDate)
67 .withTenor(1 * Days)
68 .withCalendar(overnightIndex->fixingCalendar())
69 .withConvention(overnightIndex->businessDayConvention())
70 .backwards();
71 valueDates_ = sch.dates();
72
73 if (telescopicValueDates) {
74 // build optimised value dates schedule: back stub
75 // contains at least two dates and enough periods to cover rate cutoff
76 Date tmp2 = overnightIndex->fixingCalendar().adjust(valueEnd, overnightIndex->businessDayConvention());
77 Date tmp1 = overnightIndex->fixingCalendar().advance(tmp2, -std::max<Size>(rateCutoff_, 1), Days, Preceding);
78 while (tmp1 <= tmp2) {
79 if (tmp1 > valueDates_.back())
80 valueDates_.push_back(tmp1);
81 tmp1 = overnightIndex->fixingCalendar().advance(tmp1, 1, Days, Following);
82 }
83 }
84
85 QL_ENSURE(valueDates_.size() >= 2 + rateCutoff_, "degenerate schedule");
86
87 // the first and last value date should be the unadjusted input value dates
88 if (valueDates_.front() != valueStart)
89 valueDates_.front() = valueStart;
90 if (valueDates_.back() != valueEnd)
91 valueDates_.back() = valueEnd;
92
93 numPeriods_ = valueDates_.size() - 1;
94
95 QL_REQUIRE(valueDates_[0] != valueDates_[1],
96 "internal error: first two value dates of on coupon are equal: " << valueDates_[0]);
98 "internal error: last two value dates of on coupon are equal: " << valueDates_[numPeriods_]);
99
100 // Populate the fixing dates.
102 for (Size i = 0; i < numPeriods_; ++i)
103 fixingDates_[i] = overnightIndex->fixingCalendar().advance(
104 valueDates_[i], -static_cast<Integer>(FloatingRateCoupon::fixingDays()), Days, Preceding);
105
106 // Populate the accrual periods.
107 dt_.resize(numPeriods_);
108 for (Size i = 0; i < numPeriods_; ++i)
109 dt_[i] = dayCounter.yearFraction(valueDates_[i], valueDates_[i + 1]);
110
111 // check that rate cutoff is < number of fixing dates
112 QL_REQUIRE(rateCutoff_ < numPeriods_, "rate cutoff (" << rateCutoff_
113 << ") must be less than number of fixings in period ("
114 << numPeriods_ << ")");
115}
Natural rateCutoff() const
rate cutoff associated with the coupon
QuantLib::ext::shared_ptr< OvernightIndex > overnightIndex_
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 averaged

Definition at line 59 of file averageonindexedcoupon.hpp.

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

◆ dt()

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

accrual periods for the averaging

Definition at line 61 of file averageonindexedcoupon.hpp.

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

◆ indexFixings()

const std::vector< Rate > & indexFixings ( ) const

fixings to be averaged

Definition at line 117 of file averageonindexedcoupon.cpp.

117 {
118
119 fixings_.resize(numPeriods_);
120 Size i;
121
122 for (i = 0; i < numPeriods_ - rateCutoff_; ++i) {
123 fixings_[i] = index_->fixing(fixingDates_[i]);
124 }
125
126 Rate cutoffFixing = fixings_[i - 1];
127 while (i < numPeriods_) {
128 fixings_[i] = cutoffFixing;
129 i++;
130 }
131
132 return fixings_;
133}
+ Here is the caller graph for this function:

◆ valueDates()

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

value dates for the rates to be averaged

Definition at line 65 of file averageonindexedcoupon.hpp.

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

◆ rateCutoff()

Natural rateCutoff ( ) const

rate cutoff associated with the coupon

Definition at line 67 of file averageonindexedcoupon.hpp.

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

◆ lookback()

const Period & lookback ( ) const

lookback period

Definition at line 69 of file averageonindexedcoupon.hpp.

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

◆ rateComputationStartDate()

const Date & rateComputationStartDate ( ) const

rate computation start date

Definition at line 71 of file averageonindexedcoupon.hpp.

◆ rateComputationEndDate()

const Date & rateComputationEndDate ( ) const

rate computation end date

Definition at line 73 of file averageonindexedcoupon.hpp.

◆ overnightIndex()

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

the underlying index

Definition at line 75 of file averageonindexedcoupon.hpp.

75{ 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 135 of file averageonindexedcoupon.cpp.

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

◆ accept()

void accept ( AcyclicVisitor &  v)
override

Definition at line 137 of file averageonindexedcoupon.cpp.

137 {
138 Visitor<AverageONIndexedCoupon>* v1 = dynamic_cast<Visitor<AverageONIndexedCoupon>*>(&v);
139 if (v1 != 0) {
140 v1->visit(*this);
141 } else {
142 FloatingRateCoupon::accept(v);
143 }
144}

Member Data Documentation

◆ overnightIndex_

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

Definition at line 87 of file averageonindexedcoupon.hpp.

◆ valueDates_

std::vector<Date> valueDates_
private

Definition at line 88 of file averageonindexedcoupon.hpp.

◆ fixingDates_

std::vector<Date> fixingDates_
private

Definition at line 88 of file averageonindexedcoupon.hpp.

◆ fixings_

std::vector<Rate> fixings_
mutableprivate

Definition at line 89 of file averageonindexedcoupon.hpp.

◆ numPeriods_

Size numPeriods_
private

Definition at line 90 of file averageonindexedcoupon.hpp.

◆ dt_

std::vector<Time> dt_
private

Definition at line 91 of file averageonindexedcoupon.hpp.

◆ rateCutoff_

Natural rateCutoff_
private

Definition at line 92 of file averageonindexedcoupon.hpp.

◆ lookback_

Period lookback_
private

Definition at line 93 of file averageonindexedcoupon.hpp.

◆ rateComputationStartDate_

Date rateComputationStartDate_
private

Definition at line 94 of file averageonindexedcoupon.hpp.

◆ rateComputationEndDate_

Date rateComputationEndDate_
private

Definition at line 94 of file averageonindexedcoupon.hpp.