Auto-refresh review list and stats when trades or annotations change.

Clarify that category/style breakdowns need manual entry tagging.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-23 13:28:27 +08:00
parent c16dc2e061
commit e15b1d7491
4 changed files with 108 additions and 5 deletions
+5 -2
View File
@@ -1,8 +1,11 @@
{% extends "base.html" %}
{% block title %}交易复盘 · {{ app_name }}{% endblock %}
{% block content %}
<h2 style="margin:0 0 6px">交易记录与复盘</h2>
<p class="muted" style="margin:0 0 10px">按机器筛选 · 每页 {{ per_page }} 条 · 时间均为北京时间 · 已隐藏对账/去重影子记录</p>
<h2 style="margin:0 0 6px;display:flex;align-items:center;gap:10px;flex-wrap:wrap">
交易记录与复盘
<span id="records-live-hint" class="tag" style="font-size:12px;font-weight:500">自动刷新中…</span>
</h2>
<p class="muted" style="margin:0 0 10px">按机器筛选 · 每页 {{ per_page }} 条 · 北京时间 · 成交变化会自动刷新 · 已隐藏对账/去重影子记录</p>
<div style="display:flex;gap:8px;margin-bottom:14px;flex-wrap:wrap">
<a class="btn" href="{{ url_for('records_page', machine_id=selected_machine_id) if selected_machine_id else url_for('records_page') }}">交易列表</a>
+51 -2
View File
@@ -1,9 +1,13 @@
{% extends "base.html" %}
{% block title %}统计看板 · {{ app_name }}{% endblock %}
{% block content %}
<h2 style="margin:0 0 6px">统计看板</h2>
<h2 style="margin:0 0 6px;display:flex;align-items:center;gap:10px;flex-wrap:wrap">
统计看板
<span id="records-live-hint" class="tag" style="font-size:12px;font-weight:500">自动刷新中…</span>
</h2>
<p class="muted" style="margin:0 0 10px">
默认按北京时间<strong>今日真实平仓</strong>统计;对账/去重产生的假平仓已排除。
成交/标注变化会<strong>自动刷新</strong>本页。
{% if selected_period == 'today' and stats.day %}当前:{{ stats.day }}{% endif %}
{% if stats.skipped_synthetic %} · 已排除假平仓 {{ stats.skipped_synthetic }} 笔{% endif %}
{% if stats.skipped_dup_ticket %} · 已排除重复单号 {{ stats.skipped_dup_ticket }} 笔{% endif %}
@@ -82,6 +86,7 @@
<div class="grid cols-2" style="margin-top:14px">
<div class="card">
<h3>按大类(顺势 / 反转 / 其他)</h3>
<p class="muted" style="margin:0 0 10px">需在复盘页选「入场形式」后才会分入顺势/反转;未选的汇总在「未标注」。</p>
<table>
<thead>
<tr>
@@ -107,6 +112,7 @@
</div>
<div class="card">
<h3>按入场形式(细项)</h3>
<p class="muted" style="margin:0 0 10px">只显示已标注过的形式;全部为「—」时请先打开复盘标注。</p>
<table>
<thead>
<tr>
@@ -125,7 +131,7 @@
<td class="muted">{{ g.avg_hold }}</td>
</tr>
{% else %}
<tr><td colspan="5" class="muted">暂无数据</td></tr>
<tr><td colspan="5" class="muted">暂无入场形式标注</td></tr>
{% endfor %}
</tbody>
</table>
@@ -239,3 +245,46 @@
</table>
</div>
{% endblock %}
{% block scripts %}
<script>
(function () {
var fpUrl = {{ url_for('records_fingerprint')|tojson }};
var machineId = {{ (selected_machine_id or '')|tojson }};
var hint = document.getElementById('records-live-hint');
var lastFp = null;
var q = machineId ? ('?machine_id=' + encodeURIComponent(machineId)) : '';
function setHint(text, kind) {
if (!hint) return;
hint.textContent = text;
hint.className = 'tag' + (kind ? ' ' + kind : '');
}
function tick() {
fetch(fpUrl + q, { credentials: 'same-origin' })
.then(function (r) { return r.json(); })
.then(function (d) {
if (!d || !d.ok) return;
if (lastFp === null) {
lastFp = d.fp;
setHint('自动刷新 · 监听中', 'green');
return;
}
if (d.fp !== lastFp) {
setHint('有新成交,刷新中…', 'green');
location.reload();
return;
}
setHint('自动刷新 · 监听中', 'green');
})
.catch(function () {
setHint('自动刷新暂时不可用', '');
});
}
tick();
setInterval(tick, 3000);
})();
</script>
{% endblock %}