Financial Times Series Forecasting of Clustered Stocks

Abstract

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 technique. 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. Later, predicted prices are compared to the correct prices in order to analyze prices tendency. Results showed that clustering stocks did not influence the effectiveness of the network, once tendency was predicted correct for an average of 48% of time. Investors and portfolio managers can use proposed techniques to simply their daily tasks.

This is a preview of subscription content, log in to check access.

Fig. 1
Fig. 2
Fig. 3

Notes

  1. 1.

    https://www.kaggle.com/borismarjanovic/price-volume-data-for-all-us-stocks-etfs

References

  1. 1.

    Selvin S, Vinayakumar R, Gopalakrishnan EA, Menon VK, Soman KP (2017) Stock price prediction using LSTM, RNN and CNN-sliding window model. In 2017 international conference on advances in computing, communications and informatics (icacci) (pp 1643-1647). IEEE

  2. 2.

    Sagheer A, Kotb M (2019) Time series forecasting of petroleum production using deep LSTM recurrent networks. Neurocomputing 323:203–213

    Article  Google Scholar 

  3. 3.

    Filho DBF, Júnior JAdS (2009) Desvendando os mistérios do coeficiente de correlacão de pearson (r). Universidade Federal de Pernambuco

  4. 4.

    Zhang J, Cui S, Xu Y, Li Q, Li T (2018) A novel data-driven stock price trend prediction system. Expert Syst Appl 97:60–69

    Article  Google Scholar 

  5. 5.

    LeCun Y, Bengio Y, Hinton G (2015) Deep learning. Nature 521(7553):436

    Article  Google Scholar 

  6. 6.

    Gerlein EA, McGinnity M, Belatreche A, Coleman S (2016) Evaluating machine learning classification for financial trading: an empirical approach. Expert Syst Appl 54:193–207

    Article  Google Scholar 

  7. 7.

    Krauss C, Do XA, Huck N (2017) Deep neural networks, gradient-boosted trees, random forests: statistical arbitrage on the S&P 500. Eur J Oper Res 259(2):689–702

    Article  Google Scholar 

  8. 8.

    Bini BS, Mathew T (2016) Clustering and regression techniques for stock prediction. Procedia Technol 24:1248–1255

    Article  Google Scholar 

  9. 9.

    Jung SS, Chang W (2016) Clustering stocks using partial correlation coefficients. Phys A: Statistical Mech Appl 462:410–420

    Article  Google Scholar 

  10. 10.

    Momeni M, Mohseni M, Soofi M (2015) Clustering stock market companies via K-means algorithm. Kuwait Chapter Arabian J Business Manag Rev 4(5):1–10

    Article  Google Scholar 

  11. 11.

    Nanda SR, Mahanty B, Tiwari MK (2010) Clustering Indian stock market data for portfolio management. Expert Syst Appl 37(12):8793–8798

    Article  Google Scholar 

  12. 12.

    Längkvist M, Karlsson L, Loutfi A (2014) A review of unsupervised feature learning and deep learning for time-series modeling. Pattern Recogn Lett 42:11–24

    Article  Google Scholar 

  13. 13.

    Kumar BS, Ravi V (2016) A survey of the applications of text mining in financial domain. Knowl-Based Syst 114:128–147

    Article  Google Scholar 

  14. 14.

    Cavalcante RC, Brasileiro RC, Souza VL, Nobrega JP, Oliveira AL (2016) Computational intelligence and financial markets: A survey and future directions. Expert Syst Appl 55:194–211

    Article  Google Scholar 

  15. 15.

    Chong E, Han C, Park FC (2017) Deep learning networks for stock market analysis and prediction: methodology, data representations, and case studies. Expert Syst Appl 83:187–205

    Article  Google Scholar 

  16. 16.

    Fischer T, Krauss C (2018) Deep learning with long short-term memory networks for financial market predictions. Eur J Oper Res 270(2):654–669

    MathSciNet  Article  Google Scholar 

  17. 17.

    Nelson DM, Pereira AC, de Oliveira RA (2017) Stock market's price movement prediction with LSTM neural networks. In neural networks (IJCNN), 2017 international joint conference on (pp 1419-1426). IEEE

  18. 18.

    Shao X, Ma D, Liu Y, Yin Q (2017) Short-term forecast of stock price of multi-branch LSTM based on K-means. In 2017 4th International Conference on Systems and Informatics (ICSAI) (pp 1546-1551). IEEE

  19. 19.

    Python Software Foundation (2018) Python 3.5.5 documentation. Available at https://docs.python.org/3.5/

  20. 20.

    Chollet, F. (2015). Keras. Available at https://keras.io

  21. 21.

    Mirkin BG (1996) Mathematical classification and clustering. Kluwer Academic Publishing, Dordrecht

    Google Scholar 

  22. 22.

    Affonso F, de Oliveira F, Dias TMR (2017) Uma Análise dos Fatores que Influenciam o Movimento Acionário das Empresas Petrolíferas. In Ibero-Latin Am Congress Computat Methods Eng (CILAMCE)

  23. 23.

    Gan G, Ma C, Wu J (2007) Data clustering: theory, algorithms, and applications (Vol. 20). Siam

  24. 24.

    Liu Y, Li Z, Xiong H, Gao X, Wu J (2010) Understanding of internal clustering validation measures. In ICDM:911–916

  25. 25.

    Ketchen DJ, Shook CL (1996) The application of cluster analysis in strategic management research: an analysis and critique. Strateg Manag J 17(6):441–458

    Article  Google Scholar 

  26. 26.

    Siami-Namini S, Tavakoli N, Namin AS (2018) A comparison of ARIMA and LSTM in forecasting time series. In 2018 17th IEEE International Conference on Machine Learning and Applications (ICMLA) (pp. 1394-1401). IEEE

  27. 27.

    Li Y, Jiang W, Yang L, Wu T (2018) On neural networks and learning systems for business computing. Neurocomputing 275:1150–1159

    Article  Google Scholar 

  28. 28.

    Bengio Y, Simard P, Frasconi P (1994) Learning long-term dependencies with gradient descent is difficult. IEEE Trans Neural Netw 5(2):157–166

    Article  Google Scholar 

  29. 29.

    Hochreiter S, Schmidhuber J (1997) Long short-term memory. Neural Comput 9(8):1735–1780

    Article  Google Scholar 

Download references

Author information

Affiliations

Authors

Corresponding author

Correspondence to Felipe Affonso.

Ethics declarations

Conflicts of interest/competing interest

Not Applicable.

Code availability

The code developed is available at: https://github.com/felipe-affonso/Financial-Times-Series-Forecasting-MONET

Additional information

Publisher’s Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Affonso, F., Dias, T.M.R. & Pinto, A.L. Financial Times Series Forecasting of Clustered Stocks. Mobile Netw Appl (2020). https://doi.org/10.1007/s11036-020-01647-8

Download citation

Keywords

  • Financial forecasting
  • Clustering stocks
  • Artificial neural networks