auto: 일일 백업 2026-06-23 02:00
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -859,7 +859,7 @@ def _build_data_block(snap: dict) -> str:
|
||||
lines.append(f'### 종목: {snap["name"]} ({snap["code"]})')
|
||||
lines.append(f'- 현재가: {b["price"]:,}원 ({b["change"]:+,} / {b["change_pct"]:+.2f}%)')
|
||||
lines.append(f'- 오늘 시고저: 시 {b["open"]:,} / 고 {b["high"]:,} / 저 {b["low"]:,}')
|
||||
lines.append(f'- 시가총액: {b["market_cap"]:,} (단위 키움원본) · 상장주식수: {b["listed_shares"]:,}주')
|
||||
lines.append(f'- 시가총액: {_fmt_market_cap(b["market_cap"])} · 상장주식수: {b["listed_shares"]:,}주')
|
||||
lines.append(f'- 52주 고저: 고 {b["high_52w"]:,}원 ({_fmt_date(b["high_52w_dt"])}) / 저 {b["low_52w"]:,}원 ({_fmt_date(b["low_52w_dt"])})')
|
||||
lines.append(f'- 회전율(오늘): {b["turnover_rate"]:.2f}% · 외국인 보유비율: {b["foreign_holding_pct"]:.2f}%')
|
||||
lines.append(f'- PER {b["per"]} · PBR {b["pbr"]} · ROE {b["roe"]} · EPS {b["eps"]:,} · BPS {b["bps"]:,}')
|
||||
@@ -1121,6 +1121,19 @@ def _fmt_pct_signed(v: float) -> str:
|
||||
return f'{v:+.2f}%'
|
||||
|
||||
|
||||
def _fmt_market_cap(eok) -> str:
|
||||
"""키움 mac(억원) → 사람이 읽는 '2,084조 1,983억원'. 0/None은 '—'."""
|
||||
if not isinstance(eok, (int, float)) or eok <= 0:
|
||||
return '—'
|
||||
eok = int(eok)
|
||||
jo, rem = divmod(eok, 10000)
|
||||
if jo and rem:
|
||||
return f'{jo:,}조 {rem:,}억원'
|
||||
if jo:
|
||||
return f'{jo:,}조원'
|
||||
return f'{rem:,}억원'
|
||||
|
||||
|
||||
def _fmt_date(s) -> str:
|
||||
"""20260519 → 2026-05-19. 형식 다르면 원본 반환."""
|
||||
s = str(s or '').strip()
|
||||
@@ -1477,6 +1490,12 @@ def build_report_html(snap: dict, parsed: dict) -> str:
|
||||
v = p.get(field)
|
||||
return f'{v:,}{suffix}' if isinstance(v, (int, float)) else '—'
|
||||
|
||||
def _peer_mac(p: dict) -> str:
|
||||
if p.get('error'):
|
||||
return '<span style="color:#ef4444;font-size:11px">조회 실패</span>'
|
||||
v = p.get('market_cap')
|
||||
return _fmt_market_cap(v) if isinstance(v, (int, float)) else '—'
|
||||
|
||||
def _peer_pct(p: dict, field: str) -> str:
|
||||
if p.get('error'):
|
||||
return '<span style="color:#ef4444;font-size:11px">조회 실패</span>'
|
||||
@@ -1501,8 +1520,7 @@ def build_report_html(snap: dict, parsed: dict) -> str:
|
||||
('오늘 시가', f'{b["open"]:,}원', lambda p: _peer_int(p, 'open', '원')),
|
||||
('오늘 고가', f'{b["high"]:,}원', lambda p: _peer_int(p, 'high', '원')),
|
||||
('오늘 저가', f'{b["low"]:,}원', lambda p: _peer_int(p, 'low', '원')),
|
||||
('시가총액', f'{b["market_cap"]:,} <span style="color:#7a8493;font-size:11px">(키움 원본 단위)</span>',
|
||||
lambda p: _peer_int(p, 'market_cap', '')),
|
||||
('시가총액', _fmt_market_cap(b["market_cap"]), _peer_mac),
|
||||
('상장주식수', f'{b["listed_shares"]:,}주', lambda p: _peer_int(p, 'listed_shares', '주')),
|
||||
('52주 최고', f'{b["high_52w"]:,}원 <span style="color:#7a8493;font-size:11px">({_fmt_date(b["high_52w_dt"])})</span>',
|
||||
lambda p: _peer_52w(p, 'high_52w', 'high_52w_dt')),
|
||||
|
||||
Reference in New Issue
Block a user