From 6bbc75d063906a9dd2007b40d467cc8fd1f30b1e Mon Sep 17 00:00:00 2001 From: yellowdog Date: Fri, 12 Jun 2026 04:03:43 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BB=BA=E8=AE=AE=E4=BB=93=E4=BD=8D?= =?UTF-8?q?=E6=8C=89=E9=87=8F=E7=BA=A7=E8=87=AA=E9=80=82=E5=BA=94=E5=B0=8F?= =?UTF-8?q?=E6=95=B0=E4=BD=8D=EF=BC=88=E4=BF=AE=E5=A4=8D=20BTC=20=E7=AD=89?= =?UTF-8?q?=E9=AB=98=E4=BB=B7=E5=B8=81=E6=98=BE=E7=A4=BA=E4=B8=BA0?= =?UTF-8?q?=EF=BC=89+=20=E9=80=9A=E7=94=A8=E5=8C=96=E5=8D=95=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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)+'%';