From ef0fcb0e0f5b82548b53380a0968d1750c64da69 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 25 Dec 2019 10:21:30 +0100 Subject: [PATCH] Make data-finding safe --- freqtrade/data/datahandlers/jsondatahandler.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/freqtrade/data/datahandlers/jsondatahandler.py b/freqtrade/data/datahandlers/jsondatahandler.py index 214958251..fe01176ad 100644 --- a/freqtrade/data/datahandlers/jsondatahandler.py +++ b/freqtrade/data/datahandlers/jsondatahandler.py @@ -19,8 +19,11 @@ class JsonDataHandler(IDataHandler): """ Returns a list of all pairs available in this datadir """ - return [re.search(r'^(\S+)(?=\-' + timeframe + '.json)', p.name)[0].replace('_', ' /') + + _tmp = [re.search(r'^(\S+)(?=\-' + timeframe + '.json)', p.name) for p in datadir.glob(f"*{timeframe}.{cls._get_file_extension()}")] + # Check if regex found something and only return these results + return [match[0].replace('_', ' /') for match in _tmp if match] def ohlcv_store(self, timeframe: str, data: DataFrame): """ @@ -54,8 +57,10 @@ class JsonDataHandler(IDataHandler): """ Returns a list of all pairs available in this datadir """ - return [re.search(r'^(\S+)(?=\-trades.json)', p.name)[0].replace('_', '/') + _tmp = [re.search(r'^(\S+)(?=\-trades.json)', p.name) for p in datadir.glob(f"*trades.{cls._get_file_extension()}")] + # Check if regex found something and only return these results to avoid exceptions. + return [match[0].replace('_', ' /') for match in _tmp if match] def trades_store(self, data: List[Dict]): """