provide cancel-reason to handle_cancel_order

This commit is contained in:
Matthias 2023-01-31 07:08:12 +01:00
parent 5a7008f377
commit a704c43402

View File

@ -355,7 +355,7 @@ class FreqtradeBot(LoggingMixin):
"Order is older than 5 days. Assuming order was fully cancelled.") "Order is older than 5 days. Assuming order was fully cancelled.")
fo = order.to_ccxt_object() fo = order.to_ccxt_object()
fo['status'] = 'canceled' fo['status'] = 'canceled'
self.handle_cancel_order(fo, order.trade) self.handle_cancel_order(fo, order.trade, constants.CANCEL_REASON['TIMEOUT'])
except ExchangeError as e: except ExchangeError as e:
@ -1253,11 +1253,11 @@ class FreqtradeBot(LoggingMixin):
if not_closed: if not_closed:
if fully_cancelled or (order_obj and self.strategy.ft_check_timed_out( if fully_cancelled or (order_obj and self.strategy.ft_check_timed_out(
trade, order_obj, datetime.now(timezone.utc))): trade, order_obj, datetime.now(timezone.utc))):
self.handle_cancel_order(order, trade) self.handle_cancel_order(order, trade, constants.CANCEL_REASON['TIMEOUT'])
else: else:
self.replace_order(order, order_obj, trade) self.replace_order(order, order_obj, trade)
def handle_cancel_order(self, order: Dict, trade: Trade) -> None: def handle_cancel_order(self, order: Dict, trade: Trade, reason: str) -> None:
""" """
Check if current analyzed order timed out and cancel if necessary. Check if current analyzed order timed out and cancel if necessary.
:param order: Order dict grabbed with exchange.fetch_order() :param order: Order dict grabbed with exchange.fetch_order()
@ -1265,10 +1265,10 @@ class FreqtradeBot(LoggingMixin):
:return: None :return: None
""" """
if order['side'] == trade.entry_side: if order['side'] == trade.entry_side:
self.handle_cancel_enter(trade, order, constants.CANCEL_REASON['TIMEOUT']) self.handle_cancel_enter(trade, order, reason)
else: else:
canceled = self.handle_cancel_exit( canceled = self.handle_cancel_exit(
trade, order, constants.CANCEL_REASON['TIMEOUT']) trade, order, reason)
canceled_count = trade.get_exit_order_count() canceled_count = trade.get_exit_order_count()
max_timeouts = self.config.get('unfilledtimeout', {}).get('exit_timeout_count', 0) max_timeouts = self.config.get('unfilledtimeout', {}).get('exit_timeout_count', 0)
if canceled and max_timeouts > 0 and canceled_count >= max_timeouts: if canceled and max_timeouts > 0 and canceled_count >= max_timeouts: