Codaone / DEXBot

Trading Bot for the BitShares Decentralized Exchange
Other
250 stars 129 forks source link

Worker disabled due to KeyError: 'orderid' #782

Closed abitmore closed 2 years ago

abitmore commented 3 years ago

Error logs:

2021-12-02 14:25:00,152 - mm.xusdt-xhive.abot-stag using account mm.xusdt-xhive.abot on XBTSX.HIVE/XBTSX.USDT - INFO - Placing a buy order with 246.927378 XBTSX.USDT @ 2.03085904
2021-12-02 14:25:03,352 - mm.xusdt-xhive.abot-stag using account mm.xusdt-xhive.abot on XBTSX.HIVE/XBTSX.USDT - ERROR - in ontick()
Traceback (most recent call last):
  File "/home/ubuntu/dexbot/dexbot/worker.py", line 131, in on_block
    self.workers[worker_name].ontick(data)
  File "/home/ubuntu/opt/python-3.9.1/lib/python3.9/site-packages/events/events.py", line 95, in __call__
    f(*a, **kw)
  File "/home/ubuntu/dexbot/dexbot/strategies/staggered_orders.py", line 2249, in tick
    self.maintain_strategy()
  File "/home/ubuntu/dexbot/dexbot/decorators.py", line 21, in wrapper
    func(self, *args, **kwargs)
  File "/home/ubuntu/dexbot/dexbot/strategies/staggered_orders.py", line 173, in maintain_strategy
    self.check_operational_depth(self.real_buy_orders, self.virtual_buy_orders)
  File "/home/ubuntu/dexbot/dexbot/strategies/staggered_orders.py", line 616, in check_operational_depth
    self.replace_virtual_order_with_real(virtual_orders[i])
  File "/home/ubuntu/dexbot/dexbot/strategies/staggered_orders.py", line 669, in replace_virtual_order_with_real
    new_order = self.place_market_buy_order(quote_amount, price, returnOrderId=True)
  File "/home/ubuntu/dexbot/dexbot/orderengines/bitshares_engine.py", line 607, in place_market_buy_order
    buy_order = self.get_order(buy_transaction['orderid'], return_none=return_none)
KeyError: 'orderid'
2021-12-02 14:25:07,031 - mm.xusdt-xhive.abot-stag using account mm.xusdt-xhive.abot on XBTSX.HIVE/XBTSX.USDT - ERROR - Worker "mm.xusdt-xhive.abot-stag" is disabled
2021-12-02 14:58:18,375 - mm.xusdt-xhive.abot-stag using account mm.xusdt-xhive.abot on XBTSX.HIVE/XBTSX.USDT - ERROR - in ontick()
Traceback (most recent call last):
  File "/home/ubuntu/dexbot/dexbot/worker.py", line 131, in on_block
    self.workers[worker_name].ontick(data)
  File "/home/ubuntu/opt/python-3.9.1/lib/python3.9/site-packages/events/events.py", line 95, in __call__
    f(*a, **kw)
  File "/home/ubuntu/dexbot/dexbot/strategies/staggered_orders.py", line 2249, in tick
    self.maintain_strategy()
  File "/home/ubuntu/dexbot/dexbot/decorators.py", line 21, in wrapper
    func(self, *args, **kwargs)
  File "/home/ubuntu/dexbot/dexbot/strategies/staggered_orders.py", line 174, in maintain_strategy
    self.check_operational_depth(self.real_sell_orders, self.virtual_sell_orders)
  File "/home/ubuntu/dexbot/dexbot/strategies/staggered_orders.py", line 616, in check_operational_depth
    self.replace_virtual_order_with_real(virtual_orders[i])
  File "/home/ubuntu/dexbot/dexbot/strategies/staggered_orders.py", line 678, in replace_virtual_order_with_real
    new_order = self.place_market_sell_order(quote_amount, price, returnOrderId=True)
  File "/home/ubuntu/dexbot/dexbot/orderengines/bitshares_engine.py", line 655, in place_market_sell_order
    sell_transaction = self.retry_action(
  File "/home/ubuntu/dexbot/dexbot/orderengines/bitshares_engine.py", line 699, in retry_action
    return action(*args, **kwargs)
  File "/home/ubuntu/opt/python-3.9.1/lib/python3.9/site-packages/bitshares/market.py", line 641, in sell
    tx["orderid"] = tx["operation_results"][0][1]
IndexError: list index out of range

It is likely caused by a change in BitShares 6.0 (Mekong) update:

Description Issue Pull Request
The get_block API will return an empty operation_results field for blocks produced by nodes with version 6.0.0 or higher. The operation results can still be retrieved via get_account_history and related APIs. - 2475
abitmore commented 3 years ago

Update: It seems to be an issue about the broadcast_transaction_with_callback API, which has been fixed by https://github.com/bitshares/bitshares-core/pull/2528. The solution is to run dexbot with BitShares 6.0 API nodes. Will close this issue when confirmed.