stale_push_wlin: 按Dad确认流程重构推送逻辑

1. 加重评冷却(4小时)— 查holding_strategies.updated_at
2. 修zone_notes早退bug — 有区间说明时不静默退出
3. zone_notes冷却30分→4小时(匹配重评冷却)
4. 标题自适应:有推荐→自选买入提醒 | 仅区间提醒→操作区间提醒
5. 区间说明格式:'进入操作区间,但重评结果:x'
6. 操作建议标题只在有可操作项时显示
7. has_actionable判定改用实际lines内容
This commit is contained in:
知微
2026-07-09 10:33:50 +08:00
parent a147085f1a
commit c745f1318a
22 changed files with 3452 additions and 1315 deletions
+27 -12
View File
@@ -806,7 +806,8 @@ def main():
return text, gap
# 标准格式:每个可操作标的 — 大盘/行业/个股三面 + 仓位
lines.append(f"【💡 操作建议】(当前{n}只自选可操作 | 总资产{total_assets:,.0f}元 现金{available_cash:,.0f}元)")
if actionable:
lines.append(f"【💡 操作建议】(当前{len(actionable)}只自选可操作 | 总资产{total_assets:,.0f}元 现金{available_cash:,.0f}元)")
for s in actionable:
name, code, price, buy_low, buy_high, lot, ratio = s
d = code_data.get(code, {})
@@ -935,16 +936,26 @@ def main():
save_cooldown(cooldown)
# 修正可操作数量(剔除冷却跳过后的实际数量)
actual_n = len(lines) - (1 if macro_line else 0) - 1 # 减去市场背景 + 操作建议标题
if actual_n != n:
# 更新操作建议行
for i, ln in enumerate(lines):
if "【💡 操作建议】" in ln:
lines[i] = f"【💡 操作建议】(当前{actual_n}只自选可操作 | 总资产{total_assets:,.0f}元 现金{available_cash:,.0f}元)"
break
if actionable:
actual_n = sum(
1 for ln in lines
if ln.startswith(" 🛒") or ln.startswith(" ⚠️")
)
if actual_n != len(actionable):
for i, ln in enumerate(lines):
if "【💡 操作建议】" in ln:
if actual_n > 0:
lines[i] = f"【💡 操作建议】(当前{actual_n}只自选可操作 | 总资产{total_assets:,.0f}元 现金{available_cash:,.0f}元)"
else:
lines.pop(i) # 全部冷却,移除空标题
break
if actual_n <= 0:
return 0 # 全部冷却中 → 静默,不推
# 检查最终是否还有内容要推
has_actionable = any(
ln.startswith(" 🛒") or ln.startswith(" ⚠️") for ln in lines
)
if not has_actionable and not zone_notes:
return 0 # 全部冷却+无区间说明 → 静默
# ── T+2前瞻:扫描近期可能入买区的A股,提前准备现金 ──
t2_lines = []
@@ -1004,10 +1015,14 @@ def main():
for name, code, price, buy_low, buy_high, reason, sig in zone_notes:
lines.append(
f" {name}({code}) 价{price:.2f} 区间{buy_low}~{buy_high} "
f"→ 重评结果: {reason}"
f"进入操作区间,但重评结果: {reason}"
)
lines.insert(0, f"【知微】自选买入提醒 {now} | 总资产{total_assets:,.0f}")
# 标题:有推荐操作→"自选买入提醒",仅有区间说明→"操作区间提醒"
if has_actionable:
lines.insert(0, f"【知微】自选买入提醒 {now} | 总资产{total_assets:,.0f}")
else:
lines.insert(0, f"【知微】操作区间提醒 {now} | 总资产{total_assets:,.0f}")
out = "\n".join(lines)
print(out)
push_to_xmpp(out)