QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
sensitivityanalysis.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) 2008, 2010 Ferdinando Ametrano
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 sensitivityanalysis.hpp
21 \brief sensitivity analysis function
22*/
23
24#ifndef quantlib_sensitivity_analysis_hpp
25#define quantlib_sensitivity_analysis_hpp
26
27#include <ql/types.hpp>
28#include <ql/utilities/null.hpp>
29#include <ql/shared_ptr.hpp>
30#include <vector>
31
32namespace QuantLib {
33
34 template <class T>
35 class Handle;
36 class Quote;
37 class SimpleQuote;
38 class Instrument;
39
40 //! Finite differences calculation
41 /*! \deprecated Out of scope; copy this enumeration in your codebase if needed.
42 Deprecated in version 1.36.
43 */
44 enum [[deprecated("Out of scope; copy this enumeration in your codebase if needed")]] SensitivityAnalysis {
47 };
48
50
51 /*! \relates SensitivityAnalysis
52 \deprecated Out of scope; copy this function in your codebase if needed.
53 Deprecated in version 1.36.
54 */
55 [[deprecated("Out of scope; copy this function in your codebase if needed")]]
56 std::ostream& operator<<(std::ostream&,
58
59 //! utility fuction for weighted sum of NPVs
60 /*! \deprecated Out of scope; copy this function in your codebase if needed.
61 Deprecated in version 1.36.
62 */
63 [[deprecated("Out of scope; copy this function in your codebase if needed")]]
64 Real aggregateNPV(const std::vector<ext::shared_ptr<Instrument> >&,
65 const std::vector<Real>& quantities);
66
67 //! parallel shift PV01 sensitivity analysis for a SimpleQuote vector
68 /*! returns a pair of first and second derivative values calculated as
69 prescribed by SensitivityAnalysis. Second derivative might not be
70 available depending on SensitivityAnalysis value.
71
72 Empty quantities vector is considered as unit vector. The same if
73 the vector is just one single element equal to one.
74
75 All SimpleQuotes are tweaked together in a parallel fashion.
76
77 \deprecated Out of scope; copy this function in your codebase if needed.
78 Deprecated in version 1.36.
79 */
80 [[deprecated("Out of scope; copy this function in your codebase if needed")]]
81 std::pair<Real, Real>
82 parallelAnalysis(const std::vector<Handle<SimpleQuote> >&,
83 const std::vector<ext::shared_ptr<Instrument> >&,
84 const std::vector<Real>& quantities,
85 Real shift = 0.0001,
87 Real referenceNpv = Null<Real>());
88
89 //! parallel shift PV01 sensitivity analysis for a SimpleQuote matrix
90 /*! returns a pair of first and second derivative values calculated as
91 prescribed by SensitivityAnalysis. Second derivative might not be
92 available depending on SensitivityAnalysis value.
93
94 Empty quantities vector is considered as unit vector. The same if
95 the vector is of size one.
96
97 All SimpleQuotes are tweaked together in a parallel fashion.
98
99 \deprecated Out of scope; copy this function in your codebase if needed.
100 Deprecated in version 1.36.
101 */
102 [[deprecated("Out of scope; copy this function in your codebase if needed")]]
103 std::pair<Real, Real>
104 parallelAnalysis(const std::vector<std::vector<Handle<SimpleQuote> > >&,
105 const std::vector<ext::shared_ptr<Instrument> >&,
106 const std::vector<Real>& quantities,
107 Real shift = 0.0001,
109 Real referenceNpv = Null<Real>());
110
111 //! (bucket) PV01 sensitivity analysis for a (single) SimpleQuote
112 /*! returns a pair of first and second derivative values calculated as
113 prescribed by SensitivityAnalysis. Second derivative might not be
114 available depending on SensitivityAnalysis value.
115
116 Empty quantities vector is considered as unit vector. The same if
117 the vector is of size one.
118
119 \deprecated Out of scope; copy this function in your codebase if needed.
120 Deprecated in version 1.36.
121 */
122 [[deprecated("Out of scope; copy this function in your codebase if needed")]]
123 std::pair<Real, Real> bucketAnalysis(const Handle<SimpleQuote>& quote,
124 const std::vector<ext::shared_ptr<Instrument> >&,
125 const std::vector<Real>& quantities,
126 Real shift = 0.0001,
128 Real referenceNpv = Null<Real>());
129
130 //! (bucket) parameters' sensitivity analysis for a (single) SimpleQuote
131 /*! returns a vector (one element for each paramet) of pair of first and
132 second derivative values calculated as prescribed by
133 SensitivityAnalysis. Second derivative might not be available
134 depending on SensitivityAnalysis value.
135
136 Empty quantities vector is considered as unit vector. The same if
137 the vector is of size one.
138
139 \deprecated Out of scope; copy this function in your codebase if needed.
140 Deprecated in version 1.36.
141 */
142 [[deprecated("Out of scope; copy this function in your codebase if needed")]]
143 void bucketAnalysis(std::vector<Real>& deltaVector, // result
144 std::vector<Real>& gammaVector, // result
145 std::vector<Real>& referenceValues,
146 const Handle<SimpleQuote>& quote,
147 const std::vector<Handle<Quote> >& parameters,
148 Real shift = 0.0001,
150
151 //! bucket PV01 sensitivity analysis for a SimpleQuote vector
152 /*! returns a pair of first and second derivative vectors calculated as
153 prescribed by SensitivityAnalysis. Second derivative might not be
154 available depending on SensitivityAnalysis value.
155
156 Empty quantities vector is considered as unit vector. The same if
157 the vector is of size one.
158
159 The (bucket) SimpleQuotes are tweaked one by one separately.
160
161 \deprecated Out of scope; copy this function in your codebase if needed.
162 Deprecated in version 1.36.
163 */
164 [[deprecated("Out of scope; copy this function in your codebase if needed")]]
165 std::pair<std::vector<Real>, std::vector<Real> >
166 bucketAnalysis(const std::vector<Handle<SimpleQuote> >& quotes,
167 const std::vector<ext::shared_ptr<Instrument> >&,
168 const std::vector<Real>& quantities,
169 Real shift = 0.0001,
171
172 //! bucket parameters' sensitivity analysis for a SimpleQuote vector
173 /*! returns a vector (one element for each paramet) of pair of first and
174 second derivative vectors calculated as prescribed by
175 SensitivityAnalysis. Second derivative might not be available
176 depending on SensitivityAnalysis value.
177
178 Empty quantities vector is considered as unit vector. The same if
179 the vector is of size one.
180
181 The (bucket) SimpleQuotes are tweaked one by one separately.
182
183 \deprecated Out of scope; copy this function in your codebase if needed.
184 Deprecated in version 1.36.
185 */
186 [[deprecated("Out of scope; copy this function in your codebase if needed")]]
187 void
188 bucketAnalysis(std::vector<std::vector<Real> >& deltaMatrix, // result
189 std::vector<std::vector<Real> >& gammaMatrix, // result
190 const std::vector<Handle<SimpleQuote> >& quotes,
191 const std::vector<Handle<Quote> >& parameters,
192 Real shift = 0.0001,
194
195
196 //! bucket sensitivity analysis for a SimpleQuote matrix
197 /*! returns a pair of first and second derivative metrices calculated as
198 prescribed by SensitivityAnalysis. Second derivative might not be
199 available depending on SensitivityAnalysis value.
200
201 Empty quantities vector is considered as unit vector. The same if
202 the vector is of size one.
203
204 The (bucket) SimpleQuotes are tweaked one by one separately.
205
206 \deprecated Out of scope; copy this function in your codebase if needed.
207 Deprecated in version 1.36.
208 */
209 [[deprecated("Out of scope; copy this function in your codebase if needed")]]
210 std::pair<std::vector<std::vector<Real> >, std::vector<std::vector<Real> > >
211 bucketAnalysis(const std::vector<std::vector<Handle<SimpleQuote> > >&,
212 const std::vector<ext::shared_ptr<Instrument> >&,
213 const std::vector<Real>& quantities,
214 Real shift = 0.0001,
216
218}
219
220#endif
Shared handle to an observable.
Definition: handle.hpp:41
template class providing a null value for a given type.
Definition: null.hpp:59
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:37
Real aggregateNPV(const vector< ext::shared_ptr< Instrument > > &instruments, const vector< Real > &quant)
utility fuction for weighted sum of NPVs
pair< Real, Real > parallelAnalysis(const vector< Handle< SimpleQuote > > &quotes, const vector< ext::shared_ptr< Instrument > > &instruments, const vector< Real > &quantities, Real shift, SensitivityAnalysis type, Real referenceNpv)
parallel shift PV01 sensitivity analysis for a SimpleQuote vector
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
pair< Real, Real > bucketAnalysis(const Handle< SimpleQuote > &quote, const vector< ext::shared_ptr< Instrument > > &instruments, const vector< Real > &quantities, Real shift, SensitivityAnalysis type, Real referenceNpv)
(bucket) PV01 sensitivity analysis for a (single) SimpleQuote
SensitivityAnalysis
Finite differences calculation.
null values
#define QL_DEPRECATED_DISABLE_WARNING
Definition: qldefines.hpp:216
#define QL_DEPRECATED_ENABLE_WARNING
Definition: qldefines.hpp:217
Maps shared_ptr to either the boost or std implementation.
Custom types.