MASTER: Market-Guided Stock Transformer for Stock Price Forecasting

Tong Li, Zhaoyang Liu, Yanyan Shen, Xue Wang, Haokun Chen, Sen Huang

TL;DR

MASTER (MArkert-Guided Stock TransformER) is a novel forecasting architecture that captures the "momentary" and "cross-time" correlations between stocks—recognizing that different companies often react to the same market events with varying delays. By integrating macro-market signals to automatically weight input features, MASTER achieves a 47% improvement in portfolio returns compared to existing state-of-the-art models.

What Problem Does This Paper Address?

Predicting stock prices is notoriously difficult because markets are non-stationary and highly interconnected. Most existing deep learning models for finance suffer from two major blind spots:

  1. Time-Aligned Bias: Current models usually assume that if Stock A and Stock B are correlated, they move together at the exact same timestamp. In reality, correlations are often "cross-time"—an event might affect a raw material supplier today, but its downstream customer only feels the impact three days later (a lead-lag effect).
  2. Static Feature Importance: Traditional models treat input features (like moving averages or volatility) with the same weight regardless of market conditions. However, a feature that is highly predictive during a "bull market" might be complete noise during a "bear market."

The authors aim to bridge these gaps by creating a model that understands both the shifting importance of features and the complex, time-lagged relationships between different stocks.

Methods

The MASTER framework consists of a five-step pipeline designed to break down the massive complexity of the stock market into manageable computations:

  • Market-Guided Gating: Before any time-series analysis happens, the model looks at "Market Status" (index prices and trading volumes). It uses a gating mechanism to rescale input features, effectively performing automated feature selection based on whether the market is volatile, stable, or trending.
  • Intra-Stock Aggregation: The model uses a Transformer encoder to look at the historical sequence of a single stock. This captures local temporal patterns (like momentum) while preserving time-specific details.
  • Inter-Stock Aggregation: This is the core innovation. At each time step, the model calculates correlations across the entire universe of stocks. Because this happens after the intra-stock step, information from a previous time step in Stock A can "flow" into the current representation of Stock B, capturing those elusive cross-time dependencies.
  • Temporal Aggregation: It uses an attention-based pooling layer to summarize the sequence of embeddings into one comprehensive vector for each stock.
  • Prediction: A final linear layer predicts the normalized return ratio.

By alternating between "time" (intra-stock) and "space" (inter-stock), the model reduces computational complexity from $O((T \times N)^2)$ to $O(N^2T)$, making it feasible to train on hundreds of stocks simultaneously.

Datasets

The researchers evaluated MASTER on two major benchmarks from the Chinese stock market:

  • CSI300: Represents the 300 largest and most liquid stocks on the Shanghai and Shenzhen exchanges.
  • CSI800: A broader index containing 800 stocks, offering a more complex and "noisier" environment for testing.

They used data spanning from 2008 to 2022, utilizing the Alpha158 indicator set (a collection of 158 technical financial indicators) as the raw input features.

Key Insights and Ideas

  • The "Momentary" Nature of Correlation: The authors visualize their attention maps to show that stock correlations aren't "neat strips" that last forever. Instead, they are sparse and scattered. MASTER is designed to "pick up" these fleeting connections that traditional static graph models miss.
  • Lead-Lag Discovery: The "cross-time" correlation discovery is a standout feature. The model doesn't need to be told which stocks are upstream or downstream; it learns these dependencies purely from the data by observing how signals propagate through the intra- and inter-stock layers.
  • Contextual Feature Selection: The gating mechanism acts like a "dimmer switch" for data. If the market index suggests high volatility, the model might "turn up" the volume on risk-related features and "turn down" the volume on long-term trend indicators.

Key Results

MASTER was compared against a battery of baselines, including XGBoost, LSTMs, and specialized financial models like DTML and GAT.

  • Ranking Performance: MASTER achieved the highest Information Coefficient (IC) and RankIC, which measure how well the model's predicted rankings align with actual market performance. It showed a ~13% improvement over the next best models.
  • Profitability (The Bottom Line): In backtesting a "Top 30" trading strategy, MASTER achieved an Annualized Return (AR) of 27% on the CSI300 and 28% on the CSI800. This represented a 47% improvement in portfolio-based metrics over previous state-of-the-art methods.
  • Risk-Adjusted Return: The model also led in Information Ratio (IR), suggesting that its gains weren't just the result of taking on more risk, but rather more accurate signal detection.

Limitations and Future Work

  • Computational Scaling: While more efficient than a "naive" Transformer, the $O(N^2)$ complexity relative to the number of stocks ($N$) still poses a challenge for scaling to entire markets (like the 5,000+ stocks in the US market).
  • Data Hunger: The authors note that stock forecasting is "intense in data hunger." With only ~250 trading days a year, the model has a limited number of samples to learn high-dimensional correlations.
  • Future Directions: The team suggests exploring more granular market information (like order book data) and investigating how these learned correlations might be used for risk management or portfolio optimization beyond just price prediction.

Summary updated

BibTeX
@inproceedings{li2024master,
  author = {Tong Li and Zhaoyang Liu and Yanyan Shen and Xue Wang and Haokun Chen and Sen Huang},
  title = {{MASTER: Market-Guided Stock Transformer for Stock Price Forecasting}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  doi = {10.1609/aaai.v38i1.27767},
}
Figure