Implement pair_to_filename to datahandler

includes tests - taken from #2744 and modified to adapt to new structure
This commit is contained in:
Matthias
2020-01-05 10:36:08 +01:00
parent bc6a10353b
commit 4eaaec9d1a
4 changed files with 55 additions and 16 deletions

View File

@@ -30,7 +30,7 @@ class JsonDataHandler(IDataHandler):
_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]
return [misc.pair_to_filename(match[0]) for match in _tmp if match]
def ohlcv_store(self, pair: str, timeframe: str, data: DataFrame) -> None:
"""
@@ -109,7 +109,7 @@ class JsonDataHandler(IDataHandler):
_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]
return [misc.pair_to_filename(match[0]) for match in _tmp if match]
def trades_store(self, pair: str, data: List[Dict]) -> None:
"""
@@ -157,7 +157,7 @@ class JsonDataHandler(IDataHandler):
@classmethod
def _pair_data_filename(cls, datadir: Path, pair: str, timeframe: str) -> Path:
pair_s = pair.replace("/", "_")
pair_s = misc.pair_to_filename(pair)
filename = datadir.joinpath(f'{pair_s}-{timeframe}.{cls._get_file_extension()}')
return filename
@@ -167,7 +167,7 @@ class JsonDataHandler(IDataHandler):
@classmethod
def _pair_trades_filename(cls, datadir: Path, pair: str) -> Path:
pair_s = pair.replace("/", "_")
pair_s = misc.pair_to_filename(pair)
filename = datadir.joinpath(f'{pair_s}-trades.{cls._get_file_extension()}')
return filename

View File

@@ -93,7 +93,7 @@ def file_load_json(file):
def pair_to_filename(pair: str) -> str:
for ch in ['/', ' ', '.']:
for ch in ['/', '-', ' ', '.', '@', '$', '+', ':']:
pair = pair.replace(ch, '_')
return pair