@gloom-sh/terminal 0.20.20 → 0.20.21

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 (365) hide show
  1. package/package.json +3 -1
  2. package/src/api-client/data.ts +1 -1
  3. package/src/api-client/equity-screener.ts +17 -0
  4. package/src/api-client/futures-curve.ts +5 -0
  5. package/src/api-client/market-discovery.ts +8 -0
  6. package/src/api-client/members.ts +2 -0
  7. package/src/api-client/paths.ts +3 -0
  8. package/src/api-client/perps.ts +20 -0
  9. package/src/api-client/request.ts +53 -7
  10. package/src/api-client/types/filings-and-calls.ts +2 -0
  11. package/src/app/pane-runtime/plugin-bindings.ts +6 -4
  12. package/src/app/pro-welcome/model.ts +15 -11
  13. package/src/app/pro-welcome/row.tsx +3 -3
  14. package/src/app/pro-welcome/use-pro-welcome.ts +2 -2
  15. package/src/app/runtime/startup.ts +3 -2
  16. package/src/app.tsx +3 -2
  17. package/src/capabilities/asset-data-inputs.ts +5 -0
  18. package/src/capabilities/factories.ts +8 -3
  19. package/src/capabilities/registry.ts +1 -0
  20. package/src/capabilities/types.ts +1 -0
  21. package/src/cli/commands/market.ts +68 -35
  22. package/src/cli/commands/options-chain.ts +2 -2
  23. package/src/cli/commands/overview.ts +10 -9
  24. package/src/cli/commands/ticker.ts +19 -4
  25. package/src/cli/desktop-pane-shot.ts +11 -3
  26. package/src/cli/export-source.ts +35 -2
  27. package/src/cli/glossary.ts +3 -2
  28. package/src/cli/helpers.ts +2 -1
  29. package/src/cli/history-demergers.ts +41 -10
  30. package/src/cli/history-rows.ts +3 -1
  31. package/src/cli/known-gaps.ts +21 -7
  32. package/src/cli/listing-arg.ts +22 -11
  33. package/src/cli/pane-functions/capabilities.ts +4 -9
  34. package/src/cli/pane-functions/catalog-snapshot.json +29 -29
  35. package/src/cli/pane-functions/catalog.ts +1 -18
  36. package/src/cli/pane-functions/data.ts +8 -4
  37. package/src/cli/pane-functions/financial-ratio-shot.ts +20 -5
  38. package/src/cli/pane-functions/freshness.ts +57 -12
  39. package/src/cli/pane-functions/function-help.ts +2 -2
  40. package/src/cli/pane-functions/headless.ts +6 -0
  41. package/src/cli/pane-functions/index.ts +11 -4
  42. package/src/cli/pane-functions/market-session.ts +25 -0
  43. package/src/cli/pane-functions/report-notices.ts +10 -0
  44. package/src/cli/pane-functions/resolver.ts +75 -3
  45. package/src/cli/pane-functions/screenshot-bridge.ts +1 -0
  46. package/src/cli/pane-functions/screenshot-data-evidence.ts +1 -0
  47. package/src/cli/pane-functions/screenshot-payload.ts +38 -5
  48. package/src/cli/pane-functions/screenshot-render.ts +20 -7
  49. package/src/cli/perpetual-contract.ts +14 -1
  50. package/src/cli/report-tables.ts +11 -2
  51. package/src/cli/result.ts +6 -1
  52. package/src/components/chart-table/layout.ts +8 -4
  53. package/src/components/command-bar/list/model.ts +2 -0
  54. package/src/components/command-bar/pane-templates/items.ts +5 -25
  55. package/src/components/command-bar/panel/index.tsx +7 -4
  56. package/src/components/command-bar/routes/root/provider-search.ts +4 -4
  57. package/src/components/command-bar/routes/root/results.ts +6 -2
  58. package/src/components/command-bar/routes/ticker-search/results.ts +19 -0
  59. package/src/components/command-bar/routes/ticker-search/route.ts +3 -3
  60. package/src/components/command-bar/routes/ticker-search/title.ts +23 -0
  61. package/src/components/command-bar/routing/list-state.ts +17 -5
  62. package/src/components/command-bar/selection-runtime.ts +3 -2
  63. package/src/components/command-bar/surface/index.tsx +2 -0
  64. package/src/components/command-bar/workflow/alert.ts +6 -4
  65. package/src/components/command-bar/workflow/collection-actions.ts +2 -1
  66. package/src/components/layout/pane/footer/index.tsx +1 -0
  67. package/src/components/layout/pane/footer/model.ts +20 -7
  68. package/src/components/layout/pane/title.ts +11 -2
  69. package/src/components/price-selector-dialog.tsx +8 -4
  70. package/src/components/ticker/badge/list.tsx +4 -3
  71. package/src/components/ticker/list-table-view.tsx +12 -1
  72. package/src/components/ui/query-bar.tsx +20 -14
  73. package/src/data/cached-query.ts +20 -4
  74. package/src/data/news-pane-snapshots.ts +2 -1
  75. package/src/data/plugin-cache.ts +5 -1
  76. package/src/data/saved-copies.ts +68 -2
  77. package/src/docs/snapshot.json +65 -14
  78. package/src/docs/topics.ts +11 -9
  79. package/src/i18n/es.ts +1 -0
  80. package/src/i18n/ja.ts +1 -0
  81. package/src/i18n/ko.ts +1 -0
  82. package/src/i18n/zh-cn.ts +1 -0
  83. package/src/i18n/zh-tw.ts +1 -0
  84. package/src/market-data/coordinator/index.ts +25 -5
  85. package/src/market-data/depositary-pair.ts +27 -10
  86. package/src/market-data/futures-roll-returns.ts +54 -7
  87. package/src/market-data/fx-closes.ts +14 -0
  88. package/src/market-data/market/futures-product-hours.ts +113 -0
  89. package/src/market-data/market/futures-week.ts +2 -0
  90. package/src/market-data/market/globex-day.ts +9 -2
  91. package/src/market-data/market/status.ts +32 -25
  92. package/src/market-data/market/venue-session.ts +18 -0
  93. package/src/market-data/options-alternatives.ts +49 -7
  94. package/src/market-data/perpetual-open-interest.ts +41 -0
  95. package/src/market-data/quotes/contributions.ts +4 -2
  96. package/src/market-data/quotes/export-identity.ts +11 -3
  97. package/src/market-data/quotes/freshness.ts +3 -2
  98. package/src/market-data/quotes/resolution.ts +9 -2
  99. package/src/market-data/quotes/tick-range.ts +22 -1
  100. package/src/market-data/quotes/time.ts +34 -4
  101. package/src/market-data/split-terms.ts +3 -2
  102. package/src/news/aggregator.ts +1 -0
  103. package/src/news/news-model.ts +12 -2
  104. package/src/news/types.ts +15 -0
  105. package/src/plugins/builtin/alerts/alert-engine.ts +2 -0
  106. package/src/plugins/builtin/alerts/cli-forms.ts +3 -2
  107. package/src/plugins/builtin/alerts/cli-move.ts +5 -2
  108. package/src/plugins/builtin/alerts/cli.ts +50 -25
  109. package/src/plugins/builtin/alerts/command.ts +51 -3
  110. package/src/plugins/builtin/alerts/event-rows.ts +1 -1
  111. package/src/plugins/builtin/alerts/events-pane.tsx +1 -1
  112. package/src/plugins/builtin/alerts/format.ts +67 -8
  113. package/src/plugins/builtin/alerts/headless.ts +22 -6
  114. package/src/plugins/builtin/alerts/index.tsx +26 -25
  115. package/src/plugins/builtin/alerts/move-checks.ts +1 -0
  116. package/src/plugins/builtin/alerts/pane.tsx +15 -6
  117. package/src/plugins/builtin/alerts/pro-rules.ts +9 -4
  118. package/src/plugins/builtin/alerts/quotes.ts +10 -5
  119. package/src/plugins/builtin/alerts/session.ts +28 -0
  120. package/src/plugins/builtin/alerts/types.ts +1 -0
  121. package/src/plugins/builtin/analytics/pane-model.ts +2 -1
  122. package/src/plugins/builtin/analytics/risk-model.ts +2 -2
  123. package/src/plugins/builtin/attention/headless.ts +2 -2
  124. package/src/plugins/builtin/attention/model.ts +7 -2
  125. package/src/plugins/builtin/attention/pane.tsx +2 -1
  126. package/src/plugins/builtin/awards/headless.ts +1 -1
  127. package/src/plugins/builtin/broker-trading/ticket.tsx +13 -5
  128. package/src/plugins/builtin/buildout/detail/company.tsx +0 -1
  129. package/src/plugins/builtin/buildout/detail/ui.tsx +7 -5
  130. package/src/plugins/builtin/buildout/model/normalizers.ts +0 -1
  131. package/src/plugins/builtin/buildout/model/types.ts +0 -1
  132. package/src/plugins/builtin/buildout/pane/index.tsx +9 -0
  133. package/src/plugins/builtin/buildout/pane/status.tsx +11 -0
  134. package/src/plugins/builtin/catalysts/headless.ts +1 -1
  135. package/src/plugins/builtin/chart-composer/headless.ts +14 -6
  136. package/src/plugins/builtin/chart-composer/pane.tsx +2 -1
  137. package/src/plugins/builtin/chart-composer/session-history.ts +14 -2
  138. package/src/plugins/builtin/chat/controller/index.ts +5 -3
  139. package/src/plugins/builtin/chat/controller/session-runtime.ts +18 -8
  140. package/src/plugins/builtin/chat/index.tsx +1 -1
  141. package/src/plugins/builtin/cloud/auth-actions.tsx +4 -2
  142. package/src/plugins/builtin/cloud/mcp-connect/dialog.tsx +4 -1
  143. package/src/plugins/builtin/cloud/thesis/ticker-tab.tsx +2 -1
  144. package/src/plugins/builtin/company-attention/headless.ts +2 -1
  145. package/src/plugins/builtin/company-kpis/headless.ts +1 -1
  146. package/src/plugins/builtin/correlation/headless.ts +3 -3
  147. package/src/plugins/builtin/correlation/history.ts +1 -0
  148. package/src/plugins/builtin/correlation/index.tsx +7 -5
  149. package/src/plugins/builtin/correlation/matrix/selection.ts +21 -3
  150. package/src/plugins/builtin/correlation/relationship/model.ts +5 -0
  151. package/src/plugins/builtin/correlation/relationship/pane.tsx +3 -2
  152. package/src/plugins/builtin/correlation/relationship/view-model.ts +3 -2
  153. package/src/plugins/builtin/credit-documents/headless.ts +1 -1
  154. package/src/plugins/builtin/dividend-yield/client.ts +81 -10
  155. package/src/plugins/builtin/dividend-yield/headless.ts +21 -10
  156. package/src/plugins/builtin/dividend-yield/model.ts +1 -1
  157. package/src/plugins/builtin/dividend-yield/pane.tsx +9 -5
  158. package/src/plugins/builtin/dividend-yield/ranking.ts +15 -5
  159. package/src/plugins/builtin/dividend-yield/reference-price.ts +3 -0
  160. package/src/plugins/builtin/dividend-yield/types.ts +12 -0
  161. package/src/plugins/builtin/dividend-yield/view.ts +30 -7
  162. package/src/plugins/builtin/doe/headless.ts +1 -1
  163. package/src/plugins/builtin/doe/pane.tsx +16 -7
  164. package/src/plugins/builtin/earnings-calls/data.ts +8 -5
  165. package/src/plugins/builtin/earnings-ripple/headless.ts +1 -1
  166. package/src/plugins/builtin/econ/calendar-model.ts +1 -1
  167. package/src/plugins/builtin/econ/index.tsx +26 -18
  168. package/src/plugins/builtin/equity-screener/client.ts +1 -1
  169. package/src/plugins/builtin/equity-screener/headless.ts +149 -31
  170. package/src/plugins/builtin/equity-screener/live.ts +23 -5
  171. package/src/plugins/builtin/equity-screener/model.ts +27 -12
  172. package/src/plugins/builtin/equity-screener/pane.tsx +5 -5
  173. package/src/plugins/builtin/exposure/headless.ts +1 -1
  174. package/src/plugins/builtin/exposure/holdings.ts +2 -2
  175. package/src/plugins/builtin/futures/index.tsx +29 -1
  176. package/src/plugins/builtin/futures/model.ts +93 -10
  177. package/src/plugins/builtin/futures/returns.ts +54 -1
  178. package/src/plugins/builtin/futures/table.tsx +14 -2
  179. package/src/plugins/builtin/futures/use-front-returns.ts +20 -3
  180. package/src/plugins/builtin/futures-curve/client.ts +1 -1
  181. package/src/plugins/builtin/futures-curve/headless.ts +9 -3
  182. package/src/plugins/builtin/futures-curve/model.ts +19 -5
  183. package/src/plugins/builtin/futures-curve/pane.tsx +12 -6
  184. package/src/plugins/builtin/gpu/headless.ts +1 -1
  185. package/src/plugins/builtin/gpu/model.ts +1 -1
  186. package/src/plugins/builtin/help/function-index.ts +16 -8
  187. package/src/plugins/builtin/help/functions-table.tsx +6 -4
  188. package/src/plugins/builtin/help/shortcut-model.ts +7 -2
  189. package/src/plugins/builtin/holders/headless.ts +16 -5
  190. package/src/plugins/builtin/holders/pane.tsx +43 -5
  191. package/src/plugins/builtin/insider/client.ts +118 -11
  192. package/src/plugins/builtin/insider/filing-stories.ts +36 -20
  193. package/src/plugins/builtin/insider/issuer.ts +5 -2
  194. package/src/plugins/builtin/iv-history/headless.ts +2 -0
  195. package/src/plugins/builtin/macro-day/client.ts +2 -3
  196. package/src/plugins/builtin/macro-day/comparison.ts +58 -0
  197. package/src/plugins/builtin/macro-day/headless.ts +47 -3
  198. package/src/plugins/builtin/macro-day/index.tsx +32 -9
  199. package/src/plugins/builtin/macro-day/model.ts +1 -1
  200. package/src/plugins/builtin/macro-day/pane.tsx +99 -12
  201. package/src/plugins/builtin/market-heatmap/index.tsx +2 -2
  202. package/src/plugins/builtin/market-movers/footer.ts +29 -3
  203. package/src/plugins/builtin/market-movers/headless.ts +12 -5
  204. package/src/plugins/builtin/market-movers/index.tsx +3 -3
  205. package/src/plugins/builtin/market-movers/session-body.tsx +6 -3
  206. package/src/plugins/builtin/market-valuation/detail.tsx +3 -3
  207. package/src/plugins/builtin/market-valuation/headless.ts +6 -6
  208. package/src/plugins/builtin/market-valuation/pane.tsx +2 -3
  209. package/src/plugins/builtin/market-valuation/view.ts +6 -8
  210. package/src/plugins/builtin/members/client.ts +9 -2
  211. package/src/plugins/builtin/members/headless.ts +8 -10
  212. package/src/plugins/builtin/members/model.ts +29 -17
  213. package/src/plugins/builtin/members/pane.tsx +10 -12
  214. package/src/plugins/builtin/money-markets/headless.ts +1 -1
  215. package/src/plugins/builtin/news/headless.ts +4 -0
  216. package/src/plugins/builtin/news/index.tsx +3 -1
  217. package/src/plugins/builtin/news/wire/industry-pane.tsx +2 -1
  218. package/src/plugins/builtin/news/wire/news/preset-pane.tsx +1 -1
  219. package/src/plugins/builtin/news/wire/persisted-articles.ts +8 -4
  220. package/src/plugins/builtin/notes/headless.ts +7 -0
  221. package/src/plugins/builtin/notes/index.tsx +1 -1
  222. package/src/plugins/builtin/notes/quick-notes-pane.tsx +18 -2
  223. package/src/plugins/builtin/options/view.tsx +7 -6
  224. package/src/plugins/builtin/options-positioning/headless.ts +4 -4
  225. package/src/plugins/builtin/options-positioning/pane.tsx +7 -3
  226. package/src/plugins/builtin/options-scenario/client.ts +20 -4
  227. package/src/plugins/builtin/options-scenario/headless.ts +1 -1
  228. package/src/plugins/builtin/pe-band/client.ts +5 -9
  229. package/src/plugins/builtin/pe-band/headless.ts +11 -13
  230. package/src/plugins/builtin/pe-band/model.ts +39 -60
  231. package/src/plugins/builtin/pe-band/pane.tsx +14 -15
  232. package/src/plugins/builtin/perps/equity-row.tsx +3 -1
  233. package/src/plugins/builtin/perps/freshness.ts +16 -9
  234. package/src/plugins/builtin/perps/headless.ts +4 -1
  235. package/src/plugins/builtin/perps/markets-section.tsx +16 -10
  236. package/src/plugins/builtin/perps/model.ts +33 -2
  237. package/src/plugins/builtin/perps/pane.tsx +3 -2
  238. package/src/plugins/builtin/perps/status-line.ts +12 -3
  239. package/src/plugins/builtin/perps/venue-markets.ts +38 -0
  240. package/src/plugins/builtin/plugin-marketplace/pane.tsx +4 -3
  241. package/src/plugins/builtin/portfolio-list/cell-version.ts +1 -1
  242. package/src/plugins/builtin/portfolio-list/cli/render.ts +46 -7
  243. package/src/plugins/builtin/portfolio-list/headless.ts +31 -8
  244. package/src/plugins/builtin/portfolio-list/settings.ts +3 -0
  245. package/src/plugins/builtin/portfolio-list/table.tsx +7 -1
  246. package/src/plugins/builtin/power/headless.ts +1 -1
  247. package/src/plugins/builtin/realized-vol/headless.ts +1 -1
  248. package/src/plugins/builtin/research/corporate-actions-pane.tsx +27 -13
  249. package/src/plugins/builtin/scanner/feed.ts +7 -4
  250. package/src/plugins/builtin/scanner/flow-pane.tsx +8 -4
  251. package/src/plugins/builtin/scanner/headless.ts +57 -26
  252. package/src/plugins/builtin/scanner/hilo-pane.tsx +6 -3
  253. package/src/plugins/builtin/scanner/lock-note.ts +3 -2
  254. package/src/plugins/builtin/scanner/us-session.ts +9 -0
  255. package/src/plugins/builtin/seasonality/client.ts +46 -10
  256. package/src/plugins/builtin/seasonality/headless.ts +29 -11
  257. package/src/plugins/builtin/seasonality/model.ts +101 -24
  258. package/src/plugins/builtin/seasonality/pane.tsx +10 -6
  259. package/src/plugins/builtin/sec/filing-content.ts +13 -0
  260. package/src/plugins/builtin/sec/index.tsx +16 -11
  261. package/src/plugins/builtin/sectors/client.ts +27 -5
  262. package/src/plugins/builtin/sectors/headless.ts +2 -1
  263. package/src/plugins/builtin/sectors/index.tsx +22 -10
  264. package/src/plugins/builtin/shared/cloud-resource.ts +3 -3
  265. package/src/plugins/builtin/shared/extended-print.ts +38 -0
  266. package/src/plugins/builtin/shared/pro-feature-wall.tsx +1 -1
  267. package/src/plugins/builtin/shared/report-freshness.ts +7 -3
  268. package/src/plugins/builtin/shared/scanner-capture.ts +16 -3
  269. package/src/plugins/builtin/shared/ticker-company.ts +17 -8
  270. package/src/plugins/builtin/shared/use-quote-board.ts +11 -4
  271. package/src/plugins/builtin/social-mentions/client.ts +7 -3
  272. package/src/plugins/builtin/social-mentions/outliers.tsx +9 -2
  273. package/src/plugins/builtin/thirteenf/api.ts +24 -3
  274. package/src/plugins/builtin/thirteenf/data.ts +21 -8
  275. package/src/plugins/builtin/thirteenf/headless.ts +7 -3
  276. package/src/plugins/builtin/thirteenf/signals-pane.tsx +10 -3
  277. package/src/plugins/builtin/thirteenf/signals.ts +22 -1
  278. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +4 -2
  279. package/src/plugins/builtin/ticker-detail/financials/model.ts +7 -0
  280. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +15 -6
  281. package/src/plugins/builtin/ticker-detail/financials/ratios.ts +5 -4
  282. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +14 -5
  283. package/src/plugins/builtin/ticker-detail/headless.ts +32 -26
  284. package/src/plugins/builtin/ticker-detail/index.tsx +1 -1
  285. package/src/plugins/builtin/ticker-detail/overview/components.tsx +8 -3
  286. package/src/plugins/builtin/ticker-detail/overview/model.ts +28 -5
  287. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +14 -1
  288. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -8
  289. package/src/plugins/builtin/ticker-detail/pane.tsx +16 -9
  290. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +41 -23
  291. package/src/plugins/builtin/ticker-detail/quote-monitor/rows.ts +30 -13
  292. package/src/plugins/builtin/ticker-detail/settings.ts +9 -2
  293. package/src/plugins/builtin/time-sales/headless.ts +49 -13
  294. package/src/plugins/builtin/time-sales/model.ts +2 -2
  295. package/src/plugins/builtin/time-sales/window.ts +84 -10
  296. package/src/plugins/builtin/vol-surface/charts.tsx +4 -2
  297. package/src/plugins/builtin/vol-surface/events.ts +12 -5
  298. package/src/plugins/builtin/vol-surface/headless.ts +1 -1
  299. package/src/plugins/builtin/vol-surface/pane.tsx +15 -7
  300. package/src/plugins/builtin/world-indices/footer.ts +1 -1
  301. package/src/plugins/builtin/world-venue-map/chokepoint-report.ts +3 -1
  302. package/src/plugins/builtin/world-venue-map/headless.ts +27 -13
  303. package/src/plugins/builtin/yield-curve/client.ts +3 -1
  304. package/src/plugins/duplicates.ts +60 -0
  305. package/src/plugins/loader.ts +12 -3
  306. package/src/plugins/marketplace/model.ts +10 -1
  307. package/src/portfolio/column-values.ts +52 -5
  308. package/src/react/async-resource.ts +8 -7
  309. package/src/renderers/browser/bundled-plugins.ts +2 -1
  310. package/src/renderers/dom/build-assets.ts +20 -0
  311. package/src/renderers/dom/data-table/index.tsx +36 -2
  312. package/src/renderers/dom/es2023-array-methods.ts +57 -0
  313. package/src/renderers/dom/host/surface-fit.ts +64 -13
  314. package/src/renderers/dom/styles.css +6 -1
  315. package/src/renderers/electrobun/bun/external-plugins.ts +16 -6
  316. package/src/renderers/electrobun/shared/protocol.ts +2 -0
  317. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +31 -7
  318. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +15 -8
  319. package/src/renderers/electrobun/view/external-plugins.ts +1 -0
  320. package/src/renderers/electrobun/view/remote/asset-data-client.ts +1 -0
  321. package/src/series/types.ts +1 -0
  322. package/src/sources/gloomberb-cloud/fred-attribution.ts +6 -5
  323. package/src/sources/gloomberb-cloud/index.ts +42 -5
  324. package/src/sources/gloomberb-cloud/news.ts +15 -2
  325. package/src/sources/gloomberb-cloud/normalizers.ts +9 -0
  326. package/src/sources/history-result.ts +2 -1
  327. package/src/sources/history-retention.ts +14 -2
  328. package/src/sources/listing-symbols.ts +1 -1
  329. package/src/sources/provider-router/cache.ts +32 -3
  330. package/src/sources/provider-router/cached-routes.ts +25 -0
  331. package/src/sources/provider-router/connection-health.ts +1 -0
  332. package/src/sources/provider-router/history.ts +2 -2
  333. package/src/sources/provider-router/index.ts +14 -0
  334. package/src/sources/provider-router/sec-filings-page.ts +25 -0
  335. package/src/sources/sec-edgar/content.ts +67 -36
  336. package/src/tickers/listing-fate.ts +28 -0
  337. package/src/tickers/search/home-listing.ts +3 -0
  338. package/src/tickers/search/index-root-lead.ts +40 -0
  339. package/src/tickers/terminal-codes.ts +7 -4
  340. package/src/time-series/base-series.ts +17 -8
  341. package/src/time-series/fundamentals/historical-valuation.ts +2 -2
  342. package/src/time-series/fundamentals/series.ts +15 -12
  343. package/src/time-series/history-acquisition.ts +2 -0
  344. package/src/time-series/market.ts +3 -1
  345. package/src/time-series/price-comparison.ts +3 -1
  346. package/src/time-series/resolve-context.ts +8 -0
  347. package/src/time-series/resolve.ts +50 -10
  348. package/src/time-series/types.ts +1 -0
  349. package/src/time-series/use-chart-resolution.ts +2 -2
  350. package/src/time-series/valuation-currency.ts +40 -12
  351. package/src/types/data-provider.ts +30 -1
  352. package/src/types/financials.ts +23 -0
  353. package/src/types/headless.ts +23 -0
  354. package/src/types/instrument.ts +1 -0
  355. package/src/utils/crypto-pair.ts +16 -0
  356. package/src/utils/exchange-announcements.ts +2 -1
  357. package/src/utils/exchange-notation.generated.ts +58 -1
  358. package/src/utils/exchanges.ts +43 -1
  359. package/src/utils/format.ts +37 -2
  360. package/src/utils/function-search.ts +38 -0
  361. package/src/utils/fuzzy-search.ts +10 -6
  362. package/src/utils/option-choice.ts +15 -0
  363. package/src/utils/price-history.ts +15 -1
  364. package/src/utils/reason-codes.ts +6 -3
  365. package/src/utils/trailing-dividend.ts +241 -28
@@ -1,25 +1,35 @@
1
1
  import type { DividendMetrics, DividendPayment, GrowthPayments } from "./types";
2
- import { MISSING_VALUE, formatCurrency, formatDistributionAmount } from "../../../utils/format";
2
+ import { MISSING_VALUE, formatDistributionAmount } from "../../../utils/format";
3
3
  import { resolveCurrencyUnit } from "../../../utils/currency-units";
4
4
  import type { ProjectedChartPoint } from "../../../components/chart/core/data";
5
5
  import { calendarMonthsBefore } from "../../../utils/calendar-date";
6
6
  import { NOT_MEANINGFUL, formatPriceEarnings } from "../../../utils/price-earnings";
7
7
  import { UNEVEN_REGULAR_PAYMENTS } from "../../../utils/forward-dividend";
8
- import { CADENCE_GRACE_DAYS, LATE_GRACE_DAYS, trailingCashAt, type TrailingPayments } from "../../../utils/trailing-dividend";
8
+ import { CADENCE_GRACE_DAYS, LATE_GRACE_DAYS, OFF_CYCLE_DAYS, trailingCashAt, type TrailingPayments } from "../../../utils/trailing-dividend";
9
9
 
10
10
  const DAY = 24 * 60 * 60 * 1000;
11
11
 
12
+ /** An amount converted from the currency the company declares in, in the unit its history is in (pence for a London line), as any distribution is written. */
12
13
  export function formatConvertedAmount(value: number | null | undefined, currency: string, subUnit?: string): string {
13
14
  if (value == null || !Number.isFinite(value)) return MISSING_VALUE;
14
15
  const unit = subUnit ? resolveCurrencyUnit(subUnit) : null;
15
16
  return unit && unit.divisor !== 1 && unit.currency === currency
16
- ? formatCurrency(value * unit.divisor, subUnit!, 6)
17
- : formatCurrency(value, currency, 8);
17
+ ? formatDistributionAmount(value * unit.divisor, subUnit!)
18
+ : formatDistributionAmount(value, currency);
18
19
  }
19
20
 
20
- export function formatDividendRowAmount(row: Pick<DividendRow, "amount" | "currency" | "cashEstimate" | "combined">, converted = false, subUnit?: string): string {
21
+ export function formatDividendRowAmount(row: Pick<DividendRow, "amount" | "currency" | "cashEstimate" | "combined" | "special">, converted = false, subUnit?: string): string {
21
22
  const cash = converted ? formatConvertedAmount(row.amount, row.currency, subUnit) : formatDistributionAmount(row.amount, row.currency);
22
- return `${row.cashEstimate ? "estimated " : ""}${row.combined ? `${COMBINED_PAYMENT} ` : ""}${cash}`;
23
+ return `${row.cashEstimate ? "estimated " : ""}${row.combined ? `${COMBINED_PAYMENT} ` : ""}${row.special ? `${SPECIAL_PAYMENT} ` : ""}${cash}`;
24
+ }
25
+
26
+ /** A payment its issuer's own form says is a special (DividendPayment.special). */
27
+ const SPECIAL_PAYMENT = "special";
28
+
29
+ /** What the trailing year's specials are, beside its yield: "incl. HK$0.56 special". */
30
+ export function trailingSpecialText(metrics: Pick<DividendMetrics, "trailingSpecial">, currency: string): string | null {
31
+ return metrics.trailingSpecial && metrics.trailingSpecial > 0
32
+ ? `incl. ${formatDistributionAmount(metrics.trailingSpecial, currency)} ${SPECIAL_PAYMENT}` : null;
23
33
  }
24
34
 
25
35
  /** A row whose amount is a regular payment and an extra one on the same ex-date (DividendPayment.combined). */
@@ -49,6 +59,9 @@ export function distinctEstimateTexts(estimates: readonly NonNullable<DividendMe
49
59
  }))];
50
60
  }
51
61
 
62
+ /** What a date stated by the company's other listing says beside it: `(from HSBA:LSE)`. */
63
+ export const carriedDateText = (listing: string) => `(from ${listing})`;
64
+
52
65
  /** What a converted amount says beside it: `converted from USD`. */
53
66
  export const convertedFromText = (currency: string) => `converted from ${currency}`;
54
67
 
@@ -56,6 +69,9 @@ export function formatDividendYield(value: number | null): string {
56
69
  return value != null && Number.isFinite(value) ? `${(value * 100).toFixed(2)}%` : MISSING_VALUE;
57
70
  }
58
71
 
72
+ /** What the payout ratio is over: trailing twelve-month dividends over this, the EPS the P/E is on. */
73
+ export const PAYOUT_BASIS = "TTM diluted EPS";
74
+
59
75
  /** A payout over zero or negative earnings, written as a P/E over a loss is. */
60
76
  export const PAYOUT_NOT_MEANINGFUL = formatPriceEarnings(NOT_MEANINGFUL);
61
77
 
@@ -87,12 +103,16 @@ export function buildTrailingCashChartPoints(payments: DividendPayment[], now =
87
103
  const firstDate = sorted[0]?.exDate;
88
104
  if (!firstDate) return [];
89
105
  // Rolling cash can change on ex-dates, when payments leave the one-year
90
- // window or its late grace, and when the two-year cadence window moves.
106
+ // window or its late grace, when the two-year cadence window moves, and
107
+ // when a payment is judged off-cycle.
91
108
  // Date rollover deliberately expires February 29 on March 1 in a non-leap
92
109
  // year, when the clamped trailing-year cutoff first reaches that payment.
93
110
  const dates = new Set<number>([now.getTime()]);
94
111
  for (const payment of sorted) {
95
112
  dates.add(payment.exDate.getTime());
113
+ // A payment its slot a year on did not repeat stops counting as a period of the cadence (inferCadence).
114
+ const offCycle = payment.exDate.getTime() + OFF_CYCLE_DAYS * DAY;
115
+ if (offCycle <= now.getTime()) dates.add(offCycle);
96
116
  for (const years of [1, 2]) {
97
117
  const expiry = new Date(payment.exDate);
98
118
  expiry.setUTCFullYear(expiry.getUTCFullYear() + years);
@@ -134,6 +154,8 @@ export interface DividendRow {
134
154
  source?: string;
135
155
  /** A regular payment and an extra one on the same ex-date (DividendPayment.combined). */
136
156
  combined?: true;
157
+ /** A special, as the issuer's own form types it (DividendPayment.special). */
158
+ special?: true;
137
159
  }
138
160
 
139
161
  export function toDividendRows(payments: DividendPayment[]): DividendRow[] {
@@ -146,5 +168,6 @@ export function toDividendRows(payments: DividendPayment[]): DividendRow[] {
146
168
  ...(payment.declared ? { declared: payment.declared } : {}),
147
169
  ...(payment.source ? { source: payment.source.publisher } : {}),
148
170
  ...(payment.combined ? { combined: true as const } : {}),
171
+ ...(payment.special ? { special: true as const } : {}),
149
172
  }));
150
173
  }
@@ -63,7 +63,7 @@ export function doeHeadless(defaultTab: DoeTab | "all"): HeadlessPaneDefinition<
63
63
  return {
64
64
  shape: "bundle",
65
65
  argument: { kind: "free-text", optional: true, placeholder: "series", description: "A series such as cushing, gasoline or east; omit for the tables." },
66
- options: [{ key: "tab", type: "enum", values: [{ value: "all" }, ...DOE_TABS.map(({ value }) => ({ value }))], defaultValue: defaultTab,
66
+ options: [{ key: "tab", type: "enum", values: [{ value: "all" }, ...DOE_TABS], defaultValue: defaultTab,
67
67
  description: "Crude, products, gas storage, or all three." }],
68
68
  discovery: { aliases: ["DOE", "NGS"], dataRequirements: ["Gloom Cloud EIA weekly history"],
69
69
  limitations: ["Weekly data, published Wednesday (petroleum) and Thursday (gas) at 10:30 ET, moved by holidays.",
@@ -1,4 +1,4 @@
1
- import { useMemo } from "react";
1
+ import { useCallback, useMemo, useState } from "react";
2
2
  import type { DoeBoardPayload, DoeSeriesRow, DoeTab } from "../../../api-client/doe";
3
3
  import {
4
4
  ChartRead,
@@ -134,20 +134,29 @@ export function DoePane({ width, height, focused }: PaneProps) {
134
134
  const tab = doeTab(storedTab);
135
135
  const params = usePaneInstance()?.params;
136
136
  const initialSeries = params?.series ?? null;
137
- // Opened from a futures search on a contract this board does not cover (`FUT HG --tab inventories`): it says so.
137
+ // Opened from a futures search on a contract this board does not cover
138
+ // (`FUT HG --tab inventories`): it says so at once, in place of the board,
139
+ // which is read once a tab is picked and then shown under the note.
138
140
  const coverage = useMemo(() => doeCoverageNote(params?.query), [params?.query]);
139
- useRemoteUiNode(coverage ? { role: "report-notice", label: "Coverage", getMetadata: () => ({ text: coverage }) } : null);
140
- const resource = useAsyncResource(loadDoeBoard, { initialData: getCachedDoeBoard });
141
+ const [browsing, setBrowsing] = useState(false);
142
+ const covering = coverage != null && !browsing;
143
+ const selectTab = useCallback((value: string) => {
144
+ setBrowsing(true);
145
+ setTab(value);
146
+ }, [setTab]);
147
+ useRemoteUiNode(coverage && !covering ? { role: "report-notice", label: "Coverage", getMetadata: () => ({ text: coverage }) } : null);
148
+ const resource = useAsyncResource(covering ? null : loadDoeBoard, { initialData: getCachedDoeBoard });
141
149
  const data = resource.data?.payload ?? null;
142
150
  // The server not serving the board yet is a state of the data, not a failure.
143
151
  const notAvailable = !data && resource.error === DOE_NOT_AVAILABLE;
144
- const { strip, rows: tabRows } = usePaneTabs({ tabs: [...DOE_TABS], activeValue: tab, onSelect: setTab, focused, dense: true });
152
+ // No board is shown while the note stands in for it: none of its tabs is the open one.
153
+ const { strip, rows: tabRows } = usePaneTabs({ tabs: [...DOE_TABS], activeValue: covering ? null : tab, onSelect: selectTab, focused, dense: true });
145
154
  useAutoRefresh(resource.updatedAt, resource.load);
146
155
  usePaneRefreshKey(() => resource.reload(), { focused });
147
156
  // A refresh that failed shows the board an earlier read saved, and says when that copy is from.
148
157
  const savedAt = resource.data?.savedAt ?? null;
149
158
  usePaneNoticeFooter({ registrationId: "doe:notices", focused,
150
- notices: [...(coverage ? [coverage] : []), ...(data?.gaps ?? []), ...(resource.data?.refreshError && savedAt == null ? [resource.data.refreshError] : [])] });
159
+ notices: [...(coverage && !covering ? [coverage] : []), ...(data?.gaps ?? []), ...(resource.data?.refreshError && savedAt == null ? [resource.data.refreshError] : [])] });
151
160
  // What Vs 1Y and Vs 5Y are measured against on this tab: the EIA's published figures for gas storage.
152
161
  const basis = useMemo(() => data ? doeComparisonBasis(doeRows(data, tab)) : null, [data, tab]);
153
162
  const info = useMemo(() => {
@@ -163,7 +172,7 @@ export function DoePane({ width, height, focused }: PaneProps) {
163
172
  <Box width={width} height={height} flexDirection="column">
164
173
  {strip}
165
174
  <PaneStatusBody loading={resource.loading && !data} error={!data && !notAvailable ? resource.error : null}
166
- empty={notAvailable} emptyTitle={DOE_NOT_AVAILABLE} subject="oil and gas inventories">
175
+ empty={covering || notAvailable} emptyTitle={covering ? coverage : DOE_NOT_AVAILABLE} subject="oil and gas inventories">
167
176
  {data ? <DoeBoard payload={data} tab={tab} initialSeries={initialSeries} width={width} height={Math.max(3, height - tabRows)} focused={focused} /> : null}
168
177
  </PaneStatusBody>
169
178
  </Box>
@@ -34,10 +34,8 @@ const LIST_CACHE_POLICY = {
34
34
  expireMs: 7 * 24 * 60 * 60 * 1000,
35
35
  } as const;
36
36
 
37
- /**
38
- * A published transcript is immutable: the call already happened and the audio
39
- * is transcribed once. Keep it for a long time so re-reading is instant.
40
- */
37
+ const TRANSLATION_RECHECK_MS = 60_000;
38
+ /** A finished English transcript can be read again from the local cache. */
41
39
  const TRANSCRIPT_CACHE_POLICY = {
42
40
  staleMs: 30 * 24 * 60 * 60 * 1000,
43
41
  expireMs: 365 * 24 * 60 * 60 * 1000,
@@ -459,7 +457,12 @@ export async function loadTranscriptWithClient(
459
457
  callId,
460
458
  { sourceKey: CACHE_SOURCE, schemaVersion: CACHE_SCHEMA_VERSION },
461
459
  );
462
- if (!force && cached && !cached.stale) return cached.value;
460
+ if (!force && cached && !cached.stale) {
461
+ // A Japanese or Chinese original may gain an English edition after the reader opens it.
462
+ // Check its fetch time so this also works with copies saved before translation was available.
463
+ const awaitingEnglish = !cached.value.isTranslated && /^(?:zh|ja)(?:[-_]|$)|^(?:chinese|japanese)$/i.test(cached.value.language ?? "");
464
+ if (!awaitingEnglish || Date.now() - cached.fetchedAt < TRANSLATION_RECHECK_MS) return cached.value;
465
+ }
463
466
 
464
467
  const active = activeTranscriptFetches.get(callId);
465
468
  if (active && !force) return active;
@@ -12,7 +12,7 @@ export const earningsRippleHeadless: HeadlessPaneDefinition<"bundle"> = {
12
12
  shape: "bundle",
13
13
  freshness: { source: "SEC filings and Gloom Cloud", status: "not-a-feed", basis: "filings and earnings calendar" },
14
14
  argument: { kind: "symbol-list", placeholder: "tickers", description: "Holdings to check against their customers' and suppliers' report dates.", minimum: 1, maximum: 60 },
15
- options: [{ key: "tab", type: "enum", settingKey: "tab", defaultValue: "direct", values: [{ value: "direct" }, { value: "two-hop" }],
15
+ options: [{ key: "tab", type: "enum", settingKey: "tab", defaultValue: "direct", values: [{ value: "direct", label: "1 hop" }, { value: "two-hop", label: "2 hops" }],
16
16
  description: "Direct customers and suppliers, or also companies two hops away (Pro)." }],
17
17
  describe: (args) => `RIPL ${args.symbols.join(", ")}`,
18
18
  discovery: { screenshotReadiness: "live-dom", limitations: ["Customers each holding names in its own US filings, and suppliers whose US filings name it, with a share of revenue.",
@@ -56,7 +56,7 @@ type EconCalendarColumnId =
56
56
  export type EconCalendarColumn = DataTableColumn & { id: EconCalendarColumnId };
57
57
 
58
58
  type PersistedEconEvent = Omit<EconEvent, "date"> & { date: string };
59
- export type EconCalendarCacheEntry = { data: EconEvent[]; fetchedAt: number; stale: boolean };
59
+ export type EconCalendarCacheEntry = { data: EconEvent[]; fetchedAt: number; stale: boolean; fromEarlierRun?: true };
60
60
 
61
61
  const cache = createPluginCache<EconEvent[], PersistedEconEvent[]>({
62
62
  kind: CACHE_KIND, source: CACHE_SOURCE, schemaVersion: CACHE_SCHEMA_VERSION, policy: CACHE_POLICY,
@@ -100,25 +100,31 @@ const SPELLED_COUNTRY = "COUNTRY";
100
100
  const SPELLED_HEADER_MIN_EVENT_WIDTH = 24;
101
101
  /** A result says whether a forced reload asked for it, so its answer can reset the cursor. */
102
102
  type CalendarResult = EconCalendarLoadResult & { forced?: boolean };
103
- const loadEvents = async (force: boolean): Promise<CalendarResult> => ({ ...await loadCalendar(force), forced: force });
103
+ const loadEvents = async (force: boolean): Promise<CalendarResult> => ({
104
+ ...await loadCalendar(force || getCalendarCache()?.fromEarlierRun === true), forced: force,
105
+ });
104
106
  const cachedEvents = () => getCalendarCache();
105
107
 
106
108
  function EconCalendarPane({ focused, width, height }: PaneProps) {
107
109
  // loadCalendar serves a fresh cache without a request, so the pane can always
108
110
  // ask and still follow the global cadence once the cache goes stale.
109
- const calendar = useAsyncResource<CalendarResult>(loadEvents, { initialData: cachedEvents });
111
+ const paneVisible = usePaneVisible();
112
+ const calendar = useAsyncResource<CalendarResult>(loadEvents, { initialData: cachedEvents, deferLoad: !paneVisible });
110
113
  // A load made elsewhere, such as the print watch asking while a release is
111
114
  // due, reaches the open pane through the cache; the newer of the two wins.
112
115
  const [cacheVersion, setCacheVersion] = useState(0);
113
116
  useEffect(() => subscribeCalendar(() => setCacheVersion((version) => version + 1)), []);
114
117
  const cached = useMemo(() => getCalendarCache(), [cacheVersion]);
115
- const shown = cached && (!calendar.data || cached.fetchedAt > calendar.data.fetchedAt) ? cached : calendar.data;
118
+ const shown: CalendarResult | null = cached && (!calendar.data || cached.fetchedAt > calendar.data.fetchedAt) ? cached : calendar.data;
119
+ useEffect(() => {
120
+ if (shown === cached && calendar.savedAt != null) calendar.load();
121
+ }, [cached, calendar.load, calendar.savedAt, shown]);
116
122
  const loading = calendar.loading || (!shown && !calendar.error);
117
123
  const events = shown?.data ?? NO_EVENTS;
118
124
  const stale = shown?.stale ?? false;
119
125
  const fetchedAt = shown?.fetchedAt ?? null;
120
126
  // A cache that could not be refreshed arrives as a result, not a failure.
121
- const error = calendar.error ?? (loading ? null : calendar.data?.refreshError ?? null);
127
+ const error = calendar.error ?? (loading || shown?.source === "stale-fallback" ? null : shown?.refreshError ?? null);
122
128
  // The selected row and the open event are remembered by event id, so a
123
129
  // reload or a shared layout comes back to the same release.
124
130
  const [selectedKey, setSelectedKey] = usePluginPaneState<string | null>("selectedKey", null);
@@ -151,7 +157,6 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
151
157
 
152
158
  useAutoRefresh(stale ? null : fetchedAt, calendar.load);
153
159
 
154
- const paneVisible = usePaneVisible();
155
160
  // In view, a due high-impact print is asked for on the print watch's timing
156
161
  // and lands here through the cache; a covered or hidden pane asks nothing.
157
162
  useEffect(() => (paneVisible ? retainVisiblePrintRefresh() : undefined), [paneVisible]);
@@ -267,7 +272,7 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
267
272
  }, [returnToPresent, setCountryFilter, setSelectedKey]);
268
273
 
269
274
  // A forced reload goes back to the present once it answers.
270
- const forcedResult = calendar.data?.forced ? calendar.data : null;
275
+ const forcedResult = calendar.savedAt === null && calendar.data?.forced ? calendar.data : null;
271
276
  useEffect(() => {
272
277
  if (!forcedResult) return;
273
278
  setSelectedKey(null);
@@ -287,10 +292,14 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
287
292
  // cells over "07:00" while EVENT read "GDP Growth Ra…" (review, 12 Nov 2026).
288
293
  const timeLabelText = CALENDAR_TIME_ZONE_LABEL;
289
294
  const timeWidth = tableColumnWidth({ width: filtered.some(isAllDayEvent) ? "All day".length : 5, label: timeLabelText });
290
- const actualWidth = valueColumnWidth(filtered, "actual", 9);
291
- const forecastWidth = valueColumnWidth(filtered, "forecast", 10);
292
- const priorWidth = valueColumnWidth(filtered, "prior", 9);
293
- const minEventWidth = 12;
295
+ const compact = width < 58;
296
+ const showCountry = !compact || !/^[A-Z]{2}$/.test(countryFilter) || countryFilter === "EU";
297
+ const actualLabel = compact ? "ACT" : "ACTUAL";
298
+ const forecastLabel = compact ? "EST" : "FORECAST";
299
+ const actualWidth = tableColumnWidth({ width: valueColumnWidth(filtered, "actual", compact ? 3 : 9), label: actualLabel });
300
+ const forecastWidth = tableColumnWidth({ width: valueColumnWidth(filtered, "forecast", compact ? 3 : 10), label: forecastLabel });
301
+ const priorWidth = tableColumnWidth({ width: valueColumnWidth(filtered, "prior", compact ? 5 : 9), label: "PRIOR" });
302
+ const minEventWidth = tableColumnWidth({ width: compact ? 5 : 12, label: "EVENT" });
294
303
  // The reader's clock, with the weekday on rows where it is another day than the UTC one they are listed under.
295
304
  const readerLabel = readerZone ? timeZoneCity(readerZone).toUpperCase() : null;
296
305
  const readerWidth = !readerZone || !readerLabel ? 0 : tableColumnWidth({ label: readerLabel,
@@ -298,7 +307,7 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
298
307
  // Padding, one gap per column boundary, and the vertical scrollbar lane;
299
308
  // one column short of that clipped the PRIOR values at the right edge.
300
309
  const roomBeside = (count: number, timesWidth: number) => (impactWidth: number, countryWidth: number) => (
301
- width - 3 - count - (timesWidth + impactWidth + countryWidth + actualWidth + forecastWidth + priorWidth)
310
+ width - 3 - count + (showCountry ? 0 : 1) - (timesWidth + impactWidth + (showCountry ? countryWidth : 0) + actualWidth + forecastWidth + priorWidth)
302
311
  );
303
312
  const codeWidth = 2 + (flagged ? COUNTRY_FLAG_CELLS : 0);
304
313
  // The reader's column only where the event names keep room to read beside it, under the short headers.
@@ -315,19 +324,19 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
315
324
  const countryColumn = spelled
316
325
  ? { label: SPELLED_COUNTRY, width: spelledCountryWidth }
317
326
  : { label: "CTY", width: Math.max(3, codeWidth), title: "Country" };
318
- const eventWidth = Math.max(minEventWidth, eventRoom(impactColumn.width, countryColumn.width));
327
+ const eventWidth = Math.max(minEventWidth, eventRoom(tableColumnWidth(impactColumn), tableColumnWidth(countryColumn)));
319
328
 
320
329
  return [
321
330
  { id: "time", label: timeLabelText, width: timeWidth, align: "left" },
322
331
  ...withReader ? [{ id: "readerTime" as const, label: readerLabel!, width: readerWidth, align: "left" as const, title: readerZone! }] : [],
323
332
  { id: "impact", ...impactColumn, align: "left" },
324
- { id: "country", ...countryColumn, align: "left" },
333
+ ...showCountry ? [{ id: "country" as const, ...countryColumn, align: "left" as const }] : [],
325
334
  { id: "event", label: "EVENT", width: eventWidth, align: "left" },
326
- { id: "actual", label: "ACTUAL", width: actualWidth, align: "right" },
327
- { id: "forecast", label: "FORECAST", width: forecastWidth, align: "right" },
335
+ { id: "actual", label: actualLabel, title: "Actual", width: actualWidth, align: "right" },
336
+ { id: "forecast", label: forecastLabel, title: "Forecast", width: forecastWidth, align: "right" },
328
337
  { id: "prior", label: "PRIOR", width: priorWidth, align: "right" },
329
338
  ];
330
- }, [filtered, flagged, readerZone, width]);
339
+ }, [countryFilter, filtered, flagged, readerZone, width]);
331
340
  const separatorBg = blendHex(colors.bg, colors.border, 0.3);
332
341
  const staleness = fetchedAt ? formatStaleness(fetchedAt, now) : "";
333
342
  // The calendar has events and the filters hid them all: say which, with the way back.
@@ -359,7 +368,7 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
359
368
  // context; the footer ellipsizes a long event name.
360
369
  const nextText = nextEvent && nextCountdown ? `next ${econEventName(nextEvent)} ${nextCountdown}` : null;
361
370
  // The cached first paint is being replaced; its age only counts once a load has answered.
362
- const showStale = stale && (!loading || calendar.updatedAt !== null);
371
+ const showStale = stale && shown?.source !== "stale-fallback" && (!loading || calendar.updatedAt !== null);
363
372
  // An empty list says it in its empty state instead.
364
373
  const listedAfterStatus = listedAfter && !detailEvent && filtered.length > 0 ? listedAfter : null;
365
374
  // What the High filter, where the calendar opens, leaves out, and the key that lists it (Shift+F steps back to All).
@@ -599,7 +608,6 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
599
608
  ) : undefined}
600
609
  emptyStateTitle={listedAfter ?? "No events"}
601
610
  emptyStateHint={emptyStateHint}
602
- showHorizontalScrollbar={false}
603
611
  />
604
612
  );
605
613
  }
@@ -21,7 +21,7 @@ const savedPath = (id: string) => `saved/${encodeURIComponent(id)}`;
21
21
  export const screenerApi = {
22
22
  query: (query: ScreenQuery, signal?: AbortSignal, client: ScreenerClient = apiClient) =>
23
23
  client.equityScreener<ScreenPayload>("query", json("POST", query, { signal })),
24
- fields: (signal?: AbortSignal) => apiClient.equityScreener<ScreenFieldsResponse>("fields?include=social,research,attention,hiring-apps,kpis,volatility,dividends,technical,option-volatility,ownership,quality,scores,grades", { signal }),
24
+ fields: (signal?: AbortSignal) => apiClient.equityScreener<ScreenFieldsResponse>("fields?include=social,research,attention,hiring-apps,kpis,volatility,dividends,technical,option-volatility,ownership,quality,scores,grades,trailing-yield", { signal }),
25
25
  export: (definition: ScreenDefinition, snapshotId: string) =>
26
26
  apiClient.equityScreener<ScreenExportResponse>("export", json("POST", { ...definition, snapshotId }, { headers: { Accept: "application/json" } })),
27
27
  saved: async (signal?: AbortSignal, client: ScreenerClient = apiClient) =>
@@ -1,6 +1,6 @@
1
1
  import type { HeadlessPaneDefinition } from "../../../types/plugin";
2
2
  import { isProLock } from "../../../cli/pane-functions/access-gate";
3
- import type { HeadlessPaneColumn, HeadlessPaneContext } from "../../../types/headless";
3
+ import type { HeadlessPaneColumn, HeadlessPaneContext, HeadlessPaneEntry } from "../../../types/headless";
4
4
  import {
5
5
  KPI_FIELDS,
6
6
  NUMERIC_FIELDS,
@@ -14,8 +14,9 @@ import { EXTENDED_SESSION_LABELS, type ExtendedSession } from "../../../market-d
14
14
  import { buildQuoteKey } from "../../../market-data/selectors";
15
15
  import type { Quote } from "../../../types/financials";
16
16
  import { MISSING_VALUE, formatCurrency, formatPercentRaw } from "../../../utils/format";
17
+ import { currencyPriceMinDigits, formatMarketPriceWithCurrency } from "../../../market-data/market/format";
17
18
  import { fetchSavedScreens, fetchScreen, fetchScreenCheck } from "./client";
18
- import { ideaMetricSetting, SCREEN_IDEAS, screenIdea } from "./ideas";
19
+ import { ideaMetricSetting, SCREEN_IDEAS, screenIdea, type ScreenIdea } from "./ideas";
19
20
  import { checkRows, screenCheckSummary, screenCheckTicker } from "./screen-check";
20
21
  import { overlayScreenQuotes, screenExtendedSessions, sortLiveScreenRows } from "./live";
21
22
  import {
@@ -26,9 +27,11 @@ import {
26
27
  unmatchedCategoryValues,
27
28
  } from "./categories";
28
29
  import { REPORT_ROWS } from "../shared/headless-options";
30
+ import { shellWord } from "../../../utils/shell-word";
29
31
  import { findNamedCollection, readWatchlistArgument } from "../../../portfolio/collection-name";
30
32
  import {
31
33
  appendScreenPage,
34
+ criterionText,
32
35
  DEFAULT_SCREEN,
33
36
  EXAMPLE_SCREEN_DEFINITION,
34
37
  formatScreenMetric,
@@ -99,8 +102,12 @@ async function loadRowQuotes(rows: readonly ScreenRow[], ctx: HeadlessPaneContex
99
102
  }
100
103
  }
101
104
 
105
+ // A line quoted in pence keeps the decimals it trades in (GCP's £0.828), as `quote` prints it.
102
106
  const price = (value: unknown, row: Record<string, unknown>) =>
103
- typeof value === "number" && typeof row.currency === "string" && row.currency ? formatCurrency(value, row.currency) : MISSING_VALUE;
107
+ typeof value !== "number" || typeof row.currency !== "string" || !row.currency ? MISSING_VALUE
108
+ : typeof row.quotedUnitDivisor === "number" && row.quotedUnitDivisor > 1
109
+ ? formatMarketPriceWithCurrency(value, row.currency, { minimumFractionDigits: currencyPriceMinDigits(row.currency), quotedUnitDivisor: row.quotedUnitDivisor })
110
+ : formatCurrency(value, row.currency);
104
111
  const percent = (value: unknown) => typeof value === "number" ? formatPercentRaw(value) : MISSING_VALUE;
105
112
 
106
113
  /** The pre-market, after-hours or overnight print and its move from the close in Last, for the rows that have one. */
@@ -178,12 +185,86 @@ function extraMetricCell(field: NumericField, metric: ScreenMetric | undefined):
178
185
  return metric.value != null && /^[A-Z]{3}$/.test(metric.unit) ? `${value} ${metric.unit}` : value;
179
186
  }
180
187
 
181
- /** What the State column's words mean, said once under a report whose first metric has them. */
188
+ /** What the State columns' words mean, said once under a report where a shown metric has them. */
182
189
  const STATE_LEGEND: ReadonlyArray<{ state: ScreenMetric["state"]; text: string }> = [
183
190
  { state: "partial", text: "A partial State means the source gives no date for the figure, so As of is when it was collected, or that it covers part of what it measures." },
184
- { state: "stale", text: "A stale State means the figure is older than its field allows, such as a quote over 4 days old or fundamentals collected over 7 days ago." },
191
+ { state: "stale", text: "A stale State means the figure is older than its field allows, such as a price from before its exchange's latest session, a quote over 4 days old or fundamentals collected over 7 days ago." },
185
192
  ];
186
193
 
194
+ /** A date as a report cell prints it: a day as it is, an instant to the minute in UTC. */
195
+ function stampText(stamp: unknown): string {
196
+ if (typeof stamp !== "string" || !stamp) return MISSING_VALUE;
197
+ if (/^\d{4}-\d{2}-\d{2}$/.test(stamp)) return stamp;
198
+ const time = Date.parse(stamp);
199
+ return Number.isFinite(time) ? `${new Date(time).toISOString().slice(0, 16).replace("T", " ")} UTC` : stamp;
200
+ }
201
+
202
+ /**
203
+ * A metric's own As of and State, as the first metric's columns print them.
204
+ * A forecast is dated by when it was given, and names the period it is for
205
+ * apart, so a forward date never reads as when the figure was observed.
206
+ */
207
+ function metricStamp(metric: ScreenMetric | undefined): { asOf: string; state: string } {
208
+ if (!metric) return { asOf: MISSING_VALUE, state: MISSING_VALUE };
209
+ const stamp = metricDate(metric);
210
+ const date = stamp.collected ? `${stamp.text} (collected)` : stamp.text;
211
+ return {
212
+ asOf: metric.periodEnd ? `${date} (for the period ending ${metric.periodEnd})` : date,
213
+ state: metric.access === "pro" ? "locked" : metric.state,
214
+ };
215
+ }
216
+
217
+ /**
218
+ * When the row's Last is from (the session it closed, the time it traded, or
219
+ * when a last price on record was printed), its state, and, when it is not a
220
+ * current price, why.
221
+ */
222
+ function lastStamp(metric: ScreenMetric): { at: string | null; state: string; note: string | null } {
223
+ const at = metric.printedAt ?? metric.asOf ?? (metric.value != null ? metric.observedAt : null);
224
+ const note = metric.value == null || metric.state === "available" ? null
225
+ : metric.reason ?? (metric.state === "stale" ? "The last price on record: older than a current price allows" : null);
226
+ return { at, state: metric.state, note };
227
+ }
228
+
229
+ /** The column the rows are ordered by: the first metric's, one every report prints, or the one `extraScreenColumns` adds for the sort. */
230
+ function sortedColumnKey(sortField: string, metric: NumericField): string {
231
+ return sortField === metric ? "value" : sortField;
232
+ }
233
+
234
+ /**
235
+ * What the rows are: the screen as it ran, how they are ordered, and the
236
+ * snapshot they come from, so a saved report says how to get them again. The
237
+ * command is the definition exactly, as text an export keeps whole (a JSON
238
+ * cell would be flattened into words).
239
+ */
240
+ function screenEntries(
241
+ data: ScreenPayload,
242
+ sortedBy: string,
243
+ source: { preset?: ScreenIdea; savedName?: string; metrics: readonly NumericField[] },
244
+ ): HeadlessPaneEntry[] {
245
+ const { definition, snapshot, universe } = data;
246
+ const direction = definition.sort.direction === "desc" ? "descending" : "ascending";
247
+ return [
248
+ ...(source.preset ? [{ key: "preset", label: "Preset", value: `${source.preset.name} (--preset ${source.preset.id})` }] : []),
249
+ ...(source.savedName ? [{ key: "savedScreen", label: "Saved screen", value: source.savedName }] : []),
250
+ { key: "criteria", label: "Criteria", value: definition.criteria.length ? definition.criteria.map(criterionText).join("; ") : "None" },
251
+ { key: "currency", label: "Currency", value: definition.currency ?? "None: no criterion compares money" },
252
+ { key: "sort", label: "Sorted by", value: `${sortedBy} (${definition.sort.field}), ${direction}` },
253
+ { key: "command", label: "Command", value: `gloom fn EQS --definition ${shellWord(spacedJson(definition))} --metric ${source.metrics.join(",")}` },
254
+ { key: "snapshot", label: "Snapshot", value: snapshot?.id ?? MISSING_VALUE },
255
+ { key: "assembledAt", label: "Assembled", value: snapshot?.assembledAt ?? MISSING_VALUE },
256
+ { key: "matched", label: "Matches", value: `${universe.matched.toLocaleString("en-US")} of ${universe.covered.toLocaleString("en-US")} covered listings` },
257
+ ];
258
+ }
259
+
260
+ /** The newest input the snapshot observed, as of its assembly or before; a later date is no observation. */
261
+ function newestInput(snapshot: ScreenPayload["snapshot"]): string | null {
262
+ const newest = snapshot?.sourceNewestAt;
263
+ if (!newest || !snapshot) return null;
264
+ const at = Date.parse(newest), assembled = Date.parse(snapshot.assembledAt);
265
+ return Number.isFinite(at) && Number.isFinite(assembled) && at <= assembled ? newest : null;
266
+ }
267
+
187
268
  /** A typed `--definition`, checked; every error points at the worked example. */
188
269
  function readDefinition(text: string): ScreenDefinition {
189
270
  const pointer = "The example in gloom catalog EQS is a valid definition to start from.";
@@ -386,50 +467,83 @@ export const equityScreenerHeadless: HeadlessPaneDefinition<"bundle"> = {
386
467
  const ytdBase = screenYtdBase(data.rows, data.snapshot?.assembledAt);
387
468
  // The metrics after the first, then the field the rows are sorted by, so the order shown is explained by a column.
388
469
  const extra = extraScreenColumns(metrics, data.definition.sort.field);
389
- const states = new Set(rows.map((row) => row.metrics[metric].state));
470
+ const extraMetrics = extra.filter(isNumericField);
471
+ // Last is the first metric's own column when it is the price; otherwise it carries its own date and state.
472
+ const lastShown = metric !== "price";
473
+ // Every State column a row shows: the first metric's, each other metric's, and Last's.
474
+ const stated = [...extraMetrics, ...lastShown ? ["price" as const] : []];
475
+ const states = new Set(rows.flatMap((row) => [row.metrics[metric].state,
476
+ ...stated.flatMap((field) => row.metrics[field] && row.metrics[field].access !== "pro" ? [row.metrics[field].state] : [])]));
390
477
  const legend = STATE_LEGEND.filter(({ state }) => states.has(state)).map(({ text }) => text);
391
478
  const locked = rows.some((row) => metrics.some((field) => row.metrics[field]?.access === "pro"));
392
479
  const notes = [...watchlistRead.notes, ...listingReadNotes(data.listings, data.definition.currency), ...kpiGaps, ...legend,
393
480
  ...(locked && !errors.some(isProLock) ? ["Locked figures require Gloom Pro access."] : [])];
481
+ const sortedKey = sortedColumnKey(data.definition.sort.field, metric);
482
+ const mark = data.definition.sort.direction === "desc" ? "▼" : "▲";
483
+ const columns: HeadlessPaneColumn[] = [
484
+ { key: "symbol", header: "Symbol" },
485
+ { key: "exchange", header: "Exchange" },
486
+ { key: "name", header: "Name" },
487
+ // The focus metric says it once when it is the price or the move.
488
+ ...(lastShown ? [{ key: "price", header: "Last", align: "right" as const, format: price }] : []),
489
+ ...(metric === "changePercent" ? [] : [{ key: "changePercent", header: "Chg%", align: "right" as const, format: percent }]),
490
+ ...extendedSessions.map(extendedColumn),
491
+ // When Last and its move are from, and whether that is a current price. Exports write these after their older
492
+ // columns, so none of those moves.
493
+ ...(lastShown ? [
494
+ { key: "priceAsOf", header: "Last as of", textFormat: stampText, optional: true, exportLast: true },
495
+ { key: "priceState", header: "Last state", optional: true, exportLast: true },
496
+ ] : []),
497
+ // YTD names the close it is measured from: `YTD% vs 31 Dec close`.
498
+ { key: "value", header: screenColumnLabel(metric, ytdBase, "report"), align: "right" },
499
+ { key: "unit", header: "Unit" },
500
+ { key: "percentile", header: "Covered pctl", align: "right" },
501
+ { key: "asOf", header: "As of" },
502
+ { key: "state", header: "State" },
503
+ // Every metric after the first is dated and stated on its own, never by the first's columns.
504
+ ...extra.flatMap((field): HeadlessPaneColumn[] => {
505
+ if (!isNumericField(field)) return [{ key: field, header: CATEGORY_HEADERS[field] }];
506
+ const label = screenColumnLabel(field, ytdBase, "report");
507
+ return [
508
+ { key: field, header: label, align: "right" },
509
+ { key: `${field}AsOf`, header: `${label} as of`, literalHeader: true, optional: true, exportLast: true },
510
+ { key: `${field}State`, header: `${label} state`, literalHeader: true, optional: true, exportLast: true },
511
+ ];
512
+ }),
513
+ // Why a row's Last is not a current price, under that row.
514
+ ...(lastShown ? [{ key: "priceNote", header: "Last note", underRow: true, exportLast: true }] : []),
515
+ ];
516
+ // The text report marks the column the rows are ordered by (`(sorted descending)` in plain text); exports name it in Screen.
517
+ const sortedColumn = columns.find((column) => column.key === sortedKey);
518
+ const sortedBy = sortedColumn?.header ?? screenLabel(data.definition.sort.field);
519
+ if (sortedColumn) sortedColumn.textHeader = `${sortedColumn.header} ${mark}`;
394
520
  // Payload status also counts ordinary per-field sparsity; only generation
395
521
  // warnings are failures, and more pages are not an error.
396
522
  return {
397
- freshness: { asOf: data.snapshot?.sourceNewestAt ?? null },
523
+ freshness: { asOf: newestInput(data.snapshot) },
398
524
  complete: !data.nextCursor && errors.length === 0,
399
525
  errors,
400
526
  ...(notes.length ? { notes } : {}),
401
527
  ...(rows.length > 0 && unmatchedText ? { warnings: [unmatchedText] } : {}),
402
528
  sections: [
529
+ // First, so a saved report opens with what it is a screen of and how its rows are ordered.
530
+ { title: "Screen", entries: screenEntries(data, sortedBy, { preset, savedName, metrics }) },
403
531
  {
404
532
  title: "Matching equities",
405
533
  ...(empty ? { empty } : {}),
406
- columns: [
407
- { key: "symbol", header: "Symbol" },
408
- { key: "exchange", header: "Exchange" },
409
- { key: "name", header: "Name" },
410
- // The focus metric says it once when it is the price or the move.
411
- ...(metric === "price" ? [] : [{ key: "price", header: "Last", align: "right" as const, format: price }]),
412
- ...(metric === "changePercent" ? [] : [{ key: "changePercent", header: "Chg%", align: "right" as const, format: percent }]),
413
- ...extendedSessions.map(extendedColumn),
414
- // YTD names the close it is measured from: `YTD% vs 31 Dec close`.
415
- { key: "value", header: screenColumnLabel(metric, ytdBase, "report"), align: "right" },
416
- { key: "unit", header: "Unit" },
417
- { key: "percentile", header: "Covered pctl", align: "right" },
418
- { key: "asOf", header: "As of" },
419
- { key: "state", header: "State" },
420
- ...extra.map((field): HeadlessPaneColumn => isNumericField(field)
421
- ? { key: field, header: screenColumnLabel(field, ytdBase, "report"), align: "right" }
422
- : { key: field, header: CATEGORY_HEADERS[field] }),
423
- ],
534
+ columns,
424
535
  rows: rows.map((row) => {
425
536
  const observation = row.metrics[metric];
426
- const stamp = metricDate(observation);
537
+ const focus = metricStamp(observation);
538
+ const last = lastStamp(row.metrics.price);
427
539
  return {
428
540
  symbol: row.symbol,
429
541
  exchange: row.exchange,
430
542
  name: row.name,
431
543
  currency: row.currency,
432
544
  price: row.metrics.price.value,
545
+ ...(lastShown ? { priceAsOf: last.at, priceState: last.state } : {}),
546
+ ...row.quotedUnitDivisor ? { quotedUnitDivisor: row.quotedUnitDivisor } : {},
433
547
  changePercent: row.metrics.changePercent.value,
434
548
  extendedSession: row.extended?.session ?? null,
435
549
  extendedPrice: row.extended?.price ?? null,
@@ -441,11 +555,14 @@ export const equityScreenerHeadless: HeadlessPaneDefinition<"bundle"> = {
441
555
  observation.percentile.value == null
442
556
  ? null
443
557
  : Math.round(observation.percentile.value),
444
- asOf: stamp.collected ? `${stamp.text} (collected)` : stamp.text,
445
- state: observation.access === "pro" ? "locked" : observation.state,
446
- ...Object.fromEntries(extra.map((field) => [field, isNumericField(field)
447
- ? extraMetricCell(field, row.metrics[field])
448
- : row[field]])),
558
+ asOf: focus.asOf,
559
+ state: focus.state,
560
+ ...Object.fromEntries(extra.flatMap((field): Array<[string, unknown]> => {
561
+ if (!isNumericField(field)) return [[field, row[field]]];
562
+ const own = metricStamp(row.metrics[field]);
563
+ return [[field, extraMetricCell(field, row.metrics[field])], [`${field}AsOf`, own.asOf], [`${field}State`, own.state]];
564
+ })),
565
+ ...(lastShown ? { priceNote: last.note } : {}),
449
566
  };
450
567
  }),
451
568
  },
@@ -459,6 +576,7 @@ export const equityScreenerHeadless: HeadlessPaneDefinition<"bundle"> = {
459
576
  returned: data.rows.length,
460
577
  hasMore: !!data.nextCursor,
461
578
  metrics,
579
+ sort: { field: data.definition.sort.field, direction: data.definition.sort.direction, column: sortedBy },
462
580
  ...(unmatched.length > 0 ? { unmatchedValues: unmatchedCategoryValues(data.definition, data, rows) } : {}),
463
581
  priceBasis: "price, changePercent and the market cap are the regular session, read from each row's quote as `quote` reads it: after the close, its close and that close's move. trailingPE, forwardPE and priceToBook are over that price, as `valuation` reprices them. A pre-market, after-hours or overnight print is in extendedPrice and extendedChangePercent, measured from that close. Membership and percentiles are the snapshot's, which ranks by the close; a sort on price, changePercent, volume, marketCap or those multiples orders these rows by the figures shown.",
464
582
  notices: data.nextCursor