유효하지 않은 KEY 가 설정되어 있어도, 일단 UI 페이지가 나오도록 수정.
This commit is contained in:
@@ -23,6 +23,12 @@ class TradingService:
|
||||
self._client = httpx.AsyncClient(timeout=10.0)
|
||||
self._rate_limiter = RateLimiter(settings.rate_limit.requests_per_second)
|
||||
|
||||
def _check_auth(self) -> bool:
|
||||
if not token_manager.is_authenticated:
|
||||
logger.debug("API 인증되지 않음 - 매매 불가")
|
||||
return False
|
||||
return True
|
||||
|
||||
def _get_tr_id(self, side: str) -> str:
|
||||
mode = settings.kis.server_mode
|
||||
return _TR_IDS.get(mode, _TR_IDS["vps"]).get(side, "VTTC0802U")
|
||||
@@ -35,6 +41,9 @@ class TradingService:
|
||||
price: int = 0,
|
||||
order_type: str = "00",
|
||||
) -> dict:
|
||||
if not self._check_auth():
|
||||
return {"rt_cd": "-1", "msg": "API 인증되지 않음", "order_no": ""}
|
||||
|
||||
await self._rate_limiter.acquire()
|
||||
|
||||
tr_id = self._get_tr_id(side)
|
||||
@@ -86,6 +95,9 @@ class TradingService:
|
||||
async def modify_order(
|
||||
self, order_no: str, stock_code: str, qty: int, price: int, order_type: str = "00"
|
||||
) -> dict:
|
||||
if not self._check_auth():
|
||||
return {"rt_cd": "-1", "msg": "API 인증되지 않음"}
|
||||
|
||||
await self._rate_limiter.acquire()
|
||||
|
||||
tr_id = self._get_tr_id("modify")
|
||||
@@ -123,6 +135,9 @@ class TradingService:
|
||||
return result
|
||||
|
||||
async def cancel_order(self, order_no: str, stock_code: str, qty: int) -> dict:
|
||||
if not self._check_auth():
|
||||
return {"rt_cd": "-1", "msg": "API 인증되지 않음"}
|
||||
|
||||
await self._rate_limiter.acquire()
|
||||
|
||||
tr_id = self._get_tr_id("cancel")
|
||||
|
||||
Reference in New Issue
Block a user