25#include <ql/math/distributions/normaldistribution.hpp>
26#include <ql/math/solvers1d/brent.hpp>
27#include <ql/methods/finitedifferences/utilities/gbsmrndcalculator.hpp>
28#include <ql/pricingengines/blackcalculator.hpp>
29#include <ql/processes/blackscholesprocess.hpp>
35 : process_(
std::move(process)) {}
38 const Real dk = 1e-3*k;
40 return (
cdf(k+dk, t) -
cdf(k-dk, t)) / (2*dk);
47 const Real dk = 1e-3*k;
49 = (volTS->blackVol(t, k+dk) - volTS->blackVol(t, k-dk)) / (2*dk);
52 =
process_->riskFreeRate()->discount(t,
true);
54 =
process_->dividendYield()->discount(t,
true);
57 const Real stdDev = std::sqrt(
58 process_->blackVolatility()->blackVariance(t, k,
true));
64 + calc.
vega(t) * dvol_dk) /dR;
70 + calc.
vega(t) * dvol_dk) /dR;
76 /
process_->riskFreeRate()->discount(t,
true)
77 *
process_->dividendYield()->discount(t,
true);
80 process_->blackVolatility()->blackVariance(t, fwd,
true));
84 const Real guess = fwd*std::exp(atmVariance*atmX);
87 while (guess/lower < 65535.0 &&
cdf(lower, t) > q)
91 while (upper/guess < 65535.0 &&
cdf(upper, t) < q) upper*=2;
93 QL_REQUIRE(guess/lower < 65535.0 && upper/guess < 65535.0,
94 "Could not find an start interval with ("
95 << lower <<
", " << upper <<
") -> ("
96 <<
cdf(lower, t) <<
", " <<
cdf(upper, t) <<
")");
100 1e-10, 0.5*(lower+upper), lower, upper);
Black 1976 calculator class.
Real vega(Time maturity) const
Real strikeSensitivity() const
Real cdf(Real s, Time t) const override
Real pdf(Real s, Time t) const override
Real invcdf(Real q, Time t) const override
const ext::shared_ptr< GeneralizedBlackScholesProcess > process_
GBSMRNDCalculator(ext::shared_ptr< GeneralizedBlackScholesProcess > process)
Shared handle to an observable.
Inverse cumulative normal distribution function.
Real solve(const F &f, Real accuracy, Real guess, Real step) const
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates
Real Volatility
volatility