Fix problem with FTX
where cancelled orders are "cancelled", not "canceled"
This commit is contained in:
parent
61ec7a309b
commit
99583bbd0c
@ -1053,7 +1053,8 @@ class Exchange:
|
||||
:param order: Order dict as returned from fetch_order()
|
||||
:return: True if order has been cancelled without being filled, False otherwise.
|
||||
"""
|
||||
return order.get('status') in ('closed', 'canceled') and order.get('filled') == 0.0
|
||||
return (order.get('status') in ('closed', 'canceled', 'cancelled')
|
||||
and order.get('filled') == 0.0)
|
||||
|
||||
@retrier
|
||||
def cancel_order(self, order_id: str, pair: str) -> Dict:
|
||||
|
@ -1023,13 +1023,13 @@ class FreqtradeBot(LoggingMixin):
|
||||
was_trade_fully_canceled = False
|
||||
|
||||
# Cancelled orders may have the status of 'canceled' or 'closed'
|
||||
if order['status'] not in ('canceled', 'closed'):
|
||||
if order['status'] not in ('cancelled', 'canceled', 'closed'):
|
||||
corder = self.exchange.cancel_order_with_result(trade.open_order_id, trade.pair,
|
||||
trade.amount)
|
||||
# Avoid race condition where the order could not be cancelled coz its already filled.
|
||||
# Simply bailing here is the only safe way - as this order will then be
|
||||
# handled in the next iteration.
|
||||
if corder.get('status') not in ('canceled', 'closed'):
|
||||
if corder.get('status') not in ('cancelled', 'canceled', 'closed'):
|
||||
logger.warning(f"Order {trade.open_order_id} for {trade.pair} not cancelled.")
|
||||
return False
|
||||
else:
|
||||
|
@ -425,7 +425,7 @@ class Trade(_DECL_BASE):
|
||||
self.close_rate_requested = self.stop_loss
|
||||
if self.is_open:
|
||||
logger.info(f'{order_type.upper()} is hit for {self}.')
|
||||
self.close(order['average'])
|
||||
self.close(safe_value_fallback(order, 'average', 'price'))
|
||||
else:
|
||||
raise ValueError(f'Unknown order type: {order_type}')
|
||||
cleanup_db()
|
||||
|
Loading…
Reference in New Issue
Block a user