Data Sources Overview

πŸ“‹ Implementation Status: βœ… Core Features Implemented (v1.0.0)

This document provides a high-level overview of the multi-source data integration architecture for the trading system.


Overview

The trading system supports multiple market data sources to provide:

  • Redundancy: Backup sources if one fails
  • Data Validation: Cross-validate data between sources
  • Rich Data: Different sources provide different data types
  • Cost Optimization: Use free sources where possible
  • Flexibility: Choose best source for each use case

Supported Data Sources

Source OHLCV Fundamentals Dividends Splits Real-time Cost
Polygon.io βœ… ❌ βœ… βœ… βœ… Paid (Free tier: 5 calls/min)
Yahoo Finance βœ… βœ… βœ… βœ… ⚠️ Delayed Free (Unlimited)
Alpaca βœ… ❌ ❌ ❌ βœ… Free with account

For detailed integration guides, see: - Polygon.io Integration - Yahoo Finance Integration - Data Source Comparison


Multi-Source Architecture

Design Principles

  1. Independent Services: Each data source has its own service module
  2. Unified Storage: All market data stored in data_ingestion.market_data with data_source field (e.g. yahoo, yahoo_adjusted, polygon, alpaca)
  3. Source Tracking: Track which provider supplied each data point; Yahoo stores both unadjusted (yahoo) and adjusted (yahoo_adjusted) OHLCV
  4. Separate Loaders: Each source has dedicated loader class
  5. Consistent Interface: Similar API patterns across sources

Directory Structure

src/services/
β”œβ”€β”€ polygon/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ client.py           # PolygonClient
β”‚   β”œβ”€β”€ exceptions.py       # Polygon-specific exceptions
β”‚   └── models.py           # Pydantic models
β”‚
β”œβ”€β”€ yahoo/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ client.py           # YahooClient
β”‚   β”œβ”€β”€ exceptions.py       # Yahoo-specific exceptions
β”‚   β”œβ”€β”€ models.py           # Pydantic models
β”‚   └── loader.py           # YahooDataLoader
β”‚
β”œβ”€β”€ alpaca/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ client.py           # AlpacaClient
β”‚   └── exceptions.py
β”‚
└── data_ingestion/
    β”œβ”€β”€ __init__.py
    β”œβ”€β”€ historical_loader.py  # HistoricalDataLoader (Polygon)
    └── symbols.py

Data Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Polygon.io │────▢│ PolygonClient│────▢│ HistoricalDataLoaderβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                    β”‚
                                                    β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚Yahoo Finance│────▢│ YahooClient  │────▢│ YahooDataLoader   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                    β”‚
                                                    β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”‚
β”‚   Alpaca    │────▢│ AlpacaClient β”‚               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
                                                    β”‚
                                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                         β”‚   PostgreSQL DB     β”‚
                                         β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
                                         β”‚  β”‚ market_data  β”‚   β”‚
                                         β”‚  β”‚ fundamentals β”‚   β”‚
                                         β”‚  β”‚ dividends    β”‚   β”‚
                                         β”‚  β”‚ splits       β”‚   β”‚
                                         β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
                                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜


Last Updated: December 2025
Status: βœ… Core Features Implemented (v1.0.0)