bmoscon / cryptofeed

Cryptocurrency Exchange Websocket Data Feed Handler
Other
2.14k stars 666 forks source link

BITMEX: Failed to parse symbol information: 'expiry' #1014

Closed gawaboga closed 4 months ago

gawaboga commented 4 months ago

Describe the bug 2024-03-01 14:27:05,508 : ERROR : BITMEX: Failed to parse symbol information: 'expiry' Traceback (most recent call last): File "/home/ec2-user/.cache/pypoetry/virtualenvs/feed-CdS8cHT0-py3.9/lib64/python3.9/site-packages/cryptofeed/exchange.py", line 105, in symbol_mapping syms, info = cls._parse_symbol_data(data if len(data) > 1 else data[0]) File "/home/ec2-user/.cache/pypoetry/virtualenvs/feed-CdS8cHT0-py3.9/lib64/python3.9/site-packages/cryptofeed/exchanges/bitmex.py", line 61, in _parse_symbol_data s = Symbol(base, quote, type=stype, expiry_date=entry['expiry']) KeyError: 'expiry' 2024-03-01 14:27:05,510:ERROR:An error occurred: 'expiry'

To Reproduce fh.add_feed(Bitmex(timeout=5000, symbols=Bitmex.symbols(), channels=[LIQUIDATIONS], callbacks={LIQUIDATIONS: liquidations, OPEN_INTEREST: oi, FUNDING: funding}))

Expected behavior expiry = entry.get('expiry') # Use .get() to avoid KeyError if not expiry: continue # Skip symbols without expiry or handle appropriately s = Symbol(base, quote, type=stype, expiry_date=expiry)

Operating System:

Cryptofeed Version 2.4.0 Python Version 3.9.16

I have tested using .get() to avoid KeyError, as in Expected behavior, editing the packages/cryptofeed/exchanges/bitmex.py", line 61, in _parse_symbol_data, and now works. If anyone has same issue, is this correct way to workaround? Thanks! Cheers! Sam