Files
qlib/backend/app/domain/repositories/signal.py
T
Simon 995ed08548 feat(chart): M9-1 Chart DTO + Chart Service + Chart API(v3 §20)
- domain/entities/chart.py:ChartResult/OHLC/Volume/Series/EventMarker/ChartMetadata
  (adjust_mode + execution_price_basis 口径元数据)+ SelectionHit
- application/services/chart_service.py:个股 K线/量/MA 指标;显示层 qfq/hfq 折算
  (基于主口径 none 行情 × adjust_factor,绝回写研究数据);回测个股视图把实际成交
  转 fills 标记并在显示口径不同时做坐标换算(v3 §20.3/§20.5)
- by-symbol 历史查询:SignalRepository/SelectionRepository.list_by_symbol(含溯源 id)
- api/charts.py:/stocks/{symbol}/chart|signals|selections、/backtests/{id}/stocks/{symbol}/chart
  |trades|positions
- tests/test_charts.py(指标/qfq-hfq 折算断言/回测 fills/API 集成+404);全量 pytest 通过
2026-09-09 07:09:52 +08:00

23 lines
752 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.
"""Signal Repository Protocol(M8.1 落库)。"""
from __future__ import annotations
from datetime import date
from typing import Protocol
from app.domain.entities.signal import SignalHit, SignalMeta, SignalResult
class SignalRepository(Protocol):
def save(self, signal_id: str, result: SignalResult) -> None:
"""snapshot 一行 + 事件逐行(同事务,调用方 commit)。"""
def get(self, signal_id: str) -> SignalResult | None: ...
def list_recent(
self, as_of: date | None = None, limit: int = 20
) -> list[SignalMeta]: ...
def list_by_symbol(self, symbol: str, limit: int = 50) -> list[SignalHit]:
"""该股在历史信号中的命中(Chart 标记用,含 signal_id 溯源)。"""