@openfinclaw/openfinclaw-strategy 2026.3.25 → 2026.3.26
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/index.ts +5 -5
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/skills/price-check/SKILL.md +36 -31
- package/src/datahub/tools.ts +5 -7
- package/src/strategy/client.ts +1 -1
- package/src/strategy/fork.ts +9 -9
- package/src/strategy/storage.ts +1 -1
- package/src/strategy/tools.ts +3 -6
- package/src/strategy/validate.ts +1 -1
package/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
1
2
|
/**
|
|
2
3
|
* OpenFinClaw — Unified financial tools plugin.
|
|
3
4
|
* Features:
|
|
@@ -5,12 +6,11 @@
|
|
|
5
6
|
* - Market data tools: price, K-line, crypto data, compare, search
|
|
6
7
|
* Supports FEP v2.0 protocol for strategy packages.
|
|
7
8
|
*/
|
|
8
|
-
import type { OpenClawPluginApi } from "
|
|
9
|
-
import type { Command } from "commander";
|
|
10
|
-
import { registerDatahubTools } from "./src/datahub/tools.js";
|
|
11
|
-
import { registerStrategyTools } from "./src/strategy/tools.js";
|
|
9
|
+
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
12
10
|
import { registerStrategyCli } from "./src/cli.js";
|
|
13
11
|
import { resolvePluginConfig } from "./src/config.js";
|
|
12
|
+
import { registerDatahubTools } from "./src/datahub/tools.js";
|
|
13
|
+
import { registerStrategyTools } from "./src/strategy/tools.js";
|
|
14
14
|
|
|
15
15
|
const openfinclawPlugin = {
|
|
16
16
|
id: "openfinclaw",
|
|
@@ -41,4 +41,4 @@ const openfinclawPlugin = {
|
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
export default openfinclawPlugin;
|
|
44
|
+
export default openfinclawPlugin;
|
package/openclaw.plugin.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "OpenFinClaw",
|
|
4
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": "
|
|
6
|
+
"version": "2026.3.25",
|
|
7
7
|
"skills": ["./skills"],
|
|
8
8
|
"configSchema": {
|
|
9
9
|
"type": "object",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfinclaw/openfinclaw-strategy",
|
|
3
|
-
"version": "2026.3.
|
|
3
|
+
"version": "2026.3.26",
|
|
4
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",
|
|
@@ -12,14 +12,15 @@ metadata: { "openclaw": { "emoji": "💰", "requires": { "extensions": ["openfin
|
|
|
12
12
|
|
|
13
13
|
### fin_price — 查当前价
|
|
14
14
|
|
|
15
|
-
| Parameter | Type | Required | Example
|
|
16
|
-
| --------- | ------ | -------- |
|
|
17
|
-
| symbol | string | Yes | BTC/USDT
|
|
18
|
-
| market | string | No | crypto
|
|
15
|
+
| Parameter | Type | Required | Example |
|
|
16
|
+
| --------- | ------ | -------- | -------- |
|
|
17
|
+
| symbol | string | Yes | BTC/USDT |
|
|
18
|
+
| market | string | No | crypto |
|
|
19
19
|
|
|
20
20
|
Market 自动检测:含 `/` → crypto;`.SH/.SZ/.HK` 或纯字母 → equity。
|
|
21
21
|
|
|
22
22
|
**返回字段:**
|
|
23
|
+
|
|
23
24
|
- `price`: 最新价格
|
|
24
25
|
- `volume24h`: 24小时成交量(加密货币)
|
|
25
26
|
- `timestamp`: 数据时间
|
|
@@ -33,6 +34,7 @@ Market 自动检测:含 `/` → crypto;`.SH/.SZ/.HK` 或纯字母 → equity
|
|
|
33
34
|
| limit | number | No | 30 | 10 |
|
|
34
35
|
|
|
35
36
|
**返回字段:**
|
|
37
|
+
|
|
36
38
|
- `bars[]`: K线数组,包含 date, open, high, low, close, volume
|
|
37
39
|
|
|
38
40
|
### fin_compare — 多资产对比
|
|
@@ -42,50 +44,52 @@ Market 自动检测:含 `/` → crypto;`.SH/.SZ/.HK` 或纯字母 → equity
|
|
|
42
44
|
| symbols | string | Yes | BTC/USDT,ETH/USDT,600519.SH |
|
|
43
45
|
|
|
44
46
|
**返回字段:**
|
|
47
|
+
|
|
45
48
|
- `comparison[]`: 每个资产的 price, weekChange(周涨跌幅)
|
|
46
49
|
|
|
47
50
|
### fin_slim_search — 搜索代码
|
|
48
51
|
|
|
49
52
|
当用户只说公司/币种名称,不确定 symbol 时使用:
|
|
50
53
|
|
|
51
|
-
| Parameter | Type | Required | Example
|
|
52
|
-
| --------- | ------ | -------- |
|
|
53
|
-
| query | string | Yes | 茅台
|
|
54
|
-
| market | string | No | equity
|
|
54
|
+
| Parameter | Type | Required | Example |
|
|
55
|
+
| --------- | ------ | -------- | ------- |
|
|
56
|
+
| query | string | Yes | 茅台 |
|
|
57
|
+
| market | string | No | equity |
|
|
55
58
|
|
|
56
59
|
**触发场景:**
|
|
60
|
+
|
|
57
61
|
- 用户说 "茅台多少钱" → 先搜索 `query="茅台"` → 找到 `600519.SH` → 再查价格
|
|
58
62
|
- 用户说 "特斯拉股价" → 先搜索 `query="特斯拉"` → 找到 `TSLA` → 再查价格
|
|
59
63
|
|
|
60
64
|
### fin_crypto — 加密市场数据
|
|
61
65
|
|
|
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
|
|
66
|
+
| Parameter | Type | Required | Example |
|
|
67
|
+
| --------- | ------ | -------- | ------------------- |
|
|
68
|
+
| endpoint | string | Yes | market/funding_rate |
|
|
69
|
+
| symbol | string | No | BTC/USDT:USDT |
|
|
70
|
+
| limit | number | No | 20 |
|
|
67
71
|
|
|
68
72
|
**常用端点:**
|
|
69
73
|
|
|
70
|
-
| 端点
|
|
71
|
-
|
|
|
72
|
-
| `market/ticker`
|
|
73
|
-
| `market/tickers`
|
|
74
|
-
| `market/funding_rate`
|
|
75
|
-
| `coin/market`
|
|
76
|
-
| `coin/trending`
|
|
77
|
-
| `defi/protocols`
|
|
78
|
-
| `defi/yields`
|
|
74
|
+
| 端点 | 用途 |
|
|
75
|
+
| --------------------- | ------------------ |
|
|
76
|
+
| `market/ticker` | 单币种行情 |
|
|
77
|
+
| `market/tickers` | 多币种行情 |
|
|
78
|
+
| `market/funding_rate` | 资金费率 |
|
|
79
|
+
| `coin/market` | CoinGecko 币种排行 |
|
|
80
|
+
| `coin/trending` | 热门币种 |
|
|
81
|
+
| `defi/protocols` | DeFi 协议 TVL 排行 |
|
|
82
|
+
| `defi/yields` | DeFi 收益率 |
|
|
79
83
|
|
|
80
84
|
## Symbol 格式速查
|
|
81
85
|
|
|
82
|
-
| 格式
|
|
83
|
-
|
|
|
84
|
-
| `XXX/YYY`
|
|
85
|
-
| `6位数.SZ/SH`
|
|
86
|
-
| `5位数.HK`
|
|
87
|
-
| `1-5大写字母`
|
|
88
|
-
| `000xxx.SH`
|
|
86
|
+
| 格式 | 市场 | 示例 |
|
|
87
|
+
| ------------- | ------ | ------------------------ |
|
|
88
|
+
| `XXX/YYY` | Crypto | `BTC/USDT`, `ETH/BTC` |
|
|
89
|
+
| `6位数.SZ/SH` | A股 | `000001.SZ`, `600519.SH` |
|
|
90
|
+
| `5位数.HK` | 港股 | `00700.HK`, `00941.HK` |
|
|
91
|
+
| `1-5大写字母` | 美股 | `AAPL`, `NVDA`, `TSLA` |
|
|
92
|
+
| `000xxx.SH` | 指数 | `000300.SH` (沪深300) |
|
|
89
93
|
|
|
90
94
|
## Response Guidelines
|
|
91
95
|
|
|
@@ -101,7 +105,8 @@ Market 自动检测:含 `/` → crypto;`.SH/.SZ/.HK` 或纯字母 → equity
|
|
|
101
105
|
**流程:** `fin_price(symbol="BTC/USDT")` → 返回 $69,552
|
|
102
106
|
|
|
103
107
|
**用户:** 茅台现在什么价?
|
|
104
|
-
**流程:**
|
|
108
|
+
**流程:**
|
|
109
|
+
|
|
105
110
|
1. `fin_slim_search(query="茅台")` → 找到 `600519.SH`
|
|
106
111
|
2. `fin_price(symbol="600519.SH")` → 返回 ¥1,856.00
|
|
107
112
|
|
|
@@ -115,4 +120,4 @@ Market 自动检测:含 `/` → crypto;`.SH/.SZ/.HK` 或纯字母 → equity
|
|
|
115
120
|
**流程:** `fin_crypto(endpoint="market/funding_rate", symbol="BTC/USDT:USDT")` → 费率数据
|
|
116
121
|
|
|
117
122
|
**用户:** 现在 DeFi 哪个协议 TVL 最高?
|
|
118
|
-
**流程:** `fin_crypto(endpoint="defi/protocols", limit=5)` → TVL 排行
|
|
123
|
+
**流程:** `fin_crypto(endpoint="defi/protocols", limit=5)` → TVL 排行
|
package/src/datahub/tools.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Type } from "@sinclair/typebox";
|
|
6
6
|
import type { OpenClawPluginApi } from "openfinclaw/plugin-sdk";
|
|
7
|
-
import { DataHubClient, guessMarket } from "./client.js";
|
|
8
7
|
import type { UnifiedPluginConfig, MarketType } from "../types.js";
|
|
8
|
+
import { DataHubClient, guessMarket } from "./client.js";
|
|
9
9
|
|
|
10
10
|
/** JSON tool result helper. */
|
|
11
11
|
function json(payload: unknown) {
|
|
@@ -24,15 +24,13 @@ function pick(params: Record<string, unknown>, ...keys: string[]): Record<string
|
|
|
24
24
|
return out;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const NO_KEY =
|
|
27
|
+
const NO_KEY =
|
|
28
|
+
"API key not configured. Set apiKey in plugin config or OPENFINCLAW_API_KEY env var.";
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* Register DataHub market data tools.
|
|
31
32
|
*/
|
|
32
|
-
export function registerDatahubTools(
|
|
33
|
-
api: OpenClawPluginApi,
|
|
34
|
-
config: UnifiedPluginConfig,
|
|
35
|
-
): void {
|
|
33
|
+
export function registerDatahubTools(api: OpenClawPluginApi, config: UnifiedPluginConfig): void {
|
|
36
34
|
const datahubClient = config.apiKey
|
|
37
35
|
? new DataHubClient(config.datahubGatewayUrl, config.apiKey, config.requestTimeoutMs)
|
|
38
36
|
: null;
|
|
@@ -346,4 +344,4 @@ export function registerDatahubTools(
|
|
|
346
344
|
},
|
|
347
345
|
{ names: ["fin_slim_search"] },
|
|
348
346
|
);
|
|
349
|
-
}
|
|
347
|
+
}
|
package/src/strategy/client.ts
CHANGED
package/src/strategy/fork.ts
CHANGED
|
@@ -4,14 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
|
-
import {
|
|
8
|
-
getStrategiesRoot,
|
|
9
|
-
createDateDir,
|
|
10
|
-
generateForkDirName,
|
|
11
|
-
writeForkMeta,
|
|
12
|
-
parseStrategyId,
|
|
13
|
-
formatDate,
|
|
14
|
-
} from "./storage.js";
|
|
15
7
|
import type {
|
|
16
8
|
UnifiedPluginConfig,
|
|
17
9
|
ForkOptions,
|
|
@@ -20,6 +12,14 @@ import type {
|
|
|
20
12
|
ForkAndDownloadResponse,
|
|
21
13
|
} from "../types.js";
|
|
22
14
|
import type { ForkMeta } from "../types.js";
|
|
15
|
+
import {
|
|
16
|
+
getStrategiesRoot,
|
|
17
|
+
createDateDir,
|
|
18
|
+
generateForkDirName,
|
|
19
|
+
writeForkMeta,
|
|
20
|
+
parseStrategyId,
|
|
21
|
+
formatDate,
|
|
22
|
+
} from "./storage.js";
|
|
23
23
|
|
|
24
24
|
const HUB_BASE_URL = "https://hub.openfinclaw.ai";
|
|
25
25
|
|
|
@@ -340,4 +340,4 @@ export async function forkStrategy(
|
|
|
340
340
|
*/
|
|
341
341
|
export function buildHubUrl(strategyId: string): string {
|
|
342
342
|
return `${HUB_BASE_URL}/strategy/${strategyId}`;
|
|
343
|
-
}
|
|
343
|
+
}
|
package/src/strategy/storage.ts
CHANGED
package/src/strategy/tools.ts
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
6
6
|
import { Type } from "@sinclair/typebox";
|
|
7
7
|
import type { OpenClawPluginApi } from "openfinclaw/plugin-sdk";
|
|
8
|
+
import type { UnifiedPluginConfig, BoardType, LeaderboardResponse } from "../types.js";
|
|
8
9
|
import { hubApiRequest } from "./client.js";
|
|
9
10
|
import { forkStrategy, fetchStrategyInfo } from "./fork.js";
|
|
10
11
|
import { listLocalStrategies } from "./storage.js";
|
|
11
12
|
import { validateStrategyPackage } from "./validate.js";
|
|
12
|
-
import type { UnifiedPluginConfig, BoardType, LeaderboardResponse } from "../types.js";
|
|
13
13
|
|
|
14
14
|
/** JSON tool result helper. */
|
|
15
15
|
function json(payload: unknown) {
|
|
@@ -25,10 +25,7 @@ const NO_API_KEY =
|
|
|
25
25
|
/**
|
|
26
26
|
* Register strategy tools.
|
|
27
27
|
*/
|
|
28
|
-
export function registerStrategyTools(
|
|
29
|
-
api: OpenClawPluginApi,
|
|
30
|
-
config: UnifiedPluginConfig,
|
|
31
|
-
): void {
|
|
28
|
+
export function registerStrategyTools(api: OpenClawPluginApi, config: UnifiedPluginConfig): void {
|
|
32
29
|
// ── skill_publish ──
|
|
33
30
|
api.registerTool(
|
|
34
31
|
{
|
|
@@ -521,4 +518,4 @@ export function registerStrategyTools(
|
|
|
521
518
|
},
|
|
522
519
|
{ names: ["skill_get_info"] },
|
|
523
520
|
);
|
|
524
|
-
}
|
|
521
|
+
}
|
package/src/strategy/validate.ts
CHANGED