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:
@@ -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. 题材前10:bf3 降序
|
||||
# 3. 题材涨幅前20:bf3 降序
|
||||
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}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user