From b44adaa5ab803c9acc46400292bdcaf9f0a84f05 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sun, 28 Jan 2018 21:52:27 +0800 Subject: [PATCH] Added support in /optimize for gzip ticker data files if they exist. --- freqtrade/optimize/__init__.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/freqtrade/optimize/__init__.py b/freqtrade/optimize/__init__.py index a0eb5b8a2..ce753ccb2 100644 --- a/freqtrade/optimize/__init__.py +++ b/freqtrade/optimize/__init__.py @@ -10,6 +10,7 @@ from freqtrade.analyze import populate_indicators, parse_ticker_dataframe from freqtrade import misc from user_data.hyperopt_conf import hyperopt_optimize_conf +import gzip logger = logging.getLogger(__name__) @@ -38,13 +39,21 @@ def load_tickerdata_file(datadir, pair, ticker_interval, pair=pair, ticker_interval=ticker_interval, ) + gzipfile = file + '.gz' + # 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 - # Read the file, load the json - with open(file) as tickerdata: - pairdata = json.load(tickerdata) if timerange: pairdata = trim_tickerlist(pairdata, timerange) return pairdata