From ae01afdd0f3bd9f63b3b39d8bb22ae8a3a38830b Mon Sep 17 00:00:00 2001 From: eSeR1805 Date: Wed, 4 May 2022 22:05:53 +0300 Subject: [PATCH] Models:Trade: Fix open_rate updates. --- freqtrade/persistence/models.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/freqtrade/persistence/models.py b/freqtrade/persistence/models.py index 4ed651e20..62f3d7d55 100644 --- a/freqtrade/persistence/models.py +++ b/freqtrade/persistence/models.py @@ -868,12 +868,11 @@ class LocalTrade(): def recalc_trade_from_orders(self): filled_orders_count = len(self.select_filled_orders(self.entry_side)) latest_order_in_trade = self.select_order(self.entry_side, True) - # No fills but newer order + # No fills - update open_rate in case order was replaced if (filled_orders_count == 0 and latest_order_in_trade is not None and - latest_order_in_trade.id is not None): - # after ensuring there is a populated order - if latest_order_in_trade.id > 1: - self.open_rate = latest_order_in_trade.price + latest_order_in_trade.price is not None): + # after ensuring there is a populated order price + self.open_rate = latest_order_in_trade.price # We need at least 2 entry orders for averaging amounts and rates. # TODO: this condition could probably be removed if filled_orders_count < 2: