Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
SensitivityScenarioData Class Reference

Description of sensitivity shift scenarios. More...

#include <orea/scenario/sensitivityscenariodata.hpp>

+ Inheritance diagram for SensitivityScenarioData:
+ Collaboration diagram for SensitivityScenarioData:

Classes

struct  BaseCorrelationShiftData
 
struct  CapFloorVolShiftData
 
struct  CapFloorVolShiftParData
 
struct  CdsVolShiftData
 
struct  CurveShiftData
 
struct  CurveShiftParData
 
struct  GenericYieldVolShiftData
 
struct  ShiftData
 
struct  VolShiftData
 

Public Types

using SpotShiftData = ShiftData
 

Public Member Functions

 SensitivityScenarioData (bool parConversion=true)
 Default constructor. More...
 
Inspectors
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & discountCurveShiftData () const
 
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & indexCurveShiftData () const
 
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & yieldCurveShiftData () const
 
const map< string, SpotShiftData > & fxShiftData () const
 
const map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & capFloorVolShiftData () const
 
const map< string, GenericYieldVolShiftData > & swaptionVolShiftData () const
 
const map< string, GenericYieldVolShiftData > & yieldVolShiftData () const
 
const map< string, VolShiftData > & fxVolShiftData () const
 
const map< string, CdsVolShiftData > & cdsVolShiftData () const
 
const map< string, BaseCorrelationShiftData > & baseCorrelationShiftData () const
 
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & zeroInflationCurveShiftData () const
 
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & yoyInflationCurveShiftData () const
 
const map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & yoyInflationCapFloorVolShiftData () const
 
const map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & zeroInflationCapFloorVolShiftData () const
 
const map< string, string > & creditCcys () const
 
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & creditCurveShiftData () const
 
const map< string, SpotShiftData > & equityShiftData () const
 
const map< string, VolShiftData > & equityVolShiftData () const
 
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & dividendYieldShiftData () const
 
const map< string, string > & commodityCurrencies () const
 
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & commodityCurveShiftData () const
 
const map< string, VolShiftData > & commodityVolShiftData () const
 
const map< string, VolShiftData > & correlationShiftData () const
 
const map< string, SpotShiftData > & securityShiftData () const
 
const vector< pair< string, string > > & crossGammaFilter () const
 
const bool computeGamma () const
 
const bool useSpreadedTermStructures () const
 
const ShiftDatashiftData (const ore::analytics::RiskFactorKey::KeyType &keyType, const std::string &name) const
 Give back the shift data for the given risk factor type, keyType, with the given name. More...
 
Setters
boolparConversion ()
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & discountCurveShiftData ()
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & indexCurveShiftData ()
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & yieldCurveShiftData ()
 
map< string, SpotShiftData > & fxShiftData ()
 
map< string, GenericYieldVolShiftData > & swaptionVolShiftData ()
 
map< string, GenericYieldVolShiftData > & yieldVolShiftData ()
 
map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & capFloorVolShiftData ()
 
map< string, VolShiftData > & fxVolShiftData ()
 
map< string, CdsVolShiftData > & cdsVolShiftData ()
 
map< string, BaseCorrelationShiftData > & baseCorrelationShiftData ()
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & zeroInflationCurveShiftData ()
 
map< string, string > & creditCcys ()
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & creditCurveShiftData ()
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & yoyInflationCurveShiftData ()
 
map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & yoyInflationCapFloorVolShiftData ()
 
map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & zeroInflationCapFloorVolShiftData ()
 
map< string, SpotShiftData > & equityShiftData ()
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & dividendYieldShiftData ()
 
map< string, VolShiftData > & equityVolShiftData ()
 
map< string, string > & commodityCurrencies ()
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & commodityCurveShiftData ()
 
map< string, VolShiftData > & commodityVolShiftData ()
 
map< string, VolShiftData > & correlationShiftData ()
 
map< string, SpotShiftData > & securityShiftData ()
 
vector< pair< string, string > > & crossGammaFilter ()
 
boolcomputeGamma ()
 
booluseSpreadedTermStructures ()
 
Serialisation
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
- Public Member Functions inherited from XMLSerializable
virtual ~XMLSerializable ()
 
virtual void fromXML (XMLNode *node)=0
 
virtual XMLNodetoXML (XMLDocument &doc) const=0
 
void fromFile (const std::string &filename)
 
void toFile (const std::string &filename) const
 
void fromXMLString (const std::string &xml)
 
std::string toXMLString () const
 

Equality Operators

map< string, QuantLib::ext::shared_ptr< CurveShiftData > > discountCurveShiftData_
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > indexCurveShiftData_
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > yieldCurveShiftData_
 
map< string, SpotShiftDatafxShiftData_
 
map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > capFloorVolShiftData_
 
map< string, GenericYieldVolShiftDataswaptionVolShiftData_
 
map< string, GenericYieldVolShiftDatayieldVolShiftData_
 
map< string, VolShiftDatafxVolShiftData_
 
map< string, CdsVolShiftDatacdsVolShiftData_
 
map< string, BaseCorrelationShiftDatabaseCorrelationShiftData_
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > zeroInflationCurveShiftData_
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > yoyInflationCurveShiftData_
 
map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > yoyInflationCapFloorVolShiftData_
 
map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > zeroInflationCapFloorVolShiftData_
 
map< string, string > creditCcys_
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > creditCurveShiftData_
 
map< string, SpotShiftDataequityShiftData_
 
map< string, VolShiftDataequityVolShiftData_
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > dividendYieldShiftData_
 
map< string, std::string > commodityCurrencies_
 
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > commodityCurveShiftData_
 
map< string, VolShiftDatacorrelationShiftData_
 
map< string, VolShiftDatacommodityVolShiftData_
 
map< string, SpotShiftDatasecurityShiftData_
 
vector< pair< string, string > > crossGammaFilter_
 
bool computeGamma_
 
bool useSpreadedTermStructures_
 
bool parConversion_
 
string getIndexCurrency (string indexName)
 Utilities. More...
 
void shiftDataFromXML (XMLNode *child, ShiftData &data)
 
void curveShiftDataFromXML (XMLNode *child, CurveShiftData &data)
 
void volShiftDataFromXML (XMLNode *child, VolShiftData &data, const bool requireShiftStrikes=true)
 
void shiftDataToXML (ore::data::XMLDocument &doc, XMLNode *node, const ShiftData &data) const
 toXML helper methods More...
 
void curveShiftDataToXML (ore::data::XMLDocument &doc, XMLNode *node, const CurveShiftData &data) const
 
void volShiftDataToXML (ore::data::XMLDocument &doc, XMLNode *node, const VolShiftData &data) const
 
void parDataFromXML (XMLNode *child, CurveShiftParData &data)
 
XMLNodeparDataToXML (ore::data::XMLDocument &doc, const QuantLib::ext::shared_ptr< CurveShiftData > &csd) const
 toXML helper method More...
 

Detailed Description

Description of sensitivity shift scenarios.

Definition at line 46 of file sensitivityscenariodata.hpp.

Member Typedef Documentation

◆ SpotShiftData

Definition at line 69 of file sensitivityscenariodata.hpp.

Constructor & Destructor Documentation

◆ SensitivityScenarioData()

SensitivityScenarioData ( bool  parConversion = true)

Member Function Documentation

◆ discountCurveShiftData() [1/2]

const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & discountCurveShiftData ( ) const

Definition at line 145 of file sensitivityscenariodata.hpp.

145 {
147 }
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > discountCurveShiftData_
+ Here is the caller graph for this function:

◆ indexCurveShiftData() [1/2]

const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & indexCurveShiftData ( ) const

Definition at line 148 of file sensitivityscenariodata.hpp.

148{ return indexCurveShiftData_; }
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > indexCurveShiftData_
+ Here is the caller graph for this function:

◆ yieldCurveShiftData() [1/2]

const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & yieldCurveShiftData ( ) const

Definition at line 149 of file sensitivityscenariodata.hpp.

149{ return yieldCurveShiftData_; }
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > yieldCurveShiftData_
+ Here is the caller graph for this function:

◆ fxShiftData() [1/2]

const map< string, SpotShiftData > & fxShiftData ( ) const

Definition at line 150 of file sensitivityscenariodata.hpp.

150{ return fxShiftData_; }
+ Here is the caller graph for this function:

◆ capFloorVolShiftData() [1/2]

const map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & capFloorVolShiftData ( ) const

Definition at line 151 of file sensitivityscenariodata.hpp.

151 {
153 }
map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > capFloorVolShiftData_
+ Here is the caller graph for this function:

◆ swaptionVolShiftData() [1/2]

const map< string, GenericYieldVolShiftData > & swaptionVolShiftData ( ) const

Definition at line 154 of file sensitivityscenariodata.hpp.

154{ return swaptionVolShiftData_; }
map< string, GenericYieldVolShiftData > swaptionVolShiftData_
+ Here is the caller graph for this function:

◆ yieldVolShiftData() [1/2]

const map< string, GenericYieldVolShiftData > & yieldVolShiftData ( ) const

Definition at line 155 of file sensitivityscenariodata.hpp.

155{ return yieldVolShiftData_; }
map< string, GenericYieldVolShiftData > yieldVolShiftData_
+ Here is the caller graph for this function:

◆ fxVolShiftData() [1/2]

const map< string, VolShiftData > & fxVolShiftData ( ) const

Definition at line 156 of file sensitivityscenariodata.hpp.

156{ return fxVolShiftData_; }
+ Here is the caller graph for this function:

◆ cdsVolShiftData() [1/2]

const map< string, CdsVolShiftData > & cdsVolShiftData ( ) const

Definition at line 157 of file sensitivityscenariodata.hpp.

157{ return cdsVolShiftData_; }
map< string, CdsVolShiftData > cdsVolShiftData_
+ Here is the caller graph for this function:

◆ baseCorrelationShiftData() [1/2]

const map< string, BaseCorrelationShiftData > & baseCorrelationShiftData ( ) const

Definition at line 158 of file sensitivityscenariodata.hpp.

map< string, BaseCorrelationShiftData > baseCorrelationShiftData_
+ Here is the caller graph for this function:

◆ zeroInflationCurveShiftData() [1/2]

const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & zeroInflationCurveShiftData ( ) const

Definition at line 159 of file sensitivityscenariodata.hpp.

159 {
161 }
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > zeroInflationCurveShiftData_
+ Here is the caller graph for this function:

◆ yoyInflationCurveShiftData() [1/2]

const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & yoyInflationCurveShiftData ( ) const

Definition at line 162 of file sensitivityscenariodata.hpp.

162 {
164 }
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > yoyInflationCurveShiftData_
+ Here is the caller graph for this function:

◆ yoyInflationCapFloorVolShiftData() [1/2]

const map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & yoyInflationCapFloorVolShiftData ( ) const

Definition at line 165 of file sensitivityscenariodata.hpp.

165 {
167 }
map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > yoyInflationCapFloorVolShiftData_
+ Here is the caller graph for this function:

◆ zeroInflationCapFloorVolShiftData() [1/2]

const map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & zeroInflationCapFloorVolShiftData ( ) const

Definition at line 168 of file sensitivityscenariodata.hpp.

168 {
170 }
map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > zeroInflationCapFloorVolShiftData_
+ Here is the caller graph for this function:

◆ creditCcys() [1/2]

const map< string, string > & creditCcys ( ) const

Definition at line 171 of file sensitivityscenariodata.hpp.

171{ return creditCcys_; }
+ Here is the caller graph for this function:

◆ creditCurveShiftData() [1/2]

const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & creditCurveShiftData ( ) const

Definition at line 172 of file sensitivityscenariodata.hpp.

172{ return creditCurveShiftData_; }
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > creditCurveShiftData_
+ Here is the caller graph for this function:

◆ equityShiftData() [1/2]

const map< string, SpotShiftData > & equityShiftData ( ) const

Definition at line 173 of file sensitivityscenariodata.hpp.

173{ return equityShiftData_; }
+ Here is the caller graph for this function:

◆ equityVolShiftData() [1/2]

const map< string, VolShiftData > & equityVolShiftData ( ) const

Definition at line 174 of file sensitivityscenariodata.hpp.

174{ return equityVolShiftData_; }
+ Here is the caller graph for this function:

◆ dividendYieldShiftData() [1/2]

const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & dividendYieldShiftData ( ) const

Definition at line 175 of file sensitivityscenariodata.hpp.

175 {
177 }
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > dividendYieldShiftData_
+ Here is the caller graph for this function:

◆ commodityCurrencies() [1/2]

const map< string, string > & commodityCurrencies ( ) const

Definition at line 178 of file sensitivityscenariodata.hpp.

178{ return commodityCurrencies_; }

◆ commodityCurveShiftData() [1/2]

const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & commodityCurveShiftData ( ) const

Definition at line 179 of file sensitivityscenariodata.hpp.

179 {
181 }
map< string, QuantLib::ext::shared_ptr< CurveShiftData > > commodityCurveShiftData_
+ Here is the caller graph for this function:

◆ commodityVolShiftData() [1/2]

const map< string, VolShiftData > & commodityVolShiftData ( ) const

Definition at line 182 of file sensitivityscenariodata.hpp.

182{ return commodityVolShiftData_; }
+ Here is the caller graph for this function:

◆ correlationShiftData() [1/2]

const map< string, VolShiftData > & correlationShiftData ( ) const

Definition at line 183 of file sensitivityscenariodata.hpp.

183{ return correlationShiftData_; }
+ Here is the caller graph for this function:

◆ securityShiftData() [1/2]

const map< string, SpotShiftData > & securityShiftData ( ) const

Definition at line 184 of file sensitivityscenariodata.hpp.

184{ return securityShiftData_; }
+ Here is the caller graph for this function:

◆ crossGammaFilter() [1/2]

const vector< pair< string, string > > & crossGammaFilter ( ) const

Definition at line 186 of file sensitivityscenariodata.hpp.

186{ return crossGammaFilter_; }
vector< pair< string, string > > crossGammaFilter_

◆ computeGamma() [1/2]

const bool computeGamma ( ) const

Definition at line 187 of file sensitivityscenariodata.hpp.

187{ return computeGamma_; }

◆ useSpreadedTermStructures() [1/2]

const bool useSpreadedTermStructures ( ) const

Definition at line 188 of file sensitivityscenariodata.hpp.

◆ shiftData()

const ShiftData & shiftData ( const ore::analytics::RiskFactorKey::KeyType keyType,
const std::string &  name 
) const

Give back the shift data for the given risk factor type, keyType, with the given name.

Definition at line 149 of file sensitivityscenariodata.cpp.

149 {
150 // Not nice but not spending time refactoring the class now.
151 switch (keyType) {
152 case RFType::DiscountCurve:
153 return *discountCurveShiftData().at(name);
154 case RFType::IndexCurve:
155 return *indexCurveShiftData().at(name);
156 case RFType::YieldCurve:
157 return *yieldCurveShiftData().at(name);
158 case RFType::FXSpot:
159 return fxShiftData().at(name);
160 case RFType::SwaptionVolatility:
161 return swaptionVolShiftData().at(name);
162 case RFType::YieldVolatility:
163 return yieldVolShiftData().at(name);
164 case RFType::OptionletVolatility:
165 return *capFloorVolShiftData().at(name);
166 case RFType::FXVolatility:
167 return fxVolShiftData().at(name);
168 case RFType::CDSVolatility:
169 return cdsVolShiftData().at(name);
170 case RFType::BaseCorrelation:
171 return baseCorrelationShiftData().at(name);
172 case RFType::ZeroInflationCurve:
173 return *zeroInflationCurveShiftData().at(name);
174 case RFType::SurvivalProbability:
175 return *creditCurveShiftData().at(name);
176 case RFType::YoYInflationCurve:
177 return *yoyInflationCurveShiftData().at(name);
178 case RFType::YoYInflationCapFloorVolatility:
179 return *yoyInflationCapFloorVolShiftData().at(name);
180 case RFType::ZeroInflationCapFloorVolatility:
181 return *zeroInflationCapFloorVolShiftData().at(name);
182 case RFType::EquitySpot:
183 return equityShiftData().at(name);
184 case RFType::EquityVolatility:
185 return equityVolShiftData().at(name);
186 case RFType::DividendYield:
187 return *dividendYieldShiftData().at(name);
188 case RFType::CommodityCurve:
189 return *commodityCurveShiftData().at(name);
190 case RFType::CommodityVolatility:
191 return commodityVolShiftData().at(name);
192 case RFType::SecuritySpread:
193 return securityShiftData().at(name);
194 case RFType::Correlation:
195 return correlationShiftData().at(name);
196 default:
197 QL_FAIL("Cannot return shift data for key type: " << keyType);
198 }
199}
const map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & yoyInflationCapFloorVolShiftData() const
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & indexCurveShiftData() const
const map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & capFloorVolShiftData() const
const map< string, SpotShiftData > & securityShiftData() const
const map< string, VolShiftData > & equityVolShiftData() const
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & discountCurveShiftData() const
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & dividendYieldShiftData() const
const map< string, VolShiftData > & fxVolShiftData() const
const map< string, GenericYieldVolShiftData > & yieldVolShiftData() const
const map< string, VolShiftData > & correlationShiftData() const
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & zeroInflationCurveShiftData() const
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & creditCurveShiftData() const
const map< string, SpotShiftData > & fxShiftData() const
const map< string, GenericYieldVolShiftData > & swaptionVolShiftData() const
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & yoyInflationCurveShiftData() const
const map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & zeroInflationCapFloorVolShiftData() const
const map< string, BaseCorrelationShiftData > & baseCorrelationShiftData() const
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & yieldCurveShiftData() const
const map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & commodityCurveShiftData() const
const map< string, VolShiftData > & commodityVolShiftData() const
const map< string, CdsVolShiftData > & cdsVolShiftData() const
const map< string, SpotShiftData > & equityShiftData() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parConversion()

bool & parConversion ( )

Definition at line 196 of file sensitivityscenariodata.hpp.

196{ return parConversion_; }

◆ discountCurveShiftData() [2/2]

map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & discountCurveShiftData ( )

Definition at line 198 of file sensitivityscenariodata.hpp.

198{ return discountCurveShiftData_; }

◆ indexCurveShiftData() [2/2]

map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & indexCurveShiftData ( )

Definition at line 199 of file sensitivityscenariodata.hpp.

199{ return indexCurveShiftData_; }

◆ yieldCurveShiftData() [2/2]

map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & yieldCurveShiftData ( )

Definition at line 200 of file sensitivityscenariodata.hpp.

200{ return yieldCurveShiftData_; }

◆ fxShiftData() [2/2]

map< string, SpotShiftData > & fxShiftData ( )

Definition at line 201 of file sensitivityscenariodata.hpp.

201{ return fxShiftData_; }

◆ swaptionVolShiftData() [2/2]

map< string, GenericYieldVolShiftData > & swaptionVolShiftData ( )

Definition at line 202 of file sensitivityscenariodata.hpp.

202{ return swaptionVolShiftData_; }

◆ yieldVolShiftData() [2/2]

map< string, GenericYieldVolShiftData > & yieldVolShiftData ( )

Definition at line 203 of file sensitivityscenariodata.hpp.

203{ return yieldVolShiftData_; }

◆ capFloorVolShiftData() [2/2]

map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & capFloorVolShiftData ( )

Definition at line 204 of file sensitivityscenariodata.hpp.

204{ return capFloorVolShiftData_; }

◆ fxVolShiftData() [2/2]

map< string, VolShiftData > & fxVolShiftData ( )

Definition at line 205 of file sensitivityscenariodata.hpp.

205{ return fxVolShiftData_; }

◆ cdsVolShiftData() [2/2]

map< string, CdsVolShiftData > & cdsVolShiftData ( )

Definition at line 206 of file sensitivityscenariodata.hpp.

206{ return cdsVolShiftData_; }

◆ baseCorrelationShiftData() [2/2]

map< string, BaseCorrelationShiftData > & baseCorrelationShiftData ( )

Definition at line 207 of file sensitivityscenariodata.hpp.

◆ zeroInflationCurveShiftData() [2/2]

map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & zeroInflationCurveShiftData ( )

Definition at line 208 of file sensitivityscenariodata.hpp.

208 {
210 }

◆ creditCcys() [2/2]

map< string, string > & creditCcys ( )

Definition at line 211 of file sensitivityscenariodata.hpp.

211{ return creditCcys_; }

◆ creditCurveShiftData() [2/2]

map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & creditCurveShiftData ( )

Definition at line 212 of file sensitivityscenariodata.hpp.

212{ return creditCurveShiftData_; }

◆ yoyInflationCurveShiftData() [2/2]

map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & yoyInflationCurveShiftData ( )

Definition at line 213 of file sensitivityscenariodata.hpp.

◆ yoyInflationCapFloorVolShiftData() [2/2]

map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & yoyInflationCapFloorVolShiftData ( )

Definition at line 214 of file sensitivityscenariodata.hpp.

214 {
216 }

◆ zeroInflationCapFloorVolShiftData() [2/2]

map< string, QuantLib::ext::shared_ptr< CapFloorVolShiftData > > & zeroInflationCapFloorVolShiftData ( )

Definition at line 217 of file sensitivityscenariodata.hpp.

217 {
219 }

◆ equityShiftData() [2/2]

map< string, SpotShiftData > & equityShiftData ( )

Definition at line 220 of file sensitivityscenariodata.hpp.

220{ return equityShiftData_; }

◆ dividendYieldShiftData() [2/2]

map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & dividendYieldShiftData ( )

Definition at line 221 of file sensitivityscenariodata.hpp.

221{ return dividendYieldShiftData_; }

◆ equityVolShiftData() [2/2]

map< string, VolShiftData > & equityVolShiftData ( )

Definition at line 222 of file sensitivityscenariodata.hpp.

222{ return equityVolShiftData_; }

◆ commodityCurrencies() [2/2]

map< string, string > & commodityCurrencies ( )

Definition at line 223 of file sensitivityscenariodata.hpp.

223{ return commodityCurrencies_; }

◆ commodityCurveShiftData() [2/2]

map< string, QuantLib::ext::shared_ptr< CurveShiftData > > & commodityCurveShiftData ( )

Definition at line 224 of file sensitivityscenariodata.hpp.

224{ return commodityCurveShiftData_; }

◆ commodityVolShiftData() [2/2]

map< string, VolShiftData > & commodityVolShiftData ( )

Definition at line 225 of file sensitivityscenariodata.hpp.

225{ return commodityVolShiftData_; }

◆ correlationShiftData() [2/2]

map< string, VolShiftData > & correlationShiftData ( )

Definition at line 226 of file sensitivityscenariodata.hpp.

226{ return correlationShiftData_; }

◆ securityShiftData() [2/2]

map< string, SpotShiftData > & securityShiftData ( )

Definition at line 227 of file sensitivityscenariodata.hpp.

227{ return securityShiftData_; }

◆ crossGammaFilter() [2/2]

vector< pair< string, string > > & crossGammaFilter ( )

Definition at line 229 of file sensitivityscenariodata.hpp.

229{ return crossGammaFilter_; }

◆ computeGamma() [2/2]

bool & computeGamma ( )

Definition at line 230 of file sensitivityscenariodata.hpp.

230{ return computeGamma_; }

◆ useSpreadedTermStructures() [2/2]

bool & useSpreadedTermStructures ( )

Definition at line 231 of file sensitivityscenariodata.hpp.

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 201 of file sensitivityscenariodata.cpp.

201 {
202 XMLNode* node = XMLUtils::locateNode(root, "SensitivityAnalysis");
203 XMLUtils::checkNode(node, "SensitivityAnalysis");
204
205 DLOG("Get discount curve sensitivity parameters");
206 XMLNode* discountCurves = XMLUtils::getChildNode(node, "DiscountCurves");
207 if (discountCurves) {
208 for (XMLNode* child = XMLUtils::getChildNode(discountCurves, "DiscountCurve"); child;
209 child = XMLUtils::getNextSibling(child)) {
210 string ccy = XMLUtils::getAttribute(child, "ccy");
211 DLOG("Discount curve for ccy " << ccy);
213 curveShiftDataFromXML(child, data);
214 discountCurveShiftData_[ccy] = QuantLib::ext::make_shared<CurveShiftData>(data);
215 }
216 }
217
218 DLOG("Get index curve sensitivity parameters");
219 XMLNode* indexCurves = XMLUtils::getChildNode(node, "IndexCurves");
220 if (indexCurves) {
221 for (XMLNode* child = XMLUtils::getChildNode(indexCurves, "IndexCurve"); child;
222 child = XMLUtils::getNextSibling(child)) {
223 string index = XMLUtils::getAttribute(child, "index");
225 curveShiftDataFromXML(child, data);
226 indexCurveShiftData_[index] = QuantLib::ext::make_shared<CurveShiftData>(data);
227 }
228 }
229
230 DLOG("Get yield curve sensitivity parameters");
231 XMLNode* yieldCurves = XMLUtils::getChildNode(node, "YieldCurves");
232 if (yieldCurves) {
233 for (XMLNode* child = XMLUtils::getChildNode(yieldCurves, "YieldCurve"); child;
234 child = XMLUtils::getNextSibling(child)) {
235 string curveName = XMLUtils::getAttribute(child, "name");
237 curveShiftDataFromXML(child, data);
238
239 string curveType = XMLUtils::getChildValue(child, "CurveType", false);
240 yieldCurveShiftData_[curveName] = QuantLib::ext::make_shared<CurveShiftData>(data);
241 }
242 }
243
244 DLOG("Get dividend yield curve sensitivity parameters");
245 XMLNode* dividendYieldCurves = XMLUtils::getChildNode(node, "DividendYieldCurves");
246 if (dividendYieldCurves) {
247 for (XMLNode* child = XMLUtils::getChildNode(dividendYieldCurves, "DividendYieldCurve"); child;
248 child = XMLUtils::getNextSibling(child)) {
249 string curveName = XMLUtils::getAttribute(child, "equity");
250 DLOG("Add dividend yield curve data for equity " << curveName);
252 curveShiftDataFromXML(child, data);
253 dividendYieldShiftData_[curveName] = QuantLib::ext::make_shared<CurveShiftData>(data);
254 }
255 }
256
257 DLOG("Get FX spot sensitivity parameters");
258 XMLNode* fxSpots = XMLUtils::getChildNode(node, "FxSpots");
259 if (fxSpots) {
260 for (XMLNode* child = XMLUtils::getChildNode(fxSpots, "FxSpot"); child;
261 child = XMLUtils::getNextSibling(child)) {
262 string ccypair = XMLUtils::getAttribute(child, "ccypair");
264 shiftDataFromXML(child, data);
265 fxShiftData_[ccypair] = data;
266 }
267 }
268
269 DLOG("Get swaption vol sensitivity parameters");
270 XMLNode* swaptionVols = XMLUtils::getChildNode(node, "SwaptionVolatilities");
271 if (swaptionVols) {
272 for (XMLNode* child = XMLUtils::getChildNode(swaptionVols, "SwaptionVolatility"); child;
273 child = XMLUtils::getNextSibling(child)) {
274 string key = XMLUtils::getAttribute(child, "key");
275 if(key.empty()) {
276 string ccyAttr = XMLUtils::getAttribute(child, "ccy");
277 if(!ccyAttr.empty()) {
278 key = ccyAttr;
279 WLOG("SensitivityData: attribute 'ccy' for SwaptionVolatilities is deprecated, use 'key' instead.");
280 }
281 }
282 GenericYieldVolShiftData data;
283 volShiftDataFromXML(child, data);
284 data.shiftTerms = XMLUtils::getChildrenValuesAsPeriods(child, "ShiftTerms", true);
285 if (data.shiftStrikes.size() == 0)
286 data.shiftStrikes = {0.0};
288 }
289 }
290
291 DLOG("Get yield vol sensitivity parameters");
292 XMLNode* yieldVols = XMLUtils::getChildNode(node, "YieldVolatilities");
293 if (yieldVols) {
294 for (XMLNode* child = XMLUtils::getChildNode(yieldVols, "YieldVolatility"); child;
295 child = XMLUtils::getNextSibling(child)) {
296 string securityId = XMLUtils::getAttribute(child, "name");
297 GenericYieldVolShiftData data;
298 volShiftDataFromXML(child, data, false);
299 data.shiftTerms = XMLUtils::getChildrenValuesAsPeriods(child, "ShiftTerms", true);
300 QL_REQUIRE(data.shiftStrikes.size() == 0 ||
301 (data.shiftStrikes.size() == 1 && close_enough(data.shiftStrikes[0], 0.0)),
302 "no shift strikes (or exactly {0.0}) should be given for yield volatilities");
303 data.shiftStrikes = {0.0};
304 yieldVolShiftData_[securityId] = data;
305 }
306 }
307
308 DLOG("Get cap/floor vol sensitivity parameters");
309 XMLNode* capVols = XMLUtils::getChildNode(node, "CapFloorVolatilities");
310 if (capVols) {
311 for (XMLNode* child = XMLUtils::getChildNode(capVols, "CapFloorVolatility"); child;
312 child = XMLUtils::getNextSibling(child)) {
313 string key = XMLUtils::getAttribute(child, "key");
314 if(key.empty()) {
315 string ccyAttr = XMLUtils::getAttribute(child, "ccy");
316 if(!ccyAttr.empty()) {
317 key = ccyAttr;
318 WLOG("SensitivityData: attribute 'ccy' for CapFloorVolatilities is deprecated, use 'key' instead.");
319 }
320 }
321 auto data = QuantLib::ext::make_shared<CapFloorVolShiftData>();
322 volShiftDataFromXML(child, *data);
323 data->indexName = XMLUtils::getChildValue(child, "Index", true);
325 }
326 }
327
328 DLOG("Get fx vol sensitivity parameters");
329 XMLNode* fxVols = XMLUtils::getChildNode(node, "FxVolatilities");
330 if (fxVols) {
331 for (XMLNode* child = XMLUtils::getChildNode(fxVols, "FxVolatility"); child;
332 child = XMLUtils::getNextSibling(child)) {
333 string ccypair = XMLUtils::getAttribute(child, "ccypair");
334 VolShiftData data;
335 volShiftDataFromXML(child, data);
336 fxVolShiftData_[ccypair] = data;
337 }
338 }
339
340 DLOG("Get credit curve sensitivity parameters");
341 XMLNode* creditCurves = XMLUtils::getChildNode(node, "CreditCurves");
342 if (creditCurves) {
343 for (XMLNode* child = XMLUtils::getChildNode(creditCurves, "CreditCurve"); child;
344 child = XMLUtils::getNextSibling(child)) {
345 string name = XMLUtils::getAttribute(child, "name");
346 string ccy = XMLUtils::getChildValue(child, "Currency", true);
347 creditCcys_[name] = ccy;
349 curveShiftDataFromXML(child, data);
350 creditCurveShiftData_[name] = QuantLib::ext::make_shared<CurveShiftData>(data);
351 }
352 }
353
354 DLOG("Get cds vol sensitivity parameters");
355 XMLNode* cdsVols = XMLUtils::getChildNode(node, "CDSVolatilities");
356 if (cdsVols) {
357 for (XMLNode* child = XMLUtils::getChildNode(cdsVols, "CDSVolatility"); child;
358 child = XMLUtils::getNextSibling(child)) {
359 string name = XMLUtils::getAttribute(child, "name");
360 CdsVolShiftData data;
361 shiftDataFromXML(child, data);
362 data.shiftExpiries = XMLUtils::getChildrenValuesAsPeriods(child, "ShiftExpiries", true);
364 }
365 }
366
367 DLOG("Get Base Correlation sensitivity parameters");
368 XMLNode* bcNode = XMLUtils::getChildNode(node, "BaseCorrelations");
369 if (bcNode) {
370 for (XMLNode* child = XMLUtils::getChildNode(bcNode, "BaseCorrelation"); child;
371 child = XMLUtils::getNextSibling(child)) {
372 string name = XMLUtils::getAttribute(child, "indexName");
373 BaseCorrelationShiftData data;
374 shiftDataFromXML(child, data);
375 data.shiftTerms = XMLUtils::getChildrenValuesAsPeriods(child, "ShiftTerms", true);
376 data.shiftLossLevels = XMLUtils::getChildrenValuesAsDoublesCompact(child, "ShiftLossLevels", true);
378 }
379 }
380
381 DLOG("Get Equity spot sensitivity parameters");
382 XMLNode* equitySpots = XMLUtils::getChildNode(node, "EquitySpots");
383 if (equitySpots) {
384 for (XMLNode* child = XMLUtils::getChildNode(equitySpots, "EquitySpot"); child;
385 child = XMLUtils::getNextSibling(child)) {
386 string equity = XMLUtils::getAttribute(child, "equity");
388 shiftDataFromXML(child, data);
389 equityShiftData_[equity] = data;
390 }
391 }
392
393 DLOG("Get Equity vol sensitivity parameters");
394 XMLNode* equityVols = XMLUtils::getChildNode(node, "EquityVolatilities");
395 if (equityVols) {
396 for (XMLNode* child = XMLUtils::getChildNode(equityVols, "EquityVolatility"); child;
397 child = XMLUtils::getNextSibling(child)) {
398 string equity = XMLUtils::getAttribute(child, "equity");
399 VolShiftData data;
400 volShiftDataFromXML(child, data);
401 equityVolShiftData_[equity] = data;
402 }
403 }
404
405 DLOG("Get Zero Inflation sensitivity parameters");
406 XMLNode* zeroInflation = XMLUtils::getChildNode(node, "ZeroInflationIndexCurves");
407 if (zeroInflation) {
408 for (XMLNode* child = XMLUtils::getChildNode(zeroInflation, "ZeroInflationIndexCurve"); child;
409 child = XMLUtils::getNextSibling(child)) {
410 string index = XMLUtils::getAttribute(child, "index");
412 curveShiftDataFromXML(child, data);
413 zeroInflationCurveShiftData_[index] = QuantLib::ext::make_shared<CurveShiftData>(data);
414 }
415 }
416
417 DLOG("Get Yoy Inflation sensitivity parameters");
418 XMLNode* yoyInflation = XMLUtils::getChildNode(node, "YYInflationIndexCurves");
419 if (yoyInflation) {
420 for (XMLNode* child = XMLUtils::getChildNode(yoyInflation, "YYInflationIndexCurve"); child;
421 child = XMLUtils::getNextSibling(child)) {
422 string index = XMLUtils::getAttribute(child, "index");
424 curveShiftDataFromXML(child, data);
425 yoyInflationCurveShiftData_[index] = QuantLib::ext::make_shared<CurveShiftData>(data);
426 }
427 }
428
429 DLOG("Get yoy inflation cap/floor vol sensitivity parameters");
430 XMLNode* yoyCapVols = XMLUtils::getChildNode(node, "YYCapFloorVolatilities");
431 if (yoyCapVols) {
432 for (XMLNode* child = XMLUtils::getChildNode(yoyCapVols, "YYCapFloorVolatility"); child;
433 child = XMLUtils::getNextSibling(child)) {
434 string index = XMLUtils::getAttribute(child, "index");
435 auto data = QuantLib::ext::make_shared<CapFloorVolShiftData>();
436 volShiftDataFromXML(child, *data);
438 }
439 }
440
441 DLOG("Get zero inflation cap/floor vol sensitivity parameters");
442 XMLNode* zeroCapVols = XMLUtils::getChildNode(node, "CPICapFloorVolatilities");
443 if (zeroCapVols) {
444 for (XMLNode* child = XMLUtils::getChildNode(zeroCapVols, "CPICapFloorVolatility"); child;
445 child = XMLUtils::getNextSibling(child)) {
446 string index = XMLUtils::getAttribute(child, "index");
447 auto data = QuantLib::ext::make_shared<CapFloorVolShiftData>();
448 volShiftDataFromXML(child, *data);
450 }
451 }
452
453 DLOG("Get commodity curve sensitivity parameters");
454 XMLNode* ccNode = XMLUtils::getChildNode(node, "CommodityCurves");
455 if (ccNode) {
456 for (XMLNode* child = XMLUtils::getChildNode(ccNode, "CommodityCurve"); child;
457 child = XMLUtils::getNextSibling(child)) {
458 string name = XMLUtils::getAttribute(child, "name");
459 commodityCurrencies_[name] = XMLUtils::getChildValue(child, "Currency", true);
461 curveShiftDataFromXML(child, data);
462 commodityCurveShiftData_[name] = QuantLib::ext::make_shared<CurveShiftData>(data);
463 }
464 }
465
466 DLOG("Get commodity volatility sensitivity parameters");
467 XMLNode* cvNode = XMLUtils::getChildNode(node, "CommodityVolatilities");
468 if (cvNode) {
469 for (XMLNode* child = XMLUtils::getChildNode(cvNode, "CommodityVolatility"); child;
470 child = XMLUtils::getNextSibling(child)) {
471 string name = XMLUtils::getAttribute(child, "name");
472 VolShiftData data;
473 volShiftDataFromXML(child, data);
474 // If data has one strike and it is 0.0, it needs to be overwritten for commodity volatilities
475 // Commodity volatility surface in simulation market is defined in terms of spot moneyness e.g.
476 // strike sets like {0.99 * S(0), 1.00 * S(0), 1.01 * S(0)} => we need to define sensitivity
477 // data in the same way
478 if (data.shiftStrikes.size() == 1 && close_enough(data.shiftStrikes[0], 0.0)) {
479 data.shiftStrikes[0] = 1.0;
480 }
482 }
483 }
484
485 DLOG("Get security spread sensitivity parameters");
486 XMLNode* securitySpreads = XMLUtils::getChildNode(node, "SecuritySpreads");
487 if (securitySpreads) {
488 for (XMLNode* child = XMLUtils::getChildNode(securitySpreads, "SecuritySpread"); child;
489 child = XMLUtils::getNextSibling(child)) {
490 string bond = XMLUtils::getAttribute(child, "security");
492 shiftDataFromXML(child, data);
493 securityShiftData_[bond] = data;
494 }
495 }
496
497 DLOG("Get correlation sensitivity parameters");
498 XMLNode* correlations = XMLUtils::getChildNode(node, "Correlations");
499 if (correlations) {
500 for (XMLNode* child = XMLUtils::getChildNode(correlations, "Correlation"); child;
501 child = XMLUtils::getNextSibling(child)) {
502 string index1 = XMLUtils::getAttribute(child, "index1");
503 string index2 = XMLUtils::getAttribute(child, "index2");
504 string label = index1 + ":" + index2;
505 VolShiftData data;
506 volShiftDataFromXML(child, data);
508 }
509 }
510
511 XMLNode* CGF = XMLUtils::getChildNode(node, "CrossGammaFilter");
512 if (CGF) {
513 DLOG("Get cross gamma parameters");
514 vector<string> filter = XMLUtils::getChildrenValues(node, "CrossGammaFilter", "Pair", true);
515 for (Size i = 0; i < filter.size(); ++i) {
516 vector<string> tokens;
517 boost::split(tokens, filter[i], boost::is_any_of(","));
518 QL_REQUIRE(tokens.size() == 2, "expected 2 tokens, found " << tokens.size() << " in " << filter[i]);
519 crossGammaFilter_.push_back(pair<string, string>(tokens[0], tokens[1]));
520 }
521 }
522
523 DLOG("Get compute gamma flag");
524 computeGamma_ = XMLUtils::getChildValueAsBool(node, "ComputeGamma", false); // defaults to true
525
526 DLOG("Get useSpreadedTermStructures flag");
527 if (auto n = XMLUtils::getChildNode(node, "UseSpreadedTermStructures"))
529 else
531
532 if (!parConversion_)
533 return;
534
535 node = XMLUtils::locateNode(root, "SensitivityAnalysis");
536 XMLUtils::checkNode(node, "SensitivityAnalysis");
537
538 DLOG("Get discount curve parSensitivity parameters");
539 discountCurves = XMLUtils::getChildNode(node, "DiscountCurves");
540 if (discountCurves) {
541 for (XMLNode* child = XMLUtils::getChildNode(discountCurves, "DiscountCurve"); child;
542 child = XMLUtils::getNextSibling(child)) {
543 string ccy = XMLUtils::getAttribute(child, "ccy");
544 CurveShiftParData data(*discountCurveShiftData_.find(ccy)->second);
545 parDataFromXML(child, data);
546 discountCurveShiftData_[ccy] = QuantLib::ext::make_shared<CurveShiftParData>(data);
547 }
548 }
549
550 DLOG("Get index curve parSensitivity parameters");
551 indexCurves = XMLUtils::getChildNode(node, "IndexCurves");
552 if (indexCurves) {
553 for (XMLNode* child = XMLUtils::getChildNode(indexCurves, "IndexCurve"); child;
554 child = XMLUtils::getNextSibling(child)) {
555 string index = XMLUtils::getAttribute(child, "index");
556 CurveShiftParData data(*indexCurveShiftData_.find(index)->second);
557 parDataFromXML(child, data);
558 indexCurveShiftData_[index] = QuantLib::ext::make_shared<CurveShiftParData>(data);
559 }
560 }
561
562 DLOG("Get yield curve parSensitivity parameters");
563 yieldCurves = XMLUtils::getChildNode(node, "YieldCurves");
564 if (yieldCurves) {
565 for (XMLNode* child = XMLUtils::getChildNode(yieldCurves, "YieldCurve"); child;
566 child = XMLUtils::getNextSibling(child)) {
567 string curveName = XMLUtils::getAttribute(child, "name");
568 string curveType = XMLUtils::getChildValue(child, "CurveType", false);
569 CurveShiftParData data(*yieldCurveShiftData_.find(curveName)->second);
570 parDataFromXML(child, data);
571 yieldCurveShiftData_[curveName] = QuantLib::ext::make_shared<CurveShiftParData>(data);
572 }
573 }
574
575 DLOG("Get cap/floor vol par sensitivity parameters");
576 capVols = XMLUtils::getChildNode(node, "CapFloorVolatilities");
577 if (capVols) {
578 for (XMLNode* child = XMLUtils::getChildNode(capVols, "CapFloorVolatility"); child;
579 child = XMLUtils::getNextSibling(child)) {
580 string key = XMLUtils::getAttribute(child, "key");
581 if(key.empty()) {
582 string ccyAttr = XMLUtils::getAttribute(child, "ccy");
583 if(!ccyAttr.empty()) {
584 key = ccyAttr;
585 WLOG("SensitivityData: attribute 'ccy' for CapFloorVolatilities is deprecated, use 'key' instead.");
586 }
587 }
588 CapFloorVolShiftParData data(*capFloorVolShiftData_.find(key)->second);
589 XMLNode* par = XMLUtils::getChildNode(child, "ParConversion");
590 if (par) {
591 data.discountCurve = XMLUtils::getChildValue(par, "DiscountCurve", false);
592 }
593 capFloorVolShiftData_[key] = QuantLib::ext::make_shared<CapFloorVolShiftParData>(data);
594 }
595 }
596
597 DLOG("Get credit curve parSensitivity parameters");
598 creditCurves = XMLUtils::getChildNode(node, "CreditCurves");
599 if (creditCurves) {
600 for (XMLNode* child = XMLUtils::getChildNode(creditCurves, "CreditCurve"); child;
601 child = XMLUtils::getNextSibling(child)) {
602 string name = XMLUtils::getAttribute(child, "name");
603 CurveShiftParData data(*creditCurveShiftData_.find(name)->second);
604 parDataFromXML(child, data);
605 creditCurveShiftData_[name] = QuantLib::ext::make_shared<CurveShiftParData>(data);
606 }
607 }
608
609 DLOG("Get Zero Inflation parSensitivity parameters");
610 zeroInflation = XMLUtils::getChildNode(node, "ZeroInflationIndexCurves");
611 if (zeroInflation) {
612 for (XMLNode* child = XMLUtils::getChildNode(zeroInflation, "ZeroInflationIndexCurve"); child;
613 child = XMLUtils::getNextSibling(child)) {
614 string index = XMLUtils::getAttribute(child, "index");
615 CurveShiftParData data(*zeroInflationCurveShiftData_.find(index)->second);
616 parDataFromXML(child, data);
617 zeroInflationCurveShiftData_[index] = QuantLib::ext::make_shared<CurveShiftParData>(data);
618 }
619 }
620
621 DLOG("Get Yoy Inflation parSensitivity parameters");
622 yoyInflation = XMLUtils::getChildNode(node, "YYInflationIndexCurves");
623 if (yoyInflation) {
624 for (XMLNode* child = XMLUtils::getChildNode(yoyInflation, "YYInflationIndexCurve"); child;
625 child = XMLUtils::getNextSibling(child)) {
626 string index = XMLUtils::getAttribute(child, "index");
627 CurveShiftParData data(*yoyInflationCurveShiftData_.find(index)->second);
628 parDataFromXML(child, data);
629 yoyInflationCurveShiftData_[index] = QuantLib::ext::make_shared<CurveShiftParData>(data);
630 }
631 }
632
633 DLOG("Get Yoy cap/floor vol par sensitivity parameters");
634 yoyCapVols = XMLUtils::getChildNode(node, "YYCapFloorVolatilities");
635 if (yoyCapVols) {
636 for (XMLNode* child = XMLUtils::getChildNode(yoyCapVols, "YYCapFloorVolatility"); child;
637 child = XMLUtils::getNextSibling(child)) {
638 string index = XMLUtils::getAttribute(child, "index");
639 CapFloorVolShiftParData data(*yoyInflationCapFloorVolShiftData_.find(index)->second);
640 XMLNode* par = XMLUtils::getChildNode(child, "ParConversion");
641 //QL_REQUIRE(par, "parData must be provided for YYCapFloorVolatilities");
642 if (par) {
643 data.parInstruments = XMLUtils::getChildrenValuesAsStrings(par, "Instruments", true);
644 data.parInstrumentSingleCurve = XMLUtils::getChildValueAsBool(par, "SingleCurve", true);
645 data.discountCurve = XMLUtils::getChildValue(par, "DiscountCurve", false);
646 XMLNode* conventionsNode = XMLUtils::getChildNode(par, "Conventions");
647 data.parInstrumentConventions =
648 XMLUtils::getChildrenAttributesAndValues(conventionsNode, "Convention", "id", true);
649 }
650 yoyInflationCapFloorVolShiftData_[index] = QuantLib::ext::make_shared<CapFloorVolShiftParData>(data);
651 }
652 }
653}
void shiftDataFromXML(XMLNode *child, ShiftData &data)
void parDataFromXML(XMLNode *child, CurveShiftParData &data)
void curveShiftDataFromXML(XMLNode *child, CurveShiftData &data)
void volShiftDataFromXML(XMLNode *child, VolShiftData &data, const bool requireShiftStrikes=true)
static string getAttribute(XMLNode *node, const string &attrName)
static void checkNode(XMLNode *n, const string &expectedName)
static XMLNode * locateNode(XMLNode *n, const string &name="")
static map< string, string > getChildrenAttributesAndValues(XMLNode *parent, const string &names, const string &attributeName, bool mandatory=false)
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< string > getChildrenValuesAsStrings(XMLNode *node, const string &name, bool mandatory=false)
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 vector< Period > getChildrenValuesAsPeriods(XMLNode *node, const string &name, bool mandatory=false)
SafeStack< Filter > filter
bool parseBool(const string &s)
data
#define DLOG(text)
#define WLOG(text)
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
SensitivityScenarioData::CurveShiftData CurveShiftData
SensitivityScenarioData::SpotShiftData SpotShiftData
string name
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( ore::data::XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 655 of file sensitivityscenariodata.cpp.

655 {
656
657 XMLNode* root = doc.allocNode("SensitivityAnalysis");
658
659 if (!discountCurveShiftData_.empty()) {
660 DLOG("toXML for DiscountCurves");
661 XMLNode* parent = XMLUtils::addChild(doc, root, "DiscountCurves");
662 for (const auto& kv : discountCurveShiftData_) {
663 XMLNode* node = XMLUtils::addChild(doc, parent, "DiscountCurve");
664 XMLUtils::addAttribute(doc, node, "ccy", kv.first);
665 curveShiftDataToXML(doc, node, *kv.second);
666 }
667 }
668
669 if (!indexCurveShiftData_.empty()) {
670 DLOG("toXML for IndexCurves");
671 XMLNode* parent = XMLUtils::addChild(doc, root, "IndexCurves");
672 for (const auto& kv : indexCurveShiftData_) {
673 XMLNode* node = XMLUtils::addChild(doc, parent, "IndexCurve");
674 XMLUtils::addAttribute(doc, node, "index", kv.first);
675 curveShiftDataToXML(doc, node, *kv.second);
676 }
677 }
678
679 if (!yieldCurveShiftData_.empty()) {
680 XMLNode* yieldCurvesNode = XMLUtils::addChild(doc, root, "YieldCurves");
681 DLOG("toXML for YieldCurves");
682 for (const auto& kv : yieldCurveShiftData_) {
683 XMLNode* node = XMLUtils::addChild(doc, yieldCurvesNode, "YieldCurve");
684 XMLUtils::addAttribute(doc, node, "name", kv.first);
685 curveShiftDataToXML(doc, node, *kv.second);
686 }
687 }
688
689 if (!dividendYieldShiftData_.empty()) {
690 DLOG("toXML for DividendYieldCurves");
691 XMLNode* parent = XMLUtils::addChild(doc, root, "DividendYieldCurves");
692 for (const auto& kv : dividendYieldShiftData_) {
693 XMLNode* node = XMLUtils::addChild(doc, parent, "DividendYieldCurve");
694 XMLUtils::addAttribute(doc, node, "equity", kv.first);
695 curveShiftDataToXML(doc, node, *kv.second);
696 }
697 }
698
699 if (!fxShiftData_.empty()) {
700 DLOG("toXML for FxSpots");
701 XMLNode* parent = XMLUtils::addChild(doc, root, "FxSpots");
702 for (const auto& kv : fxShiftData_) {
703 XMLNode* node = XMLUtils::addChild(doc, parent, "FxSpot");
704 XMLUtils::addAttribute(doc, node, "ccypair", kv.first);
705 shiftDataToXML(doc, node, kv.second);
706 }
707 }
708
709 if (!swaptionVolShiftData_.empty()) {
710 DLOG("toXML for SwaptionVolatilities");
711 XMLNode* parent = XMLUtils::addChild(doc, root, "SwaptionVolatilities");
712 for (const auto& kv : swaptionVolShiftData_) {
713 XMLNode* node = XMLUtils::addChild(doc, parent, "SwaptionVolatility");
714 XMLUtils::addAttribute(doc, node, "ccy", kv.first);
715 volShiftDataToXML(doc, node, kv.second);
716 XMLUtils::addGenericChildAsList(doc, node, "ShiftTerms", kv.second.shiftTerms);
717 }
718 }
719
720 if (!yieldVolShiftData_.empty()) {
721 DLOG("toXML for YieldVolatilities");
722 XMLNode* parent = XMLUtils::addChild(doc, root, "YieldVolatilities");
723 for (const auto& kv : yieldVolShiftData_) {
724 XMLNode* node = XMLUtils::addChild(doc, parent, "YieldVolatility");
725 XMLUtils::addAttribute(doc, node, "name", kv.first);
726 volShiftDataToXML(doc, node, kv.second);
727 XMLUtils::addGenericChildAsList(doc, node, "ShiftTerms", kv.second.shiftTerms);
728 }
729 }
730
731 if (!capFloorVolShiftData_.empty()) {
732 DLOG("toXML for CapFloorVolatilities");
733 XMLNode* parent = XMLUtils::addChild(doc, root, "CapFloorVolatilities");
734 for (const auto& kv : capFloorVolShiftData_) {
735 XMLNode* node = XMLUtils::addChild(doc, parent, "CapFloorVolatility");
736 XMLUtils::addAttribute(doc, node, "key", kv.first);
737 volShiftDataToXML(doc, node, *kv.second);
738 XMLUtils::addChild(doc, node, "Index", kv.second->indexName);
739 XMLUtils::addChild(doc, node, "IsRelative", kv.second->isRelative);
740 }
741 }
742
743 if (!fxVolShiftData_.empty()) {
744 DLOG("toXML for FxVolatilities");
745 XMLNode* parent = XMLUtils::addChild(doc, root, "FxVolatilities");
746 for (const auto& kv : fxVolShiftData_) {
747 XMLNode* node = XMLUtils::addChild(doc, parent, "FxVolatility");
748 XMLUtils::addAttribute(doc, node, "ccypair", kv.first);
749 volShiftDataToXML(doc, node, kv.second);
750 }
751 }
752
753 if (!creditCurveShiftData_.empty()) {
754 DLOG("toXML for CreditCurves");
755 XMLNode* parent = XMLUtils::addChild(doc, root, "CreditCurves");
756 for (const auto& kv : creditCurveShiftData_) {
757 XMLNode* node = XMLUtils::addChild(doc, parent, "CreditCurve");
758 XMLUtils::addAttribute(doc, node, "name", kv.first);
759 XMLUtils::addChild(doc, node, "Currency", creditCcys_.find(kv.first)->second);
760 curveShiftDataToXML(doc, node, *kv.second);
761 }
762 }
763
764 if (!cdsVolShiftData_.empty()) {
765 DLOG("toXML for CDSVolatilities");
766 XMLNode* parent = XMLUtils::addChild(doc, root, "CDSVolatilities");
767 for (const auto& kv : cdsVolShiftData_) {
768 XMLNode* node = XMLUtils::addChild(doc, parent, "CDSVolatility");
769 XMLUtils::addAttribute(doc, node, "name", kv.first);
770 shiftDataToXML(doc, node, kv.second);
771 XMLUtils::addGenericChildAsList(doc, node, "ShiftExpiries", kv.second.shiftExpiries);
772 }
773 }
774
775 if (!baseCorrelationShiftData_.empty()) {
776 DLOG("toXML for BaseCorrelations");
777 XMLNode* parent = XMLUtils::addChild(doc, root, "BaseCorrelations");
778 for (const auto& kv : baseCorrelationShiftData_) {
779 XMLNode* node = XMLUtils::addChild(doc, parent, "BaseCorrelation");
780 XMLUtils::addAttribute(doc, node, "indexName", kv.first);
781 shiftDataToXML(doc, node, kv.second);
782 XMLUtils::addGenericChildAsList(doc, node, "ShiftTerms", kv.second.shiftTerms);
783 XMLUtils::addChild(doc, node, "ShiftLossLevels", kv.second.shiftLossLevels);
784 }
785 }
786
787 if (!equityShiftData_.empty()) {
788 DLOG("toXML for EquitySpots");
789 XMLNode* parent = XMLUtils::addChild(doc, root, "EquitySpots");
790 for (const auto& kv : equityShiftData_) {
791 XMLNode* node = XMLUtils::addChild(doc, parent, "EquitySpot");
792 XMLUtils::addAttribute(doc, node, "equity", kv.first);
793 shiftDataToXML(doc, node, kv.second);
794 }
795 }
796
797 if (!equityVolShiftData_.empty()) {
798 DLOG("toXML for EquityVolatilities");
799 XMLNode* parent = XMLUtils::addChild(doc, root, "EquityVolatilities");
800 for (const auto& kv : equityVolShiftData_) {
801 XMLNode* node = XMLUtils::addChild(doc, parent, "EquityVolatility");
802 XMLUtils::addAttribute(doc, node, "equity", kv.first);
803 volShiftDataToXML(doc, node, kv.second);
804 }
805 }
806
807 if (!zeroInflationCurveShiftData_.empty()) {
808 DLOG("toXML for ZeroInflationIndexCurves");
809 XMLNode* parent = XMLUtils::addChild(doc, root, "ZeroInflationIndexCurves");
810 for (const auto& kv : zeroInflationCurveShiftData_) {
811 XMLNode* node = XMLUtils::addChild(doc, parent, "ZeroInflationIndexCurve");
812 XMLUtils::addAttribute(doc, node, "index", kv.first);
813 curveShiftDataToXML(doc, node, *kv.second);
814 }
815 }
816
817 if (!yoyInflationCurveShiftData_.empty()) {
818 DLOG("toXML for YYInflationIndexCurves");
819 XMLNode* parent = XMLUtils::addChild(doc, root, "YYInflationIndexCurves");
820 for (const auto& kv : yoyInflationCurveShiftData_) {
821 XMLNode* node = XMLUtils::addChild(doc, parent, "YYInflationIndexCurve");
822 XMLUtils::addAttribute(doc, node, "index", kv.first);
823 curveShiftDataToXML(doc, node, *kv.second);
824 }
825 }
826
828 DLOG("toXML for YYInflationCapFloorVolatilities");
829 XMLNode* parent = XMLUtils::addChild(doc, root, "YYCapFloorVolatilities");
830 for (const auto& kv : yoyInflationCapFloorVolShiftData_) {
831 XMLNode* node = XMLUtils::addChild(doc, parent, "YYCapFloorVolatility");
832 XMLUtils::addAttribute(doc, node, "index", kv.first);
833 volShiftDataToXML(doc, node, *kv.second);
834 }
835 }
836
838 DLOG("toXML for CPIInflationCapFloorVolatilities");
839 XMLNode* parent = XMLUtils::addChild(doc, root, "CPICapFloorVolatilities");
840 for (const auto& kv : zeroInflationCapFloorVolShiftData_) {
841 XMLNode* node = XMLUtils::addChild(doc, parent, "CPICapFloorVolatility");
842 XMLUtils::addAttribute(doc, node, "index", kv.first);
843 volShiftDataToXML(doc, node, *kv.second);
844 }
845 }
846
847 if (!commodityCurveShiftData_.empty()) {
848 DLOG("toXML for CommodityCurves");
849 XMLNode* parent = XMLUtils::addChild(doc, root, "CommodityCurves");
850 for (const auto& kv : commodityCurveShiftData_) {
851 XMLNode* node = XMLUtils::addChild(doc, parent, "CommodityCurve");
852 XMLUtils::addAttribute(doc, node, "name", kv.first);
853 XMLUtils::addChild(doc, node, "Currency", commodityCurrencies_.find(kv.first)->second);
854 curveShiftDataToXML(doc, node, *kv.second);
855 }
856 }
857
858 if (!commodityVolShiftData_.empty()) {
859 DLOG("toXML for CommodityVolatilities");
860 XMLNode* parent = XMLUtils::addChild(doc, root, "CommodityVolatilities");
861 for (const auto& kv : commodityVolShiftData_) {
862 XMLNode* node = XMLUtils::addChild(doc, parent, "CommodityVolatility");
863 XMLUtils::addAttribute(doc, node, "name", kv.first);
864 volShiftDataToXML(doc, node, kv.second);
865 }
866 }
867
868 if (!securityShiftData_.empty()) {
869 DLOG("toXML for SecuritySpreads");
870 XMLNode* parent = XMLUtils::addChild(doc, root, "SecuritySpreads");
871 for (const auto& kv : securityShiftData_) {
872 XMLNode* node = XMLUtils::addChild(doc, parent, "SecuritySpread");
873 XMLUtils::addAttribute(doc, node, "security", kv.first);
874 shiftDataToXML(doc, node, kv.second);
875 }
876 }
877
878 if (!correlationShiftData_.empty()) {
879 DLOG("toXML for Correlations");
880 XMLNode* parent = XMLUtils::addChild(doc, root, "Correlations");
881 for (const auto& kv : correlationShiftData_) {
882 XMLNode* node = XMLUtils::addChild(doc, parent, "Correlation");
883 string label = kv.first;
884 vector<string> tokens = ore::data::getCorrelationTokens(label);
885 XMLUtils::addAttribute(doc, node, "index1", tokens[0]);
886 XMLUtils::addAttribute(doc, node, "index2", tokens[1]);
887 shiftDataToXML(doc, node, kv.second);
888 }
889 }
890
891 if (!crossGammaFilter_.empty()) {
892 DLOG("toXML for CrossGammaFilter");
893 XMLNode* parent = XMLUtils::addChild(doc, root, "CrossGammaFilter");
894 for (const auto& crossGamma : crossGammaFilter_) {
895 XMLUtils::addChild(doc, parent, "Pair", crossGamma.first + "," + crossGamma.second);
896 }
897 }
898
899 XMLUtils::addChild(doc, root, "ComputeGamma", computeGamma_);
900 XMLUtils::addChild(doc, root, "UseSpreadedTermStructures", useSpreadedTermStructures_);
901
902 // If not par, no more to do
903 if (!parConversion_)
904 return root;
905
906 // If par, add par nodes where necessary
907 XMLNode* discountCurves = XMLUtils::getChildNode(root, "DiscountCurves");
908 if (discountCurves) {
909 DLOG("toXML for DiscountCurves ParConversion node");
910 for (XMLNode* child = XMLUtils::getChildNode(discountCurves, "DiscountCurve"); child;
911 child = XMLUtils::getNextSibling(child)) {
912 string ccy = XMLUtils::getAttribute(child, "ccy");
913 XMLNode* parNode = parDataToXML(doc, discountCurveShiftData_.find(ccy)->second);
914 XMLUtils::appendNode(child, parNode);
915 }
916 }
917
918 XMLNode* indexCurves = XMLUtils::getChildNode(root, "IndexCurves");
919 if (indexCurves) {
920 DLOG("toXML for IndexCurves ParConversion node");
921 for (XMLNode* child = XMLUtils::getChildNode(indexCurves, "IndexCurve"); child;
922 child = XMLUtils::getNextSibling(child)) {
923 string index = XMLUtils::getAttribute(child, "index");
924 XMLNode* parNode = parDataToXML(doc, indexCurveShiftData_.find(index)->second);
925 XMLUtils::appendNode(child, parNode);
926 }
927 }
928
929 XMLNode* yieldCurves = XMLUtils::getChildNode(root, "YieldCurves");
930 if (yieldCurves) {
931 DLOG("toXML for YieldCurves ParConversion node");
932 for (XMLNode* child = XMLUtils::getChildNode(yieldCurves, "YieldCurve"); child;
933 child = XMLUtils::getNextSibling(child)) {
934 string curveName = XMLUtils::getAttribute(child, "name");
935 string curveType = XMLUtils::getChildValue(child, "CurveType", false);
936 auto data = yieldCurveShiftData_.at(curveName);
937 if (data) {
938 XMLNode* parNode = parDataToXML(doc, data);
939 XMLUtils::appendNode(child, parNode);
940 }
941 }
942 }
943
944 XMLNode* creditCurves = XMLUtils::getChildNode(root, "CreditCurves");
945 if (creditCurves) {
946 DLOG("toXML for CreditCurves ParConversion node");
947 for (XMLNode* child = XMLUtils::getChildNode(creditCurves, "CreditCurve"); child;
948 child = XMLUtils::getNextSibling(child)) {
949 string name = XMLUtils::getAttribute(child, "name");
950 XMLNode* parNode = parDataToXML(doc, creditCurveShiftData_.find(name)->second);
951 XMLUtils::appendNode(child, parNode);
952 }
953 }
954
955 XMLNode* zeroInflation = XMLUtils::getChildNode(root, "ZeroInflationIndexCurves");
956 if (zeroInflation) {
957 DLOG("toXML for ZeroInflationIndexCurves ParConversion node");
958 for (XMLNode* child = XMLUtils::getChildNode(zeroInflation, "ZeroInflationIndexCurve"); child;
959 child = XMLUtils::getNextSibling(child)) {
960 string index = XMLUtils::getAttribute(child, "index");
961 XMLNode* parNode = parDataToXML(doc, zeroInflationCurveShiftData_.find(index)->second);
962 XMLUtils::appendNode(child, parNode);
963 }
964 }
965
966 XMLNode* yoyInflation = XMLUtils::getChildNode(root, "YYInflationIndexCurves");
967 if (yoyInflation) {
968 DLOG("toXML for YYInflationIndexCurves ParConversion node");
969 for (XMLNode* child = XMLUtils::getChildNode(yoyInflation, "YYInflationIndexCurve"); child;
970 child = XMLUtils::getNextSibling(child)) {
971 string index = XMLUtils::getAttribute(child, "index");
972 XMLNode* parNode = parDataToXML(doc, yoyInflationCurveShiftData_.find(index)->second);
973 XMLUtils::appendNode(child, parNode);
974 }
975 }
976
977 XMLNode* capFloor = XMLUtils::getChildNode(root, "CapFloorVolatilities");
978 if (capFloor) {
979 DLOG("toXML for CapFloorVolatilities ParConversion node");
980 for (XMLNode* child = XMLUtils::getChildNode(capFloor, "CapFloorVolatility"); child;
981 child = XMLUtils::getNextSibling(child)) {
982 string key = XMLUtils::getAttribute(child, "key");
983 auto data = QuantLib::ext::dynamic_pointer_cast<CapFloorVolShiftParData>(capFloorVolShiftData_.find(key)->second);
984 if (data) {
985 XMLNode* parNode = doc.allocNode("ParConversion");
986 if (!data->discountCurve.empty())
987 XMLUtils::addChild(doc, parNode, "DiscountCurve", data->discountCurve);
988 XMLUtils::appendNode(child, parNode);
989 }
990 }
991 }
992
993 XMLNode* yoyCapFloor = XMLUtils::getChildNode(root, "YYCapFloorVolatilities");
994 if (yoyCapFloor) {
995 DLOG("toXML for YYCapFloorVolatilities ParConversion node");
996 for (XMLNode* child = XMLUtils::getChildNode(yoyCapFloor, "YYCapFloorVolatility"); child;
997 child = XMLUtils::getNextSibling(child)) {
998 string index = XMLUtils::getAttribute(child, "index");
999 auto data = QuantLib::ext::dynamic_pointer_cast<CapFloorVolShiftParData>(yoyInflationCapFloorVolShiftData_.find(index)->second);
1000 if (data) {
1001 XMLNode* parNode = doc.allocNode("ParConversion");
1002 XMLUtils::addGenericChildAsList(doc, parNode, "Instruments", data->parInstruments);
1003 XMLUtils::addChild(doc, parNode, "SingleCurve", data->parInstrumentSingleCurve);
1004 if (!data->discountCurve.empty())
1005 XMLUtils::addChild(doc, parNode, "DiscountCurve", data->discountCurve);
1006 XMLUtils::appendNode(child, parNode);
1007 XMLNode* conventionsNode = XMLUtils::addChild(doc, parNode, "Conventions");
1008 for (const auto& kv : data->parInstrumentConventions) {
1009 XMLNode* conventionNode = doc.allocNode("Convention", kv.second);
1010 XMLUtils::addAttribute(doc, conventionNode, "id", kv.first);
1011 XMLUtils::appendNode(conventionsNode, conventionNode);
1012 }
1013 }
1014 }
1015 }
1016
1017 return root;
1018}
XMLNode * parDataToXML(ore::data::XMLDocument &doc, const QuantLib::ext::shared_ptr< CurveShiftData > &csd) const
toXML helper method
void volShiftDataToXML(ore::data::XMLDocument &doc, XMLNode *node, const VolShiftData &data) const
void curveShiftDataToXML(ore::data::XMLDocument &doc, XMLNode *node, const CurveShiftData &data) const
void shiftDataToXML(ore::data::XMLDocument &doc, XMLNode *node, const ShiftData &data) const
toXML helper methods
XMLNode * allocNode(const string &nodeName)
static void addAttribute(XMLDocument &doc, XMLNode *node, const string &attrName, const string &attrValue)
static void addGenericChildAsList(XMLDocument &doc, XMLNode *n, const string &name, const vector< T > &values, const string &attrName="", const string &attr="")
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
std::vector< std::string > getCorrelationTokens(const std::string &name)
+ Here is the call graph for this function:

◆ getIndexCurrency()

string getIndexCurrency ( string  indexName)

Utilities.

Definition at line 1020 of file sensitivityscenariodata.cpp.

1020 {
1021 vector<string> tokens;
1022 boost::split(tokens, indexName, boost::is_any_of("-"));
1023 QL_REQUIRE(tokens.size() > 1, "expected 2 or 3 tokens, found " << tokens.size() << " in " << indexName);
1024 return tokens[0];
1025}

◆ shiftDataFromXML()

void shiftDataFromXML ( XMLNode child,
ShiftData data 
)
protected

Definition at line 40 of file sensitivityscenariodata.cpp.

40 {
41
42 // read in the shift types, sizes, schemes for all keys
43
44 vector<string> shiftTypeKeys;
45 vector<string> shiftSizeKeys;
46 vector<string> shiftSchemeKeys;
47
48 auto shiftTypes =
49 XMLUtils::getChildrenValuesWithAttributes(child, std::string(), "ShiftType", "key", shiftTypeKeys);
50 auto shiftSizes = XMLUtils::getChildrenValuesWithAttributes<Real>(child, std::string(), "ShiftSize", "key",
51 shiftSizeKeys, &ore::data::parseReal);
52 auto shiftSchemes =
53 XMLUtils::getChildrenValuesWithAttributes(child, std::string(), "ShiftScheme", "key", shiftSchemeKeys);
54
55 // check that attributes are unique
56
57 QL_REQUIRE(shiftTypeKeys.size() == std::set<string>(shiftTypeKeys.begin(), shiftTypeKeys.end()).size(),
58 "SensitivityScenarioData::shiftDataFromXML(): non-unique attributes for ShiftType in node '"
59 << XMLUtils::getNodeName(child) << "'");
60 QL_REQUIRE(shiftSizeKeys.size() == std::set<string>(shiftSizeKeys.begin(), shiftSizeKeys.end()).size(),
61 "SensitivityScenarioData::shiftDataFromXML(): non-unique attributes for ShiftSize in node '"
62 << XMLUtils::getNodeName(child) << "'");
63 QL_REQUIRE(shiftSchemeKeys.size() == std::set<string>(shiftSchemeKeys.begin(), shiftSchemeKeys.end()).size(),
64 "SensitivityScenarioData::shiftDataFromXML(): non-unique attributes for ShiftScheme in node '"
65 << XMLUtils::getNodeName(child) << "'");
66
67 // extract the parameter without attribute, shift type and size are mandatory, scheme is optional
68
69 auto shiftTypeEmptyKey = std::find(shiftTypeKeys.begin(), shiftTypeKeys.end(), std::string());
70 auto shiftSizeEmptyKey = std::find(shiftSizeKeys.begin(), shiftSizeKeys.end(), std::string());
71 auto shiftSchemeEmptyKey = std::find(shiftSchemeKeys.begin(), shiftSchemeKeys.end(), std::string());
72
73 QL_REQUIRE(shiftTypeEmptyKey != shiftTypeKeys.end(),
74 "SensitivityScenarioData::shiftDataFromXML(): no ShiftType without attribute defined in node '"
75 << XMLUtils::getNodeName(child) << "'");
76 QL_REQUIRE(shiftSizeEmptyKey != shiftSizeKeys.end(),
77 "SensitivityScenarioData::shiftDataFromXML(): no ShiftSize without attribute defined in node '"
78 << XMLUtils::getNodeName(child) << "'");
79
80 data.shiftType = parseShiftType(shiftTypes.at(std::distance(shiftTypeKeys.begin(), shiftTypeEmptyKey)));
81 data.shiftSize = shiftSizes.at(std::distance(shiftSizeKeys.begin(), shiftSizeEmptyKey));
82
83 if (shiftSchemeEmptyKey == shiftSchemeKeys.end())
84 data.shiftScheme = ShiftScheme::Forward;
85 else
86 data.shiftScheme =
87 parseShiftScheme(shiftSchemes.at(std::distance(shiftSchemeKeys.begin(), shiftSchemeEmptyKey)));
88
89 // extract the parameters with attribute
90
91 for (Size i = 0; i < shiftTypeKeys.size(); ++i) {
92 if (!shiftTypeKeys[i].empty()) {
93 data.keyedShiftType[shiftTypeKeys[i]] = parseShiftType(shiftTypes[i]);
94 }
95 }
96 for (Size i = 0; i < shiftSizeKeys.size(); ++i) {
97 if (!shiftSizeKeys[i].empty()) {
98 data.keyedShiftSize[shiftSizeKeys[i]] = shiftSizes[i];
99 }
100 }
101 for (Size i = 0; i < shiftSchemeKeys.size(); ++i) {
102 if (!shiftSchemeKeys[i].empty()) {
103 data.keyedShiftScheme[shiftSchemeKeys[i]] = parseShiftScheme(shiftSchemes[i]);
104 }
105 }
106}
static string getNodeName(XMLNode *n)
static vector< string > getChildrenValuesWithAttributes(XMLNode *node, const string &names, const string &name, const string &attrName, vector< string > &attrs, bool mandatory=false)
Real parseReal(const string &s)
ShiftScheme parseShiftScheme(const std::string &s)
Definition: scenario.cpp:193
ShiftType parseShiftType(const std::string &s)
Definition: scenario.cpp:216
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ curveShiftDataFromXML()

void curveShiftDataFromXML ( XMLNode child,
CurveShiftData data 
)
protected

Definition at line 108 of file sensitivityscenariodata.cpp.

108 {
109 shiftDataFromXML(child, data);
110 data.shiftTenors = XMLUtils::getChildrenValuesAsPeriods(child, "ShiftTenors", true);
111}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ volShiftDataFromXML()

void volShiftDataFromXML ( XMLNode child,
VolShiftData data,
const bool  requireShiftStrikes = true 
)
protected

Definition at line 113 of file sensitivityscenariodata.cpp.

113 {
114 shiftDataFromXML(child, data);
115 data.shiftExpiries = XMLUtils::getChildrenValuesAsPeriods(child, "ShiftExpiries", true);
116 data.shiftStrikes = XMLUtils::getChildrenValuesAsDoublesCompact(child, "ShiftStrikes", requireShiftStrikes);
117 if (data.shiftStrikes.size() == 0)
118 data.shiftStrikes = {0.0};
119
120 // Set data.isRelative if it is provided explicitly
121 if (XMLNode* n = XMLUtils::getChildNode(child, "IsRelative")) {
122 data.isRelative = parseBool(XMLUtils::getNodeValue(n));
123 }
124}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shiftDataToXML()

void shiftDataToXML ( ore::data::XMLDocument doc,
XMLNode node,
const ShiftData data 
) const
protected

toXML helper methods

Definition at line 126 of file sensitivityscenariodata.cpp.

126 {
127 XMLUtils::addChild(doc, node, "ShiftType", ore::data::to_string(data.shiftType));
128 for (auto const& [k, v] : data.keyedShiftType)
129 XMLUtils::addChild(doc, node, "ShiftType", ore::data::to_string(v), "key", k);
130 XMLUtils::addChild(doc, node, "ShiftSize", data.shiftSize);
131 for (auto const& [k, v] : data.keyedShiftSize)
132 XMLUtils::addChild(doc, node, "ShiftSize", XMLUtils::convertToString(v), "key", k);
133 XMLUtils::addChild(doc, node, "ShiftScheme", ore::data::to_string(data.shiftScheme));
134 for (auto const& [k, v] : data.keyedShiftScheme)
135 XMLUtils::addChild(doc, node, "ShiftScheme", ore::data::to_string(v), "key", k);
136}
static string convertToString(const Real value)
std::string to_string(const LocationInfo &l)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ curveShiftDataToXML()

void curveShiftDataToXML ( ore::data::XMLDocument doc,
XMLNode node,
const CurveShiftData data 
) const
protected

Definition at line 138 of file sensitivityscenariodata.cpp.

138 {
139 shiftDataToXML(doc, node, data);
140 XMLUtils::addGenericChildAsList(doc, node, "ShiftTenors", data.shiftTenors);
141}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ volShiftDataToXML()

void volShiftDataToXML ( ore::data::XMLDocument doc,
XMLNode node,
const VolShiftData data 
) const
protected

Definition at line 143 of file sensitivityscenariodata.cpp.

143 {
144 shiftDataToXML(doc, node, data);
145 XMLUtils::addGenericChildAsList(doc, node, "ShiftExpiries", data.shiftExpiries);
146 XMLUtils::addChild(doc, node, "ShiftStrikes", data.shiftStrikes);
147}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parDataFromXML()

void parDataFromXML ( XMLNode child,
CurveShiftParData data 
)
private

Definition at line 1027 of file sensitivityscenariodata.cpp.

1027 {
1028 XMLNode* par = XMLUtils::getChildNode(child, "ParConversion");
1029 // QL_REQUIRE(par, "parData must be provided for parConversion");
1030 if (par) {
1031 data.parInstruments = XMLUtils::getChildrenValuesAsStrings(par, "Instruments", true);
1032 data.parInstrumentSingleCurve = XMLUtils::getChildValueAsBool(par, "SingleCurve", true);
1033 data.discountCurve = XMLUtils::getChildValue(par, "DiscountCurve", false);
1034 data.otherCurrency = XMLUtils::getChildValue(par, "OtherCurrency", false);
1035 XMLNode* conventionsNode = XMLUtils::getChildNode(par, "Conventions");
1036 data.parInstrumentConventions = XMLUtils::getChildrenAttributesAndValues(conventionsNode, "Convention", "id", true);
1037 }
1038}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parDataToXML()

XMLNode * parDataToXML ( ore::data::XMLDocument doc,
const QuantLib::ext::shared_ptr< CurveShiftData > &  csd 
) const
private

toXML helper method

Definition at line 1040 of file sensitivityscenariodata.cpp.

1041 {
1042
1043 // Check that we have a CurveShiftParData node
1044 auto data = QuantLib::ext::dynamic_pointer_cast<CurveShiftParData>(csd);
1045
1046 // TODO: Fail here because fromXML requires par everywhere but maybe needs to be revisited
1047 QL_REQUIRE(data, "The sensitivity configuration should have par conversion data");
1048
1049 XMLNode* parNode = doc.allocNode("ParConversion");
1050 XMLUtils::addGenericChildAsList(doc, parNode, "Instruments", data->parInstruments);
1051 XMLUtils::addChild(doc, parNode, "SingleCurve", data->parInstrumentSingleCurve);
1052 if (!data->discountCurve.empty())
1053 XMLUtils::addChild(doc, parNode, "DiscountCurve", data->discountCurve);
1054 if (!data->otherCurrency.empty())
1055 XMLUtils::addChild(doc, parNode, "OtherCurrency", data->otherCurrency);
1056 XMLNode* conventionsNode = XMLUtils::addChild(doc, parNode, "Conventions");
1057 for (const auto& kv : data->parInstrumentConventions) {
1058 XMLNode* conventionNode = doc.allocNode("Convention", kv.second);
1059 XMLUtils::addAttribute(doc, conventionNode, "id", kv.first);
1060 XMLUtils::appendNode(conventionsNode, conventionNode);
1061 }
1062
1063 return parNode;
1064}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ discountCurveShiftData_

map<string, QuantLib::ext::shared_ptr<CurveShiftData> > discountCurveShiftData_
protected

Definition at line 263 of file sensitivityscenariodata.hpp.

◆ indexCurveShiftData_

map<string, QuantLib::ext::shared_ptr<CurveShiftData> > indexCurveShiftData_
protected

Definition at line 264 of file sensitivityscenariodata.hpp.

◆ yieldCurveShiftData_

map<string, QuantLib::ext::shared_ptr<CurveShiftData> > yieldCurveShiftData_
protected

Definition at line 265 of file sensitivityscenariodata.hpp.

◆ fxShiftData_

map<string, SpotShiftData> fxShiftData_
protected

Definition at line 266 of file sensitivityscenariodata.hpp.

◆ capFloorVolShiftData_

map<string, QuantLib::ext::shared_ptr<CapFloorVolShiftData> > capFloorVolShiftData_
protected

Definition at line 267 of file sensitivityscenariodata.hpp.

◆ swaptionVolShiftData_

map<string, GenericYieldVolShiftData> swaptionVolShiftData_
protected

Definition at line 268 of file sensitivityscenariodata.hpp.

◆ yieldVolShiftData_

map<string, GenericYieldVolShiftData> yieldVolShiftData_
protected

Definition at line 269 of file sensitivityscenariodata.hpp.

◆ fxVolShiftData_

map<string, VolShiftData> fxVolShiftData_
protected

Definition at line 270 of file sensitivityscenariodata.hpp.

◆ cdsVolShiftData_

map<string, CdsVolShiftData> cdsVolShiftData_
protected

Definition at line 271 of file sensitivityscenariodata.hpp.

◆ baseCorrelationShiftData_

map<string, BaseCorrelationShiftData> baseCorrelationShiftData_
protected

Definition at line 272 of file sensitivityscenariodata.hpp.

◆ zeroInflationCurveShiftData_

map<string, QuantLib::ext::shared_ptr<CurveShiftData> > zeroInflationCurveShiftData_
protected

Definition at line 273 of file sensitivityscenariodata.hpp.

◆ yoyInflationCurveShiftData_

map<string, QuantLib::ext::shared_ptr<CurveShiftData> > yoyInflationCurveShiftData_
protected

Definition at line 274 of file sensitivityscenariodata.hpp.

◆ yoyInflationCapFloorVolShiftData_

map<string, QuantLib::ext::shared_ptr<CapFloorVolShiftData> > yoyInflationCapFloorVolShiftData_
protected

Definition at line 275 of file sensitivityscenariodata.hpp.

◆ zeroInflationCapFloorVolShiftData_

map<string, QuantLib::ext::shared_ptr<CapFloorVolShiftData> > zeroInflationCapFloorVolShiftData_
protected

Definition at line 277 of file sensitivityscenariodata.hpp.

◆ creditCcys_

map<string, string> creditCcys_
protected

Definition at line 278 of file sensitivityscenariodata.hpp.

◆ creditCurveShiftData_

map<string, QuantLib::ext::shared_ptr<CurveShiftData> > creditCurveShiftData_
protected

Definition at line 279 of file sensitivityscenariodata.hpp.

◆ equityShiftData_

map<string, SpotShiftData> equityShiftData_
protected

Definition at line 280 of file sensitivityscenariodata.hpp.

◆ equityVolShiftData_

map<string, VolShiftData> equityVolShiftData_
protected

Definition at line 281 of file sensitivityscenariodata.hpp.

◆ dividendYieldShiftData_

map<string, QuantLib::ext::shared_ptr<CurveShiftData> > dividendYieldShiftData_
protected

Definition at line 282 of file sensitivityscenariodata.hpp.

◆ commodityCurrencies_

map<string, std::string> commodityCurrencies_
protected

Definition at line 283 of file sensitivityscenariodata.hpp.

◆ commodityCurveShiftData_

map<string, QuantLib::ext::shared_ptr<CurveShiftData> > commodityCurveShiftData_
protected

Definition at line 284 of file sensitivityscenariodata.hpp.

◆ correlationShiftData_

map<string, VolShiftData> correlationShiftData_
protected

Definition at line 285 of file sensitivityscenariodata.hpp.

◆ commodityVolShiftData_

map<string, VolShiftData> commodityVolShiftData_
protected

Definition at line 286 of file sensitivityscenariodata.hpp.

◆ securityShiftData_

map<string, SpotShiftData> securityShiftData_
protected

Definition at line 287 of file sensitivityscenariodata.hpp.

◆ crossGammaFilter_

vector<pair<string, string> > crossGammaFilter_
protected

Definition at line 289 of file sensitivityscenariodata.hpp.

◆ computeGamma_

bool computeGamma_
protected

Definition at line 290 of file sensitivityscenariodata.hpp.

◆ useSpreadedTermStructures_

bool useSpreadedTermStructures_
protected

Definition at line 291 of file sensitivityscenariodata.hpp.

◆ parConversion_

bool parConversion_
protected

Definition at line 292 of file sensitivityscenariodata.hpp.