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

#include <qle/cashflows/nonstandardcapflooredyoyinflationcoupon.hpp>

+ Collaboration diagram for NonStandardYoYInflationLeg:

Public Member Functions

 NonStandardYoYInflationLeg (const Schedule &schedule, const Calendar &cal, const ext::shared_ptr< ZeroInflationIndex > &index, const Period &observationLag)
 
NonStandardYoYInflationLegwithNotionals (Real notional)
 
NonStandardYoYInflationLegwithNotionals (const std::vector< Real > &notionals)
 
NonStandardYoYInflationLegwithPaymentDayCounter (const DayCounter &)
 
NonStandardYoYInflationLegwithPaymentAdjustment (BusinessDayConvention)
 
NonStandardYoYInflationLegwithFixingDays (Natural fixingDays)
 
NonStandardYoYInflationLegwithFixingDays (const std::vector< Natural > &fixingDays)
 
NonStandardYoYInflationLegwithGearings (Real gearing)
 
NonStandardYoYInflationLegwithGearings (const std::vector< Real > &gearings)
 
NonStandardYoYInflationLegwithSpreads (Spread spread)
 
NonStandardYoYInflationLegwithSpreads (const std::vector< Spread > &spreads)
 
NonStandardYoYInflationLegwithCaps (Rate cap)
 
NonStandardYoYInflationLegwithCaps (const std::vector< Rate > &caps)
 
NonStandardYoYInflationLegwithFloors (Rate floor)
 
NonStandardYoYInflationLegwithFloors (const std::vector< Rate > &floors)
 
NonStandardYoYInflationLegwithRateCurve (const Handle< YieldTermStructure > &rateCurve)
 
NonStandardYoYInflationLegwithInflationNotional (bool addInflationNotional_)
 
NonStandardYoYInflationLegwithObservationInterpolation (QuantLib::CPI::InterpolationType interpolation)
 
 operator Leg () const
 

Private Attributes

Schedule schedule_
 
ext::shared_ptr< ZeroInflationIndex > 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_
 
QuantLib::CPI::InterpolationType interpolation_
 

Detailed Description

Definition at line 129 of file nonstandardcapflooredyoyinflationcoupon.hpp.

Constructor & Destructor Documentation

◆ NonStandardYoYInflationLeg()

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

Member Function Documentation

◆ withNotionals() [1/2]

NonStandardYoYInflationLeg & withNotionals ( Real  notional)

Definition at line 171 of file nonstandardcapflooredyoyinflationcoupon.cpp.

171 {
172 notionals_ = std::vector<Real>(1, notional);
173 return *this;
174}

◆ withNotionals() [2/2]

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

Definition at line 176 of file nonstandardcapflooredyoyinflationcoupon.cpp.

176 {
177 notionals_ = notionals;
178 return *this;
179}

◆ withPaymentDayCounter()

NonStandardYoYInflationLeg & withPaymentDayCounter ( const DayCounter &  dayCounter)

Definition at line 181 of file nonstandardcapflooredyoyinflationcoupon.cpp.

181 {
182 paymentDayCounter_ = dayCounter;
183 return *this;
184}

◆ withPaymentAdjustment()

NonStandardYoYInflationLeg & withPaymentAdjustment ( BusinessDayConvention  convention)

Definition at line 186 of file nonstandardcapflooredyoyinflationcoupon.cpp.

186 {
187 paymentAdjustment_ = convention;
188 return *this;
189}

◆ withFixingDays() [1/2]

NonStandardYoYInflationLeg & withFixingDays ( Natural  fixingDays)

Definition at line 191 of file nonstandardcapflooredyoyinflationcoupon.cpp.

191 {
192 fixingDays_ = std::vector<Natural>(1, fixingDays);
193 return *this;
194}

◆ withFixingDays() [2/2]

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

Definition at line 196 of file nonstandardcapflooredyoyinflationcoupon.cpp.

196 {
197 fixingDays_ = fixingDays;
198 return *this;
199}

◆ withGearings() [1/2]

NonStandardYoYInflationLeg & withGearings ( Real  gearing)

Definition at line 201 of file nonstandardcapflooredyoyinflationcoupon.cpp.

201 {
202 gearings_ = std::vector<Real>(1, gearing);
203 return *this;
204}

◆ withGearings() [2/2]

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

Definition at line 206 of file nonstandardcapflooredyoyinflationcoupon.cpp.

206 {
207 gearings_ = gearings;
208 return *this;
209}

◆ withSpreads() [1/2]

NonStandardYoYInflationLeg & withSpreads ( Spread  spread)

Definition at line 211 of file nonstandardcapflooredyoyinflationcoupon.cpp.

211 {
212 spreads_ = std::vector<Spread>(1, spread);
213 return *this;
214}

◆ withSpreads() [2/2]

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

Definition at line 216 of file nonstandardcapflooredyoyinflationcoupon.cpp.

216 {
217 spreads_ = spreads;
218 return *this;
219}

◆ withCaps() [1/2]

NonStandardYoYInflationLeg & withCaps ( Rate  cap)

Definition at line 221 of file nonstandardcapflooredyoyinflationcoupon.cpp.

221 {
222 caps_ = std::vector<Rate>(1, cap);
223 return *this;
224}

◆ withCaps() [2/2]

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

Definition at line 226 of file nonstandardcapflooredyoyinflationcoupon.cpp.

226 {
227 caps_ = caps;
228 return *this;
229}

◆ withFloors() [1/2]

NonStandardYoYInflationLeg & withFloors ( Rate  floor)

Definition at line 231 of file nonstandardcapflooredyoyinflationcoupon.cpp.

231 {
232 floors_ = std::vector<Rate>(1, floor);
233 return *this;
234}

◆ withFloors() [2/2]

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

Definition at line 236 of file nonstandardcapflooredyoyinflationcoupon.cpp.

236 {
237 floors_ = floors;
238 return *this;
239}

◆ withRateCurve()

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

Definition at line 241 of file nonstandardcapflooredyoyinflationcoupon.cpp.

241 {
242 rateCurve_ = rateCurve;
243 return *this;
244}

◆ withInflationNotional()

NonStandardYoYInflationLeg & withInflationNotional ( bool  addInflationNotional_)

Definition at line 246 of file nonstandardcapflooredyoyinflationcoupon.cpp.

246 {
247 addInflationNotional_ = addInflationNotional;
248 return *this;
249}

◆ withObservationInterpolation()

NonStandardYoYInflationLeg & withObservationInterpolation ( QuantLib::CPI::InterpolationType  interpolation)

Definition at line 251 of file nonstandardcapflooredyoyinflationcoupon.cpp.

251 {
252 interpolation_ = interpolation;
253 return *this;
254}

◆ operator Leg()

operator Leg ( ) const

Definition at line 256 of file nonstandardcapflooredyoyinflationcoupon.cpp.

256 {
257
258 Size n = schedule_.size() - 1;
259 QL_REQUIRE(!notionals_.empty(), "no notional given");
260 QL_REQUIRE(notionals_.size() <= n, "too many nominals (" << notionals_.size() << "), only " << n << " required");
261 QL_REQUIRE(gearings_.size() <= n, "too many gearings (" << gearings_.size() << "), only " << n << " required");
262 QL_REQUIRE(spreads_.size() <= n, "too many spreads (" << spreads_.size() << "), only " << n << " required");
263 QL_REQUIRE(caps_.size() <= n, "too many caps (" << caps_.size() << "), only " << n << " required");
264 QL_REQUIRE(floors_.size() <= n, "too many floors (" << floors_.size() << "), only " << n << " required");
265
266 Leg leg;
267 leg.reserve(n);
268
269 Calendar calendar = paymentCalendar_;
270
271 Date refStart, start, refEnd, end;
272
273 for (Size i = 0; i < n; ++i) {
274 refStart = start = schedule_.date(i);
275 refEnd = end = schedule_.date(i + 1);
276 Date paymentDate = calendar.adjust(end, paymentAdjustment_);
277 if (i == 0 && schedule_.hasIsRegular() && !schedule_.isRegular(i + 1)) {
278 BusinessDayConvention bdc = schedule_.businessDayConvention();
279 refStart = schedule_.calendar().adjust(end - schedule_.tenor(), bdc);
280 }
281 if (i == n - 1 && schedule_.hasIsRegular() && !schedule_.isRegular(i + 1)) {
282 BusinessDayConvention bdc = schedule_.businessDayConvention();
283 refEnd = schedule_.calendar().adjust(start + schedule_.tenor(), bdc);
284 }
285 if (detail::get(gearings_, i, 1.0) == 0.0) { // fixed coupon
286 leg.push_back(ext::shared_ptr<CashFlow>(new FixedRateCoupon(
287 paymentDate, detail::get(notionals_, i, 1.0), detail::effectiveFixedRate(spreads_, caps_, floors_, i),
288 paymentDayCounter_, start, end, refStart, refEnd)));
289 } else { // yoy inflation coupon
290 if (detail::noOption(caps_, floors_, i)) { // just swaplet
291 ext::shared_ptr<NonStandardYoYInflationCoupon> coup(new NonStandardYoYInflationCoupon(
292 paymentDate, detail::get(notionals_, i, 1.0), start, end, detail::get(fixingDays_, i, 0), index_,
293 observationLag_, paymentDayCounter_, detail::get(gearings_, i, 1.0), detail::get(spreads_, i, 0.0),
294 refStart, refEnd, addInflationNotional_, interpolation_));
295
296 // in this case you can set a pricer
297 // straight away because it only provides computation - not data
298 ext::shared_ptr<NonStandardYoYInflationCouponPricer> pricer(
299 new NonStandardYoYInflationCouponPricer(rateCurve_));
300 coup->setPricer(pricer);
301 leg.push_back(ext::dynamic_pointer_cast<CashFlow>(coup));
302
303 } else { // cap/floorlet
304 leg.push_back(ext::shared_ptr<CashFlow>(new NonStandardCappedFlooredYoYInflationCoupon(
305 paymentDate, detail::get(notionals_, i, 1.0), start, end, detail::get(fixingDays_, i, 0), index_,
306 observationLag_, paymentDayCounter_, detail::get(gearings_, i, 1.0), detail::get(spreads_, i, 0.0),
307 detail::get(caps_, i, Null<Rate>()), detail::get(floors_, i, Null<Rate>()), refStart, refEnd,
309 }
310 }
311 }
312
313 return leg;
314}

Member Data Documentation

◆ schedule_

Schedule schedule_
private

Definition at line 153 of file nonstandardcapflooredyoyinflationcoupon.hpp.

◆ index_

ext::shared_ptr<ZeroInflationIndex> index_
private

Definition at line 154 of file nonstandardcapflooredyoyinflationcoupon.hpp.

◆ observationLag_

Period observationLag_
private

Definition at line 155 of file nonstandardcapflooredyoyinflationcoupon.hpp.

◆ notionals_

std::vector<Real> notionals_
private

Definition at line 156 of file nonstandardcapflooredyoyinflationcoupon.hpp.

◆ paymentDayCounter_

DayCounter paymentDayCounter_
private

Definition at line 157 of file nonstandardcapflooredyoyinflationcoupon.hpp.

◆ paymentAdjustment_

BusinessDayConvention paymentAdjustment_
private

Definition at line 158 of file nonstandardcapflooredyoyinflationcoupon.hpp.

◆ paymentCalendar_

Calendar paymentCalendar_
private

Definition at line 159 of file nonstandardcapflooredyoyinflationcoupon.hpp.

◆ fixingDays_

std::vector<Natural> fixingDays_
private

Definition at line 160 of file nonstandardcapflooredyoyinflationcoupon.hpp.

◆ gearings_

std::vector<Real> gearings_
private

Definition at line 161 of file nonstandardcapflooredyoyinflationcoupon.hpp.

◆ spreads_

std::vector<Spread> spreads_
private

Definition at line 162 of file nonstandardcapflooredyoyinflationcoupon.hpp.

◆ caps_

std::vector<Rate> caps_
private

Definition at line 163 of file nonstandardcapflooredyoyinflationcoupon.hpp.

◆ floors_

std::vector<Rate> floors_
private

Definition at line 163 of file nonstandardcapflooredyoyinflationcoupon.hpp.

◆ rateCurve_

Handle<YieldTermStructure> rateCurve_
private

Definition at line 164 of file nonstandardcapflooredyoyinflationcoupon.hpp.

◆ addInflationNotional_

bool addInflationNotional_
private

Definition at line 165 of file nonstandardcapflooredyoyinflationcoupon.hpp.

◆ interpolation_

QuantLib::CPI::InterpolationType interpolation_
private

Definition at line 166 of file nonstandardcapflooredyoyinflationcoupon.hpp.