Partial exits should consider leveraged trades.

This commit is contained in:
Matthias
2023-09-07 18:26:56 +02:00
parent 95d8c45481
commit 227b194a88

View File

@@ -1529,7 +1529,8 @@ class FreqtradeBot(LoggingMixin):
# Cancelled orders may have the status of 'canceled' or 'closed'
if order['status'] not in constants.NON_OPEN_EXCHANGE_STATES:
filled_amt: float = order.get('filled', 0.0) or 0.0
filled_rem_stake = trade.stake_amount - filled_amt * trade.open_rate
# Filled val is in quote currency (after leverage)
filled_rem_stake = trade.stake_amount - (filled_amt * trade.open_rate / trade.leverage)
minstake = self.exchange.get_min_pair_stake_amount(
trade.pair, trade.open_rate, self.strategy.stoploss)
# Double-check remaining amount