fix: 弱信号不可执行+rr_low/rr_high防DELETE+INSERT冲零
- /api/watch: 信号不充分/关注/弱势持有/观望/持有 的推荐永远排队不徽章可执行 (tag是LLM行动信号时遗留,技术路径降级信号后无权摘tag,徽章层自卡信号) - write_holding_strategy: INSERT补rr_low/rr_high列,调用方不提供时保留旧值 (盘中per_stock技术路径每次DELETE+INSERT把两个计算列冲成0,昨晚回填全灭)
This commit is contained in:
+11
-4
@@ -1488,9 +1488,11 @@ def write_holding_strategy(conn, code: str, name: str, data: dict,
|
||||
_old_sig = ''
|
||||
_old_ra = ''
|
||||
_old_action = ''
|
||||
_old_rr_lo = 0
|
||||
_old_rr_hi = 0
|
||||
if True:
|
||||
try:
|
||||
_old = conn.execute("SELECT full_analysis, reassessed_at, tag, timing_signal, action FROM holding_strategies WHERE code=? ORDER BY id DESC LIMIT 1", (code,)).fetchone()
|
||||
_old = conn.execute("SELECT full_analysis, reassessed_at, tag, timing_signal, action, rr_low, rr_high FROM holding_strategies WHERE code=? ORDER BY id DESC LIMIT 1", (code,)).fetchone()
|
||||
if _old:
|
||||
if not _existing_fa:
|
||||
if _old[0]: _existing_fa = _old[0]
|
||||
@@ -1499,6 +1501,8 @@ def write_holding_strategy(conn, code: str, name: str, data: dict,
|
||||
_old_sig = _old[3] or ''
|
||||
_old_ra = _old[1] or ''
|
||||
_old_action = _old[4] or ''
|
||||
_old_rr_lo = _old[5] or 0
|
||||
_old_rr_hi = _old[6] or 0
|
||||
except:
|
||||
pass
|
||||
# ── 信号权威层级(2026-07-22):新鲜(<20h)12维动作级信号,
|
||||
@@ -1549,7 +1553,7 @@ def write_holding_strategy(conn, code: str, name: str, data: dict,
|
||||
# DELETE + INSERT
|
||||
conn.execute("DELETE FROM holding_strategies WHERE code=?", (code,))
|
||||
conn.execute("""
|
||||
INSERT INTO holding_strategies
|
||||
INSERT INTO holding_strategies
|
||||
(code, name, version, price, cost, shares, stop_loss, take_profit,
|
||||
entry_low, entry_high, currency, strategy_type, action,
|
||||
timing_signal, rr_ratio, tech_snapshot, stock_category,
|
||||
@@ -1558,10 +1562,10 @@ def write_holding_strategy(conn, code: str, name: str, data: dict,
|
||||
avg_price, decision_timestamp, note, quality_check,
|
||||
quality_checked_at, quality_issues_json, position_advice,
|
||||
signal_factors_json, time_horizon, decision_type,
|
||||
full_analysis, reassessed_at, tag)
|
||||
full_analysis, reassessed_at, tag, rr_low, rr_high)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
|
||||
datetime('now','localtime'),
|
||||
?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
""", (
|
||||
code, name,
|
||||
data.get('version', 1), data.get('price'), data.get('cost'),
|
||||
@@ -1588,6 +1592,9 @@ def write_holding_strategy(conn, code: str, name: str, data: dict,
|
||||
_existing_fa,
|
||||
_existing_ra,
|
||||
_existing_tag,
|
||||
# rr_low/rr_high: 调用方不提供时保留旧值(防DELETE+INSERT把计算列冲零)
|
||||
data.get('rr_low') or _old_rr_lo,
|
||||
data.get('rr_high') or _old_rr_hi,
|
||||
))
|
||||
conn.commit()
|
||||
# ── 推荐转场:LLM路径新转为 current_recommend → 记入摘要队列(不逐只推送)──
|
||||
|
||||
@@ -240,11 +240,17 @@ def get_watch():
|
||||
# 买入:RR≥1.5 才有可执行资格(prompt 自己的纪律:RR<1.5→不推荐);
|
||||
# 达标者贪心装入现金预算,预算外/不达标标记"排队"(不再降级隐藏)
|
||||
_cum = 0.0
|
||||
# 弱信号不可执行(2026-07-23 老爸:信号不充分+盈利持有为何可执行?——
|
||||
# tag是LLM行动信号时的遗留,技术路径降级信号后无权摘tag,徽章层必须自己卡信号)
|
||||
_WEAK_SIGNALS = ('信号不充分', '关注', '弱势持有', '观望', '持有', '')
|
||||
for d in _buys:
|
||||
pct = _sugg_pct(d)
|
||||
d['suggested_position_pct'] = pct
|
||||
rr = d.get('rr_ratio') or 0
|
||||
if rr >= 1.5 and _cum + pct <= _budget_pct + 1e-9:
|
||||
sig_now = d.get('timing_signal') or ''
|
||||
if sig_now in _WEAK_SIGNALS:
|
||||
d['rec_exec'] = False # 弱信号永远排队
|
||||
elif rr >= 1.5 and _cum + pct <= _budget_pct + 1e-9:
|
||||
d['rec_exec'] = True # 可执行
|
||||
_cum += pct
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user