fix: indicators/prices API 가 limit=N 단독 호출 시 최신 N개 반환 #70

Merged
xhh merged 1 commit from issue-68-limit-recent-n into main 2026-04-26 21:19:08 +09:00
Owner

요약

/api/indicators/{symbol}, /api/prices/{symbol}, /api/prices/batch/{symbols}
limit=N 단독 호출 시 historical 시작점(1959년 등) 데이터를 반환하던 버그 수정.

변경 내용

  • 세 엔드포인트의 쿼리를 ORDER BY date DESC + LIMIT N 후 응답에서 시간순(ASC) 정렬로 변경
  • 응답 데이터 형식(시간순) 은 그대로 유지 — 클라이언트 호환
  • start_date / end_date 명시 호출도 동일 정책으로 구간 내 최신 N개 반환

발견 경위

claude-plugin macro-report 시범 전환 (#6) 의 첫 A/B 측정 (2026-04-26 liquidity)
중 발견. scanner 가 limit 만 믿고 호출했다 1959년 값이 보고서에 흘러들어갈
위험. 클라이언트 쪽에서는 모든 호출에 start_date 명시로 우회 중이었음.

테스트

  • 신규 tests/api/test_indicators_prices.py — 9 case
    • limit=N 단독 호출 시 최신 N개 검증 (indicators / prices single / prices batch / crypto)
    • start_date 명시 호출 회귀 방지
    • 응답이 항상 ASC 정렬인지 확인
    • 빈 데이터 404, 빈 symbols 400 검증
  • 전체 122 case + ruff 통과

이슈

Closes #68

## 요약 `/api/indicators/{symbol}`, `/api/prices/{symbol}`, `/api/prices/batch/{symbols}` 가 `limit=N` 단독 호출 시 historical 시작점(1959년 등) 데이터를 반환하던 버그 수정. ## 변경 내용 - 세 엔드포인트의 쿼리를 `ORDER BY date DESC + LIMIT N` 후 응답에서 시간순(ASC) 정렬로 변경 - 응답 데이터 형식(시간순) 은 그대로 유지 — 클라이언트 호환 - `start_date` / `end_date` 명시 호출도 동일 정책으로 구간 내 최신 N개 반환 ## 발견 경위 claude-plugin macro-report 시범 전환 (#6) 의 첫 A/B 측정 (2026-04-26 liquidity) 중 발견. scanner 가 `limit` 만 믿고 호출했다 1959년 값이 보고서에 흘러들어갈 위험. 클라이언트 쪽에서는 모든 호출에 `start_date` 명시로 우회 중이었음. ## 테스트 - 신규 `tests/api/test_indicators_prices.py` — 9 case - `limit=N` 단독 호출 시 최신 N개 검증 (indicators / prices single / prices batch / crypto) - `start_date` 명시 호출 회귀 방지 - 응답이 항상 ASC 정렬인지 확인 - 빈 데이터 404, 빈 symbols 400 검증 - 전체 122 case + ruff 통과 ## 이슈 Closes #68
fix: indicators/prices API 가 limit=N 단독 호출 시 최신 N개 반환 (#68)
All checks were successful
Tests (PR) / pytest (pull_request) Successful in 31s
000a6378fe
기존: ORDER BY date ASC + LIMIT N → 1959년 등 historical 시작점 반환.
변경: ORDER BY date DESC + LIMIT N 후 응답에서 시간순(ASC) 정렬.

영향 범위:
- /api/indicators/{symbol}
- /api/prices/{symbol}
- /api/prices/batch/{symbols}

start_date / end_date 명시 호출은 기존과 동일하게 구간 내 시간순 반환
(테스트로 회귀 방지). 응답 형식도 ASC 유지.

claude-plugin macro-report 시범 전환 (#6) 의 첫 A/B 측정 중 발견된
잠복 버그. scanner 가 limit 만 믿고 호출하면 1959년 값이 보고서에
흘러들어갈 위험이 있었음.

Closes #68
xhh merged commit 4248bb9fd5 into main 2026-04-26 21:19:08 +09:00
xhh deleted branch issue-68-limit-recent-n 2026-04-26 21:19:08 +09:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
xhh/financial-data-platform!70
No description provided.