[Bug] XEMM V2 Executor: Cancel/Fill Race Condition causes missing Taker hedge order (Naked Position)
Describe the bug
I encountered a critical issue while running the xemm_multiple_levels (V2 controller) strategy. A race condition between order cancellation and execution caused the bot to completely skip the taker hedge order, resulting in a naked position.
Environment:
Strategy: v2_with_controllers (xemm_multiple_levels)
Maker Connector: mexc (Spot)
Taker Connector: kucoin (Spot)
Trading Pair: DOT-USDT
Actual Behavior:
The bot detected that the expected profitability dropped below min_profitability and initiated an order cancellation (11:50:02,960).
Almost simultaneously (11:50:02,975), the order was completely filled on MEXC before the cancel request reached the exchange.
The MEXC API returned a 400 error for the DELETE request: {"msg":"Order filled.","code":-2011} (11:50:03,024).
The Bug: Due to this API exception during the cancellation state, the xemm_executor seemed to break its state machine. It caught the BuyOrderCompletedEvent, but it failed to execute the Taker hedge order on KuCoin. Instead, it just proceeded to create the next maker order, leaving me with an unhedged/naked position.
Expected Behavior: Even if the API cancel request fails because the order is already filled, the executor should properly handle this exception, recognize the filled status, and still trigger the Taker hedge order to protect the position.
Steps to reproduce
- Just initiate a xemm bot, it'll ocationally hapen Strategy: v2_with_controllers (xemm_multiple_levels) Maker Connector: mexc (Spot) Taker Connector: kucoin (Spot)
- xx
- xx
Release version
hummingbot:latest (2026/2/25)
Type of installation
Docker
Attach required files
Source: hummingbot/hummingbot