Calculate the modified duration of a bond
mod_duration(yields, maturity, format_out = "xts")A series of modified duration
a series of yields
constant bond maturity in years
xts or tibble
This function is normally used in combination with total_return() to compute bond total returns.
The modified duration is the interest rate sensitivity of the price of bond.
$$duration = \frac{1}{y_t}{z_t}^{2M}$$
with
$$z_t = 1+\frac{y_t}{2}$$
\(M\) is the maturity in years (e.g. 10), \(y_t\) is the yield at time \(t\).