QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
fdvanillaengine.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2002, 2003, 2004 Ferdinando Ametrano
5 Copyright (C) 2002, 2003 RiskMap srl
6 Copyright (C) 2003, 2004, 2005, 2007 StatPro Italia srl
7 Copyright (C) 2005 Joseph Wang
8
9 This file is part of QuantLib, a free-software/open-source library
10 for financial quantitative analysts and developers - http://quantlib.org/
11
12 QuantLib is free software: you can redistribute it and/or modify it
13 under the terms of the QuantLib license. You should have received a
14 copy of the license along with this program; if not, please email
15 <quantlib-dev@lists.sf.net>. The license is also available online at
16 <http://quantlib.org/license.shtml>.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the license for more details.
21*/
22
27#ifndef quantlib_fd_vanilla_engine_hpp
28#define quantlib_fd_vanilla_engine_hpp
29
30#include <ql/math/sampledcurve.hpp>
31#include <ql/methods/finitedifferences/boundarycondition.hpp>
32#include <ql/methods/finitedifferences/tridiagonaloperator.hpp>
33#include <ql/payoff.hpp>
34#include <ql/pricingengine.hpp>
35#include <ql/processes/blackscholesprocess.hpp>
36#include <utility>
37
38
39namespace QuantLib {
40
44 class [[deprecated("Use the new finite-differences framework instead")]] FDVanillaEngine {
45 public:
46 QL_DEPRECATED_DISABLE_WARNING
47 FDVanillaEngine(ext::shared_ptr<GeneralizedBlackScholesProcess> process,
48 Size timeSteps,
49 Size gridPoints,
50 bool timeDependent = false)
51 : process_(std::move(process)), timeSteps_(timeSteps), gridPoints_(gridPoints),
52 timeDependent_(timeDependent), intrinsicValues_(gridPoints), BCs_(2) {}
53 virtual ~FDVanillaEngine() = default;
54 // accessors
55 const Array& grid() const { return intrinsicValues_.grid(); }
56 QL_DEPRECATED_ENABLE_WARNING
57 protected:
58 // methods
59 virtual void setupArguments(const PricingEngine::arguments*) const;
60 virtual void setGridLimits() const;
61 virtual void setGridLimits(Real, Time) const;
62 virtual void initializeInitialCondition() const;
63 virtual void initializeBoundaryConditions() const;
64 virtual void initializeOperator() const;
65 virtual Time getResidualTime() const;
66 // data
67 ext::shared_ptr<GeneralizedBlackScholesProcess> process_;
68 Size timeSteps_, gridPoints_;
71 mutable ext::shared_ptr<Payoff> payoff_;
73 QL_DEPRECATED_DISABLE_WARNING
75 QL_DEPRECATED_ENABLE_WARNING
77 mutable std::vector<ext::shared_ptr<bc_type> > BCs_;
78 // temporaries
79 mutable Real sMin_, center_, sMax_;
80
81 void ensureStrikeInGrid() const;
82 private:
83 Size safeGridPoints(Size gridPoints,
84 Time residualTime) const;
85 static const Real safetyZoneFactor_;
86 };
87
88}
89
90#endif
1-D array used in linear algebra.
Definition: array.hpp:52
Abstract boundary condition class for finite difference problems.
Concrete date class.
Definition: date.hpp:125
virtual ~FDVanillaEngine()=default
TridiagonalOperator finiteDifferenceOperator_
QL_DEPRECATED_DISABLE_WARNING FDVanillaEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process, Size timeSteps, Size gridPoints, bool timeDependent=false)
QL_DEPRECATED_DISABLE_WARNING SampledCurve intrinsicValues_
std::vector< ext::shared_ptr< bc_type > > BCs_
ext::shared_ptr< Payoff > payoff_
QL_DEPRECATED_ENABLE_WARNING typedef BoundaryCondition< TridiagonalOperator > bc_type
const Array & grid() const
static const Real safetyZoneFactor_
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
Base implementation for tridiagonal operator.
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
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.