vnpy-x 1.0.0__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.
Files changed (81) hide show
  1. vnpy_x-1.0.0/LICENSE +21 -0
  2. vnpy_x-1.0.0/PKG-INFO +41 -0
  3. vnpy_x-1.0.0/README.md +16 -0
  4. vnpy_x-1.0.0/pyproject.toml +40 -0
  5. vnpy_x-1.0.0/src/vnpy_x/__init__.py +24 -0
  6. vnpy_x-1.0.0/src/vnpy_x/alpha/__init__.py +18 -0
  7. vnpy_x-1.0.0/src/vnpy_x/alpha/dataset/__init__.py +30 -0
  8. vnpy_x-1.0.0/src/vnpy_x/alpha/dataset/cs_function.py +64 -0
  9. vnpy_x-1.0.0/src/vnpy_x/alpha/dataset/datasets/__init__.py +0 -0
  10. vnpy_x-1.0.0/src/vnpy_x/alpha/dataset/datasets/alpha_101.py +330 -0
  11. vnpy_x-1.0.0/src/vnpy_x/alpha/dataset/datasets/alpha_158.py +130 -0
  12. vnpy_x-1.0.0/src/vnpy_x/alpha/dataset/math_function.py +167 -0
  13. vnpy_x-1.0.0/src/vnpy_x/alpha/dataset/processor.py +201 -0
  14. vnpy_x-1.0.0/src/vnpy_x/alpha/dataset/ta_function.py +43 -0
  15. vnpy_x-1.0.0/src/vnpy_x/alpha/dataset/template.py +305 -0
  16. vnpy_x-1.0.0/src/vnpy_x/alpha/dataset/ts_function.py +329 -0
  17. vnpy_x-1.0.0/src/vnpy_x/alpha/dataset/utility.py +285 -0
  18. vnpy_x-1.0.0/src/vnpy_x/alpha/lab.py +480 -0
  19. vnpy_x-1.0.0/src/vnpy_x/alpha/logger.py +12 -0
  20. vnpy_x-1.0.0/src/vnpy_x/alpha/model/__init__.py +6 -0
  21. vnpy_x-1.0.0/src/vnpy_x/alpha/model/models/__init__.py +0 -0
  22. vnpy_x-1.0.0/src/vnpy_x/alpha/model/models/lasso_model.py +139 -0
  23. vnpy_x-1.0.0/src/vnpy_x/alpha/model/models/lgb_model.py +170 -0
  24. vnpy_x-1.0.0/src/vnpy_x/alpha/model/models/mlp_model.py +683 -0
  25. vnpy_x-1.0.0/src/vnpy_x/alpha/model/template.py +30 -0
  26. vnpy_x-1.0.0/src/vnpy_x/alpha/strategy/__init__.py +8 -0
  27. vnpy_x-1.0.0/src/vnpy_x/alpha/strategy/backtesting.py +944 -0
  28. vnpy_x-1.0.0/src/vnpy_x/alpha/strategy/strategies/__init__.py +0 -0
  29. vnpy_x-1.0.0/src/vnpy_x/alpha/strategy/strategies/equity_demo_strategy.py +101 -0
  30. vnpy_x-1.0.0/src/vnpy_x/alpha/strategy/template.py +205 -0
  31. vnpy_x-1.0.0/src/vnpy_x/chart/__init__.py +9 -0
  32. vnpy_x-1.0.0/src/vnpy_x/chart/axis.py +44 -0
  33. vnpy_x-1.0.0/src/vnpy_x/chart/base.py +21 -0
  34. vnpy_x-1.0.0/src/vnpy_x/chart/item.py +333 -0
  35. vnpy_x-1.0.0/src/vnpy_x/chart/manager.py +170 -0
  36. vnpy_x-1.0.0/src/vnpy_x/chart/widget.py +556 -0
  37. vnpy_x-1.0.0/src/vnpy_x/event/__init__.py +8 -0
  38. vnpy_x-1.0.0/src/vnpy_x/event/engine.py +145 -0
  39. vnpy_x-1.0.0/src/vnpy_x/py.typed +0 -0
  40. vnpy_x-1.0.0/src/vnpy_x/rpc/__init__.py +8 -0
  41. vnpy_x-1.0.0/src/vnpy_x/rpc/client.py +169 -0
  42. vnpy_x-1.0.0/src/vnpy_x/rpc/common.py +10 -0
  43. vnpy_x-1.0.0/src/vnpy_x/rpc/server.py +140 -0
  44. vnpy_x-1.0.0/src/vnpy_x/trader/__init__.py +0 -0
  45. vnpy_x-1.0.0/src/vnpy_x/trader/app.py +21 -0
  46. vnpy_x-1.0.0/src/vnpy_x/trader/constant.py +164 -0
  47. vnpy_x-1.0.0/src/vnpy_x/trader/converter.py +402 -0
  48. vnpy_x-1.0.0/src/vnpy_x/trader/database.py +159 -0
  49. vnpy_x-1.0.0/src/vnpy_x/trader/datafeed.py +68 -0
  50. vnpy_x-1.0.0/src/vnpy_x/trader/engine.py +838 -0
  51. vnpy_x-1.0.0/src/vnpy_x/trader/event.py +14 -0
  52. vnpy_x-1.0.0/src/vnpy_x/trader/gateway.py +272 -0
  53. vnpy_x-1.0.0/src/vnpy_x/trader/locale/__init__.py +9 -0
  54. vnpy_x-1.0.0/src/vnpy_x/trader/locale/build_hook.py +23 -0
  55. vnpy_x-1.0.0/src/vnpy_x/trader/locale/en/LC_MESSAGES/vnpy.mo +0 -0
  56. vnpy_x-1.0.0/src/vnpy_x/trader/locale/en/LC_MESSAGES/vnpy.po +827 -0
  57. vnpy_x-1.0.0/src/vnpy_x/trader/locale/generate_mo.bat +1 -0
  58. vnpy_x-1.0.0/src/vnpy_x/trader/locale/generate_pot.bat +1 -0
  59. vnpy_x-1.0.0/src/vnpy_x/trader/locale/vnpy.pot +629 -0
  60. vnpy_x-1.0.0/src/vnpy_x/trader/logger.py +55 -0
  61. vnpy_x-1.0.0/src/vnpy_x/trader/object.py +427 -0
  62. vnpy_x-1.0.0/src/vnpy_x/trader/optimize.py +250 -0
  63. vnpy_x-1.0.0/src/vnpy_x/trader/setting.py +43 -0
  64. vnpy_x-1.0.0/src/vnpy_x/trader/ui/__init__.py +12 -0
  65. vnpy_x-1.0.0/src/vnpy_x/trader/ui/ico/__init__.py +0 -0
  66. vnpy_x-1.0.0/src/vnpy_x/trader/ui/ico/about.ico +0 -0
  67. vnpy_x-1.0.0/src/vnpy_x/trader/ui/ico/connect.ico +0 -0
  68. vnpy_x-1.0.0/src/vnpy_x/trader/ui/ico/contract.ico +0 -0
  69. vnpy_x-1.0.0/src/vnpy_x/trader/ui/ico/database.ico +0 -0
  70. vnpy_x-1.0.0/src/vnpy_x/trader/ui/ico/editor.ico +0 -0
  71. vnpy_x-1.0.0/src/vnpy_x/trader/ui/ico/email.ico +0 -0
  72. vnpy_x-1.0.0/src/vnpy_x/trader/ui/ico/exit.ico +0 -0
  73. vnpy_x-1.0.0/src/vnpy_x/trader/ui/ico/forum.ico +0 -0
  74. vnpy_x-1.0.0/src/vnpy_x/trader/ui/ico/restore.ico +0 -0
  75. vnpy_x-1.0.0/src/vnpy_x/trader/ui/ico/test.ico +0 -0
  76. vnpy_x-1.0.0/src/vnpy_x/trader/ui/ico/vnpy.ico +0 -0
  77. vnpy_x-1.0.0/src/vnpy_x/trader/ui/mainwindow.py +347 -0
  78. vnpy_x-1.0.0/src/vnpy_x/trader/ui/qt.py +125 -0
  79. vnpy_x-1.0.0/src/vnpy_x/trader/ui/widget.py +1710 -0
  80. vnpy_x-1.0.0/src/vnpy_x/trader/utility.py +1281 -0
  81. vnpy_x-1.0.0/src/vnpy_x/trader/wechat.py +307 -0
vnpy_x-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 EddyXie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
vnpy_x-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.5
2
+ Name: vnpy_x
3
+ Version: 1.0.0
4
+ Summary: vnpy官方的数据格式分钟线就是分钟线,我补充了5分钟线,15分钟线,30分钟线,还有月线
5
+ Author-email: EddyXie <xieshufan@163.com>
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Keywords: quant,stock,vnpy
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Requires-Python: >=3.9
19
+ Provides-Extra: dev
20
+ Requires-Dist: build>=1.0; extra == 'dev'
21
+ Requires-Dist: pytest>=7.0; extra == 'dev'
22
+ Requires-Dist: ruff>=0.1; extra == 'dev'
23
+ Requires-Dist: twine>=4.0; extra == 'dev'
24
+ Description-Content-Type: text/markdown
25
+
26
+ # vnpy_postgresql_x
27
+
28
+ [![PyPI version](https://img.shields.io/pypi/v/your-project-name.svg)](https://pypi.org/project/your-project-name/)
29
+ [![Python versions](https://img.shields.io/pypi/pyversions/your-project-name.svg)](https://pypi.org/project/your-project-name/)
30
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
31
+
32
+ 一句话说明这个项目是做什么的。
33
+
34
+ ## 简介
35
+
36
+ vnpy官方的数据格式分钟线就是分钟线,我补充了5分钟线,15分钟线,30分钟线,还有月线
37
+
38
+ ## 安装
39
+
40
+ ```bash
41
+ pip install vnpy_postgresql_x
vnpy_x-1.0.0/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # vnpy_postgresql_x
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/your-project-name.svg)](https://pypi.org/project/your-project-name/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/your-project-name.svg)](https://pypi.org/project/your-project-name/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ 一句话说明这个项目是做什么的。
8
+
9
+ ## 简介
10
+
11
+ vnpy官方的数据格式分钟线就是分钟线,我补充了5分钟线,15分钟线,30分钟线,还有月线
12
+
13
+ ## 安装
14
+
15
+ ```bash
16
+ pip install vnpy_postgresql_x
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "vnpy_x"
7
+ version = "1.0.0"
8
+ description = "vnpy官方的数据格式分钟线就是分钟线,我补充了5分钟线,15分钟线,30分钟线,还有月线"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ license-files = ["LICEN[CS]E*"]
13
+ authors = [
14
+ { name = "EddyXie", email = "xieshufan@163.com" },
15
+ ]
16
+ keywords = ["quant", "stock", "vnpy"]
17
+ classifiers = [
18
+ "Development Status :: 3 - Alpha",
19
+ "Intended Audience :: Developers",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Operating System :: OS Independent",
27
+ ]
28
+ dependencies = [
29
+ ]
30
+
31
+ [project.optional-dependencies]
32
+ dev = [
33
+ "pytest>=7.0",
34
+ "ruff>=0.1",
35
+ "build>=1.0",
36
+ "twine>=4.0",
37
+ ]
38
+
39
+ [tool.hatch.build.targets.wheel]
40
+ packages = ["src/vnpy_x"]
@@ -0,0 +1,24 @@
1
+ # The MIT License (MIT)
2
+
3
+ # Copyright (c) 2015-present, Xiaoyou Chen
4
+
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+
24
+ __version__ = "4.4.0"
@@ -0,0 +1,18 @@
1
+ from .logger import logger
2
+ from .dataset import AlphaDataset, Segment, to_datetime, register_functions
3
+ from .model import AlphaModel
4
+ from .strategy import AlphaStrategy, BacktestingEngine
5
+ from .lab import AlphaLab
6
+
7
+
8
+ __all__ = [
9
+ "logger",
10
+ "AlphaDataset",
11
+ "Segment",
12
+ "to_datetime",
13
+ "register_functions",
14
+ "AlphaModel",
15
+ "AlphaStrategy",
16
+ "BacktestingEngine",
17
+ "AlphaLab"
18
+ ]
@@ -0,0 +1,30 @@
1
+ from .template import AlphaDataset
2
+ from .utility import Segment, to_datetime, register_functions
3
+ from .processor import (
4
+ process_drop_na,
5
+ process_fill_na,
6
+ process_cs_norm,
7
+ process_robust_zscore_norm,
8
+ process_cs_rank_norm,
9
+ process_replace_inf,
10
+ process_ts_norm,
11
+ process_drop_feature,
12
+ process_cs_fill_na,
13
+ )
14
+
15
+
16
+ __all__ = [
17
+ "AlphaDataset",
18
+ "Segment",
19
+ "to_datetime",
20
+ "register_functions",
21
+ "process_drop_na",
22
+ "process_fill_na",
23
+ "process_cs_norm",
24
+ "process_robust_zscore_norm",
25
+ "process_cs_rank_norm",
26
+ "process_replace_inf",
27
+ "process_ts_norm",
28
+ "process_drop_feature",
29
+ "process_cs_fill_na",
30
+ ]
@@ -0,0 +1,64 @@
1
+ """
2
+ Cross Section Operators
3
+ """
4
+
5
+ import polars as pl
6
+
7
+ from .utility import DataProxy
8
+
9
+
10
+ def cs_rank(feature: DataProxy) -> DataProxy:
11
+ """Perform cross-sectional ranking"""
12
+ df: pl.DataFrame = feature.df.select(
13
+ pl.col("datetime"),
14
+ pl.col("vt_symbol"),
15
+ pl.col("data").rank().over("datetime")
16
+ )
17
+ return DataProxy(df)
18
+
19
+
20
+ def cs_mean(feature: DataProxy) -> DataProxy:
21
+ """Calculate cross-sectional mean"""
22
+ df: pl.DataFrame = feature.df.select(
23
+ pl.col("datetime"),
24
+ pl.col("vt_symbol"),
25
+ pl.col("data").mean().over("datetime")
26
+ )
27
+ return DataProxy(df)
28
+
29
+
30
+ def cs_std(feature: DataProxy) -> DataProxy:
31
+ """Calculate cross-sectional standard deviation"""
32
+ df: pl.DataFrame = feature.df.select(
33
+ pl.col("datetime"),
34
+ pl.col("vt_symbol"),
35
+ pl.col("data").std().over("datetime")
36
+ )
37
+ return DataProxy(df)
38
+
39
+
40
+ def cs_sum(feature: DataProxy) -> DataProxy:
41
+ """Calculate cross-sectional sum"""
42
+ df: pl.DataFrame = feature.df.select(
43
+ pl.col("datetime"),
44
+ pl.col("vt_symbol"),
45
+ pl.col("data").sum().over("datetime")
46
+ )
47
+ return DataProxy(df)
48
+
49
+
50
+ def cs_scale(feature: DataProxy) -> DataProxy:
51
+ """Scale the feature by the sum of absolute values in the cross section"""
52
+ abs_feature = abs(feature)
53
+ sum_abs = cs_sum(abs_feature)
54
+
55
+ df_merged: pl.DataFrame = feature.df.join(sum_abs.df, on=["datetime", "vt_symbol"], suffix="_sum")
56
+
57
+ df: pl.DataFrame = df_merged.with_columns(
58
+ pl.when(pl.col("data_sum") != 0)
59
+ .then(pl.col("data") / pl.col("data_sum"))
60
+ .otherwise(0)
61
+ .alias("data")
62
+ ).select(["datetime", "vt_symbol", "data"])
63
+
64
+ return DataProxy(df)
@@ -0,0 +1,330 @@
1
+ import polars as pl
2
+
3
+ from vnpy.alpha import AlphaDataset
4
+
5
+
6
+ class Alpha101(AlphaDataset):
7
+ """101 basic factors from WorldQuant"""
8
+
9
+ def __init__(
10
+ self,
11
+ df: pl.DataFrame,
12
+ train_period: tuple[str, str],
13
+ valid_period: tuple[str, str],
14
+ test_period: tuple[str, str]
15
+ ) -> None:
16
+ """Constructor"""
17
+ super().__init__(
18
+ df=df,
19
+ train_period=train_period,
20
+ valid_period=valid_period,
21
+ test_period=test_period,
22
+ )
23
+
24
+ returns_expr: str = "(close / ts_delay(close, 1) - 1)"
25
+
26
+ # Alpha1
27
+ self.add_feature("alpha1", f"(cs_rank(ts_argmax(pow1(quesval(0, {returns_expr}, close, ts_std({returns_expr}, 20)), 2.0), 5)) - 0.5)")
28
+
29
+ # Alpha2
30
+ self.add_feature("alpha2", "(-1) * ts_corr(cs_rank(ts_delta(log(volume), 2)), cs_rank((close - open) / open), 6)")
31
+
32
+ # Alpha3
33
+ self.add_feature("alpha3", "ts_corr(cs_rank(open), cs_rank(volume), 10) * -1")
34
+
35
+ # Alpha4
36
+ self.add_feature("alpha4", "-1 * ts_rank(cs_rank(low), 9)")
37
+
38
+ # Alpha5
39
+ self.add_feature("alpha5", "cs_rank((open - (ts_sum(vwap, 10) / 10))) * (-1 * abs(cs_rank((close - vwap))))")
40
+
41
+ # Alpha6
42
+ self.add_feature("alpha6", "(-1) * ts_corr(open, volume, 10)")
43
+
44
+ # Alpha7
45
+ self.add_feature("alpha7", "quesval2(ts_mean(volume, 20), volume, (-1 * ts_rank(abs(close - ts_delay(close, 7)), 60)) * sign(ts_delta(close, 7)), -1)")
46
+
47
+ # Alpha8
48
+ self.add_feature("alpha8", f"-1 * cs_rank(((ts_sum(open, 5) * ts_sum({returns_expr}, 5)) - ts_delay((ts_sum(open, 5) * ts_sum({returns_expr}, 5)), 10)))")
49
+
50
+ # Alpha9
51
+ self.add_feature("alpha9", "quesval(0, ts_min(ts_delta(close, 1), 5), ts_delta(close, 1), quesval(0, ts_max(ts_delta(close, 1), 5), (-1 * ts_delta(close, 1)), ts_delta(close, 1)))")
52
+
53
+ # Alpha10
54
+ self.add_feature("alpha10", "cs_rank(quesval(0, ts_min(ts_delta(close, 1), 4), ts_delta(close, 1), quesval(0, ts_max(ts_delta(close, 1), 4), (-1 * ts_delta(close, 1)), ts_delta(close, 1))))")
55
+
56
+ # Alpha11
57
+ self.add_feature("alpha11", "(cs_rank(ts_max(vwap - close, 3)) + cs_rank(ts_min(vwap - close, 3))) * cs_rank(ts_delta(volume, 3))")
58
+
59
+ # Alpha12
60
+ self.add_feature("alpha12", "sign(ts_delta(volume, 1)) * (-1 * ts_delta(close, 1))")
61
+
62
+ # Alpha13
63
+ self.add_feature("alpha13", "-1 * cs_rank(ts_cov(cs_rank(close), cs_rank(volume), 5))")
64
+
65
+ # Alpha14
66
+ self.add_feature("alpha14", f"(-1 * cs_rank(({returns_expr}) - ts_delay({returns_expr}, 3))) * ts_corr(open, volume, 10)")
67
+
68
+ # Alpha15
69
+ self.add_feature("alpha15", "-1 * ts_sum(cs_rank(ts_corr(cs_rank(high), cs_rank(volume), 3)), 3)")
70
+
71
+ # Alpha16
72
+ self.add_feature("alpha16", "-1 * cs_rank(ts_cov(cs_rank(high), cs_rank(volume), 5))")
73
+
74
+ # Alpha17
75
+ self.add_feature("alpha17", "(-1 * cs_rank(ts_rank(close, 10))) * cs_rank(close - 2 * ts_delay(close, 1) + ts_delay(close, 2)) * cs_rank(ts_rank(volume / ts_mean(volume, 20), 5))")
76
+
77
+ # Alpha18
78
+ self.add_feature("alpha18", "-1 * cs_rank((ts_std(abs(close - open), 5) + (close - open)) + ts_corr(close, open, 10))")
79
+
80
+ # Alpha19
81
+ self.add_feature("alpha19", f"(-1 * sign(ts_delta(close, 7) + (close - ts_delay(close, 7)))) * (cs_rank(ts_sum({returns_expr}, 250) + 1) + 1)")
82
+
83
+ # Alpha20
84
+ self.add_feature("alpha20", "(-1 * cs_rank(open - ts_delay(high, 1))) * cs_rank(open - ts_delay(close, 1)) * cs_rank(open - ts_delay(low, 1))")
85
+
86
+ # Alpha21 (the innermost original was >=1, implemented as >1)
87
+ self.add_feature("alpha21", "quesval2((ts_mean(close, 8) + ts_std(close, 8)), ts_mean(close, 2), -1, quesval2(ts_mean(close, 2), (ts_mean(close, 8) - ts_std(close, 8)), 1, quesval(1, (volume / ts_mean(volume, 20)), 1, -1)))")
88
+
89
+ # Alpha22
90
+ self.add_feature("alpha22", "-1 * ts_delta(ts_corr(high, volume, 5), 5) * cs_rank(ts_std(close, 20))")
91
+
92
+ # Alpha23
93
+ self.add_feature("alpha23", "quesval2(ts_mean(high, 20), high, -1 * ts_delta(high, 2), 0)")
94
+
95
+ # Alpha24 (the original condition was <=0.05, implemented as <0.05)
96
+ self.add_feature("alpha24", "quesval(0.05, ts_delta(ts_sum(close, 100) / 100, 100) / ts_delay(close, 100), (-1 * ts_delta(close, 3)), (-1 * (close - ts_min(close, 100))))")
97
+
98
+ # Alpha25
99
+ self.add_feature("alpha25", f"cs_rank( (-1 * {returns_expr}) * ts_mean(volume, 20) * vwap * (high - close) )")
100
+
101
+ # Alpha26
102
+ self.add_feature("alpha26", "-1 * ts_max(ts_corr(ts_rank(volume, 5), ts_rank(high, 5), 5), 3)")
103
+
104
+ # Alpha27
105
+ self.add_feature("alpha27", "quesval(0.5, cs_rank(ts_mean(ts_corr(cs_rank(volume), cs_rank(vwap), 6), 2)), -1, 1)")
106
+
107
+ # Alpha28
108
+ self.add_feature("alpha28", "cs_scale(ts_corr(ts_mean(volume, 20), low, 5) + (high + low) / 2 - close)")
109
+
110
+ # Alpha29
111
+ self.add_feature("alpha29", f"ts_min(ts_product(cs_rank(cs_rank(cs_scale(log(ts_sum(ts_min(cs_rank(cs_rank((-1 * cs_rank(ts_delta((close - 1), 5))))), 2), 1))))), 1), 5) + ts_rank(ts_delay((-1 * {returns_expr}), 6), 5)")
112
+
113
+ # Alpha30
114
+ self.add_feature("alpha30", "((cs_rank(sign(close - ts_delay(close, 1)) + sign(ts_delay(close, 1) - ts_delay(close, 2)) + sign(ts_delay(close, 2) - ts_delay(close, 3))) * -1 + 1) * ts_sum(volume, 5)) / ts_sum(volume, 20)")
115
+
116
+ # Alpha31
117
+ self.add_feature("alpha31", "(cs_rank(cs_rank(cs_rank(ts_decay_linear((-1) * cs_rank(cs_rank(ts_delta(close, 10))), 10)))) + cs_rank((-1) * ts_delta(close, 3))) + sign(cs_scale(ts_corr(ts_mean(volume, 20), low, 12)))")
118
+
119
+ # Alpha32
120
+ self.add_feature("alpha32", "cs_scale((ts_sum(close, 7) / 7 - close)) + (20 * cs_scale(ts_corr(vwap, ts_delay(close, 5), 230)))")
121
+
122
+ # Alpha33
123
+ self.add_feature("alpha33", "cs_rank((-1) * (open / close * -1 + 1))")
124
+
125
+ # Alpha34
126
+ self.add_feature("alpha34", f"cs_rank((cs_rank(ts_std({returns_expr}, 2) / ts_std({returns_expr}, 5)) * -1 + 1) + (cs_rank(ts_delta(close, 1)) * -1 + 1))")
127
+
128
+ # Alpha35
129
+ self.add_feature("alpha35", f"(ts_rank(volume, 32) * (ts_rank((close + high - low), 16) * -1 + 1)) * (ts_rank({returns_expr}, 32) * -1 + 1)")
130
+
131
+ # Alpha36
132
+ self.add_feature("alpha36", f"((((2.21 * cs_rank(ts_corr((close - open), ts_delay(volume, 1), 15))) + (0.7 * cs_rank((open - close)))) + (0.73 * cs_rank(ts_rank(ts_delay((-1) * {returns_expr}, 6), 5)))) + cs_rank(abs(ts_corr(vwap, ts_mean(volume, 20), 6)))) + (0.6 * cs_rank(((ts_sum(close, 200) / 200 - open) * (close - open))))")
133
+
134
+ # Alpha37
135
+ self.add_feature("alpha37", "cs_rank(ts_corr(ts_delay((open - close), 1), close, 200)) + cs_rank((open - close))")
136
+
137
+ # Alpha38
138
+ self.add_feature("alpha38", "((-1) * cs_rank(ts_rank(close, 10))) * cs_rank((close / open))")
139
+
140
+ # Alpha39
141
+ self.add_feature("alpha39", f"((-1) * cs_rank((ts_delta(close, 7) * (cs_rank(ts_decay_linear((volume / ts_mean(volume, 20)), 9)) * -1 + 1)))) * (cs_rank(ts_sum({returns_expr}, 250)) + 1)")
142
+
143
+ # Alpha40
144
+ self.add_feature("alpha40", "((-1) * cs_rank(ts_std(high, 10))) * ts_corr(high, volume, 10)")
145
+
146
+ # Alpha41
147
+ self.add_feature("alpha41", "pow1((high * low), 0.5) - vwap")
148
+
149
+ # Alpha42
150
+ self.add_feature("alpha42", "cs_rank((vwap - close)) / cs_rank((vwap + close))")
151
+
152
+ # Alpha43
153
+ self.add_feature("alpha43", "ts_rank((volume / ts_mean(volume, 20)), 20) * ts_rank((-1) * ts_delta(close, 7), 8)")
154
+
155
+ # Alpha44
156
+ self.add_feature("alpha44", "(-1) * ts_corr(high, cs_rank(volume), 5)")
157
+
158
+ # Alpha45
159
+ self.add_feature("alpha45", "(-1) * cs_rank(ts_sum(ts_delay(close, 5), 20) / 20) * ts_corr(close, volume, 2) * cs_rank(ts_corr(ts_sum(close, 5), ts_sum(close, 20), 2))")
160
+
161
+ # Alpha46
162
+ self.add_feature("alpha46", "quesval(0.25, ((ts_delay(close, 20) - ts_delay(close, 10)) / 10 - (ts_delay(close, 10) - close) / 10), -1, quesval(0, ((ts_delay(close, 20) - ts_delay(close, 10)) / 10 - (ts_delay(close, 10) - close) / 10), (-1) * (close - ts_delay(close, 1)), 1))")
163
+
164
+ # Alpha47
165
+ self.add_feature("alpha47", "((cs_rank(pow1(close, -1)) * volume / ts_mean(volume, 20)) * (high * cs_rank(high - close)) / (ts_sum(high, 5) / 5)) - cs_rank(vwap - ts_delay(vwap, 5))")
166
+
167
+ # Alpha48 (contains `IndNeutralize`, currently not implemented)
168
+ # self.add_feature("alpha48", "(ts_corr(ts_delta(close, 1), ts_delta(ts_delay(close, 1), 1), 250) * ts_delta(close, 1)) / close / ts_sum(pow1((ts_delta(close, 1) / ts_delay(close, 1)), 2), 250)")
169
+
170
+ # Alpha49
171
+ self.add_feature("alpha49", "quesval(-0.1, ((ts_delay(close, 20) - ts_delay(close, 10)) / 10 - (ts_delay(close, 10) - close) / 10), (-1) * (close - ts_delay(close, 1)), 1)")
172
+
173
+ # Alpha50
174
+ self.add_feature("alpha50", "(-1) * ts_max(cs_rank(ts_corr(cs_rank(volume), cs_rank(vwap), 5)), 5)")
175
+
176
+ # Alpha51
177
+ self.add_feature("alpha51", "quesval(-0.05, ((ts_delay(close, 20) - ts_delay(close, 10)) / 10 - (ts_delay(close, 10) - close) / 10), (-1) * (close - ts_delay(close, 1)), 1)")
178
+
179
+ # Alpha52
180
+ self.add_feature("alpha52", f"(((-1) * ts_min(low, 5)) + ts_delay(ts_min(low, 5), 5)) * cs_rank((ts_sum({returns_expr}, 240) - ts_sum({returns_expr}, 20)) / 220) * ts_rank(volume, 5)")
181
+
182
+ # Alpha53
183
+ self.add_feature("alpha53", "(-1) * ts_delta(((close - low) - (high - close)) / (close - low), 9)")
184
+
185
+ # Alpha54
186
+ self.add_feature("alpha54", "((-1) * ((low - close) * pow1(open, 5))) / ((low - high) * pow1(close, 5))")
187
+
188
+ # Alpha55
189
+ self.add_feature("alpha55", "(-1) * ts_corr(cs_rank((close - ts_min(low, 12)) / (ts_max(high, 12) - ts_min(low, 12))), cs_rank(volume), 6)")
190
+
191
+ # Alpha56 (missing `cap` field, cannot be implemented)
192
+ # original formula: (0 - (1 * (rank((sum(returns, 10) / sum(sum(returns, 2), 3))) * rank((returns * cap)))))
193
+
194
+ # Alpha57
195
+ self.add_feature("alpha57", "-1 * ((close - vwap) / ts_decay_linear(cs_rank(ts_argmax(close, 30)), 2))")
196
+
197
+ # Alpha58 (contains `IndNeutralize`, currently not implemented)
198
+ # self.add_feature("alpha58", "(-1) * ts_rank(ts_decay_linear(ts_corr(vwap, volume, 4), 8), 6)")
199
+
200
+ # Alpha59 (contains `IndNeutralize`, currently not implemented)
201
+ # self.add_feature("alpha59", "(-1) * ts_rank(ts_decay_linear(ts_corr(((vwap * 0.728317) + (vwap * (1 - 0.728317))), volume, 4), 16), 8)")
202
+
203
+ # Alpha60
204
+ self.add_feature("alpha60", "- 1 * ((2 * cs_scale(cs_rank((((close - low) - (high - close)) / (high - low)) * volume))) - cs_scale(cs_rank(ts_argmax(close, 10))))")
205
+
206
+ # Alpha61
207
+ self.add_feature("alpha61", "quesval2(cs_rank(vwap - ts_min(vwap, 16)), cs_rank(ts_corr(vwap, ts_mean(volume, 180), 18)), 1, 0)")
208
+
209
+ # Alpha62
210
+ self.add_feature("alpha62", "(cs_rank(ts_corr(vwap, ts_sum(ts_mean(volume, 20), 22), 10)) < cs_rank((cs_rank(open) + cs_rank(open)) < (cs_rank((high + low) / 2) + cs_rank(high)))) * -1")
211
+
212
+ # Alpha63 (contains `IndNeutralize`, currently not implemented)
213
+ # self.add_feature("alpha63", "(cs_rank(ts_decay_linear(ts_delta(close, 2), 8)) - cs_rank(ts_decay_linear(ts_corr(vwap * 0.318108 + open * 0.681892, ts_sum(ts_mean(volume, 180), 37), 14), 12))) * -1")
214
+
215
+ # Alpha64
216
+ self.add_feature("alpha64", "(cs_rank(ts_corr(ts_sum(((open * 0.178404) + (low * (1 - 0.178404))), 13), ts_sum(ts_mean(volume, 120), 13), 17)) < cs_rank(ts_delta((((high + low) / 2 * 0.178404) + (vwap * (1 - 0.178404))), 4))) * -1")
217
+
218
+ # Alpha65
219
+ self.add_feature("alpha65", "(cs_rank(ts_corr(((open * 0.00817205) + (vwap * (1 - 0.00817205))), ts_sum(ts_mean(volume, 60), 9), 6)) < cs_rank(open - ts_min(open, 14))) * -1")
220
+
221
+ # Alpha66
222
+ self.add_feature("alpha66", "(cs_rank(ts_decay_linear(ts_delta(vwap, 4), 7)) + ts_rank(ts_decay_linear((((low * 0.96633) + (low * (1 - 0.96633))) - vwap) / (open - ((high + low) / 2)), 11), 7)) * -1")
223
+
224
+ # Alpha67 (contains `IndNeutralize`, currently not implemented)
225
+ # self.add_feature("alpha67", "pow2(cs_rank(high - ts_min(high, 2)), cs_rank(ts_corr(vwap, ts_mean(volume, 20), 6))) * -1")
226
+
227
+ # Alpha68
228
+ self.add_feature("alpha68", "(ts_rank(ts_corr(cs_rank(high), cs_rank(ts_mean(volume, 15)), 9), 14) < cs_rank(ts_delta((close * 0.518371 + low * (1 - 0.518371)), 1))) * -1")
229
+
230
+ # Alpha69 (contains `IndNeutralize`, currently not implemented)
231
+ # self.add_feature("alpha69", "pow2(cs_rank(ts_max(ts_delta(vwap, 3), 5)), ts_rank(ts_corr(close * 0.490655 + vwap * 0.509345, ts_mean(volume, 20), 5), 9)) * -1")
232
+
233
+ # Alpha70 (contains `IndNeutralize`, currently not implemented)
234
+ # self.add_feature("alpha70", "pow2(cs_rank(ts_delta(vwap, 1)), ts_rank(ts_corr(close, ts_mean(volume, 50), 18), 18)) * -1")
235
+
236
+ # Alpha71
237
+ self.add_feature("alpha71", "ts_greater(ts_rank(ts_decay_linear(ts_corr(ts_rank(close, 3), ts_rank(ts_mean(volume, 180), 12), 18), 4), 16), ts_rank(ts_decay_linear(pow1(cs_rank((low + open) - (vwap + vwap)), 2), 16), 4))")
238
+
239
+ # Alpha72
240
+ self.add_feature("alpha72", "cs_rank(ts_decay_linear(ts_corr((high + low) / 2, ts_mean(volume, 40), 9), 10)) / cs_rank(ts_decay_linear(ts_corr(ts_rank(vwap, 4), ts_rank(volume, 19), 7), 3))")
241
+
242
+ # Alpha73
243
+ self.add_feature("alpha73", "ts_greater(cs_rank(ts_decay_linear(ts_delta(vwap, 5), 3)), ts_rank(ts_decay_linear((ts_delta(open * 0.147155 + low * 0.852845, 2) / (open * 0.147155 + low * 0.852845)) * -1, 3), 17)) * -1")
244
+
245
+ # Alpha74
246
+ self.add_feature("alpha74", "quesval2(cs_rank(ts_corr(close, ts_sum(ts_mean(volume, 30), 37), 15)), cs_rank(ts_corr(cs_rank(high * 0.0261661 + vwap * 0.9738339), cs_rank(volume), 11)), 1, 0) * -1")
247
+
248
+ # Alpha75
249
+ self.add_feature("alpha75", "quesval2(cs_rank(ts_corr(vwap, volume, 4)), cs_rank(ts_corr(cs_rank(low), cs_rank(ts_mean(volume, 50)), 12)), 1, 0)")
250
+
251
+ # Alpha76 (contains `IndNeutralize`, currently not implemented)
252
+ # self.add_feature("alpha76", "ts_greater(cs_rank(ts_decay_linear(ts_delta(vwap, 1), 12)), ts_rank(ts_decay_linear(ts_rank(ts_corr(low, ts_mean(volume, 81), 8), 20), 17), 19)) * -1")
253
+
254
+ # Alpha77
255
+ self.add_feature("alpha77", "ts_less(cs_rank(ts_decay_linear((((high + low) / 2 + high) - (vwap + high)), 20)), cs_rank(ts_decay_linear(ts_corr((high + low) / 2, ts_mean(volume, 40), 3), 6)))")
256
+
257
+ # Alpha78
258
+ self.add_feature("alpha78", "pow2(cs_rank(ts_corr(ts_sum((low * 0.352233) + (vwap * (1 - 0.352233)), 20), ts_sum(ts_mean(volume, 40), 20), 7)), cs_rank(ts_corr(cs_rank(vwap), cs_rank(volume), 6)))")
259
+
260
+ # Alpha79 (contains `IndNeutralize`, currently not implemented)
261
+ # self.add_feature("alpha79", "quesval2(cs_rank(ts_delta(close * 0.60733 + open * 0.39267, 1)), cs_rank(ts_corr(ts_rank(vwap, 4), ts_rank(ts_mean(volume, 150), 9), 15)), 1, 0)")
262
+
263
+ # Alpha80 (contains `IndNeutralize`, currently not implemented)
264
+ # self.add_feature("alpha80", "pow2(cs_rank(sign(ts_delta(open * 0.868128 + high * 0.131872, 4))), ts_rank(ts_corr(high, ts_mean(volume, 10), 5), 6)) * -1")
265
+
266
+ # Alpha81
267
+ self.add_feature("alpha81", "quesval2(cs_rank(log(ts_product(cs_rank(pow1(cs_rank(ts_corr(vwap, ts_sum(ts_mean(volume, 10), 50), 8)), 4)), 15))), cs_rank(ts_corr(cs_rank(vwap), cs_rank(volume), 5)), 1, 0) * -1")
268
+
269
+ # Alpha82 (contains `IndNeutralize`, currently not implemented)
270
+ # self.add_feature("alpha82", "ts_less(cs_rank(ts_decay_linear(ts_delta(open, 1), 15)), ts_rank(ts_decay_linear(ts_corr(volume, open, 17), 7), 13)) * -1")
271
+
272
+ # Alpha83
273
+ self.add_feature("alpha83", "(cs_rank(ts_delay((high - low) / (ts_sum(close, 5) / 5), 2)) * cs_rank(cs_rank(volume))) / (((high - low) / (ts_sum(close, 5) / 5)) / (vwap - close))")
274
+
275
+ # Alpha84
276
+ self.add_feature("alpha84", "pow2(ts_rank(vwap - ts_max(vwap, 15), 21), ts_delta(close, 5))")
277
+
278
+ # Alpha85
279
+ self.add_feature("alpha85", "pow2(cs_rank(ts_corr(high * 0.876703 + close * 0.123297, ts_mean(volume, 30), 10)), cs_rank(ts_corr(ts_rank((high + low) / 2, 4), ts_rank(volume, 10), 7)))")
280
+
281
+ # Alpha86
282
+ self.add_feature("alpha86", "quesval2(ts_rank(ts_corr(close, ts_sum(ts_mean(volume, 20), 15), 6), 20), cs_rank((open + close) - (vwap + open)), 1, 0) * -1")
283
+
284
+ # Alpha87 (contains `IndNeutralize`, currently not implemented)
285
+ # self.add_feature("alpha87", "ts_greater(cs_rank(ts_decay_linear(ts_delta(close * 0.369701 + vwap * 0.630299, 2), 3)), ts_rank(ts_decay_linear(abs(ts_corr(ts_mean(volume, 81), close, 13)), 5), 14)) * -1")
286
+
287
+ # Alpha88
288
+ self.add_feature("alpha88", "ts_less(cs_rank(ts_decay_linear((cs_rank(open) + cs_rank(low)) - (cs_rank(high) + cs_rank(close)), 8)), ts_rank(ts_decay_linear(ts_corr(ts_rank(close, 8), ts_rank(ts_mean(volume, 60), 21), 8), 7), 3))")
289
+
290
+ # Alpha89 (contains `IndNeutralize`, currently not implemented)
291
+ # self.add_feature("alpha89", "(ts_rank(ts_decay_linear(ts_corr(low, ts_mean(volume, 10), 7), 6), 4) - ts_rank(ts_decay_linear(ts_delta(vwap, 3), 10), 15))")
292
+
293
+ # Alpha90 (contains `IndNeutralize`, currently not implemented)
294
+ # self.add_feature("alpha90", "pow2(cs_rank(close - ts_max(close, 5)), ts_rank(ts_corr(ts_mean(volume, 40), low, 5), 3)) * -1")
295
+
296
+ # Alpha91 (contains `IndNeutralize`, currently not implemented)
297
+ # self.add_feature("alpha91", "(ts_rank(ts_decay_linear(ts_decay_linear(ts_corr(close, volume, 10), 16), 4), 5) - cs_rank(ts_decay_linear(ts_corr(vwap, ts_mean(volume, 30), 4), 3))) * -1")
298
+
299
+ # Alpha92
300
+ self.add_feature("alpha92", "ts_less(ts_rank(ts_decay_linear(quesval2(((high + low) / 2 + close), (low + open), 1, 0), 15), 19), ts_rank(ts_decay_linear(ts_corr(cs_rank(low), cs_rank(ts_mean(volume, 30)), 8), 7), 7))")
301
+
302
+ # Alpha93 (contains `IndNeutralize`, currently not implemented)
303
+ # self.add_feature("alpha93", "ts_rank(ts_decay_linear(ts_corr(vwap, ts_mean(volume, 81), 17), 20), 8) / cs_rank(ts_decay_linear(ts_delta(close * 0.524434 + vwap * 0.475566, 3), 16))")
304
+
305
+ # Alpha94
306
+ self.add_feature("alpha94", "pow2(cs_rank(vwap - ts_min(vwap, 12)), ts_rank(ts_corr(ts_rank(vwap, 20), ts_rank(ts_mean(volume, 60), 4), 18), 3)) * -1")
307
+
308
+ # Alpha95
309
+ self.add_feature("alpha95", "quesval2(cs_rank(open - ts_min(open, 12)), ts_rank(pow1(cs_rank(ts_corr(ts_sum((high + low) / 2, 19), ts_sum(ts_mean(volume, 40), 19), 13)), 5), 12), 1, 0)")
310
+
311
+ # Alpha96
312
+ self.add_feature("alpha96", "ts_greater(ts_rank(ts_decay_linear(ts_corr(cs_rank(vwap), cs_rank(volume), 4), 4), 8), ts_rank(ts_decay_linear(ts_argmax(ts_corr(ts_rank(close, 7), ts_rank(ts_mean(volume, 60), 4), 4), 13), 14), 13)) * -1")
313
+
314
+ # Alpha97 (contains `IndNeutralize`, currently not implemented)
315
+ # self.add_feature("alpha97", "(cs_rank(ts_decay_linear(ts_delta(low * 0.721001 + vwap * 0.278999, 3), 20)) - ts_rank(ts_decay_linear(ts_rank(ts_corr(ts_rank(low, 8), ts_rank(ts_mean(volume, 60), 17), 5), 19), 16), 7)) * -1")
316
+
317
+ # Alpha98
318
+ self.add_feature("alpha98", "cs_rank(ts_decay_linear(ts_corr(vwap, ts_sum(ts_mean(volume, 5), 26), 5), 7)) - cs_rank(ts_decay_linear(ts_rank(ts_argmin(ts_corr(cs_rank(open), cs_rank(ts_mean(volume, 15)), 21), 9), 7), 8))")
319
+
320
+ # Alpha99
321
+ self.add_feature("alpha99", "quesval2(cs_rank(ts_corr(ts_sum((high + low) / 2, 20), ts_sum(ts_mean(volume, 60), 20), 9)), cs_rank(ts_corr(low, volume, 6)), 1, 0) * -1")
322
+
323
+ # Alpha100 (contains `IndNeutralize`, currently not implemented)
324
+ # self.add_feature("alpha100", "-1 * ((1.5 * cs_scale(cs_rank(((close - low) - (high - close)) / (high - low) * volume))) - cs_scale(ts_corr(close, cs_rank(ts_mean(volume, 20)), 5) - cs_rank(ts_argmin(close, 30)))) * (volume / ts_mean(volume, 20))")
325
+
326
+ # Alpha101
327
+ self.add_feature("alpha101", "((close - open) / ((high - low) + 0.001))")
328
+
329
+ # Set label
330
+ self.set_label("ts_delay(close, -3) / ts_delay(close, -1) - 1")