@gloom-sh/terminal 0.19.6 → 0.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/LICENSE +0 -4
  2. package/package.json +6 -5
  3. package/patches/electrobun-devkit@2.0.5.patch +408 -0
  4. package/src/api-client/bond-trades.ts +59 -0
  5. package/src/api-client/crypto-markets.ts +20 -2
  6. package/src/api-client/data.ts +21 -0
  7. package/src/api-client/fund-facts.ts +23 -1
  8. package/src/api-client/index.ts +2 -0
  9. package/src/api-client/types/account.ts +86 -0
  10. package/src/api-client/types/assist.ts +32 -0
  11. package/src/api-client/types/auth.ts +63 -0
  12. package/src/api-client/types/billing.ts +54 -0
  13. package/src/api-client/types/chat.ts +180 -0
  14. package/src/api-client/types/congress.ts +107 -0
  15. package/src/api-client/types/credit.ts +110 -0
  16. package/src/api-client/types/econ.ts +158 -0
  17. package/src/api-client/types/equity-diagnostic.ts +73 -0
  18. package/src/api-client/types/filings-and-calls.ts +356 -0
  19. package/src/api-client/types/index.ts +25 -0
  20. package/src/api-client/types/jobs.ts +147 -0
  21. package/src/api-client/types/market.ts +122 -0
  22. package/src/api-client/types/news.ts +91 -0
  23. package/src/api-client/types/notes-and-theses.ts +172 -0
  24. package/src/api-client/types/quotes.ts +28 -0
  25. package/src/api-client/types/scanners.ts +125 -0
  26. package/src/api-client/types/screener.ts +65 -0
  27. package/src/api-client/types/search.ts +107 -0
  28. package/src/api-client/types/sync.ts +14 -0
  29. package/src/api-client/types/team-collections.ts +43 -0
  30. package/src/api-client/types/team-views.ts +32 -0
  31. package/src/api-client/types/teams.ts +135 -0
  32. package/src/api-client/types/ticker-data.ts +57 -0
  33. package/src/api-client/types/tweets.ts +59 -0
  34. package/src/api-client/types/world-venues.ts +23 -0
  35. package/src/app/runtime/desktop-deeplink.ts +41 -6
  36. package/src/app/runtime/plugin-seed.ts +119 -0
  37. package/src/app/runtime/startup.ts +45 -9
  38. package/src/app/star-prompt/status-line.tsx +1 -1
  39. package/src/app.tsx +2 -7
  40. package/src/architecture/ui-tokens-allowlist.json +0 -8
  41. package/src/cli/board-coins.ts +38 -5
  42. package/src/cli/commands/crypto-hints.ts +8 -1
  43. package/src/cli/commands/market.ts +29 -26
  44. package/src/cli/commands/overview.ts +13 -6
  45. package/src/cli/commands/ticker.ts +78 -18
  46. package/src/cli/company-name-hint.ts +19 -0
  47. package/src/cli/desktop-pane-shot-browser.ts +69 -3
  48. package/src/cli/entry.ts +10 -4
  49. package/src/cli/glossary.ts +25 -0
  50. package/src/cli/helpers.ts +4 -2
  51. package/src/cli/not-a-ticker.ts +26 -1
  52. package/src/cli/pane-functions/catalog.ts +3 -1
  53. package/src/cli/pane-functions/freshness.ts +45 -29
  54. package/src/cli/pane-functions/market-session.ts +14 -5
  55. package/src/cli/restore-plugins.ts +164 -51
  56. package/src/components/chart/composite/use-composite-chart-keyboard.ts +11 -2
  57. package/src/components/chart-table/header.tsx +10 -1
  58. package/src/components/chart-table/layout.ts +14 -5
  59. package/src/components/command-bar/panel/index.tsx +13 -0
  60. package/src/components/command-bar/panel/layout.ts +7 -0
  61. package/src/components/command-bar/panel/runtime.ts +1 -0
  62. package/src/components/command-bar/panel/types.ts +2 -0
  63. package/src/components/data-table/export.ts +4 -1
  64. package/src/components/layout/detached-pane-shell.tsx +10 -37
  65. package/src/components/layout/double-escape-close.ts +90 -0
  66. package/src/components/layout/header.tsx +3 -2
  67. package/src/components/layout/market-summary.ts +6 -3
  68. package/src/components/layout/pane/footer/index.tsx +2 -6
  69. package/src/components/layout/pane/footer/model.ts +6 -12
  70. package/src/components/layout/shell/active-drag.ts +53 -11
  71. package/src/components/layout/shell/drag/magnets.ts +128 -19
  72. package/src/components/layout/shell/pane/actions.ts +6 -2
  73. package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
  74. package/src/components/layout/status-bar.tsx +4 -78
  75. package/src/components/layout/status-widget-space.ts +5 -5
  76. package/src/components/onboarding/portfolio-step/positions-panel.tsx +1 -1
  77. package/src/components/ui/data-table/index.tsx +5 -1
  78. package/src/components/ui/data-table/render-cell.ts +19 -0
  79. package/src/components/ui/delayed-mark.tsx +59 -7
  80. package/src/components/ui/icon.tsx +1 -8
  81. package/src/components/ui/menu.tsx +6 -1
  82. package/src/i18n/es.ts +6 -3
  83. package/src/i18n/ja.ts +6 -3
  84. package/src/i18n/ko.ts +6 -3
  85. package/src/i18n/zh-cn.ts +6 -3
  86. package/src/i18n/zh-tw.ts +6 -3
  87. package/src/market-data/fund-facts.ts +7 -1
  88. package/src/market-data/market/change-basis.ts +20 -0
  89. package/src/market-data/market/format.ts +62 -2
  90. package/src/market-data/market/futures-week.ts +3 -1
  91. package/src/plugins/builtin/chart-composer/headless.ts +57 -17
  92. package/src/plugins/builtin/chart-composer/session-range.ts +82 -3
  93. package/src/plugins/builtin/chat/content/composer.tsx +21 -27
  94. package/src/plugins/builtin/chat/content/index.tsx +31 -3
  95. package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
  96. package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
  97. package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
  98. package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
  99. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +32 -25
  100. package/src/plugins/builtin/congress-trades/model.ts +2 -1
  101. package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
  102. package/src/plugins/builtin/correlation/compute.ts +8 -2
  103. package/src/plugins/builtin/correlation/headless.ts +10 -9
  104. package/src/plugins/builtin/correlation/history.ts +30 -0
  105. package/src/plugins/builtin/correlation/matrix/model.ts +10 -10
  106. package/src/plugins/builtin/correlation/relationship/model.ts +3 -6
  107. package/src/plugins/builtin/correlation/relationship/pane.tsx +1 -2
  108. package/src/plugins/builtin/crypto-board/client.ts +6 -1
  109. package/src/plugins/builtin/crypto-board/defi-view.tsx +12 -1
  110. package/src/plugins/builtin/crypto-board/defi.ts +44 -7
  111. package/src/plugins/builtin/crypto-board/headless.ts +83 -12
  112. package/src/plugins/builtin/crypto-board/model.ts +30 -6
  113. package/src/plugins/builtin/crypto-board/pane.tsx +13 -2
  114. package/src/plugins/builtin/custom-view/index.tsx +1 -1
  115. package/src/plugins/builtin/custom-view/loader.ts +85 -8
  116. package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
  117. package/src/plugins/builtin/equity-screener/criterion-editor.tsx +13 -4
  118. package/src/plugins/builtin/equity-screener/headless.ts +33 -1
  119. package/src/plugins/builtin/equity-screener/model.ts +58 -15
  120. package/src/plugins/builtin/equity-screener/pane.tsx +36 -6
  121. package/src/plugins/builtin/executives/format.ts +5 -4
  122. package/src/plugins/builtin/executives/pane.tsx +1 -1
  123. package/src/plugins/builtin/help/index.tsx +55 -1
  124. package/src/plugins/builtin/insider/model.ts +30 -2
  125. package/src/plugins/builtin/jobs/model.ts +2 -2
  126. package/src/plugins/builtin/mna/model.ts +2 -2
  127. package/src/plugins/builtin/notes/files.ts +2 -0
  128. package/src/plugins/builtin/notes/owner.tsx +20 -1
  129. package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
  130. package/src/plugins/builtin/notes/store.ts +6 -1
  131. package/src/plugins/builtin/perps/headless.ts +8 -2
  132. package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
  133. package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
  134. package/src/plugins/builtin/risk-factors/index.tsx +2 -28
  135. package/src/plugins/builtin/risk-factors/lock-note.ts +58 -0
  136. package/src/plugins/builtin/risk-factors/pane.tsx +10 -3
  137. package/src/plugins/builtin/scanner/hilo-model.ts +4 -3
  138. package/src/plugins/builtin/sec/fund-facts.ts +45 -11
  139. package/src/plugins/builtin/sec/headless.ts +30 -1
  140. package/src/plugins/builtin/sec/index.tsx +26 -5
  141. package/src/plugins/builtin/series-inventory.ts +1 -0
  142. package/src/plugins/builtin/shared/earnings-report.ts +7 -2
  143. package/src/plugins/builtin/shared/pro-lock-note.ts +5 -1
  144. package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
  145. package/src/plugins/builtin/short-interest/headless.ts +1 -1
  146. package/src/plugins/builtin/short-interest/model.ts +15 -6
  147. package/src/plugins/builtin/short-interest/types.ts +2 -0
  148. package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
  149. package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
  150. package/src/plugins/builtin/ticker-detail/overview/model.ts +19 -9
  151. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
  152. package/src/plugins/builtin/time-sales/headless.ts +23 -7
  153. package/src/plugins/builtin/time-sales/index.tsx +2 -2
  154. package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
  155. package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
  156. package/src/plugins/builtin/trace-bonds/history.ts +155 -0
  157. package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
  158. package/src/plugins/extracted-plugins.ts +49 -24
  159. package/src/plugins/installer.ts +234 -32
  160. package/src/plugins/plugin-names.ts +11 -2
  161. package/src/plugins/running-installs.ts +34 -0
  162. package/src/plugins/seed-progress.ts +72 -0
  163. package/src/remote/controller.ts +9 -2
  164. package/src/remote/schema.ts +2 -1
  165. package/src/renderers/cloudflare/http-proxy.ts +67 -8
  166. package/src/renderers/cloudflare/proxy-session.ts +1 -1
  167. package/src/renderers/cloudflare/worker.ts +29 -2
  168. package/src/renderers/dom/desktop/icons.tsx +0 -2
  169. package/src/renderers/dom/styles.css +0 -3
  170. package/src/renderers/electrobun/bun/desktop/backend.ts +14 -0
  171. package/src/renderers/electrobun/bun/desktop/host-requests.ts +14 -7
  172. package/src/renderers/electrobun/bun/desktop/initialization.ts +24 -14
  173. package/src/renderers/electrobun/bun/desktop/install-records.ts +59 -0
  174. package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
  175. package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
  176. package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
  177. package/src/renderers/electrobun/bun/index.ts +24 -13
  178. package/src/renderers/electrobun/bun/window/context-menu-thread.ts +84 -0
  179. package/src/renderers/electrobun/bun/window/create.ts +23 -3
  180. package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +4 -4
  181. package/src/renderers/electrobun/bun/window/events.ts +4 -4
  182. package/src/renderers/electrobun/bun/window/frame.ts +2 -1
  183. package/src/renderers/electrobun/bun/window/native-call-thread.ts +224 -0
  184. package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
  185. package/src/renderers/electrobun/bun/window/native-timing.ts +10 -0
  186. package/src/renderers/electrobun/bun/window/script-for-webview.ts +15 -0
  187. package/src/renderers/electrobun/bun/window/webview-script-thread.ts +82 -0
  188. package/src/renderers/electrobun/shared/protocol.ts +13 -2
  189. package/src/renderers/electrobun/view/backend-rpc.ts +8 -1
  190. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +1 -1
  191. package/src/renderers/electrobun/view/main.tsx +4 -3
  192. package/src/renderers/opentui/start.tsx +3 -0
  193. package/src/sources/gloomberb-cloud/index.ts +5 -7
  194. package/src/sources/provider-router/batches.ts +18 -3
  195. package/src/sources/provider-router/financials.ts +18 -4
  196. package/src/telemetry/stall-reports.ts +21 -4
  197. package/src/types/data-provider.ts +14 -0
  198. package/src/types/financials.ts +15 -3
  199. package/src/types/headless.ts +2 -0
  200. package/src/utils/double-escape-close.ts +38 -16
  201. package/src/utils/format.ts +23 -3
  202. package/src/utils/main-thread-stall.ts +21 -5
  203. package/src/utils/perf-marks.ts +88 -9
  204. package/src/utils/price-earnings.ts +18 -0
  205. package/src/utils/reported-money.ts +9 -2
  206. package/src/utils/sec.ts +34 -3
  207. package/patches/electrobun@1.18.1.patch +0 -633
  208. package/src/api-client/types.ts +0 -2441
  209. package/src/plugins/seed-notice.ts +0 -20
package/src/i18n/ko.ts CHANGED
@@ -284,6 +284,8 @@ export const ko: Record<string, string> = {
284
284
 
285
285
  // ── Context menu ─────────────────────────────────────────────
286
286
  "Start Here": "여기서 시작",
287
+ "About": "정보",
288
+ "What's new in v{version}": "v{version}의 새로운 기능",
287
289
  "Research a company: the overview, then tabs for the chart, financials, news, filings and earnings calls.": "기업 조사: 개요부터 보고 차트, 재무, 뉴스, 공시, 실적 발표 탭으로 이동합니다.",
288
290
  "Add what you own. Alerts and emails then follow your portfolio.": "보유 종목을 추가하세요. 알림과 이메일이 포트폴리오에 맞춰집니다.",
289
291
  "Your portfolio and watchlists.": "포트폴리오와 관심 목록.",
@@ -685,7 +687,7 @@ export const ko: Record<string, string> = {
685
687
  "{delay} delayed · try Pro live": "{delay} 지연 · Pro 실시간 사용해 보기",
686
688
  "Pro trial {days}d": "Pro 체험 {days}일",
687
689
  "Pro trial — ends {date}": "Pro 체험 — {date} 종료",
688
- "delayed data · upgrade": "지연 데이터 · 업그레이드",
690
+ "delayed": "지연",
689
691
  "upgrade": "업그레이드",
690
692
  "real-time news": "실시간 뉴스",
691
693
  "AI command bar": "AI 명령 바",
@@ -850,7 +852,6 @@ export const ko: Record<string, string> = {
850
852
  "Start group chat": "그룹 채팅 시작",
851
853
  "Use @username, or multiple usernames for a group chat": "그룹 채팅에는 @username 또는 여러 사용자 이름을 사용하세요",
852
854
  "Type DM @username to start one": "DM @username을 입력하여 시작하세요",
853
- "Read-only chat. Log in or sign up to send.": "읽기 전용 채팅. 보내려면 로그인하거나 회원가입하세요.",
854
855
  "Saved login found. Log in again to send.": "저장된 로그인을 찾았습니다. 보내려면 다시 로그인하세요.",
855
856
  "Verify your email to send messages.": "메시지를 보내려면 이메일을 인증하세요.",
856
857
  // The first-chat prompt for an account still on its signup handle.
@@ -874,7 +875,6 @@ export const ko: Record<string, string> = {
874
875
  "ask questions about anything on screen": "화면에 보이는 모든 내용에 대해 질문",
875
876
  "Free with a verified Gloom account.": "인증된 Gloom 계정이 있으면 무료입니다.",
876
877
  "search X": "X를 검색",
877
- "{shortcut}, then Resend Verification Email": "{shortcut} 후 인증 이메일 재전송",
878
878
  "editing": "편집 중",
879
879
  "replying to": "답장 대상",
880
880
  "Reply": "답장",
@@ -1144,6 +1144,9 @@ export const ko: Record<string, string> = {
1144
1144
  "No figures for {symbol}: its sponsor's site is not one Gloom reads, and the SEC's prospectus and N-PORT data sets list none for it yet.": "{symbol}의 수치가 없습니다. Gloom은 스폰서의 사이트를 읽지 않으며, SEC의 투자설명서 및 N-PORT 데이터 세트에도 아직 없습니다.",
1145
1145
  "est. {range}": "추정 {range}",
1146
1146
  "Shares outstanding": "발행 주식 수",
1147
+ "Management fee": "운용 보수",
1148
+ "Mgmt Fee": "운용 보수",
1149
+ "Units per {asset}": "{asset}당 좌수",
1147
1150
  "1M flows": "1개월 자금 유출입",
1148
1151
  "Structure": "구조",
1149
1152
  "Closed-end fund": "폐쇄형 펀드",
package/src/i18n/zh-cn.ts CHANGED
@@ -286,6 +286,8 @@ export const zhCN: Record<string, string> = {
286
286
 
287
287
  // ── Context menu ─────────────────────────────────────────────
288
288
  "Start Here": "从这里开始",
289
+ "About": "关于",
290
+ "What's new in v{version}": "v{version} 新功能",
289
291
  "Research a company: the overview, then tabs for the chart, financials, news, filings and earnings calls.": "研究一家公司:先看概览,再切换到图表、财务、新闻、文件和财报电话会议标签。",
290
292
  "Add what you own. Alerts and emails then follow your portfolio.": "添加你的持仓。之后提醒和邮件都会围绕你的投资组合。",
291
293
  "Your portfolio and watchlists.": "你的投资组合和自选列表。",
@@ -687,7 +689,7 @@ export const zhCN: Record<string, string> = {
687
689
  "{delay} delayed · try Pro live": "延迟 {delay} · 试用 Pro 实时数据",
688
690
  "Pro trial {days}d": "Pro 试用 {days} 天",
689
691
  "Pro trial — ends {date}": "Pro 试用 — {date} 结束",
690
- "delayed data · upgrade": "数据延迟 · 升级",
692
+ "delayed": "延迟",
691
693
  "upgrade": "升级",
692
694
  "real-time news": "实时新闻",
693
695
  "AI command bar": "AI 命令栏",
@@ -852,7 +854,6 @@ export const zhCN: Record<string, string> = {
852
854
  "Start group chat": "开始群聊",
853
855
  "Use @username, or multiple usernames for a group chat": "使用 @用户名,或输入多个用户名开始群聊",
854
856
  "Type DM @username to start one": "输入 DM @用户名开始私信",
855
- "Read-only chat. Log in or sign up to send.": "聊天为只读模式。登录或注册后才能发送消息。",
856
857
  "Saved login found. Log in again to send.": "发现已保存的登录信息。请重新登录后发送消息。",
857
858
  "Verify your email to send messages.": "验证邮箱后才能发送消息。",
858
859
  // The first-chat prompt for an account still on its signup handle.
@@ -876,7 +877,6 @@ export const zhCN: Record<string, string> = {
876
877
  "ask questions about anything on screen": "就屏幕上的任何内容提问",
877
878
  "Free with a verified Gloom account.": "使用已验证的 Gloom 账户即可免费使用。",
878
879
  "search X": "搜索 X",
879
- "{shortcut}, then Resend Verification Email": "按 {shortcut},然后选择“重新发送验证邮件”",
880
880
  "editing": "编辑中",
881
881
  "replying to": "回复",
882
882
  "Reply": "回复",
@@ -1146,6 +1146,9 @@ export const zhCN: Record<string, string> = {
1146
1146
  "No figures for {symbol}: its sponsor's site is not one Gloom reads, and the SEC's prospectus and N-PORT data sets list none for it yet.": "暂无 {symbol} 的数据:Gloom 不读取其发起人的网站,SEC 的招募说明书和 N-PORT 数据集中也尚未列出。",
1147
1147
  "est. {range}": "估计 {range}",
1148
1148
  "Shares outstanding": "流通份额",
1149
+ "Management fee": "管理费",
1150
+ "Mgmt Fee": "管理费",
1151
+ "Units per {asset}": "每 {asset} 份额",
1149
1152
  "1M flows": "1个月资金流",
1150
1153
  "Structure": "结构",
1151
1154
  "Closed-end fund": "封闭式基金",
package/src/i18n/zh-tw.ts CHANGED
@@ -286,6 +286,8 @@ export const zhTW: Record<string, string> = {
286
286
 
287
287
  // ── Context menu ─────────────────────────────────────────────
288
288
  "Start Here": "從這裡開始",
289
+ "About": "關於",
290
+ "What's new in v{version}": "v{version} 新功能",
289
291
  "Research a company: the overview, then tabs for the chart, financials, news, filings and earnings calls.": "研究一家公司:先看概覽,再切換到圖表、財務、新聞、文件和法說會標籤。",
290
292
  "Add what you own. Alerts and emails then follow your portfolio.": "新增你的持股。之後提醒和郵件都會圍繞你的投資組合。",
291
293
  "Your portfolio and watchlists.": "你的投資組合和自選清單。",
@@ -687,7 +689,7 @@ export const zhTW: Record<string, string> = {
687
689
  "{delay} delayed · try Pro live": "延遲 {delay} · 試用 Pro 即時資料",
688
690
  "Pro trial {days}d": "Pro 試用 {days} 天",
689
691
  "Pro trial — ends {date}": "Pro 試用 — {date} 結束",
690
- "delayed data · upgrade": "資料延遲 · 升級",
692
+ "delayed": "延遲",
691
693
  "upgrade": "升級",
692
694
  "real-time news": "即時新聞",
693
695
  "AI command bar": "AI 命令列",
@@ -852,7 +854,6 @@ export const zhTW: Record<string, string> = {
852
854
  "Start group chat": "開始群組聊天",
853
855
  "Use @username, or multiple usernames for a group chat": "使用 @username,或輸入多個使用者名稱開始群組聊天",
854
856
  "Type DM @username to start one": "輸入 DM @username 開始私訊",
855
- "Read-only chat. Log in or sign up to send.": "聊天目前為唯讀模式。登入或註冊後即可傳送訊息。",
856
857
  "Saved login found. Log in again to send.": "發現已儲存的登入資訊。請重新登入後傳送訊息。",
857
858
  "Verify your email to send messages.": "驗證電子郵件後才能傳送訊息。",
858
859
  // The first-chat prompt for an account still on its signup handle.
@@ -876,7 +877,6 @@ export const zhTW: Record<string, string> = {
876
877
  "ask questions about anything on screen": "針對畫面上的任何內容提問",
877
878
  "Free with a verified Gloom account.": "使用已驗證的 Gloom 帳戶即可免費使用。",
878
879
  "search X": "搜尋 X",
879
- "{shortcut}, then Resend Verification Email": "按 {shortcut},然後選擇「重新發送驗證郵件」",
880
880
  "editing": "編輯中",
881
881
  "replying to": "回覆",
882
882
  "Reply": "回覆",
@@ -1146,6 +1146,9 @@ export const zhTW: Record<string, string> = {
1146
1146
  "No figures for {symbol}: its sponsor's site is not one Gloom reads, and the SEC's prospectus and N-PORT data sets list none for it yet.": "暫無 {symbol} 的數據:Gloom 不讀取其發起人的網站,SEC 的公開說明書與 N-PORT 資料集中也尚未列出。",
1147
1147
  "est. {range}": "估計 {range}",
1148
1148
  "Shares outstanding": "流通單位數",
1149
+ "Management fee": "管理費",
1150
+ "Mgmt Fee": "管理費",
1151
+ "Units per {asset}": "每 {asset} 單位數",
1149
1152
  "1M flows": "1個月資金流",
1150
1153
  "Structure": "結構",
1151
1154
  "Closed-end fund": "封閉式基金",
@@ -30,11 +30,17 @@ const sharesShape = (value: FundFactsPayload["sharesOutstanding"]) => value == n
30
30
  const flowsShape = (value: FundFlows | null | undefined) => value == null
31
31
  || (finite(value.shares) && (value.value === null || finite(value.value)) && typeof value.from === "string" && typeof value.asOf === "string");
32
32
 
33
+ /** Absent for any fund but a spot coin fund abroad; otherwise its coins and the units per coin, dated. */
34
+ const coinHoldingsShape = (value: FundFactsPayload["coinHoldings"]) => value == null
35
+ || ((value.asset === "BTC" || value.asset === "ETH") && finite(value.coins) && finite(value.unitsPerCoin) && value.unitsPerCoin > 0
36
+ && typeof value.asOf === "string" && typeof value.source === "string");
37
+
33
38
  export function validateFundFacts(data: FundFactsPayload): FundFactsPayload {
34
39
  if (!data || typeof data.ticker !== "string" || typeof data.covered !== "boolean"
35
40
  || ![data.expenseRatio, data.nav, data.premiumDiscount, data.netAssets, data.sponsor, data.inception, data.index].every(fact)
36
41
  || !estimateShape(data.nav) || !sharesShape(data.sharesOutstanding) || !flowsShape(data.flows)
37
- || !isBondFactsShape(data.bond) || !leverageShape(data.leverage) || !isMetalHoldingsShape(data.metalHoldings)) {
42
+ || !isBondFactsShape(data.bond) || !leverageShape(data.leverage) || !isMetalHoldingsShape(data.metalHoldings)
43
+ || !coinHoldingsShape(data.coinHoldings) || (data.currency !== undefined && typeof data.currency !== "string")) {
38
44
  throw new Error("Unreadable fund facts response");
39
45
  }
40
46
  return data;
@@ -233,6 +233,26 @@ export function quotePreviousCloseDate(quote: Quote | null | undefined): string
233
233
  return previousSession(quote, sessionDate)?.date ?? null;
234
234
  }
235
235
 
236
+ /**
237
+ * Whether the quote's print is older than what its move is measured from, so
238
+ * the move, labelled as of now, is not one: a coin whose last print is
239
+ * before today's 00:00 UTC (TUSD-USD's 29 Oct print read on 3 Nov, "0.00%
240
+ * since 00:00 UTC"), or a move over 24 hours whose print is older than that.
241
+ * A move from a dated close is measured from the print's own session, so it
242
+ * never is.
243
+ */
244
+ export function printPredatesChangeBasis(
245
+ quote: Pick<Quote, "lastUpdated"> | null | undefined,
246
+ basis: QuoteChangeBasis | null | undefined,
247
+ now = Date.now(),
248
+ ): boolean {
249
+ const printed = quote?.lastUpdated;
250
+ if (!basis || !isFiniteNumber(printed) || printed <= 0 || printed > now) return false;
251
+ if (basis.kind === "utc day") return printed < Math.floor(now / DAY_MS) * DAY_MS;
252
+ if (basis.kind === "24h") return printed < now - DAY_MS;
253
+ return false;
254
+ }
255
+
236
256
  /** `Fri 16 Oct`, with the year when it is not `now`'s. */
237
257
  function sessionDay(date: string, now: number): string {
238
258
  return formatUtcDayTime({ time: Date.parse(`${date}T00:00:00Z`), dateOnly: true }, now);
@@ -16,6 +16,13 @@ export interface AssetDisplayContext {
16
16
  multiplier?: number;
17
17
  priceBasis?: PriceBasis | null;
18
18
  quantityCurrency?: string;
19
+ /**
20
+ * The tick table the listing trades on, when its tick is finer than its
21
+ * currency's minor unit: `hkex-reduced`, the spread table Hong Kong's
22
+ * exchange traded products trade on (0.002 from 1 to 5, 0.005 from 5 to 10),
23
+ * whose prices under 10 print to three decimals (5.325, not 5.33).
24
+ */
25
+ listingTickTable?: "hkex-reduced";
19
26
  }
20
27
 
21
28
  export interface MarketFormatOptions extends AssetDisplayContext {
@@ -34,10 +41,28 @@ export interface MarketFormatOptions extends AssetDisplayContext {
34
41
  referencePrice?: number;
35
42
  }
36
43
 
44
+ /** Hong Kong's exchange traded products (ETFs, leveraged and inverse products) trade on its reduced spread table. */
45
+ const HKEX_REDUCED_SPREAD_TYPES = new Set(["ETF", "ETN", "ETP", "FUND"]);
46
+ const HKEX_VENUES = new Set(["HKEX", "HKG", "HKSE", "SEHK"]);
47
+
48
+ /** The tick table a quote's listing trades on, when its tick is finer than its currency's minor unit (see `listingTickTable`). */
49
+ function quoteListingTickTable(
50
+ quote: Partial<Pick<Quote, "instrumentType" | "exchangeName" | "listingExchangeName">> | null | undefined,
51
+ ): AssetDisplayContext["listingTickTable"] {
52
+ const venue = (quote?.listingExchangeName || quote?.exchangeName || "").trim().toUpperCase();
53
+ return HKEX_VENUES.has(venue) && HKEX_REDUCED_SPREAD_TYPES.has(normalizeType(quote?.instrumentType)) ? "hkex-reduced" : undefined;
54
+ }
55
+
56
+ /** The decimals a listing's tick asks for at a price, beyond its currency's; undefined when the currency's are enough. */
57
+ function listingTickDigits(table: AssetDisplayContext["listingTickTable"], price: number | undefined): number | undefined {
58
+ if (table !== "hkex-reduced" || price === undefined || !Number.isFinite(price)) return undefined;
59
+ return Math.abs(price) < 10 ? 3 : undefined;
60
+ }
61
+
37
62
  /** Current price fields use the quote's source metadata; stored cost/mark
38
63
  * conventions and independent history must not supply its missing basis. */
39
64
  export function quoteFormatOptions(
40
- quote: Pick<Quote, "instrumentType" | "priceBasis" | "providerPriceDivisor"> | null | undefined,
65
+ quote: (Pick<Quote, "instrumentType" | "priceBasis" | "providerPriceDivisor"> & Partial<Pick<Quote, "exchangeName" | "listingExchangeName">>) | null | undefined,
41
66
  fallbackAssetCategory?: string,
42
67
  metadataInstrumentType?: string,
43
68
  ): MarketFormatOptions {
@@ -45,13 +70,34 @@ export function quoteFormatOptions(
45
70
  // never turn a saved bond into a monetary quote or supply a par declaration.
46
71
  const fallback = metadataInstrumentType?.trim().toUpperCase() === "BOND" ? "BOND" : fallbackAssetCategory;
47
72
  const divisor = quote?.providerPriceDivisor;
73
+ const tickTable = quoteListingTickTable(quote);
48
74
  return {
49
75
  assetCategory: quote?.instrumentType?.trim() || fallback,
50
76
  priceBasis: quote?.priceBasis,
51
77
  ...(divisor != null && Number.isFinite(divisor) && divisor > 1 ? { quotedUnitDivisor: divisor } : {}),
78
+ ...(tickTable ? { listingTickTable: tickTable } : {}),
52
79
  };
53
80
  }
54
81
 
82
+ /** A hundredth of a cent, one basis point of a dollar peg: the decimals CRYP prints a stablecoin to. */
83
+ const NEAR_PAR_COIN_PRICE_DIGITS = 4;
84
+
85
+ /**
86
+ * The decimals a coin trading near a dollar prints to, a dollar stablecoin's
87
+ * 0.9989 and 1.0003 and a bond token's 0.9762, whatever digits its source sent
88
+ * (0.99886, 0.97619265): four either side of par, as CRYP prints them, so
89
+ * `quote`, `ticker` and `G` read one price. Undefined for any other price,
90
+ * which keeps its kind's own decimals (a sub-cent coin's eight).
91
+ */
92
+ export function nearParCoinPriceDigits(
93
+ quote: Pick<Quote, "instrumentType" | "currency" | "previousClose" | "price"> | null | undefined,
94
+ ): number | undefined {
95
+ if (!quote || resolveAssetDisplayKind({ assetCategory: quote.instrumentType }) !== "crypto") return undefined;
96
+ if ((quote.currency ?? "USD").trim().toUpperCase() !== "USD") return undefined;
97
+ const reference = [quote.previousClose, quote.price].find((value) => typeof value === "number" && Number.isFinite(value) && value > 0);
98
+ return reference != null && reference >= 0.9 && reference < 1.1 ? NEAR_PAR_COIN_PRICE_DIGITS : undefined;
99
+ }
100
+
55
101
  /** Decimals a sub-unit quote adds in the major unit: two for pence shown in pounds. */
56
102
  function quotedUnitFractionDigits(divisor: number | undefined): number {
57
103
  return divisor != null && Number.isFinite(divisor) && divisor > 1 ? Math.min(3, Math.round(Math.log10(divisor))) : 0;
@@ -368,6 +414,8 @@ export function formatMarketPrice(value: number | undefined, options: MarketForm
368
414
  ? getBasePriceMaxFractionDigits(kind, value, options.currency) + quotedUnitDigits
369
415
  : marketPriceFractionDigitCeiling(reference, options) + quotedUnitDigits;
370
416
  let digits = Math.max(0, Math.min(fixedFractionDigits, maxFractionDigits));
417
+ const tick = kind === "equity" || kind === "other" ? listingTickDigits(options.listingTickTable, reference ?? value) : undefined;
418
+ if (tick !== undefined) digits = Math.max(digits, tick);
371
419
  // A live price keeps its instrument's decimals, but a trade finer than the
372
420
  // session prices showed (a half-yen print after whole-yen closes) is not
373
421
  // rounded to a price that never traded.
@@ -377,9 +425,12 @@ export function formatMarketPrice(value: number | undefined, options: MarketForm
377
425
  ? fitted
378
426
  : scientificPrice(value, options.maxWidth);
379
427
  }
428
+ // A listing whose tick is finer than its currency's minor unit keeps the tick's decimals (an HKEX ETF's 5.325).
429
+ const tick = kind === "equity" || kind === "other" ? listingTickDigits(options.listingTickTable, value) : undefined;
380
430
  const minimumFractionDigits = Math.max(
381
431
  0,
382
432
  Math.min(options.minimumFractionDigits ?? 0, getBasePriceMaxFractionDigits(kind, value, options.currency)),
433
+ tick ?? 0,
383
434
  );
384
435
  const maxFractionDigits = Math.max(
385
436
  getPriceMaxFractionDigits(kind, value, options.priceRange, options.precisionOffset ?? 0, quotedUnitDigits, options.currency),
@@ -443,6 +494,13 @@ export function formatMarketChangeWithCurrency(
443
494
  ...options, minimumFractionDigits: Math.max(2, options.minimumFractionDigits ?? 0),
444
495
  })}`;
445
496
  }
497
+ // A move on a listing whose tick is finer than cents is written to the tick's decimals (+HK$0.030 on an HKEX ETF).
498
+ const tick = listingTickDigits(options.listingTickTable, referencePrice);
499
+ if (tick !== undefined && resolveAssetDisplayKind(options) !== "crypto") {
500
+ const rounded = Math.abs(value) < 0.5 * 10 ** -tick;
501
+ const body = formatMarketPriceWithCurrency(rounded ? 0 : Math.abs(value), currency, { ...options, minimumFractionDigits: tick });
502
+ return rounded ? body : `${value > 0 ? "+" : "-"}${body}`;
503
+ }
446
504
  // Cents hide the whole move of a sub-cent asset (-$0.00 for a SHIB day change).
447
505
  const unitDigits = currencyPriceDigits(currency);
448
506
  const smallestMove = 0.5 / 10 ** unitDigits;
@@ -551,7 +609,9 @@ export function stablePriceFractionDigits(context: StablePriceContext): number {
551
609
  } else if (kind === "equity" || kind === "other") {
552
610
  // A sub-unit price keeps four decimals of the major unit, pence lines
553
611
  // included; above one unit the currency's minor unit (and pence) apply.
554
- digits = below(1) ? 4 : currencyPriceMinDigits(context.currency) + unitDigits;
612
+ // A listing whose tick is finer than its currency's minor unit prints to the tick (an HKEX ETF's 5.325 and 0.676).
613
+ digits = listingTickDigits(context.listingTickTable, reference)
614
+ ?? (below(1) ? 4 : currencyPriceMinDigits(context.currency) + unitDigits);
555
615
  } else if (kind === "cash") {
556
616
  digits = below(10) ? 4 : 2;
557
617
  } else if (kind === "crypto") {
@@ -35,6 +35,8 @@ export interface FuturesWeekendClosure {
35
35
  closedAt: number;
36
36
  /** The Sunday open that ends it, when the venue's contracts all open then or later. */
37
37
  reopensAt?: number;
38
+ /** The zone that open is kept in, beside it. */
39
+ timeZone?: string;
38
40
  /** That open's local date, `YYYY-MM-DD` (always a Sunday). */
39
41
  reopensOn?: string;
40
42
  }
@@ -63,6 +65,6 @@ export function futuresWeekendClosure(exchange: string | undefined, time: number
63
65
  if (time < closedAt || time >= reopensAt) return null;
64
66
  return {
65
67
  closedAt,
66
- ...(venue.reopens ? { reopensAt, reopensOn: new Date((friday + 2) * MS_PER_DAY).toISOString().slice(0, 10) } : {}),
68
+ ...(venue.reopens ? { reopensAt, timeZone: WEEK_ZONE, reopensOn: new Date((friday + 2) * MS_PER_DAY).toISOString().slice(0, 10) } : {}),
67
69
  };
68
70
  }
@@ -23,7 +23,7 @@ import {
23
23
  } from "../../../time-series/resolution";
24
24
  import type { ChartResolution } from "../../../time-series/range";
25
25
  import { intradaySessionDates, intradaySessionTimeZone, loadIntradayWindow, resolveIntradayRequest, type IntradayRequest, type IntradayWindow, type LoadedIntradayWindow } from "./session-history";
26
- import { sessionRangeReport } from "./session-range";
26
+ import { sessionRangeReport, usBarCoverageNotice } from "./session-range";
27
27
  import { createSnapshotDataProvider, snapshotInstrumentKey, type SnapshotMarketData } from "../../../market-data/snapshot-provider";
28
28
  import type { InstrumentRef } from "../../../market-data/request-types";
29
29
  import type { HistorySession } from "../../../types/price-history";
@@ -32,15 +32,16 @@ import { chartQuoteOverrideKeyForTarget, getLiveChartQuoteTargets } from "../../
32
32
  import { createChartSeriesResolver } from "../../../capabilities";
33
33
  import { loadFuturesContractTerms, loadFuturesPriceUnit } from "../../../market-data/futures-contract";
34
34
  import { canonicalExchange, isKnownExchangeCode, isUsListingExchange, parsePublicTickerKey, publicTickerKey } from "../../../utils/exchanges";
35
- import { zonedDateTimeParts } from "../../../utils/zoned-date-time";
35
+ import { zonedDateKey, zonedDateTimeParts } from "../../../utils/zoned-date-time";
36
36
  import { futuresSessionOpenMinute } from "../../../market-data/market/trading-sessions";
37
37
  import { isAlwaysOpenExchange, isRegularSessionTime } from "../../../market-data/market/freshness";
38
38
  import { isRoundTheClockCoin } from "../../../utils/crypto-pair";
39
39
  import { isCurrencyPairListing } from "../../../utils/fx-market-hours";
40
40
  import { cleanFloat32Price, historyPriceDecimals } from "../../../cli/history-rows";
41
+ import { nearParCoinPriceDigits } from "../../../market-data/market/format";
41
42
  import { parseChartSpec } from "./chart-spec";
42
43
  import { paneSchemas } from "./headless-schema";
43
- import { barHistoryFreshness, DAILY_CLOSES, REPORTED_DATA } from "../shared/report-freshness";
44
+ import { barHistoryFreshness, DAILY_CLOSES, quoteObservation, REPORTED_DATA } from "../shared/report-freshness";
44
45
  import type { BarPeriodToDate } from "../../../market-data/market/bar-period";
45
46
  import { closedHistoryBarDay, formingHistoryBar } from "../ticker-detail/data-panes/history-bars";
46
47
  import { inferSeriesFrequency } from "../../../series/csv";
@@ -227,11 +228,14 @@ export async function loadChartPaneModel(
227
228
  source.instrument.symbol,
228
229
  ).map((row) => [row.date, row.growth])) : null;
229
230
  // A formula or a converted price prints at its legs' decimals in text; JSON keeps every digit.
231
+ // A coin's dollar price near par prints to four decimals, as `quote`, `ticker` and CRYP print it.
230
232
  const { valueDecimals, ...reported } = series;
233
+ const textDecimals = valueDecimals ?? (source?.kind === "security" && series.unitGroup === "price:USD"
234
+ ? nearParCoinPriceDigits(financials.get(snapshotInstrumentKey(source.instrument))?.quote) : undefined);
231
235
  return {
232
236
  ...reported,
233
237
  ...name ? { name } : {},
234
- ...valueDecimals !== undefined ? { textDecimals: valueDecimals } : {},
238
+ ...textDecimals !== undefined ? { textDecimals } : {},
235
239
  // A company's reported total (revenue, market cap) reads as 63.33B in the report, as in the legend and the tables.
236
240
  ...series.unitGroup.split(":")[0] === "currency-total" ? { textCompact: true } : {},
237
241
  derived: !ids.has(series.id),
@@ -350,8 +354,9 @@ function chartFreshness(
350
354
  allSeries: readonly HeadlessSeries[],
351
355
  spec: ChartSpec,
352
356
  comparison?: PriceComparison | null,
353
- quoteTimes: ReadonlyMap<string, number> = new Map(),
357
+ quotes: ReadonlyMap<string, Quote> = new Map(),
354
358
  ): HeadlessPaneFreshness {
359
+ const quoteTimes = new Map([...quotes].map(([id, quote]) => [id, quote.lastUpdated] as const));
355
360
  const order = ["1wk", "1mo"];
356
361
  // A leg that failed to load has no bars to date; the ones that loaded say what the chart is.
357
362
  const loaded = allSeries.filter((entry) => entry.points.length > 0);
@@ -382,6 +387,23 @@ function chartFreshness(
382
387
  return { status: "not-a-feed", basis: through ? `${basis} through ${periodDayText(through, new Date().getUTCFullYear())}` : basis,
383
388
  ...(through && closedDay ? { asOf: through } : {}), oldest: null };
384
389
  }
390
+ // Intraday bars of listings whose quotes carry them on are dated as their capture dates them: by those quotes,
391
+ // with their delay and where their markets stand (GIP: `Tue 3 Nov 2026 17:10 UTC · 15 min delayed`).
392
+ // Only a quote of the newest bar's trading date in the venue's zone carries them on: a session of the past
393
+ // (`--session 2026-10-01`, or yesterday's) is not what today's quote carries on.
394
+ const visibleSecurities = visible.filter((entry) => entry.source.kind === "security");
395
+ const carriedOn = (entry: ChartSeriesSpec) => {
396
+ const newest = series.find((item) => item.id === entry.id)?.points.at(-1)?.date;
397
+ const time = newest ? new Date(newest).getTime() : Number.NaN;
398
+ const quoted = quotes.get(entry.id)?.lastUpdated;
399
+ if (!Number.isFinite(time) || quoted == null || !Number.isFinite(quoted) || entry.source.kind !== "security") return false;
400
+ const zone = intradaySessionTimeZone(entry.source.instrument.symbol, entry.source.instrument.exchange);
401
+ return zonedDateKey(quoted, zone) === zonedDateKey(time, zone);
402
+ };
403
+ if (!["1d", "1wk", "1mo"].includes(coarsest!) && visibleSecurities.length === visible.length && visible.length > 0
404
+ && visibleSecurities.every(carriedOn)) {
405
+ return { prices: true, observations: visibleSecurities.map((entry) => ({ ...quoteObservation(quotes.get(entry.id)!) })) };
406
+ }
385
407
  const forming = formingPriceBar(series);
386
408
  // A history: its first bars are not stale data, so the line dates it by the bar still forming alone.
387
409
  if (forming) return { ...barHistoryFreshness(coarsest), periodToDate: forming, oldest: null };
@@ -439,8 +461,8 @@ function newestDailyPoint(series: readonly HeadlessSeries[], closedDay: string |
439
461
  }
440
462
 
441
463
  /** When each security series' listing was last quoted, by series id, from the quotes the chart was read with. */
442
- function chartQuoteTimes(model: Pick<ChartPaneModel, "spec" | "snapshot">): Map<string, number> {
443
- const times = new Map<string, number>();
464
+ function chartQuotes(model: Pick<ChartPaneModel, "spec" | "snapshot">): Map<string, Quote> {
465
+ const quotes = new Map<string, Quote>();
444
466
  for (const entry of model.spec.series) {
445
467
  if (entry.source.kind !== "security") continue;
446
468
  const { instrument } = entry.source;
@@ -449,9 +471,9 @@ function chartQuoteTimes(model: Pick<ChartPaneModel, "spec" | "snapshot">): Map<
449
471
  const data = model.snapshot.financials.find(([candidate]) => candidate === key)?.[1]
450
472
  ?? model.snapshot.instrumentFinancials?.find((item) => snapshotInstrumentKey(item.instrument) === instrumentKey)?.financials;
451
473
  const time = data?.quote?.lastUpdated;
452
- if (typeof time === "number" && Number.isFinite(time)) times.set(entry.id, time);
474
+ if (data?.quote && typeof time === "number" && Number.isFinite(time)) quotes.set(entry.id, data.quote);
453
475
  }
454
- return times;
476
+ return quotes;
455
477
  }
456
478
 
457
479
  /** A series' venue and the day its newest bar starts, as the forming and closed bar checks read them. */
@@ -777,6 +799,15 @@ export function chartHeadless(template: keyof typeof paneSchemas): HeadlessPaneD
777
799
  ...await loadIntradayWindow({ provider: context.marketData, symbol: target.symbol, exchange: target.exchange ?? "", request, context: { brokerId: target.brokerId, brokerInstanceId: target.brokerInstanceId, instrument: target.instrument } }),
778
800
  })));
779
801
  context.signal.throwIfAborted();
802
+ // One quote per listing, read once: it dates the footer as the capture dates the bars, decides a closed session's
803
+ // last bar, and answers the chart's metadata. A captured shot's source can have none.
804
+ await Promise.all(histories.map(async (history) => {
805
+ if (history.quote || !history.points.length || typeof context.marketData.getQuote !== "function") return;
806
+ const quote = await Promise.resolve(context.marketData.getQuote(history.symbol, history.exchange,
807
+ { brokerId: history.target.brokerId, brokerInstanceId: history.target.brokerInstanceId, instrument: history.target.instrument }))
808
+ .catch(logFailure("chart-composer.headless", "Read an intraday chart's quote failed", null));
809
+ if (quote) history.quote = quote;
810
+ }));
780
811
  // Once a session has closed, its last bar ends on the official close (the closing auction's print), as
781
812
  // `history` and CMP give it, not on the last trade before it; until the quote has that close, the footer says so.
782
813
  await Promise.all(histories.map(async (history) => {
@@ -791,11 +822,7 @@ export function chartHeadless(template: keyof typeof paneSchemas): HeadlessPaneD
791
822
  if (history.quote?.marketState === "REGULAR" || (known && isRegularSessionTime(known, now) === true)) return;
792
823
  if (known && !newestClosedSession(history.points, { venue: known, now })) return;
793
824
  // A captured shot's source can have no quotes: its bars are drawn as captured.
794
- const quote = history.quote ?? (typeof context.marketData.getQuote === "function"
795
- ? await Promise.resolve(context.marketData.getQuote(history.symbol, history.exchange,
796
- { brokerId: history.target.brokerId, brokerInstanceId: history.target.brokerInstanceId, instrument: history.target.instrument }))
797
- .catch(logFailure("chart-composer.headless", "Read the official close of an intraday chart failed", null))
798
- : null);
825
+ const quote = history.quote ?? null;
799
826
  const venue = known || quote?.listingExchangeName || quote?.exchangeName || undefined;
800
827
  const newest = newestClosedSession(history.points, { venue, now });
801
828
  const decided = newest ? newestSessionClose(quote, { ...newest, venue }) : null;
@@ -871,8 +898,10 @@ export function chartHeadless(template: keyof typeof paneSchemas): HeadlessPaneD
871
898
  if (template !== "graph-intraday-price-pane") model.series = model.series.map(barsAtSeriesPrecision);
872
899
  if (template === "graph-intraday-price-pane") {
873
900
  model.series = model.series.map(tradedBars);
874
- const regular = regularSessionNotice(intradayHistories.map((window) => ({ ...window, exchange: listingExchange(window.symbol, window.exchange) })));
875
- if (regular) model.metadata = { ...model.metadata, notices: [...(Array.isArray(model.metadata?.notices) ? model.metadata.notices : []), regular] };
901
+ const windows = intradayHistories.map((window) => ({ ...window, exchange: listingExchange(window.symbol, window.exchange) }));
902
+ // What the bars count, and the minutes of the session with no print that sets a price.
903
+ const notices = [regularSessionNotice(windows), usBarCoverageNotice(windows)].filter((notice): notice is string => !!notice);
904
+ if (notices.length) model.metadata = { ...model.metadata, notices: [...(Array.isArray(model.metadata?.notices) ? model.metadata.notices : []), ...notices] };
876
905
  }
877
906
  const dropped = chartResolutionDrop(
878
907
  parsed.viewport.resolution,
@@ -884,7 +913,18 @@ export function chartHeadless(template: keyof typeof paneSchemas): HeadlessPaneD
884
913
  model.warnings = [...model.warnings ?? [], dropped.warning];
885
914
  model.metadata = { ...model.metadata, resolution: dropped.drop };
886
915
  }
887
- model.freshness = chartFreshness(model.series, model.spec, model.chart.priceComparison, chartQuoteTimes(model));
916
+ const quotes = chartQuotes(model);
917
+ // GIP's bars are dated by the quote that carries them on, as its capture dates them: the one its window read.
918
+ if (template === "graph-intraday-price-pane") {
919
+ for (const entry of model.spec.series) {
920
+ if (entry.source.kind !== "security" || quotes.has(entry.id)) continue;
921
+ const { symbol, exchange } = entry.source.instrument;
922
+ const quote = intradayHistories.find((window) => window.quote && window.symbol.toUpperCase() === symbol.toUpperCase()
923
+ && (!exchange || !window.exchange || canonicalExchange(window.exchange) === canonicalExchange(exchange)))?.quote;
924
+ if (quote && Number.isFinite(quote.lastUpdated)) quotes.set(entry.id, quote);
925
+ }
926
+ }
927
+ model.freshness = chartFreshness(model.series, model.spec, model.chart.priceComparison, quotes);
888
928
  if (closingPrintsPending.length) {
889
929
  model.freshness = { ...model.freshness, note: [model.freshness.note, CLOSING_PRINT_PENDING_TEXT].filter(Boolean).join(", ") };
890
930
  }
@@ -2,9 +2,39 @@ import type { HeadlessPaneEntry } from "../../../types/headless";
2
2
  import type { PricePoint } from "../../../types/financials";
3
3
  import { cleanFloat32Price } from "../../../cli/history-rows";
4
4
  import { exportNumber } from "../../../cli/report-tables";
5
- import { publicTickerKey } from "../../../utils/exchanges";
5
+ import { isUsListingExchange, publicTickerKey } from "../../../utils/exchanges";
6
6
  import { formatUtcTime } from "../../../utils/utc-time";
7
7
  import { pricePointWicks } from "../../../utils/price-history-integrity";
8
+ import { futuresSessionOpenMinute } from "../../../market-data/market/trading-sessions";
9
+ import { getPublishedUsEquitySession } from "../../../market-data/published-us-sessions";
10
+ import { zonedDateKey, zonedDateTimeParts } from "../../../utils/zoned-date-time";
11
+
12
+ const NEW_YORK = "America/New_York";
13
+ const REGULAR_OPEN_MINUTE = 9 * 60 + 30;
14
+ const REGULAR_CLOSE_MINUTE = 16 * 60;
15
+
16
+ /** A US stock or fund line, whose day's range `quote` reads from its regular session; not a future on a US venue. */
17
+ function usStockLine(symbol: string, exchange: string): boolean {
18
+ return isUsListingExchange(exchange) && futuresSessionOpenMinute(symbol, exchange) == null;
19
+ }
20
+
21
+ /**
22
+ * The bars that start in a US regular session: from the venue's published
23
+ * open to its close, 13:00 New York on an early close (the day after
24
+ * Thanksgiving, Christmas Eve). A day the calendar does not publish is taken
25
+ * as 09:30 to 16:00.
26
+ */
27
+ function regularSessionBars<T extends Pick<PricePoint, "date">>(points: readonly T[], exchange: string): T[] {
28
+ return points.filter(({ date }) => {
29
+ const time = new Date(date).getTime();
30
+ if (!Number.isFinite(time)) return false;
31
+ const session = getPublishedUsEquitySession(exchange, zonedDateKey(time, NEW_YORK));
32
+ if (session?.kind === "session") return time >= session.open && time < session.close;
33
+ const { hour, minute } = zonedDateTimeParts(time, NEW_YORK);
34
+ const at = hour * 60 + minute;
35
+ return at >= REGULAR_OPEN_MINUTE && at < REGULAR_CLOSE_MINUTE;
36
+ });
37
+ }
8
38
 
9
39
  interface SessionExtreme {
10
40
  price: number;
@@ -49,6 +79,52 @@ interface SessionRangeWindow {
49
79
  quote?: { currency?: string } | null;
50
80
  }
51
81
 
82
+ /**
83
+ * What a US line's intraday bars count and how many of the regular session's
84
+ * spans had no bar: `Bars are of every US venue's prints that set a
85
+ * price; odd lots and special-condition prints count only in volume. 3 of 276
86
+ * minutes had none, so no bar.` Each session is counted from the 09:30 open to
87
+ * its close, or to its newest bar while it trades. Null for another venue.
88
+ */
89
+ export function usBarCoverageNotice(
90
+ windows: ReadonlyArray<SessionRangeWindow & { resolution?: string | null }>,
91
+ now = Date.now(),
92
+ ): string | null {
93
+ const counts = windows.flatMap((window) => {
94
+ const step = barStepMs(window.resolution);
95
+ if (!step || !usStockLine(window.symbol, window.exchange)) return [];
96
+ const bars = regularSessionBars(window.points, window.exchange).map(({ date }) => new Date(date).getTime());
97
+ if (!bars.length) return [];
98
+ let expected = 0;
99
+ let present = 0;
100
+ for (const date of new Set(bars.map((time) => zonedDateKey(time, NEW_YORK)))) {
101
+ const session = getPublishedUsEquitySession(window.exchange, date);
102
+ if (session?.kind !== "session") continue;
103
+ const starts = new Set(bars.filter((time) => time >= session.open && time < session.close));
104
+ // A session still trading is counted to its newest bar: the spans after it have not been served yet.
105
+ const through = now < session.close ? Math.max(...starts) : session.close - step;
106
+ for (let start = session.open; start <= through; start += step) {
107
+ expected++;
108
+ if (starts.has(start)) present++;
109
+ }
110
+ }
111
+ return expected ? [{ listing: publicTickerKey(window.symbol, window.exchange), missing: expected - present, expected, step }] : [];
112
+ });
113
+ if (!counts.length) return null;
114
+ const spans = (step: number, count: number) => step === 60_000 ? (count === 1 ? "minute" : "minutes")
115
+ : step % 3_600_000 === 0 ? `${step / 3_600_000}-hour ${count === 1 ? "span" : "spans"}` : `${step / 60_000}-minute ${count === 1 ? "span" : "spans"}`;
116
+ const each = counts.map(({ listing, missing, expected, step }) =>
117
+ `${counts.length > 1 ? `${listing}: ` : ""}${missing} of ${expected} ${spans(step, expected)} had none, so no bar.`);
118
+ return ["Bars are of every US venue's prints that set a price; odd lots and special-condition prints count only in volume.", ...each].join(" ");
119
+ }
120
+
121
+ /** A bar size as `1m`, `5m` or `1h` in milliseconds; null for a daily or longer one. */
122
+ function barStepMs(resolution: string | null | undefined): number | null {
123
+ const match = /^(\d+)(m|h)$/.exec(resolution ?? "");
124
+ if (!match) return null;
125
+ return Number(match[1]) * (match[2] === "h" ? 3_600_000 : 60_000);
126
+ }
127
+
52
128
  export interface SessionRangeReport {
53
129
  /** For the Statistics section: `USDT-USD:CCC session low 0.99833 at 2026-10-17 11:30 UTC`. */
54
130
  entries: HeadlessPaneEntry[];
@@ -63,10 +139,13 @@ export interface SessionRangeReport {
63
139
  export function sessionRangeReport(windows: readonly SessionRangeWindow[]): SessionRangeReport {
64
140
  const report: SessionRangeReport = { entries: [], ranges: [] };
65
141
  for (const window of windows) {
66
- const range = sessionRange(window.points);
142
+ // A US line's range is its regular session's, the rule `quote` reads the day's low and high by.
143
+ const regular = usStockLine(window.symbol, window.exchange);
144
+ const range = sessionRange(regular ? regularSessionBars(window.points, window.exchange) : window.points);
67
145
  if (!range) continue;
68
146
  const listing = publicTickerKey(window.symbol, window.exchange);
69
- const span = (window.sessionDates?.length ?? 1) > 1 ? "" : "session ";
147
+ const several = (window.sessionDates?.length ?? 1) > 1;
148
+ const span = regular ? (several ? "regular-hours " : "regular-session ") : several ? "" : "session ";
70
149
  const currency = window.quote?.currency?.trim();
71
150
  // As the bars export them: the decimal the feed's float stands for (85.1, not 85.099998).
72
151
  const low = cleanFloat32Price(exportNumber(range.low.price));