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

Serializable Fixed Leg Data. More...

#include <ored/portfolio/legdata.hpp>

+ Inheritance diagram for EquityLegData:
+ Collaboration diagram for EquityLegData:

Public Member Functions

 EquityLegData ()
 Default constructor. More...
 
 EquityLegData (EquityReturnType returnType, Real dividendFactor, EquityUnderlying equityUnderlying, Real initialPrice, bool notionalReset, Natural fixingDays=0, const ScheduleData &valuationSchedule=ScheduleData(), string eqCurrency="", string fxIndex="", Real quantity=Null< Real >(), string initialPriceCurrency="")
 Constructor. More...
 
Inspectors
EquityReturnType returnType () const
 
string eqName ()
 
Real dividendFactor () const
 
EquityUnderlying equityIdentifier () const
 
Real initialPrice () const
 
Natural fixingDays () const
 
ScheduleData valuationSchedule () const
 
const string & eqCurrency () const
 
const string & fxIndex () const
 
bool notionalReset () const
 
Real quantity () const
 
const string & initialPriceCurrency () const
 
- Public Member Functions inherited from LegAdditionalData
 LegAdditionalData (const string &legType, const string &legNodeName)
 
 LegAdditionalData (const string &legType)
 
const string & legType () const
 
const string & legNodeName () const
 
const std::set< std::string > & indices () 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

EquityReturnType returnType_
 
Real dividendFactor_ = 1.0
 
EquityUnderlying equityUnderlying_
 
Real initialPrice_
 
bool notionalReset_ = false
 
Natural fixingDays_ = 0
 
ScheduleData valuationSchedule_
 
string eqCurrency_ = ""
 
string fxIndex_ = ""
 
Real quantity_
 
string initialPriceCurrency_
 
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (XMLDocument &doc) const override
 

Additional Inherited Members

- Protected Attributes inherited from LegAdditionalData
std::set< std::string > indices_
 

Detailed Description

Serializable Fixed Leg Data.

Definition at line 754 of file legdata.hpp.

Constructor & Destructor Documentation

◆ EquityLegData() [1/2]

Default constructor.

Definition at line 757 of file legdata.hpp.

757: LegAdditionalData("Equity"), initialPrice_(Null<Real>()), quantity_(Null<Real>()) {}
LegAdditionalData(const string &legType, const string &legNodeName)
Definition: legdata.hpp:65

◆ EquityLegData() [2/2]

EquityLegData ( EquityReturnType  returnType,
Real  dividendFactor,
EquityUnderlying  equityUnderlying,
Real  initialPrice,
bool  notionalReset,
Natural  fixingDays = 0,
const ScheduleData valuationSchedule = ScheduleData(),
string  eqCurrency = "",
string  fxIndex = "",
Real  quantity = Null<Real>(),
string  initialPriceCurrency = "" 
)

Constructor.

Definition at line 759 of file legdata.hpp.

766 indices_.insert("EQ-" + eqName());
767 }
EquityReturnType returnType() const
Definition: legdata.hpp:771
ScheduleData valuationSchedule_
Definition: legdata.hpp:797
Natural fixingDays() const
Definition: legdata.hpp:776
Real dividendFactor() const
Definition: legdata.hpp:773
EquityReturnType returnType_
Definition: legdata.hpp:791
const string & initialPriceCurrency() const
Definition: legdata.hpp:782
bool notionalReset() const
Definition: legdata.hpp:780
const string & eqCurrency() const
Definition: legdata.hpp:778
const string & fxIndex() const
Definition: legdata.hpp:779
Real quantity() const
Definition: legdata.hpp:781
EquityUnderlying equityUnderlying_
Definition: legdata.hpp:793
ScheduleData valuationSchedule() const
Definition: legdata.hpp:777
Real initialPrice() const
Definition: legdata.hpp:775
std::set< std::string > indices_
Definition: legdata.hpp:77
+ Here is the call graph for this function:

Member Function Documentation

◆ returnType()

EquityReturnType returnType ( ) const

Definition at line 771 of file legdata.hpp.

771{ return returnType_; }

◆ eqName()

string eqName ( )

Definition at line 772 of file legdata.hpp.

772{ return equityUnderlying_.name(); }
const std::string & name() const override
Definition: underlying.hpp:109
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dividendFactor()

Real dividendFactor ( ) const

Definition at line 773 of file legdata.hpp.

773{ return dividendFactor_; }

◆ equityIdentifier()

EquityUnderlying equityIdentifier ( ) const

Definition at line 774 of file legdata.hpp.

774{ return equityUnderlying_; }

◆ initialPrice()

Real initialPrice ( ) const

Definition at line 775 of file legdata.hpp.

775{ return initialPrice_; }

◆ fixingDays()

Natural fixingDays ( ) const

Definition at line 776 of file legdata.hpp.

776{ return fixingDays_; }

◆ valuationSchedule()

ScheduleData valuationSchedule ( ) const

Definition at line 777 of file legdata.hpp.

777{ return valuationSchedule_; }

◆ eqCurrency()

const string & eqCurrency ( ) const

Definition at line 778 of file legdata.hpp.

778{ return eqCurrency_; }

◆ fxIndex()

const string & fxIndex ( ) const

Definition at line 779 of file legdata.hpp.

779{ return fxIndex_; }

◆ notionalReset()

bool notionalReset ( ) const

Definition at line 780 of file legdata.hpp.

780{ return notionalReset_; }

◆ quantity()

Real quantity ( ) const

Definition at line 781 of file legdata.hpp.

781{ return quantity_; } // might be null

◆ initialPriceCurrency()

const string & initialPriceCurrency ( ) const

Definition at line 782 of file legdata.hpp.

782{ return initialPriceCurrency_; } // might be empty

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 618 of file legdata.cpp.

618 {
621 if (returnType_ == EquityReturnType::Total && XMLUtils::getChildNode(node, "DividendFactor"))
622 dividendFactor_ = XMLUtils::getChildValueAsDouble(node, "DividendFactor", true);
623 else
624 dividendFactor_ = 1.0;
625 XMLNode* utmp = XMLUtils::getChildNode(node, "Underlying");
626 if (!utmp)
627 utmp = XMLUtils::getChildNode(node, "Name");
629 indices_.insert("EQ-" + eqName());
630 if (XMLUtils::getChildNode(node, "InitialPrice"))
631 initialPrice_ = XMLUtils::getChildValueAsDouble(node, "InitialPrice");
632 else
633 initialPrice_ = Null<Real>();
634 initialPriceCurrency_ = XMLUtils::getChildValue(node, "InitialPriceCurrency", false);
635 fixingDays_ = XMLUtils::getChildValueAsInt(node, "FixingDays");
636 XMLNode* tmp = XMLUtils::getChildNode(node, "ValuationSchedule");
637 if (tmp)
639 if (XMLUtils::getChildNode(node, "NotionalReset"))
640 notionalReset_ = XMLUtils::getChildValueAsBool(node, "NotionalReset");
641 else
642 notionalReset_ = true;
643
644 XMLNode* fxt = XMLUtils::getChildNode(node, "FXTerms");
645 if (fxt) {
646 eqCurrency_ = XMLUtils::getChildValue(fxt, "EquityCurrency", false);
647 fxIndex_ = XMLUtils::getChildValue(fxt, "FXIndex", true);
648 if (XMLUtils::getChildNode(fxt, "FXIndexFixingDays")) {
649 WLOG("EquityLegData::fromXML, node FXIndexFixingDays has been deprecated, fixing days are "
650 "taken from conventions.");
651 }
652 if (XMLUtils::getChildNode(fxt, "FXIndexCalendar")) {
653 WLOG("EquityLegData::fromXML, node FXIndexCalendar has been deprecated, fixing calendar is "
654 "taken from conventions.");
655 }
656 indices_.insert(fxIndex_);
657 }
658
659 if (XMLNode* qty = XMLUtils::getChildNode(node, "Quantity"))
661 else
662 quantity_ = Null<Real>();
663}
void fromXML(XMLNode *node) override
Definition: underlying.cpp:81
const string & legNodeName() const
Definition: legdata.hpp:70
virtual void fromXML(XMLNode *node) override
Definition: schedule.cpp:179
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 string getNodeValue(XMLNode *node)
Get a node's value.
Definition: xmlutils.cpp:489
static int getChildValueAsInt(XMLNode *node, const string &name, bool mandatory=false, int defaultValue=0)
Definition: xmlutils.cpp:291
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
EquityReturnType parseEquityReturnType(const std::string &str)
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 665 of file legdata.cpp.

665 {
666 XMLNode* node = doc.allocNode(legNodeName());
667 if (quantity_ != Null<Real>())
668 XMLUtils::addChild(doc, node, "Quantity", quantity_);
669
670 XMLUtils::addChild(doc, node, "ReturnType", to_string(returnType_));
671 if (returnType_ == EquityReturnType::Total)
672 XMLUtils::addChild(doc, node, "DividendFactor", dividendFactor_);
673
675 if (initialPrice_ != Null<Real>())
676 XMLUtils::addChild(doc, node, "InitialPrice", initialPrice_);
677 if (!initialPriceCurrency_.empty())
678 XMLUtils::addChild(doc, node, "InitialPriceCurrency", initialPriceCurrency_);
679 XMLUtils::addChild(doc, node, "NotionalReset", notionalReset_);
680
682 XMLNode* schedNode = valuationSchedule_.toXML(doc);
683 XMLUtils::setNodeName(doc, schedNode, "ValuationSchedule");
684 XMLUtils::appendNode(node, schedNode);
685 } else {
686 XMLUtils::addChild(doc, node, "FixingDays", static_cast<Integer>(fixingDays_));
687 }
688
689 if (fxIndex_ != "") {
690 XMLNode* fxNode = doc.allocNode("FXTerms");
691 XMLUtils::addChild(doc, fxNode, "EquityCurrency", eqCurrency_);
692 XMLUtils::addChild(doc, fxNode, "FXIndex", fxIndex_);
693 XMLUtils::appendNode(node, fxNode);
694 }
695 return node;
696}
XMLNode * toXML(XMLDocument &doc) const override
Definition: underlying.cpp:102
bool hasData() const
Check if has any dates/rules/derived schedules.
Definition: schedule.hpp:223
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: schedule.cpp:198
static void setNodeName(XMLDocument &doc, XMLNode *node, const string &name)
Definition: xmlutils.cpp:478
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:

Member Data Documentation

◆ returnType_

EquityReturnType returnType_
private

Definition at line 791 of file legdata.hpp.

◆ dividendFactor_

Real dividendFactor_ = 1.0
private

Definition at line 792 of file legdata.hpp.

◆ equityUnderlying_

EquityUnderlying equityUnderlying_
private

Definition at line 793 of file legdata.hpp.

◆ initialPrice_

Real initialPrice_
private

Definition at line 794 of file legdata.hpp.

◆ notionalReset_

bool notionalReset_ = false
private

Definition at line 795 of file legdata.hpp.

◆ fixingDays_

Natural fixingDays_ = 0
private

Definition at line 796 of file legdata.hpp.

◆ valuationSchedule_

ScheduleData valuationSchedule_
private

Definition at line 797 of file legdata.hpp.

◆ eqCurrency_

string eqCurrency_ = ""
private

Definition at line 798 of file legdata.hpp.

◆ fxIndex_

string fxIndex_ = ""
private

Definition at line 799 of file legdata.hpp.

◆ quantity_

Real quantity_
private

Definition at line 800 of file legdata.hpp.

◆ initialPriceCurrency_

string initialPriceCurrency_
private

Definition at line 801 of file legdata.hpp.