ECL API¶
creditriskengine.ecl.ifrs9.ecl_calc
¶
IFRS 9 ECL computation — 12-month and lifetime.
12-month ECL (Stage 1): ECL_12m = PD_12m * LGD * EAD * DF
Lifetime ECL (Stage 2 and 3): ECL_lifetime = Sum(t=1..T) [Marginal_PD(t) * LGD(t) * EAD(t) * DF(t)]
Reference: IFRS 9.5.5.1-5.5.20, IFRS 9.B5.5.28-B5.5.29.
discount_factors(eir, periods)
¶
Calculate discount factors at the effective interest rate.
DF(t) = 1 / (1 + EIR)^t
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
eir
|
float
|
Effective interest rate (annualized). |
required |
periods
|
int
|
Number of periods. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of discount factors for periods 1..T. |
Source code in creditriskengine\ecl\ifrs9\ecl_calc.py
ecl_12_month(pd_12m, lgd, ead, eir=0.0)
¶
Calculate 12-month ECL for Stage 1 exposures.
Formula
ECL_12m = PD_12m * LGD * EAD * DF(1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pd_12m
|
float
|
12-month probability of default. |
required |
lgd
|
float
|
Loss given default. |
required |
ead
|
float
|
Exposure at default. |
required |
eir
|
float
|
Effective interest rate for discounting. |
0.0
|
Returns:
| Type | Description |
|---|---|
float
|
12-month ECL amount. |
Source code in creditriskengine\ecl\ifrs9\ecl_calc.py
ecl_lifetime(marginal_pds, lgds, eads, eir=0.0)
¶
Calculate lifetime ECL for Stage 2/3 exposures.
Formula
ECL = Sum(t=1..T) [Marginal_PD(t) * LGD(t) * EAD(t) * DF(t)]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
marginal_pds
|
ndarray
|
Array of marginal PDs for each period. |
required |
lgds
|
ndarray | float
|
LGD values (scalar or array per period). |
required |
eads
|
ndarray | float
|
EAD values (scalar or array per period). |
required |
eir
|
float
|
Effective interest rate for discounting. |
0.0
|
Returns:
| Type | Description |
|---|---|
float
|
Lifetime ECL amount. |
Source code in creditriskengine\ecl\ifrs9\ecl_calc.py
calculate_ecl(stage, pd_12m, lgd, ead, eir=0.0, marginal_pds=None, lgd_curve=None, ead_curve=None)
¶
Unified ECL calculation dispatcher based on IFRS 9 stage.
Stage 1: 12-month ECL Stage 2/3/POCI: Lifetime ECL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stage
|
IFRS9Stage
|
IFRS 9 impairment stage. |
required |
pd_12m
|
float
|
12-month PD. |
required |
lgd
|
float
|
Loss given default (scalar). |
required |
ead
|
float
|
Exposure at default (scalar). |
required |
eir
|
float
|
Effective interest rate. |
0.0
|
marginal_pds
|
ndarray | None
|
Marginal PD curve (required for lifetime ECL). |
None
|
lgd_curve
|
ndarray | None
|
Optional LGD term structure. |
None
|
ead_curve
|
ndarray | None
|
Optional EAD term structure. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
ECL amount. |
Source code in creditriskengine\ecl\ifrs9\ecl_calc.py
creditriskengine.ecl.ifrs9.staging
¶
IFRS 9 three-stage impairment model.
Reference: IFRS 9.5.5.1-5.5.20.
Stage 1: 12-month ECL (performing, no SICR) Stage 2: Lifetime ECL (performing, SICR identified) Stage 3: Lifetime ECL (credit-impaired / defaulted) POCI: Purchased or originated credit-impaired
assign_stage(days_past_due, is_credit_impaired=False, is_defaulted=False, is_poci=False, sicr_triggered=False, dpd_backstop=30)
¶
Assign IFRS 9 impairment stage.
Logic per IFRS 9.5.5.1-5.5.20: - Stage 3: Credit-impaired or defaulted - Stage 2: SICR triggered or DPD > backstop (rebuttable, IFRS 9.B5.5.19) - Stage 1: All other performing exposures - POCI: Purchased/originated credit-impaired (separate treatment)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
days_past_due
|
int
|
Days past due count. |
required |
is_credit_impaired
|
bool
|
Whether exposure is credit-impaired. |
False
|
is_defaulted
|
bool
|
Whether exposure is in default. |
False
|
is_poci
|
bool
|
Whether this is a POCI asset. |
False
|
sicr_triggered
|
bool
|
Whether SICR assessment triggered Stage 2. |
False
|
dpd_backstop
|
int
|
DPD backstop for Stage 2 (default 30, per IFRS 9.5.5.11). |
30
|
Returns:
| Type | Description |
|---|---|
IFRS9Stage
|
IFRS9Stage enum value. |
Source code in creditriskengine\ecl\ifrs9\staging.py
stage_allocation_summary(stages, eads)
¶
Summarize stage allocation by count and EAD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stages
|
list[IFRS9Stage]
|
List of stage assignments. |
required |
eads
|
list[float]
|
Corresponding EAD values. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, float]]
|
Dict with count and ead totals per stage. |
Source code in creditriskengine\ecl\ifrs9\staging.py
creditriskengine.ecl.ifrs9.sicr
¶
Significant Increase in Credit Risk (SICR) assessment.
Reference: IFRS 9.5.5.9-5.5.12, IFRS 9.B5.5.15-B5.5.22.
SICR is assessed by comparing lifetime PD at reporting date vs lifetime PD at origination. Uses a relative change threshold. 30 DPD backstop is rebuttable per IFRS 9.B5.5.19.
assess_sicr(current_lifetime_pd, origination_lifetime_pd, days_past_due=0, relative_threshold=2.0, absolute_threshold=0.005, dpd_backstop=30, use_dpd_backstop=True)
¶
Assess whether Significant Increase in Credit Risk has occurred.
Quantitative assessment (IFRS 9.5.5.9): SICR if lifetime PD has increased significantly since origination. Typically: relative change > threshold OR absolute change > threshold.
Qualitative backstop (IFRS 9.B5.5.19): 30 DPD rebuttable presumption of SICR.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_lifetime_pd
|
float
|
Current lifetime PD estimate. |
required |
origination_lifetime_pd
|
float
|
Lifetime PD at origination date. |
required |
days_past_due
|
int
|
Current days past due. |
0
|
relative_threshold
|
float
|
Relative PD increase threshold (default 2.0 = 200%). |
2.0
|
absolute_threshold
|
float
|
Absolute PD increase threshold (default 50 bps). |
0.005
|
dpd_backstop
|
int
|
DPD backstop (default 30 days). |
30
|
use_dpd_backstop
|
bool
|
Whether to apply DPD backstop. |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True if SICR is triggered. |