#include <orea/engine/historicalpnlgenerator.hpp>
Inheritance diagram for HistoricalPnlGenerator:Public Types | |
| using | TradePnlStore = std::vector< std::vector< QuantLib::Real > > |
Public Member Functions | |
| HistoricalPnlGenerator (const std::string &baseCurrency, const QuantLib::ext::shared_ptr< ore::data::Portfolio > &portfolio, const QuantLib::ext::shared_ptr< ScenarioSimMarket > &simMarket, const QuantLib::ext::shared_ptr< HistoricalScenarioGenerator > &hisScenGen, const QuantLib::ext::shared_ptr< NPVCube > &cube, const set< std::pair< string, QuantLib::ext::shared_ptr< QuantExt::ModelBuilder >>> &modelBuilders={}, bool dryRun=false) | |
| HistoricalPnlGenerator (const string &baseCurrency, const QuantLib::ext::shared_ptr< Portfolio > &portfolio, const QuantLib::ext::shared_ptr< HistoricalScenarioGenerator > &hisScenGen, const QuantLib::ext::shared_ptr< EngineData > &engineData, const Size nThreads, const Date &today, const QuantLib::ext::shared_ptr< ore::data::Loader > &loader, const QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > &curveConfigs, const QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > &todaysMarketParams, const std::string &configuration, const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &simMarketData, const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceData=nullptr, const IborFallbackConfig &iborFallbackConfig=IborFallbackConfig::defaultConfig(), bool dryRun=false, const std::string &context="historical pnl generation") | |
| void | generateCube (const QuantLib::ext::shared_ptr< ScenarioFilter > &filter) |
| std::vector< QuantLib::Real > | pnl (const ore::data::TimePeriod &period, const std::set< std::pair< std::string, QuantLib::Size >> &tradeIds) const |
| std::vector< QuantLib::Real > | pnl (const ore::data::TimePeriod &period) const |
| std::vector< QuantLib::Real > | pnl (const std::set< std::pair< std::string, QuantLib::Size >> &tradeIds) const |
| std::vector< QuantLib::Real > | pnl () const |
| TradePnlStore | tradeLevelPnl (const ore::data::TimePeriod &period, const std::set< std::pair< std::string, QuantLib::Size >> &tradeIds) const |
| TradePnlStore | tradeLevelPnl (const ore::data::TimePeriod &period) const |
| TradePnlStore | tradeLevelPnl (const std::set< std::pair< std::string, QuantLib::Size >> &tradeIds) const |
| TradePnlStore | tradeLevelPnl () const |
| const QuantLib::ext::shared_ptr< NPVCube > & | cube () const |
| std::set< std::pair< std::string, QuantLib::Size > > | tradeIdIndexPairs () const |
| Set of trade ID and index pairs for all trades. | |
| ore::data::TimePeriod | timePeriod () const |
| Time period covered by the historical P&L generator. | |
Public Member Functions inherited from 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 |
Class for generating historical P&L vectors for a given portfolio in a given currency.
In particular, assume that the portfolio has a base NPV, \(\Pi_0\), today i.e. at \(t_0\). This class takes a HistoricalScenarioGenerator which holds a set of historical market moves, over a given period \(\tau\) e.g. 10 business days, for a set of past dates \(\{d_1, d_2, \ldots, d_N\}\). This class calculates the P&L changes on the portfolio, \(\{\Delta_1, \Delta_2, \ldots, \Delta_N\}\), resulting from applying these market moves to the base market. In other words, \(\Delta_i = \Pi_i - \Pi_0 \) where \(\Pi_i\) is the portfolio NPV under the shifted market corresponding to date \(d_i\) for \(i = 1, 2, \ldots, N\).
In the calculation of P&L, the class allows the scenario shifts to be filtered and also the trades to be filtered.
| using TradePnlStore = std::vector<std::vector<QuantLib::Real> > |
Return a vector of historical trade level P&L values restricted to scenarios falling in period and restricted to the given tradeIds. The P&L values are calculated from the last cube generated by generateCube. The first dimension is time and the second dimension is tradeId.
| HistoricalPnlGenerator | ( | const std::string & | baseCurrency, |
| const QuantLib::ext::shared_ptr< ore::data::Portfolio > & | portfolio, | ||
| const QuantLib::ext::shared_ptr< ScenarioSimMarket > & | simMarket, | ||
| const QuantLib::ext::shared_ptr< HistoricalScenarioGenerator > & | hisScenGen, | ||
| const QuantLib::ext::shared_ptr< NPVCube > & | cube, | ||
| const set< std::pair< string, QuantLib::ext::shared_ptr< QuantExt::ModelBuilder >>> & | modelBuilders = {}, |
||
| bool | dryRun = false |
||
| ) |
Constructor to use a single-threaded valuation engine
| baseCurrency | currency in which the P&Ls will be calculated |
| portfolio | portfolio of trades for which P&Ls will be calculated |
| simMarket | simulation market used for valuation |
| hisScenGen | historical scenario generator |
| cube | an NPV cube that will be populated by each call to generateCube |
| modelBuilders | model builders to update during a val engine run |
| dryRun | for testing - limit the number of scenarios to one and fill the cube with random data |
| HistoricalPnlGenerator | ( | const string & | baseCurrency, |
| const QuantLib::ext::shared_ptr< Portfolio > & | portfolio, | ||
| const QuantLib::ext::shared_ptr< HistoricalScenarioGenerator > & | hisScenGen, | ||
| const QuantLib::ext::shared_ptr< EngineData > & | engineData, | ||
| const Size | nThreads, | ||
| const Date & | today, | ||
| const QuantLib::ext::shared_ptr< ore::data::Loader > & | loader, | ||
| const QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > & | curveConfigs, | ||
| const QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > & | todaysMarketParams, | ||
| const std::string & | configuration, | ||
| const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > & | simMarketData, | ||
| const QuantLib::ext::shared_ptr< ReferenceDataManager > & | referenceData = nullptr, |
||
| const IborFallbackConfig & | iborFallbackConfig = IborFallbackConfig::defaultConfig(), |
||
| bool | dryRun = false, |
||
| const std::string & | context = "historical pnl generation" |
||
| ) |
Constructor to use a multi-threaded valuation engine
| void generateCube | ( | const QuantLib::ext::shared_ptr< ScenarioFilter > & | filter | ) |
Generate a "cube" of P&L values for the trades in the portfolio on each of the scenarios provided by the historical scenario generator. The historical scenarios will have the given filter applied.
| std::vector<QuantLib::Real> pnl | ( | const ore::data::TimePeriod & | period, |
| const std::set< std::pair< std::string, QuantLib::Size >> & | tradeIds | ||
| ) | const |
Return a vector of historical portfolio P&L values restricted to scenarios falling in period and restricted to the given tradeIds. The P&L values are calculated from the last cube generated by generateCube.
| std::vector<QuantLib::Real> pnl | ( | const ore::data::TimePeriod & | period | ) | const |
Return a vector of historical portfolio P&L values restricted to scenarios falling in period. The P&L values are calculated from the last cube generated by generateCube.
| std::vector<QuantLib::Real> pnl | ( | const std::set< std::pair< std::string, QuantLib::Size >> & | tradeIds | ) | const |
Return a vector of historical portfolio P&L values restricted to the given tradeIds. The P&L values are calculated from the last cube generated by generateCube.
| std::vector<QuantLib::Real> pnl | ( | ) | const |
Return a vector of historical portfolio P&L values for all scenarios generated by the historical scenario generator. The P&L values are calculated from the last cube generated by generateCube.
| TradePnlStore tradeLevelPnl | ( | const ore::data::TimePeriod & | period | ) | const |
Return a vector of historical trade level P&L values restricted to scenarios falling in period. The P&L values are calculated from the last cube generated by generateCube. The first dimension is time and the second dimension is tradeId.
| TradePnlStore tradeLevelPnl | ( | const std::set< std::pair< std::string, QuantLib::Size >> & | tradeIds | ) | const |
Return a vector of historical trade level P&L values restricted to the given tradeIds. The P&L values are calculated from the last cube generated by generateCube. The first dimension is time and the second dimension is tradeId.
| TradePnlStore tradeLevelPnl | ( | ) | const |
Return a vector of historical trade level P&L values for all scenarios generated by the historical scenario generator. The P&L values are calculated from the last cube generated by generateCube. The first dimension is time and the second dimension is tradeId.
| const QuantLib::ext::shared_ptr<NPVCube>& cube | ( | ) | const |
Return the last cube generated by generateCube.