Logo
Reference manual - version orea_version
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PostProcess Class Reference

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< Portfolioportfolio_
 
QuantLib::ext::shared_ptr< NettingSetManagernettingSetManager_
 
QuantLib::ext::shared_ptr< CollateralBalancescollateralBalances_
 
QuantLib::ext::shared_ptr< Marketmarket_
 
const std::string configuration_
 
QuantLib::ext::shared_ptr< NPVCubecube_
 
QuantLib::ext::shared_ptr< NPVCubecptyCube_
 
QuantLib::ext::shared_ptr< AggregationScenarioDatascenarioData_
 
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< DynamicInitialMarginCalculatordimCalculator_
 
QuantLib::ext::shared_ptr< ExposureCalculatorexposureCalculator_
 
QuantLib::ext::shared_ptr< NettedExposureCalculatornettedExposureCalculator_
 
QuantLib::ext::shared_ptr< ValueAdjustmentCalculatorcvaCalculator_
 
QuantLib::ext::shared_ptr< ValueAdjustmentCalculatorallocatedCvaCalculator_
 
QuantLib::ext::shared_ptr< CubeInterpretationcubeInterpretation_
 
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< CreditSimulationParameterscreditSimulationParameters_
 
std::vector< Real > creditMigrationDistributionGrid_
 
std::vector< Size > creditMigrationTimeSteps_
 
Matrix creditStateCorrelationMatrix_
 
QuantLib::ext::shared_ptr< CreditMigrationCalculatorcreditMigrationCalculator_
 
std::vector< Real > creditMigrationUpperBucketBounds_
 
std::vector< std::vector< Real > > creditMigrationCdf_
 
std::vector< std::vector< Real > > creditMigrationPdf_
 
bool withMporStickyDate_
 
MporCashFlowMode mporCashFlowMode_
 

Detailed Description

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:

Constructor & Destructor Documentation

◆ PostProcess()

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.

Parameters
portfolioTrade portfolio to identify e.g. netting set, maturity, break dates for each trade
nettingSetManagerNetting set manager to access CSA details for each netting set
collateralBalancesCollateral balances (VM, IM, IA)
marketMarket data object to access e.g. discounting and funding curves
configurationMarket configuration to use
cubeInput NPV Cube
scenarioDataSubset of simulated market data, index fixings and FX spot rates, associated with the NPV cube
analyticsSelection of analytics to be produced
baseCurrencyExpression currency for all results
allocationMethodMethod to be used for Exposure/XVA allocation down to trade level
cvaMarginalAllocationLimitCutoff parameter for the marginal allocation method below which we switch to equal distribution
quantileQuantile for Potential Future Exposure output
calculationTypeCollateral calculation type to be used, see class CollateralExposureHelper
dvaNameCredit curve name to be used for "our" credit risk in DVA calculations
fvaBorrowingCurveBorrowing curve name to be used in FVA calculations
fvaLendingCurveLending curve name to be used in FVA calculations
dimCalculatorDynamic Initial Margin Calculator
cubeInterpretationInterpreter for cube storage (where to find which data items)
fullInitialCollateralisationAssume t=0 collateral balance equals NPV (set to 0 if false)
cvaSpreadSensiGridCVA spread sensitivity grid
cvaSpreadSensiShiftSizeCVA spread sensitivity shift size
kvaCapitalDiscountRateown capital discounting rate for discounting expected capital for KVA
kvaAlphaalpha to adjust EEPE to give EAD for risk capital
kvaRegAdjustmentregulatory adjustment, 1/min cap requirement
kvaCapitalHurdleCost of Capital for KVA = regulatory adjustment x capital hurdle
kvaOurPdFloorOur KVA PD floor
kvaTheirPdFloorTheir KVA PD floor
kvaOurCvaRiskWeightOur KVA CVA Risk Weight
kvaTheirCvaRiskWeightTheir KVA CVA Risk Weight,
cptyCube_Input Counterparty Cube
flipViewBorrowingCurvePostfixPostfix for flipView borrowing curve for fva
flipViewLendingCurvePostfixPostfix for flipView lending curve for fva
creditSimulationParametersCredit simulation parameters
creditMigrationDistributionGridCredit simulation distribution grid
creditMigrationTimeStepsCredit simulation time steps
creditStateCorrelationMatrixCredit State correlation matrix
withMporStickyDateIf set to true, cash flows in the margin period of risk are ignored in the collateral modelling
mporCashFlowModeTreatment of cash flows over the margin period of risk

Member Function Documentation

◆ exportDimEvolution()

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