openclaw-stock-analysis 0.2.1 → 0.2.5
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/LICENSE +21 -0
- package/README.md +2 -2
- package/dist/index.js +170 -23
- package/index.ts +184 -26
- package/openclaw.plugin.json +10 -1
- package/package.json +1 -1
- package/scripts/ci-resolve-llm-host.mjs +29 -0
- package/scripts/setup-python.mjs +7 -9
- package/skills/event-driven/SKILL.md +6 -0
- package/skills/growth-quality/SKILL.md +6 -0
- package/skills/hot-theme/SKILL.md +3 -2
- package/skills/stock-analysis/SKILL.md +22 -0
- package/skills/stock-screener/SKILL.md +19 -1
- package/skills/strategy-backtest/SKILL.md +11 -5
- package/strategies/examples/bottom_volume.yaml +5 -0
- package/strategies/examples/box_oscillation.yaml +5 -0
- package/strategies/examples/bull_trend.yaml +11 -3
- package/strategies/examples/dragon_head.yaml +4 -2
- package/strategies/examples/emotion_cycle.yaml +5 -0
- package/strategies/examples/ma_crossover.yaml +10 -3
- package/strategies/examples/rsi_oversold.yaml +5 -0
- package/strategies/examples/shrink_pullback.yaml +7 -1
- package/strategies/examples/volume_breakout.yaml +7 -1
- package/tools/_cache.py +61 -0
- package/tools/_subproc.py +49 -0
- package/tools/alert_rules.py +19 -9
- package/tools/anomaly_detect.py +24 -35
- package/tools/backtest.py +180 -100
- package/tools/capabilities.py +13 -5
- package/tools/diagnostics.py +12 -6
- package/tools/gather.py +13 -9
- package/tools/import_parser.py +2 -5
- package/tools/market_regime.py +27 -35
- package/tools/market_review.py +56 -9
- package/tools/name_resolver.py +2 -5
- package/tools/pattern.py +2 -5
- package/tools/position_context.py +2 -5
- package/tools/report_renderer.py +10 -6
- package/tools/requirements.txt +2 -1
- package/tools/risk_screening.py +29 -23
- package/tools/screener.py +80 -18
- package/tools/search_intel.py +5 -13
- package/tools/signal_tracker.py +2 -6
- package/tools/stock_data.py +612 -177
- package/tools/technical.py +136 -40
- package/tools/trading_calendar.py +78 -18
- package/tools/value_data.py +1368 -0
- package/tools/volume_analysis.py +2 -5
- package/tools/watchlist.py +2 -5
- package/tools/watchlist_context.py +2 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Weaxs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Stock Analysis — OpenClaw Plugin
|
|
2
2
|
|
|
3
|
-
A股 / 港股 / 美股 / 日股 / 韩股 / 台股 行情、技术分析、筛选与回测。OpenClaw Gateway 加载后即可在对话中调用
|
|
3
|
+
A股 / 港股 / 美股 / 日股 / 韩股 / 台股 行情、技术分析、筛选与回测。OpenClaw Gateway 加载后即可在对话中调用 51 个工具。
|
|
4
4
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
@@ -17,7 +17,7 @@ npm install
|
|
|
17
17
|
|
|
18
18
|
### Python 运行时
|
|
19
19
|
|
|
20
|
-
工具实际逻辑在 `tools/*.py`,依赖 `akshare`、`pandas`、`numpy`、`requests`。仓库根 `package.json` 的 postinstall(`scripts/setup-python.mjs`)会自动建 `.venv` 并装好依赖,无需手工操作。前提:本机有 `python3 >= 3.
|
|
20
|
+
工具实际逻辑在 `tools/*.py`,依赖 `akshare`、`pandas`、`numpy`、`requests`。仓库根 `package.json` 的 postinstall(`scripts/setup-python.mjs`)会自动建 `.venv` 并装好依赖,无需手工操作。前提:本机有 `python3 >= 3.10`。
|
|
21
21
|
|
|
22
22
|
如果 venv 没建起来(比如 Python 缺失),plugin 会回退到系统 `python3`,请自行 `pip install -r tools/requirements.txt`。
|
|
23
23
|
|
package/dist/index.js
CHANGED
|
@@ -4436,19 +4436,9 @@ function __setExecutor(fn) {
|
|
|
4436
4436
|
}
|
|
4437
4437
|
var here = dirname(fileURLToPath(import.meta.url));
|
|
4438
4438
|
var toolsDir = existsSync(join(here, "tools")) ? join(here, "tools") : join(here, "..", "tools");
|
|
4439
|
-
var
|
|
4439
|
+
var fallbackRoot = dirname(toolsDir);
|
|
4440
4440
|
var isWin = process.platform === "win32";
|
|
4441
4441
|
var venvBin = join(".venv", isWin ? "Scripts" : "bin", isWin ? "python.exe" : "python3");
|
|
4442
|
-
var venvPython = join(repoRoot, venvBin);
|
|
4443
|
-
var parentVenvPython = join(repoRoot, "..", venvBin);
|
|
4444
|
-
function pythonBin() {
|
|
4445
|
-
if (existsSync(venvPython)) return venvPython;
|
|
4446
|
-
if (existsSync(parentVenvPython)) return parentVenvPython;
|
|
4447
|
-
return isWin ? "python" : "python3";
|
|
4448
|
-
}
|
|
4449
|
-
async function runPy(script, args) {
|
|
4450
|
-
return executor(pythonBin(), [join(toolsDir, script), ...args]);
|
|
4451
|
-
}
|
|
4452
4442
|
function asText(text) {
|
|
4453
4443
|
return { content: [{ type: "text", text }] };
|
|
4454
4444
|
}
|
|
@@ -4457,9 +4447,97 @@ var index_default = definePluginEntry({
|
|
|
4457
4447
|
name: "Stock Analysis",
|
|
4458
4448
|
description: "Stock analysis, screening, and strategy backtesting across A/HK/US/JP/KR/TW markets",
|
|
4459
4449
|
register(api) {
|
|
4450
|
+
const repoRoot = api.rootDir || fallbackRoot;
|
|
4451
|
+
const pythonBin = () => {
|
|
4452
|
+
const venvPython = join(repoRoot, venvBin);
|
|
4453
|
+
if (existsSync(venvPython)) return venvPython;
|
|
4454
|
+
const parentVenvPython = join(repoRoot, "..", venvBin);
|
|
4455
|
+
if (existsSync(parentVenvPython)) return parentVenvPython;
|
|
4456
|
+
return isWin ? "python" : "python3";
|
|
4457
|
+
};
|
|
4458
|
+
const runPy = (script, args) => executor(pythonBin(), [join(toolsDir, script), ...args]);
|
|
4459
|
+
api.registerTool({
|
|
4460
|
+
name: "get_valuation_history",
|
|
4461
|
+
description: "\u67E5\u8BE2A/HK\u80A1\u7968\u5386\u53F2 PE-TTM/PB\u3001\u5F53\u524D\u6B63\u503C\u5206\u4F4D\u548C10/25/50/75/90\u5206\u4F4D Band\uFF0C\u8FD4\u56DE\u5B9E\u9645\u91C7\u6837\u533A\u95F4\uFF1B\u4E8F\u635F\u4F30\u503C\u5206\u4F4D\u4E3Anull\u3002years=1..10\uFF0C\u6570\u636E\u6309\u5929\u7F13\u5B58\u3002",
|
|
4462
|
+
parameters: typebox_exports.Object({
|
|
4463
|
+
symbol: typebox_exports.String({ description: "A\u80A1\u4EE3\u7801\u6216\u6E2F\u80A1.HK\u4EE3\u7801" }),
|
|
4464
|
+
years: typebox_exports.Optional(typebox_exports.Number({ description: "\u5386\u53F2\u7A97\u53E3\u5E74\u65701..10\uFF0C\u9ED8\u8BA45" }))
|
|
4465
|
+
}),
|
|
4466
|
+
async execute(_id, p) {
|
|
4467
|
+
const out = await runPy("value_data.py", ["valuation_history", p.symbol, "--years", String(p.years ?? 5)]);
|
|
4468
|
+
return asText(out);
|
|
4469
|
+
}
|
|
4470
|
+
});
|
|
4471
|
+
api.registerTool({
|
|
4472
|
+
name: "get_index_valuation",
|
|
4473
|
+
description: "\u67E5\u8BE2\u4E2D\u56FD\u6307\u6570\u4F30\u503C\u5386\u53F2\u5206\u4F4D\u4E0EBand\uFF1B\u4E50\u5495\u4E50\u80A1PE/PB\u4F18\u5148\uFF0C\u4E2D\u8BC1\u5B98\u65B9\u5386\u53F2\u8865\u5145\u6EDA\u52A8PE\u5E76\u4FDD\u7559\u8FD1\u671FPE1\u53E3\u5F84\u3002\u7F3APB\u65F6\u53EF\u7528LIXINGER_TOKEN\u8865\u5145\u7406\u674F\u4EC1mcw\u5386\u53F2\uFF0C\u6765\u6E90\u4E0E\u7B97\u6CD5\u5206\u522B\u6807\u660E\uFF0C\u4E0D\u6DF7\u63A5\u540C\u4E00\u6307\u6807\u3002",
|
|
4474
|
+
parameters: typebox_exports.Object({
|
|
4475
|
+
symbol: typebox_exports.String({ description: "\u6307\u6570\u4EE3\u7801\u6216\u540D\u79F0\uFF0C\u5982000300\u3001\u6CAA\u6DF1300\u3001000985" }),
|
|
4476
|
+
years: typebox_exports.Optional(typebox_exports.Number({ description: "\u5386\u53F2\u7A97\u53E3\u5E74\u65701..10\uFF0C\u9ED8\u8BA45" }))
|
|
4477
|
+
}),
|
|
4478
|
+
async execute(_id, p) {
|
|
4479
|
+
const out = await runPy("value_data.py", ["index_valuation", p.symbol, "--years", String(p.years ?? 5)]);
|
|
4480
|
+
return asText(out);
|
|
4481
|
+
}
|
|
4482
|
+
});
|
|
4483
|
+
api.registerTool({
|
|
4484
|
+
name: "get_earnings_calendar",
|
|
4485
|
+
description: "\u67E5\u8BE2\u8D22\u62A5\u65E5\u5386\uFF1AA\u80A1report_date\u5FC5\u586B\u5B63\u5EA6\u671F\u672B\uFF0C\u8FD4\u56DE\u9884\u7EA6/\u4FEE\u8BA2/\u5B9E\u9645\u62AB\u9732\u4E0E\u4E1A\u7EE9\u9884\u544A\uFF1BHK\u9700symbol\uFF0C\u4F18\u5148HKEX\u5DF2\u516C\u544A\u4E1A\u7EE9\u5BA1\u6279\u8463\u4E8B\u4F1A\u6392\u671F\uFF08\u4E0D\u662F\u5B9E\u9645\u62AB\u9732\u65E5\uFF09\uFF0C\u7F3A\u5931\u65F6\u8FD4\u56DE\u4F9B\u5E94\u5546\u65E5\u671F\u3002HK\u53EF\u6309\u5DF2\u77E5\u8D22\u653F\u671F\u672B\u8FC7\u6EE4\uFF0C\u672A\u77E5\u671F\u6B21\u53E6\u5217\u3002",
|
|
4486
|
+
parameters: typebox_exports.Object({
|
|
4487
|
+
report_date: typebox_exports.Optional(typebox_exports.String({ description: "A\u80A1\u5FC5\u586B\u5B63\u5EA6\u671F\u672BYYYY-MM-DD\uFF1BHK\u53EF\u9009\u5DF2\u516C\u544A\u8D22\u653F\u671F\u672B\uFF0C\u672A\u77E5\u671F\u6B21\u53E6\u5217" })),
|
|
4488
|
+
symbol: typebox_exports.Optional(typebox_exports.String({ description: "A\u80A1\u4EE3\u7801\u53EF\u9009\uFF08\u7701\u7565\u67E5\u5168\u5E02\u573A\uFF09\uFF1BHK\u5FC5\u987B\u63D0\u4F9B\u6E2F\u80A1.HK\u4EE3\u7801" })),
|
|
4489
|
+
top: typebox_exports.Optional(typebox_exports.Number({ description: "\u6BCF\u7C7B\u6700\u591A\u8FD4\u56DE\u6761\u65701..500\uFF0C\u9ED8\u8BA450" }))
|
|
4490
|
+
}),
|
|
4491
|
+
async execute(_id, p) {
|
|
4492
|
+
const out = await runPy("value_data.py", ["earnings_calendar", "--report-date", p.report_date ?? "", "--symbol", p.symbol ?? "", "--top", String(p.top ?? 50)]);
|
|
4493
|
+
return asText(out);
|
|
4494
|
+
}
|
|
4495
|
+
});
|
|
4496
|
+
api.registerTool({
|
|
4497
|
+
name: "get_shareholder_structure",
|
|
4498
|
+
description: "\u67E5\u8BE2A\u80A1\u80A1\u4E1C\u6237\u6570\u3001\u5341\u5927\u6D41\u901A\u80A1\u4E1C\u53D8\u5316\u53CA\u6CAA\u6DF1\u4EA4\u6613\u6240\u5B63\u5EA6\u5317\u5411\u5408\u8BA1\u6301\u80A1\uFF1B\u5B98\u65B9\u603B\u91CF\u4F18\u5148\uFF0C\u5341\u5927HKSCC\u540D\u4E49\u6301\u80A1\u4EC5\u515C\u5E95\u4E14\u6807\u660E\u53E3\u5F84\u3002HK\u8FD4\u56DE\u6E2F\u4EA4\u6240\u5357\u5411\u8BB0\u5F55\u3002\u7F3A\u5931\u4E0D\u5F53\u96F6\uFF0C\u671F\u672B\u4E0D\u7B49\u4E8E\u5DF2\u516C\u5E03\u3002",
|
|
4499
|
+
parameters: typebox_exports.Object({
|
|
4500
|
+
symbol: typebox_exports.String({ description: "A\u80A1\u4EE3\u7801\u6216\u6E2F\u80A1.HK\u4EE3\u7801" }),
|
|
4501
|
+
report_date: typebox_exports.Optional(typebox_exports.String({ description: "A\u80A1\u62A5\u544A\u671FYYYY-MM-DD\uFF1B\u7701\u7565\u65F6\u5317\u5411\u4F7F\u7528\u6700\u65B0\u5DF2\u516C\u5E03\u5B63\u5EA6\uFF0C\u5341\u5927\u80A1\u4E1C\u4F7F\u7528\u6700\u65B0\u8D22\u62A5\u671F\uFF1BHK\u5FFD\u7565" }))
|
|
4502
|
+
}),
|
|
4503
|
+
async execute(_id, p) {
|
|
4504
|
+
const out = await runPy("value_data.py", ["shareholder_structure", p.symbol, "--report-date", p.report_date ?? ""]);
|
|
4505
|
+
return asText(out);
|
|
4506
|
+
}
|
|
4507
|
+
});
|
|
4508
|
+
api.registerTool({
|
|
4509
|
+
name: "get_etf_details",
|
|
4510
|
+
description: "\u67E5\u8BE2A\u80A1ETF\u51C0\u503C\u6298\u6EA2\u4EF7\u3001\u89C4\u6A21\u3001\u62AB\u9732\u6301\u4ED3\u53CA\u6CAA\u6DF1\u5B8C\u6574PCF\u7533\u8D4E\u7BEE\u5B50\uFF1B\u7BEE\u5B50\u4E0D\u662F\u5B9E\u9645\u6301\u4ED3\u3002include_full_holdings=true\u53E6\u53D6\u6700\u8FD1\u53EF\u5F97\u534A\u5E74\u5EA6/\u5E74\u5EA6\u62AB\u9732\u80A1\u7968\u8868\uFF0C\u542B\u6570\u91CF/\u5E02\u503C/\u62A5\u544A\u671F\uFF0C\u975E\u5B9E\u65F6\u5168\u8D44\u4EA7\u7EC4\u5408\uFF1Bbenchmark\u7528\u4E8E\u8DDF\u8E2A\u8BEF\u5DEE\u3002",
|
|
4511
|
+
parameters: typebox_exports.Object({
|
|
4512
|
+
include_full_holdings: typebox_exports.Optional(typebox_exports.Boolean({ description: "\u8BF7\u6C42\u534A\u5E74\u5EA6/\u5E74\u5EA6\u62AB\u9732\u80A1\u7968\u8868\uFF0C\u9ED8\u8BA4false" })),
|
|
4513
|
+
symbol: typebox_exports.String({ description: "A\u80A1ETF\u4EE3\u7801\uFF0C\u5982510300" }),
|
|
4514
|
+
benchmark: typebox_exports.Optional(typebox_exports.String({ description: "\u53EF\u9009\u57FA\u51C6\u4EE3\u7801\uFF0C\u5982sh000300\uFF1B\u4E0D\u731C\u6D4B\u57FA\u51C6" })),
|
|
4515
|
+
days: typebox_exports.Optional(typebox_exports.Number({ description: "\u51C0\u503C\u7A97\u53E3\u4EA4\u6613\u65E5\u657010..252\uFF0C\u9ED8\u8BA460" }))
|
|
4516
|
+
}),
|
|
4517
|
+
async execute(_id, p) {
|
|
4518
|
+
const out = await runPy("value_data.py", ["etf_details", p.symbol, "--benchmark", p.benchmark ?? "", "--days", String(p.days ?? 60), ...p.include_full_holdings ? ["--include-full-holdings"] : []]);
|
|
4519
|
+
return asText(out);
|
|
4520
|
+
}
|
|
4521
|
+
});
|
|
4522
|
+
api.registerTool({
|
|
4523
|
+
name: "get_dividends",
|
|
4524
|
+
description: "\u67E5\u8BE2A/HK\u5206\u7EA2\u5386\u53F2\u3001\u9664\u606F\u65E5\u5386\u3001\u5DF2\u5B9E\u65BDTTM\u80A1\u606F\u4E0E\u8FDE\u7EED\u5E74\u6570\u3002mode=ranking\u7701\u7565symbol\uFF0Cmarket=A\u67E5\u62A5\u544A\u671F\u6392\u884C\uFF0Cmarket=HK\u67E5HKEX/LSEG\u5E74\u5EA6\u80A1\u606F\u7387\u6392\u884C\uFF08report_date\u987B\u5E74\u672B\uFF09\uFF1B\u6392\u884C\u5747\u975E\u5F53\u524DTTM\u6536\u76CA\u7387\u3002\u7F3A\u5931\u4E0D\u6309\u96F6\u3002",
|
|
4525
|
+
parameters: typebox_exports.Object({
|
|
4526
|
+
market: typebox_exports.Optional(typebox_exports.Union([typebox_exports.Literal("A"), typebox_exports.Literal("HK")], { description: "\u4EC5ranking\u9009\u62E9\u5E02\u573A\uFF0C\u9ED8\u8BA4A" })),
|
|
4527
|
+
symbol: typebox_exports.Optional(typebox_exports.String({ description: "history/calendar\u5FC5\u586BA\u80A1\u6216\u6E2F\u80A1.HK\u4EE3\u7801\uFF1Branking\u7701\u7565" })),
|
|
4528
|
+
mode: typebox_exports.Optional(typebox_exports.Union([typebox_exports.Literal("history"), typebox_exports.Literal("calendar"), typebox_exports.Literal("ranking")], { description: "history\u9ED8\u8BA4\uFF1Bcalendar\u672A\u6765\u5DF2\u516C\u5E03\u9664\u606F\u4E8B\u4EF6\uFF1Branking\u6309market\u67E5\u8BE2A/HK\u6392\u884C" })),
|
|
4529
|
+
report_date: typebox_exports.Optional(typebox_exports.String({ description: "ranking\u62A5\u544A\u671FYYYY-MM-DD\uFF0C\u9ED8\u8BA4\u4E0A\u4E00\u5E74\u5E74\u672B\uFF1BHK\u4EC5\u5E74\u5EA6\u5E74\u672B\u65E5\u671F" })),
|
|
4530
|
+
years: typebox_exports.Optional(typebox_exports.Number({ description: "\u5386\u53F2\u7A97\u53E3\u5E74\u65701..20\uFF0C\u9ED8\u8BA410" })),
|
|
4531
|
+
top: typebox_exports.Optional(typebox_exports.Number({ description: "\u6392\u540D\u6761\u65701..500\uFF0C\u9ED8\u8BA420" }))
|
|
4532
|
+
}),
|
|
4533
|
+
async execute(_id, p) {
|
|
4534
|
+
const out = await runPy("value_data.py", ["dividends", "--market", p.market ?? "A", "--symbol", p.symbol ?? "", "--mode", p.mode ?? "history", "--report-date", p.report_date ?? "", "--years", String(p.years ?? 10), "--top", String(p.top ?? 20)]);
|
|
4535
|
+
return asText(out);
|
|
4536
|
+
}
|
|
4537
|
+
});
|
|
4460
4538
|
api.registerTool({
|
|
4461
4539
|
name: "get_kline",
|
|
4462
|
-
description: "\u83B7\u53D6\u80A1\u7968K\u7EBF\u6570\u636E\uFF08OHLCV\uFF09\u3002\u652F\u6301A\u80A1\uFF08\u5982600519\uFF09\u3001\u6E2F\u80A1\uFF08\u598200700.HK\uFF09\u3001\u7F8E\u80A1\uFF08\u5982AAPL\uFF09\u3001\u65E5\u80A1\uFF08\u59827203.T\uFF09\u3001\u97E9\u80A1\uFF08\u5982005930.KS\uFF09\u3001\u53F0\u80A1\uFF08\u59822330.TW\uFF09\u53CAA\u80A1ETF\
|
|
4540
|
+
description: "\u83B7\u53D6\u80A1\u7968K\u7EBF\u6570\u636E\uFF08OHLCV\uFF09\u3002\u652F\u6301A\u80A1\uFF08\u5982600519\uFF09\u3001\u6E2F\u80A1\uFF08\u598200700.HK\uFF09\u3001\u7F8E\u80A1\uFF08\u5982AAPL\uFF09\u3001\u65E5\u80A1\uFF08\u59827203.T\uFF09\u3001\u97E9\u80A1\uFF08\u5982005930.KS\uFF09\u3001\u53F0\u80A1\uFF08\u59822330.TW\uFF09\u53CAA\u80A1ETF\u3002A\u80A1\u80A1\u7968/ETF\u8FD4\u56DE\u524D\u590D\u6743\u4EF7\u683C\uFF0C\u6BCF\u6761\u8BB0\u5F55 adjusted=qfq\uFF1Bsh000xxx/sz399xxx \u6307\u6570\u8FD4\u56DE\u539F\u59CB\u70B9\u4F4D\uFF0Cadjusted=none\u3002\u9700\u8981\u5386\u53F2\u4EF7\u683C\u81EA\u884C\u8BA1\u7B97\u6216\u753B\u56FE\u65F6\u7528\uFF1B\u53EA\u95EE\u6307\u6807\u7528 get_technical_analysis\uFF0C\u53EA\u95EE\u73B0\u4EF7\u7528 get_quote",
|
|
4463
4541
|
parameters: typebox_exports.Object({
|
|
4464
4542
|
symbol: typebox_exports.String({
|
|
4465
4543
|
description: "\u80A1\u7968\u4EE3\u7801\uFF0C\u5982 600519\uFF08A\u80A1\uFF09\u300100700.HK\uFF08\u6E2F\u80A1\uFF09\u3001AAPL\uFF08\u7F8E\u80A1\uFF09\u30017203.T\uFF08\u65E5\u80A1\uFF09\u3001005930.KS\uFF08\u97E9\u80A1\uFF09\u30012330.TW\uFF08\u53F0\u80A1\uFF09"
|
|
@@ -4486,7 +4564,7 @@ var index_default = definePluginEntry({
|
|
|
4486
4564
|
});
|
|
4487
4565
|
api.registerTool({
|
|
4488
4566
|
name: "get_quote",
|
|
4489
|
-
description: "\u83B7\u53D6\u80A1\u7968\u5B9E\u65F6\u884C\u60C5\u62A5\u4EF7\uFF08\u73B0\u4EF7\u3001\u6DA8\u8DCC\u5E45\u3001\u91CF\u6BD4\u7B49\uFF09\u3002\u652F\u6301A\u80A1\u3001\u6E2F\u80A1\u3001\u7F8E\u80A1\u3001\u65E5\u80A1\u3001\u97E9\u80A1\u3001\u53F0\u80A1\uFF1B\u975E\u4EA4\u6613\u65F6\u6BB5\u8FD4\u56DE\u6700\u8FD1\u4EA4\u6613\u65E5\u6536\u76D8\u4EF7\u5E76\u4EE5 as_of/stale \u6807\u6CE8",
|
|
4567
|
+
description: "\u83B7\u53D6\u80A1\u7968\u5B9E\u65F6\u884C\u60C5\u62A5\u4EF7\uFF08\u73B0\u4EF7\u3001\u6DA8\u8DCC\u5E45\u3001\u91CF\u6BD4\u7B49\uFF09\u3002\u652F\u6301A\u80A1\u3001\u6E2F\u80A1\u3001\u7F8E\u80A1\u3001\u65E5\u80A1\u3001\u97E9\u80A1\u3001\u53F0\u80A1\uFF1B\u975E\u4EA4\u6613\u65F6\u6BB5\u8FD4\u56DE\u6700\u8FD1\u4EA4\u6613\u65E5\u6536\u76D8\u4EF7\u5E76\u4EE5 as_of/stale \u6807\u6CE8\uFF1BETF \u7684 premium_discount_rate \u4E3A\u6B63=\u6EA2\u4EF7\u3001\u8D1F=\u6298\u4EF7",
|
|
4490
4568
|
parameters: typebox_exports.Object({
|
|
4491
4569
|
symbol: typebox_exports.String({ description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" })
|
|
4492
4570
|
}),
|
|
@@ -4542,18 +4620,25 @@ var index_default = definePluginEntry({
|
|
|
4542
4620
|
});
|
|
4543
4621
|
api.registerTool({
|
|
4544
4622
|
name: "get_financials",
|
|
4545
|
-
description: "\u83B7\u53D6\u80A1\u7968\u8D22\u52A1\u6458\u8981\
|
|
4623
|
+
description: "\u83B7\u53D6\u80A1\u7968\u8D22\u52A1\u6458\u8981\u53CA\u5386\u53F2\u8D8B\u52BF\uFF0C\u6309\u5929\u7F13\u5B58\u3002A\u80A1\u8FD4\u56DEROE/\u6BDB\u5229\u7387/\u51C0\u5229\u7387\u7B49\uFF1Bannual=true\u4E0Eperiods=10\u53D6\u5341\u5E74\u5E74\u62A5\uFF0C\u6E2F\u80A1\u5E74\u5EA6\u5386\u53F2\u6309\u6570\u636E\u6E90\u5B9E\u9645\u53EF\u5F97\u671F\u6570\u8FD4\u56DE\u3002\u4F30\u503C\u5386\u53F2\u7528get_valuation_history\uFF0C\u62AB\u9732\u6392\u671F\u7528get_earnings_calendar",
|
|
4546
4624
|
parameters: typebox_exports.Object({
|
|
4547
|
-
symbol: typebox_exports.String({ description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" })
|
|
4625
|
+
symbol: typebox_exports.String({ description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" }),
|
|
4626
|
+
annual: typebox_exports.Optional(typebox_exports.Boolean({ description: "\u53EA\u53D6\u5E74\u5EA6\u62A5\u544A\uFF0C\u9ED8\u8BA4false" })),
|
|
4627
|
+
periods: typebox_exports.Optional(
|
|
4628
|
+
typebox_exports.Number({ description: "\u8FD4\u56DE\u6700\u8FD1N\u4E2A\u62A5\u544A\u671F1..40\uFF0C\u9ED8\u8BA41\uFF1Bannual=true\u65F6periods=10\u8BF7\u6C4210\u5E74\u5E74\u62A5" })
|
|
4629
|
+
)
|
|
4548
4630
|
}),
|
|
4549
4631
|
async execute(_id, params) {
|
|
4550
|
-
const
|
|
4632
|
+
const args = ["financials", params.symbol];
|
|
4633
|
+
if (params.periods !== void 0 && params.periods !== 1) args.push("--periods", String(params.periods));
|
|
4634
|
+
if (params.annual) args.push("--annual");
|
|
4635
|
+
const out = await runPy("stock_data.py", args);
|
|
4551
4636
|
return asText(out);
|
|
4552
4637
|
}
|
|
4553
4638
|
});
|
|
4554
4639
|
api.registerTool({
|
|
4555
4640
|
name: "get_technical_analysis",
|
|
4556
|
-
description: "\u83B7\u53D6\u80A1\u7968\u6280\u672F\u9762\u5206\u6790\uFF08MA/MACD/RSI/BOLL/KDJ/\u6210\u4EA4\u91CF\u7B49\u6307\u6807 + 100\u5206\u7EFC\u5408\u8BC4\u5206 + 6\u7EA7\u4E70\u5356\u4FE1\u53F7 + \u8D8B\u52BF/\u504F\u79BB\u5EA6/\u652F\u6491\u538B\u529B\u4F4D\uFF09\u3002\u4E2A\u80A1\u6280\u672F\u9762\u7EFC\u5408\u5224\u65AD\u4E0E\u4E70\u5356\u65F6\u673A\u5206\u6790\u7684\u9996\u9009\uFF1B\u53EA\u8981\u5747\u7EBF\u6570\u503C\u6216\u81EA\u5B9A\u4E49\u5468\u671F\u7528 calculate_ma\uFF0C\u4E13\u95EE\u91CF\u4EF7\u7528 get_volume_analysis\uFF0C\u626B\u5F53\u65E5\u5F02\u52A8\u7528 detect_anomaly",
|
|
4641
|
+
description: "\u83B7\u53D6\u80A1\u7968\u6280\u672F\u9762\u5206\u6790\uFF08MA/MACD/RSI/BOLL/KDJ/\u6210\u4EA4\u91CF\u7B49\u6307\u6807 + 100\u5206\u7EFC\u5408\u8BC4\u5206 + 6\u7EA7\u4E70\u5356\u4FE1\u53F7 + \u8D8B\u52BF/\u504F\u79BB\u5EA6/\u652F\u6491\u538B\u529B\u4F4D\uFF1B\u591A\u5468\u671F\u5171\u632F\u65F6 resonance.direction \u2208 aligned_bullish/aligned_bearish/divergent\uFF09\u3002\u4E2A\u80A1\u6280\u672F\u9762\u7EFC\u5408\u5224\u65AD\u4E0E\u4E70\u5356\u65F6\u673A\u5206\u6790\u7684\u9996\u9009\uFF1B\u53EA\u8981\u5747\u7EBF\u6570\u503C\u6216\u81EA\u5B9A\u4E49\u5468\u671F\u7528 calculate_ma\uFF0C\u4E13\u95EE\u91CF\u4EF7\u7528 get_volume_analysis\uFF0C\u626B\u5F53\u65E5\u5F02\u52A8\u7528 detect_anomaly",
|
|
4557
4642
|
parameters: typebox_exports.Object({
|
|
4558
4643
|
symbol: typebox_exports.String({ description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" }),
|
|
4559
4644
|
period: typebox_exports.Optional(
|
|
@@ -4564,17 +4649,24 @@ var index_default = definePluginEntry({
|
|
|
4564
4649
|
),
|
|
4565
4650
|
count: typebox_exports.Optional(
|
|
4566
4651
|
typebox_exports.Number({ description: "\u7528\u4E8E\u8BA1\u7B97\u6307\u6807\u7684K\u7EBF\u6761\u6570\uFF0C\u9ED8\u8BA4 120" })
|
|
4652
|
+
),
|
|
4653
|
+
periods: typebox_exports.Optional(
|
|
4654
|
+
typebox_exports.String({
|
|
4655
|
+
description: '\u591A\u5468\u671F\u5171\u632F\u5206\u6790\uFF0C\u9017\u53F7\u5206\u9694\u7684\u5468\u671F\u5217\u8868\uFF0C\u5982 "daily,weekly"\uFF1B\u4E0D\u4F20\u5219\u53EA\u5206\u6790 period \u6307\u5B9A\u7684\u5355\u5468\u671F'
|
|
4656
|
+
})
|
|
4567
4657
|
)
|
|
4568
4658
|
}),
|
|
4569
4659
|
async execute(_id, params) {
|
|
4570
|
-
const
|
|
4660
|
+
const args = [
|
|
4571
4661
|
"analyze",
|
|
4572
4662
|
params.symbol,
|
|
4573
4663
|
"--period",
|
|
4574
4664
|
params.period ?? "daily",
|
|
4575
4665
|
"--count",
|
|
4576
4666
|
String(params.count ?? 120)
|
|
4577
|
-
]
|
|
4667
|
+
];
|
|
4668
|
+
if (params.periods) args.push("--periods", params.periods);
|
|
4669
|
+
const out = await runPy("technical.py", args);
|
|
4578
4670
|
return asText(out);
|
|
4579
4671
|
}
|
|
4580
4672
|
});
|
|
@@ -4660,7 +4752,7 @@ var index_default = definePluginEntry({
|
|
|
4660
4752
|
});
|
|
4661
4753
|
api.registerTool({
|
|
4662
4754
|
name: "get_sector_constituents",
|
|
4663
|
-
description: "\u67E5\u8BE2A\u80A1\u677F\u5757\u6210\u5206\u80A1\uFF08\u6B63\u5411\u6620\u5C04\uFF1A\u677F\u5757\u2192\u80A1\u7968\u5217\u8868\uFF09\u3002\u677F\u5757\u540D\u652F\u6301\u6A21\u7CCA\u5339\u914D\uFF08\u5982\u300C\u521B\u65B0\u836F\u300D\u81EA\u52A8\u89E3\u6790\u5230\u7CBE\u786E\u677F\u5757\u540D\uFF09\uFF0C\u4E1C\u8D22\u884C\u4E1A/\u6982\u5FF5 + \u65B0\u6D6A\u591A\u6E90 failover\uFF0C\u7ED3\u679C\u7F13\
|
|
4755
|
+
description: "\u67E5\u8BE2A\u80A1\u677F\u5757\u6210\u5206\u80A1\uFF08\u6B63\u5411\u6620\u5C04\uFF1A\u677F\u5757\u2192\u80A1\u7968\u5217\u8868\uFF09\u3002\u677F\u5757\u540D\u652F\u6301\u6A21\u7CCA\u5339\u914D\uFF08\u5982\u300C\u521B\u65B0\u836F\u300D\u81EA\u52A8\u89E3\u6790\u5230\u7CBE\u786E\u677F\u5757\u540D\uFF09\uFF0C\u4E1C\u8D22\u884C\u4E1A/\u6982\u5FF5 + \u65B0\u6D6A\u591A\u6E90 failover\uFF0C\u7ED3\u679C\u6309\u7528\u6237\u76EE\u5F55\u7F13\u5B587\u5929\u3002\u4EC5\u652F\u6301A\u80A1\uFF1B\u53CD\u5411\u67E5\u4E2A\u80A1\u6240\u5C5E\u677F\u5757\u7528 resolve_stock_sectors",
|
|
4664
4756
|
parameters: typebox_exports.Object({
|
|
4665
4757
|
sector: typebox_exports.String({ description: "\u677F\u5757\u540D\u79F0\uFF08\u53EF\u6A21\u7CCA\uFF0C\u5982 \u521B\u65B0\u836F\u3001\u534A\u5BFC\u4F53\uFF09" }),
|
|
4666
4758
|
board_type: typebox_exports.Optional(
|
|
@@ -4783,6 +4875,44 @@ var index_default = definePluginEntry({
|
|
|
4783
4875
|
return asText(out);
|
|
4784
4876
|
}
|
|
4785
4877
|
});
|
|
4878
|
+
api.registerTool({
|
|
4879
|
+
name: "get_margin_trading",
|
|
4880
|
+
description: "\u83B7\u53D6A\u80A1\u4E2A\u80A1\u878D\u8D44\u878D\u5238\u660E\u7EC6\uFF08\u878D\u8D44\u4F59\u989D/\u878D\u8D44\u4E70\u5165\u989D/\u878D\u5238\u4F59\u91CF\u7B49\uFF0C\u4E0A\u4EA4\u6240/\u6DF1\u4EA4\u6240\u5B98\u65B9\u6570\u636E\u6309\u4EA4\u6613\u6240\u5206\u6D41\uFF09\uFF0C\u8FD4\u56DE\u6700\u8FD1N\u4E2A\u4EA4\u6613\u65E5\u5E8F\u5217\uFF08\u6700\u65B0\u5728\u524D\uFF09\u3002\u91D1\u989D\u5355\u4F4D\u4E3A\u5143\uFF0Cshort_*_shares \u5355\u4F4D\u4E3A\u80A1\u3002include_ratio=true\u8FFD\u52A0\u540C\u65E5\u878D\u8D44\u4E70\u5165/\u6210\u4EA4\u989D\u767E\u5206\u6BD4\uFF08margin_buy_ratio_pct\uFF09\uFF0C\u7F3A\u5C11\u540C\u65E5\u5143\u53E3\u5F84\u6210\u4EA4\u989D\u5219\u4E3Anull\u3002\u4EC5\u4E24\u878D\u6807\u7684\u6709\u6570\u636E\uFF0C\u975E\u4E24\u878D\u6807\u7684\u8FD4\u56DE\u9519\u8BEF",
|
|
4881
|
+
parameters: typebox_exports.Object({
|
|
4882
|
+
symbol: typebox_exports.String({ description: "A\u80A1\u80A1\u7968\u4EE3\u7801\uFF0C\u5982 600519" }),
|
|
4883
|
+
include_ratio: typebox_exports.Optional(typebox_exports.Boolean({ description: "\u8FFD\u52A0\u540C\u65E5\u878D\u8D44\u4E70\u5165\u5360\u6BD4\uFF0C\u9ED8\u8BA4false" })),
|
|
4884
|
+
days: typebox_exports.Optional(
|
|
4885
|
+
typebox_exports.Number({ description: "\u8FD4\u56DE\u6700\u8FD1N\u4E2A\u4EA4\u6613\u65E5\uFF0C\u9ED8\u8BA4 10" })
|
|
4886
|
+
)
|
|
4887
|
+
}),
|
|
4888
|
+
async execute(_id, params) {
|
|
4889
|
+
const out = await runPy("stock_data.py", [
|
|
4890
|
+
"margin_trading",
|
|
4891
|
+
params.symbol,
|
|
4892
|
+
"--days",
|
|
4893
|
+
String(params.days ?? 10),
|
|
4894
|
+
...params.include_ratio ? ["--include-ratio"] : []
|
|
4895
|
+
]);
|
|
4896
|
+
return asText(out);
|
|
4897
|
+
}
|
|
4898
|
+
});
|
|
4899
|
+
api.registerTool({
|
|
4900
|
+
name: "get_northbound_flow",
|
|
4901
|
+
description: "\u83B7\u53D6\u5317\u5411\u8D44\u91D1\u5E02\u573A\u7EA7\u51C0\u4E70\u5165\u5E8F\u5217\uFF08\u6700\u65B0\u5728\u524D\uFF0C\u5355\u4F4D\u4EBF\u5143\uFF09\u3002\u6570\u636E\u53E3\u5F84\uFF1A\u4E1C\u65B9\u8D22\u5BCC\u6CAA\u6DF1\u6E2F\u901A\u5386\u53F2\u6570\u636E\uFF1B2024-08-16 \u8D77\u4EA4\u6613\u6240\u505C\u6B62\u62AB\u9732\u65E5\u5EA6\u51C0\u4E70\u989D\uFF0C\u4EC5 2024-08 \u4E4B\u524D\u5386\u53F2\u6570\u636E\u53EF\u67E5\uFF08\u8FD1\u671F\u5C0F days \u7A97\u53E3\u4F1A\u8FD4\u56DE\u505C\u62AB\u9519\u8BEF\uFF0C\u52A0\u5927 days \u53EF\u53D6\u5386\u53F2\uFF09",
|
|
4902
|
+
parameters: typebox_exports.Object({
|
|
4903
|
+
days: typebox_exports.Optional(
|
|
4904
|
+
typebox_exports.Number({ description: "\u8FD4\u56DE\u6700\u8FD1N\u4E2A\u4EA4\u6613\u65E5\uFF0C\u9ED8\u8BA4 10" })
|
|
4905
|
+
)
|
|
4906
|
+
}),
|
|
4907
|
+
async execute(_id, params) {
|
|
4908
|
+
const out = await runPy("stock_data.py", [
|
|
4909
|
+
"northbound_flow",
|
|
4910
|
+
"--days",
|
|
4911
|
+
String(params.days ?? 10)
|
|
4912
|
+
]);
|
|
4913
|
+
return asText(out);
|
|
4914
|
+
}
|
|
4915
|
+
});
|
|
4786
4916
|
api.registerTool({
|
|
4787
4917
|
name: "get_fundamental_context",
|
|
4788
4918
|
description: "\u83B7\u53D6A\u80A1\u57FA\u672C\u9762\u4E0A\u4E0B\u6587\uFF08\u4F30\u503C PE/PB/\u5E02\u503C + \u8425\u6536/\u51C0\u5229\u589E\u901F + ROE/\u6BDB\u5229\u7387/\u51C0\u5229\u7387 + \u5206\u7EA2\u5386\u53F2\uFF09\u3002\u7528\u4E8E\u8BC4\u4F30\u516C\u53F8\u8D28\u5730\u4E0E\u957F\u671F\u6301\u6709\u4EF7\u503C",
|
|
@@ -5274,13 +5404,30 @@ var index_default = definePluginEntry({
|
|
|
5274
5404
|
});
|
|
5275
5405
|
api.registerTool({
|
|
5276
5406
|
name: "render_market_report",
|
|
5277
|
-
description: "\u5927\u76D8\u590D\u76D8\u62A5\u544A\u6E32\u67D3 \u2014 \u5C06\u7ED3\u6784\u5316\u62A5\u544A JSON \u901A\u8FC7 j2 \u6A21\u677F\u6E32\u67D3\u4E3A Markdown\u3002report \u5B57\u6BB5\u4EE5 schemas/market_review_schema.json \u4E3A\u51C6\
|
|
5407
|
+
description: "\u5927\u76D8\u590D\u76D8\u62A5\u544A\u6E32\u67D3 \u2014 \u5C06\u7ED3\u6784\u5316\u62A5\u544A JSON \u901A\u8FC7 j2 \u6A21\u677F\u6E32\u67D3\u4E3A Markdown\u3002report \u5B57\u6BB5\u4EE5 schemas/market_review_schema.json \u4E3A\u51C6\u3002save=true \u65F6\u628A\u62A5\u544A\u5BF9\u8C61\u8FFD\u52A0\u5F52\u6863\u5230\u672C\u5730 JSONL\uFF08\u9ED8\u8BA4\u4E0D\u4FDD\u5B58\u4E0D\u63A8\u9001\uFF09\uFF0C\u7EB5\u5411\u5BF9\u6BD4\u7528 get_review_history",
|
|
5278
5408
|
parameters: typebox_exports.Object({
|
|
5279
|
-
report: typebox_exports.Object({}, { additionalProperties: true, description: "\u7ED3\u6784\u5316\u5E02\u573A\u590D\u76D8" })
|
|
5409
|
+
report: typebox_exports.Object({}, { additionalProperties: true, description: "\u7ED3\u6784\u5316\u5E02\u573A\u590D\u76D8" }),
|
|
5410
|
+
save: typebox_exports.Optional(typebox_exports.Boolean({ description: "\u662F\u5426\u5F52\u6863\u5230\u672C\u5730\u590D\u76D8 JSONL \u5B58\u50A8\uFF0C\u9ED8\u8BA4 false" }))
|
|
5280
5411
|
}),
|
|
5281
5412
|
async execute(_id, params) {
|
|
5282
5413
|
const b64 = Buffer.from(JSON.stringify(params.report), "utf-8").toString("base64");
|
|
5283
|
-
const out = await runPy("report_renderer.py", [
|
|
5414
|
+
const out = await runPy("report_renderer.py", [
|
|
5415
|
+
"market",
|
|
5416
|
+
"--input-b64",
|
|
5417
|
+
b64,
|
|
5418
|
+
...params.save ? ["--save"] : []
|
|
5419
|
+
]);
|
|
5420
|
+
return asText(out);
|
|
5421
|
+
}
|
|
5422
|
+
});
|
|
5423
|
+
api.registerTool({
|
|
5424
|
+
name: "get_review_history",
|
|
5425
|
+
description: "\u590D\u76D8\u5F52\u6863\u5386\u53F2 \u2014 \u8BFB\u53D6\u672C\u5730 JSONL \u5F52\u6863\u7684\u6700\u8FD1 N \u6761\u5E02\u573A\u590D\u76D8\uFF08\u6700\u65B0\u5728\u524D\uFF09\uFF0C\u7528\u4E8E\u7EB5\u5411\u5BF9\u6BD4\uFF08\u6E29\u5EA6/\u59FF\u6001/\u4E3B\u7EBF\u53D8\u5316\uFF09\u3002\u5F52\u6863\u7531 render_market_report \u7684 save=true \u5199\u5165\uFF0C\u7A7A\u5B58\u6863\u8FD4\u56DE\u7A7A\u5217\u8868",
|
|
5426
|
+
parameters: typebox_exports.Object({
|
|
5427
|
+
limit: typebox_exports.Optional(typebox_exports.Number({ description: "\u8FD4\u56DE\u6761\u6570\uFF0C\u9ED8\u8BA4 10" }))
|
|
5428
|
+
}),
|
|
5429
|
+
async execute(_id, params) {
|
|
5430
|
+
const out = await runPy("market_review.py", ["history", "--limit", String(params.limit ?? 10)]);
|
|
5284
5431
|
return asText(out);
|
|
5285
5432
|
}
|
|
5286
5433
|
});
|
package/index.ts
CHANGED
|
@@ -25,25 +25,10 @@ const here = dirname(fileURLToPath(import.meta.url));
|
|
|
25
25
|
const toolsDir = existsSync(join(here, "tools"))
|
|
26
26
|
? join(here, "tools")
|
|
27
27
|
: join(here, "..", "tools");
|
|
28
|
-
const
|
|
28
|
+
const fallbackRoot = dirname(toolsDir);
|
|
29
29
|
const isWin = process.platform === "win32";
|
|
30
30
|
// Windows venvs ship Scripts/python.exe (there is no python3); POSIX venvs ship bin/python3.
|
|
31
31
|
const venvBin = join(".venv", isWin ? "Scripts" : "bin", isWin ? "python.exe" : "python3");
|
|
32
|
-
const venvPython = join(repoRoot, venvBin);
|
|
33
|
-
// Staged-payload layout (openclaw/tools present in a dev checkout): the venv
|
|
34
|
-
// still lives at the repo root one level up.
|
|
35
|
-
const parentVenvPython = join(repoRoot, "..", venvBin);
|
|
36
|
-
|
|
37
|
-
function pythonBin(): string {
|
|
38
|
-
if (existsSync(venvPython)) return venvPython;
|
|
39
|
-
if (existsSync(parentVenvPython)) return parentVenvPython;
|
|
40
|
-
// On Windows "python3" is usually the Microsoft Store stub — prefer "python".
|
|
41
|
-
return isWin ? "python" : "python3";
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function runPy(script: string, args: string[]): Promise<string> {
|
|
45
|
-
return executor(pythonBin(), [join(toolsDir, script), ...args]);
|
|
46
|
-
}
|
|
47
32
|
|
|
48
33
|
function asText(text: string) {
|
|
49
34
|
return { content: [{ type: "text" as const, text }] };
|
|
@@ -55,12 +40,110 @@ export default definePluginEntry({
|
|
|
55
40
|
description:
|
|
56
41
|
"Stock analysis, screening, and strategy backtesting across A/HK/US/JP/KR/TW markets",
|
|
57
42
|
register(api) {
|
|
43
|
+
// OpenClaw executes a captured copy of the JS bundle; the venv stays in the installed plugin root.
|
|
44
|
+
const repoRoot = api.rootDir || fallbackRoot;
|
|
45
|
+
const pythonBin = () => {
|
|
46
|
+
const venvPython = join(repoRoot, venvBin);
|
|
47
|
+
if (existsSync(venvPython)) return venvPython;
|
|
48
|
+
// In a staged dev checkout, the venv still lives at the repo root.
|
|
49
|
+
const parentVenvPython = join(repoRoot, "..", venvBin);
|
|
50
|
+
if (existsSync(parentVenvPython)) return parentVenvPython;
|
|
51
|
+
// On Windows "python3" is usually the Microsoft Store stub — prefer "python".
|
|
52
|
+
return isWin ? "python" : "python3";
|
|
53
|
+
};
|
|
54
|
+
const runPy = (script: string, args: string[]) =>
|
|
55
|
+
executor(pythonBin(), [join(toolsDir, script), ...args]);
|
|
58
56
|
// --- Data Tools ---
|
|
59
57
|
|
|
58
|
+
api.registerTool({
|
|
59
|
+
name: "get_valuation_history",
|
|
60
|
+
description: "查询A/HK股票历史 PE-TTM/PB、当前正值分位和10/25/50/75/90分位 Band,返回实际采样区间;亏损估值分位为null。years=1..10,数据按天缓存。",
|
|
61
|
+
parameters: Type.Object({
|
|
62
|
+
symbol: Type.String({ description: "A股代码或港股.HK代码" }),
|
|
63
|
+
years: Type.Optional(Type.Number({ description: "历史窗口年数1..10,默认5" })),
|
|
64
|
+
}),
|
|
65
|
+
async execute(_id, p) {
|
|
66
|
+
const out = await runPy("value_data.py", ["valuation_history", p.symbol, "--years", String(p.years ?? 5)]);
|
|
67
|
+
return asText(out);
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
api.registerTool({
|
|
72
|
+
name: "get_index_valuation",
|
|
73
|
+
description: "查询中国指数估值历史分位与Band;乐咕乐股PE/PB优先,中证官方历史补充滚动PE并保留近期PE1口径。缺PB时可用LIXINGER_TOKEN补充理杏仁mcw历史,来源与算法分别标明,不混接同一指标。",
|
|
74
|
+
parameters: Type.Object({
|
|
75
|
+
symbol: Type.String({ description: "指数代码或名称,如000300、沪深300、000985" }),
|
|
76
|
+
years: Type.Optional(Type.Number({ description: "历史窗口年数1..10,默认5" })),
|
|
77
|
+
}),
|
|
78
|
+
async execute(_id, p) {
|
|
79
|
+
const out = await runPy("value_data.py", ["index_valuation", p.symbol, "--years", String(p.years ?? 5)]);
|
|
80
|
+
return asText(out);
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
api.registerTool({
|
|
85
|
+
name: "get_earnings_calendar",
|
|
86
|
+
description: "查询财报日历:A股report_date必填季度期末,返回预约/修订/实际披露与业绩预告;HK需symbol,优先HKEX已公告业绩审批董事会排期(不是实际披露日),缺失时返回供应商日期。HK可按已知财政期末过滤,未知期次另列。",
|
|
87
|
+
parameters: Type.Object({
|
|
88
|
+
report_date: Type.Optional(Type.String({ description: "A股必填季度期末YYYY-MM-DD;HK可选已公告财政期末,未知期次另列" })),
|
|
89
|
+
symbol: Type.Optional(Type.String({ description: "A股代码可选(省略查全市场);HK必须提供港股.HK代码" })),
|
|
90
|
+
top: Type.Optional(Type.Number({ description: "每类最多返回条数1..500,默认50" })),
|
|
91
|
+
}),
|
|
92
|
+
async execute(_id, p) {
|
|
93
|
+
const out = await runPy("value_data.py", ["earnings_calendar", "--report-date", p.report_date ?? "", "--symbol", p.symbol ?? "", "--top", String(p.top ?? 50)]);
|
|
94
|
+
return asText(out);
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
api.registerTool({
|
|
99
|
+
name: "get_shareholder_structure",
|
|
100
|
+
description: "查询A股股东户数、十大流通股东变化及沪深交易所季度北向合计持股;官方总量优先,十大HKSCC名义持股仅兜底且标明口径。HK返回港交所南向记录。缺失不当零,期末不等于已公布。",
|
|
101
|
+
parameters: Type.Object({
|
|
102
|
+
symbol: Type.String({ description: "A股代码或港股.HK代码" }),
|
|
103
|
+
report_date: Type.Optional(Type.String({ description: "A股报告期YYYY-MM-DD;省略时北向使用最新已公布季度,十大股东使用最新财报期;HK忽略" })),
|
|
104
|
+
}),
|
|
105
|
+
async execute(_id, p) {
|
|
106
|
+
const out = await runPy("value_data.py", ["shareholder_structure", p.symbol, "--report-date", p.report_date ?? ""]);
|
|
107
|
+
return asText(out);
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
api.registerTool({
|
|
112
|
+
name: "get_etf_details",
|
|
113
|
+
description: "查询A股ETF净值折溢价、规模、披露持仓及沪深完整PCF申赎篮子;篮子不是实际持仓。include_full_holdings=true另取最近可得半年度/年度披露股票表,含数量/市值/报告期,非实时全资产组合;benchmark用于跟踪误差。",
|
|
114
|
+
parameters: Type.Object({
|
|
115
|
+
include_full_holdings: Type.Optional(Type.Boolean({ description: "请求半年度/年度披露股票表,默认false" })),
|
|
116
|
+
symbol: Type.String({ description: "A股ETF代码,如510300" }),
|
|
117
|
+
benchmark: Type.Optional(Type.String({ description: "可选基准代码,如sh000300;不猜测基准" })),
|
|
118
|
+
days: Type.Optional(Type.Number({ description: "净值窗口交易日数10..252,默认60" })),
|
|
119
|
+
}),
|
|
120
|
+
async execute(_id, p) {
|
|
121
|
+
const out = await runPy("value_data.py", ["etf_details", p.symbol, "--benchmark", p.benchmark ?? "", "--days", String(p.days ?? 60), ...(p.include_full_holdings ? ["--include-full-holdings"] : [])]);
|
|
122
|
+
return asText(out);
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
api.registerTool({
|
|
127
|
+
name: "get_dividends",
|
|
128
|
+
description: "查询A/HK分红历史、除息日历、已实施TTM股息与连续年数。mode=ranking省略symbol,market=A查报告期排行,market=HK查HKEX/LSEG年度股息率排行(report_date须年末);排行均非当前TTM收益率。缺失不按零。",
|
|
129
|
+
parameters: Type.Object({
|
|
130
|
+
market: Type.Optional(Type.Union([Type.Literal("A"), Type.Literal("HK")], { description: "仅ranking选择市场,默认A" })),
|
|
131
|
+
symbol: Type.Optional(Type.String({ description: "history/calendar必填A股或港股.HK代码;ranking省略" })),
|
|
132
|
+
mode: Type.Optional(Type.Union([Type.Literal("history"), Type.Literal("calendar"), Type.Literal("ranking")], { description: "history默认;calendar未来已公布除息事件;ranking按market查询A/HK排行" })),
|
|
133
|
+
report_date: Type.Optional(Type.String({ description: "ranking报告期YYYY-MM-DD,默认上一年年末;HK仅年度年末日期" })),
|
|
134
|
+
years: Type.Optional(Type.Number({ description: "历史窗口年数1..20,默认10" })),
|
|
135
|
+
top: Type.Optional(Type.Number({ description: "排名条数1..500,默认20" })),
|
|
136
|
+
}),
|
|
137
|
+
async execute(_id, p) {
|
|
138
|
+
const out = await runPy("value_data.py", ["dividends", "--market", p.market ?? "A", "--symbol", p.symbol ?? "", "--mode", p.mode ?? "history", "--report-date", p.report_date ?? "", "--years", String(p.years ?? 10), "--top", String(p.top ?? 20)]);
|
|
139
|
+
return asText(out);
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
|
|
60
143
|
api.registerTool({
|
|
61
144
|
name: "get_kline",
|
|
62
145
|
description:
|
|
63
|
-
"获取股票K线数据(OHLCV)。支持A股(如600519)、港股(如00700.HK)、美股(如AAPL)、日股(如7203.T)、韩股(如005930.KS)、台股(如2330.TW)及A股ETF
|
|
146
|
+
"获取股票K线数据(OHLCV)。支持A股(如600519)、港股(如00700.HK)、美股(如AAPL)、日股(如7203.T)、韩股(如005930.KS)、台股(如2330.TW)及A股ETF。A股股票/ETF返回前复权价格,每条记录 adjusted=qfq;sh000xxx/sz399xxx 指数返回原始点位,adjusted=none。需要历史价格自行计算或画图时用;只问指标用 get_technical_analysis,只问现价用 get_quote",
|
|
64
147
|
parameters: Type.Object({
|
|
65
148
|
symbol: Type.String({
|
|
66
149
|
description: "股票代码,如 600519(A股)、00700.HK(港股)、AAPL(美股)、7203.T(日股)、005930.KS(韩股)、2330.TW(台股)",
|
|
@@ -88,7 +171,7 @@ export default definePluginEntry({
|
|
|
88
171
|
|
|
89
172
|
api.registerTool({
|
|
90
173
|
name: "get_quote",
|
|
91
|
-
description: "获取股票实时行情报价(现价、涨跌幅、量比等)。支持A股、港股、美股、日股、韩股、台股;非交易时段返回最近交易日收盘价并以 as_of/stale
|
|
174
|
+
description: "获取股票实时行情报价(现价、涨跌幅、量比等)。支持A股、港股、美股、日股、韩股、台股;非交易时段返回最近交易日收盘价并以 as_of/stale 标注;ETF 的 premium_discount_rate 为正=溢价、负=折价",
|
|
92
175
|
parameters: Type.Object({
|
|
93
176
|
symbol: Type.String({ description: "股票代码(A股如600519,美股如AAPL,港股如00700.HK)" }),
|
|
94
177
|
}),
|
|
@@ -148,12 +231,19 @@ export default definePluginEntry({
|
|
|
148
231
|
|
|
149
232
|
api.registerTool({
|
|
150
233
|
name: "get_financials",
|
|
151
|
-
description: "
|
|
234
|
+
description: "获取股票财务摘要及历史趋势,按天缓存。A股返回ROE/毛利率/净利率等;annual=true与periods=10取十年年报,港股年度历史按数据源实际可得期数返回。估值历史用get_valuation_history,披露排期用get_earnings_calendar",
|
|
152
235
|
parameters: Type.Object({
|
|
153
236
|
symbol: Type.String({ description: "股票代码(A股如600519,美股如AAPL,港股如00700.HK)" }),
|
|
237
|
+
annual: Type.Optional(Type.Boolean({description: "只取年度报告,默认false"})),
|
|
238
|
+
periods: Type.Optional(
|
|
239
|
+
Type.Number({ description: "返回最近N个报告期1..40,默认1;annual=true时periods=10请求10年年报" })
|
|
240
|
+
),
|
|
154
241
|
}),
|
|
155
242
|
async execute(_id, params) {
|
|
156
|
-
const
|
|
243
|
+
const args = ["financials", params.symbol];
|
|
244
|
+
if (params.periods !== undefined && params.periods !== 1) args.push("--periods", String(params.periods));
|
|
245
|
+
if (params.annual) args.push("--annual");
|
|
246
|
+
const out = await runPy("stock_data.py", args);
|
|
157
247
|
return asText(out);
|
|
158
248
|
},
|
|
159
249
|
});
|
|
@@ -163,7 +253,7 @@ export default definePluginEntry({
|
|
|
163
253
|
api.registerTool({
|
|
164
254
|
name: "get_technical_analysis",
|
|
165
255
|
description:
|
|
166
|
-
"获取股票技术面分析(MA/MACD/RSI/BOLL/KDJ/成交量等指标 + 100分综合评分 + 6级买卖信号 +
|
|
256
|
+
"获取股票技术面分析(MA/MACD/RSI/BOLL/KDJ/成交量等指标 + 100分综合评分 + 6级买卖信号 + 趋势/偏离度/支撑压力位;多周期共振时 resonance.direction ∈ aligned_bullish/aligned_bearish/divergent)。个股技术面综合判断与买卖时机分析的首选;只要均线数值或自定义周期用 calculate_ma,专问量价用 get_volume_analysis,扫当日异动用 detect_anomaly",
|
|
167
257
|
parameters: Type.Object({
|
|
168
258
|
symbol: Type.String({ description: "股票代码(A股如600519,美股如AAPL,港股如00700.HK)" }),
|
|
169
259
|
period: Type.Optional(
|
|
@@ -175,16 +265,23 @@ export default definePluginEntry({
|
|
|
175
265
|
count: Type.Optional(
|
|
176
266
|
Type.Number({ description: "用于计算指标的K线条数,默认 120" })
|
|
177
267
|
),
|
|
268
|
+
periods: Type.Optional(
|
|
269
|
+
Type.String({
|
|
270
|
+
description: '多周期共振分析,逗号分隔的周期列表,如 "daily,weekly";不传则只分析 period 指定的单周期',
|
|
271
|
+
})
|
|
272
|
+
),
|
|
178
273
|
}),
|
|
179
274
|
async execute(_id, params) {
|
|
180
|
-
const
|
|
275
|
+
const args = [
|
|
181
276
|
"analyze",
|
|
182
277
|
params.symbol,
|
|
183
278
|
"--period",
|
|
184
279
|
params.period ?? "daily",
|
|
185
280
|
"--count",
|
|
186
281
|
String(params.count ?? 120),
|
|
187
|
-
]
|
|
282
|
+
];
|
|
283
|
+
if (params.periods) args.push("--periods", params.periods);
|
|
284
|
+
const out = await runPy("technical.py", args);
|
|
188
285
|
return asText(out);
|
|
189
286
|
},
|
|
190
287
|
});
|
|
@@ -280,7 +377,7 @@ export default definePluginEntry({
|
|
|
280
377
|
api.registerTool({
|
|
281
378
|
name: "get_sector_constituents",
|
|
282
379
|
description:
|
|
283
|
-
"查询A股板块成分股(正向映射:板块→股票列表)。板块名支持模糊匹配(如「创新药」自动解析到精确板块名),东财行业/概念 + 新浪多源 failover
|
|
380
|
+
"查询A股板块成分股(正向映射:板块→股票列表)。板块名支持模糊匹配(如「创新药」自动解析到精确板块名),东财行业/概念 + 新浪多源 failover,结果按用户目录缓存7天。仅支持A股;反向查个股所属板块用 resolve_stock_sectors",
|
|
284
381
|
parameters: Type.Object({
|
|
285
382
|
sector: Type.String({ description: "板块名称(可模糊,如 创新药、半导体)" }),
|
|
286
383
|
board_type: Type.Optional(
|
|
@@ -417,6 +514,48 @@ export default definePluginEntry({
|
|
|
417
514
|
},
|
|
418
515
|
});
|
|
419
516
|
|
|
517
|
+
api.registerTool({
|
|
518
|
+
name: "get_margin_trading",
|
|
519
|
+
description:
|
|
520
|
+
"获取A股个股融资融券明细(融资余额/融资买入额/融券余量等,上交所/深交所官方数据按交易所分流),返回最近N个交易日序列(最新在前)。金额单位为元,short_*_shares 单位为股。include_ratio=true追加同日融资买入/成交额百分比(margin_buy_ratio_pct),缺少同日元口径成交额则为null。仅两融标的有数据,非两融标的返回错误",
|
|
521
|
+
parameters: Type.Object({
|
|
522
|
+
symbol: Type.String({ description: "A股股票代码,如 600519" }),
|
|
523
|
+
include_ratio: Type.Optional(Type.Boolean({description: "追加同日融资买入占比,默认false"})),
|
|
524
|
+
days: Type.Optional(
|
|
525
|
+
Type.Number({ description: "返回最近N个交易日,默认 10" })
|
|
526
|
+
),
|
|
527
|
+
}),
|
|
528
|
+
async execute(_id, params) {
|
|
529
|
+
const out = await runPy("stock_data.py", [
|
|
530
|
+
"margin_trading",
|
|
531
|
+
params.symbol,
|
|
532
|
+
"--days",
|
|
533
|
+
String(params.days ?? 10),
|
|
534
|
+
...(params.include_ratio ? ["--include-ratio"] : []),
|
|
535
|
+
]);
|
|
536
|
+
return asText(out);
|
|
537
|
+
},
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
api.registerTool({
|
|
541
|
+
name: "get_northbound_flow",
|
|
542
|
+
description:
|
|
543
|
+
"获取北向资金市场级净买入序列(最新在前,单位亿元)。数据口径:东方财富沪深港通历史数据;2024-08-16 起交易所停止披露日度净买额,仅 2024-08 之前历史数据可查(近期小 days 窗口会返回停披错误,加大 days 可取历史)",
|
|
544
|
+
parameters: Type.Object({
|
|
545
|
+
days: Type.Optional(
|
|
546
|
+
Type.Number({ description: "返回最近N个交易日,默认 10" })
|
|
547
|
+
),
|
|
548
|
+
}),
|
|
549
|
+
async execute(_id, params) {
|
|
550
|
+
const out = await runPy("stock_data.py", [
|
|
551
|
+
"northbound_flow",
|
|
552
|
+
"--days",
|
|
553
|
+
String(params.days ?? 10),
|
|
554
|
+
]);
|
|
555
|
+
return asText(out);
|
|
556
|
+
},
|
|
557
|
+
});
|
|
558
|
+
|
|
420
559
|
api.registerTool({
|
|
421
560
|
name: "get_fundamental_context",
|
|
422
561
|
description:
|
|
@@ -972,13 +1111,32 @@ export default definePluginEntry({
|
|
|
972
1111
|
api.registerTool({
|
|
973
1112
|
name: "render_market_report",
|
|
974
1113
|
description:
|
|
975
|
-
"大盘复盘报告渲染 — 将结构化报告 JSON 通过 j2 模板渲染为 Markdown。report 字段以 schemas/market_review_schema.json
|
|
1114
|
+
"大盘复盘报告渲染 — 将结构化报告 JSON 通过 j2 模板渲染为 Markdown。report 字段以 schemas/market_review_schema.json 为准。save=true 时把报告对象追加归档到本地 JSONL(默认不保存不推送),纵向对比用 get_review_history",
|
|
976
1115
|
parameters: Type.Object({
|
|
977
1116
|
report: Type.Object({}, { additionalProperties: true, description: "结构化市场复盘" }),
|
|
1117
|
+
save: Type.Optional(Type.Boolean({ description: "是否归档到本地复盘 JSONL 存储,默认 false" })),
|
|
978
1118
|
}),
|
|
979
1119
|
async execute(_id, params) {
|
|
980
1120
|
const b64 = Buffer.from(JSON.stringify(params.report), "utf-8").toString("base64");
|
|
981
|
-
const out = await runPy("report_renderer.py", [
|
|
1121
|
+
const out = await runPy("report_renderer.py", [
|
|
1122
|
+
"market",
|
|
1123
|
+
"--input-b64",
|
|
1124
|
+
b64,
|
|
1125
|
+
...(params.save ? ["--save"] : []),
|
|
1126
|
+
]);
|
|
1127
|
+
return asText(out);
|
|
1128
|
+
},
|
|
1129
|
+
});
|
|
1130
|
+
|
|
1131
|
+
api.registerTool({
|
|
1132
|
+
name: "get_review_history",
|
|
1133
|
+
description:
|
|
1134
|
+
"复盘归档历史 — 读取本地 JSONL 归档的最近 N 条市场复盘(最新在前),用于纵向对比(温度/姿态/主线变化)。归档由 render_market_report 的 save=true 写入,空存档返回空列表",
|
|
1135
|
+
parameters: Type.Object({
|
|
1136
|
+
limit: Type.Optional(Type.Number({ description: "返回条数,默认 10" })),
|
|
1137
|
+
}),
|
|
1138
|
+
async execute(_id, params) {
|
|
1139
|
+
const out = await runPy("market_review.py", ["history", "--limit", String(params.limit ?? 10)]);
|
|
982
1140
|
return asText(out);
|
|
983
1141
|
},
|
|
984
1142
|
});
|