Type: | Package |
Title: | SA Counterparty Credit Risk under CRR2 |
Version: | 3.3 |
Date: | 2025-05-04 |
Author: | Tasos Grivas [aut, cre] |
Maintainer: | Tasos Grivas <info@openriskcalculator.com> |
Description: | Computes the Exposure-At-Default based on the standardized approach of CRR2 (SA-CCR). The simplified version of SA-CCR has been included, as well as the OEM methodology. Multiple trade types of all the five major asset classes are being supported including the Other Exposure and, given the inheritance- based structure of the application, the addition of further trade types is straightforward. The application returns a list of trees per Counterparty and CSA after automatically separating the trades based on the Counterparty, the CSAs, the hedging sets, the netting sets and the risk factors. The basis and volatility transactions are also identified and treated in specific hedging sets whereby the corresponding penalty factors are applied. All the examples appearing on the regulatory papers (both for the margined and the unmargined workflow) have been implemented including the latest CRR2 developments. |
License: | GPL-3 |
Imports: | methods, data.tree, jsonlite, Trading |
URL: | https://openriskcalculator.com/ |
Collate: | 'CalcAddon.R' 'CalcEAD.R' 'CalcPFE.R' 'CalcRC.R' 'ExampleBasisVol.R' 'ExampleComm.R' 'ExampleCredit.R' 'ExampleFX.R' 'ExampleIRD.R' 'ExampleIRDCommMargined.R' 'ExampleIRDCredit.R' 'HandleBasisVol.R' 'LoadSupervisoryData.R' 'runExampleCalcs.R' 'CalculateFactorMult.R' 'CreateTradeGraph.R' 'GroupCommTrades.R' 'GroupCreditTrades.R' 'GroupEquityTrades.R' 'GroupFXTrades.R' 'GroupIRDTrades.R' 'GroupTrades.R' 'SACCRCalculator.R' 'SingleTradeAddon.R' 'onLoad.R' 'DetermineCCRMethodology.R' 'GroupOtherTrades.R' |
NeedsCompilation: | no |
RoxygenNote: | 7.1.1 |
Repository: | CRAN |
Packaged: | 2025-05-10 08:09:46 UTC; user1 |
Date/Publication: | 2025-05-13 08:30:10 UTC |
Calculates the Addon amount
Description
Calculates the amount of the addon for each heding/nettting set
Usage
CalcAddon(trades_tree, MF, simplified = FALSE, OEM = FALSE)
Arguments
trades_tree |
A tree structure with the input trades |
MF |
(Optional) The Maturity Factor based on the collateral agreement |
simplified |
(optional) When TRUE, the add-ons will be calculated as per the simplified SA-CCR |
OEM |
(optional) When TRUE, the add-ons will be calculated as per the Original Exposure Method |
Value
The aggregate amount of the addon summed up for all the asset classes
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Regulation (EU) 2019/876 of the European Parliament and of the Council of 20 May 2019 http://data.europa.eu/eli/reg/2019/876/oj
Calculates the EAD
Description
Calculates the Exposure at Default
Usage
CalcEAD(RC, PFE)
Arguments
RC |
the replacement cost |
PFE |
the projected future exposure |
Value
The Exposure-at-Default
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Regulation (EU) 2019/876 of the European Parliament and of the Council of 20 May 2019 http://data.europa.eu/eli/reg/2019/876/oj
Examples
#returns 1.4*(60+500) = 784
EAD <- CalcEAD(60,500)
Calculates the PFE
Description
Calculates the Projected Future Exposure (PFE) after applying the relevant multiplier. The purpose of this multiplier is to lessen the risk stemming from the addons in case of excess collateral
Usage
CalcPFE(V_C, V = 0,Addon_Aggregate, simplified)
Arguments
V_C |
the difference between the sum of the MtMs and the collateral |
V |
the sum of MVs of the trades |
Addon_Aggregate |
the aggregate amount of the Addon |
simplified |
(optional) When TRUE, the multiplier will be set to 1 as per the simplified & OEM approach |
Value
The Projected Future Exposure (PFE)
Author(s)
Tasos Grivas <info@openriskcalculator.com>
References
Regulation (EU) 2019/876 of the European Parliament and of the Council of 20 May 2019 http://data.europa.eu/eli/reg/2019/876/oj
Calculates the RC
Description
Calculates the Replacement Cost(RC) and the sum of the MtMs for all the trades
Usage
CalcRC(trades, csa, collaterals, simplified, ignore_margin = FALSE)
Arguments
trades |
The full list of the Trade Objects |
csa |
(Optional) The CSA objects |
collaterals |
(Optional) The collaterals Objects |
simplified |
(optional) When TRUE, collaterals will be ignored as per the simplified & OEM approach |
ignore_margin |
(optional) if TRUE, the margin agreement workflow will be turned off |
Value
The replacement Cost and the sum of the MtMs
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Regulation (EU) 2019/876 of the European Parliament and of the Council of 20 May 2019 http://data.europa.eu/eli/reg/2019/876/oj
Creates a tree-like structure of a list of trades
Description
Creates a tree-like structure describing the various hedging sets / risk factors that that the input trades can be broken into
Usage
CreateTradeGraph(trades)
Arguments
trades |
The full list of the Trade Objects |
Value
A tree structure based on hedging/netting sets and basis/volatility transactions
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
Specifies the CCR methodology
Description
Determines the CCR methodology that the institution is eligible to utilize. The regulator allows the institutions to select less complicated methodologies when the derivatives trading business is negligible
Usage
DetermineCCRMethodology(trades_filename, total_assets)
Arguments
trades_filename |
the file holding the trades of the portfolio |
total_assets |
the total assets of the institution in mio EUR |
Value
The CCR methodology that the institution is eligible to utilize
Author(s)
Tasos Grivas <info@openriskcalculator.com>
References
Regulation (EU) 2019/876 of the European Parliament and of the Council of 20 May 2019 http://data.europa.eu/eli/reg/2019/876/oj
Basis+Volatility trades Example
Description
Calculates the Exposure at Default for a trade set containing basis and volatility transactions
Usage
ExampleBasisVol(JSON = FALSE)
Arguments
JSON |
(optional) if TRUE it returns a json string |
Value
The exposure at default
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Regulation (EU) 2019/876 of the European Parliament and of the Council of 20 May 2019 http://data.europa.eu/eli/reg/2019/876/oj
Commodities Example
Description
Calculates the Exposure at Default for the Commodities example as given in the Basel III regulatory paper
Usage
ExampleComm(JSON = FALSE)
Arguments
JSON |
(optional) if TRUE it returns a json string |
Value
The exposure at default (expected value based on the Basel paper is 5406)
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Basel Committee: The standardised approach for measuring counterparty credit risk exposures http://www.bis.org/publ/bcbs279.htm
Credit Products Example
Description
Calculates the Exposure at Default for the Credit example as given in the Basel III regulatory paper
Usage
ExampleCredit(JSON = FALSE)
Arguments
JSON |
(optional) if TRUE it returns a json string |
Value
The exposure at default (expected value based on the Basel paper is 381)
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Basel Committee: The standardised approach for measuring counterparty credit risk exposures http://www.bis.org/publ/bcbs279.htm
FX Example
Description
Calculates the Exposure at Default for the FX product type
Usage
ExampleFX(JSON = FALSE)
Arguments
JSON |
(optional) if TRUE it returns a json string |
Value
The exposure at default
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Basel Committee: The standardised approach for measuring counterparty credit risk exposures http://www.bis.org/publ/bcbs279.htm
IRDs Example
Description
Calculates the Exposure at Default for the IRD example as given in the Basel III regulatory paper
Usage
ExampleIRD(JSON = FALSE)
Arguments
JSON |
(optional) if TRUE it returns a json string |
Value
The exposure at default (expected value based on the Basel paper is 569)
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Basel Committee: The standardised approach for measuring counterparty credit risk exposures http://www.bis.org/publ/bcbs279.htm
Margined IRDs+Commodity Example
Description
Calculates the Exposure at Default for the margined IRDs + Commodity example as given in the Basel III regulatory paper
Usage
ExampleIRDCommMargined(JSON = FALSE)
Arguments
JSON |
(optional) if TRUE it returns a json string |
Value
The exposure at default (expected value based on the Basel paper is 1879)
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Basel Committee: The standardised approach for measuring counterparty credit risk exposures http://www.bis.org/publ/bcbs279.htm
IRDs+Commodity Example
Description
Calculates the Exposure at Default for the IRDs + Commodity example as given in the Basel III regulatory paper
Usage
ExampleIRDCredit(JSON = FALSE)
Arguments
JSON |
(optional) if TRUE it returns a json string |
Value
The exposure at default (expected value based on the Basel paper is 936)
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Basel Committee: The standardised approach for measuring counterparty credit risk exposures http://www.bis.org/publ/bcbs279.htm
Splits trades in being basis, volatility or 'normal' transactions
Description
Receives a list of trades and splits them according to being basis, volatility or 'normal' transactions
Usage
HandleBasisVol(trades)
Arguments
trades |
The full list of the Trade Objects |
Value
A list depicting which trade IDs fall under each hedging set.
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Regulation (EU) 2019/876 of the European Parliament and of the Council of 20 May 2019 http://data.europa.eu/eli/reg/2019/876/oj
Supervisory Data Loading
Description
Loads the supervisory data (factors, correlation and option volatility) for each Asset Class and SubClass
Usage
LoadSupervisoryData()
Value
A data frame with the required data
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Regulation (EU) 2019/876 of the European Parliament and of the Council of 20 May 2019 http://data.europa.eu/eli/reg/2019/876/oj
SA-CCR Calculator
Description
Returns a tree structure depicting the add-on calculations on different hedging/netting sets
Usage
SACCRCalculator(
trades_filename,
csa_filename,
coll_filename,
JSON = FALSE,
simplified = FALSE,
OEM = FALSE,
export_results = FALSE,
ignore_margin = FALSE
)
Arguments
trades_filename |
a .csv file containing the trades |
csa_filename |
a .csv file containing CSAs |
coll_filename |
a .csv file containing collaterals |
JSON |
(optional) if TRUE it returns a json string |
simplified |
(optional) if TRUE, the simplified SA-CCR is being calculated |
OEM |
(optional) if TRUE, the Original Exposure Method is being calculated |
export_results |
(optional) if TRUE, a csv with the exposure at the top level will be exported |
ignore_margin |
(optional) if TRUE, the margin agreement workflow will be turned off |
Value
The relevant exposure trees
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Regulation (EU) 2019/876 of the European Parliament and of the Council of 20 May 2019 http://data.europa.eu/eli/reg/2019/876/oj
Calculates the addon information
Description
Calculates the addon information (including Adj notional, superv delta etc) for each trade
Usage
SingleTradeAddon(trade, MF)
Arguments
trade |
A trade object |
MF |
(Optional) The Maturity Factor based on the collateral agreement |
Value
A list of addon information
Author(s)
Tasos Grivas <tasos@openriskcalculator.com>
References
Regulation (EU) 2019/876 of the European Parliament and of the Council of 20 May 2019 http://data.europa.eu/eli/reg/2019/876/oj