fix: 行业未映射时诚实标注,禁止大盘指标伪装成行业信息
This commit is contained in:
@@ -124,17 +124,20 @@ def collect_data(code):
|
||||
except:
|
||||
data["price"] = 0
|
||||
|
||||
# 行业上下文修正:sector_context 被"大盘上涨比"污染或为空时,用 stock_sectors 的行业名兜底
|
||||
# 行业上下文修正:sector_context 被"大盘上涨比"污染或为空时,用 stock_sectors 的行业名兜底;
|
||||
# 未映射的股票明确标注"行业未映射"(不让大盘指标伪装成行业信息)
|
||||
_sector_ctx = data.get('sector_context', '') or ''
|
||||
if (not _sector_ctx) or _sector_ctx.startswith('大盘上涨比') or len(_sector_ctx) < 4:
|
||||
_resolved = ""
|
||||
try:
|
||||
_sdb = sqlite3.connect(DB)
|
||||
_sr = _sdb.execute("SELECT sector_name FROM stock_sectors WHERE code=? LIMIT 1", (code,)).fetchone()
|
||||
_sdb.close()
|
||||
if _sr and _sr[0]:
|
||||
_sector_ctx = f"行业{_sr[0]}"
|
||||
_resolved = f"行业{_sr[0]}"
|
||||
except Exception:
|
||||
pass
|
||||
_sector_ctx = _resolved if _resolved else "行业未映射(仅大盘环境参考)"
|
||||
data['sector_context'] = _sector_ctx
|
||||
# 大盘
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user