Disclosure of Invention
The invention aims to provide a real-time algorithm trading system and a real-time algorithm trading method in a stock trading process.
In order to solve the technical problems, the invention is realized by the following technical scheme:
the invention relates to a real-time algorithm trading system in the stock trading process, which comprises a trading control unit and a trading server;
the trading control unit is used for receiving a stock buying pre-request input by a user, sending the stock buying pre-request to a trading server, and sending a stock buying identifier returned by the trading server to the user;
the trading control unit receives the stock buying request and the stock buying mark input by the user and sends the same to the trading server
The trading server is used for receiving the stock buying request and the stock buying identification, judging the risk of the stock, checking the stock buying identification, executing buying operation after successful checking, generating a stock selling identification and sending the stock selling identification to the trading control unit;
and the trading server verifies the stock selling identifier and executes the stock selling instruction after the verification is successful.
As a preferred technical scheme, the trading server does not receive a stock selling instruction sent by a user; and the trading server generates a stock selling identifier according to the stock buying request and the stock buying identifier.
The invention relates to a real-time algorithm trading method in a stock trading process, which comprises the following steps:
step S1: the trading control unit receives a stock buying pre-request input by a user and sends the stock buying pre-request to a trading server;
step S2: the trading server sends the stock identification input by the user to a stock risk model;
step S3: the risk model outputs a stock entropy risk value which is sent to a user by a trading server together with a stock buying identifier;
step S4: the risk model ranks stocks of the same type from low to high according to the entropy risk value of the stocks;
step S5: the trading server calculates the competition ratio of the lowest-risk stock and the stock selected by the user;
step S6: sending the competition ratio and the buying identification of the lowest risk stock to the user;
step S7: the trading control unit receives the stock buying request and the stock buying identification input by the user and sends the stock buying request and the stock buying identification to the trading server.
As a preferred technical solution, after the step S7, when the trading server receives the stock buying request and the stock buying identifier, and verifies the stock buying identifier, after the verification is successful, the buying operation is executed and a stock selling identifier is generated, and the stock selling identifier is sent to the trading control unit; when the trading control unit generates a stock selling trading rule according to the stock buying request, the price change of the stock is monitored in real time, when the real-time price of the stock meets the stock selling trading rule, a stock selling instruction is generated, and the stock selling instruction and the stock selling identification are sent to the trading server together; the trading server checks the stock selling identification, and executes the stock selling instruction after the check is successful.
As a preferred technical solution, in step S1, the trading server generates a stock buying identifier according to the stock buying pre-request, wherein the stock buying identifier is a buying code; the purchase code includes a string generated using a random algorithm or an encryption algorithm.
As a preferred technical solution, in step S2, the training process of the stock risk model is as follows:
step S21: acquiring stock history data;
step S22: calculating initial entropy risk value
Step S23: respectively averaging the initial entropies of the six groups of interval numbers q;
step S24: carrying out linear relation analysis on the mean value of the initial entropy and k;
step S25: obtaining six groups of interval data, wherein the linear relation is 0.64083x + 1.890258;
step S26: entropy risk value of stock
As a preferred technical solution, in step S21, the acquired stock history data includes list data, disk data, stroke-by-stroke data, and time-sharing k-line data.
As a preferred technical solution, in step S4, stock list data, disk mouth data, batch-by-batch data, and time-sharing k-line data are refreshed in real time by the trading server, a subscription publishing mode is adopted to perform socket long connection with the trading server, each module requests data from the trading server and stores the data in a cache, the cache of each requested data module is processed in the trading server, and the cache is classified according to data types.
As a preferred technical solution, in the step S5, the competition ratio of the lowest risk stock to the stock selected by the user is calculated as follows:
the invention has the following beneficial effects:
the invention receives the stock buying pre-request input by the user through the trading control unit, sends the stock buying pre-request to the trading server, and the trading server judges the risk value of the stock selected by the user and sends the risk value to the user through the trading server and the stock buying mark, thereby increasing the stock buying interest of the user and improving the stock income of the user.
Of course, it is not necessary for any product in which the invention is practiced to achieve all of the above-described advantages at the same time.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The invention relates to a real-time algorithm trading system in the stock trading process, which comprises a trading control unit and a trading server;
the trading control unit is used for receiving a stock buying pre-request input by a user, sending the stock buying pre-request to a trading server, and sending a stock buying identifier returned by the trading server to the user;
the trading control unit receives a stock buying request and a stock buying identifier input by a user and sends the stock buying request and the stock buying identifier to the trading server;
the trading server is used for receiving the stock buying request and the stock buying identifier, judging the risk of the stock, checking the stock buying identifier, executing buying operation after successful checking, generating a stock selling identifier and sending the stock selling identifier to the trading control unit;
the trading server checks the stock selling identification, and executes the stock selling instruction after the check is successful.
The trading server does not receive the stock selling instruction sent by the user; the trading server generates a stock selling identifier according to the stock buying request and the stock buying identifier.
Referring to fig. 1, the present invention relates to a real-time algorithm trading method in a stock trading process, which comprises the following steps:
step S1: the trading control unit receives a stock buying pre-request input by a user and sends the stock buying pre-request to a trading server;
step S2: the trading server sends the stock identification input by the user to a stock risk model;
step S3: the risk model outputs a stock entropy risk value which is sent to a user by a trading server together with a stock buying identifier;
step S4: the risk model ranks stocks of the same type from low to high according to the entropy risk value of the stocks;
step S5: the trading server calculates the competition ratio of the lowest-risk stock and the stock selected by the user;
step S6: sending the competition ratio and the buying identification of the lowest risk stock to the user;
step S7: the trading control unit receives the stock buying request and the stock buying identification input by the user and sends the stock buying request and the stock buying identification to the trading server.
After step S7, when the trading server receives the stock buying request and the stock buying identification, and verifies the stock buying identification, after the verification is successful, the buying operation is executed and a stock selling identification is generated, and the stock selling identification is sent to the trading control unit; when the trading control unit generates a stock selling trading rule according to the stock buying request, the price change of the stock is monitored in real time, when the real-time price of the stock meets the stock selling trading rule, a stock selling instruction is generated, and the stock selling instruction and the stock selling identification are sent to the trading server together; the trading server checks the stock selling identification, and executes the stock selling instruction after the check is successful.
In step S1, the trading server generates a stock buy identifier according to the stock buy pre-request, the stock buy identifier being a buy code; the buy code comprises a string of characters generated using a random algorithm or an encryption algorithm, which may be 6 randomly generated numbers, for example 123456; it should be understood that the stock buy identification can also be other identifications, such as pictures, etc.
In step S2, the training process of the stock risk model is as follows:
step S21: acquiring stock history data;
step S22: calculating initial entropy risk value
Step S23: respectively averaging the initial entropies of the six groups of interval numbers q;
step S24: carrying out linear relation analysis on the mean value of the initial entropy and k;
step S25: obtaining six groups of interval data, wherein the linear relation is 0.64083x + 1.890258;
step S26: entropy risk value of stock
In step S21, the acquired stock history data includes list data, disk opening data, stroke-by-stroke data, and time-sharing k-line data.
In step S22, in the stock screening process, the entropy risk value measure is taken as the basis: if the entropy risk value of the stock is large, the stability of the income of the stock is considered to be poor, the investment risk is high, and the investment is temporarily not suitable; and if the entropy risk value is small, the stability of the income of the stock is considered to be strong, the investment risk is low, and the investment is suitable.
In step S25, the initial entropy risk value increases with the increase of the interval density, and it is found through analysis that the initial entropy mean value and k are likely to satisfy a linear relationship. In view of the fact that initial entropy data is large, fitting is not performed on each initial entropy risk value, and the mean value of the initial entropy risk values is selected for linear fitting so as to simplify calculation. The initial entropy values of the surface densities of the six groups of intervals are averaged, then the linear correlation analysis is carried out on the average value and k, and finally the risk value of the stock entropy is obtained
Therefore, when the interval density is gradually increased and the step length is gradually reduced, the approaching effect of the measurement result on the q-320 stock risk value is better and better, and the measurement accuracy of the entropy model on the stock risk value is gradually improved. And reordering 598 stocks in ascending order by taking the entropy risk value when q is 320 as a standard, and selecting the top 20 stocks into the investment target.
In step S4, stock list data, disk mouth data, stroke-by-stroke data, and time-sharing k-line data are refreshed in real time by the trading server, a socket long connection is made with the trading server in a subscription and release mode, each module requests data from the trading server and stores the data in a cache, the cache of each requested data module is processed in the trading server, and the caches are classified according to data types.
In step S5, the competition ratio of the lowest-risk stock to the stock selected by the user is calculated as follows:
from t
1Stock price starting at the moment, and the first occurrence is recordedIn that
At a price of
Push button
For a price of
To buy the stock, the second transaction time point is recorded as t
2(ii) a If from t
1The time begins and does not appear less than the whole transaction time period
The price of (2) is then the total funds left
At last stock price p
iThe purchase price.
It should be noted that, in the above system embodiment, each included unit is only divided according to functional logic, but is not limited to the above division as long as the corresponding function can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
In addition, it is understood by those skilled in the art that all or part of the steps in the method for implementing the embodiments described above may be implemented by a program instructing associated hardware, and the corresponding program may be stored in a computer-readable storage medium.
The preferred embodiments of the invention disclosed above are intended to be illustrative only. The preferred embodiments are not intended to be exhaustive or to limit the invention to the precise embodiments disclosed. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the invention and the practical application, to thereby enable others skilled in the art to best utilize the invention. The invention is limited only by the claims and their full scope and equivalents.