49std::ostream&
operator<<(std::ostream& out,
const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup);
56 virtual QuantLib::ext::shared_ptr<MarketRiskGroupBase>
next() = 0;
57 virtual void add(
const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup) = 0;
59 virtual QuantLib::Size
size() = 0;
71std::ostream&
operator<<(std::ostream& out,
const QuantLib::ext::shared_ptr<TradeGroupBase>& tradeGroup);
78 virtual QuantLib::ext::shared_ptr<TradeGroupBase>
next() = 0;
79 virtual void add(
const QuantLib::ext::shared_ptr<TradeGroupBase>& tradeGroup) = 0;
106 static std::map<MarketRiskConfiguration::RiskClass, QuantLib::Size>
rcOrder;
107 static std::map<MarketRiskConfiguration::RiskType, QuantLib::Size>
rtOrder;
109 bool operator()(
const QuantLib::ext::shared_ptr<MarketRiskGroup>& lhs,
110 const QuantLib::ext::shared_ptr<MarketRiskGroup>& rhs)
const;
113 QuantLib::ext::shared_ptr<MarketRiskGroupBase>
next()
override;
114 void add(
const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup)
override;
115 void reset()
override;
116 QuantLib::Size
size()
override;
123 std::set<QuantLib::ext::shared_ptr<MarketRiskGroup>>::const_iterator
rgIdx_;
144 QuantLib::ext::shared_ptr<TradeGroupBase>
next()
override;
145 void add(
const QuantLib::ext::shared_ptr<TradeGroupBase>& tradeGroup)
override;
146 void reset()
override;
150 std::set<QuantLib::ext::shared_ptr<TradeGroup>>::const_iterator
tgIdx_;
166 const QuantLib::ext::shared_ptr<ScenarioShiftCalculator>& sc,
167 QuantLib::Real pnlThres = 0.01,
168 std::map<std::pair<RiskFactorKey, RiskFactorKey>, Real> ci = {})
174 QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarket>
simMarket_;
188 FullRevalArgs(
const QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarket>& sm,
189 const QuantLib::ext::shared_ptr<ore::data::EngineData>& ed,
190 const QuantLib::ext::shared_ptr<ore::data::ReferenceDataManager>& rd =
nullptr,
192 const bool dr =
false)
199 QuantLib::ext::shared_ptr<ore::data::Loader>
loader_;
203 QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarketParameters>
simMarketData_;
206 MultiThreadArgs(QuantLib::Size n, QuantLib::Date t,
const QuantLib::ext::shared_ptr<ore::data::Loader>& l,
207 const QuantLib::ext::shared_ptr<ore::data::CurveConfigurations>& cc,
208 const QuantLib::ext::shared_ptr<ore::data::TodaysMarketParameters>& tmp, std::string conf,
209 const QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarketParameters>& smd,
210 const std::string& context)
219 void add(
const QuantLib::ext::shared_ptr<ore::data::Report>& report) {
reports_.push_back(report); }
220 const std::vector<QuantLib::ext::shared_ptr<ore::data::Report>>&
reports()
const {
return reports_; };
223 std::vector<QuantLib::ext::shared_ptr<ore::data::Report>>
reports_;
226 MarketRiskReport(
const std::string& calculationCurrency,
const QuantLib::ext::shared_ptr<Portfolio>& portfolio,
227 const std::string& portfolioFilter, boost::optional<ore::data::TimePeriod> period,
228 const QuantLib::ext::shared_ptr<HistoricalScenarioGenerator>& hisScenGen =
nullptr,
229 std::unique_ptr<SensiRunArgs> sensiArgs =
nullptr, std::unique_ptr<FullRevalArgs> fullRevalArgs =
nullptr,
230 std::unique_ptr<MultiThreadArgs> multiThreadArgs =
nullptr,
const bool breakdown =
false,
231 const bool requireTradePnl =
false)
243 virtual void calculate(
const QuantLib::ext::shared_ptr<Reports>& report);
253 void enableCubeWrite(
const std::string& cubeDir,
const std::string& cubeFilename);
265 boost::optional<ore::data::TimePeriod>
period_;
266 QuantLib::ext::shared_ptr<HistoricalScenarioGenerator>
hisScenGen_;
275 QuantLib::ext::shared_ptr<MarketRiskGroupBaseContainer>
riskGroups_;
280 std::map<std::string, std::set<std::pair<std::string, QuantLib::Size>>>
tradeIdGroups_;
285 std::map<RiskFactorKey, QuantLib::Real>
deltas_;
286 std::map<std::pair<RiskFactorKey, RiskFactorKey>, QuantLib::Real>
gammas_;
290 QuantLib::ext::shared_ptr<QuantExt::CovarianceSalvage>
salvage_ =
291 QuantLib::ext::make_shared<QuantExt::SpectralCovarianceSalvage>();
296 QuantLib::ext::shared_ptr<ore::data::EngineFactory>
factory_;
298 QuantLib::ext::shared_ptr<ore::analytics::HistoricalPnlGenerator>
histPnlGen_;
302 virtual void createReports(
const QuantLib::ext::shared_ptr<MarketRiskReport::Reports>& reports) = 0;
304 virtual QuantLib::ext::shared_ptr<ScenarioFilter>
307 virtual void reset(
const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup);
309 const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup)
const {
316 virtual bool disablesAll(
const QuantLib::ext::shared_ptr<ScenarioFilter>& filter)
const {
return false; };
319 virtual void updateFilter(
const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup,
320 const QuantLib::ext::shared_ptr<ScenarioFilter>& filter) {}
321 virtual std::string
portfolioId(
const QuantLib::ext::shared_ptr<TradeGroupBase>& tradeGroup)
const;
322 virtual std::string
tradeGroupKey(
const QuantLib::ext::shared_ptr<TradeGroupBase>& tradeGroup)
const;
324 virtual void addPnlCalculators(
const QuantLib::ext::shared_ptr<MarketRiskReport::Reports>& reports) {}
328 const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup,
329 const QuantLib::ext::shared_ptr<TradeGroupBase>& tradeGroup){};
332 const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup,
333 const QuantLib::ext::shared_ptr<TradeGroupBase>& tradeGroup){};
335 virtual bool includeDeltaMargin(
const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup)
const {
338 virtual bool includeGammaMargin(
const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup)
const {
341 virtual bool runFullReval(
const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup)
const {
return true; }
342 virtual bool generateCube(
const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup)
const {
return true; }
343 virtual std::string
cubeFilePath(
const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup)
const {
344 return std::string();
347 virtual void writeReports(
const QuantLib::ext::shared_ptr<MarketRiskReport::Reports>& reports,
348 const QuantLib::ext::shared_ptr<MarketRiskGroupBase>& riskGroup,
349 const QuantLib::ext::shared_ptr<TradeGroupBase>& tradeGroup) {}
350 virtual void closeReports(
const QuantLib::ext::shared_ptr<MarketRiskReport::Reports>& reports);
MarketRiskGroupBaseContainer()
virtual QuantLib::Size size()=0
virtual ~MarketRiskGroupBaseContainer()
virtual QuantLib::ext::shared_ptr< MarketRiskGroupBase > next()=0
virtual void add(const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup)=0
virtual bool allLevel() const =0
virtual std::string to_string()=0
virtual ~MarketRiskGroupBase()
std::set< QuantLib::ext::shared_ptr< MarketRiskGroup > >::const_iterator rgIdx_
QuantLib::ext::shared_ptr< MarketRiskGroupBase > next() override
MarketRiskGroupContainer()
void add(const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) override
QuantLib::Size size() override
std::set< QuantLib::ext::shared_ptr< MarketRiskGroup >, CompRisk > riskGroups_
MarketRiskConfiguration::RiskType riskType_
std::string to_string() override
MarketRiskGroup(MarketRiskConfiguration::RiskClass riskClass, MarketRiskConfiguration::RiskType riskType)
MarketRiskConfiguration::RiskClass riskClass() const
bool allLevel() const override
MarketRiskConfiguration::RiskClass riskClass_
MarketRiskConfiguration::RiskType riskType() const
std::vector< QuantLib::ext::shared_ptr< ore::data::Report > > reports_
const std::vector< QuantLib::ext::shared_ptr< ore::data::Report > > & reports() const
void add(const QuantLib::ext::shared_ptr< ore::data::Report > &report)
QuantLib::ext::shared_ptr< ore::data::EngineFactory > factory_
virtual bool includeGammaMargin(const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const
virtual void initialise()
void enableCubeWrite(const std::string &cubeDir, const std::string &cubeFilename)
std::string calculationCurrency_
virtual void closeReports(const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports)
std::vector< QuantLib::ext::shared_ptr< PNLCalculator > > pnlCalculators_
boost::optional< ore::data::TimePeriod > period_
virtual void createReports(const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports)=0
virtual bool disablesAll(const QuantLib::ext::shared_ptr< ScenarioFilter > &filter) const
QuantLib::ext::shared_ptr< MarketRiskGroupBaseContainer > riskGroups_
virtual void calculate(const QuantLib::ext::shared_ptr< Reports > &report)
virtual std::string tradeGroupKey(const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup) const
void initSimMarket()
Method to init simMarket_ for multi-threaded ctors.
QuantLib::ext::shared_ptr< HistoricalScenarioGenerator > hisScenGen_
virtual bool runTradeRiskGroup(const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup, const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const
virtual QuantLib::ext::shared_ptr< ScenarioFilter > createScenarioFilter(const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup)
virtual bool includeDeltaMargin(const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const
virtual std::string portfolioId(const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup) const
virtual std::string cubeFilePath(const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const
std::unique_ptr< MultiThreadArgs > multiThreadArgs_
std::map< std::string, std::set< std::pair< std::string, QuantLib::Size > > > tradeIdGroups_
std::unique_ptr< FullRevalArgs > fullRevalArgs_
virtual void initialiseRiskGroups()
Method for shared initialisation.
QuantLib::Matrix covarianceMatrix_
QuantLib::ext::shared_ptr< Portfolio > portfolio_
QuantLib::ext::shared_ptr< HistoricalSensiPnlCalculator > sensiPnlCalculator_
std::map< RiskFactorKey, QuantLib::Real > deltas_
std::vector< std::string > tradeIds_
virtual ~MarketRiskReport()
std::map< std::pair< RiskFactorKey, RiskFactorKey >, QuantLib::Real > gammas_
virtual bool runFullReval(const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const
std::set< std::pair< std::string, QuantLib::Size > > tradeIdIdxPairs_
virtual void reset(const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup)
virtual void registerProgressIndicators()
std::unique_ptr< SensiRunArgs > sensiArgs_
virtual void writeReports(const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports, const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup)
virtual void handleFullRevalResults(const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports, const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup)
QuantLib::ext::shared_ptr< TradeGroupBaseContainer > tradeGroups_
virtual void addPnlCalculators(const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports)
virtual void updateFilter(const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< ScenarioFilter > &filter)
update any filters required
virtual bool runTradeDetail(const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports)
virtual bool generateCube(const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const
virtual std::vector< ore::data::TimePeriod > timePeriods()
virtual void handleSensiResults(const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &report, const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup)
QuantLib::ext::shared_ptr< QuantExt::CovarianceSalvage > salvage_
MarketRiskReport(const std::string &calculationCurrency, const QuantLib::ext::shared_ptr< Portfolio > &portfolio, const std::string &portfolioFilter, boost::optional< ore::data::TimePeriod > period, const QuantLib::ext::shared_ptr< HistoricalScenarioGenerator > &hisScenGen=nullptr, std::unique_ptr< SensiRunArgs > sensiArgs=nullptr, std::unique_ptr< FullRevalArgs > fullRevalArgs=nullptr, std::unique_ptr< MultiThreadArgs > multiThreadArgs=nullptr, const bool breakdown=false, const bool requireTradePnl=false)
std::string portfolioFilter_
QuantLib::ext::shared_ptr< ore::analytics::HistoricalPnlGenerator > histPnlGen_
virtual ore::data::TimePeriod covariancePeriod() const
TradeGroupBaseContainer()
virtual void add(const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup)=0
virtual QuantLib::ext::shared_ptr< TradeGroupBase > next()=0
virtual ~TradeGroupBaseContainer()
virtual bool allLevel() const =0
virtual ~TradeGroupBase()
virtual std::string to_string()=0
std::set< QuantLib::ext::shared_ptr< TradeGroup > >::const_iterator tgIdx_
void add(const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup) override
std::set< QuantLib::ext::shared_ptr< TradeGroup > > tradeGroups_
QuantLib::ext::shared_ptr< TradeGroupBase > next() override
std::string to_string() override
const std::string & portfolioId() const
TradeGroup(std::string portfolioId)
bool allLevel() const override
static IborFallbackConfig defaultConfig()
Class for generating portfolio P&Ls based on historical scenarios.
Class for generating sensi pnl.
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
std::vector< std::vector< QuantLib::Real > > TradePnLStore
risk class and type filter
Used to order pairs [Risk class, Risk Type].
bool operator()(const QuantLib::ext::shared_ptr< MarketRiskGroup > &lhs, const QuantLib::ext::shared_ptr< MarketRiskGroup > &rhs) const
static std::map< MarketRiskConfiguration::RiskClass, QuantLib::Size > rcOrder
static std::map< MarketRiskConfiguration::RiskType, QuantLib::Size > rtOrder
std::string cubeFilename_
std::string cubeDir_
If cube writing is enabled, cube(s) will be written to this directory.
FullRevalArgs(const QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarket > &sm, const QuantLib::ext::shared_ptr< ore::data::EngineData > &ed, const QuantLib::ext::shared_ptr< ore::data::ReferenceDataManager > &rd=nullptr, const ore::data::IborFallbackConfig ifc=ore::data::IborFallbackConfig::defaultConfig(), const bool dr=false)
QuantLib::ext::shared_ptr< ore::data::ReferenceDataManager > referenceData_
ore::data::IborFallbackConfig iborFallbackConfig_
bool writeCube_
True to enable cube writing.
QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarket > simMarket_
QuantLib::ext::shared_ptr< ore::data::EngineData > engineData_
QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > curveConfigs_
std::string configuration_
QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > todaysMarketParams_
MultiThreadArgs(QuantLib::Size n, QuantLib::Date t, const QuantLib::ext::shared_ptr< ore::data::Loader > &l, const QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > &cc, const QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > &tmp, std::string conf, const QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > &smd, const std::string &context)
QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > simMarketData_
QuantLib::ext::shared_ptr< ore::data::Loader > loader_
QuantLib::Real pnlWriteThreshold_
Amount by which absolute P&L value must exceed 0 to be written to P&L contribution report.
std::map< std::pair< RiskFactorKey, RiskFactorKey >, Real > covarianceInput_
Optional input of covariance matrix.
QuantLib::ext::shared_ptr< SensitivityStream > sensitivityStream_
Stream of sensitivity records used for the sensitivity based backtest.
QuantLib::ext::shared_ptr< ScenarioShiftCalculator > shiftCalculator_
Calculates the shift multiple in moving from one scenario to another.
SensiRunArgs(const QuantLib::ext::shared_ptr< SensitivityStream > &ss, const QuantLib::ext::shared_ptr< ScenarioShiftCalculator > &sc, QuantLib::Real pnlThres=0.01, std::map< std::pair< RiskFactorKey, RiskFactorKey >, Real > ci={})