@weaxs/dsh-stock-analysis 0.2.10 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -3
- package/dist/client.js +88 -0
- package/dist/index.js +625 -110
- package/dist/web/app.js +871 -0
- package/dist/web/index.html +87 -0
- package/dist/web/style.css +292 -0
- package/package.json +13 -3
- package/skills/stock-analysis/SKILL.md +4 -1
- package/tools/alert_rules.py +63 -14
- package/tools/name_resolver.py +16 -14
- package/tools/requirements.txt +2 -2
- package/tools/search_intel.py +2 -2
- package/tools/signal_tracker.py +6 -5
- package/tools/stock_data.py +255 -24
- package/tools/tiaa_disclosures.py +263 -0
package/dist/index.js
CHANGED
|
@@ -81,11 +81,11 @@ function commandTimeout(script, args) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// dsh/index.ts
|
|
84
|
-
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
84
|
+
import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2 } from "node:fs";
|
|
85
85
|
import * as cp from "node:child_process";
|
|
86
86
|
import { promisify } from "node:util";
|
|
87
|
-
import { dirname, join as
|
|
88
|
-
import { fileURLToPath } from "node:url";
|
|
87
|
+
import { dirname as dirname2, join as join4 } from "node:path";
|
|
88
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
89
89
|
import {
|
|
90
90
|
defineTool as defineTool2
|
|
91
91
|
} from "@deepseek-ai/dsh-tools";
|
|
@@ -100,9 +100,16 @@ function venvPythonPath(rootDir) {
|
|
|
100
100
|
// dsh/discovery.ts
|
|
101
101
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
102
102
|
var SEARCH = "stock_tool_search";
|
|
103
|
-
function
|
|
104
|
-
if (typeof ctx.
|
|
105
|
-
const
|
|
103
|
+
function createToolDiscovery(ctx) {
|
|
104
|
+
if (typeof ctx.tools.resolve !== "function" || ctx.tools.get(SEARCH)) return () => void 0;
|
|
105
|
+
const names = /* @__PURE__ */ new Map();
|
|
106
|
+
const loaded = /* @__PURE__ */ new WeakMap();
|
|
107
|
+
const ptc = /* @__PURE__ */ new WeakSet();
|
|
108
|
+
const active = (agent) => {
|
|
109
|
+
if (ctx.tools.get(SEARCH, agent) && !ptc.has(agent)) return true;
|
|
110
|
+
loaded.delete(agent);
|
|
111
|
+
return false;
|
|
112
|
+
};
|
|
106
113
|
ctx.tools.register(defineTool({
|
|
107
114
|
name: SEARCH,
|
|
108
115
|
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",
|
|
@@ -119,37 +126,535 @@ function registerToolDiscovery(ctx, names) {
|
|
|
119
126
|
if (!terms.length || !Number.isInteger(limit) || limit < 1 || limit > 20) {
|
|
120
127
|
return JSON.stringify({ error: "query must contain searchable text and limit must be an integer from 1 to 20" });
|
|
121
128
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const candidates =
|
|
129
|
+
if (!exec.agent) return JSON.stringify({ error: "Tool discovery is unavailable for this agent; use its directly exposed tools" });
|
|
130
|
+
const agent = exec.agent;
|
|
131
|
+
const candidates = [...names].filter(([name2]) => ctx.tools.get(name2, agent)).map(([name2, description]) => ({ tool: { name: name2, description }, text: `${name2} ${description}`.toLowerCase() }));
|
|
125
132
|
const weights = terms.map((term) => 1 / (1 + candidates.filter(({ text }) => text.includes(term)).length));
|
|
126
133
|
const matches = candidates.map(({ tool, text }) => {
|
|
127
134
|
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);
|
|
128
135
|
return { tool, score };
|
|
129
136
|
}).filter((match) => match.score > 0).sort((a, b) => b.score - a.score || a.tool.name.length - b.tool.name.length || a.tool.name.localeCompare(b.tool.name)).slice(0, limit);
|
|
130
|
-
|
|
131
|
-
|
|
137
|
+
const set = loaded.get(agent) ?? /* @__PURE__ */ new Set();
|
|
138
|
+
for (const { tool } of matches) set.add(tool.name);
|
|
139
|
+
loaded.set(agent, set);
|
|
140
|
+
return JSON.stringify({ loaded: matches.map(({ tool }) => tool) });
|
|
132
141
|
}
|
|
133
142
|
}));
|
|
134
143
|
ctx.on("system-prompt/assemble", async (_assembly, context, next) => {
|
|
135
144
|
const result = await next();
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
if (context.scope) {
|
|
146
|
+
if (result.sections.some((section) => section.name === "tools:sdk")) ptc.add(context.scope);
|
|
147
|
+
else ptc.delete(context.scope);
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|
+
});
|
|
151
|
+
return ({ name: name2, description }) => {
|
|
152
|
+
names.set(name2, description);
|
|
153
|
+
return { when: ({ agent }) => !active(agent) || (loaded.get(agent)?.has(name2) ?? false) };
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// dsh/dashboard.ts
|
|
158
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
159
|
+
import { homedir } from "node:os";
|
|
160
|
+
import { dirname, join as join3 } from "node:path";
|
|
161
|
+
import { fileURLToPath } from "node:url";
|
|
162
|
+
import { randomUUID } from "node:crypto";
|
|
163
|
+
var DASHBOARD_BASE = "/stock-analysis";
|
|
164
|
+
var REGIONS = ["cn", "hk", "us", "jp", "kr", "tw"];
|
|
165
|
+
var STATIC_FILES = /* @__PURE__ */ new Map([
|
|
166
|
+
["/", ["index.html", "text/html; charset=utf-8"]],
|
|
167
|
+
["/app.js", ["app.js", "text/javascript; charset=utf-8"]],
|
|
168
|
+
["/style.css", ["style.css", "text/css; charset=utf-8"]]
|
|
169
|
+
]);
|
|
170
|
+
var MAX_WATCHLIST = 30;
|
|
171
|
+
var MAX_PYTHON = 4;
|
|
172
|
+
var TICK_MS = 1e4;
|
|
173
|
+
var SECOND = 1e3;
|
|
174
|
+
var MINUTE = 60 * SECOND;
|
|
175
|
+
var CN_INDEX_SYMBOLS = ["sh000001", "sz399001", "sz399006", "sh000688", "sh000300", "sh000016"];
|
|
176
|
+
var INDEX_SYMBOLS = {
|
|
177
|
+
cn: CN_INDEX_SYMBOLS,
|
|
178
|
+
hk: ["^HSI", "^HSCE", "^HSTECH"],
|
|
179
|
+
us: ["^DJI", "^IXIC", "^GSPC", "^RUT"],
|
|
180
|
+
jp: ["^N225", "^TOPX"],
|
|
181
|
+
kr: ["^KS11", "^KQ11"],
|
|
182
|
+
tw: ["^TWII"]
|
|
183
|
+
};
|
|
184
|
+
var RIBBON = [
|
|
185
|
+
["cn", "sh000001"],
|
|
186
|
+
["cn", "sz399001"],
|
|
187
|
+
["cn", "sz399006"],
|
|
188
|
+
["hk", "^HSI"],
|
|
189
|
+
["hk", "^HSTECH"],
|
|
190
|
+
["us", "^IXIC"],
|
|
191
|
+
["us", "^GSPC"],
|
|
192
|
+
["us", "^DJI"],
|
|
193
|
+
["jp", "^N225"],
|
|
194
|
+
["kr", "^KS11"],
|
|
195
|
+
["tw", "^TWII"]
|
|
196
|
+
];
|
|
197
|
+
var TRADING_PHASES = /* @__PURE__ */ new Set(["morning", "afternoon", "intraday"]);
|
|
198
|
+
var HttpError = class extends Error {
|
|
199
|
+
constructor(status, message) {
|
|
200
|
+
super(message);
|
|
201
|
+
this.status = status;
|
|
202
|
+
}
|
|
203
|
+
status;
|
|
204
|
+
};
|
|
205
|
+
function assertApiAccess(req) {
|
|
206
|
+
let hostname = "";
|
|
207
|
+
try {
|
|
208
|
+
hostname = new URL(`http://${req.headers.host}`).hostname.replace(/^\[|\]$/g, "").split("%")[0];
|
|
209
|
+
} catch {
|
|
210
|
+
}
|
|
211
|
+
if (!["127.0.0.1", "localhost", "::1"].includes(hostname)) throw new HttpError(403, "\u53EA\u5141\u8BB8\u672C\u673A\u8BBF\u95EE\u4EEA\u8868\u76D8 API");
|
|
212
|
+
const site = req.headers["sec-fetch-site"];
|
|
213
|
+
if (site && !["same-origin", "none"].includes(site)) throw new HttpError(403, "\u53EA\u5141\u8BB8\u540C\u6E90\u9875\u9762\u8BBF\u95EE\u4EEA\u8868\u76D8 API");
|
|
214
|
+
const origin = req.headers.origin;
|
|
215
|
+
if (origin && origin.replace(/^https?:\/\//, "") !== req.headers.host) throw new HttpError(403, "\u53EA\u5141\u8BB8\u540C\u6E90\u9875\u9762\u8BBF\u95EE\u4EEA\u8868\u76D8 API");
|
|
216
|
+
}
|
|
217
|
+
function normalizeWatchlist(input) {
|
|
218
|
+
if (!Array.isArray(input)) throw new HttpError(400, "symbols \u5FC5\u987B\u662F\u80A1\u7968\u4EE3\u7801\u6570\u7EC4");
|
|
219
|
+
const symbols = [...new Set(input.map((value) => {
|
|
220
|
+
if (typeof value !== "string") throw new HttpError(400, "\u80A1\u7968\u4EE3\u7801\u5FC5\u987B\u662F\u5B57\u7B26\u4E32");
|
|
221
|
+
const symbol = value.trim().toUpperCase();
|
|
222
|
+
if (!/^[A-Z0-9][A-Z0-9.-]{0,31}$/.test(symbol)) throw new HttpError(400, "\u80A1\u7968\u4EE3\u7801\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
223
|
+
return /^(?:SH|SZ|BJ)\d{6}$/.test(symbol) ? symbol.toLowerCase() : symbol;
|
|
224
|
+
}))];
|
|
225
|
+
if (symbols.length > MAX_WATCHLIST) throw new HttpError(400, `\u81EA\u9009\u80A1\u6700\u591A\u4FDD\u5B58 ${MAX_WATCHLIST} \u53EA`);
|
|
226
|
+
return symbols;
|
|
227
|
+
}
|
|
228
|
+
function readWatchlist(file) {
|
|
229
|
+
let raw;
|
|
230
|
+
try {
|
|
231
|
+
raw = readFileSync(file, "utf8");
|
|
232
|
+
} catch (error) {
|
|
233
|
+
if (error.code === "ENOENT") return [];
|
|
234
|
+
throw new Error("\u65E0\u6CD5\u8BFB\u53D6\u81EA\u9009\u80A1\u6587\u4EF6");
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
const value = JSON.parse(raw);
|
|
238
|
+
return normalizeWatchlist(value.symbols);
|
|
239
|
+
} catch {
|
|
240
|
+
throw new Error("\u81EA\u9009\u80A1\u6587\u4EF6\u5DF2\u635F\u574F\uFF0C\u8BF7\u5148\u4FEE\u590D\u6216\u79FB\u8D70\u8BE5\u6587\u4EF6");
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function writeWatchlist(file, input) {
|
|
244
|
+
readWatchlist(file);
|
|
245
|
+
const symbols = normalizeWatchlist(input);
|
|
246
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
247
|
+
const temp = `${file}.${process.pid}-${randomUUID()}.tmp`;
|
|
248
|
+
try {
|
|
249
|
+
writeFileSync(temp, `${JSON.stringify({ version: 1, symbols }, null, 2)}
|
|
250
|
+
`, { encoding: "utf8", mode: 384 });
|
|
251
|
+
renameSync(temp, file);
|
|
252
|
+
} finally {
|
|
253
|
+
rmSync(temp, { force: true });
|
|
254
|
+
}
|
|
255
|
+
return symbols;
|
|
256
|
+
}
|
|
257
|
+
function sendJson(res, status, value) {
|
|
258
|
+
res.writeHead(status, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" });
|
|
259
|
+
res.end(JSON.stringify(value));
|
|
260
|
+
}
|
|
261
|
+
async function readJson(req, max = 16 * 1024) {
|
|
262
|
+
if (!/^application\/json\b/.test(req.headers["content-type"] ?? "")) throw new HttpError(415, "\u8BF7\u4F7F\u7528 JSON \u8BF7\u6C42");
|
|
263
|
+
return new Promise((resolve, reject) => {
|
|
264
|
+
let size = 0;
|
|
265
|
+
let tooLarge = false;
|
|
266
|
+
const chunks = [];
|
|
267
|
+
req.on("data", (chunk) => {
|
|
268
|
+
size += chunk.length;
|
|
269
|
+
if (size > max) tooLarge = true;
|
|
270
|
+
else chunks.push(chunk);
|
|
271
|
+
});
|
|
272
|
+
req.on("end", () => {
|
|
273
|
+
if (tooLarge) return reject(new HttpError(413, "\u8BF7\u6C42\u5185\u5BB9\u8FC7\u5927"));
|
|
274
|
+
try {
|
|
275
|
+
resolve(JSON.parse(Buffer.concat(chunks).toString("utf8") || "{}"));
|
|
276
|
+
} catch {
|
|
277
|
+
reject(new HttpError(400, "JSON \u8BF7\u6C42\u683C\u5F0F\u4E0D\u6B63\u786E"));
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
req.on("error", reject);
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
function dashboardQuoteSymbol(symbol) {
|
|
284
|
+
if (!/^\d{6}$/.test(symbol)) return symbol;
|
|
285
|
+
if (/^(?:43|81|82|83|87|88|92)/.test(symbol)) return `bj${symbol}`;
|
|
286
|
+
return `${/^[569]/.test(symbol) ? "sh" : "sz"}${symbol}`;
|
|
287
|
+
}
|
|
288
|
+
function symbolRegion(symbol) {
|
|
289
|
+
if (/^(?:sh|sz|bj)?\d{6}$/.test(symbol)) return "cn";
|
|
290
|
+
if (/\.HK$/.test(symbol)) return "hk";
|
|
291
|
+
if (/\.T$/.test(symbol)) return "jp";
|
|
292
|
+
if (/\.K[SQ]$/.test(symbol)) return "kr";
|
|
293
|
+
if (/\.TWO?$/.test(symbol)) return "tw";
|
|
294
|
+
return "us";
|
|
295
|
+
}
|
|
296
|
+
function safeError(value, fallback) {
|
|
297
|
+
return typeof value === "string" && value && value.length <= 160 && !/[/\\\n]/.test(value) ? value : fallback;
|
|
298
|
+
}
|
|
299
|
+
function createPriorityLimiter(limit) {
|
|
300
|
+
let active = 0;
|
|
301
|
+
const waiting = [];
|
|
302
|
+
const next = () => {
|
|
303
|
+
while (active < limit && waiting.length) {
|
|
304
|
+
waiting.sort((a, b) => a.priority - b.priority);
|
|
305
|
+
active++;
|
|
306
|
+
waiting.shift().start();
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
return {
|
|
310
|
+
run(priority, fn) {
|
|
311
|
+
return new Promise((resolve, reject) => {
|
|
312
|
+
waiting.push({
|
|
313
|
+
priority,
|
|
314
|
+
start: () => fn().then(resolve, reject).finally(() => {
|
|
315
|
+
active--;
|
|
316
|
+
next();
|
|
317
|
+
})
|
|
318
|
+
});
|
|
319
|
+
next();
|
|
320
|
+
});
|
|
321
|
+
},
|
|
322
|
+
get queued() {
|
|
323
|
+
return waiting.length + active;
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function parseJson(raw) {
|
|
328
|
+
try {
|
|
329
|
+
return JSON.parse(raw);
|
|
330
|
+
} catch {
|
|
331
|
+
return { error: "\u884C\u60C5\u547D\u4EE4\u8FD4\u56DE\u4E86\u65E0\u6CD5\u89E3\u6790\u7684\u6570\u636E" };
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function trendRows(value) {
|
|
335
|
+
if (!Array.isArray(value)) throw new Error("K\u7EBF\u6570\u636E\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
336
|
+
return value.map((row) => ({ date: String(row?.date ?? ""), close: Number(row?.close) })).filter((row) => Number.isFinite(row.close) && row.close > 0);
|
|
337
|
+
}
|
|
338
|
+
function createDashboardHandler(options) {
|
|
339
|
+
const { runPy: runPy2, watchlistFile, webDir } = options;
|
|
340
|
+
const limiter = createPriorityLimiter(MAX_PYTHON);
|
|
341
|
+
const slots = /* @__PURE__ */ new Map();
|
|
342
|
+
const inflight = /* @__PURE__ */ new Set();
|
|
343
|
+
let viewedRegion = "cn";
|
|
344
|
+
let lastSeen = 0;
|
|
345
|
+
const slot = (key) => {
|
|
346
|
+
let value = slots.get(key);
|
|
347
|
+
if (!value) slots.set(key, value = { value: null, error: null, updatedAt: 0, checkedAt: 0, running: false, force: false, failures: 0 });
|
|
348
|
+
return value;
|
|
349
|
+
};
|
|
350
|
+
const trading = (region) => TRADING_PHASES.has(slots.get(`phase:${region}`)?.value?.phase ?? "");
|
|
351
|
+
function freshFor(kind, region) {
|
|
352
|
+
const open = trading(region);
|
|
353
|
+
const watched = Date.now() - lastSeen < 2 * MINUTE;
|
|
354
|
+
if (kind === "phase") return watched ? MINUTE : 5 * MINUTE;
|
|
355
|
+
if (slots.get(`phase:${region}`)?.value?.phase === "closed") return 2 * 60 * MINUTE;
|
|
356
|
+
switch (kind) {
|
|
357
|
+
case "quote":
|
|
358
|
+
case "indices":
|
|
359
|
+
return open ? watched ? 30 * SECOND : 5 * MINUTE : 30 * MINUTE;
|
|
360
|
+
case "trend":
|
|
361
|
+
return open ? 10 * MINUTE : 60 * MINUTE;
|
|
362
|
+
case "sectors":
|
|
363
|
+
return open ? watched ? MINUTE : 5 * MINUTE : 30 * MINUTE;
|
|
364
|
+
case "stats":
|
|
365
|
+
return open ? watched ? 2 * MINUTE : 10 * MINUTE : 60 * MINUTE;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
const py = async (script, args, timeoutMs) => parseJson(await runPy2(script, args, timeoutMs));
|
|
369
|
+
function quoteJob(symbol, priority) {
|
|
370
|
+
return {
|
|
371
|
+
key: `quote:${symbol}`,
|
|
372
|
+
kind: "quote",
|
|
373
|
+
region: symbolRegion(symbol),
|
|
374
|
+
priority,
|
|
375
|
+
run: async () => {
|
|
376
|
+
const value = await py("stock_data.py", ["quote", dashboardQuoteSymbol(symbol)], 2e4);
|
|
377
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("\u62A5\u4EF7\u6570\u636E\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
378
|
+
if (value.error) throw new Error(safeError(value.error, "\u62A5\u4EF7\u6682\u4E0D\u53EF\u7528"));
|
|
379
|
+
return { ...value, symbol };
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function trendJob(symbol, region, priority) {
|
|
384
|
+
return {
|
|
385
|
+
key: `trend:${symbol}`,
|
|
386
|
+
kind: "trend",
|
|
387
|
+
region,
|
|
388
|
+
priority,
|
|
389
|
+
// Yahoo-backed regions regularly need 20-30 s from mainland networks.
|
|
390
|
+
run: async () => trendRows(await py("stock_data.py", ["kline", symbol, "--period", "daily", "--count", "30"], region === "cn" ? 2e4 : 4e4))
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
function jobs(symbols) {
|
|
394
|
+
const list = [];
|
|
395
|
+
for (const region of REGIONS) {
|
|
396
|
+
list.push({
|
|
397
|
+
key: `phase:${region}`,
|
|
398
|
+
kind: "phase",
|
|
399
|
+
region,
|
|
400
|
+
priority: 0,
|
|
401
|
+
run: async () => {
|
|
402
|
+
const value = await py("trading_calendar.py", ["phase", region.toUpperCase()], 1e4);
|
|
403
|
+
if (!value || typeof value !== "object" || value.error) throw new Error("\u4EA4\u6613\u9636\u6BB5\u6682\u4E0D\u53EF\u7528");
|
|
404
|
+
return value;
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
for (const symbol of symbols) list.push(quoteJob(symbol, 1));
|
|
409
|
+
for (const region of REGIONS) {
|
|
410
|
+
const indexPriority = region === viewedRegion ? 1 : 2;
|
|
411
|
+
if (region === "cn") {
|
|
412
|
+
for (const code of CN_INDEX_SYMBOLS) list.push(quoteJob(code, indexPriority));
|
|
413
|
+
} else {
|
|
414
|
+
list.push({
|
|
415
|
+
key: `indices:${region}`,
|
|
416
|
+
kind: "indices",
|
|
417
|
+
region,
|
|
418
|
+
priority: indexPriority,
|
|
419
|
+
run: async () => {
|
|
420
|
+
const value = await py("stock_data.py", ["market_indices", "--region", region], 6e4);
|
|
421
|
+
if (!Array.isArray(value)) throw new Error(safeError(value?.error, "\u6307\u6570\u6682\u4E0D\u53EF\u7528"));
|
|
422
|
+
return value;
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
}
|
|
140
426
|
}
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
427
|
+
for (const symbol of symbols) list.push(trendJob(symbol, symbolRegion(symbol), 3));
|
|
428
|
+
for (const region of REGIONS) {
|
|
429
|
+
for (const code of INDEX_SYMBOLS[region]) {
|
|
430
|
+
const ribbon = RIBBON.some(([, item]) => item === code);
|
|
431
|
+
list.push(trendJob(code, region, ribbon || region === viewedRegion ? 3 : 4));
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
list.push({
|
|
435
|
+
key: "sectors",
|
|
436
|
+
kind: "sectors",
|
|
437
|
+
region: "cn",
|
|
438
|
+
priority: 4,
|
|
439
|
+
run: async () => {
|
|
440
|
+
const value = await py("stock_data.py", ["sector_rankings", "--top", "5", "--direction", "both", "--board-type", "industry"], 25e3);
|
|
441
|
+
if (!value || !Array.isArray(value.top)) throw new Error(safeError(value?.error, "\u884C\u4E1A\u6392\u884C\u6682\u4E0D\u53EF\u7528"));
|
|
442
|
+
return { top: value.top, bottom: Array.isArray(value.bottom) ? value.bottom : [] };
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
list.push({
|
|
446
|
+
// Slow (~15 s alone) but first-viewport content: start it in the first wave on its own worker.
|
|
447
|
+
key: "stats",
|
|
448
|
+
kind: "stats",
|
|
449
|
+
region: "cn",
|
|
450
|
+
priority: 2,
|
|
451
|
+
run: async () => {
|
|
452
|
+
const value = await py("stock_data.py", ["market_stats"], 13e4);
|
|
453
|
+
if (!value || typeof value !== "object" || value.error) throw new Error(safeError(value?.error, "\u5E02\u573A\u5BBD\u5EA6\u6682\u4E0D\u53EF\u7528"));
|
|
454
|
+
return value;
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
return list;
|
|
458
|
+
}
|
|
459
|
+
function due(job, now) {
|
|
460
|
+
const entry = slot(job.key);
|
|
461
|
+
if (entry.running) return false;
|
|
462
|
+
if (entry.force || entry.checkedAt === 0) return true;
|
|
463
|
+
const fresh = freshFor(job.kind, job.region);
|
|
464
|
+
const retry = Math.min(fresh, MINUTE * 2 ** Math.min(entry.failures - 1, 5));
|
|
465
|
+
return now - entry.checkedAt >= (entry.error ? retry : fresh);
|
|
466
|
+
}
|
|
467
|
+
function start(job) {
|
|
468
|
+
const entry = slot(job.key);
|
|
469
|
+
entry.running = true;
|
|
470
|
+
entry.force = false;
|
|
471
|
+
const task = limiter.run(job.priority, job.run).then(
|
|
472
|
+
(value) => {
|
|
473
|
+
entry.value = value;
|
|
474
|
+
entry.error = null;
|
|
475
|
+
entry.failures = 0;
|
|
476
|
+
entry.updatedAt = Date.now();
|
|
477
|
+
},
|
|
478
|
+
(error) => {
|
|
479
|
+
entry.error = safeError(error instanceof Error ? error.message : null, "\u6570\u636E\u6682\u4E0D\u53EF\u7528");
|
|
480
|
+
entry.failures++;
|
|
481
|
+
}
|
|
482
|
+
).finally(() => {
|
|
483
|
+
entry.running = false;
|
|
484
|
+
entry.checkedAt = Date.now();
|
|
485
|
+
inflight.delete(task);
|
|
486
|
+
});
|
|
487
|
+
inflight.add(task);
|
|
488
|
+
return task;
|
|
489
|
+
}
|
|
490
|
+
function currentSymbols() {
|
|
491
|
+
try {
|
|
492
|
+
return readWatchlist(watchlistFile);
|
|
493
|
+
} catch {
|
|
494
|
+
return [];
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
async function tick() {
|
|
498
|
+
const symbols = currentSymbols();
|
|
499
|
+
const list = jobs(symbols);
|
|
500
|
+
const keep = new Set(list.map((job) => job.key));
|
|
501
|
+
for (const key of slots.keys()) if (!keep.has(key) && !slots.get(key).running) slots.delete(key);
|
|
502
|
+
const now = Date.now();
|
|
503
|
+
await Promise.all(list.filter((job) => due(job, now)).sort((a, b) => a.priority - b.priority).map(start));
|
|
504
|
+
}
|
|
505
|
+
async function settle() {
|
|
506
|
+
while (inflight.size) await Promise.all([...inflight]);
|
|
507
|
+
}
|
|
508
|
+
const kick = () => {
|
|
509
|
+
void tick();
|
|
510
|
+
};
|
|
511
|
+
function slotView(key) {
|
|
512
|
+
const entry = slots.get(key);
|
|
513
|
+
return {
|
|
514
|
+
value: entry?.value ?? null,
|
|
515
|
+
error: entry?.error ?? null,
|
|
516
|
+
updatedAt: entry?.updatedAt ? new Date(entry.updatedAt).toISOString() : null,
|
|
517
|
+
loading: !entry || entry.running || entry.checkedAt === 0
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
function indexRow(region, code) {
|
|
521
|
+
const trend = slotView(`trend:${code}`);
|
|
522
|
+
if (region === "cn") {
|
|
523
|
+
const quote2 = slotView(`quote:${code}`);
|
|
524
|
+
return { region, code, quote: quote2.value, error: quote2.error, loading: quote2.loading, trend: trend.value };
|
|
525
|
+
}
|
|
526
|
+
const indices = slotView(`indices:${region}`);
|
|
527
|
+
const quote = Array.isArray(indices.value) ? indices.value.find((row) => row?.code === code) ?? null : null;
|
|
528
|
+
return { region, code, quote, error: indices.error, loading: indices.loading, trend: trend.value };
|
|
529
|
+
}
|
|
530
|
+
function snapshot(region) {
|
|
531
|
+
lastSeen = Date.now();
|
|
532
|
+
viewedRegion = region;
|
|
533
|
+
const symbols = readWatchlist(watchlistFile);
|
|
534
|
+
kick();
|
|
535
|
+
return {
|
|
536
|
+
watchlist: symbols.map((symbol) => {
|
|
537
|
+
const quote = slotView(`quote:${symbol}`);
|
|
538
|
+
const trend = slotView(`trend:${symbol}`);
|
|
539
|
+
return {
|
|
540
|
+
symbol,
|
|
541
|
+
region: symbolRegion(symbol),
|
|
542
|
+
quote: quote.value,
|
|
543
|
+
quoteError: quote.error,
|
|
544
|
+
quoteLoading: quote.loading,
|
|
545
|
+
trend: trend.value,
|
|
546
|
+
trendError: trend.error
|
|
547
|
+
};
|
|
548
|
+
}),
|
|
549
|
+
ribbon: RIBBON.map(([item, code]) => indexRow(item, code)),
|
|
550
|
+
phases: Object.fromEntries(REGIONS.map((item) => [item, slotView(`phase:${item}`).value])),
|
|
551
|
+
market: { region, indices: INDEX_SYMBOLS[region].map((code) => indexRow(region, code)) },
|
|
552
|
+
// A-share breadth and sectors are the only whole-market statistics; other regions stay honest blanks.
|
|
553
|
+
stats: slotView("stats"),
|
|
554
|
+
sectors: slotView("sectors"),
|
|
555
|
+
pending: limiter.queued,
|
|
556
|
+
fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
function parseRegion(value) {
|
|
560
|
+
const region = value ?? "cn";
|
|
561
|
+
if (!REGIONS.includes(region)) throw new HttpError(400, "\u4E0D\u652F\u6301\u7684\u5E02\u573A\u533A\u57DF");
|
|
562
|
+
return region;
|
|
563
|
+
}
|
|
564
|
+
let timer;
|
|
565
|
+
if (options.warm) {
|
|
566
|
+
kick();
|
|
567
|
+
timer = setInterval(kick, TICK_MS);
|
|
568
|
+
timer.unref();
|
|
569
|
+
}
|
|
570
|
+
const handler = (async (req, res) => {
|
|
571
|
+
try {
|
|
572
|
+
const url = new URL(req.url ?? "/", "http://dashboard.local");
|
|
573
|
+
if (url.pathname !== DASHBOARD_BASE && !url.pathname.startsWith(`${DASHBOARD_BASE}/`)) return sendJson(res, 404, { error: "Not found" });
|
|
574
|
+
const rest = url.pathname.slice(DASHBOARD_BASE.length) || "/";
|
|
575
|
+
if (rest.startsWith("/api/")) assertApiAccess(req);
|
|
576
|
+
if (rest === "/api/snapshot") {
|
|
577
|
+
if (req.method !== "GET") return sendJson(res, 405, { error: "Method not allowed" });
|
|
578
|
+
return sendJson(res, 200, snapshot(parseRegion(url.searchParams.get("region"))));
|
|
579
|
+
}
|
|
580
|
+
if (rest === "/api/refresh") {
|
|
581
|
+
if (req.method !== "POST") return sendJson(res, 405, { error: "Method not allowed" });
|
|
582
|
+
for (const entry of slots.values()) if (!entry.running) entry.force = true;
|
|
583
|
+
kick();
|
|
584
|
+
return sendJson(res, 202, { ok: true, pending: limiter.queued });
|
|
585
|
+
}
|
|
586
|
+
if (rest === "/api/watchlist") {
|
|
587
|
+
if (req.method === "GET") return sendJson(res, 200, { symbols: readWatchlist(watchlistFile) });
|
|
588
|
+
if (req.method === "POST") {
|
|
589
|
+
const body2 = await readJson(req);
|
|
590
|
+
if (!body2?.op) throw new HttpError(400, "\u5FC5\u987B\u6307\u5B9A add \u6216 remove \u64CD\u4F5C");
|
|
591
|
+
const symbols = normalizeWatchlist(body2.symbols);
|
|
592
|
+
const current = readWatchlist(watchlistFile);
|
|
593
|
+
let saved;
|
|
594
|
+
if (body2.op === "add") saved = writeWatchlist(watchlistFile, [...current, ...symbols]);
|
|
595
|
+
else if (body2.op === "remove") saved = writeWatchlist(watchlistFile, current.filter((symbol) => !symbols.includes(symbol)));
|
|
596
|
+
else throw new HttpError(400, "\u4E0D\u652F\u6301\u81EA\u9009\u80A1\u64CD\u4F5C");
|
|
597
|
+
kick();
|
|
598
|
+
return sendJson(res, 200, { symbols: saved });
|
|
599
|
+
}
|
|
600
|
+
return sendJson(res, 405, { error: "Method not allowed" });
|
|
601
|
+
}
|
|
602
|
+
if (rest.startsWith("/api/")) return sendJson(res, 404, { error: "Not found" });
|
|
603
|
+
if (req.method !== "GET" && req.method !== "HEAD") return sendJson(res, 404, { error: "Not found" });
|
|
604
|
+
const asset = STATIC_FILES.get(rest);
|
|
605
|
+
if (!asset) return sendJson(res, 404, { error: "Not found" });
|
|
606
|
+
const [file, contentType] = asset;
|
|
607
|
+
let body;
|
|
608
|
+
try {
|
|
609
|
+
body = readFileSync(join3(webDir, file));
|
|
610
|
+
} catch {
|
|
611
|
+
return sendJson(res, 404, { error: "Not found" });
|
|
612
|
+
}
|
|
613
|
+
res.writeHead(200, {
|
|
614
|
+
"content-type": contentType,
|
|
615
|
+
"content-length": body.length,
|
|
616
|
+
"cache-control": "no-cache",
|
|
617
|
+
"x-content-type-options": "nosniff"
|
|
618
|
+
});
|
|
619
|
+
res.end(req.method === "HEAD" ? void 0 : body);
|
|
620
|
+
} catch (error) {
|
|
621
|
+
if (error instanceof HttpError) return sendJson(res, error.status, { error: error.message });
|
|
622
|
+
const message = error instanceof Error && !/[/\\]/.test(error.message) ? error.message : "\u4EEA\u8868\u76D8\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528";
|
|
623
|
+
return sendJson(res, 500, { error: message });
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
handler.tick = tick;
|
|
627
|
+
handler.settle = settle;
|
|
628
|
+
handler.dispose = () => {
|
|
629
|
+
if (timer) clearInterval(timer);
|
|
630
|
+
timer = void 0;
|
|
631
|
+
};
|
|
632
|
+
return handler;
|
|
633
|
+
}
|
|
634
|
+
function registerDashboard(ctx, runPy2) {
|
|
635
|
+
if (typeof ctx.inject !== "function") return;
|
|
636
|
+
const here2 = dirname(fileURLToPath(import.meta.url));
|
|
637
|
+
const webDir = [join3(here2, "web"), join3(here2, "dist", "web")].find((dir) => existsSync(join3(dir, "app.js"))) ?? join3(here2, "web");
|
|
638
|
+
const dataRoot = process.env.DSH_HOME || join3(homedir(), ".dsh");
|
|
639
|
+
const watchlistFile = process.env.STOCK_WATCHLIST_FILE || join3(dataRoot, "stock-analysis", "watchlist.json");
|
|
640
|
+
ctx.inject(["webServer"], (nested) => {
|
|
641
|
+
const c = nested;
|
|
642
|
+
c.effect(() => {
|
|
643
|
+
const handler = createDashboardHandler({ runPy: runPy2, watchlistFile, webDir, warm: true });
|
|
644
|
+
const disposeRoute = c.webServer.register({ kind: "prefix", path: DASHBOARD_BASE, handler });
|
|
645
|
+
return () => {
|
|
646
|
+
handler.dispose();
|
|
647
|
+
disposeRoute();
|
|
648
|
+
};
|
|
649
|
+
});
|
|
145
650
|
});
|
|
146
651
|
}
|
|
147
652
|
|
|
148
653
|
// dsh/index.ts
|
|
149
|
-
var defaultExecutor = async (bin, argv) => {
|
|
654
|
+
var defaultExecutor = async (bin, argv, timeoutMs) => {
|
|
150
655
|
const exec = promisify(cp.execFile);
|
|
151
656
|
try {
|
|
152
|
-
const { stdout } = await exec(bin, argv, { maxBuffer: 32 * 1024 * 1024, timeout: commandTimeout(argv[0], argv.slice(1)) });
|
|
657
|
+
const { stdout } = await exec(bin, argv, { maxBuffer: 32 * 1024 * 1024, timeout: timeoutMs ?? commandTimeout(argv[0], argv.slice(1)) });
|
|
153
658
|
return stdout;
|
|
154
659
|
} catch (error) {
|
|
155
660
|
const stdout = error.stdout;
|
|
@@ -165,19 +670,19 @@ var executor = defaultExecutor;
|
|
|
165
670
|
function __setExecutor(fn) {
|
|
166
671
|
executor = fn;
|
|
167
672
|
}
|
|
168
|
-
var here =
|
|
169
|
-
var
|
|
170
|
-
var
|
|
673
|
+
var here = dirname2(fileURLToPath2(import.meta.url));
|
|
674
|
+
var pkgRoot = [join4(here, ".."), join4(here, "..", "..")].find((root) => existsSync2(join4(root, "tools"))) ?? join4(here, "..");
|
|
675
|
+
var toolsDir = join4(pkgRoot, "tools");
|
|
171
676
|
var isWin2 = process.platform === "win32";
|
|
172
677
|
function pythonBin() {
|
|
173
|
-
for (const root of [pkgRoot,
|
|
678
|
+
for (const root of [pkgRoot, join4(pkgRoot, "..")]) {
|
|
174
679
|
const candidate = venvPythonPath(root);
|
|
175
|
-
if (
|
|
680
|
+
if (existsSync2(candidate)) return candidate;
|
|
176
681
|
}
|
|
177
682
|
return isWin2 ? "python" : "python3";
|
|
178
683
|
}
|
|
179
|
-
async function runPy(script, args) {
|
|
180
|
-
return executor(pythonBin(), [
|
|
684
|
+
async function runPy(script, args, timeoutMs) {
|
|
685
|
+
return executor(pythonBin(), [join4(toolsDir, script), ...args], timeoutMs);
|
|
181
686
|
}
|
|
182
687
|
var textOutput = {
|
|
183
688
|
schema: { type: "string" },
|
|
@@ -202,19 +707,19 @@ function closedTool(opts) {
|
|
|
202
707
|
tool.parameters.additionalProperties = false;
|
|
203
708
|
return tool;
|
|
204
709
|
}
|
|
205
|
-
var skillsDir =
|
|
710
|
+
var skillsDir = join4(pkgRoot, "skills");
|
|
206
711
|
function frontmatterValue(raw, key) {
|
|
207
712
|
const block = raw.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
208
713
|
const line = block?.[1].match(new RegExp(`^${key}:\\s*(.+)$`, "m"));
|
|
209
714
|
return line?.[1].trim();
|
|
210
715
|
}
|
|
211
716
|
function registerSkills(ctx) {
|
|
212
|
-
if (!
|
|
717
|
+
if (!existsSync2(skillsDir)) return;
|
|
213
718
|
for (const child of readdirSync(skillsDir, { withFileTypes: true })) {
|
|
214
719
|
if (!child.isDirectory()) continue;
|
|
215
|
-
const skillFile =
|
|
216
|
-
if (!
|
|
217
|
-
const raw =
|
|
720
|
+
const skillFile = join4(skillsDir, child.name, "SKILL.md");
|
|
721
|
+
if (!existsSync2(skillFile)) continue;
|
|
722
|
+
const raw = readFileSync2(skillFile, "utf-8");
|
|
218
723
|
ctx.skills.register({
|
|
219
724
|
name: child.name,
|
|
220
725
|
description: frontmatterValue(raw, "description") ?? child.name,
|
|
@@ -223,7 +728,7 @@ function registerSkills(ctx) {
|
|
|
223
728
|
content: raw.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, "").trimStart(),
|
|
224
729
|
source: "bundled",
|
|
225
730
|
path: skillFile,
|
|
226
|
-
resourceBase: { kind: "directory", path:
|
|
731
|
+
resourceBase: { kind: "directory", path: join4(skillsDir, child.name) }
|
|
227
732
|
});
|
|
228
733
|
}
|
|
229
734
|
}
|
|
@@ -233,8 +738,9 @@ function apply(ctx, config = {}) {
|
|
|
233
738
|
if (config.toolDiscovery !== void 0 && typeof config.toolDiscovery !== "boolean") {
|
|
234
739
|
throw new TypeError("toolDiscovery must be a boolean");
|
|
235
740
|
}
|
|
236
|
-
const
|
|
237
|
-
ctx.tools.register(
|
|
741
|
+
const discovery = config.toolDiscovery === false ? void 0 : createToolDiscovery(ctx);
|
|
742
|
+
const register = (tool) => ctx.tools.register(tool, discovery?.(tool));
|
|
743
|
+
register(
|
|
238
744
|
pyTool({
|
|
239
745
|
name: "get_announcements",
|
|
240
746
|
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",
|
|
@@ -277,7 +783,7 @@ function apply(ctx, config = {}) {
|
|
|
277
783
|
argv: (p) => ["announcements", p.symbol, "--category", p.category ?? "all", "--start-date", p.start_date ?? "", "--end-date", p.end_date ?? "", "--top", String(p.top ?? 50)]
|
|
278
784
|
})
|
|
279
785
|
);
|
|
280
|
-
|
|
786
|
+
register(
|
|
281
787
|
pyTool({
|
|
282
788
|
name: "get_us_holdings",
|
|
283
789
|
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",
|
|
@@ -293,7 +799,7 @@ function apply(ctx, config = {}) {
|
|
|
293
799
|
argv: (p) => ["holdings", p.cik, ...p.mode ? ["--mode", p.mode] : []]
|
|
294
800
|
})
|
|
295
801
|
);
|
|
296
|
-
|
|
802
|
+
register(
|
|
297
803
|
pyTool({
|
|
298
804
|
name: "get_insider_trades",
|
|
299
805
|
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",
|
|
@@ -316,7 +822,7 @@ function apply(ctx, config = {}) {
|
|
|
316
822
|
argv: (p) => ["insider_trades", p.symbol, "--days", String(p.days ?? 90), "--top", String(p.top ?? 10)]
|
|
317
823
|
})
|
|
318
824
|
);
|
|
319
|
-
|
|
825
|
+
register(
|
|
320
826
|
pyTool({
|
|
321
827
|
name: "get_valuation_history",
|
|
322
828
|
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",
|
|
@@ -335,7 +841,7 @@ function apply(ctx, config = {}) {
|
|
|
335
841
|
argv: (p) => ["valuation_history", p.symbol, "--years", String(p.years ?? 5)]
|
|
336
842
|
})
|
|
337
843
|
);
|
|
338
|
-
|
|
844
|
+
register(
|
|
339
845
|
pyTool({
|
|
340
846
|
name: "get_index_valuation",
|
|
341
847
|
description: "\u67E5\u8BE2\u4E2D\u56FD\u6307\u6570\u4F30\u503C\u5386\u53F2\u5206\u4F4D\u4E0EBand\uFF1B\u4E50\u5495\u4E50\u80A1PE/PB\u4F18\u5148\uFF0C\u4E2D\u8BC1\u5B98\u65B9\u5386\u53F2\u8865\u5145\u6EDA\u52A8PE\u5E76\u4FDD\u7559\u8FD1\u671FPE1\u53E3\u5F84\u3002\u7F3APB\u65F6\u53EF\u7528LIXINGER_TOKEN\u8865\u5145\u7406\u674F\u4EC1mcw\u5386\u53F2\uFF0C\u6765\u6E90\u4E0E\u7B97\u6CD5\u5206\u522B\u6807\u660E\uFF0C\u4E0D\u6DF7\u63A5\u540C\u4E00\u6307\u6807\u3002",
|
|
@@ -354,7 +860,7 @@ function apply(ctx, config = {}) {
|
|
|
354
860
|
argv: (p) => ["index_valuation", p.symbol, "--years", String(p.years ?? 5)]
|
|
355
861
|
})
|
|
356
862
|
);
|
|
357
|
-
|
|
863
|
+
register(
|
|
358
864
|
pyTool({
|
|
359
865
|
name: "get_earnings_calendar",
|
|
360
866
|
description: "\u67E5\u8BE2\u8D22\u62A5\u65E5\u5386\uFF1AA\u80A1report_date\u5FC5\u586B\u5B63\u5EA6\u671F\u672B\uFF0C\u8FD4\u56DE\u9884\u7EA6/\u4FEE\u8BA2/\u5B9E\u9645\u62AB\u9732\u4E0E\u4E1A\u7EE9\u9884\u544A\uFF1BHK\u9700symbol\uFF0C\u4F18\u5148HKEX\u5DF2\u516C\u544A\u4E1A\u7EE9\u5BA1\u6279\u8463\u4E8B\u4F1A\u6392\u671F\uFF08\u4E0D\u662F\u5B9E\u9645\u62AB\u9732\u65E5\uFF09\uFF0C\u7F3A\u5931\u65F6\u8FD4\u56DE\u4F9B\u5E94\u5546\u65E5\u671F\u3002HK\u53EF\u6309\u5DF2\u77E5\u8D22\u653F\u671F\u672B\u8FC7\u6EE4\uFF0C\u672A\u77E5\u671F\u6B21\u53E6\u5217\u3002",
|
|
@@ -376,7 +882,7 @@ function apply(ctx, config = {}) {
|
|
|
376
882
|
argv: (p) => ["earnings_calendar", "--report-date", p.report_date ?? "", "--symbol", p.symbol ?? "", "--top", String(p.top ?? 50)]
|
|
377
883
|
})
|
|
378
884
|
);
|
|
379
|
-
|
|
885
|
+
register(
|
|
380
886
|
pyTool({
|
|
381
887
|
name: "get_shareholder_structure",
|
|
382
888
|
description: "\u67E5\u8BE2A\u80A1\u80A1\u4E1C\u6237\u6570\u3001\u5341\u5927\u6D41\u901A\u80A1\u4E1C\u53D8\u5316\u53CA\u6CAA\u6DF1\u4EA4\u6613\u6240\u5B63\u5EA6\u5317\u5411\u5408\u8BA1\u6301\u80A1\uFF1B\u5B98\u65B9\u603B\u91CF\u4F18\u5148\uFF0C\u5341\u5927HKSCC\u540D\u4E49\u6301\u80A1\u4EC5\u515C\u5E95\u4E14\u6807\u660E\u53E3\u5F84\u3002HK\u8FD4\u56DE\u6E2F\u4EA4\u6240\u5357\u5411\u8BB0\u5F55\u3002\u7F3A\u5931\u4E0D\u5F53\u96F6\uFF0C\u671F\u672B\u4E0D\u7B49\u4E8E\u5DF2\u516C\u5E03\u3002",
|
|
@@ -395,7 +901,7 @@ function apply(ctx, config = {}) {
|
|
|
395
901
|
argv: (p) => ["shareholder_structure", p.symbol, "--report-date", p.report_date ?? ""]
|
|
396
902
|
})
|
|
397
903
|
);
|
|
398
|
-
|
|
904
|
+
register(
|
|
399
905
|
pyTool({
|
|
400
906
|
name: "get_etf_details",
|
|
401
907
|
description: "\u67E5\u8BE2A\u80A1ETF\u51C0\u503C\u6298\u6EA2\u4EF7\u3001\u89C4\u6A21\u3001\u62AB\u9732\u6301\u4ED3\u53CA\u6CAA\u6DF1\u5B8C\u6574PCF\u7533\u8D4E\u7BEE\u5B50\uFF1B\u7BEE\u5B50\u4E0D\u662F\u5B9E\u9645\u6301\u4ED3\u3002include_full_holdings=true\u53E6\u53D6\u6700\u8FD1\u53EF\u5F97\u534A\u5E74\u5EA6/\u5E74\u5EA6\u62AB\u9732\u80A1\u7968\u8868\uFF0C\u542B\u6570\u91CF/\u5E02\u503C/\u62A5\u544A\u671F\uFF0C\u975E\u5B9E\u65F6\u5168\u8D44\u4EA7\u7EC4\u5408\uFF1Bbenchmark\u7528\u4E8E\u8DDF\u8E2A\u8BEF\u5DEE\u3002",
|
|
@@ -419,7 +925,7 @@ function apply(ctx, config = {}) {
|
|
|
419
925
|
argv: (p) => ["etf_details", p.symbol, "--benchmark", p.benchmark ?? "", "--days", String(p.days ?? 60), ...p.include_full_holdings ? ["--include-full-holdings"] : []]
|
|
420
926
|
})
|
|
421
927
|
);
|
|
422
|
-
|
|
928
|
+
register(
|
|
423
929
|
pyTool({
|
|
424
930
|
name: "get_dividends",
|
|
425
931
|
description: "\u67E5\u8BE2A/HK\u5206\u7EA2\u5386\u53F2\u3001\u9664\u606F\u65E5\u5386\u3001\u5DF2\u5B9E\u65BDTTM\u80A1\u606F\u4E0E\u8FDE\u7EED\u5E74\u6570\u3002mode=ranking\u7701\u7565symbol\uFF0Cmarket=A\u67E5\u62A5\u544A\u671F\u6392\u884C\uFF0Cmarket=HK\u67E5HKEX/LSEG\u5E74\u5EA6\u80A1\u606F\u7387\u6392\u884C\uFF08report_date\u987B\u5E74\u672B\uFF09\uFF1B\u6392\u884C\u5747\u975E\u5F53\u524DTTM\u6536\u76CA\u7387\u3002\u7F3A\u5931\u4E0D\u6309\u96F6\u3002",
|
|
@@ -455,7 +961,7 @@ function apply(ctx, config = {}) {
|
|
|
455
961
|
argv: (p) => ["dividends", "--market", p.market ?? "A", "--symbol", p.symbol ?? "", "--mode", p.mode ?? "history", "--report-date", p.report_date ?? "", "--years", String(p.years ?? 10), "--top", String(p.top ?? 20)]
|
|
456
962
|
})
|
|
457
963
|
);
|
|
458
|
-
|
|
964
|
+
register(
|
|
459
965
|
pyTool({
|
|
460
966
|
name: "get_kline",
|
|
461
967
|
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",
|
|
@@ -483,10 +989,10 @@ function apply(ctx, config = {}) {
|
|
|
483
989
|
]
|
|
484
990
|
})
|
|
485
991
|
);
|
|
486
|
-
|
|
992
|
+
register(
|
|
487
993
|
pyTool({
|
|
488
994
|
name: "get_quote",
|
|
489
|
-
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",
|
|
995
|
+
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\u573A\u5916\u57FA\u91D1\u7528 get_fund_quote\uFF1BTIAAxxxxxx \u8FD4\u56DE\u6295\u987E\u7EC4\u5408\u8BC6\u522B\u3001advisor_org \u4E0E\u65E0\u7EDF\u4E00\u51C0\u503C\u63D0\u793A\uFF1B\u957F\u94B1/\u6D77\u5916\u957F\u94B1/\u7A33\u94B1\u53E6\u6709\u6709\u77E5\u6709\u884C official_disclosures\uFF08partial=true\uFF0C\u975E\u5B9E\u65F6\u5B8C\u6574\u6301\u4ED3\uFF09\uFF1B\u5176\u4ED6\u7EC4\u5408\u641C\u7D22\u53EF\u7528\u65F6\u4E3A search_partial\uFF0C\u5426\u5219 unsupported_provider\u3002",
|
|
490
996
|
parameters: {
|
|
491
997
|
symbol: { type: "string", required: true, description: "\u80A1\u7968\u4EE3\u7801\uFF08A\u80A1\u5982600519\uFF0C\u7F8E\u80A1\u5982AAPL\uFF0C\u6E2F\u80A1\u598200700.HK\uFF09" }
|
|
492
998
|
},
|
|
@@ -494,7 +1000,18 @@ function apply(ctx, config = {}) {
|
|
|
494
1000
|
argv: (p) => ["quote", p.symbol]
|
|
495
1001
|
})
|
|
496
1002
|
);
|
|
497
|
-
|
|
1003
|
+
register(
|
|
1004
|
+
pyTool({
|
|
1005
|
+
name: "get_fund_quote",
|
|
1006
|
+
description: "\u83B7\u53D6\u573A\u5916\u516C\u52DF\u57FA\u91D1\u51C0\u503C\uFF086\u4F4D\u57FA\u91D1\u4EE3\u7801\uFF0C\u5982018147\uFF09\u3002nav \u662F\u5DF2\u62AB\u9732\u65E5\u7EC8\u51C0\u503C\uFF0C\u975E\u5B9E\u65F6\u4EF7\uFF1B\u8FD4\u56DE accumulated_nav\uFF08\u7D2F\u8BA1\u51C0\u503C\uFF09\u3001change_pct\uFF08\u65E5\u6DA8\u8DCC\u5E45\uFF09\u3001nav_date\uFF08\u51C0\u503C\u65E5\u671F\uFF09\u3002estimated_nav \u4E3A\u4F30\u7B97\u51C0\u503C\uFF0C\u53EF\u80FD\u4E3A null\uFF0C\u4E0D\u80FD\u5F53\u4F5C\u5B9E\u65F6\u4EF7\uFF1BQDII \u51C0\u503C\u53EF\u80FD\u6EDE\u540E 1-2 \u4EA4\u6613\u65E5\u3002",
|
|
1007
|
+
parameters: {
|
|
1008
|
+
symbol: { type: "string", required: true, description: "6\u4F4D\u573A\u5916\u516C\u52DF\u57FA\u91D1\u4EE3\u7801\uFF0C\u5982 018147" }
|
|
1009
|
+
},
|
|
1010
|
+
script: "stock_data.py",
|
|
1011
|
+
argv: (p) => ["fund_quote", p.symbol]
|
|
1012
|
+
})
|
|
1013
|
+
);
|
|
1014
|
+
register(
|
|
498
1015
|
pyTool({
|
|
499
1016
|
name: "get_capital_flow",
|
|
500
1017
|
description: "\u83B7\u53D6A\u80A1\u8D44\u91D1\u6D41\u5411\uFF08\u4E3B\u529B/\u8D85\u5927\u5355/\u5927\u5355/\u4E2D\u5355/\u5C0F\u5355\u51C0\u6D41\u5165\uFF09\u3002detail=\u4E2A\u80A1\u6BCF\u65E5\u660E\u7EC6\uFF0Csummary=\u591A\u65E5\u6C47\u603B+\u8D8B\u52BF\uFF0Csector_flow=\u677F\u5757\u8D44\u91D1\u6D41\u6392\u884C\u3002\u53EF\u914D\u5408 get_chip_distribution \u9A8C\u8BC1\u4E3B\u529B\u884C\u4E3A",
|
|
@@ -518,7 +1035,7 @@ function apply(ctx, config = {}) {
|
|
|
518
1035
|
}
|
|
519
1036
|
})
|
|
520
1037
|
);
|
|
521
|
-
|
|
1038
|
+
register(
|
|
522
1039
|
pyTool({
|
|
523
1040
|
name: "get_news",
|
|
524
1041
|
description: "\u83B7\u53D6\u4E2A\u80A1\u6700\u8FD1N\u5929\u8D22\u7ECF\u65B0\u95FB\u5FEB\u8BAF\uFF08\u8F7B\u91CF\u3001\u65E0\u9700\u914D\u7F6E\uFF09\u3002\u9700\u8981\u6DF1\u5EA6\u5168\u7F51\u60C5\u62A5\u7528 search_comprehensive_intel\uFF0C\u6309\u4E3B\u9898\u641C\u7D22\u7528 search_stock_news\uFF0C\u8BFB\u6587\u7AE0\u5168\u6587\u7528 extract_article",
|
|
@@ -530,7 +1047,7 @@ function apply(ctx, config = {}) {
|
|
|
530
1047
|
argv: (p) => ["news", p.symbol, "--days", String(p.days ?? 3)]
|
|
531
1048
|
})
|
|
532
1049
|
);
|
|
533
|
-
|
|
1050
|
+
register(
|
|
534
1051
|
pyTool({
|
|
535
1052
|
name: "get_financials",
|
|
536
1053
|
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",
|
|
@@ -548,7 +1065,7 @@ function apply(ctx, config = {}) {
|
|
|
548
1065
|
}
|
|
549
1066
|
})
|
|
550
1067
|
);
|
|
551
|
-
|
|
1068
|
+
register(
|
|
552
1069
|
pyTool({
|
|
553
1070
|
name: "get_technical_analysis",
|
|
554
1071
|
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",
|
|
@@ -580,7 +1097,7 @@ function apply(ctx, config = {}) {
|
|
|
580
1097
|
}
|
|
581
1098
|
})
|
|
582
1099
|
);
|
|
583
|
-
|
|
1100
|
+
register(
|
|
584
1101
|
pyTool({
|
|
585
1102
|
name: "analyze_pattern",
|
|
586
1103
|
description: "K\u7EBF\u5F62\u6001\u8BC6\u522B \u2014 \u68C0\u6D4B\u5341\u5B57\u661F\u3001\u9524\u5B50\u7EBF\u3001\u541E\u6CA1\u3001\u542F\u660E\u661F\u3001\u9EC4\u660F\u661F\u3001\u53CC\u5E95\u300120\u65E5\u7A81\u7834\u7B4912+\u79CD\u7ECF\u5178\u5F62\u6001\u3002\u7EFC\u5408\u6280\u672F\u9762\u5224\u65AD\u7528 get_technical_analysis",
|
|
@@ -604,7 +1121,7 @@ function apply(ctx, config = {}) {
|
|
|
604
1121
|
]
|
|
605
1122
|
})
|
|
606
1123
|
);
|
|
607
|
-
|
|
1124
|
+
register(
|
|
608
1125
|
pyTool({
|
|
609
1126
|
name: "get_market_indices",
|
|
610
1127
|
description: "\u83B7\u53D6\u4E3B\u8981\u5E02\u573A\u6307\u6570\u884C\u60C5\u3002CN: \u4E0A\u8BC1/\u6DF1\u8BC1/\u521B\u4E1A\u677F/\u79D1\u521B50/\u6CAA\u6DF1300\uFF1BHK: \u6052\u751F/\u56FD\u4F01/\u79D1\u6280\uFF1BUS: \u9053\u743C\u65AF/\u7EB3\u65AF\u8FBE\u514B/\u6807\u666E500\uFF1BJP: \u65E5\u7ECF225/\u4E1C\u8BC1\uFF1BKR: KOSPI/KOSDAQ\uFF1BTW: \u53F0\u6E7E\u52A0\u6743\u3002\u5927\u76D8\u590D\u76D8\u7528 get_market_review \u4E00\u7AD9\u5F0F\u83B7\u53D6",
|
|
@@ -619,7 +1136,7 @@ function apply(ctx, config = {}) {
|
|
|
619
1136
|
argv: (p) => ["market_indices", "--region", p.region ?? "cn"]
|
|
620
1137
|
})
|
|
621
1138
|
);
|
|
622
|
-
|
|
1139
|
+
register(
|
|
623
1140
|
pyTool({
|
|
624
1141
|
name: "get_sector_rankings",
|
|
625
1142
|
description: "\u83B7\u53D6A\u80A1\u677F\u5757\u6DA8\u8DCC\u5E45\u6392\u884C\uFF08\u542B\u9886\u6DA8\u80A1\u3001\u6DA8\u8DCC\u5BB6\u6570\u7B49\uFF09\u3002board_type=industry\uFF08\u9ED8\u8BA4\uFF09\u4E3A\u884C\u4E1A\u677F\u5757\uFF0Cboard_type=concept \u65F6\u4E3A\u6982\u5FF5\u677F\u5757\u6392\u884C\u3002\u652F\u6301\u67E5\u770B\u6DA8\u5E45\u699C/\u8DCC\u5E45\u699C/\u53CC\u5411",
|
|
@@ -648,7 +1165,7 @@ function apply(ctx, config = {}) {
|
|
|
648
1165
|
]
|
|
649
1166
|
})
|
|
650
1167
|
);
|
|
651
|
-
|
|
1168
|
+
register(
|
|
652
1169
|
pyTool({
|
|
653
1170
|
name: "get_sector_constituents",
|
|
654
1171
|
description: "\u67E5\u8BE2A\u80A1\u677F\u5757\u6210\u5206\u80A1\uFF08\u6B63\u5411\u6620\u5C04\uFF1A\u677F\u5757\u2192\u80A1\u7968\u5217\u8868\uFF09\u3002\u677F\u5757\u540D\u652F\u6301\u6A21\u7CCA\u5339\u914D\uFF08\u5982\u300C\u521B\u65B0\u836F\u300D\u81EA\u52A8\u89E3\u6790\u5230\u7CBE\u786E\u677F\u5757\u540D\uFF09\uFF0C\u4E1C\u8D22\u884C\u4E1A/\u6982\u5FF5 + \u65B0\u6D6A\u591A\u6E90 failover\uFF0C\u7ED3\u679C\u6309\u7528\u6237\u76EE\u5F55\u7F13\u5B587\u5929\u3002\u4EC5\u652F\u6301A\u80A1\uFF1B\u53CD\u5411\u67E5\u4E2A\u80A1\u6240\u5C5E\u677F\u5757\u7528 resolve_stock_sectors",
|
|
@@ -673,7 +1190,7 @@ function apply(ctx, config = {}) {
|
|
|
673
1190
|
]
|
|
674
1191
|
})
|
|
675
1192
|
);
|
|
676
|
-
|
|
1193
|
+
register(
|
|
677
1194
|
pyTool({
|
|
678
1195
|
name: "resolve_stock_sectors",
|
|
679
1196
|
description: "\u67E5\u8BE2\u4E2A\u80A1\u6240\u5C5E\u677F\u5757\uFF08\u53CD\u5411\u6620\u5C04\uFF1A\u4E2A\u80A1\u2192\u677F\u5757\uFF09\u3002A\u80A1\u8FD4\u56DE\u4E1C\u8D22\u884C\u4E1A + efinance \u6982\u5FF5/\u677F\u5757\uFF08\u96EA\u7403\u884C\u4E1A\u515C\u5E95\uFF0C\u9700 XUEQIU_TOKEN\uFF09\uFF0C\u6E2F\u80A1\u8FD4\u56DE yfinance GICS \u82F1\u6587 sector/industry \u53E3\u5F84\u3002\u677F\u5757\u7EA7\u60C5\u62A5\uFF08\u5982\u300C\u521B\u65B0\u836F\u56DE\u8C03\u300D\uFF09\u6620\u5C04\u5230\u6C60\u5185\u4E2A\u80A1\u65F6\u8C03\u672C\u5DE5\u5177\uFF1B\u6B63\u5411\u67E5\u677F\u5757\u6210\u5206\u80A1\u7528 get_sector_constituents",
|
|
@@ -688,7 +1205,7 @@ function apply(ctx, config = {}) {
|
|
|
688
1205
|
argv: (p) => ["resolve_stock_sectors", p.symbol]
|
|
689
1206
|
})
|
|
690
1207
|
);
|
|
691
|
-
|
|
1208
|
+
register(
|
|
692
1209
|
pyTool({
|
|
693
1210
|
name: "get_stock_info",
|
|
694
1211
|
description: "\u83B7\u53D6\u80A1\u7968\u57FA\u672C\u4FE1\u606F\uFF08\u884C\u4E1A\u3001\u677F\u5757\u3001\u4E0A\u5E02\u65E5\u671F\u3001\u603B\u80A1\u672C\u7B49\uFF09\u3002A\u80A1\u8FD4\u56DE\u677F\u5757/\u884C\u4E1A\uFF0C\u5176\u4ED6\u5E02\u573A\u8FD4\u56DE\u884C\u4E1A/\u516C\u53F8\u7B80\u4ECB",
|
|
@@ -699,7 +1216,7 @@ function apply(ctx, config = {}) {
|
|
|
699
1216
|
argv: (p) => ["stock_info", p.symbol]
|
|
700
1217
|
})
|
|
701
1218
|
);
|
|
702
|
-
|
|
1219
|
+
register(
|
|
703
1220
|
pyTool({
|
|
704
1221
|
name: "get_chip_distribution",
|
|
705
1222
|
description: "\u83B7\u53D6A\u80A1\u7B79\u7801\u5206\u5E03\u6570\u636E\uFF08\u83B7\u5229\u6BD4\u4F8B\u3001\u5E73\u5747\u6210\u672C\u300190%/70%\u6210\u672C\u96C6\u4E2D\u5EA6\uFF09\u3002\u4EC5\u652F\u6301A\u80A1\u3002\u4E0E get_capital_flow \u914D\u5408\u9A8C\u8BC1\u4E3B\u529B\u884C\u4E3A",
|
|
@@ -714,7 +1231,7 @@ function apply(ctx, config = {}) {
|
|
|
714
1231
|
argv: (p) => ["chip_distribution", p.symbol]
|
|
715
1232
|
})
|
|
716
1233
|
);
|
|
717
|
-
|
|
1234
|
+
register(
|
|
718
1235
|
pyTool({
|
|
719
1236
|
name: "get_market_stats",
|
|
720
1237
|
description: "\u83B7\u53D6A\u80A1\u5E02\u573A\u6574\u4F53\u7EDF\u8BA1\uFF08\u6DA8\u8DCC\u5BB6\u6570\u3001\u6DA8\u505C\u8DCC\u505C\u6570\u3001\u5E73\u5747\u6DA8\u5E45\u3001\u6DA8\u8DCCTop5\u3001\u603B\u6210\u4EA4\u989D\uFF09\u3002\u7528\u4E8E\u8861\u91CF\u5E02\u573A\u6574\u4F53\u60C5\u7EEA\u4E0E\u6E29\u5EA6",
|
|
@@ -723,7 +1240,7 @@ function apply(ctx, config = {}) {
|
|
|
723
1240
|
argv: () => ["market_stats"]
|
|
724
1241
|
})
|
|
725
1242
|
);
|
|
726
|
-
|
|
1243
|
+
register(
|
|
727
1244
|
pyTool({
|
|
728
1245
|
name: "get_limit_up_pool",
|
|
729
1246
|
description: "\u83B7\u53D6A\u80A1\u6DA8\u505C\u6C60/\u6DA8\u505C\u677F\u590D\u76D8\u2014\u2014\u5F53\u65E5\u6DA8\u505C\u4E2A\u80A1\uFF0C\u542B\u8FDE\u677F\u6570\u3001\u5C01\u677F\u8D44\u91D1\u3001\u70B8\u677F\u6B21\u6570\u3001\u9996\u672B\u6B21\u5C01\u677F\u65F6\u95F4\u3001\u6240\u5C5E\u884C\u4E1A\u3002\u77ED\u7EBF\u60C5\u7EEA\u4E0E\u9F99\u5934\u6218\u6CD5\u6838\u5FC3\u6570\u636E",
|
|
@@ -738,7 +1255,7 @@ function apply(ctx, config = {}) {
|
|
|
738
1255
|
}
|
|
739
1256
|
})
|
|
740
1257
|
);
|
|
741
|
-
|
|
1258
|
+
register(
|
|
742
1259
|
pyTool({
|
|
743
1260
|
name: "get_dragon_tiger",
|
|
744
1261
|
description: "\u83B7\u53D6A\u80A1\u9F99\u864E\u699C\u2014\u2014\u4E0A\u699C\u4E2A\u80A1\u51C0\u4E70\u989D/\u4E70\u5165\u989D/\u5356\u51FA\u989D/\u4E0A\u699C\u539F\u56E0/\u89E3\u8BFB\uFF0C\u53EF\u6309\u4E2A\u80A1\u8FC7\u6EE4",
|
|
@@ -757,7 +1274,7 @@ function apply(ctx, config = {}) {
|
|
|
757
1274
|
}
|
|
758
1275
|
})
|
|
759
1276
|
);
|
|
760
|
-
|
|
1277
|
+
register(
|
|
761
1278
|
pyTool({
|
|
762
1279
|
name: "get_hot_stocks",
|
|
763
1280
|
description: "\u83B7\u53D6A\u80A1\u5168\u5E02\u573A\u4EBA\u6C14\u70ED\u641C\u699C\uFF08\u4E1C\u65B9\u8D22\u5BCC\u4EBA\u6C14\u699C\uFF09",
|
|
@@ -768,7 +1285,7 @@ function apply(ctx, config = {}) {
|
|
|
768
1285
|
argv: (p) => ["hot_stocks", "--top", String(p.top ?? 20)]
|
|
769
1286
|
})
|
|
770
1287
|
);
|
|
771
|
-
|
|
1288
|
+
register(
|
|
772
1289
|
pyTool({
|
|
773
1290
|
name: "get_margin_trading",
|
|
774
1291
|
description: "\u83B7\u53D6A\u80A1\u4E2A\u80A1\u878D\u8D44\u878D\u5238\u660E\u7EC6\uFF08\u878D\u8D44\u4F59\u989D/\u878D\u8D44\u4E70\u5165\u989D/\u878D\u5238\u4F59\u91CF\u7B49\uFF0C\u4E0A\u4EA4\u6240/\u6DF1\u4EA4\u6240\u5B98\u65B9\u6570\u636E\u6309\u4EA4\u6613\u6240\u5206\u6D41\uFF09\uFF0C\u8FD4\u56DE\u6700\u8FD1N\u4E2A\u4EA4\u6613\u65E5\u5E8F\u5217\uFF08\u6700\u65B0\u5728\u524D\uFF09\u3002\u91D1\u989D\u5355\u4F4D\u4E3A\u5143\uFF0Cshort_*_shares \u5355\u4F4D\u4E3A\u80A1\u3002include_ratio=true\u8FFD\u52A0\u540C\u65E5\u878D\u8D44\u4E70\u5165/\u6210\u4EA4\u989D\u767E\u5206\u6BD4\uFF08margin_buy_ratio_pct\uFF09\uFF0C\u7F3A\u5C11\u540C\u65E5\u5143\u53E3\u5F84\u6210\u4EA4\u989D\u5219\u4E3Anull\u3002\u4EC5\u4E24\u878D\u6807\u7684\u6709\u6570\u636E\uFF0C\u975E\u4E24\u878D\u6807\u7684\u8FD4\u56DE\u9519\u8BEF",
|
|
@@ -781,7 +1298,7 @@ function apply(ctx, config = {}) {
|
|
|
781
1298
|
argv: (p) => ["margin_trading", p.symbol, "--days", String(p.days ?? 10), ...p.include_ratio ? ["--include-ratio"] : []]
|
|
782
1299
|
})
|
|
783
1300
|
);
|
|
784
|
-
|
|
1301
|
+
register(
|
|
785
1302
|
pyTool({
|
|
786
1303
|
name: "get_northbound_flow",
|
|
787
1304
|
description: "\u83B7\u53D6\u5317\u5411\u8D44\u91D1\u5E02\u573A\u7EA7\u51C0\u4E70\u5165\u5E8F\u5217\uFF08\u6700\u65B0\u5728\u524D\uFF0C\u5355\u4F4D\u4EBF\u5143\uFF09\u3002\u6570\u636E\u53E3\u5F84\uFF1A\u4E1C\u65B9\u8D22\u5BCC\u6CAA\u6DF1\u6E2F\u901A\u5386\u53F2\u6570\u636E\uFF1B2024-08-16 \u8D77\u4EA4\u6613\u6240\u505C\u6B62\u62AB\u9732\u65E5\u5EA6\u51C0\u4E70\u989D\uFF0C\u4EC5 2024-08 \u4E4B\u524D\u5386\u53F2\u6570\u636E\u53EF\u67E5\uFF08\u8FD1\u671F\u5C0F days \u7A97\u53E3\u4F1A\u8FD4\u56DE\u505C\u62AB\u9519\u8BEF\uFF0C\u52A0\u5927 days \u53EF\u53D6\u5386\u53F2\uFF09",
|
|
@@ -792,7 +1309,7 @@ function apply(ctx, config = {}) {
|
|
|
792
1309
|
argv: (p) => ["northbound_flow", "--days", String(p.days ?? 10)]
|
|
793
1310
|
})
|
|
794
1311
|
);
|
|
795
|
-
|
|
1312
|
+
register(
|
|
796
1313
|
pyTool({
|
|
797
1314
|
name: "get_fundamental_context",
|
|
798
1315
|
description: "\u83B7\u53D6A\u80A1\u57FA\u672C\u9762\u4E0A\u4E0B\u6587\uFF08\u4F30\u503C PE/PB/\u5E02\u503C + \u8425\u6536/\u51C0\u5229\u589E\u901F + ROE/\u6BDB\u5229\u7387/\u51C0\u5229\u7387 + \u5206\u7EA2\u5386\u53F2\uFF09\u3002\u7528\u4E8E\u8BC4\u4F30\u516C\u53F8\u8D28\u5730\u4E0E\u957F\u671F\u6301\u6709\u4EF7\u503C",
|
|
@@ -807,7 +1324,7 @@ function apply(ctx, config = {}) {
|
|
|
807
1324
|
argv: (p) => ["fundamental_context", p.symbol]
|
|
808
1325
|
})
|
|
809
1326
|
);
|
|
810
|
-
|
|
1327
|
+
register(
|
|
811
1328
|
pyTool({
|
|
812
1329
|
name: "screen_stocks",
|
|
813
1330
|
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",
|
|
@@ -830,7 +1347,7 @@ function apply(ctx, config = {}) {
|
|
|
830
1347
|
}
|
|
831
1348
|
})
|
|
832
1349
|
);
|
|
833
|
-
|
|
1350
|
+
register(closedTool({
|
|
834
1351
|
name: "calculate_rotation_metrics",
|
|
835
1352
|
description: "\u884C\u4E1A\u8F6E\u52A8\u6570\u503C\u590D\u6838\uFF1A\u8F93\u5165\u771F\u5B9EMC-dropout\u6837\u672C\u548C/\u6216\u5386\u53F2\u6210\u4EA4\u8BA1\u6570\uFF0C\u8BA1\u7B97\u96C6\u4E2D\u5EA6\u548C\u539F\u59CB\u914D\u6743\uFF1B\u4E0D\u8BAD\u7EC3\u6A21\u578B\u3001\u4E0D\u751F\u6210\u4E70\u5165\u4FE1\u53F7\uFF0C\u96F6\u5386\u53F2\u4E0D\u8865\u9ED8\u8BA4\u503C\u3002",
|
|
836
1353
|
parameters: {
|
|
@@ -893,7 +1410,7 @@ function apply(ctx, config = {}) {
|
|
|
893
1410
|
return withJsonInput(params, (path) => runPy("sector_rotation.py", ["analyze", "--input", path]));
|
|
894
1411
|
}
|
|
895
1412
|
}));
|
|
896
|
-
|
|
1413
|
+
register(closedTool({
|
|
897
1414
|
name: "backtest_rotation_allocation",
|
|
898
1415
|
description: "\u884C\u4E1A\u8F6E\u52A8\u914D\u6743\u5206\u9879\u56DE\u6D4B\uFF1A\u4EE3\u7801\u81EA\u52A8\u53D6\u884C\u60C5\uFF0C\u6216\u4F20\u660E\u786E\u5E01\u79CD/\u590D\u6743OHLCV\uFF1B\u76F8\u540C\u6BCF\u5468\u5168\u6C60\u4E70\u5356\u4E0B\u6BD4\u8F83\u7B49\u6743\u4E0E\u5386\u53F2\u914D\u6743\u3002\u6309\u5E02\u573A\u548C\u62A5\u4EF7\u5E01\u79CD\u72EC\u7ACB\u8D44\u91D1\uFF0C\u652F\u6301A/HK/US/JP/KR/TW\uFF1B\u4E0D\u662F\u5B8C\u6574\u8BBA\u6587\u6DF1\u5EA6\u6A21\u578B\u6216\u8DE8\u5E01\u79CD\u5171\u4EAB\u8D44\u91D1\u56DE\u6D4B\u3002",
|
|
899
1416
|
parameters: {
|
|
@@ -1015,7 +1532,7 @@ function apply(ctx, config = {}) {
|
|
|
1015
1532
|
return withJsonInput(params, (path) => runPy("sector_rotation.py", ["backtest", "--input", path]));
|
|
1016
1533
|
}
|
|
1017
1534
|
}));
|
|
1018
|
-
|
|
1535
|
+
register(closedTool({
|
|
1019
1536
|
name: "analyze_trend_strategy",
|
|
1020
1537
|
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",
|
|
1021
1538
|
parameters: {
|
|
@@ -1054,7 +1571,7 @@ function apply(ctx, config = {}) {
|
|
|
1054
1571
|
return withJsonInput(params, (path) => runPy("trend_strategy.py", ["fetch", "--input", path]));
|
|
1055
1572
|
}
|
|
1056
1573
|
}));
|
|
1057
|
-
|
|
1574
|
+
register(
|
|
1058
1575
|
pyTool({
|
|
1059
1576
|
name: "run_backtest",
|
|
1060
1577
|
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",
|
|
@@ -1075,7 +1592,7 @@ function apply(ctx, config = {}) {
|
|
|
1075
1592
|
}
|
|
1076
1593
|
})
|
|
1077
1594
|
);
|
|
1078
|
-
|
|
1595
|
+
register(
|
|
1079
1596
|
pyTool({
|
|
1080
1597
|
name: "evaluate_signal",
|
|
1081
1598
|
description: "\u6280\u672F\u4FE1\u53F7\u5386\u53F2\u51C6\u786E\u7387\u8BC4\u4F30 \u2014 \u56DE\u6EAF\u5386\u53F2\u6570\u636E\uFF0C\u7EDF\u8BA1\u67D0\u4E2A\u6280\u672F\u4FE1\u53F7\u89E6\u53D1\u540EN\u65E5\u7684\u80DC\u7387\u548C\u5E73\u5747\u6536\u76CA\u3002\u652F\u63019\u79CD\u4FE1\u53F7\uFF1Amacd_golden_cross/macd_death_cross/rsi_oversold/rsi_overbought/breakout_20d/breakdown_20d/volume_surge/ma_golden_cross/ma_death_cross\u3002\u8981\u5B8C\u6574\u6A21\u62DF\u4EA4\u6613\u8FC7\u7A0B\u7528 run_backtest",
|
|
@@ -1115,7 +1632,7 @@ function apply(ctx, config = {}) {
|
|
|
1115
1632
|
]
|
|
1116
1633
|
})
|
|
1117
1634
|
);
|
|
1118
|
-
|
|
1635
|
+
register(
|
|
1119
1636
|
pyTool({
|
|
1120
1637
|
name: "resolve_stock_name",
|
|
1121
1638
|
description: "\u80A1\u7968\u540D\u79F0\u667A\u80FD\u89E3\u6790 \u2014 \u8F93\u5165\u4E2D\u6587\u540D\uFF08\u8D35\u5DDE\u8305\u53F0\uFF09\u3001\u62FC\u97F3\uFF08guizhou maotai/gzmt\uFF09\u3001\u90E8\u5206\u4EE3\u7801\uFF0C\u8FD4\u56DE\u5339\u914D\u7684\u80A1\u7968\u4EE3\u7801\u3002\u4EC5\u652F\u6301A\u80A1\u3002\u7528\u6237\u7ED9\u51FA\u4E2D\u6587\u540D/\u62FC\u97F3/\u90E8\u5206\u4EE3\u7801\u65F6\u5148\u8C03\u672C\u5DE5\u5177\u6362\u6210\u4EE3\u7801\u518D\u8C03\u5176\u4ED6\u5DE5\u5177",
|
|
@@ -1131,7 +1648,7 @@ function apply(ctx, config = {}) {
|
|
|
1131
1648
|
argv: (p) => ["resolve", p.query, "--top", String(p.top ?? 5)]
|
|
1132
1649
|
})
|
|
1133
1650
|
);
|
|
1134
|
-
|
|
1651
|
+
register(
|
|
1135
1652
|
pyTool({
|
|
1136
1653
|
name: "check_trading_day",
|
|
1137
1654
|
description: "\u67E5\u8BE2\u67D0\u65E5\u662F\u5426\u4E3A\u4EA4\u6613\u65E5\u3002\u652F\u6301CN\uFF08A\u80A1\uFF09\u3001HK\uFF08\u6E2F\u80A1\uFF09\u3001US\uFF08\u7F8E\u80A1\uFF09\u3001JP\uFF08\u65E5\u80A1\uFF09\u3001KR\uFF08\u97E9\u80A1\uFF09\u3001TW\uFF08\u53F0\u80A1\uFF09",
|
|
@@ -1152,7 +1669,7 @@ function apply(ctx, config = {}) {
|
|
|
1152
1669
|
}
|
|
1153
1670
|
})
|
|
1154
1671
|
);
|
|
1155
|
-
|
|
1672
|
+
register(
|
|
1156
1673
|
pyTool({
|
|
1157
1674
|
name: "get_trading_days",
|
|
1158
1675
|
description: "\u83B7\u53D6\u6700\u8FD1/\u672A\u6765N\u4E2A\u4EA4\u6613\u65E5\u5217\u8868\u3002\u652F\u6301CN/HK/US/JP/KR/TW",
|
|
@@ -1179,7 +1696,7 @@ function apply(ctx, config = {}) {
|
|
|
1179
1696
|
}
|
|
1180
1697
|
})
|
|
1181
1698
|
);
|
|
1182
|
-
|
|
1699
|
+
register(
|
|
1183
1700
|
pyTool({
|
|
1184
1701
|
name: "get_trading_phase",
|
|
1185
1702
|
description: "\u67E5\u8BE2\u67D0\u5E02\u573A\u5F53\u524D\u4EA4\u6613\u65F6\u6BB5\uFF08\u76D8\u524D/\u65E9\u76D8/\u5348\u95F4\u4F11\u5E02/\u5348\u76D8/\u4EA4\u6613\u4E2D/\u76D8\u540E/\u4F11\u5E02\uFF09\uFF0C\u7528\u4E8E\u6B63\u786E\u89E3\u8BFB\u5B9E\u65F6\u884C\u60C5\u7684\u76D8\u4E2D\u8BED\u4E49\u3002\u652F\u6301CN/HK/US/JP/KR/TW",
|
|
@@ -1195,7 +1712,7 @@ function apply(ctx, config = {}) {
|
|
|
1195
1712
|
argv: (p) => ["phase", p.market]
|
|
1196
1713
|
})
|
|
1197
1714
|
);
|
|
1198
|
-
|
|
1715
|
+
register(
|
|
1199
1716
|
pyTool({
|
|
1200
1717
|
name: "calculate_ma",
|
|
1201
1718
|
description: "\u72EC\u7ACB\u5747\u7EBF\u8BA1\u7B97\u5668 \u2014 \u652F\u6301\u4EFB\u610F\u5468\u671FMA\uFF085/10/20/30/60/120/250\u6216\u81EA\u5B9A\u4E49\uFF09+ \u504F\u79BB\u5EA6 + \u5747\u7EBF\u6392\u5217 + \u91D1\u53C9\u6B7B\u53C9\u68C0\u6D4B\u3002\u53EA\u8981\u5747\u7EBF\u6570\u503C\u6216\u9700\u898130/120/250\u7B49\u975E\u9ED8\u8BA4\u5468\u671F\u65F6\u7528\u672C\u5DE5\u5177\uFF1B\u7EFC\u5408\u6280\u672F\u9762\u5206\u6790\u7528 get_technical_analysis",
|
|
@@ -1224,7 +1741,7 @@ function apply(ctx, config = {}) {
|
|
|
1224
1741
|
]
|
|
1225
1742
|
})
|
|
1226
1743
|
);
|
|
1227
|
-
|
|
1744
|
+
register(
|
|
1228
1745
|
pyTool({
|
|
1229
1746
|
name: "get_volume_analysis",
|
|
1230
1747
|
description: "\u72EC\u7ACB\u91CF\u4EF7\u5206\u6790 \u2014 \u91CF\u4EF7\u76F8\u5173\u6027\u3001\u4E0A\u6DA8/\u4E0B\u8DCC\u65E5\u6210\u4EA4\u91CF\u5BF9\u6BD4\u3001\u91CF\u80FD\u8D8B\u52BF\u3001\u91CF\u4EF7\u6A21\u5F0F\u89E3\u8BFB\uFF08\u653E\u91CF\u4E0A\u6DA8/\u7F29\u91CF\u56DE\u8C03\u7B49\uFF09\u3002\u7EFC\u5408\u6280\u672F\u9762\u5224\u65AD\u7528 get_technical_analysis\uFF0C\u626B\u5F53\u65E5\u5F02\u52A8\u7528 detect_anomaly",
|
|
@@ -1248,7 +1765,7 @@ function apply(ctx, config = {}) {
|
|
|
1248
1765
|
]
|
|
1249
1766
|
})
|
|
1250
1767
|
);
|
|
1251
|
-
|
|
1768
|
+
register(
|
|
1252
1769
|
pyTool({
|
|
1253
1770
|
name: "search_stock_news",
|
|
1254
1771
|
description: "\u591A\u5F15\u64CE\u80A1\u7968\u65B0\u95FB\u641C\u7D22\uFF08Tavily/Brave/SerpAPI/Bocha/SearXNG\uFF09\u3002\u9700\u914D\u7F6E\u81F3\u5C11\u4E00\u4E2A\u641C\u7D22\u6E90\u7684 Key \u6216 SearXNG URL\u3002get_news \u5FEB\u8BAF\u4E0D\u591F\u6216\u8981\u6309\u4E3B\u9898\u641C\u7D22\u65F6\u7528\uFF1B\u6DF1\u5EA66\u7EF4\u60C5\u62A5\u7528 search_comprehensive_intel",
|
|
@@ -1260,7 +1777,7 @@ function apply(ctx, config = {}) {
|
|
|
1260
1777
|
argv: (p) => ["search", p.query, "--count", String(p.count ?? 10)]
|
|
1261
1778
|
})
|
|
1262
1779
|
);
|
|
1263
|
-
|
|
1780
|
+
register(
|
|
1264
1781
|
pyTool({
|
|
1265
1782
|
name: "search_comprehensive_intel",
|
|
1266
1783
|
description: "\u80A1\u7968\u7EFC\u5408\u60C5\u62A5\u641C\u7D22 \u2014 \u4ECE6\u4E2A\u7EF4\u5EA6\uFF08\u65B0\u95FB/\u516C\u544A/\u884C\u60C5\u5206\u6790/\u98CE\u9669/\u4E1A\u7EE9/\u884C\u4E1A\uFF09\u641C\u7D22\u7EFC\u5408\u4FE1\u606F\u3002\u7528\u4E8E\u4E2A\u80A1\u7684\u6DF1\u5165\u7814\u7A76/\u5168\u9762\u8C03\u7814\uFF1B\u5FEB\u901F\u770B\u65B0\u95FB\u7528 get_news",
|
|
@@ -1276,7 +1793,7 @@ function apply(ctx, config = {}) {
|
|
|
1276
1793
|
}
|
|
1277
1794
|
})
|
|
1278
1795
|
);
|
|
1279
|
-
|
|
1796
|
+
register(
|
|
1280
1797
|
pyTool({
|
|
1281
1798
|
name: "get_social_sentiment",
|
|
1282
1799
|
description: "\u83B7\u53D6\u80A1\u7968\u793E\u4EA4\u5A92\u4F53\u60C5\u7EEA\u6570\u636E\u3002A\u80A1\uFF1A\u4E1C\u65B9\u8D22\u5BCC\u80A1\u5427\u70ED\u5EA6+\u96EA\u7403\u8BA8\u8BBA\u70ED\u5EA6\uFF08\u65E0\u9700\u914D\u7F6E\uFF09\uFF1B\u7F8E\u80A1/\u6E2F\u80A1\uFF1AReddit/X/Polymarket\u60C5\u7EEA\uFF08\u9700 SENTIMENT_API_KEY\uFF09\u3002\u81EA\u52A8\u6309\u5E02\u573A\u9009\u6570\u636E\u6E90\u3002\u9762\u5411\u4E2A\u80A1\u7EF4\u5EA6\uFF1B\u5168\u5E02\u573A\u70ED\u95E8\u8BA8\u8BBA\u7528 get_trending_sentiment",
|
|
@@ -1287,7 +1804,7 @@ function apply(ctx, config = {}) {
|
|
|
1287
1804
|
argv: (p) => ["sentiment", p.symbol]
|
|
1288
1805
|
})
|
|
1289
1806
|
);
|
|
1290
|
-
|
|
1807
|
+
register(
|
|
1291
1808
|
pyTool({
|
|
1292
1809
|
name: "get_trending_sentiment",
|
|
1293
1810
|
description: "\u83B7\u53D6\u793E\u4EA4\u5A92\u4F53\u70ED\u95E8\u8D8B\u52BF\uFF08Reddit/X/Polymarket\u70ED\u95E8\u80A1\u7968\u8BA8\u8BBA\uFF09\u3002\u9002\u7528\u4E8E\u53D1\u73B0\u5E02\u573A\u70ED\u70B9\uFF1B\u67E5\u4E2A\u80A1\u60C5\u7EEA\u7528 get_social_sentiment",
|
|
@@ -1296,7 +1813,7 @@ function apply(ctx, config = {}) {
|
|
|
1296
1813
|
argv: () => ["trending"]
|
|
1297
1814
|
})
|
|
1298
1815
|
);
|
|
1299
|
-
|
|
1816
|
+
register(
|
|
1300
1817
|
pyTool({
|
|
1301
1818
|
name: "extract_article",
|
|
1302
1819
|
description: "\u7F51\u9875\u6587\u7AE0\u5168\u6587\u63D0\u53D6 \u2014 \u8F93\u5165URL\uFF0C\u63D0\u53D6\u6587\u7AE0\u6807\u9898\u3001\u6B63\u6587\uFF08\u6700\u591A3000\u5B57\uFF09\u3001\u4F5C\u8005\u3001\u53D1\u5E03\u65E5\u671F\u7B49\u3002\u914D\u5408 get_news/search_stock_news \u7684\u641C\u7D22\u7ED3\u679C\u505A\u6DF1\u5EA6\u9605\u8BFB",
|
|
@@ -1307,7 +1824,7 @@ function apply(ctx, config = {}) {
|
|
|
1307
1824
|
argv: (p) => ["extract", p.url]
|
|
1308
1825
|
})
|
|
1309
1826
|
);
|
|
1310
|
-
|
|
1827
|
+
register(
|
|
1311
1828
|
pyTool({
|
|
1312
1829
|
name: "screen_risk",
|
|
1313
1830
|
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",
|
|
@@ -1327,7 +1844,7 @@ function apply(ctx, config = {}) {
|
|
|
1327
1844
|
}
|
|
1328
1845
|
})
|
|
1329
1846
|
);
|
|
1330
|
-
|
|
1847
|
+
register(
|
|
1331
1848
|
pyTool({
|
|
1332
1849
|
name: "detect_market_regime",
|
|
1333
1850
|
description: "\u5E02\u573A\u72B6\u6001\u68C0\u6D4B \u2014 \u5206\u6790\u5927\u76D8\u6307\u6570\u5224\u65AD\u5F53\u524D\u5E02\u573A\u9636\u6BB5\uFF08\u4E0A\u6DA8\u8D8B\u52BF/\u4E0B\u8DCC\u8D8B\u52BF/\u6A2A\u76D8\u9707\u8361/\u9AD8\u6CE2\u52A8/\u677F\u5757\u70ED\u70B9\uFF09\uFF0C\u5E76\u63A8\u8350\u9002\u5408\u7684\u5206\u6790\u7B56\u7565",
|
|
@@ -1342,7 +1859,7 @@ function apply(ctx, config = {}) {
|
|
|
1342
1859
|
argv: (p) => ["detect", p.market ?? "A"]
|
|
1343
1860
|
})
|
|
1344
1861
|
);
|
|
1345
|
-
|
|
1862
|
+
register(
|
|
1346
1863
|
pyTool({
|
|
1347
1864
|
name: "get_market_review",
|
|
1348
1865
|
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",
|
|
@@ -1357,7 +1874,7 @@ function apply(ctx, config = {}) {
|
|
|
1357
1874
|
argv: (p) => ["review", "--market", p.market ?? "A"]
|
|
1358
1875
|
})
|
|
1359
1876
|
);
|
|
1360
|
-
|
|
1877
|
+
register(
|
|
1361
1878
|
pyTool({
|
|
1362
1879
|
name: "run_watchlist_analysis",
|
|
1363
1880
|
description: "\u6279\u91CF\u81EA\u9009\u80A1\u5206\u6790 \u2014 \u5BF9\u591A\u53EA\u80A1\u7968\u5E76\u884C\u91C7\u96C6\u884C\u60C5/\u6280\u672F/\u8D44\u91D1/\u98CE\u9669\u7B49\u6570\u636E\uFF0C\u8FD4\u56DE\u6C47\u603B\u7ED3\u679C\u3002\u9002\u7528\u4E8E\u6BCF\u65E5\u5B9A\u65F6\u5206\u6790\u81EA\u9009\u80A1\u5217\u8868",
|
|
@@ -1376,7 +1893,7 @@ function apply(ctx, config = {}) {
|
|
|
1376
1893
|
argv: (p) => ["analyze", p.symbols, "--workers", String(p.workers ?? 3)]
|
|
1377
1894
|
})
|
|
1378
1895
|
);
|
|
1379
|
-
|
|
1896
|
+
register(
|
|
1380
1897
|
pyTool({
|
|
1381
1898
|
name: "detect_anomaly",
|
|
1382
1899
|
description: "\u5F02\u5E38/\u4E8B\u4EF6\u68C0\u6D4B \u2014 \u4E00\u952E\u626B\u63CF\u80A1\u7968\u5F53\u524D\u6240\u6709\u5F02\u52A8\u4FE1\u53F7\uFF08MACD\u91D1\u53C9\u6B7B\u53C9\u3001RSI\u8D85\u4E70\u8D85\u5356\u300120\u65E5\u7A81\u7834\u3001\u653E\u91CF\u5F02\u52A8\u3001\u6DA8\u8DCC\u505C\u3001\u5E03\u6797\u7A81\u7834\u3001KDJ\u6781\u503C\u3001\u8D44\u91D1\u5F02\u52A8\u7B49\uFF09\uFF0C\u8FD4\u56DE\u7ED3\u6784\u5316\u5F02\u5E38\u5217\u8868\u3002\u5F53\u65E5\u5F02\u52A8\u5F52\u56E0\u7684\u9996\u9009\uFF1B\u7EFC\u5408\u6280\u672F\u9762\u5224\u65AD\u7528 get_technical_analysis",
|
|
@@ -1391,7 +1908,7 @@ function apply(ctx, config = {}) {
|
|
|
1391
1908
|
argv: (p) => ["detect", p.symbol]
|
|
1392
1909
|
})
|
|
1393
1910
|
);
|
|
1394
|
-
|
|
1911
|
+
register(
|
|
1395
1912
|
pyTool({
|
|
1396
1913
|
name: "diagnose_data_sources",
|
|
1397
1914
|
description: "\u6570\u636E\u6E90\u8BCA\u65AD \u2014 \u68C0\u67E5\u5F53\u524D\u73AF\u5883\u5404\u6570\u636E provider \u7684\u5305\u4E0E\u51ED\u636E\u5C31\u7EEA\u60C5\u51B5\uFF08\u4E0D\u63A2\u6D4B\u7F51\u7EDC\u53EF\u8FBE\u6027\uFF09\uFF0C\u8F93\u51FA\u6BCF\u4E2A\u5E02\u573A\u7684\u53EF\u7528\u94FE\u8DEF\u3001\u7F3A\u5931 env\u3001warnings\u3002\u5DE5\u5177\u62FF\u4E0D\u5230\u6570\u636E\u6216\u62A5\u9519\u65F6\u8C03\u7528\u6392\u67E5",
|
|
@@ -1406,7 +1923,7 @@ function apply(ctx, config = {}) {
|
|
|
1406
1923
|
argv: (p) => ["check", "--market", p.market ?? "all"]
|
|
1407
1924
|
})
|
|
1408
1925
|
);
|
|
1409
|
-
|
|
1926
|
+
register(
|
|
1410
1927
|
pyTool({
|
|
1411
1928
|
name: "get_market_capabilities",
|
|
1412
1929
|
description: "\u5E02\u573A\u80FD\u529B\u8FB9\u754C \u2014 \u8FD4\u56DE\u6307\u5B9A\u5E02\u573A\u652F\u6301/\u4E0D\u652F\u6301\u7684\u5DE5\u5177\u5217\u8868\u3002\u4E0D\u786E\u5B9A\u67D0\u5E02\u573A\u80FD\u5426\u7528\u67D0\u5DE5\u5177\uFF08\u5982\u6E2F\u80A1\u7684\u7B79\u7801\u5206\u5E03\u3001\u7F8E\u80A1\u7684\u8D44\u91D1\u6D41\uFF09\u65F6\u5148\u8C03\u672C\u5DE5\u5177\uFF0C\u907F\u514D\u8C03\u7528\u4E0D\u652F\u6301\u7684\u5DE5\u5177\u540E\u7F16\u9020\u6570\u636E",
|
|
@@ -1422,7 +1939,7 @@ function apply(ctx, config = {}) {
|
|
|
1422
1939
|
argv: (p) => p.symbol ? ["get", "--symbol", p.symbol] : ["get", "--market", p.market ?? "A"]
|
|
1423
1940
|
})
|
|
1424
1941
|
);
|
|
1425
|
-
|
|
1942
|
+
register(
|
|
1426
1943
|
pyTool({
|
|
1427
1944
|
name: "render_stock_report",
|
|
1428
1945
|
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\u9ED8\u8BA4\u4EC5\u6E32\u67D3\uFF1Bfinal=true\u8868\u793A\u6700\u7EC8\u56DE\u590D\uFF0C\u652F\u6301\u76F4\u51FA\u7684\u5BBF\u4E3B\u53EF\u539F\u6837\u4EA4\u4ED8\u5E76\u7ED3\u675F\u672C\u8F6E\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",
|
|
@@ -1447,7 +1964,7 @@ function apply(ctx, config = {}) {
|
|
|
1447
1964
|
}
|
|
1448
1965
|
})
|
|
1449
1966
|
);
|
|
1450
|
-
|
|
1967
|
+
register(
|
|
1451
1968
|
pyTool({
|
|
1452
1969
|
name: "render_market_report",
|
|
1453
1970
|
description: "\u5927\u76D8\u590D\u76D8\u62A5\u544A\u6E32\u67D3 \u2014 \u5C06\u7ED3\u6784\u5316\u62A5\u544A JSON \u901A\u8FC7 j2 \u6A21\u677F\u6E32\u67D3\u4E3A Markdown\u3002report \u5B57\u6BB5\u4EE5 schemas/market_review_schema.json \u4E3A\u51C6\u3002save=true \u65F6\u628A\u62A5\u544A\u5BF9\u8C61\u8FFD\u52A0\u5F52\u6863\u5230\u672C\u5730 JSONL\uFF08\u9ED8\u8BA4\u4E0D\u4FDD\u5B58\u4E0D\u63A8\u9001\uFF09\uFF0C\u7EB5\u5411\u5BF9\u6BD4\u7528 get_review_history\uFF1Bfinal=true\u4EC5\u7528\u4E8E\u6700\u7EC8\u56DE\u590D\uFF0C\u4FDD\u5B58\u9644\u4EF6\u6216\u7EE7\u7EED\u5206\u6790\u65F6\u4FDD\u6301false",
|
|
@@ -1474,7 +1991,7 @@ function apply(ctx, config = {}) {
|
|
|
1474
1991
|
}
|
|
1475
1992
|
})
|
|
1476
1993
|
);
|
|
1477
|
-
|
|
1994
|
+
register(
|
|
1478
1995
|
pyTool({
|
|
1479
1996
|
name: "get_review_history",
|
|
1480
1997
|
description: "\u590D\u76D8\u5F52\u6863\u5386\u53F2 \u2014 \u8BFB\u53D6\u672C\u5730 JSONL \u5F52\u6863\u7684\u6700\u8FD1 N \u6761\u5E02\u573A\u590D\u76D8\uFF08\u6700\u65B0\u5728\u524D\uFF09\uFF0C\u7528\u4E8E\u7EB5\u5411\u5BF9\u6BD4\uFF08\u6E29\u5EA6/\u59FF\u6001/\u4E3B\u7EBF\u53D8\u5316\uFF09\u3002\u5F52\u6863\u7531 render_market_report \u7684 save=true \u5199\u5165\uFF0C\u7A7A\u5B58\u6863\u8FD4\u56DE\u7A7A\u5217\u8868",
|
|
@@ -1485,7 +2002,7 @@ function apply(ctx, config = {}) {
|
|
|
1485
2002
|
argv: (p) => ["history", "--limit", String(p.limit ?? 10)]
|
|
1486
2003
|
})
|
|
1487
2004
|
);
|
|
1488
|
-
|
|
2005
|
+
register(
|
|
1489
2006
|
pyTool({
|
|
1490
2007
|
name: "build_watchlist_context",
|
|
1491
2008
|
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",
|
|
@@ -1505,7 +2022,7 @@ function apply(ctx, config = {}) {
|
|
|
1505
2022
|
}
|
|
1506
2023
|
})
|
|
1507
2024
|
);
|
|
1508
|
-
|
|
2025
|
+
register(
|
|
1509
2026
|
pyTool({
|
|
1510
2027
|
name: "analyze_position_context",
|
|
1511
2028
|
description: "\u6301\u4ED3\u4E0A\u4E0B\u6587\u5206\u6790 \u2014 \u8F93\u5165\u6210\u672C/\u4ED3\u4F4D/\u6B62\u635F\u6B62\u76C8\uFF0C\u7ED3\u5408\u73B0\u4EF7\u548C\u6280\u672F\u4F4D\u8F93\u51FA\u6D6E\u76C8\u4E8F\u3001\u79BB\u6B62\u635F\u8DDD\u79BB\u3001\u98CE\u9669\u7EA7\u522B\u3001\u64CD\u4F5C\u5EFA\u8BAE\u3002\u65E0\u72B6\u6001\u3001\u4E0D\u5B58\u8D26\u6237",
|
|
@@ -1532,7 +2049,7 @@ function apply(ctx, config = {}) {
|
|
|
1532
2049
|
}
|
|
1533
2050
|
})
|
|
1534
2051
|
);
|
|
1535
|
-
|
|
2052
|
+
register(
|
|
1536
2053
|
pyTool({
|
|
1537
2054
|
name: "check_alert_rules",
|
|
1538
2055
|
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",
|
|
@@ -1552,7 +2069,7 @@ function apply(ctx, config = {}) {
|
|
|
1552
2069
|
}
|
|
1553
2070
|
})
|
|
1554
2071
|
);
|
|
1555
|
-
|
|
2072
|
+
register(
|
|
1556
2073
|
pyTool({
|
|
1557
2074
|
name: "record_signal",
|
|
1558
2075
|
description: "\u8BB0\u5F55\u4E00\u6761 AI \u5206\u6790\u5EFA\u8BAE\u4FE1\u53F7\uFF08\u65B9\u5411/\u5165\u573A\u4EF7/\u76EE\u6807\u4EF7/\u6B62\u635F\u4EF7/\u6301\u6709\u671F\u9650\uFF09\uFF0C\u4F9B\u540E\u7EED\u80DC\u7387\u8BC4\u4F30\u3002\u4FE1\u53F7\u6301\u4E45\u5316\u5728\u672C\u5730 JSONL\uFF08$STOCK_SIGNAL_STORE \u6216 ~/.stock-analysis/signals.jsonl\uFF09\uFF0C\u5BBF\u4E3B Agent \u81EA\u884C\u51B3\u5B9A\u4F55\u65F6 record/evaluate",
|
|
@@ -1590,7 +2107,7 @@ function apply(ctx, config = {}) {
|
|
|
1590
2107
|
}
|
|
1591
2108
|
})
|
|
1592
2109
|
);
|
|
1593
|
-
|
|
2110
|
+
register(
|
|
1594
2111
|
pyTool({
|
|
1595
2112
|
name: "evaluate_signals",
|
|
1596
2113
|
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",
|
|
@@ -1605,7 +2122,7 @@ function apply(ctx, config = {}) {
|
|
|
1605
2122
|
}
|
|
1606
2123
|
})
|
|
1607
2124
|
);
|
|
1608
|
-
|
|
2125
|
+
register(
|
|
1609
2126
|
pyTool({
|
|
1610
2127
|
name: "get_signal_summary",
|
|
1611
2128
|
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",
|
|
@@ -1628,7 +2145,7 @@ function apply(ctx, config = {}) {
|
|
|
1628
2145
|
}
|
|
1629
2146
|
})
|
|
1630
2147
|
);
|
|
1631
|
-
|
|
2148
|
+
register(
|
|
1632
2149
|
pyTool({
|
|
1633
2150
|
name: "parse_stock_list",
|
|
1634
2151
|
description: "\u81EA\u9009\u80A1/\u6587\u672C\u5BFC\u5165\u89E3\u6790 \u2014 \u4ECE\u81EA\u7136\u8BED\u8A00\u3001CSV\u3001Markdown \u8868\u683C\u63D0\u53D6\u80A1\u7968\uFF0C\u81EA\u52A8\u8BC6\u522B A \u80A1 6 \u4F4D\u4EE3\u7801\u3001\u6E2F\u80A1 xxxxx.HK\u3001\u7F8E\u80A1 ticker\u3001\u65E5\u80A1 xxxx.T\u3001\u97E9\u80A1 xxxxxx.KS/KQ\u3001\u53F0\u80A1 xxxx.TW\uFF0C\u5E76\u8C03\u7528 name_resolver \u5904\u7406\u4E2D\u6587\u80A1\u7968\u540D",
|
|
@@ -1642,7 +2159,7 @@ function apply(ctx, config = {}) {
|
|
|
1642
2159
|
}
|
|
1643
2160
|
})
|
|
1644
2161
|
);
|
|
1645
|
-
|
|
2162
|
+
register(closedTool({
|
|
1646
2163
|
name: "compare_stocks",
|
|
1647
2164
|
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",
|
|
1648
2165
|
parameters: {
|
|
@@ -1714,7 +2231,7 @@ function apply(ctx, config = {}) {
|
|
|
1714
2231
|
return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["peers", "--input", path]));
|
|
1715
2232
|
}
|
|
1716
2233
|
}));
|
|
1717
|
-
|
|
2234
|
+
register(closedTool({
|
|
1718
2235
|
name: "analyze_disclosure_changes",
|
|
1719
2236
|
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",
|
|
1720
2237
|
parameters: {
|
|
@@ -1855,7 +2372,7 @@ function apply(ctx, config = {}) {
|
|
|
1855
2372
|
return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["disclosure", "--input", path]));
|
|
1856
2373
|
}
|
|
1857
2374
|
}));
|
|
1858
|
-
|
|
2375
|
+
register(closedTool({
|
|
1859
2376
|
name: "analyze_portfolio_risk",
|
|
1860
2377
|
description: "\u65E0\u72B6\u6001\u73B0\u8D27\u591A\u5934\u7EC4\u5408\u98CE\u9669\u4E0E\u538B\u529B\u6D4B\u8BD5\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\u3001\u6B62\u635F\u60C5\u666F\u53CA\u53EF\u9009\u5E02\u573A/\u884C\u4E1A/\u4E2A\u80A1/\u6C47\u7387\u51B2\u51FB\u635F\u76CA\u3002\u7F3A\u6C47\u7387\u62A5\u9519\uFF1B\u4E0D\u4FDD\u5B58\u8D26\u6237\u3002",
|
|
1861
2378
|
parameters: {
|
|
@@ -2056,7 +2573,7 @@ function apply(ctx, config = {}) {
|
|
|
2056
2573
|
return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["portfolio", "--input", path]));
|
|
2057
2574
|
}
|
|
2058
2575
|
}));
|
|
2059
|
-
|
|
2576
|
+
register(closedTool({
|
|
2060
2577
|
name: "plan_portfolio_rebalance",
|
|
2061
2578
|
description: "\u65E0\u72B6\u6001\u7EC4\u5408\u8C03\u4ED3\u8BA1\u5212\uFF1A\u6309\u5F53\u524D\u6301\u4ED3\u3001\u76EE\u6807\u6743\u91CD\u3001\u73B0\u91D1\u3001\u6C47\u7387\u3001\u6574\u624B\u3001\u8D39\u7528\u548C\u6362\u624B\u7EA6\u675F\u751F\u6210\u5148\u5356\u540E\u4E70\u6E05\u5355\uFF1B\u4E0D\u4FDD\u5B58\u8D26\u6237\u6216\u63D0\u4EA4\u8BA2\u5355\u3002",
|
|
2062
2579
|
parameters: {
|
|
@@ -2195,7 +2712,7 @@ function apply(ctx, config = {}) {
|
|
|
2195
2712
|
return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["rebalance", "--input", path]));
|
|
2196
2713
|
}
|
|
2197
2714
|
}));
|
|
2198
|
-
|
|
2715
|
+
register(closedTool({
|
|
2199
2716
|
name: "calculate_position_size",
|
|
2200
2717
|
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",
|
|
2201
2718
|
parameters: {
|
|
@@ -2246,7 +2763,7 @@ function apply(ctx, config = {}) {
|
|
|
2246
2763
|
return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["position_size", "--input", path]));
|
|
2247
2764
|
}
|
|
2248
2765
|
}));
|
|
2249
|
-
|
|
2766
|
+
register(closedTool({
|
|
2250
2767
|
name: "analyze_event_study",
|
|
2251
2768
|
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",
|
|
2252
2769
|
parameters: {
|
|
@@ -2332,7 +2849,7 @@ function apply(ctx, config = {}) {
|
|
|
2332
2849
|
return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["event_study", "--input", path]));
|
|
2333
2850
|
}
|
|
2334
2851
|
}));
|
|
2335
|
-
|
|
2852
|
+
register(closedTool({
|
|
2336
2853
|
name: "validate_backtest",
|
|
2337
2854
|
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",
|
|
2338
2855
|
parameters: {
|
|
@@ -2452,7 +2969,7 @@ function apply(ctx, config = {}) {
|
|
|
2452
2969
|
return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["robustness", "--input", path]));
|
|
2453
2970
|
}
|
|
2454
2971
|
}));
|
|
2455
|
-
|
|
2972
|
+
register(closedTool({
|
|
2456
2973
|
name: "compare_analysis_snapshots",
|
|
2457
2974
|
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",
|
|
2458
2975
|
parameters: {
|
|
@@ -2475,10 +2992,8 @@ function apply(ctx, config = {}) {
|
|
|
2475
2992
|
return withJsonInput(params, (path) => runPy("stateless_analysis.py", ["snapshot", "--input", path]));
|
|
2476
2993
|
}
|
|
2477
2994
|
}));
|
|
2995
|
+
registerDashboard(ctx, runPy);
|
|
2478
2996
|
registerSkills(ctx);
|
|
2479
|
-
if (config.toolDiscovery !== false) {
|
|
2480
|
-
registerToolDiscovery(ctx, new Set(ctx.tools.schemas?.().filter((tool) => !previousTools.has(tool.name)).map((tool) => tool.name)));
|
|
2481
|
-
}
|
|
2482
2997
|
}
|
|
2483
2998
|
export {
|
|
2484
2999
|
__setExecutor,
|