Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
scenariosimmarketparameters.cpp
Go to the documentation of this file.
1/*
2Copyright (C) 2016 Quaternion Risk Management Ltd
3All rights reserved.
4
5This file is part of ORE, a free-software/open-source library
6for transparent pricing and risk analysis - http://opensourcerisk.org
7
8ORE is free software: you can redistribute it and/or modify it
9under the terms of the Modified BSD License. You should have received a
10copy of the license along with this program.
11The license is also available online at <http://opensourcerisk.org>
12
13This program is distributed on the basis that it will form a useful
14contribution to risk analytics and model standardisation, but WITHOUT
15ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19#include <set>
20
26
27#include <boost/algorithm/string/join.hpp>
28#include <boost/lexical_cast.hpp>
29#include <boost/range/adaptor/transformed.hpp>
30
31using namespace QuantLib;
32using namespace ore::data;
33using boost::adaptors::transformed;
34using boost::algorithm::join;
35using std::set;
36
37namespace ore {
38namespace analytics {
39
40namespace {
41
42template <typename T> const vector<T>& lookup(const map<string, vector<T>>& m, const string& k) {
43 if (m.count(k) > 0) {
44 return m.at(k);
45 } else if (m.count(std::string()) > 0) {
46 return m.at(std::string());
47 } else
48 QL_FAIL("ScenarioSimMarketParameters: no vector for key \"" << k << "\" found.");
49}
50
51template <typename T> const T& lookup(const map<string, T>& m, const string& k) {
52 if (m.count(k) > 0) {
53 return m.at(k);
54 } else if (m.count(std::string()) > 0) {
55 return m.at(std::string());
56 } else
57 QL_FAIL("ScenarioSimMarketParameters: no result for key \"" << k << "\" found.");
58}
59
60} // namespace
61
63 vector<string> names;
64 auto it = params_.find(kt);
65 if (it != params_.end()) {
66 for (auto n : it->second.second)
67 names.push_back(n);
68 }
69 return names;
70}
71
73 auto it = params_.find(kt);
74 if (it != params_.end()) {
75 return std::find(it->second.second.begin(), it->second.second.end(), name) == it->second.second.end() ? false
76 : true;
77 }
78 return false;
79}
80
82 // check if key type exists - if doesn't exist set simulate to true first
83 if (names.size() > 0) {
84 auto it = params_.find(kt);
85 if (it == params_.end())
86 params_[kt].first = true;
87 for (auto name : names) {
88 if (!hasParamsName(kt, name))
89 params_[kt].second.insert(name);
90 }
91 }
92}
93
95 bool simulate = false;
96 auto it = params_.find(kt);
97 if (it != params_.end())
98 simulate = it->second.first;
99 return simulate;
100}
101
103 params_[kt].first = simulate;
104}
105
107 // Set default simulate
109 setSimulateSwapVols(false);
116 setSimulateCdsVols(false);
117 setSimulateFXVols(false);
123 setSimulateFxSpots(true);
125
126 // set default smile dynamics
127 setSwapVolSmileDynamics("", "StickyStrike");
128 setYieldVolSmileDynamics("", "StickyStrike");
129 setCapFloorVolSmileDynamics("", "StickyStrike");
130 setYoYInflationCapFloorVolSmileDynamics("", "StickyStrike");
132 setCdsVolSmileDynamics("", "StickyStrike");
133 setFxVolSmileDynamics("", "StickyStrike");
134 setEquityVolSmileDynamics("", "StickyStrike");
135 setCommodityVolSmileDynamics("", "StickyStrike");
136
137 // Set default tenors
138 defaultTenors_[""] = vector<Period>();
139 equityDividendTenors_[""] = vector<Period>();
140 zeroInflationTenors_[""] = vector<Period>();
141 yoyInflationTenors_[""] = vector<Period>();
142 // Default calendars
143 defaultCurveCalendars_[""] = "TARGET";
144 // Default fxVol params
145 fxVolIsSurface_[""] = false;
146 // Defaults for simulate atm only
149 simulateSwapVolATMOnly() = false;
151 // Default interpolation for yield curves
152 interpolation_ = "LogLinear";
153 extrapolation_ = "FlatFwd";
154 defaultCurveExtrapolation_ = "FlatFwd";
155}
156
159 std::swap(*this, ssmp);
160}
161
162const vector<Period>& ScenarioSimMarketParameters::yieldCurveTenors(const string& key) const {
163 return lookup(yieldCurveTenors_, key);
164}
165
166const vector<Period>& ScenarioSimMarketParameters::capFloorVolExpiries(const string& key) const {
167 return lookup(capFloorVolExpiries_, key);
168}
169
170const vector<Rate>& ScenarioSimMarketParameters::capFloorVolStrikes(const string& key) const {
171 return lookup(capFloorVolStrikes_, key);
172}
173
174bool ScenarioSimMarketParameters::capFloorVolIsAtm(const string& key) const { return lookup(capFloorVolIsAtm_, key); }
175
176const vector<Period>& ScenarioSimMarketParameters::yoyInflationCapFloorVolExpiries(const string& key) const {
177 return lookup(yoyInflationCapFloorVolExpiries_, key);
178}
179
180const vector<Rate>& ScenarioSimMarketParameters::yoyInflationCapFloorVolStrikes(const string& key) const {
181 return lookup(yoyInflationCapFloorVolStrikes_, key);
182}
183
184const vector<Period>& ScenarioSimMarketParameters::defaultTenors(const string& key) const {
185 return lookup(defaultTenors_, key);
186}
187
188const string& ScenarioSimMarketParameters::defaultCurveCalendar(const string& key) const {
189 return lookup(defaultCurveCalendars_, key);
190}
191
192bool ScenarioSimMarketParameters::swapVolIsCube(const string& key) const { return lookup(swapVolIsCube_, key); }
193
194const string& ScenarioSimMarketParameters::swapVolSmileDynamics(const string& key) const {
195 return lookup(swapVolSmileDynamics_, key);
196}
197const string& ScenarioSimMarketParameters::yieldVolSmileDynamics(const string& key) const {
198 return lookup(yieldVolSmileDynamics_, key);
199}
200const string& ScenarioSimMarketParameters::capFloorVolSmileDynamics(const string& key) const {
201 return lookup(capFloorVolSmileDynamics_, key);
202}
204 return lookup(yoyInflationCapFloorVolSmileDynamics_, key);
205}
207 return lookup(zeroInflationCapFloorVolSmileDynamics_, key);
208}
209const string& ScenarioSimMarketParameters::cdsVolSmileDynamics(const string& key) const {
210 return lookup(cdsVolSmileDynamics_, key);
211}
212const string& ScenarioSimMarketParameters::fxVolSmileDynamics(const string& key) const {
213 return lookup(fxVolSmileDynamics_, key);
214}
215const string& ScenarioSimMarketParameters::equityVolSmileDynamics(const string& key) const {
216 return lookup(equityVolSmileDynamics_, key);
217}
218const string& ScenarioSimMarketParameters::commodityVolSmileDynamics(const string& key) const {
219 return lookup(commodityVolSmileDynamics_, key);
220}
221
222const vector<Period>& ScenarioSimMarketParameters::swapVolTerms(const string& key) const {
223 return lookup(swapVolTerms_, key);
224}
225
226const vector<Period>& ScenarioSimMarketParameters::swapVolExpiries(const string& key) const {
227 return lookup(swapVolExpiries_, key);
228}
229
230const vector<Real>& ScenarioSimMarketParameters::swapVolStrikeSpreads(const string& key) const {
231 return lookup(swapVolStrikeSpreads_, key);
232}
233
234const vector<Period>& ScenarioSimMarketParameters::zeroInflationCapFloorVolExpiries(const string& key) const {
235 return lookup(zeroInflationCapFloorVolExpiries_, key);
236}
237
238const vector<Rate>& ScenarioSimMarketParameters::zeroInflationCapFloorVolStrikes(const string& key) const {
239 return lookup(zeroInflationCapFloorVolStrikes_, key);
240}
241
242const vector<Period>& ScenarioSimMarketParameters::equityDividendTenors(const string& key) const {
243 return lookup(equityDividendTenors_, key);
244}
245
246const vector<Period>& ScenarioSimMarketParameters::zeroInflationTenors(const string& key) const {
247 return lookup(zeroInflationTenors_, key);
248}
249
250const vector<Period>& ScenarioSimMarketParameters::yoyInflationTenors(const string& key) const {
251 return lookup(yoyInflationTenors_, key);
252}
253
256}
257
258const vector<Period>& ScenarioSimMarketParameters::commodityCurveTenors(const string& commodityName) const {
259 return lookup(commodityCurveTenors_, commodityName);
260}
261
262bool ScenarioSimMarketParameters::hasCommodityCurveTenors(const string& commodityName) const {
263 return commodityCurveTenors_.count(commodityName) > 0;
264}
265
266const vector<Period>& ScenarioSimMarketParameters::commodityVolExpiries(const string& commodityName) const {
267 return lookup(commodityVolExpiries_, commodityName);
268}
269
270const vector<Real>& ScenarioSimMarketParameters::fxVolMoneyness(const string& ccypair) const {
271 return lookup(fxMoneyness_, ccypair);
272}
273
274const vector<Real>& ScenarioSimMarketParameters::fxVolStdDevs(const string& ccypair) const {
275 return lookup(fxStandardDevs_, ccypair);
276}
277
278bool ScenarioSimMarketParameters::fxVolIsSurface(const string& ccypair) const {
279 return lookup(fxVolIsSurface_, ccypair);
280}
281
282bool ScenarioSimMarketParameters::fxUseMoneyness(const string& ccypair) const {
283 try {
284 const vector<Real> temp = lookup(fxMoneyness_, ccypair);
285 if (temp.size() > 0)
286 return true;
287 } catch (...) {
288 }
289 return false;
290}
291
292const vector<Real>& ScenarioSimMarketParameters::commodityVolMoneyness(const string& commodityName) const {
293 if (commodityVolMoneyness_.count(commodityName) > 0) {
294 return commodityVolMoneyness_.at(commodityName);
295 } else {
296 QL_FAIL("no moneyness for commodity \"" << commodityName << "\" found.");
297 }
298}
299
300void ScenarioSimMarketParameters::setYieldCurveTenors(const string& key, const std::vector<Period>& p) {
301 yieldCurveTenors_[key] = p;
302}
303
304void ScenarioSimMarketParameters::setSwapVolIsCube(const string& key, bool isCube) { swapVolIsCube_[key] = isCube; }
305
306void ScenarioSimMarketParameters::setSwapVolSmileDynamics(const string& key, const string& smileDynamics) {
307 swapVolSmileDynamics_[key] = smileDynamics;
308}
309void ScenarioSimMarketParameters::setCdsVolSmileDynamics(const string& key, const string& smileDynamics) {
310 cdsVolSmileDynamics_[key] = smileDynamics;
311}
312void ScenarioSimMarketParameters::setCapFloorVolSmileDynamics(const string& key, const string& smileDynamics) {
313 capFloorVolSmileDynamics_[key] = smileDynamics;
314}
315void ScenarioSimMarketParameters::setYieldVolSmileDynamics(const string& key, const string& smileDynamics) {
316 yieldVolSmileDynamics_[key] = smileDynamics;
317}
319 const string& smileDynamics) {
320 zeroInflationCapFloorVolSmileDynamics_[key] = smileDynamics;
321}
323 const string& smileDynamics) {
324 yoyInflationCapFloorVolSmileDynamics_[key] = smileDynamics;
325}
326void ScenarioSimMarketParameters::setEquityVolSmileDynamics(const string& key, const string& smileDynamics) {
327 equityVolSmileDynamics_[key] = smileDynamics;
328}
329void ScenarioSimMarketParameters::setFxVolSmileDynamics(const string& key, const string& smileDynamics) {
330 fxVolSmileDynamics_[key] = smileDynamics;
331}
332void ScenarioSimMarketParameters::setCommodityVolSmileDynamics(const string& key, const string& smileDynamics) {
333 commodityVolSmileDynamics_[key] = smileDynamics;
334}
335
336void ScenarioSimMarketParameters::setSwapVolTerms(const string& key, const vector<Period>& p) {
337 swapVolTerms_[key] = p;
338}
339
340void ScenarioSimMarketParameters::setSwapVolExpiries(const string& key, const vector<Period>& p) {
341 swapVolExpiries_[key] = p;
342}
343
345 const std::vector<QuantLib::Rate>& strikes) {
346 setSwapVolIsCube(key, strikes.size() > 1);
348}
349
350void ScenarioSimMarketParameters::setCapFloorVolExpiries(const string& key, const std::vector<Period>& p) {
351 capFloorVolExpiries_[key] = p;
352}
353
354void ScenarioSimMarketParameters::setCapFloorVolStrikes(const string& key, const vector<Rate>& strikes) {
355 // An empty vector of strikes signifies ATM
356 capFloorVolIsAtm_[key] = strikes.empty();
358}
359
360void ScenarioSimMarketParameters::setCapFloorVolIsAtm(const string& key, bool isAtm) {
361 capFloorVolIsAtm_[key] = isAtm;
362 if (isAtm) {
363 // An empty vector of strikes signifies ATM. If isAtm is false, user is expected to have
364 // provided the strikes by calling setCapFloorVolStrikes.
365 capFloorVolStrikes_[key] = vector<Rate>();
366 }
367}
368
369void ScenarioSimMarketParameters::setDefaultTenors(const string& key, const std::vector<Period>& p) {
370 defaultTenors_[key] = p;
371}
372
373void ScenarioSimMarketParameters::setDefaultCurveCalendars(const string& key, const string& s) {
374 defaultCurveCalendars_[key] = s;
375}
376
377void ScenarioSimMarketParameters::setEquityDividendTenors(const string& key, const std::vector<Period>& p) {
378 equityDividendTenors_[key] = p;
379}
380
381void ScenarioSimMarketParameters::setZeroInflationTenors(const string& key, const std::vector<Period>& p) {
382 zeroInflationTenors_[key] = p;
383}
384
385void ScenarioSimMarketParameters::setYoyInflationTenors(const string& key, const std::vector<Period>& p) {
386 yoyInflationTenors_[key] = p;
387}
388
389const vector<Period>& ScenarioSimMarketParameters::fxVolExpiries(const string& key) const {
390 return lookup(fxVolExpiries_, key);
391}
392
393void ScenarioSimMarketParameters::setFxVolIsSurface(const string& key, bool val) { fxVolIsSurface_[key] = val; }
394
396
397void ScenarioSimMarketParameters::setFxVolExpiries(const string& key, const vector<Period>& expiries) {
398 fxVolExpiries_[key] = expiries;
399}
400
402
403void ScenarioSimMarketParameters::setFxVolMoneyness(const string& ccypair, const vector<Real>& moneyness) {
404 fxMoneyness_[ccypair] = moneyness;
405}
406
407void ScenarioSimMarketParameters::setFxVolMoneyness(const vector<Real>& moneyness) { fxMoneyness_[""] = moneyness; }
408
409void ScenarioSimMarketParameters::setFxVolStdDevs(const string& ccypair, const vector<Real>& moneyness) {
410 fxStandardDevs_[ccypair] = moneyness;
411}
412
413void ScenarioSimMarketParameters::setFxVolStdDevs(const vector<Real>& moneyness) { fxStandardDevs_[""] = moneyness; }
414
416
417void ScenarioSimMarketParameters::setCommodityCurveTenors(const string& commodityName, const vector<Period>& p) {
418 commodityCurveTenors_[commodityName] = p;
419}
420
422 ccys_ = names;
424}
425
428}
429
430void ScenarioSimMarketParameters::setIndices(vector<string> names) {
432}
433
436}
437
440}
441
444}
445
448}
449
452}
453
456}
457
458void ScenarioSimMarketParameters::setZeroInflationCapFloorVolExpiries(const string& key, const std::vector<Period>& p) {
460}
461
462void ScenarioSimMarketParameters::setZeroInflationCapFloorVolStrikes(const string& key, const vector<Rate>& strikes) {
464}
465
468 setRecoveryRates(names);
469}
470
473}
474
478}
479
482}
483
486}
487
490}
491
494}
495
498}
499
502}
503
506}
507
510}
511
514}
515
518}
519
522}
523
526}
527
528void ScenarioSimMarketParameters::setCprs(const vector<string>& names) {
530}
531
534}
535
538}
539
542}
543
546}
547
550}
551
552void ScenarioSimMarketParameters::setYoYInflationCapFloorVolExpiries(const string& key, const vector<Period>& p) {
554}
555
556void ScenarioSimMarketParameters::setYoYInflationCapFloorVolStrikes(const string& key, const vector<Rate>& strikes) {
558}
559
562}
563
566}
567
570}
571
574}
575
578}
579
582}
583
586}
587
590}
591
594}
595
598}
599
602}
603
606}
607
610}
611
612void ScenarioSimMarketParameters::setEquityVolIsSurface(const string& name, bool isSurface) {
613 equityVolIsSurface_[name] = isSurface;
614}
615
616void ScenarioSimMarketParameters::setEquityVolExpiries(const string& name, const vector<Period>& expiries) {
617 equityVolExpiries_[name] = expiries;
618}
619
620void ScenarioSimMarketParameters::setEquityVolMoneyness(const string&name, const vector<Real>& moneyness) {
621 equityMoneyness_[name] = moneyness;
622}
623
624void ScenarioSimMarketParameters::setEquityVolStandardDevs(const string&name, const vector<Real>& standardDevs) {
625 equityStandardDevs_[name] = standardDevs;
626}
627
629 try {
630 const vector<Real> temp = lookup(equityMoneyness_, key);
631 if (temp.size() > 0)
632 return true;
633 } catch (...) {}
634 return false;
635}
636
638 return lookup(equityVolIsSurface_, key);
639}
640
641const vector<Period>& ScenarioSimMarketParameters::equityVolExpiries(const string& key) const {
642 return lookup(equityVolExpiries_, key);
643}
644
645const vector<Real>& ScenarioSimMarketParameters::equityVolMoneyness(const string& key) const {
646 return lookup(equityMoneyness_, key);
647}
648
649const vector<Real>& ScenarioSimMarketParameters::equityVolStandardDevs(const string& key) const {
650 return lookup(equityStandardDevs_, key);
651}
652
654
655 if (baseCcy_ != rhs.baseCcy_ || ccys_ != rhs.ccys_ || params_ != rhs.params_ ||
688 return false;
689 } else {
690 return true;
691 }
692}
693
695
697
698 // fromXML always uses a "clean" object
699 reset();
700
701 DLOG("ScenarioSimMarketParameters::fromXML()");
702
703 XMLNode* sim = XMLUtils::locateNode(root, "Simulation");
704 XMLNode* node = XMLUtils::getChildNode(sim, "Market");
705 XMLUtils::checkNode(node, "Market");
706
707 // TODO: add in checks (checkNode or QL_REQUIRE) on mandatory nodes
708 DLOG("Loading Currencies");
709 baseCcy_ = XMLUtils::getChildValue(node, "BaseCurrency");
710 setDiscountCurveNames(XMLUtils::getChildrenValues(node, "Currencies", "Currency"));
711
712 DLOG("Loading BenchmarkCurve");
713 XMLNode* nodeChild = XMLUtils::getChildNode(node, "BenchmarkCurves");
714 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
715 vector<string> yields;
716 for (XMLNode* n = XMLUtils::getChildNode(nodeChild, "BenchmarkCurve"); n != nullptr;
717 n = XMLUtils::getNextSibling(n, "BenchmarkCurve")) {
718 yields.push_back(XMLUtils::getChildValue(n, "Name", true));
720 XMLUtils::getChildValue(n, "Currency", true);
721 }
722 setYieldCurveNames(yields);
723 }
724
725 DLOG("Loading YieldCurves");
726 nodeChild = XMLUtils::getChildNode(node, "YieldCurves");
727 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
728 for (XMLNode* child = XMLUtils::getChildNode(nodeChild, "Configuration"); child;
729 child = XMLUtils::getNextSibling(child)) {
730
731 // If there is no attribute "curve", this returns "" i.e. the default
732 string label = XMLUtils::getAttribute(child, "curve");
733 if (label == "") {
734 yieldCurveTenors_[label] = XMLUtils::getChildrenValuesAsPeriods(child, "Tenors", true);
735 if (auto n = XMLUtils::getChildNode(child, "Interpolation")) {
737 }
738 if (auto n = XMLUtils::getChildNode(child, "Extrapolation")) {
740 }
741 // for backwards compatibility, map an extrapolation value that parses to bool to FlatFwd
742 bool dummy;
743 if (tryParse<bool>(extrapolation_, dummy, &parseBool)) {
744 WLOG("ScenarioSimMarket parameter Extrapolation should be FlatFwd or FlatZero, mapping deprecated "
745 "boolean '"
746 << extrapolation_ << "' to FlatFwd. Please change this in your configuration.");
747 extrapolation_ = "FlatFwd";
748 }
749 } else {
750 if (XMLUtils::getChildNode(child, "Interpolation")) {
751 WLOG("Only one default interpolation value is allowed for yield curves");
752 }
753 if (XMLUtils::getChildNode(child, "Extrapolation")) {
754 WLOG("Only one default extrapolation value is allowed for yield curves");
755 }
756 if (XMLUtils::getChildNode(child, "Tenors")) {
757 yieldCurveTenors_[label] = XMLUtils::getChildrenValuesAsPeriods(child, "Tenors", true);
758 }
759 }
760 }
761 }
762
763 DLOG("Loading Libor indices");
764 setIndices(XMLUtils::getChildrenValues(node, "Indices", "Index"));
765
766 DLOG("Loading swap indices");
767 nodeChild = XMLUtils::getChildNode(node, "SwapIndices");
768 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
769 for (XMLNode* n = XMLUtils::getChildNode(nodeChild, "SwapIndex"); n != nullptr;
770 n = XMLUtils::getNextSibling(n, "SwapIndex")) {
771 string name = XMLUtils::getChildValue(n, "Name");
772 string disc = XMLUtils::getChildValue(n, "DiscountingIndex");
773 swapIndices_[name] = disc;
774 }
775 }
776
777 DLOG("Loading FX Rates");
778 nodeChild = XMLUtils::getChildNode(node, "FxRates");
779 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
780 XMLNode* fxSpotSimNode = XMLUtils::getChildNode(nodeChild, "Simulate");
781 if (fxSpotSimNode)
783 // if currency pairs are specified load these, otherwise infer from currencies list and base currency
784 XMLNode* ccyPairsNode = XMLUtils::getChildNode(nodeChild, "CurrencyPairs");
785 if (ccyPairsNode) {
786 setFxCcyPairs(XMLUtils::getChildrenValues(nodeChild, "CurrencyPairs", "CurrencyPair", true));
787 } else {
788 vector<string> ccys;
789 for (auto ccy : ccys_) {
790 if (ccy != baseCcy_)
791 ccys.push_back(ccy + baseCcy_);
792 }
794 }
795 } else {
796 // spot simulation turned on by default
797 setSimulateFxSpots(true);
798 vector<string> ccys;
799 for (auto ccy : ccys_) {
800 if (ccy != baseCcy_)
801 ccys.push_back(ccy + baseCcy_);
802 }
804 }
805
806 DLOG("Loading SwaptionVolatilities");
807 nodeChild = XMLUtils::getChildNode(node, "SwaptionVolatilities");
808 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
809 XMLNode* swapVolSimNode = XMLUtils::getChildNode(nodeChild, "Simulate");
810 if (swapVolSimNode)
812 swapVolDecayMode_ = XMLUtils::getChildValue(nodeChild, "ReactionToTimeDecay");
813
814 auto ccys = XMLUtils::getChildrenValues(nodeChild, "Currencies", "Currency", false);
815 auto keys = XMLUtils::getChildrenValues(nodeChild, "Keys", "Key", false);
816 if(!ccys.empty()) {
817 keys.insert(keys.end(), ccys.begin(), ccys.end());
818 WLOG("ScenarioSimMarketParameters: SwaptionVolatilities/Currencies is deprecated, use Keys instead.");
819 }
820 setSwapVolKeys(keys);
821 QL_REQUIRE(!keys.empty(), "SwaptionVolatilities needs at least one currency");
822
823 // Get the configured expiries. They are of the form:
824 // - <Expiries ccy="CCY">t_1,...,t_n</Expiries> for currency specific expiries
825 // - <Expiries>t_1,...,t_n</Expiries> or <Expiries ccy="">t_1,...,t_n</Expiries> for default set of expiries
826 // Only need a default expiry set if every currency has not been given an expiry set explicitly
827 vector<XMLNode*> expiryNodes = XMLUtils::getChildrenNodes(nodeChild, "Expiries");
828 QL_REQUIRE(!expiryNodes.empty(), "SwaptionVolatilities needs at least one Expiries node");
829 set<string> keysCheck(keys.begin(),keys.end());
830 bool defaultProvided = false;
831 for (XMLNode* expiryNode : expiryNodes) {
832 // If there is no "key" attribute, getAttribute returns "" which is what we want in any case
833 string key = XMLUtils::getAttribute(expiryNode, "key");
834 if (key.empty()) {
835 string ccyAttr = XMLUtils::getAttribute(expiryNode, "ccy");
836 if (!ccyAttr.empty()) {
837 key = ccyAttr;
838 WLOG("ScenarioSimMarketParameters: SwaptionVolatilities/Expiries: 'ccy' attribute is deprecated, "
839 "use 'key' instead.");
840 }
841 }
842 vector<Period> expiries = parseListOfValues<Period>(XMLUtils::getNodeValue(expiryNode), &parsePeriod);
843 QL_REQUIRE(swapVolExpiries_.insert(make_pair(key, expiries)).second,
844 "SwaptionVolatilities has duplicate expiries for key '" << key << "'");
845 keysCheck.erase(key);
846 defaultProvided = defaultProvided || key.empty();
847 }
848 QL_REQUIRE(defaultProvided || keysCheck.empty(), "SwaptionVolatilities has no expiries for "
849 << "keys '" << join(keysCheck, ",")
850 << "' and no default expiry set has been given");
851
852 // Get the configured terms, similar to expiries above
853 vector<XMLNode*> termNodes = XMLUtils::getChildrenNodes(nodeChild, "Terms");
854 keysCheck = set<string>(keys.begin(), keys.end());
855 defaultProvided = false;
856 for (XMLNode* termNode : termNodes) {
857 // If there is no "key" attribute, getAttribute returns "" which is what we want in any case
858 string key = XMLUtils::getAttribute(termNode, "key");
859 if (key.empty()) {
860 string ccyAttr = XMLUtils::getAttribute(termNode, "ccy");
861 if (!ccyAttr.empty()) {
862 key = ccyAttr;
863 WLOG("ScenarioSimMarketParameters: SwaptionVolatilities/Terms: 'ccy' attribute is deprecated, "
864 "use 'key' instead.");
865 }
866 }
867 vector<Period> terms = parseListOfValues<Period>(XMLUtils::getNodeValue(termNode), &parsePeriod);
868 QL_REQUIRE(swapVolTerms_.insert(make_pair(key, terms)).second,
869 "SwaptionVolatilities has duplicate terms for key '" << key << "'");
870 keysCheck.erase(key);
871 defaultProvided = defaultProvided || key.empty();
872 }
873 QL_REQUIRE(defaultProvided || keysCheck.empty(), "SwaptionVolatilities has no terms for "
874 << "keys '" << join(keysCheck, ",")
875 << "' and no default term set has been given");
876
877 // Get smile dynamics
878 vector<XMLNode*> smileDynamicsNodes = XMLUtils::getChildrenNodes(nodeChild, "SmileDynamics");
879 for (XMLNode* smileDynamicsNode : smileDynamicsNodes) {
880 string key = XMLUtils::getAttribute(smileDynamicsNode, "key");
881 swapVolSmileDynamics_.insert(make_pair(key, XMLUtils::getNodeValue(smileDynamicsNode)));
882 }
883
884 XMLNode* atmOnlyNode = XMLUtils::getChildNode(nodeChild, "SimulateATMOnly");
885 if (atmOnlyNode)
886 swapVolSimulateATMOnly_ = XMLUtils::getChildValueAsBool(nodeChild, "SimulateATMOnly", true);
887
889 vector<XMLNode*> spreadNodes = XMLUtils::getChildrenNodes(nodeChild, "StrikeSpreads");
890 if (spreadNodes.size() > 0) {
891 keysCheck = set<string>(keys.begin(), keys.end());
892 defaultProvided = false;
893 for (XMLNode* spreadNode : spreadNodes) {
894 // If there is no "ccy" attribute, getAttribute returns "" which is what we want in any case
895 string key = XMLUtils::getAttribute(spreadNode, "key");
896 if (key.empty()) {
897 string ccyAttr = XMLUtils::getAttribute(spreadNode, "ccy");
898 if (!ccyAttr.empty()) {
899 key = ccyAttr;
900 ALOG("ScenarioSimMarketParameters: SwaptionVolatilities/StrikeSpreads: 'ccy' attribute is "
901 "deprecated, use 'key' instead.");
902 }
903 }
904 vector<Rate> strikes;
905 string strStrike = XMLUtils::getNodeValue(spreadNode);
906 if (strStrike == "ATM" || strStrike == "0" || strStrike == "0.0") {
907 // Add a '0' to the strike spreads
908 strikes = {0.0};
909 } else {
910 strikes = parseListOfValues<Rate>(strStrike, &parseReal);
911 }
913 keysCheck.erase(key);
914 defaultProvided = defaultProvided || key.empty();
915 }
916 QL_REQUIRE(defaultProvided || keysCheck.empty(),
917 "SwaptionVolatilities has no strike spreads for "
918 << "currencies '" << join(keysCheck, ",")
919 << "' and no default strike spreads set has been given");
920 }
921 }
922 }
923
924 DLOG("Loading YieldVolatilities");
925 nodeChild = XMLUtils::getChildNode(node, "YieldVolatilities");
926 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
927 XMLNode* yieldVolSimNode = XMLUtils::getChildNode(nodeChild, "Simulate");
928 if (yieldVolSimNode) {
930 yieldVolTerms_ = XMLUtils::getChildrenValuesAsPeriods(nodeChild, "Terms", true);
931 yieldVolExpiries_ = XMLUtils::getChildrenValuesAsPeriods(nodeChild, "Expiries", true);
932 setYieldVolNames(XMLUtils::getChildrenValues(nodeChild, "Names", "Name", true));
933 yieldVolDecayMode_ = XMLUtils::getChildValue(nodeChild, "ReactionToTimeDecay");
934 }
935 // Get smile dynamics
936 vector<XMLNode*> smileDynamicsNodes = XMLUtils::getChildrenNodes(nodeChild, "SmileDynamics");
937 for (XMLNode* smileDynamicsNode : smileDynamicsNodes) {
938 string key = XMLUtils::getAttribute(smileDynamicsNode, "key");
939 yieldVolSmileDynamics_.insert(make_pair(key, XMLUtils::getNodeValue(smileDynamicsNode)));
940 }
941 }
942
943 DLOG("Loading Correlations");
944 nodeChild = XMLUtils::getChildNode(node, "Correlations");
945 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
946 XMLNode* pn = XMLUtils::getChildNode(nodeChild, "Pairs");
947 vector<string> pairs;
948 if (pn) {
949 for (XMLNode* child = XMLUtils::getChildNode(pn, "Pair"); child; child = XMLUtils::getNextSibling(child)) {
950 string p = XMLUtils::getNodeValue(child);
951 vector<string> tokens = getCorrelationTokens(p);
952 QL_REQUIRE(tokens.size() == 2, "not a valid correlation pair: " << p);
953 pairs.push_back(p);
954 }
955 }
956 setCorrelationPairs(pairs);
957 XMLNode* correlSimNode = XMLUtils::getChildNode(nodeChild, "Simulate");
958 if (correlSimNode) {
960 correlationExpiries_ = XMLUtils::getChildrenValuesAsPeriods(nodeChild, "Expiries", true);
961
962 XMLNode* surfaceNode = XMLUtils::getChildNode(nodeChild, "Surface");
963 if (surfaceNode) {
966 } else {
967 correlationIsSurface_ = false;
968 }
969 }
970 }
971
972 DLOG("Loading CapFloorVolatilities");
973 nodeChild = XMLUtils::getChildNode(node, "CapFloorVolatilities");
974 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
975
976 // Are we simulating caps
978 XMLNode* capVolSimNode = XMLUtils::getChildNode(nodeChild, "Simulate");
979 if (capVolSimNode)
981
982 // All cap floor keys
983 auto ccys = XMLUtils::getChildrenValues(nodeChild, "Currencies", "Currency", false);
984 auto keys = XMLUtils::getChildrenValues(nodeChild, "Keys", "Key", false);
985 if(!ccys.empty()) {
986 keys.insert(keys.end(), ccys.begin(), ccys.end());
987 WLOG("ScenarioSimMarketParameters: CapFloorVolatilities/Currencies is deprecated, use Keys instead.");
988 }
989 setCapFloorVolKeys(keys);
990 QL_REQUIRE(!keys.empty(), "CapFloorVolatilities needs at least one entry");
991
992 // Get the configured expiries. They are of the form:
993 // - <Expiries key="CCY">t_1,...,t_n</Expiries> for currency specific expiries
994 // - <Expiries>t_1,...,t_n</Expiries> or <Expiries key="">t_1,...,t_n</Expiries> for default set of expiries
995 // Only need a default expiry set if every currency has not been given an expiry set explicitly
996 // instead of key, ccy is supported as an derprecated attribute
997 vector<XMLNode*> expiryNodes = XMLUtils::getChildrenNodes(nodeChild, "Expiries");
998 QL_REQUIRE(expiryNodes.size() > 0, "CapFloorVolatilities needs at least one Expiries node");
999 set<string> keysCheck(keys.begin(), keys.end());
1000 bool defaultProvided = false;
1001 for (XMLNode* expiryNode : expiryNodes) {
1002 // If there is no "key" attribute, getAttribute returns "" which is what we want in any case
1003 string key = XMLUtils::getAttribute(expiryNode, "key");
1004 if (key.empty()) {
1005 string ccyAttr = XMLUtils::getAttribute(expiryNode, "ccy");
1006 if (!ccyAttr.empty()) {
1007 key = ccyAttr;
1008 WLOG("ScenarioSimMarketParameters: CapFloorVolatilities/Expiries: 'ccy' attribute is deprecated, "
1009 "use 'key' instead.");
1010 }
1011 }
1012 vector<Period> expiries = parseListOfValues<Period>(XMLUtils::getNodeValue(expiryNode), &parsePeriod);
1013 QL_REQUIRE(capFloorVolExpiries_.insert(make_pair(key, expiries)).second,
1014 "CapFloorVolatilities has duplicate expiries for key '" << key << "'");
1015 keysCheck.erase(key);
1016 defaultProvided = defaultProvided || key.empty();
1017 }
1018 QL_REQUIRE(defaultProvided || keysCheck.size() == 0, "CapFloorVolatilities has no expiries for "
1019 << "keys '" << join(keysCheck, ",")
1020 << "' and no default expiry set has been given");
1021
1022 // Get the configured strikes. This has the same set up and logic as the Expiries above.
1023 vector<XMLNode*> strikeNodes = XMLUtils::getChildrenNodes(nodeChild, "Strikes");
1024 QL_REQUIRE(strikeNodes.size() > 0, "CapFloorVolatilities needs at least one Strikes node");
1025 keysCheck = std::set<std::string>(keys.begin(), keys.end());
1026 defaultProvided = false;
1027 for (XMLNode* strikeNode : strikeNodes) {
1028 string key = XMLUtils::getAttribute(strikeNode, "key");
1029 if (key.empty()) {
1030 string ccyAttr = XMLUtils::getAttribute(strikeNode, "ccy");
1031 if (!ccyAttr.empty()) {
1032 key = ccyAttr;
1033 WLOG("ScenarioSimMarketParameters: CapFloorVolatilities/Strikes: 'ccy' attribute is deprecated, "
1034 "use 'key' instead.");
1035 }
1036 }
1037 // For the strike value, we allow ATM or a comma separated list of absolute strike values
1038 // If ATM, the stored strikes vector is left as an empty vector
1039 vector<Rate> strikes;
1040 string strStrike = XMLUtils::getNodeValue(strikeNode);
1041 if (strStrike == "ATM") {
1042 QL_REQUIRE(capFloorVolIsAtm_.insert(make_pair(key, true)).second,
1043 "CapFloorVolatilities has duplicate strikes for key '" << key << "'");
1044 } else {
1045 QL_REQUIRE(capFloorVolIsAtm_.insert(make_pair(key, false)).second,
1046 "CapFloorVolatilities has duplicate strikes for key '" << key << "'");
1047 strikes = parseListOfValues<Rate>(strStrike, &parseReal);
1048 }
1049 QL_REQUIRE(capFloorVolStrikes_.insert(make_pair(key, strikes)).second,
1050 "CapFloorVolatilities has duplicate strikes for key '" << key << "'");
1051 keysCheck.erase(key);
1052 defaultProvided = defaultProvided || key.empty();
1053 }
1054 QL_REQUIRE(defaultProvided || keysCheck.empty(), "CapFloorVolatilities has no strikes for "
1055 << "key '" << join(keysCheck, ",")
1056 << "' and no default strike set has been given");
1057
1058 capFloorVolDecayMode_ = XMLUtils::getChildValue(nodeChild, "ReactionToTimeDecay");
1059
1061 if (XMLNode* n = XMLUtils::getChildNode(nodeChild, "AdjustOptionletPillars")) {
1063 }
1064
1065 capFloorVolUseCapAtm_ = false;
1066 if (XMLNode* n = XMLUtils::getChildNode(nodeChild, "UseCapAtm")) {
1068 }
1069
1070 // Get smile dynamics
1071 vector<XMLNode*> smileDynamicsNodes = XMLUtils::getChildrenNodes(nodeChild, "SmileDynamics");
1072 for (XMLNode* smileDynamicsNode : smileDynamicsNodes) {
1073 string key = XMLUtils::getAttribute(smileDynamicsNode, "key");
1074 capFloorVolSmileDynamics_.insert(make_pair(key, XMLUtils::getNodeValue(smileDynamicsNode)));
1075 }
1076 }
1077
1078 DLOG("Loading YYCapFloorVolatilities");
1079 nodeChild = XMLUtils::getChildNode(node, "YYCapFloorVolatilities");
1080 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
1081 // Are we simulating yy caps
1083 XMLNode* yoyCapVolSimNode = XMLUtils::getChildNode(nodeChild, "Simulate");
1084 if (yoyCapVolSimNode)
1086
1087 // All yy cap indices
1088 setYoYInflationCapFloorVolNames(XMLUtils::getChildrenValues(nodeChild, "Names", "Name", true));
1089 set<string> yyIndices = params_.find(RiskFactorKey::KeyType::YoYInflationCapFloorVolatility)->second.second;
1090 QL_REQUIRE(yyIndices.size() > 0, "YYCapFloorVolatilities needs at least on index");
1091
1092 // Get configured expiries
1093 vector<XMLNode*> expiryNodes = XMLUtils::getChildrenNodes(nodeChild, "Expiries");
1094 QL_REQUIRE(expiryNodes.size() > 0, "YYCapFloorVolatilities needs at least one Expiries node");
1095 set<string> indicesCheck = yyIndices;
1096 bool defaultProvided = false;
1097 for (XMLNode* expiryNode : expiryNodes) {
1098 string index = XMLUtils::getAttribute(expiryNode, "name");
1099 vector<Period> expiries = parseListOfValues<Period>(XMLUtils::getNodeValue(expiryNode), &parsePeriod);
1100 QL_REQUIRE(yoyInflationCapFloorVolExpiries_.insert(make_pair(index, expiries)).second,
1101 "YYCapFloorVolatlities has duplicate expiries for key '" << index << "'");
1102 indicesCheck.erase(index);
1103 defaultProvided = index == "";
1104 }
1105 QL_REQUIRE(defaultProvided || indicesCheck.size() == 0, "YYCapFloorVolatilites has no expiries for indices '"
1106 << join(indicesCheck, ";")
1107 << "' and no default expiry has been given");
1108
1109 // Get configured strikes
1110 vector<XMLNode*> strikeNodes = XMLUtils::getChildrenNodes(nodeChild, "Strikes");
1111 QL_REQUIRE(strikeNodes.size() > 0, "CapFloorVolatilities needs at least one Strikes node");
1112 indicesCheck = yyIndices;
1113 defaultProvided = false;
1114 for (XMLNode* strikeNode : strikeNodes) {
1115 string index = XMLUtils::getAttribute(strikeNode, "name");
1116 // For the strike value, we allow ATM or a comma separated list of absolute strike values
1117 // If ATM, the stored strikes vector is left as an empty vector
1118 vector<Rate> strikes;
1119 string strStrike = XMLUtils::getNodeValue(strikeNode);
1120 strikes = parseListOfValues<Rate>(strStrike, &parseReal);
1121 QL_REQUIRE(yoyInflationCapFloorVolStrikes_.insert(make_pair(index, strikes)).second,
1122 "YYInflationCapFloorVolatilities has duplicate strikes for key '" << index << "'");
1123 indicesCheck.erase(index);
1124 defaultProvided = index == "";
1125 }
1126 QL_REQUIRE(defaultProvided || indicesCheck.size() == 0, "YYInflationCapFloorVolatilities has no strikes for "
1127 << "currencies '" << join(indicesCheck, ",")
1128 << "' and no default strike set has been given");
1129
1130 yoyInflationCapFloorVolDecayMode_ = XMLUtils::getChildValue(nodeChild, "ReactionToTimeDecay");
1131
1132 // Get smile dynamics
1133 vector<XMLNode*> smileDynamicsNodes = XMLUtils::getChildrenNodes(nodeChild, "SmileDynamics");
1134 for (XMLNode* smileDynamicsNode : smileDynamicsNodes) {
1135 string key = XMLUtils::getAttribute(smileDynamicsNode, "key");
1136 yoyInflationCapFloorVolSmileDynamics_.insert(make_pair(key, XMLUtils::getNodeValue(smileDynamicsNode)));
1137 }
1138 }
1139
1140 DLOG("Loading CPICapFloorVolatilities");
1141 nodeChild = XMLUtils::getChildNode(node, "CPICapFloorVolatilities");
1142 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
1144 XMLNode* ziCapVolSimNode = XMLUtils::getChildNode(nodeChild, "Simulate");
1145 if (ziCapVolSimNode)
1147
1148 setZeroInflationCapFloorNames(XMLUtils::getChildrenValues(nodeChild, "Names", "Name", true));
1149
1151 QL_REQUIRE(cpiIndices.size() > 0, "CPICapFloorVolatilities needs at least on index");
1152
1153 // Get configured expiries
1154 // zeroInflationCapFloorVolExpiries_[""] = XMLUtils::getChildrenValuesAsPeriods(nodeChild, "Expiries", true);
1155 vector<XMLNode*> expiryNodes = XMLUtils::getChildrenNodes(nodeChild, "Expiries");
1156 QL_REQUIRE(expiryNodes.size() > 0, "CPICapFloorVolatilities needs at least one Expiries node");
1157 set<string> indicesCheck = cpiIndices;
1158 bool defaultProvided = false;
1159 for (XMLNode* expiryNode : expiryNodes) {
1160 string index = XMLUtils::getAttribute(expiryNode, "name");
1161 vector<Period> expiries = parseListOfValues<Period>(XMLUtils::getNodeValue(expiryNode), &parsePeriod);
1162 QL_REQUIRE(zeroInflationCapFloorVolExpiries_.insert(make_pair(index, expiries)).second,
1163 "CPICapFloorVolatlities has duplicate expiries for key '" << index << "'");
1164 indicesCheck.erase(index);
1165 defaultProvided = index == "";
1166 }
1167 QL_REQUIRE(defaultProvided || indicesCheck.size() == 0, "CPICapFloorVolatilites has no expiries for indices '"
1168 << join(indicesCheck, ";")
1169 << "' and no default expiry has been given");
1170
1171 // Get configured strikes
1172 // zeroInflationCapFloorVolStrikes_ = XMLUtils::getChildrenValuesAsDoublesCompact(nodeChild, "Strikes", true);
1173 vector<XMLNode*> strikeNodes = XMLUtils::getChildrenNodes(nodeChild, "Strikes");
1174 QL_REQUIRE(strikeNodes.size() > 0, "CPICapFloorVolatilities needs at least one Strikes node");
1175 indicesCheck = cpiIndices;
1176 defaultProvided = false;
1177 for (XMLNode* strikeNode : strikeNodes) {
1178 string index = XMLUtils::getAttribute(strikeNode, "name");
1179 // For the strike value, we allow ATM or a comma separated list of absolute strike values
1180 // If ATM, the stored strikes vector is left as an empty vector
1181 vector<Rate> strikes;
1182 string strStrike = XMLUtils::getNodeValue(strikeNode);
1183 strikes = parseListOfValues<Rate>(strStrike, &parseReal);
1184 QL_REQUIRE(zeroInflationCapFloorVolStrikes_.insert(make_pair(index, strikes)).second,
1185 "CPIInflationCapFloorVolatilities has duplicate strikes for key '" << index << "'");
1186 indicesCheck.erase(index);
1187 defaultProvided = index == "";
1188 }
1189 QL_REQUIRE(defaultProvided || indicesCheck.size() == 0, "CPIInflationCapFloorVolatilities has no strikes for "
1190 << "currencies '" << join(indicesCheck, ",")
1191 << "' and no default strike set has been given");
1192
1193 zeroInflationCapFloorVolDecayMode_ = XMLUtils::getChildValue(nodeChild, "ReactionToTimeDecay");
1194
1195 // Get smile dynamics
1196 vector<XMLNode*> smileDynamicsNodes = XMLUtils::getChildrenNodes(nodeChild, "SmileDynamics");
1197 for (XMLNode* smileDynamicsNode : smileDynamicsNodes) {
1198 string key = XMLUtils::getAttribute(smileDynamicsNode, "key");
1199 zeroInflationCapFloorVolSmileDynamics_.insert(make_pair(key, XMLUtils::getNodeValue(smileDynamicsNode)));
1200 }
1201 }
1202
1203 DLOG("Loading DefaultCurves Rates");
1204 nodeChild = XMLUtils::getChildNode(node, "DefaultCurves");
1205 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
1206 setDefaultNames(XMLUtils::getChildrenValues(nodeChild, "Names", "Name", true));
1207 defaultTenors_[""] = XMLUtils::getChildrenValuesAsPeriods(nodeChild, "Tenors", true);
1208 // TODO read other keys
1209 XMLNode* survivalProbabilitySimNode = XMLUtils::getChildNode(nodeChild, "SimulateSurvivalProbabilities");
1210 if (survivalProbabilitySimNode)
1212 XMLNode* recoveryRateSimNode = XMLUtils::getChildNode(nodeChild, "SimulateRecoveryRates");
1213 if (recoveryRateSimNode)
1215
1216 XMLNode* cal = XMLUtils::getChildNode(nodeChild, "Calendars");
1217 if (cal) {
1218 for (XMLNode* child = XMLUtils::getChildNode(cal, "Calendar"); child;
1219 child = XMLUtils::getNextSibling(child)) {
1220 string label = XMLUtils::getAttribute(child, "name");
1222 }
1223 }
1224 QL_REQUIRE(defaultCurveCalendars_.find("") != defaultCurveCalendars_.end(),
1225 "default calendar is not set for defaultCurves");
1226 if (auto n = XMLUtils::getChildNode(nodeChild, "Extrapolation")) {
1228 }
1229 }
1230
1231 DLOG("Loading Equities Rates");
1232 nodeChild = XMLUtils::getChildNode(node, "Equities");
1233 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
1234 XMLNode* dividendYieldSimNode = XMLUtils::getChildNode(nodeChild, "SimulateDividendYield");
1235 if (dividendYieldSimNode)
1237 else
1239 vector<string> equityNames = XMLUtils::getChildrenValues(nodeChild, "Names", "Name", true);
1241 equityDividendTenors_[""] = XMLUtils::getChildrenValuesAsPeriods(nodeChild, "DividendTenors", true);
1242 }
1243
1244 DLOG("Loading CDSVolatilities Rates");
1245 nodeChild = XMLUtils::getChildNode(node, "CDSVolatilities");
1246 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
1247 XMLNode* cdsVolSimNode = XMLUtils::getChildNode(nodeChild, "Simulate");
1248 if (cdsVolSimNode)
1250 cdsVolExpiries_ = XMLUtils::getChildrenValuesAsPeriods(nodeChild, "Expiries", true);
1251 setCdsVolNames(XMLUtils::getChildrenValues(nodeChild, "Names", "Name", true));
1252 cdsVolDecayMode_ = XMLUtils::getChildValue(nodeChild, "ReactionToTimeDecay");
1253
1254 XMLNode* atmOnlyNode = XMLUtils::getChildNode(nodeChild, "SimulateATMOnly");
1255 if (atmOnlyNode) {
1256 cdsVolSimulateATMOnly_ = XMLUtils::getChildValueAsBool(nodeChild, "SimulateATMOnly", true);
1257 }
1258
1259 // Get smile dynamics
1260 vector<XMLNode*> smileDynamicsNodes = XMLUtils::getChildrenNodes(nodeChild, "SmileDynamics");
1261 for (XMLNode* smileDynamicsNode : smileDynamicsNodes) {
1262 string key = XMLUtils::getAttribute(smileDynamicsNode, "key");
1263 cdsVolSmileDynamics_.insert(make_pair(key, XMLUtils::getNodeValue(smileDynamicsNode)));
1264 }
1265 }
1266
1267 DLOG("Loading FXVolatilities");
1268 nodeChild = XMLUtils::getChildNode(node, "FxVolatilities");
1269 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
1270 setSimulateFXVols(false);
1271 XMLNode* fxVolSimNode = XMLUtils::getChildNode(nodeChild, "Simulate");
1272 if (fxVolSimNode)
1274 fxVolDecayMode_ = XMLUtils::getChildValue(nodeChild, "ReactionToTimeDecay");
1275 setFxVolCcyPairs(XMLUtils::getChildrenValues(nodeChild, "CurrencyPairs", "CurrencyPair", true));
1276
1277 vector<XMLNode*> expiryNodes = XMLUtils::getChildrenNodes(nodeChild, "Expiries");
1278 set<string> names = params_.find(RiskFactorKey::KeyType::FXVolatility)->second.second;
1279 QL_REQUIRE(names.size() > 0, "FXVolatility needs at least one name");
1280 set<string> namesCheck = names;
1281 bool defaultProvided = false;
1282 for (XMLNode* expiryNode : expiryNodes) {
1283 // If there is no "name" attribute, getAttribute returns "" which is what we want in any case
1284 string name = XMLUtils::getAttribute(expiryNode, "ccyPair");
1285 vector<Period> expiries = parseListOfValues<Period>(XMLUtils::getNodeValue(expiryNode), &parsePeriod);
1286 QL_REQUIRE(fxVolExpiries_.insert(make_pair(name, expiries)).second,
1287 "FXVolatilities has duplicate expiries for key '" << name << "'");
1288 namesCheck.erase(name);
1289 defaultProvided = name == "";
1290 }
1291 QL_REQUIRE(defaultProvided || namesCheck.size() == 0, "FXVolatilities has no expiries for "
1292 << "equities '" << join(namesCheck, ",") << "' and no default expiry set has been given");
1293
1294 XMLNode* fxSurfaceNode = XMLUtils::getChildNode(nodeChild, "Surface");
1295 setFxVolIsSurface("", false);
1296 if (fxSurfaceNode) {
1297 for (XMLNode* child = XMLUtils::getChildNode(fxSurfaceNode, "Moneyness"); child;
1298 child = XMLUtils::getNextSibling(child, "Moneyness")) {
1299 string label = XMLUtils::getAttribute(child, "ccyPair"); // will be "" if no attr
1301 if (fxVolMoneyness(label).size() > 1) {
1302 setFxVolIsSurface(label, true);
1303 }
1304 }
1305 for (XMLNode* child = XMLUtils::getChildNode(fxSurfaceNode, "StandardDeviations"); child;
1306 child = XMLUtils::getNextSibling(child, "StandardDeviations")) {
1307 string label = XMLUtils::getAttribute(child, "ccyPair"); // will be "" if no attr
1308 // We cannot have both moneyness and standard deviations for any label (inclding the default of ""
1309 // Throw error if this occurs
1310 if (fxMoneyness_.find(label) != fxMoneyness_.end()) {
1311 QL_FAIL(
1312 "FX Volatility simulation parameters - both moneyness and standard deviations provided for "
1313 "label " << label);
1314 } else {
1316 if (fxVolStdDevs(label).size() > 1) {
1317 setFxVolIsSurface(label, true);
1318 }
1319 }
1320 }
1321 } else {
1322 XMLNode* atmOnlyNode = XMLUtils::getChildNode(nodeChild, "SimulateATMOnly");
1323 if (atmOnlyNode) {
1324 fxVolSimulateATMOnly_ = XMLUtils::getChildValueAsBool(nodeChild, "SimulateATMOnly", true);
1325 }
1326 }
1327 // Get smile dynamics
1328 vector<XMLNode*> smileDynamicsNodes = XMLUtils::getChildrenNodes(nodeChild, "SmileDynamics");
1329 for (XMLNode* smileDynamicsNode : smileDynamicsNodes) {
1330 string key = XMLUtils::getAttribute(smileDynamicsNode, "key");
1331 fxVolSmileDynamics_.insert(make_pair(key, XMLUtils::getNodeValue(smileDynamicsNode)));
1332 }
1333 }
1334
1335 DLOG("Loading EquityVolatilities");
1336 nodeChild = XMLUtils::getChildNode(node, "EquityVolatilities");
1337 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
1338 setSimulateEquityVols(XMLUtils::getChildValueAsBool(nodeChild, "Simulate", true));
1339 equityVolDecayMode_ = XMLUtils::getChildValue(nodeChild, "ReactionToTimeDecay");
1340 setEquityVolNames(XMLUtils::getChildrenValues(nodeChild, "Names", "Name", true));
1341
1342 vector<XMLNode*> expiryNodes = XMLUtils::getChildrenNodes(nodeChild, "Expiries");
1343 set<string> names = params_.find(RiskFactorKey::KeyType::EquityVolatility)->second.second;
1344 QL_REQUIRE(names.size() > 0, "EquityVolatility needs at least one name");
1345 set<string> namesCheck = names;
1346 bool defaultProvided = false;
1347 for (XMLNode* expiryNode : expiryNodes) {
1348 // If there is no "name" attribute, getAttribute returns "" which is what we want in any case
1349 string name = XMLUtils::getAttribute(expiryNode, "name");
1350 vector<Period> expiries = parseListOfValues<Period>(XMLUtils::getNodeValue(expiryNode), &parsePeriod);
1351 QL_REQUIRE(equityVolExpiries_.insert(make_pair(name, expiries)).second,
1352 "EquityVolatilities has duplicate expiries for key '" << name << "'");
1353 namesCheck.erase(name);
1354 defaultProvided = name == "";
1355 }
1356 QL_REQUIRE(defaultProvided || namesCheck.size() == 0, "EquityVolatilities has no expiries for " <<
1357 "equities '" << join(namesCheck, ",") << "' and no default expiry set has been given");
1358
1359 XMLNode* eqSurfaceNode = XMLUtils::getChildNode(nodeChild, "Surface");
1360 setEquityVolIsSurface("", false);
1361 if (eqSurfaceNode) {
1362 for (XMLNode* child = XMLUtils::getChildNode(eqSurfaceNode, "Moneyness"); child;
1363 child = XMLUtils::getNextSibling(child, "Moneyness")) {
1364 string label = XMLUtils::getAttribute(child, "name"); // will be "" if no attr
1366 if (equityVolMoneyness(label).size() > 1) {
1367 setEquityVolIsSurface(label, true);
1368 }
1369 }
1370 for (XMLNode* child = XMLUtils::getChildNode(eqSurfaceNode, "StandardDeviations"); child;
1371 child = XMLUtils::getNextSibling(child, "StandardDeviations")) {
1372 string label = XMLUtils::getAttribute(child, "name"); // will be "" if no attr
1373 // We cannot have both moneyness and standard deviations for any label (including the default of ""
1374 // Throw error if this occurs
1375 if (equityMoneyness_.find(label) != equityMoneyness_.end()){
1376 QL_FAIL("Equity Volatility simulation parameters - both moneyness and standard deviations provided for label " << label);
1377 } else {
1379 if (equityVolStandardDevs(label).size() > 1) {
1380 setEquityVolIsSurface(label, true);
1381 }
1382 }
1383 }
1384 } else {
1385 XMLNode* atmOnlyNode = XMLUtils::getChildNode(nodeChild, "SimulateATMOnly");
1386 if (atmOnlyNode) {
1387 equityVolSimulateATMOnly_ = XMLUtils::getChildValueAsBool(nodeChild, "SimulateATMOnly", true);
1388 }
1389 }
1390 // Get smile dynamics
1391 vector<XMLNode*> smileDynamicsNodes = XMLUtils::getChildrenNodes(nodeChild, "SmileDynamics");
1392 for (XMLNode* smileDynamicsNode : smileDynamicsNodes) {
1393 string key = XMLUtils::getAttribute(smileDynamicsNode, "key");
1394 equityVolSmileDynamics_.insert(make_pair(key, XMLUtils::getNodeValue(smileDynamicsNode)));
1395 }
1396 }
1397
1398 DLOG("Loading CpiInflationIndexCurves");
1399 setCpiIndices(XMLUtils::getChildrenValues(node, "CpiIndices", "Index", false));
1400
1401 DLOG("Loading ZeroInflationIndexCurves");
1402 nodeChild = XMLUtils::getChildNode(node, "ZeroInflationIndexCurves");
1403 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
1404 setZeroInflationIndices(XMLUtils::getChildrenValues(nodeChild, "Names", "Name", true));
1405 zeroInflationTenors_[""] = XMLUtils::getChildrenValuesAsPeriods(nodeChild, "Tenors", true);
1406 }
1407
1408 DLOG("Loading YYInflationIndexCurves");
1409
1410 nodeChild = XMLUtils::getChildNode(node, "YYInflationIndexCurves");
1411 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
1412 setYoyInflationIndices(XMLUtils::getChildrenValues(nodeChild, "Names", "Name", true));
1413 yoyInflationTenors_[""] = XMLUtils::getChildrenValuesAsPeriods(nodeChild, "Tenors", true);
1414 }
1415
1416 DLOG("Loading AggregationScenarioDataIndices");
1417 if (XMLUtils::getChildNode(node, "AggregationScenarioDataIndices")) {
1418 additionalScenarioDataIndices_ = XMLUtils::getChildrenValues(node, "AggregationScenarioDataIndices", "Index");
1419 }
1420
1421 DLOG("Loading AggregationScenarioDataCurrencies");
1422 if (XMLUtils::getChildNode(node, "AggregationScenarioDataCurrencies")) {
1424 XMLUtils::getChildrenValues(node, "AggregationScenarioDataCurrencies", "Currency", true);
1425 }
1426
1427 DLOG("Loading Securities");
1428 nodeChild = XMLUtils::getChildNode(node, "Securities");
1429 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
1430 // TODO 1) this should be renamed to SimulateSpread?
1431 // 2) add security recovery rates here separate from default curves?
1432 setSecuritySpreadsSimulate(XMLUtils::getChildValueAsBool(nodeChild, "Simulate", false));
1433 vector<string> securities = XMLUtils::getChildrenValues(nodeChild, "Names", "Name");
1435 }
1436
1437 DLOG("Loading CPRs");
1438 nodeChild = XMLUtils::getChildNode(node, "CPRs");
1439 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
1440 setSimulateCprs(XMLUtils::getChildValueAsBool(nodeChild, "Simulate", false));
1441 setCprs(XMLUtils::getChildrenValues(nodeChild, "Names", "Name"));
1442 }
1443
1444 DLOG("Loading BaseCorrelations");
1445 nodeChild = XMLUtils::getChildNode(node, "BaseCorrelations");
1446 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
1447 setSimulateBaseCorrelations(XMLUtils::getChildValueAsBool(nodeChild, "Simulate", true));
1448 setBaseCorrelationNames(XMLUtils::getChildrenValues(nodeChild, "IndexNames", "IndexName", true));
1451 XMLUtils::getChildrenValuesAsDoublesCompact(nodeChild, "DetachmentPoints", true);
1452 }
1453
1454 DLOG("Loading commodities data");
1455 nodeChild = XMLUtils::getChildNode(node, "Commodities");
1456 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
1457 XMLNode* commoditySimNode = XMLUtils::getChildNode(nodeChild, "Simulate");
1458 setCommodityCurveSimulate(commoditySimNode ? parseBool(XMLUtils::getNodeValue(commoditySimNode)) : false);
1459
1460 vector<string> commodityNames = XMLUtils::getChildrenValues(nodeChild, "Names", "Name", true);
1462
1463 set<string> names = params_.find(RiskFactorKey::KeyType::CommodityCurve)->second.second;
1464 QL_REQUIRE(names.size() > 0, "Commodities needs at least one name");
1465
1466 // Get the configured tenors. They are of the form:
1467 // - <Tenors name="NAME">t_1,...,t_n</Tenors> for commodity name specific tenors
1468 // - <Tenors>t_1,...,t_n</Tenors> or <Tenors name="">t_1,...,t_n</Tenors> for a default set of tenors
1469 // Only need a default tenor set if every commodity name has not been given a tenor set explicitly
1470 vector<XMLNode*> tenorNodes = XMLUtils::getChildrenNodes(nodeChild, "Tenors");
1471 QL_REQUIRE(tenorNodes.size() > 0, "Commodities needs at least one Tenors node");
1472 set<string> namesCheck = names;
1473 bool defaultProvided = false;
1474 for (XMLNode* tenorNode : tenorNodes) {
1475 // If there is no "name" attribute, getAttribute returns "" which is what we want in any case
1476 string name = XMLUtils::getAttribute(tenorNode, "name");
1477
1478 // An empty tenor list here means that the scenario simulation market should be set up on the
1479 // same pillars as the initial t_0 market from which it is sampling its values
1480 vector<Period> tenors;
1481 string strTenorList = XMLUtils::getNodeValue(tenorNode);
1482 if (!strTenorList.empty()) {
1483 tenors = parseListOfValues<Period>(XMLUtils::getNodeValue(tenorNode), &parsePeriod);
1484 }
1485
1486 QL_REQUIRE(commodityCurveTenors_.insert(make_pair(name, tenors)).second,
1487 "Commodities has duplicate expiries for key '" << name << "'");
1488 namesCheck.erase(name);
1489 defaultProvided = name == "";
1490 }
1491 QL_REQUIRE(defaultProvided || namesCheck.size() == 0, "Commodities has no tenors for "
1492 << "names '" << join(namesCheck, ",")
1493 << "' and no default tenor set has been given");
1494 }
1495
1496 DLOG("Loading commodity volatility data");
1497 nodeChild = XMLUtils::getChildNode(node, "CommodityVolatilities");
1498 if (nodeChild && XMLUtils::getChildNode(nodeChild)) {
1499 setCommodityVolSimulate(XMLUtils::getChildValueAsBool(nodeChild, "Simulate", true));
1500 commodityVolDecayMode_ = XMLUtils::getChildValue(nodeChild, "ReactionToTimeDecay");
1501
1502 vector<string> names;
1503 XMLNode* namesNode = XMLUtils::getChildNode(nodeChild, "Names");
1504 if (namesNode) {
1505 for (XMLNode* child = XMLUtils::getChildNode(namesNode, "Name"); child;
1506 child = XMLUtils::getNextSibling(child)) {
1507 // Get the vol configuration for each commodity name
1508 string name = XMLUtils::getAttribute(child, "id");
1509 names.push_back(name);
1511 vector<Real> moneyness = XMLUtils::getChildrenValuesAsDoublesCompact(child, "Moneyness", false);
1512 if (moneyness.empty())
1513 moneyness = {1.0};
1514 commodityVolMoneyness_[name] = moneyness;
1515 }
1516 }
1517 setCommodityVolNames(names);
1518 // Get smile dynamics
1519 vector<XMLNode*> smileDynamicsNodes = XMLUtils::getChildrenNodes(nodeChild, "SmileDynamics");
1520 for (XMLNode* smileDynamicsNode : smileDynamicsNodes) {
1521 string key = XMLUtils::getAttribute(smileDynamicsNode, "key");
1522 commodityVolSmileDynamics_.insert(make_pair(key, XMLUtils::getNodeValue(smileDynamicsNode)));
1523 }
1524 }
1525
1526 DLOG("Loading credit states data");
1527 nodeChild = XMLUtils::getChildNode(node, "CreditStates");
1529 if (nodeChild) {
1530 numberOfCreditStates_ = XMLUtils::getChildValueAsInt(nodeChild, "NumberOfFactors", true);
1531 }
1532
1533 DLOG("Loading AggregationScenarioDataCreditStates");
1534 nodeChild = XMLUtils::getChildNode(node, "AggregationScenarioDataCreditStates");
1536 if (nodeChild) {
1538 }
1539
1540 DLOG("Loading AggregationScenarioDataSurvivalWeights");
1541 additionalScenarioDataSurvivalWeights_ = XMLUtils::getChildrenValues(node, "AggregationScenarioDataSurvivalWeights", "Name");
1542
1543
1544 DLOG("Loaded ScenarioSimMarketParameters");
1545}
1546
1548
1549 XMLNode* simulationNode = doc.allocNode("Simulation");
1550 XMLNode* marketNode = doc.allocNode("Market");
1551
1552 // currencies
1553 XMLUtils::addChild(doc, marketNode, "BaseCurrency", baseCcy_);
1554 XMLUtils::addChildren(doc, marketNode, "Currencies", "Currency", ccys_);
1555
1556 // yield curves
1557 DLOG("Writing yield curves data");
1558 XMLNode* yieldCurvesNode = XMLUtils::addChild(doc, marketNode, "YieldCurves");
1559
1560 // Take the keys from the yieldCurveDayCounters_ and yieldCurveTenors_ maps
1561 set<string> keys;
1562 for (const auto& kv : yieldCurveTenors_) {
1563 keys.insert(kv.first);
1564 }
1565 QL_REQUIRE(keys.count("") > 0, "There is no default yield curve configuration in simulation parameters");
1566
1567 // Add the yield curve configuration nodes
1568 for (const auto& key : keys) {
1569 XMLNode* configNode = doc.allocNode("Configuration");
1570 XMLUtils::addAttribute(doc, configNode, "curve", key);
1571 if (yieldCurveTenors_.count(key) > 0) {
1572 XMLUtils::addGenericChildAsList(doc, configNode, "Tenors", yieldCurveTenors_.at(key));
1573 }
1574 if (key == "") {
1575 XMLUtils::addChild(doc, configNode, "Interpolation", interpolation_);
1576 XMLUtils::addChild(doc, configNode, "Extrapolation", extrapolation_);
1577 }
1578 XMLUtils::appendNode(yieldCurvesNode, configNode);
1579 }
1580
1581 // fx rates
1582 if (fxCcyPairs().size() > 0) {
1583 DLOG("Writing FX rates");
1584 XMLNode* fxRatesNode = XMLUtils::addChild(doc, marketNode, "FxRates");
1585 XMLUtils::addChildren(doc, fxRatesNode, "CurrencyPairs", "CurrencyPair", fxCcyPairs());
1586 }
1587
1588 // indices
1589 if (indices().size() > 0) {
1590 DLOG("Writing libor indices");
1591 XMLUtils::addChildren(doc, marketNode, "Indices", "Index", indices());
1592 }
1593
1594 // swap indices
1595 if (swapIndices_.size() > 0) {
1596 DLOG("Writing swap indices");
1597 XMLNode* swapIndicesNode = XMLUtils::addChild(doc, marketNode, "SwapIndices");
1598 for (auto kv : swapIndices_) {
1599 XMLNode* swapIndexNode = XMLUtils::addChild(doc, swapIndicesNode, "SwapIndex");
1600 XMLUtils::addChild(doc, swapIndexNode, "Name", kv.first);
1601 XMLUtils::addChild(doc, swapIndexNode, "DiscountingIndex", kv.second);
1602 }
1603 }
1604
1605 // default curves
1606 if (!defaultNames().empty()) {
1607 DLOG("Writing default curves");
1608 XMLNode* defaultCurvesNode = XMLUtils::addChild(doc, marketNode, "DefaultCurves");
1609 XMLUtils::addChildren(doc, defaultCurvesNode, "Names", "Name", defaultNames());
1610 XMLUtils::addGenericChildAsList(doc, defaultCurvesNode, "Tenors", lookup(defaultTenors_, ""));
1611 XMLUtils::addChild(doc, defaultCurvesNode, "SimulateSurvivalProbabilities", simulateSurvivalProbabilities());
1612 XMLUtils::addChild(doc, defaultCurvesNode, "SimulateRecoveryRates", simulateRecoveryRates());
1613
1614 if (defaultCurveCalendars_.size() > 0) {
1615 XMLNode* node = XMLUtils::addChild(doc, defaultCurvesNode, "Calendars");
1616 for (auto dc : defaultCurveCalendars_) {
1617 XMLNode* c = doc.allocNode("Calendar", dc.second);
1618 XMLUtils::addAttribute(doc, c, "name", dc.first);
1619 XMLUtils::appendNode(node, c);
1620 }
1621 }
1622
1623 if (!defaultCurveExtrapolation_.empty()) {
1624 XMLUtils::addChild(doc, defaultCurvesNode, "Extrapolation", defaultCurveExtrapolation_);
1625 }
1626 }
1627
1628 // equities
1629 if (!equityNames().empty()) {
1630 DLOG("Writing equities");
1631 XMLNode* equitiesNode = XMLUtils::addChild(doc, marketNode, "Equities");
1632 XMLUtils::addChild(doc, equitiesNode, "SimulateDividendYield", simulateDividendYield());
1633 XMLUtils::addChildren(doc, equitiesNode, "Names", "Name", equityNames());
1634 XMLUtils::addGenericChildAsList(doc, equitiesNode, "DividendTenors", lookup(equityDividendTenors_, ""));
1635 }
1636
1637 // swaption volatilities
1638 if (!swapVolKeys().empty()) {
1639 DLOG("Writing swaption volatilities");
1640 XMLNode* swaptionVolatilitiesNode = XMLUtils::addChild(doc, marketNode, "SwaptionVolatilities");
1641 XMLUtils::addChild(doc, swaptionVolatilitiesNode, "Simulate", simulateSwapVols());
1642 XMLUtils::addChild(doc, swaptionVolatilitiesNode, "ReactionToTimeDecay", swapVolDecayMode_);
1643 XMLUtils::addChildren(doc, swaptionVolatilitiesNode, "Keys", "Key", swapVolKeys());
1644 for (auto it = swapVolExpiries_.begin(); it != swapVolExpiries_.end(); it++) {
1645 XMLUtils::addGenericChildAsList(doc, swaptionVolatilitiesNode, "Expiries", swapVolExpiries_.find(it->first)->second,
1646 "key", it->first);
1647 }
1648 for (auto it = swapVolTerms_.begin(); it != swapVolTerms_.end(); it++) {
1649 XMLUtils::addGenericChildAsList(doc, swaptionVolatilitiesNode, "Terms", swapVolTerms_.find(it->first)->second, "key",
1650 it->first);
1651 }
1652
1654 XMLUtils::addChild(doc, swaptionVolatilitiesNode, "SimulateATMOnly", swapVolSimulateATMOnly_);
1655 } else {
1656 for (auto it = swapVolStrikeSpreads_.begin(); it != swapVolStrikeSpreads_.end(); it++) {
1657 XMLUtils::addGenericChildAsList(doc, swaptionVolatilitiesNode, "StrikeSpreads",
1658 swapVolStrikeSpreads_.find(it->first)->second, "key", it->first);
1659 }
1660 }
1661 for (auto it = swapVolSmileDynamics_.begin(); it != swapVolSmileDynamics_.end(); it++) {
1662 XMLUtils::addChild(doc, swaptionVolatilitiesNode, "SmileDynamics", it->second, "key", it->first);
1663 }
1664 }
1665
1666 // yield volatilities
1667 if (!yieldVolNames().empty()) {
1668 DLOG("Writing yield volatilities");
1669 XMLNode* yieldVolatilitiesNode = XMLUtils::addChild(doc, marketNode, "YieldVolatilities");
1670 XMLUtils::addChild(doc, yieldVolatilitiesNode, "Simulate", simulateYieldVols());
1671 XMLUtils::addChild(doc, yieldVolatilitiesNode, "ReactionToTimeDecay", yieldVolDecayMode_);
1672 XMLUtils::addChildren(doc, yieldVolatilitiesNode, "Names", "Name", yieldVolNames());
1673 XMLUtils::addGenericChildAsList(doc, yieldVolatilitiesNode, "Expiries", yieldVolExpiries_);
1674 XMLUtils::addGenericChildAsList(doc, yieldVolatilitiesNode, "Terms", yieldVolTerms_);
1675 for (auto it = yieldVolSmileDynamics_.begin(); it != yieldVolSmileDynamics_.end(); it++) {
1676 XMLUtils::addChild(doc, yieldVolatilitiesNode, "SmileDynamics", it->second, "key", it->first);
1677 }
1678 }
1679
1680 // cap/floor volatilities
1681 if (!capFloorVolKeys().empty()) {
1682 DLOG("Writing cap/floor volatilities");
1683 XMLNode* capFloorVolatilitiesNode = XMLUtils::addChild(doc, marketNode, "CapFloorVolatilities");
1684 XMLUtils::addChild(doc, capFloorVolatilitiesNode, "Simulate", simulateCapFloorVols());
1685 XMLUtils::addChild(doc, capFloorVolatilitiesNode, "ReactionToTimeDecay", capFloorVolDecayMode_);
1686 XMLUtils::addChildren(doc, capFloorVolatilitiesNode, "Keys", "Key", capFloorVolKeys());
1687
1688 // Write out cap floor expiries node for each key
1689 for (auto kv : capFloorVolExpiries_) {
1690 // If strikes vector is empty, the node value is ATM else it is the comma separated list of strikes
1691 // No checks here on the string repr of each strike value - dangerous but in lots of places.
1692 string nodeValue = join(kv.second | transformed([](Period p) { return ore::data::to_string(p); }), ",");
1693 XMLNode* expiriesNode = doc.allocNode("Expiries", nodeValue);
1694 XMLUtils::addAttribute(doc, expiriesNode, "key", kv.first);
1695 XMLUtils::appendNode(capFloorVolatilitiesNode, expiriesNode);
1696 }
1697
1698 // Write out cap floor strikes for each currency
1699 for (auto kv : capFloorVolStrikes_) {
1700 // If strikes vector is empty, the node value is ATM else it is the comma separated list of strikes
1701 // No checks here on the string repr of each strike value - dangerous but in lots of places.
1702 string nodeValue = kv.second.empty()
1703 ? "ATM"
1704 : join(kv.second | transformed([](Rate s) { return ore::data::to_string(s); }), ",");
1705 XMLNode* strikesNode = doc.allocNode("Strikes", nodeValue);
1706 XMLUtils::addAttribute(doc, strikesNode, "key", kv.first);
1707 XMLUtils::appendNode(capFloorVolatilitiesNode, strikesNode);
1708 }
1709
1710 XMLUtils::addChild(doc, capFloorVolatilitiesNode, "AdjustOptionletPillars",
1712 XMLUtils::addChild(doc, capFloorVolatilitiesNode, "UseCapAtm", capFloorVolUseCapAtm_);
1713 for (auto it = capFloorVolSmileDynamics_.begin(); it != capFloorVolSmileDynamics_.end(); it++) {
1714 XMLUtils::addChild(doc, capFloorVolatilitiesNode, "SmileDynamics", it->second, "key", it->first);
1715 }
1716 }
1717
1718 // zero inflation cap/floor volatilities
1719 if (!zeroInflationCapFloorVolNames().empty()) {
1720 DLOG("Writing zero inflation cap/floor volatilities");
1721 XMLNode* n = XMLUtils::addChild(doc, marketNode, "CPICapFloorVolatilities");
1723 XMLUtils::addChild(doc, n, "ReactionToTimeDecay", zeroInflationCapFloorVolDecayMode());
1724 XMLUtils::addChildren(doc, n, "Names", "Name", zeroInflationCapFloorVolNames());
1725
1726 // Write out cap floor expiries node for each currency
1727 for (auto kv : zeroInflationCapFloorVolExpiries_) {
1728 string nodeValue = join(kv.second | transformed([](Period p) { return ore::data::to_string(p); }), ",");
1729 XMLNode* expiriesNode = doc.allocNode("Expiries", nodeValue);
1730 XMLUtils::addAttribute(doc, expiriesNode, "name", kv.first);
1731 XMLUtils::appendNode(n, expiriesNode);
1732 }
1733
1734 // Write out cap floor strikes for each currency
1735 for (auto kv : zeroInflationCapFloorVolStrikes_) {
1736 string nodeValue = kv.second.empty()
1737 ? "ATM"
1738 : join(kv.second | transformed([](Rate s) { return ore::data::to_string(s); }), ",");
1739 XMLNode* strikesNode = doc.allocNode("Strikes", nodeValue);
1740 XMLUtils::addAttribute(doc, strikesNode, "name", kv.first);
1741 XMLUtils::appendNode(n, strikesNode);
1742 }
1743 for (auto it = zeroInflationCapFloorVolSmileDynamics_.begin();
1744 it != zeroInflationCapFloorVolSmileDynamics_.end(); it++) {
1745 XMLUtils::addChild(doc, n, "SmileDynamics", it->second, "key", it->first);
1746 }
1747 }
1748
1749 if (!cdsVolNames().empty()) {
1750 DLOG("Writing CDS volatilities");
1751 XMLNode* cdsVolatilitiesNode = XMLUtils::addChild(doc, marketNode, "CDSVolatilities");
1752 XMLUtils::addChild(doc, cdsVolatilitiesNode, "Simulate", simulateCdsVols());
1753 XMLUtils::addChild(doc, cdsVolatilitiesNode, "ReactionToTimeDecay", cdsVolDecayMode_);
1754 XMLUtils::addChildren(doc, cdsVolatilitiesNode, "Names", "Name", cdsVolNames());
1755 XMLUtils::addGenericChildAsList(doc, cdsVolatilitiesNode, "Expiries", cdsVolExpiries_);
1757 XMLUtils::addChild(doc, cdsVolatilitiesNode, "SimulateATMOnly", cdsVolSimulateATMOnly_);
1758 }
1759 for (auto it = cdsVolSmileDynamics_.begin(); it != cdsVolSmileDynamics_.end(); it++) {
1760 XMLUtils::addChild(doc, cdsVolatilitiesNode, "SmileDynamics", it->second, "key", it->first);
1761 }
1762 }
1763
1764 // fx volatilities
1765 if (!fxVolCcyPairs().empty()) {
1766 DLOG("Writing FX volatilities");
1767 XMLNode* fxVolatilitiesNode = XMLUtils::addChild(doc, marketNode, "FxVolatilities");
1768 XMLUtils::addChild(doc, fxVolatilitiesNode, "Simulate", simulateFXVols());
1769 XMLUtils::addChild(doc, fxVolatilitiesNode, "ReactionToTimeDecay", fxVolDecayMode_);
1770 XMLUtils::addChildren(doc, fxVolatilitiesNode, "CurrencyPairs", "CurrencyPair", fxVolCcyPairs());
1771 for (auto it = fxVolExpiries_.begin(); it != fxVolExpiries_.end(); it++) {
1772 XMLUtils::addGenericChildAsList(doc, fxVolatilitiesNode, "Expiries", fxVolExpiries_.find(it->first)->second, "ccyPair",
1773 it->first);
1774 }
1776 XMLUtils::addChild(doc, fxVolatilitiesNode, "SimulateATMOnly", fxVolSimulateATMOnly_);
1777 }
1778 if (fxVolSimulateATMOnly_ || fxMoneyness_.size() > 0 || fxStandardDevs_.size() > 0) {
1779 XMLNode* fxSurfaceNode = XMLUtils::addChild(doc, fxVolatilitiesNode, "Surface");
1780 for (auto it = fxMoneyness_.begin(); it != fxMoneyness_.end(); it++) {
1781 XMLUtils::addGenericChildAsList(doc, fxSurfaceNode, "Moneyness", equityMoneyness_.find(it->first)->second, "ccyPair",
1782 it->first);
1783 }
1784 for (auto it = fxStandardDevs_.begin(); it != fxStandardDevs_.end(); it++) {
1785 XMLUtils::addGenericChildAsList(doc, fxSurfaceNode, "StandardDeviations",
1786 fxStandardDevs_.find(it->first)->second, "ccyPair", it->first);
1787 }
1788 }
1789 for (auto it = fxVolSmileDynamics_.begin(); it != fxVolSmileDynamics_.end(); it++) {
1790 XMLUtils::addChild(doc, fxVolatilitiesNode, "SmileDynamics", it->second, "key", it->first);
1791 }
1792 }
1793
1794 // eq volatilities
1795 if (!equityVolNames().empty()) {
1796 DLOG("Writing equity volatilities");
1797 XMLNode* eqVolatilitiesNode = XMLUtils::addChild(doc, marketNode, "EquityVolatilities");
1798 XMLUtils::addChild(doc, eqVolatilitiesNode, "Simulate", simulateEquityVols());
1799 XMLUtils::addChild(doc, eqVolatilitiesNode, "ReactionToTimeDecay", equityVolDecayMode_);
1800 XMLUtils::addChildren(doc, eqVolatilitiesNode, "Names", "Name", equityVolNames());
1801 for (auto it = equityVolExpiries_.begin(); it != equityVolExpiries_.end(); it++) {
1802 XMLUtils::addGenericChildAsList(doc, eqVolatilitiesNode, "Expiries", equityVolExpiries_.find(it->first)->second, "name",
1803 it->first);
1804 }
1806 XMLUtils::addChild(doc, eqVolatilitiesNode, "SimulateATMOnly", equityVolSimulateATMOnly_);
1807 }
1808 if (equityVolSimulateATMOnly_ || equityMoneyness_.size() > 0 || equityStandardDevs_.size() > 0) {
1809 XMLNode* eqSurfaceNode = XMLUtils::addChild(doc, eqVolatilitiesNode, "Surface");
1810 for (auto it = equityMoneyness_.begin(); it != equityMoneyness_.end(); it++) {
1811 XMLUtils::addGenericChildAsList(doc, eqSurfaceNode, "Moneyness", equityMoneyness_.find(it->first)->second, "name",
1812 it->first);
1813 }
1814 for (auto it = equityStandardDevs_.begin(); it != equityStandardDevs_.end(); it++) {
1815 XMLUtils::addGenericChildAsList(doc, eqSurfaceNode, "StandardDeviations", equityStandardDevs_.find(it->first)->second, "name",
1816 it->first);
1817 }
1818 }
1819 for (auto it = equityVolSmileDynamics_.begin(); it != equityVolSmileDynamics_.end(); it++) {
1820 XMLUtils::addChild(doc, eqVolatilitiesNode, "SmileDynamics", it->second, "key", it->first);
1821 }
1822 }
1823
1824 // benchmark yield curves
1825 XMLNode* benchmarkCurvesNode = XMLUtils::addChild(doc, marketNode, "BenchmarkCurves");
1826 for (Size i = 0; i < yieldCurveNames().size(); ++i) {
1827 DLOG("Writing benchmark yield curves data");
1828 XMLNode* benchmarkCurveNode = XMLUtils::addChild(doc, benchmarkCurvesNode, "BenchmarkCurve");
1829 XMLUtils::addChild(doc, benchmarkCurveNode, "Currency", yieldCurveCurrencies_.find(yieldCurveNames()[i])->second);
1830 XMLUtils::addChild(doc, benchmarkCurveNode, "Name", yieldCurveNames()[i]);
1831 }
1832
1833 // securities
1834 if (!securities().empty()) {
1835 DLOG("Writing securities");
1836 XMLNode* secNode = XMLUtils::addChild(doc, marketNode, "Securities");
1837 XMLUtils::addChild(doc, secNode, "Simulate", securitySpreadsSimulate());
1838 XMLUtils::addChildren(doc, secNode, "Names", "Name", securities());
1839 }
1840
1841 // cprs
1842 if (!cprs().empty()) {
1843 DLOG("Writing cprs");
1844 XMLNode* cprNode = XMLUtils::addChild(doc, marketNode, "CPRs");
1845 XMLUtils::addChild(doc, cprNode, "Simulate", simulateCprs());
1846 XMLUtils::addChildren(doc, cprNode, "Names", "Name", cprs());
1847 }
1848
1849 // inflation indices
1850 if (!cpiIndices().empty()) {
1851 DLOG("Writing inflation indices");
1852 XMLUtils::addChildren(doc, marketNode, "CpiIndices", "Index", cpiIndices());
1853 }
1854
1855 // zero inflation
1856 if (!zeroInflationIndices().empty()) {
1857 DLOG("Writing zero inflation");
1858 XMLNode* zeroNode = XMLUtils::addChild(doc, marketNode, "ZeroInflationIndexCurves");
1859 XMLUtils::addChildren(doc, zeroNode, "Names", "Name", zeroInflationIndices());
1860 XMLUtils::addGenericChildAsList(doc, zeroNode, "Tenors", lookup(zeroInflationTenors_, ""));
1861 }
1862
1863 // yoy inflation
1864 if (!yoyInflationIndices().empty()) {
1865 DLOG("Writing year-on-year inflation");
1866 XMLNode* yoyNode = XMLUtils::addChild(doc, marketNode, "YYInflationIndexCurves");
1867 XMLUtils::addChildren(doc, yoyNode, "Names", "Name", yoyInflationIndices());
1868 XMLUtils::addGenericChildAsList(doc, yoyNode, "Tenors", lookup(yoyInflationTenors_, ""));
1869 }
1870
1871 // yoy cap/floor volatilities
1872 if (!yoyInflationCapFloorVolNames().empty()) {
1873 DLOG("Writing inflation cap/floor volatilities");
1874 XMLNode* n = XMLUtils::addChild(doc, marketNode, "YYCapFloorVolatilities");
1876 XMLUtils::addChild(doc, n, "ReactionToTimeDecay", yoyInflationCapFloorVolDecayMode());
1877 XMLUtils::addChildren(doc, n, "Names", "Name", yoyInflationCapFloorVolNames());
1878
1879 // Write out cap floor expiries node for each currency
1880 for (auto kv : yoyInflationCapFloorVolExpiries_) {
1881 string nodeValue = join(kv.second | transformed([](Period p) { return ore::data::to_string(p); }), ",");
1882 XMLNode* expiriesNode = doc.allocNode("Expiries", nodeValue);
1883 XMLUtils::addAttribute(doc, expiriesNode, "name", kv.first);
1884 XMLUtils::appendNode(n, expiriesNode);
1885 }
1886
1887 // Write out cap floor strikes for each currency
1888 for (auto kv : yoyInflationCapFloorVolStrikes_) {
1889 string nodeValue = kv.second.empty()
1890 ? "ATM"
1891 : join(kv.second | transformed([](Rate s) { return ore::data::to_string(s); }), ",");
1892 XMLNode* strikesNode = doc.allocNode("Strikes", nodeValue);
1893 XMLUtils::addAttribute(doc, strikesNode, "name", kv.first);
1894 XMLUtils::appendNode(n, strikesNode);
1895 }
1897 it++) {
1898 XMLUtils::addChild(doc, n, "SmileDynamics", it->second, "key", it->first);
1899 }
1900 }
1901
1902 // Commodity price curves
1903 if (!commodityNames().empty()) {
1904 DLOG("Writing commodity price curves");
1905 XMLNode* commodityPriceNode = XMLUtils::addChild(doc, marketNode, "Commodities");
1906 XMLUtils::addChild(doc, commodityPriceNode, "Simulate", commodityCurveSimulate());
1907 XMLUtils::addChildren(doc, commodityPriceNode, "Names", "Name", commodityNames());
1908
1909 // Write out tenors node for each commodity name
1910 for (auto kv : commodityCurveTenors_) {
1911 // Single bar here is a boost range adaptor. Documented here:
1912 // https://www.boost.org/doc/libs/1_71_0/libs/range/doc/html/range/reference/adaptors/introduction.html
1913 string nodeValue = join(kv.second | transformed([](Period p) { return ore::data::to_string(p); }), ",");
1914 XMLNode* tenorsNode = doc.allocNode("Tenors", nodeValue);
1915 XMLUtils::addAttribute(doc, tenorsNode, "name", kv.first);
1916 XMLUtils::appendNode(commodityPriceNode, tenorsNode);
1917 }
1918 }
1919
1920 // Commodity volatilities
1921 if (!commodityVolNames().empty()) {
1922 DLOG("Writing commodity volatilities");
1923 XMLNode* commodityVolatilitiesNode = XMLUtils::addChild(doc, marketNode, "CommodityVolatilities");
1924 XMLUtils::addChild(doc, commodityVolatilitiesNode, "Simulate", commodityVolSimulate());
1925 XMLUtils::addChild(doc, commodityVolatilitiesNode, "ReactionToTimeDecay", commodityVolDecayMode_);
1926 XMLNode* namesNode = XMLUtils::addChild(doc, commodityVolatilitiesNode, "Names");
1927 for (const auto& name : commodityVolNames()) {
1928 XMLNode* nameNode = doc.allocNode("Name");
1929 XMLUtils::addAttribute(doc, nameNode, "id", name);
1930 XMLUtils::addGenericChildAsList(doc, nameNode, "Expiries", commodityVolExpiries_.find(name)->second);
1931 XMLUtils::addGenericChildAsList(doc, nameNode, "Moneyness", commodityVolMoneyness_.find(name)->second);
1932 XMLUtils::appendNode(namesNode, nameNode);
1933 }
1934 for (auto it = commodityVolSmileDynamics_.begin(); it != commodityVolSmileDynamics_.end(); it++) {
1935 XMLUtils::addChild(doc, commodityVolatilitiesNode, "SmileDynamics", it->second, "key", it->first);
1936 }
1937 }
1938
1939 // additional scenario data currencies
1940 if (!additionalScenarioDataCcys_.empty()) {
1941 DLOG("Writing aggregation scenario data currencies");
1942 XMLUtils::addChildren(doc, marketNode, "AggregationScenarioDataCurrencies", "Currency",
1944 }
1945
1946 // additional scenario data indices
1947 if (!additionalScenarioDataIndices_.empty()) {
1948 DLOG("Writing aggregation scenario data indices");
1949 XMLUtils::addChildren(doc, marketNode, "AggregationScenarioDataIndices", "Index",
1951 }
1952
1953 // Credit States
1954 DLOG("Writing number of credit states");
1955 XMLNode* creditStatesNode = XMLUtils::addChild(doc, marketNode, "CreditStates");
1956 XMLUtils::addChild(doc, creditStatesNode, "NumberOfFactors", int(numberOfCreditStates_));
1957
1958 DLOG("Writing number of credit states, AggregationScenarioDataCreditStates");
1959 XMLNode* aggScenDataCreditStatesNode = XMLUtils::addChild(doc, marketNode, "AggregationScenarioDataCreditStates");
1960 XMLUtils::addChild(doc, aggScenDataCreditStatesNode, "NumberOfFactors",
1962
1963 // Survival Weights
1964 DLOG("Writing names that need tracking of survival weights");
1966 XMLUtils::addChildren(doc, marketNode, "AggregationScenarioDataSurvivalWeights", "Name",
1968 }
1969
1970 // base correlations
1971 if (!baseCorrelationNames().empty()) {
1972 DLOG("Writing base correlations");
1973 XMLNode* bcNode = XMLUtils::addChild(doc, marketNode, "BaseCorrelations");
1974 XMLUtils::addChild(doc, bcNode, "Simulate", simulateBaseCorrelations());
1975 XMLUtils::addChildren(doc, bcNode, "IndexNames", "IndexName", baseCorrelationNames());
1977 XMLUtils::addGenericChildAsList(doc, bcNode, "DetachmentPoints", baseCorrelationDetachmentPoints_);
1978 }
1979
1980 // correlations
1981 if (!correlationPairs().empty()) {
1982 DLOG("Writing correlation");
1983 XMLNode* correlationsNode = XMLUtils::addChild(doc, marketNode, "Correlations");
1984 XMLUtils::addChild(doc, correlationsNode, "Simulate", simulateCorrelations());
1985 XMLUtils::addChildren(doc, correlationsNode, "Pairs", "Pair", correlationPairs());
1986
1987 XMLUtils::addGenericChildAsList(doc, correlationsNode, "Expiries", correlationExpiries_);
1988 }
1989
1990 XMLUtils::appendNode(simulationNode, marketNode);
1991
1992 return simulationNode;
1993}
1994} // namespace analytics
1995} // namespace ore
KeyType
Risk Factor types.
Definition: scenario.hpp:51
void setSwapVolSmileDynamics(const string &key, const string &smileDynamics)
void setCapFloorVolIsAtm(const std::string &key, bool isAtm)
vector< string > paramsLookup(RiskFactorKey::KeyType k) const
bool fxUseMoneyness(const std::string &ccypair) const
const string & yieldVolSmileDynamics(const string &key) const
std::map< std::string, std::vector< QuantLib::Period > > commodityVolExpiries_
std::map< std::string, std::vector< QuantLib::Real > > commodityVolMoneyness_
const string & cdsVolSmileDynamics(const string &key) const
const map< string, vector< Period > > & yieldCurveTenors() const
const vector< QuantLib::Rate > & capFloorVolStrikes(const std::string &key) const
void setCapFloorVolStrikes(const std::string &key, const std::vector< QuantLib::Rate > &strikes)
void setYoyInflationTenors(const string &key, const vector< Period > &p)
bool fxVolIsSurface(const std::string &ccypair) const
void setDefaultTenors(const string &key, const vector< Period > &p)
void addParamsName(RiskFactorKey::KeyType kt, vector< string > names)
const vector< Real > & swapVolStrikeSpreads(const string &key) const
void setEquityVolSmileDynamics(const string &name, const string &smileDynamics)
const vector< Period > & swapVolTerms(const string &key) const
const vector< Period > & yoyInflationCapFloorVolExpiries(const string &key) const
void setCommodityCurveTenors(const std::string &commodityName, const std::vector< QuantLib::Period > &p)
void setCommodityVolSmileDynamics(const string &key, const string &smileDynamics)
void setYieldVolSmileDynamics(const string &key, const string &smileDynamics)
const vector< Real > & fxVolMoneyness(const string &ccypair) const
const string & zeroInflationCapFloorVolSmileDynamics(const string &key) const
map< std::string, std::vector< QuantLib::Rate > > capFloorVolStrikes_
const std::vector< QuantLib::Real > & commodityVolMoneyness(const std::string &commodityName) const
bool paramsSimulate(RiskFactorKey::KeyType kt) const
void setEquityVolIsSurface(const string &name, bool isSurface)
void setEquityVolMoneyness(const string &name, const vector< Real > &moneyness)
const string & commodityVolSmileDynamics(const string &commodityName) const
bool hasParamsName(RiskFactorKey::KeyType kt, string name) const
void setZeroInflationCapFloorVolStrikes(const std::string &key, const std::vector< QuantLib::Rate > &strikes)
const string & yoyInflationCapFloorVolSmileDynamics(const string &key) const
void setYoYInflationCapFloorVolSmileDynamics(const string &key, const string &smileDynamics)
void setZeroInflationCapFloorVolExpiries(const string &key, const vector< Period > &p)
void setFxVolStdDevs(const string &ccypair, const vector< Real > &stdDevs)
void setSwapVolTerms(const string &key, const vector< Period > &p)
void setEquityVolExpiries(const string &name, const vector< Period > &expiries)
const vector< Real > & fxVolStdDevs(const string &ccypair) const
void setZeroInflationCapFloorVolSmileDynamics(const string &key, const string &smileDynamics)
const vector< Period > & capFloorVolExpiries(const string &key) const
const vector< Period > & defaultTenors(const string &key) const
const vector< Real > & equityVolMoneyness(const string &key) const
bool operator!=(const ScenarioSimMarketParameters &rhs)
const std::vector< QuantLib::Period > & commodityCurveTenors(const std::string &commodityName) const
void setSwapVolStrikeSpreads(const std::string &key, const std::vector< QuantLib::Rate > &strikes)
void setCapFloorVolSmileDynamics(const string &key, const string &smileDynamics)
const vector< Period > & equityDividendTenors(const string &key) const
const vector< Period > & zeroInflationCapFloorVolExpiries(const string &key) const
const vector< Period > & swapVolExpiries(const string &key) const
void setFxVolExpiries(const string &name, const vector< Period > &expiries)
std::map< RiskFactorKey::KeyType, std::pair< bool, std::set< std::string > > > params_
const vector< Period > & fxVolExpiries(const string &key) const
const string & swapVolSmileDynamics(const string &key) const
void setSwapVolIsCube(const string &key, bool isCube)
bool operator==(const ScenarioSimMarketParameters &rhs)
virtual XMLNode * toXML(ore::data::XMLDocument &doc) const override
void setCdsVolSmileDynamics(const string &key, const string &smileDynamics)
const vector< Real > & yoyInflationCapFloorVolStrikes(const std::string &key) const
void setCapFloorVolExpiries(const string &key, const vector< Period > &p)
const string & defaultCurveCalendar(const string &key) const
bool hasCommodityCurveTenors(const std::string &commodityName) const
map< string, vector< Period > > zeroInflationCapFloorVolExpiries_
void setFxVolIsSurface(const string &ccypair, bool val)
void setFxVolSmileDynamics(const string &name, const string &smileDynamics)
void setParamsSimulate(RiskFactorKey::KeyType kt, bool simulate)
const vector< Real > & zeroInflationCapFloorVolStrikes(const string &key) const
const string & equityVolSmileDynamics(const string &key) const
const vector< Period > & yoyInflationTenors(const string &key) const
const vector< Period > & equityVolExpiries(const string &key) const
const string & fxVolSmileDynamics(const string &key) const
std::map< std::string, std::vector< QuantLib::Period > > commodityCurveTenors_
map< string, vector< Period > > yoyInflationCapFloorVolExpiries_
void reset()
A method used to reset the object to its default state before fromXML is called.
map< std::string, std::vector< QuantLib::Rate > > zeroInflationCapFloorVolStrikes_
void setEquityDividendTenors(const string &key, const vector< Period > &p)
const std::vector< QuantLib::Period > & commodityVolExpiries(const std::string &commodityName) const
void setDefaultCurveCalendars(const string &key, const string &p)
void setYoYInflationCapFloorVolExpiries(const string &key, const vector< Period > &p)
const vector< Real > & equityVolStandardDevs(const string &key) const
map< std::string, std::vector< QuantLib::Rate > > yoyInflationCapFloorVolStrikes_
void setYieldCurveTenors(const string &key, const vector< Period > &p)
void setYoYInflationCapFloorVolStrikes(const std::string &key, const std::vector< QuantLib::Rate > &strikes)
void setFxVolMoneyness(const string &ccypair, const vector< Real > &moneyness)
const vector< Period > & zeroInflationTenors(const string &key) const
void setEquityVolStandardDevs(const string &name, const vector< Real > &standardDevs)
void setSwapVolExpiries(const string &key, const vector< Period > &p)
const string & capFloorVolSmileDynamics(const string &key) const
void setZeroInflationTenors(const string &key, const vector< Period > &p)
XMLNode * allocNode(const string &nodeName)
static void addAttribute(XMLDocument &doc, XMLNode *node, const string &attrName, const string &attrValue)
static void addChildren(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values)
static string getAttribute(XMLNode *node, const string &attrName)
static void addGenericChildAsList(XMLDocument &doc, XMLNode *n, const string &name, const vector< T > &values, const string &attrName="", const string &attr="")
static void checkNode(XMLNode *n, const string &expectedName)
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
static XMLNode * locateNode(XMLNode *n, const string &name="")
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static string getNodeValue(XMLNode *node)
static int getChildValueAsInt(XMLNode *node, const string &name, bool mandatory=false, int defaultValue=0)
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
static vector< Real > getChildrenValuesAsDoublesCompact(XMLNode *node, const string &name, bool mandatory=false)
static vector< string > getChildrenValues(XMLNode *node, const string &names, const string &name, bool mandatory=false)
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
static vector< Period > getChildrenValuesAsPeriods(XMLNode *node, const string &name, bool mandatory=false)
static vector< Real > getNodeValueAsDoublesCompact(XMLNode *node)
Period parsePeriod(const string &s)
bool parseBool(const string &s)
Real parseReal(const string &s)
#define DLOG(text)
#define ALOG(text)
#define WLOG(text)
std::vector< std::string > getCorrelationTokens(const std::string &name)
Size size(const ValueType &v)
std::string to_string(const LocationInfo &l)
A class to hold Scenario parameters for scenarioSimMarket.
vector< Real > strikes
string name