improve pairlistmanager errorhandling

This commit is contained in:
Matthias 2019-11-09 14:49:25 +01:00
parent a01b34a004
commit ae35649366
2 changed files with 23 additions and 5 deletions

View File

@ -23,17 +23,19 @@ class PairListManager():
self._blacklist = self._config['exchange'].get('pair_blacklist', []) self._blacklist = self._config['exchange'].get('pair_blacklist', [])
self._pairlists: List[IPairList] = [] self._pairlists: List[IPairList] = []
self._tickers_needed = False self._tickers_needed = False
pairlists = self._config.get('pairlists', None)
if not pairlists: for pl in self._config.get('pairlists', None):
pairlists = [{'method': "StaticPairList"}] if 'method' not in pl:
for pl in pairlists: logger.warning(f"No method in {pl}")
continue
pairl = PairListResolver(pl.get('method'), pairl = PairListResolver(pl.get('method'),
exchange, self, config, exchange, self, config,
pl.get('config')).pairlist pl.get('config')).pairlist
self._tickers_needed = pairl.needstickers or self._tickers_needed self._tickers_needed = pairl.needstickers or self._tickers_needed
self._pairlists.append(pairl) self._pairlists.append(pairl)
if not self._pairlists: if not self._pairlists:
raise OperationalException("No Pairlist defined!!") raise OperationalException("No Pairlist defined!")
@property @property
def whitelist(self) -> List[str]: def whitelist(self) -> List[str]:

View File

@ -257,3 +257,19 @@ def test_volumepairlist_caching(mocker, markets, whitelist_conf, tickers):
bot.pairlists.refresh_pairlist() bot.pairlists.refresh_pairlist()
# Time should not be updated. # Time should not be updated.
assert bot.pairlists._pairlists[0]._last_refresh == lrf assert bot.pairlists._pairlists[0]._last_refresh == lrf
def test_pairlistmanager_no_pairlist(mocker, markets, whitelist_conf, caplog):
del whitelist_conf['pairlists'][0]['method']
mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True))
with pytest.raises(OperationalException,
match=r"No Pairlist defined!"):
get_patched_freqtradebot(mocker, whitelist_conf)
assert log_has_re("No method in .*", caplog)
whitelist_conf['pairlists'] = []
with pytest.raises(OperationalException,
match=r"No Pairlist defined!"):
get_patched_freqtradebot(mocker, whitelist_conf)