Interest Rate Curve Build, Part 1: Instruments & Bootstrapping#
See also
Bank of England: yield curves, published nominal and inflation curves
ARRC: SOFR, the transition to SOFR, which is the reference for USD curves
Almost every valuation depends on a curve: a set of discount factors that says what one unit of a currency paid at each future date is worth today. There is a curve for each currency, because the value of waiting depends on the rate of interest in that currency. Any product with cash flows in the future has to be discounted i.e. all products need one. Interest rate products however, need the curve in a second way as well. The floating rates that they pay are read from a curve of forward rates, so the curve sets the size of the cash flows as well as their present value. Part 2 separates those two jobs, and in a single-curve build, as here, one curve does both.
Building the curve from market quotes is therefore the first step in valuing almost anything, and it is the first thing that valuation control checks, because an error in the curve is an error in every trade that uses it.
This is the first of four pages on the curve. This one builds a single curve by bootstrapping, from four types of instrument. Interest Rate Curve Build, Part 2: Multi-Curve & Basis adds separate projection curves and the basis between them, Interest Rate Curve Build, Part 3: Global Solver & Jacobian replaces the one-at-a-time bootstrap with a global solver and the Jacobian, and Interest Rate Curve Build, Part 4: Regression Fits covers curves that are fitted to the data and not made to reprice it.
What the curve is#
The discount factor \(D(t)\) is the value today of 1 paid at time \(t\), with \(D(0) = 1\). It is easiest to think of it as the result of discounting at a rate \(z(t)\) for \(t\) years:
\(z(t)\) is the continuously compounded zero rate to \(t\). It is the single rate that, applied for the whole period, gives the discount factor. Solving the equation above for it gives
The same idea applies between two future dates \(t_1 < t_2\). Money paid at \(t_2\) is worth \(D(t_2)\) today, and the factor that moves it back from \(t_2\) to \(t_1\) is \(e^{-f\,(t_2 - t_1)}\), where \(f\) is the continuously compounded forward rate for the period:
Money-market instruments quote simple interest and not continuous compounding. Lending 1 at \(t_1\) earns \(F\tau\) of interest by \(t_2\), where \(\tau\) is the accrual fraction of the period (\(\tau = t_2 - t_1\) in the simplest case), so it grows to \(1 + F\tau\). The factor that moves a value back from \(t_2\) to \(t_1\) is therefore \(1/(1 + F\tau)\), which takes the place of \(e^{-f\,(t_2 - t_1)}\) above. The simple forward rate \(F(t_1, t_2)\) is the rate that makes the two dates consistent with the curve:
The three quantities, \(z\), \(f\) and \(F\), are different ways to express the same curve. The simple forward rate \(F\) is the one that the instruments below quote.
The overnight rate and OIS#
Every instrument on this page is a contract on one rate, the overnight rate. It is the rate at which banks borrow for one day, published each day as a fixing: SOFR in the US, SONIA in the UK, ESTR in the euro area. It is also the rate paid on cash collateral, which is why a collateralised trade is discounted at it. The curve built here is therefore the overnight curve, and in a single-curve build it does both jobs: it discounts and it gives the forward rates. Discounting at the overnight rate assumes that the trades are collateralised with cash, which earns that rate. A trade with no collateral, or with collateral in another currency, is discounted differently. Interest Rate Curve Build, Part 2: Multi-Curve & Basis covers the choice of collateral and its effect on the discount curve.
Note
Fixing. A fixing is the official value of a benchmark rate for a given day, calculated and published after the day’s market activity. For example, the New York Fed publishes the SOFR fixing each morning for the previous business day, based on that day’s overnight repo trades. Once published it does not change, and floating payments are calculated from it.
Over a period from \(t_1\) to \(t_2\), daily rates \(r_j\) with accrual fractions \(\delta_j\) compound to the compounded overnight rate \(R\), which has accrual fraction \(\tau\) for the whole period:
This is what 1 lent at \(t_1\) and rolled over every night grows to by \(t_2\). The value of this amount today follows from replication, whatever the daily rates turn out to be:
Receiving 1 at \(t_1\) is worth \(D(t_1)\) today.
Rolling that 1 overnight until \(t_2\) turns it into \(1 + R\tau\). The roll costs nothing and carries no risk, because the discount curve is the overnight curve. So \(1 + R\tau\) paid at \(t_2\) is also worth \(D(t_1)\).
Paying 1 at \(t_2\) is worth \(D(t_2)\). Taking it away leaves the interest \(R\tau\) paid at \(t_2\).
The value today of receiving \(R\tau\) at \(t_2\) is therefore
This does not need a model for the daily rates. It also holds because the curve is defined by \(D(t_1)/D(t_2) = 1 + F\tau\), so the compounded overnight rate over a period is exactly the simple forward rate \(F(t_1, t_2)\) of the curve. The argument fails for a term rate, which cannot be rolled at no cost and which contains a credit premium. An overnight index swap (OIS) is the contract that exchanges this floating amount for a fixed rate, and it is set out in full under the swap below. The other three instruments are contracts on the same rate over shorter periods.
A term rate, such as 3 month LIBOR was, includes bank credit and liquidity premia that the overnight rate does not. A FRA or future on a term rate needs its own projection curve, which is the subject of Interest Rate Curve Build, Part 2: Multi-Curve & Basis. Here every instrument references the overnight rate, so one curve is enough.
Instruments and their payoffs#
The curve is built from the most liquid instruments at each maturity. Each one exists because someone needs it: a company that wants to fix the cost of a loan, an investor that wants to match long-term payments, a bank that needs funding overnight. That demand is what makes each instrument liquid, and a liquid, frequently traded price is what makes it reliable enough to build a curve from. Each one has a quote, a payoff, and an equation that says what the curve must do for that instrument to be worth zero at inception. All four are contracts on the overnight rate (see The overnight rate and OIS), and all four are shown here with a notional of 1 unless stated.
Each instrument is valued as the sum of the present values of its parts, \(\text{PV} = \text{PV}_{\text{part 1}} + \text{PV}_{\text{part 2}}\). A cash flow that the holder receives counts as positive, and one that the holder pays counts as negative. The quote is the level that makes the total zero at inception.
Cash deposit#
Why it is traded. A deposit is the simplest way to lend or borrow money for a fixed short period at a known rate. A company with spare cash for three months, or a bank that needs funding for a week, uses it to put cash to work or to raise it. The rate that the market agrees for each term is the price of money for that term, which is why it is the first thing that the curve is built from. For example, a treasurer who deposits 10 million for three months at 3.94% gets the 10 million back at the end, plus \(10{,}000{,}000 \times 0.0394 \times 0.25 = 98{,}500\) of interest. In many markets the very short end of the curve now comes from overnight rate fixings and short overnight index swaps, because unsecured term deposits have largely stopped being the benchmark.
The instrument. A deposit from the valuation date to \(T\) at a simple rate \(r\). The accrual fraction \(\tau\) of the deposit is the length of the period from today to \(T\), so \(\tau = T\) when \(T\) is measured in years. In practice \(\tau\) comes from the market’s day count, such as actual/360, and differs slightly from \(T\). The lender pays 1 today and receives back the principal and interest at \(T\), so the value is the sum of the two parts:
Setting the total to zero gives the discount factor at the end of the deposit:
Overnight and short-dated deposits fix the first part of the curve. The quote is the rate \(r\), which here is the overnight rate compounded over the term (see The overnight rate and OIS), so that \(r = F(0, T)\).
Forward rate agreement (FRA)#
Why it is traded. An FRA fixes today the interest rate for a borrowing or a loan that starts in the future, without borrowing or lending anything now. Take a company that will borrow 50 million for three months, starting in three months, and is worried that rates will rise. It buys a 3x6 FRA at 3.93%, which means that it pays 3.93% and receives the market rate \(L\). If \(L\) turns out to be 4.50%, the FRA pays the company \(50{,}000{,}000 \times 0.25 \times (0.0450 - 0.0393) = 71{,}250\), which offsets the extra interest on the loan. If \(L\) is lower, the company pays on the FRA, but its loan is cheaper by the same amount. Either way, its cost is fixed at 3.93%. The seller of the FRA is in the opposite position, such as a lender that is worried that rates will fall. Banks also use FRAs to manage their own exposure and to take a view on future rates. Only the difference in interest is paid, and never the principal.
The instrument. A contract on the rate for a future period from \(T_1\) to \(T_2\). The buyer pays a fixed rate \(K\) and receives the index rate \(L\), which is observed at \(T_1\). With notional \(N\) and \(\tau = T_2 - T_1\), the amount settled at \(T_2\) is
The rate \(L\) is known at \(T_1\), so the amount \(N\tau(L - K)\) is already fixed at the start of the period, but it is paid at the end. In the market the FRA is settled at \(T_1\) instead, which is earlier by the length of the period. The payment is therefore reduced by the interest that it would have earned between \(T_1\) and \(T_2\). Money lent at \(T_1\) at the rate \(L\) grows by the factor \(1 + \tau L\) by \(T_2\), so a payment at \(T_2\) is worth \(1/(1 + \tau L)\) of that amount at \(T_1\):
The two ways of settling are worth the same, because the second is the first moved back from \(T_2\) to \(T_1\) at the rate \(L\). In terms of the curve, with the expected value of \(L\) equal to the forward rate \(F(T_1,T_2)\), discounting the settlement amount from \(T_1\) to today gives
which is the value of the payment at \(T_2\). The rest of this section uses the payment at \(T_2\), as it is simpler. The payoff is the difference of a floating payment that is received and a fixed payment that is paid. Valuing each part with the curve:
The floating part uses the forward rate \(F(T_1,T_2)\) from the curve in place of the unknown \(L\).
At inception the contract is worth zero when \(K\) equals the forward rate, and the forward rate comes from the curve as in the previous section:
A “3x6” FRA covers the period from 3 months to 6 months. The quote is the fixed rate \(K\). The rate \(L\) is the overnight rate compounded over the period (see The overnight rate and OIS). The settlement timing above is that of a term-rate FRA, where \(L\) is fixed at \(T_1\). A FRA on a compounded overnight rate is fixed in arrears and paid at \(T_2\), which is the payment used for the valuation. Either way the pillar equation is the same.
Interest rate future#
Why it is traded. A future does the same job as an FRA, which is to fix a rate for a future period, but it trades on an exchange. The contract is standardised, it is easy to buy and sell at any time, and the exchange’s clearing house collects margin every day, so there is little credit risk to the other side. Hedgers and speculators both use it for those reasons. A borrower who is worried about rising rates sells futures, because the price falls when rates rise. For example, a company that will borrow 50 million for three months sells 50 contracts of 1,000,000. If rates rise by 50 basis points, each contract gains \(50 \times 25 = 1{,}250\) and the 50 contracts gain 62,500, which is about what the extra 50 basis points cost on the loan, \(50{,}000{,}000 \times 0.005 \times 0.25 = 62{,}500\). An investor who is worried that rates will fall buys futures instead. Because futures trade in large volume on regular start dates, they give the most liquid view of short-term forward rates.
The instrument. A standardised contract on a three-month rate for a future period from \(T_1\) to \(T_2\). It is quoted as a price, and the rate is read from the price:
The final settlement price is fixed by the rate \(R_{T_1}\) at the start of the period. The holder of a long position gains when the rate falls. Profit and loss is paid every day as the price moves (margining), and in total it is
where \(R_0 = (100 - P_0)/100\) is the rate at which the position was opened. For a notional of 1,000,000 and \(\tau = 0.25\), one basis point, which is 0.01 in price, is worth \(1{,}000{,}000 \times 0.25 \times 0.0001 = 25\). The position has an agreed rate \(R_0\) that is received, and an expected future rate \(F(T_1, T_2)\) that is paid. Because the profit and loss is settled every day, there is no discount factor in the value:
The curve takes the futures rate as the forward rate for the period. The position is worth zero when \(R_0 = F(T_1, T_2)\), which gives the discount factor at the end of the period:
The three-month rate is the overnight rate compounded over the period (see The overnight rate and OIS), as in a three-month SOFR future, so \(F(T_1, T_2)\) comes from the same curve. Futures are listed on a fixed calendar of start dates, which is why they give a ladder of consecutive three-month forward rates. They are used for the part of the curve between the cash deposits and the swaps.
Overnight index swap (OIS)#
Why it is traded. A swap changes the nature of an interest payment for years, and not just for a few months. A company with a floating-rate loan is exposed to rising rates. By paying a fixed rate and receiving the floating rate in a swap, it turns the loan into a fixed-rate one. Take a 100 million loan that pays the overnight rate plus a margin for five years, and a 5 year swap at 3.65% in which the company pays fixed and receives the overnight rate. The floating payments that it receives from the swap offset the floating interest on the loan, which leaves a fixed 3.65% a year, or 3.65 million, plus the margin. The other side of the trade might be an investor such as a pension fund or an insurer that wants to receive fixed rates to match long-term payments to its members, or a bank that is managing the mismatch between its assets and its liabilities. Swaps are also used to take a view on the direction of rates. They are the most liquid instruments from one year out to 30 years or more, so they set most of the curve. Collateralised swaps are discounted at the overnight rate, which is why overnight index swaps define the discount curve.
The instrument. An overnight index swap (OIS), defined in The overnight rate and OIS, exchanges a fixed rate \(s\) for the compounded overnight rate. For a swap with annual payments and unit notional, the receiver of fixed gets \(s\tau_i\) on each payment date \(T_i\) and pays the interest that compounding the overnight rate over that period would have earned:
Fixed leg (received) |
Floating leg (paid) |
Value today of the floating payment |
|---|---|---|
\(s \tau_i\) |
\(\prod_{j \in i} (1 + r_j \delta_j) - 1\), the compounded overnight interest of the period |
\(D(T_{i-1}) - D(T_i)\) |
As shown in The overnight rate and OIS, the value of the compounded overnight interest of a period is \(D(T_{i-1}) - D(T_i)\), which is the last column. The swap is then the sum of the present values of its two legs, with the fixed leg received and the floating leg paid:
The sum for the floating leg telescopes, which is why only the first and last discount factors remain. The swap is worth zero at inception when the fixed leg exactly offsets the floating leg:
The last form holds when every earlier payment date is already a pillar of the curve. The quote is the par fixed rate \(s\). Swaps run from one year out to 30 or 50 years, and they are the core of a modern curve.
Summary#
Instrument |
Typical range |
Quote |
Value at inception |
New discount factor |
|---|---|---|---|---|
Cash |
Overnight to 3 months |
Simple rate \(r\) |
\(-1 + (1+r\tau) D(T)\) |
\(\dfrac{1}{1 + r\tau}\) |
FRA |
3 months to 2 years |
Fixed rate \(K\) |
\(N\tau D(T_2)\,(F - K)\) |
\(\dfrac{D(T_1)}{1 + K\tau}\) |
Future |
3 months to 2 or 3 years |
Price \(P = 100 - 100R\) |
\(N\tau\,(R_0 - F)\), no discounting because it is margined daily |
\(\dfrac{D(T_1)}{1 + R\tau}\) |
Swap (OIS) |
1 year to 50 years |
Par fixed rate \(s\) |
\(s \sum \tau_i D(T_i) - (1 - D(T_n))\) |
Solve the par equation for \(D(T_n)\) |
Each of the four exists to meet a need, and the table below says who has it. That demand is why the quotes are liquid enough to build a curve from.
Instrument |
Typical users |
Purpose |
|---|---|---|
Cash deposit |
Corporate treasurers, banks, money market funds |
Lend or borrow for a fixed short term at a known rate. |
FRA |
Corporates, banks |
Fix the rate for a borrowing or a loan that starts in the future, and pay only the difference in interest. |
Future |
Banks, funds, traders, borrowers and lenders |
The same job as an FRA, on an exchange, with daily margin and easy entry and exit. |
Swap (OIS) |
Borrowers, investors, pension funds, insurers, banks |
Turn floating payments into fixed, or the reverse, for years. Also used to take a view on rates. |
Each instrument ends at a different date, and each one adds exactly one new unknown, the discount factor at its end date. That is what makes the bootstrap work.
The swap market also quotes curve spreads, such as the switch 2s10s (the 10 year swap rate less the 2 year) and the butterfly, or fly, 5s7s10s (twice the 7 year rate less the 5 and 10 year rates). They are often the most liquid way to trade the less liquid tenors, so a production curve uses them as inputs. They are not used in the bootstrap, because one spread quote involves several maturities and does not bring in a single new unknown at its end date. Interest Rate Curve Build, Part 3: Global Solver & Jacobian covers how they are used.
Bootstrapping#
Bootstrapping solves for the discount factors one pillar at a time, from the shortest to the longest, so that each input reprices to par:
Sort the instruments by the date at which they end.
Start with \(D(0) = 1\).
For the next instrument, every discount factor that it needs, other than the one at its end date, is already known. The pillar equation has one unknown, \(D(T)\).
Solve it. For cash, FRAs and futures there is a closed form, from the table. For a swap, use the closed form if all of the payment dates are pillars, and otherwise use a root finder.
Add the new pillar and go to the next instrument.
A swap pays on dates that have no instrument, such as the annual payments in years 4 and 6 between the 3, 5 and 7 year swaps. The discount factors on those dates come from the interpolation rule, which is part of the curve and which is evaluated inside the root finder.
Interpolation#
Method |
Property |
Weakness |
|---|---|---|
Linear in the discount factor |
Simple. |
Gives forward rates with large jumps. |
Log-linear in the discount factor |
Flat forward rates between pillars. Never gives negative forwards when the inputs are sensible. |
Forward curve is a staircase, so it is not smooth and hedge risk jumps at the pillars. |
Linear in the zero rate |
Smooth zero curve. |
Forward rates can oscillate and go negative. |
Cubic splines, monotone convex |
Smooth, with sensible forward rates. Monotone convex is built to stay positive and local. |
More complex. A poor spline can oscillate. |
The choice changes the forward rates, and so changes the price of anything that depends on them, such as a forward-starting swap or a swaption. It must be documented and be the same across the firm. This page uses log-linear interpolation, which gives the flat forwards in the output.
Worked example#
The example builds a curve from thirteen instruments: two cash deposits (1 and 3 months), a 3x6 FRA, two futures (6 to 9 months and 9 to 12 months), and eight swaps from 2 to 30 years. It solves for the discount factor at each end date in turn, and then reprices every input. The quotes are invented but realistic. Times are exact fractions of a year, with no calendars or day counts.
Python code
"""Bootstrap a discount curve from cash, FRAs, futures and swaps, then reprice every input."""
import numpy as np
from scipy.optimize import brentq
from curve_example import Curve, bootstrap as swap_only_bootstrap, forward_swap
# (type, start, end, quote). Times are in years and accruals are exact fractions, with no calendars.
# cash : simple deposit rate from time 0 to `end`
# fra : forward rate agreement rate for the period start to end
# future : futures price, 100 - rate, for the period start to end
# swap : par fixed rate of an annual OIS swap from time 0 to `end`
INSTRUMENTS = [
("cash", 0.0, 1 / 12, 0.0395),
("cash", 0.0, 0.25, 0.0394),
("fra", 0.25, 0.50, 0.0393),
("future", 0.50, 0.75, 96.08),
("future", 0.75, 1.00, 96.07),
("swap", 0.0, 2, 0.0380),
("swap", 0.0, 3, 0.0370),
("swap", 0.0, 5, 0.0365),
("swap", 0.0, 7, 0.0368),
("swap", 0.0, 10, 0.0375),
("swap", 0.0, 15, 0.0385),
("swap", 0.0, 20, 0.0380),
("swap", 0.0, 30, 0.0365),
]
def forward_simple(curve, start, end):
"""Simple forward rate for [start, end] implied by the curve."""
return (curve.df(start) / curve.df(end) - 1.0) / (end - start)
def implied_quote(curve, kind, start, end):
"""The quote the curve gives for an instrument. The bootstrap makes this equal the market quote."""
if kind == "cash":
return forward_simple(curve, 0.0, end)
if kind == "fra":
return forward_simple(curve, start, end)
if kind == "future":
return 100.0 - 100.0 * forward_simple(curve, start, end)
return forward_swap(curve, 0, int(end))[0]
def bootstrap(instruments=INSTRUMENTS):
"""Solve for one discount factor per instrument, from the shortest to the longest."""
times, dfs = [], []
for kind, start, end, quote in sorted(instruments, key=lambda i: i[2]):
if kind == "swap":
def error(df_end):
curve = Curve(times + [end], dfs + [df_end])
return quote * curve.df(np.arange(1, int(end) + 1)).sum() - (1.0 - df_end)
df_end = brentq(error, 1e-6, 1.0)
else:
rate = quote if kind != "future" else (100.0 - quote) / 100.0
df_start = Curve(times, dfs).df(start) if times else 1.0
df_end = df_start / (1.0 + rate * (end - start))
times.append(end)
dfs.append(df_end)
return Curve(times, dfs)
if __name__ == "__main__":
curve = bootstrap()
print(f"{'Instrument':<12} {'Period':<13} {'Quote':>9} {'DF':>9} {'Zero':>8} {'Forward':>9}")
previous = 0.0
for kind, start, end, quote in sorted(INSTRUMENTS, key=lambda i: i[2]):
name = {"cash": f"Cash {end * 12:.0f}M", "fra": f"FRA {start * 12:.0f}x{end * 12:.0f}",
"future": f"Future {start * 12:.0f}-{end * 12:.0f}", "swap": f"Swap {end:.0f}Y"}[kind]
period = f"{start:.2f}-{end:.2f}Y"
shown = f"{quote:9.2f}" if kind == "future" else f"{quote:9.4%}"
zero = -np.log(curve.df(end)) / end
forward = np.log(curve.df(previous) / curve.df(end)) / (end - previous)
print(f"{name:<12} {period:<13} {shown} {curve.df(end):9.6f} {zero:8.4%} {forward:9.4%}")
previous = end
errors = []
for kind, start, end, quote in INSTRUMENTS:
difference = abs(implied_quote(curve, kind, start, end) - quote)
errors.append(difference * 0.01 if kind == "future" else difference)
print(f"\nLargest repricing error: {max(errors):.2e}")
forward, annuity = forward_swap(curve, 5, 5)
reference, _ = forward_swap(swap_only_bootstrap(), 5, 5)
print(f"5Y x 5Y forward swap rate: {forward:.4%} (swap-only curve used later in the series: {reference:.4%})")
# Bump the 5Y swap by 1bp and see where the forward rates move.
bumped = [(k, s, e, q + (1e-4 if (k, e) == ("swap", 5) else 0.0)) for k, s, e, q in INSTRUMENTS]
bumped_curve = bootstrap(bumped)
print("\nChange in the flat forward rate after a +1bp bump to the 5Y swap:")
edges = [2, 3, 5, 7, 10, 15]
for lo, hi in zip(edges[:-1], edges[1:]):
change = (np.log(bumped_curve.df(lo) / bumped_curve.df(hi)) / (hi - lo)
- np.log(curve.df(lo) / curve.df(hi)) / (hi - lo)) * 1e4
print(f" {lo:>2}Y-{hi:>2}Y: {change:+6.2f} bp")
The output is:
Instrument Period Quote DF Zero Forward
Cash 1M 0.00-0.08Y 3.9500% 0.996719 3.9435% 3.9435%
Cash 3M 0.00-0.25Y 3.9400% 0.990246 3.9207% 3.9093%
FRA 3x6 0.25-0.50Y 3.9300% 0.980612 3.9158% 3.9108%
Future 6-9 0.50-0.75Y 96.08 0.971095 3.9108% 3.9009%
Future 9-12 0.75-1.00Y 96.07 0.961647 3.9108% 3.9108%
Swap 2Y 0.00-2.00Y 3.8000% 0.928186 3.7261% 3.5415%
Swap 3Y 0.00-3.00Y 3.7000% 0.896891 3.6274% 3.4298%
Swap 5Y 0.00-5.00Y 3.6500% 0.836156 3.5788% 3.5060%
Swap 7Y 0.00-7.00Y 3.6800% 0.776577 3.6123% 3.6960%
Swap 10Y 0.00-10.00Y 3.7500% 0.691431 3.6899% 3.8711%
Swap 15Y 0.00-15.00Y 3.8500% 0.565087 3.8052% 4.0357%
Swap 20Y 0.00-20.00Y 3.8000% 0.473996 3.7328% 3.5156%
Swap 30Y 0.00-30.00Y 3.6500% 0.348176 3.5168% 3.0849%
Largest repricing error: 3.10e-14
5Y x 5Y forward swap rate: 3.8700% (swap-only curve used later in the series: 3.8700%)
Change in the flat forward rate after a +1bp bump to the 5Y swap:
2Y- 3Y: +0.00 bp
3Y- 5Y: +2.54 bp
5Y- 7Y: -2.73 bp
7Y-10Y: -0.00 bp
10Y-15Y: -0.00 bp
Reading the output:
Each pillar uses the instrument that ends there. The first five discount factors come from the closed forms for cash, the FRA and the futures. A futures price of 96.08 is a rate of 3.92%. The swaps then solve the par equation for the 2, 3, 5, 7, 10, 15, 20 and 30 year discount factors.
The short end is flat in this example. The forward rates for the first year are all close to 3.91%, which is how the quotes were set. In a real market it would slope with the expectations for the central bank.
Every input reprices. The largest error is of the order of \(10^{-14}\), which is rounding. A bootstrap with an exact fit has to give this, and it is the first test of a build.
The forward column shows the staircase. Each forward is constant between pillars, which is the effect of log-linear interpolation.
The bump test shows the cost of the staircase. A 1 basis point rise in the 5 year swap rate raises the forward rate between 3 and 5 years by 2.5 basis points and lowers the forward between 5 and 7 years by 2.7 basis points. The forwards in the other segments do not change. The effect is called a sawtooth. The forward after the bumped pillar moves the other way because the 7 year swap quote did not change, so the curve has to compensate. Hedges for forward-starting trades inherit it, which is the reason for smoother interpolation.
The bootstrapped zero curve and the flat forwards between pillars. The dots are the quotes of the four instruments, as simple rates.#
The first two years in detail. The dots are the quotes as simple rates, and the lines are continuously compounded, so they differ slightly. The first swap is the 2 year.#
The swap-only curve used in the rest of the series#
The later pages of this series, on swaptions and SABR, need only the long end of the curve, so they use a simpler version built from annual overnight swaps from 1 to 30 years. The long end is the same: the 5Y x 5Y forward swap rate is 3.8700% on both curves, as the last line of the output above shows. The two curves differ only in the first year, where the simpler one has a single flat forward rate. The code for it is below.
Python code
"""Bootstrap a discount curve from par swap rates, then reprice the inputs as a check."""
import numpy as np
from scipy.optimize import brentq
PILLARS = [1, 2, 3, 5, 7, 10, 15, 20, 30] # years
PAR_RATES = [0.0400, 0.0380, 0.0370, 0.0365, 0.0368, 0.0375, 0.0385, 0.0380, 0.0365]
class Curve:
"""Discount factors, interpolated log-linearly (flat forward rates between pillars)."""
def __init__(self, times, dfs):
self.t = np.concatenate([[0.0], times])
self.d = np.concatenate([[1.0], dfs])
def df(self, t):
return np.exp(np.interp(t, self.t, np.log(self.d)))
def bootstrap(pillars=PILLARS, par_rates=PAR_RATES):
"""Solve for one discount factor per pillar, so that each par swap reprices to zero."""
times, dfs = [], []
for maturity, rate in zip(pillars, par_rates):
def error(df_maturity):
curve = Curve(times + [maturity], dfs + [df_maturity])
annual_dates = np.arange(1, maturity + 1)
# Annual fixed leg against an overnight floating leg worth 1 - DF(maturity).
return rate * curve.df(annual_dates).sum() - (1.0 - df_maturity)
dfs.append(brentq(error, 1e-6, 1.0))
times.append(maturity)
return Curve(times, dfs)
def forward_swap(curve, expiry, tenor):
"""Forward par swap rate and annuity for an annual fixed leg starting at `expiry`."""
pay_dates = expiry + np.arange(1, tenor + 1)
annuity = curve.df(pay_dates).sum()
return (curve.df(expiry) - curve.df(pay_dates[-1])) / annuity, annuity
if __name__ == "__main__":
curve = bootstrap()
print(f"{'Pillar':>6} {'Par rate':>9} {'DF':>9} {'Zero':>8} {'Fwd':>8}")
previous_t, previous_df = 0.0, 1.0
for t, rate in zip(PILLARS, PAR_RATES):
df = curve.df(t)
zero = -np.log(df) / t
forward = np.log(previous_df / df) / (t - previous_t)
print(f"{t:>5}Y {rate:9.4%} {df:9.6f} {zero:8.4%} {forward:8.4%}")
previous_t, previous_df = t, df
# Reprice every input swap with the finished curve.
errors = []
for t, rate in zip(PILLARS, PAR_RATES):
repriced, _ = forward_swap(curve, 0, t)
errors.append(abs(repriced - rate))
print(f"\nLargest repricing error: {max(errors):.2e}")
forward, annuity = forward_swap(curve, 5, 5)
print(f"5Y x 5Y forward swap rate: {forward:.4%}, annuity: {annuity:.4f}")
Conventions the example leaves out#
Day counts and calendars: each instrument has its own day count (such as actual/360 or actual/365) and business-day rules, so \(\tau\) is not an exact fraction. They matter at the level of basis points.
Spot lag and stubs: a deposit may start in two days, not today, and a swap may have a short first period.
Turn of year: the overnight rate jumps over the year end and quarter ends, which a smooth curve cannot reproduce without an explicit adjustment.
Extrapolation: beyond the last liquid pillar, which is often 30 or 50 years, the curve is an assumption, such as a flat last forward rate, and it needs its own control.
Instrument choice at the overlaps: a futures contract, an FRA and a swap can cover the same dates. A curve must decide which to use for each date. Using all of them over-determines it, which is the case in Interest Rate Curve Build, Part 3: Global Solver & Jacobian.
A valuation control view#
The curve underlies everything else, so the controls are about inputs and methodology:
Inputs: each instrument’s quote is checked against an independent source at the same snapshot time, with a tolerance for each instrument and tenor. A futures price, an FRA rate and a swap rate that cover the same dates should agree.
Repricing: the curve must reprice its inputs to a small tolerance, as in the check above. A repricing break means a bug or a stale input.
Smoothness: the forward curve is inspected for jumps, negative forwards or kinks that are not in the market, and the effect of a one basis point bump is checked, as in the sawtooth test.
Methodology: the choice of instruments at each date, the interpolation, the day counts and the extrapolation are documented and approved. See Governance: Model Risk, Accountability and Data.
Link to fair value: quotes that are illiquid, such as 30 year and longer pillars, are an input to the level judgement in Fair-Value Hierarchy: Levels 1, 2 & 3.
Next, Interest Rate Curve Build, Part 2: Multi-Curve & Basis explains why a single curve is no longer enough.