QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
noarbsabr.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
50#ifndef quantlib_noarb_sabr
51#define quantlib_noarb_sabr
52
53#include <ql/qldefines.hpp>
54#include <ql/types.hpp>
55#include <ql/math/integrals/gausslobattointegral.hpp>
56
57#include <vector>
58
59namespace QuantLib {
60
61namespace detail {
62namespace NoArbSabrModel {
63// parameter bounds
64const Real beta_min = 0.01;
65const Real beta_max = 0.99;
66const Real expiryTime_max = 30.0;
67const Real sigmaI_min = 0.05;
68const Real sigmaI_max = 1.00;
69const Real nu_min = 0.01;
70const Real nu_max = 0.80;
71const Real rho_min = -0.99;
72const Real rho_max = 0.99;
73// cutoff for phi(d0) / tau
74// if beta = 0.99, d0 is below 1E-14 for
75// bigger values than this
76const Real phiByTau_cutoff = 124.587;
77// number of mc simulations in tabulated
78// absorption probabilities
79const Real nsim = 2500000.0;
80// small probability used for extrapolation
81// of beta towards 1
82const Real tiny_prob = 1E-5;
83// minimum strike used for normal case integration
84const Real strike_min = 1E-6;
85// accuracy and max iterations for
86// numerical integration
87const Real i_accuracy = 1E-7;
88const Size i_max_iterations = 10000;
89// accuracy when adjusting the model forward
90// to match the given forward
92// step for searching the model forward
93// in newton algorithm
95// lower bound for density evaluation
97// threshold to identify a zero density
98const Real density_threshold = 1E-100;
99}
100}
101
103
104 public:
106
107 Real optionPrice(Real strike) const;
108 Real digitalOptionPrice(Real strike) const;
109 Real density(const Real strike) const {
110 return p(strike) * (1 - absProb_) / numericalIntegralOverP_;
111 }
112
113 Real forward() const { return externalForward_; }
115 Real expiryTime() const { return expiryTime_; }
116 Real alpha() const { return alpha_; }
117 Real beta() const { return beta_; }
118 Real nu() const { return nu_; }
119 Real rho() const { return rho_; }
120
122
123 private:
124 Real p(Real f) const;
131 ext::shared_ptr<GaussLobattoIntegral> integrator_;
132 class integrand;
133 class p_integrand;
134};
135
136namespace detail {
137
138extern "C" const unsigned long sabrabsprob[1209600];
139
141 public:
142 D0Interpolator(Real forward, Real expiryTime, Real alpha, Real beta, Real nu, Real rho);
143 Real operator()() const;
144
145 private:
146 Real phi(Real d0) const;
147 Real d0(Real phi) const;
150 std::vector<Real> tauG_, sigmaIG_, rhoG_, nuG_, betaG_;
151};
152
153} // namespace detail
154} // namespace QuantLib
155
156#endif
Real p(Real f) const
Definition: noarbsabr.cpp:143
Real numericalForward() const
Definition: noarbsabr.hpp:114
Real digitalOptionPrice(Real strike) const
Definition: noarbsabr.cpp:125
Real density(const Real strike) const
Definition: noarbsabr.hpp:109
Real optionPrice(Real strike) const
Definition: noarbsabr.cpp:116
Real absorptionProbability() const
Definition: noarbsabr.hpp:121
ext::shared_ptr< GaussLobattoIntegral > integrator_
Definition: noarbsabr.hpp:131
Real forwardError(Real forward) const
Definition: noarbsabr.cpp:136
std::vector< Real > sigmaIG_
Definition: noarbsabr.hpp:150
std::vector< Real > betaG_
Definition: noarbsabr.hpp:150
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
const unsigned long sabrabsprob[1209600]
Definition: noarbsabr.hpp:138
Definition: any.hpp:35