@onebullex-group/cli 1.3.1 → 1.5.0

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/README.md CHANGED
@@ -1,243 +1,304 @@
1
- # @onebullex-group/cli
2
-
3
- OneBullEx Open API V2 的命令行工具。
4
-
5
- > 当前版本(1.1.0)覆盖 V2 文档的全部 60 个端点:22 个公开 + 18 个私有只读 + 20 个写。所有写命令默认 dry-run,需 `--confirm` 才真发请求。
6
-
7
- ---
8
-
9
- ## 安装
10
-
11
- ```bash
12
- npm i -g @onebullex-group/cli
13
- ```
14
-
15
- 或本地构建:
16
-
17
- ```bash
18
- cd cli
19
- pnpm install
20
- pnpm build
21
- pnpm link --global
22
- ```
23
-
24
- 校验:
25
-
26
- ```bash
27
- onebullex --version
28
- onebullex public time --base-url https://futures-openapi.1bullex.com
29
- ```
30
-
31
- ## Quick Start
32
-
33
- ```bash
34
- # 1. 初始化一个 profile(向导式)
35
- onebullex config init
36
-
37
- # 2. 看下当前 profile 配置(敏感字段已脱敏)
38
- onebullex config show
39
-
40
- # 3. 跑公开接口验证联通性
41
- onebullex public time
42
- onebullex symbol list
43
-
44
- # 4. 跑私有只读接口(需要在 config init 时填了 api-key/secret)
45
- onebullex balance list
46
- onebullex position list
47
- ```
48
-
49
- ## 命令分组
50
-
51
- 完整命令列表跟 V2 文档逐项对齐,可用 `onebullex <group> --help` 查询。
52
-
53
- ### 公开(22)
54
-
55
- ```
56
- public time GET /v2/public/time
57
- symbol list / get / coins / all
58
- ticker get / list / agg / agg-list
59
- depth get
60
- deal list
61
- kline list
62
- mark-price list / get
63
- index-price list / get* (* index-price get 需要认证)
64
- funding rate / history
65
- risk-balance list
66
- open-interest get
67
- leverage brackets-list / brackets-get
68
- ```
69
-
70
- ### 私有只读(18)
71
-
72
- ```
73
- listen-key get
74
- balance list / get / bills
75
- order list-unfinished / list-unfinished-multi / list / list-by-ids /
76
- list-history / get / trades
77
- entrust plan-list / plan-history / plan-get / profit-list / profit-get
78
- order-entrust list
79
- position list
80
- ```
81
-
82
- ### 写操作(20)
83
-
84
- 所有写命令默认 dry-run:仅打印预览不发请求。**加 `--confirm` 才会真正下单/撤单/改仓。**
85
-
86
- ```
87
- order create / create-batch / cancel / cancel-batch / cancel-all
88
- entrust create-plan / create-profit /
89
- cancel-plan / cancel-profit / update-profit /
90
- cancel-all-plan / cancel-all-profit
91
- order-entrust cancel / cancel-all
92
- position adjust-leverage / margin / auto-margin /
93
- close-all / merge / change-type
94
- ```
95
-
96
- 例:
97
- ```bash
98
- # dry-run(默认,退出码 4,preview 在 stdout)
99
- onebullex order create --symbol btc_usdt --order-type LIMIT \
100
- --order-side BUY --position-side LONG --orig-qty 0.001 --price 50000
101
-
102
- # 真正下单
103
- onebullex order create --symbol btc_usdt --order-type LIMIT \
104
- --order-side BUY --position-side LONG --orig-qty 0.001 --price 50000 \
105
- --confirm
106
- ```
107
-
108
- CLI flag 用 kebab-case,会映射到 API 的 camelCase 字段(如 `--order-side` → `orderSide`)。批量类(`create-batch` / `cancel-batch`)的 `--list` / `--order-ids` 接受 JSON 字符串数组。
109
-
110
- ### 配置管理(6)
111
-
112
- ```
113
- config init 交互式向导
114
- config set <key> 仅 base-url / identify / env 可用 --value
115
- api-key / secret 必须用 --stdin
116
- config show [--reveal] 默认脱敏,加 --reveal 后明文(带 stderr 警告)
117
- config use <profile> 切换默认 profile
118
- config list-profiles 表格列出全部 profile
119
- config remove <p> 删除 profile(防止删掉最后一个)
120
- ```
121
-
122
- ## 配置文件
123
-
124
- 默认路径 `~/.onebullex/config.json`,权限 0600(非 Windows 上自动校正)。
125
-
126
- ```json
127
- {
128
- "version": 1,
129
- "default-profile": "test",
130
- "profiles": {
131
- "test": {
132
- "base-url": "https://futures-openapi.1bullex.com",
133
- "api-key": "AK...",
134
- "secret": "...",
135
- "identify": null,
136
- "env": "test"
137
- }
138
- }
139
- }
140
- ```
141
-
142
- 可通过 `ONEBULLEX_CONFIG_PATH` 环境变量覆盖路径(脚本/CI 友好)。
143
-
144
- ## 优先级与全局 flag
145
-
146
- 每次调用按以下顺序解析:
147
-
148
- ```
149
- CLI flag > 环境变量 > 配置文件 profile > 报错(要求 config init)
150
- ```
151
-
152
- | 全局 flag | 环境变量 | 说明 |
153
- |---|---|---|
154
- | `--profile <name>` | `ONEBULLEX_PROFILE` | 临时切换 profile |
155
- | `--api-key <key>` | `ONEBULLEX_API_KEY` | 覆盖 api key |
156
- | `--secret <s>` | `ONEBULLEX_SECRET` | 覆盖 secret(不建议 CLI 上明文) |
157
- | `--base-url <url>` | `ONEBULLEX_BASE_URL` | 覆盖 base URL |
158
- | `--output <fmt>` | — | `table` / `json`,TTY 默认 table,否则 json |
159
- | `--debug` | `ONEBULLEX_DEBUG=1` | 把请求/响应(脱敏后)写到 stderr |
160
- | `--timeout <ms>` | — | HTTP 超时,默认 10s |
161
- | `--confirm` | — | Phase 2 写命令使用,未传时走 dry-run |
162
-
163
- ## 安全
164
-
165
- - secret 与 api-key **明文落盘**在 config.json,权限收紧到 0600
166
- - `config set api-key` / `config set secret` 拒绝 `--value`,强制 `--stdin`,防止 shell history 泄漏
167
- - `config show` 默认脱敏(`AK****1234` / `****`),仅 `--reveal` 时明文并带 stderr 警告
168
- - `--debug` 输出会通过 redact 过滤掉 `X-Signature` / `X-API-KEY` / `Authorization` / `secret` 字段
169
- - 每次调用都会校验 `~/.onebullex/config.json` 的 mode(非 win32),不是 0600 时打 warn 并自动修复
170
-
171
- ## 输出格式
172
-
173
- - TTY 下默认表格(`cli-table3`),列名取并集,时间戳列自动渲染成 `YYYY-MM-DD HH:mm:ss`
174
- - 非 TTY(管道、重定向、CI)默认 JSON,`jq` 友好
175
- - 任意时候用 `--output json` 强制 JSON,`--output table` 强制表格
176
-
177
- ## 防漂移 lint
178
-
179
- `pnpm check-coverage` 跑三层校验:
180
-
181
- 1. **端点级**:把 `docs/onebullex-openapi-cn-v2.md` 里的所有 `#### GET/POST /v2/*` 标题与 `cli/src/registry.ts` 对账,缺/多就 fail
182
- 2. **参数级**:用 ts-morph 解析每个命令文件,提取 commander 的 `command()` / `requiredOption()` / `option()`,与文档参数表的 `必填` 列对账
183
- 3. **写守门**:方法是 GET 但 `isWrite=true`,或者 method 是 POST 但 `isWrite=false`(`/v2/order/list-by-ids` 是已知例外)
184
-
185
- CI 上当文档新增一个端点时,coverage 检查会立刻 fail,强制开发者补一个新命令。
186
-
187
- ## 开发
188
-
189
- ```bash
190
- cd cli
191
- pnpm install
192
- pnpm dev <command> # 直接跑 src/index.ts,无需先 build
193
- pnpm test # 跑全部单测/集成测
194
- pnpm typecheck # tsc --noEmit
195
- pnpm lint # biome
196
- pnpm check-coverage # 防漂移 lint
197
- pnpm build # 产出 dist/index.js
198
- ```
199
-
200
- ### 跑 testnet e2e
201
-
202
- 只读 e2e(默认跳过)只验证公开接口连通性:
203
-
204
- ```bash
205
- ONEBULLEX_E2E=1 pnpm vitest run tests/e2e/public.e2e.test.ts
206
- ```
207
-
208
- 写 e2e(默认跳过)会真发请求到 testnet:下/撤远价限价单、改杠杆、改持仓模式、用 MARKET 单开仓 → 加保证金 → 创建止盈止损 → close-all。需要测试网账户和 ≥ 50 USDT 余额:
209
-
210
- ```bash
211
- ONEBULLEX_E2E=1 \
212
- ONEBULLEX_E2E_API_KEY=<testnet-key> \
213
- ONEBULLEX_E2E_SECRET=<testnet-secret> \
214
- pnpm vitest run tests/e2e/write.e2e.test.ts
215
- ```
216
-
217
- 按业务流程组织成 4 个 block,串行执行:configuration chain → limit order chain → plan + order-entrust chain → position + profit chain。每个 block 末尾有 best-effort `cancel-all` / `close-all`,跑挂时也尽量不留挂单/持仓残留。
218
-
219
- #### Nightly CI(可选)
220
-
221
- `cli/.gitlab-ci.yml` 里有一个 `cli-e2e-nightly` job,仅在 schedule 触发时跑(`$CI_PIPELINE_SOURCE == "schedule"`),跑完整 `tests/e2e/` 套件。开启方式:
222
-
223
- 1. 在 GitLab project **Settings → CI/CD → Variables** 添加 masked + protected 变量:
224
- - `ONEBULLEX_E2E_API_KEY` = testnet API key
225
- - `ONEBULLEX_E2E_SECRET` = testnet API secret
226
- 2. **Build → Pipeline schedules → New schedule**,cron 设成例如 `0 19 * * *`(每日 03:00 UTC+8),target branch 选 `main`。
227
-
228
- job 标 `allow_failure: true` 且 retry 一次——testnet 偶发抖动不会阻塞调度。变量没配时只有 public e2e 跑,写 e2e 自动 skip(HAS_AUTH 门控)。
229
-
230
- ## 与 Java SDK 的关系
231
-
232
- 签名实现严格对齐 `src/main/java/com/onebullex/api/common/SignatureUtilsV2.java`:
233
-
234
- - timestamp 秒级(10 位)
235
- - nonce 是 UUID v4 去横线(32 位 hex 小写)
236
- - query string 按 key 字典序排序,**不做 URL 编码**
237
- - HMAC-SHA256,输出 hex 小写
238
-
239
- Java 端通过 `SignatureVectorGenTest` 生成 `cli/tests/fixtures/signature-vectors.json`,CLI 端 `signature-parity.test.ts` 把 7 条向量逐条对照 Java 输出,保证字节级一致。
240
-
241
- ## License
242
-
243
- MIT
1
+ # @onebullex-group/cli
2
+
3
+ OneBullEx Open API V2 的命令行工具。
4
+
5
+ > 当前版本(1.5.0)覆盖 V2 文档的全部 68 个端点:22 个公开 + 25 个私有只读 + 21 个写。所有写命令默认 dry-run,需 `--confirm` 才真发请求。
6
+
7
+ ---
8
+
9
+ ## 安装
10
+
11
+ ```bash
12
+ npm i -g @onebullex-group/cli
13
+ ```
14
+
15
+ 或本地构建:
16
+
17
+ ```bash
18
+ cd cli
19
+ pnpm install
20
+ pnpm build
21
+ pnpm link --global
22
+ ```
23
+
24
+ 校验:
25
+
26
+ ```bash
27
+ onebullex --version
28
+ onebullex public time --base-url https://futures-openapi.1bullex.com
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ```bash
34
+ # 1. 初始化一个 profile(向导式)
35
+ onebullex config init
36
+
37
+ # 2. 看下当前 profile 配置(敏感字段已脱敏)
38
+ onebullex config show
39
+
40
+ # 3. 跑公开接口验证联通性
41
+ onebullex public time
42
+ onebullex symbol list
43
+
44
+ # 4. 跑私有只读接口(需要在 config init 时填了 api-key/secret)
45
+ onebullex balance list
46
+ onebullex position list
47
+ ```
48
+
49
+ ## 命令分组
50
+
51
+ 完整命令列表跟 V2 文档逐项对齐,可用 `onebullex <group> --help` 查询。
52
+
53
+ ### 公开(22)
54
+
55
+ ```
56
+ public time GET /v2/public/time
57
+ symbol list / get / coins / all
58
+ ticker get / list / agg / agg-list (`--time-range-type` 必填,如 H24 / UTC_P_8)
59
+ depth get (`--level` 必填,1–50)
60
+ deal list
61
+ kline list
62
+ mark-price list / get
63
+ index-price list / get
64
+ funding rate / history
65
+ risk-balance list
66
+ open-interest get
67
+ leverage brackets-list / brackets-get
68
+ ```
69
+
70
+ ### 私有只读(25)
71
+
72
+ ```
73
+ listen-key get
74
+ balance list / get / bills / funding
75
+ bot redeeming-info
76
+ order list-unfinished / list-unfinished-multi / list / list-by-ids /
77
+ list-history / get / trades
78
+ entrust plan-list / plan-history / plan-get / profit-list / profit-get
79
+ order-entrust list
80
+ position list / confs / history / history-async
81
+ system user-info / download
82
+ ```
83
+
84
+ ### 写操作(21)
85
+
86
+ 所有写命令默认 dry-run:仅打印预览不发请求。**加 `--confirm` 才会真正下单/撤单/改仓/划转。**
87
+
88
+ ```
89
+ balance transfer ⚠ 真实资金划转,见下方说明
90
+ order create / create-batch / cancel / cancel-batch / cancel-all
91
+ entrust create-plan / create-profit /
92
+ cancel-plan / cancel-profit / update-profit /
93
+ cancel-all-plan / cancel-all-profit
94
+ order-entrust cancel / cancel-all
95
+ position adjust-leverage / margin / auto-margin /
96
+ close-all / merge / change-type
97
+ ```
98
+
99
+ 例:
100
+ ```bash
101
+ # dry-run(默认,退出码 4,preview 在 stdout)
102
+ onebullex order create --symbol btc_usdt --order-type LIMIT \
103
+ --order-side BUY --position-side LONG --orig-qty 1 --price 50000
104
+
105
+ # 真正下单
106
+ onebullex order create --symbol btc_usdt --order-type LIMIT \
107
+ --order-side BUY --position-side LONG --orig-qty 1 --price 50000 \
108
+ --confirm
109
+ ```
110
+
111
+ CLI flag 用 kebab-case,会映射到 API 的 camelCase 字段(如 `--order-side` → `orderSide`)。批量类(`create-batch` / `cancel-batch`)的 `--list` / `--order-ids` 接受 JSON 字符串数组。
112
+
113
+ #### ⚠ 资金划转(`balance transfer`)
114
+
115
+ 在资金账户(`FUNDING`,存钱、不能交易)和合约账户(`CONTRACT`,交易占保证金)之间搬钱。
116
+ 划错不能撤销,只能反向再划一次。
117
+
118
+ ```bash
119
+ # dry-run:预览里会显示自动生成的 billNo
120
+ onebullex balance transfer --from FUNDING --to CONTRACT --amount 500
121
+
122
+ # 真正划转 —— 把预览里那个 billNo 原样带上
123
+ onebullex balance transfer --from FUNDING --to CONTRACT --amount 500 \
124
+ --bill-no obe-3f6c1e9a-... --confirm
125
+ ```
126
+
127
+ `--bill-no` 是幂等单号。省略时 CLI 会生成一个 `obe-<uuid>`,但**重试同一笔划转必须
128
+ 复用第一次的单号** —— 换新单号会被服务端当成第二笔,等于划两次。所以脚本里重试请
129
+ 先把 billNo 存下来,不要依赖自动生成。`--from` 与 `--to` 不能相同。
130
+
131
+ ### 配置管理(6)
132
+
133
+ ```
134
+ config init 交互式向导;新增 profile,--no-set-default 不改默认
135
+ config set <key> 仅 base-url / identify / env 可用 --value
136
+ api-key / secret 必须用 --stdin
137
+ config show [--reveal] 默认脱敏,加 --reveal 后明文(带 stderr 警告)
138
+ config use <profile> 切换默认 profile
139
+ config list-profiles 表格列出全部 profile
140
+ config remove <p> 删除 profile(防止删掉最后一个)
141
+ ```
142
+
143
+ ## 配置文件
144
+
145
+ 默认路径 `~/.onebullex/config.json`,权限 0600(非 Windows 上自动校正)。
146
+
147
+ ```json
148
+ {
149
+ "version": 1,
150
+ "default-profile": "test",
151
+ "profiles": {
152
+ "test": {
153
+ "base-url": "https://futures-openapi.1bullex.com",
154
+ "api-key": "AK...",
155
+ "secret": "...",
156
+ "identify": null,
157
+ "env": "test"
158
+ }
159
+ }
160
+ }
161
+ ```
162
+
163
+ 可通过 `ONEBULLEX_CONFIG_PATH` 环境变量覆盖路径(脚本/CI 友好)。
164
+
165
+ ## 多个 API Key(多 profile)
166
+
167
+ 一个 profile 对应一套 API Key。同一台电脑要用多个 Key,就在同一个配置文件里建多个 profile,调用时选一个。
168
+
169
+ **添加 profile**:每次 `config init` 新增(或覆盖同名)一个 profile,已有的 profile 保留。默认会把新 profile 设为默认,加 `--no-set-default` 则不改默认。
170
+
171
+ ```bash
172
+ onebullex config init # 交互式:Profile name 填 alice,按提示填 key/secret
173
+ onebullex config init --no-set-default # 再加一个:Profile name 填 bob,默认仍是 alice
174
+ onebullex config list-profiles # 带 * 的是默认 profile
175
+ ```
176
+
177
+ 非交互(脚本)时,key/secret 建议用 `--stdin` 写入,不进 shell history:
178
+
179
+ ```bash
180
+ onebullex config init --yes --no-set-default --name bob --env prod
181
+ onebullex --profile bob config set api-key --stdin # 粘贴后 Ctrl+D(Windows: Ctrl+Z 回车)
182
+ onebullex --profile bob config set secret --stdin
183
+ ```
184
+
185
+ **选用 profile**(优先级从高到低):
186
+
187
+ ```bash
188
+ onebullex --profile bob balance list # 单条命令临时切换,不改默认
189
+ ONEBULLEX_PROFILE=bob onebullex balance list # 当前 shell / 脚本内生效
190
+ onebullex config use bob # 改默认 profile(影响之后所有未指定的调用)
191
+ ```
192
+
193
+ 多个终端或多个 Claude 会话同时跑时,**用 `--profile` 或 `ONEBULLEX_PROFILE`,不要靠 `config use` 来回切**:默认 profile 存在共享的配置文件里,一边切换,另一边下一次调用就会用错账户。
194
+
195
+ 需要完全隔离(例如每个账户一份文件、不同权限的机器用户)时,用 `ONEBULLEX_CONFIG_PATH` 指向不同的配置文件:
196
+
197
+ ```bash
198
+ ONEBULLEX_CONFIG_PATH=~/.onebullex/alice.json onebullex balance list
199
+ ```
200
+
201
+ profile 名写错时会报 `未找到 baseUrl 配置`,先用 `config list-profiles` 核对名字。
202
+
203
+ MCP 场景下怎么同时连多个账户,见 [mcp/README.md](../mcp/README.md#多个-api-key多账户)。
204
+
205
+ ## 优先级与全局 flag
206
+
207
+ 每次调用按以下顺序解析:
208
+
209
+ ```
210
+ CLI flag > 环境变量 > 配置文件 profile > 报错(要求 config init)
211
+ ```
212
+
213
+ | 全局 flag | 环境变量 | 说明 |
214
+ |---|---|---|
215
+ | `--profile <name>` | `ONEBULLEX_PROFILE` | 临时切换 profile |
216
+ | `--api-key <key>` | `ONEBULLEX_API_KEY` | 覆盖 api key |
217
+ | `--secret <s>` | `ONEBULLEX_SECRET` | 覆盖 secret(不建议 CLI 上明文) |
218
+ | `--base-url <url>` | `ONEBULLEX_BASE_URL` | 覆盖 base URL |
219
+ | `--output <fmt>` | — | `table` / `json`,TTY 默认 table,否则 json |
220
+ | `--debug` | `ONEBULLEX_DEBUG=1` | 把请求/响应(脱敏后)写到 stderr |
221
+ | `--timeout <ms>` | — | HTTP 超时,默认 10s |
222
+ | `--confirm` | — | Phase 2 写命令使用,未传时走 dry-run |
223
+
224
+ ## 安全
225
+
226
+ - secret 与 api-key **明文落盘**在 config.json,权限收紧到 0600
227
+ - `config set api-key` / `config set secret` 拒绝 `--value`,强制 `--stdin`,防止 shell history 泄漏
228
+ - `config show` 默认脱敏(`AK****1234` / `****`),仅 `--reveal` 时明文并带 stderr 警告
229
+ - `--debug` 输出会通过 redact 过滤掉 `X-Signature` / `X-API-KEY` / `Authorization` / `secret` 字段
230
+ - 每次调用都会校验 `~/.onebullex/config.json` 的 mode(非 win32),不是 0600 时打 warn 并自动修复
231
+
232
+ ## 输出格式
233
+
234
+ - TTY 下默认表格(`cli-table3`),列名取并集,时间戳列自动渲染成 `YYYY-MM-DD HH:mm:ss`
235
+ - 非 TTY(管道、重定向、CI)默认 JSON,`jq` 友好
236
+ - 任意时候用 `--output json` 强制 JSON,`--output table` 强制表格
237
+
238
+ ## 防漂移 lint
239
+
240
+ `pnpm check-coverage` 跑三层校验:
241
+
242
+ 1. **端点级**:把 `docs/onebullex-openapi-cn-v2.md` 里的所有 `#### GET/POST /v2/*` 标题与 `cli/src/registry.ts` 对账,缺/多就 fail
243
+ 2. **参数级**:用 ts-morph 解析每个命令文件,提取 commander 的 `command()` / `requiredOption()` / `option()`,与文档参数表的 `必填` 列对账
244
+ 3. **写守门**:方法是 GET 但 `isWrite=true`,或者 method 是 POST 但 `isWrite=false`(`/v2/order/list-by-ids` 是已知例外)
245
+
246
+ CI 上当文档新增一个端点时,coverage 检查会立刻 fail,强制开发者补一个新命令。
247
+
248
+ ## 开发
249
+
250
+ ```bash
251
+ cd cli
252
+ pnpm install
253
+ pnpm dev <command> # 直接跑 src/index.ts,无需先 build
254
+ pnpm test # 跑全部单测/集成测
255
+ pnpm typecheck # tsc --noEmit
256
+ pnpm lint # biome
257
+ pnpm check-coverage # 防漂移 lint
258
+ pnpm build # 产出 dist/index.js
259
+ ```
260
+
261
+ ### 跑 testnet e2e
262
+
263
+ 只读 e2e(默认跳过)只验证公开接口连通性:
264
+
265
+ ```bash
266
+ ONEBULLEX_E2E=1 pnpm vitest run tests/e2e/public.e2e.test.ts
267
+ ```
268
+
269
+ 写 e2e(默认跳过)会真发请求到 testnet:下/撤远价限价单、改杠杆、改持仓模式、用 MARKET 单开仓 → 加保证金 → 创建止盈止损 → close-all。需要测试网账户和 ≥ 50 USDT 余额:
270
+
271
+ ```bash
272
+ ONEBULLEX_E2E=1 \
273
+ ONEBULLEX_E2E_API_KEY=<testnet-key> \
274
+ ONEBULLEX_E2E_SECRET=<testnet-secret> \
275
+ pnpm vitest run tests/e2e/write.e2e.test.ts
276
+ ```
277
+
278
+ 按业务流程组织成 4 个 block,串行执行:configuration chain → limit order chain → plan + order-entrust chain → position + profit chain。每个 block 末尾有 best-effort `cancel-all` / `close-all`,跑挂时也尽量不留挂单/持仓残留。
279
+
280
+ #### Nightly CI(可选)
281
+
282
+ `cli/.gitlab-ci.yml` 里有一个 `cli-e2e-nightly` job,仅在 schedule 触发时跑(`$CI_PIPELINE_SOURCE == "schedule"`),跑完整 `tests/e2e/` 套件。开启方式:
283
+
284
+ 1. 在 GitLab project **Settings → CI/CD → Variables** 添加 masked + protected 变量:
285
+ - `ONEBULLEX_E2E_API_KEY` = testnet API key
286
+ - `ONEBULLEX_E2E_SECRET` = testnet API secret
287
+ 2. **Build → Pipeline schedules → New schedule**,cron 设成例如 `0 19 * * *`(每日 03:00 UTC+8),target branch 选 `main`。
288
+
289
+ job 标 `allow_failure: true` 且 retry 一次——testnet 偶发抖动不会阻塞调度。变量没配时只有 public e2e 跑,写 e2e 自动 skip(HAS_AUTH 门控)。
290
+
291
+ ## 与 Java SDK 的关系
292
+
293
+ 签名实现严格对齐 `src/main/java/com/onebullex/api/common/SignatureUtilsV2.java`:
294
+
295
+ - timestamp 秒级(10 位)
296
+ - nonce 是 UUID v4 去横线(32 位 hex 小写)
297
+ - query string 按 key 字典序排序,**不做 URL 编码**
298
+ - HMAC-SHA256,输出 hex 小写
299
+
300
+ Java 端通过 `SignatureVectorGenTest` 生成 `cli/tests/fixtures/signature-vectors.json`,CLI 端 `signature-parity.test.ts` 把 7 条向量逐条对照 Java 输出,保证字节级一致。
301
+
302
+ ## License
303
+
304
+ MIT
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/core/bill-no.ts
4
+ import { randomUUID } from "crypto";
5
+ function generateBillNo() {
6
+ return `obe-${randomUUID()}`;
7
+ }
8
+ function resolveBillNo(supplied) {
9
+ const trimmed = supplied?.trim();
10
+ return trimmed ? trimmed : generateBillNo();
11
+ }
12
+
13
+ export {
14
+ generateBillNo,
15
+ resolveBillNo
16
+ };
@@ -128,7 +128,7 @@ var REGISTRY = [
128
128
  method: "GET",
129
129
  path: "/v2/public/q/symbol-index-price",
130
130
  isWrite: false,
131
- needsAuth: true,
131
+ needsAuth: false,
132
132
  implFile: "src/commands/index-price/get.ts"
133
133
  },
134
134
  {
@@ -212,6 +212,22 @@ var REGISTRY = [
212
212
  needsAuth: true,
213
213
  implFile: "src/commands/balance/bills.ts"
214
214
  },
215
+ {
216
+ command: "balance funding",
217
+ method: "GET",
218
+ path: "/v2/balance/funding",
219
+ isWrite: false,
220
+ needsAuth: true,
221
+ implFile: "src/commands/balance/funding.ts"
222
+ },
223
+ {
224
+ command: "bot redeeming-info",
225
+ method: "GET",
226
+ path: "/v2/bot/redeeming-info",
227
+ isWrite: false,
228
+ needsAuth: true,
229
+ implFile: "src/commands/bot/redeeming-info.ts"
230
+ },
215
231
  {
216
232
  command: "order list-unfinished",
217
233
  method: "GET",
@@ -340,7 +356,39 @@ var REGISTRY = [
340
356
  needsAuth: true,
341
357
  implFile: "src/commands/position/history.ts"
342
358
  },
359
+ {
360
+ command: "position history-async",
361
+ method: "GET",
362
+ path: "/v2/position/history/async",
363
+ isWrite: false,
364
+ needsAuth: true,
365
+ implFile: "src/commands/position/history-async.ts"
366
+ },
367
+ {
368
+ command: "system user-info",
369
+ method: "GET",
370
+ path: "/v2/system/user/info",
371
+ isWrite: false,
372
+ needsAuth: true,
373
+ implFile: "src/commands/system/user-info.ts"
374
+ },
375
+ {
376
+ command: "system download",
377
+ method: "GET",
378
+ path: "/v2/system/download",
379
+ isWrite: false,
380
+ needsAuth: true,
381
+ implFile: "src/commands/system/download.ts"
382
+ },
343
383
  // ───── Phase 2: write operations ─────
384
+ {
385
+ command: "balance transfer",
386
+ method: "POST",
387
+ path: "/v2/balance/transfer",
388
+ isWrite: true,
389
+ needsAuth: true,
390
+ implFile: "src/commands/balance/transfer.ts"
391
+ },
344
392
  {
345
393
  command: "order create",
346
394
  method: "POST",