| | |
| | | |
| | | <!-- 事件日志 Tab --> |
| | | <div class="tab-content" data-tab="events"> |
| | | <div class="events-panel" style="margin-bottom:16px"> |
| | | <div class="events-header"> |
| | | <h3>🎯 每轮止损次数</h3> |
| | | <button class="btn btn-outline" onclick="refreshRoundStopLoss()" style="font-size:11px;padding:3px 10px">🔄 刷新</button> |
| | | </div> |
| | | <div style="max-height:300px;overflow-y:auto"> |
| | | <table class="events-table"> |
| | | <thead> |
| | | <tr> |
| | | <th style="width:120px">轮次</th> |
| | | <th style="width:120px">多仓止损</th> |
| | | <th>空仓止损</th> |
| | | </tr> |
| | | </thead> |
| | | <tbody id="roundStopLossBody"></tbody> |
| | | </table> |
| | | </div> |
| | | </div> |
| | | <div class="events-panel"> |
| | | <div class="events-header"> |
| | | <h3>📋 最近 100 条事件</h3> |
| | |
| | | // 加载事件(内部会渲染事件表格 + PNL 图表) |
| | | await loadEvents(md5); |
| | | |
| | | // 加载每轮止损次数 |
| | | loadRoundStopLoss(md5); |
| | | |
| | | // 事件加载完成后重算统计卡:账户总权益依赖最新 PNL_SNAPSHOT |
| | | if (selectedMd5 === md5 && instances[md5]) { |
| | | renderStats(instances[md5]); |
| | |
| | | renderPnlChart(); |
| | | } |
| | | |
| | | // ==================== 每轮止损次数 ==================== |
| | | async function loadRoundStopLoss(md5) { |
| | | try { |
| | | const rows = await api(API + '/round-stop-loss?apiKeyMd5=' + encodeURIComponent(md5)); |
| | | renderRoundStopLoss(rows || []); |
| | | } catch (e) { |
| | | renderRoundStopLoss([]); |
| | | } |
| | | } |
| | | |
| | | function renderRoundStopLoss(rows) { |
| | | const tbody = $('roundStopLossBody'); |
| | | if (!tbody) return; |
| | | if (!rows || rows.length === 0) { |
| | | tbody.innerHTML = `<tr><td colspan="3" style="text-align:center;padding:20px;color:var(--dim)">暂无止损记录</td></tr>`; |
| | | return; |
| | | } |
| | | tbody.innerHTML = rows.map(r => { |
| | | const roundLabel = (r.roundNum === null || r.roundNum === undefined) ? '进行中' : ('第 ' + r.roundNum + ' 轮'); |
| | | return ` |
| | | <tr> |
| | | <td>${esc(roundLabel)}</td> |
| | | <td>${r.longLossCount ?? 0}</td> |
| | | <td>${r.shortLossCount ?? 0}</td> |
| | | </tr>`; |
| | | }).join(''); |
| | | } |
| | | |
| | | function refreshRoundStopLoss() { |
| | | if (selectedMd5) loadRoundStopLoss(selectedMd5); |
| | | } |
| | | |
| | | // ==================== PNL 图表 ==================== |
| | | function renderPnlChart() { |
| | | const canvas = document.getElementById('pnlChart'); |