30 {
32
35
38
41
42 StressTestData test;
44
45
46 LOG(
"Load stress test label " << test.label);
47
49 if (parShiftsNode) {
51 test.irCapFloorParShifts =
53 test.creditCurveParShifts =
55 }
56
57 LOG(
"Get recovery rate shift parameters");
58
59 test.recoveryRateShifts.clear();
61 if (recoveryRates) {
65 LOG(
"Loading stress parameters for recovery rate for " << isin);
69 test.recoveryRateShifts[isin] =
data;
70 }
71 }
72 LOG(
"Get survival probability shift parameters");
74 QL_REQUIRE(survivalProbability, "Survival Probabilities node not found");
75 test.survivalProbabilityShifts.clear();
79 LOG(
"Loading stress parameters for survival probability for " << name);
84 QL_REQUIRE(
data.shifts.size() ==
data.shiftTenors.size(),
85 "number of tenors and shifts does not match in survival probability stress data");
86 QL_REQUIRE(
data.shifts.size() > 0,
"no shifts provided in survival probability stress data");
87 test.survivalProbabilityShifts[
name] =
data;
88 }
89
90 LOG(
"Get discount curve shift parameters");
92 QL_REQUIRE(discountCurves, "DiscountCurves node not found");
93 test.discountCurveShifts.clear();
97 LOG(
"Loading stress parameters for discount curve for ccy " << ccy);
102 QL_REQUIRE(
data.shifts.size() ==
data.shiftTenors.size(),
103 "number of tenors (" <<
data.shiftTenors.size() <<
")and shifts (" <<
data.shifts.size()
104 << ") does not match in discount curve stress data for ccy = " << ccy);
105 QL_REQUIRE(
data.shifts.size() > 0,
"no shifts provided in discount curve stress data for ccy = " << ccy);
106 test.discountCurveShifts[ccy] =
data;
107 }
108
109 LOG(
"Get index curve stress parameters");
111 QL_REQUIRE(indexCurves, "IndexCurves node not found");
112 test.indexCurveShifts.clear();
116 LOG(
"Loading stress parameters for index " << index);
117
122 QL_REQUIRE(
data.shifts.size() ==
data.shiftTenors.size(),
123 "number of tenors (" <<
data.shiftTenors.size() <<
")and shifts (" <<
data.shifts.size()
124 << ") does not match in index curve stress data curve = " << index);
125 QL_REQUIRE(
data.shifts.size() > 0,
"no shifts provided in index curve stress data curve = " << index);
126 test.indexCurveShifts[index] =
data;
127 }
128
129 LOG(
"Get yield curve stress parameters");
131 QL_REQUIRE(yieldCurves, "YieldCurves node not found");
132 test.yieldCurveShifts.clear();
136 LOG(
"Loading stress parameters for yield curve " << name);
137
142 QL_REQUIRE(
data.shifts.size() ==
data.shiftTenors.size(),
143 "number of tenors (" <<
data.shiftTenors.size() <<
")and shifts (" <<
data.shifts.size()
144 << ") does not match in yield curve stress data curve = " << name);
145 QL_REQUIRE(
data.shifts.size() > 0,
"no shifts provided in yield curve stress data curve = " << name);
147 }
148
149 LOG(
"Get FX spot stress parameters");
151 QL_REQUIRE(fxSpots, "FxSpots node not found");
152 test.fxShifts.clear();
156 LOG(
"Loading stress parameters for FX " << ccypair);
160 test.fxShifts[ccypair] =
data;
161 }
162
163 LOG(
"Get fx vol stress parameters");
165 test.fxVolShifts.clear();
166 if (fxVols) {
170 LOG(
"Loading stress parameters for FX vols " << ccypair);
175 test.fxVolShifts[ccypair] =
data;
176 }
177 }
178 LOG(
"Get Equity spot stress parameters");
180 test.equityShifts.clear();
181 if (equitySpots) {
185 LOG(
"Loading stress parameters for Equity " << equity);
189 test.equityShifts[equity] =
data;
190 }
191 }
192 LOG(
"Get equity vol stress parameters");
194 QL_REQUIRE(equityVols, "EquityVolatilities node not found");
195 test.equityVolShifts.clear();
199 LOG(
"Loading stress parameters for Equity vols " << equity);
204 test.equityVolShifts[equity] =
data;
205 }
206
207 LOG(
"Get swaption vol stress parameters");
209 QL_REQUIRE(swaptionVols, "SwaptionVols node not found");
210 test.swaptionVolShifts.clear();
214 LOG(
"Loading stress parameters for swaption vols " << ccy);
215 SwaptionVolShiftData
data;
220 data.parallelShiftSize = 0.0;
225 if (expiry == "" && term == "")
227 else {
228 QL_REQUIRE(expiry != "" && term != "", "expiry and term attributes required on shift size nodes");
232 pair<Period, Period> key(e, t);
234 }
235 }
236 test.swaptionVolShifts[ccy] =
data;
237 }
238
239 LOG(
"Get cap/floor vol stress parameters");
241 QL_REQUIRE(capVols, "CapVols node not found");
242 test.capVolShifts.clear();
246 if (key.empty()) {
248 if (!ccyAttr.empty()) {
249 key = ccyAttr;
250 WLOG(
"StressScenarioData: 'ccy' is deprecated as an attribute for CapFloorVolatilities, use 'key' "
251 "instead.");
252 }
253 }
254 CapFloorVolShiftData
data;
263 QL_REQUIRE((
data.shiftStrikes.empty() &&
data.shifts[tenor].size() == 1) ||
264 (
data.shifts[tenor].size() ==
data.shiftStrikes.size()),
265 "StressScenarioData: CapFloor " << key << ": Mismatch between size of strikes ("
266 <<
data.shiftStrikes.size() <<
") and shifts ("
267 <<
data.shifts[tenor].size() <<
") for tenor "
269 }
270 QL_REQUIRE(
data.shifts.size() ==
data.shiftExpiries.size(),
271 "StressScenarioData: CapFloor " << key << ": Mismatch between size of expiries ("
272 <<
data.shiftExpiries.size() <<
") and shifts("
273 <<
data.shifts.size() <<
")");
274 test.capVolShifts[key] =
data;
275 }
276 LOG(
"Get Security spread stress parameters");
278 QL_REQUIRE(securitySpreads, "SecuritySpreads node not found");
279 test.securitySpreadShifts.clear();
283 LOG(
"Loading stress parameters for Security spreads " << bond);
287 test.securitySpreadShifts[bond] =
data;
288 }
289 data_.push_back(test);
290 LOG(
"Loading stress test label " << test.label <<
" done");
291 }
292 LOG(
"Loading stress tests done");
293}
const vector< StressTestData > & data() const
static string getAttribute(XMLNode *node, const string &attrName)
static void checkNode(XMLNode *n, const string &expectedName)
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
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 XMLNode * getNextSibling(XMLNode *node, const string &name="")
static vector< Real > getChildrenValuesAsDoublesCompact(XMLNode *node, const string &name, bool mandatory=false)
static vector< Period > getChildrenValuesAsPeriods(XMLNode *node, const string &name, bool mandatory=false)
static vector< Real > getNodeValueAsDoublesCompact(XMLNode *node)
SafeStack< ValueType > value
Period parsePeriod(const string &s)
bool parseBool(const string &s)
Real parseReal(const string &s)
ShiftType parseShiftType(const std::string &s)
std::string to_string(const LocationInfo &l)
SensitivityScenarioData::CurveShiftData CurveShiftData
SensitivityScenarioData::SpotShiftData SpotShiftData