feat(backtest): 回测结算持久化、按配置重新测试、执行时以当前时间为窗口基准

- 持久化: BUY/SELL 与 SETTLEMENT(WIN/LOSE/UNKNOWN/CLOSED) 均写入 backtest_trade
- 重新测试: 已完成任务支持「按当前配置重新测试」,新任务名称可编辑,后端 POST /tasks/rerun + 前端按钮与确认弹窗
- 回测窗口: 首次执行以当前时间为终点、startTime = endTime - backtestDays(局部变量,不修改实体)
- 新增错误码 BACKTEST_TASK_NOT_COMPLETED、SERVER_BACKTEST_RERUN_FAILED 及多语言

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
WrBug
2026-02-09 01:08:40 +08:00
co-authored by Cursor
parent 01a1836659
commit b1ad6f02d2
20 changed files with 526 additions and 199 deletions
+67
View File
@@ -0,0 +1,67 @@
import React from 'react'
import { Select } from 'antd'
import type { Leader } from '../types'
const { Option } = Select
interface LeaderSelectProps {
value?: number
onChange?: (value: number | undefined) => void
onSelectChange?: (value: number | undefined) => void // 选择变化时的回调
leaders: Leader[]
placeholder?: string
disabled?: boolean
showSearch?: boolean
allowClear?: boolean
notFoundContent?: React.ReactNode
}
const LeaderSelect: React.FC<LeaderSelectProps> = ({
value,
onChange,
onSelectChange,
leaders,
placeholder,
disabled,
showSearch = true,
allowClear = false,
notFoundContent
}) => {
// 处理选择变化
const handleChange = (val: number | undefined) => {
if (onChange) {
onChange(val)
}
if (onSelectChange) {
onSelectChange(val)
}
}
return (
<Select
value={value}
onChange={handleChange}
placeholder={placeholder}
disabled={disabled}
showSearch={showSearch}
allowClear={allowClear}
notFoundContent={notFoundContent}
optionFilterProp="label"
optionLabelProp="label"
>
{leaders.map(leader => {
const label = leader.leaderName || `Leader ${leader.id}`
return (
<Option key={leader.id} value={leader.id} label={label}>
<div style={{ display: 'flex', flexDirection: 'column' }}>
<span>{label}</span>
<span style={{ fontSize: '12px', color: '#999' }}>{leader.leaderAddress}</span>
</div>
</Option>
)
})}
</Select>
)
}
export default LeaderSelect