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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user