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>
+3 -3
View File
@@ -7,8 +7,8 @@
<script src="/static/autofill_guard.js?v=1"></script>
<link rel="stylesheet" href="/static/instance_theme_early.css?v=4">
<link rel="stylesheet" href="/static/account_risk_badge.css?v=4">
<link rel="stylesheet" href="/static/instance_page.css?v=12">
<link rel="stylesheet" href="/static/instance_theme.css?v=109">
<link rel="stylesheet" href="/static/instance_page.css?v=13">
<link rel="stylesheet" href="/static/instance_theme.css?v=110">
<script src="/static/account_risk_badge.js?v=4"></script>
<meta name="theme-color" content="#0b0d14">
<title>{{ pwa_app_name }}</title>
@@ -158,7 +158,7 @@ const ORDER_ENTRY_MODEL_CODE_TO_CATEGORY = {{ entry_model_code_to_category | toj
<script src="/static/symbol_live_price.js?v=2"></script>
<script src="/static/strategy_roll.js?v=6"></script>
<script src="/static/key_monitor_form.js?v=2"></script>
<script src="/static/instance_stats.js?v=4"></script>
<script src="/static/instance_stats.js?v=5"></script>
{% include 'embed_boot_scripts.html' %}
<script src="/static/records_review_page.js?v=4"></script>
<script src="/static/options_expiry_countdown.js?v=1"></script>
+41 -3
View File
@@ -17,8 +17,8 @@
<link rel="apple-touch-icon" href="/static/icons/apple-touch-icon.png">
<link rel="manifest" href="/static/icons/manifest.webmanifest">
<title>{{ pwa_app_name }}</title>
<link rel="stylesheet" href="/static/instance_page.css?v=12">
<link rel="stylesheet" href="/static/instance_theme.css?v=109">
<link rel="stylesheet" href="/static/instance_page.css?v=13">
<link rel="stylesheet" href="/static/instance_theme.css?v=110">
</head>
<body
@@ -110,6 +110,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="container">
@@ -384,10 +420,12 @@
<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>
@@ -429,7 +467,7 @@ const ORDER_ENTRY_MODEL_CODE_TO_CATEGORY = {{ entry_model_code_to_category | toj
<script src="/static/manual_order_rr_preview.js?v=5"></script>
<script src="/static/symbol_live_price.js?v=2"></script>
<script src="/static/strategy_roll.js?v=6"></script>
<script src="/static/instance_stats.js?v=4"></script>
<script src="/static/instance_stats.js?v=5"></script>
<script>
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
const JOURNAL_ORDER_TYPE_OPTIONS = {{ order_type_options | tojson }};