Method and system for stock selection based on data analysis
Through the stock selection method and system based on data analysis, the high-quality stock selection criteria are determined using historical stock data and stock selection index factors, and the problem of low stock selection success rate in the existing technology is solved, and a higher stock selection success rate is achieved and investment decision accuracy.
Patent Information
- Application Number
- CN202411053937.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-02
- Publication Date
- 2025-01-10
AI Technical Summary
The existing stock selection methods in the stock investment field are difficult to keep up with changes in the stock market, resulting in a low stock selection success rate and unable to effectively guide investors when to buy or sell stocks, increasing investment risks.
By collecting historical stock data, obtaining multiple stock selection index factors, establishing data sets, dividing training sets and test sets, determining stock selection criteria, screening high-quality stocks, and establishing correlation relationships based on the rate of return and correlation coefficients to select stocks.
It improves the success rate of stock selection, simplifies the difficulty of stock investors in selecting stocks, improves the accuracy and continuous effectiveness of stock selection, and reduces investment risks.
Smart Images

Figure CN119295206A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data analysis and processing, and in particular to a stock selection method and system based on data analysis. Background Art
[0002] Stock investment refers to the investment behavior of enterprises or individual investors buying and selling stocks to obtain returns. Traditional stock investment analysis methods mainly include: basic analysis based on traditional economic theory, technical analysis based on traditional securities theory, and evolutionary analysis based on fireworks securities theory. However, the current number of investable stocks and stock investment analysis methods in the securities market are numerous, which increases the difficulty of stock investment for investors.
[0003] With the continuous development of computer big data, big data mining technology has been widely used in stock investment. Especially in foreign countries, the intelligent mining method of quantitative stock selection has been developed rapidly. The so-called quantitative stock selection refers to the use of quantitative methods such as mathematics, statistics, and computer science to analyze the data of the financial market, and screen out stocks that meet specific conditions to maximize investment returns. However, in the face of massive quantities, how to mine valuable information from it, select high-quality stocks, buy at low prices, sell at high prices, and obtain investment returns is still a major problem in the current stock investment field. The existing stock selection methods on the market cannot keep up with the changes in the stock market, resulting in a low success rate of stock selection and insufficient guidance for investors. For example, it cannot guide investors well when to buy or sell stocks, so as to achieve returns by buying low and selling high, thereby increasing the risk of investors investing in stocks. Summary of the invention
[0004] The purpose of the present invention is to solve the deficiencies of the above-mentioned prior art and provide a stock selection method and system based on data analysis, which is achieved through the following technical solutions:
[0005] In a first aspect, a stock selection method based on data analysis is provided, comprising the following steps: collecting historical stock data; obtaining multiple stock selection index factors based on the historical stock data to establish a first data set; dividing the historical stock data into main board data, GEM data and Sci-Tech Innovation Board data; executing S1-S9 for the main board data, GEM data and Sci-Tech Innovation Board data respectively; wherein, S1: collecting a first input value M; dividing the historical stock data of the M months closest to the current time into a test set, and dividing the remaining historical stock data into a training set; S2: obtaining the rate of return of each stock on each trading day based on the historical stock data in the training set; S3: determining multiple groups of stock selection criteria based on the training set; S4: obtaining each group The stock selection success rate corresponding to the stock selection criteria; S5: Collect the second input value N; Screen out multiple groups of stock selection criteria corresponding to all the stock selection success rates ranked in the top N numerically; S6: According to each group of stock selection criteria screened out, multiple stocks are screened out from the test set, and a first association relationship is established between each screened stock and a corresponding group of stock selection criteria; S7: Collect the third input value X; Get the rate of return of each stock screened out by S6, and screen out all stocks corresponding to all the rate of returns ranked in the top X numerically; S8: According to each stock screened out by S7 and the first association relationship, screen out one or more groups of high-quality stock selection criteria from all the stock selection criteria screened out by S5; S9: Select stocks according to the high-quality stock selection criteria.
[0006] Furthermore, the method for obtaining the rate of return of each stock on each trading day based on historical stock data is: execute steps A1 to A3 for each stock; wherein, step A1: obtain the opening price of the stock on each trading day; step A2: obtain the highest price of the stock within a preset number of days after each trading day; step A3: for each trading day, calculate the rate of return of the stock using a rate of return calculation model; the expression of the rate of return calculation model is: rate of return = (highest price - opening price) / opening price × 100.
[0007] Furthermore, S3 includes the following steps: obtaining the correlation coefficient between each stock selection index factor and the rate of return of each stock on each trading day to establish a second data set; collecting a fourth input value Y; filtering out all correlation coefficients ranked in the top Y in numerical order from the second data set to establish a third data set; filtering out the stock selection index factors corresponding to each correlation coefficient in the third data set from the first data set to establish a fourth data set; grouping all the stock selection index factors in the fourth data set in pairs to obtain multiple groups of stock selection index factors; filtering out multiple groups of stock selection criteria from the multiple groups of stock selection index factors.
[0008] Furthermore, the method of selecting multiple groups of stock selection criteria from multiple groups of stock selection index factors is as follows: executing steps B1 to B3 for each group of stock selection criteria; wherein, step B1: collecting the first value range and the first step length of one of the stock selection index factors; collecting the second value range and the second step length of another stock selection index factor; step B2: listing all values of one of the stock selection index factors according to the first value range and the first step length to obtain a first stock selection index factor set; listing all values of another stock selection index factor according to the second value range and the second step length to obtain a second stock selection index factor set; step B3: exhaustively enumerating all stock selection index factor combinations according to the first stock selection index factor set and the second stock selection index factor set to obtain multiple groups of stock selection criteria; wherein, the stock selection index factor combination includes the value range of one of the stock selection index factors and the value range of another stock selection index factor.
[0009] Furthermore, S4 includes the following steps: screening out all stocks matching each set of stock selection criteria from the training set to establish a fifth data set; in the fifth data set, establishing a third association relationship between each stock and a corresponding set of stock selection criteria; extracting the rate of return of each stock in the fifth data set, and screening out all stocks with a rate of return > 0 to establish a sixth data set; obtaining the ratio between the number of stocks in the sixth data set and the number of stocks in the fifth data set to obtain the stock selection success rate; establishing a fourth association relationship between the stock selection success rate and each stock in the sixth data set; and obtaining the stock selection success rate for each set of stock selection criteria based on the third association relationship and the fourth association relationship.
[0010] In a second aspect, a stock selection system based on data analysis is provided, including: a historical data collection module for collecting historical stock data; an indicator factor acquisition module for acquiring multiple stock selection indicator factors based on historical stock data to establish a first data set; a first data division module for dividing historical stock data into main board data, GEM data and Sci-Tech Innovation Board data; a yield acquisition module for acquiring the yield of each stock on each trading day based on the historical stock data in the training set; an input data collection module for collecting first input data M, second input data N, third input value X and fourth input value Y; a second data division module for dividing the historical stock data of the M months closest to the current time into a test set and the remaining historical stock data into a training set; a stock selection standard determination module for determining multiple groups of stock selection standards based on the training set; a stock selection success rate acquisition module for The method comprises the following steps: a first stock selection standard screening module is used to screen out multiple groups of stock selection standards corresponding to all the stock selection success rates ranked in the top N in numerical value; a first stock screening module is used to screen out multiple stocks from the test set according to each group of stock selection standards screened out; a first association establishment module is used to establish a first association between each screened stock and a corresponding group of stock selection standards; a second stock screening module is used to obtain the rate of return of each stock screened out by the first stock screening module, and screen out all the stocks corresponding to all the rate of returns ranked in the top X in numerical value; a second stock selection standard screening module is used to screen out one or more groups of high-quality stock selection standards from all the stock selection standards screened out by the first stock selection standard screening module according to each stock screened out by the second stock screening module and the first association; a stock selection module is used to select stocks according to high-quality stock selection standards.
[0011] Furthermore, the yield acquisition module includes: an opening price acquisition unit, which is used to obtain the opening price of the stock on each trading day; a maximum price acquisition unit, which is used to obtain the maximum price of the stock within a preset number of stock holding days after each trading day; a yield calculation unit, which is used to calculate the yield of the stock for each trading day using a yield calculation model; the expression of the yield calculation model is: yield = (highest price - opening price) / opening price × 100.
[0012] Furthermore, the stock selection criteria determination module includes: a correlation coefficient acquisition unit, which is used to obtain the correlation coefficient between each stock selection index factor and the yield of each stock in the training set on each trading day, and establish a second data set; a correlation coefficient screening unit, which is used to screen out all the correlation coefficients of the top Y in numerical order from the second data set, and establish a third data set; a stock selection index factor screening unit, which is used to screen out the stock selection index factors corresponding to each correlation coefficient in the third data set from the first data set, and establish a fourth data set; a stock selection index factor division unit, which is used to group all the stock selection index factors in the fourth data set in pairs, and obtain multiple groups of stock selection index factors; a stock selection criteria screening unit, which is used to screen out multiple groups of stock selection criteria from multiple groups of stock selection index factors.
[0013] Furthermore, the stock selection criteria screening unit includes: a value range and step size collection unit, which is used to collect the first value range and the first step size of one of the stock selection index factors; collect the second value range and the second step size of another stock selection index factor; a stock selection index factor listing unit, which is used to list all values of one of the stock selection index factors according to the first value range and the first step size to obtain a first stock selection index factor set; list all values of another stock selection index factor according to the second value range and the second step size to obtain a second stock selection index factor set; a stock selection criteria exhaustive unit, which is used to exhaustively list all stock selection index factor combinations according to the first stock selection index factor set and the second stock selection index factor set to obtain multiple groups of stock selection criteria; wherein the stock selection index factor combination includes the value range of one of the stock selection index factors and the value range of another stock selection index factor.
[0014] Furthermore, the stock selection success rate acquisition module includes: a first stock screening unit, used to screen out all stocks that match each group of stock selection criteria from the training set to establish a fifth data set; a first association relationship establishment unit, used to establish a third association relationship between each stock and a corresponding group of stock selection criteria in the fifth data set; a second stock screening unit, used to obtain the yield of each stock in the fifth data set, and screen out all stocks with a yield rate greater than 0 to establish a sixth data set; a first stock selection success rate acquisition unit, used to obtain the ratio between the number of stocks in the sixth data set and the number of stocks in the fifth data set to obtain the stock selection success rate; a second association relationship establishment unit, used to establish a fourth association relationship between the stock selection success rate and each stock in the sixth data set; a second stock selection success rate acquisition unit, used to obtain the stock selection success rate of each group of stock selection criteria based on the third association relationship and the fourth association relationship.
[0015] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0016] 1. Quantify the large and comprehensive stock information into separate stock selection index factors, which ultimately simplifies the difficulty of stock selection for stock investors.
[0017] 2. We exhaustively list all the stock selection criteria created by combining multiple stock selection index factors with the highest correlation coefficient with stock returns in the training data set, find out the stock selection criteria with high stock selection success rate, and verify these high-quality stock selection criteria with the test data set, thereby greatly improving the stock selection success rate;
[0018] 3. After the end of the most recent trading day, the stock data of the latest trading day will be included in the database, and the stocks with the highest probability of predicted increase will be selected according to the high-quality stock selection standards, which will greatly improve the success rate of stock selection.
[0019] 4. Regularly observe and count the stock selection success rate. If the rate drops by more than the set threshold, we will re-explore high-quality stock selection standards to keep the stock selection method effective.
[0020] 5. When providing advice to investors on stock investment decisions, the stock selection system does not need to recommend all stocks in the market with a rate of return greater than 0 (i.e., the stock price rises after the selected stocks are bought), but recommends stocks with the highest possibility of a rate of return greater than 0. Therefore, in order to achieve more accurate stock selection results, the present invention uses the ranking of stock selection success rates obtained by different stock selection criteria to select high-quality stock selection criteria with high success rates. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 A schematic diagram of a stock selection method based on data analysis provided by an embodiment of the present invention;
[0023] Figure 2 A schematic diagram of historical stock data including yield and amplitude provided for an embodiment of the present invention;
[0024] Figure 3 A schematic diagram of historical stock data including yield, amplitude and previous day's amplitude provided for an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.
[0026] In the following description, a large number of specific details are set forth in order to provide a thorough understanding of the present invention. However, it is apparent to one of ordinary skill in the art that these specific details are not necessarily employed to practice the present invention. In other embodiments, in order to avoid obscuring the present invention, well-known structures, circuits, materials, or methods are not specifically described.
[0027] Throughout the specification, references to "one embodiment," "an embodiment," "an example," or "an example" mean that a particular feature, structure, or characteristic described in conjunction with the embodiment or example is included in at least one embodiment of the present invention. Therefore, the phrases "one embodiment," "an embodiment," "an example," or "an example" appearing in various places throughout the specification do not necessarily all refer to the same embodiment or example. In addition, particular features, structures, or characteristics may be combined in one or more embodiments or examples in any suitable combination and / or sub-combination. In addition, it will be appreciated by those of ordinary skill in the art that the figures provided herein are for illustrative purposes and that the figures are not necessarily drawn to scale. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0028] In the description of the present invention, the directions or positional relationships indicated by terms such as “front”, “rear”, “left”, “right”, “up”, “down”, “vertical”, “horizontal”, “high”, “low”, “inside” and “outside” are based on the directions or positional relationships shown in the accompanying drawings and are only for the convenience of describing the present invention and simplifying the description. They do not indicate or imply that the device or element referred to must have a specific direction, be constructed and operated in a specific direction. Therefore, they should not be understood as limiting the scope of protection of the present invention.
[0029] Embodiment: The first aspect of this embodiment provides a stock selection method based on data analysis. This method reads and pre-processes historical stock data through the database of the stock exchange; then calculates all stock selection index factors; finally, digs out high-quality stock selection criteria with a high stock selection success rate, and uses the high-quality stock selection criteria to select stocks. The implementation process of this method is as follows Figure 1 As shown, the following steps are included:
[0030] Step 1: Collect historical stock data.
[0031] The specific method is: use Python to read all stock data including the main board, GEM and Sci-Tech Innovation Board before the current time from the database of the stock exchange. The collected historical stock data includes K-line data (opening price, highest price, lowest price, closing price, etc.) and basic indicators (turnover rate, trading volume, transaction amount, rise and fall, amplitude, circulating market value, etc.).
[0032] Step 2: Preprocess the collected historical stock data.
[0033] Data preprocessing includes: removing extreme values in historical stock data, standardizing historical stock data, and removing suspended stocks.
[0034] Step 3: Obtain multiple stock selection index factors based on historical stock data and establish the first data set.
[0035] The stock selection factors are calculated through historical stock data. The calculated stock selection index factors include: technical index factors (such as KDJ index, MACD index, etc.), market index factors (such as average turnover rate, volume ratio, rise and fall within 5 days, etc.), financial index factors (such as per share index, profitability index, etc.), and capital flow index factors (such as net amount of large orders, main force strength, etc.).
[0036] Step 4: Divide historical stock data into main board data, ChiNext data, and Science and Technology Innovation Board data.
[0037] Step 5: Execute steps 5.1 to 5.9 for the main board data, ChiNext data, and STAR Market data respectively.
[0038] Step 5.1: Collect the first input value M; divide the historical stock data of the M months closest to the current time into the test set, and divide the remaining historical stock data into the training set.
[0039] The first input value M is the dividing line between the test set and the training set set by the user according to the actual situation of the collected historical stock data.
[0040] Step 5.2: Obtain the return rate of each stock on each trading day based on the historical stock data in the training set.
[0041] The specific method is: perform steps 5.21 to 5.23 for each stock.
[0042] Step 5.21: Get the stock's opening price on each trading day.
[0043] In the historical stock data of the training set, each stock contains the opening price, highest price, lowest price, closing price and other data on each trading day. Step 5.21 is to obtain the opening price of the stock on each trading day in advance from the historical stock data of the training set.
[0044] For example: Figure 2As shown, taking the stock code 000001 as an example, the opening prices (unit: yuan) of this stock on each trading day (excluding weekends) from January 2, 2024 to January 10, 2024 are: 8.67, 8.67, 8.47, 8.38, 8.51, 8.44 and 8.44 respectively.
[0045] Step 5.22: Get the highest price of the stock within the preset number of days after the purchase date.
[0046] It should be noted in advance that: (1) Before this step, the number of stock holding days d set by the user must be collected in advance. The number of stock holding days d means that the user sells the stock on the dth day at the latest after buying the stock, that is, the number of stock holding days d includes the purchase date, and the preset number of days after the purchase date described in this step is d-1; (2) The highest price described in this step refers to the highest price of all stocks within the preset number of days after the purchase date.
[0047] The following combination Figure 2 Let's take an example:
[0048] (1) If a user buys stock with stock code 000001 on January 1, 2024, and the number of days set by the user to hold the stock is 5 days, then the highest price within 4 days after the purchase date January 1, 2024 is the highest value among 8.70, 8.70, 8.47 and 8.72, which is 8.72.
[0049] (2) If a user buys stock with the stock code 000001 on the trading day of January 2, 2024, and also sets the stock holding period to 5 days, then the highest price within 4 days after the purchase date of January 2, 2024 is the highest value among 8.70, 8.47, 8.72 and 8.58, which is also 8.72.
[0050] (3) If a user buys stock with the stock code 000001 on the trading day of January 3, 2024, and also sets the stock holding period to 5 days, then the highest price within 4 days after the purchase date of January 3, 2024 is the highest value among 8.47, 8.72, 8.58 and 8.47, which is also 8.72.
[0051] (4) If a user buys stock with the stock code 000001 on the trading day of January 4, 2024, and also sets the stock holding period to 5 days, then the highest price within 4 days after the purchase date of January 4, 2024 is the highest of 8.72, 8.58, 8.47 and 8.47, which is also 8.72.
[0052] (5) If a user buys stock with the stock code 000001 on the trading day of January 5, 2024, and also sets the stock holding period to 5 days, then the highest price within 4 days after the purchase date of January 5, 2024 is 8.58, 8.47, 8.47 and 8.50, whichever is the highest, that is, 8.58.
[0053] For each trading day on and after January 8, 2024, the method for obtaining the highest price is the same as above and will not be repeated here.
[0054] Step 5.23: For each trading day, use the yield calculation model to calculate the stock yield; the expression of the yield calculation model is: yield = (highest price - opening price) / opening price × 100.
[0055] The following continues to combine Figure 2 Let's take an example:
[0056] (1) If the user buys the stock with the stock code 000001 on the trading day of January 1, 2024, the rate of return calculated in this step does not include the rate of return on January 1, 2024, but starts from January 2, 2024. If the number of days the user sets the stock to be held is 5 days, then according to the highest price of 8.72 on January 1, 2024 and the opening price of 8.67 on January 2, 2024 obtained in step 5.22, then according to the above rate of return calculation model, its rate of return = (8.72-8.67) / 8.67×100=0.57.
[0057] (2) If the user buys the stock with the stock code 000001 on the trading day of January 2, 2024, the rate of return calculated in this step does not include the rate of return on January 2, 2024, but starts from January 3, 2024. If the number of days the user sets the stock to be held is 5 days, then according to the highest price of 8.72 on January 2, 2024 and the opening price of 8.67 on January 3, 2024 obtained in step 5.22, then according to the above rate of return calculation model, its rate of return = (8.72-8.67) / 8.67×100=0.57.
[0058] (3) If the user buys the stock with the stock code 000001 on the trading day of January 3, 2024, the rate of return calculated in this step does not include the rate of return on January 3, 2024, but starts from January 4, 2024. If the number of days the user sets the stock to be held is 5 days, then according to the highest price of 8.72 on January 3, 2024 and the opening price of 8.47 on January 4, 2024 obtained in step 5.22, then according to the above rate of return calculation model, its rate of return = (8.72-8.47) / 8.47×100 = 2.95.
[0059] (4) If the user buys the stock with the stock code 000001 on the trading day of January 4, 2024, the rate of return calculated in this step does not include the rate of return on January 4, 2024, but starts from January 5, 2024. If the number of days the user sets the stock to hold is 5 days, then according to the highest price of 8.58 on January 4, 2024 and the opening price of 8.38 on January 4, 2024 obtained in step 5.22, then according to the above rate of return calculation model, its rate of return = (8.58-8.38) / 8.38×100=2.38.
[0060] For each trading day on and after January 5, 2024, the method for obtaining the yield is the same as above and will not be repeated here.
[0061] It should also be noted that the yield of each stock on each trading day is obtained based on historical stock data as described in step 5.2. Python can be used to batch calculate the yield of each trading day according to the above method.
[0062] Step 5.3: Determine multiple sets of stock selection criteria based on the training set.
[0063] The specific method is:
[0064] Step 5.31: Obtain the correlation coefficient between each stock selection index factor and the return rate of each stock on each trading day to establish the second data set.
[0065] The following combination Figure 3 , the calculation method of the correlation coefficient in this step is described as follows:
[0066] Taking the stock selection index factor "amplitude" as an example, if the stock with the stock code 000001 is bought on the trading day January 3, 2024, the user refers to the amplitude corresponding to each trading day before January 3, 2024 when buying the stock. Therefore, this step first extracts the amplitude data corresponding to each trading day before January 3, 2024 to obtain the amplitude sequence; then, each trading day before January 3, 2024 corresponds to the yield calculated in step 5.2, so that the yield sequence can be established; finally, the amplitude sequence and the yield sequence are substituted into the corr() function provided by Python to calculate the correlation coefficient between the amplitude and the yield.
[0067] The calculation method of the correlation coefficient is the same for each other stock selection index factor. Of course, other feasible methods can also be used to calculate the correlation coefficient between each stock selection index factor and the return rate of each stock on each trading day.
[0068] Step 5.32: Collect the fourth input value Y; filter out all the correlation coefficients of the top Y values from the second data set to establish a third data set.
[0069] The value Y is set by the user based on the current stock market volatility, with the goal of screening out higher correlation coefficients.
[0070] Step 5.33: Filter out the stock selection index factors corresponding to each correlation coefficient in the third data set from the first data set to establish the fourth data set.
[0071] The purpose of this step is to screen out the stock selection index factors with a high correlation with high yield from the stock selection index factors obtained in step 3, so as to provide favorable reference indicators for stock selection.
[0072] Step 5.34: Group all the stock selection index factors in the fourth data set into groups of two each to obtain multiple groups of stock selection index factors.
[0073] The purpose of this step is to pair the multiple stock selection index factors obtained in step 5.33 using an exhaustive method to obtain all possible combinations of stock selection index factors.
[0074] Step 5.35: Select multiple groups of stock selection criteria from multiple groups of stock selection index factors. The specific method is:
[0075] For each set of stock selection criteria, follow these steps:
[0076] First, collect the value range and step size of one of the stock selection index factors in the stock selection index factor combination, and record them as the first value range and the first step size; collect the value range and the step size of another stock selection index factor in the stock selection index factor combination, and record them as the second value range and the second step size.
[0077] It should be noted that the value range of the stock selection index factor can be obtained based on the collected historical stock data, and the step size is set by the user according to the actual situation. For example, the value range of the amplitude is [0,20), recorded as the first value range; the step size of the amplitude is 1, recorded as the first step size; the value range of the increase or decrease is [-10,10), recorded as the second value range; the step size of the amplitude is 1, recorded as the second step size.
[0078] Then, all values of one of the stock selection index factors are listed according to the first value range and the first step length to obtain a first stock selection index factor set; all values of another stock selection index factor are listed according to the second value range and the second step length to obtain a second stock selection index factor set.
[0079] For example: suppose the stock selection index factor combination (amplitude, price change) consists of "amplitude" and "rate of increase or decrease". Then all the values of amplitude listed are [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19], which is the amplitude set; all the values of price change listed are [-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9], which is the price change set.
[0080] Finally, based on the amplitude set and the price increase / decrease set, Python is used to exhaustively enumerate all combinations of amplitude and price increase / decrease, and multiple sets of stock selection criteria for amplitude and price increase / decrease are obtained.
[0081] For example, one set of stock selection criteria may be (amplitude>=5.0, rise / fall>=2.0).
[0082] Step 5.4: Obtain the stock selection success rate corresponding to each set of stock selection criteria.
[0083] The specific method is:
[0084] Step 5.41: Filter out all stocks that match each set of stock selection criteria from the training set to establish the fifth data set.
[0085] Based on the set of stock selection criteria listed in the above steps (amplitude>=5.0, rise and fall>=2.0), if one of the stocks in the training set has an amplitude of ≥5.0 and a rise and fall of ≥2.8 on a certain trading day, then the stock meets the reorganized stock selection criteria. All stocks that meet each set of stock selection criteria are screened out according to the method described in step 6.1.
[0086] Step 5.42: From all the yields calculated in step 5.2, extract the yield of each stock in the fifth data set, and filter out all stocks with a yield > 0 to establish the sixth data set.
[0087] Step 5.43: Obtain the ratio between the number of stocks in the sixth data set and the number of stocks in the fifth data set to obtain the stock selection success rate.
[0088] Step 5.44: Establish the fourth correlation between the stock selection success rate and each stock in the sixth data set.
[0089] Step 5.45: Obtain the stock selection success rate for each set of stock selection criteria based on the third correlation and the fourth correlation.
[0090] Step 5.5: Collect the second input value N; filter out multiple groups of stock selection criteria corresponding to all stock selection success rates ranked top N in numerical value.
[0091] Similarly, the value N is set by the user based on the current stock market volatility, with the goal of screening out stock selection criteria that are more conducive to stock selection reference.
[0092] Step 5.6: Select multiple stocks from the test set according to each set of selected stock selection criteria, and establish a first association relationship between each selected stock and the corresponding set of stock selection criteria.
[0093] Step 5.7: Collect the third input value X; obtain the rate of return of each stock screened out in step 8, and screen out all stocks corresponding to all rate of returns ranked in the top X in value.
[0094] Step 5.8: Based on each stock screened out in step 9 and the first association, select one or more sets of high-quality stock selection criteria from all the stock selection criteria screened out in step 7.
[0095] Step 5.9: Select stocks according to the quality stock selection criteria.
[0096] In addition, this method also regularly observes and compiles statistics on the success rate of stock selection. If the decline exceeds the set threshold, the above steps 1 to 11 will be repeated to re-explore high-quality stock selection criteria.
[0097] Corresponding to the stock selection method based on data analysis provided in the first aspect above, the second aspect of this embodiment provides a stock selection system based on data analysis, including: a historical data collection module for collecting historical stock data; an indicator factor acquisition module for acquiring multiple stock selection indicator factors based on historical stock data to establish a first data set; a yield acquisition module for batch calculating stock yields based on historical stock data; a first data partitioning module for dividing historical stock data into main board data, GEM data and Sci-Tech Innovation Board data; a second data partitioning module for dividing historical stock data of multiple months closest to the current time into a test set and dividing the remaining data into a training set; a stock selection standard determination module for determining multiple groups of stock selection standards based on the training set; a stock selection success rate acquisition module for acquiring the success rate of each stock selection. A stock selection success rate corresponding to a set of stock selection criteria; a first stock selection criteria screening module, used to screen out one or more sets of stock selection criteria with the highest stock selection success rate; a first stock screening module, used to screen out multiple stocks from a test set according to each set of screened stock selection criteria; a first association establishment module, used to establish a first association between each screened stock and a corresponding set of stock selection criteria; a second stock screening module, used to obtain the rate of return of each stock screened by the stock screening module, and screen out all stocks with a rate of return greater than a threshold; a second stock selection criteria screening module, used to screen out one or more sets of high-quality stock selection criteria from all stock selection criteria screened by S4 according to each stock screened by the second stock screening module and the first association; a stock selection module, used to select stocks according to high-quality stock selection criteria.
[0098] Furthermore, the stock selection criteria determination module includes: a correlation coefficient acquisition unit, which is used to obtain the correlation coefficient between the yield of each stock in the training set and each stock selection index factor, and establish a second data set; a correlation coefficient screening unit, which is used to screen out all correlation coefficients with the largest values from the second data set, and establish a third data set; a stock selection index factor screening unit, which is used to screen out stock selection index factors corresponding to each correlation coefficient in the third data set from the first data set, and establish a fourth data set; a stock selection index factor division unit, which is used to group all stock selection index factors in the fourth data set into groups of two by two, and obtain multiple groups of stock selection index factors; a stock selection criteria screening unit, which is used to screen out multiple groups of stock selection criteria from multiple groups of stock selection index factors.
[0099] Furthermore, the stock selection success rate acquisition module includes: a first stock screening unit, used to screen out all stocks that match each group of stock selection criteria from the training set to establish a fifth data set; a first association relationship establishment unit, used to establish a third association relationship between each stock and a corresponding group of stock selection criteria in the fifth data set; a second stock screening unit, used to obtain the yield of each stock in the fifth data set, and screen out all stocks with a yield rate greater than 0 to establish a sixth data set; a first stock selection success rate acquisition unit, used to obtain the ratio between the number of stocks in the sixth data set and the number of stocks in the fifth data set to obtain the stock selection success rate; a second association relationship establishment unit, used to establish a fourth association relationship between the stock selection success rate and each stock in the sixth data set; a second stock selection success rate acquisition unit, used to obtain the stock selection success rate of each group of stock selection criteria based on the third association relationship and the fourth association relationship.
[0100] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A stock selection method based on data analysis, characterized in that: The following steps are involved: Collect historical stock data; Acquire multiple stock selection index factors based on historical stock data to establish a first data set; Divide historical stock data into main board data, GEM data and Sci-Tech Innovation Board data; Execute S1-S9 for the main board data, ChiNext data, and Science and Technology Innovation Board data respectively; in, S1: Collect the first input value M; divide the historical stock data of the M months closest to the current time into the test set, and divide the remaining historical stock data into the training set; S2: Obtain the rate of return of each stock on each trading day based on the historical stock data in the training set; S3: Determine multiple sets of stock selection criteria based on the training set; S4: Obtain the stock selection success rate corresponding to each set of stock selection criteria; S5: Collect the second input value N; filter out multiple groups of stock selection criteria corresponding to all stock selection success rates ranked top N by value; S6: screening multiple stocks from the test set according to each group of screened stock selection criteria, and establishing a first association relationship between each screened stock and the corresponding group of stock selection criteria; S7: Collect the third input value X; obtain the rate of return of each stock screened out in S6, and screen out all stocks corresponding to all the rate of returns ranked in the top X; S8: based on each stock screened by S7 and the first association, one or more sets of high-quality stock selection criteria are screened from all stock selection criteria screened by S5; S9: Select stocks according to the quality stock selection criteria.
2. A stock selection method based on data analysis according to claim 1, characterized in that: The method for obtaining the rate of return of each stock on each trading day based on historical stock data is as follows: performing steps A1 to A3 for each stock; wherein, Step A1: Get the stock's opening price on each trading day; Step A2: Get the highest price of the stock within a preset number of days after each trading day; Step A3: For each trading day, the rate of return of the stock is calculated using the rate of return calculation model; the expression of the rate of return calculation model is: rate of return = (highest price - opening price) / opening price × 100.
3. A stock selection method based on data analysis according to claim 1, characterized in that: S3 includes the following steps: Obtain the correlation coefficient between each stock selection index factor and the return rate of each stock on each trading day to establish a second data set; Collecting a fourth input value Y; Filter out all the correlation coefficients of the top Y in numerical ranking from the second data set to establish a third data set; Screening out the stock selection index factors corresponding to each correlation coefficient in the third data set from the first data set to establish a fourth data set; Group all the stock selection index factors in the fourth data set into groups of two by two to obtain multiple groups of stock selection index factors; Filter out multiple sets of stock selection criteria from multiple sets of stock selection indicator factors.
4. A stock selection method based on data analysis according to claim 3, characterized in that: The method of selecting multiple groups of stock selection criteria from multiple groups of stock selection index factors is as follows: Steps B1 to B3 are performed for each set of stock selection criteria; wherein, Step B1: Collect the first value range and the first step length of one of the stock selection index factors; collect the second value range and the second step length of another stock selection index factor; Step B2: enumerate all values of one of the stock selection index factors according to the first value range and the first step length to obtain a first stock selection index factor set; enumerate all values of another stock selection index factor according to the second value range and the second step length to obtain a second stock selection index factor set; Step B3: Based on the first stock selection index factor set and the second stock selection index factor set, all stock selection index factor combinations are exhaustively enumerated to obtain multiple sets of stock selection criteria; wherein the stock selection index factor combination includes the value range of one stock selection index factor and the value range of another stock selection index factor.
5. A stock selection method based on data analysis according to claim 2, characterized in that: S4 includes the following steps: All stocks matching each set of stock selection criteria are selected from the training set to establish the fifth data set; In the fifth data set, a third association relationship is established between each stock and a corresponding set of stock selection criteria; Extract the yield of each stock in the fifth data set, and filter out all stocks with yields greater than 0 to establish the sixth data set; Obtaining the ratio between the number of stocks in the sixth data set and the number of stocks in the fifth data set to obtain a stock selection success rate; Establishing a fourth correlation between the stock selection success rate and each stock in the sixth data set; The stock selection success rate of each set of stock selection criteria is obtained according to the third correlation relationship and the fourth correlation relationship.
6. A stock selection system based on data analysis, characterized in that: include: Historical data collection module, used to collect historical stock data; An index factor acquisition module is used to acquire multiple stock selection index factors according to historical stock data and establish a first data set; The first data division module is used to divide the historical stock data into main board data, GEM data and Sci-Tech Innovation Board data; The yield acquisition module is used to obtain the yield of each stock on each trading day based on the historical stock data in the training set; An input data acquisition module, used for acquiring first input data M, second input data N, third input value X and fourth input value Y; The second data partitioning module is used to partition the historical stock data of the M months closest to the current time into a test set, and to partition the remaining historical stock data into a training set; A stock selection criteria determination module is used to determine multiple sets of stock selection criteria based on a training set; The stock selection success rate acquisition module is used to obtain the stock selection success rate corresponding to each set of stock selection criteria; The first stock selection criteria screening module is used to screen out multiple groups of stock selection criteria corresponding to all stock selection success rates ranked top N by value; A first stock screening module is used to screen multiple stocks from the test set according to each group of screened stock selection criteria; A first association relationship establishment module, used to establish a first association relationship between each screened stock and a corresponding set of stock selection criteria; The second stock screening module is used to obtain the rate of return of each stock screened by the first stock screening module, and screen out all stocks corresponding to all the rate of returns ranked in the top X; A second stock selection criteria screening module is used to screen out one or more groups of high-quality stock selection criteria from all stock selection criteria screened by the first stock selection criteria screening module according to each stock screened by the second stock screening module and the first association relationship; The stock selection module is used to select stocks according to high-quality stock selection criteria.
7. A stock selection system based on data analysis according to claim 6, characterized in that: The yield acquisition module includes: The opening price acquisition unit is used to obtain the opening price of the stock on each trading day; The highest price acquisition unit is used to acquire the highest price of the stock within a preset number of stock holding days after each trading day; The yield calculation unit is used to calculate the yield of the stock for each trading day using the yield calculation model; the expression of the yield calculation model is: yield = (highest price - opening price) / opening price × 100.
8. A stock selection system based on data analysis according to claim 6, characterized in that: The stock selection criteria determination module includes: A correlation coefficient acquisition unit is used to acquire the correlation coefficient between each stock selection index factor and the rate of return of each stock in the training set on each trading day, and establish a second data set; A correlation coefficient screening unit is used to screen out all the correlation coefficients of the top Y values from the second data set to establish a third data set; A stock selection index factor screening unit, used to screen out the stock selection index factors corresponding to each correlation coefficient in the third data set from the first data set, and establish a fourth data set; A stock selection index factor division unit is used to group all the stock selection index factors in the fourth data set into groups in pairs to obtain multiple groups of stock selection index factors; The stock selection criteria screening unit is used to screen out multiple groups of stock selection criteria from multiple groups of stock selection index factors.
9. A stock selection system based on data analysis according to claim 8, characterized in that: The stock selection criteria screening unit includes: The value range and step length acquisition unit is used to acquire the first value range and the first step length of one of the stock selection index factors; and to acquire the second value range and the second step length of another stock selection index factor; The stock selection index factor enumeration unit is used to enumerate all values of one of the stock selection index factors according to the first value range and the first step length to obtain a first stock selection index factor set; and enumerate all values of another stock selection index factor according to the second value range and the second step length to obtain a second stock selection index factor set; The stock selection criteria exhaustive unit is used to exhaustively enumerate all stock selection index factor combinations based on the first stock selection index factor set and the second stock selection index factor set to obtain multiple sets of stock selection criteria; wherein the stock selection index factor combination includes the value range of one stock selection index factor and the value range of another stock selection index factor.
10. A stock selection system based on data analysis according to claim 7, characterized in that: The stock selection success rate acquisition module includes: A first stock screening unit is used to screen out all stocks matching each set of stock selection criteria from the training set to establish a fifth data set; A first association relationship establishing unit, used to establish a third association relationship between each stock and a corresponding set of stock selection criteria in the fifth data set; The second stock screening unit is used to obtain the rate of return of each stock in the fifth data set, and screen out all stocks with a rate of return greater than 0 to establish a sixth data set; A first stock selection success rate acquisition unit, used to acquire a ratio between the number of stocks in the sixth data set and the number of stocks in the fifth data set, to obtain a stock selection success rate; A second association relationship establishing unit, used to establish a fourth association relationship between the stock selection success rate and each stock in the sixth data set; The second stock selection success rate acquisition unit is used to acquire the stock selection success rate of each group of stock selection criteria according to the third association relationship and the fourth association relationship.