Split to fetch_pairlist function, Info Message
This commit is contained in:
parent
48160f3fe9
commit
607d5b2f8f
@ -59,20 +59,7 @@ class RemotePairList(IPairList):
|
|||||||
"""
|
"""
|
||||||
return f"{self.name} - {self._pairlistconfig['number_assets']} pairs from RemotePairlist."
|
return f"{self.name} - {self._pairlistconfig['number_assets']} pairs from RemotePairlist."
|
||||||
|
|
||||||
def gen_pairlist(self, tickers: Tickers) -> List[str]:
|
def fetch_pairlist(self):
|
||||||
"""
|
|
||||||
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
|
|
||||||
headers = {
|
headers = {
|
||||||
'User-Agent': 'Freqtrade - Remotepairlist',
|
'User-Agent': 'Freqtrade - Remotepairlist',
|
||||||
}
|
}
|
||||||
@ -93,9 +80,13 @@ class RemotePairList(IPairList):
|
|||||||
else:
|
else:
|
||||||
plist = json.loads(rsplit[0])
|
plist = json.loads(rsplit[0])
|
||||||
elif "application/json" in str(content_type):
|
elif "application/json" in str(content_type):
|
||||||
jsonp = json.loads(' '.join(rsplit))
|
jsonr = response.json()
|
||||||
plist = jsonp['pairs']
|
plist = jsonr['pairs']
|
||||||
info = jsonp['info']
|
|
||||||
|
if 'info' in jsonr:
|
||||||
|
info = jsonr['info']
|
||||||
|
if 'refresh_period' in jsonr:
|
||||||
|
self._refresh_period = jsonr['refresh_period']
|
||||||
|
|
||||||
except requests.exceptions.RequestException:
|
except requests.exceptions.RequestException:
|
||||||
self.log_once(f'Was not able to fetch pairlist from:'
|
self.log_once(f'Was not able to fetch pairlist from:'
|
||||||
@ -109,6 +100,23 @@ class RemotePairList(IPairList):
|
|||||||
|
|
||||||
time_elapsed = 0
|
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 = []
|
pairlist = []
|
||||||
|
|
||||||
for i in plist:
|
for i in plist:
|
||||||
@ -121,8 +129,7 @@ class RemotePairList(IPairList):
|
|||||||
self._pair_cache['pairlist'] = pairlist.copy()
|
self._pair_cache['pairlist'] = pairlist.copy()
|
||||||
|
|
||||||
if(time_elapsed):
|
if(time_elapsed):
|
||||||
self.log_once(info + " | " + " Fetched in " + str(time_elapsed) +
|
self.log_once(f'{info} Fetched in {time_elapsed} seconds.', logger.info)
|
||||||
" seconds.", logger.info)
|
|
||||||
|
|
||||||
self._last_pairlist = list(pairlist)
|
self._last_pairlist = list(pairlist)
|
||||||
return pairlist
|
return pairlist
|
||||||
|
Loading…
Reference in New Issue
Block a user