Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
In this notebook we will explore a machine learning approach to find anomalies in stock options pricing.
| Date | Stars |
|---|---|
| 2026-07-31 | 276 |
| 2026-08-05 | 276 |
| 2026-08-06 | 276 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# Unsupervised Learning for anomaly detection in options pricing
**Note**: This notebook is part of a broader work for predicting stock prices. The outcome (identified anomaly) is a feature (input) in a **LSTM** model (within a **GAN** architecture)- <a href='https://github.com/borisbanushev/stockpredictionai'>link to the repo</a>.
#### 1. Why using options pricing data and anomalies as inputs in the GAN?
Options valuation is a very difficult task. It entails using a lot of data points (some are listed below) and some of them are quite subjective (such as the implied volatility - see below) and difficult to calculate precisely. As an example let us check the calculation for the call's _Theta_ - $\theta$:
<center><img src='imgs/Options/calltheta.png'></img></center>
where (among others) $N(d_1)$ and $N(d_2)$ are cumulative distribution functions for a standard normal distribution, respectively:
<center><img src='imgs/Options/optionsinfo.png'></img></center>
and the **Black-Scholes** formula which is used for calculating the options price itself. The formula for calculating the price of a European call option with maturity in $t$ and current price of $S_0$ is:
<center><img src='imgs/Options/bsmcall.png'></img></center>
Second, the Black-Scholes model, famously known as _binomial tree_, requires a lot of assumptions to be met in order for the model to be accurate. These rules, however, most often cannot be met in real life. Some of them include:
- the model assumes that the underlying volatility ($\sigma$) is constant over the life of the option and stays unaffected by changes in the underlying stock price levels. Many times the volatility changes with changes in the strike price - the higher the difference between strike and the underlying price, the higher the volatility. This phenomenon is called the **Volatility smile** (refer to the chart below),
- the model assumes constant risk-free rate of return (something difficult to anticipate as the global economy changes every day),
- the model does not account for liquidity risk and additional fees/charges,
- it assumes that stock returns follow lognormal distribution (meaning that the model ignores the possibility of large price deviations, surge or drop, something that can easily be observed in real trading),
- assumes no dividend payout. Dividend payouts change the current valuation of the stock, which in turn should change the options price,
- the model is applicable only for European options.
The fact that the aforementioned assumptions can rarely be met in real-life is exactly why anomalies can be observed. This, in turn, creates a lot of opportunities we can explore and exploit with machine/deep learning, such as arbitrage trading.
```python
"""
===== IMPORTANT:
Execute the following code cells (below) first in order to instantiate the 'options_df' dataframe
"""
curr_price_ = options_df.iloc[0,0]
plt.figure(figsize=(10, 6))
plt.scatter(options_df.Strike, options_df.IVAsk, label='IV to Strike', \
c='royalblue')
plt.vlines(curr_price_, options_df.IVAsk.min(), \
options_df.IVAsk.max(), \
label='Current GS price - ${}'.format(curr_price_), \
linestyles='--', colors='gray')
plt.xlabel('Strike price - $')
plt.ylabel('IV')
plt.title('Options Volatility smile')
plt.legend(fontsize='large')
plt.savefig('imgs/Options/volatilitysmile.jpg', dpi=100)
plt.show()
```

_Not a perfect smile at this example, but we only used data for one day._
The difficulty in options valuation creates a lot of opportunities for arbitrage (something we will explore in another post). So let's go back to our original idea - predicting stock prices. As we already mentioned, we want to use as many different types of features in order to find, and account for, eExcerpt of 22,825 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:7fe2c72ca9ed0f03, llm:description: 'In this notebook we will explore a machine learning approach to find anomalies in stock options pricing.' Language: Jupyter Notebook
matched fp:7fe2c72ca9ed0f03, llm:description: 'In this notebook we will explore a machine learning approach to find anomalies in stock options pricing.' Language: Jupyter Notebook
matched fp:7fe2c72ca9ed0f03, llm:description: 'In this notebook we will explore a machine learning approach to find anomalies in stock options pricing.' Language: Jupyter Notebook