Skip to content

Commit b8220a0

Browse files
committed
fix: Support non-utf8 characters in pair filenames
1 parent 31bec6b commit b8220a0

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

freqtrade/data/history/datahandlers/idatahandler.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232

3333
class IDataHandler(ABC):
34-
_OHLCV_REGEX = r"^([a-zA-Z_\d-]+)\-(\d+[a-zA-Z]{1,2})\-?([a-zA-Z_]*)?(?=\.)"
35-
_TRADES_REGEX = r"^([a-zA-Z_\d-]+)\-(trades)?(?=\.)"
34+
_OHLCV_REGEX = r"^([\w-]+)\-(\d+[a-zA-Z]{1,2})\-?([a-zA-Z_]*)?(?=\.)"
35+
_TRADES_REGEX = r"^([\w-]+)\-(trades)?(?=\.)"
3636

3737
def __init__(self, datadir: Path) -> None:
3838
self._datadir = datadir
@@ -336,11 +336,10 @@ def rebuild_timeframe_from_filename(timeframe: str) -> str:
336336
def rebuild_pair_from_filename(pair: str) -> str:
337337
"""
338338
Rebuild pair name from filename
339-
Assumes a asset name of max. 7 length to also support BTC-PERP and BTC-PERP:USD names.
339+
Replaces the first '_' with '/' and the second '_' (if present) with ':'.
340+
e.g. BTC_USDT -> BTC/USDT, BTC_USDT_USDT -> BTC/USDT:USDT
340341
"""
341-
res = re.sub(r"^(([A-Za-z\d]{1,10})|^([A-Za-z\-]{1,6}))(_)", r"\g<1>/", pair, count=1)
342-
res = re.sub("_", ":", res, count=1)
343-
return res
342+
return pair.replace("_", "/", 1).replace("_", ":", 1)
344343

345344
def ohlcv_load(
346345
self,

0 commit comments

Comments
 (0)