BitMEX / sample-market-maker

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

Amending failed. Waiting for order data to converge and retrying #194

Open maxness opened 5 years ago

maxness commented 5 years ago

Receiving this error on any order amendment (persistent with a fresh install):

INFO - bitmex - sending req to https://testnet.bitmex.com/api/v1/order/bulk: [...]

ERROR - bitmex - Unhandled Error: 400 Client Error: Bad Request for url: https://testnet.bitmex.com/api/v1/order/bulk: {"error":{"message":"Invalid ordStatus","name":"HTTPError"}} ERROR - bitmex - Endpoint was: PUT order/bulk: [...] (persistent with a fresh install)

WARNING - market_maker - Amending failed. Waiting for order data to converge and retrying.

Rate limits hit as this looped every 0.5s.

My attempts include:

Traceback (most recent call last): File "[...]env/lib/python3.5/site-packages/market_maker/market_maker.py", line 406, in converge_orders self.exchange.amend_bulk_orders(to_amend) File "[...]env/lib/python3.5/site-packages/market_maker/market_maker.py", line 188, in amend_bulk_orders return self.bitmex.amend_bulk_orders(orders) File "[...]env/lib/python3.5/site-packages/market_maker/bitmex.py", line 104, in wrapped return fn(self, *args, **kwargs) File "[...]env/lib/python3.5/site-packages/market_maker/bitmex.py", line 168, in amend_bulk_orders return self._curl_bitmex(path='order/bulk', postdict={'orders': orders}, verb='PUT', rethrow_errors=True) File "[...]env/lib/python3.5/site-packages/market_maker/bitmex.py", line 346, in _curl_bitmex exit_or_throw(e) File "[...]env/lib/python3.5/site-packages/market_maker/bitmex.py", line 245, in exit_or_throw raise e File "[...]env/lib/python3.5/site-packages/market_maker/bitmex.py", line 263, in _curl_bitmex response.raise_for_status() File "[...]env/lib/python3.5/site-packages/requests/models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://testnet.bitmex.com/api/v1/order/bulk

Other notes: slept for 12h; ignores filled orders, tries to amend them; new orders are placed without problem; no bugs until amending after fill or price change; not receiving "Ratelimited on current request. Sleeping, then trying again." or "Your ratelimit will reset at XX. Sleeping for 3 seconds."

maxness commented 5 years ago

I've been aborting to avoid further rate limitations/bans, but when left to run, the full output is as follows (NB. another fresh install, this time with python 3.7):

File "[...]env/lib/python3.7/site-packages/market_maker/bitmex.py", line 263, in _curl_bitmex response.raise_for_status() File "[...]env/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: https://testnet.bitmex.com/api/v1/order/bulk

... then,

File "[...]env/bin/marketmaker", line 11, in load_entry_point('bitmex-market-maker==1.5', 'console_scripts', 'marketmaker')() File "[...]env/lib/python3.7/site-packages/market_maker/init.py", line 22, in run market_maker.run() File "[...]env/lib/python3.7/site-packages/market_maker/market_maker.py", line 546, in run om.run_loop() File "[...]env/lib/python3.7/site-packages/market_maker/market_maker.py", line 515, in run_loop self.place_orders() # Creates desired orders and converges to existing orders File "[...]env/lib/python3.7/site-packages/market_maker/market_maker.py", line 325, in place_orders return self.converge_orders(buy_orders, sell_orders) File "[...]env/lib/python3.7/site-packages/market_maker/market_maker.py", line 402, in converge_orders return self.place_orders()

---"---

File "[...]env/lib/python3.7/site-packages/market_maker/market_maker.py", line 325, in place_orders return self.converge_orders(buy_orders, sell_orders) File "[...]env/lib/python3.7/site-packages/market_maker/market_maker.py", line 402, in converge_orders return self.place_orders() File "[...]env/lib/python3.7/site-packages/market_maker/market_maker.py", line 325, in place_orders return self.converge_orders(buy_orders, sell_orders) File "[...]env/lib/python3.7/site-packages/market_maker/market_maker.py", line 402, in converge_orders return self.place_orders() File "[...]env/lib/python3.7/site-packages/market_maker/market_maker.py", line 325, in place_orders return self.converge_orders(buy_orders, sell_orders) File "[...]env/lib/python3.7/site-packages/market_maker/market_maker.py", line 402, in converge_orders return self.place_orders() File "[...]env/lib/python3.7/site-packages/market_maker/market_maker.py", line 325, in place_orders return self.converge_orders(buy_orders, sell_orders) File "[...]env/lib/python3.7/site-packages/market_maker/market_maker.py", line 396, in converge_orders self.exchange.amend_bulk_orders(to_amend) File "[...]env/lib/python3.7/site-packages/market_maker/market_maker.py", line 188, in amend_bulk_orders return self.bitmex.amend_bulk_orders(orders) File "[...]env/lib/python3.7/site-packages/market_maker/bitmex.py", line 104, in wrapped return fn(self, *args, **kwargs) File "[...]env/lib/python3.7/site-packages/market_maker/bitmex.py", line 168, in amend_bulk_orders return self._curl_bitmex(path='order/bulk', postdict={'orders': orders}, verb='PUT', rethrow_errors=True) File "[...]env/lib/python3.7/site-packages/market_maker/bitmex.py", line 306, in _curl_bitmex return retry() File "[...]env/lib/python3.7/site-packages/market_maker/bitmex.py", line 252, in retry raise Exception("Max retries on %s (%s) hit, raising." % (path, json.dumps(postdict or ''))) Exception: Max retries on order/bulk ({"orders": [{"orderID": "86a4e7ac-eb47-4117-a0e8-327bc085a0b4", "orderQty": 30, "price": 8253.0, "side": "Sell"}, {"orderID": "c1c477b3-3174-5ac8-5aeb-263209489b62", "orderQty": 15, "price": 8250.0, "side": "Sell"}]}) hit, raising.