From 56f73a6320e4f81a58115f25cf4c22cd58c2a490 Mon Sep 17 00:00:00 2001 From: jongjae Date: Tue, 19 May 2026 08:09:06 +0900 Subject: [PATCH] =?UTF-8?q?[2026-05-19]=20KIS=20=ED=86=A0=ED=81=B0=20EGW00?= =?UTF-8?q?133=20=EC=B2=98=EB=A6=AC=20=EA=B0=9C=EC=84=A0=20=E2=80=94=20?= =?UTF-8?q?=EC=BA=90=EC=8B=9C=20=EC=9E=AC=EC=82=AC=EC=9A=A9=20+=2060?= =?UTF-8?q?=EC=B4=88=20=EC=9E=AC=EC=8B=9C=EB=8F=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- app/execution/kis_client.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/execution/kis_client.py b/app/execution/kis_client.py index d4d52c4..b57daba 100644 --- a/app/execution/kis_client.py +++ b/app/execution/kis_client.py @@ -123,7 +123,19 @@ class KISClient: data = await resp.json() if "access_token" not in data: - raise RuntimeError(f"토큰 발급 실패: {data}") + # EGW00133: 분당 1회 제한 — 캐시 토큰이 아직 유효하면 그대로 사용 + if data.get("error_code") == "EGW00133" and self._access_token: + logger.warning("KIS 토큰 발급 속도 제한(EGW00133) — 기존 캐시 토큰 유지") + return self._access_token + # 캐시 없으면 60초 대기 후 1회 재시도 + if data.get("error_code") == "EGW00133": + logger.warning("KIS 토큰 발급 속도 제한(EGW00133) — 60초 후 재시도") + await asyncio.sleep(60) + async with aiohttp.ClientSession() as session: + async with session.post(url, json=body) as resp: + data = await resp.json() + if "access_token" not in data: + raise RuntimeError(f"토큰 발급 실패: {data}") self._access_token = data["access_token"] # 유효기간 24시간