feat(history): 任务列表加创建时间(created_at)+类型命名统一菜单(个股回测/组合回测/参数优化/因子分析)+列宽均衡(去实例列) [nas]
This commit is contained in:
@@ -18,8 +18,8 @@ const pageSize = 20
|
|||||||
|
|
||||||
const typeOptions = [
|
const typeOptions = [
|
||||||
{ key: 'all', label: '全部' },
|
{ key: 'all', label: '全部' },
|
||||||
{ key: 'cta', label: '回测' },
|
{ key: 'cta', label: '个股回测' },
|
||||||
{ key: 'portfolio', label: '组合' },
|
{ key: 'portfolio', label: '组合回测' },
|
||||||
{ key: 'optimize', label: '参数优化' },
|
{ key: 'optimize', label: '参数优化' },
|
||||||
{ key: 'factor', label: '因子分析' },
|
{ key: 'factor', label: '因子分析' },
|
||||||
] as const
|
] as const
|
||||||
@@ -113,7 +113,7 @@ function open(row: TaskListItem): void {
|
|||||||
else router.push(`/backtest/result/${row.task_id}`)
|
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 {
|
function typeLabel(t: string): string {
|
||||||
return typeLabelMap[t] || t
|
return typeLabelMap[t] || t
|
||||||
}
|
}
|
||||||
@@ -151,30 +151,22 @@ function statusLabel(s: string): string {
|
|||||||
|
|
||||||
<el-card v-loading="loading" class="table-card" shadow="never">
|
<el-card v-loading="loading" class="table-card" shadow="never">
|
||||||
<el-table :data="paged" size="small" empty-text="暂无符合条件的任务">
|
<el-table :data="paged" size="small" empty-text="暂无符合条件的任务">
|
||||||
<el-table-column label="任务 ID" min-width="190">
|
<el-table-column label="任务 ID" min-width="170">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }"><span class="mono">{{ row.task_id }}</span></template>
|
||||||
<span class="mono">{{ row.task_id }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="类型" width="84">
|
<el-table-column label="类型" width="96">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }"><span class="chip" :class="`chip-${row.type}`">{{ typeLabel(row.type) }}</span></template>
|
||||||
<span class="chip" :class="`chip-${row.type}`">{{ typeLabel(row.type) }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="strategy" label="策略 / 因子" min-width="160" show-overflow-tooltip />
|
<el-table-column prop="strategy" label="策略 / 因子" min-width="130" show-overflow-tooltip />
|
||||||
<el-table-column prop="instance" label="实例" min-width="160">
|
<el-table-column prop="symbol" label="标的" width="100" />
|
||||||
<template #default="{ row }"><span class="mono">{{ row.instance || '—' }}</span></template>
|
<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>
|
||||||
<el-table-column prop="symbol" label="标的" width="92" />
|
<el-table-column label="回测区间" min-width="150">
|
||||||
<el-table-column label="状态" width="84">
|
<template #default="{ row }"><span class="mono muted">{{ row.start }} ~ {{ row.end }}</span></template>
|
||||||
<template #default="{ row }">
|
|
||||||
<span class="chip" :class="`st-${row.status}`">{{ statusLabel(row.status) }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="时间区间" min-width="180">
|
<el-table-column label="创建时间" width="150">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }"><span class="mono muted">{{ row.created_at ? row.created_at.slice(0, 16) : '—' }}</span></template>
|
||||||
<span class="muted">{{ row.start }} ~ {{ row.end }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="76" fixed="right">
|
<el-table-column label="操作" width="76" fixed="right">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
|
|||||||
@@ -357,6 +357,7 @@ def list_tasks(type: str | None = None, status: str | None = None):
|
|||||||
"symbol": spec.get("symbol", "") or spec.get("benchmark", ""),
|
"symbol": spec.get("symbol", "") or spec.get("benchmark", ""),
|
||||||
"start": spec.get("start", ""),
|
"start": spec.get("start", ""),
|
||||||
"end": spec.get("end", ""),
|
"end": spec.get("end", ""),
|
||||||
|
"created_at": "",
|
||||||
})
|
})
|
||||||
seen.add(tid)
|
seen.add(tid)
|
||||||
|
|
||||||
@@ -376,6 +377,7 @@ def list_tasks(type: str | None = None, status: str | None = None):
|
|||||||
"symbol": r.symbol,
|
"symbol": r.symbol,
|
||||||
"start": r.start,
|
"start": r.start,
|
||||||
"end": r.end,
|
"end": r.end,
|
||||||
|
"created_at": r.created_at,
|
||||||
})
|
})
|
||||||
|
|
||||||
active.reverse() # 最新提交的 running 在最上
|
active.reverse() # 最新提交的 running 在最上
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class BacktestResult:
|
|||||||
trades: Optional[pd.DataFrame] = None
|
trades: Optional[pd.DataFrame] = None
|
||||||
error_msg: Optional[str] = None
|
error_msg: Optional[str] = None
|
||||||
id: Optional[int] = None
|
id: Optional[int] = None
|
||||||
|
created_at: Optional[str] = None # 任务创建时间(DB TIMESTAMP)
|
||||||
|
|
||||||
|
|
||||||
# SQLite schema for backtest stats
|
# 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 {},
|
statistics=json.loads(d["statistics"]) if d["statistics"] else {},
|
||||||
equity_curve=equity,
|
equity_curve=equity,
|
||||||
trades=trades,
|
trades=trades,
|
||||||
error_msg=d.get("error_msg")
|
error_msg=d.get("error_msg"),
|
||||||
|
created_at=d.get("created_at"),
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user