@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
@@ -4,7 +4,7 @@ import { getLanguage, tf } from "../../i18n";
4
4
  import { formatUtcDayTime, formatUtcWeekdayTime } from "../../utils/utc-time";
5
5
  import { formatShortDate } from "../../utils/datetime-format";
6
6
  import { quoteFeedDelayMinutes } from "../market/freshness";
7
- import { quoteHeadlineTime, quoteSessionStateLabel } from "../market/status";
7
+ import { extendedPrintTime, quoteHeadlineTime, quoteSessionStateLabel } from "../market/status";
8
8
  import { dailyNavDate, isQuoteStaleForCurrentSession } from "./freshness";
9
9
  import { savedCopyAt } from "../../data/saved-copies";
10
10
 
@@ -47,13 +47,43 @@ export function asOfClock(time: number, now = Date.now()): string {
47
47
  return `${now - time < WEEK_MS ? formatUtcWeekdayTime(time) : formatUtcDayTime({ time, dateOnly: false }, now)} UTC`;
48
48
  }
49
49
 
50
+ /** What a book the source sent without its time says in place of one. */
51
+ export const QUOTE_BOOK_UNDATED = "not dated";
52
+
53
+ /**
54
+ * When a quote's bid and ask were quoted, as a card dates a price (asOfClock):
55
+ * `Sat 00:55 UTC`; QUOTE_BOOK_UNDATED for a book the source sent without its
56
+ * time, and null with no book. Every view of a book dates it this way, never
57
+ * by the trade's time beside it: EWG's after-hours book quoted at 00:55 UTC
58
+ * read as of the 23:20 print.
59
+ */
60
+ export function formatQuoteBookTime(
61
+ quote: Pick<Quote, "bid" | "ask" | "bidAskTime"> | null | undefined,
62
+ now = Date.now(),
63
+ ): string | null {
64
+ if (!quote || (quote.bid == null && quote.ask == null)) return null;
65
+ const at = quote.bidAskTime;
66
+ return at != null && Number.isFinite(at) && at > 0 ? asOfClock(Math.min(at, now), now) : QUOTE_BOOK_UNDATED;
67
+ }
68
+
69
+ /**
70
+ * When a quote's pre-market, after-hours or overnight print was observed, as
71
+ * a card dates a price (asOfClock): `Sat 00:34 UTC` beside the close it is
72
+ * measured from, which formatQuoteSessionAsOf dates. Null without such a print.
73
+ */
74
+ export function formatExtendedPrintAsOf(quote: Quote | null | undefined, now = Date.now()): string | null {
75
+ const time = extendedPrintTime(quote);
76
+ return time == null ? null : asOfClock(Math.min(time, now), now);
77
+ }
78
+
50
79
  /**
51
80
  * What a quote card's price is as of: CLOSED while its market is, else how
52
81
  * current its feed is, and when the price was observed (quoteHeadlineTime,
53
82
  * as an export's as_of dates it): `CLOSED · 08:09 UTC` for Hong Kong's close
54
- * beside `15 min delayed · 21:20 UTC` for New York's after hours. Null for a
55
- * fund priced by its NAV (formatQuoteNavAsOf dates it), a listing that no
56
- * longer trades and a quote stale for its session, whose own status says so.
83
+ * beside `CLOSED · Fri 21:00 UTC` for New York's, whose after-hours print
84
+ * says its own time (formatExtendedPrintAsOf). Null for a fund priced by its
85
+ * NAV (formatQuoteNavAsOf dates it), a listing that no longer trades and a
86
+ * quote stale for its session, whose own status says so.
57
87
  */
58
88
  export function formatQuoteSessionAsOf(quote: Quote | null | undefined, now = Date.now()): string | null {
59
89
  if (!quote || quote.delisting || !(quote.lastUpdated > 0) || dailyNavDate(quote, now)) return null;
@@ -1,6 +1,6 @@
1
1
  import type { SplitAction } from "../types/financials";
2
2
 
3
- /** A factor with more shares than this on either side is no share count a split states: GE's 1253:1000 spinoff adjustment. */
3
+ /** A factor with more shares than this on a side, and no single share on the other, is no share count a split states: GE's 1253:1000 spinoff adjustment. */
4
4
  const MAX_SPLIT_SHARES = 100;
5
5
 
6
6
  function greatestCommonDivisor(a: number, b: number): number {
@@ -20,7 +20,8 @@ export function splitShareTerms(split: Pick<SplitAction, "fromFactor" | "toFacto
20
20
  const divisor = greatestCommonDivisor(to!, from!);
21
21
  const after = to! / divisor;
22
22
  const before = from! / divisor;
23
- if (Math.max(after, before) > MAX_SPLIT_SHARES) return null;
23
+ // One share for many (FFAI's 1-for-150 reverse split) is a split however many: an adjustment is never a whole 1:N.
24
+ if (Math.min(after, before) !== 1 && Math.max(after, before) > MAX_SPLIT_SHARES) return null;
24
25
  if (after < before) return `${after}-for-${before} reverse`;
25
26
  if (before === 1) return `${after}-for-1`;
26
27
  const added = after - before;
@@ -536,6 +536,7 @@ export class NewsService {
536
536
  if (generation !== this.sessionGeneration) return this.currentRead(entry);
537
537
  const state: NewsQueryState = {
538
538
  ...(denied ? createIdleNewsQueryState() : current),
539
+ ...(!denied && current.articles.length > 0 && current.updatedAt != null ? { savedAt: current.savedAt ?? current.updatedAt } : {}),
539
540
  phase: "error",
540
541
  error: error instanceof Error ? error.message : String(error),
541
542
  };
@@ -152,6 +152,16 @@ export function newsArticleRevision(article: NewsArticle): string {
152
152
  return JSON.stringify([newsArticleSummaryRevision(article), article.items ?? []]);
153
153
  }
154
154
 
155
+ /**
156
+ * When a story last changed: its latest report's publication, where the
157
+ * service says, else its date. A story keeps its first publication as its
158
+ * date, so a later report does not move that.
159
+ */
160
+ function storyRevisionTime(article: Pick<NewsArticle, "publishedAt" | "times">): number {
161
+ const latest = Date.parse(article.times?.lastPublishedAt ?? "");
162
+ return Number.isFinite(latest) ? Math.max(latest, article.publishedAt.getTime()) : article.publishedAt.getTime();
163
+ }
164
+
155
165
  function mergeDuplicateArticle(existing: NewsArticle, item: NewsArticle): NewsArticle {
156
166
  if (existing.id === item.id) {
157
167
  // A story's newer publication supersedes its earlier importance score.
@@ -160,7 +170,7 @@ function mergeDuplicateArticle(existing: NewsArticle, item: NewsArticle): NewsAr
160
170
  const sameSummary = newsArticleSummaryRevision(existing) === newsArticleSummaryRevision(item);
161
171
  const compatibleTimeline = !hasStoryItems(existing) || !hasStoryItems(item)
162
172
  || newsArticleRevision(existing) === newsArticleRevision(item);
163
- const winner = item.publishedAt > existing.publishedAt
173
+ const winner = storyRevisionTime(item) > storyRevisionTime(existing)
164
174
  || (sameSummary && compatibleTimeline && item.importance > existing.importance) ? item : existing;
165
175
  const other = winner === item ? existing : item;
166
176
  return !hasStoryItems(winner) && sameSummary && hasStoryItems(other)
@@ -203,7 +213,7 @@ export function dedupeNewsArticles(items: NewsArticle[]): NewsArticle[] {
203
213
  export function mergeNewsArticle(base: NewsArticle, detail: NewsArticle): NewsArticle {
204
214
  const detailItems = detail.items ?? [];
205
215
  const baseItems = base.items ?? [];
206
- const olderDetail = detail.publishedAt < base.publishedAt;
216
+ const olderDetail = storyRevisionTime(detail) < storyRevisionTime(base);
207
217
  return {
208
218
  ...base,
209
219
  ...detail,
package/src/news/types.ts CHANGED
@@ -49,12 +49,27 @@ export interface NewsInsiderFiling {
49
49
  url: string;
50
50
  }
51
51
 
52
+ /**
53
+ * A story's times as the service reports them, ISO instants: its first and
54
+ * latest publication across the reports it gathers, and when the service first
55
+ * and last saw it. A field the service did not send is absent.
56
+ */
57
+ export interface NewsStoryTimes {
58
+ firstPublishedAt?: string;
59
+ lastPublishedAt?: string;
60
+ firstSeenAt?: string;
61
+ lastSeenAt?: string;
62
+ }
63
+
52
64
  export interface NewsArticle {
53
65
  id: string;
54
66
  title: string;
55
67
  url: string;
56
68
  source: string;
69
+ /** When the story was first published, the earliest time known for it: what lists show and sort by. */
57
70
  publishedAt: Date;
71
+ /** Every time the service reported for the story (a later report's publication, when it was seen), kept as sent. */
72
+ times?: NewsStoryTimes;
58
73
  summary?: string;
59
74
  imageUrl?: string;
60
75
  topic: string;
@@ -53,6 +53,7 @@ export function editAlert(
53
53
  status: "active",
54
54
  message: alert.message,
55
55
  ...(alert.metric ? { metric: alert.metric } : {}),
56
+ ...(alert.regularHoursOnly ? { regularHoursOnly: true } : {}),
56
57
  // A move rule stays one; the session it went off in is dropped, so it can go off again.
57
58
  ...(alert.move ? { move: true } : {}),
58
59
  };
@@ -70,6 +71,7 @@ export function rearmAlert(alert: AlertRule): AlertRule {
70
71
  export function sameLevelRule(a: AlertRule, b: AlertRule): boolean {
71
72
  // One key per listing: 7203.T, `7203 JP` and 7203:JPX are one listing, as is AAPL read on NASDAQ.
72
73
  return alertListingKey(a) === alertListingKey(b) && !!a.move === !!b.move
74
+ && !!a.regularHoursOnly === !!b.regularHoursOnly
73
75
  && a.condition === b.condition && a.targetPrice === b.targetPrice
74
76
  && JSON.stringify(readAlertMetric(a.metric)) === JSON.stringify(readAlertMetric(b.metric));
75
77
  }
@@ -1,4 +1,5 @@
1
1
  import { CATALYST_TYPES } from "../../../api-client/catalysts";
2
+ import { checkedOnlyWithPro } from "./pro-rules";
2
3
  import { RESEARCH_ALERT_FORMS } from "./research-rules";
3
4
 
4
5
  /**
@@ -68,9 +69,9 @@ export interface RuleAddRequest {
68
69
 
69
70
  /** Who checks a rule and how it reaches you, as docs/usage.md states it. */
70
71
  export function ruleDelivery(event: string): string {
71
- if (event.startsWith("catalyst")) return "the app checks it every five minutes while it is running and signed in";
72
+ if (event.startsWith("catalyst")) return "the app checks it every five minutes while it is running and signed in with Pro";
72
73
  if (event.startsWith("congress") || event.startsWith("thirteenf")) return "Gloom Cloud sends it to your phone for a signed-in account with Cloud sync";
73
- return "Gloom Cloud checks it, not the app, for a signed-in account with Cloud sync and sends it to your phone";
74
+ return `Gloom Cloud checks it, not the app, for a signed-in account with Cloud sync${checkedOnlyWithPro({ kind: event }) ? " on Gloom Pro" : ""} and sends it to your phone`;
74
75
  }
75
76
 
76
77
  /** What a US-only rule is called when a listing abroad is refused. */
@@ -11,7 +11,8 @@ import { findCollection } from "../portfolio-list/cli/render";
11
11
  import { alertListing, readingSessionWords } from "./format";
12
12
  import { createAlert, sameLevelRule } from "./alert-engine";
13
13
  import { moveBasisText, moveCondition, movePercentText, moveReached, moveRuleWords, parseMovePercent } from "./move";
14
- import { moveQuoteFields } from "./quotes";
14
+ import { alertQuoteListingFields, moveQuoteFields } from "./quotes";
15
+ import { acceptsAlertSession } from "./session";
15
16
  import type { AlertCondition, AlertRule } from "./types";
16
17
 
17
18
  /** Listings quoted in one request: as many as a signed-out caller's batch may read. */
@@ -22,6 +23,7 @@ export const MAX_BULK_ALERTS = 500;
22
23
 
23
24
  /** What `alerts add` was asked for when it names a move. */
24
25
  export interface MoveAddRequest {
26
+ regularHoursOnly?: true;
25
27
  kind: "move";
26
28
  /** As typed; empty with `--watchlist`. */
27
29
  symbols: string[];
@@ -184,7 +186,8 @@ export function planMoveAlerts(request: MoveAddRequest, listings: readonly MoveL
184
186
  const alert: AlertRule = {
185
187
  ...createAlert(entry.listing.symbol, request.condition, request.percent, entry.listing.exchange),
186
188
  move: true,
187
- ...moveQuoteFields(entry.quote, now),
189
+ ...request.regularHoursOnly ? { regularHoursOnly: true } : {},
190
+ ...acceptsAlertSession(request, entry.quote) ? moveQuoteFields(entry.quote, now) : alertQuoteListingFields(entry.quote),
188
191
  };
189
192
  const savedRule = saved.find((other) => sameLevelRule(other, alert));
190
193
  const made = savedRule ? undefined : plan.added.find((other) => sameLevelRule(other, alert));
@@ -5,9 +5,12 @@ import { firstDailyCheck, metricAvailabilityError, metricReadings } from "./metr
5
5
  import { ALERT_ADD_FORMS, ALERT_KINDS_TEXT, parseRuleAddArgs, RULE_US_DATA, ruleDelivery, type RuleAddRequest } from "./cli-forms";
6
6
  import { alertChangeEntry, appendAlertLog, type AlertLogAction } from "./fired-log";
7
7
  import { alertLogRule } from "./alert-log";
8
- import { alertListing, alertReadingAt, alertReadingText, isoUtc, listingWithCurrency, measureLabel, NOT_CHECKED_YET, readingSessionWords } from "./format";
8
+ import {
9
+ alertBenchmarkListing, alertComparatorReadingText, alertListing, alertReadingAt, alertReadingCurrency, alertReadingText, isoUtc, listingWithCurrency,
10
+ measureLabel, NOT_CHECKED_YET, readingSessionWords,
11
+ } from "./format";
9
12
  import { isQuoteStaleForCurrentSession } from "../../../market-data/quotes/freshness";
10
- import { quoteAlertFields } from "./quotes";
13
+ import { alertQuoteListingFields, quoteAlertFields } from "./quotes";
11
14
  import { createEventAlert } from "./events";
12
15
  import { isResearchAlertKind, readResearchRule } from "./research-rules";
13
16
  import { withConfigData, withMarketData } from "../../../cli/scoped-context";
@@ -16,6 +19,7 @@ import { resolvePersistedCloudSessionToken } from "../../../cli/pane-functions/c
16
19
  import type { ConfigContext } from "../../../cli/types";
17
20
  import { checkedWhenSignedIn, NEEDS_SIGN_IN, needsSignInNote } from "./event-rows";
18
21
  import { checkedOnlyWithPro, checksProRules, NEEDS_PRO, needsProNote, savedWithoutProNote } from "./pro-rules";
22
+ import { acceptsAlertSession, alertSessionLabel } from "./session";
19
23
  import { OCC_CONTRACT, occContractExample, occFormText, parseLooseOptionContract, resolveLooseOptionContract, type LooseOptionContract } from "./option-contract";
20
24
  import { CLI_COMMAND_GROUPS } from "../../../cli/help";
21
25
  import { dryRunNote } from "../../../cli/helpers";
@@ -27,7 +31,7 @@ import { saveConfig } from "../../../data/config/store";
27
31
  import { resumeStateKey } from "../../registry/plugin-state";
28
32
  import type { CliCommandDef } from "../../../types/plugin";
29
33
  import type { Quote } from "../../../types/financials";
30
- import { extendedPrintSession, getActiveQuoteDisplay } from "../../../market-data/market/status";
34
+ import { getActiveQuoteDisplay } from "../../../market-data/market/status";
31
35
  import { cliStyles } from "../../../utils/cli-output";
32
36
  import { canonicalExchange, isUsListingExchange, parsePublicTickerKey } from "../../../utils/exchanges";
33
37
  import { isRoundTheClockCoin } from "../../../utils/crypto-pair";
@@ -414,7 +418,7 @@ function researchFormValues(request: ResearchAddRequest, exchange: string): { ki
414
418
  */
415
419
  function researchDelivery(kind: ResearchAddRequest["kind"]): string {
416
420
  if (kind === "iv_level") return "the app checks it every 15 minutes while it is running, on the same option fits as OVDV";
417
- const plan = kind === "news" ? "" : " on Gloom Pro";
421
+ const plan = checkedOnlyWithPro({ kind: kind === "flow" ? "options_flow" : kind }) ? " on Gloom Pro" : "";
418
422
  // Said apart from the app, which checks IV levels and price alerts: this one goes on with the app closed, and only signed in.
419
423
  return `Gloom Cloud checks it, not the app, for a signed-in account with Cloud sync${plan} and sends it to your phone`;
420
424
  }
@@ -566,13 +570,18 @@ type AlertListRow = Record<string, unknown> & {
566
570
  function priceRow(alert: AlertRule): AlertListRow {
567
571
  return {
568
572
  ...alert, kind: alert.metric?.kind ?? (alert.move ? "move" : "price"), rule: alert.metric ? metricDescription(alert) : undefined,
573
+ session: alertSessionLabel(alert),
569
574
  // A move's rule in the words it was added with: `up 3.00%`, `moves 0.50%`.
570
575
  ...alert.move ? { rule: `${moveRuleWords(alert)} from the previous close`, appOnly: true } : {},
571
576
  // The listing as it was kept: 7203:JPX, never 7203:JPX:JPX.
572
577
  target: alertListing({ symbol: alert.symbol, exchange: alert.exchange }),
573
- // The listing it is checked on, in its currency, and its last reading in words with when it is from.
574
- listing: alertListing(alert), currency: alert.lastQuoteCurrency ?? null,
578
+ // The listing it is checked on, the currency its readings are in (none for a ratio, RSI or a multiple), and its
579
+ // last reading in words with when it is from.
580
+ listing: alertListing(alert), currency: alertReadingCurrency(alert),
575
581
  lastReading: alertReadingText(alert), lastReadingAt: isoUtc(alertReadingAt(alert)) || null,
582
+ // What the reading is measured against: the slow average of a crossover, or the listing a ratio divides by.
583
+ comparatorReading: alertComparatorReadingText(alert) || null,
584
+ benchmarkListing: alertBenchmarkListing(alert) || null,
576
585
  };
577
586
  }
578
587
 
@@ -667,8 +676,10 @@ const plural = (count: number, word: string) => `${count} ${word}${count === 1 ?
667
676
 
668
677
  /**
669
678
  * One row as text and CSV give it. CSV keeps the columns it has always had in
670
- * their order, then Created (ISO UTC), the listing, its currency and the last
671
- * reading, in words and dated.
679
+ * their order, Triggered in ISO UTC, then Created (ISO UTC), the listing, its currency and the last
680
+ * reading, in words and dated, the session it is read in, and what that
681
+ * reading is measured against: the comparator's own reading and the
682
+ * benchmark listing of a ratio or RRG rule.
672
683
  */
673
684
  function textRow(row: AlertListRow): Record<string, unknown> {
674
685
  const price = row.kind === "price";
@@ -683,15 +694,19 @@ function textRow(row: AlertListRow): Record<string, unknown> {
683
694
  : typeof row.leadDays === "number"
684
695
  ? scheduledTriggerText({ leadDays: row.leadDays, trigger: row.when === "results" ? "results" : "date", prints: row.onRelease === true })
685
696
  : ""),
686
- eventDate: typeof row.leadDays === "number" ? row.eventDate ?? "not known" : "",
697
+ eventDate: typeof row.leadDays === "number" ? row.eventDate ?? (row.kind === "earnings_date" ? "waiting for next date" : "not known") : "",
687
698
  status: row.status,
688
699
  lastCheckedPrice: row.lastCheckedPrice,
689
- triggeredAt: row.triggeredAt,
700
+ // ISO 8601 in UTC, as createdAt: a spreadsheet reads an epoch count as a number.
701
+ triggeredAt: isoUtc(typeof row.triggeredAt === "number" ? row.triggeredAt : null),
690
702
  createdAt: isoUtc(typeof row.createdAt === "number" ? row.createdAt : null),
691
703
  listing: row.listing ?? "",
692
704
  currency: row.currency ?? "",
693
705
  lastReading: row.lastReading ?? "",
694
706
  lastReadingAt: row.lastReadingAt ?? "",
707
+ session: row.session ?? "",
708
+ comparatorReading: row.comparatorReading ?? "",
709
+ benchmarkListing: row.benchmarkListing ?? "",
695
710
  };
696
711
  }
697
712
 
@@ -822,10 +837,10 @@ async function requireEventDate(
822
837
  sources: ScheduledEventSources,
823
838
  today: string,
824
839
  fail: (message: string) => never,
825
- ): Promise<string> {
840
+ ): Promise<string | null> {
826
841
  const lookup = (await lookupScheduledDates([target], sources, today)).get(scheduledTargetKey(target));
827
842
  if (!lookup || "error" in lookup) fail(eventDateUnavailableMessage(target, lookup?.error ?? "no answer"));
828
- if (!lookup.date) fail(noUpcomingEventMessage(target));
843
+ if (!lookup.date && target.kind !== "earnings") fail(noUpcomingEventMessage(target));
829
844
  return lookup.date;
830
845
  }
831
846
 
@@ -848,6 +863,7 @@ export const alertsCliCommand: CliCommandDef = {
848
863
  { flags: "--country <code>", description: "The country of a calendar event, as econ --country takes it (CN, US, DE); a code before the name does the same (alerts add CN PMI)" },
849
864
  { flags: "--benchmark <symbol>", description: "The listing an RRG alert is measured against; SPY by default, as in RRG" },
850
865
  { flags: "--watchlist <name>", description: `A move alert on each listing of the watchlist, up to ${MAX_BULK_ALERTS} (alerts add --watchlist Book up 3%)` },
866
+ { flags: "--session <regular|extended>", description: "Watch regular hours only, or regular and extended hours (default); price and move alerts" },
851
867
  ],
852
868
  examples: [
853
869
  "alerts",
@@ -901,6 +917,10 @@ export const alertsCliCommand: CliCommandDef = {
901
917
  const benchmark = benchmarkFlag && benchmarkValue === undefined ? null : benchmarkValue;
902
918
  const watchlistFlag = rawArgs.some((arg) => arg === "--watchlist" || arg.startsWith("--watchlist="));
903
919
  const watchlistName = takeOption(args, "--watchlist");
920
+ const sessionFlag = rawArgs.some((arg) => arg === "--session" || arg.startsWith("--session="));
921
+ const sessionMode = takeOption(args, "--session")?.toLowerCase();
922
+ if (sessionFlag && sessionMode !== "regular" && sessionMode !== "extended") ctx.fail("Use --session regular or --session extended (regular and extended hours).");
923
+ const sessionRule = sessionMode === "regular" ? { regularHoursOnly: true as const } : {};
904
924
  if (watchlistFlag && !watchlistName?.trim()) ctx.fail("--watchlist takes a watchlist's name: alerts add --watchlist Book up 3%.");
905
925
  const action = args[0] ?? "list";
906
926
  if (watchlistFlag && action !== "add") ctx.fail("--watchlist is for alerts add: alerts add --watchlist Book up 3%.");
@@ -908,7 +928,7 @@ export const alertsCliCommand: CliCommandDef = {
908
928
  const today = newYorkToday(new Date(now));
909
929
  const failWith = (error: unknown): never => ctx.fail(error instanceof Error ? error.message : String(error));
910
930
  // A symbol whose company moved names the same add on its new symbol.
911
- const alertRetry = (symbol: string) => `gloom alerts add ${symbol} ${args.slice(2).join(" ")}`;
931
+ const alertRetry = (symbol: string) => `gloom alerts add ${symbol} ${args.slice(2).join(" ")}${sessionMode ? ` --session ${sessionMode}` : ""}`;
912
932
  // The listing an alert follows, read as `quote` reads it and held to one that trades (`resolveAlertListing`).
913
933
  const requireAlertListing = (typed: string, market: ListingDeps, exchange: string | null | undefined = exchangeOption) =>
914
934
  resolveAlertListing(typed, exchange, market, { retry: alertRetry }).catch((error: unknown) => {
@@ -924,6 +944,7 @@ export const alertsCliCommand: CliCommandDef = {
924
944
  }
925
945
  };
926
946
  const typedRequest = action === "add" ? parseAdd() : null;
947
+ if (sessionFlag && typedRequest?.kind !== "price" && typedRequest?.kind !== "move") ctx.fail("--session is only for price and move alerts.");
927
948
  // A move's listings, each read as `quote` reads it, or a watchlist's as it keeps them, with what was dropped.
928
949
  let moves: { listings: MoveListing[]; repeats: number; leftOut: number; watchlist?: string } | null = null;
929
950
  if (typedRequest?.kind === "move") {
@@ -1058,10 +1079,12 @@ export const alertsCliCommand: CliCommandDef = {
1058
1079
  failWith(error);
1059
1080
  }
1060
1081
  }
1061
- if (request?.kind === "price" && priced && !isQuoteStaleForCurrentSession(priced.quote)) {
1082
+ if (request?.kind === "price" && priced && acceptsAlertSession(sessionRule, priced.quote) && !isQuoteStaleForCurrentSession(priced.quote)) {
1062
1083
  // The price it is added at is its first reading and the baseline a crossing is measured from, as Add Alert keeps it.
1063
1084
  const price = lastPrice(priced.quote);
1064
1085
  if (price != null) reading = quoteAlertFields({ ...priced.quote, price }, now);
1086
+ } else if (request?.kind === "price" && priced && sessionRule.regularHoursOnly) {
1087
+ reading = alertQuoteListingFields(priced.quote);
1065
1088
  }
1066
1089
  if (request?.kind === "price" && request.thousandsDot && priced) {
1067
1090
  const question = thousandsDotMessage(request, priced.listing.key, lastPrice(priced.quote), exchangeOption);
@@ -1069,8 +1092,8 @@ export const alertsCliCommand: CliCommandDef = {
1069
1092
  }
1070
1093
  if (request?.kind === "price" && priced) {
1071
1094
  // A target ten times away is a slip or another instrument's price, such as bitcoin's on the BTC fund.
1072
- // Against the price the alert is checked on, as Add Alert measures it.
1073
- const far = farTargetMessage(priced.listing.key, request.price, priced.quote.price, coinNote ?? futureNote, isPenceQuotedLine(priced.quote));
1095
+ const referencePrice = sessionRule.regularHoursOnly ? priced.quote.price : lastPrice(priced.quote);
1096
+ const far = farTargetMessage(priced.listing.key, request.price, referencePrice, coinNote ?? futureNote, isPenceQuotedLine(priced.quote));
1074
1097
  if (far) ctx.fail(far);
1075
1098
  }
1076
1099
  // What a typed listing was read as (7203:TSE as 7203:JPX, MXN as MXN:FWB2), said beside what was added.
@@ -1235,7 +1258,10 @@ export const alertsCliCommand: CliCommandDef = {
1235
1258
  { key: "lastReading", header: "Last Reading" },
1236
1259
  // ISO 8601 in UTC, as CSV writes it.
1237
1260
  { key: "createdAt", header: "Created", format: (value) => String(value ?? "") },
1238
- { key: "triggeredAt", header: "Triggered", optional: true },
1261
+ { key: "triggeredAt", header: "Triggered", optional: true, format: (value) => String(value ?? "") },
1262
+ { key: "session", header: "Session", optional: true },
1263
+ { key: "comparatorReading", header: "Against", optional: true },
1264
+ { key: "benchmarkListing", header: "Benchmark", optional: true },
1239
1265
  ],
1240
1266
  empty: "No alerts. Add one with gloom alerts add AAPL above 400, alerts add CRWV earnings --days 3, alerts add CPI --days 1, or alerts add CN PMI.",
1241
1267
  });
@@ -1295,7 +1321,7 @@ export const alertsCliCommand: CliCommandDef = {
1295
1321
  };
1296
1322
 
1297
1323
  if (request?.kind === "move" && moves) {
1298
- const plan = planMoveAlerts(request, moves.listings, alerts, now);
1324
+ const plan = planMoveAlerts({ ...request, ...sessionRule }, moves.listings, alerts, now);
1299
1325
  const single = moves.listings.length === 1 && !moves.watchlist;
1300
1326
  const rule = moveRuleWords({ condition: request.condition, targetPrice: request.percent });
1301
1327
  if (single && plan.existing[0]) {
@@ -1320,7 +1346,7 @@ export const alertsCliCommand: CliCommandDef = {
1320
1346
  const alert = plan.added[0]!;
1321
1347
  const nowText = moveNowText(alert, now);
1322
1348
  ctx.printResult({ data: { changed: !ctx.cliOptions.dryRun, dryRun: ctx.cliOptions.dryRun, alert }, ...(notes.length ? { warnings: notes } : {}) }, {
1323
- text: (data) => `Added alert ${data.alert.id}: ${formatAlertDescription(data.alert)} (${MOVE_REARM}).${nowText ? ` ${capitalize(nowText)}.` : ""}${dryRunNote(data.dryRun)}\n${MOVE_DELIVERY}`,
1349
+ text: (data) => `Added alert ${data.alert.id}: ${formatAlertDescription(data.alert)} (${MOVE_REARM}).${nowText ? ` ${capitalize(nowText)}.` : alert.regularHoursOnly ? " Waiting for a regular-hours quote." : ""}${dryRunNote(data.dryRun)}\n${MOVE_DELIVERY}`,
1324
1350
  });
1325
1351
  return;
1326
1352
  }
@@ -1343,7 +1369,7 @@ export const alertsCliCommand: CliCommandDef = {
1343
1369
  if (request?.kind === "price" || request?.kind === "metric") {
1344
1370
  const { condition } = request;
1345
1371
  const symbol = requireArg(priceListing?.key, ADD_USAGE, ctx);
1346
- const alert: AlertRule = { ...createAlert(symbol, condition, request.price, priceListing?.exchange), ...(request.kind === "metric" ? { metric: request.metric } : {}),
1372
+ const alert: AlertRule = { ...createAlert(symbol, condition, request.price, priceListing?.exchange), ...sessionRule, ...(request.kind === "metric" ? { metric: request.metric } : {}),
1347
1373
  // A London line's level is shown in pence from the first, before any check has read its quote.
1348
1374
  ...request.kind === "price" && priced ? {
1349
1375
  lastQuoteCurrency: priced.quote.currency || undefined, lastQuotePence: isPenceQuotedLine(priced.quote) || undefined,
@@ -1361,8 +1387,7 @@ export const alertsCliCommand: CliCommandDef = {
1361
1387
  const weekly = alert.metric?.kind === "rrg";
1362
1388
  const daily = !!alert.metric && isDailyMetric(alert.metric);
1363
1389
  const firstCheck = daily ? firstDailyCheck(alert.exchange, now, weekly) : null;
1364
- // The price a price alert is checked on, as the far-target check measures against.
1365
- const checkedPrice = !alert.metric && priced && Number.isFinite(priced.quote.price) && priced.quote.price !== 0 ? priced.quote.price : null;
1390
+ const checkedPrice = alert.lastCheckedPrice;
1366
1391
  // An above or below rule that already holds goes off at its first check, not on the next cross: said with the reading.
1367
1392
  const alreadyMet = alert.metric
1368
1393
  ? levelAlreadyMet(alert.condition, alert.lastCheckedPrice, alert.lastCheckedTarget)
@@ -1372,7 +1397,7 @@ export const alertsCliCommand: CliCommandDef = {
1372
1397
  const goesOffThen = daily && alreadyMet ? ` It goes off then if it is still ${alert.condition}.` : "";
1373
1398
  const notes = [
1374
1399
  alert.metric ? unread ? `Not read yet: ${unread.replace(/\.$/, "")}.` : `${metricReadingNote(alert)}${met}.`
1375
- : checkedPrice != null ? `Last price ${alertPriceWithCurrency(alert, checkedPrice)}${readingSessionWords({ lastQuoteSession: extendedPrintSession(priced?.quote, checkedPrice) ?? undefined })} · ${alertQuoteTime(alert.lastQuoteUpdatedAt)}${met}.` : null,
1400
+ : checkedPrice != null ? `Last price ${alertPriceWithCurrency(alert, checkedPrice)}${readingSessionWords(alert)} · ${alertQuoteTime(alert.lastQuoteUpdatedAt)}${met}.` : alert.regularHoursOnly ? "Waiting for a regular-hours quote." : null,
1376
1401
  firstCheck ? `First checked on the ${firstCheck.day} ${weekly ? "weekly close" : "close"}, from ${isoUtc(firstCheck.at).slice(11, 16)} UTC.${goesOffThen}`
1377
1402
  : goesOffThen ? `It goes off on the first close it is checked on if it is still ${alert.condition}.` : null,
1378
1403
  ].filter(Boolean).join(" ");
@@ -1431,7 +1456,7 @@ export const alertsCliCommand: CliCommandDef = {
1431
1456
  const delivery = release ? ", only while it is running" : " while it is running, or on your phone with Cloud sync";
1432
1457
  const when = !eventDate ? null : newRelease?.next ? releaseWhen(newRelease.next) : `on ${eventDate}`;
1433
1458
  const reminder = !eventDate
1434
- ? "the app alerts once the calendar lists its next date, about two weeks ahead"
1459
+ ? scheduled.target.kind === "earnings" ? "waiting for the next earnings date to be published" : "the app alerts once the calendar lists its next date, about two weeks ahead"
1435
1460
  : macroOutAt != null ? `it came out today at ${new Date(macroOutAt).toISOString().slice(11, 16)} UTC, so the app alerts before the next one`
1436
1461
  : due ? "already reached, so the app alerts at its next check" : `the app alerts on ${leadStartDate(eventDate, scheduled.leadDays)}`;
1437
1462
  ctx.printResult({ data: { changed: !ctx.cliOptions.dryRun, dryRun: ctx.cliOptions.dryRun, alert: rule,
@@ -1439,7 +1464,7 @@ export const alertsCliCommand: CliCommandDef = {
1439
1464
  // Delivery, as docs/usage.md states it: CPI, FOMC and calendar releases notify in the running app only; earnings also reach the phone,
1440
1465
  // which Gloom Cloud alerts with the same results once the actual EPS is stored for a results alert.
1441
1466
  text: (data) => scheduled.trigger === "results"
1442
- ? `Added alert ${data.alert.id}: ${name} on ${eventDate}, when results are out (the app alerts once the actual EPS is in while it is running, and with Cloud sync your phone gets the same alert).${dryRunNote(data.dryRun)}`
1467
+ ? `Added alert ${data.alert.id}: ${name}${eventDate ? ` on ${eventDate}` : ""}, when results are out (the app alerts once the actual EPS is in while it is running, and with Cloud sync your phone gets the same alert).${eventDate ? "" : " Waiting for the next earnings date to be published."}${dryRunNote(data.dryRun)}`
1443
1468
  : `Added alert ${data.alert.id}: ${name}${when ? ` ${when}` : ""}, ${plural(scheduled.leadDays, "day")} before${prints ? " and when it prints" : ""} (${reminder}${
1444
1469
  prints ? ", and with the actual, forecast and prior once out" : ""}${delivery}).${dryRunNote(data.dryRun)}`,
1445
1470
  });
@@ -1,10 +1,12 @@
1
- import { metricFormInput, metricShortcut, parseMetricAlert } from "./metric-command";
1
+ import { metricFormInput, metricShortcut, namesTwoListings, parseMetricAlert } from "./metric-command";
2
2
  import { isRelativeMetric, type AlertMetric } from "./metric-model";
3
3
  import type { AlertCondition } from "./types";
4
4
  import { hasAlertCurrency, isPenceLevel, parseAlertPrice, readAlertLevel } from "./price";
5
5
  import { normalizeAlertSymbol } from "./quotes";
6
6
  import { moveCondition, parseMovePercent } from "./move";
7
7
  import type { WizardStep } from "../../../types/plugin";
8
+ import { parseListingArg } from "../../../cli/listing-arg";
9
+ import { isSpotCommodityOrCurrencyPair } from "../../../utils/crypto-pair";
8
10
 
9
11
  /** Add Alert's kind for a move from the previous close, beside a price level. */
10
12
  export const MOVE_KIND_CHOICE = { value: "move", label: "Move from previous close" };
@@ -25,6 +27,7 @@ export interface AlertCommandInput {
25
27
  price: number;
26
28
  /** A move from the previous close (`QQQ moves 5%`): `condition` is either way (crosses), up (above) or down (below). */
27
29
  move?: true;
30
+ regularHoursOnly?: true;
28
31
  /** Typed in pence (`70p`): `price` is in pounds, for a London line quoted in pence. */
29
32
  pence?: true;
30
33
  currency?: string;
@@ -53,6 +56,49 @@ function parseAlertCondition(value: string | undefined): AlertCondition | null {
53
56
  }
54
57
  }
55
58
 
59
+ /** BTC/USD, BRK/B and EUR/USD are one listing written with a slash, as `alerts add` reads them; XLK/SPY is not. */
60
+ export function slashSpellsListing(symbol: string): boolean {
61
+ try {
62
+ return parseListingArg(symbol).key !== symbol.toUpperCase();
63
+ } catch {
64
+ // Intentional ignore: text the listing reader refuses is no pair to divide, so the quote's own error stands.
65
+ return true;
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Whether SA can open `A/B` as the ratio of two listings before anything is quoted: no listing is written that
71
+ * way. One that is stays a listing's price, and Add Alert asks the service first, as `alerts add` does: a pair
72
+ * the listing reader respells (BRK/B is BRK-B, EUR/USD is EURUSD=X, BTC/USD is BTC-USD), a spot commodity
73
+ * (XAU/USD), and one or two letters after the slash, a share class or series (BF/B, BAC/PL).
74
+ */
75
+ function slashNamesTwoListings(symbol: string): boolean {
76
+ if (namesTwoListings(symbol)) return true;
77
+ const pair = /^([^/\s:]+)\/([^/\s:]+)$/.exec(symbol);
78
+ if (!pair || pair[2]!.length <= 2) return false;
79
+ return !slashSpellsListing(symbol) && !isSpotCommodityOrCurrencyPair(symbol);
80
+ }
81
+
82
+ /**
83
+ * `EWJ/ACWI above 0.60` typed after SA: the ratio of two listings (slashNamesTwoListings), as `alerts add` saves
84
+ * it, so Add Alert opens on Ratio to benchmark with both listings, the direction and the level filled in.
85
+ */
86
+ function shortcutRatio(parts: readonly string[]): Record<string, string> | null {
87
+ const pair = /^([^/\s]+)\/([^/\s]+)$/.exec(parts[0] ?? "");
88
+ if (!pair || !slashNamesTwoListings(parts[0]!)) return null;
89
+ const condition = parseAlertCondition(parts[1]);
90
+ if (condition && parts.length === 3) {
91
+ const ratio = parseMetricAlert(`${parts[0]} ratio ${condition} ${parts[2]}`);
92
+ if (ratio) return metricShortcut(ratio);
93
+ }
94
+ // The pair alone, or with its direction: the ratio form opens on both listings for the rest to be typed.
95
+ if (parts.length > 2 || (parts[1] && !condition)) return null;
96
+ return {
97
+ symbol: normalizeAlertSymbol(pair[1]), kind: "rs_ratio", "rs_ratio:benchmark": pair[2]!.toUpperCase(),
98
+ ...condition ? { "rs_ratio:condition": condition } : {},
99
+ };
100
+ }
101
+
56
102
  export function parseAlertShortcutValues(
57
103
  input: string,
58
104
  context?: { activeTicker: string | null },
@@ -64,6 +110,8 @@ export function parseAlertShortcutValues(
64
110
  const activeTicker = normalizeAlertSymbol(context?.activeTicker);
65
111
  return activeTicker ? { symbol: activeTicker } : {};
66
112
  }
113
+ const ratio = shortcutRatio(parts);
114
+ if (ratio) return ratio;
67
115
  // The price is the rest of the line, as one: `$ 757.75`, `1 000.50` and `757.75 USD` read as `alerts add` reads them quoted.
68
116
  const priceText = parts.slice(2).join(" ");
69
117
  if (parts.length > 3 && !isPenceLevel(priceText) && !hasAlertCurrency(priceText) && parseAlertPrice(priceText).kind === "invalid") {
@@ -118,7 +166,7 @@ export function parseAlertCommandValues(
118
166
  if (!symbol || !typed) return null;
119
167
  const percent = parseMovePercent(typed);
120
168
  if (percent == null) throw new Error(`${MOVE_PERCENT_RULE}, not "${typed}".`);
121
- return { symbol, condition, price: percent, move: true };
169
+ return { symbol, condition, price: percent, move: true, ...values["move:session"] === "regular" ? { regularHoursOnly: true } : {} };
122
170
  }
123
171
  const metric = values ? metricFormInput(values) : null;
124
172
  if (metric) return metric;
@@ -126,7 +174,7 @@ export function parseAlertCommandValues(
126
174
  const condition = parseAlertCondition(values?.condition);
127
175
  const priceStr = values?.price?.trim();
128
176
  if (!symbol || !condition || !priceStr) return null;
129
- return { symbol, condition, ...readAlertLevel(priceStr) };
177
+ return { symbol, condition, ...readAlertLevel(priceStr), ...values?.["price:session"] === "regular" ? { regularHoursOnly: true } : {} };
130
178
  }
131
179
 
132
180
  /** A move rule's edit read: `GBPUSD=X moves 0.5%`, `HSBA:LSE down 3`, as `alerts add` takes it. Null for another form. */
@@ -11,7 +11,7 @@ import { checkedOnlyWithPro } from "./pro-rules";
11
11
  export function ruleTarget(rule: EventAlertRule, zone: string | null = null): string {
12
12
  const target = eventAlertTarget(rule);
13
13
  if (!readScheduledRule(rule)) return target;
14
- return `${target} · ${rule.eventDate ? eventWhen(rule, zone) : "date not known yet"}`;
14
+ return `${target} · ${rule.eventDate ? eventWhen(rule, zone) : rule.kind === "earnings_date" ? "waiting for next date" : "date not known yet"}`;
15
15
  }
16
16
 
17
17
  /** `2026-11-06 13:30 UTC, 08:30 New York`, or the day alone without a print time. */
@@ -170,9 +170,9 @@ export function EventAlertsPane({ focused, width, height }: PaneProps) {
170
170
  }, [dialog, selectedRule, setAlertLog, updateRules]);
171
171
  const status =
172
172
  error ??
173
- (selectedRule?.kind === "catalyst" ? catalystStatus : null) ??
174
173
  // A Pro rule nothing checks says so while it is selected, and what is free beside it.
175
174
  (selectedRule && ruleState(selectedRule, now, signedIn, pro) === "Needs Pro" ? proRuleStatus(selectedRule) : null) ??
175
+ (selectedRule?.kind === "catalyst" ? catalystStatus : null) ??
176
176
  sync.error ??
177
177
  (sync.phase === "disabled"
178
178
  ? "Cloud sync disabled"