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

Serializable Bond-Basket Data. More...

#include <ored/portfolio/tranche.hpp>

+ Inheritance diagram for TrancheData:
+ Collaboration diagram for TrancheData:

Public Member Functions

 TrancheData ()
 Default constructor. More...
 
 TrancheData (const std::string &name, double icRatio, double ocRatio, const QuantLib::ext::shared_ptr< LegAdditionalData > &concreteLegData)
 
Inspectors
const std::string name () const
 
double faceAmount ()
 
double icRatio ()
 
double ocRatio ()
 
const QuantLib::ext::shared_ptr< LegAdditionalDataconcreteLegData ()
 
- 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

std::string name_
 
double faceAmount_
 
double icRatio_
 
double ocRatio_
 
QuantLib::ext::shared_ptr< LegAdditionalDataconcreteLegData_
 
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (ore::data::XMLDocument &doc) const override
 

Detailed Description

Serializable Bond-Basket Data.

Definition at line 40 of file tranche.hpp.

Constructor & Destructor Documentation

◆ TrancheData() [1/2]

Default constructor.

Definition at line 43 of file tranche.hpp.

43{}

◆ TrancheData() [2/2]

TrancheData ( const std::string &  name,
double  icRatio,
double  ocRatio,
const QuantLib::ext::shared_ptr< LegAdditionalData > &  concreteLegData 
)

Definition at line 45 of file tranche.hpp.

std::string name_
Definition: tranche.hpp:64
const QuantLib::ext::shared_ptr< LegAdditionalData > concreteLegData()
Definition: tranche.hpp:54
QuantLib::ext::shared_ptr< LegAdditionalData > concreteLegData_
Definition: tranche.hpp:68
const std::string name() const
Definition: tranche.hpp:50

Member Function Documentation

◆ name()

const std::string name ( ) const

Definition at line 50 of file tranche.hpp.

50{ return name_; }

◆ faceAmount()

double faceAmount ( )

Definition at line 51 of file tranche.hpp.

51{ return faceAmount_; }

◆ icRatio()

double icRatio ( )

Definition at line 52 of file tranche.hpp.

52{ return icRatio_; }

◆ ocRatio()

double ocRatio ( )

Definition at line 53 of file tranche.hpp.

53{ return ocRatio_; }

◆ concreteLegData()

const QuantLib::ext::shared_ptr< LegAdditionalData > concreteLegData ( )

Definition at line 54 of file tranche.hpp.

54{return concreteLegData_; }

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 28 of file tranche.cpp.

28 {
29
30 XMLUtils::checkNode(node, "Tranche");
31
32 QL_REQUIRE(node, "No Tranche Node");
33
34 name_ = XMLUtils::getChildValue(node, "Name", true);
35 faceAmount_ = XMLUtils::getChildValueAsDouble(node, "Notional", true);
36 icRatio_ = XMLUtils::getChildValueAsDouble(node, "ICRatio", false, -1.0);
37 ocRatio_ = XMLUtils::getChildValueAsDouble(node, "OCRatio", false, -1.0);
38
39 //FloatingLegData
40 XMLNode* floater = XMLUtils::getChildNode(node, "FloatingLegData");
41 if(floater){
42 //Floating
43 concreteLegData_ = LegDataFactory::instance().build("Floating");
44 concreteLegData_->fromXML(XMLUtils::getChildNode(node, concreteLegData_->legNodeName()));
45 }
46
47 //FixedLegData
48 XMLNode* fixed = XMLUtils::getChildNode(node, "FixedLegData");
49 if(fixed){
50 //Fixed
51 concreteLegData_ = LegDataFactory::instance().build("Fixed");
52 concreteLegData_->fromXML(XMLUtils::getChildNode(node, concreteLegData_->legNodeName()));
53 }
54
55}
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 XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( ore::data::XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 58 of file tranche.cpp.

58 {
59
60 XMLNode* node = doc.allocNode("Tranche");
61
62 XMLUtils::addChild(doc, node, "Name", name_);
63 XMLUtils::addChild(doc, node, "Notional", faceAmount_);
64 XMLUtils::addChild(doc, node, "ICRatio", icRatio_);
65 XMLUtils::addChild(doc, node, "OCRatio", ocRatio_);
66 XMLUtils::appendNode(node, concreteLegData_->toXML(doc));
67
68 return node;
69}
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
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
+ Here is the call graph for this function:

Member Data Documentation

◆ name_

std::string name_
private

Definition at line 64 of file tranche.hpp.

◆ faceAmount_

double faceAmount_
private

Definition at line 65 of file tranche.hpp.

◆ icRatio_

double icRatio_
private

Definition at line 66 of file tranche.hpp.

◆ ocRatio_

double ocRatio_
private

Definition at line 67 of file tranche.hpp.

◆ concreteLegData_

QuantLib::ext::shared_ptr<LegAdditionalData> concreteLegData_
private

Definition at line 68 of file tranche.hpp.