Don't refresh tickers if they are not needed
This commit is contained in:
@@ -22,11 +22,12 @@ class PairListManager():
|
||||
self._whitelist = self._config['exchange'].get('pair_whitelist')
|
||||
self._blacklist = self._config['exchange'].get('pair_blacklist', [])
|
||||
self._pairlists: List[IPairList] = []
|
||||
|
||||
self._tickers_needed = False
|
||||
for pl in self._config.get('pairlists', [{'method': "StaticPairList"}]):
|
||||
pairl = PairListResolver(pl.get('method'),
|
||||
exchange, config,
|
||||
pl.get('config')).pairlist
|
||||
self._tickers_needed = pairl.needstickers or self._tickers_needed
|
||||
self._pairlists.append(pairl)
|
||||
|
||||
@property
|
||||
@@ -52,17 +53,22 @@ class PairListManager():
|
||||
pairlist = self._whitelist.copy()
|
||||
|
||||
# tickers should be cached to avoid calling the exchange on each call.
|
||||
tickers = self._exchange.get_tickers()
|
||||
tickers = []
|
||||
if self._tickers_needed:
|
||||
tickers = self._exchange.get_tickers()
|
||||
|
||||
for pl in self._pairlists:
|
||||
pl.filter_pairlist(pairlist, tickers)
|
||||
|
||||
pairlist = self._verify_blacklist(pairlist)
|
||||
# Validation against blacklist happens after the pairlists to ensure blacklist is respected.
|
||||
pairlist = self.verify_blacklist(pairlist, self.blacklist)
|
||||
self._whitelist = pairlist
|
||||
|
||||
def _verify_blacklist(self, pairlist: List[str]) -> List[str]:
|
||||
@staticmethod
|
||||
def verify_blacklist(pairlist: List[str], blacklist: List[str]) -> List[str]:
|
||||
|
||||
for pair in deepcopy(pairlist):
|
||||
if pair in self.blacklist:
|
||||
if pair in blacklist:
|
||||
logger.warning(f"Pair {pair} in your blacklist. Removing it from whitelist...")
|
||||
pairlist.remove(pair)
|
||||
return pairlist
|
||||
|
||||
Reference in New Issue
Block a user