Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commoditycurveconfig.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 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/configuration/commoditycurveconfig.hpp
20 \brief Commodity curve configuration class
21 \ingroup configuration
22*/
23
24#pragma once
25
28#include <boost/optional/optional.hpp>
29
30namespace ore {
31namespace data {
32
33/*! Class for holding information on a set of instruments used in bootstrapping a piecewise price curve.
34 \ingroup configuration
35*/
37public:
38 //! Type of price segment being represented, i.e. type of instrument in the price segment.
40
41 //! Class to store quotes used in building daily off-peak power quotes.
43 public:
44 //! Constructor.
46
47 //! Detailed constructor.
49 const std::vector<std::string>& offPeakQuotes,
50 const std::vector<std::string>& peakQuotes);
51
52 const std::vector<std::string>& offPeakQuotes() const { return offPeakQuotes_; }
53 const std::vector<std::string>& peakQuotes() const { return peakQuotes_; }
54
55 void fromXML(XMLNode* node) override;
56 XMLNode* toXML(XMLDocument& doc) const override;
57
58 private:
59 std::vector<std::string> offPeakQuotes_;
60 std::vector<std::string> peakQuotes_;
61 };
62
63 //! \name Constructors
64 //@{
65 //! Default constructor
67 //! Detailed constructor
68 PriceSegment(const std::string& type,
69 const std::string& conventionsId,
70 const std::vector<std::string>& quotes,
71 const boost::optional<unsigned short>& priority = boost::none,
72 const boost::optional<OffPeakDaily>& offPeakDaily = boost::none,
73 const std::string& peakPriceCurveId = "",
74 const std::string& peakPriceCalendar = "");
75 //@}
76
77 //! \name Inspectors
78 //@{
79 Type type() const;
80 const std::string& conventionsId() const;
81 const std::vector<std::string>& quotes() const;
82 const boost::optional<unsigned short>& priority() const;
83 const boost::optional<OffPeakDaily>& offPeakDaily() const;
84 const std::string& peakPriceCurveId() const;
85 const std::string& peakPriceCalendar() const;
86 bool empty() const;
87 //@}
88
89 //! \name Serialisation
90 //@{
91 void fromXML(XMLNode* node) override;
92 XMLNode* toXML(XMLDocument& doc) const override;
93 //@}
94
95private:
96 //! Populate quotes
97 void populateQuotes();
98
99 std::string strType_;
100 std::string conventionsId_;
101 std::vector<std::string> quotes_;
102 boost::optional<unsigned short> priority_;
103 boost::optional<OffPeakDaily> offPeakDaily_;
104 std::string peakPriceCurveId_;
106
107 bool empty_;
109};
110
111//! Commodity curve configuration
112/*!
113 \ingroup configuration
114*/
116public:
117 /*! The type of commodity curve that has been configured:
118 - Direct: if the commodity price curve is built from commodity forward quotes
119 - CrossCurrency: if the commodity price curve is implied from a price curve in a different currency
120 - Basis: if the commodity price curve is built from basis quotes
121 - Piecewise: if the commodity price curve is bootstrapped from sets of instruments
122 */
124
125 //! \name Constructors
126 //@{
127 //! Default constructor
129 monthOffset_(0), averageBase_(true) {}
130
131 //! Detailed constructor for Direct commodity curve configuration
132 CommodityCurveConfig(const std::string& curveId, const std::string& curveDescription, const std::string& currency,
133 const std::vector<std::string>& quotes, const std::string& commoditySpotQuote = "",
134 const std::string& dayCountId = "A365", const std::string& interpolationMethod = "Linear",
135 bool extrapolation = true, const std::string& conventionsId = "");
136
137 //! Detailed constructor for CrossCurrency commodity curve configuration
138 CommodityCurveConfig(const std::string& curveId, const std::string& curveDescription, const std::string& currency,
139 const std::string& basePriceCurveId, const std::string& baseYieldCurveId,
140 const std::string& yieldCurveId, bool extrapolation = true);
141
142 //! Detailed constructor for Basis commodity curve configuration
143 CommodityCurveConfig(const std::string& curveId, const std::string& curveDescription, const std::string& currency,
144 const std::string& basePriceCurveId, const std::string& baseConventionsId,
145 const std::vector<std::string>& basisQuotes, const std::string& basisConventionsId,
146 const std::string& dayCountId = "A365", const std::string& interpolationMethod = "Linear",
147 bool extrapolation = true, bool addBasis = true, QuantLib::Natural monthOffset = 0,
148 bool averageBase = true);
149
150 //! Detailed constructor for Piecewise commodity curve configuration
151 CommodityCurveConfig(const std::string& curveId, const std::string& curveDescription, const std::string& currency,
152 const std::vector<PriceSegment>& priceSegments, const std::string& dayCountId = "A365",
153 const std::string& interpolationMethod = "Linear", bool extrapolation = true,
154 const boost::optional<BootstrapConfig>& bootstrapConfig = boost::none);
155 //@}
156
157 //! \name Serialisation
158 //@{
159 void fromXML(XMLNode* node) override;
160 XMLNode* toXML(XMLDocument& doc) const override;
161 //@}
162
163 //! \name Inspectors
164 //@{
165 const Type& type() const { return type_; }
166 const std::string& currency() const { return currency_; }
167 const std::string& commoditySpotQuoteId() const { return commoditySpotQuoteId_; }
168 const std::string& dayCountId() const { return dayCountId_; }
169 const std::string& interpolationMethod() const { return interpolationMethod_; }
170 const std::string& basePriceCurveId() const { return basePriceCurveId_; }
171 const std::string& baseYieldCurveId() const { return baseYieldCurveId_; }
172 const std::string& yieldCurveId() const { return yieldCurveId_; }
173 bool extrapolation() const { return extrapolation_; }
174 const vector<string>& fwdQuotes() const { return fwdQuotes_; }
175 const std::string& conventionsId() const { return conventionsId_; }
176 const std::string& baseConventionsId() const { return baseConventionsId_; }
177 bool addBasis() const { return addBasis_; }
178 QuantLib::Natural monthOffset() const { return monthOffset_; }
179 bool averageBase() const { return averageBase_; }
180 bool priceAsHistFixing() const { return priceAsHistFixing_; }
181 const std::map<unsigned short, PriceSegment>& priceSegments() const { return priceSegments_; }
182 const boost::optional<BootstrapConfig>& bootstrapConfig() const { return bootstrapConfig_; }
183 //@}
184
185 //! \name Setters
186 //@{
187 Type& type() { return type_; }
188 std::string& currency() { return currency_; }
190 std::string& dayCountId() { return dayCountId_; }
191 std::string& interpolationMethod() { return interpolationMethod_; }
192 std::string& basePriceCurveId() { return basePriceCurveId_; }
193 std::string& baseYieldCurveId() { return baseYieldCurveId_; }
194 std::string& yieldCurveId() { return yieldCurveId_; }
195 bool& extrapolation() { return extrapolation_; }
196 std::string& conventionsId() { return conventionsId_; }
197 std::string& baseConventionsId() { return baseConventionsId_; }
198 bool& addBasis() { return addBasis_; }
199 QuantLib::Natural& monthOffset() { return monthOffset_; }
200 bool& averageBase() { return averageBase_; }
202 void setPriceSegments(const std::map<unsigned short, PriceSegment>& priceSegments) {
204 }
206 //@}
207
208private:
209 //! Populate any dependent curve IDs.
211
212 //! Process price segments when configuring a Piecewise curve.
213 void processSegments(std::vector<PriceSegment> priceSegments);
214
216 vector<string> fwdQuotes_;
217 std::string currency_;
219 std::string dayCountId_;
221 std::string basePriceCurveId_;
222 std::string baseYieldCurveId_;
223 std::string yieldCurveId_;
225 std::string conventionsId_;
228 QuantLib::Natural monthOffset_;
231 /*! The map key is the internal priority of the price segment and does not necessarily map the PriceSegment's
232 priority member value. We are allowing here for the priority to be unspecified in the PriceSegment during
233 configuration.
234 */
235 std::map<unsigned short, PriceSegment> priceSegments_;
236 boost::optional<BootstrapConfig> bootstrapConfig_;
237};
238
239} // namespace data
240} // namespace ore
Class for holding bootstrap configurations.
Commodity curve configuration.
void populateRequiredCurveIds()
Populate any dependent curve IDs.
const std::string & conventionsId() const
const std::string & currency() const
const std::string & baseYieldCurveId() const
const std::string & basePriceCurveId() const
const std::string & yieldCurveId() const
const std::map< unsigned short, PriceSegment > & priceSegments() const
void processSegments(std::vector< PriceSegment > priceSegments)
Process price segments when configuring a Piecewise curve.
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
void setBootstrapConfig(const BootstrapConfig &bootstrapConfig)
const boost::optional< BootstrapConfig > & bootstrapConfig() const
std::map< unsigned short, PriceSegment > priceSegments_
boost::optional< BootstrapConfig > bootstrapConfig_
const vector< string > & fwdQuotes() const
CommodityCurveConfig()
Default constructor.
QuantLib::Natural monthOffset() const
const std::string & baseConventionsId() const
const std::string & interpolationMethod() const
void setPriceSegments(const std::map< unsigned short, PriceSegment > &priceSegments)
const std::string & dayCountId() const
const std::string & commoditySpotQuoteId() const
Base curve configuration.
Definition: curveconfig.hpp:41
const string & curveDescription() const
Definition: curveconfig.hpp:55
virtual const vector< string > & quotes()
Return all the market quotes required for this config.
Definition: curveconfig.hpp:69
Class to store quotes used in building daily off-peak power quotes.
const std::vector< std::string > & offPeakQuotes() const
XMLNode * toXML(XMLDocument &doc) const override
const std::vector< std::string > & peakQuotes() const
const boost::optional< unsigned short > & priority() const
void populateQuotes()
Populate quotes.
Type
Type of price segment being represented, i.e. type of instrument in the price segment.
const std::string & peakPriceCalendar() const
const boost::optional< OffPeakDaily > & offPeakDaily() const
boost::optional< OffPeakDaily > offPeakDaily_
const std::string & peakPriceCurveId() const
PriceSegment()
Default constructor.
std::vector< std::string > quotes_
boost::optional< unsigned short > priority_
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
const std::string & conventionsId() const
const std::vector< std::string > & quotes() const
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
Base class for all serializable classes.
Definition: xmlutils.hpp:101
Base curve configuration classes.
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23