QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
yoyinflationoptionletvolatilitystructure.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 yoyinflationoptionletvolatilitystructure.hpp
21 \brief yoy inflation volatility structures
22 */
23
24#ifndef quantlib_yoy_optionlet_volatility_structures_hpp
25#define quantlib_yoy_optionlet_volatility_structures_hpp
26
31#include <ql/quote.hpp>
32
33namespace QuantLib {
34
35 /*! Abstract interface ... no data, only results.
36
37 Basically used to change the BlackVariance() methods to
38 totalVariance. Also deal with lagged observations of an index
39 with a (usually different) availability lag.
40 */
42 public:
43 //! \name Constructor
44 //! calculate the reference date based on the global evaluation date
46 const Calendar&,
48 const DayCounter& dc,
53 Real displacement = 0.0);
54
55 ~YoYOptionletVolatilitySurface() override = default;
56
57 //! \name Volatility (only)
58 //@{
59 //! Returns the volatility for a given maturity date and strike rate
60 //! that observes inflation, by default, with the observation lag
61 //! of the term structure.
62 //! Because inflation is highly linked to dates (for interpolation, periods, etc)
63 //! we do NOT provide a time version.
64 Volatility volatility(const Date& maturityDate,
65 Rate strike,
66 const Period &obsLag = Period(-1,Days),
67 bool extrapolate = false) const;
68 //! returns the volatility for a given option tenor and strike rate
69 Volatility volatility(const Period& optionTenor,
70 Rate strike,
71 const Period &obsLag = Period(-1,Days),
72 bool extrapolate = false) const;
73 /*! Returns the volatility for a given time and strike rate. No adjustments
74 due to lags and interpolation are applied to the input time. */
75 Volatility volatility(Time time, Rate strike) const;
76
77 //! Returns the volatility type
78 virtual VolatilityType volatilityType() const { return volType_; }
79 //! Returns the displacement for lognormal volatilities
80 virtual Real displacement() const { return displacement_; }
81
82 //! Returns the total integrated variance for a given exercise date and strike rate.
83 /*! Total integrated variance is useful because it scales out
84 t for the optionlet pricing formulae. Note that it is
85 called "total" because the surface does not know whether
86 it represents Black, Bachelier or Displaced Diffusion
87 variance. These are virtual so alternate connections
88 between const vol and total var are possible.
89
90 Because inflation is highly linked to dates (for interpolation, periods, etc)
91 we do NOT provide a time version
92 */
93 virtual Volatility totalVariance(const Date& exerciseDate,
94 Rate strike,
95 const Period &obsLag = Period(-1,Days),
96 bool extrapolate = false) const;
97 //! returns the total integrated variance for a given option tenor and strike rate
98 virtual Volatility totalVariance(const Period& optionTenor,
99 Rate strike,
100 const Period &obsLag = Period(-1,Days),
101 bool extrapolate = false) const;
102
103 //! The TS observes with a lag that is usually different from the
104 //! availability lag of the index. An inflation rate is given,
105 //! by default, for the maturity requested assuming this lag.
106 virtual Period observationLag() const { return observationLag_; }
107 virtual Frequency frequency() const { return frequency_; }
108 virtual bool indexIsInterpolated() const { return indexIsInterpolated_; }
109 virtual Date baseDate() const;
110 //! base date will be in the past because of observation lag
111 virtual Time timeFromBase(const Date &date,
112 const Period& obsLag = Period(-1,Days)) const;
113 //@}
114
115 //! \name Limits
116 //@{
117 //! the minimum strike for which the term structure can return vols
118 Real minStrike() const override = 0;
119 //! the maximum strike for which the term structure can return vols
120 Real maxStrike() const override = 0;
121 //@}
122
123 // acts as zero time value for boostrapping
124 virtual Volatility baseLevel() const {
126 "Base volatility, for baseDate(), not set.");
127 return baseLevel_;
128 }
129
130 protected:
131 virtual void checkRange(const Date &, Rate strike, bool extrapolate) const;
132 virtual void checkRange(Time, Rate strike, bool extrapolate) const;
133
134 //! Implements the actual volatility surface calculation in
135 //! derived classes e.g. bilinear interpolation. N.B. does
136 //! not derive the surface.
138 Rate strike) const = 0;
139
140 // acts as zero time value for boostrapping
141 virtual void setBaseLevel(Volatility v) { baseLevel_ = v; }
143
144 // so you do not need an index
150 };
151
152
153 //! Constant surface, no K or T dependence.
156 public:
157 //! \name Constructors
158 //@{
159 //! calculate the reference date based on the global evaluation date
162 const Calendar&,
164 const DayCounter& dc,
165 const Period& observationLag,
168 Rate minStrike = -1.0, // -100%
169 Rate maxStrike = 100.0, // +10,000%
171 Real displacement = 0.0);
172
173 // costructor taking a quote
176 const Calendar&,
178 const DayCounter& dc,
179 const Period& observationLag,
182 Rate minStrike = -1.0, // -100%
183 Rate maxStrike = 100.0, // +10,000%
185 Real displacement = 0.0);
186 //@}
187
188 //! \name Limits
189 //@{
190 Date maxDate() const override { return Date::maxDate(); }
191 //! the minimum strike for which the term structure can return vols
192 Real minStrike() const override { return minStrike_; }
193 //! the maximum strike for which the term structure can return vols
194 Real maxStrike() const override { return maxStrike_; }
195 //@}
196 protected:
197 //! implements the actual volatility calculation in derived classes
198 Volatility volatilityImpl(Time length, Rate strike) const override;
199
202 };
203
204
205
206} // namespace QuantLib
207
208#endif
209
calendar class
Definition: calendar.hpp:61
Real minStrike() const override
the minimum strike for which the term structure can return vols
Volatility volatilityImpl(Time length, Rate strike) const override
implements the actual volatility calculation in derived classes
Date maxDate() const override
the latest date for which the curve can return values
Real maxStrike() const override
the maximum strike for which the term structure can return vols
Concrete date class.
Definition: date.hpp:125
static Date maxDate()
latest allowed date
Definition: date.cpp:771
day counter class
Definition: daycounter.hpp:44
Shared handle to an observable.
Definition: handle.hpp:41
template class providing a null value for a given type.
Definition: null.hpp:76
virtual Natural settlementDays() const
the settlementDays used for reference date calculation
Volatility term structure.
Real minStrike() const override=0
the minimum strike for which the term structure can return vols
virtual Volatility volatilityImpl(Time length, Rate strike) const =0
virtual Time timeFromBase(const Date &date, const Period &obsLag=Period(-1, Days)) const
base date will be in the past because of observation lag
~YoYOptionletVolatilitySurface() override=default
virtual void checkRange(const Date &, Rate strike, bool extrapolate) const
virtual VolatilityType volatilityType() const
Returns the volatility type.
virtual Volatility totalVariance(const Date &exerciseDate, Rate strike, const Period &obsLag=Period(-1, Days), bool extrapolate=false) const
Returns the total integrated variance for a given exercise date and strike rate.
virtual Real displacement() const
Returns the displacement for lognormal volatilities.
Real maxStrike() const override=0
the maximum strike for which the term structure can return vols
Volatility volatility(const Date &maturityDate, Rate strike, const Period &obsLag=Period(-1, Days), bool extrapolate=false) const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
Frequency
Frequency of events.
Definition: frequency.hpp:37
BusinessDayConvention
Business Day conventions.
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Volatility
volatility
Definition: types.hpp:78
Real Rate
interest rates
Definition: types.hpp:70
base class for 1-D interpolations
Definition: any.hpp:35
ext::shared_ptr< BlackVolTermStructure > v
purely virtual base class for market observables
TARGET calendar.
volatility types
Volatility term structure.