feat: 补齐 spec 遗漏 — themes/history 接口 + cover_count/coverCount/daysSinceLastAppear
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -60,10 +60,12 @@ async def collect_daily(trade_date: str, dry_run: bool = False) -> dict:
|
||||
|
||||
# 2. 核心股前100:按领涨股 f3 降序,去重(同一股票可能是多个题材领涨股)
|
||||
stock_map: dict[str, dict] = {}
|
||||
theme_count: dict[str, int] = {} # securityCode -> 覆盖题材数
|
||||
for t in themes:
|
||||
code = t.get("securityCode")
|
||||
if not code:
|
||||
continue
|
||||
theme_count[code] = theme_count.get(code, 0) + 1
|
||||
if code not in stock_map or (t.get("f3") or 0) > (stock_map[code].get("f3") or 0):
|
||||
stock_map[code] = {
|
||||
"stock_code": code,
|
||||
@@ -86,8 +88,8 @@ async def collect_daily(trade_date: str, dry_run: bool = False) -> dict:
|
||||
try:
|
||||
for i, s in enumerate(core_stocks, start=1):
|
||||
conn.execute(
|
||||
"INSERT OR IGNORE INTO daily_core_stocks (trade_date, stock_code, stock_name, f3, rank) VALUES (?,?,?,?,?)",
|
||||
(trade_date, s["stock_code"], s["stock_name"], s["f3"], i),
|
||||
"INSERT OR IGNORE INTO daily_core_stocks (trade_date, stock_code, stock_name, f3, cover_count, rank) VALUES (?,?,?,?,?,?)",
|
||||
(trade_date, s["stock_code"], s["stock_name"], s["f3"], theme_count.get(s["stock_code"], 0), i),
|
||||
)
|
||||
# 核心股所属题材:从 themes 列表(含 securityCode/themeCode/themeName)中
|
||||
# 为每个核心股收集其全部所属题材,写入 daily_core_stock_themes
|
||||
|
||||
Reference in New Issue
Block a user