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

#include <ored/portfolio/collateralbalance.hpp>

+ Inheritance diagram for CollateralBalance:
+ Collaboration diagram for CollateralBalance:

Public Member Functions

 CollateralBalance ()
 
 CollateralBalance (ore::data::XMLNode *node)
 
 CollateralBalance (const std::string &nettingSetId, const std::string &currency, const QuantLib::Real &im, const QuantLib::Real &vm=QuantLib::Null< QuantLib::Real >())
 
 CollateralBalance (const NettingSetDetails &nettingSetDetails, const std::string &currency, const QuantLib::Real &im, const QuantLib::Real &vm=QuantLib::Null< QuantLib::Real >())
 
void fromXML (ore::data::XMLNode *node) override
 
ore::data::XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
const std::string & nettingSetId () const
 
const NettingSetDetails nettingSetDetails () const
 
const std::string & currency () const
 
const QuantLib::Real & initialMargin () const
 
const QuantLib::Real & variationMargin () const
 
QuantLib::Real & initialMargin ()
 
QuantLib::Real & variationMargin ()
 
- 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...
 

Private Attributes

std::string nettingSetId_
 
NettingSetDetails nettingSetDetails_
 
std::string currency_
 
QuantLib::Real im_
 
QuantLib::Real vm_
 

Detailed Description

Definition at line 36 of file collateralbalance.hpp.

Constructor & Destructor Documentation

◆ CollateralBalance() [1/4]

default constructor

Definition at line 41 of file collateralbalance.hpp.

43 im_(QuantLib::Null<QuantLib::Real>()), vm_(QuantLib::Null<QuantLib::Real>()) {}
NettingSetDetails nettingSetDetails_
Serializable object holding netting set identification data.

◆ CollateralBalance() [2/4]

Definition at line 55 of file collateralbalance.cpp.

55 {
56 fromXML(node);
57}
void fromXML(ore::data::XMLNode *node) override
+ Here is the call graph for this function:

◆ CollateralBalance() [3/4]

CollateralBalance ( const std::string &  nettingSetId,
const std::string &  currency,
const QuantLib::Real &  im,
const QuantLib::Real &  vm = QuantLib::Null<QuantLib::Real>() 
)

Definition at line 47 of file collateralbalance.hpp.

◆ CollateralBalance() [4/4]

CollateralBalance ( const NettingSetDetails nettingSetDetails,
const std::string &  currency,
const QuantLib::Real &  im,
const QuantLib::Real &  vm = QuantLib::Null<QuantLib::Real>() 
)

Definition at line 52 of file collateralbalance.hpp.

const NettingSetDetails nettingSetDetails() const

Member Function Documentation

◆ fromXML()

void fromXML ( ore::data::XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 80 of file collateralbalance.cpp.

80 {
81 XMLUtils::checkNode(node, "CollateralBalance");
82
83 XMLNode* nettingSetDetailsNode = XMLUtils::getChildNode(node, "NettingSetDetails");
84 if (nettingSetDetailsNode) {
85 nettingSetDetails_.fromXML(nettingSetDetailsNode);
86 } else {
87 nettingSetId_ = XMLUtils::getChildValue(node, "NettingSetId", false);
89 }
90
91 currency_ = XMLUtils::getChildValue(node, "Currency", true);
92
93 XMLNode* initialMarginNode = XMLUtils::getChildNode(node, "InitialMargin");
94 if (!initialMarginNode || (initialMarginNode && XMLUtils::getNodeValue(initialMarginNode).empty()))
95 im_ = QuantLib::Null<QuantLib::Real>();
96 else
97 im_ = parseReal(XMLUtils::getNodeValue(initialMarginNode));
98
99 XMLNode* variationMarginNode = XMLUtils::getChildNode(node, "VariationMargin");
100 if (!variationMarginNode || (variationMarginNode && XMLUtils::getNodeValue(variationMarginNode).empty()))
101 vm_ = QuantLib::Null<QuantLib::Real>();
102 else
103 vm_ = parseReal(XMLUtils::getNodeValue(variationMarginNode));
104
105 DLOG("Loaded collateral balances for netting set " << nettingSetId());
106 DLOG("Currency: " << currency());
107 DLOG("Variation Margin: " << variationMargin());
108 DLOG("Initial Margin: " << initialMargin());
109}
const QuantLib::Real & variationMargin() const
const QuantLib::Real & initialMargin() const
virtual void fromXML(XMLNode *node) override
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
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
static string getNodeValue(XMLNode *node)
Get a node's value.
Definition: xmlutils.cpp:489
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

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

Implements XMLSerializable.

Definition at line 111 of file collateralbalance.cpp.

111 {
112 XMLNode* node = doc.allocNode("CollateralBalance");
113 XMLUtils::addChild(doc, node, "Currency", currency_);
115 XMLUtils::addChild(doc, node, "NettingSetId", nettingSetId_);
116 } else {
118 }
119 if (im_ != QuantLib::Null<QuantLib::Real>())
120 XMLUtils::addChild(doc, node, "InitialMargin", std::round(im_));
121 if (vm_ != QuantLib::Null<QuantLib::Real>())
122 XMLUtils::addChild(doc, node, "VariationMargin", std::round(vm_));
123 return node;
124}
bool empty() const
Check if the netting set details have been populated.
virtual XMLNode * toXML(XMLDocument &doc) const override
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:

◆ nettingSetId()

const std::string & nettingSetId ( ) const

Definition at line 60 of file collateralbalance.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nettingSetDetails()

const NettingSetDetails nettingSetDetails ( ) const

Definition at line 63 of file collateralbalance.hpp.

63{ return nettingSetDetails_; }

◆ currency()

const std::string & currency ( ) const

Definition at line 64 of file collateralbalance.hpp.

64{ return currency_; }
+ Here is the caller graph for this function:

◆ initialMargin() [1/2]

const QuantLib::Real & initialMargin ( ) const

Definition at line 65 of file collateralbalance.hpp.

65{ return im_; }
+ Here is the caller graph for this function:

◆ variationMargin() [1/2]

const QuantLib::Real & variationMargin ( ) const

Definition at line 66 of file collateralbalance.hpp.

66{ return vm_; }
+ Here is the caller graph for this function:

◆ initialMargin() [2/2]

QuantLib::Real & initialMargin ( )

Definition at line 69 of file collateralbalance.hpp.

69{ return im_; }

◆ variationMargin() [2/2]

QuantLib::Real & variationMargin ( )

Definition at line 70 of file collateralbalance.hpp.

70{ return vm_; }

Member Data Documentation

◆ nettingSetId_

std::string nettingSetId_
private

Definition at line 73 of file collateralbalance.hpp.

◆ nettingSetDetails_

NettingSetDetails nettingSetDetails_
private

Definition at line 74 of file collateralbalance.hpp.

◆ currency_

std::string currency_
private

Definition at line 75 of file collateralbalance.hpp.

◆ im_

QuantLib::Real im_
private

Definition at line 76 of file collateralbalance.hpp.

◆ vm_

QuantLib::Real vm_
private

Definition at line 76 of file collateralbalance.hpp.