You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
I Luk Kim 8c9abe3e31 feat(attention): Attention 서브시스템 추가 — 이벤트 중심 Wikipedia/GDELT 관심도 피처
## 주요 기능
- Entity resolver: ticker → canonical name → Wikipedia 매칭
  - SEC company_tickers.json fallback으로 placeholder name 자동 수정
  - all-caps SEC 이름 title-case 변환, "Com" suffix 처리
- Wikipedia 페이지뷰 수집 + spike_10d / zscore_20d 피처 계산
- GDELT V2 DOC API 뉴스 기사 수집 (2017-01-01 이후)

## GDELT rate limit 제약 강제
- /event/{ticker} 온디맨드 GDELT 수집 제거 (IP ban 방지)
- 프로세스 전역 asyncio.Lock + 10초 최소 간격 강제
- 429 시 exponential backoff (30→60→120s)
- news.gdelt_status 필드로 클라이언트에 수집 상태 명시
  ('collected' | 'not_collected' | 'not_available')

## API
- GET  /api/v1/attention/event/{ticker}?event_date=YYYY-MM-DD
- GET  /api/v1/attention/entity/{ticker}
- POST /api/v1/attention/admin/resolve/{ticker}
- POST /api/v1/attention/admin/collect/wiki/{ticker}
- POST /api/v1/attention/admin/collect/gdelt/{ticker}  ← scheduler 전용

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5 months ago
..
README.md Initial commit with full project improvements 5 months ago
TEST_SUMMARY.md Initial commit with full project improvements 5 months ago
__init__.py Initial commit with full project improvements 5 months ago
conftest.py Initial commit with full project improvements 5 months ago
run_all_tests.py Initial commit with full project improvements 5 months ago
test_5year_comparison.py Initial commit with full project improvements 5 months ago
test_15year_financial_data.py Initial commit with full project improvements 5 months ago
test_attention.py feat(attention): Attention 서브시스템 추가 — 이벤트 중심 Wikipedia/GDELT 관심도 피처 5 months ago
test_catalog.py Initial commit with full project improvements 5 months ago
test_final_verification.py Initial commit with full project improvements 5 months ago
test_financial.py Initial commit with full project improvements 5 months ago
test_health.py Initial commit with full project improvements 5 months ago
test_integration.py Initial commit with full project improvements 5 months ago
test_migration.py Initial commit with full project improvements 5 months ago
test_mock_data.py Initial commit with full project improvements 5 months ago
test_ohlcv.py Initial commit with full project improvements 5 months ago
test_overlay.py Add Phase 5 Attention Overlay API and fix Redis port mismatch 5 months ago
test_quick.py Initial commit with full project improvements 5 months ago
test_real_sec_vs_yfinance_plus.py Initial commit with full project improvements 5 months ago
test_sec_edgar_15year.py Initial commit with full project improvements 5 months ago
test_sec_filings_fixes.py fix(sec): 대형 exhibit 파일로 인한 서버 메모리 고갈 방지 5 months ago
test_simple.py Initial commit with full project improvements 5 months ago
test_simple_real_data.py Initial commit with full project improvements 5 months ago
test_yfinance_comparison.py Initial commit with full project improvements 5 months ago
test_yfinance_fallback.py Initial commit with full project improvements 5 months ago

README.md

Stock Oracle 테스트 스위트

이 폴더에는 Stock Oracle 시스템의 다양한 기능을 테스트하는 스크립트들이 포함되어 있습니다.

📁 테스트 파일 목록

1. test_yfinance_fallback.py

목적: YFinance Plus 연결 테스트

  • yfinance_plus 모듈이 정상적으로 작동하는지 확인
  • 기본적인 주식 데이터 가져오기 테스트
  • API 수동 호출 테스트

실행 방법:

python tests/test_yfinance_fallback.py

2. test_simple_real_data.py

목적: 실제 SEC 데이터 기본 테스트

  • Stock Oracle API에서 실제 SEC 재무 데이터를 정상적으로 가져오는지 확인
  • 데이터 품질 검증 (실제 데이터 vs 추정 데이터)
  • YFinance Plus와의 기본 비교

실행 방법:

python tests/test_simple_real_data.py

3. test_real_sec_vs_yfinance_plus.py

목적: Stock Oracle vs YFinance Plus 상세 비교

  • 두 시스템에서 가져온 재무 데이터의 정확도 비교
  • 주요 재무 지표들의 차이점 분석
  • 여러 종목(AAPL, MSFT)에 대한 비교 테스트

실행 방법:

python tests/test_real_sec_vs_yfinance_plus.py

4. test_5year_comparison.py

목적: 5년 분기별 정확도 테스트

  • 동일한 분기 데이터의 정확도를 5년간 비교 검증
  • 분기별 매칭된 데이터만 비교하여 정확도 측정
  • 시계열 데이터의 일관성 검증

실행 방법:

python tests/test_5year_comparison.py

5. run_all_tests.py (통합 테스트 스위트)

목적: 모든 테스트를 한번에 실행

  • 위의 모든 테스트를 순차적으로 실행
  • 각 테스트의 성공/실패 결과 요약
  • 실행 시간 측정 및 리포트 생성

실행 방법:

python tests/run_all_tests.py

🚀 빠른 시작

전체 테스트 실행

# 모든 테스트를 한번에 실행
python tests/run_all_tests.py

개별 테스트 실행

# 기본적인 연결 테스트만
python tests/test_yfinance_fallback.py

# 실제 데이터 테스트만
python tests/test_simple_real_data.py

# 정확도 비교 테스트만
python tests/test_real_sec_vs_yfinance_plus.py

# 5년 정확도 검증만
python tests/test_5year_comparison.py

📋 사전 요구사항

테스트 실행 전에 다음 조건들이 만족되어야 합니다:

1. Docker 서비스 실행

docker-compose up -d

2. 필수 Python 패키지

  • requests
  • yfinance_plus
  • pandas
  • json

3. API 서버 확인

Stock Oracle API가 http://localhost:18001에서 실행 중이어야 합니다.

# 서버 상태 확인
curl http://localhost:18001/health

📊 예상 결과

성공적인 테스트 결과

  • YFinance Plus 연결: 정상 연결 및 데이터 가져오기
  • 실제 SEC 데이터: 실제 데이터 (is_estimated: false) 반환
  • 데이터 비교: 합리적인 차이 범위 내 (동일 분기 대비)
  • 5년 정확도: 동일 분기 데이터 100% 일치

문제 해결

API 서버 연결 실패

# Docker 컨테이너 상태 확인
docker-compose ps

# 서비스 재시작
docker-compose restart

yfinance_plus 모듈 오류

# 모듈 재설치
pip install yfinance_plus

# Docker 내부에서 재설치
docker-compose exec api pip install yfinance_plus

데이터베이스 연결 오류

# PostgreSQL 컨테이너 재시작
docker-compose restart postgres

# 로그 확인
docker-compose logs postgres

🎯 테스트 목표

이 테스트 스위트의 목표는 다음과 같습니다:

  1. 기능 검증: 모든 핵심 기능이 정상 작동하는지 확인
  2. 데이터 정확성: 실제 SEC 데이터가 정확하게 가져와지는지 검증
  3. 일관성 확인: 시스템 간 데이터 일관성 보장
  4. 성능 측정: 각 테스트의 실행 시간 측정
  5. 회귀 방지: 향후 코드 변경 시 기존 기능 보호

📝 테스트 결과 해석

성공 지표

  • 모든 API 호출이 200 상태 코드 반환
  • 실제 재무 데이터 (is_estimated: false) 반환
  • 동일 분기 데이터의 정확한 일치
  • 합리적인 실행 시간 (각 테스트 < 5분)

주의사항

  • 서로 다른 분기 데이터 비교 시 차이는 정상
  • 네트워크 상태에 따라 실행 시간 변동 가능
  • 일부 종목의 경우 특정 분기 데이터가 없을 수 있음

🔄 정기 테스트 권장

  • 개발 후: 코드 변경 후 전체 테스트 실행
  • 배포 전: 프로덕션 배포 전 필수 검증
  • 주기적: 주 1회 데이터 정확성 검증
  • 문제 발생 시: 즉시 해당 영역 테스트 실행