# STGAT: Spatial-Temporal Graph Attention Neural Network for Stock Prediction
###### Abstract
For instance, hybrid frameworks like ARIMA combined with echo state networks (ESNs) leverage linear models to capture global trends in crude oil price volatility, using the ESNs to refine nonlinear residuals [15]. Seasonal-trend decomposition using Loess (STL) has been applied to isolate price components, enabling feature reconstruction that amplifies latent patterns under efficiency constraints [16]. Meanwhile, state models in a binary-temporal representation explicitly characterize crude oil price dynamics as state transitions governed by binary-temporal patterns, with optimized trend duration and range thresholds to capture transient inefficiencies in high-frequency regimes [17]. These approaches also address challenges in time series analysis, where interpretability is critical. In this work, we propose a Spatial-Temporal Graph Attention Network (STGAT) that combines a multi-head graph attention network (GAT) with a temporal convolutional network (TCN) to efficiently extract both spatial and temporal features of stock closing prices. The residual attention mechanisms set in both the GAT and TCN enable the network to focus on more relevant features of the stock market by continuously updating node features. By integrating spatial and temporal features, STGAT achieves higher consistency between the predicted outputs and actual data based on the input stock prices. Stock portfolios constructed using the prediction results at different market periods also yield higher returns compared to other neural network models. The results demonstrate that the time series graph attention network proposed in this paper can effectively extract market information and apply it to stock price prediction. The main contributions of this paper are as follows:  
1. By employing the Pearson correlation coefficient as a metric for stock correlation, the flattened stock market data are converted into graph data that encapsulate rich structural information. The graph attention module introduced in this work is used to capture spatial features and identify correlation patterns within the stock market. 2. By applying time series decomposition, the stock price data aRE separated into trend, seasonal, and residual components. Different parts of the stock information are then used as inputs to distinct modules, leading to improved performance and accuracy in this work. 3. A pioneering graph attention network and temporal convolutional network with a residual attention mechanism are proposed to effectively capture the dynamic spatial features of the stock market. These networks uncover deeper patterns both within and among stocks, providing critical features for stock price prediction. 4. The integration of graph attention network and temporal convolutional network effectively combines spatial and temporal features, resulting in improved performance in stock price prediction and portfolio optimization. This approach offers a new intelligent model for financial portfolio management by striking a reasonable balance between risk and return. The remaining sections of this paper are organized as follows. Section 2 provides background information and outlines research methods for portfolio optimization across different periods. Section 3 describes the algorithms used in this model and offers an overview of the framework designed in this study, ensuring the overall network's feasibility. Section 4 presents the model's performance compared to other approaches and concludes the paper by summarizing its limitations and suggesting directions for future research.