QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
coxingersollross.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) 2001, 2002, 2003 Sadruddin Rejeb
5 Copyright (C) 2021 Magnus Mencke
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 coxingersollross.hpp
22 \brief Cox-Ingersoll-Ross model
23*/
24
25#ifndef quantlib_cox_ingersoll_ross_hpp
26#define quantlib_cox_ingersoll_ross_hpp
27
30
31namespace QuantLib {
32
33 //! Cox-Ingersoll-Ross model class.
34 /*! This class implements the Cox-Ingersoll-Ross model defined by
35 \f[
36 dr(t) = k(\theta - r(t))dt + \sigma \sqrt{r(t)} dW(t)
37 \f]
38
39 \bug this class was not tested enough to guarantee
40 its functionality.
41
42 \ingroup shortrate
43 */
45 public:
46 CoxIngersollRoss(Rate r0 = 0.05,
47 Real theta = 0.1,
48 Real k = 0.1,
49 Real sigma = 0.1,
50 bool withFellerConstraint = true);
51
53 Real strike,
54 Time maturity,
55 Time bondMaturity) const override;
56
57 ext::shared_ptr<ShortRateDynamics> dynamics() const override;
58
59 ext::shared_ptr<Lattice> tree(const TimeGrid& grid) const override;
60
61
62 class Dynamics;
63 protected:
64 Real A(Time t, Time T) const override;
65 Real B(Time t, Time T) const override;
66
67 Real theta() const { return theta_(0.0); }
68 Real k() const { return k_(0.0); }
69 Real sigma() const { return sigma_(0.0); }
70 Real x0() const { return r0_(0.0); }
71
72 private:
73 class VolatilityConstraint;
74
79 };
80
81 //! %Dynamics of the short-rate under the Cox-Ingersoll-Ross model
82 /*! The short-rate is simulated directly using the Quadratic Exponential
83 discretization scheme as described in Leif Andersen,
84 Efficient Simulation of the Heston Stochastic Volatility Model.
85 */
88 public:
90 Real k,
91 Real sigma,
92 Real x0)
93 : ShortRateDynamics(ext::shared_ptr<StochasticProcess1D>(
95
96 Real variable(Time, Rate r) const override { return r; }
97 Real shortRate(Time, Real y) const override { return y; }
98 };
99
100}
101
102
103#endif
Dynamics of the short-rate under the Cox-Ingersoll-Ross model
Real shortRate(Time, Real y) const override
Compute short rate from state variable.
Real variable(Time, Rate r) const override
Compute state variable from short rate.
Dynamics(Real theta, Real k, Real sigma, Real x0)
Cox-Ingersoll-Ross model class.
Real B(Time t, Time T) const override
Real discountBondOption(Option::Type type, Real strike, Time maturity, Time bondMaturity) const override
ext::shared_ptr< Lattice > tree(const TimeGrid &grid) const override
Return by default a trinomial recombining tree.
ext::shared_ptr< ShortRateDynamics > dynamics() const override
returns the short-rate dynamics
Real A(Time t, Time T) const override
CoxIngersollRoss process class.
Single-factor affine base class.
Base class describing the short-rate dynamics.
Base class for model arguments.
Definition: parameter.hpp:38
1-dimensional stochastic process
time grid class
Definition: timegrid.hpp:43
CoxIngersollRoss process.
const DefaultType & t
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35
Abstract one-factor interest rate model class.
ext::shared_ptr< YieldTermStructure > r