image

Understanding the Market Trends: A Hybrid Approach to Stock Price Prediction Using RNNs and Transformer-Based Sentiment Analysis

Download Paper PDF: Download pdf
Author(s):
Abstract:

Stock price prediction is a critical yet challenging task in financial markets due to the complexity and volatility of asset movements. This paper presents a hybrid approach that combines Recurrent Neural Networks (RNN), particularly Long Short-Term Memory (LSTM) models, for time-series prediction with Transformer-based text analysis to capture sentiment from financial news. The study focuses on predicting Apple Inc.'s (AAPL) stock price, using three years of historical data alongside news sentiment analysis. The LSTM model captures temporal dependencies in the stock prices, while the Transformer model extracts relevant features from unstructured textual data, offering insights into market sentiment and external events. The results demonstrate that integrating sentiment data with stock price predictions significantly improves model accuracy, as reflected by a reduction in mean squared error (MSE) compared to models based solely on price data. This hybrid model offers a more holistic approach to financial forecasting, combining quantitative and qualitative data for enhanced prediction.

The paper contributes to the field of machine learning in finance by highlighting the benefits of hybrid modelling approaches, and it opens avenues for future research on broader applications in other asset classes and more diverse data sources.


Copyright© 2025 The Author(s). This article is distributed under the terms of the license CC-BY 4.0., which permits any further distribution in any medium, provided the original work is properly cited.


How to cite:

Vallarino, D. (2025). Understanding the Market Trends: A Hybrid Approach to Stock Price Prediction Using RNNs and Transformer-Based Sentiment Analysis Journal of Applied Economic Sciences, Volume XX, Spring, 1(87), 21–33. https://doi.org/10.57017/jaes.v20.1(87).02


References:

Cui, P., Shen, Z., Li, S., Yao, L., Li, Y., Chu, Z., & Gao, J. (2020). Causal Inference Meets Machine Learning. Proceedings of the ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 3527–3528. https://doi.org/10.1145/3394486.3406460


Fischer, T., & Krauss, C. (2018). Deep learning with long short-term memory networks for financial market predictions. European Journal of Operational Research, 270(2), 654–669. https://doi.org/https://doi.org/10.1016/j.ejor.2017.11.054


Hochreiter, S., & Schmidhuber, J. (1997). Long Short-Term Memory. Neural Computation, 9(8), 1735–1780. https://doi.org/10.1162/neco.1997.9.8.1735 


Jiang, F., Ma, T., & Zhu, F. (2024). Fundamental characteristics, machine learning, and stock price crash risk. Journal of Financial Markets, 69, 100908. https://doi.org/10.1016/j.finmar.2024.100908 


Lim, B., Arık, S. Ö., Loeff, N., & Pfister, T. (2021). Temporal Fusion Transformers for interpretable multi-horizon time series forecasting. International Journal of Forecasting, 37(4), 1748–1764. https://doi.org/10.1016/j.ijforecast.2021.03.012


Münster, M., Reichenbach, F., & Walther, M. (2024). Robinhood, Reddit, and the news: The impact of traditional and social media on retail investor trading. Journal of Financial Markets, 100929. https://doi.org/10.1016/j.finmar.2024.100929 


Pradeep, P., Premjith, B., Nimal Madhu, M., & Gopalakrishnan, E. A. (2024, January). A Transformer-Based Stock Market Price Prediction by Incorporating BERT Embedding. International Conference on Mathematics and Computing, pp. 95-107. Singapore: Springer Nature Singapore. https://doi.org/10.1007/978-981-97-2066-8_10


Sun, Y., Ni, R., & Zhao, Y. (2022). ET: Edge-Enhanced Transformer for Image Splicing Detection. IEEE Signal Processing Letters, 29, 1232–1236. https://doi.org/10.1109/LSP.2022.3172617


Nguyen, T. H., Shirai, K., & Velcin, J. (2015). Sentiment analysis on social media for stock movement prediction. Expert Systems with Applications, 42(24), 9603-9611. https://doi.org/10.1016/j.eswa.2015.07.052 


Vallarino, D. (2024). Dynamic Portfolio Rebalancing: A Hybrid new Model Using GNNs and Pathfinding for Cost Efficiency. ArXiv preprint arXiv:2410.01864. https://doi.org/10.48550/arXiv.2410.01864 


Vallarino, D. (2024). Modeling Adaptive Fraud Patterns: An Agent-Centric Hybrid Framework with MoE and Deep Learning. Available at SSRN 5001848. http://dx.doi.org/10.2139/ssrn.5001848


Vallarino, D. (2024). A Dynamic Approach to Stock Price Prediction: Comparing RNN and Mixture of Experts Models Across Different Volatility Profiles. arXiv preprint arXiv:2410.07234. https://doi.org/10.48550/arXiv.2410.07234 


Vaswani, A., Brain, G., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, Ł., & Polosukhin, I. (n.d.). Attention Is All You Need.


Wen, Q., Zhou, T., Zhang, C., Chen, W., Ma, Z., Yan, J., & Sun, L. (2022). Transformers in Time Series: A Survey. http://arxiv.org/abs/2202.07125


Zhang, X., Qu, S., Huang, J., Fang, B., & Yu, P. (2018). Stock Market Prediction via Multi-Source Multiple Instance Learning. IEEE Access, 6, 50720–50728. https://doi.org/10.1109/ACCESS.2018.2869735