fix(gate-bot): show orphan exchange positions and relink monitor
When the exchange still has a position but order_monitors is not active, surface it on the trade page and allow restoring the latest stopped record.
This commit is contained in:
@@ -246,6 +246,10 @@
|
||||
.pos-value.price-flat{color:#e8ecf4}
|
||||
.pos-footer{display:flex;flex-wrap:wrap;gap:14px 18px;font-size:.75rem;color:#6d7689}
|
||||
.pos-empty{padding:18px;text-align:center;color:#8892b0;font-size:.85rem;background:#141923;border:1px dashed #2a3348;border-radius:10px}
|
||||
.pos-card-orphan{border-color:#6a5528;background:#1a1810}
|
||||
.pos-orphan-banner{font-size:.78rem;color:#eac147;background:#2a2418;border:1px solid #6a5528;border-radius:8px;padding:8px 10px;margin-bottom:10px;line-height:1.45}
|
||||
.pos-relink-btn{padding:6px 12px;background:#3d4a2a;color:#d4e8a8;border:none;border-radius:8px;font-size:.82rem;cursor:pointer}
|
||||
.pos-relink-btn:hover{filter:brightness(1.08)}
|
||||
@media (max-width:520px){.pos-grid{grid-template-columns:repeat(2,1fr)}}
|
||||
.stats-card{grid-column:1/-1;margin-top:14px}
|
||||
.stats-card .stats-toggle{background:#1f3a5a;color:#8fc8ff;border:none;border-radius:8px;padding:6px 10px;cursor:pointer}
|
||||
@@ -434,6 +438,12 @@
|
||||
<div class="card">
|
||||
<h2 style="margin-bottom:8px">实时持仓</h2>
|
||||
<div class="panel-scroll pos-list pos-list-live">
|
||||
{% if orphan_positions %}
|
||||
<div class="pos-orphan-banner">交易所有持仓,但本地 <code>order_monitors</code> 无 active 记录(中控仍可能显示交易所实盘)。可点「恢复监控」接回最近已停止记录,或在中控全平。</div>
|
||||
{% endif %}
|
||||
{% if not order and not orphan_positions %}
|
||||
<div class="pos-empty">暂无持仓</div>
|
||||
{% endif %}
|
||||
{% for o in order %}
|
||||
<div class="pos-card" id="order-row-{{ o.id }}"
|
||||
data-monitor-id="{{ o.id }}"
|
||||
@@ -513,8 +523,28 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="pos-empty">暂无持仓</div>
|
||||
{% endfor %}
|
||||
{% for op in orphan_positions %}
|
||||
<div class="pos-card pos-card-orphan" id="orphan-row-{{ op.symbol }}-{{ op.direction }}">
|
||||
<div class="pos-card-head">
|
||||
<div class="pos-card-symbol">
|
||||
<strong>{{ op.exchange_symbol or op.symbol }}</strong>
|
||||
<span class="pos-side-badge {{ 'pos-side-long' if op.direction == 'long' else 'pos-side-short' }}">{{ '做多' if op.direction == 'long' else '做空' }}</span>
|
||||
<span class="badge miss" style="margin-left:4px">仅交易所</span>
|
||||
</div>
|
||||
<div class="pos-head-actions">
|
||||
<button type="button" class="pos-relink-btn" onclick="relinkOrphanPosition('{{ op.symbol }}','{{ op.direction }}')">恢复监控</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pos-meta">
|
||||
<span class="pos-meta-item">张数: {{ op.contracts }}</span>
|
||||
<span class="pos-meta-item">开仓价: {{ price_fmt(op.symbol, op.entry_price) }}</span>
|
||||
<span class="pos-meta-item">标记价: {{ price_fmt(op.symbol, op.mark_price) }}</span>
|
||||
{% if op.unrealized_pnl is not none %}
|
||||
<span class="pos-meta-item">浮盈亏: {{ money_fmt(op.unrealized_pnl) }}U</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1682,6 +1712,22 @@ function submitTpslEntrust(){
|
||||
post();
|
||||
}).catch(()=>alert('无法校验盈亏比'));
|
||||
}
|
||||
function relinkOrphanPosition(symbol, direction){
|
||||
if(!confirm(`恢复 ${symbol} ${direction} 的本地监控?(接回最近一条已停止记录)`)) return;
|
||||
fetch("/api/order/relink_orphan", {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({ symbol, direction }),
|
||||
})
|
||||
.then(r=>r.json())
|
||||
.then(data=>{
|
||||
if(!data.ok){ alert(data.msg || "恢复失败"); return; }
|
||||
alert(data.msg || "已恢复");
|
||||
location.reload();
|
||||
})
|
||||
.catch(()=>alert("恢复请求失败"));
|
||||
}
|
||||
|
||||
function cancelExchangeTpsl(orderId, role){
|
||||
const label = role === 'sl' ? '止损' : '止盈';
|
||||
if(!confirm(`确认撤销交易所${label}委托?(不会平仓)`)) return;
|
||||
|
||||
Reference in New Issue
Block a user