Skip to content

Commit bbb11c9

Browse files
pcaspersjenkins
authored andcommitted
QPR-12159 QPR-9557 update yield curve config
1 parent ece7be2 commit bbb11c9

2 files changed

Lines changed: 21 additions & 23 deletions

File tree

OREData/ored/configuration/yieldcurveconfig.cpp

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,11 @@ YieldCurveConfig::YieldCurveConfig(const string& curveID, const string& curveDes
217217
const vector<boost::shared_ptr<YieldCurveSegment>>& curveSegments,
218218
const string& interpolationVariable, const string& interpolationMethod,
219219
const string& zeroDayCounter, bool extrapolation,
220-
const BootstrapConfig& bootstrapConfig)
220+
const BootstrapConfig& bootstrapConfig, const Size mixedInterpolationCutoff)
221221
: CurveConfig(curveID, curveDescription), currency_(currency), discountCurveID_(discountCurveID),
222222
curveSegments_(curveSegments), interpolationVariable_(interpolationVariable),
223223
interpolationMethod_(interpolationMethod), zeroDayCounter_(zeroDayCounter), extrapolation_(extrapolation),
224-
bootstrapConfig_(bootstrapConfig) {
224+
bootstrapConfig_(bootstrapConfig), mixedInterpolationCutoff_(mixedInterpolationCutoff) {
225225
populateRequiredCurveIds();
226226
}
227227

@@ -309,26 +309,11 @@ void YieldCurveConfig::fromXML(XMLNode* node) {
309309
// Read in the optional nodes.
310310

311311
// Empty strings if not there (or if there and empty).
312-
interpolationVariable_ = XMLUtils::getChildValue(node, "InterpolationVariable", false);
313-
interpolationMethod_ = XMLUtils::getChildValue(node, "InterpolationMethod", false);
314-
zeroDayCounter_ = XMLUtils::getChildValue(node, "YieldCurveDayCounter", false);
315-
316-
// Add hardcoded defaults for now.
317-
if (interpolationVariable_.empty()) {
318-
interpolationVariable_ = "Discount";
319-
}
320-
if (interpolationMethod_.empty()) {
321-
interpolationMethod_ = interpolationVariable_ == "Zero" ? "Linear" : "LogLinear";
322-
}
323-
if (zeroDayCounter_.empty()) {
324-
zeroDayCounter_ = "A365";
325-
}
326-
XMLNode* nodeToTest = XMLUtils::getChildNode(node, "Extrapolation");
327-
if (nodeToTest) {
328-
extrapolation_ = XMLUtils::getChildValueAsBool(node, "Extrapolation", false);
329-
} else {
330-
extrapolation_ = true;
331-
}
312+
interpolationVariable_ = XMLUtils::getChildValue(node, "InterpolationVariable", false, "Discount");
313+
interpolationMethod_ = XMLUtils::getChildValue(node, "InterpolationMethod", false, interpolationVariable_ == "Zero" ? "Linear" : "LogLinear");
314+
mixedInterpolationCutoff_ = XMLUtils::getChildValueAsInt(node, "MixedInterpolationCutoff", false, 1);
315+
zeroDayCounter_ = XMLUtils::getChildValue(node, "YieldCurveDayCounter", false, "A365");
316+
extrapolation_ = XMLUtils::getChildValueAsBool(node, "Extrapolation", false, true);
332317

333318
// Optional bootstrap configuration
334319
if (XMLNode* n = XMLUtils::getChildNode(node, "BootstrapConfig")) {
@@ -367,6 +352,7 @@ XMLNode* YieldCurveConfig::toXML(XMLDocument& doc) {
367352
// Add the defaultable elements.
368353
XMLUtils::addChild(doc, node, "InterpolationVariable", interpolationVariable_);
369354
XMLUtils::addChild(doc, node, "InterpolationMethod", interpolationMethod_);
355+
XMLUtils::addChild(doc, node, "MixedInterpolationCutoff", (int)mixedInterpolationCutoff_);
370356
XMLUtils::addChild(doc, node, "YieldCurveDayCounter", zeroDayCounter_);
371357
XMLUtils::addChild(doc, node, "Tolerance", bootstrapConfig_.accuracy());
372358
XMLUtils::addChild(doc, node, "Extrapolation", extrapolation_);
@@ -447,6 +433,8 @@ void YieldCurveSegment::fromXML(XMLNode* node) {
447433
pillarChoice_ = parsePillarChoice(XMLUtils::getChildValue(node, "PillarChoice", false, "LastRelevantDate"));
448434
QL_REQUIRE(pillarChoice_ == QuantLib::Pillar::MaturityDate || pillarChoice_ == QuantLib::Pillar::LastRelevantDate,
449435
"PillarChoice " << pillarChoice_ << " not supported, expected MaturityDate, LastRelevantDate");
436+
priority_ = XMLUtils::getChildValueAsInt(node, "Priority", false, 0);
437+
minDistance_ = XMLUtils::getChildValueAsInt(node, "MinDistance", false, 1);
450438
}
451439

452440
XMLNode* YieldCurveSegment::toXML(XMLDocument& doc) {
@@ -481,6 +469,8 @@ XMLNode* YieldCurveSegment::toXML(XMLDocument& doc) {
481469
if (!conventionsID_.empty())
482470
XMLUtils::addChild(doc, node, "Conventions", conventionsID_);
483471
XMLUtils::addChild(doc, node, "PillarChoice", ore::data::to_string(pillarChoice_));
472+
XMLUtils::addChild(doc, node, "Priority", (int)priority_);
473+
XMLUtils::addChild(doc, node, "MinDistance", (int)minDistance_);
484474
return node;
485475
}
486476

OREData/ored/configuration/yieldcurveconfig.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ class YieldCurveSegment : public XMLSerializable {
9797
const string& typeID() const { return typeID_; }
9898
const string& conventionsID() const { return conventionsID_; }
9999
const QuantLib::Pillar::Choice pillarChoice() const { return pillarChoice_; }
100+
Size priority() const { return priority_; }
101+
Size minDistance() const { return minDistance_; }
100102
const vector<pair<string, bool>>& quotes() const { return quotes_; }
101103
//@}
102104

@@ -130,6 +132,8 @@ class YieldCurveSegment : public XMLSerializable {
130132
string typeID_;
131133
string conventionsID_;
132134
QuantLib::Pillar::Choice pillarChoice_ = QuantLib::Pillar::LastRelevantDate;
135+
Size priority_ = 0;
136+
Size minDistance_ = 1;
133137
};
134138

135139
//! Direct yield curve segment
@@ -656,7 +660,8 @@ class YieldCurveConfig : public CurveConfig {
656660
const string& discountCurveID, const vector<boost::shared_ptr<YieldCurveSegment>>& curveSegments,
657661
const string& interpolationVariable = "Discount", const string& interpolationMethod = "LogLinear",
658662
const string& zeroDayCounter = "A365", bool extrapolation = true,
659-
const BootstrapConfig& bootstrapConfig = BootstrapConfig());
663+
const BootstrapConfig& bootstrapConfig = BootstrapConfig(),
664+
const Size mixedInterpolationCutoff = 1);
660665
//! Default destructor
661666
virtual ~YieldCurveConfig() {}
662667
//@}
@@ -674,6 +679,7 @@ class YieldCurveConfig : public CurveConfig {
674679
const vector<boost::shared_ptr<YieldCurveSegment>>& curveSegments() const { return curveSegments_; }
675680
const string& interpolationVariable() const { return interpolationVariable_; }
676681
const string& interpolationMethod() const { return interpolationMethod_; }
682+
Size mixedInterpolationCutoff() const { return mixedInterpolationCutoff_; }
677683
const string& zeroDayCounter() const { return zeroDayCounter_; }
678684
bool extrapolation() const { return extrapolation_; }
679685
const BootstrapConfig& bootstrapConfig() const { return bootstrapConfig_; }
@@ -683,6 +689,7 @@ class YieldCurveConfig : public CurveConfig {
683689
//@{
684690
string& interpolationVariable() { return interpolationVariable_; }
685691
string& interpolationMethod() { return interpolationMethod_; }
692+
Size& mixedInterpolationCutoff() { return mixedInterpolationCutoff_; }
686693
string& zeroDayCounter() { return zeroDayCounter_; }
687694
bool& extrapolation() { return extrapolation_; }
688695
void setBootstrapConfig(const BootstrapConfig& bootstrapConfig) { bootstrapConfig_ = bootstrapConfig; }
@@ -704,6 +711,7 @@ class YieldCurveConfig : public CurveConfig {
704711
string zeroDayCounter_;
705712
bool extrapolation_;
706713
BootstrapConfig bootstrapConfig_;
714+
Size mixedInterpolationCutoff_;
707715
};
708716

709717
// Map form curveID to YieldCurveConfig

0 commit comments

Comments
 (0)