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

#include <orea/app/analytics/stresstestanalytic.hpp>

+ Inheritance diagram for StressTestAnalyticImpl:
+ Collaboration diagram for StressTestAnalyticImpl:

Public Member Functions

 StressTestAnalyticImpl (const boost::shared_ptr< InputParameters > &inputs)
 
void runAnalytic (const boost::shared_ptr< ore::data::InMemoryLoader > &loader, const std::set< std::string > &runTypes={}) override
 
void setUpConfigurations () override
 
- Public Member Functions inherited from Analytic::Impl
 Impl ()
 
 Impl (const QuantLib::ext::shared_ptr< InputParameters > &inputs)
 
virtual ~Impl ()
 
virtual void runAnalytic (const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const std::set< std::string > &runTypes={})=0
 
virtual void setUpConfigurations ()
 
virtual QuantLib::ext::shared_ptr< ore::data::EngineFactoryengineFactory ()
 build an engine factory More...
 
void setLabel (const string &label)
 
const std::string & label () const
 
void setAnalytic (Analytic *analytic)
 
Analyticanalytic () const
 
void setInputs (const QuantLib::ext::shared_ptr< InputParameters > &inputs)
 
bool generateAdditionalResults () const
 
void setGenerateAdditionalResults (const bool generateAdditionalResults)
 
bool hasDependentAnalytic (const std::string &key)
 
template<class T >
QuantLib::ext::shared_ptr< T > dependentAnalytic (const std::string &key) const
 
QuantLib::ext::shared_ptr< AnalyticdependentAnalytic (const std::string &key) const
 
const std::map< std::string, QuantLib::ext::shared_ptr< Analytic > > & dependentAnalytics () const
 
void addDependentAnalytic (const std::string &key, const QuantLib::ext::shared_ptr< Analytic > &analytic)
 
std::vector< QuantLib::ext::shared_ptr< Analytic > > allDependentAnalytics () const
 
virtual std::vector< QuantLib::Date > additionalMarketDates () const
 

Static Public Attributes

static constexpr const char * LABEL = "STRESS"
 

Additional Inherited Members

- Protected Attributes inherited from Analytic::Impl
QuantLib::ext::shared_ptr< InputParametersinputs_
 
std::string label_
 label for logging purposes primarily More...
 
std::map< std::string, QuantLib::ext::shared_ptr< Analytic > > dependentAnalytics_
 

Detailed Description

Definition at line 29 of file stresstestanalytic.hpp.

Constructor & Destructor Documentation

◆ StressTestAnalyticImpl()

StressTestAnalyticImpl ( const boost::shared_ptr< InputParameters > &  inputs)

Definition at line 33 of file stresstestanalytic.hpp.

33 : Analytic::Impl(inputs) {
35 }
void setLabel(const string &label)
Definition: analytic.hpp:189
static constexpr const char * LABEL
+ Here is the call graph for this function:

Member Function Documentation

◆ runAnalytic()

void runAnalytic ( const boost::shared_ptr< ore::data::InMemoryLoader > &  loader,
const std::set< std::string > &  runTypes = {} 
)
override

Definition at line 48 of file stresstestanalytic.cpp.

49 {
50 if (!analytic()->match(runTypes))
51 return;
52
53 LOG("StressTestAnalytic::runAnalytic called");
54
55 Settings::instance().evaluationDate() = inputs_->asof();
56 ObservationMode::instance().setMode(inputs_->observationModel());
57 QL_REQUIRE(inputs_->portfolio(), "StressTestAnalytic::run: No portfolio loaded.");
58
59 CONSOLEW("StressTestAnalytic: Build Market");
60 analytic()->buildMarket(loader);
61 CONSOLE("OK");
62
63 CONSOLEW("StressTestAnalytic: Build Portfolio");
65 CONSOLE("OK");
66 QuantLib::ext::shared_ptr<InMemoryReport> report = QuantLib::ext::make_shared<InMemoryReport>();
67 // This hook allows modifying the portfolio in derived classes before running the analytics below,
68 // e.g. to apply SIMM exemptions.
70 CONSOLEW("Risk: Stress Test Report");
71 LOG("Stress Test Analysis called");
72 QuantLib::ext::shared_ptr<StressTestScenarioData> scenarioData = inputs_->stressScenarioData();
73 if (scenarioData != nullptr && scenarioData->hasScenarioWithParShifts()) {
74 try{
75 ParStressTestConverter converter(
76 inputs_->asof(), analytic()->configurations().todaysMarketParams,
77 analytic()->configurations().simMarketParams, analytic()->configurations().sensiScenarioData,
78 analytic()->configurations().curveConfig, analytic()->market(), inputs_->iborFallbackConfig());
79 scenarioData = converter.convertStressScenarioData(scenarioData);
80 analytic()->stressTests()[label()]["stress_ZeroStressData"] = scenarioData;
81 } catch(const std::exception& e){
82 StructuredAnalyticsErrorMessage(label(), "ParConversionFailed", e.what()).log();
83 }
84 }
85
86 Settings::instance().evaluationDate() = inputs_->asof();
87
88 std::string marketConfig = inputs_->marketConfig("pricing");
89 std::vector<QuantLib::ext::shared_ptr<ore::data::EngineBuilder>> extraEngineBuilders;
90 std::vector<QuantLib::ext::shared_ptr<ore::data::LegBuilder>> extraLegBuilders;
91 QuantLib::ext::shared_ptr<StressTest> stressTest = QuantLib::ext::make_shared<StressTest>(
92 analytic()->portfolio(), analytic()->market(), marketConfig, inputs_->pricingEngine(),
93 analytic()->configurations().simMarketParams, scenarioData, *analytic()->configurations().curveConfig,
94 *analytic()->configurations().todaysMarketParams, nullptr, inputs_->refDataManager(),
95 *inputs_->iborFallbackConfig(), inputs_->continueOnError());
96 stressTest->writeReport(report, inputs_->stressThreshold());
97 analytic()->reports()[label()]["stress"] = report;
98 CONSOLE("OK");
99}
Analytic * analytic() const
Definition: analytic.hpp:193
const std::string & label() const
Definition: analytic.hpp:190
QuantLib::ext::shared_ptr< InputParameters > inputs_
Definition: analytic.hpp:216
analytic_reports & reports()
Result reports.
Definition: analytic.hpp:131
analytic_stresstests & stressTests()
Definition: analytic.hpp:134
virtual void modifyPortfolio()
Definition: analytic.hpp:110
virtual void buildMarket(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const bool marketRequired=true)
Definition: analytic.cpp:178
virtual void buildPortfolio()
Definition: analytic.cpp:222
#define LOG(text)
#define CONSOLEW(text)
#define CONSOLE(text)
+ Here is the call graph for this function:

◆ setUpConfigurations()

void setUpConfigurations ( )
overridevirtual

Reimplemented from Analytic::Impl.

Definition at line 34 of file stresstestanalytic.cpp.

34 {
35 const auto stressData = inputs_->stressScenarioData();
37 if (stressData != nullptr) {
38 analytic()->configurations().sensitivityConfigRequired = stressData->hasScenarioWithParShifts();
39 } else {
41 }
42 analytic()->configurations().todaysMarketParams = inputs_->todaysMarketParams();
43 analytic()->configurations().simMarketParams = inputs_->stressSimMarketParams();
44 analytic()->configurations().sensiScenarioData = inputs_->stressSensitivityScenarioData();
46}
void setGenerateAdditionalResults(const bool generateAdditionalResults)
Definition: analytic.hpp:197
Configurations & configurations()
Definition: analytic.hpp:128
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
+ Here is the call graph for this function:

Member Data Documentation

◆ LABEL

constexpr const char* LABEL = "STRESS"
staticconstexpr

Definition at line 31 of file stresstestanalytic.hpp.