Skip to content

Yields of zero-coupon bonds

Course exercise 54 · Part I

Problem

Write a function that turns zero-coupon bond prices into annual yields, and apply it to five bonds with maturities from 3 months to 2 years.

Method

A zero-coupon bond pays 100 at maturity \(T\), so its price \(P\) implies the annual yield:

\[ P = 100\,(1 + i)^{-T} \quad\Longrightarrow\quad i = \left(\frac{100}{P}\right)^{1/T} - 1 \]

Code

clear all, clc
format long

% Point 1
    % See F_es54 (local function below)

% Point 2
    P = [99.88, 99.85, 99.76, 99.24, 97.33];
    T = [1/4, 1/3, 1/2, 1, 2];          % 3-months, 4-months, 6-months, 1-year, 2-years to maturity

    ZCB_returns = F_es54(P, T)

% Point 3
    % save('Annual_return.txt', 'ZCB_Returns', '-ascii');


function [i] = F_es54(P, T)
% inputs:   P := price at inception
%           T := maturity
% output:   i := interest rate

n = length(P);
m = length(T);

% force the dimensions of the matrix
P = reshape(P, n, 1);   % reshape P into an n x 1 column
T = reshape(T, m, 1);   % reshape T into an m x 1 column

i = (100 ./ P).^(1 ./ T) - 1;
end
import numpy as np


# %% function F_es54

def F_es54(P, T):
    # inputs:   P := price at inception
    #           T := maturity
    # output:   i := annual interest rate

    i = (100 / P) ** (1 / T) - 1
    return i


# %% Point 2
P = np.array([99.88, 99.85, 99.76, 99.24, 97.33])
T = np.array([1/4, 1/3, 1/2, 1, 2])     # 3-months, 4-months, 6-months, 1-year, 2-years

ZCB_returns = F_es54(P, T)
print("ZCB_returns =", ZCB_returns)

Results

Maturity Price Annual yield
3 months 99.88 0.481%
4 months 99.85 0.451%
6 months 99.76 0.482%
1 year 99.24 0.766%
2 years 97.33 1.362%

Takeaways

  • Yields must be annualised with the exponent \(1/T\) to be comparable across maturities.
  • The prices imply a slight dip at 4 months, then a rising curve.