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. | |
~ShiftScenarioGenerator () | |
Default destructor. | |
QuantLib::ext::shared_ptr< Scenario > | next (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< ScenarioDescription > | scenarioDescriptions () |
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 > ×, 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 | |
Public Member Functions inherited from ScenarioGenerator | |
virtual | ~ScenarioGenerator () |
Default destructor. | |
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
|
overridevirtual |
Reset the generator so calls to next() return the first scenario.
This allows re-generation of scenarios if required.
Implements ScenarioGenerator.
Size samples | ( | ) |
Inspectors.
Number of shift scenarios
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) |