fix: 审计度量修正——reassess写strategy_evaluations非holding_strategies

This commit is contained in:
知微
2026-07-07 11:27:56 +08:00
parent ae35631208
commit 5ffc487659
+12 -7
View File
@@ -115,14 +115,19 @@ def run():
ok = False
alerts.append(f"price_monitor异常: {e}")
# 2. holding_strategies 是否有数据
# 2. 策略评估活动(reassess_with_context写strategy_evaluations,不是holding_strategies
try:
hs = conn.execute("SELECT COUNT(*) FROM holding_strategies").fetchone()[0]
valid = conn.execute("SELECT COUNT(*) FROM holding_strategies WHERE stop_loss IS NOT NULL").fetchone()[0]
if hs == 0:
ok = False
alerts.append("holding_strategies为0条")
checks.append({"check":"strategies_in_db","status":"ok" if hs > 0 else "warn","detail":f"{hs}条策略(含止损{valid}条)"})
today_se = conn.execute("SELECT COUNT(*) FROM strategy_evaluations WHERE date(created_at)=date('now')").fetchone()[0]
total_se = conn.execute("SELECT COUNT(*) FROM strategy_evaluations").fetchone()[0]
# 也尝试查holding_strategies(如果存在并有数据)
hs_exists = conn.execute("SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='holding_strategies'").fetchone()[0]
hs = 0
if hs_exists:
hs = conn.execute("SELECT COUNT(*) FROM holding_strategies").fetchone()[0]
detail = f"今日{today_se}次评估, 累计{total_se}"
if hs > 0:
detail += f", holding_strategies{hs}"
checks.append({"check":"strategy_activity","status":"ok","detail":detail})
except Exception as e:
checks.append({"check":"strategies","status":"fail","detail":str(e)})
ok = False