44 const std::set<std::string>& runTypes) {
49 Settings::instance().evaluationDate() =
inputs_->asof();
51 ObservationMode::instance().setMode(
inputs_->observationModel());
53 QL_REQUIRE(
inputs_->portfolio(),
"PnlAnalytic::run: No portfolio loaded.");
54 QL_REQUIRE(
inputs_->portfolio()->size() > 0,
"PnlAnalytic::run: Portfolio is empty.");
56 std::string effectiveResultCurrency =
74 QL_REQUIRE(
analytic()->configurations().simMarketParams,
"scenario sim market parameters not set");
75 QL_REQUIRE(
analytic()->configurations().todaysMarketParams,
"today's market parameters not set");
77 auto simMarket = QuantLib::ext::make_shared<ScenarioSimMarket>(
79 *
analytic()->configurations().curveConfig, *
analytic()->configurations().todaysMarketParams,
81 auto sgen = QuantLib::ext::make_shared<StaticScenarioGenerator>();
82 simMarket->scenarioGenerator() = sgen;
87 boost::shared_ptr<InMemoryReport> t0NpvReport = boost::make_shared<InMemoryReport>();
93 if (
inputs_->outputAdditionalResults()) {
94 CONSOLEW(
"Pricing: Additional t0 Results");
95 boost::shared_ptr<InMemoryReport> t0AddReport = boost::make_shared<InMemoryReport>();
98 effectiveResultCurrency);
109 boost::shared_ptr<InMemoryReport> t0CashFlowReport = boost::make_shared<InMemoryReport>();
110 string marketConfig =
inputs_->marketConfig(
"pricing");
114 marketConfig,
inputs_->includePastCashflows());
126 Settings::instance().evaluationDate() =
mporDate();
130 mporAnalytic->configurations().asofDate =
mporDate();
135 mporAnalytic->runAnalytic(loader);
138 Settings::instance().evaluationDate() =
inputs_->asof();
140 QuantLib::ext::shared_ptr<Scenario> asofBaseScenario = simMarket->baseScenarioAbsolute();
142 QuantLib::ext::shared_ptr<Scenario> mporBaseScenario = sai->
scenarioSimMarket()->baseScenarioAbsolute();
144 QuantLib::ext::shared_ptr<ore::analytics::Scenario>
t0Scenario =
150 QuantLib::ext::shared_ptr<ore::analytics::Scenario>
t1Scenario =
162 simMarket->update(simMarket->asofDate());
171 QuantLib::ext::shared_ptr<InMemoryReport> t0NpvLaggedReport = QuantLib::ext::make_shared<InMemoryReport>();
176 if (
inputs_->outputAdditionalResults()) {
177 CONSOLEW(
"Pricing: Additional Results, t0 lagged");
178 boost::shared_ptr<InMemoryReport> t0LaggedAddReport = boost::make_shared<InMemoryReport>();
181 effectiveResultCurrency);
195 Settings::instance().evaluationDate() = d1;
197 auto simMarket1 = sai->scenarioSimMarket();
198 auto sgen1 = QuantLib::ext::make_shared<StaticScenarioGenerator>();
201 simMarket1->scenarioGenerator() = sgen1;
202 simMarket1->update(d1);
205 QuantLib::ext::shared_ptr<InMemoryReport> t1NpvLaggedReport = QuantLib::ext::make_shared<InMemoryReport>();
212 if (
inputs_->outputAdditionalResults()) {
213 CONSOLEW(
"Pricing: Additional Results t1");
214 boost::shared_ptr<InMemoryReport> t1AddReport = boost::make_shared<InMemoryReport>();
217 effectiveResultCurrency);
229 sgen1->setScenario(sai->scenarioSimMarket()->baseScenario());
230 simMarket1->scenarioGenerator() = sgen1;
231 simMarket1->update(d1);
234 QuantLib::ext::shared_ptr<InMemoryReport> t1NpvReport = QuantLib::ext::make_shared<InMemoryReport>();
241 if (
inputs_->outputAdditionalResults()) {
242 CONSOLEW(
"Pricing: Additional t1 Results");
243 boost::shared_ptr<InMemoryReport> t1AddReport = boost::make_shared<InMemoryReport>();
246 effectiveResultCurrency);
258 QuantLib::ext::shared_ptr<InMemoryReport> pnlReport = QuantLib::ext::make_shared<InMemoryReport>();
260 .
writePnlReport(*pnlReport, t0NpvReport, t0NpvLaggedReport, t1NpvLaggedReport, t1NpvReport,
271 boost::shared_ptr<InMemoryReport> t0ScenarioReport = boost::make_shared<InMemoryReport>();
273 t0sw.writeScenario(asofBaseScenario,
true);
276 boost::shared_ptr<InMemoryReport> t1ScenarioReport = boost::make_shared<InMemoryReport>();
278 t1sw.writeScenario(mporBaseScenario,
true);
Analytic * analytic() const
const std::string & label() const
void setGenerateAdditionalResults(const bool generateAdditionalResults)
QuantLib::ext::shared_ptr< T > dependentAnalytic(const std::string &key) const
QuantLib::ext::shared_ptr< InputParameters > inputs_
analytic_reports & reports()
Result reports.
Configurations & configurations()
virtual void modifyPortfolio()
virtual void buildMarket(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const bool marketRequired=true)
void setMarket(const QuantLib::ext::shared_ptr< ore::data::Market > &market)
virtual void buildPortfolio()
void setUpConfigurations() override
const QuantLib::ext::shared_ptr< ore::analytics::Scenario > & t1Scenario() const
void runAnalytic(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const std::set< std::string > &runTypes={}) override
void setT1Scenario(const QuantLib::ext::shared_ptr< ore::analytics::Scenario > &scenario)
void setT0Scenario(const QuantLib::ext::shared_ptr< ore::analytics::Scenario > &scenario)
static constexpr const char * mporLookupKey
const QuantLib::Date & mporDate() const
bool useSpreadedTermStructures() const
const QuantLib::ext::shared_ptr< ore::analytics::Scenario > & t0Scenario() const
static constexpr const char * LABEL
Write ORE outputs to reports.
virtual void writePnlReport(ore::data::Report &report, const ext::shared_ptr< InMemoryReport > &t0NpvReport, const ext::shared_ptr< InMemoryReport > &t0NpvLaggedReport, const ext::shared_ptr< InMemoryReport > &t1NpvLaggedReport, const ext::shared_ptr< InMemoryReport > &t1NpvReport, const ext::shared_ptr< InMemoryReport > &t0CashFlowReport, const Date &startDate, const Date &endDate, const std::string &baseCurrency, const ext::shared_ptr< ore::data::Market > &market, const std::string &configuration, const ext::shared_ptr< Portfolio > &portfolio)
virtual void writeAdditionalResultsReport(ore::data::Report &report, QuantLib::ext::shared_ptr< ore::data::Portfolio > portfolio, QuantLib::ext::shared_ptr< Market > market, const std::string &baseCurrency, const std::size_t precision=6)
virtual void writeCashflow(ore::data::Report &report, const std::string &baseCurrency, QuantLib::ext::shared_ptr< ore::data::Portfolio > portfolio, QuantLib::ext::shared_ptr< ore::data::Market > market=QuantLib::ext::shared_ptr< ore::data::Market >(), const std::string &configuration=ore::data::Market::defaultConfiguration, const bool includePastCashflows=false)
virtual void writeNpv(ore::data::Report &report, const std::string &baseCurrency, QuantLib::ext::shared_ptr< ore::data::Market > market, const std::string &configuration, QuantLib::ext::shared_ptr< Portfolio > portfolio)
KeyType
Risk Factor types.
const QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarket > & scenarioSimMarket() const
Class for writing scenarios to file.
Real getDifferenceScenario(const RiskFactorKey::KeyType keyType, const Real v1, const Real v2)
Singleton class to hold global Observation Mode.
A Class to write ORE outputs to reports.
Scenario utility functions.
QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > todaysMarketParams
bool simulationConfigRequired
Booleans to determine if these configs are needed.
QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > simMarketParams