Minute-Level Stock Prediction & Backtesting
Pythonscikit-learnpandasNumPyBacktestingTime-Series
An intraday price-direction system over 9.4M NSE tick records across 31 NIFTY stocks — from raw ticks to minute bars to a directional model and a probability-thresholded backtest — raising next-minute prediction precision from 0.51 to 0.61.
End-to-end system
- Built an intraday price-direction system over 9.4M NSE tick records across 31 NIFTY stocks, raising next-minute prediction precision from 0.51 to 0.61.
- Engineered a tick-to-minute-bar pipeline condensing 2.9M trades and 6.4M quotes into ~11,600 labeled OHLC feature rows across 31 stocks.
- Designed a minute-level trading signal from NSE order-flow and quote data, validated through a probability-thresholded backtest over 3,100 held-out bars.
Modeling & features
- Trained a scikit-learn RandomForestClassifier on 20+ engineered features and tuned a 0.63 probability threshold to suppress false buy signals, lifting precision to 0.61.
- Constructed rolling mean and standard-deviation features over 3-, 5-, 10- and 20-minute windows on price and volume using pandas groupby-transform.
- Computed per-minute VWAP, OHLC, and bid-ask spread statistics from raw order flow to capture intraday liquidity and momentum signals.
Leakage control & backtesting
- Labeled next-minute return direction with horizon-shifted targets and a per-company time-ordered train/test split to prevent look-ahead leakage.
- Backtested threshold-filtered long signals across 3,100 minute bars with per-trade PnL accounting, comparing precision and trade count at 0.5/0.6/0.7 cutoffs.
- Ingested 31 per-symbol tick files (~9.4M rows) with a pandas loader, tagging each record by company and concatenating into unified trade and quote datasets.
← Back to projects