QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
fdbatesvanillaengine.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2010 Klaus Spanderen
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#include <ql/processes/batesprocess.hpp>
25#include <ql/methods/finitedifferences/solvers/fdmbatessolver.hpp>
26#include <ql/pricingengines/vanilla/fdbatesvanillaengine.hpp>
27#include <ql/pricingengines/vanilla/fdhestonvanillaengine.hpp>
28
29namespace QuantLib {
30
31 QL_DEPRECATED_DISABLE_WARNING
32
34 const ext::shared_ptr<BatesModel>& model,
35 Size tGrid, Size xGrid,
36 Size vGrid, Size dampingSteps,
37 const FdmSchemeDesc& schemeDesc)
41 explicitDividends_(false),
42 tGrid_(tGrid), xGrid_(xGrid),
43 vGrid_(vGrid), dampingSteps_(dampingSteps),
44 schemeDesc_(schemeDesc) {}
45
47 const ext::shared_ptr<BatesModel>& model,
48 DividendSchedule dividends,
49 Size tGrid, Size xGrid,
50 Size vGrid, Size dampingSteps,
51 const FdmSchemeDesc& schemeDesc)
55 dividends_(std::move(dividends)), explicitDividends_(true),
56 tGrid_(tGrid), xGrid_(xGrid),
57 vGrid_(vGrid), dampingSteps_(dampingSteps),
58 schemeDesc_(schemeDesc) {}
59
60 QL_DEPRECATED_ENABLE_WARNING
61
63
64 // dividends will eventually be moved out of arguments, but for now we need the switch
65 QL_DEPRECATED_DISABLE_WARNING
66 const DividendSchedule& passedDividends = explicitDividends_ ? dividends_ : arguments_.cashFlow;
67 QL_DEPRECATED_ENABLE_WARNING
68
70 passedDividends,
73
74 QL_DEPRECATED_DISABLE_WARNING
76 helperEngine.getArguments()) = arguments_;
77 QL_DEPRECATED_ENABLE_WARNING
78
79 FdmSolverDesc solverDesc = helperEngine.getSolverDesc(2.0);
80
81 const ext::shared_ptr<BatesProcess> process =
82 ext::dynamic_pointer_cast<BatesProcess>(model_->process());
83
84 ext::shared_ptr<FdmBatesSolver> solver(
86 solverDesc, schemeDesc_));
87
88 const Real v0 = process->v0();
89 const Real spot = process->s0()->value();
90
91 results_.value = solver->valueAt(spot, v0);
92 results_.delta = solver->deltaAt(spot, v0);
93 results_.gamma = solver->gammaAt(spot, v0);
94 results_.theta = solver->thetaAt(spot, v0);
95 }
96}
Bates stochastic-volatility model.
Definition: batesmodel.hpp:43
Single-asset vanilla option (no barriers) with discrete dividends.
FdBatesVanillaEngine(const ext::shared_ptr< BatesModel > &model, Size tGrid=100, Size xGrid=100, Size vGrid=50, Size dampingSteps=0, const FdmSchemeDesc &schemeDesc=FdmSchemeDesc::Hundsdorfer())
Finite-differences Heston vanilla option engine.
Base class for some pricing engine on a particular model.
Shared handle to an observable.
Definition: handle.hpp:41
const ext::shared_ptr< T > & currentLink() const
dereferencing
Definition: handle.hpp:148
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
STL namespace.