A Methodology for Definition and Refinement of a LSTM Stock Predictor Architecture using iRace and NSGA-II

  • Thiago F. Costa CEFET-MG
  • Elizabeth F. Wanner CEFET-MG
  • Flávio V. C. Martins CEFET-MG
  • André R. da Cruz CEFET-MG


This paper presents a novel methodology aiming to define and refine a LSTM architecture applied to predict stock market prices. The methodology, dubbed STOCK-PRED: THE LSTM PROPHET OF THE STOCK MARKET, uses iRace and NSGA-II algorithms. The LSTM is built in two steps: (i) initially, iRace determines a robust set of hyperparameters using a compound objective function; afterwards, (ii) one of the best structures is used to define a tiny search space for the NSGA-II populations. In this step NSGA-II optimizes, simultaneously, the Mean Squared Error, in relation to price prediction, and the Accumulated Accuracy Rate for a time horizon of seven days, relative to growth price tendency. The methodology is tested considering stock market tickers from USA and Brazil. Even in a challenging scenario surrounded by possibly turbulent events, the Stock-Pred predicts the prices based on historical data and machine learning techniques. Since the optimization problem is noisy and the objective functions have a high computational cost, we consider a low budget in relation to the number of fitness evaluations. The analysis of the non-dominated solution indicates that the proposed methodology is promising, achieving a MAPE of 1.279%, 1.564% and 2.047% for BVSP, IBM and AAPL stocks respectively.

Palavras-chave: Stock market forecasting, LSTM Networks, NSGA-II, Irace


B3 (2021). Uma análise da evolução dos investidores na b3. (visited on 2021-11-03).

Bahdanau, D., Cho, K., and Bengio, Y. (2014). Neural machine translation by jointly learning to align and translate. arXiv preprint arXiv:1409.0473.

Blank, J. and Deb, K. (2020). pymoo: Multi-objective optimization in python. IEEE Access, 8:89497–89509.

Chen, K., Zhou, Y., and Dai, F. (2015). A lstm-based method for stock returns prediction: A case study of china stock market. In IEEE international conference on big data.

Chu, X., Zhang, B., Ma, H., Xu, R., and Li, Q. (2021). Fast, accurate and lightweight super-resolution with neural architecture search. In 2020 25th International Conference on Pattern Recognition (ICPR), pages 59–64. IEEE.

Chui, K. T., Gupta, B. B., and Vasant, P. (2021). A genetic algorithm optimized rnn-lstm model for remaining useful life prediction of turbofan engine. Electronics, 10(3):285.

Cramer, S., Kampouridis, M., Freitas, A. A., and Alexandridis, A. K. (2017). An extensive evaluation of seven machine learning methods for rainfall prediction in weather derivatives. Expert Systems with Applications, 85:169–181.

Deb, K., Pratap, A., Agarwal, S., and Meyarivan, T. (2002). A fast and elitist multiobjective genetic algorithm: NSGA-II. IEEE Transactions on Evolutionary Computation.

Fama, E. F. (1970). Efficient capital markets: A review of theory and empirical work. The Journal of Finance, 25(2):383–417.

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

Ishibuchi, H., Tsukamoto, N., and Nojima, Y. (2008). Evolutionary many-objective optimization: A short review. In 2008 IEEE congress on evolutionary computation (IEEE world congress on computational intelligence), pages 2419–2426. IEEE.

Kampouridis, M. and Otero, F. E. (2017). Evolving trading strategies using directional changes. Expert Systems with Applications, 73:145–160.

Kirkpatrick II, C. D. and Dahlquist, J. A. (2010). Technical analysis: the complete resource for financial market technicians. FT press.

Li, H., Shen, Y., and Zhu, Y. (2018). Stock price prediction using attention-based multiinput lstm. In Asian conference on machine learning, pages 454–469. PMLR.

Li, J., Liang, C., Zhang, B., Wang, Z., Xiang, F., and Chu, X. (2019). Neural architecture search on acoustic scene classification. arXiv preprint arXiv:1912.12825.

Liu, S., Liao, G., and Ding, Y. (2018). Stock transaction prediction modeling and analysis based on lstm. In IEEE Conference on Industrial Electronics and Applications.

López-Ibáñez, M., Dubois-Lacoste, J., Cáceres, L. P., Birattari, M., and Stützle, T. (2016). The irace package: Iterated racing for automatic algorithm configuration. Operations Research Perspectives, 3:43–58.

Malkiel, B. G. (1973). A random walk down wall street. w. w.

Menon, A., Singh, S., and Parekh, H. (2019). A review of stock market prediction using neural networks. In 2019 IEEE International Conference on System, Computation, Automation and Networking (ICSCAN), pages 1–6. IEEE.

Moghar, A. and Hamiche, M. (2020). Stock market prediction using lstm recurrent neural network. Procedia Computer Science, 170:1168–1173.

Mohamed, I. and Otero, F. E. (2020). A multiobjective optimization approach for market timing. In Proceedings of the Genetic and Evolutionary Computation Conference.

Nakagawa, S. and Schielzeth, H. (2013). A general and simple method for obtaining r2 from generalized linear mixed-effects models. Methods in ecology and evolution, 4(2).

Nelson, D. M., Pereira, A. C., and de Oliveira, R. A. (2017). Stock market’s price movement prediction with lstm neural networks. In 2017 International joint conference on neural networks (IJCNN), pages 1419–1426. IEEE.

Palepu, K. G., Healy, P. M., Wright, S., Bradbury, M., and Coulton, J. (2020). Business analysis and valuation: Using financial statements. Cengage AU.

Roondiwala, M., Patel, H., and Varma, S. (2017). Predicting stock prices using lstm. International Journal of Science and Research (IJSR), 6(4):1754–1756.

Sahni, R. (2018). Analysis of stock market behaviour by applying chaos theory. In 9th international conference on computing, communication and networking technologies.

Selvin, S., Vinayakumar, R., Gopalakrishnan, E., Menon, V. K., and Soman, K. (2017). Stock price prediction using lstm, rnn and cnn-sliding window model. In international conference on advances in computing, communications and informatics.

Shah, D., Isah, H., and Zulkernine, F. (2019). Stock market analysis: A review and taxonomy of prediction techniques. International Journal of Financial Studies, 7(2):26.

Xu, D., Zhang, S., Zhang, H., and Mandic, D. P. (2021). Convergence of the rmsprop deep learning method with penalty for nonconvex optimization. Neural Networks, 139:17–23.
Como Citar

Selecione um Formato
COSTA, Thiago F.; WANNER, Elizabeth F.; MARTINS, Flávio V. C.; CRUZ, André R. da. A Methodology for Definition and Refinement of a LSTM Stock Predictor Architecture using iRace and NSGA-II. In: BRAZILIAN WORKSHOP ON ARTIFICIAL INTELLIGENCE IN FINANCE (BWAIF), 1. , 2022, Niterói. Anais [...]. Porto Alegre: Sociedade Brasileira de Computação, 2022 . p. 25-36. DOI: https://doi.org/10.5753/bwaif.2022.222869.