fix(trade-journal): recognize slash-delimited crypto trading pairs in market inference (#934)
Signed-off-by: santhreal <64453045+santhreal@users.noreply.github.com>
This commit is contained in:
1 parent
e23e1d2ff6
commit
e701c089be
2 files changed
+18
-1
No files matched your search
@@ -529,7 +529,7 @@ def _infer_market_from_symbol(symbol: str) -> str:
|
||||
return "hk"
|
||||
if s.endswith(".SH") or s.endswith(".SZ") or s.endswith(".BJ"):
|
||||
return "china_a"
|
||||
if "-" in s and any(quote in s for quote in ("USDT", "USDC", "BTC", "USD")):
|
||||
if ("-" in s or "/" in s) and any(quote in s for quote in ("USDT", "USDC", "BTC", "USD")):
|
||||
return "crypto"
|
||||
# Binance-style concatenated pairs (BTCUSDT) are purely alphabetic, so the
|
||||
# isalpha() US-equity branch below would mis-label them without this check.
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
"""Regression test for _infer_market_from_symbol handling slash-delimited crypto symbols in trade_journal_parsers.
|
||||
|
||||
Locks out a bug where _infer_market_from_symbol returned "other" instead of "crypto" for
|
||||
slash-formatted crypto trading pairs (e.g. "ETH/USDT" or "BTC/USD").
|
||||
"""
|
||||
|
||||
from src.tools.trade_journal_parsers import _infer_market_from_symbol
|
||||
|
||||
|
||||
def test_infer_market_from_symbol_supports_slash_crypto_pairs():
|
||||
"""Prove that _infer_market_from_symbol classifies slash-delimited crypto pairs as 'crypto'."""
|
||||
assert _infer_market_from_symbol("BTC-USDT") == "crypto"
|
||||
|
||||
# Slash delimited crypto pairs (previously returned "other" on un-fixed code)
|
||||
assert _infer_market_from_symbol("ETH/USDT") == "crypto"
|
||||
assert _infer_market_from_symbol("BTC/USD") == "crypto"
|
||||
assert _infer_market_from_symbol("SOL/USDC") == "crypto"
|
||||
Reference in new issue
Block a user