INNER CODE UNIT · Python
subset
renee-jia/trading-bot · ai_portfolio.py:149
subset = [rows[n] for n in names + watch if n in rows]
cards, event = daily_watch.annotate(
subset, held=held, today=today, tape=(macro_result or {}).get("macro_tape"))
card_map = {c["ticker"]: c for c in cards}
plan_map = {p["ticker"]: p for p in ((sell_put_plan or {}).get("names") or [])}
out = [_item(n, rows.get(n), card_map.get(n), plan_map.get(n)) for n in names]
watch_items = [_item(n, rows.get(n), card_map.get(n), plan_map.get(n)) for n in watch]
scored = [x for x in out if x["score"] is not None]
d1 = [x["change_1d"] for x in out if x["change_1d"] is not None]
summary = {
"total": len(out),
"in_run": sum(1 for x in out if x["in_run"]),
"avg_score": sum(x["score"] for x in scored) / len(scored) if scored else None,
"avg_1d": sum(d1) / len(d1) if d1 else None,
"buy_now": [x["ticker"] for x in out if x["buy_action"] == "buy"],
"scale_in": [x["ticker"] for x in out if x["buy_action"] in ("scale_in", "add_held")],