QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
hullwhite.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) 2006 Chiara Fornarola
6 Copyright (C) 2007 StatPro Italia srl
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
26#ifndef quantlib_hull_white_hpp
27#define quantlib_hull_white_hpp
28
29#include <ql/models/shortrate/onefactormodels/vasicek.hpp>
30#include <utility>
31
32namespace QuantLib {
33
35
50 public:
52 Real a = 0.1, Real sigma = 0.01);
53
54 ext::shared_ptr<Lattice> tree(const TimeGrid& grid) const override;
55
56 ext::shared_ptr<ShortRateDynamics> dynamics() const override;
57
59 Real strike,
60 Time maturity,
61 Time bondMaturity) const override;
62
64 Real strike,
65 Time maturity,
66 Time bondStart,
67 Time bondMaturity) const override;
68
77 static Rate convexityBias(Real futurePrice,
78 Time t,
79 Time T,
80 Real sigma,
81 Real a);
82
83 static std::vector<bool> FixedReversion() {
84 std::vector<bool> c(2);
85 c[0] = true; c[1] = false;
86 return c;
87 }
88
89 protected:
90 void generateArguments() override;
91
92 Real A(Time t, Time T) const override;
93
94 private:
95 class Dynamics;
96 class FittingParameter;
97
99 };
100
102
111 public:
114 ext::shared_ptr<StochasticProcess1D>(new OrnsteinUhlenbeckProcess(a, sigma))),
115 fitting_(std::move(fitting)) {}
116
117 Real variable(Time t, Rate r) const override { return r - fitting_(t); }
118 Real shortRate(Time t, Real x) const override { return x + fitting_(t); }
119
120 private:
122 };
123
125
133 private:
134 class Impl final : public Parameter::Impl {
135 public:
138
139 Real value(const Array&, Time t) const override {
140 Rate forwardRate =
141 termStructure_->forwardRate(t, t, Continuous, NoFrequency);
142 Real temp = a_ < std::sqrt(QL_EPSILON) ?
143 Real(sigma_*t) :
144 Real(sigma_*(1.0 - std::exp(-a_*t))/a_);
145 return (forwardRate + 0.5*temp*temp);
146 }
147
148 private:
151 };
152 public:
154 Real a, Real sigma)
155 : TermStructureFittingParameter(ext::shared_ptr<Parameter::Impl>(
157 };
158
159
160 // inline definitions
161
162 inline ext::shared_ptr<OneFactorModel::ShortRateDynamics>
164 return ext::shared_ptr<ShortRateDynamics>(
165 new Dynamics(phi_, a(), sigma()));
166 }
167
168}
169
170
171#endif
172
1-D array used in linear algebra.
Definition: array.hpp:52
Shared handle to an observable.
Definition: handle.hpp:41
Short-rate dynamics in the Hull-White model.
Definition: hullwhite.hpp:110
Dynamics(Parameter fitting, Real a, Real sigma)
Definition: hullwhite.hpp:112
Real shortRate(Time t, Real x) const override
Compute short rate from state variable.
Definition: hullwhite.hpp:118
Real variable(Time t, Rate r) const override
Compute state variable from short rate.
Definition: hullwhite.hpp:117
Real value(const Array &, Time t) const override
Definition: hullwhite.hpp:139
Handle< YieldTermStructure > termStructure_
Definition: hullwhite.hpp:149
Impl(Handle< YieldTermStructure > termStructure, Real a, Real sigma)
Definition: hullwhite.hpp:136
Analytical term-structure fitting parameter .
Definition: hullwhite.hpp:132
FittingParameter(const Handle< YieldTermStructure > &termStructure, Real a, Real sigma)
Definition: hullwhite.hpp:153
Single-factor Hull-White (extended Vasicek) model class.
Definition: hullwhite.hpp:49
static Rate convexityBias(Real futurePrice, Time t, Time T, Real sigma, Real a)
Definition: hullwhite.cpp:133
Real discountBondOption(Option::Type type, Real strike, Time maturity, Time bondMaturity) const override
Definition: hullwhite.cpp:89
void generateArguments() override
Definition: hullwhite.cpp:85
ext::shared_ptr< Lattice > tree(const TimeGrid &grid) const override
Return by default a trinomial recombining tree.
Definition: hullwhite.cpp:43
ext::shared_ptr< ShortRateDynamics > dynamics() const override
returns the short-rate dynamics
Definition: hullwhite.hpp:163
Real A(Time t, Time T) const override
Definition: hullwhite.cpp:75
static std::vector< bool > FixedReversion()
Definition: hullwhite.hpp:83
Base class describing the short-rate dynamics.
Ornstein-Uhlenbeck process class.
Base class for model parameter implementation.
Definition: parameter.hpp:41
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
Deterministic time-dependent parameter used for yield-curve fitting.
Definition: parameter.hpp:149
time grid class
Definition: timegrid.hpp:43
Vasicek model class
Definition: vasicek.hpp:42
Real sigma() const
Definition: vasicek.hpp:57
Real a() const
Definition: vasicek.hpp:54
@ NoFrequency
null frequency
Definition: frequency.hpp:37
#define QL_EPSILON
Definition: qldefines.hpp:178
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.