Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
LgmData Class Reference

Linear Gauss Markov Model Parameters. More...

#include <ored/model/lgmdata.hpp>

+ Inheritance diagram for LgmData:
+ Collaboration diagram for LgmData:

Public Types

enum class  ReversionType { HullWhite , Hagan }
 Supported mean reversion types. More...
 
enum class  VolatilityType { HullWhite , Hagan }
 Supported volatility types. More...
 

Public Member Functions

 LgmData ()
 Default constructor. More...
 
 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. More...
 
void clear () override
 Clear list of calibration instruments. More...
 
void reset () override
 Reset member variables to defaults. More...
 
Serialisation
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (XMLDocument &doc) const override
 
Setters/Getters
ReversionTypereversionType ()
 
VolatilityTypevolatilityType ()
 
boolcalibrateH ()
 
ParamTypehParamType ()
 
std::vector< Time > & hTimes ()
 
std::vector< Real > & hValues ()
 
boolcalibrateA ()
 
ParamTypeaParamType ()
 
std::vector< Time > & aTimes ()
 
std::vector< Real > & aValues ()
 
Real & shiftHorizon ()
 
Real & scaling ()
 
QuantExt::AnalyticLgmSwaptionEngine::FloatSpreadMappingfloatSpreadMapping ()
 
std::vector< std::string > & optionExpiries () const
 
std::vector< std::string > & optionTerms () const
 
std::vector< std::string > & optionStrikes () const
 
ReversionParameter reversionParameter () const
 
VolatilityParameter volatilityParameter () const
 
- Public Member Functions inherited from IrModelData
 IrModelData (const std::string &name)
 minimal constructor More...
 
 IrModelData (const std::string &name, const std::string &qualifier, CalibrationType calibrationType)
 Detailed constructor. More...
 
virtual void clear ()
 Clear list of calibration instruments. More...
 
virtual void reset ()
 Reset member variables to defaults. More...
 
const std::string & name ()
 
std::string & qualifier ()
 
CalibrationTypecalibrationType ()
 
virtual std::string ccy () const
 
- Public Member Functions inherited from XMLSerializable
virtual ~XMLSerializable ()
 
virtual void fromXML (XMLNode *node)=0
 
virtual XMLNodetoXML (XMLDocument &doc) const =0
 
void fromFile (const std::string &filename)
 
void toFile (const std::string &filename) const
 
void fromXMLString (const std::string &xml)
 Parse from XML string. More...
 
std::string toXMLString () const
 Parse from XML string. More...
 

Operators

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_
 
Real scaling_
 
std::vector< std::string > optionExpiries_
 
std::vector< std::string > optionTerms_
 
std::vector< std::string > optionStrikes_
 
QuantExt::AnalyticLgmSwaptionEngine::FloatSpreadMapping floatSpreadMapping_
 
bool operator== (const LgmData &rhs)
 
bool operator!= (const LgmData &rhs)
 

Additional Inherited Members

- Protected Attributes inherited from IrModelData
std::string name_
 
std::string qualifier_
 
CalibrationType calibrationType_
 

Detailed Description

Linear Gauss Markov Model Parameters.

This class contains the description of a Linear Gauss Markov interest rate model and instructions for how to calibrate it.

Definition at line 53 of file lgmdata.hpp.

Member Enumeration Documentation

◆ ReversionType

enum class ReversionType
strong

Supported mean reversion types.

Enumerator
HullWhite 

Parametrize H(t) via Hull-White mean reversion speed, LGM H(t) = int_0^t exp(-kappa(s) *s) ds with constant or piecewise kappa(s)

Hagan 

Parametrize LGM H(t) as H(t) = int_0^t h(s) ds with constant or piecewise h(s)

Definition at line 56 of file lgmdata.hpp.

56 {
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 };
@ Hagan
Parametrize LGM H(t) as H(t) = int_0^t h(s) ds with constant or piecewise h(s)

◆ VolatilityType

enum class VolatilityType
strong

Supported volatility types.

Enumerator
HullWhite 

Parametrize volatility as HullWhite sigma(t)

Hagan 

Parametrize volatility as Hagan alpha(t)

Definition at line 67 of file lgmdata.hpp.

67 {
68 //! Parametrize volatility as HullWhite sigma(t)
70 //! Parametrize volatility as Hagan alpha(t)
71 Hagan
72 };

Constructor & Destructor Documentation

◆ LgmData() [1/2]

LgmData ( )

Default constructor.

Definition at line 75 of file lgmdata.hpp.

◆ LgmData() [2/2]

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 at line 81 of file lgmdata.hpp.

CalibrationType & calibrationType()
std::string & qualifier()
std::vector< Time > & hTimes()
Definition: lgmdata.hpp:112
std::vector< std::string > & optionExpiries() const
Definition: lgmdata.hpp:121
std::vector< Time > & aTimes()
Definition: lgmdata.hpp:116
std::vector< std::string > optionTerms_
Definition: lgmdata.hpp:147
Real & scaling()
Definition: lgmdata.hpp:119
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
std::vector< Real > & hValues()
Definition: lgmdata.hpp:113
std::vector< Real > & aValues()
Definition: lgmdata.hpp:117
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
std::vector< Real > hValues_
Definition: lgmdata.hpp:140
bool & calibrateA()
Definition: lgmdata.hpp:114
std::vector< std::string > & optionStrikes() const
Definition: lgmdata.hpp:123
std::vector< std::string > optionStrikes_
Definition: lgmdata.hpp:148

Member Function Documentation

◆ clear()

void clear ( )
overridevirtual

Clear list of calibration instruments.

Reimplemented from IrModelData.

Definition at line 123 of file lgmdata.cpp.

123 {
124 optionExpiries_.clear();
125 optionTerms_.clear();
126 optionStrikes_.clear();
127}
+ Here is the caller graph for this function:

◆ reset()

void reset ( )
overridevirtual

Reset member variables to defaults.

Reimplemented from IrModelData.

Definition at line 129 of file lgmdata.cpp.

129 {
133 calibrateH_ = false;
135 hTimes_ = {};
136 hValues_ = {0.03};
137 calibrateA_ = false;
139 aTimes_ = {};
140 aValues_ = {0.01};
141 shiftHorizon_ = 0.0;
142 scaling_ = 1.0;
143}
virtual void reset()
Reset member variables to defaults.
@ HullWhite
Parametrize volatility as HullWhite sigma(t)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Reimplemented from IrModelData.

Reimplemented in CrLgmData, and IrLgmData.

Definition at line 145 of file lgmdata.cpp.

145 {
146 XMLNode* volNode = XMLUtils::getChildNode(node, "Volatility");
147
148 calibrateA_ = XMLUtils::getChildValueAsBool(volNode, "Calibrate", true);
149 LOG("LGM Volatility calibrate = " << calibrateA_);
150
151 std::string volTypeString = XMLUtils::getChildValue(volNode, "VolatilityType", true);
152 volType_ = parseVolatilityType(volTypeString);
153 LOG("LGM Volatility type = " << volTypeString);
154
155 std::string alphaTypeString = XMLUtils::getChildValue(volNode, "ParamType", true);
156 aType_ = parseParamType(alphaTypeString);
157 LOG("LGM Volatility param type = " << alphaTypeString);
158
159 aTimes_ = XMLUtils::getChildrenValuesAsDoublesCompact(volNode, "TimeGrid", true);
160 LOG("LGM Volatility time grid size = " << aTimes_.size());
161
162 aValues_ = XMLUtils::getChildrenValuesAsDoublesCompact(volNode, "InitialValue", true);
163 LOG("LGM Volatility initial values size = " << aValues_.size());
164
165 // Reversion config
166
167 XMLNode* revNode = XMLUtils::getChildNode(node, "Reversion");
168
169 calibrateH_ = XMLUtils::getChildValueAsBool(revNode, "Calibrate", true);
170 LOG("LGM Reversion calibrate = " << calibrateH_);
171
172 std::string revTypeString = XMLUtils::getChildValue(revNode, "ReversionType", true);
173 revType_ = parseReversionType(revTypeString);
174 LOG("LGM Reversion type = " << revTypeString);
175
176 std::string hTypeString = XMLUtils::getChildValue(revNode, "ParamType", true);
177 hType_ = parseParamType(hTypeString);
178 LOG("LGM Reversion parameter type = " << hTypeString);
179
180 hTimes_ = XMLUtils::getChildrenValuesAsDoublesCompact(revNode, "TimeGrid", true);
181 LOG("LGM Reversion time grid size = " << hTimes_.size());
182
183 hValues_ = XMLUtils::getChildrenValuesAsDoublesCompact(revNode, "InitialValue", true);
184 LOG("LGM Reversion initial values size = " << hValues_.size());
185
186 // Parameter transformation config
187
188 if (XMLNode* tranformNode = XMLUtils::getChildNode(node, "ParameterTransformation")) {
189 shiftHorizon_ = XMLUtils::getChildValueAsDouble(tranformNode, "ShiftHorizon", true);
190 LOG("LGM shift horizon = " << shiftHorizon_);
191
192 scaling_ = XMLUtils::getChildValueAsDouble(tranformNode, "Scaling", true);
193 LOG("LGM scaling = " << scaling_);
194 } else {
195 shiftHorizon_ = 0.0;
196 scaling_ = 1.0;
197 }
198
200 parseFloatSpreadMapping(XMLUtils::getChildValue(node, "FloatSpreadMapping", false, "proRata"));
201
203
204 LOG("LgmData done");
205}
virtual void fromXML(XMLNode *node) override
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
Definition: xmlutils.cpp:286
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
Definition: xmlutils.cpp:296
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static vector< Real > getChildrenValuesAsDoublesCompact(XMLNode *node, const string &name, bool mandatory=false)
Definition: xmlutils.cpp:327
#define LOG(text)
Logging Macro (Level = Notice)
Definition: log.hpp:552
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
ParamType parseParamType(const string &s)
Convert parameter type string into enumerated class value.
Definition: irmodeldata.cpp:38
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Reimplemented from IrModelData.

Reimplemented in CrLgmData, and IrLgmData.

Definition at line 207 of file lgmdata.cpp.

207 {
208
209 XMLNode* lgmNode = IrModelData::toXML(doc);
210
211 // volatility
212 XMLNode* volatilityNode = XMLUtils::addChild(doc, lgmNode, "Volatility");
213 XMLUtils::addChild(doc, volatilityNode, "Calibrate", calibrateA_);
214
215 XMLNode* volatilityTypeNode = doc.allocNode("VolatilityType", to_string(volType_));
216 XMLUtils::appendNode(volatilityNode, volatilityTypeNode);
217
218 XMLUtils::addGenericChild(doc, volatilityNode, "ParamType", aType_);
219 XMLUtils::addGenericChildAsList(doc, volatilityNode, "TimeGrid", aTimes_);
220 XMLUtils::addGenericChildAsList(doc, volatilityNode, "InitialValue", aValues_);
221
222 // reversion
223 XMLNode* reversionNode = XMLUtils::addChild(doc, lgmNode, "Reversion");
224 XMLUtils::addChild(doc, reversionNode, "Calibrate", calibrateH_);
225
226 XMLNode* reversionTypeNode = doc.allocNode("ReversionType", to_string(revType_));
227 XMLUtils::appendNode(reversionNode, reversionTypeNode);
228
229 XMLUtils::addGenericChild(doc, reversionNode, "ParamType", hType_);
230 XMLUtils::addGenericChildAsList(doc, reversionNode, "TimeGrid", hTimes_);
231 XMLUtils::addGenericChildAsList(doc, reversionNode, "InitialValue", hValues_);
232
233 // parameter transformation
234 XMLNode* parameterTransformationNode = XMLUtils::addChild(doc, lgmNode, "ParameterTransformation");
235 XMLUtils::addChild(doc, parameterTransformationNode, "ShiftHorizon", shiftHorizon_);
236 XMLUtils::addChild(doc, parameterTransformationNode, "Scaling", scaling_);
237
238 XMLUtils::addChild(doc, lgmNode, "FloatSpreadMapping", ore::data::to_string(floatSpreadMapping_));
239
240 return lgmNode;
241}
virtual XMLNode * toXML(XMLDocument &doc) const override
static void addGenericChildAsList(XMLDocument &doc, XMLNode *n, const string &name, const vector< T > &values, const string &attrName="", const string &attr="")
Definition: xmlutils.hpp:144
static void addGenericChild(XMLDocument &doc, XMLNode *n, const char *name, const T &value)
Adds <Name>p1,p2,p3</Name>
Definition: xmlutils.hpp:137
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reversionType()

ReversionType & reversionType ( )

Definition at line 108 of file lgmdata.hpp.

108{ return revType_; }

◆ volatilityType()

VolatilityType & volatilityType ( )

Definition at line 109 of file lgmdata.hpp.

109{ return volType_; }

◆ calibrateH()

bool & calibrateH ( )

Definition at line 110 of file lgmdata.hpp.

110{ return calibrateH_; }

◆ hParamType()

ParamType & hParamType ( )

Definition at line 111 of file lgmdata.hpp.

111{ return hType_; }

◆ hTimes()

std::vector< Time > & hTimes ( )

Definition at line 112 of file lgmdata.hpp.

112{ return hTimes_; }

◆ hValues()

std::vector< Real > & hValues ( )

Definition at line 113 of file lgmdata.hpp.

113{ return hValues_; }

◆ calibrateA()

bool & calibrateA ( )

Definition at line 114 of file lgmdata.hpp.

114{ return calibrateA_; }

◆ aParamType()

ParamType & aParamType ( )

Definition at line 115 of file lgmdata.hpp.

115{ return aType_; }

◆ aTimes()

std::vector< Time > & aTimes ( )

Definition at line 116 of file lgmdata.hpp.

116{ return aTimes_; }

◆ aValues()

std::vector< Real > & aValues ( )

Definition at line 117 of file lgmdata.hpp.

117{ return aValues_; }

◆ shiftHorizon()

Real & shiftHorizon ( )

Definition at line 118 of file lgmdata.hpp.

118{ return shiftHorizon_; }

◆ scaling()

Real & scaling ( )

Definition at line 119 of file lgmdata.hpp.

119{ return scaling_; }

◆ floatSpreadMapping()

Definition at line 120 of file lgmdata.hpp.

120{ return floatSpreadMapping_; }

◆ optionExpiries()

std::vector< std::string > & optionExpiries ( ) const

Definition at line 121 of file lgmdata.hpp.

121{ return optionExpiries_; }
+ Here is the caller graph for this function:

◆ optionTerms()

std::vector< std::string > & optionTerms ( ) const

Definition at line 122 of file lgmdata.hpp.

122{ return optionTerms_; }
+ Here is the caller graph for this function:

◆ optionStrikes()

std::vector< std::string > & optionStrikes ( ) const

Definition at line 123 of file lgmdata.hpp.

123{ return optionStrikes_; }
+ Here is the caller graph for this function:

◆ reversionParameter()

ReversionParameter reversionParameter ( ) const

Definition at line 243 of file lgmdata.cpp.

243 {
244 return ReversionParameter(revType_, calibrateH_, hType_, hTimes_, hValues_);
245}

◆ volatilityParameter()

VolatilityParameter volatilityParameter ( ) const

Definition at line 247 of file lgmdata.cpp.

247 {
248 return VolatilityParameter(volType_, calibrateA_, aType_, aTimes_, aValues_);
249}

◆ operator==()

bool operator== ( const LgmData rhs)

Definition at line 47 of file lgmdata.cpp.

47 {
48
49 if (qualifier_ != rhs.qualifier_ || calibrationType_ != rhs.calibrationType_ || revType_ != rhs.revType_ ||
50 volType_ != rhs.volType_ || calibrateH_ != rhs.calibrateH_ || hType_ != rhs.hType_ || hTimes_ != rhs.hTimes_ ||
51 hValues_ != rhs.hValues_ || calibrateA_ != rhs.calibrateA_ || aType_ != rhs.aType_ || aTimes_ != rhs.aTimes_ ||
52 aValues_ != rhs.aValues_ || shiftHorizon_ != rhs.shiftHorizon_ || scaling_ != rhs.scaling_ ||
53 optionExpiries_ != rhs.optionExpiries_ || optionTerms_ != rhs.optionTerms_ ||
54 optionStrikes_ != rhs.optionStrikes_) {
55 return false;
56 }
57 return true;
58}
CalibrationType calibrationType_

◆ operator!=()

bool operator!= ( const LgmData rhs)

Definition at line 60 of file lgmdata.cpp.

60{ return !(*this == rhs); }

Member Data Documentation

◆ revType_

ReversionType revType_
private

Definition at line 135 of file lgmdata.hpp.

◆ volType_

VolatilityType volType_
private

Definition at line 136 of file lgmdata.hpp.

◆ calibrateH_

bool calibrateH_
private

Definition at line 137 of file lgmdata.hpp.

◆ hType_

ParamType hType_
private

Definition at line 138 of file lgmdata.hpp.

◆ hTimes_

std::vector<Time> hTimes_
private

Definition at line 139 of file lgmdata.hpp.

◆ hValues_

std::vector<Real> hValues_
private

Definition at line 140 of file lgmdata.hpp.

◆ calibrateA_

bool calibrateA_
private

Definition at line 141 of file lgmdata.hpp.

◆ aType_

ParamType aType_
private

Definition at line 142 of file lgmdata.hpp.

◆ aTimes_

std::vector<Time> aTimes_
private

Definition at line 143 of file lgmdata.hpp.

◆ aValues_

std::vector<Real> aValues_
private

Definition at line 144 of file lgmdata.hpp.

◆ shiftHorizon_

Real shiftHorizon_
private

Definition at line 145 of file lgmdata.hpp.

◆ scaling_

Real scaling_
private

Definition at line 145 of file lgmdata.hpp.

◆ optionExpiries_

std::vector<std::string> optionExpiries_
mutableprivate

Definition at line 146 of file lgmdata.hpp.

◆ optionTerms_

std::vector<std::string> optionTerms_
mutableprivate

Definition at line 147 of file lgmdata.hpp.

◆ optionStrikes_

std::vector<std::string> optionStrikes_
mutableprivate

Definition at line 148 of file lgmdata.hpp.

◆ floatSpreadMapping_