bmoscon / cryptofeed

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

Incorrect prices and volumes on BitMEX #857

Open aceffer opened 2 years ago

aceffer commented 2 years ago

Describe the bug Order book data from BitMEX for symbol MATICUSDT is incorrect.

To Reproduce Steps to reproduce the behavior: Run this script and compare prices and volumes against data on bitmex.com.

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}")
            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: ['MATIC-USDT-PERP']}, callbacks={L2_BOOK: br.book}),
               checksum_validation=True, cross_check=True)
    f.run()

if __name__ == '__main__':
    main()

Expected behavior The price and volume should be the same as the exchange provides on their website.

Screenshots bitmex_error

Operating System:

Cryptofeed Version 2.2.1, 2.2.3

anguswschan commented 2 years ago

And Also incorrect volumes on HuobiSwap.