QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
fdbatesvanillaengine.cpp
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) 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
20/*! \file fdbatesvanillaengine.cpp
21 \brief Partial Integro Finite-Differences Bates vanilla option engine
22*/
23
28
29namespace QuantLib {
30
32 const ext::shared_ptr<BatesModel>& model,
33 Size tGrid, Size xGrid,
34 Size vGrid, Size dampingSteps,
35 const FdmSchemeDesc& schemeDesc)
38 VanillaOption::results>(model),
39 tGrid_(tGrid), xGrid_(xGrid),
40 vGrid_(vGrid), dampingSteps_(dampingSteps),
41 schemeDesc_(schemeDesc) {}
42
44 const ext::shared_ptr<BatesModel>& model,
45 DividendSchedule dividends,
46 Size tGrid, Size xGrid,
47 Size vGrid, Size dampingSteps,
48 const FdmSchemeDesc& schemeDesc)
51 VanillaOption::results>(model),
52 dividends_(std::move(dividends)),
53 tGrid_(tGrid), xGrid_(xGrid),
54 vGrid_(vGrid), dampingSteps_(dampingSteps),
55 schemeDesc_(schemeDesc) {}
56
58
63
64 *dynamic_cast<VanillaOption::arguments*>(
65 helperEngine.getArguments()) = arguments_;
66
67 FdmSolverDesc solverDesc = helperEngine.getSolverDesc(2.0);
68
69 const ext::shared_ptr<BatesProcess> process =
70 ext::dynamic_pointer_cast<BatesProcess>(model_->process());
71
72 ext::shared_ptr<FdmBatesSolver> solver(
74 solverDesc, schemeDesc_));
75
76 const Real v0 = process->v0();
77 const Real spot = process->s0()->value();
78
79 results_.value = solver->valueAt(spot, v0);
80 results_.delta = solver->deltaAt(spot, v0);
81 results_.gamma = solver->gammaAt(spot, v0);
82 results_.theta = solver->thetaAt(spot, v0);
83 }
84}
Bates stochastic process, Heston process plus compound Poisson process plus log-normal jump diffusion...
Bates stochastic-volatility model.
Definition: batesmodel.hpp:43
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.
FdmSolverDesc getSolverDesc(Real equityScaleFactor) const
PricingEngine::arguments * getArguments() const override
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:173
basic option arguments
Definition: option.hpp:57
Vanilla option (no discrete dividends, no barriers) on a single asset.
Partial integro finite-differences Bates vanilla option engine.
Finite-differences Heston vanilla option engine.
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Real v0
Definition: any.hpp:35
std::vector< ext::shared_ptr< Dividend > > DividendSchedule
STL namespace.