Z-Spread
Calculates the zero-volatility spread (Z-spread) for a bond given a benchmark zero-coupon (spot) yield curve. The Z-spread is the constant spread that, when added uniformly to every point of the benchmark curve, makes the present value of the bond’s discounted cash flows equal to its observed market price.
Unlike a simple yield spread (the bond’s yield to maturity minus a benchmark yield of the same maturity), the Z-spread is measured against the entire curve rather than a single point, which makes it a more accurate measure of the compensation an investor receives for a bond’s credit and liquidity risk.
The Z-spread is found iteratively using the secant method, in the same way that get_yield_to_maturity solves for the yield to maturity.
Also known as: zero-volatility spread, static spread.
No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Z-Spread for you. Just ask in plain English.
Calculate the Z-Spread in Python
The Z-Spread is available in the Fixed Income module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_z_spread as shown below.
from financetoolkit import FixedIncome
fixedincome = FixedIncome()
fixedincome.get_z_spread(
coupon_rate=0.05,
years_to_maturity=[5, 10, 15],
bond_price=[95, 100, 105],
show_input_info=False,
)
Which returns:
| Bond Price | 5 | 10 | 15 |
|---|---|---|---|
| 95 | 0.0243 | 0.0137 | 0.0103 |
| 100 | 0.0124 | 0.007 | 0.0053 |
| 105 | 0.0012 | 0.0007 | 0.0005 |
Parameters
get_z_spread accepts the following parameters:
- par_value (float): The par value (face value) of the bond.
- coupon_rate (float, optional): The coupon rate of the bond. Defaults to 0.05.
- years_to_maturity (float, optional): The years to maturity of the bond in years. Defaults to None.
- bond_price (float, optional): The price of the bond. Defaults to None.
- spot_rates (pd.Series | dict, optional): The benchmark zero-coupon (spot) yield curve, indexed by maturity in years (in decimal). Defaults to a sample curve.
- frequency (int, optional): The number of coupon payments per year. Defaults to 1.
- guess (float, optional): The initial guess for the Z-spread. Defaults to 0.01.
- tolerance (float, optional): The tolerance level for convergence. Defaults to 0.0001.
- max_iterations (int, optional): The maximum number of iterations for convergence. Defaults to 100.
- 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.