QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
coxingersollross.hpp
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
25#ifndef quantlib_cox_ingersoll_ross_hpp
26#define quantlib_cox_ingersoll_ross_hpp
27
28#include <ql/models/shortrate/onefactormodel.hpp>
29#include <ql/processes/coxingersollrossprocess.hpp>
30
31namespace QuantLib {
32
34
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
82
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
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