From 478387531de6b6928977f2882b87067d1863e788 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 17 Dec 2024 06:48:47 +0100 Subject: [PATCH] feat: Updates for proxy coin functionalities --- freqtrade/rpc/rpc.py | 12 +++++++----- freqtrade/wallets.py | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 0e492be86..38cf044b9 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -682,9 +682,10 @@ class RPC: ) -> tuple[float, float]: est_stake = 0.0 est_bot_stake = 0.0 - if coin == stake_currency: + is_futures = self._config.get("trading_mode", TradingMode.SPOT) == TradingMode.FUTURES + if coin == self._freqtrade.exchange.get_proxy_coin(): est_stake = balance.total - if self._config.get("trading_mode", TradingMode.SPOT) != TradingMode.SPOT: + if is_futures: # in Futures, "total" includes the locked stake, and therefore all positions est_stake = balance.free est_bot_stake = amount @@ -694,7 +695,7 @@ class RPC: coin, stake_currency ) if rate: - est_stake = rate * balance.total + est_stake = rate * (balance.free if is_futures else balance.total) est_bot_stake = rate * amount return est_stake, est_bot_stake @@ -727,9 +728,10 @@ class RPC: continue trade = open_assets.get(coin, None) - is_bot_managed = coin == stake_currency or trade is not None + is_stake_currency = coin == self._freqtrade.exchange.get_proxy_coin() + is_bot_managed = is_stake_currency or trade is not None trade_amount = trade.amount if trade else 0 - if coin == stake_currency: + if is_stake_currency: trade_amount = self._freqtrade.wallets.get_available_stake_amount() try: diff --git a/freqtrade/wallets.py b/freqtrade/wallets.py index e0fb1f556..eea90ce33 100644 --- a/freqtrade/wallets.py +++ b/freqtrade/wallets.py @@ -41,7 +41,8 @@ class Wallets: self._wallets: dict[str, Wallet] = {} self._positions: dict[str, PositionWallet] = {} self._start_cap: dict[str, float] = {} - self._stake_currency = config["stake_currency"] + + self._stake_currency = self._exchange.get_proxy_coin() if isinstance(_start_cap := config["dry_run_wallet"], float | int): self._start_cap[self._stake_currency] = _start_cap