Title: | Calculates Credit Risk Valuation Adjustments |
---|---|
Description: | Calculates a number of valuation adjustments including CVA, DVA, FBA, FCA, MVA and KVA. A two-way margin agreement has been implemented. For the KVA calculation three regulatory frameworks are supported: CEM, (simplified) SA-CCR, OEM and IMM. The probability of default is implied through the credit spreads curve. The package supports an exposure calculation based on SA-CCR which includes several trade types and a simulated path which is currently available only for IRSwaps. The latest regulatory capital charge methodologies have been implementing including BA-CVA & SA-CVA. |
Authors: | Tasos Grivas |
Maintainer: | Tasos Grivas <[email protected]> |
License: | GPL-3 |
Version: | 1.1 |
Built: | 2024-10-20 18:20:26 UTC |
Source: | https://github.com/cranhaven/cranhaven.r-universe.dev |
Calculates the CVA capital charge based on the standardized approach
calcCVACapital( trades, EAD, reg_data, superv, effective_maturity, cva_sensitivities )
calcCVACapital( trades, EAD, reg_data, superv, effective_maturity, cva_sensitivities )
trades |
The full list of the Trade Objects |
EAD |
Exposure-at-Default |
reg_data |
A list containing data related to the regulatory calculations |
superv |
A list containing supervisory data including correlations, risk weights etc |
effective_maturity |
The effective maturity of the trades of the netting set |
cva_sensitivities |
The effective maturity of the trades of the netting set |
The CVA capital charge of the trade set
Tasos Grivas <[email protected]>
Calculates the default capital charge using the advanced IRB methodology and the stressed R
calcDefCapital(trades, EAD, reg_data, effective_maturity)
calcDefCapital(trades, EAD, reg_data, effective_maturity)
trades |
The full list of the Trade Objects |
EAD |
The Exposure-At-Default of the trades as per the selected regulatory framework |
reg_data |
A list containing data related to the regulatory calculations (for example the regulatory probability-of-default, the regulatory loss-given-default etc) |
effective_maturity |
The effective maturity of the trades of the netting set |
The default capital charge
Tasos Grivas <[email protected]>
Calculates the Exposure-At-Default (EAD) based on the given regulatory framework. It supports the CEM, IMM and (simplified) SA-CCR frameworks
calcEADRegulatory( trades, framework, sa_ccr_simplified = "", CSA, collateral, EEE, time_points )
calcEADRegulatory( trades, framework, sa_ccr_simplified = "", CSA, collateral, EEE, time_points )
trades |
The full list of the Trade Objects |
framework |
Specifies the regulatory framework used in the calculations. It can take the values of 'IMM', 'CEM', 'SA-CCR' |
sa_ccr_simplified |
(Optional) Specifies whether the standard SACCR or its simplified version or the OEM will be implemented. It can take the values of ”, 'simplified', 'OEM' |
CSA |
The margin agreement with the counterparty |
collateral |
The amount of collaterals currently exchanged with the counterparty |
EEE |
A vector containing the effective expected exposure against the counterparty |
time_points |
The timepoints that the analysis is performed on |
The Exposure-At-Default
Tasos Grivas <[email protected]>
Calculates the effective maturity based on the specified regulatory framework
calcEffectiveMaturity(trades, time_points, framework, simulated_exposure)
calcEffectiveMaturity(trades, time_points, framework, simulated_exposure)
trades |
The full list of the Trade Objects |
time_points |
The timepoints that the analysis is performed on |
framework |
Specifies the regulatory framework used in the calculations. It can take the values of 'IMM', 'CEM', 'SA-CCR' |
simulated_exposure |
The exposure profile list containing the EE, EEE etc |
The effective maturity of the trade set
Tasos Grivas <[email protected]>
Calculates the capital valuation adjustment by computing the default capital charge and the CVA capital charge and applying the required return-on-capital
calcKVA( CSA, collateral, trades, reg_data, time_points, EAD, effective_maturity, ignore_def_charge = TRUE )
calcKVA( CSA, collateral, trades, reg_data, time_points, EAD, effective_maturity, ignore_def_charge = TRUE )
CSA |
The margin agreement with the counterparty |
collateral |
The current amount of collaterals currently exchanged with the counterparty |
trades |
The full list of the Trade Objects |
reg_data |
A list containing data related to the regulatory calculations (for example the 'framework' member variable can be 'IMM','SACCR','CEM') |
time_points |
The timepoints that the analysis is performed on |
EAD |
The Exposure-at-default calculated based on the prescribed framework as appearing in the 'reg_data' |
effective_maturity |
The effective maturity of the trades performed with a specific counterparty |
ignore_def_charge |
if set to true the default capital charge is set to zero |
The capital valuation adjustment (KVA)
Tasos Grivas <[email protected]>
Calculates the Net/Gross ratio used under the CEM regulatory framework
CalcNGR(MtM_Vector)
CalcNGR(MtM_Vector)
MtM_Vector |
A vector containing the trades to be netted |
The Net-Gross ratio (NGR)
Tasos Grivas <[email protected]>
Calculates the probablity of the default on specific time points by using the spread of the corresponding credit curve and the loss given default
CalcPD(spread, LGD, time_points)
CalcPD(spread, LGD, time_points)
spread |
The spread based on the credit curve |
LGD |
The loss-given-default |
time_points |
The timepoints that the analysis is performed on |
A vector containing the probablity of default on the specified timepoints
Tasos Grivas <[email protected]>
Calculates the simulated exposure profile (EE, NEE, PFE, EEE) by use of the Hull-White model. Two sets of results are provided: one after taking into account the marging agreement and one assuming that there is no marging agreement present
CalcSimulatedExposure( discount_factors, time_points, spot_curve, CSA, trades, sim_data, framework )
CalcSimulatedExposure( discount_factors, time_points, spot_curve, CSA, trades, sim_data, framework )
discount_factors |
The discount curve derived from the spot curve |
time_points |
The timepoints that the analysis is performed on |
spot_curve |
The curve derived from interpolating the market spot rates |
CSA |
The margin agreement |
trades |
The list of the trade objects |
sim_data |
A list containing simulation-related data (model parameters and number of simulation) |
framework |
regulatory framework can be 'IMM','SACCR','CEM' |
A list containing the exposure profile (both collateralized and uncollateralized)
Tasos Grivas <[email protected]>
Calculates the Valuation Adjustment based on the exposure, the probability-of-default and the loss-given-default
CalcVA(exposure, discount_factors, PD, LGD)
CalcVA(exposure, discount_factors, PD, LGD)
exposure |
A vector containing the exposure values on which the credit risk adjustment will be calculated |
discount_factors |
The Discount Curve |
PD |
The probability-of-Default |
LGD |
The Loss-Given-Default |
The Valuation Adjustment Value
Tasos Grivas <[email protected]>
Checks if the specified currency is eligible to receive reduced regulatory risk weights
IS_ELIGIBLE_CCY(ccy)
IS_ELIGIBLE_CCY(ccy)
ccy |
The currency to be checked |
TRUE if the currency is is eligible to receive reduced regulatory risk weights
Tasos Grivas <[email protected]>
https://www.bis.org/basel_framework/chapter/MAR/50.htm?inforce=20230101&published=20200708
TRUE == IS_ELIGIBLE_CCY('EUR')
TRUE == IS_ELIGIBLE_CCY('EUR')
Checks if the credit rating is investment grade or not (if not rating not recognised will be unrated)
IS_IG(credit_rating)
IS_IG(credit_rating)
credit_rating |
The Credit Rating to be checked |
TRUE if Rating is Investment Grade
Tasos Grivas <[email protected]>
https://en.wikipedia.org/wiki/Credit_rating
TRUE == IS_IG('AAA')
TRUE == IS_IG('AAA')
Loads the supervisory data (factors, correlation and option volatility) for each Asset Class and SubClass
LoadSupervisoryCVAData()
LoadSupervisoryCVAData()
A list with the required data
Tasos Grivas <[email protected]>
MAR50 - Credit Value Adjustment Framework https://www.bis.org/basel_framework/chapter/MAR/50.htm?inforce=20230101&published=20200708
Calculates the xVA values (CVA, DVA, FVA, FBA, MVA, KVA)
xVACalculator( trades, CSA, collateral, sim_data, reg_data, credit_curve_PO, credit_curve_cpty, funding_curve, spot_rates, cpty_LGD, PO_LGD, no_simulations )
xVACalculator( trades, CSA, collateral, sim_data, reg_data, credit_curve_PO, credit_curve_cpty, funding_curve, spot_rates, cpty_LGD, PO_LGD, no_simulations )
trades |
The full list of the Trade Objects |
CSA |
The margin agreement with the counterparty |
collateral |
The amount of collateral currently exchanged with the counterparty |
sim_data |
A list containing data related to the calculation of simulated exposures (for example the model parameters and the number of simulations) |
reg_data |
A list containing data related to the regulatory calculations (for example the 'ccr_framework' member variable can be 'IMM','SACCR','CEM') |
credit_curve_PO |
The credit curve of the processing organization |
credit_curve_cpty |
The credit curve of the processing organization |
funding_curve |
A curve containing the credit spread for the funding of the collateral |
spot_rates |
The spot rates curve |
cpty_LGD |
The loss-given-default of the counterparty |
PO_LGD |
The loss-given-default of the processing organization |
no_simulations |
if true, no simulated exposure will be generated and the regulatory framework should be SA-CCR |
A list containing the xVA values and the cva capital charge
Tasos Grivas <[email protected]>
Gregory J., The xVA Challenge, 2015, Wiley
Calculates the xVA values for a simple example containing two IR swaps.
xVACalculatorExample()
xVACalculatorExample()
A list with the values of various valuations' adjustments
Tasos Grivas <[email protected]>
## run the example xVACalculatorExample()
## run the example xVACalculatorExample()