Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ParStressTestConverter Class Reference

#include <orea/engine/parstressconverter.hpp>

+ Collaboration diagram for ParStressTestConverter:

Public Member Functions

 ParStressTestConverter (const QuantLib::Date &asof, QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > &todaysMarketParams, const QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > &simMarketParams, const QuantLib::ext::shared_ptr< ore::analytics::SensitivityScenarioData > &sensiScenarioData, const QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > &curveConfigs, const QuantLib::ext::shared_ptr< ore::data::Market > &todaysMarket, const QuantLib::ext::shared_ptr< ore::data::IborFallbackConfig > &iborFallbackConfig)
 
QuantLib::ext::shared_ptr< ore::analytics::StressTestScenarioDataconvertStressScenarioData (const QuantLib::ext::shared_ptr< ore::analytics::StressTestScenarioData > &scenarioData) const
 Convert all par shifts to zero shifts for all scenarios defined in the stresstest. More...
 
std::pair< QuantLib::ext::shared_ptr< ScenarioSimMarket >, QuantLib::ext::shared_ptr< ParSensitivityAnalysis > > computeParSensitivity (const std::set< RiskFactorKey::KeyType > &typesDisabled) const
 

Private Member Functions

std::set< RiskFactorKey::KeyTypezeroRateRiskFactors (bool irCurveParRates, bool irCapFloorParRates, bool creditParRates) const
 get a set of risk factors which will be interpreted as zero rate shifts More...
 

Private Attributes

QuantLib::Date asof_
 
QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameterstodaysMarketParams_
 
QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameterssimMarketParams_
 
QuantLib::ext::shared_ptr< ore::analytics::SensitivityScenarioDatasensiScenarioData_
 
QuantLib::ext::shared_ptr< ore::data::CurveConfigurationscurveConfigs_
 
QuantLib::ext::shared_ptr< ore::data::MarkettodaysMarket_
 
QuantLib::ext::shared_ptr< ore::data::IborFallbackConfigiborFallbackConfig_
 

Detailed Description

Definition at line 39 of file parstressconverter.hpp.

Constructor & Destructor Documentation

◆ ParStressTestConverter()

ParStressTestConverter ( const QuantLib::Date &  asof,
QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > &  todaysMarketParams,
const QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > &  simMarketParams,
const QuantLib::ext::shared_ptr< ore::analytics::SensitivityScenarioData > &  sensiScenarioData,
const QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > &  curveConfigs,
const QuantLib::ext::shared_ptr< ore::data::Market > &  todaysMarket,
const QuantLib::ext::shared_ptr< ore::data::IborFallbackConfig > &  iborFallbackConfig 
)

Definition at line 77 of file parstressconverter.cpp.

84 : asof_(asof), todaysMarketParams_(todaysMarketParams), simMarketParams_(simMarketParams),
85 sensiScenarioData_(sensiScenarioData), curveConfigs_(curveConfigs), todaysMarket_(todaysMarket),
86 iborFallbackConfig_(iborFallbackConfig) {}
QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > curveConfigs_
QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > todaysMarketParams_
QuantLib::ext::shared_ptr< ore::data::Market > todaysMarket_
QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > simMarketParams_
QuantLib::ext::shared_ptr< ore::data::IborFallbackConfig > iborFallbackConfig_
QuantLib::ext::shared_ptr< ore::analytics::SensitivityScenarioData > sensiScenarioData_
Date asof(14, Jun, 2018)

Member Function Documentation

◆ convertStressScenarioData()

QuantLib::ext::shared_ptr< ore::analytics::StressTestScenarioData > convertStressScenarioData ( const QuantLib::ext::shared_ptr< ore::analytics::StressTestScenarioData > &  scenarioData) const

Convert all par shifts to zero shifts for all scenarios defined in the stresstest.

Definition at line 88 of file parstressconverter.cpp.

89 {
90 // Exit early if we have dont have any par stress shifts in any scenario
91 if (!stressTestData->hasScenarioWithParShifts()) {
92 LOG("ParStressConverter: No scenario with par shifts found, use it as is");
93 return stressTestData;
94 }
95 QuantLib::ext::shared_ptr<StressTestScenarioData> results = QuantLib::ext::make_shared<StressTestScenarioData>();
96 results->useSpreadedTermStructures() = stressTestData->useSpreadedTermStructures();
97 // Identify all required parInstruments, ignore if a risk factor is a zeroshift in all scenarios
98 // The following risk factors arent supported in the par stress
99 std::set<RiskFactorKey::KeyType> disabledRiskFactors{
102
103 auto disabled = disabledParRates(stressTestData->withIrCurveParShifts(), stressTestData->withIrCapFloorParShifts(),
104 stressTestData->withCreditCurveParShifts());
105 disabledRiskFactors.insert(disabled.begin(), disabled.end());
106
107 DLOG("ParStressConverter: The following risk factors will be not converted:")
108 for (const auto& keyType : disabledRiskFactors) {
109 DLOG(keyType);
110 }
111 LOG("ParStressConverter: Compute Par Sensitivities")
112 auto [simMarket, parAnalysis] = computeParSensitivity(disabledRiskFactors);
113 // Loop over scenarios
114 LOG("ParStressConverter: Build dependency graph of par instruments")
115 auto dependencyGraph = sortParRiskFactorByDependency(parAnalysis->parSensitivities());
116 ParStressScenarioConverter converter(asof_, dependencyGraph, simMarketParams_, sensiScenarioData_, simMarket,
117 parAnalysis->parInstruments(), stressTestData->useSpreadedTermStructures());
118
119 for (const auto& scenario : stressTestData->data()) {
120 DLOG("ParStressConverter: Scenario" << scenario.label);
121 if (scenario.containsParShifts()) {
122 try {
123 LOG("ParStressConverter: Scenario " << scenario.label << " Convert par shifts to zero shifts");
124 auto convertedScenario = converter.convertScenario(scenario);
125 results->data().push_back(std::move(convertedScenario));
126 } catch (const std::exception& e) {
127 StructuredAnalyticsWarningMessage("ParStressConversion", "ScenarioConversionFailed",
128 "Skip Scenario " + scenario.label + ", got :" + e.what())
129 .log();
130 }
131 } else {
132 LOG("ParStressConverter: Skip scenario " << scenario.label << ", it contains only zero shifts");
133 results->data().push_back(scenario);
134 }
135 }
136 return results;
137}
std::pair< QuantLib::ext::shared_ptr< ScenarioSimMarket >, QuantLib::ext::shared_ptr< ParSensitivityAnalysis > > computeParSensitivity(const std::set< RiskFactorKey::KeyType > &typesDisabled) const
#define LOG(text)
#define DLOG(text)
std::set< RiskFactorKey::KeyType > disabledParRates(bool irCurveParRates, bool irCapFloorParRates, bool creditParRates)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ computeParSensitivity()

std::pair< QuantLib::ext::shared_ptr< ScenarioSimMarket >, QuantLib::ext::shared_ptr< ParSensitivityAnalysis > > computeParSensitivity ( const std::set< RiskFactorKey::KeyType > &  typesDisabled) const

Creates a SimMarket, aligns the pillars and strikes of sim and sensitivity scenario market, computes par sensitivites

Definition at line 142 of file parstressconverter.cpp.

142 {
143 QL_REQUIRE(simMarketParams_ != nullptr, "computeParSensitivity: simMarketData required to compute par sensitivity before "
144 "converting par to zero stress test shifts");
145 QL_REQUIRE(sensiScenarioData_ != nullptr,
146 "computeParSensitivity: sensiScenarioData required to compute par sensitivity before "
147 "converting par to zero stress test shifts");
148 auto parAnalysis = ext::make_shared<ParSensitivityAnalysis>(asof_, simMarketParams_, *sensiScenarioData_,
149 Market::defaultConfiguration, true, typesDisabled);
150 QL_REQUIRE(parAnalysis != nullptr, "ParStressConverter: failed to generate parAnalysis");
151 LOG("ParStressConverter: Allign Pillars for par sensitivity analysis");
152 parAnalysis->alignPillars();
153 // Align Cap Floor Strikes
154 if (typesDisabled.count(RiskFactorKey::KeyType::OptionletVolatility) == 0) {
155 LOG("ParStressConverter: Allign CapFloor strikes and adjust optionletPillars");
156 for (const auto& [index, data] : sensiScenarioData_->capFloorVolShiftData()) {
157 simMarketParams_->setCapFloorVolStrikes(index, data->shiftStrikes);
158 simMarketParams_->setCapFloorVolAdjustOptionletPillars(true);
159 }
160 }
161 LOG("ParStressConverter: Build SimMarket");
162 auto simMarket = QuantLib::ext::make_shared<ScenarioSimMarket>(
166 sensiScenarioData_->useSpreadedTermStructures(), false, true, *iborFallbackConfig_);
167 LOG("ParStressConverter: Build ScenarioGenerator");
168 auto scnearioFactory = QuantLib::ext::make_shared<ore::analytics::DeltaScenarioFactory>(simMarket->baseScenario());
169 auto scenarioGenerator = QuantLib::ext::make_shared<SensitivityScenarioGenerator>(
170 sensiScenarioData_, simMarket->baseScenario(), simMarketParams_, simMarket, scnearioFactory, true, "", false,
171 simMarket->baseScenarioAbsolute());
172 simMarket->scenarioGenerator() = scenarioGenerator;
173 LOG("ParStressConverter: Compute ParInstrumentSensitivities");
174 parAnalysis->computeParInstrumentSensitivities(simMarket);
175 return {simMarket, parAnalysis};
176}
static const string defaultConfiguration
data
+ Here is the caller graph for this function:

◆ zeroRateRiskFactors()

std::set< RiskFactorKey::KeyType > zeroRateRiskFactors ( bool  irCurveParRates,
bool  irCapFloorParRates,
bool  creditParRates 
) const
private

get a set of risk factors which will be interpreted as zero rate shifts

Member Data Documentation

◆ asof_

QuantLib::Date asof_
private

Definition at line 63 of file parstressconverter.hpp.

◆ todaysMarketParams_

QuantLib::ext::shared_ptr<ore::data::TodaysMarketParameters> todaysMarketParams_
private

Definition at line 64 of file parstressconverter.hpp.

◆ simMarketParams_

QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarketParameters> simMarketParams_
private

Definition at line 65 of file parstressconverter.hpp.

◆ sensiScenarioData_

QuantLib::ext::shared_ptr<ore::analytics::SensitivityScenarioData> sensiScenarioData_
private

Definition at line 66 of file parstressconverter.hpp.

◆ curveConfigs_

QuantLib::ext::shared_ptr<ore::data::CurveConfigurations> curveConfigs_
private

Definition at line 67 of file parstressconverter.hpp.

◆ todaysMarket_

QuantLib::ext::shared_ptr<ore::data::Market> todaysMarket_
private

Definition at line 68 of file parstressconverter.hpp.

◆ iborFallbackConfig_

QuantLib::ext::shared_ptr<ore::data::IborFallbackConfig> iborFallbackConfig_
private

Definition at line 69 of file parstressconverter.hpp.