Predicting stock prices and ETF on the B3 stock exchange using machine learning techniques

Authors

DOI:

https://doi.org/10.47236/2594-7036.2026.v10.1879

Keywords:

Machine learning, Stock market, LSTM, Time series

Abstract

The number of new investors in the Brazilian stock market is increasing. Many of these new investors seek higher returns, often without the necessary skills to analyze the opportunities and dangers. This study aims to develop an LSTM model with the objective of predicting the prices of stocks and ETF on the B3 stock exchange.  The model was trained with historical data from the last 10 years of a group of five stocks (Banco do Brasil, Itaú, Vale, Petrobras, and Caixa Seguridade) and two ETF (BOVA11 and FIND11). The results demonstrated that the model is effective in predicting assets within the Brazilian financial market, validated through some metrics, with results within the following ranges: RMSE (0.30 to 1.98), MAE (0.23 to 1.54), MAPE (0.98 to 3.40), and R² (0.77 to 0.99).  However, assets with little historical data, such as Caixa Seguridade, showed greater variation in the forecasts, indicating limitations of the model.

Downloads

Download data is not yet available.

Metrics

Metrics Loading ...

Author Biographies

Eduardo Luiz Zanotto, University of Passo Fundo

Bachelor's degree in Computer Science from the University of Passo Fundo. Passo Fundo, Rio Grande do Sul, Brazil. Email address: eduardoluizzanoto@gmail.com. Orcid: https://orcid.org/0009-0004-9479-9841. Lattes Curriculum: http://lattes.cnpq.br/1732542745002387.

Carlos Amaral Holbig, University of Passo Fundo

PhD in Computer Science from the Federal University of Rio Grande do Sul. Full Professor in the Graduate Program in Applied Computing at the University of Passo Fundo. Passo Fundo, Rio Grande do Sul, Brazil. Email address: holbig@upf.br. Orcid: https://orcid.org/0000-0002-3126-344X. Lattes Curriculum: http://lattes.cnpq.br/5419646313109789.

References

ALMEIDA, Tiago da Silva; MAGALHÃES, Hudson Pena. A precipitation forecasting in central ecotone region in Brazil using artificial neural networks and public climatic data. Revista Sítio Novo, Palmas, v. 5, n. 2, p. 131-146, 2021. DOI: 10.47236/2594-7036.2021.v5.i2.131-146p. Disponível em: https://sitionovo.ifto.edu.br/index.php/sitionovo/article/view/919. Acesso em: 15 dez. 2025.

ALVES, P. C. P.; PRADO, S. C. C. Estudo comparativo entre algoritmos de machine learning aplicados à previsão de séries temporais do mercado financeiro. In: CONGRESSO DE TECNOLOGIA, Faculdade de Tecnologia de Mococa, 2022, Mococa. Anais [...]. Mococa: Fatec, 2022. v. 6, n. 2.

AYYILDIZ, Nazif; ISKENDEROGLU, Omer. How effective is machine learning in stock market predictions? Heliyon, v. 10, n. 2, p. e24123, 2024. DOI: 10.1016/j.heliyon.2024.e24123. Disponível em: https://doi.org/10.1016/j.heliyon.2024.e24123. Acesso em: 8 out. 2025.

B3. Perfil de investidores pessoa física. 2024. Disponível em: https://www.b3.com.br/pt_br/market-data-e-indices/servicos-de-dados/market-data/consultas/mercado-a-vista/perfil-pessoas-fisicas/perfil-pessoa-fisica/. Acesso em: 17 out. 2024.

BISHOP, Christopher M. Pattern recognition and machine learning. Berlin: Springer, 2011.

BOX, George E. P.; JENKINS, Gwilym M.; REINSEL, Gregory C.; LJUNG, Greta M. Time series analysis forecasting and control. 5. ed. San Francisco: Wiley, 2015.

CHEN, James. Exponential moving average (EMA): definition, formula, and usage. Investopedia, 2025. Disponível em: https://www.investopedia.com/terms/e/ema.asp. Acesso em: 14 dez. 2025.

DA SILVA, Jeremias Fontinele; RODRIGUES, Carlos Alberto de Sousa Parente;

TOLENTINO, Carlos Henrique Corrêa; MACIEL, Wandro Bequiman. Modelo de rede neural para avaliação desportiva. Revista Sítio Novo, Palmas, v. 5, n. 3, p. 34-44, 2021. DOI: 10.47236/2594-7036.2021. Disponível em: https://sitionovo.ifto.edu.br/index.php/sitionovo/article/view/952. Acesso em: 15 dez. 2025.

GOODFELLOW, Ian et al. Deep learning. Cambridge: The MIT Press, 2016. (Adaptive Computation and Machine Learning Series).

GOOGLE. Google Colaboratory. 2024. Disponível em: https://colab.research.google.com/. Acesso em: 15 maio 2024.

GÜLMEZ, Burak. Stock price prediction with optimized deep LSTM network with artificial rabbits optimization algorithm. Expert Systems with Application, v. 227, p.120346, 2023. DOI: 10.1016/j.eswa.2023.120346. Disponível em: https://doi.org/10.1016/j.eswa.2023.120346. Acesso em: 15 out. 2024.

GUPTA, Samraj; NACHAPPA, Sanchal; PARMANANDHAM, Nirmala. Stock market time series forecasting using comparative machine learning algorithms. Procedia Computer Science. v. 252, n. C, p. 893-904, 2025. DOI: 10.1016/j.procs.2025.01.050. Disponível em: https://doi.org/10.1016/j.procs.2025.01.050. Acesso em: 14 dez. 2025.

HOCHREITER, Sepp; SCHMIDHUBER, Jürgen. Long short-term memory. Neural Computation. v. 9, n. 8, p. 1735-1780, 1997. DOI: 10.1162/neco.1997.9.8.1735. Disponível em: https://doi.org/10.1162/neco.1997.9.8.1735. Acesso em: 15 dez. 2025.

HYNDMAN, Rob J.; ATHANASOPOULOS, George. Forecasting: principles and practice. 3. ed. Melbourne: OTexts, 2021. Disponível em: https://otexts.com/fpp3/. Acesso em: 14 dez. 2025.

JIANG, Fuwei; MA, Tian; ZHU, Feifei. Fundamental characteristics, machine learning, and stock price crash risk. Journal of Financial Markets, v. 69, p.100908, 2024. DOI: 10.1016/j.finmar.2024.100908. Disponível em: https://doi.org/10.1016/j.finmar.2024.100908. Acesso em: 15 out. 2024.

KUNDU, Triparna; PINSKY, Eugene. Predicting daily stock price directions with deep learning models. Machine Learning with Applications, v. 22, p. 100744, 2025. DOI: 10.1016/j.mlwa.2025.100744. Disponível em: https://doi.org/10.1016/j.mlwa.2025.100744. Acesso em: 14 dez. 2025.

LI, Katherine Yi. Machine learning for stock price prediction. Neptune Blog, 2024. Disponível em: https://neptune.ai/blog/predicting-stock-prices-using-machine-learning. Acesso em: 16 out. 2024.

LIN, Yaohu et al. Stock trend prediction using candlestick charting and ensemble machine learning techniques with a novelty feature engineering scheme. IEEE Access, v. 9, p. 101433-101446, 2021.

LOPES, Alex Oliveira et al. Factors influencing Petrobras Stock Prices (PETR4) between 2009 and 2020. Research, Society and Development, [s. l.], v. 10, n. 7, p. e13410716294, 2021. DOI: 10.33448/rsd-v10i7.16294. Disponível em: https://rsdjournal.org/rsd/article/view/16294. Acesso em: 12 dez. 2025.

MACHADO, Michele Rílany Rodrigues; GARTNER, Ivan Ricardo; MACHADO, Lúcio de Souza. Relationship between Ibovespa and macroeconomic variables: evidence from a Markov-Switching model. Brazilian Review of Finance, [s. l.], v. 15, n. 3, p. 435-468, 2018. DOI: 10.12660/rbfin.v15n3.2017.59406. Disponível em: https://periodicos.fgv.br/rbfin/article/view/59406. Acesso em: 12 dez. 2025.

MATPLOTLIB. Matplotlib. 2024. Disponível em: https://matplotlib.org/. Acesso em: 20 abr. 2025.

MINTARYA, Latrisha N. et al. Machine learning approaches in stock market prediction: a systematic literature review. Procedia Computer Science, v. 216, p.96-102, 2023. DOI: 10.1016/j.procs.2022.12.115. Disponível em: https://doi.org/10.1016/j.procs.2022.12.115. Acesso em: 20 abr. 2025.

NAJEM, Rihab et al. Advancements in Artificial Intelligence and machine learning for stock market prediction: a comprehensive analysis of techniques and case studies. Procedia Computer Science, v. 231, p.198-204, 2024. DOI: 10.1016/j.procs.2023.12.193. Disponível em: https://doi.org/10.1016/j.procs.2023.12.193. Acesso em: 20 abr. 2025.

NASCIMENTO, Oberis S.; SANTOS, Felipe G.; FERREIRA, Karl Hansimuller A. Previsão de preços de ações utilizando Inteligência Artificial. In: BRAZILIAN WORKSHOP ON ARTIFICIAL INTELLIGENCE IN FINANCE (BWAIF), 1., 2022, Niterói, RJ. Anais eletrônicos [...]. Porto Alegre: SBC, 2022. Disponível em: https://sol.sbc.org.br/index.php/bwaif/article/view/20485. Acesso em: 20 abr. 2025.

NEPTUNE.AI. Neptune documentation. 2024. Disponível em: https://neptune.ai/. Acesso em: 16 out. 2024.

PANDAS DEVELOPMENT TEAM. Pandas documentation. 2024. Disponível em: https://pandas.pydata.org/. Acesso em: 16 out. 2024.

PYTHON SOFTWARE FOUNDATION. Python. 2024. Disponível em: https://www.python.org/. Acesso em: 15 out. 2024.

REN, Tingting; LI, Shaofang; ZHANG, Siying. Stock market extreme risk prediction based on machine learning: evidence from the american market. 2024. The North American Journal of Economics and Finance, v. 74, p. 102241. DOI: 10.1016/j.najef.2024.102241. Disponível em: https://doi.org/10.1016/j.najef.2024.102241. Acesso em: 20 abr. 2025.

SANTANA, Daniel. Ajustando o preço das ações Yahoo Finance. 2022. Disponível em: https://medium.com/@sant1/ajustando-o-preço-das-ações-yahoo-finance-9bd5520bf941. Acesso em: 16 out. 2024.

SANTOS, Júlio Cesar. Abordagens de aprendizado de máquina para séries temporais financeiras. 2022. Trabalho de Conclusão de Curso (MBA em Inteligência Artificial e Big Data) – Universidade de São Paulo, São Paulo, 2022.

SCIKIT-LEARN. Scikit-learn documentation. 2024. Disponível em: https://scikit-learn.org/stable/. Acesso em: 16 out. 2024.

SILVEIRA, Rafael Bourscheid. Avaliação de modelos preditivos para o mercado de ações utilizando machine e deep learning. 2021. Trabalho de Conclusão de Curso (Ciência da Computação) – Universidade de Caxias do Sul. Disponível em: https://repositorio.ucs.br/11338/9714. Acesso em: 20 abr. 2025.

TENSORFLOW. TensorFlow. 2024. Disponível em: https://www.tensorflow.org/. Acessos em: 16 out. 2024; 20 abr. 2025.

YFINANCE. Yfinance library documentation. 2024. Disponível em: https://pypi.org/project/yfinance/. Acesso em: 16 out. 2024.

Published

2026-01-19

How to Cite

ZANOTTO, Eduardo Luiz; HOLBIG, Carlos Amaral. Predicting stock prices and ETF on the B3 stock exchange using machine learning techniques. Sítio Novo Magazine, Palmas, v. 10, p. e1879, 2026. DOI: 10.47236/2594-7036.2026.v10.1879. Disponível em: https://sitionovo.ifto.edu.br/index.php/sitionovo/article/view/1879. Acesso em: 23 jan. 2026.

Issue

Section

Artigo Científico