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
+34
View File
@@ -17,6 +17,23 @@ async def fake_stream(messages, info):
str(p.content) for m in messages[latest:] for p in m.parts if isinstance(p, UserPromptPart)
)
returns = [p for m in messages[latest:] for p in m.parts if isinstance(p, ToolReturnPart)]
if returns and returns[-1].tool_name == "prepare_backtest":
content = returns[-1].content
content = json.loads(content) if isinstance(content, str) else content
yield {
0: DeltaToolCall(
name="start_backtest",
json_args=json.dumps(
{
"preview_id": content["preview_id"],
"version": 1,
"idempotency_key": content["preview_id"],
}
),
tool_call_id=uuid4().hex,
)
}
return
if returns and "LOOP" not in text:
if returns[-1].tool_name == "capability_probe":
yield str(returns[-1].content)
@@ -35,6 +52,23 @@ async def fake_stream(messages, info):
await asyncio.sleep(2)
yield ",查询完成。"
return
elif "回测" in text:
name, args = (
"prepare_backtest",
{
"inline": {
"name": "AI 固定回测",
"source": {"kind": "ai"},
"candidates": [
{
"client_item_id": "ai-1",
"expression": "rank(close)",
"settings": {"region": "USA", "universe": "TOP3000", "delay": 1},
}
],
}
},
)
elif "批量" in text:
name, args = "bulk_update_research", {"alpha_ids": ["a0000", "a0001"], "add_tags": ["AI"]}
elif "修改" in text or "update" in text: