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
+38 -1
View File
@@ -398,6 +398,43 @@ def count_trades(
return int(row["c"] if row else 0)
def trades_fingerprint(
conn: sqlite3.Connection,
account_id: Optional[int] = None,
machine_id: Optional[int] = None,
) -> str:
"""列表/统计页轮询用:成交条数、最新 id/平仓时间、标注变化任一变即刷新。"""
clause, params = _trades_where(account_id, machine_id, hide_synthetic=True)
row = conn.execute(
f"""
SELECT COUNT(*) AS c,
COALESCE(MAX(t.id), 0) AS max_id,
COALESCE(MAX(t.close_time), 0) AS max_close,
COALESCE(MAX(t.open_time), 0) AS max_open,
SUM(CASE WHEN IFNULL(t.entry_style,'') != '' THEN 1 ELSE 0 END) AS annotated,
SUM(CASE WHEN IFNULL(t.review_issues,'') != '' THEN 1 ELSE 0 END) AS issues,
SUM(CASE WHEN t.close_time IS NULL OR t.close_time='' THEN 1 ELSE 0 END) AS open_n
FROM trades t
{clause}
""",
tuple(params),
).fetchone()
if not row:
return "0"
return "|".join(
str(x)
for x in (
int(row["c"] or 0),
int(row["max_id"] or 0),
round(float(row["max_close"] or 0), 3),
round(float(row["max_open"] or 0), 3),
int(row["annotated"] or 0),
int(row["issues"] or 0),
int(row["open_n"] or 0),
)
)
def list_trades(
conn: sqlite3.Connection,
limit: int = 200,
@@ -792,7 +829,7 @@ def trade_stats(
"by_style": [
_finalize_group(by_style[k])
for k in style_order
if k in by_style and (by_style[k]["count"] or k in ENTRY_STYLES)
if k in by_style and by_style[k]["count"]
],
}