QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
analytic_discr_geom_av_price_heston.hpp
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
25#ifndef quantlib_analytic_discrete_geometric_average_price_asian_heston_engine_hpp
26#define quantlib_analytic_discrete_geometric_average_price_asian_heston_engine_hpp
27
28#include <ql/instruments/asianoption.hpp>
29#include <ql/processes/hestonprocess.hpp>
30#include <ql/math/integrals/gaussianquadratures.hpp>
31#include <ql/exercise.hpp>
32#include <complex>
33
34namespace QuantLib {
35
37
66 public:
68 ext::shared_ptr<HestonProcess> process, Real xiRightLimit = 100.0);
69 void calculate() const override;
70
71 // Equation (21) - must be public so the integrand can access it.
72 std::complex<Real> Phi(std::complex<Real> s,
73 std::complex<Real> w,
74 Time t,
75 Time T,
76 Size kStar,
77 const std::vector<Time>& t_n,
78 const std::vector<Time>& tauK) const;
79
80 private:
81 // Initial process params
86
87 ext::shared_ptr<HestonProcess> process_;
88
89 // A lookup table for the reuslts of omega_tilde() to avoid repeated calls for given Phi call
90 mutable std::map<Size, std::complex<Real> > omegaTildeLookupTable_;
91
92 // Cutoff parameter for integral in Eqs (23) and (24)
94
95 // Integrator for equation (23) and (24)
97
98 // Integrand
99 class Integrand;
100
101 // We need to set up several variables inside calculate as they depend on fixing times. Rather
102 // than pass them between a, omega, F etc. which makes for very messy method signatures, we
103 // make them mutable class properties instead.
104 mutable Real tr_t_;
105 mutable Real Tr_T_;
106 mutable std::vector<Real> tkr_tk_;
107
108 // Equation (11)
109 std::complex<Real> F(const std::complex<Real>& z1,
110 const std::complex<Real>& z2,
111 Time tau) const;
112
113 std::complex<Real> F_tilde(const std::complex<Real>& z1,
114 const std::complex<Real>& z2,
115 Time tau) const;
116
117 // Equation (14)
118 std::complex<Real> z(const std::complex<Real>& s,
119 const std::complex<Real>& w,
120 Size k, Size n) const;
121
122 // Equation (15)
123 std::complex<Real> omega(const std::complex<Real>& s,
124 const std::complex<Real>& w,
125 Size k, Size kStar, Size n) const;
126
127 // Equation (16)
128 std::complex<Real> a(const std::complex<Real>& s,
129 const std::complex<Real>& w,
130 Time t, Time T, Size kStar,
131 const std::vector<Time>& t_n) const;
132
133 // Equation (19)
134 std::complex<Real> omega_tilde(const std::complex<Real>& s,
135 const std::complex<Real>& w,
136 Size k, Size kStar, Size n,
137 const std::vector<Time>& tauK) const;
138 };
139}
140
141
142#endif
Pricing engine for European discrete geometric average price Asian.
std::complex< Real > F_tilde(const std::complex< Real > &z1, const std::complex< Real > &z2, Time tau) const
std::complex< Real > omega(const std::complex< Real > &s, const std::complex< Real > &w, Size k, Size kStar, Size n) const
std::complex< Real > z(const std::complex< Real > &s, const std::complex< Real > &w, Size k, Size n) const
std::complex< Real > Phi(std::complex< Real > s, std::complex< Real > w, Time t, Time T, Size kStar, const std::vector< Time > &t_n, const std::vector< Time > &tauK) const
std::complex< Real > a(const std::complex< Real > &s, const std::complex< Real > &w, Time t, Time T, Size kStar, const std::vector< Time > &t_n) const
std::complex< Real > F(const std::complex< Real > &z1, const std::complex< Real > &z2, Time tau) const
std::complex< Real > omega_tilde(const std::complex< Real > &s, const std::complex< Real > &w, Size k, Size kStar, Size n, const std::vector< Time > &tauK) const
Discrete-averaging Asian engine base class.
Shared handle to an observable.
Definition: handle.hpp:41
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