refactor(factor): 完全重构因子计算框架 - 引入DSL表达式系统

- 删除旧因子框架:移除 base.py、composite.py、data_loader.py、data_spec.py
  及所有子模块(momentum、financial、quality、sentiment等)
- 新增DSL表达式系统:实现 factor DSL 编译器和翻译器
  - dsl.py: 领域特定语言定义
  - compiler.py: AST编译与优化
  - translator.py: Polars表达式翻译
  - api.py: 统一API接口
- 新增数据路由层:data_router.py 实现字段到表的动态路由
- 新增API封装:api_pro_bar.py 提供pro_bar数据接口
- 更新执行引擎:engine.py 适配新的DSL架构
- 重构测试体系:删除旧测试,新增 test_dsl_promotion.py、
  test_factor_integration.py、test_pro_bar.py
- 清理文档:删除8个过时文档(factor_design、db_sync_guide等)
This commit is contained in:
2026-02-27 22:22:23 +08:00
parent c3c20ed7ea
commit a56433e440
51 changed files with 667 additions and 11287 deletions

View File

@@ -8,7 +8,7 @@ import pandas as pd
from typing import Optional, Literal
from pathlib import Path
from src.data.client import TushareClient
from src.data.config import get_config
from src.config.settings import get_settings
# Module-level flag to track if cache has been synced in this session
_cache_synced = False
@@ -18,7 +18,7 @@ _cache_synced = False
# Trading calendar cache file path
def _get_cache_path() -> Path:
"""Get the cache file path for trade calendar."""
cfg = get_config()
cfg = get_settings()
return cfg.data_path_resolved / "trade_cal.h5"
@@ -296,8 +296,8 @@ def get_first_trading_day(
trading_days = get_trading_days(start_date, end_date, exchange)
if not trading_days:
return None
# Trading days are sorted in descending order (newest first) from cache
return trading_days[-1]
# Return the earliest trading day
return min(trading_days)
def get_last_trading_day(
@@ -318,8 +318,8 @@ def get_last_trading_day(
trading_days = get_trading_days(start_date, end_date, exchange)
if not trading_days:
return None
# Trading days are sorted in descending order (newest first) from cache
return trading_days[0]
# Return the latest trading day
return max(trading_days)
if __name__ == "__main__":