feature_to_weight

czsc.feature_to_weight(df, factor, positive, **kwargs)[source]

时序因子转换为持仓权重

处理流程:

  1. 缩尾处理:去除极端值

  2. scale 缩放,均值为0

  3. maxabs_scale 缩放至 [-1, 1]

Parameters:
  • df – pd.DataFrame, 包含因子列的数据

  • factor – str, 因子列名

  • positive – bool, 因子是否为正向因子

  • kwargs

    • window: int, 计算窗口长度,默认为1000

    • min_periods: int, 最小计算窗口长度,默认为100

    • q_threshold: float, 缩尾阈值,默认为0.05