gloomberb 0.19.4 → 0.19.6

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 (321) hide show
  1. package/package.json +3 -1
  2. package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
  3. package/src/api-client/equity-screener.ts +23 -0
  4. package/src/app/pane-runtime/index.tsx +2 -0
  5. package/src/app/pane-runtime/plugin-bindings.ts +10 -1
  6. package/src/app.tsx +63 -16
  7. package/src/cli/commands/command-utils.ts +4 -0
  8. package/src/cli/commands/market.ts +264 -33
  9. package/src/cli/commands/search.ts +22 -4
  10. package/src/cli/commands/ticker.ts +84 -39
  11. package/src/cli/currency-name-hint.ts +60 -0
  12. package/src/cli/glossary.ts +3 -3
  13. package/src/cli/history-rows.ts +18 -1
  14. package/src/cli/known-gaps.ts +25 -2
  15. package/src/cli/listing-arg.ts +12 -0
  16. package/src/cli/not-a-ticker.ts +5 -3
  17. package/src/cli/pane-functions/capabilities.ts +2 -0
  18. package/src/cli/pane-functions/catalog.ts +31 -5
  19. package/src/cli/pane-functions/function-help.ts +8 -5
  20. package/src/cli/pane-functions/headless.ts +11 -6
  21. package/src/cli/pane-functions/market-session.ts +6 -7
  22. package/src/cli/pane-functions/resolver.ts +75 -2
  23. package/src/cli/quote-answer.ts +9 -0
  24. package/src/cli/series-search.ts +4 -5
  25. package/src/cli/symbol-list.ts +54 -2
  26. package/src/cli/symbol-rows.ts +14 -2
  27. package/src/cli/ticker-resolution.ts +89 -20
  28. package/src/components/chart/composite/axis-overlays.tsx +60 -27
  29. package/src/components/chart/composite/composite-chart.tsx +118 -63
  30. package/src/components/chart/composite/cursor-source.ts +111 -0
  31. package/src/components/chart/composite/format.ts +168 -6
  32. package/src/components/chart/composite/legend.tsx +8 -4
  33. package/src/components/chart/composite/panel-bitmap.ts +28 -2
  34. package/src/components/chart/composite/panel-labels.ts +20 -1
  35. package/src/components/chart/composite/panel-surface.tsx +201 -92
  36. package/src/components/chart/composite/price-axis-labels.tsx +92 -46
  37. package/src/components/chart/composite/price-series.ts +31 -8
  38. package/src/components/chart/composite/scene.ts +154 -59
  39. package/src/components/chart/composite/series-axis-tags.tsx +4 -2
  40. package/src/components/chart/composite/time-axis.ts +30 -7
  41. package/src/components/chart/composite/time-scale.ts +211 -56
  42. package/src/components/chart/composite/types.ts +11 -1
  43. package/src/components/chart/composite/use-composite-chart-keyboard.ts +32 -12
  44. package/src/components/chart/curve/curve-surface.tsx +5 -2
  45. package/src/components/chart/curve/model.ts +4 -1
  46. package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
  47. package/src/components/chart/static/series.ts +3 -0
  48. package/src/components/command-bar/commands/collection-list.ts +81 -0
  49. package/src/components/command-bar/commands/direct/index.ts +6 -0
  50. package/src/components/command-bar/commands/registry.ts +8 -0
  51. package/src/components/command-bar/layout-items/current-layout.ts +22 -1
  52. package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
  53. package/src/components/command-bar/pane-templates/items.ts +19 -3
  54. package/src/components/command-bar/pane-templates/workflow.ts +5 -0
  55. package/src/components/command-bar/routes/root/results.ts +23 -3
  56. package/src/components/command-bar/routes/root/selection.ts +4 -2
  57. package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
  58. package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
  59. package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
  60. package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
  61. package/src/components/command-bar/surface/environment.ts +2 -0
  62. package/src/components/command-bar/view-model.ts +7 -0
  63. package/src/components/command-bar/workflow/ops.ts +2 -1
  64. package/src/components/command-bar/workflow/tickers.ts +20 -0
  65. package/src/components/layout/shell/active-drag.ts +38 -7
  66. package/src/components/layout/shell/drag/magnets.ts +106 -0
  67. package/src/components/layout/shell/menu.ts +15 -1
  68. package/src/components/layout/shell/pane/actions.ts +4 -0
  69. package/src/components/layout/shell/ticker-link-menu.ts +12 -3
  70. package/src/components/layout/status-bar.tsx +20 -0
  71. package/src/components/layout/window-controls.tsx +96 -35
  72. package/src/components/layout/window-fullscreen.ts +20 -0
  73. package/src/components/onboarding/onboarding-keyboard.ts +5 -1
  74. package/src/components/onboarding/onboarding-wizard.tsx +15 -4
  75. package/src/components/onboarding/portfolio-step/positions-panel.tsx +8 -5
  76. package/src/components/onboarding/use-onboarding-progress.ts +20 -1
  77. package/src/components/price-sparkline/view.tsx +14 -6
  78. package/src/components/quote-flash.ts +36 -32
  79. package/src/components/ticker/badge/index.tsx +8 -4
  80. package/src/components/ticker/badge/list.tsx +23 -7
  81. package/src/components/ui/column-grid.tsx +8 -2
  82. package/src/components/ui/data-table/opentui/model.ts +4 -1
  83. package/src/components/ui/tabs.tsx +5 -2
  84. package/src/core/state/app/layout.ts +18 -3
  85. package/src/core/state/app/state.ts +2 -0
  86. package/src/core/state/app/types.ts +5 -0
  87. package/src/data/config/layout.ts +3 -0
  88. package/src/data/config/store/normalize.ts +39 -4
  89. package/src/i18n/es.ts +10 -0
  90. package/src/i18n/ja.ts +10 -0
  91. package/src/i18n/ko.ts +10 -0
  92. package/src/i18n/zh-cn.ts +10 -0
  93. package/src/i18n/zh-tw.ts +10 -0
  94. package/src/layout/pane-manager/floating-placement.ts +7 -4
  95. package/src/layout/pane-manager/floating.ts +5 -2
  96. package/src/market-data/bond-funds.ts +19 -0
  97. package/src/market-data/coordinator/events.ts +17 -1
  98. package/src/market-data/frame-scheduler.ts +47 -10
  99. package/src/market-data/frame-wake.ts +74 -0
  100. package/src/market-data/futures-board.ts +7 -6
  101. package/src/market-data/futures-contract.ts +14 -3
  102. package/src/market-data/hooks.tsx +12 -3
  103. package/src/market-data/market/freshness.ts +18 -0
  104. package/src/market-data/market/status.ts +15 -2
  105. package/src/market-data/performance.ts +78 -9
  106. package/src/market-data/request-types.ts +6 -3
  107. package/src/plugins/builtin/alerts/cli.ts +2 -1
  108. package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
  109. package/src/plugins/builtin/attention/evidence.ts +1 -1
  110. package/src/plugins/builtin/awards/client.ts +1 -1
  111. package/src/plugins/builtin/awards/evidence.ts +1 -1
  112. package/src/plugins/builtin/awards/pane.tsx +2 -1
  113. package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
  114. package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
  115. package/src/plugins/builtin/bond-calculator/math.ts +1 -1
  116. package/src/plugins/builtin/bond-calculator/model.ts +14 -5
  117. package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
  118. package/src/plugins/builtin/broker-manager/footer.ts +3 -2
  119. package/src/plugins/builtin/broker-manager/index.tsx +2 -1
  120. package/src/plugins/builtin/broker-manager/keyboard.ts +2 -1
  121. package/src/plugins/builtin/buildout/cells.tsx +25 -45
  122. package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
  123. package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
  124. package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
  125. package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
  126. package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
  127. package/src/plugins/builtin/buildout/format.ts +23 -1
  128. package/src/plugins/builtin/buildout/model/types.ts +1 -0
  129. package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
  130. package/src/plugins/builtin/buildout/table-model.ts +12 -4
  131. package/src/plugins/builtin/catalysts/evidence.ts +1 -1
  132. package/src/plugins/builtin/catalysts/pane.tsx +2 -1
  133. package/src/plugins/builtin/cds/headless.ts +1 -0
  134. package/src/plugins/builtin/cds/index.tsx +1 -1
  135. package/src/plugins/builtin/chart-composer/headless.ts +40 -1
  136. package/src/plugins/builtin/cloud/plugin.tsx +2 -0
  137. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +28 -3
  138. package/src/plugins/builtin/cloud-tweets/table.tsx +3 -2
  139. package/src/plugins/builtin/comment-letters/client.ts +2 -1
  140. package/src/plugins/builtin/company-kpis/client.ts +1 -1
  141. package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
  142. package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
  143. package/src/plugins/builtin/correlation/headless.ts +3 -2
  144. package/src/plugins/builtin/cot/headless.ts +9 -3
  145. package/src/plugins/builtin/cot/model.ts +44 -3
  146. package/src/plugins/builtin/credit-documents/client.ts +1 -1
  147. package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
  148. package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
  149. package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
  150. package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
  151. package/src/plugins/builtin/debt-maturities/model.ts +66 -0
  152. package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
  153. package/src/plugins/builtin/earnings-calls/pane.tsx +1 -1
  154. package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
  155. package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
  156. package/src/plugins/builtin/econ/calendar-model.ts +30 -6
  157. package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
  158. package/src/plugins/builtin/econ/print-watch.ts +3 -1
  159. package/src/plugins/builtin/equity-screener/client.ts +1 -1
  160. package/src/plugins/builtin/equity-screener/criterion-editor.tsx +4 -16
  161. package/src/plugins/builtin/equity-screener/headless.ts +4 -2
  162. package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
  163. package/src/plugins/builtin/equity-screener/model.ts +180 -12
  164. package/src/plugins/builtin/equity-screener/pane.tsx +52 -12
  165. package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
  166. package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
  167. package/src/plugins/builtin/futures/series.ts +16 -1
  168. package/src/plugins/builtin/futures-curve/client.ts +19 -0
  169. package/src/plugins/builtin/futures-curve/headless.ts +52 -13
  170. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  171. package/src/plugins/builtin/futures-curve/model.ts +77 -6
  172. package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
  173. package/src/plugins/builtin/fx-matrix/headless.ts +4 -2
  174. package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
  175. package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
  176. package/src/plugins/builtin/gpu/headless.ts +2 -1
  177. package/src/plugins/builtin/help/function-card.tsx +2 -1
  178. package/src/plugins/builtin/help/index.tsx +2 -1
  179. package/src/plugins/builtin/insider/display.ts +45 -6
  180. package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
  181. package/src/plugins/builtin/iv-history/client.ts +2 -1
  182. package/src/plugins/builtin/iv-history/headless.ts +2 -1
  183. package/src/plugins/builtin/jobs/pages.ts +4 -4
  184. package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
  185. package/src/plugins/builtin/macro-day/client.ts +41 -0
  186. package/src/plugins/builtin/macro-day/headless.ts +19 -9
  187. package/src/plugins/builtin/macro-day/model.ts +3 -1
  188. package/src/plugins/builtin/market-heatmap/index.tsx +2 -1
  189. package/src/plugins/builtin/market-movers/index.tsx +4 -3
  190. package/src/plugins/builtin/members/client.ts +1 -1
  191. package/src/plugins/builtin/mna/distress/client.ts +1 -0
  192. package/src/plugins/builtin/mna/distress/headless.ts +1 -0
  193. package/src/plugins/builtin/mna/pane.tsx +4 -1
  194. package/src/plugins/builtin/options/market-reference.ts +1 -1
  195. package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
  196. package/src/plugins/builtin/options/view.tsx +2 -1
  197. package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
  198. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
  199. package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
  200. package/src/plugins/builtin/options-scenario/csp.ts +28 -9
  201. package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
  202. package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
  203. package/src/plugins/builtin/perps/client.ts +1 -1
  204. package/src/plugins/builtin/perps/pane.tsx +3 -1
  205. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
  206. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
  207. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +4 -2
  208. package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
  209. package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
  210. package/src/plugins/builtin/rate-path/headless.ts +24 -10
  211. package/src/plugins/builtin/research/analyst-model.ts +1 -0
  212. package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
  213. package/src/plugins/builtin/research/event-model.ts +10 -3
  214. package/src/plugins/builtin/research/events-headless.ts +20 -2
  215. package/src/plugins/builtin/research/index.tsx +1 -0
  216. package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
  217. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
  218. package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
  219. package/src/plugins/builtin/research-search/snippet.ts +1 -0
  220. package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
  221. package/src/plugins/builtin/seasonality/headless.ts +2 -1
  222. package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
  223. package/src/plugins/builtin/sec/fund-facts.ts +17 -1
  224. package/src/plugins/builtin/sec/index.tsx +8 -5
  225. package/src/plugins/builtin/sec/row-summaries.ts +28 -12
  226. package/src/plugins/builtin/shared/members-menu.tsx +103 -38
  227. package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
  228. package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
  229. package/src/plugins/builtin/short-interest/watch-client.ts +2 -1
  230. package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
  231. package/src/plugins/builtin/social-mentions/client.ts +2 -1
  232. package/src/plugins/builtin/supply-chain/client.ts +1 -1
  233. package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
  234. package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
  235. package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
  236. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
  237. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
  238. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
  239. package/src/plugins/builtin/time-sales/client.ts +1 -0
  240. package/src/plugins/builtin/time-sales/pane.tsx +3 -2
  241. package/src/plugins/builtin/trace-bonds/client.ts +7 -4
  242. package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
  243. package/src/plugins/builtin/vol-surface/client.ts +2 -1
  244. package/src/plugins/builtin/volatility/client.ts +6 -1
  245. package/src/plugins/builtin/volatility/headless.ts +0 -1
  246. package/src/plugins/builtin/yield-curve/curves.ts +15 -0
  247. package/src/plugins/builtin/yield-curve/headless.ts +9 -2
  248. package/src/plugins/builtin/yield-curve/index.tsx +5 -8
  249. package/src/plugins/host-modules.ts +22 -3
  250. package/src/plugins/host-smoke.ts +6 -3
  251. package/src/portfolio/collection-name.ts +19 -0
  252. package/src/portfolio/column-values.ts +76 -10
  253. package/src/renderers/browser/http-proxy-transport.ts +78 -8
  254. package/src/renderers/cloudflare/http-proxy.ts +13 -2
  255. package/src/renderers/cloudflare/proxy-session.ts +47 -24
  256. package/src/renderers/cloudflare/worker.ts +15 -2
  257. package/src/renderers/desktop/geometry.ts +279 -0
  258. package/src/renderers/desktop/screen-setup.ts +246 -0
  259. package/src/renderers/desktop/sequential-window-host.ts +179 -0
  260. package/src/renderers/desktop/test-utils.ts +71 -0
  261. package/src/renderers/desktop/window-controller.ts +433 -0
  262. package/src/renderers/desktop/window-host.ts +70 -0
  263. package/src/renderers/desktop/window-layouts.ts +630 -0
  264. package/src/renderers/dom/data-frames.ts +15 -4
  265. package/src/renderers/dom/host/box.tsx +204 -176
  266. package/src/renderers/dom/host/style.ts +49 -20
  267. package/src/renderers/dom/host/text.tsx +3 -2
  268. package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
  269. package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
  270. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
  271. package/src/renderers/electrobun/bun/desktop/backend.ts +322 -19
  272. package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
  273. package/src/renderers/electrobun/bun/desktop/host-requests.ts +29 -15
  274. package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
  275. package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
  276. package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
  277. package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
  278. package/src/renderers/electrobun/bun/desktop/windows-script.ts +9 -6
  279. package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
  280. package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
  281. package/src/renderers/electrobun/bun/index.ts +4 -97
  282. package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
  283. package/src/renderers/electrobun/bun/window/focus.ts +0 -25
  284. package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
  285. package/src/renderers/electrobun/bun/window/windows-native.ts +26 -1
  286. package/src/renderers/electrobun/shared/protocol.ts +50 -2
  287. package/src/renderers/electrobun/view/backend-rpc.ts +15 -0
  288. package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
  289. package/src/renderers/electrobun/view/main.tsx +13 -7
  290. package/src/renderers/electrobun/view/ui-host.tsx +7 -0
  291. package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
  292. package/src/series/fred-argument.ts +17 -0
  293. package/src/sources/provider-router/financial-routes.ts +7 -1
  294. package/src/sources/provider-router/index.ts +7 -1
  295. package/src/state/app/context/index.tsx +16 -2
  296. package/src/state/desktop-windows.ts +63 -0
  297. package/src/sync/other-window-tabs.ts +62 -0
  298. package/src/tickers/company-name-listing.ts +23 -3
  299. package/src/tickers/listing-fate.ts +147 -1
  300. package/src/tickers/terminal-codes.ts +5 -0
  301. package/src/time-series/price-units.ts +11 -0
  302. package/src/time-series/types.ts +6 -0
  303. package/src/types/config.ts +10 -1
  304. package/src/types/desktop-window.ts +71 -2
  305. package/src/types/financials.ts +4 -0
  306. package/src/types/headless.ts +19 -0
  307. package/src/types/plugin.ts +6 -0
  308. package/src/ui/host.tsx +2 -0
  309. package/src/ui/index.tsx +14 -13
  310. package/src/ui/same-props.ts +58 -0
  311. package/src/utils/cli-output.ts +33 -4
  312. package/src/utils/currency-names.ts +20 -0
  313. package/src/utils/currency-pair.ts +6 -0
  314. package/src/utils/exchange-rate-snapshot.ts +20 -2
  315. package/src/utils/format.ts +7 -2
  316. package/src/utils/futures-generic.ts +12 -0
  317. package/src/utils/fx-market-hours.ts +43 -0
  318. package/src/utils/http-proxy-upstream.ts +6 -2
  319. package/src/utils/plugin-proxy-hosts.json +0 -4
  320. package/src/utils/plugin-proxy-hosts.ts +22 -0
  321. package/src/utils/sec-filings.ts +7 -1
@@ -17,6 +17,7 @@ import type {
17
17
  import {
18
18
  buildCompositeTimeScale,
19
19
  COMPOSITE_RIGHT_OFFSET_RATIO,
20
+ compositeTimeProjector,
20
21
  projectCompositeTimestamp,
21
22
  unprojectCompositeTimestamp,
22
23
  } from "./time-scale";
@@ -108,10 +109,33 @@ interface NormalizedPointsCache {
108
109
  // the last point in place, so the cache also keys on its time and value.
109
110
  const normalizedPointsCache = new WeakMap<ResolvedSeries, NormalizedPointsCache>();
110
111
 
112
+ /**
113
+ * Points already in time order, one per instant and with no fiscal period,
114
+ * normalise in order: each is its own observation, at its own date. Null for
115
+ * anything else, which goes through the keyed sort.
116
+ */
117
+ function orderedSourcePoints(points: readonly TimeSeriesPoint[]): NormalizedSourcePoint[] | null {
118
+ const normalized: NormalizedSourcePoint[] = [];
119
+ let previous = Number.NEGATIVE_INFINITY;
120
+ for (const point of points) {
121
+ if (point.periodLabel !== undefined) return null;
122
+ const timestamp = pointTime(point);
123
+ if (timestamp === null || timestamp <= previous) return null;
124
+ previous = timestamp;
125
+ normalized.push({ point, timestamp, value: resolveTimeSeriesPointValue(point) });
126
+ }
127
+ return normalized;
128
+ }
129
+
111
130
  function computeNormalizedSourcePoints(
112
131
  series: ResolvedSeries,
113
132
  timeScale?: CompositeTimeScale,
114
133
  ): NormalizedSourcePoint[] {
134
+ // Placed at their own dates, points in time order are already normalised;
135
+ // a live chart re-resolves its series on every tick.
136
+ const effectiveTimes = timeScale?.kind === "market" && !isMarketObservationSeries(series);
137
+ const ordered = effectiveTimes ? null : orderedSourcePoints(series.points);
138
+ if (ordered) return ordered;
115
139
  const byObservation = new Map<string, NormalizedSourcePoint>();
116
140
  for (const point of series.points) {
117
141
  const sourceTimestamp = pointTime(point);
@@ -165,16 +189,34 @@ function normalizedSourcePoints(
165
189
  return normalized;
166
190
  }
167
191
 
168
- function normalizedPoints(series: ResolvedSeries): Array<{
169
- point: TimeSeriesPoint;
170
- timestamp: number;
171
- value: number;
172
- }> {
173
- return normalizedSourcePoints(series).flatMap((entry) => (
174
- entry.value === null
175
- ? []
176
- : [{ ...entry, value: entry.value }]
177
- ));
192
+ function hasDrawableValue(series: ResolvedSeries): boolean {
193
+ return normalizedSourcePoints(series).some((entry) => entry.value !== null);
194
+ }
195
+
196
+ /**
197
+ * The sorted union of timestamp lists that are each sorted, as
198
+ * `[...new Set(lists.flat())].sort()` gives it, merged in one pass.
199
+ */
200
+ function mergeSortedTimestamps(lists: readonly (readonly number[])[]): number[] {
201
+ let merged: number[] = [];
202
+ for (const list of lists) {
203
+ const next: number[] = [];
204
+ let left = 0;
205
+ let right = 0;
206
+ while (left < merged.length || right < list.length) {
207
+ const fromLeft = right >= list.length || (left < merged.length && merged[left]! <= list[right]!);
208
+ const value = fromLeft ? merged[left++]! : list[right++]!;
209
+ if (next.length === 0 || next[next.length - 1] !== value) next.push(value);
210
+ }
211
+ merged = next;
212
+ }
213
+ return merged;
214
+ }
215
+
216
+ function timestampsOf(points: readonly NormalizedSourcePoint[]): number[] {
217
+ const timestamps = new Array<number>(points.length);
218
+ for (let index = 0; index < points.length; index += 1) timestamps[index] = points[index]!.timestamp;
219
+ return timestamps;
178
220
  }
179
221
 
180
222
  function explicitViewport(
@@ -198,10 +240,11 @@ function scopeSeriesToViewport(
198
240
  const placement = timeScale.kind === "market" && !isMarketObservationSeries(series)
199
241
  ? "next-market-slot" as const
200
242
  : "timestamp" as const;
243
+ const project = compositeTimeProjector(timeScale, placement);
201
244
  const visible = points.filter(({ timestamp }) => {
202
245
  if (timestamp >= startTime && timestamp <= endTime) return true;
203
246
  if (clipToViewport) return false;
204
- const projected = projectCompositeTimestamp(timeScale, timestamp, placement);
247
+ const projected = project(timestamp);
205
248
  return !!projected && projected.ratio >= 0 && projected.ratio <= 1;
206
249
  });
207
250
  if (series.interpolation === "step-after" || series.style === "step") {
@@ -271,31 +314,67 @@ export function allocateCompositePanelHeights(
271
314
  return heights;
272
315
  }
273
316
 
274
- function seriesDomainValues(series: ResolvedSeries): number[] {
275
- const values: number[] = [];
317
+ /**
318
+ * The extremes of a set of values, of all of them and of the positive ones a
319
+ * log axis can show, gathered without keeping the values.
320
+ */
321
+ interface DomainExtent {
322
+ count: number;
323
+ min: number;
324
+ max: number;
325
+ positiveCount: number;
326
+ positiveMin: number;
327
+ positiveMax: number;
328
+ }
329
+
330
+ function emptyDomainExtent(): DomainExtent {
331
+ return {
332
+ count: 0,
333
+ min: Number.POSITIVE_INFINITY,
334
+ max: Number.NEGATIVE_INFINITY,
335
+ positiveCount: 0,
336
+ positiveMin: Number.POSITIVE_INFINITY,
337
+ positiveMax: Number.NEGATIVE_INFINITY,
338
+ };
339
+ }
340
+
341
+ function addDomainValue(extent: DomainExtent, value: number): void {
342
+ extent.count += 1;
343
+ extent.min = Math.min(extent.min, value);
344
+ extent.max = Math.max(extent.max, value);
345
+ if (value > 0) {
346
+ extent.positiveCount += 1;
347
+ extent.positiveMin = Math.min(extent.positiveMin, value);
348
+ extent.positiveMax = Math.max(extent.positiveMax, value);
349
+ }
350
+ }
351
+
352
+ /** Every value a series holds its axis open for: its points, their bar extremes or band, and zero under columns. */
353
+ function addSeriesDomainValues(extent: DomainExtent, series: ResolvedSeries): void {
354
+ const ohlc = series.dataShape === "ohlcv";
355
+ const band = !ohlc && series.style === "band";
276
356
  for (const point of series.points) {
277
357
  const scalar = resolveTimeSeriesPointValue(point);
278
- if (scalar !== null) values.push(scalar);
279
- if (series.dataShape === "ohlcv") {
280
- for (const candidate of [point.open, point.high, point.low, point.close]) {
281
- if (isFiniteNumber(candidate)) values.push(candidate);
282
- }
283
- } else if (series.style === "band") {
284
- for (const candidate of [point.high, point.low]) {
285
- if (isFiniteNumber(candidate)) values.push(candidate);
286
- }
358
+ if (scalar !== null) addDomainValue(extent, scalar);
359
+ if (ohlc) {
360
+ if (isFiniteNumber(point.open)) addDomainValue(extent, point.open);
361
+ if (isFiniteNumber(point.high)) addDomainValue(extent, point.high);
362
+ if (isFiniteNumber(point.low)) addDomainValue(extent, point.low);
363
+ if (isFiniteNumber(point.close)) addDomainValue(extent, point.close);
364
+ } else if (band) {
365
+ if (isFiniteNumber(point.high)) addDomainValue(extent, point.high);
366
+ if (isFiniteNumber(point.low)) addDomainValue(extent, point.low);
287
367
  }
288
368
  }
289
- if (series.style === "columns") values.push(0);
290
- return values;
369
+ if (series.style === "columns") addDomainValue(extent, 0);
291
370
  }
292
371
 
293
- function paddedDomain(values: number[], scale: PanelScale): { min: number; max: number } {
294
- const usable = scale === "log" ? values.filter((value) => value > 0) : values;
295
- if (usable.length === 0) return scale === "log" ? { min: 1, max: 10 } : { min: 0, max: 1 };
372
+ function paddedDomain(extent: DomainExtent, scale: PanelScale): { min: number; max: number } {
373
+ const usable = scale === "log" ? extent.positiveCount : extent.count;
374
+ if (usable === 0) return scale === "log" ? { min: 1, max: 10 } : { min: 0, max: 1 };
296
375
 
297
- const rawMin = Math.min(...usable);
298
- const rawMax = Math.max(...usable);
376
+ const rawMin = scale === "log" ? extent.positiveMin : extent.min;
377
+ const rawMax = scale === "log" ? extent.positiveMax : extent.max;
299
378
  if (rawMin === rawMax) {
300
379
  if (scale === "log") {
301
380
  return { min: rawMin / 1.1, max: rawMax * 1.1 };
@@ -342,15 +421,11 @@ function axisPriceReferences(axisSeries: ResolvedSeries[]): Record<string, numbe
342
421
  * session range of the bars, so a quiet session still shows where it opened
343
422
  * from; a far gap leaves the bars their full height.
344
423
  */
345
- function priorCloseInReach(series: readonly ResolvedSeries[], values: readonly number[]): number[] {
424
+ function priorCloseInReach(series: readonly ResolvedSeries[], values: DomainExtent): number[] {
346
425
  const reference = series.find((entry) => isFiniteNumber(entry.priorClose) && entry.points.length > 0)?.priorClose;
347
- if (reference === undefined || values.length === 0) return [];
348
- let low = Number.POSITIVE_INFINITY;
349
- let high = Number.NEGATIVE_INFINITY;
350
- for (const value of values) {
351
- if (value < low) low = value;
352
- if (value > high) high = value;
353
- }
426
+ if (reference === undefined || values.count === 0) return [];
427
+ const low = values.min;
428
+ const high = values.max;
354
429
  const span = high - low;
355
430
  return reference >= low - span && reference <= high + span ? [reference] : [];
356
431
  }
@@ -365,11 +440,16 @@ function buildAxisDomain(
365
440
  ): CompositeAxisDomain | undefined {
366
441
  const axisSeries = series.filter((entry) => entry.axis === side);
367
442
  if (axisSeries.length === 0) return undefined;
368
- const values = axisSeries.flatMap(seriesDomainValues);
443
+ const values = emptyDomainExtent();
444
+ for (const entry of axisSeries) addSeriesDomainValues(values, entry);
369
445
  const references = referenceLevels && axisSeries.some((entry) => entry.id === referenceLevels.seriesId)
370
446
  ? referenceLevels.items.map((level) => level.value).filter(Number.isFinite)
371
447
  : [];
372
- const fitted = paddedDomain([...values, ...priorCloseInReach(axisSeries, values), ...references], scale);
448
+ const extra = [...priorCloseInReach(axisSeries, values), ...references];
449
+ const fitted = paddedDomain(extra.length === 0 ? values : extra.reduce((extent, value) => {
450
+ addDomainValue(extent, value);
451
+ return extent;
452
+ }, { ...values }), scale);
373
453
  const scaleKey = valueScaleKey(scale, axisSeries);
374
454
  // A range set by hand holds while the axis plots the same series and some
375
455
  // of their data is in it; otherwise the axis fits the data again.
@@ -390,6 +470,7 @@ function buildAxisDomain(
390
470
  seriesIds: axisSeries.map((entry) => entry.id),
391
471
  maxTicks: compositeAxisMaxTicks(rows),
392
472
  tickRows: rows,
473
+ ...(first.tickGrid ? { tickGrid: first.tickGrid } : {}),
393
474
  scaleKey,
394
475
  ...(manual ? { manual: true } : {}),
395
476
  };
@@ -463,6 +544,7 @@ function projectSeries(
463
544
  ? "next-market-slot" as const
464
545
  : "timestamp" as const;
465
546
  const stepSeries = series.interpolation === "step-after" || series.style === "step";
547
+ const project = compositeTimeProjector(timeScale, placement);
466
548
  for (const { point, timestamp, value } of normalizedSourcePoints(series, timeScale)) {
467
549
  if (value === null) {
468
550
  breakBefore = true;
@@ -473,7 +555,7 @@ function projectSeries(
473
555
  breakBefore = true;
474
556
  continue;
475
557
  }
476
- const projectedTime = projectCompositeTimestamp(timeScale, timestamp, placement);
558
+ const projectedTime = project(timestamp);
477
559
  if (!projectedTime) continue;
478
560
  const beforeViewportStepAnchor = stepSeries
479
561
  && timestamp < startTime
@@ -667,6 +749,28 @@ function cursorPointForSeries(
667
749
  return points[low - 1] ?? null;
668
750
  }
669
751
 
752
+ /**
753
+ * The latest unavailable observation at or before the cursor and after the
754
+ * value it reads there, which ends that value. Points are in time order, so
755
+ * the search stops at the first one older than that value.
756
+ */
757
+ function gapAfterCursorValue(
758
+ points: readonly NormalizedSourcePoint[],
759
+ cursorTime: number,
760
+ projected: CompositeProjectedPoint | null,
761
+ ): NormalizedSourcePoint | undefined {
762
+ const after = projected?.timestamp ?? Number.NEGATIVE_INFINITY;
763
+ for (let index = points.length - 1; index >= 0; index -= 1) {
764
+ const entry = points[index]!;
765
+ const { timestamp, point, value } = entry;
766
+ if (timestamp < after) return undefined;
767
+ if (timestamp > cursorTime) continue;
768
+ const later = timestamp > after || (timestamp === projected?.timestamp && point.observedAt > projected.point.observedAt);
769
+ if (later && (point.provenance?.priceHistoryIntegrity || value === null)) return entry;
770
+ }
771
+ return undefined;
772
+ }
773
+
670
774
  function buildCursorValues(
671
775
  panels: CompositePanelScene[],
672
776
  cursorDate: Date | null,
@@ -688,11 +792,7 @@ function buildCursorValues(
688
792
  let projected = cursorPointForSeries(entry, cursorTime);
689
793
  // Sparse observations can carry forward, but an explicitly unavailable
690
794
  // observation ends that value at its date, including the idle legend.
691
- const gap = normalizedSourcePoints(entry.source, viewport.timeScale).findLast(({ timestamp, point, value }) => (
692
- timestamp <= cursorTime && (timestamp > (projected?.timestamp ?? Number.NEGATIVE_INFINITY)
693
- || (timestamp === projected?.timestamp && point.observedAt > projected.point.observedAt))
694
- && (point.provenance?.priceHistoryIntegrity || value === null)
695
- ));
795
+ const gap = gapAfterCursorValue(normalizedSourcePoints(entry.source, viewport.timeScale), cursorTime, projected);
696
796
  if (gap) projected = null;
697
797
  // The drawn navigation buffer can include observations after the chosen
698
798
  // end. An unarmed legend describes the active window, including when the
@@ -799,13 +899,12 @@ export function buildCompositeChartScene(
799
899
  ): CompositeChartScene | null {
800
900
  const dataSeries = series
801
901
  .map((entry) => entry.style === "heikin-ashi" ? { ...entry, points: heikinAshiPoints(entry.points) } : entry)
802
- .filter((entry) => normalizedPoints(entry).length > 0);
902
+ .filter(hasDrawableValue);
803
903
  if (dataSeries.length === 0) return null;
804
904
 
805
905
  // A known missing observation owns a date even though it has no drawable
806
906
  // value. Retain it in the window and cursor timeline, including trailing gaps.
807
- const times = dataSeries.flatMap((entry) => normalizedSourcePoints(entry).map((point) => point.timestamp));
808
- const uniqueTimes = [...new Set(times)].sort((left, right) => left - right);
907
+ const uniqueTimes = mergeSortedTimestamps(dataSeries.map((entry) => timestampsOf(normalizedSourcePoints(entry))));
809
908
  if (uniqueTimes.length === 0) return null;
810
909
  const firstTime = uniqueTimes[0]!;
811
910
  const lastTime = uniqueTimes.at(-1)!;
@@ -844,15 +943,12 @@ export function buildCompositeChartScene(
844
943
  // observation must remain inspectable. Other exchanges can trade before
845
944
  // or after its anchors. Nonmarket source dates stay excluded: filings
846
945
  // retain their availability-based placement on eligible market slots.
847
- ? [...new Set([
848
- ...timeScale.anchors.map(({ timestamp }) => timestamp),
946
+ ? mergeSortedTimestamps([
947
+ timeScale.anchors.map(({ timestamp }) => timestamp),
849
948
  ...scopedSeries.filter(isMarketObservationSeries)
850
- .flatMap((entry) => normalizedSourcePoints(entry)
851
- .filter(({ value, point }) => value !== null || point.provenance?.priceHistoryIntegrity)
852
- .map(({ timestamp }) => timestamp)),
853
- ])]
854
- .filter((time) => time >= startTime && time <= plotEndTime)
855
- .sort((left, right) => left - right)
949
+ .map((entry) => timestampsOf(normalizedSourcePoints(entry)
950
+ .filter(({ value, point }) => value !== null || point.provenance?.priceHistoryIntegrity))),
951
+ ]).filter((time) => time >= startTime && time <= plotEndTime)
856
952
  : [];
857
953
  const cursorTimes = timeScale.kind === "market" ? marketTimes : visibleTimes;
858
954
  const dates = (cursorTimes.length > 0
@@ -861,9 +957,8 @@ export function buildCompositeChartScene(
861
957
  ? [...new Set([startTime, endTime])]
862
958
  : uniqueTimes
863
959
  ).map((time) => new Date(time));
864
- const dateRatios = dates.map((date) => (
865
- projectCompositeTimestamp(timeScale, date.getTime())?.ratio ?? 0
866
- ));
960
+ const projectDate = compositeTimeProjector(timeScale);
961
+ const dateRatios = dates.map((date) => projectDate(date.getTime())?.ratio ?? 0);
867
962
  const requestedCursor = options.cursorDate ?? null;
868
963
  const cursorDate = requestedCursor ? nearestDate(dates, requestedCursor) : null;
869
964
  const cursorXRatio = cursorDate
@@ -1,3 +1,4 @@
1
+ import { memo } from "react";
1
2
  import { Box, Text } from "../../../ui";
2
3
  import { clamp } from "../../../utils/math";
3
4
  import type { SeriesAxisTag } from "./panel-labels";
@@ -28,7 +29,8 @@ export function placeSeriesAxisTags(tags: readonly SeriesAxisTag[], pixelHeight:
28
29
  return placed;
29
30
  }
30
31
 
31
- export function SeriesAxisTags({ placed, pixelHeight, lanes, background }: {
32
+ /** Each series' value at the cursor, beside the axis; it renders when they move, not with the pointer's height. */
33
+ export const SeriesAxisTags = memo(function SeriesAxisTags({ placed, pixelHeight, lanes, background }: {
32
34
  placed: ReturnType<typeof placeSeriesAxisTags>;
33
35
  pixelHeight: number;
34
36
  lanes: number;
@@ -71,4 +73,4 @@ export function SeriesAxisTags({ placed, pixelHeight, lanes, background }: {
71
73
  </Box>
72
74
  </Box>;
73
75
  });
74
- }
76
+ });
@@ -349,13 +349,21 @@ function lowerBoundSample(samples: readonly CompositeTimeAxisSample[], timestamp
349
349
  }
350
350
 
351
351
  function normalizeMarketSamples(scene: CompositeChartScene): CompositeTimeAxisSample[] {
352
- const samples = scene.dates.flatMap((date, index) => {
352
+ const samples: CompositeTimeAxisSample[] = [];
353
+ // A scene's dates come in time order, their ratios rising with them.
354
+ let ordered = true;
355
+ scene.dates.forEach((date, index) => {
353
356
  const timestamp = date.getTime();
354
357
  const ratio = scene.dateRatios[index];
355
- return validTimestamp(timestamp) && typeof ratio === "number" && Number.isFinite(ratio)
356
- ? [{ timestamp, ratio: clamp(ratio, 0, 1) }]
357
- : [];
358
- }).sort((left, right) => left.timestamp - right.timestamp || left.ratio - right.ratio);
358
+ if (!validTimestamp(timestamp) || typeof ratio !== "number" || !Number.isFinite(ratio)) return;
359
+ const sample = { timestamp, ratio: clamp(ratio, 0, 1) };
360
+ const previous = samples[samples.length - 1];
361
+ if (previous && (previous.timestamp > timestamp || (previous.timestamp === timestamp && previous.ratio > sample.ratio))) {
362
+ ordered = false;
363
+ }
364
+ samples.push(sample);
365
+ });
366
+ if (!ordered) samples.sort((left, right) => left.timestamp - right.timestamp || left.ratio - right.ratio);
359
367
 
360
368
  return samples.filter((sample, index) => (
361
369
  index === 0
@@ -492,6 +500,17 @@ function addCandidate(
492
500
  if (!duplicate) candidates.push(candidate);
493
501
  }
494
502
 
503
+ /**
504
+ * Blank cells a regular tick keeps from the start and end labels: half the
505
+ * room between two ticks, from 3 to 5 cells. Those two are the longest labels
506
+ * on the axis (a date with its year), and a tick closer than that reads as a
507
+ * part of one ("Oct Oct 29 2026") instead of a mark of its own.
508
+ */
509
+ function endpointLabelGap(interval: CompositeTimeAxisInterval, span: number, axisWidth: number): number {
510
+ const tickRoom = (axisWidth * interval.approximateMs) / span;
511
+ return clamp(Math.round(tickRoom / 2), 3, 5);
512
+ }
513
+
495
514
  function layoutTimeAxis({
496
515
  startTime,
497
516
  endTime,
@@ -641,6 +660,9 @@ function layoutTimeAxis({
641
660
  const minimumGap = interval.unit === "month" || interval.unit === "year" ? 2 : 1;
642
661
  let previousTimestamp = firstTimestamp;
643
662
  let previousEnd = startLabel.length - 1;
663
+ const endpointGap = endpointLabelGap(interval, span, axisWidth);
664
+ // The first tick follows the start label, the rest follow a tick.
665
+ let previousGap = endpointGap;
644
666
  for (const candidate of candidates.filter((entry) => !entry.boundary)) {
645
667
  const label = formatInteriorLabel(candidate.timestamp, previousTimestamp, interval, clock);
646
668
  // A year boundary inside the final year would repeat the right endpoint's year.
@@ -648,8 +670,8 @@ function layoutTimeAxis({
648
670
  const center = candidate.ratio * Math.max(axisWidth - 1, 0);
649
671
  const start = resolveLabelStart(center, label, axisWidth);
650
672
  const end = start + label.length - 1;
651
- if (start <= previousEnd + minimumGap) continue;
652
- if (end >= endStart - minimumGap) continue;
673
+ if (start <= previousEnd + previousGap) continue;
674
+ if (end >= endStart - endpointGap) continue;
653
675
  writeLabel(axis, start, label);
654
676
  placed.push({
655
677
  timestamp: candidate.timestamp,
@@ -660,6 +682,7 @@ function layoutTimeAxis({
660
682
  });
661
683
  previousTimestamp = candidate.timestamp;
662
684
  previousEnd = end;
685
+ previousGap = minimumGap;
663
686
  }
664
687
 
665
688
  writeLabel(axis, endStart, endLabel);