Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
stressscenariogenerator.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file scenario/stressscenariogenerator.hpp
20 \brief Stress scenario generation
21 \ingroup scenario
22*/
23
24#pragma once
25
32
33namespace ore {
34namespace analytics {
35using namespace data;
36
37//! Stress Scenario Generator
38/*!
39 This class builds a vector of stress scenarios based on instructions in StressScenarioData
40 and ScenarioSimMarketParameters objects passed.
41
42 The ScenarioSimMarketParameters object determines the scope and structure of a "simulation"
43 market (currencies, currency pairs, curve tenor points, vol matrix expiries and terms/strikes etc)
44 to which sensitivity scenarios are applied in order to compute their NPV impact.
45
46 The StressScenarioData object determines the structure of shift curves (shift tenor points
47 can differ from the simulation market's tenor points), as well as type (relative/absolute) and size
48 of shifts applied.
49
50 The generator then produces comprehensive scenarios that can be applied to the simulation market,
51 i.e. covering all quotes in the simulation market, possibly filled with "base" scenario values.
52
53 The generator currently covers the IR/FX asset class, with shifts for the following term
54 structure types:
55 - FX spot rates
56 - FX ATM volatilities
57 - Discount curve zero rates
58 - Index curve zero rates
59 - Yield curve zero rates
60 - Swaption ATM volatility matrices
61 - Cap/Floor volatility matrices (by expiry and strike)
62
63 Note:
64 - For yield curves, the class applies shifts in the Zero rate domain only.
65 - Likewise, Cap/Floor volatility stress tests are applied in the optionlet domain.
66
67 \ingroup scenario
68 */
70public:
71 //! Constructor
72 StressScenarioGenerator(const QuantLib::ext::shared_ptr<StressTestScenarioData>& stressData,
73 const QuantLib::ext::shared_ptr<Scenario>& baseScenario,
74 const QuantLib::ext::shared_ptr<ScenarioSimMarketParameters>& simMarketData,
75 const QuantLib::ext::shared_ptr<ScenarioSimMarket>& simMarket,
76 const QuantLib::ext::shared_ptr<ScenarioFactory>& stressScenarioFactory,
77 const QuantLib::ext::shared_ptr<Scenario>& baseScenarioAbsolute = nullptr);
78 //! Default destructor
80
81private:
82 void generateScenarios();
83 void addFxShifts(StressTestScenarioData::StressTestData& data, QuantLib::ext::shared_ptr<Scenario>& scenario);
84 void addEquityShifts(StressTestScenarioData::StressTestData& data, QuantLib::ext::shared_ptr<Scenario>& scenario);
85 void addDiscountCurveShifts(StressTestScenarioData::StressTestData& data, QuantLib::ext::shared_ptr<Scenario>& scenario);
86 void addIndexCurveShifts(StressTestScenarioData::StressTestData& data, QuantLib::ext::shared_ptr<Scenario>& scenario);
87 void addYieldCurveShifts(StressTestScenarioData::StressTestData& data, QuantLib::ext::shared_ptr<Scenario>& scenario);
88 void addFxVolShifts(StressTestScenarioData::StressTestData& data, QuantLib::ext::shared_ptr<Scenario>& scenario);
89 void addEquityVolShifts(StressTestScenarioData::StressTestData& data, QuantLib::ext::shared_ptr<Scenario>& scenario);
90 void addSwaptionVolShifts(StressTestScenarioData::StressTestData& data, QuantLib::ext::shared_ptr<Scenario>& scenario);
91 void addCapFloorVolShifts(StressTestScenarioData::StressTestData& data, QuantLib::ext::shared_ptr<Scenario>& scenario);
92 void addSecuritySpreadShifts(StressTestScenarioData::StressTestData& data, QuantLib::ext::shared_ptr<Scenario>& scenario);
93 void addDefaultCurveShifts(StressTestScenarioData::StressTestData& data, QuantLib::ext::shared_ptr<Scenario>& scenario);
94 void addRecoveryRateShifts(StressTestScenarioData::StressTestData& data, QuantLib::ext::shared_ptr<Scenario>& scenario);
96 QuantLib::ext::shared_ptr<Scenario>& scenario);
97
98 QuantLib::ext::shared_ptr<StressTestScenarioData> stressData_;
99 QuantLib::ext::shared_ptr<ScenarioFactory> stressScenarioFactory_;
100 QuantLib::ext::shared_ptr<Scenario> baseScenarioAbsolute_;
101};
102} // namespace analytics
103} // namespace ore
const QuantLib::ext::shared_ptr< Scenario > & baseScenario()
Return the base scenario, i.e. cached initial values of all relevant market points.
void addCapFloorVolShifts(StressTestScenarioData::StressTestData &data, QuantLib::ext::shared_ptr< Scenario > &scenario)
void addFxVolShifts(StressTestScenarioData::StressTestData &data, QuantLib::ext::shared_ptr< Scenario > &scenario)
void addDefaultCurveShifts(StressTestScenarioData::StressTestData &data, QuantLib::ext::shared_ptr< Scenario > &scenario)
void addSwaptionVolShifts(StressTestScenarioData::StressTestData &data, QuantLib::ext::shared_ptr< Scenario > &scenario)
void addDiscountCurveShifts(StressTestScenarioData::StressTestData &data, QuantLib::ext::shared_ptr< Scenario > &scenario)
QuantLib::ext::shared_ptr< Scenario > baseScenarioAbsolute_
void addIndexCurveShifts(StressTestScenarioData::StressTestData &data, QuantLib::ext::shared_ptr< Scenario > &scenario)
void addYieldCurveShifts(StressTestScenarioData::StressTestData &data, QuantLib::ext::shared_ptr< Scenario > &scenario)
void addEquityShifts(StressTestScenarioData::StressTestData &data, QuantLib::ext::shared_ptr< Scenario > &scenario)
void addEquityVolShifts(StressTestScenarioData::StressTestData &data, QuantLib::ext::shared_ptr< Scenario > &scenario)
void addSecuritySpreadShifts(StressTestScenarioData::StressTestData &data, QuantLib::ext::shared_ptr< Scenario > &scenario)
QuantLib::ext::shared_ptr< ScenarioFactory > stressScenarioFactory_
void addRecoveryRateShifts(StressTestScenarioData::StressTestData &data, QuantLib::ext::shared_ptr< Scenario > &scenario)
void addSurvivalProbabilityShifts(StressTestScenarioData::StressTestData &data, QuantLib::ext::shared_ptr< Scenario > &scenario)
QuantLib::ext::shared_ptr< StressTestScenarioData > stressData_
void addFxShifts(StressTestScenarioData::StressTestData &data, QuantLib::ext::shared_ptr< Scenario > &scenario)
data
factory classes for scenarios
Scenario generator base classes.
A Market class that can be updated by Scenarios.
Shift scenario generation.
A class to hold the parametrisation for building sensitivity scenarios.