deeptrade-quant 0.1.0__tar.gz → 0.3.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.
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/PKG-INFO +65 -48
- deeptrade_quant-0.3.0/README.md +150 -0
- deeptrade_quant-0.3.0/deeptrade/__init__.py +6 -0
- deeptrade_quant-0.3.0/deeptrade/core/__init__.py +7 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/config_migrations.py +65 -6
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/db.py +6 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/migrations/core/20260509_001_init.sql +1 -1
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/plugin_manager.py +3 -4
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/plugins_api/__init__.py +0 -12
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/plugins_api/base.py +2 -6
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/plugins_api/metadata.py +1 -3
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/pyproject.toml +1 -1
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/cli/test_plugin_cmd.py +21 -16
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/core/test_config_migrations.py +77 -3
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/plugins_api/test_protocol.py +3 -20
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/test_smoke.py +1 -2
- deeptrade_quant-0.1.0/README.md +0 -133
- deeptrade_quant-0.1.0/deeptrade/__init__.py +0 -8
- deeptrade_quant-0.1.0/deeptrade/channels_builtin/stdout/deeptrade_plugin.yaml +0 -25
- deeptrade_quant-0.1.0/deeptrade/channels_builtin/stdout/migrations/20260509_001_init.sql +0 -13
- deeptrade_quant-0.1.0/deeptrade/channels_builtin/stdout/stdout_channel/channel.py +0 -180
- deeptrade_quant-0.1.0/deeptrade/core/__init__.py +0 -8
- deeptrade_quant-0.1.0/deeptrade/core/notifier.py +0 -304
- deeptrade_quant-0.1.0/deeptrade/plugins_api/channel.py +0 -42
- deeptrade_quant-0.1.0/deeptrade/plugins_api/notify.py +0 -67
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/__init__.py +0 -0
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/deeptrade_plugin.yaml +0 -83
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/limit_up_board/__init__.py +0 -0
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/limit_up_board/calendar.py +0 -65
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/limit_up_board/cli.py +0 -269
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/limit_up_board/config.py +0 -76
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/limit_up_board/data.py +0 -1191
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/limit_up_board/pipeline.py +0 -869
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/limit_up_board/plugin.py +0 -30
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/limit_up_board/profiles.py +0 -85
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/limit_up_board/prompts.py +0 -485
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/limit_up_board/render.py +0 -890
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/limit_up_board/runner.py +0 -1087
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/limit_up_board/runtime.py +0 -164
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/limit_up_board/schemas.py +0 -178
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/limit_up_board/migrations/20260509_001_init.sql +0 -188
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/__init__.py +0 -0
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/deeptrade_plugin.yaml +0 -53
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/migrations/20260509_001_init.sql +0 -111
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/volume_anomaly/__init__.py +0 -0
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/volume_anomaly/calendar.py +0 -52
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/volume_anomaly/cli.py +0 -246
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/volume_anomaly/data.py +0 -2157
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/volume_anomaly/pipeline.py +0 -327
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/volume_anomaly/plugin.py +0 -22
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/volume_anomaly/profiles.py +0 -49
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/volume_anomaly/prompts.py +0 -187
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/volume_anomaly/prompts_examples.py +0 -84
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/volume_anomaly/render.py +0 -906
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/volume_anomaly/runner.py +0 -772
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/volume_anomaly/runtime.py +0 -84
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/volume_anomaly/schemas.py +0 -97
- deeptrade_quant-0.1.0/deeptrade/strategies_builtin/volume_anomaly/volume_anomaly/stats.py +0 -174
- deeptrade_quant-0.1.0/tests/__init__.py +0 -0
- deeptrade_quant-0.1.0/tests/cli/__init__.py +0 -0
- deeptrade_quant-0.1.0/tests/core/__init__.py +0 -0
- deeptrade_quant-0.1.0/tests/core/test_notifier.py +0 -189
- deeptrade_quant-0.1.0/tests/plugins_api/__init__.py +0 -0
- deeptrade_quant-0.1.0/tests/plugins_api/test_notify.py +0 -94
- deeptrade_quant-0.1.0/tests/strategies_builtin/__init__.py +0 -0
- deeptrade_quant-0.1.0/tests/strategies_builtin/limit_up_board/__init__.py +0 -0
- deeptrade_quant-0.1.0/tests/strategies_builtin/limit_up_board/test_phase_a_factors.py +0 -250
- deeptrade_quant-0.1.0/tests/strategies_builtin/limit_up_board/test_phase_b_factors.py +0 -164
- deeptrade_quant-0.1.0/tests/strategies_builtin/limit_up_board/test_v04_settings.py +0 -150
- deeptrade_quant-0.1.0/tests/strategies_builtin/volume_anomaly/__init__.py +0 -0
- deeptrade_quant-0.1.0/tests/strategies_builtin/volume_anomaly/test_alpha_features.py +0 -201
- deeptrade_quant-0.1.0/tests/strategies_builtin/volume_anomaly/test_candidate_features.py +0 -343
- deeptrade_quant-0.1.0/tests/strategies_builtin/volume_anomaly/test_dimension_scores.py +0 -128
- deeptrade_quant-0.1.0/tests/strategies_builtin/volume_anomaly/test_prompt_consistency.py +0 -185
- deeptrade_quant-0.1.0/tests/strategies_builtin/volume_anomaly/test_realized_returns.py +0 -165
- deeptrade_quant-0.1.0/tests/strategies_builtin/volume_anomaly/test_screen_rules.py +0 -224
- deeptrade_quant-0.1.0/tests/strategies_builtin/volume_anomaly/test_stats_query.py +0 -166
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/.gitignore +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/LICENSE +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/cli.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/cli_config.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/cli_data.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/cli_plugin.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/config.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/github_fetch.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/llm_client.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/llm_manager.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/logging_config.py +0 -0
- {deeptrade_quant-0.1.0/deeptrade/channels_builtin → deeptrade_quant-0.3.0/deeptrade/core/migrations}/__init__.py +0 -0
- {deeptrade_quant-0.1.0/deeptrade/channels_builtin/stdout → deeptrade_quant-0.3.0/deeptrade/core/migrations/core}/__init__.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/paths.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/plugin_source.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/registry.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/run_status.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/secrets.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/tushare_client.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/plugins_api/events.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/plugins_api/llm.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/theme.py +0 -0
- {deeptrade_quant-0.1.0/deeptrade/channels_builtin/stdout/stdout_channel → deeptrade_quant-0.3.0/tests}/__init__.py +0 -0
- {deeptrade_quant-0.1.0/deeptrade/core/migrations → deeptrade_quant-0.3.0/tests/cli}/__init__.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/cli/test_config_cmd.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/cli/test_routing.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/conftest.py +0 -0
- {deeptrade_quant-0.1.0/deeptrade/core/migrations → deeptrade_quant-0.3.0/tests}/core/__init__.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/core/test_config.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/core/test_db.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/core/test_github_fetch.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/core/test_llm_client.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/core/test_llm_manager.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/core/test_paths.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/core/test_plugin_install.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/core/test_plugin_source.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/core/test_plugin_upgrade.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/core/test_registry.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/core/test_secrets.py +0 -0
- {deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/tests/core/test_tushare_client.py +0 -0
- {deeptrade_quant-0.1.0/deeptrade/strategies_builtin → deeptrade_quant-0.3.0/tests/plugins_api}/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deeptrade-quant
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: LLM-driven A-share (Shanghai/Shenzhen main board) stock screening CLI
|
|
5
5
|
Project-URL: Homepage, https://github.com/ty19880929/deeptrade
|
|
6
6
|
Project-URL: Repository, https://github.com/ty19880929/deeptrade
|
|
@@ -34,29 +34,38 @@ Description-Content-Type: text/markdown
|
|
|
34
34
|
|
|
35
35
|
# DeepTrade
|
|
36
36
|
|
|
37
|
-
> 本地运行的 A 股(沪深主板)选股 CLI
|
|
37
|
+
> 本地运行的 A 股(沪深主板)选股 CLI 框架:tushare 行情 + OpenAI 兼容 LLM(DeepSeek / Qwen / Kimi …)+ DuckDB 单机仓库 + 纯透传式插件 CLI。框架不携带任何业务策略,所有策略按需从官方注册表安装。
|
|
38
38
|
|
|
39
|
-
[
|
|
39
|
+
> 📖 **在线文档**:[deeptrade.tiey.ai](https://deeptrade.tiey.ai) — 用户手册 + 开发者手册 + 官方插件目录
|
|
40
|
+
|
|
41
|
+
[](#) [](#) [](LICENSE) [](CHANGELOG.md)
|
|
40
42
|
|
|
41
43
|
## ✨ 主要特性
|
|
42
44
|
|
|
43
45
|
- **轻量本地化**:单文件 DuckDB + uv,一条命令跑完,无需服务进程或容器。
|
|
44
|
-
-
|
|
46
|
+
- **框架与插件物理解耦**:`deeptrade-quant` wheel 只含框架(`init / config / plugin / data`),所有策略走 `deeptrade plugin install <短名>` 从注册表安装。
|
|
47
|
+
- **纯透传式插件 CLI**:未知首词一律按 `deeptrade <plugin_id> <argv...>` 透传给插件,插件自管 `--help`、子命令、参数、持久化。
|
|
45
48
|
- **数据隔离(Plan A)**:每个插件在自己的 migrations 里声明并拥有自己的表(含 tushare 派生数据),框架不持有任何业务表。`tushare_sync_state` / `tushare_calls` / `llm_calls` 都按 `plugin_id` 维度隔离。
|
|
46
|
-
- **顶层通知 API**:`from deeptrade import notify, notification_session` 一行发推送;框架根据已安装的 channel 插件自动路由,无 channel 时自动 noop。
|
|
47
49
|
- **多 LLM Provider 共存**:`llm.providers` 字典化配置,多个 OpenAI 兼容服务并存;插件通过 `LLMManager.get_client(name=...)` 按名取用,单次 run 内可调多家。
|
|
48
50
|
- **LLM 强约束**:JSON 模式 + Pydantic 双层校验;**永远**不传 tools / function calls。
|
|
49
|
-
- **盘中数据隔离**:`--allow-intraday` 模式下同步的不完整数据写入 `data_completeness='intraday'`,日终模式严格拒绝命中。
|
|
50
51
|
|
|
51
52
|
## 🚀 5 分钟上手
|
|
52
53
|
|
|
53
|
-
###
|
|
54
|
+
### 安装框架
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# 推荐:pipx 隔离环境(命令名仍是 deeptrade)
|
|
58
|
+
pipx install deeptrade-quant
|
|
59
|
+
# 或
|
|
60
|
+
uv tool install deeptrade-quant
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> **注**:PyPI 项目名是 `deeptrade-quant`,CLI 命令是 `deeptrade`,Python 包名是 `deeptrade`(`import deeptrade`)。三者不同是 Python 生态常态(同 `pip install scikit-learn` → `import sklearn`)。
|
|
54
64
|
|
|
55
65
|
```bash
|
|
56
|
-
#
|
|
66
|
+
# 开发模式(克隆本仓库,editable install)
|
|
57
67
|
uv sync --all-extras
|
|
58
68
|
uv run pre-commit install
|
|
59
|
-
|
|
60
69
|
# 兜底(无 uv)
|
|
61
70
|
python -m venv .venv && source .venv/bin/activate # Windows: .\.venv\Scripts\activate
|
|
62
71
|
pip install -e ".[dev]"
|
|
@@ -65,7 +74,7 @@ pip install -e ".[dev]"
|
|
|
65
74
|
### 初始化与配置
|
|
66
75
|
|
|
67
76
|
```bash
|
|
68
|
-
deeptrade init # 建库 + 应用 core migrations
|
|
77
|
+
deeptrade init # 建库 + 应用 core migrations(交互式可选配 tushare / LLM)
|
|
69
78
|
deeptrade config set-tushare # 交互式输入 tushare token
|
|
70
79
|
deeptrade config set-llm # 交互式增/改/删 LLM provider(deepseek / qwen / kimi …)
|
|
71
80
|
deeptrade config list-llm # 列出已配置且可用的 provider
|
|
@@ -73,12 +82,18 @@ deeptrade config test-llm # 对所有 provider 做连通性自
|
|
|
73
82
|
deeptrade config show # 表格展示当前配置(密钥脱敏)
|
|
74
83
|
```
|
|
75
84
|
|
|
76
|
-
###
|
|
85
|
+
### 安装官方插件并运行
|
|
86
|
+
|
|
87
|
+
官方插件维护在 [DeepTradePluginOfficial](https://github.com/ty19880929/DeepTradePluginOfficial),框架按短名查注册表 → 拉 GitHub release tarball 自动安装。
|
|
77
88
|
|
|
78
89
|
```bash
|
|
79
|
-
#
|
|
80
|
-
deeptrade plugin
|
|
81
|
-
deeptrade plugin
|
|
90
|
+
# 浏览注册表
|
|
91
|
+
deeptrade plugin search # 全量列出
|
|
92
|
+
deeptrade plugin search anomaly # 关键词过滤
|
|
93
|
+
|
|
94
|
+
# 按短名安装(注册表 → 该插件最新 release tag)
|
|
95
|
+
deeptrade plugin install limit-up-board
|
|
96
|
+
deeptrade plugin install volume-anomaly
|
|
82
97
|
|
|
83
98
|
deeptrade plugin list # 查看已安装
|
|
84
99
|
|
|
@@ -87,15 +102,19 @@ deeptrade limit-up-board --help
|
|
|
87
102
|
deeptrade limit-up-board run # 默认日终模式
|
|
88
103
|
deeptrade limit-up-board run --allow-intraday --force-sync
|
|
89
104
|
|
|
90
|
-
#
|
|
105
|
+
# 运行成交量异动策略
|
|
91
106
|
deeptrade volume-anomaly screen # 异动筛选 → upsert va_watchlist
|
|
92
107
|
deeptrade volume-anomaly analyze # LLM 主升浪启动预测
|
|
93
|
-
deeptrade volume-anomaly
|
|
94
|
-
|
|
95
|
-
# 推送链路自检
|
|
96
|
-
deeptrade stdout-channel test
|
|
108
|
+
deeptrade volume-anomaly evaluate # T+N 自动回测闭环
|
|
109
|
+
deeptrade volume-anomaly stats # 收益统计聚合
|
|
97
110
|
```
|
|
98
111
|
|
|
112
|
+
> **第三方 / 本地开发插件**:`deeptrade plugin install <SOURCE>` 三种来源统一处理,判定顺序为 *本地目录存在 → git URL → 注册表短名*:
|
|
113
|
+
>
|
|
114
|
+
> - `deeptrade plugin install ./path/to/my-plugin` — 本地目录
|
|
115
|
+
> - `deeptrade plugin install https://github.com/owner/repo` — 完整 git 仓库(仓库根需含 `deeptrade_plugin.yaml`)
|
|
116
|
+
> - `deeptrade plugin install my-plugin --ref v1.2.0` — 指定 tag/branch/sha
|
|
117
|
+
|
|
99
118
|
报告产出在 `~/.deeptrade/reports/<run_id>/`。
|
|
100
119
|
|
|
101
120
|
## 📦 命令矩阵
|
|
@@ -107,26 +126,27 @@ deeptrade stdout-channel test
|
|
|
107
126
|
| `deeptrade --version` / `-V` | 显示版本 |
|
|
108
127
|
| `deeptrade --help` / `-h` | 框架命令清单(**不**枚举插件子命令) |
|
|
109
128
|
| `deeptrade init [--no-prompts]` | 建库 + 应用 core migrations |
|
|
129
|
+
| `deeptrade db init` / `db upgrade` | 显式建库 / 应用待执行迁移 |
|
|
110
130
|
| `deeptrade config {show, set, set-tushare, set-llm, list-llm, test-llm}` | 全局配置 |
|
|
111
|
-
| `deeptrade plugin
|
|
112
|
-
| `deeptrade plugin
|
|
113
|
-
| `deeptrade plugin
|
|
131
|
+
| `deeptrade plugin search [keyword] [--no-cache]` | 浏览官方注册表 |
|
|
132
|
+
| `deeptrade plugin install <SOURCE> [--ref <REF>] [-y]` | 注册表短名 / GitHub URL / 本地路径 |
|
|
133
|
+
| `deeptrade plugin list` / `info <id>` | 列表 / 详情(未安装时回退注册表条目) |
|
|
134
|
+
| `deeptrade plugin enable <id>` / `disable <id>` | 启 / 停 |
|
|
114
135
|
| `deeptrade plugin uninstall <id> [--purge]` | 卸载(`--purge` 才 DROP 表) |
|
|
115
|
-
| `deeptrade plugin upgrade <
|
|
116
|
-
| `deeptrade data sync ...` |
|
|
136
|
+
| `deeptrade plugin upgrade <SOURCE> [--ref <REF>]` | 升级(SemVer 比较,禁止降级;增量 migrations) |
|
|
137
|
+
| `deeptrade data sync ...` | (暂停用,下版本恢复;改用插件自带的 sync 子命令) |
|
|
117
138
|
|
|
118
|
-
保留字(不可作为 plugin_id):`init / config / plugin / data`。
|
|
139
|
+
保留字(不可作为 plugin_id):`init / config / plugin / data / db`。
|
|
119
140
|
|
|
120
141
|
### 插件命令(按 plugin_id 透传,插件自管)
|
|
121
142
|
|
|
122
|
-
| 命令 |
|
|
143
|
+
| 命令 | 来源(注册表短名) |
|
|
123
144
|
|---|---|
|
|
124
|
-
| `deeptrade limit-up-board {run, sync, history, report}` |
|
|
125
|
-
| `deeptrade volume-anomaly {screen, analyze, prune, history, report}` |
|
|
126
|
-
| `deeptrade stdout-channel {test, log}` | 内建 stdout 通知插件 |
|
|
145
|
+
| `deeptrade limit-up-board {run, sync, history, report, settings}` | `limit-up-board`(strategy) |
|
|
146
|
+
| `deeptrade volume-anomaly {screen, analyze, evaluate, stats, prune, history, report}` | `volume-anomaly`(strategy) |
|
|
127
147
|
| `deeptrade <你的-plugin-id> ...` | 你自己写的任何插件 |
|
|
128
148
|
|
|
129
|
-
任意插件子命令的 `--help`
|
|
149
|
+
任意插件子命令的 `--help` 都由插件自身渲染——框架不感知动词语义。各插件的最新子命令、参数与运行手册见 [DeepTradePluginOfficial](https://github.com/ty19880929/DeepTradePluginOfficial)。
|
|
130
150
|
|
|
131
151
|
## 🧱 架构
|
|
132
152
|
|
|
@@ -134,33 +154,30 @@ deeptrade stdout-channel test
|
|
|
134
154
|
┌──────────────────────── deeptrade CLI (custom click.Group) ────────────────────────┐
|
|
135
155
|
│ │
|
|
136
156
|
│ framework commands (closed): │
|
|
137
|
-
│ init │ config │ plugin │ data
|
|
157
|
+
│ init │ config │ plugin │ data │ db │
|
|
138
158
|
│ │
|
|
139
159
|
│ plugin pass-through (open): │
|
|
140
160
|
│ <plugin_id> ──argv──→ Plugin.dispatch(argv) → int (plugin owns the rest) │
|
|
141
161
|
└──────────────────────────────────┬─────────────────────────────────────────────────┘
|
|
142
162
|
│
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
163
|
+
│
|
|
164
|
+
┌────────────────┴────────────────┐
|
|
165
|
+
▼ ▼
|
|
166
|
+
┌──────────────────┐ ┌────────────────────┐
|
|
167
|
+
│ Core services │ │ Plugins (strategy)│
|
|
168
|
+
│ DuckDB · Config │ │ • metadata │
|
|
169
|
+
│ Tushare · LLM │ │ • validate_static │
|
|
170
|
+
└──────────────────┘ │ • dispatch(argv) │
|
|
171
|
+
└────────────────────┘
|
|
152
172
|
```
|
|
153
173
|
|
|
154
|
-
|
|
174
|
+
每个插件通过自己的 migrations 声明并拥有 `<prefix>_*` 业务表;`tushare_sync_state` / `tushare_calls` / `llm_calls` 按 `plugin_id` 维度隔离,`__framework__` 为框架自身保留 sentinel。
|
|
155
175
|
|
|
156
|
-
## 📖
|
|
176
|
+
## 📖 参考
|
|
157
177
|
|
|
158
|
-
- [
|
|
159
|
-
- [
|
|
160
|
-
-
|
|
161
|
-
- [docs/plugin-development.md](docs/plugin-development.md) — 写一个新插件
|
|
162
|
-
- [docs/limit-up-board.md](docs/limit-up-board.md) — 打板策略说明
|
|
163
|
-
- [CHANGELOG.md](CHANGELOG.md) — 版本变更
|
|
178
|
+
- [CHANGELOG.md](CHANGELOG.md) — 版本变更与历次 breaking change 记录
|
|
179
|
+
- [DeepTradePluginOfficial](https://github.com/ty19880929/DeepTradePluginOfficial) — 官方插件源码、注册表、各插件运行手册
|
|
180
|
+
- 历史快照 `archive/with-builtin-plugins-v0.1.0-preview` — 含 builtin 子树的最后一版状态(v0.2.0 之前)
|
|
164
181
|
|
|
165
182
|
## ⚖️ 免责声明
|
|
166
183
|
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# DeepTrade
|
|
2
|
+
|
|
3
|
+
> 本地运行的 A 股(沪深主板)选股 CLI 框架:tushare 行情 + OpenAI 兼容 LLM(DeepSeek / Qwen / Kimi …)+ DuckDB 单机仓库 + 纯透传式插件 CLI。框架不携带任何业务策略,所有策略按需从官方注册表安装。
|
|
4
|
+
|
|
5
|
+
> 📖 **在线文档**:[deeptrade.tiey.ai](https://deeptrade.tiey.ai) — 用户手册 + 开发者手册 + 官方插件目录
|
|
6
|
+
|
|
7
|
+
[](#) [](#) [](LICENSE) [](CHANGELOG.md)
|
|
8
|
+
|
|
9
|
+
## ✨ 主要特性
|
|
10
|
+
|
|
11
|
+
- **轻量本地化**:单文件 DuckDB + uv,一条命令跑完,无需服务进程或容器。
|
|
12
|
+
- **框架与插件物理解耦**:`deeptrade-quant` wheel 只含框架(`init / config / plugin / data`),所有策略走 `deeptrade plugin install <短名>` 从注册表安装。
|
|
13
|
+
- **纯透传式插件 CLI**:未知首词一律按 `deeptrade <plugin_id> <argv...>` 透传给插件,插件自管 `--help`、子命令、参数、持久化。
|
|
14
|
+
- **数据隔离(Plan A)**:每个插件在自己的 migrations 里声明并拥有自己的表(含 tushare 派生数据),框架不持有任何业务表。`tushare_sync_state` / `tushare_calls` / `llm_calls` 都按 `plugin_id` 维度隔离。
|
|
15
|
+
- **多 LLM Provider 共存**:`llm.providers` 字典化配置,多个 OpenAI 兼容服务并存;插件通过 `LLMManager.get_client(name=...)` 按名取用,单次 run 内可调多家。
|
|
16
|
+
- **LLM 强约束**:JSON 模式 + Pydantic 双层校验;**永远**不传 tools / function calls。
|
|
17
|
+
|
|
18
|
+
## 🚀 5 分钟上手
|
|
19
|
+
|
|
20
|
+
### 安装框架
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# 推荐:pipx 隔离环境(命令名仍是 deeptrade)
|
|
24
|
+
pipx install deeptrade-quant
|
|
25
|
+
# 或
|
|
26
|
+
uv tool install deeptrade-quant
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> **注**:PyPI 项目名是 `deeptrade-quant`,CLI 命令是 `deeptrade`,Python 包名是 `deeptrade`(`import deeptrade`)。三者不同是 Python 生态常态(同 `pip install scikit-learn` → `import sklearn`)。
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# 开发模式(克隆本仓库,editable install)
|
|
33
|
+
uv sync --all-extras
|
|
34
|
+
uv run pre-commit install
|
|
35
|
+
# 兜底(无 uv)
|
|
36
|
+
python -m venv .venv && source .venv/bin/activate # Windows: .\.venv\Scripts\activate
|
|
37
|
+
pip install -e ".[dev]"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 初始化与配置
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
deeptrade init # 建库 + 应用 core migrations(交互式可选配 tushare / LLM)
|
|
44
|
+
deeptrade config set-tushare # 交互式输入 tushare token
|
|
45
|
+
deeptrade config set-llm # 交互式增/改/删 LLM provider(deepseek / qwen / kimi …)
|
|
46
|
+
deeptrade config list-llm # 列出已配置且可用的 provider
|
|
47
|
+
deeptrade config test-llm # 对所有 provider 做连通性自检(也可加 <name> 单测)
|
|
48
|
+
deeptrade config show # 表格展示当前配置(密钥脱敏)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 安装官方插件并运行
|
|
52
|
+
|
|
53
|
+
官方插件维护在 [DeepTradePluginOfficial](https://github.com/ty19880929/DeepTradePluginOfficial),框架按短名查注册表 → 拉 GitHub release tarball 自动安装。
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# 浏览注册表
|
|
57
|
+
deeptrade plugin search # 全量列出
|
|
58
|
+
deeptrade plugin search anomaly # 关键词过滤
|
|
59
|
+
|
|
60
|
+
# 按短名安装(注册表 → 该插件最新 release tag)
|
|
61
|
+
deeptrade plugin install limit-up-board
|
|
62
|
+
deeptrade plugin install volume-anomaly
|
|
63
|
+
|
|
64
|
+
deeptrade plugin list # 查看已安装
|
|
65
|
+
|
|
66
|
+
# 运行打板策略(CLI 由插件自管,--help 由插件渲染)
|
|
67
|
+
deeptrade limit-up-board --help
|
|
68
|
+
deeptrade limit-up-board run # 默认日终模式
|
|
69
|
+
deeptrade limit-up-board run --allow-intraday --force-sync
|
|
70
|
+
|
|
71
|
+
# 运行成交量异动策略
|
|
72
|
+
deeptrade volume-anomaly screen # 异动筛选 → upsert va_watchlist
|
|
73
|
+
deeptrade volume-anomaly analyze # LLM 主升浪启动预测
|
|
74
|
+
deeptrade volume-anomaly evaluate # T+N 自动回测闭环
|
|
75
|
+
deeptrade volume-anomaly stats # 收益统计聚合
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
> **第三方 / 本地开发插件**:`deeptrade plugin install <SOURCE>` 三种来源统一处理,判定顺序为 *本地目录存在 → git URL → 注册表短名*:
|
|
79
|
+
>
|
|
80
|
+
> - `deeptrade plugin install ./path/to/my-plugin` — 本地目录
|
|
81
|
+
> - `deeptrade plugin install https://github.com/owner/repo` — 完整 git 仓库(仓库根需含 `deeptrade_plugin.yaml`)
|
|
82
|
+
> - `deeptrade plugin install my-plugin --ref v1.2.0` — 指定 tag/branch/sha
|
|
83
|
+
|
|
84
|
+
报告产出在 `~/.deeptrade/reports/<run_id>/`。
|
|
85
|
+
|
|
86
|
+
## 📦 命令矩阵
|
|
87
|
+
|
|
88
|
+
### 框架命令(封闭集合)
|
|
89
|
+
|
|
90
|
+
| 命令 | 用途 |
|
|
91
|
+
|---|---|
|
|
92
|
+
| `deeptrade --version` / `-V` | 显示版本 |
|
|
93
|
+
| `deeptrade --help` / `-h` | 框架命令清单(**不**枚举插件子命令) |
|
|
94
|
+
| `deeptrade init [--no-prompts]` | 建库 + 应用 core migrations |
|
|
95
|
+
| `deeptrade db init` / `db upgrade` | 显式建库 / 应用待执行迁移 |
|
|
96
|
+
| `deeptrade config {show, set, set-tushare, set-llm, list-llm, test-llm}` | 全局配置 |
|
|
97
|
+
| `deeptrade plugin search [keyword] [--no-cache]` | 浏览官方注册表 |
|
|
98
|
+
| `deeptrade plugin install <SOURCE> [--ref <REF>] [-y]` | 注册表短名 / GitHub URL / 本地路径 |
|
|
99
|
+
| `deeptrade plugin list` / `info <id>` | 列表 / 详情(未安装时回退注册表条目) |
|
|
100
|
+
| `deeptrade plugin enable <id>` / `disable <id>` | 启 / 停 |
|
|
101
|
+
| `deeptrade plugin uninstall <id> [--purge]` | 卸载(`--purge` 才 DROP 表) |
|
|
102
|
+
| `deeptrade plugin upgrade <SOURCE> [--ref <REF>]` | 升级(SemVer 比较,禁止降级;增量 migrations) |
|
|
103
|
+
| `deeptrade data sync ...` | (暂停用,下版本恢复;改用插件自带的 sync 子命令) |
|
|
104
|
+
|
|
105
|
+
保留字(不可作为 plugin_id):`init / config / plugin / data / db`。
|
|
106
|
+
|
|
107
|
+
### 插件命令(按 plugin_id 透传,插件自管)
|
|
108
|
+
|
|
109
|
+
| 命令 | 来源(注册表短名) |
|
|
110
|
+
|---|---|
|
|
111
|
+
| `deeptrade limit-up-board {run, sync, history, report, settings}` | `limit-up-board`(strategy) |
|
|
112
|
+
| `deeptrade volume-anomaly {screen, analyze, evaluate, stats, prune, history, report}` | `volume-anomaly`(strategy) |
|
|
113
|
+
| `deeptrade <你的-plugin-id> ...` | 你自己写的任何插件 |
|
|
114
|
+
|
|
115
|
+
任意插件子命令的 `--help` 都由插件自身渲染——框架不感知动词语义。各插件的最新子命令、参数与运行手册见 [DeepTradePluginOfficial](https://github.com/ty19880929/DeepTradePluginOfficial)。
|
|
116
|
+
|
|
117
|
+
## 🧱 架构
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
┌──────────────────────── deeptrade CLI (custom click.Group) ────────────────────────┐
|
|
121
|
+
│ │
|
|
122
|
+
│ framework commands (closed): │
|
|
123
|
+
│ init │ config │ plugin │ data │ db │
|
|
124
|
+
│ │
|
|
125
|
+
│ plugin pass-through (open): │
|
|
126
|
+
│ <plugin_id> ──argv──→ Plugin.dispatch(argv) → int (plugin owns the rest) │
|
|
127
|
+
└──────────────────────────────────┬─────────────────────────────────────────────────┘
|
|
128
|
+
│
|
|
129
|
+
│
|
|
130
|
+
┌────────────────┴────────────────┐
|
|
131
|
+
▼ ▼
|
|
132
|
+
┌──────────────────┐ ┌────────────────────┐
|
|
133
|
+
│ Core services │ │ Plugins (strategy)│
|
|
134
|
+
│ DuckDB · Config │ │ • metadata │
|
|
135
|
+
│ Tushare · LLM │ │ • validate_static │
|
|
136
|
+
└──────────────────┘ │ • dispatch(argv) │
|
|
137
|
+
└────────────────────┘
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
每个插件通过自己的 migrations 声明并拥有 `<prefix>_*` 业务表;`tushare_sync_state` / `tushare_calls` / `llm_calls` 按 `plugin_id` 维度隔离,`__framework__` 为框架自身保留 sentinel。
|
|
141
|
+
|
|
142
|
+
## 📖 参考
|
|
143
|
+
|
|
144
|
+
- [CHANGELOG.md](CHANGELOG.md) — 版本变更与历次 breaking change 记录
|
|
145
|
+
- [DeepTradePluginOfficial](https://github.com/ty19880929/DeepTradePluginOfficial) — 官方插件源码、注册表、各插件运行手册
|
|
146
|
+
- 历史快照 `archive/with-builtin-plugins-v0.1.0-preview` — 含 builtin 子树的最后一版状态(v0.2.0 之前)
|
|
147
|
+
|
|
148
|
+
## ⚖️ 免责声明
|
|
149
|
+
|
|
150
|
+
本工具仅用于策略研究、数据整理与候选标的分析,**不构成投资建议**,**不进行自动交易**。所有 LLM 输出基于提交的结构化数据,不引用任何外部信息源;用户应自行核验候选标的的最新状态后再做决策。
|
|
@@ -8,16 +8,22 @@ or already-migrated DB is a no-op.
|
|
|
8
8
|
|
|
9
9
|
v0.6 — deepseek.* → llm.providers / llm.<name>.api_key (DESIGN §0.7 / §10.5).
|
|
10
10
|
v0.7 — deepseek.profile → app.profile (DESIGN §10.1 update).
|
|
11
|
+
v0.3.0 — purge legacy channel-type plugin installs (channel type removed).
|
|
11
12
|
"""
|
|
12
13
|
|
|
13
14
|
from __future__ import annotations
|
|
14
15
|
|
|
15
16
|
import json
|
|
17
|
+
import logging
|
|
18
|
+
import shutil
|
|
19
|
+
from pathlib import Path
|
|
16
20
|
from typing import TYPE_CHECKING
|
|
17
21
|
|
|
18
22
|
if TYPE_CHECKING: # pragma: no cover
|
|
19
23
|
from deeptrade.core.db import Database
|
|
20
24
|
|
|
25
|
+
logger = logging.getLogger(__name__)
|
|
26
|
+
|
|
21
27
|
|
|
22
28
|
_LEGACY_KEYS = (
|
|
23
29
|
"deepseek.base_url",
|
|
@@ -95,9 +101,7 @@ def migrate_legacy_deepseek_keys(db: Database) -> bool:
|
|
|
95
101
|
# Rename secret. UPDATE-only avoids re-encrypting; if the destination
|
|
96
102
|
# row already exists (extremely unlikely on a non-migrated DB), prefer
|
|
97
103
|
# the legacy value as canonical and overwrite.
|
|
98
|
-
existing_dest = db.fetchone(
|
|
99
|
-
"SELECT 1 FROM secret_store WHERE key = 'llm.deepseek.api_key'"
|
|
100
|
-
)
|
|
104
|
+
existing_dest = db.fetchone("SELECT 1 FROM secret_store WHERE key = 'llm.deepseek.api_key'")
|
|
101
105
|
if existing_dest is not None:
|
|
102
106
|
db.execute("DELETE FROM secret_store WHERE key = 'llm.deepseek.api_key'")
|
|
103
107
|
db.execute(
|
|
@@ -134,9 +138,7 @@ def migrate_llm_default_provider(db: Database) -> bool:
|
|
|
134
138
|
if not isinstance(providers, dict) or not providers:
|
|
135
139
|
return False
|
|
136
140
|
|
|
137
|
-
has_default = any(
|
|
138
|
-
isinstance(v, dict) and bool(v.get("is_default")) for v in providers.values()
|
|
139
|
-
)
|
|
141
|
+
has_default = any(isinstance(v, dict) and bool(v.get("is_default")) for v in providers.values())
|
|
140
142
|
if has_default:
|
|
141
143
|
return False
|
|
142
144
|
|
|
@@ -154,6 +156,63 @@ def migrate_llm_default_provider(db: Database) -> bool:
|
|
|
154
156
|
return True
|
|
155
157
|
|
|
156
158
|
|
|
159
|
+
def migrate_purge_non_strategy_plugins(db: Database) -> list[str]:
|
|
160
|
+
"""Remove legacy non-``strategy`` plugin records (v0.3.0).
|
|
161
|
+
|
|
162
|
+
The ``channel`` plugin type was retired in v0.3.0 along with the framework
|
|
163
|
+
notifier. Any plugin row whose ``type`` is not ``'strategy'`` would now
|
|
164
|
+
fail :class:`PluginMetadata` validation on every ``list_all`` call, which
|
|
165
|
+
blocks the CLI hard. This migration silently:
|
|
166
|
+
|
|
167
|
+
1. Drops each legacy plugin's owned tables (respecting
|
|
168
|
+
``purge_on_uninstall``).
|
|
169
|
+
2. Deletes the rows in ``plugin_tables`` / ``plugin_schema_migrations``
|
|
170
|
+
/ ``plugins``.
|
|
171
|
+
3. Removes the on-disk install directory.
|
|
172
|
+
|
|
173
|
+
Idempotent: returns an empty list when no offending rows exist. Returns
|
|
174
|
+
the list of purged ``plugin_id`` values otherwise (caller logs them).
|
|
175
|
+
"""
|
|
176
|
+
rows = db.fetchall("SELECT plugin_id, type, install_path FROM plugins WHERE type != 'strategy'")
|
|
177
|
+
if not rows:
|
|
178
|
+
return []
|
|
179
|
+
|
|
180
|
+
purged: list[str] = []
|
|
181
|
+
for plugin_id, plugin_type, install_path in rows:
|
|
182
|
+
tables = db.fetchall(
|
|
183
|
+
"SELECT table_name, purge_on_uninstall FROM plugin_tables WHERE plugin_id = ?",
|
|
184
|
+
(plugin_id,),
|
|
185
|
+
)
|
|
186
|
+
with db.transaction():
|
|
187
|
+
for tname, purge_flag in tables:
|
|
188
|
+
if purge_flag:
|
|
189
|
+
try:
|
|
190
|
+
db.execute(f"DROP TABLE IF EXISTS {tname}") # noqa: S608 — name validated at install
|
|
191
|
+
except Exception: # noqa: BLE001 — best-effort cleanup
|
|
192
|
+
logger.warning(
|
|
193
|
+
"purge: failed to drop table %s owned by legacy plugin %s",
|
|
194
|
+
tname,
|
|
195
|
+
plugin_id,
|
|
196
|
+
)
|
|
197
|
+
db.execute("DELETE FROM plugin_tables WHERE plugin_id = ?", (plugin_id,))
|
|
198
|
+
db.execute("DELETE FROM plugin_schema_migrations WHERE plugin_id = ?", (plugin_id,))
|
|
199
|
+
db.execute("DELETE FROM plugins WHERE plugin_id = ?", (plugin_id,))
|
|
200
|
+
|
|
201
|
+
if install_path:
|
|
202
|
+
dest = Path(install_path)
|
|
203
|
+
if dest.exists():
|
|
204
|
+
shutil.rmtree(dest, ignore_errors=True)
|
|
205
|
+
|
|
206
|
+
logger.warning(
|
|
207
|
+
"purged legacy plugin %r (type=%r) — type retired in v0.3.0",
|
|
208
|
+
plugin_id,
|
|
209
|
+
plugin_type,
|
|
210
|
+
)
|
|
211
|
+
purged.append(plugin_id)
|
|
212
|
+
|
|
213
|
+
return purged
|
|
214
|
+
|
|
215
|
+
|
|
157
216
|
def migrate_legacy_deepseek_profile_key(db: Database) -> bool:
|
|
158
217
|
"""Migrate ``deepseek.profile`` → ``app.profile`` (v0.7).
|
|
159
218
|
|
|
@@ -167,6 +167,7 @@ def apply_core_migrations(db: Database) -> list[str]:
|
|
|
167
167
|
migrate_legacy_deepseek_keys,
|
|
168
168
|
migrate_legacy_deepseek_profile_key,
|
|
169
169
|
migrate_llm_default_provider,
|
|
170
|
+
migrate_purge_non_strategy_plugins,
|
|
170
171
|
)
|
|
171
172
|
|
|
172
173
|
if migrate_legacy_deepseek_keys(db):
|
|
@@ -177,4 +178,9 @@ def apply_core_migrations(db: Database) -> list[str]:
|
|
|
177
178
|
# v0.8 data migration — backfill is_default on existing providers.
|
|
178
179
|
if migrate_llm_default_provider(db):
|
|
179
180
|
newly.append("data:v08_llm_default_provider")
|
|
181
|
+
# v0.3.0 data migration — drop legacy non-strategy (channel) plugin rows
|
|
182
|
+
# so list_all() / PluginMetadata.model_validate don't crash on the
|
|
183
|
+
# retired type literal.
|
|
184
|
+
if migrate_purge_non_strategy_plugins(db):
|
|
185
|
+
newly.append("data:v030_purge_non_strategy_plugins")
|
|
180
186
|
return newly
|
{deeptrade_quant-0.1.0 → deeptrade_quant-0.3.0}/deeptrade/core/migrations/core/20260509_001_init.sql
RENAMED
|
@@ -41,7 +41,7 @@ CREATE TABLE IF NOT EXISTS plugins (
|
|
|
41
41
|
plugin_id VARCHAR PRIMARY KEY,
|
|
42
42
|
name VARCHAR NOT NULL,
|
|
43
43
|
version VARCHAR NOT NULL,
|
|
44
|
-
type VARCHAR NOT NULL, -- 'strategy'
|
|
44
|
+
type VARCHAR NOT NULL, -- 'strategy' (reserved for future plugin types)
|
|
45
45
|
api_version VARCHAR NOT NULL,
|
|
46
46
|
entrypoint VARCHAR NOT NULL,
|
|
47
47
|
install_path VARCHAR NOT NULL,
|
|
@@ -167,10 +167,9 @@ def _load_entrypoint(
|
|
|
167
167
|
def _build_validate_ctx(db: Database, meta: PluginMetadata) -> Any:
|
|
168
168
|
"""Build the framework's minimal ``PluginContext`` for ``validate_static``.
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
``dispatch`` from these primitives.
|
|
170
|
+
Every plugin shares the same narrow context shape: db + config + plugin_id.
|
|
171
|
+
Plugins that need richer services (TushareClient, LLMManager / LLMClient, ...)
|
|
172
|
+
construct them inside their own ``dispatch`` from these primitives.
|
|
174
173
|
"""
|
|
175
174
|
from deeptrade.core.config import ConfigService
|
|
176
175
|
from deeptrade.plugins_api.base import PluginContext
|
|
@@ -4,8 +4,6 @@ All plugins import from this package; the rest of ``deeptrade.*`` is internal.
|
|
|
4
4
|
|
|
5
5
|
Stable surface (api_version = "1"):
|
|
6
6
|
- Plugin (Protocol), PluginContext — every plugin's contract: metadata + validate_static + dispatch
|
|
7
|
-
- ChannelPlugin (Protocol) — channel-specific extension (push hook)
|
|
8
|
-
- NotificationPayload, NotificationSection, NotificationItem — notify data contract
|
|
9
7
|
- PluginMetadata, TableSpec, MigrationSpec, PluginPermissions, ...
|
|
10
8
|
- StageProfile — LLM 调参档;插件持有 preset → stage 映射表,自行解析
|
|
11
9
|
"""
|
|
@@ -13,7 +11,6 @@ Stable surface (api_version = "1"):
|
|
|
13
11
|
from __future__ import annotations
|
|
14
12
|
|
|
15
13
|
from deeptrade.plugins_api.base import Plugin, PluginContext
|
|
16
|
-
from deeptrade.plugins_api.channel import ChannelPlugin
|
|
17
14
|
from deeptrade.plugins_api.llm import StageProfile
|
|
18
15
|
from deeptrade.plugins_api.metadata import (
|
|
19
16
|
MigrationSpec,
|
|
@@ -22,18 +19,9 @@ from deeptrade.plugins_api.metadata import (
|
|
|
22
19
|
TableSpec,
|
|
23
20
|
TushareApiPermissions,
|
|
24
21
|
)
|
|
25
|
-
from deeptrade.plugins_api.notify import (
|
|
26
|
-
NotificationItem,
|
|
27
|
-
NotificationPayload,
|
|
28
|
-
NotificationSection,
|
|
29
|
-
)
|
|
30
22
|
|
|
31
23
|
__all__ = [
|
|
32
|
-
"ChannelPlugin",
|
|
33
24
|
"MigrationSpec",
|
|
34
|
-
"NotificationItem",
|
|
35
|
-
"NotificationPayload",
|
|
36
|
-
"NotificationSection",
|
|
37
25
|
"Plugin",
|
|
38
26
|
"PluginContext",
|
|
39
27
|
"PluginMetadata",
|
|
@@ -6,10 +6,7 @@ NOTHING about the plugin's domain semantics; the plugin owns its own command
|
|
|
6
6
|
parsing, execution, persistence, and output.
|
|
7
7
|
|
|
8
8
|
``PluginContext`` is the minimal services bundle the framework hands to every
|
|
9
|
-
plugin's ``validate_static`` (during install)
|
|
10
|
-
(during notify). It lives here — alongside the base ``Plugin`` Protocol —
|
|
11
|
-
because it is the universal context for the base contract; channel-specific
|
|
12
|
-
extensions live in :mod:`deeptrade.plugins_api.channel`.
|
|
9
|
+
plugin's ``validate_static`` (during install).
|
|
13
10
|
"""
|
|
14
11
|
|
|
15
12
|
from __future__ import annotations
|
|
@@ -26,8 +23,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
26
23
|
@dataclass
|
|
27
24
|
class PluginContext:
|
|
28
25
|
"""Minimal services bundle the framework hands to a plugin's
|
|
29
|
-
``validate_static`` (during install)
|
|
30
|
-
(during notify).
|
|
26
|
+
``validate_static`` (during install).
|
|
31
27
|
|
|
32
28
|
Plugins that need richer services (TushareClient, LLMManager / LLMClient, etc.)
|
|
33
29
|
construct them inside their own ``dispatch`` from these primitives.
|
|
@@ -53,9 +53,7 @@ class PluginMetadata(BaseModel):
|
|
|
53
53
|
plugin_id: str = Field(..., pattern=r"^[a-z][a-z0-9-]{2,31}$")
|
|
54
54
|
name: str
|
|
55
55
|
version: str
|
|
56
|
-
|
|
57
|
-
# type='strategy' (or omitted) remains valid via the default.
|
|
58
|
-
type: Literal["strategy", "channel"] = "strategy"
|
|
56
|
+
type: Literal["strategy"] = "strategy"
|
|
59
57
|
api_version: str
|
|
60
58
|
entrypoint: str = Field(..., pattern=r"^[A-Za-z_][\w\.]*:[A-Za-z_]\w*$")
|
|
61
59
|
description: str
|