Type: | Package |
Title: | Credit Risk Valuation Adjustments |
Version: | 1.3 |
Date: | 2025-05-23 |
Author: | Tasos Grivas [aut, cre] |
Maintainer: | Tasos Grivas <info@openriskcalculator.com> |
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 four 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 Interest Rate Swaps. The latest regulatory capital charge methodologies have been implementing including BA-CVA & SA-CVA. |
License: | GPL-3 |
Imports: | methods, SACCR, Trading, data.table |
URL: | https://openriskcalculator.com/ |
Collate: | 'CalcNGR.R' 'CalcPD.R' 'CalcSimulatedExposure.R' 'CalcVA.R' 'GenerateTimeGrid.R' 'calcDefCapital.R' 'calcEADRegulatory.R' 'calcEffectiveMaturity.R' 'calcKVA.R' 'xVACalculator.R' 'xVACalculatorExample.R' 'onLoad.R' 'IS_ELIGIBLE_CCY.R' 'IS_IG.R' 'LoadSupervisoryCVAData.R' 'calcCVACapital.R' |
NeedsCompilation: | no |
RoxygenNote: | 7.3.2 |
Repository: | CRAN |
Repository/R-Forge/Project: | ccr |
Repository/R-Forge/Revision: | 65 |
Repository/R-Forge/DateTimeStamp: | 2022-08-27 16:52:51 |
Date/Publication: | 2025-05-30 09:50:01 UTC |
Packaged: | 2025-05-28 22:29:20 UTC; user1 |
Calculates the Net/Gross ratio (NGR)
Description
Calculates the Net/Gross ratio used under the CEM regulatory framework
Usage
CalcNGR(MtM_Vector)
Arguments
MtM_Vector |
A vector containing the trades to be netted |
Value
The Net-Gross ratio (NGR)
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
Calculates the Probablity of Default
Description
Calculates the probablity of the default on specific time points by using the spread of the corresponding credit curve and the loss given default
Usage
CalcPD(spread, LGD, time_points)
Arguments
spread |
The spread based on the credit curve |
LGD |
The loss-given-default |
time_points |
The timepoints that the analysis is performed on |
Value
A vector containing the probablity of default on the specified timepoints
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
Calculated the Simulated Exposure Profile
Description
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
Usage
CalcSimulatedExposure(
discount_factors,
time_points,
spot_curve,
CSA,
trades,
sim_data,
framework,
seed = NULL
)
Arguments
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' |
seed |
The seed for the simulations |
Value
A list containing the exposure profile (both collateralized and uncollateralized)
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
Calculates the Valuation Adjustment
Description
Calculates the Valuation Adjustment based on the exposure, the probability-of-default and the loss-given-default
Usage
CalcVA(exposure, discount_factors, PD, LGD)
Arguments
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 |
Value
The Valuation Adjustment Value
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
Checks if specified currency is low risk
Description
Checks if the specified currency is eligible to receive reduced regulatory risk weights
Usage
IS_ELIGIBLE_CCY(ccy)
Arguments
ccy |
The currency to be checked |
Value
TRUE if the currency is is eligible to receive reduced regulatory risk weights
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
https://www.bis.org/basel_framework/chapter/MAR/50.htm?inforce=20230101&published=20200708
Examples
TRUE == IS_ELIGIBLE_CCY('EUR')
Checks if Credit rating is Investment Grade
Description
Checks if the credit rating is investment grade or not (if not rating not recognised will be unrated)
Usage
IS_IG(credit_rating)
Arguments
credit_rating |
The Credit Rating to be checked |
Value
TRUE if Rating is Investment Grade
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
https://en.wikipedia.org/wiki/Credit_rating
Examples
TRUE == IS_IG('AAA')
Supervisory Data Loading
Description
Loads the supervisory data (factors, correlation and option volatility) for each Asset Class and SubClass
Usage
LoadSupervisoryCVAData()
Value
A list with the required data
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
MAR50 - Credit Value Adjustment Framework https://www.bis.org/basel_framework/chapter/MAR/50.htm?inforce=20230101&published=20200708
Calculates the CVA Capital Charge
Description
Calculates the CVA capital charge based on the standardized approach
Usage
calcCVACapital(
trades,
EAD,
reg_data,
superv,
effective_maturity,
cva_sensitivities
)
Arguments
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 |
Value
The CVA capital charge of the trade set
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
Calculates the Default Capital Charge
Description
Calculates the default capital charge using the advanced IRB methodology and the stressed R
Usage
calcDefCapital(trades, EAD, reg_data, effective_maturity)
Arguments
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 |
Value
The default capital charge
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
Calculates the Exposure-At-Default (EAD)
Description
Calculates the Exposure-At-Default (EAD) based on the given regulatory framework. It supports the CEM, IMM and (simplified) SA-CCR frameworks
Usage
calcEADRegulatory(
trades,
framework,
sa_ccr_simplified = "",
CSA,
collateral,
EEE,
time_points
)
Arguments
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 |
Value
The Exposure-At-Default
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
Calculates the Effective Maturity
Description
Calculates the effective maturity based on the specified regulatory framework
Usage
calcEffectiveMaturity(trades, time_points, framework, simulated_exposure)
Arguments
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 |
Value
The effective maturity of the trade set
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
Calculates the Capital Valuation Adjustment (KVA)
Description
Calculates the capital valuation adjustment by computing the default capital charge and the CVA capital charge and applying the required return-on-capital
Usage
calcKVA(
trades,
reg_data,
EAD,
effective_maturity,
ignore_def_charge = TRUE,
cva_capital_charge
)
Arguments
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') |
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 |
cva_capital_charge |
The CVA Capital Charge linked to this portfolio |
Value
The capital valuation adjustment (KVA)
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
Calculates the xVA values
Description
Calculates the xVA values (CVA, DVA, FVA, FBA, MVA, KVA)
Usage
xVACalculator(
trades,
CSA,
collateral,
sim_data,
reg_data,
credit_curve_PO,
credit_curve_cpty,
funding_curve,
spot_rates,
cpty_LGD,
PO_LGD,
no_simulations
)
Arguments
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 |
Value
A list containing the xVA values and the cva capital charge
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Gregory J., The xVA Challenge, 2015, Wiley
xVA calculation example
Description
Calculates the xVA values for a simple example containing two IR swaps.
Usage
xVACalculatorExample()
Value
A list with the values of various valuations' adjustments
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
Examples
## run the example
xVACalculatorExample()