@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
@@ -1,3 +1,4 @@
1
+ import { splitShareTerms } from "../../market-data/split-terms";
1
2
  import { logFailure } from "../../utils/log-failure";
2
3
  import { isTransientFailure } from "../../api-client/errors";
3
4
  import { normalizeTickerSymbol } from "../../tickers/search/ranking";
@@ -14,10 +15,12 @@ import { shortStoryId } from "../../news/story-id";
14
15
  import type {
15
16
  AnalystResearchData,
16
17
  CorporateActionsData,
18
+ DemergerAction,
17
19
  HolderData,
18
20
  OptionsChain,
19
21
  PricePoint,
20
22
  Quote,
23
+ SplitAction,
21
24
  TickerFinancials,
22
25
  } from "../../types/financials";
23
26
  import { currencyPriceMinDigits, formatMarketPrice, formatMarketPriceWithCurrency, nearParCoinPriceDigits, penceFigure, quoteFormatOptions, withCurrencyMinorDigits } from "../../market-data/market/format";
@@ -125,7 +128,7 @@ import {
125
128
  } from "../../utils/exchange-announcements";
126
129
  import { dailyFxLeg, fxCloseOnDate, fxCloseOnOrBefore, loadDailyFxCloses, type FxCloseReading } from "../../market-data/fx-closes";
127
130
  import { zonedDateTimeParts } from "../../utils/zoned-date-time";
128
- import { declaredDividends } from "../../utils/declared-dividends";
131
+ import { declaredDividendCash, declaredDividends } from "../../utils/declared-dividends";
129
132
  import {
130
133
  DEFAULT_LEAPS_CRITERIA, LEAPS_EXTRA_COLUMNS, LEAPS_USAGE, parseLeapsCriteria, runLeapsScreen, takeLeapsOptions,
131
134
  } from "./options-leaps";
@@ -141,6 +144,7 @@ import {
141
144
  import { historyCoverageNotice, WindowBeforeFirstBarError } from "../../sources/history-coverage";
142
145
  import { fetchHistoryResult } from "../../sources/history-result";
143
146
  import { settleWithin } from "../../utils/async-deadline";
147
+ import { demergerRuns, demergerSuccessor, hasPriceBreak, historyDemergerNote, withDemergerFlags } from "../history-demergers";
144
148
  import type { FxInterventionsPayload } from "../../api-client/fx-interventions";
145
149
  import {
146
150
  fxInterventionLatestNote, fxInterventionPair, fxInterventionWindowNote, loadFxInterventions, type FxInterventionPair,
@@ -285,6 +289,7 @@ import {
285
289
  failUnchosenListing,
286
290
  futureByWordLine,
287
291
  loadBareVenues,
292
+ isMovedSymbolFailure,
288
293
  loadForListing,
289
294
  ownedCodeNotes,
290
295
  loadListingQuote,
@@ -331,7 +336,7 @@ import { secRegistrantMismatchMessage, SecRegistrantMismatchError, areDifferentC
331
336
  import { isCryptoPairSymbol, isRoundTheClockCoin } from "../../utils/crypto-pair";
332
337
  import { canonicalExchange, isUsListingExchange } from "../../utils/exchanges";
333
338
  import { listingSuffixVenue } from "../../sources/listing-symbols";
334
- import { resolveTickerInstrumentKind } from "../../tickers/instrument-kind";
339
+ import { classifyInstrumentType, resolveTickerInstrumentKind } from "../../tickers/instrument-kind";
335
340
  import {
336
341
  describeFormerIssuer, describeTickerChange, movedAwayChange, startTickerChangeLookup, tickerChangeLine, type FormerIssuer, type TickerChange,
337
342
  } from "../../tickers/ticker-changes";
@@ -1107,6 +1112,13 @@ function cleanDecimal(value: number | undefined): string {
1107
1112
  return value == null || !Number.isFinite(value) ? "" : String(Number(value.toFixed(6)));
1108
1113
  }
1109
1114
 
1115
+ /** "commercial vehicles into TMCV:NSE (Tata Motors Limited), 1 share per share, listed 2025-11-12". */
1116
+ function demergerDetail(event: DemergerAction): string {
1117
+ return [`${event.business ? `${event.business} ` : ""}into ${demergerSuccessor(event)}`,
1118
+ event.ratio ? `${cleanDecimal(event.ratio)} share per share` : null,
1119
+ event.successor.listedOn ? `listed ${event.successor.listedOn}` : "not yet listed"].filter(Boolean).join(", ");
1120
+ }
1121
+
1110
1122
  function corporateActionRows(data: CorporateActionsData) {
1111
1123
  const currency = /^[A-Z]{3}$/.test(data.currency ?? "") ? data.currency! : null;
1112
1124
  // EPS is in the reporting currency, which can differ from the listing's dividends (Tencent: CNY vs HKD).
@@ -1147,16 +1159,27 @@ function corporateActionRows(data: CorporateActionsData) {
1147
1159
  detail: currency ? formatDistributionAmount(event.amount, currency) : cleanDecimal(event.amount),
1148
1160
  })),
1149
1161
  // Declared and unpaid, at its ex-date beside the paid rows, never one of them.
1150
- ...declaredDividends(data).map((event) => ({
1151
- type: "dividend",
1152
- date: event.exDate,
1153
- detail: `declared ${event.special ? "special " : ""}${currency ? formatDistributionAmount(event.amount, currency) : cleanDecimal(event.amount)}`
1154
- + (event.payDate ? `, payable ${event.payDate}` : ""),
1155
- })),
1162
+ ...declaredDividends(data).map((event) => {
1163
+ const cash = declaredDividendCash(event, currency);
1164
+ return {
1165
+ type: "dividend",
1166
+ date: event.exDate,
1167
+ detail: `declared ${event.special ? "special " : ""}${currency || event.cashEstimate ? cash.amount : cleanDecimal(event.amount)}${cash.estimate ? `, ${cash.estimate}` : ""}`
1168
+ + (event.payDate ? `, payable ${event.payDate}` : ""),
1169
+ ...(event.cashEstimate ? { cashEstimate: event.cashEstimate } : {}),
1170
+ };
1171
+ }),
1172
+ // In share terms where the factor states them (11-for-10, 1 new share for every 10 held), else as its source writes it.
1156
1173
  ...data.splits.map((event) => ({
1157
1174
  type: "split",
1158
1175
  date: event.date,
1159
- detail: event.description ?? `${event.fromFactor ?? ""}:${event.toFactor ?? ""}`,
1176
+ detail: splitShareTerms(event) ?? event.description ?? `${event.toFactor ?? ""}:${event.fromFactor ?? ""}`,
1177
+ })),
1178
+ // A business demerged out of the listing: its price fell by that business's value on the day, no market move.
1179
+ ...(data.demergers ?? []).map((event) => ({
1180
+ type: "demerger",
1181
+ date: event.exDate,
1182
+ detail: demergerDetail(event),
1160
1183
  })),
1161
1184
  ].sort((left, right) => right.date.localeCompare(left.date));
1162
1185
  }
@@ -1874,6 +1897,8 @@ interface ListingHistory {
1874
1897
  fx?: HistoryConversion;
1875
1898
  /** A catalog series (`CAP:bond-yield:jp-10y`) read beside listings: its values are in `close`, and are no price. */
1876
1899
  catalogSeries?: true;
1900
+ /** The bars a business was demerged out of the listing at (flag `demerger`): a drawdown is measured within the runs between them. */
1901
+ demergers?: Array<{ date: string; action: DemergerAction }>;
1877
1902
  }
1878
1903
 
1879
1904
  /**
@@ -2162,7 +2187,10 @@ async function loadListingHistory(
2162
2187
  const identity = listingIdentity(listing, quote);
2163
2188
  // Without a quote currency, the listing metadata research reads (as `ticker` does) may still state it.
2164
2189
  const listed = quote?.currency ? quote : await market.dataProvider.getQuoteMetadata?.(symbol, exchange).catch(logFailure("cli.commands-market", "Read quote metadata for history failed", null));
2165
- const unit = historyUnit(listing.key, listed ?? quote, await priceUnit);
2190
+ // With neither, the currency the listing was saved with from search (TMPV on NSE trades in INR) still names the unit.
2191
+ const savedCurrency = listing.saved?.metadata.currency?.trim();
2192
+ const unit = historyUnit(listing.key, listed?.currency || quote?.currency || !savedCurrency ? listed ?? quote
2193
+ : { ...listed ?? quote ?? {}, currency: savedCurrency }, await priceUnit);
2166
2194
  const mostTraded = /=F$/i.test(listing.symbol) && (await futuresTerms)?.roll?.mostTraded === true;
2167
2195
  const traded = {
2168
2196
  listing: listing.key, exchange: quote?.listingExchangeName || exchange || undefined, instrumentType: quote?.instrumentType,
@@ -2191,7 +2219,15 @@ async function loadListingHistory(
2191
2219
  const forming = formingPeriodBar(served, venue);
2192
2220
  // A complete one is dated by the day its last session closed, the day its close is from.
2193
2221
  const closedDay = forming ? null : closedPeriodBarDay(served, venue);
2194
- const data = forming?.rows ?? served;
2222
+ // A close that falls a fifth or more below the one before can be a business demerged out of the listing (TMPV's
2223
+ // commercial vehicles on 2025-10-14): its corporate actions say, and that bar is flagged rather than read as a crash.
2224
+ // One read of the listing's corporate actions serves both, asked only for a share or a fund.
2225
+ const actions = shareActionsReader(market, listing, instrumentType);
2226
+ const demerged = await listingDemergerFlags(forming?.rows ?? served, actions);
2227
+ const data = demerged.rows;
2228
+ // NFLX's bars across its 10-for-1 split are in post-split shares, as META's FB-era bars say they were FB's. A long
2229
+ // list skips the read, as it skips the other lookups.
2230
+ const splitNote = lookups ? historySplitNote(listing.symbol, data, await actions.splits()) : null;
2195
2231
  const interval = data[0]?.interval ?? null;
2196
2232
  // Intraday bars print in UTC, as the charts and time and sales label them, not the host zone.
2197
2233
  const intraday = data.some((row) => row.date.length > 10);
@@ -2253,15 +2289,71 @@ async function loadListingHistory(
2253
2289
  historyVenueVolumeNote(data) ?? [],
2254
2290
  // NG=F's rows are November's to the 23rd and December's from the 26th: each roll named, and thin bars said.
2255
2291
  historyRollNote(listing.symbol, data, { mostTraded }) ?? [], historyThinNote(data) ?? [],
2292
+ historyDemergerNote(data, demerged.breaks, historyPrice(historyPriceDecimals(data, listing.saved?.metadata.assetCategory, priceDivisor))) ?? [],
2293
+ splitNote ?? [],
2256
2294
  historyBarStatusNote(forming ? served : data, { tradingDay: venueTradingDay(venue, Date.now()) }) ?? [],
2257
2295
  await interventionWindowNote(interventions, interventionPair, data) ?? [],
2258
2296
  ].flat();
2259
2297
  return {
2260
2298
  listing, identity, unit, data, resolution, interval, intraday, volume, freshness, notes, mostTraded,
2261
2299
  decimals: historyPriceDecimals(data, listing.saved?.metadata.assetCategory, priceDivisor),
2300
+ ...demerged.breaks.length > 0 ? { demergers: demerged.breaks } : {},
2262
2301
  };
2263
2302
  }
2264
2303
 
2304
+ /** How long a history waits for the corporate actions it reads beside a price break; the bars are served without them after. */
2305
+ const DEMERGER_READ_WAIT_MS = 3_000;
2306
+
2307
+ /**
2308
+ * A listing's corporate actions, read at most once and only for a share or a fund: a future, a pair or an index has
2309
+ * no business to split or demerge. `splits` reads them for the bars' splits; `demergers` only once a close has fallen
2310
+ * a fifth or more (hasPriceBreak). Fails soft, and waits no longer than DEMERGER_READ_WAIT_MS.
2311
+ */
2312
+ function shareActionsReader(market: MarketContext, listing: CliListing, instrumentType: string | undefined) {
2313
+ const kind = classifyInstrumentType(instrumentType ?? "");
2314
+ const share = (kind === "equity" || kind === "fund" || !instrumentType)
2315
+ && !isFuturesInstrument(listing.symbol, instrumentType ?? null) && !isCurrencyPairListing(listing.symbol, listing.request.exchange)
2316
+ && typeof market.dataProvider.getCorporateActions === "function";
2317
+ let read: Promise<CorporateActionsData | null> | null = null;
2318
+ const actions = () => read ??= settleWithin(Promise.resolve().then(() => market.dataProvider.getCorporateActions!(listing.request.symbol, listing.request.exchange))
2319
+ .catch(logFailure("cli.commands-market", "Read corporate actions for a history failed", null)), DEMERGER_READ_WAIT_MS)
2320
+ .then((value) => value ?? null);
2321
+ return {
2322
+ share,
2323
+ splits: async (): Promise<SplitAction[]> => share ? (await actions())?.splits ?? [] : [],
2324
+ demergers: async (): Promise<DemergerAction[]> => share ? (await actions())?.demergers ?? [] : [],
2325
+ };
2326
+ }
2327
+
2328
+ /** A share's bars with the bar each demerger falls in flagged (withDemergerFlags), read only when a close falls a fifth or more below the one before. */
2329
+ async function listingDemergerFlags(
2330
+ rows: HistoryRow[],
2331
+ actions: ReturnType<typeof shareActionsReader>,
2332
+ ): Promise<{ rows: HistoryRow[]; breaks: Array<{ date: string; action: DemergerAction }> }> {
2333
+ if (!actions.share || !hasPriceBreak(rows)) return { rows, breaks: [] };
2334
+ return withDemergerFlags(rows, await actions.demergers());
2335
+ }
2336
+
2337
+ /**
2338
+ * "Splits in range: NFLX 10-for-1 on 2025-11-17; bars before it are split-adjusted.": the splits that took effect
2339
+ * after the first bar shown and by the last, which the bars run across in post-split shares. Null with none, or for
2340
+ * a factor no share count states (a spinoff's price adjustment, which the demerger note covers).
2341
+ */
2342
+ function historySplitNote(symbol: string, rows: readonly HistoryRow[], splits: readonly SplitAction[]): string | null {
2343
+ const first = rows[0]?.date.slice(0, 10);
2344
+ const last = rows.at(-1)?.date.slice(0, 10);
2345
+ if (!first || !last || first === last) return null;
2346
+ const inside = splits
2347
+ .filter((split) => /^\d{4}-\d{2}-\d{2}/.test(split.date) && split.date.slice(0, 10) > first && split.date.slice(0, 10) <= last)
2348
+ .sort((left, right) => left.date.localeCompare(right.date))
2349
+ .flatMap((split) => {
2350
+ const terms = splitShareTerms(split);
2351
+ return terms ? [`${terms.split(",")[0]} on ${split.date.slice(0, 10)}`] : [];
2352
+ });
2353
+ if (inside.length === 0) return null;
2354
+ return `Splits in range: ${symbol} ${inside.join(" and ")}; bars before ${inside.length === 1 ? "it" : "each"} are split-adjusted.`;
2355
+ }
2356
+
2265
2357
  /**
2266
2358
  * A bare symbol with no quote whose US listing stopped trading is that
2267
2359
  * listing's history: a source can answer the bare symbol with a listing
@@ -2465,13 +2557,19 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
2465
2557
  const closes = (interval === "1wk" || interval === "1mo"
2466
2558
  ? data.map((row) => ({ ...row, date: barCloseSession(interval, row.date, identity.exchange || undefined, Date.now()) }))
2467
2559
  : data).filter((row) => !row.flag?.split(",").includes(CLOSE_COPIED_FLAG));
2468
- const contractDrawdown = historyContractDrawdown(closes, yieldUnits ? "yield" : "return");
2560
+ // Nor from a close that held a business the listing demerged to one that did not (TMPV before 2025-10-14): split
2561
+ // before each bar flagged `demerger`, whatever date its close is given, and named by the demerger's own day.
2562
+ const demergedOn = history.demergers?.map((entry) => entry.action.exDate) ?? [];
2563
+ const contractDrawdown = demergedOn.length > 0
2564
+ ? deepestRunDrawdown(demergerRuns(closes).map((run) => historyContractDrawdown(run, yieldUnits ? "yield" : "return")))
2565
+ : historyContractDrawdown(closes, yieldUnits ? "yield" : "return");
2469
2566
  // A window's last week can close after the dates asked for (--to 2003, a week ending Fri 2 Jan 2004): measured to its end.
2470
2567
  const until = ask.window?.to;
2471
2568
  const drawdown = contractDrawdown ? measuredUntil(contractDrawdown.drawdown, until) : null;
2472
2569
  const rose = yieldUnits ? maxRunUp(closes) : null;
2473
2570
  const runUp = rose && measuredUntil(rose, until);
2474
- const moveText = interval ? { basis: `${BAR_INTERVAL_LABELS[interval]} closes${contractDrawdown?.contract ? `, ${contractDrawdown.contract}` : ""}`, price,
2571
+ const across = demergedOn.length > 0 ? `, not across the ${demergedOn.join(" and ")} ${demergedOn.length === 1 ? "demerger" : "demergers"}` : "";
2572
+ const moveText = interval ? { basis: `${BAR_INTERVAL_LABELS[interval]} closes${contractDrawdown?.contract ? `, ${contractDrawdown.contract}` : ""}${across}`, price,
2475
2573
  date: (text: string) => intraday ? formatUtcTime(text) : text.slice(0, 10) } : null;
2476
2574
  ctx.printResult({
2477
2575
  data,
@@ -2490,6 +2588,7 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
2490
2588
  unbrokenFrom: historyUnbrokenFrom(data) ?? data[0]?.date ?? null,
2491
2589
  bars: data.length,
2492
2590
  maxDrawdown: drawdown && contractDrawdown?.contract ? { ...drawdown, contract: contractDrawdown.contract } : drawdown,
2591
+ ...(history.demergers ? { demergers: history.demergers.map(({ date, action }) => ({ bar: date, ...action })) } : {}),
2493
2592
  ...(runUp ? { maxRunUp: runUp } : {}),
2494
2593
  asOf: freshness?.asOf ?? null,
2495
2594
  ...(history.fx ? { converted: history.fx } : {}),
@@ -2514,6 +2613,12 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
2514
2613
  });
2515
2614
  }
2516
2615
 
2616
+ /** The deepest of the drawdowns measured within each run between demergers. */
2617
+ function deepestRunDrawdown(runs: ReadonlyArray<ReturnType<typeof historyContractDrawdown>>): ReturnType<typeof historyContractDrawdown> {
2618
+ const depth = (entry: NonNullable<ReturnType<typeof historyContractDrawdown>>) => entry.drawdown.bp ?? entry.drawdown.drawdown;
2619
+ return runs.reduce<ReturnType<typeof historyContractDrawdown>>((deepest, run) => run && (!deepest || depth(run) < depth(deepest)) ? run : deepest, null);
2620
+ }
2621
+
2517
2622
  /** The window from `years` back to today. */
2518
2623
  function yearsBackWindow(years: number): PriceWindow | null {
2519
2624
  const from = new Date();
@@ -2992,9 +3097,15 @@ async function runFinancials(rawArgs: string[], ctx: Parameters<CliCommandDef["e
2992
3097
  await withMarketData(ctx, async (market) => {
2993
3098
  const listing = await requireCliListing(raw, exchangeOption, market, ctx);
2994
3099
  const venues = loadBareVenues(listing, market);
2995
- const loaded = await loadForListing(listing, market, ctx, () => market.dataProvider.getTickerFinancials(
3100
+ // The statements carry the listing's quote: what says whether the line can have moved, with no read of its own.
3101
+ const read = market.dataProvider.getTickerFinancials(
2996
3102
  listing.request.symbol, listing.request.exchange, { cacheMode: ctx.cliOptions.refresh ? "refresh" : "default" },
2997
- ), undefined, { command: commandName, noun: commandName === "valuation" ? "valuation data" : commandName });
3103
+ );
3104
+ const loaded = await loadForListing(listing, market, ctx, () => read, undefined,
3105
+ { command: commandName, noun: commandName === "valuation" ? "valuation data" : commandName, quote: read.then((found) => found.quote ?? null, () => {
3106
+ // Intentional ignore: this is the same read loadForListing awaits as the command's load, which reports its failure.
3107
+ return null;
3108
+ }) });
2998
3109
  // A converted TTM block at the rate `fx` reports, as `ticker` shows it; only the US dollar legs are read.
2999
3110
  // A withdrawn EV's bridge converts a balance sheet in another currency at our close on its date (withBalanceSheetRate).
3000
3111
  const financials = view === "statements" ? loaded
@@ -3478,7 +3589,7 @@ async function runFilings(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
3478
3589
  hidden = shown.hidden;
3479
3590
  return shown.filings;
3480
3591
  }),
3481
- (found) => found.length === 0),
3592
+ (found) => found.length === 0, { command: form ? `filings --form ${form}` : "filings", noun: "SEC filings", quote: quotePromise }),
3482
3593
  quotePromise,
3483
3594
  ]);
3484
3595
  const hiddenNote = hidden ? hiddenFilingsNote(hidden) : null;
@@ -3706,7 +3817,8 @@ async function printBeneficialOwners(
3706
3817
  const abroad = nonUsSecListingVenue(symbol, exchange) ? listingIdentity(listing, await quotePromise) : null;
3707
3818
  const request = { form: beneficialRouteForm(form), history, listing: { exchange, name: abroad?.name ?? undefined } };
3708
3819
  const [payload, holders, quote, financials] = await Promise.all([
3709
- loadForListing(listing, market, ctx, () => fetchBeneficialOwners(symbol, request)),
3820
+ loadForListing(listing, market, ctx, () => fetchBeneficialOwners(symbol, request), undefined,
3821
+ { command: `holders --form ${form}${history ? " --history" : ""}`, noun: "beneficial owners", quote: quotePromise }),
3710
3822
  market.dataProvider.getHolders?.(symbol, exchange).catch(logFailure("cli.commands-market", "Read company holders failed", null)) ?? null,
3711
3823
  quotePromise,
3712
3824
  // Today's share count, which the filed percents are set against.
@@ -3790,8 +3902,10 @@ async function runHolders(
3790
3902
  listing, market, ctx,
3791
3903
  () => market.dataProvider.getHolders(listing.request.symbol, listing.request.exchange),
3792
3904
  (found) => found.holders.length === 0,
3793
- { command: commandName, noun: "holder data" },
3905
+ { command: commandName, noun: "holder data", quote: quoted },
3794
3906
  ).catch(async (error: unknown) => {
3907
+ // A symbol whose company moved names its new symbol, as every command does.
3908
+ if (isMovedSymbolFailure(error)) throw error;
3795
3909
  // A fund has no ownership breakdown, and a listing may have no holders on record: say so
3796
3910
  // (and what reads a fund) rather than the source's NO_DATA.
3797
3911
  const none = await noHoldersAnswer(listing.key, listing.request.exchange, error, await quoted, apiClient);
@@ -3923,13 +4037,14 @@ async function runAnalyst(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
3923
4037
  await withMarketData(ctx, async (market) => {
3924
4038
  const listing = await requireCliListing(raw, exchangeOption, market, ctx);
3925
4039
  const venues = loadBareVenues(listing, market);
4040
+ const quoted = loadListingQuote(market.dataProvider, listing);
3926
4041
  const [data, quote] = await Promise.all([
3927
4042
  loadForListing(
3928
4043
  // A listing no analyst covers loads as research with nothing in it, said below rather than failed.
3929
4044
  listing, market, ctx, () => loadAnalystResearch(market.dataProvider, listing.request.symbol, listing.request.exchange),
3930
- undefined, { command: "analyst", noun: "analyst research" },
4045
+ undefined, { command: "analyst", noun: "analyst research", quote: quoted },
3931
4046
  ),
3932
- loadListingQuote(market.dataProvider, listing),
4047
+ quoted,
3933
4048
  ]);
3934
4049
  const identity = listingIdentity(listing, quote);
3935
4050
  const choice = await listingChoiceNotes(listing, market, quote, venues);
@@ -3980,12 +4095,13 @@ async function runEvents(rawArgs: string[], ctx: Parameters<CliCommandDef["execu
3980
4095
  // The earnings rows are resolved against the calendar `earnings` reads, so the next report is the same in both.
3981
4096
  const calendar = market.dataProvider.getEarningsCalendar?.([listing.key])
3982
4097
  .catch(logFailure("cli.commands-market", "Read the earnings calendar for events failed", [] as EarningsEvent[]));
4098
+ const quoted = loadListingQuote(market.dataProvider, listing);
3983
4099
  const [recorded, quote, events] = await Promise.all([
3984
4100
  loadForListing(
3985
4101
  listing, market, ctx, () => market.dataProvider.getCorporateActions(listing.request.symbol, listing.request.exchange),
3986
- undefined, { command: "events", noun: "corporate events" },
4102
+ undefined, { command: "events", noun: "corporate events", quote: quoted },
3987
4103
  ),
3988
- loadListingQuote(market.dataProvider, listing),
4104
+ quoted,
3989
4105
  calendar,
3990
4106
  ]);
3991
4107
  const data = withResolvedEarnings(recorded, calendarEventOf(events, listing.key), newYorkDay());
@@ -4,7 +4,8 @@ import { ApiRequestError } from "../../api-client/errors";
4
4
  import type { CliCommandDef } from "../../types/plugin";
5
5
  import { withCliServices, withConfigData, withMarketData } from "../context";
6
6
  import { CLI_ERROR_CODE, failWithFields } from "../errors";
7
- import type { CliResultColumn } from "../result";
7
+ import type { CliResult, CliResultColumn, CliResultRenderOptions } from "../result";
8
+ import { fredCitation, fredPublisher } from "../../sources/gloomberb-cloud/fred-publisher";
8
9
  import { MISSING_VALUE, formatCompact } from "../../utils/format";
9
10
  import { DATE_OPTION_EXAMPLES, DATE_OPTION_FORMATS, dateOptionError, readCalendarDate } from "../../utils/calendar-date";
10
11
  import {
@@ -102,10 +103,12 @@ import {
102
103
  fredValueHeader,
103
104
  isSpreadSeries,
104
105
  laggingSeriesNote,
106
+ FRED_VINTAGE_NOTE,
105
107
  parseFredChange,
106
108
  } from "./fred-series";
107
109
  import { fredProvenance, fredPublicationTime, notOnFredSource } from "../../sources/gloomberb-cloud/fred-attribution";
108
110
  import { followsUsBondMarket, usBondMarketClosedNote } from "../../market-data/us-bond-market";
111
+ import { commandWord } from "../../utils/shell-word";
109
112
 
110
113
  /** The Actual of a release its publisher could not compute; the notes say why. */
111
114
  const NOT_PUBLISHED_TEXT = "not published";
@@ -745,12 +748,12 @@ async function runEcon(args: string[], ctx: Parameters<CliCommandDef["execute"]>
745
748
  }),
746
749
  // The exports add what a script needs to read a row; the text table keeps the columns it had.
747
750
  columns: [...econExportHeadColumns(viewerZone, publisherTimed), ...econFigureColumns(false), ...econExportColumns],
748
- textColumns: [...econTextHeadColumns(viewerZone, publisherTimed), ...econFigureColumns(true), ECON_PUBLISHER_COLUMN],
751
+ textColumns: [...econTextHeadColumns(viewerZone, publisherTimed), { key: "referencePeriod", header: "Period" }, ...econFigureColumns(true), ECON_PUBLISHER_COLUMN],
749
752
  });
750
753
  });
751
754
  }
752
755
 
753
- const FRED_USAGE = "fred <series-id> [--start <date>] [--sort desc|asc] [--change 1D|1W]";
756
+ const FRED_USAGE = "fred <series-id> [series-id ...] [--start <date>] [--sort desc|asc] [--change 1D|1W]";
754
757
  const FRED_LIST_USAGE = "fred --list [filter]";
755
758
 
756
759
  /** A year or a month stands for the first day of it. */
@@ -844,12 +847,55 @@ async function runFred(rawArgs: string[], ctx: Parameters<CliCommandDef["execute
844
847
  if (changeGiven && !horizon) {
845
848
  ctx.fail(change ? `Unknown change "${change}".` : "--change needs 1D or 1W.", "Use 1D (from the previous observation) or 1W (from a week before).");
846
849
  }
850
+ if (args.length > 1 || args[0]?.includes(",")) {
851
+ const seriesIds = [...new Set(args.flatMap((value) => value.split(",")).map((value) => value.trim().toUpperCase()).filter(Boolean))];
852
+ if (!seriesIds.length || seriesIds.some((seriesId) => !/^[A-Z0-9_]+$/.test(seriesId))) ctx.fail("Use space- or comma-separated series IDs.", `Usage: gloom ${FRED_USAGE}`);
853
+ if (seriesIds.length > 20) ctx.fail("fred accepts at most 20 series in one aligned report.");
854
+ return withSavedFredSeries(ctx, () => printFredAligned(ctx, seriesIds, { start, startDate, sortOrder, horizon }));
855
+ }
847
856
  const asked = requireOneArg(args, FRED_USAGE, "series", ctx);
848
857
  // A series by its name (`3 month t-bill` is DTB3) when one alone fits it.
849
858
  const seriesId = (/\s/.test(asked.trim()) ? fredSeriesIdForName(asked) : null) ?? asked.toUpperCase();
850
859
  await withSavedFredSeries(ctx, () => printFredSeries(ctx, { seriesId, start, startDate, sortOrder, horizon }));
851
860
  }
852
861
 
862
+ async function printFredAligned(ctx: Parameters<CliCommandDef["execute"]>[1], seriesIds: string[],
863
+ options: { start?: string; startDate: string; sortOrder: "asc" | "desc"; horizon: ReturnType<typeof parseFredChange> }) {
864
+ const reports: Array<{ seriesId: string; result: CliResult; render: CliResultRenderOptions }> = [];
865
+ for (const seriesId of seriesIds) {
866
+ await printFredSeries({ ...ctx, printResult: (result, render = {}) => { reports.push({ seriesId, result, render: render as unknown as CliResultRenderOptions }); } }, { ...options, start: options.start, seriesId });
867
+ }
868
+ const byDate = new Map<string, Record<string, unknown>>();
869
+ const metadata: Record<string, unknown> = {};
870
+ const notes = ["Aligned on observation dates, not release dates. Missing observations remain blank; values are not forward-filled."];
871
+ const suffixes = ["unit", "interval", "source", "released", "first_released", "revised_on", "first_release_value", ...options.horizon ? ["change", "changeFrom"] : [], "as_of"];
872
+ for (const { seriesId, result, render } of reports) {
873
+ metadata[seriesId] = result.metadata;
874
+ notes.push(...render.exportNotes ?? []);
875
+ for (const entry of result.data as Record<string, unknown>[]) {
876
+ const date = String(entry.date);
877
+ const row = byDate.get(date) ?? { date };
878
+ const identity = typeof render.exportIdentity === "function" ? render.exportIdentity(entry) : render.exportIdentity;
879
+ row[seriesId] = entry.value;
880
+ row[`${seriesId}_unit`] = identity?.currencyOrUnit;
881
+ row[`${seriesId}_interval`] = identity?.interval;
882
+ row[`${seriesId}_source`] = result.freshness?.source;
883
+ for (const suffix of suffixes.slice(3)) row[`${seriesId}_${suffix}`] = entry[suffix];
884
+ row[`${seriesId}_as_of`] = identity?.asOf;
885
+ byDate.set(date, row);
886
+ }
887
+ }
888
+ const rows = [...byDate.values()].sort((left, right) => options.sortOrder === "asc"
889
+ ? String(left.date).localeCompare(String(right.date)) : String(right.date).localeCompare(String(left.date)));
890
+ ctx.printResult({ data: rows, metadata: { series: metadata, alignment: "observation date" },
891
+ warnings: reports.flatMap(({ result }) => result.warnings ?? []),
892
+ freshness: rowsFreshness(rows, { source: [...new Set(reports.map(({ result }) => result.freshness?.source).filter(Boolean))].join("; "),
893
+ status: "not-a-feed", basis: "published statistics", observedKey: "date", oldest: null }),
894
+ }, { dateKey: "date", columns: ["date", ...seriesIds, ...seriesIds.flatMap((seriesId) => suffixes.map((suffix) => `${seriesId}_${suffix}`))].map((key) => ({ key, header: key })),
895
+ exportIdentity: { symbolOrSeries: seriesIds.join(" "), currencyOrUnit: "see per-series unit columns", interval: "see per-series interval columns" },
896
+ exportNotes: [...new Set(notes)], footnote: [...new Set(notes)].join("\n") });
897
+ }
898
+
853
899
  async function printFredSeries(ctx: Parameters<CliCommandDef["execute"]>[1], { seriesId, start, startDate, sortOrder, horizon }: {
854
900
  seriesId: string;
855
901
  start: string | undefined;
@@ -870,11 +916,11 @@ async function printFredSeries(ctx: Parameters<CliCommandDef["execute"]>[1], { s
870
916
  if (mismatch) ctx.fail(mismatch);
871
917
  // Each row's change in the unit its value exports in, and the date it is from; a holiday's stays blank.
872
918
  const changes = horizon ? fredChanges(seriesId, data.observations, horizon) : null;
873
- const releasedOf = (observation: { publisher?: string; publishedAt?: string; releasedOn?: string }) =>
874
- observation.releasedOn ?? (observation.publisher?.trim() ? observation.publishedAt : undefined);
919
+ const releasedOf = (observation: { publisher?: string; publishedAt?: string; releasedOn?: string; firstReleased?: string }) =>
920
+ observation.firstReleased ?? observation.releasedOn ?? (observation.publisher?.trim() ? observation.publishedAt : undefined);
875
921
  // A value FRED does not list yet carries its publisher and when it published, in every export.
876
922
  // A row from the copy an earlier read saved, the refresh having failed, carries its mark: the source line says so.
877
- const exportRow = (observation: { date: string; value: number | null; publisher?: string; publishedAt?: string; releasedOn?: string }) => ({
923
+ const exportRow = (observation: CloudFredSeriesPayload["observations"][number]) => ({
878
924
  ...savedCopyMark(data),
879
925
  date: observation.date,
880
926
  value: fredExportValue(seriesId, observation.value),
@@ -882,6 +928,9 @@ async function printFredSeries(ctx: Parameters<CliCommandDef["execute"]>[1], { s
882
928
  ...(observation.publisher?.trim() ? { publisher: observation.publisher.trim(), ...(observation.publishedAt ? { publishedAt: observation.publishedAt } : {}) } : {}),
883
929
  // When the figure came out, where the data says: only a series' newest observation does. `date` is the period it covers.
884
930
  ...releasedOf(observation) ? { released: releasedOf(observation) } : {},
931
+ ...(observation.firstReleased ? { first_released: observation.firstReleased } : {}),
932
+ ...(observation.revisedOn ? { revised_on: observation.revisedOn } : {}),
933
+ ...(observation.firstReleaseValue != null ? { first_release_value: fredExportValue(seriesId, observation.firstReleaseValue) } : {}),
885
934
  });
886
935
  // A --start before the series begins comes back padded with blank days: the rows start at its first observation.
887
936
  const fromStart = fredObservationsFromStart(data.observations, data.info?.observationStart)
@@ -892,6 +941,7 @@ async function printFredSeries(ctx: Parameters<CliCommandDef["execute"]>[1], { s
892
941
  ...fredHistoryNotes({ startDate, startGiven: start != null, seriesStart: data.info?.observationStart }),
893
942
  laggingSeriesNote(seriesId),
894
943
  computedFredSeriesNote(seriesId),
944
+ ...(data.observations.some((observation) => observation.firstReleased) ? [FRED_VINTAGE_NOTE] : []),
895
945
  // A publisher's licence asks for its attribution wherever its series is shown (MAS's SORA).
896
946
  seriesNotOnFred(seriesId)?.attribution ?? null,
897
947
  ].filter((note): note is string => note != null);
@@ -913,7 +963,7 @@ async function printFredSeries(ctx: Parameters<CliCommandDef["execute"]>[1], { s
913
963
  // A newest value FRED does not list yet names its publisher, Treasury for a yield; FRED's own stay "FRED".
914
964
  const ahead = fredProvenance(data.observations.filter((observation) => observation.date === newestDate), seriesId);
915
965
  // FRED names the series' publisher when Gloom Cloud passes it on, and when it last updated the series.
916
- const publisher = ahead?.publisher ?? data.info?.source?.trim();
966
+ const publisher = ahead?.publisher ?? fredPublisher(seriesId, data.info?.source);
917
967
  const publishedAt = ahead ? ahead.publishedAt : fredPublicationTime(data.info, newestDate);
918
968
  // When the newest figure was released: the report is as of then, `Sep 2026, released Tue 20 Oct`.
919
969
  const releasedOn = ahead ? undefined : data.observations.find((observation) => observation.date === newestDate)?.releasedOn;
@@ -926,7 +976,7 @@ async function printFredSeries(ctx: Parameters<CliCommandDef["execute"]>[1], { s
926
976
  ...(latest && !closedDay ? { latestObservation: exportRow(latest) } : {}),
927
977
  },
928
978
  freshness: rowsFreshness(rows, {
929
- source: ahead?.source ?? notOnFredSource(seriesId) ?? "FRED", status: "not-a-feed", basis: "published statistics", observedKey: "date", oldest: null,
979
+ source: ahead?.source ?? notOnFredSource(seriesId) ?? fredCitation(seriesId, data.info?.source), status: "not-a-feed", basis: "published statistics", observedKey: "date", oldest: null,
930
980
  // A monthly or quarterly observation is dated the first of its period, not a day it was seen.
931
981
  ...(periodicity ? { periodicity } : {}),
932
982
  ...(releasedOn ? { releasedOn } : {}),
@@ -937,16 +987,18 @@ async function printFredSeries(ctx: Parameters<CliCommandDef["execute"]>[1], { s
937
987
  dateKey: "date",
938
988
  empty: fredEmptyMessage(startDate, latest == null ? null : exportRow(latest)),
939
989
  ...(notes.length ? { footnote: notes.join("\n"), exportNotes: notes } : {}),
940
- // `as_of` is the release. A figure with none stated is as of its own day when the series is known to observe
990
+ // `as_of` is the revision or release. Without either, it is its own day when the series is known to observe
941
991
  // days (a daily or weekly rate), and of nothing otherwise, never the first day of the period it covers.
942
992
  exportDated: true,
993
+ exportAppendedKeys: ["first_released", "revised_on", "first_release_value"],
943
994
  exportIdentity: (row) => {
944
995
  const released = typeof row.released === "string" ? row.released : null;
996
+ const revised = typeof row.revised_on === "string" ? row.revised_on : null;
945
997
  const date = typeof row.date === "string" ? row.date : null;
946
- return { symbolOrSeries: seriesId, currencyOrUnit: unit, interval, asOf: released ?? (observesDays ? date : null), period: date, released };
998
+ return { symbolOrSeries: seriesId, currencyOrUnit: unit, interval, asOf: revised ?? released ?? (observesDays ? date : null), period: date, released };
947
999
  },
948
1000
  // The release closes the row with the other dating columns, so it is not one of the observation's own.
949
- columns: [...new Set(rows.flatMap((row) => Object.keys(row)))].filter((key) => key !== "released").map((key) => ({ key, header: key })),
1001
+ columns: [...new Set([...rows.flatMap((row) => Object.keys(row)), "first_released", "revised_on", "first_release_value"])].filter((key) => key !== "released").map((key) => ({ key, header: key })),
950
1002
  textColumns: [
951
1003
  { key: "date", header: "Date" },
952
1004
  isSpreadSeries(seriesId)
@@ -1040,10 +1092,15 @@ async function runCorrelation(rawArgs: string[], ctx: Parameters<CliCommandDef["
1040
1092
  const right = rightListing!.key;
1041
1093
  // Same daily-return model as the CORR pane: price levels of two trending
1042
1094
  // assets correlate spuriously, often with the opposite sign.
1095
+ // Each symbol's quote, read once: whether its line can have moved, and where its daily close is taken below.
1096
+ const quotes = new Map([leftListing!, rightListing!].map((listing) => [listing, loadListingQuote(services.dataProvider, listing)] as const));
1043
1097
  const loadSeries = async (listing: CliListing) => {
1098
+ // A symbol whose company moved is asked again under its new symbol, the other one kept.
1099
+ const retry = (key: string) => `gloom correlation ${listing === leftListing ? `${key} ${commandWord(right)}` : `${commandWord(left)} ${key}`}`;
1044
1100
  const bars = await loadForListing(
1045
1101
  listing, services, ctx,
1046
1102
  () => loadCorrelationHistory(services.dataProvider, listing.request.symbol, listing.request.exchange, "1Y"),
1103
+ undefined, { command: "correlation", noun: "history", retry, quote: quotes.get(listing)! },
1047
1104
  );
1048
1105
  return { ...buildCorrelationSeries(listing.key, bars), bars: bars.length };
1049
1106
  };
@@ -1058,7 +1115,7 @@ async function runCorrelation(rawArgs: string[], ctx: Parameters<CliCommandDef["
1058
1115
  .map((series) => series.rollNote ? `${series.symbol}: ${series.rollNote}` : null),
1059
1116
  ].filter((note) => note != null);
1060
1117
  // A bare symbol names no exchange; its quote says where it lists, which sets when its daily close is taken.
1061
- const [leftQuote, rightQuote] = await Promise.all([leftListing!, rightListing!].map((listing) => loadListingQuote(services.dataProvider, listing)));
1118
+ const [leftQuote, rightQuote] = await Promise.all([leftListing!, rightListing!].map((listing) => quotes.get(listing)!));
1062
1119
  const sessionNote = mixedSessionCloseNote(
1063
1120
  { symbol: leftListing!.symbol, exchange: listingIdentity(leftListing!, leftQuote).exchange, label: left },
1064
1121
  { symbol: rightListing!.symbol, exchange: listingIdentity(rightListing!, rightQuote).exchange, label: right },
@@ -1140,7 +1197,7 @@ export const overviewCliCommands: CliCommandDef[] = [
1140
1197
  options: [
1141
1198
  { flags: "--country <regions or countries>", description: "US, G7, EU, all (default), or countries by their two-letter codes, comma separated, such as MX or MX,BR,ZA" },
1142
1199
  { flags: "--impact <level>", description: "high, medium, low, or all (default all)" },
1143
- { flags: "--search <words>", description: "Events whose name or publisher has these words, case, spaces and hyphens aside, such as nonfarm, fed funds or USDA" },
1200
+ { flags: "--search <words>", description: "Match all words in an event name or publisher; OR joins alternatives, such as \"housing OR mortgage OR NAHB\". Case, spaces and hyphens are ignored" },
1144
1201
  { flags: "--from <date>", description: `First day listed, as ${DATE_OPTION_EXAMPLES} (default today, UTC); an earlier day lists past events from the stored calendar and says where it starts` },
1145
1202
  { flags: "--tz <zone>", description: "Add a column with each release's time on that clock, an IANA zone such as America/New_York; with the weekday when it falls on another day than the UTC date" },
1146
1203
  ],
@@ -1168,9 +1225,10 @@ export const overviewCliCommands: CliCommandDef[] = [
1168
1225
  title: "Series",
1169
1226
  lines: [
1170
1227
  "Gloom Cloud serves a curated set of FRED series and needs no sign-in for them. gloom fred (or fred --list) prints them by topic; any other ID fails with that pointer.",
1228
+ "Several IDs, separated by spaces or commas, align on observation dates without forward filling. Each series keeps its own unit, source and release fields.",
1171
1229
  ],
1172
1230
  }],
1173
- examples: ["fred CPIAUCSL", "fred DGS10 --tail 5", "fred DGS10 --change 1D --tail 5", "fred UNRATE --start 2020-01-01 --csv", "fred", "fred --list credit", "fred --list fx"],
1231
+ examples: ["fred CPIAUCSL", "fred DGS10 --tail 5", "fred DGS10 --change 1D --tail 5", "fred UNRATE --start 2020-01-01 --csv", "fred PERMIT HOUST --start 2026-01-01 --csv", "fred", "fred --list credit", "fred --list fx"],
1174
1232
  },
1175
1233
  execute: runFred,
1176
1234
  },
@@ -1,5 +1,5 @@
1
1
  import { basename, join, resolve } from "path";
2
- import { existsSync, lstatSync, readFileSync, rmSync } from "fs";
2
+ import { existsSync, lstatSync, readFileSync } from "fs";
3
3
  import {
4
4
  DEPRECATED_HOST_EXPORTS,
5
5
  REMOVED_HOST_EXPORTS,
@@ -31,6 +31,7 @@ import {
31
31
  } from "../../plugins/installer";
32
32
  import { isReservedBuiltinPluginId } from "../../plugins/ownership";
33
33
  import { pluginFromModule, pluginSupportsTarget } from "../../plugins/plugin-export";
34
+ import { removeFolder } from "../../utils/remove-folder";
34
35
  import { formatVersion, requiredGloomberb } from "../../utils/semver";
35
36
  import { ALL_PLUGIN_TARGETS, type GloomPlugin, type PluginTarget } from "../../types/plugin";
36
37
  import {
@@ -311,7 +312,7 @@ async function doctorPlugin(nameOrPath: string): Promise<PluginDoctorReport> {
311
312
  const result = await bundleExternalPlugin(candidate, outDir, { define: { "process.env.NODE_ENV": "\"production\"" } });
312
313
  const size = Math.round(Bun.file(result.outputPath).size / 1024);
313
314
  add("browser-build", "ok", `${basename(browserEntry ?? entryFile)} compiles for the desktop view (${size}KB)`);
314
- rmSync(outDir, { recursive: true, force: true });
315
+ await removeFolder(outDir);
315
316
  } catch (error) {
316
317
  const message = error instanceof Error ? error.message : String(error);
317
318
  add("browser-build", "fail", `Desktop build failed: ${message.split("\n")[0]}. Ship an index.browser.ts without node:* imports, or set targets to ["cli", "tui"].`);