From 8e6151fe65d1a398b504b0cf5a4d3cfb266c1369 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 22 Sep 2024 13:17:27 +0200 Subject: [PATCH] fix: properly consider open order values as "tied up" stake. --- freqtrade/wallets.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/freqtrade/wallets.py b/freqtrade/wallets.py index f888ef92e..e67bdd79e 100644 --- a/freqtrade/wallets.py +++ b/freqtrade/wallets.py @@ -99,11 +99,21 @@ class Wallets: used_stake = 0.0 if self._config.get("trading_mode", "spot") != TradingMode.FUTURES: - current_stake = self.start_cap + tot_profit - tot_in_trades - total_stake = current_stake for trade in open_trades: curr = self._exchange.get_pair_base_currency(trade.pair) - _wallets[curr] = Wallet(curr, trade.amount, 0, trade.amount) + used_stake += sum( + o.stake_amount for o in trade.open_orders if o.ft_order_side == trade.entry_side + ) + pending = sum( + o.amount + for o in trade.open_orders + if o.amount and o.ft_order_side == trade.exit_side + ) + + _wallets[curr] = Wallet(curr, trade.amount - pending, pending, trade.amount) + + current_stake = self.start_cap + tot_profit - tot_in_trades + total_stake = current_stake + used_stake else: tot_in_trades = 0 for position in open_trades: