# Use Matlab to Understand Bonds Valuation

1. Basic knowledge:

1.1 The price equation and its six contributing factors

As we know, there are six factors that determine the expected price of bonds: the par value(F),

the maturity(n)

the yield to maturity(y),

the coupon interest(CF),

the interest payment frequency(m),

and the interest rates for each period(ri).

We assume that the coupon interest is fixed, then the price of bonds(P)is the discounted cash flows of each period: P=i=1nm(CF(1+ym)i)+F(1+ym)mn=i=1nm(CF(1+rim)i)+F(1+rnm)mn

Indeed, to intuitively understand this equation is not easy. Firstly, we can see that the yield to maturity(y) is a kind of “average” of the interest rates(ri) for each period. Thus, when one of the interest rates goes up, so does the YTM(yield to maturity).

We can simplify this equation: P=fy,n,m,F,CF=fri,n,m,F,CF.

So, there are at last five variables in each equation. In each bonds, the par value(F), the interest(CF), and the way to pay interest(m and n)are predetermined. Thus the change in price is mainly due to the change in YTM, in other words, due to the change in interest rate, thus we can simplify this equation to: P=fy|n,m,F,CF= fri|n,m,F,CF or

P=fy= fri

1.2 For example (This example will be used throughout the paper): The Pembroke Co. wants to issue the bonds that have:

Par value(F):$100

Coupon interest(CF): $10

Coupon interests are paid annually (m=1),

Maturity(n): 5years

Thus P=fy=i=15(10(1+y)i)+100(1+y)10

2 The trend of YTM:

2.1 relation between YTM and interest rates in future periods: The relation between the YTM and periodic interest rates is not so easy to understand, from the equation: P=i=1nm(CF(1+ym)i)+F(1+ym)mn=i=1nm(CF(1+rim)i)+F(1+rnm)mn

We can see that the YTM have a positive relation with each period’s interest rate, the YTM is a kind of “average” of each period’s interest rate. In order to see how YTM changes in future, we consider that the interest rate in the future be the forward interest rate and have three kinds of simple situation: The first situation is the flat expectation, meaning the future interest rates will keep constant, the second one is the upward expectation, meaning the future interest rates will keep growing, and the third one, downward expectation, means the interest rates will decrease in future. We know that the YTM is a kind of “average” of future interest rate, thus if future interest rate goes up, so does the YTM.

2.2 Using Matlab to construct the function YTM and interest rates Using Matlab, we can draw charts to show the relations between the future interest rate and YTM, here is my method:

Firstly, we need to write a function ytm(r, CF, F), which includes inputs of row vector r (r includes all the expected periodic future interest rates), the maturity n (the number of the elements in r), the CF and F. Then ytm(r, CF, F) will calculate and the YTM and the bonds price and return the YTM.

Here is the code of function:

function s=ytm(r,CF,F)

% Calculate the YTM and P given interest rates, CF, and F

% Calculate and return the bonds price P

[x y]=size(r);

P=0;

if y ==1

s=r;

else

for i=1:y

P=P+CF./((1+r(i)).^(i));

end

P=P+F./((1+r(y)).^(y));

% Construct the right side of equation for YTM

A=poly2str([CF*ones(y+1,1)]+[F;zeros(y,1)],'*s');

A=A(1:(length(A)-length(CF)-3));

% Construct the equation for YTM

function s=ytm(r,CF,F)

% Calculate the YTM and P given interest rates, CF, and F

% Calculate and return the bonds price P

[x y]=size(r);

P=0;

if y ==1

s=r;

else

for i=1:y

P=P+CF./((1+r(i)).^(i));

end

P=P+F./((1+r(y)).^(y));

% Construct the right side of equation for YTM

A=poly2str([CF*ones(y+1,1)]+[F;zeros(y,1)],'*s');

A=A(1:(length(A)-length(CF)-3));

% Construct the equation for YTM

Pstr=num2str(P);

b=strcat(Pstr,'=');

A=strcat(b,A);

% Solve the equation and calculate the YTM

s=solve(A,'s');

s=s(find(imag(s)==0 & s>0...

Please join StudyMode to read the full document