Python
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cryptofeed
tests
tools
.gitignore
.travis.yml
CHANGES.md
LICENSE
README.md
demo.py
demo_nbbo.py
setup.py

README.md

Cryptocurrency Feed Handler

License Python Build Status Codacy Badge PyPi Slack

Handles multiple feeds and returns normalized and standardized results across exchanges to client registered callbacks for events like trades, book updates, ticker updates, etc.

from cryptofeed import FeedHandler

fh = FeedHandler()

# ticker, trade, and book are user defined functions that
# will be called when ticker, trade and book updates are received
ticker_cb = {'ticker': TickerCallback(ticker)}
trade_cb = {'trades': TradeCallback(trade)}
gemini_cb = {'trades': TradeCallback(trade), 'book': BookCallback(book)}


fh.add_feed(GDAX(pairs=['BTC-USD'], channels=['ticker'], callbacks=ticker_cb)
fh.add_feed(Bitfinex(pairs=['BTC-USD'], channels=['ticker'], callbacks=ticker_cb)
fh.add_feed(Poloniex(channels=['USDT_BTC'], callbacks=trade_cb))
fh.add_feed(Gemini(pairs=['BTC-USD'], callbacks=gemini_cb)

fh.run()

Supports the following exchanges:

  • Bitfinex
  • GDAX
  • Poloniex
  • Gemini
  • HitBTC
  • Bitstamp

Also provides a synthetic NBBO (National Best Bid/Offer) feed that aggregates the best bids and asks from the user specified feeds.

from cryptofeed.feedhandler import FeedHandler
from cryptofeed import GDAX, Bitfinex, HitBTC


def nbbo_ticker(pair, bid, ask, bid_feed, ask_feed):
    print('Pair: {} Bid: {} Bid Feed: {} Ask: {} Ask Feed: {}'.format(pair,
                                                                      bid,
                                                                      bid_feed,
                                                                      ask,
                                                                      ask_feed))


fh = FeedHandler()
fh.add_nbbo([GDAX, Bitfinex, HitBTC], ['BTC-USD'], nbbo_ticker)
fh.run()

Planned Work

Future Feeds

  • EXX
  • CEX
  • Bitmex
  • BTCC
  • Many more...

REST API Support

Some feeds do not support websocket. A framework for supporting non websocket feeds is planned.

DB Plugins

Support for registering databases and writing directly to them via the handler (as opposed to client provided callbacks).