refactor: unify data preparations and research input snapshots
Deploy production / deploy (push) Successful in 53s

This commit is contained in:
yuxuanhui
2026-09-12 01:24:02 +08:00
parent 849f86fef7
commit 394438e753
82 changed files with 4146 additions and 2076 deletions
+29 -1
View File
@@ -1,3 +1,8 @@
import {
ResearchDataInput,
researchSelection,
} from "../preparations/ResearchDataInput";
import type { InputSnapshot } from "../research/workspaceTypes";
import { useCallback, useEffect, useState } from "react";
import {
Banner,
@@ -70,6 +75,8 @@ export function BacktestPage({
const [editor, setEditor] = useState(false);
const [draft, setDraft] = useState<Draft | null>(null);
const [name, setName] = useState("");
const [inputIds, setInputIds] = useState<string[]>([]);
const [inputs, setInputs] = useState<InputSnapshot[]>([]);
const [source, setSource] = useState<Source>({ kind: "manual" });
const [text, setText] = useState("");
const [mode, setMode] = useState("lines");
@@ -215,6 +222,8 @@ export function BacktestPage({
setDraft(null);
setName("");
setSource({ kind: "manual" });
setInputIds([]);
setInputs([]);
setText("");
setSettings(initialSettings);
setMode("lines");
@@ -241,7 +250,7 @@ export function BacktestPage({
}));
if (!Array.isArray(candidates) || !candidates.length)
throw new Error("请提供非空候选集合");
return { name, source, candidates };
return { name, source, candidates, ...researchSelection(inputIds, inputs) };
}
async function loadDraft(id: string) {
setSettingsDraft(null);
@@ -249,6 +258,8 @@ export function BacktestPage({
setDraft(d);
setName(d.name);
setSource(d.source);
setInputIds(d.source.input_snapshot_ids ?? []);
setInputs([]);
setMode("json");
setText(JSON.stringify(d.candidates, null, 2));
setPreview(null);
@@ -600,6 +611,23 @@ export function BacktestPage({
maxLength={200}
/>
</label>
<ResearchDataInput
label="选择回测数据准备(可选)"
ids={inputIds}
inputs={inputs}
onChange={(ids, rows) => {
setInputIds(ids);
setInputs(rows);
const first = rows.find((r) => r.id === ids[0]);
if (first)
setSettings((old) => ({
...old,
region: first.scope.region,
universe: first.scope.universe,
delay: first.scope.delay,
}));
}}
/>
<div className="backtest-form-grid">
<label>
来源