fix: correct TR_ID, path, and params for fetch_market_rankings (#155) #156
Reference in New Issue
Block a user
Delete Branch "feature/issue-155-fix-ranking-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
문제 (Issue #155)
fetch_market_rankings()에 KIS 공식 스펙과 다른 버그가 3개 있었습니다.실계정 전환 시 랭킹 API가 정상 동작하지 않을 수 있는 상태였습니다.
수정 내용
FID_COND_SCR_DIV_CODE"20001""20171"FID_TRGT_EXLS_CLS_CODE"000000"(6자리)"0000000000"(10자리)"FHPST01710100"(존재 안 함)"FHPST01700000"/quotations/volume-rank/ranking/fluctuation참고: KIS VTS(모의투자)에서 랭킹 API가 빈 결과를 반환하는 것은 KIS 정책 제한으로 코드와 무관합니다.
테스트 결과
Closes #155
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>