From 2c269a39b9b3ba04e2d4d4cae82a0aa021d5f569 Mon Sep 17 00:00:00 2001 From: creslin <34645187+creslinux@users.noreply.github.com> Date: Thu, 31 May 2018 11:47:33 +0300 Subject: [PATCH] Catch error condition when loading time range --- freqtrade/optimize/__init__.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/freqtrade/optimize/__init__.py b/freqtrade/optimize/__init__.py index f6f1ba47a..f851ef112 100644 --- a/freqtrade/optimize/__init__.py +++ b/freqtrade/optimize/__init__.py @@ -74,6 +74,25 @@ def load_tickerdata_file( pairdata = json.load(tickerdata) 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)