diff --git a/deploy/profile-scripts/accumulation_scanner.py b/deploy/profile-scripts/accumulation_scanner.py index 0697655b..07ab7c77 100644 --- a/deploy/profile-scripts/accumulation_scanner.py +++ b/deploy/profile-scripts/accumulation_scanner.py @@ -230,16 +230,18 @@ def main(): # UPSERT:只更新扫描器自有列,保留 score_*/pass_*/promoted/log/zhiwei_* 等计算列 # (原 INSERT OR REPLACE 会把 promoted=1 的行整行替换,计算列全部清零——2026-07-23 审计发现) + _mid_v = (entry_low + entry_high) / 2 + _rr_v = round((tp - _mid_v) / (_mid_v - sl), 2) if _mid_v > sl > 0 else 0 conn.execute( "INSERT INTO candidates (code, name, sector, reason, " - "entry_range, stop_loss, target, created_at) " - "VALUES (?,?,?,?,?,?,?,datetime('now','localtime')) " + "entry_range, stop_loss, target, rr, created_at) " + "VALUES (?,?,?,?,?,?,?,?,datetime('now','localtime')) " "ON CONFLICT(code) DO UPDATE SET " "name=excluded.name, sector=excluded.sector, reason=excluded.reason, " - "entry_range=excluded.entry_range, stop_loss=excluded.stop_loss, target=excluded.target", + "entry_range=excluded.entry_range, stop_loss=excluded.stop_loss, target=excluded.target, rr=excluded.rr", (code, name, "accumulation", f"主力建仓特征({reasons}) 评分{score}/7", - f"{entry_low}~{entry_high}", sl, tp) + f"{entry_low}~{entry_high}", sl, tp, _rr_v) ) inserted += 1 print(f" 🟢 {code} {name} 价{price} 评分{score}/7 {reasons}", flush=True) diff --git a/deploy/profile-scripts/mr_scanner.py b/deploy/profile-scripts/mr_scanner.py index 750fb5e7..be2c2b33 100644 --- a/deploy/profile-scripts/mr_scanner.py +++ b/deploy/profile-scripts/mr_scanner.py @@ -317,15 +317,17 @@ def main(): (code,)).fetchone() if exists: continue + _mid_v = (entry_low + entry_high) / 2 + _rr_v = round((tp - _mid_v) / (_mid_v - sl), 2) if _mid_v > sl > 0 else 0 conn.execute( "INSERT INTO candidates (code, name, sector, reason, " - "entry_range, stop_loss, target, created_at) " - "VALUES (?,?,?,?,?,?,?,datetime('now','localtime')) " + "entry_range, stop_loss, target, rr, created_at) " + "VALUES (?,?,?,?,?,?,?,?,datetime('now','localtime')) " "ON CONFLICT(code) DO UPDATE SET " "name=excluded.name, sector=excluded.sector, reason=excluded.reason, " - "entry_range=excluded.entry_range, stop_loss=excluded.stop_loss, target=excluded.target", + "entry_range=excluded.entry_range, stop_loss=excluded.stop_loss, target=excluded.target, rr=excluded.rr", (code, name, "v_mr", reasons, - f"{entry_low}~{entry_high}", sl, tp)) + f"{entry_low}~{entry_high}", sl, tp, _rr_v)) inserted += 1 print(f" 🟢 {code} {name} 价{price} bias60={sig['bias60']}% " f"rsi={sig['rsi']} r5f={sig['r5f']}% {reasons}", flush=True)