Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'clOrdID' #239

Closed
derlykk opened this issue Mar 26, 2023 · 1 comment
Closed

KeyError: 'clOrdID' #239

derlykk opened this issue Mar 26, 2023 · 1 comment

Comments

@derlykk
Copy link

derlykk commented Mar 26, 2023

Traceback (most recent call last):
  File "custom_bitmex_strategy.py", line 508, in <module>
    run()
  File "custom_bitmex_strategy.py", line 500, in run
    order_manager = CustomOrderManager()
  File "/home/admin/my_bitmex/market_maker.py", line 217, in __init__
    self.reset()
  File "/home/admin/my_bitmex/market_maker.py", line 221, in reset
    self.sanity_check()
  File "/home/admin/my_bitmex/market_maker.py", line 452, in sanity_check
    ticker = self.get_ticker()
  File "/home/admin/my_bitmex/market_maker.py", line 260, in get_ticker
    if ticker['buy'] == self.exchange.get_highest_buy()['price']:
  File "/home/admin/my_bitmex/market_maker.py", line 143, in get_highest_buy
    buys = [o for o in self.get_orders() if o['side'] == 'Buy']
  File "/home/admin/my_bitmex/market_maker.py", line 140, in get_orders
    return self.bitmex.open_orders()
  File "/home/admin/my_bitmex/bitmex.py", line 134, in wrapped
    return fn(self, *args, **kwargs)
  File "/home/admin/my_bitmex/bitmex.py", line 226, in open_orders
    return self.ws.open_orders(self.orderIDPrefix)
  File "/home/admin/my_bitmex/ws/ws_thread.py", line 118, in open_orders
    return [o for o in orders if str(o['clOrdID']).startswith(clOrdIDPrefix) and o['leavesQty'] > 0]
  File "/home/admin/my_bitmex/ws/ws_thread.py", line 118, in <listcomp>
    return [o for o in orders if str(o['clOrdID']).startswith(clOrdIDPrefix) and o['leavesQty'] > 0]
KeyError: 'clOrdID'

fixed it with replaceing line 117 in: https://github.com/BitMEX/sample-market-maker/blob/be124ebc90d7aa692bdf2f53e066bf5e7e25723f/market_maker/ws/ws_thread.py
from
return [o for o in orders if str(o['clOrdID']).startswith(clOrdIDPrefix) and o['leavesQty'] > 0]
to
return [o for o in orders if 'clOrdID' in o and str(o['clOrdID']).startswith(clOrdIDPrefix) and o['leavesQty'] > 0]

@byshing
Copy link

byshing commented Mar 27, 2023

Hi @derlykk thanks for reporting. This fix has been applied 0bb5ddb. And included in release version 1.6.1.

https://pypi.org/project/bitmex-market-maker/1.6.1/

@byshing byshing closed this as completed Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants