QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
inflationcouponpricer.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 inflationcouponpricer.hpp
21 \brief inflation-coupon pricers
22 */
23
24#ifndef quantlib_inflation_coupon_pricer_hpp
25#define quantlib_inflation_coupon_pricer_hpp
26
27#include <ql/cashflow.hpp>
28#include <ql/option.hpp>
31
32namespace QuantLib {
33
34 //! Base inflation-coupon pricer.
35 /*! The main reason we can't use FloatingRateCouponPricer as the
36 base is that it takes a FloatingRateCoupon which takes an
37 InterestRateIndex and we need an inflation index (these are
38 lagged).
39
40 The basic inflation-specific thing that the pricer has to do
41 is deal with different lags in the index and the option
42 e.g. the option could look 3 months back and the index 2.
43
44 We add the requirement that pricers do inverseCap/Floor-lets.
45 These are cap/floor-lets as usually defined, i.e. pay out if
46 underlying is above/below a strike. The non-inverse (usual)
47 versions are from a coupon point of view (a capped coupon has
48 a maximum at the strike).
49
50 We add the inverse prices so that conventional caps can be
51 priced simply.
52 */
53 class InflationCouponPricer: public virtual Observer,
54 public virtual Observable {
55 public:
58 ~InflationCouponPricer() override = default;
60 //! \name Interface
61 //@{
62 virtual Real swapletPrice() const = 0;
63 virtual Rate swapletRate() const = 0;
64 virtual Real capletPrice(Rate effectiveCap) const = 0;
65 virtual Rate capletRate(Rate effectiveCap) const = 0;
66 virtual Real floorletPrice(Rate effectiveFloor) const = 0;
67 virtual Rate floorletRate(Rate effectiveFloor) const = 0;
68 virtual void initialize(const InflationCoupon&) = 0;
69 //@}
70
71 //! \name Observer interface
72 //@{
73 void update() override { notifyObservers(); }
74 //@}
75 protected:
77 };
78
79
80 void setCouponPricer(const Leg& leg,
81 const ext::shared_ptr<InflationCouponPricer>&);
82
83
84 //! base pricer for capped/floored YoY inflation coupons
85 /*! \note this pricer can already do swaplets but to get
86 volatility-dependent coupons you need the descendents.
87 */
89 public:
91
93
96
98 return capletVol_;
99 }
100
103 }
104
105 virtual void setCapletVolatility(
107
108 //! \name InflationCouponPricer interface
109 //@{
110 Real swapletPrice() const override;
111 Rate swapletRate() const override;
112 Real capletPrice(Rate effectiveCap) const override;
113 Rate capletRate(Rate effectiveCap) const override;
114 Real floorletPrice(Rate effectiveFloor) const override;
115 Rate floorletRate(Rate effectiveFloor) const override;
116 void initialize(const InflationCoupon&) override;
117 //@}
118
119 protected:
120 virtual Real optionletPrice(Option::Type optionType,
121 Real effStrike) const;
122 virtual Real optionletRate(Option::Type optionType,
123 Real effStrike) const;
124
125 /*! Derived classes usually only need to implement this.
126
127 The name of the method is misleading. This actually
128 returns the rate of the optionlet (so not discounted and
129 not accrued).
130 */
131 virtual Real optionletPriceImp(Option::Type, Real strike,
132 Real forward, Real stdDev) const;
133 virtual Rate adjustedFixing(Rate fixing = Null<Rate>()) const;
134
135 //! data
142 };
143
144
145 //! Black-formula pricer for capped/floored yoy inflation coupons
147 public:
151
155
160 protected:
161 Real optionletPriceImp(Option::Type, Real strike, Real forward, Real stdDev) const override;
162 };
163
164
165 //! Unit-Displaced-Black-formula pricer for capped/floored yoy inflation coupons
167 public:
171
175
180 protected:
181 Real optionletPriceImp(Option::Type, Real strike, Real forward, Real stdDev) const override;
182 };
183
184
185 //! Bachelier-formula pricer for capped/floored yoy inflation coupons
187 public:
191
195
200 protected:
201 Real optionletPriceImp(Option::Type, Real strike, Real forward, Real stdDev) const override;
202 };
203
204}
205
206
207#endif
208
209
Base class for cash flows.
Bachelier-formula pricer for capped/floored yoy inflation coupons.
Real optionletPriceImp(Option::Type, Real strike, Real forward, Real stdDev) const override
BachelierYoYInflationCouponPricer(const Handle< YieldTermStructure > &nominalTermStructure)
BachelierYoYInflationCouponPricer(const Handle< YoYOptionletVolatilitySurface > &capletVol, const Handle< YieldTermStructure > &nominalTermStructure)
Black-formula pricer for capped/floored yoy inflation coupons.
Real optionletPriceImp(Option::Type, Real strike, Real forward, Real stdDev) const override
BlackYoYInflationCouponPricer(const Handle< YieldTermStructure > &nominalTermStructure)
BlackYoYInflationCouponPricer(const Handle< YoYOptionletVolatilitySurface > &capletVol, const Handle< YieldTermStructure > &nominalTermStructure)
Concrete date class.
Definition: date.hpp:125
Shared handle to an observable.
Definition: handle.hpp:41
Base inflation-coupon class.
Base inflation-coupon pricer.
virtual Real capletPrice(Rate effectiveCap) const =0
virtual Real floorletPrice(Rate effectiveFloor) const =0
virtual Rate capletRate(Rate effectiveCap) const =0
virtual Rate floorletRate(Rate effectiveFloor) const =0
virtual Real swapletPrice() const =0
virtual Rate swapletRate() const =0
QL_DEPRECATED_DISABLE_WARNING InflationCouponPricer()=default
virtual void initialize(const InflationCoupon &)=0
~InflationCouponPricer() override=default
template class providing a null value for a given type.
Definition: null.hpp:76
Object that notifies its changes to a set of observers.
Definition: observable.hpp:62
Object that gets notified when a given observable changes.
Definition: observable.hpp:116
Unit-Displaced-Black-formula pricer for capped/floored yoy inflation coupons.
Real optionletPriceImp(Option::Type, Real strike, Real forward, Real stdDev) const override
UnitDisplacedBlackYoYInflationCouponPricer(const Handle< YoYOptionletVolatilitySurface > &capletVol, const Handle< YieldTermStructure > &nominalTermStructure)
UnitDisplacedBlackYoYInflationCouponPricer(const Handle< YieldTermStructure > &nominalTermStructure)
Interest-rate term structure.
Coupon paying a YoY-inflation type index
base pricer for capped/floored YoY inflation coupons
void initialize(const InflationCoupon &) override
Real capletPrice(Rate effectiveCap) const override
Rate floorletRate(Rate effectiveFloor) const override
virtual Rate adjustedFixing(Rate fixing=Null< Rate >()) const
Handle< YieldTermStructure > nominalTermStructure_
virtual Real optionletPrice(Option::Type optionType, Real effStrike) const
virtual Handle< YieldTermStructure > nominalTermStructure() const
virtual Handle< YoYOptionletVolatilitySurface > capletVolatility() const
virtual Real optionletRate(Option::Type optionType, Real effStrike) const
virtual Real optionletPriceImp(Option::Type, Real strike, Real forward, Real stdDev) const
Real floorletPrice(Rate effectiveFloor) const override
virtual void setCapletVolatility(const Handle< YoYOptionletVolatilitySurface > &capletVol)
Handle< YoYOptionletVolatilitySurface > capletVol_
data
Rate capletRate(Rate effectiveCap) const override
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
Definition: any.hpp:35
void setCouponPricer(const Leg &leg, const ext::shared_ptr< FloatingRateCouponPricer > &pricer)
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
Base option class.
#define QL_DEPRECATED_DISABLE_WARNING
Definition: qldefines.hpp:216
#define QL_DEPRECATED_ENABLE_WARNING
Definition: qldefines.hpp:217
Coupon paying a yoy inflation index.
yoy inflation volatility structures