Files
MoFin/scripts/trace_97_source.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

19 lines
826 B
Python

import sqlite3
conn = sqlite3.connect('/home/hmo/MoFin/data/mofin.db')
conn.row_factory = sqlite3.Row
codes = ['000711', '603766', '600617', '688271', '688608']
for code in codes:
r = conn.execute(
"SELECT code, name, entry_low, entry_high, substr(full_analysis,1,1200) as fa, "
"reassessed_at, updated_at FROM holding_strategies WHERE code=? AND status='active'",
(code,)).fetchone()
if r:
print(f"=== {r['code']} {r['name']}{r['entry_low']}~{r['entry_high']} updated={r['updated_at']} reassessed={r['reassessed_at']}")
fa = r['fa'] or ''
# 找买入区间相关行
for line in fa.split('\n'):
if any(k in line for k in ['买入区间', '止损', '止盈', '综合结论']):
print(' ', line[:120])
print()
conn.close()