Stock Selection via Spatiotemporal Hypergraph Attention Network: A Learning to Rank Approach

Ramit Sawhney, Shivam Agarwal, Arnav Wadhwa, Tyler Derr, Rajiv Ratn Shah

Abstract

Predicting stock market movements is a complex task often hindered by the "random walk" nature of price data. Traditional models focus on pointwise regression or classification, often overlooking the relative ranking of stocks and the higher-order relationships between them. This paper introduces STHAN-SR, a SpatioTemporal Hypergraph Attention Network that reformulates stock selection as a learning-to-rank problem. By leveraging hypergraphs to model multi-stock dependencies and a Hawkes process-based attention mechanism for temporal dynamics, STHAN-SR achieves superior risk-adjusted returns across major global exchanges.

Introduction: Beyond Pairwise Relationships

Most modern neural stock predictors suffer from two primary limitations. First, they often optimize for price accuracy (regression) or direction (classification), creating a "profit-precision gap" where high accuracy on low-volatility stocks yields less profit than identifying high-growth opportunities. Second, existing graph-based models typically rely on pairwise relationships, failing to capture the collective movement of entire industries or corporate groups.

Conceptualizing stock relationships as hyperedges, where groups of stocks move in clusters based on industry or ownership.

As shown in Figure 1, market relations are inherently higher-order. For instance, the travel industry during a global event or a parent company like Berkshire Hathaway influencing multiple subsidiaries simultaneously represents a "hyperedge" rather than a simple link between two nodes. STHAN-SR addresses this by using hypergraphs to preserve the collective synergy of these groups.

Methodology: The STHAN-SR Framework

The proposed STHAN-SR model integrates spatial and temporal modeling into a unified ranking framework. The architecture consists of three key components:

  1. Temporal Hawkes Attention: Unlike standard attention mechanisms that treat time steps independently, STHAN-SR employs a Hawkes process. This mathematical model captures the "excitation" of market events, allowing the model to account for how a price shock on one day continues to influence subsequent days with a decaying effect.
  2. Hypergraph Construction: The model builds hyperedges using industry sectors (GICS) and corporate relations mined from Wikidata (e.g., ownership and shared leadership).
  3. Spatial Hypergraph Attention (HAT): An attention mechanism weights the importance of different hyperedges, identifying which relationships (e.g., subsidiary status vs. broad sector) are currently driving a stock's price.
The STHAN-SR architecture, integrating Hawkes Attention for temporal feature extraction and Hypergraph Learning for spatial stock ranking.

The model is trained using a hybrid loss function that combines pointwise regression with a pairwise ranking loss, ensuring the model prioritizes the relative order of top-performing stocks rather than just absolute price values.

Experimental Evaluation

The model was evaluated on six years of data (2013–2020) from three major global markets: the NASDAQ (1,026 stocks), the NYSE (1,737 stocks), and the Tokyo Stock Exchange (TSE) (95 stocks). STHAN-SR consistently outperformed state-of-the-art baselines, including GCNs, LSTMs, and Reinforcement Learning agents.

Key Results

  • Risk-Adjusted Returns: On the NASDAQ, STHAN-SR achieved a Sharpe Ratio of 1.42, significantly higher than the next best state-of-the-art model (RSR-I at 1.34).
  • Profitability: The model delivered an Internal Rate of Return (IRR) of 0.44 on NASDAQ and 0.62 on the TSE, nearly doubling the performance of many traditional deep learning baselines.
  • Ablation Success: Removing either the hypergraph component or the Hawkes attention led to a significant drop in ranking performance (NDCG), confirming that both spatial relationships and temporal event decay are critical for accurate selection.

Conclusion

STHAN-SR demonstrates that treating stock selection as a ranking problem on spatiotemporal hypergraphs is a highly effective strategy for quantitative trading. By capturing higher-order relationships and the "memory" of market events, the model bridges the gap between raw price prediction and profitable portfolio management. Future work may explore time-evolving hypergraphs and the integration of unstructured data like news sentiment to further refine the "excitation" modeling.

Summary updated

BibTeX
@inproceedings{sawhney2021stock,
  author = {Ramit Sawhney and Shivam Agarwal and Arnav Wadhwa and Tyler Derr and Rajiv Ratn Shah},
  title = {{Stock Selection via Spatiotemporal Hypergraph Attention Network: A Learning to Rank Approach}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i1.16127},
}
Figure