QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
fdvanillaengine.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) 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
23/*! \file fdvanillaengine.hpp
24 \brief Finite-differences vanilla-option engine
25*/
26
27#ifndef quantlib_fd_vanilla_engine_hpp
28#define quantlib_fd_vanilla_engine_hpp
29
33#include <ql/payoff.hpp>
34#include <ql/pricingengine.hpp>
36#include <utility>
37
38
39namespace QuantLib {
40
41 /*! \deprecated Use the new finite-differences framework instead.
42 Deprecated in version 1.32.
43 */
44 class [[deprecated("Use the new finite-differences framework instead")]] FDVanillaEngine {
45 public:
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(); }
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_;
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
Black-Scholes processes.
boundary conditions for differential operators
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.
Option payoff classes.
Base class for pricing engines.
#define QL_DEPRECATED_DISABLE_WARNING
Definition: qldefines.hpp:216
#define QL_DEPRECATED_ENABLE_WARNING
Definition: qldefines.hpp:217
a class that contains a sampled curve
tridiagonal operator