dsh-stock-analysis 0.2.6 → 0.2.8

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 (36) hide show
  1. package/README.md +17 -1
  2. package/dist/index.js +820 -24
  3. package/package.json +1 -1
  4. package/schemas/market_review_schema.json +12 -5
  5. package/schemas/report_schema.json +65 -1
  6. package/scripts/cli-timeout.mjs +27 -0
  7. package/scripts/json-input.mjs +26 -0
  8. package/skills/bull-trend/SKILL.md +11 -1
  9. package/skills/bull-trend/references/monthly-trend-strategy.md +47 -0
  10. package/skills/bull-trend/references/trend-horizons.md +43 -0
  11. package/skills/bull-trend/references/trend-temperature.md +57 -0
  12. package/skills/bull-trend/scripts/market_trend.py +78 -0
  13. package/skills/event-driven/SKILL.md +4 -0
  14. package/skills/growth-quality/SKILL.md +4 -0
  15. package/skills/market-review/SKILL.md +2 -0
  16. package/skills/stock-analysis/SKILL.md +17 -3
  17. package/skills/stock-analysis/references/stateless-analysis.md +66 -0
  18. package/skills/stock-screener/SKILL.md +5 -1
  19. package/skills/strategy-backtest/SKILL.md +19 -0
  20. package/templates/market_review/full.md.j2 +7 -0
  21. package/templates/stock_analysis/_evidence.md.j2 +11 -0
  22. package/templates/stock_analysis/brief.md.j2 +2 -0
  23. package/templates/stock_analysis/full.md.j2 +2 -0
  24. package/tools/_subproc.py +66 -11
  25. package/tools/backtest.py +143 -19
  26. package/tools/capabilities.py +12 -0
  27. package/tools/cli_budgets.json +27 -0
  28. package/tools/gather.py +4 -6
  29. package/tools/market_review.py +30 -9
  30. package/tools/screener.py +57 -15
  31. package/tools/signal_tracker.py +77 -6
  32. package/tools/stateless_analysis.py +630 -0
  33. package/tools/stock_data.py +90 -15
  34. package/tools/technical.py +186 -0
  35. package/tools/trend_strategy.py +365 -0
  36. package/tools/watchlist_context.py +18 -7
package/dist/index.js CHANGED
@@ -1,25 +1,152 @@
1
+ // scripts/json-input.mjs
2
+ import { mkdtemp, writeFile, rm } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ async function withJsonInput(input, execute) {
6
+ let directory;
7
+ let result;
8
+ try {
9
+ directory = await mkdtemp(join(tmpdir(), "stock-analysis-"));
10
+ const path = join(directory, "input.json");
11
+ await writeFile(path, JSON.stringify(input), { encoding: "utf8", mode: 384 });
12
+ result = await execute(path);
13
+ } catch {
14
+ result = JSON.stringify({ error: "Analysis command failed; check input and interpreter/dependencies" });
15
+ } finally {
16
+ if (directory) {
17
+ try {
18
+ await rm(directory, { recursive: true, force: true });
19
+ } catch {
20
+ result = JSON.stringify({ error: "Could not remove temporary analysis input" });
21
+ }
22
+ }
23
+ }
24
+ return result;
25
+ }
26
+
27
+ // tools/cli_budgets.json
28
+ var cli_budgets_default = {
29
+ default: 120,
30
+ "stock_data.py:market_snapshot": 240,
31
+ "screener.py:screen": 390,
32
+ "sec_edgar.py:holdings": 300,
33
+ "technical.py:analyze": 150,
34
+ "market_regime.py:detect": 270,
35
+ "backtest.py:run": 270,
36
+ "risk_screening.py:screen": 450,
37
+ "signal_tracker.py:evaluate": 300,
38
+ "stock_data.py:market_stats": 240,
39
+ "market_review.py:review": 300,
40
+ "anomaly_detect.py:detect": 390,
41
+ "position_context.py:analyze": 300,
42
+ "alert_rules.py:check": 480,
43
+ "technical.py:calculate_ma": 150,
44
+ "value_data.py:dividends": 300,
45
+ "value_data.py:etf_details": 450,
46
+ "watchlist.py:analyze": 30,
47
+ "watchlist_context.py:build": 30,
48
+ l2_batch: 360,
49
+ l2_workers: 6,
50
+ watchlist_item: 480,
51
+ "stateless_analysis.py:event_study": 300,
52
+ "stateless_analysis.py:robustness": 660,
53
+ "trend_strategy.py:fetch": 660
54
+ };
55
+
56
+ // scripts/cli-timeout.mjs
57
+ import { basename } from "node:path";
58
+ function commandTimeout(script, args) {
59
+ const key = `${basename(script)}:${args[0] ?? ""}`;
60
+ let budget = cli_budgets_default[key] ?? cli_budgets_default.default;
61
+ const option = (name2, fallback) => args.includes(name2) ? args[args.indexOf(name2) + 1] ?? fallback : fallback;
62
+ const positiveInt = (value, fallback) => /^\d+$/.test(String(value)) && Number(value) > 0 ? Number(value) : fallback;
63
+ if (key === "screener.py:screen") {
64
+ budget += Math.ceil(positiveInt(option("--top", 20), 20) / cli_budgets_default.l2_workers) * cli_budgets_default.l2_batch;
65
+ } else if (key === "watchlist.py:analyze" || key === "watchlist_context.py:build") {
66
+ const count = String(args[1] ?? "").split(",").filter((s) => s.trim()).length;
67
+ const workers = positiveInt(option("--workers", 3), 3);
68
+ budget += Math.ceil(count / workers) * cli_budgets_default.watchlist_item;
69
+ if (key === "watchlist_context.py:build") {
70
+ budget += Math.ceil(count / Math.min(workers * 2, 6)) * cli_budgets_default["anomaly_detect.py:detect"];
71
+ if (args.includes("--include-market-review")) budget += 3 * cli_budgets_default["market_review.py:review"] + 30;
72
+ }
73
+ } else if (key === "market_review.py:review" && option("--market", "A") === "all") {
74
+ budget = 3 * budget + 30;
75
+ } else if (key === "technical.py:analyze" && args.includes("--periods")) {
76
+ const periods = String(option("--periods", "daily")).split(",").map((p) => p.trim()).filter(Boolean);
77
+ budget *= (/* @__PURE__ */ new Set([option("--period", "daily"), ...periods])).size;
78
+ }
79
+ return budget * 1e3 + 3e4;
80
+ }
81
+
1
82
  // dsh/index.ts
2
83
  import { existsSync, readdirSync, readFileSync } from "node:fs";
3
84
  import * as cp from "node:child_process";
4
85
  import { promisify } from "node:util";
5
- import { dirname, join as join2 } from "node:path";
86
+ import { dirname, join as join3 } from "node:path";
6
87
  import { fileURLToPath } from "node:url";
7
88
  import {
8
- defineTool
89
+ defineTool as defineTool2
9
90
  } from "@deepseek-ai/dsh-tools";
10
91
 
11
92
  // scripts/venv-python.mjs
12
- import { join } from "node:path";
93
+ import { join as join2 } from "node:path";
13
94
  var isWin = process.platform === "win32";
14
95
  function venvPythonPath(rootDir) {
15
- return join(rootDir, ".venv", isWin ? "Scripts" : "bin", isWin ? "python.exe" : "python3");
96
+ return join2(rootDir, ".venv", isWin ? "Scripts" : "bin", isWin ? "python.exe" : "python3");
97
+ }
98
+
99
+ // dsh/discovery.ts
100
+ import { defineTool } from "@deepseek-ai/dsh-tools";
101
+ var SEARCH = "stock_tool_search";
102
+ function registerToolDiscovery(ctx, names) {
103
+ if (typeof ctx.on !== "function" || typeof ctx.tools.get !== "function" || typeof ctx.tools.presentAs !== "function" || names.size === 0 || ctx.tools.get(SEARCH)) return;
104
+ const states = /* @__PURE__ */ new WeakMap();
105
+ ctx.tools.register(defineTool({
106
+ name: SEARCH,
107
+ description: "\u641C\u7D22\u5E76\u52A0\u8F7D\u80A1\u7968\u5206\u6790\u5DE5\u5177\uFF1B\u652F\u6301\u4E2D\u6587\u3001\u82F1\u6587\u5173\u952E\u8BCD\u6216\u786E\u5207\u5DE5\u5177\u540D\uFF0C\u5982\u8D22\u52A1\u3001get_quote\u3001run_backtest\u3002\u5339\u914D\u5DE5\u5177\u5C06\u5728\u4E0B\u4E00\u6B21\u6A21\u578B\u8BF7\u6C42\u63D0\u4F9B\u5B8C\u6574\u53C2\u6570\uFF0C\u53EF\u6309\u539F\u540D\u76F4\u63A5\u8C03\u7528\u3002\u4E0D\u4F1A\u6267\u884C\u5206\u6790\u6216\u6269\u5927\u6743\u9650\u3002",
108
+ parameters: {
109
+ query: { type: "string", required: true, description: "\u5DE5\u5177\u540D\u79F0\u6216\u529F\u80FD\u5173\u952E\u8BCD" },
110
+ limit: { type: "integer", description: "\u6700\u591A\u52A0\u8F7D\u6570\u91CF\uFF0C\u9ED8\u8BA45\uFF0C\u8303\u56F41\u523020" }
111
+ },
112
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
113
+ async execute({ query, limit = 5 }, exec) {
114
+ const needle = query.trim().toLowerCase();
115
+ const terms = [...new Set(needle.match(/[a-z0-9_]+|\p{Script=Han}/gu) ?? [])];
116
+ if (!terms.length || !Number.isInteger(limit) || limit < 1 || limit > 20) {
117
+ return JSON.stringify({ error: "query must contain searchable text and limit must be an integer from 1 to 20" });
118
+ }
119
+ const state = exec.agent && states.get(exec.agent);
120
+ if (!state) return JSON.stringify({ error: "Tool discovery is unavailable for this agent; use its directly exposed tools" });
121
+ const candidates = state.catalog.filter((tool) => ctx.tools.get(tool.name, exec.agent)).map((tool) => ({ tool, text: `${tool.name} ${tool.description}`.toLowerCase() }));
122
+ const weights = terms.map((term) => 1 / (1 + candidates.filter(({ text }) => text.includes(term)).length));
123
+ const matches = candidates.map(({ tool, text }) => {
124
+ const score = (tool.name === needle ? 1e3 : 0) + (text.includes(needle) ? 10 : 0) + terms.reduce((sum, term, index) => sum + weights[index] * (tool.name.includes(term) ? 3 : text.includes(term) ? 1 : 0), 0);
125
+ return { tool, score };
126
+ }).filter((match) => match.score > 0).sort((a, b) => b.score - a.score || a.tool.name.localeCompare(b.tool.name)).slice(0, limit);
127
+ for (const { tool } of matches) state.loaded.add(tool.name);
128
+ return JSON.stringify({ loaded: matches.map(({ tool }) => ({ name: tool.name, description: tool.description })) });
129
+ }
130
+ }));
131
+ ctx.on("system-prompt/assemble", async (_assembly, context, next) => {
132
+ const result = await next();
133
+ if (!context.scope) return result;
134
+ if (!result.tools.some((tool) => tool.name === SEARCH) || result.tools.some((tool) => tool.name === "run_code")) {
135
+ states.delete(context.scope);
136
+ return result;
137
+ }
138
+ const state = states.get(context.scope) ?? { catalog: [], loaded: /* @__PURE__ */ new Set() };
139
+ state.catalog = result.tools.filter((tool) => names.has(tool.name));
140
+ states.set(context.scope, state);
141
+ return { ...result, tools: result.tools.filter((tool) => !names.has(tool.name) || state.loaded.has(tool.name)) };
142
+ });
16
143
  }
17
144
 
18
145
  // dsh/index.ts
19
146
  var defaultExecutor = async (bin, argv) => {
20
147
  const exec = promisify(cp.execFile);
21
148
  try {
22
- const { stdout } = await exec(bin, argv, { maxBuffer: 32 * 1024 * 1024 });
149
+ const { stdout } = await exec(bin, argv, { maxBuffer: 32 * 1024 * 1024, timeout: commandTimeout(argv[0], argv.slice(1)) });
23
150
  return stdout;
24
151
  } catch (error) {
25
152
  const stdout = error.stdout;
@@ -28,7 +155,7 @@ var defaultExecutor = async (bin, argv) => {
28
155
  if (data && typeof data.error === "string") return stdout;
29
156
  } catch {
30
157
  }
31
- return JSON.stringify({ error: "Python command failed; check interpreter/dependencies" });
158
+ return JSON.stringify({ error: error.killed ? "Python command timed out" : "Python command failed; check interpreter/dependencies" });
32
159
  }
33
160
  };
34
161
  var executor = defaultExecutor;
@@ -36,21 +163,21 @@ function __setExecutor(fn) {
36
163
  executor = fn;
37
164
  }
38
165
  var here = dirname(fileURLToPath(import.meta.url));
39
- var toolsDir = join2(here, "..", "tools");
166
+ var toolsDir = join3(here, "..", "tools");
40
167
  var pkgRoot = dirname(toolsDir);
41
168
  var isWin2 = process.platform === "win32";
42
169
  function pythonBin() {
43
- for (const root of [pkgRoot, join2(pkgRoot, "..")]) {
170
+ for (const root of [pkgRoot, join3(pkgRoot, "..")]) {
44
171
  const candidate = venvPythonPath(root);
45
172
  if (existsSync(candidate)) return candidate;
46
173
  }
47
174
  return isWin2 ? "python" : "python3";
48
175
  }
49
176
  async function runPy(script, args) {
50
- return executor(pythonBin(), [join2(toolsDir, script), ...args]);
177
+ return executor(pythonBin(), [join3(toolsDir, script), ...args]);
51
178
  }
52
179
  function pyTool(opts) {
53
- return defineTool({
180
+ return defineTool2({
54
181
  name: opts.name,
55
182
  description: opts.description,
56
183
  parameters: opts.parameters,
@@ -63,7 +190,7 @@ function pyTool(opts) {
63
190
  }
64
191
  });
65
192
  }
66
- var skillsDir = join2(here, "..", "skills");
193
+ var skillsDir = join3(here, "..", "skills");
67
194
  function frontmatterValue(raw, key) {
68
195
  const block = raw.match(/^---\r?\n([\s\S]*?)\r?\n---/);
69
196
  const line = block?.[1].match(new RegExp(`^${key}:\\s*(.+)$`, "m"));
@@ -73,7 +200,7 @@ function registerSkills(ctx) {
73
200
  if (!existsSync(skillsDir)) return;
74
201
  for (const child of readdirSync(skillsDir, { withFileTypes: true })) {
75
202
  if (!child.isDirectory()) continue;
76
- const skillFile = join2(skillsDir, child.name, "SKILL.md");
203
+ const skillFile = join3(skillsDir, child.name, "SKILL.md");
77
204
  if (!existsSync(skillFile)) continue;
78
205
  const raw = readFileSync(skillFile, "utf-8");
79
206
  ctx.skills.register({
@@ -84,13 +211,17 @@ function registerSkills(ctx) {
84
211
  content: raw.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, "").trimStart(),
85
212
  source: "bundled",
86
213
  path: skillFile,
87
- resourceBase: { kind: "directory", path: join2(skillsDir, child.name) }
214
+ resourceBase: { kind: "directory", path: join3(skillsDir, child.name) }
88
215
  });
89
216
  }
90
217
  }
91
218
  var name = "stock-analysis";
92
219
  var inject = ["tools", "skills"];
93
- function apply(ctx) {
220
+ function apply(ctx, config = {}) {
221
+ if (config.toolDiscovery !== void 0 && typeof config.toolDiscovery !== "boolean") {
222
+ throw new TypeError("toolDiscovery must be a boolean");
223
+ }
224
+ const previousTools = new Set(ctx.tools.schemas?.().map((tool) => tool.name));
94
225
  ctx.tools.register(
95
226
  pyTool({
96
227
  name: "get_announcements",
@@ -315,7 +446,7 @@ function apply(ctx) {
315
446
  ctx.tools.register(
316
447
  pyTool({
317
448
  name: "get_kline",
318
- 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",
449
+ 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\u3002\u6BCF\u6761\u8BB0\u5F55\u9644 source\u3001UTC fetched_at\u3001data_as_of \u548C adjusted\uFF1B\u975EA\u80A1\u590D\u6743\u53E3\u5F84\u53EF\u80FD\u4E3Atotal_return/qfq/unknown\uFF0C\u672A\u77E5\u4E0D\u80FD\u5047\u5B9A\u5DF2\u590D\u6743\u3002\u90E8\u5206\u6765\u6E90\u9644 adjustment_factor\uFF08\u590D\u6743\u4EF7\u683C/\u539F\u59CB\u4EF7\u683C\uFF09\uFF1B\u7F3A\u5931\u4E0D\u80FD\u731C\u6D4B\u6362\u7B97\u7CFB\u6570\u3002",
319
450
  parameters: {
320
451
  symbol: {
321
452
  type: "string",
@@ -343,7 +474,7 @@ function apply(ctx) {
343
474
  ctx.tools.register(
344
475
  pyTool({
345
476
  name: "get_quote",
346
- 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",
477
+ 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\u3002\u8FD4\u56DE source\u3001UTC fetched_at \u548C\u63D0\u4F9B\u65B9 data_as_of\uFF08\u672A\u77E5\u4E3Anull\uFF09\uFF1Bas_of_basis\u533A\u5206\u63D0\u4F9B\u65B9\u65F6\u95F4\u4E0E\u4EA4\u6613\u65E5\u5386\u63A8\u65AD\uFF0C\u91C7\u96C6\u65F6\u95F4\u4E0D\u7B49\u4E8E\u884C\u60C5\u65F6\u95F4\u3002",
347
478
  parameters: {
348
479
  symbol: { type: "string", required: true, description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" }
349
480
  },
@@ -408,7 +539,7 @@ function apply(ctx) {
408
539
  ctx.tools.register(
409
540
  pyTool({
410
541
  name: "get_technical_analysis",
411
- 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",
542
+ 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\u9644 trend_temperature\uFF08\u5B9E\u9A8C\u6027EMA\u5DEE/ATR\u63CF\u8FF0\uFF1Bdirection\u4E3A\u5747\u7EBF\u65B9\u5411\uFF1Bvalidation_status=not_validated\uFF0C\u975E\u661F\u7403\u6307\u6807\uFF0C\u4E03\u6863\u4E0D\u4F5C\u5165\u573A\u4F9D\u636E\uFF1B\u53E6\u9644 trend_horizons\uFF1A21/63/252\u6839\u65E5K\u6708\u5EA6\u52A8\u91CF\uFF0C\u5EFA\u8BAEcount=360\uFF0C\u975E\u6982\u7387\u3001\u672A\u9A8C\u8BC1\uFF09\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",
412
543
  parameters: {
413
544
  symbol: { type: "string", required: true, description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" },
414
545
  period: {
@@ -667,7 +798,7 @@ function apply(ctx) {
667
798
  ctx.tools.register(
668
799
  pyTool({
669
800
  name: "screen_stocks",
670
- 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",
801
+ 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\u3002\u5019\u9009factor_coverage\u5217\u51FA\u53EF\u7528/\u7F3A\u5931\u56E0\u5B50\u3001\u52A0\u6743\u8986\u76D6\u7387\u548Ceffective_weights\uFF1BL1\u4E0EL2\u5747\u6309\u53EF\u7528\u56E0\u5B50\u5F52\u4E00\u5316\u540E\u6392\u5E8F\uFF0C\u7F3A\u5931/\u975E\u6709\u9650\u503C\u4E0D\u6309\u96F6\u5206\u8BA1\uFF1BL2\u53E6\u8FD4\u56DEeffective_scores\u4F9B\u7ED3\u5408\u5E02\u573A\u7CFB\u6570\u590D\u7B97final\uFF0C\u6309\u53EF\u7528\u56E0\u5B50\u91CD\u5F52\u4E00\u5316\uFF0C\u9AD8\u5206\u4E0D\u4EE3\u8868\u6570\u636E\u5B8C\u6574\u3002\u9009\u80A1\u9884\u7B97\u6309\u5019\u9009\u6570\u91CF\u53CA\u91C7\u96C6\u6279\u6B21\u8BA1\u7B97\uFF0Ctop\u987B\u4E3A\u6B63\u6574\u6570\u3002",
671
802
  parameters: {
672
803
  market: {
673
804
  type: "string",
@@ -687,10 +818,50 @@ function apply(ctx) {
687
818
  }
688
819
  })
689
820
  );
821
+ ctx.tools.register(defineTool2({
822
+ name: "analyze_trend_strategy",
823
+ description: "\u6708\u5EA6\u53F3\u4FA7\u8D8B\u52BF\u7B56\u7565\uFF1A\u76F4\u63A5\u4F20\u540C\u5E02\u573AA/HK/US\u80A1\u7968\u4EE3\u7801\uFF0C\u81EA\u52A8\u83B7\u53D6\u65E5K\uFF0C\u8F93\u51FA\u6708\u5EA6\u65B0\u5165/\u6301\u6709/\u9000\u51FA\u4E0E\u9006\u6CE2\u52A8\u9884\u7B97\u3002as_of\u9ED8\u8BA4\u6700\u8FD1\u5DF2\u6536\u76D8\u4EA4\u6613\u65E5\uFF0C\u6301\u4ED3\u53EF\u9009\u4E14\u4E0D\u4FDD\u5B58\uFF0C\u4E0D\u81EA\u52A8\u4E0B\u5355\uFF1B\u8DE8\u6837\u672C\u4ECDnot_validated\u3002",
824
+ parameters: {
825
+ "symbols": {
826
+ "type": "array",
827
+ "items": {
828
+ "type": "string"
829
+ },
830
+ "description": "\u540C\u4E00\u5E02\u573A\u7684\u5B8C\u6574\u80A1\u7968\u6C60\uFF0C1..100\u53EA\uFF1BA\u5982600036\uFF0CHK\u59820700.HK\uFF0CUS\u5982AAPL",
831
+ "required": true
832
+ },
833
+ "as_of": {
834
+ "type": "string",
835
+ "description": "\u53EF\u9009\u5DF2\u6536\u76D8\u622A\u6B62\u65E5\u671FYYYY-MM-DD\uFF0C\u9ED8\u8BA4\u8BE5\u5E02\u573A\u6700\u8FD1\u5DF2\u6536\u76D8\u4EA4\u6613\u65E5"
836
+ },
837
+ "held_symbols": {
838
+ "type": "array",
839
+ "items": {
840
+ "type": "string"
841
+ },
842
+ "description": "\u53EF\u9009\uFF0Cas_of\u65F6\u771F\u5B9E\u6301\u80A1\u4EE3\u7801\uFF0C\u5FC5\u987B\u5728\u80A1\u7968\u6C60\u4E2D\uFF1B\u7701\u7565\u4EE3\u8868\u521D\u59CB\u7A7A\u4ED3\uFF0C\u4E0D\u4FDD\u5B58\u8D26\u6237"
843
+ },
844
+ "pending_exit_symbols": {
845
+ "type": "array",
846
+ "items": {
847
+ "type": "string"
848
+ },
849
+ "description": "\u53EF\u9009\uFF0C\u771F\u5B9E\u6301\u80A1\u4E2D\u6B64\u524D\u5DF2\u9501\u5B9A\u4E14\u672A\u6210\u4EA4\u7684\u9000\u51FA\u4EE3\u7801"
850
+ },
851
+ "slots": {
852
+ "type": "number",
853
+ "description": "\u53EF\u9009\u56FA\u5B9A\u5BB9\u91CFK\uFF0C\u9ED8\u8BA4ceil(N/3)\uFF0C\u4E0D\u5F97\u5C0F\u4E8E\u771F\u5B9E\u6301\u80A1\u6570\u91CF"
854
+ }
855
+ },
856
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
857
+ async execute(params) {
858
+ return withJsonInput(params, (path) => runPy("trend_strategy.py", ["fetch", "--input", path]));
859
+ }
860
+ }));
690
861
  ctx.tools.register(
691
862
  pyTool({
692
863
  name: "run_backtest",
693
- 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",
864
+ 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\u3002\u9ED8\u8BA4\u524D\u65E5\u6536\u76D8\u4FE1\u53F7\u3001\u6B21\u65E5\u5F00\u76D8\u6210\u4EA4\uFF1BYAML simulation.execution=same_close\u53EF\u590D\u73B0\u65E7\u5047\u8BBE\u3002execution\u8FD4\u56DE\u6A21\u578B\u3001\u963B\u6B62\u6210\u4EA4\u6B21\u6570\u548C\u672A\u6A21\u62DF\u7EA6\u675F\uFF1B\u96F6\u6210\u4EA4\u91CF\u53CA\u5E26\u5386\u53F2\u9650\u4EF7\u7684\u4E00\u5B57\u677F\u4E0D\u6210\u4EA4\u3002\u652F\u6301 monthly_momentum\uFF1A\u6708\u521D\u9996\u6839\u6709\u6548\u65E5K\u6536\u76D8\u89C2\u5BDF\u8FC7\u53BBperiod\u6839\u5BF9\u6570\u6536\u76CA\uFF0C\u6B21\u65E5\u5F00\u76D8\uFF1B\u957F\u5468\u671F\u9700\u9884\u70ED\u3002",
694
865
  parameters: {
695
866
  strategy: { type: "string", required: true, description: "\u7B56\u7565YAML\u6587\u4EF6\u8DEF\u5F84" },
696
867
  symbol: { type: "string", required: true, description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" },
@@ -978,7 +1149,7 @@ function apply(ctx) {
978
1149
  ctx.tools.register(
979
1150
  pyTool({
980
1151
  name: "get_market_review",
981
- description: "\u5927\u76D8\u590D\u76D8 \u2014 \u83B7\u53D6\u5E02\u573A\u65E5\u5EA6\u590D\u76D8\u6570\u636E\uFF0C\u5305\u542B\u6307\u6570\u3001\u6DA8\u8DCC\u7EDF\u8BA1\u3001\u677F\u5757\u6392\u540D\u3001\u65B0\u95FB\u3001\u5E02\u573A\u6E29\u5EA6\u4E0E\u7B56\u7565\u5EFA\u8BAE\u3002\u590D\u76D8\u7C7B\u9700\u6C42\u7684\u9996\u9009\uFF0C\u65E0\u9700\u518D\u5206\u522B\u8C03\u6307\u6570/\u7EDF\u8BA1/\u677F\u5757\u5DE5\u5177",
1152
+ description: "\u5927\u76D8\u590D\u76D8 \u2014 \u83B7\u53D6\u5E02\u573A\u65E5\u5EA6\u590D\u76D8\u6570\u636E\uFF0C\u5305\u542B\u6307\u6570\u3001\u6DA8\u8DCC\u7EDF\u8BA1\u3001\u677F\u5757\u6392\u540D\u3001\u65B0\u95FB\u3001\u5E02\u573A\u6E29\u5EA6\u4E0E\u7B56\u7565\u5EFA\u8BAE\u3002\u590D\u76D8\u7C7B\u9700\u6C42\u7684\u9996\u9009\uFF0C\u65E0\u9700\u518D\u5206\u522B\u8C03\u6307\u6570/\u7EDF\u8BA1/\u677F\u5757\u5DE5\u5177\u3002\u6570\u636E\u4E0D\u8DB3\u65F6\u6E29\u5EA6score\u53CAstrategy_stance\u4E3Anull\uFF0C\u4FE1\u53F7unknown\uFF1Bwarnings/data_quality\u8BF4\u660E\u9650\u5236",
982
1153
  parameters: {
983
1154
  market: {
984
1155
  type: "string",
@@ -1058,7 +1229,7 @@ function apply(ctx) {
1058
1229
  ctx.tools.register(
1059
1230
  pyTool({
1060
1231
  name: "render_stock_report",
1061
- description: "\u80A1\u7968\u5206\u6790\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 skill \u63D0\u4F9B\u7684 report_schema \u4E3A\u51C6\uFF0C\u4E0D\u8981\u81EA\u9020\u5B57\u6BB5\u3002template: brief|full\u3002\u5168\u90E8\u5206\u6790\u5B8C\u6210\u540E\u7684\u6700\u540E\u4E00\u6B65\u8C03\u7528\u3002\u4EC5\u6E32\u67D3\uFF0C\u4E0D\u4FDD\u5B58\u4E0D\u63A8\u9001",
1232
+ description: "\u80A1\u7968\u5206\u6790\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 skill \u63D0\u4F9B\u7684 report_schema \u4E3A\u51C6\uFF0C\u4E0D\u8981\u81EA\u9020\u5B57\u6BB5\u3002template: brief|full\u3002\u5168\u90E8\u5206\u6790\u5B8C\u6210\u540E\u7684\u6700\u540E\u4E00\u6B65\u8C03\u7528\u3002\u4EC5\u6E32\u67D3\uFF0C\u4E0D\u4FDD\u5B58\u4E0D\u63A8\u9001\u3002report\u53EF\u5305\u542Bevidence\uFF08path/label/value/source/as_of\uFF09\u4E0Edata_quality\uFF08flags/limitations\uFF09\uFF0Cbrief/full\u5747\u5C55\u793A\u8BC1\u636E\u548C\u9650\u5236\u3002",
1062
1233
  parameters: {
1063
1234
  report: {
1064
1235
  type: "object",
@@ -1118,7 +1289,7 @@ function apply(ctx) {
1118
1289
  ctx.tools.register(
1119
1290
  pyTool({
1120
1291
  name: "build_watchlist_context",
1121
- description: "\u81EA\u9009\u80A1\u4E0A\u4E0B\u6587\u5305 \u2014 \u5BF9\u591A\u53EA\u80A1\u7968\u8F93\u51FA\u8BC4\u5206/\u8D8B\u52BF/\u5F02\u5E38/\u98CE\u9669/\u5EFA\u8BAE next_tools \u7684 agent \u53CB\u597D\u6458\u8981\u3002\u5BBF\u4E3B agent \u51B3\u5B9A\u5982\u4F55\u5199\u65E5\u62A5\u6216\u6DF1\u5165\u5206\u6790",
1292
+ description: "\u81EA\u9009\u80A1\u4E0A\u4E0B\u6587\u5305 \u2014 \u5BF9\u591A\u53EA\u80A1\u7968\u8F93\u51FA\u8BC4\u5206/\u8D8B\u52BF/\u5F02\u5E38/\u98CE\u9669/\u5EFA\u8BAE next_tools \u7684 agent \u53CB\u597D\u6458\u8981\u3002\u5BBF\u4E3B agent \u51B3\u5B9A\u5982\u4F55\u5199\u65E5\u62A5\u6216\u6DF1\u5165\u5206\u6790\u3002\u5F02\u52A8\u68C0\u67E5\u5931\u8D25\u65F6anomaly_status=unavailable\u3001anomaly_count=null\uFF0C\u4FDD\u7559anomaly_error/warnings\uFF1B\u6C47\u603B\u8BA1\u5165partial",
1122
1293
  parameters: {
1123
1294
  symbols: { type: "string", required: true, description: "\u9017\u53F7\u5206\u9694\u7684\u80A1\u7968\u4EE3\u7801\u5217\u8868" },
1124
1295
  include_market_review: {
@@ -1223,7 +1394,7 @@ function apply(ctx) {
1223
1394
  ctx.tools.register(
1224
1395
  pyTool({
1225
1396
  name: "evaluate_signals",
1226
- 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",
1397
+ 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\u3002\u539F\u59CB\u4FE1\u53F7\u4EF7\u4E0E\u590D\u6743K\u7EBF\u987B\u6709\u53EF\u6838\u5B9E\u7684adjustment_factor\uFF0C\u7F3A\u5931\u5219skipped_price_basis\u4FDD\u6301\u672A\u7ED3\u7B97\u3002CLI\u9884\u7B97300\u79D2\uFF0C\u622A\u6B62\u524D\u8FD4\u56DE\u5E76\u4FDD\u5B58\u5DF2\u5B8C\u6210\u7ED3\u679C\uFF1Bcomplete/deferred/warnings\u8BF4\u660E\u672A\u5904\u7406\u8BB0\u5F55\uFF0C\u4E0B\u6B21\u53EF\u91CD\u8BD5",
1227
1398
  parameters: {
1228
1399
  symbol: { type: "string", description: "\u80A1\u7968\u4EE3\u7801\uFF08\u53EF\u9009\uFF0C\u53EA\u8BC4\u4F30\u8BE5\u80A1\u7684\u4FE1\u53F7\uFF09" }
1229
1400
  },
@@ -1238,7 +1409,7 @@ function apply(ctx) {
1238
1409
  ctx.tools.register(
1239
1410
  pyTool({
1240
1411
  name: "get_signal_summary",
1241
- description: "\u4FE1\u53F7\u80DC\u7387\u6C47\u603B\uFF08\u53EF\u6309 source/symbol/status \u8FC7\u6EE4\uFF09\uFF1A\u80DC\u7387\u3001\u5E73\u5747\u6536\u76CA\u3001\u7ED3\u679C\u5206\u5E03\u4E0E\u660E\u7EC6",
1412
+ description: "\u4FE1\u53F7\u80DC\u7387\u6C47\u603B\uFF08\u53EF\u6309 source/symbol/status \u8FC7\u6EE4\uFF09\uFF1A\u80DC\u7387\u3001\u5E73\u5747\u6536\u76CA\u3001\u7ED3\u679C\u5206\u5E03\u4E0E\u660E\u7EC6\u3002by_source\u9644avg_return_pct\u3001return_samples\u548Csample_warning\uFF1B\u4EC5\u89C2\u5BDF\u6027\u590D\u76D8\uFF0C\u6837\u672C\u5C11\u4E0D\u80FD\u8BA4\u5B9A\u7B56\u7565\u6709\u6548\u3002",
1242
1413
  parameters: {
1243
1414
  source: { type: "string", description: "\u6309\u4FE1\u53F7\u6765\u6E90\u8FC7\u6EE4\uFF08\u53EF\u9009\uFF09" },
1244
1415
  symbol: { type: "string", description: "\u6309\u80A1\u7968\u4EE3\u7801\u8FC7\u6EE4\uFF08\u53EF\u9009\uFF09" },
@@ -1272,7 +1443,632 @@ function apply(ctx) {
1272
1443
  }
1273
1444
  })
1274
1445
  );
1446
+ ctx.tools.register(defineTool2({
1447
+ name: "compare_stocks",
1448
+ description: "\u65E0\u72B6\u6001\u540C\u884C\u6307\u6807\u6BD4\u8F83\uFF1A\u5148\u7528\u73B0\u6709\u8D22\u52A1/\u884C\u60C5\u5DE5\u5177\u53D6\u6570\uFF0C\u518D\u4F20companies\uFF1B\u4EC5\u76F8\u540Cunit/basis/period\u53EF\u6392\u5E8F\uFF0C\u7F3A\u5931\u4E0D\u586B\u96F6\uFF0C\u4E0D\u751F\u6210\u4E70\u5356\u7EFC\u5408\u5206\u3002",
1449
+ parameters: {
1450
+ "companies": {
1451
+ "type": "array",
1452
+ "items": {
1453
+ "type": "object",
1454
+ "properties": {
1455
+ "symbol": {
1456
+ "type": "string",
1457
+ "description": "\u552F\u4E00\u80A1\u7968\u4EE3\u7801",
1458
+ "required": true
1459
+ },
1460
+ "period": {
1461
+ "type": "string",
1462
+ "description": "\u7EDF\u4E00\u53EF\u6BD4\u671F\u95F4\uFF1B\u8D22\u52A1\u7528\u62A5\u544A\u671F\uFF0C\u4F30\u503C\u7528\u4F30\u503C\u65E5",
1463
+ "required": true
1464
+ },
1465
+ "metrics": {
1466
+ "type": "array",
1467
+ "items": {
1468
+ "type": "object",
1469
+ "properties": {
1470
+ "name": {
1471
+ "type": "string",
1472
+ "description": "\u6307\u6807\u540D\uFF0C\u5982pe/roe/net_income",
1473
+ "required": true
1474
+ },
1475
+ "value": {
1476
+ "oneOf": [
1477
+ {
1478
+ "type": "number"
1479
+ },
1480
+ {
1481
+ "type": "null"
1482
+ }
1483
+ ],
1484
+ "description": "\u6709\u9650\u6570\u503C\uFF1B\u7F3A\u5931\u4E3Anull",
1485
+ "required": true
1486
+ },
1487
+ "unit": {
1488
+ "type": "string",
1489
+ "description": "\u7CBE\u786E\u5355\u4F4D\uFF0C\u5982multiple/percent/fraction/CNY/USD",
1490
+ "required": true
1491
+ },
1492
+ "basis": {
1493
+ "type": "string",
1494
+ "description": "\u53E3\u5F84\uFF0C\u5982TTM/annual/consolidated\uFF1B\u533A\u5206\u7D2F\u8BA1\u4E0E\u5355\u5B63",
1495
+ "required": true
1496
+ },
1497
+ "source": {
1498
+ "type": "string",
1499
+ "description": "\u539F\u59CB\u8BC1\u636EURL\u6216\u5B57\u6BB5\u8DEF\u5F84"
1500
+ }
1501
+ },
1502
+ "additionalProperties": false
1503
+ },
1504
+ "description": "\u7ED3\u6784\u5316\u6307\u6807\uFF0C\u5355\u4F4D\u3001\u53E3\u5F84\u660E\u786E\uFF0C\u7F3A\u5931\u4E0D\u586B\u96F6",
1505
+ "required": true
1506
+ }
1507
+ },
1508
+ "additionalProperties": false
1509
+ },
1510
+ "description": "2..30\u5BB6\u516C\u53F8\uFF0C\u8C03\u7528\u65B9\u786E\u8BA4\u53EF\u6BD4\u6027",
1511
+ "required": true
1512
+ }
1513
+ },
1514
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1515
+ async execute(params) {
1516
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["peers", "--input", path]));
1517
+ }
1518
+ }));
1519
+ ctx.tools.register(defineTool2({
1520
+ name: "analyze_disclosure_changes",
1521
+ description: "\u65E0\u72B6\u6001\u516C\u544A\u8D22\u62A5\u6BD4\u8F83\uFF1A\u4F20\u65B0\u65E7\u6B63\u6587\u53CA\u6307\u6807\uFF0C\u8FD4\u56DE\u53D8\u66F4\u884C\u53F7\u3001\u6765\u6E90\u4E0E\u8D22\u52A1\u53D8\u5316\uFF1B\u8D1F/\u96F6\u57FA\u6570\u589E\u957F\u7387\u4E3Anull\u3002\u4E0D\u4E0B\u8F7DPDF\u3001\u4E0D\u4EE3\u66FF\u7ECF\u6D4E\u89E3\u8BFB\u3002",
1522
+ parameters: {
1523
+ "previous": {
1524
+ "type": "object",
1525
+ "properties": {
1526
+ "text": {
1527
+ "type": "string",
1528
+ "description": "\u5DF2\u6838\u5B9E\u6B63\u6587\uFF0C\u6700\u591A200000\u5B57\u7B26\uFF1B\u4FDD\u7559\u6362\u884C\uFF0CPDF\u9700\u5BBF\u4E3B\u63D0\u53D6",
1529
+ "required": true
1530
+ },
1531
+ "source": {
1532
+ "type": "string",
1533
+ "description": "\u539F\u6587URL\u6216\u6587\u6863\u6807\u8BC6",
1534
+ "required": true
1535
+ },
1536
+ "period": {
1537
+ "type": "string",
1538
+ "description": "\u62A5\u544A\u671F\uFF0C\u59822025\u5E74\u5EA6",
1539
+ "required": true
1540
+ },
1541
+ "metrics": {
1542
+ "type": "array",
1543
+ "items": {
1544
+ "type": "object",
1545
+ "properties": {
1546
+ "name": {
1547
+ "type": "string",
1548
+ "description": "\u6307\u6807\u540D\uFF0C\u5982pe/roe/net_income",
1549
+ "required": true
1550
+ },
1551
+ "value": {
1552
+ "oneOf": [
1553
+ {
1554
+ "type": "number"
1555
+ },
1556
+ {
1557
+ "type": "null"
1558
+ }
1559
+ ],
1560
+ "description": "\u6709\u9650\u6570\u503C\uFF1B\u7F3A\u5931\u4E3Anull",
1561
+ "required": true
1562
+ },
1563
+ "unit": {
1564
+ "type": "string",
1565
+ "description": "\u7CBE\u786E\u5355\u4F4D\uFF0C\u5982multiple/percent/fraction/CNY/USD",
1566
+ "required": true
1567
+ },
1568
+ "basis": {
1569
+ "type": "string",
1570
+ "description": "\u53E3\u5F84\uFF0C\u5982TTM/annual/consolidated\uFF1B\u533A\u5206\u7D2F\u8BA1\u4E0E\u5355\u5B63",
1571
+ "required": true
1572
+ },
1573
+ "source": {
1574
+ "type": "string",
1575
+ "description": "\u539F\u59CB\u8BC1\u636EURL\u6216\u5B57\u6BB5\u8DEF\u5F84"
1576
+ }
1577
+ },
1578
+ "additionalProperties": false
1579
+ },
1580
+ "description": "\u7ED3\u6784\u5316\u6307\u6807\uFF0C\u5355\u4F4D\u3001\u53E3\u5F84\u660E\u786E\uFF0C\u7F3A\u5931\u4E0D\u586B\u96F6",
1581
+ "required": true
1582
+ }
1583
+ },
1584
+ "additionalProperties": false,
1585
+ "required": true
1586
+ },
1587
+ "current": {
1588
+ "type": "object",
1589
+ "properties": {
1590
+ "text": {
1591
+ "type": "string",
1592
+ "description": "\u5DF2\u6838\u5B9E\u6B63\u6587\uFF0C\u6700\u591A200000\u5B57\u7B26\uFF1B\u4FDD\u7559\u6362\u884C\uFF0CPDF\u9700\u5BBF\u4E3B\u63D0\u53D6",
1593
+ "required": true
1594
+ },
1595
+ "source": {
1596
+ "type": "string",
1597
+ "description": "\u539F\u6587URL\u6216\u6587\u6863\u6807\u8BC6",
1598
+ "required": true
1599
+ },
1600
+ "period": {
1601
+ "type": "string",
1602
+ "description": "\u62A5\u544A\u671F\uFF0C\u59822025\u5E74\u5EA6",
1603
+ "required": true
1604
+ },
1605
+ "metrics": {
1606
+ "type": "array",
1607
+ "items": {
1608
+ "type": "object",
1609
+ "properties": {
1610
+ "name": {
1611
+ "type": "string",
1612
+ "description": "\u6307\u6807\u540D\uFF0C\u5982pe/roe/net_income",
1613
+ "required": true
1614
+ },
1615
+ "value": {
1616
+ "oneOf": [
1617
+ {
1618
+ "type": "number"
1619
+ },
1620
+ {
1621
+ "type": "null"
1622
+ }
1623
+ ],
1624
+ "description": "\u6709\u9650\u6570\u503C\uFF1B\u7F3A\u5931\u4E3Anull",
1625
+ "required": true
1626
+ },
1627
+ "unit": {
1628
+ "type": "string",
1629
+ "description": "\u7CBE\u786E\u5355\u4F4D\uFF0C\u5982multiple/percent/fraction/CNY/USD",
1630
+ "required": true
1631
+ },
1632
+ "basis": {
1633
+ "type": "string",
1634
+ "description": "\u53E3\u5F84\uFF0C\u5982TTM/annual/consolidated\uFF1B\u533A\u5206\u7D2F\u8BA1\u4E0E\u5355\u5B63",
1635
+ "required": true
1636
+ },
1637
+ "source": {
1638
+ "type": "string",
1639
+ "description": "\u539F\u59CB\u8BC1\u636EURL\u6216\u5B57\u6BB5\u8DEF\u5F84"
1640
+ }
1641
+ },
1642
+ "additionalProperties": false
1643
+ },
1644
+ "description": "\u7ED3\u6784\u5316\u6307\u6807\uFF0C\u5355\u4F4D\u3001\u53E3\u5F84\u660E\u786E\uFF0C\u7F3A\u5931\u4E0D\u586B\u96F6",
1645
+ "required": true
1646
+ }
1647
+ },
1648
+ "additionalProperties": false,
1649
+ "required": true
1650
+ },
1651
+ "max_changes": {
1652
+ "type": "number",
1653
+ "description": "\u53D8\u5316\u4E0A\u96501..100\uFF0C\u9ED8\u8BA430"
1654
+ }
1655
+ },
1656
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1657
+ async execute(params) {
1658
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["disclosure", "--input", path]));
1659
+ }
1660
+ }));
1661
+ ctx.tools.register(defineTool2({
1662
+ name: "analyze_portfolio_risk",
1663
+ description: "\u65E0\u72B6\u6001\u73B0\u8D27\u591A\u5934\u7EC4\u5408\u98CE\u9669\uFF1A\u8F93\u5165\u6301\u4ED3\u3001\u57FA\u51C6\u5E01\u79CD\u73B0\u91D1\u4E0E\u6C47\u7387\uFF0C\u8FD4\u56DE\u96C6\u4E2D\u5EA6\u3001\u5E01\u79CD/\u884C\u4E1A\u655E\u53E3\u3001\u4EF7\u683C\u76C8\u4E8F\u548C\u6B62\u635F\u60C5\u666F\u3002\u7F3A\u6C47\u7387\u62A5\u9519\uFF1B\u4E0D\u4FDD\u5B58\u8D26\u6237\u3002",
1664
+ parameters: {
1665
+ "positions": {
1666
+ "type": "array",
1667
+ "items": {
1668
+ "type": "object",
1669
+ "properties": {
1670
+ "symbol": {
1671
+ "type": "string",
1672
+ "description": "\u552F\u4E00\u4EE3\u7801\uFF0C\u91CD\u590D\u6301\u4ED3\u5148\u6C47\u603B",
1673
+ "required": true
1674
+ },
1675
+ "quantity": {
1676
+ "type": "number",
1677
+ "description": "\u6B63\u6301\u4ED3\u6570\u91CF",
1678
+ "required": true
1679
+ },
1680
+ "price": {
1681
+ "type": "number",
1682
+ "description": "\u6B63\u73B0\u4EF7",
1683
+ "required": true
1684
+ },
1685
+ "currency": {
1686
+ "type": "string",
1687
+ "description": "\u6301\u4ED3\u5E01\u79CD\uFF0C\u5982CNY/USD/HKD",
1688
+ "required": true
1689
+ },
1690
+ "cost": {
1691
+ "type": "number",
1692
+ "description": "\u540C\u5E01\u79CD\u6B63\u6210\u672C\u4EF7\uFF0C\u53EF\u9009"
1693
+ },
1694
+ "stop_price": {
1695
+ "type": "number",
1696
+ "description": "\u540C\u5E01\u79CD\u6B63\u6B62\u635F\u4EF7\uFF0C\u53EF\u9009"
1697
+ },
1698
+ "sector": {
1699
+ "type": "string",
1700
+ "description": "\u7EDF\u4E00\u884C\u4E1A\u5206\u7C7B\uFF0C\u53EF\u9009"
1701
+ },
1702
+ "as_of": {
1703
+ "type": "string",
1704
+ "description": "\u5B9E\u9645\u4F30\u503C\u65F6\u70B9\uFF0C\u5EFA\u8BAEISO8601"
1705
+ }
1706
+ },
1707
+ "additionalProperties": false
1708
+ },
1709
+ "description": "1..100\u4E2A\u73B0\u8D27\u591A\u5934\u6301\u4ED3",
1710
+ "required": true
1711
+ },
1712
+ "base_currency": {
1713
+ "type": "string",
1714
+ "description": "\u57FA\u51C6\u5E01\u79CD",
1715
+ "required": true
1716
+ },
1717
+ "cash": {
1718
+ "type": "number",
1719
+ "description": "\u57FA\u51C6\u5E01\u79CD\u73B0\u91D1\uFF0C\u975E\u8D1F",
1720
+ "required": true
1721
+ },
1722
+ "fx_rates": {
1723
+ "type": "array",
1724
+ "items": {
1725
+ "type": "object",
1726
+ "properties": {
1727
+ "currency": {
1728
+ "type": "string",
1729
+ "description": "\u552F\u4E00\u975E\u57FA\u51C6\u5E01\u79CD",
1730
+ "required": true
1731
+ },
1732
+ "rate": {
1733
+ "type": "number",
1734
+ "description": "\u4E00\u5355\u4F4D\u8BE5\u5E01\u79CD\u5BF9\u5E94\u591A\u5C11\u57FA\u51C6\u5E01\u79CD\uFF0C\u6B63\u6570",
1735
+ "required": true
1736
+ }
1737
+ },
1738
+ "additionalProperties": false
1739
+ },
1740
+ "description": "\u663E\u5F0F\u73B0\u4EF7\u6C47\u7387\uFF1B\u57FA\u51C6\u5E01\u79CD\u9690\u542B1\uFF0C\u4E0D\u5F97\u91CD\u590D"
1741
+ },
1742
+ "histories": {
1743
+ "type": "array",
1744
+ "items": {
1745
+ "type": "object",
1746
+ "properties": {
1747
+ "symbol": {
1748
+ "type": "string",
1749
+ "description": "\u5BF9\u5E94\u552F\u4E00\u6301\u4ED3\u80A1\u7968",
1750
+ "required": true
1751
+ },
1752
+ "prices": {
1753
+ "type": "array",
1754
+ "items": {
1755
+ "type": "object",
1756
+ "properties": {
1757
+ "date": {
1758
+ "type": "string",
1759
+ "description": "YYYY-MM-DD\uFF0C\u552F\u4E00\u65E5\u671F",
1760
+ "required": true
1761
+ },
1762
+ "close": {
1763
+ "type": "number",
1764
+ "description": "\u6B63\u6709\u9650\u6536\u76D8\u4EF7",
1765
+ "required": true
1766
+ }
1767
+ },
1768
+ "additionalProperties": false
1769
+ },
1770
+ "description": "\u5B8C\u6574\u65E5K\u6536\u76D8\u5E8F\u5217\uFF0C2..20000\u6761\uFF0C\u4E0D\u5F97\u8DE8\u80A1\u7968\u6216\u6DF7\u7528\u590D\u6743\u53E3\u5F84",
1771
+ "required": true
1772
+ }
1773
+ },
1774
+ "additionalProperties": false
1775
+ },
1776
+ "description": "\u53EF\u9009\u5386\u53F2\uFF0C\u5171\u540C\u65E5\u671F\u672C\u5E01\u4EF7\u683C\u6536\u76CA\u76F8\u5173\u6027\uFF0C\u4E0D\u8BA1\u6C47\u7387"
1777
+ }
1778
+ },
1779
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1780
+ async execute(params) {
1781
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["portfolio", "--input", path]));
1782
+ }
1783
+ }));
1784
+ ctx.tools.register(defineTool2({
1785
+ name: "calculate_position_size",
1786
+ description: "\u65E0\u72B6\u6001\u591A\u5934\u4ED3\u4F4D\u9884\u7B97\uFF1A\u540C\u5E01\u79CD\u91D1\u989D\uFF0C\u6309\u73B0\u91D1/\u98CE\u9669\u9884\u7B97/\u6700\u5927\u4ED3\u4F4D/\u4EA4\u6613\u5355\u4F4D\u53D6\u6700\u5C0F\u6570\u91CF\uFF0C\u53CC\u8FB9\u8D39\u7528\u548C\u6ED1\u70B9\u53C2\u4E0E\u6B62\u635F\u60C5\u666F\uFF1B\u4E0D\u6267\u884C\u4EA4\u6613\u3002",
1787
+ parameters: {
1788
+ "equity": {
1789
+ "type": "number",
1790
+ "description": "\u603B\u6743\u76CA\uFF0C\u6B63\u6570",
1791
+ "required": true
1792
+ },
1793
+ "cash": {
1794
+ "type": "number",
1795
+ "description": "\u53EF\u7528\u73B0\u91D1\uFF0C0..equity",
1796
+ "required": true
1797
+ },
1798
+ "entry_price": {
1799
+ "type": "number",
1800
+ "description": "\u8BA1\u5212\u5165\u573A\u4EF7\uFF0C\u6B63\u6570",
1801
+ "required": true
1802
+ },
1803
+ "stop_price": {
1804
+ "type": "number",
1805
+ "description": "\u6B63\u6B62\u635F\u4EF7\uFF0C\u4F4E\u4E8E\u5165\u573A\u4EF7",
1806
+ "required": true
1807
+ },
1808
+ "risk_fraction": {
1809
+ "type": "number",
1810
+ "description": "\u5355\u7B14\u98CE\u9669\u5360\u6743\u76CA\u6BD4\u4F8B0..1\uFF0C\u59820.01",
1811
+ "required": true
1812
+ },
1813
+ "lot_size": {
1814
+ "type": "number",
1815
+ "description": "\u6B63\u6574\u6570\u4EA4\u6613\u5355\u4F4D\uFF0C\u7528\u6237\u786E\u8BA4\uFF0C\u4E0D\u731C\u6E2F\u80A1\u6BCF\u624B\u6570\u91CF",
1816
+ "required": true
1817
+ },
1818
+ "max_position_fraction": {
1819
+ "type": "number",
1820
+ "description": "\u672C\u6B21\u4E70\u5165\u6700\u5927\u8D44\u91D1\u5360\u6BD40..1\uFF0C\u9ED8\u8BA41\uFF1B\u5DF2\u6709\u540C\u80A1\u6301\u4ED3\u5148\u6263\u51CF\u989D\u5EA6"
1821
+ },
1822
+ "fee_rate": {
1823
+ "type": "number",
1824
+ "description": "\u6BCF\u8FB9\u6BD4\u4F8B\u8D39\u75280..0.1\uFF0C\u9ED8\u8BA40\uFF1B\u4E0D\u542B\u672A\u63D0\u4F9B\u7A0E\u8D39/\u6700\u4F4E\u6536\u8D39"
1825
+ },
1826
+ "slippage_rate": {
1827
+ "type": "number",
1828
+ "description": "\u6BCF\u8FB9\u6ED1\u70B90..0.1\uFF0C\u9ED8\u8BA40"
1829
+ }
1830
+ },
1831
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1832
+ async execute(params) {
1833
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["position_size", "--input", path]));
1834
+ }
1835
+ }));
1836
+ ctx.tools.register(defineTool2({
1837
+ name: "analyze_event_study",
1838
+ description: "\u65E0\u72B6\u6001\u4E8B\u4EF6\u7814\u7A76\uFF1A\u63D0\u4F9B\u540C\u5E02\u573A\u80A1\u7968\u53CA\u57FA\u51C6\u5B8C\u6574\u4EF7\u683C\u3001\u4E8B\u4EF6\u65E5\u671F\uFF1B\u4E8B\u4EF6\u524D\u4E00\u4EA4\u6613\u65E5\u6536\u76D8\u4E3A\u57FA\u70B9\uFF0C\u8BA1\u7B97\u4EA4\u6613\u65E5\u7A97\u53E3\u6536\u76CA\u5DEE\u3002\u7F3A\u7A97\u53E3/\u57FA\u51C6\u4E3Anull\uFF0C\u6807\u6CE8\u91CD\u53E0\uFF0C\u4E0D\u63A8\u65AD\u56E0\u679C\u3002",
1839
+ parameters: {
1840
+ "prices": {
1841
+ "type": "array",
1842
+ "items": {
1843
+ "type": "object",
1844
+ "properties": {
1845
+ "date": {
1846
+ "type": "string",
1847
+ "description": "YYYY-MM-DD\uFF0C\u552F\u4E00\u65E5\u671F",
1848
+ "required": true
1849
+ },
1850
+ "close": {
1851
+ "type": "number",
1852
+ "description": "\u6B63\u6709\u9650\u6536\u76D8\u4EF7",
1853
+ "required": true
1854
+ }
1855
+ },
1856
+ "additionalProperties": false
1857
+ },
1858
+ "description": "\u5B8C\u6574\u65E5K\u6536\u76D8\u5E8F\u5217\uFF0C2..20000\u6761\uFF0C\u4E0D\u5F97\u8DE8\u80A1\u7968\u6216\u6DF7\u7528\u590D\u6743\u53E3\u5F84"
1859
+ },
1860
+ "benchmark_prices": {
1861
+ "type": "array",
1862
+ "items": {
1863
+ "type": "object",
1864
+ "properties": {
1865
+ "date": {
1866
+ "type": "string",
1867
+ "description": "YYYY-MM-DD\uFF0C\u552F\u4E00\u65E5\u671F",
1868
+ "required": true
1869
+ },
1870
+ "close": {
1871
+ "type": "number",
1872
+ "description": "\u6B63\u6709\u9650\u6536\u76D8\u4EF7",
1873
+ "required": true
1874
+ }
1875
+ },
1876
+ "additionalProperties": false
1877
+ },
1878
+ "description": "\u5B8C\u6574\u65E5K\u6536\u76D8\u5E8F\u5217\uFF0C2..20000\u6761\uFF0C\u4E0D\u5F97\u8DE8\u80A1\u7968\u6216\u6DF7\u7528\u590D\u6743\u53E3\u5F84"
1879
+ },
1880
+ "event_dates": {
1881
+ "type": "array",
1882
+ "items": {
1883
+ "type": "string",
1884
+ "description": "YYYY-MM-DD\uFF0C\u76D8\u540E\u516C\u544A\u4F20\u4E0B\u4E00\u4EA4\u6613\u65E5"
1885
+ },
1886
+ "description": "1..100\u4E2A\u552F\u4E00\u4E8B\u4EF6\u65E5",
1887
+ "required": true
1888
+ },
1889
+ "price_basis": {
1890
+ "type": "string",
1891
+ "description": "\u4EC5\u663E\u5F0Fprices\u6A21\u5F0F\u5FC5\u9700\uFF1B\u4EE3\u7801\u6A21\u5F0F\u62A5\u544A\u5B9E\u9645\u63D0\u4F9B\u65B9\u6807\u8BB0\uFF0C\u7F3A\u5931\u4E3Aunknown\uFF0C\u987B\u6838\u5B9E"
1892
+ },
1893
+ "horizons": {
1894
+ "type": "array",
1895
+ "items": {
1896
+ "type": "number",
1897
+ "description": "0=\u4E8B\u4EF6\u65E5\uFF0C1=\u4E0B\u4E00\u4EA4\u6613\u65E5\uFF1B\u6574\u65700..250"
1898
+ },
1899
+ "description": "1..20\u4E2A\u7A97\u53E3\uFF0C\u9ED8\u8BA40/1/5/10/20"
1900
+ },
1901
+ "start_date": {
1902
+ "type": "string",
1903
+ "description": "\u4EE3\u7801\u6A21\u5F0F\u5FC5\u9700\uFF0CYYYY-MM-DD\uFF0C\u5305\u542B\u4E8B\u4EF6\u524D\u57FA\u51C6\u65E5\u6216\u8BAD\u7EC3\u7A97\u53E3"
1904
+ },
1905
+ "end_date": {
1906
+ "type": "string",
1907
+ "description": "\u4EE3\u7801\u6A21\u5F0F\u5FC5\u9700\uFF0CYYYY-MM-DD\uFF0C\u665A\u4E8Estart_date"
1908
+ },
1909
+ "symbol": {
1910
+ "type": "string",
1911
+ "description": "\u80A1\u7968\u4EE3\u7801\uFF1B\u4E0Ebenchmark/start_date/end_date\u4E00\u8D77\u76F4\u63A5\u53D6\u6570\uFF0C\u548Cprices\u6A21\u5F0F\u4E92\u65A5"
1912
+ },
1913
+ "benchmark": {
1914
+ "type": "string",
1915
+ "description": "\u540C\u5E02\u573A\u57FA\u51C6\u4EE3\u7801\uFF1B\u4E0Esymbol\u4E00\u8D77\u4F7F\u7528"
1916
+ }
1917
+ },
1918
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1919
+ async execute(params) {
1920
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["event_study", "--input", path]));
1921
+ }
1922
+ }));
1923
+ ctx.tools.register(defineTool2({
1924
+ name: "validate_backtest",
1925
+ description: "\u65E0\u72B6\u6001\u56DE\u6D4B\u7A33\u5065\u6027\uFF1A\u8F93\u5165\u5386\u53F2OHLCV\u548C\u5B8C\u6574\u5019\u9009DSL\uFF1B\u6EDA\u52A8\u8BAD\u7EC3\u9009\u53C2\u6570\u3001\u540E\u7EED\u4E0D\u91CD\u53E0\u7A97\u53E3\u9A8C\u8BC1\uFF0C\u5217\u51FA\u5168\u90E8\u6837\u672C\u5185\u654F\u611F\u6027\u53CA\u8DE8\u6807\u7684\u7ED3\u679C\u3002\u4EC5next_open\uFF0C\u4E0D\u81EA\u52A8\u4F18\u5316\u6216\u4FDD\u5B58\u3002",
1926
+ parameters: {
1927
+ "datasets": {
1928
+ "type": "array",
1929
+ "items": {
1930
+ "type": "object",
1931
+ "properties": {
1932
+ "symbol": {
1933
+ "type": "string",
1934
+ "description": "\u552F\u4E00\u80A1\u7968\u4EE3\u7801",
1935
+ "required": true
1936
+ },
1937
+ "price_basis": {
1938
+ "type": "string",
1939
+ "description": "\u5DF2\u6838\u5B9E\u590D\u6743/\u539F\u59CB\u4EF7\u683C\u53E3\u5F84",
1940
+ "required": true
1941
+ },
1942
+ "bars": {
1943
+ "type": "array",
1944
+ "items": {
1945
+ "type": "object",
1946
+ "properties": {
1947
+ "date": {
1948
+ "type": "string",
1949
+ "description": "YYYY-MM-DD",
1950
+ "required": true
1951
+ },
1952
+ "open": {
1953
+ "type": "number",
1954
+ "description": "\u6709\u9650OHLCV\uFF1B\u4EF7\u683C\u4E3A\u6B63\u3001volume\u975E\u8D1F",
1955
+ "required": true
1956
+ },
1957
+ "high": {
1958
+ "type": "number",
1959
+ "description": "\u6709\u9650OHLCV\uFF1B\u4EF7\u683C\u4E3A\u6B63\u3001volume\u975E\u8D1F",
1960
+ "required": true
1961
+ },
1962
+ "low": {
1963
+ "type": "number",
1964
+ "description": "\u6709\u9650OHLCV\uFF1B\u4EF7\u683C\u4E3A\u6B63\u3001volume\u975E\u8D1F",
1965
+ "required": true
1966
+ },
1967
+ "close": {
1968
+ "type": "number",
1969
+ "description": "\u6709\u9650OHLCV\uFF1B\u4EF7\u683C\u4E3A\u6B63\u3001volume\u975E\u8D1F",
1970
+ "required": true
1971
+ },
1972
+ "volume": {
1973
+ "type": "number",
1974
+ "description": "\u6709\u9650OHLCV\uFF1B\u4EF7\u683C\u4E3A\u6B63\u3001volume\u975E\u8D1F",
1975
+ "required": true
1976
+ }
1977
+ },
1978
+ "additionalProperties": false
1979
+ },
1980
+ "description": "\u65E5\u671F\u9012\u589E\u5B8C\u6574OHLCV\uFF0C\u6BCF\u7EC4\u6700\u591A2000\u6761\uFF0C\u81F3\u5C11train_bars+test_bars",
1981
+ "required": true
1982
+ }
1983
+ },
1984
+ "additionalProperties": false
1985
+ },
1986
+ "description": "1..5\u4E2A\u6807\u7684\uFF0C\u590D\u7528get_kline\u53D6\u6570"
1987
+ },
1988
+ "strategies": {
1989
+ "type": "array",
1990
+ "items": {
1991
+ "type": "object",
1992
+ "properties": {
1993
+ "name": {
1994
+ "type": "string",
1995
+ "description": "\u552F\u4E00\u5019\u9009\u540D",
1996
+ "required": true
1997
+ },
1998
+ "strategy": {
1999
+ "type": "object",
2000
+ "additionalProperties": true,
2001
+ "description": "\u5B8C\u6574\u65E2\u6709YAML DSL\u5BF9\u5E94JSON\uFF0C\u5141\u8BB8parameters\u5F15\u7528\uFF1B\u4EC5next_open",
2002
+ "properties": {},
2003
+ "required": true
2004
+ }
2005
+ },
2006
+ "additionalProperties": false
2007
+ },
2008
+ "description": "1..5\u4E2A\u9884\u5148\u786E\u5B9A\u7684\u5019\u9009\uFF0C\u7981\u6B62\u6D4B\u8BD5\u7ED3\u679C\u56DE\u8C03\u53C2\u6570",
2009
+ "required": true
2010
+ },
2011
+ "train_bars": {
2012
+ "type": "number",
2013
+ "description": "\u8BAD\u7EC3\u4EA4\u6613\u65E5\u657030..1000\uFF0C\u9ED8\u8BA4126"
2014
+ },
2015
+ "test_bars": {
2016
+ "type": "number",
2017
+ "description": "\u6D4B\u8BD5\u4EA4\u6613\u65E5\u657030..1000\uFF0C\u9ED8\u8BA463"
2018
+ },
2019
+ "capital": {
2020
+ "type": "number",
2021
+ "description": "\u6BCF\u7A97\u53E3\u521D\u59CB\u8D44\u91D1\uFF0C\u9ED8\u8BA41000000"
2022
+ },
2023
+ "start_date": {
2024
+ "type": "string",
2025
+ "description": "\u4EE3\u7801\u6A21\u5F0F\u5FC5\u9700\uFF0CYYYY-MM-DD\uFF0C\u5305\u542B\u4E8B\u4EF6\u524D\u57FA\u51C6\u65E5\u6216\u8BAD\u7EC3\u7A97\u53E3"
2026
+ },
2027
+ "end_date": {
2028
+ "type": "string",
2029
+ "description": "\u4EE3\u7801\u6A21\u5F0F\u5FC5\u9700\uFF0CYYYY-MM-DD\uFF0C\u665A\u4E8Estart_date"
2030
+ },
2031
+ "symbols": {
2032
+ "type": "array",
2033
+ "items": {
2034
+ "type": "string"
2035
+ },
2036
+ "description": "1..5\u4E2A\u552F\u4E00\u80A1\u7968\u4EE3\u7801\uFF0C\u914D\u5408start_date/end_date\u76F4\u63A5\u53D6\u6570\uFF1B\u548Cdatasets\u4E92\u65A5"
2037
+ }
2038
+ },
2039
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
2040
+ async execute(params) {
2041
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["robustness", "--input", path]));
2042
+ }
2043
+ }));
2044
+ ctx.tools.register(defineTool2({
2045
+ name: "compare_analysis_snapshots",
2046
+ description: "\u65E0\u72B6\u6001\u5FEB\u7167\u6BD4\u8F83\uFF1A\u4F20\u65B0\u65E7JSON\uFF0C\u8FD4\u56DEJSON Pointer\u53CA\u65B0\u589E/\u5220\u9664/\u53D8\u5316/\u5931\u6548/\u6062\u590D\uFF1B\u4E0D\u4FDD\u5B58\u5FEB\u7167\u3002\u6570\u7EC4\u6574\u4F53\u6BD4\u8F83\uFF0C\u8C03\u7528\u524D\u6309symbol\u5BF9\u9F50\u3002",
2047
+ parameters: {
2048
+ "previous": {
2049
+ "type": "object",
2050
+ "additionalProperties": true,
2051
+ "description": "JSON\u5BF9\u8C61\uFF0C\u8BE6\u89C1\u5171\u4EABSkill\u4E0EREADME",
2052
+ "properties": {},
2053
+ "required": true
2054
+ },
2055
+ "current": {
2056
+ "type": "object",
2057
+ "additionalProperties": true,
2058
+ "description": "JSON\u5BF9\u8C61\uFF0C\u8BE6\u89C1\u5171\u4EABSkill\u4E0EREADME",
2059
+ "properties": {},
2060
+ "required": true
2061
+ }
2062
+ },
2063
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
2064
+ async execute(params) {
2065
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["snapshot", "--input", path]));
2066
+ }
2067
+ }));
1275
2068
  registerSkills(ctx);
2069
+ if (config.toolDiscovery !== false) {
2070
+ registerToolDiscovery(ctx, new Set(ctx.tools.schemas?.().filter((tool) => !previousTools.has(tool.name)).map((tool) => tool.name)));
2071
+ }
1276
2072
  }
1277
2073
  export {
1278
2074
  __setExecutor,