隐藏粉尘级ETH/BTC余额,避免顶栏显示0币

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-20 13:19:35 +08:00
parent f3de3763bb
commit 15694e8ea8
4 changed files with 8 additions and 7 deletions
+4 -4
View File
@@ -116,14 +116,14 @@ def options_funding_label(
return ""
def _fmt_coin_amount(v: float | None) -> str | None:
def _fmt_coin_amount(v: float | None, *, min_amt: float = 1e-6) -> str | None:
if v is None:
return None
try:
n = float(v)
except (TypeError, ValueError):
return None
if n <= 0:
if n < min_amt:
return None
txt = f"{n:.6f}".rstrip("0").rstrip(".")
return txt or None
@@ -160,10 +160,10 @@ def trading_account_label(
parts.append(f"{float(usdt):.2f} USDT")
except (TypeError, ValueError):
pass
eth_txt = _fmt_coin_amount(eth)
eth_txt = _fmt_coin_amount(eth, min_amt=1e-6)
if eth_txt is not None:
parts.append(f"{eth_txt} ETH")
btc_txt = _fmt_coin_amount(btc)
btc_txt = _fmt_coin_amount(btc, min_amt=1e-7)
if btc_txt is not None:
parts.append(f"{btc_txt} BTC")
return " / ".join(parts) if parts else ""