Merge pull request #12876 from freqtrade/fix/chinese_char_pairs
Allow non-ascii characters in pair names
This commit is contained in:
@@ -31,8 +31,8 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class IDataHandler(ABC):
|
class IDataHandler(ABC):
|
||||||
_OHLCV_REGEX = r"^([a-zA-Z_\d-]+)\-(\d+[a-zA-Z]{1,2})\-?([a-zA-Z_]*)?(?=\.)"
|
_OHLCV_REGEX = r"^([\w-]+)\-(\d+[a-zA-Z]{1,2})\-?([a-zA-Z_]*)?(?=\.)"
|
||||||
_TRADES_REGEX = r"^([a-zA-Z_\d-]+)\-(trades)?(?=\.)"
|
_TRADES_REGEX = r"^([\w-]+)\-(trades)?(?=\.)"
|
||||||
|
|
||||||
def __init__(self, datadir: Path) -> None:
|
def __init__(self, datadir: Path) -> None:
|
||||||
self._datadir = datadir
|
self._datadir = datadir
|
||||||
@@ -336,11 +336,10 @@ class IDataHandler(ABC):
|
|||||||
def rebuild_pair_from_filename(pair: str) -> str:
|
def rebuild_pair_from_filename(pair: str) -> str:
|
||||||
"""
|
"""
|
||||||
Rebuild pair name from filename
|
Rebuild pair name from filename
|
||||||
Assumes a asset name of max. 7 length to also support BTC-PERP and BTC-PERP:USD names.
|
Replaces the first '_' with '/' and the second '_' (if present) with ':'.
|
||||||
|
e.g. BTC_USDT -> BTC/USDT, BTC_USDT_USDT -> BTC/USDT:USDT
|
||||||
"""
|
"""
|
||||||
res = re.sub(r"^(([A-Za-z\d]{1,10})|^([A-Za-z\-]{1,6}))(_)", r"\g<1>/", pair, count=1)
|
return pair.replace("_", "/", 1).replace("_", ":", 1)
|
||||||
res = re.sub("_", ":", res, count=1)
|
|
||||||
return res
|
|
||||||
|
|
||||||
def ohlcv_load(
|
def ohlcv_load(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -28,7 +28,11 @@ def expand_pairlist(
|
|||||||
raise ValueError(f"Wildcard error in {pair_wc}, {err}")
|
raise ValueError(f"Wildcard error in {pair_wc}, {err}")
|
||||||
|
|
||||||
# Remove wildcard pairs that didn't have a match.
|
# Remove wildcard pairs that didn't have a match.
|
||||||
result = [element for element in result if re.fullmatch(r"^[A-Za-z0-9:/-]+$", element)]
|
result = [
|
||||||
|
element
|
||||||
|
for element in result
|
||||||
|
if re.fullmatch(r"^[\w:/-]+$", element) and "_" not in element
|
||||||
|
]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for pair_wc in wildcardpl:
|
for pair_wc in wildcardpl:
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ def test_datahandler_ohlcv_regex(filename, pair, timeframe, candletype):
|
|||||||
("USDT_BUSD", "USDT/BUSD"),
|
("USDT_BUSD", "USDT/BUSD"),
|
||||||
("BTC_USDT_USDT", "BTC/USDT:USDT"), # Futures
|
("BTC_USDT_USDT", "BTC/USDT:USDT"), # Futures
|
||||||
("XRP_USDT_USDT", "XRP/USDT:USDT"), # futures
|
("XRP_USDT_USDT", "XRP/USDT:USDT"), # futures
|
||||||
("BTC-PERP", "BTC-PERP"),
|
("XYZ-XRP_USDT_USDT", "XYZ-XRP/USDT:USDT"), # hip3 futures
|
||||||
("BTC-PERP_USDT", "BTC-PERP:USDT"),
|
|
||||||
("UNITTEST_USDT", "UNITTEST/USDT"),
|
("UNITTEST_USDT", "UNITTEST/USDT"),
|
||||||
|
("币安人生_USDT_USDT", "币安人生/USDT:USDT"), # futures
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_rebuild_pair_from_filename(pair, expected):
|
def test_rebuild_pair_from_filename(pair, expected):
|
||||||
|
|||||||
Reference in New Issue
Block a user