실시간 웹소켓 리팩토링

This commit is contained in:
2026-02-23 15:37:22 +09:00
parent 276ef09d89
commit 19ebb1c6ea
10 changed files with 510 additions and 96 deletions

View File

@@ -25,8 +25,15 @@ export function useCurrentPrice({
// 1. Priority: Realtime Tick (Trade WS)
if (latestTick?.price && latestTick.price > 0) {
currentPrice = latestTick.price;
change = latestTick.change;
changeRate = latestTick.changeRate;
// 실시간 틱(change/changeRate)은 TR 종류(실체결/예상체결)에 따라 해석 차이가 있을 수 있어
// 화면 표시는 항상 전일종가(prevClose) 기준으로 재계산해 일관성을 유지합니다.
if (prevClose > 0) {
change = currentPrice - prevClose;
changeRate = (change / prevClose) * 100;
} else {
change = latestTick.change;
changeRate = latestTick.changeRate;
}
}
// 2. Fallback: OrderBook Best Ask (Proxy for current price if no tick)
else if (