File size: 1,741 Bytes
590a501 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | # 算子构建因子示例 — 用算子树组合 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"
|