Logo
Reference manual - version orea_version
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
ShiftScenarioGenerator Class Reference

Shift Scenario Generator. More...

#include <orea/scenario/shiftscenariogenerator.hpp>

+ Inheritance diagram for ShiftScenarioGenerator:

Classes

class  ScenarioDescription
 

Public Types

enum class  ShiftType { Absolute , Relative }
 

Public Member Functions

 ShiftScenarioGenerator (const boost::shared_ptr< Scenario > &baseScenario, const boost::shared_ptr< ScenarioSimMarketParameters > &simMarketData, const boost::weak_ptr< ScenarioSimMarket > &simMarket)
 Constructor.
 
 ~ShiftScenarioGenerator ()
 Default destructor.
 
boost::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 boost::shared_ptr< Scenario > & baseScenario ()
 Return the base scenario, i.e. cached initial values of all relevant market points.
 
const std::vector< boost::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...
 
boost::shared_ptr< ScenariobaseScenario () const
 return the base scenario
 
- Public Member Functions inherited from ScenarioGenerator
virtual ~ScenarioGenerator ()
 Default destructor.
 

Protected Attributes

const boost::shared_ptr< ScenariobaseScenario_
 
const boost::shared_ptr< ScenarioSimMarketParameterssimMarketData_
 
const boost::weak_ptr< ScenarioSimMarketsimMarket_
 
std::vector< boost::shared_ptr< Scenario > > scenarios_
 
Size counter_
 
std::vector< ScenarioDescriptionscenarioDescriptions_
 
std::map< RiskFactorKey, std::string > keyToFactor_
 
std::map< std::string, RiskFactorKeyfactorToKey_
 

Detailed Description

Shift Scenario Generator.

Base class for sensitivity and stress scenario generators

Member Function Documentation

◆ reset()

void reset ( )
overridevirtual

Reset the generator so calls to next() return the first scenario.

This allows re-generation of scenarios if required.

Implements ScenarioGenerator.

◆ samples()

Size samples ( )

Inspectors.

Number of shift scenarios

◆ applyShift() [1/2]

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.

Apply triangular shaped shifts to the underlying curve where the triangle reaches from the previous to the next shift tenor point with peak at the current shift tenor point. At the initial and final shift tenor the shape is replaced such that the full shift is applied to all curve grid points to the left of the first shift point and to the right of the last shift point, respectively. The procedure guarantees that no sensitivity to original curve points is "missed" when the shift curve is less granular, e.g. original curve |...|...|...|...|...|...|...|...|...| shift curve ......|...........|...........|......

Parameters
jNumber of the shift curve tenor point to be shifted here
shiftSizeShift size interpreted as either absolute or relative shift
upUpwards shift if true, otherwise downwards
typeAbsolute: newValue = oldValue + shiftSize. Relative: newValue = oldValue * (1 + shiftSize)
shiftTimesShift tenors expressed as times
valuesInput curve values such as zero rates
timesTenor points of the input curve, expressed as times
shiftedValuesResulting shifted curve with same tenor structure as the input curve
initialiseInitialise shiftedValues vector before applying this shift j (yes for sensitivity, no for stress)

◆ applyShift() [2/2]

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.

This is the 2d generalisation of the 1d version of applyShift()

Parameters
jIndex of the shift tenor in "expiry" direction
kIndex of the shift tenor in "term" (Swaptions) or "strike" (Caps) direction
shiftSizeShift size interpreted as either absolute or relative shift
upUpwards shift if true, otherwise downwards
typeAbsolute: newValue = oldValue + shiftSize. Relative: newValue = oldValue * (1 + shiftSize)
shiftXCoordinate time in "expiry" direction of the shift curve
shiftYCoordinate time in "term" or "strike" direction of the shift curve
dataXCoordinate time in "expiry" direction of the underlying data
dataYCoordinate time in "term" or "strike" direction of the underlying data
dataMatrix of input data
shiftedDataMatrix of shifted result data
initialiseInitialise shiftedData vector before applying this shift j/k (yes for sensitivity, no for stress)