QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
blackkarasinski.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
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 blackkarasinski.hpp
21 \brief Black-Karasinski model
22*/
23
24#ifndef quantlib_black_karasinski_hpp
25#define quantlib_black_karasinski_hpp
26
29#include <utility>
30
31namespace QuantLib {
32
33 //! Standard Black-Karasinski model class.
34 /*! This class implements the standard Black-Karasinski model defined by
35 \f[
36 d\ln r_t = (\theta(t) - \alpha \ln r_t)dt + \sigma dW_t,
37 \f]
38 where \f$ alpha \f$ and \f$ sigma \f$ are constants.
39
40 \ingroup shortrate
41 */
44 public:
46 Real a = 0.1, Real sigma = 0.1);
47
48 ext::shared_ptr<ShortRateDynamics> dynamics() const override;
49
50 ext::shared_ptr<Lattice> tree(const TimeGrid& grid) const override;
51
52 private:
53 class Dynamics;
54 class Helper;
55
56 Real a() const { return a_(0.0); }
57 Real sigma() const { return sigma_(0.0); }
58
62 };
63
64 //! Short-rate dynamics in the Black-Karasinski model
65 /*! The short-rate is here
66 \f[
67 r_t = e^{\varphi(t) + x_t}
68 \f]
69 where \f$ \varphi(t) \f$ is the deterministic time-dependent
70 parameter (which can not be determined analytically)
71 used for term-structure fitting and \f$ x_t \f$ is the state
72 variable following an Ornstein-Uhlenbeck process.
73 */
76 public:
80 fitting_(std::move(fitting)) {}
81
82 Real variable(Time t, Rate r) const override { return std::log(r) - fitting_(t); }
83
84 Real shortRate(Time t, Real x) const override { return std::exp(x + fitting_(t)); }
85
86 private:
88 };
89
90}
91
92#endif
93
Short-rate dynamics in the Black-Karasinski model.
Real shortRate(Time t, Real x) const override
Compute short rate from state variable.
Dynamics(Parameter fitting, Real alpha, Real sigma)
Real variable(Time t, Rate r) const override
Compute state variable from short rate.
Standard Black-Karasinski model class.
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
Shared handle to an observable.
Definition: handle.hpp:41
Base class describing the short-rate dynamics.
Single-factor short-rate model abstract class.
Ornstein-Uhlenbeck process class.
Base class for model arguments.
Definition: parameter.hpp:38
1-dimensional stochastic process
Term-structure consistent model class.
Definition: model.hpp:73
const Handle< YieldTermStructure > & termStructure() const
Definition: model.hpp:77
time grid class
Definition: timegrid.hpp:43
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
STL namespace.
Abstract one-factor interest rate model class.
Ornstein-Uhlenbeck process.
ext::shared_ptr< YieldTermStructure > r
Real alpha
Definition: sabr.cpp:200