24#include <ql/errors.hpp>
26#include <boost/make_shared.hpp>
33void addMinimalCurves(
const char* nodeName,
const map<
string, QuantLib::ext::shared_ptr<T>>& m,
37 if ((configIds.count(curveType) && configIds.at(curveType).count(it.first))) {
38 const string&
id = it.second->curveID();
51 for (
const auto& c : it->second) {
58 QuantLib::ext::shared_ptr<CurveConfig> config;
61 const auto& itc = it->second.find(curveId);
62 if (itc != it->second.end()) {
65 config = QuantLib::ext::make_shared<YieldCurveConfig>();
69 config = QuantLib::ext::make_shared<DefaultCurveConfig>();
73 config = QuantLib::ext::make_shared<CDSVolatilityCurveConfig>();
77 config = QuantLib::ext::make_shared<BaseCorrelationCurveConfig>();
81 config = QuantLib::ext::make_shared<FXSpotConfig>();
85 config = QuantLib::ext::make_shared<FXVolatilityCurveConfig>();
89 config = QuantLib::ext::make_shared<SwaptionVolatilityCurveConfig>();
93 config = QuantLib::ext::make_shared<YieldVolatilityCurveConfig>();
97 config = QuantLib::ext::make_shared<CapFloorVolatilityCurveConfig>();
101 config = QuantLib::ext::make_shared<InflationCurveConfig>();
105 config = QuantLib::ext::make_shared<InflationCapFloorVolatilityCurveConfig>();
109 config = QuantLib::ext::make_shared<EquityCurveConfig>();
113 config = QuantLib::ext::make_shared<EquityVolatilityCurveConfig>();
117 config = QuantLib::ext::make_shared<SecurityConfig>();
121 config = QuantLib::ext::make_shared<CommodityCurveConfig>();
125 config = QuantLib::ext::make_shared<CommodityVolatilityConfig>();
129 config = QuantLib::ext::make_shared<CorrelationCurveConfig>();
134 config->fromXMLString(itc->second);
137 }
catch (std::exception& ex) {
138 string err =
"Curve config under node '" +
to_string(type) +
" was requested, but could not be parsed.";
143 QL_FAIL(
"Could not find curveId " << curveId <<
" of type " << type <<
" in unparsed curve configurations");
145 QL_FAIL(
"Could not find CurveType " << type <<
" in unparsed curve configurations");
149 const QuantLib::ext::shared_ptr<CurveConfig>& config) {
154 return (
configs_.count(type) > 0 &&
configs_.at(type).count(curveId) > 0) ||
159 const string& curveId)
const {
160 const auto& it =
configs_.find(type);
162 const auto& itc = it->second.find(curveId);
163 if (itc != it->second.end()) {
168 return configs_.at(type).at(curveId);
173 for (
auto it = u.second.cbegin(), nit = it; it != u.second.cend(); it = nit) {
192QuantLib::ext::shared_ptr<CurveConfigurations>
194 const set<string>& configurations)
const {
196 QuantLib::ext::shared_ptr<CurveConfigurations> minimum = QuantLib::ext::make_shared<CurveConfigurations>();
198 map<CurveSpec::CurveType, set<string>> curveConfigIds;
200 for (
const auto& config : configurations) {
201 for (
const auto& strSpec : todaysMarketParams->curveSpecs(config)) {
203 if (curveConfigIds.count(spec->baseType()))
204 curveConfigIds[spec->baseType()].insert(spec->curveConfigID());
206 curveConfigIds[spec->baseType()] = {spec->curveConfigID()};
210 for (
const auto& it : curveConfigIds) {
211 for (
auto& c : it.second) {
213 auto cc =
get(it.first, c);
214 minimum->add(it.first, c,
get(it.first, c));
223 const set<string>& configurations)
const {
232 for (
const auto& config : configurations) {
233 for (
const auto& strSpec : todaysMarketParams->curveSpecs(config)) {
236 QuantLib::ext::shared_ptr<FXSpotSpec> fxss = QuantLib::ext::dynamic_pointer_cast<FXSpotSpec>(spec);
237 QL_REQUIRE(fxss,
"Expected an FXSpotSpec but did not get one");
238 string strQuote =
"FX/RATE/" + fxss->unitCcy() +
"/" + fxss->ccy();
252 for (
const auto& c : ct.second) {
253 quotes.insert(c.second->quotes().begin(), c.second->quotes().end());
260 const set<string>& configurations)
const {
277 for (
const auto& c : cc.second) {
278 auto ycc = QuantLib::ext::dynamic_pointer_cast<YieldCurveConfig>(c.second);
280 for (
auto& s : ycc->curveSegments())
281 if (!s->conventionsID().empty())
288 for (
const auto& c : cc.second) {
289 auto dcc = QuantLib::ext::dynamic_pointer_cast<DefaultCurveConfig>(c.second);
291 for (
auto& s : dcc->configs()) {
292 if (s.second.conventionID() !=
"")
300 for (
const auto& c : cc.second) {
301 auto icc = QuantLib::ext::dynamic_pointer_cast<InflationCurveConfig>(c.second);
303 if (icc->conventions() !=
"")
310 for (
const auto& c : cc.second) {
311 auto ccc = QuantLib::ext::dynamic_pointer_cast<CorrelationCurveConfig>(c.second);
313 if (ccc->conventions() !=
"")
320 for (
const auto& c : cc.second) {
321 auto fcc = QuantLib::ext::dynamic_pointer_cast<FXVolatilityCurveConfig>(c.second);
323 if (fcc->conventionsID() !=
"")
336 for (
const auto& c : it->second)
337 curves.insert(c.first);
342 for (
const auto& c : itu->second)
343 curves.insert(c.first);
349std::map<CurveSpec::CurveType, std::set<string>>
351 QuantLib::ext::shared_ptr<CurveConfig> cc;
352 std::map<CurveSpec::CurveType, std::set<string>> ids;
353 if (!curveId.empty())
355 cc =
get(type, curveId);
359 ids = cc->requiredCurveIds();
366 return QuantLib::ext::dynamic_pointer_cast<YieldCurveConfig>(cc);
375 return QuantLib::ext::dynamic_pointer_cast<FXVolatilityCurveConfig>(cc);
382QuantLib::ext::shared_ptr<SwaptionVolatilityCurveConfig>
385 return QuantLib::ext::dynamic_pointer_cast<SwaptionVolatilityCurveConfig>(cc);
392QuantLib::ext::shared_ptr<YieldVolatilityCurveConfig>
395 return QuantLib::ext::dynamic_pointer_cast<YieldVolatilityCurveConfig>(cc);
402QuantLib::ext::shared_ptr<CapFloorVolatilityCurveConfig>
405 return QuantLib::ext::dynamic_pointer_cast<CapFloorVolatilityCurveConfig>(cc);
414 return QuantLib::ext::dynamic_pointer_cast<DefaultCurveConfig>(cc);
423 return QuantLib::ext::dynamic_pointer_cast<CDSVolatilityCurveConfig>(cc);
430QuantLib::ext::shared_ptr<BaseCorrelationCurveConfig>
433 return QuantLib::ext::dynamic_pointer_cast<BaseCorrelationCurveConfig>(cc);
442 return QuantLib::ext::dynamic_pointer_cast<InflationCurveConfig>(cc);
449QuantLib::ext::shared_ptr<InflationCapFloorVolatilityCurveConfig>
452 return QuantLib::ext::dynamic_pointer_cast<InflationCapFloorVolatilityCurveConfig>(cc);
461 return QuantLib::ext::dynamic_pointer_cast<EquityCurveConfig>(cc);
468QuantLib::ext::shared_ptr<EquityVolatilityCurveConfig>
471 return QuantLib::ext::dynamic_pointer_cast<EquityVolatilityCurveConfig>(cc);
480 return QuantLib::ext::dynamic_pointer_cast<SecurityConfig>(cc);
489 return QuantLib::ext::dynamic_pointer_cast<FXSpotConfig>(cc);
498 return QuantLib::ext::dynamic_pointer_cast<CommodityCurveConfig>(cc);
505QuantLib::ext::shared_ptr<CommodityVolatilityConfig>
508 return QuantLib::ext::dynamic_pointer_cast<CommodityVolatilityConfig>(cc);
515QuantLib::ext::shared_ptr<CorrelationCurveConfig>
518 return QuantLib::ext::dynamic_pointer_cast<CorrelationCurveConfig>(cc);
550 getNode(node,
"YieldCurves",
"YieldCurve");
551 getNode(node,
"FXVolatilities",
"FXVolatility");
552 getNode(node,
"SwaptionVolatilities",
"SwaptionVolatility");
553 getNode(node,
"YieldVolatilities",
"YieldVolatility");
554 getNode(node,
"CapFloorVolatilities",
"CapFloorVolatility");
555 getNode(node,
"DefaultCurves",
"DefaultCurve");
556 getNode(node,
"CDSVolatilities",
"CDSVolatility");
557 getNode(node,
"BaseCorrelations",
"BaseCorrelation");
558 getNode(node,
"EquityCurves",
"EquityCurve");
559 getNode(node,
"EquityVolatilities",
"EquityVolatility");
560 getNode(node,
"InflationCurves",
"InflationCurve");
561 getNode(node,
"InflationCapFloorVolatilities",
"InflationCapFloorVolatility");
562 getNode(node,
"Securities",
"Security");
563 getNode(node,
"FXSpots",
"FXSpot");
564 getNode(node,
"CommodityCurves",
"CommodityCurve");
565 getNode(node,
"CommodityVolatilities",
"CommodityVolatility");
566 getNode(node,
"Correlations",
"Correlation");
573 addNodes(doc, parent,
"FXVolatilities");
574 addNodes(doc, parent,
"SwaptionVolatilities");
575 addNodes(doc, parent,
"YieldVolatilities");
576 addNodes(doc, parent,
"CapFloorVolatilities");
577 addNodes(doc, parent,
"CDSVolatilities");
578 addNodes(doc, parent,
"DefaultCurves");
579 addNodes(doc, parent,
"YieldCurves");
580 addNodes(doc, parent,
"InflationCurves");
581 addNodes(doc, parent,
"InflationCapFloorVolatilities");
582 addNodes(doc, parent,
"EquityCurves");
583 addNodes(doc, parent,
"EquityVolatilities");
584 addNodes(doc, parent,
"Securities");
585 addNodes(doc, parent,
"BaseCorrelations");
586 addNodes(doc, parent,
"CommodityCurves");
587 addNodes(doc, parent,
"CommodityVolatilities");
588 addNodes(doc, parent,
"Correlations");
597 for (
auto const& [curveType, configs] : c.
configs_) {
598 for (
auto const& [
name, config] : configs) {
604 auto c2 = c1->second.find(
name);
605 if (c2 == c1->second.end()) {
606 c1->second[
name] = config;
614 for (
auto const& [curveType, configs] : c.
unparsed_) {
615 for (
auto const& [
name, config] : configs) {
621 auto c2 = c1->second.find(
name);
622 if (c2 == c1->second.end()) {
623 c1->second[
name] = config;
637 WLOG(
"CurveConfigurationsManager: could not find CurveConfiguration for id "
638 <<
id <<
", attempting to get default curveConfig.");
640 QL_REQUIRE(it !=
configs_.end(),
"CurveConfigurationsManager: could not find CurveConfiguration for id " <<
id);
Container class for all Curve Configurations.
const QuantLib::ext::shared_ptr< CurveConfig > & get(const CurveSpec::CurveType &type, const string &curveId) const
bool hasYieldVolCurveConfig(const std::string &curveID) const
bool hasEquityVolCurveConfig(const std::string &curveID) const
bool hasDefaultCurveConfig(const std::string &curveID) const
std::set< string > yieldCurveConfigIds()
ReportConfig reportConfigIrSwaptionVols_
QuantLib::ext::shared_ptr< EquityCurveConfig > equityCurveConfig(const string &curveID) const
void getNode(XMLNode *node, const char *parentName, const char *childName)
QuantLib::ext::shared_ptr< YieldCurveConfig > yieldCurveConfig(const string &curveID) const
QuantLib::ext::shared_ptr< CDSVolatilityCurveConfig > cdsVolCurveConfig(const string &curveID) const
QuantLib::ext::shared_ptr< CurveConfigurations > minimalCurveConfig(const QuantLib::ext::shared_ptr< TodaysMarketParameters > todaysMarketParams, const std::set< std::string > &configurations={""}) const
QuantLib::ext::shared_ptr< BaseCorrelationCurveConfig > baseCorrelationCurveConfig(const string &curveID) const
std::set< string > conventions() const
std::set< string > quotes() const
bool hasCorrelationCurveConfig(const std::string &curveID) const
bool hasSecurityConfig(const std::string &curveID) const
QuantLib::ext::shared_ptr< CommodityCurveConfig > commodityCurveConfig(const std::string &curveID) const
QuantLib::ext::shared_ptr< InflationCurveConfig > inflationCurveConfig(const string &curveID) const
bool hasFxSpotConfig(const std::string &curveID) const
QuantLib::ext::shared_ptr< SwaptionVolatilityCurveConfig > swaptionVolCurveConfig(const string &curveID) const
QuantLib::ext::shared_ptr< CapFloorVolatilityCurveConfig > capFloorVolCurveConfig(const string &curveID) const
QuantLib::ext::shared_ptr< FXSpotConfig > fxSpotConfig(const string &curveID) const
QuantLib::ext::shared_ptr< InflationCapFloorVolatilityCurveConfig > inflationCapFloorVolCurveConfig(const string &curveID) const
bool hasFxVolCurveConfig(const std::string &curveID) const
bool hasCdsVolCurveConfig(const std::string &curveID) const
void fromXML(XMLNode *node) override
bool hasInflationCapFloorVolCurveConfig(const std::string &curveID) const
QuantLib::ext::shared_ptr< CorrelationCurveConfig > correlationCurveConfig(const std::string &curveID) const
XMLNode * toXML(XMLDocument &doc) const override
bool hasYieldCurveConfig(const std::string &curveID) const
bool hasCommodityVolatilityConfig(const std::string &curveID) const
bool hasEquityCurveConfig(const std::string &curveID) const
bool hasCommodityCurveConfig(const std::string &curveID) const
void addAdditionalCurveConfigs(const CurveConfigurations &c)
bool hasInflationCurveConfig(const std::string &curveID) const
std::map< CurveSpec::CurveType, std::map< std::string, std::string > > unparsed_
ReportConfig reportConfigFxVols_
bool has(const CurveSpec::CurveType &type, const string &curveId) const
QuantLib::ext::shared_ptr< YieldVolatilityCurveConfig > yieldVolCurveConfig(const string &curveID) const
std::map< CurveSpec::CurveType, std::set< string > > requiredCurveIds(const CurveSpec::CurveType &type, const std::string &curveId) const
QuantLib::ext::shared_ptr< DefaultCurveConfig > defaultCurveConfig(const string &curveID) const
QuantLib::ext::shared_ptr< EquityVolatilityCurveConfig > equityVolCurveConfig(const string &curveID) const
ReportConfig reportConfigIrCapFloorVols_
void add(const CurveSpec::CurveType &type, const string &curveId, const QuantLib::ext::shared_ptr< CurveConfig > &config)
QuantLib::ext::shared_ptr< CommodityVolatilityConfig > commodityVolatilityConfig(const std::string &curveID) const
void addNodes(XMLDocument &doc, XMLNode *parent, const char *nodeName) const
ReportConfig reportConfigEqVols_
std::map< CurveSpec::CurveType, std::map< std::string, QuantLib::ext::shared_ptr< CurveConfig > > > configs_
void parseNode(const CurveSpec::CurveType &type, const string &curveId) const
ReportConfig reportConfigCommVols_
QuantLib::ext::shared_ptr< SecurityConfig > securityConfig(const string &curveID) const
bool hasCapFloorVolCurveConfig(const std::string &curveID) const
bool hasBaseCorrelationCurveConfig(const std::string &curveID) const
QuantLib::ext::shared_ptr< FXVolatilityCurveConfig > fxVolCurveConfig(const string &curveID) const
bool hasSwaptionVolCurveConfig(const std::string &curveID) const
std::map< std::string, QuantLib::ext::shared_ptr< CurveConfigurations > > configs_
const bool has(std::string id=std::string()) const
void add(const QuantLib::ext::shared_ptr< CurveConfigurations > &config, std::string id=std::string())
const QuantLib::ext::shared_ptr< CurveConfigurations > & get(std::string id=std::string()) const
const std::map< std::string, QuantLib::ext::shared_ptr< CurveConfigurations > > & curveConfigurations() const
CurveType
Supported curve types.
@ InflationCapFloorVolatility
void log() const
generate Boost log record to pass to corresponding sinks
static const string defaultConfiguration
Default configuration label.
void fromXML(XMLNode *node) override
Utility class for Structured Curve errors, contains the curve ID.
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
static void checkNode(XMLNode *n, const string &expectedName)
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
static string toString(XMLNode *node)
Write a node out as a string.
static void appendNode(XMLNode *parent, XMLNode *child)
Curve configuration repository.
QuantLib::ext::shared_ptr< CurveSpec > parseCurveSpec(const string &s)
function to convert a string into a curve spec
CurveSpec::CurveType parseCurveConfigurationType(const std::string &s)
function to convert a curve configuration node string into a curve spec type
Classes and functions for log message handling.
#define WLOG(text)
Logging Macro (Level = Warning)
void addMinimalCurves(const char *nodeName, const map< string, QuantLib::ext::shared_ptr< T > > &m, map< string, QuantLib::ext::shared_ptr< T > > &n, CurveSpec::CurveType curveType, const map< CurveSpec::CurveType, set< string > > configIds)
std::string to_string(const LocationInfo &l)
Serializable Credit Default Swap.
Error for market data or curve.
string conversion utilities