QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
cpivolatilitystructure.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, 2011 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 cpivolatilitystructure.hpp
21 \brief zero inflation (i.e. CPI/RPI/HICP/etc.) volatility structures
22 */
23
24#ifndef quantlib_cpi_volatility_structure_hpp
25#define quantlib_cpi_volatility_structure_hpp
26
28
29namespace QuantLib {
30
31 //! zero inflation (i.e. CPI/RPI/HICP/etc.) volatility structures
32 /*! Abstract interface. CPI volatility is always with respect to
33 some base date. Also deal with lagged observations of an index
34 with a (usually different) availability lag.
35 */
37 public:
38 /*! calculates the reference date based on the global
39 evaluation date.
40 */
42 const Calendar&,
44 const DayCounter& dc,
48
49 //! \name Volatility
50 /*! by default, inflation is observed with the lag
51 of the term structure.
52
53 Because inflation is highly linked to dates (for
54 interpolation, periods, etc) time-based overload of the
55 methods are not provided.
56 */
57 //@{
58 //! Returns the volatility for a given maturity date and strike rate.
59 Volatility volatility(const Date& maturityDate,
60 Rate strike,
61 const Period &obsLag = Period(-1,Days),
62 bool extrapolate = false) const;
63 //! returns the volatility for a given option tenor and strike rate
64 Volatility volatility(const Period& optionTenor,
65 Rate strike,
66 const Period &obsLag = Period(-1,Days),
67 bool extrapolate = false) const;
68 /*! Returns the volatility for a given time and strike rate. No adjustments
69 due to lags and interpolation are applied to the input time. */
70 Volatility volatility(Time time, Rate strike) const;
71
72 //! Returns the total integrated variance for a given exercise
73 //! date and strike rate.
74 /*! Total integrated variance is useful because it scales out
75 t for the optionlet pricing formulae. Note that it is
76 called "total" because the surface does not know whether
77 it represents Black, Bachelier or Displaced Diffusion
78 variance. These are virtual so alternate connections
79 between const vol and total var are possible.
80 */
81 virtual Volatility totalVariance(const Date& exerciseDate,
82 Rate strike,
83 const Period &obsLag = Period(-1,Days),
84 bool extrapolate = false) const;
85 //! returns the total integrated variance for a given option
86 //! tenor and strike rate.
87 virtual Volatility totalVariance(const Period& optionTenor,
88 Rate strike,
89 const Period &obsLag = Period(-1,Days),
90 bool extrapolate = false) const;
91 //@}
92
93 //! \name Inspectors
94 //@{
95 /*! The term structure observes with a lag that is usually
96 different from the availability lag of the index. An
97 inflation rate is given, by default, for the maturity
98 requested assuming this lag.
99 */
100 virtual Period observationLag() const { return observationLag_; }
101 virtual Frequency frequency() const { return frequency_; }
102 virtual bool indexIsInterpolated() const {
104 }
105 virtual Date baseDate() const;
106 //! base date will be in the past because of observation lag
107 virtual Time timeFromBase(const Date &date,
108 const Period& obsLag = Period(-1,Days)) const;
109 // acts as zero time value for boostrapping
110 virtual Volatility baseLevel() const {
112 "Base volatility, for baseDate(), not set.");
113 return baseLevel_;
114 }
115 //@}
116
117 //! \name Limits
118 //@{
119 //! the minimum strike for which the term structure can return vols
120 Real minStrike() const override = 0;
121 //! the maximum strike for which the term structure can return vols
122 Real maxStrike() const override = 0;
123 //@}
124 protected:
125 virtual void checkRange(const Date&, Rate strike, bool extrapolate) const;
126 virtual void checkRange(Time, Rate strike, bool extrapolate) const;
127
128 /*! Implements the actual volatility surface calculation in
129 derived classes e.g. bilinear interpolation. N.B. does
130 not derive the surface.
131 */
133 Rate strike) const = 0;
134
136 // so you do not need an index
140 };
141
142}
143
144#endif
145
zero inflation (i.e. CPI/RPI/HICP/etc.) volatility structures
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
virtual Volatility baseLevel() const
virtual void checkRange(const Date &, Rate strike, bool extrapolate) const
virtual Volatility totalVariance(const Date &exerciseDate, Rate strike, const Period &obsLag=Period(-1, Days), bool extrapolate=false) const
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
Returns the volatility for a given maturity date and strike rate.
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
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.
#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
Definition: any.hpp:35
Volatility term structure.