QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
yoyinflationoptionletvolatilitystructure.hpp
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
24#ifndef quantlib_yoy_optionlet_volatility_structures_hpp
25#define quantlib_yoy_optionlet_volatility_structures_hpp
26
27#include <ql/termstructures/voltermstructure.hpp>
28#include <ql/termstructures/volatility/volatilitytype.hpp>
29#include <ql/math/interpolation.hpp>
30#include <ql/time/calendars/target.hpp>
31#include <ql/quote.hpp>
32
33namespace QuantLib {
34
42 public:
46 const Calendar&,
48 const DayCounter& dc,
53 Real displacement = 0.0);
54
55 ~YoYOptionletVolatilitySurface() override = default;
56
58
59
64 Volatility volatility(const Date& maturityDate,
65 Rate strike,
66 const Period &obsLag = Period(-1,Days),
67 bool extrapolate = false) const;
69 Volatility volatility(const Period& optionTenor,
70 Rate strike,
71 const Period &obsLag = Period(-1,Days),
72 bool extrapolate = false) const;
75 Volatility volatility(Time time, Rate strike) const;
76
78 virtual VolatilityType volatilityType() const { return volType_; }
80 virtual Real displacement() const { return displacement_; }
81
83
93 virtual Volatility totalVariance(const Date& exerciseDate,
94 Rate strike,
95 const Period &obsLag = Period(-1,Days),
96 bool extrapolate = false) const;
98 virtual Volatility totalVariance(const Period& optionTenor,
99 Rate strike,
100 const Period &obsLag = Period(-1,Days),
101 bool extrapolate = false) const;
102
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;
111 virtual Time timeFromBase(const Date &date,
112 const Period& obsLag = Period(-1,Days)) const;
114
116
117
118 Real minStrike() const override = 0;
120 Real maxStrike() const override = 0;
122
123 // acts as zero time value for boostrapping
124 virtual Volatility baseLevel() const {
125 QL_REQUIRE(baseLevel_ != Null<Volatility>(),
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
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
156 public:
158
159
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);
187
189
190 Date maxDate() const override { return Date::maxDate(); }
192 Real minStrike() const override { return minStrike_; }
194 Real maxStrike() const override { return maxStrike_; }
196 protected:
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
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