diff --git a/agents/stock/workspace/scripts/behive_web.py b/agents/stock/workspace/scripts/behive_web.py index 9b3a462..f2e5b6d 100644 --- a/agents/stock/workspace/scripts/behive_web.py +++ b/agents/stock/workspace/scripts/behive_web.py @@ -10024,6 +10024,8 @@ class Handler(BaseHTTPRequestHandler): if not mins: self.send_error(404, 'no minute candles') return + # 당일 시가 = 오늘 첫 봉 시가. range 슬라이스 전에 캡처 — 구간을 좁혀도 baseline 고정. + day_open = mins[0].get('open') or 0 # range 슬라이스 — 최근 N 봉만. if range_minutes is not None: num_bars = max(1, range_minutes // tic_scope) @@ -10061,7 +10063,7 @@ class Handler(BaseHTTPRequestHandler): prev_close = _pc except Exception: pass - svg = sa.render_svg_chart(snap, range_key='1Y', ref_price=prev_close, intraday=True) + svg = sa.render_svg_chart(snap, range_key='1Y', ref_price=prev_close, intraday=True, day_open=day_open) body = svg.encode('utf-8') body, enc = _maybe_gzip(body, self.headers.get('Accept-Encoding')) self.send_response(200) diff --git a/agents/stock/workspace/scripts/stock_analysis.py b/agents/stock/workspace/scripts/stock_analysis.py index 9da0835..dc24dd3 100644 --- a/agents/stock/workspace/scripts/stock_analysis.py +++ b/agents/stock/workspace/scripts/stock_analysis.py @@ -546,7 +546,7 @@ VOL_BOT = VOL_TOP + VOL_PANEL_H CHART_RANGE_DAYS = {'1Y': 250, '6M': 120, '1M': 21} -def render_svg_chart(snap: dict, range_key: str = '1Y', ref_price: float | None = None, intraday: bool = False) -> str: +def render_svg_chart(snap: dict, range_key: str = '1Y', ref_price: float | None = None, intraday: bool = False, day_open: float | None = None) -> str: """캔들 + SMA 3선 + 거래량 막대 인라인 SVG. range_key: '1Y' (250일) | '6M' (120일) | '1M' (21일). 같은 snapshot 데이터에서 슬라이스만. @@ -611,8 +611,9 @@ def render_svg_chart(snap: dict, range_key: str = '1Y', ref_price: float | None ], 'ymin': y_min, 'ymax': y_max, - # 분봉일 때만 당일 시가(첫 봉 시가) — 크로스헤어 툴팁의 '당일시가 대비 등락률'용. - 'dayOpen': (candles[0]['open'] if (intraday and candles) else 0), + # 분봉일 때만 당일 시가 — 크로스헤어 툴팁의 '당일시가 대비 등락률'용. + # day_open(슬라이스 전 오늘 첫 봉 시가)을 caller가 넘기면 그걸 baseline으로 (구간 슬라이스 영향 X). + 'dayOpen': (int(day_open) if (intraday and day_open) else 0), 'priceTop': PRICE_TOP, 'priceBot': PRICE_BOT, 'volTop': VOL_TOP, @@ -712,13 +713,7 @@ def render_svg_chart(snap: dict, range_key: str = '1Y', ref_price: float | None parts.append( f'전일' ) - last_close = candles[-1]['close'] - pct = (last_close / ref_price - 1) * 100 - pc = '#ef4444' if pct > 0 else '#3b82f6' if pct < 0 else '#9ca3af' # 한국 관습: 상승=빨강 - parts.append( - f'{last_close:,} 전일대비 {pct:+.2f}%' - ) + # 우상단 '전일대비 X%' 텍스트는 제거(관리자 요청) — 전일종가 기준선만 유지. # SMA 범례 legend_y = PRICE_TOP + 14