This guide explains how supervised learning is applied to price prediction, what it takes to build a model properly, the pitfalls specific to markets, what machine learning can and cannot do, and how SEBI's rules apply to strategies built on it.
What supervised learning is
Supervised learning trains a model on examples where the answer is known. Each example has:
- Features: the inputs, such as recent returns, volatility, volume or option data.
- A label: the outcome to predict, such as whether Nifty rises over the next 30 minutes, or by how much.
The model learns a relationship between features and labels on past data, then makes predictions on new data.
Common models
| Model | Strengths | Weaknesses |
|---|---|---|
| Linear and logistic regression | Simple, fast, interpretable | Misses non-linear patterns |
| Decision trees and random forests | Capture interactions, handle mixed data | Can overfit without limits |
| Gradient-boosted trees | Often strong on tabular data | Many settings to tune |
| Neural networks | Flexible, handle large and complex data | Need much data, hard to interpret, easy to overfit |
In research on predicting stock returns, such as Gu, Kelly and Xiu's large study of US stocks, tree-based models and neural networks have improved on linear models, but the gains were modest relative to the noise in returns. Prediction in markets is hard even for the best models.
Building a model properly
- Define the question. For example: will the next 30-minute return of Nifty futures be positive?
- Build features from past data only. Every feature must be known at the moment of the prediction.
- Split data by time. Train on an earlier period, validate on a later one, test on the latest. Never shuffle time series data randomly, which lets the model learn from the future.
- Tune on validation, judge on test. Use the test period once, at the end.
- Walk forward. Retrain on a rolling window and test on the next period, repeatedly. See walk-forward testing.
- Turn predictions into a strategy. Decide how a prediction becomes a trade: thresholds, position size and exits.
- Include costs. A model can be accurate and still lose money if its edge is smaller than costs.
Pitfalls specific to markets
Data leakage
Leakage happens when information from the future slips into the features. Common examples: using the day's closing price to predict an intraday move, normalising data using statistics from the whole dataset, or labels that overlap with the next training example. Leakage produces models that look brilliant and fail live.
Non-stationarity
Markets change. Relationships that held in one period can weaken or reverse in another. A model trained on a calm period may fail in a volatile one.
Low signal-to-noise
Price changes are mostly noise. A model that predicts direction correctly 52% of the time may be useful, or may be luck. Tiny edges are hard to tell apart from chance and easily wiped out by costs.
Overfitting
Flexible models with many parameters can memorise past data. The more models and settings you try, the more likely the best one is a fluke. See avoiding overfitting.
Accuracy is not profit
A model that is right 60% of the time but loses more on wrong calls than it makes on right ones loses money. Evaluate models on the strategy's P&L after costs, not just on accuracy.
What machine learning can and cannot do
It can:
- Find combinations of signals that simple rules miss.
- Classify market conditions, such as trending or range-bound, to switch strategies on or off.
- Improve execution, for example by predicting short-term liquidity.
- Help size positions based on predicted volatility.
It cannot:
- Predict prices reliably over long periods.
- Remove the need for risk controls, stops and position limits.
- Replace a clear reason for why a strategy should work.
Machine learning and SEBI's algo framework
Under SEBI's framework for retail algorithmic trading, which has applied in full since 1 April 2026, algorithms offered to retail investors through brokers are classified as white-box, where the logic is disclosed and can be replicated, or black-box, where it is not. Providers of black-box algorithms must be registered with SEBI as Research Analysts and maintain a research report for each algorithm. Many machine-learning strategies are hard to explain fully, so anyone planning to offer one to others should understand how it would be classified. Our guide to SEBI's algo trading rules covers the framework.
Getting started
If you want to explore machine learning for trading:
- Start with simple models and a clear question.
- Build a clean dataset with careful timestamps.
- Split by time and walk forward.
- Compare the model's strategy with a simple rule-based baseline.
- Paper trade any model before using real money.
QuantPower's strategy builder and backtesting engine focus on transparent, rule-based strategies, which are a good baseline to compare any model against. Our guide to systematic vs discretionary trading explains why transparent rules are easier to trust.
Start your free trial
Connect your broker, build a strategy and test it on paper before a single live order goes out.
Frequently asked questions
Can machine learning predict the stock market?
It can find weak patterns in some conditions, but market returns are mostly noise. Reliable long-term prediction is not realistic.
Which machine learning model is best for trading?
There is no single best model. Simple models are a good starting point; tree-based models often do well on tabular market data. Judge any model by out-of-sample strategy results after costs.
What is data leakage in trading models?
When information that would not have been available at prediction time slips into the model's inputs, making results look far better than they would be live.
Do I need coding skills for machine learning in trading?
Usually yes. Building and testing models properly requires programming, commonly in Python, and careful handling of data.
Sources
- Gu, S., Kelly, B. and Xiu, D. (2020). Empirical Asset Pricing via Machine Learning. Review of Financial Studies, 33(5), 2223–2273
- López de Prado, M. (2018). Advances in Financial Machine Learning. Wiley
- SEBI circular: Safer participation of retail investors in algorithmic trading, 4 February 2025
