polars-ta 0.4.7__py3-none-any.whl → 0.5.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polars_ta
3
- Version: 0.4.7
3
+ Version: 0.5.2
4
4
  Summary: polars expressions
5
5
  Author-email: wukan <wu-kan@163.com>
6
6
  License: MIT License
@@ -31,7 +31,7 @@ Classifier: Programming Language :: Python
31
31
  Requires-Python: >=3.8
32
32
  Description-Content-Type: text/markdown
33
33
  License-File: LICENSE
34
- Requires-Dist: polars>=0.20.19
34
+ Requires-Dist: polars>=1.28.0
35
35
  Requires-Dist: polars-ols>=0.3.0
36
36
  Requires-Dist: numpy
37
37
  Requires-Dist: numba
@@ -66,6 +66,7 @@ pip install polars_ta-0.1.2-py3-none-any.whl
66
66
  ```
67
67
 
68
68
  ### How to Install TA-Lib
69
+
69
70
  Non-official `TA-Lib` wheels can be downloaded from `https://github.com/cgohlke/talib-build/releases`
70
71
 
71
72
  ## Usage
@@ -92,6 +93,18 @@ df = df.with_columns([
92
93
  ])
93
94
  ```
94
95
 
96
+ When both `min_periods` and `MIN_SAMPLES` are set, `min_periods` takes precedence. default value is `None`.
97
+
98
+ ```python
99
+ import polars_ta
100
+
101
+ # Global settings. Priority Low
102
+ polars_ta.MIN_SAMPLES = 1
103
+
104
+ # High priority
105
+ ts_mean(CLOSE, 10, min_samples=1)
106
+ ```
107
+
95
108
  ## How We Designed This
96
109
 
97
110
  1. We use `Expr` instead of `Series` to avoid using `Series` in the calculation. Functions are no longer methods of class.
@@ -109,32 +122,6 @@ See [compare](compare.md)
109
122
 
110
123
  See [nan_to_null](nan_to_null.md)
111
124
 
112
- ## Evolve of Our TA-Lib Wrappers
113
-
114
- 1. `Expr.map_batches` can be used to call third-party libraries, such as `TA-Lib, bottleneck`. But because of the input and output format requirements, you need to wrap the third-party API with a function.
115
- - Both input and output can only be one column. If you want to support multiple columns, you need to convert them to `pl.Struct`. After that, you need to use `unnest` to split `pl.Struct`.
116
- - The output must be `pl.Series`
117
- 2. Start to use `register_expr_namespace` to simplify the code
118
- - Implementation [helper.py](polars_ta/utils/helper.py)
119
- - Usage demo [demo_ta1.py](examples/demo_ta1.py)
120
- - Pros: Easy to use
121
- - Cons:
122
- - The `member function call mode` is not convenient for inputting into genetic algorithms for factor mining
123
- - `__getattribute__` dynamic method call is very flexible, but loses `IDE` support.
124
- 3. Prefix expression. Convert all member functions into formulas
125
- - Implementation [wrapper.py](polars_ta/utils/wrapper.py)
126
- - Usage demo [demo_ta2.py](examples/demo_ta2.py)
127
- - Pros: Can be input into our implementation of genetic algorithms
128
- - Cons: `__getattribute__` dynamic method call is very flexible, but loses `IDE` support.
129
- 4. Code generation.
130
- - Implementation [codegen_talib.py](tools/codegen_talib.py)
131
- - Generated result will be at [\_\_init\_\_.py](polars_ta/talib/__init__.py)
132
- - Usage demo [demo_ta3.py](examples/demo_ta3.py)
133
- - Pros:
134
- - Can be input into our implementation of genetic algorithms
135
- - `IDE` support
136
-
137
-
138
125
  ## Debugging
139
126
 
140
127
  ```commandline
@@ -158,10 +145,6 @@ This is required to use in `expr_codegen`.
158
145
  - https://support.worldquantbrain.com/hc/en-us/community/posts/20278408956439-从价量看技术指标总结-Technical-Indicator-
159
146
  - https://platform.worldquantbrain.com/learn/operators/operators
160
147
 
161
-
162
-
163
-
164
-
165
148
  # polars_ta
166
149
 
167
150
  基于`polars`的算子库。实现量化投研中常用的技术指标、数据处理等函数。对于不易翻译成`Expr`的库(如:`TA-Lib`)也提供了函数式调用的封装
@@ -186,6 +169,7 @@ pip install polars_ta-0.1.2-py3-none-any.whl
186
169
  ```
187
170
 
188
171
  ### TA-Lib安装
172
+
189
173
  Windows用户不会安装可从`https://github.com/cgohlke/talib-build/releases` 下载对应版本whl文件
190
174
 
191
175
  ## 使用方法
@@ -212,6 +196,19 @@ df = df.with_columns([
212
196
  ])
213
197
  ```
214
198
 
199
+ 当`min_periods`和`MIN_SAMPLES`都设置时,以`min_periods`为准,默认值为`None`
200
+
201
+ ```python
202
+ import polars_ta
203
+
204
+ # 全局设置。优先级低
205
+ polars_ta.MIN_SAMPLES = 1
206
+
207
+ # 指定函数。优先级高
208
+ ts_mean(CLOSE, 10, min_samples=1)
209
+
210
+ ```
211
+
215
212
  ## 设计原则
216
213
 
217
214
  1. 调用方法由`成员函数`换成`独立函数`。输入输出使用`Expr`,避免使用`Series`
@@ -229,28 +226,6 @@ df = df.with_columns([
229
226
 
230
227
  请参考[nan_to_null](nan_to_null.md)
231
228
 
232
- ## TA-Lib封装的演化
233
-
234
- 1. `Expr.map_batches`可以实现调用第三方库,如`TA-Lib, bottleneck`。但因为对输入与输出格式有要求,所以还需要用函数对第三方API封装一下。
235
- - 输入输出都只能是一列,如要支持多列需转换成`pl.Struct`。事后`pl.Struct`要拆分需使用`unnest`
236
- - 输出必须是`pl.Series`
237
- 2. 参数多,代码长。开始使用`register_expr_namespace`来简化代码
238
- - 实现代码[helper.py](polars_ta/utils/helper.py)
239
- - 使用演示[demo_ta1.py](examples/demo_ta1.py)
240
- - 优点:使用简单
241
- - 不足:`成员函数调用模式`不便于输入到遗传算法中进行因子挖掘
242
- - 不足:`__getattribute__`动态方法调用非常灵活,但失去了`IDE`智能提示
243
- 3. 前缀表达式。将所有的成员函数都转换成公式
244
- - 实现代码[wrapper.py](polars_ta/utils/wrapper.py)
245
- - 使用演示[demo_ta2.py](examples/demo_ta2.py)
246
- - 优点:可以输入到遗传算法
247
- - 不足:`__getattribute__`动态方法调用非常灵活,但失去了`IDE`智能提示
248
- 4. 代码自动生成。
249
- - 实现代码[codegen_talib.py](tools/codegen_talib.py)
250
- - 生成结果[\_\_init\_\_.py](polars_ta/talib/__init__.py)
251
- - 使用演示[demo_ta3.py](examples/demo_ta3.py)
252
- - 优点:即可以输入到遗传算法,`IDE`还有智能提示
253
-
254
229
  ## 开发调试
255
230
 
256
231
  ```commandline
@@ -261,6 +236,18 @@ pip install -e .
261
236
 
262
237
  注意:如果你在`ta`或`tdx`中添加了新的函数,请再运行`tools`下的`prefix_ta.py`或`prefix_tdx.py`,用于生成对应的前缀文件。前缀文件方便在`expr_codegen`中使用
263
238
 
239
+ ## 文档生成
240
+
241
+ ```commandline
242
+ pip install -r requirements-docs.txt
243
+ mkdocs build
244
+ ```
245
+
246
+ 文档生成在`site`目录下,其中的`llms-full.txt`可以作为大语言模型的知识库导入。
247
+
248
+ 也可以通过以下链接导入:
249
+ https://polars-ta.readthedocs.io/en/latest/llms-full.txt
250
+
264
251
  ## 参考
265
252
 
266
253
  - https://github.com/pola-rs/polars
@@ -1,5 +1,5 @@
1
- polars_ta/__init__.py,sha256=UfRKvBoFTFhGlL9fNsarlPs0_FV6kxM1vfWvJD5YBe8,53
2
- polars_ta/_version.py,sha256=MHGyAIWXVeovtteWUUSzLq9UGWJLLooUZCXB9KGpNK8,22
1
+ polars_ta/__init__.py,sha256=ig6f6c1AMSpntwKjqaX3msBzVIwkI7J776IujEmiuvA,123
2
+ polars_ta/_version.py,sha256=isJrmDBLRag7Zc2UK9ZovWGOv7ji1Oh-zJtJMNJFkXw,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
@@ -26,7 +26,7 @@ polars_ta/ta/statistic.py,sha256=dS5dPBszbdlroJ9u5aXBniJmKgPQnuh9zE7miYKzICs,968
26
26
  polars_ta/ta/transform.py,sha256=c4s5l6khVqIer50g6oScdZ1EEPWYANeKm64AkBkPrtY,1789
27
27
  polars_ta/ta/volatility.py,sha256=yQDKLxos521y3RzywOcE0hTj3qIG_2mfqpARpdxQ1KU,836
28
28
  polars_ta/ta/volume.py,sha256=fPd9Po30kFu-cSmYoRQP4_Ypi9oSWROj650-mjwlfwM,739
29
- polars_ta/talib/__init__.py,sha256=bdNWsIrLlaOU2DVZWiFVBoQEBWtz-BJ1_4hAR5fa1H0,71818
29
+ polars_ta/talib/__init__.py,sha256=UZIkJ6tDYTcxBuKqjeKW93Ya_VyzTtNjXefoTqMd5P8,69701
30
30
  polars_ta/tdx/__init__.py,sha256=HBVPri6GwiEsFx4op0ZxDa3Yk4MbnPZgth5xJhtnxiA,662
31
31
  polars_ta/tdx/_chip.py,sha256=2eCe-y_0DcBivVjQHXlFwAiY410-hH-KKPrsUcRJcyk,3832
32
32
  polars_ta/tdx/_nb.py,sha256=IV3XrgSYPoR4jnOOT8p7jJWGtnoRrHLw5-fnIOfmMvA,2192
@@ -47,22 +47,22 @@ polars_ta/tdx/trend_feature.py,sha256=uNc4Z46Kyd7Prl0Ftl2ljSAXztTzQtbO28p7gy8iMv
47
47
  polars_ta/tdx/volume.py,sha256=juYM4Qlx2BX5okRCSwuf-6kRUETqDF7MVWUbYIzc4ww,901
48
48
  polars_ta/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
49
  polars_ta/utils/helper.py,sha256=rqxBhmA-RhpHd1-qxdYi7OEZloQpPxR30Kz8fJ_hLic,6254
50
- polars_ta/utils/numba_.py,sha256=HzizWbCJ8qJs-_3RwCqb33XlXMULI5UG1jUgleBNWZk,2808
51
- polars_ta/utils/pandas_.py,sha256=xdh-vc5I8RPYGVLh2WQkIwefPsdaah7fa7sb901vdj8,1956
50
+ polars_ta/utils/numba_.py,sha256=jiOxEZjdGBr8aFivCQbJllBsZCfQsBJXQ-DyGhTS2cI,5832
51
+ polars_ta/utils/pandas_.py,sha256=codb51l45TUMngY55twQaUPUxnffjvj8UEOm35zFpNE,1989
52
52
  polars_ta/utils/pit.py,sha256=YNgUE6mbwhrtA-7wyOL0PCUDdwfTQouXwage-cK6efY,4312
53
53
  polars_ta/utils/wrapper.py,sha256=jbR-ZQdzBf5iWvtnJ1HsN9HdepmDbU7fUj4w8Bt2BkU,3422
54
54
  polars_ta/wq/__init__.py,sha256=C3YYJc997XCUI7H_afGT_mj2m4UdHMcql4sboCVvrXU,327
55
- polars_ta/wq/_nb.py,sha256=cYEUlEvLQJCjt5_o_1qnWrJ2eWMamwUedOsLwYTq_Oo,9470
55
+ polars_ta/wq/_nb.py,sha256=9N7afRiABqdjO1QPnRlP1RIKJ98cQLpv6nF3dsqUA6k,11281
56
56
  polars_ta/wq/_slow.py,sha256=MfWg9FYX8NGNLWN4ezI_awf3pPTqhSq_zo0LOS4nCzw,937
57
57
  polars_ta/wq/arithmetic.py,sha256=rVFWhHpmgsMRfPj08VaXCrKapIZ3TP7-1Nc8wBi2BpE,23682
58
58
  polars_ta/wq/cross_sectional.py,sha256=mHLwuXu9m4ladb6cUJVnH4OofliBSkpzmIZu6TtBoe4,13697
59
59
  polars_ta/wq/logical.py,sha256=5lttGwQi9oHml7soqmxEwgIVVLpeWO7JSXmQ3-TUqlU,2261
60
60
  polars_ta/wq/preprocess.py,sha256=xbESoAtsbQgXJMhnLzg4r5o2H9uwPyHfySg5skk_DUg,4188
61
- polars_ta/wq/time_series.py,sha256=L74rqAUyZS6rI3S3R9aIwrKosGFFHWxP3BESNJ67ak8,27093
61
+ polars_ta/wq/time_series.py,sha256=iVYIGSQxD3xbiwNPHO7w-Yw0eQ-0nDzRtNzpMXwHwQU,32212
62
62
  polars_ta/wq/transformational.py,sha256=ktluqo-lcxWysFL3huNypId0EFR1wn1PmyBGO180UQo,7194
63
63
  polars_ta/wq/vector.py,sha256=Qs-mHC2YsiWXoyMuXZZPzd5W5w_HL1ZgDCj9wRAnqmQ,1902
64
- polars_ta-0.4.7.dist-info/licenses/LICENSE,sha256=nREFtfwxWCCYD-ZA1jMzhhxMyTz-wGWFlnkpgg0DCtQ,1062
65
- polars_ta-0.4.7.dist-info/METADATA,sha256=LCshC1cLprfJT5I_I2AFsyKOjElDGyXEzHCnZIKE-GA,10733
66
- polars_ta-0.4.7.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
67
- polars_ta-0.4.7.dist-info/top_level.txt,sha256=eat2IhP79-dIGA4DAFOz1o-95--UDqfjeIgmU9TBsDQ,10
68
- polars_ta-0.4.7.dist-info/RECORD,,
64
+ polars_ta-0.5.2.dist-info/licenses/LICENSE,sha256=nREFtfwxWCCYD-ZA1jMzhhxMyTz-wGWFlnkpgg0DCtQ,1062
65
+ polars_ta-0.5.2.dist-info/METADATA,sha256=acgqEzE0-X87lpIS5695GNLLlwDp_0Lpxuz5vsxPnAw,8633
66
+ polars_ta-0.5.2.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
67
+ polars_ta-0.5.2.dist-info/top_level.txt,sha256=eat2IhP79-dIGA4DAFOz1o-95--UDqfjeIgmU9TBsDQ,10
68
+ polars_ta-0.5.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (77.0.3)
2
+ Generator: setuptools (80.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5