QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
noarbsabrinterpolatedsmilesection.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_noarbsabr_interpolated_smile_section_hpp
25#define quantlib_noarbsabr_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/noarbsabrinterpolation.hpp>
31#include <ql/time/daycounters/actual365fixed.hpp>
32
33namespace QuantLib {
34
35 class Quote;
37 public LazyObject {
38 public:
40
41
43 const Date& optionDate,
44 Handle<Quote> forward,
45 const std::vector<Rate>& strikes,
46 bool hasFloatingStrikes,
47 Handle<Quote> atmVolatility,
48 const std::vector<Handle<Quote> >& volHandles,
49 Real alpha,
50 Real beta,
51 Real nu,
52 Real rho,
53 bool isAlphaFixed = false,
54 bool isBetaFixed = false,
55 bool isNuFixed = false,
56 bool isRhoFixed = false,
57 bool vegaWeighted = true,
58 ext::shared_ptr<EndCriteria> endCriteria = ext::shared_ptr<EndCriteria>(),
59 ext::shared_ptr<OptimizationMethod> method = ext::shared_ptr<OptimizationMethod>(),
60 const DayCounter& dc = Actual365Fixed());
63 const Date& optionDate,
64 const Rate& forward,
65 const std::vector<Rate>& strikes,
66 bool hasFloatingStrikes,
67 const Volatility& atmVolatility,
68 const std::vector<Volatility>& vols,
69 Real alpha,
70 Real beta,
71 Real nu,
72 Real rho,
73 bool isAlphaFixed = false,
74 bool isBetaFixed = false,
75 bool isNuFixed = false,
76 bool isRhoFixed = false,
77 bool vegaWeighted = true,
78 ext::shared_ptr<EndCriteria> endCriteria = ext::shared_ptr<EndCriteria>(),
79 ext::shared_ptr<OptimizationMethod> method = ext::shared_ptr<OptimizationMethod>(),
80 const DayCounter& dc = Actual365Fixed());
82
84 void performCalculations() const override;
85 void update() override;
87
89 Real minStrike() const override;
90 Real maxStrike() const override;
91 Real atmLevel() const override;
93 Real varianceImpl(Rate strike) const override;
94 Volatility volatilityImpl(Rate strike) const override;
96
97 Real alpha() const;
98 Real beta() const;
99 Real nu() const;
100 Real rho() const;
101 Real rmsError() const;
102 Real maxError() const;
105
106 protected:
107
109 void createInterpolation() const;
110 mutable ext::shared_ptr<NoArbSabrInterpolation> noArbSabrInterpolation_;
111
115 std::vector<Handle<Quote> > volHandles_;
116 mutable std::vector<Rate> strikes_;
118 mutable std::vector<Rate> actualStrikes_;
120
122 mutable std::vector<Volatility> vols_;
128 const ext::shared_ptr<EndCriteria> endCriteria_;
129 const ext::shared_ptr<OptimizationMethod> method_;
130 };
131
135 }
136
138 calculate();
139 return (*noArbSabrInterpolation_)(strike, true);
140 }
141
143 calculate();
144 return noArbSabrInterpolation_->alpha();
145 }
146
148 calculate();
149 return noArbSabrInterpolation_->beta();
150 }
151
153 calculate();
154 return noArbSabrInterpolation_->nu();
155 }
156
158 calculate();
159 return noArbSabrInterpolation_->rho();
160 }
161
163 calculate();
164 return noArbSabrInterpolation_->rmsError();
165 }
166
168 calculate();
169 return noArbSabrInterpolation_->maxError();
170 }
171
173 calculate();
174 return noArbSabrInterpolation_->endCriteria();
175 }
176
178 calculate();
179 return actualStrikes_.front();
180
181 }
182
184 calculate();
185 return actualStrikes_.back();
186 }
187
189 calculate();
190 return forwardValue_;
191 }
192
193
194}
195
196#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
void createInterpolation() const
Creates the mutable SABRInterpolation.
std::vector< Rate > actualStrikes_
Only strikes corresponding to valid market data.
const ext::shared_ptr< OptimizationMethod > method_
ext::shared_ptr< NoArbSabrInterpolation > noArbSabrInterpolation_
interest rate volatility smile section
void update() 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