Commit 2a33445

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-02-06 20:48:12
fix(price): fix category matching
1 parent 437de33
Changed files (1)
src
src/price/entrypoint.py
@@ -103,10 +103,9 @@ async def get_asset_price(client: Client, message: Message, **kwargs):
     else:  # match single symbol: "BTC" / "AAPL" / "SPX" / "000001"
         symbol = text
         interval = None
-
     categories = await match_symbol_category(symbol)
     if not categories:
-        await send2tg(client, message, texts=f"不支持此Symbol: {symbol}\n{HELP}", **kwargs)
+        await send2tg(client, message, texts=f"不支持此Symbol: {symbol.upper()}\n{HELP}", **kwargs)
         return
     if warnings := categories.get("warnings"):
         warn_msg = await send2tg(client, message, texts=warnings, **kwargs)
@@ -136,12 +135,15 @@ async def match_symbol_category(symbol: str = "") -> dict[str, str]:
     if cmc := await cmc_supported(symbol):  # {"symbol": "BTC"} or {"slug": "bitcoin"}
         category["cmc"] = cmc.get("symbol", cmc.get("slug"))
         category["crypto"] = cmc.get("symbol", cmc.get("slug"))
-    if okx := await okx_supported(symbol):  # symbol, instId
-        category["okx"] = okx[0]
-        category["crypto"] = okx[0]
-    if binance := await binance_supported(symbol):  # symbol, market
-        category["binance"] = binance[0]
-        category["crypto"] = binance[0]
+    # okx
+    okx_symbol, _ = await okx_supported(symbol)  # (symbol, instId)
+    if okx_symbol:
+        category["okx"] = okx_symbol
+        category["crypto"] = okx_symbol
+    binance_symbol, _ = await binance_supported(symbol)  # (symbol, market)
+    if binance_symbol:
+        category["binance"] = binance_symbol
+        category["crypto"] = binance_symbol
     if tradingview := await tradingview_supported(symbol):  # ["SSE:000001", "SZSE:000001"]
         category["tradingview"] = ", ".join(tradingview)
     # skip some crypto ETF (e.g. Grayscale Bitcoin Mini Trust use symbol "AMEX:BTC")