Coverage Report

Created: 2025-09-04 07:11

/src/quantlib/ql/models/equity/piecewisetimedependenthestonmodel.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) 2010 Klaus Spanderen
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
 <https://www.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 piecewisetimedependenthestonmodel.hpp
21
    \brief piecewise constant time dependent Heston-model
22
*/
23
24
#ifndef quantlib_piecewise_time_dependent_heston_model_hpp
25
#define quantlib_piecewise_time_dependent_heston_model_hpp
26
27
#include <ql/timegrid.hpp>
28
#include <ql/models/model.hpp>
29
30
namespace QuantLib {
31
32
    //! Piecewise time dependent Heston model
33
    /*! References:
34
35
        Heston, Steven L., 1993. A Closed-Form Solution for Options
36
        with Stochastic Volatility with Applications to Bond and
37
        Currency Options.  The review of Financial Studies, Volume 6,
38
        Issue 2, 327-343.
39
        
40
        A. Elices, Models with time-dependent parameters using 
41
        transform methods: application to Heston’s model,
42
        http://arxiv.org/pdf/0708.2020
43
    */
44
    class PiecewiseTimeDependentHestonModel : public CalibratedModel {
45
      public:
46
        PiecewiseTimeDependentHestonModel(const Handle<YieldTermStructure>& riskFreeRate,
47
                                          const Handle<YieldTermStructure>& dividendYield,
48
                                          const Handle<Quote>& s0,
49
                                          Real v0,
50
                                          const Parameter& theta,
51
                                          const Parameter& kappa,
52
                                          const Parameter& sigma,
53
                                          const Parameter& rho,
54
                                          TimeGrid timeGrid);
55
56
        // variance mean version level
57
0
        Real theta(Time t) const { return arguments_[0](t); }
58
        // variance mean reversion speed
59
0
        Real kappa(Time t) const { return arguments_[1](t); }
60
        // volatility of the volatility
61
0
        Real sigma(Time t) const { return arguments_[2](t); }
62
        // correlation
63
0
        Real rho(Time t)   const { return arguments_[3](t); }
64
        // spot variance
65
0
        Real v0()          const { return arguments_[4](0.0); }
66
        // spot
67
0
        Real s0()          const { return s0_->value(); }
68
69
        
70
        const TimeGrid& timeGrid() const;
71
        const Handle<YieldTermStructure>& dividendYield() const;
72
        const Handle<YieldTermStructure>& riskFreeRate() const;
73
        
74
      protected:
75
        const Handle<Quote> s0_;
76
        const Handle<YieldTermStructure> riskFreeRate_;
77
        const Handle<YieldTermStructure> dividendYield_;
78
        const TimeGrid timeGrid_;
79
    };
80
}
81
82
83
#endif
84