Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
reportwriter.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 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
19/*! \file orea/app/reportwriter.hpp
20 \brief A Class to write ORE outputs to reports
21 \ingroup app
22 */
23
24#pragma once
25
26#include <ql/shared_ptr.hpp>
27#include <map>
30#include <orea/cube/npvcube.hpp>
35#include <orea/simm/crif.hpp>
47#include <string>
48
49namespace ore {
50namespace analytics {
51//! Write ORE outputs to reports
52/*! \ingroup app
53 */
55public:
56 /*! Constructor.
57 \param nullString used to represent string values that are not applicable.
58 */
59 ReportWriter(const std::string& nullString = "#NA") : nullString_(nullString) {}
60
61 virtual ~ReportWriter(){};
62
63 virtual void writeNpv(ore::data::Report& report, const std::string& baseCurrency,
64 QuantLib::ext::shared_ptr<ore::data::Market> market, const std::string& configuration,
65 QuantLib::ext::shared_ptr<Portfolio> portfolio);
66
67 virtual void writeCashflow(ore::data::Report& report, const std::string& baseCurrency,
68 QuantLib::ext::shared_ptr<ore::data::Portfolio> portfolio,
69 QuantLib::ext::shared_ptr<ore::data::Market> market = QuantLib::ext::shared_ptr<ore::data::Market>(),
70 const std::string& configuration = ore::data::Market::defaultConfiguration,
71 const bool includePastCashflows = false);
72
73 virtual void writeCashflowNpv(ore::data::Report& report,
74 const ore::data::InMemoryReport& cashflowReport,
75 QuantLib::ext::shared_ptr<ore::data::Market> market,
76 const std::string& configuration,
77 const std::string& baseCcy,
78 const Date& horizon = Date::maxDate());
79
80 virtual void writeCurves(ore::data::Report& report, const std::string& configID, const DateGrid& grid,
81 const TodaysMarketParameters& marketConfig, const QuantLib::ext::shared_ptr<Market>& market,
82 const bool continueOnError = false);
83
84 virtual void writeTradeExposures(ore::data::Report& report, QuantLib::ext::shared_ptr<PostProcess> postProcess,
85 const std::string& tradeId);
86
87 virtual void writeNettingSetExposures(ore::data::Report& report, QuantLib::ext::shared_ptr<PostProcess> postProcess,
88 const std::string& nettingSetId);
89
90 virtual void writeNettingSetExposures(ore::data::Report& report, QuantLib::ext::shared_ptr<PostProcess> postProcess);
91
92 virtual void writeNettingSetCvaSensitivities(ore::data::Report& report, QuantLib::ext::shared_ptr<PostProcess> postProcess,
93 const std::string& nettingSetId);
94
95 virtual void writeNettingSetColva(ore::data::Report& report, QuantLib::ext::shared_ptr<PostProcess> postProcess,
96 const std::string& nettingSetId);
97
98 virtual void writeXVA(ore::data::Report& report, const string& allocationMethod,
99 QuantLib::ext::shared_ptr<Portfolio> portfolio, QuantLib::ext::shared_ptr<PostProcess> postProcess);
100
102
103 virtual void writeScenarioReport(ore::data::Report& report,
104 const std::vector<QuantLib::ext::shared_ptr<SensitivityCube>>& sensitivityCubes,
105 QuantLib::Real outputThreshold = 0.0);
106
107 virtual void writeSensitivityReport(ore::data::Report& report, const QuantLib::ext::shared_ptr<SensitivityStream>& ss,
108 QuantLib::Real outputThreshold = 0.0, QuantLib::Size outputPrecision = 2);
109
111 const std::map<RiskFactorKey, QuantLib::Real>& shiftSizes,
112 const std::map<RiskFactorKey, QuantLib::Real>& baseValues,
113 const std::map<RiskFactorKey, std::string>& keyToFactor);
114
116 QuantLib::ext::shared_ptr<ore::data::Portfolio> portfolio,
117 QuantLib::ext::shared_ptr<Market> market, const std::string& baseCurrency,
118 const std::size_t precision = 6);
119
120 virtual void writeMarketData(ore::data::Report& report, const QuantLib::ext::shared_ptr<ore::data::Loader>& loader, const QuantLib::Date& asof,
121 const set<string>& quoteNames, bool returnAll);
122
123 virtual void writeFixings(ore::data::Report& report, const QuantLib::ext::shared_ptr<ore::data::Loader>& loader);
124
125 virtual void writeDividends(ore::data::Report& report, const QuantLib::ext::shared_ptr<ore::data::Loader>& loader);
126
127 virtual void writePricingStats(ore::data::Report& report, const QuantLib::ext::shared_ptr<Portfolio>& portfolio);
128
129 virtual void writeCube(ore::data::Report& report, const QuantLib::ext::shared_ptr<NPVCube>& cube,
130 const std::map<std::string, std::string>& nettingSetMap = std::map<std::string, std::string>());
131
132 const std::string& nullString() const { return nullString_; }
133
134 /*! Write out the SIMM results contained in the \p resultsMap and \p additionalMargin.
135 The parameter \p resultsMap is a map containing the SIMM results containers for a
136 set of portfolios. The key is the portfolio ID and the value is the SIMM results
137 container for that portfolio. Similarly, the parameter \p additionalMargin contains
138 the additional margin element for each portfolio.
139 */
140 virtual void
142 std::map<NettingSetDetails, std::pair<std::string, SimmResults>>>& simmResultsMap,
143 const QuantLib::ext::shared_ptr<ore::data::Report> report, const bool hasNettingSetDetails = false,
144 const std::string& simmResultCcy = "", const std::string& simmCalcCcyCall = "",
145 const std::string& simmCalcCcyPost = "", const std::string& reportCcy = "",
146 QuantLib::Real fxSpot = 1.0, QuantLib::Real outputThreshold = 0.005);
147 virtual void
149 std::map<NettingSetDetails, std::map<std::string, SimmResults>>>& simmResultsMap,
150 const QuantLib::ext::shared_ptr<ore::data::Report> report, const bool hasNettingSetDetails = false,
151 const std::string& simmResultCcy = "", const std::string& simmCalcCcyCall = "",
152 const std::string& simmCalcCcyPost = "", const std::string& reportCcy = "",
153 const bool isFinalSimm = true, QuantLib::Real fxSpot = 1.0, QuantLib::Real outputThreshold = 0.005);
154
155 //! Write the SIMM data report i.e. the netted CRIF records used in a SIMM calculation
156 virtual void writeSIMMData(const ore::analytics::Crif& simmData,
157 const QuantLib::ext::shared_ptr<ore::data::Report>& dataReport,
158 const bool hasNettingSetDetails = false);
159
160 //! Write out CRIF records to a report
161 virtual void writeCrifReport(const QuantLib::ext::shared_ptr<ore::data::Report>& report,
162 const ore::analytics::Crif& crifRecords);
163
164 virtual void writeScenarioStatistics(const QuantLib::ext::shared_ptr<ore::analytics::ScenarioGenerator>& generator,
165 const std::vector<ore::analytics::RiskFactorKey>& keys,
166 QuantLib::Size numPaths, const std::vector<QuantLib::Date>& dates,
167 ore::data::Report& report);
168
169 virtual void writeScenarioDistributions(const QuantLib::ext::shared_ptr<ore::analytics::ScenarioGenerator>& generator,
170 const std::vector<ore::analytics::RiskFactorKey>& keys,
171 QuantLib::Size numPaths, const std::vector<QuantLib::Date>& dates,
172 QuantLib::Size distSteps, ore::data::Report& report);
173
174 virtual void
175 writeHistoricalScenarioDetails(const QuantLib::ext::shared_ptr<ore::analytics::HistoricalScenarioGenerator>& generator,
176 ore::data::Report& report);
177
178 virtual void writeStockSplitReport(const QuantLib::ext::shared_ptr<ore::analytics::Scenario>& baseScenario,
179 const QuantLib::ext::shared_ptr<ore::analytics::HistoricalScenarioLoader>& hsloader,
180 const QuantLib::ext::shared_ptr<ore::data::AdjustmentFactors>& adjFactors,
181 const QuantLib::ext::shared_ptr<ore::data::Report>& report);
182
183 void writeHistoricalScenarios(const QuantLib::ext::shared_ptr<HistoricalScenarioLoader>& hsloader,
184 const QuantLib::ext::shared_ptr<ore::data::Report>& report);
185
187 QuantLib::ext::shared_ptr<HistoricalScenarioGenerator>& hsgen,
188 const QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarket>& simMarket,
189 const QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarketParameters>& simMarketParams,
190 QuantLib::ext::shared_ptr<ore::data::Report> histScenDetailsReport, QuantLib::ext::shared_ptr<ore::data::Report> statReport,
191 QuantLib::ext::shared_ptr<ore::data::Report> distReport, QuantLib::Size distSteps = Null<Size>());
192
193 virtual void writeIMScheduleSummaryReport(
194 const std::map<SimmConfiguration::SimmSide,
195 std::map<NettingSetDetails, std::pair<std::string, IMScheduleResults>>>& finalResultsMap,
196 const QuantLib::ext::shared_ptr<Report> report, const bool hasNettingSetDetails = false,
197 const std::string& simmResultCcy = "", const std::string& reportCcy = "", QuantLib::Real fxSpot = 1.0,
198 QuantLib::Real outputThreshold = 0.005);
199
200 virtual void writeIMScheduleTradeReport(const std::map<std::string, std::vector<IMScheduleCalculator::IMScheduleTradeData>>& tradeResults,
201 const QuantLib::ext::shared_ptr<ore::data::Report> report,
202 const bool hasNettingSetDetails = false);
203
204 virtual void writePnlReport(ore::data::Report& report,
205 const ext::shared_ptr<InMemoryReport>& t0NpvReport,
206 const ext::shared_ptr<InMemoryReport>& t0NpvLaggedReport,
207 const ext::shared_ptr<InMemoryReport>& t1NpvLaggedReport,
208 const ext::shared_ptr<InMemoryReport>& t1NpvReport,
209 const ext::shared_ptr<InMemoryReport>& t0CashFlowReport,
210 const Date& startDate, const Date& endDate,
211 const std::string& baseCurrency,
212 const ext::shared_ptr<ore::data::Market>& market, const std::string& configuration,
213 const ext::shared_ptr<Portfolio>& portfolio);
214
215protected:
216 std::string nullString_;
218 const QuantLib::Date& actualDate = Date());
219};
220
221} // namespace analytics
222} // namespace ore
Container for storing simulated market data.
Write ORE outputs to reports.
void addMarketDatum(ore::data::Report &report, const ore::data::MarketDatum &md, const QuantLib::Date &actualDate=Date())
void writeHistoricalScenarios(const QuantLib::ext::shared_ptr< HistoricalScenarioLoader > &hsloader, const QuantLib::ext::shared_ptr< ore::data::Report > &report)
virtual void writeStockSplitReport(const QuantLib::ext::shared_ptr< ore::analytics::Scenario > &baseScenario, const QuantLib::ext::shared_ptr< ore::analytics::HistoricalScenarioLoader > &hsloader, const QuantLib::ext::shared_ptr< ore::data::AdjustmentFactors > &adjFactors, const QuantLib::ext::shared_ptr< ore::data::Report > &report)
virtual void writeHistoricalScenarioDetails(const QuantLib::ext::shared_ptr< ore::analytics::HistoricalScenarioGenerator > &generator, ore::data::Report &report)
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 writeSIMMReport(const std::map< SimmConfiguration::SimmSide, std::map< NettingSetDetails, std::map< std::string, SimmResults > > > &simmResultsMap, const QuantLib::ext::shared_ptr< ore::data::Report > report, const bool hasNettingSetDetails=false, const std::string &simmResultCcy="", const std::string &simmCalcCcyCall="", const std::string &simmCalcCcyPost="", const std::string &reportCcy="", const bool isFinalSimm=true, QuantLib::Real fxSpot=1.0, QuantLib::Real outputThreshold=0.005)
const std::string & nullString() const
virtual void writeMarketData(ore::data::Report &report, const QuantLib::ext::shared_ptr< ore::data::Loader > &loader, const QuantLib::Date &asof, const set< string > &quoteNames, bool returnAll)
virtual void writeSIMMReport(const std::map< SimmConfiguration::SimmSide, std::map< NettingSetDetails, std::pair< std::string, SimmResults > > > &simmResultsMap, const QuantLib::ext::shared_ptr< ore::data::Report > report, const bool hasNettingSetDetails=false, const std::string &simmResultCcy="", const std::string &simmCalcCcyCall="", const std::string &simmCalcCcyPost="", const std::string &reportCcy="", QuantLib::Real fxSpot=1.0, QuantLib::Real outputThreshold=0.005)
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 writeSIMMData(const ore::analytics::Crif &simmData, const QuantLib::ext::shared_ptr< ore::data::Report > &dataReport, const bool hasNettingSetDetails=false)
Write the SIMM data report i.e. the netted CRIF records used in a SIMM calculation.
virtual void writeCube(ore::data::Report &report, const QuantLib::ext::shared_ptr< NPVCube > &cube, const std::map< std::string, std::string > &nettingSetMap=std::map< std::string, std::string >())
virtual void writeIMScheduleTradeReport(const std::map< std::string, std::vector< IMScheduleCalculator::IMScheduleTradeData > > &tradeResults, const QuantLib::ext::shared_ptr< ore::data::Report > report, const bool hasNettingSetDetails=false)
virtual void writeNettingSetCvaSensitivities(ore::data::Report &report, QuantLib::ext::shared_ptr< PostProcess > postProcess, const std::string &nettingSetId)
ReportWriter(const std::string &nullString="#NA")
virtual void writeCashflowNpv(ore::data::Report &report, const ore::data::InMemoryReport &cashflowReport, QuantLib::ext::shared_ptr< ore::data::Market > market, const std::string &configuration, const std::string &baseCcy, const Date &horizon=Date::maxDate())
virtual void writeCrifReport(const QuantLib::ext::shared_ptr< ore::data::Report > &report, const ore::analytics::Crif &crifRecords)
Write out CRIF records to a report.
virtual void writeNettingSetExposures(ore::data::Report &report, QuantLib::ext::shared_ptr< PostProcess > postProcess, const std::string &nettingSetId)
virtual void writeDividends(ore::data::Report &report, const QuantLib::ext::shared_ptr< ore::data::Loader > &loader)
virtual void writeCurves(ore::data::Report &report, const std::string &configID, const DateGrid &grid, const TodaysMarketParameters &marketConfig, const QuantLib::ext::shared_ptr< Market > &market, const bool continueOnError=false)
virtual void writeSensitivityReport(ore::data::Report &report, const QuantLib::ext::shared_ptr< SensitivityStream > &ss, QuantLib::Real outputThreshold=0.0, QuantLib::Size outputPrecision=2)
virtual void writeTradeExposures(ore::data::Report &report, QuantLib::ext::shared_ptr< PostProcess > postProcess, const std::string &tradeId)
virtual void writeScenarioReport(ore::data::Report &report, const std::vector< QuantLib::ext::shared_ptr< SensitivityCube > > &sensitivityCubes, QuantLib::Real outputThreshold=0.0)
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 writeSensitivityConfigReport(ore::data::Report &report, const std::map< RiskFactorKey, QuantLib::Real > &shiftSizes, const std::map< RiskFactorKey, QuantLib::Real > &baseValues, const std::map< RiskFactorKey, std::string > &keyToFactor)
virtual void writeFixings(ore::data::Report &report, const QuantLib::ext::shared_ptr< ore::data::Loader > &loader)
virtual void writeXVA(ore::data::Report &report, const string &allocationMethod, QuantLib::ext::shared_ptr< Portfolio > portfolio, QuantLib::ext::shared_ptr< PostProcess > postProcess)
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)
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)
virtual void writePricingStats(ore::data::Report &report, const QuantLib::ext::shared_ptr< Portfolio > &portfolio)
virtual void writeIMScheduleSummaryReport(const std::map< SimmConfiguration::SimmSide, std::map< NettingSetDetails, std::pair< std::string, IMScheduleResults > > > &finalResultsMap, const QuantLib::ext::shared_ptr< Report > report, const bool hasNettingSetDetails=false, const std::string &simmResultCcy="", const std::string &reportCcy="", QuantLib::Real fxSpot=1.0, QuantLib::Real outputThreshold=0.005)
void writeHistoricalScenarioDistributions(QuantLib::ext::shared_ptr< HistoricalScenarioGenerator > &hsgen, const QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarket > &simMarket, const QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > &simMarketParams, QuantLib::ext::shared_ptr< ore::data::Report > histScenDetailsReport, QuantLib::ext::shared_ptr< ore::data::Report > statReport, QuantLib::ext::shared_ptr< ore::data::Report > distReport, QuantLib::Size distSteps=Null< Size >())
virtual void writeAggregationScenarioData(ore::data::Report &report, const AggregationScenarioData &data)
virtual void writeNettingSetColva(ore::data::Report &report, QuantLib::ext::shared_ptr< PostProcess > postProcess, const std::string &nettingSetId)
SimmSide
Enum indicating the relevant side of the SIMM calculation.
static const string defaultConfiguration
Struct for holding CRIF records.
Struct for holding a CRIF record.
Class for calculating SIMM.
Matrix generator(const Matrix &t, const Real horizon)
The base NPV cube class.
Open Risk Engine setup and analytics choice.
Exposure aggregation and XVA calculation.
Scenario generator base classes.
holds a grid of NPVs for a list of trades under various scenarios
Base class for sensitivity record streamer.
Class for holding SIMM results.
Date asof(14, Jun, 2018)