Hi,👋 we have updated the app and fixed multiple bugs. We are lacking funds, request to free user not to use Adblock. Ads are non intrusive. 😊

@pyquantnews: Calculating the theta for Amer...

@pyquantnews
8 views Apr 18, 2024
1
Calculating the theta for American options is hard.

It’s the "time decay" of an option's value.

And it’s critical for traders to understand.

The good news?

We have QuantLib to do it for us.

Here’s how:
2
Options theta represents the sensitivity of the option's price to the passage of time.

Theta is a critical concept for options traders to understand.

If you're long theta erodes value.

If you're short, theta makes you money.

Let's go:
3
We’ll start with importing NumPy for some math, OpenBB for data, and QuantLib to calculate theta.
Media image
4
Using OpenBB, grab the options chains to find at-the-money (ATM) strikes, expirations, and historical price data.
Media image
5
We use pandas to find the strike price that’s closest to the last traded price.

Then we find the last closing price and the annualized volatility.

Finally, we hard code the dividend yield, risk-free rate, and set the evaluation date to today.
Media image
6
Now we'll create the QuantLib handles to set the underlying price, yield term structure for the risk free rate and dividend, and the volatility term structure.
Media image
7
We can now build the Black-Scholes-Merton process which models the dynamics of the underlying asset.

Using the Black-Scholes-Merton process, we can build our option pricer.
Media image
8
While this example values a plain vanilla option using constant volatility, QuantLib supports many features to better reflect reality.

Try using a BlackVarianceCurve if you want to specify the at-the-money volatility with respect to time.
Actions
Visual Editor Carousel Maker NEW
Update Thread
What You Can Do
  • Download as PDF
  • Save to Notion
  • Export as Markdown
  • Visual Editor
  • LinkedIn & Instagram Carousel Maker
Create Free Account

Includes 7-day Premium trial