32 const vector<string>& peakQuotes) : offPeakQuotes_(offPeakQuotes), peakQuotes_(peakQuotes) {}
52 const boost::optional<unsigned short>& priority,
const boost::optional<OffPeakDaily>& offPeakDaily,
53 const string& peakPriceCurveId,
const string& peakPriceCalendar)
54 : strType_(type), conventionsId_(conventionsId), quotes_(quotes), priority_(priority),
55 offPeakDaily_(offPeakDaily), peakPriceCurveId_(peakPriceCurveId),
58 QL_REQUIRE(
offPeakDaily_,
"When price segment type is OffPeakPowerDaily, OffPeakDaily is required.");
112 QL_REQUIRE(n,
"When price segment type is OffPeakPowerDaily, an OffPeakDaily node is required.");
124 set<string>
quotes{ opqs.begin(), opqs.end() };
126 quotes.insert(pqs.begin(), pqs.end());
156 const string& currency,
const vector<string>& quotes,
157 const string& commoditySpotQuote,
const string& dayCountId,
158 const string& interpolationMethod,
bool extrapolation,
159 const string& conventionsId)
160 :
CurveConfig(curveId, curveDescription), type_(
Type::Direct), fwdQuotes_(quotes), currency_(currency),
161 commoditySpotQuoteId_(commoditySpotQuote), dayCountId_(dayCountId), interpolationMethod_(interpolationMethod),
162 extrapolation_(extrapolation), conventionsId_(conventionsId), addBasis_(true), monthOffset_(0),
166 if (!commoditySpotQuote.empty()) {
172 const string& currency,
const string& basePriceCurveId,
173 const string& baseYieldCurveId,
const string& yieldCurveId,
175 :
CurveConfig(curveId, curveDescription), type_(
Type::CrossCurrency), currency_(currency),
176 basePriceCurveId_(basePriceCurveId), baseYieldCurveId_(baseYieldCurveId), yieldCurveId_(yieldCurveId),
177 extrapolation_(extrapolation), addBasis_(true), monthOffset_(0), averageBase_(true), priceAsHistFixing_(true) {
182 const string& currency,
const string& basePriceCurveId,
183 const string& baseConventionsId,
const vector<string>& basisQuotes,
184 const string& basisConventionsId,
const string& dayCountId,
185 const string& interpolationMethod,
bool extrapolation,
bool addBasis,
186 QuantLib::Natural monthOffset,
bool averageBase)
187 :
CurveConfig(curveId, curveDescription), type_(
Type::Basis), fwdQuotes_(basisQuotes), currency_(currency),
188 dayCountId_(dayCountId), interpolationMethod_(interpolationMethod), basePriceCurveId_(basePriceCurveId),
189 extrapolation_(extrapolation), conventionsId_(basisConventionsId), baseConventionsId_(baseConventionsId),
190 addBasis_(addBasis), monthOffset_(monthOffset), averageBase_(averageBase), priceAsHistFixing_(true) {
195 const string& currency,
const vector<PriceSegment>& priceSegments,
196 const string& dayCountId,
const string& interpolationMethod,
197 bool extrapolation,
const boost::optional<BootstrapConfig>& bootstrapConfig)
199 interpolationMethod_(interpolationMethod), extrapolation_(extrapolation), addBasis_(true), monthOffset_(0),
200 averageBase_(true), priceAsHistFixing_(true), bootstrapConfig_(bootstrapConfig) {
339 QL_REQUIRE(!
priceSegments.empty(),
"Need at least one price segment for a Piecewise commodity curve.");
348 QL_REQUIRE(!it->peakPriceCurveId().empty(),
"An AveragingOffPeakPower price segment should have" <<
349 " a non empty PeakPriceCurveId");
357 if (it->priority()) {
358 unsigned short p = *it->priority();
359 QL_REQUIRE(
priceSegments_.count(p) == 0,
"CommodityCurveConfig: already configured a price segment " <<
360 "with priority " << p <<
" for commodity curve configuration " <<
curveID() <<
".");
370 unsigned short largestPriority = 0;
376 QL_REQUIRE(
priceSegments.size() <=
static_cast<unsigned short>(std::numeric_limits<unsigned short>::max() - largestPriority),
377 "Largest price segment priority (" << largestPriority <<
") and number of segments without a " <<
378 "priority (" <<
priceSegments.size() <<
") combine to give a value too large for unsigned short.");
void populateRequiredCurveIds()
Populate any dependent curve IDs.
std::string interpolationMethod_
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.
std::string basePriceCurveId_
void fromXML(XMLNode *node) override
std::string commoditySpotQuoteId_
XMLNode * toXML(XMLDocument &doc) const override
std::string baseYieldCurveId_
vector< string > fwdQuotes_
std::map< unsigned short, PriceSegment > priceSegments_
boost::optional< BootstrapConfig > bootstrapConfig_
QuantLib::Natural monthOffset_
CommodityCurveConfig()
Default constructor.
std::string baseConventionsId_
std::string yieldCurveId_
std::string conventionsId_
Base curve configuration.
const string & curveID() const
virtual const vector< string > & quotes()
Return all the market quotes required for this config.
map< CurveSpec::CurveType, set< string > > requiredCurveIds_
Class to store quotes used in building daily off-peak power quotes.
OffPeakDaily()
Constructor.
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
const boost::optional< unsigned short > & priority() const
std::string peakPriceCurveId_
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_
std::string peakPriceCalendar_
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
const std::string & conventionsId() const
const std::vector< std::string > & quotes() const
std::string conventionsId_
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
static void addChildren(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values)
static void checkNode(XMLNode *n, const string &expectedName)
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static string getNodeValue(XMLNode *node)
Get a node's value.
static int getChildValueAsInt(XMLNode *node, const string &name, bool mandatory=false, int defaultValue=0)
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
static vector< string > getChildrenValues(XMLNode *node, const string &names, const string &name, bool mandatory=false)
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
Commodity curve configuration class.
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
PriceSegment::Type parsePriceSegmentType(const string &s)
Convert text to PriceSegment::Type.
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.