Skip to content

Commit b75eb85

Browse files
committed
fix: Calculate liquidation price only once the initial order filled
closes freqtrade#11318
1 parent dbb9f22 commit b75eb85

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

freqtrade/leverage/liquidation_price.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,20 @@ def update_liquidation_prices(
3535

3636
open_trades: list[Trade] = Trade.get_open_trades()
3737
for t in open_trades:
38-
# TODO: This should be done in a batch update
39-
t.set_liquidation_price(
40-
exchange.get_liquidation_price(
41-
pair=t.pair,
42-
open_rate=t.open_rate,
43-
is_short=t.is_short,
44-
amount=t.amount,
45-
stake_amount=t.stake_amount,
46-
leverage=t.leverage,
47-
wallet_balance=total_wallet_stake,
48-
open_trades=open_trades,
38+
if t.has_open_position:
39+
# TODO: This should be done in a batch update
40+
t.set_liquidation_price(
41+
exchange.get_liquidation_price(
42+
pair=t.pair,
43+
open_rate=t.open_rate,
44+
is_short=t.is_short,
45+
amount=t.amount,
46+
stake_amount=t.stake_amount,
47+
leverage=t.leverage,
48+
wallet_balance=total_wallet_stake,
49+
open_trades=open_trades,
50+
)
4951
)
50-
)
5152
elif trade:
5253
trade.set_liquidation_price(
5354
exchange.get_liquidation_price(

0 commit comments

Comments
 (0)