Key Rate Duration
Calculates the key rate duration of a bond for one or more individual maturity points (“key rates”) on the yield curve. Whereas get_duration with duration_type='effective' assumes the entire curve shifts in parallel, key rate duration measures the bond’s price sensitivity to a shock at a single tenor of the curve while every other point is held fixed. Because cash flows are discounted using linear interpolation between the curve’s tenors, a shock at one tenor tapers off towards its neighboring tenors and has no effect beyond them.
Summing the key rate durations across every tenor of the curve approximately reproduces the bond’s effective (parallel-shift) duration, but key rate duration additionally reveals which segment of the curve the bond’s price is most exposed to - information that is essential for constructing curve-neutral hedges or identifying “twist” risk.
Also known as: partial duration, rate-specific duration.
No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Key Rate Duration for you. Just ask in plain English.
Calculate the Key Rate Duration in Python
The Key Rate Duration is available in the Fixed Income module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_key_rate_duration as shown below.
from financetoolkit import FixedIncome
fixedincome = FixedIncome()
fixedincome.get_key_rate_duration(
coupon_rate=0.05,
years_to_maturity=[5, 10],
key_rate_maturity=[2, 5, 10],
show_input_info=False,
)
Which returns:
| Years to Maturity | 2 | 5 | 10 |
|---|---|---|---|
| 5 | 0.0862 | 4.0561 | -0 |
| 10 | 0.0862 | 0.377 | 6.4666 |
Parameters
get_key_rate_duration accepts the following parameters:
- par_value (float, optional): The par value (face value) of the bond. Defaults to 100.
- coupon_rate (float, optional): The coupon rate of the bond. Defaults to 0.05.
- years_to_maturity (float | list, optional): The years to maturity of the bond (or bonds). If not provided, a range of years to maturity will be used.
- spot_rates (pd.Series | dict, optional): The zero-coupon (spot) yield curve used to discount the bond’s cash flows, indexed by maturity in years (in decimal). Defaults to a sample curve.
- key_rate_maturity (float | list, optional): The maturity (or maturities), in
years, of the curve point(s) to shock. Must be present in the index of
spot_rates. Defaults to every maturity inspot_rates. - frequency (int, optional): The number of coupon payments per year. Defaults to 1.
- yield_change (float, optional): The size of the shock applied to each key rate, up and down (in decimal). Defaults to 0.0001 (1 basis point).
- show_input_info (bool, optional): Whether to display input information. Defaults to True.
Related Bond Valuations
The Fixed Income module page introduces the module, and the sidebar lists all of its functions.