@gloom-sh/terminal 0.20.16 → 0.20.18

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 (345) hide show
  1. package/package.json +3 -1
  2. package/src/account/auth-dialog.tsx +19 -1
  3. package/src/account/billing.ts +2 -1
  4. package/src/account/heard-from-question.tsx +235 -0
  5. package/src/account/heard-from.ts +97 -0
  6. package/src/api-client/data.ts +16 -5
  7. package/src/api-client/heard-from.ts +72 -0
  8. package/src/api-client/index.ts +63 -6
  9. package/src/api-client/mna.ts +18 -0
  10. package/src/api-client/supply-chain.ts +9 -0
  11. package/src/api-client/types/billing.ts +35 -1
  12. package/src/api-client/types/econ.ts +3 -0
  13. package/src/app/global-shortcuts.ts +5 -3
  14. package/src/app/pro-welcome/keys.ts +27 -0
  15. package/src/app/pro-welcome/model.ts +158 -0
  16. package/src/app/pro-welcome/row.tsx +176 -0
  17. package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
  18. package/src/app/runtime/external-profile-changes.ts +135 -0
  19. package/src/app.tsx +33 -2
  20. package/src/architecture/core-builtin-allowlist.json +1 -1
  21. package/src/architecture/floating-promise-allowlist.json +0 -1
  22. package/src/architecture/shortcut-labels-allowlist.json +1 -0
  23. package/src/cli/alert-listing.ts +98 -0
  24. package/src/cli/commands/fred-series.ts +3 -1
  25. package/src/cli/commands/market.ts +138 -22
  26. package/src/cli/commands/overview.ts +72 -14
  27. package/src/cli/commands/plugins.ts +3 -2
  28. package/src/cli/commands/search.ts +30 -6
  29. package/src/cli/context.ts +16 -5
  30. package/src/cli/csv-export.ts +74 -0
  31. package/src/cli/desktop-pane-shot.ts +75 -11
  32. package/src/cli/glossary.ts +64 -10
  33. package/src/cli/help.ts +4 -2
  34. package/src/cli/history-demergers.ts +117 -0
  35. package/src/cli/history-rows.ts +6 -2
  36. package/src/cli/index.ts +1 -0
  37. package/src/cli/known-gaps.ts +16 -0
  38. package/src/cli/known-us-stocks.ts +18 -0
  39. package/src/cli/listing-arg.ts +105 -15
  40. package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
  41. package/src/cli/pane-functions/catalog-snapshot.json +866 -0
  42. package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
  43. package/src/cli/pane-functions/catalog.ts +50 -16
  44. package/src/cli/pane-functions/data.ts +16 -4
  45. package/src/cli/pane-functions/dom.ts +24 -6
  46. package/src/cli/pane-functions/freshness.ts +17 -1
  47. package/src/cli/pane-functions/headless.ts +7 -2
  48. package/src/cli/pane-functions/index.ts +102 -44
  49. package/src/cli/pane-functions/resolver.ts +8 -5
  50. package/src/cli/pane-functions/screenshot-assessment.ts +30 -7
  51. package/src/cli/pane-functions/screenshot-bridge.ts +4 -2
  52. package/src/cli/pane-functions/screenshot-payload.ts +21 -0
  53. package/src/cli/pane-functions/screenshot-render.ts +3 -1
  54. package/src/cli/quote-answer.ts +32 -16
  55. package/src/cli/registry.ts +22 -2
  56. package/src/cli/report-tables.ts +17 -3
  57. package/src/cli/result.ts +8 -10
  58. package/src/cli/series-search.ts +45 -6
  59. package/src/cli/shot-temp-dir.ts +4 -9
  60. package/src/components/chart/composite/legend.tsx +80 -25
  61. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
  62. package/src/components/chart/composite/price-axis-labels.tsx +7 -5
  63. package/src/components/chart-table/header.tsx +9 -0
  64. package/src/components/chart-table/layout.ts +11 -11
  65. package/src/components/command-bar/pane-templates/items.ts +17 -1
  66. package/src/components/command-bar/routes/root/provider-search.ts +10 -1
  67. package/src/components/command-bar/routes/root/results.ts +34 -2
  68. package/src/components/command-bar/routes/root/runtime.ts +8 -1
  69. package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
  70. package/src/components/command-bar/workflow/alert.ts +19 -8
  71. package/src/components/data-table/view.tsx +15 -2
  72. package/src/components/form-modal/content.tsx +9 -4
  73. package/src/components/index.ts +1 -1
  74. package/src/components/layout/header.tsx +9 -5
  75. package/src/components/layout/pane/capture-status.ts +6 -0
  76. package/src/components/layout/pane/footer/index.tsx +2 -0
  77. package/src/components/layout/pane/footer/model.ts +113 -15
  78. package/src/components/layout/pane/header.tsx +16 -2
  79. package/src/components/market-board/index.tsx +4 -2
  80. package/src/components/onboarding/onboarding-frame.tsx +6 -2
  81. package/src/components/onboarding/onboarding-keyboard.ts +7 -1
  82. package/src/components/onboarding/onboarding-wizard.tsx +3 -1
  83. package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
  84. package/src/components/onboarding/setup-cards.ts +36 -0
  85. package/src/components/onboarding/use-onboarding-progress.ts +22 -1
  86. package/src/components/onboarding/wizard-account.ts +6 -1
  87. package/src/components/onboarding/wizard-model.ts +32 -6
  88. package/src/components/onboarding/wizard-positions.ts +1 -1
  89. package/src/components/sign-in-gate.tsx +3 -1
  90. package/src/components/toggle-list.tsx +6 -8
  91. package/src/components/ui/confirm-dialog.tsx +47 -7
  92. package/src/components/ui/data-table/display-columns.ts +4 -1
  93. package/src/components/ui/data-table/hooks.ts +2 -3
  94. package/src/components/ui/data-table/index.tsx +4 -1
  95. package/src/components/ui/data-table/types.ts +19 -4
  96. package/src/components/ui/data-table/visible-range.ts +11 -1
  97. package/src/components/ui/display.tsx +17 -2
  98. package/src/components/ui/index.ts +1 -1
  99. package/src/components/ui/stat-grid.tsx +4 -0
  100. package/src/components/ui/status.tsx +13 -1
  101. package/src/components/ui/table-layout.ts +2 -1
  102. package/src/components/use-pane-notice-footer.tsx +16 -3
  103. package/src/data/config/store/index.ts +31 -0
  104. package/src/data/config/store/node.ts +61 -11
  105. package/src/data/config/store/normalize.ts +4 -6
  106. package/src/data/config/store/shared-file.ts +309 -0
  107. package/src/data/profile-merge.ts +299 -0
  108. package/src/data/sqlite/checkpointer.ts +11 -1
  109. package/src/data/sqlite/database.ts +1 -1
  110. package/src/data/ticker-repository.ts +134 -10
  111. package/src/data/ticker-store.ts +67 -0
  112. package/src/data/ticker-writes.ts +5 -0
  113. package/src/i18n/es.ts +27 -0
  114. package/src/i18n/ja.ts +27 -0
  115. package/src/i18n/ko.ts +27 -0
  116. package/src/i18n/zh-cn.ts +27 -0
  117. package/src/i18n/zh-tw.ts +27 -0
  118. package/src/layout-marketplace/gallery-desktop.tsx +2 -2
  119. package/src/market-data/ah-pair.ts +103 -0
  120. package/src/market-data/depositary-pair.ts +6 -2
  121. package/src/market-data/hooks.tsx +33 -2
  122. package/src/market-data/market/change-basis.ts +2 -1
  123. package/src/market-data/market/header-market.ts +11 -0
  124. package/src/market-data/split-terms.ts +28 -0
  125. package/src/plugins/builtin/account-management/footer.ts +1 -1
  126. package/src/plugins/builtin/account-management/keyboard.ts +4 -0
  127. package/src/plugins/builtin/account-management/model.ts +1 -0
  128. package/src/plugins/builtin/account-management/pane.tsx +75 -7
  129. package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
  130. package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
  131. package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
  132. package/src/plugins/builtin/alerts/cli-move.ts +2 -2
  133. package/src/plugins/builtin/alerts/cli.ts +36 -30
  134. package/src/plugins/builtin/alerts/constants.ts +10 -0
  135. package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
  136. package/src/plugins/builtin/alerts/format.ts +24 -8
  137. package/src/plugins/builtin/alerts/index.tsx +38 -9
  138. package/src/plugins/builtin/alerts/move-checks.ts +7 -0
  139. package/src/plugins/builtin/alerts/pane.tsx +1 -1
  140. package/src/plugins/builtin/alerts/quotes.ts +26 -2
  141. package/src/plugins/builtin/alerts/scheduled.ts +6 -1
  142. package/src/plugins/builtin/alerts/types.ts +7 -0
  143. package/src/plugins/builtin/analytics/manual-value.ts +61 -0
  144. package/src/plugins/builtin/analytics/risk-book.ts +7 -7
  145. package/src/plugins/builtin/analytics/risk-client.ts +26 -13
  146. package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
  147. package/src/plugins/builtin/analytics/risk-model.ts +92 -4
  148. package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
  149. package/src/plugins/builtin/awards/pane.tsx +7 -3
  150. package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
  151. package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
  152. package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
  153. package/src/plugins/builtin/chart-composer/cli-options.ts +4 -2
  154. package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
  155. package/src/plugins/builtin/chart-composer/pane.tsx +9 -3
  156. package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
  157. package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
  158. package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
  159. package/src/plugins/builtin/company-kpis/headless.ts +9 -4
  160. package/src/plugins/builtin/company-kpis/latest.ts +45 -0
  161. package/src/plugins/builtin/company-kpis/model.ts +38 -8
  162. package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
  163. package/src/plugins/builtin/composite/alt-data.ts +20 -0
  164. package/src/plugins/builtin/composite/application.ts +14 -0
  165. package/src/plugins/builtin/composite/broker.ts +12 -0
  166. package/src/plugins/builtin/composite/credit.ts +33 -0
  167. package/src/plugins/builtin/composite/crypto.ts +10 -0
  168. package/src/plugins/builtin/composite/earnings.ts +12 -0
  169. package/src/plugins/builtin/composite/filings.ts +13 -0
  170. package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
  171. package/src/plugins/builtin/composite/global-markets.ts +12 -0
  172. package/src/plugins/builtin/composite/options-volatility.ts +23 -0
  173. package/src/plugins/builtin/composite/ownership.ts +23 -0
  174. package/src/plugins/builtin/composite/portfolio.ts +10 -0
  175. package/src/plugins/builtin/composite/quant.ts +15 -0
  176. package/src/plugins/builtin/composite/rates-macro.ts +30 -0
  177. package/src/plugins/builtin/composite/screeners.ts +11 -0
  178. package/src/plugins/builtin/composite/shared.ts +11 -0
  179. package/src/plugins/builtin/composite/ticker-core.ts +36 -0
  180. package/src/plugins/builtin/congress-trades/headless.ts +31 -3
  181. package/src/plugins/builtin/correlation/index.tsx +13 -17
  182. package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
  183. package/src/plugins/builtin/credit-conditions/series.ts +2 -2
  184. package/src/plugins/builtin/dividend-yield/client.ts +57 -16
  185. package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
  186. package/src/plugins/builtin/dividend-yield/model.ts +4 -3
  187. package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
  188. package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
  189. package/src/plugins/builtin/dividend-yield/types.ts +4 -0
  190. package/src/plugins/builtin/dividend-yield/view.ts +23 -12
  191. package/src/plugins/builtin/earnings/board-model.ts +12 -0
  192. package/src/plugins/builtin/earnings/board-table.ts +7 -4
  193. package/src/plugins/builtin/earnings/board.tsx +2 -2
  194. package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
  195. package/src/plugins/builtin/earnings/headless.ts +7 -4
  196. package/src/plugins/builtin/earnings/highlight.ts +1 -1
  197. package/src/plugins/builtin/earnings/history-model.ts +6 -4
  198. package/src/plugins/builtin/earnings/history-table.ts +4 -3
  199. package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
  200. package/src/plugins/builtin/econ/calendar-model.ts +18 -0
  201. package/src/plugins/builtin/econ/fred-catalog.ts +1 -256
  202. package/src/plugins/builtin/econ/index.tsx +3 -0
  203. package/src/plugins/builtin/econ-statistics/cache.ts +1 -1
  204. package/src/plugins/builtin/econ-statistics/client.ts +11 -10
  205. package/src/plugins/builtin/econ-statistics/detail.tsx +1 -0
  206. package/src/plugins/builtin/econ-statistics/headless.ts +42 -6
  207. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  208. package/src/plugins/builtin/econ-statistics/pane.tsx +7 -2
  209. package/src/plugins/builtin/econ-statistics/stats.ts +2 -1
  210. package/src/plugins/builtin/econ-statistics/view.ts +9 -3
  211. package/src/plugins/builtin/equity-screener/headless.ts +4 -1
  212. package/src/plugins/builtin/equity-screener/model.ts +7 -6
  213. package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
  214. package/src/plugins/builtin/exposure/model.ts +10 -0
  215. package/src/plugins/builtin/exposure/pane.tsx +10 -3
  216. package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
  217. package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
  218. package/src/plugins/builtin/fx-matrix/index.tsx +23 -5
  219. package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
  220. package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
  221. package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
  222. package/src/plugins/builtin/mna/detail.tsx +67 -6
  223. package/src/plugins/builtin/mna/headless.ts +128 -13
  224. package/src/plugins/builtin/mna/model.ts +219 -16
  225. package/src/plugins/builtin/mna/pane.tsx +34 -6
  226. package/src/plugins/builtin/money-markets/model.ts +14 -5
  227. package/src/plugins/builtin/money-markets/pane.tsx +4 -3
  228. package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
  229. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
  230. package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
  231. package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
  232. package/src/plugins/builtin/pe-band/client.ts +13 -1
  233. package/src/plugins/builtin/pe-band/headless.ts +2 -2
  234. package/src/plugins/builtin/pe-band/model.ts +63 -10
  235. package/src/plugins/builtin/pe-band/pane.tsx +5 -5
  236. package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
  237. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
  238. package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
  239. package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
  240. package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
  241. package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
  242. package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
  243. package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
  244. package/src/plugins/builtin/research/corporate-actions-pane.tsx +5 -1
  245. package/src/plugins/builtin/research/event-model.ts +31 -13
  246. package/src/plugins/builtin/research/headless.ts +8 -1
  247. package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
  248. package/src/plugins/builtin/sectors/index.tsx +6 -9
  249. package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
  250. package/src/plugins/builtin/shared/earnings-report.ts +19 -4
  251. package/src/plugins/builtin/shared/fred-catalog.ts +256 -0
  252. package/src/plugins/builtin/shared/report-freshness.ts +2 -3
  253. package/src/plugins/builtin/shared/series-cache.ts +3 -0
  254. package/src/plugins/builtin/shared/series-detail-chart.tsx +3 -0
  255. package/src/plugins/builtin/short-interest/watch-pane.tsx +7 -7
  256. package/src/plugins/builtin/supply-chain/client.ts +34 -9
  257. package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
  258. package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
  259. package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
  260. package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
  261. package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
  262. package/src/plugins/builtin/supply-chain/headless.ts +19 -4
  263. package/src/plugins/builtin/supply-chain/model.ts +50 -6
  264. package/src/plugins/builtin/supply-chain/pane.tsx +76 -16
  265. package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
  266. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
  267. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +67 -1
  268. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +31 -16
  269. package/src/plugins/builtin/ticker-detail/overview/model.ts +17 -1
  270. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
  271. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -2
  272. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
  273. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
  274. package/src/plugins/builtin/time-sales/headless.ts +4 -1
  275. package/src/plugins/builtin/time-sales/pane.tsx +2 -0
  276. package/src/plugins/builtin/time-sales/window.ts +12 -0
  277. package/src/plugins/builtin/treasury-auctions/client.ts +4 -0
  278. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +2 -0
  279. package/src/plugins/builtin/treasury-daily/client.ts +23 -11
  280. package/src/plugins/builtin/volatility/model.ts +17 -0
  281. package/src/plugins/builtin/volatility/pane.tsx +13 -4
  282. package/src/plugins/builtin/world-indices/index.tsx +2 -0
  283. package/src/plugins/builtin/world-indices/table.tsx +15 -0
  284. package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
  285. package/src/plugins/builtin/world-venue-map/headless.ts +28 -16
  286. package/src/plugins/builtin/world-venue-map/index.ts +19 -6
  287. package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
  288. package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
  289. package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
  290. package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
  291. package/src/plugins/builtin/world-venue-map/place.ts +119 -0
  292. package/src/plugins/catalog-data.ts +20 -0
  293. package/src/plugins/catalog-lazy.ts +51 -0
  294. package/src/plugins/catalog-ui.ts +16 -18
  295. package/src/plugins/host-smoke.ts +5 -2
  296. package/src/portfolio/allocation.ts +79 -19
  297. package/src/portfolio/cash-balances.ts +76 -0
  298. package/src/portfolio/mutations.ts +43 -8
  299. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  300. package/src/renderers/desktop/window-layouts.ts +14 -0
  301. package/src/renderers/dom/data-table/row.tsx +2 -0
  302. package/src/renderers/dom/host/tabs.tsx +57 -8
  303. package/src/renderers/dom/styles.css +13 -5
  304. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
  305. package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
  306. package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
  307. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  308. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +2 -0
  309. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
  310. package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
  311. package/src/series/standalone-catalog.ts +5 -4
  312. package/src/series/standalone.ts +13 -7
  313. package/src/sources/gloomberb-cloud/fred-publisher.ts +25 -0
  314. package/src/sources/gloomberb-cloud/fred-series.ts +1 -1
  315. package/src/sources/gloomberb-cloud/index.ts +14 -3
  316. package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
  317. package/src/sources/provider-router/financials.ts +20 -13
  318. package/src/sources/provider-router/index.ts +4 -0
  319. package/src/sources/provider-router/search.ts +1 -0
  320. package/src/sync/collections-contributor.ts +3 -1
  321. package/src/sync/config-merge.ts +10 -1
  322. package/src/sync/sanitize.ts +26 -2
  323. package/src/tickers/company-name-listing.ts +16 -2
  324. package/src/tickers/listing-fate.ts +12 -8
  325. package/src/tickers/renamed-listings.ts +43 -10
  326. package/src/tickers/search/home-listing.ts +28 -0
  327. package/src/tickers/search/index.ts +19 -7
  328. package/src/tickers/terminal-codes.ts +11 -1
  329. package/src/time-series/base-series.ts +3 -0
  330. package/src/time-series/ice-credit.ts +1 -0
  331. package/src/time-series/resolve.ts +3 -1
  332. package/src/time-series/spec.ts +2 -2
  333. package/src/time-series/types.ts +2 -1
  334. package/src/types/data-provider.ts +11 -0
  335. package/src/types/financials.ts +39 -3
  336. package/src/types/headless.ts +4 -2
  337. package/src/types/ticker.ts +10 -2
  338. package/src/utils/cli-output.ts +1 -1
  339. package/src/utils/declared-dividends.ts +13 -1
  340. package/src/utils/dividend-cash.ts +5 -1
  341. package/src/utils/forward-dividend.ts +4 -3
  342. package/src/utils/remove-folder.ts +37 -0
  343. package/src/utils/throttled-fetch.ts +15 -1
  344. package/src/utils/trailing-dividend.ts +1 -1
  345. package/src/plugins/builtin/composite-plugins.ts +0 -285
@@ -29,11 +29,13 @@ import {
29
29
  type LayoutMergeContext,
30
30
  } from "./layout-merge";
31
31
  import {
32
+ PORTFOLIOS_CARRY_OTHER_CASH,
32
33
  sanitizeBrokerInstance,
33
34
  sanitizePortfolio,
34
35
  sanitizeUnknown,
35
36
  sanitizeWatchlist,
36
37
  WATCHLISTS_CARRY_GROUPS,
38
+ withLocalOtherCash,
37
39
  withLocalPluginSecrets,
38
40
  withLocalWatchlistGroups,
39
41
  } from "./sanitize";
@@ -44,6 +46,8 @@ export function collectCoreConfigPayload(config: AppConfig) {
44
46
  baseCurrency: config.baseCurrency,
45
47
  refreshIntervalMinutes: config.refreshIntervalMinutes,
46
48
  portfolios: config.portfolios.map(sanitizePortfolio),
49
+ // The portfolios carry their cash in other currencies: one without it holds no more.
50
+ [PORTFOLIOS_CARRY_OTHER_CASH]: true,
47
51
  watchlists: config.watchlists.map(sanitizeWatchlist),
48
52
  [WATCHLISTS_CARRY_GROUPS]: true,
49
53
  ...collectLayoutPayload(config),
@@ -166,10 +170,15 @@ export function mergeConfigPayload(
166
170
  payload.brokerInstancesMergedById === true,
167
171
  );
168
172
  }
173
+ // An older build pushes its portfolios without their cash in other currencies: they keep what they hold here.
169
174
  if ("portfolios" in payload && canApply("portfolios")) {
170
175
  const syncedPortfolios = payload.portfolios;
171
176
  next.portfolios = Array.isArray(syncedPortfolios)
172
- ? mergeLocalBrokerPortfolioIdentity(config.portfolios, syncedPortfolios as Portfolio[], next.brokerInstances)
177
+ ? mergeLocalBrokerPortfolioIdentity(
178
+ config.portfolios,
179
+ withLocalOtherCash(syncedPortfolios, config.portfolios, payload[PORTFOLIOS_CARRY_OTHER_CASH] === true),
180
+ next.brokerInstances,
181
+ )
173
182
  : syncedPortfolios as AppConfig["portfolios"];
174
183
  }
175
184
  // An older build pushes its lists without their groups: they keep the groups they have here.
@@ -2,6 +2,7 @@ import type { AppConfig, BrokerInstanceConfig } from "../types/config";
2
2
  import type { Portfolio, TickerPosition, Watchlist } from "../types/ticker";
3
3
  import { isRecord } from "../utils/guards";
4
4
  import { normalizeWatchlistGroups } from "../portfolio/watchlist-groups";
5
+ import { portfolioCashBalances, withKeptOtherCash } from "../portfolio/cash-balances";
5
6
 
6
7
  const SENSITIVE_KEY_PATTERN = /(token|secret|password|credential|private|api[_-]?key|access[_-]?key|refresh[_-]?key|session|cookie|dataDir|path|directory|localPath)/i;
7
8
 
@@ -57,6 +58,7 @@ export function withLocalPluginSecrets(
57
58
  }
58
59
 
59
60
  export function sanitizePortfolio(portfolio: Portfolio): Portfolio {
61
+ const [cash, ...otherCash] = portfolioCashBalances(portfolio);
60
62
  return {
61
63
  id: portfolio.id,
62
64
  name: portfolio.name,
@@ -66,8 +68,10 @@ export function sanitizePortfolio(portfolio: Portfolio): Portfolio {
66
68
  brokerId: portfolio.brokerId,
67
69
  lastSyncedAt: portfolio.lastSyncedAt,
68
70
  // Cash and targets are the user's own entries: a pulled portfolio without
69
- // them would erase them on this device.
70
- ...(portfolio.cash ? { cash: { ...portfolio.cash } } : {}),
71
+ // them would erase them on this device. `cash` is the first balance, as an
72
+ // older build reads it, and `otherCash` the other currencies'.
73
+ ...(cash ? { cash } : {}),
74
+ ...(otherCash.length > 0 ? { otherCash } : {}),
71
75
  ...(portfolio.targetWeights ? { targetWeights: { ...portfolio.targetWeights } } : {}),
72
76
  ...(portfolio.importedFrom ? {
73
77
  importedFrom: {
@@ -78,6 +82,26 @@ export function sanitizePortfolio(portfolio: Portfolio): Portfolio {
78
82
  };
79
83
  }
80
84
 
85
+ /**
86
+ * Set on every payload this build pushes with portfolios: they carry their
87
+ * cash in other currencies (`otherCash`), so one without it holds cash in one
88
+ * currency at most. An older build strips `otherCash` from every push, and
89
+ * its portfolios taken as they came would erase those balances here and then
90
+ * everywhere this device pushes to.
91
+ */
92
+ export const PORTFOLIOS_CARRY_OTHER_CASH = "portfoliosCarryOtherCash";
93
+
94
+ /**
95
+ * Pulled portfolios, each one an older build pushed (no
96
+ * `PORTFOLIOS_CARRY_OTHER_CASH`) keeping the other currencies' cash it holds
97
+ * here (`withKeptOtherCash`); a build that sends them is taken as it came, so
98
+ * a balance cleared there is cleared here.
99
+ */
100
+ export function withLocalOtherCash(pulled: unknown[], local: readonly Portfolio[], carriesOtherCash: boolean): Portfolio[] {
101
+ if (carriesOtherCash) return pulled as Portfolio[];
102
+ return pulled.map((entry) => withKeptOtherCash(entry, isRecord(entry) ? local.find((portfolio) => portfolio.id === entry.id) : null) as Portfolio);
103
+ }
104
+
81
105
  /**
82
106
  * Set on every payload this build pushes with watchlists: its lists carry their
83
107
  * groups, so one without `groups` has none. An older build's lists never carry
@@ -95,6 +95,18 @@ function homeLineQuery(typed: string): string | null {
95
95
  return words.length >= 3 ? words.slice(1).join(" ") : null;
96
96
  }
97
97
 
98
+ /** A word written as a ticker: capitals and digits, short, with a class or venue mark after a dot, dash, slash or colon. */
99
+ const TICKER_WORD = /^\$?[A-Z0-9]{1,6}(?:[.\-/:][A-Z0-9]{1,6})*$/;
100
+
101
+ /**
102
+ * Whether every word of a line is written as a ticker (`V MCO CPRT`, `0700 0005`), as a company's name, which has
103
+ * words longer than a ticker or in lower case (`Turk Hava Yollari`, `TURK HAVA YOLLARI`), is not.
104
+ */
105
+ function wordsAreTickers(typed: string): boolean {
106
+ const words = typed.trim().split(/\s+/).filter(Boolean);
107
+ return words.length > 0 && words.every((word) => TICKER_WORD.test(word));
108
+ }
109
+
98
110
  /** A list entry with a space inside is a company's name, never a symbol: "Whirlpool Corporation". */
99
111
  export function isCompanyNameInput(input: string): boolean {
100
112
  return /\S\s+\S/.test(input.trim());
@@ -150,9 +162,11 @@ export async function findListingOfCompanyName(
150
162
  let results = answers.flatMap((answer) => Array.isArray(answer) ? answer : []);
151
163
  let listed = rankCompanyLines(name, results, options);
152
164
  // A company the answers list only abroad or by receipts (Türk Hava Yolları on Frankfurt and OTC) is searched again
153
- // under its later words, which can list its home line: THYAO in Istanbul.
165
+ // under its later words, which can list its home line: THYAO in Istanbul. A line of tickers (`V MCO CPRT`) that
166
+ // search found nothing for names no company, abroad or at home, so a shorter line would find nothing either.
154
167
  const lead = listed.find((listing) => listing.namesCompany);
155
- const again = !options.oneWord && (!lead || (!lead.home && lead.rank[3]! > 1)) ? homeLineQuery(name) : null;
168
+ const tickersOnly = results.length === 0 && wordsAreTickers(name);
169
+ const again = !options.oneWord && !tickersOnly && (!lead || (!lead.home && lead.rank[3]! > 1)) ? homeLineQuery(name) : null;
156
170
  if (again && !queries.includes(again)) {
157
171
  const more = await searchListings(dataProvider, again);
158
172
  if (Array.isArray(more) && more.length) {
@@ -19,7 +19,7 @@ import {
19
19
  } from "./ticker-changes";
20
20
  import { isQuoteBeforeLatestSession, isQuoteStaleForCurrentSession } from "../market-data/quotes/freshness";
21
21
  import { formatMarketPriceWithCurrency, quoteFormatOptions } from "../market-data/market/format";
22
- import { canonicalExchange, isUsListingExchange, parsePublicTickerKey, resolveExchangeTimeZone } from "../utils/exchanges";
22
+ import { canonicalExchange, exchangeLabel, isUsListingExchange, parsePublicTickerKey, resolveExchangeTimeZone } from "../utils/exchanges";
23
23
  import { zonedDateKey } from "../utils/zoned-date-time";
24
24
  import { delistingLabel } from "../market-data/quotes/delisting";
25
25
 
@@ -295,19 +295,23 @@ export function isVenueAbroad(venue: string): boolean {
295
295
  }
296
296
 
297
297
  /**
298
- * "SXR8 -> XETRA" for a bare symbol the data service read on its home listing
299
- * abroad, as it reads a symbol with no US listing whose listings belong to one
300
- * company or fund: a row that shows the symbol as typed says which listing it
301
- * is. Null for a named or saved venue, and for a venue the app does not place
302
- * outside the US (a US exchange, OTC, a futures exchange).
298
+ * "Z74 has no US listing; it trades on Singapore Exchange (SGX), in SGD." for
299
+ * a bare symbol the data service read on its home listing abroad, as it reads
300
+ * a symbol with no US listing whose listings belong to one company or fund: a
301
+ * row that shows the symbol as typed says which listing it is, in the words
302
+ * `watchlist add` says it. Null for a named or saved venue, and for a venue
303
+ * the app does not place outside the US (a US exchange, OTC, a futures
304
+ * exchange).
303
305
  */
304
306
  export function bareListingNote(
305
307
  listing: { symbol: string; request: { exchange: string } },
306
- quote: Pick<Quote, "listingExchangeName" | "exchangeName"> | null | undefined,
308
+ quote: Pick<Quote, "listingExchangeName" | "exchangeName" | "currency"> | null | undefined,
307
309
  ): string | null {
308
310
  if (listing.request.exchange || !quote || !/^[A-Z0-9]{1,10}$/.test(listing.symbol)) return null;
309
311
  const venue = canonicalExchange(quote.listingExchangeName || quote.exchangeName);
310
- return isVenueAbroad(venue) ? `${listing.symbol} -> ${venue}` : null;
312
+ if (!isVenueAbroad(venue)) return null;
313
+ const unit = quote.currency?.trim();
314
+ return `${listing.symbol} has no US listing; it trades on ${exchangeLabel(venue)}${unit ? `, in ${unit}` : ""}.`;
311
315
  }
312
316
 
313
317
  /** `ListingFate` from a listing's quote (null when it has none) and its ticker changes. */
@@ -16,15 +16,27 @@ export interface RenamedListing {
16
16
  exchange: string;
17
17
  /** Its name now. */
18
18
  name: string;
19
- /** The names people still search for, the one it went by first: its brand, then its legal name. */
20
- formerNames: readonly [string, ...string[]];
19
+ /**
20
+ * The names people still search for, the one it went by first: its brand, then its legal name. Empty when the
21
+ * old name went with another company (Tata Motors Limited is now the demerged commercial-vehicle business), so
22
+ * only the old symbol, never a name, leads to this line.
23
+ */
24
+ formerNames: readonly string[];
25
+ /** What the old line is called in a sentence when no former name leads to it: "Tata Motors". */
26
+ formerLabel?: string;
27
+ /** How the new line is written in the app's own key (`TMPV:NSE`), where the venue's suffix is not how it is read. */
28
+ shownAs?: string;
21
29
  /** The day a class that no longer trades was converted into the `to` line (YYYY-MM-DD). */
22
30
  convertedOn?: string;
31
+ /** The day the venue renamed the line, when its notice says so (YYYY-MM-DD). */
32
+ renamedOn?: string;
33
+ /** A business demerged out of the line around the rename, listed on its own: the old symbol is never that company. */
34
+ demerged?: { symbol: string; name: string; business: string };
23
35
  }
24
36
 
25
37
  /** The name it went by: "Eletrobras". */
26
38
  function renamedListingFormerName(listing: RenamedListing): string {
27
- return listing.formerNames[0];
39
+ return listing.formerNames[0] ?? listing.formerLabel ?? listing.from;
28
40
  }
29
41
 
30
42
  /**
@@ -40,10 +52,22 @@ function renamedListingFormerName(listing: RenamedListing): string {
40
52
  */
41
53
  const ELETROBRAS = ["Eletrobras", "Centrais Elétricas Brasileiras"] as const;
42
54
  const AXIA_PREFERRED_CONVERTED = "2026-06-05";
55
+ /**
56
+ * NSE renamed Tata Motors' line, TATAMOTORS, to TMPV (Tata Motors Passenger
57
+ * Vehicles Limited) effective 24 Oct 2025 (NSE circular CML70875; NSE's
58
+ * symbol change list has the same row), and BSE renamed it the same day. The
59
+ * commercial-vehicle business was demerged out of it (record date 14 Oct
60
+ * 2025) and listed as TMCV on 12 Nov 2025; that company took the legal name
61
+ * Tata Motors Limited, so the old code follows the line, TMPV, never the
62
+ * name, and no name leads here.
63
+ */
64
+ const TATA_MOTORS = { to: "TMPV", name: "Tata Motors Passenger Vehicles", formerNames: [], formerLabel: "Tata Motors", renamedOn: "2025-10-24" } as const;
43
65
  const RENAMED_LISTINGS: readonly RenamedListing[] = [
44
66
  { from: "ELET3", to: "AXIA3", suffix: ".SA", exchange: "B3", name: "AXIA Energia", formerNames: ELETROBRAS },
45
67
  ...["ELET6", "AXIA6", "ELET5", "AXIA5"].map((from): RenamedListing => ({ from, to: "AXIA3", suffix: ".SA", exchange: "B3",
46
68
  name: "AXIA Energia", formerNames: ELETROBRAS, convertedOn: AXIA_PREFERRED_CONVERTED })),
69
+ { ...TATA_MOTORS, from: "TATAMOTORS", suffix: ".NS", exchange: "NSE", shownAs: "TMPV:NSE", demerged: { symbol: "TMCV:NSE", name: "Tata Motors Limited", business: "commercial-vehicle" } },
70
+ { ...TATA_MOTORS, from: "TATAMOTORS", suffix: ".BO", exchange: "BSE", shownAs: "TMPV:BSE", demerged: { symbol: "TMCV:BSE", name: "Tata Motors Limited", business: "commercial-vehicle" } },
47
71
  ];
48
72
 
49
73
  /** "5 Jun 2026". */
@@ -53,7 +77,7 @@ function conversionDay(date: string): string {
53
77
 
54
78
  /** `AXIA3.SA`: the new listing as `quote` takes it. */
55
79
  export function renamedListingSymbol(listing: RenamedListing): string {
56
- return `${listing.to}${listing.suffix}`;
80
+ return listing.shownAs ?? `${listing.to}${listing.suffix}`;
57
81
  }
58
82
 
59
83
  /**
@@ -78,9 +102,14 @@ export function renamedListingFor(query: string): RenamedListing | null {
78
102
  export function renamedListingHint(listing: RenamedListing): string {
79
103
  const now = renamedListingSymbol(listing);
80
104
  const named = `${now} (${listing.name}, formerly ${renamedListingFormerName(listing)})`;
81
- return listing.convertedOn
82
- ? `It was converted into ${named} on ${conversionDay(listing.convertedOn)}: \`gloom quote ${now}\`.`
83
- : `It is now ${named}: \`gloom quote ${now}\`.`;
105
+ if (listing.convertedOn) return `It was converted into ${named} on ${conversionDay(listing.convertedOn)}: \`gloom quote ${now}\`.`;
106
+ return `It is now ${named}${listing.demerged ? `; ${demergedClause(listing)}` : ""}: \`gloom quote ${now}\`.`;
107
+ }
108
+
109
+ /** "its commercial-vehicle business was demerged into TMCV:NSE (Tata Motors Limited)": the company the old code is not. */
110
+ function demergedClause(listing: RenamedListing): string {
111
+ const { business, symbol, name } = listing.demerged!;
112
+ return `its ${business} business was demerged into ${symbol} (${name})`;
84
113
  }
85
114
 
86
115
  /** What search says the new line was: "Eletrobras (ELET3)", or "Eletrobras (ELET6, converted 5 Jun 2026)". */
@@ -100,7 +129,11 @@ export function renamedListingReadAs(typed: string, listing: RenamedListing): st
100
129
  // A name is quoted, as every name read as a listing is; the CLI puts it back in the user's spelling.
101
130
  const shown = listing.formerNames.some((name) => normalizeSearchText(word) === normalizeSearchText(name)) ? `"${word}"` : word;
102
131
  const now = renamedListingSymbol(listing);
103
- return listing.convertedOn
104
- ? `Read ${shown} as ${now}: those preferred shares were converted into ${listing.name}'s common shares on ${conversionDay(listing.convertedOn)}.`
105
- : `Read ${shown} as ${now}: ${renamedListingFormerName(listing)} is ${listing.name} now.`;
132
+ if (listing.convertedOn) return `Read ${shown} as ${now}: those preferred shares were converted into ${listing.name}'s common shares on ${conversionDay(listing.convertedOn)}.`;
133
+ // One line: the rename, and the company the old code is not.
134
+ if (listing.renamedOn) {
135
+ return `Read ${shown} as ${now}: ${listing.exchange} renamed ${listing.from} ${listing.to} (${listing.name}) on ${conversionDay(listing.renamedOn)}`
136
+ + `${listing.demerged ? `; ${demergedClause(listing)}` : ""}.`;
137
+ }
138
+ return `Read ${shown} as ${now}: ${renamedListingFormerName(listing)} is ${listing.name} now.`;
106
139
  }
@@ -267,6 +267,34 @@ export function withNamedCompanyAfterUsLead<T extends TickerSearchCandidate>(ite
267
267
  return [...items.slice(0, at), ...named, ...rest];
268
268
  }
269
269
 
270
+ /**
271
+ * The lines the service marks with the word as typed (or whose code it is) on
272
+ * the user's own market, ahead of every other row but the saved ones: for a
273
+ * desk whose market is Hong Kong (the header's Hang Seng, the default of a
274
+ * machine in Hong Kong), "aia" is AIA Group's 1299 before the iShares Asia 50
275
+ * ETF's AIA, "mtr" MTR Corporation's 0066 before Mesa Royalty Trust, "hsbc"
276
+ * HSBC's 0005 before its London line and its New York receipt, "catl" CATL's
277
+ * 3750 before Catalyst Acquisition and its Shenzhen line. Only a company's own
278
+ * shares on that venue lead (no receipt, fund or line quoting shares listed
279
+ * elsewhere), behind the saved rows the list opens with, and only for a word
280
+ * typed without a venue: `AIA:NASDAQ` and
281
+ * `AIA US` ask for that line. A market in the US changes nothing: a US ticker
282
+ * already leads (`withNamedCompanyAfterUsLead`).
283
+ */
284
+ export function withHomeVenueLead<T extends TickerSearchCandidate>(items: T[], query: string, homeVenue: string | null | undefined): T[] {
285
+ const venue = canonicalExchange(homeVenue ?? "");
286
+ if (!venue || isUsListingExchange(venue) || isQualifiedTickerQuery(query)) return items;
287
+ const typed = normalizeTickerSymbol(query);
288
+ const lead = items.filter((item) => isListedEquity(item) && item.instrumentClass === "equity" && !!item.result
289
+ && candidateExchange(item) === venue && listingDistance(item) === 0
290
+ && (namedByService(query, item.result) || normalizeTickerSymbol(item.symbol) === typed));
291
+ if (lead.length === 0) return items;
292
+ // Behind the saved rows the list opens with.
293
+ const rest = items.filter((item) => !lead.includes(item));
294
+ const at = rest.findIndex((item) => item.kind !== "ticker" && !item.saved);
295
+ return at < 0 ? [...rest, ...lead] : [...rest.slice(0, at), ...lead, ...rest.slice(at)];
296
+ }
297
+
270
298
  /** `items` with `home` moved just ahead of `lead`. */
271
299
  function moveAhead<T>(items: readonly T[], home: T, lead: T): T[] {
272
300
  const rest = items.filter((item) => item !== home);
@@ -41,7 +41,7 @@ import { endsInLegalForm, readNearMissListing, readVenueFirstListing, readTermin
41
41
  import { isProviderBusy, ProviderBusyError, SEARCH_BUSY_MESSAGE } from "../../sources/provider-errors";
42
42
  import { settleWithin } from "../../utils/async-deadline";
43
43
  import { companyNameExtraWords } from "../company-name";
44
- import { withFundReceiptsAsFunds, withHomeListingLead, withNamedCompanyAfterUsLead } from "./home-listing";
44
+ import { withFundReceiptsAsFunds, withHomeListingLead, withHomeVenueLead, withNamedCompanyAfterUsLead } from "./home-listing";
45
45
  import { answeredInFull, rememberSearchAnswer, withKnownListings } from "./listing-index";
46
46
  import { savedAbroadForBareSymbol, savedUsListingOf } from "./bare-symbol";
47
47
  import { delistingLabel, parseListingWithdrawal, withdrawalLabel } from "../../market-data/quotes/delisting";
@@ -284,6 +284,7 @@ export async function searchTickerCandidates({
284
284
  totalLimit = 8,
285
285
  includeOptionContracts = true,
286
286
  onPartial,
287
+ homeVenue,
287
288
  }: {
288
289
  query: string;
289
290
  tickers: ReadonlyMap<string, TickerRecord>;
@@ -292,6 +293,8 @@ export async function searchTickerCandidates({
292
293
  localLimit?: number;
293
294
  totalLimit?: number;
294
295
  includeOptionContracts?: boolean;
296
+ /** The venue of the user's own market, whose lines of the company a word names lead (`withHomeVenueLead`). */
297
+ homeVenue?: string | null;
295
298
  /** Called when a slower, richer source improves results already returned. */
296
299
  onPartial?: (candidates: TickerSearchCandidate[]) => void;
297
300
  }): Promise<TickerSearchCandidate[]> {
@@ -304,6 +307,7 @@ export async function searchTickerCandidates({
304
307
  totalLimit,
305
308
  // A search that hides contracts still shows them when asked: "AAPL OPT".
306
309
  includeOptionContracts: includeOptionContracts || parseAssetClassQuery(query)?.code === "OPT",
310
+ homeVenue,
307
311
  });
308
312
  const renamed = renamedListingFor(rawQuery);
309
313
  const [searched, renamedRow] = await Promise.all([
@@ -339,6 +343,7 @@ export function buildTickerSearchCandidates({
339
343
  localLimit = 6,
340
344
  totalLimit = 8,
341
345
  includeOptionContracts = true,
346
+ homeVenue,
342
347
  }: {
343
348
  query: string;
344
349
  tickers: ReadonlyMap<string, TickerRecord>;
@@ -346,6 +351,8 @@ export function buildTickerSearchCandidates({
346
351
  localLimit?: number;
347
352
  totalLimit?: number;
348
353
  includeOptionContracts?: boolean;
354
+ /** The venue of the user's own market (`homeMarketVenue`): its lines of the company a word names lead (`withHomeVenueLead`). */
355
+ homeVenue?: string | null;
349
356
  }): TickerSearchCandidate[] {
350
357
  const filteredProviderResults = includeOptionContracts
351
358
  ? providerResults
@@ -363,10 +370,10 @@ export function buildTickerSearchCandidates({
363
370
  );
364
371
  // A receipt on a fund is the fund's line, never a company's primary listing over it (HK01 on SET for the Tracker Fund).
365
372
  const providerItems = withFundReceiptsAsFunds(createProviderTickerSearchCandidates(filteredProviderResults, tickers, candidateOptions));
366
- const ranked = withNamedCompanyAfterUsLead(
373
+ const ranked = withHomeVenueLead(withNamedCompanyAfterUsLead(
367
374
  withHomeListingLead(withSuccessorFirst(rankTickerSearchItems([...localItems, ...providerItems], query), query), query),
368
375
  query,
369
- );
376
+ ), query, homeVenue);
370
377
  return limitTickerSearchCandidates(companyListingsFirst(assignTickerSearchCategories(ranked, query), query), totalLimit, localLimit);
371
378
  }
372
379
 
@@ -816,7 +823,7 @@ async function searchProviderResults(
816
823
  };
817
824
  let busy = false;
818
825
  let unreachable: unknown = null;
819
- await Promise.all(searchQueries.map(async (searchQuery, index) => {
826
+ const ask = async (searchQuery: string, index: number) => {
820
827
  try {
821
828
  const results = await dataProvider.search(searchQuery, {
822
829
  ...searchContext,
@@ -838,7 +845,11 @@ async function searchProviderResults(
838
845
  else if (isProviderBusy(error)) busy = true;
839
846
  else logFailure("tickers-search", "Could not search ticker spelling")(error);
840
847
  }
841
- }));
848
+ };
849
+ // A share class written without its mark (BRKB for BRK.B) is guessed at beside the symbol's own search, unless the
850
+ // symbol is known to be a US stock: NVDA is Nvidia, and NVD-A and NVD.A are two more searches for nothing.
851
+ const notAsked = dataProvider.knownUsStock?.(query) ? new Set(compactShareClassAliases(query)) : new Set<string>();
852
+ await Promise.all(searchQueries.map((searchQuery, index) => notAsked.has(searchQuery) ? null : ask(searchQuery, index)));
842
853
 
843
854
  // Catalogues can omit exact market symbols or return a crypto pair from a
844
855
  // different venue. Verify the requested quote before accepting an alias.
@@ -949,12 +960,13 @@ function buildProviderSearchQueries(query: string): string[] {
949
960
 
950
961
  if (!symbolLike) queries.add(trimmedQuery);
951
962
  for (const alias of buildSymbolAliases(trimmedQuery)) queries.add(alias);
952
- for (const alias of buildCompactShareClassAliases(trimmedQuery)) queries.add(alias);
963
+ for (const alias of compactShareClassAliases(trimmedQuery)) queries.add(alias);
953
964
  queries.add(trimmedQuery);
954
965
  return [...queries].slice(0, 4);
955
966
  }
956
967
 
957
- function buildCompactShareClassAliases(query: string): string[] {
968
+ /** The share-class spellings a four or five letter code with a class letter at its end may be (NVDA: NVD-A, NVD.A). */
969
+ function compactShareClassAliases(query: string): string[] {
958
970
  const normalized = normalizeTickerSymbol(query);
959
971
  if (!/^[A-Z]{4,5}$/.test(normalized)) return [];
960
972
  const shareClass = normalized.slice(-1);
@@ -126,15 +126,25 @@ export const BLOOMBERG_MARKETS: Readonly<Record<string, BloombergMarket>> = {
126
126
  PM: { venues: [], name: "Philippine Stock Exchange" },
127
127
  AU: at("ASX"),
128
128
  NZ: at("NZX"),
129
- CN: at("TSX", "TSXV"),
129
+ CN: at("TSX", "TSXV", "CSE"),
130
130
  CT: at("TSX"),
131
131
  CV: at("TSXV"),
132
+ CF: at("CSE"),
132
133
  MM: at("BMV"),
133
134
  BZ: at("B3"),
134
135
  BS: at("B3"),
135
136
  AR: at("BYMA"),
136
137
  SJ: at("JSE"),
137
138
  IT: at("TASE"),
139
+ IR: at("ICEX"),
140
+ TI: at("BIST"),
141
+ AB: { venues: ["TADAWUL"], hint: "Bloomberg and Tadawul codes differ there: type the Tadawul code, such as 2222 AB for Saudi Aramco." },
142
+ QD: at("QE"),
143
+ BI: at("BHB"),
144
+ DB: at("DFM"),
145
+ OM: at("MSX"),
146
+ KK: at("KUWAIT"),
147
+ EY: at("EGX"),
138
148
  };
139
149
 
140
150
  /** Bloomberg's index tickers the quote sources carry, by the symbol each is quoted as. */
@@ -52,6 +52,7 @@ export function unloadableSeries(spec: ChartSeriesSpec, index: number, warning:
52
52
  return {
53
53
  id: spec.id,
54
54
  label: spec.label?.trim() || label,
55
+ legendContext: spec.label?.trim() ? undefined : field?.seriesLabel ?? field?.shortLabel,
55
56
  color: spec.color ?? SERIES_COLORS[index % SERIES_COLORS.length]!,
56
57
  unit: field?.unit ?? "",
57
58
  unitGroup: field?.unitGroup ?? "unknown",
@@ -242,6 +243,8 @@ export function baseSecuritySeries(
242
243
  id: spec.id,
243
244
  label: spec.label?.trim() || (generic ? futuresGenericCaption(generic)
244
245
  : `${symbol} ${field.id === "market.volume" && volumeBasis ? INDEX_MEMBERS_VOLUME_LABEL : field.seriesLabel ?? field.shortLabel}`),
246
+ legendContext: spec.label?.trim() || generic ? undefined
247
+ : field.id === "market.volume" && volumeBasis ? INDEX_MEMBERS_VOLUME_LABEL : field.seriesLabel ?? field.shortLabel,
245
248
  color: spec.color ?? SERIES_COLORS[index % SERIES_COLORS.length]!,
246
249
  unit,
247
250
  unitGroup: currencyUnitGroup,
@@ -22,6 +22,7 @@ export interface IceCreditSeries {
22
22
 
23
23
  /** What every surface that shows an ICE series says about how far back FRED carries it. */
24
24
  export const ICE_HISTORY_LIMIT_NOTICE = "History limited to 3 years by the publisher.";
25
+ export const ICE_CREDIT_PUBLISHER = "ICE Data Indices";
25
26
 
26
27
  const HIGH_YIELD = ["high yield", "junk"];
27
28
  const EMERGING = ["EM", "emerging markets"];
@@ -1148,7 +1148,9 @@ async function resolveChartSpecPass(
1148
1148
  { ...comparisonOptions, atSessionClose: timed.timing.atSessionClose, closedEnds: timed.timing.closedEnds });
1149
1149
  }
1150
1150
  const splitNotice = priceComparison?.legs ? await comparedSplitNotice(spec, priceComparison, rawSeries, loadDistributions, comparisonOptions.now) : null;
1151
- const displayBounds = comparisonDisplayBounds(bounds, priceComparison);
1151
+ const comparedBounds = comparisonDisplayBounds(bounds, priceComparison);
1152
+ const displayBounds = spec.viewport.dateWindow?.endAtLatestObservation && !requestBounds
1153
+ ? endAtNewestObservation(comparedBounds, rawSeries) : comparedBounds;
1152
1154
  const comparisonBounds = priceComparison && priceComparison.start !== null
1153
1155
  ? priceComparison : bounds;
1154
1156
  const baseSeries = rawSeries
@@ -191,7 +191,7 @@ function normalizeSource(value: unknown): ChartSeriesSource | null {
191
191
  };
192
192
  }
193
193
 
194
- function normalizedDateWindow(value: unknown): { start: string; end: string } | undefined {
194
+ function normalizedDateWindow(value: unknown): ChartSpec["viewport"]["dateWindow"] {
195
195
  const window = recordOrNull(value);
196
196
  const start = nonEmptyString(window?.start);
197
197
  const end = nonEmptyString(window?.end);
@@ -199,7 +199,7 @@ function normalizedDateWindow(value: unknown): { start: string; end: string } |
199
199
  const startTime = Date.parse(start);
200
200
  const endTime = Date.parse(end);
201
201
  if (!Number.isFinite(startTime) || !Number.isFinite(endTime) || startTime > endTime) return undefined;
202
- return { start, end };
202
+ return { start, end, ...(window?.endAtLatestObservation === true ? { endAtLatestObservation: true } : {}) };
203
203
  }
204
204
 
205
205
  function normalizePanel(value: unknown, index: number, seen: Set<string>): ChartPanelSpec | null {
@@ -105,7 +105,7 @@ export interface ChartPanelSpec {
105
105
  export interface ChartViewportSpec {
106
106
  range: TimeRange;
107
107
  resolution: ChartResolution;
108
- dateWindow?: { start: string; end: string };
108
+ dateWindow?: { start: string; end: string; endAtLatestObservation?: boolean };
109
109
  /** Optional latest-observation cap, useful for period-based financial views. */
110
110
  maxPoints?: number;
111
111
  /** Intraday market history includes pre-market and after-hours bars where the venue has them. */
@@ -217,6 +217,7 @@ export interface ResolvedSeries {
217
217
  * "8058 Close · M..." and "8031 Close · M...".
218
218
  */
219
219
  compactLabel?: string;
220
+ legendContext?: string;
220
221
  color: string;
221
222
  unit: string;
222
223
  /** Unit of rawValue, retained when presentation transforms change unit. */
@@ -231,6 +231,11 @@ export interface SearchRequestContext {
231
231
  * still waited for: its answer is the search's.
232
232
  */
233
233
  interactive?: boolean;
234
+ /**
235
+ * `always` asks for perpetual markets beside the listings for every query. Without it, a command that looks up
236
+ * one bare symbol the listings show to be a US stock does not ask for them.
237
+ */
238
+ perpetuals?: "always";
234
239
  /**
235
240
  * Rows to ask a catalogue for. Every listing of a symbol several companies
236
241
  * use (CAR: Avis, Carrefour, CAR Group) takes more than a keystroke's ten.
@@ -373,6 +378,12 @@ export interface AssetDataProvider {
373
378
  * all, or when another source (a connected broker) adds rows of its own.
374
379
  */
375
380
  searchBatch?(queries: string[], options?: { limit?: number; signal?: AbortSignal }): Promise<Map<string, InstrumentSearchResult[]> | null>;
381
+ /**
382
+ * True of a symbol known, before any request, to be a stock on a US exchange. A lookup of one is not searched for
383
+ * its share-class spellings (NVDA as NVD-A) and asks for no perpetual contracts. Set by a command line that
384
+ * ships the listings; absent elsewhere, where every lookup asks.
385
+ */
386
+ knownUsStock?(symbol: string): boolean;
376
387
  getEarningsCalendar?(symbols: string[], context?: MarketDataRequestContext): Promise<EarningsEvent[]>;
377
388
  getSecFilingDocuments?(filing: SecFilingItem): Promise<SecFilingDocument[]>;
378
389
  getSecFilingContent?(filing: SecFilingItem): Promise<string | null>;
@@ -666,6 +666,8 @@ export interface AnalystResearchData {
666
666
  export interface DividendAction {
667
667
  exDate: string;
668
668
  amount: number;
669
+ payDate?: string;
670
+ recordDate?: string;
669
671
  /**
670
672
  * Who published the row when it is not the listing's own history: a fund's
671
673
  * sponsor, for a distribution the history lacks (iShares, SPDR, J.P. Morgan,
@@ -676,13 +678,14 @@ export interface DividendAction {
676
678
 
677
679
  /**
678
680
  * A distribution the issuer has declared and not yet paid, as the source
679
- * states it. Kept apart from the paid `dividends`: no history, yield or growth
680
- * figure takes it.
681
+ * states it. Kept apart from paid `dividends`; issuer-confirmed declarations
682
+ * enter ex-date-based cash figures once ex-dated, with any conversion estimate.
681
683
  */
682
684
  export interface DeclaredDividendAction {
683
685
  exDate: string;
684
686
  /** Per share, in the listing's dividend currency (`currency`). */
685
687
  amount: number;
688
+ cashEstimate?: DividendCashEstimate;
686
689
  declarationDate?: string;
687
690
  recordDate?: string;
688
691
  payDate?: string;
@@ -690,6 +693,14 @@ export interface DeclaredDividendAction {
690
693
  special?: true;
691
694
  }
692
695
 
696
+ /** declaredAmount is in declaredCurrency's major unit; the enclosing amount keeps the history's currency/unit. */
697
+ export interface DividendCashEstimate {
698
+ declaredCurrency: string;
699
+ declaredAmount?: number;
700
+ fixingDate?: string;
701
+ basis: string;
702
+ }
703
+
693
704
  export interface SplitAction {
694
705
  date: string;
695
706
  description?: string;
@@ -757,12 +768,37 @@ export interface CorporateActionsData {
757
768
  dividendsAsOf?: string;
758
769
  splits: SplitAction[];
759
770
  earnings: EarningsAction[];
771
+ /** Businesses demerged out of the listing into companies of their own; absent where none is on record and from older servers. */
772
+ demergers?: DemergerAction[];
760
773
  }
761
774
 
762
- /** Paid rows as their company declared them, in `currency` (its major unit). */
775
+ /**
776
+ * A business demerged out of a listing (Tata Motors' commercial vehicles into
777
+ * TMCV): the listing's price falls by that business's value on the ex-date,
778
+ * which is no market move.
779
+ */
780
+ export interface DemergerAction {
781
+ /** The first session the listing traded without the business, YYYY-MM-DD. */
782
+ exDate: string;
783
+ recordDate?: string;
784
+ /** The company the business went to, as it lists, and the day it first traded (null until it lists). */
785
+ successor: { symbol: string; exchange?: string; name?: string; listedOn?: string | null };
786
+ /** What the business does: "commercial vehicles". */
787
+ business?: string;
788
+ /** Shares of the demerged company per share of the listing. */
789
+ ratio?: number;
790
+ source?: string;
791
+ }
792
+
793
+ /** Declaration amounts (rows and announced.amount) are in the major unit of `currency`.
794
+ * announced.paidAmount uses the corporate-action history's currency/unit, like dividends. */
763
795
  export interface DeclaredCash {
764
796
  currency: string;
765
797
  rows: DividendAction[];
798
+ announced?: { exDate: string; payDate: string; amount: number; paidAmount?: number; fixingDate?: string };
799
+ fetchedAt?: string;
800
+ stale?: boolean;
801
+ verification?: "unavailable";
766
802
  }
767
803
 
768
804
  export interface CompanyProfile {
@@ -643,6 +643,7 @@ export type HeadlessBundleSection =
643
643
  * lists them all.
644
644
  */
645
645
  rowSourceKey?: string;
646
+ appendedColumns?: number;
646
647
  /** The symbol every row is of, where the report's own is not (a section per name): each exported row names it in `symbol_or_series`. */
647
648
  symbol?: string;
648
649
  /** When every row was observed (an ISO date or instant), where it is not the report's newest: each exported row names it in `as_of`. */
@@ -661,6 +662,7 @@ export type HeadlessBundleSection =
661
662
  | {
662
663
  title: string;
663
664
  entries: HeadlessPaneEntry[];
665
+ source?: string;
664
666
  /**
665
667
  * The lines the text report prints in place of `entries`, when the pane
666
668
  * says in one line what the exported records keep apart (a range as
@@ -683,9 +685,9 @@ export type HeadlessBundleSection =
683
685
  rows?: never;
684
686
  textColumns?: never;
685
687
  textRows?: never;
686
- unit?: never;
688
+ unit?: string;
687
689
  rowUnitKey?: never;
688
- interval?: never;
690
+ interval?: string;
689
691
  rowIntervalKey?: never;
690
692
  rowSourceKey?: never;
691
693
  locked?: never;