示例#1
0
def main():
    f = FeedHandler()
    f.run(start_loop=False)

    f.add_feed(
        Binance(symbols=['BTC-USDT'],
                channels=[TRADES, TICKER, L2_BOOK],
                callbacks={
                    L2_BOOK: book,
                    TRADES: trade,
                    TICKER: ticker
                }))
    f.add_feed(COINBASE,
               symbols=['BTC-USD'],
               channels=[TICKER],
               callbacks={TICKER: ticker})
    f.add_feed(
        Coinbase(symbols=['BTC-USD'],
                 channels=[TRADES],
                 callbacks={TRADES: trade}))
    f.add_feed(
        Coinbase(subscription={
            L2_BOOK: ['BTC-USD', 'ETH-USD'],
            TRADES: ['ETH-USD', 'BTC-USD']
        },
                 callbacks={
                     TRADES: trade,
                     L2_BOOK: book
                 }))

    loop = asyncio.get_event_loop()
    loop.create_task(aio_task())
    loop.run_forever()
def main():
    addr = 'tcp://localhost'
    port = 8189

    f = FeedHandler()
    f.add_feed(
        Coinbase(channels=[TRADES],
                 symbols=['BTC-USD'],
                 callbacks={
                     TRADES: TradeVictoriaMetrics(addr, port, 'demo-trades')
                 }))
    f.add_feed(
        Coinbase(channels=[TICKER],
                 symbols=['BTC-USD'],
                 callbacks={
                     TICKER: TickerVictoriaMetrics(addr, port, 'demo-tickers')
                 }))
    f.add_feed(
        Coinbase(channels=[L2_BOOK],
                 symbols=['BTC-USD'],
                 callbacks={
                     L2_BOOK: BookVictoriaMetrics(addr, port, 'demo-book'),
                     BOOK_DELTA:
                     BookDeltaVictoriaMetrics(addr, port, 'demo-book')
                 }))
    f.add_feed(
        Binance(channels=[CANDLES],
                symbols=['BTC-USDT'],
                callbacks={
                    CANDLES: CandlesVictoriaMetrics(addr, port, 'demo-candles')
                }))

    f.run()
示例#3
0
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(channels=[TICKER, 'BTC-USDT', 'BTC-USDC'], callbacks={L2_BOOK: BookCallback(book), TICKER: TickerCallback(ticker)}))
    f.add_feed(Poloniex(channels=['BTC-USDT', 'BTC-USDC'], callbacks={TRADES: TradeCallback(trade)}))
    f.add_feed(Gemini(pairs=['BTC-USD'], callbacks={L2_BOOK: BookCallback(book), TRADES: TradeCallback(trade)}))
    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=[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=[L3_BOOK], callbacks={L3_BOOK: BookCallback(book)}))
    f.add_feed(Kraken(pairs=['BTC-USD'], channels=[TRADES, TICKER, L2_BOOK], callbacks={TRADES: TradeCallback(trade), TICKER: TickerCallback(ticker), L2_BOOK: BookCallback(book)}))

    f.run()
示例#4
0
def main():

    f = FeedHandler()
    f.add_feed(Bitmex(channels=[FUNDING, L2_BOOK], symbols=['BTC-USD'], callbacks={FUNDING: FundingInflux('http://localhost:8086', 'example', create_db=True), L2_BOOK: BookInflux('http://localhost:8086', 'example', create_db=True, numeric_type=float), BOOK_DELTA: BookDeltaInflux('http://localhost:8086', 'example', create_db=True, numeric_type=float)}))
    f.add_feed(Coinbase(channels=[TRADES], symbols=['BTC-USD'], callbacks={TRADES: TradeInflux('http://localhost:8086', 'example', create_db=True)}))
    f.add_feed(Coinbase(channels=[L2_BOOK], symbols=['BTC-USD'], callbacks={L2_BOOK: BookInflux('http://localhost:8086', 'example', create_db=True, numeric_type=float), BOOK_DELTA: BookDeltaInflux('http://localhost:8086', 'example', create_db=True, numeric_type=float)}))
    f.add_feed(Coinbase(channels=[TICKER], symbols=['BTC-USD'], callbacks={TICKER: TickerInflux('http://localhost:8086', 'example', create_db=True, numeric_type=float)}))

    """
    # Uncomment Here When Using InfluxDB 2.0
    # For InfluxDB 2.0, provide additional org, bucket(instead of db), token and precision(optional)
    # [Note] In order to use visualization and aggregation, numeric_type with float is strongly recommended.

    ADDR = 'https://localhost:9999'
    ORG='my-org'
    BUCKET = 'my-bucket'
    TOKEN = 'token-something-like-end-with-=='

    f = FeedHandler()
    funding_influx = FundingInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)
    trade_influx = TradeInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)
    book_influx = BookInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)
    bookdelta_influx = BookDeltaInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)
    ticker_influx = TickerInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)

    f.add_feed(Bitmex(channels=[FUNDING, L2_BOOK],symbols=['BTC-USD'], callbacks={FUNDING: funding_influx, L2_BOOK: book_influx, BOOK_DELTA: bookdelta_influx}))
    f.add_feed(Coinbase(channels=[TRADES], symbols=['BTC-USD'], callbacks={TRADES: trade_influx}))
    f.add_feed(Coinbase(channels=[L2_BOOK], symbols=['BTC-USD'], callbacks={L2_BOOK: book_influx, BOOK_DELTA: bookdelta_influx}))
    f.add_feed(Coinbase(channels=[TICKER], symbols=['BTC-USD'], callbacks={TICKER: ticker_influx}))
    """

    f.run()
示例#5
0
def main():
    f = FeedHandler()
    f.add_feed(
        Bitmex(channels=[FUNDING, L3_BOOK],
               pairs=['XBTUSD'],
               callbacks={
                   FUNDING:
                   FundingInflux('http://localhost:8086', 'example'),
                   L3_BOOK:
                   BookInflux('http://localhost:8086', 'example', depth=10)
               }))
    f.add_feed(
        Coinbase(channels=[TRADES],
                 pairs=['BTC-USD'],
                 callbacks={
                     TRADES: TradeInflux('http://localhost:8086', 'example')
                 }))
    f.add_feed(
        Coinbase(channels=[L2_BOOK],
                 pairs=['BTC-USD'],
                 callbacks={
                     L2_BOOK:
                     BookInflux('http://localhost:8086', 'example', depth=10)
                 }))

    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.run(start_loop=False)

    loop = asyncio.get_event_loop()
    loop.create_task(aio_task())
    loop.run_forever()
示例#7
0
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()
示例#8
0
def main():
    f = FeedHandler()
    f.add_feed(
        Bitmex(channels=[TRADES, FUNDING, OPEN_INTEREST],
               pairs=['XBTUSD'],
               callbacks={
                   TRADES: TradeRedis(),
                   FUNDING: FundingRedis(),
                   OPEN_INTEREST: OpenInterestRedis()
               }))
    f.add_feed(
        Bitfinex(channels=[TRADES],
                 pairs=['BTC-USD'],
                 callbacks={TRADES: TradeRedis()}))
    f.add_feed(
        Coinbase(channels=[TRADES],
                 pairs=['BTC-USD'],
                 callbacks={TRADES: TradeRedis()}))
    f.add_feed(
        Coinbase(max_depth=10,
                 channels=[L2_BOOK],
                 pairs=['BTC-USD'],
                 callbacks={L2_BOOK: BookRedis()}))
    f.add_feed(Gemini(pairs=['BTC-USD'], callbacks={TRADES: TradeRedis()}))

    f.run()
示例#9
0
def main():

    f = FeedHandler()
    f.add_feed(
        Bitmex(channels=[FUNDING, L2_BOOK],
               symbols=['BTC-USD-PERP'],
               callbacks={
                   FUNDING: FundingInflux(INFLUX_ADDR, ORG, BUCKET, TOKEN),
                   L2_BOOK: BookInflux(INFLUX_ADDR, ORG, BUCKET, TOKEN)
               }))
    f.add_feed(
        Coinbase(
            channels=[TRADES],
            symbols=['BTC-USD'],
            callbacks={TRADES: TradeInflux(INFLUX_ADDR, ORG, BUCKET, TOKEN)}))
    f.add_feed(
        Coinbase(
            channels=[L2_BOOK],
            symbols=['BTC-USD'],
            callbacks={L2_BOOK: BookInflux(INFLUX_ADDR, ORG, BUCKET, TOKEN)}))
    f.add_feed(
        Coinbase(
            channels=[TICKER],
            symbols=['BTC-USD'],
            callbacks={TICKER: TickerInflux(INFLUX_ADDR, ORG, BUCKET, TOKEN)}))

    f.run()
示例#10
0
def main():
    f = FeedHandler()
    f.add_feed(
        Bitmex(channels=[TRADES, FUNDING, OPEN_INTEREST],
               symbols=['BTC-USD'],
               callbacks={
                   TRADES: TradeRedis(),
                   FUNDING: FundingRedis(),
                   OPEN_INTEREST: OpenInterestRedis()
               }))
    f.add_feed(
        Bitfinex(channels=[TRADES],
                 symbols=['BTC-USD'],
                 callbacks={TRADES: TradeRedis()}))
    f.add_feed(
        Coinbase(channels=[TRADES],
                 symbols=['BTC-USD'],
                 callbacks={TRADES: TradeRedis()}))
    f.add_feed(
        Coinbase(max_depth=10,
                 channels=[L2_BOOK],
                 symbols=['BTC-USD'],
                 callbacks={L2_BOOK: BookRedis()}))
    f.add_feed(Gemini(symbols=['BTC-USD'], callbacks={TRADES: TradeRedis()}))
    f.add_feed(
        Binance(symbols=['BTC-USDT'],
                channels=[CANDLES],
                callbacks={CANDLES: CandlesStream()}))

    f.run()
示例#11
0
def main():
    f = FeedHandler()
    f.add_feed(
        Bitmex(pairs=['XBTUSD'],
               channels=[L2_BOOK],
               callbacks=DeltaBook("Bitmex").L2))
    f.add_feed(
        Bitfinex(pairs=['BTC-USD'],
                 channels=[L3_BOOK],
                 callbacks=DeltaBook("Bitfinex-L3").L3))
    f.add_feed(
        Bitfinex(pairs=['BTC-USD'],
                 channels=[L2_BOOK],
                 callbacks=DeltaBook("Bitfinex-L2").L2))
    f.add_feed(
        Coinbase(pairs=['BTC-USD'],
                 channels=[L3_BOOK],
                 callbacks=DeltaBook("Coinbase-L3").L3))
    f.add_feed(
        Coinbase(pairs=['BTC-USD'],
                 channels=[L2_BOOK],
                 callbacks=DeltaBook("Coinbase-L2").L2))
    f.add_feed(
        Gemini(book_interval=100,
               pairs=['BTC-USD'],
               channels=[L2_BOOK],
               callbacks=DeltaBook("Gemini").L2))
    f.add_feed(
        HitBTC(book_interval=100,
               pairs=['BTC-USD'],
               channels=[L2_BOOK],
               callbacks=DeltaBook("HitBTC").L2))
    f.add_feed(
        Poloniex(book_interval=100,
                 pairs=['BTC-USDT'],
                 channels=[L2_BOOK],
                 callbacks=DeltaBook("Poloniex").L2))
    f.add_feed(
        Kraken(book_interval=100,
               pairs=['BTC-USD'],
               channels=[L2_BOOK],
               callbacks=DeltaBook("Kraken").L2))
    f.add_feed(
        OKCoin(book_interval=100,
               pairs=['BTC-USD'],
               channels=[L2_BOOK],
               callbacks=DeltaBook("OKCoin").L2))
    f.add_feed(
        Bybit(book_interval=100,
              pairs=['BTC-USD'],
              channels=[L2_BOOK],
              callbacks=DeltaBook("Bybit").L2))
    f.add_feed(
        Binance(book_interval=30,
                pairs=['BTC-USDT'],
                channels=[L2_BOOK],
                callbacks=DeltaBook("Binance").L2))

    f.run()
示例#12
0
def main():

    f = FeedHandler()
    f.add_feed(Bitmex(channels=[FUNDING, L2_BOOK], symbols=['BTC-USD-PERP'], callbacks={FUNDING: FundingQuest(host=QUEST_HOST, port=QUEST_PORT), L2_BOOK: BookQuest(host=QUEST_HOST, port=QUEST_PORT)}))
    f.add_feed(Coinbase(channels=[TRADES], symbols=['BTC-USD'], callbacks={TRADES: TradeQuest(host=QUEST_HOST, port=QUEST_PORT)}))
    f.add_feed(Coinbase(channels=[L2_BOOK], symbols=['BTC-USD'], callbacks={L2_BOOK: BookQuest(host=QUEST_HOST, port=QUEST_PORT)}))
    f.add_feed(Coinbase(channels=[TICKER], symbols=['BTC-USD'], callbacks={TICKER: TickerQuest(host=QUEST_HOST, port=QUEST_PORT)}))
    f.add_feed(Binance(candle_closed_only=False, channels=[CANDLES], symbols=['BTC-USDT'], callbacks={CANDLES: CandlesQuest(host=QUEST_HOST, port=QUEST_PORT)}))
    f.run()
示例#13
0
def main():
    f = FeedHandler()
    f.add_feed(Bitmex(channels=[TRADES, FUNDING, OPEN_INTEREST], symbols=['BTC-USD'], callbacks={TRADES: TradeRedis(), FUNDING: FundingRedis(), OPEN_INTEREST: OpenInterestRedis()}))
    f.add_feed(Bitfinex(channels=[TRADES], symbols=['BTC-USD'], callbacks={TRADES: TradeRedis()}))
    f.add_feed(Coinbase(channels=[TRADES], symbols=['BTC-USD'], callbacks={TRADES: TradeRedis()}))
    f.add_feed(Coinbase(channels=[L2_BOOK], symbols=['BTC-USD'], callbacks={BOOK_DELTA: BookDeltaStream(), L2_BOOK: BookStream()}))
    f.add_feed(Gemini(symbols=['BTC-USD'], callbacks={TRADES: TradeRedis()}))
    f.add_feed(Binance(candle_closed_only=True, symbols=['BTC-USDT'], channels=[CANDLES], callbacks={CANDLES: CandlesRedis(score_key='start')}))

    f.run()
示例#14
0
def main():
    config = {'log': {'filename': 'redis-demo.log', 'level': 'INFO'}}
    f = FeedHandler(config=config)
    f.add_feed(Bitmex(channels=[TRADES, FUNDING, OPEN_INTEREST], symbols=['BTC-USD-PERP'], callbacks={TRADES: TradeRedis(), FUNDING: FundingRedis(), OPEN_INTEREST: OpenInterestRedis()}))
    f.add_feed(Bitfinex(channels=[TRADES], symbols=['BTC-USD'], callbacks={TRADES: TradeRedis()}))
    f.add_feed(Coinbase(channels=[TRADES], symbols=['BTC-USD'], callbacks={TRADES: TradeRedis()}))
    f.add_feed(Coinbase(channels=[L2_BOOK], symbols=['BTC-USD'], callbacks={L2_BOOK: BookStream()}))
    f.add_feed(Gemini(symbols=['BTC-USD'], callbacks={TRADES: TradeRedis()}))
    f.add_feed(Binance(candle_closed_only=True, symbols=['BTC-USDT'], channels=[CANDLES], callbacks={CANDLES: CandlesRedis(score_key='start')}))
    f.add_feed(Binance(max_depth=10, symbols=['BTC-USDT'], channels=[L2_BOOK], callbacks={L2_BOOK: BookRedis(snapshots_only=True)}))

    f.run()
示例#15
0
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()
示例#16
0
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=[TRADES, OPEN_INTEREST, FUNDING, LIQUIDATIONS], callbacks={TRADES: trade, 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(candle_closed_only=True, 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(config='config.yaml', 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(OKX(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.add_feed(CryptoDotCom(symbols=['BTC-USDT'], channels=[L2_BOOK, TICKER, CANDLES, TRADES], callbacks={TRADES: trade, CANDLES: candle_callback, TICKER: ticker, L2_BOOK: book}))
    f.add_feed(Delta(symbols=['BTC-USDT', 'BTC-USDT-PERP'], channels=[L2_BOOK, TRADES, CANDLES], callbacks={TRADES: trade, CANDLES: candle_callback, L2_BOOK: book}))
    f.add_feed(BitDotCom(config="config.yaml", sandbox=True, symbols=['BTC-USDT', 'BTC-USD-PERP'], channels=[TICKER, TRADES, L2_BOOK], callbacks={TRADES: trade, L2_BOOK: book, TICKER: ticker}))
    f.add_feed(Bitget(config='config.yaml', symbols=['BTC-USD-PERP', 'BTC-USDT-PERP', 'BTC-USDT'], channels=[L2_BOOK, TICKER, CANDLES, TRADES], callbacks={CANDLES: candle_callback, TRADES: trade, L2_BOOK: book, TICKER: ticker}))
    f.add_feed(IndependentReserve(symbols=['BTC-USD'], channels=[L3_BOOK, TRADES], callbacks={TRADES: trade, L3_BOOK: book}))

    f.run()
示例#17
0
def main():
    loop = asyncio.get_event_loop()
    f = FeedHandler()
    f.add_feed(Coinbase(pairs=['BTC-USD'], channels=[TRADES], callbacks={TRADES: trade}))
    f.run(start_loop=False)

    loop.call_later(5, stop)
    loop.run_forever()

    print("\n\n******* ADDING NEW TRADING PAIR *******\n\n")
    f.add_feed(Coinbase(pairs=['ETH-USD'], channels=[TRADES], callbacks={TRADES: trade}))
    f.run(start_loop=False)

    loop.call_later(5, stop)
    loop.run_forever()
示例#18
0
def writer(addr, port):
    f = FeedHandler()
    f.add_feed(
        Coinbase(channels=[TRADES],
                 pairs=['BTC-USD'],
                 callbacks={TRADES: TradeSocket(addr, port=port)}))
    f.run()
示例#19
0
def writer(addr, port):
    f = FeedHandler()
    f.add_feed(Coinbase(channels=[TRADES, L2_BOOK], pairs=['BTC-USD'],
                        callbacks={TRADES: TradeSocket(addr, port=port),
                                   L2_BOOK: BookSocket(addr, port=port),
                                   BOOK_DELTA: BookDeltaSocket(addr, port=port)}))
    f.run()
示例#20
0
def main():
    f = FeedHandler()
    cbs = {TRADES: TradeKafka(), L2_BOOK: BookKafka()}
    
    f.add_feed(Coinbase(max_depth=10, channels=[TRADES, L2_BOOK], pairs=['BTC-USD'], callbacks=cbs))

    f.run()
示例#21
0
def main():
    try:
        p = Process(target=receiver, args=(5678, ))

        p.start()

        f = FeedHandler()
        f.add_feed(
            Kraken(max_depth=2,
                   channels=[L2_BOOK],
                   symbols=['ETH-USD', 'BTC-USD'],
                   callbacks={
                       L2_BOOK:
                       BookZMQ(snapshots_only=False,
                               snapshot_interval=2,
                               port=5678)
                   }))
        f.add_feed(
            Coinbase(channels=[TICKER],
                     symbols=['BTC-USD'],
                     callbacks={TICKER: TickerZMQ(port=5678)}))

        f.run()

    finally:
        p.terminate()
示例#22
0
def main():
    f = FeedHandler()

    f.add_feed(Coinbase(channels=[L2_BOOK, TRADES], pairs=['BTC-USD'], callbacks={L2_BOOK: BookElastic('http://localhost:9200', numeric_type=float), BOOK_DELTA: BookDeltaElastic('http://localhost:9200', numeric_type=float), TRADES: TradeElastic('http://localhost:9200', numeric_type=float)}))
    f.add_feed(Bitmex(channels=[FUNDING], pairs=['XBTUSD'], callbacks={FUNDING: FundingElastic('http://localhost:9200', numeric_type=float)}))

    f.run()
示例#23
0
def main():
    f = FeedHandler()
    f.add_feed(
        Bitmex(channels=[FUNDING, L2_BOOK],
               pairs=['XBTUSD'],
               callbacks={
                   FUNDING:
                   FundingInflux('http://localhost:8086', 'example'),
                   L2_BOOK:
                   BookInflux('http://localhost:8086',
                              'example',
                              numeric_type=float),
                   BOOK_DELTA:
                   BookDeltaInflux('http://localhost:8086',
                                   'example',
                                   numeric_type=float)
               }))
    f.add_feed(
        Coinbase(channels=[TRADES],
                 pairs=['BTC-USD'],
                 callbacks={
                     TRADES: TradeInflux('http://localhost:8086', 'example')
                 }))
    f.add_feed(
        Coinbase(channels=[L2_BOOK],
                 pairs=['BTC-USD'],
                 callbacks={
                     L2_BOOK:
                     BookInflux('http://localhost:8086',
                                'example',
                                numeric_type=float),
                     BOOK_DELTA:
                     BookDeltaInflux('http://localhost:8086',
                                     'example',
                                     numeric_type=float)
                 }))
    f.add_feed(
        Coinbase(channels=[TICKER],
                 pairs=['BTC-USD'],
                 callbacks={
                     TICKER:
                     TickerInflux('http://localhost:8086',
                                  'example',
                                  numeric_type=float)
                 }))

    f.run()
示例#24
0
def main():
    f = FeedHandler()
    f.add_feed(
        Coinbase(symbols=['BTC-USD', 'ETH-USD', 'BCH-USD'],
                 channels=[TRADES],
                 callbacks={TRADES: OHLCV(ohlcv, window=10)}))

    f.run()
示例#25
0
def main():
    f = FeedHandler()
    f.add_feed(
        Coinbase(pairs=['BTC-USD', 'ETH-USD', 'BCH-USD'],
                 channels=[TRADES],
                 callbacks={TRADES: OHLCV(Callback(ohlcv), window=300)}))

    f.run()
示例#26
0
def main():
    f = FeedHandler()
    f.add_feed(
        Coinbase(symbols=['BTC-USD'],
                 channels=[L2_BOOK],
                 callbacks={L2_BOOK: Throttle(callback, window=10)}))

    f.run()
示例#27
0
def main():
    loop = asyncio.get_event_loop()
    f.add_feed(Coinbase(symbols=['BTC-USD'], channels=[TRADES], callbacks={TRADES: trade}))
    f.run(start_loop=False)

    loop.call_later(2, add_new_feed)
    loop.call_later(15, stop)
    loop.run_forever()
示例#28
0
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()
示例#29
0
def main():
    f = FeedHandler()
    f.add_feed(
        Coinbase(
            channels=[TRADES],
            pairs=['BTC-USD'],
            callbacks={TRADES: TradeMongo('coinbase', collection='trades')}))

    f.run()
示例#30
0
def main():
    f = FeedHandler()

    f.add_feed(
        Coinbase(max_depth=5,
                 symbols=['BTC-USD'],
                 channels=[L2_BOOK],
                 callbacks={L2_BOOK: BookCallback(book)}))
    f.run()