CCR/XVA Calculations
DiffFusion.expected_exposure
— Functionexpected_exposure(
scens::ScenarioCube,
gross_leg::Bool = false,
average_paths::Bool = true,
aggregate_legs::Bool = true,
)
Calculate expected positive exposure (EPE or EE).
scens
is the input ScenarioCube
.
If gross_leg
is true then calculate positive floor on trade level. Otherwise, use netted portfolio to determine positive floor.
If average_paths
is true then reduce scenario cube along path axis. Otherwise, keep individual paths.
If aggregate_legs
is true then reduce scenario cube along the axis of legs. Otherwise, keep individual legs.
DiffFusion.potential_future_exposure
— Functionpotential_future_exposure(
scens::ScenarioCube,
quantile_::ModelValue,
gross_leg::Bool = false,
)
Calculate the potential future exposure (PFE).
scens
is the input ScenarioCube
.
quantile_
is the desired quantile for PFE calculation.
If gross_leg
is true then calculate positive floor on trade level. Otherwise, use netted portfolio to determine positive floor.
DiffFusion.valuation_adjustment
— Functionvaluation_adjustment(
credit_ts::CreditDefaultTermstructure,
recovery_rate::ModelValue,
cva_dva::ModelValue,
scens::ScenarioCube,
gross_leg::Bool = false,
average_paths::Bool = true,
aggregate_legs::Bool = true,
rho::ModelValue = 0.5,
)
Calculate unilateral CVA and DVA for a given ScenarioCube
. Result is a ScenarioCube
with non-negative XVA contributions along the time axis.
credit_ts
is the credit spread curve to calculate survival probabilities. recovery_rate
is the corresponding constant recovery rate value (typicall 0.40).
cva_dva
is a binary flag to model CVA (+1.0) and DVA (-1.0).
scens
is the input ScenarioCube
. Values are assumed to be discounted prices in the corresponding portfolio currency.
Parameters gross_leg
, average_paths
and aggregate_legs
are used as in function expected_exposure
.
rho
specifies how to integrate discounted prices. rho=0.5
uses trapezoidal rule. This choice is used in BCBS paper Basel III: A global regulatory framework for more resilient banks and banking systems (2011). rho=0.0
uses prices at the start of period and is proposed in Green, XVA (2016).