43 ext::shared_ptr<LocalVolTermStructure> leverageFct,
44 const Real mixingFactor)
48 tGrid_(tGrid), xGrid_(xGrid), vGrid_(vGrid), dampingSteps_(dampingSteps),
49 schemeDesc_(schemeDesc), leverageFct_(
std::move(leverageFct)),
50 quantoHelper_(ext::shared_ptr<
FdmQuantoHelper>()), mixingFactor_(mixingFactor) {}
59 ext::shared_ptr<LocalVolTermStructure> leverageFct,
60 const Real mixingFactor)
64 dividends_(
std::move(dividends)),
65 tGrid_(tGrid), xGrid_(xGrid), vGrid_(vGrid), dampingSteps_(dampingSteps),
66 schemeDesc_(schemeDesc), leverageFct_(
std::move(leverageFct)),
67 quantoHelper_(ext::shared_ptr<
FdmQuantoHelper>()), mixingFactor_(mixingFactor) {}
70 ext::shared_ptr<FdmQuantoHelper> quantoHelper,
76 ext::shared_ptr<LocalVolTermStructure> leverageFct,
77 const Real mixingFactor)
81 tGrid_(tGrid), xGrid_(xGrid), vGrid_(vGrid), dampingSteps_(dampingSteps),
82 schemeDesc_(schemeDesc), leverageFct_(
std::move(leverageFct)),
83 quantoHelper_(
std::move(quantoHelper)), mixingFactor_(mixingFactor) {}
87 ext::shared_ptr<FdmQuantoHelper> quantoHelper,
93 ext::shared_ptr<LocalVolTermStructure> leverageFct,
94 const Real mixingFactor)
98 dividends_(
std::move(dividends)),
99 tGrid_(tGrid), xGrid_(xGrid), vGrid_(vGrid), dampingSteps_(dampingSteps),
100 schemeDesc_(schemeDesc), leverageFct_(
std::move(leverageFct)),
101 quantoHelper_(
std::move(quantoHelper)), mixingFactor_(mixingFactor) {}
106 const ext::shared_ptr<HestonProcess> process =
model_->process();
107 const Time maturity = process->time(
arguments_.exercise->lastDate());
110 const Size tGridMin = 5;
111 const Size tGridAvgSteps = std::max(tGridMin,
tGrid_/50);
112 const ext::shared_ptr<FdmHestonLocalVolatilityVarianceMesher> vMesher
113 = ext::make_shared<FdmHestonLocalVolatilityVarianceMesher>(
116 const Volatility avgVolaEstimate = vMesher->volaEstimate();
119 const ext::shared_ptr<StrikedTypePayoff>
payoff =
120 ext::dynamic_pointer_cast<StrikedTypePayoff>(
arguments_.payoff);
122 ext::shared_ptr<Fdm1dMesher> equityMesher;
124 equityMesher = ext::shared_ptr<Fdm1dMesher>(
128 process->s0(), process->dividendYield(),
129 process->riskFreeRate(), avgVolaEstimate),
130 maturity,
payoff->strike(),
132 std::pair<Real, Real>(
payoff->strike(), 0.1),
138 "multiple strikes engine does not work with discrete dividends");
139 equityMesher = ext::shared_ptr<Fdm1dMesher>(
143 process->s0(), process->dividendYield(),
144 process->riskFreeRate(), avgVolaEstimate),
146 std::pair<Real, Real>(
payoff->strike(), 0.075)));
149 const ext::shared_ptr<FdmMesher> mesher(
153 const ext::shared_ptr<FdmInnerValueCalculator> calculator(
157 const ext::shared_ptr<FdmStepConditionComposite> conditions =
161 process->riskFreeRate()->referenceDate(),
162 process->riskFreeRate()->dayCounter());
169 calculator, maturity,
179 if (cachedArgs2result.first.exercise->type() ==
arguments_.exercise->type() &&
180 cachedArgs2result.first.exercise->dates() ==
arguments_.exercise->dates()) {
181 ext::shared_ptr<PlainVanillaPayoff> p1 =
182 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
184 ext::shared_ptr<PlainVanillaPayoff> p2 =
185 ext::dynamic_pointer_cast<PlainVanillaPayoff>(cachedArgs2result.first.payoff);
187 if ((p1 !=
nullptr) && p1->strike() == p2->strike() &&
188 p1->optionType() == p2->optionType()) {
190 "multiple strikes engine does not work with discrete dividends");
191 results_ = cachedArgs2result.second;
197 const ext::shared_ptr<HestonProcess> process =
model_->process();
205 const Real v0 = process->v0();
206 const Real spot = process->s0()->value();
214 const ext::shared_ptr<StrikedTypePayoff>
payoff =
215 ext::dynamic_pointer_cast<StrikedTypePayoff>(
arguments_.payoff);
219 ext::make_shared<PlainVanillaPayoff>(
239 const std::vector<Real>& strikes) {
246 : hestonModel_(
std::move(hestonModel)),
250 const ext::shared_ptr<FdmQuantoHelper>& quantoHelper) {
282 schemeDesc_ = ext::make_shared<FdmSchemeDesc>(schemeDesc);
288 ext::shared_ptr<LocalVolTermStructure>& leverageFct) {
295 const std::vector<Date>& dividendDates,
296 const std::vector<Real>& dividendAmounts) {
301 MakeFdHestonVanillaEngine::operator
302 ext::shared_ptr<PricingEngine>()
const {
303 return ext::make_shared<FdHestonVanillaEngine>(
307 tGrid_, xGrid_, vGrid_, dampingSteps_,
Bates stochastic process, Heston process plus compound Poisson process plus log-normal jump diffusion...
FdmSolverDesc getSolverDesc(Real equityScaleFactor) const
std::vector< Real > strikes_
std::vector< std::pair< VanillaOption::arguments, VanillaOption::results > > cachedArgs2results_
const ext::shared_ptr< FdmQuantoHelper > quantoHelper_
void calculate() const override
const ext::shared_ptr< LocalVolTermStructure > leverageFct_
FdHestonVanillaEngine(const ext::shared_ptr< HestonModel > &model, Size tGrid=100, Size xGrid=100, Size vGrid=50, Size dampingSteps=0, const FdmSchemeDesc &schemeDesc=FdmSchemeDesc::Hundsdorfer(), ext::shared_ptr< LocalVolTermStructure > leverageFct={}, Real mixingFactor=1.0)
DividendSchedule dividends_
void enableMultipleStrikesCaching(const std::vector< Real > &strikes)
const FdmSchemeDesc schemeDesc_
static ext::shared_ptr< GeneralizedBlackScholesProcess > processHelper(const Handle< Quote > &s0, const Handle< YieldTermStructure > &rTS, const Handle< YieldTermStructure > &qTS, Volatility vol)
static ext::shared_ptr< FdmStepConditionComposite > vanillaComposite(const DividendSchedule &schedule, const ext::shared_ptr< Exercise > &exercise, const ext::shared_ptr< FdmMesher > &mesher, const ext::shared_ptr< FdmInnerValueCalculator > &calculator, const Date &refDate, const DayCounter &dayCounter)
Base class for some pricing engine on a particular model.
Handle< HestonModel > model_
Shared handle to an observable.
Heston model for the stochastic volatility of an asset.
MakeFdHestonVanillaEngine & withDampingSteps(Size dampingSteps)
MakeFdHestonVanillaEngine & withQuantoHelper(const ext::shared_ptr< FdmQuantoHelper > &quantoHelper)
MakeFdHestonVanillaEngine & withTGrid(Size tGrid)
MakeFdHestonVanillaEngine(ext::shared_ptr< HestonModel > hestonModel)
MakeFdHestonVanillaEngine & withCashDividends(const std::vector< Date > ÷ndDates, const std::vector< Real > ÷ndAmounts)
DividendSchedule dividends_
ext::shared_ptr< FdmQuantoHelper > quantoHelper_
MakeFdHestonVanillaEngine & withVGrid(Size vGrid)
ext::shared_ptr< FdmSchemeDesc > schemeDesc_
MakeFdHestonVanillaEngine & withFdmSchemeDesc(const FdmSchemeDesc &schemeDesc)
MakeFdHestonVanillaEngine & withLeverageFunction(ext::shared_ptr< LocalVolTermStructure > &leverageFct)
MakeFdHestonVanillaEngine & withXGrid(Size xGrid)
ext::shared_ptr< LocalVolTermStructure > leverageFct_
template class providing a null value for a given type.
Vanilla option (no discrete dividends, no barriers) on a single asset.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Finite-differences Heston vanilla option engine.
1-d mesher for the Black-Scholes process (in ln(S))
1-d mesher for the Black-Scholes process (in ln(S))
One-dimensional grid mesher for the variance part of the Heston model.
layer of abstraction to calculate the inner value
memory layout of a fdm linear operator
FdmMesher which is a composite of Fdm1dMesher.
composite of fdm step conditions
Real Time
continuous quantity with 1-year units
Real Volatility
volatility
std::size_t Size
size of a container
ext::shared_ptr< QuantLib::Payoff > payoff
std::vector< ext::shared_ptr< Dividend > > DividendSchedule
std::vector< ext::shared_ptr< Dividend > > DividendVector(const std::vector< Date > ÷ndDates, const std::vector< Real > ÷nds)
helper function building a sequence of fixed dividends
OperatorTraits< FdmLinearOp >::bc_set FdmBoundaryConditionSet