fix: get_time_series 카테고리별 endpoint 분기 (indicators 404 스팸 제거) #75
No reviewers
Labels
No labels
api
bug
chore
collector
decision-needed
docs
enhancement
feature
feedback-loop
frontend
infra
skill
test
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
xhh/financial-data-platform!75
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/streamlit-indicators-routing"
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?
문제
운영 API 로그에
/api/indicators/{symbol}404 가 매 페이지 로드마다 누적되고 있었음. 예:원인
/api/indicators/{symbol}라우터는EconomicIndicator테이블만 조회하는 FRED 전용 엔드포인트. 호출자frontend/streamlit/utils/data_loader.get_time_series는 심볼 카테고리를 모르니까 "indicators 먼저 try → 404 면 prices fallback" 패턴이라, prices 심볼마다 404 가 한 줄씩 찍힘. 동작은 정상이지만 로그 스팸 + 매 호출 round-trip 1회 낭비.변경
_fred_symbol_set()헬퍼 추가:/api/meta/symbols응답에서category=="fred"인 심볼 set 추출,@st.cache_data(ttl=600).get_time_series가 symbol 이 FRED set 에 있으면/api/indicators/만, 아니면/api/prices/만 호출 (미정의 심볼도 prices 폴백 그대로).검증 (NAS 로컬, 리빌드된 컨테이너 내부 in-process 호출)
/api/indicators/M2SL/api/prices/SPY/api/prices/%5EVIX호출 시점 60초간 API 로그에 indicators 404 0건.
영향 범위
응답 데이터 동일, FRED 심볼 분기시 prices 폴백 경로가 사라지므로 캐시된 FRED set 이 누락되면 fred 심볼 조회가 빈 DF 반환 (이 상황은
/api/meta/symbols자체가 실패해야 하고 그 경우 어차피 다른 동작도 어려움).기존엔 모든 심볼에 대해 /api/indicators/{symbol} 먼저 시도하고 404 시 /api/prices/{symbol} 로 폴백하는 패턴이라, prices 심볼(SPY, IWM, ^VIX, ^W5000 등) 호출마다 API 측에 404 액세스 로그가 한 줄씩 찍혔다. `/api/meta/symbols` 응답에서 category=="fred" 인 심볼 set 을 10분 캐시 (`st.cache_data`) 후, 그 set 에 속하는 심볼만 indicators 로, 나머지는 prices 로 직접 호출한다. 의도되지 않은 404 가 사라지고 round-trip 도 절감. 검증: - 컨테이너 리빌드 후 in-process 호출: - M2SL → /api/indicators/M2SL 200 (27 rows) - SPY → /api/prices/SPY 200 (7 rows), indicators 호출 없음 - ^VIX → /api/prices/%5EVIX 200 (7 rows), indicators 호출 없음 - 60초 API 로그에 indicators 404 발생 0건.