QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
abcdatmvolcurve.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) 2007 Cristina Duminuco
5 Copyright (C) 2007 Ferdinando Ametrano
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21/*! \file abcdatmvolcurve.hpp
22 \brief Abcd-interpolated at-the-money (no-smile) interest rate vol curve
23*/
24
25#ifndef quantlib_abcd_atm_vol_curve_hpp
26#define quantlib_abcd_atm_vol_curve_hpp
27
32
33namespace QuantLib {
34
35 class Quote;
36
37 //! Abcd-interpolated at-the-money (no-smile) volatility curve
38 /*! blah blah
39 */
41 public LazyObject {
42 public:
43 //! floating reference date, floating market data
45 const Calendar& cal,
46 const std::vector<Period>& optionTenors,
47 const std::vector<Handle<Quote> >& volsHandles,
48 std::vector<bool> inclusionInInterpolationFlag = std::vector<bool>(1, true),
50 const DayCounter& dc = Actual365Fixed());
51 //! Returns k adjustment factors for option tenors used in interpolation
52 std::vector<Real> k() const;
53 //! Returns k adjustment factor at time t
54 Real k(Time t) const;
55 Real a() const;
56 Real b() const;
57 Real c() const;
58 Real d() const;
59 Real rmsError() const;
60 Real maxError() const;
62 //! \name TermStructure interface
63 //@{
64 Date maxDate() const override;
65 //@}
66 //! \name VolatilityTermStructure interface
67 //@{
68 Real minStrike() const override;
69 Real maxStrike() const override;
70 //@}
71 //! \name LazyObject interface
72 //@{
73 void update() override;
74 void performCalculations() const override;
75 //@}
76 //! \name some inspectors
77 //@{
78 const std::vector<Period>& optionTenors() const;
79 const std::vector<Period>& optionTenorsInInterpolation() const;
80 const std::vector<Date>& optionDates() const;
81 const std::vector<Time>& optionTimes() const;
82 //@}
83 //! \name Visitability
84 //@{
85 void accept(AcyclicVisitor&) override;
86 //@}
87 protected:
88 //! \name BlackAtmVolCurve interface
89 //@{
90 //! spot at-the-money variance calculation (k adjusted)
91 Real atmVarianceImpl(Time t) const override;
92 //! spot at-the-money volatility calculation (k adjusted)
93 Volatility atmVolImpl(Time t) const override;
94 //@}
95 private:
96 void checkInputs() const;
100 void interpolate();
101
103 std::vector<Period> optionTenors_;
104 mutable std::vector<Period> actualOptionTenors_;
105 mutable std::vector<Date> optionDates_;
106 mutable std::vector<Time> optionTimes_;
107 mutable std::vector<Time> actualOptionTimes_;
109
110 std::vector<Handle<Quote> > volHandles_;
111 mutable std::vector<Volatility> vols_;
112 mutable std::vector<Volatility> actualVols_;
113
114 mutable std::vector<bool> inclusionInInterpolation_;
115
116 ext::shared_ptr<AbcdInterpolation> interpolation_;
117 };
118
119 // inline
120
122 calculate();
123 return optionDateFromTenor(optionTenors_.back());
124 }
125
127 return QL_MIN_REAL;
128 }
129
131 return QL_MAX_REAL;
132 }
133
135 Volatility vol = atmVolImpl(t);
136 return vol*vol*t;
137 }
138
140 calculate();
141 return k(t) * (*interpolation_)(t, true);
142 }
143
144 inline const std::vector<Period>& AbcdAtmVolCurve::optionTenors() const {
145 return optionTenors_;
146 }
147
148 inline const std::vector<Period>& AbcdAtmVolCurve::optionTenorsInInterpolation() const {
149 return actualOptionTenors_;
150 }
151
152 inline
153 const std::vector<Date>& AbcdAtmVolCurve::optionDates() const {
154 return optionDates_;
155 }
156
157 inline
158 const std::vector<Time>& AbcdAtmVolCurve::optionTimes() const {
159 return optionTimes_;
160 }
161
162 inline
163 std::vector<Real> AbcdAtmVolCurve::k() const {
164 return interpolation_->k();
165 }
166
167 inline
169 return interpolation_->k(t,actualOptionTimes_.begin(),actualOptionTimes_.end());
170 }
171
172 inline Real AbcdAtmVolCurve::a() const {
173 return interpolation_->a();
174 }
175
176 inline Real AbcdAtmVolCurve::b() const {
177 return interpolation_->b();
178 }
179
180 inline Real AbcdAtmVolCurve::c() const {
181 return interpolation_->c();
182 }
183
184 inline Real AbcdAtmVolCurve::d() const {
185 return interpolation_->d();
186 }
187
189 return interpolation_->rmsError();
190 }
192 return interpolation_->maxError();
193 }
194
196 return interpolation_->endCriteria();
197 }
198}
199
200#endif
Abcd interpolation interpolation between discrete points.
Actual/365 (Fixed) day counter.
Black at-the-money (no-smile) volatility curve base class.
Abcd-interpolated at-the-money (no-smile) volatility curve.
std::vector< Date > optionDates_
void performCalculations() const override
Volatility atmVolImpl(Time t) const override
spot at-the-money volatility calculation (k adjusted)
std::vector< Volatility > actualVols_
Real minStrike() const override
the minimum strike for which the term structure can return vols
EndCriteria::Type endCriteria() const
void accept(AcyclicVisitor &) override
const std::vector< Period > & optionTenors() const
const std::vector< Period > & optionTenorsInInterpolation() const
const std::vector< Time > & optionTimes() const
std::vector< Time > optionTimes_
std::vector< Real > k() const
Returns k adjustment factors for option tenors used in interpolation.
Date maxDate() const override
the latest date for which the curve can return values
std::vector< bool > inclusionInInterpolation_
const std::vector< Date > & optionDates() const
std::vector< Period > optionTenors_
std::vector< Period > actualOptionTenors_
std::vector< Volatility > vols_
void initializeOptionDatesAndTimes() const
Real atmVarianceImpl(Time t) const override
spot at-the-money variance calculation (k adjusted)
Real maxStrike() const override
the maximum strike for which the term structure can return vols
std::vector< Handle< Quote > > volHandles_
std::vector< Time > actualOptionTimes_
ext::shared_ptr< AbcdInterpolation > interpolation_
Actual/365 (Fixed) day count convention.
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Black at-the-money (no-smile) volatility curve.
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Shared handle to an observable.
Definition: handle.hpp:41
Framework for calculation on demand and result caching.
Definition: lazyobject.hpp:35
virtual void calculate() const
Definition: lazyobject.hpp:253
virtual Natural settlementDays() const
the settlementDays used for reference date calculation
Date optionDateFromTenor(const Period &) const
period/date conversion
const DefaultType & t
BusinessDayConvention
Business Day conventions.
#define QL_MAX_REAL
Definition: qldefines.hpp:176
#define QL_MIN_REAL
Definition: qldefines.hpp:175
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
std::size_t Size
size of a container
Definition: types.hpp:58
framework for calculation on demand and result caching
Definition: any.hpp:35