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

Netting Set Manager. More...

#include <ored/portfolio/nettingsetmanager.hpp>

+ Inheritance diagram for NettingSetManager:
+ Collaboration diagram for NettingSetManager:

Public Member Functions

 NettingSetManager ()
 
void reset ()
 
const bool empty () const
 
const bool calculateIMAmount () const
 
const std::set< NettingSetDetailscalculateIMNettingSets () const
 
bool has (const string &id) const
 
bool has (const NettingSetDetails &nettingSetDetails) const
 
void add (const QuantLib::ext::shared_ptr< NettingSetDefinition > &nettingSet)
 
QuantLib::ext::shared_ptr< NettingSetDefinitionget (const string &id) const
 
QuantLib::ext::shared_ptr< NettingSetDefinitionget (const NettingSetDetails &nettingSetDetails) const
 
vector< NettingSetDetailsuniqueKeys () const
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (XMLDocument &doc) const override
 
const std::map< NettingSetDetails, const QuantLib::ext::shared_ptr< NettingSetDefinition > > & nettingSetDefinitions ()
 
- 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

map< NettingSetDetails, const QuantLib::ext::shared_ptr< NettingSetDefinition > > data_
 
vector< NettingSetDetailsuniqueKeys_
 

Detailed Description

Netting Set Manager.

This class is a manager to store netting set definitions

Definition at line 42 of file nettingsetmanager.hpp.

Constructor & Destructor Documentation

◆ NettingSetManager()

default constructor

Definition at line 47 of file nettingsetmanager.hpp.

47{}

Member Function Documentation

◆ reset()

void reset ( )

clears the manager of all data

Definition at line 49 of file nettingsetmanager.cpp.

49 {
50 data_.clear();
51 uniqueKeys_.clear();
52}
vector< NettingSetDetails > uniqueKeys_
map< NettingSetDetails, const QuantLib::ext::shared_ptr< NettingSetDefinition > > data_

◆ empty()

const bool empty ( ) const

checks if the manager is empty

Definition at line 54 of file nettingsetmanager.cpp.

54 {
55 return data_.empty();
56}

◆ calculateIMAmount()

const bool calculateIMAmount ( ) const

checks if at least one of the netting set definitions has calculateIMAmount = true

Definition at line 58 of file nettingsetmanager.cpp.

58 {
59 for (const auto& nsd : data_) {
60 if (nsd.second->activeCsaFlag() && nsd.second->csaDetails()->calculateIMAmount())
61 return true;
62 }
63 return false;
64}

◆ calculateIMNettingSets()

const set< NettingSetDetails > calculateIMNettingSets ( ) const

returns the list of netting sets for which SIMM will be calculated as IM

Definition at line 66 of file nettingsetmanager.cpp.

66 {
67 set<NettingSetDetails> calculateIMNettingSets = set<NettingSetDetails>();
68 for (const auto& nsd : data_) {
69 if (nsd.second->activeCsaFlag() && nsd.second->csaDetails()->calculateIMAmount()) {
70 calculateIMNettingSets.insert(nsd.first);
71 }
72 }
74}
const std::set< NettingSetDetails > calculateIMNettingSets() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ has() [1/2]

bool has ( const string &  id) const

checks if object named id exists in manager

Definition at line 45 of file nettingsetmanager.cpp.

45 {
46 return has(NettingSetDetails(id));
47}
Serializable object holding netting set identification data.
bool has(const string &id) const
+ 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 41 of file nettingsetmanager.cpp.

41 {
42 return data_.find(nettingSetDetails) != data_.end();
43}

◆ add()

void add ( const QuantLib::ext::shared_ptr< NettingSetDefinition > &  nettingSet)

adds a new NettingSetDefinition object to manager

Definition at line 29 of file nettingsetmanager.cpp.

29 {
30 const NettingSetDetails& k = nettingSet->nettingSetDetails();
31
32 std::pair<NettingSetDetails, QuantLib::ext::shared_ptr<NettingSetDefinition>> newNetSetDef(k, nettingSet);
33
34 bool added = data_.insert(newNetSetDef).second;
35 if (added)
36 uniqueKeys_.push_back(k);
37
38 QL_REQUIRE(data_.size() == uniqueKeys_.size(), "NettingSetManager: vector/map size mismatch");
39}
+ Here is the caller graph for this function:

◆ get() [1/2]

QuantLib::ext::shared_ptr< NettingSetDefinition > get ( const string &  id) const

extracts a pointer to a NettingSetDefinition from manager

Definition at line 83 of file nettingsetmanager.cpp.

83 {
84 auto found = std::find_if(data_.begin(), data_.end(),
85 [&id](const auto& details) { return details.first.nettingSetId() == id; });
86 if (found != data_.end())
87 return found->second;
88 else
89 QL_FAIL("NettingSetDefinition not found in manager: " + id);
90}

◆ get() [2/2]

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

Definition at line 76 of file nettingsetmanager.cpp.

76 {
77 if (has(nettingSetDetails))
78 return data_.find(nettingSetDetails)->second;
79 else
80 QL_FAIL("NettingSetDefinition not found in manager: " << nettingSetDetails);
81}
+ Here is the call graph for this function:

◆ uniqueKeys()

vector< NettingSetDetails > uniqueKeys ( ) const

vector containing the ids of all objects stored in manager

Definition at line 93 of file nettingsetmanager.hpp.

93{ return uniqueKeys_; }

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 92 of file nettingsetmanager.cpp.

92 {
93 XMLUtils::checkNode(node, "NettingSetDefinitions");
94 vector<XMLNode*> nettingSetNodes = XMLUtils::getChildrenNodes(node, "NettingSet");
95 for (unsigned i = 0; i < nettingSetNodes.size(); i++) {
96 XMLNode* child = nettingSetNodes[i];
97 try {
98 QuantLib::ext::shared_ptr<NettingSetDefinition> nettingSet(new NettingSetDefinition(child));
99 add(nettingSet);
100 } catch (std::exception& ex) {
101 StructuredConfigurationWarningMessage("Netting set manager", "", "Failed to parse netting set definition",
102 ex.what())
103 .log();
104 }
105 }
106}
void add(const QuantLib::ext::shared_ptr< NettingSetDefinition > &nettingSet)
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
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 108 of file nettingsetmanager.cpp.

108 {
109 XMLNode* node = doc.allocNode("NettingSetDefinitions");
110 // map<NettingSetDetails, const QuantLib::ext::shared_ptr<NettingSetDefinition>>::iterator it;
111 for (auto it = data_.begin(); it != data_.end(); ++it)
112 XMLUtils::appendNode(node, it->second->toXML(doc));
113 return node;
114}
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
+ Here is the call graph for this function:

◆ nettingSetDefinitions()

const std::map< NettingSetDetails, const QuantLib::ext::shared_ptr< NettingSetDefinition > > & nettingSetDefinitions ( )

Definition at line 97 of file nettingsetmanager.hpp.

97{ return data_; }

Member Data Documentation

◆ data_

map<NettingSetDetails, const QuantLib::ext::shared_ptr<NettingSetDefinition> > data_
private

Definition at line 100 of file nettingsetmanager.hpp.

◆ uniqueKeys_

vector<NettingSetDetails> uniqueKeys_
private

Definition at line 101 of file nettingsetmanager.hpp.