openclaw-stock-analysis 0.2.2 → 0.2.6

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.
Files changed (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -2
  3. package/dist/index.js +228 -30
  4. package/index.ts +246 -33
  5. package/openclaw.plugin.json +13 -1
  6. package/package.json +1 -1
  7. package/schemas/report_schema.json +3 -3
  8. package/scripts/ci-resolve-llm-host.mjs +29 -0
  9. package/scripts/setup-python.mjs +11 -13
  10. package/skills/bull-trend/SKILL.md +34 -10
  11. package/skills/bull-trend/references/fat-tails.md +91 -0
  12. package/skills/bull-trend/scripts/tail_analysis.py +132 -0
  13. package/skills/event-driven/SKILL.md +8 -0
  14. package/skills/growth-quality/SKILL.md +8 -0
  15. package/skills/hot-theme/SKILL.md +3 -2
  16. package/skills/stock-analysis/SKILL.md +31 -3
  17. package/skills/stock-screener/SKILL.md +21 -1
  18. package/skills/strategy-backtest/SKILL.md +15 -5
  19. package/skills/wisburg-research/SKILL.md +2 -0
  20. package/strategies/examples/bottom_volume.yaml +5 -0
  21. package/strategies/examples/box_oscillation.yaml +5 -0
  22. package/strategies/examples/bull_trend.yaml +11 -3
  23. package/strategies/examples/dragon_head.yaml +4 -2
  24. package/strategies/examples/emotion_cycle.yaml +5 -0
  25. package/strategies/examples/ma_crossover.yaml +10 -3
  26. package/strategies/examples/rsi_oversold.yaml +5 -0
  27. package/strategies/examples/shrink_pullback.yaml +7 -1
  28. package/strategies/examples/volume_breakout.yaml +7 -1
  29. package/templates/stock_analysis/brief.md.j2 +4 -1
  30. package/templates/stock_analysis/full.md.j2 +6 -3
  31. package/tools/_cache.py +61 -0
  32. package/tools/_subproc.py +49 -0
  33. package/tools/alert_rules.py +51 -13
  34. package/tools/anomaly_detect.py +24 -35
  35. package/tools/backtest.py +202 -104
  36. package/tools/capabilities.py +16 -5
  37. package/tools/diagnostics.py +12 -6
  38. package/tools/gather.py +33 -19
  39. package/tools/import_parser.py +2 -5
  40. package/tools/lixinger.py +100 -0
  41. package/tools/market_regime.py +34 -38
  42. package/tools/market_review.py +57 -9
  43. package/tools/name_resolver.py +2 -5
  44. package/tools/pattern.py +2 -5
  45. package/tools/position_context.py +22 -7
  46. package/tools/report_renderer.py +12 -6
  47. package/tools/requirements.txt +2 -1
  48. package/tools/risk_screening.py +73 -39
  49. package/tools/screener.py +90 -20
  50. package/tools/search_intel.py +5 -13
  51. package/tools/sec_edgar.py +346 -0
  52. package/tools/sec_holders.py +263 -0
  53. package/tools/signal_tracker.py +144 -25
  54. package/tools/stock_data.py +600 -186
  55. package/tools/technical.py +152 -42
  56. package/tools/trading_calendar.py +78 -18
  57. package/tools/value_data.py +1527 -0
  58. package/tools/volume_analysis.py +2 -5
  59. package/tools/watchlist.py +26 -6
  60. package/tools/watchlist_context.py +9 -8
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 加载后即可在对话中调用 48 个工具。
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.9`。
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
@@ -4427,8 +4427,18 @@ __export(typebox_exports, {
4427
4427
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
4428
4428
  var defaultExecutor = async (bin, argv) => {
4429
4429
  const exec = promisify(cp.execFile);
4430
- const { stdout } = await exec(bin, argv, { maxBuffer: 32 * 1024 * 1024 });
4431
- return stdout;
4430
+ try {
4431
+ const { stdout } = await exec(bin, argv, { maxBuffer: 32 * 1024 * 1024 });
4432
+ return stdout;
4433
+ } catch (error) {
4434
+ const stdout = error.stdout;
4435
+ try {
4436
+ const data = JSON.parse(stdout ?? "");
4437
+ if (data && typeof data.error === "string") return stdout;
4438
+ } catch {
4439
+ }
4440
+ return JSON.stringify({ error: "Python command failed; check interpreter/dependencies" });
4441
+ }
4432
4442
  };
4433
4443
  var executor = defaultExecutor;
4434
4444
  function __setExecutor(fn) {
@@ -4436,19 +4446,9 @@ function __setExecutor(fn) {
4436
4446
  }
4437
4447
  var here = dirname(fileURLToPath(import.meta.url));
4438
4448
  var toolsDir = existsSync(join(here, "tools")) ? join(here, "tools") : join(here, "..", "tools");
4439
- var repoRoot = dirname(toolsDir);
4449
+ var fallbackRoot = dirname(toolsDir);
4440
4450
  var isWin = process.platform === "win32";
4441
4451
  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
4452
  function asText(text) {
4453
4453
  return { content: [{ type: "text", text }] };
4454
4454
  }
@@ -4457,9 +4457,138 @@ var index_default = definePluginEntry({
4457
4457
  name: "Stock Analysis",
4458
4458
  description: "Stock analysis, screening, and strategy backtesting across A/HK/US/JP/KR/TW markets",
4459
4459
  register(api) {
4460
+ const repoRoot = api.rootDir || fallbackRoot;
4461
+ const runtimeToolsDir = existsSync(join(repoRoot, "tools")) ? join(repoRoot, "tools") : toolsDir;
4462
+ const pythonBin = () => {
4463
+ const venvPython = join(repoRoot, venvBin);
4464
+ if (existsSync(venvPython)) return venvPython;
4465
+ const parentVenvPython = join(repoRoot, "..", venvBin);
4466
+ if (existsSync(parentVenvPython)) return parentVenvPython;
4467
+ return isWin ? "python" : "python3";
4468
+ };
4469
+ const runPy = (script, args) => executor(pythonBin(), [join(runtimeToolsDir, script), ...args]);
4470
+ api.registerTool({
4471
+ name: "get_announcements",
4472
+ description: "\u67E5\u8BE2A\u80A1\u5DE8\u6F6E\u516C\u544A\u6807\u9898\u3001\u65E5\u671F\u3001\u7C7B\u578B\u548C\u539F\u6587PDF\u94FE\u63A5\uFF1B\u6309\u65E5\u671F\u8303\u56F4/\u7C7B\u522B\u7B5B\u9009\uFF0C\u9ED8\u8BA4\u8FD190\u5929\uFF0Ctop=1..500\u3002\u7B2C\u4E00\u7248\u4E0D\u63D0\u53D6\u6B63\u6587\uFF0Ctruncated\u63D0\u793A\u622A\u65AD\u3002",
4473
+ parameters: typebox_exports.Object({
4474
+ symbol: typebox_exports.String({ description: "A\u80A1\u4EE3\u7801" }),
4475
+ category: typebox_exports.Optional(typebox_exports.Union([typebox_exports.Literal("all"), typebox_exports.Literal("forecast"), typebox_exports.Literal("express"), typebox_exports.Literal("annual"), typebox_exports.Literal("interim"), typebox_exports.Literal("quarterly"), typebox_exports.Literal("reduction"), typebox_exports.Literal("issuance"), typebox_exports.Literal("inquiry"), typebox_exports.Literal("dividend")], { description: "\u516C\u544A\u7C7B\u522B\uFF0C\u9ED8\u8BA4all" })),
4476
+ start_date: typebox_exports.Optional(typebox_exports.String({ description: "\u5F00\u59CB\u65E5\u671FYYYY-MM-DD\uFF0C\u9ED8\u8BA4\u7ED3\u675F\u65E5\u671F\u524D90\u5929" })),
4477
+ end_date: typebox_exports.Optional(typebox_exports.String({ description: "\u7ED3\u675F\u65E5\u671FYYYY-MM-DD\uFF0C\u9ED8\u8BA4\u4ECA\u5929" })),
4478
+ top: typebox_exports.Optional(typebox_exports.Number({ description: "\u6700\u591A\u6761\u65701..500\uFF0C\u9ED8\u8BA450" }))
4479
+ }),
4480
+ async execute(_id, p) {
4481
+ const out = await runPy("value_data.py", ["announcements", p.symbol, "--category", p.category ?? "all", "--start-date", p.start_date ?? "", "--end-date", p.end_date ?? "", "--top", String(p.top ?? 50)]);
4482
+ return asText(out);
4483
+ }
4484
+ });
4485
+ api.registerTool({
4486
+ name: "get_us_holdings",
4487
+ description: "\u67E5\u8BE2SEC 13F\uFF1Amode=auto\u9ED8\u8BA4\u670913F\u7533\u62A5\u65F6\u67E5\u673A\u6784\uFF0C\u5426\u5219\u6309\u53D1\u884C\u4EBACIK\u53CD\u67E5\u6301\u4ED3\u673A\u6784\uFF1Bmanager/issuer\u53EF\u663E\u5F0F\u6307\u5B9A\u3002\u53D1\u884C\u4EBA\u901A\u8FC7\u5B98\u65B913D/G\u7CBE\u786E\u6620\u5C04CUSIP\uFF0C\u626B\u63CF\u6700\u65B0\u5DF2\u53D1\u5E0313F\u7A97\u53E3\uFF0C\u5904\u7406\u91CD\u8FF0/\u8865\u5145\u4FEE\u8BA2\uFF0C\u8FD4\u56DE\u5B9E\u9645\u62A5\u544A\u671F\u3001\u622A\u6B62\u65E5\u53CA\u6620\u5C04\u8986\u76D6\u3002\u9996\u6B21\u7EA6100MB\u4E0B\u8F7D\uFF0C\u540E\u7EED\u7F13\u5B58\uFF1B\u65E0\u6620\u5C04\u660E\u786E\u62A5\u9519\uFF0C\u4E0D\u505A\u540D\u79F0\u731C\u6D4B\u3002\u9700SEC_USER_AGENT\u542B\u771F\u5B9E\u8054\u7CFB\u90AE\u7BB1\uFF0C\u4E0D\u662F\u5B9E\u65F6\u6216\u5168\u90E8\u8BC1\u5238\u6301\u4ED3\u3002",
4488
+ parameters: typebox_exports.Object({
4489
+ cik: typebox_exports.String({ description: "\u673A\u6784\u6216\u53D1\u884C\u4EBACIK\uFF0C1..10\u4F4D\u6570\u5B57\uFF0C\u59820001067983/0000320193" }),
4490
+ mode: typebox_exports.Optional(typebox_exports.Union([typebox_exports.Literal("auto"), typebox_exports.Literal("manager"), typebox_exports.Literal("issuer")], { description: "\u9ED8\u8BA4auto\uFF1Bmanager\u67E5\u673A\u6784\u7EC4\u5408\uFF0Cissuer\u53CD\u67E5\u53D1\u884C\u4EBA\u6301\u4ED3\u673A\u6784" }))
4491
+ }),
4492
+ async execute(_id, p) {
4493
+ const out = await runPy("sec_edgar.py", ["holdings", p.cik, ...p.mode ? ["--mode", p.mode] : []]);
4494
+ return asText(out);
4495
+ }
4496
+ });
4497
+ api.registerTool({
4498
+ name: "get_insider_trades",
4499
+ description: "\u67E5\u8BE2\u7F8E\u80A1\u53D1\u884C\u4EBA\u8FD1\u671FForm 4/4-A\u5185\u90E8\u4EBA\u4EA4\u6613\uFF08SEC\u5B98\u65B9XML\uFF09\uFF0C\u4FDD\u7559\u4EBA\u5458\u804C\u52A1\u3001\u4EA4\u6613\u4EE3\u7801\u3001\u4E70\u5356\u65B9\u5411\u3001\u6570\u91CF\u3001\u4EF7\u683C\u3001\u811A\u6CE8\u548C\u884D\u751F\u54C1\u6807\u5FD7\u3002\u9700SEC_USER_AGENT\u542B\u771F\u5B9E\u8054\u7CFB\u90AE\u7BB1\uFF1Bdays\u6309\u7533\u62A5\u65E5\u671F\u7B5B\u9009\uFF0Ctop\u9650\u5236\u6587\u4EF6\u6570\uFF0C\u4FEE\u8BA2\u52FF\u91CD\u590D\u8BA1\u6570\u3002",
4500
+ parameters: typebox_exports.Object({
4501
+ symbol: typebox_exports.String({ description: "\u7F8E\u80A1ticker\u6216\u53D1\u884C\u4EBACIK" }),
4502
+ days: typebox_exports.Optional(typebox_exports.Number({ description: "\u7533\u62A5\u65E5\u671F\u7A97\u53E31..365\u5929\uFF0C\u9ED8\u8BA490" })),
4503
+ top: typebox_exports.Optional(typebox_exports.Number({ description: "\u6700\u591A\u89E3\u6790Form 4\u6587\u4EF6\u65701..20\uFF0C\u9ED8\u8BA410" }))
4504
+ }),
4505
+ async execute(_id, p) {
4506
+ const out = await runPy("sec_edgar.py", ["insider_trades", p.symbol, "--days", String(p.days ?? 90), "--top", String(p.top ?? 10)]);
4507
+ return asText(out);
4508
+ }
4509
+ });
4510
+ api.registerTool({
4511
+ name: "get_valuation_history",
4512
+ description: "\u67E5\u8BE2A/HK\u80A1\u7968\u5386\u53F2PE-TTM/PB\u3001\u5F53\u524D\u6B63\u503C\u5206\u4F4D\u548C10/25/50/75/90\u5206\u4F4DBand\uFF0C\u8FD4\u56DE\u5B9E\u9645\u91C7\u6837\u533A\u95F4\uFF1B\u4E8F\u635F\u4F30\u503C\u5206\u4F4D\u4E3Anull\u3002years=1..10\uFF0C\u6309\u5929\u7F13\u5B58\u3002HK\u914D\u7F6ELIXINGER_TOKEN\u65F6\u4F18\u5148\u7406\u674F\u4EC1\u975E\u91D1\u878D\u516C\u53F8\u65E5\u5386\u53F2\uFF0C\u5931\u8D25\u964D\u7EA7\u767E\u5EA6\uFF0C\u4E0D\u6DF7\u63A5\u6765\u6E90\u3002",
4513
+ parameters: typebox_exports.Object({
4514
+ symbol: typebox_exports.String({ description: "A\u80A1\u4EE3\u7801\u6216\u6E2F\u80A1.HK\u4EE3\u7801" }),
4515
+ years: typebox_exports.Optional(typebox_exports.Number({ description: "\u5386\u53F2\u7A97\u53E3\u5E74\u65701..10\uFF0C\u9ED8\u8BA45" }))
4516
+ }),
4517
+ async execute(_id, p) {
4518
+ const out = await runPy("value_data.py", ["valuation_history", p.symbol, "--years", String(p.years ?? 5)]);
4519
+ return asText(out);
4520
+ }
4521
+ });
4522
+ api.registerTool({
4523
+ name: "get_index_valuation",
4524
+ 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",
4525
+ parameters: typebox_exports.Object({
4526
+ symbol: typebox_exports.String({ description: "\u6307\u6570\u4EE3\u7801\u6216\u540D\u79F0\uFF0C\u5982000300\u3001\u6CAA\u6DF1300\u3001000985" }),
4527
+ years: typebox_exports.Optional(typebox_exports.Number({ description: "\u5386\u53F2\u7A97\u53E3\u5E74\u65701..10\uFF0C\u9ED8\u8BA45" }))
4528
+ }),
4529
+ async execute(_id, p) {
4530
+ const out = await runPy("value_data.py", ["index_valuation", p.symbol, "--years", String(p.years ?? 5)]);
4531
+ return asText(out);
4532
+ }
4533
+ });
4534
+ api.registerTool({
4535
+ name: "get_earnings_calendar",
4536
+ 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",
4537
+ parameters: typebox_exports.Object({
4538
+ 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" })),
4539
+ 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" })),
4540
+ top: typebox_exports.Optional(typebox_exports.Number({ description: "\u6BCF\u7C7B\u6700\u591A\u8FD4\u56DE\u6761\u65701..500\uFF0C\u9ED8\u8BA450" }))
4541
+ }),
4542
+ async execute(_id, p) {
4543
+ const out = await runPy("value_data.py", ["earnings_calendar", "--report-date", p.report_date ?? "", "--symbol", p.symbol ?? "", "--top", String(p.top ?? 50)]);
4544
+ return asText(out);
4545
+ }
4546
+ });
4547
+ api.registerTool({
4548
+ name: "get_shareholder_structure",
4549
+ 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",
4550
+ parameters: typebox_exports.Object({
4551
+ symbol: typebox_exports.String({ description: "A\u80A1\u4EE3\u7801\u6216\u6E2F\u80A1.HK\u4EE3\u7801" }),
4552
+ 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" }))
4553
+ }),
4554
+ async execute(_id, p) {
4555
+ const out = await runPy("value_data.py", ["shareholder_structure", p.symbol, "--report-date", p.report_date ?? ""]);
4556
+ return asText(out);
4557
+ }
4558
+ });
4559
+ api.registerTool({
4560
+ name: "get_etf_details",
4561
+ 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",
4562
+ parameters: typebox_exports.Object({
4563
+ 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" })),
4564
+ symbol: typebox_exports.String({ description: "A\u80A1ETF\u4EE3\u7801\uFF0C\u5982510300" }),
4565
+ benchmark: typebox_exports.Optional(typebox_exports.String({ description: "\u53EF\u9009\u57FA\u51C6\u4EE3\u7801\uFF0C\u5982sh000300\uFF1B\u4E0D\u731C\u6D4B\u57FA\u51C6" })),
4566
+ days: typebox_exports.Optional(typebox_exports.Number({ description: "\u51C0\u503C\u7A97\u53E3\u4EA4\u6613\u65E5\u657010..252\uFF0C\u9ED8\u8BA460" }))
4567
+ }),
4568
+ async execute(_id, p) {
4569
+ 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"] : []]);
4570
+ return asText(out);
4571
+ }
4572
+ });
4573
+ api.registerTool({
4574
+ name: "get_dividends",
4575
+ 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",
4576
+ parameters: typebox_exports.Object({
4577
+ market: typebox_exports.Optional(typebox_exports.Union([typebox_exports.Literal("A"), typebox_exports.Literal("HK")], { description: "\u4EC5ranking\u9009\u62E9\u5E02\u573A\uFF0C\u9ED8\u8BA4A" })),
4578
+ symbol: typebox_exports.Optional(typebox_exports.String({ description: "history/calendar\u5FC5\u586BA\u80A1\u6216\u6E2F\u80A1.HK\u4EE3\u7801\uFF1Branking\u7701\u7565" })),
4579
+ 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" })),
4580
+ 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" })),
4581
+ years: typebox_exports.Optional(typebox_exports.Number({ description: "\u5386\u53F2\u7A97\u53E3\u5E74\u65701..20\uFF0C\u9ED8\u8BA410" })),
4582
+ top: typebox_exports.Optional(typebox_exports.Number({ description: "\u6392\u540D\u6761\u65701..500\uFF0C\u9ED8\u8BA420" }))
4583
+ }),
4584
+ async execute(_id, p) {
4585
+ 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)]);
4586
+ return asText(out);
4587
+ }
4588
+ });
4460
4589
  api.registerTool({
4461
4590
  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\u3002\u9700\u8981\u539F\u59CB\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",
4591
+ 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
4592
  parameters: typebox_exports.Object({
4464
4593
  symbol: typebox_exports.String({
4465
4594
  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 +4615,7 @@ var index_default = definePluginEntry({
4486
4615
  });
4487
4616
  api.registerTool({
4488
4617
  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",
4618
+ 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
4619
  parameters: typebox_exports.Object({
4491
4620
  symbol: typebox_exports.String({ description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" })
4492
4621
  }),
@@ -4542,18 +4671,25 @@ var index_default = definePluginEntry({
4542
4671
  });
4543
4672
  api.registerTool({
4544
4673
  name: "get_financials",
4545
- description: "\u83B7\u53D6\u80A1\u7968\u8D22\u52A1\u6458\u8981\u3002A\u80A1\u8FD4\u56DE\u6700\u65B0\u62A5\u544A\u671F ROE/\u6BDB\u5229\u7387/\u51C0\u5229\u7387/\u8D1F\u503A\u7387/\u6D41\u52A8\u6BD4\u7387\uFF1B\u5176\u4ED6\u5E02\u573A\u8FD4\u56DE PE/PB/\u5E02\u503C/\u8425\u6536/\u51C0\u5229\u6DA6\u7B49\u3002A\u80A1\u4F30\u503C\u3001\u6210\u957F\u548C\u5206\u7EA2\u7528 get_fundamental_context",
4674
+ description: "\u83B7\u53D6\u80A1\u7968\u8D22\u52A1\u6458\u8981\u53CA\u5386\u53F2\u8D8B\u52BF\uFF0C\u6309\u5929\u7F13\u5B58\u3002A\u80A1annual=true\u4E0Eperiods=10\u53D6\u5341\u5E74\u5E74\u62A5\uFF1B\u6E2F\u80A1\u53EF\u914D\u7F6ELIXINGER_TOKEN\u53D6\u975E\u91D1\u878D\u516C\u53F8\u8D22\u52A1\u5E8F\u5217\uFF0C\u4FDD\u7559\u5E01\u79CD/\u62AB\u9732\u65E5/\u5B9E\u9645\u8D22\u5E74\uFF0C\u5386\u53F2\u6BD4\u7387\u5355\u4F4Dpercent\u3002\u6709\u6548Yahoo\u9876\u5C42\u5FEB\u7167\u6309\u6574\u7EC4\u4FDD\u7559\uFF0Ccurrency\u4E3A\u8D22\u62A5\u5E01\u79CD\u3001market_cap_currency\u4E3A\u5E02\u503C\u5E01\u79CD\u3001snapshot_source\u6807\u660E\u6765\u6E90\uFF1B\u7F3A\u5931\u503C\u53CAreport_date\u4E0D\u6DF7\u5165\u5386\u53F2\u6570\u503C/\u65E5\u671F\u3002\u7F3Atoken\u6216\u65E0\u6743\u9650\u964D\u7EA7\u539F\u6709\u6765\u6E90\u5E76\u6807\u6CE8\u4E0D\u8DB3\uFF0C\u4E0D\u8865\u9020\u7F3A\u5931\u3002\u4F30\u503C\u5386\u53F2\u7528get_valuation_history\uFF0C\u62AB\u9732\u6392\u671F\u7528get_earnings_calendar",
4546
4675
  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" })
4676
+ symbol: typebox_exports.String({ description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" }),
4677
+ annual: typebox_exports.Optional(typebox_exports.Boolean({ description: "\u53EA\u53D6\u5E74\u5EA6\u62A5\u544A\uFF0C\u9ED8\u8BA4false" })),
4678
+ periods: typebox_exports.Optional(
4679
+ 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" })
4680
+ )
4548
4681
  }),
4549
4682
  async execute(_id, params) {
4550
- const out = await runPy("stock_data.py", ["financials", params.symbol]);
4683
+ const args = ["financials", params.symbol];
4684
+ if (params.periods !== void 0 && params.periods !== 1) args.push("--periods", String(params.periods));
4685
+ if (params.annual) args.push("--annual");
4686
+ const out = await runPy("stock_data.py", args);
4551
4687
  return asText(out);
4552
4688
  }
4553
4689
  });
4554
4690
  api.registerTool({
4555
4691
  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",
4692
+ 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
4693
  parameters: typebox_exports.Object({
4558
4694
  symbol: typebox_exports.String({ description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" }),
4559
4695
  period: typebox_exports.Optional(
@@ -4564,17 +4700,24 @@ var index_default = definePluginEntry({
4564
4700
  ),
4565
4701
  count: typebox_exports.Optional(
4566
4702
  typebox_exports.Number({ description: "\u7528\u4E8E\u8BA1\u7B97\u6307\u6807\u7684K\u7EBF\u6761\u6570\uFF0C\u9ED8\u8BA4 120" })
4703
+ ),
4704
+ periods: typebox_exports.Optional(
4705
+ typebox_exports.String({
4706
+ 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'
4707
+ })
4567
4708
  )
4568
4709
  }),
4569
4710
  async execute(_id, params) {
4570
- const out = await runPy("technical.py", [
4711
+ const args = [
4571
4712
  "analyze",
4572
4713
  params.symbol,
4573
4714
  "--period",
4574
4715
  params.period ?? "daily",
4575
4716
  "--count",
4576
4717
  String(params.count ?? 120)
4577
- ]);
4718
+ ];
4719
+ if (params.periods) args.push("--periods", params.periods);
4720
+ const out = await runPy("technical.py", args);
4578
4721
  return asText(out);
4579
4722
  }
4580
4723
  });
@@ -4660,7 +4803,7 @@ var index_default = definePluginEntry({
4660
4803
  });
4661
4804
  api.registerTool({
4662
4805
  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\u5B5824\u5C0F\u65F6\u3002\u4EC5\u652F\u6301A\u80A1\uFF1B\u53CD\u5411\u67E5\u4E2A\u80A1\u6240\u5C5E\u677F\u5757\u7528 resolve_stock_sectors",
4806
+ 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
4807
  parameters: typebox_exports.Object({
4665
4808
  sector: typebox_exports.String({ description: "\u677F\u5757\u540D\u79F0\uFF08\u53EF\u6A21\u7CCA\uFF0C\u5982 \u521B\u65B0\u836F\u3001\u534A\u5BFC\u4F53\uFF09" }),
4666
4809
  board_type: typebox_exports.Optional(
@@ -4783,6 +4926,44 @@ var index_default = definePluginEntry({
4783
4926
  return asText(out);
4784
4927
  }
4785
4928
  });
4929
+ api.registerTool({
4930
+ name: "get_margin_trading",
4931
+ 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",
4932
+ parameters: typebox_exports.Object({
4933
+ symbol: typebox_exports.String({ description: "A\u80A1\u80A1\u7968\u4EE3\u7801\uFF0C\u5982 600519" }),
4934
+ include_ratio: typebox_exports.Optional(typebox_exports.Boolean({ description: "\u8FFD\u52A0\u540C\u65E5\u878D\u8D44\u4E70\u5165\u5360\u6BD4\uFF0C\u9ED8\u8BA4false" })),
4935
+ days: typebox_exports.Optional(
4936
+ typebox_exports.Number({ description: "\u8FD4\u56DE\u6700\u8FD1N\u4E2A\u4EA4\u6613\u65E5\uFF0C\u9ED8\u8BA4 10" })
4937
+ )
4938
+ }),
4939
+ async execute(_id, params) {
4940
+ const out = await runPy("stock_data.py", [
4941
+ "margin_trading",
4942
+ params.symbol,
4943
+ "--days",
4944
+ String(params.days ?? 10),
4945
+ ...params.include_ratio ? ["--include-ratio"] : []
4946
+ ]);
4947
+ return asText(out);
4948
+ }
4949
+ });
4950
+ api.registerTool({
4951
+ name: "get_northbound_flow",
4952
+ 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",
4953
+ parameters: typebox_exports.Object({
4954
+ days: typebox_exports.Optional(
4955
+ typebox_exports.Number({ description: "\u8FD4\u56DE\u6700\u8FD1N\u4E2A\u4EA4\u6613\u65E5\uFF0C\u9ED8\u8BA4 10" })
4956
+ )
4957
+ }),
4958
+ async execute(_id, params) {
4959
+ const out = await runPy("stock_data.py", [
4960
+ "northbound_flow",
4961
+ "--days",
4962
+ String(params.days ?? 10)
4963
+ ]);
4964
+ return asText(out);
4965
+ }
4966
+ });
4786
4967
  api.registerTool({
4787
4968
  name: "get_fundamental_context",
4788
4969
  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",
@@ -4799,7 +4980,7 @@ var index_default = definePluginEntry({
4799
4980
  });
4800
4981
  api.registerTool({
4801
4982
  name: "screen_stocks",
4802
- description: "\u5168\u5E02\u573A\u80A1\u7968\u7B5B\u9009\uFF08AlphaSift L1 \u591A\u56E0\u5B50\u786C\u7B5B + \u5E02\u573A\u60C5\u7EEA\u8C03\u8282\uFF09\u3002\u6309PE/PB/\u5E02\u503C/\u6362\u624B\u7387/\u6DA8\u8DCC\u5E45/\u91CF\u6BD4\u7B49\u56E0\u5B50\u8FC7\u6EE4\u548C\u8BC4\u5206\uFF0C\u53EF\u7528 l2 \u5F00\u542F\u8D28\u91CF/\u6210\u957F/\u52A8\u91CF/\u6CE2\u52A8\u7387/\u8D44\u91D1\u6D41\u589E\u5F3A",
4983
+ description: "\u5168\u5E02\u573A\u80A1\u7968\u7B5B\u9009\uFF08AlphaSift L1 \u591A\u56E0\u5B50\u786C\u7B5B + \u5E02\u573A\u60C5\u7EEA\u8C03\u8282\uFF09\u3002\u6309PE/PB/\u5E02\u503C/\u6362\u624B\u7387/\u6DA8\u8DCC\u5E45/\u91CF\u6BD4\u7B49\u56E0\u5B50\u8FC7\u6EE4\u548C\u8BC4\u5206\uFF0C\u53EF\u7528 l2 \u5F00\u542F\u8D28\u91CF/\u6210\u957F/\u52A8\u91CF/\u6CE2\u52A8\u7387/\u8D44\u91D1\u6D41\u589E\u5F3A\u3002\u663E\u5F0F\u7B5B\u9009\u6761\u4EF6\u7F3A\u5C11\u6570\u636E\u65F6\u62A5error\uFF0Cfilters_applied\u53EA\u5217\u5B9E\u9645\u6267\u884C\u7684\u6761\u4EF6",
4803
4984
  parameters: typebox_exports.Object({
4804
4985
  market: typebox_exports.Optional(
4805
4986
  typebox_exports.Union(
@@ -4833,7 +5014,7 @@ var index_default = definePluginEntry({
4833
5014
  });
4834
5015
  api.registerTool({
4835
5016
  name: "run_backtest",
4836
- description: "\u7B56\u7565\u56DE\u6D4B\uFF08AlphaEvo\uFF09\u3002\u8BFB\u53D6YAML\u7B56\u7565\u5B9A\u4E49\uFF0C\u5728\u5386\u53F2\u6570\u636E\u4E0A\u6A21\u62DF\u4EA4\u6613\uFF0C\u8F93\u51FA\u6536\u76CA\u7387/\u56DE\u64A4/\u80DC\u7387\u7B49\u6307\u6807\u3002\u53EA\u60F3\u77E5\u9053\u5355\u4E2A\u6280\u672F\u4FE1\u53F7\u7684\u5386\u53F2\u80DC\u7387\u7528\u66F4\u8F7B\u91CF\u7684 evaluate_signal",
5017
+ description: "\u7B56\u7565\u56DE\u6D4B\uFF08AlphaEvo\uFF09\u3002\u8BFB\u53D6YAML\u7B56\u7565\u5B9A\u4E49\uFF0C\u5728\u5386\u53F2\u6570\u636E\u4E0A\u6A21\u62DF\u4EA4\u6613\uFF0C\u8F93\u51FA\u6536\u76CA\u7387/\u56DE\u64A4/\u80DC\u7387\u7B49\u6307\u6807\u3002\u53EA\u60F3\u77E5\u9053\u5355\u4E2A\u6280\u672F\u4FE1\u53F7\u7684\u5386\u53F2\u80DC\u7387\u7528\u66F4\u8F7B\u91CF\u7684 evaluate_signal\u3002period\u4E3A\u5B9E\u9645\u6570\u636E\u671F\u95F4\uFF0Crequested_period\u4FDD\u7559\u8BF7\u6C42\u671F\u95F4\uFF0Cwarnings\u63D0\u793A\u8986\u76D6\u5DEE\u5F02\uFF1B\u5E74\u5316\u6309\u5B9E\u9645\u671F\u95F4\u8BA1\u7B97",
4837
5018
  parameters: typebox_exports.Object({
4838
5019
  strategy: typebox_exports.String({ description: "\u7B56\u7565YAML\u6587\u4EF6\u8DEF\u5F84" }),
4839
5020
  symbol: typebox_exports.String({ description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" }),
@@ -5107,7 +5288,7 @@ var index_default = definePluginEntry({
5107
5288
  });
5108
5289
  api.registerTool({
5109
5290
  name: "screen_risk",
5110
- description: "A\u80A1\u98CE\u9669\u4E13\u9879\u7B5B\u67E5 \u2014 \u68C0\u67E5\u4F30\u503C\u3001\u6280\u672F\u9884\u8B66\u3001\u89E3\u7981\u3001\u51CF\u6301\u3001\u4E1A\u7EE9\u9884\u8B66\u3001\u76D1\u7BA1\u548C\u884C\u4E1A\u653F\u7B56\uFF0C\u8FD4\u56DE\u98CE\u9669\u8BC4\u7EA7\u548C veto_buy\u3002\u65B0\u95FB\u641C\u7D22\u547D\u4E2D\u662F\u5F85\u6838\u5B9E\u7EBF\u7D22\uFF0C\u4E0D\u662F\u5DF2\u8BC1\u5B9E\u98CE\u9669",
5291
+ description: "A\u80A1\u98CE\u9669\u4E13\u9879\u7B5B\u67E5 \u2014 \u68C0\u67E5\u4F30\u503C\u3001\u6280\u672F\u9884\u8B66\u3001\u89E3\u7981\u3001\u51CF\u6301\u3001\u4E1A\u7EE9\u9884\u8B66\u3001\u76D1\u7BA1\u548C\u884C\u4E1A\u653F\u7B56\uFF0C\u8FD4\u56DE\u98CE\u9669\u8BC4\u7EA7\u548C veto_buy\u3002\u65B0\u95FB\u641C\u7D22\u547D\u4E2D\u662F\u5F85\u6838\u5B9E\u7EBF\u7D22\uFF0C\u4E0D\u662F\u5DF2\u8BC1\u5B9E\u98CE\u9669\u3002data_complete\u548Cwarnings\u6807\u660E\u8986\u76D6\uFF1B\u6570\u636E\u4E0D\u8DB3\u65F6risk_level=unknown\uFF0Crisk_score\u6216veto_buy\u53EF\u4E3Anull\uFF0C\u4E0D\u80FD\u89C6\u4E3A\u4F4E\u98CE\u9669",
5111
5292
  parameters: typebox_exports.Object({
5112
5293
  symbol: typebox_exports.String({ description: "A\u80A1\u80A1\u7968\u4EE3\u7801\uFF0C\u5982 600519" }),
5113
5294
  name: typebox_exports.Optional(
@@ -5274,13 +5455,30 @@ var index_default = definePluginEntry({
5274
5455
  });
5275
5456
  api.registerTool({
5276
5457
  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\u3002\u4EC5\u6E32\u67D3\uFF0C\u4E0D\u4FDD\u5B58\u4E0D\u63A8\u9001",
5458
+ 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
5459
  parameters: typebox_exports.Object({
5279
- report: typebox_exports.Object({}, { additionalProperties: true, description: "\u7ED3\u6784\u5316\u5E02\u573A\u590D\u76D8" })
5460
+ report: typebox_exports.Object({}, { additionalProperties: true, description: "\u7ED3\u6784\u5316\u5E02\u573A\u590D\u76D8" }),
5461
+ 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
5462
  }),
5281
5463
  async execute(_id, params) {
5282
5464
  const b64 = Buffer.from(JSON.stringify(params.report), "utf-8").toString("base64");
5283
- const out = await runPy("report_renderer.py", ["market", "--input-b64", b64]);
5465
+ const out = await runPy("report_renderer.py", [
5466
+ "market",
5467
+ "--input-b64",
5468
+ b64,
5469
+ ...params.save ? ["--save"] : []
5470
+ ]);
5471
+ return asText(out);
5472
+ }
5473
+ });
5474
+ api.registerTool({
5475
+ name: "get_review_history",
5476
+ 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",
5477
+ parameters: typebox_exports.Object({
5478
+ limit: typebox_exports.Optional(typebox_exports.Number({ description: "\u8FD4\u56DE\u6761\u6570\uFF0C\u9ED8\u8BA4 10" }))
5479
+ }),
5480
+ async execute(_id, params) {
5481
+ const out = await runPy("market_review.py", ["history", "--limit", String(params.limit ?? 10)]);
5284
5482
  return asText(out);
5285
5483
  }
5286
5484
  });
@@ -5337,7 +5535,7 @@ var index_default = definePluginEntry({
5337
5535
  });
5338
5536
  api.registerTool({
5339
5537
  name: "check_alert_rules",
5340
- description: "\u65E0\u72B6\u6001\u544A\u8B66\u89C4\u5219\u68C0\u67E5 \u2014 \u4F20\u5165\u89C4\u5219\u6570\u7EC4\uFF0C\u8FD4\u56DE\u5F53\u524D\u662F\u5426\u89E6\u53D1\u3002\u89C4\u5219\u7C7B\u578B\uFF1Aprice_below/price_above/change_pct_above/change_pct_below/volume_ratio_above/anomaly/risk_veto/risk_level_at_least\u3002\u4E0D\u505A\u8C03\u5EA6\u4E0D\u5B58\u5386\u53F2",
5538
+ description: "\u65E0\u72B6\u6001\u544A\u8B66\u89C4\u5219\u68C0\u67E5 \u2014 \u4F20\u5165\u89C4\u5219\u6570\u7EC4\uFF0C\u8FD4\u56DE\u5F53\u524D\u662F\u5426\u89E6\u53D1\u3002\u89C4\u5219\u7C7B\u578B\uFF1Aprice_below/price_above/change_pct_above/change_pct_below/volume_ratio_above/anomaly/risk_veto/risk_level_at_least\u3002\u4E0D\u505A\u8C03\u5EA6\u4E0D\u5B58\u5386\u53F2\u3002\u4F9D\u8D56\u6570\u636E\u4E0D\u53EF\u7528\u65F6evaluated\u6761\u76EE\u542Berror\uFF0Cmeta.warnings\u63D0\u793A\u7F3A\u5931\uFF0Ctriggered=false\u4E0D\u4EE3\u8868\u68C0\u67E5\u6210\u529F",
5341
5539
  parameters: typebox_exports.Object({
5342
5540
  symbol: typebox_exports.String({ description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" }),
5343
5541
  rules: typebox_exports.Array(
@@ -5395,7 +5593,7 @@ var index_default = definePluginEntry({
5395
5593
  });
5396
5594
  api.registerTool({
5397
5595
  name: "evaluate_signals",
5398
- description: "\u8BC4\u4F30\u5230\u671F\u4FE1\u53F7\uFF1A\u62C9\u53D6\u8BB0\u5F55\u65E5\u4E4B\u540E\u7684\u65E5K\uFF0C\u5224\u5B9A target_hit/stop_hit/timeout \u5E76\u8BA1\u7B97\u6536\u76CA\uFF0C\u56DE\u5199\u5B58\u50A8\u3002\u8BB0\u5F55\u5EFA\u8BAE\u7528 record_signal\uFF0C\u80DC\u7387\u590D\u76D8\u7528 get_signal_summary",
5596
+ description: "\u8BC4\u4F30\u5230\u671F\u4FE1\u53F7\uFF1A\u62C9\u53D6\u8BB0\u5F55\u65E5\u4E4B\u540E\u7684\u65E5K\uFF0C\u5224\u5B9A target_hit/stop_hit/timeout \u5E76\u8BA1\u7B97\u6536\u76CA\uFF0C\u56DE\u5199\u5B58\u50A8\u3002\u8BB0\u5F55\u5EFA\u8BAE\u7528 record_signal\uFF0C\u80DC\u7387\u590D\u76D8\u7528 get_signal_summary\u3002\u5386\u53F2K\u7EBF\u672A\u8986\u76D6\u8BB0\u5F55\u65E5\u65F6skipped_no_data\u5E76\u4FDD\u6301\u672A\u7ED3\u7B97\uFF0C\u4E0D\u80FD\u7528\u8F83\u65B0\u884C\u60C5\u4EE3\u66FF",
5399
5597
  parameters: typebox_exports.Object({
5400
5598
  symbol: typebox_exports.Optional(
5401
5599
  typebox_exports.String({ description: "\u80A1\u7968\u4EE3\u7801\uFF08\u53EF\u9009\uFF0C\u53EA\u8BC4\u4F30\u8BE5\u80A1\u7684\u4FE1\u53F7\uFF09" })