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

#include <ored/portfolio/bondposition.hpp>

+ Inheritance diagram for BondPositionData:
+ Collaboration diagram for BondPositionData:

Public Member Functions

 BondPositionData ()
 
 BondPositionData (const Real quantity, const std::vector< BondUnderlying > &underlyings)
 
Real quantity () const
 
const std::string & identifier () const
 
const std::vector< BondUnderlying > & underlyings () const
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (XMLDocument &doc) const override
 
void populateFromBondBasketReferenceData (const QuantLib::ext::shared_ptr< ReferenceDataManager > &ref)
 
- 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

Real quantity_ = QuantLib::Null<Real>()
 
std::string identifier_
 
std::vector< BondUnderlyingunderlyings_
 

Detailed Description

Definition at line 35 of file bondposition.hpp.

Constructor & Destructor Documentation

◆ BondPositionData() [1/2]

Definition at line 37 of file bondposition.hpp.

37{}

◆ BondPositionData() [2/2]

BondPositionData ( const Real  quantity,
const std::vector< BondUnderlying > &  underlyings 
)

Definition at line 38 of file bondposition.hpp.

std::vector< BondUnderlying > underlyings_
const std::vector< BondUnderlying > & underlyings() const

Member Function Documentation

◆ quantity()

Real quantity ( ) const

Definition at line 41 of file bondposition.hpp.

41{ return quantity_; }
+ Here is the caller graph for this function:

◆ identifier()

const std::string & identifier ( ) const

Definition at line 42 of file bondposition.hpp.

42{ return identifier_; }

◆ underlyings()

const std::vector< BondUnderlying > & underlyings ( ) const

Definition at line 43 of file bondposition.hpp.

43{ return underlyings_; }
+ Here is the caller graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 25 of file bondposition.cpp.

25 {
26 XMLUtils::checkNode(node, "BondBasketData");
27 quantity_ = XMLUtils::getChildValueAsDouble(node, "Quantity", true);
28 identifier_ = XMLUtils::getChildValue(node, "Identifier", true);
29 auto c = XMLUtils::getChildrenNodes(node, "Underlying");
30 underlyings_.clear();
31 for (auto const n : c) {
32 underlyings_.push_back(BondUnderlying());
33 underlyings_.back().fromXML(n);
34 }
35}
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
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 37 of file bondposition.cpp.

37 {
38 XMLNode* n = doc.allocNode("BondBasketData");
39 XMLUtils::addChild(doc, n, "Quantity", quantity_);
40 XMLUtils::addChild(doc, n, "Identifier", identifier_);
41 for (auto& u : underlyings_) {
42 XMLUtils::appendNode(n, u.toXML(doc));
43 }
44 return n;
45}
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
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:

◆ populateFromBondBasketReferenceData()

void populateFromBondBasketReferenceData ( const QuantLib::ext::shared_ptr< ReferenceDataManager > &  ref)

Definition at line 47 of file bondposition.cpp.

47 {
48 QL_REQUIRE(!identifier_.empty(), "BondPositionData::populateFromBondBasketReferenceData(): no identifier given");
49 if (!ref || !ref->hasData(BondBasketReferenceDatum::TYPE, identifier_)) {
50 DLOG("could not get BondBasketReferenceDatum for '" << identifier_ << "' leave data in trade unchanged");
51 } else {
52 DLOG("got BondBasketReferenceDatum for '" << identifier_ << "':");
53 auto r = QuantLib::ext::dynamic_pointer_cast<BondBasketReferenceDatum>(
55 QL_REQUIRE(r, "BondPositionData::populateFromBondBasketReferenceData(): internal error, could not cast "
56 "reference datum to expected type.");
57 underlyings_ = r->underlyingData();
58 DLOG("updated " << underlyings_.size() << " Underlying nodes.");
59 }
60}
static constexpr const char * TYPE
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
+ Here is the caller graph for this function:

Member Data Documentation

◆ quantity_

Real quantity_ = QuantLib::Null<Real>()
private

Definition at line 51 of file bondposition.hpp.

◆ identifier_

std::string identifier_
private

Definition at line 52 of file bondposition.hpp.

◆ underlyings_

std::vector<BondUnderlying> underlyings_
private

Definition at line 53 of file bondposition.hpp.