Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
scenarioanalytic.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2023 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
21
22using namespace ore::analytics;
23
24namespace ore {
25namespace analytics {
26
28 analytic()->configurations().todaysMarketParams = inputs_->todaysMarketParams();
29 analytic()->configurations().simMarketParams = inputs_->scenarioSimMarketParams();
30}
31
32void ScenarioAnalyticImpl::runAnalytic(const QuantLib::ext::shared_ptr<InMemoryLoader>& loader,
33 const std::set<std::string>& runTypes) {
34
35 if (!analytic()->match(runTypes))
36 return;
37
38 LOG("ScenarioAnalytic::runAnalytic called");
39
40 analytic()->buildMarket(loader);
41
42 LOG("Building scenario simulation market for date " << io::iso_date(inputs_->asof()));
43 // FIXME: *configurations_.todaysMarketParams uninitialized?
44 auto ssm = QuantLib::ext::make_shared<ScenarioSimMarket>(
45 analytic()->market(), analytic()->configurations().simMarketParams, Market::defaultConfiguration,
46 *analytic()->configurations().curveConfig, *analytic()->configurations().todaysMarketParams, true,
47 useSpreadedTermStructures_, false, false, *inputs_->iborFallbackConfig());
48
50 auto scenario = ssm->baseScenario();
52
53 QuantLib::ext::shared_ptr<InMemoryReport> report = QuantLib::ext::make_shared<InMemoryReport>();
54 auto sw = ScenarioWriter(nullptr, report);
55 sw.writeScenario(scenario, true);
56 analytic()->reports()[label()]["scenario"] = report;
57}
58
59} // namespace analytics
60} // namespace ore
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
Configurations & configurations()
Definition: analytic.hpp:128
virtual void buildMarket(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const bool marketRequired=true)
Definition: analytic.cpp:178
const QuantLib::ext::shared_ptr< ore::analytics::Scenario > & scenario() const
void runAnalytic(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const std::set< std::string > &runTypes={}) override
void setScenario(const QuantLib::ext::shared_ptr< ore::analytics::Scenario > &scenario)
void setScenarioSimMarket(const QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarket > &ssm)
Class for writing scenarios to file.
static const string defaultConfiguration
#define LOG(text)
ORE Scenario Analytic.
ScenarioWriter class.
QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > todaysMarketParams
Definition: analytic.hpp:68
QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > simMarketParams
Definition: analytic.hpp:69