Cleanup in pairlistmanager
This commit is contained in:
@@ -23,24 +23,25 @@ class PairListManager():
|
||||
self._config = config
|
||||
self._whitelist = self._config['exchange'].get('pair_whitelist')
|
||||
self._blacklist = self._config['exchange'].get('pair_blacklist', [])
|
||||
self._pairlists: List[IPairList] = []
|
||||
self._pairlist_handlers: List[IPairList] = []
|
||||
self._tickers_needed = False
|
||||
for pl in self._config.get('pairlists', None):
|
||||
if 'method' not in pl:
|
||||
logger.warning(f"No method in {pl}")
|
||||
for pairlist_handler_config in self._config.get('pairlists', None):
|
||||
if 'method' not in pairlist_handler_config:
|
||||
logger.warning(f"No method found in {pairlist_handler_config}, ignoring.")
|
||||
continue
|
||||
pairl = PairListResolver.load_pairlist(pl.get('method'),
|
||||
exchange=exchange,
|
||||
pairlistmanager=self,
|
||||
config=config,
|
||||
pairlistconfig=pl,
|
||||
pairlist_pos=len(self._pairlists)
|
||||
)
|
||||
self._tickers_needed = pairl.needstickers or self._tickers_needed
|
||||
self._pairlists.append(pairl)
|
||||
pairlist_handler = PairListResolver.load_pairlist(
|
||||
pairlist_handler_config['method'],
|
||||
exchange=exchange,
|
||||
pairlistmanager=self,
|
||||
config=config,
|
||||
pairlistconfig=pairlist_handler_config,
|
||||
pairlist_pos=len(self._pairlist_handlers)
|
||||
)
|
||||
self._tickers_needed |= pairlist_handler.needstickers
|
||||
self._pairlist_handlers.append(pairlist_handler)
|
||||
|
||||
if not self._pairlists:
|
||||
raise OperationalException("No Pairlist defined!")
|
||||
if not self._pairlist_handlers:
|
||||
raise OperationalException("No Pairlist Handlers defined")
|
||||
|
||||
@property
|
||||
def whitelist(self) -> List[str]:
|
||||
@@ -60,15 +61,15 @@ class PairListManager():
|
||||
@property
|
||||
def name_list(self) -> List[str]:
|
||||
"""
|
||||
Get list of loaded pairlists names
|
||||
Get list of loaded Pairlist Handler names
|
||||
"""
|
||||
return [p.name for p in self._pairlists]
|
||||
return [p.name for p in self._pairlist_handlers]
|
||||
|
||||
def short_desc(self) -> List[Dict]:
|
||||
"""
|
||||
List of short_desc for each pairlist
|
||||
List of short_desc for each Pairlist Handler
|
||||
"""
|
||||
return [{p.name: p.short_desc()} for p in self._pairlists]
|
||||
return [{p.name: p.short_desc()} for p in self._pairlist_handlers]
|
||||
|
||||
@cached(TTLCache(maxsize=1, ttl=1800))
|
||||
def _get_cached_tickers(self):
|
||||
@@ -76,7 +77,7 @@ class PairListManager():
|
||||
|
||||
def refresh_pairlist(self) -> None:
|
||||
"""
|
||||
Run pairlist through all configured pairlists.
|
||||
Run pairlist through all configured Pairlist Handlers.
|
||||
"""
|
||||
# Tickers should be cached to avoid calling the exchange on each call.
|
||||
tickers: Dict = {}
|
||||
@@ -86,19 +87,19 @@ class PairListManager():
|
||||
# Adjust whitelist if filters are using tickers
|
||||
pairlist = self._prepare_whitelist(self._whitelist.copy(), tickers)
|
||||
|
||||
# Process all pairlists in chain
|
||||
for pl in self._pairlists:
|
||||
pairlist = pl.filter_pairlist(pairlist, tickers)
|
||||
# Process all Pairlist Handlers in the chain
|
||||
for pairlist_handler in self._pairlist_handlers:
|
||||
pairlist = pairlist_handler.filter_pairlist(pairlist, tickers)
|
||||
|
||||
# Validation against blacklist happens after the pairlists to ensure
|
||||
# blacklist is respected.
|
||||
# Validation against blacklist happens after the chain of Pairlist Handlers
|
||||
# to ensure blacklist is respected.
|
||||
pairlist = IPairList.verify_blacklist(pairlist, self.blacklist, True)
|
||||
|
||||
self._whitelist = pairlist
|
||||
|
||||
def _prepare_whitelist(self, pairlist: List[str], tickers) -> List[str]:
|
||||
"""
|
||||
Prepare sanitized pairlist for Pairlist Filters that use tickers data - remove
|
||||
Prepare sanitized pairlist for Pairlist Handlers that use tickers data - remove
|
||||
pairs that do not have ticker available
|
||||
"""
|
||||
if self._tickers_needed:
|
||||
|
||||
Reference in New Issue
Block a user