Shift Scenario Generator. More...
#include <orea/scenario/shiftscenariogenerator.hpp>
Classes | |
class | ScenarioDescription |
Public Member Functions | |
ShiftScenarioGenerator (const QuantLib::ext::shared_ptr< Scenario > &baseScenario, const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &simMarketData, const QuantLib::ext::weak_ptr< ScenarioSimMarket > &simMarket) | |
Constructor. More... | |
~ShiftScenarioGenerator () | |
Default destructor. More... | |
QuantLib::ext::shared_ptr< Scenario > | next (const Date &d) override |
Scenario Generator interface. More... | |
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. More... | |
const std::vector< QuantLib::ext::shared_ptr< Scenario > > & | scenarios () |
Return vector of sensitivity scenarios, scenario 0 is the base scenario. More... | |
std::vector< ScenarioDescription > | scenarioDescriptions () |
Return vector of scenario descriptions. More... | |
const std::map< RiskFactorKey, std::string > & | keyToFactor () |
const std::map< std::string, RiskFactorKey > & | factorToKey () |
Return revers map of factors to RiskFactorKeys. More... | |
void | applyShift (Size j, Real shiftSize, bool up, ShiftType type, const vector< Time > &shiftTimes, const vector< Real > &values, const vector< Time > ×, 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< Scenario > | baseScenario () const |
return the base scenario More... | |
Public Member Functions inherited from ScenarioGenerator | |
virtual | ~ScenarioGenerator () |
Default destructor. More... | |
virtual QuantLib::ext::shared_ptr< Scenario > | next (const Date &d)=0 |
Return the next scenario for the given date. More... | |
virtual void | reset ()=0 |
Reset the generator so calls to next() return the first scenario. More... | |
Protected Attributes | |
const QuantLib::ext::shared_ptr< Scenario > | baseScenario_ |
const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > | simMarketData_ |
const QuantLib::ext::weak_ptr< ScenarioSimMarket > | simMarket_ |
std::vector< QuantLib::ext::shared_ptr< Scenario > > | scenarios_ |
Size | counter_ |
std::vector< ScenarioDescription > | scenarioDescriptions_ |
std::map< RiskFactorKey, std::string > | keyToFactor_ |
std::map< std::string, RiskFactorKey > | factorToKey_ |
Shift Scenario Generator.
Base class for sensitivity and stress scenario generators
Definition at line 43 of file shiftscenariogenerator.hpp.
ShiftScenarioGenerator | ( | const QuantLib::ext::shared_ptr< Scenario > & | baseScenario, |
const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > & | simMarketData, | ||
const QuantLib::ext::weak_ptr< ScenarioSimMarket > & | simMarket | ||
) |
Constructor.
Definition at line 130 of file shiftscenariogenerator.cpp.
|
overridevirtual |
Scenario Generator interface.
Implements ScenarioGenerator.
Definition at line 140 of file shiftscenariogenerator.cpp.
|
overridevirtual |
Reset the generator so calls to next() return the first scenario.
This allows re-generation of scenarios if required.
Implements ScenarioGenerator.
Definition at line 98 of file shiftscenariogenerator.hpp.
Size samples | ( | ) |
const QuantLib::ext::shared_ptr< Scenario > & baseScenario | ( | ) |
Return the base scenario, i.e. cached initial values of all relevant market points.
Definition at line 106 of file shiftscenariogenerator.hpp.
const std::vector< QuantLib::ext::shared_ptr< Scenario > > & scenarios | ( | ) |
Return vector of sensitivity scenarios, scenario 0 is the base scenario.
Definition at line 108 of file shiftscenariogenerator.hpp.
std::vector< ScenarioDescription > scenarioDescriptions | ( | ) |
const std::map< RiskFactorKey, std::string > & keyToFactor | ( | ) |
Definition at line 112 of file shiftscenariogenerator.hpp.
const std::map< std::string, RiskFactorKey > & factorToKey | ( | ) |
Return revers map of factors to RiskFactorKeys.
Definition at line 114 of file shiftscenariogenerator.hpp.
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 ......|...........|...........|......
j | Number of the shift curve tenor point to be shifted here |
shiftSize | Shift size interpreted as either absolute or relative shift |
up | Upwards shift if true, otherwise downwards |
type | Absolute: newValue = oldValue + shiftSize. Relative: newValue = oldValue * (1 + shiftSize) |
shiftTimes | Shift tenors expressed as times |
values | Input curve values such as zero rates |
times | Tenor points of the input curve, expressed as times |
shiftedValues | Resulting shifted curve with same tenor structure as the input curve |
initialise | Initialise shiftedValues vector before applying this shift j (yes for sensitivity, no for stress) |
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()
j | Index of the shift tenor in "expiry" direction |
k | Index of the shift tenor in "term" (Swaptions) or "strike" (Caps) direction |
shiftSize | Shift size interpreted as either absolute or relative shift |
up | Upwards shift if true, otherwise downwards |
type | Absolute: newValue = oldValue + shiftSize. Relative: newValue = oldValue * (1 + shiftSize) |
shiftX | Coordinate time in "expiry" direction of the shift curve |
shiftY | Coordinate time in "term" or "strike" direction of the shift curve |
dataX | Coordinate time in "expiry" direction of the underlying data |
dataY | Coordinate time in "term" or "strike" direction of the underlying data |
data | Matrix of input data |
shiftedData | Matrix of shifted result data |
initialise | Initialise shiftedData vector before applying this shift j/k (yes for sensitivity, no for stress) |
Definition at line 277 of file shiftscenariogenerator.cpp.
QuantLib::ext::shared_ptr< Scenario > baseScenario | ( | ) | const |
|
protected |
Definition at line 183 of file shiftscenariogenerator.hpp.
|
protected |
Definition at line 184 of file shiftscenariogenerator.hpp.
|
protected |
Definition at line 185 of file shiftscenariogenerator.hpp.
|
protected |
Definition at line 186 of file shiftscenariogenerator.hpp.
|
protected |
Definition at line 187 of file shiftscenariogenerator.hpp.
|
protected |
Definition at line 188 of file shiftscenariogenerator.hpp.
|
protected |
Definition at line 190 of file shiftscenariogenerator.hpp.
|
protected |
Definition at line 192 of file shiftscenariogenerator.hpp.