24#include <ql/time/daycounters/actualactual.hpp>
25#include <ql/time/daycounters/actual365fixed.hpp>
26#include <ql/time/daycounters/actual360.hpp>
45 const QuantLib::ext::shared_ptr<ScenarioSimMarketParameters>& simMarketConfig,
46 const QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarket>& simMarket)
47 : sensitivityConfig_(sensitivityConfig), simMarketConfig_(simMarketConfig), simMarket_(simMarket) {}
56 if (!std::isfinite(v_1) || std::isnan(v_1)) {
57 ALOG(
"The scenario value v_1 for key '" << key <<
"' is " << v_1 <<
" and is not usable so we are returning 0");
60 if (!std::isfinite(v_2) || std::isnan(v_2)) {
61 ALOG(
"The scenario value v_2 for key '" << key <<
"' is " << v_2 <<
" and is not usable so we are returning 0");
71 if (
close(shiftSize, 0.0)) {
72 ALOG(
"The shift size for key '" << key <<
"' in sensitivity config is zero");
81 if (
close(v_1, 0.0)) {
82 ALOG(
"The reference scenario value for key '"
83 << key <<
"' is zero and the shift is relative so must return a shift of zero");
85 result = v_2 / v_1 - 1.0;
96 DayCounter dc = Actual365Fixed();
99 case RFType::DiscountCurve:
100 case RFType::YieldCurve:
101 case RFType::IndexCurve:
104 dc =
simMarket_->iborIndex(key.
name)->forwardingTermStructure()->dayCounter();
106 case RFType::DividendYield:
111 case RFType::SurvivalProbability:
123 Time t = dc.yearFraction(
asof,
asof + p);
127 ALOG(
"The time needed in the denominator of the transform for key '"
128 << key <<
"' is zero so we return a transformed value of zero");
Data types stored in the scenario class.
std::string name
Key name.
KeyType
Risk Factor types.
virtual const Date & asof() const =0
Return the scenario asof date.
virtual Real get(const RiskFactorKey &key) const =0
Get an element from the scenario.
QuantLib::Real shift(const ore::analytics::RiskFactorKey &key, const ore::analytics::Scenario &s_1, const ore::analytics::Scenario &s_2) const
ScenarioShiftCalculator(const QuantLib::ext::shared_ptr< ore::analytics::SensitivityScenarioData > &sensitivityConfig, const QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > &simMarketConfig, const QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarket > &simMarket=QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarket >())
QuantLib::Real transform(const ore::analytics::RiskFactorKey &key, QuantLib::Real value, const QuantLib::Date &asof) const
QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > simMarketConfig_
QuantLib::ext::shared_ptr< ore::analytics::SensitivityScenarioData > sensitivityConfig_
QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarket > simMarket_
ScenarioSimMarket description.
Description of sensitivity shift scenarios.
Shift Scenario Generator.
SafeStack< ValueType > value
DayCounter parseDayCounter(const string &s)
RandomVariable log(RandomVariable x)
bool close(const Real &t_1, const Real &t_2)
ShiftType parseShiftType(const std::string &s)
Class for calculating the shift multiple between two scenarios for a given key.
Shift scenario generation.