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

#include <ored/portfolio/commoditylegdata.hpp>

+ Inheritance diagram for CommodityFloatingLegData:
+ Collaboration diagram for CommodityFloatingLegData:

Public Member Functions

 CommodityFloatingLegData ()
 Default constructor. More...
 
 CommodityFloatingLegData (const std::string &name, CommodityPriceType priceType, const std::vector< QuantLib::Real > &quantities, const std::vector< std::string > &quantityDates, QuantExt::CommodityQuantityFrequency commodityQuantityFrequency=QuantExt::CommodityQuantityFrequency::PerCalculationPeriod, CommodityPayRelativeTo commodityPayRelativeTo=CommodityPayRelativeTo::CalculationPeriodEndDate, const std::vector< QuantLib::Real > &spreads={}, const std::vector< std::string > &spreadDates={}, const std::vector< QuantLib::Real > &gearings={}, const std::vector< std::string > &gearingDates={}, CommodityPricingDateRule pricingDateRule=CommodityPricingDateRule::FutureExpiryDate, const std::string &pricingCalendar="", QuantLib::Natural pricingLag=0, const std::vector< std::string > &pricingDates={}, bool isAveraged=false, bool isInArrears=true, QuantLib::Natural futureMonthOffset=0, QuantLib::Natural deliveryRollDays=0, bool includePeriodEnd=true, bool excludePeriodStart=true, QuantLib::Natural hoursPerDay=QuantLib::Null< QuantLib::Natural >(), bool useBusinessDays=true, const std::string &tag="", QuantLib::Natural dailyExpiryOffset=QuantLib::Null< QuantLib::Natural >(), bool unrealisedQuantity=false, QuantLib::Natural lastNDays=QuantLib::Null< QuantLib::Natural >(), std::string fxIndex="")
 Constructor. More...
 
Inspectors
const std::string & name () const
 
CommodityPriceType priceType () const
 
const std::vector< QuantLib::Real > & quantities () const
 
const std::vector< std::string > & quantityDates () const
 
QuantExt::CommodityQuantityFrequency commodityQuantityFrequency () const
 
CommodityPayRelativeTo commodityPayRelativeTo () const
 
const std::vector< QuantLib::Real > & spreads () const
 
const std::vector< std::string > & spreadDates () const
 
const std::vector< QuantLib::Real > & gearings () const
 
const std::vector< std::string > & gearingDates () const
 
CommodityPricingDateRule pricingDateRule () const
 
const std::string & pricingCalendar () const
 
QuantLib::Natural pricingLag () const
 
const std::vector< std::string > & pricingDates () const
 
bool isAveraged () const
 
bool isInArrears () const
 
QuantLib::Natural futureMonthOffset () const
 
QuantLib::Natural deliveryRollDays () const
 
bool includePeriodEnd () const
 
bool excludePeriodStart () const
 
QuantLib::Natural hoursPerDay () const
 
bool useBusinessDays () const
 
const std::string & tag () const
 
QuantLib::Natural dailyExpiryOffset () const
 
bool unrealisedQuantity () const
 
QuantLib::Natural lastNDays () const
 
std::string const & fxIndex () 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

std::string name_
 
CommodityPriceType priceType_
 
std::vector< QuantLib::Real > quantities_
 
std::vector< std::string > quantityDates_
 
QuantExt::CommodityQuantityFrequency commodityQuantityFrequency_
 
CommodityPayRelativeTo commodityPayRelativeTo_
 
std::vector< QuantLib::Real > spreads_
 
std::vector< std::string > spreadDates_
 
std::vector< QuantLib::Real > gearings_
 
std::vector< std::string > gearingDates_
 
CommodityPricingDateRule pricingDateRule_
 
std::string pricingCalendar_
 
QuantLib::Natural pricingLag_
 
std::vector< std::string > pricingDates_
 
bool isAveraged_
 
bool isInArrears_
 
QuantLib::Natural futureMonthOffset_
 
QuantLib::Natural deliveryRollDays_
 
bool includePeriodEnd_
 
bool excludePeriodStart_
 
QuantLib::Natural hoursPerDay_
 
bool useBusinessDays_
 
std::string tag_
 
QuantLib::Natural dailyExpiryOffset_
 
bool unrealisedQuantity_
 
QuantLib::Natural lastNDays_
 
std::string fxIndex_
 
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 96 of file commoditylegdata.hpp.

Constructor & Destructor Documentation

◆ CommodityFloatingLegData() [1/2]

Default constructor.

Definition at line 171 of file commoditylegdata.cpp.

172 : ore::data::LegAdditionalData("CommodityFloating"),
174 commodityQuantityFrequency_(CommodityQuantityFrequency::PerCalculationPeriod),
179 hoursPerDay_(Null<Natural>()), useBusinessDays_(true), dailyExpiryOffset_(0),
180 unrealisedQuantity_(false), lastNDays_(Null<Natural>()), fxIndex_("") {}
QuantExt::CommodityQuantityFrequency commodityQuantityFrequency_
CommodityPricingDateRule pricingDateRule_
CommodityPayRelativeTo commodityPayRelativeTo_
Serializable Additional Leg Data.
Definition: legdata.hpp:63

◆ CommodityFloatingLegData() [2/2]

CommodityFloatingLegData ( const std::string &  name,
CommodityPriceType  priceType,
const std::vector< QuantLib::Real > &  quantities,
const std::vector< std::string > &  quantityDates,
QuantExt::CommodityQuantityFrequency  commodityQuantityFrequency = QuantExt::CommodityQuantityFrequency::PerCalculationPeriod,
CommodityPayRelativeTo  commodityPayRelativeTo = CommodityPayRelativeTo::CalculationPeriodEndDate,
const std::vector< QuantLib::Real > &  spreads = {},
const std::vector< std::string > &  spreadDates = {},
const std::vector< QuantLib::Real > &  gearings = {},
const std::vector< std::string > &  gearingDates = {},
CommodityPricingDateRule  pricingDateRule = CommodityPricingDateRule::FutureExpiryDate,
const std::string &  pricingCalendar = "",
QuantLib::Natural  pricingLag = 0,
const std::vector< std::string > &  pricingDates = {},
bool  isAveraged = false,
bool  isInArrears = true,
QuantLib::Natural  futureMonthOffset = 0,
QuantLib::Natural  deliveryRollDays = 0,
bool  includePeriodEnd = true,
bool  excludePeriodStart = true,
QuantLib::Natural  hoursPerDay = QuantLib::Null< QuantLib::Natural >(),
bool  useBusinessDays = true,
const std::string &  tag = "",
QuantLib::Natural  dailyExpiryOffset = QuantLib::Null< QuantLib::Natural >(),
bool  unrealisedQuantity = false,
QuantLib::Natural  lastNDays = QuantLib::Null< QuantLib::Natural >(),
std::string  fxIndex = "" 
)

Constructor.

Member Function Documentation

◆ name()

const std::string & name ( ) const

Definition at line 122 of file commoditylegdata.hpp.

◆ priceType()

CommodityPriceType priceType ( ) const

Definition at line 123 of file commoditylegdata.hpp.

123{ return priceType_; }

◆ quantities()

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

Definition at line 124 of file commoditylegdata.hpp.

124{ return quantities_; }
std::vector< QuantLib::Real > quantities_

◆ quantityDates()

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

Definition at line 125 of file commoditylegdata.hpp.

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

◆ commodityQuantityFrequency()

QuantExt::CommodityQuantityFrequency commodityQuantityFrequency ( ) const

Definition at line 126 of file commoditylegdata.hpp.

◆ commodityPayRelativeTo()

CommodityPayRelativeTo commodityPayRelativeTo ( ) const

Definition at line 127 of file commoditylegdata.hpp.

127{ return commodityPayRelativeTo_; }

◆ spreads()

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

Definition at line 128 of file commoditylegdata.hpp.

128{ return spreads_; }
std::vector< QuantLib::Real > spreads_

◆ spreadDates()

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

Definition at line 129 of file commoditylegdata.hpp.

129{ return spreadDates_; }
std::vector< std::string > spreadDates_

◆ gearings()

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

Definition at line 130 of file commoditylegdata.hpp.

130{ return gearings_; }
std::vector< QuantLib::Real > gearings_

◆ gearingDates()

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

Definition at line 131 of file commoditylegdata.hpp.

131{ return gearingDates_; }
std::vector< std::string > gearingDates_

◆ pricingDateRule()

CommodityPricingDateRule pricingDateRule ( ) const

Definition at line 132 of file commoditylegdata.hpp.

132{ return pricingDateRule_; }

◆ pricingCalendar()

const std::string & pricingCalendar ( ) const

Definition at line 133 of file commoditylegdata.hpp.

◆ pricingLag()

QuantLib::Natural pricingLag ( ) const

Definition at line 134 of file commoditylegdata.hpp.

134{ return pricingLag_; }

◆ pricingDates()

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

Definition at line 135 of file commoditylegdata.hpp.

135{ return pricingDates_; }
std::vector< std::string > pricingDates_

◆ isAveraged()

bool isAveraged ( ) const

Definition at line 136 of file commoditylegdata.hpp.

136{ return isAveraged_; }

◆ isInArrears()

bool isInArrears ( ) const

Definition at line 137 of file commoditylegdata.hpp.

137{ return isInArrears_; }

◆ futureMonthOffset()

QuantLib::Natural futureMonthOffset ( ) const

Definition at line 138 of file commoditylegdata.hpp.

138{ return futureMonthOffset_; }

◆ deliveryRollDays()

QuantLib::Natural deliveryRollDays ( ) const

Definition at line 139 of file commoditylegdata.hpp.

139{ return deliveryRollDays_; }

◆ includePeriodEnd()

bool includePeriodEnd ( ) const

Definition at line 140 of file commoditylegdata.hpp.

140{ return includePeriodEnd_; }

◆ excludePeriodStart()

bool excludePeriodStart ( ) const

Definition at line 141 of file commoditylegdata.hpp.

141{ return excludePeriodStart_; }

◆ hoursPerDay()

QuantLib::Natural hoursPerDay ( ) const

Definition at line 142 of file commoditylegdata.hpp.

142{ return hoursPerDay_; }

◆ useBusinessDays()

bool useBusinessDays ( ) const

Definition at line 143 of file commoditylegdata.hpp.

143{ return useBusinessDays_; }

◆ tag()

const std::string & tag ( ) const

Definition at line 144 of file commoditylegdata.hpp.

144{ return tag_; }

◆ dailyExpiryOffset()

QuantLib::Natural dailyExpiryOffset ( ) const

Definition at line 145 of file commoditylegdata.hpp.

145{ return dailyExpiryOffset_; }

◆ unrealisedQuantity()

bool unrealisedQuantity ( ) const

Definition at line 146 of file commoditylegdata.hpp.

146{ return unrealisedQuantity_; }

◆ lastNDays()

QuantLib::Natural lastNDays ( ) const

Definition at line 147 of file commoditylegdata.hpp.

147{ return lastNDays_; }

◆ fxIndex()

std::string const & fxIndex ( ) const

Definition at line 148 of file commoditylegdata.hpp.

148{ return fxIndex_; }

◆ fromXML()

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

Implements XMLSerializable.

Definition at line 203 of file commoditylegdata.cpp.

203 {
204
205 XMLUtils::checkNode(node, "CommodityFloatingLegData");
206
207 name_ = XMLUtils::getChildValue(node, "Name", true);
208 indices_.insert("COMM-" + name_);
210 quantities_ = XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Quantities", "Quantity", "startDate",
211 quantityDates_, &parseReal, true);
212
213 commodityQuantityFrequency_ = CommodityQuantityFrequency::PerCalculationPeriod;
214 if (XMLNode* n = XMLUtils::getChildNode(node, "CommodityQuantityFrequency")) {
216 }
217
219 if (XMLNode* n = XMLUtils::getChildNode(node, "CommodityPayRelativeTo")) {
221 }
222
223 spreads_ = XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Spreads", "Spread", "startDate", spreadDates_,
224 &parseReal);
225 gearings_ = XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Gearings", "Gearing", "startDate", gearingDates_,
226 &parseReal);
227
229 if (XMLNode* n = XMLUtils::getChildNode(node, "PricingDateRule")) {
231 }
232
233 pricingCalendar_ = XMLUtils::getChildValue(node, "PricingCalendar", false);
234 pricingLag_ = XMLUtils::getChildValueAsInt(node, "PricingLag", false);
235 pricingDates_ = XMLUtils::getChildrenValues(node, "PricingDates", "PricingDate", false);
236
237 isAveraged_ = false;
238 if (XMLNode* n = XMLUtils::getChildNode(node, "IsAveraged")) {
240 }
241
242 isInArrears_ = true;
243 if (XMLNode* n = XMLUtils::getChildNode(node, "IsInArrears")) {
245 }
246
247 futureMonthOffset_ = XMLUtils::getChildValueAsInt(node, "FutureMonthOffset", false);
248 deliveryRollDays_ = XMLUtils::getChildValueAsInt(node, "DeliveryRollDays", false);
249
250 includePeriodEnd_ = true;
251 if (XMLNode* n = XMLUtils::getChildNode(node, "IncludePeriodEnd")) {
253 }
254
255 excludePeriodStart_ = true;
256 if (XMLNode* n = XMLUtils::getChildNode(node, "ExcludePeriodStart")) {
258 }
259
260 hoursPerDay_ = Null<Natural>();
261 if (XMLNode* n = XMLUtils::getChildNode(node, "HoursPerDay")) {
263 }
264
265 useBusinessDays_ = true;
266 if (XMLNode* n = XMLUtils::getChildNode(node, "UseBusinessDays")) {
268 }
269
270 tag_ = XMLUtils::getChildValue(node, "Tag", false);
271
272 dailyExpiryOffset_ = Null<Natural>();
273 if (XMLNode* n = XMLUtils::getChildNode(node, "DailyExpiryOffset")) {
275 }
276
277 unrealisedQuantity_ = false;
278 if (XMLNode* n = XMLUtils::getChildNode(node, "UnrealisedQuantity")) {
280 }
281
282 lastNDays_ = Null<Natural>();
283 if (XMLNode* n = XMLUtils::getChildNode(node, "LastNDays")) {
285 }
286
287 if (XMLNode* n = XMLUtils::getChildNode(node, "FXIndex")) {
289 }
290}
std::set< std::string > indices_
Definition: legdata.hpp:77
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
static int getChildValueAsInt(XMLNode *node, const string &name, bool mandatory=false, int defaultValue=0)
Definition: xmlutils.cpp:291
static vector< string > getChildrenValues(XMLNode *node, const string &names, const string &name, bool mandatory=false)
Definition: xmlutils.cpp:306
bool parseBool(const string &s)
Convert text to bool.
Definition: parsers.cpp:144
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Definition: parsers.cpp:136
CommodityPricingDateRule parseCommodityPricingDateRule(const string &s)
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
CommodityPriceType parseCommodityPriceType(const string &s)
CommodityPayRelativeTo parseCommodityPayRelativeTo(const string &s)
CommodityQuantityFrequency parseCommodityQuantityFrequency(const string &s)
Convert text to QuantExt::CommodityQuantityFrequency.
Definition: parsers.cpp:1192
+ Here is the call graph for this function:

◆ toXML()

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

Implements XMLSerializable.

Definition at line 292 of file commoditylegdata.cpp.

292 {
293
294 XMLNode* node = doc.allocNode("CommodityFloatingLegData");
295
296 XMLUtils::addChild(doc, node, "Name", name_);
297 XMLUtils::addChild(doc, node, "PriceType", to_string(priceType_));
298 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Quantities", "Quantity", quantities_, "startDate",
300 XMLUtils::addChild(doc, node, "CommodityQuantityFrequency", to_string(commodityQuantityFrequency_));
301 XMLUtils::addChild(doc, node, "CommodityPayRelativeTo", to_string(commodityPayRelativeTo_));
302
303 if (!spreads_.empty())
304 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Spreads", "Spread", spreads_, "startDate",
306
307 if (!gearings_.empty())
308 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Gearings", "Gearing", gearings_, "startDate",
310
311 XMLUtils::addChild(doc, node, "PricingDateRule", to_string(pricingDateRule_));
312
313 if (!pricingCalendar_.empty())
314 XMLUtils::addChild(doc, node, "PricingCalendar", pricingCalendar_);
315
316 XMLUtils::addChild(doc, node, "PricingLag", static_cast<int>(pricingLag_));
317
318 if (!pricingDates_.empty())
319 XMLUtils::addChildren(doc, node, "PricingDates", "PricingDate", pricingDates_);
320
321 XMLUtils::addChild(doc, node, "IsAveraged", isAveraged_);
322 XMLUtils::addChild(doc, node, "IsInArrears", isInArrears_);
323 XMLUtils::addChild(doc, node, "FutureMonthOffset", static_cast<int>(futureMonthOffset_));
324 XMLUtils::addChild(doc, node, "DeliveryRollDays", static_cast<int>(deliveryRollDays_));
325 XMLUtils::addChild(doc, node, "IncludePeriodEnd", includePeriodEnd_);
326 XMLUtils::addChild(doc, node, "ExcludePeriodStart", excludePeriodStart_);
327 if (hoursPerDay_ != Null<Natural>())
328 XMLUtils::addChild(doc, node, "HoursPerDay", static_cast<int>(hoursPerDay_));
329 XMLUtils::addChild(doc, node, "UseBusinessDays", useBusinessDays_);
330 if (!tag_.empty())
331 XMLUtils::addChild(doc, node, "Tag", tag_);
332 if (dailyExpiryOffset_ != Null<Natural>())
333 XMLUtils::addChild(doc, node, "DailyExpiryOffset", static_cast<int>(dailyExpiryOffset_));
335 XMLUtils::addChild(doc, node, "UnrealisedQuantity", unrealisedQuantity_);
336 if (lastNDays_ != Null<Natural>())
337 XMLUtils::addChild(doc, node, "LastNDays", static_cast<int>(lastNDays_));
338 if (!fxIndex_.empty())
339 XMLUtils::addChild(doc, node, "FXIndex", fxIndex_);
340
341 return node;
342}
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
static void addChildren(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values)
Definition: xmlutils.cpp:502
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

◆ name_

std::string name_
private

Definition at line 158 of file commoditylegdata.hpp.

◆ priceType_

CommodityPriceType priceType_
private

Definition at line 159 of file commoditylegdata.hpp.

◆ quantities_

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

Definition at line 160 of file commoditylegdata.hpp.

◆ quantityDates_

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

Definition at line 161 of file commoditylegdata.hpp.

◆ commodityQuantityFrequency_

QuantExt::CommodityQuantityFrequency commodityQuantityFrequency_
private

Definition at line 162 of file commoditylegdata.hpp.

◆ commodityPayRelativeTo_

CommodityPayRelativeTo commodityPayRelativeTo_
private

Definition at line 163 of file commoditylegdata.hpp.

◆ spreads_

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

Definition at line 164 of file commoditylegdata.hpp.

◆ spreadDates_

std::vector<std::string> spreadDates_
private

Definition at line 165 of file commoditylegdata.hpp.

◆ gearings_

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

Definition at line 166 of file commoditylegdata.hpp.

◆ gearingDates_

std::vector<std::string> gearingDates_
private

Definition at line 167 of file commoditylegdata.hpp.

◆ pricingDateRule_

CommodityPricingDateRule pricingDateRule_
private

Definition at line 168 of file commoditylegdata.hpp.

◆ pricingCalendar_

std::string pricingCalendar_
private

Definition at line 169 of file commoditylegdata.hpp.

◆ pricingLag_

QuantLib::Natural pricingLag_
private

Definition at line 170 of file commoditylegdata.hpp.

◆ pricingDates_

std::vector<std::string> pricingDates_
private

Definition at line 171 of file commoditylegdata.hpp.

◆ isAveraged_

bool isAveraged_
private

Definition at line 172 of file commoditylegdata.hpp.

◆ isInArrears_

bool isInArrears_
private

Definition at line 173 of file commoditylegdata.hpp.

◆ futureMonthOffset_

QuantLib::Natural futureMonthOffset_
private

Definition at line 174 of file commoditylegdata.hpp.

◆ deliveryRollDays_

QuantLib::Natural deliveryRollDays_
private

Definition at line 175 of file commoditylegdata.hpp.

◆ includePeriodEnd_

bool includePeriodEnd_
private

Definition at line 176 of file commoditylegdata.hpp.

◆ excludePeriodStart_

bool excludePeriodStart_
private

Definition at line 177 of file commoditylegdata.hpp.

◆ hoursPerDay_

QuantLib::Natural hoursPerDay_
private

Definition at line 178 of file commoditylegdata.hpp.

◆ useBusinessDays_

bool useBusinessDays_
private

Definition at line 179 of file commoditylegdata.hpp.

◆ tag_

std::string tag_
private

Definition at line 180 of file commoditylegdata.hpp.

◆ dailyExpiryOffset_

QuantLib::Natural dailyExpiryOffset_
private

Definition at line 181 of file commoditylegdata.hpp.

◆ unrealisedQuantity_

bool unrealisedQuantity_
private

Definition at line 182 of file commoditylegdata.hpp.

◆ lastNDays_

QuantLib::Natural lastNDays_
private

Definition at line 183 of file commoditylegdata.hpp.

◆ fxIndex_

std::string fxIndex_
private

Definition at line 184 of file commoditylegdata.hpp.