Skip to content

⚙️ [기능추가][AI] 국내주식 OHLCV 수집 파이프라인 추가 - #375

Merged
twq110 merged 1 commit into
mainfrom
20260711-#372-korea-stock-ohlcv-data-collector
Jul 23, 2026
Merged

⚙️ [기능추가][AI] 국내주식 OHLCV 수집 파이프라인 추가#375
twq110 merged 1 commit into
mainfrom
20260711-#372-korea-stock-ohlcv-data-collector

Conversation

@twq110

@twq110 twq110 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

변경 내용

  • FinanceDataReader를 기본 수집원으로 사용하고, pykrx를 선택 가능한 보조 수집원으로 구성했습니다.
  • KOSPI·KOSDAQ 종목 목록과 일봉 OHLCV를 공통 스키마로 정규화합니다.
  • CSV·Parquet 파일 저장과 PostgreSQL price_data 테이블 업서트를 지원합니다.
  • 종목별 오류를 격리해 전체 배치가 중단되지 않도록 하고 실패 목록을 별도 기록합니다.
  • JSON 설정, 실행용 CLI, 한글 사용 문서와 단위 검증 스크립트를 추가했습니다.
  • 수집 데이터와 실행 로그가 Git에 포함되지 않도록 제외 규칙을 추가했습니다.

변경 이유

국내 주식 데이터를 반복 가능하게 수집·저장하는 파이프라인이 없어, 이후 뉴스·공시 이벤트와 가격 반응을 연결하는 분석 작업을 진행하기 어려웠습니다. 이번 변경으로 데이터 수집 계층을 먼저 독립적으로 사용할 수 있게 했습니다.

Closes #372

영향 범위

  • AI/modules/data_collector 국내주식 수집 모듈
  • AI/requirements.txt의 FinanceDataReader 의존성
  • 로컬 수집 데이터·로그 제외 규칙
  • 기존 미국주식 수집 로직과 웹 애플리케이션 동작에는 변경이 없습니다.

검증 결과

  • FinanceDataReader 응답 표준화 테스트
  • pykrx 한글 컬럼 표준화 테스트
  • 종목별 실패 격리 및 실패 로그 테스트
  • PostgreSQL 업서트 테스트
  • 단위 테스트 4개 통과
  • Python 문법 컴파일 검사 통과
  • 삼성전자(005930) 2026-07-01~2026-07-10 표본 수집: 8개 거래일 성공
  • 최신 origin/main 리베이스 완료

참고 사항

  • pykrx는 선택 기능이며 기본 설치 대상은 FinanceDataReader입니다.
  • 실제 수집 CSV와 로그는 저장소에 포함하지 않습니다.

Summary by CodeRabbit

  • 새 기능

    • 국내 주식(KOSPI·KOSDAQ·KONEX) 일봉 OHLCV 데이터를 수집할 수 있습니다.
    • 수집 데이터를 CSV·Parquet 파일 또는 PostgreSQL에 저장할 수 있습니다.
    • 설정 파일과 명령줄 옵션으로 소스, 기간, 종목, 저장 방식 등을 지정할 수 있습니다.
    • 여러 종목을 일괄 처리하며 실패한 종목과 사유를 별도로 기록합니다.
  • 문서

    • 설치, 실행 방법, 데이터 처리 정책 및 저장 형식을 안내하는 문서를 추가했습니다.
  • 검증

    • 데이터 정규화, 일괄 수집 실패 처리, 데이터 저장 동작을 검증하는 테스트를 추가했습니다.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 01be2f50-a25c-43a3-8b36-923314118f7b

📥 Commits

Reviewing files that changed from the base of the PR and between d7ef852 and bcac5dd.

📒 Files selected for processing (9)
  • .gitignore
  • AI/modules/data_collector/README.md
  • AI/modules/data_collector/__init__.py
  • AI/modules/data_collector/components/__init__.py
  • AI/modules/data_collector/components/korea_stock_data.py
  • AI/modules/data_collector/config/korea_stocks.json
  • AI/modules/data_collector/scripts/collect_korea_stocks.py
  • AI/requirements.txt
  • AI/tests/verify_korea_stock_data.py

Walkthrough

국내 주식 일봉 OHLCV 수집기를 추가했습니다. 설정과 CLI로 수집 조건을 지정하고, 데이터를 표준화해 CSV·Parquet 또는 PostgreSQL에 저장하며, 실패 종목을 별도 로그로 기록합니다. 관련 의존성, 테스트, README와 저장 경로 무시 설정도 포함됩니다.

Changes

국내 주식 수집 파이프라인

Layer / File(s) Summary
수집 설정과 실행 기반
AI/modules/data_collector/components/korea_stock_data.py, AI/modules/data_collector/config/korea_stocks.json
수집 소스·시장·기간·저장 방식을 설정 dataclass와 JSON으로 정의하고 경로 및 날짜를 정규화합니다.
수집·정규화·저장 흐름
AI/modules/data_collector/components/korea_stock_data.py
FinanceDataReader 또는 pykrx에서 데이터를 조회하고 표준 OHLCV 컬럼으로 변환한 뒤 파일과 PostgreSQL에 저장합니다. 배치 실패와 빈 결과는 CSV 로그로 기록합니다.
CLI와 패키지 공개 경로
AI/modules/data_collector/scripts/collect_korea_stocks.py, AI/modules/data_collector/components/__init__.py, AI/modules/data_collector/__init__.py, AI/requirements.txt
CLI 옵션으로 설정을 덮어써 배치 수집을 실행하며 수집기 심볼과 FinanceDataReader 의존성을 추가합니다.
검증과 운영 문서
AI/tests/verify_korea_stock_data.py, AI/modules/data_collector/README.md, .gitignore
정규화·실패 격리·DB upsert 테스트와 설치·실행·처리 정책 문서를 추가하고 실행 생성 디렉터리를 무시합니다.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI as collect_korea_stocks.py
  participant Config as KoreaStockCollectorConfig
  participant Collector as KoreaStockDataCollector
  participant Source as FinanceDataReader_or_pykrx
  participant Storage as File_or_PostgreSQL
  CLI->>Config: 설정 파일 로드 및 CLI override 병합
  Config-->>CLI: 수집 설정 반환
  CLI->>Collector: 설정으로 수집기 생성
  Collector->>Source: 종목 목록 및 일봉 OHLCV 조회
  Source-->>Collector: 원천 데이터 반환
  Collector->>Collector: OHLCV 정규화 및 배치 처리
  Collector->>Storage: 파일 저장 또는 DB upsert
  Collector-->>CLI: success/empty/failed/rows 통계 반환
Loading

Suggested reviewers: discipline24

Poem

깡충 토끼 데이터밭,
OHLCV 씨앗을 심었네.
CSV와 DB에 차곡차곡,
실패 기록도 남겼네.
당근처럼 싱싱한 파이프라인,
오늘도 귀를 쫑긋! 🐇

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 20260711-#372-korea-stock-ohlcv-data-collector

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
AI/modules/data_collector/config/korea_stocks.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

AI/requirements.txt

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@twq110
twq110 marked this pull request as ready for review July 23, 2026 06:35
@twq110
twq110 requested a review from discipline24 as a code owner July 23, 2026 06:35
@twq110
twq110 merged commit f5d620a into main Jul 23, 2026
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

⚙️ [기능추가][AI] 국장 주가데이터 수집 파이프라인 추가

1 participant