From 15694e8ea85f7e3bee4854615a3d907264412d60 Mon Sep 17 00:00:00 2001 From: dekun Date: Thu, 20 Aug 2026 13:19:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=90=E8=97=8F=E7=B2=89=E5=B0=98=E7=BA=A7ET?= =?UTF-8?q?H/BTC=E4=BD=99=E9=A2=9D=EF=BC=8C=E9=81=BF=E5=85=8D=E9=A1=B6?= =?UTF-8?q?=E6=A0=8F=E6=98=BE=E7=A4=BA0=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- lib/instance/instance_embed_context_lib.py | 8 ++++---- lib/instance/templates/embed_boot_scripts.html | 2 +- lib/instance/templates/index.html | 2 +- manual_trading_hub/static/app.js | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/instance/instance_embed_context_lib.py b/lib/instance/instance_embed_context_lib.py index e00f65e..0d943e7 100644 --- a/lib/instance/instance_embed_context_lib.py +++ b/lib/instance/instance_embed_context_lib.py @@ -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 "—" diff --git a/lib/instance/templates/embed_boot_scripts.html b/lib/instance/templates/embed_boot_scripts.html index fb28dc1..fa2d2ab 100644 --- a/lib/instance/templates/embed_boot_scripts.html +++ b/lib/instance/templates/embed_boot_scripts.html @@ -1158,7 +1158,7 @@ function formatTradingAccountLabel(usdt, eth, btc, marginMode) { const pushCoin = (v, ccy) => { if (v === null || v === undefined || v === "") return; const n = Number(v); - if (Number.isNaN(n) || !(n > 0)) return; + if (Number.isNaN(n) || !(n >= (ccy === "BTC" ? 1e-7 : 1e-6))) return; const txt = String(n.toFixed(6)).replace(/\.?0+$/, ""); parts.push(`${txt || "0"} ${ccy}`); }; diff --git a/lib/instance/templates/index.html b/lib/instance/templates/index.html index e2d9374..166452b 100644 --- a/lib/instance/templates/index.html +++ b/lib/instance/templates/index.html @@ -1639,7 +1639,7 @@ function formatTradingAccountLabel(usdt, eth, btc, marginMode) { const pushCoin = (v, ccy) => { if (v == null || v === "") return; const n = Number(v); - if (Number.isNaN(n) || !(n > 0)) return; + if (Number.isNaN(n) || !(n >= (ccy === "BTC" ? 1e-7 : 1e-6))) return; const txt = String(n.toFixed(6)).replace(/\.?0+$/, ""); parts.push(`${txt || "0"} ${ccy}`); }; diff --git a/manual_trading_hub/static/app.js b/manual_trading_hub/static/app.js index 4304df0..491f8f1 100644 --- a/manual_trading_hub/static/app.js +++ b/manual_trading_hub/static/app.js @@ -3924,7 +3924,8 @@ const pushCoin = (v, ccy) => { if (v == null || v === "") return; const n = Number(v); - if (Number.isNaN(n) || !(n > 0)) return; + const minAmt = ccy === "BTC" ? 1e-7 : 1e-6; + if (Number.isNaN(n) || !(n >= minAmt)) return; const txt = String(n.toFixed(6)).replace(/\.?0+$/, ""); parts.push(`${txt || "0"} ${ccy}`); };