Skip to content

Statistic

polars_ta.tdx.statistic

Functions:

Name Description
AVEDEV

mean absolute deviation

DEVSQ
SLOPE
STD

std dev with ddof = 1

STDDEV

标准偏差?

STDP

std dev with ddof = 0

VAR
VARP
ts_up_stat

T天N板统计,与通达信结果一样,最简为5天2板

AVEDEV(close: Expr, timeperiod: int = 5) -> Expr

mean absolute deviation 平均绝对偏差

DEVSQ(close: Expr, timeperiod: int = 5) -> Expr

SLOPE(close: Expr, timeperiod: int = 5) -> Expr

STD(close: Expr, timeperiod: int = 5) -> Expr

std dev with ddof = 1 估算标准差

STDDEV(close: Expr, timeperiod: int = 5) -> Expr

标准偏差?

STDP(close: Expr, timeperiod: int = 5) -> Expr

std dev with ddof = 0 总体标准差

VAR(close: Expr, timeperiod: int = 5) -> Expr

VARP(close: Expr, timeperiod: int = 5) -> Expr

ts_up_stat(x: Expr) -> Expr

T天N板统计,与通达信结果一样,最简为5天2板

Parameters:

Name Type Description Default
x Expr

布尔序列,True表示涨停

required

Returns:

Type Description
Expr
  1. T天
  2. N板
  3. 离上次涨停距离

Examples:

df = pl.DataFrame({
    'a': [False, True, True, False, True, False, False, False, False, False],
}).with_columns(
    out=ts_up_stat(pl.col('a'))
)
┌───────┬───────────┐
│ a     ┆ out       │
│ ---   ┆ ---       │
│ bool  ┆ struct[3] │
╞═══════╪═══════════╡
│ false ┆ {0,0,0}   │
│ true  ┆ {1,1,0}   │
│ true  ┆ {2,2,0}   │
│ false ┆ {3,2,1}   │
│ true  ┆ {4,3,0}   │
│ false ┆ {5,3,1}   │
│ false ┆ {6,3,2}   │
│ false ┆ {7,3,3}   │
│ false ┆ {0,0,4}   │
│ false ┆ {0,0,5}   │
└───────┴───────────┘