QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
hestonmodel.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2005 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 <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
20/*! \file hestonmodel.hpp
21 \brief Heston model for the stochastic volatility of an asset
22*/
23
24#ifndef quantlib_heston_model_hpp
25#define quantlib_heston_model_hpp
26
27#include <ql/models/model.hpp>
29
30namespace QuantLib {
31
32 //! Heston model for the stochastic volatility of an asset
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 \test calibration is tested against known good values.
41 */
43 public:
44 explicit HestonModel(const ext::shared_ptr<HestonProcess>& process);
45
46 // variance mean version level
47 Real theta() const { return arguments_[0](0.0); }
48 // variance mean reversion speed
49 Real kappa() const { return arguments_[1](0.0); }
50 // volatility of the volatility
51 Real sigma() const { return arguments_[2](0.0); }
52 // correlation
53 Real rho() const { return arguments_[3](0.0); }
54 // spot variance
55 Real v0() const { return arguments_[4](0.0); }
56
57 // underlying process
58 ext::shared_ptr<HestonProcess> process() const { return process_; }
59
60 class FellerConstraint;
61 protected:
62 void generateArguments() override;
63 ext::shared_ptr<HestonProcess> process_;
64 };
65
67 private:
68 class Impl final : public Constraint::Impl {
69 public:
70 bool test(const Array& params) const override {
71 const Real theta = params[0];
72 const Real kappa = params[1];
73 const Real sigma = params[2];
74
75 return (sigma >= 0.0 && sigma*sigma < 2.0*kappa*theta);
76 }
77 };
78 public:
80 : Constraint(ext::shared_ptr<Constraint::Impl>(
81 new FellerConstraint::Impl)) {}
82 };
83}
84
85
86#endif
87
1-D array used in linear algebra.
Definition: array.hpp:52
Calibrated model class.
Definition: model.hpp:86
Array params() const
Returns array of arguments on which calibration is done.
Definition: model.cpp:126
std::vector< Parameter > arguments_
Definition: model.hpp:126
Base class for constraint implementations.
Definition: constraint.hpp:38
Base constraint class.
Definition: constraint.hpp:35
bool test(const Array &params) const override
Tests if params satisfy the constraint.
Definition: hestonmodel.hpp:70
Heston model for the stochastic volatility of an asset.
Definition: hestonmodel.hpp:42
ext::shared_ptr< HestonProcess > process_
Definition: hestonmodel.hpp:63
ext::shared_ptr< HestonProcess > process() const
Definition: hestonmodel.hpp:58
void generateArguments() override
Definition: hestonmodel.cpp:44
QL_REAL Real
real number
Definition: types.hpp:50
Heston stochastic process.
Abstract interest rate model class.
Definition: any.hpp:35