QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
yoyinflationoptionletvolatilitystructure2.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 yoyinflationoptionletvolatilitystructure2.hpp
21 \brief experimental yoy inflation volatility structures
22 */
23
24#ifndef quantlib_yoy_optionlet_volatility_structures2_hpp
25#define quantlib_yoy_optionlet_volatility_structures2_hpp
26
33
34namespace QuantLib {
35
36 //! Interpolated flat smile surface
37 /*! Interpolated in T direction and constant in K direction. */
38 template <class Interpolator1D>
41 protected InterpolatedCurve<Interpolator1D> {
42 public:
43 //! \name Constructor
44 //@{
45 //! calculate the reference date based on the global evaluation date
46 /*! The dates are those of the volatility ... there is no lag
47 on the dates <b>but</b> they are relative to a start date
48 earlier than the reference date as always for inflation.
49 */
51 const Calendar&,
53 const DayCounter& dc,
54 const Period &lag,
57 const std::vector<Date> &d,
58 const std::vector<Volatility> &v,
61 const Interpolator1D &i =
63 //@}
64
66
67 //! \name Limits
68 //@{
69 //! the minimum strike for which the term structure can return vols
70 Real minStrike() const override { return minStrike_; }
71 //! the maximum strike for which the term structure can return vols
72 Real maxStrike() const override { return maxStrike_; }
73 Date maxDate() const override {
74 //FIXME approx
75 return optionDateFromTenor(Period((int)ceil(this->interpolation_.xMax()),Years));
76 }
77 //@}
78
79 //! \name Bootstrap interface
80 //@{
81 virtual const std::vector<Time>& times() const {return this->times_;}
82 virtual const std::vector<Date>& dates() const {return dates_;}
83 virtual const std::vector<Real>& data() const {return this->data_;}
84 virtual std::vector<std::pair<Date, Real> > nodes() const {return nodes_;}
85 //@}
86
87 protected:
88 // we need a second constructor for when we have no data
89 // this is protected as we only expect to use it in the
90 // piecewise versions
92 const Calendar&,
94 const DayCounter& dc,
95 const Period &lag,
100 Volatility baseYoYVolatility,
101 const Interpolator1D &i =
103
104 // we do specify data representation here
105 // because the bootstrapper needs this specifically
106 mutable std::vector<Date> dates_;
107 std::vector<std::pair<Date, Real> > nodes_;
108 //@}
109
110 //! implements the actual volatility calculation in derived classes
111 Volatility volatilityImpl(Time length, Rate strike) const override;
112
114 };
115
116
117
118 template<class Interpolator1D>
121 const Calendar &cal,
123 const DayCounter& dc,
124 const Period &lag,
125 Frequency frequency,
126 bool indexIsInterpolated,
127 const std::vector<Date> &d,
128 const std::vector<Volatility> &v,
129 Rate minStrike,
130 Rate maxStrike,
131 const Interpolator1D &i)
132 : YoYOptionletVolatilitySurface(settlementDays, cal, bdc, dc, lag,
133 frequency, indexIsInterpolated),
135 dates_(d), minStrike_(minStrike), maxStrike_(maxStrike) {
136 QL_REQUIRE(d.size() == v.size(),
137 "must have same number of dates and vols: "
138 << d.size() << " vs " << v.size());
139 QL_REQUIRE(d.size() > 1,
140 "must have at least two dates: " << d.size());
141
142 for (Size j = 0; j < d.size(); j++ ){
143 this->times_.push_back( this->timeFromReference(dates_[j]) );
144 this->data_.push_back(v[j]),
145 nodes_.push_back( std::make_pair( dates_[j], this->data_[j]) );
146 }
147
148 this->setupInterpolation();
149 // set the base vol level to that predicted by the interpolation
150 // this is allowed by the extrapolation
151 Time baseTime = this->timeFromReference(baseDate());
152 setBaseLevel(this->interpolation_(baseTime,true));
153 }
154
155
156 template<class Interpolator1D>
159 const Calendar &cal,
161 const DayCounter& dc,
162 const Period &lag,
163 Frequency frequency,
164 bool indexIsInterpolated,
165 Rate minStrike,
166 Rate maxStrike,
167 Volatility baseYoYVolatility,
168 const Interpolator1D &i)
169 : YoYOptionletVolatilitySurface(settlementDays, cal, bdc, dc, lag,
170 frequency, indexIsInterpolated),
172 minStrike_(minStrike), maxStrike_(maxStrike) {
173 // don't have the data yet except for the base volatility
174 // must set to communicate with bootstrap
175 setBaseLevel(baseYoYVolatility);
176 }
177
178
179
180 //! For the curve strike is ignored because the smile is (can only be) flat.
181 template<class Interpolator1D>
184 Rate) const {
185 return this->interpolation_(t);
186 }
187
188} // namespace QuantLib
189
190#endif
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Helper class to build interpolated term structures.
InterpolatedYoYOptionletVolatilityCurve(Natural settlementDays, const Calendar &, BusinessDayConvention bdc, const DayCounter &dc, const Period &lag, Frequency frequency, bool indexIsInterpolated, const std::vector< Date > &d, const std::vector< Volatility > &v, Rate minStrike, Rate maxStrike, const Interpolator1D &i=Interpolator1D())
calculate the reference date based on the global evaluation date
Real minStrike() const override
the minimum strike for which the term structure can return vols
InterpolatedYoYOptionletVolatilityCurve(Natural settlementDays, const Calendar &, BusinessDayConvention bdc, const DayCounter &dc, const Period &lag, Frequency frequency, bool indexIsInterpolated, Rate minStrike, Rate maxStrike, Volatility baseYoYVolatility, const Interpolator1D &i=Interpolator1D())
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
virtual std::vector< std::pair< Date, Real > > nodes() const
virtual Natural settlementDays() const
the settlementDays used for reference date calculation
Time timeFromReference(const Date &date) const
date/time conversion
Date optionDateFromTenor(const Period &) const
period/date conversion
const DefaultType & t
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
Date d
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
std::size_t Size
size of a container
Definition: types.hpp:58
Base classes for inflation term structures.
Helper class to build interpolated term structures.
base class for 1-D interpolations
Definition: any.hpp:35
ext::shared_ptr< BlackVolTermStructure > v
TARGET calendar.
Volatility term structure.
yoy inflation volatility structures