dsh-stock-analysis 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +17 -1
  2. package/dist/index.js +874 -27
  3. package/package.json +1 -1
  4. package/schemas/market_review_schema.json +12 -5
  5. package/schemas/report_schema.json +68 -4
  6. package/scripts/cli-timeout.mjs +27 -0
  7. package/scripts/json-input.mjs +26 -0
  8. package/scripts/setup-python.mjs +6 -6
  9. package/skills/bull-trend/SKILL.md +34 -10
  10. package/skills/bull-trend/references/fat-tails.md +91 -0
  11. package/skills/bull-trend/scripts/tail_analysis.py +132 -0
  12. package/skills/event-driven/SKILL.md +6 -0
  13. package/skills/growth-quality/SKILL.md +6 -0
  14. package/skills/market-review/SKILL.md +2 -0
  15. package/skills/stock-analysis/SKILL.md +25 -5
  16. package/skills/stock-analysis/references/stateless-analysis.md +66 -0
  17. package/skills/stock-screener/SKILL.md +7 -1
  18. package/skills/strategy-backtest/SKILL.md +13 -0
  19. package/skills/wisburg-research/SKILL.md +2 -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 +6 -1
  23. package/templates/stock_analysis/full.md.j2 +8 -3
  24. package/tools/_subproc.py +66 -11
  25. package/tools/alert_rules.py +32 -4
  26. package/tools/backtest.py +95 -18
  27. package/tools/capabilities.py +11 -0
  28. package/tools/cli_budgets.json +26 -0
  29. package/tools/gather.py +24 -16
  30. package/tools/lixinger.py +100 -0
  31. package/tools/market_regime.py +7 -3
  32. package/tools/market_review.py +37 -15
  33. package/tools/position_context.py +20 -2
  34. package/tools/report_renderer.py +2 -0
  35. package/tools/risk_screening.py +45 -17
  36. package/tools/screener.py +74 -24
  37. package/tools/sec_edgar.py +346 -0
  38. package/tools/sec_holders.py +263 -0
  39. package/tools/signal_tracker.py +218 -24
  40. package/tools/stateless_analysis.py +630 -0
  41. package/tools/stock_data.py +170 -32
  42. package/tools/technical.py +16 -2
  43. package/tools/value_data.py +159 -0
  44. package/tools/watchlist.py +24 -1
  45. package/tools/watchlist_context.py +25 -10
package/dist/index.js CHANGED
@@ -1,46 +1,182 @@
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
+ };
54
+
55
+ // scripts/cli-timeout.mjs
56
+ import { basename } from "node:path";
57
+ function commandTimeout(script, args) {
58
+ const key = `${basename(script)}:${args[0] ?? ""}`;
59
+ let budget = cli_budgets_default[key] ?? cli_budgets_default.default;
60
+ const option = (name2, fallback) => args.includes(name2) ? args[args.indexOf(name2) + 1] ?? fallback : fallback;
61
+ const positiveInt = (value, fallback) => /^\d+$/.test(String(value)) && Number(value) > 0 ? Number(value) : fallback;
62
+ if (key === "screener.py:screen") {
63
+ budget += Math.ceil(positiveInt(option("--top", 20), 20) / cli_budgets_default.l2_workers) * cli_budgets_default.l2_batch;
64
+ } else if (key === "watchlist.py:analyze" || key === "watchlist_context.py:build") {
65
+ const count = String(args[1] ?? "").split(",").filter((s) => s.trim()).length;
66
+ const workers = positiveInt(option("--workers", 3), 3);
67
+ budget += Math.ceil(count / workers) * cli_budgets_default.watchlist_item;
68
+ if (key === "watchlist_context.py:build") {
69
+ budget += Math.ceil(count / Math.min(workers * 2, 6)) * cli_budgets_default["anomaly_detect.py:detect"];
70
+ if (args.includes("--include-market-review")) budget += 3 * cli_budgets_default["market_review.py:review"] + 30;
71
+ }
72
+ } else if (key === "market_review.py:review" && option("--market", "A") === "all") {
73
+ budget = 3 * budget + 30;
74
+ } else if (key === "technical.py:analyze" && args.includes("--periods")) {
75
+ const periods = String(option("--periods", "daily")).split(",").map((p) => p.trim()).filter(Boolean);
76
+ budget *= (/* @__PURE__ */ new Set([option("--period", "daily"), ...periods])).size;
77
+ }
78
+ return budget * 1e3 + 3e4;
79
+ }
80
+
1
81
  // dsh/index.ts
2
82
  import { existsSync, readdirSync, readFileSync } from "node:fs";
3
83
  import * as cp from "node:child_process";
4
84
  import { promisify } from "node:util";
5
- import { dirname, join as join2 } from "node:path";
85
+ import { dirname, join as join3 } from "node:path";
6
86
  import { fileURLToPath } from "node:url";
7
87
  import {
8
- defineTool
88
+ defineTool as defineTool2
9
89
  } from "@deepseek-ai/dsh-tools";
10
90
 
11
91
  // scripts/venv-python.mjs
12
- import { join } from "node:path";
92
+ import { join as join2 } from "node:path";
13
93
  var isWin = process.platform === "win32";
14
94
  function venvPythonPath(rootDir) {
15
- return join(rootDir, ".venv", isWin ? "Scripts" : "bin", isWin ? "python.exe" : "python3");
95
+ return join2(rootDir, ".venv", isWin ? "Scripts" : "bin", isWin ? "python.exe" : "python3");
96
+ }
97
+
98
+ // dsh/discovery.ts
99
+ import { defineTool } from "@deepseek-ai/dsh-tools";
100
+ var SEARCH = "stock_tool_search";
101
+ function registerToolDiscovery(ctx, names) {
102
+ if (typeof ctx.on !== "function" || typeof ctx.tools.get !== "function" || typeof ctx.tools.presentAs !== "function" || names.size === 0 || ctx.tools.get(SEARCH)) return;
103
+ const states = /* @__PURE__ */ new WeakMap();
104
+ ctx.tools.register(defineTool({
105
+ name: SEARCH,
106
+ 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",
107
+ parameters: {
108
+ query: { type: "string", required: true, description: "\u5DE5\u5177\u540D\u79F0\u6216\u529F\u80FD\u5173\u952E\u8BCD" },
109
+ limit: { type: "integer", description: "\u6700\u591A\u52A0\u8F7D\u6570\u91CF\uFF0C\u9ED8\u8BA45\uFF0C\u8303\u56F41\u523020" }
110
+ },
111
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
112
+ async execute({ query, limit = 5 }, exec) {
113
+ const needle = query.trim().toLowerCase();
114
+ const terms = [...new Set(needle.match(/[a-z0-9_]+|\p{Script=Han}/gu) ?? [])];
115
+ if (!terms.length || !Number.isInteger(limit) || limit < 1 || limit > 20) {
116
+ return JSON.stringify({ error: "query must contain searchable text and limit must be an integer from 1 to 20" });
117
+ }
118
+ const state = exec.agent && states.get(exec.agent);
119
+ if (!state) return JSON.stringify({ error: "Tool discovery is unavailable for this agent; use its directly exposed tools" });
120
+ const candidates = state.catalog.filter((tool) => ctx.tools.get(tool.name, exec.agent)).map((tool) => ({ tool, text: `${tool.name} ${tool.description}`.toLowerCase() }));
121
+ const weights = terms.map((term) => 1 / (1 + candidates.filter(({ text }) => text.includes(term)).length));
122
+ const matches = candidates.map(({ tool, text }) => {
123
+ 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);
124
+ return { tool, score };
125
+ }).filter((match) => match.score > 0).sort((a, b) => b.score - a.score || a.tool.name.localeCompare(b.tool.name)).slice(0, limit);
126
+ for (const { tool } of matches) state.loaded.add(tool.name);
127
+ return JSON.stringify({ loaded: matches.map(({ tool }) => ({ name: tool.name, description: tool.description })) });
128
+ }
129
+ }));
130
+ ctx.on("system-prompt/assemble", async (_assembly, context, next) => {
131
+ const result = await next();
132
+ if (!context.scope) return result;
133
+ if (!result.tools.some((tool) => tool.name === SEARCH) || result.tools.some((tool) => tool.name === "run_code")) {
134
+ states.delete(context.scope);
135
+ return result;
136
+ }
137
+ const state = states.get(context.scope) ?? { catalog: [], loaded: /* @__PURE__ */ new Set() };
138
+ state.catalog = result.tools.filter((tool) => names.has(tool.name));
139
+ states.set(context.scope, state);
140
+ return { ...result, tools: result.tools.filter((tool) => !names.has(tool.name) || state.loaded.has(tool.name)) };
141
+ });
16
142
  }
17
143
 
18
144
  // dsh/index.ts
19
145
  var defaultExecutor = async (bin, argv) => {
20
146
  const exec = promisify(cp.execFile);
21
- const { stdout } = await exec(bin, argv, { maxBuffer: 32 * 1024 * 1024 });
22
- return stdout;
147
+ try {
148
+ const { stdout } = await exec(bin, argv, { maxBuffer: 32 * 1024 * 1024, timeout: commandTimeout(argv[0], argv.slice(1)) });
149
+ return stdout;
150
+ } catch (error) {
151
+ const stdout = error.stdout;
152
+ try {
153
+ const data = JSON.parse(stdout ?? "");
154
+ if (data && typeof data.error === "string") return stdout;
155
+ } catch {
156
+ }
157
+ return JSON.stringify({ error: error.killed ? "Python command timed out" : "Python command failed; check interpreter/dependencies" });
158
+ }
23
159
  };
24
160
  var executor = defaultExecutor;
25
161
  function __setExecutor(fn) {
26
162
  executor = fn;
27
163
  }
28
164
  var here = dirname(fileURLToPath(import.meta.url));
29
- var toolsDir = join2(here, "..", "tools");
165
+ var toolsDir = join3(here, "..", "tools");
30
166
  var pkgRoot = dirname(toolsDir);
31
167
  var isWin2 = process.platform === "win32";
32
168
  function pythonBin() {
33
- for (const root of [pkgRoot, join2(pkgRoot, "..")]) {
169
+ for (const root of [pkgRoot, join3(pkgRoot, "..")]) {
34
170
  const candidate = venvPythonPath(root);
35
171
  if (existsSync(candidate)) return candidate;
36
172
  }
37
173
  return isWin2 ? "python" : "python3";
38
174
  }
39
175
  async function runPy(script, args) {
40
- return executor(pythonBin(), [join2(toolsDir, script), ...args]);
176
+ return executor(pythonBin(), [join3(toolsDir, script), ...args]);
41
177
  }
42
178
  function pyTool(opts) {
43
- return defineTool({
179
+ return defineTool2({
44
180
  name: opts.name,
45
181
  description: opts.description,
46
182
  parameters: opts.parameters,
@@ -53,7 +189,7 @@ function pyTool(opts) {
53
189
  }
54
190
  });
55
191
  }
56
- var skillsDir = join2(here, "..", "skills");
192
+ var skillsDir = join3(here, "..", "skills");
57
193
  function frontmatterValue(raw, key) {
58
194
  const block = raw.match(/^---\r?\n([\s\S]*?)\r?\n---/);
59
195
  const line = block?.[1].match(new RegExp(`^${key}:\\s*(.+)$`, "m"));
@@ -63,7 +199,7 @@ function registerSkills(ctx) {
63
199
  if (!existsSync(skillsDir)) return;
64
200
  for (const child of readdirSync(skillsDir, { withFileTypes: true })) {
65
201
  if (!child.isDirectory()) continue;
66
- const skillFile = join2(skillsDir, child.name, "SKILL.md");
202
+ const skillFile = join3(skillsDir, child.name, "SKILL.md");
67
203
  if (!existsSync(skillFile)) continue;
68
204
  const raw = readFileSync(skillFile, "utf-8");
69
205
  ctx.skills.register({
@@ -74,17 +210,103 @@ function registerSkills(ctx) {
74
210
  content: raw.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, "").trimStart(),
75
211
  source: "bundled",
76
212
  path: skillFile,
77
- resourceBase: { kind: "directory", path: join2(skillsDir, child.name) }
213
+ resourceBase: { kind: "directory", path: join3(skillsDir, child.name) }
78
214
  });
79
215
  }
80
216
  }
81
217
  var name = "stock-analysis";
82
218
  var inject = ["tools", "skills"];
83
- function apply(ctx) {
219
+ function apply(ctx, config = {}) {
220
+ if (config.toolDiscovery !== void 0 && typeof config.toolDiscovery !== "boolean") {
221
+ throw new TypeError("toolDiscovery must be a boolean");
222
+ }
223
+ const previousTools = new Set(ctx.tools.schemas?.().map((tool) => tool.name));
224
+ ctx.tools.register(
225
+ pyTool({
226
+ name: "get_announcements",
227
+ 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",
228
+ parameters: {
229
+ "symbol": {
230
+ "type": "string",
231
+ "description": "A\u80A1\u4EE3\u7801",
232
+ "required": true
233
+ },
234
+ "category": {
235
+ "type": "string",
236
+ "enum": [
237
+ "all",
238
+ "forecast",
239
+ "express",
240
+ "annual",
241
+ "interim",
242
+ "quarterly",
243
+ "reduction",
244
+ "issuance",
245
+ "inquiry",
246
+ "dividend"
247
+ ],
248
+ "description": "\u516C\u544A\u7C7B\u522B\uFF0C\u9ED8\u8BA4all"
249
+ },
250
+ "start_date": {
251
+ "type": "string",
252
+ "description": "\u5F00\u59CB\u65E5\u671FYYYY-MM-DD\uFF0C\u9ED8\u8BA4\u7ED3\u675F\u65E5\u671F\u524D90\u5929"
253
+ },
254
+ "end_date": {
255
+ "type": "string",
256
+ "description": "\u7ED3\u675F\u65E5\u671FYYYY-MM-DD\uFF0C\u9ED8\u8BA4\u4ECA\u5929"
257
+ },
258
+ "top": {
259
+ "type": "number",
260
+ "description": "\u6700\u591A\u6761\u65701..500\uFF0C\u9ED8\u8BA450"
261
+ }
262
+ },
263
+ script: "value_data.py",
264
+ argv: (p) => ["announcements", p.symbol, "--category", p.category ?? "all", "--start-date", p.start_date ?? "", "--end-date", p.end_date ?? "", "--top", String(p.top ?? 50)]
265
+ })
266
+ );
267
+ ctx.tools.register(
268
+ pyTool({
269
+ name: "get_us_holdings",
270
+ 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",
271
+ parameters: {
272
+ "cik": {
273
+ "type": "string",
274
+ "description": "\u673A\u6784\u6216\u53D1\u884C\u4EBACIK\uFF0C1..10\u4F4D\u6570\u5B57\uFF0C\u59820001067983/0000320193",
275
+ "required": true
276
+ },
277
+ "mode": { "type": "string", "enum": ["auto", "manager", "issuer"], "description": "\u9ED8\u8BA4auto\uFF1Bmanager\u67E5\u673A\u6784\u7EC4\u5408\uFF0Cissuer\u53CD\u67E5\u53D1\u884C\u4EBA\u6301\u4ED3\u673A\u6784" }
278
+ },
279
+ script: "sec_edgar.py",
280
+ argv: (p) => ["holdings", p.cik, ...p.mode ? ["--mode", p.mode] : []]
281
+ })
282
+ );
283
+ ctx.tools.register(
284
+ pyTool({
285
+ name: "get_insider_trades",
286
+ 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",
287
+ parameters: {
288
+ "symbol": {
289
+ "type": "string",
290
+ "description": "\u7F8E\u80A1ticker\u6216\u53D1\u884C\u4EBACIK",
291
+ "required": true
292
+ },
293
+ "days": {
294
+ "type": "number",
295
+ "description": "\u7533\u62A5\u65E5\u671F\u7A97\u53E31..365\u5929\uFF0C\u9ED8\u8BA490"
296
+ },
297
+ "top": {
298
+ "type": "number",
299
+ "description": "\u6700\u591A\u89E3\u6790Form 4\u6587\u4EF6\u65701..20\uFF0C\u9ED8\u8BA410"
300
+ }
301
+ },
302
+ script: "sec_edgar.py",
303
+ argv: (p) => ["insider_trades", p.symbol, "--days", String(p.days ?? 90), "--top", String(p.top ?? 10)]
304
+ })
305
+ );
84
306
  ctx.tools.register(
85
307
  pyTool({
86
308
  name: "get_valuation_history",
87
- description: "\u67E5\u8BE2A/HK\u80A1\u7968\u5386\u53F2 PE-TTM/PB\u3001\u5F53\u524D\u6B63\u503C\u5206\u4F4D\u548C10/25/50/75/90\u5206\u4F4D Band\uFF0C\u8FD4\u56DE\u5B9E\u9645\u91C7\u6837\u533A\u95F4\uFF1B\u4E8F\u635F\u4F30\u503C\u5206\u4F4D\u4E3Anull\u3002years=1..10\uFF0C\u6570\u636E\u6309\u5929\u7F13\u5B58\u3002",
309
+ 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",
88
310
  parameters: {
89
311
  "symbol": {
90
312
  "type": "string",
@@ -223,7 +445,7 @@ function apply(ctx) {
223
445
  ctx.tools.register(
224
446
  pyTool({
225
447
  name: "get_kline",
226
- 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",
448
+ 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",
227
449
  parameters: {
228
450
  symbol: {
229
451
  type: "string",
@@ -251,7 +473,7 @@ function apply(ctx) {
251
473
  ctx.tools.register(
252
474
  pyTool({
253
475
  name: "get_quote",
254
- 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",
476
+ 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",
255
477
  parameters: {
256
478
  symbol: { type: "string", required: true, description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" }
257
479
  },
@@ -298,7 +520,7 @@ function apply(ctx) {
298
520
  ctx.tools.register(
299
521
  pyTool({
300
522
  name: "get_financials",
301
- description: "\u83B7\u53D6\u80A1\u7968\u8D22\u52A1\u6458\u8981\u53CA\u5386\u53F2\u8D8B\u52BF\uFF0C\u6309\u5929\u7F13\u5B58\u3002A\u80A1\u8FD4\u56DEROE/\u6BDB\u5229\u7387/\u51C0\u5229\u7387\u7B49\uFF1Bannual=true\u4E0Eperiods=10\u53D6\u5341\u5E74\u5E74\u62A5\uFF0C\u6E2F\u80A1\u5E74\u5EA6\u5386\u53F2\u6309\u6570\u636E\u6E90\u5B9E\u9645\u53EF\u5F97\u671F\u6570\u8FD4\u56DE\u3002\u4F30\u503C\u5386\u53F2\u7528get_valuation_history\uFF0C\u62AB\u9732\u6392\u671F\u7528get_earnings_calendar",
523
+ 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",
302
524
  parameters: {
303
525
  symbol: { type: "string", required: true, description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" },
304
526
  annual: { type: "boolean", description: "\u53EA\u53D6\u5E74\u5EA6\u62A5\u544A\uFF0C\u9ED8\u8BA4false" },
@@ -575,7 +797,7 @@ function apply(ctx) {
575
797
  ctx.tools.register(
576
798
  pyTool({
577
799
  name: "screen_stocks",
578
- 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",
800
+ 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",
579
801
  parameters: {
580
802
  market: {
581
803
  type: "string",
@@ -598,7 +820,7 @@ function apply(ctx) {
598
820
  ctx.tools.register(
599
821
  pyTool({
600
822
  name: "run_backtest",
601
- 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",
823
+ 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",
602
824
  parameters: {
603
825
  strategy: { type: "string", required: true, description: "\u7B56\u7565YAML\u6587\u4EF6\u8DEF\u5F84" },
604
826
  symbol: { type: "string", required: true, description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" },
@@ -851,7 +1073,7 @@ function apply(ctx) {
851
1073
  ctx.tools.register(
852
1074
  pyTool({
853
1075
  name: "screen_risk",
854
- 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",
1076
+ 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",
855
1077
  parameters: {
856
1078
  symbol: {
857
1079
  type: "string",
@@ -886,7 +1108,7 @@ function apply(ctx) {
886
1108
  ctx.tools.register(
887
1109
  pyTool({
888
1110
  name: "get_market_review",
889
- 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",
1111
+ 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",
890
1112
  parameters: {
891
1113
  market: {
892
1114
  type: "string",
@@ -966,7 +1188,7 @@ function apply(ctx) {
966
1188
  ctx.tools.register(
967
1189
  pyTool({
968
1190
  name: "render_stock_report",
969
- 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",
1191
+ 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",
970
1192
  parameters: {
971
1193
  report: {
972
1194
  type: "object",
@@ -1026,7 +1248,7 @@ function apply(ctx) {
1026
1248
  ctx.tools.register(
1027
1249
  pyTool({
1028
1250
  name: "build_watchlist_context",
1029
- 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",
1251
+ 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",
1030
1252
  parameters: {
1031
1253
  symbols: { type: "string", required: true, description: "\u9017\u53F7\u5206\u9694\u7684\u80A1\u7968\u4EE3\u7801\u5217\u8868" },
1032
1254
  include_market_review: {
@@ -1073,7 +1295,7 @@ function apply(ctx) {
1073
1295
  ctx.tools.register(
1074
1296
  pyTool({
1075
1297
  name: "check_alert_rules",
1076
- 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",
1298
+ 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",
1077
1299
  parameters: {
1078
1300
  symbol: { type: "string", required: true, description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" },
1079
1301
  rules: {
@@ -1131,7 +1353,7 @@ function apply(ctx) {
1131
1353
  ctx.tools.register(
1132
1354
  pyTool({
1133
1355
  name: "evaluate_signals",
1134
- 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",
1356
+ 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",
1135
1357
  parameters: {
1136
1358
  symbol: { type: "string", description: "\u80A1\u7968\u4EE3\u7801\uFF08\u53EF\u9009\uFF0C\u53EA\u8BC4\u4F30\u8BE5\u80A1\u7684\u4FE1\u53F7\uFF09" }
1137
1359
  },
@@ -1146,7 +1368,7 @@ function apply(ctx) {
1146
1368
  ctx.tools.register(
1147
1369
  pyTool({
1148
1370
  name: "get_signal_summary",
1149
- 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",
1371
+ 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",
1150
1372
  parameters: {
1151
1373
  source: { type: "string", description: "\u6309\u4FE1\u53F7\u6765\u6E90\u8FC7\u6EE4\uFF08\u53EF\u9009\uFF09" },
1152
1374
  symbol: { type: "string", description: "\u6309\u80A1\u7968\u4EE3\u7801\u8FC7\u6EE4\uFF08\u53EF\u9009\uFF09" },
@@ -1180,7 +1402,632 @@ function apply(ctx) {
1180
1402
  }
1181
1403
  })
1182
1404
  );
1405
+ ctx.tools.register(defineTool2({
1406
+ name: "compare_stocks",
1407
+ 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",
1408
+ parameters: {
1409
+ "companies": {
1410
+ "type": "array",
1411
+ "items": {
1412
+ "type": "object",
1413
+ "properties": {
1414
+ "symbol": {
1415
+ "type": "string",
1416
+ "description": "\u552F\u4E00\u80A1\u7968\u4EE3\u7801",
1417
+ "required": true
1418
+ },
1419
+ "period": {
1420
+ "type": "string",
1421
+ "description": "\u7EDF\u4E00\u53EF\u6BD4\u671F\u95F4\uFF1B\u8D22\u52A1\u7528\u62A5\u544A\u671F\uFF0C\u4F30\u503C\u7528\u4F30\u503C\u65E5",
1422
+ "required": true
1423
+ },
1424
+ "metrics": {
1425
+ "type": "array",
1426
+ "items": {
1427
+ "type": "object",
1428
+ "properties": {
1429
+ "name": {
1430
+ "type": "string",
1431
+ "description": "\u6307\u6807\u540D\uFF0C\u5982pe/roe/net_income",
1432
+ "required": true
1433
+ },
1434
+ "value": {
1435
+ "oneOf": [
1436
+ {
1437
+ "type": "number"
1438
+ },
1439
+ {
1440
+ "type": "null"
1441
+ }
1442
+ ],
1443
+ "description": "\u6709\u9650\u6570\u503C\uFF1B\u7F3A\u5931\u4E3Anull",
1444
+ "required": true
1445
+ },
1446
+ "unit": {
1447
+ "type": "string",
1448
+ "description": "\u7CBE\u786E\u5355\u4F4D\uFF0C\u5982multiple/percent/fraction/CNY/USD",
1449
+ "required": true
1450
+ },
1451
+ "basis": {
1452
+ "type": "string",
1453
+ "description": "\u53E3\u5F84\uFF0C\u5982TTM/annual/consolidated\uFF1B\u533A\u5206\u7D2F\u8BA1\u4E0E\u5355\u5B63",
1454
+ "required": true
1455
+ },
1456
+ "source": {
1457
+ "type": "string",
1458
+ "description": "\u539F\u59CB\u8BC1\u636EURL\u6216\u5B57\u6BB5\u8DEF\u5F84"
1459
+ }
1460
+ },
1461
+ "additionalProperties": false
1462
+ },
1463
+ "description": "\u7ED3\u6784\u5316\u6307\u6807\uFF0C\u5355\u4F4D\u3001\u53E3\u5F84\u660E\u786E\uFF0C\u7F3A\u5931\u4E0D\u586B\u96F6",
1464
+ "required": true
1465
+ }
1466
+ },
1467
+ "additionalProperties": false
1468
+ },
1469
+ "description": "2..30\u5BB6\u516C\u53F8\uFF0C\u8C03\u7528\u65B9\u786E\u8BA4\u53EF\u6BD4\u6027",
1470
+ "required": true
1471
+ }
1472
+ },
1473
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1474
+ async execute(params) {
1475
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["peers", "--input", path]));
1476
+ }
1477
+ }));
1478
+ ctx.tools.register(defineTool2({
1479
+ name: "analyze_disclosure_changes",
1480
+ 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",
1481
+ parameters: {
1482
+ "previous": {
1483
+ "type": "object",
1484
+ "properties": {
1485
+ "text": {
1486
+ "type": "string",
1487
+ "description": "\u5DF2\u6838\u5B9E\u6B63\u6587\uFF0C\u6700\u591A200000\u5B57\u7B26\uFF1B\u4FDD\u7559\u6362\u884C\uFF0CPDF\u9700\u5BBF\u4E3B\u63D0\u53D6",
1488
+ "required": true
1489
+ },
1490
+ "source": {
1491
+ "type": "string",
1492
+ "description": "\u539F\u6587URL\u6216\u6587\u6863\u6807\u8BC6",
1493
+ "required": true
1494
+ },
1495
+ "period": {
1496
+ "type": "string",
1497
+ "description": "\u62A5\u544A\u671F\uFF0C\u59822025\u5E74\u5EA6",
1498
+ "required": true
1499
+ },
1500
+ "metrics": {
1501
+ "type": "array",
1502
+ "items": {
1503
+ "type": "object",
1504
+ "properties": {
1505
+ "name": {
1506
+ "type": "string",
1507
+ "description": "\u6307\u6807\u540D\uFF0C\u5982pe/roe/net_income",
1508
+ "required": true
1509
+ },
1510
+ "value": {
1511
+ "oneOf": [
1512
+ {
1513
+ "type": "number"
1514
+ },
1515
+ {
1516
+ "type": "null"
1517
+ }
1518
+ ],
1519
+ "description": "\u6709\u9650\u6570\u503C\uFF1B\u7F3A\u5931\u4E3Anull",
1520
+ "required": true
1521
+ },
1522
+ "unit": {
1523
+ "type": "string",
1524
+ "description": "\u7CBE\u786E\u5355\u4F4D\uFF0C\u5982multiple/percent/fraction/CNY/USD",
1525
+ "required": true
1526
+ },
1527
+ "basis": {
1528
+ "type": "string",
1529
+ "description": "\u53E3\u5F84\uFF0C\u5982TTM/annual/consolidated\uFF1B\u533A\u5206\u7D2F\u8BA1\u4E0E\u5355\u5B63",
1530
+ "required": true
1531
+ },
1532
+ "source": {
1533
+ "type": "string",
1534
+ "description": "\u539F\u59CB\u8BC1\u636EURL\u6216\u5B57\u6BB5\u8DEF\u5F84"
1535
+ }
1536
+ },
1537
+ "additionalProperties": false
1538
+ },
1539
+ "description": "\u7ED3\u6784\u5316\u6307\u6807\uFF0C\u5355\u4F4D\u3001\u53E3\u5F84\u660E\u786E\uFF0C\u7F3A\u5931\u4E0D\u586B\u96F6",
1540
+ "required": true
1541
+ }
1542
+ },
1543
+ "additionalProperties": false,
1544
+ "required": true
1545
+ },
1546
+ "current": {
1547
+ "type": "object",
1548
+ "properties": {
1549
+ "text": {
1550
+ "type": "string",
1551
+ "description": "\u5DF2\u6838\u5B9E\u6B63\u6587\uFF0C\u6700\u591A200000\u5B57\u7B26\uFF1B\u4FDD\u7559\u6362\u884C\uFF0CPDF\u9700\u5BBF\u4E3B\u63D0\u53D6",
1552
+ "required": true
1553
+ },
1554
+ "source": {
1555
+ "type": "string",
1556
+ "description": "\u539F\u6587URL\u6216\u6587\u6863\u6807\u8BC6",
1557
+ "required": true
1558
+ },
1559
+ "period": {
1560
+ "type": "string",
1561
+ "description": "\u62A5\u544A\u671F\uFF0C\u59822025\u5E74\u5EA6",
1562
+ "required": true
1563
+ },
1564
+ "metrics": {
1565
+ "type": "array",
1566
+ "items": {
1567
+ "type": "object",
1568
+ "properties": {
1569
+ "name": {
1570
+ "type": "string",
1571
+ "description": "\u6307\u6807\u540D\uFF0C\u5982pe/roe/net_income",
1572
+ "required": true
1573
+ },
1574
+ "value": {
1575
+ "oneOf": [
1576
+ {
1577
+ "type": "number"
1578
+ },
1579
+ {
1580
+ "type": "null"
1581
+ }
1582
+ ],
1583
+ "description": "\u6709\u9650\u6570\u503C\uFF1B\u7F3A\u5931\u4E3Anull",
1584
+ "required": true
1585
+ },
1586
+ "unit": {
1587
+ "type": "string",
1588
+ "description": "\u7CBE\u786E\u5355\u4F4D\uFF0C\u5982multiple/percent/fraction/CNY/USD",
1589
+ "required": true
1590
+ },
1591
+ "basis": {
1592
+ "type": "string",
1593
+ "description": "\u53E3\u5F84\uFF0C\u5982TTM/annual/consolidated\uFF1B\u533A\u5206\u7D2F\u8BA1\u4E0E\u5355\u5B63",
1594
+ "required": true
1595
+ },
1596
+ "source": {
1597
+ "type": "string",
1598
+ "description": "\u539F\u59CB\u8BC1\u636EURL\u6216\u5B57\u6BB5\u8DEF\u5F84"
1599
+ }
1600
+ },
1601
+ "additionalProperties": false
1602
+ },
1603
+ "description": "\u7ED3\u6784\u5316\u6307\u6807\uFF0C\u5355\u4F4D\u3001\u53E3\u5F84\u660E\u786E\uFF0C\u7F3A\u5931\u4E0D\u586B\u96F6",
1604
+ "required": true
1605
+ }
1606
+ },
1607
+ "additionalProperties": false,
1608
+ "required": true
1609
+ },
1610
+ "max_changes": {
1611
+ "type": "number",
1612
+ "description": "\u53D8\u5316\u4E0A\u96501..100\uFF0C\u9ED8\u8BA430"
1613
+ }
1614
+ },
1615
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1616
+ async execute(params) {
1617
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["disclosure", "--input", path]));
1618
+ }
1619
+ }));
1620
+ ctx.tools.register(defineTool2({
1621
+ name: "analyze_portfolio_risk",
1622
+ 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",
1623
+ parameters: {
1624
+ "positions": {
1625
+ "type": "array",
1626
+ "items": {
1627
+ "type": "object",
1628
+ "properties": {
1629
+ "symbol": {
1630
+ "type": "string",
1631
+ "description": "\u552F\u4E00\u4EE3\u7801\uFF0C\u91CD\u590D\u6301\u4ED3\u5148\u6C47\u603B",
1632
+ "required": true
1633
+ },
1634
+ "quantity": {
1635
+ "type": "number",
1636
+ "description": "\u6B63\u6301\u4ED3\u6570\u91CF",
1637
+ "required": true
1638
+ },
1639
+ "price": {
1640
+ "type": "number",
1641
+ "description": "\u6B63\u73B0\u4EF7",
1642
+ "required": true
1643
+ },
1644
+ "currency": {
1645
+ "type": "string",
1646
+ "description": "\u6301\u4ED3\u5E01\u79CD\uFF0C\u5982CNY/USD/HKD",
1647
+ "required": true
1648
+ },
1649
+ "cost": {
1650
+ "type": "number",
1651
+ "description": "\u540C\u5E01\u79CD\u6B63\u6210\u672C\u4EF7\uFF0C\u53EF\u9009"
1652
+ },
1653
+ "stop_price": {
1654
+ "type": "number",
1655
+ "description": "\u540C\u5E01\u79CD\u6B63\u6B62\u635F\u4EF7\uFF0C\u53EF\u9009"
1656
+ },
1657
+ "sector": {
1658
+ "type": "string",
1659
+ "description": "\u7EDF\u4E00\u884C\u4E1A\u5206\u7C7B\uFF0C\u53EF\u9009"
1660
+ },
1661
+ "as_of": {
1662
+ "type": "string",
1663
+ "description": "\u5B9E\u9645\u4F30\u503C\u65F6\u70B9\uFF0C\u5EFA\u8BAEISO8601"
1664
+ }
1665
+ },
1666
+ "additionalProperties": false
1667
+ },
1668
+ "description": "1..100\u4E2A\u73B0\u8D27\u591A\u5934\u6301\u4ED3",
1669
+ "required": true
1670
+ },
1671
+ "base_currency": {
1672
+ "type": "string",
1673
+ "description": "\u57FA\u51C6\u5E01\u79CD",
1674
+ "required": true
1675
+ },
1676
+ "cash": {
1677
+ "type": "number",
1678
+ "description": "\u57FA\u51C6\u5E01\u79CD\u73B0\u91D1\uFF0C\u975E\u8D1F",
1679
+ "required": true
1680
+ },
1681
+ "fx_rates": {
1682
+ "type": "array",
1683
+ "items": {
1684
+ "type": "object",
1685
+ "properties": {
1686
+ "currency": {
1687
+ "type": "string",
1688
+ "description": "\u552F\u4E00\u975E\u57FA\u51C6\u5E01\u79CD",
1689
+ "required": true
1690
+ },
1691
+ "rate": {
1692
+ "type": "number",
1693
+ "description": "\u4E00\u5355\u4F4D\u8BE5\u5E01\u79CD\u5BF9\u5E94\u591A\u5C11\u57FA\u51C6\u5E01\u79CD\uFF0C\u6B63\u6570",
1694
+ "required": true
1695
+ }
1696
+ },
1697
+ "additionalProperties": false
1698
+ },
1699
+ "description": "\u663E\u5F0F\u73B0\u4EF7\u6C47\u7387\uFF1B\u57FA\u51C6\u5E01\u79CD\u9690\u542B1\uFF0C\u4E0D\u5F97\u91CD\u590D"
1700
+ },
1701
+ "histories": {
1702
+ "type": "array",
1703
+ "items": {
1704
+ "type": "object",
1705
+ "properties": {
1706
+ "symbol": {
1707
+ "type": "string",
1708
+ "description": "\u5BF9\u5E94\u552F\u4E00\u6301\u4ED3\u80A1\u7968",
1709
+ "required": true
1710
+ },
1711
+ "prices": {
1712
+ "type": "array",
1713
+ "items": {
1714
+ "type": "object",
1715
+ "properties": {
1716
+ "date": {
1717
+ "type": "string",
1718
+ "description": "YYYY-MM-DD\uFF0C\u552F\u4E00\u65E5\u671F",
1719
+ "required": true
1720
+ },
1721
+ "close": {
1722
+ "type": "number",
1723
+ "description": "\u6B63\u6709\u9650\u6536\u76D8\u4EF7",
1724
+ "required": true
1725
+ }
1726
+ },
1727
+ "additionalProperties": false
1728
+ },
1729
+ "description": "\u5B8C\u6574\u65E5K\u6536\u76D8\u5E8F\u5217\uFF0C2..20000\u6761\uFF0C\u4E0D\u5F97\u8DE8\u80A1\u7968\u6216\u6DF7\u7528\u590D\u6743\u53E3\u5F84",
1730
+ "required": true
1731
+ }
1732
+ },
1733
+ "additionalProperties": false
1734
+ },
1735
+ "description": "\u53EF\u9009\u5386\u53F2\uFF0C\u5171\u540C\u65E5\u671F\u672C\u5E01\u4EF7\u683C\u6536\u76CA\u76F8\u5173\u6027\uFF0C\u4E0D\u8BA1\u6C47\u7387"
1736
+ }
1737
+ },
1738
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1739
+ async execute(params) {
1740
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["portfolio", "--input", path]));
1741
+ }
1742
+ }));
1743
+ ctx.tools.register(defineTool2({
1744
+ name: "calculate_position_size",
1745
+ 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",
1746
+ parameters: {
1747
+ "equity": {
1748
+ "type": "number",
1749
+ "description": "\u603B\u6743\u76CA\uFF0C\u6B63\u6570",
1750
+ "required": true
1751
+ },
1752
+ "cash": {
1753
+ "type": "number",
1754
+ "description": "\u53EF\u7528\u73B0\u91D1\uFF0C0..equity",
1755
+ "required": true
1756
+ },
1757
+ "entry_price": {
1758
+ "type": "number",
1759
+ "description": "\u8BA1\u5212\u5165\u573A\u4EF7\uFF0C\u6B63\u6570",
1760
+ "required": true
1761
+ },
1762
+ "stop_price": {
1763
+ "type": "number",
1764
+ "description": "\u6B63\u6B62\u635F\u4EF7\uFF0C\u4F4E\u4E8E\u5165\u573A\u4EF7",
1765
+ "required": true
1766
+ },
1767
+ "risk_fraction": {
1768
+ "type": "number",
1769
+ "description": "\u5355\u7B14\u98CE\u9669\u5360\u6743\u76CA\u6BD4\u4F8B0..1\uFF0C\u59820.01",
1770
+ "required": true
1771
+ },
1772
+ "lot_size": {
1773
+ "type": "number",
1774
+ "description": "\u6B63\u6574\u6570\u4EA4\u6613\u5355\u4F4D\uFF0C\u7528\u6237\u786E\u8BA4\uFF0C\u4E0D\u731C\u6E2F\u80A1\u6BCF\u624B\u6570\u91CF",
1775
+ "required": true
1776
+ },
1777
+ "max_position_fraction": {
1778
+ "type": "number",
1779
+ "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"
1780
+ },
1781
+ "fee_rate": {
1782
+ "type": "number",
1783
+ "description": "\u6BCF\u8FB9\u6BD4\u4F8B\u8D39\u75280..0.1\uFF0C\u9ED8\u8BA40\uFF1B\u4E0D\u542B\u672A\u63D0\u4F9B\u7A0E\u8D39/\u6700\u4F4E\u6536\u8D39"
1784
+ },
1785
+ "slippage_rate": {
1786
+ "type": "number",
1787
+ "description": "\u6BCF\u8FB9\u6ED1\u70B90..0.1\uFF0C\u9ED8\u8BA40"
1788
+ }
1789
+ },
1790
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1791
+ async execute(params) {
1792
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["position_size", "--input", path]));
1793
+ }
1794
+ }));
1795
+ ctx.tools.register(defineTool2({
1796
+ name: "analyze_event_study",
1797
+ 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",
1798
+ parameters: {
1799
+ "prices": {
1800
+ "type": "array",
1801
+ "items": {
1802
+ "type": "object",
1803
+ "properties": {
1804
+ "date": {
1805
+ "type": "string",
1806
+ "description": "YYYY-MM-DD\uFF0C\u552F\u4E00\u65E5\u671F",
1807
+ "required": true
1808
+ },
1809
+ "close": {
1810
+ "type": "number",
1811
+ "description": "\u6B63\u6709\u9650\u6536\u76D8\u4EF7",
1812
+ "required": true
1813
+ }
1814
+ },
1815
+ "additionalProperties": false
1816
+ },
1817
+ "description": "\u5B8C\u6574\u65E5K\u6536\u76D8\u5E8F\u5217\uFF0C2..20000\u6761\uFF0C\u4E0D\u5F97\u8DE8\u80A1\u7968\u6216\u6DF7\u7528\u590D\u6743\u53E3\u5F84"
1818
+ },
1819
+ "benchmark_prices": {
1820
+ "type": "array",
1821
+ "items": {
1822
+ "type": "object",
1823
+ "properties": {
1824
+ "date": {
1825
+ "type": "string",
1826
+ "description": "YYYY-MM-DD\uFF0C\u552F\u4E00\u65E5\u671F",
1827
+ "required": true
1828
+ },
1829
+ "close": {
1830
+ "type": "number",
1831
+ "description": "\u6B63\u6709\u9650\u6536\u76D8\u4EF7",
1832
+ "required": true
1833
+ }
1834
+ },
1835
+ "additionalProperties": false
1836
+ },
1837
+ "description": "\u5B8C\u6574\u65E5K\u6536\u76D8\u5E8F\u5217\uFF0C2..20000\u6761\uFF0C\u4E0D\u5F97\u8DE8\u80A1\u7968\u6216\u6DF7\u7528\u590D\u6743\u53E3\u5F84"
1838
+ },
1839
+ "event_dates": {
1840
+ "type": "array",
1841
+ "items": {
1842
+ "type": "string",
1843
+ "description": "YYYY-MM-DD\uFF0C\u76D8\u540E\u516C\u544A\u4F20\u4E0B\u4E00\u4EA4\u6613\u65E5"
1844
+ },
1845
+ "description": "1..100\u4E2A\u552F\u4E00\u4E8B\u4EF6\u65E5",
1846
+ "required": true
1847
+ },
1848
+ "price_basis": {
1849
+ "type": "string",
1850
+ "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"
1851
+ },
1852
+ "horizons": {
1853
+ "type": "array",
1854
+ "items": {
1855
+ "type": "number",
1856
+ "description": "0=\u4E8B\u4EF6\u65E5\uFF0C1=\u4E0B\u4E00\u4EA4\u6613\u65E5\uFF1B\u6574\u65700..250"
1857
+ },
1858
+ "description": "1..20\u4E2A\u7A97\u53E3\uFF0C\u9ED8\u8BA40/1/5/10/20"
1859
+ },
1860
+ "start_date": {
1861
+ "type": "string",
1862
+ "description": "\u4EE3\u7801\u6A21\u5F0F\u5FC5\u9700\uFF0CYYYY-MM-DD\uFF0C\u5305\u542B\u4E8B\u4EF6\u524D\u57FA\u51C6\u65E5\u6216\u8BAD\u7EC3\u7A97\u53E3"
1863
+ },
1864
+ "end_date": {
1865
+ "type": "string",
1866
+ "description": "\u4EE3\u7801\u6A21\u5F0F\u5FC5\u9700\uFF0CYYYY-MM-DD\uFF0C\u665A\u4E8Estart_date"
1867
+ },
1868
+ "symbol": {
1869
+ "type": "string",
1870
+ "description": "\u80A1\u7968\u4EE3\u7801\uFF1B\u4E0Ebenchmark/start_date/end_date\u4E00\u8D77\u76F4\u63A5\u53D6\u6570\uFF0C\u548Cprices\u6A21\u5F0F\u4E92\u65A5"
1871
+ },
1872
+ "benchmark": {
1873
+ "type": "string",
1874
+ "description": "\u540C\u5E02\u573A\u57FA\u51C6\u4EE3\u7801\uFF1B\u4E0Esymbol\u4E00\u8D77\u4F7F\u7528"
1875
+ }
1876
+ },
1877
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1878
+ async execute(params) {
1879
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["event_study", "--input", path]));
1880
+ }
1881
+ }));
1882
+ ctx.tools.register(defineTool2({
1883
+ name: "validate_backtest",
1884
+ 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",
1885
+ parameters: {
1886
+ "datasets": {
1887
+ "type": "array",
1888
+ "items": {
1889
+ "type": "object",
1890
+ "properties": {
1891
+ "symbol": {
1892
+ "type": "string",
1893
+ "description": "\u552F\u4E00\u80A1\u7968\u4EE3\u7801",
1894
+ "required": true
1895
+ },
1896
+ "price_basis": {
1897
+ "type": "string",
1898
+ "description": "\u5DF2\u6838\u5B9E\u590D\u6743/\u539F\u59CB\u4EF7\u683C\u53E3\u5F84",
1899
+ "required": true
1900
+ },
1901
+ "bars": {
1902
+ "type": "array",
1903
+ "items": {
1904
+ "type": "object",
1905
+ "properties": {
1906
+ "date": {
1907
+ "type": "string",
1908
+ "description": "YYYY-MM-DD",
1909
+ "required": true
1910
+ },
1911
+ "open": {
1912
+ "type": "number",
1913
+ "description": "\u6709\u9650OHLCV\uFF1B\u4EF7\u683C\u4E3A\u6B63\u3001volume\u975E\u8D1F",
1914
+ "required": true
1915
+ },
1916
+ "high": {
1917
+ "type": "number",
1918
+ "description": "\u6709\u9650OHLCV\uFF1B\u4EF7\u683C\u4E3A\u6B63\u3001volume\u975E\u8D1F",
1919
+ "required": true
1920
+ },
1921
+ "low": {
1922
+ "type": "number",
1923
+ "description": "\u6709\u9650OHLCV\uFF1B\u4EF7\u683C\u4E3A\u6B63\u3001volume\u975E\u8D1F",
1924
+ "required": true
1925
+ },
1926
+ "close": {
1927
+ "type": "number",
1928
+ "description": "\u6709\u9650OHLCV\uFF1B\u4EF7\u683C\u4E3A\u6B63\u3001volume\u975E\u8D1F",
1929
+ "required": true
1930
+ },
1931
+ "volume": {
1932
+ "type": "number",
1933
+ "description": "\u6709\u9650OHLCV\uFF1B\u4EF7\u683C\u4E3A\u6B63\u3001volume\u975E\u8D1F",
1934
+ "required": true
1935
+ }
1936
+ },
1937
+ "additionalProperties": false
1938
+ },
1939
+ "description": "\u65E5\u671F\u9012\u589E\u5B8C\u6574OHLCV\uFF0C\u6BCF\u7EC4\u6700\u591A2000\u6761\uFF0C\u81F3\u5C11train_bars+test_bars",
1940
+ "required": true
1941
+ }
1942
+ },
1943
+ "additionalProperties": false
1944
+ },
1945
+ "description": "1..5\u4E2A\u6807\u7684\uFF0C\u590D\u7528get_kline\u53D6\u6570"
1946
+ },
1947
+ "strategies": {
1948
+ "type": "array",
1949
+ "items": {
1950
+ "type": "object",
1951
+ "properties": {
1952
+ "name": {
1953
+ "type": "string",
1954
+ "description": "\u552F\u4E00\u5019\u9009\u540D",
1955
+ "required": true
1956
+ },
1957
+ "strategy": {
1958
+ "type": "object",
1959
+ "additionalProperties": true,
1960
+ "description": "\u5B8C\u6574\u65E2\u6709YAML DSL\u5BF9\u5E94JSON\uFF0C\u5141\u8BB8parameters\u5F15\u7528\uFF1B\u4EC5next_open",
1961
+ "properties": {},
1962
+ "required": true
1963
+ }
1964
+ },
1965
+ "additionalProperties": false
1966
+ },
1967
+ "description": "1..5\u4E2A\u9884\u5148\u786E\u5B9A\u7684\u5019\u9009\uFF0C\u7981\u6B62\u6D4B\u8BD5\u7ED3\u679C\u56DE\u8C03\u53C2\u6570",
1968
+ "required": true
1969
+ },
1970
+ "train_bars": {
1971
+ "type": "number",
1972
+ "description": "\u8BAD\u7EC3\u4EA4\u6613\u65E5\u657030..1000\uFF0C\u9ED8\u8BA4126"
1973
+ },
1974
+ "test_bars": {
1975
+ "type": "number",
1976
+ "description": "\u6D4B\u8BD5\u4EA4\u6613\u65E5\u657030..1000\uFF0C\u9ED8\u8BA463"
1977
+ },
1978
+ "capital": {
1979
+ "type": "number",
1980
+ "description": "\u6BCF\u7A97\u53E3\u521D\u59CB\u8D44\u91D1\uFF0C\u9ED8\u8BA41000000"
1981
+ },
1982
+ "start_date": {
1983
+ "type": "string",
1984
+ "description": "\u4EE3\u7801\u6A21\u5F0F\u5FC5\u9700\uFF0CYYYY-MM-DD\uFF0C\u5305\u542B\u4E8B\u4EF6\u524D\u57FA\u51C6\u65E5\u6216\u8BAD\u7EC3\u7A97\u53E3"
1985
+ },
1986
+ "end_date": {
1987
+ "type": "string",
1988
+ "description": "\u4EE3\u7801\u6A21\u5F0F\u5FC5\u9700\uFF0CYYYY-MM-DD\uFF0C\u665A\u4E8Estart_date"
1989
+ },
1990
+ "symbols": {
1991
+ "type": "array",
1992
+ "items": {
1993
+ "type": "string"
1994
+ },
1995
+ "description": "1..5\u4E2A\u552F\u4E00\u80A1\u7968\u4EE3\u7801\uFF0C\u914D\u5408start_date/end_date\u76F4\u63A5\u53D6\u6570\uFF1B\u548Cdatasets\u4E92\u65A5"
1996
+ }
1997
+ },
1998
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
1999
+ async execute(params) {
2000
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["robustness", "--input", path]));
2001
+ }
2002
+ }));
2003
+ ctx.tools.register(defineTool2({
2004
+ name: "compare_analysis_snapshots",
2005
+ 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",
2006
+ parameters: {
2007
+ "previous": {
2008
+ "type": "object",
2009
+ "additionalProperties": true,
2010
+ "description": "JSON\u5BF9\u8C61\uFF0C\u8BE6\u89C1\u5171\u4EABSkill\u4E0EREADME",
2011
+ "properties": {},
2012
+ "required": true
2013
+ },
2014
+ "current": {
2015
+ "type": "object",
2016
+ "additionalProperties": true,
2017
+ "description": "JSON\u5BF9\u8C61\uFF0C\u8BE6\u89C1\u5171\u4EABSkill\u4E0EREADME",
2018
+ "properties": {},
2019
+ "required": true
2020
+ }
2021
+ },
2022
+ output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
2023
+ async execute(params) {
2024
+ return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["snapshot", "--input", path]));
2025
+ }
2026
+ }));
1183
2027
  registerSkills(ctx);
2028
+ if (config.toolDiscovery !== false) {
2029
+ registerToolDiscovery(ctx, new Set(ctx.tools.schemas?.().filter((tool) => !previousTools.has(tool.name)).map((tool) => tool.name)));
2030
+ }
1184
2031
  }
1185
2032
  export {
1186
2033
  __setExecutor,