polars-ta 0.5.5__py3-none-any.whl → 0.5.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- polars_ta/_version.py +1 -1
- polars_ta/prefix/vec.py +1 -0
- polars_ta/wq/cross_sectional.py +31 -1
- polars_ta/wq/preprocess.py +15 -4
- polars_ta/wq/transformational.py +5 -0
- polars_ta/wq/vector.py +3 -0
- {polars_ta-0.5.5.dist-info → polars_ta-0.5.6.dist-info}/METADATA +1 -1
- {polars_ta-0.5.5.dist-info → polars_ta-0.5.6.dist-info}/RECORD +10 -10
- {polars_ta-0.5.5.dist-info → polars_ta-0.5.6.dist-info}/WHEEL +0 -0
- {polars_ta-0.5.5.dist-info → polars_ta-0.5.6.dist-info}/licenses/LICENSE +0 -0
polars_ta/_version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.5.
|
1
|
+
__version__ = "0.5.6"
|
polars_ta/prefix/vec.py
CHANGED
@@ -7,6 +7,7 @@ from polars_ta.wq.vector import vec_ir as cs_vec_ir # noqa
|
|
7
7
|
from polars_ta.wq.vector import vec_kurtosis as cs_vec_kurtosis # noqa
|
8
8
|
from polars_ta.wq.vector import vec_l2_norm as cs_vec_l2_norm # noqa
|
9
9
|
from polars_ta.wq.vector import vec_max as cs_vec_max # noqa
|
10
|
+
from polars_ta.wq.vector import vec_median as cs_vec_median # noqa
|
10
11
|
from polars_ta.wq.vector import vec_min as cs_vec_min # noqa
|
11
12
|
from polars_ta.wq.vector import vec_norm as cs_vec_norm # noqa
|
12
13
|
from polars_ta.wq.vector import vec_percentage as cs_vec_percentage # noqa
|
polars_ta/wq/cross_sectional.py
CHANGED
@@ -252,7 +252,6 @@ def cs_rank(x: Expr, pct: bool = True) -> Expr:
|
|
252
252
|
|
253
253
|
Examples
|
254
254
|
--------
|
255
|
-
|
256
255
|
```python
|
257
256
|
df = pl.DataFrame({
|
258
257
|
'a': [None, 1, 1, 1, 2, 2, 3, 10],
|
@@ -290,6 +289,37 @@ def cs_rank(x: Expr, pct: bool = True) -> Expr:
|
|
290
289
|
return x.rank(method='dense')
|
291
290
|
|
292
291
|
|
292
|
+
def cs_rank_if(condition: Expr, x: Expr, pct: bool = True) -> Expr:
|
293
|
+
"""动态票池过滤排名
|
294
|
+
|
295
|
+
Parameters
|
296
|
+
----------
|
297
|
+
condition:Expr
|
298
|
+
条件
|
299
|
+
x:Expr
|
300
|
+
因子
|
301
|
+
pct:bool
|
302
|
+
|
303
|
+
Examples
|
304
|
+
--------
|
305
|
+
```python
|
306
|
+
df = pl.DataFrame({
|
307
|
+
'a': [None, 1, 1, 1, 2, 2, 3, 10],
|
308
|
+
'b': [1, 2, 3, 4, 5, 6, 7, 8],
|
309
|
+
}).with_columns(
|
310
|
+
out1=cs_rank_if(True, pl.col('a'), True), # 与cs_rank等价
|
311
|
+
out2=cs_rank_if(pl.col('b') > 3, -pl.col('a'), False),
|
312
|
+
)
|
313
|
+
```
|
314
|
+
|
315
|
+
Notes
|
316
|
+
-----
|
317
|
+
已经产生了新的None,尽量避免之后再进行ts_时序计算
|
318
|
+
|
319
|
+
"""
|
320
|
+
return cs_rank(when(condition).then(x).otherwise(None), pct)
|
321
|
+
|
322
|
+
|
293
323
|
def _cs_qcut_rank(x: Expr, q: int = 10) -> Expr:
|
294
324
|
"""横截面上等频分箱
|
295
325
|
|
polars_ta/wq/preprocess.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
"""
|
2
|
-
补空值 → 去极值 → 标准化 → 中性化 → 标准化(可选二次标准化)
|
2
|
+
1. 补空值 → 去极值 → 标准化 → 中性化 → 标准化(可选二次标准化)
|
3
|
+
2. 补空值 → 去极值 → 中性化 → 标准化
|
3
4
|
|
4
5
|
# 对数市值。去极值
|
5
6
|
MC_LOG = cs_quantile(log1p(market_cap), 0.01, 0.99)
|
@@ -95,16 +96,26 @@ def cs_zscore_resid(y: Expr, *more_x: Expr) -> Expr:
|
|
95
96
|
return cs_resid(cs_zscore(y), *more_x)
|
96
97
|
|
97
98
|
|
99
|
+
def cs_resid_zscore(y: Expr, *more_x: Expr) -> Expr:
|
100
|
+
"""横截面中性化、标准化"""
|
101
|
+
return cs_resid(cs_zscore(y), *more_x)
|
102
|
+
|
103
|
+
|
98
104
|
def cs_mad_zscore(y: Expr) -> Expr:
|
99
|
-
"""
|
105
|
+
"""横截面MAD去极值、标准化"""
|
100
106
|
return cs_zscore(cs_mad(y))
|
101
107
|
|
102
108
|
|
103
109
|
def cs_mad_zscore_resid(y: Expr, *more_x: Expr) -> Expr:
|
104
|
-
"""
|
110
|
+
"""横截面MAD去极值、标准化、中性化"""
|
105
111
|
return cs_resid(cs_zscore(cs_mad(y)), *more_x)
|
106
112
|
|
107
113
|
|
108
114
|
def cs_mad_zscore_resid_zscore(y: Expr, *more_x: Expr) -> Expr:
|
109
|
-
"""
|
115
|
+
"""横截面去MAD极值、标准化、中性化、二次标准化"""
|
110
116
|
return cs_zscore(cs_resid(cs_zscore(cs_mad(y)), *more_x))
|
117
|
+
|
118
|
+
|
119
|
+
def cs_quantile_zscore(y: Expr, low_limit: float = 0.025, up_limit: float = 0.975) -> Expr:
|
120
|
+
"""横截面分位数去极值、标准化"""
|
121
|
+
return cs_zscore(cs_quantile(y, low_limit, up_limit))
|
polars_ta/wq/transformational.py
CHANGED
@@ -215,6 +215,11 @@ def sigmoid(x: Expr) -> Expr:
|
|
215
215
|
return 1 / (1 + (-x).exp())
|
216
216
|
|
217
217
|
|
218
|
+
def logit(x: Expr) -> Expr:
|
219
|
+
"""对数几率,拉伸中间部分"""
|
220
|
+
return (x / (1 + x)).log()
|
221
|
+
|
222
|
+
|
218
223
|
def tail(x: Expr, lower: float = 0, upper: float = 0, newval: float = 0) -> Expr:
|
219
224
|
"""If (x > lower AND x < upper) return newval, else return x. Lower, upper, newval should be constants.
|
220
225
|
|
polars_ta/wq/vector.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
polars_ta/__init__.py,sha256=ig6f6c1AMSpntwKjqaX3msBzVIwkI7J776IujEmiuvA,123
|
2
|
-
polars_ta/_version.py,sha256=
|
2
|
+
polars_ta/_version.py,sha256=CMH34Gt1AqO7z_TqRj94XwohGoVCf8aes0djkqm45mk,22
|
3
3
|
polars_ta/noise.py,sha256=LJHubBqnWlU3Bz84z07N1JB-b-hAMW2rgBF1BT4m0FE,1471
|
4
4
|
polars_ta/candles/__init__.py,sha256=AW68IuFC0gD4_OyjwLP3p22WSzSIYqlSrsS9fW_15xw,141
|
5
5
|
polars_ta/candles/cdl1.py,sha256=RnRu1QzpqEt5y0-1hlfZRUvza1no-Gj4x_dx2QWxr5A,3130
|
@@ -18,7 +18,7 @@ polars_ta/prefix/reports.py,sha256=B2QgdfX6RbZu9ytgaINv3Aq-ZAh_m3cr2pgbpFyL35A,4
|
|
18
18
|
polars_ta/prefix/ta.py,sha256=qIb3oRmexNZ6LTQ35V194QTLqj8UgzjaYl5ASwqN5pc,4167
|
19
19
|
polars_ta/prefix/talib.py,sha256=6JsrkgDIUsR2bIA7jVywxgWwxiiFuzsCPvbDeAt4qBA,9392
|
20
20
|
polars_ta/prefix/tdx.py,sha256=EttaExzqoA3Y3lD-YKA32-5GfJ6jgKjt-nRuoeuK0wQ,11429
|
21
|
-
polars_ta/prefix/vec.py,sha256=
|
21
|
+
polars_ta/prefix/vec.py,sha256=vsRbRryBdtrAPZ1CRcatzcx_-JNieF9CAacw6yXZbvI,1123
|
22
22
|
polars_ta/prefix/wq.py,sha256=PpSLQQ3vD0Mf3Tiz_AFSi--q8p7CkLg9CHh_ayMfoYo,35
|
23
23
|
polars_ta/reports/__init__.py,sha256=KEATtWxhdaO6XScHYN2XE4WkYbYpQvDOEyXgyc2z22g,45
|
24
24
|
polars_ta/reports/cicc.py,sha256=ZpNzHo5h855Xo9IeKeOzlUjjwE5tR8opb11UoJVxGkg,707
|
@@ -64,13 +64,13 @@ polars_ta/wq/__init__.py,sha256=C3YYJc997XCUI7H_afGT_mj2m4UdHMcql4sboCVvrXU,327
|
|
64
64
|
polars_ta/wq/_nb.py,sha256=9N7afRiABqdjO1QPnRlP1RIKJ98cQLpv6nF3dsqUA6k,11281
|
65
65
|
polars_ta/wq/_slow.py,sha256=MfWg9FYX8NGNLWN4ezI_awf3pPTqhSq_zo0LOS4nCzw,937
|
66
66
|
polars_ta/wq/arithmetic.py,sha256=NwyX-K8j9ul7XHHSNuGimBq6f3NvcOGQ4le5PQuaRPc,26346
|
67
|
-
polars_ta/wq/cross_sectional.py,sha256=
|
67
|
+
polars_ta/wq/cross_sectional.py,sha256=wAVG8jUpF8wZlJPm1LExmwLHdgmx2u1OOCECumYjy10,15457
|
68
68
|
polars_ta/wq/logical.py,sha256=PfcPrY3iYoYFDTJ-B1IlCfpab1uTWV7GN1TdRtjauEk,2241
|
69
|
-
polars_ta/wq/preprocess.py,sha256=
|
69
|
+
polars_ta/wq/preprocess.py,sha256=sGvCKMpGMWKXwd2OC7mM65G4Ecd-dIGH9jkyQraIZhE,3705
|
70
70
|
polars_ta/wq/time_series.py,sha256=nywBEfkVrTsUgyUL7NCSMUSBoLm09e0ToCp9zwrxbvM,33155
|
71
|
-
polars_ta/wq/transformational.py,sha256=
|
72
|
-
polars_ta/wq/vector.py,sha256=
|
73
|
-
polars_ta-0.5.
|
74
|
-
polars_ta-0.5.
|
75
|
-
polars_ta-0.5.
|
76
|
-
polars_ta-0.5.
|
71
|
+
polars_ta/wq/transformational.py,sha256=ewZPwzeg5ak6fxCDI_PY5mDJrNryOIoCX4x7LTyPXNU,7371
|
72
|
+
polars_ta/wq/vector.py,sha256=Hkg5q3zi1QOylccB43FvnR_AcCjG4JxhmeKW5RdMn3Q,1957
|
73
|
+
polars_ta-0.5.6.dist-info/METADATA,sha256=9Xm_okfFEEFZM1MOq_0h8txvRq-06ZnX4Z-V_UDXcCM,8839
|
74
|
+
polars_ta-0.5.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
75
|
+
polars_ta-0.5.6.dist-info/licenses/LICENSE,sha256=nREFtfwxWCCYD-ZA1jMzhhxMyTz-wGWFlnkpgg0DCtQ,1062
|
76
|
+
polars_ta-0.5.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|