bmoscon / cryptofeed

Cryptocurrency Exchange Websocket Data Feed Handler
Other
2.19k stars 679 forks source link

ETHUSDT book is not updated in Bitmex #905

Closed dfogaras closed 1 year ago

dfogaras commented 1 year ago

ETHUSDT L2 book seems to be stuck at unrealistic prices since yesterday. The code below prints "bid=1400.05 / 6306000000 ask=1680.0 / 61000000", but the real prices are very different.

from cryptofeed import FeedHandler
from cryptofeed.defines import L2_BOOK
import cryptofeed.exchanges

from datetime import datetime,timedelta
from cryptofeed.exchanges import Bitmex

class BookReader:

    def __init__(self):
        self.__last_print = datetime.utcnow()

    async def book(self, book, receipt_timestamp):
            if datetime.utcnow() - self.__last_print > timedelta(seconds=1):
                bid = float(book.book['bid'].index(0)[0])
                ask = float(book.book['ask'].index(0)[0])
                bidVol = book.book['bid'].index(0)[1]
                askVol = book.book['ask'].index(0)[1]
                print(f"bid={bid} / {bidVol} ask={ask} / {askVol}")
                #print(f"bid array={list(book.book['bid'].items())}")
                self.__last_print = datetime.utcnow()

def main():
    config = {'log': {'filename': 'demo.log', 'level': 'DEBUG', 'disabled': False}}
    f = FeedHandler(config=config)
    br = BookReader()
    f.add_feed(Bitmex(max_depth=10, subscription={L2_BOOK: ['ETH-USDT-PERP']}, callbacks={L2_BOOK: br.book}), checksum_validation=True, cross_check=True)
    f.run()

if __name__ == '__main__':
    main()

I could reproduce this problem with macos and linux and cryptofeed versions 2.3.0 and 2.2.0.

dfogaras commented 1 year ago

As of now, the entries are updated, but the prices are obviously wrong compared to the Bitmex UI