Files
MoFin/scripts/find_97_rows.py
T
hmo 7b26c373d1 fix(reassess): stale_detector timeout 60->240s + batch cap 5/run + GATE_ZONE_SANITY
Three issues from zhiwei's strategy report:

1. '37 reassess all timed out (subprocess 60s)': real cause is per-call LLM
   latency exceeding the 60s per-subprocess limit during the key5-dead/
   gateway-unstable window. NOT 'no concurrency control' as reported (60s
   is per stock, not for the batch). Fixes: per-call timeout 60->240s
   (LLM cold-start is 20-100s), and cap AUTO_REASSESS batch to 5 stocks
   per run with remainder continuing next run (was unbounded serial calls
   that also blew the 120s cron script window).

2. '15 stocks entry-zone center wrongly 97.0': quality gates had no
   zone-sanity-vs-price check, so bad data (bad quote or LLM template
   output) could be written freely. New GATE_ZONE_SANITY (CRITICAL):
   zone center must be within 0.3x-3x of current price. Verified: rejects
   the exact 97-center-vs-5.69-price corruption, passes legit zones.

3. 'reassess overwrites manual SQL fixes': true by design; with
   GATE_ZONE_SANITY at write time, reassess can no longer overwrite good
   values with garbage - invalid writes get rejected + flagged instead.
2026-07-20 22:05:00 +08:00

24 lines
1014 B
Python

import sqlite3
conn = sqlite3.connect('/home/hmo/MoFin/data/mofin.db')
conn.row_factory = sqlite3.Row
print('=== 中心 85~110 的活跃自选/持仓 ===')
rows = conn.execute(
"SELECT code, name, entry_low, entry_high, decision_type, strategy_type, created_at, updated_at "
"FROM holding_strategies WHERE status='active' AND entry_low > 0").fetchall()
found = 0
for r in rows:
c = (r['entry_low'] + r['entry_high']) / 2
if 85 <= c <= 110:
print(f" {r['code']} {r['name']}: 区{r['entry_low']}~{r['entry_high']} 中心{c:.2f} | {r['decision_type']}/{r['strategy_type']} | created={r['created_at']} updated={r['updated_at']}")
found += 1
print(f'共 {found} 只')
print()
# holding_strategies 表结构 + 默认值
print('=== holding_strategies schema ===')
sql = conn.execute("SELECT sql FROM sqlite_master WHERE name='holding_strategies'").fetchone()[0]
for line in sql.split('\n'):
if '97' in line or 'DEFAULT' in line.upper():
print(' ', line.strip())
conn.close()