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

Netting Set Definition. More...

#include <ored/portfolio/nettingsetdefinition.hpp>

+ Inheritance diagram for NettingSetDefinition:
+ Collaboration diagram for NettingSetDefinition:

Public Member Functions

 NettingSetDefinition (XMLNode *node)
 
 NettingSetDefinition (const NettingSetDetails &nettingSetDetails)
 
 NettingSetDefinition (const string &nettingSetId)
 
 NettingSetDefinition (const NettingSetDetails &nettingSetDetails, const string &bilateral, const string &csaCurrency, const string &index, const Real &thresholdPay, const Real &thresholdRcv, const Real &mtaPay, const Real &mtaRcv, const Real &iaHeld, const string &iaType, const string &marginCallFreq, const string &marginPostFreq, const string &mpr, const Real &collatSpreadPay, const Real &collatSpreadRcv, const vector< string > &eligCollatCcys, bool applyInitialMargin=false, const string &initialMarginType="Bilateral", const bool calculateIMAmount=false, const bool calculateVMAmount=false, const string &nonExemptIMRegulations="")
 
 NettingSetDefinition (const string &nettingSetId, const string &bilateral, const string &csaCurrency, const string &index, const Real &thresholdPay, const Real &thresholdRcv, const Real &mtaPay, const Real &mtaRcv, const Real &iaHeld, const string &iaType, const string &marginCallFreq, const string &marginPostFreq, const string &mpr, const Real &collatSpreadPay, const Real &collatSpreadRcv, const vector< string > &eligCollatCcys, bool applyInitialMargin=false, const string &initialMarginType="Bilateral", const bool calculateIMAmount=false, const bool calculateVMAmount=false, const string &nonExemptIMRegulations="")
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (XMLDocument &doc) const override
 
void validate ()
 
const string & nettingSetId () const
 Inspectors. More...
 
const NettingSetDetails nettingSetDetails () const
 
bool activeCsaFlag () const
 
const QuantLib::ext::shared_ptr< CSA > & csaDetails ()
 
- 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...
 

Detailed Description

Netting Set Definition.

This class is a container for a definition of a netting agreement (including CSA information)

Definition at line 146 of file nettingsetdefinition.hpp.

Constructor & Destructor Documentation

◆ NettingSetDefinition() [1/5]

builds a NettingSetDefinition from an XML input

Definition at line 109 of file nettingsetdefinition.cpp.

109 {
110 fromXML(node);
111 DLOG(nettingSetDetails_ << ": NettingSetDefinition built from XML... ");
112}
void fromXML(XMLNode *node) override
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
+ Here is the call graph for this function:

◆ NettingSetDefinition() [2/5]

NettingSetDefinition ( const NettingSetDetails nettingSetDetails)

Constructor for "uncollateralised" netting sets

Definition at line 114 of file nettingsetdefinition.cpp.

115 : nettingSetDetails_(nettingSetDetails), activeCsaFlag_(false) {
116 validate();
117 DLOG(nettingSetDetails_ << ": uncollateralised NettingSetDefinition built.");
118}
const NettingSetDetails nettingSetDetails() const
+ Here is the call graph for this function:

◆ NettingSetDefinition() [3/5]

NettingSetDefinition ( const string &  nettingSetId)

Definition at line 157 of file nettingsetdefinition.hpp.

const string & nettingSetId() const
Inspectors.
Serializable object holding netting set identification data.

◆ NettingSetDefinition() [4/5]

NettingSetDefinition ( const NettingSetDetails nettingSetDetails,
const string &  bilateral,
const string &  csaCurrency,
const string &  index,
const Real &  thresholdPay,
const Real &  thresholdRcv,
const Real &  mtaPay,
const Real &  mtaRcv,
const Real &  iaHeld,
const string &  iaType,
const string &  marginCallFreq,
const string &  marginPostFreq,
const string &  mpr,
const Real &  collatSpreadPay,
const Real &  collatSpreadRcv,
const vector< string > &  eligCollatCcys,
bool  applyInitialMargin = false,
const string &  initialMarginType = "Bilateral",
const bool  calculateIMAmount = false,
const bool  calculateVMAmount = false,
const string &  nonExemptIMRegulations = "" 
)

Constructor for "collateralised" netting sets

Definition at line 120 of file nettingsetdefinition.cpp.

129 : nettingSetDetails_(nettingSetDetails), activeCsaFlag_(true) {
130
131 csa_ = QuantLib::ext::make_shared<CSA>(
132 parseCsaType(bilateral), csaCurrency, index, thresholdPay, thresholdRcv, mtaPay, mtaRcv, iaHeld, iaType,
133 parsePeriod(marginCallFreq), parsePeriod(marginPostFreq), parsePeriod(mpr), collatSpreadPay, collatSpreadRcv,
134 eligCollatCcys, applyInitialMargin, parseCsaType(initialMarginType), calculateIMAmount, calculateVMAmount,
135 nonExemptIMRegulations);
136
137 validate();
138 DLOG(nettingSetDetails_ << ": collateralised NettingSetDefinition built. ");
139}
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Definition: parsers.cpp:171
CSA::Type parseCsaType(const string &s)
+ Here is the call graph for this function:

◆ NettingSetDefinition() [5/5]

NettingSetDefinition ( const string &  nettingSetId,
const string &  bilateral,
const string &  csaCurrency,
const string &  index,
const Real &  thresholdPay,
const Real &  thresholdRcv,
const Real &  mtaPay,
const Real &  mtaRcv,
const Real &  iaHeld,
const string &  iaType,
const string &  marginCallFreq,
const string &  marginPostFreq,
const string &  mpr,
const Real &  collatSpreadPay,
const Real &  collatSpreadRcv,
const vector< string > &  eligCollatCcys,
bool  applyInitialMargin = false,
const string &  initialMarginType = "Bilateral",
const bool  calculateIMAmount = false,
const bool  calculateVMAmount = false,
const string &  nonExemptIMRegulations = "" 
)

Definition at line 176 of file nettingsetdefinition.hpp.

188 : NettingSetDefinition(NettingSetDetails(nettingSetId), bilateral, csaCurrency, index, thresholdPay,
189 thresholdRcv, mtaPay, mtaRcv, iaHeld, iaType, marginCallFreq, marginPostFreq, mpr,
190 collatSpreadPay, collatSpreadRcv, eligCollatCcys, applyInitialMargin, initialMarginType,
191 calculateIMAmount, calculateVMAmount, nonExemptIMRegulations) {}

Member Function Documentation

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

loads NettingSetDefinition object from XML

Implements XMLSerializable.

Definition at line 141 of file nettingsetdefinition.cpp.

141 {
142 XMLUtils::checkNode(node, "NettingSet");
143
144 // Read in the mandatory nodes.
145 XMLNode* nettingSetDetailsNode = XMLUtils::getChildNode(node, "NettingSetDetails");
146 if (nettingSetDetailsNode) {
147 nettingSetDetails_.fromXML(nettingSetDetailsNode);
148 } else {
149 nettingSetId_ = XMLUtils::getChildValue(node, "NettingSetId", false);
150 nettingSetDetails_ = NettingSetDetails(nettingSetId_);
151 }
152
153 activeCsaFlag_ = XMLUtils::getChildValueAsBool(node, "ActiveCSAFlag", false, true);
154
155 // Load "CSA" information, if necessary
156 if (activeCsaFlag_) {
157 XMLNode* csaChild = XMLUtils::getChildNode(node, "CSADetails");
158 XMLUtils::checkNode(csaChild, "CSADetails");
159
160 string csaTypeStr = XMLUtils::getChildValue(csaChild, "Bilateral", false);
161 if (csaTypeStr.empty())
162 csaTypeStr = "Bilateral";
163 string csaCurrency = XMLUtils::getChildValue(csaChild, "CSACurrency", false);
164 string index = XMLUtils::getChildValue(csaChild, "Index", false);
165 Real thresholdPay = XMLUtils::getChildValueAsDouble(csaChild, "ThresholdPay", false, 0.0);
166 Real thresholdRcv = XMLUtils::getChildValueAsDouble(csaChild, "ThresholdReceive", false, 0.0);
167 Real mtaPay = XMLUtils::getChildValueAsDouble(csaChild, "MinimumTransferAmountPay", false, 0.0);
168 Real mtaRcv = XMLUtils::getChildValueAsDouble(csaChild, "MinimumTransferAmountReceive", false, 0.0);
169 string mprStr = XMLUtils::getChildValue(csaChild, "MarginPeriodOfRisk", false);
170 if (mprStr.empty())
171 mprStr = "2W";
172 Real collatSpreadRcv =
173 XMLUtils::getChildValueAsDouble(csaChild, "CollateralCompoundingSpreadReceive", false, 0.0);
174 Real collatSpreadPay = XMLUtils::getChildValueAsDouble(csaChild, "CollateralCompoundingSpreadPay", false, 0.0);
175
176 string marginCallFreqStr, marginPostFreqStr;
177 if (XMLNode* freqChild = XMLUtils::getChildNode(csaChild, "MarginingFrequency")) {
178 marginCallFreqStr = XMLUtils::getChildValue(freqChild, "CallFrequency", false);
179 marginPostFreqStr = XMLUtils::getChildValue(freqChild, "PostFrequency", false);
180 }
181 if (marginCallFreqStr.empty())
182 marginCallFreqStr = "1D";
183 if (marginPostFreqStr.empty())
184 marginPostFreqStr = "1D";
185
186 Real iaHeld = 0.0;
187 string iaType;
188 if (XMLNode* iaChild = XMLUtils::getChildNode(csaChild, "IndependentAmount")) {
189 iaHeld = XMLUtils::getChildValueAsDouble(iaChild, "IndependentAmountHeld", false, 0.0);
190 iaType = XMLUtils::getChildValue(iaChild, "IndependentAmountType", false);
191 }
192 if (iaType.empty())
193 iaType = "FIXED";
194
195 vector<string> eligCollatCcys;
196 if (XMLNode* collatChild = XMLUtils::getChildNode(csaChild, "EligibleCollaterals")) {
197 eligCollatCcys = XMLUtils::getChildrenValues(collatChild, "Currencies", "Currency", false);
198 }
199
200 bool applyInitialMargin = XMLUtils::getChildValueAsBool(csaChild, "ApplyInitialMargin", false, false);
201
202 string initialMarginType = XMLUtils::getChildValue(csaChild, "InitialMarginType", false);
203 if (initialMarginType.empty())
204 initialMarginType = "Bilateral";
205
206 bool calculateIMAmount = XMLUtils::getChildValueAsBool(csaChild, "CalculateIMAmount", false, false);
207 bool calculateVMAmount = XMLUtils::getChildValueAsBool(csaChild, "CalculateVMAmount", false, false);
208
209 string nonExemptIMRegulations = XMLUtils::getChildValue(csaChild, "NonExemptIMRegulations", false);
210
211 csa_ = QuantLib::ext::make_shared<CSA>(parseCsaType(csaTypeStr), csaCurrency, index, thresholdPay, thresholdRcv, mtaPay,
212 mtaRcv, iaHeld, iaType, parsePeriod(marginCallFreqStr),
213 parsePeriod(marginPostFreqStr), parsePeriod(mprStr), collatSpreadPay,
214 collatSpreadRcv, eligCollatCcys, applyInitialMargin,
215 parseCsaType(initialMarginType), calculateIMAmount, calculateVMAmount,
216 nonExemptIMRegulations);
217 }
218
219 validate();
220}
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 bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
Definition: xmlutils.cpp:296
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static vector< string > getChildrenValues(XMLNode *node, const string &names, const string &name, bool mandatory=false)
Definition: xmlutils.cpp:306
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 ( XMLDocument doc) const
overridevirtual

writes object to XML

Implements XMLSerializable.

Definition at line 222 of file nettingsetdefinition.cpp.

222 {
223 // Allocate a node.
224 XMLNode* node = doc.allocNode("NettingSet");
225
226 // Add the mandatory members.
227 if (nettingSetDetails_.emptyOptionalFields()) {
228 XMLUtils::addChild(doc, node, "NettingSetId", nettingSetId_);
229 } else {
230 XMLUtils::appendNode(node, nettingSetDetails_.toXML(doc));
231 }
232 XMLUtils::addChild(doc, node, "ActiveCSAFlag", activeCsaFlag_);
233
234 XMLNode* csaSubNode = doc.allocNode("CSADetails");
235 XMLUtils::appendNode(node, csaSubNode);
236
237 if (activeCsaFlag_) {
238 QL_REQUIRE(csa_, "CSA details not defined");
239
240 XMLUtils::addChild(doc, csaSubNode, "Bilateral", to_string(csa_->type()));
241 XMLUtils::addChild(doc, csaSubNode, "CSACurrency", csa_->csaCurrency());
242 XMLUtils::addChild(doc, csaSubNode, "ThresholdPay", csa_->thresholdPay());
243 XMLUtils::addChild(doc, csaSubNode, "ThresholdReceive", csa_->thresholdRcv());
244 XMLUtils::addChild(doc, csaSubNode, "MinimumTransferAmountPay", csa_->mtaPay());
245 XMLUtils::addChild(doc, csaSubNode, "MinimumTransferAmountReceive", csa_->mtaRcv());
246 XMLUtils::addChild(doc, csaSubNode, "MarginPeriodOfRisk", to_string(csa_->marginPeriodOfRisk()));
247 XMLUtils::addChild(doc, csaSubNode, "CollateralCompoundingSpreadPay", csa_->collatSpreadPay());
248 XMLUtils::addChild(doc, csaSubNode, "CollateralCompoundingSpreadReceive", csa_->collatSpreadRcv());
249
250 XMLNode* freqSubNode = doc.allocNode("MarginingFrequency");
251 XMLUtils::appendNode(csaSubNode, freqSubNode);
252 XMLUtils::addChild(doc, freqSubNode, "CallFrequency", to_string(csa_->marginCallFrequency()));
253 XMLUtils::addChild(doc, freqSubNode, "PostFrequency", to_string(csa_->marginPostFrequency()));
254
255 XMLNode* iaSubNode = doc.allocNode("IndependentAmount");
256 XMLUtils::appendNode(csaSubNode, iaSubNode);
257 XMLUtils::addChild(doc, iaSubNode, "IndependentAmountHeld", csa_->independentAmountHeld());
258 XMLUtils::addChild(doc, iaSubNode, "IndependentAmountType", csa_->independentAmountType());
259
260 XMLNode* collatSubNode = doc.allocNode("EligibleCollaterals");
261 XMLUtils::appendNode(csaSubNode, collatSubNode);
262 XMLUtils::addChildren(doc, collatSubNode, "Currencies", "Currency", csa_->eligCollatCcys());
263
264 XMLUtils::addChild(doc, csaSubNode, "ApplyInitialMargin", csa_->applyInitialMargin());
265 XMLUtils::addChild(doc, csaSubNode, "InitialMarginType", to_string(csa_->initialMarginType()));
266 XMLUtils::addChild(doc, csaSubNode, "CalculateIMAmount", csa_->calculateIMAmount());
267 XMLUtils::addChild(doc, csaSubNode, "CalculateVMAmount", csa_->calculateVMAmount());
268 XMLUtils::addChild(doc, csaSubNode, "NonExemptIMRegulations", csa_->nonExemptIMRegulations());
269 }
270
271 return node;
272}
static void addChildren(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values)
Definition: xmlutils.cpp:502
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
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
+ Here is the call graph for this function:

◆ validate()

void validate ( )

validate the netting set definition including CSA details

Definition at line 274 of file nettingsetdefinition.cpp.

274 {
275 string nettingSetLog = nettingSetDetails_.empty() ? nettingSetId_ : ore::data::to_string(nettingSetDetails_);
276 LOG(nettingSetLog << ": Validating netting set definition");
277 QL_REQUIRE(nettingSetId_.size() > 0 || !nettingSetDetails_.empty(),
278 "NettingSetDefinition build error; no netting set ID or netting set details");
279
280 if (activeCsaFlag_) {
281 QL_REQUIRE(csa_, "CSA not defined yet");
282 string nettingSetLog = nettingSetDetails_.empty() ? nettingSetId_ : ore::data::to_string(nettingSetDetails_);
283 LOG(nettingSetLog << ": Validating netting set definition's CSA details");
284 csa_->validate();
285 }
286}
#define LOG(text)
Logging Macro (Level = Notice)
Definition: log.hpp:552
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nettingSetId()

const string & nettingSetId ( ) const

Inspectors.

returns netting set id

Definition at line 210 of file nettingsetdefinition.hpp.

210 {
211 return (nettingSetDetails_.empty() ? nettingSetId_ : nettingSetDetails_.nettingSetId());
212 }

◆ nettingSetDetails()

const NettingSetDetails nettingSetDetails ( ) const

returns netting set details

Definition at line 214 of file nettingsetdefinition.hpp.

214{ return nettingSetDetails_; }

◆ activeCsaFlag()

bool activeCsaFlag ( ) const

boolean specifying if ISDA agreement is covered by a Credit Support Annex

Definition at line 216 of file nettingsetdefinition.hpp.

216{ return activeCsaFlag_; }

◆ csaDetails()

const QuantLib::ext::shared_ptr< CSA > & csaDetails ( )

CSA details, if active

Definition at line 218 of file nettingsetdefinition.hpp.

218{ return csa_; }