QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
fdhestonvanillaengine.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 Andreas Gaida
5 Copyright (C) 2008 Ralph Schreyer
6 Copyright (C) 2008, 2009, 2014 Klaus Spanderen
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
26#ifndef quantlib_fd_heston_vanilla_engine_hpp
27#define quantlib_fd_heston_vanilla_engine_hpp
28
29#include <ql/instruments/dividendvanillaoption.hpp>
30#include <ql/models/equity/hestonmodel.hpp>
31#include <ql/pricingengines/genericmodelengine.hpp>
32#include <ql/methods/finitedifferences/solvers/fdmsolverdesc.hpp>
33#include <ql/methods/finitedifferences/solvers/fdmbackwardsolver.hpp>
34#include <ql/termstructures/volatility/equityfx/localvoltermstructure.hpp>
35
36namespace QuantLib {
37
38 class FdmQuantoHelper;
39
40 QL_DEPRECATED_DISABLE_WARNING
41
43
50 : public GenericModelEngine<HestonModel,
51 DividendVanillaOption::arguments,
52 DividendVanillaOption::results> {
53 QL_DEPRECATED_ENABLE_WARNING
54 public:
55 explicit
56 FdHestonVanillaEngine(const ext::shared_ptr<HestonModel>& model,
57 Size tGrid = 100,
58 Size xGrid = 100,
59 Size vGrid = 50,
60 Size dampingSteps = 0,
61 const FdmSchemeDesc& schemeDesc = FdmSchemeDesc::Hundsdorfer(),
62 ext::shared_ptr<LocalVolTermStructure> leverageFct = {},
63 Real mixingFactor = 1.0);
64
65 FdHestonVanillaEngine(const ext::shared_ptr<HestonModel>& model,
66 DividendSchedule dividends,
67 Size tGrid = 100,
68 Size xGrid = 100,
69 Size vGrid = 50,
70 Size dampingSteps = 0,
71 const FdmSchemeDesc& schemeDesc = FdmSchemeDesc::Hundsdorfer(),
72 ext::shared_ptr<LocalVolTermStructure> leverageFct = {},
73 Real mixingFactor = 1.0);
74
75 FdHestonVanillaEngine(const ext::shared_ptr<HestonModel>& model,
76 ext::shared_ptr<FdmQuantoHelper> quantoHelper,
77 Size tGrid = 100,
78 Size xGrid = 100,
79 Size vGrid = 50,
80 Size dampingSteps = 0,
81 const FdmSchemeDesc& schemeDesc = FdmSchemeDesc::Hundsdorfer(),
82 ext::shared_ptr<LocalVolTermStructure> leverageFct = {},
83 Real mixingFactor = 1.0);
84
85 FdHestonVanillaEngine(const ext::shared_ptr<HestonModel>& model,
86 DividendSchedule dividends,
87 ext::shared_ptr<FdmQuantoHelper> quantoHelper,
88 Size tGrid = 100,
89 Size xGrid = 100,
90 Size vGrid = 50,
91 Size dampingSteps = 0,
92 const FdmSchemeDesc& schemeDesc = FdmSchemeDesc::Hundsdorfer(),
93 ext::shared_ptr<LocalVolTermStructure> leverageFct = {},
94 Real mixingFactor = 1.0);
95
96 void calculate() const override;
97
98 // multiple strikes caching engine
99 void update() override;
100 void enableMultipleStrikesCaching(const std::vector<Real>& strikes);
101
102 // helper method for Heston like engines
103 FdmSolverDesc getSolverDesc(Real equityScaleFactor) const;
104
105 private:
110 const ext::shared_ptr<LocalVolTermStructure> leverageFct_;
111 const ext::shared_ptr<FdmQuantoHelper> quantoHelper_;
113
114 std::vector<Real> strikes_;
115 QL_DEPRECATED_DISABLE_WARNING
116 mutable std::vector<std::pair<DividendVanillaOption::arguments,
119 QL_DEPRECATED_ENABLE_WARNING
120 };
121
123 public:
124 explicit MakeFdHestonVanillaEngine(ext::shared_ptr<HestonModel> hestonModel);
125
127 const ext::shared_ptr<FdmQuantoHelper>& quantoHelper);
128
133 Size dampingSteps);
134
136 const FdmSchemeDesc& schemeDesc);
137
139 ext::shared_ptr<LocalVolTermStructure>& leverageFct);
140
142 const std::vector<Date>& dividendDates,
143 const std::vector<Real>& dividendAmounts);
144
145 operator ext::shared_ptr<PricingEngine>() const;
146
147 private:
148 ext::shared_ptr<HestonModel> hestonModel_;
150 bool explicitDividends_ = false;
151 Size tGrid_ = 100, xGrid_ = 100, vGrid_ = 50, dampingSteps_ = 0;
152 ext::shared_ptr<FdmSchemeDesc> schemeDesc_;
153 ext::shared_ptr<LocalVolTermStructure> leverageFct_;
154 ext::shared_ptr<FdmQuantoHelper> quantoHelper_;
155 };
156
157}
158
159#endif
Finite-differences Heston vanilla option engine.
FdmSolverDesc getSolverDesc(Real equityScaleFactor) const
const ext::shared_ptr< FdmQuantoHelper > quantoHelper_
const ext::shared_ptr< LocalVolTermStructure > leverageFct_
QL_DEPRECATED_DISABLE_WARNING std::vector< std::pair< DividendVanillaOption::arguments, DividendVanillaOption::results > > cachedArgs2results_
void enableMultipleStrikesCaching(const std::vector< Real > &strikes)
Base class for some pricing engine on a particular model.
ext::shared_ptr< HestonModel > hestonModel_
MakeFdHestonVanillaEngine & withDampingSteps(Size dampingSteps)
MakeFdHestonVanillaEngine & withQuantoHelper(const ext::shared_ptr< FdmQuantoHelper > &quantoHelper)
MakeFdHestonVanillaEngine & withTGrid(Size tGrid)
MakeFdHestonVanillaEngine & withCashDividends(const std::vector< Date > &dividendDates, const std::vector< Real > &dividendAmounts)
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_
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
std::vector< ext::shared_ptr< Dividend > > DividendSchedule
static FdmSchemeDesc Hundsdorfer()