# data - 데이터 관리 ## 개요 **data** 컴포넌트는 시계열 데이터 수집, 정제, 저장, 제공을 담당합니다. ### 책임 - 외부 데이터 소스 연동 및 수집 스케줄링 - 실시간 시세 스트리밍 및 캐시 업데이트 - 데이터 품질 검증/보정 - 백테스트 및 전략 실행을 위한 데이터 제공 ### 의존성 ```mermaid graph LR Data[data] --> Providers[Data Providers] Data --> DB[(Time-series DB)] Data --> Cache[(Redis Cache)] Strategy[strategy] --> Data Analytics[analytics] --> Data Monitor[monitor] --> Data style Data fill:#9C27B0,color:#fff ``` ## 주요 기능 ### 1. 데이터 수집 ```typescript collectMarketData(symbols: string[], from: Date, to: Date): void updateRealTimeData(symbols: string[]): void ``` - 외부 제공자(Yahoo Finance, Alpha Vantage 등)에서 시세를 수집합니다. - 증분 업데이트로 중복 수집을 방지합니다. ### 2. 데이터 제공 ```typescript getPriceHistory(symbol: string, from: Date, to: Date, interval: Interval): PriceBar[] getLatestPrice(symbol: string): Price getMultipleSymbols(symbols: string[], date: Date): Record ``` - 실시간 데이터는 캐시 우선으로 제공합니다. ### 3. 데이터 품질 관리 ```typescript validateData(symbol: string, from: Date, to: Date): ValidationReport adjustForCorporateActions(symbol: string): void fillMissingData(symbol: string, method: 'FORWARD_FILL' | 'INTERPOLATE'): void ``` - 결측치/이상치 탐지 및 보정 정책을 적용합니다. ### 4. 데이터 소스 관리 ```typescript addDataSource(source: DataSourceConfig): DataSource syncDataSource(sourceId: string): SyncResult ``` ## 데이터 모델 ```typescript interface PriceBar { symbol: string timestamp: Date open: number high: number low: number close: number volume: number adjustedClose?: number } interface DataSource { id: string name: string provider: 'BROKER' | 'YAHOO' | 'ALPHA_VANTAGE' | 'CUSTOM' config: { apiKey?: string endpoint?: string rateLimit?: number } coverage: { symbols: string[] intervals: string[] delay: number } priority: number isActive: boolean } interface ValidationReport { symbol: string period: { from: Date, to: Date } issues: { type: 'MISSING_DATA' | 'OUTLIER' | 'ZERO_VOLUME' | 'PRICE_GAP' date: Date description: string severity: 'LOW' | 'MEDIUM' | 'HIGH' }[] completeness: number quality: 'EXCELLENT' | 'GOOD' | 'FAIR' | 'POOR' } ``` ## API 명세 ### GET /api/data/prices 가격 데이터 조회 ### POST /api/data/sources 데이터 소스 추가 ## 구현 고려사항 - 데이터 소스별 레이트 리밋을 준수합니다. - 기업 이벤트(배당, 액면분할) 반영 규칙을 문서화합니다. ## 관련 문서 - [공통 데이터 모델](../../docs/03-data-models.md) - [주요 워크플로우](../../docs/04-workflows.md) ### 관련 컴포넌트 - [strategy - 전략 관리](./strategy.md) - [analytics - 성과 분석](../phase2/analytics.md) - [monitor - 모니터링](../phase2/monitor.md)