Research Article

Using transformer in stock trend prediction

Zhichen Liu*
Southern University of Science and Technology

* Corresponding author: [email protected]

Abstract

Large transformer model had achieved good results in many tasks, such as computer vision (CV) and natural language processing (NLP). However, in financial domains, the application of large deep learning models is rarely observed. Stock Trend Prediction (STP) is a task that using Limit Order Books (LOBs) to predict the future stock price trend by the sequence of historical limit order information, the trend can be Current works are mostly based on the structure of Convolutional Neural Network (CNN) + Recurrent Neural Networks (RNN). This structure is hard to parallel and cannot make full use of GPU resources. It is also difficult to increase the dimension to fit more complex data and performs poor when time sequence is long. Recently, some works proposed that CNN + Transformer model can also work is solving this task. This paper verifies that Transformer can be directly used into STP task and gain a good result, and proposes a novel Transformer-based model, Transformer-LOB, to enhance the basic transformer model performance. This model uses attention mechanisms to extract temporal information rather than using RNN, which utilizes the GPU effectively. Since all the feature extractions are based on transformer modules, the model is scalable and easy to parallel. Transformer-LOB is tested on FI-2010 LOB dataset and SZ-2015 LOB dataset, and outputs ideal results on both datasets.

Keywords: stock trend prediction; limit order book; transformer; neural networks; deep learning
Published: October 23, 2023
DOI: 10.54254/2755-2721/22/20231212
Volume: ACE Vol.22
pp. 166-175
Download PDF

References

  1. Ahn, H.-J., Cai, J., Hamao, Y., Ho, R.Y.K.: The components of the bid–ask spread in a limit-order market: Evidence from the Tokyo Stock Exchange. Journal of Empirical Finance. 9, 399–430 (2002).
  2. Aitken, M.J., Berkman, H., Mak, D.: The use of undisclosed limit orders on the Australian Stock Exchange. Journal of Banking & Finance. 25, 1589–1603 (2001).
  3. Anagnostidis, P., Papachristou, G., Thomaidis, N.S.: Liquidity commonality in order-driven trading: Evidence from the Athens Stock Exchange. Applied Economics. 48, 2007–2021 (2015).
  4. Thakor, A.V., A., B.A.W., Parlour , C.A., Seppi, D.J.: Chapter 3 - limit order markets: A survey. In: Handbook of Financial Intermediation and banking. pp. 63–96. North-Holland/Elsevier, Amsterdam, San Diego (2008).
  5. Carrie, C.: The new electronic trading regime of dark books, mashups and algorithmic trading. The Journal of Trading. 1, 14-20 (2006)
  6. Bollerslev, T., Marrone, J., Xu, L., Zhou, H.: Stock return predictability and variance risk premia: Statistical Inference and International evidence. SSRN Electronic Journal. (2012).
  7. Ferreira, M.A., Santa-Clara, P.: Forecasting stock market returns: The sum of the parts is more than the whole. Journal of Financial Economics. 100, 514–537 (2011).
  8. Sirignano, J., Cont, R.: Universal features of Price Formation in financial markets: Perspectives from Deep Learning. SSRN Electronic Journal. (2018).
  9. Atsalakis, G.S., Valavanis, K.P.: Surveying stock market forecasting techniques – part II: Soft computing methods. Expert Systems with Applications. 36, 5932–5941 (2009).
  10. Kercheval, A.N., Zhang, Y.: Modelling high-frequency limit order book dynamics with support Vector Machines. Quantitative Finance. 15, 1315–1329 (2015).
  11. Passalis, N., Tefas, A., Kanniainen, J., Gabbouj, M., Iosifidis, A.: Temporal bag-of-features learning for predicting mid price movements using High Frequency Limit Order Book Data. IEEE Transactions on Emerging Topics in Computational Intelligence. 4, 774–785 (2020).
  12. Tsantekidis, A., Passalis, N., Tefas, A., Kanniainen, J., Gabbouj, M., Iosifidis, A.: Forecasting stock prices from the limit order book using Convolutional Neural Networks. 2017 IEEE 19th Conference on Business Informatics (CBI). (2017).
  13. Tsantekidis, A., Passalis, N., Tefas, A., Kanniainen, J., Gabbouj, M., Iosifidis, A.: Using deep learning to detect price change indications in financial markets. 2017 25th European Signal Processing Conference (EUSIPCO). (2017).
  14. Zhang, Z., Zohren, S., Roberts, S.: DeepLOB: Deep convolutional neural networks for limit order books. IEEE Transactions on Signal Processing. 67, 3001–3012 (2019).
  15. Sangadiev, A., Rivera-Castro, R., Stepanov, K., Poddubny, A., Bubenchikov, K., Bekezin, N., Pilyugina, P., Burnaev, E.: DeepFolio: Convolutional Neural Networks for portfolios with Limit Order Book Data, https://arxiv.org/abs/2008.12152.
  16. Yang, P., Fu, L., Zhang, J., Li, G.: OCET: One-dimensional convolution embedding transformer for stock trend prediction. Communications in Computer and Information Science. 370–384 (2023).
  17. Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A.N., Kaiser, L., Polosukhin, I.: Attention is all you need, https://arxiv.org/abs/1706.03762.
  18. Devlin, J., Chang, M.-W., Lee, K., Toutanova, K.: Bert: Pre-training of deep bidirectional Transformers for language understanding, https://arxiv.org/abs/1810.04805.
  19. Radford, A., Narasimhan, K.: https://openai.com/research/language-unsupervised.
  20. Radford, A., Wu, J., Child, R., Luan, D., Amodei, D., Sutskever, I.: https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf.
  21. Brown, T.B., Mann, B., Ryder, N., Subbiah, M., Kaplan, J., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., Agarwal, S., Herbert-Voss, A., Krueger, G., Henighan, T., Child, R., Ramesh, A., Ziegler, D.M., Wu, J., Winter, C., Hesse, C., Chen, M., Sigler, E., Litwin, M., Gray, S., Chess, B., Clark, J., Berner, C., McCandlish, S., Radford, A., Sutskever, I., Amodei, D.: Language models are few-shot learners, https://arxiv.org/abs/2005.14165.
  22. Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer, M., Heigold, G., Gelly, S., Uszkoreit, J., Houlsby, N.: An image is worth 16x16 words: Transformers for image recognition at scale, https://arxiv.org/abs/2010.11929.
  23. Ntakaris, A., Magris, M., Kanniainen, J., Gabbouj, M., Iosifidis, A.: Benchmark dataset for mid-price forecasting of limit order book data with Machine Learning Methods. Journal of Forecasting. 37, 852–866 (2018).
  24. Gould, M.D., Porter, M.A., Williams, S., McDonald, M., Fenn, D.J., Howison, S.D.: Limit order books, https://arxiv.org/abs/1012.0349.