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 通过
This commit is contained in:
Simon
2026-09-09 07:09:52 +08:00
parent 8abfd6538c
commit 995ed08548
11 changed files with 736 additions and 1 deletions
@@ -10,6 +10,7 @@ from __future__ import annotations
from datetime import date
from typing import Protocol
from app.domain.entities.chart import SelectionHit
from app.domain.entities.selection import SelectionMeta, SelectionResult
@@ -27,3 +28,6 @@ class SelectionRepository(Protocol):
limit: int = 20,
) -> list[SelectionMeta]:
"""历史选股元数据列表(按 created_at 倒序;可选 as_of/method 过滤)。"""
def list_by_symbol(self, symbol: str, limit: int = 50) -> list[SelectionHit]:
"""该股在历史选股中的命中(Chart 标记用,含 as_of/rank/reason)。"""
+4 -1
View File
@@ -5,7 +5,7 @@ from __future__ import annotations
from datetime import date
from typing import Protocol
from app.domain.entities.signal import SignalMeta, SignalResult
from app.domain.entities.signal import SignalHit, SignalMeta, SignalResult
class SignalRepository(Protocol):
@@ -17,3 +17,6 @@ class SignalRepository(Protocol):
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 溯源)。"""