π LSTM-Based Options Upside Classifier
Predict whether an option contract has upside potential using a deep learning model trained on market-derived features. This project uses a time-aware LSTM model to capture temporal dynamics and trends in the options market.
π Motivation
In options trading, identifying contracts with likely upside can significantly boost strategy returns. Most traditional models overlook temporal dependencies β our LSTM model leverages time series sequences of engineered features to predict if an option will have a positive return in the near future.
π§ Model Overview
- Architecture: LSTM + Dense layers
- Problem Type: Binary classification (
UpsideorNo Upside) - Evaluation: Achieves >90% on precision, recall, and F1
π Performance
| Metric | Value |
|---|---|
| Accuracy | 88.02% |
| Precision | 92.23% |
| Recall | 93.20% |
| F1 Score | 92.71% |
| ROC AUC | 0.9067 |
Confusion Matrix:
[[ 9190 5000] # True Negatives / False Positives [ 4329 59350]] # False Negatives / True Positives
π¦ Features Used
- Time-based:
days_to_expiry,day_of_week,month - Price action:
intraday_range,daily_return,log_return - Volatility:
volatility_ratio - Strike comparison:
price_vs_strike,pct_above_strike - Market sentiment:
oi_change_ratio,volume_per_oi,val_per_contract - Rolling signals:
rolling_mean_5,rolling_std_5,return_5d
All features are standardized before being fed into the LSTM.
π§ͺ Dataset & Preprocessing
- Input: Time series of option features with a binary label (
1if future return > 0, else0) - Scaling:
StandardScalerused on both features and target - Sequence building: Uses sliding window of
10timesteps - Train/test split: Chronologically split to avoid time leakage
π οΈ Training
model.fit(
X_train_seq, y_train_seq,
validation_split=0.2,
epochs=50,
batch_size=32,
callbacks=[EarlyStopping(patience=10, restore_best_weights=True)]
)
π§Ύ How to Use Load the Model:
from tensorflow.keras.models import load_model
model = load_model("models/option_upside_lstm.h5")
Predict:
X_seq = prepare_sequences(your_feature_df, scaler, time_steps=10)
preds = model.predict(X_seq)
To install all requirements, simply run:
pip install -r requirements.txt
π€ Contributing Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change or improve.