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

#include <ored/model/crcirdata.hpp>

+ Inheritance diagram for CrCirData:
+ Collaboration diagram for CrCirData:

Public Types

enum class  CalibrationStrategy { CurveAndFlatVol , None }
 

Public Member Functions

 CrCirData ()
 Default constructor. More...
 
 CrCirData (std::string name, std::string currency, CalibrationType calibrationType, CalibrationStrategy calibrationStrategy, Real startValue, Real reversionValue, Real longTermValue, Real volatility, bool relaxedFeller, Real fellerFactor, Real tolerance, 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 >())
 Detailed constructor. More...
 
Serialisation
void fromXML (XMLNode *node) override
 
XMLNodetoXML (XMLDocument &doc) const override
 
Setters/Getters

setter/getter for qualifier in derived classes

std::string & name ()
 
std::string & currency ()
 
CalibrationTypecalibrationType ()
 
CalibrationStrategycalibrationStrategy ()
 
Real & startValue ()
 
Real & reversionValue ()
 
Real & longTermValue ()
 
Real & volatility ()
 
std::vector< std::string > & optionExpiries ()
 
std::vector< std::string > & optionTerms ()
 
std::vector< std::string > & optionStrikes ()
 
boolrelaxedFeller ()
 
Real & fellerFactor ()
 
Real & tolerance ()
 
- 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

std::string name_
 
std::string currency_
 
CalibrationType calibrationType_
 
CalibrationStrategy calibrationStrategy_
 
Real startValue_
 
Real reversionValue_
 
Real longTermValue_
 
Real volatility_
 
bool relaxedFeller_
 
Real fellerFactor_
 
Real tolerance_
 
std::vector< std::string > optionExpiries_
 
std::vector< std::string > optionTerms_
 
std::vector< std::string > optionStrikes_
 
bool operator== (const CrCirData &rhs)
 
bool operator!= (const CrCirData &rhs)
 

Detailed Description

Definition at line 40 of file crcirdata.hpp.

Member Enumeration Documentation

◆ CalibrationStrategy

enum class CalibrationStrategy
strong
Enumerator
CurveAndFlatVol 
None 

Definition at line 42 of file crcirdata.hpp.

Constructor & Destructor Documentation

◆ CrCirData() [1/2]

CrCirData ( )

Default constructor.

Definition at line 45 of file crcirdata.hpp.

45{}

◆ CrCirData() [2/2]

CrCirData ( std::string  name,
std::string  currency,
CalibrationType  calibrationType,
CalibrationStrategy  calibrationStrategy,
Real  startValue,
Real  reversionValue,
Real  longTermValue,
Real  volatility,
bool  relaxedFeller,
Real  fellerFactor,
Real  tolerance,
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>() 
)

Detailed constructor.

Definition at line 48 of file crcirdata.hpp.

CalibrationType & calibrationType()
Definition: crcirdata.hpp:71
Real & reversionValue()
Definition: crcirdata.hpp:74
std::string currency_
Definition: crcirdata.hpp:93
std::vector< std::string > & optionStrikes()
Definition: crcirdata.hpp:79
CalibrationType calibrationType_
Definition: crcirdata.hpp:94
CalibrationStrategy calibrationStrategy_
Definition: crcirdata.hpp:95
std::string name_
Definition: crcirdata.hpp:92
std::vector< std::string > optionTerms_
Definition: crcirdata.hpp:101
Real & longTermValue()
Definition: crcirdata.hpp:75
std::string & currency()
Definition: crcirdata.hpp:70
std::vector< std::string > optionExpiries_
Definition: crcirdata.hpp:100
CalibrationStrategy & calibrationStrategy()
Definition: crcirdata.hpp:72
std::string & name()
Definition: crcirdata.hpp:69
std::vector< std::string > & optionTerms()
Definition: crcirdata.hpp:78
bool & relaxedFeller()
Definition: crcirdata.hpp:80
std::vector< std::string > & optionExpiries()
Definition: crcirdata.hpp:77
std::vector< std::string > optionStrikes_
Definition: crcirdata.hpp:102

Member Function Documentation

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 62 of file crcirdata.cpp.

62 {
63
64 name_ = XMLUtils::getAttribute(node, "name");
65 LOG("CIR with attribute (name) = " << name_);
66
67 currency_ = XMLUtils::getChildValue(node, "Currency", true);
68 LOG("CIR currency = " << currency_);
69
70 std::string calibTypeString = XMLUtils::getChildValue(node, "CalibrationType", true);
71 calibrationType_ = parseCalibrationType(calibTypeString);
72 LOG("CIR calibration type = " << calibTypeString);
73
74 std::string calibStratString = XMLUtils::getChildValue(node, "CalibrationStrategy", true);
76 LOG("CIR calibration strategy = " << calibStratString);
77
78 startValue_ = XMLUtils::getChildValueAsDouble(node, "StartValue", true);
79 LOG("CIR start value_ = " << startValue_);
80
81 reversionValue_ = XMLUtils::getChildValueAsDouble(node, "ReversionValue", true);
82 LOG("CIR reversion value = " << reversionValue_);
83
84 longTermValue_ = XMLUtils::getChildValueAsDouble(node, "LongTermValue", true);
85 LOG("CIR long term value = " << longTermValue_);
86
87 volatility_ = XMLUtils::getChildValueAsDouble(node, "Volatility", true);
88 LOG("CIR volatility = " << volatility_);
89
90 relaxedFeller_ = XMLUtils::getChildValueAsBool(node, "RelaxedFeller", true);
91 LOG("CIR relaxed feller = " << relaxedFeller_);
92
93 fellerFactor_ = XMLUtils::getChildValueAsDouble(node, "FellerFactor", true);
94 LOG("CIR feller factor = " << fellerFactor_);
95
96 tolerance_ = XMLUtils::getChildValueAsDouble(node, "Tolerance", true);
97 LOG("CIR tolerance = " << tolerance_);
98
99 // Calibration Swaptions
100
101 XMLNode* optionsNode = XMLUtils::getChildNode(node, "CalibrationCdsOptions");
102
103 if (optionsNode) {
104
105 optionExpiries() = XMLUtils::getChildrenValuesAsStrings(optionsNode, "Expiries", false);
106 optionTerms() = XMLUtils::getChildrenValuesAsStrings(optionsNode, "Terms", false);
107 QL_REQUIRE(optionExpiries().size() == optionTerms().size(),
108 "vector size mismatch in cds option expiries/terms for name " << name_);
109 optionStrikes() = XMLUtils::getChildrenValuesAsStrings(optionsNode, "Strikes", false);
110 if (optionStrikes().size() > 0) {
111 QL_REQUIRE(optionStrikes().size() == optionExpiries().size(),
112 "vector size mismatch in cds option expiries/strikes for name " << name_);
113 } else // Default: ATM
114 optionStrikes().resize(optionExpiries().size(), "ATM");
115
116 for (Size i = 0; i < optionExpiries().size(); i++) {
117 LOG("CrCir calibration cds option " << optionExpiries()[i] << " x " << optionTerms()[i] << " "
118 << optionStrikes()[i]);
119 }
120 }
121
122 LOG("CrCirData done");
123}
static string getAttribute(XMLNode *node, const string &attrName)
Definition: xmlutils.cpp:419
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< string > getChildrenValuesAsStrings(XMLNode *node, const string &name, bool mandatory=false)
Definition: xmlutils.cpp:342
#define LOG(text)
Logging Macro (Level = Notice)
Definition: log.hpp:552
CalibrationType parseCalibrationType(const string &s)
Convert calibration type string into enumerated class value.
Definition: irmodeldata.cpp:47
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
CrCirData::CalibrationStrategy parseCirCalibrationStrategy(const string &s)
Definition: crcirdata.cpp:42
Size size(const ValueType &v)
Definition: value.cpp:145
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 125 of file crcirdata.cpp.

125 {
126
127 XMLNode* cirNode = doc.allocNode("CIR");
128 XMLUtils::addAttribute(doc, cirNode, "name", name_);
129
130 XMLUtils::addChild(doc, cirNode, "Currency", currency_);
131
132 XMLUtils::addGenericChild(doc, cirNode, "CalibrationType", calibrationType_);
133 XMLUtils::addGenericChild(doc, cirNode, "CalibrationStrategy", calibrationStrategy_);
134
135 XMLUtils::addChild(doc, cirNode, "StartValue", startValue_);
136 XMLUtils::addChild(doc, cirNode, "ReversionValue", reversionValue_);
137 XMLUtils::addChild(doc, cirNode, "LongTermValue", longTermValue_);
138 XMLUtils::addChild(doc, cirNode, "Volatility", volatility_);
139
140 XMLUtils::addChild(doc, cirNode, "RelaxedFeller", relaxedFeller_);
141 XMLUtils::addChild(doc, cirNode, "FellerFactor", fellerFactor_);
142 XMLUtils::addChild(doc, cirNode, "Tolerance", tolerance_);
143
144 // swaption calibration
145 XMLNode* calibrationSwaptionsNode = XMLUtils::addChild(doc, cirNode, "CalibrationCdsOptions");
146 XMLUtils::addGenericChildAsList(doc, calibrationSwaptionsNode, "Expiries", optionExpiries_);
147 XMLUtils::addGenericChildAsList(doc, calibrationSwaptionsNode, "Terms", optionTerms_);
148 XMLUtils::addGenericChildAsList(doc, calibrationSwaptionsNode, "Strikes", optionStrikes_);
149
150 return cirNode;
151}
static void addAttribute(XMLDocument &doc, XMLNode *node, const string &attrName, const string &attrValue)
Definition: xmlutils.cpp:412
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
+ Here is the call graph for this function:

◆ name()

std::string & name ( )

Definition at line 69 of file crcirdata.hpp.

69{ return name_; }

◆ currency()

std::string & currency ( )

Definition at line 70 of file crcirdata.hpp.

70{ return currency_; }

◆ calibrationType()

CalibrationType & calibrationType ( )

Definition at line 71 of file crcirdata.hpp.

71{ return calibrationType_; }

◆ calibrationStrategy()

CalibrationStrategy & calibrationStrategy ( )

Definition at line 72 of file crcirdata.hpp.

72{ return calibrationStrategy_; }

◆ startValue()

Real & startValue ( )

Definition at line 73 of file crcirdata.hpp.

73{ return startValue_; }

◆ reversionValue()

Real & reversionValue ( )

Definition at line 74 of file crcirdata.hpp.

74{ return reversionValue_; }

◆ longTermValue()

Real & longTermValue ( )

Definition at line 75 of file crcirdata.hpp.

75{ return longTermValue_; }

◆ volatility()

Real & volatility ( )

Definition at line 76 of file crcirdata.hpp.

76{ return volatility_; }

◆ optionExpiries()

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

Definition at line 77 of file crcirdata.hpp.

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

◆ optionTerms()

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

Definition at line 78 of file crcirdata.hpp.

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

◆ optionStrikes()

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

Definition at line 79 of file crcirdata.hpp.

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

◆ relaxedFeller()

bool & relaxedFeller ( )

Definition at line 80 of file crcirdata.hpp.

80{ return relaxedFeller_; }

◆ fellerFactor()

Real & fellerFactor ( )

Definition at line 81 of file crcirdata.hpp.

81{ return fellerFactor_; }

◆ tolerance()

Real & tolerance ( )

Definition at line 82 of file crcirdata.hpp.

82{ return tolerance_; }

◆ operator==()

bool operator== ( const CrCirData rhs)

Definition at line 25 of file crcirdata.cpp.

25 {
26
27 if (name_ != rhs.name_ || currency_ != rhs.currency_ ||
28 calibrationType_ != rhs.calibrationType_ || calibrationStrategy_ != rhs.calibrationStrategy_ ||
29 startValue_ != rhs.startValue_ ||
30 reversionValue_ != rhs.reversionValue_ || longTermValue_ != rhs.longTermValue_ ||
31 volatility_ != rhs.volatility_ || relaxedFeller_ != rhs.relaxedFeller_ ||
32 fellerFactor_ != rhs.fellerFactor_ || tolerance_ != rhs.tolerance_ ||
33 optionExpiries_ != rhs.optionExpiries_ || optionTerms_ != rhs.optionTerms_ ||
34 optionStrikes_ != rhs.optionStrikes_) {
35 return false;
36 }
37 return true;
38}

◆ operator!=()

bool operator!= ( const CrCirData rhs)

Definition at line 40 of file crcirdata.cpp.

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

Member Data Documentation

◆ name_

std::string name_
private

Definition at line 92 of file crcirdata.hpp.

◆ currency_

std::string currency_
private

Definition at line 93 of file crcirdata.hpp.

◆ calibrationType_

CalibrationType calibrationType_
private

Definition at line 94 of file crcirdata.hpp.

◆ calibrationStrategy_

CalibrationStrategy calibrationStrategy_
private

Definition at line 95 of file crcirdata.hpp.

◆ startValue_

Real startValue_
private

Definition at line 96 of file crcirdata.hpp.

◆ reversionValue_

Real reversionValue_
private

Definition at line 96 of file crcirdata.hpp.

◆ longTermValue_

Real longTermValue_
private

Definition at line 96 of file crcirdata.hpp.

◆ volatility_

Real volatility_
private

Definition at line 96 of file crcirdata.hpp.

◆ relaxedFeller_

bool relaxedFeller_
private

Definition at line 97 of file crcirdata.hpp.

◆ fellerFactor_

Real fellerFactor_
private

Definition at line 98 of file crcirdata.hpp.

◆ tolerance_

Real tolerance_
private

Definition at line 99 of file crcirdata.hpp.

◆ optionExpiries_

std::vector<std::string> optionExpiries_
private

Definition at line 100 of file crcirdata.hpp.

◆ optionTerms_

std::vector<std::string> optionTerms_
private

Definition at line 101 of file crcirdata.hpp.

◆ optionStrikes_

std::vector<std::string> optionStrikes_
private

Definition at line 102 of file crcirdata.hpp.