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

#include <ored/portfolio/basketdata.hpp>

+ Inheritance diagram for BasketConstituent:
+ Collaboration diagram for BasketConstituent:

Public Member Functions

 BasketConstituent ()
 Default constructor. More...
 
 BasketConstituent (const std::string &issuerName, const std::string &creditCurveId, QuantLib::Real notional, const std::string &currency, const std::string &qualifier, QuantLib::Real priorNotional=QuantLib::Null< QuantLib::Real >(), QuantLib::Real recovery=QuantLib::Null< QuantLib::Real >(), const QuantLib::Date &auctionDate=QuantLib::Date(), const QuantLib::Date &auctionSettlementDate=QuantLib::Date(), const QuantLib::Date &defaultDate=QuantLib::Date(), const QuantLib::Date &eventDeterminationDate=QuantLib::Date())
 Constructor taking an explicit creditCurveId. More...
 
 BasketConstituent (const std::string &issuerName, const std::string &creditCurveId, QuantLib::Real weight, const std::string &qualifier, QuantLib::Real priorWeight=QuantLib::Null< QuantLib::Real >(), QuantLib::Real recovery=QuantLib::Null< QuantLib::Real >(), const QuantLib::Date &auctionDate=QuantLib::Date(), const QuantLib::Date &auctionSettlementDate=QuantLib::Date(), const QuantLib::Date &defaultDate=QuantLib::Date(), const QuantLib::Date &eventDeterminationDate=QuantLib::Date())
 Constructor taking an explicit creditCurveId and initialized by weight. More...
 
 BasketConstituent (const std::string &issuerName, const ore::data::CdsReferenceInformation &cdsReferenceInfo, QuantLib::Real notional, const std::string &currency, const std::string &qualifier, QuantLib::Real priorNotional=QuantLib::Null< QuantLib::Real >(), QuantLib::Real recovery=QuantLib::Null< QuantLib::Real >(), const QuantLib::Date &auctionDate=QuantLib::Date(), const QuantLib::Date &auctionSettlementDate=QuantLib::Date(), const QuantLib::Date &defaultDate=QuantLib::Date(), const QuantLib::Date &eventDeterminationDate=QuantLib::Date())
 Constructor taking CDS reference information, cdsReferenceInfo. More...
 
Serialisation
void fromXML (ore::data::XMLNode *node) override
 
ore::data::XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
- 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...
 

Inspectors

std::string issuerName_
 
boost::optional< ore::data::CdsReferenceInformationcdsReferenceInfo_
 
std::string creditCurveId_
 
QuantLib::Real notional_
 
std::string currency_
 
std::string qualifier_
 
QuantLib::Real priorNotional_
 
QuantLib::Real weight_
 
QuantLib::Real priorWeight_
 
QuantLib::Real recovery_
 
QuantLib::Date auctionDate_
 
QuantLib::Date auctionSettlementDate_
 
QuantLib::Date defaultDate_
 
QuantLib::Date eventDeterminationDate_
 
bool weightInsteadOfNotional_
 
const std::string & issuerName () const
 
const std::string & creditCurveId () const
 
const boost::optional< ore::data::CdsReferenceInformation > & cdsReferenceInfo () const
 
QuantLib::Real notional () const
 
const std::string & currency () const
 
QuantLib::Real priorNotional () const
 
QuantLib::Real recovery () const
 
QuantLib::Real weight () const
 
QuantLib::Real priorWeight () const
 
const QuantLib::Date & auctionDate () const
 
const QuantLib::Date & auctionSettlementDate () const
 
const QuantLib::Date & defaultDate () const
 
const QuantLib::Date & eventDeterminationDate () const
 
bool weightInsteadOfNotional () const
 

Detailed Description

Serializable credit basket data constituent

Definition at line 37 of file basketdata.hpp.

Constructor & Destructor Documentation

◆ BasketConstituent() [1/4]

Default constructor.

Definition at line 36 of file basketdata.cpp.

37 : notional_(Null<Real>()), priorNotional_(Null<Real>()), weight_(Null<Real>()), priorWeight_(Null<Real>()),
38 recovery_(Null<Real>()), weightInsteadOfNotional_(false) {}

◆ BasketConstituent() [2/4]

BasketConstituent ( const std::string &  issuerName,
const std::string &  creditCurveId,
QuantLib::Real  notional,
const std::string &  currency,
const std::string &  qualifier,
QuantLib::Real  priorNotional = QuantLib::Null< QuantLib::Real >(),
QuantLib::Real  recovery = QuantLib::Null< QuantLib::Real >(),
const QuantLib::Date &  auctionDate = QuantLib::Date(),
const QuantLib::Date &  auctionSettlementDate = QuantLib::Date(),
const QuantLib::Date &  defaultDate = QuantLib::Date(),
const QuantLib::Date &  eventDeterminationDate = QuantLib::Date() 
)

Constructor taking an explicit creditCurveId.

◆ BasketConstituent() [3/4]

BasketConstituent ( const std::string &  issuerName,
const std::string &  creditCurveId,
QuantLib::Real  weight,
const std::string &  qualifier,
QuantLib::Real  priorWeight = QuantLib::Null< QuantLib::Real >(),
QuantLib::Real  recovery = QuantLib::Null< QuantLib::Real >(),
const QuantLib::Date &  auctionDate = QuantLib::Date(),
const QuantLib::Date &  auctionSettlementDate = QuantLib::Date(),
const QuantLib::Date &  defaultDate = QuantLib::Date(),
const QuantLib::Date &  eventDeterminationDate = QuantLib::Date() 
)

Constructor taking an explicit creditCurveId and initialized by weight.

◆ BasketConstituent() [4/4]

BasketConstituent ( const std::string &  issuerName,
const ore::data::CdsReferenceInformation cdsReferenceInfo,
QuantLib::Real  notional,
const std::string &  currency,
const std::string &  qualifier,
QuantLib::Real  priorNotional = QuantLib::Null< QuantLib::Real >(),
QuantLib::Real  recovery = QuantLib::Null< QuantLib::Real >(),
const QuantLib::Date &  auctionDate = QuantLib::Date(),
const QuantLib::Date &  auctionSettlementDate = QuantLib::Date(),
const QuantLib::Date &  defaultDate = QuantLib::Date(),
const QuantLib::Date &  eventDeterminationDate = QuantLib::Date() 
)

Constructor taking CDS reference information, cdsReferenceInfo.

Member Function Documentation

◆ fromXML()

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

Implements XMLSerializable.

Definition at line 69 of file basketdata.cpp.

69 {
70
71 XMLUtils::checkNode(node, "Name");
72
73 issuerName_ = XMLUtils::getChildValue(node, "IssuerId", true);
74 qualifier_ = XMLUtils::getChildValue(node, "Qualifier", false);
75
76 // May get an explicit CreditCurveId node. If so, we use it. Otherwise, we must have ReferenceInformation node.
77 if (XMLNode* tmp = XMLUtils::getChildNode(node, "CreditCurveId")) {
79 } else {
80 tmp = XMLUtils::getChildNode(node, "ReferenceInformation");
81 QL_REQUIRE(tmp, "Need either a CreditCurveId or ReferenceInformation node in each BasketConstituent.");
82 cdsReferenceInfo_ = CdsReferenceInformation();
83 cdsReferenceInfo_->fromXML(tmp);
85 }
86
87 bool zeroWeightOrZeroNotional = false;
88 if (auto notionalNode = XMLUtils::getChildNode(node, "Notional")) {
91 currency_ = XMLUtils::getChildValue(node, "Currency", true);
92 if (close(notional_, 0.0))
93 zeroWeightOrZeroNotional = true;
94 } else {
95 auto weightNode = XMLUtils::getChildNode(node, "Weight");
96 QL_REQUIRE(weightNode, "a 'Notional' or 'Weight' node is mandatory.");
99 if (close(weight_, 0.0))
100 zeroWeightOrZeroNotional = true;
101 currency_ = "";
102 }
103 if (zeroWeightOrZeroNotional) {
104 priorNotional_ = Null<Real>();
105 priorWeight_ = Null<Real>();
107 if (auto n = XMLUtils::getChildNode(node, "PriorNotional"))
109 } else {
110 if (auto n = XMLUtils::getChildNode(node, "PriorWeight"))
112 }
113
114 recovery_ = Null<Real>();
115 if (auto n = XMLUtils::getChildNode(node, "RecoveryRate"))
117
118 auctionDate_ = Date();
119 if (auto n = XMLUtils::getChildNode(node, "AuctionDate"))
121
122 auctionSettlementDate_ = Date();
123 if (auto n = XMLUtils::getChildNode(node, "AuctionSettlementDate"))
125
126 defaultDate_ = Date();
127 if (auto n = XMLUtils::getChildNode(node, "DefaultDate"))
129
131 if (auto n = XMLUtils::getChildNode(node, "EventDeterminationDate"))
133 }
134
135}
QuantLib::Date eventDeterminationDate_
Definition: basketdata.hpp:112
boost::optional< ore::data::CdsReferenceInformation > cdsReferenceInfo_
Definition: basketdata.hpp:100
QuantLib::Date auctionSettlementDate_
Definition: basketdata.hpp:110
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static string getNodeValue(XMLNode *node)
Get a node's value.
Definition: xmlutils.cpp:489
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
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 ( ore::data::XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 137 of file basketdata.cpp.

137 {
138
139 XMLNode* node = doc.allocNode("Name");
140
141 XMLUtils::addChild(doc, node, "IssuerId", issuerName_);
142 if (!qualifier_.empty())
143 XMLUtils::addChild(doc, node, "Qualifier", qualifier_);
144
145 // We either have reference information or an explicit credit curve ID
146 if (cdsReferenceInfo_) {
147 XMLUtils::appendNode(node, cdsReferenceInfo_->toXML(doc));
148 } else {
149 XMLUtils::addChild(doc, node, "CreditCurveId", creditCurveId_);
150 }
151
153 XMLUtils::addChild(doc, node, "Notional", notional_);
154 XMLUtils::addChild(doc, node, "Currency", currency_);
155 } else {
156 XMLUtils::addChild(doc, node, "Weight", weight_);
157 }
158
159 if (close(notional_, 0.0) && !weightInsteadOfNotional_) {
160
161 if (priorNotional_ != Null<Real>())
162 XMLUtils::addChild(doc, node, "PriorNotional", priorNotional_);
163
164 if (recovery_ != Null<Real>())
165 XMLUtils::addChild(doc, node, "RecoveryRate", recovery_);
166
167 if (auctionDate_ != Date())
168 XMLUtils::addChild(doc, node, "AuctionDate", to_string(auctionDate_));
169
170 if (auctionSettlementDate_ != Date())
171 XMLUtils::addChild(doc, node, "AuctionSettlementDate", to_string(auctionSettlementDate_));
172
173 if (defaultDate_ != Date())
174 XMLUtils::addChild(doc, node, "DefaultDate", to_string(defaultDate_));
175
176 if (eventDeterminationDate_ != Date())
177 XMLUtils::addChild(doc, node, "EventDeterminationDate", to_string(eventDeterminationDate_));
178 } else if (close(weight_, 0.0) && weightInsteadOfNotional_) {
179
180 if (priorWeight_ != Null<Real>())
181 XMLUtils::addChild(doc, node, "PriorWeight", priorWeight_);
182
183 if (recovery_ != Null<Real>())
184 XMLUtils::addChild(doc, node, "RecoveryRate", recovery_);
185
186 if (auctionDate_ != Date())
187 XMLUtils::addChild(doc, node, "AuctionDate", to_string(auctionDate_));
188
189 if (auctionSettlementDate_ != Date())
190 XMLUtils::addChild(doc, node, "AuctionSettlementDate", to_string(auctionSettlementDate_));
191
192 if (defaultDate_ != Date())
193 XMLUtils::addChild(doc, node, "DefaultDate", to_string(defaultDate_));
194
195 if (eventDeterminationDate_ != Date())
196 XMLUtils::addChild(doc, node, "EventDeterminationDate", to_string(eventDeterminationDate_));
197 }
198
199 return node;
200}
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
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:

◆ issuerName()

const string & issuerName ( ) const

Definition at line 202 of file basketdata.cpp.

202{ return issuerName_; }

◆ creditCurveId()

const string & creditCurveId ( ) const

Definition at line 204 of file basketdata.cpp.

204{ return creditCurveId_; }
+ Here is the caller graph for this function:

◆ cdsReferenceInfo()

const boost::optional< CdsReferenceInformation > & cdsReferenceInfo ( ) const

Definition at line 206 of file basketdata.cpp.

206 {
207 return cdsReferenceInfo_;
208}

◆ notional()

QuantLib::Real notional ( ) const

Definition at line 210 of file basketdata.cpp.

210 {
211 QL_REQUIRE(!weightInsteadOfNotional_, "Try to access notional from basket constituent "
212 << issuerName_ << ", but weight (w=" << weight_
213 << ") was given.");
214 return notional_;
215}

◆ currency()

const string & currency ( ) const

Definition at line 216 of file basketdata.cpp.

216 {
217 QL_REQUIRE(!weightInsteadOfNotional_, "Try to access currceny from basket constituent "
218 << issuerName_ << ", but weight instead of notional given");
219 return currency_;
220}

◆ priorNotional()

QuantLib::Real priorNotional ( ) const

Definition at line 222 of file basketdata.cpp.

222 {
223 QL_REQUIRE(!weightInsteadOfNotional_, "Try to access priorNotional from basket constituent "
224 << issuerName_ << ", but priorWeight (w=" << priorWeight_
225 << ") was given.");
226 return priorNotional_;
227}

◆ recovery()

Real recovery ( ) const

Definition at line 229 of file basketdata.cpp.

229{ return recovery_; }

◆ weight()

QuantLib::Real weight ( ) const

Definition at line 231 of file basketdata.cpp.

231 {
232 QL_REQUIRE(weightInsteadOfNotional_, "Try to access weight from basket constituent "
233 << issuerName_ << ", but notional (N=" << notional_ << " "
234 << currency_ << ") was given.");
235 return weight_;
236}

◆ priorWeight()

QuantLib::Real priorWeight ( ) const

Definition at line 238 of file basketdata.cpp.

238 {
239 QL_REQUIRE(weightInsteadOfNotional_, "Try to access priorWeight from basket constituent "
240 << issuerName_ << ", but priorNotional (N=" << priorNotional_ << " "
241 << currency_ << ") was given.");
242 return priorWeight_;
243}

◆ auctionDate()

const Date & auctionDate ( ) const

Definition at line 245 of file basketdata.cpp.

245{ return auctionDate_; }

◆ auctionSettlementDate()

const Date & auctionSettlementDate ( ) const

Definition at line 247 of file basketdata.cpp.

247{ return auctionSettlementDate_; }

◆ defaultDate()

const Date & defaultDate ( ) const

Definition at line 249 of file basketdata.cpp.

249{ return defaultDate_; }

◆ eventDeterminationDate()

const Date & eventDeterminationDate ( ) const

Definition at line 251 of file basketdata.cpp.

251{ return eventDeterminationDate_; }

◆ weightInsteadOfNotional()

bool weightInsteadOfNotional ( ) const

Definition at line 253 of file basketdata.cpp.

253{ return weightInsteadOfNotional_; }

Member Data Documentation

◆ issuerName_

std::string issuerName_
private

Definition at line 99 of file basketdata.hpp.

◆ cdsReferenceInfo_

boost::optional<ore::data::CdsReferenceInformation> cdsReferenceInfo_
private

Definition at line 100 of file basketdata.hpp.

◆ creditCurveId_

std::string creditCurveId_
private

Definition at line 101 of file basketdata.hpp.

◆ notional_

QuantLib::Real notional_
private

Definition at line 102 of file basketdata.hpp.

◆ currency_

std::string currency_
private

Definition at line 103 of file basketdata.hpp.

◆ qualifier_

std::string qualifier_
private

Definition at line 104 of file basketdata.hpp.

◆ priorNotional_

QuantLib::Real priorNotional_
private

Definition at line 105 of file basketdata.hpp.

◆ weight_

QuantLib::Real weight_
private

Definition at line 106 of file basketdata.hpp.

◆ priorWeight_

QuantLib::Real priorWeight_
private

Definition at line 107 of file basketdata.hpp.

◆ recovery_

QuantLib::Real recovery_
private

Definition at line 108 of file basketdata.hpp.

◆ auctionDate_

QuantLib::Date auctionDate_
private

Definition at line 109 of file basketdata.hpp.

◆ auctionSettlementDate_

QuantLib::Date auctionSettlementDate_
private

Definition at line 110 of file basketdata.hpp.

◆ defaultDate_

QuantLib::Date defaultDate_
private

Definition at line 111 of file basketdata.hpp.

◆ eventDeterminationDate_

QuantLib::Date eventDeterminationDate_
private

Definition at line 112 of file basketdata.hpp.

◆ weightInsteadOfNotional_

bool weightInsteadOfNotional_
private

Definition at line 113 of file basketdata.hpp.