Show trade record prices at exchange tick precision.

API enriches entry/SL/TP with price_to_precision display strings; OKX formatter now uses the same path as Gate/Binance.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-18 15:41:49 +08:00
parent 0a14fe73c1
commit faf21da955
7 changed files with 84 additions and 5 deletions
+22 -3
View File
@@ -42,6 +42,25 @@
return n.toFixed(digits == null ? 2 : digits);
}
/** 优先用后端交易所精度字符串;否则回退量级格式(与 formatPriceForInput 一致). */
function fmtPx(display, raw) {
if (display != null && display !== "") return esc(display);
if (raw == null || raw === "") return "—";
var n = Number(raw);
if (!Number.isFinite(n)) return esc(raw);
var av = Math.abs(n);
var d;
if (av >= 10000) d = 2;
else if (av >= 100) d = 3;
else if (av >= 1) d = 4;
else if (av >= 0.01) d = 6;
else if (av >= 0.0001) d = 8;
else d = 10;
var text = n.toFixed(d);
if (text.indexOf(".") >= 0) text = text.replace(/\.?0+$/, "");
return text;
}
function fmtTime(s) {
if (!s) return "—";
return esc(String(s).slice(0, 16));
@@ -199,13 +218,13 @@
dirTxt +
"</span></td>" +
"<td>" +
fmtNum(t.trigger_price, 4) +
fmtPx(t.trigger_price_display, t.trigger_price) +
"</td>" +
"<td>" +
fmtNum(stopShow, 4) +
fmtPx(t.stop_loss_display, stopShow) +
"</td>" +
"<td>" +
fmtNum(tpShow, 4) +
fmtPx(t.take_profit_display, tpShow) +
"</td>" +
"<td>" +
margin +