전일대비 부호 및 API 데이터 파싱 로직 개선:
Some checks failed
Build Push and Restart Compose / deploy (push) Failing after 1m13s
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:
@@ -434,11 +434,17 @@ func (k *KiwoomWSClient) reconnect() {
|
||||
func parseRealPrice(code string, v map[string]string) *models.StockPrice {
|
||||
normalized := strings.TrimPrefix(code, "A")
|
||||
normalized = strings.SplitN(normalized, "_", 2)[0] // _NX, _AL 등 접미사 제거
|
||||
// 전일대비(v["11"])는 절댓값으로 파싱 후, 등락률(v["12"]) 부호에 맞춰 부호 결정
|
||||
changeAbs := absInt(parseWSInt(v["11"]))
|
||||
changeRate := parseWSFloat(v["12"])
|
||||
if changeRate < 0 {
|
||||
changeAbs = -changeAbs
|
||||
}
|
||||
return &models.StockPrice{
|
||||
Code: normalized,
|
||||
CurrentPrice: absInt(parseWSInt(v["10"])),
|
||||
ChangePrice: parseWSInt(v["11"]),
|
||||
ChangeRate: parseWSFloat(v["12"]),
|
||||
ChangePrice: changeAbs,
|
||||
ChangeRate: changeRate,
|
||||
Volume: absInt(parseWSInt(v["13"])),
|
||||
TradeMoney: absInt(parseWSInt(v["14"])),
|
||||
TradeVolume: absInt(parseWSInt(v["15"])),
|
||||
@@ -458,11 +464,17 @@ func parseRealPrice(code string, v map[string]string) *models.StockPrice {
|
||||
func parseExpectedPrice(code string, v map[string]string) *models.StockPrice {
|
||||
normalized := strings.TrimPrefix(code, "A")
|
||||
normalized = strings.SplitN(normalized, "_", 2)[0]
|
||||
// 전일대비(v["11"])는 절댓값으로 파싱 후, 등락률(v["12"]) 부호에 맞춰 부호 결정
|
||||
expChangeAbs := absInt(parseWSInt(v["11"]))
|
||||
expChangeRate := parseWSFloat(v["12"])
|
||||
if expChangeRate < 0 {
|
||||
expChangeAbs = -expChangeAbs
|
||||
}
|
||||
return &models.StockPrice{
|
||||
Code: normalized,
|
||||
CurrentPrice: absInt(parseWSInt(v["10"])),
|
||||
ChangePrice: parseWSInt(v["11"]),
|
||||
ChangeRate: parseWSFloat(v["12"]),
|
||||
ChangePrice: expChangeAbs,
|
||||
ChangeRate: expChangeRate,
|
||||
TradeVolume: absInt(parseWSInt(v["15"])),
|
||||
Volume: absInt(parseWSInt(v["13"])),
|
||||
TradeTime: v["20"],
|
||||
|
||||
Reference in New Issue
Block a user