QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
qdplusamericanengine.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 qdplusamericanengine.hpp
21*/
22
23#ifndef quantlib_qd_plus_american_engine_hpp
24#define quantlib_qd_plus_american_engine_hpp
25
26#include <ql/utilities/null.hpp>
30
31
32namespace QuantLib {
33
34 class Interpolation;
35 class ChebyshevInterpolation;
36 class QdPlusBoundaryEvaluator;
37
38 namespace detail {
39
41 public:
42 explicit QdPutCallParityEngine(
43 ext::shared_ptr<GeneralizedBlackScholesProcess> process);
44
45 void calculate() const override;
46
47 protected:
49 Real S, Real K, Rate r, Rate q, Volatility vol, Time T) const = 0;
50
51 const ext::shared_ptr<GeneralizedBlackScholesProcess> process_;
52
53 private:
55 Real S, Real K, Rate r, Rate q, Volatility vol, Time T) const;
56 };
57
59 public:
61 Real S,
62 Real K,
63 Rate r,
64 Rate q,
65 Volatility vol,
66 Real xmax,
67 ext::shared_ptr<Interpolation> q_z);
68
69 Real operator()(Real z) const;
70 private:
71 const Time T_;
72 const Real S_, K_, xmax_;
73 const Rate r_, q_;
75 const ext::shared_ptr<Interpolation> q_z_;
77 };
78 }
79
80
81 //! American engine based on the QD+ approximation to the exercise boundary.
82 /*! The main purpose of this engine is to provide a good initial guess to the exercise
83 boundary for the superior fixed point American engine QdFpAmericanEngine
84
85 References:
86 Li, M. (2009), “Analytical Approximations for the Critical Stock Prices
87 of American Options: A Performance Comparison,”
88 Working paper, Georgia Institute of Technology.
89
90 https://mpra.ub.uni-muenchen.de/15018/1/MPRA_paper_15018.pdf
91 */
93 public:
95
96 explicit QdPlusAmericanEngine(
97 ext::shared_ptr<GeneralizedBlackScholesProcess>,
98 Size interpolationPoints = 8,
99 SolverType solverType = Halley,
100 Real eps = 1e-6,
101 Size maxIter = Null<Size>());
102
103 std::pair<Size, Real> putExerciseBoundaryAtTau(
104 Real S, Real K, Rate r, Rate q,
105 Volatility vol, Time T, Time tau) const;
106
107 ext::shared_ptr<ChebyshevInterpolation> getPutExerciseBoundary(
108 Real S, Real K, Rate r, Rate q, Volatility vol, Time T) const;
109
110 static Real xMax(Real K, Rate r, Rate q);
111
112 protected:
114 Real S, Real K, Rate r, Rate q, Volatility vol, Time T) const override;
115
116 private:
117 template <class Solver>
119 const QdPlusBoundaryEvaluator& eval,
120 Solver solver, Real S, Real strike, Size maxIter,
121 Real guess = Null<Real>()) const;
122
125 const Real eps_;
127 };
128}
129
130#endif
Black-Scholes processes.
Cumulative normal distribution function.
template class providing a null value for a given type.
Definition: null.hpp:76
American engine based on the QD+ approximation to the exercise boundary.
ext::shared_ptr< ChebyshevInterpolation > getPutExerciseBoundary(Real S, Real K, Rate r, Rate q, Volatility vol, Time T) const
static Real xMax(Real K, Rate r, Rate q)
std::pair< Size, Real > putExerciseBoundaryAtTau(Real S, Real K, Rate r, Rate q, Volatility vol, Time T, Time tau) const
Real calculatePut(Real S, Real K, Rate r, Rate q, Volatility vol, Time T) const override
Real buildInSolver(const QdPlusBoundaryEvaluator &eval, Solver solver, Real S, Real strike, Size maxIter, Real guess=Null< Real >()) const
const ext::shared_ptr< Interpolation > q_z_
const CumulativeNormalDistribution Phi_
virtual Real calculatePut(Real S, Real K, Rate r, Rate q, Volatility vol, Time T) const =0
const ext::shared_ptr< GeneralizedBlackScholesProcess > process_
Real calculatePutWithEdgeCases(Real S, Real K, Rate r, Rate q, Volatility vol, Time T) const
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
normal, cumulative and inverse cumulative distributions
null values
ext::shared_ptr< YieldTermStructure > q
ext::shared_ptr< YieldTermStructure > r
Vanilla option on a single asset.