디자인 변경

This commit is contained in:
2026-02-11 15:27:03 +09:00
parent 95291e6922
commit f650d51f68
15 changed files with 667 additions and 505 deletions

View File

@@ -47,9 +47,9 @@ function resolveOrderBookTrId(
}
/**
* @description KIS 실시간 체결/호가를 단일 WebSocket으로 구독합니다.
* @see features/dashboard/components/DashboardContainer.tsx useKisTradeWebSocket 호출
* @see lib/kis/domestic-market-session.ts 장 세션 계산 및 테스트용 override
* @description Subscribes trade ticks and orderbook over one websocket.
* @see features/dashboard/components/DashboardContainer.tsx
* @see lib/kis/domestic-market-session.ts
*/
export function useKisTradeWebSocket(
symbol: string | undefined,
@@ -83,7 +83,6 @@ export function useKisTradeWebSocket(
? resolveTradeTrId(credentials.tradingEnv, marketSession)
: TRADE_TR_ID;
// KST 장 세션을 주기적으로 재평가합니다.
useEffect(() => {
const timerId = window.setInterval(() => {
const nextSession = resolveSessionInClient();
@@ -93,13 +92,12 @@ export function useKisTradeWebSocket(
return () => window.clearInterval(timerId);
}, []);
// 연결은 되었는데 체결이 오래 안 들어오는 경우 안내합니다.
useEffect(() => {
if (!isConnected || lastTickAt) return;
const timer = window.setTimeout(() => {
setError(
"실시간 연결은 되었지만 체결 데이터가 없습니다. 장 시간(한국시간) 여부를 확인해 주세요.",
"실시간 연결은 되었지만 체결 데이터가 없습니다. 장 시간(한국시간)과 TR ID를 확인해 주세요.",
);
}, 8000);
@@ -134,22 +132,18 @@ export function useKisTradeWebSocket(
setError(null);
setIsConnected(false);
const approvalKey = await useKisRuntimeStore
const wsConnection = await useKisRuntimeStore
.getState()
.getOrFetchApprovalKey();
.getOrFetchWsConnection();
if (!approvalKey) {
if (!wsConnection) {
throw new Error("웹소켓 승인키 발급에 실패했습니다.");
}
if (disposed) return;
approvalKeyRef.current = approvalKey;
approvalKeyRef.current = wsConnection.approvalKey;
const wsBase =
process.env.NEXT_PUBLIC_KIS_WS_URL ||
"ws://ops.koreainvestment.com:21000";
socket = new WebSocket(`${wsBase}/tryitout/${tradeTrId}`);
socket = new WebSocket(`${wsConnection.wsUrl}/tryitout/${tradeTrId}`);
socketRef.current = socket;
socket.onopen = () => {