Skip to content

Commit c4f5466

Browse files
pcaspersjenkins
authored andcommitted
QPR-12297 move simulateATMOnly flag one level up for FX, EQ, CDS vols
1 parent 273c0e3 commit c4f5466

2 files changed

Lines changed: 32 additions & 40 deletions

File tree

OREAnalytics/orea/scenario/scenariosimmarketparameters.cpp

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
*
22
Copyright (C) 2016 Quaternion Risk Management Ltd
33
All rights reserved.
44

@@ -134,7 +134,7 @@ void ScenarioSimMarketParameters::setDefaults() {
134134
setEquityVolSmileDynamics("", "StickyStrike");
135135
setCommodityVolSmileDynamics("", "StickyStrike");
136136

137-
// Set default tenors (don't know why but keep it as is)
137+
// Set default tenors
138138
defaultTenors_[""] = vector<Period>();
139139
equityDividendTenors_[""] = vector<Period>();
140140
zeroInflationTenors_[""] = vector<Period>();
@@ -143,9 +143,11 @@ void ScenarioSimMarketParameters::setDefaults() {
143143
defaultCurveCalendars_[""] = "TARGET";
144144
// Default fxVol params
145145
fxVolIsSurface_[""] = false;
146-
// Defaults for equity/fx
146+
// Defaults for simulate atm only
147147
setSimulateFxVolATMOnly(false);
148148
setSimulateEquityVolATMOnly(false);
149+
setSimulateSwapVolATMOnly(false);
150+
setSimulateCDSVollATMOnly(false);
149151
// Default interpolation for yield curves
150152
interpolation_ = "LogLinear";
151153
extrapolation_ = "FlatFwd";
@@ -664,12 +666,12 @@ bool ScenarioSimMarketParameters::operator==(const ScenarioSimMarketParameters&
664666
capFloorVolIsAtm_ != rhs.capFloorVolIsAtm_ || capFloorVolDecayMode_ != rhs.capFloorVolDecayMode_ ||
665667
defaultCurveCalendars_ != rhs.defaultCurveCalendars_ || defaultTenors_ != rhs.defaultTenors_ ||
666668
defaultCurveExtrapolation_ != rhs.defaultCurveExtrapolation_ || cdsVolExpiries_ != rhs.cdsVolExpiries_ ||
667-
cdsVolDecayMode_ != rhs.cdsVolDecayMode_ || equityDividendTenors_ != rhs.equityDividendTenors_ ||
668-
fxVolIsSurface_ != rhs.fxVolIsSurface_ ||
669+
cdsVolDecayMode_ != rhs.cdsVolDecayMode_ || cdsVolSimulateATMOnly_ != rhs.cdsVolSimulateATMOnly ||
670+
equityDividendTenors_ != rhs.equityDividendTenors_ || fxVolIsSurface_ != rhs.fxVolIsSurface_ ||
669671
fxVolExpiries_ != rhs.fxVolExpiries_ || fxVolDecayMode_ != rhs.fxVolDecayMode_ ||
670-
equityVolExpiries_ != rhs.equityVolExpiries_ || equityVolDecayMode_ != rhs.equityVolDecayMode_ ||
671-
equityVolSimulateATMOnly_ != rhs.equityVolSimulateATMOnly_ || equityMoneyness_ != rhs.equityMoneyness_ ||
672-
equityStandardDevs_ != rhs.equityStandardDevs_ ||
672+
fxVolSimulateATMOnly_ != rhs.fxVolSimulateATMOnly || equityVolExpiries_ != rhs.equityVolExpiries_ ||
673+
equityVolDecayMode_ != rhs.equityVolDecayMode_ || equityVolSimulateATMOnly_ != rhs.equityVolSimulateATMOnly_ ||
674+
equityMoneyness_ != rhs.equityMoneyness_ || equityStandardDevs_ != rhs.equityStandardDevs_ ||
673675
additionalScenarioDataIndices_ != rhs.additionalScenarioDataIndices_ ||
674676
additionalScenarioDataCcys_ != rhs.additionalScenarioDataCcys_ ||
675677
additionalScenarioDataNumberOfCreditStates_ != rhs.additionalScenarioDataNumberOfCreditStates_ ||
@@ -1248,15 +1250,10 @@ void ScenarioSimMarketParameters::fromXML(XMLNode* root) {
12481250
cdsVolExpiries_ = XMLUtils::getChildrenValuesAsPeriods(nodeChild, "Expiries", true);
12491251
setCdsVolNames(XMLUtils::getChildrenValues(nodeChild, "Names", "Name", true));
12501252
cdsVolDecayMode_ = XMLUtils::getChildValue(nodeChild, "ReactionToTimeDecay");
1251-
1252-
XMLNode* cdsSurfaceNode = XMLUtils::getChildNode(nodeChild, "Surface");
1253-
if (cdsSurfaceNode) {
1254-
XMLNode* atmOnlyNode = XMLUtils::getChildNode(cdsSurfaceNode, "SimulateATMOnly");
1255-
// if set to true we will simulate ATM only for any surfaces without an explicit surface defined
1256-
// adding a default surface of moneyness or standard deviations below will supersede this
1257-
if (atmOnlyNode) {
1258-
cdsVolSimulateATMOnly_ = XMLUtils::getChildValueAsBool(cdsSurfaceNode, "SimulateATMOnly", true);
1259-
}
1253+
1254+
XMLNode* atmOnlyNode = XMLUtils::getChildNode(nodeChild, "SimulateATMOnly");
1255+
if (atmOnlyNode) {
1256+
cdsVolSimulateATMOnly_ = XMLUtils::getChildValueAsBool(nodeChild, "SimulateATMOnly", true);
12601257
}
12611258

12621259
// Get smile dynamics
@@ -1297,12 +1294,6 @@ void ScenarioSimMarketParameters::fromXML(XMLNode* root) {
12971294
XMLNode* fxSurfaceNode = XMLUtils::getChildNode(nodeChild, "Surface");
12981295
setFxVolIsSurface("", false);
12991296
if (fxSurfaceNode) {
1300-
XMLNode* atmOnlyNode = XMLUtils::getChildNode(fxSurfaceNode, "SimulateATMOnly");
1301-
// if set to true we will simulate ATM only for any surfaces without an explicit surface defined
1302-
// adding a default surface of moneyness or standard deviations below will supersede this
1303-
if (atmOnlyNode) {
1304-
fxVolSimulateATMOnly_ = XMLUtils::getChildValueAsBool(fxSurfaceNode, "SimulateATMOnly", true);
1305-
}
13061297
for (XMLNode* child = XMLUtils::getChildNode(fxSurfaceNode, "Moneyness"); child;
13071298
child = XMLUtils::getNextSibling(child, "Moneyness")) {
13081299
string label = XMLUtils::getAttribute(child, "ccyPair"); // will be "" if no attr
@@ -1327,6 +1318,11 @@ void ScenarioSimMarketParameters::fromXML(XMLNode* root) {
13271318
}
13281319
}
13291320
}
1321+
} else {
1322+
XMLNode* atmOnlyNode = XMLUtils::getChildNode(nodeChild, "SimulateATMOnly");
1323+
if (atmOnlyNode) {
1324+
fxVolSimulateATMOnly_ = XMLUtils::getChildValueAsBool(nodeChild, "SimulateATMOnly", true);
1325+
}
13301326
}
13311327
// Get smile dynamics
13321328
vector<XMLNode*> smileDynamicsNodes = XMLUtils::getChildrenNodes(nodeChild, "SmileDynamics");
@@ -1363,12 +1359,6 @@ void ScenarioSimMarketParameters::fromXML(XMLNode* root) {
13631359
XMLNode* eqSurfaceNode = XMLUtils::getChildNode(nodeChild, "Surface");
13641360
setEquityVolIsSurface("", false);
13651361
if (eqSurfaceNode) {
1366-
XMLNode* atmOnlyNode = XMLUtils::getChildNode(eqSurfaceNode, "SimulateATMOnly");
1367-
// if set to true we will simulate ATM only for any surfaces without an explicit surface defined
1368-
// adding a default surface of moneyness or standard deviations below will supersede this
1369-
if (atmOnlyNode) {
1370-
equityVolSimulateATMOnly_ = XMLUtils::getChildValueAsBool(eqSurfaceNode, "SimulateATMOnly", true);
1371-
}
13721362
for (XMLNode* child = XMLUtils::getChildNode(eqSurfaceNode, "Moneyness"); child;
13731363
child = XMLUtils::getNextSibling(child, "Moneyness")) {
13741364
string label = XMLUtils::getAttribute(child, "name"); // will be "" if no attr
@@ -1392,7 +1382,10 @@ void ScenarioSimMarketParameters::fromXML(XMLNode* root) {
13921382
}
13931383
}
13941384
} else {
1395-
DLOG("No surface provided, all equity volatilities will be taken as ATM.");
1385+
XMLNode* atmOnlyNode = XMLUtils::getChildNode(nodeChild, "SimulateATMOnly");
1386+
if (atmOnlyNode) {
1387+
equityVolSimulateATMOnly_ = XMLUtils::getChildValueAsBool(nodeChild, "SimulateATMOnly", true);
1388+
}
13961389
}
13971390
// Get smile dynamics
13981391
vector<XMLNode*> smileDynamicsNodes = XMLUtils::getChildrenNodes(nodeChild, "SmileDynamics");
@@ -1761,8 +1754,7 @@ XMLNode* ScenarioSimMarketParameters::toXML(XMLDocument& doc) {
17611754
XMLUtils::addChildren(doc, cdsVolatilitiesNode, "Names", "Name", cdsVolNames());
17621755
XMLUtils::addGenericChildAsList(doc, cdsVolatilitiesNode, "Expiries", cdsVolExpiries_);
17631756
if (cdsVolSimulateATMOnly_) {
1764-
XMLNode* cdsSurfaceNode = XMLUtils::addChild(doc, cdsVolatilitiesNode, "Surface");
1765-
XMLUtils::addChild(doc, cdsSurfaceNode, "SimulateATMOnly", cdsVolSimulateATMOnly_);
1757+
XMLUtils::addChild(doc, cdsVolatilitiesNode, "SimulateATMOnly", cdsVolSimulateATMOnly_);
17661758
}
17671759
for (auto it = cdsVolSmileDynamics_.begin(); it != cdsVolSmileDynamics_.end(); it++) {
17681760
XMLUtils::addChild(doc, cdsVolatilitiesNode, "SmileDynamics", it->second, "key", it->first);
@@ -1780,11 +1772,11 @@ XMLNode* ScenarioSimMarketParameters::toXML(XMLDocument& doc) {
17801772
XMLUtils::addGenericChildAsList(doc, fxVolatilitiesNode, "Expiries", fxVolExpiries_[it->first], "ccyPair",
17811773
it->first);
17821774
}
1775+
if (fxVolSimulateATMOnly_) {
1776+
XMLUtils::addChild(doc, fxVolatilitiesNode, "SimulateATMOnly", fxVolSimulateATMOnly_);
1777+
}
17831778
if (fxVolSimulateATMOnly_ || fxMoneyness_.size() > 0 || fxStandardDevs_.size() > 0) {
17841779
XMLNode* fxSurfaceNode = XMLUtils::addChild(doc, fxVolatilitiesNode, "Surface");
1785-
if (fxVolSimulateATMOnly_) {
1786-
XMLUtils::addChild(doc, fxSurfaceNode, "SimulateATMOnly", fxVolSimulateATMOnly_);
1787-
}
17881780
for (auto it = fxMoneyness_.begin(); it != fxMoneyness_.end(); it++) {
17891781
XMLUtils::addGenericChildAsList(doc, fxSurfaceNode, "Moneyness", equityMoneyness_[it->first], "ccyPair",
17901782
it->first);
@@ -1810,11 +1802,11 @@ XMLNode* ScenarioSimMarketParameters::toXML(XMLDocument& doc) {
18101802
XMLUtils::addGenericChildAsList(doc, eqVolatilitiesNode, "Expiries", equityVolExpiries_[it->first], "name",
18111803
it->first);
18121804
}
1805+
if (equityVolSimulateATMOnly_) {
1806+
XMLUtils::addChild(doc, eqVolatilitiesNode, "SimulateATMOnly", equityVolSimulateATMOnly_);
1807+
}
18131808
if (equityVolSimulateATMOnly_ || equityMoneyness_.size() > 0 || equityStandardDevs_.size() > 0) {
18141809
XMLNode* eqSurfaceNode = XMLUtils::addChild(doc, eqVolatilitiesNode, "Surface");
1815-
if (equityVolSimulateATMOnly_) {
1816-
XMLUtils::addChild(doc, eqSurfaceNode, "SimulateATMOnly", equityVolSimulateATMOnly_);
1817-
}
18181810
for (auto it = equityMoneyness_.begin(); it != equityMoneyness_.end(); it++) {
18191811
XMLUtils::addGenericChildAsList(doc, eqSurfaceNode, "Moneyness", equityMoneyness_[it->first], "name",
18201812
it->first);

OREAnalytics/orea/scenario/scenariosimmarketparameters.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ScenarioSimMarketParameters : public XMLSerializable {
4848
public:
4949
//! Default constructor
5050
ScenarioSimMarketParameters()
51-
: swapVolIsCube_({{"", false}}), swapVolSimulateATMOnly_(false), swapVolStrikeSpreads_({{"", {0.0}}}),
51+
: swapVolIsCube_({{"", false}}), swapVolStrikeSpreads_({{"", {0.0}}}),
5252
capFloorVolAdjustOptionletPillars_(false), capFloorVolUseCapAtm_(false), cprSimulate_(false),
5353
correlationIsSurface_(false), correlationStrikes_({0.0}) {
5454
setDefaults();
@@ -418,7 +418,7 @@ class ScenarioSimMarketParameters : public XMLSerializable {
418418
string extrapolation_;
419419

420420
map<string, bool> swapVolIsCube_;
421-
bool swapVolSimulateATMOnly_;
421+
bool swapVolSimulateATMOnly_ = false;
422422
map<string, vector<Period>> swapVolTerms_;
423423
map<string, vector<Period>> swapVolExpiries_;
424424
map<string, vector<Real>> swapVolStrikeSpreads_;

0 commit comments

Comments
 (0)