Using transformer in stock trend prediction

Research Article
Open access

Using transformer in stock trend prediction

Zhichen Liu 1*
  • 1 Southern University of Science and Technology    
  • *corresponding author 12011125@mail.sustech.edu.cn
Published on 23 October 2023 | https://doi.org/10.54254/2755-2721/22/20231212
ACE Vol.22
ISSN (Print): 2755-273X
ISSN (Online): 2755-2721
ISBN (Print): 978-1-83558-035-6
ISBN (Online): 978-1-83558-036-3

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

Liu,Z. (2023). Using transformer in stock trend prediction. Applied and Computational Engineering,22,166-175.
Export citation

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.


Cite this article

Liu,Z. (2023). Using transformer in stock trend prediction. Applied and Computational Engineering,22,166-175.

Data availability

The datasets used and/or analyzed during the current study will be available from the authors upon reasonable request.

Disclaimer/Publisher's Note

The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of EWA Publishing and/or the editor(s). EWA Publishing and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

About volume

Volume title: Proceedings of the 5th International Conference on Computing and Data Science

ISBN:978-1-83558-035-6(Print) / 978-1-83558-036-3(Online)
Editor:Alan Wang, Marwan Omar, Roman Bauer
Conference website: https://2023.confcds.org/
Conference date: 14 July 2023
Series: Applied and Computational Engineering
Volume number: Vol.22
ISSN:2755-2721(Print) / 2755-273X(Online)

© 2024 by the author(s). Licensee EWA Publishing, Oxford, UK. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license. Authors who publish this series agree to the following terms:
1. Authors retain copyright and grant the series right of first publication with the work simultaneously licensed under a Creative Commons Attribution License that allows others to share the work with an acknowledgment of the work's authorship and initial publication in this series.
2. Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the series's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgment of its initial publication in this series.
3. Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See Open access policy for details).

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.