Sitemap
Image source: https://www.pexels.com/photo/back-view-shot-of-a-man-working-on-his-computer-7988113/

Bond Risk Sensitivities with Python (Part 2) — Convexity

5 min readJun 25, 2025

Background:

This Part 2 of the article is in continuation to the earlier article on bond risk sensitivities that I had written a few months back. Part 1 of this article can be found at:

https://abhyankar-ameya.medium.com/bond-risk-sensitivities-with-python-part-1-24b164a0ec2e

Part 1 of this article discussed the concept of bond duration and its types along with its Python implementation. As discussed in Part 1, duration is a linear measure of bond risk sensitivity. This Part 2 of the article, goes one step ahead and discusses bond convexity.

Just like the earlier article, we will discuss:

· Concept of bond convexity

· Convexity’s impact on different bond types

· Python modelling for measuring convexity

What is convexity?

Convexity is a measure of sensitivity of the bond price to changes in in yields. We consider the following functional form connecting bond price and yields.

P = f(y)

where, P: bond price; y: yield

Convexity can be defined as below:

where, C: convexity; d2P/dy2: second order differential relating change in bond price w.r.t change in yields

The presence of the second order differential makes it evident that it’s a non-linear measure that can accommodate the convex nature of the bond price vs yield chart. Thus, this being a second order derivative of the bond price w.r.t. yields, lends more flexibility in analysing risk sensitivity to changes in yields.

Understand the nature of price-yield chart for different bonds:

It’s a good idea to understand the nature of convexity i.e., curvature, observed in the price vs yield chart which helps one appreciate the reason for learning the concept of convexity.

Below are three charts giving the nature of price vs yields for:

a. Plain vanilla bonds

b. Callable bonds

c. Puttable bonds

· For plain vanilla bonds: This is a standard price vs yield relation observed in the market. This is by far the most popular diagram depicting the inverse relationship between bond price and bond yields.

· For callable bonds: These are also known as bonds with an issuer call option. This structure allows the bond issuer to go in for early redemption of the bond issued at specific dates and specific price as per the call schedule from the bond prospectus. Due to the call schedule, the bond price gets capped in the face of rising yields. Thus, even if market yields keep dropping (in the extreme if they even go to 0%), the bond price will not rally beyond the call price mentioned in the call schedule. As a result, the bond price vs yield chart “turns and levels off” i.e., shows negative convexity as shows in the diagram for callable bonds above.

· For puttable bonds: These are also known as bonds with an investor put option. This structure allows the investor to sell back the bond to the issuer prior to maturity at specific dates and specific price as per the put schedule from the bond prospectus. Due to the put schedule, the bond price gets a cushion in the face of rising yields. Thus, even if market yields keep rising, the bond price will not drop below the put price mentioned in the put schedule. As a result, in the bond price vs yield chart we observe a “cushion” which prevents bond price from falling below it in spite of increase in yields.

When to bother measuring convexity?

Convexity becomes an important parameter for measuring interest rate sensitivity for bonds that may have:

· Issuer call options

· Investor put options

· Or other pre-payment options

For plain vanilla bonds generally, one does not bother much about calculating convexity. For vanilla bonds, Duration acts as a sufficient measure to approximate interest rate sensitivity.

Approximating bond sensitivity using duration + convexity:

Below given is an approximation to change in bond price for a given change in yield by incorporating duration and convexity.

As some readers may have guessed, the above expression includes the first two terms of the Taylor series expansion. The curvature term can be thought of as a “correction” that we apply in order to factor in curvature in price-yield chart.

Python implementation for measuring convexity:

Convexity can be approximated by the formula below. Please note, we will use the below formula in the Python model for measuring convexity:

where, P0: current price, Δy: assumed change in yield, P+: price when yield drops by Δy;

P-: price when yield rises by Δy.

Note: As this model implementation is for illustrative purposes, there are a few variables that are hard coded in the model below. In real industry level models, we would avoid hard-coding values of variables thereby giving more flexibility to reuse the same model across multiple bonds in the portfolio

Applications:

· Convexity can be used as a metric to hedge against non-parallel shift in yields

· This metric is a must have particularly for non-vanilla bonds

Way forward

This article discussed the convexity — its concept, properties, application and implementation in Python. For readers working on structured bonds desk at bank or a financial institution will most certainly end up incorporating convexity in their analysis and risk management actions. Further, for readers applying for jobs as a fixed income analyst would find it useful to brush up duration and convexity since these concepts are almost certain to appear on interviews.

Happy learning!

--

--

No responses yet