QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
yearonyearinflationswap.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) 2007, 2009 Chris Kenyon
5 Copyright (C) 2009 StatPro Italia srl
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19 */
20
21/*! \file yearonyearinflationswap.hpp
22 \brief Year-on-year inflation-indexed swap
23 */
24
25#ifndef quantlib_yyiis_hpp
26#define quantlib_yyiis_hpp
27
30#include <ql/time/calendar.hpp>
32#include <ql/time/schedule.hpp>
33
34namespace QuantLib {
35
36 //! Year-on-year inflation-indexed swap
37 /*! Quoted as a fixed rate \f$ K \f$. At start:
38 \f[
39 \sum_{i=1}^{M} P_n(0,t_i) N K =
40 \sum_{i=1}^{M} P_n(0,t_i) N \left[ \frac{I(t_i)}{I(t_i-1)} - 1 \right]
41 \f]
42 where \f$ t_M \f$ is the maturity time, \f$ P_n(0,t) \f$ is the
43 nominal discount factor at time \f$ t \f$, \f$ N \f$ is the
44 notional, and \f$ I(t) \f$ is the inflation index value at
45 time \f$ t \f$.
46 */
48 public:
49 class arguments;
50 class results;
51 class engine;
53 Type type,
59 ext::shared_ptr<YoYInflationIndex> yoyIndex,
61 CPI::InterpolationType interpolation,
64 Calendar paymentCalendar, // inflation index does not have a calendar
66 /*! \deprecated Use the overload that passes an interpolation type instead.
67 Deprecated in version 1.36.
68 */
69 [[deprecated("Use the overload that passes an interpolation type instead")]]
71 Type type,
77 ext::shared_ptr<YoYInflationIndex> yoyIndex,
81 Calendar paymentCalendar, // inflation index does not have a calendar
83 // results
84 virtual Real fixedLegNPV() const;
85 virtual Rate fairRate() const;
86
87 virtual Real yoyLegNPV() const;
88 virtual Spread fairSpread() const;
89 // inspectors
90 virtual Type type() const;
91 virtual Real nominal() const;
92
93 virtual const Schedule& fixedSchedule() const;
94 virtual Rate fixedRate() const;
95 virtual const DayCounter& fixedDayCount() const;
96
97 virtual const Schedule& yoySchedule() const;
98 virtual const ext::shared_ptr<YoYInflationIndex>& yoyInflationIndex() const;
99 virtual Period observationLag() const { return observationLag_; }
100 virtual Spread spread() const;
101 virtual const DayCounter& yoyDayCount() const;
102
103 virtual Calendar paymentCalendar() const { return paymentCalendar_; }
105
106 virtual const Leg& fixedLeg() const;
107 virtual const Leg& yoyLeg() const;
108
109 // other
110 void setupArguments(PricingEngine::arguments* args) const override;
111 void fetchResults(const PricingEngine::results*) const override;
112 ~YearOnYearInflationSwap() override = default;
113
114 private:
115 void setupExpired() const override;
122 ext::shared_ptr<YoYInflationIndex> yoyIndex_;
128 // results
131 };
132
133
134 //! %Arguments for YoY swap calculation
136 public:
140
141 std::vector<Date> fixedResetDates;
142 std::vector<Date> fixedPayDates;
143 std::vector<Time> yoyAccrualTimes;
144 std::vector<Date> yoyResetDates;
145 std::vector<Date> yoyFixingDates;
146 std::vector<Date> yoyPayDates;
147
148 std::vector<Real> fixedCoupons;
149 std::vector<Spread> yoySpreads;
150 std::vector<Real> yoyCoupons;
151 void validate() const override;
152 };
153
154 //! %Results from YoY swap calculation
156 public:
159 void reset() override;
160 };
161
162 class YearOnYearInflationSwap::engine : public GenericEngine<YearOnYearInflationSwap::arguments,
163 YearOnYearInflationSwap::results> {};
164
165
166 // inline definitions
167
169 return type_;
170 }
171
173 return nominal_;
174 }
175
177 return fixedSchedule_;
178 }
179
181 return fixedRate_;
182 }
183
185 return fixedDayCount_;
186 }
187
189 return yoySchedule_;
190 }
191
192 inline const ext::shared_ptr<YoYInflationIndex>& YearOnYearInflationSwap::yoyInflationIndex() const {
193 return yoyIndex_;
194 }
195
197 return spread_;
198 }
199
201 return yoyDayCount_;
202 }
203
205 return paymentConvention_;
206 }
207
209 return legs_[0];
210 }
211
212 inline const Leg& YearOnYearInflationSwap::yoyLeg() const {
213 return legs_[1];
214 }
215
216}
217
218#endif
219
calendar class
calendar class
Definition: calendar.hpp:61
day counter class
Definition: daycounter.hpp:44
template base class for option pricing engines
template class providing a null value for a given type.
Definition: null.hpp:59
Payment schedule.
Definition: schedule.hpp:40
Interest rate swap.
Definition: swap.hpp:41
std::vector< Leg > legs_
Definition: swap.hpp:133
Year-on-year inflation-indexed swap.
virtual const ext::shared_ptr< YoYInflationIndex > & yoyInflationIndex() const
virtual const DayCounter & fixedDayCount() const
virtual BusinessDayConvention paymentConvention() const
virtual const Schedule & fixedSchedule() const
~YearOnYearInflationSwap() override=default
virtual const Schedule & yoySchedule() const
void setupArguments(PricingEngine::arguments *args) const override
void fetchResults(const PricingEngine::results *) const override
virtual const DayCounter & yoyDayCount() const
ext::shared_ptr< YoYInflationIndex > yoyIndex_
day counter class
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
Real Spread
spreads on interest rates
Definition: types.hpp:74
Real Rate
interest rates
Definition: types.hpp:70
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?
Interest rate swap.