Added support in /optimize for gzip ticker data files if they exist.

This commit is contained in:
Michael Smith 2018-01-28 21:52:27 +08:00
parent 3b11459a38
commit b44adaa5ab

View File

@ -10,6 +10,7 @@ from freqtrade.analyze import populate_indicators, parse_ticker_dataframe
from freqtrade import misc from freqtrade import misc
from user_data.hyperopt_conf import hyperopt_optimize_conf from user_data.hyperopt_conf import hyperopt_optimize_conf
import gzip
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -38,13 +39,21 @@ def load_tickerdata_file(datadir, pair, ticker_interval,
pair=pair, pair=pair,
ticker_interval=ticker_interval, ticker_interval=ticker_interval,
) )
gzipfile = file + '.gz'
# The file does not exist we download it # The file does not exist we download it
if not os.path.isfile(file): # If file exists, read the file, load the json
if os.path.isfile(gzipfile):
with gzip.open(gzipfile) as tickerdata:
print("Found gzip file. Using that.")
pairdata = json.load(tickerdata)
elif os.path.isfile(file):
with open(file) as tickerdata:
print("Found json file. Using that.")
pairdata = json.load(tickerdata)
else:
return None return None
# Read the file, load the json
with open(file) as tickerdata:
pairdata = json.load(tickerdata)
if timerange: if timerange:
pairdata = trim_tickerlist(pairdata, timerange) pairdata = trim_tickerlist(pairdata, timerange)
return pairdata return pairdata