QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
fdcirvanillaengine.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2020 Lew Wei Hao
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
24#ifndef quantlib_fd_cir_vanilla_engine_hpp
25#define quantlib_fd_cir_vanilla_engine_hpp
26
27#include <ql/instruments/dividendvanillaoption.hpp>
28#include <ql/methods/finitedifferences/solvers/fdmbackwardsolver.hpp>
29#include <ql/methods/finitedifferences/solvers/fdmsolverdesc.hpp>
30#include <ql/models/equity/hestonmodel.hpp>
31#include <ql/pricingengines/genericmodelengine.hpp>
32#include <ql/processes/coxingersollrossprocess.hpp>
33#include <ql/termstructures/volatility/equityfx/localvoltermstructure.hpp>
34
35namespace QuantLib {
36
37 class FdmQuantoHelper;
38
39 QL_DEPRECATED_DISABLE_WARNING
40
42
47 QL_DEPRECATED_ENABLE_WARNING
48 public:
49 FdCIRVanillaEngine(ext::shared_ptr<CoxIngersollRossProcess> cirProcess,
50 ext::shared_ptr<GeneralizedBlackScholesProcess> bsProcess,
51 Size tGrid,
52 Size xGrid,
53 Size vGrid,
54 Size dampingSteps,
55 Real rho,
57 ext::shared_ptr<FdmQuantoHelper> quantoHelper = {});
58
59 FdCIRVanillaEngine(ext::shared_ptr<CoxIngersollRossProcess> cirProcess,
60 ext::shared_ptr<GeneralizedBlackScholesProcess> bsProcess,
61 DividendSchedule dividends,
62 Size tGrid,
63 Size xGrid,
64 Size vGrid,
65 Size dampingSteps,
66 Real rho,
68 ext::shared_ptr<FdmQuantoHelper> quantoHelper = {});
69
70 void calculate() const override;
71
72 FdmSolverDesc getSolverDesc(Real equityScaleFactor) const;
73
74 private:
75 ext::shared_ptr<GeneralizedBlackScholesProcess> bsProcess_;
76 ext::shared_ptr<CoxIngersollRossProcess> cirProcess_;
77 ext::shared_ptr<FdmQuantoHelper> quantoHelper_;
81 const Real rho_;
83 };
84
86 public:
87 explicit MakeFdCIRVanillaEngine(ext::shared_ptr<CoxIngersollRossProcess> cirProcess,
88 ext::shared_ptr<GeneralizedBlackScholesProcess> bsProcess,
89 Real rho);
90
92 const ext::shared_ptr<FdmQuantoHelper>& quantoHelper);
93
98 Size dampingSteps);
99
101 const FdmSchemeDesc& schemeDesc);
102
104 const std::vector<Date>& dividendDates,
105 const std::vector<Real>& dividendAmounts);
106
107 operator ext::shared_ptr<PricingEngine>() const;
108
109 private:
110 ext::shared_ptr<CoxIngersollRossProcess> cirProcess_;
111 ext::shared_ptr<GeneralizedBlackScholesProcess> bsProcess_;
113 bool explicitDividends_ = false;
114 const Real rho_;
115 Size tGrid_ = 10, xGrid_ = 100, rGrid_ = 100, dampingSteps_ = 0;
116 ext::shared_ptr<FdmSchemeDesc> schemeDesc_;
117 ext::shared_ptr<FdmQuantoHelper> quantoHelper_;
118 };
119}
120
121#endif
Finite-differences CIR vanilla option engine.
FdmSolverDesc getSolverDesc(Real equityScaleFactor) const
ext::shared_ptr< GeneralizedBlackScholesProcess > bsProcess_
ext::shared_ptr< CoxIngersollRossProcess > cirProcess_
ext::shared_ptr< FdmQuantoHelper > quantoHelper_
MakeFdCIRVanillaEngine & withTGrid(Size tGrid)
MakeFdCIRVanillaEngine & withQuantoHelper(const ext::shared_ptr< FdmQuantoHelper > &quantoHelper)
MakeFdCIRVanillaEngine & withCashDividends(const std::vector< Date > &dividendDates, const std::vector< Real > &dividendAmounts)
MakeFdCIRVanillaEngine & withRGrid(Size rGrid)
MakeFdCIRVanillaEngine & withFdmSchemeDesc(const FdmSchemeDesc &schemeDesc)
ext::shared_ptr< GeneralizedBlackScholesProcess > bsProcess_
MakeFdCIRVanillaEngine & withXGrid(Size xGrid)
MakeFdCIRVanillaEngine & withDampingSteps(Size dampingSteps)
ext::shared_ptr< CoxIngersollRossProcess > cirProcess_
ext::shared_ptr< FdmQuantoHelper > quantoHelper_
ext::shared_ptr< FdmSchemeDesc > schemeDesc_
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 ModifiedHundsdorfer()