IRB Risk Weights¶
The Internal Ratings-Based (IRB) approach allows banks to use internal estimates of PD, LGD, and EAD for capital calculations.
Basic Usage¶
from creditriskengine.rwa.irb.formulas import irb_risk_weight
# Corporate exposure
rw = irb_risk_weight(pd=0.01, lgd=0.45, asset_class="corporate", maturity=2.5)
print(f"Corporate RW: {rw:.2f}%") # ~75%
# SME with firm-size adjustment
rw_sme = irb_risk_weight(
pd=0.01, lgd=0.45, asset_class="corporate",
maturity=2.5, turnover_eur_millions=15.0
)
print(f"SME RW: {rw_sme:.2f}%") # Lower than general corporate
# Residential mortgage
rw_rre = irb_risk_weight(pd=0.005, lgd=0.15, asset_class="residential_mortgage")
# QRRE with transactor scalar
rw_qrre = irb_risk_weight(
pd=0.02, lgd=0.80, asset_class="qrre", is_qrre_transactor=True
)
Asset Classes¶
| Asset Class | Correlation | Maturity Adj | Reference |
|---|---|---|---|
corporate |
R ∈ [0.12, 0.24] | Yes | CRE31.5 |
sovereign |
Same as corporate | Yes | CRE31.5 |
bank |
Same as corporate | Yes | CRE31.5 |
residential_mortgage |
R = 0.15 (fixed) | No | CRE31.8 |
qrre |
R = 0.04 (fixed) | No | CRE31.9 |
other_retail |
R ∈ [0.03, 0.16] | No | CRE31.10 |
API Reference¶
creditriskengine.rwa.irb.formulas
¶
IRB Risk Weight Formulas — BCBS d424 (December 2017).
This module implements the regulatory risk weight functions for all IRB asset classes. Each function documents its exact source paragraph from the Basel III framework.
CRITICAL: These formulas directly affect bank capital requirements. Every parameter, threshold, and formula must be verified against the referenced Basel Committee text.
asset_correlation_corporate(pd)
¶
Asset correlation for corporate, sovereign, and bank exposures.
Formula (BCBS CRE31.5): R = 0.12 * (1 - exp(-50 * PD)) / (1 - exp(-50)) + 0.24 * (1 - (1 - exp(-50 * PD)) / (1 - exp(-50)))
Produces R in [0.12, 0.24]: - R -> 0.24 as PD -> 0 - R -> 0.12 as PD -> 1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pd
|
float
|
Probability of Default (annualized, in [0.0003, 1.0]) |
required |
Returns:
| Type | Description |
|---|---|
float
|
Asset correlation R in [0.12, 0.24] |
Source code in creditriskengine\rwa\irb\formulas.py
sme_firm_size_adjustment(turnover_eur_millions)
¶
SME firm-size adjustment to correlation for corporate exposures.
Formula (BCBS CRE31.6): Adjustment = -0.04 * (1 - (min(max(S, 5), 50) - 5) / 45)
Where S = annual turnover in EUR millions. - S is floored at EUR 5M and capped at EUR 50M - Maximum reduction is 0.04 (at S = EUR 5M) - No adjustment when S >= EUR 50M
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turnover_eur_millions
|
float
|
Annual sales/turnover in EUR millions |
required |
Returns:
| Type | Description |
|---|---|
float
|
Correlation adjustment (negative value to subtract from R) |
Source code in creditriskengine\rwa\irb\formulas.py
asset_correlation_residential_mortgage(pd)
¶
Asset correlation for residential mortgage exposures.
Formula (BCBS CRE31.8): R = 0.15
Fixed correlation of 0.15 per the 2017 Basel III reform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pd
|
float
|
Probability of Default (unused, kept for interface consistency) |
required |
Returns:
| Type | Description |
|---|---|
float
|
Fixed correlation of 0.15 |
Source code in creditriskengine\rwa\irb\formulas.py
asset_correlation_qrre(pd)
¶
Asset correlation for Qualifying Revolving Retail Exposures.
Formula (BCBS CRE31.9): R = 0.04
Fixed correlation for all QRRE exposures.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pd
|
float
|
Probability of Default |
required |
Returns:
| Type | Description |
|---|---|
float
|
Fixed correlation of 0.04 |
Source code in creditriskengine\rwa\irb\formulas.py
asset_correlation_other_retail(pd)
¶
Asset correlation for Other Retail exposures.
Formula (BCBS CRE31.10): R = 0.03 * (1 - exp(-35 * PD)) / (1 - exp(-35)) + 0.16 * (1 - (1 - exp(-35 * PD)) / (1 - exp(-35)))
Range: [0.03, 0.16]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pd
|
float
|
Probability of Default |
required |
Returns:
| Type | Description |
|---|---|
float
|
Asset correlation in [0.03, 0.16] |
Source code in creditriskengine\rwa\irb\formulas.py
maturity_adjustment(pd, maturity)
¶
Maturity adjustment factor for corporate, sovereign, bank exposures.
Formula (BCBS CRE31.7): b = (0.11852 - 0.05478 * ln(PD))^2 MA = (1 + (M - 2.5) * b) / (1 - 1.5 * b)
Where M = effective maturity in years.
For F-IRB: M = 2.5 years fixed (BCBS CRE32.47). For A-IRB: M = max(1, effective maturity), capped at 5 years. Retail exposures: NO maturity adjustment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pd
|
float
|
Probability of Default (>= 0.0003) |
required |
maturity
|
float
|
Effective maturity M in years |
required |
Returns:
| Type | Description |
|---|---|
float
|
Maturity adjustment factor (multiplier to capital requirement K) |
Source code in creditriskengine\rwa\irb\formulas.py
irb_capital_requirement_k(pd, lgd, correlation)
¶
IRB capital requirement K (before maturity adjustment).
Formula (BCBS CRE31.4): K = LGD * [N((1-R)^(-0.5) * G(PD) + (R/(1-R))^0.5 * G(0.999)) - PD]
Where: - N() = standard normal CDF - G() = standard normal inverse CDF - R = asset correlation - PD = probability of default (floored at 0.03%) - LGD = loss given default
The 0.999 confidence level = 99.9th percentile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pd
|
float
|
Probability of Default (>= 0.0003 floor applied) |
required |
lgd
|
float
|
Loss Given Default (in [0, 1]) |
required |
correlation
|
float
|
Asset correlation R |
required |
Returns:
| Type | Description |
|---|---|
float
|
Capital requirement K as a fraction of EAD |
Source code in creditriskengine\rwa\irb\formulas.py
irb_risk_weight(pd, lgd, asset_class, maturity=2.5, turnover_eur_millions=None, is_qrre_transactor=False, ead=1.0)
¶
Full IRB risk weight computation.
Formula (BCBS CRE31.4-31.10): RW = K * 12.5 * MA (corporate/sovereign/bank) RW = K * 12.5 (retail)
The 12.5 multiplier converts K to risk weight because Capital = 8% * RWA = K * EAD, so RW = K * 12.5.
PD Floor (CRE32.13): 0.03% for all non-defaulted exposures.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pd
|
float
|
Probability of Default |
required |
lgd
|
float
|
Loss Given Default |
required |
asset_class
|
str
|
One of 'corporate', 'sovereign', 'bank', 'residential_mortgage', 'qrre', 'other_retail' |
required |
maturity
|
float
|
Effective maturity in years (non-retail only) |
2.5
|
turnover_eur_millions
|
float | None
|
For SME firm-size correlation adjustment |
None
|
is_qrre_transactor
|
bool
|
If True, apply 0.75× RW scalar per CRE31.9 fn 15 |
False
|
ead
|
float
|
Exposure at Default (default 1.0) |
1.0
|
Returns:
| Type | Description |
|---|---|
float
|
Risk weight as a percentage (e.g., 75.0 means 75%) |
Source code in creditriskengine\rwa\irb\formulas.py
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 | |
double_default_rw(pd_obligor, pd_guarantor, lgd, maturity=2.5, asset_class='corporate')
¶
Double default risk weight using the substitution approach.
When a guarantee or credit derivative exists, the bank may substitute the guarantor's PD for the obligor's PD while retaining the asset correlation derived from the obligor's asset class.
Formula (BCBS CRE32.38-41): 1. Effective PD = max(PD_guarantor, PD_FLOOR) 2. Correlation R = derived from obligor's asset class using PD_obligor 3. K = IRB capital requirement using effective PD, obligor's R, and LGD 4. Apply maturity adjustment for non-retail asset classes 5. RW = K * 12.5
The guarantor PD is floored at 0.03% per CRE32.13.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pd_obligor
|
float
|
Probability of Default of the original obligor. |
required |
pd_guarantor
|
float
|
Probability of Default of the guarantor. |
required |
lgd
|
float
|
Loss Given Default (in [0, 1]). |
required |
maturity
|
float
|
Effective maturity in years (non-retail only). |
2.5
|
asset_class
|
str
|
One of 'corporate', 'sovereign', 'bank', 'residential_mortgage', 'qrre', 'other_retail'. |
'corporate'
|
Returns:
| Type | Description |
|---|---|
float
|
Risk weight as a percentage (e.g., 75.0 means 75%). |
Source code in creditriskengine\rwa\irb\formulas.py
equity_irb_rw(pd, equity_type='listed')
¶
IRB simple risk weight method for equity exposures.
Formula (BCBS CRE33): RW = max(floor, 2.5 * corporate_IRB_RW(PD, LGD=90%, M=5))
Where: - Listed equity: floor = 200% - Private/unlisted equity: floor = 300% - LGD is fixed at 90% per CRE33 - Maturity M is fixed at 5 years per CRE33 - The corporate IRB RW uses the standard corporate correlation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pd
|
float
|
Probability of Default. |
required |
equity_type
|
str
|
One of 'listed' or 'private'. |
'listed'
|
Returns:
| Type | Description |
|---|---|
float
|
Risk weight as a percentage (e.g., 200.0 means 200%). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If equity_type is not 'listed' or 'private'. |