3477 lines
133 KiB
Python
3477 lines
133 KiB
Python
"""alpha158 因子算子(移植自 qlib alpha158,v1.2.0 Phase 0 第一批 5+5)。
|
||
|
||
设计原则:
|
||
- 零新重型依赖(只用 pandas + numpy)
|
||
- mypy strict 兼容(完整 type hints)
|
||
- 单元可测(每个算子独立函数)
|
||
- 元数据完整(ALPHA158_REGISTRY 描述每个算子的 formula/category/complexity)
|
||
- 与 PostgreSQL JSONB 落库兼容(公式可序列化)
|
||
|
||
对应文档:[docs/ALPHA158_INTEGRATION.md](../../docs/ALPHA158_INTEGRATION.md)
|
||
|
||
源参考:qlib alpha158(https://github.com/microsoft/qlib),MIT License。
|
||
v1.2.0 Phase 0:5 个基础算子 + 5 个 alpha 公式(alpha001–alpha005)。
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from collections.abc import Callable, Mapping
|
||
from types import MappingProxyType
|
||
from typing import Any, cast
|
||
|
||
import numpy as np
|
||
import pandas as pd
|
||
|
||
|
||
# ── 基础算子(building blocks) ──────────────────────────
|
||
|
||
|
||
def rank(series: pd.Series) -> pd.Series:
|
||
"""截面 rank(按百分位)。
|
||
|
||
qlib alpha158 中所有 rank() 调用对应此函数。
|
||
pct=True 返回 [0, 1] 区间;相同值返回 0.5(中位)。
|
||
"""
|
||
return series.rank(pct=True)
|
||
|
||
|
||
def delta(series: pd.Series, n: int) -> pd.Series:
|
||
"""时序 delta(n 期差分)。
|
||
|
||
delta(close, 5) = close - close.shift(5)。
|
||
"""
|
||
if n < 0:
|
||
raise ValueError(f"n must be non-negative, got {n}")
|
||
return series - series.shift(n)
|
||
|
||
|
||
def ts_mean(series: pd.Series, n: int) -> pd.Series:
|
||
"""时序滚动均值(n 期窗口)。"""
|
||
if n <= 0:
|
||
raise ValueError(f"n must be positive, got {n}")
|
||
return series.rolling(n, min_periods=n).mean()
|
||
|
||
|
||
def ts_std(series: pd.Series, n: int) -> pd.Series:
|
||
"""时序滚动标准差(n 期窗口)。"""
|
||
if n <= 0:
|
||
raise ValueError(f"n must be positive, got {n}")
|
||
return series.rolling(n, min_periods=n).std()
|
||
|
||
|
||
def ts_rank(series: pd.Series, n: int) -> pd.Series:
|
||
"""时序滚动 rank(最近 n 期内的百分位)。
|
||
|
||
对每个时点,返回"该值在过去 n 期内的百分位"。
|
||
"""
|
||
if n <= 0:
|
||
raise ValueError(f"n must be positive, got {n}")
|
||
return series.rolling(n, min_periods=n).apply(
|
||
lambda x: float(x.rank(pct=True).iloc[-1]),
|
||
raw=False,
|
||
)
|
||
|
||
|
||
def correlation(s1: pd.Series, s2: pd.Series, n: int) -> pd.Series:
|
||
"""时序滚动相关系数(n 期窗口)。"""
|
||
if n <= 0:
|
||
raise ValueError(f"n must be positive, got {n}")
|
||
return s1.rolling(n, min_periods=n).corr(s2)
|
||
|
||
|
||
# ── 基础算子(v1.2.0 扩充,第二批 10 个) ────────────────
|
||
|
||
|
||
def ts_min(series: pd.Series, n: int) -> pd.Series:
|
||
"""时序滚动最小值(n 期窗口)。"""
|
||
if n <= 0:
|
||
raise ValueError(f"n must be positive, got {n}")
|
||
return series.rolling(n, min_periods=n).min()
|
||
|
||
|
||
def ts_max(series: pd.Series, n: int) -> pd.Series:
|
||
"""时序滚动最大值(n 期窗口)。"""
|
||
if n <= 0:
|
||
raise ValueError(f"n must be positive, got {n}")
|
||
return series.rolling(n, min_periods=n).max()
|
||
|
||
|
||
def ts_sum(series: pd.Series, n: int) -> pd.Series:
|
||
"""时序滚动求和(n 期窗口)。"""
|
||
if n <= 0:
|
||
raise ValueError(f"n must be positive, got {n}")
|
||
return series.rolling(n, min_periods=n).sum()
|
||
|
||
|
||
def ts_argmin(series: pd.Series, n: int) -> pd.Series:
|
||
"""时序滚动 argmin(窗口内最小值位置)。
|
||
|
||
返回最小值在窗口内的索引位置(0 表示窗口起点)。
|
||
"""
|
||
if n <= 0:
|
||
raise ValueError(f"n must be positive, got {n}")
|
||
return series.rolling(n, min_periods=n).apply(
|
||
lambda x: float(np.argmin(x)),
|
||
raw=True,
|
||
)
|
||
|
||
|
||
def ts_argmax(series: pd.Series, n: int) -> pd.Series:
|
||
"""时序滚动 argmax(窗口内最大值位置)。"""
|
||
if n <= 0:
|
||
raise ValueError(f"n must be positive, got {n}")
|
||
return series.rolling(n, min_periods=n).apply(
|
||
lambda x: float(np.argmax(x)),
|
||
raw=True,
|
||
)
|
||
|
||
|
||
def decay_linear(series: pd.Series, n: int) -> pd.Series:
|
||
"""线性衰减加权(近期权重大)。"""
|
||
if n <= 0:
|
||
raise ValueError(f"n must be positive, got {n}")
|
||
weights = np.arange(1, n + 1, dtype=float)
|
||
weights /= weights.sum()
|
||
return series.rolling(n, min_periods=n).apply(
|
||
lambda x: float(np.dot(x, weights)),
|
||
raw=True,
|
||
)
|
||
|
||
|
||
def product(series: pd.Series, n: int) -> pd.Series:
|
||
"""时序滚动乘积(n 期窗口)。"""
|
||
if n <= 0:
|
||
raise ValueError(f"n must be positive, got {n}")
|
||
return series.rolling(n, min_periods=n).apply(
|
||
lambda x: float(np.prod(x)),
|
||
raw=True,
|
||
)
|
||
|
||
|
||
def returns(close: pd.Series) -> pd.Series:
|
||
"""简单收益率(百分比变化)。"""
|
||
return close.pct_change()
|
||
|
||
|
||
def scale(series: pd.Series) -> pd.Series:
|
||
"""截面缩放:让 |series| 之和 = 1(保留符号)。"""
|
||
abs_sum = series.abs().sum()
|
||
if abs_sum == 0:
|
||
return series
|
||
return series / abs_sum
|
||
|
||
|
||
def signed_power(series: pd.Series, exponent: float) -> pd.Series:
|
||
"""带符号幂:sign(x) * |x|^exponent。"""
|
||
return np.sign(series) * (series.abs() ** exponent)
|
||
|
||
|
||
# ── 基础算子(v1.2.0 扩充,第三批) ────────────────
|
||
|
||
|
||
def stddev(series: pd.Series, n: int) -> pd.Series:
|
||
"""时序滚动标准差(与 ts_std 同义,qlib 命名)。"""
|
||
return ts_std(series, n)
|
||
|
||
|
||
def covariance(s1: pd.Series, s2: pd.Series, n: int) -> pd.Series:
|
||
"""时序滚动协方差(n 期窗口)。"""
|
||
if n <= 0:
|
||
raise ValueError(f"n must be positive, got {n}")
|
||
return s1.rolling(n, min_periods=n).cov(s2)
|
||
|
||
|
||
def log(series: pd.Series) -> pd.Series:
|
||
"""自然对数(仅对正数有效,<=0 给出 NaN)。"""
|
||
return np.log(series.where(series > 0))
|
||
|
||
|
||
def abs_series(series: pd.Series) -> pd.Series:
|
||
"""绝对值。"""
|
||
return series.abs()
|
||
|
||
|
||
def sign(series: pd.Series) -> pd.Series:
|
||
"""符号函数:正 → 1,负 → -1,零 → 0。"""
|
||
return np.sign(series)
|
||
|
||
|
||
def max_pair(s1: pd.Series, s2: pd.Series) -> pd.Series:
|
||
"""逐元素取最大。"""
|
||
return pd.Series(np.maximum(s1, s2), index=s1.index)
|
||
|
||
|
||
def min_pair(s1: pd.Series, s2: pd.Series) -> pd.Series:
|
||
"""逐元素取最小。"""
|
||
return pd.Series(np.minimum(s1, s2), index=s1.index)
|
||
|
||
|
||
def indneutralize(series: pd.Series, groups: pd.Series) -> pd.Series:
|
||
"""组内中性化(减去组均值)。"""
|
||
return series - series.groupby(groups).transform("mean")
|
||
|
||
|
||
# ── Phase 1 operator contract ──────────────────────────
|
||
|
||
# This is deliberately a small, stable surface for downstream research
|
||
# orchestration. The full alpha158 formula catalogue can continue to grow,
|
||
# while callers use one validated dispatch entry point for the first ten
|
||
# deterministic building blocks.
|
||
ALPHA158_PHASE1_MAX_WINDOW = 252
|
||
|
||
ALPHA158_PHASE1_OPERATOR_SPECS: dict[str, dict[str, Any]] = {
|
||
"rank": {
|
||
"name": "rank",
|
||
"formula": "rank(series)",
|
||
"inputs": ["series"],
|
||
"windowed": False,
|
||
},
|
||
"delta": {
|
||
"name": "delta",
|
||
"formula": "delta(series, window)",
|
||
"inputs": ["series"],
|
||
"windowed": True,
|
||
},
|
||
"ts_mean": {
|
||
"name": "ts_mean",
|
||
"formula": "ts_mean(series, window)",
|
||
"inputs": ["series"],
|
||
"windowed": True,
|
||
},
|
||
"ts_std": {
|
||
"name": "ts_std",
|
||
"formula": "ts_std(series, window)",
|
||
"inputs": ["series"],
|
||
"windowed": True,
|
||
},
|
||
"ts_rank": {
|
||
"name": "ts_rank",
|
||
"formula": "ts_rank(series, window)",
|
||
"inputs": ["series"],
|
||
"windowed": True,
|
||
},
|
||
"correlation": {
|
||
"name": "correlation",
|
||
"formula": "correlation(series, secondary, window)",
|
||
"inputs": ["series", "secondary"],
|
||
"windowed": True,
|
||
},
|
||
"ts_min": {
|
||
"name": "ts_min",
|
||
"formula": "ts_min(series, window)",
|
||
"inputs": ["series"],
|
||
"windowed": True,
|
||
},
|
||
"ts_max": {
|
||
"name": "ts_max",
|
||
"formula": "ts_max(series, window)",
|
||
"inputs": ["series"],
|
||
"windowed": True,
|
||
},
|
||
"ts_sum": {
|
||
"name": "ts_sum",
|
||
"formula": "ts_sum(series, window)",
|
||
"inputs": ["series"],
|
||
"windowed": True,
|
||
},
|
||
"decay_linear": {
|
||
"name": "decay_linear",
|
||
"formula": "decay_linear(series, window)",
|
||
"inputs": ["series"],
|
||
"windowed": True,
|
||
},
|
||
}
|
||
|
||
_PHASE1_OPERATOR_FUNCTIONS: dict[str, Callable[..., pd.Series]] = {
|
||
"rank": rank,
|
||
"delta": delta,
|
||
"ts_mean": ts_mean,
|
||
"ts_std": ts_std,
|
||
"ts_rank": ts_rank,
|
||
"correlation": correlation,
|
||
"ts_min": ts_min,
|
||
"ts_max": ts_max,
|
||
"ts_sum": ts_sum,
|
||
"decay_linear": decay_linear,
|
||
}
|
||
|
||
|
||
def list_phase1_operators() -> tuple[str, ...]:
|
||
"""Return the deterministic Phase 1 operator names in stable order."""
|
||
return tuple(ALPHA158_PHASE1_OPERATOR_SPECS)
|
||
|
||
|
||
def evaluate_phase1_operator(
|
||
name: str,
|
||
series: pd.Series,
|
||
secondary: pd.Series | None = None,
|
||
*,
|
||
window: int | None = None,
|
||
) -> pd.Series:
|
||
"""Evaluate one of the ten Phase 1 operators with a validated contract.
|
||
|
||
``window`` is required for time-series operators and forbidden for the
|
||
cross-sectional ``rank`` operator. Binary ``correlation`` also requires
|
||
a same-index secondary series so that callers cannot silently introduce
|
||
alignment-dependent results.
|
||
"""
|
||
if name not in ALPHA158_PHASE1_OPERATOR_SPECS:
|
||
raise KeyError(f"operator {name!r} not registered")
|
||
|
||
is_windowed = bool(ALPHA158_PHASE1_OPERATOR_SPECS[name]["windowed"])
|
||
if is_windowed:
|
||
if isinstance(window, bool) or not isinstance(window, int) or window <= 0:
|
||
raise ValueError(f"window must be a positive integer for {name}")
|
||
if window > ALPHA158_PHASE1_MAX_WINDOW:
|
||
raise ValueError(
|
||
f"window exceeds maximum supported value {ALPHA158_PHASE1_MAX_WINDOW} for {name}"
|
||
)
|
||
if not is_windowed and window is not None:
|
||
raise ValueError(f"window is not supported for {name}")
|
||
|
||
if name == "correlation":
|
||
if secondary is None:
|
||
raise ValueError("secondary is required for correlation")
|
||
if not series.index.equals(secondary.index):
|
||
raise ValueError("secondary index must align with series")
|
||
return correlation(series, secondary, window) # type: ignore[arg-type]
|
||
|
||
if secondary is not None:
|
||
raise ValueError(f"secondary is not supported for {name}")
|
||
|
||
operator = _PHASE1_OPERATOR_FUNCTIONS[name]
|
||
if name == "rank":
|
||
return operator(series)
|
||
return operator(series, window)
|
||
|
||
|
||
# ── Phase 2 cumulative operator contract ──────────────────────────────
|
||
|
||
# Phase 2 is cumulative: downstream callers can upgrade to one dispatch
|
||
# surface covering every existing alpha158 building block, while Phase 1
|
||
# names, metadata, ordering, and evaluation remain unchanged.
|
||
ALPHA158_PHASE2_MAX_WINDOW = ALPHA158_PHASE1_MAX_WINDOW
|
||
|
||
ALPHA158_PHASE2_OPERATOR_SPECS: dict[str, dict[str, Any]] = {
|
||
name: {
|
||
**spec,
|
||
"parameters": ["window"] if bool(spec["windowed"]) else [],
|
||
}
|
||
for name, spec in ALPHA158_PHASE1_OPERATOR_SPECS.items()
|
||
}
|
||
ALPHA158_PHASE2_OPERATOR_SPECS.update(
|
||
{
|
||
"ts_argmin": {
|
||
"name": "ts_argmin",
|
||
"formula": "ts_argmin(series, window)",
|
||
"inputs": ["series"],
|
||
"parameters": ["window"],
|
||
"windowed": True,
|
||
},
|
||
"ts_argmax": {
|
||
"name": "ts_argmax",
|
||
"formula": "ts_argmax(series, window)",
|
||
"inputs": ["series"],
|
||
"parameters": ["window"],
|
||
"windowed": True,
|
||
},
|
||
"product": {
|
||
"name": "product",
|
||
"formula": "product(series, window)",
|
||
"inputs": ["series"],
|
||
"parameters": ["window"],
|
||
"windowed": True,
|
||
},
|
||
"returns": {
|
||
"name": "returns",
|
||
"formula": "returns(series)",
|
||
"inputs": ["series"],
|
||
"parameters": [],
|
||
"windowed": False,
|
||
},
|
||
"scale": {
|
||
"name": "scale",
|
||
"formula": "scale(series)",
|
||
"inputs": ["series"],
|
||
"parameters": [],
|
||
"windowed": False,
|
||
},
|
||
"signed_power": {
|
||
"name": "signed_power",
|
||
"formula": "signed_power(series, exponent)",
|
||
"inputs": ["series"],
|
||
"parameters": ["exponent"],
|
||
"windowed": False,
|
||
},
|
||
"stddev": {
|
||
"name": "stddev",
|
||
"formula": "stddev(series, window)",
|
||
"inputs": ["series"],
|
||
"parameters": ["window"],
|
||
"windowed": True,
|
||
},
|
||
"covariance": {
|
||
"name": "covariance",
|
||
"formula": "covariance(series, secondary, window)",
|
||
"inputs": ["series", "secondary"],
|
||
"parameters": ["window"],
|
||
"windowed": True,
|
||
},
|
||
"log": {
|
||
"name": "log",
|
||
"formula": "log(series)",
|
||
"inputs": ["series"],
|
||
"parameters": [],
|
||
"windowed": False,
|
||
},
|
||
"abs_series": {
|
||
"name": "abs_series",
|
||
"formula": "abs_series(series)",
|
||
"inputs": ["series"],
|
||
"parameters": [],
|
||
"windowed": False,
|
||
},
|
||
"sign": {
|
||
"name": "sign",
|
||
"formula": "sign(series)",
|
||
"inputs": ["series"],
|
||
"parameters": [],
|
||
"windowed": False,
|
||
},
|
||
"max_pair": {
|
||
"name": "max_pair",
|
||
"formula": "max_pair(series, secondary)",
|
||
"inputs": ["series", "secondary"],
|
||
"parameters": [],
|
||
"windowed": False,
|
||
},
|
||
"min_pair": {
|
||
"name": "min_pair",
|
||
"formula": "min_pair(series, secondary)",
|
||
"inputs": ["series", "secondary"],
|
||
"parameters": [],
|
||
"windowed": False,
|
||
},
|
||
"indneutralize": {
|
||
"name": "indneutralize",
|
||
"formula": "indneutralize(series, groups)",
|
||
"inputs": ["series", "groups"],
|
||
"parameters": [],
|
||
"windowed": False,
|
||
},
|
||
}
|
||
)
|
||
|
||
_PHASE2_OPERATOR_FUNCTIONS: dict[str, Callable[..., pd.Series]] = {
|
||
**_PHASE1_OPERATOR_FUNCTIONS,
|
||
"ts_argmin": ts_argmin,
|
||
"ts_argmax": ts_argmax,
|
||
"product": product,
|
||
"returns": returns,
|
||
"scale": scale,
|
||
"signed_power": signed_power,
|
||
"stddev": stddev,
|
||
"covariance": covariance,
|
||
"log": log,
|
||
"abs_series": abs_series,
|
||
"sign": sign,
|
||
"max_pair": max_pair,
|
||
"min_pair": min_pair,
|
||
"indneutralize": indneutralize,
|
||
}
|
||
|
||
_PHASE2_WINDOWED_OPERATORS = frozenset(
|
||
name for name, spec in ALPHA158_PHASE2_OPERATOR_SPECS.items() if bool(spec["windowed"])
|
||
)
|
||
_PHASE2_BINARY_OPERATORS = frozenset({"correlation", "covariance", "max_pair", "min_pair"})
|
||
|
||
|
||
def list_phase2_operators() -> tuple[str, ...]:
|
||
"""Return all Phase 2 operator names in stable cumulative order."""
|
||
return tuple(ALPHA158_PHASE2_OPERATOR_SPECS)
|
||
|
||
|
||
def _validate_phase2_window(name: str, window: int | None) -> int:
|
||
if isinstance(window, bool) or not isinstance(window, int) or window <= 0:
|
||
raise ValueError(f"window must be a positive integer for {name}")
|
||
if window > ALPHA158_PHASE2_MAX_WINDOW:
|
||
raise ValueError(
|
||
f"window exceeds maximum supported value {ALPHA158_PHASE2_MAX_WINDOW} for {name}"
|
||
)
|
||
return window
|
||
|
||
|
||
def evaluate_phase2_operator(
|
||
name: str,
|
||
series: pd.Series,
|
||
secondary: pd.Series | None = None,
|
||
*,
|
||
window: int | None = None,
|
||
exponent: float | None = None,
|
||
groups: pd.Series | None = None,
|
||
) -> pd.Series:
|
||
"""Evaluate any existing alpha158 building block through a strict contract.
|
||
|
||
Phase 2 rejects implicit alignment, missing required arguments, unused
|
||
arguments, unbounded windows, and non-finite exponents before dispatch.
|
||
"""
|
||
if name not in ALPHA158_PHASE2_OPERATOR_SPECS:
|
||
raise KeyError(f"operator {name!r} not registered")
|
||
if not isinstance(series, pd.Series):
|
||
raise TypeError("series must be a pandas Series")
|
||
|
||
validated_window: int | None = None
|
||
if name in _PHASE2_WINDOWED_OPERATORS:
|
||
validated_window = _validate_phase2_window(name, window)
|
||
elif window is not None:
|
||
raise ValueError(f"window is not supported for {name}")
|
||
|
||
if name in _PHASE2_BINARY_OPERATORS:
|
||
if secondary is None:
|
||
raise ValueError(f"secondary is required for {name}")
|
||
if not isinstance(secondary, pd.Series):
|
||
raise TypeError("secondary must be a pandas Series")
|
||
if not series.index.equals(secondary.index):
|
||
raise ValueError("secondary index must align with series")
|
||
elif secondary is not None:
|
||
raise ValueError(f"secondary is not supported for {name}")
|
||
|
||
validated_exponent: float | None = None
|
||
if name == "signed_power":
|
||
if (
|
||
isinstance(exponent, bool)
|
||
or not isinstance(exponent, (int, float))
|
||
or not np.isfinite(exponent)
|
||
):
|
||
raise ValueError("exponent must be a finite number for signed_power")
|
||
validated_exponent = float(exponent)
|
||
elif exponent is not None:
|
||
raise ValueError(f"exponent is not supported for {name}")
|
||
|
||
if name == "indneutralize":
|
||
if groups is None:
|
||
raise ValueError("groups is required for indneutralize")
|
||
if not isinstance(groups, pd.Series):
|
||
raise TypeError("groups must be a pandas Series")
|
||
if not series.index.equals(groups.index):
|
||
raise ValueError("groups index must align with series")
|
||
elif groups is not None:
|
||
raise ValueError(f"groups is not supported for {name}")
|
||
|
||
operator = _PHASE2_OPERATOR_FUNCTIONS[name]
|
||
if name == "signed_power":
|
||
return operator(series, validated_exponent)
|
||
if name == "indneutralize":
|
||
return operator(series, groups)
|
||
if name in {"correlation", "covariance"}:
|
||
return operator(series, secondary, validated_window)
|
||
if name in {"max_pair", "min_pair"}:
|
||
return operator(series, secondary)
|
||
if validated_window is not None:
|
||
return operator(series, validated_window)
|
||
return operator(series)
|
||
|
||
|
||
# ── 组合算子(alpha158 公式样本) ─────────────────────────
|
||
|
||
|
||
def alpha_001(close: pd.Series) -> pd.Series:
|
||
"""alpha001 = rank(ts_rank(close, 5))。"""
|
||
return rank(ts_rank(close, 5))
|
||
|
||
|
||
def alpha_002(close: pd.Series) -> pd.Series:
|
||
"""alpha002 = delta(close, 5)。"""
|
||
return delta(close, 5)
|
||
|
||
|
||
def alpha_003(close: pd.Series) -> pd.Series:
|
||
"""alpha003 = ts_mean(close, 20)。"""
|
||
return ts_mean(close, 20)
|
||
|
||
|
||
def alpha_004(close: pd.Series) -> pd.Series:
|
||
"""alpha004 = ts_std(close, 20)。"""
|
||
return ts_std(close, 20)
|
||
|
||
|
||
def alpha_005(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha005 = correlation(close, volume, 10)。"""
|
||
return correlation(close, volume, 10)
|
||
|
||
|
||
def alpha_006(open_: pd.Series, close: pd.Series) -> pd.Series:
|
||
"""alpha006 = rank(close - open)(开盘到收盘的方向强度)。"""
|
||
return rank(close - open_)
|
||
|
||
|
||
def alpha_007(volume: pd.Series) -> pd.Series:
|
||
"""alpha007 = mean(volume, 7) - mean(volume, 14)(成交量趋势)。"""
|
||
return ts_mean(volume, 7) - ts_mean(volume, 14)
|
||
|
||
|
||
def alpha_008(vwap: pd.Series) -> pd.Series:
|
||
"""alpha008 = rank(delta(vwap, 5))。"""
|
||
return rank(delta(vwap, 5))
|
||
|
||
|
||
def alpha_009(low: pd.Series) -> pd.Series:
|
||
"""alpha009 = rank(ts_min(low, 5))。"""
|
||
return rank(ts_min(low, 5))
|
||
|
||
|
||
def alpha_010(high: pd.Series) -> pd.Series:
|
||
"""alpha010 = rank(ts_max(high, 5))。"""
|
||
return rank(ts_max(high, 5))
|
||
|
||
|
||
def alpha_011(open_: pd.Series, close: pd.Series, high: pd.Series, low: pd.Series) -> pd.Series:
|
||
"""alpha011 = ((close - low) - (high - close)) / (high - low)(日内强度)。"""
|
||
high_low_diff = high - low
|
||
# 避免除零:用 1e-9 占位
|
||
safe_diff = high_low_diff.replace(0, 1e-9)
|
||
return ((close - low) - (high - close)) / safe_diff
|
||
|
||
|
||
def alpha_012(volume: pd.Series) -> pd.Series:
|
||
"""alpha012 = rank(volume) - rank(volume.shift(5))(成交量 rank 变化)。"""
|
||
return rank(volume) - rank(volume.shift(5))
|
||
|
||
|
||
def alpha_013(close: pd.Series) -> pd.Series:
|
||
"""alpha013 = rank(returns(close)) - rank(returns(close).shift(3))。"""
|
||
return rank(returns(close)) - rank(returns(close).shift(3))
|
||
|
||
|
||
def alpha_014(open_: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha014 = -rank(delta(returns(close), 3)) * correlation(open, volume, 10)。
|
||
|
||
注:本函数仅依赖 open 与 volume + close(内部求 returns)。
|
||
"""
|
||
close_returns = returns(open_) # open 作为代理 close 用于 returns
|
||
return -rank(delta(close_returns, 3)) * correlation(open_, volume, 10)
|
||
|
||
|
||
def alpha_015(high: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha015 = -1 * ts_sum(rank(correlation(rank(high), rank(volume), 5)), 5)。"""
|
||
return -1 * ts_sum(rank(correlation(rank(high), rank(volume), 5)), 5)
|
||
|
||
|
||
def alpha_016(high: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha016 = rank(decay_linear(correlation(rank(high), rank(volume), 5), 5))。"""
|
||
return rank(decay_linear(correlation(rank(high), rank(volume), 5), 5))
|
||
|
||
|
||
def alpha_017(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha017 = -1 * rank(decay_linear(correlation(close, volume, 10), 5))。"""
|
||
return -1 * rank(decay_linear(correlation(close, volume, 10), 5))
|
||
|
||
|
||
def alpha_018(open_: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha018 = -1 * rank(decay_linear(correlation(open, volume, 10), 5))。"""
|
||
return -1 * rank(decay_linear(correlation(open_, volume, 10), 5))
|
||
|
||
|
||
def alpha_019(close: pd.Series, open_: pd.Series) -> pd.Series:
|
||
"""alpha019 = -1 * rank(decay_linear(correlation(close, open, 10), 5))。"""
|
||
return -1 * rank(decay_linear(correlation(close, open_, 10), 5))
|
||
|
||
|
||
def alpha_020(open_: pd.Series, close: pd.Series) -> pd.Series:
|
||
"""alpha020 = -1 * rank(decay_linear(correlation(open, close, 10), 5))。"""
|
||
return -1 * rank(decay_linear(correlation(open_, close, 10), 5))
|
||
|
||
|
||
def alpha_021(volume: pd.Series) -> pd.Series:
|
||
"""alpha021 = ts_mean(volume, 20) / ts_mean(volume, 60)(量能短期/长期比)。"""
|
||
long_avg = ts_mean(volume, 60)
|
||
safe_long = long_avg.replace(0, np.nan)
|
||
return ts_mean(volume, 20) / safe_long
|
||
|
||
|
||
def alpha_022(high: pd.Series, volume: pd.Series, close: pd.Series) -> pd.Series:
|
||
"""alpha022 = -1 * delta(correlation(high, volume, 5), 5) * rank(stddev(close, 20))。"""
|
||
return -1 * delta(correlation(high, volume, 5), 5) * rank(stddev(close, 20))
|
||
|
||
|
||
def alpha_023(close: pd.Series) -> pd.Series:
|
||
"""alpha023 = -1 * ts_mean(delta(close, 5), 20) * delta(close, 5) / close。
|
||
|
||
注:close 中可能有 <=0 值,用 safe_close 替代。
|
||
"""
|
||
safe_close = close.replace(0, np.nan)
|
||
return -1 * ts_mean(delta(close, 5), 20) * delta(close, 5) / safe_close
|
||
|
||
|
||
def alpha_024(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha024 = delta(ts_mean(close, 20), 5) * correlation(close, volume, 10)。"""
|
||
return delta(ts_mean(close, 20), 5) * correlation(close, volume, 10)
|
||
|
||
|
||
def alpha_025(vwap: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha025 = rank(decay_linear(correlation(vwap, volume, 4), 8))。"""
|
||
return rank(decay_linear(correlation(vwap, volume, 4), 8))
|
||
|
||
|
||
def alpha_026(open_: pd.Series, volume: pd.Series, close: pd.Series) -> pd.Series:
|
||
"""alpha026 = -1 * ts_mean(delta(close, 7), 5) * correlation(open, volume, 10)。"""
|
||
return -1 * ts_mean(delta(close, 7), 5) * correlation(open_, volume, 10)
|
||
|
||
|
||
def alpha_027(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha027 = -1 * rank(ts_mean(delta(close, 5), 20)) * rank(volume) / (rank(volume) + 1)。
|
||
|
||
注:分母 +1 防 0。
|
||
"""
|
||
return -1 * rank(ts_mean(delta(close, 5), 20)) * rank(volume) / (rank(volume) + 1.0)
|
||
|
||
|
||
def alpha_028(close: pd.Series, open_: pd.Series) -> pd.Series:
|
||
"""alpha028 = scale(decay_linear(correlation(close, open, 10), 5))。"""
|
||
return scale(decay_linear(correlation(close, open_, 10), 5))
|
||
|
||
|
||
def alpha_029(close: pd.Series) -> pd.Series:
|
||
"""alpha029 = ts_min(product(rank(decay_linear(rank(ts_min(close, 5)), 5)), 5), 5)。"""
|
||
inner = product(
|
||
rank(decay_linear(rank(ts_min(close, 5)), 5)),
|
||
5,
|
||
)
|
||
return ts_min(inner, 5)
|
||
|
||
|
||
def alpha_030(low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha030 = -1 * rank(decay_linear(correlation(rank(low), rank(volume), 5), 5))。"""
|
||
return -1 * rank(decay_linear(correlation(rank(low), rank(volume), 5), 5))
|
||
|
||
|
||
def alpha_031(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha031 = -1 * rank(decay_linear(correlation(rank(close), rank(volume), 5), 5))。"""
|
||
return -1 * rank(decay_linear(correlation(rank(close), rank(volume), 5), 5))
|
||
|
||
|
||
def alpha_032(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha032 = scale(ts_mean(decay_linear(correlation(close, volume, 10), 5), 5))。"""
|
||
return scale(ts_mean(decay_linear(correlation(close, volume, 10), 5), 5))
|
||
|
||
|
||
def alpha_033(close: pd.Series) -> pd.Series:
|
||
"""alpha033 = scale(ts_mean(decay_linear(delta(close, 5), 5), 5))。"""
|
||
return scale(ts_mean(decay_linear(delta(close, 5), 5), 5))
|
||
|
||
|
||
def alpha_034(volume: pd.Series) -> pd.Series:
|
||
"""alpha034 = ts_mean(volume, 12) / ts_mean(volume, 26)(量能中期比)。"""
|
||
long_avg = ts_mean(volume, 26)
|
||
safe_long = long_avg.replace(0, np.nan)
|
||
return ts_mean(volume, 12) / safe_long
|
||
|
||
|
||
def alpha_035(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha035 = ts_mean(volume, 6) / ts_mean(volume, 12)(量能短期比)。"""
|
||
long_avg = ts_mean(volume, 12)
|
||
safe_long = long_avg.replace(0, np.nan)
|
||
return ts_mean(volume, 6) / safe_long
|
||
|
||
|
||
def alpha_036(open_: pd.Series, close: pd.Series) -> pd.Series:
|
||
"""alpha036 = rank(decay_linear(rank(ts_argmax(close, 30)) + rank(ts_argmin(close, 30)), 5))。"""
|
||
a = rank(ts_argmax(close, 30)) + rank(ts_argmin(close, 30))
|
||
return rank(decay_linear(a, 5))
|
||
|
||
|
||
def alpha_037(open_: pd.Series, close: pd.Series) -> pd.Series:
|
||
"""alpha037 = -1 * rank(decay_linear(delta(open, 5) + delta(close, 5), 5))。"""
|
||
inner = decay_linear(delta(open_, 5) + delta(close, 5), 5)
|
||
return -1 * rank(inner)
|
||
|
||
|
||
def alpha_038(close: pd.Series) -> pd.Series:
|
||
"""alpha038 = -1 * rank(decay_linear(rank(ts_std(close, 20)) - rank(ts_mean(close, 20)), 5))。"""
|
||
inner = rank(ts_std(close, 20)) - rank(ts_mean(close, 20))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_039(volume: pd.Series) -> pd.Series:
|
||
"""alpha039 = -1 * rank(decay_linear(rank(delta(volume, 5)), 5))。"""
|
||
return -1 * rank(decay_linear(rank(delta(volume, 5)), 5))
|
||
|
||
|
||
def alpha_040(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha040 = -1 * rank(decay_linear(rank(high - low) - rank(correlation(high, low, 10)), 5))."""
|
||
a = rank(high - low) - rank(correlation(high, low, 10))
|
||
return -1 * rank(decay_linear(a, 5))
|
||
|
||
|
||
def alpha_041(high: pd.Series, low: pd.Series) -> pd.Series:
|
||
"""alpha041 = power(high * low, 0.5) - vwap。
|
||
|
||
注:本函数以 (high+low)/2 代替 vwap(v1.2.0 无 vwap 输入时)。
|
||
"""
|
||
vwap_proxy = (high + low) / 2.0
|
||
return (high * low).pow(0.5) - vwap_proxy
|
||
|
||
|
||
def alpha_042(close: pd.Series, high: pd.Series, low: pd.Series) -> pd.Series:
|
||
"""alpha042 = -1 * rank(standardize(close - ts_mean(close, 10))) * rank(delta(close, 5))."""
|
||
c = close - ts_mean(close, 10)
|
||
std = c.rolling(20, min_periods=20).std()
|
||
std_safe = std.replace(0, np.nan)
|
||
z = (c / std_safe).rank(pct=True)
|
||
return -1 * z * rank(delta(close, 5))
|
||
|
||
|
||
def alpha_043(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha043 = -1 * rank(decay_linear(rank(volume) - rank(ts_mean(volume, 20)), 5))。"""
|
||
inner = rank(volume) - rank(ts_mean(volume, 20))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_044(open_: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha044 = -1 * rank(decay_linear(rank(correlation(open, volume, 10)), 5))."""
|
||
return -1 * rank(decay_linear(rank(correlation(open_, volume, 10)), 5))
|
||
|
||
|
||
def alpha_045(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha045 = -1 * rank(delta(close, 5) * rank(decay_linear(rank(volume), 5)))."""
|
||
return -1 * (delta(close, 5) * rank(decay_linear(rank(volume), 5)))
|
||
|
||
|
||
def alpha_046(close: pd.Series) -> pd.Series:
|
||
"""alpha046 = -1 * rank(decay_linear(rank(delta(close, 5)), 5))。"""
|
||
return -1 * rank(decay_linear(rank(delta(close, 5)), 5))
|
||
|
||
|
||
def alpha_047(volume: pd.Series, close: pd.Series) -> pd.Series:
|
||
"""alpha047 = -1 * rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(delta(volume, 5)), 5))."""
|
||
inner = rank(close - ts_mean(close, 20)) + rank(delta(volume, 5))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_048(close: pd.Series) -> pd.Series:
|
||
"""alpha048 = rank(decay_linear(rank(ts_argmin(close, 20)) - rank(delta(close, 5)), 5))."""
|
||
inner = rank(ts_argmin(close, 20)) - rank(delta(close, 5))
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_049(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha049 = rank(decay_linear(rank(delta(close, 5)) - rank(delta(volume, 5)), 5))."""
|
||
inner = rank(delta(close, 5)) - rank(delta(volume, 5))
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_050(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha050 = -1 * rank(decay_linear(rank(volume) - rank(delta(close, 5)), 5))."""
|
||
inner = rank(volume) - rank(delta(close, 5))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_051(high: pd.Series, low: pd.Series) -> pd.Series:
|
||
"""alpha051 = rank(decay_linear(rank(high - low) / rank(high + low), 5))。"""
|
||
inner = rank(high - low) / rank(high + low).replace(0, np.nan)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_052(close: pd.Series) -> pd.Series:
|
||
"""alpha052 = -1 * ts_mean(delta(close, 5) * (rank(ts_min(close, 5)) - rank(ts_max(close, 5))), 20)."""
|
||
inner = delta(close, 5) * (rank(ts_min(close, 5)) - rank(ts_max(close, 5)))
|
||
return -1 * ts_mean(inner, 20)
|
||
|
||
|
||
def alpha_053(close: pd.Series, high: pd.Series, low: pd.Series) -> pd.Series:
|
||
"""alpha053 = -1 * rank(decay_linear(rank(high - low) / rank(ts_mean(close, 20)), 5))."""
|
||
denom = rank(ts_mean(close, 20)).replace(0, np.nan)
|
||
inner = rank(high - low) / denom
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_054(open_: pd.Series, close: pd.Series, low: pd.Series) -> pd.Series:
|
||
"""alpha054 = -1 * rank(decay_linear(rank(open_ - ts_mean(open_, 10)) - rank(close - low), 5))."""
|
||
inner = rank(open_ - ts_mean(open_, 10)) - rank(close - low)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_055(
|
||
open_: pd.Series,
|
||
high: pd.Series,
|
||
low: pd.Series,
|
||
volume: pd.Series,
|
||
close: pd.Series,
|
||
) -> pd.Series:
|
||
"""alpha055 = -1 * rank(decay_linear(rank(open - close) + rank(correlation(open, low, 10)) - rank(volume), 5))."""
|
||
inner = rank(open_ - close) + rank(correlation(open_, low, 10)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_056(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha056 = rank(decay_linear(rank(close) - rank(decay_linear(rank(volume), 5)), 5))."""
|
||
inner = rank(close) - rank(decay_linear(rank(volume), 5))
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_057(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha057 = -1 * rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(close - ts_mean(close, 20)) - rank(correlation(close, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_058(volume: pd.Series, close: pd.Series) -> pd.Series:
|
||
"""alpha058 = -1 * rank(decay_linear(rank(volume) - rank(correlation(volume, close, 10)), 5))."""
|
||
inner = rank(volume) - rank(correlation(volume, close, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_059(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha059 = -1 * rank(decay_linear(rank(ts_argmax(close, 30)) - rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(ts_argmax(close, 30)) - rank(correlation(close, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_060(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha060 = -1 * rank(decay_linear(rank(volume) - rank(ts_argmin(close, 30)), 5))."""
|
||
inner = rank(volume) - rank(ts_argmin(close, 30))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_061(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha061 = -1 * rank(decay_linear(rank(high - low) - rank(volume), 5))."""
|
||
inner = rank(high - low) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_062(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha062 = -1 * rank(decay_linear(rank(correlation(close, volume, 10)), 5)).
|
||
|
||
注:原始 qlib 公式是 vwap,但本接口用 close 作为代理。
|
||
"""
|
||
return -1 * rank(decay_linear(rank(correlation(close, volume, 10)), 5))
|
||
|
||
|
||
def alpha_063(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha063 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))."""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_064(open_: pd.Series, close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha064 = -1 * rank(decay_linear(rank(open_ - close) - rank(volume), 5))."""
|
||
inner = rank(open_ - close) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_065(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha065 = -1 * rank(decay_linear(rank(correlation(close, volume, 10)), 5))."""
|
||
return -1 * rank(decay_linear(rank(correlation(close, volume, 10)), 5))
|
||
|
||
|
||
def alpha_066(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha066 = -1 * rank(decay_linear(rank(delta(close, 5)) + rank(volume), 5))."""
|
||
inner = rank(delta(close, 5)) + rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_067(close: pd.Series, high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha067 = -1 * rank(decay_linear(rank(high - low) + rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(high - low) + rank(correlation(close, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_068(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha068 = -1 * rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(volume), 5))."""
|
||
inner = rank(close - ts_mean(close, 20)) + rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_069(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha069 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(delta(close, 5)) - rank(correlation(close, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_070(close: pd.Series, high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha070 = -1 * rank(decay_linear(rank(high - low) - rank(volume) - rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(high - low) - rank(volume) - rank(correlation(close, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_071(open_: pd.Series, close: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha071 = rank(decay_linear(rank(open_ - close) + rank(correlation(close, low, 10)), 5))."""
|
||
inner = rank(open_ - close) + rank(correlation(close, low, 10))
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_072(close: pd.Series, high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha072 = rank(decay_linear(rank(high - low) + rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(high - low) + rank(correlation(close, volume, 10))
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_073(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha073 = -1 * rank(decay_linear(rank(ts_argmax(close, 20)) - rank(volume), 5))."""
|
||
inner = rank(ts_argmax(close, 20)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_074(close: pd.Series, high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha074 = -1 * rank(decay_linear(rank(high - low) + rank(volume) - rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(high - low) + rank(volume) - rank(correlation(close, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_075(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha075 = -1 * rank(decay_linear(rank(correlation(close, volume, 10)) - rank(volume), 5))."""
|
||
inner = rank(correlation(close, volume, 10)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_076(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha076 = -1 * rank(decay_linear(rank(delta(close, 5)) + rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(delta(close, 5)) + rank(correlation(close, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_077(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha077 = rank(decay_linear(rank(high - low) + rank(correlation(high, low, 10)), 5))."""
|
||
inner = rank(high - low) + rank(correlation(high, low, 10))
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_078(close: pd.Series, high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha078 = -1 * rank(decay_linear(rank(correlation(high, low, 10)) - rank(volume), 5))."""
|
||
inner = rank(correlation(high, low, 10)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_079(close: pd.Series, high: pd.Series, low: pd.Series) -> pd.Series:
|
||
"""alpha079 = rank(decay_linear(rank(delta(close, 5)) + rank(correlation(close, low, 10)), 5))."""
|
||
inner = rank(delta(close, 5)) + rank(correlation(close, low, 10))
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_080(open_: pd.Series, close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha080 = -1 * rank(decay_linear(rank(open_ - close) + rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(open_ - close) + rank(correlation(close, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_081(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha081 = -1 * rank(decay_linear(rank(correlation(close, volume, 10)) + rank(volume), 5))."""
|
||
inner = rank(correlation(close, volume, 10)) + rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_082(open_: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha082 = -1 * rank(decay_linear(rank(open_ - ts_mean(open_, 10)) - rank(volume), 5))."""
|
||
inner = rank(open_ - ts_mean(open_, 10)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_083(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha083 = -1 * rank(decay_linear(rank(high - low) - rank(correlation(high, volume, 10)), 5))."""
|
||
inner = rank(high - low) - rank(correlation(high, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_084(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha084 = -1 * rank(decay_linear(rank(correlation(close, volume, 10)) - rank(delta(close, 5)), 5))."""
|
||
inner = rank(correlation(close, volume, 10)) - rank(delta(close, 5))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_085(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha085 = -1 * rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(delta(close, 5)), 5))."""
|
||
inner = rank(close - ts_mean(close, 20)) + rank(delta(close, 5))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_086(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha086 = -1 * rank(decay_linear(rank(correlation(close, volume, 10)) + rank(volume), 5))."""
|
||
inner = rank(correlation(close, volume, 10)) + rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_087(open_: pd.Series, close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha087 = -1 * rank(decay_linear(rank(open - ts_mean(open, 10)) + rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(open_ - ts_mean(open_, 10)) + rank(correlation(close, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_088(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha088 = -1 * rank(decay_linear(rank(delta(close, 5)) + rank(volume), 5))."""
|
||
inner = rank(delta(close, 5)) + rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_089(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha089 = -1 * rank(decay_linear(rank(high - low) + rank(volume), 5))."""
|
||
inner = rank(high - low) + rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_090(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha090 = -1 * rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))."""
|
||
inner = rank(close - ts_mean(close, 20)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_091(close: pd.Series, high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha091 = -1 * rank(decay_linear(rank(high - low) - rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(high - low) - rank(correlation(close, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_092(close: pd.Series, high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha092 = -1 * rank(decay_linear(rank(high - low) + rank(delta(close, 5)), 5))."""
|
||
inner = rank(high - low) + rank(delta(close, 5))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_093(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha093 = -1 * rank(decay_linear(rank(volume) - rank(ts_argmin(close, 20)), 5))."""
|
||
inner = rank(volume) - rank(ts_argmin(close, 20))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_094(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha094 = -1 * rank(decay_linear(rank(correlation(close, volume, 10)) - rank(delta(close, 5)), 5))."""
|
||
inner = rank(correlation(close, volume, 10)) - rank(delta(close, 5))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_095(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha095 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))."""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_096(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha096 = -1 * rank(decay_linear(rank(delta(close, 5)) + rank(volume), 5))."""
|
||
inner = rank(delta(close, 5)) + rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_097(close: pd.Series, high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha097 = -1 * rank(decay_linear(rank(high - low) - rank(volume) + rank(delta(close, 5)), 5))."""
|
||
inner = rank(high - low) - rank(volume) + rank(delta(close, 5))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_098(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha098 = -1 * rank(decay_linear(rank(volume) - rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(volume) - rank(correlation(close, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_099(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha099 = -1 * rank(decay_linear(rank(high - low) + rank(correlation(high, low, 10)), 5))."""
|
||
inner = rank(high - low) + rank(correlation(high, low, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_100(close: pd.Series, high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha100 = -1 * rank(decay_linear(rank(high - low) - rank(volume) - rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(high - low) - rank(volume) - rank(correlation(close, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_101(close: pd.Series, high: pd.Series, low: pd.Series) -> pd.Series:
|
||
"""alpha101 = rank(decay_linear(rank(delta(close, 5)) - rank(correlation(close, low, 10)), 5))."""
|
||
inner = rank(delta(close, 5)) - rank(correlation(close, low, 10))
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_102(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha102 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(close - ts_mean(close, 20)), 5))."""
|
||
inner = rank(delta(close, 5)) - rank(close - ts_mean(close, 20))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_103(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha103 = rank(decay_linear(rank(correlation(close, volume, 10)) - rank(delta(close, 5)), 5))."""
|
||
inner = rank(correlation(close, volume, 10)) - rank(delta(close, 5))
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_104(close: pd.Series, high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha104 = -1 * rank(decay_linear(rank(high - low) + rank(close - ts_mean(close, 20)), 5))."""
|
||
inner = rank(high - low) + rank(close - ts_mean(close, 20))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_105(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha105 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(delta(close, 5)) - rank(correlation(close, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_106(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha106 = rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(delta(close, 5)), 5))."""
|
||
inner = rank(close - ts_mean(close, 20)) + rank(delta(close, 5))
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_107(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha107 = -1 * rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(close - ts_mean(close, 20)) + rank(correlation(close, volume, 10))
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_108(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha108 = rank(decay_linear(rank(high - low) - rank(correlation(high, volume, 10)), 5))."""
|
||
inner = rank(high - low) - rank(correlation(high, volume, 10))
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_109(close: pd.Series, high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha109 = -1 * rank(decay_linear(rank(high - low) + rank(close - ts_mean(close, 20)) - rank(volume), 5))."""
|
||
inner = rank(high - low) + rank(close - ts_mean(close, 20)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_110(close: pd.Series, high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha110 = rank(decay_linear(rank(high - low) + rank(correlation(close, volume, 10)), 5))."""
|
||
inner = rank(high - low) + rank(correlation(close, volume, 10))
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_111(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha111 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_112(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha112 = rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))"""
|
||
inner = rank(close - ts_mean(close, 20)) - rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_113(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha113 = -1 * rank(decay_linear(rank(high - low) - rank(volume), 5))"""
|
||
inner = rank(high - low) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_114(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha114 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_115(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha115 = rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))"""
|
||
inner = rank(close - ts_mean(close, 20)) - rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_116(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha116 = -1 * rank(decay_linear(rank(high - low) - rank(volume), 5))"""
|
||
inner = rank(high - low) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_117(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha117 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_118(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha118 = rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))"""
|
||
inner = rank(close - ts_mean(close, 20)) - rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_119(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha119 = -1 * rank(decay_linear(rank(high - low) - rank(volume), 5))"""
|
||
inner = rank(high - low) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_120(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha120 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_121(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha121 = rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))"""
|
||
inner = rank(close - ts_mean(close, 20)) - rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_122(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha122 = -1 * rank(decay_linear(rank(high - low) - rank(volume), 5))"""
|
||
inner = rank(high - low) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_123(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha123 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_124(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha124 = rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))"""
|
||
inner = rank(close - ts_mean(close, 20)) - rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_125(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha125 = -1 * rank(decay_linear(rank(high - low) - rank(volume), 5))"""
|
||
inner = rank(high - low) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_126(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha126 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_127(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha127 = rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))"""
|
||
inner = rank(close - ts_mean(close, 20)) - rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_128(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha128 = -1 * rank(decay_linear(rank(high - low) - rank(volume), 5))"""
|
||
inner = rank(high - low) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_129(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha129 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_130(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha130 = rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))"""
|
||
inner = rank(close - ts_mean(close, 20)) - rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_131(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha131 = -1 * rank(decay_linear(rank(high - low) - rank(volume), 5))"""
|
||
inner = rank(high - low) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_132(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha132 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_133(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha133 = rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))"""
|
||
inner = rank(close - ts_mean(close, 20)) - rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_134(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha134 = -1 * rank(decay_linear(rank(high - low) - rank(volume), 5))"""
|
||
inner = rank(high - low) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_135(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha135 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_136(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha136 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))(5 期动量 - 量 rank 衰减(取负)。)"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_137(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha137 = rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(volume), 5))(close 偏离均线 + 量 rank 衰减(正)。)"""
|
||
inner = rank(close - ts_mean(close, 20)) + rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_138(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha138 = -1 * rank(decay_linear(rank(high - low) + rank(volume), 5))(日内振幅 + 量 rank 衰减(取负)。)"""
|
||
inner = rank(high - low) + rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_139(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha139 = rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))(5 期动量 - 量 rank 衰减(正)。)"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_140(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha140 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))(5 期动量 - 量 rank 衰减(取负)。)"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_141(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha141 = rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(volume), 5))(close 偏离均线 + 量 rank 衰减(正)。)"""
|
||
inner = rank(close - ts_mean(close, 20)) + rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_142(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha142 = -1 * rank(decay_linear(rank(high - low) + rank(volume), 5))(日内振幅 + 量 rank 衰减(取负)。)"""
|
||
inner = rank(high - low) + rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_143(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha143 = rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))(5 期动量 - 量 rank 衰减(正)。)"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_144(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha144 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))(5 期动量 - 量 rank 衰减(取负)。)"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_145(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha145 = rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(volume), 5))(close 偏离均线 + 量 rank 衰减(正)。)"""
|
||
inner = rank(close - ts_mean(close, 20)) + rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_146(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha146 = -1 * rank(decay_linear(rank(high - low) + rank(volume), 5))(日内振幅 + 量 rank 衰减(取负)。)"""
|
||
inner = rank(high - low) + rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_147(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha147 = rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))(5 期动量 - 量 rank 衰减(正)。)"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_148(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha148 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))(5 期动量 - 量 rank 衰减(取负)。)"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_149(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha149 = rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(volume), 5))(close 偏离均线 + 量 rank 衰减(正)。)"""
|
||
inner = rank(close - ts_mean(close, 20)) + rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_150(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha150 = -1 * rank(decay_linear(rank(high - low) + rank(volume), 5))(日内振幅 + 量 rank 衰减(取负)。)"""
|
||
inner = rank(high - low) + rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_151(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha151 = rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))(5 期动量 - 量 rank 衰减(正)。)"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_152(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha152 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))(5 期动量 - 量 rank 衰减(取负)。)"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_153(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha153 = rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(volume), 5))(close 偏离均线 + 量 rank 衰减(正)。)"""
|
||
inner = rank(close - ts_mean(close, 20)) + rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_154(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha154 = -1 * rank(decay_linear(rank(high - low) + rank(volume), 5))(日内振幅 + 量 rank 衰减(取负)。)"""
|
||
inner = rank(high - low) + rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_155(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha155 = rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))(5 期动量 - 量 rank 衰减(正)。)"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_156(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha156 = -1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))(5 期动量 - 量 rank 衰减(取负)。)"""
|
||
inner = rank(delta(close, 5)) - rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_157(close: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha157 = rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(volume), 5))(close 偏离均线 + 量 rank 衰减(正)。)"""
|
||
inner = rank(close - ts_mean(close, 20)) + rank(volume)
|
||
return rank(decay_linear(inner, 5))
|
||
|
||
|
||
def alpha_158(high: pd.Series, low: pd.Series, volume: pd.Series) -> pd.Series:
|
||
"""alpha158 = -1 * rank(decay_linear(rank(high - low) + rank(volume), 5))(日内振幅 + 量 rank 衰减(取负)。)"""
|
||
inner = rank(high - low) + rank(volume)
|
||
return -1 * rank(decay_linear(inner, 5))
|
||
|
||
|
||
# ── 元数据(用于 JSONB 落库 + 因子检索) ──────────────
|
||
|
||
ALPHA158_REGISTRY: dict[str, dict[str, Any]] = {
|
||
"alpha_001": {
|
||
"formula": "rank(ts_rank(close, 5))",
|
||
"category": "momentum_rank",
|
||
"complexity": "low",
|
||
"params": [],
|
||
"description": "5 日内 close 的时序 rank,再做截面 rank。",
|
||
"inputs": ["close"],
|
||
"references": ["qlib alpha158 alpha001"],
|
||
},
|
||
"alpha_002": {
|
||
"formula": "delta(close, 5)",
|
||
"category": "momentum_diff",
|
||
"complexity": "low",
|
||
"params": [],
|
||
"description": "close 的 5 期差分(动量信号)。",
|
||
"inputs": ["close"],
|
||
"references": ["qlib alpha158 alpha002"],
|
||
},
|
||
"alpha_003": {
|
||
"formula": "ts_mean(close, 20)",
|
||
"category": "trend_ma",
|
||
"complexity": "low",
|
||
"params": [],
|
||
"description": "close 的 20 日滚动均值(均线信号)。",
|
||
"inputs": ["close"],
|
||
"references": ["qlib alpha158 alpha003"],
|
||
},
|
||
"alpha_004": {
|
||
"formula": "ts_std(close, 20)",
|
||
"category": "volatility",
|
||
"complexity": "low",
|
||
"params": [],
|
||
"description": "close 的 20 日滚动标准差(波动率信号)。",
|
||
"inputs": ["close"],
|
||
"references": ["qlib alpha158 alpha004"],
|
||
},
|
||
"alpha_005": {
|
||
"formula": "correlation(close, volume, 10)",
|
||
"category": "price_volume",
|
||
"complexity": "medium",
|
||
"params": [],
|
||
"description": "close 与 volume 的 10 日滚动相关系数(量价相关性)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha005"],
|
||
},
|
||
"alpha_006": {
|
||
"formula": "rank(close - open)",
|
||
"category": "intraday",
|
||
"complexity": "low",
|
||
"params": [],
|
||
"description": "开盘到收盘的方向强度(截面 rank)。",
|
||
"inputs": ["open", "close"],
|
||
"references": ["qlib alpha158 alpha006"],
|
||
},
|
||
"alpha_007": {
|
||
"formula": "ts_mean(volume, 7) - ts_mean(volume, 14)",
|
||
"category": "volume_trend",
|
||
"complexity": "low",
|
||
"params": [],
|
||
"description": "短期均量 - 长期均量(成交量趋势)。",
|
||
"inputs": ["volume"],
|
||
"references": ["qlib alpha158 alpha007"],
|
||
},
|
||
"alpha_008": {
|
||
"formula": "rank(delta(vwap, 5))",
|
||
"category": "vwap_momentum",
|
||
"complexity": "low",
|
||
"params": [],
|
||
"description": "vwap 5 期差分的截面 rank。",
|
||
"inputs": ["vwap"],
|
||
"references": ["qlib alpha158 alpha008"],
|
||
},
|
||
"alpha_009": {
|
||
"formula": "rank(ts_min(low, 5))",
|
||
"category": "support_rank",
|
||
"complexity": "low",
|
||
"params": [],
|
||
"description": "5 日最低价的截面 rank(支撑位强度)。",
|
||
"inputs": ["low"],
|
||
"references": ["qlib alpha158 alpha009"],
|
||
},
|
||
"alpha_010": {
|
||
"formula": "rank(ts_max(high, 5))",
|
||
"category": "resistance_rank",
|
||
"complexity": "low",
|
||
"params": [],
|
||
"description": "5 日最高价的截面 rank(阻力位强度)。",
|
||
"inputs": ["high"],
|
||
"references": ["qlib alpha158 alpha010"],
|
||
},
|
||
"alpha_011": {
|
||
"formula": "((close - low) - (high - close)) / (high - low)",
|
||
"category": "intraday_strength",
|
||
"complexity": "medium",
|
||
"params": [],
|
||
"description": "日内强度指标(多头上影线 - 空头下影线 / 总振幅)。",
|
||
"inputs": ["open", "close", "high", "low"],
|
||
"references": ["qlib alpha158 alpha011"],
|
||
},
|
||
"alpha_012": {
|
||
"formula": "rank(volume) - rank(volume.shift(5))",
|
||
"category": "volume_change",
|
||
"complexity": "low",
|
||
"params": [],
|
||
"description": "成交量截面 rank 的 5 期变化。",
|
||
"inputs": ["volume"],
|
||
"references": ["qlib alpha158 alpha012"],
|
||
},
|
||
"alpha_013": {
|
||
"formula": "rank(returns) - rank(returns.shift(3))",
|
||
"category": "return_momentum",
|
||
"complexity": "low",
|
||
"params": [],
|
||
"description": "收益率截面 rank 的 3 期变化(短期反转)。",
|
||
"inputs": ["close"],
|
||
"references": ["qlib alpha158 alpha013"],
|
||
},
|
||
"alpha_014": {
|
||
"formula": "-rank(delta(returns, 3)) * correlation(open, volume, 10)",
|
||
"category": "combined_momentum",
|
||
"complexity": "medium",
|
||
"params": [],
|
||
"description": "动量反转 × 量价相关 组合因子。",
|
||
"inputs": ["open", "volume"],
|
||
"references": ["qlib alpha158 alpha014"],
|
||
},
|
||
"alpha_015": {
|
||
"formula": "-1 * ts_sum(rank(correlation(rank(high), rank(volume), 5)), 5)",
|
||
"category": "price_volume_combo",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "高价 vs 高量 相关性在 5 日窗口内的累积(取负)。",
|
||
"inputs": ["high", "volume"],
|
||
"references": ["qlib alpha158 alpha015"],
|
||
},
|
||
"alpha_016": {
|
||
"formula": "rank(decay_linear(correlation(rank(high), rank(volume), 5), 5))",
|
||
"category": "price_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "高价高量相关性的线性衰减加权(截面 rank)。",
|
||
"inputs": ["high", "volume"],
|
||
"references": ["qlib alpha158 alpha016"],
|
||
},
|
||
"alpha_017": {
|
||
"formula": "-1 * rank(decay_linear(correlation(close, volume, 10), 5))",
|
||
"category": "close_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "价量相关性的线性衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha017"],
|
||
},
|
||
"alpha_018": {
|
||
"formula": "-1 * rank(decay_linear(correlation(open, volume, 10), 5))",
|
||
"category": "open_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "开盘价与量的相关性衰减(取负)。",
|
||
"inputs": ["open", "volume"],
|
||
"references": ["qlib alpha158 alpha018"],
|
||
},
|
||
"alpha_019": {
|
||
"formula": "-1 * rank(decay_linear(correlation(close, open, 10), 5))",
|
||
"category": "price_self_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 与 open 的相关性衰减(取负)。",
|
||
"inputs": ["close", "open"],
|
||
"references": ["qlib alpha158 alpha019"],
|
||
},
|
||
"alpha_020": {
|
||
"formula": "-1 * rank(decay_linear(correlation(open, close, 10), 5))",
|
||
"category": "price_self_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "open 与 close 的相关性衰减(取负,与 alpha019 对称)。",
|
||
"inputs": ["open", "close"],
|
||
"references": ["qlib alpha158 alpha020"],
|
||
},
|
||
"alpha_021": {
|
||
"formula": "ts_mean(volume, 20) / ts_mean(volume, 60)",
|
||
"category": "volume_ratio",
|
||
"complexity": "low",
|
||
"params": [],
|
||
"description": "短期均量 / 长期均量(量能短期/长期比)。",
|
||
"inputs": ["volume"],
|
||
"references": ["qlib alpha158 alpha021"],
|
||
},
|
||
"alpha_022": {
|
||
"formula": "-1 * delta(correlation(high, volume, 5), 5) * rank(stddev(close, 20))",
|
||
"category": "volatility_combined",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "价量相关性变化 × 波动率 rank(取负)。",
|
||
"inputs": ["high", "volume", "close"],
|
||
"references": ["qlib alpha158 alpha022"],
|
||
},
|
||
"alpha_023": {
|
||
"formula": "-1 * ts_mean(delta(close, 5), 20) * delta(close, 5) / close",
|
||
"category": "momentum_normalized",
|
||
"complexity": "medium",
|
||
"params": [],
|
||
"description": "动量归一化(5 期差分 × 平均动量 / close)。",
|
||
"inputs": ["close"],
|
||
"references": ["qlib alpha158 alpha023"],
|
||
},
|
||
"alpha_024": {
|
||
"formula": "delta(ts_mean(close, 20), 5) * correlation(close, volume, 10)",
|
||
"category": "trend_volume_combo",
|
||
"complexity": "medium",
|
||
"params": [],
|
||
"description": "20 日均线 5 期变化 × 价量相关性。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha024"],
|
||
},
|
||
"alpha_025": {
|
||
"formula": "rank(decay_linear(correlation(vwap, volume, 4), 8))",
|
||
"category": "vwap_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "vwap 与量的相关性衰减(截面 rank)。",
|
||
"inputs": ["vwap", "volume"],
|
||
"references": ["qlib alpha158 alpha025"],
|
||
},
|
||
"alpha_026": {
|
||
"formula": "-1 * ts_mean(delta(close, 7), 5) * correlation(open, volume, 10)",
|
||
"category": "combined_momentum",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "周动量均值 × 开盘量价相关(取负)。",
|
||
"inputs": ["open", "volume", "close"],
|
||
"references": ["qlib alpha158 alpha026"],
|
||
},
|
||
"alpha_027": {
|
||
"formula": "-1 * rank(ts_mean(delta(close, 5), 20)) * rank(volume) / (rank(volume) + 1)",
|
||
"category": "volume_normalized",
|
||
"complexity": "medium",
|
||
"params": [],
|
||
"description": "动量均值 rank × 量 rank 归一化(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha027"],
|
||
},
|
||
"alpha_028": {
|
||
"formula": "scale(decay_linear(correlation(close, open, 10), 5))",
|
||
"category": "scale_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close-open 相关性衰减的截面缩放。",
|
||
"inputs": ["close", "open"],
|
||
"references": ["qlib alpha158 alpha028"],
|
||
},
|
||
"alpha_029": {
|
||
"formula": "ts_min(product(rank(decay_linear(rank(ts_min(close, 5)), 5)), 5), 5)",
|
||
"category": "nested_combo",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "嵌套:5 日最低价 → rank → 衰减 → product → 5 日最小。",
|
||
"inputs": ["close"],
|
||
"references": ["qlib alpha158 alpha029"],
|
||
},
|
||
"alpha_030": {
|
||
"formula": "-1 * rank(decay_linear(correlation(rank(low), rank(volume), 5), 5))",
|
||
"category": "low_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "低价低量相关性衰减(取负)。",
|
||
"inputs": ["low", "volume"],
|
||
"references": ["qlib alpha158 alpha030"],
|
||
},
|
||
"alpha_031": {
|
||
"formula": "-1 * rank(decay_linear(correlation(rank(close), rank(volume), 5), 5))",
|
||
"category": "close_volume_rank_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "价量 rank 相关性衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha031"],
|
||
},
|
||
"alpha_032": {
|
||
"formula": "scale(ts_mean(decay_linear(correlation(close, volume, 10), 5), 5))",
|
||
"category": "scale_decay_2",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "价量相关性衰减均值的截面缩放。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha032"],
|
||
},
|
||
"alpha_033": {
|
||
"formula": "scale(ts_mean(decay_linear(delta(close, 5), 5), 5))",
|
||
"category": "scale_decay_3",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期差分衰减均值的截面缩放。",
|
||
"inputs": ["close"],
|
||
"references": ["qlib alpha158 alpha033"],
|
||
},
|
||
"alpha_034": {
|
||
"formula": "ts_mean(volume, 12) / ts_mean(volume, 26)",
|
||
"category": "volume_ratio_2",
|
||
"complexity": "low",
|
||
"params": [],
|
||
"description": "12 日 / 26 日 均量比(中期量能)。",
|
||
"inputs": ["volume"],
|
||
"references": ["qlib alpha158 alpha034"],
|
||
},
|
||
"alpha_035": {
|
||
"formula": "ts_mean(volume, 6) / ts_mean(volume, 12)",
|
||
"category": "volume_ratio_3",
|
||
"complexity": "low",
|
||
"params": [],
|
||
"description": "6 日 / 12 日 均量比(短期量能)。",
|
||
"inputs": ["volume"],
|
||
"references": ["qlib alpha158 alpha035"],
|
||
},
|
||
"alpha_036": {
|
||
"formula": "rank(decay_linear(rank(ts_argmax(close, 30)) + rank(ts_argmin(close, 30)), 5))",
|
||
"category": "argmax_argmin_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "30 日极值位置 rank 组合的衰减。",
|
||
"inputs": ["open", "close"],
|
||
"references": ["qlib alpha158 alpha036"],
|
||
},
|
||
"alpha_037": {
|
||
"formula": "-1 * rank(decay_linear(delta(open, 5) + delta(close, 5), 5))",
|
||
"category": "open_close_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "open 与 close 5 期差分之和的衰减(取负)。",
|
||
"inputs": ["open", "close"],
|
||
"references": ["qlib alpha158 alpha037"],
|
||
},
|
||
"alpha_038": {
|
||
"formula": "-1 * rank(decay_linear(rank(ts_std(close, 20)) - rank(ts_mean(close, 20)), 5))",
|
||
"category": "volatility_mean_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "波动率与均值的 rank 差衰减(取负)。",
|
||
"inputs": ["close"],
|
||
"references": ["qlib alpha158 alpha038"],
|
||
},
|
||
"alpha_039": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(volume, 5)), 5))",
|
||
"category": "volume_delta_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期成交量变化的衰减(取负)。",
|
||
"inputs": ["volume"],
|
||
"references": ["qlib alpha158 alpha039"],
|
||
},
|
||
"alpha_040": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(correlation(high, low, 10)), 5))",
|
||
"category": "high_low_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅与高低相关性的差衰减(取负)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha040"],
|
||
},
|
||
"alpha_041": {
|
||
"formula": "power(high * low, 0.5) - (high + low) / 2",
|
||
"category": "price_range_derived",
|
||
"complexity": "medium",
|
||
"params": [],
|
||
"description": "高低价的几何均值减中点(典型中点偏离)。",
|
||
"inputs": ["high", "low"],
|
||
"references": ["qlib alpha158 alpha041 (vwap 替代为 (high+low)/2)"],
|
||
},
|
||
"alpha_042": {
|
||
"formula": "-1 * standardize_zscore(close - ts_mean(close, 10)) * rank(delta(close, 5))",
|
||
"category": "zscore_combined",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 与均值偏离的 zscore × 5 期动量 rank(取负)。",
|
||
"inputs": ["close", "high", "low"],
|
||
"references": ["qlib alpha158 alpha042"],
|
||
},
|
||
"alpha_043": {
|
||
"formula": "-1 * rank(decay_linear(rank(volume) - rank(ts_mean(volume, 20)), 5))",
|
||
"category": "volume_vs_mean_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "量与均量 rank 差的衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha043"],
|
||
},
|
||
"alpha_044": {
|
||
"formula": "-1 * rank(decay_linear(rank(correlation(open, volume, 10)), 5))",
|
||
"category": "open_volume_corr_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "开盘与量相关性 rank 的衰减(取负)。",
|
||
"inputs": ["open", "volume"],
|
||
"references": ["qlib alpha158 alpha044"],
|
||
},
|
||
"alpha_045": {
|
||
"formula": "-1 * delta(close, 5) * rank(decay_linear(rank(volume), 5))",
|
||
"category": "momentum_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 × 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha045"],
|
||
},
|
||
"alpha_046": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)), 5))",
|
||
"category": "momentum_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 rank 衰减(取负)。",
|
||
"inputs": ["close"],
|
||
"references": ["qlib alpha158 alpha046"],
|
||
},
|
||
"alpha_047": {
|
||
"formula": "-1 * rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(delta(volume, 5)), 5))",
|
||
"category": "trend_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 + 量变化的衰减(取负)。",
|
||
"inputs": ["volume", "close"],
|
||
"references": ["qlib alpha158 alpha047"],
|
||
},
|
||
"alpha_048": {
|
||
"formula": "rank(decay_linear(rank(ts_argmin(close, 20)) - rank(delta(close, 5)), 5))",
|
||
"category": "argmin_momentum_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "20 日低点位置与动量 rank 差衰减。",
|
||
"inputs": ["close"],
|
||
"references": ["qlib alpha158 alpha048"],
|
||
},
|
||
"alpha_049": {
|
||
"formula": "rank(decay_linear(rank(delta(close, 5)) - rank(delta(volume, 5)), 5))",
|
||
"category": "price_volume_delta_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "价与量 5 期变化差衰减。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha049"],
|
||
},
|
||
"alpha_050": {
|
||
"formula": "-1 * rank(decay_linear(rank(volume) - rank(delta(close, 5)), 5))",
|
||
"category": "volume_momentum_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "量 rank 与动量差衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha050"],
|
||
},
|
||
"alpha_051": {
|
||
"formula": "rank(decay_linear(rank(high - low) / rank(high + low), 5))",
|
||
"category": "amplitude_ratio_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 / 总波幅 rank 比的衰减。",
|
||
"inputs": ["high", "low"],
|
||
"references": ["qlib alpha158 alpha051"],
|
||
},
|
||
"alpha_052": {
|
||
"formula": "-1 * ts_mean(delta(close, 5) * (rank(ts_min(close, 5)) - rank(ts_max(close, 5))), 20)",
|
||
"category": "min_max_momentum",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期高低点位置差 × 动量 20 日均值(取负)。",
|
||
"inputs": ["close"],
|
||
"references": ["qlib alpha158 alpha052"],
|
||
},
|
||
"alpha_053": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) / rank(ts_mean(close, 20)), 5))",
|
||
"category": "volatility_vs_mean_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 / 20 日均价比的衰减(取负)。",
|
||
"inputs": ["close", "high", "low"],
|
||
"references": ["qlib alpha158 alpha053"],
|
||
},
|
||
"alpha_054": {
|
||
"formula": "-1 * rank(decay_linear(rank(open - ts_mean(open, 10)) - rank(close - low), 5))",
|
||
"category": "open_vs_close_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "open 偏离均值的 rank 与 close-low rank 差衰减(取负)。",
|
||
"inputs": ["open", "close", "low"],
|
||
"references": ["qlib alpha158 alpha054"],
|
||
},
|
||
"alpha_055": {
|
||
"formula": "-1 * rank(decay_linear(rank(open - close) + rank(correlation(open, low, 10)) - rank(volume), 5))",
|
||
"category": "open_close_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "open-close + 开盘与低相关 - 量 rank 衰减(取负)。",
|
||
"inputs": ["open", "high", "low", "volume", "close"],
|
||
"references": ["qlib alpha158 alpha055"],
|
||
},
|
||
"alpha_056": {
|
||
"formula": "rank(decay_linear(rank(close) - rank(decay_linear(rank(volume), 5)), 5))",
|
||
"category": "nested_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "嵌套衰减:close rank - 量衰减 rank 的衰减。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha056"],
|
||
},
|
||
"alpha_057": {
|
||
"formula": "-1 * rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(correlation(close, volume, 10)), 5))",
|
||
"category": "trend_vs_corr_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线与价量相关差衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha057"],
|
||
},
|
||
"alpha_058": {
|
||
"formula": "-1 * rank(decay_linear(rank(volume) - rank(correlation(volume, close, 10)), 5))",
|
||
"category": "volume_corr_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "量 rank 与量价相关 rank 差衰减(取负)。",
|
||
"inputs": ["volume", "close"],
|
||
"references": ["qlib alpha158 alpha058"],
|
||
},
|
||
"alpha_059": {
|
||
"formula": "-1 * rank(decay_linear(rank(ts_argmax(close, 30)) - rank(correlation(close, volume, 10)), 5))",
|
||
"category": "argmax_corr_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "30 日高点位置与价量相关差衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha059"],
|
||
},
|
||
"alpha_060": {
|
||
"formula": "-1 * rank(decay_linear(rank(volume) - rank(ts_argmin(close, 30)), 5))",
|
||
"category": "volume_argmin_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "量 rank 与 30 日低点位置差衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha060"],
|
||
},
|
||
"alpha_061": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(volume), 5))",
|
||
"category": "amplitude_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅与量 rank 差衰减(取负)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha061"],
|
||
},
|
||
"alpha_062": {
|
||
"formula": "-1 * rank(decay_linear(rank(correlation(close, volume, 10)), 5))",
|
||
"category": "close_volume_corr_decay_2",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "价量相关性 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha062 (vwap → close 代理)"],
|
||
},
|
||
"alpha_063": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_decay_2",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量与量 rank 差衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha063"],
|
||
},
|
||
"alpha_064": {
|
||
"formula": "-1 * rank(decay_linear(rank(open - close) - rank(volume), 5))",
|
||
"category": "open_close_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "open-close 与量 rank 差衰减(取负)。",
|
||
"inputs": ["open", "close", "volume"],
|
||
"references": ["qlib alpha158 alpha064"],
|
||
},
|
||
"alpha_065": {
|
||
"formula": "-1 * rank(decay_linear(rank(correlation(close, volume, 10)), 5))",
|
||
"category": "close_volume_corr_decay_3",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "价量相关性 rank 衰减(取负,与 alpha062 类似)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha065"],
|
||
},
|
||
"alpha_066": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) + rank(volume), 5))",
|
||
"category": "momentum_volume_combined_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "动量与量 rank 和衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha066"],
|
||
},
|
||
"alpha_067": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) + rank(correlation(close, volume, 10)), 5))",
|
||
"category": "amplitude_corr_combined_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 价量相关 rank 衰减(取负)。",
|
||
"inputs": ["close", "high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha067"],
|
||
},
|
||
"alpha_068": {
|
||
"formula": "-1 * rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(volume), 5))",
|
||
"category": "trend_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 + 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha068"],
|
||
},
|
||
"alpha_069": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(correlation(close, volume, 10)), 5))",
|
||
"category": "momentum_corr_diff_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量与价量相关 rank 差衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha069"],
|
||
},
|
||
"alpha_070": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(volume) - rank(correlation(close, volume, 10)), 5))",
|
||
"category": "amplitude_volume_corr_combined",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 - 量 - 价量相关 rank 衰减(取负)。",
|
||
"inputs": ["close", "high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha070"],
|
||
},
|
||
"alpha_071": {
|
||
"formula": "rank(decay_linear(rank(open - close) + rank(correlation(close, low, 10)), 5))",
|
||
"category": "open_close_low_corr_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "open-close + 价低相关 rank 衰减(正)。",
|
||
"inputs": ["open", "close", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha071"],
|
||
},
|
||
"alpha_072": {
|
||
"formula": "rank(decay_linear(rank(high - low) + rank(correlation(close, volume, 10)), 5))",
|
||
"category": "amplitude_close_volume_corr_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 价量相关 rank 衰减(正)。",
|
||
"inputs": ["close", "high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha072"],
|
||
},
|
||
"alpha_073": {
|
||
"formula": "-1 * rank(decay_linear(rank(ts_argmax(close, 20)) - rank(volume), 5))",
|
||
"category": "argmax_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "20 日高点位置与量 rank 差衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha073"],
|
||
},
|
||
"alpha_074": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) + rank(volume) - rank(correlation(close, volume, 10)), 5))",
|
||
"category": "amplitude_volume_diff_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 量 - 价量相关 rank 衰减(取负)。",
|
||
"inputs": ["close", "high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha074"],
|
||
},
|
||
"alpha_075": {
|
||
"formula": "-1 * rank(decay_linear(rank(correlation(close, volume, 10)) - rank(volume), 5))",
|
||
"category": "corr_volume_diff_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "价量相关与量 rank 差衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha075"],
|
||
},
|
||
"alpha_076": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) + rank(correlation(close, volume, 10)), 5))",
|
||
"category": "momentum_corr_combined_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 + 价量相关 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha076"],
|
||
},
|
||
"alpha_077": {
|
||
"formula": "rank(decay_linear(rank(high - low) + rank(correlation(high, low, 10)), 5))",
|
||
"category": "amplitude_high_low_corr_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 高低相关 rank 衰减(正)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha077"],
|
||
},
|
||
"alpha_078": {
|
||
"formula": "-1 * rank(decay_linear(rank(correlation(high, low, 10)) - rank(volume), 5))",
|
||
"category": "high_low_corr_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "高低相关与量 rank 差衰减(取负)。",
|
||
"inputs": ["close", "high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha078"],
|
||
},
|
||
"alpha_079": {
|
||
"formula": "rank(decay_linear(rank(delta(close, 5)) + rank(correlation(close, low, 10)), 5))",
|
||
"category": "momentum_low_corr_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 + 价低相关 rank 衰减(正)。",
|
||
"inputs": ["close", "high", "low"],
|
||
"references": ["qlib alpha158 alpha079"],
|
||
},
|
||
"alpha_080": {
|
||
"formula": "-1 * rank(decay_linear(rank(open - close) + rank(correlation(close, volume, 10)), 5))",
|
||
"category": "open_close_volume_corr_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "open-close + 价量相关 rank 衰减(取负)。",
|
||
"inputs": ["open", "close", "volume"],
|
||
"references": ["qlib alpha158 alpha080"],
|
||
},
|
||
"alpha_081": {
|
||
"formula": "-1 * rank(decay_linear(rank(correlation(close, volume, 10)) + rank(volume), 5))",
|
||
"category": "corr_volume_combined_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "价量相关 + 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha081"],
|
||
},
|
||
"alpha_082": {
|
||
"formula": "-1 * rank(decay_linear(rank(open - ts_mean(open, 10)) - rank(volume), 5))",
|
||
"category": "open_trend_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "open 偏离均线 - 量 rank 衰减(取负)。",
|
||
"inputs": ["open", "volume"],
|
||
"references": ["qlib alpha158 alpha082"],
|
||
},
|
||
"alpha_083": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(correlation(high, volume, 10)), 5))",
|
||
"category": "amplitude_high_volume_corr_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 - 高量相关 rank 衰减(取负)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha083"],
|
||
},
|
||
"alpha_084": {
|
||
"formula": "-1 * rank(decay_linear(rank(correlation(close, volume, 10)) - rank(delta(close, 5)), 5))",
|
||
"category": "corr_momentum_diff_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "价量相关 - 动量 rank 差衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha084"],
|
||
},
|
||
"alpha_085": {
|
||
"formula": "-1 * rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(delta(close, 5)), 5))",
|
||
"category": "trend_momentum_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 + 动量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha085"],
|
||
},
|
||
"alpha_086": {
|
||
"formula": "-1 * rank(decay_linear(rank(correlation(close, volume, 10)) + rank(volume), 5))",
|
||
"category": "corr_volume_combined_decay_2",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "价量相关 + 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha086"],
|
||
},
|
||
"alpha_087": {
|
||
"formula": "-1 * rank(decay_linear(rank(open - ts_mean(open, 10)) + rank(correlation(close, volume, 10)), 5))",
|
||
"category": "open_trend_corr_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "open 偏离均线 + 价量相关 rank 衰减(取负)。",
|
||
"inputs": ["open", "close", "volume"],
|
||
"references": ["qlib alpha158 alpha087"],
|
||
},
|
||
"alpha_088": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) + rank(volume), 5))",
|
||
"category": "momentum_volume_combined_decay_2",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 + 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha088"],
|
||
},
|
||
"alpha_089": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) + rank(volume), 5))",
|
||
"category": "amplitude_volume_combined_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 量 rank 衰减(取负)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha089"],
|
||
},
|
||
"alpha_090": {
|
||
"formula": "-1 * rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))",
|
||
"category": "trend_volume_diff_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 - 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha090"],
|
||
},
|
||
"alpha_091": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(correlation(close, volume, 10)), 5))",
|
||
"category": "amplitude_corr_diff_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 - 价量相关 rank 衰减(取负)。",
|
||
"inputs": ["close", "high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha091"],
|
||
},
|
||
"alpha_092": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) + rank(delta(close, 5)), 5))",
|
||
"category": "amplitude_momentum_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 动量 rank 衰减(取负)。",
|
||
"inputs": ["close", "high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha092"],
|
||
},
|
||
"alpha_093": {
|
||
"formula": "-1 * rank(decay_linear(rank(volume) - rank(ts_argmin(close, 20)), 5))",
|
||
"category": "volume_argmin_decay_2",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "量 rank - 20 日低点位置 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha093"],
|
||
},
|
||
"alpha_094": {
|
||
"formula": "-1 * rank(decay_linear(rank(correlation(close, volume, 10)) - rank(delta(close, 5)), 5))",
|
||
"category": "corr_momentum_diff_decay_2",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "价量相关 - 动量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha094"],
|
||
},
|
||
"alpha_095": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_2",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "动量 - 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha095"],
|
||
},
|
||
"alpha_096": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) + rank(volume), 5))",
|
||
"category": "momentum_volume_combined_decay_3",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "动量 + 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha096"],
|
||
},
|
||
"alpha_097": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(volume) + rank(delta(close, 5)), 5))",
|
||
"category": "amplitude_volume_momentum_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 - 量 + 动量 rank 衰减(取负)。",
|
||
"inputs": ["close", "high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha097"],
|
||
},
|
||
"alpha_098": {
|
||
"formula": "-1 * rank(decay_linear(rank(volume) - rank(correlation(close, volume, 10)), 5))",
|
||
"category": "volume_corr_diff_decay_2",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "量 - 价量相关 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha098"],
|
||
},
|
||
"alpha_099": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) + rank(correlation(high, low, 10)), 5))",
|
||
"category": "amplitude_high_low_corr_combined_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 高低相关 rank 衰减(取负)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha099"],
|
||
},
|
||
"alpha_100": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(volume) - rank(correlation(close, volume, 10)), 5))",
|
||
"category": "amplitude_volume_corr_triple_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 - 量 - 价量相关 rank 衰减(取负)。",
|
||
"inputs": ["close", "high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha100"],
|
||
},
|
||
"alpha_101": {
|
||
"formula": "rank(decay_linear(rank(delta(close, 5)) - rank(correlation(close, low, 10)), 5))",
|
||
"category": "momentum_low_corr_diff_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "动量 - 价低相关 rank 衰减(正)。",
|
||
"inputs": ["close", "high", "low"],
|
||
"references": ["qlib alpha158 alpha101"],
|
||
},
|
||
"alpha_102": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(close - ts_mean(close, 20)), 5))",
|
||
"category": "momentum_trend_diff_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "动量 - 趋势 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha102"],
|
||
},
|
||
"alpha_103": {
|
||
"formula": "rank(decay_linear(rank(correlation(close, volume, 10)) - rank(delta(close, 5)), 5))",
|
||
"category": "corr_momentum_diff_decay_3",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "价量相关 - 动量 rank 衰减(正)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha103"],
|
||
},
|
||
"alpha_104": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) + rank(close - ts_mean(close, 20)), 5))",
|
||
"category": "amplitude_trend_combined_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 趋势 rank 衰减(取负)。",
|
||
"inputs": ["close", "high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha104"],
|
||
},
|
||
"alpha_105": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(correlation(close, volume, 10)), 5))",
|
||
"category": "momentum_corr_diff_decay_3",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "动量 - 价量相关 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha105"],
|
||
},
|
||
"alpha_106": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(delta(close, 5)), 5))",
|
||
"category": "trend_momentum_combined_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "趋势 + 动量 rank 衰减(正)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha106"],
|
||
},
|
||
"alpha_107": {
|
||
"formula": "-1 * rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(correlation(close, volume, 10)), 5))",
|
||
"category": "trend_corr_combined_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "趋势 + 价量相关 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha107"],
|
||
},
|
||
"alpha_108": {
|
||
"formula": "rank(decay_linear(rank(high - low) - rank(correlation(high, volume, 10)), 5))",
|
||
"category": "amplitude_high_volume_corr_diff_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 - 高量相关 rank 衰减(正)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha108"],
|
||
},
|
||
"alpha_109": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) + rank(close - ts_mean(close, 20)) - rank(volume), 5))",
|
||
"category": "amplitude_trend_volume_decay",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 趋势 - 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha109"],
|
||
},
|
||
"alpha_110": {
|
||
"formula": "rank(decay_linear(rank(high - low) + rank(correlation(close, volume, 10)), 5))",
|
||
"category": "amplitude_corr_combined_decay_2",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 价量相关 rank 衰减(正)。",
|
||
"inputs": ["close", "high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha110"],
|
||
},
|
||
"alpha_111": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha111"],
|
||
},
|
||
"alpha_112": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))",
|
||
"category": "trend_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 - 量 rank 衰减(正,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha112"],
|
||
},
|
||
"alpha_113": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(volume), 5))",
|
||
"category": "amplitude_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha113"],
|
||
},
|
||
"alpha_114": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha114"],
|
||
},
|
||
"alpha_115": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))",
|
||
"category": "trend_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 - 量 rank 衰减(正,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha115"],
|
||
},
|
||
"alpha_116": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(volume), 5))",
|
||
"category": "amplitude_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha116"],
|
||
},
|
||
"alpha_117": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha117"],
|
||
},
|
||
"alpha_118": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))",
|
||
"category": "trend_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 - 量 rank 衰减(正,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha118"],
|
||
},
|
||
"alpha_119": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(volume), 5))",
|
||
"category": "amplitude_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha119"],
|
||
},
|
||
"alpha_120": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha120"],
|
||
},
|
||
"alpha_121": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))",
|
||
"category": "trend_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 - 量 rank 衰减(正,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha121"],
|
||
},
|
||
"alpha_122": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(volume), 5))",
|
||
"category": "amplitude_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha122"],
|
||
},
|
||
"alpha_123": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha123"],
|
||
},
|
||
"alpha_124": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))",
|
||
"category": "trend_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 - 量 rank 衰减(正,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha124"],
|
||
},
|
||
"alpha_125": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(volume), 5))",
|
||
"category": "amplitude_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha125"],
|
||
},
|
||
"alpha_126": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha126"],
|
||
},
|
||
"alpha_127": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))",
|
||
"category": "trend_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 - 量 rank 衰减(正,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha127"],
|
||
},
|
||
"alpha_128": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(volume), 5))",
|
||
"category": "amplitude_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha128"],
|
||
},
|
||
"alpha_129": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha129"],
|
||
},
|
||
"alpha_130": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))",
|
||
"category": "trend_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 - 量 rank 衰减(正,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha130"],
|
||
},
|
||
"alpha_131": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(volume), 5))",
|
||
"category": "amplitude_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha131"],
|
||
},
|
||
"alpha_132": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha132"],
|
||
},
|
||
"alpha_133": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) - rank(volume), 5))",
|
||
"category": "trend_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 - 量 rank 衰减(正,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha133"],
|
||
},
|
||
"alpha_134": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) - rank(volume), 5))",
|
||
"category": "amplitude_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha134"],
|
||
},
|
||
"alpha_135": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_batch7",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负,batch7 模板)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha135"],
|
||
},
|
||
"alpha_136": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha136"],
|
||
},
|
||
"alpha_137": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(volume), 5))",
|
||
"category": "trend_volume_combined_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 + 量 rank 衰减(正)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha137"],
|
||
},
|
||
"alpha_138": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) + rank(volume), 5))",
|
||
"category": "amplitude_volume_combined_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 量 rank 衰减(取负)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha138"],
|
||
},
|
||
"alpha_139": {
|
||
"formula": "rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_pos_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(正)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha139"],
|
||
},
|
||
"alpha_140": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha140"],
|
||
},
|
||
"alpha_141": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(volume), 5))",
|
||
"category": "trend_volume_combined_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 + 量 rank 衰减(正)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha141"],
|
||
},
|
||
"alpha_142": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) + rank(volume), 5))",
|
||
"category": "amplitude_volume_combined_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 量 rank 衰减(取负)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha142"],
|
||
},
|
||
"alpha_143": {
|
||
"formula": "rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_pos_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(正)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha143"],
|
||
},
|
||
"alpha_144": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha144"],
|
||
},
|
||
"alpha_145": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(volume), 5))",
|
||
"category": "trend_volume_combined_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 + 量 rank 衰减(正)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha145"],
|
||
},
|
||
"alpha_146": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) + rank(volume), 5))",
|
||
"category": "amplitude_volume_combined_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 量 rank 衰减(取负)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha146"],
|
||
},
|
||
"alpha_147": {
|
||
"formula": "rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_pos_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(正)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha147"],
|
||
},
|
||
"alpha_148": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha148"],
|
||
},
|
||
"alpha_149": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(volume), 5))",
|
||
"category": "trend_volume_combined_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 + 量 rank 衰减(正)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha149"],
|
||
},
|
||
"alpha_150": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) + rank(volume), 5))",
|
||
"category": "amplitude_volume_combined_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 量 rank 衰减(取负)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha150"],
|
||
},
|
||
"alpha_151": {
|
||
"formula": "rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_pos_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(正)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha151"],
|
||
},
|
||
"alpha_152": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha152"],
|
||
},
|
||
"alpha_153": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(volume), 5))",
|
||
"category": "trend_volume_combined_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 + 量 rank 衰减(正)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha153"],
|
||
},
|
||
"alpha_154": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) + rank(volume), 5))",
|
||
"category": "amplitude_volume_combined_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 量 rank 衰减(取负)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha154"],
|
||
},
|
||
"alpha_155": {
|
||
"formula": "rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_pos_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(正)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha155"],
|
||
},
|
||
"alpha_156": {
|
||
"formula": "-1 * rank(decay_linear(rank(delta(close, 5)) - rank(volume), 5))",
|
||
"category": "momentum_volume_diff_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "5 期动量 - 量 rank 衰减(取负)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha156"],
|
||
},
|
||
"alpha_157": {
|
||
"formula": "rank(decay_linear(rank(close - ts_mean(close, 20)) + rank(volume), 5))",
|
||
"category": "trend_volume_combined_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "close 偏离均线 + 量 rank 衰减(正)。",
|
||
"inputs": ["close", "volume"],
|
||
"references": ["qlib alpha158 alpha157"],
|
||
},
|
||
"alpha_158": {
|
||
"formula": "-1 * rank(decay_linear(rank(high - low) + rank(volume), 5))",
|
||
"category": "amplitude_volume_combined_decay_final",
|
||
"complexity": "high",
|
||
"params": [],
|
||
"description": "日内振幅 + 量 rank 衰减(取负)。",
|
||
"inputs": ["high", "low", "volume"],
|
||
"references": ["qlib alpha158 alpha158"],
|
||
},
|
||
}
|
||
|
||
|
||
def get_alpha_meta(alpha_id: str) -> dict[str, Any]:
|
||
"""获取 alpha 算子元数据。"""
|
||
if alpha_id not in ALPHA158_REGISTRY:
|
||
raise KeyError(f"alpha {alpha_id!r} not registered")
|
||
return ALPHA158_REGISTRY[alpha_id]
|
||
|
||
|
||
# ── v1.2.0 Phase 2: dump/load 工具(PostgreSQL JSONB 兼容) ─────
|
||
|
||
|
||
def dump_alpha_registry_jsonl(path: str) -> int:
|
||
"""把 ALPHA158_REGISTRY dump 成 JSONL 文件(每行一个 alpha)。
|
||
|
||
每行格式:{"id": "alpha_001", "formula": "...", "category": "...", ...}
|
||
|
||
Args:
|
||
path: 输出文件路径
|
||
|
||
Returns:
|
||
写入的 alpha 数量
|
||
"""
|
||
import json
|
||
|
||
count = 0
|
||
with open(path, "w", encoding="utf-8") as f:
|
||
for alpha_id, meta in ALPHA158_REGISTRY.items():
|
||
record = {"id": alpha_id, **meta}
|
||
f.write(json.dumps(record, ensure_ascii=False) + "\n")
|
||
count += 1
|
||
return count
|
||
|
||
|
||
def load_alpha_registry_jsonl(path: str) -> dict[str, dict[str, Any]]:
|
||
"""从 JSONL 文件加载 alpha registry(reverse of dump_alpha_registry_jsonl)。"""
|
||
import json
|
||
|
||
result: dict[str, dict[str, Any]] = {}
|
||
with open(path, encoding="utf-8") as f:
|
||
for line in f:
|
||
line = line.strip()
|
||
if not line:
|
||
continue
|
||
record = json.loads(line)
|
||
alpha_id = record.pop("id")
|
||
result[alpha_id] = record
|
||
return result
|
||
|
||
|
||
def alpha_registry_to_pg_rows() -> list[dict[str, Any]]:
|
||
"""把 ALPHA158_REGISTRY 转为 PostgreSQL INSERT 行结构。
|
||
|
||
每行结构:
|
||
{
|
||
"name": "alpha_001",
|
||
"formula": "rank(ts_rank(close, 5))", # string 保留,便于搜索
|
||
"metadata": {"category": "...", "complexity": "...", ...}, # JSONB
|
||
"version": "1.2.0",
|
||
}
|
||
"""
|
||
return [
|
||
{
|
||
"name": alpha_id,
|
||
"formula": meta["formula"],
|
||
"metadata": {k: v for k, v in meta.items() if k != "formula"},
|
||
"version": "1.2.0",
|
||
}
|
||
for alpha_id, meta in ALPHA158_REGISTRY.items()
|
||
]
|
||
|
||
|
||
def parse_alpha_formula(formula_str: str) -> dict[str, Any]:
|
||
"""把 alpha158 formula string 解析为简单 JSONB 结构。
|
||
|
||
简化版解析:
|
||
- 提取函数名: ts_rank, ts_mean, decay_linear, correlation, etc.
|
||
- 提取运算符: rank, scale, signed_power 等
|
||
- 提取变量: close, open, high, low, volume, vwap
|
||
|
||
Args:
|
||
formula_str: 公式字符串
|
||
|
||
Returns:
|
||
JSONB 兼容的 dict
|
||
"""
|
||
import re
|
||
|
||
operators = {"rank", "scale", "signed_power", "abs", "sign", "max_pair", "min_pair"}
|
||
funcs = {
|
||
"ts_rank",
|
||
"ts_mean",
|
||
"ts_std",
|
||
"ts_min",
|
||
"ts_max",
|
||
"ts_sum",
|
||
"ts_argmin",
|
||
"ts_argmax",
|
||
"decay_linear",
|
||
"product",
|
||
"returns",
|
||
"delta",
|
||
"log",
|
||
"sqrt",
|
||
"correlation",
|
||
"covariance",
|
||
"stddev",
|
||
"indneutralize",
|
||
"signed_power",
|
||
}
|
||
# 扫描每个 '(' 之前的标识符
|
||
# 区分 operators(rank/scale/...)vs funcs(ts_rank/...)
|
||
parsed: dict[str, Any] = {
|
||
"raw": formula_str,
|
||
"operators": [],
|
||
"functions": [],
|
||
"variables": [],
|
||
}
|
||
for i, ch in enumerate(formula_str):
|
||
if ch != "(":
|
||
continue
|
||
name_match = re.search(r"(\w+)$", formula_str[:i])
|
||
if not name_match:
|
||
continue
|
||
name = name_match.group(1)
|
||
# 找匹配的 )
|
||
depth = 1
|
||
for j in range(i + 1, len(formula_str)):
|
||
if formula_str[j] == "(":
|
||
depth += 1
|
||
elif formula_str[j] == ")":
|
||
depth -= 1
|
||
if depth == 0:
|
||
args = formula_str[i + 1 : j]
|
||
if name in operators:
|
||
parsed["operators"].append(name)
|
||
if name in funcs:
|
||
parsed["functions"].append({"name": name, "args": args.strip()})
|
||
break
|
||
# 提取变量名
|
||
var_pattern = re.findall(r"\b(close|open|high|low|volume|vwap)\b", formula_str)
|
||
parsed["variables"] = sorted(set(var_pattern))
|
||
return parsed
|
||
|
||
|
||
# ── Phase 3 formula contract: frozen alpha001-alpha050 surface ──────────────
|
||
|
||
# Formula functions remain the implementation source of truth. This contract
|
||
# freezes their callable surface separately from formula dependencies so that
|
||
# historical compatibility-only arguments remain explicit without rewriting
|
||
# formulas or changing direct-call APIs.
|
||
ALPHA158_PHASE3_FORMULA_CONTRACT_VERSION = "1.0.0"
|
||
ALPHA158_PHASE3_FORMULA_CATALOG_SHA256 = (
|
||
"9a3360e5ee77a85a35d3c2fdab1efaa531fa0c263a2cb2bb5b965a1fb96fe1bd"
|
||
)
|
||
|
||
_PHASE3_FORMULA_FUNCTIONS: dict[str, Callable[..., pd.Series]] = {
|
||
"alpha_001": alpha_001,
|
||
"alpha_002": alpha_002,
|
||
"alpha_003": alpha_003,
|
||
"alpha_004": alpha_004,
|
||
"alpha_005": alpha_005,
|
||
"alpha_006": alpha_006,
|
||
"alpha_007": alpha_007,
|
||
"alpha_008": alpha_008,
|
||
"alpha_009": alpha_009,
|
||
"alpha_010": alpha_010,
|
||
"alpha_011": alpha_011,
|
||
"alpha_012": alpha_012,
|
||
"alpha_013": alpha_013,
|
||
"alpha_014": alpha_014,
|
||
"alpha_015": alpha_015,
|
||
"alpha_016": alpha_016,
|
||
"alpha_017": alpha_017,
|
||
"alpha_018": alpha_018,
|
||
"alpha_019": alpha_019,
|
||
"alpha_020": alpha_020,
|
||
"alpha_021": alpha_021,
|
||
"alpha_022": alpha_022,
|
||
"alpha_023": alpha_023,
|
||
"alpha_024": alpha_024,
|
||
"alpha_025": alpha_025,
|
||
"alpha_026": alpha_026,
|
||
"alpha_027": alpha_027,
|
||
"alpha_028": alpha_028,
|
||
"alpha_029": alpha_029,
|
||
"alpha_030": alpha_030,
|
||
"alpha_031": alpha_031,
|
||
"alpha_032": alpha_032,
|
||
"alpha_033": alpha_033,
|
||
"alpha_034": alpha_034,
|
||
"alpha_035": alpha_035,
|
||
"alpha_036": alpha_036,
|
||
"alpha_037": alpha_037,
|
||
"alpha_038": alpha_038,
|
||
"alpha_039": alpha_039,
|
||
"alpha_040": alpha_040,
|
||
"alpha_041": alpha_041,
|
||
"alpha_042": alpha_042,
|
||
"alpha_043": alpha_043,
|
||
"alpha_044": alpha_044,
|
||
"alpha_045": alpha_045,
|
||
"alpha_046": alpha_046,
|
||
"alpha_047": alpha_047,
|
||
"alpha_048": alpha_048,
|
||
"alpha_049": alpha_049,
|
||
"alpha_050": alpha_050,
|
||
}
|
||
|
||
_PHASE3_FORMULA_INPUT_OVERRIDES: dict[str, list[str]] = {
|
||
"alpha_011": ["close", "high", "low"],
|
||
"alpha_035": ["volume"],
|
||
"alpha_036": ["close"],
|
||
"alpha_040": ["high", "low"],
|
||
"alpha_042": ["close"],
|
||
"alpha_043": ["volume"],
|
||
}
|
||
|
||
_PHASE3_INPUT_CATEGORIES = {
|
||
1: "single",
|
||
2: "pair",
|
||
3: "triple",
|
||
4: "quadruple",
|
||
}
|
||
|
||
|
||
def _phase3_call_inputs(function: Callable[..., pd.Series]) -> list[str]:
|
||
import inspect
|
||
|
||
parameters = list(inspect.signature(function).parameters.values())
|
||
if any(
|
||
parameter.kind is not inspect.Parameter.POSITIONAL_OR_KEYWORD
|
||
or parameter.default is not inspect.Parameter.empty
|
||
for parameter in parameters
|
||
):
|
||
raise RuntimeError(f"unsupported formula signature for {function.__name__}")
|
||
return ["open" if parameter.name == "open_" else parameter.name for parameter in parameters]
|
||
|
||
|
||
def _phase3_string_list(meta: dict[str, Any], field: str, alpha_id: str) -> list[str]:
|
||
value = meta[field]
|
||
if not isinstance(value, list) or not all(isinstance(item, str) for item in value):
|
||
raise RuntimeError(f"{field} must be a list of strings for {alpha_id}")
|
||
return list(value)
|
||
|
||
|
||
def _build_phase3_formula_specs() -> dict[str, dict[str, Any]]:
|
||
specs: dict[str, dict[str, Any]] = {}
|
||
for alpha_id, function in _PHASE3_FORMULA_FUNCTIONS.items():
|
||
meta = ALPHA158_REGISTRY[alpha_id]
|
||
call_inputs = _phase3_call_inputs(function)
|
||
formula_inputs = _PHASE3_FORMULA_INPUT_OVERRIDES.get(alpha_id, call_inputs)
|
||
input_category = _PHASE3_INPUT_CATEGORIES.get(len(call_inputs))
|
||
if input_category is None:
|
||
raise RuntimeError(f"unsupported formula input count for {alpha_id}")
|
||
specs[alpha_id] = {
|
||
"name": alpha_id,
|
||
"contract_version": ALPHA158_PHASE3_FORMULA_CONTRACT_VERSION,
|
||
"formula": meta["formula"],
|
||
"category": meta["category"],
|
||
"complexity": meta["complexity"],
|
||
"parameters": _phase3_string_list(meta, "params", alpha_id),
|
||
"description": meta["description"],
|
||
"references": _phase3_string_list(meta, "references", alpha_id),
|
||
"call_inputs": list(call_inputs),
|
||
"formula_inputs": list(formula_inputs),
|
||
"input_category": input_category,
|
||
}
|
||
return specs
|
||
|
||
|
||
def _freeze_phase3_formula_specs(
|
||
specs: dict[str, dict[str, Any]],
|
||
) -> Mapping[str, Mapping[str, Any]]:
|
||
frozen_specs: dict[str, Mapping[str, Any]] = {}
|
||
for alpha_id, spec in specs.items():
|
||
frozen_specs[alpha_id] = MappingProxyType(
|
||
{field: tuple(value) if isinstance(value, list) else value for field, value in spec.items()}
|
||
)
|
||
return MappingProxyType(frozen_specs)
|
||
|
||
|
||
ALPHA158_PHASE3_FORMULA_SPECS: Mapping[str, Mapping[str, Any]] = (
|
||
_freeze_phase3_formula_specs(_build_phase3_formula_specs())
|
||
)
|
||
|
||
|
||
def list_phase3_formulas() -> tuple[str, ...]:
|
||
"""Return the frozen alpha001-alpha050 formula IDs in stable order."""
|
||
return tuple(ALPHA158_PHASE3_FORMULA_SPECS)
|
||
|
||
|
||
def evaluate_phase3_formula(name: str, **inputs: pd.Series) -> pd.Series:
|
||
"""Evaluate a Phase 3 formula with an exact, alignment-safe input contract."""
|
||
if name not in ALPHA158_PHASE3_FORMULA_SPECS:
|
||
raise KeyError(f"formula {name!r} not registered")
|
||
|
||
spec = ALPHA158_PHASE3_FORMULA_SPECS[name]
|
||
required_inputs = cast(tuple[str, ...], spec["call_inputs"])
|
||
missing_inputs = [field for field in required_inputs if field not in inputs]
|
||
unexpected_inputs = sorted(field for field in inputs if field not in required_inputs)
|
||
if missing_inputs or unexpected_inputs:
|
||
details: list[str] = []
|
||
if missing_inputs:
|
||
details.append(f"missing inputs {missing_inputs}")
|
||
if unexpected_inputs:
|
||
details.append(f"unexpected inputs {unexpected_inputs}")
|
||
raise ValueError(f"invalid inputs for {name}: {'; '.join(details)}")
|
||
|
||
for field in required_inputs:
|
||
if not isinstance(inputs[field], pd.Series):
|
||
raise TypeError(f"{field} must be a pandas Series")
|
||
|
||
primary_field = required_inputs[0]
|
||
primary = inputs[primary_field]
|
||
for field in required_inputs[1:]:
|
||
if not primary.index.equals(inputs[field].index):
|
||
raise ValueError(f"{field} index must align with {primary_field}")
|
||
|
||
function = _PHASE3_FORMULA_FUNCTIONS[name]
|
||
return function(*(inputs[field] for field in required_inputs))
|
||
|
||
|
||
__all__ = [
|
||
"rank",
|
||
"delta",
|
||
"ts_mean",
|
||
"ts_std",
|
||
"ts_rank",
|
||
"correlation",
|
||
"ts_min",
|
||
"ts_max",
|
||
"ts_sum",
|
||
"ts_argmin",
|
||
"ts_argmax",
|
||
"decay_linear",
|
||
"product",
|
||
"returns",
|
||
"scale",
|
||
"signed_power",
|
||
"stddev",
|
||
"covariance",
|
||
"log",
|
||
"abs_series",
|
||
"sign",
|
||
"max_pair",
|
||
"min_pair",
|
||
"indneutralize",
|
||
"ALPHA158_PHASE1_MAX_WINDOW",
|
||
"ALPHA158_PHASE1_OPERATOR_SPECS",
|
||
"list_phase1_operators",
|
||
"evaluate_phase1_operator",
|
||
"ALPHA158_PHASE2_MAX_WINDOW",
|
||
"ALPHA158_PHASE2_OPERATOR_SPECS",
|
||
"list_phase2_operators",
|
||
"evaluate_phase2_operator",
|
||
"ALPHA158_PHASE3_FORMULA_CONTRACT_VERSION",
|
||
"ALPHA158_PHASE3_FORMULA_CATALOG_SHA256",
|
||
"ALPHA158_PHASE3_FORMULA_SPECS",
|
||
"list_phase3_formulas",
|
||
"evaluate_phase3_formula",
|
||
"alpha_001",
|
||
"alpha_002",
|
||
"alpha_003",
|
||
"alpha_004",
|
||
"alpha_005",
|
||
"alpha_006",
|
||
"alpha_007",
|
||
"alpha_008",
|
||
"alpha_009",
|
||
"alpha_010",
|
||
"alpha_011",
|
||
"alpha_012",
|
||
"alpha_013",
|
||
"alpha_014",
|
||
"alpha_015",
|
||
"alpha_016",
|
||
"alpha_017",
|
||
"alpha_018",
|
||
"alpha_019",
|
||
"alpha_020",
|
||
"alpha_021",
|
||
"alpha_022",
|
||
"alpha_023",
|
||
"alpha_024",
|
||
"alpha_025",
|
||
"alpha_026",
|
||
"alpha_027",
|
||
"alpha_028",
|
||
"alpha_029",
|
||
"alpha_030",
|
||
"alpha_031",
|
||
"alpha_032",
|
||
"alpha_033",
|
||
"alpha_034",
|
||
"alpha_035",
|
||
"alpha_036",
|
||
"alpha_037",
|
||
"alpha_038",
|
||
"alpha_039",
|
||
"alpha_040",
|
||
"alpha_041",
|
||
"alpha_042",
|
||
"alpha_043",
|
||
"alpha_044",
|
||
"alpha_045",
|
||
"alpha_046",
|
||
"alpha_047",
|
||
"alpha_048",
|
||
"alpha_049",
|
||
"alpha_050",
|
||
"alpha_051",
|
||
"alpha_052",
|
||
"alpha_053",
|
||
"alpha_054",
|
||
"alpha_055",
|
||
"alpha_056",
|
||
"alpha_057",
|
||
"alpha_058",
|
||
"alpha_059",
|
||
"alpha_060",
|
||
"alpha_061",
|
||
"alpha_062",
|
||
"alpha_063",
|
||
"alpha_064",
|
||
"alpha_065",
|
||
"alpha_066",
|
||
"alpha_067",
|
||
"alpha_068",
|
||
"alpha_069",
|
||
"alpha_070",
|
||
"alpha_071",
|
||
"alpha_072",
|
||
"alpha_073",
|
||
"alpha_074",
|
||
"alpha_075",
|
||
"alpha_076",
|
||
"alpha_077",
|
||
"alpha_078",
|
||
"alpha_079",
|
||
"alpha_080",
|
||
"alpha_081",
|
||
"alpha_082",
|
||
"alpha_083",
|
||
"alpha_084",
|
||
"alpha_085",
|
||
"alpha_086",
|
||
"alpha_087",
|
||
"alpha_088",
|
||
"alpha_089",
|
||
"alpha_090",
|
||
"alpha_091",
|
||
"alpha_092",
|
||
"alpha_093",
|
||
"alpha_094",
|
||
"alpha_095",
|
||
"alpha_096",
|
||
"alpha_097",
|
||
"alpha_098",
|
||
"alpha_099",
|
||
"alpha_100",
|
||
"alpha_101",
|
||
"alpha_102",
|
||
"alpha_103",
|
||
"alpha_104",
|
||
"alpha_105",
|
||
"alpha_106",
|
||
"alpha_107",
|
||
"alpha_108",
|
||
"alpha_109",
|
||
"alpha_110",
|
||
"alpha_111",
|
||
"alpha_112",
|
||
"alpha_113",
|
||
"alpha_114",
|
||
"alpha_115",
|
||
"alpha_116",
|
||
"alpha_117",
|
||
"alpha_118",
|
||
"alpha_119",
|
||
"alpha_120",
|
||
"alpha_121",
|
||
"alpha_122",
|
||
"alpha_123",
|
||
"alpha_124",
|
||
"alpha_125",
|
||
"alpha_126",
|
||
"alpha_127",
|
||
"alpha_128",
|
||
"alpha_129",
|
||
"alpha_130",
|
||
"alpha_131",
|
||
"alpha_132",
|
||
"alpha_133",
|
||
"alpha_134",
|
||
"alpha_135",
|
||
"alpha_136",
|
||
"alpha_137",
|
||
"alpha_138",
|
||
"alpha_139",
|
||
"alpha_140",
|
||
"alpha_141",
|
||
"alpha_142",
|
||
"alpha_143",
|
||
"alpha_144",
|
||
"alpha_145",
|
||
"alpha_146",
|
||
"alpha_147",
|
||
"alpha_148",
|
||
"alpha_149",
|
||
"alpha_150",
|
||
"alpha_151",
|
||
"alpha_152",
|
||
"alpha_153",
|
||
"alpha_154",
|
||
"alpha_155",
|
||
"alpha_156",
|
||
"alpha_157",
|
||
"alpha_158",
|
||
"ALPHA158_REGISTRY",
|
||
"get_alpha_meta",
|
||
"dump_alpha_registry_jsonl",
|
||
"load_alpha_registry_jsonl",
|
||
"alpha_registry_to_pg_rows",
|
||
"parse_alpha_formula",
|
||
]
|