INNER CODE UNIT · Python
email_lines
renee-jia/trading-bot · ai_portfolio.py:307
def email_lines(data):
lines = ["=== AI PORTFOLIO ==="]
for x in data.get("names") or []:
score = f"评分 {x['score']:.0f}" if x["score"] is not None else "评分 —"
rec = REC_CN.get(x["recommendation"], "")
k = x.get("pick")
put = (f"put {x['expiry']} ${k['strike']:.0f}P @{k['mid']:.2f}"
if k and x.get("expiry") else (x.get("entry_label") or "put —"))
lines.append(
f" {x['ticker']:<5} {_money(x['price']):>8} {_pct(x['change_1d']):>7} "
f"{score}{'(' + rec + ')' if rec else ''} | {x['buy_label']} | "
f"买点 {_levels_cell(x)} | {put}"
)
watch = data.get("watch") or []
if watch:
lines.append("观察名单:")
for x in watch:
score = f"评分 {x['score']:.0f}" if x["score"] is not None else "评分 —"