@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
@@ -5,6 +5,12 @@
5
5
  export interface ExchangeNotation {
6
6
  /** Every spelling read as a venue, by the venue's code. */
7
7
  aliases: Readonly<Record<string, string>>
8
+ /**
9
+ * Other spellings of venues `aliases` does not name, by the venue's code,
10
+ * read only where a listing is typed (INTP:IDX is INTP:JAKARTA): never in a
11
+ * saved ticker or as a listing suffix.
12
+ */
13
+ typedAliases: Readonly<Record<string, string>>
8
14
  /** What a listing key writes for a venue when it is not the code (its MIC). */
9
15
  keyCodes: Readonly<Record<string, string>>
10
16
  /** Venue names, for output that says where a listing trades. */
@@ -213,6 +219,11 @@ export const EXCHANGE_NOTATION: ExchangeNotation = {
213
219
  XCAI: "EGX",
214
220
  EGYPT: "EGX",
215
221
  CAIRO: "EGX",
222
+ HOSE: "HOSE",
223
+ HSX: "HOSE",
224
+ XSTC: "HOSE",
225
+ HNX: "HNX",
226
+ XHNX: "HNX",
216
227
  CME: "CME",
217
228
  CBT: "CBT",
218
229
  CBOT: "CBT",
@@ -239,6 +250,50 @@ export const EXCHANGE_NOTATION: ExchangeNotation = {
239
250
  KRX: "KRX",
240
251
  EURONEXT: "AMS",
241
252
  },
253
+ typedAliases: {
254
+ "TEXAS STOCK EXCHANGE": "TXSE",
255
+ BCXE: "CBOE",
256
+ XDUB: "ISE",
257
+ XMSM: "ISE",
258
+ IRISH: "ISE",
259
+ KLSE: "BURSAMY",
260
+ XKLS: "BURSAMY",
261
+ IDX: "JAKARTA",
262
+ XIDX: "JAKARTA",
263
+ BKK: "SET",
264
+ XBKK: "SET",
265
+ THAILAND: "SET",
266
+ BCS: "BVS",
267
+ SGO: "BVS",
268
+ XSGO: "BVS",
269
+ SANTIAGO: "BVS",
270
+ BUX: "BUD",
271
+ XBUD: "BUD",
272
+ BUDAPEST: "BUD",
273
+ ATHEX: "ATH",
274
+ ASEX: "ATH",
275
+ ATHENS: "ATH",
276
+ XBSE: "BVB",
277
+ IST: "BIST",
278
+ XIST: "BIST",
279
+ ISTANBUL: "BIST",
280
+ XADS: "ADX",
281
+ ADSM: "ADX",
282
+ "ABU DHABI": "ADX",
283
+ XKAR: "PSX",
284
+ KAR: "PSX",
285
+ KARACHI: "PSX",
286
+ MUN: "MUNICH",
287
+ XMUN: "MUNICH",
288
+ SWB: "XSTU",
289
+ STU: "XSTU",
290
+ STUTTGART: "XSTU",
291
+ DUS: "XDUS",
292
+ BER: "XBER",
293
+ HAM: "XHAM",
294
+ HAN: "HANOVER",
295
+ XHAN: "HANOVER",
296
+ },
242
297
  keyCodes: {
243
298
  NASDAQ: "XNAS",
244
299
  NYSE: "XNYS",
@@ -329,6 +384,8 @@ export const EXCHANGE_NOTATION: ExchangeNotation = {
329
384
  MSX: "Muscat Stock Exchange",
330
385
  KUWAIT: "Boursa Kuwait",
331
386
  EGX: "Egyptian Exchange",
387
+ HOSE: "Ho Chi Minh Stock Exchange",
388
+ HNX: "Hanoi Stock Exchange",
332
389
  CBT: "CBOT",
333
390
  NYM: "NYMEX",
334
391
  CMX: "COMEX",
@@ -356,4 +413,4 @@ export const EXCHANGE_NOTATION: ExchangeNotation = {
356
413
  },
357
414
  }
358
415
 
359
- export const EXCHANGE_NOTATION_VERSION = "936f2769090c78dd"
416
+ export const EXCHANGE_NOTATION_VERSION = "eb76ebd1ac8be330"
@@ -47,6 +47,8 @@ export const EXCHANGE_TIME_ZONES: Record<string, string> = {
47
47
  LSE: "Europe/London",
48
48
  ASX: "Australia/Sydney",
49
49
  SGX: "Asia/Singapore",
50
+ HOSE: "Asia/Ho_Chi_Minh",
51
+ HNX: "Asia/Ho_Chi_Minh",
50
52
  KRX: "Asia/Seoul",
51
53
  KOSDAQ: "Asia/Seoul",
52
54
  NZX: "Pacific/Auckland",
@@ -94,6 +96,19 @@ export function isKnownExchangeCode(value?: string): boolean {
94
96
  return !!normalized && KNOWN_EXCHANGE_CODES.has(normalized);
95
97
  }
96
98
 
99
+ /**
100
+ * The venue a code the app does not know names where a listing is typed with it: IDX and XIDX are the Indonesia
101
+ * Stock Exchange (JAKARTA), KLSE Bursa Malaysia, BKK the Stock Exchange of Thailand (the notation table's
102
+ * `typedAliases`, Gloom Cloud's own reading). Never read from a saved ticker or as a listing suffix, so a key is
103
+ * built from the venue's code and none already saved moves. Undefined for a code the app knows, or one no venue
104
+ * is written as.
105
+ */
106
+ export function typedExchangeVenue(value?: string): string | undefined {
107
+ const normalized = normalizeExchange(value);
108
+ if (!normalized || KNOWN_EXCHANGE_CODES.has(normalized)) return undefined;
109
+ return EXCHANGE_NOTATION.typedAliases[normalized];
110
+ }
111
+
97
112
  /** "Warsaw Stock Exchange" for a venue with a name, the canonical code otherwise (NASDAQ, whose name is its code). */
98
113
  export function exchangeName(value?: string): string {
99
114
  const code = canonicalExchange(value);
@@ -140,11 +155,15 @@ export function isSharedExchangeCode(value?: string): boolean {
140
155
 
141
156
  /**
142
157
  * Every venue a typed exchange code can name, as canonical codes: TSE is
143
- * TSX or JPX, PAR is EPA. Empty for no code.
158
+ * TSX or JPX, PAR is EPA, IDX is JAKARTA (or IDX, where a row is saved on
159
+ * it). Empty for no code.
144
160
  */
145
161
  export function exchangeCodeVenues(value?: string): string[] {
146
162
  const normalized = normalizeExchange(value);
147
163
  if (!normalized) return [];
164
+ // A typed spelling of a venue (IDX) is that venue, or the spelling a row was saved under before it was read.
165
+ const typed = typedExchangeVenue(normalized);
166
+ if (typed) return [typed, normalized];
148
167
  return [...(SHARED_EXCHANGE_CODES[normalized] ?? [canonicalExchange(normalized)])];
149
168
  }
150
169
 
@@ -271,6 +290,29 @@ export function displayTickerKey(key: string): string {
271
290
  return isKnownExchangeCode(parsePublicTickerKey(key).exchange) ? canonicalTickerKey(key) : key;
272
291
  }
273
292
 
293
+ /** A venue by the MIC a stored key writes for it (`XHKG` is HKEX), for the venues whose key code is not their own. */
294
+ const VENUE_BY_KEY_CODE: ReadonlyMap<string, string> = new Map(
295
+ Object.entries(EXCHANGE_NOTATION.keyCodes).filter(([venue, code]) => venue !== code).map(([venue, code]) => [code, venue]),
296
+ );
297
+
298
+ /** A stored listing key in running text: a symbol, a colon and a key code (`0700:XHKG`, `XYZ:XNYS`). */
299
+ const STORED_LISTING_KEY = new RegExp(
300
+ `(?<![\\w:.^=-])([A-Z0-9^][A-Z0-9.^=-]*):(${[...VENUE_BY_KEY_CODE.keys()].join("|")})(?![\\w:])`,
301
+ "g",
302
+ );
303
+
304
+ /**
305
+ * Text with every stored listing key in it written as a person types it, by
306
+ * its venue's own code (displayTickerKey): "No data for 0700:XHKG" reads "No
307
+ * data for 0700:HKEX", as titles, cards and the command bar name it. Anything
308
+ * else stays as written. For text a pane or the CLI shows that may carry a key
309
+ * as it was stored: an error, a state's title, a window's saved title.
310
+ */
311
+ export function displayListingKeys(text: string): string {
312
+ if (!text.includes(":")) return text;
313
+ return text.replace(STORED_LISTING_KEY, (_match, symbol: string, code: string) => `${symbol}:${VENUE_BY_KEY_CODE.get(code)!}`);
314
+ }
315
+
274
316
  /**
275
317
  * A stored key as the listing a request names: a row saved under its venue's
276
318
  * code (`ES3:XSES`, as a key is when another listing holds the bare symbol)
@@ -104,10 +104,22 @@ export function formatCurrencyCode(
104
104
  return `${value < 0 && /[1-9]/.test(body) ? "-" : ""}${body} ${code}`;
105
105
  }
106
106
 
107
- /** Preserve fractional per-share distributions, including split-adjusted history. */
107
+ /**
108
+ * The decimals a per-share distribution is written to: a ten-thousandth of
109
+ * its currency's minor unit, whichever unit it is in. HSBC states its HK$ and
110
+ * sterling amounts to six decimals (HK$0.784088, £0.076442), the same pound
111
+ * amount in pence is 7.6442p, and a split-adjusted $0.000469 keeps its digits;
112
+ * an amount converted at a market rate (Shell's 29.858244p before its sterling
113
+ * fixing) or a sum of them is no finer than that, 29.8582p.
114
+ */
115
+ function distributionAmountDigits(currency = "USD"): number {
116
+ return minorUnitSign(currency) ? 4 : currencyPriceDigits(currency) + 4;
117
+ }
118
+
119
+ /** A per-share distribution to distributionAmountDigits, its currency's usual decimals at least. */
108
120
  export function formatDistributionAmount(value: number | undefined, currency = "USD"): string {
109
121
  if (value == null || !Number.isFinite(value)) return MISSING_VALUE;
110
- return formatMoney(value, currency, 6);
122
+ return formatMoney(value, currency, distributionAmountDigits(currency));
111
123
  }
112
124
 
113
125
  /** Signs a fixed-decimal move; one that rounds to zero is unsigned (0.00, never +0.00 or -0.00). */
@@ -220,6 +232,29 @@ export function formatNumber(value: number | undefined, decimals = 2): string {
220
232
  return getNumberFormatter(decimals).format(value);
221
233
  }
222
234
 
235
+ const tradeSizeFormatters = new Map<number, Intl.NumberFormat>();
236
+
237
+ /**
238
+ * A traded size, as every book, tape and size column writes it: a bid or ask
239
+ * size, a print's size, a lot count. A whole number reads as it always has
240
+ * (1,500); a fraction keeps up to four decimals, and one under 1 four
241
+ * significant digits (0.001235), so a coin's size never rounds to 0.
242
+ * `compact` writes a thousand or more as a compact column does (1.5k).
243
+ */
244
+ export function formatTradeSize(value: number | null | undefined, { compact = false }: { compact?: boolean } = {}): string {
245
+ if (value == null || !Number.isFinite(value)) return MISSING_VALUE;
246
+ if (compact && Math.abs(value) >= 1000) return formatCompact(value);
247
+ if (Number.isInteger(value)) return getNumberFormatter(0).format(value);
248
+ const abs = Math.abs(value);
249
+ const decimals = abs >= 1 ? 4 : Math.min(12, 3 - Math.floor(Math.log10(abs)));
250
+ let formatter = tradeSizeFormatters.get(decimals);
251
+ if (!formatter) {
252
+ formatter = new Intl.NumberFormat("en-US", { maximumFractionDigits: decimals });
253
+ tradeSizeFormatters.set(decimals, formatter);
254
+ }
255
+ return formatter.format(value);
256
+ }
257
+
223
258
  /**
224
259
  * A value to a count of significant digits, so a small ratio keeps its leading
225
260
  * digits (0.0005664, not 0.0006) while a large one reads as a plain number
@@ -0,0 +1,38 @@
1
+ import type { PaneTemplateDef } from "../types/plugin";
2
+
3
+ const STOP_WORDS = new Set(["a", "an", "and", "at", "by", "for", "from", "in", "is", "of", "on", "or", "the", "to", "with"]);
4
+
5
+ export function functionQueryTerms(query: string): string[] {
6
+ const words = query.toLowerCase().trim().split(/\s+/).filter(Boolean);
7
+ const named = words.filter((word) => !STOP_WORDS.has(word));
8
+ return named.length > 0 ? named : words;
9
+ }
10
+
11
+ function searchStem(text: string): string {
12
+ return text.replace(/\bcompar(?:isons?|ing|e[ds]?)\b/g, "compare");
13
+ }
14
+
15
+ function startsWord(text: string, phrase: string): boolean {
16
+ for (let at = text.indexOf(phrase); at >= 0; at = text.indexOf(phrase, at + 1)) {
17
+ if (at === 0 || !/[a-z0-9]/.test(text[at - 1]!)) return true;
18
+ }
19
+ return false;
20
+ }
21
+
22
+ export function matchesFunctionPhrase(text: string, phrase: string): boolean {
23
+ const target = text.toLowerCase();
24
+ const query = phrase.toLowerCase();
25
+ return !query || startsWord(target, query) || startsWord(searchStem(target), searchStem(query));
26
+ }
27
+
28
+ export function matchesFunctionSearch(query: string, fields: readonly string[]): boolean {
29
+ return functionQueryTerms(query).every((term) => fields.some((field) => matchesFunctionPhrase(field, term)));
30
+ }
31
+
32
+ export function paneTemplateSearchFields(template: PaneTemplateDef, pane?: { headless?: PaneTemplateDef["headless"] }): string[] {
33
+ const discovery = (template.headless ?? pane?.headless)?.discovery;
34
+ return [...template.keywords ?? [], template.label, template.description, template.paneId, template.id,
35
+ template.shortcut?.prefix ?? "", ...template.shortcut?.aliases ?? [],
36
+ ...discovery?.aliases ?? [], ...discovery?.suggestFor ?? [], ...discovery?.intents ?? [],
37
+ ...discovery?.opens?.flatMap((opening) => opening.words) ?? []];
38
+ }
@@ -1,3 +1,5 @@
1
+ import { functionQueryTerms, matchesFunctionPhrase } from "./function-search";
2
+
1
3
  interface FuzzyMatchResult {
2
4
  match: boolean;
3
5
  score: number;
@@ -43,7 +45,7 @@ function matchWordPrefixRun(query: string, label: string): FuzzyMatchResult {
43
45
  * up in the full haystack; the looser fallback only ever sees the label, since
44
46
  * keywords and descriptions are there to be found by whole words, not letters.
45
47
  */
46
- function matchTerm(term: string, haystack: string, label: string): FuzzyMatchResult {
48
+ function matchTerm(term: string, haystack: string, label: string, functionLookup: boolean): FuzzyMatchResult {
47
49
  if (haystack === term) return { match: true, score: 2500 - term.length };
48
50
 
49
51
  const tokens = haystack.split(/\s+/).filter(Boolean);
@@ -57,23 +59,24 @@ function matchTerm(term: string, haystack: string, label: string): FuzzyMatchRes
57
59
  }
58
60
 
59
61
  if (haystack.includes(term)) return { match: true, score: 500 - term.length };
62
+ if (functionLookup && matchesFunctionPhrase(haystack, term)) return { match: true, score: 400 - term.length };
60
63
 
61
64
  return matchWordPrefixRun(term, label);
62
65
  }
63
66
 
64
67
  /** Every word of the query has to match on its own; the whole phrase matching too ranks higher. */
65
- function fuzzyMatch(query: string, target: string, label: string): FuzzyMatchResult {
68
+ function fuzzyMatch(query: string, target: string, label: string, functionLookup: boolean): FuzzyMatchResult {
66
69
  const q = query.toLowerCase().trim();
67
70
  const haystack = target.toLowerCase();
68
71
  const labelText = label.toLowerCase();
69
- const terms = q.split(/\s+/).filter(Boolean);
72
+ const terms = functionLookup ? functionQueryTerms(q) : q.split(/\s+/).filter(Boolean);
70
73
 
71
74
  if (terms.length === 0) return { match: true, score: 0 };
72
- if (terms.length === 1) return matchTerm(terms[0]!, haystack, labelText);
75
+ if (terms.length === 1) return matchTerm(terms[0]!, haystack, labelText, functionLookup);
73
76
 
74
77
  let score = 0;
75
78
  for (const term of terms) {
76
- const result = matchTerm(term, haystack, labelText);
79
+ const result = matchTerm(term, haystack, labelText, functionLookup);
77
80
  if (!result.match) return NO_MATCH;
78
81
  score += result.score;
79
82
  }
@@ -92,12 +95,13 @@ export function fuzzyFilter<T>(
92
95
  query: string,
93
96
  getText: (item: T) => string,
94
97
  getLabel?: (item: T) => string,
98
+ isFunction?: (item: T) => boolean,
95
99
  ): T[] {
96
100
  if (!query) return items;
97
101
  return items
98
102
  .map((item) => {
99
103
  const text = getText(item);
100
- return { item, ...fuzzyMatch(query, text, getLabel ? getLabel(item) : text) };
104
+ return { item, ...fuzzyMatch(query, text, getLabel ? getLabel(item) : text, isFunction?.(item) ?? false) };
101
105
  })
102
106
  .filter((r) => r.match)
103
107
  .sort((a, b) => b.score - a.score)
@@ -0,0 +1,15 @@
1
+ type Choice = { value: string; label?: string; aliases?: readonly string[] };
2
+
3
+ const choiceToken = (value: string) => value.trim().toLowerCase().replace(/[\s_.-]+/g, "");
4
+
5
+ export function matchOptionChoice<ChoiceType extends Choice>(choices: readonly ChoiceType[], typed: string): ChoiceType | undefined {
6
+ const token = choiceToken(typed);
7
+ return choices.find((choice) => choiceToken(choice.value) === token)
8
+ ?? choices.find((choice) => (choice.label && choiceToken(choice.label) === token)
9
+ || choice.aliases?.some((alias) => choiceToken(alias) === token));
10
+ }
11
+
12
+ export function optionChoiceNames(choices: readonly Choice[]): string {
13
+ return choices.map(({ value, label }) => label && choiceToken(label) !== choiceToken(value)
14
+ ? `"${label}" (${value})` : value).join(", ");
15
+ }
@@ -263,9 +263,23 @@ export function isPriceHistoryStaleForCurrentWindow(
263
263
  * follows, and one written with a venue's suffix (GUBRF.IS) to that venue, whose hours its bars keep.
264
264
  */
265
265
  function listingSessionExchange(exchange: string | undefined, symbol?: string): string {
266
- return canonicalExchange(exchange) || indexSessionVenue(symbol) || (symbol ? listingSuffixVenue(symbol)?.exchange : undefined) || "NYSE";
266
+ const venue = canonicalExchange(exchange);
267
+ return (venue && !US_SESSION_PUBLISHERS.has(venue) ? venue : "") || indexSessionVenue(symbol)
268
+ || (symbol ? listingSuffixVenue(symbol)?.exchange : undefined) || "NYSE";
267
269
  }
268
270
 
271
+ /**
272
+ * US index publishers (S&P's SNP, Dow Jones's DJI, Nasdaq's NIM, Cboe's index
273
+ * feed, FTSE Russell's WCB) and US futures exchanges, which the session tables
274
+ * have no calendar for. Their bars are read on the US calendar, as the same
275
+ * symbol asked for bare is: under its venue, `^VIX:CXI` or `GC=F:CMX`, Friday's
276
+ * bars counted as behind all weekend, and a chart of it had none to show.
277
+ */
278
+ const US_SESSION_PUBLISHERS: ReadonlySet<string> = new Set([
279
+ "SNP", "DJI", "NIM", "NASDAQ GIDS", "WCB", "CXI", "CBOE INDICES", "CHICAGO OPTIONS",
280
+ "CME", "CBT", "NYM", "CMX", "NYB", "CFE",
281
+ ]);
282
+
269
283
  interface ListingSessions {
270
284
  /** The open of the session trading at the time asked, if one is. */
271
285
  liveOpen: number | null;
@@ -1,3 +1,5 @@
1
+ import { displayListingKeys } from "./exchanges";
2
+
1
3
  /**
2
4
  * Reason codes are a data service's words for a machine: why it has nothing
3
5
  * (NO_DATA, NOT_FOUND) or could not answer (UPSTREAM_ERROR, TIMEOUT). An
@@ -65,15 +67,16 @@ function withEmbeddedCodes(text: string): string {
65
67
  * Text fit to show as a state's title or a CLI error: a bare reason code as
66
68
  * a sentence ("The source did not answer."), a known code inside a longer
67
69
  * text as its clause ("AAPL: the source did not answer"), anything else as
68
- * it is.
70
+ * it is, with a listing stored under its venue's MIC named as it is typed
71
+ * (`0700:XHKG` reads `0700:HKEX`, displayListingKeys).
69
72
  */
70
73
  export function readableError(text: string): string {
71
- if (!isReasonCode(text)) return withEmbeddedCodes(text);
74
+ if (!isReasonCode(text)) return displayListingKeys(withEmbeddedCodes(text));
72
75
  const clause = reasonCodeClause(text);
73
76
  return `${clause.charAt(0).toUpperCase()}${clause.slice(1)}.`;
74
77
  }
75
78
 
76
79
  /** The same for a footer status, which reads as a clause: "the source did not answer". */
77
80
  export function readableStatus(text: string): string {
78
- return isReasonCode(text) ? reasonCodeClause(text) : withEmbeddedCodes(text);
81
+ return isReasonCode(text) ? reasonCodeClause(text) : displayListingKeys(withEmbeddedCodes(text));
79
82
  }