merge: reassess timeout + zone sanity gate

This commit is contained in:
知微
2026-07-20 22:05:05 +08:00
5 changed files with 122 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
import sqlite3
conn = sqlite3.connect('/home/hmo/MoFin/data/mofin.db')
conn.row_factory = sqlite3.Row
# 1. 找曾被 zhiwei 修过的 15 只(她提到的几只)当前值
codes = ['000711', '603766', '600617', '688271']
print('=== holding_strategies 当前值(她修过的几只)===')
for code in codes:
r = conn.execute(
"SELECT code, name, entry_low, entry_high, stop_loss, take_profit, strategy_type, "
"quality_check, created_at, updated_at FROM holding_strategies WHERE code=? AND status='active'",
(code,)).fetchone()
if r:
c = (r['entry_low'] + r['entry_high']) / 2 if r['entry_low'] and r['entry_high'] else 0
print(f" {r['code']} {r['name']}: 区{r['entry_low']}~{r['entry_high']} 中心{c:.2f} | type={r['strategy_type']} | created={r['created_at']} updated={r['updated_at']}")
# 2. 找 candidates 里这些股票的评分/买入区(看是不是 promote 写进来的)
print()
print('=== candidates 对应记录 ===')
for code in codes:
r = conn.execute(
"SELECT code, name, score, entry_low, entry_high, stop_loss, take_profit, promoted, created_at "
"FROM candidates WHERE code=?", (code,)).fetchone()
if r:
print(f" {r['code']} {r['name']}: score={r['score']}{r['entry_low']}~{r['entry_high']} promoted={r['promoted']} created={r['created_at']}")
# 3. 还有谁可能是 97 中心:找 entry 中心在 90~105 的活跃自选
print()
print('=== 当前活跃自选里中心 90~105 的(可能还有漏网的)===')
rows = conn.execute(
"SELECT code, name, entry_low, entry_high FROM holding_strategies "
"WHERE status='active' AND decision_type='自选策略' AND entry_low > 0").fetchall()
for r in rows:
c = (r['entry_low'] + r['entry_high']) / 2
if 90 <= c <= 105:
print(f" {r['code']} {r['name']}: 区{r['entry_low']}~{r['entry_high']} 中心{c:.2f}")
conn.close()
+20
View File
@@ -0,0 +1,20 @@
import sqlite3
conn = sqlite3.connect('/home/hmo/MoFin/data/mofin.db')
conn.row_factory = sqlite3.Row
# candidates 表结构
cols = [r[1] for r in conn.execute("PRAGMA table_info(candidates)")]
print('candidates cols:', cols)
print()
codes = ['000711', '603766', '600617', '688271']
print('=== candidates 对应记录 ===')
for code in codes:
r = conn.execute("SELECT * FROM candidates WHERE code=?", (code,)).fetchone()
if r:
d = dict(r)
keys = [k for k in d.keys() if any(s in k.lower() for s in ['score', 'entry', 'stop', 'take', 'promot', 'created', 'name', 'code'])]
print(f" {code}: " + ' | '.join(f'{k}={d[k]}' for k in keys))
else:
print(f' {code}: 无记录')
conn.close()
+24
View File
@@ -0,0 +1,24 @@
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()
+22
View File
@@ -0,0 +1,22 @@
import sys
sys.path.insert(0, '/home/hmo/.hermes/profiles/position-analyst/scripts')
sys.path.insert(0, '/home/hmo/MoFin')
from strategy_lifecycle import validate_strategy
# 模拟 97 中心坏数据(5元股票被写成中心97)
bad = {'code': '000711', 'price': 5.69, 'entry_low': 94.0, 'entry_high': 100.0,
'stop_loss': 90.0, 'take_profit': 110.0, 'timing_signal': '买入',
'rr_ratio': 2.0, 'tech_snapshot': '强撑94 弱撑95 弱压99 强压100',
'sector_context': '环保', 'signal_factors': ['x'], 'currency': 'CNY'}
passed, failures = validate_strategy(bad)
print('坏数据(中心97 vs 价5.69): passed =', passed)
for f in failures:
print(' FAIL:', f.get('id'), '-', f.get('desc', '')[:60])
# 正常数据
good = dict(bad)
good['entry_low'], good['entry_high'], good['stop_loss'], good['take_profit'] = 5.23, 6.15, 5.0, 7.0
passed2, failures2 = validate_strategy(good)
print('好数据(区5.23~6.15): passed =', passed2)
for f in failures2:
print(' FAIL:', f.get('id'), '-', f.get('desc', '')[:60])
+19
View File
@@ -0,0 +1,19 @@
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()