Do not try to redownload pair data if --refresh-pairs-cached is not set

This commit is contained in:
Anton 2018-05-21 22:31:08 +03:00
parent 13d6297b9f
commit e1cb0dbf28
1 changed files with 7 additions and 11 deletions

View File

@ -29,7 +29,7 @@ def trim_tickerlist(tickerlist: List[Dict], timerange: Tuple[Tuple, int, int]) -
if stype[0] == 'index':
start_index = start
elif stype[0] == 'date':
while tickerlist[start_index][0] < start * 1000:
while start_index < len(tickerlist) and tickerlist[start_index][0] < start * 1000:
start_index += 1
if stype[1] == 'line':
@ -37,7 +37,7 @@ def trim_tickerlist(tickerlist: List[Dict], timerange: Tuple[Tuple, int, int]) -
if stype[1] == 'index':
stop_index = stop
elif stype[1] == 'date':
while tickerlist[stop_index-1][0] > stop * 1000:
while stop_index > 0 and tickerlist[stop_index-1][0] > stop * 1000:
stop_index -= 1
if start_index > stop_index:
@ -100,15 +100,11 @@ def load_data(datadir: str,
for pair in _pairs:
pairdata = load_tickerdata_file(datadir, pair, ticker_interval, timerange=timerange)
if not pairdata:
# download the tickerdata from exchange
download_backtesting_testdata(datadir,
pair=pair,
tick_interval=ticker_interval,
timerange=timerange)
# and retry reading the pair
pairdata = load_tickerdata_file(datadir, pair, ticker_interval, timerange=timerange)
result[pair] = pairdata
if pairdata:
result[pair] = pairdata
else:
logger.warn('No data for pair %s, use --update-pairs-cached to download the data', pair)
return result