CryptoCurrency / Docker · October 23, 2021

FreqTrade: Quickly deploy your BOT ARMY!

In this episode, I build upon the last topic around FreqTrade’s integrated Dashboard, and show you how to quickly scale out your army or FreqTrade bots, by storing the container variables as Docker environment variables, so you only have one place you need to make changes, as you copy and deploy your bots rapidly. Check out the video, and when you’re ready, below is the sample code you came here for!

Also, if you’re looking for a great machine to run your fleet of FreqTrade bots on, I highly recommend this small form-factor Intel NUC – this is an amazing price on a rock-solid piece of hardware, in a compact, silent, power-efficient format! Please note this is an affiliate link and I may receive a commission from your purchase. Clicking this link and completing your regular Amazon purchases is an easy no-cost way to support the channel!

YouTube player

Here’s your sample code for your docker-compose.yml file:

version: '3.3'

    external: true

    image: freqtradeorg/freqtrade:develop
      - ./user_data:/freqtrade/user_data
      - /etc/timezone:/etc/timezone:ro
    command: >
      --logfile /freqtrade/user_data/logs/freqtrade.log
      --config /freqtrade/user_data/config.json
      --strategy ${STRATEGY}
      --db-url sqlite:///user_data/${DATABASE_FILE}
      - proxy
      mode: replicated
      replicas: 1
          - node.role == manager
        condition: on-failure
        delay: 5s
        - 'traefik.http.routers.${BOTNAME}.tls=true'
        - 'traefik.http.routers.${BOTNAME}.rule=Host(`${BOTNAME}`)'
        - '${BOTNAME}.loadbalancer.server.port=8080'

In the above sample code, it’s important that you are using a wildcard subdomain in the placeholder. If you are not familiar, this means you want everything (*) under that namespace to resolve to the IP of your docker host. If you need a refresher on this, check out my Traefik proxy video, I cover this in-depth!

YouTube player

Next, you need the .env file that contains the variables referenced in the sample docker-compose.yml, so, here you go!


The above file should be saved as a hidden “dot file” in the same path with your docker-compose.yml file, as .env

The BOTNAME variable dictates what the fully-qualified name of the deployed bot will be, ie:

The STRATEGY variable needs to be the exact (case-sensitive) name of your strategy file, which is stored in user_data/strategies folder

Also remember when you’re copying your base FreqTrade folder (this was bot001 in the video, for example), that you want to go in and remove the existing trades.sqlite database, and clear the logs by removing the logs/freqtrade.log file if it exists, after copying, and before deploying

Lastly, you’re probably looking for that command that lets you use .env variables with a docker stack deploy deployed container! Here you go:

docker stack deploy -c <(docker-compose config) stackName

This looks similar to the standard deploy command, however we can see that in place of where we normally reference the docker-compose.yml file, we’re telling it to evaluate that configuration with docker-compose instead! When this runs, it builds the config, evaluating the variables, and then passes that all back to docker stack deploy to complete the deployment.

I hope this is helpful to you! Please give me a thumbs up on the video if you found it useful, subscribe if you’re not already, and leave me a comment if you have questions or thoughts! Thank you!