32using namespace boost::filesystem;
42 LOG(
"ScenarioStatisticsAnalytic::setUpConfigurations() called");
51 std::string configuration =
inputs_->marketConfig(
"simulation");
52 simMarket_ = QuantLib::ext::make_shared<ScenarioSimMarket>(
54 analytic()->configurations().simMarketParams,
55 QuantLib::ext::make_shared<FixingManager>(
inputs_->asof()),
58 *
analytic()->configurations().todaysMarketParams,
69 QuantLib::ext::shared_ptr<ScenarioFactory> sf = QuantLib::ext::make_shared<SimpleScenarioFactory>(
true);
70 string config =
inputs_->marketConfig(
"simulation");
74 LOG(
"simulation grid size " <<
grid_->size());
75 LOG(
"simulation grid valuation dates " <<
grid_->valuationDates().size());
76 LOG(
"simulation grid close-out dates " <<
grid_->closeOutDates().size());
77 LOG(
"simulation grid front date " << io::iso_date(
grid_->dates().front()));
78 LOG(
"simulation grid back date " << io::iso_date(
grid_->dates().back()));
80 if (
inputs_->writeScenarios()) {
81 auto report = QuantLib::ext::make_shared<InMemoryReport>();
88 LOG(
"SCENARIO_STATISTICS: Build Simulation Model (continueOnCalibrationError = "
89 << std::boolalpha << continueOnCalibrationError <<
")");
91 analytic()->market(),
analytic()->configurations().crossAssetModelData,
inputs_->marketConfig(
"lgmcalibration"),
92 inputs_->marketConfig(
"fxcalibration"),
inputs_->marketConfig(
"eqcalibration"),
93 inputs_->marketConfig(
"infcalibration"),
inputs_->marketConfig(
"crcalibration"),
94 inputs_->marketConfig(
"simulation"),
false, continueOnCalibrationError,
"",
95 inputs_->salvageCorrelationMatrix() ? SalvagingAlgorithm::Spectral : SalvagingAlgorithm::None,
101 const std::set<std::string>& runTypes) {
103 LOG(
"Scenario analytic called with asof " << io::iso_date(
inputs_->asof()));
105 Settings::instance().evaluationDate() =
inputs_->asof();
108 LOG(
"SCENARIO_STATISTICS: Build Today's Market");
109 CONSOLEW(
"SCENARIO_STATISTICS: Build Market");
115 LOG(
"SCENARIO_STATISTICS: Build simulation market");
118 LOG(
"SCENARIO_STATISTICS: Build Scenario Generator");
119 auto globalParams =
inputs_->simulationPricingEngine()->globalParameters();
120 auto continueOnCalErr = globalParams.find(
"ContinueOnCalibrationError");
121 bool continueOnErr = (continueOnCalErr != globalParams.end()) &&
parseBool(continueOnCalErr->second);
124 LOG(
"SCENARIO_STATISTICS: Attach Scenario Generator to ScenarioSimMarket");
130 const vector<RiskFactorKey>& keys =
simMarket_->baseScenario()->keys();
132 inputs_->scenarioOutputZeroRate()
134 analytic()->configurations().simMarketParams)
137 auto statsReport = QuantLib::ext::make_shared<InMemoryReport>();
141 analytic()->
reports()[
"SCENARIO_STATISTICS"][
"scenario_statistics"] = statsReport;
143 auto distributionReport = QuantLib::ext::make_shared<InMemoryReport>();
146 inputs_->scenarioDistributionSteps(), *distributionReport);
147 analytic()->
reports()[
"SCENARIO_STATISTICS"][
"scenario_distribution"] = distributionReport;
Analytic * analytic() const
QuantLib::ext::shared_ptr< InputParameters > inputs_
analytic_reports & reports()
Result reports.
Configurations & configurations()
virtual void buildMarket(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const bool marketRequired=true)
Write ORE outputs to reports.
virtual void writeScenarioStatistics(const QuantLib::ext::shared_ptr< ore::analytics::ScenarioGenerator > &generator, const std::vector< ore::analytics::RiskFactorKey > &keys, QuantLib::Size numPaths, const std::vector< QuantLib::Date > &dates, ore::data::Report &report)
virtual void writeScenarioDistributions(const QuantLib::ext::shared_ptr< ore::analytics::ScenarioGenerator > &generator, const std::vector< ore::analytics::RiskFactorKey > &keys, QuantLib::Size numPaths, const std::vector< QuantLib::Date > &dates, QuantLib::Size distSteps, ore::data::Report &report)
Build a ScenarioGenerator.
QuantLib::ext::shared_ptr< ScenarioGenerator > build(QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > model, QuantLib::ext::shared_ptr< ScenarioFactory > sf, QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > marketConfig, Date asof, QuantLib::ext::shared_ptr< ore::data::Market > initMarket, const std::string &configuration=ore::data::Market::defaultConfiguration, const QuantLib::ext::shared_ptr< PathGeneratorFactory > &pf=QuantLib::ext::make_shared< MultiPathGeneratorFactory >())
Build function.
QuantLib::ext::shared_ptr< ScenarioGenerator > scenarioGenerator()
void setUpConfigurations() override
virtual void runAnalytic(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const std::set< std::string > &runTypes={}) override
QuantLib::ext::shared_ptr< ScenarioSimMarket > simMarket_
QuantLib::ext::shared_ptr< ScenarioGenerator > scenarioGenerator_
void buildScenarioSimMarket()
QuantLib::ext::shared_ptr< DateGrid > grid_
QuantLib::ext::shared_ptr< CrossAssetModel > model_
void buildScenarioGenerator(bool continueOnError)
void buildCrossAssetModel(bool continueOnError)
Handle< QuantExt::CrossAssetModel > model() const
Scenario generation using cross asset model paths.
bool parseBool(const string &s)
A Class to write ORE outputs to reports.
ORE Scenario Statistics Analytics.
factory classes for simple scenarios
QuantLib::ext::shared_ptr< ore::analytics::CrossAssetModelData > crossAssetModelData
QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > todaysMarketParams
QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > simMarketParams
QuantLib::ext::shared_ptr< ore::analytics::ScenarioGeneratorData > scenarioGeneratorData
Structured analytics error.
Class for structured analytics warnings.