After some tweaks and cleanups, I’ve decided to share the code to a couple of friends as they expressed interests to have a bot trade for them too.

To make things easier, I’ve dockerised the trading project, bundling a python2.7 image with dependencies installed, batteries included, to Docker Hub

This was in the hope that it’ll be a one-liner when people run the code, after the one-time docker installation and git pull. And it’ll work everywhere! Linux, Mac, Windows, what have you.

Almost true.

Windows 7 32 bit isn’t supported. But I’ll share how I organised the docker configs here.

The following is roughly the plan:

ec2-docker infrastructure

First I use docker-compose to declare all the images:

# docker-compose.yml
test:
  build: .
  dockerfile: Dockerfile.test
  env_file: test.env
  volumes:
    - ./:/usr/src/app

live:
  build: .
  dockerfile: Dockerfile.live
  env_file: live.env
  volumes:
   - ./:/usr/src/app

I have a pre-built image hosted for free on Docker Hub which builds on Python:2.7, installs TA-lib and other smaller dependencies for the project.

Then Dockerfile.live and Dockerfile.test are identical, pulling from the pre-built image, and appending different commands:

# Dockerfile.test
FROM kakadadroid/python27-talib
MAINTAINER skeang@gmail.com

CMD py.test
# Dockerfile.live
FROM kakadadroid/python27-talib
MAINTAINER skeang@gmail.com

CMD python runner.py

With the docker image successfully downloaded, the command to trade looking at the current prices can now be a one-liner: docker-compose run live.

Similarly, it’s a one liner to run all tests: docker-compose run test

Now, how make this work on Windows 7… :fliptable: