Skip to content

Commit

Permalink
[CCXT] fix pending cancel error
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDSM committed Nov 28, 2024
1 parent af674d1 commit 6eeb1c6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion octobot_trading/exchanges/connectors/ccxt/ccxt_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions octobot_trading/personal_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions octobot_trading/personal_data/orders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions octobot_trading/personal_data/orders/order_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6eeb1c6

Please sign in to comment.