Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
curveconfigurations.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
24#include <ql/errors.hpp>
25
26#include <boost/make_shared.hpp>
27
28namespace ore {
29namespace data {
30
31// utility function to add a set of nodes from a given map of curve configs
32template <class T>
33void addMinimalCurves(const char* nodeName, const map<string, QuantLib::ext::shared_ptr<T>>& m,
34 map<string, QuantLib::ext::shared_ptr<T>>& n, CurveSpec::CurveType curveType,
35 const map<CurveSpec::CurveType, set<string>> configIds) {
36 for (auto it : m) {
37 if ((configIds.count(curveType) && configIds.at(curveType).count(it.first))) {
38 const string& id = it.second->curveID();
39 n[id] = it.second;
40 }
41 }
42}
43
44void CurveConfigurations::addNodes(XMLDocument& doc, XMLNode* parent, const char* nodeName) const {
45 const auto& ct = parseCurveConfigurationType(nodeName);
46 const auto& it = configs_.find(ct);
47 if (it != configs_.end()) {
48 XMLNode* node = doc.allocNode(nodeName);
49 XMLUtils::appendNode(parent, node);
50
51 for (const auto& c : it->second) {
52 XMLUtils::appendNode(node, c.second->toXML(doc));
53 }
54 }
55}
56
57void CurveConfigurations::parseNode(const CurveSpec::CurveType& type, const string& curveId) const {
58 QuantLib::ext::shared_ptr<CurveConfig> config;
59 const auto& it = unparsed_.find(type);
60 if (it != unparsed_.end()) {
61 const auto& itc = it->second.find(curveId);
62 if (itc != it->second.end()) {
63 switch (type) {
65 config = QuantLib::ext::make_shared<YieldCurveConfig>();
66 break;
67 }
69 config = QuantLib::ext::make_shared<DefaultCurveConfig>();
70 break;
71 }
73 config = QuantLib::ext::make_shared<CDSVolatilityCurveConfig>();
74 break;
75 }
77 config = QuantLib::ext::make_shared<BaseCorrelationCurveConfig>();
78 break;
79 }
81 config = QuantLib::ext::make_shared<FXSpotConfig>();
82 break;
83 }
85 config = QuantLib::ext::make_shared<FXVolatilityCurveConfig>();
86 break;
87 }
89 config = QuantLib::ext::make_shared<SwaptionVolatilityCurveConfig>();
90 break;
91 }
93 config = QuantLib::ext::make_shared<YieldVolatilityCurveConfig>();
94 break;
95 }
97 config = QuantLib::ext::make_shared<CapFloorVolatilityCurveConfig>();
98 break;
99 }
101 config = QuantLib::ext::make_shared<InflationCurveConfig>();
102 break;
103 }
105 config = QuantLib::ext::make_shared<InflationCapFloorVolatilityCurveConfig>();
106 break;
107 }
109 config = QuantLib::ext::make_shared<EquityCurveConfig>();
110 break;
111 }
113 config = QuantLib::ext::make_shared<EquityVolatilityCurveConfig>();
114 break;
115 }
117 config = QuantLib::ext::make_shared<SecurityConfig>();
118 break;
119 }
121 config = QuantLib::ext::make_shared<CommodityCurveConfig>();
122 break;
123 }
125 config = QuantLib::ext::make_shared<CommodityVolatilityConfig>();
126 break;
127 }
129 config = QuantLib::ext::make_shared<CorrelationCurveConfig>();
130 break;
131 }
132 }
133 try {
134 config->fromXMLString(itc->second);
135 configs_[type][curveId] = config;
136 unparsed_.at(type).erase(curveId);
137 } catch (std::exception& ex) {
138 string err = "Curve config under node '" + to_string(type) + " was requested, but could not be parsed.";
139 StructuredCurveErrorMessage(curveId, err, ex.what()).log();
140 QL_FAIL(err);
141 }
142 } else
143 QL_FAIL("Could not find curveId " << curveId << " of type " << type << " in unparsed curve configurations");
144 } else
145 QL_FAIL("Could not find CurveType " << type << " in unparsed curve configurations");
146}
147
148void CurveConfigurations::add(const CurveSpec::CurveType& type, const string& curveId,
149 const QuantLib::ext::shared_ptr<CurveConfig>& config) {
150 configs_[type][curveId] = config;
151}
152
153bool CurveConfigurations::has(const CurveSpec::CurveType& type, const string& curveId) const {
154 return (configs_.count(type) > 0 && configs_.at(type).count(curveId) > 0) ||
155 (unparsed_.count(type) > 0 && unparsed_.at(type).count(curveId) > 0);
156}
157
158const QuantLib::ext::shared_ptr<CurveConfig>& CurveConfigurations::get(const CurveSpec::CurveType& type,
159 const string& curveId) const {
160 const auto& it = configs_.find(type);
161 if (it != configs_.end()) {
162 const auto& itc = it->second.find(curveId);
163 if (itc != it->second.end()) {
164 return itc->second;
165 }
166 }
167 parseNode(type, curveId);
168 return configs_.at(type).at(curveId);
169}
170
172 for (const auto& u : unparsed_) {
173 for (auto it = u.second.cbegin(), nit = it; it != u.second.cend(); it = nit) {
174 nit++;
175 parseNode(u.first, it->first);
176 }
177 }
178}
179
180void CurveConfigurations::getNode(XMLNode* node, const char* parentName, const char* childName) {
181 const auto& type = parseCurveConfigurationType(parentName);
182 XMLNode* parentNode = XMLUtils::getChildNode(node, parentName);
183 if (parentNode) {
184 for (XMLNode* child = XMLUtils::getChildNode(parentNode, childName); child;
185 child = XMLUtils::getNextSibling(child, childName)) {
186 const auto& id = XMLUtils::getChildValue(child, "CurveId", true);
187 unparsed_[type][id] = XMLUtils::toString(child);
188 }
189 }
190}
191
192QuantLib::ext::shared_ptr<CurveConfigurations>
193CurveConfigurations::minimalCurveConfig(const QuantLib::ext::shared_ptr<TodaysMarketParameters> todaysMarketParams,
194 const set<string>& configurations) const {
195
196 QuantLib::ext::shared_ptr<CurveConfigurations> minimum = QuantLib::ext::make_shared<CurveConfigurations>();
197 // If tmparams is not null, organise its specs in to a map [CurveType, set of CurveConfigID]
198 map<CurveSpec::CurveType, set<string>> curveConfigIds;
199
200 for (const auto& config : configurations) {
201 for (const auto& strSpec : todaysMarketParams->curveSpecs(config)) {
202 auto spec = parseCurveSpec(strSpec);
203 if (curveConfigIds.count(spec->baseType()))
204 curveConfigIds[spec->baseType()].insert(spec->curveConfigID());
205 else
206 curveConfigIds[spec->baseType()] = {spec->curveConfigID()};
207 }
208 }
209
210 for (const auto& it : curveConfigIds) {
211 for (auto& c : it.second) {
212 try {
213 auto cc = get(it.first, c);
214 minimum->add(it.first, c, get(it.first, c));
215 } catch (...) {
216 }
217 }
218 }
219 return minimum;
220}
221
222std::set<string> CurveConfigurations::quotes(const QuantLib::ext::shared_ptr<TodaysMarketParameters> todaysMarketParams,
223 const set<string>& configurations) const {
224
225 std::set<string> quotes = minimalCurveConfig(todaysMarketParams, configurations)->quotes();
226
227 // FX spot is special in that we generally do not enter a curve configuration for it. Above, we ran over the
228 // curve configurations asking each for its quotes. We may end up missing FX spot quotes that are specified in a
229 // TodaysMarketParameters but do not have a CurveConfig. If we have a TodaysMarketParameters instance we can add
230 // them here directly using it.
231
232 for (const auto& config : configurations) {
233 for (const auto& strSpec : todaysMarketParams->curveSpecs(config)) {
234 auto spec = parseCurveSpec(strSpec);
235 if (spec->baseType() == CurveSpec::CurveType::FX) {
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();
239 quotes.insert(strQuote);
240 }
241 }
242 }
243
244 return quotes;
245}
246
247std::set<string> CurveConfigurations::quotes() const {
248 set<string> quotes;
249
250 // only add quotes for parsed configs
251 for (const auto& ct : configs_) {
252 for (const auto& c : ct.second) {
253 quotes.insert(c.second->quotes().begin(), c.second->quotes().end());
254 }
255 }
256 return quotes;
257}
258
259std::set<string> CurveConfigurations::conventions(const QuantLib::ext::shared_ptr<TodaysMarketParameters> todaysMarketParams,
260 const set<string>& configurations) const {
261 set<string> conventions = minimalCurveConfig(todaysMarketParams, configurations)->conventions();
262
263 // Checking for any swapIndices
264 if (todaysMarketParams->hasMarketObject(MarketObject::SwapIndexCurve)) {
265 for (const auto& m : todaysMarketParams->mapping(MarketObject::SwapIndexCurve, Market::defaultConfiguration)) {
266 conventions.insert(m.first);
267 }
268 }
269
270 return conventions;
271}
272
273std::set<string> CurveConfigurations::conventions() const {
274 set<string> conventions;
275 for (const auto& cc : configs_) {
276 if (cc.first == CurveSpec::CurveType::Yield) {
277 for (const auto& c : cc.second) {
278 auto ycc = QuantLib::ext::dynamic_pointer_cast<YieldCurveConfig>(c.second);
279 if (ycc) {
280 for (auto& s : ycc->curveSegments())
281 if (!s->conventionsID().empty())
282 conventions.insert(s->conventionsID());
283 }
284 }
285 }
286
287 if (cc.first == CurveSpec::CurveType::Default) {
288 for (const auto& c : cc.second) {
289 auto dcc = QuantLib::ext::dynamic_pointer_cast<DefaultCurveConfig>(c.second);
290 if (dcc) {
291 for (auto& s : dcc->configs()) {
292 if (s.second.conventionID() != "")
293 conventions.insert(s.second.conventionID());
294 }
295 }
296 }
297 }
298
299 if (cc.first == CurveSpec::CurveType::Inflation) {
300 for (const auto& c : cc.second) {
301 auto icc = QuantLib::ext::dynamic_pointer_cast<InflationCurveConfig>(c.second);
302 if (icc) {
303 if (icc->conventions() != "")
304 conventions.insert(icc->conventions());
305 }
306 }
307 }
308
309 if (cc.first == CurveSpec::CurveType::Correlation) {
310 for (const auto& c : cc.second) {
311 auto ccc = QuantLib::ext::dynamic_pointer_cast<CorrelationCurveConfig>(c.second);
312 if (ccc) {
313 if (ccc->conventions() != "")
314 conventions.insert(ccc->conventions());
315 }
316 }
317 }
318
319 if (cc.first == CurveSpec::CurveType::FXVolatility) {
320 for (const auto& c : cc.second) {
321 auto fcc = QuantLib::ext::dynamic_pointer_cast<FXVolatilityCurveConfig>(c.second);
322 if (fcc) {
323 if (fcc->conventionsID() != "")
324 conventions.insert(fcc->conventionsID());
325 }
326 }
327 }
328 }
329 return conventions;
330}
331
333 set<string> curves;
334 const auto& it = configs_.find(CurveSpec::CurveType::Yield);
335 if (it != configs_.end()) {
336 for (const auto& c : it->second)
337 curves.insert(c.first);
338 }
339
340 const auto& itu = unparsed_.find(CurveSpec::CurveType::Yield);
341 if (itu != unparsed_.end()) {
342 for (const auto& c : itu->second)
343 curves.insert(c.first);
344 }
345
346 return curves;
347}
348
349std::map<CurveSpec::CurveType, std::set<string>>
350CurveConfigurations::requiredCurveIds(const CurveSpec::CurveType& type, const std::string& curveId) const {
351 QuantLib::ext::shared_ptr<CurveConfig> cc;
352 std::map<CurveSpec::CurveType, std::set<string>> ids;
353 if (!curveId.empty())
354 try {
355 cc = get(type, curveId);
356 } catch (...) {
357 }
358 if (cc)
359 ids = cc->requiredCurveIds();
360 return ids;
361}
362
363bool CurveConfigurations::hasYieldCurveConfig(const string& curveID) const { return has(CurveSpec::CurveType::Yield, curveID); }
364QuantLib::ext::shared_ptr<YieldCurveConfig> CurveConfigurations::yieldCurveConfig(const string& curveID) const {
365 QuantLib::ext::shared_ptr<CurveConfig> cc = get(CurveSpec::CurveType::Yield, curveID);
366 return QuantLib::ext::dynamic_pointer_cast<YieldCurveConfig>(cc);
367}
368
369bool CurveConfigurations::hasFxVolCurveConfig(const string& curveID) const {
370 return has(CurveSpec::CurveType::FXVolatility, curveID);
371}
372
373QuantLib::ext::shared_ptr<FXVolatilityCurveConfig> CurveConfigurations::fxVolCurveConfig(const string& curveID) const {
374 auto cc = get(CurveSpec::CurveType::FXVolatility, curveID);
375 return QuantLib::ext::dynamic_pointer_cast<FXVolatilityCurveConfig>(cc);
376}
377
378bool CurveConfigurations::hasSwaptionVolCurveConfig(const string& curveID) const {
380}
381
382QuantLib::ext::shared_ptr<SwaptionVolatilityCurveConfig>
385 return QuantLib::ext::dynamic_pointer_cast<SwaptionVolatilityCurveConfig>(cc);
386}
387
388bool CurveConfigurations::hasYieldVolCurveConfig(const string& curveID) const {
390}
391
392QuantLib::ext::shared_ptr<YieldVolatilityCurveConfig>
393CurveConfigurations::yieldVolCurveConfig(const string& curveID) const {
394 auto cc = get(CurveSpec::CurveType::YieldVolatility, curveID);
395 return QuantLib::ext::dynamic_pointer_cast<YieldVolatilityCurveConfig>(cc);
396}
397
398bool CurveConfigurations::hasCapFloorVolCurveConfig(const string& curveID) const {
400}
401
402QuantLib::ext::shared_ptr<CapFloorVolatilityCurveConfig>
405 return QuantLib::ext::dynamic_pointer_cast<CapFloorVolatilityCurveConfig>(cc);
406}
407
408bool CurveConfigurations::hasDefaultCurveConfig(const string& curveID) const {
409 return has(CurveSpec::CurveType::Default, curveID);
410}
411
412QuantLib::ext::shared_ptr<DefaultCurveConfig> CurveConfigurations::defaultCurveConfig(const string& curveID) const {
413 auto cc = get(CurveSpec::CurveType::Default, curveID);
414 return QuantLib::ext::dynamic_pointer_cast<DefaultCurveConfig>(cc);
415}
416
417bool CurveConfigurations::hasCdsVolCurveConfig(const string& curveID) const {
419}
420
421QuantLib::ext::shared_ptr<CDSVolatilityCurveConfig> CurveConfigurations::cdsVolCurveConfig(const string& curveID) const {
422 auto cc = get(CurveSpec::CurveType::CDSVolatility, curveID);
423 return QuantLib::ext::dynamic_pointer_cast<CDSVolatilityCurveConfig>(cc);
424}
425
426bool CurveConfigurations::hasBaseCorrelationCurveConfig(const string& curveID) const {
428}
429
430QuantLib::ext::shared_ptr<BaseCorrelationCurveConfig>
432 auto cc = get(CurveSpec::CurveType::BaseCorrelation, curveID);
433 return QuantLib::ext::dynamic_pointer_cast<BaseCorrelationCurveConfig>(cc);
434}
435
436bool CurveConfigurations::hasInflationCurveConfig(const string& curveID) const {
437 return has(CurveSpec::CurveType::Inflation, curveID);
438}
439
440QuantLib::ext::shared_ptr<InflationCurveConfig> CurveConfigurations::inflationCurveConfig(const string& curveID) const {
441 auto cc = get(CurveSpec::CurveType::Inflation, curveID);
442 return QuantLib::ext::dynamic_pointer_cast<InflationCurveConfig>(cc);
443}
444
447}
448
449QuantLib::ext::shared_ptr<InflationCapFloorVolatilityCurveConfig>
452 return QuantLib::ext::dynamic_pointer_cast<InflationCapFloorVolatilityCurveConfig>(cc);
453}
454
455bool CurveConfigurations::hasEquityCurveConfig(const string& curveID) const {
456 return has(CurveSpec::CurveType::Equity, curveID);
457}
458
459QuantLib::ext::shared_ptr<EquityCurveConfig> CurveConfigurations::equityCurveConfig(const string& curveID) const {
460 auto cc = get(CurveSpec::CurveType::Equity, curveID);
461 return QuantLib::ext::dynamic_pointer_cast<EquityCurveConfig>(cc);
462}
463
464bool CurveConfigurations::hasEquityVolCurveConfig(const string& curveID) const {
466}
467
468QuantLib::ext::shared_ptr<EquityVolatilityCurveConfig>
469CurveConfigurations::equityVolCurveConfig(const string& curveID) const {
471 return QuantLib::ext::dynamic_pointer_cast<EquityVolatilityCurveConfig>(cc);
472}
473
474bool CurveConfigurations::hasSecurityConfig(const string& curveID) const {
475 return has(CurveSpec::CurveType::Security, curveID);
476}
477
478QuantLib::ext::shared_ptr<SecurityConfig> CurveConfigurations::securityConfig(const string& curveID) const {
479 auto cc = get(CurveSpec::CurveType::Security, curveID);
480 return QuantLib::ext::dynamic_pointer_cast<SecurityConfig>(cc);
481}
482
483bool CurveConfigurations::hasFxSpotConfig(const string& curveID) const {
484 return has(CurveSpec::CurveType::FX, curveID);
485}
486
487QuantLib::ext::shared_ptr<FXSpotConfig> CurveConfigurations::fxSpotConfig(const string& curveID) const {
488 auto cc = get(CurveSpec::CurveType::FX, curveID);
489 return QuantLib::ext::dynamic_pointer_cast<FXSpotConfig>(cc);
490}
491
492bool CurveConfigurations::hasCommodityCurveConfig(const string& curveID) const {
493 return has(CurveSpec::CurveType::Commodity, curveID);
494}
495
496QuantLib::ext::shared_ptr<CommodityCurveConfig> CurveConfigurations::commodityCurveConfig(const string& curveID) const {
497 auto cc = get(CurveSpec::CurveType::Commodity, curveID);
498 return QuantLib::ext::dynamic_pointer_cast<CommodityCurveConfig>(cc);
499}
500
501bool CurveConfigurations::hasCommodityVolatilityConfig(const string& curveID) const {
503}
504
505QuantLib::ext::shared_ptr<CommodityVolatilityConfig>
508 return QuantLib::ext::dynamic_pointer_cast<CommodityVolatilityConfig>(cc);
509}
510
511bool CurveConfigurations::hasCorrelationCurveConfig(const string& curveID) const {
512 return has(CurveSpec::CurveType::Correlation, curveID);
513}
514
515QuantLib::ext::shared_ptr<CorrelationCurveConfig>
517 auto cc = get(CurveSpec::CurveType::Correlation, curveID);
518 return QuantLib::ext::dynamic_pointer_cast<CorrelationCurveConfig>(cc);
519}
520
521#include <iostream>
523 XMLUtils::checkNode(node, "CurveConfiguration");
524
525 // Load global settings
526 if (auto tmp = XMLUtils::getChildNode(node, "ReportConfiguration")) {
527 if (auto tmp2 = XMLUtils::getChildNode(tmp, "EquityVolatilities")) {
528 if (auto tmp3 = XMLUtils::getChildNode(tmp2, "Report"))
530 }
531 if (auto tmp2 = XMLUtils::getChildNode(tmp, "FXVolatilities")) {
532 if (auto tmp3 = XMLUtils::getChildNode(tmp2, "Report"))
534 }
535 if (auto tmp2 = XMLUtils::getChildNode(tmp, "CommodityVolatilities")) {
536 if (auto tmp3 = XMLUtils::getChildNode(tmp2, "Report"))
538 }
539 if (auto tmp2 = XMLUtils::getChildNode(tmp, "IRCapFloorVolatilities")) {
540 if (auto tmp3 = XMLUtils::getChildNode(tmp2, "Report"))
542 }
543 if (auto tmp2 = XMLUtils::getChildNode(tmp, "IRSwaptionVolatilities")) {
544 if (auto tmp3 = XMLUtils::getChildNode(tmp2, "Report"))
546 }
547 }
548
549 // Load YieldCurves, FXVols, etc, etc
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");
567}
568
570 XMLNode* parent = doc.allocNode("CurveConfiguration");
571
572 addNodes(doc, parent, "FXSpots");
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");
589
590 return parent;
591}
592
594
595 // add parsed configs
596
597 for (auto const& [curveType, configs] : c.configs_) {
598 for (auto const& [name, config] : configs) {
599 auto c1 = configs_.find(curveType);
600 if (c1 == configs_.end()) {
601 configs_[curveType] = {{name, config}};
602 continue;
603 }
604 auto c2 = c1->second.find(name);
605 if (c2 == c1->second.end()) {
606 c1->second[name] = config;
607 continue;
608 }
609 }
610 }
611
612 // add unparsed configs
613
614 for (auto const& [curveType, configs] : c.unparsed_) {
615 for (auto const& [name, config] : configs) {
616 auto c1 = unparsed_.find(curveType);
617 if (c1 == unparsed_.end()) {
618 unparsed_[curveType] = {{name, config}};
619 continue;
620 }
621 auto c2 = c1->second.find(name);
622 if (c2 == c1->second.end()) {
623 c1->second[name] = config;
624 continue;
625 }
626 }
627 }
628}
629
630void CurveConfigurationsManager::add(const QuantLib::ext::shared_ptr<CurveConfigurations>& config, std::string id) {
631 configs_[id] = config;
632}
633
634const QuantLib::ext::shared_ptr<CurveConfigurations>& CurveConfigurationsManager::get(std::string id) const {
635 auto it = configs_.find(id);
636 if (it == configs_.end()) {
637 WLOG("CurveConfigurationsManager: could not find CurveConfiguration for id "
638 << id << ", attempting to get default curveConfig.");
639 it = configs_.find("");
640 QL_REQUIRE(it != configs_.end(), "CurveConfigurationsManager: could not find CurveConfiguration for id " << id);
641 }
642 return it->second;
643}
644
645const bool CurveConfigurationsManager::has(std::string id) const {
646 auto it = configs_.find(id);
647 return it != configs_.end();
648}
649
650const std::map<std::string, QuantLib::ext::shared_ptr<CurveConfigurations>>& CurveConfigurationsManager::curveConfigurations() const {
651 return configs_;
652}
653
655 return configs_.size() == 0;
656}
657} // namespace data
658} // namespace ore
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()
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_
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
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
std::map< CurveSpec::CurveType, std::map< std::string, QuantLib::ext::shared_ptr< CurveConfig > > > configs_
void parseNode(const CurveSpec::CurveType &type, const string &curveId) const
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.
Definition: curvespec.hpp:43
void log() const
generate Boost log record to pass to corresponding sinks
Definition: log.cpp:491
static const string defaultConfiguration
Default configuration label.
Definition: market.hpp:296
void fromXML(XMLNode *node) override
Utility class for Structured Curve errors, contains the curve ID.
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
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
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
Definition: xmlutils.cpp:484
static string toString(XMLNode *node)
Write a node out as a string.
Definition: xmlutils.cpp:714
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
Curve configuration repository.
CurveSpec parser.
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.
@ data
Definition: log.hpp:77
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
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)
Definition: ast.cpp:28
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Error for market data or curve.
string conversion utilities
string name