Add test for Generic behavior

This commit is contained in:
Matthias
2022-05-27 07:02:15 +02:00
parent 7c464f3237
commit 2b5530217d
2 changed files with 67 additions and 4 deletions

View File

@@ -552,13 +552,19 @@ class FreqtradeBot(LoggingMixin):
if stake_amount is not None and stake_amount < 0.0:
# We should decrease our position
amount = abs(float(Decimal(stake_amount) / Decimal(current_exit_rate)))
if (trade.amount - amount) * current_exit_rate < min_exit_stake:
logger.info('Remaining amount would be too small.')
return
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
remaining = (trade.amount - amount) * current_exit_rate
if remaining < min_exit_stake:
logger.info(f'Remaining amount of {remaining} would be too small.')
return
self.execute_trade_exit(trade, current_exit_rate, exit_check=ExitCheckTuple(
exit_type=ExitType.PARTIAL_EXIT), sub_trade_amt=amount)