Coverage Report

Created: 2025-08-11 06:28

/src/quantlib/ql/processes/hestonslvprocess.hpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2015 Johannes Göttker-Schnetmann
5
 Copyright (C) 2015 Klaus Spanderen
6
7
 This file is part of QuantLib, a free-software/open-source library
8
 for financial quantitative analysts and developers - http://quantlib.org/
9
10
 QuantLib is free software: you can redistribute it and/or modify it
11
 under the terms of the QuantLib license.  You should have received a
12
 copy of the license along with this program; if not, please email
13
 <quantlib-dev@lists.sf.net>. The license is also available online at
14
 <http://quantlib.org/license.shtml>.
15
16
 This program is distributed in the hope that it will be useful, but WITHOUT
17
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
 FOR A PARTICULAR PURPOSE.  See the license for more details.
19
*/
20
21
/*! \file hestonslvprocess.hpp
22
    \brief Heston stochastic local volatility process
23
*/
24
25
#ifndef quantlib_heston_slv_process_hpp
26
#define quantlib_heston_slv_process_hpp
27
28
#include <ql/processes/hestonprocess.hpp>
29
#include <ql/termstructures/volatility/equityfx/localvoltermstructure.hpp>
30
31
namespace QuantLib {
32
33
    class HestonSLVProcess : public StochasticProcess {
34
      public:
35
        HestonSLVProcess(const ext::shared_ptr<HestonProcess>& hestonProcess,
36
                         ext::shared_ptr<LocalVolTermStructure> leverageFct,
37
                         Real mixingFactor = 1.0);
38
39
0
        Size size() const override { return Size(2); }
40
0
        Size factors() const override { return Size(2); }
41
42
        void update() override;
43
44
0
        Array initialValues() const override {
45
0
            return hestonProcess_->initialValues();
46
0
        }
47
0
        Array apply(const Array& x0, const Array& dx) const override {
48
0
            return hestonProcess_->apply(x0, dx);
49
0
        }
50
51
        Array drift(Time t, const Array& x) const override;
52
        Matrix diffusion(Time t, const Array& x) const override;
53
        Array evolve(Time t0, const Array& x0, Time dt, const Array& dw) const override;
54
55
0
        Real v0()    const { return v0_; }
56
0
        Real rho()   const { return rho_; }
57
0
        Real kappa() const { return kappa_; }
58
0
        Real theta() const { return theta_; }
59
0
        Real sigma() const { return sigma_; }
60
0
        Real mixingFactor() const { return mixingFactor_; }
61
0
        ext::shared_ptr<LocalVolTermStructure> leverageFct() const {
62
0
            return leverageFct_;
63
0
        }
64
65
0
        const Handle<Quote>& s0() const { return hestonProcess_->s0(); }
66
0
        const Handle<YieldTermStructure>& dividendYield() const {
67
0
            return hestonProcess_->dividendYield();
68
0
        }
69
0
        const Handle<YieldTermStructure>& riskFreeRate() const {
70
0
            return hestonProcess_->riskFreeRate();
71
0
        }
72
73
0
        Time time(const Date& d) const override { return hestonProcess_->time(d); }
74
75
      private:
76
        Real kappa_, theta_, sigma_, rho_, v0_, mixingFactor_, mixedSigma_;
77
78
        const ext::shared_ptr<HestonProcess> hestonProcess_;
79
        const ext::shared_ptr<LocalVolTermStructure> leverageFct_;
80
81
        void setParameters();
82
    };
83
84
}
85
86
#endif