CRED Credit Risk Modeling
Modeling the probability of default — when counterparties can't pay
Learning Objectives
- •Understand credit risk and probability of default
- •Know structural vs reduced-form credit models
- •See how credit risk relates to trading
Explain Like I'm 5
Credit risk is the risk that someone who owes you money doesn't pay. In trading, this is counterparty risk — your broker, your clearing house, your prop firm could theoretically go bust. Credit models estimate the PROBABILITY of default and the expected loss. It's insurance math applied to financial institutions.
Think of It This Way
Credit risk modeling is like being a bookie deciding which gamblers to extend credit to. Some gamblers (AAA rated) almost always pay up. Others (junk rated) might disappear. You set different terms (interest rates) based on your estimate of each person's reliability.
1Credit Risk Basics
2Structural vs Reduced-Form Models
Key Formulas
Expected Loss
Expected loss = probability of default x fraction lost if default x exposure amount. This is the basis of all credit risk management.
Survival Probability
Probability of NO default by time T, given constant hazard rate lambda. Higher lambda = more risky = lower survival probability.
Hands-On Code
Credit Risk Calculator
import numpy as np
def credit_risk_analysis(pd, lgd, ead, n_years=5, n_sims=10000):
"""Monte Carlo credit risk simulation."""
uniform = np.random.uniform(0, 1, (n_sims, n_years))
defaults = uniform < pd # True = default in that year
losses = []
for sim in range(n_sims):
default_years = np.where(defaults[sim])[0]
if len(default_years) > 0:
first_default = default_years[0] + 1
loss = lgd * ead * np.exp(-0.05 * first_default) # discounted
losses.append(loss)
else:
losses.append(0)
losses = np.array(losses)
print(f"=== CREDIT RISK ANALYSIS ===")
print(f"PD: {pd:.2%} per year")
print(f"LGD: {lgd:.0%}")
print(f"EAD: {ead:,.0f}")
print(f"Expected loss: {np.mean(losses):,.0f}")
print(f"P(any default in {n_years}y): {(losses>0).mean():.2%}")
print(f"VaR 99%: {np.percentile(losses, 99):,.0f}")
# credit_risk_analysis(pd=0.02, lgd=0.45, ead=100000)Monte Carlo simulation of credit default events, computing expected loss, default probability over multi-year horizons, and credit VaR.
Knowledge Check
Q1.A counterparty has PD=5%, LGD=60%, and your EAD is $100K. What's the expected loss?
Assignment
Simulate credit risk for a portfolio of 10 counterparties with different PDs. Compute portfolio-level expected loss and VaR. How does default correlation affect portfolio risk?