def main(): f = FeedHandler() f.add_feed( FTX(pairs=ftx_pairs(), channels=[OPEN_INTEREST, LIQUIDATIONS], callbacks={ OPEN_INTEREST: OpenInterestCallback(oi), LIQUIDATIONS: LiquidationCallback(liquidations) })) f.add_feed( BinanceFutures(pairs=binance_futures_pairs(), channels=[OPEN_INTEREST, LIQUIDATIONS], callbacks={ OPEN_INTEREST: OpenInterestCallback(oi), LIQUIDATIONS: LiquidationCallback(liquidations) })) f.add_feed( Deribit(pairs=['BTC-PERPETUAL'], channels=[OPEN_INTEREST, LIQUIDATIONS], callbacks={ OPEN_INTEREST: OpenInterestCallback(oi), LIQUIDATIONS: LiquidationCallback(liquidations) })) f.run()
def main(): f = FeedHandler() f.add_feed( FTX(symbols=FTX.info()['symbols'], channels=[OPEN_INTEREST, LIQUIDATIONS], callbacks={ OPEN_INTEREST: OpenInterestCallback(oi), LIQUIDATIONS: LiquidationCallback(liquidations) })) symbols = [ s for s in BinanceFutures.info()['symbols'] if 'PINDEX' not in s ] f.add_feed( BinanceFutures(symbols=symbols, channels=[OPEN_INTEREST, LIQUIDATIONS], callbacks={ OPEN_INTEREST: OpenInterestCallback(oi), LIQUIDATIONS: LiquidationCallback(liquidations) })) f.add_feed( Deribit(symbols=['BTC-USD-PERPETUAL', 'ETH-USD-PERPETUAL'], channels=[LIQUIDATIONS, OPEN_INTEREST], callbacks={ OPEN_INTEREST: OpenInterestCallback(oi), LIQUIDATIONS: LiquidationCallback(liquidations) })) f.run()
def main(): config = {'log': {'filename': 'demo.log', 'level': 'INFO'}} # the config will be automatically passed into any exchanges set up by string. Instantiated exchange objects would need to pass the config in manually. f = FeedHandler(config=config) # Note: EXX is extremely unreliable - sometimes a connection can take many many retries # from cryptofeed.exchanges import EXX # f.add_feed(EXX(symbols=['BTC-USDT'], channels=[L2_BOOK, TRADES], callbacks={L2_BOOK: BookCallback(book), TRADES: TradeCallback(trade)})) f.add_feed( KuCoin(symbols=['BTC-USDT', 'ETH-USDT'], channels=[ L2_BOOK, ], callbacks={ L2_BOOK: book, BOOK_DELTA: delta, CANDLES: candle_callback, TICKER: ticker, TRADES: trade })) f.add_feed( Gateio(symbols=['BTC-USDT', 'ETH-USDT'], channels=[L2_BOOK], callbacks={ CANDLES: candle_callback, L2_BOOK: book, TRADES: trade, TICKER: ticker, BOOK_DELTA: delta })) pairs = Binance.symbols() f.add_feed( Binance(symbols=pairs, channels=[TRADES], callbacks={TRADES: TradeCallback(trade)})) pairs = BinanceUS.symbols() f.add_feed( BinanceUS(symbols=pairs, channels=[CANDLES], callbacks={CANDLES: candle_callback})) f.add_feed(COINBASE, symbols=['BTC-USD'], channels=[TICKER], callbacks={TICKER: TickerCallback(ticker)}) f.add_feed( Coinbase(symbols=['BTC-USD'], channels=[TRADES], callbacks={TRADES: TradeCallback(trade)})) f.add_feed( Coinbase(subscription={ L2_BOOK: ['BTC-USD', 'ETH-USD'], TRADES: ['ETH-USD'] }, callbacks={ TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book) })) f.add_feed( Coinbase(subscription={L3_BOOK: ['LTC-USD']}, callbacks={L3_BOOK: BookCallback(book)})) f.add_feed( Bitfinex(symbols=['BTC-USDT'], channels=[L2_BOOK], callbacks={L2_BOOK: BookCallback(book)})) f.add_feed( Bitfinex(symbols=['BTC'], channels=[FUNDING], callbacks={FUNDING: FundingCallback(funding)})) f.add_feed( Poloniex(symbols=['BTC-USDT'], channels=[TICKER, TRADES], callbacks={ TICKER: TickerCallback(ticker), TRADES: TradeCallback(trade) })) f.add_feed( Poloniex(subscription={ TRADES: ['DOGE-BTC'], L2_BOOK: ['LTC-BTC'] }, callbacks={ TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book) })) f.add_feed(GEMINI, subscription={ L2_BOOK: ['BTC-USD', 'ETH-USD'], TRADES: ['ETH-USD', 'BTC-USD'] }, callbacks={ TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book) }) f.add_feed( HitBTC(channels=[TRADES], symbols=['BTC-USD'], callbacks={TRADES: TradeCallback(trade)})) f.add_feed( HitBTC(channels=[L2_BOOK], symbols=['BTC-USD'], callbacks={L2_BOOK: BookCallback(book)})) f.add_feed( Bitstamp(channels=[L2_BOOK, TRADES], symbols=['BTC-USD'], callbacks={ L2_BOOK: BookCallback(book), TRADES: TradeCallback(trade) })) bitmex_symbols = Bitmex.symbols() f.add_feed( Bitmex(channels=[OPEN_INTEREST], symbols=['BTC-USD'], callbacks={OPEN_INTEREST: oi})) f.add_feed( Bitmex(channels=[TRADES], symbols=bitmex_symbols, callbacks={TRADES: TradeCallback(trade)})) f.add_feed( Bitmex(symbols=['BTC-USD'], channels=[FUNDING, TRADES], callbacks={ FUNDING: FundingCallback(funding), TRADES: TradeCallback(trade) })) f.add_feed( Bitmex(symbols=['BTC-USD'], channels=[L2_BOOK], callbacks={L2_BOOK: BookCallback(book)})) f.add_feed( Kraken(checksum_validation=True, subscription={ L2_BOOK: ['BTC-USD'], TRADES: ['BTC-USD'], CANDLES: ['BTC-USD'], TICKER: ['ETH-USD'] }, callbacks={ L2_BOOK: book, CANDLES: candle_callback, TRADES: TradeCallback(trade), TICKER: TickerCallback(ticker) })) sub = {TRADES: ['BTC-USDT', 'ETH-USDT'], L2_BOOK: ['BTC-USDT']} f.add_feed( Huobi(subscription=sub, callbacks={ TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book) })) f.add_feed( Huobi(symbols=['BTC-USDT'], channels=[CANDLES], callbacks={CANDLES: candle_callback})) sub = {L2_BOOK: ['BTC_CQ', 'BTC_NQ']} f.add_feed( HuobiDM(subscription=sub, callbacks={ TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book) })) pairs = ['BTC-USD', 'ETH-USD', 'EOS-USD', 'BCH-USD', 'BSV-USD', 'LTC-USD'] f.add_feed( HuobiSwap(symbols=pairs, channels=[TRADES, L2_BOOK, FUNDING], callbacks={ FUNDING: funding, TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book) })) f.add_feed( OKCoin(symbols=['BTC-USD'], channels=[L2_BOOK], callbacks={L2_BOOK: BookCallback(book)})) f.add_feed( OKEx(symbols=['BTC-USDT'], channels=[TRADES], callbacks={TRADES: TradeCallback(trade)})) f.add_feed( Bittrex(subscription={ L2_BOOK: ['BTC-USDT', 'ETH-USDT'], CANDLES: ['BTC-USDT', 'ETH-USDT'], TRADES: ['BTC-USDT', 'ETH-USDT'], TICKER: ['BTC-USDT', 'ETH-USDT'] }, callbacks={ CANDLES: candle_callback, L2_BOOK: BookCallback(book), TICKER: TickerCallback(ticker), TRADES: TradeCallback(trade) })) f.add_feed( FTX(symbols=[ 'ADA-PERP', 'ALGO-PERP', 'ALT-PERP', 'ATOM-PERP', 'BCH-PERP', 'BNB-PERP', 'BSV-PERP', 'BTC-PERP', 'BTMX-PERP', 'DOGE-PERP', 'DRGN-PERP', 'EOS-PERP', 'ETC-PERP' ], channels=[TICKER], callbacks={ TICKER: ticker, TRADES: TradeCallback(trade) })) f.add_feed( Bybit(symbols=['BTC-USDT', 'BTC-USD'], channels=[FUTURES_INDEX], callbacks={ OPEN_INTEREST: OpenInterestCallback(oi), FUTURES_INDEX: FuturesIndexCallback(futures_index) })) f.add_feed( Bybit(symbols=['BTC-USDT', 'BTC-USD'], channels=[L2_BOOK, TRADES], callbacks={ TRADES: trade, L2_BOOK: book })) f.add_feed(BLOCKCHAIN, symbols=['BTC-USD', 'ETH-USD'], channels=[L2_BOOK, TRADES], callbacks={ L2_BOOK: BookCallback(book), TRADES: trade }) f.add_feed( Bitmax(symbols=['XRP-USDT', 'BTC-USDT'], channels=[L2_BOOK], callbacks={ TRADES: trade, L2_BOOK: book })) f.add_feed( Bitflyer(symbols=['BTC-JPY'], channels=[L2_BOOK, TRADES, TICKER], callbacks={ L2_BOOK: book, BOOK_DELTA: delta, TICKER: ticker, TRADES: trade })) f.add_feed( BinanceFutures(symbols=['BTC-USDT'], channels=[TICKER], callbacks={TICKER: ticker})) f.add_feed( BinanceFutures(subscription={ TRADES: ['BTC-USDT'], CANDLES: ['BTC-USDT', 'BTC-USDT-PINDEX'] }, callbacks={ CANDLES: candle_callback, TRADES: trade })) f.run()
def main(): f = FeedHandler() # Note: EXX is extremely unreliable - sometimes a connection can take many many retries # from cryptofeed.exchanges import EXX # f.add_feed(EXX(pairs=['BTC-USDT'], channels=[L2_BOOK, TRADES], callbacks={L2_BOOK: BookCallback(book), TRADES: TradeCallback(trade)})) f.add_feed( Gateio(pairs=['BTC-USDT', 'ETH-USDT'], channels=[TRADES, L2_BOOK], callbacks={ TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book) })) f.add_feed( Binance(pairs=['BTC-USDT'], channels=[TRADES, TICKER, L2_BOOK], callbacks={ L2_BOOK: BookCallback(book), TRADES: TradeCallback(trade), TICKER: TickerCallback(ticker) })) f.add_feed(COINBASE, pairs=['BTC-USD'], channels=[TICKER], callbacks={TICKER: TickerCallback(ticker)}) f.add_feed( Coinbase(pairs=['BTC-USD'], channels=[TRADES], callbacks={TRADES: TradeCallback(trade)})) f.add_feed( Coinbase(config={ L2_BOOK: ['BTC-USD', 'ETH-USD'], TRADES: ['ETH-USD', 'BTC-USD'] }, callbacks={ TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book) })) f.add_feed( Bitfinex(pairs=['BTC-USD'], channels=[L2_BOOK], callbacks={L2_BOOK: BookCallback(book)})) f.add_feed( Poloniex(pairs=['BTC-USDT', 'BTC-USDC'], channels=[TICKER, TRADES, VOLUME], callbacks={ VOLUME: volume, TICKER: TickerCallback(ticker), TRADES: TradeCallback(trade) })) f.add_feed( Poloniex(config={ TRADES: ['DOGE-BTC', 'ETH-BTC'], TICKER: ['ETH-BTC'], L2_BOOK: ['LTC-BTC'] }, callbacks={ TRADES: TradeCallback(trade), TICKER: TickerCallback(ticker), L2_BOOK: BookCallback(book) })) f.add_feed(GEMINI, config={ L2_BOOK: ['BTC-USD', 'ETH-USD'], TRADES: ['ETH-USD', 'BTC-USD'] }, callbacks={ TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book) }) f.add_feed( HitBTC(channels=[TRADES], pairs=['BTC-USD'], callbacks={TRADES: TradeCallback(trade)})) f.add_feed( HitBTC(channels=[L2_BOOK], pairs=['BTC-USD'], callbacks={L2_BOOK: BookCallback(book)})) f.add_feed( Bitstamp(channels=[L2_BOOK, TRADES], pairs=['BTC-USD'], callbacks={ L2_BOOK: BookCallback(book), TRADES: TradeCallback(trade) })) bitmex_symbols = Bitmex.info()['pairs'] f.add_feed( Bitmex(channels=[OPEN_INTEREST], pairs=['XBTUSD'], callbacks={OPEN_INTEREST: oi})) f.add_feed( Bitmex(channels=[TRADES], pairs=bitmex_symbols, callbacks={TRADES: TradeCallback(trade)})) f.add_feed( Bitmex(pairs=['XBTUSD'], channels=[FUNDING, TRADES], callbacks={ FUNDING: FundingCallback(funding), TRADES: TradeCallback(trade) })) f.add_feed( Bitfinex(pairs=['BTC'], channels=[FUNDING], callbacks={FUNDING: FundingCallback(funding)})) f.add_feed( Bitmex(pairs=['XBTUSD'], channels=[L2_BOOK], callbacks={L2_BOOK: BookCallback(book)})) f.add_feed( Kraken(checksum_validation=True, config={ L2_BOOK: ['BTC-USD'], TRADES: ['BTC-USD'], TICKER: ['ETH-USD'] }, callbacks={ L2_BOOK: book, TRADES: TradeCallback(trade), TICKER: TickerCallback(ticker) })) config = {TRADES: ['BTC-USDT', 'ETH-USDT'], L2_BOOK: ['BTC-USDT']} f.add_feed( Huobi(config=config, callbacks={ TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book) })) config = {L2_BOOK: ['BTC_CQ', 'BTC_NQ']} f.add_feed( HuobiDM(config=config, callbacks={ TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book) })) pairs = ['BTC-USD', 'ETH-USD', 'EOS-USD', 'BCH-USD', 'BSV-USD', 'LTC-USD'] f.add_feed( HuobiSwap(pairs=pairs, channels=[TRADES, L2_BOOK, FUNDING], callbacks={ FUNDING: funding, TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book) })) f.add_feed( OKCoin(pairs=['BTC-USD'], channels=[L2_BOOK], callbacks={L2_BOOK: BookCallback(book)})) f.add_feed( OKEx(pairs=['BTC-USDT'], channels=[TRADES], callbacks={TRADES: TradeCallback(trade)})) f.add_feed( Bittrex(config={ TRADES: ['BTC-USD'], TICKER: ['ETH-USD'], L2_BOOK: ['BTC-USDT'] }, callbacks={ L2_BOOK: BookCallback(book), TICKER: TickerCallback(ticker), TRADES: TradeCallback(trade) })) f.add_feed( FTX(pairs=[ 'ADA-PERP', 'ALGO-PERP', 'ALT-PERP', 'ATOM-PERP', 'BCH-PERP', 'BNB-PERP', 'BSV-PERP', 'BTC-PERP', 'BTMX-PERP', 'DOGE-PERP', 'DRGN-PERP', 'EOS-PERP', 'ETC-PERP' ], channels=[TICKER], callbacks={ TICKER: ticker, TRADES: TradeCallback(trade) })) f.add_feed( Bybit(pairs=['BTC-USD'], channels=[FUTURES_INDEX], callbacks={ OPEN_INTEREST: OpenInterestCallback(oi), FUTURES_INDEX: FuturesIndexCallback(futures_index) })) f.add_feed(BLOCKCHAIN, pairs=['BTC-USD', 'ETH-USD'], channels=[L2_BOOK, TRADES], callbacks={ L2_BOOK: BookCallback(book), TRADES: trade }) f.run()