Please note that GitHub no longer supports your web browser.

Cointrol was created to automate Bitcoin speculation. Besides automated trading based on price change triggers and various trading strategies, it also provides a real-time updated dashboard for your Bitstamp account where you can see all your orders and transactions real-time updated (something Bitstamp lacks). The dashboard for a real-time updated overview can also be used standalone without letting Cointrol make any transactions.

Even though the original idea was to perhaps provide a fully-fledged hosted service, the system remained quite basic as it has only been used by its creator for a period of time in the winter of ’13/’14 (when BTC price fluctuations were pretty insane). Some of the obvious limitations—all of which could easily be addressed—are:

  • Only basic trading strategies are implemented
  • Single user/Bitstamp account is supported
  • Only one active trading session at a time
  • The whole account value is used when trading
  • Django admin is used for auth and trading strategy/session manipulations
  • Serves Webapp static files
  • Exposes DB for Webapp via a REST API
  • Forwards Redis pub/sub messages from Trader to Webapp via WebSocket
  • Exposes Django administration that is currently used for managing trading sessions

The server-side parts (cointrol-server + cointrol-trader) are written in Python 3 (3.3+ is required) and use a mixture of Django (models, admin) and Tornado (WebSockets, async IO). Other libraries that are used include sockjs-tornado, Django REST framework.

mkdir Cointrol && cd Cointrol

# Create an isolated Python virtual environment
pip install virtualenv
virtualenv ./virtualenv --python=$(which python3)

# Activate the virtualenv
# IMPORTANT: it needs to be activated every time before you run
#            a manage.py or cointrol-* command.
. virtualenv/bin/activate

# Get the code
git clone git@github.com:jakubroztocil/cointrol.git

# Create a local settings file
echo 'from .settings_dev import *' > cointrol/cointrol/conf/settings_local.py

# Install Python requirements
pip install -r cointrol/cointrol/conf/requirements.txt

# Initialize the database
cointrol/manage.py migrate

# Install cointrol-*
pip install -e ./cointrol
# Install dependencies
sudo npm -g install bower
cd cointrol/webapp
npm install
bower install

# Build the app
brunch build

# Use `brunch watch` during development

Note, until trading is configured and the COINTROL_DO_TRADE settings set to True (covered in a later step), the trader won’t make any transactions. It only pulls your data from Bitstamp to populate the dashboard view.

  1. Through the admin (http://bitcoinium.ru/:8000/admin/) you can create a trading strategy profile. It can be for the fixed (fixed price points in USD are used as buy/sell triggers) or the relative (percentage of the initial BTC price are used) strategy.
  2. Create a trading session (also in the admin interface).
  3. To perform actual transactions, you’ll have to enable them in the settings (we used the settings_dev module which disables them). Add COINTROL_DO_TRADE = True to your cointrol/cointrol/conf/settings_local.py.

During the installation process, you’ve created cointrol/cointrol/conf/settings_local.py which imports settings from the settings_dev.py file. All the settings are Django settings. The only non-Django settings is COINTROL_DO_TRADE (False in dev, True in prod). You can override any of the default settings in the settings_local.py file.

Besides settings_dev.py, the conf directory also has settings_prod.py, which is more suitable for production use. It defines logging configuration which makes messages of a level >= WARNING logged by the trader to be sent to you via email (e.g. when the trader places an order or there is an error). If you decide to use this settings file (by changing the import in settings_local.py to from .settings_prod import *, you’ll have to configure at least DATABASES, ADMINS and SECRET_KEY as well in your in settings_local.py.