QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
fdmbatessolver.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2010, 2011 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
23#include <ql/methods/finitedifferences/operators/fdmbatesop.hpp>
24#include <ql/methods/finitedifferences/solvers/fdm2dimsolver.hpp>
25#include <ql/methods/finitedifferences/solvers/fdmbatessolver.hpp>
26#include <ql/processes/batesprocess.hpp>
27#include <utility>
28
29
30namespace QuantLib {
31
33 FdmSolverDesc solverDesc,
34 const FdmSchemeDesc& schemeDesc,
35 Size integroIntegrationOrder,
36 Handle<FdmQuantoHelper> quantoHelper)
37 : process_(std::move(process)), solverDesc_(std::move(solverDesc)), schemeDesc_(schemeDesc),
38 integroIntegrationOrder_(integroIntegrationOrder), quantoHelper_(std::move(quantoHelper)) {
41 }
42
44 ext::shared_ptr<FdmLinearOpComposite> op(
45 new FdmBatesOp(solverDesc_.mesher, process_.currentLink(),
47 (!quantoHelper_.empty())
48 ? quantoHelper_.currentLink()
49 : ext::shared_ptr<FdmQuantoHelper>()));
50
51 solver_ = ext::make_shared<Fdm2DimSolver>(
53 }
54
56 calculate();
57 return solver_->interpolateAt(std::log(s), v);
58 }
59
61 calculate();
62 return solver_->derivativeX(std::log(s), v)/s;
63 }
64
66 calculate();
67 const Real x = std::log(s);
68 return (solver_->derivativeXX(x, v)-solver_->derivativeX(x, v))/(s*s);
69 }
70
72 calculate();
73 return solver_->thetaAt(std::log(s), v);
74 }
75
76}
ext::shared_ptr< Fdm2DimSolver > solver_
void performCalculations() const override
FdmBatesSolver(Handle< BatesProcess > process, FdmSolverDesc solverDesc, const FdmSchemeDesc &schemeDesc=FdmSchemeDesc::Hundsdorfer(), Size integroIntegrationOrder=12, Handle< FdmQuantoHelper > quantoHelper=Handle< FdmQuantoHelper >())
Real thetaAt(Real s, Real v) const
const FdmSolverDesc solverDesc_
const Handle< BatesProcess > process_
Real gammaAt(Real s, Real v) const
Real valueAt(Real s, Real v) const
Real deltaAt(Real s, Real v) const
const Handle< FdmQuantoHelper > quantoHelper_
const FdmSchemeDesc schemeDesc_
Shared handle to an observable.
Definition: handle.hpp:41
virtual void calculate() const
Definition: lazyobject.hpp:253
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
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
STL namespace.
const FdmBoundaryConditionSet bcSet
const ext::shared_ptr< FdmMesher > mesher