fix: 审计修复(explore发现)
- candidate_filter资金流读到旧id=194→WHERE id=1(critical) - strategy_lifecycle sector_snapshots全表133907行→最新快照(major) - strategy_lifecycle行业读取加stock_sectors_em回退(2处)
This commit is contained in:
@@ -287,7 +287,7 @@ def stage6_narrative(code, name):
|
||||
flow_trend = "中性"
|
||||
try:
|
||||
import json as _j
|
||||
fr = conn.execute("SELECT cache_json FROM capital_flow_cache ORDER BY id DESC LIMIT 1").fetchone()
|
||||
fr = conn.execute("SELECT cache_json FROM capital_flow_cache WHERE id=1 ORDER BY updated_at DESC LIMIT 1").fetchone()
|
||||
if fr and fr[0]:
|
||||
fc = _j.loads(fr[0])
|
||||
a = (fc.get("stocks", {}).get(code, {}) or {}).get("analysis", {})
|
||||
|
||||
@@ -181,6 +181,8 @@ def enforce_strategy_quality(code, name, result):
|
||||
try:
|
||||
_db = sqlite3.connect("/home/hmo/MoFin/data/mofin.db", timeout=5)
|
||||
r = _db.execute("SELECT sector_name FROM stock_sectors WHERE code=?", (code_str,)).fetchone()
|
||||
if not r or not r[0]:
|
||||
r = _db.execute("SELECT sector FROM stock_sectors_em WHERE code=?", (code_str,)).fetchone()
|
||||
_db.close()
|
||||
return r[0] if r else None
|
||||
except:
|
||||
@@ -1337,7 +1339,7 @@ def reassess_strategy(code, name, price, cost, shares, current_action,
|
||||
try:
|
||||
_db2 = sqlite3.connect("/home/hmo/MoFin/data/mofin.db", timeout=5)
|
||||
_rows2 = _db2.execute(
|
||||
"SELECT name, change_pct FROM sector_snapshots ORDER BY change_pct DESC"
|
||||
"SELECT name, change_pct FROM sector_snapshots WHERE snapshot_id=(SELECT MAX(snapshot_id) FROM sector_snapshots) ORDER BY change_pct DESC"
|
||||
).fetchall()
|
||||
if _rows2:
|
||||
# 找到该股所属行业(简单匹配name或通过stock_sectors)
|
||||
@@ -1345,6 +1347,11 @@ def reassess_strategy(code, name, price, cost, shares, current_action,
|
||||
"SELECT sector_name FROM stock_sectors WHERE code=?",
|
||||
(code,)
|
||||
).fetchall()
|
||||
if not _my_sectors:
|
||||
_my_sectors = _db2.execute(
|
||||
"SELECT sector FROM stock_sectors_em WHERE code=?",
|
||||
(code,)
|
||||
).fetchall()
|
||||
if _my_sectors:
|
||||
for (_sn,) in _my_sectors:
|
||||
for r_name, r_chg in _rows2:
|
||||
|
||||
Reference in New Issue
Block a user