Welcome to Francis Academic Press

Academic Journal of Business & Management, 2023, 5(16); doi: 10.25236/AJBM.2023.051611.

Forecasting stock prices with CNN and LSTM model

Author(s)

Chang Liu1, Shukun Geng2, Zhezhu Han2

Corresponding Author:
Chang Liu
Affiliation(s)

1Financial Mathmatics, Xi'an Jiaotong-Liverpool University, 111 Ren’ai Road, Suzhou, China

2Applied Mathmatics, Xi'an Jiaotong-Liverpool University, 111 Ren’ai Road, Suzhou, China

Abstract

Utilizing historical data from the Quandl API, this experiment investigates the use of Convolutional Neural Networks (CNNs) in stock price prediction. The information for Microsoft Corporation (MSFT) spans the dates of January 1, 2013, and May 18, 2018. The high, low, open, and close prices are scaled, and input sequences of length 6 are created in order to capture temporal dependencies. Dense layers, 1D convolutional layers, max pooling, and dropout regularization are all components of the CNN architecture. Mean squared error (MSE) loss and the Adam optimizer are used to train the model. Mean absolute error (MAE) and root mean square error (RMSE) are used to assess performance. To evaluate the model's convergence and generalization, the losses and errors from training and validation are examined. For visual purposes, the anticipated and actual stock prices are contrasted. The results shed light on how well CNNs anticipate stock prices, assisting investors and financial institutions in making wise choices.

Keywords

Deep leaning, LSTM, CNN, Stock Prices

Cite This Paper

Chang Liu, Shukun Geng, Zhezhu Han. Forecasting stock prices with CNN and LSTM model. Academic Journal of Business & Management (2023) Vol. 5, Issue 16: 76-82. https://doi.org/10.25236/AJBM.2023.051611.

References

[1] Cowles A. Can Stock Market Forecasters Forecast? Econom. 1933; 1:309. 

[2] K. -S. Moon and H. Kim, “Performance of deep learning in prediction of stock market volatility,” Economic Computation And Economic Cybernetics Studies And Research, vol. 53, no. 2, pp. 77–92, 2019. 

[3] He K, Zhang X, Ren S, Sun J. Deep Residual Learning for Image Recognition. In: 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR) [Internet]. 2016. p. 770–8. http://ieeexplore. ieee. org/document/7780459/

[4] Nicholas Refenes, A., Zapranis, A., & Francis, G. (1994). Stock performance modeling using neural networks: A comparative study with regression models. Neural Networks, 7(2), 375–388. https://doi. org/10. 1016/0893-6080(94)90030-2

[5] M. O. Afolabi and O. Olude, "Predicting Stock Prices Using a Hybrid Kohonen Self Organizing Map (SOM)," 2007 40th Annual Hawaii International Conference on System Sciences (HICSS'07), Waikoloa, HI, USA, 2007, pp. 48-48, doi: 10. 1109/HICSS. 2007. 441. 

[6] 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. 

[7] Wu, J. M., Li, Z., Srivastava, G., Tasi, M., & Lin, J. C. (2020). A graph‐based convolutional neural network stock price prediction with leading indicators. Software: Practice and Experience, 51(3), 628–644. https://doi. org/10. 1002/spe. 2915

[8] Hochreiter, S., & Schmidhuber, J. (1997). Long short-term memory. Neural computation, 9(8), 1735-1780. 

[9] Sherstinsky, A. (2020). Fundamentals of Recurrent Neural Network (RNN) and Long Short-Term Memory (LSTM) network. Physica D: Nonlinear Phenomena, 404, 132306. https://doi. org/ 10. 1016/j. physd. 2019. 132306. 

[10] Chauhan, S., & Vig, L. (2015). Anomaly detection in ECG time signals via deep long short-term memory networks. In 2015 IEEE International Conference on Data Science and Advanced Analytics (DSAA) (pp. 1-7). IEEE. doi: 10. 1109/DSAA. 2015. 7344872. 

[11] Graves, A. (2013). Generating sequences with recurrent neural networks. arXiv preprint arXiv: 1308. 0850. 

[12] Muthukumar, P., & Zhong, J. (2021, February 1). A Stochastic Time Series Model for Predicting Financial Trends using NLP. https://doi. org/10. 48550/arXiv. 2102. 01290

[13] Akita, R., Yoshihara, A., Matsubara, T., & Uehara, K. (2016). Deep learning for stock prediction using numerical and textual information. 2016 IEEE/ACIS 15th International Conference on Computer and Information Science (ICIS), 1-6. 

[14] Bhardwaj, K. (2021, June 3). Convolutional Neural Network(CNN/ConvNet) in Stock Price Movement Prediction. https://doi. org/10. 48550/arXiv. 2106. 01920

[15] Xu, B., Zhang, D., Zhang, S., Li, H., & Lin, H. (2018). Stock Market Trend Prediction Using Recurrent Convolutional Neural Networks. Natural Language Processing and Chinese Computing, 166–177. https://doi. org/10. 1007/978-3-319-99501-4_14