Models:Trade: Revert trade open_rate update.

This commit is contained in:
eSeR1805 2022-05-05 12:18:19 +03:00
parent ae01afdd0f
commit 25c74e26d1
No known key found for this signature in database
GPG Key ID: BA53686259B46936

View File

@ -866,16 +866,10 @@ class LocalTrade():
return float(f"{profit_ratio:.8f}") return float(f"{profit_ratio:.8f}")
def recalc_trade_from_orders(self): 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 - 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.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. # We need at least 2 entry orders for averaging amounts and rates.
# TODO: this condition could probably be removed # TODO: this condition could probably be removed
if filled_orders_count < 2: if len(self.select_filled_orders(self.entry_side)) < 2:
self.stake_amount = self.amount * self.open_rate / self.leverage self.stake_amount = self.amount * self.open_rate / self.leverage
# Just in case, still recalc open trade value # Just in case, still recalc open trade value