Bond Valuation
In [1]:
#Face value
FV = 1000
#Coupon Rate
cr = .02
#Coupon payment
coupon = FV*cr
#Periods
periods = 5
#We get one payment every year
payments = [coupon]*periods
#Last period we also get the face value
payments[-1]+=FV
print(payments)
Now if our discount rate is 5% we can also find what the present value is going to be as we did before.
In [2]:
time = list(range(1,6))
#Get the present value for each year
PV = [x/(1.05)**t for x,t in zip(payments,time)]
print(PV)
#Find the sum over the years
PV = sum(PV)
print(PV)
In [3]:
#Bringing back our timeline function
import matplotlib.pyplot as plt
def timelinePlot(periods,values):
#Create our plot
fig = plt.figure(figsize=(12, 4))
ax = fig.add_subplot(111)
#Set the limits of our plots (in terms of values, not dimensions)
ax.set_xlim(0,10)
ax.set_ylim(0,10)
#Set the minimums that we will be plotting in (we give a 1 or 10% margin on each side)
xmin = 1
xmax = 9
#Set the y of where our plot will be centered around, 5 is the middle
y = 5
#Set height for our ticks
height = 1
#Get the spacing between each tick
delta = (xmax-xmin)/periods
#Create the positions for each tick
positions = [xmin+delta*x for x in list(range(periods+1))]
#Plot the horizontal line
plt.hlines(y, xmin, xmax, color='grey')
for t in range(periods+1):
#Plot the tick
plt.vlines(positions[t], y - .5, y + .5, color='grey')
#Plot the time period below
plt.text(positions[t], y-1.2, t, horizontalalignment='center',fontsize=14)
#Get rid of axes
plt.axis('off')
for value in values:
#Plot a red dot on the year that our value is at
plt.plot(positions[value[1]],y, 'ro', ms = 15, mfc = 'r')
#Plot the values above, use rounding to keep it clean
plt.text(positions[value[1]], y+1.2, "$"+str(round(value[0],1)), horizontalalignment='center',fontsize=18)
plt.show()
#Plot the data
data = [(-PV,0)]
for x,t in zip(payments,time):
data.append((x,t))
timelinePlot(5,data)