# 算子构建因子示例 — 用算子树组合 qlib 表达式,无需手写字符串 # # 用法: # python scripts/run_factor.py build --name price_vol_divergence # python scripts/run_factor.py register-built --all built_factors: price_vol_divergence: description: "价量排名差(价量背离代理)" tags: [operator, custom] enabled: true tree: op: sub args: - op: rank args: [{field: "$close"}, {const: 20}] - op: rank args: [{field: "$volume"}, {const: 20}] norm_momentum_10: description: "10日归一化动量" tags: [operator, momentum] enabled: true tree: op: div args: - op: sub args: - {field: "$close"} - op: ref args: [{field: "$close"}, {const: 10}] - op: std args: [{field: "$close"}, {const: 10}] vol_shock: description: "成交量冲击(当日量/20日均量)" tags: [operator, volume] enabled: true tree: op: div args: - {field: "$volume"} - op: mean args: [{field: "$volume"}, {const: 20}] high_low_spread: description: "振幅相对昨收" tags: [operator, volatility] enabled: true tree: op: div args: - op: sub args: [{field: "$high"}, {field: "$low"}] - op: ref args: [{field: "$close"}, {const: 1}] # 可用算子(供参考 / 前端可视化) operator_catalog: fields: ["$open", "$close", "$high", "$low", "$volume", "$vwap"] unary: [abs, log, rank, neg] binary: [add, sub, mul, div, max, min] rolling: [mean, std, sum, max, min, ref, delta, rank] constants: "window sizes e.g. 3,5,10,20,60"