40#include <ql/time/date.hpp>
42#include <ql/shared_ptr.hpp>
97 const QuantLib::ext::shared_ptr<Portfolio>& portfolio,
99 const QuantLib::ext::shared_ptr<NettingSetManager>& nettingSetManager,
101 const QuantLib::ext::shared_ptr<CollateralBalances>& collateralBalances,
103 const QuantLib::ext::shared_ptr<Market>& market,
105 const std::string& configuration,
107 const QuantLib::ext::shared_ptr<NPVCube>&
cube,
109 const QuantLib::ext::shared_ptr<AggregationScenarioData>& scenarioData,
111 const map<string, bool>& analytics,
113 const string& baseCurrency,
115 const string& allocationMethod,
117 Real cvaMarginalAllocationLimit,
119 Real quantile = 0.95,
121 const string& calculationType =
"Symmetric",
123 const string& dvaName =
"",
125 const string& fvaBorrowingCurve =
"",
127 const string& fvaLendingCurve =
"",
129 const QuantLib::ext::shared_ptr<DynamicInitialMarginCalculator>& dimCalculator =
130 QuantLib::ext::shared_ptr<DynamicInitialMarginCalculator>(),
132 const QuantLib::ext::shared_ptr<CubeInterpretation>& cubeInterpretation = QuantLib::ext::shared_ptr<CubeInterpretation>(),
134 bool fullInitialCollateralisation =
false,
136 vector<Period> cvaSpreadSensiGrid = {6 * Months, 1 * Years, 3 * Years, 5 * Years, 10 * Years},
140 Real kvaCapitalDiscountRate = 0.10,
144 Real kvaRegAdjustment = 12.5,
146 Real kvaCapitalHurdle = 0.012,
148 Real kvaOurPdFloor = 0.03,
150 Real kvaTheirPdFloor = 0.03,
152 Real kvaOurCvaRiskWeight = 0.05,
154 Real kvaTheirCvaRiskWeight = 0.05,
156 const QuantLib::ext::shared_ptr<NPVCube>&
cptyCube_ =
nullptr,
158 const string& flipViewBorrowingCurvePostfix =
"_BORROW",
160 const string& flipViewLendingCurvePostfix =
"_LEND",
162 const QuantLib::ext::shared_ptr<CreditSimulationParameters>& creditSimulationParameters =
nullptr,
164 const std::vector<Real>& creditMigrationDistributionGrid = {},
166 const std::vector<Size>& creditMigrationTimeSteps = {},
168 const Matrix& creditStateCorrelationMatrix = Matrix(),
170 bool withMporStickyDate =
false,
174 void setDimCalculator(QuantLib::ext::shared_ptr<DynamicInitialMarginCalculator> dimCalculator) {
183 return cube()->idsAndIndexes();
187 return netCube()->idsAndIndexes();
193 const vector<Real>&
tradeEPE(
const string& tradeId);
195 const vector<Real>&
tradeENE(
const string& tradeId);
197 const vector<Real>&
tradeEE_B(
const string& tradeId);
199 const Real&
tradeEPE_B(
const string& tradeId);
201 const vector<Real>&
tradeEEE_B(
const string& tradeId);
205 const vector<Real>&
tradePFE(
const string& tradeId);
209 const vector<Real>&
netEPE(
const string& nettingSetId);
211 const vector<Real>&
netENE(
const string& nettingSetId);
213 const vector<Real>&
netEE_B(
const string& nettingSetId);
215 const Real&
netEPE_B(
const string& nettingSetId);
217 const vector<Real>&
netEEE_B(
const string& nettingSetId);
219 const Real&
netEEPE_B(
const string& nettingSetId);
221 const vector<Real>&
netPFE(
const string& nettingSetId);
244 Real
tradeCVA(
const string& tradeId);
246 Real
tradeDVA(
const string& tradeId);
248 Real
tradeMVA(
const string& tradeId);
250 Real
tradeFBA(
const string& tradeId);
252 Real
tradeFCA(
const string& tradeId);
297 const QuantLib::ext::shared_ptr<NPVCube>&
cube() {
return cube_; }
307 void exportDimRegression(
const std::string& nettingSet,
const std::vector<Size>& timeSteps,
308 const std::vector<QuantLib::ext::shared_ptr<ore::data::Report>>& dimRegReports);
320 QuantLib::ext::shared_ptr<vector<QuantLib::ext::shared_ptr<CollateralAccount>>>
321 collateralPaths(
const string& nettingSetId,
const QuantLib::ext::shared_ptr<NettingSetManager>& nettingSetManager,
322 const QuantLib::ext::shared_ptr<Market>& market,
const std::string& configuration,
323 const QuantLib::ext::shared_ptr<AggregationScenarioData>& scenarioData, Size dates, Size samples,
324 const vector<vector<Real>>& nettingSetValue, Real nettingSetValueToday,
325 const Date& nettingSetMaturity);
335 QuantLib::ext::shared_ptr<NPVCube>
cube_;
this class holds data associated to scenarios
Exposure Aggregation and XVA Calculation.
const Real & tradeEEPE_B(const string &tradeId)
Return trade level Effective Expected Positive Exposure evolution.
Real tradeFBA_exAllSP(const string &tradeId)
Return trade (stand-alone) FBA (Funding Benefit Adjustment) excluding both survival probabilities.
Real tradeFCA(const string &tradeId)
Return trade (stand-alone) FCA (Funding Cost Adjustment)
const vector< Real > & tradeEEE_B(const string &tradeId)
Return trade level Effective Expected Exposure evolution.
map< string, Real > theirNettingSetKVACVA_
const std::string configuration_
Real nettingSetOurKVACVA(const string &nettingSetId)
Return netting set KVA-CVA.
Real kvaCapitalDiscountRate_
QuantLib::ext::shared_ptr< Market > market_
QuantLib::Real cvaSpreadSensiShiftSize()
get the cvaSpreadSensiShiftSize
Real nettingSetCollateralFloor(const string &nettingSetId)
Return netting set Collateral Floor value.
const std::map< string, Size > tradeIds()
Return list of Trade IDs in the portfolio.
const vector< Real > & tradeENE(const string &tradeId)
Return trade level Expected Negative Exposure evolution.
string fvaBorrowingCurve_
const vector< Period > & spreadSensitivityGrid()
QuantLib::ext::shared_ptr< ExposureCalculator > exposureCalculator_
Real nettingSetFCA_exOwnSP(const string &nettingSetId)
Return netting set FCA excluding own survival probability.
const vector< Real > & colvaIncrements(const string &nettingSetId)
Return the netting set's expected COLVA increments through time.
const vector< Real > & netEEE_B(const string &nettingSetId)
Return Netting Set Effective Expected Exposure evolution.
map< string, vector< Real > > netEPE_
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.
const vector< Real > & netEPE(const string &nettingSetId)
Return Netting Set Expected Positive Exposure evolution.
Real cvaSpreadSensiShiftSize_
Real tradeFBA(const string &tradeId)
Return trade (stand-alone) FBA (Funding Benefit Adjustment)
const vector< Real > & netPFE(const string &nettingSetId)
Return Netting Set Potential Future Exposure evolution.
const map< string, string > & counterpartyId()
Return the map of counterparty Ids.
Real nettingSetCVA(const string &nettingSetId)
Return netting set CVA.
const vector< Real > & netEE_B(const string &nettingSetId)
Return Netting Set Basel Expected Exposure evolution.
bool fullInitialCollateralisation_
Real tradeFBA_exOwnSP(const string &tradeId)
Return trade (stand-alone) FBA (Funding Benefit Adjustment) excluding own survival probability.
Real nettingSetMVA(const string &nettingSetId)
Return netting set MVA.
void setDimCalculator(QuantLib::ext::shared_ptr< DynamicInitialMarginCalculator > dimCalculator)
std::vector< std::vector< Real > > creditMigrationCdf_
map< string, vector< Real > > netCvaSpreadSensi_
const vector< Real > & allocatedTradeEPE(const string &tradeId)
Return the trade EPE, allocated down from the netting set level.
Real nettingSetFBA_exOwnSP(const string &nettingSetId)
Return netting set FBA excluding own survival probability.
const QuantLib::ext::shared_ptr< NPVCube > & cptyCube()
Inspector for the input Cpty cube (by name, time, scenario)
const vector< Real > & expectedCollateral(const string &nettingSetId)
Return the netting set's expected collateral evolution.
Real nettingSetTheirKVACVA(const string &nettingSetId)
Return netting set KVA-CVA from counterparty perspective.
Real nettingSetFCA(const string &nettingSetId)
Return netting set FCA.
const vector< Real > & spreadSensitivityTimes()
const vector< Real > & tradeEPE(const string &tradeId)
Return trade level Expected Positive Exposure evolution.
vector< Period > cvaSpreadSensiGrid_
const Real & tradeEPE_B(const string &tradeId)
Return trade level Basel Expected Positive Exposure evolution.
Real nettingSetFBA(const string &nettingSetId)
Return netting set FBA.
Real tradeMVA(const string &tradeId)
Return trade (stand-alone) MVA.
void updateNettingSetKVA()
const Real & netEEPE_B(const string &nettingSetId)
Return Netting Set Effective Expected Positive Exposure evolution.
vector< Real > netCvaHazardRateSensitivity(const string &nettingSetId)
Return Netting Set CVA Hazard Rate Sensitivity vector.
map< string, bool > analytics_
const QuantLib::ext::shared_ptr< NPVCube > & cube()
Inspector for the input NPV cube (by trade, time, scenario)
map< string, vector< Real > > allocatedTradeEPE_
map< string, vector< Real > > tradeEPE_
QuantLib::ext::shared_ptr< ValueAdjustmentCalculator > allocatedCvaCalculator_
Real nettingSetCOLVA(const string &nettingSetId)
Return netting set COLVA.
map< string, vector< Real > > allocatedTradeENE_
QuantLib::ext::shared_ptr< Portfolio > portfolio_
vector< Time > cvaSpreadSensiTimes_
QuantLib::ext::shared_ptr< NettedExposureCalculator > nettedExposureCalculator_
const std::map< string, Size > nettingSetIds()
Return list of netting set IDs in the portfolio.
const vector< Real > & tradePFE(const string &tradeId)
Return trade level Potential Future Exposure evolution.
void updateNettingSetCvaSensitivity()
const QuantLib::ext::shared_ptr< NPVCube > & netCube()
Return the for the input NPV cube after netting and collateral (by netting set, time,...
QuantLib::ext::shared_ptr< AggregationScenarioData > scenarioData_
Real tradeCVA(const string &tradeId)
Return trade (stand-alone) CVA.
QuantLib::ext::shared_ptr< CubeInterpretation > cubeInterpretation_
map< string, Real > ourNettingSetKVACCR_
map< string, vector< Real > > tradeENE_
map< string, vector< Real > > netENE_
Real allocatedTradeDVA(const string &tradeId)
Return allocated trade DVA (trade DVAs add up to netting set DVA)
const std::vector< Real > & creditMigrationUpperBucketBounds() const
get the credit migration pnl distributions for each time step
std::vector< Size > creditMigrationTimeSteps_
QuantLib::ext::shared_ptr< DynamicInitialMarginCalculator > dimCalculator_
CollateralExposureHelper::CalculationType calcType_
Real tradeFCA_exAllSP(const string &tradeId)
Return trade (stand-alone) FCA (Funding Cost Adjustment) excluding both survival probabilities.
const vector< Real > & allocatedTradeENE(const string &tradeId)
Return trade ENE, allocated down from the netting set level.
std::vector< Real > creditMigrationUpperBucketBounds_
QuantLib::ext::shared_ptr< CollateralBalances > collateralBalances_
Real allocatedTradeCVA(const string &tradeId)
Return allocated trade CVA (trade CVAs add up to netting set CVA)
Real nettingSetDVA(const string &nettingSetId)
Return netting set DVA.
Real tradeFCA_exOwnSP(const string &tradeId)
Return trade (stand-alone) FCA (Funding Cost Adjustment) excluding own survival probability.
QuantLib::ext::shared_ptr< CreditSimulationParameters > creditSimulationParameters_
MporCashFlowMode mporCashFlowMode_
Matrix creditStateCorrelationMatrix_
QuantLib::ext::shared_ptr< NPVCube > cptyCube_
Real nettingSetOurKVACCR(const string &nettingSetId)
Return netting set KVA-CCR.
QuantLib::ext::shared_ptr< NettingSetManager > nettingSetManager_
const std::vector< std::vector< Real > > & creditMigrationPdf() const
Real kvaTheirCvaRiskWeight_
std::vector< Real > creditMigrationDistributionGrid_
Real nettingSetFBA_exAllSP(const string &nettingSetId)
Return netting set FBA excluding both survival probabilities.
map< string, Real > ourNettingSetKVACVA_
Real kvaOurCvaRiskWeight_
map< string, Real > theirNettingSetKVACCR_
QuantLib::ext::shared_ptr< CreditMigrationCalculator > creditMigrationCalculator_
void exportDimEvolution(ore::data::Report &dimEvolutionReport)
Return the dynamic initial margin cube (regression approach)
Real tradeDVA(const string &tradeId)
Return trade (stand-alone) DVA.
const std::vector< std::vector< Real > > & creditMigrationCdf() const
Real nettingSetFCA_exAllSP(const string &nettingSetId)
Return netting set FCA excluding both survival probabilities.
const vector< Real > & netENE(const string &nettingSetId)
Return Netting Set Expected Negative Exposure evolution.
map< string, vector< Real > > netCvaHazardRateSensi_
const std::map< std::string, std::vector< QuantLib::Real > > & netCvaSpreadSensitivity() const
Return Netting Set CVA Spread Sensitivity vector.
std::vector< std::vector< Real > > creditMigrationPdf_
const vector< Real > & tradeEE_B(const string &tradeId)
Return trade level Basel Expected Exposure evolution.
QuantLib::ext::shared_ptr< NPVCube > cube_
const vector< Real > & collateralFloorIncrements(const string &nettingSetId)
Return the netting set's expected Collateral Floor increments through time.
QuantLib::ext::shared_ptr< ValueAdjustmentCalculator > cvaCalculator_
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.
Real nettingSetTheirKVACCR(const string &nettingSetId)
Return netting set KVA-CCR from counterparty perspective.
const Real & netEPE_B(const string &nettingSetId)
Return Netting Set Basel Expected Positive Exposure evolution.
Collateral Exposure Helper Functions (stored in base currency)
class describing the layout of an npv cube and aggregation scenario data
Dynamic Initial Margin calculator base class.
A cube implementation that stores the cube in memory.
CVA calculator base class.