Merge pull request #2771 from freqtrade/fix/2770

Fix bad bug in safe_sell_amount
This commit is contained in:
hroff-1902 2020-01-15 23:33:04 +03:00 committed by GitHub
commit a20f502159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -903,8 +903,8 @@ class FreqtradeBot:
:raise: DependencyException: if available balance is not within 2% of the available amount.
"""
wallet_amount = self.wallets.get_free(pair.split('/')[0])
logger.debug(f"{pair} - Wallet: {wallet_amount} - Trade-amount: {amount}")
if wallet_amount > amount:
logger.info(f"Selling {pair} - Wallet: {wallet_amount} - Trade-amount: {amount}")
if wallet_amount >= amount:
return amount
elif wallet_amount > amount * 0.98:
logger.info(f"{pair} - Falling back to wallet-amount.")

View File

@ -2764,6 +2764,9 @@ def test__safe_sell_amount(default_conf, fee, caplog, mocker):
assert freqtrade._safe_sell_amount(trade.pair, trade.amount) == amount_wallet
assert log_has_re(r'.*Falling back to wallet-amount.', caplog)
caplog.clear()
assert freqtrade._safe_sell_amount(trade.pair, amount_wallet) == amount_wallet
assert not log_has_re(r'.*Falling back to wallet-amount.', caplog)
def test__safe_sell_amount_error(default_conf, fee, caplog, mocker):