virtual-insanity
← 리포트 목록

analyst 알림 데이터 기준 시점 표시 추가

2026-04-24 analyst [analyst, telegram, freshness, alert, hermes]

결론

4개 analyst 알림(macro/fundamental/technical/pm) 모두 본문 상단에 📊 데이터 기준: 한 줄이 들어가도록 적용했다.

  • macro: 전용 sender(macro_redesign_report.py)에서 표시
  • fundamental: 전용 sender(fundamental_redesign_report.py)에서 표시
  • technical/pm: 공용 sender(analyst_common_sender.py)에서 표시

실제 텔레그램 중복 발송은 막고, ANALYST_COMMON_NO_SEND=1로 최종 메시지 렌더링을 검증했다.

형식 결정 사유

상단 고정 한 줄 방식을 택했다.

예:

📊 데이터 기준: WTI=04-23 / DXY=04-23 / US10Y=04-22 / latest=04-24 07:00

이유:

  1. 해리가 본문을 열자마자 데이터 시점을 볼 수 있다.
  2. 50~90자 내외라 5,000자 제한에 영향이 작다.
  3. analyst별 데이터 구조가 달라도 같은 prefix로 통일된다.
  4. stale 여부를 나중에 grep/로그 집계하기 쉽다.

수정 파일과 백업

analyst 수정 파일 백업
macro /Users/ron/.hermes/workspace/scripts/macro_redesign_report.py macro_redesign_report.py.bak-freshness-marker-20260424123910
fundamental /Users/ron/.hermes/workspace/scripts/fundamental_redesign_report.py fundamental_redesign_report.py.bak-freshness-marker-20260424123910
technical /Users/ron/.hermes/workspace/scripts/analyst_common_sender.py analyst_common_sender.py.bak-freshness-marker-20260424123910
pm /Users/ron/.hermes/workspace/scripts/analyst_common_sender.py analyst_common_sender.py.bak-freshness-marker-20260424123910

요청은 “4개 파일 수정 diff”였지만 실제 구조상 technical/pm은 같은 공용 sender를 사용한다. 그래서 수정 파일은 3개이고, 적용 대상은 4개 analyst 전부다.

diff 요약

1) analyst_common_sender.py

추가:

def freshness_marker(analyst: str, data: dict) -> str:
    ...
    return "📊 데이터 기준: ..."

삽입 위치:

lines.append(f"발송: {now}")
marker = freshness_marker(analyst, data)
if marker:
    lines.append(marker)

technical은 data_vintage에서 price-history/US/KR/FX 기준일을 추출하고, pm은 data_dates에서 macro/fundamental/technical 기준일을 추출한다.

2) macro_redesign_report.py

추가:

def freshness_marker(latest: dict) -> str:
    ...
    return "📊 데이터 기준: WTI=... / DXY=... / US10Y=... / latest=..."

삽입 위치:

headline = str(latest.get("headline") or "Macro Analyst")
lines.append(f"🌐 {headline}")
marker = freshness_marker(latest)
if marker:
    lines.append(marker)

3) fundamental_redesign_report.py

추가:

def freshness_marker(data: dict, ctx: dict) -> str:
    ...
    return "📊 데이터 기준: DART=... / EDGAR=... / 실적=... / latest=..."

변경:

def build_body(ctx: dict, latest: dict | None = None) -> str:
    ...

삽입 위치:

lines.append(f"기준: {today} / 전송: {now}")
marker = freshness_marker(latest or {}, ctx)
if marker:
    lines.append(marker)

검증 결과

py_compile

cd /Users/ron/.hermes/workspace
python3 -m py_compile \
  scripts/analyst_common_sender.py \
  scripts/macro_redesign_report.py \
  scripts/fundamental_redesign_report.py
OK

4개 analyst no-send 렌더링

실행:

cd /Users/ron/.hermes/workspace
for a in macro fundamental technical pm; do
  ANALYST_COMMON_SKIP_RUN=1 \
  ANALYST_COMMON_NO_SEND=1 \
  ANALYST_COMMON_PRINT_BODY=1 \
  bash scripts/analyst_common_wrapper.sh "$a" \
    > "/tmp/analyst_${a}_freshness.out" \
    2> "/tmp/analyst_${a}_freshness.err"
done

결과 샘플:

analyst freshness 표시 결과
macro 📊 데이터 기준: WTI=04-23 / DXY=04-23 / US10Y=04-22 / latest=04-24 07:00 PASS
fundamental 📊 데이터 기준: DART=04-23 / EDGAR=04-23 / 실적=04-23 / latest=04-24 07:10 PASS
technical 📊 데이터 기준: price=04-23 / US=04-24 / KR=04-24 / FX=04-24 / latest=04-24 07:20 PASS
pm 📊 데이터 기준: macro=04-24 / fund=04-24 / tech=04-24 / latest=04-24 12:38 PASS

각 렌더링은 no_send=true로 종료되어 실제 텔레그램 중복 발송은 발생하지 않았다.

메시지 길이

analyst body_len 판정
macro 2006 안전
fundamental 2168 안전
technical 2554 안전
pm 2518 안전

5,000자 제한에 걸리지 않는다.

다음 정기 발송 반영 여부

크론이나 wrapper 수정은 필요 없다. 기존 정기 발송 경로가 그대로 아래 파일들을 호출하므로 내일 아침 정기 알림부터 자동 반영된다.

  • macro → macro_redesign_report.py
  • fundamental → fundamental_redesign_report.py
  • technical/pm → analyst_common_sender.py

남은 리스크

  • 일부 latest.json에 metadata가 비어 있으면 파일 mtime 또는 제한된 필드만 표시된다.
  • 실제 발송 검증은 중복 알림 방지를 위해 하지 않았고, no-send 최종 본문 렌더링으로 검증했다.

자체평가

  • 정확성: 4.5/5 — 4개 analyst 모두 실제 최종 메시지 렌더링에서 freshness 줄 확인.
  • 완성도: 4.5/5 — 백업, 구현, 검증, 보고 완료.
  • 검증: 4.5/5 — py_compile + 4개 no-send 렌더링 확인.
  • 최소 변경: 4.5/5 — sender 3개만 수정, cron/비즈니스 로직 변경 없음.

종합: 4.5/5

DONE