WO2019205384A1 - 电子装置、基于机器学习的股票择时方法及存储介质 - Google Patents
电子装置、基于机器学习的股票择时方法及存储介质 Download PDFInfo
- Publication number
- WO2019205384A1 WO2019205384A1 PCT/CN2018/102224 CN2018102224W WO2019205384A1 WO 2019205384 A1 WO2019205384 A1 WO 2019205384A1 CN 2018102224 W CN2018102224 W CN 2018102224W WO 2019205384 A1 WO2019205384 A1 WO 2019205384A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- trend
- trading day
- objects
- trading
- factor value
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/23—Clustering techniques
- G06F18/232—Non-hierarchical techniques
- G06F18/2321—Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions
- G06F18/23213—Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions with fixed number of clusters, e.g. K-means clustering
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
- G06N3/084—Backpropagation, e.g. using gradient descent
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
Definitions
- the present application relates to the field of financial market analysis, and in particular, to an electronic device, a machine learning-based stock timing method, and a storage medium.
- timing trading refers to using some method to judge the investment target, such as stocks, futures, foreign exchange, etc., within a predetermined period of time, and according to the trend A means of trading that determines the point of sale.
- the analysis of stock timing trading requires professionals to study the corresponding trend timing indicators, such as stock trend timing indicators including MA (double moving average), DMA (average line difference), TRIX (triple index smooth movement).
- MA double moving average
- DMA average line difference
- TRIX triple index smooth movement
- the present application proposes an electronic device, a machine learning-based stock timing method and a storage medium, which can improve the efficiency and accuracy of stock timing transaction analysis.
- the present application provides an electronic device including a memory and a processor coupled to the memory, the processor for executing a machine learning based stock timing program stored on the memory, The machine learning-based stock timing program is executed by the processor to implement the following steps:
- the preset type index factors of each acquired trading day are respectively analyzed according to the timing analysis strategy model completed by the pre-training, so as to output the trend factor values corresponding to each trading day;
- A30 Perform cluster analysis on the trend factor values corresponding to each trading day according to a predetermined clustering algorithm to obtain a trend category corresponding to the trend factor value of each trading day;
- A40 Determine a timing trading strategy according to the trend category corresponding to the obtained trend factor value of each trading day.
- the present application also proposes a machine learning-based stock timing method, the method comprising the following steps:
- S400 Determine a timing trading strategy according to the trend category corresponding to the obtained trend factor value of each trading day.
- the present application further provides a computer readable storage medium storing a machine learning based stock timing program, the machine learning based stock timing program being executable by at least one processor, Taking the at least one processor to perform the following steps:
- the preset type index factors of each acquired trading day are respectively analyzed to output the trend factor values corresponding to each trading day;
- the timing trading strategy is determined according to the trend category corresponding to the trend factor value of each trading day obtained.
- the electronic device, the machine learning-based stock timing method and the storage medium proposed by the present application firstly obtain a preset corresponding to each trading day of the predetermined stock market index within a preset time period.
- Type indicator factor then, according to the pre-trained timing analysis model, the preset type index factors of each transaction day are analyzed to output the trend factor values corresponding to each trading day; and then according to a predetermined clustering algorithm
- the trend factor values corresponding to each trading day are clustered to obtain the trend category corresponding to the trend factor value of each trading day; finally, the timing trading strategy is determined according to the trend category corresponding to the trend factor value of each trading day.
- FIG. 1 is a schematic diagram of an optional hardware architecture of an electronic device proposed by the present application.
- FIG. 2 is a schematic diagram of a stock timing program module based on machine learning in an embodiment of an electronic device of the present application
- FIG. 3 is a flow chart of an implementation of a preferred embodiment of a machine learning based stock timing method of the present application.
- the electronic device 10 may include, but is not limited to, a memory 11, a processor 12, and a network interface 13 communicably connected to each other through a communication bus 14. It should be noted that FIG. 1 only shows the electronic device 10 having the components 11-14, but it should be understood that not all illustrated components may be implemented, and more or fewer components may be implemented instead.
- the memory 11 includes at least one type of computer readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (for example, SD or DX memory, etc.), a random access memory (RAM), and a static memory.
- the memory 11 may be an internal storage unit of the electronic device 10, such as a hard disk or memory of the electronic device 10.
- the memory 11 may also be an outsourced storage device of the electronic device 10, such as a plug-in hard disk equipped on the electronic device 10, a smart memory card (SMC), and a secure digital (Secure Digital, SD) ) cards, flash cards, etc.
- the memory 11 can also include both an internal storage unit of the electronic device 10 and an external storage device thereof.
- the memory 11 is generally used to store an operating system installed on the electronic device 10 and various types of application software, such as a stock learning time-based program based on machine learning. Further, the memory 11 can also be used to temporarily store various types of data that have been output or are to be output.
- Processor 12 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments.
- the processor 12 is typically used to control the overall operation of the electronic device 10.
- the processor 12 is configured to run program code or processing data stored in the memory 11, such as a running machine learning based stock timing program.
- Network interface 13 may include a wireless network interface or a wired network interface, which is typically used to establish a communication connection between electronic device 10 and other electronic devices.
- Communication bus 14 is used to implement a communication connection between components 11-13.
- Figure 1 shows only the electronic device 10 with components 11-14 and a machine learning based stock timing program, but it should be understood that not all illustrated components may be implemented, alternative implementations may be more or less s component.
- the electronic device 10 may further include a user interface (not shown in FIG. 1), and the user interface may include a display, an input unit such as a keyboard, wherein the user interface may further include a standard wired interface, a wireless interface, and the like.
- the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED touch device, or the like. Further, the display may also be referred to as a display screen or display unit for displaying information processed in the electronic device 10 and a user interface for displaying visualizations.
- the pre-determined stock market index refers to stock market reference data that has strong liquidity, large scale, can represent the stock price comprehensive change, and can provide investors with an authoritative investment direction, such as SSE 50, Shanghai and Shenzhen. 300, or commonly used reference data such as CSI 500.
- SSE 50 corresponds to 50 large-cap stocks in Shanghai stock market
- CSI 300 corresponds to 300 blue-chip stocks outside the market value of 30 cities, of which only a few are coincident with SSE 50, such as Pufa, Unicom, etc.
- 500 corresponds to 500 stocks with moderate market capitalization in the two cities, many of which coincide with the Shanghai and Shenzhen 300.
- the preset type index factor is a macro indicator that affects a predetermined stock market index.
- the debt yield of China Bond is 10 years - the 10-year period of China Bond National Debt can be seen from the general trend.
- AAA China Bond
- the market will also start to rise and the small market will go down.
- the indicator goes down and the small market goes up. From the chart, the spread of the spread has recently declined, indicating that the market is starting to decline and the small-cap style is dominant.
- the risk premium and the dividend yield are inversely related.
- the stock market's yield is higher than the bond market, the funds will flow from the bond market to the stock market.
- the stock index yield is lower than the bond market, the funds will flow from the stock market to the bond market.
- MACD Histogram When the MACD Histogram turns from negative to positive, the multi-signal appears, the MACD changes from positive to negative, and the short signal appears;
- RSRS indicator when zscore>0.7 and the closing price of MA(20) on the same day > the closing price of MA(20) in the past three days, buy signal; when zscore ⁇ -0.7 and the closing price of MA(20) on the same day ⁇ the past three days MA (20) When the closing price is sold, the signal is sold.
- the Shanghai and Shenzhen 300 actively buy the amount, the premium rate is >0, the market is optimistic; the premium rate is ⁇ 0, the market is pessimistic; historically, the premium rate hits 5 o'clock, it is a sell signal; when the premium rate hits -1, it is a buy signal.
- the preset time period may be classified into ultra short-term, short-term, medium-term, long-term, and ultra-long-term, etc., for example, in this embodiment, the predefined ultra-short-term included transaction
- the number of days is less than or equal to 5, and the number of trading days included in the short-term is greater than 5 and less than or equal to 10.
- the number of trading days included in the medium-term is greater than 10 and less than or equal to 15, and the number of trading days included in the long-term is greater than 15 days and less than one year.
- the number of trading days included in the long term is greater than one year.
- time series data in ultra-short-term and short-term time periods have a good fitting effect, but contain less information and can be used for ultra-short-line timing reference; the data of medium- and long-term time series contains There is more information, but the dependence of data between time series is not obvious in the short term, so the fitting effect is not super short-term and short-term, so the macroeconomic situation and economic trend are usually described by ultra-long-term data, and combined with medium and long-term data, Long-term timing reference.
- the preset type index factors of each acquired trading day are respectively analyzed according to the timing analysis strategy model completed by the pre-training, so as to output the trend factor values corresponding to each trading day;
- the pre-trained timing strategy model adopts the idea of machine learning, and uses a preset type index factor of each trading day in a preset time period as an input of a machine learning model, and outputs corresponding to each trading day through machine learning prediction.
- Trend factor value a preset type index factor of each trading day in a preset time period as an input of a machine learning model.
- the pre-trained completion timing strategy model is a cyclic neural network (RNN), and the cyclic neural network is used as a machine learning algorithm.
- the cyclic neural network includes an input layer, a hidden layer (state learning layer), and an output layer; in this embodiment, the output layer is configured to output a relative profit rate within a preset time period, specifically, a relative profit rate
- the rate of return associated with the total return of the stock market over a predetermined period of time in this embodiment, the relative rate of return is used to train the inverse update gradient of the machine learning model, and the different factors corresponding to each trading day of the hidden layer output The value is the trend factor value corresponding to each trading day output by the timing strategy model.
- the hidden layer of the cyclic neural network includes multiple nodes, and the interconnection between the nodes acts as a key layer of the entire machine learning model.
- the characteristics of the input layer input pass through the hidden layer training learning transformation and reach the output layer.
- the hidden layer which contains multiple layers of neurons, it can be regarded as a neural network transmitted in time. Its depth is the length of time. Usually, as the depth deepens, the phenomenon of “gradient disappearance” will appear. At time t, the gradient it produces disappears after several layers of history on the time axis.
- the neural network of the layer performs training learning corresponding to the preset type indicators of each trading day input by the input layer, and obtains the factor values corresponding to each trading day, and outputs the respective factor values at the corresponding nodes.
- the timing strategy model used in this scheme is not used for the prediction of the rate of return, and is closer to a generation model in thought.
- the output of the timing strategy model involved in this scenario is a classification of hidden layer values corresponding to each trading day, which is equivalent to generating a label for each trading day.
- A30 Perform cluster analysis on the trend factor values corresponding to each trading day according to a predetermined clustering algorithm to obtain a trend category corresponding to the trend factor value of each trading day;
- the predetermined clustering algorithm is a k-means clustering algorithm
- the k-means clustering algorithm is one of the more classical clustering algorithms in the partitioning method. Because of its high efficiency, the algorithm is widely used in clustering large-scale data. At present, many algorithms are extended and improved around the algorithm.
- the k-means algorithm uses k as a parameter to divide n objects into k clusters, so that the clusters have higher similarity and the similarity between clusters is lower.
- the processing of the k-means algorithm is as follows: First, assuming that there are n trading days, the trend factor values corresponding to k transaction days are randomly selected as objects, where n>k, and n,k are Is a positive integer; each object initially represents the average or center of a cluster; for each of the remaining objects, it is assigned to the nearest cluster based on its distance from the center of each cluster; then each cluster is recalculated average value. This process is repeated until the criterion function converges.
- the criterion function uses a squared error criterion, which is defined as follows:
- E is the sum of the squared errors of all objects consisting of the trend factor values corresponding to n trading days
- p is the point in the space that needs to be clustered.
- mi is the average of the cluster Ci.
- the objective function makes the generated cluster as compact and independent as possible, and the distance metric used is the Euclidean distance, although other distance metrics can be used.
- the algorithm flow of the k-means clustering algorithm is as follows: input the database containing n objects and the number k of clusters.
- the trend factor values corresponding to n transaction days are taken as the above n objects, and the preset k The class trend category is used as the number of clusters; k clusters are output to minimize the square error criterion.
- the method specifically includes: selecting a trend factor value of k transaction days as an initial cluster center; assigning each object (re) to the most similar cluster according to the average value of the objects in the cluster; updating the average of the clusters The value, which is the average of the objects in each cluster; until the calculation no longer changes, the cluster ends.
- the common trend categories can be visually represented in different K-line patterns.
- the common K-line form has a "V" shape, a reverse cross type, a "W” type, a low position five-yang line, and an arc bottom type.
- the rise of the bow line in the middle of the rise, the jump of the sword line in the middle of the rise, the jump line of the jump, and so on, and the trend factor value corresponds to one of the various K-line forms.
- A40 Determine a timing trading strategy according to the trend category corresponding to the obtained trend factor value of each trading day.
- the trend factor values corresponding to each trading day in a year are clustered and analyzed, and k types corresponding to the trend factor values of each trading day are obtained.
- the position points corresponding to the corresponding K-line patterns are respectively analyzed on each trading day, and the subsequent K-line variation pattern of the corresponding position points is further determined, specifically, in the historical time period (in this embodiment, the hypothesis analysis period is 1) Years)
- the hypothesis analysis period is 1) Years
- There are market trend categories similar to the K-line pattern For example, statistical analysis of the trend pattern of the Shanghai and Shenzhen 300 in a week, assuming that the trend factor corresponding to each trading day in the week has a "w" in the trend category.
- the electronic device proposed by the present application firstly obtains a preset type index factor corresponding to each trading day of a predetermined stock market index within a preset time period; and then performs a timing strategy based on pre-training.
- the analysis model separately analyzes the preset type index factors of each acquired trading day to output the trend factor values corresponding to each trading day; and then clusters the trend factor values corresponding to each trading day according to a predetermined clustering algorithm.
- the timing trading strategy is determined according to the trend category corresponding to the trend factor value of each trading day obtained.
- the machine learning-based stock timing program of the present application may be described by a program module having the same function according to different functions implemented by the respective parts.
- FIG. 2 is a schematic diagram of a program module of a machine-based stock timing program according to an embodiment of the electronic device of the present application.
- the machine timing program based on machine learning may be divided into an obtaining module 201, an analyzing module 202, a clustering module 203, and a determining module 204 according to different functions implemented by the respective parts.
- the program module referred to in the present application refers to a series of computer program instruction segments capable of performing a specific function, and is more suitable than the program to describe the execution process of the machine learning-based stock timing program in the electronic device 10.
- the functions or operational steps implemented by the modules 201-204 are similar to the above, and are not described in detail herein, by way of example, for example:
- the obtaining module 201 is configured to obtain a preset type indicator factor corresponding to each trading day of the predetermined stock market index within a preset time period;
- the analyzing module 202 is configured to analyze the preset type index factors of each acquired trading day according to the timing analysis strategy model completed by the pre-training, so as to output the trend factor values corresponding to each trading day;
- the clustering module 203 is configured to perform cluster analysis on the trend factor values corresponding to each trading day according to a predetermined clustering algorithm, to obtain a trend category corresponding to the trend factor value of each trading day;
- the determining module 204 is configured to determine a timing trading strategy according to the obtained trend category corresponding to the trend factor value of each trading day.
- the present application also proposes a machine learning-based stock timing method.
- the machine learning-based stock timing method includes the following steps:
- the pre-determined stock market index refers to stock market reference data that has strong liquidity, large scale, can represent the stock price comprehensive change, and can provide investors with an authoritative investment direction, such as SSE 50, Shanghai and Shenzhen. 300, or commonly used reference data such as CSI 500.
- SSE 50 corresponds to 50 large-cap stocks in Shanghai stock market
- CSI 300 corresponds to 300 blue-chip stocks outside the market value of 30 cities, of which only a few are coincident with SSE 50, such as Pufa, Unicom, etc.
- 500 corresponds to 500 stocks with moderate market capitalization in the two cities, many of which coincide with the Shanghai and Shenzhen 300.
- the preset type index factor is a macro indicator that affects a predetermined stock market index.
- the debt yield of China Bond is 10 years - the 10-year period of China Bond National Debt can be seen from the general trend.
- AAA China Bond
- the market will also start to rise and the small market will go down.
- the indicator goes down and the small market goes up. From the chart, the spread of the spread has recently declined, indicating that the market is starting to decline and the small-cap style is dominant.
- the risk premium and the dividend yield are inversely related.
- the stock market's yield is higher than the bond market, the funds will flow from the bond market to the stock market.
- the stock index yield is lower than the bond market, the funds will flow from the stock market to the bond market.
- MACD Histogram When the MACD Histogram turns from negative to positive, the multi-signal appears, the MACD changes from positive to negative, and the short signal appears;
- RSRS indicator when zscore>0.7 and the closing price of MA(20) on the same day > the closing price of MA(20) in the past three days, buy signal; when zscore ⁇ -0.7 and the closing price of MA(20) on the same day ⁇ the past three days MA (20) When the closing price is sold, the signal is sold.
- the Shanghai and Shenzhen 300 actively buy the amount, the premium rate is >0, the market is optimistic; the premium rate is ⁇ 0, the market is pessimistic; historically, the premium rate hits 5 o'clock, it is a sell signal; when the premium rate hits -1, it is a buy signal.
- the preset time period may be classified into ultra short-term, short-term, medium-term, long-term, and ultra-long-term, etc., for example, in this embodiment, the predefined ultra-short-term included transaction
- the number of days is less than or equal to 5, and the number of trading days included in the short-term is greater than 5 and less than or equal to 10.
- the number of trading days included in the medium-term is greater than 10 and less than or equal to 15, and the number of trading days included in the long-term is greater than 15 days and less than one year.
- the number of trading days included in the long term is greater than one year.
- time series data in ultra-short-term and short-term time periods have a good fitting effect, but contain less information and can be used for ultra-short-line timing reference; the data of medium- and long-term time series contains There is more information, but the dependence of data between time series is not obvious in the short term, so the fitting effect is not super short-term and short-term, so the macroeconomic situation and economic trend are usually described by ultra-long-term data, and combined with medium and long-term data, Long-term timing reference.
- the pre-trained timing strategy model adopts the idea of machine learning, and uses a preset type index factor of each trading day in a preset time period as an input of a machine learning model, and outputs corresponding to each trading day through machine learning prediction.
- Trend factor value a preset type index factor of each trading day in a preset time period as an input of a machine learning model.
- the pre-trained completion timing strategy model is a cyclic neural network (RNN), and the cyclic neural network is used as a machine learning algorithm.
- the cyclic neural network includes an input layer, a hidden layer (state learning layer), and an output layer; in this embodiment, the output layer is configured to output a relative profit rate within a preset time period, specifically, a relative profit rate
- the rate of return associated with the total return of the stock market over a predetermined period of time in this embodiment, the relative rate of return is used to train the inverse update gradient of the machine learning model, and the different factors corresponding to each trading day of the hidden layer output The value is the trend factor value corresponding to each trading day output by the timing strategy model.
- the hidden layer which contains multiple layers of neurons, it can be regarded as a neural network transmitted in time. Its depth is the length of time. Usually, as the depth deepens, the phenomenon of “gradient disappearance” will appear. At time t, the gradient it produces disappears after several layers of history on the time axis.
- the neural network of the layer performs training learning corresponding to the preset type indicators of each trading day input by the input layer, and obtains the factor values corresponding to each trading day, and outputs the respective factor values at the corresponding nodes.
- the timing strategy model used in this scheme is not used for the prediction of the rate of return, and is closer to a generation model in thought.
- the output of the timing strategy model involved in this scenario is a classification of hidden layer values corresponding to each trading day, which is equivalent to generating a label for each trading day.
- the predetermined clustering algorithm is a k-means clustering algorithm
- the k-means clustering algorithm is one of the more classical clustering algorithms in the partitioning method. Because of its high efficiency, the algorithm is widely used in clustering large-scale data. At present, many algorithms are extended and improved around the algorithm.
- the k-means algorithm uses k as a parameter to divide n objects into k clusters, so that the clusters have higher similarity and the similarity between clusters is lower.
- the processing of the k-means algorithm is as follows: First, assuming that there are n trading days, the trend factor values corresponding to k transaction days are randomly selected as objects, where n>k, and n,k are Is a positive integer; each object initially represents the average or center of a cluster; for each of the remaining objects, it is assigned to the nearest cluster based on its distance from the center of each cluster; then each cluster is recalculated average value. This process is repeated until the criterion function converges.
- the criterion function uses a squared error criterion, which is defined as follows:
- E is the sum of the squared errors of all objects consisting of the trend factor values corresponding to n trading days
- p is the point in space
- mi is the average of the cluster Ci.
- the objective function makes the generated cluster as compact and independent as possible, and the distance metric used is the Euclidean distance, although other distance metrics can be used.
- the algorithm flow of the k-means clustering algorithm is as follows: input the database containing n objects and the number k of clusters.
- the trend factor values corresponding to n transaction days are taken as the above n objects, and the preset k
- the class trend category is used as the number of clusters; k clusters are output to minimize the square error criterion.
- the method specifically includes: selecting a trend factor value of k transaction days as an initial cluster center; assigning each object (re) to the most similar cluster according to the average value of the objects in the cluster; updating the average of the clusters The value, which is the average of the objects in each cluster; until the calculation no longer changes, the cluster ends.
- the common trend categories can be visually represented in different K-line patterns.
- the common K-line form has a "V" shape, a reverse cross type, a "W” type, a low position five-yang line, and an arc bottom type.
- the rise of the bow line in the middle of the rise, the jump of the sword line in the middle of the rise, the jump line of the jump, and so on, and the trend factor value corresponds to one of the various K-line forms.
- S400 Determine a timing trading strategy according to the trend category corresponding to the obtained trend factor value of each trading day.
- the trend factor values corresponding to each trading day in a year are clustered and analyzed, and k types corresponding to the trend factor values of each trading day are obtained.
- the position points corresponding to the corresponding K-line patterns are respectively analyzed on each trading day, and the subsequent K-line variation pattern of the corresponding position points is further determined, specifically, in the historical time period (in this embodiment, the hypothesis analysis period is 1) Years)
- the hypothesis analysis period is 1) Years
- There are market trend categories similar to the K-line pattern For example, statistical analysis of the trend pattern of the Shanghai and Shenzhen 300 in a week, assuming that the trend factor corresponding to each trading day in the week has a "w" in the trend category.
- the machine learning-based stock timing method proposed by the present application firstly obtains a preset type index factor corresponding to each trading day of a predetermined stock market index within a preset time period;
- the training completion timing analysis model separately analyzes the preset type index factors of each transaction day to output the trend factor values corresponding to each trading day; and then according to the predetermined clustering algorithm, the corresponding trend of each trading day
- the factor value is clustered to obtain the trend category corresponding to the trend factor value of each trading day; finally, the timing trading strategy is determined according to the trend category corresponding to the trend factor value of each trading day.
- the present application further provides a computer readable storage medium on which a machine learning based stock timing program is stored, and the machine learning based stock timing program is executed by a processor as follows: operating:
- the preset type index factors of each acquired trading day are respectively analyzed to output the trend factor values corresponding to each trading day;
- the timing trading strategy is determined according to the trend category corresponding to the trend factor value of each trading day obtained.
- the specific embodiment of the computer readable storage medium of the present application is substantially the same as the above embodiments of the electronic device and the machine learning based stock method, and will not be described herein.
- the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be through hardware, but in many cases, the former is better.
- Implementation Based on such understanding, the technical solution of the present application, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk,
- the optical disc includes a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods described in various embodiments of the present application.
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- General Physics & Mathematics (AREA)
- Business, Economics & Management (AREA)
- Finance (AREA)
- Life Sciences & Earth Sciences (AREA)
- Artificial Intelligence (AREA)
- Accounting & Taxation (AREA)
- Evolutionary Computation (AREA)
- General Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Health & Medical Sciences (AREA)
- Bioinformatics & Computational Biology (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Probability & Statistics with Applications (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Marketing (AREA)
- Strategic Management (AREA)
- Technology Law (AREA)
- General Business, Economics & Management (AREA)
- Evolutionary Biology (AREA)
- Biomedical Technology (AREA)
- Biophysics (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
Abstract
本申请公开了一种电子装置、基于机器学习的股票择时方法及存储介质,首先通过获取预先确定的股票市场指数在预设时间段内的各交易日对应的预设类型指标因子;然后根据预先训练完成的择时策略分析模型分别对获取的各交易日的预设类型指标因子进行分析,以输出各交易日对应的走势因子值;再根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别;最后根据得到的各交易日的走势因子值对应的走势类别,确定择时交易策略。提高了股票择时交易的效率及准确性。
Description
本申请要求于2018年4月26日提交中国专利局、申请号为2018103871394,发明名称为“电子装置、基于机器学习的股票择时方法及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及金融市场分析领域,尤其涉及一种电子装置、基于机器学习的股票择时方法及存储介质。
随着金融市场以及金融理论的不断完善及发展,股票量化投资成为很多金融机构用来吸引股票投资者的有利因素。目前,对股票量化投资的研究主要以择时交易为主,择时交易是指利用某种方法来判断投资标的,如股票、期货、外汇等在预先确定的时间段内的走势,并根据走势确定买卖时间点的一种交易手段。而通常对股票择时交易的分析需要专业人员研究对应的趋势性择时指标,如股票的趋势性择时指标包括MA(双均线)、DMA(平均线差)、TRIX(三重指数平滑移动)等的变化,并根据择时指标的变化确定买卖交易的时间点,存在效率低下,且准确率不高的问题。
发明内容
有鉴于此,本申请提出一种电子装置、基于机器学习的股票择时方法及存储介质,能够提高股票择时交易分析的效率及准确性。
首先,本申请提出一种电子装置,所述电子装置包括存储器、及与所述存储器连接的处理器,所述处理器用于执行所述存储器上存储的基于机器学习的股票择时程序,所述基于机器学习的股票择时程序被所述处理器执行时实现如下步骤:
A10、获取预先确定的股票市场指数在预设时间段内的各交易日对应的预 设类型指标因子;
A20、根据预先训练完成的择时策略分析模型分别对获取的各交易日的预设类型指标因子进行分析,以输出各交易日对应的走势因子值;
A30、根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别;
A40、根据得到的各交易日的走势因子值对应的走势类别,确定择时交易策略。
此外,本申请还提出一种基于机器学习的股票择时方法,所述方法包括如下步骤:
S100、获取预先确定的股票市场指数在预设时间段内的各交易日对应的预设类型指标因子;
S200、根据预先训练完成的择时策略分析模型分别对获取的各交易日的预设类型指标因子进行分析,以输出各交易日对应的走势因子值;
S300、根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别;
S400、根据得到的各交易日的走势因子值对应的走势类别,确定择时交易策略。
此外,本申请还提出一种计算机可读存储介质,所述计算机可读存储介质存储有基于机器学习的股票择时程序,所述基于机器学习的股票择时程序可被至少一个处理器执行,以使所述至少一个处理器执行如下步骤:
获取预先确定的股票市场指数在预设时间段内的各交易日对应的预设类型指标因子;
根据预先训练完成的择时策略分析模型分别对获取的各交易日的预设类型指标因子进行分析,以输出各交易日对应的走势因子值;
根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别;
根据得到的各交易日的走势因子值对应的走势类别,确定择时交易策略。
相较于现有技术,本申请所提出的电子装置、基于机器学习的股票择时方法及存储介质,首先通过获取预先确定的股票市场指数在预设时间段内的各交易日对应的预设类型指标因子;然后根据预先训练完成的择时策略分析模型分别对获取的各交易日的预设类型指标因子进行分析,以输出各交易日对应的走势因子值;再根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别;最后根据得到的各交易日的走势因子值对应的走势类别,确定择时交易策略。提高了股票择时交易分析的效率及准确性。
图1是本申请提出的电子装置一可选的硬件架构的示意图;
图2是本申请电子装置一实施例中基于机器学习的股票择时程序模块示意图;
图3是本申请基于机器学习的股票择时方法较佳实施例的实施流程图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
需要说明的是,在本申请中涉及“第一”、“第二”等的描述仅用于描述目的,而不能理解为指示或暗示其相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。另外,各个实施例之间的技术方案可以相互结合,但是必须是以本领 域普通技术人员能够实现为基础,当技术方案的结合出现相互矛盾或无法实现时应当认为这种技术方案的结合不存在,也不在本申请要求的保护范围之内。
参阅图1所示,是本申请提出的电子装置一可选的硬件架构示意图。本实施例中,电子装置10可包括,但不仅限于,可通过通信总线14相互通信连接的存储器11、处理器12、网络接口13。需要指出的是,图1仅示出了具有组件11-14的电子装置10,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。
其中,存储器11至少包括一种类型的计算机可读存储介质,计算机可读存储介质包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘等。在一些实施例中,存储器11可以是电子装置10的内部存储单元,例如电子装置10的硬盘或内存。在另一些实施例中,存储器11也可以是电子装置10的外包存储设备,例如电子装置10上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。当然,存储器11还可以既包括电子装置10的内部存储单元也包括其外部存储设备。本实施例中,存储器11通常用于存储安装于电子装置10的操作系统和各类应用软件,例如基于机器学习的股票择时程序等。此外,存储器11还可以用于暂时地存储已经输出或者将要输出的各类数据。
处理器12在一些实施例中可以是中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器、或其他数据处理芯片。处理器12通常用于控制电子装置10的总体操作。本实施例中,处理器12用于运行存储器11中存储的程序代码或者处理数据,例如运行的基于机器学习的股票择时程序等。
网络接口13可包括无线网络接口或有线网络接口,网络接口13通常用 于在电子装置10与其他电子设备之间建立通信连接。
通信总线14用于实现组件11-13之间的通信连接。
图1仅示出了具有组件11-14以及基于机器学习的股票择时程序的电子装置10,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。
可选地,电子装置10还可以包括用户接口(图1中未示出),用户接口可以包括显示器、输入单元比如键盘,其中,用户接口还可以包括标准的有线接口、无线接口等。
可选地,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED触摸器等。进一步地,显示器也可称为显示屏或显示单元,用于显示在电子装置10中处理信息以及用于显示可视化的用户界面。
在一实施例中,存储器11中存储的基于机器学习的股票择时程序被处理器12执行时,实现如下操作:
A10、获取预先确定的股票市场指数在预设时间段内的各交易日对应的预设类型指标因子;
具体地,预先确定的股票市场指数指的是具有流动性强、规模大、能够代表股票的股价综合变动,且能够为投资者提供权威的投资方向的股票市场参考数据,例如上证50、沪深300、或者中证500等的常用参考数据。其中,上证50对应的是沪市的50只大盘股,沪深300对应的是两市市值30名以外的300只蓝筹股,其中只有极少部分与上证50重合,如浦发、联通等,中证500对应的是两市市值适中的500只个股,有许多与沪深300重合。具体地,预设类型指标因子为影响预先确定的股票市场指数的宏观指标,例如,在本实施例中,以沪深300为例,对应的预设类型指标因子包括,但不仅限于,中债国债到期收益率-中债企业债到期收益率、风险溢价、股息率、SlowD、MACD Histogram、Bollinger Bands、MA of RSI(14)[M=22]、4-period MA of4-week MA of modified OBV-(MA4*4)、CR指标、大小盘换手率比值、RSRS 指标、沪深300溢价率、沪深300主动买入额等13维指标。
其中,中债企业债到期收益率(AAA)10年-中债国债10年期,可以从大致趋势上来看当利差上升阶段,大盘也开始上行,小盘下行。反之当利差下降时指标大盘下行,小盘上行。从图上来看利差近期出现下降拐点,预示大盘开始下行,小盘风格占优。
风险溢价与股息率呈现反相关性,当股市的收益率高于债市时,资金将从债市流向股市;反之,当股指收益率低于债市时,资金将从股市流向债市。(平稳通道为average加减1std)
股息率,沪深300股息率与沪深300收盘价呈负相关性。(平稳通道为average加减1std)
SlowD,当slowD<10超卖信号出现,做多指数;当slowD>10超卖信号消失,做空指数。
MACD Histogram当MACD Histogram由负转正,做多信号出现,MACD由正转负,做空信号出现;
Bollinger Bands,当股价<下轨线BN,买入信号出现。
MA of RSI(14)[M=22],当22-day MA of RSI(14)<40时,买入信号出现,投资期限为22个交易日。
4-period MA of 4-week MA of modified OBV-(MA4*4),当股价走势和MA4*4一致时,买入信号出现,背离时,卖出信号出现。
CR指标,CR<260,能量较低,加仓信号出现。
大小盘换手率比值
当换手率<=0.1,且振幅<=-10%,市场从小盘转为大盘风格;当换手率>=0.3,且振幅>=10%,市场从大盘转为小盘。
RSRS指标,当zscore>0.7且当日MA(20)收盘价>过去三日MA(20)收盘价的时候,买入信号;当zscore<-0.7且当日MA(20)收盘价<过去三日MA(20)收盘价的时候,卖出信号
沪深300溢价率,溢价率>0,市场乐观;溢价率<0,市场悲观;历史上, 溢价率触及5时,为卖出信号;溢价率触及-1时,为买入信号。
沪深300主动买入额,溢价率>0,市场乐观;溢价率<0,市场悲观;历史上,溢价率触及5时,为卖出信号;溢价率触及-1时,为买入信号。
通常,根据预设时间段内包含的交易日数目不同,预设时间段可分为超短期,短期,中期,长期,以及超长期等,例如在本实施例中,预定义超短期包含的交易日数目小于等于5,短期包含的交易日数目大于5,且小于等于10,中期包含的交易日数目大于10,且小于等于15,长期包含的交易日数目大于15日,且小于一年,超长期包含的交易日数目大于一年等。一般而言,在实际应用中,超短期和短期时间段内的时间序列数据具有较好的拟合效果,但是包含的信息较少,可用于超短线择时参考;中长期时间序列的数据包含的信息较多,但是时序间数据的依赖关系没有短期明显,导致拟合效果没有超短期和短期好,所以通常通过超长期数据刻画宏观经济形势与经济走势,并结合中长期数据,用于中长线择时参考。
A20、根据预先训练完成的择时策略分析模型分别对获取的各交易日的预设类型指标因子进行分析,以输出各交易日对应的走势因子值;
具体地,预先训练完成的择时策略模型为采用机器学习的思路,将预设时间段内各交易日的预设类型指标因子作为机器学习模型的输入,通过机器学习预测输出各交易日对应的走势因子值。
优选地,在本实施例中,预先训练完成的择时策略模型为循环神经网络(RNN),通过循环神经网络作为机器学习算法。具体地,循环神经网络包括输入层、隐藏层(状态学习层)、以及输出层;在本实施例中,输出层用于输出预设时间段内的相对收益率,具体地,相对收益率为与预设时间段内股票市场的总收益相关的收益率;在本实施例中,相对收益率用来训练机器学习模型的反向更新梯度,而将隐藏层输出的各交易日对应的不同因子值作为择时策略模型输出的各交易日对应的走势因子值。
需要说明的是,循环神经网络(RNN)的隐藏层包括多个节点,各节点之间存在互连的作用,为整个机器学习模型的关键层。通常输入层输入的特 征通过隐藏层训练学习变换之后,到达输出层。而在隐藏层包含多层神经元,可以看成一个在时间上传递的神经网络,它的深度是时间的长度,通常随着深度的加深,“梯度消失”的现象就会出现,这是由于在时间t时刻,它产生的梯度在时间轴上向历史传播几层之后就消失了,因此,在训练的过程中,需要借助输出层输出的数据训练机器学习模型的反向更新梯度,而隐藏层的神经网络对应将输入层输入的各个交易日的预设类型指标进行训练学习之后,得到各个交易日对应的因子数值,并将各个因子数值在对应的节点输出。
通过上述分析可知,本方案所使用的择时策略模型并不用于收益率的预测,在思想上更加接近于一个生成模型。本方案所涉及的择时策略模型的输出,是对应于每个交易日的隐藏层数值的分类,相当于对每一个交易日而言,生成一个标签。
A30、根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别;
具体地,预先确定的聚类算法为k-means聚类算法,k-means聚类算法是划分方法中较经典的聚类算法之一。由于该算法的效率高,所以在对大规模数据进行聚类时被广泛应用。目前,许多算法均围绕着该算法进行扩展和改进。
k-means算法以k为参数,把n个对象分成k个簇,使簇内具有较高的相似度,而簇间的相似度较低。在本实施例中,k-means算法的处理过程如下:首先,假设有n个交易日,随机地选择k个交易日对应的走势因子值为对象,其中,n>k,且n,k均为正整数;每个对象初始地代表了一个簇的平均值或中心;对剩余的每个对象,根据其与各簇中心的距离,将它赋给最近的簇;然后重新计算每个簇的平均值。这个过程不断重复,直到准则函数收敛。通常,准则函数采用平方误差准则,其定义如下:
其中,E是n个交易日对应的走势因子值构成的所有对象的平方误差的总 和,p是空间中需要聚类的点,在本实施例中,p是n个交易日的走势因子,mi是簇Ci的平均值。该目标函数使生成的簇尽可能紧凑独立,使用的距离度量是欧几里得距离,当然也可以用其他距离度量。k-means聚类算法的算法流程如下:输入包含n个对象的数据库和簇的数目k,在本实施例中,将n个交易日对应的走势因子值作为上述n个对象,预设的k类走势类别作为簇的数目;输出k个簇,使平方误差准则最小。在本实施例中,具体包括:任意选择k个交易日的走势因子值作为初始的簇中心;根据簇中对象的平均值,将每个对象(重新)赋予最类似的簇;更新簇的平均值,即计算每个簇中对象的平均值;直到计算结果不再发生变化,则聚类结束。
进一步地,常见的走势类别可在不同K线形态中形象地表示,例如常见的K线形态有“V”字型、反转十字型、“W”型、低位档五阳线、圆弧底型、上升中途跳高弓形线、上升中途跳高剑形线、跳空攀援线等等,而走势因子值对应为各种K线形态中的一个点。
A40、根据得到的各交易日的走势因子值对应的走势类别,确定择时交易策略。
具体地,在本实施例的一种实施方式中,以沪深300为例,假设将一年内各交易日对应的走势因子值进行聚类分析,得到各交易日的走势因子值对应的k类市场走势类别。分别分析各交易日在各自对应的K线形态中对应的位置点,进一步确定对应的位置点后续的K线变化形态,具体地,获取历史时间段内(本实施例中,假设分析周期为1年)分别出现类似K线形态的市场走势类别,例如,统计分析一周内沪深300的走势形态,假设该一周内的各交易日对应的走势因子值对应的走势类别中有“w”底的K线变化形态,且历史上在一周内出现“w”底的K线变化形态后,在后续预设时间内,假设一周内,对应的K线变化形态更可能接近于另一确定的走势类别,假设为上升中途跳高弓形线,则确定根据上升中途跳高弓形线来确定未来一周的择时交易策略。
由上述事实施例可知,本申请提出的电子装置,首先通过获取预先确定的股票市场指数在预设时间段内的各交易日对应的预设类型指标因子;然后 根据预先训练完成的择时策略分析模型分别对获取的各交易日的预设类型指标因子进行分析,以输出各交易日对应的走势因子值;再根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别;最后根据得到的各交易日的走势因子值对应的走势类别,确定择时交易策略。提高了股票择时交易的效率及准确性。
进一步需要说明的是,本申请的基于机器学习的股票择时程序依据其各部分所实现的功能不同,可用具有相同功能的程序模块进行描述。请参阅图2所示,是本申请电子装置一实施例中基于机器学习的股票择时程序的程序模块示意图。本实施例中,基于机器学习的股票择时程序依据其各部分所实现的功能的不同,可以被分割成获取模块201、分析模块202、聚类模块203、以及确定模块204。由上面的描述可知,本申请所称的程序模块是指能够完成特定功能的一系列计算机程序指令段,比程序更适合于描述基于机器学习的股票择时程序在电子装置10中的执行过程。所述模块201-204所实现的功能或操作步骤均与上文类似,此处不再详述,示例性地,例如其中:
获取模块201用于获取预先确定的股票市场指数在预设时间段内的各交易日对应的预设类型指标因子;
分析模块202用于根据预先训练完成的择时策略分析模型分别对获取的各交易日的预设类型指标因子进行分析,以输出各交易日对应的走势因子值;
聚类模块203用于根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别;
确定模块204用于根据得到的各交易日的走势因子值对应的走势类别,确定择时交易策略。
此外,本申请还提出一种基于机器学习的股票择时方法,请参阅图3所示,所述基于机器学习的股票择时方法包括如下步骤:
S100、获取预先确定的股票市场指数在预设时间段内的各交易日对应的预设类型指标因子;
具体地,预先确定的股票市场指数指的是具有流动性强、规模大、能够 代表股票的股价综合变动,且能够为投资者提供权威的投资方向的股票市场参考数据,例如上证50、沪深300、或者中证500等的常用参考数据。其中,上证50对应的是沪市的50只大盘股,沪深300对应的是两市市值30名以外的300只蓝筹股,其中只有极少部分与上证50重合,如浦发、联通等,中证500对应的是两市市值适中的500只个股,有许多与沪深300重合。具体地,预设类型指标因子为影响预先确定的股票市场指数的宏观指标,例如,在本实施例中,以沪深300为例,对应的预设类型指标因子包括,但不仅限于,中债国债到期收益率-中债企业债到期收益率、风险溢价、股息率、SlowD、MACD Histogram、Bollinger Bands、MA of RSI(14)[M=22]、4-period MA of4-week MA of modified OBV-(MA4*4)、CR指标、大小盘换手率比值、RSRS指标、沪深300溢价率、沪深300主动买入额等13维指标。
其中,中债企业债到期收益率(AAA)10年-中债国债10年期,可以从大致趋势上来看当利差上升阶段,大盘也开始上行,小盘下行。反之当利差下降时指标大盘下行,小盘上行。从图上来看利差近期出现下降拐点,预示大盘开始下行,小盘风格占优。
风险溢价与股息率呈现反相关性,当股市的收益率高于债市时,资金将从债市流向股市;反之,当股指收益率低于债市时,资金将从股市流向债市。(平稳通道为average加减1std)
股息率,沪深300股息率与沪深300收盘价呈负相关性。(平稳通道为average加减1std)
SlowD,当slowD<10超卖信号出现,做多指数;当slowD>10超卖信号消失,做空指数。
MACD Histogram当MACD Histogram由负转正,做多信号出现,MACD由正转负,做空信号出现;
Bollinger Bands,当股价<下轨线BN,买入信号出现。
MA of RSI(14)[M=22],当22-day MA of RSI(14)<40时,买入信号出现,投资期限为22个交易日。
4-period MA of 4-week MA of modified OBV-(MA4*4),当股价走势和MA4*4一致时,买入信号出现,背离时,卖出信号出现。
CR指标,CR<260,能量较低,加仓信号出现。
大小盘换手率比值
当换手率<=0.1,且振幅<=-10%,市场从小盘转为大盘风格;当换手率>=0.3,且振幅>=10%,市场从大盘转为小盘。
RSRS指标,当zscore>0.7且当日MA(20)收盘价>过去三日MA(20)收盘价的时候,买入信号;当zscore<-0.7且当日MA(20)收盘价<过去三日MA(20)收盘价的时候,卖出信号
沪深300溢价率,溢价率>0,市场乐观;溢价率<0,市场悲观;历史上,溢价率触及5时,为卖出信号;溢价率触及-1时,为买入信号。
沪深300主动买入额,溢价率>0,市场乐观;溢价率<0,市场悲观;历史上,溢价率触及5时,为卖出信号;溢价率触及-1时,为买入信号。
通常,根据预设时间段内包含的交易日数目不同,预设时间段可分为超短期,短期,中期,长期,以及超长期等,例如在本实施例中,预定义超短期包含的交易日数目小于等于5,短期包含的交易日数目大于5,且小于等于10,中期包含的交易日数目大于10,且小于等于15,长期包含的交易日数目大于15日,且小于一年,超长期包含的交易日数目大于一年等。一般而言,在实际应用中,超短期和短期时间段内的时间序列数据具有较好的拟合效果,但是包含的信息较少,可用于超短线择时参考;中长期时间序列的数据包含的信息较多,但是时序间数据的依赖关系没有短期明显,导致拟合效果没有超短期和短期好,所以通常通过超长期数据刻画宏观经济形势与经济走势,并结合中长期数据,用于中长线择时参考。
S200、根据预先训练完成的择时策略分析模型分别对获取的各交易日的预设类型指标因子进行分析,以输出各交易日对应的走势因子值;
具体地,预先训练完成的择时策略模型为采用机器学习的思路,将预设时间段内各交易日的预设类型指标因子作为机器学习模型的输入,通过机器 学习预测输出各交易日对应的走势因子值。
优选地,在本实施例中,预先训练完成的择时策略模型为循环神经网络(RNN),通过循环神经网络作为机器学习算法。具体地,循环神经网络包括输入层、隐藏层(状态学习层)、以及输出层;在本实施例中,输出层用于输出预设时间段内的相对收益率,具体地,相对收益率为与预设时间段内股票市场的总收益相关的收益率;在本实施例中,相对收益率用来训练机器学习模型的反向更新梯度,而将隐藏层输出的各交易日对应的不同因子值作为择时策略模型输出的各交易日对应的走势因子值。
需要说明的是,循环神经网络(RNN)的隐藏层节点之间存在互连的作用,为整个机器学习模型的关键层。通常输入层输入的特征通过隐藏层训练学习变换之后,到达输出层。而在隐藏层包含多层神经元,可以看成一个在时间上传递的神经网络,它的深度是时间的长度,通常随着深度的加深,“梯度消失”的现象就会出现,这是由于在时间t时刻,它产生的梯度在时间轴上向历史传播几层之后就消失了,因此,在训练的过程中,需要借助输出层输出的数据训练机器学习模型的反向更新梯度,而隐藏层的神经网络对应将输入层输入的各个交易日的预设类型指标进行训练学习之后,得到各个交易日对应的因子数值,并将各个因子数值在对应的节点输出。
通过上述分析可知,本方案所使用的择时策略模型并不用于收益率的预测,在思想上更加接近于一个生成模型。本方案所涉及的择时策略模型的输出,是对应于每个交易日的隐藏层数值的分类,相当于对每一个交易日而言,生成一个标签。
S300、根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别;
具体地,预先确定的聚类算法为k-means聚类算法,k-means聚类算法是划分方法中较经典的聚类算法之一。由于该算法的效率高,所以在对大规模数据进行聚类时被广泛应用。目前,许多算法均围绕着该算法进行扩展和改进。
k-means算法以k为参数,把n个对象分成k个簇,使簇内具有较高的相似度,而簇间的相似度较低。在本实施例中,k-means算法的处理过程如下:首先,假设有n个交易日,随机地选择k个交易日对应的走势因子值为对象,其中,n>k,且n,k均为正整数;每个对象初始地代表了一个簇的平均值或中心;对剩余的每个对象,根据其与各簇中心的距离,将它赋给最近的簇;然后重新计算每个簇的平均值。这个过程不断重复,直到准则函数收敛。通常,准则函数采用平方误差准则,其定义如下:
其中,E是n个交易日对应的走势因子值构成的所有对象的平方误差的总和,p是空间中的点,mi是簇Ci的平均值。该目标函数使生成的簇尽可能紧凑独立,使用的距离度量是欧几里得距离,当然也可以用其他距离度量。k-means聚类算法的算法流程如下:输入包含n个对象的数据库和簇的数目k,在本实施例中,将n个交易日对应的走势因子值作为上述n个对象,预设的k类走势类别作为簇的数目;输出k个簇,使平方误差准则最小。在本实施例中,具体包括:任意选择k个交易日的走势因子值作为初始的簇中心;根据簇中对象的平均值,将每个对象(重新)赋予最类似的簇;更新簇的平均值,即计算每个簇中对象的平均值;直到计算结果不再发生变化,则聚类结束。
进一步地,常见的走势类别可在不同K线形态中形象地表示,例如常见的K线形态有“V”字型、反转十字型、“W”型、低位档五阳线、圆弧底型、上升中途跳高弓形线、上升中途跳高剑形线、跳空攀援线等等,而走势因子值对应为各种K线形态中的一个点。
S400、根据得到的各交易日的走势因子值对应的走势类别,确定择时交易策略。
具体地,在本实施例的一种实施方式中,以沪深300为例,假设将一年内各交易日对应的走势因子值进行聚类分析,得到各交易日的走势因子值对应的k类市场走势类别。分别分析各交易日在各自对应的K线形态中对应的 位置点,进一步确定对应的位置点后续的K线变化形态,具体地,获取历史时间段内(本实施例中,假设分析周期为1年)分别出现类似K线形态的市场走势类别,例如,统计分析一周内沪深300的走势形态,假设该一周内的各交易日对应的走势因子值对应的走势类别中有“w”底的K线变化形态,且历史上在一周内出现“w”底的K线变化形态后,在后续预设时间内,假设一周内,对应的K线变化形态更可能接近于另一确定的走势类别,假设为上升中途跳高弓形线,则确定根据上升中途跳高弓形线来确定未来一周的择时交易策略。
由上述事实施例可知,本申请提出的基于机器学习的股票择时方法,首先通过获取预先确定的股票市场指数在预设时间段内的各交易日对应的预设类型指标因子;然后根据预先训练完成的择时策略分析模型分别对获取的各交易日的预设类型指标因子进行分析,以输出各交易日对应的走势因子值;再根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别;最后根据得到的各交易日的走势因子值对应的走势类别,确定择时交易策略。提高了股票择时交易的效率及准确性。
此外,本申请还提出一种计算机可读存储介质,所述计算机可读存储介质上存储有基于机器学习的股票择时程序,所述基于机器学习的股票择时程序被处理器执行时实现如下操作:
获取预先确定的股票市场指数在预设时间段内的各交易日对应的预设类型指标因子;
根据预先训练完成的择时策略分析模型分别对获取的各交易日的预设类型指标因子进行分析,以输出各交易日对应的走势因子值;
根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别;
根据得到的各交易日的走势因子值对应的走势类别,确定择时交易策略。
本申请计算机可读存储介质具体实施方式与上述电子装置以及基于机器学习的股票方法各实施例基本相同,在此不作累述。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。
Claims (20)
- 一种电子装置,其特征在于,所述电子装置包括存储器、及与所述存储器连接的处理器,所述处理器用于执行所述存储器上存储的基于机器学习的股票择时程序,所述基于机器学习的股票择时程序被所述处理器执行时实现如下步骤:A10、获取预先确定的股票市场指数在预设时间段内的各交易日对应的预设类型指标因子;A20、根据预先训练完成的择时策略分析模型分别对获取的各交易日的预设类型指标因子进行分析,以输出各交易日对应的走势因子值;A30、根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别;A40、根据得到的各交易日的走势因子值对应的走势类别,确定择时交易策略。
- 如权利要求1所述的电子装置,其特征在于,所述预先训练完成的择时策略分析模型为循环神经网络模型;所述循环神经网络包括输入层、隐藏层、以及输出层;所述输入层用于输入预设时间段内各交易日对应的预设类型指标因子;所述输出层用于输出预设时间段内的相对收益率;所述隐藏层包含多层神经元,且各神经元的各个节点之间存在互连的作用,用于将所述输入层输入的预设类型指标因子通过神经元训练学习变换之后,生成各交易日对应的走势因子值。
- 如权利要求2所述的电子装置,其特征在于,所述预先确定的聚类算法为k-means聚类算法;所述步骤A30包括如下步骤:E1、分别假设n个对象以及簇的数目,所述n个对象为获取的各个交易日对应的走势因子值,所述簇的数目为预定义的k类走势类别,其中n≥k,且均为正整数;F1、从所述n个对象中任意选取k个对象分别作为预定义的初始簇,k个对象分别为预定义的初始簇的平均值;G1、分别计算所述n个对象与各个初始簇的平均值之间的欧几里得距离,并根据计算结果,将所述n个对象分别赋予对应欧几里得距离最小的簇;H1、重新计算各个簇的平均值,并重复执行上述步骤G1,直至预定义的准则函数收敛,则聚类结束。
- 如权利要求1所述的电子装置,其特征在于,所述走势因子值对应为不同K线形态中的点,所述走势因子值对应的走势类别包括不同的K线形态。
- 如权利要求2所述的电子装置,其特征在于,所述走势因子值对应为不同K线形态中的点,所述走势因子值对应的走势类别包括不同的K线形态。
- 如权利要求3所述的电子装置,其特征在于,所述走势因子值对应为不同K线形态中的点,所述走势因子值对应的走势类别包括不同的K线形态。
- 如权利要求4所述的电子装置,其特征在于,所述走势因子值对应为不同K线形态中的点,所述走势因子值对应的走势类别包括不同的K线形态。
- 一种基于机器学习的股票择时方法,其特征在于,所述方法包括如下步骤:S100、获取预先确定的股票市场指数在预设时间段内的各交易日对应的预设类型指标因子;S200、根据预先训练完成的择时策略分析模型分别对获取的各交易日的预设类型指标因子进行分析,以输出各交易日对应的走势因子值;S300、根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别;S400、根据得到的各交易日的走势因子值对应的走势类别,确定择时交 易策略。
- 如权利要求9所述的基于机器学习的股票择时方法,其特征在于,所述预先训练完成的择时策略分析模型为循环神经网络模型;所述循环神经网络包括输入层、隐藏层、以及输出层;所述输入层用于输入预设时间段内各交易日对应的预设类型指标因子;所述输出层用于输出预设时间段内的相对收益率;所述隐藏层包含多层神经元,且各神经元的各个节点之间存在互连的作用,用于将所述输入层输入的预设类型指标因子通过神经元训练学习变换之后,生成各交易日对应的走势因子值。
- 如权利要求10所述的基于机器学习的股票择时方法,其特征在于,所述预先确定的聚类算法为k-means聚类算法;所述步骤S300包括如下步骤:E2、分别假设n个对象以及簇的数目,所述n个对象为获取的各个交易日对应的走势因子值,所述簇的数目为预定义的k类走势类别,其中n≥k,且均为正整数;F2、从所述n个对象中任意选取k个对象分别作为预定义的初始簇,k个对象分别为预定义的初始簇的平均值;G2、分别计算所述n个对象与各个初始簇的平均值之间的欧几里得距离,并根据计算结果,将所述n个对象分别赋予对应欧几里得距离最小的簇;H2、重新计算各个簇的平均值,并重复执行上述步骤G2,直至预定义的准则函数收敛,则聚类结束。
- 如权利要求9所述的基于机器学习的股票择时方法,其特征在于,所述走势因子值对应为不同K线形态中的点,所述走势因子值对应的走势类别 包括不同的K线形态。
- 如权利要求10所述的基于机器学习的股票择时方法,其特征在于,所述走势因子值对应为不同K线形态中的点,所述走势因子值对应的走势类别包括不同的K线形态。
- 如权利要求11所述的基于机器学习的股票择时方法,其特征在于,所述走势因子值对应为不同K线形态中的点,所述走势因子值对应的走势类别包括不同的K线形态。
- 如权利要求12所述的基于机器学习的股票择时方法,其特征在于,所述走势因子值对应为不同K线形态中的点,所述走势因子值对应的走势类别包括不同的K线形态。
- 一种计算机可读存储介质,所述计算机可读存储介质存储有基于机器学习的股票择时程序,所述基于机器学习的股票择时程序可被至少一个处理器执行,以使所述至少一个处理器执行如下步骤:获取预先确定的股票市场指数在预设时间段内的各交易日对应的预设类型指标因子;根据预先训练完成的择时策略分析模型分别对获取的各交易日的预设类型指标因子进行分析,以输出各交易日对应的走势因子值;根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别;根据得到的各交易日的走势因子值对应的走势类别,确定择时交易策略。
- 如权利要求17所述的存储介质,其特征在于,所述预先训练完成的择时策略分析模型为循环神经网络模型;所述循环神经网络包括输入层、隐藏层、以及输出层;所述输入层用于输入预设时间段内各交易日对应的预设类型指标因子;所述输出层用于输出预设时间段内的相对收益率;所述隐藏层包含多层神经元,且各神经元的各个节点之间存在互连的作用,用于将所述输入层输入的预设类型指标因子通过神经元训练学习变换之后,生成各交易日对应的走势因子值。
- 如权利要求2所述的电子装置,其特征在于,所述预先确定的聚类算法为k-means聚类算法;所述根据预先确定的聚类算法对各交易日对应的走势因子值进行聚类分析,以得到各交易日的走势因子值对应的走势类别的步骤包括:E1、分别假设n个对象以及簇的数目,所述n个对象为获取的各个交易日对应的走势因子值,所述簇的数目为预定义的k类走势类别,其中n≥k,且均为正整数;F1、从所述n个对象中任意选取k个对象分别作为预定义的初始簇,k个对象分别为预定义的初始簇的平均值;G1、分别计算所述n个对象与各个初始簇的平均值之间的欧几里得距离,并根据计算结果,将所述n个对象分别赋予对应欧几里得距离最小的簇;H1、重新计算各个簇的平均值,并重复执行上述步骤G1,直至预定义的准则函数收敛,则聚类结束。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201810387139.4A CN108764291A (zh) | 2018-04-26 | 2018-04-26 | 电子装置、基于机器学习的股票择时方法及存储介质 |
| CN201810387139.4 | 2018-04-26 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2019205384A1 true WO2019205384A1 (zh) | 2019-10-31 |
Family
ID=64012111
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2018/102224 Ceased WO2019205384A1 (zh) | 2018-04-26 | 2018-08-24 | 电子装置、基于机器学习的股票择时方法及存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN108764291A (zh) |
| WO (1) | WO2019205384A1 (zh) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113435623A (zh) * | 2020-03-23 | 2021-09-24 | 北京沃东天骏信息技术有限公司 | 一种预警方法和装置 |
| CN114008658A (zh) * | 2021-09-30 | 2022-02-01 | 富途网络科技(深圳)有限公司 | K线形态的识别方法及电子设备 |
| CN116541738A (zh) * | 2023-05-08 | 2023-08-04 | 沈阳麟龙科技股份有限公司 | 基于k线形态聚类的相似k线序列搜索系统及方法 |
Families Citing this family (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110895585B (zh) * | 2019-10-18 | 2022-08-23 | 深圳市富途网络科技有限公司 | 股票数据获取方法、装置、终端设备及存储介质 |
| CN111402042B (zh) * | 2020-02-17 | 2023-10-27 | 中信建投证券股份有限公司 | 一种用于股市大盘形态分析的数据分析与显示方法 |
| CN111429272B (zh) * | 2020-02-20 | 2023-08-22 | 中信建投证券股份有限公司 | 自动生成量化交易因子及重要性评判的方法、装置 |
| CN114638701A (zh) * | 2022-03-28 | 2022-06-17 | 中国银行股份有限公司 | 股债性价比分析方法及装置 |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106952161A (zh) * | 2017-03-31 | 2017-07-14 | 洪志令 | 一种基于长短期记忆深度学习网络的股票近期走势预测方法 |
| CN107832897A (zh) * | 2017-11-30 | 2018-03-23 | 浙江工业大学 | 一种基于深度学习的股票市场预测方法 |
| CN107844865A (zh) * | 2017-11-20 | 2018-03-27 | 天津科技大学 | 基于特征参数选取与lstm模型的股指预测方法 |
-
2018
- 2018-04-26 CN CN201810387139.4A patent/CN108764291A/zh active Pending
- 2018-08-24 WO PCT/CN2018/102224 patent/WO2019205384A1/zh not_active Ceased
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106952161A (zh) * | 2017-03-31 | 2017-07-14 | 洪志令 | 一种基于长短期记忆深度学习网络的股票近期走势预测方法 |
| CN107844865A (zh) * | 2017-11-20 | 2018-03-27 | 天津科技大学 | 基于特征参数选取与lstm模型的股指预测方法 |
| CN107832897A (zh) * | 2017-11-30 | 2018-03-23 | 浙江工业大学 | 一种基于深度学习的股票市场预测方法 |
Non-Patent Citations (1)
| Title |
|---|
| WANG, GUORUI: "Time Series Data Clustering Algorithm based on Recurrent Neural Network and Its Parallelization", ELECTRONIC TECHNOLOGY & INFORMATION SCIENCE, no. 2, 15 February 2018 (2018-02-15) * |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113435623A (zh) * | 2020-03-23 | 2021-09-24 | 北京沃东天骏信息技术有限公司 | 一种预警方法和装置 |
| CN114008658A (zh) * | 2021-09-30 | 2022-02-01 | 富途网络科技(深圳)有限公司 | K线形态的识别方法及电子设备 |
| CN116541738A (zh) * | 2023-05-08 | 2023-08-04 | 沈阳麟龙科技股份有限公司 | 基于k线形态聚类的相似k线序列搜索系统及方法 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN108764291A (zh) | 2018-11-06 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2019205384A1 (zh) | 电子装置、基于机器学习的股票择时方法及存储介质 | |
| Li et al. | Deep robust reinforcement learning for practical algorithmic trading | |
| Li et al. | Online portfolio selection: A survey | |
| US8417615B2 (en) | Methods and systems for computing trading strategies for use in portfolio management and computing associated probability distributions for use in option pricing | |
| WO2019019346A1 (zh) | 资产配置策略获取方法、装置、计算机设备和存储介质 | |
| CN114925842A (zh) | 基于量子退火求解优化问题的方法 | |
| US20240338768A1 (en) | Systems and methods for predicting a cluster of a side of order book market liquidity | |
| WO2019192135A1 (zh) | 电子装置、债券收益率分析方法、系统及存储介质 | |
| El-Berawi et al. | Adaptive deep learning based cryptocurrency price fluctuation classification | |
| CN112184305A (zh) | 一种企业估值方法、装置、电子设备及可读存储介质 | |
| US20210103990A1 (en) | Automated real time mortgage servicing and whole loan valuation | |
| Chen et al. | Analysis of frequent trading effects of various machine learning models | |
| Agnihotri et al. | Next-Generation Stock Market Prediction: Integrating CNN and LSTM Model | |
| Patil et al. | Cluster driven candlestick method for stock market prediction | |
| WO2020199483A1 (zh) | 金融数据的图像处理方法、装置、设备及计算机可读存储介质 | |
| CN106485363A (zh) | 一种股票日内价格趋势的量化及预测方法 | |
| Christensen et al. | Rebuilding the limit order book: sequential Bayesian inference on hidden states | |
| Hortúa et al. | Stock Return Predictability on S&P 500 ETF: A Deep Learning Approach | |
| Rahimi | Forecast comparison of financial models. | |
| Phatangare | Stock Market Forecasting | |
| Mallamo et al. | A predictive trading framework using functional linear discriminant analysis | |
| BaLashwar et al. | Optimizing Bank Stability Through MSME Loan Securitization: A Predictive and Prescriptive Analytics Approach | |
| Verma et al. | Automated Stock Trading using Machine Learning Approaches | |
| WO2019192136A1 (zh) | 电子装置、金融数据处理方法、系统和计算机可读存储介质 | |
| Chorro et al. | Testing for leverage effect in financial returns |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 18916212 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 08.02.2021) |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 18916212 Country of ref document: EP Kind code of ref document: A1 |