feat: ADR 수치도 누적분 평균으로 표시(20일 미만)

_compute_adr_ma_latest를 확장 윈도우로 — 20일 미만이어도 가용분 평균 숫자 표시('누적 N/20일 평균').
단 과열/침체 태그·색은 20일 채워질 때까지 보류(짧은 윈도우 임계치 해석 부정확). 차트 정책과 일치.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hyowons
2026-06-08 15:59:00 +09:00
parent ceb9b8565d
commit cb570437aa
+10 -5
View File
@@ -5108,8 +5108,7 @@ def _compute_adr_ma_latest(symbol: str, today_raw_adr: float | None, today_date:
return (None, 0, False) return (None, 0, False)
used = base[-window:] used = base[-window:]
used_live = any(r.get('is_live') for r in used) used_live = any(r.get('is_live') for r in used)
if len(used) < window: # 확장 윈도우: window 미만이어도 가용한 만큼의 평균을 돌려준다(차트와 동일 정책). count로 누적 여부 표기.
return (None, len(used), used_live)
avg = sum(r['adr'] for r in used) / len(used) avg = sum(r['adr'] for r in used) / len(used)
return (avg, len(used), used_live) return (avg, len(used), used_live)
@@ -5143,13 +5142,19 @@ def _render_adr_summary_block(rows: list[dict] | None) -> str:
bd = r.get('bizdate') bd = r.get('bizdate')
today_iso = f'{bd[:4]}-{bd[4:6]}-{bd[6:]}' if (bd and len(bd) == 8) else None today_iso = f'{bd[:4]}-{bd[4:6]}-{bd[6:]}' if (bd and len(bd) == 8) else None
ma, count, _used_live = _compute_adr_ma_latest(r['symbol'], raw_adr, today_iso) ma, count, _used_live = _compute_adr_ma_latest(r['symbol'], raw_adr, today_iso)
full = count >= ADR_MA_WINDOW
adr_cls, adr_tag = _adr_class(ma) adr_cls, adr_tag = _adr_class(ma)
if ma is not None: if ma is None:
adr_str = ''
sub_html = '<div class="adr-sub muted small">미수신</div>'
elif full:
adr_str = f'{ma:.1f}' adr_str = f'{ma:.1f}'
sub_html = '<div class="adr-sub muted small">20일 이평</div>' sub_html = '<div class="adr-sub muted small">20일 이평</div>'
else: else:
adr_str = '' # 누적 < 20일 — 숫자는 보여주되 과열/침체 판정은 보류(짧은 윈도우는 임계치 해석 부정확).
sub_html = f'<div class="adr-sub muted small">누적 중 {count}/{ADR_MA_WINDOW}</div>' adr_str = f'{ma:.1f}'
sub_html = f'<div class="adr-sub muted small">누적 {count}/{ADR_MA_WINDOW}일 평균</div>'
adr_cls, adr_tag = '', ''
tag_html = f' <span class="adr-tag {adr_cls}">{adr_tag}</span>' if adr_tag else '' tag_html = f' <span class="adr-tag {adr_cls}">{adr_tag}</span>' if adr_tag else ''
body_rows.append( body_rows.append(
f'<tr>' f'<tr>'