评析目标名单取展示给人的候选单,不取全部主榜
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
0c4129738d
commit
89eb5135e7
|
|
@ -62,7 +62,11 @@ def save(ds: str, rows: list, conn_factory=None) -> None:
|
|||
|
||||
|
||||
def persist(ds: str, snap: dict, write=None) -> dict:
|
||||
rows = build_rows(ds, snap.get("main") or [], snap.get("observe") or [])
|
||||
"""目标是计划里展示给人的那一份候选单(主榜前几十只加观察档),不是全部主榜;快照里叫 main_shown / observe_shown,
|
||||
老快照没有这两个键就退回 main / observe。"""
|
||||
main = snap.get("main_shown") if snap.get("main_shown") is not None else (snap.get("main") or [])
|
||||
obs = snap.get("observe_shown") if snap.get("observe_shown") is not None else (snap.get("observe") or [])
|
||||
rows = build_rows(ds, main, obs)
|
||||
(write or save)(ds, rows)
|
||||
n_main = sum(1 for r in rows if r["source"] == "main")
|
||||
print(f" 评析目标名单 {ds}:主榜 {n_main},观察 {len(rows) - n_main},写入 {TABLE}")
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ def main():
|
|||
out = rt.persist("2026-09-08", snap, write=lambda ds, rs: got.setdefault(ds, rs))
|
||||
t("写入可注入且读数正确", out["rows"] == 3 and out["main"] == 2 and len(got["2026-09-08"]) == 3)
|
||||
t("认不出的代码丢弃", all(len(r["ts_code"]) == 9 for r in rows))
|
||||
shown = {"main": [{"code": "SH600519"}] * 3, "observe": [], "main_shown": [{"code": "SZ300750"}], "observe_shown": [{"code": "SZ000001"}]}
|
||||
out2 = rt.persist("2026-09-09", shown, write=lambda ds, rs: got.setdefault(ds, rs))
|
||||
t("优先取展示给人的那份候选单", out2["rows"] == 2 and got["2026-09-09"][0]["ts_code"] == "300750.SZ")
|
||||
print("ALL OK — 评析目标名单")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue