Skip to content
Open access

Bio-Inspired Hyperparameter Optimization of LSTM Networks for Long-Horizon Stock Price Forecasting

Sep 2026 · Forecasting · 0 citations · 34 references

Abstract

Accurate stock price forecasting remains a challenging problem because financial markets are highly dynamic, nonlinear, and influenced by changing economic conditions. Deep learning models, particularly Long Short-Term Memory (LSTM) networks, have shown strong capability in capturing temporal dependencies in financial time series. However, their performance is often sensitive to hyperparameter selection, which can affect convergence, stability, and generalization. This research presents a comparative forecasting framework using three bio-inspired hyperparameter optimization algorithms: Sand Cat Swarm Optimization (SCSO), Particle Swarm Optimization (PSO), and Grey Wolf Optimization (GWO). Each of the optimization algorithms works on a common hyperparameter search space comprising the learning rate, dropout rate, batch size and number of units in the LSTM layers, while the input sequence length is fixed at 60 trading days. The models are compared with a fixed-hyperparameter baseline LSTM to validate whether hyperparameter optimization improves price forecasting. The models are evaluated using daily data from five DAX-index equities over two sample periods: 2018–2023 and 1996–2024, respectively, with 2023 and 2019–2024 being their respective held-out test sets. The LSTM predicts the next-trading-day log return, which is transformed into a forecast of the next adjusted closing price. Historical prices and technical indicators representing trend, momentum, and volatility are incorporated into the modeling process. Chronological data splitting, training-only scaler fitting, validation-based hyperparameter selection, and a held-out test set used exclusively for final evaluation are employed to limit look-ahead bias, with every model evaluated across three random seeds. Model performance is assessed using Mean Absolute Error (MAE), Root Mean Squared Error (RMSE), Mean Absolute Percentage Error (MAPE), coefficient of determination (R2) and directional accuracy, along with support from Diebold–Mariano tests and Ljung–Box and ARCH residual diagnostics. LSTM–SCSO achieves the strongest aggregate error performance during 2018–2023, reducing mean RMSE by approximately 2.5% relative to the baseline. During 1996–2024, PSO–LSTM ranks first on RMSE, MAE, and MAPE, reducing mean RMSE by approximately 3.9%, while GWO–LSTM produces closely comparable results. Optimized models record the lowest equity-level mean RMSE for four of five equities in the short-term experiment and three of five equities in the long-term experiment. However, Diebold–Mariano significance varies across model–equity comparisons, and aggregate directional accuracy remains below 50% for all models in both periods. Long-term residual diagnostics also identify substantial autocorrelation and ARCH effects. The findings demonstrate that bio-inspired metaheuristic optimization can improve one-step-ahead LSTM forecasts, but its benefits depend on the optimizer, equity, and historical evaluation period.

Read PDF

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.