/src/quantlib/ql/math/interpolations/xabrinterpolation.hpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2006 Ferdinando Ametrano |
5 | | Copyright (C) 2007 Marco Bianchetti |
6 | | Copyright (C) 2007 François du Vignaud |
7 | | Copyright (C) 2007 Giorgio Facchinetti |
8 | | Copyright (C) 2006 Mario Pucci |
9 | | Copyright (C) 2006 StatPro Italia srl |
10 | | Copyright (C) 2014 Peter Caspers |
11 | | |
12 | | This file is part of QuantLib, a free-software/open-source library |
13 | | for financial quantitative analysts and developers - http://quantlib.org/ |
14 | | |
15 | | QuantLib is free software: you can redistribute it and/or modify it |
16 | | under the terms of the QuantLib license. You should have received a |
17 | | copy of the license along with this program; if not, please email |
18 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
19 | | <https://www.quantlib.org/license.shtml>. |
20 | | |
21 | | This program is distributed in the hope that it will be useful, but WITHOUT |
22 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
23 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
24 | | */ |
25 | | |
26 | | /*! \file xabrinterpolation.hpp |
27 | | \brief generic interpolation class for sabr style underlying models |
28 | | like the Hagan 2002 expansion, Doust's no arbitrage sabr, |
29 | | Andreasen's zabr expansion for the masses and similar |
30 | | */ |
31 | | |
32 | | #ifndef ql_xabr_interpolation_hpp |
33 | | #define ql_xabr_interpolation_hpp |
34 | | |
35 | | #include <ql/math/interpolation.hpp> |
36 | | #include <ql/math/optimization/constraint.hpp> |
37 | | #include <ql/math/optimization/levenbergmarquardt.hpp> |
38 | | #include <ql/math/optimization/method.hpp> |
39 | | #include <ql/math/optimization/projectedcostfunction.hpp> |
40 | | #include <ql/math/optimization/simplex.hpp> |
41 | | #include <ql/math/randomnumbers/haltonrsg.hpp> |
42 | | #include <ql/pricingengines/blackformula.hpp> |
43 | | #include <ql/termstructures/volatility/volatilitytype.hpp> |
44 | | #include <ql/utilities/dataformatters.hpp> |
45 | | #include <ql/utilities/null.hpp> |
46 | | #include <utility> |
47 | | #include <cmath> |
48 | | |
49 | | namespace QuantLib::detail { |
50 | | |
51 | | template <typename Model> class XABRCoeffHolder { |
52 | | public: |
53 | | XABRCoeffHolder(const Time t, |
54 | | const Real& forward, |
55 | | const std::vector<Real>& params, |
56 | | const std::vector<bool>& paramIsFixed, |
57 | | std::vector<Real> addParams) |
58 | 0 | : t_(t), forward_(forward), params_(params), paramIsFixed_(paramIsFixed.size(), false), |
59 | 0 | error_(Null<Real>()), maxError_(Null<Real>()), addParams_(std::move(addParams)) { |
60 | 0 | QL_REQUIRE(t > 0.0, "expiry time must be positive: " << t |
61 | 0 | << " not allowed"); |
62 | 0 | QL_REQUIRE(params.size() == Model().dimension(), |
63 | 0 | "wrong number of parameters (" << params.size() |
64 | 0 | << "), should be " |
65 | 0 | << Model().dimension()); |
66 | 0 | QL_REQUIRE(paramIsFixed.size() == Model().dimension(), |
67 | 0 | "wrong number of fixed parameters flags (" |
68 | 0 | << paramIsFixed.size() << "), should be " |
69 | 0 | << Model().dimension()); |
70 | | |
71 | 0 | for (Size i = 0; i < params.size(); ++i) { |
72 | 0 | if (params[i] != Null<Real>()) |
73 | 0 | paramIsFixed_[i] = paramIsFixed[i]; |
74 | 0 | } |
75 | 0 | Model().defaultValues(params_, paramIsFixed_, forward_, t_, addParams_); |
76 | 0 | updateModelInstance(); |
77 | 0 | } Unexecuted instantiation: QuantLib::detail::XABRCoeffHolder<QuantLib::detail::NoArbSabrSpecs>::XABRCoeffHolder(double, double const&, std::__1::vector<double, std::__1::allocator<double> > const&, std::__1::vector<bool, std::__1::allocator<bool> > const&, std::__1::vector<double, std::__1::allocator<double> >) Unexecuted instantiation: QuantLib::detail::XABRCoeffHolder<QuantLib::detail::SviSpecs>::XABRCoeffHolder(double, double const&, std::__1::vector<double, std::__1::allocator<double> > const&, std::__1::vector<bool, std::__1::allocator<bool> > const&, std::__1::vector<double, std::__1::allocator<double> >) Unexecuted instantiation: QuantLib::detail::XABRCoeffHolder<QuantLib::detail::SABRSpecs>::XABRCoeffHolder(double, double const&, std::__1::vector<double, std::__1::allocator<double> > const&, std::__1::vector<bool, std::__1::allocator<bool> > const&, std::__1::vector<double, std::__1::allocator<double> >) |
78 | 0 | virtual ~XABRCoeffHolder() = default; Unexecuted instantiation: QuantLib::detail::XABRCoeffHolder<QuantLib::detail::NoArbSabrSpecs>::~XABRCoeffHolder() Unexecuted instantiation: QuantLib::detail::XABRCoeffHolder<QuantLib::detail::SviSpecs>::~XABRCoeffHolder() Unexecuted instantiation: QuantLib::detail::XABRCoeffHolder<QuantLib::detail::SABRSpecs>::~XABRCoeffHolder() |
79 | | |
80 | 0 | void updateModelInstance() { |
81 | 0 | modelInstance_ = Model().instance(t_, forward_, params_, addParams_); |
82 | 0 | } Unexecuted instantiation: QuantLib::detail::XABRCoeffHolder<QuantLib::detail::NoArbSabrSpecs>::updateModelInstance() Unexecuted instantiation: QuantLib::detail::XABRCoeffHolder<QuantLib::detail::SviSpecs>::updateModelInstance() Unexecuted instantiation: QuantLib::detail::XABRCoeffHolder<QuantLib::detail::SABRSpecs>::updateModelInstance() |
83 | | |
84 | | /*! Expiry, Forward */ |
85 | | Real t_; |
86 | | const Real &forward_; |
87 | | /*! Parameters */ |
88 | | std::vector<Real> params_; |
89 | | std::vector<bool> paramIsFixed_; |
90 | | std::vector<Real> weights_; |
91 | | /*! Interpolation results */ |
92 | | Real error_, maxError_; |
93 | | EndCriteria::Type XABREndCriteria_ = EndCriteria::None; |
94 | | /*! Model instance (if required) */ |
95 | | ext::shared_ptr<typename Model::type> modelInstance_; |
96 | | /*! additional parameters */ |
97 | | std::vector<Real> addParams_; |
98 | | }; |
99 | | |
100 | | template <class I1, class I2, typename Model> |
101 | | class XABRInterpolationImpl final : public Interpolation::templateImpl<I1, I2>, |
102 | | public XABRCoeffHolder<Model> { |
103 | | public: |
104 | | XABRInterpolationImpl(const I1& xBegin, |
105 | | const I1& xEnd, |
106 | | const I2& yBegin, |
107 | | Time t, |
108 | | const Real& forward, |
109 | | const std::vector<Real>& params, |
110 | | const std::vector<bool>& paramIsFixed, |
111 | | bool vegaWeighted, |
112 | | ext::shared_ptr<EndCriteria> endCriteria, |
113 | | ext::shared_ptr<OptimizationMethod> optMethod, |
114 | | const Real errorAccept, |
115 | | const bool useMaxError, |
116 | | const Size maxGuesses, |
117 | | const std::vector<Real>& addParams = std::vector<Real>(), |
118 | | VolatilityType volatilityType = VolatilityType::ShiftedLognormal) |
119 | 0 | : Interpolation::templateImpl<I1, I2>(xBegin, xEnd, yBegin, 1), |
120 | 0 | XABRCoeffHolder<Model>(t, forward, params, paramIsFixed, addParams), |
121 | 0 | endCriteria_(std::move(endCriteria)), optMethod_(std::move(optMethod)), |
122 | 0 | errorAccept_(errorAccept), useMaxError_(useMaxError), maxGuesses_(maxGuesses), |
123 | 0 | vegaWeighted_(vegaWeighted), volatilityType_(volatilityType) { |
124 | | // if no optimization method or endCriteria is provided, we provide one |
125 | 0 | if (!optMethod_) |
126 | 0 | optMethod_ = ext::shared_ptr<OptimizationMethod>( |
127 | 0 | new LevenbergMarquardt(1e-8, 1e-8, 1e-8)); |
128 | | // optMethod_ = ext::shared_ptr<OptimizationMethod>(new |
129 | | // Simplex(0.01)); |
130 | 0 | if (!endCriteria_) { |
131 | 0 | endCriteria_ = ext::make_shared<EndCriteria>( |
132 | 0 | 60000, 100, 1e-8, 1e-8, 1e-8); |
133 | 0 | } |
134 | 0 | this->weights_ = |
135 | 0 | std::vector<Real>(xEnd - xBegin, 1.0 / (xEnd - xBegin)); |
136 | 0 | } Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::NoArbSabrSpecs>::XABRInterpolationImpl(std::__1::__wrap_iter<double*> const&, std::__1::__wrap_iter<double*> const&, std::__1::__wrap_iter<double*> const&, double, double const&, std::__1::vector<double, std::__1::allocator<double> > const&, std::__1::vector<bool, std::__1::allocator<bool> > const&, bool, boost::shared_ptr<QuantLib::EndCriteria>, boost::shared_ptr<QuantLib::OptimizationMethod>, double, bool, unsigned long, std::__1::vector<double, std::__1::allocator<double> > const&, QuantLib::VolatilityType) Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SviSpecs>::XABRInterpolationImpl(std::__1::__wrap_iter<double*> const&, std::__1::__wrap_iter<double*> const&, std::__1::__wrap_iter<double*> const&, double, double const&, std::__1::vector<double, std::__1::allocator<double> > const&, std::__1::vector<bool, std::__1::allocator<bool> > const&, bool, boost::shared_ptr<QuantLib::EndCriteria>, boost::shared_ptr<QuantLib::OptimizationMethod>, double, bool, unsigned long, std::__1::vector<double, std::__1::allocator<double> > const&, QuantLib::VolatilityType) Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SABRSpecs>::XABRInterpolationImpl(std::__1::__wrap_iter<double*> const&, std::__1::__wrap_iter<double*> const&, std::__1::__wrap_iter<double*> const&, double, double const&, std::__1::vector<double, std::__1::allocator<double> > const&, std::__1::vector<bool, std::__1::allocator<bool> > const&, bool, boost::shared_ptr<QuantLib::EndCriteria>, boost::shared_ptr<QuantLib::OptimizationMethod>, double, bool, unsigned long, std::__1::vector<double, std::__1::allocator<double> > const&, QuantLib::VolatilityType) |
137 | | |
138 | 0 | void update() override { |
139 | 0 | this->updateModelInstance(); |
140 | | |
141 | | // we should also check that y contains positive values only |
142 | | |
143 | | // we must update weights if it is vegaWeighted |
144 | 0 | if (vegaWeighted_) { |
145 | 0 | I1 x = this->xBegin_; |
146 | 0 | I2 y = this->yBegin_; |
147 | | // std::vector<Real>::iterator w = weights_.begin(); |
148 | 0 | this->weights_.clear(); |
149 | 0 | Real weightsSum = 0.0; |
150 | 0 | for (; x != this->xEnd_; ++x, ++y) { |
151 | 0 | Real stdDev = std::sqrt((*y) * (*y) * this->t_); |
152 | 0 | this->weights_.push_back(Model().weight(*x, this->forward_, stdDev, |
153 | 0 | this->addParams_)); |
154 | 0 | weightsSum += this->weights_.back(); |
155 | 0 | } |
156 | | // weight normalization |
157 | 0 | auto w = this->weights_.begin(); |
158 | 0 | for (; w != this->weights_.end(); ++w) |
159 | 0 | *w /= weightsSum; |
160 | 0 | } |
161 | | |
162 | | // there is nothing to optimize |
163 | 0 | if (std::accumulate(this->paramIsFixed_.begin(), |
164 | 0 | this->paramIsFixed_.end(), true, |
165 | 0 | std::logical_and<>())) { |
166 | 0 | this->error_ = interpolationError(); |
167 | 0 | this->maxError_ = interpolationMaxError(); |
168 | 0 | this->XABREndCriteria_ = EndCriteria::None; |
169 | 0 | return; |
170 | 0 | } else { |
171 | 0 | XABRError costFunction(this); |
172 | |
|
173 | 0 | Array guess(Model().dimension()); |
174 | 0 | for (Size i = 0; i < guess.size(); ++i) |
175 | 0 | guess[i] = this->params_[i]; |
176 | |
|
177 | 0 | Size iterations = 0; |
178 | 0 | Size freeParameters = 0; |
179 | 0 | Real bestError = QL_MAX_REAL; |
180 | 0 | Array bestParameters; |
181 | 0 | for (Size i = 0; i < Model().dimension(); ++i) |
182 | 0 | if (!this->paramIsFixed_[i]) |
183 | 0 | ++freeParameters; |
184 | 0 | HaltonRsg halton(freeParameters, 42); |
185 | 0 | EndCriteria::Type tmpEndCriteria; |
186 | 0 | Real tmpInterpolationError; |
187 | |
|
188 | 0 | do { |
189 | 0 | if (iterations > 0) { |
190 | 0 | const auto& s = halton.nextSequence(); |
191 | 0 | Model().guess(guess, this->paramIsFixed_, this->forward_, |
192 | 0 | this->t_, s.value, this->addParams_); |
193 | 0 | for (Size i = 0; i < this->paramIsFixed_.size(); ++i) |
194 | 0 | if (this->paramIsFixed_[i]) |
195 | 0 | guess[i] = this->params_[i]; |
196 | 0 | } |
197 | |
|
198 | 0 | Array inversedTransformatedGuess(Model().inverse( |
199 | 0 | guess, this->paramIsFixed_, this->params_, this->forward_)); |
200 | |
|
201 | 0 | ProjectedCostFunction constrainedXABRError( |
202 | 0 | costFunction, inversedTransformatedGuess, |
203 | 0 | this->paramIsFixed_); |
204 | |
|
205 | 0 | Array projectedGuess( |
206 | 0 | constrainedXABRError.project(inversedTransformatedGuess)); |
207 | |
|
208 | 0 | NoConstraint constraint; |
209 | 0 | Problem problem(constrainedXABRError, constraint, |
210 | 0 | projectedGuess); |
211 | 0 | tmpEndCriteria = optMethod_->minimize(problem, *endCriteria_); |
212 | 0 | Array projectedResult(problem.currentValue()); |
213 | 0 | Array transfResult( |
214 | 0 | constrainedXABRError.include(projectedResult)); |
215 | |
|
216 | 0 | Array result = Model().direct(transfResult, this->paramIsFixed_, |
217 | 0 | this->params_, this->forward_); |
218 | 0 | tmpInterpolationError = useMaxError_ ? interpolationMaxError() |
219 | 0 | : interpolationError(); |
220 | |
|
221 | 0 | if (tmpInterpolationError < bestError) { |
222 | 0 | bestError = tmpInterpolationError; |
223 | 0 | bestParameters = result; |
224 | 0 | this->XABREndCriteria_ = tmpEndCriteria; |
225 | 0 | } |
226 | |
|
227 | 0 | } while (++iterations < maxGuesses_ && |
228 | 0 | tmpInterpolationError > errorAccept_); |
229 | |
|
230 | 0 | for (Size i = 0; i < bestParameters.size(); ++i) |
231 | 0 | this->params_[i] = bestParameters[i]; |
232 | |
|
233 | 0 | this->error_ = interpolationError(); |
234 | 0 | this->maxError_ = interpolationMaxError(); |
235 | 0 | } |
236 | 0 | } Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::NoArbSabrSpecs>::update() Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SviSpecs>::update() Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SABRSpecs>::update() |
237 | | |
238 | 0 | Real value(Real x) const override { return this->modelInstance_->volatility(x, volatilityType_); }Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::NoArbSabrSpecs>::value(double) const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SviSpecs>::value(double) const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SABRSpecs>::value(double) const |
239 | | |
240 | 0 | Real primitive(Real) const override { QL_FAIL("XABR primitive not implemented"); }Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::NoArbSabrSpecs>::primitive(double) const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SviSpecs>::primitive(double) const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SABRSpecs>::primitive(double) const |
241 | 0 | Real derivative(Real) const override { QL_FAIL("XABR derivative not implemented"); }Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::NoArbSabrSpecs>::derivative(double) const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SviSpecs>::derivative(double) const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SABRSpecs>::derivative(double) const |
242 | 0 | Real secondDerivative(Real) const override { QL_FAIL("XABR secondDerivative not implemented"); }Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::NoArbSabrSpecs>::secondDerivative(double) const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SviSpecs>::secondDerivative(double) const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SABRSpecs>::secondDerivative(double) const |
243 | | |
244 | | // calculate total squared weighted difference (L2 norm) |
245 | 0 | Real interpolationSquaredError() const { |
246 | 0 | Real error, totalError = 0.0; |
247 | 0 | I1 x = this->xBegin_; |
248 | 0 | I2 y = this->yBegin_; |
249 | 0 | auto w = this->weights_.begin(); |
250 | 0 | for (; x != this->xEnd_; ++x, ++y, ++w) { |
251 | 0 | error = (value(*x) - *y); |
252 | 0 | totalError += error * error * (*w); |
253 | 0 | } |
254 | 0 | return totalError; |
255 | 0 | } Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::NoArbSabrSpecs>::interpolationSquaredError() const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SviSpecs>::interpolationSquaredError() const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SABRSpecs>::interpolationSquaredError() const |
256 | | |
257 | | // calculate weighted differences |
258 | 0 | Array interpolationErrors() const { |
259 | 0 | Array results(this->xEnd_ - this->xBegin_); |
260 | 0 | I1 x = this->xBegin_; |
261 | 0 | Array::iterator r = results.begin(); |
262 | 0 | I2 y = this->yBegin_; |
263 | 0 | auto w = this->weights_.begin(); |
264 | 0 | for (; x != this->xEnd_; ++x, ++r, ++w, ++y) { |
265 | 0 | *r = (value(*x) - *y) * std::sqrt(*w); |
266 | 0 | } |
267 | 0 | return results; |
268 | 0 | } Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::NoArbSabrSpecs>::interpolationErrors() const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SviSpecs>::interpolationErrors() const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SABRSpecs>::interpolationErrors() const |
269 | | |
270 | 0 | Real interpolationError() const { |
271 | 0 | Size n = this->xEnd_ - this->xBegin_; |
272 | 0 | Real squaredError = interpolationSquaredError(); |
273 | 0 | return std::sqrt(n * squaredError / (n==1 ? 1 : (n - 1))); |
274 | 0 | } Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::NoArbSabrSpecs>::interpolationError() const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SviSpecs>::interpolationError() const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SABRSpecs>::interpolationError() const |
275 | | |
276 | 0 | Real interpolationMaxError() const { |
277 | 0 | Real error, maxError = QL_MIN_REAL; |
278 | 0 | I1 i = this->xBegin_; |
279 | 0 | I2 j = this->yBegin_; |
280 | 0 | for (; i != this->xEnd_; ++i, ++j) { |
281 | 0 | error = std::fabs(value(*i) - *j); |
282 | 0 | maxError = std::max(maxError, error); |
283 | 0 | } |
284 | 0 | return maxError; |
285 | 0 | } Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::NoArbSabrSpecs>::interpolationMaxError() const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SviSpecs>::interpolationMaxError() const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SABRSpecs>::interpolationMaxError() const |
286 | | |
287 | | private: |
288 | | class XABRError : public CostFunction { |
289 | | public: |
290 | 0 | explicit XABRError(XABRInterpolationImpl *xabr) : xabr_(xabr) {}Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::NoArbSabrSpecs>::XABRError::XABRError(QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::NoArbSabrSpecs>*) Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SviSpecs>::XABRError::XABRError(QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SviSpecs>*) Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SABRSpecs>::XABRError::XABRError(QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SABRSpecs>*) |
291 | | |
292 | 0 | Real value(const Array& x) const override { |
293 | 0 | const Array y = Model().direct(x, xabr_->paramIsFixed_, |
294 | 0 | xabr_->params_, xabr_->forward_); |
295 | 0 | for (Size i = 0; i < xabr_->params_.size(); ++i) |
296 | 0 | xabr_->params_[i] = y[i]; |
297 | 0 | xabr_->updateModelInstance(); |
298 | 0 | return xabr_->interpolationSquaredError(); |
299 | 0 | } Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::NoArbSabrSpecs>::XABRError::value(QuantLib::Array const&) const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SviSpecs>::XABRError::value(QuantLib::Array const&) const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SABRSpecs>::XABRError::value(QuantLib::Array const&) const |
300 | | |
301 | 0 | Array values(const Array& x) const override { |
302 | 0 | const Array y = Model().direct(x, xabr_->paramIsFixed_, |
303 | 0 | xabr_->params_, xabr_->forward_); |
304 | 0 | for (Size i = 0; i < xabr_->params_.size(); ++i) |
305 | 0 | xabr_->params_[i] = y[i]; |
306 | 0 | xabr_->updateModelInstance(); |
307 | 0 | return xabr_->interpolationErrors(); |
308 | 0 | } Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::NoArbSabrSpecs>::XABRError::values(QuantLib::Array const&) const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SviSpecs>::XABRError::values(QuantLib::Array const&) const Unexecuted instantiation: QuantLib::detail::XABRInterpolationImpl<std::__1::__wrap_iter<double*>, std::__1::__wrap_iter<double*>, QuantLib::detail::SABRSpecs>::XABRError::values(QuantLib::Array const&) const |
309 | | |
310 | | private: |
311 | | XABRInterpolationImpl *xabr_; |
312 | | }; |
313 | | ext::shared_ptr<EndCriteria> endCriteria_; |
314 | | ext::shared_ptr<OptimizationMethod> optMethod_; |
315 | | const Real errorAccept_; |
316 | | const bool useMaxError_; |
317 | | const Size maxGuesses_; |
318 | | bool vegaWeighted_; |
319 | | NoConstraint constraint_; |
320 | | VolatilityType volatilityType_; |
321 | | }; |
322 | | |
323 | | } // namespace QuantLib |
324 | | |
325 | | #endif |