Force special exit reason for "recovered" exits

This commit is contained in:
Matthias 2023-04-25 18:09:46 +02:00
parent 24cab00479
commit f2696c9609
2 changed files with 6 additions and 1 deletions

View File

@ -15,6 +15,7 @@ class ExitType(Enum):
EMERGENCY_EXIT = "emergency_exit"
CUSTOM_EXIT = "custom_exit"
PARTIAL_EXIT = "partial_exit"
SOLD_ON_EXCHANGE = "sold_on_exchange"
NONE = ""
def __str__(self):

View File

@ -470,13 +470,17 @@ class FreqtradeBot(LoggingMixin):
trade.orders.append(order_obj)
# TODO: how do we handle open_order_id ...
Trade.commit()
prev_exit_reason = trade.exit_reason
trade.exit_reason = ExitType.SOLD_ON_EXCHANGE.value
self.update_trade_state(trade, order['id'], order)
logger.info(f"handled order {order['id']}")
if not trade.is_open:
# Trade was just closed
trade.close_date = order_obj.order_filled_date
Trade.commit()
continue
break
else:
trade.exit_reason = prev_exit_reason
except ExchangeError:
logger.warning("Error finding onexchange order")