Gracefully handle cases where no buy price was found

closes #4030
This commit is contained in:
Matthias 2020-12-04 07:42:16 +01:00
parent 22595e6f92
commit 2fbbeb970b
2 changed files with 9 additions and 0 deletions

View File

@ -616,6 +616,9 @@ class FreqtradeBot:
# Calculate price
buy_limit_requested = self.get_buy_rate(pair, True)
if not buy_limit_requested:
raise PricingError('Could not determine buy price.')
min_stake_amount = self._get_min_pair_stake_amount(pair, buy_limit_requested)
if min_stake_amount is not None and min_stake_amount > stake_amount:
logger.warning(

View File

@ -1074,6 +1074,12 @@ def test_execute_buy(mocker, default_conf, fee, limit_buy_order, limit_buy_order
mocker.patch('freqtrade.exchange.Exchange.buy', MagicMock(return_value=limit_buy_order))
assert not freqtrade.execute_buy(pair, stake_amount)
# Fail to get price...
mocker.patch('freqtrade.freqtradebot.FreqtradeBot.get_buy_rate', MagicMock(return_value=0.0))
with pytest.raises(PricingError, match="Could not determine buy price."):
freqtrade.execute_buy(pair, stake_amount)
def test_execute_buy_confirm_error(mocker, default_conf, fee, limit_buy_order) -> None:
freqtrade = get_patched_freqtradebot(mocker, default_conf)