Building a Credit Curve#
A credit curve gives the probability that a reference entity has survived to each future date. It is built from CDS spreads for several maturities, in the same way as an interest rate curve is built from swaps. This page shows how a curve is bootstrapped from spreads, with a worked example in Python.
The method#
The curve is described by a hazard rate that is constant between the maturities of the quotes. For maturities of 1, 3 and 5 years, the hazard rate is one number for 0 to 1 years, one for 1 to 3 years, and one for 3 to 5 years. See Credit Risk Basics for the hazard rate and the survival probability \(Q(t)\).
For a CDS with maturity \(T\) and premium dates \(t_1, \dots, t_n\), the par spread is the premium that makes the two legs equal:
The numerator is the protection leg, which is the loss given default times the probability of default in each period, discounted. The denominator is the risky annuity, which is the premium of one unit paid for as long as the entity survives. \(D(t)\) is the discount factor and \(\Delta_i\) is the length of period \(i\). This version leaves out the premium that has accrued at the time of a default, which is small.
The curve is bootstrapped one maturity at a time. The hazard rate of the first segment is chosen so that the 1-year CDS is repriced exactly. It is then held fixed, and the hazard rate of the second segment is chosen so that the 3-year CDS is repriced, and so on. This needs a number from a solver, not a formula.
A worked example#
The example below uses a recovery of 40%, a flat discount rate of 3%, quarterly premiums, and par spreads of 60bp, 100bp and 130bp for 1, 3 and 5 years. It then:
Bootstraps the hazard rate for each segment.
Compares it with the credit triangle estimate.
Reports the survival and default probabilities, and reprices each quote from the curve to check it.
Python code
"""Bootstrap a piecewise-constant hazard rate curve from CDS par spreads, then reprice the quotes."""
import numpy as np
recovery = 0.40
disc_rate = 0.03 # flat, continuously compounded
quotes = {1: 0.0060, 3: 0.0100, 5: 0.0130} # CDS par spreads by maturity, as decimals (60, 100, 130bp)
dt = 0.25 # quarterly premium payments
ends = np.array(sorted(quotes)) # the hazard rate is constant between these dates
starts = np.concatenate(([0.0], ends[:-1]))
def survival(hazard, t):
"""Probability of no default by time t for a piecewise-constant hazard rate."""
time_in_segment = np.clip(np.minimum(t, ends) - starts, 0.0, None)
return np.exp(-(hazard * time_in_segment).sum())
def par_spread(hazard, maturity):
"""Premium that makes the protection leg equal the premium leg (accrued premium on default ignored)."""
dates = np.arange(dt, maturity + dt / 2, dt)
df = np.exp(-disc_rate * dates)
q = np.array([survival(hazard, t) for t in np.concatenate(([0.0], dates))])
protection = (1 - recovery) * (df * (q[:-1] - q[1:])).sum()
risky_annuity = (dt * df * q[1:]).sum()
return protection / risky_annuity
# Bootstrap: solve for each segment in turn, so that earlier segments stay fixed
hazard = np.zeros(len(ends))
for k, maturity in enumerate(ends):
lo, hi = 0.0, 1.0
for _ in range(100):
hazard[k] = 0.5 * (lo + hi)
if par_spread(hazard, maturity) < quotes[maturity]:
lo = hazard[k]
else:
hi = hazard[k]
hazard[k] = 0.5 * (lo + hi)
print(f"Recovery rate: {recovery:.0%}")
print(f"{'Segment':>9} {'Quote':>8} {'Hazard rate':>12} {'Credit triangle':>16}")
for k, maturity in enumerate(ends):
approx = quotes[maturity] / (1 - recovery)
print(f"{starts[k]:3.0f}-{maturity:<3.0f}y {quotes[maturity] * 1e4:6.0f}bp {hazard[k] * 100:11.3f}% {approx * 100:15.3f}%")
print()
print(f"{'Maturity':>9} {'Survival':>10} {'Default prob':>13} {'Repriced spread':>16}")
for maturity in ends:
q = survival(hazard, maturity)
print(f"{maturity:8.0f}y {q * 100:9.2f}% {(1 - q) * 100:12.2f}% {par_spread(hazard, maturity) * 1e4:13.1f}bp")
The output is:
Recovery rate: 40%
Segment Quote Hazard rate Credit triangle
0-1 y 60bp 0.999% 1.000%
1-3 y 100bp 2.019% 1.667%
3-5 y 130bp 3.014% 2.167%
Maturity Survival Default prob Repriced spread
1y 99.01% 0.99% 60.0bp
3y 95.09% 4.91% 100.0bp
5y 89.52% 10.48% 130.0bp
Points to notice:
The curve reprices every quote exactly, which is the test of a correct bootstrap.
The hazard rate in a segment is higher than the credit triangle for the same quote in the later segments. The credit triangle gives the average hazard rate over the whole life, so when the curve rises the rate in the later segments must be higher than the average.
The probability of default by 5 years is 10.5%. This is a risk-neutral figure, and it is not a forecast.
A higher recovery assumption would give a higher hazard rate for the same spread, since a smaller loss is paid on each default. The recovery matters to the shape of the curve.
Practical points#
Shape: a curve that rises steeply can give a negative hazard rate in a segment, which is not possible. This points to inconsistent quotes, or an interpolation that is too rigid.
Interpolation: a piecewise constant hazard rate is the standard. Other methods give a smoother curve, and the choice changes the survival probabilities between the quoted points.
Discount curve: the curve uses the nominal discount curve of the contract’s currency. See Interest Rate Curve Build, Part 1: Instruments & Bootstrapping.
Standard model: the market’s standard model has its own conventions for the accrued premium and the dates. A curve built for pricing should match it where the quotes are given in that way.
A valuation control view#
Repricing: check that every input CDS is repriced to within a small tolerance, and that the check is run each day.
Quotes used: check the source of each quote, how recent it is, and whether it is a traded or an indicative level. A curve is only as good as its quotes. Single-name CDS are thin, and some tenors rarely trade.
Recovery and discounting: check that the recovery and the discount curve are those of the policy. Each changes the hazard rate for the same quote.
Reasonableness: the credit triangle gives a quick test of a hazard rate. A hazard rate that is far from the credit triangle without an explanation points to an error in a quote or a date.
Use of the curve: the same curve is used for CDS, for bonds and for counterparty risk. See CVA: Credit Valuation Adjustment. A wrong curve spreads to all of them.