23#include <ql/errors.hpp>
34 std::pair<NettingSetDetails, QuantLib::ext::shared_ptr<CollateralBalance>> newCollateralBalance(cb->nettingSetDetails(),
60 if (
has(nettingSetDetails))
63 QL_FAIL(
"CollateralBalance not found in manager: " << nettingSetDetails);
72 std::map<std::string, QuantLib::Real>& currentIM) {
74 if (cb.second->currency() == baseCurrency) {
75 currentIM[cb.first.nettingSetId()] = cb.second->initialMargin();
84 if (nettingSetDetailsNode) {
95 im_ = QuantLib::Null<QuantLib::Real>();
101 vm_ = QuantLib::Null<QuantLib::Real>();
119 if (
im_ != QuantLib::Null<QuantLib::Real>())
121 if (
vm_ != QuantLib::Null<QuantLib::Real>())
129 for (
unsigned i = 0; i < nettingSetNodes.size(); i++) {
131 QuantLib::ext::shared_ptr<CollateralBalance> cb(
new CollateralBalance(nettingSetNodes[i]));
133 }
catch (
const std::exception& ex) {
135 "Collateral balance node failed to parse", ex.what())
const std::string & currency() const
const std::string & nettingSetId() const
void fromXML(ore::data::XMLNode *node) override
std::string nettingSetId_
NettingSetDetails nettingSetDetails_
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
const QuantLib::Real & variationMargin() const
const QuantLib::Real & initialMargin() const
void add(const QuantLib::ext::shared_ptr< CollateralBalance > &cb)
bool has(const std::string &nettingSetId) const
void fromXML(ore::data::XMLNode *node) override
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
const std::map< NettingSetDetails, QuantLib::ext::shared_ptr< CollateralBalance > > & collateralBalances()
void currentIM(const std::string &baseCurrency, std::map< std::string, QuantLib::Real > ¤tIM)
std::map< NettingSetDetails, QuantLib::ext::shared_ptr< CollateralBalance > > collateralBalances_
const QuantLib::ext::shared_ptr< CollateralBalance > & get(const std::string &nettingSetId) const
void log() const
generate Boost log record to pass to corresponding sinks
Serializable object holding netting set identification data.
bool empty() const
Check if the netting set details have been populated.
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
Utility classes for Structured configuration errors, contains the configuration type and ID (NettingS...
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
static void checkNode(XMLNode *n, const string &expectedName)
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static string getNodeValue(XMLNode *node)
Get a node's value.
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
Holder class for collateral balances.
Real parseReal(const string &s)
Convert text to Real.
Classes and functions for log message handling.
#define DLOG(text)
Logging Macro (Level = Debug)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
Class for structured configuration errors.