When we carry out the programming and quantitative trading, we can use any device to run the quantitative trading program (a robot program that operates the account to trade according to a certain trading strategy). However, it is safer to use a server in an operator's computer room. The network communication and power supply are more secure. After all, the quantitative trading program operates the account assets of real money, and the basic guarantee that can be achieved should be done as much as possible. Using your own computer and other equipment to run quantitative trading programs, the loss caused by power outages and network disconnections at critical moments can be considered a big loss compared to the cost of the server. So let's talk about the use of servers and related content when doing quantitative trading today.
What is the "server" running a quantitative trading robot?
The server here can be simply understood as a computer device running in the server room of a server provider. Like an ordinary computer, it has memory, CPU and hard disk. The server provider ensures stable power supply, network communication, etc. We users of the server provider, pay the server provider (of course there may be some free ones, we use the paid ones usually) and the server is provided to us for our use (on a rented basis, with monthly payments, daily payments and other payment options). We log in the server remotely and we can run our program, download software, etc. We run the quantitative trading robot program on the server, and the quantitative trading robot program can access the interface of the exchange (digital currencies), the front servers of futures companies (commodity futures) for operations such as market acquisition, order trading, etc. There may be many different kinds of servers (products) offered by server providers, and the price varies by type and configuration. Generally, if you do quantitative trading with a small number of trading robots (1~5), you can choose the lowest configuration VPS server, which generally costs around 60~100CNY (if the price is too low, you should pay attention to whether it is a hardware resource "shared" server, which has a low performance).
Choose the server providers
- Alibaba Cloud
- vultr
- Amazon
- Linode
There are many server providers, and you can search for them by yourself on Baidu or Zhihu. You can choose your own suitable one according to the payment method and the location of the server room (the closer to the exchange server, the better, after all, the faster the future programs running on the server, it can access the exchange better).
Choose the server operating system
- The Windows system is easy to operate. It is almost the same as the Windows system on your own computer, but it is not recommended. Linux has higher performance stability.
- Linux system is more complex than Windows, but it has good stability and performance. Although the operation is complex, you can just use some commands for deploying quantitative trading programs.
There are many versions of Linux system, mainly including:
· CentOS
· Debian
· Ubuntu
You can choose according to your own needs, generally, we use CentOS.
Use of the server
After paying to rent a server from a server provider, the server provider will send you the login password for the server (in the form of an email). It is also possible to set the login password by the user on the page at the time of rental. You need to keep the login password safe and use it when you log in the server remotely.
- Windows system
Windows system is relatively simple to use. We can log in the server provider's website page terminal or use "Remote Desktop Connection". - Linux system
There are several ways to log in remotely: · For Linux system login, we can use the terminal on the server provider's website page to log in, such as Alibaba Cloud:
Generally, you can find the leased server remote connection terminal on the server provider's website after logging in. Fill in the login password and log in.
· Software such as putty etc. We can also use some remote login software to log in. If you use the Windows system (not your server, but your current computer), you can use the software ```putty```. You can refer to the related introduction: https://baike.baidu.com/item/putty/5426468?fr=aladdin Configure the information such as the IP address of the server to log in. The user name of the Linux server is ```root```. When logging in, enter the user name first, click on Enter, and then enter the login password. Note that when entering the login password, you cannot see it, just enter it. If you are prompted to select Yes/No, you can select it according to the content (usually enter yes and click on Enter), as shown in the following figure. /upload/asset/28da6584fc2e8bd8d107a.png · Apple computer terminal ssh login Open the terminal, as shown in the screenshots: /upload/asset/28dd3af3e8ac145f31950.png /upload/asset/28e3fb645996226a7f7b5.png /upload/asset/28e154a8622766dcb8bf7.png Use the command ```ssh root@xxx.xxx.xxx.xxx``` to login remotely, xxx.xxx.xxx.xxx is the IP address of the server you want to login. /upload/asset/28dfeaaf02e8288cb6980.png Input your login password to login. /upload/asset/28d9e37685b01be1e7b93.png After remote login, in the Linux operating system, we often use the command line interface to operate, input operation commands, and perform specific work.
Linux common commands
After logging in to the Linux server, the operation is the same, which has no relation with what system your own computer is or how you login. So we use the terminal screenshot after the Apple Computer (MAC) login to demonstrate the common commands.
- ls
To view the contents of the current directory is to see what files, programs, etc. are in the current folder. Use the parameter - a to view all contents, as shown in the following:
We can see that there are three files in the current directory: the robot docker program, the robot compressed package, and the log folder of the logs docker program. (These were downloaded by myself, and for demonstration)
- pwd
View the current directory, as shown below: - cd
To enter a directory, for example, if I want to enter the logs folder in the figure above, I can entercd logs
in the directory in the figure above, as shown below:
It goes to the logs directory.
At this point, we use pwd to view the current directory.
We can see the changes. If I want to go back to the previous directory, just use the cd..
command.
We can see that the parent directory is returned.
- mkdir
We create a folder in the current directory, first wels -a
look at the contents of the current directory, thenmkdir test1
create a directory (folder) namedtest1
, and finally inls -a
, we can see it is created. - rm
Delete command. If I want to delete the folder (including its contents) just created, we can userm - rf test1
.
If I want to delete a file, such as a robot program, use rm robot
, as shown below:
- wget software
Generally, CentOS installs wget by default. If you do not have it, you can search Baidu to install it.
For example, use wget to download the docker program of FMZ Quant Trading Platform, and the download link of the docker program of Linux 64 system is:http://www.fmz.com/dist/robot_linux_amd64.tar.gz
.
Use the wget
link to download, such as wget
http://www.fmz.com/dist/robot_linux_amd64.tar.gz
- tar
Decompress command, for example, decompress the compressed package robot of the docker program you just downloaded: robot_ linux_amd64.tar. gz,tar -zxvf robot_ linux_ Amd64. tar. gz
, as shown below:
- nohup
Nohup runs the program in the backstage to prevent the program from stopping after the remote login is disconnected.
For example, deploy the robot docker program of FMZ.
Use the command:nohup ./robot -s node.fmz.com/XXXXXX -p YYYYYYY &
node.fmz.com/XXXXXX
is a unique address for each FMZ account (it can be found on the add docker page of FMZ platform). TheXXXXXX
part of each user is different. TheYYYYYYYY
after - p is the corresponding FMZ account password for the address.