diff --git a/octobot_trading/exchanges/connectors/ccxt/ccxt_connector.py b/octobot_trading/exchanges/connectors/ccxt/ccxt_connector.py index 86fe0e683..12b8c2f6c 100644 --- a/octobot_trading/exchanges/connectors/ccxt/ccxt_connector.py +++ b/octobot_trading/exchanges/connectors/ccxt/ccxt_connector.py @@ -664,7 +664,10 @@ async def cancel_order( ) if cancelled_order is None or personal_data.parse_is_cancelled(cancelled_order): return enums.OrderStatus.CANCELED - elif personal_data.parse_is_open(cancelled_order): + elif ( + personal_data.parse_is_open(cancelled_order) + or personal_data.parse_is_pending_cancel(cancelled_order) + ): return enums.OrderStatus.PENDING_CANCEL # cancel command worked but order is still existing and is not open or canceled. unhandled case # log error and consider it canceling. order states will manage the diff --git a/octobot_trading/personal_data/__init__.py b/octobot_trading/personal_data/__init__.py index cf83747fa..e2b5b9f9e 100644 --- a/octobot_trading/personal_data/__init__.py +++ b/octobot_trading/personal_data/__init__.py @@ -37,6 +37,7 @@ parse_raw_fees, parse_order_status, parse_is_cancelled, + parse_is_pending_cancel, parse_is_open, get_pnl_transaction_source_from_order, is_stop_order, @@ -253,6 +254,7 @@ "parse_raw_fees", "parse_order_status", "parse_is_cancelled", + "parse_is_pending_cancel", "parse_is_open", "get_pnl_transaction_source_from_order", "is_stop_order", diff --git a/octobot_trading/personal_data/orders/__init__.py b/octobot_trading/personal_data/orders/__init__.py index 74472a6f9..c1624344e 100644 --- a/octobot_trading/personal_data/orders/__init__.py +++ b/octobot_trading/personal_data/orders/__init__.py @@ -87,6 +87,7 @@ parse_raw_fees, parse_order_status, parse_is_cancelled, + parse_is_pending_cancel, parse_is_open, get_up_to_date_price, get_pre_order_data, @@ -160,6 +161,7 @@ "parse_raw_fees", "parse_order_status", "parse_is_cancelled", + "parse_is_pending_cancel", "parse_is_open", "get_up_to_date_price", "get_pre_order_data", diff --git a/octobot_trading/personal_data/orders/order_util.py b/octobot_trading/personal_data/orders/order_util.py index 34aa79add..eb6c701a3 100644 --- a/octobot_trading/personal_data/orders/order_util.py +++ b/octobot_trading/personal_data/orders/order_util.py @@ -395,6 +395,10 @@ def parse_is_cancelled(raw_order): return parse_order_status(raw_order) in {enums.OrderStatus.CANCELED, enums.OrderStatus.CLOSED} +def parse_is_pending_cancel(raw_order): + return parse_order_status(raw_order) is enums.OrderStatus.PENDING_CANCEL + + def parse_is_open(raw_order): return parse_order_status(raw_order) is enums.OrderStatus.OPEN