The term structure of interest rates and an object lesson

In this chapter we look at various algorithms that has been used to estimate a ``term structure,'' i e a relation between length of period for investment and interest rate.

The term structure is the current price for a future (time $t$) payment of one dollar (discount factor). It can also be viewed as the yield on a zero coupon bond paying one dollar at time $t$. Alternatively one can think about forward interest rates, the yield on borrowing at some future date $t_1$ and repaying it at a later date $t_2$. Knowing one of these one also knows the others, since there are one-to-one transforms moving one into the other.

Term structure calculations

Let us show some useful transformations for moving between these three alternative views of the term structure. . Let $r(t)$ be the yield on a $t$-period discount bond, and $d(t)$ the discount factor for time $t$ (the current price of a bond that pays $1 at time $t$. Then

\begin{displaymath}d(t) = e^{-{r(t)}t} \end{displaymath}

\begin{displaymath}r(t) = \frac{-\ln(d(t))}{t} \end{displaymath}

Also, the forward rate for borrowing at time $t_1$ for delivery at time $T$ is calculated as

\begin{displaymath}f_t(t_1,T) = \frac{- \ln\left(\frac{d(T)}{d(t_1)}\right) }{T-t_1}
= \frac{ \ln\left(\frac{d(t_1)}{d(T)}\right) }{T-t_1} \end{displaymath}

The forward rate can also be calculated directly from yields as

\begin{displaymath}f_d(t,t_1,T)=r_d(t,T)\frac{T-t}{T-t_1} - r_d(t,t_1) \frac{t_1-t}{T-t_1}\end{displaymath}

Note that this assumes continously compounded interest rates.

Code 3.1 shows the implementation of these transformations.

% latex2html id marker 1237\caption{Term structure transformat...

Using the currently observed term structure.

To just use todays term structure, we need to take the observations of yields that is observed in the market and use these to generate a term structure. The simplest possible way of doing this is to linearly interpolate the currently observable zero coupon yields.

Linear Interpolation.

If we are given a set of yields for various maturities, the simplest way to construct a term structure is by straightforward linear interpolation between the observations we have to find an intermediate time. For many purposes this is ``good enough.'' This interpolation can be on either yields, discount factors or forward rates, we illustrate the case of linear interpolation of spot rates.

Computer algorithm, linear interpolation of yields.

Note that the algorithm assumes the yields are ordered in increasing order of time to maturity.

% latex2html id marker 1242\caption{Interpolated term structur...

The term structure as an object

To actually use the term structure one has to specify one of these three alternative views of the term stucuture for all possible future dates. This is of course not feasible, so one will need to have a method for specifying the term structure, such as the linear interpolation above. Next this term structure will have to be made available for use in other contexts. This is perfect for specifying a class, so we will use this as the prime example of the uses of a class. One can think of the term structure class as an abstract function that either return a discount_factor or a yield.

Implementing a term structure class

A term structure can thus be abstractly described as a function of time. The user of a term structure will not need to know the underlying model of term structures, all that is needed is an interface that specifies functions for

These will for given parameters and term structure models provide all that a user will want to use for calculations.

Base class

% latex2html id marker 1247\caption{}

The code for these functions uses algorithms that are described earlier in this chapter for transforming between various views of the term structure. The term structure class merely provide a convenient interface to these algoritms.

% latex2html id marker 1252\caption{}

Note that the definitions of calculations are circular. Any given specific type of term structure has to over-ride at least one of the functions yield, discount_factor or forward_rate.

We next consider two examples of specific term structures.

Flat term structure.

The flat term structure overrides both the yield member function of the base class.

The only piece of data this type of term structure needs is an interest rate.

% latex2html id marker 1257\caption{}

% latex2html id marker 1262\caption{}

Interpolated term structure.

The interpolated term structure implemented here uses a set of observations of yields as a basis, and for observations in between observations will interpolate between the two closest. The following only provides implementations of calculation of the yield, for the other two rely on the base class code.

There is some more book-keeping involved here, need to have code that stores observations of times and yields.

% latex2html id marker 1267\caption{}

% latex2html id marker 1272\caption{}

Bond calculations using the term structure class

Codes 3.9 and 3.10 illustrates how one would calculate bond prices and duration if one has a term structure class.

% latex2html id marker 1277\caption{Pricing a bond with a term...

% latex2html id marker 1282\caption{Calculating a bonds durati...


Shiller (1990) is a good reference on the term structure.