# STGAT: Spatial-Temporal Graph Attention Neural Network for Stock Prediction
###### Abstract  
Stock price prediction and portfolio optimization are critical research areas in financial markets, as they directly impact investment strategies and risk management. Traditional statistical methods and machine learning approaches have been widely applied to these tasks, but they often fail to fully capture the complex dynamics of financial markets. Traditional statistical methods typically rely on unrealistic assumptions or over-simplified models, neglecting the nonlinear and high-dimensional characteristics of market data. Additionally, deep learning methods, especially temporal convolution networks and graph attention networks, have been introduced in this area and have achieved significant improvements in both stock price prediction and portfolio optimization. Therefore, this study proposes a Spatial-Temporal Graph Attention Network (STGAT) that integrates STL decomposition components and graph structures to model both temporal patterns and asset correlations. By combining graph attention mechanisms with temporal convolutional modules, STGAT effectively processes spatiotemporal data, enhancing the accuracy of stock price predictions. Empirical experiments on the CSI 500 and S&P 500 datasets demonstrate that STGAT outperforms other deep learning models in both prediction accuracy and portfolio performance. The investment portfolios constructed based on STGAT's predictions achieve higher returns in real market scenarios, which validates the feasibility of spatiotemporal feature fusion for stock price prediction and highlights the advantages of graph attention networks in capturing complex market characteristics. This study not only provides a robust tool for portfolio optimization but also offers valuable insights for future research in intelligent financial systems. p 2025 15 4315 22 February 2025 4 April 2  
statistical-based forecasting models were introduced for stock price prediction, such as Autoregressive Integrated Models (ARIMA), Vector Autoregression (VAR), the Autoregressive Conditional Heteroskedasticity Model (ARCH), and the Generative Autoregressive Conditional Heteroskedasticity Model (GARCH) [3; 4; 5]. However, these models perform forecasting through static patterns of statistical historical series and therefore fail to capture the nonlinear characteristics of stock price series [6]. With the development of machine learning algorithms, researchers started to utilize Support Vector Regression (SVR), random forest (RF), and Principal Component Analysis (PCA) to analyze more complex patterns of stock data [7; 8; 9; 10]. With the continuous development of machine learning techniques, deep learning models, particularly neural networks, have shown great potential in analyzing financial data. [PERSON] et al. [11] employed dilated and causal convolutions in temporal neural networks (TCNs) to effectively capture long-term sequence features while enabling the parallelization of the neural network. Machine learning models and deep learning models enhance predictive ability by focusing on sequential feature extraction. However, they fail to capture the potential correlations among different stocks. Recently, numerous studies revealed that a stock's future price is impacted by the performance of other stocks [12; 13], which is both intuitive and insightful. Researchers have begun utilizing graph structures to represent stocks and model the correlations among stocks, providing a structured approach to capturing inter-stock relationships. [PERSON] and [PERSON] [14] used a graph convolutional network (GCN) to organize stocks into an influence network that evaluates relationships among stocks based on historical and technical indicators. This approach leverages a semi-supervised framework and plausible label discovery to enhance prediction accuracy by capturing latent inter-stock dependencies effectively. It is also worth noting that temporal prediction methods without deep learning methods are also being developed at the same time.