QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
analytic_cont_geom_av_price_heston.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 analytic_cont_geom_av_price_heston.hpp
21 \brief Analytic engine for continuous geometric average price Asian
22 in the Heston model
23*/
24
25#ifndef quantlib_analytic_continuous_geometric_average_price_asian_heston_engine_hpp
26#define quantlib_analytic_continuous_geometric_average_price_asian_heston_engine_hpp
27
32#include <ql/exercise.hpp>
33#include <complex>
34
35namespace QuantLib {
36
37 //! Pricing engine for European continuous geometric average price Asian
38 /*! This class implements a continuous geometric average price
39 Asian option with European exercise under the Heston stochastic
40 vol model where spot and variance follow the processes
41
42 \f[
43 \begin{array}{rcl}
44 dS(t, S) &=& (r-d) S dt +\sqrt{v} S dW_1 \\
45 dv(t, S) &=& \kappa (\theta - v) dt + \sigma \sqrt{v} dW_2 \\
46 dW_1 dW_2 &=& \rho dt \\
47 \end{array}
48 \f]
49
50 References:
51
52 Implements the analytical solution for continuous geometric Asian
53 options developed in "Pricing of geometric Asian options under
54 Heston's stochastic volatility model", B. Kim & I. S. Wee, Quantative
55 Finance 14:10, 1795-1809 (2014)
56
57 \ingroup asianengines
58
59 \test
60 - the correctness of the returned value is tested by reproducing
61 results in Table 1 and Table 4 of the paper
62
63 \todo handle seasoned options
64 */
67 public:
69 ext::shared_ptr<HestonProcess> process,
70 Size summationCutoff = 50,
71 Real xiRightLimit = 100.0);
72 void calculate() const override;
73
74 // Phi, defined in eq (25). Must be public so the integrand can access it (Could
75 // use friend functions I think, but perhaps overkill?)
76 std::complex<Real> Phi(const std::complex<Real>& s,
77 const std::complex<Real>& w,
78 Real T, Real t = 0.0, Size cutoff = 50) const;
79
80 private:
81 // Initial process params
86
87 ext::shared_ptr<HestonProcess> process_;
88
89 // Some intermediate calculation constant parameters
91 mutable Real a3_ = 0.0, a4_ = 0.0, a5_ = 0.0;
92
93 // A lookup table for the reuslts of f() to avoid repeated calls
94 mutable std::map<int, std::complex<Real> > fLookupTable_;
95
96 // Cutoff parameters for summation (19), (20) and for integral (29)
99
100 // Integrator for equation (29)
102
103 // Integrands
104 class Integrand;
105 class DcfIntegrand;
106
107 // Equations (13)
108 std::complex<Real> z1_f(const std::complex<Real>& s, const std::complex<Real>& w, Real T) const;
109 std::complex<Real> z2_f(const std::complex<Real>& s, const std::complex<Real>& w, Real T) const;
110 std::complex<Real> z3_f(const std::complex<Real>& s, const std::complex<Real>& w, Real T) const;
111 std::complex<Real> z4_f(const std::complex<Real>& s, const std::complex<Real>& w) const;
112
113 // Equations (19), (20)
114 std::pair<std::complex<Real>, std::complex<Real> > F_F_tilde(
115 const std::complex<Real>& z1,
116 const std::complex<Real>& z2,
117 const std::complex<Real>& z3,
118 const std::complex<Real>& z4,
119 Real tau,
120 Size cutoff = 50) const;
121
122 // Equation (21)
123 std::complex<Real> f(const std::complex<Real>& z1,
124 const std::complex<Real>& z2,
125 const std::complex<Real>& z3,
126 const std::complex<Real>& z4,
127 int n,
128 Real tau) const;
129 };
130}
131
132
133#endif
Asian option on a single asset.
Pricing engine for European continuous geometric average price Asian.
std::complex< Real > z3_f(const std::complex< Real > &s, const std::complex< Real > &w, Real T) const
std::complex< Real > z4_f(const std::complex< Real > &s, const std::complex< Real > &w) const
std::pair< std::complex< Real >, std::complex< Real > > F_F_tilde(const std::complex< Real > &z1, const std::complex< Real > &z2, const std::complex< Real > &z3, const std::complex< Real > &z4, Real tau, Size cutoff=50) const
std::complex< Real > z2_f(const std::complex< Real > &s, const std::complex< Real > &w, Real T) const
std::complex< Real > z1_f(const std::complex< Real > &s, const std::complex< Real > &w, Real T) const
std::complex< Real > Phi(const std::complex< Real > &s, const std::complex< Real > &w, Real T, Real t=0.0, Size cutoff=50) const
Continuous-averaging Asian engine base class.
Shared handle to an observable.
Definition: handle.hpp:41
const DefaultType & t
Option exercise classes and payoff function.
Integral of a 1-dimensional function using the Gauss quadratures.
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Heston stochastic process.
Definition: any.hpp:35
integral of a one-dimensional function using Simpson formula