DEV Community

Cover image for The Illusion of Accuracy: Why Gradient Descent Can Mislead Trading Forecasts
Vikas Srinivasa
Vikas Srinivasa

Posted on

The Illusion of Accuracy: Why Gradient Descent Can Mislead Trading Forecasts

Traditional machine learning approaches in financial markets often model stock prices as time-series data, assuming that historical price patterns can predict future movements. However, this approach is fundamentally flawed because stock prices do not follow a continuous or structured progression over time. Instead, price movements are dictated by order book dynamics, liquidity, and market events, leading to an event-driven and discontinuous behavior. This blog argues that treating stock market data as a conventional time series misrepresents its true nature, resulting in ineffective machine learning models. We propose a new framework for AI-driven stock price modeling that leverages event-driven architectures, order book data, and sentiment analysis instead of time-series forecasting techniques.

Introduction

Machine learning has been extensively applied in financial markets for stock price prediction, with models such as ARIMA, GARCH, LSTMs, and Transformers. These models operate on the assumption that stock prices evolve over time in a structured way, similar to classical time-series datasets. However, stock prices are not inherently a function of time; instead, they are driven by discrete market events, order execution, and changes in supply and demand. This blog challenges the traditional time-series approach in financial ML and introduces an alternative event-driven framework that better reflects real-world stock price movements.

The Problem with Time-Series-Based Stock Predictions

Defining Time-Series Data

A dataset is considered time-series data if it possesses the following characteristics:

  • Regular Time Intervals: Data is collected at fixed, sequential time intervals (e.g., every second, minute, hour, day).

  • Continuous Evolution: Future values depend smoothly on past values, allowing for trend extrapolation.

  • Stationarity and Predictability: Many time-series models assume that past behavior can help forecast future trends.

Why Stock Prices Do Not Fit Time-Series Characteristics

Unlike classical time-series datasets, stock prices exhibit:

  • Event-Driven Changes: Prices move only when an order is executed, not at fixed time intervals.

  • Discontinuous Jumps: The price can instantly move several points up or down based on a large market order, rather than evolving smoothly.

  • Non-Stationarity: Financial markets are influenced by external macroeconomic factors, news events, and sentiment shifts, leading to unpredictable movements.

Feature Selection and Engineering Failures in Traditional ML Models

Lagging Nature of Historical Prices & Technical Indicators: Machine learning models that rely on past price data often suffer from overfitting and poor generalization. Historical prices and technical indicators are lagging variables—they do not cause price changes but merely reflect them after they occur !

  • Irrelevance of Price Trends: Price-based features are only one part of the equation in determining future movements, but they have weak causal influence on supply-demand dynamics.

  • Better Feature Selection with Order Book & Sentiment Data: More effective models should incorporate order book imbalances, bid-ask spreads, market depth, and sentiment analysis to capture real drivers of price changes.

Why Do Traditional ML Models Still Show Good Training Results Despite Using Incorrect Features?

One of the biggest misconceptions in financial machine learning is that because a model performs well in training, it must be using valid predictive features.

However, this is often not the case, due to the power of gradient descent in optimization:

  • Gradient Descent Can Fit Even Incorrect Features: The optimization process in machine learning adjusts model parameters to minimize loss, meaning that even if the input features are weak or irrelevant, the model will still find a way to reduce error. This creates an illusion of predictive power where none exists!

  • Overfitting to Historical Correlations: Since historical stock prices contain patterns and trends, gradient descent can find relationships that minimize loss without those relationships being causal or meaningful.

  • Poor Generalization to Future Market Conditions: These models tend to perform well on training data but fail in real-world trading because they are optimizing for past patterns rather than actual supply-demand dynamics.

After minimizing the loss using gradient descent, we have essentially force-fitted a real-world problem into a flawed equation. In live trading and testing, we are then attempting to make predictions based on relationships that DO NOT exist in reality. This explains why many machine learning models that show strong backtest results fail when deployed in real trading environments.

A Non-Trading Example: Why Feature Selection Matters

To illustrate why modeling features that drive the outcome is superior to using lagging indicators, consider medical diagnostics:

  • Bad Approach (Lagging Features): Suppose a doctor tries to predict heart attacks using past hospital visits and previous mild chest pain episodes. While this data may correlate with heart attacks, it does not cause them.

  • Better Approach (Causal Features): Instead, if the doctor models features like blood pressure spikes, cholesterol levels, and artery blockage, these directly impact the likelihood of a heart attack and provide a much more accurate and early prediction.

This same logic applies to stock price modeling! Focusing on the actual forces that move prices (order book shifts, news sentiment, liquidity imbalances) results in a more reliable model than relying on past price movements alone.

The AI-Driven Event-Based Approach to Stock Market Modeling

Why This Approach is Superior

Unlike traditional ML models that rely on historical prices, my AI-driven approach focuses on news events that directly impact how a stock’s valuation is perceived.

Rather than using price trends, the model incorporates:

  • Sentiment analysis on financial news and updates.

  • A stock’s fundamental data as contextual reference to determine how impactful an event is.

  • Bid-ask imbalances and liquidity signals to gauge market sentiment and supply-demand shifts.

By combining these features, my strategy identifies opportunities before price movement occurs, rather than reacting to past trends like conventional ML models do.

How This Improves Trade Selection

Most ML models pick trades based on past price action, which is inherently reactive.

My AI-driven approach identifies trades based on leading indicators, such as how an event changes an investor’s perception of a stock’s value.

This leads to better trade selection and execution compared to traditional ML-based trading models.

Implications for AI-Driven Trading Strategies

Shifting from time-series forecasting to an event-driven framework can significantly enhance algorithmic trading performance.

Key benefits include:

  • Higher Predictive Accuracy: By incorporating real-time order book data and market events, AI models can anticipate price jumps more effectively.

  • More Adaptive Learning: Event-driven models dynamically adjust to new market conditions, unlike static time-series models that overfit to past trends.

  • Better Risk Management: Incorporating order book liquidity and slippage reduces execution risks in real-world trading.

Conclusion

Stock prices should not be treated as a traditional time series. The reality of stock price movements—driven by order book dynamics, liquidity changes, and external events—invalidates many of the assumptions underlying classical time-series forecasting. This blog advocates for an event-driven AI modeling approach that integrates market microstructure, sentiment analysis, and reinforcement learning to better capture stock price behavior. By adopting this framework, AI-based trading systems can move beyond outdated price-based forecasting methods and develop more robust predictive models.

Top comments (0)