Files
qlib/backend/app/domain/repositories/strategy.py
T
Simon 9d25d466e5 feat(strategy): M8.3 策略模型 + /api/strategies(命名配置资产,可展开为 ResearchSpec)
- StrategyDefinition:universe/factors/selection/rebalance/costs/portfolio +
  price_adjustment(除 period 外完整策略定义);to_research_spec(period) 展开为标准 Spec
- strategy 表(migration e1f2a3b4c5d6,MySQL 已应用;name 唯一)+ StrategyRepository
- /api/strategies:POST/GET/DELETE + POST /{id}/expand(period+initial_capital → ResearchSpec)
- tests/test_strategies.py(repo CRUD/同名/expand、API CRUD/400/404);全量 pytest 通过
2026-09-09 00:38:09 +08:00

21 lines
588 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""策略 Repository Protocol(M8.3)。"""
from __future__ import annotations
from typing import Protocol
from app.domain.entities.strategy import StrategyDefinition
class StrategyRepository(Protocol):
def save(self, definition: StrategyDefinition) -> StrategyDefinition:
"""新建(name 冲突抛 ValueError)。"""
def get(self, strategy_id: str) -> StrategyDefinition | None: ...
def get_by_name(self, name: str) -> StrategyDefinition | None: ...
def list(self) -> list[StrategyDefinition]: ...
def delete(self, strategy_id: str) -> bool: ...