Skip to content

Cryptocurrency Feed Handler with synthetic NBBO

License

Notifications You must be signed in to change notification settings

halida/cryptofeed

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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), L3_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
  • BitMEX

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
  • 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).

Additional Callback Methods

  • Unix Domain Sockets
  • Redis
  • ZMQ

About

Cryptocurrency Feed Handler with synthetic NBBO

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%