Remove pairs with no ticker available when it's needed
This commit is contained in:
parent
d457542d96
commit
ce185a3b19
@ -5,6 +5,7 @@ Provides lists as configured in config.json
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
from copy import deepcopy
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
|
|
||||||
from cachetools import TTLCache, cached
|
from cachetools import TTLCache, cached
|
||||||
@ -79,13 +80,14 @@ class PairListManager():
|
|||||||
Run pairlist through all configured pairlists.
|
Run pairlist through all configured pairlists.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pairlist = self._whitelist.copy()
|
|
||||||
|
|
||||||
# tickers should be cached to avoid calling the exchange on each call.
|
# tickers should be cached to avoid calling the exchange on each call.
|
||||||
tickers: Dict = {}
|
tickers: Dict = {}
|
||||||
if self._tickers_needed:
|
if self._tickers_needed:
|
||||||
tickers = self._get_cached_tickers()
|
tickers = self._get_cached_tickers()
|
||||||
|
|
||||||
|
# Adjust whitelist if filters are using tickers
|
||||||
|
pairlist = self._prepare_whitelist(self._whitelist.copy(), tickers)
|
||||||
|
|
||||||
# Process all pairlists in chain
|
# Process all pairlists in chain
|
||||||
for pl in self._pairlists:
|
for pl in self._pairlists:
|
||||||
pairlist = pl.filter_pairlist(pairlist, tickers)
|
pairlist = pl.filter_pairlist(pairlist, tickers)
|
||||||
@ -94,3 +96,17 @@ class PairListManager():
|
|||||||
pairlist = IPairList.verify_blacklist(pairlist, self.blacklist, True)
|
pairlist = IPairList.verify_blacklist(pairlist, self.blacklist, True)
|
||||||
|
|
||||||
self._whitelist = pairlist
|
self._whitelist = pairlist
|
||||||
|
|
||||||
|
def _prepare_whitelist(self, pairlist: List[str], tickers) -> List[str]:
|
||||||
|
"""
|
||||||
|
Prepare pairlist for Pairlist Filters that use tickers data - remove
|
||||||
|
pairs that do not have ticker available
|
||||||
|
"""
|
||||||
|
if self._tickers_needed:
|
||||||
|
# Copy list since we're modifying this list
|
||||||
|
for p in deepcopy(pairlist):
|
||||||
|
ticker = tickers.get(p)
|
||||||
|
if not ticker:
|
||||||
|
pairlist.remove(p)
|
||||||
|
|
||||||
|
return pairlist
|
||||||
|
Loading…
Reference in New Issue
Block a user