- domain:市场数据实体(Stock / 交易日历 / 日线 / 复权 / 财务含 announce_date)+ Repository 与 MarketDataProvider Protocol
- 数据源:TushareProvider(归一化、重试、鉴权错误归类)、SinaProvider(备用,明确前复权口径与能力边界)、FailoverProvider + SyncLog 审计(禁止静默切换)
- 持久化:SQLAlchemy 2.x Models + Repository 实现(按业务键幂等 upsert、as_of_date 防未来函数过滤)+ Alembic 迁移
- CLI:uv run python -m app.cli.sync {basic|calendar|daily|financial|verify},支持 --resume 断点续传
- 真实 Tushare 验证:stock 5556 / 交易日历 366 / daily+factor 242 / 财务 55;sync_log 审计完整
- 测试:38 passed(domain / provider / failover / repository / 未来函数 / 迁移),ruff clean
14 lines
422 B
Python
14 lines
422 B
Python
"""数据源异常类型。"""
|
|
|
|
|
|
class DataSourceError(Exception):
|
|
"""数据源通用失败(网络、限频、解析等)。"""
|
|
|
|
|
|
class DataSourceAuthenticationError(DataSourceError):
|
|
"""凭证无效 / 权限不足(如 Tushare token 无该接口权限)。"""
|
|
|
|
|
|
class DataSourceNotSupported(DataSourceError):
|
|
"""该数据源不提供此能力(如新浪无复权因子),用于 Failover 判定。"""
|