Convert all par shifts to zero shifts for all scenarios defined in the stresstest.
89 {
90
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
98
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) {
110 }
111 LOG(
"ParStressConverter: Compute Par Sensitivities")
113
114 LOG("ParStressConverter: Build dependency graph of par instruments")
115 auto dependencyGraph = sortParRiskFactorByDependency(parAnalysis->parSensitivities());
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
@ YoYInflationCapFloorVolatility
@ ZeroInflationCapFloorVolatility
std::set< RiskFactorKey::KeyType > disabledParRates(bool irCurveParRates, bool irCapFloorParRates, bool creditParRates)