Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kucoin - Order canceled and filled at the same time causes failed to cancel, KeyError: 'data' #6970

Closed
rapcmia opened this issue Apr 15, 2024 · 0 comments

Comments

@rapcmia
Copy link
Contributor

rapcmia commented Apr 15, 2024

Describe the bug

When testing xemm script on development using kucoin as maker exchange, there are instances of the order is successfully placed and created however got canceled and filled at the same time as well. This causes failed to cancel error for the connector

# creating buy order BLMUT615ea97d6f53bff34e4fdb834401cc56895
2024-04-12 18:39:34,240 - 865872 - hummingbot.strategy.script_strategy_base - INFO - Creating LOOM-USDT buy order: price: 0.08122478155256393830782630581 amount: 20.
2024-04-12 18:39:34,241 - 865872 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - INFO - Created maker order BLMUT615ea97d6f53bff34e4fdb834401cc56895 at price 0.08122478155256393830782630581.
2024-04-12 18:39:34,403 - 865872 - hummingbot.connector.client_order_tracker - INFO - Created LIMIT BUY order BLMUT615ea97d6f53bff34e4fdb834401cc56895 for 20.0000 LOOM-USDT.
2024-04-12 18:39:34,403 - 865872 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - INFO - Maker order BLMUT615ea97d6f53bff34e4fdb834401cc56895 created.
2024-04-12 18:39:34,420 - 865872 - hummingbot.core.event.event_reporter - EVENT_LOG - {"timestamp": 1712947173.0, "type": "OrderType.LIMIT", "trading_pair": "LOOM-USDT", "amount": "20.0000", "price": "0.08122", "order_id": "BLMUT615ea97d6f53bff34e4fdb834401cc56895", "creation_timestamp": 1712947173.0, "exchange_order_id": "66197fe61e021f0007a8dc39", "leverage": 1, "position": "NIL", "event_name": "BuyOrderCreatedEvent", "event_source": "kucoin"}
2024-04-12 18:39:35,740 - 865872 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
2024-04-12 18:39:36,768 - 865872 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
2024-04-12 18:39:37,868 - 865872 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.
2024-04-12 18:39:39,119 - 865872 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - ERROR - Not enough budget to open position.

# order canceled and filled 
2024-04-12 18:39:39,141 - 865872 - hummingbot.smart_components.executors.xemm_executor.xemm_executor - INFO - Trade profitability -0.000887787660954782441060411849 is below minimum profitability. Cancelling order.
2024-04-12 18:39:39,142 - 865872 - hummingbot.strategy.script_strategy_base - INFO - (LOOM-USDT) Canceling the limit order BLMUT615ea97d6f53bff34e4fdb834401cc56895. [clock=2024-04-12 18:39:38+00:00]
2024-04-12 18:39:39,145 - 865872 - hummingbot.connector.client_order_tracker - INFO - The BUY order BLMUT615ea97d6f53bff34e4fdb834401cc56895 amounting to 20/20.0000 LOOM has been filled.
2024-04-12 18:39:39,171 - 865872 - hummingbot.core.event.event_reporter - EVENT_LOG - {"timestamp": 1712947178.0, "order_id": "BLMUT615ea97d6f53bff34e4fdb834401cc56895", "trading_pair": "LOOM-USDT", "trade_type": "TradeType.BUY", "order_type": "OrderType.LIMIT", "price": "0.08122", "amount": "20", "trade_fee": {"percent": "0.001", "percent_token": null, "flat_fees": []}, "exchange_trade_id": "9597633095927809", "exchange_order_id": "66197fe61e021f0007a8dc39", "leverage": 1, "position": "NIL", "event_name": "OrderFilledEvent", "event_source": "kucoin"}

2024-04-12 18:39:39,269 - 865872 - hummingbot.core.event.event_reporter - EVENT_LOG - {"timestamp": 1712947178.0, "order_id": "BLMUT615ea97d6f53bff34e4fdb834401cc56895", "base_asset": "LOOM", "quote_asset": "USDT", "base_asset_amount": "20", "quote_asset_amount": "1.62440", "order_type": "OrderType.LIMIT", "exchange_order_id": "66197fe61e021f0007a8dc39", "event_name": "BuyOrderCompletedEvent", "event_source": "kucoin"}
2024-04-12 18:39:39,269 - 865872 - hummingbot.connector.client_order_tracker - INFO - BUY order BLMUT615ea97d6f53bff34e4fdb834401cc56895 completely filled.
2024-04-12 18:39:39,400 - 865872 - hummingbot.connector.exchange.kucoin.kucoin_exchange.KucoinExchange - ERROR - Failed to cancel order BLMUT615ea97d6f53bff34e4fdb834401cc56895
Traceback (most recent call last):
  File "/home/ralph/github/hummingbot/6946/hummingbot/connector/exchange_py_base.py", line 520, in _execute_order_cancel
    cancelled = await self._execute_order_cancel_and_process_update(order=order)
  File "/home/ralph/github/hummingbot/6946/hummingbot/connector/exchange_py_base.py", line 540, in _execute_order_cancel_and_process_update
    cancelled = await self._place_cancel(order.client_order_id, order)
  File "/home/ralph/github/hummingbot/6946/hummingbot/connector/exchange/kucoin/kucoin_exchange.py", line 231, in _place_cancel
    if tracked_order.exchange_order_id in cancel_result["data"].get("cancelledOrderIds", []):
KeyError: 'data'
  • Placed buy market limit order
    • order_id and exchange_order_id available
    • order got filled at 2024-04-12 18:39:39,145 however at the same time the cancel order event is triggered
      • buy order filled completed and got a failed to cancel error KeyError: 'data'
    • Check data and exchange trade history for order BLMUT615ea97d6f53bff34e4fdb834401cc56895
      • Timestamp 1712947173.0, converted to Saturday, April 13, 2024 2:39:33 AM [GMT+08:00](https://www.epochconverter.com/timezones?q=1712947173)
      • Trade history
        image
      • CSV and sqlite
        image
        image

Steps to reproduce

  1. Setup the xemm script on this PR Feat/xemm executor #6946
  2. Run the script for couple of hours and monitor logs
  3. Observe this sequence when maker limit order is placed, created, canceled then filled

Release version

dev-1.27.0

Type of installation

Source

Attach required files

0412024.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant