expr-codegen 0.6.3__tar.gz → 0.6.5__tar.gz
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.
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/PKG-INFO +30 -3
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/README.md +29 -2
- expr_codegen-0.6.5/expr_codegen/_version.py +1 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/tool.py +9 -3
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen.egg-info/PKG-INFO +30 -3
- expr_codegen-0.6.3/expr_codegen/_version.py +0 -1
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/LICENSE +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/__init__.py +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/codes.py +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/dag.py +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/expr.py +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/latex/__init__.py +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/latex/printer.py +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/model.py +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/pandas/__init__.py +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/pandas/code.py +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/pandas/printer.py +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/pandas/template.py.j2 +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/polars/__init__.py +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/polars/code.py +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/polars/printer.py +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen/polars/template.py.j2 +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen.egg-info/SOURCES.txt +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen.egg-info/dependency_links.txt +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen.egg-info/requires.txt +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/expr_codegen.egg-info/top_level.txt +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/pyproject.toml +0 -0
- {expr_codegen-0.6.3 → expr_codegen-0.6.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: expr_codegen
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.5
|
|
4
4
|
Summary: symbol expression to polars expression tool
|
|
5
5
|
Author-email: wukan <wu-kan@163.com>
|
|
6
6
|
License: BSD 3-Clause License
|
|
@@ -75,9 +75,35 @@ https://exprcodegen.streamlit.app
|
|
|
75
75
|
|
|
76
76
|
更完整示例访问[alpha_examples](https://github.com/wukan1986/alpha_examples)
|
|
77
77
|
|
|
78
|
-
##
|
|
78
|
+
## 使用示例
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
```python
|
|
81
|
+
from expr_codegen.tool import codegen_exec
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _code_block_():
|
|
85
|
+
# 因子编辑区,可利用IDE的智能提示在此区域编辑因子
|
|
86
|
+
|
|
87
|
+
# 会在生成的代码中自动导入
|
|
88
|
+
from polars_ta.wq import cs_mad_zscore_resid
|
|
89
|
+
|
|
90
|
+
# 1. 下划线开头的变量只是中间变量,最终输出时会被剔除
|
|
91
|
+
_a = ts_returns(CLOSE, 1)
|
|
92
|
+
_b = ts_sum(min_(_a, 0) ** 2, 20)
|
|
93
|
+
_c = ts_sum(max_(_a, 0) ** 2, 20)
|
|
94
|
+
_d = ts_sum(_a ** 2, 20)
|
|
95
|
+
_e = (_b - _c) / _d
|
|
96
|
+
# 2. 下划线开头的变量可以重复使用。 多个复杂因子多行书写时有重复中间变时不再冲突
|
|
97
|
+
# 3. 下划线开头的变量循环赋值。 在调试时可快速用注释进行切换了
|
|
98
|
+
_e = cs_mad_zscore_resid(_e, LOG_MC_ZS, ONE)
|
|
99
|
+
RSJ = _e
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
df = None # 替换成真实的polars数据
|
|
103
|
+
df = codegen_exec(_code_block_, df, output_file="output.py")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
```
|
|
81
107
|
|
|
82
108
|
## 目录结构
|
|
83
109
|
|
|
@@ -88,6 +114,7 @@ https://exprcodegen.streamlit.app
|
|
|
88
114
|
├─examples
|
|
89
115
|
│ alpha101.txt # WorldQuant Alpha101示例,可复制到`streamlit`应用
|
|
90
116
|
│ demo_cn.py # 中文注释示例。演示如何将表达式转换成代码
|
|
117
|
+
│ demo_express.py # 速成示例
|
|
91
118
|
│ demo_exec_pl.py # 演示调用转换后代码并绘图
|
|
92
119
|
│ demo_transformer.py # 演示将第三方表达式转成内部表达式
|
|
93
120
|
│ output.py # 结果输出。可不修改代码,直接被其它项目导入
|
|
@@ -25,9 +25,35 @@ https://exprcodegen.streamlit.app
|
|
|
25
25
|
|
|
26
26
|
更完整示例访问[alpha_examples](https://github.com/wukan1986/alpha_examples)
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## 使用示例
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
```python
|
|
31
|
+
from expr_codegen.tool import codegen_exec
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _code_block_():
|
|
35
|
+
# 因子编辑区,可利用IDE的智能提示在此区域编辑因子
|
|
36
|
+
|
|
37
|
+
# 会在生成的代码中自动导入
|
|
38
|
+
from polars_ta.wq import cs_mad_zscore_resid
|
|
39
|
+
|
|
40
|
+
# 1. 下划线开头的变量只是中间变量,最终输出时会被剔除
|
|
41
|
+
_a = ts_returns(CLOSE, 1)
|
|
42
|
+
_b = ts_sum(min_(_a, 0) ** 2, 20)
|
|
43
|
+
_c = ts_sum(max_(_a, 0) ** 2, 20)
|
|
44
|
+
_d = ts_sum(_a ** 2, 20)
|
|
45
|
+
_e = (_b - _c) / _d
|
|
46
|
+
# 2. 下划线开头的变量可以重复使用。 多个复杂因子多行书写时有重复中间变时不再冲突
|
|
47
|
+
# 3. 下划线开头的变量循环赋值。 在调试时可快速用注释进行切换了
|
|
48
|
+
_e = cs_mad_zscore_resid(_e, LOG_MC_ZS, ONE)
|
|
49
|
+
RSJ = _e
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
df = None # 替换成真实的polars数据
|
|
53
|
+
df = codegen_exec(_code_block_, df, output_file="output.py")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
```
|
|
31
57
|
|
|
32
58
|
## 目录结构
|
|
33
59
|
|
|
@@ -38,6 +64,7 @@ https://exprcodegen.streamlit.app
|
|
|
38
64
|
├─examples
|
|
39
65
|
│ alpha101.txt # WorldQuant Alpha101示例,可复制到`streamlit`应用
|
|
40
66
|
│ demo_cn.py # 中文注释示例。演示如何将表达式转换成代码
|
|
67
|
+
│ demo_express.py # 速成示例
|
|
41
68
|
│ demo_exec_pl.py # 演示调用转换后代码并绘图
|
|
42
69
|
│ demo_transformer.py # 演示将第三方表达式转成内部表达式
|
|
43
70
|
│ output.py # 结果输出。可不修改代码,直接被其它项目导入
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.6.5"
|
|
@@ -247,11 +247,14 @@ class ExprTool:
|
|
|
247
247
|
_TOOL_ = ExprTool()
|
|
248
248
|
|
|
249
249
|
|
|
250
|
-
def codegen_exec(
|
|
250
|
+
def codegen_exec(code_block, df_input,
|
|
251
251
|
extra_codes: str = r'CS_SW_L1 = pl.col(r"^sw_l1_\d+$")',
|
|
252
252
|
output_file: Optional[str] = None):
|
|
253
253
|
"""快速转换源代码并执行"""
|
|
254
|
-
|
|
254
|
+
# 此代码来自于sympy.var
|
|
255
|
+
frame = inspect.currentframe().f_back
|
|
256
|
+
_TOOL_.globals_ = frame.f_globals.copy()
|
|
257
|
+
del frame
|
|
255
258
|
|
|
256
259
|
if isinstance(code_block, str):
|
|
257
260
|
source = code_block
|
|
@@ -260,4 +263,7 @@ def codegen_exec(globals_, code_block, df_input,
|
|
|
260
263
|
|
|
261
264
|
codes = _TOOL_._get_codes(source, extra_codes, output_file)
|
|
262
265
|
|
|
263
|
-
|
|
266
|
+
if df_input is None:
|
|
267
|
+
return df_input
|
|
268
|
+
else:
|
|
269
|
+
return _TOOL_.exec(codes, df_input)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: expr_codegen
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.5
|
|
4
4
|
Summary: symbol expression to polars expression tool
|
|
5
5
|
Author-email: wukan <wu-kan@163.com>
|
|
6
6
|
License: BSD 3-Clause License
|
|
@@ -75,9 +75,35 @@ https://exprcodegen.streamlit.app
|
|
|
75
75
|
|
|
76
76
|
更完整示例访问[alpha_examples](https://github.com/wukan1986/alpha_examples)
|
|
77
77
|
|
|
78
|
-
##
|
|
78
|
+
## 使用示例
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
```python
|
|
81
|
+
from expr_codegen.tool import codegen_exec
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _code_block_():
|
|
85
|
+
# 因子编辑区,可利用IDE的智能提示在此区域编辑因子
|
|
86
|
+
|
|
87
|
+
# 会在生成的代码中自动导入
|
|
88
|
+
from polars_ta.wq import cs_mad_zscore_resid
|
|
89
|
+
|
|
90
|
+
# 1. 下划线开头的变量只是中间变量,最终输出时会被剔除
|
|
91
|
+
_a = ts_returns(CLOSE, 1)
|
|
92
|
+
_b = ts_sum(min_(_a, 0) ** 2, 20)
|
|
93
|
+
_c = ts_sum(max_(_a, 0) ** 2, 20)
|
|
94
|
+
_d = ts_sum(_a ** 2, 20)
|
|
95
|
+
_e = (_b - _c) / _d
|
|
96
|
+
# 2. 下划线开头的变量可以重复使用。 多个复杂因子多行书写时有重复中间变时不再冲突
|
|
97
|
+
# 3. 下划线开头的变量循环赋值。 在调试时可快速用注释进行切换了
|
|
98
|
+
_e = cs_mad_zscore_resid(_e, LOG_MC_ZS, ONE)
|
|
99
|
+
RSJ = _e
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
df = None # 替换成真实的polars数据
|
|
103
|
+
df = codegen_exec(_code_block_, df, output_file="output.py")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
```
|
|
81
107
|
|
|
82
108
|
## 目录结构
|
|
83
109
|
|
|
@@ -88,6 +114,7 @@ https://exprcodegen.streamlit.app
|
|
|
88
114
|
├─examples
|
|
89
115
|
│ alpha101.txt # WorldQuant Alpha101示例,可复制到`streamlit`应用
|
|
90
116
|
│ demo_cn.py # 中文注释示例。演示如何将表达式转换成代码
|
|
117
|
+
│ demo_express.py # 速成示例
|
|
91
118
|
│ demo_exec_pl.py # 演示调用转换后代码并绘图
|
|
92
119
|
│ demo_transformer.py # 演示将第三方表达式转成内部表达式
|
|
93
120
|
│ output.py # 结果输出。可不修改代码,直接被其它项目导入
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.6.3"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|