[Paper Review] MASTER: Market-Guided Stock Transformer for Stock Price Forecasting
MASTER proposes a market-guided stock transformer that models momentary, cross-time stock correlations through alternating intra-stock and inter-stock attention, while using a market-aware gating mechanism for dynamic feature selection. It achieves 13% average improvement in ranking metrics and 47% in portfolio-based metrics on Chinese stock datasets, outperforming prior methods in capturing realistic, time-varying stock relationships.
Stock price forecasting has remained an extremely challenging problem for many decades due to the high volatility of the stock market. Recent efforts have been devoted to modeling complex stock correlations toward joint stock price forecasting. Existing works share a common neural architecture that learns temporal patterns from individual stock series and then mixes up temporal representations to establish stock correlations. However, they only consider time-aligned stock correlations stemming from all the input stock features, which suffer from two limitations. First, stock correlations often occur momentarily and in a cross-time manner. Second, the feature effectiveness is dynamic with market variation, which affects both the stock sequential patterns and their correlations. To address the limitations, this paper introduces MASTER, a MArkert-Guided Stock TransformER, which models the momentary and cross-time stock correlation and leverages market information for automatic feature selection. MASTER elegantly tackles the complex stock correlation by alternatively engaging in intra-stock and inter-stock information aggregation. Experiments show the superiority of MASTER compared with previous works and visualize the captured realistic stock correlation to provide valuable insights.
Motivation & Objective
- To address the limitations of existing stock price forecasting models that fail to capture momentary and cross-time stock correlations due to fixed attention fields and static feature weighting.
- To model dynamic stock correlations that occur at misaligned time steps and vary with market conditions, rather than assuming static or time-aligned relationships.
- To reduce computational burden and improve optimization in data-scarce stock forecasting by avoiding full $τ \times |\mathcal{S}|$ attention fields while preserving correlation expressiveness.
- To automate feature selection using market context, reducing reliance on manual feature engineering and improving model adaptability to changing market regimes.
- To provide a more realistic and granular view of stock correlations through attention visualization, revealing asymmetric, time-shifted, and sparse inter-stock relationships.
Proposed method
- Introduces a five-stage architecture: market-guided gating, intra-stock aggregation, inter-stock aggregation, temporal aggregation, and prediction, enabling dynamic correlation modeling.
- Uses a novel gating mechanism that leverages market state embeddings to perform adaptive, attention-based feature selection, with learnable temperature hyperparameter $β$ controlling selection sharpness.
- Alternates between intra-stock self-attention (within each stock's sequence) and inter-stock cross-attention (across stocks at the same time step) to model both sequential patterns and cross-stock dependencies.
- Avoids full $τ \times |\mathcal{S}|$ attention by structuring aggregation in a hierarchical, alternating manner, reducing computational cost while preserving momentary and cross-time correlation modeling.
- Employs a multi-head attention mechanism with scaled dot-product attention for both intra- and inter-stock stages, with residual connections and layer normalization for stability.
- Uses a learnable query projection for inter-stock attention, where the query is derived from the current time step's representation, enabling dynamic correlation discovery across time and stocks.

Experimental results
Research questions
- RQ1How can stock price forecasting models better capture momentary and cross-time stock correlations that are not aligned in time?
- RQ2Can a transformer-based architecture model dynamic stock correlations more effectively than static or time-aligned correlation graphs?
- RQ3How does market context influence the effectiveness of different stock features, and can this be modeled automatically?
- RQ4Does a hierarchical, alternating attention mechanism outperform full-attention or clustering-based approximations in data-scarce stock forecasting?
- RQ5Can attention visualization reveal realistic, asymmetric, and time-shifted stock correlations that are missed by prior methods?
Key findings
- MASTER achieves an average 13% improvement in ranking metrics (e.g., Spearman’s rho) across multiple benchmarks compared to state-of-the-art baselines on Chinese stock datasets.
- On portfolio-based metrics, MASTER improves performance by 47% compared to baselines, demonstrating strong practical value in real investment scenarios.
- Ablation studies show that the alternating intra- and inter-stock aggregation mechanism consistently outperforms naive attention and clustering-based approximations, even with limited data.
- Visualization of attention maps confirms that correlations are momentary, sparse, and asymmetric, with strong evidence of cross-time alignment (e.g., not centered on diagonal) and time-shifted responses.
- The optimal temperature $β$ in the gating mechanism is smaller for more complex datasets like CSI800, indicating stronger feature selection is needed in volatile markets.
- The model’s attention maps reveal that correlations change slowly over time, with similar correlation patterns persisting across different prediction dates when aligned to the same absolute time window.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.