feat: accumulation/mr scanner写candidates.rr——全部scanner按规范提供RR

This commit is contained in:
xxm
2026-08-17 15:50:57 +08:00
parent d9d46f54e1
commit 34a7d521d0
2 changed files with 12 additions and 8 deletions
@@ -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)
+6 -4
View File
@@ -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)