Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
lgmdata.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file model/lgmdata.hpp
20 \brief Linear Gauss Markov model data
21 \ingroup models
22*/
23
24#pragma once
25
26#include <vector>
27
28#include <ql/time/daycounters/actualactual.hpp>
29#include <ql/types.hpp>
30
31#include <qle/models/lgm.hpp>
33
38
39namespace ore {
40namespace data {
41using namespace QuantLib;
42
43class VolatilityParameter;
44class ReversionParameter;
45
46//! Linear Gauss Markov Model Parameters
47/*!
48 This class contains the description of a Linear Gauss Markov interest rate model
49 and instructions for how to calibrate it.
50
51 \ingroup models
52 */
53class LgmData : public IrModelData {
54public:
55 //! Supported mean reversion types
56 enum class ReversionType {
57 /*! Parametrize H(t) via Hull-White mean reversion speed,
58 LGM H(t) = int_0^t exp(-kappa(s) *s) ds with constant or piecewise kappa(s)
59 */
61 //! Parametrize LGM H(t) as H(t) = int_0^t h(s) ds with constant or piecewise h(s)
62 Hagan
63 // FIXME: indent
64 };
65
66 //! Supported volatility types
67 enum class VolatilityType {
68 //! Parametrize volatility as HullWhite sigma(t)
70 //! Parametrize volatility as Hagan alpha(t)
71 Hagan
72 };
73
74 //! Default constructor
79
80 //! Detailed constructor
82 bool calibrateH, ParamType hType, std::vector<Time> hTimes, std::vector<Real> hValues, bool calibrateA,
83 ParamType aType, std::vector<Time> aTimes, std::vector<Real> aValues, Real shiftHorizon = 0.0,
84 Real scaling = 1.0, std::vector<std::string> optionExpiries = std::vector<std::string>(),
85 std::vector<std::string> optionTerms = std::vector<std::string>(),
86 std::vector<std::string> optionStrikes = std::vector<std::string>(),
93
94 //! Clear list of calibration instruments
95 void clear() override;
96
97 //! Reset member variables to defaults
98 void reset() override;
99
100 //! \name Serialisation
101 //@{
102 virtual void fromXML(XMLNode* node) override;
103 virtual XMLNode* toXML(XMLDocument& doc) const override;
104 //@}
105
106 //! \name Setters/Getters
107 //@{
110 bool& calibrateH() { return calibrateH_; }
112 std::vector<Time>& hTimes() { return hTimes_; }
113 std::vector<Real>& hValues() { return hValues_; }
114 bool& calibrateA() { return calibrateA_; }
116 std::vector<Time>& aTimes() { return aTimes_; }
117 std::vector<Real>& aValues() { return aValues_; }
118 Real& shiftHorizon() { return shiftHorizon_; }
119 Real& scaling() { return scaling_; }
121 std::vector<std::string>& optionExpiries() const { return optionExpiries_; }
122 std::vector<std::string>& optionTerms() const { return optionTerms_; }
123 std::vector<std::string>& optionStrikes() const { return optionStrikes_; }
126 //@}
127
128 //! \name Operators
129 //@{
130 bool operator==(const LgmData& rhs);
131 bool operator!=(const LgmData& rhs);
132 //@}
133
134private:
139 std::vector<Time> hTimes_;
140 std::vector<Real> hValues_;
143 std::vector<Time> aTimes_;
144 std::vector<Real> aValues_;
146 mutable std::vector<std::string> optionExpiries_;
147 mutable std::vector<std::string> optionTerms_;
148 mutable std::vector<std::string> optionStrikes_;
151};
152
153//! Enum parsers
157
158//! Enum to string
159std::ostream& operator<<(std::ostream& oss, const LgmData::ReversionType& type);
160std::ostream& operator<<(std::ostream& oss, const LgmData::VolatilityType& type);
161std::ostream& operator<<(std::ostream& oss, const QuantExt::AnalyticLgmSwaptionEngine::FloatSpreadMapping& m);
162
163/*! LGM reversion transformation.
164
165 This class holds values for possibly transforming the reversion parameter of the LGM model. The use of this is
166 outlined in <em>Modern Derivatives Pricing and Credit Exposure Analysis</em>, Section 16.4.
167
168 \ingroup models
169 */
171public:
172 //! Default constructor setting the horizon to 0.0 and the scaling to 1.0.
174
175 //! Detailed constructor
176 LgmReversionTransformation(QuantLib::Time horizon, QuantLib::Real scaling);
177
178 //! \name Inspectors
179 //@{
180 QuantLib::Time horizon() const;
181 QuantLib::Real scaling() const;
182 //@}
183
184 //! \name Serialisation
185 //@{
186 void fromXML(XMLNode* node) override;
187 XMLNode* toXML(XMLDocument& doc) const override;
188 //@}
189
190private:
191 QuantLib::Time horizon_;
192 QuantLib::Real scaling_;
193};
194
195} // namespace data
196} // namespace ore
Linear Gauss Markov Model Parameters.
Definition: irmodeldata.hpp:88
CalibrationType & calibrationType()
std::string & qualifier()
Linear Gauss Markov Model Parameters.
Definition: lgmdata.hpp:53
std::vector< Time > & hTimes()
Definition: lgmdata.hpp:112
VolatilityType & volatilityType()
Definition: lgmdata.hpp:109
ParamType aType_
Definition: lgmdata.hpp:142
VolatilityParameter volatilityParameter() const
Definition: lgmdata.cpp:247
bool operator!=(const LgmData &rhs)
Definition: lgmdata.cpp:60
std::vector< std::string > & optionExpiries() const
Definition: lgmdata.hpp:121
ParamType & hParamType()
Definition: lgmdata.hpp:111
std::vector< Time > & aTimes()
Definition: lgmdata.hpp:116
std::vector< std::string > optionTerms_
Definition: lgmdata.hpp:147
VolatilityType volType_
Definition: lgmdata.hpp:136
Real & scaling()
Definition: lgmdata.hpp:119
LgmData()
Default constructor.
Definition: lgmdata.hpp:75
ReversionParameter reversionParameter() const
Definition: lgmdata.cpp:243
QuantExt::AnalyticLgmSwaptionEngine::FloatSpreadMapping floatSpreadMapping_
Definition: lgmdata.hpp:149
std::vector< std::string > optionExpiries_
Definition: lgmdata.hpp:146
std::vector< Time > hTimes_
Definition: lgmdata.hpp:139
std::vector< Time > aTimes_
Definition: lgmdata.hpp:143
virtual void fromXML(XMLNode *node) override
Definition: lgmdata.cpp:145
std::vector< Real > & hValues()
Definition: lgmdata.hpp:113
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: lgmdata.cpp:207
ReversionType
Supported mean reversion types.
Definition: lgmdata.hpp:56
@ Hagan
Parametrize LGM H(t) as H(t) = int_0^t h(s) ds with constant or piecewise h(s)
std::vector< Real > & aValues()
Definition: lgmdata.hpp:117
VolatilityType
Supported volatility types.
Definition: lgmdata.hpp:67
std::vector< std::string > & optionTerms() const
Definition: lgmdata.hpp:122
Real & shiftHorizon()
Definition: lgmdata.hpp:118
bool & calibrateH()
Definition: lgmdata.hpp:110
std::vector< Real > aValues_
Definition: lgmdata.hpp:144
ParamType & aParamType()
Definition: lgmdata.hpp:115
bool operator==(const LgmData &rhs)
Definition: lgmdata.cpp:47
QuantExt::AnalyticLgmSwaptionEngine::FloatSpreadMapping & floatSpreadMapping()
Definition: lgmdata.hpp:120
std::vector< Real > hValues_
Definition: lgmdata.hpp:140
bool & calibrateA()
Definition: lgmdata.hpp:114
ReversionType & reversionType()
Definition: lgmdata.hpp:108
LgmData(std::string qualifier, CalibrationType calibrationType, ReversionType revType, VolatilityType volType, bool calibrateH, ParamType hType, std::vector< Time > hTimes, std::vector< Real > hValues, bool calibrateA, ParamType aType, std::vector< Time > aTimes, std::vector< Real > aValues, Real shiftHorizon=0.0, Real scaling=1.0, std::vector< std::string > optionExpiries=std::vector< std::string >(), std::vector< std::string > optionTerms=std::vector< std::string >(), std::vector< std::string > optionStrikes=std::vector< std::string >(), const QuantExt::AnalyticLgmSwaptionEngine::FloatSpreadMapping inputFloatSpreadMapping=QuantExt::AnalyticLgmSwaptionEngine::proRata)
Detailed constructor.
Definition: lgmdata.hpp:81
std::vector< std::string > & optionStrikes() const
Definition: lgmdata.hpp:123
ParamType hType_
Definition: lgmdata.hpp:138
void reset() override
Reset member variables to defaults.
Definition: lgmdata.cpp:129
void clear() override
Clear list of calibration instruments.
Definition: lgmdata.cpp:123
std::vector< std::string > optionStrikes_
Definition: lgmdata.hpp:148
ReversionType revType_
Definition: lgmdata.hpp:135
void fromXML(XMLNode *node) override
Definition: lgmdata.cpp:260
XMLNode * toXML(XMLDocument &doc) const override
Definition: lgmdata.cpp:266
LgmReversionTransformation()
Default constructor setting the horizon to 0.0 and the scaling to 1.0.
Definition: lgmdata.cpp:251
QuantLib::Real scaling() const
Definition: lgmdata.cpp:258
QuantLib::Time horizon() const
Definition: lgmdata.cpp:256
LgmReversionTransformation(QuantLib::Time horizon, QuantLib::Real scaling)
Detailed constructor.
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
Base class for all serializable classes.
Definition: xmlutils.hpp:101
Currency and instrument specific conventions/defaults.
Generic interest rate model data.
@ data
Definition: log.hpp:77
Base Market class.
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
CalibrationType
Supported calibration types.
Definition: irmodeldata.hpp:46
ParamType
Supported calibration parameter type.
Definition: irmodeldata.hpp:35
LgmData::ReversionType parseReversionType(const string &s)
Enum parsers.
Definition: lgmdata.cpp:62
QuantExt::AnalyticLgmSwaptionEngine::FloatSpreadMapping parseFloatSpreadMapping(const string &s)
Definition: lgmdata.cpp:100
LgmData::VolatilityType parseVolatilityType(const string &s)
Definition: lgmdata.cpp:81
Serializable Credit Default Swap.
Definition: namespaces.docs:23
XML utility functions.