24#include <ql/experimental/exoticoptions/analyticpdfhestonengine.hpp>
25#include <ql/math/integrals/gausslobattointegral.hpp>
26#include <ql/methods/finitedifferences/utilities/hestonrndcalculator.hpp>
33 Size maxIntegrationIterations)
34 : maxIntegrationIterations_(maxIntegrationIterations), integrationEps_(integrationEps_),
35 model_(
std::move(model)) {}
40 "not an European option");
42 const ext::shared_ptr<HestonProcess>& process =
model_->process();
46 const Real xMax = 8.0 * std::sqrt(process->theta()*t
47 + (process->v0() - process->theta())
48 *(1-std::exp(-process->kappa()*t))/process->kappa());
50 const Real x0 = std::log(process->s0()->value());
51 const Real rD = process->riskFreeRate()->discount(t);
52 const Real qD = process->dividendYield()->discount(t);
54 const Real drift = x0 + std::log(rD/qD);
58 -xMax+drift, xMax+drift);
68 const Real x_t = std::log(s);
76 =
model_->process()->riskFreeRate()->discount(t);
78 const Real s_t = std::exp(x_t);
81 return (payoff != 0.0) ? payoff*
Pv(x_t, t)*rD :
Real(0.0);
Real cdf(Real X, Time t) const
AnalyticPDFHestonEngine(ext::shared_ptr< HestonModel > model, Real gaussLobattoEps=1e-6, Size gaussLobattoIntegrationOrder=10000UL)
void calculate() const override
const Real integrationEps_
Real Pv(Real x_t, Time t) const
const Size maxIntegrationIterations_
const ext::shared_ptr< HestonModel > model_
Real weightedPayoff(Real x_t, Time t) const
Integral of a one-dimensional function.
Risk neutral terminal probability density for the Heston model.
Real pdf(Real x, Time t) const override
Real cdf(Real x, Time t) const override
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates
std::size_t Size
size of a container