Science, Technology, Engineering and Mathematics.
Open Access

FORECASTING STOCK PRICES WITH DEEP LEARNING MODELS: A COMPARISON OF LONG-SHORT TERM MEMORY (LSTM), GATED RECURRENT UNIT (GRU), ATTENTION MECHANISM, AND TRANSFORMER MODE

Download as PDF

Volume 2, Issue 4, Pp 34-42 2025

DOI: https://doi.org/10.61784/jtfe3063

Author(s)

ZeTong Li1JiuRu Lyu2, ZiHan Wang3, Liu Yang3*

Affiliation(s)

1Department of Electronic Science and Technology, Xi’an Jiaotong-Liverloop University, Suzhou 215000, Jiangsu, China.

2Department of Mathematics, Emory College of Art and Science Emory University, Atlanta, United States.

3School of Mathematics and Physics, Xi’an Jiaotong-Liverloop University, Suzhou 215000, Jiangsu, China.

Corresponding Author

Liu Yang

ABSTRACT

With the expansion of the stock market, more and more people have started to use deep learning models to predict the stock market and facilitate their trading decisions. This paper compares four mainstream deep learning models for stock price prediction: Long Short-Term Memory (LSTM), Gated Recurrent Unit (GRU), Attention Mechanism, and Transformer Model. Using MSE and RMSE as the evaluation metrics, we found LSTM performs the best in stock price prediction of the four companies of selection: Boeing Co, General Electric Co, Coca-Cola Co, and Johnson & Johnson. With a deeper analysis of the result, we found several limitations of LSTM, such as inconsistency of accuracy when forecasting the stock price of different firms. Hence, we suggested corresponding ways of improvement: adding more training data, introducing external factors, and integrating LSTM with other models. 

KEYWORDS

Deep learning; LSTM; GRU; Attention; Transformer; Stock; Forecasting; BA; GE; KO; JNJ

CITE THIS PAPER

ZeTong Li, JiuRu Lyu, ZiHan Wang, Liu Yang. Forecasting stock prices with deep learning models: a comparison of Long-Short Term Memory (LSTM), Gated Recurrent Unit (GRU), attention mechanism, and transformer mode. Journal of Trends in Financial and Economics. 2025, 2(4): 34-42. DOI: https://doi.org/10.61784/jtfe3063.

REFERENCES

[1] Q Ding, S Wu, H Sun, et al. Hierarchical Multi-Scale Gaussian Transformer for Stock Movement Prediction.  Proceedings of the Twenty-Ninth International Joint Conference on Artificial Intelligence, Yokohama, Japan: International Joint Conferences on Artificial Intelligence Organization, 2020: 4640–4646. DOI: 10.24963/ijcai.2020/640.

[2] D Nelson, A Pereira, R de Oliveira. Stock market’s price movement prediction with LSTM neural networks. 2017: 1419–1426. DOI: 10.1109/IJCNN.2017.7966019.

[3] H Li, Y Shen, Y Zhu. Stock price prediction using attention-based multi-input LSTM. Journal of Financial Data Science. 2022, 4(3): 45-60. DOI: 10.1016/j.jfds.2022.05.002.

[4] J Qiu, B Wang, C Zhou. Forecasting stock prices with long-short term memory neural network based on attention mechanism. PLoS One, 2020, 15(1): e0227222. DOI: 10.1371/journal.pone.0227222.

[5] A Vaswani, N Shazeer, N Parmar, et al. Attention Is All You Need.  2017. http://arxiv.org/abs/1706.03762.

[6] S Hochreiter, J Schmidhuber. Long Short-Term Memory. Neural Computation, 1997, 9(8): 1735–1780.

[7] U Gupta, V Bhattacharjee, P Bishnu. StockNet - GRU based Stock Index Prediction. Expert Systems with Applications, 2022, 207: 117986. DOI: 10.1016/j.eswa.2022.117986.

[8] C Wang, Y Chen, S Zhang, et al. Stock market index prediction using deep Transformer model. Expert Systems with Applications, 2022, 208: 118128. DOI: 10.1016/j.eswa.2022.118128.

[9] S Zhang, H Zhang. Prediction of Stock Closing Prices Based on Attention Mechanism. 2020 16th Dahe Fortune China Forum and Chinese High-educational Management Annual Academic Conference (DFHMC), Zhengzhou, China: IEEE, 2020. DOI: 10.1109/DFHMC52214.2020.00053.

[10] M C Lee. Research on the Feasibility of Applying GRU and Attention Mechanism Combined with Technical Indicators in Stock Trading Strategies. Applied Sciences, 2022, 12(3). DOI: 10.3390/app12031007.

[11] K Kumar M, V R C, I C Kumari P, et al. Stock Price Prediction using LSTM and TLBO. 2023 IEEE International Conference on Integrated Circuits and Communication Systems (ICICACS), 2023: 1–5. DOI: 10.1109/ICICACS57338.2023.10100074.

[12] A Rajanand, P Singh. Stock Price Prediction using Depthwise Pointwise CNN with Sequential LSTM. 2023 2nd International Conference on Applied Artificial Intelligence and Computing (ICAAIC), 2023: 82–86. DOI: 10.1109/ICAAIC56838.2023.10140728.

[13] F A Gers, J Schmidhuber, F Cummins. Learning to forget: continual prediction with LSTM. Neural Comput, 2000, 12(10): 2451–2471. DOI: 10.1162/089976600300015015.

[14] Y Yu, X Si, C Hu, J Zhang. A Review of Recurrent Neural Networks: LSTM Cells and Network Architectures,” Neural Computation, 2019, 31(7): 1235–1270. DOI: 10.1162/neco_a_01199.

[15] K Cho, B van Merrienboer, C Gulcehre, et al. Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation. 2014. DOI: 10.48550/arXiv.1406.1078.

[16] D Bahdanau, K Cho, Y Bengio. Neural Machine Translation by Jointly Learning to Align and Translate. arXiv, 2016. http://arxiv.org/abs/1409.0473.

[17] H Liu. Leveraging Financial News for Stock Trend Prediction with Attention-Based Recurrent Neural Network. 2018. DOI: 10.48550/arXiv.1811.06173.

All published work is licensed under a Creative Commons Attribution 4.0 International License. sitemap
Copyright © 2017 - 2025 Science, Technology, Engineering and Mathematics.   All Rights Reserved.