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.
22 lines
1.0 KiB
Python
22 lines
1.0 KiB
Python
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]) |