Replaced logging with OperationalException when AgeFilter given invalid parameters

This commit is contained in:
gambcl 2020-07-15 12:40:54 +01:00
parent 40bdc93653
commit 1051ab917a
2 changed files with 12 additions and 15 deletions

View File

@ -5,6 +5,7 @@ import logging
import arrow import arrow
from typing import Any, Dict from typing import Any, Dict
from freqtrade.exceptions import OperationalException
from freqtrade.misc import plural from freqtrade.misc import plural
from freqtrade.pairlist.IPairList import IPairList from freqtrade.pairlist.IPairList import IPairList
@ -25,14 +26,11 @@ class AgeFilter(IPairList):
self._min_days_listed = pairlistconfig.get('min_days_listed', 10) self._min_days_listed = pairlistconfig.get('min_days_listed', 10)
if self._min_days_listed < 1: if self._min_days_listed < 1:
self.log_on_refresh(logger.info, "min_days_listed must be >= 1, " raise OperationalException("AgeFilter requires min_days_listed must be >= 1")
"ignoring filter")
if self._min_days_listed > exchange.ohlcv_candle_limit: if self._min_days_listed > exchange.ohlcv_candle_limit:
self._min_days_listed = min(self._min_days_listed, exchange.ohlcv_candle_limit) raise OperationalException("AgeFilter requires min_days_listed must not exceed "
self.log_on_refresh(logger.info, "min_days_listed exceeds " "exchange max request size "
"exchange max request size " f"({exchange.ohlcv_candle_limit})")
f"({exchange.ohlcv_candle_limit}), using "
f"min_days_listed={self._min_days_listed}")
self._enabled = self._min_days_listed >= 1 self._enabled = self._min_days_listed >= 1
@property @property

View File

@ -543,10 +543,9 @@ def test_agefilter_min_days_listed_too_small(mocker, default_conf, markets, tick
get_tickers=tickers get_tickers=tickers
) )
get_patched_freqtradebot(mocker, default_conf) with pytest.raises(OperationalException,
match=r'AgeFilter requires min_days_listed must be >= 1'):
assert log_has_re(r'min_days_listed must be >= 1, ' get_patched_freqtradebot(mocker, default_conf)
r'ignoring filter', caplog)
def test_agefilter_min_days_listed_too_large(mocker, default_conf, markets, tickers, caplog): def test_agefilter_min_days_listed_too_large(mocker, default_conf, markets, tickers, caplog):
@ -559,10 +558,10 @@ def test_agefilter_min_days_listed_too_large(mocker, default_conf, markets, tick
get_tickers=tickers get_tickers=tickers
) )
get_patched_freqtradebot(mocker, default_conf) with pytest.raises(OperationalException,
match=r'AgeFilter requires min_days_listed must not exceed '
assert log_has_re(r'^min_days_listed exceeds ' r'exchange max request size \([0-9]+\)'):
r'exchange max request size', caplog) get_patched_freqtradebot(mocker, default_conf)
def test_agefilter_caching(mocker, markets, whitelist_conf_3, tickers, ohlcv_history_list): def test_agefilter_caching(mocker, markets, whitelist_conf_3, tickers, ohlcv_history_list):