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

Collateral Balances. More...

#include <ored/portfolio/collateralbalance.hpp>

+ Inheritance diagram for CollateralBalances:
+ Collaboration diagram for CollateralBalances:

Public Member Functions

 CollateralBalances ()
 
void reset ()
 
const bool empty ()
 
bool has (const std::string &nettingSetId) const
 
bool has (const NettingSetDetails &nettingSetDetails) const
 
void add (const QuantLib::ext::shared_ptr< CollateralBalance > &cb)
 
const QuantLib::ext::shared_ptr< CollateralBalance > & get (const std::string &nettingSetId) const
 
const QuantLib::ext::shared_ptr< CollateralBalance > & get (const NettingSetDetails &nettingSetDetails) const
 
void currentIM (const std::string &baseCurrency, std::map< std::string, QuantLib::Real > &currentIM)
 
void fromXML (ore::data::XMLNode *node) override
 
ore::data::XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
const std::map< NettingSetDetails, QuantLib::ext::shared_ptr< CollateralBalance > > & collateralBalances ()
 
- 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::map< NettingSetDetails, QuantLib::ext::shared_ptr< CollateralBalance > > collateralBalances_
 

Detailed Description

Collateral Balances.

This class hold collateral balances

Definition at line 85 of file collateralbalance.hpp.

Constructor & Destructor Documentation

◆ CollateralBalances()

default constructor

Definition at line 90 of file collateralbalance.hpp.

90{}

Member Function Documentation

◆ reset()

void reset ( )

clears the manager of all data

Definition at line 47 of file collateralbalance.cpp.

47 {
48 collateralBalances_.clear();
49}
std::map< NettingSetDetails, QuantLib::ext::shared_ptr< CollateralBalance > > collateralBalances_

◆ empty()

const bool empty ( )

checks if there are any collateral balance entries

Definition at line 51 of file collateralbalance.cpp.

51 {
52 return collateralBalances_.empty();
53}

◆ has() [1/2]

bool has ( const std::string &  nettingSetId) const

checks if object named nettingSetId exists in manager

Definition at line 43 of file collateralbalance.cpp.

43 {
44 return has(NettingSetDetails(nettingSetId));
45}
bool has(const std::string &nettingSetId) const
Serializable object holding netting set identification data.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ has() [2/2]

bool has ( const NettingSetDetails nettingSetDetails) const

checks if object with the given nettingSetDetails exists in manager

Definition at line 39 of file collateralbalance.cpp.

39 {
40 return collateralBalances_.find(nettingSetDetails) != collateralBalances_.end();
41}

◆ add()

void add ( const QuantLib::ext::shared_ptr< CollateralBalance > &  cb)

adds a new collateral balance to manager

Definition at line 33 of file collateralbalance.cpp.

33 {
34 std::pair<NettingSetDetails, QuantLib::ext::shared_ptr<CollateralBalance>> newCollateralBalance(cb->nettingSetDetails(),
35 cb);
36 collateralBalances_.insert(newCollateralBalance);
37}
+ Here is the caller graph for this function:

◆ get() [1/2]

const QuantLib::ext::shared_ptr< CollateralBalance > & get ( const std::string &  nettingSetId) const

extracts a collateral balance from manager

Definition at line 66 of file collateralbalance.cpp.

66 {
67 return get(NettingSetDetails(nettingSetId));
68}
const QuantLib::ext::shared_ptr< CollateralBalance > & get(const std::string &nettingSetId) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get() [2/2]

const QuantLib::ext::shared_ptr< CollateralBalance > & get ( const NettingSetDetails nettingSetDetails) const

Definition at line 59 of file collateralbalance.cpp.

59 {
60 if (has(nettingSetDetails))
61 return collateralBalances_.find(nettingSetDetails)->second;
62 else
63 QL_FAIL("CollateralBalance not found in manager: " << nettingSetDetails);
64}
+ Here is the call graph for this function:

◆ currentIM()

void currentIM ( const std::string &  baseCurrency,
std::map< std::string, QuantLib::Real > &  currentIM 
)

gets currentIM for DIM calculation

Definition at line 71 of file collateralbalance.cpp.

72 {
73 for (auto& cb : collateralBalances_) {
74 if (cb.second->currency() == baseCurrency) {
75 currentIM[cb.first.nettingSetId()] = cb.second->initialMargin();
76 }
77 }
78}
void currentIM(const std::string &baseCurrency, std::map< std::string, QuantLib::Real > &currentIM)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromXML()

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

Implements XMLSerializable.

Definition at line 126 of file collateralbalance.cpp.

126 {
127 XMLUtils::checkNode(node, "CollateralBalances");
128 std::vector<XMLNode*> nettingSetNodes = XMLUtils::getChildrenNodes(node, "CollateralBalance");
129 for (unsigned i = 0; i < nettingSetNodes.size(); i++) {
130 try {
131 QuantLib::ext::shared_ptr<CollateralBalance> cb(new CollateralBalance(nettingSetNodes[i]));
132 add(cb);
133 } catch (const std::exception& ex) {
134 ore::data::StructuredConfigurationErrorMessage("Collateral balances", "",
135 "Collateral balance node failed to parse", ex.what())
136 .log();
137 }
138 }
139}
void add(const QuantLib::ext::shared_ptr< CollateralBalance > &cb)
void log() const
generate Boost log record to pass to corresponding sinks
Definition: log.cpp:491
Utility classes for Structured configuration errors, contains the configuration type and ID (NettingS...
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
Definition: xmlutils.cpp:428
+ Here is the call graph for this function:

◆ toXML()

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

Implements XMLSerializable.

Definition at line 141 of file collateralbalance.cpp.

141 {
142 XMLNode* node = doc.allocNode("CollateralBalances");
143 for (auto it = collateralBalances_.begin(); it != collateralBalances_.end(); ++it) {
144 XMLUtils::appendNode(node, it->second->toXML(doc));
145 }
146 return node;
147}
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:

◆ collateralBalances()

const std::map< NettingSetDetails, QuantLib::ext::shared_ptr< CollateralBalance > > & collateralBalances ( )

Definition at line 149 of file collateralbalance.cpp.

149 {
150 return collateralBalances_;
151}

Member Data Documentation

◆ collateralBalances_

std::map<NettingSetDetails, QuantLib::ext::shared_ptr<CollateralBalance> > collateralBalances_
private

Definition at line 133 of file collateralbalance.hpp.