docs(AGENTS): 新增AI行为准则规范
- 添加代码存放位置规则,强制代码存放于 src/ 或 tests/ 目录 - 添加 Tests 目录代码运行规则,强制使用 pytest 运行测试代码 - 更新 learn_to_rank 实验代码:调整因子列表和处理器配置 - 修复 schema_cache 表结构缓存逻辑
This commit is contained in:
@@ -110,6 +110,9 @@ class SchemaCache:
|
||||
# 字段到表的映射(一个字段可能在多个表中存在)
|
||||
field_to_tables: Dict[str, List[str]] = {}
|
||||
for table, fields in table_fields.items():
|
||||
# 跳过不支持 PIT 的财务表(如 fina_indicator)
|
||||
if table.lower() in self._NON_PIT_FINANCIAL_TABLES:
|
||||
continue
|
||||
for field in fields:
|
||||
if field not in field_to_tables:
|
||||
field_to_tables[field] = []
|
||||
@@ -124,17 +127,30 @@ class SchemaCache:
|
||||
sorted_tables = sorted(tables, key=lambda t: priority_order.get(t, 999))
|
||||
self._field_to_table_map[field] = sorted_tables[0]
|
||||
|
||||
# 不支持 PIT(Point-In-Time)策略的财务表列表
|
||||
# 这些表缺少 f_ann_date 列,无法使用 asof_backward 模式
|
||||
_NON_PIT_FINANCIAL_TABLES = {"financial_fina_indicator"}
|
||||
|
||||
def is_financial_table(self, table_name: str) -> bool:
|
||||
"""判断是否为财务数据表。
|
||||
|
||||
注意:只有支持 PIT 策略(有 f_ann_date 列)的财务表才会返回 True。
|
||||
fina_indicator 表由于只有 ann_date 而没有 f_ann_date,被排除在外。
|
||||
|
||||
Args:
|
||||
table_name: 表名
|
||||
|
||||
Returns:
|
||||
是否为财务数据表
|
||||
是否为支持 PIT 的财务数据表
|
||||
"""
|
||||
financial_prefixes = ("financial_", "income", "balance", "cashflow")
|
||||
return table_name.lower().startswith(financial_prefixes)
|
||||
is_financial = table_name.lower().startswith(financial_prefixes)
|
||||
|
||||
# 排除不支持 PIT 的表
|
||||
if is_financial and table_name.lower() in self._NON_PIT_FINANCIAL_TABLES:
|
||||
return False
|
||||
|
||||
return is_financial
|
||||
|
||||
def get_table_fields(self, table_name: str) -> List[str]:
|
||||
"""获取指定表的字段列表。
|
||||
|
||||
Reference in New Issue
Block a user