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

Serializable CPI Leg Data. More...

#include <ored/portfolio/legdata.hpp>

+ Inheritance diagram for CPILegData:
+ Collaboration diagram for CPILegData:

Public Member Functions

 CPILegData ()
 Default constructor. More...
 
 CPILegData (string index, string startDate, double baseCPI, string observationLag, string interpolation, const vector< double > &rates, const vector< string > &rateDates=std::vector< string >(), bool subtractInflationNominal=true, const vector< double > &caps=vector< double >(), const vector< string > &capDates=vector< string >(), const vector< double > &floors=vector< double >(), const vector< string > &floorDates=vector< string >(), double finalFlowCap=Null< Real >(), double finalFlowFloor=Null< Real >(), bool nakedOption=false, bool subtractInflationNominalCoupons=false)
 Constructor. More...
 
Inspectors
const string & index () const
 
const string & startDate () const
 
double baseCPI () const
 
const string & observationLag () const
 
const string & interpolation () const
 
const std::vector< double > & rates () const
 
const std::vector< string > & rateDates () const
 
bool subtractInflationNominal () const
 
const vector< double > & caps () const
 
const vector< string > & capDates () const
 
const vector< double > & floors () const
 
const vector< string > & floorDates () const
 
double finalFlowCap () const
 
double finalFlowFloor () const
 
bool nakedOption () const
 
bool subtractInflationNominalCoupons () const
 
- Public Member Functions inherited from LegAdditionalData
 LegAdditionalData (const string &legType, const string &legNodeName)
 
 LegAdditionalData (const string &legType)
 
const string & legType () const
 
const string & legNodeName () const
 
const std::set< std::string > & indices () 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...
 

Serialisation

string index_
 
string startDate_
 
double baseCPI_
 
string observationLag_
 
string interpolation_
 
vector< double > rates_
 
vector< string > rateDates_
 
bool subtractInflationNominal_
 
vector< double > caps_
 
vector< string > capDates_
 
vector< double > floors_
 
vector< string > floorDates_
 
double finalFlowCap_
 
double finalFlowFloor_
 
bool nakedOption_
 
bool subtractInflationNominalCoupons_
 
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (XMLDocument &doc) const override
 

Additional Inherited Members

- Protected Attributes inherited from LegAdditionalData
std::set< std::string > indices_
 

Detailed Description

Serializable CPI Leg Data.

Definition at line 281 of file legdata.hpp.

Constructor & Destructor Documentation

◆ CPILegData() [1/2]

Default constructor.

Definition at line 284 of file legdata.hpp.

284: LegAdditionalData("CPI") {}
LegAdditionalData(const string &legType, const string &legNodeName)
Definition: legdata.hpp:65

◆ CPILegData() [2/2]

CPILegData ( string  index,
string  startDate,
double  baseCPI,
string  observationLag,
string  interpolation,
const vector< double > &  rates,
const vector< string > &  rateDates = std::vector<string>(),
bool  subtractInflationNominal = true,
const vector< double > &  caps = vector<double>(),
const vector< string > &  capDates = vector<string>(),
const vector< double > &  floors = vector<double>(),
const vector< string > &  floorDates = vector<string>(),
double  finalFlowCap = Null<Real>(),
double  finalFlowFloor = Null<Real>(),
bool  nakedOption = false,
bool  subtractInflationNominalCoupons = false 
)

Constructor.

Definition at line 286 of file legdata.hpp.

298 indices_.insert(index_);
299 }
const vector< double > & floors() const
Definition: legdata.hpp:313
const string & observationLag() const
Definition: legdata.hpp:306
bool nakedOption() const
Definition: legdata.hpp:317
double finalFlowCap() const
Definition: legdata.hpp:315
const string & interpolation() const
Definition: legdata.hpp:307
const string & startDate() const
Definition: legdata.hpp:304
const std::vector< double > & rates() const
Definition: legdata.hpp:308
const string & index() const
Definition: legdata.hpp:303
vector< double > floors_
Definition: legdata.hpp:337
vector< string > floorDates_
Definition: legdata.hpp:338
const std::vector< string > & rateDates() const
Definition: legdata.hpp:309
vector< string > rateDates_
Definition: legdata.hpp:333
const vector< double > & caps() const
Definition: legdata.hpp:311
bool subtractInflationNominalCoupons_
Definition: legdata.hpp:342
const vector< string > & floorDates() const
Definition: legdata.hpp:314
double baseCPI() const
Definition: legdata.hpp:305
const vector< string > & capDates() const
Definition: legdata.hpp:312
vector< string > capDates_
Definition: legdata.hpp:336
bool subtractInflationNominal() const
Definition: legdata.hpp:310
vector< double > caps_
Definition: legdata.hpp:335
vector< double > rates_
Definition: legdata.hpp:332
bool subtractInflationNominal_
Definition: legdata.hpp:334
double finalFlowFloor() const
Definition: legdata.hpp:316
bool subtractInflationNominalCoupons() const
Definition: legdata.hpp:318
std::set< std::string > indices_
Definition: legdata.hpp:77

Member Function Documentation

◆ index()

const string & index ( ) const

Definition at line 303 of file legdata.hpp.

303{ return index_; }

◆ startDate()

const string & startDate ( ) const

Definition at line 304 of file legdata.hpp.

304{ return startDate_; }

◆ baseCPI()

double baseCPI ( ) const

Definition at line 305 of file legdata.hpp.

305{ return baseCPI_; }

◆ observationLag()

const string & observationLag ( ) const

Definition at line 306 of file legdata.hpp.

306{ return observationLag_; }

◆ interpolation()

const string & interpolation ( ) const

Definition at line 307 of file legdata.hpp.

307{ return interpolation_; }

◆ rates()

const std::vector< double > & rates ( ) const

Definition at line 308 of file legdata.hpp.

308{ return rates_; }

◆ rateDates()

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

Definition at line 309 of file legdata.hpp.

309{ return rateDates_; }

◆ subtractInflationNominal()

bool subtractInflationNominal ( ) const

Definition at line 310 of file legdata.hpp.

◆ caps()

const vector< double > & caps ( ) const

Definition at line 311 of file legdata.hpp.

311{ return caps_; }

◆ capDates()

const vector< string > & capDates ( ) const

Definition at line 312 of file legdata.hpp.

312{ return capDates_; }

◆ floors()

const vector< double > & floors ( ) const

Definition at line 313 of file legdata.hpp.

313{ return floors_; }

◆ floorDates()

const vector< string > & floorDates ( ) const

Definition at line 314 of file legdata.hpp.

314{ return floorDates_; }

◆ finalFlowCap()

double finalFlowCap ( ) const

Definition at line 315 of file legdata.hpp.

315{ return finalFlowCap_; }

◆ finalFlowFloor()

double finalFlowFloor ( ) const

Definition at line 316 of file legdata.hpp.

316{ return finalFlowFloor_; }

◆ nakedOption()

bool nakedOption ( ) const

Definition at line 317 of file legdata.hpp.

317{ return nakedOption_; }

◆ subtractInflationNominalCoupons()

bool subtractInflationNominalCoupons ( ) const

Definition at line 318 of file legdata.hpp.

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 262 of file legdata.cpp.

262 {
264 index_ = XMLUtils::getChildValue(node, "Index", true);
265 startDate_ = XMLUtils::getChildValue(node, "StartDate", false);
266 indices_.insert(index_);
267 baseCPI_ = XMLUtils::getChildValueAsDouble(node, "BaseCPI", false, QuantLib::Null<QuantLib::Real>());
268 observationLag_ = XMLUtils::getChildValue(node, "ObservationLag", false, "");
269 // for backwards compatibility only
270 if (auto c = XMLUtils::getChildNode(node, "Interpolated")) {
271 QL_REQUIRE(XMLUtils::getChildNode(node, "Interpolation") == nullptr,
272 "can not have both Interpolated and Interpolation node in CPILegData");
273 interpolation_ = parseBool(XMLUtils::getNodeValue(c)) ? "Linear" : "Flat";
274 } else {
275 interpolation_ = XMLUtils::getChildValue(node, "Interpolation", false, "");
276 }
277 XMLNode* subNomNode = XMLUtils::getChildNode(node, "SubtractInflationNotional");
278 if (subNomNode)
279 subtractInflationNominal_ = XMLUtils::getChildValueAsBool(node, "SubtractInflationNotional", true);
280 else
282
283 XMLNode* subNomCpnsNode = XMLUtils::getChildNode(node, "SubtractInflationNotionalAllCoupons");
284 if (subNomCpnsNode)
286 XMLUtils::getChildValueAsBool(node, "SubtractInflationNotionalAllCoupons", true);
287 else
289
290 rates_ = XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Rates", "Rate", "startDate", rateDates_, &parseReal,
291 true);
292 caps_ = XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Caps", "Cap", "startDate", capDates_, &parseReal);
293 floors_ =
294 XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Floors", "Floor", "startDate", floorDates_, &parseReal);
295
296 finalFlowCap_ = Null<Real>();
297 if (auto n = XMLUtils::getChildNode(node, "FinalFlowCap")) {
298 string v = XMLUtils::getNodeValue(n);
299 if (!v.empty())
301 }
302
303 finalFlowFloor_ = Null<Real>();
304 if (auto n = XMLUtils::getChildNode(node, "FinalFlowFloor")) {
305 string v = XMLUtils::getNodeValue(n);
306 if (!v.empty())
308 }
309
310 if (XMLUtils::getChildNode(node, "NakedOption"))
311 nakedOption_ = XMLUtils::getChildValueAsBool(node, "NakedOption", false);
312 else
313 nakedOption_ = false;
314}
const string & legNodeName() const
Definition: legdata.hpp:70
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
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 string getNodeValue(XMLNode *node)
Get a node's value.
Definition: xmlutils.cpp:489
bool parseBool(const string &s)
Convert text to bool.
Definition: parsers.cpp:144
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 316 of file legdata.cpp.

316 {
317 XMLNode* node = doc.allocNode(legNodeName());
318 XMLUtils::addChild(doc, node, "Index", index_);
319 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Rates", "Rate", rates_, "startDate", rateDates_);
320 if (baseCPI_ != Null<Real>()) {
321 XMLUtils::addChild(doc, node, "BaseCPI", baseCPI_);
322 }
323 XMLUtils::addChild(doc, node, "StartDate", startDate_);
324 if (!observationLag_.empty()) {
325 XMLUtils::addChild(doc, node, "ObservationLag", observationLag_);
326 }
327 if (!interpolation_.empty()) {
328 XMLUtils::addChild(doc, node, "Interpolation", interpolation_);
329 }
330 XMLUtils::addChild(doc, node, "SubtractInflationNotional", subtractInflationNominal_);
331 XMLUtils::addChild(doc, node, "SubtractInflationNotionalAllCoupons", subtractInflationNominalCoupons_);
332 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Caps", "Cap", caps_, "startDate", capDates_);
333 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Floors", "Floor", floors_, "startDate", floorDates_);
334 if (finalFlowCap_ != Null<Real>())
335 XMLUtils::addChild(doc, node, "FinalFlowCap", finalFlowCap_);
336 if (finalFlowFloor_ != Null<Real>())
337 XMLUtils::addChild(doc, node, "FinalFlowFloor", finalFlowFloor_);
338 XMLUtils::addChild(doc, node, "NakedOption", nakedOption_);
339 return node;
340}
static void addChildrenWithOptionalAttributes(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values, const string &attrName, const vector< string > &attrs)
Definition: xmlutils.cpp:542
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
+ Here is the call graph for this function:

Member Data Documentation

◆ index_

string index_
private

Definition at line 327 of file legdata.hpp.

◆ startDate_

string startDate_
private

Definition at line 328 of file legdata.hpp.

◆ baseCPI_

double baseCPI_
private

Definition at line 329 of file legdata.hpp.

◆ observationLag_

string observationLag_
private

Definition at line 330 of file legdata.hpp.

◆ interpolation_

string interpolation_
private

Definition at line 331 of file legdata.hpp.

◆ rates_

vector<double> rates_
private

Definition at line 332 of file legdata.hpp.

◆ rateDates_

vector<string> rateDates_
private

Definition at line 333 of file legdata.hpp.

◆ subtractInflationNominal_

bool subtractInflationNominal_
private

Definition at line 334 of file legdata.hpp.

◆ caps_

vector<double> caps_
private

Definition at line 335 of file legdata.hpp.

◆ capDates_

vector<string> capDates_
private

Definition at line 336 of file legdata.hpp.

◆ floors_

vector<double> floors_
private

Definition at line 337 of file legdata.hpp.

◆ floorDates_

vector<string> floorDates_
private

Definition at line 338 of file legdata.hpp.

◆ finalFlowCap_

double finalFlowCap_
private

Definition at line 339 of file legdata.hpp.

◆ finalFlowFloor_

double finalFlowFloor_
private

Definition at line 340 of file legdata.hpp.

◆ nakedOption_

bool nakedOption_
private

Definition at line 341 of file legdata.hpp.

◆ subtractInflationNominalCoupons_

bool subtractInflationNominalCoupons_
private

Definition at line 342 of file legdata.hpp.