Stress Testing¶
Multi-framework stress testing: EBA, BoE ACS, US CCAR/DFAST, and RBI.
EBA Stress Test¶
from creditriskengine.portfolio.stress_testing import EBAStressTest, MacroScenario
import numpy as np
scenario = MacroScenario(
name="Adverse",
horizon_years=3,
variables={
"gdp_growth": np.array([-0.04, -0.02, 0.01]),
"house_price_index": np.array([-0.15, -0.10, -0.03]),
},
)
eba = EBAStressTest(scenario)
result = eba.run(base_pds, base_lgds, base_eads)
BoE ACS¶
from creditriskengine.portfolio.stress_testing import BoEACSStressTest
boe = BoEACSStressTest(scenario, horizon_years=5)
result = boe.run(base_pds, base_lgds, base_eads, initial_cet1_ratio=0.12)
print(f"CET1 breach: {result['cet1_hurdle_breach']}")
creditriskengine.portfolio.stress_testing
¶
Macro stress testing framework.
Supports EBA, BoE ACS, US CCAR/DFAST, and RBI methodologies.
References
- EBA Methodological Note (EU-wide stress testing)
- Bank of England: Annual Cyclical Scenario (ACS) framework
- Federal Reserve: SR 15-18, SR 15-19 (CCAR/DFAST)
- RBI Master Circular on Stress Testing
MacroScenario
¶
A macroeconomic stress scenario.
Source code in creditriskengine\portfolio\stress_testing.py
EBAStressTest
¶
EBA stress test framework -- constrained bottom-up approach.
Implements the methodology used in the EU-wide stress testing exercise coordinated by the European Banking Authority.
Reference
- EBA Methodological Note (latest: 2023/2025 exercise)
- EBA GL/2018/04 on institutions' stress testing
Key features
- Static balance sheet assumption (portfolio composition frozen).
- 3-year projection horizon (baseline and adverse).
- Constrained bottom-up: banks use own models, EBA provides macro scenario and prescriptive constraints on key parameters.
- PD/LGD shifts derived from macro scenario translation.
- Regulatory PD floor applied (CRR Art. 160).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario
|
MacroScenario
|
Macro scenario with at least 3 years of projections. |
required |
horizon_years
|
int
|
Projection horizon (default 3, EBA standard). |
3
|
static_balance_sheet
|
bool
|
Whether to enforce static balance sheet. |
True
|
pd_floor
|
float
|
Regulatory PD floor (CRR Art. 160: 0.03% for corporate). |
0.0003
|
Source code in creditriskengine\portfolio\stress_testing.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | |
translate_macro_to_pd_stress(base_pds, gdp_sensitivity=2.0)
¶
Translate macro scenario to PD stress multipliers.
Simple linear translation: multiplier = 1 - sensitivity * gdp_growth_deviation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_pds
|
ndarray
|
Baseline PDs (unused, for interface consistency). |
required |
gdp_sensitivity
|
float
|
Sensitivity of PD to GDP growth deviation. |
2.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
PD multipliers per period (shape: horizon_years,). |
Source code in creditriskengine\portfolio\stress_testing.py
translate_macro_to_lgd_stress()
¶
Translate macro scenario to LGD add-ons.
Driven by house price index changes for secured lending. Negative HPI changes increase LGD.
Returns:
| Type | Description |
|---|---|
ndarray
|
LGD add-ons per period (shape: horizon_years,). |
Source code in creditriskengine\portfolio\stress_testing.py
run(base_pds, base_lgds, base_eads)
¶
Run full EBA stress test projection.
Translates the macro scenario into PD multipliers and LGD add-ons, then runs a multi-period projection under the static balance sheet assumption. PDs are floored at the regulatory minimum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_pds
|
ndarray
|
Baseline PDs (n_exposures,). |
required |
base_lgds
|
ndarray
|
Baseline LGDs (n_exposures,). |
required |
base_eads
|
ndarray
|
Baseline EADs (n_exposures,). |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with stressed PDs, LGDs, expected losses per period, |
dict[str, Any]
|
cumulative EL, and scenario metadata. |
Source code in creditriskengine\portfolio\stress_testing.py
BoEACSStressTest
¶
Bank of England Annual Cyclical Scenario (ACS) stress test.
The BoE ACS is a concurrent stress test applied to major UK banks and building societies. It uses a scenario calibrated to the current risk environment rather than a fixed severity, making it cyclical — the scenario becomes more severe as systemic risks build up.
Reference
- Bank of England: Stress testing the UK banking system (annual)
- PRA SS3/19: Model risk management for stress testing
Key features
- 5-year projection horizon (longer than EBA's 3-year).
- Scenario severity varies with the financial cycle.
- Hurdle rates: CET1, Tier 1 leverage, and systemic reference point.
- IFRS 9 transitional and fully loaded capital trajectories.
- Feedback effects from bank reactions (strategic management actions).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario
|
MacroScenario
|
Macro scenario with at least 5 years of projections. |
required |
horizon_years
|
int
|
Projection horizon (default 5, BoE standard). |
5
|
cet1_hurdle_pct
|
float
|
CET1 hurdle rate as fraction (default 4.5%). |
0.045
|
leverage_hurdle_pct
|
float
|
Leverage ratio hurdle (default 3.25%). |
0.0325
|
pd_floor
|
float
|
Regulatory PD floor (default 0.03%). |
0.0003
|
Source code in creditriskengine\portfolio\stress_testing.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 | |
translate_macro_to_pd_stress(gdp_sensitivity=2.5, unemployment_sensitivity=1.5)
¶
Translate BoE ACS macro scenario to PD stress multipliers.
Uses both GDP growth and unemployment rate as drivers (dual-factor), reflecting the BoE's more comprehensive macro-credit linkage.
PD multiplier = 1 - gdp_sens × (GDP - baseline_GDP) + unemp_sens × (unemployment - baseline_unemp)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdp_sensitivity
|
float
|
Sensitivity of PD to GDP growth deviation. |
2.5
|
unemployment_sensitivity
|
float
|
Sensitivity of PD to unemployment deviation. |
1.5
|
Returns:
| Type | Description |
|---|---|
ndarray
|
PD multipliers per period (shape: horizon_years,). |
Source code in creditriskengine\portfolio\stress_testing.py
translate_macro_to_lgd_stress(hpi_lgd_sensitivity=0.6)
¶
Translate BoE ACS macro scenario to LGD add-ons.
House price index (HPI) declines drive LGD increases for secured lending.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hpi_lgd_sensitivity
|
float
|
Multiplier converting HPI declines to LGD add-ons (default 0.6 per BoE ACS methodology; EBA uses lower values around 0.4). |
0.6
|
Returns:
| Type | Description |
|---|---|
ndarray
|
LGD add-ons per period (shape: horizon_years,). |
Source code in creditriskengine\portfolio\stress_testing.py
run(base_pds, base_lgds, base_eads, initial_cet1_ratio=0.12, total_rwa=None)
¶
Run the full BoE ACS stress test projection.
Translates the macro scenario into PD and LGD stress, projects losses over the 5-year horizon, and evaluates against BoE hurdle rates for CET1 and leverage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_pds
|
ndarray
|
Baseline PDs (n_exposures,). |
required |
base_lgds
|
ndarray
|
Baseline LGDs (n_exposures,). |
required |
base_eads
|
ndarray
|
Baseline EADs (n_exposures,). |
required |
initial_cet1_ratio
|
float
|
Starting CET1 ratio (default 12%). |
0.12
|
total_rwa
|
float | None
|
Total risk-weighted assets; defaults to sum(base_eads). |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with stressed PDs, LGDs, expected losses, cumulative EL, |
dict[str, Any]
|
CET1 trajectory, hurdle breach information, and scenario metadata. |
Source code in creditriskengine\portfolio\stress_testing.py
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 | |
CCARScenario
¶
US CCAR/DFAST stress testing with 9-quarter projection horizon.
Implements the Fed's Comprehensive Capital Analysis and Review framework.
Reference
- Federal Reserve: SR 15-18, SR 15-19 (CCAR/DFAST instructions)
- 12 CFR 252 Subpart E (stress testing requirements)
Key features
- 9-quarter projection horizon (Q1 through Q9).
- Baseline, adverse, and severely adverse scenarios.
- Pre-Provision Net Revenue (PPNR) hook for income projection.
- Capital adequacy assessment at each quarter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario
|
MacroScenario
|
MacroScenario used for the stress test. |
required |
horizon_quarters
|
int
|
Number of projection quarters (default 9). |
9
|
ppnr_quarterly
|
ndarray | None
|
Optional pre-provision net revenue per quarter (9,). If not provided, PPNR is assumed to be zero each quarter. |
None
|
Source code in creditriskengine\portfolio\stress_testing.py
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 | |
project_quarterly_losses(base_pds, base_lgds, base_eads, pd_quarterly_multipliers=None, lgd_add_ons_quarterly=None)
¶
Project quarterly credit losses over the CCAR horizon.
Quarterly PD is derived from annual PD
PD_q = 1 - (1 - PD_annual)^(1/4)
The stress multiplier is then applied to the quarterly PD.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_pds
|
ndarray
|
Annual PDs (n_exposures,). |
required |
base_lgds
|
ndarray
|
Baseline LGDs (n_exposures,). |
required |
base_eads
|
ndarray
|
Baseline EADs (n_exposures,). |
required |
pd_quarterly_multipliers
|
ndarray | None
|
Optional quarterly PD stress factors (horizon_quarters,). Defaults to 1.0 each quarter. |
None
|
lgd_add_ons_quarterly
|
ndarray | None
|
Optional LGD add-ons per quarter (horizon_quarters,). Defaults to 0.0. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with quarterly_losses matrix, per-quarter totals, |
dict[str, Any]
|
cumulative loss trajectory, and total loss. |
Source code in creditriskengine\portfolio\stress_testing.py
run(base_pds, base_lgds, base_eads, pd_quarterly_multipliers=None, lgd_add_ons_quarterly=None, initial_capital=0.0)
¶
Execute the full CCAR stress scenario with capital trajectory.
Combines credit loss projection with PPNR to compute net income and a quarter-by-quarter capital adequacy trajectory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_pds
|
ndarray
|
Annual baseline PDs (n_exposures,). |
required |
base_lgds
|
ndarray
|
Baseline LGDs (n_exposures,). |
required |
base_eads
|
ndarray
|
EAD array (n_exposures,). |
required |
pd_quarterly_multipliers
|
ndarray | None
|
PD stress multipliers per quarter. |
None
|
lgd_add_ons_quarterly
|
ndarray | None
|
Optional LGD add-ons per quarter. |
None
|
initial_capital
|
float
|
Starting capital buffer for capital trajectory. |
0.0
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with quarterly losses, PPNR, net income, capital trajectory, |
dict[str, Any]
|
minimum capital point, and summary statistics. |
Source code in creditriskengine\portfolio\stress_testing.py
RBIStressTest
¶
RBI (Reserve Bank of India) stress testing with sensitivity analysis.
Implements the RBI's stress testing framework as outlined in the RBI Master Circular on Stress Testing (DBOD.No.BP.BC.94/21.06.001) and the Financial Stability Report methodology.
Key features
- Severity-calibrated credit quality deterioration (NPA migration).
- Interest rate sensitivity analysis (EVE and NII impact).
- Liquidity sensitivity analysis (LCR impact from deposit outflows).
- Single-factor shock isolation for each risk driver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
severity
|
str
|
Stress severity level ('mild', 'moderate', or 'severe'). |
'moderate'
|
baseline_metrics
|
dict[str, float] | None
|
Optional dict with baseline values for sensitivity analysis. Keys: 'npa_ratio', 'car', 'net_interest_income', 'total_advances'. If not provided, sensitivity methods that require these will raise ValueError. |
None
|
Source code in creditriskengine\portfolio\stress_testing.py
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 | |
credit_quality_stress(base_pds, base_lgds, base_eads)
¶
Apply credit quality deterioration stress.
Simulates NPA migration per RBI's macro stress testing framework. PDs are multiplied by a severity-dependent factor and LGDs receive an additive stress.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_pds
|
ndarray
|
Baseline PDs (n_exposures,). |
required |
base_lgds
|
ndarray
|
Baseline LGDs (n_exposures,). |
required |
base_eads
|
ndarray
|
Baseline EADs (n_exposures,). |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float | str]
|
Dict with base EL, stressed EL, incremental provisions, and |
dict[str, float | str]
|
severity label. |
Source code in creditriskengine\portfolio\stress_testing.py
interest_rate_sensitivity(rate_shock_bps, duration_gap, total_assets, rate_sensitive_fraction=0.6, avg_risk_weight=0.75)
¶
Interest rate sensitivity analysis.
Estimates the impact of a parallel shift in interest rates on net interest income (NII) and economic value of equity (EVE).
Impact on EVE: -Duration_gap x Delta_Rate x Total_Assets
Requires baseline_metrics with 'net_interest_income' and 'total_advances'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rate_shock_bps
|
float
|
Interest rate shock in basis points (e.g. +200). |
required |
duration_gap
|
float
|
Duration gap (years) between assets and liabilities. |
required |
total_assets
|
float
|
Total asset value. |
required |
rate_sensitive_fraction
|
float
|
Fraction of advances that are rate-sensitive (default 0.6 per RBI guidelines). |
0.6
|
avg_risk_weight
|
float
|
Average portfolio risk weight used to approximate RWA from total assets (default 0.75). |
0.75
|
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dict with EVE impact, NII impact, and stressed CAR estimate. |
Source code in creditriskengine\portfolio\stress_testing.py
credit_quality_sensitivity(npa_increase_pct, provision_coverage_ratio=0.7, avg_risk_weight=0.75)
¶
Credit quality sensitivity analysis via NPA ratio shift.
Models the impact of an increase in non-performing assets on provisioning requirements and capital adequacy.
Requires baseline_metrics with 'npa_ratio', 'car', 'total_advances'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
npa_increase_pct
|
float
|
Percentage point increase in NPA ratio (e.g. 2.0 means NPA ratio rises by 2 pp). |
required |
provision_coverage_ratio
|
float
|
Provisioning coverage ratio for incremental NPAs (default 0.70). |
0.7
|
avg_risk_weight
|
float
|
Average portfolio risk weight used to approximate RWA from total advances (default 0.75). |
0.75
|
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dict with stressed NPA ratio, incremental provisions, and CAR impact. |
Source code in creditriskengine\portfolio\stress_testing.py
liquidity_sensitivity(deposit_outflow_pct, hqla, total_deposits, net_cash_outflows_30d)
¶
Liquidity sensitivity analysis.
Estimates the impact of deposit outflows on the Liquidity Coverage Ratio (LCR) as per Basel III / RBI guidelines.
LCR = HQLA / Net cash outflows over 30 days
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deposit_outflow_pct
|
float
|
Assumed deposit run-off percentage. |
required |
hqla
|
float
|
High-quality liquid assets. |
required |
total_deposits
|
float
|
Total deposit base. |
required |
net_cash_outflows_30d
|
float
|
Baseline 30-day net cash outflows. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dict with baseline and stressed LCR, deposit outflow amount, |
dict[str, float]
|
and whether the RBI minimum LCR (100%) is breached. |
Source code in creditriskengine\portfolio\stress_testing.py
apply_pd_stress(base_pds, stress_multiplier, pd_cap=1.0)
¶
Apply stress multiplier to PDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_pds
|
ndarray
|
Baseline PD array. |
required |
stress_multiplier
|
float
|
Multiplicative stress factor. |
required |
pd_cap
|
float
|
Maximum PD cap. |
1.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Stressed PD array. |
Source code in creditriskengine\portfolio\stress_testing.py
apply_lgd_stress(base_lgds, stress_add_on, lgd_cap=1.0)
¶
Apply additive stress to LGDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_lgds
|
ndarray
|
Baseline LGD array. |
required |
stress_add_on
|
float
|
Additive stress increase. |
required |
lgd_cap
|
float
|
Maximum LGD cap. |
1.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Stressed LGD array. |
Source code in creditriskengine\portfolio\stress_testing.py
stress_test_rwa_impact(base_rwa, stressed_rwa)
¶
Calculate RWA impact from stress test.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_rwa
|
float
|
Baseline RWA. |
required |
stressed_rwa
|
float
|
Stressed RWA. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dict with absolute and relative impact. |
Source code in creditriskengine\portfolio\stress_testing.py
scenario_library()
¶
Predefined macroeconomic stress scenarios.
Provides a set of standard scenarios ranging from baseline to severely adverse, consistent with severity gradations used in EBA, CCAR, and RBI stress testing frameworks.
Returns:
| Type | Description |
|---|---|
dict[str, MacroScenario]
|
Dict mapping scenario name to MacroScenario object. |
dict[str, MacroScenario]
|
Scenarios provided: - 'baseline': Steady-state growth (GDP +2%, unemployment 4-4.5%) - 'mild_downturn': GDP -0.5% to +1.5%, unemployment 6-6.5% - 'moderate_recession': GDP -3% to +1%, unemployment rising 3pp - 'severe_recession': GDP -4% to +1%, unemployment 9-11% - 'stagflation': GDP -2%, inflation +4pp, rates +300bps - 'sovereign_crisis': GDP -5%, spreads +500bps, FX -20% |
Source code in creditriskengine\portfolio\stress_testing.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
multi_period_projection(base_pds, base_lgds, base_eads, pd_multipliers, lgd_add_ons, amortisation_rates=None)
¶
Project credit risk parameters over multiple periods with time-step simulation.
Applies period-specific stress factors to compute stressed PD, LGD, EAD, and expected loss projections. Optionally accounts for portfolio amortisation (run-off) across periods.
Useful for through-the-cycle projections in IFRS 9 ECL, CCAR, and EBA contexts. When amortisation_rates is None, a static balance sheet is assumed (EBA convention).
Reference
- EBA Methodological Note (static balance sheet)
- IFRS 9 B5.5.13 (lifetime ECL projection)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_pds
|
ndarray
|
Baseline PDs (n_exposures,). |
required |
base_lgds
|
ndarray
|
Baseline LGDs (n_exposures,). |
required |
base_eads
|
ndarray
|
Baseline EADs (n_exposures,). |
required |
pd_multipliers
|
ndarray
|
PD stress multipliers per period (n_periods,). |
required |
lgd_add_ons
|
ndarray
|
LGD additive stress per period (n_periods,). |
required |
amortisation_rates
|
ndarray | None
|
Optional per-period amortisation rate (n_periods,). Each entry is the fraction of EAD that amortises away per period. Defaults to zero (static balance sheet). |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with: - 'stressed_pds': (n_periods, n_exposures) stressed PD matrix - 'stressed_lgds': (n_periods, n_exposures) stressed LGD matrix - 'expected_losses': (n_periods, n_exposures) per-exposure EL - 'period_el': (n_periods,) total EL per period - 'period_eads': (n_periods,) total outstanding EAD per period - 'cumulative_el': float cumulative expected loss across all periods |
Raises:
| Type | Description |
|---|---|
ValueError
|
If array lengths are inconsistent. |
Source code in creditriskengine\portfolio\stress_testing.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
reverse_stress_test(base_pds, base_lgds, base_eads, target_el, pd_multiplier_range=(1.0, 10.0), tolerance=0.001)
¶
Find the PD stress multiplier that causes expected loss to hit a target.
Uses bisection method to search for the PD multiplier within the specified range that produces a portfolio expected loss equal to the target (within tolerance).
This is a key reverse stress testing technique: instead of asking "what is the loss under scenario X?", it asks "what scenario produces loss X?".
Reference
- BCBS 239: Principles for effective risk data aggregation
- EBA GL/2018/04: Guidelines on stress testing
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_pds
|
ndarray
|
Baseline PDs (n_exposures,). |
required |
base_lgds
|
ndarray
|
Baseline LGDs (n_exposures,). |
required |
base_eads
|
ndarray
|
Baseline EADs (n_exposures,). |
required |
target_el
|
float
|
Target expected loss amount to solve for. |
required |
pd_multiplier_range
|
tuple[float, float]
|
(low, high) search range for the PD multiplier. |
(1.0, 10.0)
|
tolerance
|
float
|
Convergence tolerance for absolute EL difference. |
0.001
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with: - 'multiplier': PD stress multiplier that achieves target EL - 'stressed_pds': Stressed PD array at the found multiplier - 'stressed_el': Actual EL at the found multiplier - 'iterations': Number of bisection iterations used |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the target EL is not achievable within the given range. |
Source code in creditriskengine\portfolio\stress_testing.py
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 | |
reverse_stress_capital_breach(base_pds, base_lgds, base_eads, cet1_capital, cet1_floor_pct=0.045, rwa_func=None)
¶
Find the PD multiplier that would breach the CET1 minimum.
Determines the stress severity (expressed as a PD multiplier) at which portfolio expected losses would erode CET1 capital below the regulatory minimum ratio.
The CET1 ratio is computed as
CET1_ratio = (CET1_capital - EL) / RWA
A breach occurs when CET1_ratio < cet1_floor_pct.
Reference
- CRR Art. 92: Own funds requirements
- BCBS d424: Minimum capital requirements (Basel III final)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_pds
|
ndarray
|
Baseline PDs (n_exposures,). |
required |
base_lgds
|
ndarray
|
Baseline LGDs (n_exposures,). |
required |
base_eads
|
ndarray
|
Baseline EADs (n_exposures,). |
required |
cet1_capital
|
float
|
Current CET1 capital amount. |
required |
cet1_floor_pct
|
float
|
Minimum CET1 ratio as a fraction (default 4.5%). |
0.045
|
rwa_func
|
Callable[..., float] | None
|
Optional callable(stressed_pds, base_lgds, base_eads) -> float to compute stressed RWA. If None, RWA = sum(base_eads). |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with: - 'breach_multiplier': PD multiplier at which CET1 is breached - 'stressed_el': Expected loss at breach point - 'cet1_at_breach': CET1 ratio at breach point - 'iterations': Number of bisection iterations |
Raises:
| Type | Description |
|---|---|
ValueError
|
If CET1 is already breached at multiplier=1.0 or if no breach occurs even at multiplier=10.0. |
Source code in creditriskengine\portfolio\stress_testing.py
1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 | |