TITLE:
Explore Anomaly-Aware Transformers for Robust Financial Time Series Forecasting
AUTHORS:
Qizhao Chen
KEYWORDS:
Financial Time Series Forecasting, Anomaly Detection, Isolation Forest, Rolling Z-Score, Transformer
JOURNAL NAME:
Journal of Computer and Communications,
Vol.13 No.12,
December
22,
2025
ABSTRACT: This study investigates whether anomaly-aware modeling can improve stock price forecasting by incorporating signals that highlight unusual market behavior. Financial time series often contain sudden jumps, heavy tails, and irregular movements that challenge standard neural models. To address this issue, an Anomaly-Aware Transformer (AAT) is developed by combining two unsupervised anomaly detection methods—Isolation Forest and a rolling Z-score filter—to identify periods of abnormal volatility. These anomaly flags are then added as auxiliary inputs to a Transformer model and used to guide the attention mechanism toward market conditions that deviate from typical patterns. The performance of the AAT is evaluated on twenty large companies from different industries and compared with a standard Transformer baseline. Results show that while the baseline model performs better on normal trading days, the AAT provides clear advantages for several stocks during anomalous periods, especially when the abnormal movements follow detectable structures. The overall findings suggest that anomaly-aware information can enhance robustness under extreme market conditions, although the benefits depend on the volatility profile of individual assets. This highlights the potential of integrating anomaly detection with deep learning for financial forecasting and points to future directions such as adaptive state-dependent models and hybrid anomaly handling strategies.