Exemplo n.º 1
0
def main():
    f = FeedHandler()

    f.add_feed(
        Coinbase(
            config={TRADES: ['BTC-USD']},
            callbacks={TRADES: [TradeCallback(trade),
                                TradeCallback(trade2)]}))

    f.run()
Exemplo n.º 2
0
def main():

    f = FeedHandler()
    # Liquidations happen not frequently, disable feed timeout
    f.add_feed(Bitmex(
        channels=[LIQUIDATIONS],
        symbols=['XBTUSD'],
        callbacks={LIQUIDATIONS: LiquidationCallback(liquidations)}),
               timeout=-1)
    f.run()
Exemplo n.º 3
0
def main():
    fh = FeedHandler()

    callbacks = {TRADES: TradeCallback(trade), L2_BOOK: BookCallback(book)}
    fh.add_feed(
        HuobiSwap(pairs=['BTC-USD'],
                  channels=[TRADES, L2_BOOK],
                  callbacks=callbacks))

    fh.run()
Exemplo n.º 4
0
def main():
    f = FeedHandler()

    f.add_feed(
        Bybit(pairs=['BTC-USD', 'ETH-USD', 'XRP-USD', 'EOS-USD'],
              channels=[TRADES],
              callbacks={TRADES: TradeCallback(trade)}))
    #f.add_feed(Bybit(pairs=['BTC-USD', 'ETH-USD', 'XRP-USD', 'EOS-USD'], channels=[L2_BOOK], callbacks={L2_BOOK: BookCallback(book)}))

    f.run()
Exemplo n.º 5
0
def main():
    f = FeedHandler()
    f.add_feed(
        Bitmex(pairs=['XBTUSD'],
               channels=[L2_BOOK],
               callbacks={
                   L2_BOOK: BookCallback(book),
                   BOOK_DELTA: BookUpdateCallback(delta)
               }))
    f.run()
Exemplo n.º 6
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()
def main(pairs):
    f = FeedHandler()
    trade_influx = TradeInflux('http://localhost:8086',
                               'trades',
                               create_db=False,
                               numeric_type=float)
    f.add_feed(FTX(channels=[TRADES],
                   pairs=pairs,
                   callbacks={TRADES: trade_influx}),
               timeout=120)
    f.run()
Exemplo n.º 8
0
def writer(path):
    f = FeedHandler()
    f.add_feed(
        Coinbase(channels=[TRADES, TICKER],
                 pairs=['BTC-USD'],
                 callbacks={
                     TRADES: TradeSocket(path),
                     TICKER: TickerSocket(path)
                 }))

    f.run()
Exemplo n.º 9
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()
Exemplo n.º 10
0
def streaming_ticker():
    f = FeedHandler()
    f.add_feed(
        Binance(pairs=['BTC-USDT'],
                channels=[TRADES, TICKER],
                callbacks={
                    TICKER: TickerCallback(ticker),
                    TRADES: TradeCallback(trade)
                }))

    f.run()
Exemplo n.º 11
0
def main():
    try:
        p = Process(target=receiver, args=(5555,))
        p.start()

        f = FeedHandler()
        f.add_feed(Coinbase(channels=[L2_BOOK, TRADES], pairs=['BTC-USD'], callbacks={TRADES: TradeSocket('udp://127.0.0.1', port=5555), L2_BOOK: Throttle(BookSocket('udp://127.0.0.1', port=5555, depth=10), timer=1)}))

        f.run()
    finally:
        p.terminate()
Exemplo n.º 12
0
def main():
    f = FeedHandler()
    f.add_feed(
        Bitmex(pairs=['XBTUSD'],
               channels=[TRADES, OPEN_INTEREST],
               callbacks={
                   OPEN_INTEREST: OpenInterestArctic('cryptofeed-test2'),
                   TRADES: TradeArctic('cryptofeed-test2')
               }))

    f.run()
Exemplo n.º 13
0
def main():
    f = FeedHandler()
    f.add_feed(
        FTXUS(pairs=['BTC-USD', 'BCH-USD', 'USDT-USD'],
              channels=[TRADES, L2_BOOK, TICKER],
              callbacks={
                  L2_BOOK: BookCallback(book),
                  TICKER: ticker,
                  TRADES: TradeCallback(trade)
              }))
    f.run()
Exemplo n.º 14
0
def main():
    f = FeedHandler()
    f.add_feed(
        BinanceDelivery(max_depth=3,
                        symbols=[info['symbols'][-1]],
                        channels=[L2_BOOK, TRADES, TICKER],
                        callbacks={
                            L2_BOOK: abook,
                            TRADES: trades,
                            TICKER: ticker
                        }))
    f.run()
Exemplo n.º 15
0
def main():
    f = FeedHandler()
    f.add_feed(
        Coinbase(channels=[L2_BOOK, TRADES, TICKER],
                 pairs=['BTC-USD'],
                 callbacks={
                     L2_BOOK: BookPostgres(**postgres_cfg),
                     BOOK_DELTA: BookDeltaPostgres(**postgres_cfg),
                     TICKER: TickerPostgres(**postgres_cfg),
                     TRADES: TradePostgres(**postgres_cfg)
                 }))
    f.run()
Exemplo n.º 16
0
def main():
    f = FeedHandler()
    # due to the way the test verification works, you can only run one or the other for this test
    #f.add_feed(Bitmex(pairs=['XBTUSD'], channels=[L2_BOOK], callbacks={L2_BOOK: BookCallback(book), BOOK_DELTA: BookUpdateCallback(delta)}))
    f.add_feed(
        GDAX(pairs=['BTC-USD'],
             channels=[L3_BOOK],
             callbacks={
                 L3_BOOK: BookCallback(book),
                 BOOK_DELTA: BookUpdateCallback(delta)
             }))
    f.run()
Exemplo n.º 17
0
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()
Exemplo n.º 18
0
    def run(self):
        LOG.info("Collector for %s running on PID %d", self.exchange,
                 os.getpid())
        fh = FeedHandler()
        cb = {}
        depth = None
        window = 1000

        if 'book_delta_window' in self.config:
            window = self.config['book_delta_window']

        if 'book_depth' in self.config:
            depth = self.config['book_depth']

        cache = self.config['cache']
        if cache == 'redis':
            from cryptofeed.backends.redis import TradeStream, BookStream, BookDeltaStream
            trade_cb = TradeStream
            book_cb = BookStream
            book_up = BookDeltaStream if not depth and self.config[
                'book_delta'] else None
            kwargs = {
                'host': self.config['redis']['ip'],
                'port': self.config['redis']['port']
            }
        elif cache == 'kafka':
            from cryptofeed.backends.kafka import TradeKafka, BookKafka, BookDeltaKafka
            trade_cb = TradeKafka
            book_cb = BookKafka
            book_up = BookDeltaKafka if not depth and self.config[
                'book_delta'] else None
            kwargs = {
                'host': self.config['kafka']['ip'],
                'port': self.config['kafka']['port']
            }

        if TRADES in self.exchange_config:
            cb[TRADES] = trade_cb(**kwargs)
        if L2_BOOK in self.exchange_config:
            cb[L2_BOOK] = book_cb(key=L2_BOOK, depth=depth, **kwargs)
            if book_up:
                cb[BOOK_DELTA] = book_up(key=L2_BOOK, **kwargs)
        if L3_BOOK in self.exchange_config:
            cb[L3_BOOK] = book_cb(key=L3_BOOK, depth=depth, **kwargs)
            if book_up:
                cb[BOOK_DELTA] = book_up(key=L3_BOOK, **kwargs)

        fh.add_feed(self.exchange,
                    book_interval=window,
                    config=self.exchange_config,
                    callbacks=cb)
        fh.run()
Exemplo n.º 19
0
def main():

    f = FeedHandler(config="config.yaml")
    f.add_feed(BYBIT,
               channels=[FILLS, ORDER_INFO],
               symbols=["ETH-USD-21Z31", "EOS-USD-PERP", "SOL-USDT-PERP"],
               callbacks={
                   FILLS: fill,
                   ORDER_INFO: order
               },
               timeout=-1)

    f.run()
def main():
    f = FeedHandler(config="config.yaml")

    f.add_feed(DERIBIT,
               channels=[FILLS, ORDER_INFO],
               symbols=[
                   "ETH-USD-PERP", "BTC-USD-PERP", "ETH-USD-22M24",
                   "BTC-50000-22M24-call"
               ],
               callbacks={
                   FILLS: UserFillsCallback(fill),
                   ORDER_INFO: OrderInfoCallback(order)
               },
               timeout=-1)
    f.add_feed(DERIBIT,
               channels=[BALANCES],
               symbols=["BTC", "ETH"],
               callbacks={BALANCES: BalancesCallback(balance)},
               timeout=-1)
    f.run()
def main():
    f = FeedHandler()
    # due to the way the test verification works, you can only run one for the test
    # f.add_feed(Bitmex(pairs=['XBTUSD'], channels=[L3_BOOK], callbacks={L3_BOOK: BookCallback(book), BOOK_DELTA: BookUpdateCallback(l3_delta)}))
    # f.add_feed(Bitfinex(pairs=['BTC-USD'], channels=[L3_BOOK], callbacks={L3_BOOK: BookCallback(book), BOOK_DELTA: BookUpdateCallback(l3_delta)}))
    # f.add_feed(Bitfinex(pairs=['BTC-USD'], channels=[L2_BOOK], callbacks={L2_BOOK: BookCallback(book), BOOK_DELTA: BookUpdateCallback(delta)}))
    # f.add_feed(Coinbase(pairs=['BTC-USD'], channels=[L3_BOOK], callbacks={L3_BOOK: BookCallback(book), BOOK_DELTA: BookUpdateCallback(l3_delta)}))
    # f.add_feed(Coinbase(pairs=['BTC-USD'], channels=[L2_BOOK], callbacks={L2_BOOK: BookCallback(book), BOOK_DELTA: BookUpdateCallback(delta)}))
    # f.add_feed(Gemini(book_interval=100, pairs=['BTC-USD'], callbacks={L2_BOOK: BookCallback(book), BOOK_DELTA: BookUpdateCallback(delta)}))
    # f.add_feed(HitBTC(book_interval=100, pairs=['BTC-USD'], channels=[L2_BOOK], callbacks={L2_BOOK: BookCallback(book), BOOK_DELTA: BookUpdateCallback(delta)}))
    f.add_feed(Poloniex(book_interval=100, channels=['BTC-USDT'], callbacks={L2_BOOK: BookCallback(book), BOOK_DELTA: BookUpdateCallback(delta)}))

    f.run()
Exemplo n.º 22
0
def main():
    """
    Because periods cannot be in keys in documents in mongo, the bids and asks dictionaries
    are converted to BSON. They will need to be decoded after being read
    """
    f = FeedHandler()
    f.add_feed(Coinbase(max_depth=10, channels=[L2_BOOK],
                        pairs=['BTC-USD'],
                        callbacks={TRADES: TradeMongo('coinbase', collection='trades'),
                                   L2_BOOK: BookMongo('coinbase', collection='l2_book'),
                                   BOOK_DELTA: BookDeltaMongo('coinbase', collection='l2_book')}))

    f.run()
Exemplo n.º 23
0
def main():
    try:
        p = Process(target=receiver, args=(5672,))

        p.start()

        f = FeedHandler()
        f.add_feed(Kraken(max_depth=2, channels=[L2_BOOK], symbols=['BTC-USD', 'ETH-USD'], callbacks={L2_BOOK: BookRabbit()}))

        f.run()

    finally:
        p.terminate()
Exemplo n.º 24
0
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()
Exemplo n.º 25
0
def main():
    f = FeedHandler()

    f.add_feed(
        Coinbase(max_depth=2,
                 pairs=['BTC-USD'],
                 channels=[L2_BOOK],
                 callbacks={
                     BOOK_DELTA: delta,
                     L2_BOOK: book
                 }))

    f.run()
Exemplo n.º 26
0
def main():
    try:
        f = FeedHandler()
        #f.add_feed(BinanceFutures(max_depth=10, channels=[L2_BOOK], pairs=['BTC-USDT'], callbacks={L2_BOOK:OrderbookRabbit()}))
        f.add_feed(
            FTX(max_depth=10,
                channels=[L2_BOOK],
                pairs=['BTC-PERP'],
                callbacks={L2_BOOK: OrderbookRabbit()}))
        # f.add_feed(HuobiDM(max_depth=10, channels=[L2_BOOK], pairs=['BTC-USDT'], callbacks={L2_BOOK:OrderbookRabbit()}))
        f.run()
    finally:
        pass
Exemplo n.º 27
0
def main():
    try:
        p = Process(target=receiver, args=(5678, ))

        p.start()

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

        f.run()

    finally:
        p.terminate()
Exemplo n.º 28
0
def main():
    f = FeedHandler()

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

    f.run()
Exemplo n.º 29
0
def main():
    f = FeedHandler()
    f.add_feed(
        Coinbase(symbols=['BTC-USD'],
                 channels=[TRADES],
                 callbacks={
                     TRADES:
                     CustomAggregate(callback,
                                     window=30,
                                     init=init,
                                     aggregator=custom_agg)
                 }))

    f.run()
Exemplo n.º 30
0
def main():
    f = FeedHandler()

    f.add_feed(
        Coinbase(config={
            TRADES: ['BTC-USD'],
            L3_BOOK: ['ETH-USD']
        },
                 callbacks={
                     TRADES: TradeCallback(trade, include_order_type=True),
                     L3_BOOK: BookCallback(book)
                 }))

    f.run()