BitMEX / sample-market-maker

Sample BitMEX Market Making Bot
Apache License 2.0
1.7k stars 758 forks source link

while MM restarting , Unable to cancel orders #160

Open lwldarkie opened 6 years ago

lwldarkie commented 6 years ago

2018-09-20 19:01:43,742 - INFO - ws_thread - Got all market data. Starting. 2018-09-20 19:01:43,742 - INFO - market_maker - Using symbol XBTUSD. 2018-09-20 19:01:43,743 - INFO - market_maker - Order Manager initializing, connecting to BitMEX. Live run: executing real trades. Traceback (most recent call last): File "marketmaker", line 4, in market_maker.run() File "/root/mm/market_maker/market_maker.py", line 543, in run om = OrderManager() File "/root/mm/market_maker/market_maker.py", line 217, in init self.instrument = self.exchange.get_instrument() File "/root/mm/market_maker/market_maker.py", line 133, in get_instrument return self.bitmex.instrument(symbol) File "/root/mm/market_maker/bitmex.py", line 68, in instrument return self.ws.get_instrument(symbol) File "/root/mm/market_maker/ws/ws_thread.py", line 77, in get_instrument raise Exception("Unable to find instrument or index with symbol: " + symbol) Exception: Unable to find instrument or index with symbol: XBTUSD 2018-09-20 19:01:43,744 - INFO - market_maker - Shutting down. All open orders will be cancelled. 2018-09-20 19:01:43,744 - INFO - market_maker - Resetting current position. Canceling all existing orders. 2018-09-20 19:01:43,744 - INFO - market_maker - Unable to cancel orders: Unable to find instrument or index with symbol: XBTUSD

in the bitmex.py, the function "exit" has handled this Excepttion like this:

 def exit(self):
        logger.info("Shutting down. All open orders will be cancelled.")
        try:
            self.exchange.cancel_all_orders()
            self.exchange.bitmex.exit()
        except errors.AuthenticationError as e:
            logger.info("Was not authenticated; could not cancel orders.")
        except Exception as e:
            logger.info("Unable to cancel orders: %s" % e)

        sys.exit()

I think it should go to the sys.exit() but it seems it came into a infinite loop. How should I do?

ryanfox commented 6 years ago

I don't see any indications of infinite looping in your error log. It looks like the app wasn't successfully connected to BitMEX in the first place, so there would be no orders to cancel. Can you connect via other methods (web API, api-connector, etc)?