MarketGPT: Developing a Pre-trained transformer (GPT) for Modeling Financial Time Series
MarketGPT: Developing a Pre-trained transformer (GPT) for Modeling Financial Time Series
This paper presents MarketGPT, a generative pre-trained transformer (GPT) designed to model financial time series at the limit order book (LOB) level. The model functions as an order generation engine within a discrete event simulator (DES), producing realistic order flow messages with nanosecond precision. The authors tokenize order message components (timestamp, type, order ID, direction, size, price) into a vocabulary of 12,111 tokens and train a decoder-only transformer with 12 layers, 12 heads, and 768 embedding dimensions (~100M parameters). The model is pretrained on 91 million messages from 20 Nasdaq stocks and fine-tuned on specific tickers. Key innovations include the use of attention sinks and a rolling KV cache to enable streaming generation beyond the model's context window, and an error correction procedure to handle hallucinated messages (e.g., cancel orders referencing non-existent orders).
Evaluation on AAPL data shows that the model successfully reproduces several stylized facts of financial markets: heavy-tailed return distributions (kurtosis κ=4.93 vs. empirical 2.44), volatility clustering with slowly decaying autocorrelation of squared returns, and long-range dependence (Hurst exponent H=0.77 vs. empirical 0.678). The model also captures order-level statistics such as message type frequencies, inter-arrival times, and order size distributions, though it slightly over-predicts limit orders and under-predicts replace orders due to higher error rates in referential messages. Generated price and volume trajectories appear qualitatively similar to real data, with no directional bias.
The paper demonstrates that a transformer-based model can generate realistic market microstructure data without explicit supervision on price series, relying solely on next-token prediction over order message sequences. Limitations include high inference cost (24 tokens per message), sensitivity to sampling parameters, and reduced liquidity realism. The work represents a significant step toward high-fidelity, interactive market simulations for applications such as stress testing trading strategies and evaluating market regulations.
Highlights
- 1Developed a generative pre-trained transformer (GPT) for modeling financial time series at the limit order book (LOB) level.
- 2Introduced attention sinks and a rolling KV cache to enable streaming generation of order messages beyond the model's context window.
- 3Demonstrated that the model reproduces key stylized facts of financial markets, including heavy-tailed returns, volatility clustering, and long-range dependence.
- 4Achieved realistic order flow generation with nanosecond precision using a discrete event simulator (DES) and error correction for hallucinated messages.
- 5Showed that pretraining on multiple tickers followed by fine-tuning on a specific asset improves model performance.
Methods
- MTokenization of order message components (timestamp, type, order ID, direction, size, price) into a vocabulary of 12,111 tokens.
- MDecoder-only transformer architecture with 12 layers, 12 heads, 768 embedding dimensions, and ~100M parameters.
- MPretraining on 91 million messages from 20 assets, followed by fine-tuning on a specific ticker (e.g., AAPL).
- MIntegration with a discrete event simulator (ABIDES) for interactive market simulation with error correction for invalid messages.
Results
- RThe model accurately reproduces order type frequencies, inter-arrival times, and order size distributions, with slight over-prediction of limit orders and under-prediction of replace orders.
- RGenerated returns exhibit heavy tails (kurtosis κ=4.93±1.99 vs. empirical κ=2.44) and volatility clustering with autocorrelation decay similar to real data.
- RLong-range dependence is captured: Hurst exponent H=0.77±0.05 for generated absolute returns (empirical H=0.678), indicating persistent behavior.
- RThe model generates realistic price and volume trajectories without explicit training on price series, showing no directional bias.
- RAttention sinks enable stable generation for sequences far exceeding the training context length (10,368 tokens).
Analyze Paper
Generate insights from "MarketGPT: Developing a Pre-trained transformer (GPT) for Mo...".