21
$\begingroup$

I am starting to do Algorithmic trading in cryptocurrencies using Python libraries. Most exchanges have RESTful API that make it easy to write you own code and get started.

However, I would like to benefit from the analytical features of established libraries such as zipline and others. However these do not support the trading of cryptocurrencies (yet).

Should I just try to write a backend for my favorite cryptocurrency exchange, or are there other options out there?

$\endgroup$
11
$\begingroup$

I have started to do the same thing a few months ago.

You can test your strategies pretty much in any platform: I have tried:

backtrader - www.backtrader.com - python based, open source, with great documentation and community support, helpful author and some great features. If you have basic python then thiswould be my recommendation.

ninjatrader - free to download and good for the beginner with easy to use visuals - you can get this with backtrader too but you will need a bit more unix/python knowledge.

Wealthlab - similar to ninjatrader but comes with a strategy library so that you can get started straight away.

Gekko - Java nodejs based. really good platform to get up and running quickly and so far the only one where you can setup live bots, although backtrader user bartosh seems to have devleoped a branch using ccxt but I have not tested it. I left this option because I wanted to go down the python route.

I think the trickiest bit for most crypto bot enthusiasts is getting the data, so here is my ccxt script that will pull in the data from poloniex (you can change this - please refer to: https://github.com/ccxt/ccxt)

this particular one uses input format for ninjatrader.

Getting Data:

Best place to get it is ccxt - each exchange has different attributes but I have found that poloniex gives me the longest historical duration for most coins for 5m, 15m and 1d timeframes.

Here is a script you can use to pull info for poloniex:

import ccxt
import datetime
import time
import math
import pandas as pd


# DATA FEED FROM EXCHANGE
symbol = str('ETH/USDT')
timeframe = str('1d')
exchange = str('poloniex')
exchange_out = str(exchange)
start_date = str('2014-01-01 00:00:00')
get_data = True


def to_unix_time(timestamp):
    epoch = datetime.datetime.utcfromtimestamp(0)  # start of epoch time
    my_time = datetime.datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S")  # plugin your time object
    delta = my_time - epoch
    return delta.total_seconds() * 1000

# CSV File Name
symbol_out = symbol.replace("/", "")
filename = '{}-{}-{}.csv'.format(exchange_out, symbol_out, timeframe)
out_filename = '{}-{}-{}-out.csv'.format(exchange_out, symbol_out, timeframe)


# Get our Exchange
exchange = getattr(ccxt, exchange)()
exchange.load_markets()
hist_start_date = int(to_unix_time(start_date))

data = exchange.fetch_ohlcv(symbol, timeframe, since=hist_start_date)
header = ['Timestamp', 'Open', 'High', 'Low', 'Close', 'Volume']
df = pd.DataFrame(data, columns=header)
df['Timestamp'] = pd.to_datetime(df['Timestamp'], unit='ms')
df['Timestamp'] = df['Timestamp'].dt.strftime('%Y%m%d %H%M')

#Precision

df[['Volume']] = df[['Volume']].astype(int)


# Save it
df.to_csv(filename, index= False,header=False, sep=';')

Backtest rookies is a great site to get you started - the author also seems to be a really nice guy: https://backtest-rookies.com.

Here is a great list of a lot of other quant stuff:

https://github.com/EliteQuant/EliteQuant/blob/master/README.md#cryptocurrency

Good luck!

EDIT: 7/3/18: One more to add - Zorro - https://zorro-project.com/. programmable using c-lite, fast, good tutorials https://www.financial-hacker.com/ - free version available for low trading volumes and able to download historical data from a number of sources.

EDIT: 12/4/19: This is a great link A list of online resources for quantitative modeling, trading, portfolio management.

https://github.com/EliteQuant/EliteQuant

$\endgroup$
8
$\begingroup$

QuantConnect has had users work on contributing REST bitcoin brokerages - its fully open source and has complete modeling support for currencies. It also has python support in beta.

https://www.quantconnect.com/forum/discussion/958/bitfinex-brokerage

(I'm the founder of QuantConnect)

Edit: Fully support python and crypto currencies now. We've pushed GDAX brokerage into production!

Edit (12/2017): A community user has contributed a Bitfinex implementation. It is in the PR phase now.

$\endgroup$
7
$\begingroup$

Check out my ccxt library on GitHub: https://github.com/ccxt/ccxt

With it you can access market data and trade bitcoin and altcoins with many cryptocurrency exchanges. The library is in Python 2 & 3 (JavaScript and PHP versions are also available as well). You can deploy it from PyPI, with npm or by cloning from GitHub repository.

The ccxt library is under heavy development right now, but already offers a quick-start for trading and technical analysis with many crypto exchange markets out of the box.

$\endgroup$
3
$\begingroup$

Just starting to check it out, but https://www.enigma.co/ seems to have a Crypto framework based on zipline in the making.

$\endgroup$
  • $\begingroup$ Have you tried this out yet, if so what are your thoughts? $\endgroup$ – Goose Dec 31 '18 at 20:54
  • 1
    $\begingroup$ I tried their trading library (catalystcrypto.io) almost a year ago in an early alpha state. Looked promising back then. Haven´t check in since (rolled my own based own on ccxt and backtrader). $\endgroup$ – perelin Jan 3 at 19:09
  • 1
    $\begingroup$ The framework is powerful and well done and installation/setup notes are great. The only negative I have is the repo has been rather dormant as of late, they seem to be off working on another initiative. See for details: github.com/enigmampc/catalyst/issues/547 $\endgroup$ – rahvin_t May 5 at 22:59
1
$\begingroup$

https://github.com/askmike/gekko looks pretty good

you can probably find a lot of similar repos on github. depending on the type of algo/strategy you want to use, these might suffice or come short. language is another concern. based on my research, node.js is probably the most common one for crypto trading, python runner-up.

ultimately I'd suggest build up your own infra for trading and utilize some of the api or wrapper libraries for connections, because a full-fledged in-house trading system is more robust, transparent, and easier for debugging. ultimately you'd benefit from it in the long run.

$\endgroup$
  • $\begingroup$ Isn't that node.js? $\endgroup$ – mementum Dec 11 '17 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.