feat(s3): 历史任务 + 参数优化端到端跑通
- result_store.load_result_by_task_id + orchestrator.get_result DB 兜底(历史回看)
- GET /task 列表、GET /task/{id}/optimization-results
- Task.raw_result 存优化结果 list(内存)
- cta_optimizer 修同款 bug(interval d / capital 1M / vnpy DB SETTINGS)
- get_status 返回 error_msg(str 守卫)
- 前端 优化页(网格输入+轮询+结果表)、历史页(任务列表+回看)、侧栏子菜单
- 修 5 个旧 test_routes 回归;73 tests passed
- 冒烟:历史 3 任务 + 优化 9 组合
This commit is contained in:
@@ -22,7 +22,8 @@ def test_submit_cta_backtest():
|
||||
token = create_token("admin")
|
||||
|
||||
# Mock get_orchestrator to return mock orchestrator
|
||||
with patch("sanguo_api.routes.get_orchestrator") as mock_get_orch:
|
||||
with patch("sanguo_api.routes.get_orchestrator") as mock_get_orch, \
|
||||
patch("sanguo_api.routes.get_strategy_class", return_value=Mock()):
|
||||
mock_orch = Mock()
|
||||
mock_orch.submit_cta = AsyncMock(return_value="cta_test_123")
|
||||
mock_get_orch.return_value = mock_orch
|
||||
@@ -148,9 +149,13 @@ def test_get_task_result():
|
||||
token = create_token("admin")
|
||||
|
||||
with patch("sanguo_api.routes.get_orchestrator") as mock_get_orch:
|
||||
from sanguo_backtest.result_store import BacktestResult
|
||||
mock_orch = Mock()
|
||||
mock_result = Mock()
|
||||
mock_result.statistics = {"total_trades": 10, "total_return": 0.15}
|
||||
mock_result = BacktestResult(
|
||||
task_id="cta_test_123", type="cta", status="done", strategy="S", symbol="600000",
|
||||
params={}, start="2024-01-01", end="2024-12-31",
|
||||
statistics={"total_trades": 10, "total_return": 0.15},
|
||||
)
|
||||
mock_orch.get_result.return_value = mock_result
|
||||
mock_get_orch.return_value = mock_orch
|
||||
|
||||
@@ -205,7 +210,8 @@ def test_submit_optimize_returns_pending():
|
||||
app = create_app(db_path=db_path, file_dir=None)
|
||||
token = create_token("admin")
|
||||
|
||||
with patch("sanguo_api.routes.get_orchestrator") as mock_get_orch:
|
||||
with patch("sanguo_api.routes.get_orchestrator") as mock_get_orch, \
|
||||
patch("sanguo_api.routes.get_strategy_class", return_value=Mock()):
|
||||
mock_orch = Mock()
|
||||
mock_orch.submit_optimize = AsyncMock(return_value="opt_test_123")
|
||||
mock_get_orch.return_value = mock_orch
|
||||
@@ -322,7 +328,8 @@ def test_optimize_route_calls_submit(tmp_path):
|
||||
client = TestClient(app)
|
||||
token = create_token("admin")
|
||||
|
||||
with patch("sanguo_api.routes.get_orchestrator") as m:
|
||||
with patch("sanguo_api.routes.get_orchestrator") as m, \
|
||||
patch("sanguo_api.routes.get_strategy_class", return_value=Mock()):
|
||||
orch = Mock()
|
||||
orch.submit_optimize = AsyncMock(return_value="opt_1")
|
||||
m.return_value = orch
|
||||
|
||||
Reference in New Issue
Block a user