Add win rate and profit-loss ratio to archive stats.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-21 09:13:37 +08:00
parent c05afbbedf
commit c0f3606ecc
5 changed files with 55 additions and 4 deletions
+20 -1
View File
@@ -427,6 +427,19 @@
return fmtPnlStat(v);
}
function fmtWinRate(v, openN, winN) {
if (v != null && v !== "") return Number(v).toFixed(1) + "%";
if (openN) return (Math.round(((winN || 0) / openN) * 1000) / 10) + "%";
return "—";
}
function fmtProfitLossRatio(v) {
if (v == null || v === "") return "—";
const n = Number(v);
if (!Number.isFinite(n)) return "—";
return n.toFixed(2) + ":1";
}
function renderStatsRow(label, e, isTotal) {
const openN = e.open_count || 0;
const sickN = e.sick_count || 0;
@@ -444,10 +457,14 @@
"</td><td>" +
(e.loss_count || 0) +
"</td><td>" +
fmtWinRate(e.win_rate, openN, e.win_count) +
"</td><td>" +
fmtPnlStatOptional(e.avg_win) +
"</td><td>" +
fmtPnlStatOptional(e.avg_loss) +
"</td><td>" +
fmtProfitLossRatio(e.profit_loss_ratio) +
"</td><td>" +
fmtPnlStatOptional(e.max_win) +
"</td><td>" +
fmtPnlStatOptional(e.max_loss) +
@@ -482,6 +499,8 @@
loss_count: st.loss_count,
avg_win: st.avg_win,
avg_loss: st.avg_loss,
win_rate: st.win_rate,
profit_loss_ratio: st.profit_loss_ratio,
max_win: st.max_win,
max_loss: st.max_loss,
},
@@ -494,7 +513,7 @@
.join("");
elStats.innerHTML =
'<table class="archive-stats-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><th>平均亏损</th><th>盈亏比</th><th>最大盈利</th><th>最大亏损</th><th>犯病</th><th>犯病占比</th><th>盈亏</th><th>剔除犯病盈亏</th>" +
"</tr></thead><tbody>" +
rows +
"</tbody></table>";