49 {
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");
62
63 CONSOLEW(
"StressTestAnalytic: Build Portfolio");
66 QuantLib::ext::shared_ptr<InMemoryReport> report = QuantLib::ext::make_shared<InMemoryReport>();
67
68
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(
77 analytic()->configurations().simMarketParams,
analytic()->configurations().sensiScenarioData,
79 scenarioData = converter.convertStressScenarioData(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>(
93 analytic()->configurations().simMarketParams, scenarioData, *
analytic()->configurations().curveConfig,
94 *
analytic()->configurations().todaysMarketParams,
nullptr,
inputs_->refDataManager(),
96 stressTest->writeReport(report,
inputs_->stressThreshold());
99}
Analytic * analytic() const
const std::string & label() const
QuantLib::ext::shared_ptr< InputParameters > inputs_
analytic_reports & reports()
Result reports.
analytic_stresstests & stressTests()
virtual void modifyPortfolio()
virtual void buildMarket(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const bool marketRequired=true)
virtual void buildPortfolio()