fix: show risk amount only in full-margin mode across four exchanges

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-05 09:08:45 +08:00
parent 673bcbdc70
commit 934e48b9a8
12 changed files with 143 additions and 27 deletions
+32 -10
View File
@@ -322,6 +322,34 @@
};
}
function formatMonitorRiskMeta(mo, trendPlan) {
const m = mo || {};
const t = trendPlan || {};
const amt =
m.risk_amount != null && m.risk_amount !== ""
? Number(m.risk_amount)
: t.risk_amount != null && t.risk_amount !== ""
? Number(t.risk_amount)
: null;
const pctRaw =
m.risk_percent != null && m.risk_percent !== ""
? m.risk_percent
: t.risk_percent != null && t.risk_percent !== ""
? t.risk_percent
: null;
if (pctRaw == null || pctRaw === "") {
if (amt != null && Number.isFinite(amt)) {
return `风险: ${fmt(amt, 2)}U`;
}
return null;
}
const pct = esc(pctRaw);
if (amt != null && Number.isFinite(amt)) {
return `风险: ${pct}%≈${fmt(amt, 2)}U`;
}
return `风险: ${pct}%`;
}
function resolveTrendMarkPrice(pos, trendPlan, symbol, tickMap) {
const fromPos = fmtMarkPrice(pos, tickMap);
if (fromPos && fromPos !== "—") return fromPos;
@@ -1983,13 +2011,8 @@
const meta = [];
if (isTrend) {
meta.push(monitorOrderSourceHtml(mo, trendPlan));
const riskPct =
trendPlan && trendPlan.risk_percent != null && trendPlan.risk_percent !== ""
? trendPlan.risk_percent
: mo.risk_percent;
if (riskPct != null && riskPct !== "") {
meta.push(`风险: ${esc(riskPct)}%`);
}
const riskLine = formatMonitorRiskMeta(mo, trendPlan);
if (riskLine) meta.push(riskLine);
if (trendPlan && trendPlan.id) {
const zone =
trendPlan.add_upper_display ||
@@ -2006,9 +2029,8 @@
meta.push(monitorOrderSourceHtml(mo, trendPlan));
if (mo.trade_style) meta.push(`风格: ${esc(mo.trade_style)}`);
else meta.push("风格: —");
if (mo.risk_percent != null) {
meta.push(`风险: ${esc(mo.risk_percent)}%`);
}
const riskLine = formatMonitorRiskMeta(mo, trendPlan);
if (riskLine) meta.push(riskLine);
const beOn = mo.breakeven_enabled === 1 || mo.breakeven_enabled === true;
meta.push(
`<span class="${beOn ? "pos-meta-on" : "pos-meta-off"}">移动保本:${beOn ? "开" : "关"}</span>`