Transformers versus LSTMs for electronic trading
Transformers versus LSTMs for electronic trading
This paper systematically compares Transformer-based and LSTM-based models for financial time series prediction using high-frequency limit order book data from Binance Exchange. Three tasks are considered: mid-price prediction (regression of absolute prices), mid-price difference prediction (regression of price changes), and mid-price movement prediction (classification of price direction). The study evaluates multiple LSTM variants (vanilla LSTM, DeepLOB, DeepLOB-Seq2Seq, DeepLOB-Attention) and Transformer variants (vanilla Transformer, LogTrans, Reformer, Informer, Autoformer, FEDformer, Pyraformer). A new LSTM-based model called DLSTM is proposed, which integrates time series decomposition via an Inception module into the LSTM architecture for movement prediction. Additionally, Transformer architectures are adapted for movement prediction by modifying the output layer.
The experimental results reveal that Transformer-based models have a limited advantage in absolute price prediction, achieving 10-25% lower error than LSTM-based models, but the predictions are not accurate enough for practical trading. In contrast, LSTM-based models perform better and more robustly in difference prediction, with the highest out-of-sample R² reaching 11.5%. For movement prediction, the proposed DLSTM significantly outperforms all other models, achieving accuracy between 63.73% and 73.31% across different horizons. Simulated trading based on DLSTM predictions shows strong profitability and robustness, while Transformer-based models fail to generate profitable signals. The study concludes that LSTM-based models, especially DLSTM, are more suitable for financial time series prediction tasks involving price changes and movements, whereas Transformers may be better suited for absolute price forecasting but still require further improvement for practical applications.
Highlights
- 1Systematic comparison of Transformer-based and LSTM-based models on three financial prediction tasks using high-frequency limit order book data.
- 2Development of a new LSTM-based model (DLSTM) combining LSTM with time series decomposition for mid-price movement prediction, achieving 63.73% to 73.31% accuracy.
- 3Transformer-based models show limited advantage in absolute price prediction (10-25% lower error) but LSTM-based models outperform in difference and movement prediction tasks.
- 4DLSTM demonstrates strong profitability and robustness in simulated trading, outperforming previous LSTM and Transformer-based methods.
Methods
- MLSTM-based models: vanilla LSTM, DeepLOB, DeepLOB-Seq2Seq, DeepLOB-Attention, and proposed DLSTM (LSTM with time series decomposition).
- MTransformer-based models: vanilla Transformer, LogTrans, Reformer, Informer, Autoformer, FEDformer, and Pyraformer.
- MTime series decomposition via Inception module and smoothing labeling for movement prediction.
- MLearnable time-stamp encoding for Transformer to incorporate temporal information.
Results
- RIn mid-price prediction, Transformer-based models achieve 10-25% lower prediction error than LSTM-based models, but results are insufficient for trading.
- RIn mid-price difference prediction, LSTM-based models outperform Transformer-based models, with highest out-of-sample R² reaching 11.5%.
- RIn mid-price movement prediction, the proposed DLSTM achieves 63.73% to 73.31% accuracy, outperforming all other models.
- RDLSTM shows strong profitability and robustness in simulated trading, while Transformer-based models perform poorly in movement prediction.
Analyze Paper
Generate insights from "Transformers versus LSTMs for electronic trading".