QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
sviinterpolatedsmilesection.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2014 Peter Caspers
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_svi_interpolated_smile_section_hpp
25#define quantlib_svi_interpolated_smile_section_hpp
26
27#include <ql/handle.hpp>
28#include <ql/patterns/lazyobject.hpp>
29#include <ql/termstructures/volatility/smilesection.hpp>
30#include <ql/experimental/volatility/sviinterpolation.hpp>
31#include <ql/time/daycounters/actual365fixed.hpp>
32
33namespace QuantLib {
34
35class Quote;
37 public:
39
40
42 const Date& optionDate,
43 Handle<Quote> forward,
44 const std::vector<Rate>& strikes,
45 bool hasFloatingStrikes,
46 Handle<Quote> atmVolatility,
47 const std::vector<Handle<Quote> >& volHandles,
48 Real a,
49 Real b,
50 Real sigma,
51 Real rho,
52 Real m,
53 bool aIsFixed,
54 bool bIsFixed,
55 bool sigmaIsFixed,
56 bool rhoIsFixed,
57 bool mIsFixed,
58 bool vegaWeighted = true,
59 ext::shared_ptr<EndCriteria> endCriteria = ext::shared_ptr<EndCriteria>(),
60 ext::shared_ptr<OptimizationMethod> method = ext::shared_ptr<OptimizationMethod>(),
61 const DayCounter& dc = Actual365Fixed());
64 const Date& optionDate,
65 const Rate& forward,
66 const std::vector<Rate>& strikes,
67 bool hasFloatingStrikes,
68 const Volatility& atmVolatility,
69 const std::vector<Volatility>& vols,
70 Real a,
71 Real b,
72 Real sigma,
73 Real rho,
74 Real m,
75 bool isAFixed,
76 bool isBFixed,
77 bool isSigmaFixed,
78 bool isRhoFixed,
79 bool isMFixed,
80 bool vegaWeighted = true,
81 ext::shared_ptr<EndCriteria> endCriteria = ext::shared_ptr<EndCriteria>(),
82 ext::shared_ptr<OptimizationMethod> method = ext::shared_ptr<OptimizationMethod>(),
83 const DayCounter& dc = Actual365Fixed());
85
87 void performCalculations() const override;
88 void update() override;
90
92 Real minStrike() const override;
93 Real maxStrike() const override;
94 Real atmLevel() const override;
96 Real varianceImpl(Rate strike) const override;
97 Volatility volatilityImpl(Rate strike) const override;
99
100 Real a() const;
101 Real b() const;
102 Real sigma() const;
103 Real rho() const;
104 Real m() const;
105 Real rmsError() const;
106 Real maxError() const;
109
110 protected:
112 void createInterpolation() const;
113 mutable ext::shared_ptr<SviInterpolation> sviInterpolation_;
114
118 std::vector<Handle<Quote> > volHandles_;
119 mutable std::vector<Rate> strikes_;
121 mutable std::vector<Rate> actualStrikes_;
123
125 mutable std::vector<Volatility> vols_;
131 const ext::shared_ptr<EndCriteria> endCriteria_;
132 const ext::shared_ptr<OptimizationMethod> method_;
133};
134
138}
139
141 calculate();
142 return (*sviInterpolation_)(strike, true);
143}
144
146 calculate();
147 return sviInterpolation_->a();
148}
149
151 calculate();
152 return sviInterpolation_->b();
153}
154
156 calculate();
157 return sviInterpolation_->sigma();
158}
159
161 calculate();
162 return sviInterpolation_->rho();
163}
164
166 calculate();
167 return sviInterpolation_->m();
168}
169
171 calculate();
172 return sviInterpolation_->rmsError();
173}
174
176 calculate();
177 return sviInterpolation_->maxError();
178}
179
181 calculate();
182 return sviInterpolation_->endCriteria();
183}
184
186 calculate();
187 return actualStrikes_.front();
188}
189
191 calculate();
192 return actualStrikes_.back();
193}
194
196 calculate();
197 return forwardValue_;
198}
199}
200
201#endif
Actual/365 (Fixed) day count convention.
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
void update() override
Definition: lazyobject.hpp:188
interest rate volatility smile section
void update() override
ext::shared_ptr< SviInterpolation > sviInterpolation_
const ext::shared_ptr< EndCriteria > endCriteria_
void createInterpolation() const
Creates the mutable SviInterpolation.
std::vector< Rate > actualStrikes_
Only strikes corresponding to valid market data.
const ext::shared_ptr< OptimizationMethod > method_
Volatility volatilityImpl(Rate strike) const override
QL_REAL Real
real number
Definition: types.hpp:50
Real Volatility
volatility
Definition: types.hpp:78
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35