QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
vasicek.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_vasicek_hpp
25#define quantlib_vasicek_hpp
26
27#include <ql/models/shortrate/onefactormodel.hpp>
28#include <ql/processes/ornsteinuhlenbeckprocess.hpp>
29
30namespace QuantLib {
31
33
43 public:
44 Vasicek(Rate r0 = 0.05,
45 Real a = 0.1, Real b = 0.05, Real sigma = 0.01,
46 Real lambda = 0.0);
48 Real strike,
49 Time maturity,
50 Time bondMaturity) const override;
51
52 ext::shared_ptr<ShortRateDynamics> dynamics() const override;
53
54 Real a() const { return a_(0.0); }
55 Real b() const { return b_(0.0); }
56 Real lambda() const { return lambda_(0.0); }
57 Real sigma() const { return sigma_(0.0); }
58 Real r0() const { return r0_;}
59
60 protected:
61 Real A(Time t, Time T) const override;
62 Real B(Time t, Time T) const override;
63
69 private:
70 class Dynamics;
71
72 };
73
75
79 public:
81 Real b,
82 Real sigma,
83 Real r0)
84 : ShortRateDynamics(ext::shared_ptr<StochasticProcess1D>(
86 b_(b) {}
87
88 Real variable(Time, Rate r) const override { return r - b_; }
89 Real shortRate(Time, Real x) const override { return x + b_; }
90
91 private:
93 };
94
95
96 // inline definitions
97
98 inline ext::shared_ptr<OneFactorModel::ShortRateDynamics>
100 return ext::shared_ptr<ShortRateDynamics>(
101 new Dynamics(a(), b() , sigma(), r0_));
102 }
103
104}
105
106
107#endif
108
Single-factor affine base class.
Base class describing the short-rate dynamics.
Ornstein-Uhlenbeck process class.
Base class for model arguments.
Definition: parameter.hpp:38
1-dimensional stochastic process
Short-rate dynamics in the Vasicek model.
Definition: vasicek.hpp:78
Real shortRate(Time, Real x) const override
Compute short rate from state variable.
Definition: vasicek.hpp:89
Dynamics(Real a, Real b, Real sigma, Real r0)
Definition: vasicek.hpp:80
Real variable(Time, Rate r) const override
Compute state variable from short rate.
Definition: vasicek.hpp:88
Vasicek model class
Definition: vasicek.hpp:42
Parameter & sigma_
Definition: vasicek.hpp:67
Parameter & b_
Definition: vasicek.hpp:66
Parameter & lambda_
Definition: vasicek.hpp:68
Real B(Time t, Time T) const override
Definition: vasicek.cpp:49
Real b() const
Definition: vasicek.hpp:55
Real sigma() const
Definition: vasicek.hpp:57
Real lambda() const
Definition: vasicek.hpp:56
Real discountBondOption(Option::Type type, Real strike, Time maturity, Time bondMaturity) const override
Definition: vasicek.cpp:57
Real a() const
Definition: vasicek.hpp:54
ext::shared_ptr< ShortRateDynamics > dynamics() const override
returns the short-rate dynamics
Definition: vasicek.hpp:99
Parameter & a_
Definition: vasicek.hpp:65
Real A(Time t, Time T) const override
Definition: vasicek.cpp:36
Real r0() const
Definition: vasicek.hpp:58
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