QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
analytic_cont_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_continuous_geometric_average_price_asian_heston_engine_hpp
26#define quantlib_analytic_continuous_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/math/integrals/simpsonintegral.hpp>
32#include <ql/exercise.hpp>
33#include <complex>
34
35namespace QuantLib {
36
38
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
Pricing engine for European continuous geometric average price Asian.
std::complex< Real > f(const std::complex< Real > &z1, const std::complex< Real > &z2, const std::complex< Real > &z3, const std::complex< Real > &z4, int n, Real tau) const
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
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