QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
sabrinterpolatedsmilesection.hpp
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) 2006 François du Vignaud
6 Copyright (C) 2015 Peter Caspers
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
26#ifndef quantlib_sabr_interpolated_smile_section_hpp
27#define quantlib_sabr_interpolated_smile_section_hpp
28
29#include <ql/handle.hpp>
30#include <ql/patterns/lazyobject.hpp>
31#include <ql/termstructures/volatility/smilesection.hpp>
32#include <ql/math/interpolations/sabrinterpolation.hpp>
33#include <ql/time/daycounters/actual365fixed.hpp>
34
35namespace QuantLib {
36
37 class Quote;
39 public LazyObject {
40 public:
42
43
45 const Date& optionDate,
46 Handle<Quote> forward,
47 const std::vector<Rate>& strikes,
48 bool hasFloatingStrikes,
49 Handle<Quote> atmVolatility,
50 const std::vector<Handle<Quote> >& volHandles,
51 Real alpha,
52 Real beta,
53 Real nu,
54 Real rho,
55 bool isAlphaFixed = false,
56 bool isBetaFixed = false,
57 bool isNuFixed = false,
58 bool isRhoFixed = false,
59 bool vegaWeighted = true,
60 ext::shared_ptr<EndCriteria> endCriteria = ext::shared_ptr<EndCriteria>(),
61 ext::shared_ptr<OptimizationMethod> method = ext::shared_ptr<OptimizationMethod>(),
62 const DayCounter& dc = Actual365Fixed(),
63 Real shift = 0.0);
66 const Date& optionDate,
67 const Rate& forward,
68 const std::vector<Rate>& strikes,
69 bool hasFloatingStrikes,
70 const Volatility& atmVolatility,
71 const std::vector<Volatility>& vols,
72 Real alpha,
73 Real beta,
74 Real nu,
75 Real rho,
76 bool isAlphaFixed = false,
77 bool isBetaFixed = false,
78 bool isNuFixed = false,
79 bool isRhoFixed = false,
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(),
84 Real shift = 0.0);
86
88 void performCalculations() const override;
89 void update() override;
91
93 Real minStrike() const override;
94 Real maxStrike() const override;
95 Real atmLevel() const override;
97 Real varianceImpl(Rate strike) const override;
98 Volatility volatilityImpl(Rate strike) const override;
100
101 Real alpha() const;
102 Real beta() const;
103 Real nu() const;
104 Real rho() const;
105 Real rmsError() const;
106 Real maxError() const;
109
110 protected:
111
113 void createInterpolation() const;
114 mutable ext::shared_ptr<SABRInterpolation> sabrInterpolation_;
115
119 std::vector<Handle<Quote> > volHandles_;
120 mutable std::vector<Rate> strikes_;
122 mutable std::vector<Rate> actualStrikes_;
124
126 mutable std::vector<Volatility> vols_;
132 const ext::shared_ptr<EndCriteria> endCriteria_;
133 const ext::shared_ptr<OptimizationMethod> method_;
134
136 };
137
141 }
142
144 calculate();
145 return (*sabrInterpolation_)(strike, true);
146 }
147
149 calculate();
150 return sabrInterpolation_->alpha();
151 }
152
154 calculate();
155 return sabrInterpolation_->beta();
156 }
157
159 calculate();
160 return sabrInterpolation_->nu();
161 }
162
164 calculate();
165 return sabrInterpolation_->rho();
166 }
167
169 calculate();
170 return sabrInterpolation_->rmsError();
171 }
172
174 calculate();
175 return sabrInterpolation_->maxError();
176 }
177
179 calculate();
180 return sabrInterpolation_->endCriteria();
181 }
182
184 calculate();
185 return actualStrikes_.front();
186
187 }
188
190 calculate();
191 return actualStrikes_.back();
192 }
193
195 calculate();
196 return forwardValue_;
197 }
198
199
200}
201
202#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
const ext::shared_ptr< EndCriteria > endCriteria_
ext::shared_ptr< SABRInterpolation > sabrInterpolation_
void createInterpolation() const
Creates the mutable SABRInterpolation.
std::vector< Rate > actualStrikes_
Only strikes corresponding to valid market data.
const ext::shared_ptr< OptimizationMethod > method_
Volatility volatilityImpl(Rate strike) const override
interest rate volatility smile section
void update() override
virtual Rate shift() const
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