Exposure Aggregation and XVA Calculation. More...
#include <orea/aggregation/postprocess.hpp>
Public Member Functions | |
| PostProcess (const QuantLib::ext::shared_ptr< Portfolio > &portfolio, const QuantLib::ext::shared_ptr< NettingSetManager > &nettingSetManager, const QuantLib::ext::shared_ptr< CollateralBalances > &collateralBalances, const QuantLib::ext::shared_ptr< Market > &market, const std::string &configuration, const QuantLib::ext::shared_ptr< NPVCube > &cube, const QuantLib::ext::shared_ptr< AggregationScenarioData > &scenarioData, const map< string, bool > &analytics, const string &baseCurrency, const string &allocationMethod, Real cvaMarginalAllocationLimit, Real quantile=0.95, const string &calculationType="Symmetric", const string &dvaName="", const string &fvaBorrowingCurve="", const string &fvaLendingCurve="", const QuantLib::ext::shared_ptr< DynamicInitialMarginCalculator > &dimCalculator=QuantLib::ext::shared_ptr< DynamicInitialMarginCalculator >(), const QuantLib::ext::shared_ptr< CubeInterpretation > &cubeInterpretation=QuantLib::ext::shared_ptr< CubeInterpretation >(), bool fullInitialCollateralisation=false, vector< Period > cvaSpreadSensiGrid={6 *Months, 1 *Years, 3 *Years, 5 *Years, 10 *Years}, Real cvaSpreadSensiShiftSize=0.0001, Real kvaCapitalDiscountRate=0.10, Real kvaAlpha=1.4, Real kvaRegAdjustment=12.5, Real kvaCapitalHurdle=0.012, Real kvaOurPdFloor=0.03, Real kvaTheirPdFloor=0.03, Real kvaOurCvaRiskWeight=0.05, Real kvaTheirCvaRiskWeight=0.05, const QuantLib::ext::shared_ptr< NPVCube > &cptyCube_=nullptr, const string &flipViewBorrowingCurvePostfix="_BORROW", const string &flipViewLendingCurvePostfix="_LEND", const QuantLib::ext::shared_ptr< CreditSimulationParameters > &creditSimulationParameters=nullptr, const std::vector< Real > &creditMigrationDistributionGrid={}, const std::vector< Size > &creditMigrationTimeSteps={}, const Matrix &creditStateCorrelationMatrix=Matrix(), bool withMporStickyDate=false, const MporCashFlowMode mporCashFlowMode=MporCashFlowMode::Unspecified) | |
| Constructor. More... | |
| void | setDimCalculator (QuantLib::ext::shared_ptr< DynamicInitialMarginCalculator > dimCalculator) |
| const vector< Real > & | spreadSensitivityTimes () |
| const vector< Period > & | spreadSensitivityGrid () |
| const std::map< string, Size > | tradeIds () |
| Return list of Trade IDs in the portfolio. | |
| const std::map< string, Size > | nettingSetIds () |
| Return list of netting set IDs in the portfolio. | |
| const map< string, string > & | counterpartyId () |
| Return the map of counterparty Ids. | |
| const vector< Real > & | tradeEPE (const string &tradeId) |
| Return trade level Expected Positive Exposure evolution. | |
| const vector< Real > & | tradeENE (const string &tradeId) |
| Return trade level Expected Negative Exposure evolution. | |
| const vector< Real > & | tradeEE_B (const string &tradeId) |
| Return trade level Basel Expected Exposure evolution. | |
| const Real & | tradeEPE_B (const string &tradeId) |
| Return trade level Basel Expected Positive Exposure evolution. | |
| const vector< Real > & | tradeEEE_B (const string &tradeId) |
| Return trade level Effective Expected Exposure evolution. | |
| const Real & | tradeEEPE_B (const string &tradeId) |
| Return trade level Effective Expected Positive Exposure evolution. | |
| const vector< Real > & | tradePFE (const string &tradeId) |
| Return trade level Potential Future Exposure evolution. | |
| const vector< Real > & | netEPE (const string &nettingSetId) |
| Return Netting Set Expected Positive Exposure evolution. | |
| const vector< Real > & | netENE (const string &nettingSetId) |
| Return Netting Set Expected Negative Exposure evolution. | |
| const vector< Real > & | netEE_B (const string &nettingSetId) |
| Return Netting Set Basel Expected Exposure evolution. | |
| const Real & | netEPE_B (const string &nettingSetId) |
| Return Netting Set Basel Expected Positive Exposure evolution. | |
| const vector< Real > & | netEEE_B (const string &nettingSetId) |
| Return Netting Set Effective Expected Exposure evolution. | |
| const Real & | netEEPE_B (const string &nettingSetId) |
| Return Netting Set Effective Expected Positive Exposure evolution. | |
| const vector< Real > & | netPFE (const string &nettingSetId) |
| Return Netting Set Potential Future Exposure evolution. | |
| const vector< Real > & | expectedCollateral (const string &nettingSetId) |
| Return the netting set's expected collateral evolution. | |
| const vector< Real > & | colvaIncrements (const string &nettingSetId) |
| Return the netting set's expected COLVA increments through time. | |
| const vector< Real > & | collateralFloorIncrements (const string &nettingSetId) |
| Return the netting set's expected Collateral Floor increments through time. | |
| const vector< Real > & | allocatedTradeEPE (const string &tradeId) |
| Return the trade EPE, allocated down from the netting set level. | |
| const vector< Real > & | allocatedTradeENE (const string &tradeId) |
| Return trade ENE, allocated down from the netting set level. | |
| vector< Real > | netCvaHazardRateSensitivity (const string &nettingSetId) |
| Return Netting Set CVA Hazard Rate Sensitivity vector. | |
| vector< Real > | netCvaSpreadSensitivity (const string &nettingSetId) |
| Return Netting Set CVA Spread Sensitivity vector. | |
| const std::map< std::string, std::vector< QuantLib::Real > > & | netCvaSpreadSensitivity () const |
| Return Netting Set CVA Spread Sensitivity vector. | |
| Real | tradeCVA (const string &tradeId) |
| Return trade (stand-alone) CVA. | |
| Real | tradeDVA (const string &tradeId) |
| Return trade (stand-alone) DVA. | |
| Real | tradeMVA (const string &tradeId) |
| Return trade (stand-alone) MVA. | |
| Real | tradeFBA (const string &tradeId) |
| Return trade (stand-alone) FBA (Funding Benefit Adjustment) | |
| Real | tradeFCA (const string &tradeId) |
| Return trade (stand-alone) FCA (Funding Cost Adjustment) | |
| Real | tradeFBA_exOwnSP (const string &tradeId) |
| Return trade (stand-alone) FBA (Funding Benefit Adjustment) excluding own survival probability. | |
| Real | tradeFCA_exOwnSP (const string &tradeId) |
| Return trade (stand-alone) FCA (Funding Cost Adjustment) excluding own survival probability. | |
| Real | tradeFBA_exAllSP (const string &tradeId) |
| Return trade (stand-alone) FBA (Funding Benefit Adjustment) excluding both survival probabilities. | |
| Real | tradeFCA_exAllSP (const string &tradeId) |
| Return trade (stand-alone) FCA (Funding Cost Adjustment) excluding both survival probabilities. | |
| Real | allocatedTradeCVA (const string &tradeId) |
| Return allocated trade CVA (trade CVAs add up to netting set CVA) | |
| Real | allocatedTradeDVA (const string &tradeId) |
| Return allocated trade DVA (trade DVAs add up to netting set DVA) | |
| Real | nettingSetCVA (const string &nettingSetId) |
| Return netting set CVA. | |
| Real | nettingSetDVA (const string &nettingSetId) |
| Return netting set DVA. | |
| Real | nettingSetMVA (const string &nettingSetId) |
| Return netting set MVA. | |
| Real | nettingSetFBA (const string &nettingSetId) |
| Return netting set FBA. | |
| Real | nettingSetFCA (const string &nettingSetId) |
| Return netting set FCA. | |
| Real | nettingSetOurKVACCR (const string &nettingSetId) |
| Return netting set KVA-CCR. | |
| Real | nettingSetTheirKVACCR (const string &nettingSetId) |
| Return netting set KVA-CCR from counterparty perspective. | |
| Real | nettingSetOurKVACVA (const string &nettingSetId) |
| Return netting set KVA-CVA. | |
| Real | nettingSetTheirKVACVA (const string &nettingSetId) |
| Return netting set KVA-CVA from counterparty perspective. | |
| Real | nettingSetFBA_exOwnSP (const string &nettingSetId) |
| Return netting set FBA excluding own survival probability. | |
| Real | nettingSetFCA_exOwnSP (const string &nettingSetId) |
| Return netting set FCA excluding own survival probability. | |
| Real | nettingSetFBA_exAllSP (const string &nettingSetId) |
| Return netting set FBA excluding both survival probabilities. | |
| Real | nettingSetFCA_exAllSP (const string &nettingSetId) |
| Return netting set FCA excluding both survival probabilities. | |
| Real | nettingSetCOLVA (const string &nettingSetId) |
| Return netting set COLVA. | |
| Real | nettingSetCollateralFloor (const string &nettingSetId) |
| Return netting set Collateral Floor value. | |
| const QuantLib::ext::shared_ptr< NPVCube > & | cube () |
| Inspector for the input NPV cube (by trade, time, scenario) | |
| const QuantLib::ext::shared_ptr< NPVCube > & | cptyCube () |
| Inspector for the input Cpty cube (by name, time, scenario) | |
| const QuantLib::ext::shared_ptr< NPVCube > & | netCube () |
| Return the for the input NPV cube after netting and collateral (by netting set, time, scenario) | |
| void | exportDimEvolution (ore::data::Report &dimEvolutionReport) |
| Return the dynamic initial margin cube (regression approach) More... | |
| void | exportDimRegression (const std::string &nettingSet, const std::vector< Size > &timeSteps, const std::vector< QuantLib::ext::shared_ptr< ore::data::Report >> &dimRegReports) |
| Write DIM as a function of sample netting set NPV for a given time step. | |
| QuantLib::Real | cvaSpreadSensiShiftSize () |
| get the cvaSpreadSensiShiftSize | |
| const std::vector< Real > & | creditMigrationUpperBucketBounds () const |
| get the credit migration pnl distributions for each time step | |
| const std::vector< std::vector< Real > > & | creditMigrationCdf () const |
| const std::vector< std::vector< Real > > & | creditMigrationPdf () const |
Protected Member Functions | |
| QuantLib::ext::shared_ptr< vector< QuantLib::ext::shared_ptr< CollateralAccount > > > | collateralPaths (const string &nettingSetId, const QuantLib::ext::shared_ptr< NettingSetManager > &nettingSetManager, const QuantLib::ext::shared_ptr< Market > &market, const std::string &configuration, const QuantLib::ext::shared_ptr< AggregationScenarioData > &scenarioData, Size dates, Size samples, const vector< vector< Real >> &nettingSetValue, Real nettingSetValueToday, const Date &nettingSetMaturity) |
| Helper function to return the collateral account evolution for a given netting set. | |
| void | updateNettingSetKVA () |
| void | updateNettingSetCvaSensitivity () |
Protected Attributes | |
| QuantLib::ext::shared_ptr< Portfolio > | portfolio_ |
| QuantLib::ext::shared_ptr< NettingSetManager > | nettingSetManager_ |
| QuantLib::ext::shared_ptr< CollateralBalances > | collateralBalances_ |
| QuantLib::ext::shared_ptr< Market > | market_ |
| const std::string | configuration_ |
| QuantLib::ext::shared_ptr< NPVCube > | cube_ |
| QuantLib::ext::shared_ptr< NPVCube > | cptyCube_ |
| QuantLib::ext::shared_ptr< AggregationScenarioData > | scenarioData_ |
| map< string, bool > | analytics_ |
| map< string, vector< Real > > | tradeEPE_ |
| map< string, vector< Real > > | tradeENE_ |
| map< string, vector< Real > > | allocatedTradeEPE_ |
| map< string, vector< Real > > | allocatedTradeENE_ |
| map< string, vector< Real > > | netEPE_ |
| map< string, vector< Real > > | netENE_ |
| map< string, Real > | ourNettingSetKVACCR_ |
| map< string, Real > | theirNettingSetKVACCR_ |
| map< string, Real > | ourNettingSetKVACVA_ |
| map< string, Real > | theirNettingSetKVACVA_ |
| map< string, vector< Real > > | netCvaSpreadSensi_ |
| map< string, vector< Real > > | netCvaHazardRateSensi_ |
| string | baseCurrency_ |
| Real | quantile_ |
| CollateralExposureHelper::CalculationType | calcType_ |
| string | dvaName_ |
| string | fvaBorrowingCurve_ |
| string | fvaLendingCurve_ |
| QuantLib::ext::shared_ptr< DynamicInitialMarginCalculator > | dimCalculator_ |
| QuantLib::ext::shared_ptr< ExposureCalculator > | exposureCalculator_ |
| QuantLib::ext::shared_ptr< NettedExposureCalculator > | nettedExposureCalculator_ |
| QuantLib::ext::shared_ptr< ValueAdjustmentCalculator > | cvaCalculator_ |
| QuantLib::ext::shared_ptr< ValueAdjustmentCalculator > | allocatedCvaCalculator_ |
| QuantLib::ext::shared_ptr< CubeInterpretation > | cubeInterpretation_ |
| bool | fullInitialCollateralisation_ |
| vector< Period > | cvaSpreadSensiGrid_ |
| vector< Time > | cvaSpreadSensiTimes_ |
| Real | cvaSpreadSensiShiftSize_ |
| Real | kvaCapitalDiscountRate_ |
| Real | kvaAlpha_ |
| Real | kvaRegAdjustment_ |
| Real | kvaCapitalHurdle_ |
| Real | kvaOurPdFloor_ |
| Real | kvaTheirPdFloor_ |
| Real | kvaOurCvaRiskWeight_ |
| Real | kvaTheirCvaRiskWeight_ |
| QuantLib::ext::shared_ptr< CreditSimulationParameters > | creditSimulationParameters_ |
| std::vector< Real > | creditMigrationDistributionGrid_ |
| std::vector< Size > | creditMigrationTimeSteps_ |
| Matrix | creditStateCorrelationMatrix_ |
| QuantLib::ext::shared_ptr< CreditMigrationCalculator > | creditMigrationCalculator_ |
| std::vector< Real > | creditMigrationUpperBucketBounds_ |
| std::vector< std::vector< Real > > | creditMigrationCdf_ |
| std::vector< std::vector< Real > > | creditMigrationPdf_ |
| bool | withMporStickyDate_ |
| MporCashFlowMode | mporCashFlowMode_ |
Exposure Aggregation and XVA Calculation.
This class aggregates NPV cube data, computes exposure statistics and various XVAs, all at trade and netting set level:
1) Exposures
2) Dynamic Initial Margin via regression
3) XVAs:
4) Allocation from netting set to trade level such that allocated contributions add up to the netting set
All analytics are precomputed when the class constructor is called. A number of inspectors described below then return the individual analytics results.
Note:
| PostProcess | ( | const QuantLib::ext::shared_ptr< Portfolio > & | portfolio, |
| const QuantLib::ext::shared_ptr< NettingSetManager > & | nettingSetManager, | ||
| const QuantLib::ext::shared_ptr< CollateralBalances > & | collateralBalances, | ||
| const QuantLib::ext::shared_ptr< Market > & | market, | ||
| const std::string & | configuration, | ||
| const QuantLib::ext::shared_ptr< NPVCube > & | cube, | ||
| const QuantLib::ext::shared_ptr< AggregationScenarioData > & | scenarioData, | ||
| const map< string, bool > & | analytics, | ||
| const string & | baseCurrency, | ||
| const string & | allocationMethod, | ||
| Real | cvaMarginalAllocationLimit, | ||
| Real | quantile = 0.95, |
||
| const string & | calculationType = "Symmetric", |
||
| const string & | dvaName = "", |
||
| const string & | fvaBorrowingCurve = "", |
||
| const string & | fvaLendingCurve = "", |
||
| const QuantLib::ext::shared_ptr< DynamicInitialMarginCalculator > & | dimCalculator = QuantLib::ext::shared_ptr< DynamicInitialMarginCalculator >(), |
||
| const QuantLib::ext::shared_ptr< CubeInterpretation > & | cubeInterpretation = QuantLib::ext::shared_ptr< CubeInterpretation >(), |
||
| bool | fullInitialCollateralisation = false, |
||
| vector< Period > | cvaSpreadSensiGrid = {6 *Months, 1 *Years, 3 *Years, 5 *Years, 10 *Years}, |
||
| Real | cvaSpreadSensiShiftSize = 0.0001, |
||
| Real | kvaCapitalDiscountRate = 0.10, |
||
| Real | kvaAlpha = 1.4, |
||
| Real | kvaRegAdjustment = 12.5, |
||
| Real | kvaCapitalHurdle = 0.012, |
||
| Real | kvaOurPdFloor = 0.03, |
||
| Real | kvaTheirPdFloor = 0.03, |
||
| Real | kvaOurCvaRiskWeight = 0.05, |
||
| Real | kvaTheirCvaRiskWeight = 0.05, |
||
| const QuantLib::ext::shared_ptr< NPVCube > & | cptyCube_ = nullptr, |
||
| const string & | flipViewBorrowingCurvePostfix = "_BORROW", |
||
| const string & | flipViewLendingCurvePostfix = "_LEND", |
||
| const QuantLib::ext::shared_ptr< CreditSimulationParameters > & | creditSimulationParameters = nullptr, |
||
| const std::vector< Real > & | creditMigrationDistributionGrid = {}, |
||
| const std::vector< Size > & | creditMigrationTimeSteps = {}, |
||
| const Matrix & | creditStateCorrelationMatrix = Matrix(), |
||
| bool | withMporStickyDate = false, |
||
| const MporCashFlowMode | mporCashFlowMode = MporCashFlowMode::Unspecified |
||
| ) |
Constructor.
| portfolio | Trade portfolio to identify e.g. netting set, maturity, break dates for each trade |
| nettingSetManager | Netting set manager to access CSA details for each netting set |
| collateralBalances | Collateral balances (VM, IM, IA) |
| market | Market data object to access e.g. discounting and funding curves |
| configuration | Market configuration to use |
| cube | Input NPV Cube |
| scenarioData | Subset of simulated market data, index fixings and FX spot rates, associated with the NPV cube |
| analytics | Selection of analytics to be produced |
| baseCurrency | Expression currency for all results |
| allocationMethod | Method to be used for Exposure/XVA allocation down to trade level |
| cvaMarginalAllocationLimit | Cutoff parameter for the marginal allocation method below which we switch to equal distribution |
| quantile | Quantile for Potential Future Exposure output |
| calculationType | Collateral calculation type to be used, see class CollateralExposureHelper |
| dvaName | Credit curve name to be used for "our" credit risk in DVA calculations |
| fvaBorrowingCurve | Borrowing curve name to be used in FVA calculations |
| fvaLendingCurve | Lending curve name to be used in FVA calculations |
| dimCalculator | Dynamic Initial Margin Calculator |
| cubeInterpretation | Interpreter for cube storage (where to find which data items) |
| fullInitialCollateralisation | Assume t=0 collateral balance equals NPV (set to 0 if false) |
| cvaSpreadSensiGrid | CVA spread sensitivity grid |
| cvaSpreadSensiShiftSize | CVA spread sensitivity shift size |
| kvaCapitalDiscountRate | own capital discounting rate for discounting expected capital for KVA |
| kvaAlpha | alpha to adjust EEPE to give EAD for risk capital |
| kvaRegAdjustment | regulatory adjustment, 1/min cap requirement |
| kvaCapitalHurdle | Cost of Capital for KVA = regulatory adjustment x capital hurdle |
| kvaOurPdFloor | Our KVA PD floor |
| kvaTheirPdFloor | Their KVA PD floor |
| kvaOurCvaRiskWeight | Our KVA CVA Risk Weight |
| kvaTheirCvaRiskWeight | Their KVA CVA Risk Weight, |
| cptyCube_ | Input Counterparty Cube |
| flipViewBorrowingCurvePostfix | Postfix for flipView borrowing curve for fva |
| flipViewLendingCurvePostfix | Postfix for flipView lending curve for fva |
| creditSimulationParameters | Credit simulation parameters |
| creditMigrationDistributionGrid | Credit simulation distribution grid |
| creditMigrationTimeSteps | Credit simulation time steps |
| creditStateCorrelationMatrix | Credit State correlation matrix |
| withMporStickyDate | If set to true, cash flows in the margin period of risk are ignored in the collateral modelling |
| mporCashFlowMode | Treatment of cash flows over the margin period of risk |
| void exportDimEvolution | ( | ore::data::Report & | dimEvolutionReport | ) |
Return the dynamic initial margin cube (regression approach)
Write average (over samples) DIM evolution through time for all netting sets