From b75eb85e66413bef9ce7dc5f1ee50616b27f07ef Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 5 Feb 2025 18:13:52 +0100 Subject: [PATCH] fix: Calculate liquidation price only once the initial order filled closes #11318 --- freqtrade/leverage/liquidation_price.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/freqtrade/leverage/liquidation_price.py b/freqtrade/leverage/liquidation_price.py index 5440da64a..af34f43fd 100644 --- a/freqtrade/leverage/liquidation_price.py +++ b/freqtrade/leverage/liquidation_price.py @@ -35,19 +35,20 @@ def update_liquidation_prices( open_trades: list[Trade] = Trade.get_open_trades() for t in open_trades: - # TODO: This should be done in a batch update - t.set_liquidation_price( - exchange.get_liquidation_price( - pair=t.pair, - open_rate=t.open_rate, - is_short=t.is_short, - amount=t.amount, - stake_amount=t.stake_amount, - leverage=t.leverage, - wallet_balance=total_wallet_stake, - open_trades=open_trades, + if t.has_open_position: + # TODO: This should be done in a batch update + t.set_liquidation_price( + exchange.get_liquidation_price( + pair=t.pair, + open_rate=t.open_rate, + is_short=t.is_short, + amount=t.amount, + stake_amount=t.stake_amount, + leverage=t.leverage, + wallet_balance=total_wallet_stake, + open_trades=open_trades, + ) ) - ) elif trade: trade.set_liquidation_price( exchange.get_liquidation_price(