stale_push_wlin: 每只推荐含大盘/行业/个股三面分析
每只操作建议输出三段线:
第一行:名称代码+买区+1手成本+RR+止损止盈
第二行:大盘走向 | 行业趋势 | PE估值 | 消息面
第三行:技术位(强撑→弱撑→弱压→强压) | 信号
数据来源:signal_factors(策略富化生成的因子列表)、
multi_tf_cache.json(PE/EPS)、
tech_snapshot(技术位)、
macro_line(大盘背景)
Dad要求:推荐必须能看到操作理由的三个维度分析
This commit is contained in:
@@ -268,7 +268,17 @@ def main():
|
||||
if not actionable:
|
||||
return 0 # 无操作信号 → 静默,不推
|
||||
|
||||
# 标准格式:每个可操作标的
|
||||
# 加载基本面缓存(PE等)
|
||||
fund_cache = {}
|
||||
try:
|
||||
with open("/home/hmo/web-dashboard/data/multi_tf_cache.json") as f:
|
||||
mtf = json.load(f)
|
||||
for code, v in mtf.items():
|
||||
fund_cache[code] = v.get("fundamentals", {})
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 标准格式:每个可操作标的 — 大盘/行业/个股三面+消息/基本面/技术面
|
||||
lines.append(f"【💡 操作建议】(当前{len(actionable)}只自选可操作)")
|
||||
for s in actionable:
|
||||
name, code, price, buy_low, buy_high, lot, ratio = s
|
||||
@@ -279,17 +289,58 @@ def main():
|
||||
sig = d.get("timing_signal", "")
|
||||
sector = d.get("sector_context", "")
|
||||
tech = d.get("tech_snapshot", "")
|
||||
factors = d.get("signal_factors", [])
|
||||
cat = d.get("stock_category", "")
|
||||
note = d.get("note", "")
|
||||
|
||||
# 提取技术位
|
||||
ss = {"强撑":"-", "弱撑":"-", "弱压":"-", "强压":"-"}
|
||||
for tag in ss:
|
||||
m = re.search(rf'{tag}:([\d.]+)', tech)
|
||||
if m:
|
||||
ss[tag] = m.group(1)
|
||||
|
||||
# 基本面
|
||||
fund = fund_cache.get(code, {})
|
||||
pe = fund.get("pe", 0)
|
||||
eps = fund.get("eps", 0)
|
||||
pe_str = f"PE{pe:.0f}" if pe else ""
|
||||
eps_str = f"EPS{eps:.2f}" if eps else ""
|
||||
|
||||
# 从 signal_factors 或 tag 提取各维度
|
||||
def _match_factor(prefix):
|
||||
for f in factors:
|
||||
if f.startswith(prefix):
|
||||
return f
|
||||
return ""
|
||||
|
||||
market_factor = _match_factor("大盘")
|
||||
sector_factor = _match_factor("行业")
|
||||
value_factor = _match_factor("高估值") or _match_factor("低估值") or _match_factor("蓝筹") or pe_str or ""
|
||||
news_factor = _match_factor("消息")
|
||||
tech_factor = _match_factor("净利") or _match_factor("组合") or ""
|
||||
|
||||
# 构建分析行
|
||||
parts = []
|
||||
if market_factor:
|
||||
parts.append(f"大盘{market_factor.replace('大盘','')}")
|
||||
if sector_factor:
|
||||
parts.append(f"行业{sector_factor.replace('行业','')}")
|
||||
if pe_str or value_factor:
|
||||
parts.append(value_factor or pe_str)
|
||||
if news_factor:
|
||||
parts.append(news_factor)
|
||||
if not parts:
|
||||
parts.append(sector or cat or "")
|
||||
|
||||
analysis = " | ".join(p for p in parts if p)
|
||||
|
||||
pfx = "" if len(code) == 6 else "HK$"
|
||||
lines.append(
|
||||
f" {name}({code}) {pfx}{price:.2f} 买区{buy_low}~{buy_high} | "
|
||||
f"1手{lot:,.0f}元 RR={rr:.1f} 损{sl} 盈{tp}\n"
|
||||
f" {sector} | {ss['强撑']}→{ss['弱撑']}→{ss['弱压']}→{ss['强压']} | {sig}"
|
||||
f" {analysis}\n"
|
||||
f" 技术{ss['强撑']}→{ss['弱撑']}→{ss['弱压']}→{ss['强压']} | 信号{sig}"
|
||||
)
|
||||
|
||||
lines.insert(0, f"【知微】自选买入提醒 {now} | 现金{cash:,.0f}元")
|
||||
|
||||
Reference in New Issue
Block a user