A Method for Clustering and Predicting Stocks Prices by Using Recurrent Neural Networks

  • Felipe AffonsoEmail author
  • Thiago Magela Rodrigues Dias
  • Adilson Luiz Pinto
Conference paper
Part of the Lecture Notes of the Institute for Computer Sciences, Social Informatics and Telecommunications Engineering book series (LNICST, volume 319)


Predicting the stock market is a widely studied field, either due to the curiosity in finding an explanation for the behavior of financial assets or for financial purposes. Among these studies the best techniques use neural networks as a prediction tool. More specifically, the best networks for this purpose are called recurrent neural networks (RNN) and provide an extra option when dealing with a sequence of values. However, a great part of the studies is intended to predict the result of few stocks, therefore, this work aims to predict the behavior of a large number of stocks. For this, similar stocks were grouped based on their correlation and later the algorithm K-means was applied so that similar groups were clustered. After this process, the Long Short-Term Memory (LSTM) - a type of RNN - was used in order to predict the price of a certain group of assets. Results showed that clustering stocks did not influence the effectiveness of the network and that investors and portfolio managers can use it to simply their daily tasks.


Neural networks Clustering Stock market Deep learning 


  1. 1.
    Affonso, F., de Oliveira, F., Dias, T.M.R.: Uma análise dos fatores que influenciam o movimento acionário das empresas petrolíferas. In: Ibero-Latin American Congress on Computational Methods in Engineering (CILAMCE) (2017)Google Scholar
  2. 2.
    Bengio, Y., Simard, P., Frasconi, P.: Learning long-term dependencies with gradient descent is difficult. IEEE Trans. Neural Netw. 5(2), 157–166 (1994)CrossRefGoogle Scholar
  3. 3.
    Bini, B.S., Mathew, T.: Clustering and regression techniques for stock prediction. Procedia Technol. 24, 1248–1255 (2016)CrossRefGoogle Scholar
  4. 4.
    Cavalcante, R.C., Brasileiro, R.C., Souza, V.L., Nobrega, J.P., Oliveira, A.L.: Computational intelligence and financial markets: a survey and future directions. Expert Syst. Appl. 55, 194–211 (2016)CrossRefGoogle Scholar
  5. 5.
    Chollet, F.: Keras (2015).
  6. 6.
    Chong, E., Han, C., Park, F.C.: Deep learning networks for stock market analysis and prediction: methodology, data representations, and case studies. Expert Syst. Appl. 83, 187–205 (2017)CrossRefGoogle Scholar
  7. 7.
    Filho, D.B.F., Júnior, J.A.D.S.: Desvendando os mistérios do coeficiente de correlacão de pearson (r). Universidade Federal de Pernambuco (2009)Google Scholar
  8. 8.
    Fischer, T., Krauss, C.: Deep learning with long short-term memory networks for financial market predictions. Eur. J. Oper. Res. 270(2), 654–669 (2018)MathSciNetCrossRefGoogle Scholar
  9. 9.
    Gan, G., Ma, C., Wu, J.: Data Clustering: Theory, Algorithms, and Applications, vol. 20. SIAM (2007)Google Scholar
  10. 10.
    Gerlein, E.A., McGinnity, M., Belatreche, A., Coleman, S.: Evaluating machine learning classification for financial trading: an empirical approach. Expert Syst. Appl. 54, 193–207 (2016)CrossRefGoogle Scholar
  11. 11.
    Hochreiter, S., Schmidhuber, J.: Long short-term memory. Neural Comput. 9(8), 1735–1780 (1997)CrossRefGoogle Scholar
  12. 12.
    Jung, S.S., Chang, W.: Clustering stocks using partial correlation coefficients. Phys. A: Stat. Mech. Appl. 462, 410–420 (2016)CrossRefGoogle Scholar
  13. 13.
    Ketchen, D.J., Shook, C.L.: The application of cluster analysis in strategic management research: an analysis and critique. Strat. Manag. J. 17(6), 441–458 (1996)CrossRefGoogle Scholar
  14. 14.
    Krauss, C., Do, X.A., Huck, N.: Deep neural networks, gradient-boosted trees, random forests: statistical arbitrage on the S&P 500. Eur. J. Oper. Res. 259(2), 689–702 (2017)CrossRefGoogle Scholar
  15. 15.
    Kumar, B.S., Ravi, V.: A survey of the applications of text mining in financial domain. Knowl.-Based Syst. 114, 128–147 (2016)CrossRefGoogle Scholar
  16. 16.
    Längkvist, M., Karlsson, L., Loutfi, A.: A review of unsupervised feature learning and deep learning for time-series modeling. Pattern Recognit. Lett. 42, 11–24 (2014)CrossRefGoogle Scholar
  17. 17.
    LeCun, Y., Bengio, Y., Hinton, G.: Deep learning. Nature 521(7553), 436 (2015)CrossRefGoogle Scholar
  18. 18.
    Li, Y., Jiang, W., Yang, L., Wu, T.: On neural networks and learning systems for business computing. Neurocomputing 275, 1150–1159 (2018)CrossRefGoogle Scholar
  19. 19.
    Liu, Y., Li, Z., Xiong, H., Gao, X., Wu, J.: Understanding of internal clustering validation measures. In: ICDM, pp. 911–916 (2010)Google Scholar
  20. 20.
    Mirkin, B.G.: Mathematical Classification and Clustering. Kluwer Academic Publishing, Dordrecht (1996)CrossRefGoogle Scholar
  21. 21.
    Momeni, M., Mohseni, M., Soofi, M.: Clustering stock market companies via k-means algorithm. Kuwait Chap. Arab. J. Bus. Manag. Rev. 4(5), 1 (2015)CrossRefGoogle Scholar
  22. 22.
    Nanda, S.R., Mahanty, B., Tiwari, M.K.: Clustering Indian stock market data for portfolio management. Expert Syst. Appl. 37(12), 8793–8798 (2010)CrossRefGoogle Scholar
  23. 23.
    Nelson, D.M., Pereira, A.C., de Oliveira, R.A.: Stock market’s price movement prediction with LSTM neural networks. In: 2017 International Joint Conference on Neural Networks (IJCNN), pp. 1419–1426. IEEE (2017)Google Scholar
  24. 24.
    Python Software Foundation: Python 3.5.5 documentation (2018).
  25. 25.
    Qiu, M., Song, Y., Akagi, F.: Application of artificial neural network for the prediction of stock market returns: the case of the Japanese stock market. Chaos, Solitons Fractals 85, 1–7 (2016)MathSciNetCrossRefGoogle Scholar
  26. 26.
    Zhang, J., Cui, S., Xu, Y., Li, Q., Li, T.: A novel data-driven stock price trend prediction system. Expert Syst. Appl. 97, 60–69 (2018)CrossRefGoogle Scholar

Copyright information

© ICST Institute for Computer Sciences, Social Informatics and Telecommunications Engineering 2020

Authors and Affiliations

  • Felipe Affonso
    • 1
    Email author
  • Thiago Magela Rodrigues Dias
    • 1
  • Adilson Luiz Pinto
    • 2
  1. 1.Centro Federal de Educação Tecnológica de Minas GeraisBelo HorizonteBrazil
  2. 2.Universidade Federal de Santa CatarinaFlorianópolisBrazil

Personalised recommendations