BitMEX/sample-market-maker

Got the error below when running "marketmaker", any idea?

Opened this issue · 1 comments

Got the error below when running "marketmaker", any idea?

 pythonProject % marketmaker
2024-09-14 16:35:35,160 - INFO - market_maker - BitMEX Market Maker Version: v1.1

2024-09-14 16:35:35,160 - INFO - ws_thread - Connecting to wss://testnet.bitmex.com/realtime?subscribe=quote:XBTUSD,trade:XBTUSD,instrument,order:XBTUSD,execution:XBTUSD,margin,position
2024-09-14 16:35:35,160 - INFO - ws_thread - Authenticating with API Key.
2024-09-14 16:35:35,160 - INFO - ws_thread - Started thread
2024-09-14 16:35:36,693 - INFO - _logging - Websocket connected
2024-09-14 16:35:36,693 - ERROR - _logging - error from callback <bound method BitMEXWebsocket.__on_open of <market_maker.ws.ws_thread.BitMEXWebsocket object at 0x105c24650>>: BitMEXWebsocket.__on_open() takes 1 positional argument but 2 were given
2024-09-14 16:35:36,693 - ERROR - _logging - error from callback <bound method BitMEXWebsocket.__on_error of <market_maker.ws.ws_thread.BitMEXWebsocket object at 0x105c24650>>: BitMEXWebsocket.__on_error() takes 2 positional arguments but 3 were given
2024-09-14 16:35:36,693 - INFO - _logging - tearing down on exception BitMEXWebsocket.__on_error() takes 2 positional arguments but 3 were given
2024-09-14 16:35:37,782 - ERROR - _logging - error from callback <bound method BitMEXWebsocket.__on_close of <market_maker.ws.ws_thread.BitMEXWebsocket object at 0x105c24650>>: BitMEXWebsocket.__on_close() takes 1 positional argument but 4 were given
Exception in thread Thread-1 (<lambda>):
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_app.py", line 553, in _callback
    callback(self, *args)
TypeError: BitMEXWebsocket.__on_open() takes 1 positional argument but 2 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_app.py", line 432, in setSock
    self._callback(self.on_open)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_app.py", line 558, in _callback
    self.on_error(self, e)
TypeError: BitMEXWebsocket.__on_error() takes 2 positional arguments but 3 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_app.py", line 553, in _callback
    callback(self, *args)
TypeError: BitMEXWebsocket.__on_error() takes 2 positional arguments but 3 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_app.py", line 507, in run_forever
    setSock()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_app.py", line 436, in setSock
    handleDisconnect(e, reconnecting)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_app.py", line 487, in handleDisconnect
    self._callback(self.on_error, e)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_app.py", line 558, in _callback
    self.on_error(self, e)
TypeError: BitMEXWebsocket.__on_error() takes 2 positional arguments but 3 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_app.py", line 553, in _callback
    callback(self, *args)
TypeError: BitMEXWebsocket.__on_close() takes 1 positional argument but 4 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/market_maker/ws/ws_thread.py", line 163, in <lambda>
    self.wst = threading.Thread(target=lambda: self.ws.run_forever(sslopt=sslopt_ca_certs))
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_app.py", line 514, in run_forever
    teardown()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_app.py", line 401, in teardown
    self._callback(self.on_close, close_status_code, close_reason)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_app.py", line 558, in _callback
    self.on_error(self, e)
TypeError: BitMEXWebsocket.__on_error() takes 2 positional arguments but 3 were given
2024-09-14 16:35:40,177 - ERROR - ws_thread - Couldn't connect to WS! Exiting.


Looks like the methods __on_open, __on_error, and __on_close in the BitMEXWebsocket class are being passed the wrong number of arguments. The mismatch is leading to the TypeErrors you're seeing. Can ensure you're using the latest version of the websocket-client library & modify the callback functions.