Catch error condition when loading time range

This commit is contained in:
creslin 2018-05-31 11:47:33 +03:00 committed by GitHub
parent 52386d8153
commit 2c269a39b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,6 +75,25 @@ def load_tickerdata_file(
else:
return None
"""
Check if timerange is in the pairdata loaded
Return None is not, which will then download the file.
This is to avoid trim_tickerlist throwing
"list index out of range" error else.
"""
if timerange:
howmany = (len(pairdata) - 1)
first_file_timestamp = (pairdata[0][0])
last_file_timestamp = (pairdata[howmany][0])
stype, start, stop = timerange
if stype[0] == 'date':
if first_file_timestamp > (start * 1000):
return None
if stype[1] == 'date':
if last_file_timestamp < (stop * 1000):
return None
if timerange:
pairdata = trim_tickerlist(pairdata, timerange)
return pairdata