Stock trend prediction method and system based on tensor fusion inter-stock relation network
Through the inter-stock relationship network based on tensor fusion, a multi-dimensional tensor structure and a dual-channel architecture are constructed, and the industry's super-graph and market-driven graph attention are integrated, which solves the problem of failing to make full use of stock relationships in the existing technology and achieves efficient stock prediction under different market conditions.
Patent Information
- Application Number
- CN202510379062.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-28
- Publication Date
- 2025-07-04
AI Technical Summary
The existing stock prediction methods fail to make full use of the rich interrelationships between stocks and cannot effectively capture the complex higher-order interactions in the financial market. The traditional graph convolutional network lacks adaptability to market dynamic changes and fails to effectively model the enhancement or weakening of industry relations under different market conditions.
Using an inter-stock relationship network based on tensor fusion, we integrate industry hypergraph attention and market-driven graph attention to learn the interaction and influence of different types of relationships under different market conditions by constructing a multi-dimensional tensor structure and a dual-channel architecture.
It improves the accuracy and robustness of stock forecasts, and can more comprehensively understand stock dynamic changes under different market conditions and improves the prediction effect.
Smart Images

Figure CN120258227A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical fields of machine learning and fintech, and particularly relates to a method and system for predicting stock trends based on a tensor fusion stock - to - stock relationship network. Background Art
[0002] In the financial market, stock prediction plays a crucial role and has attracted the attention of numerous investors and researchers. The complexity of the stock market is mainly reflected in various interdependent factors that affect its trends, which can be analyzed from two dimensions: one is the correlation within exchange - traded data, and the other is the propagation effect of fundamental information. In previous studies, people mainly focused on factors such as sector linkage effects, the impact of large - cap stocks, and the correlation of liquid funds. However, with the development of the market, recent research has gradually expanded its scope to aspects such as industrial chain relationships, substitution and complementary effects between industries, and the impact of the macro - economy on stock trends. The interweaving of these factors makes stock prediction more complex, while also providing a broader exploration space for investors and researchers.
[0003] Traditional deep - learning methods, especially recurrent neural networks (RNNs) and their variants, have made significant progress in capturing temporal patterns in stock prediction. For example, some researchers have comprehensively compared different RNN architectures through experiments, demonstrating the effectiveness of long short - term memory networks (LSTMs) and gated recurrent units (GRUs) in processing sequential data. These models can effectively capture long - term dependencies in time series and thus perform well in stock prediction. In addition, some studies have also analyzed momentum spillover effects by sharing data such as analyst coverage using these temporal models, further verifying their application potential in the financial market. At the same time, a tensor - based event - driven LSTM model has also been developed, which can effectively handle the multi - modal nature of market information, solve challenges such as cross - modal interaction and temporal heterogeneity, and provide a more accurate analysis tool for stock prediction.
[0004] However, many existing methods often treat stocks as independent entities and fail to fully utilize the rich interrelationships among stocks. Empirical evidence shows that the inherent connections between stocks and the companies behind them, such as common executive leadership or industry classification, are important predictive indicators. These relationships can reveal the common driving factors of stock price movements, thus providing deeper insights for prediction. To overcome this limitation, recent research has begun to apply learning techniques based on graph neural networks (GNNs) to model stock relationships. By constructing a relationship graph among stocks, these methods can capture various types of relationships between stocks, from direct correlations to complex industry-based interactions. For example, by analyzing the common supplier, customer relationships, or competitive and cooperative relationships within an industry among stocks, GNNs can gain a more comprehensive understanding of stock dynamics. These graph-based methods have shown potential in improving prediction accuracy, bringing new research directions and application prospects to the field of stock prediction.
[0005] Existing methods based on graph neural networks (GNNs) have limitations in stock prediction, mainly manifested in three aspects: First, they usually can only describe the relationships between stocks through simple binary edges and cannot fully capture the complex high-order interactions in the financial market, such as the common impact of multiple assets in market events or industry developments; Second, traditional graph convolutional networks (GCNs) rely on fixed, predefined stock connections, such as industry classification or fixed thresholds based on correlation. This static structure lacks adaptability to market dynamics, while the relationships between stocks can change significantly due to changes in market conditions, company fundamentals, or external events; Finally, although some studies have attempted to combine static industry relationships and dynamic market associations, these relationships are usually processed independently in different modules or combined only through simple connection methods, failing to effectively model the complex interactions between them, limiting the model's ability to capture how industry relationships strengthen or weaken under different market conditions.
[0006] After retrieval, it is found that the Chinese invention authorization announcement number CN116957140B discloses a stock prediction method and system based on NLP factors. This patent obtains the scores of target stock information through in-depth analysis of text content and constructs an NLP quantitative factor portfolio for stock prediction. However, it does not explore the relevance of industry relationships and trading data, thus having certain technical defects in stock prediction. Summary of the Invention
[0007] In view of the above problems existing in the prior art, the present invention proposes a stock trend prediction method and system based on a tensor fusion stock relationship network. The present invention designs a new dual-channel architecture that seamlessly integrates industry-based hypergraph attention and market-driven graph attention, enabling the model to learn how different types of relationships interact and affect stock trends under different market conditions.
[0008] To achieve the above object, the present invention adopts the following technical solutions:
[0009] A stock trend prediction method based on a tensor fusion stock relationship network, which comprises the following steps:
[0010] Step 1. Fuse the input initial data to obtain an embedding that comprehensively represents the stock.
[0011] Step 2. Based on the obtained stock embedding, capture the dependencies in the stock price sequence.
[0012] Step 3. Learn the relationships between stocks to obtain the influence of industry relationships on stocks and the influence of the correlation of trading data on stocks.
[0013] Step 4. Stock prediction. Input the obtained stock embedding into the output mapping module to obtain the probability of the stock rising trend.
[0014] Further, Step 1 includes constructing a multi-dimensional tensor structure to fully explore the internal correlation between trading data and sentiment data. The specific steps are as follows:
[0015] Step 1.1: Represent the data of each stock at time t as The quantified sentiment data of each company is represented as
[0016] Step 1.2: Construct a multi-dimensional tensor structure: Collect the historical trading data of stocks, including the opening price, closing price, highest price, lowest price, and trading volume of each trading day. The intraday trading data for T consecutive trading days can be concatenated into a trading data matrix Collect financial news data from news websites and represent these data as quantified sentiment data according to the seven sentiment features defined by the L&M dictionary: positive, negative, uncertain, litigious, restrictive, strong modality, and weak modality, to obtain a sentiment data matrix
[0017] Step 1.3: Fully explore the internal correlation between trading data and sentiment data: On trading day t, fuse the trading data of company i to obtain a fused vector. The fusion process is expressed as Obtain the fused data
[0018] Among them, represents the obtained stock embedding, and are both learnable parameters, represents the learnable deviation number, and || represents a concatenation operation.
[0019] Furthermore, step 2 specifically includes the following steps:
[0020] Step 2.1: Obtain the fused data according to step 1.3 Use a gated recurrent unit to capture long-term dependencies, which is expressed as The GRU implementation process is as follows:
[0021]
[0022] Among them, represents the update gate, represents the reset gate, represents the candidate hidden state, represents the hidden state at the current moment. W z and U z are respectively the input weight matrix and the hidden state matrix of the update gate, W r and U r are respectively the input weight matrix and the hidden state matrix of the reset gate, W v and U v are respectively the input weight matrix and the hidden state matrix of the candidate hidden state, b z 、b r 、b v are all bias vectors; ⊙ represents element-wise multiplication.
[0023] Furthermore, step 3 specifically includes two major steps of learning the correlation relationship of trading data and learning the industry relationship. Among them:
[0024] In learning the correlation relationship of trading data, an asymmetric adaptive graph generator (steps 3.1.1 - 3.1.2) and a hybrid graph attention module are used to obtain the influence of the relationship between stocks on the stock price trend, specifically as follows:
[0025] Step 3.1.1: According to the long-term dependencies obtained in step 2, first obtain the initial adjacency matrix through the following two formulas:
[0026] M A = tanh(θ A W A ), M B = tanh(θ B W B )
[0027]
[0028] Step 3.1.2: Retain only the k stocks that are most closely related to each stock. The implementation method is as follows:
[0029]
[0030] where, represents the j-th column in the initial adjacency matrix The finally obtained adjacency matrix is denoted as A = [a1, a2,..., a N .
[0031] Step 3.1.3: Embed the stock price matrix as the main node embedding matrix, and apply the adjacency matrix obtained in Step 3.1.2 to the hybrid graph attention module.
[0032] Step 3.1.4: To ensure the stability of the output of each layer, add a residual connection before generating the final output:
[0033]
[0034] Step 3.1.5: Mix the output of each layer and apply a linear transformation to obtain the final output. Among them, β1 ∈ [0, 1] is a hyperparameter, is a learnable parameter matrix.
[0035] In learning industry relationships, use hypergraphs and enhanced hypergraph attention networks to obtain the impact of industry relationships on stock trends, specifically as follows:
[0036] Step 3.2.1: Store industry relationships in the form of hypergraphs, defined as S = {s1, s2,..., s M} represents the node set, and ε = {E1, E2,..., E M} represents the hyperedge set.
[0037] Step 3.2.2: Use the hypergraph and the long-term dependencies obtained in Step 2 as the initial input for hyperedge embedding. The implementation method is the same as that in Step 3.2.4.
[0038] Step 3.2.3: According to the obtained hyperedge embedding, use group embedding to enhance the representation ability of hyperedges. The implementation method is as follows:
[0039]
[0040] where, Encoder(·) represents the encoder module in the transformer architecture, and are recognized as learnable parameters. Thus, the group embedding generates an enhanced hyperedge embedding matrix, denoted as
[0041] Step 3.2.4: Based on the obtained group embedding, use the following formula to update the embedding of each node:
[0042]
[0043]
[0044] where represents the combination of all hyperedges containing node s n , and W n ,
[0045] and represent learnable parameters;
[0046] Step 3.2.5: Also use residual links to ensure the stability of the output of each layer
[0047] Step 3.2.6: Repeat steps 3.2.1 - 3.2.5 twice, but the input becomes the output of the previous layer to obtain the output of each layer.
[0048] Step 3.2.7: Mix the outputs of each layer and apply a linear transformation to obtain the final output.
[0049] where β2 ∈ [0,1] represents a hyperparameter, represents the node embedding of the l-th layer, is a learnable parameter, represents the final output of the group-enhanced hypergraph attention module.
[0050] Furthermore, step 4 specifically includes the following steps:
[0051] Step 4.1: The output mapping module uses a single-layer feedforward neural network and the softmax enhancement function to generate an estimate of the stock trend, mathematically expressed as where represents the predicted probability of the stock price increase, v n , represents the stock embedding generated by the gated recurrent unit module, the hybrid graph attention module, and the enhanced hypergraph attention module for stock s n , and and b n represent the relevant learnable parameters.
[0052] Step 4.2: The model uses the cross-entropy loss function, which is mathematically defined as where y n ∈{0,1} represents the true label of stock v n .
[0053] The present invention also discloses a stock trend prediction system based on a tensor fusion stock relationship network for executing the above method, including the following modules:
[0054] Stock embedding acquisition module: Fuse the input initial data to obtain an embedding representing the stock;
[0055] Dependency capture module: Based on the obtained stock embedding, capture the dependencies in the stock price sequence;
[0056] Stock relationship learning module: Learn the relationships between stocks to obtain the influence of industry relationships on stock trends and the influence of the correlation of trading data on stock trends;
[0057] Stock trend acquisition module: Input the obtained stock embedding into the output mapping module to obtain the probability of the stock's upward trend.
[0058] The present invention seamlessly integrates industry-based hypergraph attention and market-driven graph attention through a new dual-channel architecture, enabling the model to learn how different types of relationships interact and affect stock trends under different market conditions, thereby improving the accuracy of prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 It is a flowchart of a stock trend prediction method based on a tensor fusion stock relationship network according to a preferred embodiment of the present invention;
[0060] Figure 2 It is a structure diagram of a gated recurrent unit in a stock trend prediction method based on a tensor fusion stock relationship network according to a preferred embodiment of the present invention;
[0061] Figure 3 It is a diagram of a group-enhanced hypergraph attention module in a stock trend prediction method based on a tensor fusion stock relationship network according to a preferred embodiment of the present invention;
[0062] Figure 4 It is a comparison diagram of the present invention with other models on different datasets in an embodiment of the present invention;
[0063] Figure 5 It is a block diagram of a stock trend prediction system based on a tensor fusion stock relationship network according to a preferred embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0064] The preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0065] As Figure 1 shown, this embodiment is a stock trend prediction method based on a tensor fusion stock relationship network, which is specifically carried out according to the following steps:
[0066] Step 1: Represent the data of each stock at time t as The quantified sentiment data of each company is represented as Collect the historical trading data of stocks, including the opening price, closing price, highest price, lowest price, and trading volume of each trading day. The intraday trading data for T consecutive trading days can be concatenated into a trading data matrix Collect financial news data from news websites, and represent the quantified sentiment data of these data according to the seven sentiment features defined in the L&M dictionary: positive, negative, uncertain, litigation, restrictive, strong modality, and weak modality, to obtain a sentiment data matrix
[0067] On trading day t, fuse the trading data of company i to obtain a fused vector. The fusion process is represented as Obtain the fused data
[0068] Step 2: According to the fused data obtained in Step 1 Use a gated recurrent unit (as Figure 2 shown) to capture long-term dependencies, which is represented as The GRU implementation process is as follows:
[0069]
[0070] Step 3: Learn the relationships between stocks to obtain the impact of industry relationships on stock trends and the impact of the correlation of trading data on stock trends. Specifically, input the obtained long-term dependencies into a dual-channel attention module:
[0071] Among them: The specific process of learning the correlation relationship of trading data is as follows:
[0072] Step 3.1.1: According to the long-term dependencies obtained in Step 2, first obtain the initial adjacency matrix through the following two formulas:
[0073] M A =tanh(θ A W A ), M B =tanh(θ B W B ),
[0074]
[0075] Step 3.1.2: For each stock, only keep the k most closely related stocks, and the implementation method is as follows:
[0076]
[0077] Among them, represents the j-th column in the initial adjacency matrix The finally obtained adjacency matrix is expressed as A = [a1, a2,..., a N .
[0078] Step 3.1.3: Embed the stock price matrix as the main node embedding matrix, and apply the adjacency matrix obtained in Step 3.1.2 to the hybrid graph attention module.
[0079] Step 3.1.4: To ensure the stability of the output of each layer, add a residual connection before generating the final output
[0080]
[0081] Step 3.1.5: Mix the output of each layer and apply a linear transformation to obtain the final output.
[0082] Among them: Input the industry hypergraph and the long-term dependence relationship into the group-enhanced hypergraph attention module together to learn the influence of the industry relationship on the stock trend.
[0083] The implementation method of the group-enhanced hypergraph attention module in this embodiment is as Figure 3 shown, and the specific steps are as follows:
[0084] Step 3.2.1: Store the industry relationship in the form of a hypergraph, defined as S = {s1, s2,..., s M} represents the node set, and ε = {E1, E2,..., E M} represents the hyperedge set.
[0085] Step 3.2.2: Use the hypergraph and the long-term dependence relationship obtained in Step 2 as the initial input for hyperedge embedding, and the implementation method is the same as that in Step 3.2.4.
[0086] Step 3.2.3: Use group embedding to enhance the representation ability of hyperedges according to the obtained hyperedge embedding, and the implementation method is as follows:
[0087]
[0088] Step 3.2.4: Based on the obtained group embedding, use the following formula to update the embedding of each node:
[0089]
[0090]
[0091] Step 3.2.5: Similarly, residual links are used to ensure the stability of the output of each layer.
[0092] Step 3.2.6: Repeat steps 3.2.1 - 3.2.5 twice, but the input becomes the output of the previous layer to obtain the output of each layer.
[0093] Step 3.2.7: Mix the outputs of each layer and apply a linear transformation to obtain the final output.
[0094] Step 4: Using a single - layer feed - forward neural network, with a softmax boosting function, generate an estimate of the stock trend, mathematically expressed as where represents the predicted probability of the stock movement. The end - to - end model uses a cross - entropy loss function, which is mathematically defined as
[0095] The experimental results are as Figure 4 shown. Using standard binary classification metrics, including accuracy, ROC–AUC, precision, and recall. Accuracy represents the proportion of correctly predicted samples in the total number of samples; ROC–AUC means that the ROC curve is plotted with the false positive rate (FPR) on the x - axis and the true positive rate (TPR, i.e., recall) on the y - axis, and AUC represents the area under this curve, with a numerical range of 0 - 1, and the closer to 1, the better the model performance; Precision represents the proportion of samples predicted as positive that are actually positive; Recall represents the proportion of samples that are actually positive and are correctly predicted as positive. The results show that the method proposed by the TFIR - Net of the present invention has better prediction results compared to other baseline models.
[0096] As Figure 5 shown, this embodiment discloses a stock movement prediction system based on a tensor - fusion stock - to - stock relationship network for performing the above - mentioned method, including the following modules:
[0097] Stock embedding acquisition module: Fuse the input initial data to obtain an embedding representing the stock;
[0098] Dependency capture module: Based on the obtained stock embeddings, capture the dependencies in the stock price sequence;
[0099] Stock relationship learning module: Learn the relationships between stocks to obtain the influence of industry relationships on stock movements and the influence of the correlation of trading data on stock movements;
[0100] Stock trend acquisition module: Embed the acquired stocks and input them into the output mapping module to obtain the probability of the stock's upward trend.
[0101] For other contents of this embodiment, reference may be made to the above embodiments.
[0102] The present invention innovatively integrates multi-source information and can capture the complex factors behind stock price fluctuations. In addition, by learning the different relationships between different stocks, the model can comprehensively consider the influence of other related stocks when predicting a certain stock, thereby improving the robustness and accuracy of the prediction. Furthermore, the robustness and accuracy of the present invention are verified through experiments on the dataset.
[0103] The above embodiments will help those skilled in the art to further understand the present invention, but do not limit the present invention in any form. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can still be made. These all belong to the protection scope of the present invention.
Claims
1. A stock trend prediction method based on a stock relationship network with tensor fusion, characterized in that, It includes the following steps: Step 1: Fuse the input initial data to obtain an embedding representing the stock; Step 2: Based on the obtained stock embedding, capture the dependencies in the stock price sequence; Step 3: Learn the relationships between stocks to obtain the influence of industry relationships on stock trends and the influence of the correlation of transaction data on stock trends; Step 4: Input the obtained stock embedding into the output mapping module to obtain the probability of the stock's upward trend.
2. The stock trend prediction method based on the tensor fusion stock relationship network according to claim 1, wherein Step 1 includes constructing a multi-dimensional tensor structure and mining the internal correlation between transaction data and sentiment data. The specific steps are as follows: Step 1.1: Represent the data of each stock at time t as The quantitative sentiment data of each company is represented as Step 1.2: Collect the historical trading data of stocks, including the opening price, closing price, highest price, lowest price, and trading volume for each trading day. Connect the intraday trading data for consecutive T trading days into a trading data matrix Collect news data and represent these data with seven sentiment features to obtain quantified sentiment data: positive, negative, uncertain, litigation, restraint, strong modality, and weak modality, resulting in a sentiment data matrix Step 1.3: On trading day t, fuse the transaction data of company i. The fusion process is expressed as: Obtain the fused data Among them, represents the obtained stock embedding, and are both learnable parameters, represents the learnable deviation number, and || represents a concatenation operation.
3. The stock trend prediction method based on the tensor fusion stock relationship network according to claim 2, characterized in that Step 2 specifically includes the following steps: Obtain the fused data according to Step 1.3 Use a gated recurrent unit to capture the described dependencies, denoted as GRU represents the implementation of the gated recurrent unit, and the implementation process is as follows: Among them, represents the update gate, represents the reset gate, represents the candidate hidden state, represents the hidden state at the current moment; W z and U z are respectively the input weight matrix and the hidden state matrix of the update gate, W r and U r are respectively the input weight matrix and the hidden state matrix of the reset gate, W v and U v are respectively the input weight matrix and the hidden state matrix of the candidate hidden state, b z 、b r 、b v are all bias vectors; ⊙ represents element-wise multiplication.
4. The stock trend prediction method based on the tensor fusion stock relationship network according to claim 3, wherein Step 3: Use a hypergraph and an enhanced hypergraph attention network to obtain the influence of industry relationships on stock trends, and use an asymmetric adaptive graph generator and a hybrid graph attention module to obtain the influence of the price relationship between stocks on stock trends.
5. The stock trend prediction method based on the tensor fusion stock relationship network according to claim 4, characterized in that In Step 3, an asymmetric adaptive graph generator and a hybrid graph attention module are used to obtain the influence of the relationship between stocks on stock trends. The specific steps are as follows: Step 3.1.1: According to the dependencies obtained in Step 2, obtain the initial adjacency matrix through the following two formulas: M A = tanh(θ A W A ), M B = tanh(θ B W B ), Step 3.1.2: For each stock, retain the k most closely related stocks. The implementation method is: Among them, represents the j-th column in the initial adjacency matrix, and the obtained adjacency matrix is denoted as A = [a1, a2, …, a N ; Step 3.1.3: Take the stock price embedding matrix as the main node embedding matrix, and apply the adjacency matrix obtained in Step 3.1.2 to the hybrid graph attention module; Step 3.1.4: Add a residual connection before generating the final output: Step 3.1.5: Mix the outputs of each layer and apply a linear transformation to obtain the final output; where β1∈[0,1] is a hyperparameter, is a learnable parameter matrix.
6. The stock trend prediction method based on the tensor fusion stock relationship network according to claim 5, wherein In Step 3, a hypergraph and an enhanced hypergraph attention network are used to obtain the influence of industry relationships on stock trends. Specifically as follows: Step 3.2.1: Store the industry relationships in the form of a hypergraph, defined as S = {s1, s2, …, s M} represents the node set, and ε = {E1, E2, …, E M} represents the hyperedge set; Step 3.2.2: Take the hypergraph and the dependencies obtained in Step 2 as the initial input for hyperedge embedding. The implementation method is as follows: Step 3.2.3: Use group embedding to enhance the representational ability of the hyperedge according to the obtained hyperedge embedding. The implementation method is as follows: Among them, Encoder(·) represents the encoder module in the transformer architecture, and are recognized as learnable parameters; the group embedding generates an enhanced hyperedge embedding matrix, denoted as Step 3.2.4: Based on the obtained group embedding, update the embedding of each node using the following formula: Among them, represents the combination of all hyperedges containing node s n , and represents learnable parameters; Step 3.2.5: Use residual connections to ensure the stability of the output of each layer Step 3.2.6: Repeat Steps 3.2.1 - 3.2.5 twice, with the input for each time being the output of the previous layer, to obtain the output of each layer; Step 3.2.7: Mix the outputs of each layer and apply a linear transformation to obtain the final output; Among them, β2 ∈ [0, 1] represents a hyperparameter, represents the node embedding of the l-th layer, are learnable parameters, represents the final output of the group-enhanced hypergraph attention network module.
7. The stock trend prediction method based on the tensor fusion stock relationship network according to claim 6, wherein Step 4 specifically includes the following steps: Step 4.1: Use a single-layer feedforward neural network and a softmax enhancement function to generate an estimate of the stock trend, expressed as: Among them, represents the predicted probability of stock price increase, v n , respectively represent the stock embeddings generated by the gated recurrent unit module, the hybrid graph attention module, and the enhanced hypergraph attention module for stock s n ; and b n represent learnable parameters; Step 4.2: The cross-entropy loss function is adopted, which measures the difference between the probability distribution output by the model and the true category, and is defined as where y n ∈ {0, 1} represents the true label of stock v n .
8. A stock trend prediction system based on a tensor fusion stock relationship network for performing the method according to any one of claims 1-7, characterized in that It includes the following modules: Stock Embedding Obtaining Module: Fuse the input initial data to obtain an embedding representing the stock; Dependency Capturing Module: Based on the obtained stock embedding, capture the dependencies in the stock price sequence; Stock Relationship Learning Module: Learn the relationships between stocks to obtain the influence of industry relationships on stock trends and the influence of the correlation of transaction data on stock trends; Stock Trend Obtaining Module: Input the obtained stock embedding into the output mapping module to obtain the probability of the stock's upward trend.