Enhancing Stock Price Forecasting with LSTM Networks: A Comparative Study of Classic and PSO-Optimized Models on S&P 500 Stocks


  •  Imad Talhartit    
  •  Sanae Ait Jillali    
  •  Mounime El Kabbouri    

Abstract

This study is part of an empirical and quantitative approach aimed at improving stock market fluctuation forecasting through the application of artificial intelligence models. More specifically, it evaluates the performance of two methods based on Long Short-Term Memory (LSTM) neural networks, one of the most powerful algorithms for analyzing financial time series. The first method is grounded in a classic LSTM model, while the second incorporates hyperparameter optimization using the Particle Swarm Optimization (PSO) metaheuristic method, allowing for better convergence and enhanced prediction accuracy. The study is conducted on ten stocks representing the US S&P 500 index, with historical data spanning several decades, collected via the Investing.com and Yahoo Finance platforms.

The empirical results demonstrate a clear superiority of the LSTM-PSO model regarding predictive accuracy, with significant reductions in errors (MSE, RMSE, MAE, MSLE, and RMSLE) compared to the traditional model. These findings emphasize the advantages of combining artificial intelligence and algorithmic optimization for handling complex financial data. In the global context of digitization and automation of investment decisions, this research contributes significantly to the development of reliable predictive systems.

Finally, the study raises the question of whether this methodological framework could be effectively adapted to emerging markets, such as the Moroccan Stock Market, where financial environments are characterized by lower trading volumes, different volatility patterns, and more limited historical data. This opens up avenues for future research into the challenges and opportunities of applying advanced AI-based forecasting models in less mature financial markets.



This work is licensed under a Creative Commons Attribution 4.0 License.