示例#1
0
def main(only_exchange=None):
    skip = [EXX]
    files = glob.glob('*')
    for f in files:
        for e in EXCHANGE_MAP.keys():
            if e + "." in f:
                skip.append(e.split(".")[0])

    print(f'Generating test data. This will take approximately {(len(EXCHANGE_MAP) - len(set(skip))) * 0.5} minutes.')
    loop = asyncio.get_event_loop()
    for exch_str, exchange in EXCHANGE_MAP.items() if only_exchange is None else [(only_exchange, EXCHANGE_MAP[only_exchange])]:
        if exch_str in skip:
            continue

        print(f"Collecting data for {exch_str}")
        fh = FeedHandler(raw_data_collection=AsyncFileCallback("./"), config={'uvloop': False, 'log': {'filename': 'feedhandler.log', 'level': 'WARNING'}, 'rest': {'log': {'filename': 'rest.log', 'level': 'WARNING'}}})
        info = exchange.info()
        channels = list(set.intersection(set(info['channels']['websocket']), set([L2_BOOK, TRADES, TICKER, CANDLES])))
        sample_size = 10
        if exch_str in (BINANCE_US, BINANCE):
            # books of size 5000 count significantly against rate limits
            sample_size = 4
        while True:
            try:
                symbols = random.sample(info['symbols'], sample_size)

                if exch_str == BINANCE_FUTURES:
                    symbols = [s for s in symbols if 'PINDEX' not in s]
                elif exch_str == BITFINEX:
                    symbols = [s for s in symbols if '-' in s]

            except ValueError:
                sample_size -= 1
            else:
                break

        fh.add_feed(exchange(symbols=symbols, channels=channels))
        fh.run(start_loop=False)

        loop.call_later(31, stop)
        print("Starting feedhandler. Will run for 30 seconds...")
        loop.run_forever()

        fh.stop(loop=loop)
        del fh

    print("Checking raw message dumps for errors...")
    for exch_str, _ in EXCHANGE_MAP.items():
        for file in glob.glob(exch_str + "*"):
            try:
                print(f"Checking {file}")
                check_dump(file)
            except Exception as e:
                print(f"File {file} failed")
                print(e)
示例#2
0
def main():
    f = FeedHandler()
    f.add_feed(
        Coinbase(pairs=['BTC-USD', 'ETH-USD'],
                 channels=[TRADES, TICKER],
                 callbacks={
                     TICKER: TickerCallback(ticker),
                     TRADES: TradeCallback(trade)
                 }))
    f.add_feed(
        Kraken(pairs=['BTC-USD', 'ETH-USD'],
               channels=[TRADES, TICKER],
               callbacks={
                   TICKER: TickerCallback(ticker),
                   TRADES: TradeCallback(trade)
               }))
    f.add_feed(
        Bitfinex(pairs=['BTC-USD', 'ETH-USD'],
                 channels=[TRADES, TICKER],
                 callbacks={
                     TICKER: TickerCallback(ticker),
                     TRADES: TradeCallback(trade)
                 }))
    #    f.add_feed(Bitmex(pairs=['XBTUSD','ETHUSD'],channels=[TRADES],callbacks={TRADES:TradeCallback(trade)}))
    #    f.add_feed(Bitstamp(pairs=['BTC-USD','ETH-USD'],channels=[TRADES],callbacks={TRADES:TradeCallback(trade)}))
    #    f.add_feed(Gemini(pairs=['ETH-USD'], callbacks={TRADES:TradeCallback(trade)}))
    #    f.add_feed(Gemini(pairs=['BTC-USD'], callbacks={TRADES:TradeCallback(trade)}))
    f.add_feed(
        HitBTC(channels=[TRADES, TICKER],
               pairs=['BTC-USD', 'ETH-USD'],
               callbacks={
                   TRADES: TradeCallback(trade),
                   TICKER: TickerCallback(ticker)
               }))
    #    f.add_feed(Huobi(pairs=['BTC-USD','ETH-USD'],channels=[TRADES],callbacks={TRADES:TradeCallback(trade)}))
    f.run()
示例#3
0
def main():
    f = FeedHandler()
    f.add_nbbo([GDAX, HitBTC, Bitfinex], ['BTC-USD', 'ETH-USD'], nbbo_ticker)
    f.run()
示例#4
0
kraken_syms = [
    'ADA-BTC', 'DASH-BTC', 'ETH-BTC', 'EOS-BTC', 'LTC-BTC', 'XLM-BTC',
    'XMR-BTC', 'XRP-BTC', 'ZEC-BTC', 'ADA-ETH', 'EOS-ETH', 'BTC-USD',
    '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'
]
fh = FeedHandler()

fh.add_feed(
    Kraken(pairs=kraken_syms,
           channels=[L2_BOOK],
           callbacks={L2_BOOK: BookCallback(book)}))
#fh.add_feed(Bitfinex(pairs=bitfinex_syms, channels=[L2_BOOK], callbacks={L2_BOOK: BookCallback(book)}))
#fh.add_feed(Bitstamp(pairs=bitstamp_syms, channels=[L2_BOOK], callbacks={L2_BOOK: BookCallback(book)}))
fh.add_feed(
    Binance(pairs=binance_syms,
            channels=[L2_BOOK],
            callbacks={L2_BOOK: BookCallback(book)}))

fh.run()
示例#5
0
def main():
    f = FeedHandler()
    f.add_nbbo([Coinbase, HitBTC, Bitfinex, Bitstamp, Gemini], ['BTC-USD'], nbbo_update)
    f.run()
示例#6
0
    '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()