jack 4 hours ago
parent a7ab5d48c9
commit 19c147c107
  1. 24
      load_optrators.py
  2. 926
      operators.json
  3. 420
      operators.txt

@ -0,0 +1,24 @@
# 将手动保存的操作符, 输出为可以直接在提示词使用的格式
# 操作符不用爬虫, 因为只有一页, 直接在网页复制
import json
import os
current_dir = os.path.dirname(os.path.abspath(__file__))
opreator_file = os.path.join(current_dir, 'operators.json')
with open(opreator_file, 'r') as f:
optrators = json.load(f)
optput = ""
for optrator in optrators:
name = optrator.get("name").replace("\n", "").replace("\r", "")
description = optrator.get("description").replace("\n", "").replace("\r", "")
category = optrator.get("category").replace("\n", "").replace("\r", "")
definition = optrator.get("definition").replace("\n", "").replace("\r", "")
optput += f"name: {name}\ndescription: {description}\ncategory:{category}\ndefinition:{definition}\n\n"
# print(f"name: {name}\ndescription: {description}\ncategory:{category}\ndefinition:{definition}\n")
with open("operators.txt", "w") as f:
f.write(optput)

@ -0,0 +1,926 @@
[
{
"name": "add",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "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",
"documentation": null,
"level": "ALL"
},
{
"name": "abs",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "abs(x)",
"description": "Absolute value of x",
"documentation": null,
"level": "ALL"
},
{
"name": "log",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "log(x)",
"description": "Natural logarithm. For example: Log(high/low) uses natural logarithm of high/low ratio as stock weights.",
"documentation": null,
"level": "ALL"
},
{
"name": "subtract",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "subtract(x, y, filter=false), x - y",
"description": "x-y. If filter = true, filter all input NaN to 0 before subtracting",
"documentation": null,
"level": "ALL"
},
{
"name": "signed_power",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "signed_power(x, y)",
"description": "x raised to the power of y such that final result preserves sign of x",
"documentation": "/operators/signed_power",
"level": "ALL"
},
{
"name": "sign",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "sign(x)",
"description": "if input > 0, return 1; if input < 0, return -1; if input = 0, return 0; if input = NaN, return NaN;\r\n\r\nInput: Value of 7 instruments at day t: (2, -3, 5, 6, 3, NaN, -10)\r\nOutput: (1, -1, 1, 1, 1, NaN, -1)",
"documentation": null,
"level": "ALL"
},
{
"name": "reverse",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "reverse(x)",
"description": " - x",
"documentation": null,
"level": "ALL"
},
{
"name": "power",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "power(x, y)",
"description": "x ^ y",
"documentation": "/operators/power",
"level": "ALL"
},
{
"name": "multiply",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "multiply(x ,y, ... , filter=false), x * y",
"description": "Multiply all inputs. At least 2 inputs are required. Filter sets the NaN values to 1",
"documentation": "/operators/multiply",
"level": "ALL"
},
{
"name": "min",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "min(x, y ..)",
"description": "Minimum value of all inputs. At least 2 inputs are required",
"documentation": "/operators/min",
"level": "ALL"
},
{
"name": "max",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "max(x, y, ..)",
"description": "Maximum value of all inputs. At least 2 inputs are required",
"documentation": "/operators/max",
"level": "ALL"
},
{
"name": "inverse",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "inverse(x)",
"description": "1 / x",
"documentation": null,
"level": "ALL"
},
{
"name": "sqrt",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "sqrt(x)",
"description": "Square root of x",
"documentation": null,
"level": "ALL"
},
{
"name": "s_log_1p",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "s_log_1p(x)",
"description": "Confine function to a shorter range using logarithm such that higher input remains higher and negative input remains negative as an output of resulting function and -1 or 1 is an asymptotic value",
"documentation": "/operators/s_log_1p",
"level": null
},
{
"name": "densify",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "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",
"documentation": "/operators/densify",
"level": "ALL"
},
{
"name": "divide",
"category": "Arithmetic",
"scope": [
"REGULAR"
],
"definition": "divide(x, y), x / y",
"description": "x / y",
"documentation": null,
"level": "ALL"
},
{
"name": "not",
"category": "Logical",
"scope": [
"REGULAR"
],
"definition": "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).",
"documentation": null,
"level": "ALL"
},
{
"name": "and",
"category": "Logical",
"scope": [
"REGULAR"
],
"definition": "and(input1, input2)",
"description": "Logical AND operator, returns true if both operands are true and returns false otherwise",
"documentation": null,
"level": "ALL"
},
{
"name": "less",
"category": "Logical",
"scope": [
"REGULAR"
],
"definition": "input1 < input2",
"description": "If input1 < input2 return true, else return false",
"documentation": null,
"level": "ALL"
},
{
"name": "equal",
"category": "Logical",
"scope": [
"REGULAR"
],
"definition": "input1 == input2",
"description": "Returns true if both inputs are same and returns false otherwise",
"documentation": null,
"level": "ALL"
},
{
"name": "or",
"category": "Logical",
"scope": [
"REGULAR"
],
"definition": "or(input1, input2)",
"description": "Logical OR operator returns true if either or both inputs are true and returns false otherwise",
"documentation": null,
"level": "ALL"
},
{
"name": "not_equal",
"category": "Logical",
"scope": [
"REGULAR"
],
"definition": "input1!= input2",
"description": "Returns true if both inputs are NOT the same and returns false otherwise",
"documentation": null,
"level": "ALL"
},
{
"name": "greater",
"category": "Logical",
"scope": [
"REGULAR"
],
"definition": "input1 > input2",
"description": "Logic comparison operators to compares two inputs",
"documentation": null,
"level": "ALL"
},
{
"name": "greater_equal",
"category": "Logical",
"scope": [
"REGULAR"
],
"definition": "input1 >= input2",
"description": "Returns true if input1 >= input2, return false otherwise",
"documentation": null,
"level": "ALL"
},
{
"name": "less_equal",
"category": "Logical",
"scope": [
"REGULAR"
],
"definition": "input1 <= input2",
"description": "Returns true if input1 <= input2, return false otherwise",
"documentation": null,
"level": "ALL"
},
{
"name": "is_nan",
"category": "Logical",
"scope": [
"REGULAR"
],
"definition": "is_nan(input)",
"description": "If (input == NaN) return 1 else return 0",
"documentation": "/operators/is_nan",
"level": "ALL"
},
{
"name": "if_else",
"category": "Logical",
"scope": [
"REGULAR"
],
"definition": "if_else(input1, input2, input 3)",
"description": "If input1 is true then return input2 else return input3.",
"documentation": "/operators/if_else",
"level": "ALL"
},
{
"name": "ts_sum",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_sum(x, d)",
"description": "Sum values of x for the past d days.",
"documentation": null,
"level": "ALL"
},
{
"name": "ts_scale",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "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",
"documentation": "/operators/ts_scale",
"level": "ALL"
},
{
"name": "ts_mean",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_mean(x, d)",
"description": "Returns average value of x for the past d days.",
"documentation": null,
"level": "ALL"
},
{
"name": "ts_zscore",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "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.\r\n\r\nInput: Value of 1 instrument in past 5 days where first element is the latest: (100, 0, 50, 60, 25), d: 5\r\nOutput: (100-47)/33.7 = 1.57 from SD: 33.7, mean = 47",
"documentation": null,
"level": "ALL"
},
{
"name": "ts_std_dev",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_std_dev(x, d)",
"description": "Returns standard deviation of x for the past d days",
"documentation": null,
"level": "ALL"
},
{
"name": "kth_element",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "kth_element(x, d, k)",
"description": "Returns K-th valid value of input by looking through lookback days. This operator can be used to backfill missing data if k=1",
"documentation": "/operators/kth_element",
"level": "ALL"
},
{
"name": "inst_tvr",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "inst_tvr(x, d)",
"description": "Total trading value / Total holding value in the past d days\r\n\r\nInput: Value of 1 instrument in past 5 days where first element is the latest: (105, 102, 99, 101,100)\r\nOutput: 0.022 from (1+2+3+3)/(105+102+99+101)",
"documentation": null,
"level": null
},
{
"name": "ts_corr",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_corr(x, y, d)",
"description": "Returns correlation of x and y for the past d days",
"documentation": "/operators/ts_corr",
"level": "ALL"
},
{
"name": "ts_count_nans",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_count_nans(x ,d)",
"description": "Returns the number of NaN values in x for the past d days\r\n\r\nInput: Value of 1 instrument in past 4 days where first element is the latest: (100, NaN, NaN, 200), d: 4\r\nOutput: Number of NaN in 4 days = 2",
"documentation": null,
"level": "ALL"
},
{
"name": "ts_target_tvr_decay",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_target_tvr_decay(x, lambda_min=0, lambda_max=1, target_tvr=0.1)",
"description": "Tune \"ts_decay\" to have a turnover equal to a certain target, with optimization weight range between lambda_min, lambda_max",
"documentation": null,
"level": null
},
{
"name": "ts_median",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_median(x, d)",
"description": "Returns median value of x for the past d days",
"documentation": null,
"level": null
},
{
"name": "ts_covariance",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_covariance(y, x, d)",
"description": "Returns covariance of y and x for the past d days",
"documentation": null,
"level": "ALL"
},
{
"name": "ts_decay_linear",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "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.",
"documentation": "/operators/ts_decay_linear",
"level": "ALL"
},
{
"name": "ts_product",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_product(x, d)",
"description": "Returns product of x for the past d days",
"documentation": "/operators/ts_product",
"level": "ALL"
},
{
"name": "ts_regression",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_regression(y, x, d, lag = 0, rettype = 0)",
"description": "Returns various parameters related to regression function",
"documentation": "/operators/ts_regression",
"level": "ALL"
},
{
"name": "ts_delta_limit",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_delta_limit(x, y, limit_volume=0.1)",
"description": "Limit the change in the Alpha position x between dates to a specified fraction of y. The \"limit_volume\" can be in the range of 0 to 1. Also, please be aware of the scaling for x and y. Besides setting y as adv20 or volume related data, you can also set y as a constant.",
"documentation": null,
"level": null
},
{
"name": "ts_step",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_step(1)",
"description": "Returns days' counter",
"documentation": null,
"level": "ALL"
},
{
"name": "ts_decay_exp_window",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_decay_exp_window(x, d, factor = f)",
"description": "Returns exponential decay of x with smoothing factor for the past d days",
"documentation": "/operators/ts_decay_exp_window",
"level": null
},
{
"name": "ts_quantile",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "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.\r\n\r\nInput: Value of 1 instrument in past 7 days where first element is the latest: (8, 10, 4, 6, 5, 3, 2), d: 7, driver: ’gaussian’\r\nOutput: quantile = 0.82 from SD = 2.82, mean = 5.43, zscore = 0.911",
"documentation": null,
"level": "ALL"
},
{
"name": "days_from_last_change",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "days_from_last_change(x)",
"description": "Amount of days since last change of x\r\n\r\nInput: Value of 1 instrument in past 7 days where first element is the latest: (2, 2, 2, 7, 5, 16, 1)\r\nOutput: 3",
"documentation": null,
"level": "ALL"
},
{
"name": "hump",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "hump(x, hump = 0.01)",
"description": "Limits amount and magnitude of changes in input (thus reducing turnover)",
"documentation": "/operators/hump",
"level": "ALL"
},
{
"name": "last_diff_value",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "last_diff_value(x, d)",
"description": "Returns last x value not equal to current x value from last d days",
"documentation": null,
"level": "ALL"
},
{
"name": "ts_arg_max",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "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",
"documentation": "/operators/ts_arg_max",
"level": "ALL"
},
{
"name": "ts_arg_min",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "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.",
"documentation": "/operators/ts_arg_min",
"level": "ALL"
},
{
"name": "ts_av_diff",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_av_diff(x, d)",
"description": "Returns x - tsmean(x, d), but deals with NaNs carefully. That is NaNs are ignored during mean computation",
"documentation": "/operators/ts_av_diff",
"level": "ALL"
},
{
"name": "ts_backfill",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_backfill(x, d)",
"description": "Returns the first valid value of the input x by looking through lookback days (d). This operator can be used to backfill missing data.",
"documentation": "/operators/ts_backfill",
"level": "ALL"
},
{
"name": "ts_rank",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "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.\r\n\r\nInput: Value of 1 instrument in past 3 days where first element is the latest: (100, 0, 200), d: 3\r\nOutput: 0.5",
"documentation": null,
"level": "ALL"
},
{
"name": "ts_delay",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_delay(x, d)",
"description": "Returns x value d days ago\r\n\r\nInput: Value of 1 instrument in past 7 days where first element is the latest: (2, 3, 5, 6, 3, 8, 10), d: 6\r\nOutput: Value 6 days ago = 10",
"documentation": null,
"level": "ALL"
},
{
"name": "ts_delta",
"category": "Time Series",
"scope": [
"REGULAR"
],
"definition": "ts_delta(x, d)",
"description": "Returns x - ts_delay(x, d)\r\n\r\nInput: Value of 1 instrument in past 7 days where first element is the latest: (2, 3, 5, 6, 3, 8, 10), d: 6\r\nOutput: Value today – value 6 days ago = 2 - 10 = -8",
"documentation": null,
"level": "ALL"
},
{
"name": "winsorize",
"category": "Cross Sectional",
"scope": [
"REGULAR"
],
"definition": "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.\r\n\r\nInput: Value of 7 instruments at day t: (2, 4, 5, 6, 3, 8, 10), std: 1\r\nOutput: (2.81, 4, 5, 6, 3, 8, 8.03) from SD. = 2.61, mean = 5.42",
"documentation": null,
"level": "ALL"
},
{
"name": "truncate",
"category": "Cross Sectional",
"scope": [
"REGULAR"
],
"definition": "truncate(x,maxPercent=0.01)",
"description": "Operator truncates all values of x to maxPercent. Here, maxPercent is in decimal notation",
"documentation": "/operators/truncate",
"level": null
},
{
"name": "regression_neut",
"category": "Cross Sectional",
"scope": [
"REGULAR"
],
"definition": "regression_neut(y, x)",
"description": "Conducts the cross-sectional regression on the stocks with Y as target and X as the independent variable",
"documentation": "/operators/regression_neut",
"level": null
},
{
"name": "scale",
"category": "Cross Sectional",
"scope": [
"REGULAR"
],
"definition": "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",
"documentation": "/operators/scale",
"level": "ALL"
},
{
"name": "rank",
"category": "Cross Sectional",
"scope": [
"REGULAR"
],
"definition": "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",
"documentation": "/operators/rank",
"level": "ALL"
},
{
"name": "quantile",
"category": "Cross Sectional",
"scope": [
"REGULAR"
],
"definition": "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",
"documentation": "/operators/quantile",
"level": "ALL"
},
{
"name": "normalize",
"category": "Cross Sectional",
"scope": [
"REGULAR"
],
"definition": "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",
"documentation": "/operators/normalize",
"level": "ALL"
},
{
"name": "zscore",
"category": "Cross Sectional",
"scope": [
"REGULAR"
],
"definition": "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",
"documentation": "/operators/zscore",
"level": "ALL"
},
{
"name": "vec_min",
"category": "Vector",
"scope": [
"REGULAR"
],
"definition": "vec_min(x)",
"description": "Minimum value form vector field x",
"documentation": null,
"level": null
},
{
"name": "vec_count",
"category": "Vector",
"scope": [
"REGULAR"
],
"definition": "vec_count(x)",
"description": "Number of elements in vector field x",
"documentation": null,
"level": null
},
{
"name": "vec_stddev",
"category": "Vector",
"scope": [
"REGULAR"
],
"definition": "vec_stddev(x)",
"description": "Standard Deviation of vector field x",
"documentation": null,
"level": null
},
{
"name": "vec_range",
"category": "Vector",
"scope": [
"REGULAR"
],
"definition": "vec_range(x)",
"description": "Difference between maximum and minimum element in vector field x",
"documentation": null,
"level": null
},
{
"name": "vec_avg",
"category": "Vector",
"scope": [
"REGULAR"
],
"definition": "vec_avg(x)",
"description": "Taking mean of the vector field x\r\n\r\nInput: Vector of value of 1 instrument in a day: (2, 3, 5, 6, 3, 8, 10)\r\nOutput: 37 / 7 = 5.29",
"documentation": null,
"level": "ALL"
},
{
"name": "vec_sum",
"category": "Vector",
"scope": [
"REGULAR"
],
"definition": "vec_sum(x)",
"description": "Sum of vector field x\r\n\r\nInput: Vector of value of 1 instrument in a day: (2, 3, 5, 6, 3, 8, 10)\r\nOutput: 2 + 3 + 5 + 6 + 3 + 8 + 10 = 37",
"documentation": null,
"level": "ALL"
},
{
"name": "vec_max",
"category": "Vector",
"scope": [
"REGULAR"
],
"definition": "vec_max(x)",
"description": "Maximum value form vector field x",
"documentation": null,
"level": null
},
{
"name": "left_tail",
"category": "Transformational",
"scope": [
"REGULAR"
],
"definition": "left_tail(x, maximum = 0)",
"description": "NaN everything greater than maximum, maximum should be constant",
"documentation": "/operators/left_tail",
"level": null
},
{
"name": "trade_when",
"category": "Transformational",
"scope": [
"REGULAR"
],
"definition": "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",
"documentation": "/operators/trade_when",
"level": "ALL"
},
{
"name": "right_tail",
"category": "Transformational",
"scope": [
"REGULAR"
],
"definition": "right_tail(x, minimum = 0)",
"description": "NaN everything less than minimum, minimum should be constant",
"documentation": "/operators/right_tail",
"level": null
},
{
"name": "bucket",
"category": "Transformational",
"scope": [
"REGULAR"
],
"definition": "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",
"documentation": "/operators/bucket",
"level": "ALL"
},
{
"name": "group_rank",
"category": "Group",
"scope": [
"REGULAR"
],
"definition": "group_rank(x, group)",
"description": "Each elements in a group is assigned the corresponding rank in this group",
"documentation": "/operators/group_rank",
"level": "ALL"
},
{
"name": "group_cartesian_product",
"category": "Group",
"scope": [
"REGULAR"
],
"definition": "group_cartesian_product(g1, g2)",
"description": "Merge two groups into one group. If originally there are len_1 and len_2 group indices in g1 and g2, there will be len_1 * len_2 indices in the new group.",
"documentation": null,
"level": null
},
{
"name": "group_backfill",
"category": "Group",
"scope": [
"REGULAR"
],
"definition": "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",
"documentation": "/operators/group_backfill",
"level": "ALL"
},
{
"name": "group_mean",
"category": "Group",
"scope": [
"REGULAR"
],
"definition": "group_mean(x, weight, group)",
"description": "All elements in group equals to the mean",
"documentation": "/operators/group_mean",
"level": "ALL"
},
{
"name": "group_neutralize",
"category": "Group",
"scope": [
"REGULAR"
],
"definition": "group_neutralize(x, group)",
"description": "Neutralizes Alpha against groups. These groups can be subindustry, industry, sector, country or a constant",
"documentation": "/operators/group_neutralize",
"level": "ALL"
},
{
"name": "group_normalize",
"category": "Group",
"scope": [
"REGULAR"
],
"definition": "group_normalize(x, group, constantCheck=False, tolerance=0.01, scale=1)",
"description": "Normalizes input such that each group's absolute sum is 1",
"documentation": null,
"level": null
},
{
"name": "group_median",
"category": "Group",
"scope": [
"REGULAR"
],
"definition": "group_median(x, group)",
"description": "All elements in group equals to the median value of the group.",
"documentation": null,
"level": null
},
{
"name": "group_scale",
"category": "Group",
"scope": [
"REGULAR"
],
"definition": "group_scale(x, group)",
"description": "Normalizes the values in a group to be between 0 and 1. (x - groupmin) / (groupmax - groupmin)",
"documentation": null,
"level": "ALL"
},
{
"name": "group_zscore",
"category": "Group",
"scope": [
"REGULAR"
],
"definition": "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.\r\n\r\nInput: Value of 5 instruments of Group A: (100, 0, 50, 60, 25)\r\nOutput: (1.57, -1.39, 0.09, 0.39, -0.65)",
"documentation": null,
"level": "ALL"
}
]

@ -0,0 +1,420 @@
name: add
description: Add all inputs (at least 2 inputs required). If filter = true, filter all input NaN to 0 before adding
category:Arithmetic
definition:add(x, y, filter = false), x + y
name: abs
description: Absolute value of x
category:Arithmetic
definition:abs(x)
name: log
description: Natural logarithm. For example: Log(high/low) uses natural logarithm of high/low ratio as stock weights.
category:Arithmetic
definition:log(x)
name: subtract
description: x-y. If filter = true, filter all input NaN to 0 before subtracting
category:Arithmetic
definition:subtract(x, y, filter=false), x - y
name: signed_power
description: x raised to the power of y such that final result preserves sign of x
category:Arithmetic
definition:signed_power(x, y)
name: sign
description: if input > 0, return 1; if input < 0, return -1; if input = 0, return 0; if input = NaN, return NaN;Input: Value of 7 instruments at day t: (2, -3, 5, 6, 3, NaN, -10)Output: (1, -1, 1, 1, 1, NaN, -1)
category:Arithmetic
definition:sign(x)
name: reverse
description:  - x
category:Arithmetic
definition:reverse(x)
name: power
description: x ^ y
category:Arithmetic
definition:power(x, y)
name: multiply
description: Multiply all inputs. At least 2 inputs are required. Filter sets the NaN values to 1
category:Arithmetic
definition:multiply(x ,y, ... , filter=false), x * y
name: min
description: Minimum value of all inputs. At least 2 inputs are required
category:Arithmetic
definition:min(x, y ..)
name: max
description: Maximum value of all inputs. At least 2 inputs are required
category:Arithmetic
definition:max(x, y, ..)
name: inverse
description: 1 / x
category:Arithmetic
definition:inverse(x)
name: sqrt
description: Square root of x
category:Arithmetic
definition:sqrt(x)
name: s_log_1p
description: Confine function to a shorter range using logarithm such that higher input remains higher and negative input remains negative as an output of resulting function and -1 or 1 is an asymptotic value
category:Arithmetic
definition:s_log_1p(x)
name: densify
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
category:Arithmetic
definition:densify(x)
name: divide
description: x / y
category:Arithmetic
definition:divide(x, y), x / y
name: not
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).
category:Logical
definition:not(x)
name: and
description: Logical AND operator, returns true if both operands are true and returns false otherwise
category:Logical
definition:and(input1, input2)
name: less
description: If input1 < input2 return true, else return false
category:Logical
definition:input1 < input2
name: equal
description: Returns true if both inputs are same and returns false otherwise
category:Logical
definition:input1 == input2
name: or
description: Logical OR operator returns true if either or both inputs are true and returns false otherwise
category:Logical
definition:or(input1, input2)
name: not_equal
description: Returns true if both inputs are NOT the same and returns false otherwise
category:Logical
definition:input1!= input2
name: greater
description: Logic comparison operators to compares two inputs
category:Logical
definition:input1 > input2
name: greater_equal
description: Returns true if input1 >= input2, return false otherwise
category:Logical
definition:input1 >= input2
name: less_equal
description: Returns true if input1 <= input2, return false otherwise
category:Logical
definition:input1 <= input2
name: is_nan
description: If (input == NaN) return 1 else return 0
category:Logical
definition:is_nan(input)
name: if_else
description: If input1 is true then return input2 else return input3.
category:Logical
definition:if_else(input1, input2, input 3)
name: ts_sum
description: Sum values of x for the past d days.
category:Time Series
definition:ts_sum(x, d)
name: ts_scale
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
category:Time Series
definition:ts_scale(x, d, constant = 0)
name: ts_mean
description: Returns average value of x for the past d days.
category:Time Series
definition:ts_mean(x, d)
name: ts_zscore
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.Input: Value of 1 instrument in past 5 days where first element is the latest: (100, 0, 50, 60, 25), d: 5Output: (100-47)/33.7 = 1.57 from SD: 33.7, mean = 47
category:Time Series
definition:ts_zscore(x, d)
name: ts_std_dev
description: Returns standard deviation of x for the past d days
category:Time Series
definition:ts_std_dev(x, d)
name: kth_element
description: Returns K-th valid value of input by looking through lookback days. This operator can be used to backfill missing data if k=1
category:Time Series
definition:kth_element(x, d, k)
name: inst_tvr
description: Total trading value / Total holding value in the past d daysInput: Value of 1 instrument in past 5 days where first element is the latest: (105, 102, 99, 101,100)Output: 0.022 from (1+2+3+3)/(105+102+99+101)
category:Time Series
definition:inst_tvr(x, d)
name: ts_corr
description: Returns correlation of x and y for the past d days
category:Time Series
definition:ts_corr(x, y, d)
name: ts_count_nans
description: Returns the number of NaN values in x for the past d daysInput: Value of 1 instrument in past 4 days where first element is the latest: (100, NaN, NaN, 200), d: 4Output: Number of NaN in 4 days = 2
category:Time Series
definition:ts_count_nans(x ,d)
name: ts_target_tvr_decay
description: Tune "ts_decay" to have a turnover equal to a certain target, with optimization weight range between lambda_min, lambda_max
category:Time Series
definition:ts_target_tvr_decay(x, lambda_min=0, lambda_max=1, target_tvr=0.1)
name: ts_median
description: Returns median value of x for the past d days
category:Time Series
definition:ts_median(x, d)
name: ts_covariance
description: Returns covariance of y and x for the past d days
category:Time Series
definition:ts_covariance(y, x, d)
name: ts_decay_linear
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.
category:Time Series
definition:ts_decay_linear(x, d, dense = false)
name: ts_product
description: Returns product of x for the past d days
category:Time Series
definition:ts_product(x, d)
name: ts_regression
description: Returns various parameters related to regression function
category:Time Series
definition:ts_regression(y, x, d, lag = 0, rettype = 0)
name: ts_delta_limit
description: Limit the change in the Alpha position x between dates to a specified fraction of y. The "limit_volume" can be in the range of 0 to 1. Also, please be aware of the scaling for x and y. Besides setting y as adv20 or volume related data, you can also set y as a constant.
category:Time Series
definition:ts_delta_limit(x, y, limit_volume=0.1)
name: ts_step
description: Returns days' counter
category:Time Series
definition:ts_step(1)
name: ts_decay_exp_window
description: Returns exponential decay of x with smoothing factor for the past d days
category:Time Series
definition:ts_decay_exp_window(x, d, factor = f)
name: ts_quantile
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.Input: Value of 1 instrument in past 7 days where first element is the latest: (8, 10, 4, 6, 5, 3, 2), d: 7, driver: ’gaussian’Output: quantile = 0.82 from SD = 2.82, mean = 5.43, zscore = 0.911
category:Time Series
definition:ts_quantile(x,d, driver="gaussian" )
name: days_from_last_change
description: Amount of days since last change of xInput: Value of 1 instrument in past 7 days where first element is the latest: (2, 2, 2, 7, 5, 16, 1)Output: 3
category:Time Series
definition:days_from_last_change(x)
name: hump
description: Limits amount and magnitude of changes in input (thus reducing turnover)
category:Time Series
definition:hump(x, hump = 0.01)
name: last_diff_value
description: Returns last x value not equal to current x value from last d days
category:Time Series
definition:last_diff_value(x, d)
name: ts_arg_max
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
category:Time Series
definition:ts_arg_max(x, d)
name: ts_arg_min
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.
category:Time Series
definition:ts_arg_min(x, d)
name: ts_av_diff
description: Returns x - tsmean(x, d), but deals with NaNs carefully. That is NaNs are ignored during mean computation
category:Time Series
definition:ts_av_diff(x, d)
name: ts_backfill
description: Returns the first valid value of the input x by looking through lookback days (d). This operator can be used to backfill missing data.
category:Time Series
definition:ts_backfill(x, d)
name: ts_rank
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.Input: Value of 1 instrument in past 3 days where first element is the latest: (100, 0, 200), d: 3Output: 0.5
category:Time Series
definition:ts_rank(x, d, constant = 0)
name: ts_delay
description: Returns x value d days agoInput: Value of 1 instrument in past 7 days where first element is the latest: (2, 3, 5, 6, 3, 8, 10), d: 6Output: Value 6 days ago = 10
category:Time Series
definition:ts_delay(x, d)
name: ts_delta
description: Returns x - ts_delay(x, d)Input: Value of 1 instrument in past 7 days where first element is the latest: (2, 3, 5, 6, 3, 8, 10), d: 6Output: Value today – value 6 days ago = 2 - 10 = -8
category:Time Series
definition:ts_delta(x, d)
name: winsorize
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.Input: Value of 7 instruments at day t: (2, 4, 5, 6, 3, 8, 10), std: 1Output: (2.81, 4, 5, 6, 3, 8, 8.03) from SD. = 2.61, mean = 5.42
category:Cross Sectional
definition:winsorize(x, std=4)
name: truncate
description: Operator truncates all values of x to maxPercent. Here, maxPercent is in decimal notation
category:Cross Sectional
definition:truncate(x,maxPercent=0.01)
name: regression_neut
description: Conducts the cross-sectional regression on the stocks with Y as target and X as the independent variable
category:Cross Sectional
definition:regression_neut(y, x)
name: scale
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
category:Cross Sectional
definition:scale(x, scale=1, longscale=1, shortscale=1)
name: rank
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
category:Cross Sectional
definition:rank(x, rate=2)
name: quantile
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
category:Cross Sectional
definition:quantile(x, driver = gaussian, sigma = 1.0)
name: normalize
description: Calculates the mean value of all valid alpha values for a certain date, then subtracts that mean from each element
category:Cross Sectional
definition:normalize(x, useStd = false, limit = 0.0)
name: zscore
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
category:Cross Sectional
definition:zscore(x)
name: vec_min
description: Minimum value form vector field x
category:Vector
definition:vec_min(x)
name: vec_count
description: Number of elements in vector field x
category:Vector
definition:vec_count(x)
name: vec_stddev
description: Standard Deviation of vector field x
category:Vector
definition:vec_stddev(x)
name: vec_range
description: Difference between maximum and minimum element in vector field x
category:Vector
definition:vec_range(x)
name: vec_avg
description: Taking mean of the vector field xInput: Vector of value of 1 instrument in a day: (2, 3, 5, 6, 3, 8, 10)Output: 37 / 7 = 5.29
category:Vector
definition:vec_avg(x)
name: vec_sum
description: Sum of vector field xInput: Vector of value of 1 instrument in a day: (2, 3, 5, 6, 3, 8, 10)Output: 2 + 3 + 5 + 6 + 3 + 8 + 10 = 37
category:Vector
definition:vec_sum(x)
name: vec_max
description: Maximum value form vector field x
category:Vector
definition:vec_max(x)
name: left_tail
description: NaN everything greater than maximum, maximum should be constant
category:Transformational
definition:left_tail(x, maximum = 0)
name: trade_when
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
category:Transformational
definition:trade_when(x, y, z)
name: right_tail
description: NaN everything less than minimum, minimum should be constant
category:Transformational
definition:right_tail(x, minimum = 0)
name: bucket
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
category:Transformational
definition:bucket(rank(x), range="0, 1, 0.1" or buckets = "2,5,6,7,10")
name: group_rank
description: Each elements in a group is assigned the corresponding rank in this group
category:Group
definition:group_rank(x, group)
name: group_cartesian_product
description: Merge two groups into one group. If originally there are len_1 and len_2 group indices in g1 and g2, there will be len_1 * len_2 indices in the new group.
category:Group
definition:group_cartesian_product(g1, g2)
name: group_backfill
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
category:Group
definition:group_backfill(x, group, d, std = 4.0)
name: group_mean
description: All elements in group equals to the mean
category:Group
definition:group_mean(x, weight, group)
name: group_neutralize
description: Neutralizes Alpha against groups. These groups can be subindustry, industry, sector, country or a constant
category:Group
definition:group_neutralize(x, group)
name: group_normalize
description: Normalizes input such that each group's absolute sum is 1
category:Group
definition:group_normalize(x, group, constantCheck=False, tolerance=0.01, scale=1)
name: group_median
description: All elements in group equals to the median value of the group.
category:Group
definition:group_median(x, group)
name: group_scale
description: Normalizes the values in a group to be between 0 and 1. (x - groupmin) / (groupmax - groupmin)
category:Group
definition:group_scale(x, group)
name: group_zscore
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.Input: Value of 5 instruments of Group A: (100, 0, 50, 60, 25)Output: (1.57, -1.39, 0.09, 0.39, -0.65)
category:Group
definition:group_zscore(x, group)
Loading…
Cancel
Save