Skip to content

Commit

Permalink
Make data-finding safe
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Dec 28, 2019
1 parent f8b8b9a commit ef0fcb0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions freqtrade/data/datahandlers/jsondatahandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ def ohlcv_get_pairs(cls, datadir: Path, timeframe: str) -> List[str]:
"""
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):
"""
Expand Down Expand Up @@ -54,8 +57,10 @@ def trades_get_pairs(cls, datadir: Path) -> List[str]:
"""
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]):
"""
Expand Down

0 comments on commit ef0fcb0

Please sign in to comment.