Self-adaptive stock investment decision generation method suitable for high-fluctuation market
By using Transformer predictive coding models in high-volatility markets and improving Markov decision-making processes, the problem that existing technology is difficult to identify and adapt to market abnormal patterns in high-volatility markets and abnormal events is solved, and more accurate and reliable stock investment decisions are achieved, and investors' adaptability to high-volatility markets is improved.
Patent Information
- Application Number
- CN202510142617.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-10
- Publication Date
- 2025-03-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing stock investment decision generation method based on DRL model is difficult to identify and adapt to market anomalies in high volatility markets and abnormal events, and has shortcomings in extracting and modeling long-term dependencies, making it difficult to capture the long-term dynamic characteristics of the stock market.
An adaptive stock investment decision generation method suitable for high-volatility markets is proposed. By obtaining stock trading data, stock price indicators, correlation indicators and market volatility indicators are calculated, and these indicators are input into the Transformer prediction coding model to obtain multi-scale feature representation. Then, through a multi-layer bull attention mechanism, a comprehensive feature is generated, and input it to improve the Markov decision-making process, the SAC algorithm is used to solve, and stock investment decisions are obtained.
Through this method, more accurate and reliable stock investment decisions can be obtained, investors can adapt to high-volatility markets, effectively capture the abnormal fluctuations and long-term dynamic characteristics of the market, improve returns and control trading risks.
Smart Images

Figure CN119579319A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of financial quantification and artificial intelligence technology, and in particular relates to an adaptive stock investment decision-making generation method suitable for a high-volatility market. Background Art
[0002] The stock market is the main channel for investors to realize capital appreciation. However, the complexity and dynamism of the financial market make investment decisions face huge challenges. The core goal of investors is to create maximum profits through strategic resource allocation. Therefore, the optimal trading strategy problem (Optimal Trade Execution, OTE) has always been a hot issue in the field of financial quantification. Traditional quantitative models usually use statistical methods, which themselves have prediction limitations, and the uncertainty of the financial market will further lead to inefficient decision-making and may even result in significant losses. With the advancement of artificial intelligence technology, deep reinforcement learning (DRL) has further promoted the intelligence of financial transactions. The DRL algorithm can identify the optimal trading strategy to maximize cumulative returns through interactive learning with the stock market environment. For example, the paper StockFormer: Learning Hybrid Trading Machines with Predictive Coding (Gao, Siyu, Yunbo Wang, and XiaokangYang., IJCAI. 2023) The DRL model is used to extract market dynamic characteristics and optimize trading behavior through reinforcement learning strategies, which alleviates the limitations of traditional investment methods to a certain extent.
[0003] Although the above technologies have significantly improved the intelligence level of financial transactions, the current stock investment decision-making method based on the DRL model still has some defects, especially when dealing with highly volatile markets and abnormal events. There are the following shortcomings:
[0004] 1. Traditional DRL models usually rely on a large amount of historical data for training. However, in rare and extreme market conditions, the model has difficulty identifying and adapting to abnormal market patterns due to the lack of relevant historical data.
[0005] 2. Although the long short-term memory (LSTM) model performs well in processing time series data, existing models still have shortcomings in extracting and modeling long-term dependencies. This limitation makes it difficult to capture the long-term dynamic characteristics of the stock market, especially in a highly volatile market, and it is difficult to effectively predict long-term trends.
[0006] 3. Existing methods generally fail to effectively combine and utilize the multi-dimensional information of market data (such as price fluctuations, correlations between stocks, and market anomalies), although some studies, such as the paper Smart robotic strategies and advice for stock trading using deep transformer reinforcement learning(Malibari, Nadeem, Iyad Katib, and Rashid Mehmood., Applied Sciences 12.24(2022): 12526) The Transformer architecture is used to extract latent features, but it still has obvious limitations in the extraction and fusion of multi-time scale features.
[0007] The above defects lead to the lack of flexibility and accuracy of existing methods in a highly volatile market environment. Therefore, it is necessary to design a new stock investment decision-making method for a highly volatile market to further improve profitability and control trading risks. Summary of the invention
[0008] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide an adaptive stock investment decision-making method suitable for high-volatility markets, so as to further improve profitability and control transaction risks.
[0009] The purpose of the present invention can be achieved by the following technical solutions:
[0010] The present invention provides an adaptive stock investment decision-making method suitable for a high volatility market, comprising the following steps:
[0011] Acquire stock trading data, calculate stock price indexes, correlation indexes and market volatility indexes, the stock price indexes include MACD, BOLL, RSI, CCI and the closing price of each stock every day, the correlation index is used to reflect the correlation between every two stocks, and the market volatility index is calculated based on the LSTM autoencoder model with dilated convolution to reflect the volatility of the stock market; Inputting the stock price index, correlation index and market volatility index into a Transformer predictive coding model to obtain a multi-scale feature representation of each index, including long-term and short-term volatility features, long-term and short-term price features and correlation features, wherein a multi-head attention module with a multi-head feedforward network is introduced into the Transformer predictive coding model; Through a multi-layer multi-head attention mechanism, the multi-scale feature representations of each indicator are fused to obtain comprehensive features; The stock transaction is modeled as an improved Markov decision process, the comprehensive features are substituted and solved using the SAC algorithm to obtain the stock investment decision.
[0012] Furthermore, the calculation formula of the correlation index is as follows: , in, is the difference between the closing price of stock A on the i-th day and its average closing price in the previous year. is the difference between the closing price of stock B on the i-th day and its average closing price in the previous year, and n is the number of days involved in the stock trading data.
[0013] Furthermore, the LSTM autoencoder model with dilated convolution includes a dilated convolution layer, an LSTM encoding layer, an LSTM decoding layer and a time reconstruction layer connected in sequence. The process of calculating the market volatility index through the LSTM autoencoder model with dilated convolution is as follows: S11. Calculate the daily market volatility index d t : , Where N is the number of stocks. is the relative price ratio vector of each stock at the tth time stamp, is the sample average vector of historical relative price ratios, is the sample covariance matrix of the historical price ratio; S12. According to the calculation result of step S11, obtain the vector , where p is the sliding window length, and the vector is input into the dilated convolutional layer to obtain the long-time span data feature E t ; S13, the long time span data feature E t Input the LSTM encoding layer for encoding, then input the encoded LSTM sequence into the LSTM decoding layer for decoding, and then map the decoded LSTM sequence into a predicted value using a fully connected layer through the time reconstruction layer; S14. Calculate the difference between the predicted value and the actual value to obtain the reconstruction error as the market volatility score; S15. Generate the market volatility index according to the market volatility score, wherein the market volatility index includes a volatility score and an extreme volatility point. Specifically, if the market volatility score of a certain day is greater than a set threshold, the volatility score of the day is recorded as 1, and the day is marked as an extreme volatility point; if the market volatility score of a certain day is greater than the set threshold, the volatility score of the day is recorded as 0.
[0014] Furthermore, a Dropout layer is provided between the atrous convolution layer and the LSTM encoding layer, and between the LSTM encoding layer and the LSTM decoding layer.
[0015] Furthermore, the mean square error is used as the loss function to train the LSTM autoencoder model with dilated convolution.
[0016] Furthermore, the Transformer predictive coding model includes multiple encoder layers and multiple decoder layers, and in each encoder layer, the output of the previous encoder layer is substituted into a multi-head feedforward network for calculation; Each decoder layer is constructed based on the multi-head attention module with a multi-head feedforward network. In each decoder layer, multi-head attention calculation is first performed according to the output of the previous decoder layer, and then the result of the multi-head attention calculation and the output of the last encoder layer are substituted into the multi-head feedforward network for calculation.
[0017] Furthermore, the calculation process of the multi-head feedforward network is specifically as follows: S21, decompose the input data Z into L subgroups along the feature dimension, process each subgroup independently through the corresponding feedforward network, and the i-th subgroup z i The corresponding output h of the i-th feedforward network i Specifically: h i = max(0, z i W 1,i +b 1,i ) 2,i +b 2,i , i∈{1, …, L}, Among them, W 1,i and W 2,i is the weight matrix of the i-th feedforward network, b 1,i and b 2,i is the bias term of the i-th feedforward network; S22. Combine the outputs of all feedforward networks: MH_FFNs = Concat(h1, …, h L )+Z , Among them, MH_FFNs is the final output of the multi-head feedforward network, and Concat is the concatenation operation.
[0018] Furthermore, the specific calculation formula of the comprehensive feature is as follows: , , , , Among them, S t is a comprehensive feature, Concat is a concatenation operation, MH_Attn is a multi-head attention operation, represents the micro-risk embedding, Indicates macro risk embedding, is the holding situation of each stock at time t, is the price feature, is the correlation feature, , are the long-term and short-term price characteristics, , They are the long-term and short-term volatility characteristics respectively.
[0019] Furthermore, the framework of the improved Markov decision process includes a state space S, an action space A, a state transition probability T, a reward space R, a discount factor γ, an observation space O and an observation information distribution P under a given potential state, wherein the observation space O is constructed based on the stock price index, correlation index and market volatility index, and the state space S is constructed based on the holdings of each stock, as well as the potential representations of the long- and short-term volatility characteristics, long- and short-term price characteristics and correlation characteristics calculated according to the observation space O. The comprehensive features are calculated according to the potential states in the state space S and input into the action network and the evaluation network, and the action network selects an action from the action space A according to the comprehensive features and outputs it, thereby obtaining a stock investment decision; the evaluation network is used to calculate the Q value according to the action-state pair, and optimize the action selection strategy of the action network by minimizing the deviation of the Q value.
[0020] Furthermore, the evaluation network is also used to feed back the gradient of the state to the Transformer predictive coding model to assist in the training of the model.
[0021] Compared with the prior art, the present invention has the following beneficial effects:
[0022] 1. The present invention proposes an adaptive stock investment decision-making method suitable for a high volatility market. First, stock trading data is obtained, and stock price index, correlation index and market volatility index are calculated. This step can extract the potential features of the original data from three aspects: risk, price and correlation. The market volatility index is calculated based on an LSTM autoencoder model with a dilated convolution, which can effectively capture the characteristics of rare but important high volatility events in the market. Then, the above indicators are input into a Transformer predictive coding model to obtain a multi-scale feature representation of each indicator. A multi-head attention module with a multi-head feedforward network is introduced into the Transformer predictive coding model to enhance the feature decoupling ability of the multi-head attention, thereby improving the accuracy and computational efficiency of the predictive coding task. Subsequently, the multi-scale feature representations of each indicator are fused through a multi-layer multi-head attention mechanism to obtain a comprehensive feature and comprehensively understand the market dynamics. Finally, the stock transaction is modeled as an improved Markov decision process, and the comprehensive features are substituted and solved using the SAC algorithm to obtain a stock investment decision. The above method can obtain more accurate and reliable stock investment decisions, and improve the adaptability of investors to a high volatility market.
[0023] 2. In the present invention, the LSTM autoencoder model with dilated convolution includes a dilated convolution layer, an LSTM encoding layer, an LSTM decoding layer and a time reconstruction layer connected in sequence, wherein the dilated convolution layer allows the model to capture data patterns with a longer time span by expanding the receptive field of the convolution kernel. In particular, in financial data, abnormal market fluctuations often have a long historical background, and the dilated convolution can capture these historical information, thereby improving the perception of these abnormal fluctuations; after capturing a wider range of historical data patterns, the LSTM autoencoder can effectively compress and restore the potential information in the volatility data by learning the encoding and decoding process of time series data, thereby helping the model to discover potential abnormal fluctuations by identifying points that do not conform to normal data patterns; the market volatility indicators generated by the model include volatility scores and extreme volatility points, which, as the basis for state generation, can provide important volatility information for subsequent analysis and calculation.
[0024] 3. The present invention introduces a multi-head attention module with a multi-head feedforward network in the Transformer predictive coding model. The multi-head feedforward network first decomposes the input data into multiple subgroups along the feature dimension. Each subgroup is processed independently by the corresponding feedforward network, and then the outputs of all feedforward networks are merged, which can further improve the computational efficiency and achieve efficient feature fusion.
[0025] 4. The present invention models stock trading as an improved Markov decision process. On the basis of the conventional Markov decision framework, an observation space constructed based on stock price index, correlation index and market volatility index and the distribution of observation information under a given potential state are added. The state space is constructed based on the position of each stock, as well as the potential representation of long-term and short-term volatility characteristics, long-term and short-term price characteristics and correlation characteristics calculated according to the observation space O. The comprehensive characteristics are calculated according to the potential state in the state space and input into the action network and the evaluation network. The action network selects an action from the action space according to the comprehensive characteristics and outputs it, thereby obtaining a stock investment decision. At the same time, the evaluation network calculates the Q value according to the action-state pair, and optimizes the action selection strategy of the action network by minimizing the deviation of the Q value. The above design components take into account that the decision-making process in the real financial market involves not only the relationship between the current state and the action, but also more complex factors. In addition, the evaluation network is also used to return the gradient of the state to the Transformer predictive coding model to assist the training of the model. Through this design, the Transformer predictive coding model and the Markov model can be jointly trained and optimized, and the forward modeling capability of predictive coding and the flexibility of deep reinforcement learning in finance are fully utilized, thereby generating more adaptive and robust trading decisions. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is the overall framework diagram of the method of the present invention;
[0027] Figure 2 This is a schematic diagram of the structure of the LSTM autoencoder model with dilated convolution;
[0028] Figure 3 Schematic diagram of the structure of the Transformer predictive coding model. DETAILED DESCRIPTION
[0029] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0030] Example:
[0031] This embodiment provides an adaptive stock investment decision generation method suitable for high volatility markets. First, an LSTM autoencoder model with dilated convolution is used to extract information related to rare high volatility from stock trading data; second, the Transformer predictive coding model is used to expand the agent's perspective to obtain potential representations of long-term and short-term volatility, price and their correlation; then, these multi-scale potential representations are fused through a series of multi-head attention structures to further enhance the model's ability to capture market dynamics; finally, stock trading is modeled as an improved Markov decision process, and the SAC algorithm is used to solve it to obtain stock investment decisions. The specific process of the above method is as follows:
[0032] Step 1: Obtain stock trading data and calculate stock price indicators, correlation indicators, and market volatility indicators.
[0033] (1) Stock price indicators: mainly include MACD, BOLL, RSI, CCI and the daily closing price of each stock.
[0034] (2) Correlation index: The covariance matrix between stocks is calculated as the correlation index to reflect the correlation between every two stocks. The calculation formula is as follows: , in, is the difference between the closing price of stock A on the i-th day and its average closing price in the previous year. is the difference between the closing price of stock B on the i-th day and its average closing price in the previous year, and n is the number of days involved in the stock trading data. If the covariance is a positive number, it means that the closing prices of the two stocks fluctuate in the same direction, that is, when the price of stock A rises, the price of stock B also tends to rise, indicating that the two stocks have a certain positive correlation; if the covariance is a negative number, it means that the closing prices of the two stocks may fluctuate in the opposite direction, that is, when stock A rises, stock B may fall. If the covariance is close to zero, it means that there is no obvious linear relationship between the closing price fluctuations of the two stocks, and there may be no correlation or other nonlinear relationships.
[0035] (3) Market volatility index: calculated based on the LSTM autoencoder model with dilated convolution, used to reflect the volatility of the stock market.
[0036] like Figure 2 As shown, the LSTM autoencoder model with dilated convolution includes a dilated convolution layer (Dilated Conv), an LSTM encoding layer (Encoding LSTM), an LSTM decoding layer (Decoding LSTM) and a time reconstruction layer (Time Distributed) connected in sequence. The dilated convolution expands the receptive field of the convolution kernel so that the model can capture data patterns with a longer time span. Especially in financial data, abnormal market fluctuations often have a long historical background. The dilated convolution can capture this historical information, thereby improving the perception of these abnormal fluctuations; after capturing a wider range of historical data patterns, the LSTM autoencoder can effectively compress and restore the potential fluctuation information in the data by learning the encoding and decoding process of time series data, thereby discovering potential abnormal fluctuations by identifying points that do not conform to normal data patterns. In a preferred embodiment, a Dropout layer is provided between the dilated convolution layer and the LSTM encoding layer, and between the LSTM encoding layer and the LSTM decoding layer to prevent the model from overfitting.
[0037] The process of calculating the market volatility index through this model is as follows:
[0038] S11. Calculate the daily market volatility index d t : , Where N is the number of stocks. is the relative price ratio vector of each stock at the tth time stamp, is the sample average vector of historical relative price ratios, is the sample covariance matrix of the historical price ratio.
[0039] S12. According to the calculation result of step S11, the vector , where p is the sliding window length, and the vector is input into the dilated convolution layer as the original data to obtain the long-term data feature E t See the paper Multi-scale context aggregation by dilated convolutions (Yu, F., arXiv preprint arXiv:1511.07122 (2015)), Atrous convolution can expand the model’s perspective to capture temporal patterns in the data more broadly and effectively.
[0040] S13, long time span data feature E t Input the LSTM encoding layer for encoding, and then encode the LSTM sequence H t (Encoded features) are input into the LSTM decoding layer for decoding, and then the decoded LSTM sequence is mapped into a predicted value using a fully connected layer through the time reconstruction layer .
[0041] S14. Calculate predicted value With the actual value E t+1 The difference between the two is the reconstruction error, which is the market volatility score at time t. t The volatility score measures the model's ability to recover data. If the model's reconstruction error is large, it indicates that the market state at that moment does not match the historical pattern, that is, there may be abnormal fluctuations.
[0042] S15. Generate a market volatility index based on the market volatility score. The market volatility index includes a volatility score and an extreme volatility point. Specifically, if the market volatility score of a certain day is greater than a set threshold, the volatility score of that day ( volaPoint t ) is recorded as 1, and the day is marked as an extreme volatility point; if the market volatility score of a certain day is greater than the set threshold, the volatility score of that day is recorded as 0: .
[0043] The threshold is set based on a specific percentile of the volatility score distribution and can be adjusted based on the investor's risk appetite, from aggressive to moderate to conservative, to suit different investment strategies.
[0044] The market volatility index generated by the above process can serve as the basis for subsequent state generation and can provide important volatility information for subsequent analysis and calculation. When training the LSTM autoencoder model with dilated convolution, the mean square error (MSE) is used as the loss function. The role of the mean square error is to optimize the model parameters by minimizing the difference between the predicted output and the actual output, thereby ensuring that the model can effectively capture the potential patterns in the time series data. Specifically, the error in the training process reflects the deviation of the model when reconstructing the input data. The purpose is to adjust the internal parameters of the model so that it can restore the input data more accurately and improve the learning ability of time series features.
[0045] Step 2: Input the stock price index, correlation index and market volatility index into the Transformer predictive coding model to obtain the multi-scale feature representation of each index.
[0046] The Transformer predictive coding model introduces a multi-head attention module with a multi-head feedforward network. Its structure is similar to that of the Transformer and aims to extract the potential features of the original data from three aspects: risk, price, and correlation in an unsupervised manner.
[0047] Specifically, Figure 3 As shown in the figure, the Transformer prediction coding model includes M encoder layers and N decoder layers. The inputs of the first encoder layer and the first decoder layer are O enc and O dec ,Right now and In the mth encoder layer, the output of the previous encoder layer is substituted into the multi-head feedforward network (MH_FFNs) for calculation: , Each decoder layer is built on a multi-head attention module with a multi-head feedforward network. In the nth decoder layer, the multi-head attention calculation (MH_Attn) is first performed based on the output of the previous decoder layer, and then the result of the multi-head attention calculation and the output of the last encoder layer are combined. Substitute into the multi-head feedforward network (MH_FFNs) for calculation: , , The output of the last decoder layer The final result of each predictive coding task is generated through a projection layer.
[0048] Since there are multiple different stocks at the same time, this embodiment considers using a multi-head feedforward network (MH_FFNs) to enhance the feature decoupling capability of the original multi-head attention module and improve the computational efficiency, so as to efficiently and accurately complete the predictive coding task. The calculation process of the multi-head feedforward network is as follows:
[0049] S21. Decompose the input data Z into L subgroups along the feature dimension: z i = Split (Z) , i∈{1, …, L}, Each subgroup is processed independently through a corresponding feed-forward network, which consists of two linear transformers with ReLU activation. i The corresponding output h of the i-th feedforward network i Specifically: h i = max(0, z i W 1,i +b 1,i ) 2,i +b 2,i , Among them, W 1,i and W 2,i is the weight matrix of the i-th feedforward network, b 1,i and b 2,i is the bias term of the i-th feedforward network.
[0050] S22. Combine the outputs of all feedforward networks: MH_FFNs = Concat(h1, …, h L )+Z , Among them, MH_FFNs is the final output of the multi-head feedforward network, and Concat is the concatenation operation.
[0051] Since volatility characteristics and price characteristics have significant time dependence, the model can effectively capture the dynamic changes of prices and market fluctuations based on visible historical data, which is crucial for stock investment decisions; while the correlation characteristics between stocks are calculated through static covariance matrices and technical indicators, and these characteristics themselves do not have clear time scale changes. Therefore, this embodiment uses the Transformer predictive coding model to capture long-term and short-term volatility characteristics , , long-term and short-term price characteristics , , and the potential characteristics of the correlation characteristics Specifically, the 5-day (1-day) volatility index processed in step 1 is used as the model input to extract the long-term (short-term) volatility characteristics; the stock price data of the past 5 days (1 day) (including opening price, closing price, highest price, lowest price, and trading volume) is used as input, and the long-term (short-term) price characteristics are also obtained based on the length of the time series; and the correlation characteristics are further extracted by using the covariance matrix and technical indicators calculated daily as the model input to reflect the dynamic correlation of the stock market.
[0052] Step 3: Through a multi-layer multi-head attention mechanism, the multi-scale feature representations of each indicator are fused to obtain comprehensive features.
[0053] In order to fuse these multi-scale features into a coherent representation, this embodiment uses a series of interacting multi-head attention mechanisms for calculation. This approach ensures that information from different scales is effectively combined, enabling scientific and reasonable decisions to be made based on a comprehensive understanding of market dynamics.
[0054] The specific calculation formula of the comprehensive characteristics is as follows: , , , , Among them, S t is a comprehensive feature, Concat is a concatenation operation, MH_Attn is a multi-head attention operation, represents the micro-risk embedding, Indicates macro risk embedding, is the holding situation of each stock at time t, For price characteristics.
[0055] Step 4: Use deep reinforcement learning (DRL) to model stock trading as a modified Markov decision process and use the SAC algorithm to solve it and obtain the stock investment decision.
[0056] In the framework of the improved Markov decision process, the agent's goal is to develop an optimal strategy to maximize the portfolio return by dynamically adjusting the asset allocation. The traditional Markov decision process (MDP) framework is usually represented by a five-tuple: {S, A, T, R, γ}, which represents the state space, action space, state transition probability, reward space, and discount factor, respectively. However, the actual stock trading decision process involves more than just the relationship between the current state and action, but also needs to consider more complex factors. Therefore, this embodiment expands it into a seven-tuple: {S, A, T, R, γ, O, P}, where O represents the observation space, P (O t |st ) represents a given potential state s t Observation information under O t In the reinforcement learning algorithm, T(s t+1 |s t ,a t ) describes the state that determines s t Next, perform action a t Then transfer to the next state s t+1 The probability distribution of P(O t |s t ) is used to solve the problem of partially observable states. In reality, agents usually cannot directly obtain the true state of the market and can only observe information O t To infer the potential state, by defining the mapping between observation and potential state, P(O t |s t ) enhances the model’s understanding of the market, allowing the agent to build a more complete representation of the market state in combination with historical observations, thereby optimizing the decision-making process. By discounting future rewards, the importance of immediate rewards and future rewards is balanced, and the larger Tend to focus on long-term returns.
[0057] Specifically, if Figure 1 As shown, the state space S includes the holdings of each stock and five types of potential representations (long-term and short-term volatility characteristics , , long-term and short-term price characteristics , , and the potential characteristics of the correlation characteristics ). The observation space O includes three inputs: price, risk, and correlation, which are calculated in step 1 and are expressed as , , , where the correlation input is the covariance between the daily closing price series and technical indicators The comprehensive representation of , technical indicators can capture the dynamic characteristics of time series. The action space A is continuous, expressed as , represents the action taken by the agent in a given state (positive number means buy, negative number means sell, 0 means hold, k is the maximum number of traded shares). The reward space R is defined by the daily portfolio return rate as the agent's reward signal.
[0058] The present invention adopts the SAC algorithm (see the paper " Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor." Haarnoja,Tuomas, et al. International conference on machine learning. PMLR, 2018.) to optimize trading strategies in multi-scale state spaces. In the SAC algorithm, the comprehensive features obtained in the state space S are passed to two networks: the action network and the evaluation network. The action network selects an action (such as buying k stocks) from the action space A based on the comprehensive features and outputs it to obtain stock investment decisions. At the same time, the evaluation network calculates the Q value based on the action-state pair. By minimizing the deviation of the Q value, the evaluation network provides a gradient signal to the action network to help optimize the action selection strategy.
[0059] In particular, in this embodiment, the evaluation network is also used to pass the gradient of the state back to the Transformer predictive coding model in step 2 ( Figure 1 ), optimizes the extraction process of correlation features to assist the training of the model and realizes the joint optimization of the Transformer predictive coding model and the stock trading model. This joint training method helps to further reveal the correlation between trading assets in noisy and high-dimensional observations, allowing the model to fully utilize the forward modeling capabilities of predictive coding and the flexibility of deep reinforcement learning in financial quantification, thereby generating more adaptive and robust stock trading strategies.
[0060] In this example, 88 stocks from the Shanghai and Shenzhen stock markets (CSI-300 dataset) and 83 stocks from the NASDAQ (NASDAQ-100 dataset) were selected for stock trading to evaluate the performance of the above method under different market conditions. The method proposed in this invention is compared with the market benchmark and deep reinforcement learning algorithms, including FinRL (see paper FinRL: A deep reinforcement learning library for automated stock trading in quantitative finance, Liu, Xiao-Yang, et al., arXiv preprintarXiv:2011.09607 (2020).) SAC and DDPG, and the latest StockFormer method (see paper StockFormer: Learning Hybrid Trading Machines with Predictive Coding,Gao, Siyu, Yunbo Wang, and Xiaokang Yang., IJCAI. 2023.) for comparison. In extreme market fluctuations, the method proposed in the present invention can successfully capture abnormal market fluctuations through a multi-scale LSTM autoencoder, showing higher adaptability and robustness. As shown in Table 1, on the CSI-300 dataset with abnormal fluctuations, the cumulative rate of return of the method of the present invention is 2.49%, and the Sharpe ratio is 1.75, which significantly exceeds other comparison algorithms. As shown in Table 2, on the relatively stable NASDAQ-100 dataset, the cumulative rate of return of the method of the present invention is also improved compared with other methods, proving its superiority in different market environments. Overall, the present invention can effectively cope with highly volatile markets and provide more accurate and robust support for investment decisions.
[0061] Table 1 Experimental data of CSI-300 dataset
[0062]
[0063] Table 2 Experimental data of NASDAQ-100 dataset
[0064]
[0065] The above description of the embodiments is to facilitate the understanding and use of the invention by those skilled in the art. It is obvious that those skilled in the art can easily make various modifications to these embodiments and apply the general principles described herein to other embodiments without creative work. Therefore, the present invention is not limited to the above embodiments, and improvements and modifications made by those skilled in the art based on the disclosure of the present invention without departing from the scope of the present invention should be within the scope of protection of the present invention.
Claims
1. An adaptive stock investment decision generation method suitable for highly volatile markets, characterized in that: The following steps are involved: Acquire stock trading data, calculate stock price indexes, correlation indexes and market volatility indexes, the stock price indexes include MACD, BOLL, RSI, CCI and the closing price of each stock every day, the correlation index is used to reflect the correlation between every two stocks, and the market volatility index is calculated based on the LSTM autoencoder model with dilated convolution to reflect the volatility of the stock market; Inputting the stock price index, correlation index and market volatility index into a Transformer predictive coding model to obtain a multi-scale feature representation of each index, including long-term and short-term volatility features, long-term and short-term price features and correlation features, wherein a multi-head attention module with a multi-head feedforward network is introduced into the Transformer predictive coding model; Through a multi-layer multi-head attention mechanism, the multi-scale feature representations of each indicator are fused to obtain comprehensive features; The stock transaction is modeled as an improved Markov decision process, the comprehensive features are substituted and solved using the SAC algorithm to obtain the stock investment decision.
2. The method for generating an adaptive stock investment decision suitable for a high volatility market according to claim 1, characterized in that: The calculation formula of the correlation index is as follows: , in, is the difference between the closing price of stock A on the i-th day and its average closing price in the previous year. is the difference between the closing price of stock B on the i-th day and its average closing price in the previous year, and n is the number of days involved in the stock trading data.
3. The method for generating an adaptive stock investment decision suitable for a highly volatile market according to claim 1, characterized in that: The LSTM autoencoder model with dilated convolution includes a dilated convolution layer, an LSTM encoding layer, an LSTM decoding layer and a time reconstruction layer connected in sequence. The process of calculating the market volatility index by using the LSTM autoencoder model with dilated convolution is as follows: S11. Calculate the daily market volatility index d t : , Where N is the number of stocks. is the relative price ratio vector of each stock at the tth time stamp, is the sample average vector of historical relative price ratios, is the sample covariance matrix of the historical price ratio; S12. According to the calculation result of step S11, obtain the vector , where p is the sliding window length, and the vector is input into the dilated convolutional layer to obtain the long-time span data feature E t ; S13, the long time span data feature E t Input the LSTM encoding layer for encoding, then input the encoded LSTM sequence into the LSTM decoding layer for decoding, and then map the decoded LSTM sequence into a predicted value using a fully connected layer through the time reconstruction layer; S14. Calculate the difference between the predicted value and the actual value to obtain the reconstruction error as the market volatility score; S15. Generate the market volatility index according to the market volatility score, wherein the market volatility index includes a volatility score and an extreme volatility point. Specifically, if the market volatility score of a certain day is greater than a set threshold, the volatility score of the day is recorded as 1, and the day is marked as an extreme volatility point; if the market volatility score of a certain day is greater than the set threshold, the volatility score of the day is recorded as 0.
4. The method for generating an adaptive stock investment decision suitable for a high volatility market according to claim 3, characterized in that: A Dropout layer is provided between the atrous convolution layer and the LSTM encoding layer, and between the LSTM encoding layer and the LSTM decoding layer.
5. The method for generating adaptive stock investment decisions in a highly volatile market according to claim 1, characterized in that: The mean square error is used as the loss function to train the LSTM autoencoder model with dilated convolution.
6. The method for generating an adaptive stock investment decision suitable for a highly volatile market according to claim 1, characterized in that: The Transformer predictive coding model includes multiple encoder layers and multiple decoder layers. In each encoder layer, the output of the previous encoder layer is substituted into a multi-head feedforward network for calculation; Each decoder layer is constructed based on the multi-head attention module with a multi-head feedforward network. In each decoder layer, multi-head attention calculation is first performed according to the output of the previous decoder layer, and then the result of the multi-head attention calculation and the output of the last encoder layer are substituted into the multi-head feedforward network for calculation.
7. The method for generating an adaptive stock investment decision suitable for a high volatility market according to claim 6, characterized in that: The calculation process of the multi-head feedforward network is specifically as follows: S21, decompose the input data Z into L subgroups along the feature dimension, process each subgroup independently through the corresponding feedforward network, and the i-th subgroup z i The corresponding output h of the i-th feedforward network i Specifically: h i = max(0, z i W 1,i +b 1,i ) W 2,i +b 2,i ,i∈{1, …, L}, Among them, W 1,i and W 2,i is the weight matrix of the i-th feedforward network, b 1,i and b 2,i is the bias term of the i-th feedforward network; S22. Combine the outputs of all feedforward networks: MH_FFNs = Concat(h1, …, h L )+Z , Among them, MH_FFNs is the final output of the multi-head feedforward network, and Concat is the concatenation operation.
8. The method for generating adaptive stock investment decisions in a highly volatile market according to claim 1, characterized in that: The specific calculation formula of the comprehensive characteristics is as follows: , , , , Among them, S t is a comprehensive feature, Concat is a concatenation operation, MH_Attn is a multi-head attention operation, represents the micro-risk embedding, Indicates macro risk embedding, is the holding situation of each stock at time t, is the price feature, is the correlation feature, , are the long-term and short-term price characteristics, , They are the long-term and short-term volatility characteristics respectively.
9. The method for generating adaptive stock investment decisions in a highly volatile market according to claim 1, characterized in that: The framework of the improved Markov decision process includes a state space S, an action space A, a state transition probability T, a reward space R, a discount factor γ, an observation space O and an observation information distribution P under a given potential state, wherein the observation space O is constructed based on the stock price index, correlation index and market volatility index, the state space S is constructed based on the holdings of each stock, and the potential representation of the long-term and short-term volatility characteristics, long-term and short-term price characteristics and correlation characteristics calculated according to the observation space O, the comprehensive characteristics are calculated according to the potential state in the state space S and input into the action network and the evaluation network, the action network selects an action from the action space A according to the comprehensive characteristics and outputs it, thereby obtaining a stock investment decision; the evaluation network is used to calculate the Q value according to the action-state pair, and optimize the action selection strategy of the action network by minimizing the deviation of the Q value.
10. The method for generating an adaptive stock investment decision suitable for a high volatility market according to claim 9, characterized in that: The evaluation network is also used to pass the gradient of the state back to the Transformer predictive coding model to assist in the training of the model.