- Term structure calculations
- Using the currently observed term structure.

- The term structure as an object
- Implementing a term structure class

- Bond calculations using the term structure class

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 ) payment of one dollar (discount factor). It can also be viewed as the yield on a zero coupon bond paying one dollar at time . Alternatively one can think about forward interest rates, the yield on borrowing at some future date and repaying it at a later date . Knowing one of these one also knows the others, since there are one-to-one transforms moving one into the other.

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

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

The forward rate can also be calculated directly from yields as

Note that this assumes continously compounded interest rates.

Code 3.1 shows the implementation of these transformations.

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.

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.

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`.

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

- prices of zero coupon bonds (discount factors).
- yields of zero coupon bonds (spot rates).
- forward rates.

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.

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.

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.

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

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

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

2003-10-22