Implied volatility is not the same over the life of an option.
Prove it with volatility surfaces.
Here's how to do it in Python (step by step):
By reading this thread, you’ll be able to:
1. Get live options data 2. Analyze volatility skew 3. Analyze volatility structure 4. Build an implied volatility surface
But first, a primer on implied volatility…
If you’re not familiar with implied volatility:
• Market’s expectation of volatility
• Varies across strikes and expirations
• Where most quants and traders spend their time
• The input that sets model and market price equal
Let's build a volatility surface.
First, import the libraries you need.
yfinance gives you options data - including implied volatility.
Nothing fancy required.
yfinance returns options data for all strikes for a single expiration at a time.
It’s easier to work with all strikes and expirations at the same time.
Write a function to combine the expirations.
Since we only want to look at calls, filter them out of the DataFrame.
But first, call the function you just built to get the data.
Now you’re ready to look at the volatility skew.
Since the options are in a DataFrame, plotting data is easy.
Next, you can see what the skew looks like.
You’ll notice two things:
1. The data are messy 2. Implied volatility varies by strike
In particular it is lowest at the $400 strike, which is right around the stock price.
This is known as volatility smile.
Create a chart of the term structure by selecting a strike.
Plotting is easy with pandas.
Implied volatility decreases as the expiration dates get further out.
The market expectation of volatility is lower in the future than it is today.
Big economic news causes spikes in the term structure.
Finally, let’s put the two charts together and look at the surface.
Pivot the DataFrame to arrange strikes on the rows and expirations on the columns. Implied volatility will be in each cell.
Use meshgrid to get the surface coordinates.
Finally, plot the surface with plot_surface.
What do you get?
An implied volatility surface!
You can see that volatility is much higher at the close expirations and higher strikes.
Quants use this information to price exotic options and find market mispricings.
7 powerful machine learning techniques everyone should know (with links to Python code):
pyGAM: Getting Started with Generalized Additive Models in Python
Generalized additive models provide a modeling approach that combines powerful statistical learning with interpretability, smooth functions, and flexibility.