Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
List of all members
YieldCurveConfig Class Reference

Yield Curve configuration. More...

#include <ored/configuration/yieldcurveconfig.hpp>

+ Inheritance diagram for YieldCurveConfig:
+ Collaboration diagram for YieldCurveConfig:

Public Member Functions

Constructors/Destructors
 YieldCurveConfig ()
 Default constructor. More...
 
 YieldCurveConfig (const string &curveID, const string &curveDescription, const string &currency, const string &discountCurveID, const vector< QuantLib::ext::shared_ptr< YieldCurveSegment > > &curveSegments, const string &interpolationVariable="Discount", const string &interpolationMethod="LogLinear", const string &zeroDayCounter="A365", bool extrapolation=true, const BootstrapConfig &bootstrapConfig=BootstrapConfig(), const Size mixedInterpolationCutoff=1)
 Detailed constructor. More...
 
virtual ~YieldCurveConfig ()
 Default destructor. More...
 
Serialization
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (XMLDocument &doc) const override
 
Inspectors
const string & currency () const
 
const string & discountCurveID () const
 
const vector< QuantLib::ext::shared_ptr< YieldCurveSegment > > & curveSegments () const
 
const string & interpolationVariable () const
 
const string & interpolationMethod () const
 
Size mixedInterpolationCutoff () const
 
const string & zeroDayCounter () const
 
bool extrapolation () const
 
const BootstrapConfigbootstrapConfig () const
 
- Public Member Functions inherited from CurveConfig
 CurveConfig (const string &curveID, const string &curveDescription, const vector< string > &quotes=vector< string >())
 Detailed constructor. More...
 
 CurveConfig ()
 Default constructor. More...
 
const string & curveID () const
 
const string & curveDescription () const
 
const set< string > & requiredCurveIds (const CurveSpec::CurveType &curveType) const
 
const map< CurveSpec::CurveType, set< string > > & requiredCurveIds () const
 
string & curveID ()
 
string & curveDescription ()
 
set< string > & requiredCurveIds (const CurveSpec::CurveType &curveType)
 
map< CurveSpec::CurveType, set< string > > & requiredCurveIds ()
 
- 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...
 

Setters

string currency_
 
string discountCurveID_
 
vector< QuantLib::ext::shared_ptr< YieldCurveSegment > > curveSegments_
 
string interpolationVariable_
 
string interpolationMethod_
 
string zeroDayCounter_
 
bool extrapolation_
 
BootstrapConfig bootstrapConfig_
 
Size mixedInterpolationCutoff_
 
string & interpolationVariable ()
 
string & interpolationMethod ()
 
Size & mixedInterpolationCutoff ()
 
string & zeroDayCounter ()
 
boolextrapolation ()
 
void setBootstrapConfig (const BootstrapConfig &bootstrapConfig)
 
const vector< string > & quotes () override
 Return all the market quotes required for this config. More...
 
void populateRequiredCurveIds ()
 

Additional Inherited Members

- Protected Attributes inherited from CurveConfig
string curveID_
 
string curveDescription_
 
vector< string > quotes_
 
map< CurveSpec::CurveType, set< string > > requiredCurveIds_
 

Detailed Description

Yield Curve configuration.

Wrapper class containing all yield curve segments needed to build a yield curve.

Definition at line 648 of file yieldcurveconfig.hpp.

Constructor & Destructor Documentation

◆ YieldCurveConfig() [1/2]

Default constructor.

Definition at line 653 of file yieldcurveconfig.hpp.

653{}

◆ YieldCurveConfig() [2/2]

YieldCurveConfig ( const string &  curveID,
const string &  curveDescription,
const string &  currency,
const string &  discountCurveID,
const vector< QuantLib::ext::shared_ptr< YieldCurveSegment > > &  curveSegments,
const string &  interpolationVariable = "Discount",
const string &  interpolationMethod = "LogLinear",
const string &  zeroDayCounter = "A365",
bool  extrapolation = true,
const BootstrapConfig bootstrapConfig = BootstrapConfig(),
const Size  mixedInterpolationCutoff = 1 
)

Detailed constructor.

Definition at line 215 of file yieldcurveconfig.cpp.

226}
const string & curveDescription() const
Definition: curveconfig.hpp:55
const string & curveID() const
Definition: curveconfig.hpp:54
CurveConfig()
Default constructor.
Definition: curveconfig.hpp:49
const string & currency() const
const string & discountCurveID() const
const string & zeroDayCounter() const
const BootstrapConfig & bootstrapConfig() const
const vector< QuantLib::ext::shared_ptr< YieldCurveSegment > > & curveSegments() const
vector< QuantLib::ext::shared_ptr< YieldCurveSegment > > curveSegments_
const string & interpolationVariable() const
const string & interpolationMethod() const
+ Here is the call graph for this function:

◆ ~YieldCurveConfig()

virtual ~YieldCurveConfig ( )
virtual

Default destructor.

Definition at line 662 of file yieldcurveconfig.hpp.

662{}

Member Function Documentation

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 246 of file yieldcurveconfig.cpp.

246 {
247
248 XMLUtils::checkNode(node, "YieldCurve");
249
250 // Read in the mandatory nodes.
251 curveID_ = XMLUtils::getChildValue(node, "CurveId", true);
252 curveDescription_ = XMLUtils::getChildValue(node, "CurveDescription", true);
253 currency_ = XMLUtils::getChildValue(node, "Currency", true);
254 discountCurveID_ = XMLUtils::getChildValue(node, "DiscountCurve", true);
255
256 // Read in the segments.
257 XMLNode* segmentsNode = XMLUtils::getChildNode(node, "Segments");
258 if (segmentsNode) {
259 for (XMLNode* child = XMLUtils::getChildNode(segmentsNode); child; child = XMLUtils::getNextSibling(child)) {
260
261 QuantLib::ext::shared_ptr<YieldCurveSegment> segment;
262 string childName = XMLUtils::getNodeName(child);
263
264 if (childName == "Direct") {
265 segment.reset(new DirectYieldCurveSegment());
266 } else if (childName == "Simple") {
267 segment.reset(new SimpleYieldCurveSegment());
268 } else if (childName == "AverageOIS") {
269 segment.reset(new AverageOISYieldCurveSegment());
270 } else if (childName == "TenorBasis") {
271 segment.reset(new TenorBasisYieldCurveSegment());
272 } else if (childName == "CrossCurrency") {
273 segment.reset(new CrossCcyYieldCurveSegment());
274 } else if (childName == "ZeroSpread") {
275 segment.reset(new ZeroSpreadedYieldCurveSegment());
276 } else if (childName == "DiscountRatio") {
277 segment.reset(new DiscountRatioYieldCurveSegment());
278 } else if (childName == "FittedBond") {
279 segment.reset(new FittedBondYieldCurveSegment());
280 } else if (childName == "BondYieldShifted") {
281 segment.reset(new BondYieldShiftedYieldCurveSegment());
282 } else if (childName == "WeightedAverage") {
283 segment.reset(new WeightedAverageYieldCurveSegment());
284 } else if (childName == "YieldPlusDefault") {
285 segment.reset(new YieldPlusDefaultYieldCurveSegment());
286 } else if(childName == "IborFallback"){
287 segment.reset(new IborFallbackCurveSegment());
288 } else {
289 QL_FAIL("Yield curve segment node name '" << childName << "' not recognized.");
290 }
291
292 if (segment) {
293 try {
294 segment->fromXML(child);
295 } catch (std::exception& ex) {
296 QL_FAIL("Exception parsing yield curve segment XML Node, name = "
297 << childName << " and curveID = " << curveID_ << " : " << ex.what());
298 }
299 } else {
300 QL_FAIL("Unable to build yield curve segment for name = " << childName
301 << " and curveID = " << curveID_);
302 }
303 curveSegments_.push_back(segment);
304 }
305 } else {
306 QL_FAIL("No Segments node in XML doc for yield curve ID = " << curveID_);
307 }
308
309 // Read in the optional nodes.
310
311 // Empty strings if not there (or if there and empty).
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);
317
318 // Optional bootstrap configuration
319 if (XMLNode* n = XMLUtils::getChildNode(node, "BootstrapConfig")) {
321 }
322
323 // Tolerance is deprecated in favour of Accuracy in BootstrapConfig. However, if it is
324 // still provided, use it as the accuracy and global accuracy in the bootstrap.
325 if (XMLUtils::getChildNode(node, "Tolerance")) {
326 Real accuracy = XMLUtils::getChildValueAsDouble(node, "Tolerance", false);
328 BootstrapConfig(accuracy, accuracy, bootstrapConfig_.dontThrow(), bootstrapConfig_.maxAttempts(),
330 }
331
333}
QuantLib::Real maxFactor() const
void fromXML(ore::data::XMLNode *node) override
QuantLib::Real minFactor() const
QuantLib::Size maxAttempts() const
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
Definition: xmlutils.cpp:286
static string getNodeName(XMLNode *n)
Get and set a node's name.
Definition: xmlutils.cpp:473
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
Definition: xmlutils.cpp:296
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static int getChildValueAsInt(XMLNode *node, const string &name, bool mandatory=false, int defaultValue=0)
Definition: xmlutils.cpp:291
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
Definition: xmlutils.cpp:484
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 335 of file yieldcurveconfig.cpp.

335 {
336 // Allocate a node.
337 XMLNode* node = doc.allocNode("YieldCurve");
338
339 // Add the mandatory members.
340 XMLUtils::addChild(doc, node, "CurveId", curveID_);
341 XMLUtils::addChild(doc, node, "CurveDescription", curveDescription_);
342 XMLUtils::addChild(doc, node, "Currency", currency_);
343 XMLUtils::addChild(doc, node, "DiscountCurve", discountCurveID_);
344
345 // Add the segments node.
346 XMLNode* segmentsNode = doc.allocNode("Segments");
347 XMLUtils::appendNode(node, segmentsNode);
348 for (Size i = 0; i < curveSegments_.size(); ++i) {
349 XMLUtils::appendNode(segmentsNode, curveSegments_[i]->toXML(doc));
350 }
351
352 // Add the defaultable elements.
353 XMLUtils::addChild(doc, node, "InterpolationVariable", interpolationVariable_);
354 XMLUtils::addChild(doc, node, "InterpolationMethod", interpolationMethod_);
355 XMLUtils::addChild(doc, node, "MixedInterpolationCutoff", (int)mixedInterpolationCutoff_);
356 XMLUtils::addChild(doc, node, "YieldCurveDayCounter", zeroDayCounter_);
357 XMLUtils::addChild(doc, node, "Tolerance", bootstrapConfig_.accuracy());
358 XMLUtils::addChild(doc, node, "Extrapolation", extrapolation_);
360
361 return node;
362}
QuantLib::Real accuracy() const
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
virtual XMLNode * toXML(XMLDocument &doc) const override
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ currency()

const string & currency ( ) const

Definition at line 673 of file yieldcurveconfig.hpp.

673{ return currency_; }

◆ discountCurveID()

const string & discountCurveID ( ) const

Definition at line 674 of file yieldcurveconfig.hpp.

674{ return discountCurveID_; }

◆ curveSegments()

const vector< QuantLib::ext::shared_ptr< YieldCurveSegment > > & curveSegments ( ) const

Definition at line 675 of file yieldcurveconfig.hpp.

675{ return curveSegments_; }

◆ interpolationVariable() [1/2]

const string & interpolationVariable ( ) const

Definition at line 676 of file yieldcurveconfig.hpp.

676{ return interpolationVariable_; }

◆ interpolationMethod() [1/2]

const string & interpolationMethod ( ) const

Definition at line 677 of file yieldcurveconfig.hpp.

677{ return interpolationMethod_; }

◆ mixedInterpolationCutoff() [1/2]

Size mixedInterpolationCutoff ( ) const

Definition at line 678 of file yieldcurveconfig.hpp.

◆ zeroDayCounter() [1/2]

const string & zeroDayCounter ( ) const

Definition at line 679 of file yieldcurveconfig.hpp.

679{ return zeroDayCounter_; }

◆ extrapolation() [1/2]

bool extrapolation ( ) const

Definition at line 680 of file yieldcurveconfig.hpp.

680{ return extrapolation_; }

◆ bootstrapConfig()

const BootstrapConfig & bootstrapConfig ( ) const

Definition at line 681 of file yieldcurveconfig.hpp.

681{ return bootstrapConfig_; }
+ Here is the caller graph for this function:

◆ interpolationVariable() [2/2]

string & interpolationVariable ( )

Definition at line 686 of file yieldcurveconfig.hpp.

686{ return interpolationVariable_; }

◆ interpolationMethod() [2/2]

string & interpolationMethod ( )

Definition at line 687 of file yieldcurveconfig.hpp.

687{ return interpolationMethod_; }

◆ mixedInterpolationCutoff() [2/2]

Size & mixedInterpolationCutoff ( )

Definition at line 688 of file yieldcurveconfig.hpp.

◆ zeroDayCounter() [2/2]

string & zeroDayCounter ( )

Definition at line 689 of file yieldcurveconfig.hpp.

689{ return zeroDayCounter_; }

◆ extrapolation() [2/2]

bool & extrapolation ( )

Definition at line 690 of file yieldcurveconfig.hpp.

690{ return extrapolation_; }

◆ setBootstrapConfig()

void setBootstrapConfig ( const BootstrapConfig bootstrapConfig)

Definition at line 691 of file yieldcurveconfig.hpp.

+ Here is the call graph for this function:

◆ quotes()

const vector< string > & quotes ( )
overridevirtual

Return all the market quotes required for this config.

Reimplemented from CurveConfig.

Definition at line 228 of file yieldcurveconfig.cpp.

228 {
229 if (quotes_.size() == 0) {
230 bool addedFxSpot = false;
231 for (auto c : curveSegments_) {
232 for (auto segmentQuote : c->quotes())
233 quotes_.push_back(segmentQuote.first);
234
235 // Check if the segment is a CrossCcyYieldCurveSegment and add the FX spot rate to the
236 // set of quotes needed for the YieldCurveConfig if it has not already been added.
237 if (auto xccySegment = QuantLib::ext::dynamic_pointer_cast<CrossCcyYieldCurveSegment>(c)) {
238 if (!addedFxSpot)
239 quotes_.push_back(xccySegment->spotRateID());
240 }
241 }
242 }
243 return quotes_;
244}
vector< string > quotes_
Definition: curveconfig.hpp:74

◆ populateRequiredCurveIds()

void populateRequiredCurveIds ( )
private

Definition at line 364 of file yieldcurveconfig.cpp.

364 {
365
366 requiredCurveIds_.clear();
367
368 if (curveID_ != discountCurveID_ && !discountCurveID_.empty()) {
370 }
371
372 SegmentIDGetter segmentIDGetter(curveID_, requiredCurveIds_);
373 for (Size i = 0; i < curveSegments_.size(); i++) {
374 curveSegments_[i]->accept(segmentIDGetter);
375 }
376}
map< CurveSpec::CurveType, set< string > > requiredCurveIds_
Definition: curveconfig.hpp:75
+ Here is the caller graph for this function:

Member Data Documentation

◆ currency_

string currency_
private

Definition at line 700 of file yieldcurveconfig.hpp.

◆ discountCurveID_

string discountCurveID_
private

Definition at line 701 of file yieldcurveconfig.hpp.

◆ curveSegments_

vector<QuantLib::ext::shared_ptr<YieldCurveSegment> > curveSegments_
private

Definition at line 702 of file yieldcurveconfig.hpp.

◆ interpolationVariable_

string interpolationVariable_
private

Definition at line 705 of file yieldcurveconfig.hpp.

◆ interpolationMethod_

string interpolationMethod_
private

Definition at line 706 of file yieldcurveconfig.hpp.

◆ zeroDayCounter_

string zeroDayCounter_
private

Definition at line 707 of file yieldcurveconfig.hpp.

◆ extrapolation_

bool extrapolation_
private

Definition at line 708 of file yieldcurveconfig.hpp.

◆ bootstrapConfig_

BootstrapConfig bootstrapConfig_
private

Definition at line 709 of file yieldcurveconfig.hpp.

◆ mixedInterpolationCutoff_

Size mixedInterpolationCutoff_
private

Definition at line 710 of file yieldcurveconfig.hpp.