## 核心功能 - CrossMarketAligner: 跨市场数据对齐(解决 ffill 陷阱) - Pydantic Schema: 数据结构验证(OHLCVInputSchema, AlignedFactorSchema 等) - 验证装饰器: @validate_factor_after_align, @validate_returns_after_align ## 解决的问题 - 跨市场交易日历不同(美股/港股/A股) - ffill 收益率陷阱(休市日复制非零收益率) - NaN 传播问题 - 日期不一致问题 ## 测试验证 - 5/5 测试通过(因子对齐、收益率对齐、多标的对齐、信号验证、ffill陷阱) - 休市日收益率 = 0%(正确) - 无 NaN 传播 ## 架构设计 - shared/data/alignment.py - 对齐器实现 - shared/data/schemas.py - Pydantic Schema 定义 - tests/test_alignment.py - 完整测试套件
20 lines
400 B
Python
20 lines
400 B
Python
"""
|
|
通用数据处理
|
|
"""
|
|
|
|
from framework_v2.shared.data.alignment import CrossMarketAligner
|
|
from framework_v2.shared.data.schemas import (
|
|
OHLCVInputSchema,
|
|
AlignedFactorSchema,
|
|
AlignedReturnsSchema,
|
|
AlignmentValidationResult,
|
|
)
|
|
|
|
__all__ = [
|
|
'CrossMarketAligner',
|
|
'OHLCVInputSchema',
|
|
'AlignedFactorSchema',
|
|
'AlignedReturnsSchema',
|
|
'AlignmentValidationResult',
|
|
]
|