自动刷新改用 tail update 与 scrollToPosition 恢复视窗,避免 setData 后跳到最右;拆分 chart_tv 模块并扩展 analyze/recent API。同步威科夫分析、pipeline 增量构建及相关策略与配置。 Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
"""Crypto symbol → Chinese display name for screener UI."""
|
||
|
||
from __future__ import annotations
|
||
|
||
# Base asset → 中文名(覆盖 provider 当前币对;未知则回退 base)
|
||
_BASE_CN: dict[str, str] = {
|
||
"BTC": "比特币",
|
||
"ETH": "以太坊",
|
||
"SOL": "索拉纳",
|
||
"XAU": "黄金",
|
||
"XAG": "白银",
|
||
"SAGA": "Saga",
|
||
"CL": "原油",
|
||
"ZEC": "大零币",
|
||
"XRP": "瑞波币",
|
||
"DOGE": "狗狗币",
|
||
"BNB": "币安币",
|
||
"SUI": "Sui",
|
||
"BILL": "Bill",
|
||
"BZ": "BZ",
|
||
"LAB": "Lab",
|
||
"TON": "通联币",
|
||
"CRCL": "Circle",
|
||
"SNDK": "SNDK",
|
||
"1000PEPE": "千倍佩佩",
|
||
"PEPE": "佩佩",
|
||
"CHIP": "CHIP",
|
||
"WIF": "狗帽子",
|
||
}
|
||
|
||
|
||
def base_asset(symbol: str) -> str:
|
||
"""BTC/USDT:USDT → BTC;1000PEPE/USDT:USDT → 1000PEPE."""
|
||
s = (symbol or "").strip()
|
||
if not s:
|
||
return ""
|
||
head = s.split(":")[0]
|
||
return head.split("/")[0].upper() if "/" in head else head.upper()
|
||
|
||
|
||
def display_name_cn(symbol: str) -> str:
|
||
base = base_asset(symbol)
|
||
if not base:
|
||
return symbol or ""
|
||
return _BASE_CN.get(base, base)
|
||
|
||
|
||
def symbol_name_map(symbols: list[str] | None = None) -> dict[str, str]:
|
||
if not symbols:
|
||
return {f"{k}/USDT:USDT": v for k, v in _BASE_CN.items()}
|
||
return {s: display_name_cn(s) for s in symbols}
|