Simplify handle_cancel_exit
This commit is contained in:
parent
39c651e40c
commit
59d2ff3ffa
@ -1460,32 +1460,32 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
co = self.exchange.cancel_order_with_result(order['id'], trade.pair,
|
order = self.exchange.cancel_order_with_result(order['id'], trade.pair,
|
||||||
trade.amount)
|
trade.amount)
|
||||||
except InvalidOrderException:
|
except InvalidOrderException:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"Could not cancel {trade.exit_side} order {trade.open_order_id}")
|
f"Could not cancel {trade.exit_side} order {trade.open_order_id}")
|
||||||
return False
|
return False
|
||||||
trade.close_rate = None
|
|
||||||
trade.close_rate_requested = None
|
|
||||||
# Set exit_reason for fill message
|
# Set exit_reason for fill message
|
||||||
exit_reason_prev = trade.exit_reason
|
exit_reason_prev = trade.exit_reason
|
||||||
trade.exit_reason = trade.exit_reason + f", {reason}" if trade.exit_reason else reason
|
trade.exit_reason = trade.exit_reason + f", {reason}" if trade.exit_reason else reason
|
||||||
self.update_trade_state(trade, trade.open_order_id, co)
|
|
||||||
# Order might be filled above in odd timing issues.
|
# Order might be filled above in odd timing issues.
|
||||||
if co.get('status') in ('canceled', 'cancelled'):
|
if order.get('status') in ('canceled', 'cancelled'):
|
||||||
trade.exit_reason = None
|
trade.exit_reason = None
|
||||||
trade.open_order_id = None
|
|
||||||
else:
|
else:
|
||||||
trade.exit_reason = exit_reason_prev
|
trade.exit_reason = exit_reason_prev
|
||||||
|
|
||||||
logger.info(f'{trade.exit_side.capitalize()} order {reason} for {trade}.')
|
|
||||||
cancelled = True
|
cancelled = True
|
||||||
else:
|
else:
|
||||||
reason = constants.CANCEL_REASON['CANCELLED_ON_EXCHANGE']
|
reason = constants.CANCEL_REASON['CANCELLED_ON_EXCHANGE']
|
||||||
logger.info(f'{trade.exit_side.capitalize()} order {reason} for {trade}.')
|
trade.exit_reason = None
|
||||||
|
|
||||||
self.update_trade_state(trade, trade.open_order_id, order)
|
self.update_trade_state(trade, trade.open_order_id, order)
|
||||||
|
|
||||||
|
logger.info(f'{trade.exit_side.capitalize()} order {reason} for {trade}.')
|
||||||
trade.open_order_id = None
|
trade.open_order_id = None
|
||||||
|
trade.close_rate = None
|
||||||
|
trade.close_rate_requested = None
|
||||||
|
|
||||||
self._notify_exit_cancel(
|
self._notify_exit_cancel(
|
||||||
trade,
|
trade,
|
||||||
|
Loading…
Reference in New Issue
Block a user