feat: 自我进化模块——health_monitor+lesson_extractor+evolution_api+Dashboard+auto_iterator
This commit is contained in:
+30
-1
@@ -1929,7 +1929,8 @@ function inMd(t) {
|
||||
function renderResearch() {
|
||||
const el = document.getElementById('tab-research');
|
||||
if (!el) return;
|
||||
el.innerHTML = '<div class="flex gap-2 items-center mb-3 flex-wrap">' +
|
||||
el.innerHTML = '<div id="evo-box" class="mb-3 bg-slate-800/60 border border-slate-700 rounded-lg p-3"><div class="text-xs text-slate-500">🧬 进化模块加载中...</div></div>' +
|
||||
'<div class="flex gap-2 items-center mb-3 flex-wrap">' +
|
||||
'<h2 class="text-lg font-bold">📋 策略研究 — 版本迭代对比</h2>' +
|
||||
'<select id="btPeriod" onchange="saveBtPeriod()" class="bg-slate-800 text-sm rounded-lg px-2 py-1 border border-slate-700">' +
|
||||
'<option value="1m">近 1 个月</option><option value="6m">近 6 个月</option>' +
|
||||
@@ -1972,6 +1973,34 @@ async function loadStrategyList() {
|
||||
}
|
||||
|
||||
const ASC_DEFAULT = new Set(['max_dd']); // 回撤类:小=好,默认升序
|
||||
async function loadEvolutionBox() {
|
||||
const box = document.getElementById('evo-box');
|
||||
if (!box) return;
|
||||
try {
|
||||
const r = await fetch('/api/evolution/dashboard');
|
||||
const d = await r.json();
|
||||
let h = '<div class="flex items-center justify-between mb-1"><span class="text-xs font-semibold text-emerald-400">🧬 策略自我进化</span><button onclick="loadEvolutionBox()" class="text-[10px] text-blue-400">刷新</button></div>';
|
||||
if (d.baseline) {
|
||||
h += '<div class="grid grid-cols-3 gap-2 mb-2">';
|
||||
for (const [v, b] of Object.entries(d.baseline)) {
|
||||
const clr = v === 'v_next4' ? 'text-emerald-400' : 'text-slate-300';
|
||||
h += '<div class="bg-slate-900/50 rounded px-2 py-1"><span class="'+clr+' font-mono font-bold text-xs">'+v+'</span><br><span class="text-slate-500 text-[10px]">胜率'+b.win_rate+'% 收益'+b.total_return+'%</span></div>';
|
||||
}
|
||||
h += '</div>';
|
||||
}
|
||||
if (d.health && d.health.length > 0) { const hs = d.health[0]; const sc = hs.health_score;
|
||||
const color = sc >= 70 ? 'text-emerald-400' : sc >= 50 ? 'text-amber-400' : 'text-red-400';
|
||||
h += '<div class="text-xs '+color+'">健康度: '+sc+'分 (实盘'+hs.live_trades+'笔)</div>'; }
|
||||
if (d.lessons && d.lessons.length > 0) {
|
||||
h += '<div class="text-xs text-slate-500 mt-1">最近教训:</div>';
|
||||
for (const l of d.lessons.slice(0,3)) h += '<div class="text-xs text-slate-400">'+(l.lesson_type==='win_pattern'?'✅':'❌')+' '+l.lesson_text+'</div>';
|
||||
}
|
||||
box.innerHTML = h;
|
||||
} catch (e) { box.innerHTML = '<div class="text-xs text-red-400">加载失败</div>'; }
|
||||
}
|
||||
// 研究Tab活跃时加载进化模块
|
||||
new MutationObserver(()=>{if(!document.getElementById('tab-research')?.classList?.contains('hidden'))loadEvolutionBox();}).observe(document.body,{attributes:true,subtree:true});
|
||||
|
||||
function showDesc(version) {
|
||||
const s = (window._strats || []).find(x => x.version === version);
|
||||
const d = s && s.description;
|
||||
|
||||
Reference in New Issue
Block a user