tradai-data¶
Market data collection and storage for the TradAI platform.
Status: ✅ Production Ready | Tests: 67/67 passing | Coverage: 93%
Features¶
- SOLID Design: Repository pattern, dependency inversion, single responsibility
- DRY Value Objects: DateRange, SymbolList, Timeframe eliminate duplication
- Clean Architecture: 3-layer pattern (Core → Infrastructure)
- Type-Safe: 100% type hints with Pydantic validation
- Test-Driven: 93% test coverage with strict TDD methodology
- Zero Dead Code: Every line driven by tests
Architecture¶
Core Layer (Business Logic)¶
- entities.py - Immutable value objects (DateRange, SymbolList, Timeframe, OHLCVData)
- repositories.py - Abstract interfaces (DataRepository, DataAdapter)
- services.py - Business logic (DataQueryService, DataCollectionService)
- exceptions.py - Domain-specific exceptions
Infrastructure Layer (External Dependencies)¶
- repositories/ccxt_repository.py - Generic CCXT data source for any exchange
- adapters/arctic_adapter.py - ArcticDB storage adapter for S3
Installation¶
Usage¶
from tradai.common import ExchangeConfig, TradingMode
from tradai.data.core.services import DataQueryService
from tradai.data.infrastructure.repositories import CCXTRepository
from tradai.data.infrastructure.adapters.arctic_adapter import ArcticAdapter
# Setup with dependency injection
config = ExchangeConfig(name="binance", trading_mode=TradingMode.FUTURES)
repository = CCXTRepository(config)
adapter = ArcticAdapter(bucket_name="my-bucket", library="futures")
service = DataQueryService(repository=repository, adapter=adapter)
# Query data with value objects
data = service.query(
symbols=["BTC/USDT:USDT", "ETH/USDT:USDT"],
start_date="2024-01-01",
end_date="2024-01-31",
timeframe="1h"
)
Testing¶
# Run tests with coverage
uv run pytest
# Run only unit tests (exclude integration tests)
uv run pytest -m "not integration"
# Run with coverage report
uv run pytest --cov=tradai.data --cov-report=html
Documentation¶
- DESIGN.md - Complete architecture and design patterns
- pyproject.toml - Package configuration and dependencies