auto: 일일 백업 2026-06-18 02:00

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hyowons
2026-06-18 02:00:02 +09:00
parent b3696949f5
commit 70e2251995
444 changed files with 9612 additions and 997 deletions
@@ -723,11 +723,13 @@ def get_stock_quote(code: str, account_label: str | None = None, exchange: str =
}
def get_watchlist_quotes(codes: list[str], account_label: str | None = None,
exchange: str = 'AL') -> dict[str, dict]:
"""ka10095 관심종목정보요청 — 다종목 시세 batch (한 콜로 N개).
WATCHLIST_BATCH_MAX = 40 # ka10095 한 콜 종목 수 한도 — 초과 시 "허용된 요청 개수 초과[1634]" (2026-06-17, universe 120개에서 발견)
def get_watchlist_quotes(codes: list[str], account_label: str | None = None,
exchange: str = 'AL') -> dict[str, dict]:
"""ka10095 관심종목정보요청 — 다종목 시세 batch. 종목 수가 한도(WATCHLIST_BATCH_MAX) 초과 시 자동 분할 호출.
19종목 ~0.05s. ka10001×N 대비 rate limit 영향 없음.
반환: {clean_code: {price, change, change_pct, name}}. 빈 codes면 빈 dict.
"""
clean_codes = [_clean_code(c) for c in codes if c]
@@ -735,8 +737,16 @@ def get_watchlist_quotes(codes: list[str], account_label: str | None = None,
return {}
label = account_label or _default_account_label()
suffix = f'_{exchange}' if exchange in ('NX', 'AL') else ''
stk_cd_param = '|'.join(f'{c}{suffix}' for c in clean_codes)
resp = _call(label, TR_WATCHLIST_INFO, {'stk_cd': stk_cd_param}, endpoint=ENDPOINT_STKINFO)
out: dict[str, dict] = {}
for i in range(0, len(clean_codes), WATCHLIST_BATCH_MAX):
chunk = clean_codes[i:i + WATCHLIST_BATCH_MAX]
stk_cd_param = '|'.join(f'{c}{suffix}' for c in chunk)
resp = _call(label, TR_WATCHLIST_INFO, {'stk_cd': stk_cd_param}, endpoint=ENDPOINT_STKINFO)
out.update(_parse_watchlist_rows(resp))
return out
def _parse_watchlist_rows(resp: dict) -> dict[str, dict]:
out: dict[str, dict] = {}
for row in resp.get('atn_stk_infr') or []:
raw_code = (row.get('stk_cd') or '').strip()
@@ -759,7 +769,7 @@ def get_watchlist_quotes(codes: list[str], account_label: str | None = None,
return out
def get_quote_book(code: str, account_label: str | None = None) -> dict:
def get_quote_book(code: str, account_label: str | None = None) -> dict: # noqa: E302
"""주식호가 조회 (ka10004) — 10단계 매도/매수 호가 + 잔량.
매매 아님 — 조회 전용. 호가창 표시·체결 가능성 판단에 사용.