auto: 일일 백업 2026-07-18 02:00
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -603,11 +603,12 @@ CHART_RANGE_DAYS = {'1Y': 250, '6M': 120, '3M': 63, '1M': 21}
|
||||
|
||||
|
||||
def render_svg_chart(snap: dict, range_key: str = '1Y', ref_price: float | None = None,
|
||||
intraday: bool = False) -> str:
|
||||
intraday: bool = False, hlines: list | None = None) -> str:
|
||||
"""캔들 + SMA 3선 + 거래량 막대(+일봉 20일 거래량 이동평균선) 인라인 SVG.
|
||||
|
||||
range_key: '1Y' (250일) | '6M' (120일) | '3M' (63일) | '1M' (21일). 같은 snapshot 데이터에서 슬라이스만.
|
||||
ref_price: 기준가(전일종가 등) — 지정 시 노란 점선 기준선 + 마지막 종가의 대비 등락률 표시 (분봉용).
|
||||
hlines: 사용자가 등록한 수평선 가격 리스트(지지/저항 등). 표시 구간 안에 드는 값만 그린다(스케일 미확장).
|
||||
회전율 값은 차트에 그리지 않고 caller가 turnover_today()로 별도 표시 (차트 아래).
|
||||
snap: collect_snapshot 결과. candles_asc·sma5/20/60 사용.
|
||||
외부 JS 의존성 0. CSS는 inline.
|
||||
@@ -872,6 +873,31 @@ def render_svg_chart(snap: dict, range_key: str = '1Y', ref_price: float | None
|
||||
f'font-size="26" font-weight="700">{int(round(cur_price)):,}</text>'
|
||||
)
|
||||
|
||||
# ---- 사용자 수평선 (hlines) — 지지/저항 등 수동 등록 가격선 ----
|
||||
# 표시 구간(y_min~y_max) 안에 드는 값만 그린다. 스케일은 확장하지 않음(캔들 가독성 우선).
|
||||
# 좌측에 분홍 가격 태그를 둔다(우측은 가격축·현재가 태그가 이미 점유).
|
||||
for hp in (hlines or []):
|
||||
try:
|
||||
hp = float(hp)
|
||||
except (TypeError, ValueError):
|
||||
continue
|
||||
if hp < y_min or hp > y_max:
|
||||
continue
|
||||
hly = price_y(hp)
|
||||
parts.append(
|
||||
f'<line x1="{CHART_PAD_L}" y1="{hly:.1f}" x2="{CHART_W-CHART_PAD_R}" y2="{hly:.1f}" '
|
||||
f'stroke="#e879f9" stroke-width="1.6" stroke-dasharray="6 4" opacity="0.9"/>'
|
||||
)
|
||||
htag_y = min(max(hly, PRICE_TOP + 15), PRICE_BOT - 15)
|
||||
parts.append(
|
||||
f'<rect x="{CHART_PAD_L+2}" y="{htag_y-15:.1f}" width="122" height="30" '
|
||||
f'fill="#e879f9" rx="3" opacity="0.95"/>'
|
||||
)
|
||||
parts.append(
|
||||
f'<text x="{CHART_PAD_L+8}" y="{htag_y+8:.1f}" text-anchor="start" fill="#1a0f1f" '
|
||||
f'font-size="26" font-weight="700">{int(round(hp)):,}</text>'
|
||||
)
|
||||
|
||||
parts.append('</svg>')
|
||||
return ''.join(parts)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user