SigmaField

Practice Credit

Price default risk with a hazard rate

Medium+25 pointsAbout 35 minutesCredit

The brief

A credit desk follows a company whose 5-year bond trades at a spread of 210 basis points over the risk-free rate. The bank's lending team wants to lend the same company $20 million for 4 years, repaid in instalments, and needs the loan's fair value.

The desk models default with a constant hazard rate λ\lambda. When the company defaults, a lender recovers 40% of what it is owed at that moment. Calibrate λ\lambda to the bond, then value the loan with it.

Your task

  1. Write default_probability(hazard, t0, t1): the probability that the company defaults between times t0 and t1, seen from time 0. Raise ValueError unless hazard is at least 0 and 0≤t0≤t10 \le t_0 \le t_1.
  2. Write risky_value(schedule, r, hazard, recovery): the value today of a schedule of payments from the company, discounted at the continuous rate r. Raise ValueError if hazard is negative or recovery is outside [0,1)[0, 1).
  3. Write hazard_from_spread(spread, schedule, r, recovery): the hazard rate at which risky_value equals the bond's market price. Raise ValueError if spread is negative, or if no hazard rate between 0 and 1 gives that price.

Each schedule entry (t, amount, exposure) is a payment of amount at time t, made only if the company has not defaulted by then. exposure is what the company owes between the previous payment time (or 0) and t. A default in that period pays recovery times exposure at once.

The market prices the bond by discounting each payment aia_i at the rate rr plus the spread ss:

P=∑iai e−(r+s) tiP = \sum_i a_i\,e^{-(r + s)\,t_i}

The data

RATE is the risk-free rate, continuously compounded; SPREAD and RECOVERY are the bond's spread and the recovery rate. BOND is per 100 of face value. LOAN is in $ millions: $2.5 million of principal every six months, with interest at 6% a year on what is still owed.

Hint: Payments that need survival

Lesson 2.5.5 gives the chance of surviving to time tt as e−λte^{-\lambda t}, and the default time's density as λe−λt\lambda e^{-\lambda t}. A payment at tt is worth its amount times e−rte−λte^{-rt}e^{-\lambda t}. The chance of default between t0t_0 and t1t_1 is the integral of the density between them (lesson 2.5.3).

Hint: The value of recovery

A default at time tt in period ii pays REiR E_i then, where RR is the recovery rate and EiE_i the exposure. Weight each moment by the density and discount it: integrate REi λe−(r+λ)tR E_i\,\lambda e^{-(r + \lambda)t} from ti−1t_{i-1} to tit_i. It is lesson 2.5.5's stream with a hazard rate, over one period.

Hint: Solving for the hazard rate

The value falls as λ\lambda rises, so a root lies between 0 and 1 when the price lies between the values there. Bisection or brentq finds it (lesson 1.3.2). As a check, λ\lambda should come out close to s1−R\frac{s}{1 - R}.