dsh-worldquant 0.0.0-stage → 0.1.1
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.
- package/LICENSE +21 -0
- package/README.md +166 -2
- package/README.zh.md +167 -0
- package/cordis.patch.yml +19 -0
- package/docs/verification-2026-11-28.md +38 -0
- package/index.js +123 -0
- package/package.json +46 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bit0620
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,167 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-worldquant
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **WorldQuant BRAIN inside DeepSeek Harness.** One bundle mounts a BRAIN MCP server, exposes its tools as `mcp__brain__*`, and adds a preflight check and a safety-first alpha research workflow.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/dsh-worldquant)
|
|
6
|
+
[](https://github.com/topics/dsh-plugin)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
DeepSeek Harness is a strong agent runtime for long, tool-heavy research loops. WorldQuant BRAIN is a tool-heavy research platform: datasets, fields, simulation settings, submission checks, correlations, and PnL. This plugin connects the two without writing a new BRAIN client: it uses DSH's official MCP bridge and the BRAIN MCP server you already run.
|
|
10
|
+
|
|
11
|
+
Not affiliated with WorldQuant. BRAIN credentials stay on your machine; this package never sends them anywhere except to the MCP server you configure.
|
|
12
|
+
|
|
13
|
+
## What you get
|
|
14
|
+
|
|
15
|
+
- **`mcp__brain__*` tools** — every tool your BRAIN MCP server publishes appears as a native DSH tool.
|
|
16
|
+
- **`brain_status`** — a local preflight that reports the MCP command and the authentication mode (`env`, `external`, or `missing`), without printing secrets or calling the API.
|
|
17
|
+
- **A workflow, not a toy demo** — the README and prompts below encode the loop that actually matters: explore fields → write an expression → simulate → read checks → compare correlation → only then consider submission.
|
|
18
|
+
- **No build step** — plain ESM JavaScript and a YAML patch. Install from git or npm.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
dsh plugin --profile web add dsh-worldquant
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or install straight from GitHub (no build step):
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
dsh plugin --profile web add github:bit0620/dsh-worldquant
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configure a BRAIN MCP server
|
|
33
|
+
|
|
34
|
+
The bundle reads four environment variables at startup:
|
|
35
|
+
|
|
36
|
+
| Variable | Default | Meaning |
|
|
37
|
+
| --- | --- | --- |
|
|
38
|
+
| `BRAIN_USERNAME` | — | BRAIN account email |
|
|
39
|
+
| `BRAIN_PASSWORD` | — | BRAIN password |
|
|
40
|
+
| `BRAIN_MCP_COMMAND` | `python` | Executable that starts the MCP server |
|
|
41
|
+
| `BRAIN_MCP_ARGS` | `["-m","wq_mcp"]` | JSON array of arguments |
|
|
42
|
+
| `BRAIN_MCP_SERVER_NAME` | `brain` | Tool namespace (`mcp__brain__*`) |
|
|
43
|
+
|
|
44
|
+
### Option A: `wq-brain-mcp` installed
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
python -m wq_mcp
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Set the credentials and leave the command/args at their defaults.
|
|
51
|
+
|
|
52
|
+
### Option B: your own BRAIN bridge script
|
|
53
|
+
|
|
54
|
+
This is the setup many BRAIN users already have — a Python file that speaks MCP over stdio:
|
|
55
|
+
|
|
56
|
+
```powershell
|
|
57
|
+
$env:BRAIN_MCP_ARGS='["D:\\123\\Documents\\wq\\platform_functions.py"]'
|
|
58
|
+
$env:BRAIN_USERNAME='you@example.com'
|
|
59
|
+
$env:BRAIN_PASSWORD='...'
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Then restart DSH. The namespace is `mcp__brain__*` unless you change `BRAIN_MCP_SERVER_NAME`.
|
|
63
|
+
|
|
64
|
+
### Option C: a different MCP server over stdio
|
|
65
|
+
|
|
66
|
+
```powershell
|
|
67
|
+
$env:BRAIN_MCP_COMMAND='uvx'
|
|
68
|
+
$env:BRAIN_MCP_ARGS='["--from","wq-brain-mcp","wq-mcp"]'
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Streamable HTTP is not wired in this bundle; add a second `@deepseek-ai/dsh-mcp-client` row to your profile if your server uses it.
|
|
72
|
+
|
|
73
|
+
### External-auth servers
|
|
74
|
+
|
|
75
|
+
Some local BRAIN bridges store the session/JWT themselves and do not read `BRAIN_USERNAME` / `BRAIN_PASSWORD` from the environment. In that case, set only `BRAIN_MCP_COMMAND` and `BRAIN_MCP_ARGS`, and leave the credential variables unset. `brain_status` reports `authMode: external` and `configured: true`; the MCP server owns authentication.
|
|
76
|
+
|
|
77
|
+
The defaults (`python -m wq_mcp`) are for a server that expects environment credentials. Pick the setup that matches your bridge.
|
|
78
|
+
|
|
79
|
+
## Verify
|
|
80
|
+
|
|
81
|
+
Ask the agent:
|
|
82
|
+
|
|
83
|
+
> Call `brain_status`, then list the BRAIN tools you can see.
|
|
84
|
+
|
|
85
|
+
A healthy setup returns `configured: true` and a tool list containing `mcp__brain__*`. If the tools are absent, the MCP server failed to start; the DSH log names the `mcp-brain` row and the underlying error.
|
|
86
|
+
|
|
87
|
+
### Verified against a live BRAIN account
|
|
88
|
+
|
|
89
|
+
On 2026-11-28, a local stdio BRAIN MCP server was launched through this bundle in a DSH headless profile. `mcp__brain__get_datasets` returned **289 datasets** for USA / TOP3000 / delay 1, including:
|
|
90
|
+
|
|
91
|
+
- `acquisition_model` — Corporate Acquisition Likelihood Model (coverage 0.9063, 15 fields)
|
|
92
|
+
- `ai_equity_alpha` — AI Equity Alpha Forecasts (coverage 0.9049, 1108 fields)
|
|
93
|
+
|
|
94
|
+
The run was read-only: no simulation, no submission, no alpha creation. The server authenticated itself; `brain_status` now reports that as `authMode: external`. Details: [docs/verification-2026-11-28.md](docs/verification-2026-11-28.md).
|
|
95
|
+
|
|
96
|
+
## The research loop
|
|
97
|
+
|
|
98
|
+
### 1. Explore before writing
|
|
99
|
+
|
|
100
|
+
> Use the BRAIN tools to list datasets in the USA/TOP3000/delay-1 universe. Rank the top five by field coverage and show the fields with the highest non-zero ratio.
|
|
101
|
+
|
|
102
|
+
The agent should call the MCP data tools, not invent field names. Require a table with dataset id, field id, coverage, and update frequency.
|
|
103
|
+
|
|
104
|
+
### 2. Write one expression at a time
|
|
105
|
+
|
|
106
|
+
> Propose three expressions using only the fields above. For each, state the economic intuition in one sentence, the operators used, and the expected turnover range. Do not simulate yet.
|
|
107
|
+
|
|
108
|
+
Keep the proposal step separate from the simulation step. It makes bad ideas cheap to reject.
|
|
109
|
+
|
|
110
|
+
### 3. Simulate with explicit settings
|
|
111
|
+
|
|
112
|
+
> Simulate expression A with region USA, universe TOP3000, delay 1, decay 0, neutralization INDUSTRY. Report Sharpe, fitness, turnover, margin, and every failed check. Do not submit.
|
|
113
|
+
|
|
114
|
+
The plugin does not add a submit tool of its own. If your MCP server exposes submission, ask the agent to stop before calling it.
|
|
115
|
+
|
|
116
|
+
### 4. Compare, then decide
|
|
117
|
+
|
|
118
|
+
> Compare the new alpha's PnL with my last 20 submitted alphas. Flag any correlation above 0.7 and explain which shared exposure is likely responsible.
|
|
119
|
+
|
|
120
|
+
### 5. Gate submission
|
|
121
|
+
|
|
122
|
+
Before any submission, require all of the following in the transcript:
|
|
123
|
+
|
|
124
|
+
- IS Sharpe and fitness above your own thresholds
|
|
125
|
+
- turnover inside the platform limit
|
|
126
|
+
- every submission check passing
|
|
127
|
+
- self-correlation and prod-correlation below your limits
|
|
128
|
+
- a written reason the alpha is not a re-skin of an existing one
|
|
129
|
+
|
|
130
|
+
If any item is missing, the correct action is **do not submit**.
|
|
131
|
+
|
|
132
|
+
## A system prompt that works well
|
|
133
|
+
|
|
134
|
+
Add this to your `AGENTS.md` or the session prompt:
|
|
135
|
+
|
|
136
|
+
```text
|
|
137
|
+
You are a BRAIN alpha research assistant.
|
|
138
|
+
- Use only fields returned by the BRAIN tools; never guess a field id.
|
|
139
|
+
- Propose expressions before simulating them.
|
|
140
|
+
- Report every simulation check, including failures.
|
|
141
|
+
- Never call a submit tool without explicit user confirmation in the same turn.
|
|
142
|
+
- After a simulation, compare PnL correlation against the user's existing alphas.
|
|
143
|
+
- Prefer one clear hypothesis per expression over a kitchen-sink formula.
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Why this is a plugin instead of a prompt
|
|
147
|
+
|
|
148
|
+
A prompt can describe a workflow; it cannot guarantee the tools exist, keep credentials out of the transcript, or make a failed MCP connection visible. The bundle owns those pieces:
|
|
149
|
+
|
|
150
|
+
- the MCP row is versioned with the plugin;
|
|
151
|
+
- `brain_status` diagnoses configuration without leaking secrets;
|
|
152
|
+
- the workflow ships with the plugin and is updated with it;
|
|
153
|
+
- the same package works in the Web UI, headless runs, and eval suites.
|
|
154
|
+
|
|
155
|
+
## Roadmap
|
|
156
|
+
|
|
157
|
+
- [ ] Streamable HTTP transport option
|
|
158
|
+
- [ ] Batch-simulation queue with a local ledger
|
|
159
|
+
- [ ] Alpha diff report (expression, settings, metrics, checks)
|
|
160
|
+
- [ ] A `dsh-regress` eval pack for BRAIN workflows (field selection, expression repair, submission gating)
|
|
161
|
+
- [ ] Read-only mode that registers only research tools even if the MCP server exposes submit
|
|
162
|
+
|
|
163
|
+
Issues and PRs welcome. If your BRAIN MCP server uses a different launch shape, open an issue with the command (never the credentials) and we will document it.
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
MIT © 2026 Bit0620
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# dsh-worldquant
|
|
2
|
+
|
|
3
|
+
> **把 WorldQuant BRAIN 接进 DeepSeek Harness。** 一个 bundle 挂载 BRAIN MCP server,把工具暴露成 `mcp__brain__*`,并附带配置自检和安全优先的 Alpha 研究工作流。
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/dsh-worldquant)
|
|
6
|
+
[](https://github.com/topics/dsh-plugin)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
DSH 很适合长链路、工具密集的研究循环;BRAIN 正好是这样一个平台:数据集、字段、仿真设置、提交检查、相关性、PnL。这个插件不重写 BRAIN 客户端,而是复用 DSH 官方 MCP bridge,把你已经在跑的 BRAIN MCP server 接进来。
|
|
10
|
+
|
|
11
|
+
与 WorldQuant 官方无关。BRAIN 凭据只留在本机;除了你配置的 MCP server,这个包不会把凭据发到任何地方。
|
|
12
|
+
|
|
13
|
+
## 提供什么
|
|
14
|
+
|
|
15
|
+
- **`mcp__brain__*` 工具** —— BRAIN MCP server 发布的每个工具都会成为 DSH 原生工具。
|
|
16
|
+
- **`brain_status`** —— 本地自检:报告 MCP 命令和认证模式(`env`、`external` 或 `missing`),不打印密钥、不调用 API。
|
|
17
|
+
- **一个真正能跑的工作流** —— 探索字段 → 写表达式 → 仿真 → 读检查 → 比相关性 → 最后才考虑提交。
|
|
18
|
+
- **无需构建** —— 纯 ESM JavaScript + YAML patch,git 或 npm 都能直接装。
|
|
19
|
+
|
|
20
|
+
## 安装
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
dsh plugin --profile web add dsh-worldquant
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
也可以直接从 GitHub 装(无需构建):
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
dsh plugin --profile web add github:bit0620/dsh-worldquant
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 配置 BRAIN MCP server
|
|
33
|
+
|
|
34
|
+
bundle 启动时读取这些环境变量:
|
|
35
|
+
|
|
36
|
+
| 变量 | 默认值 | 含义 |
|
|
37
|
+
| --- | --- | --- |
|
|
38
|
+
| `BRAIN_USERNAME` | — | BRAIN 账号邮箱 |
|
|
39
|
+
| `BRAIN_PASSWORD` | — | BRAIN 密码 |
|
|
40
|
+
| `BRAIN_MCP_COMMAND` | `python` | 启动 MCP server 的可执行文件 |
|
|
41
|
+
| `BRAIN_MCP_ARGS` | `["-m","wq_mcp"]` | JSON 字符串数组 |
|
|
42
|
+
| `BRAIN_MCP_SERVER_NAME` | `brain` | 工具命名空间(`mcp__brain__*`) |
|
|
43
|
+
|
|
44
|
+
### 方式 A:已安装 `wq-brain-mcp`
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
python -m wq_mcp
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
配置好账号密码,命令和参数保持默认即可。
|
|
51
|
+
|
|
52
|
+
### 方式 B:你自己的 BRAIN bridge 脚本
|
|
53
|
+
|
|
54
|
+
很多 BRAIN 用户已经有一个通过 stdio 提供 MCP 的 Python 文件:
|
|
55
|
+
|
|
56
|
+
```powershell
|
|
57
|
+
$env:BRAIN_MCP_ARGS='["D:\\123\\Documents\\wq\\platform_functions.py"]'
|
|
58
|
+
$env:BRAIN_USERNAME='you@example.com'
|
|
59
|
+
$env:BRAIN_PASSWORD='...'
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
重启 DSH。命名空间默认是 `mcp__brain__*`。
|
|
63
|
+
|
|
64
|
+
### 方式 C:其他 stdio MCP server
|
|
65
|
+
|
|
66
|
+
```powershell
|
|
67
|
+
$env:BRAIN_MCP_COMMAND='uvx'
|
|
68
|
+
$env:BRAIN_MCP_ARGS='["--from","wq-brain-mcp","wq-mcp"]'
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
这个 bundle 暂不包含 Streamable HTTP;如果你的 server 用 HTTP,在 profile 里再加一行 `@deepseek-ai/dsh-mcp-client`。
|
|
72
|
+
|
|
73
|
+
### 自认证 server
|
|
74
|
+
|
|
75
|
+
有些本地 BRAIN bridge 自己保存 session/JWT,不读环境变量里的 `BRAIN_USERNAME` / `BRAIN_PASSWORD`。这种情况下只设置 `BRAIN_MCP_COMMAND` 和 `BRAIN_MCP_ARGS`,不要设置账号密码。`brain_status` 会报告 `authMode: external` 和 `configured: true`,认证由 MCP server 自己负责。
|
|
76
|
+
|
|
77
|
+
默认的 `python -m wq_mcp` 是给“从环境变量读凭据”的 server 用的。按你的 bridge 选对应方式。
|
|
78
|
+
|
|
79
|
+
## 验证
|
|
80
|
+
|
|
81
|
+
对 Agent 说:
|
|
82
|
+
|
|
83
|
+
> 调用 `brain_status`,然后列出你能看到的 BRAIN 工具。
|
|
84
|
+
|
|
85
|
+
配置正常时返回 `configured: true`,工具列表里出现 `mcp__brain__*`。如果工具没出现,说明 MCP server 启动失败;DSH 日志会指出 `mcp-brain` 这一行和具体错误。
|
|
86
|
+
|
|
87
|
+
### 真实 BRAIN 账号验证
|
|
88
|
+
|
|
89
|
+
2026-11-28,在 DSH headless profile 里通过本 bundle 启动本地 stdio BRAIN MCP server。`mcp__brain__get_datasets` 返回 USA / TOP3000 / delay 1 的 **289 个数据集**,包括:
|
|
90
|
+
|
|
91
|
+
- `acquisition_model` — Corporate Acquisition Likelihood Model(coverage 0.9063,15 个字段)
|
|
92
|
+
- `ai_equity_alpha` — AI Equity Alpha Forecasts(coverage 0.9049,1108 个字段)
|
|
93
|
+
|
|
94
|
+
全程只读:没有仿真、没有提交、没有创建 alpha。server 自己完成认证;`brain_status` 现在会把这种情况报告为 `authMode: external`。详情见 [docs/verification-2026-11-28.md](docs/verification-2026-11-28.md)。
|
|
95
|
+
|
|
96
|
+
## 研究循环
|
|
97
|
+
|
|
98
|
+
### 1. 先探索
|
|
99
|
+
|
|
100
|
+
> 用 BRAIN 工具列出 USA/TOP3000/delay-1 的数据集,按字段覆盖率排序,给出覆盖率最高的五个字段和它们的非零比例。
|
|
101
|
+
|
|
102
|
+
要求 Agent 调用 MCP 工具,而不是编造字段名。输出应包含 dataset id、field id、coverage、更新频率。
|
|
103
|
+
|
|
104
|
+
### 2. 一次只写一个表达式
|
|
105
|
+
|
|
106
|
+
> 只用上面的字段提出三个表达式。每个用一句话说明经济直觉、使用的算子、预期 turnover 区间。先不要仿真。
|
|
107
|
+
|
|
108
|
+
把“提想法”和“跑仿真”分开,能低成本否掉坏点子。
|
|
109
|
+
|
|
110
|
+
### 3. 明确设置后再仿真
|
|
111
|
+
|
|
112
|
+
> 用 USA、TOP3000、delay 1、decay 0、INDUSTRY 中性化仿真表达式 A。报告 Sharpe、fitness、turnover、margin,以及每一个失败检查。不要提交。
|
|
113
|
+
|
|
114
|
+
插件本身不提供提交工具。如果你的 MCP server 有提交能力,要求 Agent 在调用前停下来。
|
|
115
|
+
|
|
116
|
+
### 4. 对比后再决定
|
|
117
|
+
|
|
118
|
+
> 把新 Alpha 的 PnL 和我最近提交的 20 个 Alpha 对比。相关性超过 0.7 的标出来,并解释可能共享了什么暴露。
|
|
119
|
+
|
|
120
|
+
### 5. 提交前门禁
|
|
121
|
+
|
|
122
|
+
提交前要求 transcript 里同时具备:
|
|
123
|
+
|
|
124
|
+
- IS Sharpe 和 fitness 达到你的阈值
|
|
125
|
+
- turnover 在平台限制内
|
|
126
|
+
- 所有 submission check 通过
|
|
127
|
+
- self-correlation 和 prod-correlation 低于你的限制
|
|
128
|
+
- 一段书面理由说明这不是已有 Alpha 的换皮
|
|
129
|
+
|
|
130
|
+
缺任何一项,正确动作都是 **不要提交**。
|
|
131
|
+
|
|
132
|
+
## 推荐系统提示
|
|
133
|
+
|
|
134
|
+
把这段加进 `AGENTS.md` 或会话提示:
|
|
135
|
+
|
|
136
|
+
```text
|
|
137
|
+
你是一名 BRAIN Alpha 研究助手。
|
|
138
|
+
- 只使用 BRAIN 工具返回的字段,绝不猜字段 id。
|
|
139
|
+
- 先提出表达式,再仿真。
|
|
140
|
+
- 报告每一个仿真检查,包括失败项。
|
|
141
|
+
- 没有用户在同一轮明确确认,绝不调用提交工具。
|
|
142
|
+
- 仿真后,把 PnL 和用户已有 Alpha 做相关性对比。
|
|
143
|
+
- 一个表达式只验证一个清晰假设,不要堆公式。
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## 为什么做成插件而不是一段提示
|
|
147
|
+
|
|
148
|
+
提示可以描述流程,但无法保证工具存在、无法避免凭据进入 transcript、也无法让 MCP 连接失败变得可见。这个 bundle 负责这些:
|
|
149
|
+
|
|
150
|
+
- MCP 配置和插件一起版本化;
|
|
151
|
+
- `brain_status` 在不泄露密钥的前提下诊断配置;
|
|
152
|
+
- 工作流随插件发布、随插件更新;
|
|
153
|
+
- 同一个包在 Web UI、headless 和 eval suite 里都能用。
|
|
154
|
+
|
|
155
|
+
## 路线图
|
|
156
|
+
|
|
157
|
+
- [ ] Streamable HTTP 传输
|
|
158
|
+
- [ ] 批量仿真队列 + 本地账本
|
|
159
|
+
- [ ] Alpha diff 报告(表达式、设置、指标、检查)
|
|
160
|
+
- [ ] 面向 BRAIN 工作流的 `dsh-regress` eval pack(字段选择、表达式修复、提交门禁)
|
|
161
|
+
- [ ] 只读模式:即使 MCP server 暴露 submit,也只注册研究工具
|
|
162
|
+
|
|
163
|
+
欢迎 issue 和 PR。如果你的 BRAIN MCP server 启动方式不同,提交 issue 时只给命令,不要给凭据。
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
MIT © 2026 Bit0620
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# A DSH bundle may insert any in-box plugin row. This one mounts the official
|
|
2
|
+
# MCP client for a WorldQuant BRAIN MCP server, then dsh-worldquant adds the
|
|
3
|
+
# preflight tool on top.
|
|
4
|
+
- insert:
|
|
5
|
+
- id: mcp-brain
|
|
6
|
+
name: '@deepseek-ai/dsh-mcp-client'
|
|
7
|
+
config:
|
|
8
|
+
serverName: !!js process.env.BRAIN_MCP_SERVER_NAME ?? 'brain'
|
|
9
|
+
transport: stdio
|
|
10
|
+
command: !!js process.env.BRAIN_MCP_COMMAND ?? 'python'
|
|
11
|
+
args: !!js "process.env.BRAIN_MCP_ARGS ? JSON.parse(process.env.BRAIN_MCP_ARGS) : ['-m', 'wq_mcp']"
|
|
12
|
+
env:
|
|
13
|
+
BRAIN_USERNAME: !!js process.env.BRAIN_USERNAME ?? ''
|
|
14
|
+
BRAIN_PASSWORD: !!js process.env.BRAIN_PASSWORD ?? ''
|
|
15
|
+
startupTimeoutMs: 20000
|
|
16
|
+
toolCallTimeoutMs: 120000
|
|
17
|
+
failOnStartupError: false
|
|
18
|
+
- id: dsh-worldquant
|
|
19
|
+
name: dsh-worldquant
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Live BRAIN verification — 2026-11-28
|
|
2
|
+
|
|
3
|
+
This note records a real, read-only run of `dsh-worldquant` against a live WorldQuant BRAIN account. No credentials, tokens, account identifiers, or personal data are included.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
- DSH `0.2.2-rc.5`, Node 24, Windows 11
|
|
8
|
+
- A custom headless DSH profile (`bench-ds`) with `dsh-worldquant@0.1.0` installed
|
|
9
|
+
- A local stdio BRAIN MCP server launched by the bundle's `mcp-brain` row
|
|
10
|
+
- Model: the user's local Magpie gateway, provider model `group/ds`
|
|
11
|
+
- The MCP server authenticated itself; `BRAIN_USERNAME` / `BRAIN_PASSWORD` were not set
|
|
12
|
+
|
|
13
|
+
The first attempt used a malformed `BRAIN_MCP_ARGS` value (single-escaped Windows path). The row failed to start and no `mcp__brain__*` tools appeared. After fixing the JSON escaping, the MCP server started and registered its tools.
|
|
14
|
+
|
|
15
|
+
## Prompt
|
|
16
|
+
|
|
17
|
+
> Call brain_status. Then, even if brain_status warns about credentials, call the available mcp__brain__* tools to list 2 datasets for USA TOP3000 delay 1. Read-only; do not simulate or submit.
|
|
18
|
+
|
|
19
|
+
## Observed
|
|
20
|
+
|
|
21
|
+
- `brain_status` initially reported `configured: false` because no `BRAIN_USERNAME` / `BRAIN_PASSWORD` were present. This was misleading for a self-authenticating server; version 0.1.1 adds `authMode: external` and treats that as configured.
|
|
22
|
+
- The MCP server logged `No JWT token found`, loaded its own saved config, re-authenticated, and stored the JWT.
|
|
23
|
+
- `mcp__brain__get_datasets` with `region=USA`, `universe=TOP3000`, `delay=1` returned `count: 289`.
|
|
24
|
+
- The model reported two datasets:
|
|
25
|
+
- `acquisition_model` — Corporate Acquisition Likelihood Model, coverage 0.9063, 15 fields
|
|
26
|
+
- `ai_equity_alpha` — AI Equity Alpha Forecasts, coverage 0.9049, 1108 fields
|
|
27
|
+
- No simulation, submission, or alpha creation was performed.
|
|
28
|
+
|
|
29
|
+
## Reproduction notes
|
|
30
|
+
|
|
31
|
+
- `BRAIN_MCP_ARGS` must be valid JSON. A Windows path needs either forward slashes (`D:/path/to/server.py`) or escaped backslashes (`D:\\path\\to\\server.py`).
|
|
32
|
+
- A server that owns its own authentication does not need `BRAIN_USERNAME` / `BRAIN_PASSWORD`. Set only `BRAIN_MCP_COMMAND` and `BRAIN_MCP_ARGS`.
|
|
33
|
+
- Restart DSH after changing MCP configuration; tools are registered at startup and cannot be hot-loaded into an existing session.
|
|
34
|
+
- Start with a read-only query and inspect the returned dataset ids before running a simulation.
|
|
35
|
+
|
|
36
|
+
## What this does and does not prove
|
|
37
|
+
|
|
38
|
+
It proves the bundle can start a BRAIN MCP server in DSH, expose its tools, and complete a read-only API query with a real account. It does not prove every MCP server shape works, nor does it validate a simulation or submission path. Those need separate, explicit runs.
|
package/index.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
export const name = 'dsh-worldquant'
|
|
2
|
+
export const inject = ['tools']
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mount the WorldQuant BRAIN MCP bridge and expose a preflight tool.
|
|
6
|
+
*
|
|
7
|
+
* The bridge itself is an ordinary `@deepseek-ai/dsh-mcp-client` row in
|
|
8
|
+
* cordis.patch.yml. Its tools appear as `mcp__brain__*`; this plugin only adds
|
|
9
|
+
* a local status check so a failed connection is diagnosable without reading
|
|
10
|
+
* the harness log.
|
|
11
|
+
*/
|
|
12
|
+
export function apply(ctx) {
|
|
13
|
+
ctx.tools.register({
|
|
14
|
+
name: 'brain_status',
|
|
15
|
+
description:
|
|
16
|
+
'Report how the WorldQuant BRAIN MCP bridge is configured: credential presence, ' +
|
|
17
|
+
'MCP command, server name and next steps. Reads environment variables only; ' +
|
|
18
|
+
'never prints secrets and never calls the BRAIN API.',
|
|
19
|
+
parameters: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
additionalProperties: false,
|
|
22
|
+
properties: {},
|
|
23
|
+
},
|
|
24
|
+
output: {
|
|
25
|
+
schema: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
properties: {
|
|
29
|
+
configured: { type: 'boolean' },
|
|
30
|
+
authMode: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
enum: ['env', 'external', 'missing'],
|
|
33
|
+
},
|
|
34
|
+
credentials: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
additionalProperties: false,
|
|
37
|
+
properties: {
|
|
38
|
+
usernameSet: { type: 'boolean' },
|
|
39
|
+
passwordSet: { type: 'boolean' },
|
|
40
|
+
},
|
|
41
|
+
required: ['usernameSet', 'passwordSet'],
|
|
42
|
+
},
|
|
43
|
+
mcp: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
properties: {
|
|
47
|
+
serverName: { type: 'string' },
|
|
48
|
+
transport: { type: 'string' },
|
|
49
|
+
command: { type: 'string' },
|
|
50
|
+
args: { type: 'array', items: { type: 'string' } },
|
|
51
|
+
},
|
|
52
|
+
required: ['serverName', 'transport', 'command', 'args'],
|
|
53
|
+
},
|
|
54
|
+
next: { type: 'array', items: { type: 'string' } },
|
|
55
|
+
},
|
|
56
|
+
required: ['configured', 'authMode', 'credentials', 'mcp', 'next'],
|
|
57
|
+
},
|
|
58
|
+
render: (_args, value) => [{ type: 'text', text: renderStatus(value) }],
|
|
59
|
+
},
|
|
60
|
+
async execute() {
|
|
61
|
+
const usernameSet = Boolean(process.env.BRAIN_USERNAME)
|
|
62
|
+
const passwordSet = Boolean(process.env.BRAIN_PASSWORD)
|
|
63
|
+
const command = process.env.BRAIN_MCP_COMMAND ?? 'python'
|
|
64
|
+
const serverName = process.env.BRAIN_MCP_SERVER_NAME ?? 'brain'
|
|
65
|
+
|
|
66
|
+
let args = ['-m', 'wq_mcp']
|
|
67
|
+
let argsValid = true
|
|
68
|
+
if (process.env.BRAIN_MCP_ARGS) {
|
|
69
|
+
try {
|
|
70
|
+
const parsed = JSON.parse(process.env.BRAIN_MCP_ARGS)
|
|
71
|
+
if (!Array.isArray(parsed) || parsed.some(item => typeof item !== 'string')) {
|
|
72
|
+
throw new Error('expected a JSON array of strings')
|
|
73
|
+
}
|
|
74
|
+
args = parsed
|
|
75
|
+
} catch (error) {
|
|
76
|
+
argsValid = false
|
|
77
|
+
args = [`<invalid BRAIN_MCP_ARGS: ${error.message}>`]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const customServer = Boolean(process.env.BRAIN_MCP_COMMAND || process.env.BRAIN_MCP_ARGS)
|
|
82
|
+
const authMode = usernameSet && passwordSet ? 'env' : customServer ? 'external' : 'missing'
|
|
83
|
+
const configured = argsValid && authMode !== 'missing'
|
|
84
|
+
|
|
85
|
+
const next = []
|
|
86
|
+
if (authMode === 'missing') {
|
|
87
|
+
next.push('Set BRAIN_USERNAME and BRAIN_PASSWORD, or configure a self-authenticating server with BRAIN_MCP_COMMAND/BRAIN_MCP_ARGS.')
|
|
88
|
+
}
|
|
89
|
+
if (authMode === 'external') {
|
|
90
|
+
next.push('External-auth server: the MCP process owns authentication; missing BRAIN_USERNAME/BRAIN_PASSWORD is expected.')
|
|
91
|
+
}
|
|
92
|
+
if (!argsValid) {
|
|
93
|
+
next.push('Fix BRAIN_MCP_ARGS: it must be a JSON array of strings, e.g. ["-m","wq_mcp"].')
|
|
94
|
+
}
|
|
95
|
+
next.push(`Start a session and call mcp__${serverName}__* tools; if they are absent, check the harness log for mcp-brain.`)
|
|
96
|
+
next.push('Run a read-only query first (datasets/fields), then simulate; never auto-submit an alpha.')
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
configured,
|
|
100
|
+
authMode,
|
|
101
|
+
credentials: { usernameSet, passwordSet },
|
|
102
|
+
mcp: { serverName, transport: 'stdio', command, args },
|
|
103
|
+
next,
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function renderStatus(value) {
|
|
110
|
+
const auth = value.authMode === 'env'
|
|
111
|
+
? 'environment credentials'
|
|
112
|
+
: value.authMode === 'external'
|
|
113
|
+
? 'external server (the MCP process owns authentication)'
|
|
114
|
+
: 'missing'
|
|
115
|
+
const lines = [
|
|
116
|
+
`dsh-worldquant: ${value.configured ? 'configured' : 'incomplete'}`,
|
|
117
|
+
`auth: ${auth}`,
|
|
118
|
+
`credentials: username ${value.credentials.usernameSet ? 'set' : 'missing'}, password ${value.credentials.passwordSet ? 'set' : 'missing'}`,
|
|
119
|
+
`mcp: server "${value.mcp.serverName}" via ${value.mcp.command} ${value.mcp.args.join(' ')}`,
|
|
120
|
+
]
|
|
121
|
+
for (const step of value.next) lines.push(`- ${step}`)
|
|
122
|
+
return lines.join('\n')
|
|
123
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-worldquant",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "WorldQuant BRAIN inside DeepSeek Harness: an MCP bridge, preflight checks and a safety-first alpha research workflow.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"index.js",
|
|
12
|
+
"cordis.patch.yml",
|
|
13
|
+
"README.md",
|
|
14
|
+
"README.zh.md",
|
|
15
|
+
"LICENSE",
|
|
16
|
+
"docs"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=20",
|
|
20
|
+
"dsh": ">=0.2.0 <0.3.0"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"registry": "https://registry.npmjs.org/"
|
|
25
|
+
},
|
|
26
|
+
"dsh": {
|
|
27
|
+
"bundle": {
|
|
28
|
+
"patch": "./cordis.patch.yml"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"dsh-plugin",
|
|
33
|
+
"deepseek-harness",
|
|
34
|
+
"worldquant",
|
|
35
|
+
"brain",
|
|
36
|
+
"alpha",
|
|
37
|
+
"quant",
|
|
38
|
+
"finance",
|
|
39
|
+
"mcp"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"test": "node --test test/status.test.js"
|
|
43
|
+
},
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/Bit0620/dsh-worldquant.git"
|
|
48
|
+
}
|
|
6
49
|
}
|