feat(rotation): componentize position weighting + fix bond threshold consistency

- Extract compute_position_weights() as pluggable pure function
- Add WeightType enum (equal/rank) and RotationConfig.weight field
- Fix bond threshold dimension mismatch: use configured factor function
  for all assets instead of hardcoded weighted_momentum_score
- Default weight: equal in config, active: rank in config_simple.yaml
This commit is contained in:
2026-06-06 22:28:08 +08:00
parent 44588d5026
commit 4973a9a2a5
3 changed files with 103 additions and 26 deletions

View File

@@ -49,6 +49,12 @@ class ThresholdMode(str, Enum):
DYNAMIC = "dynamic" # 动态阈值
class WeightType(str, Enum):
"""仓位加权模式"""
EQUAL = "equal" # 等权
RANK = "rank" # 按排名加权 (slot i gets (N-i)/triangular(N))
class DataSourceType(str, Enum):
"""数据源类型"""
FLASK_API = "flask_api"
@@ -169,6 +175,7 @@ class RotationConfig(BaseModel):
select_num: int = Field(default=3, ge=1, le=10)
diversified: bool = Field(default=True)
threshold: ThresholdConfig = Field(default_factory=ThresholdConfig)
weight: WeightType = Field(default=WeightType.EQUAL)
class RebalanceConfig(BaseModel):