1. Overview
This system builds an LSTM time-series model for JPMorgan Chase (JPM), using daily OHLCV data since 2010 together with live option-chain data, to forecast the direction of the next 10 trading days and generate Buy / Sell / Hold signals, with full backtesting and options-linked suggestions.
2. Model Architecture
- Structure: 2-layer LSTM (hidden = 64) + Dropout(0.3) + fully-connected layers (32 units); Sigmoid outputs the probability of "up over the next 10 trading days".
- Input: sliding window of the past 60 trading days Γ 19 features.
- Ensemble: 5 independently trained seeds averaged by probability to reduce single-model variance.
- Training: Adam (lr=1e-3, weight decay=1e-4), BCE loss, gradient clipping (max norm=1.0), early stopping (patience=12, best weights selected on validation accuracy).
- Framework: PyTorch 2.10.
3. Feature Engineering (19 features)
| Category | Features |
| Price / Trend | MA5 / MA20 / MA60 ratios to close, Bollinger Band position, distance from 52-week high |
| Momentum | RSI(14), MACD & signal line, 5/10/20/60-day momentum |
| Volatility | 20-day rolling volatility, 20/60-day vol ratio, ATR(14) |
| Volume | Volume change rate, 5/60-day volume ratio |
| Short-term returns | 1-day / 2-day lagged returns |
All features are stationarized (ratios / growth rates); normalization uses training-set statistics only to prevent data leakage.
4. Data & Split
- Equity: 4,250 daily bars of JPM (2010-01 to present) via the Yahoo Finance Chart API, adjusted for splits/dividends.
- Options: 521 live option-chain records via the Yahoo Options API (ATM IV 30.4%, Put/Call OI ratio 0.86, volume ratio 0.80), used for signal filtering and options suggestions; historical option chains are not freely available, so they are not part of the historical training data.
- Split (strictly chronological, no shuffling): Train 2010β2022 (2,961 samples) / Validation 2023β2024H1 (374 samples, early stopping & threshold tuning) / Test since 2024.07 (594 samples).
5. Signal Rules & Accuracy
Up probability > 0.60 β Buy; < 0.40 β Sell; otherwise β Hold. Threshold 0.52 is calibrated on the validation set; 0.60/0.40 defines the high-confidence zone.
| Metric (test set) | Value |
| Overall accuracy | 52.5% ("always-up" baseline: 58.8%) |
| Strong-signal accuracy (prob>0.60, 156 samples) | 69.2%, avg forward 10-day return +1.74% |
| Precision / Recall / F1 | 58.4% / 67.1% / 0.624 |
| Confusion matrix | TP=234, FP=167, FN=115, TN=78 |
| Yearly accuracy | 2024: 51.6% Β· 2025: 48.4% Β· 2026: 57.9% |
Methodology note: the test period (2024β2026) was a strong uptrend for JPM, so the "always-up" baseline is naturally high and overall accuracy must be read against that baseline. What matters for trading is the accuracy in the high-confidence zone. Logistic regression (52.2%) and gradient boosting (53.7%) baselines perform on par with the LSTM, reflecting the low signal-to-noise ratio of daily equity direction prediction β confidence-sliced evaluation is the fairer lens.
6. Backtest Setup & Results
- Strategy: long when Buy signal, flat when Sell signal (long/cash); signal at day T takes effect at T+1; 0.1% transaction cost per side.
- Period: 2024-07-01 to 2026-11-10 (594 trading days).
- Results: strategy total return 66.2% (annualized 24.1%, Sharpe 1.04, max drawdown -24.9%) vs buy & hold 66.5% (Sharpe 1.00, same drawdown); 1 trade, 100% win rate, 91.8% time in market.
Limitations: the model shows a long bias learned during the bull market, sell signals rarely trigger, and backtest returns are mostly beta. Re-validation is required in bear markets. The options layer uses live chain snapshots and is not historically backtested.
7. Reproduction Files
Data fetch_data.py fetch_options.py
Training train_model_v3.py (5-seed ensemble saved in model/ensemble_seed*.pt)
Backtest backtest.py (outputs model/backtest.json / backtest_curve.csv)
Signals make_site_data.py (latest-window inference + builds web/data.json)
Disclaimer: This tool is a machine-learning research demo only and does not constitute investment advice. Past performance does not guarantee future results; options trading involves substantial leverage and risk. Use at your own risk.