feat: add durable WorldQuant backtests with UI and AI confirmation

This commit is contained in:
yuxuanhui
2026-09-08 10:06:00 +08:00
parent 404a4d8a04
commit a4b93200c5
34 changed files with 4437 additions and 23 deletions
+11 -3
View File
@@ -18,6 +18,7 @@ import {
post,
stateLabels,
} from "../api";
import { BacktestToolCard } from "../backtests/BacktestToolCard";
import { PnlChart } from "../components/PnlChart";
import type { Alpha, Job, Pnl, Research } from "../types";
import { chatTransport } from "./transport";
@@ -85,6 +86,8 @@ export function ChatPanel({
"create_sync_job",
"cancel_job",
"retry_job",
"start_backtest",
"control_backtest",
].includes(call.name) &&
!seenWrites.current.has(call.id)
) {
@@ -434,9 +437,11 @@ export function ChatPanel({
</div>
<footer className="ai-composer" ref={input}>
<div className="ai-context">
{context.page === "account"
? "上下文:个人信息页"
: `上下文:${context.alpha_id ? `Alpha ${context.alpha_id}` : "Alpha 列表"}${context.selected_ids?.length ? ` · 已选 ${context.selected_ids.length} 条` : ""}`}
{context.page === "backtests"
? "上下文:回测研究"
: context.page === "account"
? "上下文:个人信息页"
: `上下文:${context.alpha_id ? `Alpha ${context.alpha_id}` : "Alpha 列表"}${context.selected_ids?.length ? ` · 已选 ${context.selected_ids.length} 条` : ""}`}
</div>
<TextArea
aria-label="发送给研究助手"
@@ -537,6 +542,9 @@ function BusinessCard({
{labels[call.status] ?? call.status}
</Tag>
</div>
{call.name.includes("backtest") && (
<BacktestToolCard call={call} onAction={onAction} />
)}
{call.preview.targets?.map((target) => (
<details
key={target.alpha_id}
+21 -1
View File
@@ -11,12 +11,20 @@ export type ModelSettings = {
test_results: Record<string, { ok: boolean; message: string }>;
};
export type PageContext = {
page: "alphas" | "account";
page: "alphas" | "account" | "backtests";
backtest_run_id?: string;
backtest_preview_id?: string;
backtest_draft_id?: string;
alpha_id?: string | null;
selected_ids?: string[];
filters?: Record<string, unknown>;
};
export type AlphaUIAction =
| { type: "open_alpha"; alpha_id: string; nonce: number }
| { type: "apply_filters"; filters: Record<string, unknown>; nonce: number };
export type UIAction =
| { type: "open_backtest"; run_id: string; nonce: number }
| { type: "open_backtest_preview"; preview_id: string; nonce: number }
| { type: "open_alpha"; alpha_id: string; nonce: number }
| { type: "apply_filters"; filters: Record<string, unknown>; nonce: number };
export type ToolCard = {
@@ -27,6 +35,9 @@ export type ToolCard = {
targets?: { alpha_id: string; before: Research; after: Research }[];
job?: Record<string, unknown>;
operation?: Record<string, unknown>;
backtest?: Record<string, unknown>;
backtest_run?: Record<string, unknown>;
action?: string;
};
result: Record<string, unknown> | null;
};
@@ -64,6 +75,15 @@ export const runLabels: Record<string, string> = {
interrupted: "执行中断",
};
export const toolLabels: Record<string, string> = {
get_backtest_capabilities: "读取回测能力",
prepare_backtest: "准备回测预览",
get_backtest_preview: "查看回测预览",
start_backtest: "启动固定回测",
list_backtests: "查询回测运行",
get_backtest: "查看回测进度",
get_backtest_results: "读取回测结果",
control_backtest: "控制回测运行",
prepare_backtest_rerun: "准备重跑预览",
search_alphas: "查询 Alpha",
get_alpha_facets: "查询筛选选项",
get_alpha: "读取 Alpha",