@dsh-ft/dsh-fft-paper-trading 0.6.2 → 0.7.0

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/lib/client.js CHANGED
@@ -9,7 +9,7 @@ window.__ModuleLoader__.load({
9
9
 
10
10
  const ROUTE = '/api/ft-paper-trading'
11
11
  /** Release number stamped into the Feedback link title at build time. */
12
- const PAPER_VERSION = '0.6.2'
12
+ const PAPER_VERSION = '0.7.0'
13
13
  /** Public repository; the panel links out and collects nothing itself. */
14
14
  const ISSUE_NEW = 'https://github.com/gigaflw/dsh-fft-paper-trading/issues/new'
15
15
  /**
@@ -2,6 +2,31 @@
2
2
 
3
3
  本项目遵循 [Semantic Versioning](https://semver.org/lang/zh-CN/)。
4
4
 
5
+ ## 0.6.7 - 2026-11-06
6
+
7
+ - 修复 DSH 首次依赖安装耗尽宿主重连次数后工具无法注册:Node 在准备期间保持 MCP 和完整工具目录,后端退出后在同一连接恢复且不重放结果未知的操作。
8
+ - 图表服务注册失败不再终止整个 MCP,运行目录恢复后自动重试注册;新增真实健康路由、后端实例校验、分型错误及 stderr 轮转日志。
9
+
10
+ - 新增无 Key 的腾讯港美股日 K 备用源;有 Key 保持 FTShare 优先,失败后再尝试公开源。
11
+ - 核对港股三种复权、美股不复权/前复权及历史当日股数;保留美股交易所后缀和类别股身份,拒绝错误复权序列。
12
+ - 最多 4,000 根的有界历史分页,校验重叠页一致性,报告实际覆盖及不足原因;过滤未完成日线并正确处理美国夏令时。
13
+ - 记录拆股/分红实际样本并补充回归;同步 DSH/Codex 包、公开插件源、双语 README 和口径说明。
14
+
15
+ ## 0.6.6 - 2026-11-05
16
+
17
+ - 港美股公开证券目录可在没有 FTShare SDK/Key 时后台刷新,补充常用中文别名并保留缓存中的别名;修复旧的 A 股缓存阻挡港美股目录更新。
18
+ - 港美股历史行情失败后不再误用 A 股接口,保留权限、限流及上游错误;修复美股股类代码被截断的问题。
19
+ - 区分匿名访问限制、已配置凭据的接口权限及临时故障;无 Key 的市场页面明确说明板块排行尚未接入免费源。
20
+ - 免费港美股日 K 只完成初步评估,尚未新增自动备用路径,详见无 Key 能力说明。
21
+
22
+ ## 0.6.5 - 2026-11-05
23
+
24
+ - DSH 图表增加可选宿主面板挂载接口,支持有界布局、精简界面、外部标的与主题联动;需要宿主开发者接入。
25
+ - 修复跨市场相同代码、美股前缀和股类被误判为同一证券而跳过切换的问题,保留同一证券别名回传的去重行为。
26
+ - 移除固定主题属性后恢复宿主主题路径,无需重新挂载。
27
+ - 修复旧的状态请求尚未结束时覆盖来源重试意图的竞争,保证点击重试后仍重新核对当前来源。
28
+ - 增加组件属性更新与视图主题路径的回归测试,重新构建客户端,同步双安装包和公开 GitHub 插件源。
29
+
5
30
  ## 0.6.4 - 2026-11-04
6
31
 
7
32
  - 修复 DSH 嵌套 bundle 安装的工作目录定位,避免 MCP 在 Python 启动前即发生 `spawn ENOENT`。
@@ -16,7 +16,7 @@
16
16
  | Codex desktop | Yes, in an app card | Yes, after opening the current chart session | Yes |
17
17
  | Codex CLI | No interactive chart | No chart drawing | Yes, as structured results |
18
18
 
19
- The Codex plugin is currently **v0.6.4**, available through this repository's public **FTShare GitHub marketplace**. It is not listed in the official public plugin directory. DSH retains its existing installation path. The DSH screenshots and persistent-watchlist description below apply to DSH Web; see [Codex setup and differences](#use-with-codex) for the separate plugin.
19
+ The Codex plugin is currently **v0.6.7**, available through this repository's public **FTShare GitHub marketplace**. It is not listed in the official public plugin directory. DSH retains its existing installation path. The DSH screenshots and persistent-watchlist description below apply to DSH Web; see [Codex setup and differences](#use-with-codex) for the separate plugin.
20
20
 
21
21
  ## What it helps you do
22
22
 
@@ -76,14 +76,14 @@ If you previously installed `ft-kline@ftshare-local` from a ZIP, disable that ol
76
76
 
77
77
  ### Install a fixed release ZIP
78
78
 
79
- To stay on a fixed release, download `ft-kline-v0.6.4.zip` and its SHA-256 from the [v0.6.4 release](https://github.com/FTShare-Lab/dsh_kline/releases/tag/v0.6.4), verify the hash, and extract to a permanent folder. Replace the quoted path below with that absolute folder path:
79
+ To stay on a fixed release, download `ft-kline-v0.6.7.zip` and its SHA-256 from the [v0.6.7 release](https://github.com/FTShare-Lab/dsh_kline/releases/tag/v0.6.7), verify the hash, and extract to a permanent folder. Replace the quoted path below with that absolute folder path:
80
80
 
81
81
  ```bash
82
- codex plugin marketplace add "/absolute/path/ft-kline-v0.6.4"
82
+ codex plugin marketplace add "/absolute/path/ft-kline-v0.6.7"
83
83
  codex plugin add ft-kline@ftshare-local
84
84
  ```
85
85
 
86
- Reopen Codex to use it. The ZIP source is `ftshare-local`, separate from the public GitHub source `ftshare`. DSH retains its `dsh-kline-v0.6.4.tgz` package and the installation method below.
86
+ Reopen Codex to use it. The ZIP source is `ftshare-local`, separate from the public GitHub source `ftshare`. DSH retains its `dsh-kline-v0.6.7.tgz` package and the installation method below.
87
87
 
88
88
  ### First launch and runtime modes
89
89
 
@@ -97,16 +97,20 @@ Chart edits follow `get_chart_context → prepare_chart_edit → apply_chart_edi
97
97
 
98
98
  ### Reuse an FTShare key
99
99
 
100
+ Symbol discovery and quote access are separate. v0.6.7 adds a keyless Tencent HK/US daily fallback: HK supports unadjusted, forward and backward adjustment; US supports unadjusted and forward adjustment. Volumes remain historical session shares. Public-source coverage is bounded; see the [data contract](docs/free-foreign-daily.md). See the [key-less capability and evaluation notes](docs/anonymous-market-support.md); fixed release archives retain their release's behavior.
101
+
100
102
  Credential priority is: **plugin-process `FTSHARE_API_KEY` → explicitly configured `FTSHARE_API_KEY_FILE` → temporary App-session key**. An export in an unrelated terminal is not automatically visible to the desktop app.
101
103
 
102
104
  The selected file is reread before provider requests and is never modified or deleted by the plugin. Use JSON `{"version":1,"api_key":"your key"}`. macOS/Linux require owner-only permissions (`chmod 600`); symbolic links are rejected. Status reports only `environment`, `external_file`, `session` or `none`, never the key or path. Codex does not discover DSH credentials or scan `.env`, shell profiles, keychains or other apps; sharing a file requires explicitly configuring its path.
103
105
 
104
- Without a key, supported A-share daily-history and index fallbacks remain available. Chart state, results, watchlists and App-entered keys stay in connection memory until the last view closes, disconnect, or 30 idle minutes. User-managed environment/file credentials are not deleted when a chart closes. DSH persistent watchlists are not inherited.
106
+ Without a key, supported A-share, HK and US daily-history and index fallbacks remain available. Chart state, results, watchlists and App-entered keys stay in connection memory until the last view closes, disconnect, or 30 idle minutes. User-managed environment/file credentials are not deleted when a chart closes. DSH persistent watchlists are not inherited.
105
107
 
106
- See the [v0.6.4 release notes](docs/release-notes-v0.6.4.md) and [acceptance checklist](docs/release-acceptance-v0.6.4.md) for verification and remaining manual desktop checks.
108
+ See the [v0.6.7 release notes](docs/release-notes-v0.6.7.md) and [acceptance checklist](docs/release-acceptance-v0.6.7.md) for verification and remaining manual desktop checks.
107
109
 
108
110
  ## Get started with DSH
109
111
 
112
+ v0.6.5 adds an optional chart-panel mounting interface for host developers, with external symbol and theme updates. Canvas and paper-trading panels require host integration; see the [embedding contract](docs/embedding.md).
113
+
110
114
  ### 1. Install and enable
111
115
 
112
116
  Find `dsh_kline` in the DeepSeek Harness plugin marketplace. If the catalog has not refreshed yet, install directly from GitHub:
@@ -167,7 +171,7 @@ For safety, the plugin never scans `.env` files, shell configuration, keychains,
167
171
 
168
172
  Theme and language follow the DSH host by default. **Settings → Theme/Language** also offers manual choices and a way back to **Follow host (default)**.
169
173
 
170
- [FTShare's free-plan endpoints](https://market.ft.tech/gateway/doc/p/pb8eizu3) still require a registered API key. Without a key, some historical daily A-share bars can use BaoStock and selected broad-market indices have another free fallback; intraday bars, other markets, and news still depend on source coverage and permissions. Existing valid OHLCV data, including rows supplied by the host, can still drive local indicators and drawing. The UI reports the applicable source or error when data is rate-limited, unavailable, or outside the account's entitlement.
174
+ [FTShare's free-plan endpoints](https://market.ft.tech/gateway/doc/p/pb8eizu3) still require a registered API key. Without a key, some historical daily A-share bars can use BaoStock, HK/US daily bars can use Tencent, and selected broad-market indices have separate free fallbacks. Intraday bars, news and other capabilities still depend on source coverage and permissions. Existing valid OHLCV data, including rows supplied by the host, can still drive local indicators and drawing. The UI reports the applicable source or error when data is rate-limited, unavailable, or outside the account's entitlement.
171
175
 
172
176
  ## Frequently asked questions
173
177
 
@@ -251,3 +255,11 @@ See [Releases](https://github.com/FTShare-Lab/dsh_kline/releases) for version hi
251
255
  Maintainers changing tools, annotations, resources or the App bridge must regenerate the packaged catalog with `python scripts/generate-codex-catalog.py`; `--check` and regression tests detect stale catalogs.
252
256
 
253
257
  The public `marketplace/ft-kline/` snapshot is generated from the same Codex package allowlist. After editing source, plugin manifests or README files, run `pnpm sync:codex-marketplace` and commit the generated files. CI runs `pnpm verify:codex-marketplace` and independently starts the directory in Desktop and CLI modes. Do not edit generated files directly; see [marketplace maintenance](marketplace/README.md).
258
+
259
+ ### DSH startup diagnostics
260
+
261
+ MCP discovery remains connected while Python is prepared; `dsh_kline_runtime_status` reports `preparing`, `recovering`, or `ready`. Backend restarts never replay operations with unknown outcomes. Chart registration retries without terminating other MCP tools.
262
+
263
+ Request `/dsh-kline/healthz` on the current DSH Web origin: 200 confirms the locator and HTTP backend instance agree; 503 identifies the failure. It does not check provider permissions or MCP tool execution. Historical `/dsh-kline/session?session=…` snapshots are not a health check. Use the locator's actual service port rather than assuming 8765.
264
+
265
+ Dependency logs remain in `bootstrap.log`; backend stderr is persisted to `logs/backend-<host_pid>.log` with one `.previous` rotation at approximately 1 MiB. The default cache is `~/.cache/dsh_kline` on macOS/Linux (honoring `XDG_CACHE_HOME`) or `%LOCALAPPDATA%\dsh_kline` on Windows. `DSH_KLINE_CACHE_DIR` overrides it; `DSH_KLINE_RUNTIME_DIR` independently overrides runtime files. Health responses never expose the service token.
@@ -16,7 +16,7 @@
16
16
  | Codex 桌面版 | 支持,图表在应用卡片中打开 | 支持,需先取得当前图表会话 | 支持 |
17
17
  | Codex CLI | 无交互图表 | 无图表落图 | 支持,返回结构化结果 |
18
18
 
19
- Codex 版目前为 **v0.6.4**,可添加本仓库的公开 **FTShare GitHub 插件源**后安装;尚未上架官方公共插件目录。DSH 版沿用原有安装方式。下面的 DSH 截图和持久化自选说明只针对 DSH Web,Codex 的会话与安装差异见[下文](#在-codex-中使用)。
19
+ Codex 版目前为 **v0.6.7**,可添加本仓库的公开 **FTShare GitHub 插件源**后安装;尚未上架官方公共插件目录。DSH 版沿用原有安装方式。下面的 DSH 截图和持久化自选说明只针对 DSH Web,Codex 的会话与安装差异见[下文](#在-codex-中使用)。
20
20
 
21
21
  ## 它能帮你做什么
22
22
 
@@ -77,14 +77,14 @@ codex plugin add ft-kline@ftshare
77
77
 
78
78
  ### 固定版本 ZIP 安装
79
79
 
80
- 如需固定在发布版本,也可从 [v0.6.4 发布页](https://github.com/FTShare-Lab/dsh_kline/releases/tag/v0.6.4) 下载 `ft-kline-v0.6.4.zip` 和同名 SHA-256 文件,核对后解压到长期保留的目录。将下面路径换成实际解压目录;含空格时保留引号:
80
+ 如需固定在发布版本,也可从 [v0.6.7 发布页](https://github.com/FTShare-Lab/dsh_kline/releases/tag/v0.6.7) 下载 `ft-kline-v0.6.7.zip` 和同名 SHA-256 文件,核对后解压到长期保留的目录。将下面路径换成实际解压目录;含空格时保留引号:
81
81
 
82
82
  ```bash
83
- codex plugin marketplace add "/absolute/path/ft-kline-v0.6.4"
83
+ codex plugin marketplace add "/absolute/path/ft-kline-v0.6.7"
84
84
  codex plugin add ft-kline@ftshare-local
85
85
  ```
86
86
 
87
- 重新打开 Codex 后即可使用。ZIP 源标识为 `ftshare-local`,与公开 GitHub 源 `ftshare` 分开维护。DSH 沿用 `dsh-kline-v0.6.4.tgz` 安装包及下文的 DSH 安装方式。
87
+ 重新打开 Codex 后即可使用。ZIP 源标识为 `ftshare-local`,与公开 GitHub 源 `ftshare` 分开维护。DSH 沿用 `dsh-kline-v0.6.7.tgz` 安装包及下文的 DSH 安装方式。
88
88
 
89
89
  ### 首次准备与运行模式
90
90
 
@@ -98,20 +98,24 @@ Codex 入口默认按宿主声明的 MCP Apps HTML 能力选择模式:具备
98
98
 
99
99
  ### 已有 FTShare Key 如何复用
100
100
 
101
+ 无 Key 不等于所有市场都不可用,搜索目录与行情权限也相互独立。v0.6.7 新增腾讯港美股免费日 K 备用源:港股支持三种复权,美股支持不复权和前复权;成交量为历史当日股数。仅接入日 K,历史覆盖受公开源限制,详见[数据口径](docs/free-foreign-daily.md)。搜索与其他能力见[无 Key 说明](docs/anonymous-market-support.md)。固定版本安装包以对应发行版为准。
102
+
101
103
  Codex 依次使用:
102
104
 
103
105
  1. **启动插件的进程环境**中的 `FTSHARE_API_KEY`;仅在另一个终端执行过 `export`,不代表桌面应用也能继承。
104
106
  2. 用户明确指定的 `FTSHARE_API_KEY_FILE`,每次取数前重新读取;文件由用户管理,插件不修改、不清除。JSON 格式为 `{"version":1,"api_key":"你的 Key"}`;macOS/Linux 必须限制为仅当前用户可读写(`chmod 600`),不接受符号链接。
105
107
  3. 图表“设置 → 数据源”输入的临时 Key,仅当前 App 会话使用。
106
108
 
107
- 没有 Key 仍可尝试部分 A 股历史日线及免费指数备用源。Codex **不自动扫描** DSH、`.env`、shell、钥匙串或其他应用的配置;如需共享已有文件,必须明确设置上述文件路径。状态只显示 `environment`、`external_file`、`session` 或 `none`,不回显 Key 或路径。
109
+ 没有 Key 仍可尝试 A 股、港股、美股历史日 K 和免费指数备用源;公开源失败不代表 Key 无效。Codex **不自动扫描** DSH、`.env`、shell、钥匙串或其他应用的配置;如需共享已有文件,必须明确设置上述文件路径。状态只显示 `environment`、`external_file`、`session` 或 `none`,不回显 Key 或路径。
108
110
 
109
111
  图表、函数结果、自选和应用内临时 Key 保存在当前连接内存中;最后一个图表视图关闭、连接结束或空闲 30 分钟后清除。Codex 不继承 DSH 的持久化自选。环境变量和显式文件由用户管理,不会随图表关闭而被插件删除。
110
112
 
111
- 发布内容、自动化验证和仍待完成的桌面人工验收见 [v0.6.4 发布说明](docs/release-notes-v0.6.4.md) 与 [验收说明](docs/release-acceptance-v0.6.4.md)。
113
+ 发布内容、自动化验证和仍待完成的桌面人工验收见 [v0.6.7 发布说明](docs/release-notes-v0.6.7.md) 与 [验收说明](docs/release-acceptance-v0.6.7.md)。
112
114
 
113
115
  ## 开始使用 DSH 版
114
116
 
117
+ v0.6.5 为宿主开发者提供可选的图表面板挂载接口,支持外部标的与主题联动。画布、模拟盘等场景需要宿主接入;接口与布局约定见[嵌入说明](docs/embedding.md)。
118
+
115
119
  ### 1. 安装并启用
116
120
 
117
121
  在 DeepSeek Harness 的插件市场搜索 `dsh_kline`。如果市场目录还没有刷新,可以直接从 GitHub 安装:
@@ -203,7 +207,7 @@ DeepSeek Harness 自带右侧栏,**不安装 Better Sidebar 也能打开 K 线
203
207
  二者不选点、不评判专业形态、不代替绘图授权。旧的分类型工具是快照接口,不应绕过当前图应用协议。
204
208
 
205
209
  运行 `pnpm build:sidebar` 和 `pnpm test` 验证构建与全部 Node / Python 回归。
206
- DSH 绘图范围见[v0.5.0 验收说明](docs/release-acceptance-v0.5.0.md),本版安装与 Codex 验证见[v0.6.4 验收说明](docs/release-acceptance-v0.6.4.md)。
210
+ DSH 绘图范围见[v0.5.0 验收说明](docs/release-acceptance-v0.5.0.md),本版安装与 Codex 验证见[v0.6.7 验收说明](docs/release-acceptance-v0.6.7.md)。
207
211
  首次自动准备依赖需要网络,耗时取决于网络和本机环境。
208
212
 
209
213
  ## 行情与数据源
@@ -221,7 +225,7 @@ DSH 中安装了 FTShare 设置插件时,宿主会把设置里的 Key 发布
221
225
 
222
226
  主题和语言默认跟随 dsh 宿主,可在 **设置 → 主题/语言** 中改为手动选择;随时可切回“跟随宿主(默认)”。
223
227
 
224
- [FTShare 的“免费版”接口](https://market.ft.tech/gateway/doc/p/pb8eizu3)仍需注册并配置 API Key。完全不配置 Key 时,部分 A 股历史日 K 可尝试 BaoStock 备用源,部分大盘指数也有免费备用行情;分钟线、其他市场及新闻等能力仍取决于来源与权限。已有的合规 K 线数据(包括宿主提供的标准 OHLCV)仍可用于本地指标计算与绘图。遇到限流、权限不足或上游暂不可用,界面会说明实际原因和数据来源。
228
+ [FTShare 的“免费版”接口](https://market.ft.tech/gateway/doc/p/pb8eizu3)仍需注册并配置 API Key。完全不配置 Key 时,部分 A 股历史日 K 可尝试 BaoStock 备用源,港美股日 K 可尝试腾讯,部分大盘指数也有独立免费备用行情;分钟线、新闻等能力仍取决于来源与权限。已有的合规 K 线数据(包括宿主提供的标准 OHLCV)仍可用于本地指标计算与绘图。遇到限流、权限不足或上游暂不可用,界面会说明实际原因和数据来源。
225
229
 
226
230
  ## 常见问题
227
231
 
@@ -267,3 +271,11 @@ FTShare 只是默认适配器,不是分析引擎的前提。调用方可以把
267
271
  维护者修改工具参数、注解、资源或 App 桥接代码后,运行 `python scripts/generate-codex-catalog.py` 更新随包目录;`--check` 与回归测试会阻止过期目录进入发布包。
268
272
 
269
273
  公开 GitHub 源中的 `marketplace/ft-kline/` 由同一 Codex 打包清单生成。修改源码、插件声明或 README 后,运行 `pnpm sync:codex-marketplace` 并提交生成结果;CI 通过 `pnpm verify:codex-marketplace` 检查文件一致性,并独立验证该目录的桌面及 CLI 启动。不要直接修改生成目录,维护说明见 [marketplace/README.md](marketplace/README.md)。
274
+
275
+ ### DSH 启动诊断
276
+
277
+ 首次启动时,MCP 工具目录会立即注册,Python 环境在同一连接内准备。`dsh_kline_runtime_status` 返回 `preparing` / `recovering` / `ready`;未就绪的调用会明确说明是否已经发送。结果未知的操作必须先核对状态,不能自动重放。图表定位文件写失败时其他 MCP 工具仍可用,目录恢复后自动注册。
278
+
279
+ 在当前 DSH Web 地址请求 `/dsh-kline/healthz`:200 表示定位记录与实际 HTTP 后端实例一致;503 返回故障原因。这个检查不验证行情供应商权限或 MCP 工具调用。`/dsh-kline/session?session=…` 读取历史快照,不能代替健康检查。后端实际端口由定位文件决定,不能假定固定为 8765。
280
+
281
+ 安装日志为缓存目录下的 `bootstrap.log`,后端 stderr 为 `logs/backend-<宿主PID>.log`,超过约 1 MiB 时保留一份 `.previous`。默认缓存目录为 macOS/Linux 的 `~/.cache/dsh_kline`(支持 `XDG_CACHE_HOME`)或 Windows 的 `%LOCALAPPDATA%\dsh_kline`,可用 `DSH_KLINE_CACHE_DIR` 覆盖;`DSH_KLINE_RUNTIME_DIR` 可独立覆盖运行目录。健康响应不会返回服务令牌。
@@ -11,6 +11,7 @@ import json
11
11
  import hmac
12
12
  import os
13
13
  import secrets
14
+ import sys
14
15
  import re
15
16
  from copy import deepcopy
16
17
  import tempfile
@@ -300,7 +301,8 @@ def _http_analyze_kline(args: dict[str, Any]) -> dict[str, Any]:
300
301
  "fetched_count": len(fetched.get("rows") or []),
301
302
  "latest": latest,
302
303
  "metrics": metric_data,
303
- "warnings": ([f"ignored unsupported indicators: {', '.join(unknown_indicators)}"] if unknown_indicators else []),
304
+ "warnings": [*fetched.get("warnings", []), *([f"ignored unsupported indicators: {', '.join(unknown_indicators)}"] if unknown_indicators else [])],
305
+ **{key: fetched[key] for key in ("source_url", "notice", "volume_unit", "volume_adjustment", "price_adjustment", "timestamp_convention", "history_complete", "history_start", "history_end", "coverage_reason", "source_symbol", "requested_count") if key in fetched},
304
306
  }
305
307
  )
306
308
  return payload
@@ -424,7 +426,9 @@ class ChartRequestHandler(BaseHTTPRequestHandler):
424
426
  def do_GET(self) -> None: # noqa: N802
425
427
  path = unquote(urlparse(self.path).path)
426
428
  if path == "/healthz":
427
- self._send_json({"ok": True, "service": "dsh_kline_chart", "version": SERVER_VERSION})
429
+ self._send_json({"ok": True, "service": "dsh_kline_chart", "version": SERVER_VERSION,
430
+ "process_id": os.getpid(), "host_process_id": HOST_PROCESS_ID,
431
+ "instance_id": self.server.instance_id})
428
432
  return
429
433
  if not self._authorized():
430
434
  self._send_json({"ok": False, "error": "unauthorized"}, status=HTTPStatus.UNAUTHORIZED)
@@ -503,6 +507,7 @@ class ChartHTTPServer(ThreadingHTTPServer):
503
507
  def __init__(self, address: tuple[str, int], store: ChartSessionStore, auth_token: str) -> None:
504
508
  self.session_store = store
505
509
  self.auth_token = auth_token
510
+ self.instance_id = secrets.token_hex(16)
506
511
  super().__init__(address, ChartRequestHandler)
507
512
 
508
513
 
@@ -519,11 +524,11 @@ class ChartService:
519
524
  def publish(self, payload: dict[str, Any]) -> tuple[str, str]:
520
525
  token = self.store.create(payload)
521
526
  service_url = f"http://{self.host}:{self.port}"
522
- _write_runtime_session(token, service_url, self.auth_token, payload)
527
+ _write_runtime_session(token, service_url, self.auth_token, payload, self.httpd.instance_id)
523
528
  return token, service_url
524
529
 
525
530
 
526
- def _write_runtime_session(token: str, service_url: str, service_token: str, payload: dict[str, Any]) -> None:
531
+ def _write_runtime_session(token: str, service_url: str, service_token: str, payload: dict[str, Any], instance_id: str) -> None:
527
532
  RUNTIME_DIR.mkdir(mode=0o700, parents=True, exist_ok=True)
528
533
  document = {
529
534
  "ok": True,
@@ -532,6 +537,7 @@ def _write_runtime_session(token: str, service_url: str, service_token: str, pay
532
537
  "session": token,
533
538
  "service_url": service_url,
534
539
  "service_token": service_token,
540
+ "instance_id": instance_id,
535
541
  "symbol": str(payload.get("symbol") or ""),
536
542
  "name": str(payload.get("name") or ""),
537
543
  "published_at": int(time.time()),
@@ -629,12 +635,52 @@ def read_chart_snapshot(token: str) -> dict[str, Any] | None:
629
635
  return None
630
636
 
631
637
 
632
- def start_chart_service() -> None:
633
- """Refresh only the service locator after restart; no chart is selected."""
638
+ _registration_thread: threading.Thread | None = None
639
+ _registration_lock = threading.Lock()
640
+
641
+
642
+ def _register_chart_service() -> None:
634
643
  service = ensure_chart_service()
635
644
  _atomic_runtime_json(RUNTIME_SESSION_FILE, {
636
645
  "ok": True, "session": "", "process_id": os.getpid(),
637
646
  "host_process_id": HOST_PROCESS_ID,
638
647
  "service_url": f"http://{service.host}:{service.port}",
639
648
  "service_token": service.auth_token, "published_at": int(time.time()),
649
+ "instance_id": service.httpd.instance_id,
640
650
  })
651
+
652
+
653
+ def _registration_error(exc: OSError | ValueError) -> None:
654
+ # Protocol stdout belongs exclusively to MCP. The Node owner persists stderr.
655
+ code = getattr(exc, "errno", None)
656
+ print(f"[dsh_kline] chart_service_registration_failed errno={code} "
657
+ f"locator={RUNTIME_SESSION_FILE}: {exc}", file=sys.stderr, flush=True)
658
+
659
+
660
+ def _retry_registration() -> None:
661
+ delay = 0.25
662
+ while True:
663
+ time.sleep(delay)
664
+ try:
665
+ _register_chart_service()
666
+ print("[dsh_kline] chart_service_registration_recovered", file=sys.stderr, flush=True)
667
+ return
668
+ except (OSError, ValueError):
669
+ # Keep MCP tools available while a temporary runtime/port failure
670
+ # clears. Chart publication still reports its own write failures.
671
+ delay = min(5.0, delay * 2)
672
+
673
+
674
+ def start_chart_service() -> bool:
675
+ """Register eagerly; retain MCP and retry when chart startup is degraded."""
676
+ global _registration_thread
677
+ try:
678
+ _register_chart_service()
679
+ return True
680
+ except (OSError, ValueError) as exc:
681
+ _registration_error(exc)
682
+ with _registration_lock:
683
+ if _registration_thread is None or not _registration_thread.is_alive():
684
+ _registration_thread = threading.Thread(target=_retry_registration, name="dsh-kline-registration", daemon=True)
685
+ _registration_thread.start()
686
+ return False
@@ -1,7 +1,7 @@
1
1
  {
2
- "version": "2026-09-07",
2
+ "version": "2026-11-05",
3
3
  "source": "https://qt.gtimg.cn/",
4
- "description": "安装自带的常用证券目录;名称与代码于版本日期核对,不代表全市场覆盖或行情权限。",
4
+ "description": "安装自带的常用证券名称、代码与别名;仅为搜索目录,不代表行情权限或全市场覆盖。",
5
5
  "items": [
6
6
  {
7
7
  "symbol": "601398.XSHG",
@@ -161,7 +161,8 @@
161
161
  {
162
162
  "symbol": "03690.HK",
163
163
  "name": "美团-W",
164
- "market": "HK"
164
+ "market": "HK",
165
+ "aliases": "美团 Meituan"
165
166
  },
166
167
  {
167
168
  "symbol": "01810.HK",
@@ -176,7 +177,8 @@
176
177
  {
177
178
  "symbol": "01211.HK",
178
179
  "name": "比亚迪股份",
179
- "market": "HK"
180
+ "market": "HK",
181
+ "aliases": "比亚迪 BYD 港股"
180
182
  },
181
183
  {
182
184
  "symbol": "00939.HK",
@@ -196,17 +198,20 @@
196
198
  {
197
199
  "symbol": "09618.HK",
198
200
  "name": "京东集团-SW",
199
- "market": "HK"
201
+ "market": "HK",
202
+ "aliases": "京东 JD"
200
203
  },
201
204
  {
202
205
  "symbol": "09888.HK",
203
206
  "name": "百度集团-W",
204
- "market": "HK"
207
+ "market": "HK",
208
+ "aliases": "百度 Baidu"
205
209
  },
206
210
  {
207
211
  "symbol": "09999.HK",
208
212
  "name": "网易",
209
- "market": "HK"
213
+ "market": "HK",
214
+ "aliases": "网易 NetEase"
210
215
  },
211
216
  {
212
217
  "symbol": "512400.XSHG",
@@ -387,6 +392,179 @@
387
392
  "symbol": "563300.XSHG",
388
393
  "name": "中证2000ETF华泰柏瑞",
389
394
  "market": "ETF"
395
+ },
396
+ {
397
+ "symbol": "TSLA.US",
398
+ "name": "Tesla, Inc. - Common Stock",
399
+ "market": "US",
400
+ "aliases": "特斯拉 Tesla"
401
+ },
402
+ {
403
+ "symbol": "META.US",
404
+ "name": "Meta Platforms, Inc. - Class A Common Stock",
405
+ "market": "US",
406
+ "aliases": "Meta 脸书 Facebook"
407
+ },
408
+ {
409
+ "symbol": "AMZN.US",
410
+ "name": "Amazon.com, Inc. - Common Stock",
411
+ "market": "US",
412
+ "aliases": "亚马逊 Amazon"
413
+ },
414
+ {
415
+ "symbol": "GOOGL.US",
416
+ "name": "Alphabet Inc. - Class A Common Stock",
417
+ "market": "US",
418
+ "aliases": "谷歌 Alphabet Google A类"
419
+ },
420
+ {
421
+ "symbol": "GOOG.US",
422
+ "name": "Alphabet Inc. - Class C Capital Stock",
423
+ "market": "US",
424
+ "aliases": "谷歌 Alphabet Google C类"
425
+ },
426
+ {
427
+ "symbol": "NFLX.US",
428
+ "name": "Netflix, Inc. - Common Stock",
429
+ "market": "US",
430
+ "aliases": "奈飞 网飞 Netflix"
431
+ },
432
+ {
433
+ "symbol": "AVGO.US",
434
+ "name": "Broadcom Inc. - Common Stock",
435
+ "market": "US",
436
+ "aliases": "博通 Broadcom"
437
+ },
438
+ {
439
+ "symbol": "TSM.US",
440
+ "name": "Taiwan Semiconductor Manufacturing Company Ltd.",
441
+ "market": "US",
442
+ "aliases": "台积电 TSMC"
443
+ },
444
+ {
445
+ "symbol": "BABA.US",
446
+ "name": "Alibaba Group Holding Limited American Depositary Shares each representing eight Ordinary share",
447
+ "market": "US",
448
+ "aliases": "阿里巴巴 Alibaba 美股"
449
+ },
450
+ {
451
+ "symbol": "JPM.US",
452
+ "name": "JP Morgan Chase & Co. Common Stock",
453
+ "market": "US",
454
+ "aliases": "摩根大通 JPMorgan"
455
+ },
456
+ {
457
+ "symbol": "V.US",
458
+ "name": "Visa Inc.",
459
+ "market": "US",
460
+ "aliases": "维萨 Visa"
461
+ },
462
+ {
463
+ "symbol": "MA.US",
464
+ "name": "Mastercard Incorporated Common Stock",
465
+ "market": "US",
466
+ "aliases": "万事达 Mastercard"
467
+ },
468
+ {
469
+ "symbol": "BRK.B.US",
470
+ "name": "Berkshire Hathaway Inc. New Common Stock",
471
+ "market": "US",
472
+ "aliases": "伯克希尔 Berkshire B类"
473
+ },
474
+ {
475
+ "symbol": "KO.US",
476
+ "name": "Coca-Cola Company (The) Common Stock",
477
+ "market": "US",
478
+ "aliases": "可口可乐 Coca Cola"
479
+ },
480
+ {
481
+ "symbol": "WMT.US",
482
+ "name": "Walmart Inc. - Common Stock",
483
+ "market": "US",
484
+ "aliases": "沃尔玛 Walmart"
485
+ },
486
+ {
487
+ "symbol": "DIS.US",
488
+ "name": "Walt Disney Company (The) Common Stock",
489
+ "market": "US",
490
+ "aliases": "迪士尼 Disney"
491
+ },
492
+ {
493
+ "symbol": "NKE.US",
494
+ "name": "Nike, Inc. Common Stock",
495
+ "market": "US",
496
+ "aliases": "耐克 Nike"
497
+ },
498
+ {
499
+ "symbol": "INTC.US",
500
+ "name": "Intel Corporation - Common Stock",
501
+ "market": "US",
502
+ "aliases": "英特尔 Intel"
503
+ },
504
+ {
505
+ "symbol": "PLTR.US",
506
+ "name": "Palantir Technologies Inc. - Class A Common Stock",
507
+ "market": "US",
508
+ "aliases": "Palantir 帕兰提尔"
509
+ },
510
+ {
511
+ "symbol": "COIN.US",
512
+ "name": "Coinbase Global, Inc. - Class A Common Stock",
513
+ "market": "US",
514
+ "aliases": "Coinbase 加密交易所"
515
+ },
516
+ {
517
+ "symbol": "00388.HK",
518
+ "name": "HKEX",
519
+ "market": "HK",
520
+ "aliases": "港交所 香港交易所 HKEX"
521
+ },
522
+ {
523
+ "symbol": "00005.HK",
524
+ "name": "HSBC HOLDINGS",
525
+ "market": "HK",
526
+ "aliases": "汇丰 汇丰控股 HSBC"
527
+ },
528
+ {
529
+ "symbol": "00941.HK",
530
+ "name": "CHINA MOBILE",
531
+ "market": "HK",
532
+ "aliases": "中国移动 China Mobile"
533
+ },
534
+ {
535
+ "symbol": "01024.HK",
536
+ "name": "KUAISHOU-W",
537
+ "market": "HK",
538
+ "aliases": "快手 Kuaishou"
539
+ },
540
+ {
541
+ "symbol": "09961.HK",
542
+ "name": "TRIP.COM-S",
543
+ "market": "HK",
544
+ "aliases": "携程 Trip.com"
545
+ },
546
+ {
547
+ "symbol": "02015.HK",
548
+ "name": "LI AUTO-W",
549
+ "market": "HK",
550
+ "aliases": "理想汽车 Li Auto"
551
+ },
552
+ {
553
+ "symbol": "09868.HK",
554
+ "name": "XPENG-W",
555
+ "market": "HK",
556
+ "aliases": "小鹏汽车 XPeng"
557
+ },
558
+ {
559
+ "symbol": "02020.HK",
560
+ "name": "ANTA SPORTS",
561
+ "market": "HK",
562
+ "aliases": "安踏体育 Anta"
390
563
  }
564
+ ],
565
+ "sources": [
566
+ "https://qt.gtimg.cn/",
567
+ "https://www.nasdaqtrader.com/trader.aspx?id=symboldirdefs",
568
+ "https://www.hkex.com.hk/eng/services/trading/securities/securitieslists/ListOfSecurities.xlsx"
391
569
  ]
392
570
  }