#include <orea/engine/marketriskbacktest.hpp>
Inheritance diagram for MarketRiskBacktest:
Collaboration diagram for MarketRiskBacktest:Classes | |
| struct | BacktestArgs |
| class | BacktestReports |
| struct | Data |
| Used to pass information. More... | |
| struct | SummaryResults |
| Used to store results for writing rows in the summary report. More... | |
| struct | VarBenchmark |
Public Types | |
| enum class | VarType { HistSim , HistSimTaylor , Parametric , Lch } |
| VAR types used as a benchmark against which SIMM can be compared. More... | |
Public Member Functions | |
| MarketRiskBacktest (const std::string &calculationCurrency, const QuantLib::ext::shared_ptr< ore::data::Portfolio > &portfolio, const std::string &portfolioFilter, std::unique_ptr< BacktestArgs > btArgs, std::unique_ptr< SensiRunArgs > sensiArgs=nullptr, std::unique_ptr< FullRevalArgs > revalArgs=nullptr, std::unique_ptr< MultiThreadArgs > mtArgs=nullptr, const QuantLib::ext::shared_ptr< ore::analytics::HistoricalScenarioGenerator > &hisScenGen=nullptr, const bool breakdown=false, const bool requireTradePnl=false) | |
| virtual | ~MarketRiskBacktest () |
| bool | disablesAll (const QuantLib::ext::shared_ptr< ore::analytics::ScenarioFilter > &filter) const override |
| virtual void | addPnlRow (const QuantLib::ext::shared_ptr< BacktestReports > &reports, QuantLib::Size scenarioIdx, bool isCall, const ore::analytics::RiskFactorKey &key_1, QuantLib::Real shift_1, QuantLib::Real delta, QuantLib::Real gamma, QuantLib::Real deltaPnl, QuantLib::Real gammaPnl, const ore::analytics::RiskFactorKey &key_2=ore::analytics::RiskFactorKey(), QuantLib::Real shift_2=0.0, const std::string &tradeId="", const std::string ¤cy="", QuantLib::Real fxSpot=1.0) |
| Add a row to the P&L contribution report. More... | |
Public Member Functions inherited from MarketRiskReport | |
| 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) | |
| virtual | ~MarketRiskReport () |
| virtual void | initialise () |
| void | initSimMarket () |
| Method to init simMarket_ for multi-threaded ctors. More... | |
| virtual void | calculate (const QuantLib::ext::shared_ptr< Reports > &report) |
| void | enableCubeWrite (const std::string &cubeDir, const std::string &cubeFilename) |
Public Member Functions inherited from ProgressReporter | |
| ProgressReporter () | |
| void | registerProgressIndicator (const QuantLib::ext::shared_ptr< ProgressIndicator > &indicator) |
| void | unregisterProgressIndicator (const QuantLib::ext::shared_ptr< ProgressIndicator > &indicator) |
| void | unregisterAllProgressIndicators () |
| void | updateProgress (const unsigned long progress, const unsigned long total, const std::string &detail="") |
| void | resetProgress () |
| const std::set< QuantLib::ext::shared_ptr< ProgressIndicator > > & | progressIndicators () const |
Protected Types | |
| typedef std::map< VarType, std::pair< QuantLib::ext::shared_ptr< ore::analytics::VarCalculator >, QuantLib::Real > > | VarBenchmarks |
| pointers to the VAR benchmarks More... | |
Protected Member Functions | |
| void | initialise () override |
| virtual const std::vector< std::tuple< std::string, ore::data::Report::ReportType, QuantLib::Size > > | summaryColumns ()=0 |
| virtual const std::vector< std::tuple< std::string, ore::data::Report::ReportType, QuantLib::Size, bool > > | detailColumns ()=0 |
| virtual const std::vector< std::tuple< std::string, ore::data::Report::ReportType, QuantLib::Size > > | pnlColumns ()=0 |
| virtual QuantLib::Real | callValue (const Data &data)=0 |
| virtual QuantLib::Real | postValue (const Data &data)=0 |
| virtual std::string | counterparty (const std::string &tradeId) const =0 |
| virtual void | setUpBenchmarks ()=0 |
| virtual void | reset (const QuantLib::ext::shared_ptr< ore::analytics::MarketRiskGroupBase > &riskGroup) override |
| void | createReports (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports) override |
| virtual bool | runTradeDetail (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports) override |
| ore::data::TimePeriod | covariancePeriod () const override |
| void | addPnlCalculators (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports) override |
| void | handleSensiResults (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports, const QuantLib::ext::shared_ptr< ore::analytics::MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< ore::analytics::TradeGroupBase > &tradeGroup) override |
| void | handleFullRevalResults (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports, const QuantLib::ext::shared_ptr< ore::analytics::MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< ore::analytics::TradeGroupBase > &tradeGroup) override |
| virtual void | adjustFullRevalPnls (std::vector< QuantLib::Real > &pnls, std::vector< QuantLib::Real > &bmPnls, ore::analytics::TradePnLStore &tradePnls, const std::vector< QuantLib::Real > &foSensiPnls, const std::vector< QuantLib::Real > &bmFoSensiPnls, const ore::analytics::TradePnLStore &foTradePnls, const QuantLib::ext::shared_ptr< ore::analytics::MarketRiskGroupBase > &riskGroup) |
| virtual void | addDetailRow (const QuantLib::ext::shared_ptr< BacktestReports > &reports, const Data &data, bool isCall, QuantLib::Real im, const QuantLib::Date &start, const QuantLib::Date &end, bool isFull, QuantLib::Real pnl, const std::string &result, const std::string &tradeId="") const =0 |
| Add a row to the detail report. More... | |
| virtual void | addSummaryRow (const QuantLib::ext::shared_ptr< BacktestReports > &reports, const Data &data, bool isCall, QuantLib::Real im, QuantLib::Size observations, bool isFull, QuantLib::Size exceptions, const std::vector< QuantLib::Size > &ragBounds, const VarBenchmarks &sensiBenchmarks, const VarBenchmarks &fullBenchmarks) const =0 |
| Add a row to the summary report. More... | |
| virtual void | calculateBenchmarks (VarBenchmarks &benchmarks, QuantLib::Real confidence, const bool isCall, const QuantLib::ext::shared_ptr< ore::analytics::MarketRiskGroupBase > &riskGroup, std::set< std::pair< std::string, QuantLib::Size > > &tradeIdIdxPairs) |
| Calculate and update the benchmarks. More... | |
| void | writeReports (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports, const QuantLib::ext::shared_ptr< ore::analytics::MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< ore::analytics::TradeGroupBase > &tradeGroup) override |
| std::vector< ore::data::TimePeriod > | timePeriods () override |
Protected Member Functions inherited from MarketRiskReport | |
| virtual void | initialiseRiskGroups () |
| Method for shared initialisation. More... | |
| virtual void | registerProgressIndicators () |
| virtual void | createReports (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports)=0 |
| virtual bool | runTradeDetail (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports) |
| virtual QuantLib::ext::shared_ptr< ScenarioFilter > | createScenarioFilter (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) |
| virtual void | reset (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) |
| virtual bool | runTradeRiskGroup (const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup, const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const |
| virtual bool | disablesAll (const QuantLib::ext::shared_ptr< ScenarioFilter > &filter) const |
| virtual void | updateFilter (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup, const QuantLib::ext::shared_ptr< ScenarioFilter > &filter) |
| update any filters required More... | |
| virtual std::string | portfolioId (const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup) const |
| virtual std::string | tradeGroupKey (const QuantLib::ext::shared_ptr< TradeGroupBase > &tradeGroup) const |
| virtual ore::data::TimePeriod | covariancePeriod () const |
| virtual void | addPnlCalculators (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports) |
| 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) |
| 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) |
| virtual bool | includeDeltaMargin (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const |
| virtual bool | includeGammaMargin (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const |
| virtual bool | runFullReval (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const |
| virtual bool | generateCube (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const |
| virtual std::string | cubeFilePath (const QuantLib::ext::shared_ptr< MarketRiskGroupBase > &riskGroup) const |
| virtual std::vector< ore::data::TimePeriod > | timePeriods () |
| 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 | closeReports (const QuantLib::ext::shared_ptr< MarketRiskReport::Reports > &reports) |
Protected Attributes | |
| std::unique_ptr< BacktestArgs > | btArgs_ |
| VarBenchmarks | sensiCallBenchmarks_ |
| VarBenchmarks | sensiPostBenchmarks_ |
| VarBenchmarks | fullRevalCallBenchmarks_ |
| VarBenchmarks | fullRevalPostBenchmarks_ |
| std::vector< QuantLib::Real > | bmSensiPnls_ |
| variables for benchmark calculations More... | |
| std::vector< QuantLib::Real > | bmFoSensiPnls_ |
| std::vector< QuantLib::Real > | pnls_ |
| std::vector< QuantLib::Real > | bmPnls_ |
| std::vector< QuantLib::Real > | sensiPnls_ |
| std::vector< QuantLib::Real > | foSensiPnls_ |
| ore::analytics::TradePnLStore | foTradePnls_ |
| ore::analytics::TradePnLStore | tradePnls_ |
| ore::analytics::TradePnLStore | sensiTradePnls_ |
| std::set< std::string > | callTradeIds_ |
| std::set< std::string > | postTradeIds_ |
Protected Attributes inherited from MarketRiskReport | |
| bool | sensiBased_ = false |
| bool | fullReval_ = false |
| std::string | calculationCurrency_ |
| QuantLib::ext::shared_ptr< Portfolio > | portfolio_ |
| std::string | portfolioFilter_ |
| boost::optional< ore::data::TimePeriod > | period_ |
| QuantLib::ext::shared_ptr< HistoricalScenarioGenerator > | hisScenGen_ |
| std::unique_ptr< SensiRunArgs > | sensiArgs_ |
| std::unique_ptr< FullRevalArgs > | fullRevalArgs_ |
| std::unique_ptr< MultiThreadArgs > | multiThreadArgs_ |
| bool | breakdown_ = false |
| bool | requireTradePnl_ = false |
| QuantLib::ext::shared_ptr< MarketRiskGroupBaseContainer > | riskGroups_ |
| QuantLib::ext::shared_ptr< TradeGroupBaseContainer > | tradeGroups_ |
| std::map< std::string, std::set< std::pair< std::string, QuantLib::Size > > > | tradeIdGroups_ |
| std::set< std::pair< std::string, QuantLib::Size > > | tradeIdIdxPairs_ |
| std::vector< std::string > | tradeIds_ |
| std::map< RiskFactorKey, QuantLib::Real > | deltas_ |
| std::map< std::pair< RiskFactorKey, RiskFactorKey >, QuantLib::Real > | gammas_ |
| QuantLib::Matrix | covarianceMatrix_ |
| bool | writePnl_ = false |
| std::vector< QuantLib::ext::shared_ptr< PNLCalculator > > | pnlCalculators_ |
| QuantLib::ext::shared_ptr< QuantExt::CovarianceSalvage > | salvage_ |
| bool | includeDeltaMargin_ = true |
| bool | includeGammaMargin_ = true |
| QuantLib::ext::shared_ptr< ore::data::EngineFactory > | factory_ |
| QuantLib::ext::shared_ptr< ore::analytics::HistoricalPnlGenerator > | histPnlGen_ |
| QuantLib::ext::shared_ptr< HistoricalSensiPnlCalculator > | sensiPnlCalculator_ |
Private Member Functions | |
| SummaryResults | calculateSummary (const QuantLib::ext::shared_ptr< BacktestReports > &reports, const Data &data, bool isFull, const std::vector< QuantLib::Real > &pnls, const std::vector< std::string > &tradeIds, const TradePnLStore &tradePnls) |
Definition at line 41 of file marketriskbacktest.hpp.
|
protected |
pointers to the VAR benchmarks
Definition at line 159 of file marketriskbacktest.hpp.
|
strong |
VAR types used as a benchmark against which SIMM can be compared.
| Enumerator | |
|---|---|
| HistSim | |
| HistSimTaylor | |
| Parametric | |
| Lch | |
Definition at line 44 of file marketriskbacktest.hpp.
| MarketRiskBacktest | ( | const std::string & | calculationCurrency, |
| const QuantLib::ext::shared_ptr< ore::data::Portfolio > & | portfolio, | ||
| const std::string & | portfolioFilter, | ||
| std::unique_ptr< BacktestArgs > | btArgs, | ||
| std::unique_ptr< SensiRunArgs > | sensiArgs = nullptr, |
||
| std::unique_ptr< FullRevalArgs > | revalArgs = nullptr, |
||
| std::unique_ptr< MultiThreadArgs > | mtArgs = nullptr, |
||
| const QuantLib::ext::shared_ptr< ore::analytics::HistoricalScenarioGenerator > & | hisScenGen = nullptr, |
||
| const bool | breakdown = false, |
||
| const bool | requireTradePnl = false |
||
| ) |
Definition at line 48 of file marketriskbacktest.cpp.
|
virtual |
Definition at line 137 of file marketriskbacktest.hpp.
|
override |
Check if the given scenario filter turns off all risk factors in the historical scenario generator
Definition at line 173 of file marketriskbacktest.cpp.
|
virtual |
Add a row to the P&L contribution report.
Definition at line 372 of file marketriskbacktest.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
overrideprotectedvirtual |
Reimplemented from MarketRiskReport.
Definition at line 64 of file marketriskbacktest.cpp.
Here is the call graph for this function:
|
protectedpure virtual |
Here is the caller graph for this function:
|
protectedpure virtual |
Here is the caller graph for this function:
|
protectedpure virtual |
Here is the caller graph for this function:
|
protectedpure virtual |
Here is the caller graph for this function:
|
protectedpure virtual |
Here is the caller graph for this function:
|
protectedpure virtual |
Here is the caller graph for this function:
|
protectedpure virtual |
|
overrideprotectedvirtual |
Definition at line 351 of file marketriskbacktest.cpp.
Here is the call graph for this function:
|
overrideprotectedvirtual |
Implements MarketRiskReport.
Definition at line 290 of file marketriskbacktest.cpp.
Here is the call graph for this function:
|
overrideprotectedvirtual |
Reimplemented from MarketRiskReport.
Definition at line 80 of file marketriskbacktest.cpp.
Here is the caller graph for this function:
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
Reimplemented from MarketRiskReport.
Definition at line 90 of file marketriskbacktest.cpp.
|
overrideprotected |
Definition at line 99 of file marketriskbacktest.cpp.
Here is the call graph for this function:
|
overrideprotected |
Definition at line 120 of file marketriskbacktest.cpp.
Here is the call graph for this function:
|
protectedvirtual |
Definition at line 190 of file marketriskbacktest.hpp.
Here is the caller graph for this function:
|
protectedpure virtual |
Add a row to the detail report.
Here is the caller graph for this function:
|
protectedpure virtual |
Add a row to the summary report.
Here is the caller graph for this function:
|
protectedvirtual |
Calculate and update the benchmarks.
Definition at line 340 of file marketriskbacktest.cpp.
Here is the caller graph for this function:
|
overrideprotected |
Definition at line 137 of file marketriskbacktest.cpp.
Here is the call graph for this function:
|
overrideprotectedvirtual |
Reimplemented from MarketRiskReport.
Definition at line 75 of file marketriskbacktest.cpp.
|
private |
Calculate the number of exceptions given the current data and the associated P&L vector pnls for both call and post sides. The parameter isFull is true if pnls come from a full revaluation and false if they are sensitivity based.
The parameters tradeIds and tradePnls are used if we are writing a trade level backtest detail report.
Definition at line 184 of file marketriskbacktest.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
protected |
Definition at line 153 of file marketriskbacktest.hpp.
|
protected |
Definition at line 160 of file marketriskbacktest.hpp.
|
protected |
Definition at line 160 of file marketriskbacktest.hpp.
|
protected |
Definition at line 160 of file marketriskbacktest.hpp.
|
protected |
Definition at line 160 of file marketriskbacktest.hpp.
|
protected |
variables for benchmark calculations
Definition at line 163 of file marketriskbacktest.hpp.
|
protected |
Definition at line 163 of file marketriskbacktest.hpp.
|
protected |
Definition at line 163 of file marketriskbacktest.hpp.
|
protected |
Definition at line 163 of file marketriskbacktest.hpp.
|
protected |
Definition at line 163 of file marketriskbacktest.hpp.
|
protected |
Definition at line 163 of file marketriskbacktest.hpp.
|
protected |
Definition at line 164 of file marketriskbacktest.hpp.
|
protected |
Definition at line 164 of file marketriskbacktest.hpp.
|
protected |
Definition at line 164 of file marketriskbacktest.hpp.
|
protected |
Definition at line 165 of file marketriskbacktest.hpp.
|
protected |
Definition at line 166 of file marketriskbacktest.hpp.