25#include <ql/math/functional.hpp>
26#include <ql/math/solvers1d/brent.hpp>
27#include <ql/pricingengines/blackformula.hpp>
28#include <ql/termstructures/volatility/equityfx/hestonblackvolsurface.hpp>
29#include <ql/time/calendars/nullcalendar.hpp>
41 std::max(0.0, vol)*std::sqrt(maturity),
53 hestonModel->process()->riskFreeRate()->dayCounter()),
54 hestonModel_(hestonModel), cpxLogFormula_(cpxLogFormula),
55 integration_(
std::move(integration)) {
60 return hestonModel_->process()->riskFreeRate()->dayCounter();
69 return std::numeric_limits<Real>::max();
77 const ext::shared_ptr<HestonProcess> process =
hestonModel_->process();
79 const DiscountFactor df = process->riskFreeRate()->discount(t,
true);
80 const DiscountFactor div = process->dividendYield()->discount(t,
true);
81 const Real spotPrice = process->s0()->value();
83 const Real fwd = spotPrice
84 * process->dividendYield()->discount(t,
true)
85 / process->riskFreeRate()->discount(t,
true);
104 df, div, spotPrice, strike, t,
105 kappa, theta, sigma, v0, rho,
107 &hestonEngine, npv, evaluations);
109 if (npv <= 0.0)
return std::sqrt(theta);
114 constexpr double accuracy = std::numeric_limits<double>::epsilon();
116 return solver.
solve([&](
Volatility _v) {
return blackValue(payoff.optionType(), strike, fwd,
118 accuracy, guess, 0.01);
analytic Heston-model engine based on Fourier transform
static void doCalculation(Real riskFreeDiscount, Real dividendDiscount, Real spotPrice, Real strikePrice, Real term, Real kappa, Real theta, Real sigma, Real v0, Real rho, const TypePayoff &type, const Integration &integration, ComplexLogFormula cpxLog, const AnalyticHestonEngine *enginePtr, Real &value, Size &evaluations)
Black-volatility term structure.
static Date maxDate()
latest allowed date
Shared handle to an observable.
const ext::shared_ptr< T > & currentLink() const
dereferencing
const AnalyticHestonEngine::Integration integration_
HestonBlackVolSurface(const Handle< HestonModel > &hestonModel, AnalyticHestonEngine::ComplexLogFormula cpxLogFormula=AnalyticHestonEngine::Gatheral, AnalyticHestonEngine::Integration integration=AnalyticHestonEngine::Integration::gaussLaguerre(164))
Real minStrike() const override
the minimum strike for which the term structure can return vols
const Handle< HestonModel > hestonModel_
DayCounter dayCounter() const override
the day counter used for date/time conversion
Date maxDate() const override
the latest date for which the curve can return values
Real blackVarianceImpl(Time t, Real strike) const override
Black variance calculation.
Volatility blackVolImpl(Time t, Real strike) const override
Black volatility calculation.
Real maxStrike() const override
the maximum strike for which the term structure can return vols
const AnalyticHestonEngine::ComplexLogFormula cpxLogFormula_
Calendar for reproducing theoretical calculations.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
void setMaxEvaluations(Size evaluations)
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
std::size_t Size
size of a container
Real blackFormula(Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount, Real displacement)