diepi-mcp 0.1.0a1__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 (50) hide show
  1. diepi_mcp-0.1.0a1/LICENSE +201 -0
  2. diepi_mcp-0.1.0a1/MANIFEST.in +5 -0
  3. diepi_mcp-0.1.0a1/PKG-INFO +237 -0
  4. diepi_mcp-0.1.0a1/README.md +203 -0
  5. diepi_mcp-0.1.0a1/SECURITY.md +127 -0
  6. diepi_mcp-0.1.0a1/THIRD_PARTY_NOTICES.md +21 -0
  7. diepi_mcp-0.1.0a1/docs/architecture.md +143 -0
  8. diepi_mcp-0.1.0a1/docs/data-contract.md +115 -0
  9. diepi_mcp-0.1.0a1/docs/release-notes.md +124 -0
  10. diepi_mcp-0.1.0a1/examples/config.example.json +16 -0
  11. diepi_mcp-0.1.0a1/pyproject.toml +64 -0
  12. diepi_mcp-0.1.0a1/setup.cfg +4 -0
  13. diepi_mcp-0.1.0a1/src/diepi_mcp/__init__.py +3 -0
  14. diepi_mcp-0.1.0a1/src/diepi_mcp/__main__.py +5 -0
  15. diepi_mcp-0.1.0a1/src/diepi_mcp/artifact_binding.py +340 -0
  16. diepi_mcp-0.1.0a1/src/diepi_mcp/bootstrap.py +244 -0
  17. diepi_mcp-0.1.0a1/src/diepi_mcp/config.py +206 -0
  18. diepi_mcp-0.1.0a1/src/diepi_mcp/integration.py +77 -0
  19. diepi_mcp-0.1.0a1/src/diepi_mcp/jobs.py +1470 -0
  20. diepi_mcp-0.1.0a1/src/diepi_mcp/models.py +84 -0
  21. diepi_mcp-0.1.0a1/src/diepi_mcp/results.py +362 -0
  22. diepi_mcp-0.1.0a1/src/diepi_mcp/security.py +142 -0
  23. diepi_mcp-0.1.0a1/src/diepi_mcp/server.py +285 -0
  24. diepi_mcp-0.1.0a1/src/diepi_mcp/service.py +673 -0
  25. diepi_mcp-0.1.0a1/src/diepi_mcp/source_binding.py +73 -0
  26. diepi_mcp-0.1.0a1/src/diepi_mcp/strategies/__init__.py +1 -0
  27. diepi_mcp-0.1.0a1/src/diepi_mcp/strategies/ma_crossover.py +87 -0
  28. diepi_mcp-0.1.0a1/src/diepi_mcp/strategy.py +130 -0
  29. diepi_mcp-0.1.0a1/src/diepi_mcp/worker.py +188 -0
  30. diepi_mcp-0.1.0a1/src/diepi_mcp.egg-info/PKG-INFO +237 -0
  31. diepi_mcp-0.1.0a1/src/diepi_mcp.egg-info/SOURCES.txt +48 -0
  32. diepi_mcp-0.1.0a1/src/diepi_mcp.egg-info/dependency_links.txt +1 -0
  33. diepi_mcp-0.1.0a1/src/diepi_mcp.egg-info/entry_points.txt +2 -0
  34. diepi_mcp-0.1.0a1/src/diepi_mcp.egg-info/requires.txt +10 -0
  35. diepi_mcp-0.1.0a1/src/diepi_mcp.egg-info/top_level.txt +1 -0
  36. diepi_mcp-0.1.0a1/tests/test_artifact_binding.py +307 -0
  37. diepi_mcp-0.1.0a1/tests/test_bootstrap.py +154 -0
  38. diepi_mcp-0.1.0a1/tests/test_config.py +98 -0
  39. diepi_mcp-0.1.0a1/tests/test_e2e.py +168 -0
  40. diepi_mcp-0.1.0a1/tests/test_jobs.py +879 -0
  41. diepi_mcp-0.1.0a1/tests/test_mcp_stdio.py +146 -0
  42. diepi_mcp-0.1.0a1/tests/test_models.py +41 -0
  43. diepi_mcp-0.1.0a1/tests/test_results_security.py +43 -0
  44. diepi_mcp-0.1.0a1/tests/test_security.py +119 -0
  45. diepi_mcp-0.1.0a1/tests/test_service.py +438 -0
  46. diepi_mcp-0.1.0a1/tests/test_source_binding.py +90 -0
  47. diepi_mcp-0.1.0a1/tests/test_strategy.py +71 -0
  48. diepi_mcp-0.1.0a1/tests/test_synthetic_e2e.py +111 -0
  49. diepi_mcp-0.1.0a1/tests/test_tushare_skill_handoff.py +236 -0
  50. diepi_mcp-0.1.0a1/tests/test_version.py +13 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ include LICENSE
2
+ include README.md
3
+ include SECURITY.md
4
+ recursive-include docs *.md
5
+ include examples/config.example.json
@@ -0,0 +1,237 @@
1
+ Metadata-Version: 2.4
2
+ Name: diepi-mcp
3
+ Version: 0.1.0a1
4
+ Summary: Constrained MCP adapter for auditable diePi research backtests
5
+ Author: diePi contributors
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/elonmaskhair-prog/dsh-plugin-diepi
8
+ Project-URL: Repository, https://github.com/elonmaskhair-prog/dsh-plugin-diepi
9
+ Project-URL: Documentation, https://github.com/elonmaskhair-prog/dsh-plugin-diepi#readme
10
+ Project-URL: Issues, https://github.com/elonmaskhair-prog/dsh-plugin-diepi/issues
11
+ Project-URL: Changelog, https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/CHANGELOG.md
12
+ Project-URL: Security, https://github.com/elonmaskhair-prog/dsh-plugin-diepi/security/policy
13
+ Keywords: backtesting,mcp,deepseek-harness,quantitative-finance
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Financial and Insurance Industry
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Topic :: Office/Business :: Financial :: Investment
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ License-File: THIRD_PARTY_NOTICES.md
24
+ Requires-Dist: diepi==0.1.1
25
+ Requires-Dist: mcp==1.29.0
26
+ Requires-Dist: pydantic<3,>=2.12
27
+ Requires-Dist: pydantic-settings<2.15,>=2.12
28
+ Provides-Extra: dev
29
+ Requires-Dist: build<2,>=1.2; extra == "dev"
30
+ Requires-Dist: pytest<10,>=8; extra == "dev"
31
+ Requires-Dist: ruff<1,>=0.12; extra == "dev"
32
+ Requires-Dist: twine<7,>=6; extra == "dev"
33
+ Dynamic: license-file
34
+
35
+ # dsh-plugin-diepi
36
+
37
+ `dsh-plugin-diepi` 是一个独立维护的社区 DSH 插件:用户用自然语言表达日线股票或 ETF
38
+ 策略,DSH 负责对话与编排,`diepi-mcp` 提供受约束的工具协议,diePi 负责数据校验、因果边界、
39
+ 撮合、记账与不可变结果工件。
40
+
41
+ ```text
42
+ 自然语言
43
+ -> DSH + diepi-quant-research Skill
44
+ -> StrategySpec v1(结构化、可预览、拒绝任意代码)
45
+ -> diepi-mcp(MCP stdio、作业队列、证据绑定)
46
+ -> 独立 diePi 子进程
47
+ -> 已验证的 RunArtifact / ResultContract
48
+ ```
49
+
50
+ 当前版本是 Developer Preview:Python 包为 `diepi-mcp 0.1.0a1`,npm bundle 为
51
+ `dsh-plugin-diepi 0.1.0-alpha.1`。本项目不是 DeepSeek 官方项目,也不代表任何官方认可。
52
+
53
+ ## 能做什么
54
+
55
+ - 日线、现金账户、单只 A 股或 ETF。
56
+ - `StrategySpec v1 / ma_crossover`:快慢均线严格交叉,可选成交额放大过滤。
57
+ - 盘前决策只读取截至 T-1 的完整日线,订单最早在 T 日开盘撮合。
58
+ - 支持 `raw_only`、`adjusted_only` 和严格对齐的 `dual` 数据。
59
+ - 回测异步排队,`submission_id` 使未知超时重试保持幂等。
60
+ - 数据来源、交易日历、策略模板、执行参数和最终 artifact 逐层绑定。
61
+ - DSH bundle 自动挂载八个受约束 MCP 工具与 `diepi-quant-research` Skill。
62
+
63
+ 暂不支持任意 Python、分钟策略协议、做空、杠杆、期货、实盘、券商凭证、内置行情下载、
64
+ 参数优化器或 GUI。模型不能通过本插件传入路径、命令、SQL 或 Python 源码。
65
+
66
+ ## 五分钟 synthetic 体验
67
+
68
+ 首次体验不读取本仓库或 diePi 仓库的真实行情。`diepi-mcp init-config` 在 DSH 工作区外
69
+ 排他认领一个全新的 adapter home,并调用 diePi 的同一个 deterministic demo generator,
70
+ 生成虚构价格、成交量、交易日和证券标签;这些数据只用于验证安装与协议接线。
71
+
72
+ 要求:
73
+
74
+ - Python 3.10+;
75
+ - Node.js `^22.19.0 || >=24.0.0`;
76
+ - pnpm `11.7.x`,且 `pnpm` 在 `PATH`;
77
+ - DSH `0.1.0-rc.7`(主支持)或 `0.1.0-rc.8`(canary)。
78
+
79
+ 先安装协调发布后的 Python Alpha,并创建一个新的 host-owned 根。`adapter-home-alpha1`
80
+ 必须尚不存在:
81
+
82
+ ```powershell
83
+ $hostRoot = Join-Path $env:LOCALAPPDATA "diepi-mcp-host"
84
+ $adapterHome = Join-Path $hostRoot "adapter-home-alpha1"
85
+ New-Item -ItemType Directory -Force -Path $hostRoot | Out-Null
86
+
87
+ python -m venv (Join-Path $hostRoot "venv")
88
+ $experiencePython = Join-Path $hostRoot "venv\Scripts\python.exe"
89
+ $mcpCommand = Join-Path $hostRoot "venv\Scripts\diepi-mcp.exe"
90
+
91
+ & $experiencePython -m pip install "diepi-mcp==0.1.0a1"
92
+ & $mcpCommand init-config --target $adapterHome
93
+
94
+ $env:DIEPI_MCP_COMMAND = (Resolve-Path $mcpCommand).Path
95
+ $env:DIEPI_MCP_CONFIG = (Resolve-Path (Join-Path $adapterHome "diepi-mcp.json")).Path
96
+ & $env:DIEPI_MCP_COMMAND --check-config
97
+ ```
98
+
99
+ 初始化命令拒绝覆盖、合并或复用已有目标。它先以排他方式创建目标和
100
+ `.diepi-mcp-incomplete` 标记,再以 exclusive-create 写入 staged payload,最后才提交
101
+ `diepi-mcp.json` 并移除标记。失败会保留一个没有可用配置的 incomplete 目录,绝不会删除
102
+ 或接管竞态目标;请改用一个新目录,或由 host owner 核对内容后人工清理。生成的配置只含
103
+ 相对路径,state、results 和 synthetic 数据都留在 adapter home,不会进入 Agent 工作区或
104
+ Git 仓库。
105
+ [examples/config.example.json](https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/examples/config.example.json)
106
+ 仅是 schema 参考,不需要手工复制。生产环境还应通过文件权限让 Agent 只读行情,并且不能
107
+ 写配置、MCP 环境、state 或 results 根。
108
+
109
+ DSH 的插件管理会调用裸 `pnpm`。Node 自带 Corepack 时可固定 DSH 所用版本:
110
+
111
+ ```powershell
112
+ corepack enable
113
+ corepack prepare pnpm@11.7.0 --activate
114
+ pnpm --version
115
+ ```
116
+
117
+ 若当前 Node 不包含 `corepack`,请先按 Corepack/pnpm 官方说明安装它,再继续。安装到
118
+ `web` profile,而不是只含 base bundle 的任意自定义 profile:
119
+
120
+ ```powershell
121
+ dsh plugin --profile web add dsh-plugin-diepi@0.1.0-alpha.1
122
+ dsh --profile web --dump-config
123
+ dsh web --no-open
124
+ ```
125
+
126
+ 插件成员变更只对新 DSH 进程生效。若要使用 headless:
127
+
128
+ ```powershell
129
+ dsh plugin --profile headless add dsh-plugin-diepi@0.1.0-alpha.1
130
+ dsh --profile headless --dump-config
131
+ dsh --profile headless
132
+ ```
133
+
134
+ 从本仓库 checkout 测试 bundle 时,在仓库根目录把包名替换为 `./dsh`。不要直接从 Git
135
+ 仓库根 URL 安装 npm 包;npm package 位于 `dsh/` 子目录。
136
+
137
+ Bundle 在激活时强制要求 `DIEPI_MCP_COMMAND` 和 `DIEPI_MCP_CONFIG` 都是显式绝对路径。
138
+ 它不会退回到 `PATH` 中名字相同的可执行文件,也不会猜测配置位置。
139
+ MCP 子进程的工作目录固定为 host-owned 配置目录,而不是 Agent workspace。
140
+
141
+ ## 自然语言到回测
142
+
143
+ 例如:
144
+
145
+ > 用 510300.SH 日线,5 日线上穿 20 日线时满仓,死叉清仓;回测 2024 年。
146
+
147
+ Agent 先生成可审阅的 `StrategySpec v1`,再依次调用:
148
+
149
+ 1. `capabilities`
150
+ 2. `preview_strategy`
151
+ 3. `validate_data`
152
+ 4. 使用一个新的、以 `req_` 开头的 `submission_id` 调用 `start_backtest`
153
+ 5. `job_status`,必要时 `cancel_job`
154
+ 6. `get_result`
155
+
156
+ 发生 MCP timeout 或传输中断时,必须用完全相同的参数和同一个 `submission_id` 重试。
157
+ 只有以下条件全部成立时才可以比较结果:
158
+
159
+ ```text
160
+ artifact_verified == true
161
+ adapter_attribution_verified == true
162
+ result_committed == true
163
+ result_status == SUCCESS
164
+ rankable == true
165
+ ```
166
+
167
+ ## 自有行情与 Tushare Skill
168
+
169
+ 最小输入是符合 diePi `market_data_v1` 的 raw 日线;最佳输入是完全对齐的 raw、HFQ 和原始
170
+ 复权因子三轨。上游接口把数据称为 `hfq`,并不能证明它满足 diePi 的因子恒等式,最终以
171
+ diePi validator 为准。
172
+
173
+ 插件不内置连接器、不携带真实行情、不保存 token,也不会自动安装外部 Skill。数据缺失时,
174
+ Agent 可以把用户引导到独立安装的
175
+ [Tushare 官方 Skill](https://github.com/waditu-tushare/skills)。我们只记录一个审阅过的上游
176
+ commit 作为人工交接参考;安装、网络权限、凭证、供应商条款和更新决定都由用户控制。详细
177
+ 规则见
178
+ [Tushare handoff](https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/dsh/skills/diepi-quant-research/references/tushare-data-handoff.md)。
179
+
180
+ 外部 Skill 只负责把数据写入一个新的 staging 根。host owner 必须在会话外校验、注册为
181
+ 不透明 `dataset_id`、冻结数据根并重启 MCP;单次 Agent 会话不能跳过这一边界。
182
+
183
+ ## 版本与兼容策略
184
+
185
+ - `diepi-mcp==0.1.0a1` 精确依赖 `diepi==0.1.1`。这是有意的:adapter 当前依赖 diePi 的
186
+ 取消回调、来源证据、日历身份和原子 artifact 语义,宽泛的 `0.1.x` 范围不能证明兼容。
187
+ - DSH rc.7 是 Alpha 主支持版本;rc.8 是前瞻 canary。两者仍处于 Developer Preview,
188
+ rc.8 测试应使用独立的 `DSH_HOME`,不要复用 rc.7 会话状态。
189
+ - Harness 自带 `@deepseek-ai/dsh-mcp-client` 和 `@deepseek-ai/dsh-skill-filesystem`;本 bundle
190
+ 不重复携带它们。
191
+
192
+ 发布顺序的硬门禁是先让 `diepi==0.1.1` 可从协调的 Python index 安装;插件 CI 在此之前应当
193
+ 失败,而不是放宽 pin。随后发布门禁会校验下载候选的 SHA-256、在干净环境安装 sdist,并在
194
+ Windows/Ubuntu、Node 22/24、web/headless、DSH rc.7/rc.8 四格中安装 wheel 与打包后的 npm
195
+ tgz。每格分别执行 wheel 上的直接 MCP/adapter synthetic smoke,并真实启动 DSH,在 Loader
196
+ settle 后严格发现八个 `mcp__diepi__*` 工具且调用 `capabilities`。该无模型 key 探针不声称覆盖
197
+ 经 DSH 的取消、崩溃重连或真实模型效果;这些边界由源码测试或单独记录的手工发布验证承担。
198
+
199
+ ## 安全边界
200
+
201
+ MCP stdio 是 host 进程,不在 Agent 文件沙箱内。配置、可执行文件、数据根、state 和 results
202
+ 必须由 host owner 控制。哈希证明工件之间的身份一致性,但不能把一个 Agent 可写目录变成
203
+ 可信证据根,也不能证明行情真实、获得合法授权或没有幸存者偏差。
204
+
205
+ 详细威胁模型与私密漏洞报告入口见
206
+ [SECURITY.md](https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/SECURITY.md)。
207
+
208
+ ## 开发
209
+
210
+ ```powershell
211
+ python -m venv .venv
212
+ .\.venv\Scripts\python.exe -m pip install ".[dev]"
213
+ .\.venv\Scripts\python.exe -m pytest -m "not integration"
214
+ .\.venv\Scripts\ruff.exe check src tests
215
+ .\.venv\Scripts\python.exe -m build
216
+ .\.venv\Scripts\python.exe -m twine check dist\*
217
+
218
+ Push-Location dsh
219
+ npm pack --dry-run
220
+ Pop-Location
221
+ ```
222
+
223
+ 贡献规则见
224
+ [CONTRIBUTING.md](https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/CONTRIBUTING.md),
225
+ 版本变化见
226
+ [CHANGELOG.md](https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/CHANGELOG.md)。
227
+
228
+ ## 免责声明与许可证
229
+
230
+ 本项目仅用于软件工程验证、量化研究和历史回测。输出不构成投资建议、交易邀约、收益保证或
231
+ 券商服务;回测可能受到数据质量、幸存者偏差、复权、撮合假设、费用、滑点和过拟合影响。
232
+ 用户对数据来源、供应商许可、模型使用和投资决定承担责任。
233
+
234
+ Apache-2.0,见
235
+ [LICENSE](https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/LICENSE)。第三方关系见
236
+ [THIRD_PARTY_NOTICES.md](https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/THIRD_PARTY_NOTICES.md)。DeepSeek、DeepSeek Harness 和 DSH 的
237
+ 相关名称与标识归其各自权利人所有;本项目与其没有隶属或背书关系。
@@ -0,0 +1,203 @@
1
+ # dsh-plugin-diepi
2
+
3
+ `dsh-plugin-diepi` 是一个独立维护的社区 DSH 插件:用户用自然语言表达日线股票或 ETF
4
+ 策略,DSH 负责对话与编排,`diepi-mcp` 提供受约束的工具协议,diePi 负责数据校验、因果边界、
5
+ 撮合、记账与不可变结果工件。
6
+
7
+ ```text
8
+ 自然语言
9
+ -> DSH + diepi-quant-research Skill
10
+ -> StrategySpec v1(结构化、可预览、拒绝任意代码)
11
+ -> diepi-mcp(MCP stdio、作业队列、证据绑定)
12
+ -> 独立 diePi 子进程
13
+ -> 已验证的 RunArtifact / ResultContract
14
+ ```
15
+
16
+ 当前版本是 Developer Preview:Python 包为 `diepi-mcp 0.1.0a1`,npm bundle 为
17
+ `dsh-plugin-diepi 0.1.0-alpha.1`。本项目不是 DeepSeek 官方项目,也不代表任何官方认可。
18
+
19
+ ## 能做什么
20
+
21
+ - 日线、现金账户、单只 A 股或 ETF。
22
+ - `StrategySpec v1 / ma_crossover`:快慢均线严格交叉,可选成交额放大过滤。
23
+ - 盘前决策只读取截至 T-1 的完整日线,订单最早在 T 日开盘撮合。
24
+ - 支持 `raw_only`、`adjusted_only` 和严格对齐的 `dual` 数据。
25
+ - 回测异步排队,`submission_id` 使未知超时重试保持幂等。
26
+ - 数据来源、交易日历、策略模板、执行参数和最终 artifact 逐层绑定。
27
+ - DSH bundle 自动挂载八个受约束 MCP 工具与 `diepi-quant-research` Skill。
28
+
29
+ 暂不支持任意 Python、分钟策略协议、做空、杠杆、期货、实盘、券商凭证、内置行情下载、
30
+ 参数优化器或 GUI。模型不能通过本插件传入路径、命令、SQL 或 Python 源码。
31
+
32
+ ## 五分钟 synthetic 体验
33
+
34
+ 首次体验不读取本仓库或 diePi 仓库的真实行情。`diepi-mcp init-config` 在 DSH 工作区外
35
+ 排他认领一个全新的 adapter home,并调用 diePi 的同一个 deterministic demo generator,
36
+ 生成虚构价格、成交量、交易日和证券标签;这些数据只用于验证安装与协议接线。
37
+
38
+ 要求:
39
+
40
+ - Python 3.10+;
41
+ - Node.js `^22.19.0 || >=24.0.0`;
42
+ - pnpm `11.7.x`,且 `pnpm` 在 `PATH`;
43
+ - DSH `0.1.0-rc.7`(主支持)或 `0.1.0-rc.8`(canary)。
44
+
45
+ 先安装协调发布后的 Python Alpha,并创建一个新的 host-owned 根。`adapter-home-alpha1`
46
+ 必须尚不存在:
47
+
48
+ ```powershell
49
+ $hostRoot = Join-Path $env:LOCALAPPDATA "diepi-mcp-host"
50
+ $adapterHome = Join-Path $hostRoot "adapter-home-alpha1"
51
+ New-Item -ItemType Directory -Force -Path $hostRoot | Out-Null
52
+
53
+ python -m venv (Join-Path $hostRoot "venv")
54
+ $experiencePython = Join-Path $hostRoot "venv\Scripts\python.exe"
55
+ $mcpCommand = Join-Path $hostRoot "venv\Scripts\diepi-mcp.exe"
56
+
57
+ & $experiencePython -m pip install "diepi-mcp==0.1.0a1"
58
+ & $mcpCommand init-config --target $adapterHome
59
+
60
+ $env:DIEPI_MCP_COMMAND = (Resolve-Path $mcpCommand).Path
61
+ $env:DIEPI_MCP_CONFIG = (Resolve-Path (Join-Path $adapterHome "diepi-mcp.json")).Path
62
+ & $env:DIEPI_MCP_COMMAND --check-config
63
+ ```
64
+
65
+ 初始化命令拒绝覆盖、合并或复用已有目标。它先以排他方式创建目标和
66
+ `.diepi-mcp-incomplete` 标记,再以 exclusive-create 写入 staged payload,最后才提交
67
+ `diepi-mcp.json` 并移除标记。失败会保留一个没有可用配置的 incomplete 目录,绝不会删除
68
+ 或接管竞态目标;请改用一个新目录,或由 host owner 核对内容后人工清理。生成的配置只含
69
+ 相对路径,state、results 和 synthetic 数据都留在 adapter home,不会进入 Agent 工作区或
70
+ Git 仓库。
71
+ [examples/config.example.json](https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/examples/config.example.json)
72
+ 仅是 schema 参考,不需要手工复制。生产环境还应通过文件权限让 Agent 只读行情,并且不能
73
+ 写配置、MCP 环境、state 或 results 根。
74
+
75
+ DSH 的插件管理会调用裸 `pnpm`。Node 自带 Corepack 时可固定 DSH 所用版本:
76
+
77
+ ```powershell
78
+ corepack enable
79
+ corepack prepare pnpm@11.7.0 --activate
80
+ pnpm --version
81
+ ```
82
+
83
+ 若当前 Node 不包含 `corepack`,请先按 Corepack/pnpm 官方说明安装它,再继续。安装到
84
+ `web` profile,而不是只含 base bundle 的任意自定义 profile:
85
+
86
+ ```powershell
87
+ dsh plugin --profile web add dsh-plugin-diepi@0.1.0-alpha.1
88
+ dsh --profile web --dump-config
89
+ dsh web --no-open
90
+ ```
91
+
92
+ 插件成员变更只对新 DSH 进程生效。若要使用 headless:
93
+
94
+ ```powershell
95
+ dsh plugin --profile headless add dsh-plugin-diepi@0.1.0-alpha.1
96
+ dsh --profile headless --dump-config
97
+ dsh --profile headless
98
+ ```
99
+
100
+ 从本仓库 checkout 测试 bundle 时,在仓库根目录把包名替换为 `./dsh`。不要直接从 Git
101
+ 仓库根 URL 安装 npm 包;npm package 位于 `dsh/` 子目录。
102
+
103
+ Bundle 在激活时强制要求 `DIEPI_MCP_COMMAND` 和 `DIEPI_MCP_CONFIG` 都是显式绝对路径。
104
+ 它不会退回到 `PATH` 中名字相同的可执行文件,也不会猜测配置位置。
105
+ MCP 子进程的工作目录固定为 host-owned 配置目录,而不是 Agent workspace。
106
+
107
+ ## 自然语言到回测
108
+
109
+ 例如:
110
+
111
+ > 用 510300.SH 日线,5 日线上穿 20 日线时满仓,死叉清仓;回测 2024 年。
112
+
113
+ Agent 先生成可审阅的 `StrategySpec v1`,再依次调用:
114
+
115
+ 1. `capabilities`
116
+ 2. `preview_strategy`
117
+ 3. `validate_data`
118
+ 4. 使用一个新的、以 `req_` 开头的 `submission_id` 调用 `start_backtest`
119
+ 5. `job_status`,必要时 `cancel_job`
120
+ 6. `get_result`
121
+
122
+ 发生 MCP timeout 或传输中断时,必须用完全相同的参数和同一个 `submission_id` 重试。
123
+ 只有以下条件全部成立时才可以比较结果:
124
+
125
+ ```text
126
+ artifact_verified == true
127
+ adapter_attribution_verified == true
128
+ result_committed == true
129
+ result_status == SUCCESS
130
+ rankable == true
131
+ ```
132
+
133
+ ## 自有行情与 Tushare Skill
134
+
135
+ 最小输入是符合 diePi `market_data_v1` 的 raw 日线;最佳输入是完全对齐的 raw、HFQ 和原始
136
+ 复权因子三轨。上游接口把数据称为 `hfq`,并不能证明它满足 diePi 的因子恒等式,最终以
137
+ diePi validator 为准。
138
+
139
+ 插件不内置连接器、不携带真实行情、不保存 token,也不会自动安装外部 Skill。数据缺失时,
140
+ Agent 可以把用户引导到独立安装的
141
+ [Tushare 官方 Skill](https://github.com/waditu-tushare/skills)。我们只记录一个审阅过的上游
142
+ commit 作为人工交接参考;安装、网络权限、凭证、供应商条款和更新决定都由用户控制。详细
143
+ 规则见
144
+ [Tushare handoff](https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/dsh/skills/diepi-quant-research/references/tushare-data-handoff.md)。
145
+
146
+ 外部 Skill 只负责把数据写入一个新的 staging 根。host owner 必须在会话外校验、注册为
147
+ 不透明 `dataset_id`、冻结数据根并重启 MCP;单次 Agent 会话不能跳过这一边界。
148
+
149
+ ## 版本与兼容策略
150
+
151
+ - `diepi-mcp==0.1.0a1` 精确依赖 `diepi==0.1.1`。这是有意的:adapter 当前依赖 diePi 的
152
+ 取消回调、来源证据、日历身份和原子 artifact 语义,宽泛的 `0.1.x` 范围不能证明兼容。
153
+ - DSH rc.7 是 Alpha 主支持版本;rc.8 是前瞻 canary。两者仍处于 Developer Preview,
154
+ rc.8 测试应使用独立的 `DSH_HOME`,不要复用 rc.7 会话状态。
155
+ - Harness 自带 `@deepseek-ai/dsh-mcp-client` 和 `@deepseek-ai/dsh-skill-filesystem`;本 bundle
156
+ 不重复携带它们。
157
+
158
+ 发布顺序的硬门禁是先让 `diepi==0.1.1` 可从协调的 Python index 安装;插件 CI 在此之前应当
159
+ 失败,而不是放宽 pin。随后发布门禁会校验下载候选的 SHA-256、在干净环境安装 sdist,并在
160
+ Windows/Ubuntu、Node 22/24、web/headless、DSH rc.7/rc.8 四格中安装 wheel 与打包后的 npm
161
+ tgz。每格分别执行 wheel 上的直接 MCP/adapter synthetic smoke,并真实启动 DSH,在 Loader
162
+ settle 后严格发现八个 `mcp__diepi__*` 工具且调用 `capabilities`。该无模型 key 探针不声称覆盖
163
+ 经 DSH 的取消、崩溃重连或真实模型效果;这些边界由源码测试或单独记录的手工发布验证承担。
164
+
165
+ ## 安全边界
166
+
167
+ MCP stdio 是 host 进程,不在 Agent 文件沙箱内。配置、可执行文件、数据根、state 和 results
168
+ 必须由 host owner 控制。哈希证明工件之间的身份一致性,但不能把一个 Agent 可写目录变成
169
+ 可信证据根,也不能证明行情真实、获得合法授权或没有幸存者偏差。
170
+
171
+ 详细威胁模型与私密漏洞报告入口见
172
+ [SECURITY.md](https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/SECURITY.md)。
173
+
174
+ ## 开发
175
+
176
+ ```powershell
177
+ python -m venv .venv
178
+ .\.venv\Scripts\python.exe -m pip install ".[dev]"
179
+ .\.venv\Scripts\python.exe -m pytest -m "not integration"
180
+ .\.venv\Scripts\ruff.exe check src tests
181
+ .\.venv\Scripts\python.exe -m build
182
+ .\.venv\Scripts\python.exe -m twine check dist\*
183
+
184
+ Push-Location dsh
185
+ npm pack --dry-run
186
+ Pop-Location
187
+ ```
188
+
189
+ 贡献规则见
190
+ [CONTRIBUTING.md](https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/CONTRIBUTING.md),
191
+ 版本变化见
192
+ [CHANGELOG.md](https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/CHANGELOG.md)。
193
+
194
+ ## 免责声明与许可证
195
+
196
+ 本项目仅用于软件工程验证、量化研究和历史回测。输出不构成投资建议、交易邀约、收益保证或
197
+ 券商服务;回测可能受到数据质量、幸存者偏差、复权、撮合假设、费用、滑点和过拟合影响。
198
+ 用户对数据来源、供应商许可、模型使用和投资决定承担责任。
199
+
200
+ Apache-2.0,见
201
+ [LICENSE](https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/LICENSE)。第三方关系见
202
+ [THIRD_PARTY_NOTICES.md](https://github.com/elonmaskhair-prog/dsh-plugin-diepi/blob/main/THIRD_PARTY_NOTICES.md)。DeepSeek、DeepSeek Harness 和 DSH 的
203
+ 相关名称与标识归其各自权利人所有;本项目与其没有隶属或背书关系。