Logo
Reference manual - version orea_version
Public Member Functions | List of all members
SensitivityScenarioGenerator Class Reference

Sensitivity Scenario Generator. More...

#include <orea/scenario/sensitivityscenariogenerator.hpp>

+ Inheritance diagram for SensitivityScenarioGenerator:

Public Member Functions

 SensitivityScenarioGenerator (const QuantLib::ext::shared_ptr< SensitivityScenarioData > &sensitivityData, const QuantLib::ext::shared_ptr< Scenario > &baseScenario, const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &simMarketData, const QuantLib::ext::shared_ptr< ScenarioSimMarket > &simMarket, const QuantLib::ext::shared_ptr< ScenarioFactory > &sensiScenarioFactory, const bool overrideTenors, const std::string &sensitivityTemplate=std::string(), const bool continueOnError=false, const QuantLib::ext::shared_ptr< Scenario > &baseScenarioAbsolute=nullptr)
 Constructor.
 
 ~SensitivityScenarioGenerator ()
 Default destructor.
 
const std::map< RiskFactorKey, QuantLib::Real > & shiftSizes () const
 
const std::map< RiskFactorKey, ShiftScheme > & shiftSchemes () const
 
const std::map< RiskFactorKey, QuantLib::Real > & baseValues () const
 
Size numScenarios () const
 
QuantLib::ext::shared_ptr< ScenariobaseScenarioAbsolute () const
 
- Public Member Functions inherited from ShiftScenarioGenerator
 ShiftScenarioGenerator (const QuantLib::ext::shared_ptr< Scenario > &baseScenario, const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &simMarketData, const QuantLib::ext::weak_ptr< ScenarioSimMarket > &simMarket)
 Constructor.
 
 ~ShiftScenarioGenerator ()
 Default destructor.
 
QuantLib::ext::shared_ptr< Scenarionext (const Date &d) override
 Scenario Generator interface.
 
void reset () override
 Reset the generator so calls to next() return the first scenario. More...
 
Size samples ()
 Inspectors. More...
 
const QuantLib::ext::shared_ptr< Scenario > & baseScenario ()
 Return the base scenario, i.e. cached initial values of all relevant market points.
 
const std::vector< QuantLib::ext::shared_ptr< Scenario > > & scenarios ()
 Return vector of sensitivity scenarios, scenario 0 is the base scenario.
 
std::vector< ScenarioDescriptionscenarioDescriptions ()
 Return vector of scenario descriptions.
 
const std::map< RiskFactorKey, std::string > & keyToFactor ()
 
const std::map< std::string, RiskFactorKey > & factorToKey ()
 Return revers map of factors to RiskFactorKeys.
 
void applyShift (Size j, Real shiftSize, bool up, ShiftType type, const vector< Time > &shiftTimes, const vector< Real > &values, const vector< Time > &times, vector< Real > &shiftedValues, bool initialise)
 Apply 1d triangular shift to 1d data such as yield curves, public to allow test suite access. More...
 
void applyShift (Size j, Size k, Real shiftSize, bool up, ShiftType type, const vector< Time > &shiftX, const vector< Time > &shiftY, const vector< Time > &dataX, const vector< Time > &dataY, const vector< vector< Real >> &data, vector< vector< Real >> &shiftedData, bool initialise)
 Apply 2d shift to 2d matrix such as swaption volatilities, public to allow test suite access. More...
 
QuantLib::ext::shared_ptr< ScenariobaseScenario () const
 return the base scenario
 
- Public Member Functions inherited from ScenarioGenerator
virtual ~ScenarioGenerator ()
 Default destructor.
 

Additional Inherited Members

- Protected Attributes inherited from ShiftScenarioGenerator
const QuantLib::ext::shared_ptr< ScenariobaseScenario_
 
const QuantLib::ext::shared_ptr< ScenarioSimMarketParameterssimMarketData_
 
const QuantLib::ext::weak_ptr< ScenarioSimMarketsimMarket_
 
std::vector< QuantLib::ext::shared_ptr< Scenario > > scenarios_
 
Size counter_
 
std::vector< ScenarioDescriptionscenarioDescriptions_
 
std::map< RiskFactorKey, std::string > keyToFactor_
 
std::map< std::string, RiskFactorKeyfactorToKey_
 

Detailed Description

Sensitivity Scenario Generator.

This class builds a vector of sensitivity scenarios based on instructions in SensitivityScenarioData and ScenarioSimMarketParameters objects passed.

The ScenarioSimMarketParameters object determines the scope and structure of a "simulation" market (currencies, currency pairs, curve tenor points, vol matrix expiries and terms/strikes etc) to which sensitivity scenarios are applied in order to compute their NPV impact.

The SensitivityScenarioData object determines the structure of shift curves (shift tenor points can differ from the simulation market's tenor points), as well as type (relative/absolute) and size of shifts applied.

The generator then produces comprehensive scenarios that can be applied to the simulation market, i.e. covering all quotes in the simulation market, possibly filled with "base" scenario values.

Both UP and DOWN shifts are generated in order to facilitate delta and gamma calculation.

The generator currently covers the IR/FX asset class, with shifts for the following term structure types:

For Credit the generator covers shifts to the following termstructure types:

To apply shifts to the integrated hazard rates let:

The relationship between these three can be expressed as:

\[ S(t) = e^{-&Lambda(t) t} \]

\[ &Lambda(t) = \frac{ \int_{0}^t &lambda(t) du}{t} \]

The survival probability quotes from the scenarioSimMarket default curves are then converted as follows:

\[ &Lambda(t) = - \frac{ ln( S(t) )}{t} \]

Note:

If sensitivityData_->generateSpreadScenarios() = true spread scenarios will be generated for supported risk factor types.

Member Function Documentation

◆ shiftSizes()

const std::map<RiskFactorKey, QuantLib::Real>& shiftSizes ( ) const

Return the map of absolute shift sizes by risk factor key for this generator

Warning:
Where there are tenor specific shifts the shift size is only meaningful if the tenors in the sensitivity configuration line up with the tenors in the simulation market configuration. If this is not the case, an absolute shift size of Null<Real>() is added for the given risk factor key

◆ baseValues()

const std::map<RiskFactorKey, QuantLib::Real>& baseValues ( ) const

Similarly, reeturn the base values for each risk factor