loop over whitelist only instead of all markets

This commit is contained in:
iuvbio 2019-03-05 21:23:55 +01:00
parent bdc0134e88
commit 39232cbcbb

View File

@ -65,29 +65,26 @@ class IPairList(ABC):
:return: the list of pairs the user wants to trade without the one unavailable or :return: the list of pairs the user wants to trade without the one unavailable or
black_listed black_listed
""" """
sanitized_whitelist = whitelist
markets = self._freqtrade.exchange.markets markets = self._freqtrade.exchange.markets
# Filter to markets in stake currency # Filter to markets in stake currency
markets = [markets[pair] for pair in markets if stake_pairs = [pair for pair in markets if
markets[pair]['quote'] == self._config['stake_currency']] pair.endswith(self._config['stake_currency'])]
known_pairs = set()
# TODO: we should loop over whitelist instead of all markets sanitized_whitelist = []
for market in markets: for pair in whitelist:
pair = market['symbol']
# pair is not in the generated dynamic market, or in the blacklist ... ignore it # pair is not in the generated dynamic market, or in the blacklist ... ignore it
if pair not in whitelist or pair in self.blacklist: if pair in self.blacklist or pair not in stake_pairs:
continue continue
# else the pair is valid # Check if market is active
known_pairs.add(pair) market = markets[pair]
# Market is not active
if not market['active']: if not market['active']:
sanitized_whitelist.remove(pair)
logger.info( logger.info(
'Ignoring %s from whitelist. Market is not active.', 'Ignoring %s from whitelist. Market is not active.',
pair pair
) )
continue
sanitized_whitelist.append(pair)
# We need to remove pairs that are unknown # We need to remove pairs that are unknown
return [x for x in sanitized_whitelist if x in known_pairs] return sanitized_whitelist