fix: 重新应用scanner+promote的source_strategy补丁(deploy_guard回滚后重做)
This commit is contained in:
@@ -234,14 +234,14 @@ def main():
|
||||
_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, rr, created_at) "
|
||||
"VALUES (?,?,?,?,?,?,?,?,datetime('now','localtime')) "
|
||||
"entry_range, stop_loss, target, rr, source_strategy, 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, rr=excluded.rr",
|
||||
"entry_range=excluded.entry_range, stop_loss=excluded.stop_loss, target=excluded.target, rr=excluded.rr, source_strategy=excluded.source_strategy",
|
||||
(code, name, "accumulation",
|
||||
f"主力建仓特征({reasons}) 评分{score}/7",
|
||||
f"{entry_low}~{entry_high}", sl, tp, _rr_v)
|
||||
f"{entry_low}~{entry_high}", sl, tp, _rr_v, "accumulation")
|
||||
)
|
||||
inserted += 1
|
||||
print(f" 🟢 {code} {name} 价{price} 评分{score}/7 {reasons}", flush=True)
|
||||
|
||||
@@ -96,13 +96,13 @@ def main():
|
||||
_mid_v = (sig['price'] * 0.98 + sig['price']) / 2
|
||||
_rr_v = round((sig['target'] - _mid_v) / (_mid_v - sig['stop_loss']), 2) if _mid_v > sig['stop_loss'] > 0 else 0
|
||||
conn.execute(
|
||||
"INSERT INTO candidates (code, name, sector, reason, entry_range, stop_loss, target, rr, created_at) "
|
||||
"VALUES (?,?,?,?,?,?,?,?,datetime('now','localtime')) "
|
||||
"INSERT INTO candidates (code, name, sector, reason, entry_range, stop_loss, target, rr, source_strategy, 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, rr=excluded.rr",
|
||||
"entry_range=excluded.entry_range, stop_loss=excluded.stop_loss, target=excluded.target, rr=excluded.rr, source_strategy=excluded.source_strategy",
|
||||
(code, code, "b_td1_v3", reasons,
|
||||
f"{sig['price']*0.98:.2f}~{sig['price']:.2f}", sig["stop_loss"], sig["target"], _rr_v))
|
||||
f"{sig['price']*0.98:.2f}~{sig['price']:.2f}", sig["stop_loss"], sig["target"], _rr_v, "b_td1_v3"))
|
||||
inserted += 1
|
||||
print(f" 🟢 {code} {code} 价{sig['price']} score={sig['score']} {reasons}", flush=True)
|
||||
conn.commit()
|
||||
|
||||
@@ -321,13 +321,13 @@ def main():
|
||||
_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, rr, created_at) "
|
||||
"VALUES (?,?,?,?,?,?,?,?,datetime('now','localtime')) "
|
||||
"entry_range, stop_loss, target, rr, source_strategy, 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, rr=excluded.rr",
|
||||
"entry_range=excluded.entry_range, stop_loss=excluded.stop_loss, target=excluded.target, rr=excluded.rr, source_strategy=excluded.source_strategy",
|
||||
(code, name, "v_mr", reasons,
|
||||
f"{entry_low}~{entry_high}", sl, tp, _rr_v))
|
||||
f"{entry_low}~{entry_high}", sl, tp, _rr_v, "v_mr"))
|
||||
inserted += 1
|
||||
print(f" 🟢 {code} {name} 价{price} bias60={sig['bias60']}% "
|
||||
f"rsi={sig['rsi']} r5f={sig['r5f']}% {reasons}", flush=True)
|
||||
|
||||
@@ -35,7 +35,7 @@ def main():
|
||||
|
||||
# 读未提拔候选(按评分降序)
|
||||
rows = conn.execute("""
|
||||
SELECT c.code, c.name, c.score_final, c.entry_range, c.stop_loss, c.target, c.sector, c.rr
|
||||
SELECT c.code, c.name, c.score_final, c.entry_range, c.stop_loss, c.target, c.sector, c.rr, c.source_strategy
|
||||
FROM candidates c
|
||||
WHERE (c.promoted IS NULL OR c.promoted = 0)
|
||||
AND (c.dropped IS NULL OR c.dropped = 0)
|
||||
@@ -59,6 +59,7 @@ def main():
|
||||
code = str(r[0])
|
||||
# 2026-08-11:读取候选 sector(用于 p_oversold RR 例外)
|
||||
cand_sector = str(r[6] or "").strip() if len(r) > 6 else ""
|
||||
source_strategy = str(r[8] or "").strip() if len(r) > 8 else ""
|
||||
exists = conn.execute(
|
||||
"SELECT id FROM holding_strategies WHERE code=? AND status='active'",
|
||||
(code,)
|
||||
@@ -180,11 +181,11 @@ def main():
|
||||
INSERT OR IGNORE INTO holding_strategies
|
||||
(code, name, price, entry_low, entry_high, stop_loss, take_profit,
|
||||
timing_signal, action, decision_type, strategy_type, status,
|
||||
rr_ratio, stock_category, created_at, updated_at,
|
||||
rr_ratio, stock_category, strategy_name, created_at, updated_at,
|
||||
sector_context, quality_check)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,'自选策略','scan',
|
||||
'active',?,'关注',?,?,'', 'pending')
|
||||
""", (code, name, 0, el, eh, sl, tp, timing_signal, action, _rr, now, now))
|
||||
'active',?,'关注',?,?,?,?,'', 'pending')
|
||||
""", (code, name, 0, el, eh, sl, tp, timing_signal, action, _rr, source_strategy, now, now))
|
||||
newly_added = cur.rowcount > 0
|
||||
|
||||
conn.execute("UPDATE candidates SET promoted=1 WHERE code=?", (code,))
|
||||
|
||||
@@ -156,13 +156,13 @@ def main():
|
||||
for code, name, sig in hits:
|
||||
reasons = (f"rsi={sig['rsi']} mcap_q={sig['mcap_q']} score={sig['score']}")
|
||||
conn.execute(
|
||||
"INSERT INTO candidates (code, name, sector, reason, entry_range, stop_loss, target, created_at) "
|
||||
"VALUES (?,?,?,?,?,?,?,datetime('now','localtime')) "
|
||||
"INSERT INTO candidates (code, name, sector, reason, entry_range, stop_loss, target, source_strategy, 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, source_strategy=excluded.source_strategy",
|
||||
(code, code, "s2_panic_v2", reasons,
|
||||
f"{sig['price']*0.98:.2f}~{sig['price']:.2f}", sig["stop_loss"], sig["target"]))
|
||||
f"{sig['price']*0.98:.2f}~{sig['price']:.2f}", sig["stop_loss"], sig["target"], "s2_panic_v2"))
|
||||
inserted += 1
|
||||
print(f" 🟢 {code} {name} 价{sig['price']} score={sig['score']} {reasons}", flush=True)
|
||||
conn.commit()
|
||||
|
||||
Reference in New Issue
Block a user