mlquantx 0.2.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.
Files changed (79) hide show
  1. mlquantx-0.2.5/LICENSE +21 -0
  2. mlquantx-0.2.5/NOTICE.md +5 -0
  3. mlquantx-0.2.5/PKG-INFO +108 -0
  4. mlquantx-0.2.5/PYPI_README.md +55 -0
  5. mlquantx-0.2.5/README.md +517 -0
  6. mlquantx-0.2.5/pyproject.toml +92 -0
  7. mlquantx-0.2.5/setup.cfg +4 -0
  8. mlquantx-0.2.5/src/mlquant/__init__.py +18 -0
  9. mlquantx-0.2.5/src/mlquant/backtest/__init__.py +14 -0
  10. mlquantx-0.2.5/src/mlquant/backtest/engine.py +118 -0
  11. mlquantx-0.2.5/src/mlquant/backtest/metrics.py +95 -0
  12. mlquantx-0.2.5/src/mlquant/cli/__init__.py +1 -0
  13. mlquantx-0.2.5/src/mlquant/cli/main.py +292 -0
  14. mlquantx-0.2.5/src/mlquant/configs/__init__.py +1 -0
  15. mlquantx-0.2.5/src/mlquant/configs/small.yaml +41 -0
  16. mlquantx-0.2.5/src/mlquant/data/__init__.py +88 -0
  17. mlquantx-0.2.5/src/mlquant/data/akshare_loader.py +168 -0
  18. mlquantx-0.2.5/src/mlquant/data/baostock_loader.py +137 -0
  19. mlquantx-0.2.5/src/mlquant/data/loaders.py +125 -0
  20. mlquantx-0.2.5/src/mlquant/data/panel.py +206 -0
  21. mlquantx-0.2.5/src/mlquant/data/synthetic.py +138 -0
  22. mlquantx-0.2.5/src/mlquant/data/yfinance_loader.py +101 -0
  23. mlquantx-0.2.5/src/mlquant/features/__init__.py +42 -0
  24. mlquantx-0.2.5/src/mlquant/features/_factors_add.py +288 -0
  25. mlquantx-0.2.5/src/mlquant/features/_factors_alpha101.py +98 -0
  26. mlquantx-0.2.5/src/mlquant/features/_factors_best.py +177 -0
  27. mlquantx-0.2.5/src/mlquant/features/_factors_better.py +385 -0
  28. mlquantx-0.2.5/src/mlquant/features/_factors_change.py +53 -0
  29. mlquantx-0.2.5/src/mlquant/features/_factors_extra.py +147 -0
  30. mlquantx-0.2.5/src/mlquant/features/_factors_market.py +61 -0
  31. mlquantx-0.2.5/src/mlquant/features/_factors_old.py +563 -0
  32. mlquantx-0.2.5/src/mlquant/features/_factors_original.py +215 -0
  33. mlquantx-0.2.5/src/mlquant/features/_factors_stock.py +270 -0
  34. mlquantx-0.2.5/src/mlquant/features/alpha101.py +84 -0
  35. mlquantx-0.2.5/src/mlquant/features/bias.py +81 -0
  36. mlquantx-0.2.5/src/mlquant/features/legacy_factors.py +126 -0
  37. mlquantx-0.2.5/src/mlquant/features/market_breadth.py +190 -0
  38. mlquantx-0.2.5/src/mlquant/features/neutralize.py +75 -0
  39. mlquantx-0.2.5/src/mlquant/features/target.py +62 -0
  40. mlquantx-0.2.5/src/mlquant/features/tensor_factors.py +301 -0
  41. mlquantx-0.2.5/src/mlquant/features.py +613 -0
  42. mlquantx-0.2.5/src/mlquant/models/__init__.py +8 -0
  43. mlquantx-0.2.5/src/mlquant/models/losses.py +88 -0
  44. mlquantx-0.2.5/src/mlquant/models/nets.py +62 -0
  45. mlquantx-0.2.5/src/mlquant/portfolio/__init__.py +5 -0
  46. mlquantx-0.2.5/src/mlquant/portfolio/frontier.py +49 -0
  47. mlquantx-0.2.5/src/mlquant/portfolio/markowitz.py +144 -0
  48. mlquantx-0.2.5/src/mlquant/training/__init__.py +6 -0
  49. mlquantx-0.2.5/src/mlquant/training/augment.py +89 -0
  50. mlquantx-0.2.5/src/mlquant/training/dataset.py +50 -0
  51. mlquantx-0.2.5/src/mlquant/training/trainer.py +108 -0
  52. mlquantx-0.2.5/src/mlquant/utils/__init__.py +5 -0
  53. mlquantx-0.2.5/src/mlquant/utils/config.py +60 -0
  54. mlquantx-0.2.5/src/mlquant/utils/seed.py +35 -0
  55. mlquantx-0.2.5/src/mlquantx.egg-info/PKG-INFO +108 -0
  56. mlquantx-0.2.5/src/mlquantx.egg-info/SOURCES.txt +77 -0
  57. mlquantx-0.2.5/src/mlquantx.egg-info/dependency_links.txt +1 -0
  58. mlquantx-0.2.5/src/mlquantx.egg-info/entry_points.txt +2 -0
  59. mlquantx-0.2.5/src/mlquantx.egg-info/requires.txt +30 -0
  60. mlquantx-0.2.5/src/mlquantx.egg-info/top_level.txt +1 -0
  61. mlquantx-0.2.5/tests/test_aggregate_validation_reports.py +57 -0
  62. mlquantx-0.2.5/tests/test_akshare.py +86 -0
  63. mlquantx-0.2.5/tests/test_akshare_csi300_full_pipeline.py +186 -0
  64. mlquantx-0.2.5/tests/test_alpha101.py +23 -0
  65. mlquantx-0.2.5/tests/test_audit_validation_report.py +77 -0
  66. mlquantx-0.2.5/tests/test_augment.py +41 -0
  67. mlquantx-0.2.5/tests/test_baostock.py +81 -0
  68. mlquantx-0.2.5/tests/test_benchmark_tensor_factors.py +15 -0
  69. mlquantx-0.2.5/tests/test_bias.py +25 -0
  70. mlquantx-0.2.5/tests/test_cli.py +95 -0
  71. mlquantx-0.2.5/tests/test_cost_drag_units.py +59 -0
  72. mlquantx-0.2.5/tests/test_export_huggingface_artifacts.py +88 -0
  73. mlquantx-0.2.5/tests/test_losses.py +29 -0
  74. mlquantx-0.2.5/tests/test_markowitz.py +38 -0
  75. mlquantx-0.2.5/tests/test_metrics.py +60 -0
  76. mlquantx-0.2.5/tests/test_neutralize.py +295 -0
  77. mlquantx-0.2.5/tests/test_public_data_validation.py +212 -0
  78. mlquantx-0.2.5/tests/test_synthetic.py +37 -0
  79. mlquantx-0.2.5/tests/test_tensor_factors.py +112 -0
mlquantx-0.2.5/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Yimin Du
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.
@@ -0,0 +1,5 @@
1
+ # Notices
2
+
3
+ This repository is distributed under the MIT License. Some optional third-party dependencies have their own licenses and terms.
4
+
5
+ In particular, MOSEK is an optional solver backend and may require a commercial or academic license from MOSEK ApS. The default install path uses open-source solvers available through `cvxpy`.
@@ -0,0 +1,108 @@
1
+ Metadata-Version: 2.4
2
+ Name: mlquantx
3
+ Version: 0.2.5
4
+ Summary: Reference implementation of ‘ML-Enhanced Multi-Factor Quantitative Trading’ (arXiv:2507.07107).
5
+ Author: Yimin Du
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/initial-d/ml-quant-trading
8
+ Project-URL: Documentation, https://initial-d.github.io/ml-quant-trading/
9
+ Project-URL: Paper, https://arxiv.org/abs/2507.07107
10
+ Project-URL: Issues, https://github.com/initial-d/ml-quant-trading/issues
11
+ Project-URL: Changelog, https://github.com/initial-d/ml-quant-trading/blob/main/CHANGELOG.md
12
+ Keywords: quant,alpha,factor,portfolio,pytorch,markowitz
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Financial and Insurance Industry
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Topic :: Office/Business :: Financial :: Investment
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ License-File: NOTICE.md
26
+ Requires-Dist: numpy>=1.24
27
+ Requires-Dist: pandas>=2.0
28
+ Requires-Dist: scipy>=1.10
29
+ Requires-Dist: scikit-learn>=1.3
30
+ Requires-Dist: torch>=2.0
31
+ Requires-Dist: cvxpy>=1.4
32
+ Requires-Dist: scs>=3.2
33
+ Requires-Dist: pyyaml>=6.0
34
+ Requires-Dist: click>=8.1
35
+ Requires-Dist: rich>=13.0
36
+ Requires-Dist: tqdm>=4.65
37
+ Requires-Dist: yfinance>=0.2.0
38
+ Requires-Dist: baostock>=0.8.8
39
+ Requires-Dist: akshare>=1.18.0
40
+ Provides-Extra: mosek
41
+ Requires-Dist: Mosek>=10.0; extra == "mosek"
42
+ Provides-Extra: ecos
43
+ Requires-Dist: ecos>=2.0; extra == "ecos"
44
+ Provides-Extra: gpu
45
+ Requires-Dist: cupy-cuda12x>=12.0; extra == "gpu"
46
+ Provides-Extra: dev
47
+ Requires-Dist: pytest>=7.4; extra == "dev"
48
+ Requires-Dist: pytest-cov>=4.1; extra == "dev"
49
+ Requires-Dist: ruff>=0.4; extra == "dev"
50
+ Requires-Dist: mypy>=1.7; extra == "dev"
51
+ Requires-Dist: hypothesis>=6.90; extra == "dev"
52
+ Dynamic: license-file
53
+
54
+ # mlquant
55
+
56
+ **A reproducible PyTorch research stack for machine-learning multi-factor
57
+ trading: 213 factors, bias correction, portfolio optimization, and vectorized
58
+ backtesting.**
59
+
60
+ [![CI](https://github.com/initial-d/ml-quant-trading/actions/workflows/ci.yml/badge.svg)](https://github.com/initial-d/ml-quant-trading/actions/workflows/ci.yml)
61
+ [![arXiv](https://img.shields.io/badge/arXiv-2507.07107-b31b1b.svg)](https://arxiv.org/abs/2507.07107)
62
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://www.python.org/downloads/)
63
+
64
+ ## Install and run
65
+
66
+ ```bash
67
+ python -m pip install mlquantx
68
+ mlquant demo
69
+ ```
70
+
71
+ The demo needs no market-data account or API key. It runs the deterministic
72
+ synthetic pipeline from data generation through 213 factor dimensions, model
73
+ training, portfolio construction, cost-aware backtesting, and Markdown/JSON
74
+ report generation. The default config ships inside the wheel, so the command
75
+ works outside a repository checkout.
76
+
77
+ ## What is included
78
+
79
+ - 204 hand-crafted factors plus 9 curated Alpha101-style factors
80
+ - mask-aware PyTorch tensor primitives for cross-sectional panels
81
+ - limit-up, limit-down, halt, and missing-data bias handling
82
+ - MLP and Transformer research baselines
83
+ - constrained Markowitz portfolio construction
84
+ - vectorized backtesting with turnover and transaction costs
85
+ - AkShare, Baostock, yfinance, and deterministic synthetic data paths
86
+ - auditable public-data validation reports, including negative results
87
+
88
+ ## Start here
89
+
90
+ - [Source and full documentation](https://github.com/initial-d/ml-quant-trading)
91
+ - [Google Colab quick start](https://colab.research.google.com/github/initial-d/ml-quant-trading/blob/main/notebooks/quickstart_colab.ipynb)
92
+ - [Public validation dashboard](https://github.com/initial-d/ml-quant-trading/blob/main/docs/validation_dashboard.md)
93
+ - [Research card and limitations](https://github.com/initial-d/ml-quant-trading/blob/main/docs/research_card.md)
94
+ - [100,000-row synthetic dataset](https://huggingface.co/datasets/dddyym/ml-quant-trading-synthetic)
95
+ - [213-input MLP checkpoint](https://huggingface.co/dddyym/ml-quant-trading-synthetic-mlp)
96
+ - [Paper: arXiv:2507.07107](https://arxiv.org/abs/2507.07107)
97
+
98
+ ## Research boundary
99
+
100
+ `mlquant` is research and educational software. It is not investment advice or
101
+ a production trading system. Synthetic smoke tests verify engineering behavior,
102
+ not profitability. Public-data backtests depend on data quality, survivorship,
103
+ transaction costs, slippage, and modeling assumptions and do not represent live
104
+ or guaranteed out-of-sample performance.
105
+
106
+ ## License
107
+
108
+ MIT. See the [repository license](https://github.com/initial-d/ml-quant-trading/blob/main/LICENSE).
@@ -0,0 +1,55 @@
1
+ # mlquant
2
+
3
+ **A reproducible PyTorch research stack for machine-learning multi-factor
4
+ trading: 213 factors, bias correction, portfolio optimization, and vectorized
5
+ backtesting.**
6
+
7
+ [![CI](https://github.com/initial-d/ml-quant-trading/actions/workflows/ci.yml/badge.svg)](https://github.com/initial-d/ml-quant-trading/actions/workflows/ci.yml)
8
+ [![arXiv](https://img.shields.io/badge/arXiv-2507.07107-b31b1b.svg)](https://arxiv.org/abs/2507.07107)
9
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://www.python.org/downloads/)
10
+
11
+ ## Install and run
12
+
13
+ ```bash
14
+ python -m pip install mlquantx
15
+ mlquant demo
16
+ ```
17
+
18
+ The demo needs no market-data account or API key. It runs the deterministic
19
+ synthetic pipeline from data generation through 213 factor dimensions, model
20
+ training, portfolio construction, cost-aware backtesting, and Markdown/JSON
21
+ report generation. The default config ships inside the wheel, so the command
22
+ works outside a repository checkout.
23
+
24
+ ## What is included
25
+
26
+ - 204 hand-crafted factors plus 9 curated Alpha101-style factors
27
+ - mask-aware PyTorch tensor primitives for cross-sectional panels
28
+ - limit-up, limit-down, halt, and missing-data bias handling
29
+ - MLP and Transformer research baselines
30
+ - constrained Markowitz portfolio construction
31
+ - vectorized backtesting with turnover and transaction costs
32
+ - AkShare, Baostock, yfinance, and deterministic synthetic data paths
33
+ - auditable public-data validation reports, including negative results
34
+
35
+ ## Start here
36
+
37
+ - [Source and full documentation](https://github.com/initial-d/ml-quant-trading)
38
+ - [Google Colab quick start](https://colab.research.google.com/github/initial-d/ml-quant-trading/blob/main/notebooks/quickstart_colab.ipynb)
39
+ - [Public validation dashboard](https://github.com/initial-d/ml-quant-trading/blob/main/docs/validation_dashboard.md)
40
+ - [Research card and limitations](https://github.com/initial-d/ml-quant-trading/blob/main/docs/research_card.md)
41
+ - [100,000-row synthetic dataset](https://huggingface.co/datasets/dddyym/ml-quant-trading-synthetic)
42
+ - [213-input MLP checkpoint](https://huggingface.co/dddyym/ml-quant-trading-synthetic-mlp)
43
+ - [Paper: arXiv:2507.07107](https://arxiv.org/abs/2507.07107)
44
+
45
+ ## Research boundary
46
+
47
+ `mlquant` is research and educational software. It is not investment advice or
48
+ a production trading system. Synthetic smoke tests verify engineering behavior,
49
+ not profitability. Public-data backtests depend on data quality, survivorship,
50
+ transaction costs, slippage, and modeling assumptions and do not represent live
51
+ or guaranteed out-of-sample performance.
52
+
53
+ ## License
54
+
55
+ MIT. See the [repository license](https://github.com/initial-d/ml-quant-trading/blob/main/LICENSE).