Submitted:
18 October 2024
Posted:
18 October 2024
You are already at the latest version
Abstract
Keywords:
1. Introduction
2. Related Work
- Conducting a thorough analysis of RNN, LSTM, CNN, GRU, and Attention LSTM models for stock price prediction.
- Evaluating these models using a selection of Indian stocks, including HDFC, TCS, ICICI, Reliance, and the Nifty 50 index.
- Assessing the strengths and weaknesses of each model, with a particular focus on their ability to manage both volatile and stable stocks.
3. Materials and Methods
3.1. Data Collection
- Open Price: The price at which the stock begins trading when the market opens.
- Close Price: The price at which the stock concludes trading when the market closes.
- High Price: The highest price at which the stock was traded during the day.
- Low Price: The lowest price at which the stock was traded during the day.
- Volume: The total number of shares traded during the day.
3.2. Data Preprocessing
3.2.1. Handling Missing Data
3.2.2. Normalization
3.2.3. Train-Test Split
3.3. Deep Learning Architectures
3.3.1. Vanilla RNN
3.3.2. LSTM
3.3.3. CNN
3.3.4. GRU
3.3.5. LSTM with Attention Mechanism
3.4. Model Training
3.5. Evaluation Metrics
4. Results and Discussion
4.1. HDFC Stock
4.2. TCS Stock
4.3. ICICI Stock
4.4. Reliance Stock
4.5. Nifty 50

4.6. Model Comparison
5. Conclusions
Future Work
Funding
Conflicts of Interest
Abbreviations
| RNN | Recurrent Neural Networks |
| LSTM | Long Short-Term Memory |
| CNN | Convolutional Neural Netoworks |
| GRU | Gated Recurrent Unit |
| MAE | Mean Absolute Error |
| MSE | Mean Squared Error |
| RMSE | Root Mean Squared Error |
| R-Squared (Coefficient of Determination) | |
| SVM | Support Vector Machine |
| RF | Random Forest |
| ANN | Artificial Neural Network |
| ARIMA | Autoregressive Integrated Moving Average |
| GARCH | Generalized Autoregressive Conditional Heteroskedasticity |
| NSE | National Stock Exchange (India) |
References
- Sachdeva, A.; Jethwani, G.; Manjunath, C.; Balamurugan, M.; Krishna, A.V.N. An Effective Time Series Analysis for Equity Market Prediction Using Deep Learning Model. 2019 International Conference on Data Science and Communication (IconDSC). IEEE, 2019, pp. 1–5. doi:10.1109/IconDSC.2019.8817035. [CrossRef]
- Selvamuthu, D.; Kumar, V.; Mishra, A. Indian stock market prediction using artificial neural networks on tick data. Financial Innovation 2019, 5, 16. doi:10.1186/s40854-019-0131-7. [CrossRef]
- Singh, J. Indian Stock Markets Data Analysis and Prediction using Machine Learning. International Journal for Research in Applied Science and Engineering Technology 2020, 8, 631–636. doi:10.22214/ijraset.2020.30996. [CrossRef]
- Fathali, Z.; Kodia, Z.; Said, L.B. Stock Market Prediction of NIFTY 50 Index Applying Machine Learning Techniques. Applied Artificial Intelligence 2022, 36. doi:10.1080/08839514.2022.2111134. [CrossRef]
- Piyush.; Amarjeet.; Sharma, A.; Kumar, S.; Ansari, N.N. Stock Price Prediction Using Machine Learning. Proceedings of International Conference on Recent Trends in Computing. Springer, 2023, pp. 79–87. doi:10.1007/978-981-19-8825-7_8. [CrossRef]
- Weng, B.; Lu, L.; Wang, X.; Megahed, F.M.; Martinez, W. Predicting short-term stock prices using ensemble methods and online data sources. Expert Systems with Applications 2018, 112, 258–273. doi:10.1016/j.eswa.2018.06.016. [CrossRef]
- Kanwal, A.; Lau, M.F.; Ng, S.P.; Sim, K.Y.; Chandrasekaran, S. BiCuDNNLSTM-1dCNN — A hybrid deep learning-based predictive model for stock price prediction. Expert Systems with Applications 2022, 202, 117123. doi:10.1016/j.eswa.2022.117123. [CrossRef]
- Parray, I.R.; Khurana, S.S.; Kumar, M.; Altalbe, A.A. Time series data analysis of stock price movement using machine learning techniques. Soft Computing 2020, 24, 16509–16517. doi:10.1007/s00500-020-04957-x. [CrossRef]
- Gupta, D.; Parikh, A.; Datta, T.K. A multi-criteria decision-making approach to rank the sectoral stock indices of national stock exchange of India based on their performances. National Accounting Review 2021, 3, 272–292. doi:10.3934/NAR.2021014. [CrossRef]
- Ab.Khalil, M.; Bakar, A.A. A Comparative Study of Deep Learning Algorithms in Univariate and Multivariate Forecasting of the Malaysian Stock Market. Sains Malaysiana 2023, 52, 993–1009. doi:10.17576/jsm-2023-5203-22. [CrossRef]
- Patel, J.; Shah, S.; Thakkar, P.; Kotecha, K. Predicting stock and stock price index movement using Trend Deterministic Data Preparation and machine learning techniques. Expert Systems with Applications 2015, 42, 259–268. doi:10.1016/j.eswa.2014.07.040. [CrossRef]
- Salehinejad, H.; Sankar, S.; Barfett, J.; Colak, E.; Valaee, S. Recent Advances in Recurrent Neural Networks, 2018, [arXiv:cs.NE/1801.01078].
- Shen, J.; Shafiq, M.O. Short-term stock market price trend prediction using a comprehensive deep learning system. Journal of Big Data 2020, 7, 66. doi:10.1186/s40537-020-00333-6. [CrossRef]
- Sen, J.; Mehtab, S. A Robust Predictive Model for Stock Price Prediction Using Deep Learning and Natural Language Processing, 2021. doi:10.36227/techrxiv.15023361.v1. [CrossRef]
- Hernández, A.; Amigó, J.M. Attention Mechanisms and Their Applications to Complex Systems. Entropy 2021, 23, 283. doi:10.3390/e23030283. [CrossRef]
- Sunday, D.O. Application of Long Short-Term Memory (LSTM) in Stock Price Prediction. International Journal of Development and Economic Sustainability 2024, 12, 36–45. doi:10.37745/ijdes.13/vol12n33645. [CrossRef]
- Pipin, S.J.; Purba, R.; Kurniawan, H. Prediksi Saham Menggunakan Recurrent Neural Network (RNN-LSTM) dengan Optimasi Adaptive Moment Estimation. Journal of Computer System and Informatics (JoSYC) 2023, 4, 806–815. doi:10.47065/josyc.v4i4.4014. [CrossRef]
- Vijh, S.; Pandey, A.K.; Vijh, G.; Kumar, S. Stock Forecasting for Time Series Data using Convolutional Neural Network. 2021 11th International Conference on Cloud Computing, Data Science & Engineering (Confluence). IEEE, 2021, pp. 866–870. doi:10.1109/Confluence51648.2021.9377128. [CrossRef]
- Satria, D. PREDICTING BANKING STOCK PRICES USING RNN, LSTM, AND GRU APPROACH. Applied Computer Science 2023, 19, 82–94. doi:10.35784/acs-2023-06. [CrossRef]
- Chaudhary, P. A Deep Learning-based Approach for Stock Price Prediction. Turkish Journal of Computer and Mathematics Education (TURCOMAT) 2020, 11, 1983–1989. doi:10.17762/turcomat.v11i3.13595. [CrossRef]
- Long, W.; Lu, Z.; Cui, L. Deep learning-based feature engineering for stock price movement prediction. Knowledge-Based Systems 2019, 164, 163–173. doi:10.1016/j.knosys.2018.10.034. [CrossRef]
- Paul, M.K.; Das, P. A Comparative Study of Deep Learning Algorithms for Forecasting Indian Stock Market Trends. International Journal of Advanced Computer Science and Applications 2023, 14. doi:10.14569/IJACSA.2023.0141098. [CrossRef]
- Hemajothi, S.; Babu, S.S.; Prathiksha, V.; B, S.; E, S.; K, S. Prediction of Stock Price Model through the Implementation of Hybrid BiLSTM-GRU. 2024 International Conference on Recent Advances in Electrical, Electronics, Ubiquitous Communication, and Computational Intelligence (RAEEUCCI). IEEE, 2024, pp. 1–6. doi:10.1109/RAEEUCCI61380.2024.10547920. [CrossRef]
- Sudriyanto, S.; Faid, M.; Malik, K.; Supriadi, A. Evaluasi Model Jaringan Saraf Tiruan Berbasis LSTM dalam Memprediksi Fluktuasi Harga Bitcoin. Jurnal Advanced Research Informatika 2024, 2, 15–22. doi:10.24929/jars.v2i2.3398. [CrossRef]
- Jafar, S.H.; Akhtar, S.; El-Chaarani, H.; Khan, P.A.; Binsaddig, R. Forecasting of NIFTY 50 Index Price by Using Backward Elimination with an LSTM Model. Journal of Risk and Financial Management 2023, 16, 423. doi:10.3390/jrfm16100423. [CrossRef]
- Polepally, V.; Reddy, N.S.N.; Sindhuja, M.; Anjali, N.; Reddy, K.J. A Deep Learning Approach for Prediction of Stock Price Based on Neural Network Models: LSTM and GRU. 2021 12th International Conference on Computing Communication and Networking Technologies (ICCCNT). IEEE, 2021, pp. 1–4. doi:10.1109/ICCCNT51525.2021.9579782. [CrossRef]
- Srivastava, N.; Hinton, G.; Krizhevsky, A.; Sutskever, I.; Salakhutdinov, R. Dropout: A Simple Way to Prevent Neural Networks from Overfitting. Journal of Machine Learning Research 2014, 15, 1929–1958.
- Mehtab, S.; Sen, J. Stock Price Prediction Using Convolutional Neural Networks on a Multivariate Time Series, 2021. doi:10.36227/techrxiv.15088734.v1. [CrossRef]
- Sen, J.; Mehtab, S.; Nath, G. Stock Price Prediction Using Deep Learning Models, 2021. doi:10.36227/techrxiv.16640197.v1. [CrossRef]
- Ahmed, S.F.; Alam, M.S.B.; Hassan, M.; Rozbu, M.R.; Ishtiak, T.; Rafa, N.; Mofijur, M.; Ali, A.B.M.S.; Gandomi, A.H. Deep learning modelling techniques: current progress, applications, advantages, and challenges. Artificial Intelligence Review 2023, 56, 13521–13617. doi:10.1007/s10462-023-10466-8. [CrossRef]
- Spuler, M.; Sarasola-Sanz, A.; Birbaumer, N.; Rosenstiel, W.; Ramos-Murguialday, A. Comparing metrics to evaluate performance of regression methods for decoding of neural signals. 2015 37th Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC). IEEE, 2015, pp. 1083–1086. doi:10.1109/EMBC.2015.7318553. [CrossRef]





| Model | MAE | MSE | RMSE | R-Square |
|---|---|---|---|---|
| RNN | 0.211425 | 0.075756 | 0.275238 | −0.014790 |
| LSTM | 0.205168 | 0.073515 | 0.271136 | 0.015231 |
| CNN | 0.201941 | 0.074096 | 0.272206 | 0.007445 |
| GRU | 0.204980 | 0.073715 | 0.271506 | 0.012543 |
| Attention LSTM | 0.205012 | 0.074433 | 0.272824 | 0.002933 |
| Model | MAE | MSE | RMSE | R-Square |
|---|---|---|---|---|
| RNN | 0.433488 | 0.292760 | 0.541073 | −1.792222 |
| LSTM | 0.286867 | 0.128644 | 0.358670 | −0.226954 |
| CNN | 0.288108 | 0.119834 | 0.346170 | −0.142925 |
| GRU | 0.291298 | 0.121207 | 0.348147 | −0.156017 |
| Attention LSTM | 0.275316 | 0.110270 | 0.332070 | −0.051711 |
| Model | MAE | MSE | RMSE | R-Square |
|---|---|---|---|---|
| RNN | 0.202412 | 0.064328 | 0.253630 | 0.138293 |
| LSTM | 0.202412 | 0.064328 | 0.253630 | 0.138293 |
| CNN | 0.205847 | 0.071689 | 0.267748 | 0.039685 |
| GRU | 0.205716 | 0.070570 | 0.265651 | 0.054675 |
| Attention LSTM | 0.210881 | 0.076649 | 0.276855 | −0.026750 |
| Model | MAE | MSE | RMSE | R-Square |
|---|---|---|---|---|
| RNN | 0.406110 | 0.296743 | 0.544741 | −1.251171 |
| LSTM | 0.406110 | 0.296743 | 0.544741 | −1.251171 |
| CNN | 0.328005 | 0.130712 | 0.361541 | 0.008383 |
| GRU | 0.333059 | 0.136330 | 0.369229 | −0.034238 |
| Attention LSTM | 0.317918 | 0.121637 | 0.348765 | 0.077228 |
| Model | MAE | MSE | RMSE | R-Square |
|---|---|---|---|---|
| RNN | 0.252424 | 0.105110 | 0.324207 | -0.203869 |
| LSTM | 0.246831 | 0.101502 | 0.318594 | -0.162540 |
| CNN | 0.232070 | 0.091618 | 0.302684 | -0.049331 |
| GRU | 0.230114 | 0.090895 | 0.301488 | -0.041058 |
| Attention LSTM | 0.446610 | 0.256458 | 0.506417 | -1.937318 |
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 MDPI and/or the editor(s). MDPI 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. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).