Dev backtest (#1134)

This commit is contained in:
Rick
2025-11-28 21:34:27 +08:00
committed by GitHub
parent 04f006abad
commit 11b6c6ba3e
39 changed files with 9293 additions and 125 deletions

View File

@@ -9,6 +9,7 @@ export const translations = {
details: 'Details',
tradingPanel: 'Trading Panel',
competition: 'Competition',
backtest: 'Backtest',
running: 'RUNNING',
stopped: 'STOPPED',
adminMode: 'Admin Mode',
@@ -82,6 +83,168 @@ export const translations = {
currentGap: 'Current Gap',
count: '{count} pts',
// Backtest Page
backtestPage: {
title: 'Backtest Lab',
subtitle: 'Pick a model + time range to replay the full AI decision loop.',
start: 'Start Backtest',
starting: 'Starting...',
quickRanges: {
h24: '24h',
d3: '3d',
d7: '7d',
},
actions: {
pause: 'Pause',
resume: 'Resume',
stop: 'Stop',
},
states: {
running: 'Running',
paused: 'Paused',
completed: 'Completed',
failed: 'Failed',
liquidated: 'Liquidated',
},
form: {
aiModelLabel: 'AI Model',
selectAiModel: 'Select AI model',
providerLabel: 'Provider',
statusLabel: 'Status',
enabled: 'Enabled',
disabled: 'Disabled',
noModelWarning:
'Please add and enable an AI model on the Model Config page first.',
runIdLabel: 'Run ID',
runIdPlaceholder: 'Leave blank to auto-generate',
decisionTfLabel: 'Decision TF',
cadenceLabel: 'Decision cadence (bars)',
timeRangeLabel: 'Time range',
symbolsLabel: 'Symbols (comma-separated)',
customTfPlaceholder: 'Custom TFs (comma separated, e.g. 2h,6h)',
initialBalanceLabel: 'Initial balance (USDT)',
feeLabel: 'Fee (bps)',
slippageLabel: 'Slippage (bps)',
btcEthLeverageLabel: 'BTC/ETH leverage (x)',
altcoinLeverageLabel: 'Altcoin leverage (x)',
fillPolicies: {
nextOpen: 'Next open',
barVwap: 'Bar VWAP',
midPrice: 'Mid price',
},
promptPresets: {
baseline: 'Baseline',
aggressive: 'Aggressive',
conservative: 'Conservative',
scalping: 'Scalping',
},
cacheAiLabel: 'Reuse AI cache',
replayOnlyLabel: 'Replay only',
overridePromptLabel: 'Use only custom prompt',
customPromptLabel: 'Custom prompt (optional)',
customPromptPlaceholder:
'Append or fully customize the strategy prompt',
},
runList: {
title: 'Runs',
count: 'Total {count} records',
},
filters: {
allStates: 'All states',
searchPlaceholder: 'Run ID / label',
},
tableHeaders: {
runId: 'Run ID',
label: 'Label',
state: 'State',
progress: 'Progress',
equity: 'Equity',
lastError: 'Last Error',
updated: 'Updated',
},
emptyStates: {
noRuns: 'No runs yet',
selectRun: 'Select a run to view details',
},
detail: {
tfAndSymbols: 'TF: {tf} · Symbols {count}',
labelPlaceholder: 'Label note',
saveLabel: 'Save',
deleteLabel: 'Delete',
exportLabel: 'Export',
errorLabel: 'Error',
},
toasts: {
selectModel: 'Please select an AI model first.',
modelDisabled: 'AI model {name} is disabled.',
invalidRange: 'End time must be later than start time.',
startSuccess: 'Backtest {id} started.',
startFailed: 'Failed to start. Please try again later.',
actionSuccess: '{action} {id} succeeded.',
actionFailed: 'Operation failed. Please try again later.',
labelSaved: 'Label updated.',
labelFailed: 'Failed to update label.',
confirmDelete: 'Delete backtest {id}? This action cannot be undone.',
deleteSuccess: 'Backtest record deleted.',
deleteFailed: 'Failed to delete. Please try again later.',
traceFailed: 'Failed to fetch AI trace.',
exportSuccess: 'Exported data for {id}.',
exportFailed: 'Failed to export.',
},
aiTrace: {
title: 'AI Trace',
clear: 'Clear',
cyclePlaceholder: 'Cycle',
fetch: 'Fetch',
prompt: 'Prompt',
cot: 'Chain of thought',
output: 'Output',
cycleTag: 'Cycle #{cycle}',
},
decisionTrail: {
title: 'AI Decision Trail',
subtitle: 'Showing last {count} cycles',
empty: 'No records yet',
emptyHint: 'The AI thought & execution log will appear once the run starts.',
},
charts: {
equityTitle: 'Equity Curve',
equityEmpty: 'No data yet',
},
metrics: {
title: 'Metrics',
totalReturn: 'Total Return %',
maxDrawdown: 'Max Drawdown %',
sharpe: 'Sharpe',
profitFactor: 'Profit Factor',
pending: 'Calculating...',
realized: 'Realized PnL',
unrealized: 'Unrealized PnL',
},
trades: {
title: 'Trade Events',
headers: {
time: 'Time',
symbol: 'Symbol',
action: 'Action',
qty: 'Qty',
leverage: 'Leverage',
pnl: 'PnL',
},
empty: 'No trades yet',
},
metadata: {
title: 'Metadata',
created: 'Created',
updated: 'Updated',
processedBars: 'Processed Bars',
maxDrawdown: 'Max DD',
liquidated: 'Liquidated',
yes: 'Yes',
no: 'No',
},
},
// Competition Page
aiCompetition: 'AI Competition',
traders: 'traders',
@@ -872,6 +1035,7 @@ export const translations = {
details: '详情',
tradingPanel: '交易面板',
competition: '竞赛',
backtest: '回测',
running: '运行中',
stopped: '已停止',
adminMode: '管理员模式',
@@ -945,6 +1109,166 @@ export const translations = {
currentGap: '当前差距',
count: '{count} 个',
// Backtest Page
backtestPage: {
title: '回测实验室',
subtitle: '选择模型与时间范围,快速复盘 AI 决策链路。',
start: '启动回测',
starting: '启动中...',
quickRanges: {
h24: '24小时',
d3: '3天',
d7: '7天',
},
actions: {
pause: '暂停',
resume: '恢复',
stop: '停止',
},
states: {
running: '运行中',
paused: '已暂停',
completed: '已完成',
failed: '失败',
liquidated: '已爆仓',
},
form: {
aiModelLabel: 'AI 模型',
selectAiModel: '选择AI模型',
providerLabel: 'Provider',
statusLabel: '状态',
enabled: '已启用',
disabled: '未启用',
noModelWarning: '请先在「模型配置」页面添加并启用AI模型。',
runIdLabel: 'Run ID',
runIdPlaceholder: '留空则自动生成',
decisionTfLabel: '决策周期',
cadenceLabel: '决策节奏(根数)',
timeRangeLabel: '时间范围',
symbolsLabel: '交易标的(逗号分隔)',
customTfPlaceholder: '自定义周期(逗号分隔,例如 2h,6h',
initialBalanceLabel: '初始资金 (USDT)',
feeLabel: '手续费 (bps)',
slippageLabel: '滑点 (bps)',
btcEthLeverageLabel: 'BTC/ETH 杠杆 (倍)',
altcoinLeverageLabel: '山寨币杠杆 (倍)',
fillPolicies: {
nextOpen: '下一根开盘价',
barVwap: 'K线 VWAP',
midPrice: '中间价',
},
promptPresets: {
baseline: '基础版',
aggressive: '激进版',
conservative: '稳健版',
scalping: '剥头皮',
},
cacheAiLabel: '复用AI缓存',
replayOnlyLabel: '仅回放记录',
overridePromptLabel: '仅使用自定义提示词',
customPromptLabel: '自定义提示词(可选)',
customPromptPlaceholder: '追加或完全自定义策略提示词',
},
runList: {
title: '运行列表',
count: '共 {count} 条记录',
},
filters: {
allStates: '全部状态',
searchPlaceholder: 'Run ID / 标签',
},
tableHeaders: {
runId: 'Run ID',
label: '标签',
state: '状态',
progress: '进度',
equity: '净值',
lastError: '最后错误',
updated: '更新时间',
},
emptyStates: {
noRuns: '暂无记录',
selectRun: '请选择一个运行查看详情',
},
detail: {
tfAndSymbols: '周期: {tf} · 币种 {count}',
labelPlaceholder: '备注标签',
saveLabel: '保存',
deleteLabel: '删除',
exportLabel: '导出',
errorLabel: '错误',
},
toasts: {
selectModel: '请先选择一个AI模型。',
modelDisabled: 'AI模型 {name} 尚未启用。',
invalidRange: '结束时间必须晚于开始时间。',
startSuccess: '回测 {id} 已启动。',
startFailed: '启动失败,请稍后再试。',
actionSuccess: '{action} {id} 成功。',
actionFailed: '操作失败,请稍后再试。',
labelSaved: '标签已更新。',
labelFailed: '更新标签失败。',
confirmDelete: '确认删除回测 {id} 吗?该操作不可恢复。',
deleteSuccess: '回测记录已删除。',
deleteFailed: '删除失败,请稍后再试。',
traceFailed: '获取AI思维链失败。',
exportSuccess: '已导出 {id} 的数据。',
exportFailed: '导出失败。',
},
aiTrace: {
title: 'AI 思维链',
clear: '清除',
cyclePlaceholder: '循环编号',
fetch: '获取',
prompt: '提示词',
cot: '思考链',
output: '输出',
cycleTag: '周期 #{cycle}',
},
decisionTrail: {
title: 'AI 决策轨迹',
subtitle: '展示最近 {count} 次循环',
empty: '暂无记录',
emptyHint: '回测运行后将自动记录每次 AI 思考与执行',
},
charts: {
equityTitle: '净值曲线',
equityEmpty: '暂无数据',
},
metrics: {
title: '指标',
totalReturn: '总收益率 %',
maxDrawdown: '最大回撤 %',
sharpe: '夏普比率',
profitFactor: '盈亏因子',
pending: '计算中...',
realized: '已实现盈亏',
unrealized: '未实现盈亏',
},
trades: {
title: '交易事件',
headers: {
time: '时间',
symbol: '币种',
action: '操作',
qty: '数量',
leverage: '杠杆',
pnl: '盈亏',
},
empty: '暂无交易',
},
metadata: {
title: '元信息',
created: '创建时间',
updated: '更新时间',
processedBars: '已处理K线',
maxDrawdown: '最大回撤',
liquidated: '是否爆仓',
yes: '是',
no: '否',
},
},
// Competition Page
aiCompetition: 'AI竞赛',
traders: '交易员',