diff --git a/static/index.html b/static/index.html index 7e541632..2f763e1d 100644 --- a/static/index.html +++ b/static/index.html @@ -94,6 +94,28 @@ body { background: #0f0f13; color: #e2e8f0; }

👁️ 盯盘 · 全部策略

0 + +
+
+ 信号: + + + +
+
+ 排序: + + RR ≥ + + +
+
@@ -1368,18 +1390,74 @@ function fmtFullStrategy(s) { return lines.join('\n'); } +// ── 盯盘筛选/排序状态 ── +const WATCH_SIGNALS = ['买入','可买入','可加仓','卖出','止盈','关注','观望','持有','弱势持有','信号不充分']; +let watchSigFilter = new Set(WATCH_SIGNALS); // 默认全选 +let watchChipsInit = false; + +function watchRenderChips() { + const host = document.getElementById('watchSigChips'); + if (!host) return; + host.innerHTML = WATCH_SIGNALS.map(sig => { + const on = watchSigFilter.has(sig); + const cls = on + ? 'bg-amber-500/25 text-amber-300 border-amber-500/50' + : 'bg-slate-800/50 text-slate-500 border-slate-700'; + return ``; + }).join(''); +} +function watchToggleSig(sig) { + if (watchSigFilter.has(sig)) watchSigFilter.delete(sig); + else watchSigFilter.add(sig); + watchRenderChips(); + renderWatch(); +} +function watchSigAll(all) { + watchSigFilter = all ? new Set(WATCH_SIGNALS) : new Set(); + watchRenderChips(); + renderWatch(); +} +function watchResetFilters() { + watchSigFilter = new Set(WATCH_SIGNALS); + document.getElementById('watchSortMode').value = 'default'; + document.getElementById('watchMinRR').value = ''; + watchRenderChips(); + renderWatch(); +} + async function renderWatch() { const el = document.getElementById('watchContent'); if (!el) return; try { if (watchTimer) clearInterval(watchTimer); + if (!watchChipsInit) { watchRenderChips(); watchChipsInit = true; } const data = await fetchJSON('/api/watch'); - const stocks = data.stocks || []; + let stocks = data.stocks || []; + + // ── 筛选:信号多选 + RR下限 ── + const minRR = parseFloat(document.getElementById('watchMinRR')?.value) || 0; + stocks = stocks.filter(s => { + const sig = s.timing_signal || '信号不充分'; + if (!watchSigFilter.has(sig)) return false; + if (minRR > 0 && (s.rr_ratio || 0) < minRR) return false; + return true; + }); + + // ── 排序:默认=服务端分组序;覆盖模式按选定键全组内排序 ── + const sortMode = document.getElementById('watchSortMode')?.value || 'default'; + const sorters = { + rr_desc: (a, b) => (b.rr_ratio || 0) - (a.rr_ratio || 0), + rr_asc: (a, b) => (a.rr_ratio || 0) - (b.rr_ratio || 0), + chg_desc: (a, b) => (b.change_pct || 0) - (a.change_pct || 0), + chg_asc: (a, b) => (a.change_pct || 0) - (b.change_pct || 0), + }; + if (sorters[sortMode]) stocks = [...stocks].sort(sorters[sortMode]); + document.getElementById('watchCount').textContent = stocks.length; document.getElementById('watchRefreshTime').textContent = new Date().toLocaleTimeString(); if (stocks.length === 0) { - el.innerHTML = '
暂无策略数据
'; + el.innerHTML = '
当前筛选条件下暂无个股(调整筛选或点重置)
'; return; }