Credit loss and impairment
calculate_credit_lossCredit-risk engine (IFRS 9 / HKFRS 9). Compute 12-month, lifetime, and staged expected credit loss, PD/LGD/EAD, provision matrices, hazard rates, and CVA/DVA. Use this for impairment, fair-value credit adjustment, and loan-loss provisioning; for the credit component of a specific convertible bond use calculate_convertible_bond, and for liquidity, control or marketability discounts rather than credit loss use calculate_fair_value_adjustment. Methods: ecl_12m: ead, pd, lgd; ecl_lifetime: ead, pd_lifetime, lgd; ecl_staged: ead, pd_12m, pd_lifetime, lgd, stage; provision_matrix: receivables_ageing, loss_rates; pd_from_spread: credit_spread, recovery, tenor_years; cumulative_pd: annual_pd, years; hazard: hazard_rate, tenor_years; cva_dva: exposure_profile, pd, lgd, discount_rate. Supply exactly one method with its declared inputs (no defaults). An unknown method, a missing input, or an extra field returns an error envelope (code INVALID_ARGUMENT) instead of raising.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pd | No | Probability of default over the horizon, in [0,1]. | |
| ead | No | Exposure at default in currency units. | |
| lgd | No | Loss given default in [0,1] (1 - recovery rate). | |
| stage | No | IFRS 9 stage (1, 2 or 3). | |
| years | No | Number of projection years n; equal len(cash_flows) when both are supplied. | |
| method | Yes | Formula to apply; the tool description lists the exact inputs each value requires. | |
| pd_12m | No | 12-month PD in [0,1]. | |
| recovery | No | Recovery rate in [0,1]. | |
| annual_pd | No | Annual PD in [0,1]. | |
| loss_rates | No | Loss rate per ageing bucket. | |
| hazard_rate | No | Default hazard rate as a decimal. | |
| pd_lifetime | No | Lifetime PD in [0,1]. | |
| tenor_years | No | Tenor in years (>0). | |
| credit_spread | No | Credit spread over the risk-free rate (decimal). | |
| discount_rate | No | Discount rate as a decimal (0.10 = 10%); pre-tax when method=viu_pre_tax. | |
| exposure_profile | No | Expected exposure per period. | |
| receivables_ageing | No | Ageing buckets [{bucket, amount}]. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | No | Error detail, present only when status='error'. | |
| steps | No | Ordered computation steps, when the method reports them. | |
| value | No | Primary result: a number for scalar methods, an object for valuation methods. | |
| method | No | Method or tool name that produced the result. | |
| status | Yes | 'ok' on success, 'error' on failure. | |
| ticker | No | Ticker the result pertains to, when applicable. | |
| assumptions | No | Inputs and assumptions used, echoed for traceability. | |
| formula_ref | No | Formula or standards reference for the method. | |
| data_timestamp | No | ISO-8601 UTC timestamp of the underlying data, when fetched. |