- 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 通过
21 lines
588 B
Python
21 lines
588 B
Python
"""策略 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: ...
|