Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
parstressscenarioconverter.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2024 AcadiaSoft Inc.
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 orea/engine/parstressscenarioconverter.hpp
20 \brief Convert all par shifts in a single stress test scenario to a zero shifts
21 \ingroup engine
22*/
23
24#pragma once
35
36namespace ore {
37namespace analytics {
38
39// Utility function
40std::set<RiskFactorKey::KeyType> disabledParRates(bool irCurveParRates, bool irCapFloorParRates, bool creditParRates);
41
42//! Convert all par shifts in a single stress test scenario to zero shifts
44public:
46 const QuantLib::Date& asof, const std::vector<RiskFactorKey>& sortedParInstrumentRiskFactorKeys,
47 const QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarketParameters>& simMarketParams,
48 const QuantLib::ext::shared_ptr<ore::analytics::SensitivityScenarioData>& sensiScenarioData,
49 const QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarket>& simMarket,
51 bool useSpreadedTermStructure);
52
53 //! Convert par shifts in a stress scenario to zero shifts
56
57private:
58 //! check if the scenario can be converted
59 bool scenarioCanBeConverted(const StressTestScenarioData::StressTestData& parStressScenario) const;
60 //! compute the time to tenor of the risk factor key
61 double maturityTime(const RiskFactorKey& key) const;
62
63 //! get the strike and tenor from a optionlet riskfactor key
64 std::pair<size_t, size_t> getCapFloorTenorAndStrikeIds(const RiskFactorKey& rfKey) const;
65
66 //! convert the scenario value to the corresponding zero shift size for the stress test data
67 double shiftsSizeForScenario(const RiskFactorKey rfKey, double targetValue, double baseValue) const;
68
69 //! add zero shifts in the stress test data
71 const RiskFactorKey& key, const double zeroShift) const;
72
73 //! Compute the implied fair rate of the par instrument
74 double impliedParRate(const RiskFactorKey& key) const;
75
76 //! get the par stress shift size from stress test data
77 double getStressShift(const RiskFactorKey& key, const StressTestScenarioData::StressTestData& stressScenario) const;
78
79 double lowerBound(const RiskFactorKey key) const;
80 double upperBound(const RiskFactorKey key) const;
81
82 QuantLib::Date asof_;
83 const std::vector<RiskFactorKey> sortedParInstrumentRiskFactorKeys_;
84 QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarketParameters> simMarketParams_;
85 QuantLib::ext::shared_ptr<ore::analytics::SensitivityScenarioData> sensiScenarioData_;
86 mutable QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarket> simMarket_;
89
90 double minVol_ = 1e-8;
91 double maxVol_ = 10.0;
92 double minDiscountFactor_ = 1e-8;
93 double maxDiscountFactor_ = 10.0;
94 double accuracy_ = 1e-8;
95};
96} // namespace analytics
97} // namespace ore
Convert all par shifts in a single stress test scenario to zero shifts.
double maturityTime(const RiskFactorKey &key) const
compute the time to tenor of the risk factor key
bool scenarioCanBeConverted(const StressTestScenarioData::StressTestData &parStressScenario) const
check if the scenario can be converted
QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > simMarketParams_
double shiftsSizeForScenario(const RiskFactorKey rfKey, double targetValue, double baseValue) const
convert the scenario value to the corresponding zero shift size for the stress test data
double getStressShift(const RiskFactorKey &key, const StressTestScenarioData::StressTestData &stressScenario) const
get the par stress shift size from stress test data
QuantLib::ext::shared_ptr< ore::analytics::SensitivityScenarioData > sensiScenarioData_
ore::analytics::StressTestScenarioData::StressTestData convertScenario(const StressTestScenarioData::StressTestData &scenario) const
Convert par shifts in a stress scenario to zero shifts.
double impliedParRate(const RiskFactorKey &key) const
Compute the implied fair rate of the par instrument.
const std::vector< RiskFactorKey > sortedParInstrumentRiskFactorKeys_
double upperBound(const RiskFactorKey key) const
const ore::analytics::ParSensitivityInstrumentBuilder::Instruments & parInstruments_
void updateTargetStressTestScenarioData(StressTestScenarioData::StressTestData &stressScenario, const RiskFactorKey &key, const double zeroShift) const
add zero shifts in the stress test data
std::pair< size_t, size_t > getCapFloorTenorAndStrikeIds(const RiskFactorKey &rfKey) const
get the strike and tenor from a optionlet riskfactor key
double lowerBound(const RiskFactorKey key) const
QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarket > simMarket_
Data types stored in the scenario class.
Definition: scenario.hpp:48
std::set< RiskFactorKey::KeyType > disabledParRates(bool irCurveParRates, bool irCapFloorParRates, bool creditParRates)
Perfrom sensitivity analysis for a given portfolio.
Scenario class.
A Market class that can be updated by Scenarios.
A class to hold Scenario parameters for scenarioSimMarket.
A class to hold the parametrisation for building sensitivity scenarios.
A class to hold the parametrisation for building sensitivity scenarios.
Date asof(14, Jun, 2018)