Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
yoyinflationcoupon.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file qle/cashflows/indexedcoupon.hpp
20 \brief coupon with an indexed notional
21 \ingroup cashflows
22*/
23
24#ifndef quantext_yoy_inflation_coupon_hpp
25#define quantext_yoy_inflation_coupon_hpp
26
27#include <ql/cashflow.hpp>
28#include <ql/cashflows/capflooredinflationcoupon.hpp>
29#include <ql/cashflows/yoyinflationcoupon.hpp>
30#include <ql/indexes/inflationindex.hpp>
31#include <ql/time/schedule.hpp>
32
33namespace QuantExt {
34using namespace QuantLib;
35
36//! %Extend the QuantLib YoYInflationCoupon, now the payoff is based on growth only (default behaviour) (I_t / I_{t-1} -
37//! 1) or I_t / I_{t-1}
38
39class YoYInflationCoupon : public QuantLib::YoYInflationCoupon {
40public:
41 YoYInflationCoupon(const Date& paymentDate, Real nominal, const Date& startDate, const Date& endDate,
42 Natural fixingDays, const ext::shared_ptr<YoYInflationIndex>& index,
43 const Period& observationLag, const DayCounter& dayCounter, Real gearing = 1.0,
44 Spread spread = 0.0, const Date& refPeriodStart = Date(), const Date& refPeriodEnd = Date(),
45 bool addInflationNotional = false);
46
47 // ! \name Coupon interface
48 Rate rate() const override;
49 //@}
50 //@}
51 //! \name Visitability
52 //@{
53 virtual void accept(AcyclicVisitor&) override;
54 //@}
55
56private:
58};
59
60class CappedFlooredYoYInflationCoupon : public QuantLib::CappedFlooredYoYInflationCoupon {
61public:
62 CappedFlooredYoYInflationCoupon(const ext::shared_ptr<YoYInflationCoupon>& underlying, Rate cap = Null<Rate>(),
63 Rate floor = Null<Rate>(), bool addInflationNotional = false);
64
65 CappedFlooredYoYInflationCoupon(const Date& paymentDate, Real nominal, const Date& startDate, const Date& endDate,
66 Natural fixingDays, const ext::shared_ptr<YoYInflationIndex>& index,
67 const Period& observationLag, const DayCounter& dayCounter, Real gearing = 1.0,
68 Spread spread = 0.0, const Rate cap = Null<Rate>(), const Rate floor = Null<Rate>(),
69 const Date& refPeriodStart = Date(), const Date& refPeriodEnd = Date(),
70 bool addInflationNotional = false);
71
72 // ! \name Coupon interface
73 Rate rate() const override;
74 //! \name Visitability
75 //@{
76 virtual void accept(AcyclicVisitor&) override;
77 //@}
78private:
80};
81
82//! Helper class building a sequence of capped/floored yoy inflation coupons
83//! payoff is: spread + gearing x index
85public:
86 yoyInflationLeg(Schedule schedule, Calendar cal, ext::shared_ptr<YoYInflationIndex> index,
87 const Period& observationLag);
88 yoyInflationLeg& withNotionals(Real notional);
89 yoyInflationLeg& withNotionals(const std::vector<Real>& notionals);
90 yoyInflationLeg& withPaymentDayCounter(const DayCounter&);
91 yoyInflationLeg& withPaymentAdjustment(BusinessDayConvention);
92 yoyInflationLeg& withFixingDays(Natural fixingDays);
93 yoyInflationLeg& withFixingDays(const std::vector<Natural>& fixingDays);
94 yoyInflationLeg& withGearings(Real gearing);
95 yoyInflationLeg& withGearings(const std::vector<Real>& gearings);
96 yoyInflationLeg& withSpreads(Spread spread);
97 yoyInflationLeg& withSpreads(const std::vector<Spread>& spreads);
98 yoyInflationLeg& withCaps(Rate cap);
99 yoyInflationLeg& withCaps(const std::vector<Rate>& caps);
100 yoyInflationLeg& withFloors(Rate floor);
101 yoyInflationLeg& withFloors(const std::vector<Rate>& floors);
102 yoyInflationLeg& withRateCurve(const Handle<YieldTermStructure>& rateCurve);
104 operator Leg() const;
105
106private:
107 Schedule schedule_;
108 ext::shared_ptr<YoYInflationIndex> index_;
110 std::vector<Real> notionals_;
112 BusinessDayConvention paymentAdjustment_;
114 std::vector<Natural> fixingDays_;
115 std::vector<Real> gearings_;
116 std::vector<Spread> spreads_;
117 std::vector<Rate> caps_, floors_;
118 Handle<YieldTermStructure> rateCurve_;
120};
121} // namespace QuantExt
122#endif
virtual void accept(AcyclicVisitor &) override
CappedFlooredYoYInflationCoupon(const ext::shared_ptr< YoYInflationCoupon > &underlying, Rate cap=Null< Rate >(), Rate floor=Null< Rate >(), bool addInflationNotional=false)
virtual void accept(AcyclicVisitor &) override
yoyInflationLeg & withRateCurve(const Handle< YieldTermStructure > &rateCurve)
BusinessDayConvention paymentAdjustment_
yoyInflationLeg & withSpreads(Spread spread)
yoyInflationLeg & withFloors(Rate floor)
yoyInflationLeg & withPaymentAdjustment(BusinessDayConvention)
ext::shared_ptr< YoYInflationIndex > index_
yoyInflationLeg & withNotionals(Real notional)
yoyInflationLeg & withGearings(Real gearing)
std::vector< Real > notionals_
std::vector< Spread > spreads_
yoyInflationLeg & withPaymentDayCounter(const DayCounter &)
Handle< YieldTermStructure > rateCurve_
std::vector< Natural > fixingDays_
yoyInflationLeg & withCaps(Rate cap)
yoyInflationLeg & withInflationNotional(bool addInflationNotional_)
yoyInflationLeg & withFixingDays(Natural fixingDays)