Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
collateralbalance.hpp
Go to the documentation of this file.
1 /*
2 Copyright (C) 2020 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7 ORE is free software: you can redistribute it and/or modify it
8 under the terms of the Modified BSD License. You should have received a
9 copy of the license along with this program.
10
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file ored/portfolio/collateralbalance.hpp
20 \brief Holder class for collateral balances
21 \ingroup tradedata
22*/
23
24#pragma once
25
28#include <ql/utilities/null.hpp>
29#include <ql/shared_ptr.hpp>
30
32
33namespace ore {
34namespace data {
35
37public:
38 /*!
39 default constructor
40 */
43 im_(QuantLib::Null<QuantLib::Real>()), vm_(QuantLib::Null<QuantLib::Real>()) {}
44
46
47 CollateralBalance(const std::string& nettingSetId, const std::string& currency,
48 const QuantLib::Real& im, const QuantLib::Real& vm = QuantLib::Null<QuantLib::Real>())
50 im_(im), vm_(vm) {}
51
53 const QuantLib::Real& im, const QuantLib::Real& vm = QuantLib::Null<QuantLib::Real>())
55
56 void fromXML(ore::data::XMLNode* node) override;
58
59 // Getters
60 const std::string& nettingSetId() const {
62 }
64 const std::string& currency() const { return currency_; }
65 const QuantLib::Real& initialMargin() const { return im_; }
66 const QuantLib::Real& variationMargin() const { return vm_; }
67
68 // Setters
69 QuantLib::Real& initialMargin() { return im_; }
70 QuantLib::Real& variationMargin() { return vm_; }
71
72private:
73 std::string nettingSetId_;
75 std::string currency_;
76 QuantLib::Real im_, vm_;
77
78};
79//! Collateral Balances
80/*!
81 This class hold collateral balances
82
83 \ingroup tradedata
84*/
86public:
87 /*!
88 default constructor
89 */
91
92 /*!
93 clears the manager of all data
94 */
95 void reset();
96
97 /*!
98 checks if there are any collateral balance entries
99 */
100 const bool empty();
101
102 /*!
103 checks if object named nettingSetId exists in manager
104 */
105 bool has(const std::string& nettingSetId) const;
106
107 /*!
108 checks if object with the given nettingSetDetails exists in manager
109 */
110 bool has(const NettingSetDetails& nettingSetDetails) const;
111
112 /*!
113 adds a new collateral balance to manager
114 */
115 void add(const QuantLib::ext::shared_ptr<CollateralBalance>& cb);
116
117 /*!
118 extracts a collateral balance from manager
119 */
120 const QuantLib::ext::shared_ptr<CollateralBalance>& get(const std::string& nettingSetId) const;
121 const QuantLib::ext::shared_ptr<CollateralBalance>& get(const NettingSetDetails& nettingSetDetails) const;
122
123 /*!
124 gets currentIM for DIM calculation
125 */
126 void currentIM(const std::string& baseCurrency, std::map<std::string, QuantLib::Real>& currentIM);
127
128 void fromXML(ore::data::XMLNode* node) override;
129 ore::data::XMLNode* toXML(ore::data::XMLDocument& doc) const override;
130 const std::map<NettingSetDetails, QuantLib::ext::shared_ptr<CollateralBalance>>& collateralBalances();
131
132private:
133 std::map<NettingSetDetails, QuantLib::ext::shared_ptr<CollateralBalance>> collateralBalances_;
134};
135
136} // namespace data
137} // namespace ore
const std::string & currency() const
CollateralBalance(const std::string &nettingSetId, const std::string &currency, const QuantLib::Real &im, const QuantLib::Real &vm=QuantLib::Null< QuantLib::Real >())
const std::string & nettingSetId() const
const NettingSetDetails nettingSetDetails() const
void fromXML(ore::data::XMLNode *node) override
NettingSetDetails nettingSetDetails_
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
QuantLib::Real & variationMargin()
CollateralBalance(const NettingSetDetails &nettingSetDetails, const std::string &currency, const QuantLib::Real &im, const QuantLib::Real &vm=QuantLib::Null< QuantLib::Real >())
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 > &currentIM)
std::map< NettingSetDetails, QuantLib::ext::shared_ptr< CollateralBalance > > collateralBalances_
const QuantLib::ext::shared_ptr< CollateralBalance > & get(const std::string &nettingSetId) const
Serializable object holding netting set identification data.
bool empty() const
Check if the netting set details have been populated.
const string & nettingSetId() const
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
Base class for all serializable classes.
Definition: xmlutils.hpp:101
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
netting set details data model and serialization
XML utility functions.