feat: 持仓快照盈亏比与交易所止损已保本标识

盈亏比固定用开仓 initial_stop_loss 计算,人工改委托后不变化;轮询交易所止损触发价相对成交价判定已保本,四所实例与中控统一显示绿色标识。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-03 16:31:03 +08:00
parent e265c1b31a
commit cf3e2ee1c9
13 changed files with 486 additions and 52 deletions
@@ -120,6 +120,7 @@
.plan-card-title{display:flex;align-items:center;gap:8px;flex-wrap:wrap;font-size:1rem;font-weight:700;color:#f0f2ff}
.plan-card-meta{font-size:.76rem;color:#8892b0;line-height:1.55;margin-bottom:10px}
.plan-card-meta .accent{color:#6ab8ff}
.pos-breakeven-badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:6px;font-size:.72rem;font-weight:600;background:#1a3d2e;color:#4cd97f;margin-left:6px}
.plan-card-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px 14px;margin-bottom:10px}
@media (max-width:720px){
.plan-card-grid{grid-template-columns:1fr}
@@ -363,6 +364,7 @@
<div class="plan-card-meta">
来源: 下单监控 风格: {{ o.trade_style or 'trend' }} 风险: {% if o.risk_percent is not none %}{{ o.risk_percent }}%{% else %}—{% endif %}≈{{ money_fmt(o.risk_amount) }}U
{% if o.breakeven_enabled %}<span class="accent">移动保本: 开 {{ o.breakeven_rr_trigger or '-' }}R→{{ price_fmt(osym, o.breakeven_price) }}</span>{% else %}移动保本: 关{% endif %}
<span id="order-be-wrap-{{ o.id }}" style="display:none"><span class="pos-breakeven-badge">已保本</span></span>
</div>
<div class="plan-card-grid">
<div class="plan-cell">
@@ -1471,6 +1473,12 @@ function paintPriceTrend(el, key, value){
lastPriceMap[key] = value;
}
function paintBreakevenBadge(orderId, secured){
const wrap = document.getElementById(`order-be-wrap-${orderId}`);
if(!wrap) return;
wrap.style.display = secured ? "inline-flex" : "none";
}
function refreshPriceSnapshot(){
fetch("/api/price_snapshot").then(r=>r.json()).then(data=>{
const updatedEl = document.getElementById("price-last-updated");
@@ -1534,6 +1542,7 @@ function refreshPriceSnapshot(){
if(rrEl){
rrEl.innerText = (typeof o.rr_ratio !== "undefined" && o.rr_ratio !== null) ? `${Number(o.rr_ratio).toFixed(2)}:1` : "-";
}
paintBreakevenBadge(o.id, o.sl_breakeven_secured);
});
}).catch(()=>{});
}