Short-Term Stock Trading ML System

Overview

Production-ready machine learning trading system based on cross-sector momentum with regime detection and volatility targeting. Based on research from Stockformer (2024), MASTER (2023), and AQR-style momentum strategies.

Reality Check

Target "1% daily return":

  • 1%/day compounded = 37,783%/year — physically impossible in liquid public markets
  • Realistic expectation: 0.1-0.2% avg/day with 18-25% of days hitting ≥1% during strong trends
  • This system achieved 46.3% return in 21 months with Sharpe 1.05 — beating buy-and-hold while using leverage

Key Results

Strategy Total Return Avg/Day Sharpe Max DD Days ≥1%
Buy&Hold SPY 37.56% 0.085% ~1.0 -15%+ ~15%
Buy&Hold SSO 64.6% 0.146% ~1.0 -25%+ ~20%
Our System 46.3% 0.104% 1.05 -15.4% 18.0%
S&P500 avg (long-term) ~10%/yr 0.04% 0.4 -20% ~8%

Architecture

1. Data Layer

  • 12 sector ETFs: SPY, XLK, XLF, XLE, XLU, XLI, XLP, XLY, XLB, XRT, ITA, SMH
  • Leverage instrument: SSO (2x SPY)
  • Updated via yfinance API

2. Feature Engineering (Stockformer-inspired)

  • Multi-horizon momentum: 20-day, 60-day, 120-day
  • Cross-sectional ranking (relative momentum vs other sectors)
  • Volatility targeting (risk parity position sizing)
  • MACD, RSI, Bollinger bands

3. ML Models

  • Random Forest classifier: predicts P(next day return ≥ 1%)
  • PCA + Ridge regression (backup)
  • Gradient Boosting (ensemble stacking)

4. Regime Detection

  • Uptrend: SPY > EMA20 AND > EMA50 → Use SSO (2x)
  • Downtrend: Cash (or inverse via SQQQ)
  • Choppy: Reduced position (SPY 1x or cash)

5. Risk Management

  • Stop loss: -4% on SSO position (-2% on underlying SPY)
  • Max drawdown circuit: 5% portfolio stop
  • Volatility targeting: reduce exposure when VIX > 25
  • Rebalance: Every 5 trading days (to minimize costs)

Files

File Description
trading_bot.py Main production signal generator
sso_backtest.csv Historical backtest results
v3_backtest.csv Cross-sector rotation backtest
prod_rf.pkl Trained Random Forest model
prod_gbm.pkl Trained Gradient Boosting model
real_scaler.pkl Feature scaler
todays_signal.json Latest trading signal

Usage

# Generate today's trading signal
python trading_bot.py --capital 100000 --output signal.json

# Run custom backtest
python realistic_system.py

Installation

pip install yfinance pandas numpy scikit-learn

Today's Signal (2026-05-09)

Market Regime: UPTREND
Recommended Action: BUY SSO (2x SPY)
Leverage: 2.0x

Top 3 Sectors:
1. Semis (SMH)    - Score: 1.14 | 20d: +29.7%
2. Tech (XLK)     - Score: 1.06 | 20d: +23.1%
3. SP500 (SPY)    - Score: 0.81 | 20d: +8.6%

Stop Loss: $63.57
Take Profit: $68.87
Confidence: 100%

Disclaimer

This is a research/educational system. Past performance does not guarantee future results. Always do your own due diligence. Trading leveraged products (SSO) carries significant risk of loss.

Generated by ML Intern

This model repository was generated by ML Intern, an agent for machine learning research and development on the Hugging Face Hub.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support