QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
abcd.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) 2006, 2007 Ferdinando Ametrano
5 Copyright (C) 2006 Cristina Duminuco
6 Copyright (C) 2007 Giorgio Facchinetti
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
22#ifndef quantlib_abcd_hpp
23#define quantlib_abcd_hpp
24
25#include <ql/types.hpp>
26#include <ql/errors.hpp>
28
29namespace QuantLib {
30
31 //! %Abcd functional form for instantaneous volatility
32 /*! \f[ f(T-t) = [ a + b(T-t) ] e^{-c(T-t)} + d \f]
33 following Rebonato's notation. */
35
36 public:
37 AbcdFunction(Real a = -0.06,
38 Real b = 0.17,
39 Real c = 0.54,
40 Real d = 0.17);
41
42 //! maximum value of the volatility function
43 Real maximumVolatility() const { return maximumValue(); }
44
45 //! volatility function value at time 0: \f[ f(0) \f]
46 Real shortTermVolatility() const { return (*this)(0.0); }
47
48 //! volatility function value at time +inf: \f[ f(\inf) \f]
50
51 /*! instantaneous covariance function at time t between T-fixing and
52 S-fixing rates \f[ f(T-t)f(S-t) \f] */
53 Real covariance(Time t, Time T, Time S) const;
54
55 /*! integral of the instantaneous covariance function between
56 time t1 and t2 for T-fixing and S-fixing rates
57 \f[ \int_{t1}^{t2} f(T-t)f(S-t)dt \f] */
58 Real covariance(Time t1, Time t2, Time T, Time S) const;
59
60 /*! average volatility in [tMin,tMax] of T-fixing rate:
61 \f[ \sqrt{ \frac{\int_{tMin}^{tMax} f^2(T-u)du}{tMax-tMin} } \f] */
62 Real volatility(Time tMin, Time tMax, Time T) const;
63
64 /*! variance between tMin and tMax of T-fixing rate:
65 \f[ \frac{\int_{tMin}^{tMax} f^2(T-u)du}{tMax-tMin} \f] */
66 Real variance(Time tMin, Time tMax, Time T) const;
67
68
69
70 // INSTANTANEOUS
71 /*! instantaneous volatility at time t of the T-fixing rate:
72 \f[ f(T-t) \f] */
74
75 /*! instantaneous variance at time t of T-fixing rate:
76 \f[ f(T-t)f(T-t) \f] */
78
79 /*! instantaneous covariance at time t between T and S fixing rates:
80 \f[ f(T-u)f(S-u) \f] */
82
83 // PRIMITIVE
84 /*! indefinite integral of the instantaneous covariance function at
85 time t between T-fixing and S-fixing rates
86 \f[ \int f(T-t)f(S-t)dt \f] */
87 Real primitive(Time t, Time T, Time S) const;
88
89 };
90
91
92 // Helper class used by unit tests
94
95 public:
97 Real operator()(Time t) const;
98
99 private:
100 ext::shared_ptr<AbcdFunction> abcd_;
102 };
103
105 AbcdFunction model(a,b,c,d);
106 return model.volatility(0.,u,u);
107 }
108}
109
110#endif
Abcd functional form for instantaneous volatility
Definition: abcd.hpp:34
Real shortTermVolatility() const
volatility function value at time 0:
Definition: abcd.hpp:46
Real covariance(Time t, Time T, Time S) const
Definition: abcd.cpp:43
Real longTermVolatility() const
volatility function value at time +inf:
Definition: abcd.hpp:49
Real maximumVolatility() const
maximum value of the volatility function
Definition: abcd.hpp:43
Real instantaneousVolatility(Time t, Time T) const
Definition: abcd.cpp:61
Real instantaneousCovariance(Time u, Time T, Time S) const
Definition: abcd.cpp:68
Real volatility(Time tMin, Time tMax, Time T) const
Definition: abcd.cpp:32
Real instantaneousVariance(Time t, Time T) const
Definition: abcd.cpp:65
Real primitive(Time t, Time T, Time S) const
Definition: abcd.cpp:73
Real maximumValue() const
maximum value of the function
Real longTermValue() const
function value at time +inf:
ext::shared_ptr< AbcdFunction > abcd_
Definition: abcd.hpp:100
Real operator()(Time t) const
Definition: abcd.cpp:103
const DefaultType & t
Classes and functions for error handling.
Date d
ext::function< Real(Real)> b
LinearInterpolation variance
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35
Real abcdBlackVolatility(Time u, Real a, Real b, Real c, Real d)
Definition: abcd.hpp:104
Custom types.