fix: 自选按信号优先级排序+策略显示tech_snapshot/sector_context
This commit is contained in:
@@ -110,11 +110,22 @@ def api_watchlist():
|
||||
conn.row_factory = sqlite3.Row
|
||||
rows = conn.execute("""
|
||||
SELECT hs.code, hs.name, hs.entry_low, hs.entry_high, hs.stop_loss, hs.take_profit,
|
||||
hs.timing_signal, hs.action, lp.price, lp.change_pct, hs.rr_ratio, hs.updated_at
|
||||
hs.timing_signal, hs.action, lp.price, lp.change_pct, hs.rr_ratio, hs.updated_at,
|
||||
hs.tech_snapshot, hs.sector_context
|
||||
FROM holding_strategies hs
|
||||
LEFT JOIN live_prices lp ON hs.code = lp.code
|
||||
WHERE hs.status='active' AND hs.decision_type='自选策略'
|
||||
ORDER BY hs.code
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN hs.timing_signal IN ('买入','可买入','可加仓') THEN 0
|
||||
WHEN hs.timing_signal IN ('关注') THEN 1
|
||||
WHEN hs.timing_signal IN ('信号不充分') THEN 2
|
||||
WHEN hs.timing_signal IN ('持有') THEN 3
|
||||
WHEN hs.timing_signal IN ('弱势持有') THEN 4
|
||||
ELSE 5
|
||||
END,
|
||||
COALESCE(hs.rr_ratio,0) DESC,
|
||||
hs.code
|
||||
""").fetchall()
|
||||
conn.close()
|
||||
stocks = [dict(r) for r in rows]
|
||||
|
||||
+9
-1
@@ -310,9 +310,17 @@ function renderWatchlist() {
|
||||
const tp = s.take_profit || 0;
|
||||
const signal = s.timing_signal || '';
|
||||
const action = (s.action||'');
|
||||
const tech = s.tech_snapshot || '';
|
||||
const sector = s.sector_context || '';
|
||||
const price = s.price || 0;
|
||||
const chg = s.change_pct || 0;
|
||||
const priceDisplay = price ? price.toFixed(2) : '—';
|
||||
// 构建完整策略显示
|
||||
let detailLines = [];
|
||||
if (action) detailLines.push(action);
|
||||
if (tech) detailLines.push('📊 ' + tech);
|
||||
if (sector) detailLines.push('🏭 ' + sector);
|
||||
const detailText = detailLines.join(' | ');
|
||||
return `
|
||||
<tr class="border-b border-slate-800/30 hover:bg-slate-800/20 cursor-pointer" onclick="openStock('${s.code}')">
|
||||
<td class="p-3"><div class="font-medium text-white">${s.name}</div><div class="text-slate-500 text-[10px]">${s.code}</div></td>
|
||||
@@ -323,7 +331,7 @@ function renderWatchlist() {
|
||||
<td class="p-3 text-right"><span class="text-xs px-2 py-1 rounded ${signal.includes('买入')?'bg-green-900/50 text-green-300':signal.includes('关注')?'bg-yellow-900/50 text-yellow-300':'bg-slate-800 text-slate-400'}">${signal||'—'}</span></td>
|
||||
</tr>
|
||||
<tr class="border-b border-slate-800/20 hover:bg-slate-800/10 cursor-pointer" onclick="openStock('${s.code}')">
|
||||
<td colspan="6" class="p-2 pl-3 text-xs text-slate-400 leading-relaxed">${action || '—'}</td>
|
||||
<td colspan="6" class="p-2 pl-3 text-xs text-slate-400 leading-relaxed">${detailText || '—'}</td>
|
||||
</tr>`;
|
||||
}).join('')}</tbody>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user