tickflow-assist 0.2.5 → 0.2.7

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,148 +1,70 @@
1
- # 📈 TickFlow Assist
1
+ # TickFlow Assist
2
2
 
3
- 基于 [OpenClaw](https://openclaw.ai) 的 A 股监控与分析插件。它使用 [TickFlow API](https://tickflow.org/auth/register?ref=BUJ54JEDGE) 获取行情与财务数据,结合 LLM 生成技术面、基本面、资讯面的综合判断,并把结果持久化到本地 LanceDB。
3
+ 基于 [OpenClaw](https://openclaw.ai) 的 A 股监控与分析插件。它使用 [TickFlow](https://tickflow.org/auth/register?ref=BUJ54JEDGE) 获取行情与财务数据,结合 LLM 生成技术面、基本面、资讯面的综合判断,并把结果持久化到本地 LanceDB。
4
4
 
5
- 当前主线架构:
5
+ ## 安装
6
6
 
7
- - OpenClaw 插件是主入口
8
- - JS/TS 负责主业务流程
9
- - Python 仅保留技术指标计算
10
-
11
- 兼容性要求:
12
-
13
- - TickFlow Assist `0.2.0` 起面向 OpenClaw `v2026.3.22+` 的新版 plugin SDK
14
- - 建议 Node `>=22.16.0`,这是 OpenClaw `v2026.3.22` 上游声明的运行时要求
15
-
16
- ## 🧭 项目简介
17
-
18
- TickFlow Assist 面向一条完整的“自选管理 -> 数据抓取 -> 综合分析 -> 后台监控 -> 结果留痕”链路,适合在 OpenClaw 中做 A 股日常盯盘、收盘后复盘和分析结果沉淀。
19
-
20
- ## ✨ 核心特性
21
-
22
- - 数据抓取:支持日 K、分钟 K、实时行情与财务数据接入,收盘后可批量更新。
23
- - 多维分析:技术面、财务面、资讯面按固定流水线执行,输出综合结论与关键价位。
24
- - 监控告警:围绕止损、突破、支撑、压力、止盈、涨跌幅和成交量异动进行交易时段轮询。
25
- - 复盘留痕:收盘后自动生成活动关键价位快照,并提供 `1/3/5` 日回测统计(测试)。
26
- - 本地数据库:使用 LanceDB 保存自选、K 线、指标、分析结果、关键价位和告警日志。
27
-
28
- ## 📚 文档导航
29
-
30
- - 安装指南:[docs/installation.md](docs/installation.md)
31
- - 使用指南:[docs/usage.md](docs/usage.md)
32
- - 插件清单:[openclaw.plugin.json](openclaw.plugin.json)
33
- - 内置技能:
34
- - [skills/stock-analysis/SKILL.md](skills/stock-analysis/SKILL.md)
35
- - [skills/usage-help/SKILL.md](skills/usage-help/SKILL.md)
36
- - [skills/database-query/SKILL.md](skills/database-query/SKILL.md)
37
-
38
- ## 🛠 安装与配置
39
-
40
- ### 社区安装(推荐)
41
-
42
- 如果你不需改动源码,可直接通过 OpenClaw 插件市场或 npm 安装:
7
+ 社区安装:
43
8
 
44
9
  ```bash
45
10
  openclaw plugins install tickflow-assist
46
11
  npx -y tickflow-assist configure-openclaw
47
12
  ```
48
13
 
49
- ### 一键安装脚本
14
+ 第二条命令会写入 `~/.openclaw/openclaw.json` 中的 `plugins.entries["tickflow-assist"].config`,并默认执行:
50
15
 
51
- 如果你已经安装了 `git`、`node`、`npm`、`uv`、`openclaw` `jq`,并且想要从源码运行,可以直接运行安装向导:
16
+ - `openclaw plugins enable tickflow-assist`
17
+ - `openclaw config validate`
18
+ - `openclaw gateway restart`
19
+
20
+ 如果你希望先审阅配置再手动启用或重启,可使用:
52
21
 
53
22
  ```bash
54
- bash -c "$(curl -fsSL https://raw.githubusercontent.com/robinspt/tickflow-assist/main/setup-tickflow.sh)"
23
+ npx -y tickflow-assist configure-openclaw --no-enable --no-restart
55
24
  ```
56
25
 
57
- 向导会自动完成源码更新、依赖安装、配置写入、插件安装与 Gateway 重启。完整流程见 [docs/installation.md](docs/installation.md)。
58
-
59
- 如果你已经装过旧版本,优先直接执行“升级”。具体升级与重装边界见 [docs/installation.md](docs/installation.md)。
60
-
61
- ### 手动源码安装
26
+ 社区安装后的升级方式:
62
27
 
63
28
  ```bash
64
- git clone https://github.com/robinspt/tickflow-assist.git
65
- cd tickflow-assist
66
- npm install
67
- cd python
68
- uv sync
69
- cd ..
70
- npm run check
71
- npm run build
72
- openclaw plugins install -l /path/to/tickflow-assist
73
- openclaw plugins enable tickflow-assist
29
+ openclaw plugins update tickflow-assist
74
30
  openclaw gateway restart
75
31
  ```
76
32
 
33
+ ## 配置
77
34
 
78
-
79
- ## 🚀 使用方式
80
-
81
- 常见入口有三种:
82
-
83
- - OpenClaw 对话:直接说“添加 002261”“分析 002261”“开始监控”。
84
- - Slash Command:使用 `/ta_addstock`、`/ta_analyze`、`/ta_monitorstatus` 等免 AI 直达命令。
85
- - 本地 CLI:通过 `npm run tool -- ...`、`npm run monitor-loop`、`npm run daily-update-loop` 做调试或直连运行。
86
-
87
- 常用示例:
35
+ 插件正式运行读取:
88
36
 
89
37
  ```text
90
- 添加 002261
91
- 分析 002261
92
- /ta_addstock 002261 34.15
93
- /ta_monitorstatus
94
- npm run tool -- analyze '{"symbol":"002261"}'
38
+ ~/.openclaw/openclaw.json
95
39
  ```
96
40
 
97
- 更完整的指令分类、CLI 示例与运行规则见 [docs/usage.md](docs/usage.md)。
98
-
99
- ## 🧩 架构与目录
100
-
101
- 后台任务统一由 `tickflow-assist.managed-loop` 托管,在同一个 service 内并行运行日更与实时监控。
41
+ 配置路径:
102
42
 
103
43
  ```text
104
- tickflow-assist/
105
- ├── docs/ # 安装与使用文档
106
- ├── src/ # 主业务代码
107
- ├── src/tools/ # OpenClaw tools
108
- ├── src/services/ # 行情、分析、监控、告警、更新服务
109
- ├── src/background/ # 日更与实时监控后台逻辑
110
- ├── src/prompts/analysis/ # 分析 prompt
111
- ├── skills/ # 插件内置 skills
112
- ├── python/ # Python 指标计算子模块
113
- ├── openclaw.plugin.json # 插件清单
114
- └── README.md # 项目概览
44
+ plugins.entries["tickflow-assist"].config
115
45
  ```
116
46
 
117
- ## 🔌 依赖与可选能力
118
-
119
- - [TickFlow](https://tickflow.org/auth/register?ref=BUJ54JEDGE):提供日线、分钟线、实时行情与财务数据接口。
120
- - OpenClaw:负责插件运行、工具注册、对话入口与消息投递。
121
- - [东方财富妙想 Skills](https://marketing.dfcfs.com/views/finskillshub/):可选,用于 `mx_search` 与 `mx_select_stock`,也用于非 Expert 财务链路的 lite 补充。
122
-
123
- ## ⚠️ 风险提示
47
+ 常用字段:
124
48
 
125
- 本项目仅用于策略研究、流程验证与教学交流,不构成任何形式的投资建议、收益承诺或具体交易指引。
49
+ - 必填:`tickflowApiKey`、`llmApiKey`
50
+ - 常用:`llmBaseUrl`、`llmModel`、`databasePath`、`calendarFile`
51
+ - 可选:`mxSearchApiKey`、`alertTarget`、`alertAccount`
126
52
 
127
- - 市场环境、流动性、执行价格与个人交易纪律都会影响实际结果,历史表现不代表未来收益。
128
- - AI 模型、自动化分析与回测结果都可能存在偏差、遗漏或失效,不应作为单一决策依据。
129
- - 使用前请结合自身资金情况、风险承受能力与独立判断审慎评估,并自行承担相应风险。
53
+ `mxSearchApiKey` 用于 `mx_search`、`mx_select_stock` 以及非 `Expert` 财务链路的 lite 补充;`alertTarget` 仅在 `test_alert`、实时监控告警和定时通知场景需要。
130
54
 
131
- ## 📝 更新日志
55
+ ## 功能
132
56
 
133
- - `2026-03-17`:统一后台托管循环
134
- - `2026-03-19`:新增财务与妙想链路
135
- - `2026-03-20`:补充收盘分析与回测
136
- - `2026-03-21`:优化A股语境与复盘记忆
137
- - `2026-03-23`:发布 `v0.2.0`,迁移到 OpenClaw `v2026.3.22+` 的新版 plugin SDK,并将复盘改至 20:00 独立调度
138
- - `2026-03-27`:发布 `v0.2.5`,优化分析 prompt 并增强结构化 JSON 解析容错。
57
+ - 自选股管理、日 K / 分钟 K 抓取与指标计算
58
+ - 技术面、财务面、资讯面的综合分析
59
+ - 实时监控、定时日更、收盘后复盘
60
+ - 本地 LanceDB 数据留痕与分析结果查看
139
61
 
140
- ## 🙏 鸣谢
62
+ ## 运行说明
141
63
 
142
- - [TickFlow](https://tickflow.org/auth/register?ref=BUJ54JEDGE) 提供行情数据服务与 API 支持
143
- - [OpenClaw](https://openclaw.ai) 提供插件运行、对话通道与工具编排能力
144
- - [CortexReach/memory-lancedb-pro](https://github.com/CortexReach/memory-lancedb-pro) 给你的 OpenClaw Agent 提供持久化、智能化的长期记忆
64
+ - 插件会在本地 `databasePath` 下持久化 LanceDB 数据。
65
+ - 后台服务会按配置执行定时日更与实时监控。
66
+ - Python 子模块仅用于技术指标计算,不承担主业务流程。
145
67
 
146
- ## 📄 License
68
+ ## 仓库
147
69
 
148
- MIT
70
+ - GitHub: <https://github.com/robinspt/tickflow-assist>
@@ -80,9 +80,6 @@ export function validatePluginConfig(config) {
80
80
  if (!config.llmApiKey) {
81
81
  errors.push("llmApiKey is required");
82
82
  }
83
- if (!config.alertTarget) {
84
- errors.push("alertTarget is required");
85
- }
86
83
  if (!config.tickflowApiUrl.startsWith("http://") && !config.tickflowApiUrl.startsWith("https://")) {
87
84
  errors.push("tickflowApiUrl must be an absolute http(s) URL");
88
85
  }
@@ -442,7 +442,7 @@ async function promptForConfig(options, existing, pluginDir, configPath) {
442
442
  else {
443
443
  targetLabel = `已选通道 [${seed.alertChannel}],请输入 Alert Target`;
444
444
  }
445
- seed.alertTarget = await promptString(rl, targetLabel, seed.alertTarget, true);
445
+ seed.alertTarget = await promptString(rl, targetLabel, seed.alertTarget, false);
446
446
  seed.requestInterval = await promptInteger(rl, "Request Interval (seconds)", seed.requestInterval, 5);
447
447
  seed.dailyUpdateNotify = await promptBoolean(rl, "Daily Update Notify", seed.dailyUpdateNotify);
448
448
  }
@@ -495,9 +495,6 @@ function assertRequired(config) {
495
495
  if (!config.llmApiKey) {
496
496
  throw new Error("llmApiKey is required");
497
497
  }
498
- if (!config.alertTarget) {
499
- throw new Error("alertTarget is required");
500
- }
501
498
  }
502
499
  async function ensurePathNotice(targetPath, label) {
503
500
  try {
@@ -598,50 +595,10 @@ async function setupPythonDeps(pythonWorkdir, nonInteractive) {
598
595
  try {
599
596
  const which = spawnSync("which", ["uv"], { encoding: "utf-8" });
600
597
  if (which.status !== 0) {
601
- console.log("\n ⚠️ 找不到 uv (Python 包管理工具)");
602
- let shouldInstall = false;
603
- if (!nonInteractive) {
604
- const rl = createInterface({ input: process.stdin, output: process.stdout });
605
- const answer = (await rl.question(" 是否自动下载并安装 uv?(y/n) [y]: ")).trim().toLowerCase();
606
- rl.close();
607
- if (!answer || ["y", "yes", "1", "true"].includes(answer)) {
608
- shouldInstall = true;
609
- }
610
- }
611
- if (shouldInstall) {
612
- console.log(" 正在安装 uv...");
613
- const installResult = spawnSync("sh", ["-c", "curl -LsSf https://astral.sh/uv/install.sh | sh"], { stdio: "inherit" });
614
- if (installResult.status !== 0) {
615
- console.warn(" uv 安装失败,跳过 Python 依赖安装。");
616
- return;
617
- }
618
- let foundUv = false;
619
- let installedLoc = "";
620
- for (const loc of [path.join(os.homedir(), ".local", "bin", "uv"), path.join(os.homedir(), ".cargo", "bin", "uv")]) {
621
- try {
622
- await access(loc);
623
- uvBin = loc;
624
- installedLoc = loc;
625
- foundUv = true;
626
- break;
627
- }
628
- catch {
629
- // ignore
630
- }
631
- }
632
- if (!foundUv) {
633
- uvBin = "uv";
634
- }
635
- else {
636
- console.log(`\n ✅ uv 已自动安装到 ${installedLoc}`);
637
- console.log(" ⚠️ 温馨提示:为了在终端能直接使用 uv 命令,您可能需要执行 `source $HOME/.local/bin/env` \n 或自行将其所在目录添加入系统的 PATH 环境变量中。\n");
638
- }
639
- }
640
- else {
641
- console.warn("\n ⚠️ 跳过 Python 依赖安装。请手动安装 uv (https://docs.astral.sh/uv/) 并执行 'uv sync',路径:");
642
- console.warn(` ${pythonWorkdir}`);
643
- return;
644
- }
598
+ console.warn("\n ⚠️ 找不到 uv (Python 包管理工具),已跳过 Python 依赖安装。");
599
+ console.warn(" 请先手动安装 uv,再在以下目录执行 `uv sync`:");
600
+ console.warn(` ${pythonWorkdir}`);
601
+ return;
645
602
  }
646
603
  else {
647
604
  uvBin = which.stdout.trim() || "uv";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,93 @@
1
+ import assert from "node:assert/strict";
2
+ import path from "node:path";
3
+ import test from "node:test";
4
+ import pluginEntry from "./plugin.js";
5
+ function createMockApi() {
6
+ const registeredTools = [];
7
+ const registeredServices = [];
8
+ const registeredCommands = [];
9
+ const hookEvents = [];
10
+ const logger = {
11
+ info() { },
12
+ warn() { },
13
+ error() { },
14
+ debug() { },
15
+ };
16
+ const api = {
17
+ config: {},
18
+ pluginConfig: {
19
+ tickflowApiKey: "test-tickflow-key",
20
+ llmApiKey: "test-llm-key",
21
+ alertTarget: "TEST_TARGET",
22
+ databasePath: "./tmp/plugin-registration-test-db",
23
+ calendarFile: "./day_future.txt",
24
+ pythonWorkdir: "./python",
25
+ },
26
+ registrationMode: "full",
27
+ resolvePath(input) {
28
+ return path.resolve(process.cwd(), input);
29
+ },
30
+ runtime: undefined,
31
+ logger,
32
+ registerTool(tool, opts) {
33
+ registeredTools.push({ tool, opts });
34
+ },
35
+ registerService(service) {
36
+ registeredServices.push(service);
37
+ },
38
+ registerCommand(command) {
39
+ registeredCommands.push(command);
40
+ },
41
+ on(event) {
42
+ hookEvents.push(event);
43
+ },
44
+ };
45
+ return {
46
+ api,
47
+ registeredTools,
48
+ registeredServices,
49
+ registeredCommands,
50
+ hookEvents,
51
+ };
52
+ }
53
+ function mapToolOptionality(registeredTools) {
54
+ return new Map(registeredTools.map(({ tool, opts }) => [tool.name, opts?.optional === true]));
55
+ }
56
+ test("plugin registration marks state-changing tools as optional", () => {
57
+ const { api, registeredTools, registeredServices, registeredCommands, hookEvents, } = createMockApi();
58
+ pluginEntry.register(api);
59
+ const optionality = mapToolOptionality(registeredTools);
60
+ for (const toolName of [
61
+ "add_stock",
62
+ "remove_stock",
63
+ "refresh_watchlist_names",
64
+ "refresh_watchlist_profiles",
65
+ "start_monitor",
66
+ "stop_monitor",
67
+ "start_daily_update",
68
+ "stop_daily_update",
69
+ "update_all",
70
+ "test_alert",
71
+ ]) {
72
+ assert.equal(optionality.get(toolName), true, `${toolName} should be optional`);
73
+ }
74
+ for (const toolName of [
75
+ "analyze",
76
+ "backtest_key_levels",
77
+ "daily_update_status",
78
+ "fetch_financials",
79
+ "fetch_intraday_klines",
80
+ "fetch_klines",
81
+ "list_watchlist",
82
+ "monitor_status",
83
+ "mx_search",
84
+ "mx_select_stock",
85
+ "query_database",
86
+ "view_analysis",
87
+ ]) {
88
+ assert.equal(optionality.get(toolName), false, `${toolName} should remain required`);
89
+ }
90
+ assert.ok(registeredServices.some((service) => service.id === "tickflow-assist.managed-loop"), "managed loop service should be registered in full mode");
91
+ assert.ok(registeredCommands.some((command) => command.name === "ta_addstock"), "slash commands should still be registered");
92
+ assert.ok(hookEvents.includes("before_prompt_build"), "stock-agent prompt hook should remain registered");
93
+ });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "tickflow-assist",
3
3
  "name": "TickFlow Assist",
4
- "version": "0.2.5",
4
+ "version": "0.2.7",
5
5
  "description": "A-share watchlist analysis, monitoring, and alert delivery powered by TickFlow and OpenClaw.",
6
6
  "skills": [
7
7
  "skills"
@@ -9,54 +9,69 @@
9
9
  "configSchema": {
10
10
  "type": "object",
11
11
  "additionalProperties": false,
12
+ "required": ["tickflowApiKey", "llmApiKey"],
12
13
  "properties": {
13
14
  "tickflowApiUrl": {
14
15
  "type": "string",
15
- "default": "https://api.tickflow.org"
16
+ "default": "https://api.tickflow.org",
17
+ "description": "TickFlow API base URL."
16
18
  },
17
19
  "tickflowApiKey": {
18
- "type": "string"
20
+ "type": "string",
21
+ "minLength": 1,
22
+ "description": "Required. TickFlow API key used for market and financial data."
19
23
  },
20
24
  "tickflowApiKeyLevel": {
21
25
  "type": "string",
22
26
  "enum": ["Free", "Start", "Pro", "Expert"],
23
- "default": "Free"
27
+ "default": "Free",
28
+ "description": "TickFlow subscription level. Pro and Expert enable intraday K-line fetching."
24
29
  },
25
30
  "mxSearchApiUrl": {
26
31
  "type": "string",
27
- "default": "https://mkapi2.dfcfs.com/finskillshub/api/claw"
32
+ "default": "https://mkapi2.dfcfs.com/finskillshub/api/claw",
33
+ "description": "MX Search API base URL."
28
34
  },
29
35
  "mxSearchApiKey": {
30
36
  "type": "string",
31
- "default": ""
37
+ "default": "",
38
+ "description": "Optional. Enables mx_search, mx_select_stock, and non-Expert financial fallback."
32
39
  },
33
40
  "llmBaseUrl": {
34
41
  "type": "string",
35
- "default": "https://api.openai.com/v1"
42
+ "default": "https://api.openai.com/v1",
43
+ "description": "OpenAI-compatible LLM API base URL."
36
44
  },
37
45
  "llmApiKey": {
38
- "type": "string"
46
+ "type": "string",
47
+ "minLength": 1,
48
+ "description": "Required. API key for the analysis model endpoint configured in llmBaseUrl."
39
49
  },
40
50
  "llmModel": {
41
51
  "type": "string",
42
- "default": "gpt-4o"
52
+ "default": "gpt-4o",
53
+ "description": "Model name used for analysis."
43
54
  },
44
55
  "databasePath": {
45
56
  "type": "string",
46
- "default": "./data/lancedb"
57
+ "default": "./data/lancedb",
58
+ "description": "Local LanceDB data directory."
47
59
  },
48
60
  "calendarFile": {
49
61
  "type": "string",
50
- "default": "./day_future.txt"
62
+ "default": "./day_future.txt",
63
+ "description": "Trading calendar file path."
51
64
  },
52
65
  "requestInterval": {
53
66
  "type": "integer",
54
67
  "minimum": 5,
55
- "default": 30
68
+ "default": 30,
69
+ "description": "Realtime monitoring polling interval in seconds."
56
70
  },
57
71
  "dailyUpdateNotify": {
58
72
  "type": "boolean",
59
- "default": true
73
+ "default": true,
74
+ "description": "Whether scheduled daily update and post-close review send notifications."
60
75
  },
61
76
  "alertChannel": {
62
77
  "type": "string",
@@ -73,44 +88,74 @@
73
88
  },
74
89
  "alertTarget": {
75
90
  "type": "string",
76
- "description": "Channel target, e.g. Telegram chat ID, qqbot:c2c:OPENID, or WeCom userId/chatId",
91
+ "description": "Optional. Channel target for test_alert, monitoring alerts, and scheduled notifications.",
77
92
  "default": ""
78
93
  },
79
94
  "pythonBin": {
80
95
  "type": "string",
81
- "default": "uv"
96
+ "default": "uv",
97
+ "description": "Python launcher used for indicator calculation."
82
98
  },
83
99
  "pythonArgs": {
84
100
  "type": "array",
85
101
  "items": {
86
102
  "type": "string"
87
103
  },
88
- "default": ["run", "python"]
104
+ "default": ["run", "python"],
105
+ "description": "Arguments passed to pythonBin before indicator_runner.py."
89
106
  },
90
107
  "pythonWorkdir": {
91
108
  "type": "string",
92
- "default": "./python"
109
+ "default": "./python",
110
+ "description": "Working directory for the Python indicator bridge."
93
111
  }
94
112
  }
95
113
  },
96
114
  "uiHints": {
97
115
  "tickflowApiKey": {
98
116
  "label": "TickFlow API Key",
117
+ "help": "Required for TickFlow market and financial data.",
99
118
  "sensitive": true
100
119
  },
101
120
  "tickflowApiKeyLevel": {
102
- "label": "TickFlow API Key Level"
121
+ "label": "TickFlow API Key Level",
122
+ "help": "Set this to your actual TickFlow subscription level."
103
123
  },
104
124
  "mxSearchApiKey": {
105
125
  "label": "MX Search API Key",
126
+ "help": "Optional. Enables mx_search, mx_select_stock, and lite financial fallback.",
106
127
  "sensitive": true
107
128
  },
129
+ "llmBaseUrl": {
130
+ "label": "LLM Base URL",
131
+ "help": "OpenAI-compatible analysis endpoint."
132
+ },
108
133
  "llmApiKey": {
109
134
  "label": "LLM API Key",
135
+ "help": "Required for analysis model requests.",
110
136
  "sensitive": true
111
137
  },
138
+ "llmModel": {
139
+ "label": "LLM Model",
140
+ "help": "Model name used for stock analysis."
141
+ },
142
+ "alertChannel": {
143
+ "label": "Alert Channel",
144
+ "help": "Default delivery channel for alert messages."
145
+ },
112
146
  "alertTarget": {
113
- "label": "Alert Target"
147
+ "label": "Alert Target",
148
+ "help": "Optional. Configure this if you want test_alert, monitoring alerts, or scheduled notifications."
149
+ },
150
+ "databasePath": {
151
+ "label": "Database Path",
152
+ "help": "Local LanceDB storage directory.",
153
+ "advanced": true
154
+ },
155
+ "calendarFile": {
156
+ "label": "Calendar File",
157
+ "help": "Trading calendar file path.",
158
+ "advanced": true
114
159
  }
115
160
  }
116
161
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tickflow-assist",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "OpenClaw plugin for TickFlow-based A-share analysis, monitoring, and alerting.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -10,7 +10,6 @@
10
10
  },
11
11
  "files": [
12
12
  "dist",
13
- "docs",
14
13
  "skills",
15
14
  "python",
16
15
  "day_future.txt",
@@ -25,9 +24,11 @@
25
24
  "lancedb"
26
25
  ],
27
26
  "scripts": {
28
- "build": "tsc -p tsconfig.json",
27
+ "build": "node ./scripts/clean-dist.mjs && tsc -p tsconfig.json",
29
28
  "check": "tsc -p tsconfig.json --noEmit",
30
29
  "dev": "tsc -p tsconfig.json --watch",
30
+ "prepack": "npm run build && node ./scripts/prepare-package-assets.mjs",
31
+ "postpack": "node ./scripts/restore-package-assets.mjs",
31
32
  "test": "npm run build && node --test dist/plugin-registration.test.js",
32
33
  "community-setup": "node dist/dev/tickflow-assist-cli.js configure-openclaw",
33
34
  "tool": "node dist/dev/run-tool.js",
@@ -51,7 +52,7 @@
51
52
  },
52
53
  "devDependencies": {
53
54
  "@types/node": "^22.13.11",
54
- "openclaw": "^2026.3.22",
55
+ "openclaw": "^2026.3.28",
55
56
  "typescript": "^5.8.2"
56
57
  }
57
58
  }
@@ -5,7 +5,8 @@ metadata:
5
5
  openclaw:
6
6
  skillKey: database_query
7
7
  requires:
8
- config: true
8
+ config:
9
+ - plugins.entries.tickflow-assist.enabled
9
10
  ---
10
11
  # LanceDB 数据查询
11
12
 
@@ -5,7 +5,10 @@ metadata:
5
5
  openclaw:
6
6
  skillKey: stock_analysis
7
7
  requires:
8
- config: true
8
+ config:
9
+ - plugins.entries.tickflow-assist.enabled
10
+ - plugins.entries.tickflow-assist.config.tickflowApiKey
11
+ - plugins.entries.tickflow-assist.config.llmApiKey
9
12
  ---
10
13
  # 股票分析与监控
11
14
 
@@ -1,3 +0,0 @@
1
- import type { PluginConfig } from "../config/schema.js";
2
- export declare function spawnMonitorLoop(config: PluginConfig, configSource: "openclaw_plugin" | "local_config"): number | null;
3
- export declare function isPidAlive(pid: number): boolean;
@@ -1,24 +0,0 @@
1
- import { spawn } from "node:child_process";
2
- import { fileURLToPath } from "node:url";
3
- import { buildProcessConfigEnv } from "./process-config.js";
4
- const PROJECT_ROOT = fileURLToPath(new URL("../../", import.meta.url));
5
- const MONITOR_LOOP_SCRIPT = fileURLToPath(new URL("../dev/run-monitor-loop.js", import.meta.url));
6
- export function spawnMonitorLoop(config, configSource) {
7
- const child = spawn(process.execPath, [MONITOR_LOOP_SCRIPT], {
8
- cwd: PROJECT_ROOT,
9
- detached: true,
10
- stdio: "ignore",
11
- env: buildProcessConfigEnv(config, configSource),
12
- });
13
- child.unref();
14
- return child.pid ?? null;
15
- }
16
- export function isPidAlive(pid) {
17
- try {
18
- process.kill(pid, 0);
19
- return true;
20
- }
21
- catch {
22
- return false;
23
- }
24
- }
@@ -1,393 +0,0 @@
1
- # TickFlow Assist 安装指南
2
-
3
- 本文档聚焦于安装、配置与消息通道接入。功能与日常使用请参阅 [使用说明](usage.md),项目概览请先看 [README](../README.md)。
4
-
5
- ## 1. 前置条件
6
-
7
- 开始前请确认目标机器已经具备:
8
-
9
- - `git`
10
- - `node` 与 `npm`
11
- - `uv`
12
- - `openclaw`
13
- - OpenClaw 版本建议 `v2026.3.22` 或更高
14
- - Node 版本建议 `>=22.16.0`(这是 OpenClaw `v2026.3.22` 上游声明的运行时要求)
15
- - 可用的 `TickFlow API Key`:[获取地址](https://tickflow.org/auth/register?ref=BUJ54JEDGE)
16
- - 可用的 OpenAI 兼容 `LLM API Key`
17
- - 可选的东方财富妙想 Skills `API Key`:[获取地址](https://marketing.dfcfs.com/views/finskillshub/)
18
-
19
- 如果目标机器还没安装 `uv`,先执行:
20
-
21
- ```bash
22
- curl -LsSf https://astral.sh/uv/install.sh | sh
23
- ```
24
-
25
- ## 2. 一键安装(推荐)
26
-
27
- 安装、升级、卸载都优先建议使用项目自带向导:
28
-
29
- ```bash
30
- bash -c "$(curl -fsSL https://raw.githubusercontent.com/robinspt/tickflow-assist/main/setup-tickflow.sh)"
31
- ```
32
-
33
- 向导会自动完成以下工作:
34
-
35
- - 拉取或更新源码
36
- - 安装 Node 与 Python 依赖
37
- - 生成或复用 `local.config.json`
38
- - 写入 `~/.openclaw/openclaw.json` 中的插件配置
39
- - 安装并启用 `tickflow-assist`
40
- - 重启 OpenClaw Gateway
41
-
42
- 如果你只是日常升级,重新运行同一条命令并在菜单里选择“升级”即可。更具体的升级与重装说明见下文 [7.2 升级](#72-升级) 与 [7.3 禁用重装与清理](#73-禁用重装与清理)。
43
-
44
- ## 3. 社区安装(推荐)
45
-
46
- 如果你不需改动源码,可直接通过 OpenClaw 插件市场或 npm 安装:
47
-
48
- ```bash
49
- openclaw plugins install tickflow-assist
50
- npx -y tickflow-assist configure-openclaw
51
- ```
52
-
53
- 第二条命令会自动:
54
-
55
- - 安装 Python 依赖(`uv sync`)
56
- - 写入 `plugins.entries["tickflow-assist"].config`
57
- - 给顶层 `tools.allow` 或推断出的目标 Agent 补 `tickflow-assist` allowlist
58
- - 执行 `openclaw plugins enable tickflow-assist`
59
- - 执行 `openclaw config validate`
60
- - 执行 `openclaw gateway restart`
61
-
62
- 如果你已经手动启用插件,或暂时不想重启 Gateway,可追加 `--no-enable` 或 `--no-restart`。如果 Python 已经装好或不需要自动安装,可追加 `--no-python-setup`。
63
-
64
- ## 4. 源码安装
65
-
66
- ### 4.1 拉取源码
67
-
68
- 推荐把项目放在普通开发目录,不要放到 `~/.openclaw/workspace/...` 下面。
69
-
70
- ```bash
71
- cd ~
72
- git clone https://github.com/robinspt/tickflow-assist.git
73
- cd tickflow-assist
74
- ```
75
-
76
- ### 4.2 安装依赖并构建
77
-
78
- ```bash
79
- npm install
80
- cd python
81
- uv sync
82
- cd ..
83
- npm run check
84
- npm run build
85
- ```
86
-
87
- ### 4.3 安装并启用插件(源码安装)
88
-
89
- ```bash
90
- openclaw plugins install -l /path/to/tickflow-assist
91
- openclaw plugins enable tickflow-assist
92
- ```
93
-
94
- ## 5. 插件配置
95
-
96
- 正式插件运行读取:
97
-
98
- ```text
99
- ~/.openclaw/openclaw.json
100
- ```
101
-
102
- 配置路径:
103
-
104
- ```text
105
- plugins.entries["tickflow-assist"].config
106
- ```
107
-
108
- 最小示例:
109
-
110
- ```json5
111
- {
112
- "plugins": {
113
- "enabled": true,
114
- "entries": {
115
- "tickflow-assist": {
116
- "enabled": true,
117
- "config": {
118
- "tickflowApiKey": "your-tickflow-key",
119
- "mxSearchApiUrl": "https://mkapi2.dfcfs.com/finskillshub/api/claw",
120
- "mxSearchApiKey": "mkt_xxx",
121
- "llmBaseUrl": "https://api.openai.com/v1",
122
- "llmApiKey": "sk-xxx",
123
- "llmModel": "gpt-4o",
124
- "databasePath": "/path/to/tickflow-assist/data/lancedb",
125
- "calendarFile": "/path/to/tickflow-assist/day_future.txt",
126
- "alertChannel": "telegram",
127
- "alertTarget": "YOUR_TARGET",
128
- "pythonBin": "uv",
129
- "pythonArgs": ["run", "python"],
130
- "pythonWorkdir": "/path/to/tickflow-assist/python"
131
- }
132
- }
133
- }
134
- }
135
- }
136
- ```
137
-
138
- 如果你还需要使用 `npm run tool -- ...`、`npm run monitor-loop` 或 `npm run daily-update-loop`,则项目根目录还需要有一个 `local.config.json`,并且字段必须写在 `plugin` 下:
139
-
140
- ```json
141
- {
142
- "plugin": {
143
- "tickflowApiKey": "your-tickflow-key",
144
- "mxSearchApiUrl": "https://mkapi2.dfcfs.com/finskillshub/api/claw",
145
- "mxSearchApiKey": "mkt_xxx",
146
- "llmBaseUrl": "https://api.openai.com/v1",
147
- "llmApiKey": "sk-xxx",
148
- "llmModel": "gpt-4o",
149
- "databasePath": "./data/lancedb",
150
- "calendarFile": "./day_future.txt",
151
- "alertChannel": "telegram",
152
- "alertTarget": "YOUR_TARGET"
153
- }
154
- }
155
- ```
156
-
157
- ### 配置字段速查
158
-
159
- | 字段 | 必填 | 说明 |
160
- |---|---|---|
161
- | `tickflowApiUrl` | 否 | TickFlow API 地址,默认 `https://api.tickflow.org` |
162
- | `tickflowApiKey` | 是 | TickFlow API Key |
163
- | `tickflowApiKeyLevel` | 否 | `Free` / `Start` / `Pro` / `Expert`;`Pro` 与 `Expert` 会尝试分钟 K |
164
- | `mxSearchApiUrl` | 否 | 妙想 Skills 接口地址 |
165
- | `mxSearchApiKey` | 否 | 启用 `mx_search` / `mx_select_stock`,也用于非 Expert 财务链路的 lite 回退 |
166
- | `llmBaseUrl` | 否 | OpenAI 兼容接口地址 |
167
- | `llmApiKey` | 是 | 大模型 API Key;使用本地模型时也不能留空,可填占位值 |
168
- | `llmModel` | 是 | 分析使用的模型名 |
169
- | `databasePath` | 是 | LanceDB 数据目录,建议正式环境用绝对路径 |
170
- | `calendarFile` | 是 | 交易日历文件路径,建议正式环境用绝对路径 |
171
- | `requestInterval` | 否 | 实时监控轮询间隔,默认 `30` 秒 |
172
- | `dailyUpdateNotify` | 否 | 是否发送定时日更与定时复盘通知,默认 `true` |
173
- | `alertChannel` | 是 | 告警通道,如 `telegram`、`qqbot`(QQ机器人)、`wecom`(企业微信)、`weixin`(微信) |
174
- | `openclawCliBin` | 否 | `openclaw` 可执行文件路径,默认 `openclaw` |
175
- | `alertAccount` | 否 | 多账号通道使用;QQBot / WeCom 常见为 `default` |
176
- | `alertTarget` | 是 | 告警投递目标,写法随通道而不同 |
177
- | `pythonBin` | 否 | Python 子模块启动命令,默认 `uv` |
178
- | `pythonArgs` | 否 | Python 子模块命令参数,默认 ["run", "python"] |
179
- | `pythonWorkdir` | 是 | Python 子模块工作目录 |
180
-
181
- <details>
182
- <summary>进阶说明:正式配置、本地调试配置与 Agent Tools</summary>
183
-
184
- 正式插件链路与本地 CLI 链路是两套独立配置:
185
-
186
- - OpenClaw 对话读取 `~/.openclaw/openclaw.json`
187
- - `npm run tool -- ...` 与本地 loop 读取 `local.config.json.plugin`
188
- - 它们不会自动同步;如果两边都要用,建议至少保持 `tickflowApiKey`、`llmBaseUrl`、`llmApiKey`、`llmModel`、`databasePath`、`calendarFile`、`alertChannel`、`alertAccount`、`alertTarget` 一致
189
-
190
- 如果你给股票 Agent 显式配置 `tools`,推荐保留 `profile: "full"`,不要额外禁用 `exec`、`read`、`write` 等运行时能力。
191
-
192
- 从 `0.2.0` 起,以下 TickFlow Assist agent tools 按 OpenClaw 官方建议以 optional 注册:
193
-
194
- - `add_stock`
195
- - `remove_stock`
196
- - `refresh_watchlist_names`
197
- - `refresh_watchlist_profiles`
198
- - `start_monitor`
199
- - `stop_monitor`
200
- - `start_daily_update`
201
- - `stop_daily_update`
202
- - `update_all`
203
- - `test_alert`
204
-
205
- 如果你给 Agent 配了 `tools.allow`,请把插件 id `tickflow-assist` 或上面的具体工具名加入允许列表;否则这些 optional tools 不会自动出现在对话可调用工具集中。插件 Slash Command 不受这个 allowlist 影响。
206
-
207
- 多 Agent 场景示例:
208
-
209
- ```json5
210
- {
211
- "agents": {
212
- "list": [
213
- {
214
- "id": "stock",
215
- "tools": {
216
- "profile": "full",
217
- "allow": ["tickflow-assist"],
218
- "deny": []
219
- }
220
- }
221
- ]
222
- }
223
- }
224
- ```
225
-
226
- 单 Agent 默认模式示例:
227
-
228
- ```json5
229
- {
230
- "tools": {
231
- "profile": "full",
232
- "allow": ["tickflow-assist"],
233
- "deny": []
234
- }
235
- }
236
- ```
237
-
238
- 修改配置后建议执行:
239
-
240
- ```bash
241
- openclaw config validate
242
- openclaw gateway restart
243
- ```
244
-
245
- </details>
246
-
247
- ## 6. 消息通道配置(可选)
248
-
249
- TickFlow Assist 当前通过 `openclaw message send` 投递告警,因此前提是目标通道本身已经能在 OpenClaw 中正常工作。
250
-
251
- 统一接入步骤:
252
-
253
- 1. 在 OpenClaw 里安装并配置目标通道。
254
- 2. 在插件配置里填写 `alertChannel`、`alertAccount`、`alertTarget`。
255
- 3. 重启 Gateway。
256
- 4. 执行一次 `test_alert` 验证链路。
257
-
258
- 识别 `alertTarget` 的通用方法:
259
-
260
- - 如果目标通道支持 `/whoami`,优先在目标会话里给机器人发送 `/whoami`。
261
- - 直接读取返回的 `User id`、`chatId` 或其它会话标识。
262
- - 再按对应通道的 target 格式写入 `alertTarget`。
263
- - 如果该通道没有 `/whoami`,再查看官方项目说明或插件日志。
264
-
265
- 通道差异速查:
266
-
267
- | 通道 | 官方项目 / 接入方式 | `alertAccount` | `alertTarget` 示例 | 说明 |
268
- |---|---|---|---|---|
269
- | `telegram` | `openclaw channels add --channel telegram` | 通常留空 | `-1001234567890` | 直接使用群组 / 会话 ID |
270
- | `discord` | `openclaw channels add --channel discord` | 通常留空 | `user:1234567890` | 优先在目标会话发送 `/whoami`,读取 `User id`,拼装成 `user:User id` |
271
- | `qqbot`(QQ机器人) | [@tencent-connect/openclaw-qqbot](https://www.npmjs.com/package/@tencent-connect/openclaw-qqbot) | 推荐 `default` | `qqbot:c2c:YOUR_OPENID` | 优先在目标会话发送 `/whoami`,读取 `User id` |
272
- | `wecom`(企业微信) | [@wecom/wecom-openclaw-plugin](https://www.npmjs.com/package/@wecom/wecom-openclaw-plugin) | 常见为 `default` | `YOUR_USER_ID_OR_CHAT_ID` | 优先在目标会话发送 `/whoami`,再区分单聊 `userId` / 群聊 `chatId` |
273
- | `weixin`(微信) | [@tencent-weixin/openclaw-weixin](https://www.npmjs.com/package/@tencent-weixin/openclaw-weixin) | 视插件配置 | `YOUR_TARGET` | 预留通道,当前 TickFlow Assist 尚未做专门适配,建议先用 `test_alert` 验证 |
274
-
275
- 配置示例:
276
-
277
- ```json5
278
- {
279
- "alertChannel": "qqbot",
280
- "alertAccount": "default",
281
- "alertTarget": "qqbot:c2c:YOUR_OPENID"
282
- }
283
- ```
284
-
285
- 如果你同时使用 `npm run tool -- test_alert` 做本地调试,记得把同样的通道字段也写进 `local.config.json.plugin`。
286
-
287
- <details>
288
- <summary>QQBot 补充</summary>
289
-
290
- 官方项目:[@tencent-connect/openclaw-qqbot](https://www.npmjs.com/package/@tencent-connect/openclaw-qqbot)
291
-
292
- - 先按官方项目完成安装与通道接入,再回到 TickFlow Assist 填写 `alertChannel: "qqbot"`、`alertAccount: "default"`、`alertTarget: "qqbot:c2c:YOUR_OPENID"`。
293
- - 私聊场景常用 target 格式为 `qqbot:c2c:YOUR_OPENID`。
294
- - target 获取方式沿用上面的通用 `/whoami` 说明;如果当前版本没有该命令,再查看官方说明或插件日志。
295
-
296
- </details>
297
-
298
- <details>
299
- <summary>WeCom 补充</summary>
300
-
301
- 官方项目:[@wecom/wecom-openclaw-plugin](https://www.npmjs.com/package/@wecom/wecom-openclaw-plugin)
302
-
303
- - 先按官方项目完成安装与通道接入,再回到 TickFlow Assist 填写 `alertChannel: "wecom"`、`alertAccount` 和 `alertTarget`。
304
- - `alertTarget` 单聊填写 `userId`;群聊填写 `chatId`。
305
- - target 获取方式沿用上面的通用 `/whoami` 说明;如果当前版本没有该命令,再查看官方说明。
306
-
307
- </details>
308
-
309
- <details>
310
- <summary>Weixin 补充</summary>
311
-
312
- 官方项目:[@tencent-weixin/openclaw-weixin](https://www.npmjs.com/package/@tencent-weixin/openclaw-weixin)
313
-
314
- - 当前 TickFlow Assist 还没有针对 `weixin` 做专门适配。
315
- - 当前实测中,`@tencent-weixin/openclaw-weixin` 通过 `openclaw message send` 主动发送时仍可能要求额外的 `contextToken`;因此即使已拿到 `alertTarget`,`test_alert`、监控告警、日更通知也仍可能失败。
316
- - 如果出现 `sendWeixinOutbound: contextToken is required`,说明当前版本暂时不适合作为 TickFlow Assist 的后台主动告警通道,建议先仅将微信作为 OpenClaw 对话入口使用,待官方插件后续更新后再启用主动告警推送。
317
- - 建议先执行一次 `test_alert`,确认当前插件版本与目标链路是否兼容。
318
-
319
- </details>
320
-
321
- ## 7. 运维与日常管理
322
-
323
- ### 7.1 重启与验收
324
-
325
- 完成安装或修改配置后,建议按下面顺序做一次验收:
326
-
327
- ```bash
328
- openclaw plugins info tickflow-assist
329
- openclaw plugins doctor
330
- openclaw config validate
331
- openclaw gateway restart
332
- openclaw channels status --probe
333
- ```
334
-
335
- 然后验证告警链路:
336
-
337
- ```bash
338
- npm run tool -- test_alert
339
- ```
340
-
341
- 或者直接在 OpenClaw 对话里发送“测试告警”。
342
-
343
- ### 7.2 升级
344
-
345
- 推荐继续使用安装向导,在菜单里选择“升级”。
346
-
347
- 从 `v0.1.0` 升到 `v0.2.0` 时,默认也走这条直接升级路径即可;不需要先卸载。
348
-
349
- 如果你更喜欢手动更新:
350
-
351
- ```bash
352
- cd /path/to/tickflow-assist
353
- git pull
354
- npm install
355
- cd python
356
- uv sync
357
- cd ..
358
- npm run check
359
- npm run build
360
- openclaw plugins install -l /path/to/tickflow-assist
361
- openclaw plugins enable tickflow-assist
362
- openclaw gateway restart
363
- ```
364
-
365
- ### 7.3 禁用、重装与清理
366
-
367
- 禁用插件:
368
-
369
- ```bash
370
- openclaw plugins disable tickflow-assist
371
- openclaw gateway restart
372
- ```
373
-
374
- 如果不再需要插件配置,再从 `~/.openclaw/openclaw.json` 删除:
375
-
376
- ```text
377
- plugins.entries["tickflow-assist"]
378
- ```
379
-
380
- 重新安装通常只在这两类场景需要:
381
-
382
- - 你要更换插件源码目录
383
- - OpenClaw 里残留了旧的同名安装来源,直接升级后仍指向错误路径
384
-
385
- 确实需要重装时再执行:
386
-
387
- ```bash
388
- openclaw plugins install -l /path/to/tickflow-assist
389
- openclaw plugins enable tickflow-assist
390
- openclaw gateway restart
391
- ```
392
-
393
- 如果你是为了“从零开始测试”,可按需手动删除 `/path/to/tickflow-assist/data/lancedb`。这只会清空本地数据库,不会删除源码。
package/docs/usage.md DELETED
@@ -1,244 +0,0 @@
1
- # TickFlow Assist 使用指南
2
-
3
- 本文档聚焦于日常使用、调试入口与关键运行规则。安装与配置请参阅 [安装指南](installation.md)。项目概览请先看 [README](../README.md)。
4
-
5
- ## 1. 使用入口
6
-
7
- | 入口 | 适合场景 | 说明 |
8
- |---|---|---|
9
- | OpenClaw 对话 | 日常使用 | 直接用自然语言操作自选、分析、监控和数据库查询 |
10
- | `/ta_` Slash Command | 零歧义操作 | 插件直接处理,不经过 AI 推理 |
11
- | `npm run tool -- ...` / loop | 本地调试、VPS 直连 | 读取 `local.config.json.plugin`,适合排障和脚本化调用 |
12
-
13
- ## 2. 对话常用指令
14
-
15
- 下面的说法是推荐示例,不要求逐字一致;表达清楚股票代码和动作即可。
16
-
17
- ### 自选管理
18
-
19
- | 指令示例 | 功能 |
20
- |---|---|
21
- | `添加 002261` | 添加股票到关注列表,成本价可后续补充 |
22
- | `添加 002261 成本 34.15` | 添加股票并记录成本价 |
23
- | `查看关注列表` | 查看当前自选、名称与成本价 |
24
- | `删除 002261` | 从关注列表移除股票 |
25
- | `刷新自选股名称` | 批量刷新关注股票名称 |
26
-
27
- ### 数据获取与检索
28
-
29
- | 指令示例 | 功能 |
30
- |---|---|
31
- | `更新 002261 数据` | 抓取最新日 K 并重算日线指标 |
32
- | `获取 002261 1m 分钟K` | 抓取分钟 K 并写入数据库 |
33
- | `搜索立讯精密最新研报` | 搜索资讯、公告、研报或事件解读 |
34
- | `找今日涨幅 2% 的股票` | 用自然语言条件执行智能选股 |
35
-
36
- ### 分析与复盘
37
-
38
- | 指令示例 | 功能 |
39
- |---|---|
40
- | `分析 002261` | 执行综合分析,汇总技术面、财务面和资讯面 |
41
- | `查看 002261 上次分析` | 回看最近一次综合分析 |
42
- | `查看 002261 最近 3 次综合分析` | 回看最近几次综合分析 |
43
- | `查看 002261 技术面分析` | 回看最近一次技术面结果 |
44
- | `查看 002261 基本面分析` | 回看最近一次财务面结果 |
45
- | `查看 002261 资讯面分析` | 回看最近一次资讯面结果 |
46
- | `回测 002261 最近 5 次关键位快照` | 回测关键价位快照的命中情况 |
47
-
48
- 如需查看更多历史,也可以直接说“查看 002261 最近 3 次技术面分析”“查看 002261 最近 3 次资讯面分析”。
49
-
50
- ### 后台维护与排障
51
-
52
- | 指令示例 | 功能 |
53
- |---|---|
54
- | `开始监控` | 启动实时监控 |
55
- | `监控状态` | 查看监控状态、最新行情与关键价位覆盖情况 |
56
- | `启动定时日更` | 启动项目自管的定时日更进程 |
57
- | `TickFlow日更状态` | 查看日更进程状态与最近执行结果 |
58
- | `停止定时日更` | 停止日更进程 |
59
- | `停止监控` | 停止实时监控 |
60
- | `测试告警` | 验证 OpenClaw channel 投递链路 |
61
- | `使用帮助` | 查看插件常用指令 |
62
- | `数据库里有哪些表` | 查看 LanceDB 当前数据表 |
63
- | `看技术指标表结构` | 查看数据库表字段结构 |
64
- | `查 002261 最近 5 条技术指标` | 查询数据库中的最近记录 |
65
-
66
- ## 3. Slash Commands
67
-
68
- 插件当前注册了 17 个 `/ta_` 直达命令,适合“添加自选”“查状态”“发测试告警”这类不需要模型解释的操作。
69
-
70
- ### 自选管理
71
-
72
- | 命令 | 说明 |
73
- |---|---|
74
- | `/ta_addstock <symbol> [costPrice] [count]` | 添加自选,并抓取默认 90 天日 K |
75
- | `/ta_rmstock <symbol>` | 删除自选 |
76
- | `/ta_watchlist` | 查看自选列表 |
77
- | `/ta_refreshnames` | 刷新股票名称 |
78
- | `/ta_refreshprofiles [symbol]` | 刷新行业分类与概念板块 |
79
-
80
- ### 分析与复盘
81
-
82
- | 命令 | 说明 |
83
- |---|---|
84
- | `/ta_analyze <symbol>` | 直接执行综合分析 |
85
- | `/ta_viewanalysis <symbol>` | 查看最近一次综合分析 |
86
- | `/ta_backtest [symbol] [recentLimit]` | 回测活动关键价位快照,可按股票与最近次数过滤 |
87
-
88
- ### 后台维护与调试
89
-
90
- | 命令 | 说明 |
91
- |---|---|
92
- | `/ta_startmonitor` | 启动实时监控 |
93
- | `/ta_stopmonitor` | 停止实时监控 |
94
- | `/ta_monitorstatus` | 查看监控状态 |
95
- | `/ta_startdailyupdate` | 启动定时日更 |
96
- | `/ta_stopdailyupdate` | 停止定时日更 |
97
- | `/ta_updateall` | 立即执行一次完整日更 |
98
- | `/ta_dailyupdatestatus` | 查看定时日更状态 |
99
- | `/ta_testalert` | 发送一条测试告警 |
100
- | `/ta_debug` | 查看插件进程当前看到的配置来源、数据库路径与 watchlist 快照 |
101
-
102
- 常用示例:
103
-
104
- ```text
105
- /ta_addstock 601872
106
- /ta_addstock 002261 34.15
107
- /ta_watchlist
108
- /ta_analyze 002261
109
- /ta_viewanalysis 002261
110
- /ta_backtest 002261 5
111
- /ta_startmonitor
112
- /ta_monitorstatus
113
- /ta_dailyupdatestatus
114
- /ta_testalert
115
- ```
116
-
117
- 使用提示:
118
-
119
- - `/ta_addstock` 的第二个参数是 `costPrice`,第三个参数才是日 K 数量;如果只写两个参数,第二个数字会被当作成本价。
120
- - `/ta_viewanalysis` 只看最近一次综合分析;如果你要看技术面、资讯面或最近 N 次历史,优先用自然语言或 CLI 的 `view_analysis`。
121
- - `/ta_backtest` 不带参数时会输出整体回测概览,带 `symbol` 和 `recentLimit` 时会更聚焦。
122
- - `/ta_debug` 适合排查“OpenClaw 对话能看到的状态”和“CLI 看到的状态”不一致的问题。
123
-
124
- ## 4. CLI 与本地直连调试
125
-
126
- `npm run tool -- ...`、`npm run monitor-loop` 与 `npm run daily-update-loop` 读取的是项目根目录 `local.config.json` 的 `plugin` 字段,不会回退到 `~/.openclaw/openclaw.json`。
127
-
128
- 推荐配置结构:
129
-
130
- ```json
131
- {
132
- "plugin": {
133
- "tickflowApiUrl": "https://api.tickflow.org",
134
- "tickflowApiKey": "sk-xxx",
135
- "mxSearchApiUrl": "https://mkapi2.dfcfs.com/finskillshub/api/claw",
136
- "mxSearchApiKey": "mkt_xxx",
137
- "llmBaseUrl": "https://api.openai.com/v1",
138
- "llmApiKey": "sk-xxx",
139
- "llmModel": "gpt-4o",
140
- "databasePath": "./data/lancedb",
141
- "calendarFile": "./day_future.txt",
142
- "requestInterval": 30,
143
- "alertChannel": "telegram",
144
- "openclawCliBin": "openclaw",
145
- "alertAccount": "",
146
- "alertTarget": "YOUR_TARGET",
147
- "pythonBin": "uv",
148
- "pythonArgs": ["run", "python"],
149
- "pythonWorkdir": "./python"
150
- }
151
- }
152
- ```
153
-
154
- ### 常用命令
155
-
156
- 基础验证:
157
-
158
- ```bash
159
- npm run tool -- test_alert
160
- npm run tool -- add_stock '{"symbol":"002261","costPrice":34.154}'
161
- npm run tool -- fetch_klines '{"symbol":"002261","count":90}'
162
- npm run tool -- fetch_intraday_klines '{"symbol":"002261","period":"1m","count":240}'
163
- npm run tool -- analyze '{"symbol":"002261"}'
164
- ```
165
-
166
- 分析回看与检索:
167
-
168
- ```bash
169
- npm run tool -- view_analysis '{"symbol":"002261"}'
170
- npm run tool -- view_analysis '{"symbol":"002261","limit":3}'
171
- npm run tool -- view_analysis '{"symbol":"002261","profile":"technical","limit":3}'
172
- npm run tool -- backtest_key_levels '{"symbol":"002261","recentLimit":5}'
173
- npm run tool -- mx_search '{"query":"立讯精密最新研报","limit":5}'
174
- npm run tool -- mx_select_stock '{"keyword":"今日涨幅2%的股票","pageNo":1,"pageSize":20}'
175
- ```
176
-
177
- 后台与循环:
178
-
179
- ```bash
180
- npm run tool -- start_monitor
181
- npm run tool -- monitor_status
182
- npm run tool -- stop_monitor
183
- npm run tool -- start_daily_update
184
- npm run tool -- daily_update_status
185
- npm run tool -- stop_daily_update
186
- npm run tool -- update_all
187
- npm run monitor-loop
188
- npm run daily-update-loop
189
- ```
190
-
191
- ## 5. 运行规则与关键机制
192
-
193
- ### 监控告警阈值
194
-
195
- | 告警类型 | 触发条件 | 说明 |
196
- |---|---|---|
197
- | 止损告警 | `价格 <= 止损位` | 触及止损位 |
198
- | 止损预警 | `价格 <= 止损位 × 1.005` | 接近止损位 |
199
- | 突破告警 | `价格 >= 突破位` | 突破关键压力位 |
200
- | 支撑告警 | `价格 <= 支撑位 × 1.005` | 接近支撑位 |
201
- | 压力告警 | `价格 >= 压力位 × 0.995` | 接近压力位 |
202
- | 止盈告警 | `价格 >= 止盈位` | 达到止盈位 |
203
- | 涨跌幅异动 | `绝对涨跌幅 >= 5%` | 基于昨收计算 |
204
- | 成交量异动 | `当前量 >= 5 日均量 × 3` | 放量异动 |
205
-
206
- ### 数据来源与降级逻辑
207
-
208
- | 场景 | 当前行为 |
209
- |---|---|
210
- | `analyze` | 读取本地日 K、日线指标,并临时补充分钟 K、分钟指标、实时行情和历史复盘摘要 |
211
- | 财务面(Expert) | 优先使用 TickFlow 完整财务快照 |
212
- | 财务面(非 Expert / TickFlow 完整财务失败) | 回退到 `mx_select_stock` 的 lite 指标链路 |
213
- | 财务面仍不可用 | 财务子任务返回降级结果,但综合分析继续执行 |
214
- | 资讯面不可用 | 资讯子任务返回降级结果,但综合分析继续执行 |
215
- | 分钟 K 保留策略 | `analyze` / `update_all` 会保留近 30 个交易日;单独执行 `fetch_intraday_klines` 会保留近 10 个交易日 |
216
-
217
- ### 后台运行规则
218
-
219
- | 项目 | 说明 |
220
- |---|---|
221
- | 实时监控时段 | `09:30-11:30`、`13:00-15:00` |
222
- | 阶段通知 | 上午开盘、上午收盘、下午开盘、当日收盘各发送一次 |
223
- | `update_all` | 面向收盘后手动补跑流程,会先执行日更,再立即执行一次复盘 |
224
- | 定时日更轮询 | 按 15 分钟对齐轮询,交易日 `15:25` 后最多执行一次 |
225
- | 定时收盘复盘轮询 | 按 15 分钟对齐轮询,交易日 `20:00` 后最多执行一次 |
226
- | `monitor_status` | 显示运行方式、最近心跳、最新行情与关键位覆盖情况 |
227
- | `daily_update_status` | 显示运行方式、配置来源、最近心跳,以及日更/复盘两类最近执行结果 |
228
-
229
- ## 6. 主要数据表
230
-
231
- | 表名 | 用途 |
232
- |---|---|
233
- | `watchlist` | 自选列表、成本价、行业分类、概念板块 |
234
- | `klines_daily` | 日 K 数据 |
235
- | `klines_intraday` | 分钟 K 数据 |
236
- | `indicators` | 技术指标 |
237
- | `key_levels` / `key_levels_history` | 当前关键价位与历史快照 |
238
- | `technical_analysis` / `financial_analysis` / `news_analysis` / `composite_analysis` | 多维分析结果 |
239
- | `analysis_log` / `alert_log` | 分析日志与告警留痕 |
240
-
241
- ## 7. 高优先级注意事项
242
-
243
- - 正式插件读取 `~/.openclaw/openclaw.json`;CLI 与本地 loop 读取 `local.config.json.plugin`,两者不会自动同步。
244
- - 未配置 `mxSearchApiKey` 时,`mx_search` / `mx_select_stock` 不可用,非 Expert 财务链路的 lite 回退也会失效。