From 455838648da4dab24c1d5193764c880542faf406 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 3 Jan 2020 10:41:10 +0100 Subject: [PATCH] Apply get_available_balance logic to regular trades, too --- freqtrade/freqtradebot.py | 2 +- tests/test_freqtradebot.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index bdba74215..aa47adfd4 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -305,7 +305,7 @@ class FreqtradeBot: for the stake currency :return: float: Stake amount """ - available_amount = self.wallets.get_free(self.config['stake_currency']) + available_amount = self._get_available_stake_amount() if stake_amount is not None and available_amount < stake_amount: raise DependencyException( diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 9ca54d003..a2e6789ef 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -3628,6 +3628,7 @@ def test_sync_wallet_dry_run(mocker, default_conf, ticker, fee, limit_buy_order, # Initialize to 2 times stake amount default_conf['dry_run_wallet'] = 0.002 default_conf['max_open_trades'] = 2 + default_conf['tradable_balance_ratio'] = 1.0 patch_exchange(mocker) mocker.patch.multiple( 'freqtrade.exchange.Exchange', @@ -3649,5 +3650,5 @@ def test_sync_wallet_dry_run(mocker, default_conf, ticker, fee, limit_buy_order, n = bot.enter_positions() assert n == 0 assert log_has_re(r"Unable to create trade for XRP/BTC: " - r"Available balance \(0 BTC\) is lower than stake amount \(0.001 BTC\)", + r"Available balance \(0.0 BTC\) is lower than stake amount \(0.001 BTC\)", caplog)