Split to fetch_pairlist function, Info Message

This commit is contained in:
Bloodhunter4rc 2022-12-07 17:47:38 +01:00
parent 48160f3fe9
commit 607d5b2f8f

View File

@ -59,20 +59,7 @@ class RemotePairList(IPairList):
"""
return f"{self.name} - {self._pairlistconfig['number_assets']} pairs from RemotePairlist."
def gen_pairlist(self, tickers: Tickers) -> List[str]:
"""
Generate the pairlist
:param tickers: Tickers (from exchange.get_tickers). May be cached.
:return: List of pairs
"""
pairlist = self._pair_cache.get('pairlist')
info = ""
if pairlist:
# Item found - no refresh necessary
return pairlist.copy()
else:
# Fetch Pairlist from Remote
def fetch_pairlist(self):
headers = {
'User-Agent': 'Freqtrade - Remotepairlist',
}
@ -93,9 +80,13 @@ class RemotePairList(IPairList):
else:
plist = json.loads(rsplit[0])
elif "application/json" in str(content_type):
jsonp = json.loads(' '.join(rsplit))
plist = jsonp['pairs']
info = jsonp['info']
jsonr = response.json()
plist = jsonr['pairs']
if 'info' in jsonr:
info = jsonr['info']
if 'refresh_period' in jsonr:
self._refresh_period = jsonr['refresh_period']
except requests.exceptions.RequestException:
self.log_once(f'Was not able to fetch pairlist from:'
@ -109,6 +100,23 @@ class RemotePairList(IPairList):
time_elapsed = 0
return plist, time_elapsed, info
def gen_pairlist(self, tickers: Tickers) -> List[str]:
"""
Generate the pairlist
:param tickers: Tickers (from exchange.get_tickers). May be cached.
:return: List of pairs
"""
pairlist = self._pair_cache.get('pairlist')
info = "Pairlist"
if pairlist:
# Item found - no refresh necessary
return pairlist.copy()
else:
# Fetch Pairlist from Remote URL
plist, time_elapsed, info = self.fetch_pairlist()
pairlist = []
for i in plist:
@ -121,8 +129,7 @@ class RemotePairList(IPairList):
self._pair_cache['pairlist'] = pairlist.copy()
if(time_elapsed):
self.log_once(info + " | " + " Fetched in " + str(time_elapsed) +
" seconds.", logger.info)
self.log_once(f'{info} Fetched in {time_elapsed} seconds.', logger.info)
self._last_pairlist = list(pairlist)
return pairlist