From 73d1201ed8d5dde5b643c76bf2f4687018bd119a Mon Sep 17 00:00:00 2001 From: axel Date: Thu, 15 Jun 2023 13:37:36 -0400 Subject: [PATCH] start fixing test_handle_stoploss_on_exchange_trailing, add temp logs --- freqtrade/freqtradebot.py | 15 ++++++++++----- tests/test_freqtradebot.py | 4 +--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index e795d24ac..c444509c3 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -1236,11 +1236,16 @@ class FreqtradeBot(LoggingMixin): self.handle_protections(trade.pair, trade.trade_direction) return True - if trade.open_entry_or_exit_orders_count != 0 or not trade.is_open: - # Trade has an open Buy or Sell order, Stoploss-handling can't happen in this case - # as the Amount on the exchange is tied up in another trade. - # The trade can be closed already (sell-order fill confirmation came in this iteration) - return False + print("***************open_orders DEBUG***************") + print(f"trade.open_orders: {trade.open_orders}") + print(f"trade.open_orders_count: {trade.open_orders_count}") + print(f"trade.open_entry_or_exit_orders_count: {trade.open_entry_or_exit_orders_count}") + + # if trade.open_entry_or_exit_orders_count != 0 or not trade.is_open: + # Trade has an open Buy or Sell order, Stoploss-handling can't happen in this case + # as the Amount on the exchange is tied up in another trade. + # The trade can be closed already (sell-order fill confirmation came in this iteration) + # return False # If enter order is fulfilled but there is no stoploss, we add a stoploss on exchange if not stoploss_order: diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 69029a2da..0a26bc95b 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -1484,7 +1484,7 @@ def test_handle_sle_cancel_cant_recreate(mocker, default_conf_usdt, fee, caplog, trade = Trade.session.scalars(select(Trade)).first() assert trade.is_short == is_short trade.is_open = True - trade.open_order_id = None + # trade.open_order_id = None trade.stoploss_order_id = "100" trade.orders.append( Order( @@ -1659,7 +1659,6 @@ def test_handle_stoploss_on_exchange_trailing( trade = Trade.session.scalars(select(Trade)).first() trade.is_short = is_short trade.is_open = True - trade.open_order_id = None trade.stoploss_order_id = '100' trade.stoploss_last_update = dt_now() - timedelta(minutes=20) trade.orders.append( @@ -2324,7 +2323,6 @@ def test_update_trade_state_withorderdict( open_date=dt_now(), fee_open=fee.return_value, fee_close=fee.return_value, - open_order_id=order_id, is_open=True, leverage=1, is_short=is_short,