Options models are wrong.

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.
Quants use implied volatity surfaces to:

• Calibrate pricing models
• Find market mispricings
• Price exotic derivatives

You can build a volatility surface too:

1. Get live options data
2. Build skew and structure
3. Plot the implied volatility surface

All in Python.
If you want to come back to this thread later, click the link below and retweet the top tweet.

If you enjoy reading about Python and quant finance, follow me @pyquantnews for more.
If you want to dive deep with options, check out the 46-Page Ultimate Guide to Pricing Options and Implied Volatility With Python.

Here's why:

• Black-Scholes, the greeks, and implied volatility
• Jupyter Notebooks with the code
• Live options data

pyquantnews.gumroad.com/l/46-page-ulti…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with PyQuant News 🐍

PyQuant News 🐍 Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @pyquantnews

Feb 15
Two weeks ago, 84% of the world couldn't afford my cohort-based course.

With inflation raging, now it's even worse.

And I think that sucks.

That's why I introduced Purchasing Power Parity (PPP).

Here's how it works:
Depending on the impact the increase in the US dollar has had in your country, you're offered a discount.

The more you've been impacted, the higher the discount.
Everyone I asked told me it was a bad idea because of lower revenue.

But I did it anyway.

In just one week:

• 27 students from around the world enrolled
• Spend per customer is down 19.2%
• New customers are up 3X
Read 5 tweets
Feb 15
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.

codeburst.io/pygam-getting-…
Neural Style Transfer in Python

Neural Style Transfer (NST) is one of the most fun techniques in deep learning which it merges two images.

sandipanweb.wordpress.com/2018/01/02/dee…
Read 11 tweets
Feb 13
The inverted yield curve is a reliable predictor of a recession.

And it’s inverted now.

Use Python to visualize the yield curve over time:
First, import the libraries you need.
Then, grab the data for free from the OpenBB SDK.
Read 7 tweets
Feb 12
Jupyter Notebook is the most powerful tool Python developers have.

But most people don’t know the hidden features.

Need a quick web app?

Or to create REST APIs?

Here are the 6 ways to use Jupyter notebook you never knew existed: The notebook to rule them all.
Jupyter Notebook is a web app for creating and sharing computational documents.

When I say powerful, here's what I mean:

• It supports 40 languages
• Produces rich, interactive output
• Can leverage big data tools like Spark

So, what else can we do with Jupyter Notebook?
Package Development

nbdev let's you develop and publish Python packages right from Jupyter Notebook.

It generates documentation and publishes on GitHub Pages. You can also write tests and setup CI with GitHub Actions.

github.com/fastai/nbdev
Read 12 tweets
Feb 9
I love Python.

But it's slow.

So I built an options pricing library in C and call it from Python.

Now I can trade like a professional (and you can too).

Here's a dead-simple way you can 45x the performance of your Python code with C (code included):
Python is based on C but it's much slower.

Python has to figure out the type of data assigned to variables when it runs.

C is compiled first so it already knows.

This helps C run up to 45x faster than pure Python.

And there's great news...
It's simple to use C with Python!

I'm going to show you how to do 3 things:

• Build an implied volatility solver in C
• Build the Black-Scholes model in C
• Use Python to call the C code

Then I'll build implied volatility charts.

Put on your seatbelt, here we go!
Read 17 tweets
Feb 8
A short interview with a front office quant at Citadel:
Citadel is a high frequency trading firm in Chicago.

It was founded in 1990 and now has more than $50 billion under management.

Citadel is known for it's ruthless culture.

But it's got really smart quants.
I briefly spoke to a friend who's a front office quant about how she uses Python.

This is what she said:
Read 11 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(