STN-TGAT: Top-K Portfolio Construction via Prior-Guided Graph Attention with Learnable Soft-Threshold Sparsification


Abstract

This paper tackles the problem of stock ranking and portfolio construction under realistic investment settings by jointly modeling temporal dynamics and cross-sectional dependencies. We propose the Soft-Threshold NMI-prior Transformer Graph Attention Network (STN-TGAT), which integrates a temporal Transformer with a Graph Attention Network to capture long-horizon sequential patterns and dynamic inter-stock relationships. An NMI-based prior graph combined with a soft-threshold sparsification mechanism enhances structural robustness by mitigating noisy correlations while preserving informative connections. The portfolio formation process incorporates practical considerations, including Top-5 selection within the Top-50 \(S\&P\) 500 constituents, explicit weight allocation, and transaction cost adjustment, thereby aligning the evaluation with real-world trading conditions. Empirical results on real-world data demonstrate that STN-TGAT consistently outperforms benchmark models from predictive accuracy and investment profitability measured by portfolio returns. These findings suggest that combining decision-aligned training with adaptive relational modeling provides a coherent and practically effective framework for data-driven portfolio construction.

1 Introduction↩︎

Equity portfolio construction in quantitative asset management is naturally formulated as a repeated Top-\(K\) selection problem. On each trading day, an investable universe is ranked and capital is allocated to a small subset of the highest-ranked assets under practical constraints such as transaction costs and position limits. In this decision-centric setting, minimizing prediction error alone is insufficient; the primary objective is achieving reliable ranking performance at the top of the list, as these assets determine realized portfolio returns.

Daily financial markets present substantial challenges, including noise, nonlinear dynamics, volatility clustering, and regime shifts. Traditional econometric models such as ARIMA and GARCH capture autoregressive structure and conditional heteroskedasticity [1], but rely on linear assumptions that limit their ability to represent complex market dependencies [2]. Deep learning architectures, including LSTM and GRU, improve temporal representation by modeling longer horizons [3]. However, many temporal approaches treat each stock independently, overlooking cross-sectional dependencies induced by sector exposure, style factors, and shared macroeconomic shocks [4].

Graph Neural Networks (GNNs) provide a natural mechanism to incorporate such relationships by representing stocks as nodes and dependencies as edges. Hybrid architectures combining Transformers with Graph Attention Networks (GATs) aim to jointly model temporal dynamics and relational structure. Yet, their effectiveness depends critically on graph construction. Dense graphs may propagate noise, while overly sparse or heuristically thresholded graphs risk discarding informative dependencies. These challenges motivate adaptive mechanisms for learning structured cross-sectional relationships.

To address these challenges, we propose Soft-Thresholded NMI-prior Transformer Graph Attention Network (STN-TGAT), a decision-oriented framework that integrates self-attention-based temporal modeling with adaptive graph learning. Instead of predicting absolute returns, the model directly learns to rank stocks by relative performance, aligning the learning objective with daily portfolio construction where only the top candidates are selected. The framework includes two key components. First, we introduce a top-weighted ListNet ranking objective that emphasizes ordering accuracy among the top predictions, reflecting the practical importance of top-ranked assets in a Top-\(K\) selection strategy. Second, we incorporate an information-theoretic relational prior based on Normalized Mutual Information (NMI) and apply a learnable soft-threshold sparsification mechanism to adaptively control graph density. This design aims to suppress noisy relations while preserving informative co-movement structures.

This paper makes three contributions:

  1. We formulate daily equity selection as a Top-\(K\) ranking problem aligned with portfolio construction and introduce a top-weighted ListNet objective that emphasizes accuracy among the highest-ranked assets.

  2. We develop a prior-guided adaptive graph that integrates an NMI-based relational prior with learnable soft-threshold sparsification to refine cross-sectional dependency modeling.

  3. We conduct evaluation using both ranking metrics and realistic net-of-fee portfolio backtesting with transaction costs, linking predictive performance to economically meaningful outcomes.

2 Related Work↩︎

2.1 Time-series modeling for financial prediction↩︎

Early financial forecasting studies relied on statistical models such as ARIMA and GARCH to capture autoregressive dynamics and volatility patterns in financial time series [5]. Although effective for short-term dynamics, these models rely largely on linear assumptions and struggle to represent the nonlinear and regime-dependent behavior of modern markets. Classical machine learning approaches, including Support Vector Machines (SVMs) and Random Forests (RFs), were later introduced to incorporate richer feature representations [6][8]. However, these methods often ignore long-range temporal dependencies and remain sensitive to non-stationarity [1].

Deep learning models have substantially improved temporal representation learning. Recurrent architectures such as LSTM and GRU capture multi-horizon dependencies in financial sequences [5], [9], while hybrid architectures combine convolutional layers, recurrent networks, and attention mechanisms to extract both local patterns and long-term dynamics [10][12]. More recently, Transformer-based models have gained prominence for their ability to model long-range dependencies through self-attention [13], with extensions including hierarchical or frequency-aware variants [14], [15]. Nevertheless, most existing approaches emphasize pointwise prediction accuracy rather than the relative ranking and Top-\(K\) selection required in practical portfolio construction.

2.2 Graph neural networks for cross-sectional dependency learning↩︎

Graph neural networks (GNNs) provide a natural framework for modeling cross-sectional dependencies among stocks [16]. By representing equities as nodes and their relationships as edges, GNNs enable information propagation across related assets. Early studies used static graphs combined with graph convolution to capture stable relationships such as sector membership or persistent co-movement [4]. However, static graph structures often fail to reflect the evolving dependencies and regime shifts common in financial markets.

To improve flexibility, attention-based GNNs dynamically learn neighbor importance and can be integrated with temporal encoders. For example, RA-GAT combines LSTM-based temporal representations with graph attention to model inter-stock relationships [9], while other spatio-temporal architectures jointly learn temporal and relational signals for stock prediction or ranking tasks [17], [18]. Extensions such as multi-graph models and dynamic graph learning further capture heterogeneous relations or evolving network structures [19][23]. These studies demonstrate the value of relational modeling, while also highlighting the sensitivity of GNN performance to the quality and sparsity of the underlying graph.

2.3 Dependence measures and graph construction↩︎

A key step in graph-based financial modeling is defining meaningful inter-stock dependencies [16]. Linear correlation measures such as Pearson correlation are widely used due to their simplicity [24], [25], while rank-based statistics like Spearman or Kendall correlations improve robustness under non-Gaussian distributions [26]. To capture nonlinear relationships, alternative measures including distance correlation, normalized mutual information (NMI), and detrended cross-correlation analysis have been explored [9], [27], [28]. However, these measures typically produce dense dependency matrices that require additional sparsification.

Various filtering techniques, such as dynamic thresholding or minimal spanning tree structures, have been used to extract informative graph topology [24], [29]. Nevertheless, heuristic sparsification strategies may be unstable under regime shifts and may not align well with downstream learning objectives. Motivated by these limitations, our work combines an NMI-based dependence prior with a learnable soft-threshold sparsification mechanism and integrates it with attention-based temporal encoding, enabling adaptive cross-sectional dependency modeling aligned with Top-\(K\) portfolio selection.

3 Task Formulation↩︎

We formulate daily equity selection as a cross-sectional Top-\(K\) ranking problem. For each trading day, we observe standardized input features for \(N\) stocks over a lookback window of length \(L\), denoted by \(\mathbf{X} \in \mathbb{R}^{N \times L \times F}\), where \(F\) is the feature dimension. The \(i\)-th stock’s temporal features are given by \(\mathbf{X}_i \in \mathbb{R}^{L \times F}\). 1

The model maps \(\mathbf{X}\) to stock-level scores \(\mathbf{s} = (s_1, \dots, s_N) \in \mathbb{R}^N\), where each \(s_i\) is produced by the spatio-temporal encoder and prediction head. These scores induce a ranking over the cross-section. Let \(y_i\) denote the realized next-day log return of stock \(i\) and let \(\mathbf{y}^{\mathrm{rank}}\) denote the cross-sectionally standardized returns used as ranking targets. 2 Portfolio construction selects the Top-\(K\) stocks according to predicted scores, \[\mathcal{S} = \operatorname{TopK}(\mathbf{s}, K),\] and allocates capital within \(\mathcal{S}\) under transaction cost and rebalancing constraints. Therefore, the learning objective emphasizes ranking consistency particularly in the upper portion of the cross-section—while optionally preserving return magnitude information for allocation.

4 Methodology↩︎

4.1 Framework Overview↩︎

The proposed Soft-Thresholded NMI-prior Transformer Graph Attention Network (STN-TGAT) jointly models temporal dynamics and cross-sectional dependencies for Top-\(K\) equity selection. A Transformer-based encoder extracts long-range sequential patterns from historical features and produces stock embeddings via attention pooling. These embeddings are refined through a Graph Attention Network guided by an NMI-based prior with learnable soft-threshold sparsification to adaptively control relational structure. Finally, a shared prediction head produces stock-level scores that are optimized using a head-weighted listwise ranking loss, optionally combined with a regression term to preserve magnitude information. During inference, stocks are ranked by predicted scores, and the top-\(K\) assets are selected to form the portfolio under transaction cost adjustments. This design jointly integrates temporal modeling, adaptive relational learning, and decision-aligned optimization for practical Top-\(K\) portfolio construction. For clarity, key notations used throughout the methodology are summarized in Appendix.

4.2 Temporal Encoding↩︎

Given the input tensor \(\mathbf{X} \in \mathbb{R}^{N \times L \times F}\) defined in the task formulation, we encode each stock’s lookback sequence using an encoder-only Transformer [30]. A linear projection is first applied along the feature dimension independently for each stock and time step: \[\bar{\mathbf{X}} = \mathbf{X}\mathbf{W}^{(I)} + \mathbf{PE},\] where \(\mathbf{W}^{(I)}\in\mathbb{R}^{F\times d}\) is a learnable projection matrix. The sinusoidal positional encodings \(\mathbf{PE}\in\mathbb{R}^{L\times d}\) are shared across stocks and added along the temporal dimension. The resulting representations are processed by a standard Transformer encoder, producing hidden states \(\mathbf{H}\in\mathbb{R}^{N\times L\times d}\).

To obtain a fixed-dimensional representation for each stock, we apply attention-based temporal pooling. Let \(\mathbf{h}_t\in\mathbb{R}^{d}\) denote the hidden state at time step \(t\) (\(t = 1, \dots, L\) indexes the lookback window). With a learnable query vector \(\mathbf{q}\in\mathbb{R}^{d}\), the attention weights are computed as \[a_t = \frac{ \exp\left( \langle \mathbf{h}_t, \mathbf{q} \rangle \right) }{ \sum_{k=1}^{L} \exp\left( \langle \mathbf{h}_k, \mathbf{q} \rangle \right) }, \qquad \mathbf{z} = \sum_{t=1}^{L} a_t \mathbf{h}_t \in \mathbb{R}^{d}.\] Applying this pooling independently to each stock yields the cross-sectional daily representation \(\mathbf{Z}\in\mathbb{R}^{N\times d}\), which serves as node features for the downstream graph module.

4.3 Spatial Encoding↩︎

4.3.1 NMI-based Dependence Graph with Learnable Soft-Thresholding↩︎

Following [9], we construct a cross-sectional dependence graph from daily log-returns using Normalized Mutual Information (NMI), which captures nonlinear co-movement beyond linear correlation. Let \(r_i=\{\Delta\log P_{t,i}\}_{t=1}^{T}\) denote the training-window return series of stock \(i\) and \(P_{t,i}\) denotes the adjusted closing price of stock \(i\) on day \(t\). Mutual information is estimated using histogram-based equal-width binning with \(k_b\) bins to obtain empirical marginal and joint distributions. The normalized mutual information between stocks \(i\) and \(j\) is computed as \[\mathrm{NMI}(r_i,r_j) = \frac{2\,I(r_i;r_j)}{H(r_i)+H(r_j)} \in [0,1],\] where \(I(\cdot;\cdot)\) and \(H(\cdot)\) denote the histogram-based estimates of mutual information and Shannon entropy, respectively. This yields a dense adjacency matrix \(\mathbf{A}_0 \in \mathbb{R}^{N\times N}\) \[(\mathbf{A}_0)_{ij} = \mathrm{NMI}(r_i,r_j), .\]

Dense connectivity may increase the risk of over-smoothing during repeated neighborhood aggregation. To address this, we introduce a differentiable gating mechanism that adaptively attenuates weak edges. Specifically, we define a gate matrix \(\mathbf{G}=[g_{ij}] \in (0,1)^{N\times N}\) as \[g_{ij} = \sigma\!\left(\beta\big((\mathbf{A}_0)_{ij}-t_g\big)\right),\] where \(\sigma(\cdot)\) denotes the sigmoid function, \(\beta>0\) controls the sharpness of the transition, larger values make the gating function approximate a hard threshold, while smaller values yield smoother attenuation. \(t_g\in(0,1)\) is a learnable threshold parameterized. The sparsified adjacency is obtained via element-wise modulation \(\mathbf{A}_\phi = \mathbf{A}_0 \odot \mathbf{G}\). Edges with weights below \(t_g\) are smoothly suppressed, while stronger connections are largely preserved. The threshold parameter is learned jointly with the overall training objective.

To preserve symmetry and stabilize scale, we symmetrize the learned adjacency as \(\mathbf{A}_\phi \leftarrow \tfrac{1}{2}\big(\mathbf{A}_\phi + \mathbf{A}_\phi^\top\big),\) followed by global max-scaling, \(\mathbf{A}_\phi \leftarrow \mathbf{A}_\phi / \max_{i,j} (\mathbf{A}_\phi)_{ij},\) ensuring \(\mathbf{A}_\phi \in [0,1]^{N\times N}\). A small diagonal shift \(\mathbf{A}_\phi \leftarrow \mathbf{A}_\phi + \delta \mathbf{I}\) is added to guarantee self-connections and avoid empty-neighborhood cases. The resulting adjacency \(\mathbf{A}_\phi\) is used in the subsequent Graph Attention Network to guide spatial aggregation according to the learned relational structure.

4.3.2 GAT with NMI Prior↩︎

Given the cross-sectional embeddings \(\mathbf{Z}\in\mathbb{R}^{N\times d}\) from the temporal encoder, we apply a multi-head Graph Attention Network (GAT) [31] to model inter-stock dependencies. The learned sparsified adjacency \(\mathbf{A}_\phi\) defines the graph structure. For computational efficiency, each node \(i\) aggregates information from its \(K_{\text{nbr}}\) strongest neighbors under \(\mathbf{A}_\phi\), denoted by \(\mathcal{N}(i)\).

Let \(\mathbf{H}^{(0)}=\mathbf{Z}\). For GAT layer \(\ell\) and attention head \(h\), we compute head-specific projections \[\mathbf{H}^{(\ell,h)}=\mathbf{H}^{(\ell)} \mathbf{W}^{(\ell,h)},\] where \(\mathbf{W}^{(\ell,h)}\in\mathbb{R}^{d\times d_h}\) are learnable parameters applied independently to each node representation.

Unlike standard GAT, we inject the NMI-based structural prior into the attention logits. For \(j\in\mathcal{N}(i)\), \[e^{(\ell,h)}_{ij} = \frac{\mathrm{LeakyReLU}\!\left( \mathbf{a}^{(\ell,h)\top} [\mathbf{H}^{(\ell,h)}_i \,\|\, \mathbf{H}^{(\ell,h)}_j] \right)}{\tau_{\text{a}}} + \lambda \log\!\left((\mathbf{A}_\phi)_{ij}+\varepsilon\right),\] where \(\mathbf{a}^{(\ell,h)}\in\mathbb{R}^{2d_h}\) is learnable, \(\tau_{\text{a}}>0\) controls attention sharpness, and \(\varepsilon>0\) ensures numerical stability. The first term captures data-driven feature compatibility, while the second term biases attention toward edges supported by the structural prior. The prior strength is controlled by \(\lambda \in (0,1)\).

Attention weights are obtained via softmax over \(\mathcal{N}(i)\): \[\alpha^{(\ell,h)}_{ij} = \frac{\exp(e^{(\ell,h)}_{ij})}{\sum_{k\in\mathcal{N}(i)} \exp(e^{(\ell,h)}_{ik})}.\]

Node representations are updated using standard multi-head aggregation [31], followed by residual connections and layer normalization. After \(L_g\) layers, we obtain \(\mathbf{H}^{(L_g)}\in\mathbb{R}^{N\times d}\). A linear prediction head is applied to each node representation: \[s_i = \mathbf{w}_{\text{out}}^\top \mathbf{H}^{(L_g)}_i + b, \qquad \mathbf{s}\in\mathbb{R}^{N}, \label{eq:score95head}\tag{1}\] where \(\mathbf{w}_{\text{out}}\in\mathbb{R}^{d}\) and \(b\in\mathbb{R}\) are learnable parameters shared across stocks.

4.4 Loss Function↩︎

To align model training with downstream Top-\(K\) portfolio construction, we optimize a composite objective consisting of three components: (i) a head-weighted listwise ranking loss, (ii) an auxiliary regression loss, and (iii) graph sparsity regularization. Direct optimization of portfolio utility is non-differentiable and unstable due to discrete Top-\(K\) selection and transaction costs; therefore, we adopt differentiable ranking-based surrogates that approximate the decision structure while preserving tractability.

4.4.0.1 Head-Weighted ListNet Objective.

Let \(\mathbf{s}\in\mathbb{R}^N\) denote predicted stock scores, and let \(\mathbf{y}^{\mathrm{rank}}\in\mathbb{R}^N\) denote cross-sectionally standardized next-period returns used as ranking targets.

Following ListNet, we define the student and teacher distributions: \[P_i = \frac{\exp(s_i)}{\sum_{j=1}^{N}\exp(s_j)}, \qquad Q_i = \frac{\exp(y^{\mathrm{rank}}_i / \tau_{\mathrm{rank}})}{\sum_{j=1}^{N}\exp(y^{\mathrm{rank}}_j / \tau_{\mathrm{rank}})},\] where \(\tau_{\mathrm{rank}}>0\) controls teacher sharpness. Cross-sectional standardization stabilizes numerical scaling.

Standard ListNet minimizes \(\mathrm{KL}(Q\|P)\), aligning full ranking distributions. However, portfolio construction depends primarily on the highest-ranked assets. Let \(\mathrm{pos}(i)\) denote the rank position of stock \(i\) under the teacher distribution \(Q\) (sorted in descending order). To emphasize accuracy in higher-ranked positions while preserving smooth gradients, we introduce geometrically decaying weights: \[w_i = \frac{\max\!\left(\gamma^{\mathrm{pos}(i)},\, w_{\min}\right)}{\sum_{j=1}^{N} \max\!\left(\gamma^{\mathrm{pos}(j)},\, w_{\min}\right)},\] where \(\gamma\in(0,1)\) controls decay and \(w_{\min}>0\) prevents vanishing gradients in lower-ranked positions. Geometric decay provides a smooth approximation to Top-\(K\) emphasis without introducing discontinuities. The resulting weighted KL objective is \[\mathcal{L}_{\mathrm{list}} = \sum_{i=1}^{N} w_i Q_i \bigl(\log Q_i - \log P_i\bigr).\] This formulation prioritizes ranking precision in the head of the distribution while maintaining global consistency.

4.4.0.2 Auxiliary Regression Loss.

To retain return magnitude information and reduce scale ambiguity under purely ranking-based optimization, we incorporate a pointwise regression term: \[\mathcal{L}_{\mathrm{mse}} = \frac{1}{N}\sum_{i=1}^{N}(s_i - y_i)^2,\] where \(y_i\) denotes realized next-period return. While \(\mathcal{L}_{\mathrm{list}}\) governs cross-sectional ordering, \(\mathcal{L}_{\mathrm{mse}}\) anchors score magnitudes to observed returns, improving numerical stability and supporting score-based allocation.

4.4.0.3 Graph Sparsity Regularization.

Let \(\mathbf{A}_\phi \in \mathbb{R}^{N \times N}\) denote the learned sparsified adjacency matrix, where \((A_\phi)_{ij} = (A_0)_{ij} g_{ij}\) and \(g_{ij} \in (0,1)\) are the learnable gating coefficients. Although the NMI prior provides an information-theoretic initialization, unconstrained optimization may lead to overly dense connectivity or degenerate solutions in which most gates saturate toward 0 or 1. Such behavior can increase over-smoothing and reduce structural interpretability.

To encourage stable and well-conditioned graph structure, we introduce a sparsity-aware regularization term consisting of two complementary components \[\mathcal{L}_{\mathrm{graph}} = \frac{1}{N(N-1)} \sum_{i\ne j}(\mathbf{A}_\phi)_{ij} + \left( \frac{1}{N(N-1)} \sum_{i\ne j} g_{ij} - \rho \right)^2,\] where the first term penalizes excessive average edge strength to control global connectivity magnitude and mitigates over-aggregation effects, and the second term constrains the expected gating density toward a target sparsity level \(\rho \in (0,1)\).

The overall objective is \[\mathcal{L}=\mathcal{L}_{\mathrm{list}}+\mathcal{L}_{\mathrm{mse}}+\mathcal{L}_{\mathrm{graph}}.\]

5 Experiments↩︎

5.1 Data preprocessing↩︎

We construct a panel dataset of the 50 largest \(S\&P\) 500 constituents by market capitalization at the start of the sample period to mitigate survivorship bias. The sample covers 752 NYSE trading days from 2022-01-03 to 2024-12-30. Daily OHLCV data are collected from Yahoo Finance and aligned with the NYSE trading calendar.

Features are winsorized at three standard deviations and standardized using training-set statistics to prevent information leakage. The data are split chronologically into training, validation, and test sets (8:1:1). Daily log returns from adjusted closing prices serve as prediction targets: returns are cross-sectionally standardized for ranking, while log returns are used for regression. Standardized features are arranged into rolling windows of length \(L\), forming tensors of shape \([N, L, F]\). For each window ending at time \(t\), the model predicts the return at \(t+1\). Additional preprocessing details are provided in Appendix.

5.2 Baseline Models↩︎

To provide a structured comparison, we adopt baseline models covering classical statistical forecasting, deep sequential encoders, and graph-based spatio-temporal architectures. ARIMA is used as a representative linear time-series benchmark [9], [17], [32]. GRU and LSTM serve as recurrent neural network baselines for nonlinear temporal modeling and are widely used in financial prediction studies [33], [34].

To incorporate cross-sectional dependencies, we further extend the temporal backbone with graph operators. GRU-GCN augments GRU with a graph convolutional layer using the same pre-computed NMI graph to ensure a fair comparison under a shared relational prior. GRU-GAT replaces the GCN layer with graph attention to enable adaptive neighbor weighting and maintain consistency with the GAT operator used in our proposed model. Together, these baselines provide a representative benchmark suite covering major paradigms in recent stock prediction and selection research. Please see the Appendix for implementation details.

5.3 Evaluation↩︎

To evaluate model performance, we consider both predictive accuracy and investment profitability. Ranking quality is evaluated using Mean Reciprocal Rank (MRR), which measures how highly the true top-performing stock appears in the predicted ranking [3], [9], [17]. We also report Rank-Biased Overlap (RBO) to assess the similarity between predicted and ground-truth ranking lists, which is particularly relevant for portfolio construction [35]. In addition, Mean Squared Error (MSE) is included to measure prediction accuracy of return values [3], [9]. To evaluate investment performance, we conduct daily backtesting by constructing a long-only Top-5 portfolio from cross-sectional model scores. Portfolios are rebalanced daily (close-to-close), weighted via softmax allocation, and evaluated using net-of-fee returns with proportional turnover costs. Performance is reported using cumulative return (IRR), annualized Sharpe Ratio, and maximum drawdown (MDD), capturing profitability, risk-adjusted return, and downside risk. Please see the Appendix for implementation details.

Table 1: Performance of STN-TGAT and baseline models. The best results are in bold.Higher is better for MRR, RBO, IRR, and Sharpe; lower is better for MSE and MDD. check the left tables
MODEL ARIMA GRU LSTM GRU-GCN GRU-GAT STN-TGAT
MRR 0.1079 \(\pm\) 0.0000 0.2120 \(\pm\) 0.0059 0.2222 \(\pm\) 0.0119 0.0768 \(\pm\) 0.0332 0.1760 \(\pm\) 0.0127 0.1879 \(\pm\) 0.0345
RBO 0.0316 \(\pm\) 0.0000 0.0580 \(\pm\) 0.0014 0.0601 \(\pm\) 0.0024 0.0193 \(\pm\) 0.0117 0.0468 \(\pm\) 0.0037 0.0509 \(\pm\) 0.0118
MSE 0.0017 \(\pm\) 0.0000 0.5142 \(\pm\) 0.2321 0.2720 \(\pm\) 0.4558 1.0727 \(\pm\) 1.3167 0.5013 \(\pm\) 0.3264 0.3115 \(\pm\) 0.4176
IRR 0.0426 \(\pm\) 0.0000 0.1341 \(\pm\) 0.0359 0.1143 \(\pm\) 0.0377 -0.0435 \(\pm\) 0.0166 -0.0012 \(\pm\) 0.0347 0.1807 \(\pm\) 0.1176
Sharpe 1.1145 \(\pm\) 0.0000 2.6553 \(\pm\) 0.5632 2.1899 \(\pm\) 0.6187 -1.4598 \(\pm\) 0.6272 0.0035 \(\pm\) 0.7847 2.9940 \(\pm\) 1.3287
MDD 0.0456 \(\pm\) 0.0066 0.0585 \(\pm\) 0.0099 0.0719 \(\pm\) 0.0086 0.0799 \(\pm\) 0.0075 0.0799 \(\pm\) 0.0075 0.0634 \(\pm\) 0.0130

6 Experiment results↩︎

6.1 Ranking Accuracy and Investment Performance Comparision↩︎

Table 1 reports the comparative performance of all baseline models and the proposed STN-TGAT framework. In terms of ranking accuracy,STN-TGAT achieves competitive results, with an MRR of 0.1879 and an RBO of 0.0509. Although LSTM attains slightly higher values on certain pure ranking metrics, STN-TGAT maintains stable top-rank consistency while extracting signals that are more effective for downstream portfolio construction.

The superiority of STN-TGAT becomes more evident in the backtesting results. As reported in Table 1, STN-TGAT achieves the highest IRR (18.07%) and Sharpe ratio (2.99), outperforming the strongest recurrent baseline GRU. The distribution plots in Fig. 1 (a) and Fig. 1 (b) further confirm that STN-TGAT consistently yields higher median returns and stronger risk-adjusted performance compared with other models. Moreover, Fig. 1 (c) illustrates the cumulative return trajectories during the test period. STN-TGAT maintains the highest equity curve throughout the evaluation window, demonstrating its ability to sustain portfolio growth even during volatile market phases. Despite operating in noisy financial environments, STN-TGAT exhibits robust risk characteristics. As shown in Table 1, it achieves lower maximum drawdown than most neural baselines, indicating improved downside protection.

a
b
c

Figure 1: Performance comparison of different methods.. a — IRR, b — Sharpe ratio, c — Cumulative return

Overall, the evaluation considers both ranking accuracy and after-fee portfolio performance. While no model dominates all metrics, STN-TGAT achieves the most consistent balance, translating reliable Top-5 selection into stronger backtested returns with a competitive risk profile under transaction costs. These results highlight its practical suitability for real-world portfolio construction.

6.2 Ablation Studies↩︎

6.2.1 Loss function↩︎

Table 2: Ablation study of loss.
Metric ListNet+MSE ListNet-only MSE-only Spearman+MSE Pairwise+MSE
RBO 0.0516 \(\pm\) 0.0127 0.0519 \(\pm\) 0.0135 0.0372 \(\pm\) 0.0077 0.0487 \(\pm\) 0.0048 0.0407 \(\pm\) 0.0076
MRR 0.1875 \(\pm\) 0.0378 0.1904 \(\pm\) 0.0401 0.1263 \(\pm\) 0.0195 0.1643 \(\pm\) 0.0245 0.1583 \(\pm\) 0.0168
IRR 0.2132 \(\pm\) 0.1309 0.2161 \(\pm\) 0.1326 0.0395 \(\pm\) 0.0730 0.0945 \(\pm\) 0.0145 0.0646 \(\pm\) 0.0543
Sharpe 3.3130 \(\pm\) 1.5240 3.3160 \(\pm\) 1.5250 0.7570 \(\pm\) 1.7100 2.3560 \(\pm\) 0.3300 1.4740 \(\pm\) 1.0780
MDD 0.0618 \(\pm\) 0.0136 0.0646 \(\pm\) 0.0142 0.0779 \(\pm\) 0.0122 0.0744 \(\pm\) 0.0058 0.0812 \(\pm\) 0.0227

We conduct an ablation study to assess the contribution of each component in the proposed training objective for Top-5 portfolio construction. Our final loss for prediction combines a global top-weighted ListNet term with an auxiliary MSE term. To isolate their contributions, we evaluate ListNet-only and MSE-only variants. In addition, two alternative ranking objectives, Spearman [26] and Pairwise [1], are tested in combination with MSE.

As shown in Table 2, models without the ListNet component (MSE-only, Spearman+MSE, Pairwise+MSE) show substantially weaker investment performance. MSE-only model achieves an IRR of 0.0395 and Sharpe ratio of 0.7570, far below the 0.2132 IRR and 3.3130 Sharpe obtained by ListNet+MSE. Similarly, Spearman+MSE and Pairwise+MSE yield lower IRRs (0.0945 and 0.0646), indicating that listwise ranking supervision is essential for decision-aligned stock selection. While ListNet-only already achieves strong profitability, incorporating the auxiliary MSE term (ListNet+MSE) leads to the most robust portfolio performance, achieving comparable ranking metrics with improved risk-adjusted returns and lower drawdowns (0.0618 vs.). This suggests that the MSE term acts as a calibration and regularization component, stabilizing score magnitudes and improving the reliability of portfolio outcomes.

Overall, the results indicate that listwise supervision is critical for investable performance, while the hybrid objective provides a balanced and practically viable training strategy.

6.2.2 Effectiveness of the Prior Knowledge↩︎

Table 3: Ablation study results across different model configurations.
MODEL Transformer-GAT (no prior) Transformer-GAT (no sparsity) Transformer-GAT (GLASSO) STN-TGAT
RBO 0.0413 \(\pm\) 0.0053 0.0413 \(\pm\) 0.0056 0.0406 \(\pm\) 0.0072 0.0509 \(\pm\) 0.0118
MRR 0.1521 \(\pm\) 0.0214 0.1514 \(\pm\) 0.0266 0.1462 \(\pm\) 0.0226 0.1879 \(\pm\) 0.0345
MSE 0.5192 \(\pm\) 0.3942 0.3073 \(\pm\) 0.3239 0.6019 \(\pm\) 0.5262 0.3115 \(\pm\) 0.4176
IRR 0.0863 \(\pm\) 0.0692 0.1152 \(\pm\) 0.0551 0.0381 \(\pm\) 0.0672 0.1807 \(\pm\) 0.1176
Sharpe 1.8932 \(\pm\) 1.2710 2.5884 \(\pm\) 0.9710 0.7480 \(\pm\) 1.5070 2.9940 \(\pm\) 1.3287
MDD 0.0574 \(\pm\) 0.0093 0.0520 \(\pm\) 0.0116 0.0622 \(\pm\) 0.0133 0.0634 \(\pm\) 0.0130
a
b
c

Figure 2: Ablation study visualization: (a) and (b) show the distributions of IRR and Sharpe ratios via violin plots; (c) displays the cumulative mean returns with shaded standard deviation bands.. a — IRR, b — Sharpe, c — Cumulative Return

To assess the contribution of each structural component, we ablate the relational prior, prior type, and adaptive sparsification. Removing the structural prior substantially reduces investment performance. The Transformer-GAT (no prior) variant shows a large drop in IRR from 18.07% to 8.63% and a decrease in Sharpe ratio from 2.9940 to 1.8932. (Table 3), with a visibly more dispersed return distribution (Fig. 2 (a)). Replacing the nonlinear NMI prior with a linear GLASSO prior further degrades results. The Transformer-GAT (GLASSO) produces the lowest IRR (0.0381) and Sharpe ratio (0.7480), and an almost flat cumulative return trajectory (Fig. 2 (c)), suggesting that the nonlinear prior captures dependencies more relevant for Top-\(K\) selection. Finally, adaptive sparsification also plays an important role. Although the Transformer-GAT (no sparsity) model still benefits from the NMI prior, disabling sparsification introduces noisy edges, reducing the Sharpe ratio from 2.9940 to 2.5884. As shown in Fig. 2 (b), STN-TGAT achieves a more concentrated high-return distribution, suggesting that learnable sparsification effectively filters redundant connections.

The structural diagnostics are consistent with this observation. The learned edge weights exhibit a highly right-skewed distribution (Fig. 3 (a)) and a steep CDF (Fig. 3 (b)), indicating that most edges are assigned small magnitudes. The prior–learned comparison (Fig. 3 (c)) and delta heatmap (Fig. 4 (a)) show systematic down-weighting relative to the NMI prior, while the reordered adjacency (Fig. 4 (b)) reveals concentrated high-weight regions alongside extensive low-weight areas. Together, these results suggest that the gating mechanism refines the prior topology by attenuating weaker connections, which aligns with the observed improvements in out-of-sample portfolio performance.

a
b
c

Figure 3: Analysis of the learned adjacency. Panel (a) reports the distribution of learned edge weights, (b) shows the cumulative distribution, and (c) compares prior weights \(A_0\) with learned weights \(A_{\phi}\); the \(y{=}x\) diagonal indicates perfect agreement.. a — Learned edge-weight histogram., b — CDF of learned edge weights., c — Prior vs.learned edge weights.

a
b

Figure 4: Heatmap diagnostics of the learned graph vs.the NMI prior. Panel (a) visualizes adjustments to the prior via the difference \(A_{\phi}-A_{0}\), and (b) shows the learned adjacency after node reordering by aggregate edge weight.. a — Delta heatmap: \(A_{\phi}-A_{0}\), b — Learned \(A_{\phi}\) heatmap (reordered)

6.2.3 Effectiveness of Top-\(K\) Within-Set Weighting↩︎

Table 4: Effect of within-Top-5 allocation for STN-TGAT.
Metric Top\(K\)-EqualWeight Top\(K\)-ScoreWeight
IRR 0.1521 \(\pm\) 0.1119 0.1807 \(\pm\) 0.1176
Sharpe 2.5595 \(\pm\) 1.3979 2.9940 \(\pm\) 1.3287
MDD 0.0636 \(\pm\) 0.0132 0.0634 \(\pm\) 0.0130

We further conduct an ablation study on the within-Top-5 allocation strategy used in portfolio construction to assess whether translating model scores into conviction-aware weights provides additional practical benefits beyond pure stock selection. Specifically, keeping the trained STN-TGAT model and the Top-5 selection rule unchanged, we compare two allocation strategies within the selected Top-5 set: (i) equal-weighting, which assigns identical weights to all selected stocks, and (ii) score-based weighting, which allocates weights according to the relative magnitudes of predicted scores from Eq. 1 , thereby reflecting the model’s confidence when forming daily portfolios.

As shown in Table 4, the score-based weighting scheme consistently improves portfolio-level performance compared with equal-weighting. Specifically, the weighted strategy achieves higher IRR (0.1807 vs.) and Sharpe ratio (2.9940 vs.), while maintaining comparable maximum drawdown (0.0634 vs.). Although the standard deviations indicate variability across runs, the consistent improvement in mean return and risk-adjusted performance suggests that the predicted score magnitudes contain information beyond ranking order alone. Overall, these findings indicate that incorporating score-based allocation within the selected Top-5 set can enhance out-of-sample portfolio performance under the same selection rule, supporting the practical utility of the model’s output for both ranking and capital allocation.

7 Conclusion↩︎

This paper presents the Soft-Thresholded NMI-prior Transformer Graph Attention Network (STN-TGAT), a spatial-temporal framework for Top-\(K\) equity selection. We formulate daily stock selection as a decision-aligned ranking problem and introduce a top-weighted ListNet objective that emphasizes accuracy within the investable set. An auxiliary MSE term anchors predicted score magnitudes to realized returns, linking predictive performance to economically meaningful portfolio results. The architecture integrates Transformer-based temporal attention with graph attention mechanisms to jointly capture long-range temporal dependencies and dynamic cross-sectional interactions. In addition, a soft-thresholded Normalized Mutual Information (NMI) prior guides graph construction through adaptive sparsification, systematically attenuating weaker connections while preserving stronger relational structure.

The framework is evaluated on real-world \(S\&P\) 500 data under a Top-5 selection setting with explicit transaction costs. Across multiple ablation configurations, STN-TGAT achieves competitive ranking performance and improved risk-adjusted returns relative to alternative structural variants. These results indicate that integrating nonlinear relational priors with adaptive gating to a coherent and practically effective approach to portfolio construction.

References↩︎

[1]
M. Patel, K. Jariwala, and C. Chattopadhyay, “A systematic review on graph neural network-based methods for stock market forecasting,” ACM Computing Surveys, 2024.
[2]
Q. Yu, “Stock price prediction and comparative analysis using RNN, LSTM and ARIMA,” in AIP conference proceedings, 2024.
[3]
J. Gao, X. Ying, C. Xu, J. Wang, S. Zhang, and Z. Li, “Graph-based stock recommendation by time-aware relational attention network,” ACM Transactions on Knowledge Discovery from Data (TKDD), 2021.
[4]
A. Jafari and S. Haratizadeh, “GCNET: Graph-based prediction of stock price movement using graph convolutional network,” Engineering Applications of Artificial Intelligence, 2022.
[5]
N. K. Pande, A. Kumar, and A. K. Gupta, “Forecasting stock indices: Stochastic and artificial neural network models,” Computational Economics, 2025.
[6]
R. Ren, D. D. Wu, and T. Liu, “Forecasting stock market movement direction using sentiment analysis and support vector machine,” IEEE Systems Journal, 2018.
[7]
P. K. Illa, B. Parvathala, and A. K. Sharma, “Stock price prediction methodology using random forest algorithm and support vector machine,” Materials Today: Proceedings, 2022.
[8]
A. B. Omar, S. Huang, A. A. Salameh, H. Khurram, and M. Fareed, “Stock market forecasting using the random forest and deep neural network models before and during the COVID-19 period,” Frontiers in Environmental Science, 2022.
[9]
S. Feng, C. Xu, Y. Zuo, G. Chen, F. Lin, and J. XiaHou, “Relation-aware dynamic attributed graph attention network for stocks recommendation,” Pattern Recognition, 2022.
[10]
J.-H. Chen and Y.-C. Tsai, “Dynamic deep convolutional candlestick learner,” arXiv preprint arXiv:2201.08669, 2022.
[11]
K. Cui, R. Hao, Y. Huang, J. Li, and Y. Song, “A novel convolutional neural networks for stock trading based on DDQN algorithm,” IEEE Access, 2023.
[12]
H. Pham, H. Lam, L. Duy, T. Pham, and T. Trinh, “An improved convolutional recurrent neural network for stock price forecasting,” IAES International Journal of Artificial Intelligence, 2024.
[13]
C. Wang, Y. Chen, S. Zhang, and Q. Zhang, “Stock market index prediction using deep transformer model,” Expert Systems with Applications, 2022.
[14]
Q. Ding, S. Wu, H. Sun, J. Guo, and J. Guo, “Hierarchical multi-scale gaussian transformer for stock movement prediction.” in IJCAI, 2020.
[15]
C. Li and G. Qian, “Stock price prediction using a frequency decomposition based GRU transformer neural network,” Applied Sciences, 2022.
[16]
Z. You, Z. Shi, H. Bo, J. Cartlidge, L. Zhang, and Y. Ge, DGDNN: Decoupled graph diffusion neural network for stock movement prediction,” in Proceedings of the 16th international conference on agents and artificial intelligence (ICAART 2024) – volume 2, 2024, pp. 431–442.
[17]
Z. Zheng, J. Shao, J. Zhu, and H. T. Shen, “Relational temporal graph convolutional networks for ranking-based stock prediction,” in 2023 IEEE 39th international conference on data engineering (ICDE), 2023.
[18]
X. Yin, D. Yan, A. Almudaifer, S. Yan, and Y. Zhou, “Forecasting stock prices using stock correlation graph: A graph convolutional network approach,” in 2021 international joint conference on neural networks (IJCNN), 2021.
[19]
C. Wang, H. Liang, B. Wang, X. Cui, and Y. Xu, “Mg-conv: A spatiotemporal multi-graph convolutional neural network for stock market index trend prediction,” Computers and Electrical Engineering, 2022.
[20]
D. Ma, D. Yuan, M. Huang, and L. Dong, “VGC-GAN: A multi-graph convolution adversarial network for stock price prediction,” Expert Systems with Applications, 2024.
[21]
H. Tian, X. Zhang, X. Zheng, and D. D. Zeng, “Learning dynamic dependencies with graph evolution recurrent unit for stock predictions,” IEEE Transactions on Systems, Man, and Cybernetics: Systems, 2023.
[22]
L. Zhang and H. Lu, “A feature-importance-aware and robust aggregator for GCN,” in Proceedings of the 29th ACM international conference on information & knowledge management, 2020, pp. 1813–1822.
[23]
L. Zhang, Y. Ge, and H. Lu, “Hop-hop relation-aware graph neural networks,” arXiv preprint arXiv:2012.11147, 2020.
[24]
D. Castilho, T. T. Souza, S. M. Kang, J. Gama, and A. C. de Carvalho, “Forecasting financial market structure from network features using machine learning,” Knowledge and Information Systems, 2024.
[25]
J. Gu, J. Ye, A. Uddin, and G. Wang, “DySTAGE: Dynamic graph representation learning for asset pricing via spatio-temporal attention and graph encodings,” in Proceedings of the 5th ACM international conference on AI in finance, 2024.
[26]
L. Hu and Q. Wang, “A study of dynamic stock relationship modeling and s&P500 price forecasting based on differential graph transformer,” arXiv preprint arXiv:2506.18717, 2025.
[27]
S. Ugwu, P. Miasnikof, and Y. Lawryshyn, “Distance correlation market graph: The case of s&P500 stocks,” Mathematics, 2023.
[28]
E. Turner and M. Cucuringu, “Graph denoising networks: A deep learning framework for equity portfolio construction,” in Proceedings of the fourth ACM international conference on AI in finance, 2023.
[29]
L. Zhang, H. Song, N. Aletras, and H. Lu, “Node-feature convolution for graph convolutional networks,” Pattern Recognition, vol. 128, p. 108661, 2022.
[30]
A. Vaswani et al., “Attention is all you need,” Advances in neural information processing systems, 2017.
[31]
P. Veličković et al., “Graph attention networks,” in International conference on learning representations, 2018.
[32]
R. Sawhney, S. Agarwal, A. Wadhwa, and R. Shah, “Exploring the scale-free nature of stock markets: Hyperbolic graph learning for algorithmic trading,” in Proceedings of the web conference 2021, 2021.
[33]
W. Xu et al., “Hist: A graph-based framework for stock trend forecasting via mining concept-oriented shared information,” arXiv preprint arXiv:2110.13716, 2021.
[34]
Y. He, Q. Li, F. Wu, and J. Gao, “Static-dynamic graph neural network for stock recommendation,” in Proceedings of the 34th international conference on scientific and statistical database management, 2022.
[35]
S. Saha, J. Gao, and R. Gerlach, “Stock ranking prediction using list-wise approach and node embedding technique,” IEEE Access, 2021.

  1. Throughout the paper, we omit explicit time indices (e.g., writing \(\mathbf{X}\) instead of \(\mathbf{X}_t\)) for notational simplicity. Unless otherwise specified, all variables are implicitly indexed by trading day \(t\), and the model operates sequentially in a rolling-window manner to predict \(t{+}1\) returns.↩︎

  2. The next-day log return is defined as \(r_{i,t} = \log P_{i,t} - \log P_{i,t-1}\), where \(P_{i,t}\) denotes the adjusted closing price of stock \(i\) on day \(t\). \(y_{i,t} = r_{i,t}\), \(y^{\mathrm{rank}}_{i,t} = \frac{r_{i,t} - \mu_{t}}{\sigma_{t}}\), where \(\mu_{t}\) and \(\sigma_{t}\) denote the cross-sectional mean and standard deviation of \(\{ r_{j,t} \}_{j=1}^{N}\) across all stocks on day \(t\).↩︎