@weaxs/dsh-stock-analysis 0.2.12 → 0.2.13

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Stock Analysis — DeepSeek Harness (dsh) Plugin
2
2
 
3
- A 股 / 港股 / 美股 / 日股 / 韩股 / 台股的行情、技术分析、选股与回测。作为 dsh bundle 安装到 profile 后,对话中可调用 74 个工具,并自动注册 21 个工作流和策略方法论 Skill;dsh Web / Desktop 侧栏还会多出一个「股票仪表盘」。
3
+ A 股 / 港股 / 美股 / 日股 / 韩股 / 台股的行情、技术分析、选股与回测。作为 dsh bundle 安装到 profile 后,对话中可调用 75 个工具,并自动注册 21 个工作流和策略方法论 Skill;dsh Web / Desktop 侧栏还会多出一个「股票仪表盘」。
4
4
 
5
5
  ![dsh 股票仪表盘:六市场自选股行情、指数带、A 股涨跌分布与行业涨跌榜(深色主题)](https://raw.githubusercontent.com/Weaxs/stock-analysis-plugin/main/docs/images/dsh-dashboard-dark.png)
6
6
 
@@ -43,13 +43,15 @@ allowBuilds:
43
43
 
44
44
  ### 数据如何更新
45
45
 
46
- 数据由插件后台常驻预热:Web 路由注册后即开始按固定任务表调用现有 CLI(`stock_data.py quote/market_indices/kline/sector_rankings/market_stats` 与 `trading_calendar.py phase`),最多 4 个 Python 进程按优先级排队(报价 > 指数 > 走势 > 行业/统计),结果留在内存缓存。刷新节奏随各市场交易阶段变化:交易时段有页面打开时报价与指数约 30 秒、行业 1 分钟、全 A 统计 2 分钟;无人查看时放宽到 5–10 分钟;收盘后 30–60 分钟一次。失败保留上次成功值并标注,重试间隔按 1、2、4… 分钟退避。页面只轮询内存快照 `/api/snapshot`(有后台任务时 1.5 秒,否则 15 秒,页面不可见时停止),并在浏览器本地缓存 24 小时,打开即显示上次数据;「刷新」会让所有数据立即重新获取。不调用包含财务、新闻、风险等完整采集的 `run_watchlist_analysis`。前端接口只接受固定的快照、刷新和自选股操作,不开放任意 Python 脚本或参数。
46
+ 数据由插件后台常驻预热:Web 路由注册后即开始按固定任务表调用现有 CLI(`stock_data.py quotes/market_indices/klines/sector_rankings/market_stats` 与 `trading_calendar.py phase`),最多 4 个 Python 进程按优先级排队(报价 > 指数 > 走势 > 行业/统计);同一轮到期的自选股与 A 股指数报价合并为一个 `quotes` 进程,走势按市场合并为每个市场一个 `klines` 进程,单只失败只影响该行,结果留在内存缓存。刷新节奏随各市场交易阶段变化:交易时段有页面打开时报价与指数约 30 秒、行业 1 分钟、全 A 统计 2 分钟;无人查看时放宽到 5–10 分钟;收盘后 30–60 分钟一次。失败保留上次成功值并标注,重试间隔按 1、2、4… 分钟退避。页面只轮询内存快照 `/api/snapshot`(有后台任务时 1.5 秒,否则 15 秒,页面不可见时停止),并在浏览器本地缓存 24 小时,打开即显示上次数据;「刷新」会让所有数据立即重新获取。不调用包含财务、新闻、风险等完整采集的 `run_watchlist_analysis`。前端接口只接受固定的快照、刷新和自选股操作,不开放任意 Python 脚本或参数。
47
47
 
48
- 前端由 `dsh/client.ts`、`dsh/dashboard.ts` 和 `dsh/web/`(`app.ts` + HTML/CSS)组成,均为 TypeScript,`npm run build:dsh` 将浏览器端编译为 IIFE 输出到 `dist/`;它不增加或改变四宿主共享的 74 个模型工具。源码或 manifest 改动后重新运行 `npm run build:dsh` 并重装/重启对应 profile。
48
+ 前端由 `dsh/client.ts`、`dsh/dashboard.ts` 和 `dsh/web/`(`app.ts` + HTML/CSS)组成,均为 TypeScript,`npm run build:dsh` 将浏览器端编译为 IIFE 输出到 `dist/`;它不增加或改变四宿主共享的 75 个模型工具。源码或 manifest 改动后重新运行 `npm run build:dsh` 并重装/重启对应 profile。
49
+
50
+ 页脚显示当前插件版本。从 npm 安装时,有页面打开的情况下后台每 6 小时最多查询一次 npm 的 `latest` 版本(默认 registry.npmjs.org,可用环境变量 `npm_config_registry` 改为镜像);有新版时页头出现「新版本 ↑ vX」标记,点击打开 dsh 插件页中本插件的详情(在其版本区块点「更新」),宿主没有插件页时打开 GitHub 发布页。查询失败不影响行情。源码或本地路径安装不检查更新。
49
51
 
50
52
  ## 按需工具发现
51
53
 
52
- dsh 0.2.2 及以上(工具注册支持按步骤的 `when` 条件)默认增加一个宿主控制入口 `stock_tool_search`;更早的 0.2.1 不提供该接口,插件会自动关闭按需发现并全量暴露工具,功能不受影响。按需发现只控制工具加载,不改变 74 个分析工具的名称、参数和输出。原生函数调用模式下,首次请求只暴露这个发现入口;其他插件的工具照常保留。搜索支持中文描述、英文关键词或确切工具名,例如 `财务`、`get_quote`、`run_backtest`;命中工具在下一次模型请求提供完整 schema,再按原名调用。默认最多加载 5 项,`limit` 可设 1 到 20;无匹配返回空列表。
54
+ dsh 0.2.2 及以上(工具注册支持按步骤的 `when` 条件)默认增加一个宿主控制入口 `stock_tool_search`;更早的 0.2.1 不提供该接口,插件会自动关闭按需发现并全量暴露工具,功能不受影响。按需发现只控制工具加载,不改变 75 个分析工具的名称、参数和输出。原生函数调用模式下,首次请求只暴露这个发现入口;其他插件的工具照常保留。搜索支持中文描述、英文关键词或确切工具名,例如 `财务`、`get_quote`、`run_backtest`;命中工具在下一次模型请求提供完整 schema,再按原名调用。默认最多加载 5 项,`limit` 可设 1 到 20;无匹配返回空列表。
53
55
 
54
56
  加载集合按 Agent 隔离,搜索和回退均保留宿主已有的工具权限限制。搜索入口被禁止或移除时,下一次请求保留原先已授权的完整股票工具目录。旧版缺少相关接口时保持全量暴露;PTC / both 模式沿用宿主生成的 SDK,不做发现过滤。加载集合在本次运行中保留,恢复会话或重载插件后需重新搜索。
55
57
 
@@ -65,7 +67,7 @@ dsh 0.2.2 及以上(工具注册支持按步骤的 `when` 条件)默认增
65
67
 
66
68
  ## 工具与 Skills
67
69
 
68
- 74 个工具覆盖行情与基金净值、技术分析与 K 线形态、资金流与板块、估值/股东/ETF/股息、公告与 SEC、多因子选股、策略回测、市场复盘、新闻舆情、持仓风险与调仓计算。完整列表见[主仓库 README · 工具列表](https://github.com/Weaxs/stock-analysis-plugin#工具列表),Skills 见 [Skills 一览](https://github.com/Weaxs/stock-analysis-plugin#skills-一览)。
70
+ 75 个工具覆盖行情与基金净值、技术分析与 K 线形态、资金流与板块、估值/股东/ETF/股息、公告与 SEC、多因子选股、策略回测、市场复盘、新闻舆情、持仓风险与调仓计算。完整列表见[主仓库 README · 工具列表](https://github.com/Weaxs/stock-analysis-plugin#工具列表),Skills 见 [Skills 一览](https://github.com/Weaxs/stock-analysis-plugin#skills-一览)。
69
71
 
70
72
  ## 其他宿主
71
73
 
package/dist/client.js CHANGED
@@ -46,11 +46,24 @@
46
46
  Object.entries(tokenMap).map(([key, token]) => [key, style.getPropertyValue(token).trim()]).filter(([, value]) => value)
47
47
  );
48
48
  };
49
+ const pluginPage = () => {
50
+ try {
51
+ const navigation = ctx.get("pluginNavigation");
52
+ return typeof navigation?.openBundle === "function" ? navigation : null;
53
+ } catch {
54
+ return null;
55
+ }
56
+ };
49
57
  const post = (frame) => {
50
58
  if (scheme && frame.contentWindow) {
51
- frame.contentWindow.postMessage({ type: "stock-analysis:theme", scheme, palette: palette() }, location.origin);
59
+ frame.contentWindow.postMessage({ type: "stock-analysis:theme", scheme, palette: palette(), pluginPage: Boolean(pluginPage()) }, location.origin);
52
60
  }
53
61
  };
62
+ window.addEventListener("message", (event) => {
63
+ if (event.origin !== location.origin || event.data?.type !== "stock-analysis:open-plugin") return;
64
+ if (![...frames].some((frame) => frame.contentWindow === event.source)) return;
65
+ pluginPage()?.openBundle?.("@weaxs/dsh-stock-analysis");
66
+ });
54
67
  ctx.inject(["theme"], (c) => {
55
68
  const push = (snapshot) => {
56
69
  scheme = snapshot.active.colorScheme;
package/dist/index.js CHANGED
@@ -373,6 +373,36 @@ var tool_schemas_default = [
373
373
  ]
374
374
  }
375
375
  },
376
+ {
377
+ name: "get_cds_index",
378
+ description: "\u67E5\u8BE2\u5E02\u573A\u7EA7CDS\u6307\u6570\u4F5C\u4E3A\u4FE1\u7528\u98CE\u9669\u504F\u597D\u80CC\u666F\uFF08\u975E\u4E2A\u80A1CDS\u6216\u4EA4\u6613\u4FE1\u53F7\uFF09\u3002source=cn\u8FD4\u56DE\u4E2D\u56FD\u8D27\u5E01\u7F51CFETS-SHCH\u9AD8\u7B49\u7EA7/\u6C11\u4F01/\u957F\u4E09\u89D2/\u79D1\u521B/\u78B3\u4E2D\u548C\u5728\u5CB8CDS\u6307\u6570\u6700\u65B0\u671F\u9650\u66F2\u7EBF\uFF08bp\uFF09\u4E0E\u7A97\u53E3\u5185\u5404\u671F\u9650\u53D8\u5316\uFF08percentile\u4E3A\u7A97\u53E3\u5185\u2264\u6700\u65B0\u503C\u7684\u767E\u5206\u6BD40..100\uFF09\uFF1Bsource=global\u53D6DTCC\u516C\u5F00\u6210\u4EA4\uFF0C\u6309\u65E5\u6C47\u603B\u5F53\u524D5Y\u7CFB\u5217CDX.NA.IG\u3001iTraxx Europe/Crossover\u5229\u5DEE\uFF08bp\uFF09\u4E0ECDX.NA.HY\u4EF7\u683C\uFF08\u4EF7\u683C\u4E0B\u8DCC=\u4FE1\u7528\u8D70\u5F31\uFF09\uFF0C\u53EA\u6BD4\u8F83\u540C\u4E00\u5230\u671F\u7CFB\u5217\uFF0C\u662F\u6210\u4EA4\u4E2D\u4F4D\u6570\u800C\u975E\u5B98\u65B9\u6536\u76D8\u3002\u7528index/tenor\u53EA\u53D6\u9700\u8981\u7684\u6307\u6570\u548C\u671F\u9650\uFF0Ccn\u5386\u53F2\u53EA\u4E3A\u5339\u914D\u5230\u7684\u6307\u6570\u5206\u9875\u62C9\u53D6\u3002",
379
+ parameters: {
380
+ type: "object",
381
+ properties: {
382
+ source: {
383
+ type: "string",
384
+ enum: [
385
+ "cn",
386
+ "global"
387
+ ],
388
+ description: "cn=\u4E2D\u56FD\u5728\u5CB8CDS\u6307\u6570\uFF08\u9ED8\u8BA4\uFF09\uFF0Cglobal=DTCC\u516C\u5F00\u6210\u4EA4\u7684CDX/iTraxx"
389
+ },
390
+ days: {
391
+ type: "number",
392
+ description: "\u56DE\u770B\u81EA\u7136\u65E51..90\uFF0C\u9ED8\u8BA430\uFF1Bglobal\u622A\u6B62\u5230DTCC\u6700\u65B0\u5DF2\u53D1\u5E03\u5DE5\u4F5C\u65E5\u6587\u4EF6"
393
+ },
394
+ index: {
395
+ type: "string",
396
+ description: "\u6307\u6570\u540D\uFF0C\u7CBE\u786E\u5339\u914D\u4F18\u5148\u3001\u5426\u5219\u5305\u542B\u5339\u914D\uFF0C\u5982\u6C11\u4F01\u3001\u79D1\u521B\u3001\u9AD8\u7B49\u7EA7\u3001CDX.NA.HY\u3001ITRAXX EUROPE\uFF1B\u7701\u7565\u8FD4\u56DE\u5168\u90E8"
397
+ },
398
+ tenor: {
399
+ type: "string",
400
+ description: "\u671F\u9650\uFF0C\u59823M\u30011Y\u30015Y\uFF1Bcn\u6309\u671F\u9650\u8FC7\u6EE4\uFF0Cglobal\u4EC55Y\uFF1B\u7701\u7565\u8FD4\u56DE\u5168\u90E8\u671F\u9650"
401
+ }
402
+ },
403
+ required: []
404
+ }
405
+ },
376
406
  {
377
407
  name: "get_earnings_calendar",
378
408
  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\uFF1BUS/JP\u9700symbol\u5E76\u8FD4\u56DEyfinance\u4F9B\u5E94\u5546\u9884\u8BA1\u65E5\u671F\uFF08provider_only\uFF0C\u975E\u5B98\u65B9\u786E\u8BA4\uFF09\u3002HK\u53EF\u6309\u5DF2\u77E5\u8D22\u653F\u671F\u672B\u8FC7\u6EE4\uFF0C\u672A\u77E5\u671F\u6B21\u4E0EUS/JP\u8BF7\u6C42report_date\u65F6\u53E6\u5217unverified_schedules\uFF1BKR/TW\u4E0D\u53EF\u7528\u3002",
@@ -813,7 +843,7 @@ var tool_schemas_default = [
813
843
  },
814
844
  {
815
845
  name: "get_market_stats",
816
- description: "\u83B7\u53D6\u5E02\u573A\u6574\u4F53\u7EDF\u8BA1\uFF08\u6DA8\u8DCC\u5BB6\u6570\u3001\u5E73\u5747/\u4E2D\u4F4D\u6DA8\u5E45\u3001\u6DA8\u8DCCTop5\u3001\u603B\u6210\u4EA4\u989D\uFF09\u3002market=A\uFF08\u9ED8\u8BA4\uFF09\u542B\u6DA8\u505C\u8DCC\u505C\u6570\uFF1BHK/US\u57FA\u4E8E\u4E1C\u65B9\u8D22\u5BCC\u5168\u5E02\u573A\u5FEB\u7167\uFF0C\u65E0\u6DA8\u8DCC\u505C\u5236\u5EA6\uFF0C\u6DA8\u8DCC\u505C\u5B57\u6BB5\u4E3Anull\u3002\u7528\u4E8E\u8861\u91CF\u5E02\u573A\u6574\u4F53\u60C5\u7EEA\u4E0E\u6E29\u5EA6",
846
+ description: "\u83B7\u53D6\u5E02\u573A\u6574\u4F53\u7EDF\u8BA1\uFF08\u6DA8\u8DCC\u5BB6\u6570\u3001\u4E2D\u4F4D\u6DA8\u5E45\u3001\u6DA8\u8DCCTop5\u3001\u603B\u6210\u4EA4\u989D\uFF09\u3002market=A\uFF08\u9ED8\u8BA4\uFF09\u542B\u6DA8\u505C\u8DCC\u505C\u6570\uFF1BHK/US\u57FA\u4E8E\u4E1C\u65B9\u8D22\u5BCC\u6DA8\u8DCC\u6392\u884C\u8BA1\u6570\uFF0C\u65E0\u6DA8\u8DCC\u505C\u5236\u5EA6\uFF0C\u6DA8\u8DCC\u505C\u5B57\u6BB5\u4E0E\u603B\u6210\u4EA4\u989D\u4E3Anull\u3002avg_change_pct\u6052\u4E3Anull\u3002\u7528\u4E8E\u8861\u91CF\u5E02\u573A\u6574\u4F53\u60C5\u7EEA\u4E0E\u6E29\u5EA6",
817
847
  parameters: {
818
848
  type: "object",
819
849
  properties: {
@@ -2752,6 +2782,10 @@ var TOOL_CALLS = {
2752
2782
  script: "value_data.py",
2753
2783
  argv: (p) => ["index_valuation", p.symbol, "--years", String(p.years ?? 5)]
2754
2784
  },
2785
+ get_cds_index: {
2786
+ script: "credit_data.py",
2787
+ argv: (p) => ["cds_index", "--source", p.source ?? "cn", "--days", String(p.days ?? 30), "--index", p.index ?? "", "--tenor", p.tenor ?? ""]
2788
+ },
2755
2789
  get_earnings_calendar: {
2756
2790
  script: "value_data.py",
2757
2791
  argv: (p) => ["earnings_calendar", "--report-date", p.report_date ?? "", "--symbol", p.symbol ?? "", "--top", String(p.top ?? 50)]
@@ -3232,7 +3266,6 @@ var cli_budgets_default = {
3232
3266
  "risk_screening.py:screen": 450,
3233
3267
  "signal_tracker.py:evaluate": 300,
3234
3268
  "stock_data.py:market_stats": 240,
3235
- "name_resolver.py:resolve": 360,
3236
3269
  "import_parser.py:parse": 360,
3237
3270
  "market_review.py:review": 300,
3238
3271
  "anomaly_detect.py:detect": 390,
@@ -3447,6 +3480,7 @@ import { fileURLToPath } from "node:url";
3447
3480
  import { randomUUID } from "node:crypto";
3448
3481
  var DASHBOARD_BASE = "/stock-analysis";
3449
3482
  var REGIONS = ["cn", "hk", "us", "jp", "kr", "tw"];
3483
+ var STATS_MARKETS = { cn: "A", hk: "HK", us: "US" };
3450
3484
  var STATIC_FILES = /* @__PURE__ */ new Map([
3451
3485
  ["/", ["index.html", "text/html; charset=utf-8"]],
3452
3486
  ["/app.js", ["app.js", "text/javascript; charset=utf-8"]],
@@ -3480,6 +3514,15 @@ var RIBBON = [
3480
3514
  ["tw", "^TWII"]
3481
3515
  ];
3482
3516
  var TRADING_PHASES = /* @__PURE__ */ new Set(["morning", "afternoon", "intraday"]);
3517
+ var UPDATE_CHECK_MS = 6 * 60 * MINUTE;
3518
+ function isNewerVersion(candidate, current) {
3519
+ const parse = (value) => /^(\d+)\.(\d+)\.(\d+)$/.exec(value)?.slice(1).map(Number);
3520
+ const next = parse(candidate);
3521
+ const now = parse(current);
3522
+ if (!next || !now) return false;
3523
+ const index = next.findIndex((part, i) => part !== now[i]);
3524
+ return index >= 0 && next[index] > now[index];
3525
+ }
3483
3526
  var HttpError = class extends Error {
3484
3527
  constructor(status, message) {
3485
3528
  super(message);
@@ -3665,7 +3708,7 @@ function trendRows(value) {
3665
3708
  return value.map((row) => ({ date: String(row?.date ?? ""), close: Number(row?.close) })).filter((row) => Number.isFinite(row.close) && row.close > 0);
3666
3709
  }
3667
3710
  function createDashboardHandler(options) {
3668
- const { runPy: runPy2, watchlistFile, webDir } = options;
3711
+ const { runPy: runPy2, watchlistFile, webDir, plugin } = options;
3669
3712
  const limiter = createPriorityLimiter(MAX_PYTHON);
3670
3713
  const slots = /* @__PURE__ */ new Map();
3671
3714
  const inflight = /* @__PURE__ */ new Set();
@@ -3697,14 +3740,40 @@ function createDashboardHandler(options) {
3697
3740
  }
3698
3741
  }
3699
3742
  const py = async (script, args, timeoutMs) => parseJson(await runPy2(script, args, timeoutMs, abort.signal));
3743
+ const pendingBatches = /* @__PURE__ */ new Map();
3744
+ function batched(command, group, symbol, priority) {
3745
+ const key = `${command}:${group}`;
3746
+ return new Promise((resolve, reject) => {
3747
+ let batch = pendingBatches.get(key);
3748
+ if (!batch) {
3749
+ pendingBatches.set(key, batch = []);
3750
+ queueMicrotask(() => flushBatch(command, key));
3751
+ }
3752
+ batch.push({ symbol, priority, resolve, reject });
3753
+ });
3754
+ }
3755
+ function flushBatch(command, key) {
3756
+ const batch = pendingBatches.get(key);
3757
+ pendingBatches.delete(key);
3758
+ const args = [command, batch.map((item) => item.symbol).join(","), ...command === "klines" ? ["--count", "30"] : []];
3759
+ limiter.run(Math.min(...batch.map((item) => item.priority)), () => py("stock_data.py", args, 4e4)).then(
3760
+ (rows) => {
3761
+ if (!Array.isArray(rows) || rows.length !== batch.length) {
3762
+ throw new Error(safeError(rows?.error, command === "quotes" ? "\u62A5\u4EF7\u6570\u636E\u683C\u5F0F\u4E0D\u6B63\u786E" : "K\u7EBF\u6570\u636E\u683C\u5F0F\u4E0D\u6B63\u786E"));
3763
+ }
3764
+ batch.forEach((item, index) => item.resolve(rows[index]));
3765
+ }
3766
+ ).catch((error) => batch.forEach((item) => item.reject(error)));
3767
+ }
3700
3768
  function quoteJob(symbol, priority) {
3701
3769
  return {
3702
3770
  key: `quote:${symbol}`,
3703
3771
  kind: "quote",
3704
3772
  region: symbolRegion(symbol),
3705
3773
  priority,
3774
+ batched: true,
3706
3775
  run: async () => {
3707
- const value = await py("stock_data.py", ["quote", dashboardQuoteSymbol(symbol)], 2e4);
3776
+ const value = await batched("quotes", "all", dashboardQuoteSymbol(symbol), priority);
3708
3777
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("\u62A5\u4EF7\u6570\u636E\u683C\u5F0F\u4E0D\u6B63\u786E");
3709
3778
  if (value.error) throw new Error(safeError(value.error, "\u62A5\u4EF7\u6682\u4E0D\u53EF\u7528"));
3710
3779
  return { ...value, symbol };
@@ -3717,8 +3786,15 @@ function createDashboardHandler(options) {
3717
3786
  kind: "trend",
3718
3787
  region,
3719
3788
  priority,
3720
- // Yahoo-backed regions regularly need 20-30 s from mainland networks.
3721
- run: async () => trendRows(await py("stock_data.py", ["kline", symbol, "--period", "daily", "--count", "30"], region === "cn" ? 2e4 : 4e4))
3789
+ batched: true,
3790
+ // Per-region batches: Yahoo-backed regions regularly need 20-30 s from mainland networks and must not hold up A-share charts.
3791
+ run: async () => {
3792
+ const value = await batched("klines", region, symbol, priority);
3793
+ if (value && typeof value === "object" && !Array.isArray(value) && "error" in value) {
3794
+ throw new Error(safeError(value.error, "K\u7EBF\u6682\u4E0D\u53EF\u7528"));
3795
+ }
3796
+ return trendRows(value);
3797
+ }
3722
3798
  };
3723
3799
  }
3724
3800
  function jobs(symbols) {
@@ -3773,18 +3849,20 @@ function createDashboardHandler(options) {
3773
3849
  return { top: value.top, bottom: Array.isArray(value.bottom) ? value.bottom : [] };
3774
3850
  }
3775
3851
  });
3776
- list.push({
3777
- // Slow (~15 s alone) but first-viewport content: start it in the first wave on its own worker.
3778
- key: "stats",
3779
- kind: "stats",
3780
- region: "cn",
3781
- priority: 2,
3782
- run: async () => {
3783
- const value = await py("stock_data.py", ["market_stats"], 13e4);
3784
- if (!value || typeof value !== "object" || value.error) throw new Error(safeError(value?.error, "\u5E02\u573A\u5BBD\u5EA6\u6682\u4E0D\u53EF\u7528"));
3785
- return value;
3786
- }
3787
- });
3852
+ for (const [region, market] of Object.entries(STATS_MARKETS)) {
3853
+ list.push({
3854
+ // First-viewport content (the breadth strip shows all three markets), so it rides the first wave.
3855
+ key: `stats:${region}`,
3856
+ kind: "stats",
3857
+ region,
3858
+ priority: 2,
3859
+ run: async () => {
3860
+ const value = await py("stock_data.py", ["market_stats", "--market", market], 6e4);
3861
+ if (!value || typeof value !== "object" || value.error) throw new Error(safeError(value?.error, "\u5E02\u573A\u5BBD\u5EA6\u6682\u4E0D\u53EF\u7528"));
3862
+ return value;
3863
+ }
3864
+ });
3865
+ }
3788
3866
  const unique = /* @__PURE__ */ new Map();
3789
3867
  for (const job of list) {
3790
3868
  const previous = unique.get(job.key);
@@ -3804,7 +3882,7 @@ function createDashboardHandler(options) {
3804
3882
  const entry = slot(job.key);
3805
3883
  entry.running = true;
3806
3884
  entry.force = false;
3807
- const task = limiter.run(job.priority, job.run).then(
3885
+ const task = (job.batched ? job.run() : limiter.run(job.priority, job.run)).then(
3808
3886
  (value) => {
3809
3887
  entry.value = value;
3810
3888
  entry.error = null;
@@ -3845,6 +3923,16 @@ function createDashboardHandler(options) {
3845
3923
  const kick = () => {
3846
3924
  void tick();
3847
3925
  };
3926
+ let latestVersion = null;
3927
+ let latestCheckedAt = 0;
3928
+ function checkLatest() {
3929
+ if (!plugin?.latest || Date.now() - latestCheckedAt < UPDATE_CHECK_MS) return;
3930
+ latestCheckedAt = Date.now();
3931
+ plugin.latest().then((value) => {
3932
+ latestVersion = value;
3933
+ }, () => {
3934
+ });
3935
+ }
3848
3936
  function slotView(key) {
3849
3937
  const entry = slots.get(key);
3850
3938
  return {
@@ -3869,6 +3957,7 @@ function createDashboardHandler(options) {
3869
3957
  viewedRegion = region;
3870
3958
  const symbols = readWatchlist(watchlistFile);
3871
3959
  kick();
3960
+ checkLatest();
3872
3961
  return {
3873
3962
  watchlist: symbols.map((symbol) => {
3874
3963
  const quote = slotView(`quote:${symbol}`);
@@ -3886,10 +3975,15 @@ function createDashboardHandler(options) {
3886
3975
  ribbon: RIBBON.map(([item, code]) => indexRow(item, code)),
3887
3976
  phases: Object.fromEntries(REGIONS.map((item) => [item, slotView(`phase:${item}`).value])),
3888
3977
  market: { region, indices: INDEX_SYMBOLS[region].map((code) => indexRow(region, code)) },
3889
- // A-share breadth and sectors are the only whole-market statistics; other regions stay honest blanks.
3890
- stats: slotView("stats"),
3978
+ // Breadth exists for A/HK/US and sectors for A only; other regions stay honest blanks.
3979
+ stats: Object.fromEntries(Object.keys(STATS_MARKETS).map((item) => [item, slotView(`stats:${item}`)])),
3891
3980
  sectors: slotView("sectors"),
3892
3981
  pending: limiter.queued,
3982
+ plugin: plugin ? {
3983
+ name: plugin.name,
3984
+ version: plugin.version,
3985
+ latest: latestVersion && isNewerVersion(latestVersion, plugin.version) ? latestVersion : null
3986
+ } : null,
3893
3987
  fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
3894
3988
  };
3895
3989
  }
@@ -3966,16 +4060,36 @@ function createDashboardHandler(options) {
3966
4060
  };
3967
4061
  return handler;
3968
4062
  }
4063
+ function installedPlugin(here2) {
4064
+ for (const file of [join3(here2, "package.json"), join3(here2, "..", "package.json")]) {
4065
+ try {
4066
+ const { name: name2, version } = JSON.parse(readFileSync(file, "utf8"));
4067
+ if (typeof name2 === "string" && name2.endsWith("dsh-stock-analysis") && typeof version === "string") {
4068
+ return { name: name2, version, latest: /[/\\]node_modules[/\\]/.test(here2) ? () => npmLatest(name2) : void 0 };
4069
+ }
4070
+ } catch {
4071
+ }
4072
+ }
4073
+ return void 0;
4074
+ }
4075
+ async function npmLatest(name2) {
4076
+ const registry = (process.env.npm_config_registry || "https://registry.npmjs.org").replace(/\/+$/, "");
4077
+ const res = await fetch(`${registry}/${name2.replace("/", "%2f")}/latest`, { signal: AbortSignal.timeout(5e3) });
4078
+ if (!res.ok) throw new Error(`registry ${res.status}`);
4079
+ const { version } = await res.json();
4080
+ return typeof version === "string" ? version : null;
4081
+ }
3969
4082
  function registerDashboard(ctx, runPy2) {
3970
4083
  if (typeof ctx.inject !== "function") return;
3971
4084
  const here2 = dirname(fileURLToPath(import.meta.url));
3972
4085
  const webDir = [join3(here2, "web"), join3(here2, "dist", "web")].find((dir) => existsSync2(join3(dir, "app.js"))) ?? join3(here2, "web");
3973
4086
  const dataRoot = process.env.DSH_HOME || join3(homedir(), ".dsh");
3974
4087
  const watchlistFile = process.env.STOCK_WATCHLIST_FILE || join3(dataRoot, "stock-analysis", "watchlist.json");
4088
+ const plugin = installedPlugin(here2);
3975
4089
  ctx.inject(["webServer"], (nested) => {
3976
4090
  const c = nested;
3977
4091
  c.effect(() => {
3978
- const handler = createDashboardHandler({ runPy: runPy2, watchlistFile, webDir, warm: true });
4092
+ const handler = createDashboardHandler({ runPy: runPy2, watchlistFile, webDir, warm: true, plugin });
3979
4093
  const disposeRoute = c.webServer.register({ kind: "prefix", path: DASHBOARD_BASE, handler });
3980
4094
  return () => {
3981
4095
  handler.dispose();
package/dist/web/app.js CHANGED
@@ -47,7 +47,9 @@
47
47
  error: null,
48
48
  lastOk: 0,
49
49
  fromCache: false,
50
- signature: ""
50
+ signature: "",
51
+ // Set by the dsh shell when its plugin manager can open this bundle's page (with its Update button).
52
+ pluginPage: false
51
53
  };
52
54
  function $(id) {
53
55
  const node = document.getElementById(id);
@@ -262,6 +264,17 @@
262
264
  function isStale(row) {
263
265
  return Boolean(row.error && row.quote);
264
266
  }
267
+ function renderVersion() {
268
+ const plugin = state.snap?.plugin;
269
+ $("version").textContent = plugin ? `${plugin.name} v${plugin.version}` : "";
270
+ const update = $("update");
271
+ update.hidden = !plugin?.latest;
272
+ if (!plugin?.latest) return;
273
+ $("update-version").textContent = `\u2191 v${plugin.latest}`;
274
+ const tip = `\u65B0\u7248\u672C v${plugin.latest} \u5DF2\u53D1\u5E03\uFF08\u5F53\u524D v${plugin.version}\uFF09\uFF0C${state.pluginPage ? "\u70B9\u51FB\u524D\u5F80\u63D2\u4EF6\u9875\u66F4\u65B0" : "\u70B9\u51FB\u67E5\u770B\u53D1\u5E03\u8BF4\u660E"}`;
275
+ update.title = tip;
276
+ update.setAttribute("aria-label", tip);
277
+ }
265
278
  function staleTitle(row) {
266
279
  return `\u66F4\u65B0\u5931\u8D25\uFF0C\u663E\u793A\u4E0A\u6B21\u62A5\u4EF7${row.updatedAt ? `\uFF08${clock(row.updatedAt)}\uFF09` : ""}`;
267
280
  }
@@ -347,36 +360,27 @@
347
360
  function statsCounts(stats) {
348
361
  return [num(stats.up_count) ?? 0, num(stats.flat_count) ?? 0, num(stats.down_count) ?? 0];
349
362
  }
363
+ var BREADTH_REGIONS = ["cn", "hk", "us"];
350
364
  function renderPulse() {
351
365
  const node = $("pulse");
352
366
  node.replaceChildren();
353
- const slot = state.snap?.stats;
354
- const stats = slot?.value;
355
- node.append(el("span", "label", "A\u80A1"));
356
- if (!slot || !stats) {
357
- node.append(el("span", "", slot?.error && !slot.loading ? "\u5168\u5E02\u573A\u6DA8\u8DCC\u7EDF\u8BA1\u6682\u65F6\u5931\u8D25\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5" : "\u6B63\u5728\u7EDF\u8BA1\u5168\u5E02\u573A\u6DA8\u8DCC\uFF0C\u9996\u6B21\u7EA6\u9700 15\u201360 \u79D2\u2026"));
358
- return;
367
+ for (const region of BREADTH_REGIONS) {
368
+ const slot = state.snap?.stats?.[region];
369
+ const stats = slot?.value;
370
+ const group = el("span", "breadth");
371
+ group.append(el("span", "label", REGION_NAMES[region]));
372
+ if (!stats) {
373
+ group.append(el("span", "", slot?.error && !slot.loading ? "\u6682\u4E0D\u53EF\u7528" : "\u7EDF\u8BA1\u4E2D\u2026"));
374
+ } else {
375
+ const [up, flat, down] = statsCounts(stats);
376
+ const upText = el("span", "up", "\u6DA8 ");
377
+ upText.append(el("strong", "up", up));
378
+ const downText = el("span", "down", "\u8DCC ");
379
+ downText.append(el("strong", "down", down));
380
+ group.append(upText, breadthBar(up, flat, down), downText);
381
+ }
382
+ node.append(group);
359
383
  }
360
- const [up, flat, down] = statsCounts(stats);
361
- const breadth = el("span", "breadth");
362
- const upText = el("span", "up", "\u6DA8 ");
363
- upText.append(el("strong", "up", up));
364
- const downText = el("span", "down", "\u8DCC ");
365
- downText.append(el("strong", "down", down));
366
- breadth.append(upText, breadthBar(up, flat, down), downText);
367
- const item = (label, value, cls = "") => {
368
- const span = el("span", "", `${label} `);
369
- span.append(el("strong", cls, value));
370
- return span;
371
- };
372
- node.append(
373
- breadth,
374
- item("\u6DA8\u505C", num(stats.limit_up_count) ?? "\u2014", "up"),
375
- item("\u8DCC\u505C", num(stats.limit_down_count) ?? "\u2014", "down"),
376
- item("\u4E2D\u4F4D\u6570", fmtPct(stats.median_change_pct), dir(stats.median_change_pct)),
377
- item("\u6210\u4EA4\u989D", fmtAmount(stats.total_turnover))
378
- );
379
- if (slot.updatedAt) node.append(el("span", "", `\u7EDF\u8BA1\u4E8E ${clock(slot.updatedAt)}`));
380
384
  }
381
385
  function renderFilters() {
382
386
  const node = $("filters");
@@ -596,7 +600,7 @@
596
600
  node.append(table);
597
601
  return node;
598
602
  }
599
- function statsPanel(slot) {
603
+ function statsPanel(region, slot) {
600
604
  const stats = slot?.value;
601
605
  const node = panel("\u6DA8\u8DCC\u5206\u5E03", slot?.updatedAt ? `\u7EDF\u8BA1\u4E8E ${clock(slot.updatedAt)}` : "");
602
606
  if (!stats) {
@@ -609,12 +613,11 @@
609
613
  legend.append(el("span", "up", `\u4E0A\u6DA8 ${up}`), el("span", "flat", `\u5E73\u76D8 ${flat}`), el("span", "down", `\u4E0B\u8DCC ${down}`));
610
614
  wide.append(breadthBar(up, flat, down), legend);
611
615
  const list = el("dl", "stats");
616
+ const aShare = region === "cn";
612
617
  const rows = [
613
- ["\u6DA8\u505C", num(stats.limit_up_count) ?? "\u2014", "up"],
614
- ["\u8DCC\u505C", num(stats.limit_down_count) ?? "\u2014", "down"],
615
- ["\u5E73\u5747\u6DA8\u5E45", fmtPct(stats.avg_change_pct), dir(stats.avg_change_pct)],
618
+ ...aShare ? [["\u6DA8\u505C", num(stats.limit_up_count) ?? "\u2014", "up"], ["\u8DCC\u505C", num(stats.limit_down_count) ?? "\u2014", "down"]] : [],
616
619
  ["\u6DA8\u5E45\u4E2D\u4F4D\u6570", fmtPct(stats.median_change_pct), dir(stats.median_change_pct)],
617
- ["\u603B\u6210\u4EA4\u989D", fmtAmount(stats.total_turnover), ""],
620
+ ...aShare ? [["\u603B\u6210\u4EA4\u989D", fmtAmount(stats.total_turnover), ""]] : [],
618
621
  ["\u7EDF\u8BA1\u80A1\u7968", num(stats.total_stocks) ?? up + flat + down, ""]
619
622
  ];
620
623
  for (const [label, value, cls] of rows) {
@@ -667,7 +670,8 @@
667
670
  if (!value) continue;
668
671
  list.append(el("dt", "", label), el("dd", "", value));
669
672
  }
670
- body.append(list, el("p", "", `\u5168\u5E02\u573A\u6DA8\u8DCC\u5206\u5E03\u4E0E\u884C\u4E1A\u6392\u884C\u76EE\u524D\u53EA\u6709 A \u80A1\u6570\u636E\uFF0C${REGION_NAMES[region]}\u6682\u4E0D\u63D0\u4F9B\uFF0C\u4E0D\u7528\u6307\u6570\u6DA8\u8DCC\u4EE3\u66FF\u3002`));
673
+ const missing = BREADTH_REGIONS.includes(region) ? "\u884C\u4E1A\u6392\u884C" : "\u5168\u5E02\u573A\u6DA8\u8DCC\u5206\u5E03\u4E0E\u884C\u4E1A\u6392\u884C";
674
+ body.append(list, el("p", "", `${missing}\u76EE\u524D\u53EA\u6709 A \u80A1\u6570\u636E\uFF0C${REGION_NAMES[region]}\u6682\u4E0D\u63D0\u4F9B\uFF0C\u4E0D\u7528\u6307\u6570\u6DA8\u8DCC\u4EE3\u66FF\u3002`));
671
675
  node.append(body);
672
676
  return node;
673
677
  }
@@ -686,7 +690,8 @@
686
690
  const phase = snap.phases?.[state.region];
687
691
  body.append(indexPanel(market, phase));
688
692
  const side = el("div", "side");
689
- if (state.region === "cn") side.append(statsPanel(snap.stats), sectorsPanel(snap.sectors));
693
+ if (state.region === "cn") side.append(statsPanel("cn", snap.stats?.cn), sectorsPanel(snap.sectors));
694
+ else if (BREADTH_REGIONS.includes(state.region)) side.append(statsPanel(state.region, snap.stats?.[state.region]), sessionPanel(state.region, phase));
690
695
  else side.append(sessionPanel(state.region, phase));
691
696
  body.append(side);
692
697
  }
@@ -694,6 +699,7 @@
694
699
  $("tip").hidden = true;
695
700
  $("watch-count").textContent = state.snap ? `${state.snap.watchlist.length} / 30` : "";
696
701
  renderStatus();
702
+ renderVersion();
697
703
  renderRibbon();
698
704
  renderPulse();
699
705
  renderFilters();
@@ -880,12 +886,19 @@
880
886
  const message = event.data;
881
887
  if (!message || message.type !== "stock-analysis:theme" || message.scheme !== "light" && message.scheme !== "dark") return;
882
888
  document.documentElement.dataset.theme = message.scheme;
889
+ state.pluginPage = message.pluginPage === true;
890
+ renderVersion();
883
891
  for (const key of ["bg", "surface", "surfaceSubtle", "text", "muted", "border", "accent", "onAccent"]) {
884
892
  const value = message.palette?.[key];
885
893
  const property = key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
886
894
  if (typeof value === "string" && value.length < 300) document.documentElement.style.setProperty(`--${property}`, value);
887
895
  }
888
896
  });
897
+ $("update").addEventListener("click", (event) => {
898
+ if (!state.pluginPage) return;
899
+ event.preventDefault();
900
+ window.parent.postMessage({ type: "stock-analysis:open-plugin" }, location.origin);
901
+ });
889
902
  document.addEventListener("visibilitychange", () => {
890
903
  if (document.visibilityState === "visible") void poll();
891
904
  else clearTimeout(state.pollTimer);
@@ -18,6 +18,10 @@
18
18
  </div>
19
19
  <p id="status" class="status" role="status" aria-live="polite">正在连接行情服务…</p>
20
20
  <div class="bar-actions">
21
+ <a id="update" class="update-pill" href="https://github.com/Weaxs/stock-analysis-plugin/releases/latest" target="_blank" rel="noreferrer" hidden>
22
+ <span class="update-label">新版本</span>
23
+ <span id="update-version" class="update-version"></span>
24
+ </a>
21
25
  <button id="refresh" class="btn ghost" type="button" title="立即刷新全部行情">
22
26
  <svg class="refresh-icon" viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6v5h-5"/><path d="M18.4 15a7 7 0 1 1-.8-7.8L20 9"/></svg>
23
27
  <span>刷新</span>
@@ -47,7 +51,7 @@
47
51
  <svg viewBox="0 0 20 20" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7.5 4.5L13 10l-5.5 5.5"/></svg>
48
52
  </button>
49
53
  </section>
50
- <div id="pulse" class="pulse" aria-label="A 股市场宽度"></div>
54
+ <div id="pulse" class="pulse" aria-label="A股、港股、美股市场宽度"></div>
51
55
 
52
56
  <section class="watch" aria-labelledby="watch-heading">
53
57
  <h2 id="watch-heading" class="sr-only">自选股行情</h2>
@@ -80,7 +84,7 @@
80
84
  <div id="market-body" class="market-body" role="tabpanel" aria-labelledby="market-heading"></div>
81
85
  </section>
82
86
 
83
- <footer class="foot">报价可能延迟,悬停名称可查看来源与报价时间。交易时段内有页面打开时约每 30 秒更新一次,后台每 5 分钟预热;30 日走势为最近 30 个有效交易日收盘价。</footer>
87
+ <footer class="foot">报价可能延迟,悬停名称可查看来源与报价时间。交易时段内有页面打开时约每 30 秒更新一次,后台每 5 分钟预热;30 日走势为最近 30 个有效交易日收盘价。<span id="version"></span></footer>
84
88
  </div>
85
89
  <div id="tip" class="tip" role="tooltip" hidden></div>
86
90
  </body>
@@ -136,11 +136,11 @@ h1 { font-size: 19px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2
136
136
  .tile-pct { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
137
137
  .tile .spark { grid-column: 1 / -1; margin-top: 3px; }
138
138
 
139
- .pulse { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 16px; min-height: 36px; padding: 8px 2px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
139
+ .pulse { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 32px; min-height: 36px; padding: 8px 2px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
140
140
  .pulse strong { color: var(--text); font-weight: 600; }
141
141
  .pulse .label { color: var(--text); font-weight: 600; }
142
142
  .breadth { display: inline-flex; align-items: center; gap: 8px; }
143
- .breadth-bar { display: flex; width: 180px; height: 6px; border-radius: 3px; overflow: hidden; background: var(--surface-subtle); }
143
+ .breadth-bar { display: flex; width: 140px; height: 6px; border-radius: 3px; overflow: hidden; background: var(--surface-subtle); }
144
144
  .breadth-bar span { display: block; height: 100%; }
145
145
  .breadth-bar .u { background: var(--up); }
146
146
  .breadth-bar .f { background: var(--border); }
@@ -236,8 +236,8 @@ tr:hover .remove, .remove:focus-visible { opacity: 1; }
236
236
  .idx .ipct { text-align: right; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
237
237
  .idx .ispark { width: 110px; }
238
238
  .side { display: grid; gap: 14px; }
239
- .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 8px 14px 14px; border-radius: 8px; overflow: hidden; background: var(--border); }
240
- .stats div { padding: 8px 10px; background: var(--surface); }
239
+ .stats { display: flex; flex-wrap: wrap; gap: 1px; margin: 8px 14px 14px; border-radius: 8px; overflow: hidden; background: var(--border); }
240
+ .stats div { flex: 1 1 30%; min-width: 0; padding: 8px 10px; background: var(--surface); }
241
241
  .stats dt { color: var(--muted); font-size: 11px; }
242
242
  .stats dd { margin: 2px 0 0; font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
243
243
  .breadth-wide { padding: 6px 14px 0; }
@@ -257,6 +257,11 @@ tr:hover .remove, .remove:focus-visible { opacity: 1; }
257
257
  .session dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; }
258
258
  .panel-note { padding: 14px; color: var(--muted); font-size: 12px; }
259
259
  .foot { margin-top: 16px; color: var(--muted); font-size: 11px; max-width: 110ch; }
260
+ .foot #version:not(:empty)::before { content: " · "; }
261
+ .update-pill { align-self: center; display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-subtle); color: inherit; font-size: 12px; text-decoration: none; white-space: nowrap; transition: border-color .16s ease; }
262
+ .update-pill:hover { border-color: var(--warn); }
263
+ .update-label { color: var(--muted); }
264
+ .update-version { color: var(--warn); font-weight: 600; font-variant-numeric: tabular-nums; }
260
265
 
261
266
  .tip { position: fixed; z-index: 10; padding: 6px 9px; border-radius: 7px; background: var(--text); color: var(--bg); font-size: 11.5px; line-height: 1.45; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }
262
267
  .tip b { font-weight: 650; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weaxs/dsh-stock-analysis",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "DeepSeek Harness (dsh) plugin for stock analysis, screening, and strategy backtesting across A/HK/US/JP/KR/TW markets",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,6 +28,10 @@ export const TOOL_CALLS = {
28
28
  script: "value_data.py",
29
29
  argv: (p) => ["index_valuation", p.symbol, "--years", String(p.years ?? 5)],
30
30
  },
31
+ get_cds_index: {
32
+ script: "credit_data.py",
33
+ argv: (p) => ["cds_index", "--source", p.source ?? "cn", "--days", String(p.days ?? 30), "--index", p.index ?? "", "--tenor", p.tenor ?? ""],
34
+ },
31
35
  get_earnings_calendar: {
32
36
  script: "value_data.py",
33
37
  argv: (p) => ["earnings_calendar", "--report-date", p.report_date ?? "", "--symbol", p.symbol ?? "", "--top", String(p.top ?? 50)],
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: bull-trend
3
- description: 趋势交易:识别中长期趋势,制定入场、持仓和退出规则。用于趋势温度计算、趋势股持有、规则化趋势策略或肥尾收益分析。
3
+ description: 趋势交易:识别中长期趋势,制定入场、持仓和退出规则。用于趋势温度计算、趋势股持有、规则化趋势策略、肥尾收益或非对称风险(赔率、凸性、脆弱性)分析。
4
4
  ---
5
5
 
6
6
  # 趋势追踪分析
@@ -9,7 +9,7 @@ description: 趋势交易:识别中长期趋势,制定入场、持仓和退
9
9
 
10
10
  趋势追踪用可执行的规则参与趋势,通过控制试错损失、保留盈利空间捕获少数大行情。肥尾描述收益分布,趋势描述价格路径;肥尾指标不是趋势启动或延续信号。
11
11
 
12
- 用户询问塔勒布、肥尾计算、极端行情或策略是否依赖少数大盈利时,先读取 [肥尾度量与趋势收益诊断](references/fat-tails.md)。概念问题直接解释方法;需要具体统计结果时,按参考中的数据口径准备输入并调用 `scripts/tail_analysis.py`。普通趋势判断无需加载这份参考。
12
+ 用户询问塔勒布、肥尾计算、极端行情、非对称风险(赔率、盈亏比、凸性、脆弱性)或策略是否依赖少数大盈利时,先读取 [肥尾、非对称风险与趋势收益诊断](references/fat-tails.md)。概念问题直接解释方法;需要具体统计结果时,按参考中的数据口径准备输入并调用 `scripts/tail_analysis.py`。普通趋势判断无需加载这份参考。
13
13
 
14
14
  仅解释肥尾概念时,到此完成;下述流程用于具体标的的趋势分析。
15
15