From adbf1b5e6f3db17d082efdfdc45fa8fab2d96b05 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 25 Apr 2024 11:46:43 +0200 Subject: [PATCH] Adjust trade amount by 2% if trade recovery remains above the trade amount closes #10002 --- freqtrade/freqtradebot.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index a7e35838b..244095ca7 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -494,7 +494,23 @@ class FreqtradeBot(LoggingMixin): send_msg=prev_trade_state != trade.is_open) else: trade.exit_reason = prev_exit_reason - + total = self.wallets.get_total(trade.base_currency) + if total < trade.amount: + if total > trade.amount * 0.98: + logger.warning( + f"{trade} has a total of {trade.amount} {trade.base_currency}, " + f"but the Wallet shows a total of {total} {trade.base_currency}. " + f"Adjusting trade amount to {total}." + "This may however lead to further issues." + ) + trade.amount = total + else: + logger.warning( + f"{trade} has a total of {trade.amount} {trade.base_currency}, " + f"but the Wallet shows a total of {total} {trade.base_currency}. " + "Refusing to adjust as the difference is too large." + "This may however lead to further issues." + ) if prev_trade_amount != trade.amount: # Cancel stoploss on exchange if the amount changed trade = self.cancel_stoploss_on_exchange(trade)