[TOC]
After studying this tutorial, you will understand the architecture and functions of FMZ Quant Trading platform, and be able to create strategies and actually run bots. The specific strategy API writing will be introduced in the subsequent tutorials:
Elementary tutorial: https://www.fmz.com/bbs-topic/9091
Advanced tutorial: https://www.fmz.com/bbs-topic/9106
FMZ Quant Platform (former BotVS) is a professional quantitative community, founded in 2014. Here you can learn, write, share, buy and sell quantitative strategies, online backtest and use virtual exchanges to simulate trading, and run, open, and view live bots. It supports commodity futures and Esunny Outer disc Futures, as well as almost all commonly used cryptocurrency platforms. FMZ is suitable for beginners in quantitative trading. Even if you have no foundation, you can get started quickly. The platform is powerful and flexible, and it may also meet advanced needs. Welcome to join in the telegram group on homepage.
For cryptocurrency spot platforms, almost all of them are currently supported. If there are other required platforms, they will be supported soon after they are proposed. Supported cryptocurrency futures trading platforms: OKEX, Huobi, GateIO, BitMEX, Deribit, BFX; supported leverage platforms: OKEX, Huobi, Binance, FCoin, ZB, Bibox; supported perpetual contract platforms: BitMEX, Deribit, GateIO, OKEX, BFX, Bibox; it also supports Deribit cryptocurrency options trading; simulation platforms: exchanges test websites, such as BitMEX and FMZ official spot simulation trading platform “Wex.app”.
FMZ Quant platform supports the use of complete high-level languages such as Javascript, Python and C++, as well as visualization languages and Mylanguage (compatible with Webstock) to implement strategies.
The platform is charged by hour; each real bot charges 0.05 US dollars per hour; less than one hour is regarded as one hour; restart after suspension without repeated charges, FMZ single bot can operate multiple platforms, multiple accounts, and multiple trading pairs.
The server running the real bot needs to be prepared by yourself, or you can rent the server prepared by FMZ Quant platform (the price is comparatively high). A current mainstream overseas server is about 30 yuan per month. Only trading commodity futures can rent domestic servers.
Note: The cryptocurrency part of FMZ has been separated. The domestic website (www.fmz.cn) focuses on commodity futures business and can be recharged in RMB. The foreign website can only do cryptocurrency business and can be recharged in US dollars or USDT.
The structure of FMZ is special; unlike other trading software that needs to download the client, it basically only needs to be managed on the FMZ website, so there are so many advantages. The main function of FMZ website is to write strategies and manage the bots. The specific implementation of the bots is on the docker of users’ server or computer. The docker is responsible for communicating with the FMZ website to transmit logs, and directly run the bot to access platforms to obtain market quotes and tradings. If there is a short-term problem on the FMZ website, it will not affect the implementation of the strategy bot. Users can deploy the docker to any place to improve the trading speed, manage the bot, view logs, and modify parameters anytime and anywhere through FMZ website. For more introductions, please refer to: https://www.fmz.com/digest-topic/7542
API-KEY is the important private information of users. FMZ does not save the user’s KEY. The server saves the data encrypted by the browser according to the user’s password. When the real bot is created, the data is sent to the docker. For FMZ doesn’t save user’s plain text password, so the user’s API-KEY cannot be obtained, even if by FMZ. Users need to protect the plain text of the API-KEY, the FMZ website password and the server where the docker locates. FMZ Quant platform has been running for more than 4 years and has been used by tens of thousands of users without any security issues.
The source code of the strategy is saved on the FMZ server. If you want to execute the strategy locally, you can save your codes as a Python file and directly call and execute in the strategy. For the specific method, see the FAQ at the end of the top basic tutorials. In this way, your codes will be fully localized.
If you want to rent out the strategy without users seeing the source code, you need to use “js” to complete the strategy, which will be compiled into machine code executed by the tenant docker, which is very difficult to decompile. However, Python language itself does not have an encryption mechanism; FMZ has recently upgraded the encryption mechanism for selling Python strategy source code, but it cannot completely prevent the risk of strategy leakage. If you must use Python, you can help your client rent the docker to run the strategy.
The most important thing is to dare to start learning, step by step, and all steps must be taken by yourself. Even if it seems very difficult at first, once you complete the first strategy, you will find that everything is so easy. If you have a certain programming foundation, you can get started and write strategies within a week. If you don’t know programming knowledge, you need an extra week to learn the most basic programming knowledge. If you use Webstock before and are familiar with Mylanguage, you only need to know how to use the platform.
If any problem, you can always post questions in the forum at https://www.fmz.com/bbs, or send a ticket at https://www.fmz.com/m/tickets, or @managers in QQ group or WeChat group (they usually answer very quickly). Pay attention that you can try searching the documents or visit the forum first to solve your problems, and you need to provide sufficient information when asking questions.
The steps to run a bot from scratch are as follows:
If the first three steps have been done, you only need make the fourth step. Next, take a WeChat price warning bot as an example to introduce how to run a bot from the beginning. More detailed functions of the platform will be introduced in next chapter.
First, you need to log in to the corresponding exchange website to apply for the API-KEY. The KEY is divided into two, namely “Access Key” and “Secret Key”. The Access Key may have other names, but just remember that one is Secret Key and the other is Access Key. API-KEY is used to encrypt data and verify identity. It is similar to username and password. It is very important, so you cannot leak it out. Different platforms have different application locations, just search “API” and you will find them. Note that if a platform supports both spot and futures, spot and futures need to be added separately, such as OKEX and OKEX futures, Huobi and Huobi futures, even if their API-KEY is the same. Here we take FMZ official virtual platform “Wex.app” as example.
The website address is: https://wex.app. (Note that due to network reasons, Wex simulated platform sometimes requires overseas dockers to access.) You need to register an account by email. After the registration, the virtual assets in the “wallet” should be transferred to the “coin account” on Wex virtual platform, and initially there are no trading assets. Click API Management on the user avatar in the upper right corner of the website. Click “Create” and enter the email verification code to create. Among them, you can see IP restrictions and available permissions. It is safer that IP restrictions can only allow programs under this IP address to access the account. As for permissions, don’t forget to add trading permissions, otherwise you will not be able to place an order.
The obtained API-KEY in the demo, namely Access Key and Secret Key, which can only be seen once, so don’t forget to record and save it.
Enter the interface of adding platform (https://www.fmz.com/m/platforms), and click ”Add platform” button.
First, select cryptocurrency for the platform category, select WexApp for the platform name (because there are many platforms, you can directly enter the text to select), and then copy the “KEY” you just apply for. Note that a platform can be added multiple times, by using different labels to distinguish. To add a platform, you need to enter the FMZ website password, where the browser encrypts the entered KEY and uploads it.
After adding, you can see the added platforms on the page, and you can also modify the added platforms.
If you want to run the commodity futures CTP virtual trading, you need to add “simnow”. For detailed procedure reference: https://www.fmz.com/bbs-topic/325
On “Strategy” page: https://www.fmz.com/m/strategies, click “Add strategy”. In order to demonstrate that we can directly copy a strategy, you can find the public strategy of “Push the price information to telegram” in the teaching strategy of “Square” (the address: https://www.fmz.com/strategy/125482), click and cope the strategy.
The figure below shows the copied strategy, in which there is a “|” in the strategy name to separate Chinese name and English name. If you want to publish a strategy with an English name, you can also use this method. Parameters are global variables that can be directly quoted in strategy codes. The strategy code is very simple. GetTicker() is used continuously to obtain the latest price in an infinite loop. When the push standard is reached, a message is pushed to WeChat (you need to bind a WeChat account on the FMZ website). Click “Create” to see this strategy in your own library.
If the strategy is modified, you only need to save the strategy and restart the strategy bot, which will makes the modification valid.
Docker page: https://www.fmz.com/m/nodes. As mentioned earlier, the user’s bot is not run by the FMZ platform, but by the user himself, so a program that executes the strategy is needed, which is called docker. Dockers can be run on Linux\Mac\Windows. Note that since almost all cryptocurrency exchanges cannot be used in China, the docker needs to run on an overseas server. Users can choose a server provider to buy a Linux server (the system can generally choose centos), and the server can choose Amazon, Google and digitalOcean, etc. If you do not have a dual currency credit card, you can also choose a service provider that supports Alipay. The server configuration generally selects the lowest, and the price is about 1 yuan per day.
Buying a server may seem difficult, but it is a necessary step in cryptocurrency quantification, and here is a detailed purchase demo. If you feel that overseas companies are troublesome, you can also choose Alibaba Cloud Hong Kong server. If you still find it troublesome, you can rent it directly from FMZ Quant platform on time just with one click. FMZ will rent a new server directly from Alibaba Cloud and other server manufacturers and automatically deploy the user’s docker, which is the simplest but relatively expensive. Refer to the detailed steps for specific Linux server deployment and upgrade: https://www.fmz.com/bbs-topic/2848
For commodity futures users, you can directly rent Alibaba Cloud servers in Shanghai or Hangzhou on a monthly basis at a price of 40 yuan per month. The price has been compressed to the lowest level (it is basically the same price as the renting price by yourself), which can save you the trouble of renting servers and management by yourself. Dockers can also upgrade with one click, which is highly recommended.
Since the demo is a virtual exchange, it can be directly deployed on your own computer (for commodity futures, you can also use your own computer). Select the 64-bit interface version, right-click after decompression, and run the robot program with administrator privileges. Fill in the address on the website (each user is different, so check on the docker page after logging in) and the FMZ website password information into the program; click Run, if you can see 2019/08/09 12:03:30 Login OK, SID: 90706, PID: 31376
and other words, which indicates that the operation is successful. You can see the logs file in the docker directory, and the bot logs will be saved there. In the docker management interface, you can see the docker you just deployed.
If the bot program doesn’t need particularly high performance, a docker can run multiple bots (the minimum configuration of the server is no problem to run more than a dozen bots). Note that a server can also deploy multiple dockers, but it is generally not required. The docker communicates with the FMZ website and, return the bot status and control the bot. Due to problems with overseas servers and domestic communication, the docker will occasionally be prompted offline, but it doesn’t affect the actual operation of the bot. If a docker is completely offline, it will not be able to operate the bots run by it, so this docker needs to be deleted. If the old docker doesn’t support adding new functions, an announcement will be issued, and users can choose to update according to their needs.
After the above work is completed, a bot can be actually run. On the bot page ( https://www.fmz.com/m/robots), click “Add bot”, and the following settings will appear:
When creating a bot, you need to set a specified strategy, a specified running docker, an platform and a trading pair to be operated, the default K-line period, and strategy parameters, etc. A bot can add trading pairs of multiple platforms, and can also control multiple trading pairs of the same platform. If the required trading pair is not found in the combo box, you can click custom to enter it manually. Except for the running strategy, other parameters all can be modified on the page of a specific bot.
After creating a bot, you can find it on the bot page, and click to enter the running bot.
So far, we have created a bot. Is it very simple?
The first is the main page of dashboard after logging in, of which the side and top are the navigation bars, which will be introduced one by one as follows.
Strategy writing can be done on the FMZ website or remotely. The strategy parameters will be explained in next tutorial.
In the combo box of “Action”, you can see “Public” option, which includes internal share and public share, and the internal share process is shown as follows:
At last, a copy link will be generated, and others can just open the link and enter the copy code, to obtain the strategy source code and parameters.
If you choose to share to public, your strategy will be displayed in the “Square”, and all the users can see it.
There are three ways of “Sale”, including “Internal Sale”, software registration and “Public Sale”. The difference from pubic strategies is others cannot obtain the strategy source code by the copy link, and they can only run the bot by the strategy.
Internal sale is the most common way. If there are strategies that you want to share to others solely (which doesn’t have to be charged), you can choose internal sale, and fill out the validity period and concurrent amount. If the public sold strategies are shown in the charged strategies, the bots of the strategies shall be verified and open to public for a while.
“Trade” is a web version of trading page, where you can add all platforms manually by yourself.
Through the navigation bar on the left, enter the payment page, and the specific instructions are as follows:
Click the account avatar in the upper right corner of the website to enter the account settings, and manage your own FMZ account on this page. Here is a brief introduction about it.