Local File Loading

This commit is contained in:
Bloodhunter4rc 2022-12-08 01:09:17 +01:00
parent da2747d487
commit 7efcbbb457

View File

@ -83,13 +83,11 @@ 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):
jsonr = response.json() jsonp = response.json()
plist = jsonr['pairs'] plist = jsonp['pairs']
if 'info' in jsonr: info = jsonp.get('info', '')
info = jsonr['info'] self._refresh_period = jsonp.get('refresh_period', self._refresh_period)
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:'
@ -128,6 +126,10 @@ class RemotePairList(IPairList):
# Load the JSON data into a dictionary # Load the JSON data into a dictionary
jsonp = json.load(json_file) jsonp = json.load(json_file)
plist = jsonp['pairs'] plist = jsonp['pairs']
info = jsonp.get('info', '')
self._refresh_period = jsonp.get('refresh_period', self._refresh_period)
else: else:
raise ValueError(f"{self._pairlist_url} does not exist.") raise ValueError(f"{self._pairlist_url} does not exist.")
else: else:
@ -145,8 +147,10 @@ class RemotePairList(IPairList):
pairlist = self.filter_pairlist(pairlist, tickers) pairlist = self.filter_pairlist(pairlist, tickers)
self._pair_cache['pairlist'] = pairlist.copy() self._pair_cache['pairlist'] = pairlist.copy()
if(time_elapsed): if (time_elapsed) in locals():
self.log_once(f'{info} Fetched in {time_elapsed} seconds.', logger.info) self.log_once(f'{info} Fetched in {time_elapsed} seconds.', logger.info)
else:
self.log_once(f'{info} Fetched Pairlist.', logger.info)
self._last_pairlist = list(pairlist) self._last_pairlist = list(pairlist)
return pairlist return pairlist