fix: 资金流聚合输出net_flow/main_force/retail_flow/trend(12维资金面恒0根因) + sector_context污染时行业名兜底

This commit is contained in:
hmo
2026-07-22 12:46:22 +08:00
parent a3f5ad5b3a
commit eb644221f4
2 changed files with 22 additions and 1 deletions
+12
View File
@@ -124,6 +124,18 @@ def collect_data(code):
except:
data["price"] = 0
# 行业上下文修正:sector_context 被"大盘上涨比"污染或为空时,用 stock_sectors 的行业名兜底
_sector_ctx = data.get('sector_context', '') or ''
if (not _sector_ctx) or _sector_ctx.startswith('大盘上涨比') or len(_sector_ctx) < 4:
try:
_sdb = sqlite3.connect(DB)
_sr = _sdb.execute("SELECT sector FROM stock_sectors WHERE code=? LIMIT 1", (code,)).fetchone()
_sdb.close()
if _sr and _sr[0]:
_sector_ctx = f"行业{_sr[0]}"
except Exception:
pass
data['sector_context'] = _sector_ctx
# 大盘
try:
conn = sqlite3.connect(DB)