QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
qdfpamericanengine.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) 2022 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 qdfpamericanengine.hpp
21*/
22
23#ifndef quantlib_qd_fp_american_engine_hpp
24#define quantlib_qd_fp_american_engine_hpp
25
27
28namespace QuantLib {
29
30 class Integrator;
31
32 //! Iteration scheme for fixed-point QD American engine
34 public:
38
39 virtual ext::shared_ptr<Integrator> getFixedPointIntegrator() const = 0;
40 virtual ext::shared_ptr<Integrator> getExerciseBoundaryToPriceIntegrator() const = 0;
41
42 virtual ~QdFpIterationScheme() = default;
43 };
44
45 //! Gauss-Legendre (l,m,n)-p Scheme
46 /*! \param l order of Gauss-Legendre integration within every fixed point iteration step
47 \param m fixed point iteration steps, first step is a partial Jacobi-Newton,
48 the rest are naive Richardson fixed point iterations
49 \param n number of Chebyshev nodes to interpolate the exercise boundary
50 \param p order of Gauss-Legendre integration in final conversion of the
51 exercise boundary into option prices
52 */
54 public:
56
60
61 ext::shared_ptr<Integrator> getFixedPointIntegrator() const override;
62 ext::shared_ptr<Integrator> getExerciseBoundaryToPriceIntegrator() const override;
63
64 private:
65 const Size m_, n_;
66 const ext::shared_ptr<Integrator> fpIntegrator_;
67 const ext::shared_ptr<Integrator> exerciseBoundaryIntegrator_;
68 };
69
70 //! Legendre-Tanh-Sinh (l,m,n)-eps Scheme
71 /*! \param l order of Gauss-Legendre integration within every fixed point iteration step
72 \param m fixed point iteration steps, first step is a partial Jacobi-Newton,
73 the rest are naive Richardson fixed point iterations
74 \param n number of Chebyshev nodes to interpolate the exercise boundary
75 \param eps final conversion of the exercise boundary into option prices
76 is carried out by a tanh-sinh integration with accuracy eps
77 */
79 public:
81
82 ext::shared_ptr<Integrator> getExerciseBoundaryToPriceIntegrator() const override;
83
84 private:
85 const Real eps_;
86 };
87
88 //! tanh-sinh (m,n)-eps Scheme
89 /*! \param m fixed point iteration steps, first step is a partial Jacobi-Newton,
90 the rest are naive Richardson fixed point iterations
91 \param n number of Chebyshev nodes to interpolate the exercise boundary
92 \param eps tanh-sinh integration precision
93 */
95 public:
97
101
102 ext::shared_ptr<Integrator> getFixedPointIntegrator() const override;
103 ext::shared_ptr<Integrator> getExerciseBoundaryToPriceIntegrator() const override;
104 private:
105 const Size m_, n_;
106 const ext::shared_ptr<Integrator> integrator_;
107 };
108
109
110 //! High performance/precision American engine based on fixed point iteration for the exercise boundary
111 /*! References:
112 Leif Andersen, Mark Lake and Dimitri Offengenden (2015)
113 "High Performance American Option Pricing",
114 https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2547027
115
116 Leif Andersen, Mark Lake (2021)
117 "Fast American Option Pricing: The Double-Boundary Case"
118
119 https://onlinelibrary.wiley.com/doi/abs/10.1002/wilm.10969
120 */
122 public:
124
125 explicit QdFpAmericanEngine(
126 ext::shared_ptr<GeneralizedBlackScholesProcess> bsProcess,
127 ext::shared_ptr<QdFpIterationScheme> iterationScheme = accurateScheme(),
128 FixedPointEquation fpEquation = Auto);
129
130 static ext::shared_ptr<QdFpIterationScheme> fastScheme();
131 static ext::shared_ptr<QdFpIterationScheme> accurateScheme();
132 static ext::shared_ptr<QdFpIterationScheme> highPrecisionScheme();
133
134 protected:
136 Real S, Real K, Rate r, Rate q, Volatility vol, Time T) const override;
137
138 private:
139 const ext::shared_ptr<QdFpIterationScheme> iterationScheme_;
141 };
142
143}
144
145#endif
High performance/precision American engine based on fixed point iteration for the exercise boundary.
static ext::shared_ptr< QdFpIterationScheme > highPrecisionScheme()
static ext::shared_ptr< QdFpIterationScheme > fastScheme()
const FixedPointEquation fpEquation_
const ext::shared_ptr< QdFpIterationScheme > iterationScheme_
static ext::shared_ptr< QdFpIterationScheme > accurateScheme()
Real calculatePut(Real S, Real K, Rate r, Rate q, Volatility vol, Time T) const override
Iteration scheme for fixed-point QD American engine.
virtual ~QdFpIterationScheme()=default
virtual ext::shared_ptr< Integrator > getFixedPointIntegrator() const =0
virtual Size getNumberOfNaiveFixedPointSteps() const =0
virtual Size getNumberOfJacobiNewtonFixedPointSteps() const =0
virtual Size getNumberOfChebyshevInterpolationNodes() const =0
virtual ext::shared_ptr< Integrator > getExerciseBoundaryToPriceIntegrator() const =0
Gauss-Legendre (l,m,n)-p Scheme.
Size getNumberOfChebyshevInterpolationNodes() const override
ext::shared_ptr< Integrator > getFixedPointIntegrator() const override
Size getNumberOfNaiveFixedPointSteps() const override
const ext::shared_ptr< Integrator > exerciseBoundaryIntegrator_
ext::shared_ptr< Integrator > getExerciseBoundaryToPriceIntegrator() const override
Size getNumberOfJacobiNewtonFixedPointSteps() const override
const ext::shared_ptr< Integrator > fpIntegrator_
Legendre-Tanh-Sinh (l,m,n)-eps Scheme.
ext::shared_ptr< Integrator > getExerciseBoundaryToPriceIntegrator() const override
Size getNumberOfChebyshevInterpolationNodes() const override
ext::shared_ptr< Integrator > getFixedPointIntegrator() const override
Size getNumberOfNaiveFixedPointSteps() const override
ext::shared_ptr< Integrator > getExerciseBoundaryToPriceIntegrator() const override
Size getNumberOfJacobiNewtonFixedPointSteps() const override
const ext::shared_ptr< Integrator > integrator_
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Real Volatility
volatility
Definition: types.hpp:78
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
ext::shared_ptr< YieldTermStructure > q
ext::shared_ptr< YieldTermStructure > r