hummingbot / hummingbot

Open source software that helps you create and deploy high-frequency crypto trading bots
https://hummingbot.org
Apache License 2.0
7.73k stars 2.7k forks source link

Coinbase Pro - Orders getting stuck during network disconnection #4945

Closed rxlxrxsx closed 1 day ago

rxlxrxsx commented 2 years ago

Describe the bug When running a bot using the Coinbase Pro connector there are instances that the orders are left open in the exchange in the event that there's a network disconnection during the time of order creation.

2021-12-20 12:59:22,016 - 9306 - hummingbot.strategy.pure_market_making.pure_market_making - INFO - (ETH-USDT) Creating 1 bid orders at (Size, Price): ['0.005 ETH, 3886.33 USDT']
2021-12-20 12:59:22,018 - 9306 - hummingbot.strategy.pure_market_making.pure_market_making - INFO - (ETH-USDT) Creating 1 ask orders at (Size, Price): ['0.005 ETH, 3964.84 USDT']
2021-12-20 12:59:25,039 - 9306 - hummingbot.connector.exchange.coinbase_pro.coinbase_pro_exchange - WARNING - Could not fetch account updates on Coinbase Pro. Check API key and network connection.
2021-12-20 12:59:27,293 - 9306 - hummingbot.connector.exchange.coinbase_pro.coinbase_pro_exchange - INFO - Network status has changed to NetworkStatus.NOT_CONNECTED. Stopping networking...
2021-12-20 12:59:32,333 - 9306 - hummingbot.connector.exchange.coinbase_pro.coinbase_pro_exchange - NETWORK - Error submitting buy limit_maker order to Coinbase Pro for 0.00500000 ETH-USDT 3886.33.
Traceback (most recent call last):
  File "hummingbot/connector/exchange/coinbase_pro/coinbase_pro_exchange.pyx", line 717, in hummingbot.connector.exchange.coinbase_pro.coinbase_pro_exchange.CoinbaseProExchange.execute_buy
    order_result = await self.place_order(order_id, trading_pair, decimal_amount, True, order_type, decimal_price)
  File "hummingbot/connector/exchange/coinbase_pro/coinbase_pro_exchange.pyx", line 693, in place_order
    order_result = await self._api_request("post", path_url=path_url, data=data)
  File "hummingbot/connector/exchange/coinbase_pro/coinbase_pro_exchange.pyx", line 310, in _api_request
    async with client.request(http_method,
  File "/Users/reiniersalazar/opt/anaconda3/envs/hummingbot/lib/python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
    self._resp = await self._coro
  File "/Users/reiniersalazar/opt/anaconda3/envs/hummingbot/lib/python3.8/site-packages/aiohttp/client.py", line 544, in _request
    await resp.start(conn)
  File "/Users/reiniersalazar/opt/anaconda3/envs/hummingbot/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 905, in start
    self._continue = None
  File "/Users/reiniersalazar/opt/anaconda3/envs/hummingbot/lib/python3.8/site-packages/aiohttp/helpers.py", line 656, in __exit__
    raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError
2021-12-20 12:59:32,334 - 9306 - hummingbot.connector.exchange.coinbase_pro.coinbase_pro_exchange - WARNING - Failed to submit buy order to Coinbase Pro. Check API key and network connection.
2021-12-20 12:59:32,335 - 9306 - hummingbot.core.event.event_reporter - EVENT_LOG - {"timestamp": 1639976372.0, "order_id": "buy-ETH-USDT-1639976362017633", "order_type": "OrderType.LIMIT_MAKER", "event_name": "MarketOrderFailureEvent", "event_source": "coinbase_pro"}
2021-12-20 12:59:32,341 - 9306 - hummingbot.connector.exchange.coinbase_pro.coinbase_pro_exchange - NETWORK - Error submitting sell limit_maker order to Coinbase Pro for 0.00500000 ETH-USDT 3964.84.
Traceback (most recent call last):
  File "hummingbot/connector/exchange/coinbase_pro/coinbase_pro_exchange.pyx", line 781, in hummingbot.connector.exchange.coinbase_pro.coinbase_pro_exchange.CoinbaseProExchange.execute_sell
    order_result = await self.place_order(order_id, trading_pair, decimal_amount, False, order_type, decimal_price)
  File "hummingbot/connector/exchange/coinbase_pro/coinbase_pro_exchange.pyx", line 693, in place_order
    order_result = await self._api_request("post", path_url=path_url, data=data)
  File "hummingbot/connector/exchange/coinbase_pro/coinbase_pro_exchange.pyx", line 310, in _api_request
    async with client.request(http_method,
  File "/Users/reiniersalazar/opt/anaconda3/envs/hummingbot/lib/python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
    self._resp = await self._coro
  File "/Users/reiniersalazar/opt/anaconda3/envs/hummingbot/lib/python3.8/site-packages/aiohttp/client.py", line 544, in _request
    await resp.start(conn)
  File "/Users/reiniersalazar/opt/anaconda3/envs/hummingbot/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 905, in start
    self._continue = None
  File "/Users/reiniersalazar/opt/anaconda3/envs/hummingbot/lib/python3.8/site-packages/aiohttp/helpers.py", line 656, in __exit__
    raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError
Screen Shot 2021-12-20 at 1 09 04 PM

Steps To Reproduce

  1. Create and run a pure_mm bot using Coinbase Pro
  2. Disconnect from the internet during the time of order creation
  3. Wait for a few minutes and reconnect from the internet
  4. Bot will now place a new set of orders however the orders from after disconnecting is not detected by the bot
  5. Check the exchange website and you'll see that the orders are still open

Note: I wasn't able to take a screenshot from the client but I can confirm that for the first 10 seconds the "stuck" orders is showing on status before disappearing. The issue is also a bit difficult to reproduce so you may need to try it several times.

Release version development-1.0.0

Attachments Logs and config: coinbase.zip

cryptomaniax69 commented 2 years ago

I hit this bug before but I'm using google cloud server so I wasn't sure its the internet but yes you're right its hard to replicate cause it happens very rare.