Ensure comparisions align when closing a trade

This commit is contained in:
Matthias
2022-08-16 08:21:02 +02:00
parent e4b7bcaeab
commit 1dd56e35d5
2 changed files with 8 additions and 9 deletions

View File

@@ -875,13 +875,14 @@ class LocalTrade():
self.realized_profit = close_profit_abs
self.close_profit_abs = profit
if current_amount > ZERO:
current_amount_tr = amount_to_precision(float(current_amount),
self.amount_precision, self.precision_mode)
if current_amount_tr > 0.0:
# Trade is still open
# Leverage not updated, as we don't allow changing leverage through DCA at the moment.
self.open_rate = price_to_precision(float(current_stake / current_amount),
self.price_precision, self.precision_mode)
self.amount = amount_to_precision(float(current_amount),
self.amount_precision, self.precision_mode)
self.amount = current_amount_tr
self.stake_amount = float(current_stake) / (self.leverage or 1.0)
self.fee_open_cost = self.fee_open * float(current_stake)
self.recalc_open_trade_value()