ALFFLLM·FINANCE

The List / Trading, Investment, and Portfolio Management / paper

StockGPT: A GenAI Model for Stock Prediction and Trading

Dat Mai

2024Social Science Research Networkcites 17P1arXiv ↗DOI ↗Semantic Scholar ↗Source ↗

Abstract

This article introduces StockGPT, an autoregressive number model trained and tested on 70 million daily US stock returns over nearly 100 years. Treating each return series as a sequence of tokens, StockGPT automatically learns the hidden patterns predictive of future returns via its attention mechanism. On a held-out test sample from 2001 to 2023, daily and monthly rebalanced long–short portfolios formed from StockGPT predictions yield solid performance. The StockGPT-based portfolios span momentum and long-/short-term reversals, reducing the need for manually crafted price-based strategies, and yield sizable alphas against leading stock market factors, suggesting a novel AI pricing effect. This highlights the immense promise of generative AI in surpassing humans in making complex financial investment decisions.

In one sentence

StockGPT is a lightweight decoder-only transformer trained on 70 million daily US stock returns that automatically learns predictive patterns, yielding long-short portfolios with significant alphas against standard asset pricing factors.

Summary

This paper addresses the challenge of automating stock return prediction by applying generative AI logic to numeric time series data. The author argues that while language models have been used for sentiment-based trading, they rely on noisy text proxies. StockGPT treats discrete return intervals as tokens, allowing a transformer to learn hidden price patterns directly from historical data without manual feature engineering or news dependency. The model aims to surpass human-designed strategies by capturing complex dependencies in price movements through its attention mechanism. The methodology involves training a ~1 million parameter decoder-only transformer on 50 million daily US stock returns from 1926-2000. Returns are discretized into 402 bins. The model predicts the next day's return distribution given a 256-day input sequence. Experiments include Fama-MacBeth regressions to assess forecast accuracy and the construction of daily and monthly rebalanced long-short decile portfolios. Performance is evaluated against transaction costs and benchmarked against Fama-French five-factor and Hou q-factor models using spanning tests to determine if the AI strategy subsumes traditional factors. Results show that the daily equal-weighted portfolio yields an annualized return of 119% with a Sharpe ratio of 6.5, while the value-weighted version yields 27% with a Sharpe ratio of 1. The monthly model achieves 13% annual return with a Sharpe ratio of 1. Crucially, spanning tests reveal that StockGPT portfolios earn highly significant alphas against all standard factors, suggesting a novel AI pricing effect. The model also spans momentum and reversal strategies, indicating it automatically learns these patterns. Limitations include the need for frequent retraining, the model's current focus on small-cap predictability, and the lack of high-frequency data integration.

Research problem

The paper investigates whether generative AI architectures, specifically transformers, can be applied directly to numeric stock return data to predict future prices more effectively than manually crafted technical strategies or text-based sentiment models. It seeks to determine if a model trained solely on historical prices can learn complex, non-linear patterns that generate alpha.

Core contributions

  • Introduction of StockGPT, the first GPT model pretrained directly on numeric stock return data rather than financial text.
  • Demonstration that a lightweight (~1M parameter) transformer can learn predictive patterns from 100 years of US stock data.
  • Evidence that StockGPT portfolios span traditional momentum and reversal strategies, automating their discovery.
  • Quantification of a novel AI pricing effect, showing significant alphas against Fama-French and Hou q-factors.
  • Comparison of daily vs. monthly trading horizons, highlighting the trade-off between Sharpe ratio and practical tradability.

Method

  • Decoder-only transformer architecture (vanilla GPT).
  • Return discretization: returns converted to integer basis points, binned into 402 intervals.
  • Input sequence: 256 consecutive daily returns (approx. 1 year of trading days).
  • Training objective: minimize cross-entropy loss for next-token prediction.
  • Forecasting: output probability distribution over 402 bins; expected return calculated as weighted average.
  • Portfolio formation: long top decile, short bottom decile based on predicted returns.
  • Spanning regression: y_t = alpha + beta * x_t + e_t to test factor subsumption.

Results & findings

  • Daily equal-weighted long-short portfolio: 119% annual return, Sharpe ratio 6.5 (2001-2023).
  • Daily value-weighted portfolio: 27% annual return, Sharpe ratio 1.0.
  • Monthly equal-weighted portfolio: 13% annual return, Sharpe ratio 1.0.
  • Monthly alpha against all standard factors: 15.58% (t-stat 4.66).
  • Daily alpha against all standard factors: 111.12% (t-stat 13.73).
  • StockGPT spans momentum, short-term reversal, and long-term reversal strategies.
  • Model trained once in 2000 remains effective for 23 years out-of-sample.
  • Net of 5bps transaction costs, daily strategy still yields 69% annual return.

Data & experiments

  • CRSP data: 70 million daily US stock returns from 1926 to 2023 (NYSE, AMEX, NASDAQ).
  • Training sample: 1926-2000; Test sample: 2001-2023.
  • Discretization of returns into 402 bins (basis points) to create a token vocabulary.
  • Daily and monthly rebalanced long-short decile portfolios.
  • Fama-MacBeth regressions for forecast accuracy evaluation.
  • Spanning tests against Fama-French 5-factor and Hou q5-factor models.

Limitations & caveats

  • Model performance is heavily skewed towards small-cap stocks; large-cap predictability is lower.
  • Requires frequent retraining to maintain performance in dynamic markets.
  • Daily trading strategy is impractical for large capital due to transaction costs and liquidity constraints.
  • Model is lightweight; larger models may perform better but were not tested.
  • Does not incorporate high-frequency data or order book information.
  • Out-of-sample performance may degrade if market regimes shift significantly from training data.

Curator notes

Represents tokenized return sequence modeling for stock prediction.