@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 +60 -93
- package/index.test.ts +11 -11
- package/index.ts +18 -979
- package/openclaw.plugin.json +25 -8
- package/package.json +10 -4
- package/skills/openfinclaw/SKILL.md +78 -78
- package/skills/price-check/SKILL.md +118 -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 +5 -5
- package/src/config.ts +57 -0
- package/src/datahub/client.ts +150 -0
- package/src/datahub/tools.ts +349 -0
- package/src/strategy/client.ts +44 -0
- package/src/{fork.ts → strategy/fork.ts} +12 -11
- package/src/{strategy-storage.ts → strategy/storage.ts} +6 -7
- package/src/strategy/tools.ts +524 -0
- package/src/{validate.ts → strategy/validate.ts} +3 -35
- package/src/types.ts +42 -0
- package/LICENSE +0 -21
- package/src/strategy-storage.test.ts +0 -109
- package/src/validate.test.ts +0 -841
package/openclaw.plugin.json
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "openfinclaw",
|
|
3
3
|
"name": "OpenFinClaw",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "Unified financial tools: market data (price/K-line/crypto/compare/search), strategy publishing, fork, and validation. Single API key for Hub and DataHub.",
|
|
5
5
|
"kind": "financial",
|
|
6
|
+
"version": "0.1.0",
|
|
6
7
|
"skills": ["./skills"],
|
|
7
8
|
"configSchema": {
|
|
8
9
|
"type": "object",
|
|
9
10
|
"properties": {
|
|
10
|
-
"
|
|
11
|
+
"apiKey": {
|
|
11
12
|
"type": "string",
|
|
12
|
-
"
|
|
13
|
+
"minLength": 1,
|
|
14
|
+
"description": "API Key for Hub and DataHub (fch_ prefix). Also accepted via OPENFINCLAW_API_KEY env var.",
|
|
15
|
+
"sensitive": true
|
|
16
|
+
},
|
|
17
|
+
"hubApiUrl": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "Hub API URL",
|
|
13
20
|
"default": "https://hub.openfinclaw.ai"
|
|
14
21
|
},
|
|
15
|
-
"
|
|
22
|
+
"datahubGatewayUrl": {
|
|
16
23
|
"type": "string",
|
|
17
|
-
"description": "
|
|
24
|
+
"description": "DataHub Gateway URL for market data",
|
|
25
|
+
"default": "http://43.134.61.136:9080"
|
|
18
26
|
},
|
|
19
27
|
"requestTimeoutMs": {
|
|
20
28
|
"type": "number",
|
|
@@ -26,10 +34,19 @@
|
|
|
26
34
|
}
|
|
27
35
|
},
|
|
28
36
|
"uiHints": {
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
"
|
|
37
|
+
"apiKey": {
|
|
38
|
+
"label": "API Key",
|
|
39
|
+
"help": "统一 API Key(用于 Hub 和 DataHub)。从 hub.openfinclaw.ai 获取。",
|
|
40
|
+
"sensitive": true,
|
|
41
|
+
"placeholder": "fch_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
42
|
+
},
|
|
43
|
+
"hubApiUrl": {
|
|
44
|
+
"label": "Hub API URL",
|
|
32
45
|
"placeholder": "https://hub.openfinclaw.ai"
|
|
46
|
+
},
|
|
47
|
+
"datahubGatewayUrl": {
|
|
48
|
+
"label": "DataHub Gateway URL",
|
|
49
|
+
"placeholder": "http://43.134.61.136:9080"
|
|
33
50
|
}
|
|
34
51
|
}
|
|
35
52
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfinclaw/openfinclaw-strategy",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "OpenFinClaw -
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "OpenFinClaw - Unified financial tools: market data (price/K-line/crypto/compare/search), strategy publishing, fork, and validation. Single API key for Hub and DataHub.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"backtest",
|
|
7
7
|
"crypto",
|
|
8
8
|
"financial",
|
|
9
|
+
"ohlcv",
|
|
9
10
|
"openclaw",
|
|
10
11
|
"openfinclaw",
|
|
12
|
+
"price",
|
|
11
13
|
"strategy",
|
|
14
|
+
"ticker",
|
|
12
15
|
"trading"
|
|
13
16
|
],
|
|
14
17
|
"homepage": "https://github.com/cryptoSUN2049/openFinclaw#readme",
|
|
@@ -16,7 +19,7 @@
|
|
|
16
19
|
"repository": {
|
|
17
20
|
"type": "git",
|
|
18
21
|
"url": "git+https://github.com/cryptoSUN2049/openFinclaw.git",
|
|
19
|
-
"directory": "extensions/openfinclaw"
|
|
22
|
+
"directory": "extensions/openfinclaw-strategy"
|
|
20
23
|
},
|
|
21
24
|
"files": [
|
|
22
25
|
"skills",
|
|
@@ -37,9 +40,12 @@
|
|
|
37
40
|
"devDependencies": {
|
|
38
41
|
"@types/adm-zip": "^0.5.8"
|
|
39
42
|
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"openclaw": ">=2026.1.0"
|
|
45
|
+
},
|
|
40
46
|
"openclaw": {
|
|
41
47
|
"extensions": [
|
|
42
48
|
"./index.ts"
|
|
43
49
|
]
|
|
44
50
|
}
|
|
45
|
-
}
|
|
51
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: openfinclaw
|
|
3
|
-
description: "
|
|
3
|
+
description: "OpenFinClaw 入口 - 统一金融工具平台。行情数据(价格/K线/加密市场/多资产对比)、策略工具(创建/验证/发布/Fork)。当用户提到 FinClaw、Hub、策略、行情、价格、K线、加密货币、BTC、ETH、DeFi 时触发。"
|
|
4
4
|
metadata:
|
|
5
5
|
openclaw:
|
|
6
6
|
emoji: "🦈"
|
|
@@ -8,9 +8,13 @@ metadata:
|
|
|
8
8
|
extensions: ["openfinclaw"]
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
#
|
|
11
|
+
# OpenFinClaw
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
统一金融工具平台,一个 API Key 即可使用所有功能:
|
|
14
|
+
|
|
15
|
+
- **行情数据**: 价格查询、K线、加密市场数据、多资产对比、代码搜索
|
|
16
|
+
- **策略工具**: 创建、验证、发布、Fork 策略
|
|
17
|
+
- **统一认证**: 一个 API Key 访问 Hub 和 DataHub
|
|
14
18
|
|
|
15
19
|
## 平台简介
|
|
16
20
|
|
|
@@ -21,29 +25,45 @@ metadata:
|
|
|
21
25
|
- **社区进化**: 其他用户可以 Fork 你的策略进行优化改进
|
|
22
26
|
- **绩效排行**: 查看各市场表现最佳的策略
|
|
23
27
|
|
|
28
|
+
**DataHub** 提供实时行情数据:
|
|
29
|
+
|
|
30
|
+
- **多市场覆盖**: 加密货币、A股、港股、美股
|
|
31
|
+
- **丰富数据**: 价格、K线、OHLCV、DeFi TVL、资金费率
|
|
32
|
+
- **数据来源**: CoinGecko、DefiLlama、CCXT、Tushare
|
|
33
|
+
|
|
24
34
|
核心价值:**不要追逐浪潮,创造浪潮。**
|
|
25
35
|
|
|
26
36
|
## 快速开始
|
|
27
37
|
|
|
28
|
-
|
|
38
|
+
### 行情查询(需要 API Key)
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
用户: BTC 现在多少钱
|
|
42
|
+
Agent: 使用 fin_price 获取实时价格
|
|
43
|
+
|
|
44
|
+
用户: ETH 最近 7 天走势
|
|
45
|
+
Agent: 使用 fin_kline 获取 K 线数据
|
|
46
|
+
|
|
47
|
+
用户: DeFi 哪个协议 TVL 最高
|
|
48
|
+
Agent: 使用 fin_crypto 获取 DeFi 排名
|
|
49
|
+
|
|
50
|
+
用户: BTC 和 ETH 谁涨得多
|
|
51
|
+
Agent: 使用 fin_compare 对比收益
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 策略管理
|
|
29
55
|
|
|
30
56
|
```bash
|
|
31
|
-
#
|
|
57
|
+
# 查看排行榜(无需 API Key)
|
|
32
58
|
openclaw strategy leaderboard
|
|
33
59
|
|
|
34
|
-
#
|
|
60
|
+
# 查看收益榜 Top 10
|
|
35
61
|
openclaw strategy leaderboard returns --limit 10
|
|
36
62
|
|
|
37
|
-
#
|
|
63
|
+
# 查看策略详情(无需 API Key)
|
|
38
64
|
openclaw strategy show 550e8400-e29b-41d4-a716-446655440001 --remote
|
|
39
65
|
```
|
|
40
66
|
|
|
41
|
-
或者直接告诉 Agent 你想做什么:
|
|
42
|
-
|
|
43
|
-
- "帮我看看排行榜有什么好策略" → Agent 会使用 `skill_leaderboard`
|
|
44
|
-
- "这个策略收益怎么样" → Agent 会使用 `skill_get_info`
|
|
45
|
-
- "帮我 Fork 这个策略" → Agent 会使用 `skill_fork`(需要配置 API Key)
|
|
46
|
-
|
|
47
67
|
## 安装指南
|
|
48
68
|
|
|
49
69
|
### 前置检查
|
|
@@ -58,16 +78,11 @@ openclaw --version
|
|
|
58
78
|
|
|
59
79
|
### 安装 openfinclaw 插件
|
|
60
80
|
|
|
61
|
-
**OpenClaw (推荐):**
|
|
62
|
-
|
|
63
81
|
```bash
|
|
64
82
|
openclaw plugins install @openfinclaw/openfinclaw-strategy
|
|
65
|
-
|
|
66
83
|
openclaw plugins enable @openfinclaw/openfinclaw-strategy
|
|
67
84
|
```
|
|
68
85
|
|
|
69
|
-
安装成功后会显示插件路径,如 `~/.openclaw/extensions/openfinclaw`。
|
|
70
|
-
|
|
71
86
|
### 验证安装
|
|
72
87
|
|
|
73
88
|
```bash
|
|
@@ -80,44 +95,42 @@ openclaw strategy list
|
|
|
80
95
|
|
|
81
96
|
### 配置 API Key
|
|
82
97
|
|
|
83
|
-
从 https://hub.openfinclaw.ai 获取 API Key(以 `fch_`
|
|
98
|
+
从 https://hub.openfinclaw.ai 获取 API Key(以 `fch_` 开头),**一个 Key 即可使用所有功能**:
|
|
84
99
|
|
|
85
100
|
```bash
|
|
86
|
-
openclaw config set plugins.entries.openfinclaw.config.
|
|
101
|
+
openclaw config set plugins.entries.openfinclaw.config.apiKey YOUR_API_KEY
|
|
87
102
|
```
|
|
88
103
|
|
|
89
104
|
或使用环境变量:
|
|
90
105
|
|
|
91
106
|
```bash
|
|
92
|
-
export
|
|
107
|
+
export OPENFINCLAW_API_KEY=YOUR_API_KEY
|
|
93
108
|
```
|
|
94
109
|
|
|
95
110
|
### ⚠️ API Key 安全提醒
|
|
96
111
|
|
|
97
|
-
**重要:请勿泄露你的
|
|
112
|
+
**重要:请勿泄露你的 API Key!**
|
|
98
113
|
|
|
99
|
-
- API Key 以 `fch_`
|
|
114
|
+
- API Key 以 `fch_` 开头,用于 Hub 和 DataHub 接口校验
|
|
100
115
|
- **不要**将 API Key 提交到 Git 仓库或公开分享
|
|
101
116
|
- **不要**在公开聊天、截图、代码示例中暴露真实的 API Key
|
|
102
117
|
- 如果怀疑 Key 已泄露,请立即在 Hub 个人设置中重新生成
|
|
103
118
|
|
|
104
|
-
配置建议:
|
|
105
|
-
|
|
106
|
-
```bash
|
|
107
|
-
# 推荐:使用环境变量(不会写入配置文件)
|
|
108
|
-
export SKILL_API_KEY=your_api_key_here
|
|
109
|
-
|
|
110
|
-
# 或使用 OpenClaw 配置(存储在本地配置文件,注意权限)
|
|
111
|
-
openclaw config set plugins.entries.openfinclaw.config.skillApiKey YOUR_API_KEY
|
|
112
|
-
```
|
|
113
|
-
|
|
114
119
|
## 功能概览
|
|
115
120
|
|
|
116
|
-
|
|
121
|
+
本插件提供两大类能力:
|
|
122
|
+
|
|
123
|
+
### 行情数据工具
|
|
117
124
|
|
|
118
|
-
|
|
125
|
+
| 工具名 | 用途 | 需要 API Key |
|
|
126
|
+
| ----------------- | --------------------------- | ------------ |
|
|
127
|
+
| `fin_price` | 价格查询(股票/加密/指数) | **是** |
|
|
128
|
+
| `fin_kline` | K线/OHLCV 数据 | **是** |
|
|
129
|
+
| `fin_crypto` | 加密市场数据(21个端点) | **是** |
|
|
130
|
+
| `fin_compare` | 多资产价格对比(2-5个资产) | **是** |
|
|
131
|
+
| `fin_slim_search` | 代码/名称搜索 | **是** |
|
|
119
132
|
|
|
120
|
-
|
|
133
|
+
### 策略工具
|
|
121
134
|
|
|
122
135
|
| 工具名 | 用途 | 需要 API Key |
|
|
123
136
|
| ---------------------- | -------------------------------------- | ------------ |
|
|
@@ -131,7 +144,13 @@ Agent 可直接调用的函数:
|
|
|
131
144
|
|
|
132
145
|
### Skills(指导文档)
|
|
133
146
|
|
|
134
|
-
|
|
147
|
+
#### 行情数据 Skills
|
|
148
|
+
|
|
149
|
+
| Skill | 触发场景 | 说明 |
|
|
150
|
+
| ------------- | ------------------ | ---------------- |
|
|
151
|
+
| `price-check` | 快速查价、XX多少钱 | 最简单的价格查询 |
|
|
152
|
+
|
|
153
|
+
#### 策略 Skills
|
|
135
154
|
|
|
136
155
|
| Skill | 触发场景 | 说明 |
|
|
137
156
|
| ------------------ | ------------------------ | ----------------------------- |
|
|
@@ -143,10 +162,10 @@ Agent 可直接调用的函数:
|
|
|
143
162
|
### 典型工作流
|
|
144
163
|
|
|
145
164
|
```
|
|
146
|
-
|
|
147
|
-
↓ ↓ ↓
|
|
148
|
-
strategy-builder skill_publish
|
|
149
|
-
|
|
165
|
+
行情查询 → 分析决策 → 策略创建 → 验证 → 发布 → Fork → 优化
|
|
166
|
+
↓ ↓ ↓ ↓ ↓
|
|
167
|
+
fin_price compare strategy-builder skill_validate skill_publish
|
|
168
|
+
fin_kline skill_fork skill_publish_verify
|
|
150
169
|
```
|
|
151
170
|
|
|
152
171
|
## CLI 命令
|
|
@@ -186,12 +205,6 @@ openclaw strategy fork 34a5792f-7d20-4a15-90f3-26f1c54fa4a6
|
|
|
186
205
|
|
|
187
206
|
# 使用 Hub URL
|
|
188
207
|
openclaw strategy fork https://hub.openfinclaw.ai/strategy/34a5792f-7d20-4a15-90f3-26f1c54fa4a6
|
|
189
|
-
|
|
190
|
-
# 指定日期目录
|
|
191
|
-
openclaw strategy fork 34a5792f-7d20-4a15-90f3-26f1c54fa4a6 --date 2026-03-01
|
|
192
|
-
|
|
193
|
-
# 自定义路径
|
|
194
|
-
openclaw strategy fork 34a5792f-7d20-4a15-90f3-26f1c54fa4a6 --dir ./my-strategies/
|
|
195
208
|
```
|
|
196
209
|
|
|
197
210
|
### strategy list
|
|
@@ -200,17 +213,6 @@ openclaw strategy fork 34a5792f-7d20-4a15-90f3-26f1c54fa4a6 --dir ./my-strategie
|
|
|
200
213
|
|
|
201
214
|
```bash
|
|
202
215
|
openclaw strategy list
|
|
203
|
-
openclaw strategy list --json
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
输出示例:
|
|
207
|
-
|
|
208
|
-
```
|
|
209
|
-
2026-03-16/
|
|
210
|
-
btc-adaptive-dca-34a5792f BTC Adaptive DCA (forked)
|
|
211
|
-
my-test-strategy My Test Strategy (created)
|
|
212
|
-
2026-03-15/
|
|
213
|
-
eth-momentum-7e8a9b2c ETH Momentum (forked)
|
|
214
216
|
```
|
|
215
217
|
|
|
216
218
|
### strategy show
|
|
@@ -225,14 +227,6 @@ openclaw strategy show btc-adaptive-dca-34a5792f
|
|
|
225
227
|
openclaw strategy show 550e8400-e29b-41d4-a716-446655440001 --remote
|
|
226
228
|
```
|
|
227
229
|
|
|
228
|
-
### strategy remove
|
|
229
|
-
|
|
230
|
-
删除本地策略:
|
|
231
|
-
|
|
232
|
-
```bash
|
|
233
|
-
openclaw strategy remove btc-adaptive-dca-34a5792f --force
|
|
234
|
-
```
|
|
235
|
-
|
|
236
230
|
## 本地存储结构
|
|
237
231
|
|
|
238
232
|
策略存储在 `~/.openfinclaw/workspace/strategies/` 目录:
|
|
@@ -253,26 +247,32 @@ openclaw strategy remove btc-adaptive-dca-34a5792f --force
|
|
|
253
247
|
|
|
254
248
|
当用户提到以下内容时,应引导阅读对应的 Skill:
|
|
255
249
|
|
|
256
|
-
| 触发关键词 | Skill
|
|
257
|
-
| ------------------------------ | ------------------ |
|
|
258
|
-
|
|
|
259
|
-
|
|
|
260
|
-
|
|
|
261
|
-
|
|
|
250
|
+
| 触发关键词 | Skill | 说明 |
|
|
251
|
+
| ------------------------------ | ------------------ | ------------------- |
|
|
252
|
+
| XX多少钱、什么价格、查价 | `price-check` | 最简单的价格查询 |
|
|
253
|
+
| 创建策略、写策略、生成策略包 | `strategy-builder` | 自然语言 → FEP v2.0 |
|
|
254
|
+
| 发布策略、上传策略、提交策略 | `skill-publish` | 验证 → 打包 → 发布 |
|
|
255
|
+
| Fork 策略、下载策略、克隆策略 | `strategy-fork` | 从 Hub Fork 策略 |
|
|
256
|
+
| 策略包格式、FEP 规范、打包回测 | `strategy-pack` | FEP v2.0 规范详解 |
|
|
262
257
|
|
|
263
258
|
## 配置选项
|
|
264
259
|
|
|
265
|
-
| 配置项
|
|
266
|
-
|
|
|
267
|
-
| `
|
|
268
|
-
| `
|
|
269
|
-
| `
|
|
260
|
+
| 配置项 | 环境变量 | 说明 | 默认值 |
|
|
261
|
+
| ------------------- | --------------------- | ---------------- | ---------------------------- |
|
|
262
|
+
| `apiKey` | `OPENFINCLAW_API_KEY` | 统一 API Key | 必填 |
|
|
263
|
+
| `hubApiUrl` | `HUB_API_URL` | Hub 服务地址 | `https://hub.openfinclaw.ai` |
|
|
264
|
+
| `datahubGatewayUrl` | `DATAHUB_GATEWAY_URL` | DataHub 网关地址 | `http://43.134.61.136:9080` |
|
|
265
|
+
| `requestTimeoutMs` | `REQUEST_TIMEOUT_MS` | 请求超时(毫秒) | `60000` |
|
|
270
266
|
|
|
271
267
|
## 常见问题
|
|
272
268
|
|
|
273
269
|
### Q: API Key 在哪里获取?
|
|
274
270
|
|
|
275
|
-
访问 https://hub.openfinclaw.ai
|
|
271
|
+
访问 https://hub.openfinclaw.ai 登录后在个人设置中获取。**一个 Key 即可使用所有功能**。
|
|
272
|
+
|
|
273
|
+
### Q: 行情数据需要额外付费吗?
|
|
274
|
+
|
|
275
|
+
API Key 已包含行情数据访问权限,无需额外付费。
|
|
276
276
|
|
|
277
277
|
### Q: Fork 的策略可以修改吗?
|
|
278
278
|
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fin-price-check
|
|
3
|
+
description: "Quick price lookup for any asset — stocks, crypto, indices. Use when user asks '什么价格', 'how much is', 'current price of', or any simple price query. Returns latest price, volume, and date."
|
|
4
|
+
metadata: { "openclaw": { "emoji": "💰", "requires": { "extensions": ["openfinclaw"] } } }
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Price Check
|
|
8
|
+
|
|
9
|
+
最简单的查价工具 — 一个 symbol 返回最新价格。
|
|
10
|
+
|
|
11
|
+
## Tools
|
|
12
|
+
|
|
13
|
+
### fin_price — 查当前价
|
|
14
|
+
|
|
15
|
+
| Parameter | Type | Required | Example |
|
|
16
|
+
| --------- | ------ | -------- | ---------- |
|
|
17
|
+
| symbol | string | Yes | BTC/USDT |
|
|
18
|
+
| market | string | No | crypto |
|
|
19
|
+
|
|
20
|
+
Market 自动检测:含 `/` → crypto;`.SH/.SZ/.HK` 或纯字母 → equity。
|
|
21
|
+
|
|
22
|
+
**返回字段:**
|
|
23
|
+
- `price`: 最新价格
|
|
24
|
+
- `volume24h`: 24小时成交量(加密货币)
|
|
25
|
+
- `timestamp`: 数据时间
|
|
26
|
+
|
|
27
|
+
### fin_kline — 查历史 K 线
|
|
28
|
+
|
|
29
|
+
| Parameter | Type | Required | Default | Example |
|
|
30
|
+
| --------- | ------ | -------- | ------- | --------- |
|
|
31
|
+
| symbol | string | Yes | — | 600519.SH |
|
|
32
|
+
| market | string | No | auto | equity |
|
|
33
|
+
| limit | number | No | 30 | 10 |
|
|
34
|
+
|
|
35
|
+
**返回字段:**
|
|
36
|
+
- `bars[]`: K线数组,包含 date, open, high, low, close, volume
|
|
37
|
+
|
|
38
|
+
### fin_compare — 多资产对比
|
|
39
|
+
|
|
40
|
+
| Parameter | Type | Required | Example |
|
|
41
|
+
| --------- | ------ | -------- | --------------------------- |
|
|
42
|
+
| symbols | string | Yes | BTC/USDT,ETH/USDT,600519.SH |
|
|
43
|
+
|
|
44
|
+
**返回字段:**
|
|
45
|
+
- `comparison[]`: 每个资产的 price, weekChange(周涨跌幅)
|
|
46
|
+
|
|
47
|
+
### fin_slim_search — 搜索代码
|
|
48
|
+
|
|
49
|
+
当用户只说公司/币种名称,不确定 symbol 时使用:
|
|
50
|
+
|
|
51
|
+
| Parameter | Type | Required | Example |
|
|
52
|
+
| --------- | ------ | -------- | --------- |
|
|
53
|
+
| query | string | Yes | 茅台 |
|
|
54
|
+
| market | string | No | equity |
|
|
55
|
+
|
|
56
|
+
**触发场景:**
|
|
57
|
+
- 用户说 "茅台多少钱" → 先搜索 `query="茅台"` → 找到 `600519.SH` → 再查价格
|
|
58
|
+
- 用户说 "特斯拉股价" → 先搜索 `query="特斯拉"` → 找到 `TSLA` → 再查价格
|
|
59
|
+
|
|
60
|
+
### fin_crypto — 加密市场数据
|
|
61
|
+
|
|
62
|
+
| Parameter | Type | Required | Example |
|
|
63
|
+
| --------- | ------ | -------- | ---------------------------- |
|
|
64
|
+
| endpoint | string | Yes | market/funding_rate |
|
|
65
|
+
| symbol | string | No | BTC/USDT:USDT |
|
|
66
|
+
| limit | number | No | 20 |
|
|
67
|
+
|
|
68
|
+
**常用端点:**
|
|
69
|
+
|
|
70
|
+
| 端点 | 用途 |
|
|
71
|
+
| ----------------------- | -------------------- |
|
|
72
|
+
| `market/ticker` | 单币种行情 |
|
|
73
|
+
| `market/tickers` | 多币种行情 |
|
|
74
|
+
| `market/funding_rate` | 资金费率 |
|
|
75
|
+
| `coin/market` | CoinGecko 币种排行 |
|
|
76
|
+
| `coin/trending` | 热门币种 |
|
|
77
|
+
| `defi/protocols` | DeFi 协议 TVL 排行 |
|
|
78
|
+
| `defi/yields` | DeFi 收益率 |
|
|
79
|
+
|
|
80
|
+
## Symbol 格式速查
|
|
81
|
+
|
|
82
|
+
| 格式 | 市场 | 示例 |
|
|
83
|
+
| ------------------ | ------ | ------------------------ |
|
|
84
|
+
| `XXX/YYY` | Crypto | `BTC/USDT`, `ETH/BTC` |
|
|
85
|
+
| `6位数.SZ/SH` | A股 | `000001.SZ`, `600519.SH` |
|
|
86
|
+
| `5位数.HK` | 港股 | `00700.HK`, `00941.HK` |
|
|
87
|
+
| `1-5大写字母` | 美股 | `AAPL`, `NVDA`, `TSLA` |
|
|
88
|
+
| `000xxx.SH` | 指数 | `000300.SH` (沪深300) |
|
|
89
|
+
|
|
90
|
+
## Response Guidelines
|
|
91
|
+
|
|
92
|
+
1. **简洁至上** — 用户问价格,直接给数字,不需要长篇分析
|
|
93
|
+
2. **格式清晰** — 用表格展示,包含:资产名、价格、涨跌幅
|
|
94
|
+
3. **币种标注** — 加密标注 USD,A 股标注 CNY,港股标注 HKD
|
|
95
|
+
4. **时间标注** — 说明数据截至时间
|
|
96
|
+
5. **搜索优先** — 用户只说名称时,先用 fin_slim_search 找 symbol
|
|
97
|
+
|
|
98
|
+
## Examples
|
|
99
|
+
|
|
100
|
+
**用户:** BTC 多少钱?
|
|
101
|
+
**流程:** `fin_price(symbol="BTC/USDT")` → 返回 $69,552
|
|
102
|
+
|
|
103
|
+
**用户:** 茅台现在什么价?
|
|
104
|
+
**流程:**
|
|
105
|
+
1. `fin_slim_search(query="茅台")` → 找到 `600519.SH`
|
|
106
|
+
2. `fin_price(symbol="600519.SH")` → 返回 ¥1,856.00
|
|
107
|
+
|
|
108
|
+
**用户:** 茅台和腾讯谁贵?
|
|
109
|
+
**流程:** `fin_compare(symbols="600519.SH,00700.HK")` → 对比表格
|
|
110
|
+
|
|
111
|
+
**用户:** ETH 最近 5 天走势
|
|
112
|
+
**流程:** `fin_kline(symbol="ETH/USDT", market="crypto", limit=5)` → K 线数据
|
|
113
|
+
|
|
114
|
+
**用户:** BTC 资金费率现在多少?
|
|
115
|
+
**流程:** `fin_crypto(endpoint="market/funding_rate", symbol="BTC/USDT:USDT")` → 费率数据
|
|
116
|
+
|
|
117
|
+
**用户:** 现在 DeFi 哪个协议 TVL 最高?
|
|
118
|
+
**流程:** `fin_crypto(endpoint="defi/protocols", limit=5)` → TVL 排行
|
|
@@ -68,13 +68,13 @@ Before publishing, **always check** `identity.visibility` in the strategy's `fep
|
|
|
68
68
|
|
|
69
69
|
The plugin requires configuration:
|
|
70
70
|
|
|
71
|
-
- `
|
|
72
|
-
- `
|
|
71
|
+
- `hubApiUrl`: Server URL (default: `https://hub.openfinclaw.ai`)
|
|
72
|
+
- `apiKey`: API key with `fch_` prefix
|
|
73
73
|
|
|
74
74
|
Configure via:
|
|
75
75
|
|
|
76
|
-
- Plugin config: `
|
|
77
|
-
- Environment: `
|
|
76
|
+
- Plugin config: `hubApiUrl`, `apiKey`
|
|
77
|
+
- Environment: `HUB_API_URL`, `OPENFINCLAW_API_KEY`
|
|
78
78
|
|
|
79
79
|
### ⚠️ API Key Security
|
|
80
80
|
|