隐藏粉尘级ETH/BTC余额,避免顶栏显示0币
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -116,14 +116,14 @@ def options_funding_label(
|
|||||||
return "—"
|
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:
|
if v is None:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
n = float(v)
|
n = float(v)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
return None
|
return None
|
||||||
if n <= 0:
|
if n < min_amt:
|
||||||
return None
|
return None
|
||||||
txt = f"{n:.6f}".rstrip("0").rstrip(".")
|
txt = f"{n:.6f}".rstrip("0").rstrip(".")
|
||||||
return txt or None
|
return txt or None
|
||||||
@@ -160,10 +160,10 @@ def trading_account_label(
|
|||||||
parts.append(f"{float(usdt):.2f} USDT")
|
parts.append(f"{float(usdt):.2f} USDT")
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
pass
|
pass
|
||||||
eth_txt = _fmt_coin_amount(eth)
|
eth_txt = _fmt_coin_amount(eth, min_amt=1e-6)
|
||||||
if eth_txt is not None:
|
if eth_txt is not None:
|
||||||
parts.append(f"{eth_txt} ETH")
|
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:
|
if btc_txt is not None:
|
||||||
parts.append(f"{btc_txt} BTC")
|
parts.append(f"{btc_txt} BTC")
|
||||||
return " / ".join(parts) if parts else "—"
|
return " / ".join(parts) if parts else "—"
|
||||||
|
|||||||
@@ -1158,7 +1158,7 @@ function formatTradingAccountLabel(usdt, eth, btc, marginMode) {
|
|||||||
const pushCoin = (v, ccy) => {
|
const pushCoin = (v, ccy) => {
|
||||||
if (v === null || v === undefined || v === "") return;
|
if (v === null || v === undefined || v === "") return;
|
||||||
const n = Number(v);
|
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+$/, "");
|
const txt = String(n.toFixed(6)).replace(/\.?0+$/, "");
|
||||||
parts.push(`${txt || "0"} ${ccy}`);
|
parts.push(`${txt || "0"} ${ccy}`);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1639,7 +1639,7 @@ function formatTradingAccountLabel(usdt, eth, btc, marginMode) {
|
|||||||
const pushCoin = (v, ccy) => {
|
const pushCoin = (v, ccy) => {
|
||||||
if (v == null || v === "") return;
|
if (v == null || v === "") return;
|
||||||
const n = Number(v);
|
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+$/, "");
|
const txt = String(n.toFixed(6)).replace(/\.?0+$/, "");
|
||||||
parts.push(`${txt || "0"} ${ccy}`);
|
parts.push(`${txt || "0"} ${ccy}`);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3924,7 +3924,8 @@
|
|||||||
const pushCoin = (v, ccy) => {
|
const pushCoin = (v, ccy) => {
|
||||||
if (v == null || v === "") return;
|
if (v == null || v === "") return;
|
||||||
const n = Number(v);
|
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+$/, "");
|
const txt = String(n.toFixed(6)).replace(/\.?0+$/, "");
|
||||||
parts.push(`${txt || "0"} ${ccy}`);
|
parts.push(`${txt || "0"} ${ccy}`);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user