Skip to content

feat: 市场搜索 + 品种 chip 拉取错误展示 (#105) - #110

Merged
363045841 merged 17 commits into
mainfrom
feat/issue-105-market-search
Jul 31, 2026
Merged

feat: 市场搜索 + 品种 chip 拉取错误展示 (#105)#110
363045841 merged 17 commits into
mainfrom
feat/issue-105-market-search

Conversation

@363045841

@363045841 363045841 commented Jul 28, 2026

Copy link
Copy Markdown
Owner

摘要

推进 #105 的 market/session 半程,并在 Vue 品种 chip 上展示主品种 K 线拉取失败原因。

  • Market sessionsSymbolSpec.market 必填;每个 Chart 持有独立的 MarketSessionRegistry(内置 CN / HK / US);Vue / React / Angular 可按实例覆盖。
  • gotdx 搜索:私有 source 参数归一为统一 market;混合批次保留可支持项、跳过不支持项(如 FUND);整批均无法归一化时仍报错。
  • gotdx 路由params.category → ex API,params.market → stock API(不按代码 / exchange 猜测)。
  • 港股分时/api/ex/history-tick{ preClose, data };约 330 槽,时间轴末端 16:00。
  • 空 K 线:成功返回 [] 仅 warning;DataBuffer.lastError = 暂无K线数据;chip 显示图标 + 文案(无圆角外层 tag)。
  • 显式失败:网络 / HTTP / 超时等仍通过 dataError 透出原始 message。

关联后端

Issue

关联:#105

测试计划

自动化(本地已跑)

  • Core 包测试(gotdx 归一化、market registry、dataBuffer 空数据/错误、chart market 校验)
  • Vue SymbolSelector.errorTitle 测试
  • 包构建(core / vue / react / angular)
  • 根目录 pnpm type-check — 已知 vue-tsc / TS 崩溃(与本 PR 无关)
  • 根目录 pnpm test:unit — 根配置排除 packages/**(请用包内测试)

E2E 任务 — gotdx Fetcher 矩阵(issue #105

环境:Vite pnpm dev + Go tdx-api(:8080)。搜索仅针对已启用的 gotdx 源。每行:搜索 → 选中 → 日 K →(可选)分时

1. gotdx 指数

  • 搜索已知 A 股指数(如 000001 上证指数 / 399001 深证成指)
  • 结果保留 source=gotdxmarket=CN,以及后端返回的 params.market + 指数 kind
  • 选中后加载非空日 K(走 stock/index 路径,chip 无错误)
  • 分时周期可加载(stock history-tick 路径)
  • 左右拖动历史加载后不塌成空图

2. gotdx 个股

  • 搜索流动性较好的 A 股(如 600519 / 000001 平安银行 — 注意与同代码指数区分)
  • market=CNparams.market 属于 {0,1,2}
  • 日 K + 成交量正常绘制;chip 错误
  • 分时:{ preClose, data } 形态正确;preClose > 0
  • 品种 A→B 切换后旧序列清空 / identity 缓存不串台

3. gotdx ETF、基金、REITS

  • 搜索 ETF(如 510300 / 159915 / 已知空数据 158017
  • 搜索基金 / REITS 关键词或扩展目录代码
  • 逐条记录实际行为
    • 能出现在搜索结果且 market 已归一化,作为不支持项被过滤
    • 若可被选中:K 线非空, chip 显示 暂无K线数据(不是笼统「加载失败」)
    • 同批混合 HK + FUND 时仍返回 HK 行(不整批「搜索失败」)
  • 失败时待补齐:将 exchange=FUND(及 ETF/REITS kind)映射到统一 market,并走对 stock vs ex 路由

4. gotdx 港股

  • 搜索港股代码/名称(如 00700 腾讯)
  • market=HKparams.category + params.kind=ex
  • 日 K 走 ex kline-by-date(不走 stock market 路由)
  • 分时走 ex history-tick;时间轴末端 16:00;日盘约 330 槽
  • 成功时 chip 干净;失败时显示真实 HTTP/message 文案

5. gotdx 新三板

  • 从 gotdx 目录搜索新三板 / BSE 代码
  • params.market 属于 {0,1,2} 时预期 market=CN(当前与主板 stock 同路径)
  • 选中后加载 K 线,给出明确空数据/错误文案(禁止静默空白图)
  • 分时跟随 params.market 的 stock history-tick
  • 若存在与其他板块同数字代码,确认 identity/cache 隔离

UI 冒烟(chip / 搜索)

  • 品种 chip:警告图标 + 错误文案水平对齐;无圆角外层 tag
  • 成功空数组 [] → chip 文案 暂无K线数据
  • Effect 硬失败 → 原始 message(message 为空时才用稳定兜底)
  • 聚合源 Tag:仅请求已启用源(若本分支已有 UI,在 E2E 中一并验证)

手工对照表

类别 示例代码 预期路由 已知风险
指数 000001, 399001 stock + kind 与同代码个股混淆
个股 600519, 000001 stock market
ETF/基金/REITS 510300, 158017 待定 / 常为空 FUND 未归一化
港股 00700 ex category 依赖 Go history-tick
新三板 (搜索结果) stock market 0/1/2 数据可得性

范围外 / 后续

  • ETF/基金/REITS 完整统一 market 映射(仍未完成;如 158017 空数据)
  • 聚合源管理 UI 的 localStorage 默认策略(issue UI §1)若本分支未完全覆盖,E2E 确认后开 follow-up

主要提交

  • fcdbcaf market-aware symbol sessions / gotdx 归一化
  • c50aecd 空 K 线仅 warning
  • 7327e06ae4098b chip 拉取错误 + 暂无K线数据

363045841 added 10 commits July 28, 2026 11:00
品种选择器不再内置默认品种列表,完全依赖 controller 的
symbolCatalog 信号从注册数据源获取,消除客户端硬编码兜底。
Default single-arg Effect.tryPromise wraps rejections in UnknownException,
swallowing the original error message. Switch to { try, catch } overload
to preserve Error/KLineChartError instances as-is.

Add regression test verifying fetcher error messages appear in logs.
Require normalized market identity across symbols, search results, caches, and semantic config. Add per-chart session registries and route gotdx Hong Kong time-share data without allowing unsupported search rows to poison valid results.

Refs #105
Empty data (e.g. ETF without gotdx history) is a valid server response. Downgrade from Effect.fail to logWarning so the chart renders empty instead of rejecting the fetch.
Specify buffer-owned lastError signal and native chip title for explicit K-line Effect failures.
Record DataBuffer lastError on explicit Effect failures, expose chart dataError, and use it as the SymbolSelector native title while the warning icon is shown.
Place the warning icon and failure reason inside a pill-shaped tag on the symbol chip, with ellipsis and native title for overflow.
Use fallback 加载失败 when dataError is empty, and keep the error pill from collapsing to icon-only under chip flex constraints.
Successful empty fetch results now set DataBuffer lastError so the symbol chip shows 暂无K线数据 instead of the generic 加载失败 fallback.
@363045841 363045841 changed the title feat: market-aware search sessions + symbol chip fetch error (#105) feat: 市场感知搜索会话 + 品种 chip 拉取错误展示 (#105) Jul 28, 2026
Pure fund queries (e.g. 国泰中) returned only exchange=FUND rows.
normalizeGotdxMarket rejected them all, so search threw and the UI
showed 搜索失败 despite a successful API response.

Map mainland fund/money extended exchanges to CN; keep futures and
other unsupported exchanges rejected.
Search no longer fails when gotdx returns exchanges without a market
session (e.g. EX-0, FUTURES). Rows are listed with empty market; chart
selection surfaces 暂不支持该品种 instead of blank 搜索失败.
Propagate backend error body from history-tick HTTP failures and
record TimeShareBuffer.lastError so chips can show messages like
「该日期暂无历史分时数据」; clear on successful reload.
Timeshare legend omitted volume and used bare short numbers; price/avg
strokes were 2/1.5 vs 1px indicator convention after DPR scale.

- Append 手 to timeshare volumeText; render it in preview legend
- Draw price and average lines at 1px logical width
- Cover both with unit tests
@363045841 363045841 changed the title feat: 市场感知搜索会话 + 品种 chip 拉取错误展示 (#105) feat: 市场搜索 + 品种 chip 拉取错误展示 (#105) Jul 29, 2026
…ng metrics

- TimeShareData.volume / amount改为可选字段
- gotdx适配器仅映射后端返回的Volume/Amount, 不再用 Price*Vol伪造成交额
- 分时渲染器仅在有 volume时保留25%量柱区域, 否则价格区占满pane
- Canvas图例仅在字段非空时绘制成交量/成交额标签
- 新增个股/指数/amount-only分时的回归测试

Closes the data-synthesis issue: upstream-不可确认的指标不再伪造为0或NaN展示.
@363045841

Copy link
Copy Markdown
Owner Author

新增提交(自 PR 描述后补充)

分时成交量和成交额去伪(#105 数据完整性)

核心改动17841e1):

  • TimeShareData.volume / amount 改为可选字段,上游不可确认时不伪造 0
  • gotdx 适配器仅映射后端 Volume(手)和 Amount(元),删除 Price * Vol 伪造成交额
  • 分时渲染器仅在存在 volume 时保留 25% 量柱区;指数/港股等纯金额数据价格区占满 pane
  • Canvas 图例仅在字段非空时绘制成交量/成交额标签

配套修复

  • cff74f2 分时量柱显示手数、细化渲染线宽
  • 19b6e07 gotdx history-tick API 错误透出到分时
  • 29ef1d8 gotdx 搜索对无法归一化的品种(FUND/部分 ETF)在结果中标记、选择时拒绝
  • 080972c FUND 搜索结果映射到 CN market
  • de086e0 Effect.tryPromise 保留原始错误文案
  • af569b1 删除硬编码 DEFAULT_SYMBOLS 回退数据(空数据状态不再被静默覆盖)

Align AGENTS.md comment style rules with project convention:
Chinese body, English technical terms, file header comments,
function docs, and inline comments.
@363045841
363045841 merged commit 03adf8b into main Jul 31, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant