name: cryptofeed
Comprehensive assistance with Cryptofeed development - a Python library for handling cryptocurrency exchange data feeds with normalized and standardized results.
This skill should be triggered when:
# Basic installation
pip install cryptofeed
# With all optional backends
pip install cryptofeed[all]
from cryptofeed import FeedHandler
from cryptofeed.exchanges import Coinbase, Bitfinex
from cryptofeed.defines import TICKER, TRADES, L2_BOOK
# Define callbacks
def ticker_callback(data):
print(f"Ticker: {data}")
def trade_callback(data):
print(f"Trade: {data}")
# Create feed handler
fh = FeedHandler()
# Add exchange feeds
fh.add_feed(Coinbase(
symbols=['BTC-USD'],
channels=[TICKER],
callbacks={TICKER: ticker_callback}
))
fh.add_feed(Bitfinex(
symbols=['BTC-USD'],
channels=[TRADES],
callbacks={TRADES: trade_callback}
))
# Start receiving data
fh.run()
from cryptofeed import FeedHandler
from cryptofeed.exchanges import Coinbase, Gemini, Kraken
def nbbo_update(symbol, bid, bid_size, ask, ask_size, bid_feed, ask_feed):
print(f'Pair: {symbol} Bid: {bid:.2f} ({bid_size:.6f}) from {bid_feed}')
print(f'Ask: {ask:.2f} ({ask_size:.6f}) from {ask_feed}')
f = FeedHandler()
f.add_nbbo([Coinbase, Kraken, Gemini], ['BTC-USD'], nbbo_update)
f.run()
AscendEX, Bequant, bitFlyer, Bithumb, Bitstamp, Blockchain.com, Bit.com, Bitget, Crypto.com, Delta, EXX, FMFW.io, HitBTC, Independent Reserve, OKCoin, Phemex, Poloniex, ProBit, Upbit
Write data directly to storage:
Cryptofeed normalizes data across all exchanges, providing consistent:
Create synthetic National Best Bid/Offer feeds by aggregating data across multiple exchanges to find arbitrage opportunities.
Direct data writing to various storage systems without custom integration code.
fh = FeedHandler()
fh.add_feed(Binance(symbols=['BTC-USDT'], channels=[TICKER], callbacks=ticker_cb))
fh.add_feed(Coinbase(symbols=['BTC-USD'], channels=[TICKER], callbacks=ticker_cb))
fh.add_feed(Kraken(symbols=['BTC-USD'], channels=[TICKER], callbacks=ticker_cb))
fh.run()
def book_callback(book, receipt_timestamp):
print(f"Bids: {len(book.book.bids)} | Asks: {len(book.book.asks)}")
fh.add_feed(Coinbase(
symbols=['BTC-USD'],
channels=[L2_BOOK],
callbacks={L2_BOOK: book_callback}
))
def trade_callback(trade, receipt_timestamp):
print(f"{trade.exchange} - {trade.symbol}: {trade.side} {trade.amount} @ {trade.price}")
fh.add_feed(Binance(
symbols=['BTC-USDT', 'ETH-USDT'],
channels=[TRADES],
callbacks={TRADES: trade_callback}
))
This skill includes documentation in references/:
Use view to read specific reference files when detailed information is needed.
Start with basic FeedHandler setup and single exchange connections before adding multiple feeds.
Explore NBBO feeds, authenticated channels, and backend integrations for production systems.
See the quick reference section above and the reference files for complete working examples.