20 — Z-Spread and Credit Curves¶
Free learning pack¶
- PIMCO Education Center — Understanding Duration
resources/fixed_income.mdreference/fixed_income/z_spread.md,credit_curves.md
Do not search for more material until these are insufficient.
PREDICT¶
A corporate bond's nominal yield spread (its YTM minus a single Treasury benchmark yield) is 220bp. Its Z-spread, measured against the whole Treasury zero curve, comes out to 205bp. What does the 15bp difference tell you — is it credit risk, or something about the curve's shape?
Formula¶
Solve for s in:
Price = sum_t CF_t / (1 + (z(t)+s)/frequency)^(t*frequency)
No closed form — this is a root-find over s.
import pandas as pd
from pm.fixed_income.bond import bond_cashflows
from pm.fixed_income.curve import interpolate_zero_rate
curve = pd.read_csv("../../data/mock_curve.csv")
curve_tenors = curve.tenor_years.to_numpy()
curve_rates = curve.treasury_par_yield.to_numpy() # treat as the zero curve for this exercise
corp_price = 96.50 # a 5Y corporate bond trading below the par curve
face, coupon_rate, years, frequency = 100.0, 0.05, 5.0, 2
times, flows = bond_cashflows(face, coupon_rate, years, frequency)
# MANUAL FIRST:
# write a function `_price_at_spread(spread)` that discounts `flows` at
# each `times[i]` using interpolate_zero_rate(times[i], curve_tenors,
# curve_rates) + spread, then use scipy.optimize.brentq to solve for the
# spread that reprices to corp_price.
spread = None
print(spread)
Credit curves, IG, and HY¶
No new code here — a credit curve is interpolated exactly like a rates
curve (interpolate_zero_rate), just on spread points instead of yield
points. Read reference/fixed_income/credit_curves.md in full, then
answer:
PREDICT¶
In a risk-off scenario, do you expect an HY credit curve to steepen or flatten relative to IG? (Hint: think about which end of the curve prices near-term default risk.)
Experiment¶
Re-run the Z-spread solve with corp_price closer to the par curve's
implied price (i.e. a smaller true spread) and confirm the solved spread
shrinks accordingly.
Reference¶
reference/fixed_income/z_spread.md
reference/fixed_income/credit_curves.md
reference/fixed_income/oas.md (what Z-spread misses for optioned bonds)
Promote¶
Use src/pm/fixed_income/credit.py::z_spread only after your own
implementation.
Test¶
pytest tests/test_fixed_income.py
ORAL CHECK¶
Explain to a PM why Z-spread is a better credit measure than a nominal yield spread to a single benchmark point, and one case where even Z-spread is misleading.
Try /tutor fixed-income z-spread for an adaptive walkthrough.