An Explainable LSTM Framework for Stock Trading via Behavioral Decomposition and Competition-Driven Optimization
Forecasting short-term stock price movements remains challenging due to market non-stationarity, volatility, and the complex aggregation of heterogeneous investor behaviors. Although Long Short-Term Memory (LSTM) networks have demonstrated strong performance in financial time-series prediction, most existing approaches operate as black boxes and provide limited insight into short-term directional changes, constraining trust and real-world deployment. This paper introduces an explainable LSTM-based trading framework based on subrogate agent-based simulation model that reframes prediction as the estimation of collective investor behavior rather than direct price forecasting. The proposed method decomposes historical price and volume series into behavioral components representing distinct investor roles. Separate LSTM models are trained to forecast the future proportions of each behavioral role. These predictions are aggregated into price-direction signals using behavioral-to-price rules whose parameters are optimized via a genetic algorithm. The genetic algorithm evolves decomposition weights and thresholds by evaluating candidate rule sets in repeated trading competitions, directly optimizing profitability and risk-adjusted performance rather than purely statistical error. This competition-driven optimization yields behaviorally consistent decompositions aligned with realistic market outcomes. The framework is implemented and evaluated within the Dashboard for Intelligent Investment Decisions with eXplainable artificial intelligence (DI2XAI), a multi-agent backtesting simulator using real Yahoo Finance data, enabling leakage-free and reproducible trading experiments across diverse market regimes. Extensive evaluations over multiple stocks, sectors, and historical periods show that the proposed approach consistently outperforms standard trading baselines with the LSTM, convolutional neural network with LSTM (CNN-LSTM), and CNN with bidirectional LSTM (CNN-BiLSTM), random forest and extreme-gradient boosting (XGBoost), achieving higher profitability. Our approach outperformed LSTM, CNN-LSTM, CNN-BiLSTM and random forest with statistically significant improvements (p<0.001), and outperformed XGBoost with an improvement of 12.5% in the final capital result.
Authors
- Iván García‐Magariño (ORCID: https://orcid.org/0000-0002-2726-6760)
- Javier Bravo (ORCID: https://orcid.org/0000-0002-3516-7367)
Institutions
- Universidad Complutense de Madrid (ES)
Publication Details
- Journal
- Research Square
- Published
- 2026-11-24
- DOI
- https://doi.org/10.21203/rs.3.rs-11842563/v1
- Primary Topic
- Stock Market Forecasting Methods
- Type
- preprint
Funders
- Comunidad de Madrid
- Agencia Estatal de Investigación