reformatted check_handle_timedout

This commit is contained in:
Sam Germain 2021-10-18 00:45:48 -06:00
parent e4682b78c5
commit 053aecf111

View File

@ -1071,44 +1071,23 @@ class FreqtradeBot(LoggingMixin):
continue continue
fully_cancelled = self.update_trade_state(trade, trade.open_order_id, order) fully_cancelled = self.update_trade_state(trade, trade.open_order_id, order)
is_entering = order['side'] == trade.enter_side
not_closed = order['status'] == 'open' or fully_cancelled
side = trade.enter_side if is_entering else trade.exit_side
timed_out = self._check_timed_out(side, order)
time_method = 'check_sell_timeout' if order['side'] == 'sell' else 'check_buy_timeout'
if ( if not_closed and (fully_cancelled or timed_out or (
order['side'] == trade.enter_side and strategy_safe_wrapper(getattr(self.strategy, time_method), default_retval=False)(
(order['status'] == 'open' or fully_cancelled) and pair=trade.pair,
(fully_cancelled or trade=trade,
self._check_timed_out(trade.enter_side, order) or order=order
strategy_safe_wrapper( )
( )):
self.strategy.check_sell_timeout if is_entering:
if trade.is_short else self.handle_cancel_enter(trade, order, constants.CANCEL_REASON['TIMEOUT'])
self.strategy.check_buy_timeout else:
), self.handle_cancel_exit(trade, order, constants.CANCEL_REASON['TIMEOUT'])
default_retval=False
)(
pair=trade.pair,
trade=trade,
order=order
)
)
):
self.handle_cancel_enter(trade, order, constants.CANCEL_REASON['TIMEOUT'])
elif (
order['side'] == trade.exit_side and
(order['status'] == 'open' or fully_cancelled) and
(fully_cancelled or
self._check_timed_out(trade.exit_side, order) or
strategy_safe_wrapper(
self.strategy.check_sell_timeout,
default_retval=False
)(
pair=trade.pair,
trade=trade,
order=order
)
)
):
self.handle_cancel_exit(trade, order, constants.CANCEL_REASON['TIMEOUT'])
def cancel_all_open_orders(self) -> None: def cancel_all_open_orders(self) -> None:
""" """