Merge pull request #9515 from stash86/bt-metrics

In partial exit, do full exit if remaining == 0
This commit is contained in:
Matthias
2023-12-30 16:39:46 +01:00
committed by GitHub
4 changed files with 39 additions and 26 deletions

View File

@@ -673,20 +673,13 @@ class FreqtradeBot(LoggingMixin):
amount = self.exchange.amount_to_contract_precision(
trade.pair,
abs(float(FtPrecise(stake_amount * trade.leverage) / FtPrecise(current_exit_rate))))
if amount > trade.amount:
# This is currently ineffective as remaining would become < min tradable
# Fixing this would require checking for 0.0 there -
# if we decide that this callback is allowed to "fully exit"
logger.info(
f"Adjusting amount to trade.amount as it is higher. {amount} > {trade.amount}")
amount = trade.amount
if amount == 0.0:
logger.info("Amount to exit is 0.0 due to exchange limits - not exiting.")
return
remaining = (trade.amount - amount) * current_exit_rate
if min_exit_stake and 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