Abstract
Financial time series prediction, especially with machine learning techniques, is an extensive field of study. In recent times, deep learning methods (especially time series analysis) have performed outstandingly for various industrial problems, with better prediction than machine learning methods. Moreover, many researchers have used deep learning methods to predict financial time series with various models in recent years. In this paper, we will compare various deep learning models, such as multilayer perceptron (MLP), one-dimensional convolutional neural networks (1D CNN), stacked long short-term memory (stacked LSTM), attention networks, and weighted attention networks for financial time series prediction. In particular, attention LSTM is not only used for prediction, but also for visualizing intermediate outputs to analyze the reason of prediction; therefore, we will show an example for understanding the model prediction intuitively with attention vectors. In addition, we focus on time and factors, which lead to an easy understanding of why certain trends are predicted when accessing a given time series table. We also modify the loss functions of the attention models with weighted categorical cross entropy; our proposed model produces a 0.76 hit ratio, which is superior to those of other methods for predicting the trends of the KOSPI 200.
Introduction
Predicting financial markets is notoriously difficult due to their non-linear, noisy, and dynamic nature. While traditional methods like technical analysis (using price/volume) and fundamental analysis (using economic factors) exist, they often fail to capture complex, long-term dependencies in the data. Furthermore, many deep learning models act as "black boxes." For an investor, knowing that a model predicts a price drop is less useful than knowing why—is it because of a shift in the exchange rate or a dip in a global index? This paper seeks to bridge the gap between high predictive accuracy and model interpretability by utilizing an Attention-based Long Short-Term Memory (LSTM) network.
Methodology
The core contribution of this research is the Weighted Attention LSTM. Unlike standard sequential models, this architecture incorporates a dual-stage attention mechanism to enhance both accuracy and explainability.
Dual-Stage Attention
The model applies attention mechanisms to two distinct dimensions:
- Temporal Dimension: Identifying which specific days in the past are most relevant to the future prediction.
- Feature Dimension: Determining which economic indicators (factors) carry the most weight in the current market context.
Soft Attention and Weighted Loss
The researchers utilized a "soft" attention module that normalizes weights using a softmax function, ensuring the architecture is end-to-end differentiable.
To further refine performance, the authors introduced Weighted Categorical Cross Entropy. Standard models treat every day's prediction as equally important; however, this modified loss function multiplies the error by the absolute magnitude of the price change. This forces the model to prioritize accuracy during periods of high volatility, where the financial stakes are highest.
Datasets and Experimental Setup
The study focuses on the KOSPI 200, an index of the 200 most traded companies on the Korean Stock Exchange.
- Input Features: The model incorporates price data alongside fundamental indicators such as currency exchange rates, global indices (e.g., S&P 500), and commodity prices.
- Timeframe: Training data spanned from 2007 to 2016, with a test set covering January 2017 to July 2018.
- Preprocessing: Data was converted into "change ratios" (returns) rather than raw prices to ensure stationarity, and the authors found that a 60-day lookback window yielded the best results.
Key Results and Insights
The proposed weighted attention model achieved a 0.763 hit ratio (76.3% accuracy in predicting up/down movement), significantly outperforming standard attention models (0.715) and simpler ANN/SVM models (typically ~0.52).
Beyond raw accuracy, the model demonstrated superior profitability, earning 1257.46 points compared to 1090.71 for the unweighted version—a 15% improvement. Visualization of the attention vectors revealed that the model naturally prioritized the most recent trading days and specific global factors like the US Dollar index when making KOSPI 200 predictions. The model performed optimally when predicting trends 40 days into the future, suggesting its utility for mid-term swing trading.
Conclusion
While the Attention LSTM provides a powerful tool for interpretable financial forecasting, limitations remain. The current model is a binary classifier (up/down) and does not predict exact price magnitudes. Additionally, real-world market frictions like transaction costs and slippage were not included in the profitability metrics. Future work may involve automated feature engineering or the integration of unstructured data, such as financial news sentiment, to further enhance predictive power.
Summary updated