fix: correct TR_ID, path, and params for fetch_market_rankings (#155) #156

Merged
jihoson merged 1 commits from feature/issue-155-fix-ranking-api into main 2026-02-19 11:00:51 +09:00
Collaborator

문제 (Issue #155)

fetch_market_rankings()에 KIS 공식 스펙과 다른 버그가 3개 있었습니다.
실계정 전환 시 랭킹 API가 정상 동작하지 않을 수 있는 상태였습니다.

수정 내용

항목 기존 (잘못됨) 수정 후 (공식 스펙)
FID_COND_SCR_DIV_CODE "20001" "20171"
FID_TRGT_EXLS_CLS_CODE "000000" (6자리) "0000000000" (10자리)
fluctuation TR_ID "FHPST01710100" (존재 안 함) "FHPST01700000"
fluctuation 경로 /quotations/volume-rank /ranking/fluctuation
fluctuation 파라미터 volume-rank 파라미터 재사용 소문자 키 + fluctuation 전용 파라미터 14개

참고: KIS VTS(모의투자)에서 랭킹 API가 빈 결과를 반환하는 것은 KIS 정책 제한으로 코드와 무관합니다.

테스트 결과

621 passed (coverage: 76%)
TestFetchMarketRankings: 3 tests ✓

Closes #155

## 문제 (Issue #155) `fetch_market_rankings()`에 KIS 공식 스펙과 다른 버그가 3개 있었습니다. 실계정 전환 시 랭킹 API가 정상 동작하지 않을 수 있는 상태였습니다. ## 수정 내용 | 항목 | 기존 (잘못됨) | 수정 후 (공식 스펙) | |---|---|---| | `FID_COND_SCR_DIV_CODE` | `"20001"` | `"20171"` | | `FID_TRGT_EXLS_CLS_CODE` | `"000000"` (6자리) | `"0000000000"` (10자리) | | fluctuation TR_ID | `"FHPST01710100"` (존재 안 함) | `"FHPST01700000"` | | fluctuation 경로 | `/quotations/volume-rank` | `/ranking/fluctuation` | | fluctuation 파라미터 | volume-rank 파라미터 재사용 | 소문자 키 + fluctuation 전용 파라미터 14개 | 참고: KIS VTS(모의투자)에서 랭킹 API가 빈 결과를 반환하는 것은 **KIS 정책 제한**으로 코드와 무관합니다. ## 테스트 결과 ``` 621 passed (coverage: 76%) TestFetchMarketRankings: 3 tests ✓ ``` Closes #155
agentson added 1 commit 2026-02-19 10:25:50 +09:00
fix: correct TR_ID, path, and params for fetch_market_rankings (#155)
Some checks failed
CI / test (pull_request) Has been cancelled
2e550f8b58
Three bugs found by comparing against KIS official GitHub examples:

1. FID_COND_SCR_DIV_CODE: "20001" → "20171" (volume-rank screen code)
2. FID_TRGT_EXLS_CLS_CODE: "000000" (6-digit) → "0000000000" (10-digit)
3. fluctuation ranking:
   - TR_ID: "FHPST01710100" (invalid) → "FHPST01700000"
   - path: /quotations/volume-rank → /ranking/fluctuation
   - params: volume-rank params → lowercase fluctuation-specific params
     (fid_rank_sort_cls_code, fid_input_cnt_1, fid_prc_cls_code,
      fid_rsfl_rate1, fid_rsfl_rate2, etc.)

Note: VTS (paper trading) does not return data from ranking APIs regardless
of parameter correctness — this is a KIS policy restriction, not a code bug.
These fixes ensure correct behavior when switching to a live account.

Tests: TestFetchMarketRankings (3 tests) added to test_broker.py

Closes #155

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jihoson merged commit e0d6c9f81d into main 2026-02-19 11:00:51 +09:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#156