Duration
Instead of introducing the equation for duration right away, we will work through an example. We have a 3 year, 5% coupon bond with face value of 1000. If r = 8%, what is the present value?
Well, let’s first get the cash flows for each period.
Period | Cash Flow |
1 | 50 |
2 | 50 |
3 | 1050 |
Let’s get the present value of each.
flows = [50,50,1050]
period = [1,2,3]
flowsPV = [x/(1.08)**y for x,y in zip(flows,period)]
print(flowsPV)
print(sum(flowsPV))
Period | Cash Flow | PV |
1 | 50 | 46.29629629629629 |
2 | 50 | 42.86694101508916 |
3 | 1050 | 833.5238530711781 |
Now, what we want to see is what the present value of each cash flow is in terms of the total present value. This weight will be a factor in the duration equation.
weights = [x/922.6870903825636 for x in flowsPV]
print(weights)
Period | Cash Flow | PV | Weights |
1 | 50 | 46.29629629629629 | 0.05017551104687177 |
2 | 50 | 42.86694101508916 | 0.04645880652488127 |
3 | 1050 | 833.5238530711781 | 0.9033656824282469 |
The final step is multiplying these weights by the number of periods until each cash flow is realized. We will then sum these numbers to get the duration.
weightedYears = [x*y for x,y in zip(weights,period)]
print(weightedYears)
print(sum(weightedYears))
Period | Cash Flow | PV | Weights | Weighted Years |
1 | 50 | 46.29629629629629 | 0.05017551104687177 | 0.05017551104687177 |
2 | 50 | 42.86694101508916 | 0.04645880652488127 | 0.09291761304976254 |
3 | 1050 | 833.5238530711781 | 0.9033656824282469 | 2.7100970472847408 |
We get a duration of 2.853 from this bond. This duration is called Macaulay duration (other forms of duration will be covered in the fixed income course) and its equation is:
Equation
t
t = Period
w
t
= Weight in Period t
Challenge