A company whose 5-year credit default swap costs 1.30% a year is being priced by the market as if it had a 10.5% chance of defaulting within five years, once we assume that bond holders recover 40% of what they are owed. Double all the spreads and that chance becomes 20.0%. This topic turns spreads into default probabilities, the same way the swaps topic turned par rates into discount factors.
Hazard rates and survival
Where we are. The last topics priced rate and equity products. Credit is the risk that a borrower does not pay. The market for insuring it is the credit default swap (CDS): the buyer of protection pays a premium every year, and if the company defaults, the seller pays the loss, which is the face value minus what is recovered.
The chance per year of defaulting, given that the company has survived so far. With a constant hazard h, the probability of still being alive after t years is exp(−h × t). A hazard of 2% means that about 2% of the companies still alive default each year.
A hazard rate is to credit what an interest rate is to discounting. We let it change from year to year but keep it constant inside each year, so that the survival probability at the end of year i is the exponential of minus the running total of the hazards.
Worked example 1. *Problem:* a company has a hazard rate of 2% in each of five years. What are its survival probabilities and its probabilities of defaulting in each year? *Plan:* take the running total of the hazards, exponentiate, and subtract neighbours. *Steps:* below.
survival = survival_from_hazard([0.02] * 5)1print(survival.round(6).tolist())2print(default_probabilities(survival).round(6).tolist(), round(float(default_probabilities(survival).sum()), 6), round(1 - float(survival[-1]), 6))
[0.980199, 0.960789, 0.941765, 0.923116, 0.904837] [0.019801, 0.019409, 0.019025, 0.018648, 0.018279] 0.095163 0.095163
- 1The survival probability at the end of each year.
- 2Default in each year, and the total.
*Check:* survival falls from 0.980199 after one year to 0.904837 after five. The probability of defaulting in each year is 0.019801, 0.019409, 0.019025, 0.018648 and 0.018279: slightly lower each year, because fewer companies are left to default. They add up to 0.095163, the same as 1 − 0.904837. *What to notice:* a 2% hazard is not a 2% chance of default each year of the original group; it is 2% of those still alive.
The two legs of a CDS
A CDS has two legs, like a swap. The premium leg is what the buyer pays: a spread s at the end of each year, but only as long as the company is alive. The protection leg is what the seller pays: the loss if default happens. To price them we need the discount factors P_i (from the Treasury curve) and the survival probabilities Q_i. We make two simplifying choices: premiums are paid once a year in arrears, and a default is taken to happen at the end of the year in which it occurs.
The present value of receiving 1 at the end of each year *only if the company has survived*: P_1 × Q_1 + P_2 × Q_2 + .... It is the annuity of the swaps topic with each payment weighted by the probability that it is made. The premium leg is the spread times the risky annuity.
Worked example 2. *Problem:* on the curve of par rates 2%, 3%, 4%, 4.5% and 5%, with the flat 2% hazard and a recovery of 40%, what are the two sides for a 5-year CDS? *Plan:* bootstrap the discount factors, then compute the risky annuity and the protection leg. *Steps:* below.
par = np.array([0.02, 0.03, 0.04, 0.045, 0.05])discount = bootstrap_discount(par)survival = survival_from_hazard([0.02] * 5)print(round(float(discount.sum()), 6), round(risky_annuity(discount, survival, 5), 6))1print(round(protection_leg(discount, survival, 0.4, 5), 6))2
4.42497 4.178543 0.050647
- 1The risky annuity is smaller than the ordinary annuity.
- 2The protection leg per unit of notional.
*Check:* the ordinary annuity is 4.424970 and the risky annuity 4.178543: the chance of default removes about 5.6% of the premium payments. The protection leg is 0.050647 per unit of notional, so the seller expects to pay about 5.1% of the notional in present value over five years. *What to notice:* the two legs are measured in different units. Protection is a sum of amounts per unit of notional, and the premium is a rate times an annuity, so the ratio of the two is a rate: the par spread.
The par spread and the credit triangle
The par spread is the premium for which the two legs are worth the same, so that the CDS costs nothing to enter. It is the number quoted in the market. An old CDS, bought at a different spread, has a value: the protection it will pay minus the premium it will cost.
Worked example 3. *Problem:* find the par spread of the 5-year CDS of example 2, and the value of one million of protection bought at a spread of 1%. *Plan:* divide the legs, then subtract the premium. *Steps:* below.
spread = par_spread(discount, survival, 0.4, 5)1print(round(spread, 6), round(0.6 * 0.02, 6))2print(round(cds_value(discount, survival, 0.4, 5, 0.01, 1e6), 2), round(cds_value(discount, survival, 0.4, 5, 0.01, 1e6, buy_protection=False), 2))print(round(cds_value(discount, survival, 0.4, 5, spread, 1e6), 6))
0.012121 0.012 8861.87 -8861.87 0.0
- 1The par spread against loss given default times the hazard.
- 2Buyer and seller of the 1% CDS.
*Check:* the par spread is 1.2121%, close to (1 − 0.4) × 2% = 1.2%. This approximation is the credit triangle: spread ≈ loss given default × hazard. A buyer who pays 1% when the market asks for 1.2121% holds an asset worth 8,861.87 per million; the seller has −8,861.87. At the par spread the value is 0. *What to notice:* the triangle lets you move between spreads and hazards in your head: a 1.2% spread with a 40% recovery means a 2% yearly chance of default.
Bootstrapping hazard rates
In the market the spreads are given and the hazards are unknown. We reverse the calculation, one maturity at a time, exactly like the bootstrap of discount factors. The 1-year spread fixes the hazard of year 1. The 2-year spread then fixes the hazard of year 2, because the first year is already known, and so on.
The key point is that for maturity i the only unknown is the survival Q_i, and the par condition is linear in it. Write A for the premium of the earlier years and B for the protection of the earlier years, both known. Then the equation s_i × (A_sum + P_i × Q_i) = B_sum + (1 − R) × P_i × (Q_(i−1) − Q_i) can be solved for Q_i without any search, and the yearly hazard is h_i = ln(Q_(i−1) / Q_i).
Worked example 4. *Problem:* the market spreads for 1 to 5 years are 0.60%, 0.80%, 1.00%, 1.15% and 1.30%, with a recovery of 40%. What hazards and survival probabilities do they imply on the curve of example 2? *Plan:* bootstrap, then check that each CDS reprices. *Steps:* below.
spreads = [0.0060, 0.0080, 0.0100, 0.0115, 0.0130]hazards = bootstrap_hazards(discount, spreads, 0.4)1survival = survival_from_hazard(hazards)print(hazards.round(6).tolist())print(survival.round(6).tolist(), round(1 - float(survival[-1]), 6))print([round(par_spread(discount, survival, 0.4, n), 6) for n in range(1, 6)])2
[0.00995, 0.016719, 0.023839, 0.027617, 0.033677] [0.990099, 0.973683, 0.950746, 0.924849, 0.894222] 0.105778 [0.006, 0.008, 0.01, 0.0115, 0.013]
- 1One hazard per year.
- 2Every CDS must reprice at its quoted spread.
*Check:* the hazards are 0.995%, 1.67%, 2.38%, 2.76% and 3.37%: they rise because the spread curve rises. The 5-year survival is 0.894222, a 10.58% chance of default, and the par spreads computed from these survival probabilities are exactly 0.60%, 0.80%, 1.00%, 1.15% and 1.30%. *What to notice:* the 1-year hazard is just below 0.60% / 0.60 = 1.00%, because the premium is paid at the end of the year. The later hazards are far above spread / 0.6, because a spread is an average over the whole life of the CDS, and an average that keeps rising needs ever higher yearly hazards.
The credit curve on three real days
Worked example 5. *Problem:* use the same spread curve on the US Treasury curve of three days, and see how much the discount curve matters. *Plan:* study bootstraps hazards on each day's discount factors, checks repricing, values a 1% CDS bought today, compares with the credit triangle and doubles the spreads. *Steps:* below.
treasury = load_treasury()out = study(treasury)1for date, row in out.items(): print(date, [round(h, 4) for h in row["hazards"]], round(row["default_5y"], 5), round(row["mtm"]), round(row["stress_5y"], 4))
2022-01-03 [0.01, 0.0166, 0.0234, 0.0269, 0.0323] 0.1035 13759 0.1965 2023-07-03 [0.01, 0.0167, 0.0237, 0.0273, 0.0329] 0.10465 12501 0.1986 2026-10-09 [0.01, 0.0168, 0.0238, 0.0275, 0.0333] 0.10536 12358 0.2
- 1One result per date.
*Check:* the 5-year default probability is 10.35% in January 2022, 10.47% in July 2023 and 10.54% on 9 October 2026, and the hazards barely move. The value of a 1% CDS bought today is 13,759, 12,501 and 12,358 per million, and it falls as rates rise because the protection arrives later. Doubling the spreads raises the 5-year probability of default to about 19.6%, 19.9% and 20.0%. *What to notice:* the spreads decide the hazards; the discount curve only matters in the second decimal. That is why credit is a risk of its own, not a consequence of rates.
The hazards found here are *risk-neutral*: they are what makes the CDS price right, and they include the compensation that investors demand for bearing default risk. They are usually higher than the default rates actually seen in history. Use them to price other contracts on the same company, not to forecast how many companies will fail.
- FunctionQuestion it answers
- survival_from_hazard(hazards)How likely is the company to be alive each year?exp of minus the running sum
- default_probabilities(survival)How likely is it to default in each year?Q_(i-1) - Q_i
- risky_annuity(discount, survival, n)What is the premium leg per unit of spread?P_i times Q_i
- protection_leg(discount, survival, recovery, n)What does the seller expect to pay?loss given default times P_i times default probability
- par_spread(discount, survival, recovery, n)Which premium makes the CDS worth nothing?protection over annuity
- cds_value(discount, survival, recovery, n, spread, notional, buy_protection)What is an old CDS worth?protection minus premium
- bootstrap_hazards(discount, spreads, recovery)Which hazards give the quoted spreads?one maturity at a time, linear in Q_i
What you will build
The lab follows the lecture. Tasks 1 and 2 turn hazard rates into survival and default probabilities. Tasks 3 and 4 write the two legs of a CDS, and task 5 divides them into the par spread. Task 6 values a CDS bought earlier, for either side. Task 7 is the heart of the topic: the bootstrap of hazard rates from spreads. Task 8 runs everything on three days of the real Treasury curve.
Next topic: a CDS prices the default of one company, as seen from the seller of protection. The next one, XVA overview, looks at what happens when the *other side of a derivative* might default, and what that does to the price.
Lab · what's graded
8 tasks · 100 pts- Survival probabilities10 pts
- Default probabilities5 pts
- The risky annuity10 pts
- The protection leg10 pts
- The par spread10 pts
- The value of a CDS10 pts
- Bootstrapping hazard rates20 pts
- The credit curve on three days25 pts