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()
Exemple #2
0
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()
Exemple #4
0
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()