Closed folkertvanheusden closed 2 years ago
When I run this:
from cryptofeed import FeedHandler from cryptofeed.defines import CANDLES, BID, ASK, BLOCKCHAIN, FUNDING, GEMINI, L2_BOOK, L3_BOOK, LIQUIDATIONS, OPEN_INTEREST, PERPETUAL, TICKER, TRADES, INDEX from cryptofeed.exchanges import (Bitstamp, Coinbase) def ticker(msg, timestamp): print(msg) fh = FeedHandler() fh.add_feed(Coinbase(subscription={TICKER: ['BTC-USD']}, callbacks={TICKER: ticker})) fh.run()
then I get the following output:
ghbot@harkbot:~/btc$ ./btc-collector.py exchange: COINBASE symbol: BTC-USD bid: 20299.99 ask: 20300.00 timestamp: 1656007155.832793 2022-06-23 19:59:17,929 : ERROR : COINBASE.ws.1: encountered an exception, reconnecting in 1.0 seconds Traceback (most recent call last): File "/home/ghbot/.local/lib/python3.9/site-packages/cryptofeed/connection_handler.py", line 69, in _create_connection await self._handler(connection, self.handler) File "/home/ghbot/.local/lib/python3.9/site-packages/cryptofeed/connection_handler.py", line 119, in _handler await handler(message, connection, self.conn.last_message) File "/home/ghbot/.local/lib/python3.9/site-packages/cryptofeed/exchanges/coinbase.py", line 351, in message_handler await self._ticker(msg, timestamp) File "/home/ghbot/.local/lib/python3.9/site-packages/cryptofeed/exchanges/coinbase.py", line 108, in _ticker await self.callback(TICKER, Ticker(self.id, self.exchange_symbol_to_std_symbol(msg['product_id']), Decimal(msg['best_bid']), Decimal(msg['best_ask']), self.timestamp_normalize(msg['time']), raw=msg), timestamp) File "/home/ghbot/.local/lib/python3.9/site-packages/cryptofeed/feed.py", line 254, in callback await cb(obj, receipt_timestamp) TypeError: object NoneType can't be used in 'await' expression
Found it: I overlooked the 'async' on the ticker-callback.
When I run this:
then I get the following output: