24#ifndef quantlib_noarbsabr_interpolation_hpp
25#define quantlib_noarbsabr_interpolation_hpp
42 std::vector<bool> ¶mIsFixed,
const Real &forward,
43 const Real expiryTime,
const std::vector<Real> &addParams) {
48 Real sigmaI = params[0] * std::pow(forward, params[1] - 1.0);
52 std::pow(forward, params[1] - 1.0);
57 (1.0 +
eps()) / params[0]) /
64 std::pow(forward, params[1] - 1.0);
69 (1.0 -
eps()) / params[0]) /
74 void guess(
Array &values,
const std::vector<bool> ¶mIsFixed,
75 const Real &forward,
const Real expiryTime,
76 const std::vector<Real> &
r,
const std::vector<Real> &) {
83 if (!paramIsFixed[0]) {
88 sigmaI *= (1.0 -
eps());
89 sigmaI +=
eps() / 2.0;
90 values[0] = sigmaI / std::pow(forward, values[1] - 1.0);
104 const std::vector<Real> ¶ms,
const Real forward) {
111 x[0] = std::tan((
y[0] * std::pow(forward,
y[1] - 1.0) -
130 const std::vector<Real> ¶ms,
const Real forward) {
138 (std::atan(x[1]) +
M_PI / 2.0) /
M_PI;
142 if (paramIsFixed[0]) {
144 Real sigmaI =
y[0] * std::pow(forward,
y[1] - 1.0);
148 (1.0 +
eps()) /
y[0]) /
154 (1.0 -
eps()) /
y[0]) /
161 (std::atan(x[0]) +
M_PI / 2.0) /
M_PI;
162 y[0] = sigmaI / std::pow(forward,
y[1] - 1.0);
170 (std::atan(x[2]) +
M_PI / 2.0) /
M_PI;
177 (std::atan(x[3]) +
M_PI / 2.0) /
M_PI;
181 const std::vector<Real> &addParams) {
186 const std::vector<Real> ¶ms,
187 const std::vector<Real> &) {
188 return ext::make_shared<type>(
t, forward, params);
196 template <
class I1,
class I2>
203 bool alphaIsFixed,
bool betaIsFixed,
bool nuIsFixed,
bool rhoIsFixed,
204 bool vegaWeighted =
true,
206 ext::shared_ptr<EndCriteria>(),
207 const ext::shared_ptr<OptimizationMethod> &optMethod =
208 ext::shared_ptr<OptimizationMethod>(),
209 const Real errorAccept = 0.0020,
const bool useMaxError =
false,
210 const Size maxGuesses = 50,
const Real shift = 0.0) {
212 QL_REQUIRE(shift==0.0,
"NoArbSabrInterpolation for non zero shift not implemented");
213 impl_ = ext::shared_ptr<Interpolation::Impl>(
217 {alphaIsFixed, betaIsFixed, nuIsFixed, rhoIsFixed},
218 vegaWeighted,
endCriteria, optMethod, errorAccept, useMaxError,
253 bool vegaWeighted =
false,
254 ext::shared_ptr<EndCriteria> endCriteria = ext::shared_ptr<EndCriteria>(),
255 ext::shared_ptr<OptimizationMethod> optMethod = ext::shared_ptr<OptimizationMethod>(),
256 const Real errorAccept = 0.0020,
257 const bool useMaxError =
false,
258 const Size maxGuesses = 50)
264 template <
class I1,
class I2>
266 const I2 &yBegin)
const {
1-D array used in linear algebra.
base class for 1-D interpolations.
ext::shared_ptr< Impl > impl_
no arbtrage sabr interpolation factory and traits
const ext::shared_ptr< OptimizationMethod > optMethod_
const ext::shared_ptr< EndCriteria > endCriteria_
Interpolation interpolate(const I1 &xBegin, const I1 &xEnd, const I2 &yBegin) const
NoArbSabr(Time t, Real forward, Real alpha, Real beta, Real nu, Real rho, bool alphaIsFixed, bool betaIsFixed, bool nuIsFixed, bool rhoIsFixed, bool vegaWeighted=false, ext::shared_ptr< EndCriteria > endCriteria=ext::shared_ptr< EndCriteria >(), ext::shared_ptr< OptimizationMethod > optMethod=ext::shared_ptr< OptimizationMethod >(), const Real errorAccept=0.0020, const bool useMaxError=false, const Size maxGuesses=50)
no arbitrage sabr smile interpolation between discrete volatility points.
NoArbSabrInterpolation(const I1 &xBegin, const I1 &xEnd, const I2 &yBegin, Time t, const Real &forward, Real alpha, Real beta, Real nu, Real rho, bool alphaIsFixed, bool betaIsFixed, bool nuIsFixed, bool rhoIsFixed, bool vegaWeighted=true, const ext::shared_ptr< EndCriteria > &endCriteria=ext::shared_ptr< EndCriteria >(), const ext::shared_ptr< OptimizationMethod > &optMethod=ext::shared_ptr< OptimizationMethod >(), const Real errorAccept=0.0020, const bool useMaxError=false, const Size maxGuesses=50, const Real shift=0.0)
EndCriteria::Type endCriteria()
const std::vector< Real > & interpolationWeights() const
const detail::XABRCoeffHolder< detail::NoArbSabrSpecs > & coeffs() const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
NoArbSabrSmileSection NoArbSabrWrapper
Real blackFormulaStdDevDerivative(Rate strike, Rate forward, Real stdDev, Real discount, Real displacement)
no arbitrage sabr smile section
ext::shared_ptr< YieldTermStructure > r
SABR interpolation interpolation between discrete points.
Array inverse(const Array &y, const std::vector< bool > ¶mIsFixed, const std::vector< Real > ¶ms, const Real forward)
Real weight(const Real strike, const Real forward, const Real stdDev, const std::vector< Real > &addParams)
Array direct(const Array &x, const std::vector< bool > ¶mIsFixed, const std::vector< Real > ¶ms, const Real forward)
ext::shared_ptr< type > instance(const Time t, const Real &forward, const std::vector< Real > ¶ms, const std::vector< Real > &)
void defaultValues(std::vector< Real > ¶ms, std::vector< bool > ¶mIsFixed, const Real &forward, const Real expiryTime, const std::vector< Real > &addParams)
void guess(Array &values, const std::vector< bool > ¶mIsFixed, const Real &forward, const Real expiryTime, const std::vector< Real > &r, const std::vector< Real > &)
void defaultValues(std::vector< Real > ¶ms, std::vector< bool > &, const Real &forward, const Real expiryTime, const std::vector< Real > &addParams)