def main(): fh = FeedHandler() # Add swaps. Futures and swaps could be added together in one feed, but its clearer to # add them as separate feeds. # EOS-USD-SWAP is from the swap exchange, BTC-USDT is from spot exchage, BTC-USD-210129-10000-C is from options fh.add_feed( OKEx(symbols=['EOS-USD-SWAP', 'BTC-USDT', "BTC-USD-210129-10000-C"], channels=[L2_BOOK, TICKER, TRADES], callbacks={ L2_BOOK: book, TRADES: trade, TICKER: ticker })) # Open Interest, Liquidations, and Funding Rates # funding is low volume, so set timeout to -1 fh.add_feed(OKEx(symbols=['EOS-USD-SWAP'], channels=[FUNDING, LIQUIDATIONS], callbacks={ FUNDING: funding, LIQUIDATIONS: liquidation }), timeout=-1) fh.run()
def main(): fh = FeedHandler() callbacks = {TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book), TICKER: TickerCallback(ticker), TICKER_FUTURES: TickerCallback(ticker), TRADES_FUTURES: TradeCallback(trade), L2_BOOK_FUTURES: BookCallback(book)} pairs = OKEx.get_active_symbols() fh.add_feed(OKEx(pairs=pairs, channels=[TRADES_FUTURES, L2_BOOK_FUTURES, TICKER_FUTURES], callbacks=callbacks)) fh.run()
def main(): f = FeedHandler() # Note: EXX is extremely unreliable - sometimes a connection can take many many retries # f.add_feed(EXX(pairs=['BTC-USDT'], channels=[L2_BOOK, TRADES], callbacks={L2_BOOK: BookCallback(book), TRADES: TradeCallback(trade)})) 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(pairs=['BTC-USD'], channels=[L2_BOOK], callbacks={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], callbacks={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.get_active_symbols() f.add_feed(Bitmex(channels=[INSTRUMENT], pairs=['XBTUSD'], callbacks={INSTRUMENT: InstrumentCallback(instrument)})) 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(config={TRADES: ['BTC-USD'], TICKER: ['ETH-USD']}, callbacks={TRADES: TradeCallback(trade), TICKER: TickerCallback(ticker)})) config={TRADES: ['BTC-USD', 'ETH-USD', 'BTC-USDT', 'ETH-USDT'], L2_BOOK: ['BTC-USD', 'BTC-USDT']} f.add_feed(HuobiUS(config=config, callbacks={TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book)})) config={TRADES: ['BTC-USDT', 'ETH-USDT'], L2_BOOK: ['BTC-USDT']} f.add_feed(Huobi(config=config, callbacks={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(Coinbene(channels=[L2_BOOK, TRADES, TICKER], pairs=['BTC-USDT'], callbacks={L2_BOOK: BookCallback(book), TICKER: TickerCallback(ticker), TRADES: TradeCallback(trade)})) f.run()
def main(): fh = FeedHandler() # Add futures contracts callbacks = {TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book), TRADES: trade, TICKER: TickerCallback(ticker)} pairs = OKEx.get_active_symbols()[:5] fh.add_feed(OKEx(pairs=pairs, channels=[TRADES, L2_BOOK, TICKER], callbacks=callbacks)) # Add swaps. Futures and swaps could be added together in one feed, but its clearer to # add them as separate feeds. # EOS-USD-SWAP is from the swap exchange, BTC-USDT is from spot exchage. fh.add_feed(OKEx(pairs=['EOS-USD-SWAP', 'BTC-USDT'], channels=[L2_BOOK, TICKER, TRADES], callbacks={L2_BOOK: book, TRADES: trade, TICKER: ticker})) # Open Interest and Funding Rates fh.add_feed(OKEx(pairs=['EOS-USD-SWAP'], channels=[FUNDING], callbacks={FUNDING: funding})) fh.add_feed(OKEx(pairs=pairs, channels=[OPEN_INTEREST], callbacks={OPEN_INTEREST: open_int})) fh.run()
def main(): fh = FeedHandler() # Add futures contracts callbacks = { TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book), TICKER: TickerCallback(ticker) } symbols = OKEx.get_active_symbols()[:5] fh.add_feed( OKEx(checksum_validation=True, symbols=symbols, channels=[TRADES, TICKER, L2_BOOK], callbacks=callbacks)) # Add swaps. Futures and swaps could be added together in one feed, but its clearer to # add them as separate feeds. # EOS-USD-SWAP is from the swap exchange, BTC-USDT is from spot exchage, BTC-USD-210129-10000-C is from options fh.add_feed( OKEx(symbols=['EOS-USD-SWAP', 'BTC-USDT', "BTC-USD-210129-10000-C"], channels=[L2_BOOK, TICKER, TRADES], callbacks={ L2_BOOK: book, TRADES: trade, TICKER: ticker })) # Open Interest, Liquidations, and Funding Rates # funding is low volume, so set timeout to -1 fh.add_feed(OKEx(symbols=['EOS-USD-SWAP'], channels=[FUNDING, LIQUIDATIONS], callbacks={ FUNDING: funding, LIQUIDATIONS: liquidation }), timeout=-1) fh.add_feed( OKEx(symbols=symbols, channels=[OPEN_INTEREST], callbacks={OPEN_INTEREST: open_int})) fh.run()
def main(): fh = FeedHandler() fh.add_feed( OKEx(pairs=['EOS-USD-SWAP'], channels=[TRADES_SWAP, L2_BOOK_SWAP], callbacks={ TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book) })) fh.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.add_feed(dYdX(symbols=dYdX.symbols(), channels=[L2_BOOK], callbacks={TRADES: trade, L2_BOOK: book, BOOK_DELTA: delta})) f.run()
def main(): fh = FeedHandler() fh.add_feed( OKEx(pairs=['EOS-USD-SWAP'], channels=[TRADES_SWAP, L2_BOOK_SWAP, OPEN_INTEREST], callbacks={ OPEN_INTEREST: open_interest, TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book) })) fh.run()
def main(): f = FeedHandler() # Note: EXX is extremely unreliable - sometimes a connection can take many many retries # 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()
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.add_feed(OKEx(symbols=['BTC-USD-SWAP', 'ETH-USD-SWAP'], channels=[LIQUIDATIONS, OPEN_INTEREST], callbacks={OPEN_INTEREST: OpenInterestCallback(oi), LIQUIDATIONS: LiquidationCallback(liquidations)})) f.add_feed(Bitmex(symbols=['BTC-USD', 'ETH-USD'], channels=[LIQUIDATIONS, OPEN_INTEREST], callbacks={OPEN_INTEREST: OpenInterestCallback(oi), LIQUIDATIONS: LiquidationCallback(liquidations)})) f.run()
def main(): fh = FeedHandler() # Add futures contracts pairs0 = ["BTC-USDT", "EOS-USDT"] pairs1 = ["BTC_CQ", "EOS_CQ"] pairs2 = ["BTC-USD", "EOS-USD"] pairs3 = OKEx.get_active_symbols()[:5] pair4 = ['XRP-USD-210326', 'LTC-USD-201225'] pair5 = list(binance_pairs().keys())[:5] pair6 = list(binance_futures_pairs().values())[:5] pair7 = list(okcoin_pairs().keys())[:5] #print(pair6) # fh.add_feed(HuobiR(pairs=pairs0, channels=[KLINE], callbacks={KLINE: kline})) # fh.add_feed(HuobiDMR(pairs=pairs1, channels=[KLINE], callbacks={KLINE: kline})) # fh.add_feed(HuobiSwapR(pairs=pairs2, channels=[KLINE], callbacks={KLINE: kline})) # fh.add_feed(BinanceFutures(pairs=["BTCUSDT"], channels=[KLINE], callbacks={KLINE: kline})) print(pair6) fh.add_feed( BinanceFutures(pairs=pair6, channels=[KLINE], callbacks={KLINE: kline})) # fh.add_feed(OKCoin(pairs=pair7, channels=[KLINE], callbacks={KLINE: kline})) # fh.add_feed(OKEx(pairs=pairs3, channels=[KLINE], callbacks={KLINE: kline})) fh.run()
def main(): f = FeedHandler() # Note: EXX is extremely unreliable - sometimes a connection can take many many retries # f.add_feed(EXX(pairs=['BTC-USDT'], channels=[L2_BOOK, TRADES], callbacks={L2_BOOK: BookCallback(book), TRADES: TradeCallback(trade)})) 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], callbacks={ 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.get_active_symbols() 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(config={ TRADES: ['BTC-USD'], TICKER: ['ETH-USD'] }, callbacks={ 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']} f.add_feed( HuobiDM(config=config, callbacks={ 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=[ 'BSVDOOM-USD', '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.run()
def main(): config = { 'log': { 'filename': 'demo.log', 'level': 'DEBUG', 'disabled': False } } # 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) f.add_feed( FMFW(symbols=['BTC-USDT'], channels=[CANDLES, L2_BOOK, TRADES, TICKER], callbacks={ CANDLES: candle_callback, TICKER: ticker, L2_BOOK: book, TRADES: trade })) f.add_feed( AscendEX(symbols=['XRP-USDT'], channels=[L2_BOOK, TRADES], callbacks={ L2_BOOK: book, TRADES: trade })) f.add_feed( Bequant(symbols=['BTC-USDT'], channels=[L2_BOOK], callbacks={ L2_BOOK: book, TRADES: trade, TICKER: ticker, CANDLES: candle_callback })) pairs = Binance.symbols()[:1] f.add_feed( Binance(symbols=pairs, channels=[L2_BOOK], callbacks={ L2_BOOK: book, CANDLES: candle_callback, TRADES: trade, TICKER: ticker })) pairs = BinanceFutures.symbols()[:30] f.add_feed( BinanceFutures(symbols=pairs, channels=[OPEN_INTEREST, FUNDING, LIQUIDATIONS], callbacks={ OPEN_INTEREST: oi, FUNDING: funding, LIQUIDATIONS: liquidations })) f.add_feed( BinanceUS(symbols=BinanceUS.symbols()[:2], channels=[TRADES, L2_BOOK], callbacks={ L2_BOOK: book, TRADES: trade })) f.add_feed( Bitfinex(symbols=['BTC-USDT'], channels=[L3_BOOK], callbacks={ L3_BOOK: book, TICKER: ticker, TRADES: trade })) f.add_feed( Bitflyer(symbols=['BTC-JPY'], channels=[TICKER, TRADES, L2_BOOK], callbacks={ L2_BOOK: book, TICKER: ticker, TRADES: trade })) f.add_feed( Bithumb(symbols=['BTC-KRW'], channels=[TRADES], callbacks={TRADES: trade})) f.add_feed( Bitmex(timeout=5000, symbols=Bitmex.symbols(), channels=[LIQUIDATIONS], callbacks={ LIQUIDATIONS: liquidations, OPEN_INTEREST: oi, FUNDING: funding })) f.add_feed( Bitstamp(channels=[L2_BOOK, TRADES], symbols=['BTC-USD'], callbacks={ L2_BOOK: book, TRADES: trade })) f.add_feed( Bittrex(subscription={ L2_BOOK: ['BTC-USDT'], CANDLES: ['BTC-USDT', 'ETH-USDT'], TRADES: ['ETH-USDT', 'BTC-USDT'], TICKER: ['ETH-USDT'] }, callbacks={ CANDLES: candle_callback, L2_BOOK: book, TICKER: ticker, TRADES: trade })) f.add_feed(BLOCKCHAIN, subscription={ L2_BOOK: ['BTC-USD'], TRADES: Blockchain.symbols() }, callbacks={ L2_BOOK: book, TRADES: trade }) f.add_feed( Bybit(symbols=['BTC-USDT-PERP', 'BTC-USD-PERP'], channels=[INDEX, FUNDING, OPEN_INTEREST], callbacks={ OPEN_INTEREST: oi, INDEX: index, FUNDING: funding })) f.add_feed( Bybit(symbols=['BTC-USDT-PERP', 'BTC-USD-PERP'], channels=[CANDLES, TRADES, L2_BOOK], callbacks={ CANDLES: candle_callback, TRADES: trade, L2_BOOK: book })) f.add_feed( Coinbase(subscription={ L2_BOOK: ['BTC-USD'], TRADES: ['BTC-USD'], TICKER: ['BTC-USD'] }, callbacks={ TRADES: trade, L2_BOOK: book, TICKER: ticker })) f.add_feed( Coinbase(subscription={L3_BOOK: ['LTC-USD']}, callbacks={L3_BOOK: book})) f.add_feed( Deribit(symbols=['BTC-USD-PERP'], channels=[ L2_BOOK, TRADES, TICKER, FUNDING, OPEN_INTEREST, LIQUIDATIONS ], callbacks={ TRADES: trade, L2_BOOK: book, TICKER: ticker, OPEN_INTEREST: oi, FUNDING: funding, LIQUIDATIONS: liquidations })) f.add_feed( dYdX(symbols=dYdX.symbols(), channels=[L2_BOOK, TRADES], callbacks={ TRADES: trade, L2_BOOK: book })) f.add_feed( FTX(checksum_validation=True, symbols=['ALGO-USD-PERP'], channels=[ TICKER, TRADES, L2_BOOK, LIQUIDATIONS, OPEN_INTEREST, FUNDING ], callbacks={ TICKER: ticker, TRADES: trade, OPEN_INTEREST: oi, FUNDING: funding, LIQUIDATIONS: liquidations, L2_BOOK: book })) f.add_feed( Gateio(symbols=['BTC-USDT', 'ETH-USDT'], channels=[L2_BOOK, CANDLES, TRADES, TICKER], callbacks={ CANDLES: candle_callback, L2_BOOK: book, TRADES: trade, TICKER: ticker })) f.add_feed(GEMINI, subscription={ L2_BOOK: ['BTC-USD', 'ETH-USD'], TRADES: ['ETH-USD', 'BTC-USD'] }, callbacks={ TRADES: trade, L2_BOOK: book }) f.add_feed( HitBTC(channels=[TRADES], symbols=['BTC-USDT'], callbacks={TRADES: trade})) f.add_feed( Huobi(symbols=['BTC-USDT'], channels=[CANDLES, TRADES, L2_BOOK], callbacks={ TRADES: trade, L2_BOOK: book, CANDLES: candle_callback })) f.add_feed( HuobiDM(subscription={ L2_BOOK: HuobiDM.symbols()[:2], TRADES: HuobiDM.symbols()[:10] }, callbacks={ TRADES: trade, L2_BOOK: book })) pairs = [ 'BTC-USD-PERP', 'ETH-USD-PERP', 'EOS-USD-PERP', 'BCH-USD-PERP', 'BSV-USD-PERP', 'LTC-USD-PERP' ] f.add_feed( HuobiSwap(symbols=pairs, channels=[TRADES, L2_BOOK, FUNDING], callbacks={ FUNDING: funding, TRADES: trade, L2_BOOK: book })) f.add_feed( KrakenFutures( symbols=KrakenFutures.symbols(), channels=[L2_BOOK, TICKER, TRADES, OPEN_INTEREST, FUNDING], callbacks={ L2_BOOK: book, FUNDING: funding, OPEN_INTEREST: oi, TRADES: trade, TICKER: ticker })) 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: trade, TICKER: ticker })) f.add_feed( KuCoin(symbols=['BTC-USDT', 'ETH-USDT'], channels=[TICKER, TRADES, CANDLES], callbacks={ CANDLES: candle_callback, TICKER: ticker, TRADES: trade })) f.add_feed( OKEx(checksum_validation=True, symbols=['BTC-USDT-PERP'], channels=[ TRADES, TICKER, FUNDING, OPEN_INTEREST, LIQUIDATIONS, L2_BOOK ], callbacks={ L2_BOOK: book, TICKER: ticker, LIQUIDATIONS: liquidations, FUNDING: funding, OPEN_INTEREST: oi, TRADES: trade })) f.add_feed( OKCoin(checksum_validation=True, symbols=['BTC-USD'], channels=[TRADES, TICKER, L2_BOOK], callbacks={ L2_BOOK: book, TICKER: ticker, TRADES: trade })) f.add_feed( Phemex(symbols=[Symbol('BTC', 'USD', type=PERPETUAL)], channels=[L2_BOOK, CANDLES, TRADES], callbacks={ TRADES: trade, L2_BOOK: book, CANDLES: candle_callback })) f.add_feed( Poloniex(symbols=['BTC-USDT'], channels=[TICKER, TRADES], callbacks={ TICKER: ticker, TRADES: trade })) f.add_feed( Poloniex(subscription={ TRADES: ['DOGE-BTC'], L2_BOOK: ['LTC-BTC'] }, callbacks={ TRADES: trade, L2_BOOK: book })) f.add_feed( Probit(subscription={ TRADES: ['BTC-USDT'], L2_BOOK: ['BTC-USDT'] }, callbacks={ TRADES: trade, L2_BOOK: book })) f.add_feed( Upbit(subscription={ TRADES: ['BTC-USDT'], L2_BOOK: ['BTC-USDT'] }, callbacks={ TRADES: trade, L2_BOOK: book })) f.run()
'ETH-USD', 'LTC-USD', 'EOS-USD' ] bitfinex_syms = [ 'ETH-BTC', 'EOS-BTC', 'LTC-BTC', 'XLM-BTC', 'XMR-BTC', 'XRP-BTC', 'ZEC-BTC', 'EOS-ETH', 'BTC-USD', 'ETH-USD', 'LTC-USD', 'EOS-USD' ] bitstamp_syms = ['ETH-BTC', 'LTC-BTC', 'XRP-BTC'] binance_syms = [ 'ADA-BTC', 'DASH-BTC', 'ETH-BTC', 'EOS-BTC', 'LTC-BTC', 'XLM-BTC', 'XMR-BTC', 'XRP-BTC', 'ZEC-BTC', 'ADA-ETH', 'EOS-ETH', 'LTC-ETH' ] okcoin_syms = [ 'BTC-USD', 'LTC-USD', 'ETH-USD', 'ETC-USD', 'TUSD-USD', 'USDT-USD', 'ZEC-USD', 'ADA-USD', 'XLM-USD', 'ZRX-USD', 'XRP-USD' ] okex_syms = ['BTC-USD-SWAP', 'BTC-USD-190607'] fh = FeedHandler() #fh.add_feed(Kraken(channels=[TRADES], pairs=kraken_syms, callbacks={TRADES: TradeCallback(trade)})) #fh.add_feed(Bitfinex(channels=[TRADES], pairs=bitfinex_syms, callbacks={TRADES: TradeCallback(trade)})) #fh.add_feed(Bitstamp(channels=[TRADES], pairs=bitstamp_syms, callbacks={TRADES: TradeCallback(trade)})) #fh.add_feed(Binance(channels=[TRADES], pairs=binance_syms, callbacks={TRADES: TradeCallback(trade)})) fh.add_feed( OKEx(channels=[TRADES], pairs=okex_syms, callbacks={TRADES: TradeCallback(trade)})) fh.run()