## Term Structure Analysis and Interest-Rate Swaps

This example illustrates some of the term-structure analysis functions found in
Financial Toolbox™ software. Specifically, it illustrates how to derive implied zero
(*spot*) and forward curves from the observed market prices of
coupon-bearing bonds. The zero and forward curves implied from the market data are then used
to price an interest rate swap agreement.

In an interest rate swap, two parties agree to a periodic exchange of cash flows. One of the cash flows is based on a fixed interest rate held constant throughout the life of the swap. The other cash flow stream is tied to some variable index rate. Pricing a swap at inception amounts to finding the fixed rate of the swap agreement. This fixed rate, appropriately scaled by the notional principal of the swap agreement, determines the periodic sequence of fixed cash flows.

In general, interest rate swaps are priced from the forward curve such that the variable cash flows implied from the series of forward rates and the periodic sequence of fixed-rate cash flows have the same current value. Thus, interest rate swap pricing and term structure analysis are intimately related.

### Step 1

Specify values for the settlement date, maturity dates, coupon rates, and market prices for 10 U.S. Treasury Bonds. This data allows you to price a five-year swap with net cash flow payments exchanged every six months. For simplicity, accept default values for the end-of-month payment rule (rule in effect) and day-count basis (actual/actual). To avoid issues of accrued interest, assume that all Treasury Bonds pay semiannual coupons and that settlement occurs on a coupon payment date.

Settle = datenum('15-Jan-1999'); BondData = {'15-Jul-1999' 0.06000 99.93 '15-Jan-2000' 0.06125 99.72 '15-Jul-2000' 0.06375 99.70 '15-Jan-2001' 0.06500 99.40 '15-Jul-2001' 0.06875 99.73 '15-Jan-2002' 0.07000 99.42 '15-Jul-2002' 0.07250 99.32 '15-Jan-2003' 0.07375 98.45 '15-Jul-2003' 0.07500 97.71 '15-Jan-2004' 0.08000 98.15};

`BondData `

is an instance of a MATLAB^{®}
*cell array*, indicated by the curly braces (`{}`

).

Next assign the date stored in the cell array to `Maturity`

,
`CouponRate`

, and `Prices`

vectors for further
processing.

```
Maturity = datenum(char(BondData{:,1}));
CouponRate = [BondData{:,2}]';
Prices = [BondData{:,3}]';
Period = 2; % semiannual coupons
```

### Step 2

Now that the data has been specified, use the term structure function `zbtprice`

to bootstrap the zero curve implied from the prices of the
coupon-bearing bonds. This implied zero curve represents the series of zero-coupon Treasury
rates consistent with the prices of the coupon-bearing bonds such that arbitrage
opportunities will not exist.

ZeroRates = zbtprice([Maturity CouponRate], Prices, Settle)

ZeroRates = 0.0614 0.0642 0.0660 0.0684 0.0702 0.0726 0.0754 0.0795 0.0827 0.0868

The zero curve, stored in `ZeroRates`

, is quoted on a semiannual bond
basis (the periodic, six-month, interest rate is doubled to annualize). The first element of
`ZeroRates`

is the annualized rate over the next six months, the second
element is the annualized rate over the next 12 months, and so on.

### Step 3

From the implied zero curve, find the corresponding series of implied forward rates
using the term structure function `zero2fwd`

.

ForwardRates = zero2fwd(ZeroRates, Maturity, Settle)

ForwardRates = 0.0614 0.0670 0.0695 0.0758 0.0774 0.0846 0.0925 0.1077 0.1089 0.1239

The forward curve, stored in `ForwardRates`

, is also quoted on a
semiannual bond basis. The first element of `ForwardRates`

is the
annualized rate applied to the interval between settlement and six months after settlement,
the second element is the annualized rate applied to the interval from six months to 12
months after settlement, and so on. This implied forward curve is also consistent with the
observed market prices such that arbitrage activities will be unprofitable. Since the first
forward rate is also a zero rate, the first element of `ZeroRates`

and
`ForwardRates`

are the same.

### Step 4

Now that you have derived the zero curve, convert it to a sequence of discount factors
with the term structure function `zero2disc`

.

DiscountFactors = zero2disc(ZeroRates, Maturity, Settle)

DiscountFactors = 0.9704 0.9387 0.9073 0.8739 0.8416 0.8072 0.7718 0.7320 0.6945 0.6537

### Step 5

From the discount factors, compute the present value of the variable cash flows derived from the implied forward rates. For plain interest rate swaps, the notional principal remains constant for each payment date and cancels out of each side of the present value equation. The next line assumes unit notional principal.

PresentValue = sum((ForwardRates/Period) .* DiscountFactors)

PresentValue = 0.3460

### Step 6

Compute the swap's price (the fixed rate) by equating the present value of the fixed cash flows with the present value of the cash flows derived from the implied forward rates. Again, since the notional principal cancels out of each side of the equation, it is assumed to be 1.

SwapFixedRate = Period * PresentValue / sum(DiscountFactors)

SwapFixedRate = 0.0845

The output for these computations is:

Zero Rates Forward Rates 0.0614 0.0614 0.0642 0.0670 0.0660 0.0695 0.0684 0.0758 0.0702 0.0774 0.0726 0.0846 0.0754 0.0925 0.0795 0.1077 0.0827 0.1089 0.0868 0.1239 Swap Price (Fixed Rate) = 0.0845

All rates are in decimal format. The swap price, 8.45%, would likely be the mid-point between a market-maker's bid/ask quotes.

## See Also

`bnddury`

| `bndconvy`

| `bndprice`

| `bndkrdur`

| `blsprice`

| `blsdelta`

| `blsgamma`

| `blsvega`

| `zbtprice`

| `zero2fwd`

| `zero2disc`

## Related Topics

- Pricing and Analyzing Equity Derivatives
- Greek-Neutral Portfolios of European Stock Options
- Sensitivity of Bond Prices to Interest Rates
- Bond Portfolio for Hedging Duration and Convexity
- Bond Prices and Yield Curve Parallel Shifts
- Bond Prices and Yield Curve Nonparallel Shifts
- Plotting Sensitivities of an Option
- Plotting Sensitivities of a Portfolio of Options