@openfinclaw/openfinclaw-strategy 0.0.11 → 2026.3.14
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 +65 -94
- package/index.test.ts +11 -11
- package/index.ts +431 -532
- package/openclaw.plugin.json +26 -9
- package/package.json +10 -4
- package/skills/cross-asset-lite/SKILL.md +95 -0
- package/skills/crypto-altseason/SKILL.md +122 -0
- package/skills/crypto-funding-arb/SKILL.md +88 -0
- package/skills/crypto-stablecoin-flow/SKILL.md +103 -0
- package/skills/openfinclaw/SKILL.md +88 -79
- package/skills/price-check/SKILL.md +58 -0
- package/skills/quick-quote/SKILL.md +59 -0
- package/skills/skill-publish/SKILL.md +4 -4
- package/skills/strategy-builder/SKILL.md +124 -399
- package/skills/strategy-fork/SKILL.md +2 -2
- package/skills/strategy-pack/SKILL.md +12 -12
- package/src/cli.ts +3 -3
- package/src/config.ts +57 -0
- package/src/datahub/client.ts +150 -0
- package/src/fork.ts +7 -7
- package/src/types.ts +42 -0
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
# @openfinclaw/openfinclaw-strategy
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
OpenFinClaw - 统一金融工具插件。一个 API Key,一站式服务:
|
|
4
|
+
- **行情数据**: 价格查询、K线、加密市场数据、多资产对比、代码搜索
|
|
5
|
+
- **策略工具**: 发布、验证、Fork、排行榜
|
|
4
6
|
|
|
5
7
|
## 安装
|
|
6
8
|
|
|
7
|
-
```bash
|
|
8
|
-
curl -fsSL https://raw.githubusercontent.com/cryptoSUN2049/openFinclaw/main/scripts/install-finclaw.sh | bash
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
或手动安装:
|
|
12
|
-
|
|
13
9
|
```bash
|
|
14
10
|
openclaw plugins install @openfinclaw/openfinclaw-strategy
|
|
15
11
|
```
|
|
16
12
|
|
|
17
|
-
##
|
|
13
|
+
## 快速开始
|
|
18
14
|
|
|
19
15
|
```bash
|
|
20
|
-
#
|
|
16
|
+
# 查看策略排行榜(无需 API Key)
|
|
21
17
|
openclaw strategy leaderboard
|
|
22
18
|
|
|
23
19
|
# 查看收益榜 Top 10
|
|
@@ -27,29 +23,36 @@ openclaw strategy leaderboard returns --limit 10
|
|
|
27
23
|
openclaw strategy show <strategy-id> --remote
|
|
28
24
|
```
|
|
29
25
|
|
|
26
|
+
或者直接告诉 Agent 你想做什么:
|
|
27
|
+
|
|
28
|
+
- "BTC 现在多少钱" → Agent 会使用 `fin_price`
|
|
29
|
+
- "ETH 最近 7 天走势" → Agent 会使用 `fin_kline`
|
|
30
|
+
- "DeFi 哪个协议 TVL 最高" → Agent 会使用 `fin_crypto`
|
|
31
|
+
- "帮我看看排行榜有什么好策略" → Agent 会使用 `skill_leaderboard`
|
|
32
|
+
|
|
30
33
|
## 功能概览
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
42
|
-
###
|
|
43
|
-
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
| `skill_leaderboard`
|
|
47
|
-
| `skill_get_info`
|
|
48
|
-
| `skill_validate`
|
|
49
|
-
| `skill_list_local`
|
|
50
|
-
| `skill_fork`
|
|
51
|
-
| `skill_publish`
|
|
52
|
-
| `skill_publish_verify
|
|
35
|
+
### 行情数据工具
|
|
36
|
+
|
|
37
|
+
| 工具名 | 说明 | API Key |
|
|
38
|
+
| ----------------- | ---------------------------- | ------- |
|
|
39
|
+
| `fin_price` | 价格查询(股票/加密/指数) | 需要 |
|
|
40
|
+
| `fin_kline` | K线/OHLCV 数据 | 需要 |
|
|
41
|
+
| `fin_crypto` | 加密市场数据(21个端点) | 需要 |
|
|
42
|
+
| `fin_compare` | 多资产价格对比 | 需要 |
|
|
43
|
+
| `fin_slim_search` | 代码/名称搜索 | 需要 |
|
|
44
|
+
|
|
45
|
+
### 策略工具
|
|
46
|
+
|
|
47
|
+
| 工具名 | 说明 | API Key |
|
|
48
|
+
| --------------------- | -------------------------- | ------- |
|
|
49
|
+
| `skill_leaderboard` | 查询排行榜 | 不需要 |
|
|
50
|
+
| `skill_get_info` | 获取 Hub 策略公开详情 | 不需要 |
|
|
51
|
+
| `skill_validate` | 本地验证策略包(FEP v2.0) | 不需要 |
|
|
52
|
+
| `skill_list_local` | 列出本地策略 | 不需要 |
|
|
53
|
+
| `skill_fork` | 从 Hub 下载策略到本地 | **需要**|
|
|
54
|
+
| `skill_publish` | 发布策略 ZIP 到 Hub | **需要**|
|
|
55
|
+
| `skill_publish_verify`| 查询发布状态和回测报告 | **需要**|
|
|
53
56
|
|
|
54
57
|
## CLI 命令
|
|
55
58
|
|
|
@@ -71,92 +74,60 @@ openclaw strategy show <name-or-id> [--remote]
|
|
|
71
74
|
openclaw strategy remove <name-or-id> --force
|
|
72
75
|
```
|
|
73
76
|
|
|
74
|
-
### 排行榜类型
|
|
75
|
-
|
|
76
|
-
| 榜单类型 | 说明 |
|
|
77
|
-
| ----------- | -------------- |
|
|
78
|
-
| `composite` | 综合榜(默认) |
|
|
79
|
-
| `returns` | 收益榜 |
|
|
80
|
-
| `risk` | 风控榜 |
|
|
81
|
-
| `popular` | 人气榜 |
|
|
82
|
-
| `rising` | 新星榜 |
|
|
83
|
-
|
|
84
77
|
## 配置
|
|
85
78
|
|
|
86
|
-
|
|
79
|
+
从 https://hub.openfinclaw.ai 获取 API Key(以 `fch_` 开头),一个 Key 即可使用所有功能:
|
|
87
80
|
|
|
88
81
|
```bash
|
|
89
|
-
openclaw config set plugins.entries.openfinclaw.config.
|
|
82
|
+
openclaw config set plugins.entries.openfinclaw.config.apiKey YOUR_API_KEY
|
|
90
83
|
```
|
|
91
84
|
|
|
92
85
|
或使用环境变量:
|
|
93
86
|
|
|
94
87
|
```bash
|
|
95
|
-
export
|
|
96
|
-
export SKILL_API_URL=https://hub.openfinclaw.ai
|
|
88
|
+
export OPENFINCLAW_API_KEY=YOUR_API_KEY
|
|
97
89
|
```
|
|
98
90
|
|
|
91
|
+
### 配置选项
|
|
92
|
+
|
|
93
|
+
| 配置项 | 环境变量 | 说明 | 默认值 |
|
|
94
|
+
| ------------------- | -------------------------- | ---------------- | ---------------------------- |
|
|
95
|
+
| `apiKey` | `OPENFINCLAW_API_KEY` | 统一 API Key | 必填 |
|
|
96
|
+
| `hubApiUrl` | `HUB_API_URL` | Hub 服务地址 | `https://hub.openfinclaw.ai` |
|
|
97
|
+
| `datahubGatewayUrl` | `DATAHUB_GATEWAY_URL` | DataHub 网关地址 | `http://43.134.61.136:9080` |
|
|
98
|
+
| `requestTimeoutMs` | `REQUEST_TIMEOUT_MS` | 请求超时(毫秒) | `60000` |
|
|
99
|
+
|
|
99
100
|
### ⚠️ API Key 安全提醒
|
|
100
101
|
|
|
101
|
-
**重要:请勿泄露你的
|
|
102
|
+
**重要:请勿泄露你的 API Key!**
|
|
102
103
|
|
|
103
|
-
- API Key 以 `fch_`
|
|
104
|
+
- API Key 以 `fch_` 开头,用于 Hub 和 DataHub 接口校验
|
|
104
105
|
- **不要**将 API Key 提交到 Git 仓库或公开分享
|
|
105
106
|
- **不要**在公开聊天、截图、代码示例中暴露真实的 API Key
|
|
106
107
|
- 如果怀疑 Key 已泄露,请立即在 Hub 个人设置中重新生成
|
|
107
108
|
|
|
108
|
-
### 配置选项
|
|
109
|
-
|
|
110
|
-
| 配置项 | 环境变量 | 说明 | 默认值 |
|
|
111
|
-
| ------------------ | -------------------------- | ---------------------------- | ---------------------------- |
|
|
112
|
-
| `skillApiKey` | `SKILL_API_KEY` | Hub API Key(Fork/发布需要) | 可选 |
|
|
113
|
-
| `skillApiUrl` | `SKILL_API_URL` | Hub 服务地址 | `https://hub.openfinclaw.ai` |
|
|
114
|
-
| `requestTimeoutMs` | `SKILL_REQUEST_TIMEOUT_MS` | 请求超时 | `60000` |
|
|
115
|
-
|
|
116
109
|
## Skills
|
|
117
110
|
|
|
118
|
-
###
|
|
119
|
-
|
|
120
|
-
平台入口 skill,帮助用户了解 Hub 平台、安装插件、使用工具链。
|
|
121
|
-
|
|
122
|
-
### skill-publish
|
|
123
|
-
|
|
124
|
-
发布策略到 Hub:
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
用户: "发布我的策略到服务器"
|
|
128
|
-
Agent:
|
|
129
|
-
1. skill_validate(dirPath) → 本地验证
|
|
130
|
-
2. [打包 ZIP]
|
|
131
|
-
3. skill_publish(filePath) → 获取 submissionId
|
|
132
|
-
4. skill_publish_verify(submissionId) → 轮询直到完成
|
|
133
|
-
5. 返回回测报告
|
|
134
|
-
```
|
|
111
|
+
### 行情数据 Skills
|
|
135
112
|
|
|
136
|
-
|
|
113
|
+
| Skill | 说明 |
|
|
114
|
+
| ------------------------- | ------------------------ |
|
|
115
|
+
| `price-check` | 快速查价 |
|
|
116
|
+
| `quick-quote` | 加密市场快照 |
|
|
117
|
+
| `crypto-stablecoin-flow` | 稳定币资金流分析 |
|
|
118
|
+
| `crypto-funding-arb` | 资金费率套利分析 |
|
|
119
|
+
| `crypto-altseason` | 山寨季择时分析 |
|
|
120
|
+
| `cross-asset-lite` | 跨资产价格对比 |
|
|
137
121
|
|
|
138
|
-
|
|
122
|
+
### 策略 Skills
|
|
139
123
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
### strategy-fork
|
|
149
|
-
|
|
150
|
-
从 Hub 下载策略:
|
|
151
|
-
|
|
152
|
-
```
|
|
153
|
-
用户: "帮我下载那个收益 453% 的 BTC 策略"
|
|
154
|
-
Agent:
|
|
155
|
-
1. skill_leaderboard() → 查看排行榜
|
|
156
|
-
2. skill_get_info(strategyId) → 查看详情
|
|
157
|
-
3. skill_fork(strategyId) → 下载到本地
|
|
158
|
-
4. 返回本地路径供编辑
|
|
159
|
-
```
|
|
124
|
+
| Skill | 说明 |
|
|
125
|
+
| ------------------ | -------------------------- |
|
|
126
|
+
| `openfinclaw` | 平台入口 |
|
|
127
|
+
| `strategy-builder` | 自然语言生成策略 |
|
|
128
|
+
| `skill-publish` | 发布策略到 Hub |
|
|
129
|
+
| `strategy-fork` | 从 Hub 下载策略 |
|
|
130
|
+
| `strategy-pack` | 创建回测策略包 |
|
|
160
131
|
|
|
161
132
|
## 本地存储
|
|
162
133
|
|
|
@@ -182,4 +153,4 @@ Agent:
|
|
|
182
153
|
|
|
183
154
|
## License
|
|
184
155
|
|
|
185
|
-
MIT
|
|
156
|
+
MIT
|
package/index.test.ts
CHANGED
|
@@ -97,8 +97,8 @@ describe("openfinclaw plugin", () => {
|
|
|
97
97
|
vi.stubGlobal("fetch", fetchMock);
|
|
98
98
|
|
|
99
99
|
const { api, tools } = createFakeApi({
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
hubApiUrl: "http://skill.example",
|
|
101
|
+
apiKey: "fch_test_key",
|
|
102
102
|
});
|
|
103
103
|
plugin.register(api);
|
|
104
104
|
|
|
@@ -131,8 +131,8 @@ describe("openfinclaw plugin", () => {
|
|
|
131
131
|
vi.stubGlobal("fetch", fetchMock);
|
|
132
132
|
|
|
133
133
|
const { api, tools } = createFakeApi({
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
hubApiUrl: "http://skill.example",
|
|
135
|
+
apiKey: "fch_test_key",
|
|
136
136
|
});
|
|
137
137
|
plugin.register(api);
|
|
138
138
|
|
|
@@ -159,7 +159,7 @@ describe("openfinclaw plugin", () => {
|
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
it("skill_publish returns error when apiKey is not configured", async () => {
|
|
162
|
-
const { api, tools } = createFakeApi({
|
|
162
|
+
const { api, tools } = createFakeApi({ hubApiUrl: "http://skill.example" });
|
|
163
163
|
plugin.register(api);
|
|
164
164
|
|
|
165
165
|
const result = parseResult(
|
|
@@ -190,8 +190,8 @@ describe("openfinclaw plugin", () => {
|
|
|
190
190
|
vi.stubGlobal("fetch", fetchMock);
|
|
191
191
|
|
|
192
192
|
const { api, tools } = createFakeApi({
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
hubApiUrl: "http://skill.example",
|
|
194
|
+
apiKey: "fch_test_key",
|
|
195
195
|
});
|
|
196
196
|
plugin.register(api);
|
|
197
197
|
|
|
@@ -215,7 +215,7 @@ describe("openfinclaw plugin", () => {
|
|
|
215
215
|
});
|
|
216
216
|
|
|
217
217
|
it("returns error when submissionId and backtestTaskId both missing for verify", async () => {
|
|
218
|
-
const { api, tools } = createFakeApi({
|
|
218
|
+
const { api, tools } = createFakeApi({ apiKey: "fch_test" });
|
|
219
219
|
plugin.register(api);
|
|
220
220
|
|
|
221
221
|
const result = parseResult(await tools.get("skill_publish_verify")!.execute("call-6", {}));
|
|
@@ -224,8 +224,8 @@ describe("openfinclaw plugin", () => {
|
|
|
224
224
|
expect(String(result.error)).toContain("Either submissionId or backtestTaskId is required");
|
|
225
225
|
});
|
|
226
226
|
|
|
227
|
-
it("uses env
|
|
228
|
-
vi.stubEnv("
|
|
227
|
+
it("uses env OPENFINCLAW_API_KEY when plugin config has no apiKey", async () => {
|
|
228
|
+
vi.stubEnv("OPENFINCLAW_API_KEY", "fch_env_key");
|
|
229
229
|
|
|
230
230
|
const fetchMock = vi.fn().mockResolvedValue({
|
|
231
231
|
ok: true,
|
|
@@ -234,7 +234,7 @@ describe("openfinclaw plugin", () => {
|
|
|
234
234
|
});
|
|
235
235
|
vi.stubGlobal("fetch", fetchMock);
|
|
236
236
|
|
|
237
|
-
const { api, tools } = createFakeApi({
|
|
237
|
+
const { api, tools } = createFakeApi({ hubApiUrl: "http://skill.example" });
|
|
238
238
|
plugin.register(api);
|
|
239
239
|
|
|
240
240
|
await tools.get("skill_publish_verify")!.execute("call-7", { submissionId: "sub-1" });
|