Price, Yield and Risk Measures#
A bond price is the present value of its cash flows. A yield is the single discount rate that turns the cash flows into the price. Duration and convexity then say how much the price moves when the yield moves. This page sets out the three, with a worked example in Python.
Price from yield#
For a bond with cash flows \(CF_i\) at times \(t_i\) (in years), and a yield \(y\) that is compounded annually:
The last cash flow includes the repayment of the principal. This page uses annual compounding to keep the formulas short. A market yield may be quoted with another compounding frequency or day count, and the convention has to be applied in the same way everywhere.
The yield to maturity (YTM) is the value of \(y\) that makes this formula equal to the market price. There is no closed formula for it, so it is solved numerically. A higher yield gives a lower price, and the relationship between the coupon and the yield tells you where the price sits against par:
Coupon against yield |
Price against par |
The bond is said to trade |
|---|---|---|
Coupon below yield |
Below 100 |
At a discount |
Coupon equal to yield |
At 100 |
At par |
Coupon above yield |
Above 100 |
At a premium |
Other yield measures:
Current yield is the annual coupon divided by the clean price. It ignores the gain or loss at maturity.
Yield to call is the yield if the bond is called on a given call date.
Yield to worst is the lowest of the yield to maturity and the yields to each call date. It is the figure that a callable bond is quoted on.
Duration, DV01 and convexity#
Macaulay duration is the average time to the cash flows, weighted by their present values. Modified duration converts it to a price sensitivity:
A modified duration of 4.4 means that the price falls by about 4.4% for a rise of one percentage point in the yield. DV01 is the price change for one basis point:
Convexity corrects for the fact that the price-yield relationship is a curve and not a straight line:
A worked example#
The example below prices a 5-year bond that pays a 4% annual coupon at a yield of 5%. It is valued on a coupon date, so the clean and dirty prices are the same. It then:
Calculates the price, the Macaulay and modified duration, the DV01 and the convexity.
Shocks the yield up and down, and compares the exact change in price with the estimate from duration, and from duration with convexity.
Python code
"""Price, yield, duration, DV01 and convexity of a fixed-rate bond."""
import numpy as np
face = 100.0
coupon_rate = 0.04
maturity = 5 # years; annual coupons, valued on a coupon date so there is no accrued interest
ytm = 0.05 # yield to maturity, annually compounded
times = np.arange(1, maturity + 1)
cash = np.full(maturity, face * coupon_rate)
cash[-1] += face # principal is repaid with the last coupon
def price(y):
"""Present value of the cash flows at the yield y."""
return (cash / (1 + y) ** times).sum()
p = price(ytm)
pv = cash / (1 + ytm) ** times
macaulay = (times * pv).sum() / p # weighted average time to the cash flows
modified = macaulay / (1 + ytm) # price sensitivity to the yield
dv01 = modified * p * 1e-4 # price change for one basis point
convexity = (times * (times + 1) * cash / (1 + ytm) ** (times + 2)).sum() / p
print(f"Price : {p:8.4f}")
print(f"Macaulay duration : {macaulay:8.4f} years")
print(f"Modified duration : {modified:8.4f}")
print(f"DV01 (per 100 face) : {dv01:8.4f}")
print(f"Convexity : {convexity:8.4f}")
print()
print("Change in price for a yield shock, per 100 face")
print(f"{'Shock':>8} {'Full revaluation':>18} {'Duration only':>15} {'Duration + convexity':>22}")
for shock in (-0.02, -0.01, 0.01, 0.02):
full = price(ytm + shock) - p
by_duration = -modified * shock * p
by_both = by_duration + 0.5 * convexity * shock ** 2 * p
print(f"{shock * 1e4:6.0f}bp {full:18.4f} {by_duration:15.4f} {by_both:22.4f}")
The output is:
Price : 95.6705
Macaulay duration : 4.6203 years
Modified duration : 4.4003
DV01 (per 100 face) : 0.0421
Convexity : 24.4724
Change in price for a yield shock, per 100 face
Shock Full revaluation Duration only Duration + convexity
-200bp 8.9092 8.4196 8.8879
-100bp 4.3295 4.2098 4.3269
100bp -4.0953 -4.2098 -4.0927
200bp -7.9711 -8.4196 -7.9513
Points to notice:
The coupon is below the yield, so the bond trades at a discount to par.
The DV01 is about 0.042 per 100 of face value for each basis point. On a position of 10 million face value that is about 4,210 for each basis point.
Duration on its own understates the gain when the yield falls and overstates the loss when it rises, because the price curve bends. Adding convexity brings the estimate very close to the full revaluation for a 100bp move. The error grows with the size of the shock.
A valuation control view#
Conversion between price and yield: the compounding frequency, day count and settlement date must be the same in every system that converts between price and yield. A vendor may quote a yield on a different convention from the one your system uses.
Tolerances in yield and price: a tolerance expressed in yield can be turned into a price tolerance with the DV01. A yield difference of 2bp on a bond with a DV01 of 0.042 is about 0.084 in price. The same yield tolerance is a much wider price tolerance for a long bond than for a short one.
Risk numbers: check that the duration or DV01 reported for a position is scaled to the position’s face value, and has the right sign for a short position.
Embedded options: modified duration assumes fixed cash flows. For a callable bond the cash flows change with the yield, so an effective duration from a model is the correct measure. See Spreads and Reference Curves.
Large moves: for a stress or a large price change, check that the estimate includes convexity, or that the position is fully revalued.