QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
analytichestonforwardeuropeanengine.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) 2020 Jack Gillett
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 analytichestonforwardeuropeanengine.hpp
21 \brief analytic heston engine for forward-starting european options
22*/
23
24#ifndef quantlib_analytic_heston_forward_european_engine_hpp
25#define quantlib_analytic_heston_forward_european_engine_hpp
26
33#include <ql/exercise.hpp>
35
36namespace QuantLib {
37
38 //! Analytic Heston engine incl. stochastic interest rates
39 /*! This class is pricing a european option under the following process
40
41 \f[
42 \begin{array}{rcl}
43 dS(t, S) &=& (r-d) S dt +\sqrt{v} S dW_1 \\
44 dv(t, S) &=& \kappa (\theta - v) dt + \sigma \sqrt{v} dW_2 \\
45 dW_1 dW_2 &=& \rho dt \\
46 \end{array}
47 \f]
48
49 References:
50
51 Implements the analytical solution for forward-starting
52 strike-reset options descriped in "On the Pricing of Forward
53 Starting Options under Stochastic Volatility", S. Kruse (2003)
54
55 \ingroup forwardengines
56
57 \test
58 - For tReset > 0, price from the analytic pricer is compared
59 to the MC priver for calls/puts at various moneynesses
60 - For tReset ~ 0, price from the analytic pricer is compared
61 to the Heston analytic vanilla pricer for various options
62 */
63
64 class AnalyticHestonForwardEuropeanEngine : public GenericEngine<ForwardOptionArguments<VanillaOption::arguments>,
65 VanillaOption::results> {
66 public:
67 explicit AnalyticHestonForwardEuropeanEngine(ext::shared_ptr<HestonProcess> process,
68 Size integrationOrder = 144);
69
70 void calculate() const override;
71
72 // The evolution probability function from t0 to tReset
73 Real propagator(Time resetTime,
74 Real varReset) const;
75
76 // Forward characteristic function for given (t, vt, St)
77 ext::shared_ptr<AnalyticHestonEngine> forwardChF(
78 Handle<Quote>& spotReset,
79 Real varReset) const;
80
81 private:
82 // Parameters for the internal chF generators
83 ext::shared_ptr<HestonProcess> process_;
85
86 // Initial process params
91
92 // Some intermediate calculation constant parameters
94
95 // The integrator for nu. This pricer needs to perform nested integrations, the outer
96 // integrator should be non-adaptive as this can cause very long runtimes. Gaussian
97 // Quadrature has been found to work well.
99
100 // Integrate over characteristic function to generate P1, P2 (fall back on this
101 // when reset time is very close, to avoid numerical issues with tReset=0s)
102 std::pair<Real, Real> calculateP1P2(Time t,
103 Handle<Quote>& St,
104 Real K,
105 Real ratio,
106 Real phiRightLimit = 100) const;
107
108 // Integrate P1, P2 over te propagator function to calculate forward-start price
109 std::pair<Real, Real> calculateP1P2Hat(Time tenor,
110 Time resetTime,
111 Real K,
112 Real ratio,
113 Real phiRightLimit = 100,
114 Real nuRightLimit = 2.0) const;
115
116 };
117}
118
119#endif
analytic Heston-model engine
Analytic Heston engine incl. stochastic interest rates.
std::pair< Real, Real > calculateP1P2(Time t, Handle< Quote > &St, Real K, Real ratio, Real phiRightLimit=100) const
ext::shared_ptr< AnalyticHestonEngine > forwardChF(Handle< Quote > &spotReset, Real varReset) const
std::pair< Real, Real > calculateP1P2Hat(Time tenor, Time resetTime, Real K, Real ratio, Real phiRightLimit=100, Real nuRightLimit=2.0) const
template base class for option pricing engines
Shared handle to an observable.
Definition: handle.hpp:41
const DefaultType & t
Option exercise classes and payoff function.
Forward version of a vanilla option.
Integral of a 1-dimensional function using the Gauss quadratures.
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
Heston model for the stochastic volatility of an asset.
Heston stochastic process.
modified Bessel functions of first and second kind
Definition: any.hpp:35
simple quote class