QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
yoyinflationcoupon.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2009 Chris Kenyon
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18 */
19
20/*! \file yoyinflationcoupon.hpp
21 \brief Coupon paying a yoy inflation index
22 */
23
24#ifndef quantlib_newyoy_coupon_hpp
25#define quantlib_newyoy_coupon_hpp
26
29#include <ql/time/schedule.hpp>
30
31namespace QuantLib {
32 class YoYInflationCouponPricer;
33
34 //! %Coupon paying a YoY-inflation type index
36 public:
37 YoYInflationCoupon(const Date& paymentDate,
39 const Date& startDate,
40 const Date& endDate,
42 const ext::shared_ptr<YoYInflationIndex>& index,
46 Real gearing = 1.0,
47 Spread spread = 0.0,
48 const Date& refPeriodStart = Date(),
49 const Date& refPeriodEnd = Date());
50
51 /*! \deprecated Use the overload that passes an interpolation type instead.
52 Deprecated in version 1.36.
53 */
54 [[deprecated("Use the overload that passes an interpolation type instead")]]
55 YoYInflationCoupon(const Date& paymentDate,
57 const Date& startDate,
58 const Date& endDate,
60 const ext::shared_ptr<YoYInflationIndex>& index,
63 Real gearing = 1.0,
64 Spread spread = 0.0,
65 const Date& refPeriodStart = Date(),
66 const Date& refPeriodEnd = Date());
67
68 //! \name Inspectors
69 //@{
70 //! index gearing, i.e. multiplicative coefficient for the index
71 Real gearing() const { return gearing_; }
72 //! spread paid over the fixing of the underlying index
73 Spread spread() const { return spread_; }
74
75 Rate indexFixing() const override;
76
77 Rate adjustedFixing() const;
78
79 const ext::shared_ptr<YoYInflationIndex>& yoyIndex() const;
81 //@}
82
83 //! \name Visitability
84 //@{
85 void accept(AcyclicVisitor&) override;
86 //@}
87
88 private:
89 ext::shared_ptr<YoYInflationIndex> yoyIndex_;
91 protected:
94 bool checkPricerImpl(const ext::shared_ptr<InflationCouponPricer>&) const override;
95 };
96
97 inline const ext::shared_ptr<YoYInflationIndex>&
99 return yoyIndex_;
100 }
101
103 return interpolation_;
104 }
105
107 return (rate()-spread())/gearing();
108 }
109
110
111
112
113 //! Helper class building a sequence of capped/floored yoy inflation coupons
115 public:
116 yoyInflationLeg(Schedule schedule,
117 Calendar cal,
118 ext::shared_ptr<YoYInflationIndex> index,
119 const Period& observationLag,
120 CPI::InterpolationType interpolation);
121 /*! \deprecated Use the overload that passes an interpolation type instead.
122 Deprecated in version 1.36.
123 */
124 [[deprecated("Use the overload that passes an interpolation type instead")]]
125 yoyInflationLeg(Schedule schedule,
126 Calendar cal,
127 ext::shared_ptr<YoYInflationIndex> index,
128 const Period& observationLag);
130 yoyInflationLeg& withNotionals(const std::vector<Real>& notionals);
134 yoyInflationLeg& withFixingDays(const std::vector<Natural>& fixingDays);
136 yoyInflationLeg& withGearings(const std::vector<Real>& gearings);
138 yoyInflationLeg& withSpreads(const std::vector<Spread>& spreads);
140 yoyInflationLeg& withCaps(const std::vector<Rate>& caps);
142 yoyInflationLeg& withFloors(const std::vector<Rate>& floors);
143 operator Leg() const;
144 private:
146 ext::shared_ptr<YoYInflationIndex> index_;
149 std::vector<Real> notionals_;
153 std::vector<Natural> fixingDays_;
154 std::vector<Real> gearings_;
155 std::vector<Spread> spreads_;
156 std::vector<Rate> caps_, floors_;
157 };
158
159
160
161}
162
163#endif
164
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
calendar class
Definition: calendar.hpp:61
virtual Real nominal() const
Definition: coupon.hpp:100
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Base inflation-coupon class.
Natural fixingDays() const
fixing days
Rate rate() const override
accrued rate
Period observationLag() const
how the coupon observes the index
DayCounter dayCounter() const override
day counter for accrual calculation
const ext::shared_ptr< InflationIndex > & index() const
yoy inflation index
Payment schedule.
Definition: schedule.hpp:40
Coupon paying a YoY-inflation type index
bool checkPricerImpl(const ext::shared_ptr< InflationCouponPricer > &) const override
makes sure you were given the correct type of pricer
CPI::InterpolationType interpolation() const
Rate indexFixing() const override
fixing of the underlying index, as observed by the coupon
CPI::InterpolationType interpolation_
void accept(AcyclicVisitor &) override
Real gearing() const
index gearing, i.e. multiplicative coefficient for the index
const ext::shared_ptr< YoYInflationIndex > & yoyIndex() const
ext::shared_ptr< YoYInflationIndex > yoyIndex_
Spread spread() const
spread paid over the fixing of the underlying index
Helper class building a sequence of capped/floored yoy inflation coupons.
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)
CPI::InterpolationType interpolation_
std::vector< Real > notionals_
std::vector< Spread > spreads_
yoyInflationLeg & withPaymentDayCounter(const DayCounter &)
std::vector< Natural > fixingDays_
yoyInflationLeg & withCaps(Rate cap)
yoyInflationLeg & withFixingDays(Natural fixingDays)
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Spread
spreads on interest rates
Definition: types.hpp:74
Real Rate
interest rates
Definition: types.hpp:70
Coupon paying a variable index-based rate.
base classes for inflation indexes
Definition: any.hpp:37
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
date schedule
InterpolationType
when you observe an index, how do you interpolate between fixings?