Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
parstressconversionanalytic.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2024 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
22
23using namespace ore::data;
24using namespace boost::filesystem;
25
26namespace ore {
27namespace analytics {
28
30 const auto stressData = inputs_->parStressScenarioData();
33 analytic()->configurations().todaysMarketParams = inputs_->todaysMarketParams();
34 analytic()->configurations().simMarketParams = inputs_->parStressSimMarketParams();
35 analytic()->configurations().sensiScenarioData = inputs_->parStressSensitivityScenarioData();
37}
38
39void ParStressConversionAnalyticImpl::runAnalytic(const QuantLib::ext::shared_ptr<ore::data::InMemoryLoader>& loader,
40 const std::set<std::string>& runTypes) {
41 if (!analytic()->match(runTypes))
42 return;
43
44 LOG("ParStressConversionAnalytic::runAnalytic called");
45
46 Settings::instance().evaluationDate() = inputs_->asof();
47 ObservationMode::instance().setMode(inputs_->observationModel());
48
49 CONSOLEW("ParStressConversionAnalytic: Build Market");
50 analytic()->buildMarket(loader);
51 CONSOLE("OK");
52
53 CONSOLEW("ParStressConversionAnalytic: Convert ParStressScenario");
54 LOG("Par Stress Conversion Analysis called");
55 QuantLib::ext::shared_ptr<StressTestScenarioData> scenarioData = inputs_->parStressScenarioData();
56 if (scenarioData != nullptr && scenarioData->hasScenarioWithParShifts()) {
57 ParStressTestConverter converter(
58 inputs_->asof(), analytic()->configurations().todaysMarketParams,
59 analytic()->configurations().simMarketParams, analytic()->configurations().sensiScenarioData,
60 analytic()->configurations().curveConfig, analytic()->market(), inputs_->iborFallbackConfig());
61 scenarioData = converter.convertStressScenarioData(scenarioData);
62 analytic()->stressTests()[label()]["parStress_ZeroStressData"] = scenarioData;
63 LOG("Finished par to zero scenarios conversion");
64 }
65 CONSOLE("OK");
66}
67
68ParStressConversionAnalytic::ParStressConversionAnalytic(const QuantLib::ext::shared_ptr<InputParameters>& inputs)
69 : Analytic(std::make_unique<ParStressConversionAnalyticImpl>(inputs), {"PARSTRESSCONVERSION"}, inputs, false, false,
70 false, false) {}
71} // namespace analytics
72} // namespace ore
Analytic * analytic() const
Definition: analytic.hpp:193
const std::string & label() const
Definition: analytic.hpp:190
void setGenerateAdditionalResults(const bool generateAdditionalResults)
Definition: analytic.hpp:197
QuantLib::ext::shared_ptr< InputParameters > inputs_
Definition: analytic.hpp:216
Configurations & configurations()
Definition: analytic.hpp:128
analytic_stresstests & stressTests()
Definition: analytic.hpp:134
virtual void buildMarket(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const bool marketRequired=true)
Definition: analytic.cpp:178
ParStressConversionAnalytic(const boost::shared_ptr< InputParameters > &inputs)
void runAnalytic(const boost::shared_ptr< ore::data::InMemoryLoader > &loader, const std::set< std::string > &runTypes={}) override
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.
#define LOG(text)
#define CONSOLEW(text)
#define CONSOLE(text)
Singleton class to hold global Observation Mode.
ORE Par-Stresstest-Conversion Analytic.
Convert all par shifts in a stress test to a zero shifts.
QuantLib::ext::shared_ptr< ore::analytics::SensitivityScenarioData > sensiScenarioData
Definition: analytic.hpp:70
QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > todaysMarketParams
Definition: analytic.hpp:68
bool simulationConfigRequired
Booleans to determine if these configs are needed.
Definition: analytic.hpp:64
QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > simMarketParams
Definition: analytic.hpp:69