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

Exch errors #1403

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Trading/Exchange/binance/binance_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ class Binance(exchanges.RestExchange):
# Binance ex: InvalidOrder binance {"code":-2010,"msg":"This symbol is not permitted for this account."}
("symbol", "not permitted", "for this account"),
]
# text content of errors due to a closed position on the exchange. Relevant for reduce-only orders
EXCHANGE_CLOSED_POSITION_ERRORS: typing.List[typing.Iterable[str]] = [
# doesn't seem to happen on binance
]
# text content of errors due to an order that would immediately trigger if created. Relevant for stop losses
EXCHANGE_ORDER_IMMEDIATELY_TRIGGER_ERRORS: typing.List[typing.Iterable[str]] = [
# binance {"code":-2021,"msg":"Order would immediately trigger."}
("order would immediately trigger", )
]

BUY_STR = "BUY"
SELL_STR = "SELL"
Expand Down
9 changes: 9 additions & 0 deletions Trading/Exchange/kucoin/kucoin_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ class Kucoin(exchanges.RestExchange):
# 'kucoin The order does not exist.'
("order does not exist",),
]
# text content of errors due to a closed position on the exchange. Relevant for reduce-only orders
EXCHANGE_CLOSED_POSITION_ERRORS: typing.List[typing.Iterable[str]] = [
# 'kucoinfutures No open positions to close.'
("No open positions to close", )
]
# text content of errors due to an order that would immediately trigger if created. Relevant for stop losses
EXCHANGE_ORDER_IMMEDIATELY_TRIGGER_ERRORS: typing.List[typing.Iterable[str]] = [
# doesn't seem to happen on kucoin
]

DEFAULT_BALANCE_CURRENCIES_TO_FETCH = ["USDT"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,11 @@ async def _chain_order(self, order_description, created_orders, ignored_orders,
base_order, chained_order, chained_order.update_with_triggering_order_fees, False
)
if base_order.state is not None and base_order.is_filled() and chained_order.should_be_created():
await personal_data.create_as_chained_order(chained_order)
try:
await personal_data.create_as_chained_order(chained_order)
except errors.OctoBotExchangeError as err:
# todo later on: handle locale error if necessary
self.logger.error(f"Failed to create chained order: {chained_order}: {err}")
return 1
return 0

Expand Down
Loading