Skip to main content

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

#ParametersDataTypeDescriptionExample
1_account_numberStringThe account number for which the Expected Credit Loss (ECL) is being calculated."123456789"
2cashflowsVec of CashflowA vector containing structs of cashflows, each representing principal amount, interest amount, and the corresponding cashflow date for the account.See Cashflow struct definition.
3as_on_dateNaiveDateThe reference date for the calculation, typically today's date or a reporting date.NaiveDate::from_ymd(2025, 1, 1)
4pd_12mVec of f64A 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]
5eirf64The Effective Interest Rate (EIR) used to discount future cashflows, expressed as a percentage.5.0
6ecl_ipEclIpA 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

#FieldDataTypeDescription
1principal_amountf64The principal part of the cashflow.
2interest_amountf64The interest part of the cashflow.
3datei64 (timestamp)A timestamp representing the cashflow's date.

2.2 EclIp Struct

#FieldDataTypeDescriptionExample
1lgdf64The Loss Given Default (LGD) percentage, representing the portion of the exposure lost in case of default.0.4
2ecl_methodStringThe method used to calculate the Expected Credit Loss (ECL)"ECL2" or "ECL1"
3loss_ratef64The loss rate used for specific ECL calculations, expressed as a percentage.0.05
4exposure_at_defaultf64The exposure amount at default, representing the outstanding balance or potential loss amount at default.100000.0
5poclStringProbability of Collection Loss indicator, used in some ECL methods."Y"
6leaseStringLease flag for the account."Y"
7stagei64The 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

#FieldDataTypeDescriptionExample
1ecl_12mf64The Expected Credit Loss (ECL) for 12 months, calculated based on the relevant parameters.1000.0
2ecl_lifetimef64The Expected Credit Loss (ECL) over the lifetime of the asset, based on projected future cashflows and probability of default.5000.0
3reporting_eclf64The 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

#FieldDataTypeDescriptionExample
1cf_dateNaiveDateThe date of the cashflow.NaiveDate::from_ymd(2025, 1, 1)
2bal_amtf64The balance amount of the cashflow.10000.0
3int_amtf64The interest amount associated with the cashflow.500.0
4exposure_at_defaultf64The exposure amount at default, representing the potential loss at the time of default.10000.0
5probability_at_defaultf64The probability of default associated with the cashflow, typically expressed as a percentage.0.02
6expected_credit_lossf64The calculated Expected Credit Loss (ECL) based on the cashflow data, incorporating default probability and exposure.200.0