Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
DefaultCurveConfig Class Reference

Default curve configuration. More...

#include <ored/configuration/defaultcurveconfig.hpp>

+ Inheritance diagram for DefaultCurveConfig:
+ Collaboration diagram for DefaultCurveConfig:

Classes

class  Config
 

Public Member Functions

 DefaultCurveConfig (const string &curveId, const string &curveDescription, const string &currency, const std::map< int, Config > &configs)
 the curve builder will try to build the configs by ascending key in the map, first success wins More...
 
 DefaultCurveConfig (const string &curveID, const string &curveDescription, const string &currency, const Config &config)
 single config ctor More...
 
 DefaultCurveConfig ()
 default ctor More...
 
- 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 ()
 
virtual const vector< string > & quotes ()
 Return all the market quotes required for this config. More...
 
- 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...
 

Serialisation

std::string currency_
 
std::map< int, Configconfigs_
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (XMLDocument &doc) const override
 
const string & currency () const
 
const std::map< int, Config > & configs () const
 
void populateQuotes ()
 
void populateRequiredCurveIds ()
 
void populateRequiredCurveIds (const std::string &discountCurveID, const std::string &benchmarkCurveID, const std::string &sourceCurveID, const std::vector< std::string > &multiSectionSourceCurveIds)
 

Additional Inherited Members

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

Detailed Description

Default curve configuration.

Definition at line 49 of file defaultcurveconfig.hpp.

Constructor & Destructor Documentation

◆ DefaultCurveConfig() [1/3]

DefaultCurveConfig ( const string &  curveId,
const string &  curveDescription,
const string &  currency,
const std::map< int, Config > &  configs 
)

the curve builder will try to build the configs by ascending key in the map, first success wins

Definition at line 33 of file defaultcurveconfig.cpp.

38 // ensure priority in config is consistent to the key used in the map
39 for (auto& c : configs_)
40 c.second.priority() = c.first;
41}
const string & curveDescription() const
Definition: curveconfig.hpp:55
CurveConfig()
Default constructor.
Definition: curveconfig.hpp:49
const std::map< int, Config > & configs() const
std::map< int, Config > configs_
+ Here is the call graph for this function:

◆ DefaultCurveConfig() [2/3]

DefaultCurveConfig ( const string &  curveID,
const string &  curveDescription,
const string &  currency,
const Config config 
)

single config ctor

Definition at line 173 of file defaultcurveconfig.hpp.

const string & curveID() const
Definition: curveconfig.hpp:54

◆ DefaultCurveConfig() [3/3]

default ctor

Definition at line 177 of file defaultcurveconfig.hpp.

177{}

Member Function Documentation

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 78 of file defaultcurveconfig.cpp.

78 {
79 XMLUtils::checkNode(node, "DefaultCurve");
80 curveID_ = XMLUtils::getChildValue(node, "CurveId", true);
81 curveDescription_ = XMLUtils::getChildValue(node, "CurveDescription", true);
82 currency_ = XMLUtils::getChildValue(node, "Currency", true);
83 if (auto configs = XMLUtils::getChildNode(node, "Configurations")) {
84 for (auto const& config : XMLUtils::getChildrenNodes(configs, "Configuration")) {
85 Config tmp;
86 tmp.fromXML(config);
87 QL_REQUIRE(configs_.find(tmp.priority()) == configs_.end(),
88 "DefaultCurveConfig::fromXML(): several configurations with same priority '" << tmp.priority()
89 << "' found.");
90 configs_[tmp.priority()] = tmp;
91 }
92 } else {
93 Config tmp;
94 tmp.fromXML(node);
95 configs_[0] = tmp;
96 }
99}
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
Definition: xmlutils.cpp:428
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 101 of file defaultcurveconfig.cpp.

101 {
102 XMLNode* node = doc.allocNode("DefaultCurve");
103
104 XMLUtils::addChild(doc, node, "CurveId", curveID_);
105 XMLUtils::addChild(doc, node, "CurveDescription", curveDescription_);
106 XMLUtils::addChild(doc, node, "Currency", currency_);
107 auto configs = XMLUtils::addChild(doc, node, "Configurations");
108
109 for (auto& tmp : configs_) {
110 XMLUtils::appendNode(configs, tmp.second.toXML(doc));
111 }
112
113 return node;
114}
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
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:

◆ currency()

const string & currency ( ) const

Definition at line 185 of file defaultcurveconfig.hpp.

185{ return currency_; }

◆ configs()

const std::map< int, Config > & configs ( ) const

Definition at line 186 of file defaultcurveconfig.hpp.

186{ return configs_; }
+ Here is the caller graph for this function:

◆ populateQuotes()

void populateQuotes ( )
private

Definition at line 65 of file defaultcurveconfig.cpp.

65 {
66 quotes_.clear();
67 for (auto const& config : configs_) {
68 for (const auto& kv : config.second.cdsQuotes()) {
69 quotes_.push_back(kv.first);
70 }
71 // recovery rate might be a hardcoded number, in which case we must not add this to the set of quotes
72 Real dummy;
73 if (!config.second.recoveryRateQuote().empty() && !tryParseReal(config.second.recoveryRateQuote(), dummy))
74 quotes_.insert(quotes_.begin(), config.second.recoveryRateQuote());
75 }
76}
vector< string > quotes_
Definition: curveconfig.hpp:74
bool tryParseReal(const string &s, QuantLib::Real &result)
Attempt to convert text to Real.
Definition: parsers.cpp:126
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateRequiredCurveIds() [1/2]

void populateRequiredCurveIds ( )
private

Definition at line 58 of file defaultcurveconfig.cpp.

58 {
59 for (auto const& config : configs_) {
60 populateRequiredCurveIds(config.second.discountCurveID(), config.second.benchmarkCurveID(),
61 config.second.sourceCurveID(), config.second.multiSectionSourceCurveIds());
62 }
63}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateRequiredCurveIds() [2/2]

void populateRequiredCurveIds ( const std::string &  discountCurveID,
const std::string &  benchmarkCurveID,
const std::string &  sourceCurveID,
const std::vector< std::string > &  multiSectionSourceCurveIds 
)
private

Definition at line 43 of file defaultcurveconfig.cpp.

45 {
46 if (!discountCurveID.empty())
47 requiredCurveIds_[CurveSpec::CurveType::Yield].insert(parseCurveSpec(discountCurveID)->curveConfigID());
48 if (!benchmarkCurveID.empty())
49 requiredCurveIds_[CurveSpec::CurveType::Yield].insert(parseCurveSpec(benchmarkCurveID)->curveConfigID());
50 if (!sourceCurveID.empty())
51 requiredCurveIds_[CurveSpec::CurveType::Yield].insert(parseCurveSpec(sourceCurveID)->curveConfigID());
52 for (auto const& s : multiSectionSourceCurveIds) {
53 if (!s.empty())
55 }
56}
map< CurveSpec::CurveType, set< string > > requiredCurveIds_
Definition: curveconfig.hpp:75
QuantLib::ext::shared_ptr< CurveSpec > parseCurveSpec(const string &s)
function to convert a string into a curve spec
+ Here is the call graph for this function:

Member Data Documentation

◆ currency_

std::string currency_
private

Definition at line 194 of file defaultcurveconfig.hpp.

◆ configs_

std::map<int, Config> configs_
private

Definition at line 195 of file defaultcurveconfig.hpp.