Stock price prediction method based on modified emotion index

Through the revised sentiment index prediction method based on BERT and LSTM models, the problem of failure to effectively consider financial anomalies in the prior art is solved, and higher accuracy of stock price trend prediction is achieved, especially in the yield forecast on Monday.

CN119648258APending Publication Date: 2025-03-18阮昌 +1
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202311187711.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-15
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

The existing technology failed to effectively consider financial anomalies when building sentiment indexes, resulting in insufficient accuracy of stock price predictions, especially with significant errors in the yield forecast on Monday.

Method used

The corrected sentiment index prediction method based on BERT and LSTM models is adopted. By extracting the emotional characteristics of stock investors, the daily sentiment index is calculated, and the emotion index correction model is constructed, the abnormal investment sentiment index is corrected, and the stock historical price data is input to the LSTM model for prediction.

Benefits of technology

It effectively improves the accuracy of stock price trend forecasts, especially in Monday's yield forecast. Correcting sentiment index can effectively correct the interference of abnormal information on investment, improving the accuracy of forecast results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119648258A_ABST
    Figure CN119648258A_ABST
Patent Text Reader

Abstract

The invention provides a stock price prediction method based on a corrected emotion index and stock market historical transaction data, and relates to the application of computer artificial intelligence in the financial field, and the method specifically comprises the steps: selecting a historical transaction data set of a to-be-predicted stock and a corresponding stock comment data set; the method comprises the following steps: selecting a financial corpus data set to carry out pre-training on a BERT (Bidirectional Encoder Representation Transformers) model, so as to obtain an emotion classification model; inputting the stock comment data into an emotion classification model to obtain an emotion index data set; constructing a correction model for correcting the abnormal investment emotion index to obtain a corrected emotion index data set; the method comprises the following steps of: establishing a long short term memory (LSTM) model used for predicting a stock price; and merging the stock historical price data set and the corrected emotion index data set, and inputting the merged data set into the LSTM model to obtain a price trend prediction value. By correcting the abnormal emotion data, the abnormal value of the emotion data is reduced, and the accuracy of stock data prediction is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the application of computer artificial intelligence in the financial field, and is a stock price prediction method based on a modified sentiment index. Background Art

[0002] The rapid development of the Internet has not only led to an increase in the number of Internet users, but also driven the transformation of new investment methods for investors. Many financial websites, such as Eastmoney.com, Tonghuashun, and Securities Star, provide investors with special social platforms. More and more investors follow up and understand the development of enterprises and industries on the Internet, express their personal opinions and share experiences. These social media information subtly influence investors' investment decisions and even cause fluctuations in the entire stock market.

[0003] By mining the social media data of financial websites, a lot of valuable information can be obtained, such as investor sentiment. Investor sentiment reflects the investment intention or expectation of market participants, which will be affected by the social environment and market development conditions, and thus make a subjective judgment on the future development and returns of the stock market, and this judgment will have an impact on subsequent investments and decisions. When the emotions and investment behaviors of most people in the market change, it is bound to affect the development of the entire market. However, investor sentiment is a non-concrete indicator and is difficult to measure accurately. Reasonable use of this social media information can enable investors to have a clearer understanding of the stock market, make more scientific investment judgments, and reduce investment risks.

[0004] As an interdisciplinary subject integrating computer science, mathematics and other fields, natural language processing technology has been widely used in the financial field. In the financial field, media text sentiment has a significant predictive ability for my country's stock fluctuations. However, when constructing sentiment indexes, financial anomalies are rarely considered. Financial anomalies are a concept closely related to the Efficient Markets Hypothesis (EMH), which assumes that investors are rational and that each investor has equal information. However, the real financial market is not so perfect. People have found many phenomena that contradict EMH, namely financial anomalies. The weekday effect is a very famous financial anomaly. The main reason is that a large amount of news is released on weekends or after the stock market closes on Friday. Investors' behavior is likely to change dramatically after the news is released on Monday, resulting in Monday's returns being generally lower than those on other days of the week. To solve this problem, we constructed a sentiment index correction model that can correct the sentiment index error and improve the accuracy of stock price prediction.

[0005] The stock market is a barometer of a country or region's economic activities, and the trading price of the stock market also objectively reflects the supply and demand relationship of the economic market. However, the stock market has the characteristics of high noise, nonlinearity and volatility, and is easily affected by news events, natural disasters and other factors. Therefore, investment in the financial field requires professional knowledge and has a certain threshold. How to lower the threshold and eliminate interference so that investors can spend less time to obtain more investment returns is the focus of this field, which prompts us to use computer artificial intelligence to deal with the above problems.

[0006] LSTM has the characteristics of a gating mechanism and the ability of long-term memory. It can effectively learn the long-term trend rules in financial time series and is very suitable for predicting stock price trends. The BERT model is currently the best text analysis model in the field of natural language, and can effectively perform sentiment analysis on text. Therefore, the present invention extracts the emotional characteristics of stock investors based on the BERT model, calculates the daily sentiment index of investors, and then merges the stock historical price data and the sentiment index data set into LSTM for prediction, which effectively improves the accuracy of stock price trend prediction. In addition, the present invention corrects the investor sentiment index by constructing a sentiment index correction algorithm, further improving the accuracy of the prediction results. Summary of the invention

[0007] The technical problem to be solved by the present invention is that, in view of the deficiencies in the prior art, the present invention provides a

[0008] The modified sentiment index prediction method based on BERT and LSTM models includes the following steps:

[0009] Select the historical transaction data set of the stock to be predicted and the corresponding stock review data set;

[0010] Select the financial corpus dataset to pre-train the BERT model and obtain the sentiment classification model;

[0011] Input the target stock review data into the sentiment classification model to obtain the sentiment index dataset;

[0012] A correction model for correcting abnormal investment sentiment index is constructed to correct the sentiment index data set, thereby obtaining a corrected sentiment index data set;

[0013] Build a stock price prediction model based on machine learning LSTM;

[0014] The stock historical price dataset and the modified sentiment index dataset are combined and input into the LSTM model to obtain the price trend prediction value;

[0015] The present invention will be further described below in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is a schematic diagram of the overall method of the volatility stock price prediction method based on the modified sentiment index of the present invention.

[0017] Figure 2 This is a diagram of the prediction results of the present invention. DETAILED DESCRIPTION

[0018] See also Figure 1 : Figure 1 The following is a flow chart of the method for predicting stock price fluctuations based on the modified sentiment index of the present invention.

[0019] The process is as follows:

[0020] Step 1: Select a data set of stock reviews published by users on Eastmoney.com from March 2017 to May 2018 and preprocess the data set, which includes review date, review content, etc.

[0021] Step 2: Select the historical trading data set of the Shanghai Composite Index from March 2017 to May 2018 and preprocess the data set, where the data set includes opening price, closing price, highest price, lowest price, trading volume, etc.

[0022] Step 3: Select the financial corpus dataset published on Kaggle and input it into the BERT model for pre-training to obtain a sentiment classification model. The dataset includes comment release time, comment content, and labels. The labels are divided into 1, 0, and -1, representing positive, neutral, and negative, respectively.

[0023] Step 4: Input the stock review data into the sentiment classification model, extract information from each stock review through the sentiment classification model, and obtain the sentiment index of each stock review, where positive sentiment is marked as "1", neutral sentiment is marked as "0", and negative sentiment is marked as "-1".

[0024] Step 5: Calculate the stock daily sentiment index based on the time series. The calculation formula is:

[0025]

[0026] Where S t represents the sentiment index of the stock on trading day t, pos t represents the number of positive comments on trading day t, neu t represents the number of neutral comments on trading day t, neg t represents the number of negative reviews on trading day t.

[0027] Step 6: Construct a sentiment index correction model, and correct the daily sentiment index in combination with the Sunday effect to obtain a corrected sentiment index. The calculation formula for the corrected sentiment index is:

[0028] S′ t =e -2a S t-2 +e -a S t-1 +e 0 S t (5)

[0029] where S′ t is the revised sentiment index for Monday, S t , S t-1 and S t-2 They represent the emotional index of Monday, Sunday and Saturday respectively. It is stipulated that a>0. The smaller a is, the greater the impact of the emotional values ​​of Saturday and Sunday on Monday. The present invention sets a to 1, then S′ t It can be expressed as:

[0030] S′ t =e -2 S t-2 +e -1 S t-1 +e 0 S t (6)

[0031] Step 7: Build an LSTM model for time series analysis.

[0032] Step 8: Combine the historical stock trading data and the modified sentiment index and input them into the LSTM model to simulate and predict the stock price.

[0033] The present invention designs a stock price prediction method with a modified sentiment index, adopts real data for experiments, and uses mean square error (MSE), root mean square error (RMSE) and mean absolute error (MAE) as evaluation indicators of the stock model, which reflects the degree of difference between the predicted value and the actual value. The smaller the selected target indicator, the better the model performance.

[0034] We compare the model used in the present invention with traditional support vector machines (SVM), temporal convolutional networks (TCN) and LSTM algorithms, where LSTM+S means that the LSTM algorithm is combined with the sentiment index for prediction, and LSTM+S' means that the LSTM algorithm is combined with the modified sentiment index for prediction. The comparison results are shown below:

[0035]

[0036] The prediction curve of the model is as follows Figure 2 As shown in the figure, the model prediction results have a certain lag compared with the actual values, but the overall fluctuation trend is similar to the actual values. The LSTM+S' model prediction curve is more in line with the actual trend, which proves that adding a modified sentiment index can effectively correct the interference of abnormal information on investment and effectively improve the accuracy of stock price prediction.

[0037] The above is a detailed introduction to the method for stock price prediction based on the modified sentiment index provided by the present invention, but the present invention is not limited to the above-mentioned specific implementation mode. The above is only a specific embodiment of the present invention and is not used to limit the scope of protection of the present invention. Under the enlightenment of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the purpose of the present invention and the claims, which all fall within the protection of the present invention.

Claims

1. A method for stock price prediction based on modified sentiment index, characterized in that: The following steps are involved: Step 1: obtaining a stock review data set and preprocessing the data, wherein the stock review data set includes a plurality of stock review data of corresponding stock data; Step 2: Obtain the stock historical transaction data set and preprocess the data; Step 3: Select the financial corpus dataset published on Kaggle to supervise the pre-trained model and obtain the sentiment classification model; Step 4: Input the target stock review dataset into the sentiment classification model to obtain a sentiment index dataset, where the sentiment index reflects the positive, neutral or negative sentiment attitude of each review towards the stock; Step 5: Construct a sentiment index correction model to eliminate the sentiment errors caused by the Sunday effect. Step 6: Build an LSTM model for predicting stock price trends; Step 7: After combining the historical transaction data with the revised stock sentiment index, input it into the LSTM model to obtain the real-time prediction results of future stock prices.

2. The method for stock price prediction based on modified sentiment index according to claim 1, characterized in that: Inputting the target stock comment data into the sentiment classification model to obtain the sentiment index, including: inputting the target stock comment data into the sentiment classification model to obtain the sentiment score, wherein the sentiment score is determined according to the probability scores of the output values ​​of the news sentiment classification model as positive sentiment, neutral sentiment, and negative sentiment; judging whether the target financial news data is positive sentiment, neutral sentiment, or negative sentiment according to the value with the largest score, and representing it with 1, 0, or -1, respectively, which is the sentiment index of each comment.

3. The method for stock price prediction based on modified sentiment index according to claim 1, characterized in that : Daily sentiment index is calculated based on the number of positive, neutral and negative comments on the day. The calculation formula is: Where S t represents the sentiment index of the stock on trading day t, pos t represents the number of positive comments on trading day t, neu t represents the number of neutral comments on trading day t, neg t represents the number of negative reviews on trading day t.

4. The method for stock price prediction based on modified sentiment index according to claim 1, characterized in that: Based on the workday effect, we construct a sentiment index correction algorithm to reduce the dramatic mood swings caused by the workday effect and correct the investment sentiment index. We define Monday's sentiment as the weighted average of past sentiments, with the weight decreasing exponentially. The calculation formula for the revised sentiment index every Monday is: S′ t =e -3a S t-2 +e -a S t-1 +e 0 S t (2) where S′ t is the revised sentiment index for Monday, S t , S t-1 and S t-2 They represent the sentiment indexes of Monday, Sunday and Saturday respectively. It is stipulated that a>0. The smaller a is, the greater the influence of the sentiment values ​​of Saturday and Sunday on Monday.

5. The method for stock price prediction based on modified sentiment index according to claim 9, characterized in that: When the modified sentiment index dataset and the stock historical transaction dataset are merged, the modified sentiment index dataset has empty sentiment index outputs for some dates due to data missing. In order to ensure that the input stock price trend prediction model does not contain empty data, this part of the data needs to be filled. The present invention selects to forward fill the sentiment data without sentiment index, and selects the sentiment index of the previous trading day multiplied by an attenuation parameter as the sentiment index of the current trading day. The calculation formula is: S″ t =S t-1 a (3) Where S″ t is the filling sentiment index of trading day t, α is the attenuation parameter, α∈[0,1], and the present invention takes α as 0.2.

Citation Information

Cited By

  • Stock price collapse risk analysis reference system based on stock market interaction data identification

    CN121052933A

  • Machine learning-based multi-output regression incremental learning dynamic adaptation stock price prediction model construction method

    CN121413805A