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

#include <ored/portfolio/underlying.hpp>

+ Inheritance diagram for EquityUnderlying:
+ Collaboration diagram for EquityUnderlying:

Public Member Functions

 EquityUnderlying ()
 Default constructor. More...
 
 EquityUnderlying (const std::string &equityName)
 Constructor with equity name. More...
 
 EquityUnderlying (const std::string &name, const std::string &identifierType, const std::string &currency, const std::string &exchange, const QuantLib::Real weight)
 Constructor with identifier information. More...
 
const std::string & name () const override
 
const std::string & identifierType () const
 
const std::string & currency () const
 
const std::string & exchange () const
 
void setEquityName ()
 set name of equity More...
 
- Public Member Functions inherited from Underlying
 Underlying ()
 Default Constructor. More...
 
 Underlying (const std::string &type, const std::string &name, const QuantLib::Real weight=QuantLib::Null< QuantLib::Real >())
 Constructor with type, name, weight. More...
 
void setType (const string &type)
 
void setName (const string &name)
 
void setWeight (const QuantLib::Real weight)
 
void setNodeName (const string &nodeName)
 
void setBasicUnderlyingNodeName (const string &basicUnderlyingNodeName)
 
const std::string & type () const
 
Real weight () const
 
- 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...
 

Serialisation

std::string equityName_
 
std::string identifierType_
 
std::string currency_
 
std::string exchange_
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (XMLDocument &doc) const override
 

Additional Inherited Members

- Protected Attributes inherited from Underlying
std::string type_
 
std::string name_
 
Real weight_ = QuantLib::Null<QuantLib::Real>()
 
std::string nodeName_
 
std::string basicUnderlyingNodeName_
 
bool isBasic_ = false
 

Detailed Description

Definition at line 93 of file underlying.hpp.

Constructor & Destructor Documentation

◆ EquityUnderlying() [1/3]

Default constructor.

Definition at line 96 of file underlying.hpp.

96: Underlying() { setType("Equity"); }
Underlying()
Default Constructor.
Definition: underlying.hpp:40
void setType(const string &type)
Definition: underlying.hpp:53
+ Here is the call graph for this function:

◆ EquityUnderlying() [2/3]

EquityUnderlying ( const std::string &  equityName)
explicit

Constructor with equity name.

Definition at line 99 of file underlying.hpp.

99: Underlying("Equity", equityName) { isBasic_ = true; };

◆ EquityUnderlying() [3/3]

EquityUnderlying ( const std::string &  name,
const std::string &  identifierType,
const std::string &  currency,
const std::string &  exchange,
const QuantLib::Real  weight 
)

Constructor with identifier information.

Definition at line 102 of file underlying.hpp.

107 };
void setEquityName()
set name of equity
Definition: underlying.cpp:65
const std::string & currency() const
Definition: underlying.hpp:111
const std::string & identifierType() const
Definition: underlying.hpp:110
const std::string & name() const override
Definition: underlying.hpp:109
const std::string & exchange() const
Definition: underlying.hpp:112
Real weight() const
Definition: underlying.hpp:65
+ Here is the call graph for this function:

Member Function Documentation

◆ name()

const std::string & name ( ) const
overridevirtual

Reimplemented from Underlying.

Definition at line 109 of file underlying.hpp.

109{ return equityName_.empty() ? name_ : equityName_; };
+ Here is the caller graph for this function:

◆ identifierType()

const std::string & identifierType ( ) const

Definition at line 110 of file underlying.hpp.

110{ return identifierType_; }

◆ currency()

const std::string & currency ( ) const

Definition at line 111 of file underlying.hpp.

111{ return currency_; }

◆ exchange()

const std::string & exchange ( ) const

Definition at line 112 of file underlying.hpp.

112{ return exchange_; };

◆ setEquityName()

void setEquityName ( )

set name of equity

Definition at line 65 of file underlying.cpp.

65 {
66 if (equityName_.empty()) {
67 string name = name_;
68 if (!identifierType_.empty())
69 name = identifierType_ + ":" + name_;
70 if (!currency_.empty())
71 name = name + ":" + currency_;
72 if (!exchange_.empty()) {
73 if (currency_.empty())
74 name = name + ":";
75 name = name + ":" + exchange_;
76 }
78 }
79}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Reimplemented from Underlying.

Definition at line 81 of file underlying.cpp.

81 {
84 isBasic_ = true;
85 } else if (XMLUtils::getNodeName(node) == nodeName_) {
87 QL_REQUIRE(type_ == "Equity", "Underlying must be of type 'Equity'.");
88 identifierType_ = XMLUtils::getChildValue(node, "IdentifierType", false);
89 // if no identifier is provided, we just use name
90 if (!identifierType_.empty()) {
91 currency_ = XMLUtils::getChildValue(node, "Currency", false);
92 exchange_ = XMLUtils::getChildValue(node, "Exchange", false);
93 }
95 isBasic_ = false;
96 } else {
97 QL_FAIL("Need either a " << basicUnderlyingNodeName_ << " or " << nodeName_ << " for EquityUnderlying.");
98 }
99 setType("Equity");
100}
std::string basicUnderlyingNodeName_
Definition: underlying.hpp:71
std::string nodeName_
Definition: underlying.hpp:71
virtual void fromXML(ore::data::XMLNode *node) override
Definition: underlying.cpp:33
static string getNodeName(XMLNode *n)
Get and set a node's name.
Definition: xmlutils.cpp:473
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static string getNodeValue(XMLNode *node)
Get a node's value.
Definition: xmlutils.cpp:489
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Reimplemented from Underlying.

Definition at line 102 of file underlying.cpp.

102 {
103 XMLNode* node;
104 if (isBasic_) {
105 node = doc.allocNode(basicUnderlyingNodeName_, name_);
106 } else {
107 node = Underlying::toXML(doc);
108 if (!identifierType_.empty())
109 XMLUtils::addChild(doc, node, "IdentifierType", identifierType_);
110 if (!currency_.empty())
111 XMLUtils::addChild(doc, node, "Currency", currency_);
112 if (!exchange_.empty())
113 XMLUtils::addChild(doc, node, "Exchange", exchange_);
114 }
115 return node;
116}
virtual ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
Definition: underlying.cpp:42
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
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:

Member Data Documentation

◆ equityName_

std::string equityName_
private

Definition at line 124 of file underlying.hpp.

◆ identifierType_

std::string identifierType_
private

Definition at line 124 of file underlying.hpp.

◆ currency_

std::string currency_
private

Definition at line 124 of file underlying.hpp.

◆ exchange_

std::string exchange_
private

Definition at line 124 of file underlying.hpp.