Merge PR #1864: preserve combined crypto routing fixes
This commit is contained in:
commit
7945829259
2 files changed
+31
No files matched your search
@@ -121,6 +121,14 @@ _MARKET_PATTERNS = [
|
||||
(re.compile(r"^[A-Z0-9]+\.VN$", re.I), "vietnam_equity"),
|
||||
(re.compile(r"^(?=[A-Z0-9]*[A-Z])[A-Z0-9]+-USDT$", re.I), "crypto"),
|
||||
(re.compile(r"^(?=[A-Z0-9]*[A-Z])[A-Z0-9]+/USDT$", re.I), "crypto"),
|
||||
# USD-M perpetuals in their documented BASE-USDT-PERP spelling
|
||||
# (ccxt_loader._parse_ccxt_symbol / binance_loader). Without this entry
|
||||
# the symbol matched nothing above and fell through to the a_share
|
||||
# default, so a leveraged perpetual ran under China A-share rules
|
||||
# (100-share board-lot rounding) and every computed size rounded to a
|
||||
# zero_size rejection (#1863). Base alphabet matches the loader's own
|
||||
# ``([A-Z0-9]+)-USDT-PERP`` fullmatch.
|
||||
(re.compile(r"^[A-Z0-9]+-USDT-PERP$", re.I), "crypto"),
|
||||
# yfinance's native crypto spelling (BTC-USD, ETH-USD). Distinct from
|
||||
# USDT pairs only in the quote currency; both belong to CryptoEngine.
|
||||
(re.compile(r"^(?=[A-Z0-9]*[A-Z])[A-Z0-9]+-USD$", re.I), "crypto"),
|
||||
|
||||
@@ -48,6 +48,29 @@ def test_shared_engine_recognizes_known_slash_usd_crypto(symbol):
|
||||
assert _detect_market(symbol) == "crypto"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"symbol",
|
||||
[
|
||||
"BTC-USDT-PERP",
|
||||
"ETH-USDT-PERP",
|
||||
# Numeric bases are legal on Binance USD-M (1000PEPE, 1MBABYDOGE)
|
||||
# and ccxt_loader's own fullmatch allows [A-Z0-9]+ for the base.
|
||||
"1000PEPE-USDT-PERP",
|
||||
"1MBABYDOGE-USDT-PERP",
|
||||
],
|
||||
)
|
||||
def test_usdm_perpetual_symbols_route_to_crypto(symbol):
|
||||
"""BASE-USDT-PERP must run under CryptoEngine, not the a_share default.
|
||||
|
||||
Before #1863's fix the perpetual spelling matched no pattern, fell
|
||||
through to ``a_share``, and the 100-share board-lot rounding turned
|
||||
every computed size into a zero_size rejection.
|
||||
"""
|
||||
from backtest.engines._market_hooks import _detect_market
|
||||
|
||||
assert _detect_market(symbol) == "crypto"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"symbol, expected",
|
||||
[
|
||||
|
||||
Reference in new issue
Block a user