Skip orders when correlated trade was deleted.

closes #8107
This commit is contained in:
Matthias 2023-02-04 08:39:01 +01:00
parent 7991124794
commit 55850a5ccd

View File

@ -344,7 +344,15 @@ class FreqtradeBot(LoggingMixin):
try: try:
fo = self.exchange.fetch_order_or_stoploss_order(order.order_id, order.ft_pair, fo = self.exchange.fetch_order_or_stoploss_order(order.order_id, order.ft_pair,
order.ft_order_side == 'stoploss') order.ft_order_side == 'stoploss')
if not order.trade:
# This should not happen, but it does if trades were deleted manually.
# This can only incur on sqlite, which doesn't enforce foreign constraints.
logger.warning(
f"Order {order.order_id} has no trade attached. "
"This may suggest a database corruption. "
f"The expected trade ID is {order.ft_trade_id}. Ignoring this order."
)
continue
self.update_trade_state(order.trade, order.order_id, fo, self.update_trade_state(order.trade, order.order_id, fo,
stoploss_order=(order.ft_order_side == 'stoploss')) stoploss_order=(order.ft_order_side == 'stoploss'))