Interest Rate Curves, Part 4: Curve Spreads#
Interest Rate Curves, Part 3: Global Solver & Jacobian shows how a global solver and its Jacobian build a curve from any set of quotes. This page applies them to a feature of the swap market that a bootstrap cannot handle: much of the trading is quoted in curve spreads, such as switches and flies, and not in outright swap rates. The page explains what the spreads are, why they are quoted, why they cannot be bootstrapped, and what they look like in the Jacobian. A worked example then shows what they add to the accuracy, the checking and the risk of a curve. Interest Rate Curves, Part 5: Regression Fits covers a different approach, which does not reprice the inputs exactly.
What they are#
In the earlier pages every input was an outright swap rate, and each one brought in exactly one new unknown. That is not how all of the swap market is quoted. Much of the trading, especially in the less liquid tenors, is done in curve spreads, and a production curve uses those quotes as inputs.
A switch is the spread between two swap rates, the long end less the short end. A fly (butterfly) is the belly of three swap rates against its two wings. With \(s(T)\) the par swap rate for maturity \(T\):
They are named by their tenors, so “2s10s” is the switch between the 2 year and the 10 year, and “5s7s10s” is the fly with the 7 year as the belly. Both are quoted in basis points. Each is a linear combination of outright swap rates, so its value is a weighted sum of par rates with the weights \(c_k\):
Conventions differ in the sign and the weights. Packages are often traded with weights that make the two legs equal in risk, not 1, 2 and 1, so the fly above is a simplified form. The name “swap spread” is not used here, as in some markets it means the swap rate less a government bond yield, which is a different thing.
Why they are used#
They trade as one package. A switch or a fly is executed in a single trade at one price, so the dealer has no exposure to the overall level of rates while quoting it. The bid-offer is quoted on the spread, and it can be tighter than the bid-offers on two or three outrights together.
The less liquid tenors trade mostly in spreads. An outright 7, 15 or 20 year swap is traded less often than the 2, 5, 10 and 30 year benchmarks, so its outright quote can be wide or stale. A fly such as 5s7s10s is how the 7 year is priced against two benchmark tenors that are liquid.
They carry information that the outrights do not. The slope and the curvature of the curve are what the market trades, and a spread quote is a direct measurement of them.
These statements depend on the market. In a market where the outrights are the liquid quote, a spread is no better than the two outrights that it is made from. The worked example later on this page shows how much depends on the relative bid-offer.
Why they cannot be bootstrapped#
The bootstrap needs each instrument to bring in one new unknown, using only unknowns that were found earlier. A switch or a fly breaks that. The 5s7s10s fly is there to fix the 7 year point, but it also contains the 10 year, which is not known until the 7 year is. The 7 and 10 year unknowns have to be solved together. The same is true in the long end, where the 15, 20 and 30 year points depend on each other through the flies that fix them.
An older workaround is to convert each spread into a synthetic outright. With the 5 and 10 year rates known, the 5s7s10s fly gives \(s(7) = \tfrac{1}{2}\,(\text{fly} + s(5) + s(10))\), and the bootstrap can then continue. It works when the set is exactly determined, but the noise in each quote is carried along the chain, it cannot weight the quotes by their reliability, and it cannot use a spread and an outright that overlap.
This is the main reason for a global solver. It treats every quote, whatever its type, as one equation in the full set of unknowns, and solves the whole set at once.
The shape of the Jacobian with spreads#
The Jacobian shows the problem exactly. The pattern below is for a curve with nine knots that is quoted with three outrights (1, 2 and 10 year), two switches (2s5s and 10s30s) and four flies. Compare it with the triangular pattern of nine outrights on Interest Rate Curves, Part 3: Global Solver & Jacobian:
Jacobian pattern, three outrights, two switches, four flies (condition number 58.0)
1Y 2Y 3Y 5Y 7Y 10Y 15Y 20Y 30Y
1Y * . . . . . . . .
2Y * * . . . . . . .
10Y * * * * * * . . .
2s5s * * * * . . . . .
10s30s * * * * * * * * *
2s3s5s * * * * . . . . .
5s7s10s * * * * * * . . .
10s15s20s * * * * * * * * .
15s20s30s * * * * * * * * *
Each row only reaches out as far as its longest tenor, but the matrix as a whole is not lower triangular. The rows that fix the 3 and 5 year knots both reach out to 5 years, the rows for the 7 and 10 year both reach out to 10 years, and the three rows that fix the 15, 20 and 30 year knots reach out to 20 or 30 years. The unknowns come in blocks of 2, 2 and 3 that have to be solved together. The matrix is block triangular, and that is the reason to solve for all the unknowns at once. The condition number rises from 45 to 58, so the problem is slightly more sensitive to the data.
How a global solver uses them#
In a global solver every quote, whatever its type, is one more residual. For an instrument with weights \(c\), the residual and its row of the Jacobian are
so the Jacobian row of a switch is the row of the long swap less the row of the short swap, and the row of a fly is twice the row of the belly less the rows of the wings. Nothing else changes in the solver. The residuals are divided by the noise \(\sigma_i\) of each quote, which is the weight \(w_i = 1/\sigma_i^2\) in the least-squares problem on Interest Rate Curves, Part 3: Global Solver & Jacobian. A quote with a wide bid-offer counts for little, and a tight one counts for a lot.
This also makes it possible to combine quotes. If a tenor has an outright quote and is also in a fly, both are used, each with its weight. There are then more quotes than unknowns, and the solver gives the best compromise and the residuals that show where the quotes disagree.
Worked example#
The example uses the swap-only curve from Interest Rate Curves, Part 1: Instruments & Bootstrapping as the true curve, with nine knots. It builds three sets of quotes, adds simulated noise to every quote in proportion to its assumed bid-offer, and solves for the curve each time. The noise levels are invented to show the mechanics:
Quote |
Noise (bp) |
Comment |
|---|---|---|
Outrights 1, 2, 5, 10 and 30 year |
0.5 |
Liquid benchmarks |
Outrights 3, 7, 15 and 20 year |
1.5 |
Less liquid, so wide or stale |
Switches (2s5s, 5s10s, 10s30s) and flies (2s3s5s, 5s7s10s, 10s15s20s, 15s20s30s) |
0.25 |
Assumed tighter, because they trade as packages |
The three sets are:
A, nine outrights. The standard input. This is the same as a bootstrap.
B, three outrights and six spreads. The 1, 2 and 10 year outrights, the switches 2s5s and 10s30s, and the four flies. It has nine quotes for nine unknowns, so the fit is exact, but the less liquid tenors are set by the flies.
C, everything. The nine outrights, three switches and four flies, which is 16 quotes for nine unknowns. They are weighted by \(1/\sigma^2\).
Python code
"""Curve switches and flies as inputs to a global solver, and what they do to accuracy, structure and risk."""
import numpy as np
from scipy.optimize import least_squares
from curve_example import PAR_RATES, PILLARS, bootstrap
from curve_global_example import N, curve_from, jacobian, par_rates, payer_pv
PIL = list(PILLARS) # the nine knots: 1, 2, 3, 5, 7, 10, 15, 20, 30
TRUE_PAR = np.array(PAR_RATES)
# name: (tenors, coefficients, assumed bid-offer noise in bp). The value of an instrument is sum(coef x par rate).
# outright : the par swap rate. switch: long end less short end. fly: 2 x belly less the two wings.
INSTRUMENTS = {
"1Y": ((1,), (1,), 0.5), "2Y": ((2,), (1,), 0.5), "5Y": ((5,), (1,), 0.5),
"10Y": ((10,), (1,), 0.5), "30Y": ((30,), (1,), 0.5),
"3Y": ((3,), (1,), 1.5), "7Y": ((7,), (1,), 1.5), "15Y": ((15,), (1,), 1.5), "20Y": ((20,), (1,), 1.5),
"2s5s": ((2, 5), (-1, 1), 0.25), "5s10s": ((5, 10), (-1, 1), 0.25), "10s30s": ((10, 30), (-1, 1), 0.25),
"2s3s5s": ((2, 3, 5), (-1, 2, -1), 0.25), "5s7s10s": ((5, 7, 10), (-1, 2, -1), 0.25),
"10s15s20s": ((10, 15, 20), (-1, 2, -1), 0.25), "15s20s30s": ((15, 20, 30), (-1, 2, -1), 0.25),
}
SET_A = ["1Y", "2Y", "3Y", "5Y", "7Y", "10Y", "15Y", "20Y", "30Y"] # nine outrights
SET_B = ["1Y", "2Y", "10Y", "2s5s", "10s30s", "2s3s5s", "5s7s10s", "10s15s20s", "15s20s30s"] # spreads for the rest
SET_C = SET_A + ["2s5s", "5s10s", "10s30s", "2s3s5s", "5s7s10s", "10s15s20s", "15s20s30s"] # everything, 16 quotes
def coefficients(names):
c = np.zeros((len(names), len(PIL)))
for i, name in enumerate(names):
for tenor, coef in zip(*INSTRUMENTS[name][:2]):
c[i, PIL.index(tenor)] = coef
return c
def noise_bp(names, scale=1.0, spread_noise=None):
out = []
for name in names:
sigma = INSTRUMENTS[name][2]
if spread_noise is not None and name[0].isdigit() and "s" in name:
sigma = spread_noise
out.append(sigma * scale)
return np.array(out)
def solve(names, quotes, sigma_bp):
"""Weighted least squares, each residual divided by its noise. Exactly determined sets give a zero fit."""
c = coefficients(names)
sigma = sigma_bp / 1e4
fun = lambda x: (c @ par_rates(curve_from(x), PIL) - quotes) / sigma
fit = least_squares(fun, -0.035 * np.array(PIL, float), method="lm", xtol=1e-13, ftol=1e-13)
return fit.x, fit.fun * sigma
def run(names, trials, rng, spread_noise=None):
"""Monte Carlo: simulate noisy quotes around the true curve, solve, and return the par rate errors in bp."""
c_all = coefficients(list(INSTRUMENTS))
all_names = list(INSTRUMENTS)
exact = dict(zip(all_names, c_all @ TRUE_PAR))
sigma_all = dict(zip(all_names, noise_bp(all_names, spread_noise=spread_noise)))
errors = np.zeros((trials, len(PIL)))
for t in range(trials):
noisy = np.array([exact[n] + rng.normal(0.0, sigma_all[n] / 1e4) for n in names])
x, _ = solve(names, noisy, np.array([sigma_all[n] for n in names]))
errors[t] = (par_rates(curve_from(x), PIL) - TRUE_PAR) * 1e4
return errors
if __name__ == "__main__":
base = bootstrap()
x_true = np.log(base.df(np.array(PIL, float)))
print("Assumed noise (bp): outrights 1Y 2Y 5Y 10Y 30Y 0.5, outrights 3Y 7Y 15Y 20Y 1.5, switches and flies 0.25\n")
# 1. Structure: which knots each instrument depends on. Exactly determined sets A and B.
for label, names in (("A: nine outrights", SET_A), ("B: three outrights, two switches, four flies", SET_B)):
c = coefficients(names)
j = jacobian(lambda x_: c @ par_rates(curve_from(x_), PIL), x_true)
print(f"1. Jacobian pattern, set {label} (condition number {np.linalg.cond(j):.1f})")
print(" " + " ".join(f"{p:>3}Y" for p in PIL))
for i, name in enumerate(names):
print(f" {name:>10} " + " ".join(f"{'*' if abs(j[i, k]) > 1e-9 else '.':>4}" for k in range(len(PIL))))
print()
# 2. Accuracy: the error in each par rate over 300 simulated quote snapshots.
rng = np.random.default_rng(11)
trials = 300
res = {label: run(names, trials, rng) for label, names in (("A", SET_A), ("B", SET_B), ("C", SET_C))}
print(f"2. RMS error of each par rate against the true curve, {trials} simulated snapshots (bp):")
print(f" {'Tenor':>6} {'A: outrights':>13} {'B: spreads':>11} {'C: all 16':>10}")
for k, tenor in enumerate(PIL):
print(f" {tenor:>5}Y " + " ".join(f"{np.sqrt(np.mean(res[s][:, k] ** 2)):>{w}.2f}" for s, w in (("A", 13), ("B", 11), ("C", 10))))
print(f" {'All':>6} " + " ".join(f"{np.sqrt(np.mean(res[s] ** 2)):>{w}.2f}" for s, w in (("A", 13), ("B", 11), ("C", 10))))
# 3. It depends on how tight the spread quotes are.
print("\n3. RMS error of the 7Y par rate (bp) as the bid-offer on switches and flies changes (outrights unchanged):")
print(f" {'Spread noise':>13} {'A: outrights':>13} {'B: spreads':>11} {'C: all 16':>10}")
k7 = PIL.index(7)
for spread_noise in (0.25, 0.5, 1.0, 1.5, 3.0):
row = [np.sqrt(np.mean(run(names, 120, rng, spread_noise)[:, k7] ** 2)) for names in (SET_A, SET_B, SET_C)]
print(f" {spread_noise:>10.2f}bp {row[0]:13.2f} {row[1]:11.2f} {row[2]:10.2f}")
# 4. Using the extra quotes to catch a bad one: the 7Y outright is 5bp stale, everything else is exact.
c_all = coefficients(SET_C)
quotes = c_all @ TRUE_PAR
quotes[SET_C.index("7Y")] += 5e-4
x_fit, residual = solve(SET_C, quotes, noise_bp(SET_C))
print("\n4. Sixteen quotes where the 7Y outright is 5bp stale: fitted less quoted, in bp and in noise units")
print(f" {'Quote':>10} {'Residual':>9} {'In sigmas':>10}")
for name, r in zip(SET_C, residual):
print(f" {name:>10} {r * 1e4:+8.2f} {r * 1e4 / INSTRUMENTS[name][2]:+9.1f}")
# 5. Curve risk in the spread quotes: a 6Y payer swap, set B. Jacobian against bump-and-rebuild.
cb = coefficients(SET_B)
quote_fn = lambda x_: cb @ par_rates(curve_from(x_), PIL)
j_b = jacobian(quote_fn, x_true)
strike = par_rates(base, [6])[0]
pv_fn = lambda x_: N * payer_pv(curve_from(x_), 6, strike)
d_pv_d_x = jacobian(lambda x_: np.array([pv_fn(x_)]), x_true)[0]
risk_jac = d_pv_d_x @ np.linalg.inv(j_b) * 1e-4
exact_b = cb @ TRUE_PAR
risk_bump = []
for i in range(len(SET_B)):
bumped = exact_b.copy()
bumped[i] += 1e-4
x_b, _ = solve(SET_B, bumped, noise_bp(SET_B))
risk_bump.append(pv_fn(x_b) - pv_fn(x_true))
print(f"\n5. Risk of a 6Y payer swap struck at par (PV {pv_fn(x_true):,.0f}) per +1bp in each set B quote:")
print(f" {'Quote':>10} {'Jacobian':>11} {'Rebuild':>11}")
for name, jac, bump in zip(SET_B, risk_jac, risk_bump):
print(f" {name:>10} {jac:11,.1f} {bump:11,.1f}")
The first test repeats the experiment 300 times with different random noise and measures the error of each par rate against the true curve:
RMS error of each par rate against the true curve, 300 simulated snapshots (bp):
Tenor A: outrights B: spreads C: all 16
1Y 0.52 0.50 0.53
2Y 0.47 0.53 0.30
3Y 1.48 0.55 0.29
5Y 0.50 0.57 0.27
7Y 1.53 0.39 0.28
10Y 0.48 0.48 0.27
15Y 1.59 0.53 0.30
20Y 1.52 0.56 0.32
30Y 0.52 0.56 0.31
All 1.09 0.52 0.33
The outrights give the curve the error of their worst quotes. In A, the 3, 7, 15 and 20 year points have an error of about 1.5 basis points, which is the noise on those outrights, and the benchmarks about 0.5.
The spreads fix the less liquid tenors. In B, the error at those tenors falls from about 1.5 to about 0.5 basis points, and the overall error from 1.09 to 0.52. The benchmark tenors are slightly worse, at 0.5 to 0.6 against 0.5, since they are now set from an outright plus a switch, and the noise of the two adds up.
Using everything is best. In C, the error is 0.33 overall, and under 0.35 at every tenor but the 1 year. The extra quotes average out the noise, and the 1 year, which has only one quote, is unchanged.
The second test changes how tight the spread quotes are, with the outrights unchanged, and shows the 7 year point:
RMS error of the 7Y par rate (bp) as the bid-offer on switches and flies changes (outrights unchanged):
Spread noise A: outrights B: spreads C: all 16
0.25bp 1.60 0.36 0.26
0.50bp 1.53 0.51 0.39
1.00bp 1.58 0.79 0.56
1.50bp 1.60 1.08 0.78
3.00bp 1.41 2.28 1.04
The benefit depends on the spread bid-offer. At 0.25 basis points the spreads give an error of 0.36, against 1.60 for the outright. The benefit fades as the spread noise grows: at 1.5 basis points, the same as the outright’s noise, set B is still better, at 1.08, because the tight benchmark outrights anchor it, but the gain is much smaller.
A badly quoted spread is worse than the outright. At 3 basis points, set B has an error of 2.28, which is more than the 1.41 of the outright, because the noise in each spread is carried down the chain of knots. The combined set C is still better than A, since the weights give a noisy quote little say.
The weights have to be right. The solver can only down-weight a noisy quote if it knows it is noisy, so the bid-offers that set the weights are an input that has to be maintained.
The third test uses the extra quotes as a check. In set C every quote is exact except that the 7 year outright is 5 basis points stale:
Sixteen quotes where the 7Y outright is 5bp stale: fitted less quoted, in bp and in noise units
Quote Residual In sigmas
1Y -0.00 -0.0
2Y +0.11 +0.2
3Y +0.12 +0.1
5Y +0.14 +0.3
7Y -4.83 -3.2
10Y +0.14 +0.3
15Y +0.12 +0.1
20Y +0.11 +0.1
30Y +0.11 +0.2
2s5s +0.03 +0.1
5s10s -0.00 -0.0
10s30s -0.03 -0.1
2s3s5s -0.00 -0.0
5s7s10s +0.07 +0.3
10s15s20s -0.00 -0.0
15s20s30s -0.00 -0.0
The fitted curve ignores the stale quote, since the 5s7s10s fly and the benchmark outrights say what the 7 year should be. Only the 7 year outright has a large residual, which is 4.8 basis points or 3.2 times its noise, and everything else is within 0.3. A residual of three or more noise units is a flag for review. Without the overlap, a stale quote would look like any other quote and go straight into the curve.
The last test is risk. For the set B, the Jacobian is square and the risk to every quote comes from \(\partial V/\partial q = \partial V/\partial x \, J^{-1}\), as on Interest Rate Curves, Part 3: Global Solver & Jacobian. The trade is the 6 year payer swap, and the risk is the change in PV for a rise of 1 basis point in each quote with the others held fixed:
Risk of a 6Y payer swap struck at par (PV 0) per +1bp in each set B quote:
Quote Jacobian Rebuild
1Y 0.2 0.2
2Y 37,483.3 37,473.3
10Y 15,462.8 15,463.1
2s5s 37,482.3 37,474.9
10s30s 0.0 0.0
2s3s5s 0.5 0.5
5s7s10s 15,462.8 15,463.1
10s15s20s 0.0 0.0
15s20s30s 0.0 0.0
The risk is in the instruments that set the 5 and 7 year rates. In this set, the 5 year rate is the 2 year outright plus the 2s5s switch, and the 7 year rate is half of the sum of the 5s7s10s fly and the 5 and 10 year rates. The 6 year swap depends on the 5 and 7 year rates, so its risk is on the 2 year, 2s5s, 10 year and 5s7s10s quotes.
It is the same risk in a different basis. From the outright risk on Interest Rate Curves, Part 3: Global Solver & Jacobian, 22,019 to the 5 year and 30,926 to the 7 year, the 2 year and 2s5s risk is \(22{,}019 + \tfrac{1}{2} \times 30{,}926 = 37{,}482\), and the 10 year and 5s7s10s risk is \(\tfrac{1}{2} \times 30{,}926 = 15{,}463\). The Jacobian is what converts the risk from one set of instruments to another.
It is the hedge in the instruments that trade. A trader who hedges with switches and flies can read the amounts directly. The Jacobian and the rebuild agree to within 0.03%.
A valuation control view#
Cross-check outrights against spreads: where a tenor has both an outright quote and a switch or fly, the residual in a combined fit is a ready-made test of the outright. A residual of three or more noise units is reviewed, as in the stale 7 year example above.
Maintain the bid-offers: the weights come from the bid-offer of each quote, and a spread is only worth using if it is tighter than the outrights it replaces. The bid-offers are reviewed against the market, and a change is a change to the methodology.
Know which quotes are observable: a tenor set only by a fly is only as observable as the fly and the benchmarks around it. That feeds the level judgement for long-dated trades. See Fair-Value Hierarchy: Levels 1, 2 & 3.
Check the Jacobian pattern: with spreads the pattern is block triangular, and its condition number should be stable from day to day. A jump is a sign of redundant or conflicting inputs. The other checks on a global fit are on Interest Rate Curves, Part 3: Global Solver & Jacobian.
Conventions: the sign and the weights of a switch or fly differ between markets and desks. Check that the weights in the curve build match the way that the quote is traded, since a wrong weight gives a wrong curve that still fits.
Next, Interest Rate Curves, Part 5: Regression Fits covers curves that are fitted to the quotes, and not made to reprice them.