Dashboard shows open positions only; closed trades stay in review.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-21 16:33:30 +08:00
parent 74cfb8b4aa
commit e68393fe5b
3 changed files with 28 additions and 19 deletions
+9 -11
View File
@@ -11,7 +11,7 @@
<div class="muted">在线机器</div>
<div class="stat"><span id="stat-online">{{ online_count }}</span><span class="muted" style="font-size:16px"> / {{ machine_count }}</span></div>
</div>
<div class="card"><div class="muted">实时成交(条)</div><div class="stat" id="stat-trades">{{ trades|length }}</div></div>
<div class="card"><div class="muted">当前持仓(笔)</div><div class="stat" id="stat-trades">{{ trades|length }}</div></div>
</div>
<div class="grid cols-2" style="margin-top:14px">
@@ -34,7 +34,7 @@
</div>
<div class="card">
<h3>快速入口</h3>
<p class="muted">下载通用辅助包并用激活码绑定;成交自动上报到本页实时记录与交易复盘。</p>
<p class="muted">下载通用辅助包并用激活码绑定;本页显示当前持仓,历史成交见交易复盘。</p>
<p style="margin-top:12px">
<a class="btn" href="{{ url_for('download_page') }}">下载中心</a>
<a class="btn secondary" href="{{ url_for('records_page') }}">交易复盘</a>
@@ -44,12 +44,12 @@
</div>
<div class="card" style="margin-top:14px">
<h3>机器实时交易记录</h3>
<h3>当前持仓</h3>
<table>
<thead>
<tr>
<th>时间</th><th>机器</th><th>品种</th><th>方向</th><th>手数</th>
<th>盈亏</th><th>账户</th><th>单号</th><th></th>
<th>开仓时间</th><th>机器</th><th>品种</th><th>方向</th><th>手数</th>
<th>浮盈</th><th>账户</th><th>单号</th><th></th>
</tr>
</thead>
<tbody id="live-trades-body">
@@ -61,14 +61,14 @@
<td><span class="tag {% if t.side=='buy' %}green{% else %}red{% endif %}">{{ t.side }}</span></td>
<td>{{ t.volume if t.volume is not none else '—' }}</td>
<td style="color:{% if t.profit is not none and t.profit>0 %}var(--green){% elif t.profit is not none and t.profit<0 %}var(--red){% else %}inherit{% endif %}">
{% if t.profit is none %}—{% else %}{{ '%.2f'|format(t.profit) }}{% if not t.close_time %}<span class="muted"> 浮</span>{% endif %}{% endif %}
{% if t.profit is none %}—{% else %}{{ '%.2f'|format(t.profit) }}{% endif %}
</td>
<td>{{ t.account_name or '—' }}</td>
<td class="muted">{{ t.ticket or '—' }}</td>
<td><a href="{{ url_for('record_detail', tid=t.id) }}">复盘</a></td>
</tr>
{% else %}
<tr><td colspan="9" class="muted">暂无成交。客户端上报后将实时显示。</td></tr>
<tr><td colspan="9" class="muted">当前无持仓。开仓后由客户端上报显示。</td></tr>
{% endfor %}
</tbody>
</table>
@@ -138,7 +138,7 @@
if (!body) return;
document.getElementById('stat-trades').textContent = String(list.length);
if (!list.length) {
body.innerHTML = '<tr><td colspan="9" class="muted">暂无成交。客户端上报后将实时显示。</td></tr>';
body.innerHTML = '<tr><td colspan="9" class="muted">当前无持仓。开仓后由客户端上报显示。</td></tr>';
return;
}
body.innerHTML = list.map(function (t) {
@@ -150,9 +150,7 @@
'<td><span class="tag ' + sideCls + '">' + esc(t.side) + '</span></td>' +
'<td>' + esc(t.volume != null ? t.volume : '—') + '</td>' +
'<td style="color:' + profitColor(t.profit) + '">' +
(t.profit == null || t.profit === ''
? '—'
: (Number(t.profit).toFixed(2) + (t.close_time ? '' : ' <span class="muted">浮</span>'))) +
(t.profit == null || t.profit === '' ? '—' : Number(t.profit).toFixed(2)) +
'</td>' +
'<td>' + esc(t.account_name || '—') + '</td>' +
'<td class="muted">' + esc(t.ticket || '—') + '</td>' +