feat(history): 任务列表加创建时间(created_at)+类型命名统一菜单(个股回测/组合回测/参数优化/因子分析)+列宽均衡(去实例列) [nas]
CI/CD / test (push) Successful in 17s
CI/CD / nas-deploy (push) Successful in 22s
CI/CD / nas-verify (push) Successful in 8s

This commit is contained in:
2026-08-13 14:04:57 +08:00
parent b99e58bca1
commit 5248062102
3 changed files with 20 additions and 24 deletions
+15 -23
View File
@@ -18,8 +18,8 @@ const pageSize = 20
const typeOptions = [
{ key: 'all', label: '全部' },
{ key: 'cta', label: '回测' },
{ key: 'portfolio', label: '组合' },
{ key: 'cta', label: '个股回测' },
{ key: 'portfolio', label: '组合回测' },
{ key: 'optimize', label: '参数优化' },
{ key: 'factor', label: '因子分析' },
] as const
@@ -113,7 +113,7 @@ function open(row: TaskListItem): void {
else router.push(`/backtest/result/${row.task_id}`)
}
const typeLabelMap: Record<string, string> = { cta: '回测', portfolio: '组合', optimize: '优化', factor: '因子' }
const typeLabelMap: Record<string, string> = { cta: '个股回测', portfolio: '组合回测', optimize: '参数优化', factor: '因子分析' }
function typeLabel(t: string): string {
return typeLabelMap[t] || t
}
@@ -151,30 +151,22 @@ function statusLabel(s: string): string {
<el-card v-loading="loading" class="table-card" shadow="never">
<el-table :data="paged" size="small" empty-text="暂无符合条件的任务">
<el-table-column label="任务 ID" min-width="190">
<template #default="{ row }">
<span class="mono">{{ row.task_id }}</span>
</template>
<el-table-column label="任务 ID" min-width="170">
<template #default="{ row }"><span class="mono">{{ row.task_id }}</span></template>
</el-table-column>
<el-table-column label="类型" width="84">
<template #default="{ row }">
<span class="chip" :class="`chip-${row.type}`">{{ typeLabel(row.type) }}</span>
</template>
<el-table-column label="类型" width="96">
<template #default="{ row }"><span class="chip" :class="`chip-${row.type}`">{{ typeLabel(row.type) }}</span></template>
</el-table-column>
<el-table-column prop="strategy" label="策略 / 因子" min-width="160" show-overflow-tooltip />
<el-table-column prop="instance" label="实例" min-width="160">
<template #default="{ row }"><span class="mono">{{ row.instance || '—' }}</span></template>
<el-table-column prop="strategy" label="策略 / 因子" min-width="130" show-overflow-tooltip />
<el-table-column prop="symbol" label="标的" width="100" />
<el-table-column label="状态" width="88">
<template #default="{ row }"><span class="chip" :class="`st-${row.status}`">{{ statusLabel(row.status) }}</span></template>
</el-table-column>
<el-table-column prop="symbol" label="标的" width="92" />
<el-table-column label="状态" width="84">
<template #default="{ row }">
<span class="chip" :class="`st-${row.status}`">{{ statusLabel(row.status) }}</span>
</template>
<el-table-column label="回测区间" min-width="150">
<template #default="{ row }"><span class="mono muted">{{ row.start }} ~ {{ row.end }}</span></template>
</el-table-column>
<el-table-column label="时间区间" min-width="180">
<template #default="{ row }">
<span class="muted">{{ row.start }} ~ {{ row.end }}</span>
</template>
<el-table-column label="创建时间" width="150">
<template #default="{ row }"><span class="mono muted">{{ row.created_at ? row.created_at.slice(0, 16) : '—' }}</span></template>
</el-table-column>
<el-table-column label="操作" width="76" fixed="right">
<template #default="{ row }">
+2
View File
@@ -357,6 +357,7 @@ def list_tasks(type: str | None = None, status: str | None = None):
"symbol": spec.get("symbol", "") or spec.get("benchmark", ""),
"start": spec.get("start", ""),
"end": spec.get("end", ""),
"created_at": "",
})
seen.add(tid)
@@ -376,6 +377,7 @@ def list_tasks(type: str | None = None, status: str | None = None):
"symbol": r.symbol,
"start": r.start,
"end": r.end,
"created_at": r.created_at,
})
active.reverse() # 最新提交的 running 在最上
+3 -1
View File
@@ -46,6 +46,7 @@ class BacktestResult:
trades: Optional[pd.DataFrame] = None
error_msg: Optional[str] = None
id: Optional[int] = None
created_at: Optional[str] = None # 任务创建时间(DB TIMESTAMP)
# SQLite schema for backtest stats
@@ -190,7 +191,8 @@ def load_result(rid: int, db_path: str) -> BacktestResult:
statistics=json.loads(d["statistics"]) if d["statistics"] else {},
equity_curve=equity,
trades=trades,
error_msg=d.get("error_msg")
error_msg=d.get("error_msg"),
created_at=d.get("created_at"),
)
finally:
conn.close()