feat(data): 财务/日线同步增量 + 新浪「两边一致」校验兜底 + 逐只进度

- financial 默认增量:按 A 股披露节奏判断已最新并跳过;--full 强制全量重拉
- Tushare fina_indicator 增加报告期窗口与 100 条/请求自动分页(修复老报告期静默截断)
- 新浪兜底收紧为校验兜底:两源重叠历史一致才导入缺失键,行标记 source=sina;
  财务可比字段取 eps/销售毛利率(ROE 两端口径不同不作依据),日线只比较最近重叠交易日
- CLI 输出逐只进度与导入内容描述(来源/行数/报告期与公告区间),失败股票留待重跑
- financial_indicator 增 source 列(迁移 d3f6c9a21b04);新增一致性/分页/服务测试
This commit is contained in:
Simon
2026-09-08 21:48:09 +08:00
parent a77d3c13c3
commit 442999f701
17 changed files with 1519 additions and 55 deletions
+30
View File
@@ -196,6 +196,36 @@ class TestFinancialRepository:
assert len(got) == 1
assert got[0].eps == Decimal("9.99")
def test_source_marker_and_incremental_queries(self, session: Session) -> None:
"""source 来源标记(默认 tushare)+ 增量判断查询(has_report_period/list_symbol)。"""
repo = SqlAlchemyFinancialRepository(session)
repo.upsert_many(
[
FinancialIndicator(
symbol="600519.SH",
report_date=date(2024, 6, 30),
announce_date=date(2024, 8, 31),
eps=Decimal("33.19"),
), # source 默认 tushare
FinancialIndicator(
symbol="600519.SH",
report_date=date(2024, 9, 30),
announce_date=date(2024, 10, 30),
source="sina",
eps=Decimal("48.42"),
),
]
)
session.commit()
rows = repo.list_symbol("600519.SH")
assert {r.source for r in rows} == {"tushare", "sina"}
assert rows[0].source == "tushare" # 按 announce_date 升序
assert repo.has_report_period("600519.SH", date(2024, 9, 30))
assert not repo.has_report_period("600519.SH", date(2024, 12, 31))
assert repo.list_symbol("000001.SZ") == []
class TestSyncLogRepository:
def test_add_and_recent(self, session: Session) -> None: