adjust_holding_weights
- czsc.adjust_holding_weights(df, hold_periods=1, **kwargs)[source]
根据 hold_periods 调整截面数据的 weight 列,固定间隔调仓
使用场景:
截面选品种,固定持仓周期为 hold_periods,每隔 hold_periods 个周期调整一次仓位
- Parameters:
df –
pd.DataFrame, 截面数据, 至少包含 dt, symbol, weight, n1b 列
注意: df 中必须有原始交易中每个时刻的持仓数据,不要求时间等间隔拆分,但是 n1b 要能代表两个交易时刻之间的收益率
hold_periods – int, 固定持仓周期,大于等于1;1 表示每个交易周期调整一次仓位
- Returns:
pd.DataFrame