Test if timerange in json file before trimming.
trim_tickerlist throws an index out of range error when parsing a json file for a timerange outside its current contents. This patch test for that condition and returns the the file as-is with a log warning to refresh-cache on fail Here is an example of the error prior to path and after patching. This is from binannce using the pair "ZEN/BTC" and timerange "20180522-20180523" """ File "/Users/creslin/PycharmProjects/freqtrade/freqtrade/optimize/__init__.py", line 107, in load_data pairdata = load_tickerdata_file(datadir, pair, ticker_interval, timerange=timerange) File "/Users/creslin/PycharmProjects/freqtrade/freqtrade/optimize/__init__.py", line 84, in load_tickerdata_file pairdata = trim_tickerlist(pairdata, timerange) File "/Users/creslin/PycharmProjects/freqtrade/freqtrade/optimize/__init__.py", line 36, in trim_tickerlist while tickerlist[start_index][0] < start * 1000: IndexError: list index out of range """" """ 2018-05-31 22:01:07,060 - freqtrade.configuration - INFO - Parameter --timerange detected: 20180522-20180523 ... 2018-05-31 22:01:07,060 - freqtrade.configuration - INFO - Parameter --datadir detected: freqtrade/tests/testdata ... 2018-05-31 22:01:13,168 - freqtrade.optimize - WARNING - start timerange for ZEN/BTC not in cache, to update cache use 2018-05-31 22:01:13,168 - freqtrade.optimize - INFO - --refresh-pairs-cached. *Nb The coin may be newer to the exchange """
This commit is contained in:
parent
52386d8153
commit
13662d4e11
@ -74,6 +74,23 @@ def load_tickerdata_file(
|
|||||||
pairdata = json.load(tickerdata)
|
pairdata = json.load(tickerdata)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
"""
|
||||||
|
Check if timerange is fully within the pairdata loaded
|
||||||
|
Do not call trim_tickerlist if not, as will fail with -index out of range- error.
|
||||||
|
Log to user to run with --refresh-pairs-cached.
|
||||||
|
"""
|
||||||
|
if timerange:
|
||||||
|
stype, start, stop = timerange
|
||||||
|
if stype[0] == 'date':
|
||||||
|
if ((pairdata[0][0]) > (start * 1000)):
|
||||||
|
logger.warn('Start timerange for %s not in cache, to update cache use', pair)
|
||||||
|
logger.info('--refresh-pairs-cached. *NB The coin may be newer to the exchange')
|
||||||
|
return pairdata
|
||||||
|
if stype[1] == 'date':
|
||||||
|
if (pairdata[(len(pairdata) - 1)][0]) < (stop * 1000):
|
||||||
|
logger.warn('End timerange for %s not in cache, to update cache use', pair)
|
||||||
|
logger.info('--refresh-pairs-cached. *NB The coin may no longer be on the exchange')
|
||||||
|
return pairdata
|
||||||
|
|
||||||
if timerange:
|
if timerange:
|
||||||
pairdata = trim_tickerlist(pairdata, timerange)
|
pairdata = trim_tickerlist(pairdata, timerange)
|
||||||
|
Loading…
Reference in New Issue
Block a user