deeptrade-quant 0.2.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.2.0 → deeptrade_quant-0.3.0}/PKG-INFO +48 -47
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/README.md +47 -46
- deeptrade_quant-0.3.0/deeptrade/__init__.py +6 -0
- deeptrade_quant-0.3.0/deeptrade/core/__init__.py +7 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/config_migrations.py +65 -6
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/db.py +6 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/migrations/core/20260509_001_init.sql +1 -1
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/plugin_manager.py +3 -4
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/plugins_api/__init__.py +0 -12
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/plugins_api/base.py +2 -6
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/plugins_api/metadata.py +1 -3
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/pyproject.toml +1 -1
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/cli/test_plugin_cmd.py +21 -16
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/core/test_config_migrations.py +77 -3
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/plugins_api/test_protocol.py +3 -20
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/test_smoke.py +1 -2
- deeptrade_quant-0.2.0/deeptrade/__init__.py +0 -8
- deeptrade_quant-0.2.0/deeptrade/core/__init__.py +0 -8
- deeptrade_quant-0.2.0/deeptrade/core/notifier.py +0 -305
- deeptrade_quant-0.2.0/deeptrade/plugins_api/channel.py +0 -42
- deeptrade_quant-0.2.0/deeptrade/plugins_api/notify.py +0 -67
- deeptrade_quant-0.2.0/tests/core/test_notifier.py +0 -189
- deeptrade_quant-0.2.0/tests/plugins_api/test_notify.py +0 -94
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/.gitignore +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/LICENSE +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/cli.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/cli_config.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/cli_data.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/cli_plugin.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/config.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/github_fetch.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/llm_client.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/llm_manager.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/logging_config.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/migrations/__init__.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/migrations/core/__init__.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/paths.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/plugin_source.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/registry.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/run_status.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/secrets.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/core/tushare_client.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/plugins_api/events.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/plugins_api/llm.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/deeptrade/theme.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/__init__.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/cli/__init__.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/cli/test_config_cmd.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/cli/test_routing.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/conftest.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/core/__init__.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/core/test_config.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/core/test_db.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/core/test_github_fetch.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/core/test_llm_client.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/core/test_llm_manager.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/core/test_paths.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/core/test_plugin_install.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/core/test_plugin_source.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/core/test_plugin_upgrade.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/core/test_registry.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/core/test_secrets.py +0 -0
- {deeptrade_quant-0.2.0 → deeptrade_quant-0.3.0}/tests/core/test_tushare_client.py +0 -0
- {deeptrade_quant-0.2.0 → 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,23 +34,24 @@ 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
|
+
### 安装框架
|
|
54
55
|
|
|
55
56
|
```bash
|
|
56
57
|
# 推荐:pipx 隔离环境(命令名仍是 deeptrade)
|
|
@@ -73,7 +74,7 @@ pip install -e ".[dev]"
|
|
|
73
74
|
### 初始化与配置
|
|
74
75
|
|
|
75
76
|
```bash
|
|
76
|
-
deeptrade init # 建库 + 应用 core migrations
|
|
77
|
+
deeptrade init # 建库 + 应用 core migrations(交互式可选配 tushare / LLM)
|
|
77
78
|
deeptrade config set-tushare # 交互式输入 tushare token
|
|
78
79
|
deeptrade config set-llm # 交互式增/改/删 LLM provider(deepseek / qwen / kimi …)
|
|
79
80
|
deeptrade config list-llm # 列出已配置且可用的 provider
|
|
@@ -83,16 +84,16 @@ deeptrade config show # 表格展示当前配置(密钥脱
|
|
|
83
84
|
|
|
84
85
|
### 安装官方插件并运行
|
|
85
86
|
|
|
86
|
-
官方插件维护在 [DeepTradePluginOfficial](https://github.com/ty19880929/DeepTradePluginOfficial)
|
|
87
|
+
官方插件维护在 [DeepTradePluginOfficial](https://github.com/ty19880929/DeepTradePluginOfficial),框架按短名查注册表 → 拉 GitHub release tarball 自动安装。
|
|
87
88
|
|
|
88
89
|
```bash
|
|
89
90
|
# 浏览注册表
|
|
90
|
-
deeptrade plugin search
|
|
91
|
+
deeptrade plugin search # 全量列出
|
|
92
|
+
deeptrade plugin search anomaly # 关键词过滤
|
|
91
93
|
|
|
92
|
-
# 按短名安装(注册表 →
|
|
94
|
+
# 按短名安装(注册表 → 该插件最新 release tag)
|
|
93
95
|
deeptrade plugin install limit-up-board
|
|
94
96
|
deeptrade plugin install volume-anomaly
|
|
95
|
-
deeptrade plugin install stdout-channel
|
|
96
97
|
|
|
97
98
|
deeptrade plugin list # 查看已安装
|
|
98
99
|
|
|
@@ -101,16 +102,18 @@ deeptrade limit-up-board --help
|
|
|
101
102
|
deeptrade limit-up-board run # 默认日终模式
|
|
102
103
|
deeptrade limit-up-board run --allow-intraday --force-sync
|
|
103
104
|
|
|
104
|
-
#
|
|
105
|
+
# 运行成交量异动策略
|
|
105
106
|
deeptrade volume-anomaly screen # 异动筛选 → upsert va_watchlist
|
|
106
107
|
deeptrade volume-anomaly analyze # LLM 主升浪启动预测
|
|
107
|
-
deeptrade volume-anomaly
|
|
108
|
-
|
|
109
|
-
# 推送链路自检
|
|
110
|
-
deeptrade stdout-channel test
|
|
108
|
+
deeptrade volume-anomaly evaluate # T+N 自动回测闭环
|
|
109
|
+
deeptrade volume-anomaly stats # 收益统计聚合
|
|
111
110
|
```
|
|
112
111
|
|
|
113
|
-
>
|
|
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
|
|
114
117
|
|
|
115
118
|
报告产出在 `~/.deeptrade/reports/<run_id>/`。
|
|
116
119
|
|
|
@@ -123,26 +126,27 @@ deeptrade stdout-channel test
|
|
|
123
126
|
| `deeptrade --version` / `-V` | 显示版本 |
|
|
124
127
|
| `deeptrade --help` / `-h` | 框架命令清单(**不**枚举插件子命令) |
|
|
125
128
|
| `deeptrade init [--no-prompts]` | 建库 + 应用 core migrations |
|
|
129
|
+
| `deeptrade db init` / `db upgrade` | 显式建库 / 应用待执行迁移 |
|
|
126
130
|
| `deeptrade config {show, set, set-tushare, set-llm, list-llm, test-llm}` | 全局配置 |
|
|
127
|
-
| `deeptrade plugin
|
|
128
|
-
| `deeptrade plugin
|
|
129
|
-
| `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>` | 启 / 停 |
|
|
130
135
|
| `deeptrade plugin uninstall <id> [--purge]` | 卸载(`--purge` 才 DROP 表) |
|
|
131
|
-
| `deeptrade plugin upgrade <
|
|
132
|
-
| `deeptrade data sync ...` |
|
|
136
|
+
| `deeptrade plugin upgrade <SOURCE> [--ref <REF>]` | 升级(SemVer 比较,禁止降级;增量 migrations) |
|
|
137
|
+
| `deeptrade data sync ...` | (暂停用,下版本恢复;改用插件自带的 sync 子命令) |
|
|
133
138
|
|
|
134
|
-
保留字(不可作为 plugin_id):`init / config / plugin / data`。
|
|
139
|
+
保留字(不可作为 plugin_id):`init / config / plugin / data / db`。
|
|
135
140
|
|
|
136
141
|
### 插件命令(按 plugin_id 透传,插件自管)
|
|
137
142
|
|
|
138
|
-
| 命令 |
|
|
143
|
+
| 命令 | 来源(注册表短名) |
|
|
139
144
|
|---|---|
|
|
140
|
-
| `deeptrade limit-up-board {run, sync, history, report}` |
|
|
141
|
-
| `deeptrade volume-anomaly {screen, analyze, prune, history, report}` |
|
|
142
|
-
| `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) |
|
|
143
147
|
| `deeptrade <你的-plugin-id> ...` | 你自己写的任何插件 |
|
|
144
148
|
|
|
145
|
-
任意插件子命令的 `--help`
|
|
149
|
+
任意插件子命令的 `--help` 都由插件自身渲染——框架不感知动词语义。各插件的最新子命令、参数与运行手册见 [DeepTradePluginOfficial](https://github.com/ty19880929/DeepTradePluginOfficial)。
|
|
146
150
|
|
|
147
151
|
## 🧱 架构
|
|
148
152
|
|
|
@@ -150,33 +154,30 @@ deeptrade stdout-channel test
|
|
|
150
154
|
┌──────────────────────── deeptrade CLI (custom click.Group) ────────────────────────┐
|
|
151
155
|
│ │
|
|
152
156
|
│ framework commands (closed): │
|
|
153
|
-
│ init │ config │ plugin │ data
|
|
157
|
+
│ init │ config │ plugin │ data │ db │
|
|
154
158
|
│ │
|
|
155
159
|
│ plugin pass-through (open): │
|
|
156
160
|
│ <plugin_id> ──argv──→ Plugin.dispatch(argv) → int (plugin owns the rest) │
|
|
157
161
|
└──────────────────────────────────┬─────────────────────────────────────────────────┘
|
|
158
162
|
│
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
│
|
|
164
|
+
┌────────────────┴────────────────┐
|
|
165
|
+
▼ ▼
|
|
166
|
+
┌──────────────────┐ ┌────────────────────┐
|
|
167
|
+
│ Core services │ │ Plugins (strategy)│
|
|
168
|
+
│ DuckDB · Config │ │ • metadata │
|
|
169
|
+
│ Tushare · LLM │ │ • validate_static │
|
|
170
|
+
└──────────────────┘ │ • dispatch(argv) │
|
|
171
|
+
└────────────────────┘
|
|
168
172
|
```
|
|
169
173
|
|
|
170
|
-
|
|
174
|
+
每个插件通过自己的 migrations 声明并拥有 `<prefix>_*` 业务表;`tushare_sync_state` / `tushare_calls` / `llm_calls` 按 `plugin_id` 维度隔离,`__framework__` 为框架自身保留 sentinel。
|
|
171
175
|
|
|
172
|
-
## 📖
|
|
176
|
+
## 📖 参考
|
|
173
177
|
|
|
174
|
-
- [
|
|
175
|
-
- [
|
|
176
|
-
-
|
|
177
|
-
- [docs/plugin-development.md](docs/plugin-development.md) — 写一个新插件
|
|
178
|
-
- [docs/limit-up-board.md](docs/limit-up-board.md) — 打板策略说明
|
|
179
|
-
- [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 之前)
|
|
180
181
|
|
|
181
182
|
## ⚖️ 免责声明
|
|
182
183
|
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
# DeepTrade
|
|
2
2
|
|
|
3
|
-
> 本地运行的 A 股(沪深主板)选股 CLI
|
|
3
|
+
> 本地运行的 A 股(沪深主板)选股 CLI 框架:tushare 行情 + OpenAI 兼容 LLM(DeepSeek / Qwen / Kimi …)+ DuckDB 单机仓库 + 纯透传式插件 CLI。框架不携带任何业务策略,所有策略按需从官方注册表安装。
|
|
4
4
|
|
|
5
|
-
[
|
|
5
|
+
> 📖 **在线文档**:[deeptrade.tiey.ai](https://deeptrade.tiey.ai) — 用户手册 + 开发者手册 + 官方插件目录
|
|
6
|
+
|
|
7
|
+
[](#) [](#) [](LICENSE) [](CHANGELOG.md)
|
|
6
8
|
|
|
7
9
|
## ✨ 主要特性
|
|
8
10
|
|
|
9
11
|
- **轻量本地化**:单文件 DuckDB + uv,一条命令跑完,无需服务进程或容器。
|
|
10
|
-
-
|
|
12
|
+
- **框架与插件物理解耦**:`deeptrade-quant` wheel 只含框架(`init / config / plugin / data`),所有策略走 `deeptrade plugin install <短名>` 从注册表安装。
|
|
13
|
+
- **纯透传式插件 CLI**:未知首词一律按 `deeptrade <plugin_id> <argv...>` 透传给插件,插件自管 `--help`、子命令、参数、持久化。
|
|
11
14
|
- **数据隔离(Plan A)**:每个插件在自己的 migrations 里声明并拥有自己的表(含 tushare 派生数据),框架不持有任何业务表。`tushare_sync_state` / `tushare_calls` / `llm_calls` 都按 `plugin_id` 维度隔离。
|
|
12
|
-
- **顶层通知 API**:`from deeptrade import notify, notification_session` 一行发推送;框架根据已安装的 channel 插件自动路由,无 channel 时自动 noop。
|
|
13
15
|
- **多 LLM Provider 共存**:`llm.providers` 字典化配置,多个 OpenAI 兼容服务并存;插件通过 `LLMManager.get_client(name=...)` 按名取用,单次 run 内可调多家。
|
|
14
16
|
- **LLM 强约束**:JSON 模式 + Pydantic 双层校验;**永远**不传 tools / function calls。
|
|
15
|
-
- **盘中数据隔离**:`--allow-intraday` 模式下同步的不完整数据写入 `data_completeness='intraday'`,日终模式严格拒绝命中。
|
|
16
17
|
|
|
17
18
|
## 🚀 5 分钟上手
|
|
18
19
|
|
|
19
|
-
###
|
|
20
|
+
### 安装框架
|
|
20
21
|
|
|
21
22
|
```bash
|
|
22
23
|
# 推荐:pipx 隔离环境(命令名仍是 deeptrade)
|
|
@@ -39,7 +40,7 @@ pip install -e ".[dev]"
|
|
|
39
40
|
### 初始化与配置
|
|
40
41
|
|
|
41
42
|
```bash
|
|
42
|
-
deeptrade init # 建库 + 应用 core migrations
|
|
43
|
+
deeptrade init # 建库 + 应用 core migrations(交互式可选配 tushare / LLM)
|
|
43
44
|
deeptrade config set-tushare # 交互式输入 tushare token
|
|
44
45
|
deeptrade config set-llm # 交互式增/改/删 LLM provider(deepseek / qwen / kimi …)
|
|
45
46
|
deeptrade config list-llm # 列出已配置且可用的 provider
|
|
@@ -49,16 +50,16 @@ deeptrade config show # 表格展示当前配置(密钥脱
|
|
|
49
50
|
|
|
50
51
|
### 安装官方插件并运行
|
|
51
52
|
|
|
52
|
-
官方插件维护在 [DeepTradePluginOfficial](https://github.com/ty19880929/DeepTradePluginOfficial)
|
|
53
|
+
官方插件维护在 [DeepTradePluginOfficial](https://github.com/ty19880929/DeepTradePluginOfficial),框架按短名查注册表 → 拉 GitHub release tarball 自动安装。
|
|
53
54
|
|
|
54
55
|
```bash
|
|
55
56
|
# 浏览注册表
|
|
56
|
-
deeptrade plugin search
|
|
57
|
+
deeptrade plugin search # 全量列出
|
|
58
|
+
deeptrade plugin search anomaly # 关键词过滤
|
|
57
59
|
|
|
58
|
-
# 按短名安装(注册表 →
|
|
60
|
+
# 按短名安装(注册表 → 该插件最新 release tag)
|
|
59
61
|
deeptrade plugin install limit-up-board
|
|
60
62
|
deeptrade plugin install volume-anomaly
|
|
61
|
-
deeptrade plugin install stdout-channel
|
|
62
63
|
|
|
63
64
|
deeptrade plugin list # 查看已安装
|
|
64
65
|
|
|
@@ -67,16 +68,18 @@ deeptrade limit-up-board --help
|
|
|
67
68
|
deeptrade limit-up-board run # 默认日终模式
|
|
68
69
|
deeptrade limit-up-board run --allow-intraday --force-sync
|
|
69
70
|
|
|
70
|
-
#
|
|
71
|
+
# 运行成交量异动策略
|
|
71
72
|
deeptrade volume-anomaly screen # 异动筛选 → upsert va_watchlist
|
|
72
73
|
deeptrade volume-anomaly analyze # LLM 主升浪启动预测
|
|
73
|
-
deeptrade volume-anomaly
|
|
74
|
-
|
|
75
|
-
# 推送链路自检
|
|
76
|
-
deeptrade stdout-channel test
|
|
74
|
+
deeptrade volume-anomaly evaluate # T+N 自动回测闭环
|
|
75
|
+
deeptrade volume-anomaly stats # 收益统计聚合
|
|
77
76
|
```
|
|
78
77
|
|
|
79
|
-
>
|
|
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
|
|
80
83
|
|
|
81
84
|
报告产出在 `~/.deeptrade/reports/<run_id>/`。
|
|
82
85
|
|
|
@@ -89,26 +92,27 @@ deeptrade stdout-channel test
|
|
|
89
92
|
| `deeptrade --version` / `-V` | 显示版本 |
|
|
90
93
|
| `deeptrade --help` / `-h` | 框架命令清单(**不**枚举插件子命令) |
|
|
91
94
|
| `deeptrade init [--no-prompts]` | 建库 + 应用 core migrations |
|
|
95
|
+
| `deeptrade db init` / `db upgrade` | 显式建库 / 应用待执行迁移 |
|
|
92
96
|
| `deeptrade config {show, set, set-tushare, set-llm, list-llm, test-llm}` | 全局配置 |
|
|
93
|
-
| `deeptrade plugin
|
|
94
|
-
| `deeptrade plugin
|
|
95
|
-
| `deeptrade plugin
|
|
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>` | 启 / 停 |
|
|
96
101
|
| `deeptrade plugin uninstall <id> [--purge]` | 卸载(`--purge` 才 DROP 表) |
|
|
97
|
-
| `deeptrade plugin upgrade <
|
|
98
|
-
| `deeptrade data sync ...` |
|
|
102
|
+
| `deeptrade plugin upgrade <SOURCE> [--ref <REF>]` | 升级(SemVer 比较,禁止降级;增量 migrations) |
|
|
103
|
+
| `deeptrade data sync ...` | (暂停用,下版本恢复;改用插件自带的 sync 子命令) |
|
|
99
104
|
|
|
100
|
-
保留字(不可作为 plugin_id):`init / config / plugin / data`。
|
|
105
|
+
保留字(不可作为 plugin_id):`init / config / plugin / data / db`。
|
|
101
106
|
|
|
102
107
|
### 插件命令(按 plugin_id 透传,插件自管)
|
|
103
108
|
|
|
104
|
-
| 命令 |
|
|
109
|
+
| 命令 | 来源(注册表短名) |
|
|
105
110
|
|---|---|
|
|
106
|
-
| `deeptrade limit-up-board {run, sync, history, report}` |
|
|
107
|
-
| `deeptrade volume-anomaly {screen, analyze, prune, history, report}` |
|
|
108
|
-
| `deeptrade stdout-channel {test, log}` | 内建 stdout 通知插件 |
|
|
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) |
|
|
109
113
|
| `deeptrade <你的-plugin-id> ...` | 你自己写的任何插件 |
|
|
110
114
|
|
|
111
|
-
任意插件子命令的 `--help`
|
|
115
|
+
任意插件子命令的 `--help` 都由插件自身渲染——框架不感知动词语义。各插件的最新子命令、参数与运行手册见 [DeepTradePluginOfficial](https://github.com/ty19880929/DeepTradePluginOfficial)。
|
|
112
116
|
|
|
113
117
|
## 🧱 架构
|
|
114
118
|
|
|
@@ -116,33 +120,30 @@ deeptrade stdout-channel test
|
|
|
116
120
|
┌──────────────────────── deeptrade CLI (custom click.Group) ────────────────────────┐
|
|
117
121
|
│ │
|
|
118
122
|
│ framework commands (closed): │
|
|
119
|
-
│ init │ config │ plugin │ data
|
|
123
|
+
│ init │ config │ plugin │ data │ db │
|
|
120
124
|
│ │
|
|
121
125
|
│ plugin pass-through (open): │
|
|
122
126
|
│ <plugin_id> ──argv──→ Plugin.dispatch(argv) → int (plugin owns the rest) │
|
|
123
127
|
└──────────────────────────────────┬─────────────────────────────────────────────────┘
|
|
124
128
|
│
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
│
|
|
130
|
+
┌────────────────┴────────────────┐
|
|
131
|
+
▼ ▼
|
|
132
|
+
┌──────────────────┐ ┌────────────────────┐
|
|
133
|
+
│ Core services │ │ Plugins (strategy)│
|
|
134
|
+
│ DuckDB · Config │ │ • metadata │
|
|
135
|
+
│ Tushare · LLM │ │ • validate_static │
|
|
136
|
+
└──────────────────┘ │ • dispatch(argv) │
|
|
137
|
+
└────────────────────┘
|
|
134
138
|
```
|
|
135
139
|
|
|
136
|
-
|
|
140
|
+
每个插件通过自己的 migrations 声明并拥有 `<prefix>_*` 业务表;`tushare_sync_state` / `tushare_calls` / `llm_calls` 按 `plugin_id` 维度隔离,`__framework__` 为框架自身保留 sentinel。
|
|
137
141
|
|
|
138
|
-
## 📖
|
|
142
|
+
## 📖 参考
|
|
139
143
|
|
|
140
|
-
- [
|
|
141
|
-
- [
|
|
142
|
-
-
|
|
143
|
-
- [docs/plugin-development.md](docs/plugin-development.md) — 写一个新插件
|
|
144
|
-
- [docs/limit-up-board.md](docs/limit-up-board.md) — 打板策略说明
|
|
145
|
-
- [CHANGELOG.md](CHANGELOG.md) — 版本变更
|
|
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 之前)
|
|
146
147
|
|
|
147
148
|
## ⚖️ 免责声明
|
|
148
149
|
|
|
@@ -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.2.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
|