Bond Sensitivity
Duration
The duration of a bond is the weighted average maturity of the bond.
where
- Ct is the cash flow in period t
- Pt is the discount factor, the current price of a discount bond paying par at t.
When holding a bond one would like to know how sensitive the value of the bond is to changes in economic environment. The most relevent piece of the economic environment is the current interest rate. An important component of such calculation is the duration of a bond. The duration of a bond should be interpreted as the weighted average maturity of the bond, and is calculated as
Typical Uses
The duration is a component used in the calculation of a bonds sensitivity to changes in the current interest rates.
Algorithm - Bond Duration using Bond Price
def bondDuration(cashflows, interestRate):
t=0
discountedCashFlows =0
bondprices = 0
while t < len(cashflow):
discountedCashFlows += t* cashflows[t]/ (1+r)**t
bondprices += cashflows[t]/(1+r)**t
return discountedCashFlows / bondprices
Algorithm - Bond Duration using Bond Price
def bondDuration(cashflows, interestRate):
t=0
discountedCashFlows =0
bondprices = 0
while t < len(cashflow):
discountedCashFlows += t* cashflows[t]/ (1+r)**t
bondprices += cashflows[t]/(1+r)**t
return discountedCashFlows / bondprices
Algorithm - Macauly Duration
An alternative is to use the bonds yield to maturity as an aproximation to its price.
def macaulyDuration(cashflows, price): yield = yieldToMaturity(cashflows, price) bondDuration(cashflows, yield)
Bond sensitivity to interest rate changes
The first approximation, Dbo the change in the bond price for a small change in the interest rate Dr, can be calculated
dB0/dB0 ~ - Duration/yield*Dr