Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
upbit_active_pairs = Upbit.get_active_symbols()
f = FeedHandler()
f.add_feed(Upbit(pairs=upbit_active_pairs, channels=[TRADES], callbacks={TRADES: TradeCallback(trade)}))
f.add_feed(Upbit(pairs=upbit_active_pairs, channels=[L2_BOOK], callbacks={L2_BOOK: BookCallback(book)}))
f.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, 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.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)}))
def main():
fh = FeedHandler()
callbacks = {TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book), TICKER: TickerCallback(ticker)}
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():
fh = FeedHandler()
fh.add_feed(OKEx(pairs=['EOS-USD-SWAP'], channels=[TRADES_SWAP, L2_BOOK_SWAP, OPEN_INTEREST, FUNDING], callbacks={FUNDING: funding, OPEN_INTEREST: open_interest, TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book)}))
fh.run()
def main():
fh = FeedHandler()
config = {OPEN_INTEREST: ['PI_XBTUSD', 'PI_ETHUSD'], TRADES: ['PI_XBTUSD'], TICKER: ['PI_XBTUSD', 'PI_ETHUSD'], L2_BOOK: ['PI_XBTUSD'], FUNDING: ['PI_XBTUSD']}
fh.add_feed(KrakenFutures(config=config, callbacks={OPEN_INTEREST: oi, FUNDING: funding, TICKER: TickerCallback(ticker), TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book)}))
fh.run()
def main():
f = FeedHandler()
f.add_feed(Coinbase(config={TRADES: ['BTC-USD'], L3_BOOK: ['ETH-USD']}, callbacks={TRADES: TradeCallback(trade), L3_BOOK: BookCallback(book)}))
f.run()
def __init__(self, name):
self.book = None
self.name = name
self.L2 = {L2_BOOK: BookCallback(self.handle_book),
BOOK_DELTA: BookUpdateCallback(self.handle_l2_delta)}
self.L3 = {L3_BOOK: BookCallback(self.handle_book),
BOOK_DELTA: BookUpdateCallback(self.handle_l3_delta)}
def main():
set_pair_separator('/')
f = FeedHandler()
f.add_feed(COINBASE, pairs=['BTC/USD'], channels=[TICKER], callbacks={TICKER: TickerCallback(ticker)})
f.add_feed(Gemini(pairs=['BTC/USD'], channels=[TRADES], callbacks={TRADES: TradeCallback(trade)}))
f.add_feed(Coinbase(config={L2_BOOK: ['ETH/USD'], L3_BOOK: ['BTC/USD']}, callbacks={L3_BOOK: BookCallback(book), L2_BOOK: BookCallback(book)}))
f.run()
def load(self, **kwargs):
"""Load.
"""
super().load(is_initialize_instmt=False, **kwargs)
self._feed_handler = FeedHandler()
self._instrument_mapping = self._create_instrument_mapping()
try:
exchange = getattr(
cryptofeed_exchanges,
self._get_exchange_name(self._name))
except AttributeError as e:
raise ImportError(
'Cannot load exchange %s from websocket' % self._name)
callbacks = {
L2_BOOK: BookCallback(self._update_order_book_callback),
TRADES: TradeCallback(self._update_trade_callback)
}
if self._name.lower() == 'poloniex':
self._feed_handler.add_feed(
exchange(
channels=list(self._instrument_mapping.keys()),
callbacks=callbacks))
else:
self._feed_handler.add_feed(
exchange(
pairs=list(self._instrument_mapping.keys()),
channels=list(callbacks.keys()),
callbacks=callbacks))