QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
blackkarasinski.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
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
24#ifndef quantlib_black_karasinski_hpp
25#define quantlib_black_karasinski_hpp
26
27#include <ql/models/shortrate/onefactormodel.hpp>
28#include <ql/processes/ornsteinuhlenbeckprocess.hpp>
29#include <utility>
30
31namespace QuantLib {
32
34
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
65
76 public:
77 Dynamics(Parameter fitting, Real alpha, Real sigma)
79 ext::shared_ptr<StochasticProcess1D>(new OrnsteinUhlenbeckProcess(alpha, sigma))),
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
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.