Git Product home page Git Product logo

cated's Introduction

CATEd - Cryptocurrency Analytics and Trading Engine for Django

Overview

HabraHabr article in Russian

CATEd is the cryptocurrency trading bot written on Python 3 with feature-rich management Web interface (Django, Celery).

Main features:

  • View the status of exchange accounts, transactions and orders on them;
  • View the status of cold wallets and transactions details;
  • History of deposits and withdrawals on graphical diagram;
  • Configurable buy/sell/hold logic, (allowed tokens and proportions);
  • Keeping the balances of different tokens at the configured levels;

home_page

main_bot_page

Install

You need python3, mysql-server, rabbitmq-server and redis-server to be installed.

Create python virtual env and activate it in your favorite way.

Clone project

git clone [email protected]:OnGridSystems/CATEd.git

Go to project dir

cd CATEd

Create mysql databases

echo "create database trade character set utf8; create database celery_result; create database portal_ticker;" | mysql -u root

And migrate

python manage.py migrate

Load initial data with some exchanges and wallets

python manage.py loaddata dump.json

Create you own superuser with

python manage.py createsuperuser

Before starting the bot should read the list of currencies from the site coinmarketcup.com. To do this run following code with activated virtual environment.

read -d "" PYTASKS <<"EOF"
from tradeBOT import tasks
coinmarketcup = tasks.pull_coinmarketcup()
EOF
echo "$PYTASKS" | python manage.py shell

And runserver

python manage.py runserver

Now you can add your api keys.

Add NEW api keys for use bot.

To do this open http://127.0.0.1:8000/ in your browser, login and click red "plus" button in the lower right corner.

Bot uses several celery queues for trade, and main is triggered by a signal from a first worker named celery@worker_high. Another worker - worker_set_orders checks for already existing orders and try keeps them up to date. There are also queues low and normal, for calculating users' orders and pulling their balances.

You can run celery in several terminal windows or screen sessions:

celery worker -A djangoTrade -n worker_high -l info -c 1 -Q high
celery worker -A djangoTrade -n worker_set_orders -l info -c 1 -Q set_orders
celery worker -A djangoTrade -n worker_low -l info -c 2 -Q low
celery worker -A djangoTrade -n worker_normal -l info -c 2 -Q normal

Example of running celery with supervisor daemon:

wget https://raw.githubusercontent.com/celery/celery/4.0/extra/generic-init.d/celeryd -O /etc/init.d/celeryd
wget https://raw.githubusercontent.com/celery/celery/4.0/extra/generic-init.d/celerybeat -O /etc/init.d/celerybeat
chmod +x /etc/init.d/celeryd /etc/init.d/celerybeat

#add celery config
read -d "" CELERYD_CFG <<"EOF"
CELERYD_NODES="worker_set_orders worker_low worker_normal worker_high"
CELERY_BIN="/opt/env/bin/python -m celery"
CELERY_APP="djangoTrade"
CELERYD_CHDIR="/opt/ongrid_portal"
CELERYD_OPTS="-Q:worker_set_orders set_orders -Q:worker_low low -Q:worker_normal normal -Q:worker_high high -c:worker_set_orders 1 -c:worker_low 3 -c:worker_normal 3 -c:worker_high 1"
CELERYD_LOG_FILE="/var/log/celery/%n%I.log"
CELERYD_PID_FILE="/var/run/celery/%n.pid"
CELERYD_USER="root"
CELERYD_GROUP="root"
DJANGO_SETTINGS_MODULE="djangoTrade.settings"
CELERY_CREATE_DIRS=1
SECRET_KEY="ada#qadaa2d#1232%!^&#*(&@(!&Y!&#*T!@(^F#!@&#F!@&#F!(@"
EOF
echo "$CELERYD_CFG" > /etc/default/celeryd

read -d "" CELERYBEAT_CFG <<"EOF"
CELERY_BIN="/opt/env/bin/python -m celery"
CELERY_APP="djangoTrade"
CELERYD_CHDIR="/opt/ongrid_portal"
DJANGO_SETTINGS_MODULE="djangoTrade.settings"
CELERYBEAT_USER="root"
CELERYBEAT_GROUP="root"
EOF
echo "$CELERYBEAT_CFG" > /etc/default/celerybeat

/etc/init.d/celeryd create-paths
/etc/init.d/celeryd start
/etc/init.d/celeryd stop
/etc/init.d/celerybeat create-paths
/etc/init.d/celerybeat start
/etc/init.d/celerybeat stop
sudo update-rc.d celeryd defaults
sudo update-rc.d celerybeat defaults

Authors

cated's People

Contributors

achievement008 avatar klyaus avatar ongrid avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.