Add a Monday-morning weekly recap briefing
No US session closes into Monday KST, so Mondays (default 07:00, cron in the daemon with restart catch-up) now publish a weekly review built entirely from stored data: the quotes table collapsed into week-over- week changes and the week's daily briefing headlines as the narrative. The recap is a BriefingResult kind="weekly" reusing MarketPayload, so the store, verification pass, all delivery channels (Blogger title "미국 주간 리뷰 <monday>") and the dashboard (주간 리뷰 badge) work unchanged. Manual runs via `run-once --weekly [--date <monday>]`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -221,6 +221,45 @@ def render_markdown(payload: MarketPayload, report: Report | None, model_used: s
|
||||
return "\n".join(lines).rstrip() + "\n"
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ weekly recap
|
||||
|
||||
|
||||
def _weekly_report_sections(report: Report) -> list[str]:
|
||||
out: list[str] = []
|
||||
if _text(report.headline):
|
||||
out += _section("주간 총평", [f"**{_text(report.headline)}**"])
|
||||
if _text(report.market_overview):
|
||||
out += _section("주간 개요", [_text(report.market_overview)])
|
||||
out += _section("지난주 주요 사건", _bullets(report.key_drivers))
|
||||
if _text(report.rates_fx_commodities):
|
||||
out += _section("금리·환율·원자재", [_text(report.rates_fx_commodities)])
|
||||
out += _section("이번 주 한국 장 시사점", _bullets(report.korea_implications))
|
||||
out += _section("이번 주 볼 것", _bullets(report.watchlist_today))
|
||||
out += _section("리스크", _bullets(report.risk_flags))
|
||||
return out
|
||||
|
||||
|
||||
def render_weekly_markdown(payload: MarketPayload, report: Report | None, week_sessions: list) -> str:
|
||||
"""Render the Monday weekly recap. `payload.quotes` carry week-over-week changes."""
|
||||
first = week_sessions[0].isoformat() if week_sessions else "?"
|
||||
last = week_sessions[-1].isoformat() if week_sessions else "?"
|
||||
lines = [f"# 🇺🇸→🇰🇷 미국 주간 리뷰 — {payload.krx_date.isoformat()} (미 {first} ~ {last})"]
|
||||
gen_kst = _kst(payload.generated_at).strftime("%Y-%m-%d %H:%M")
|
||||
lines.append(f"지난주 미국 거래일 {len(week_sessions)}일 · 생성: {gen_kst} KST")
|
||||
if not payload.krx_open_today:
|
||||
lines.append("⚠️ 오늘 한국 휴장")
|
||||
if report is None:
|
||||
lines.append("🧩 축소 모드(LLM 요약 없음)")
|
||||
lines.append("")
|
||||
if report is not None:
|
||||
lines += _weekly_report_sections(report)
|
||||
for g, title, qs in _ordered_groups(payload):
|
||||
lines += _section(f"📊 {title} — 주간 변동", _quote_table(g, qs))
|
||||
lines += _section("일별 헤드라인", _bullets(payload.history_notes))
|
||||
lines += _section("수집 누락", _bullets(payload.data_gaps))
|
||||
return "\n".join(lines).rstrip() + "\n"
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ Telegram HTML
|
||||
|
||||
_LINK_RE = re.compile(r"\[([^\]]+)\]\(([^)\s]+)\)")
|
||||
|
||||
Reference in New Issue
Block a user