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

#include <ored/portfolio/commoditylegdata.hpp>

+ Inheritance diagram for CommodityFixedLegData:
+ Collaboration diagram for CommodityFixedLegData:

Public Member Functions

 CommodityFixedLegData ()
 Default constructor. More...
 
 CommodityFixedLegData (const std::vector< QuantLib::Real > &quantities, const std::vector< std::string > &quantityDates, const std::vector< QuantLib::Real > &prices, const std::vector< std::string > &priceDates, CommodityPayRelativeTo commodityPayRelativeTo, const std::string &tag="")
 Detailed constructor. More...
 
Inspectors
const std::vector< QuantLib::Real > & quantities () const
 
const std::vector< std::string > & quantityDates () const
 
const std::vector< QuantLib::Real > & prices () const
 
const std::vector< std::string > & priceDates () const
 
CommodityPayRelativeTo commodityPayRelativeTo () const
 
const std::string & tag () const
 
void setQuantities (const std::vector< QuantLib::Real > &quantities)
 Set the fixed leg data quantities. More...
 
- 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

std::vector< QuantLib::Real > quantities_
 
std::vector< std::string > quantityDates_
 
std::vector< QuantLib::Real > prices_
 
std::vector< std::string > priceDates_
 
CommodityPayRelativeTo commodityPayRelativeTo_
 
std::string tag_
 
void fromXML (ore::data::XMLNode *node) override
 
ore::data::XMLNodetoXML (ore::data::XMLDocument &doc) const override
 

Additional Inherited Members

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

Detailed Description

Definition at line 50 of file commoditylegdata.hpp.

Constructor & Destructor Documentation

◆ CommodityFixedLegData() [1/2]

Default constructor.

Definition at line 120 of file commoditylegdata.cpp.

◆ CommodityFixedLegData() [2/2]

CommodityFixedLegData ( const std::vector< QuantLib::Real > &  quantities,
const std::vector< std::string > &  quantityDates,
const std::vector< QuantLib::Real > &  prices,
const std::vector< std::string > &  priceDates,
CommodityPayRelativeTo  commodityPayRelativeTo,
const std::string &  tag = "" 
)

Detailed constructor.

Member Function Documentation

◆ quantities()

const std::vector< QuantLib::Real > & quantities ( ) const

Definition at line 63 of file commoditylegdata.hpp.

63{ return quantities_; }
std::vector< QuantLib::Real > quantities_
+ Here is the caller graph for this function:

◆ quantityDates()

const std::vector< std::string > & quantityDates ( ) const

Definition at line 64 of file commoditylegdata.hpp.

64{ return quantityDates_; }
std::vector< std::string > quantityDates_

◆ prices()

const std::vector< QuantLib::Real > & prices ( ) const

Definition at line 65 of file commoditylegdata.hpp.

65{ return prices_; }
std::vector< QuantLib::Real > prices_

◆ priceDates()

const std::vector< std::string > & priceDates ( ) const

Definition at line 66 of file commoditylegdata.hpp.

66{ return priceDates_; }
std::vector< std::string > priceDates_

◆ commodityPayRelativeTo()

CommodityPayRelativeTo commodityPayRelativeTo ( ) const

Definition at line 67 of file commoditylegdata.hpp.

◆ tag()

const std::string & tag ( ) const

Definition at line 68 of file commoditylegdata.hpp.

68{ return tag_; }

◆ setQuantities()

void setQuantities ( const std::vector< QuantLib::Real > &  quantities)

Set the fixed leg data quantities.

For commodity swaps, there can be a number of conventions provided with the floating leg data quantities that when taken together can be used to calculate the commodity quantity for the full calculation period. Instead of duplicating that data here, we allow the fixed leg data quantities to be set using this method before being passed to the commodity fixed leg builder. The idea is that the quantities will be set by referencing the quantities from the corresponding floating leg of the swap after that leg has been built.

Definition at line 130 of file commoditylegdata.cpp.

130 {
131 // Ensure that the quantityDates_ are cleared also.
133 quantityDates_.clear();
134}
const std::vector< QuantLib::Real > & quantities() const
+ Here is the call graph for this function:

◆ fromXML()

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

Implements XMLSerializable.

Definition at line 136 of file commoditylegdata.cpp.

136 {
137 XMLUtils::checkNode(node, "CommodityFixedLegData");
138
139 quantities_.clear();
140 if (XMLUtils::getChildNode(node, "Quantities")) {
141 quantities_ = XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Quantities", "Quantity",
142 "startDate", quantityDates_, &parseReal, true);
143 }
144
145 prices_ = XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Prices", "Price", "startDate", priceDates_,
146 &parseReal, true);
147
149 if (XMLNode* n = XMLUtils::getChildNode(node, "CommodityPayRelativeTo")) {
151 }
152 tag_ = XMLUtils::getChildValue(node, "Tag", false);
153}
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
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
CommodityPayRelativeTo parseCommodityPayRelativeTo(const string &s)
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( ore::data::XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 155 of file commoditylegdata.cpp.

155 {
156 XMLNode* node = doc.allocNode("CommodityFixedLegData");
157
158 if (!quantities_.empty()) {
159 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Quantities", "Quantity",
160 quantities_, "startDate", quantityDates_);
161 }
162
163 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Prices", "Price", prices_, "startDate", priceDates_);
164 XMLUtils::addChild(doc, node, "CommodityPayRelativeTo", to_string(commodityPayRelativeTo_));
165 if (!tag_.empty())
166 XMLUtils::addChild(doc, node, "Tag", tag_);
167
168 return node;
169}
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
static void addChildrenWithOptionalAttributes(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values, const string &attrName, const vector< string > &attrs)
Definition: xmlutils.cpp:542
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
+ Here is the call graph for this function:

Member Data Documentation

◆ quantities_

std::vector<QuantLib::Real> quantities_
private

Definition at line 88 of file commoditylegdata.hpp.

◆ quantityDates_

std::vector<std::string> quantityDates_
private

Definition at line 89 of file commoditylegdata.hpp.

◆ prices_

std::vector<QuantLib::Real> prices_
private

Definition at line 90 of file commoditylegdata.hpp.

◆ priceDates_

std::vector<std::string> priceDates_
private

Definition at line 91 of file commoditylegdata.hpp.

◆ commodityPayRelativeTo_

CommodityPayRelativeTo commodityPayRelativeTo_
private

Definition at line 92 of file commoditylegdata.hpp.

◆ tag_

std::string tag_
private

Definition at line 93 of file commoditylegdata.hpp.