diff --git a/index.html b/index.html index be2c86c..a0a3e3d 100644 --- a/index.html +++ b/index.html @@ -134,7 +134,7 @@
Position Sizer · 逐仓
-

合约仓位计算器 / DOGE-USDT

+

合约仓位计算器 / 通用合约

先定亏损上限,再反推仓位。杠杆只决定爆仓距离,不决定你亏多少。
@@ -193,7 +193,7 @@
-
建议仓位 · DOGE 数量
+
建议仓位 · 合约数量
@@ -291,6 +291,12 @@ const fmtN=(n,d=2)=>isFinite(n)?n.toLocaleString('en-US',{minimumFractionDigits:d,maximumFractionDigits:d}):'—'; const fmtP=n=>isFinite(n)?n.toLocaleString('en-US',{minimumFractionDigits:5,maximumFractionDigits:5}):'—'; + // 仓位数量:按量级自适应小数位(大币种如 BTC 量很小,小币种如 DOGE 量上千) + const fmtQty=n=>{ + if(!isFinite(n)) return '—'; + const d = n>=1000?0 : n>=100?1 : n>=1?2 : n>=0.01?4 : 6; + return n.toLocaleString('en-US',{minimumFractionDigits:0,maximumFractionDigits:d}); + }; function calc(){ const bal=+$('balance').value, riskPct=+$('riskPct').value, entry=+$('entry').value; @@ -313,10 +319,10 @@ const dist=Math.abs(entry-slPrice); if(!(dist>0)){ clearOut(); return; } - const qty = risk/dist; // DOGE 数量 + const qty = risk/dist; // 合约数量 const notional = qty*entry; // 名义价值 U - $('qty').innerHTML = fmtN(qty,0)+' DOGE'; + $('qty').innerHTML = fmtQty(qty)+' '; $('notional').innerHTML = fmtN(notional)+' U'; $('slPriceShow').textContent = fmtP(slPrice); $('slShow').textContent = '止损 '+fmtN(slPctVal)+'%';