feat: 题材涨幅前20存历史(原前10)

- daily_collector TOP_THEME_LIMIT 10 → 20
- 同步 routes/collector 注释与 spec/plan 文档
- 实测 2026-08-10 题材前20入库 20 条,themes/history 返回 20 条

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Sakurasan
2026-08-10 21:27:54 +08:00
co-authored by Claude
parent 1c434a208a
commit 23644a9c77
5 changed files with 20 additions and 20 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
"""核心股历史接口:活跃核心股 + 指定日核心股/题材前10"""
"""核心股历史接口:活跃核心股 + 指定日核心股/题材前20"""
from datetime import date as date_cls
+1 -1
View File
@@ -39,7 +39,7 @@ async def theme_graph(
return JSONResponse(result, headers=_NO_CACHE_HEADERS)
@router.get("/history", summary="指定交易日题材涨幅前10")
@router.get("/history", summary="指定交易日题材涨幅前20")
async def theme_history(date: str = Query(..., description="交易日 YYYY-MM-DD")):
conn = get_connection()
try:
+5 -5
View File
@@ -1,4 +1,4 @@
"""每日热点数据采集:核心股前100 + 题材涨幅前10,收盘后自动入库
"""每日热点数据采集:核心股前100 + 题材涨幅前20,收盘后自动入库
由 main.lifespan 启动后台任务;幂等(按交易日 UNIQUE 去重)。
"""
@@ -17,7 +17,7 @@ _CST = timezone(timedelta(hours=8))
CHECK_INTERVAL_SECONDS = 300
COLLECT_AFTER_TIME = dtime(15, 0) # 收盘后 15:00 开始允许采集
CORE_STOCK_LIMIT = 100 # 核心股前100
TOP_THEME_LIMIT = 10 # 题材前10
TOP_THEME_LIMIT = 20 # 题材涨幅前20
def _is_trading_day(d: datetime) -> bool:
@@ -76,11 +76,11 @@ async def collect_daily(trade_date: str, dry_run: bool = False) -> dict:
stock_map.values(), key=lambda x: -(x["f3"] or 0)
)[:CORE_STOCK_LIMIT]
# 3. 题材前10bf3 降序
# 3. 题材涨幅前20bf3 降序
top_themes = sorted(themes, key=lambda x: -(x.get("bf3") or 0))[:TOP_THEME_LIMIT]
if dry_run:
print(f"[collector] {trade_date} 核心股 {len(core_stocks)} 只,题材前10 {len(top_themes)}")
print(f"[collector] {trade_date} 核心股 {len(core_stocks)} 只,题材前20 {len(top_themes)}")
return {"core_count": len(core_stocks), "theme_count": len(top_themes), "skipped": False}
# 4. 入库(事务,UNIQUE 幂等)
@@ -109,7 +109,7 @@ async def collect_daily(trade_date: str, dry_run: bool = False) -> dict:
finally:
conn.close()
print(f"[collector] {trade_date} 已采集:核心股 {len(core_stocks)} 只,题材前10 {len(top_themes)}")
print(f"[collector] {trade_date} 已采集:核心股 {len(core_stocks)} 只,题材前20 {len(top_themes)}")
return {"core_count": len(core_stocks), "theme_count": len(top_themes), "skipped": False}