AlgoTrader (AT) strategies, as well as AT server can be run on Docker containers in just a few steps (How to run AlgoTrader on Docker). There are 2 ways of starting an AlgoTrader strategy: embedded mode and distributed mode. In this article, we will focus on a distributed deployment because Docker containers are a perfect solution for that.
Firstly, create a docker image of the strategy. AlgoTrader examples project contains already configured Dockerfiles that you can easily adjust for your own strategy:
e.g. in Random strategy:
MAINTAINER AlgoTrader AG <firstname.lastname@example.org>
ADD target/*-bin.tar.gz .
To build the image, execute the following command:
docker build <path to dockerfile>\. -t <image name>
docker build . -t random
After you successfully build the image, it will be available for docker:
AlgoTrader examples contain also docker-compose.yml files that can be used to run AT on Docker containers. In this example we will run 2 strategies:
For the cryptos strategy, we will use the image created above, although for the cryptos2 strategy we will use an image from our Algotrader docker repository.
Before starting the strategies it's needed to fill DB with strategies names and configure connection to the exchange in Configuration UI, in this example Binance Global account was activated. After that AT downloaded reference data and based on that securityIDs were updated for each strategy.
Adjusted docker-compose.yml file:
After executing docker-compose up in the folder containing docker-compose.yml Algotrader will start in distributed mode together with both strategies, MySQL and InfluxDB container. The AlgoTrader web UI is exposed on localhost:9090.
The random strategy project contains 2 docker-compose.yml files, one is set up to work in distributed mode, by running the second one, AT with the strategy will start in embedded mode. If you are interested in running AT in embedded mode, you can check those docker-compose files, in reference to the base examples directory you have extracted: examples/random.
- Notice that: -Dhz.discovery.tcp.members= should point to the member address picked by the server: