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

#include <qle/cashflows/durationadjustedcmscoupon.hpp>

+ Collaboration diagram for DurationAdjustedCmsLeg:

Public Member Functions

 DurationAdjustedCmsLeg (const Schedule &schedule, const QuantLib::ext::shared_ptr< SwapIndex > &swapIndex, const Size duration)
 
DurationAdjustedCmsLegwithNotionals (Real notional)
 
DurationAdjustedCmsLegwithNotionals (const std::vector< Real > &notionals)
 
DurationAdjustedCmsLegwithPaymentDayCounter (const DayCounter &)
 
DurationAdjustedCmsLegwithPaymentAdjustment (BusinessDayConvention)
 
DurationAdjustedCmsLegwithPaymentLag (Natural lag)
 
DurationAdjustedCmsLegwithPaymentCalendar (const Calendar &)
 
DurationAdjustedCmsLegwithFixingDays (Natural fixingDays)
 
DurationAdjustedCmsLegwithFixingDays (const std::vector< Natural > &fixingDays)
 
DurationAdjustedCmsLegwithGearings (Real gearing)
 
DurationAdjustedCmsLegwithGearings (const std::vector< Real > &gearings)
 
DurationAdjustedCmsLegwithSpreads (Spread spread)
 
DurationAdjustedCmsLegwithSpreads (const std::vector< Spread > &spreads)
 
DurationAdjustedCmsLegwithCaps (Rate cap)
 
DurationAdjustedCmsLegwithCaps (const std::vector< Rate > &caps)
 
DurationAdjustedCmsLegwithFloors (Rate floor)
 
DurationAdjustedCmsLegwithFloors (const std::vector< Rate > &floors)
 
DurationAdjustedCmsLeginArrears (bool flag=true)
 
DurationAdjustedCmsLegwithZeroPayments (bool flag=true)
 
DurationAdjustedCmsLegwithExCouponPeriod (const Period &, const Calendar &, BusinessDayConvention, bool endOfMonth=false)
 
DurationAdjustedCmsLegwithDuration (Size duration)
 
 operator Leg () const
 

Private Attributes

Schedule schedule_
 
QuantLib::ext::shared_ptr< SwapIndex > swapIndex_
 
std::vector< Real > notionals_
 
DayCounter paymentDayCounter_
 
Natural paymentLag_
 
Calendar paymentCalendar_
 
BusinessDayConvention paymentAdjustment_
 
std::vector< Natural > fixingDays_
 
std::vector< Real > gearings_
 
std::vector< Spread > spreads_
 
std::vector< Rate > caps_
 
std::vector< Rate > floors_
 
bool inArrears_
 
bool zeroPayments_
 
Period exCouponPeriod_
 
Calendar exCouponCalendar_
 
BusinessDayConvention exCouponAdjustment_
 
bool exCouponEndOfMonth_
 
Size duration_
 

Detailed Description

Definition at line 55 of file durationadjustedcmscoupon.hpp.

Constructor & Destructor Documentation

◆ DurationAdjustedCmsLeg()

DurationAdjustedCmsLeg ( const Schedule &  schedule,
const QuantLib::ext::shared_ptr< SwapIndex > &  swapIndex,
const Size  duration 
)

Definition at line 61 of file durationadjustedcmscoupon.cpp.

63 : schedule_(schedule), swapIndex_(swapIndex), paymentLag_(0), paymentCalendar_(Calendar()),
64 paymentAdjustment_(Following), inArrears_(false), zeroPayments_(false), exCouponPeriod_(Period()),
65 exCouponCalendar_(Calendar()), exCouponAdjustment_(Unadjusted), exCouponEndOfMonth_(false), duration_(duration) {}
QuantLib::ext::shared_ptr< SwapIndex > swapIndex_

Member Function Documentation

◆ withNotionals() [1/2]

DurationAdjustedCmsLeg & withNotionals ( Real  notional)

Definition at line 67 of file durationadjustedcmscoupon.cpp.

67 {
68 notionals_ = std::vector<Real>(1, notional);
69 return *this;
70}

◆ withNotionals() [2/2]

DurationAdjustedCmsLeg & withNotionals ( const std::vector< Real > &  notionals)

Definition at line 72 of file durationadjustedcmscoupon.cpp.

72 {
73 notionals_ = notionals;
74 return *this;
75}

◆ withPaymentDayCounter()

DurationAdjustedCmsLeg & withPaymentDayCounter ( const DayCounter &  dayCounter)

Definition at line 77 of file durationadjustedcmscoupon.cpp.

77 {
78 paymentDayCounter_ = dayCounter;
79 return *this;
80}

◆ withPaymentAdjustment()

DurationAdjustedCmsLeg & withPaymentAdjustment ( BusinessDayConvention  convention)

Definition at line 82 of file durationadjustedcmscoupon.cpp.

82 {
83 paymentAdjustment_ = convention;
84 return *this;
85}

◆ withPaymentLag()

DurationAdjustedCmsLeg & withPaymentLag ( Natural  lag)

Definition at line 87 of file durationadjustedcmscoupon.cpp.

87 {
88 paymentLag_ = lag;
89 return *this;
90}

◆ withPaymentCalendar()

DurationAdjustedCmsLeg & withPaymentCalendar ( const Calendar &  cal)

Definition at line 92 of file durationadjustedcmscoupon.cpp.

92 {
93 paymentCalendar_ = cal;
94 return *this;
95}

◆ withFixingDays() [1/2]

DurationAdjustedCmsLeg & withFixingDays ( Natural  fixingDays)

Definition at line 97 of file durationadjustedcmscoupon.cpp.

97 {
98 fixingDays_ = std::vector<Natural>(1, fixingDays);
99 return *this;
100}

◆ withFixingDays() [2/2]

DurationAdjustedCmsLeg & withFixingDays ( const std::vector< Natural > &  fixingDays)

Definition at line 102 of file durationadjustedcmscoupon.cpp.

102 {
103 fixingDays_ = fixingDays;
104 return *this;
105}

◆ withGearings() [1/2]

DurationAdjustedCmsLeg & withGearings ( Real  gearing)

Definition at line 107 of file durationadjustedcmscoupon.cpp.

107 {
108 gearings_ = std::vector<Real>(1, gearing);
109 return *this;
110}

◆ withGearings() [2/2]

DurationAdjustedCmsLeg & withGearings ( const std::vector< Real > &  gearings)

Definition at line 112 of file durationadjustedcmscoupon.cpp.

112 {
113 gearings_ = gearings;
114 return *this;
115}

◆ withSpreads() [1/2]

DurationAdjustedCmsLeg & withSpreads ( Spread  spread)

Definition at line 117 of file durationadjustedcmscoupon.cpp.

117 {
118 spreads_ = std::vector<Spread>(1, spread);
119 return *this;
120}

◆ withSpreads() [2/2]

DurationAdjustedCmsLeg & withSpreads ( const std::vector< Spread > &  spreads)

Definition at line 122 of file durationadjustedcmscoupon.cpp.

122 {
123 spreads_ = spreads;
124 return *this;
125}

◆ withCaps() [1/2]

DurationAdjustedCmsLeg & withCaps ( Rate  cap)

Definition at line 127 of file durationadjustedcmscoupon.cpp.

127 {
128 caps_ = std::vector<Rate>(1, cap);
129 return *this;
130}

◆ withCaps() [2/2]

DurationAdjustedCmsLeg & withCaps ( const std::vector< Rate > &  caps)

Definition at line 132 of file durationadjustedcmscoupon.cpp.

132 {
133 caps_ = caps;
134 return *this;
135}

◆ withFloors() [1/2]

DurationAdjustedCmsLeg & withFloors ( Rate  floor)

Definition at line 137 of file durationadjustedcmscoupon.cpp.

137 {
138 floors_ = std::vector<Rate>(1, floor);
139 return *this;
140}

◆ withFloors() [2/2]

DurationAdjustedCmsLeg & withFloors ( const std::vector< Rate > &  floors)

Definition at line 142 of file durationadjustedcmscoupon.cpp.

142 {
143 floors_ = floors;
144 return *this;
145}

◆ inArrears()

DurationAdjustedCmsLeg & inArrears ( bool  flag = true)

Definition at line 147 of file durationadjustedcmscoupon.cpp.

147 {
148 inArrears_ = flag;
149 return *this;
150}

◆ withZeroPayments()

DurationAdjustedCmsLeg & withZeroPayments ( bool  flag = true)

Definition at line 152 of file durationadjustedcmscoupon.cpp.

152 {
153 zeroPayments_ = flag;
154 return *this;
155}

◆ withExCouponPeriod()

DurationAdjustedCmsLeg & withExCouponPeriod ( const Period &  period,
const Calendar &  cal,
BusinessDayConvention  convention,
bool  endOfMonth = false 
)

Definition at line 162 of file durationadjustedcmscoupon.cpp.

163 {
164 exCouponPeriod_ = period;
165 exCouponCalendar_ = cal;
166 exCouponAdjustment_ = convention;
167 exCouponEndOfMonth_ = endOfMonth;
168 return *this;
169}

◆ withDuration()

DurationAdjustedCmsLeg & withDuration ( Size  duration)

Definition at line 157 of file durationadjustedcmscoupon.cpp.

157 {
158 duration_ = duration;
159 return *this;
160}

◆ operator Leg()

operator Leg ( ) const

Definition at line 171 of file durationadjustedcmscoupon.cpp.

171 {
172 Size n = schedule_.size() - 1;
173
174 QL_REQUIRE(!notionals_.empty(), "no notional given");
175 QL_REQUIRE(notionals_.size() <= n, "too many notionals (" << notionals_.size() << "), only " << n << " required");
176 QL_REQUIRE(gearings_.size() <= n, "too many gearings (" << gearings_.size() << "), only " << n << " required");
177 QL_REQUIRE(spreads_.size() <= n, "too many spreads (" << spreads_.size() << "), only " << n << " required");
178 QL_REQUIRE(caps_.size() <= n, "too many caps (" << caps_.size() << "), only " << n << " required");
179 QL_REQUIRE(floors_.size() <= n, "too many floors (" << floors_.size() << "), only " << n << " required");
180 QL_REQUIRE(!zeroPayments_ || !inArrears_, "in-arrears and zero features are not compatible");
181
182 Leg leg;
183 leg.reserve(n);
184
185 Calendar calendar = schedule_.calendar();
186 Calendar paymentCalendar = schedule_.calendar();
187
188 if (!paymentCalendar_.empty()) {
189 paymentCalendar = paymentCalendar_;
190 }
191
192 Date refStart, start, refEnd, end;
193 Date exCouponDate;
194 Date lastPaymentDate = paymentCalendar.advance(schedule_.date(n), paymentLag_, Days, paymentAdjustment_);
195
196 for (Size i = 0; i < n; ++i) {
197 refStart = start = schedule_.date(i);
198 refEnd = end = schedule_.date(i + 1);
199 Date paymentDate =
200 zeroPayments_ ? lastPaymentDate : paymentCalendar.advance(end, paymentLag_, Days, paymentAdjustment_);
201 if (i == 0 && (schedule_.hasIsRegular() && schedule_.hasTenor() && !schedule_.isRegular(i + 1))) {
202 BusinessDayConvention bdc = schedule_.businessDayConvention();
203 refStart = calendar.adjust(end - schedule_.tenor(), bdc);
204 }
205 if (i == n - 1 && (schedule_.hasIsRegular() && schedule_.hasTenor() && !schedule_.isRegular(i + 1))) {
206 BusinessDayConvention bdc = schedule_.businessDayConvention();
207 refEnd = calendar.adjust(start + schedule_.tenor(), bdc);
208 }
209 if (exCouponPeriod_ != Period()) {
210 Calendar exCouponCalendar = calendar;
211 if (!exCouponCalendar_.empty()) {
212 exCouponCalendar = exCouponCalendar_;
213 }
214 exCouponDate =
216 }
217 auto cpn = QuantLib::ext::make_shared<DurationAdjustedCmsCoupon>(
218 paymentDate, detail::get(notionals_, i, 1.0), start, end,
219 detail::get(fixingDays_, i, swapIndex_->fixingDays()), swapIndex_, duration_,
220 detail::get(gearings_, i, 1.0), detail::get(spreads_, i, 0.0), refStart, refEnd, paymentDayCounter_,
221 inArrears_, exCouponDate);
222 if (detail::noOption(caps_, floors_, i)) {
223 leg.push_back(cpn);
224 } else {
225 leg.push_back(QuantLib::ext::make_shared<CappedFlooredCoupon>(cpn, detail::get(caps_, i, Null<Rate>()),
226 detail::get(floors_, i, Null<Rate>())));
227 }
228 }
229 return leg;
230}

Member Data Documentation

◆ schedule_

Schedule schedule_
private

Definition at line 84 of file durationadjustedcmscoupon.hpp.

◆ swapIndex_

QuantLib::ext::shared_ptr<SwapIndex> swapIndex_
private

Definition at line 85 of file durationadjustedcmscoupon.hpp.

◆ notionals_

std::vector<Real> notionals_
private

Definition at line 86 of file durationadjustedcmscoupon.hpp.

◆ paymentDayCounter_

DayCounter paymentDayCounter_
private

Definition at line 87 of file durationadjustedcmscoupon.hpp.

◆ paymentLag_

Natural paymentLag_
private

Definition at line 88 of file durationadjustedcmscoupon.hpp.

◆ paymentCalendar_

Calendar paymentCalendar_
private

Definition at line 89 of file durationadjustedcmscoupon.hpp.

◆ paymentAdjustment_

BusinessDayConvention paymentAdjustment_
private

Definition at line 90 of file durationadjustedcmscoupon.hpp.

◆ fixingDays_

std::vector<Natural> fixingDays_
private

Definition at line 91 of file durationadjustedcmscoupon.hpp.

◆ gearings_

std::vector<Real> gearings_
private

Definition at line 92 of file durationadjustedcmscoupon.hpp.

◆ spreads_

std::vector<Spread> spreads_
private

Definition at line 93 of file durationadjustedcmscoupon.hpp.

◆ caps_

std::vector<Rate> caps_
private

Definition at line 94 of file durationadjustedcmscoupon.hpp.

◆ floors_

std::vector<Rate> floors_
private

Definition at line 94 of file durationadjustedcmscoupon.hpp.

◆ inArrears_

bool inArrears_
private

Definition at line 95 of file durationadjustedcmscoupon.hpp.

◆ zeroPayments_

bool zeroPayments_
private

Definition at line 95 of file durationadjustedcmscoupon.hpp.

◆ exCouponPeriod_

Period exCouponPeriod_
private

Definition at line 96 of file durationadjustedcmscoupon.hpp.

◆ exCouponCalendar_

Calendar exCouponCalendar_
private

Definition at line 97 of file durationadjustedcmscoupon.hpp.

◆ exCouponAdjustment_

BusinessDayConvention exCouponAdjustment_
private

Definition at line 98 of file durationadjustedcmscoupon.hpp.

◆ exCouponEndOfMonth_

bool exCouponEndOfMonth_
private

Definition at line 99 of file durationadjustedcmscoupon.hpp.

◆ duration_

Size duration_
private

Definition at line 100 of file durationadjustedcmscoupon.hpp.