任务指令 你是一个WorldQuant WebSim因子工程师。你的任务是生成100个用于行业轮动策略的复合型Alpha因子表达式。 核心规则 设计维度框架 维度1:时间序列动量(TM) 核心概念:捕捉行业价格的趋势、动量和形态变化 关键函数: ts_delta, ts_mean, ts_regression(获取斜率rettype参数) ts_decay_linear, ts_zscore, ts_rank ts_scale, ts_av_diff, ts_std_dev ts_corr, ts_covariance(用于行业内序列) 设计思路: 动量的变化率、加速度或平滑度构建 动量衰减或增强模式识别 价格与成交量关系的时序分析 维度2:横截面领导力(CL) 核心概念:识别行业内部的分化、龙头效应和相对强度 关键函数: group_mean, group_std, group_rank group_zscore, group_neutralize, group_scale rank, zscore, quantile(横截面) bucket(用于龙头股筛选) 设计思路: 行业内部龙头股与平均表现的差异 行业成分股的离散度分析 相对排名的变化和稳定性 维度3:市场状态适应性(MS) 核心概念:根据市场环境动态调整因子逻辑 关键函数: ts_rank, if_else, 条件判断运算符 ts_std_dev(用于波动率调整) ts_regression(不同状态使用不同参数) trade_when(条件触发) 设计思路: 波动率调整的动量指标 不同市场状态(高/低波动)使用不同的回顾期 条件逻辑下的参数动态调整 维度4:行业间联动(IS) 核心概念:捕捉行业间的动量溢出和相关性变化 关键函数: ts_corr, ts_covariance(跨行业) group_mean(用于行业指数) 向量操作:vec_avg, vec_sum 多序列相关性分析 设计思路: 领先-滞后行业的相关性分析 行业间动量传导效应 板块轮动的早期信号识别 维度5:交易行为情绪(TS) 核心概念:基于交易行为和情绪指标的反转信号 关键函数: ts_corr(volume, close, d)(量价关系) ts_rank(历史相对位置) ts_zscore(极端值识别) days_from_last_change(事件驱动) 设计思路: 超买超卖状态识别 交易拥挤度指标 情绪极端值后的均值回归 复合因子设计原则 强制要求: 每个表达式必须融合至少两个设计维度 必须使用提供的操作符列表中的函数 因子应具有经济逻辑解释性 推荐组合模式: TM + CL:时序动量 + 横截面领导力 示例:行业动量加速度 × 龙头股相对强度 TM + MS:时序动量 + 状态适应性 示例:波动率调整后的动量指标 CL + IS:横截面 + 行业间联动 示例:龙头股表现与相关行业的领先滞后关系 MS + TS:状态适应 + 交易情绪 示例:不同市场状态下的反转信号 IS + TS:行业联动 + 交易情绪 示例:行业间相关性变化与交易拥挤度 参数化建议: 使用不同的时间窗口组合(短/中/长周期) 尝试不同的权重分配方式 考虑非线性变换(log, power, sqrt) 使用条件逻辑增强鲁棒性 表达式构建指南 基本结构: text 复合因子 = 维度A组件 [运算符] 维度B组件 [条件调整] 运算符使用策略: 算术运算:add, subtract, multiply, divide 非线性变换:log, power, sqrt, signed_power 条件逻辑:if_else, and, or, 比较运算符 标准化处理:normalize, winsorize, scale 防止过拟合建议: 避免过度复杂的嵌套 使用经济直觉验证逻辑合理性 考虑实际交易可行性 包含风险控制元素(如波动率调整) *=====* 操作符限制:只能且必须使用以下列表中提供的操作符。严禁使用任何列表外的函数(例如 ts_regression_slope 不存在,必须用 ts_regression(y, x, d, 0, 1) 来获取斜率)。 abs, add, divide, multiply, subtract, log, power, sqrt, max, min, sign, reverse ts_mean, ts_sum, ts_std_dev, ts_delta, ts_delay, ts_zscore, ts_rank, ts_decay_linear, ts_corr, ts_covariance, ts_av_diff, ts_scale, ts_regression, ts_backfill group_mean, group_std, group_rank, group_zscore, group_neutralize, group_scale rank, scale, normalize, quantile, zscore, winsorize bucket, if_else, and, or, not, >, <, == days_from_last_change, kth_element 数据字段:假设主要数据字段为 close, high, low, volume, vwap。可安全使用。 参数逻辑:参数d(回顾期)应在[5, 10, 20, 30, 60, 120]等具有市场意义(周、月、季度、半年)的数值中合理选择并差异化。 行业隐含:通过group_mean、group_rank等函数或假设表达式在行业指数上运行来体现“行业”逻辑。 输出格式: 输出必须是且仅是 100行纯文本。 每一行是一个完整、独立、语法正确的WebSim表达式。 严禁任何形式的解释、编号、标点包裹(如引号)、Markdown格式或额外文本。 示例思维(仅供理解,不输出) 一个融合“龙头股趋势加速度(M)”与“行业整体情绪背离(R)”的因子思路,可用你的操作符实现为: multiply( ts_delta(group_mean(ts_regression(close, ts_step(1), 20, 0, 1), bucket(rank(close), "0.7,1")), 5), reverse(ts_corr(ts_zscore(volume, 20), ts_zscore(close, 20), 10)) ) 这里,ts_regression(..., rettype=1)获取斜率代替动量,bucket(rank(close), "0.7,1")近似选取市值前30%的龙头股,ts_corr(...)衡量价量情绪,reverse将其转化为背离信号。 现在,请严格遵守以上所有规则,开始生成100行可立即在WebSim中运行的复合因子表达式。 **输出格式**(一行一个表达式, 只要表达式本身, 不要解释, 不需要序号, 也不要输出多余的东西): 表达式 表达式 表达式 ... 表达式 请提供具体的WQ表达式。 重申:请确保所有表达式都使用WorldQuant WebSim平台函数,不要使用pandas、numpy或其他Python库函数。输出必须是一行有效的WQ表达式。 以下是我的账号权限范围内可以使用的操作符和每个操作符的描述, 你可以参考, 请随意组合, 但禁止使用以下操作符以外的 Operator: abs(x) Description: Absolute value of x Operator: add(x, y, filter = false), x + y Description: Add all inputs (at least 2 inputs required). If filter = true, filter all input NaN to 0 before adding Operator: densify(x) Description: Converts a grouping field of many buckets into lesser number of only available buckets so as to make working with grouping fields computationally efficient Operator: divide(x, y), x / y Description: x / y Operator: inverse(x) Description: 1 / x Operator: log(x) Description: Natural logarithm. For example: Log(high/low) uses natural logarithm of high/low ratio as stock weights. Operator: max(x, y, ..) Description: Maximum value of all inputs. At least 2 inputs are required Operator: min(x, y ..) Description: Minimum value of all inputs. At least 2 inputs are required Operator: multiply(x ,y, ... , filter=false), x * y Description: Multiply all inputs. At least 2 inputs are required. Filter sets the NaN values to 1 Operator: power(x, y) Description: x ^ y Operator: reverse(x) Description: - x Operator: sign(x) Description: if input > 0, return 1; if input < 0, return -1; if input = 0, return 0; if input = NaN, return NaN; Operator: signed_power(x, y) Description: x raised to the power of y such that final result preserves sign of x Operator: sqrt(x) Description: Square root of x Operator: subtract(x, y, filter=false), x - y Description: x-y. If filter = true, filter all input NaN to 0 before subtracting Operator: and(input1, input2) Description: Logical AND operator, returns true if both operands are true and returns false otherwise Operator: if_else(input1, input2, input 3) Description: If input1 is true then return input2 else return input3. Operator: input1 < input2 Description: If input1 < input2 return true, else return false Operator: input1 <= input2 Description: Returns true if input1 <= input2, return false otherwise Operator: input1 == input2 Description: Returns true if both inputs are same and returns false otherwise Operator: input1 > input2 Description: Logic comparison operators to compares two inputs Operator: input1 >= input2 Description: Returns true if input1 >= input2, return false otherwise Operator: input1!= input2 Description: Returns true if both inputs are NOT the same and returns false otherwise Operator: is_nan(input) Description: If (input == NaN) return 1 else return 0 Operator: not(x) Description: Returns the logical negation of x. If x is true (1), it returns false (0), and if input is false (0), it returns true (1). Operator: or(input1, input2) Description: Logical OR operator returns true if either or both inputs are true and returns false otherwise Operator: days_from_last_change(x) Description: Amount of days since last change of x Operator: hump(x, hump = 0.01) Description: Limits amount and magnitude of changes in input (thus reducing turnover) Operator: kth_element(x, d, k) Description: Returns K-th value of input by looking through lookback days. This operator can be used to backfill missing data if k=1 Operator: last_diff_value(x, d) Description: Returns last x value not equal to current x value from last d days Operator: ts_arg_max(x, d) Description: Returns the relative index of the max value in the time series for the past d days. If the current day has the max value for the past d days, it returns 0. If previous day has the max value for the past d days, it returns 1 Operator: ts_arg_min(x, d) Description: Returns the relative index of the min value in the time series for the past d days; If the current day has the min value for the past d days, it returns 0; If previous day has the min value for the past d days, it returns 1. Operator: ts_av_diff(x, d) Description: Returns x - tsmean(x, d), but deals with NaNs carefully. That is NaNs are ignored during mean computation Operator: ts_backfill(x,lookback = d, k=1, ignore="NAN") Description: Backfill is the process of replacing the NAN or 0 values by a meaningful value (i.e., a first non-NaN value) Operator: ts_corr(x, y, d) Description: Returns correlation of x and y for the past d days Operator: ts_count_nans(x ,d) Description: Returns the number of NaN values in x for the past d days Operator: ts_covariance(y, x, d) Description: Returns covariance of y and x for the past d days Operator: ts_decay_linear(x, d, dense = false) Description: Returns the linear decay on x for the past d days. Dense parameter=false means operator works in sparse mode and we treat NaN as 0. In dense mode we do not. Operator: ts_delay(x, d) Description: Returns x value d days ago Operator: ts_delta(x, d) Description: Returns x - ts_delay(x, d) Operator: ts_mean(x, d) Description: Returns average value of x for the past d days. Operator: ts_product(x, d) Description: Returns product of x for the past d days Operator: ts_quantile(x,d, driver="gaussian" ) Description: It calculates ts_rank and apply to its value an inverse cumulative density function from driver distribution. Possible values of driver (optional ) are "gaussian", "uniform", "cauchy" distribution where "gaussian" is the default. Operator: ts_rank(x, d, constant = 0) Description: Rank the values of x for each instrument over the past d days, then return the rank of the current value + constant. If not specified, by default, constant = 0. Operator: ts_regression(y, x, d, lag = 0, rettype = 0) Description: Returns various parameters related to regression function Operator: ts_scale(x, d, constant = 0) Description: Returns (x - ts_min(x, d)) / (ts_max(x, d) - ts_min(x, d)) + constant. This operator is similar to scale down operator but acts in time series space Operator: ts_std_dev(x, d) Description: Returns standard deviation of x for the past d days Operator: ts_step(1) Description: Returns days' counter Operator: ts_sum(x, d) Description: Sum values of x for the past d days. Operator: ts_zscore(x, d) Description: Z-score is a numerical measurement that describes a value's relationship to the mean of a group of values. Z-score is measured in terms of standard deviations from the mean: (x - tsmean(x,d)) / tsstddev(x,d). This operator may help reduce outliers and drawdown. Operator: normalize(x, useStd = false, limit = 0.0) Description: Calculates the mean value of all valid alpha values for a certain date, then subtracts that mean from each element Operator: quantile(x, driver = gaussian, sigma = 1.0) Description: Rank the raw vector, shift the ranked Alpha vector, apply distribution (gaussian, cauchy, uniform). If driver is uniform, it simply subtract each Alpha value with the mean of all Alpha values in the Alpha vector Operator: rank(x, rate=2) Description: Ranks the input among all the instruments and returns an equally distributed number between 0.0 and 1.0. For precise sort, use the rate as 0 Operator: scale(x, scale=1, longscale=1, shortscale=1) Description: Scales input to booksize. We can also scale the long positions and short positions to separate scales by mentioning additional parameters to the operator Operator: winsorize(x, std=4) Description: Winsorizes x to make sure that all values in x are between the lower and upper limits, which are specified as multiple of std. Operator: zscore(x) Description: Z-score is a numerical measurement that describes a value's relationship to the mean of a group of values. Z-score is measured in terms of standard deviations from the mean Operator: vec_avg(x) Description: Taking mean of the vector field x Operator: vec_sum(x) Description: Sum of vector field x Operator: bucket(rank(x), range="0, 1, 0.1" or buckets = "2,5,6,7,10") Description: Convert float values into indexes for user-specified buckets. Bucket is useful for creating group values, which can be passed to GROUP as input Operator: trade_when(x, y, z) Description: Used in order to change Alpha values only under a specified condition and to hold Alpha values in other cases. It also allows to close Alpha positions (assign NaN values) under a specified condition Operator: group_backfill(x, group, d, std = 4.0) Description: If a certain value for a certain date and instrument is NaN, from the set of same group instruments, calculate winsorized mean of all non-NaN values over last d days Operator: group_mean(x, weight, group) Description: All elements in group equals to the mean Operator: group_neutralize(x, group) Description: Neutralizes Alpha against groups. These groups can be subindustry, industry, sector, country or a constant Operator: group_rank(x, group) Description: Each elements in a group is assigned the corresponding rank in this group Operator: group_scale(x, group) Description: Normalizes the values in a group to be between 0 and 1. (x - groupmin) / (groupmax - groupmin) Operator: group_zscore(x, group) Description: Calculates group Z-score - numerical measurement that describes a value's relationship to the mean of a group of values. Z-score is measured in terms of standard deviations from the mean. zscore = (data - mean) / stddev of x for each instrument within its group. 重申:请确保所有表达式都使用WorldQuant WebSim平台函数,不要使用pandas、numpy或其他Python库函数。输出必须是一行有效的WQ表达式。