Skip to content

Commit 0729952

Browse files
author
Roland Lichters
committed
format
1 parent 5f0e683 commit 0729952

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

OREAnalytics/orea/scenario/stressscenariodata.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ void StressTestScenarioData::fromXML(XMLNode* root) {
3636
useSpreadedTermStructures_ =
3737
ore::data::parseBool(XMLUtils::getChildValue(node, "UseSpreadedTermStructures", false, "false"));
3838

39-
40-
4139
for (XMLNode* testCase = XMLUtils::getChildNode(node, "StressTest"); testCase;
4240
testCase = XMLUtils::getNextSibling(testCase)) {
4341

@@ -57,7 +55,7 @@ void StressTestScenarioData::fromXML(XMLNode* root) {
5755
}
5856

5957
LOG("Get recovery rate shift parameters");
60-
58+
6159
test.recoveryRateShifts.clear();
6260
XMLNode* recoveryRates = XMLUtils::getChildNode(testCase, "RecoveryRates");
6361
if (recoveryRates) {
@@ -242,13 +240,14 @@ void StressTestScenarioData::fromXML(XMLNode* root) {
242240
for (XMLNode* child = XMLUtils::getChildNode(capVols, "CapFloorVolatility"); child;
243241
child = XMLUtils::getNextSibling(child)) {
244242
string key = XMLUtils::getAttribute(child, "key");
245-
if(key.empty()) {
246-
string ccyAttr = XMLUtils::getAttribute(child, "ccy");
247-
if(!ccyAttr.empty()) {
248-
key = ccyAttr;
249-
WLOG("StressScenarioData: 'ccy' is deprecated as an attribute for CapFloorVolatilities, use 'key' instead.");
250-
}
251-
}
243+
if (key.empty()) {
244+
string ccyAttr = XMLUtils::getAttribute(child, "ccy");
245+
if (!ccyAttr.empty()) {
246+
key = ccyAttr;
247+
WLOG("StressScenarioData: 'ccy' is deprecated as an attribute for CapFloorVolatilities, use 'key' "
248+
"instead.");
249+
}
250+
}
252251
CapFloorVolShiftData data;
253252
data.shiftType = parseShiftType(XMLUtils::getChildValue(child, "ShiftType", true));
254253
data.shiftExpiries = XMLUtils::getChildrenValuesAsPeriods(child, "ShiftExpiries", true);
@@ -292,8 +291,9 @@ void StressTestScenarioData::fromXML(XMLNode* root) {
292291

293292
void curveShiftDataToXml(ore::data::XMLDocument& doc, XMLNode* node,
294293
const std::map<std::string, StressTestScenarioData::CurveShiftData>& data,
295-
const std::string& identifier, const std::string& nodeName, const std::string& parentNodeName=std::string()) {
296-
std::string name = parentNodeName.empty() ? nodeName + "s" : parentNodeName;
294+
const std::string& identifier, const std::string& nodeName,
295+
const std::string& parentNodeName = std::string()) {
296+
std::string name = parentNodeName.empty() ? nodeName + "s" : parentNodeName;
297297
auto parentNode = XMLUtils::addChild(doc, node, name);
298298
for (const auto& [key, data] : data) {
299299
auto childNode = XMLUtils::addChild(doc, parentNode, nodeName);
@@ -337,7 +337,7 @@ XMLNode* StressTestScenarioData::toXML(ore::data::XMLDocument& doc) const {
337337
// Add test node
338338
auto testNode = XMLUtils::addChild(doc, node, "StressTest");
339339
XMLUtils::addAttribute(doc, testNode, "id", test.label);
340-
// Add Par Shifts node
340+
// Add Par Shifts node
341341
auto parShiftsNode = XMLUtils::addChild(doc, testNode, "ParShifts");
342342
XMLUtils::addChild(doc, parShiftsNode, "IRCurves", test.irCurveParShifts);
343343
XMLUtils::addChild(doc, parShiftsNode, "CapFloorVolatilities", test.irCapFloorParShifts);
@@ -373,16 +373,17 @@ XMLNode* StressTestScenarioData::toXML(ore::data::XMLDocument& doc) const {
373373
XMLUtils::addGenericChildAsList(doc, swaptionVolNode, "ShiftTerms", data.shiftTerms);
374374
XMLUtils::addGenericChildAsList(doc, swaptionVolNode, "ShiftExpiries", data.shiftExpiries);
375375
XMLNode* shiftSizesNode = XMLUtils::addChild(doc, swaptionVolNode, "Shifts");
376-
377-
if(data.shifts.empty()){
376+
377+
if (data.shifts.empty()) {
378378
XMLUtils::addChild(doc, shiftSizesNode, "Shift", ore::data::to_string(data.parallelShiftSize),
379379
swaptionAttributeNames, {"", ""});
380380
} else {
381-
for(const auto& [key, shift] : data.shifts){
381+
for (const auto& [key, shift] : data.shifts) {
382382
const auto& [expiry, term] = key;
383383
std::vector<std::string> attributeValues = {ore::data::to_string(expiry),
384384
ore::data::to_string(term)};
385-
XMLUtils::addChild(doc, shiftSizesNode, "Shift", ore::data::to_string(shift), swaptionAttributeNames, attributeValues);
385+
XMLUtils::addChild(doc, shiftSizesNode, "Shift", ore::data::to_string(shift),
386+
swaptionAttributeNames, attributeValues);
386387
}
387388
}
388389
}

0 commit comments

Comments
 (0)