QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
analytichestonforwardeuropeanengine.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
24#ifndef quantlib_analytic_heston_forward_european_engine_hpp
25#define quantlib_analytic_heston_forward_european_engine_hpp
26
27#include <ql/instruments/forwardvanillaoption.hpp>
28#include <ql/pricingengines/vanilla/analytichestonengine.hpp>
29#include <ql/processes/hestonprocess.hpp>
30#include <ql/models/equity/hestonmodel.hpp>
31#include <ql/math/modifiedbessel.hpp>
32#include <ql/math/integrals/gaussianquadratures.hpp>
33#include <ql/exercise.hpp>
34#include <ql/quotes/simplequote.hpp>
35
36namespace QuantLib {
37
39
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 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
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