Stock Price Forecasting Using Deep Learning: A Comparative Study of CNN, LSTM, and Transformer Models with Feature Engineering Insights
DOI:
https://doi.org/10.61173/j8z47028Keywords:
LSTM, Transformer, CNN, Stock Forecasting, Feature EngineeringAbstract
Accurate forecasting of stock prices remains a challenging yet essential task in financial modeling. This paper investigates the effectiveness of deep learning architectures—convolutional neural networks (CNN), long short-term memory networks (LSTM), and transformer models—for predicting the average stock price over a 30-day horizon. Historical market data from 12 representative Hong Kong-listed companies are employed to evaluate the performance of each model, both with and without the inclusion of traditional technical indicators (Type 1) and derived statistical features (Type 2). Results show that the Transformer model trained on raw price and volume data achieves superior performance, recording the lowest Root Mean Square Error (RMSE = 0.3799), Mean Absolute Error (MAE = 0.2909), and the highest directional accuracy (51.00%), outperforming other models and exceeding the random baseline. In contrast, the integration of technical indicators results in decreased performance, suggesting potential overfitting or feature redundancy. The research underscores the effectiveness of attention-based architectures in financial time series prediction and emphasizes the importance of cautious feature selection when incorporating domain-specific indicators. These findings provide practical guidance for quantitative analysts and financial data scientists regarding model architecture choices and feature engineering strategies in stock forecasting tasks.
References
[1] Bansal, M., Goyal, A., Choudhary, A.: Stock market prediction using deep learning. International Journal of Creative Research Thoughts (2022)
[2] Yang, Y., Wen, J.: Forecasting Chinese stock market using deep learning and sentiment analysis. Humanities and Social Sciences Communications 11(1), 104 (2024)
[3] Wang, H., Li, M.: Hybrid LSTM-CNN model for stock market prediction. Humanities and Social Sciences Communications 12(1), 129 (2025)
[4] Hu, Y.: Deep learning based stock market prediction and analysis. SSRN Electronic Journal (2018)
[5] Jiang, Q., Wang, X., Chen, Z.: Stock market prediction based on LSTM neural network. Procedia Computer Science 199, 1043–1050 (2022)
[6] Singh, A.K., Srivastava, A.: Stock market analysis using linear regression. International Journal of Computer Applications 183(45), 25–28 (2022)
[7] Shaikh, M., Shaikh, S.A., Talha, M.: Comparative analysis of machine learning and deep learning approaches for stock price prediction. Procedia Computer Science 200, 529–536 (2022)
[8] Hochreiter, S., Schmidhuber, J.: Long short-term memory. Neural Computation 9(8), 1735–1780 (1997)
[9] Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A.N., Kaiser, Ł., Polosukhin, I.: Attention is all you need. In: Guyon, I., Luxburg, U.V., Bengio, S., et al. (eds.) Advances in Neural Information Processing Systems, vol. 30. Curran Associates, Red Hook (2017)
[10] Khaniki, M. A. L., & Manthouri, M.: Enhancing price prediction in cryptocurrency using transformer neural network and technical indicators. arXiv preprint arXiv:2403.03606 (2024)
Downloads
Published
Issue
Section
License
Copyright (c) 2025 by the authors.

This work is licensed under a Creative Commons Attribution 4.0 International License.
