29#include <ql/errors.hpp>
30#include <ql/time/calendars/weekendsonly.hpp>
32#include <ql/math/distributions/normaldistribution.hpp>
33#include <ql/math/generallinearleastsquares.hpp>
34#include <ql/math/kernelfunctions.hpp>
35#include <ql/methods/montecarlo/lsmbasissystem.hpp>
36#include <ql/time/daycounters/actualactual.hpp>
41#include <boost/range/adaptors.hpp>
42#include <boost/accumulators/accumulators.hpp>
43#include <boost/accumulators/statistics/error_of_mean.hpp>
44#include <boost/accumulators/statistics/mean.hpp>
45#include <boost/accumulators/statistics/stats.hpp>
50using namespace boost::accumulators;
56 const QuantLib::ext::shared_ptr<Portfolio>& portfolio,
const QuantLib::ext::shared_ptr<NettingSetManager>& nettingSetManager,
57 const QuantLib::ext::shared_ptr<CollateralBalances>& collateralBalances,
58 const QuantLib::ext::shared_ptr<Market>& market,
const std::string& configuration,
const QuantLib::ext::shared_ptr<NPVCube>& cube,
59 const QuantLib::ext::shared_ptr<AggregationScenarioData>& scenarioData,
const map<string, bool>& analytics,
60 const string& baseCurrency,
const string& allocMethod, Real marginalAllocationLimit, Real quantile,
61 const string& calculationType,
const string& dvaName,
const string& fvaBorrowingCurve,
62 const string& fvaLendingCurve,
const QuantLib::ext::shared_ptr<DynamicInitialMarginCalculator>& dimCalculator,
63 const QuantLib::ext::shared_ptr<CubeInterpretation>& cubeInterpretation,
bool fullInitialCollateralisation,
64 vector<Period> cvaSensiGrid, Real cvaSensiShiftSize, Real kvaCapitalDiscountRate, Real kvaAlpha,
65 Real kvaRegAdjustment, Real kvaCapitalHurdle, Real kvaOurPdFloor, Real kvaTheirPdFloor, Real kvaOurCvaRiskWeight,
66 Real kvaTheirCvaRiskWeight,
const QuantLib::ext::shared_ptr<NPVCube>& cptyCube,
const string& flipViewBorrowingCurvePostfix,
67 const string& flipViewLendingCurvePostfix,
68 const QuantLib::ext::shared_ptr<CreditSimulationParameters>& creditSimulationParameters,
69 const std::vector<Real>& creditMigrationDistributionGrid,
const std::vector<Size>& creditMigrationTimeSteps,
70 const Matrix& creditStateCorrelationMatrix,
bool withMporStickyDate,
MporCashFlowMode mporCashFlowMode)
71: portfolio_(portfolio), nettingSetManager_(nettingSetManager), collateralBalances_(collateralBalances),
72 market_(market), configuration_(configuration),
73 cube_(cube), cptyCube_(cptyCube), scenarioData_(scenarioData), analytics_(analytics), baseCurrency_(baseCurrency),
75 fvaBorrowingCurve_(fvaBorrowingCurve), fvaLendingCurve_(fvaLendingCurve), dimCalculator_(dimCalculator),
76 cubeInterpretation_(cubeInterpretation), fullInitialCollateralisation_(fullInitialCollateralisation),
77 cvaSpreadSensiGrid_(cvaSensiGrid), cvaSpreadSensiShiftSize_(cvaSensiShiftSize),
78 kvaCapitalDiscountRate_(kvaCapitalDiscountRate), kvaAlpha_(kvaAlpha), kvaRegAdjustment_(kvaRegAdjustment),
79 kvaCapitalHurdle_(kvaCapitalHurdle), kvaOurPdFloor_(kvaOurPdFloor), kvaTheirPdFloor_(kvaTheirPdFloor),
80 kvaOurCvaRiskWeight_(kvaOurCvaRiskWeight), kvaTheirCvaRiskWeight_(kvaTheirCvaRiskWeight),
81 creditSimulationParameters_(creditSimulationParameters),
82 creditMigrationDistributionGrid_(creditMigrationDistributionGrid),
83 creditMigrationTimeSteps_(creditMigrationTimeSteps), creditStateCorrelationMatrix_(creditStateCorrelationMatrix),
84 withMporStickyDate_(withMporStickyDate), mporCashFlowMode_(mporCashFlowMode) {
86 QL_REQUIRE(
cubeInterpretation_ !=
nullptr,
"PostProcess: cubeInterpretation is not given.");
93 "PostProcess: MporMode StickyDate supports only MporCashFlowMode NonePay");
95 "PostProcess: If cube does not hold any mpor flows and MporMode is set to ActualDate, then "
96 "MporCashFlowMode must "
101 LOG(
"cube storage is regular: " << isRegularCubeStorage);
102 LOG(
"cube dates: " <<
cube->dates().size());
104 QL_REQUIRE(marginalAllocationLimit > 0.0,
"positive allocationLimit expected");
107 QL_REQUIRE(portfolio->size() ==
cube_->idsAndIndexes().size(),
108 "PostProcess::PostProcess(): portfolio size ("
109 << portfolio->size() <<
") does not match cube trade size (" <<
cube_->idsAndIndexes().size() <<
")");
111 auto portfolioIt = portfolio->trades().begin();
112 auto cubeIdIt =
cube_->idsAndIndexes().begin();
113 for (
size_t i = 0; i < portfolio->size(); i++, portfolioIt++, cubeIdIt++) {
114 const std::string& portfolioTradeId = portfolioIt->first;
115 const std::string& cubeTradeId = cubeIdIt->first;
116 QL_REQUIRE(portfolioTradeId == cubeTradeId,
"PostProcess::PostProcess(): portfolio trade #"
117 << i <<
" (id=" << portfolioTradeId
118 <<
") does not match cube trade id (" << cubeTradeId);
122 QL_REQUIRE(
cptyCube_,
"cptyCube cannot be null when dynamicCredit is ON");
124 auto cptyIds = portfolio->counterparties();
126 QL_REQUIRE(cptyIds.size() ==
cptyCube_->idsAndIndexes().size(),
127 "PostProcess::PostProcess(): portfolio counterparty size ("
128 << cptyIds.size() <<
") does not match cpty cube trade size ("
129 <<
cptyCube_->idsAndIndexes().size() <<
")");
131 auto cptyIt = cptyIds.begin();
132 cubeIdIt =
cptyCube_->idsAndIndexes().begin();
133 for (
size_t i = 0; i < cptyIds.size(); ++i, ++cptyIt, ++cubeIdIt) {
135 const std::string& cubeTradeId = cubeIdIt->first;
136 QL_REQUIRE(
counterpartyId == cubeTradeId,
"PostProcess::PostProcess(): portfolio counterparty #"
138 <<
") does not match cube name id (" << cubeTradeId);
149 LOG(
"Compute netting set NPVs as of today and netting set maturity");
151 Date today = market->asofDate();
152 LOG(
"AsOfDate = " << QuantLib::io::iso_date(today));
175 QuantLib::ext::make_shared<ExposureCalculator>(
211 cvaCalculator_ = QuantLib::ext::make_shared<DynamicCreditXvaCalculator>(
220 flipViewBorrowingCurvePostfix, flipViewLendingCurvePostfix);
222 cvaCalculator_ = QuantLib::ext::make_shared<StaticCreditXvaCalculator>(
231 flipViewBorrowingCurvePostfix, flipViewLendingCurvePostfix);
238 QuantLib::ext::shared_ptr<ExposureAllocator> exposureAllocator;
240 DLOG(
"Marginal Calculation handled in NettedExposureCalculator");
243 exposureAllocator = QuantLib::ext::make_shared<RelativeFairValueNetExposureAllocator>(
250 exposureAllocator = QuantLib::ext::make_shared<RelativeFairValueGrossExposureAllocator>(
257 exposureAllocator = QuantLib::ext::make_shared<RelativeXvaExposureAllocator>(
266 exposureAllocator = QuantLib::ext::make_shared<NoneExposureAllocator>(
270 QL_FAIL(
"allocationMethod " << allocationMethod <<
" not available");
271 if(exposureAllocator)
272 exposureAllocator->build();
284 flipViewLendingCurvePostfix);
292 flipViewLendingCurvePostfix);
299 for (
const auto& [tradeId,_]:
tradeIds()) {
349 LOG(
"Update netting set KVA");
351 vector<Date> dateVector =
cube_->dates();
352 Size dates = dateVector.size();
353 Date today =
market_->asofDate();
355 DayCounter dc = ActualActual(ActualActual::ISDA);
365 LOG(
"KVA for netting set " << nettingSetId);
368 vector<Real> epe =
netEPE_[nettingSetId];
369 vector<Real> ene =
netENE_[nettingSetId];
373 Handle<DefaultProbabilityTermStructure> cvaDts =
market_->defaultCurve(cid,
configuration_)->curve();
374 QL_REQUIRE(!cvaDts.empty(),
"Default curve missing for counterparty " << cid);
376 Real PD1 = std::max(cvaDts->defaultProbability(today + 1 * Years), 0.000000000001);
377 Real LGD1 = (1 - cvaRR);
380 Handle<DefaultProbabilityTermStructure> dvaDts;
389 PD2 = std::max(dvaDts->defaultProbability(today + 1 * Years), 0.000000000001);
391 ALOG(
"dvaName not specified, own PD set to zero for their KVA calculation");
393 Real LGD2 = (1 - dvaRR);
396 Real rho1 = 0.12 * (1 - std::exp(-50 * PD1)) / (1 - std::exp(-50)) +
397 0.24 * (1 - (1 - std::exp(-50 * PD1)) / (1 - std::exp(-50)));
398 Real rho2 = 0.12 * (1 - std::exp(-50 * PD2)) / (1 - std::exp(-50)) +
399 0.24 * (1 - (1 - std::exp(-50 * PD2)) / (1 - std::exp(-50)));
403 InverseCumulativeNormal icn;
404 CumulativeNormalDistribution cnd;
405 Real PD99_1 = cnd((icn(PD1) + std::sqrt(rho1) * icn(0.999)) / (std::sqrt(1 - rho1))) - PD1;
406 Real PD99_2 = cnd((icn(PD2) + std::sqrt(rho2) * icn(0.999)) / (std::sqrt(1 - rho2))) - PD2;
413 Real kvaMatAdjB1 = std::pow((0.11852 - 0.05478 * std::log(PD1)), 2.0);
414 Real kvaMatAdjB2 = std::pow((0.11852 - 0.05478 * std::log(PD2)), 2.0);
416 DLOG(
"Our KVA-CCR " << nettingSetId <<
": PD=" << PD1);
417 DLOG(
"Our KVA-CCR " << nettingSetId <<
": LGD=" << LGD1);
418 DLOG(
"Our KVA-CCR " << nettingSetId <<
": rho=" << rho1);
419 DLOG(
"Our KVA-CCR " << nettingSetId <<
": PD99=" << PD99_1);
421 DLOG(
"Our KVA-CCR " << nettingSetId <<
": Floored PD99=" << kva99PD1);
422 DLOG(
"Our KVA-CCR " << nettingSetId <<
": B(PD)=" << kvaMatAdjB1);
424 DLOG(
"Their KVA-CCR " << nettingSetId <<
": PD=" << PD2);
425 DLOG(
"Their KVA-CCR " << nettingSetId <<
": LGD=" << LGD2);
426 DLOG(
"Their KVA-CCR " << nettingSetId <<
": rho=" << rho2);
427 DLOG(
"Their KVA-CCR " << nettingSetId <<
": PD99=" << PD99_2);
429 DLOG(
"Their KVA-CCR " << nettingSetId <<
": Floored PD99=" << kva99PD2);
430 DLOG(
"Their KVA-CCR " << nettingSetId <<
": B(PD)=" << kvaMatAdjB2);
432 for (Size j = 0; j < dates; ++j) {
433 Date d0 = j == 0 ? today :
cube_->dates()[j - 1];
434 Date d1 =
cube_->dates()[j];
441 Real eee_kva_1 = 0.0, eee_kva_2 = 0.0;
442 Real effMatNumer1 = 0.0, effMatNumer2 = 0.0;
443 Real effMatDenom1 = 0.0, effMatDenom2 = 0.0;
444 Real eepe_kva_1 = 0, eepe_kva_2 = 0.0;
445 Size kmax = j,
count = 0;
447 while (dateVector[kmax] < dateVector[j] + 1 * Years + 4 * Days && kmax < dates - 1)
449 Real sumdt = 0.0, eee1_b = 0.0, eee2_b = 0.0;
450 for (Size k = j; k < dates; ++k) {
451 Date d2 =
cube_->dates()[k];
452 Date prevDate = k == 0 ? today : dateVector[k - 1];
454 eee_kva_1 = std::max(eee_kva_1, epe[k + 1]);
455 eee_kva_2 = std::max(eee_kva_2, ene[k + 1]);
458 if (dc.yearFraction(d1, d2) > 1.0) {
459 effMatNumer1 += epe[k + 1] * dc.yearFraction(prevDate, d2);
460 effMatNumer2 += ene[k + 1] * dc.yearFraction(prevDate, d2);
462 if (dc.yearFraction(d1, d2) <= 1.0) {
463 effMatDenom1 += eee_kva_1 * dc.yearFraction(prevDate, d2);
464 effMatDenom2 += eee_kva_2 * dc.yearFraction(prevDate, d2);
468 Real dt = dc.yearFraction(
cube_->dates()[k],
cube_->dates()[k + 1]);
470 Real epe_b = epe[k + 1] / discountCurve->discount(dateVector[k]);
471 Real ene_b = ene[k + 1] / discountCurve->discount(dateVector[k]);
472 eee1_b = std::max(epe_b, eee1_b);
473 eee2_b = std::max(ene_b, eee2_b);
474 eepe_kva_1 += eee1_b * dt;
475 eepe_kva_2 += eee2_b * dt;
481 eepe_kva_1 =
count > 0 ? eepe_kva_1 / sumdt : 0.0;
482 eepe_kva_2 =
count > 0 ? eepe_kva_2 / sumdt : 0.0;
486 Real kvaNWMaturity1 = std::min(1.0 + (effMatDenom1 == 0.0 ? 0.0 : effMatNumer1 / effMatDenom1), 5.0);
487 Real kvaNWMaturity2 = std::min(1.0 + (effMatDenom2 == 0.0 ? 0.0 : effMatNumer2 / effMatDenom2), 5.0);
493 std::max(std::min((1.0 + (kvaNWMaturity1 - 2.5) * kvaMatAdjB1) / (1.0 - 1.5 * kvaMatAdjB1), 5.0), 1.0);
495 std::max(std::min((1.0 + (kvaNWMaturity2 - 2.5) * kvaMatAdjB2) / (1.0 - 1.5 * kvaMatAdjB2), 5.0), 1.0);
498 Real kvaRC1 =
kvaAlpha_ * eepe_kva_1 * LGD1 * kva99PD1 * kvaMatAdj1;
499 Real kvaRC2 =
kvaAlpha_ * eepe_kva_2 * LGD2 * kva99PD2 * kvaMatAdj2;
503 Real kvaCCRIncrement1 =
505 Real kvaCCRIncrement2 =
511 DLOG(
"Our KVA-CCR for " << nettingSetId <<
": " << j <<
" EEPE=" << setprecision(2) << eepe_kva_1
512 <<
" EPE=" << epe[j] <<
" RC=" << kvaRC1 <<
" M=" << setprecision(6)
513 << kvaNWMaturity1 <<
" MA=" << kvaMatAdj1 <<
" Cost=" << setprecision(2)
515 DLOG(
"Their KVA-CCR for " << nettingSetId <<
": " << j <<
" EENE=" << eepe_kva_2 <<
" ENE=" << ene[j]
516 <<
" RC=" << kvaRC2 <<
" M=" << setprecision(6) << kvaNWMaturity2
517 <<
" MA=" << kvaMatAdj2 <<
" Cost=" << setprecision(2) << kvaCCRIncrement2
523 Real kvaCvaMaturity1 = 1.0 + (effMatDenom1 == 0.0 ? 0.0 : effMatNumer1 / effMatDenom1);
524 Real kvaCvaMaturity2 = 1.0 + (effMatDenom2 == 0.0 ? 0.0 : effMatNumer2 / effMatDenom2);
527 Real kvaCVAIncrement1 =
529 Real kvaCVAIncrement2 =
532 DLOG(
"Our KVA-CVA for " << nettingSetId <<
": " << j <<
" EEPE=" << eepe_kva_1 <<
" SCVA=" << scva1
533 <<
" Cost=" << kvaCVAIncrement1);
534 DLOG(
"Their KVA-CVA for " << nettingSetId <<
": " << j <<
" EENE=" << eepe_kva_2 <<
" SCVA=" << scva2
535 <<
" Cost=" << kvaCVAIncrement2);
542 LOG(
"Update netting set KVA done");
550 LOG(
"Update netting set CVA sensitivities");
555 string nettingSetId = n.first;
556 vector<Real> epe =
netEPE_[nettingSetId];
558 Handle<DefaultProbabilityTermStructure> cvaDts;
565 cvaDts =
market_->defaultCurve(cid)->curve();
566 QL_REQUIRE(!cvaDts.empty(),
"Default curve missing for counterparty " << cid);
570 LOG(
"CVA Sensitivity: " << cvaSensi);
572 QuantLib::ext::shared_ptr<CVASpreadSensitivityCalculator> cvaSensiCalculator = QuantLib::ext::make_shared<CVASpreadSensitivityCalculator>(
575 for (Size i = 0; i < cvaSensiCalculator->shiftTimes().
size(); ++i) {
576 DLOG(
"CVA Sensi Calculator: t=" << cvaSensiCalculator->shiftTimes()[i]
577 <<
" h=" << cvaSensiCalculator->hazardRateSensitivities()[i]
578 <<
" s=" << cvaSensiCalculator->cdsSpreadSensitivities()[i]);
591 LOG(
"Update netting set CVA sensitivities done");
595 QL_REQUIRE(
tradeEPE_.find(tradeId) !=
tradeEPE_.end(),
"Trade " << tradeId <<
" not found in exposure map");
600 QL_REQUIRE(
tradeENE_.find(tradeId) !=
tradeENE_.end(),
"Trade " << tradeId <<
" not found in exposure map");
626 "Netting set " << nettingSetId <<
" not found in exposure map");
632 "Netting set " << nettingSetId <<
" not found in exposure map");
640 return vector<Real>();
647 return vector<Real>();
684 "Trade " << tradeId <<
" not found in exposure map");
690 "Trade " << tradeId <<
" not found in exposure map");
755 "NettingSetId " << nettingSetId <<
" not found in nettingSet KVACCR map");
761 "NettingSetId " << nettingSetId <<
" not found in nettingSet KVACCR map");
767 "NettingSetId " << nettingSetId <<
" not found in nettingSet KVACVA map");
773 "NettingSetId " << nettingSetId <<
" not found in nettingSet KVACVA map");
814 const std::vector<QuantLib::ext::shared_ptr<ore::data::Report>>& dimRegReports) {
816 QuantLib::ext::shared_ptr<RegressionDynamicInitialMarginCalculator> regCalc =
817 QuantLib::ext::dynamic_pointer_cast<RegressionDynamicInitialMarginCalculator>(
dimCalculator_);
820 regCalc->exportDimRegression(nettingSet, timeSteps, dimRegReports);
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_
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_
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.
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 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 > & 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.
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.
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()
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)
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_
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.
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_
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.
Dynamic Initial Margin calculator base class.
Dynamic Initial Margin calculator by regression.
XVA calculator with dynamic credit.
ExposureAllocator::AllocationMethod parseAllocationMethod(const string &s)
Convert text representation to ExposureAllocator::AllocationMethod.
CollateralExposureHelper::CalculationType parseCollateralCalculationType(const string &s)
Convert text representation to CollateralExposureHelper::CalculationType.
Size size(const ValueType &v)
Exposure aggregation and XVA calculation.
XVA calculator with static credit.
CVA calculator base class.