Add all-time stats tab with monthly breakdown on instance analytics.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-01 09:49:47 +08:00
parent a00699aec3
commit f6ea0dc399
9 changed files with 239 additions and 29 deletions
@@ -78,6 +78,42 @@
<div class="stat-item"><div class="label">期内最大亏损日</div><div class="value">{% if s.worst_day %}{{ s.worst_day }}({{ funds_fmt(s.worst_day_pnl) }}U){% else %}-{% endif %}</div></div>
</div>
</details>
{% if period_key == 'all' %}
<div class="inst-stats-block inst-stats-monthly" style="margin-top:14px">
<div class="inst-stats-block-title">按月统计</div>
{% if s.monthly_rows %}
<div class="inst-stats-month-table-wrap">
<table class="inst-stats-month-table">
<thead>
<tr>
<th>月份</th>
<th>开单</th>
<th>平仓</th>
<th>胜率</th>
<th>净盈亏</th>
<th>最大回撤</th>
</tr>
</thead>
<tbody>
{% for m in s.monthly_rows %}
{% set m_net_cls = 'pos-pnl-profit' if m.net_pnl_u > 0 else ('pos-pnl-loss' if m.net_pnl_u < 0 else '') %}
<tr>
<td>{{ m.month_key }}</td>
<td>{{ m.opens_count }}</td>
<td>{{ m.closed_count }}</td>
<td>{% if m.win_rate_pct is not none %}{{ m.win_rate_pct }}%{% else %}—{% endif %}</td>
<td class="{{ m_net_cls }}">{% if m.net_pnl_u > 0 %}+{% endif %}{{ funds_fmt(m.net_pnl_u) }}</td>
<td class="pos-pnl-loss">{{ funds_fmt(m.max_drawdown_u) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p class="inst-stats-empty" style="margin-top:0">暂无按月平仓数据</p>
{% endif %}
</div>
{% endif %}
</div>
{% endmacro %}
<div class="grid">
@@ -263,6 +299,7 @@
{% if page == 'records' %}
{% include 'records_panel.html' %}
{% endif %}
</div>
{% if page == 'env_config' %}
{% include 'env_config_panel.html' %}
{% endif %}
@@ -306,13 +343,14 @@
<button type="button" class="stats-period-tab active" data-stats-period="day" role="tab" aria-selected="true" onclick="switchStatsPeriod('day')">日统计</button>
<button type="button" class="stats-period-tab" data-stats-period="week" role="tab" aria-selected="false" onclick="switchStatsPeriod('week')">周统计</button>
<button type="button" class="stats-period-tab" data-stats-period="month" role="tab" aria-selected="false" onclick="switchStatsPeriod('month')">月统计</button>
<button type="button" class="stats-period-tab" data-stats-period="all" role="tab" aria-selected="false" onclick="switchStatsPeriod('all')">全部统计</button>
</div>
{{ period_stats_pane("day", seg.day) }}
{{ period_stats_pane("week", seg.week) }}
{{ period_stats_pane("month", seg.month) }}
{{ period_stats_pane("all", seg.all) }}
</div>
{% endfor %}
</div>
</div>
{% endif %}
</div>