QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
fdcirvanillaengine.hpp
Go to the documentation of this file.
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
20/*! \file fdcirvanillaengine.hpp
21 \brief Finite-differences CIR vanilla option engine
22*/
23
24#ifndef quantlib_fd_cir_vanilla_engine_hpp
25#define quantlib_fd_cir_vanilla_engine_hpp
26
34
35namespace QuantLib {
36
37 class FdmQuantoHelper;
38
39 //! Finite-differences CIR vanilla option engine
40 /*! \ingroup vanillaengines
41
42 \test the engine has been tested to converge among different schemes.
43 */
45 public:
46 FdCIRVanillaEngine(ext::shared_ptr<CoxIngersollRossProcess> cirProcess,
47 ext::shared_ptr<GeneralizedBlackScholesProcess> bsProcess,
48 Size tGrid,
49 Size xGrid,
50 Size vGrid,
51 Size dampingSteps,
52 Real rho,
54 ext::shared_ptr<FdmQuantoHelper> quantoHelper = {});
55
56 FdCIRVanillaEngine(ext::shared_ptr<CoxIngersollRossProcess> cirProcess,
57 ext::shared_ptr<GeneralizedBlackScholesProcess> bsProcess,
58 DividendSchedule dividends,
59 Size tGrid,
60 Size xGrid,
61 Size vGrid,
62 Size dampingSteps,
63 Real rho,
65 ext::shared_ptr<FdmQuantoHelper> quantoHelper = {});
66
67 void calculate() const override;
68
69 FdmSolverDesc getSolverDesc(Real equityScaleFactor) const;
70
71 private:
72 ext::shared_ptr<GeneralizedBlackScholesProcess> bsProcess_;
73 ext::shared_ptr<CoxIngersollRossProcess> cirProcess_;
74 ext::shared_ptr<FdmQuantoHelper> quantoHelper_;
77 const Real rho_;
79 };
80
82 public:
83 explicit MakeFdCIRVanillaEngine(ext::shared_ptr<CoxIngersollRossProcess> cirProcess,
84 ext::shared_ptr<GeneralizedBlackScholesProcess> bsProcess,
85 Real rho);
86
88 const ext::shared_ptr<FdmQuantoHelper>& quantoHelper);
89
94 Size dampingSteps);
95
97 const FdmSchemeDesc& schemeDesc);
98
100 const std::vector<Date>& dividendDates,
101 const std::vector<Real>& dividendAmounts);
102
103 operator ext::shared_ptr<PricingEngine>() const;
104
105 private:
106 ext::shared_ptr<CoxIngersollRossProcess> cirProcess_;
107 ext::shared_ptr<GeneralizedBlackScholesProcess> bsProcess_;
109 const Real rho_;
110 Size tGrid_ = 10, xGrid_ = 100, rGrid_ = 100, dampingSteps_ = 0;
111 ext::shared_ptr<FdmSchemeDesc> schemeDesc_;
112 ext::shared_ptr<FdmQuantoHelper> quantoHelper_;
113 };
114}
115
116#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_
CoxIngersollRoss process.
Generic option engine based on a model.
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Heston model for the stochastic volatility of an asset.
Real rho
Local volatility term structure base class.
Definition: any.hpp:35
std::vector< ext::shared_ptr< Dividend > > DividendSchedule
static FdmSchemeDesc ModifiedHundsdorfer()
Vanilla option on a single asset.