전일대비 부호 및 API 데이터 파싱 로직 개선:
Some checks failed
Build Push and Restart Compose / deploy (push) Failing after 1m13s

- `utils.ts`: 전일대비 부호 매핑 로직(1=상한가, 4=하한가) 수정 및 관련 함수(`sigToArrow`, `sigClass`) 업데이트.
- `types.ts`: `IndexQuote` 인터페이스의 `value` 필드명을 `price`로 수정.
- `kiwoom_ws_service.go`, `theme_service.go`, `kiwoom_service.go`: 전일대비 데이터 파싱 시 부호 결정 로직 추가(`signedChange`, `signedChangeBySig`) 및 관련 함수 호출로 대체.
- 기존 `predPre` 처리 부분을 양수/음수를 정확히 계산하도록 변경.
- `kospi200_service.go`: `PredPre` 필드 부호 처리 로직(`signedChangeBySig`) 추가.
- Svelte 페이지 업데이트:
  - `+page.svelte` 파일에서 `value` 필드를 `price`로 대체.
  - `theme` 및 `kospi200` 페이지에서 전일대비 표시값 절댓값으로 렌더링되도록 수정 (`Math.abs` 적용).
This commit is contained in:
hayato5246
2026-04-08 19:53:51 +09:00
parent ba18887ed8
commit 2f8a6ea349
9 changed files with 53 additions and 21 deletions

View File

@@ -149,7 +149,7 @@ export interface WatchlistItem {
export interface IndexQuote {
name: string
value: number
price: number
change: number
changeRate: number
}

View File

@@ -39,16 +39,16 @@ export function formatDate(iso: string): string {
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`
}
// 전일대비 부호 문자 (2=상승, 3=보합, 5=하락)
// 전일대비 부호 문자 (1=상한가, 2=상승, 3=보합, 4=하한가, 5=하락)
export function sigToArrow(sig: string): string {
if (sig === '2') return '▲'
if (sig === '5') return '▼'
if (sig === '1' || sig === '2') return '▲'
if (sig === '4' || sig === '5') return '▼'
return '-'
}
// 전일대비 부호에 따른 클래스
export function sigClass(sig: string): string {
if (sig === '2') return 'text-red-400'
if (sig === '5') return 'text-blue-400'
if (sig === '1' || sig === '2') return 'text-red-400'
if (sig === '4' || sig === '5') return 'text-blue-400'
return 'text-gray-400'
}

View File

@@ -296,7 +296,7 @@
{#each indices as idx}
<div class="bg-gray-800 rounded-lg px-4 py-3">
<div class="text-xs text-gray-400 mb-1">{idx.name}</div>
<div class="text-lg font-bold text-white">{idx.value.toLocaleString('ko-KR', { maximumFractionDigits: 2 })}</div>
<div class="text-lg font-bold text-white">{idx.price.toLocaleString('ko-KR', { maximumFractionDigits: 2 })}</div>
<div class="text-sm {priceClass(idx.changeRate)}">{formatRate(idx.changeRate)}</div>
</div>
{/each}

View File

@@ -97,7 +97,7 @@
{stock.curPrc.toLocaleString()}
</td>
<td class="px-3 py-3 text-right text-sm {sigClass(stock.predPreSig)}">
{sigToArrow(stock.predPreSig)} {stock.predPre.toLocaleString()}
{sigToArrow(stock.predPreSig)} {Math.abs(stock.predPre).toLocaleString()}
</td>
<td class="px-3 py-3 text-right text-sm {priceClass(stock.fluRt)}">
{formatRate(stock.fluRt)}

View File

@@ -190,7 +190,7 @@
{stock.curPrc.toLocaleString()}
</td>
<td class="px-3 py-3 text-right text-sm {priceClass(stock.fluRt)}">
{sigToArrow(stock.fluSig)}{stock.predPre.toLocaleString()}
{sigToArrow(stock.fluSig)}{Math.abs(stock.predPre).toLocaleString()}
</td>
<td class="px-3 py-3 text-right text-sm {priceClass(stock.fluRt)}">
{formatRate(stock.fluRt)}