Introduction
Stock market forecasting remains one of the most challenging tasks in financial modeling due to the inherent volatility, noise, and non-stationary nature of global markets. While deep learning architectures, particularly Transformers, have demonstrated remarkable success in sequence modeling, their performance is heavily dependent on large-scale datasets. In the financial sector, individual institutions often face "data scarcity" for specific assets and are constrained by privacy and regulatory requirements that prevent the sharing of raw proprietary trading data.
This paper proposes a novel framework that integrates the sequence-modeling capabilities of Transformers with Attentive Federated Aggregation (FedAtt). This approach enables collaborative model training across distributed datasets from multiple enterprises without compromising data privacy, effectively addressing the limitations of isolated local training.
Methodology
The proposed architecture is built upon three primary components designed to handle the complexities of financial time series:
- Time2Vec Embeddings: Standard Transformers are permutation-invariant and lack an inherent understanding of chronological order. To provide temporal awareness, the authors utilize Time2Vec, which represents time as a vector containing both periodic (cyclic) and non-periodic (linear) components. This ensures the model captures both seasonal trends and long-term price trajectories.
- Transformer Encoder: The core of the model is a Transformer encoder utilizing a 12-head multi-attention mechanism. This allows the system to simultaneously analyze various patterns within a 16-day look-back window, identifying complex relationships between price movements and trading volumes.
- Attentive Federated Aggregation (FedAtt): In traditional Federated Learning (FedAvg), a central server simply averages the weights of local models. The authors introduce FedAtt, which employs an attention mechanism to calculate "importance weights" for each client. By prioritizing updates from clients whose local parameters align more closely with the global model, FedAtt filters out noise and better manages the heterogeneity of different stocks.
Data and Preprocessing
The researchers evaluated the framework using historical data for 45 global enterprises sourced from Yahoo! Finance. The dataset included six primary features: Date, Volume, Open, High, Low, and Close. The diversity of the data was a key factor, ranging from long-standing stocks like IBM (dating back to 1962) to more recent entries like Meta (dating back to 2012).
To make this non-stationary data suitable for deep learning, the authors converted raw prices and volumes into daily stock returns and volume changes. Additionally, moving average smoothing was applied to reduce high-frequency noise while preserving significant market signals.
Results and Discussion
The experimental results demonstrate that the FedAtt scheme consistently outperforms both decentralized local training (SOLO) and standard Federated Averaging (FedAvg) across Mean Squared Error (MSE), Mean Absolute Error (MAE), and Mean Absolute Percentage Error (MAPE) metrics.
- Mitigating Data Scarcity: The benefits were most pronounced for "data-poor" clients. For Meta (META), FedAtt achieved an MSE of 0.0041, a significant improvement over the 0.0103 achieved by SOLO training. This confirms that younger companies can benefit from the patterns learned by more established stocks through federated collaboration.
- Performance Stability: For well-established stocks like IBM, FedAtt maintained a competitive edge, proving that the attentive aggregation mechanism does not degrade performance even when local data is abundant.
- Heterogeneity Management: The shift from simple averaging to attentive aggregation is crucial. Because different sectors (e.g., tech vs. utilities) exhibit distinct behaviors, FedAtt allows the global model to "tune in" to the most relevant updates, preventing important signals from being washed out by simple averaging.
Conclusion and Future Work
This research highlights the power of combining Transformers with privacy-preserving federated learning for financial forecasting. While the results are promising, future research is needed to address the communication overhead associated with large Transformer weight matrices and to improve adversarial robustness against potential "poisoning attacks" in federated networks. The authors suggest this architecture could be extended to other sensitive time-series domains, such as healthcare and patient monitoring.
Summary updated