A small IFRS 9 expected credit loss (ECL) engine on public data, with an audit layer that tries to disagree with it: stage-transfer matrix, ECL movement waterfall, sensitivities, an independent re-calculation of sampled accounts, a PD backtest, and a generated audit-style report.
The portfolio layer (products, dates, rates, collateral) is synthetic and none of the models is a regulatory model. The behavioural data are real.
I audited bank models for years, and ECL staging and PD calibration were where the arguments were. The numbers come out of long chains of judgement, and a reviewer needs to see every link: what the label means, how a PD is moved to the horizon the standard needs, what triggers Stage 2, which assumptions the result is most sensitive to. The engine is deliberately small so that all of it can be read in an afternoon. The audit layer re-performs the calculation independently and says which parts of the result I cannot support from the data.
| Concept | Meaning |
|---|---|
| ECL | Probability-weighted, discounted loss: sum over t of marginal PD(t) x LGD x EAD(t) x DF(t) |
| Stage 1 | Performing, no significant increase in credit risk (SICR): 12-month ECL |
| Stage 2 | SICR since origination, or more than 30 days past due (rebuttable backstop): lifetime ECL |
| Stage 3 | Credit-impaired, here 90 days past due: lifetime ECL on a defaulted exposure |
| Forward-looking | PD is moved to macro scenarios that are probability-weighted |
The cliff between Stage 1 and Stage 2 makes the SICR rule, and the PD behind it, the most judgemental and most audited part of the standard.
flowchart LR
UCI[UCI card data] --> PORT[Synthetic portfolio layer]
PORT --> SC[Scorer on the one-month label<br/>Optuna: logistic vs monotone GBM]
SC --> BR[Bridge to 90 DPD<br/>over the observed 3 months]
BR --> MIG[Migration chain<br/>12-month PD and term structure]
WB[World Bank GDP growth] --> MAC[Scenarios and satellite model]
MIG --> ECL
MAC --> ECL
PORT --> LGD & EAD --> ECL[ECL, staging, discounting]
ECL --> AUD[Audit layer and report]
The PD model has three steps, kept apart in pd_model.py.
- Scorer. The UCI target is a missed payment in the month after the observation date (21.3% of live accounts), not a 90 DPD default. I fit it with two families, a regularised logistic regression and a histogram gradient-boosted model with monotonic constraints (PD rises with delinquency status, delinquency count and utilisation, falls with the payment ratio), tuned with Optuna (TPE, 25 trials per family, 5-fold stratified CV AUC). The GBM is used only if it beats the logistic by more than 0.005 AUC. Sex, marital status and education are excluded from the features.
- Bridge to the default definition. The scorer's log-odds are mapped by a two-parameter logistic to the probability of reaching 90 DPD within the three months the data observe (July to September 2005, from a June origin). This is the part of the horizon problem the data can actually test.
- Extension to 12 months. The migration chain (one-month matrix over eight PD grades plus absorbing default, estimated from the June to September snapshots) gives each grade a 12-month cumulative default probability. An account's 12-month PD is read from a monotone log-log curve through the grade anchor points, so it never falls as the window PD rises. The lifetime shape beyond month 3 comes from the same chain, anchored to the account's 12-month PD.
Other components: LGD from collateral value, scenario shock, haircut, recovery delay and workout cost with an assumed unsecured LGD; EAD as drawn plus CCF times undrawn (revolving) or level-payment run-off (amortising); end-of-month discounting at the EIR; scenarios baseline, upside and downside weighted 50/20/30.
Staging: Stage 3 at 90 DPD. Stage 2 at 30 DPD or when the PD test fires (current 12-month PD at least 2.0 times the origination PD and at least 2 percentage points higher). Otherwise Stage 1. The origination PD is a proxy: the PD at the start of the observed window, or at booking for accounts newer than that, times lognormal noise (sigma 0.30) to reflect that it is not the real origination score.
Macro: logit(PD) is shifted by minus beta times the standardised GDP growth shock of the scenario and year. Growth is the World Bank East Asia and Pacific aggregate (NY.GDP.MKTP.KD.ZG, no API key); Taiwan is not in the World Bank API.
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,download]"
ecl run --config config.yaml # downloads UCI id 350 to data/ (gitignored), writes reports/ and docs/
pytest -q && ruff check . && ruff format --check .ecl run --config tests/fixtures/config_ci.yaml runs offline on a 2,000-row fixture; CI uses it.
Reporting date 30 September 2005, 29,414 accounts, NT$ millions. The full tables and nine audit-style
findings are in reports/ecl_audit_report.md.
| Stage | Accounts | EAD | ECL | Coverage |
|---|---|---|---|---|
| 1 | 22,036 | 2,321.6 | 100.1 | 4.31% |
| 2 | 6,915 | 592.3 | 105.8 | 17.86% |
| 3 | 463 | 30.2 | 20.2 | 67.13% |
| Total | 29,414 | 2,944.1 | 226.2 | 7.68% |
By scenario before weighting: baseline 210.2, upside 185.2, downside 280.2. Movement from August (opening 204.1): derecognised -3.7, new +8.8, transfers to Stage 2 +12.9, to Stage 3 +5.6, cures -2.0, other transfers -5.9, remeasurement +6.3, closing 226.2; the waterfall reconciles to zero.
| Model | CV AUC (5-fold, best of 25 trials) |
|---|---|
| Regularised logistic | 0.7315 (sd 0.0125) |
| Monotone GBM | 0.7455 (sd 0.0113) |
The GBM is selected (gain 0.014). The optimum C of the logistic sits at the loose end of its range, so regularisation buys nothing here; the gain comes from non-linearity, not from shrinkage.
Out-of-sample AUC on the label is 0.747 (95% bootstrap CI 0.734 to 0.761, 1,000 resamples, n = 8,862; development 0.756), Gini 0.494, KS 0.392. On the bridged outcome, reaching 90 DPD within three months, AUC is 0.875 (0.841 to 0.907) with 107 events among 8,788 out-of-sample accounts; mean predicted PD 1.19% against 1.22% observed. No grade is amber or red on the one-sided binomial test across the eight grades.
The data observe three months of 90 DPD outcomes. Months 4 to 12 are the migration chain's, and nothing in the file can test them. The choice matters more than any other in the engine:
| 12-month extension | Average 12-month PD | Closing ECL |
|---|---|---|
| Migration chain (used) | 10.55% | 226.2 |
| Chain hazard scaled x0.75 / x1.25 | 179.4 / 270.3 | |
| Constant hazard from month 3 (factor 4.0) | 4.59% | 110.4 |
The chain compresses grades towards the portfolio mean as the horizon grows, as migration-based term structures do, so the best grade (3-month PD 0.17%) reaches a 12-month PD of 4.7%. A constant hazard has no such mean reversion. Both are extrapolations; I use the chain and disclose the range.
Of 6,915 Stage 2 accounts, 3,949 (57.1%) are there on the 30 DPD backstop only, 674 (9.7%) on the PD deterioration test only, and 2,292 (33.1%) on both. In ECL terms 52.3, 10.3 and 43.2. The PD test is not decorative, but the backstop dominates because 22.7% of this book is already one or more payments late in September 2005. The origination proxy matters: with no noise on it, the PD-only share of Stage 2 falls to 4%, at sigma 0.60 it rises to 31% and Stage 2 grows from 23.5% to 30.6% of accounts.
I looked for a no-key series to estimate the satellite beta. Taiwan and a regional bank-NPL aggregate are not available from the World Bank API, so I used a panel of 15 East Asia and Pacific economies (224 country-years): the change in the log-odds of the bank NPL ratio on GDP growth and its lag, clustered by economy. The cumulative effect is -0.0069 per point of growth (95% CI -0.0156 to +0.0017), which is a beta of 0.012 per standard deviation of growth (95% CI -0.003 to 0.027). That is indistinguishable from zero. I do not read it as evidence of no macro sensitivity: an NPL ratio is a slow stock, shaped by write-offs and disposal programmes, and says little about a card default flow. The run keeps the assumed beta of 0.40. Closing ECL at the estimated beta is 210.7 against 226.2, so the result for this book is not driven by the choice, but the assumption is not supported by data either.
| Driver | ECL at first / second setting | Change |
|---|---|---|
| 12-month hazard x0.75 / x1.25 | 179.4 / 270.3 | -46.8 / +44.1 |
| Revolving CCF 40% / 80% | 192.4 / 260.0 | -33.8 / +33.8 |
| Unsecured LGD -10pp / +10pp | 195.4 / 256.9 | -30.8 / +30.8 |
| Behavioural life 12m / 36m | 196.0 / 247.7 | -30.2 / +21.5 |
| Downside weight 10% / 50% | 210.8 / 241.6 | -15.4 / +15.4 |
| Macro beta 0.2 / 0.6 | 217.4 / 236.6 | -8.7 / +10.5 |
| Origination PD noise sigma 0 / 0.6 | 223.8 / 237.5 | -2.4 / +11.3 |
| SICR multiple 3.0x / 1.5x | 222.3 / 235.0 | -3.9 / +8.8 |
| Collateral haircut -10pp / +10pp | 225.8 / 226.7 | -0.3 / +0.5 |
Independent re-performance in pure Python, sharing only fitted parameters (scorer coefficients or tree tables, bridge, anchors, migration matrix) and no calculation code: 60 of 60 stratified accounts agree on stage and ECL, maximum difference 7e-10. The audit layer also tests that the migration matrix is stochastic with absorbing default, that the waterfall reconciles, that coverage rises with stage, and that ECL is non-negative and never above EAD.
All values are in config.yaml.
| Area | Assumption |
|---|---|
| Real data | UCI file: limit, age, six months of repayment status, bills, payments, next-month default. A status of n months delayed is read as 30 x n days past due |
| Reporting dates | September 2005 (closing), August 2005 (opening); four monthly snapshots give three transitions |
| Products | 30% amortising loans (6 to 48 months remaining, EIR 6 to 12%), 70% revolving (EIR 16%). The card balance is reinterpreted as the outstanding balance |
| Origination | Months on book uniform 1 to 48; 4% originated and 2% closed in September 2005 |
| Collateral | 35% of loans secured: property 50%, vehicle 30%, cash 20%; haircuts 25 / 40 / 5%; recovery 24 / 9 / 1 months; workout cost 3% |
| Unsecured LGD | 75% revolving, 55% amortising, assumed |
| CCF, life | CCF 60% on undrawn revolving limits; behavioural life 24 months |
| Scenarios | Weights 50 / 20 / 30; the downside also shocks collateral by -15% |
- The file has no outcomes beyond the month after September 2005, so months 4 to 12 of every PD are an extrapolation. The range is quantified above.
- The portfolio layer is synthetic: results describe this engine on this book, not any institution or the Taiwanese card market. The 21% label rate and 23% share already late are far above a bank book.
- Stage 3 uses collateral LGD on the reporting-date EAD; there is no workout curve, probation period, POCI treatment or disclosure table.
Yeh, I. C. (2009). Default of Credit Card Clients [Dataset]. UCI Machine Learning Repository.
https://doi.org/10.24432/C55S3H, licensed
CC BY 4.0. Related paper: Yeh, I. C., and Lien, C. H.
(2009), Expert Systems with Applications 36(2), 2473-2480. The full dataset is downloaded at run time
and not redistributed; tests/fixtures/uci_sample.csv is a 2,000-row sample kept for offline CI under
the same licence. Macro series: World Bank, indicators NY.GDP.MKTP.KD.ZG and FB.AST.NPER.ZS (CC BY 4.0).
Code: MIT, see LICENSE.
By Utku Fidan · utkufidan.com


