calc_ecl
1. Description
The calc_ecl function calculates two important metrics for financial instruments: 12-month Expected Credit Loss (ECL) and Lifetime Expected Credit Loss (ECL).
2. Input
# | Parameters | DataType | Description | Example |
---|---|---|---|---|
1 | _account_number | String | The account number for which the Expected Credit Loss (ECL) is being calculated. | "123456789" |
2 | cashflows | Vec of Cashflow | A vector containing structs of cashflows, each representing principal amount, interest amount, and the corresponding cashflow date for the account. | See Cashflow struct definition. |
3 | as_on_date | NaiveDate | The reference date for the calculation, typically today's date or a reporting date. | NaiveDate::from_ymd(2025, 1, 1) |
4 | pd_12m | Vec of f64 | A vector of Probability of Default (PD) values over 12 months, expressed as percentages, for multiple time periods or scenarios. | [0.01, 0.02, 0.015] |
5 | eir | f64 | The Effective Interest Rate (EIR) used to discount future cashflows, expressed as a percentage. | 5.0 |
6 | ecl_ip | EclIp | A struct containing additional parameters required for the ECL calculation, such as LGD, ECL method, loss rate, exposure at default, and more. | See EclIp struct definition. |
2.1 CashFlow Struct
# | Field | DataType | Description |
---|---|---|---|
1 | principal_amount | f64 | The principal part of the cashflow. |
2 | interest_amount | f64 | The interest part of the cashflow. |
3 | date | i64 (timestamp) | A timestamp representing the cashflow's date. |
2.2 EclIp Struct
# | Field | DataType | Description | Example |
---|---|---|---|---|
1 | lgd | f64 | The Loss Given Default (LGD) percentage, representing the portion of the exposure lost in case of default. | 0.4 |
2 | ecl_method | String | The method used to calculate the Expected Credit Loss (ECL) | "ECL2" or "ECL1" |
3 | loss_rate | f64 | The loss rate used for specific ECL calculations, expressed as a percentage. | 0.05 |
4 | exposure_at_default | f64 | The exposure amount at default, representing the outstanding balance or potential loss amount at default. | 100000.0 |
5 | pocl | String | Probability of Collection Loss indicator, used in some ECL methods. | "Y" |
6 | lease | String | Lease flag for the account. | "Y" |
7 | stage | i64 | The stage of the account (e.g., Stage 1, 2, or 3) under the ECL framework. | 1 |
3. Output
The function returns two structs:ECLData and EclCfData
3.1 ECLData Struct
# | Field | DataType | Description | Example |
---|---|---|---|---|
1 | ecl_12m | f64 | The Expected Credit Loss (ECL) for 12 months, calculated based on the relevant parameters. | 1000.0 |
2 | ecl_lifetime | f64 | The Expected Credit Loss (ECL) over the lifetime of the asset, based on projected future cashflows and probability of default. | 5000.0 |
3 | reporting_ecl | f64 | The reported Expected Credit Loss (ECL) for the current reporting period, which could be a subset of 12-month and lifetime ECL. | 1500.0 |
3.2 EclCfData
# | Field | DataType | Description | Example |
---|---|---|---|---|
1 | cf_date | NaiveDate | The date of the cashflow. | NaiveDate::from_ymd(2025, 1, 1) |
2 | bal_amt | f64 | The balance amount of the cashflow. | 10000.0 |
3 | int_amt | f64 | The interest amount associated with the cashflow. | 500.0 |
4 | exposure_at_default | f64 | The exposure amount at default, representing the potential loss at the time of default. | 10000.0 |
5 | probability_at_default | f64 | The probability of default associated with the cashflow, typically expressed as a percentage. | 0.02 |
6 | expected_credit_loss | f64 | The calculated Expected Credit Loss (ECL) based on the cashflow data, incorporating default probability and exposure. | 200.0 |