@openfinclaw/openfinclaw-strategy 0.0.11 → 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/README.md CHANGED
@@ -1,23 +1,20 @@
1
1
  # @openfinclaw/openfinclaw-strategy
2
2
 
3
- FinClaw Commons - 量化策略开发平台插件。连接 hub.openfinclaw.ai 策略网络,支持策略创建、验证、发布、Fork。
3
+ OpenFinClaw - 统一金融工具插件。一个 API Key,一站式服务:
4
4
 
5
- ## 安装
6
-
7
- ```bash
8
- curl -fsSL https://raw.githubusercontent.com/cryptoSUN2049/openFinclaw/main/scripts/install-finclaw.sh | bash
9
- ```
5
+ - **行情数据**: 价格查询、K线、加密市场数据、多资产对比、代码搜索
6
+ - **策略工具**: 发布、验证、Fork、排行榜
10
7
 
11
- 或手动安装:
8
+ ## 安装
12
9
 
13
10
  ```bash
14
11
  openclaw plugins install @openfinclaw/openfinclaw-strategy
15
12
  ```
16
13
 
17
- ## 快速开始(无需 API Key)
14
+ ## 快速开始
18
15
 
19
16
  ```bash
20
- # 查看排行榜
17
+ # 查看策略排行榜(无需 API Key)
21
18
  openclaw strategy leaderboard
22
19
 
23
20
  # 查看收益榜 Top 10
@@ -27,29 +24,36 @@ openclaw strategy leaderboard returns --limit 10
27
24
  openclaw strategy show <strategy-id> --remote
28
25
  ```
29
26
 
27
+ 或者直接告诉 Agent 你想做什么:
28
+
29
+ - "BTC 现在多少钱" → Agent 会使用 `fin_price`
30
+ - "ETH 最近 7 天走势" → Agent 会使用 `fin_kline`
31
+ - "DeFi 哪个协议 TVL 最高" → Agent 会使用 `fin_crypto`
32
+ - "帮我看看排行榜有什么好策略" → Agent 会使用 `skill_leaderboard`
33
+
30
34
  ## 功能概览
31
35
 
32
- | 功能 | 工具 | 需要 API Key |
33
- | ---------- | ---------------------- | ------------ |
34
- | 排行榜查询 | `skill_leaderboard` | |
35
- | 策略详情 | `skill_get_info` | |
36
- | 本地验证 | `skill_validate` | |
37
- | 本地列表 | `skill_list_local` | |
38
- | 策略 Fork | `skill_fork` | **是** |
39
- | 策略发布 | `skill_publish` | **是** |
40
- | 发布查询 | `skill_publish_verify` | **是** |
41
-
42
- ### AI 工具列表
43
-
44
- | 工具 | 说明 | API Key |
45
- | ---------------------- | -------------------------------------- | -------- |
46
- | `skill_leaderboard` | 查询排行榜(综合/收益/风控/人气/新星) | 不需要 |
47
- | `skill_get_info` | 获取 Hub 策略公开详情 | 不需要 |
48
- | `skill_validate` | 本地验证策略包(FEP v1.2 | 不需要 |
49
- | `skill_list_local` | 列出本地策略 | 不需要 |
50
- | `skill_fork` | 从 Hub 下载策略到本地 | **需要** |
51
- | `skill_publish` | 发布策略 ZIP 到 Hub,自动触发回测 | **需要** |
52
- | `skill_publish_verify` | 查询发布状态和回测报告 | **需要** |
36
+ ### 行情数据工具
37
+
38
+ | 工具名 | 说明 | API Key |
39
+ | ----------------- | -------------------------- | ------- |
40
+ | `fin_price` | 价格查询(股票/加密/指数) | 需要 |
41
+ | `fin_kline` | K线/OHLCV 数据 | 需要 |
42
+ | `fin_crypto` | 加密市场数据(21个端点) | 需要 |
43
+ | `fin_compare` | 多资产价格对比 | 需要 |
44
+ | `fin_slim_search` | 代码/名称搜索 | 需要 |
45
+
46
+ ### 策略工具
47
+
48
+ | 工具名 | 说明 | API Key |
49
+ | ---------------------- | -------------------------- | -------- |
50
+ | `skill_leaderboard` | 查询排行榜 | 不需要 |
51
+ | `skill_get_info` | 获取 Hub 策略公开详情 | 不需要 |
52
+ | `skill_validate` | 本地验证策略包(FEP v2.0 | 不需要 |
53
+ | `skill_list_local` | 列出本地策略 | 不需要 |
54
+ | `skill_fork` | 从 Hub 下载策略到本地 | **需要** |
55
+ | `skill_publish` | 发布策略 ZIP 到 Hub | **需要** |
56
+ | `skill_publish_verify` | 查询发布状态和回测报告 | **需要** |
53
57
 
54
58
  ## CLI 命令
55
59
 
@@ -71,92 +75,55 @@ openclaw strategy show <name-or-id> [--remote]
71
75
  openclaw strategy remove <name-or-id> --force
72
76
  ```
73
77
 
74
- ### 排行榜类型
75
-
76
- | 榜单类型 | 说明 |
77
- | ----------- | -------------- |
78
- | `composite` | 综合榜(默认) |
79
- | `returns` | 收益榜 |
80
- | `risk` | 风控榜 |
81
- | `popular` | 人气榜 |
82
- | `rising` | 新星榜 |
83
-
84
78
  ## 配置
85
79
 
86
- Fork 和发布策略需要 API Key(从 https://hub.openfinclaw.ai 获取):
80
+ https://hub.openfinclaw.ai 获取 API Key(以 `fch_` 开头),一个 Key 即可使用所有功能:
87
81
 
88
82
  ```bash
89
- openclaw config set plugins.entries.openfinclaw.config.skillApiKey YOUR_API_KEY
83
+ openclaw config set plugins.entries.openfinclaw.config.apiKey YOUR_API_KEY
90
84
  ```
91
85
 
92
86
  或使用环境变量:
93
87
 
94
88
  ```bash
95
- export SKILL_API_KEY=YOUR_API_KEY
96
- export SKILL_API_URL=https://hub.openfinclaw.ai
89
+ export OPENFINCLAW_API_KEY=YOUR_API_KEY
97
90
  ```
98
91
 
92
+ ### 配置选项
93
+
94
+ | 配置项 | 环境变量 | 说明 | 默认值 |
95
+ | ------------------- | --------------------- | ---------------- | ---------------------------- |
96
+ | `apiKey` | `OPENFINCLAW_API_KEY` | 统一 API Key | 必填 |
97
+ | `hubApiUrl` | `HUB_API_URL` | Hub 服务地址 | `https://hub.openfinclaw.ai` |
98
+ | `datahubGatewayUrl` | `DATAHUB_GATEWAY_URL` | DataHub 网关地址 | `http://43.134.61.136:9080` |
99
+ | `requestTimeoutMs` | `REQUEST_TIMEOUT_MS` | 请求超时(毫秒) | `60000` |
100
+
99
101
  ### ⚠️ API Key 安全提醒
100
102
 
101
- **重要:请勿泄露你的 Hub API Key!**
103
+ **重要:请勿泄露你的 API Key!**
102
104
 
103
- - API Key 以 `fch_` 开头,**仅用于** hub.openfinclaw.ai 接口校验
105
+ - API Key 以 `fch_` 开头,用于 Hub 和 DataHub 接口校验
104
106
  - **不要**将 API Key 提交到 Git 仓库或公开分享
105
107
  - **不要**在公开聊天、截图、代码示例中暴露真实的 API Key
106
108
  - 如果怀疑 Key 已泄露,请立即在 Hub 个人设置中重新生成
107
109
 
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
110
  ## Skills
117
111
 
118
- ### openfinclaw (入口)
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
- ```
112
+ ### 行情数据 Skills
135
113
 
136
- ### strategy-builder
114
+ | Skill | 说明 |
115
+ | ------------- | -------- |
116
+ | `price-check` | 快速查价 |
137
117
 
138
- 自然语言生成策略:
118
+ ### 策略 Skills
139
119
 
140
- ```
141
- 用户: "帮我创建一个 BTC 定投策略,每周买入 100 美元"
142
- Agent:
143
- 1. 生成 fep.yaml 配置
144
- 2. 生成 scripts/strategy.py 代码
145
- 3. 可选:验证并打包
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
- ```
120
+ | Skill | 说明 |
121
+ | ------------------ | ---------------- |
122
+ | `openfinclaw` | 平台入口 |
123
+ | `strategy-builder` | 自然语言生成策略 |
124
+ | `skill-publish` | 发布策略到 Hub |
125
+ | `strategy-fork` | 从 Hub 下载策略 |
126
+ | `strategy-pack` | 创建回测策略包 |
160
127
 
161
128
  ## 本地存储
162
129
 
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
- skillApiUrl: "http://skill.example",
101
- skillApiKey: "fch_test_key",
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
- skillApiUrl: "http://skill.example",
135
- skillApiKey: "fch_test_key",
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({ skillApiUrl: "http://skill.example" });
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
- skillApiUrl: "http://skill.example",
194
- skillApiKey: "fch_test_key",
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({ skillApiKey: "fch_test" });
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 SKILL_API_KEY when plugin config has no skillApiKey", async () => {
228
- vi.stubEnv("SKILL_API_KEY", "fch_env_key");
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({ skillApiUrl: "http://skill.example" });
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" });