Wyden (WY) strategies, as well as WY server can be run on Docker containers in just a few steps (How to run Wyden on Docker). There are 2 ways of starting a Wyden 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. The Wyden examples project contains already configured Dockerfiles that you can easily adjust for your own strategy:
https://www.algotrader.com/downloads/latest-examples
e.g. in Random strategy:
FROM docker.wyden.io/algotrader/algotrader:latest
MAINTAINER Wyden AG <info@wyden.io>
ENV STRATEGY_NAME=RANDOM
ENV SPRING_PROFILES=live,pooledDataSource,embeddedBroker,html5
WORKDIR /usr/local/strategy
ADD target/*-bin.tar.gz .
ENTRYPOINT ["/usr/local/algotrader/bin/docker-strategy-run.sh"]
CMD ["-e"]
To build the image, execute the following command:
docker build <path to dockerfile>\. -t <image name>
e.g.:
docker build . -t random
After you successfully build the image, it will be available for docker:
Wyden examples contain also docker-compose.yml files that can be used to run WY on Docker containers. In this example we will run 2 strategies:
- cryptos
- cryptos2
For the cryptos strategy, we will use the image created above, although for the cryptos2 strategy we will use an image from our Wyden 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 WY 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 Wyden will start in distributed mode together with both strategies, MySQL and InfluxDB container. The Wyden web UI is exposed on localhost:80.
The random strategy project contains 2 docker-compose.yml files, one is set up to work in distributed mode, and by running the second one, Wyden with the strategy will start in embedded mode. If you are interested in running Wyden in embedded mode, you can check those docker-compose files, about the base examples directory you have extracted: examples/random.
Common issues:
- If you build a strategy without the examples project as a parent, then it is imperative to update your strategy's pom.xml using the below guide so that the related jar files will be deployed correctly in the docker image.
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<dependencies>
<dependency>
<groupId>algotrader</groupId>
<artifactId>algotrader-core</artifactId>
<version>6.5.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>strategy-bin</descriptorRef>
</descriptorRefs>
<tarLongFileMode>gnu</tarLongFileMode>
</configuration>
</execution>
</executions>
</plugin>
Comments
0 comments
Please sign in to leave a comment.