(function (global) { function escapeHtml(s) { return String(s) .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """); } function statusLabel(o) { const st = o.status || ""; const reason = o.end_reason || ""; if (st === "done") { const map = { leave_up: "结束·上破", leave_down: "结束·下破", cancel: "已取消", closed: "已完成", }; return map[reason] || "已结束"; } const map2 = { armed: "待命", triggering: "触发中", open: "持仓中" }; return map2[st] || st || "—"; } async function loadCandidates() { const box = document.getElementById("cf-instances"); if (!box) return; const r = await fetch("/api/cond_orders/candidates"); const d = await r.json(); const list = d.instances || []; if (!list.length) { box.innerHTML = '暂无启用实例'; return; } box.innerHTML = list .map(function (it) { const disabled = !it.selectable; const tip = disabled ? it.has_position ? "已有持仓" : it.cond_order_locked ? "条件单占用" : it.online ? "不可选" : "离线" : "可选"; return ( '" ); }) .join(""); } async function loadOrders() { const box = document.getElementById("cond-list"); if (!box) return; const r = await fetch("/api/cond_orders"); const d = await r.json(); const list = d.orders || []; if (!list.length) { box.innerHTML = '暂无条件单'; return; } box.innerHTML = '
| 客户端 | 状态 | 标的 | 触发 | 偏离 | 到期h | 出场 | 说明 | 操作 | " + "
|---|---|---|---|---|---|---|---|---|
| " + escapeHtml(o.instance_name || "") + " | " + "" + escapeHtml(statusLabel(o)) + " | " + "" + escapeHtml((o.underlying || "") + " " + (o.opt_type || "")) + " | " + "" + escapeHtml(side + " " + (o.trigger_px != null ? o.trigger_px : "")) + " | " + "" + escapeHtml(o.deviation_pct != null ? o.deviation_pct + "%" : "—") + " | " + "" + escapeHtml(o.min_expiry_hours != null ? String(o.min_expiry_hours) : "—") + " | " + "" + escapeHtml(exit || "—") + " | " + "" + escapeHtml(o.message || "") + " | " + '' +
actions +
" | " +
"