Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commoditylegdata.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file ored/portfolio/commoditylegdata.hpp
20 \brief leg data for commodity leg types
21 \ingroup portfolio
22*/
23
24#pragma once
25
29
30namespace ore {
31namespace data {
32
38};
40std::ostream& operator<<(std::ostream& out, const CommodityPayRelativeTo& cprt);
41
44std::ostream& operator<<(std::ostream& out, const CommodityPriceType& cpt);
45
48std::ostream& operator<<(std::ostream& out, const CommodityPricingDateRule& cpdr);
49
51
52public:
53 //! Default constructor
55
56 //! Detailed constructor
57 CommodityFixedLegData(const std::vector<QuantLib::Real>& quantities, const std::vector<std::string>& quantityDates,
58 const std::vector<QuantLib::Real>& prices, const std::vector<std::string>& priceDates,
59 CommodityPayRelativeTo commodityPayRelativeTo, const std::string& tag = "");
60
61 //! \name Inspectors
62 //@{
63 const std::vector<QuantLib::Real>& quantities() const { return quantities_; }
64 const std::vector<std::string>& quantityDates() const { return quantityDates_; }
65 const std::vector<QuantLib::Real>& prices() const { return prices_; }
66 const std::vector<std::string>& priceDates() const { return priceDates_; }
68 const std::string& tag() const { return tag_; }
69 //@}
70
71 /*! \brief Set the fixed leg data quantities.
72
73 For commodity swaps, there can be a number of conventions provided with the floating leg data quantities that
74 when taken together can be used to calculate the commodity quantity for the full calculation period. Instead
75 of duplicating that data here, we allow the fixed leg data quantities to be set using this method before being
76 passed to the commodity fixed leg builder. The idea is that the quantities will be set by referencing the
77 quantities from the corresponding floating leg of the swap after that leg has been built.
78 */
79 void setQuantities(const std::vector<QuantLib::Real>& quantities);
80
81 //! \name Serialisation
82 //@{
83 void fromXML(ore::data::XMLNode* node) override;
85 //@}
86
87private:
88 std::vector<QuantLib::Real> quantities_;
89 std::vector<std::string> quantityDates_;
90 std::vector<QuantLib::Real> prices_;
91 std::vector<std::string> priceDates_;
93 std::string tag_;
94};
95
97
98public:
99 //! Default constructor
101
102 //! Constructor
104 const std::string& name, CommodityPriceType priceType, const std::vector<QuantLib::Real>& quantities,
105 const std::vector<std::string>& quantityDates,
107 QuantExt::CommodityQuantityFrequency::PerCalculationPeriod,
109 const std::vector<QuantLib::Real>& spreads = {}, const std::vector<std::string>& spreadDates = {},
110 const std::vector<QuantLib::Real>& gearings = {}, const std::vector<std::string>& gearingDates = {},
112 const std::string& pricingCalendar = "", QuantLib::Natural pricingLag = 0,
113 const std::vector<std::string>& pricingDates = {}, bool isAveraged = false, bool isInArrears = true,
114 QuantLib::Natural futureMonthOffset = 0, QuantLib::Natural deliveryRollDays = 0, bool includePeriodEnd = true,
115 bool excludePeriodStart = true, QuantLib::Natural hoursPerDay = QuantLib::Null<QuantLib::Natural>(),
116 bool useBusinessDays = true, const std::string& tag = "", QuantLib::Natural dailyExpiryOffset =
117 QuantLib::Null<QuantLib::Natural>(), bool unrealisedQuantity = false,
118 QuantLib::Natural lastNDays = QuantLib::Null<QuantLib::Natural>(), std::string fxIndex = "");
119
120 //! \name Inspectors
121 //@{
122 const std::string& name() const { return name_; }
124 const std::vector<QuantLib::Real>& quantities() const { return quantities_; }
125 const std::vector<std::string>& quantityDates() const { return quantityDates_; }
128 const std::vector<QuantLib::Real>& spreads() const { return spreads_; }
129 const std::vector<std::string>& spreadDates() const { return spreadDates_; }
130 const std::vector<QuantLib::Real>& gearings() const { return gearings_; }
131 const std::vector<std::string>& gearingDates() const { return gearingDates_; }
133 const std::string& pricingCalendar() const { return pricingCalendar_; }
134 QuantLib::Natural pricingLag() const { return pricingLag_; }
135 const std::vector<std::string>& pricingDates() const { return pricingDates_; }
136 bool isAveraged() const { return isAveraged_; }
137 bool isInArrears() const { return isInArrears_; }
138 QuantLib::Natural futureMonthOffset() const { return futureMonthOffset_; }
139 QuantLib::Natural deliveryRollDays() const { return deliveryRollDays_; }
140 bool includePeriodEnd() const { return includePeriodEnd_; }
142 QuantLib::Natural hoursPerDay() const { return hoursPerDay_; }
143 bool useBusinessDays() const { return useBusinessDays_; }
144 const std::string& tag() const { return tag_; }
145 QuantLib::Natural dailyExpiryOffset() const { return dailyExpiryOffset_; }
147 QuantLib::Natural lastNDays() const { return lastNDays_; }
148 std::string const& fxIndex() const { return fxIndex_; }
149 //@}
150
151 //! \name Serialisation
152 //@{
153 void fromXML(ore::data::XMLNode* node) override;
154 ore::data::XMLNode* toXML(ore::data::XMLDocument& doc) const override;
155 //@}
156
157private:
158 std::string name_;
160 std::vector<QuantLib::Real> quantities_;
161 std::vector<std::string> quantityDates_;
164 std::vector<QuantLib::Real> spreads_;
165 std::vector<std::string> spreadDates_;
166 std::vector<QuantLib::Real> gearings_;
167 std::vector<std::string> gearingDates_;
169 std::string pricingCalendar_;
170 QuantLib::Natural pricingLag_;
171 std::vector<std::string> pricingDates_;
174 QuantLib::Natural futureMonthOffset_;
175 QuantLib::Natural deliveryRollDays_;
178 QuantLib::Natural hoursPerDay_;
180 std::string tag_;
181 QuantLib::Natural dailyExpiryOffset_;
183 QuantLib::Natural lastNDays_;
184 std::string fxIndex_;
185};
186
187} // namespace data
188} // namespace ore
CommodityFixedLegData()
Default constructor.
void setQuantities(const std::vector< QuantLib::Real > &quantities)
Set the fixed leg data quantities.
std::vector< std::string > priceDates_
void fromXML(ore::data::XMLNode *node) override
const std::vector< std::string > & quantityDates() const
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.
std::vector< std::string > quantityDates_
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
const std::string & tag() const
std::vector< QuantLib::Real > prices_
const std::vector< std::string > & priceDates() const
std::vector< QuantLib::Real > quantities_
const std::vector< QuantLib::Real > & prices() const
CommodityPayRelativeTo commodityPayRelativeTo_
const std::vector< QuantLib::Real > & quantities() const
CommodityPayRelativeTo commodityPayRelativeTo() const
const std::vector< std::string > & pricingDates() const
std::string const & fxIndex() const
const std::vector< QuantLib::Real > & gearings() const
const std::vector< QuantLib::Real > & spreads() const
CommodityFloatingLegData()
Default constructor.
const std::string & name() const
QuantLib::Natural pricingLag() const
QuantLib::Natural dailyExpiryOffset() const
QuantExt::CommodityQuantityFrequency commodityQuantityFrequency_
const std::string & pricingCalendar() const
QuantLib::Natural hoursPerDay() const
const std::vector< std::string > & gearingDates() const
void fromXML(ore::data::XMLNode *node) override
std::vector< std::string > pricingDates_
CommodityPricingDateRule pricingDateRule_
std::vector< std::string > gearingDates_
QuantExt::CommodityQuantityFrequency commodityQuantityFrequency() const
const std::vector< std::string > & quantityDates() const
std::vector< std::string > quantityDates_
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
const std::string & tag() const
CommodityPriceType priceType() const
QuantLib::Natural deliveryRollDays() const
std::vector< QuantLib::Real > quantities_
QuantLib::Natural futureMonthOffset() const
std::vector< std::string > spreadDates_
CommodityPayRelativeTo commodityPayRelativeTo_
CommodityPricingDateRule pricingDateRule() const
const std::vector< QuantLib::Real > & quantities() const
std::vector< QuantLib::Real > spreads_
std::vector< QuantLib::Real > gearings_
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.
QuantLib::Natural lastNDays() const
CommodityPayRelativeTo commodityPayRelativeTo() const
const std::vector< std::string > & spreadDates() const
Serializable Additional Leg Data.
Definition: legdata.hpp:63
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
leg data model and serialization
@ data
Definition: log.hpp:77
CommodityQuantityFrequency
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
CommodityPricingDateRule parseCommodityPricingDateRule(const string &s)
CommodityPriceType parseCommodityPriceType(const string &s)
CommodityPayRelativeTo parseCommodityPayRelativeTo(const string &s)
Serializable Credit Default Swap.
Definition: namespaces.docs:23