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

#include <qle/cashflows/yoyinflationcoupon.hpp>

+ Collaboration diagram for yoyInflationLeg:

Public Member Functions

 yoyInflationLeg (Schedule schedule, Calendar cal, ext::shared_ptr< YoYInflationIndex > index, const Period &observationLag)
 
yoyInflationLegwithNotionals (Real notional)
 
yoyInflationLegwithNotionals (const std::vector< Real > &notionals)
 
yoyInflationLegwithPaymentDayCounter (const DayCounter &)
 
yoyInflationLegwithPaymentAdjustment (BusinessDayConvention)
 
yoyInflationLegwithFixingDays (Natural fixingDays)
 
yoyInflationLegwithFixingDays (const std::vector< Natural > &fixingDays)
 
yoyInflationLegwithGearings (Real gearing)
 
yoyInflationLegwithGearings (const std::vector< Real > &gearings)
 
yoyInflationLegwithSpreads (Spread spread)
 
yoyInflationLegwithSpreads (const std::vector< Spread > &spreads)
 
yoyInflationLegwithCaps (Rate cap)
 
yoyInflationLegwithCaps (const std::vector< Rate > &caps)
 
yoyInflationLegwithFloors (Rate floor)
 
yoyInflationLegwithFloors (const std::vector< Rate > &floors)
 
yoyInflationLegwithRateCurve (const Handle< YieldTermStructure > &rateCurve)
 
yoyInflationLegwithInflationNotional (bool addInflationNotional_)
 
 operator Leg () const
 

Private Attributes

Schedule schedule_
 
ext::shared_ptr< YoYInflationIndex > index_
 
Period observationLag_
 
std::vector< Real > notionals_
 
DayCounter paymentDayCounter_
 
BusinessDayConvention paymentAdjustment_
 
Calendar paymentCalendar_
 
std::vector< Natural > fixingDays_
 
std::vector< Real > gearings_
 
std::vector< Spread > spreads_
 
std::vector< Rate > caps_
 
std::vector< Rate > floors_
 
Handle< YieldTermStructure > rateCurve_
 
bool addInflationNotional_
 

Detailed Description

Helper class building a sequence of capped/floored yoy inflation coupons payoff is: spread + gearing x index

Definition at line 84 of file yoyinflationcoupon.hpp.

Constructor & Destructor Documentation

◆ yoyInflationLeg()

yoyInflationLeg ( Schedule  schedule,
Calendar  cal,
ext::shared_ptr< YoYInflationIndex >  index,
const Period &  observationLag 
)

Definition at line 100 of file yoyinflationcoupon.cpp.

102 : schedule_(std::move(schedule)), index_(std::move(index)), observationLag_(observationLag),
103 paymentAdjustment_(ModifiedFollowing), paymentCalendar_(std::move(paymentCalendar)),
104 addInflationNotional_(false) {}
BusinessDayConvention paymentAdjustment_
ext::shared_ptr< YoYInflationIndex > index_

Member Function Documentation

◆ withNotionals() [1/2]

yoyInflationLeg & withNotionals ( Real  notional)

Definition at line 106 of file yoyinflationcoupon.cpp.

106 {
107 notionals_ = std::vector<Real>(1, notional);
108 return *this;
109}
std::vector< Real > notionals_
+ Here is the caller graph for this function:

◆ withNotionals() [2/2]

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

Definition at line 111 of file yoyinflationcoupon.cpp.

111 {
112 notionals_ = notionals;
113 return *this;
114}

◆ withPaymentDayCounter()

yoyInflationLeg & withPaymentDayCounter ( const DayCounter &  dayCounter)

Definition at line 116 of file yoyinflationcoupon.cpp.

116 {
117 paymentDayCounter_ = dayCounter;
118 return *this;
119}
+ Here is the caller graph for this function:

◆ withPaymentAdjustment()

yoyInflationLeg & withPaymentAdjustment ( BusinessDayConvention  convention)

Definition at line 121 of file yoyinflationcoupon.cpp.

121 {
122 paymentAdjustment_ = convention;
123 return *this;
124}
+ Here is the caller graph for this function:

◆ withFixingDays() [1/2]

yoyInflationLeg & withFixingDays ( Natural  fixingDays)

Definition at line 126 of file yoyinflationcoupon.cpp.

126 {
127 fixingDays_ = std::vector<Natural>(1, fixingDays);
128 return *this;
129}
std::vector< Natural > fixingDays_

◆ withFixingDays() [2/2]

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

Definition at line 131 of file yoyinflationcoupon.cpp.

131 {
132 fixingDays_ = fixingDays;
133 return *this;
134}

◆ withGearings() [1/2]

yoyInflationLeg & withGearings ( Real  gearing)

Definition at line 136 of file yoyinflationcoupon.cpp.

136 {
137 gearings_ = std::vector<Real>(1, gearing);
138 return *this;
139}

◆ withGearings() [2/2]

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

Definition at line 141 of file yoyinflationcoupon.cpp.

141 {
142 gearings_ = gearings;
143 return *this;
144}

◆ withSpreads() [1/2]

yoyInflationLeg & withSpreads ( Spread  spread)

Definition at line 146 of file yoyinflationcoupon.cpp.

146 {
147 spreads_ = std::vector<Spread>(1, spread);
148 return *this;
149}
std::vector< Spread > spreads_

◆ withSpreads() [2/2]

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

Definition at line 151 of file yoyinflationcoupon.cpp.

151 {
152 spreads_ = spreads;
153 return *this;
154}

◆ withCaps() [1/2]

yoyInflationLeg & withCaps ( Rate  cap)

Definition at line 156 of file yoyinflationcoupon.cpp.

156 {
157 caps_ = std::vector<Rate>(1, cap);
158 return *this;
159}

◆ withCaps() [2/2]

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

Definition at line 161 of file yoyinflationcoupon.cpp.

161 {
162 caps_ = caps;
163 return *this;
164}

◆ withFloors() [1/2]

yoyInflationLeg & withFloors ( Rate  floor)

Definition at line 166 of file yoyinflationcoupon.cpp.

166 {
167 floors_ = std::vector<Rate>(1, floor);
168 return *this;
169}

◆ withFloors() [2/2]

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

Definition at line 171 of file yoyinflationcoupon.cpp.

171 {
172 floors_ = floors;
173 return *this;
174}

◆ withRateCurve()

yoyInflationLeg & withRateCurve ( const Handle< YieldTermStructure > &  rateCurve)

Definition at line 176 of file yoyinflationcoupon.cpp.

176 {
177 rateCurve_ = rateCurve;
178 return *this;
179}
Handle< YieldTermStructure > rateCurve_

◆ withInflationNotional()

yoyInflationLeg & withInflationNotional ( bool  addInflationNotional_)

Definition at line 181 of file yoyinflationcoupon.cpp.

181 {
182 addInflationNotional_ = addInflationNotional;
183 return *this;
184}

◆ operator Leg()

operator Leg ( ) const

Definition at line 186 of file yoyinflationcoupon.cpp.

186 {
187
188 Size n = schedule_.size() - 1;
189 QL_REQUIRE(!notionals_.empty(), "no notional given");
190 QL_REQUIRE(notionals_.size() <= n, "too many nominals (" << notionals_.size() << "), only " << n << " required");
191 QL_REQUIRE(gearings_.size() <= n, "too many gearings (" << gearings_.size() << "), only " << n << " required");
192 QL_REQUIRE(spreads_.size() <= n, "too many spreads (" << spreads_.size() << "), only " << n << " required");
193 QL_REQUIRE(caps_.size() <= n, "too many caps (" << caps_.size() << "), only " << n << " required");
194 QL_REQUIRE(floors_.size() <= n, "too many floors (" << floors_.size() << "), only " << n << " required");
195
196 Leg leg;
197 leg.reserve(n);
198
199 Calendar calendar = paymentCalendar_;
200
201 Date refStart, start, refEnd, end;
202
203 for (Size i = 0; i < n; ++i) {
204 refStart = start = schedule_.date(i);
205 refEnd = end = schedule_.date(i + 1);
206 Date paymentDate = calendar.adjust(end, paymentAdjustment_);
207 if (i == 0 && schedule_.hasIsRegular() && !schedule_.isRegular(i + 1)) {
208 BusinessDayConvention bdc = schedule_.businessDayConvention();
209 refStart = schedule_.calendar().adjust(end - schedule_.tenor(), bdc);
210 }
211 if (i == n - 1 && schedule_.hasIsRegular() && !schedule_.isRegular(i + 1)) {
212 BusinessDayConvention bdc = schedule_.businessDayConvention();
213 refEnd = schedule_.calendar().adjust(start + schedule_.tenor(), bdc);
214 }
215 if (detail::get(gearings_, i, 1.0) == 0.0) { // fixed coupon
216 leg.push_back(ext::shared_ptr<CashFlow>(new FixedRateCoupon(
217 paymentDate, detail::get(notionals_, i, 1.0), detail::effectiveFixedRate(spreads_, caps_, floors_, i),
218 paymentDayCounter_, start, end, refStart, refEnd)));
219 } else { // yoy inflation coupon
220 if (detail::noOption(caps_, floors_, i)) { // just swaplet
221 ext::shared_ptr<YoYInflationCoupon> coup(new YoYInflationCoupon(
222 paymentDate, detail::get(notionals_, i, 1.0), start, end, detail::get(fixingDays_, i, 0), index_,
223 observationLag_, paymentDayCounter_, detail::get(gearings_, i, 1.0), detail::get(spreads_, i, 0.0),
224 refStart, refEnd, addInflationNotional_));
225
226 // in this case you can set a pricer
227 // straight away because it only provides computation - not data
228 ext::shared_ptr<YoYInflationCouponPricer> pricer =
229 ext::make_shared<YoYInflationCouponPricer>(rateCurve_);
230 coup->setPricer(pricer);
231 leg.push_back(ext::dynamic_pointer_cast<CashFlow>(coup));
232
233 } else { // cap/floorlet
234 leg.push_back(ext::shared_ptr<CashFlow>(new CappedFlooredYoYInflationCoupon(
235 paymentDate, detail::get(notionals_, i, 1.0), start, end, detail::get(fixingDays_, i, 0), index_,
236 observationLag_, paymentDayCounter_, detail::get(gearings_, i, 1.0), detail::get(spreads_, i, 0.0),
237 detail::get(caps_, i, Null<Rate>()), detail::get(floors_, i, Null<Rate>()), refStart, refEnd,
239 }
240 }
241 }
242
243 return leg;
244}

Member Data Documentation

◆ schedule_

Schedule schedule_
private

Definition at line 107 of file yoyinflationcoupon.hpp.

◆ index_

ext::shared_ptr<YoYInflationIndex> index_
private

Definition at line 108 of file yoyinflationcoupon.hpp.

◆ observationLag_

Period observationLag_
private

Definition at line 109 of file yoyinflationcoupon.hpp.

◆ notionals_

std::vector<Real> notionals_
private

Definition at line 110 of file yoyinflationcoupon.hpp.

◆ paymentDayCounter_

DayCounter paymentDayCounter_
private

Definition at line 111 of file yoyinflationcoupon.hpp.

◆ paymentAdjustment_

BusinessDayConvention paymentAdjustment_
private

Definition at line 112 of file yoyinflationcoupon.hpp.

◆ paymentCalendar_

Calendar paymentCalendar_
private

Definition at line 113 of file yoyinflationcoupon.hpp.

◆ fixingDays_

std::vector<Natural> fixingDays_
private

Definition at line 114 of file yoyinflationcoupon.hpp.

◆ gearings_

std::vector<Real> gearings_
private

Definition at line 115 of file yoyinflationcoupon.hpp.

◆ spreads_

std::vector<Spread> spreads_
private

Definition at line 116 of file yoyinflationcoupon.hpp.

◆ caps_

std::vector<Rate> caps_
private

Definition at line 117 of file yoyinflationcoupon.hpp.

◆ floors_

std::vector<Rate> floors_
private

Definition at line 117 of file yoyinflationcoupon.hpp.

◆ rateCurve_

Handle<YieldTermStructure> rateCurve_
private

Definition at line 118 of file yoyinflationcoupon.hpp.

◆ addInflationNotional_

bool addInflationNotional_
private

Definition at line 119 of file yoyinflationcoupon.hpp.