How to Calculate Option Adjusted Spread (OAS) for Bonds with Python Programming

John T Foxworthy
4 min readMay 6, 2021
Image by Erik Johansson

Bonds are complicated, especially non — conventional ones. One of the most popular metrics in the Fixed Income industry is the Option Adjusted Spread or OAS. Bonds, as a generic product of the framework of Fixed Income, are all Debt.

Debt is an increase in current spending in exchange for a decrease in future spending. The process of debt has many products, which do vary by the components that roll up to its value and risk.

OAS is a checkpoint metric before a debt deal ends, specifically for non — conventional debt. Generically, the OAS calculation is the difference between the Yield Spread and the Cost of the Option Feature, which is expressed in basis points. Below the code has an OAS output of 0.213441, which is a particular methodology called Hull-White.

As a short write-up and proof of concept, the OAS below takes in the callable feature of the issuer of the bond, . . . let’s say, some US company in a generic corporate bond product. Before the debt deal ends, the bondholder takes the risk of exiting the deal because the other side, the issuer, calls back the deal.

Is callable the only option feature in a bond? No, there is puttable, sinkable, and more, but let’s walk before we run.

I will use the old QuantLib library and I am happy to see the conversion from C++ to Python. Otherwise, there would be no demand for its products and services going forward in the industry of finance. I set the calculation date to the past quarter date and create an instance.

For ease of implementation, I assume an 3.5% flat yield curve for the interest rate term structure.

My typical assumption is a five year deal in the corporate bond market followed by its call schedule. There are many parameters, but all of them follow a convention in the Fixed Income Markets. We can always go back and agitate these inputs, but let’s proceed to complete a single example to work on . . .

Conventional bond debt product valuation is below as a placeholder for further analysis.

Not everything settles in 2 days and 360 is the wrong basis, but these are conventions before you and I were born. North of a billion notional begins to agitate precision, but let’s move on . . .

We now value the bond with the discounting bond engine.

To add the credit spreads we take the base spread of 50 basis point to agitate above the treasury yield curve. We shock the flat_rate in the yield term structure and view the net present value differences.

A Parallel Shift of the Yield Curve.

A Non — Parallel Shift in the Yield Curve.

Image by John T Foxworthy

A bond revaluation with tree grid points followed by a OAS calculation.

Let me know what you think and comment below.

--

--

John T Foxworthy

Machine Learning Management Consultant & Data Science Manager with a M.S. in Data Science