Build your own quantitative system
If you want to remain invincible in the market for a long time! It is necessary to form a set of own trading system.
How to learn to build your own quantitative trading system?
Learning while actually fighting, learning in actual combat is the most effective way . So we share a quantitative system that can be used for both learning and actual stock trading analysis - QTYX.
The purpose of sharing the QTYX system is to provide you with a template for building a quantitative system, and ultimately help you build your own system. Therefore, we provide the source code, which can be re-developed according to your own style.
The QTYX system structure is as follows:
Since QTYX has been iteratively updated, the current introduction corresponds to version V2.5.7 . Subsequent upgrades will update the content of the document synchronously.
Function overview
The "Trade" sub-page of the stock quantitative analysis tool QTYX provides the function of remote market monitoring.
We can deploy QTYX on the cloud server, and let QTYX help us keep an eye on the market in real time. When the real market market reaches the target we set, we will be notified by instant messaging tools such as email, WeChat or DingTalk.
Start real disk monitoring
Click on QTYX "Trade" to enter the sub-page.
Select "Fixed disk scan time", there are four levels of "5 seconds, 15 seconds, 30 seconds and 60 seconds".
After clicking "Start Firm Offer", the monitoring will start. The monitoring time period is 9:25--11:31 and 12:59--15:01.
QTYX will obtain the latest market data of the whole market in real time, and read the allocation of individual stocks in the "trading stock pool (trading condition list)" and "holding stock pool".
When it is judged that the instructions in the "trading condition list" and "holding stock pool" meet the conditions, an alarm will be triggered and the transaction will be executed.
How to generate the content in the "Trading Condition Sheet" and "Pool of Holding Stocks"? Next, let's take QTYX deployed on the cloud server as an example to introduce.
Add transaction terms
The "trading condition sheet" records the information of the stocks that need to be traded in the real market, such as the stocks bought and sold, quantity, price, strategies executed in the market, etc.
After clicking "Import Stock Pool", the latest market data of the stocks in the self-selected stocks will be loaded into the interface.
After clicking the stock code, the transaction order configuration interface will appear.
We fill in the trading direction (buy or sell), the price of buying and selling, and the number of stocks bought and sold according to the results of our own strategy analysis.
Fill in the transaction configuration parameters for Miracle Pharma as follows:
After the configuration is complete, click OK and it will be added to the "trading stock pool" on the left.
If you want to delete the stock or change the trading parameters, double-click the stock code in the stock pool to select it.
Add stop loss order
The "holding stock pool" records the take-profit and stop-loss setting values of the held stocks.
A sell signal will be triggered when the take profit and stop loss value is triggered in the day.After clicking "Import Stock Pool", the latest market data of the stocks in the self-selected stocks will be loaded into the interface.
Click on the stock code, then select "holding stock pool" and the configuration interface will appear.
We can change the mode and range of take profit and stop loss, and the configuration interface will also display the buying price and the highest price after holding.
At present, the take-profit mode we support is a fixed ratio, such as a 10% stop-profit after buying. The stop loss mode is a dynamic retracement stop loss. For example, after buying, the stock price falls by 5% from the highest price, and then the stop loss is exited.
Fill in the take profit and stop loss configuration parameters of "Quanjude" as shown below.
After clicking confirm, it will be added to the "holding stock pool".
If you want to delete the stock or change the take profit and stop loss parameters, double-click the stock code in the stock pool to select it.
In addition, when the purchase of the stocks in the "trading conditional order" is triggered, it will be automatically updated to the "holding stock pool".
If there are stocks that are purchased manually, you can also update the "holding stock pool" by adding information in ConfigFiles/hold_para.json
Send analysis report remotely
After the firm offer monitoring is started, the latest market data of the specified stocks will be refreshed periodically.
When it is found that the stock has reached the buying or selling price during the firm offer, or meets the conditions for stop-profit and stop-loss trading, a message reminder will be sent remotely. (Remember to fill in the mailbox information in ConfigFiles/sys_para.json, and enable the QQ mailbox reminder function on WeChat, the effect is the same as WeChat reminder)
Automatic trading interface
In the configuration parameter dialog box, if automatic trading is checked, the system will automatically execute the buying and selling operation according to the set parameters.
It should be noted that QTYX supports access to the third-party library easytrader to perform automatic transactions, and it is enough to debug the easytrader library in your own environment before using it.
For details, please refer to the following public number articles:
If you have stabilized the debugging of automatic trading, you can add the function of automatic trading to the following code, thus completing the end link of automatic trading.
if val['auto_trade'] == True:
print("自动交易需调试交易环境,查看公众号《小散量化炒股记|要克服人性弱点?激活股票全自动化交易!》")
illustrate
The complete QTYX source code is uploaded to Knowledge Planet "Fun with Stock Quantitative Trading". Friends who want to join Knowledge Planet remember to call me on WeChat to get benefits!
Knowledge Planet Introduction Click: Knowledge Planet "Fun with Stock Quantitative Trading" essence content overview