feat: API+UI近5年区间切换(补)

This commit is contained in:
hmo
2026-07-30 10:05:16 +08:00
parent 1f57dac605
commit 6f4be02a90
2 changed files with 8 additions and 5 deletions
+3 -2
View File
@@ -535,10 +535,11 @@ def get_tracking():
@app.route("/api/research/strategies")
def api_research_strategies():
"""策略版本列表(含回测结果摘要)"""
"""策略版本列表(含回测结果摘要,支持 period_tag 区间过滤"""
try:
from strategy_lab import list_strategies
return jsonify({'strategies': list_strategies()})
pt = request.args.get('period_tag')
return jsonify({'strategies': list_strategies(period_tag=pt)})
except Exception as e:
return jsonify({'error': str(e)}), 500
+5 -3
View File
@@ -1931,9 +1931,9 @@ function renderResearch() {
if (!el) return;
el.innerHTML = '<div class="flex gap-2 items-center mb-3 flex-wrap">' +
'<h2 class="text-lg font-bold">📋 策略研究 — 版本迭代对比</h2>' +
'<select id="btPeriod" class="bg-slate-800 text-sm rounded-lg px-2 py-1 border border-slate-700">' +
'<select id="btPeriod" onchange="loadStrategyList()" 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>' +
'<option value="1y">近 1 年</option><option value="2y" selected>近 2 年</option></select>' +
'<option value="1y">近 1 年</option><option value="2y" selected>近 2 年</option><option value="5y">近 5 年</option></select>' +
'<select id="btMarket" class="bg-slate-800 text-sm rounded-lg px-2 py-1 border border-slate-700" onchange="loadStrategyList()">' +
'<option value="all">全部市场</option><option value="a">A股</option><option value="hk">港股</option></select>' +
'<span class="text-xs text-slate-500">每版策略基于上一版归因分析迭代 · 点击行展开明细</span></div>' +
@@ -1945,7 +1945,9 @@ function renderResearch() {
async function loadStrategyList() {
const listEl = document.getElementById('strategyList');
try {
const resp = await fetch('/api/research/strategies');
const ptMap = {'1m':'1m','6m':'6m','1y':'1y','2y':'2y','5y':'5y'};
const pt = ptMap[document.getElementById('btPeriod')?.value || '2y'] || '2y';
const resp = await fetch('/api/research/strategies?period_tag=' + pt);
const data = await resp.json();
if (data.error) { listEl.innerHTML = '<div class="text-red-400">' + data.error + '</div>'; return; }
const mkt = document.getElementById('btMarket')?.value || 'all';