From 9e2e60e7ad6c5b809598b51fdc4c3b4fb3d0189e Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 14 Dec 2023 20:34:58 +0100 Subject: [PATCH] Correct conditions for remaining stake checking --- freqtrade/freqtradebot.py | 2 +- freqtrade/optimize/backtesting.py | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index beb89251b..3a20bfbbe 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -685,7 +685,7 @@ class FreqtradeBot(LoggingMixin): return remaining = (trade.amount - amount) * current_exit_rate - if min_exit_stake and (0 < remaining < min_exit_stake): + if min_exit_stake and remaining != 0 and remaining < min_exit_stake: logger.info(f"Remaining amount of {remaining} would be smaller " f"than the minimum of {min_exit_stake}.") return diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index ce4c1a098..791317373 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -568,11 +568,8 @@ class Backtesting: self.precision_mode, trade.contract_size) if amount == 0.0: return trade - if amount > trade.amount: - # This is currently ineffective as remaining would become < min tradable - amount = trade.amount remaining = (trade.amount - amount) * current_rate - if 0 < remaining < min_stake: + if remaining != 0 and remaining < min_stake: # Remaining stake is too low to be sold. return trade exit_ = ExitCheckTuple(ExitType.PARTIAL_EXIT)