gloomberb 0.20.2 → 0.20.3

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 (362) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/package.json +2 -1
  4. package/src/account/auth-form.tsx +13 -8
  5. package/src/account/upgrade-dialog.tsx +1 -1
  6. package/src/api-client/central-bank-rates.ts +5 -0
  7. package/src/api-client/data.ts +17 -4
  8. package/src/api-client/debt-maturities.ts +45 -2
  9. package/src/api-client/earnings.ts +4 -2
  10. package/src/api-client/errors.ts +21 -11
  11. package/src/api-client/index.ts +1 -0
  12. package/src/api-client/paths.ts +9 -1
  13. package/src/api-client/social-mentions.ts +47 -0
  14. package/src/api-client/types/econ.ts +4 -0
  15. package/src/app.tsx +11 -1
  16. package/src/cli/command-options.ts +2 -1
  17. package/src/cli/commands/market.ts +111 -29
  18. package/src/cli/commands/options-chain.ts +23 -6
  19. package/src/cli/commands/overview.ts +13 -5
  20. package/src/cli/commands/plugins.ts +49 -18
  21. package/src/cli/commands/search.ts +25 -6
  22. package/src/cli/commands/ticker.ts +4 -2
  23. package/src/cli/fx-quote-rate.ts +49 -1
  24. package/src/cli/glossary.ts +95 -15
  25. package/src/cli/history-rows.ts +9 -25
  26. package/src/cli/index.ts +6 -38
  27. package/src/cli/known-gaps.ts +3 -3
  28. package/src/cli/listing-arg.ts +78 -18
  29. package/src/cli/name-entries.ts +3 -2
  30. package/src/cli/not-a-ticker.ts +6 -2
  31. package/src/cli/pane-functions/capabilities.ts +12 -1
  32. package/src/cli/pane-functions/function-help.ts +23 -11
  33. package/src/cli/pane-functions/headless.ts +3 -1
  34. package/src/cli/pane-functions/index.ts +32 -4
  35. package/src/cli/pane-functions/market-session.ts +8 -3
  36. package/src/cli/pane-functions/resolver.ts +18 -11
  37. package/src/cli/pane-functions/screenshot-payload.ts +36 -6
  38. package/src/cli/pane-functions/screenshot-render.ts +4 -0
  39. package/src/cli/quote-answer.ts +10 -0
  40. package/src/cli/report-tables.ts +22 -2
  41. package/src/cli/result.ts +7 -3
  42. package/src/cli/spreadsheet-hint.ts +43 -0
  43. package/src/cli/symbol-list.ts +58 -4
  44. package/src/cli/symbol-rows.ts +49 -2
  45. package/src/cli/ticker-resolution.ts +98 -5
  46. package/src/cli/unknown-command.ts +88 -0
  47. package/src/components/command-bar/assist/model.ts +6 -1
  48. package/src/components/command-bar/commands/direct/index.ts +9 -1
  49. package/src/components/command-bar/commands/registry.ts +18 -0
  50. package/src/components/command-bar/pane-actions.ts +30 -13
  51. package/src/components/command-bar/panel/index.tsx +6 -3
  52. package/src/components/command-bar/panel/prompt-binding.ts +4 -0
  53. package/src/components/command-bar/panel/types.ts +3 -0
  54. package/src/components/command-bar/routes/header-market.ts +108 -0
  55. package/src/components/command-bar/routes/root/command-items.ts +5 -0
  56. package/src/components/command-bar/routes/root/provider-search.ts +190 -32
  57. package/src/components/command-bar/routes/root/results.ts +3 -0
  58. package/src/components/command-bar/routes/root/runtime.ts +28 -5
  59. package/src/components/command-bar/routes/ticker-search/results.ts +53 -6
  60. package/src/components/command-bar/routing/list-state.ts +38 -0
  61. package/src/components/command-bar/selection-hint.ts +28 -0
  62. package/src/components/command-bar/surface/index.tsx +41 -3
  63. package/src/components/command-bar/view-model.ts +15 -0
  64. package/src/components/command-bar/workflow/tickers.ts +3 -2
  65. package/src/components/company-logo.tsx +20 -2
  66. package/src/components/data-table/export.ts +13 -8
  67. package/src/components/feedback-dialog.tsx +2 -1
  68. package/src/components/form-modal/field-row.tsx +2 -1
  69. package/src/components/input-search-bar.tsx +2 -2
  70. package/src/components/layout/double-escape-close.ts +8 -5
  71. package/src/components/layout/header.tsx +75 -44
  72. package/src/components/layout/market-summary.ts +322 -116
  73. package/src/components/layout/pane/footer/index.tsx +26 -8
  74. package/src/components/layout/pane/footer/model.ts +46 -20
  75. package/src/components/layout/pane/header.tsx +3 -2
  76. package/src/components/layout/shell/chrome.ts +15 -15
  77. package/src/components/layout/status-bar.tsx +8 -7
  78. package/src/components/layout/status-widget-space.ts +8 -0
  79. package/src/components/markdown-editor.tsx +2 -2
  80. package/src/components/onboarding/account-step/form-panel.tsx +0 -3
  81. package/src/components/onboarding/onboarding-keyboard.ts +15 -6
  82. package/src/components/onboarding/onboarding-wizard.tsx +61 -11
  83. package/src/components/onboarding/portfolio-step/broker-fields-panel.tsx +0 -1
  84. package/src/components/onboarding/portfolio-step/positions-panel.tsx +0 -2
  85. package/src/components/price-sparkline/model.ts +26 -10
  86. package/src/components/ticker/list-table-view.tsx +29 -4
  87. package/src/components/ui/button.tsx +13 -2
  88. package/src/components/ui/column-grid.tsx +18 -9
  89. package/src/components/ui/data-table/index.tsx +1 -1
  90. package/src/components/ui/data-table/opentui/index.tsx +2 -1
  91. package/src/components/ui/data-table/types.ts +18 -0
  92. package/src/components/ui/delayed-mark.tsx +3 -2
  93. package/src/components/ui/field-grid.tsx +0 -2
  94. package/src/components/ui/fields.tsx +7 -4
  95. package/src/components/ui/inline-quick-add.tsx +2 -2
  96. package/src/components/ui/key-hint-words.ts +153 -0
  97. package/src/components/ui/key-hints.tsx +73 -0
  98. package/src/components/ui/menu.tsx +3 -1
  99. package/src/components/ui/message-composer.tsx +2 -2
  100. package/src/components/ui/shortcut-hint.tsx +28 -3
  101. package/src/components/ui/tabs.tsx +7 -0
  102. package/src/components/ui/text-prompt-dialog.tsx +2 -1
  103. package/src/core/state/app/command-bar-launch.ts +3 -0
  104. package/src/data/config/store/normalize.ts +6 -0
  105. package/src/docs/snapshot.json +120 -69
  106. package/src/i18n/es.ts +24 -1
  107. package/src/i18n/ja.ts +24 -1
  108. package/src/i18n/ko.ts +24 -1
  109. package/src/i18n/zh-cn.ts +24 -1
  110. package/src/i18n/zh-tw.ts +24 -1
  111. package/src/layout/pane-manager/gridlock.ts +11 -0
  112. package/src/market-data/bars-per-year.ts +27 -9
  113. package/src/market-data/coordinator/quotes.ts +22 -3
  114. package/src/market-data/futures-board.ts +80 -0
  115. package/src/market-data/futures-contract.ts +9 -3
  116. package/src/market-data/market/change-basis.ts +2 -2
  117. package/src/market-data/market/dated-previous-close.ts +163 -47
  118. package/src/market-data/market/format.ts +14 -3
  119. package/src/market-data/market/freshness.ts +24 -7
  120. package/src/market-data/market/header-market.ts +154 -0
  121. package/src/market-data/market/index-level.ts +29 -0
  122. package/src/market-data/market/index-session-venues.ts +44 -0
  123. package/src/market-data/market/status.ts +7 -2
  124. package/src/market-data/market/venue-session.ts +72 -0
  125. package/src/market-data/model-dividend-yield.ts +23 -8
  126. package/src/market-data/options-alternatives.ts +39 -4
  127. package/src/market-data/published-apac-sessions.ts +40 -2
  128. package/src/market-data/quotes/export-identity.ts +76 -0
  129. package/src/market-data/quotes/freshness.ts +22 -0
  130. package/src/market-data/quotes/time.ts +42 -1
  131. package/src/market-data/realized-volatility.ts +11 -7
  132. package/src/market-data/tax-equivalent.ts +145 -27
  133. package/src/plugins/builtin/account-management/pane.tsx +2 -2
  134. package/src/plugins/builtin/alerts/alert-engine.ts +12 -6
  135. package/src/plugins/builtin/alerts/alert-log.ts +6 -2
  136. package/src/plugins/builtin/alerts/calendar-events.ts +74 -12
  137. package/src/plugins/builtin/alerts/cli-forms.ts +11 -1
  138. package/src/plugins/builtin/alerts/cli-move.ts +234 -0
  139. package/src/plugins/builtin/alerts/cli.ts +224 -33
  140. package/src/plugins/builtin/alerts/command.ts +33 -6
  141. package/src/plugins/builtin/alerts/event-rows.ts +18 -4
  142. package/src/plugins/builtin/alerts/events-pane.tsx +6 -2
  143. package/src/plugins/builtin/alerts/events.ts +9 -0
  144. package/src/plugins/builtin/alerts/format.ts +40 -15
  145. package/src/plugins/builtin/alerts/headless.ts +31 -18
  146. package/src/plugins/builtin/alerts/history.ts +1 -0
  147. package/src/plugins/builtin/alerts/index.tsx +86 -12
  148. package/src/plugins/builtin/alerts/live.ts +2 -1
  149. package/src/plugins/builtin/alerts/move-checks.ts +155 -0
  150. package/src/plugins/builtin/alerts/move.ts +160 -0
  151. package/src/plugins/builtin/alerts/pane.tsx +52 -22
  152. package/src/plugins/builtin/alerts/price-text.ts +62 -0
  153. package/src/plugins/builtin/alerts/price.ts +17 -0
  154. package/src/plugins/builtin/alerts/quotes.ts +84 -3
  155. package/src/plugins/builtin/alerts/scheduled-check.ts +7 -1
  156. package/src/plugins/builtin/alerts/storage.ts +20 -7
  157. package/src/plugins/builtin/alerts/types.ts +13 -0
  158. package/src/plugins/builtin/analytics/risk-client.ts +60 -39
  159. package/src/plugins/builtin/analytics/risk-episodes.ts +18 -0
  160. package/src/plugins/builtin/analytics/risk-headless.ts +20 -4
  161. package/src/plugins/builtin/analytics/risk-model.ts +68 -1
  162. package/src/plugins/builtin/analytics/risk-pane.tsx +15 -3
  163. package/src/plugins/builtin/backtest/engine.ts +4 -2
  164. package/src/plugins/builtin/backtest/window.ts +3 -1
  165. package/src/plugins/builtin/broker-manager/sign-in-end.ts +1 -1
  166. package/src/plugins/builtin/central-bank-rates/client.ts +4 -0
  167. package/src/plugins/builtin/central-bank-rates/headless.ts +1 -1
  168. package/src/plugins/builtin/central-bank-rates/model.ts +18 -8
  169. package/src/plugins/builtin/central-bank-rates/pane.tsx +6 -3
  170. package/src/plugins/builtin/chart-composer/cli-options.ts +5 -0
  171. package/src/plugins/builtin/chart-composer/headless-schema.ts +17 -1
  172. package/src/plugins/builtin/chart-composer/headless.ts +2 -0
  173. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +9 -2
  174. package/src/plugins/builtin/crypto-board/headless.ts +82 -17
  175. package/src/plugins/builtin/crypto-board/index.tsx +24 -2
  176. package/src/plugins/builtin/crypto-board/model.ts +5 -2
  177. package/src/plugins/builtin/crypto-board/pane.tsx +4 -1
  178. package/src/plugins/builtin/debt-maturities/client.ts +111 -6
  179. package/src/plugins/builtin/debt-maturities/headless.ts +84 -1
  180. package/src/plugins/builtin/debt-maturities/model.ts +97 -14
  181. package/src/plugins/builtin/debt-maturities/pane.tsx +165 -15
  182. package/src/plugins/builtin/debt-maturities/series.ts +3 -1
  183. package/src/plugins/builtin/dividend-yield/client.ts +22 -6
  184. package/src/plugins/builtin/dividend-yield/headless.ts +113 -46
  185. package/src/plugins/builtin/dividend-yield/model.ts +5 -2
  186. package/src/plugins/builtin/dividend-yield/pane.tsx +6 -3
  187. package/src/plugins/builtin/dividend-yield/ranking-reads.ts +11 -4
  188. package/src/plugins/builtin/dividend-yield/ranking.ts +113 -18
  189. package/src/plugins/builtin/dividend-yield/types.ts +2 -0
  190. package/src/plugins/builtin/dividend-yield/view.ts +3 -0
  191. package/src/plugins/builtin/econ/calendar-model.ts +21 -3
  192. package/src/plugins/builtin/econ/detail-view.tsx +5 -3
  193. package/src/plugins/builtin/econ/figures.ts +13 -0
  194. package/src/plugins/builtin/econ/fred-catalog.ts +6 -3
  195. package/src/plugins/builtin/econ/index.tsx +5 -3
  196. package/src/plugins/builtin/econ/types.ts +5 -0
  197. package/src/plugins/builtin/equity-screener/footer.ts +45 -0
  198. package/src/plugins/builtin/equity-screener/pane.tsx +4 -18
  199. package/src/plugins/builtin/equity-screener/ticker-check.tsx +2 -1
  200. package/src/plugins/builtin/fixed-income/model.ts +1 -0
  201. package/src/plugins/builtin/futures/table.tsx +1 -1
  202. package/src/plugins/builtin/futures-curve/model.ts +3 -10
  203. package/src/plugins/builtin/help/function-card.tsx +2 -1
  204. package/src/plugins/builtin/help/function-index.ts +1 -0
  205. package/src/plugins/builtin/insider/client.ts +31 -14
  206. package/src/plugins/builtin/insider/signals-model.ts +2 -7
  207. package/src/plugins/builtin/iv-history/headless.ts +1 -2
  208. package/src/plugins/builtin/iv-history/model.ts +33 -23
  209. package/src/plugins/builtin/iv-history/screen-pane.tsx +0 -3
  210. package/src/plugins/builtin/kelly-sizer/headless.ts +64 -16
  211. package/src/plugins/builtin/kelly-sizer/history.ts +37 -28
  212. package/src/plugins/builtin/kelly-sizer/pane.tsx +43 -10
  213. package/src/plugins/builtin/kelly-sizer/sections.tsx +7 -2
  214. package/src/plugins/builtin/kelly-sizer/units.ts +29 -0
  215. package/src/plugins/builtin/news/index.tsx +7 -13
  216. package/src/plugins/builtin/news/overview-headlines.tsx +117 -0
  217. package/src/plugins/builtin/news/ticker-news.ts +35 -0
  218. package/src/plugins/builtin/news/wire/news/detail-view.tsx +8 -6
  219. package/src/plugins/builtin/news/wire/news/row.ts +49 -0
  220. package/src/plugins/builtin/news/wire/news/table.tsx +9 -20
  221. package/src/plugins/builtin/options/analytics.ts +7 -2
  222. package/src/plugins/builtin/options/live-quotes.ts +6 -1
  223. package/src/plugins/builtin/options/table.ts +3 -2
  224. package/src/plugins/builtin/options/view.tsx +11 -9
  225. package/src/plugins/builtin/options-scenario/client.ts +3 -0
  226. package/src/plugins/builtin/options-scenario/headless.ts +1 -1
  227. package/src/plugins/builtin/perps/client.ts +5 -4
  228. package/src/plugins/builtin/perps/headless.ts +134 -124
  229. package/src/plugins/builtin/perps/markets-section.tsx +2 -2
  230. package/src/plugins/builtin/perps/model.ts +8 -4
  231. package/src/plugins/builtin/perps/open-market.ts +4 -4
  232. package/src/plugins/builtin/perps/venue-markets.ts +3 -6
  233. package/src/plugins/builtin/portfolio-list/cell-version.ts +1 -0
  234. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +34 -10
  235. package/src/plugins/builtin/portfolio-list/cli/period-report.ts +28 -2
  236. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +7 -3
  237. package/src/plugins/builtin/portfolio-list/cli/render.ts +66 -22
  238. package/src/plugins/builtin/portfolio-list/grid.tsx +5 -3
  239. package/src/plugins/builtin/portfolio-list/pane/data.ts +34 -1
  240. package/src/plugins/builtin/portfolio-list/pane/index.tsx +6 -0
  241. package/src/plugins/builtin/portfolio-list/pane/streaming.ts +15 -6
  242. package/src/plugins/builtin/portfolio-list/quick-add/resolution.ts +19 -7
  243. package/src/plugins/builtin/portfolio-list/table.tsx +30 -4
  244. package/src/plugins/builtin/realized-vol/evidence.ts +33 -6
  245. package/src/plugins/builtin/realized-vol/fx-proxy.ts +135 -0
  246. package/src/plugins/builtin/realized-vol/headless.ts +44 -8
  247. package/src/plugins/builtin/realized-vol/model.ts +9 -5
  248. package/src/plugins/builtin/realized-vol/pane.tsx +49 -15
  249. package/src/plugins/builtin/sec/headless.ts +48 -6
  250. package/src/plugins/builtin/sec/index.tsx +6 -4
  251. package/src/plugins/builtin/sec/model.ts +4 -1
  252. package/src/plugins/builtin/shared/earnings-calendar.ts +2 -0
  253. package/src/plugins/builtin/shared/market-cap-bands.ts +12 -0
  254. package/src/plugins/builtin/shared/report-freshness.ts +3 -1
  255. package/src/plugins/builtin/shared/use-quote-board.ts +5 -3
  256. package/src/plugins/builtin/shared/volatility/options.ts +63 -2
  257. package/src/plugins/builtin/social-mentions/headless.ts +72 -3
  258. package/src/plugins/builtin/social-mentions/index.tsx +8 -4
  259. package/src/plugins/builtin/social-mentions/lock-note.ts +6 -2
  260. package/src/plugins/builtin/social-mentions/outliers-client.ts +101 -0
  261. package/src/plugins/builtin/social-mentions/outliers-model.ts +162 -0
  262. package/src/plugins/builtin/social-mentions/outliers-names.ts +51 -0
  263. package/src/plugins/builtin/social-mentions/outliers.tsx +276 -0
  264. package/src/plugins/builtin/social-mentions/pane.tsx +32 -3
  265. package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -2
  266. package/src/plugins/builtin/thirteenf/api.ts +36 -2
  267. package/src/plugins/builtin/thirteenf/data.ts +4 -1
  268. package/src/plugins/builtin/thirteenf/headless.ts +14 -6
  269. package/src/plugins/builtin/thirteenf/model.ts +56 -1
  270. package/src/plugins/builtin/thirteenf/pane.tsx +8 -8
  271. package/src/plugins/builtin/thirteenf/report-notes.ts +11 -0
  272. package/src/plugins/builtin/thirteenf/table.ts +2 -1
  273. package/src/plugins/builtin/thirteenf/types.ts +6 -0
  274. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +23 -3
  275. package/src/plugins/builtin/ticker-detail/financials/model.ts +5 -0
  276. package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -1
  277. package/src/plugins/builtin/ticker-detail/headless.ts +21 -66
  278. package/src/plugins/builtin/ticker-detail/index.tsx +5 -0
  279. package/src/plugins/builtin/ticker-detail/overview/components.tsx +13 -1
  280. package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
  281. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +15 -0
  282. package/src/plugins/builtin/ticker-detail/overview/tax-equivalent.ts +69 -0
  283. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +41 -6
  284. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +47 -24
  285. package/src/plugins/builtin/ticker-detail/quote-monitor/export.ts +46 -0
  286. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +20 -1
  287. package/src/plugins/builtin/ticker-detail/quote-monitor/rows.ts +120 -0
  288. package/src/plugins/builtin/ticker-detail/research-tabs.ts +1 -5
  289. package/src/plugins/builtin/ticker-detail/settings.ts +6 -6
  290. package/src/plugins/builtin/treasury-auctions/cache.ts +85 -19
  291. package/src/plugins/builtin/treasury-auctions/index.tsx +22 -11
  292. package/src/plugins/builtin/treasury-auctions/model.ts +23 -0
  293. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +128 -0
  294. package/src/plugins/builtin/world-indices/client.ts +2 -0
  295. package/src/plugins/compat.ts +15 -0
  296. package/src/plugins/host-link.ts +6 -1
  297. package/src/plugins/installer.ts +8 -3
  298. package/src/portfolio/column-values.ts +14 -4
  299. package/src/portfolio/listed-symbol.ts +78 -0
  300. package/src/portfolio/real-return.ts +172 -0
  301. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  302. package/src/renderers/browser/config-host.ts +56 -15
  303. package/src/renderers/browser/main.tsx +3 -1
  304. package/src/renderers/browser/ui-host.tsx +1 -0
  305. package/src/renderers/cloudflare/http-proxy.ts +1 -0
  306. package/src/renderers/dom/boot-frame.ts +2 -2
  307. package/src/renderers/dom/data-table/row.tsx +4 -1
  308. package/src/renderers/dom/desktop/controls.tsx +4 -4
  309. package/src/renderers/dom/desktop/dialog-actions.tsx +60 -41
  310. package/src/renderers/dom/dom-ui-host.tsx +3 -1
  311. package/src/renderers/dom/host/input.tsx +4 -1
  312. package/src/renderers/dom/host/tabs.tsx +10 -1
  313. package/src/renderers/dom/styles.css +33 -13
  314. package/src/renderers/electrobun/bun/desktop/app-name.ts +1 -1
  315. package/src/renderers/opentui/host.tsx +2 -1
  316. package/src/sources/gloomberb-cloud/fred-series.ts +12 -0
  317. package/src/sources/gloomberb-cloud/index.ts +31 -2
  318. package/src/sources/gloomberb-cloud/normalizers.ts +29 -3
  319. package/src/sources/provider-router/cached-routes.ts +19 -7
  320. package/src/state/pane-table-export-registry.ts +19 -6
  321. package/src/test-support/preload.ts +5 -1
  322. package/src/theme/colors.ts +9 -1
  323. package/src/theme/themes.ts +62 -15
  324. package/src/theme/tone-contrast.ts +40 -0
  325. package/src/theme/ui-tokens.ts +23 -3
  326. package/src/tickers/batched-lookups.ts +57 -8
  327. package/src/tickers/company-name-listing.ts +156 -14
  328. package/src/tickers/company-name.ts +30 -6
  329. package/src/tickers/list.ts +7 -0
  330. package/src/tickers/search/home-listing.ts +31 -9
  331. package/src/tickers/search/index.ts +13 -3
  332. package/src/tickers/search/listing-index.ts +558 -0
  333. package/src/tickers/search/major-listings.chunk.ts +10 -0
  334. package/src/tickers/search/major-listings.json +3346 -0
  335. package/src/tickers/search/ranking.ts +68 -1
  336. package/src/tickers/search/types.ts +4 -0
  337. package/src/tickers/terminal-codes.ts +26 -1
  338. package/src/time-series/calendar-month-returns.ts +47 -0
  339. package/src/time-series/currency-conversion.ts +130 -0
  340. package/src/time-series/hooks.ts +2 -0
  341. package/src/time-series/price-comparison.ts +34 -11
  342. package/src/time-series/resolve-context.ts +3 -0
  343. package/src/time-series/resolve.ts +14 -2
  344. package/src/time-series/spec.ts +1 -0
  345. package/src/time-series/studies/indicators.ts +4 -1
  346. package/src/time-series/types.ts +8 -0
  347. package/src/types/config.ts +8 -0
  348. package/src/types/data-provider.ts +28 -0
  349. package/src/types/financials.ts +20 -2
  350. package/src/types/headless.ts +12 -0
  351. package/src/ui/host.tsx +8 -0
  352. package/src/utils/datetime-format.ts +17 -3
  353. package/src/utils/display-number.ts +15 -0
  354. package/src/utils/double-escape-close.ts +61 -16
  355. package/src/utils/float32-price.ts +24 -0
  356. package/src/utils/forward-dividend.ts +81 -16
  357. package/src/utils/fx-market-hours.ts +11 -0
  358. package/src/utils/plugin-proxy-hosts.json +2 -1
  359. package/src/utils/price-history.ts +7 -6
  360. package/src/utils/report-timing.ts +62 -0
  361. package/src/utils/sec-filings.ts +32 -0
  362. package/src/utils/utc-time.ts +5 -0
@@ -5,6 +5,7 @@ import type {
5
5
  FinancialStatement,
6
6
  Fundamentals,
7
7
  NextEarnings,
8
+ OptionContract,
8
9
  OptionsChain,
9
10
  PricePoint,
10
11
  Quote,
@@ -24,6 +25,7 @@ import { isRoundTheClockCoin } from "../../utils/crypto-pair";
24
25
  import { latestSettledSessionDate } from "../../utils/price-history";
25
26
  import { zonedDateTimeParts, zonedWallClockToUtcMs } from "../../utils/zoned-date-time";
26
27
  import { createProviderMiss } from "../provider-errors";
28
+ import { parseOptionTicker } from "../../utils/options";
27
29
  import { reconcileQuoteDayRange } from "../../market-data/quotes/day-range";
28
30
  import { redactUnavailableFundamentals } from "../../utils/fundamentals";
29
31
  import { readWithdrawnObservations } from "../../utils/statement-gaps";
@@ -296,7 +298,8 @@ function mapCloudFundamentals(fundamentals: Fundamentals | undefined): Fundament
296
298
  }
297
299
 
298
300
  const EARNINGS_TIMINGS: ReadonlySet<unknown> = new Set(["bmo", "dmh", "amc"]);
299
- const EARNINGS_TIMING_SOURCES: ReadonlySet<unknown> = new Set(["filing", "calendar", "history"]);
301
+ // "company": a date (and time) the company announced itself, which the service keeps over the calendar's.
302
+ const EARNINGS_TIMING_SOURCES: ReadonlySet<unknown> = new Set(["filing", "calendar", "history", "company"]);
300
303
 
301
304
  /** The served next report; one without a calendar date is left out. */
302
305
  function mapCloudNextEarnings(value: NextEarnings | undefined): NextEarnings | undefined {
@@ -346,14 +349,37 @@ export function mapCloudFinancials(
346
349
  };
347
350
  }
348
351
 
352
+ /**
353
+ * Whether a contract is one a corporate action adjusted: the server tags the
354
+ * ones it lists on request, and a contract under a numbered root that is not
355
+ * the underlying's (ETHA1 beside ETHA) is one too, from a server that does not.
356
+ */
357
+ function adjustedRoot(contract: OptionContract, underlying: string): string | null {
358
+ if (contract.adjusted) return contract.adjusted.root;
359
+ const root = parseOptionTicker(contract.contractSymbol)?.underlying.toUpperCase();
360
+ return root && /\d$/.test(root) && root !== underlying.toUpperCase() ? root : null;
361
+ }
362
+
363
+ /**
364
+ * A served chain: its standard contracts, or with `adjusted` the contracts a
365
+ * corporate action adjusted, which price another deliverable and are listed
366
+ * only when asked for.
367
+ */
349
368
  export function mapOptionsChain(
350
369
  chain: CloudOptionsChainPayload,
370
+ { adjusted = false }: { adjusted?: boolean } = {},
351
371
  ): OptionsChain {
372
+ // An adjusted contract a server did not tag is tagged here, its deliverable unstated.
373
+ const contracts = (side: OptionContract[] | undefined) => (side ?? []).flatMap((contract) => {
374
+ const root = adjustedRoot(contract, chain.underlyingSymbol);
375
+ if ((root != null) !== adjusted) return [];
376
+ return [root && !contract.adjusted ? { ...contract, adjusted: { root, deliverable: null } } : contract];
377
+ });
352
378
  return {
353
379
  underlyingSymbol: chain.underlyingSymbol,
354
380
  expirationDates: chain.expirationDates ?? [],
355
- calls: chain.calls ?? [],
356
- puts: chain.puts ?? [],
381
+ calls: contracts(chain.calls),
382
+ puts: contracts(chain.puts),
357
383
  providerId: chain.providerId,
358
384
  dataSource: chain.dataSource,
359
385
  feed: chain.feed,
@@ -222,13 +222,25 @@ export class ProviderRouterCachedRoutes {
222
222
  acceptCached: (data: CorporateActionsData) => !data.stale && !Object.values(data.coverage ?? {}).includes("unavailable"), throwLastError: true,
223
223
  error: `No corporate actions provider available for ${ticker}`,
224
224
  };
225
- case "getOptionsChain": return {
226
- ...tickerRoute("options-chain", "optionsChain"),
227
- variants: [...new Set([buildVariantKey([["exchange", canonicalExchange(exchange)], ["expiration", extra ?? "default"]]), buildVariantKey([["expiration", extra ?? "default"]]), ""])],
228
- request: (provider, force) => provider.getOptionsChain?.(ticker, exchange, extra, force ? { ...context, cacheMode: "refresh" } : context),
229
- brokerRequest: { ticker, exchange, expiration: extra, context },
230
- error: `No options provider available for ${ticker}`,
231
- };
225
+ case "getOptionsChain": {
226
+ // The contracts a corporate action adjusted (ETHA1) are a list of their own: kept under their own key, never
227
+ // read for the standard chain nor answered with it, and no broker's chain stands in for them.
228
+ if (context?.adjustedOptions) {
229
+ return {
230
+ ...tickerRoute("options-chain", "optionsChain"),
231
+ variants: [buildVariantKey([["exchange", canonicalExchange(exchange)], ["expiration", extra ?? "default"], ["adjusted", 1]])],
232
+ request: (provider, force) => provider.getOptionsChain?.(ticker, exchange, extra, force ? { ...context, cacheMode: "refresh" } : context),
233
+ error: `No options provider available for ${ticker}`,
234
+ };
235
+ }
236
+ return {
237
+ ...tickerRoute("options-chain", "optionsChain"),
238
+ variants: [...new Set([buildVariantKey([["exchange", canonicalExchange(exchange)], ["expiration", extra ?? "default"]]), buildVariantKey([["expiration", extra ?? "default"]]), ""])],
239
+ request: (provider, force) => provider.getOptionsChain?.(ticker, exchange, extra, force ? { ...context, cacheMode: "refresh" } : context),
240
+ brokerRequest: { ticker, exchange, expiration: extra, context },
241
+ error: `No options provider available for ${ticker}`,
242
+ };
243
+ }
232
244
  case "getSecFilings": {
233
245
  const [symbol, count = 15, listingExchange, requestContext] = args as CachedAssetArgs<"getSecFilings">;
234
246
  const exact = buildVariantKey([["exchange", canonicalExchange(listingExchange)], ["count", count]]);
@@ -2,15 +2,22 @@ import { createCsvExportFilename } from "../utils/csv";
2
2
 
3
3
  export type PaneTableExporter = (filename: string) => Promise<string>;
4
4
 
5
- const exporters = new Map<string, Map<symbol, PaneTableExporter>>();
5
+ interface RegisteredExporter {
6
+ exporter: PaneTableExporter;
7
+ /** What the table is of, which names the file: a watchlist's name, not the pane's ("Portfolio"). */
8
+ name?: () => string | null | undefined;
9
+ }
10
+
11
+ const exporters = new Map<string, Map<symbol, RegisteredExporter>>();
6
12
 
7
13
  export function registerPaneTableExporter(
8
14
  paneId: string,
9
15
  exporter: PaneTableExporter,
16
+ name?: () => string | null | undefined,
10
17
  ): () => void {
11
18
  const token = Symbol(paneId);
12
- const paneExporters = exporters.get(paneId) ?? new Map<symbol, PaneTableExporter>();
13
- paneExporters.set(token, exporter);
19
+ const paneExporters = exporters.get(paneId) ?? new Map<symbol, RegisteredExporter>();
20
+ paneExporters.set(token, { exporter, ...name ? { name } : {} });
14
21
  exporters.set(paneId, paneExporters);
15
22
 
16
23
  return () => {
@@ -24,12 +31,16 @@ export function hasPaneTableExporter(paneId: string): boolean {
24
31
  return exporters.get(paneId)?.size === 1;
25
32
  }
26
33
 
27
- export async function exportPaneTable(paneId: string, filename: string): Promise<string> {
34
+ function activeExporter(paneId: string): RegisteredExporter {
28
35
  const paneExporters = exporters.get(paneId);
29
36
  if (paneExporters?.size !== 1) {
30
37
  throw new Error("This pane does not have one active exportable table.");
31
38
  }
32
- return [...paneExporters.values()][0]!(filename);
39
+ return [...paneExporters.values()][0]!;
40
+ }
41
+
42
+ export async function exportPaneTable(paneId: string, filename: string): Promise<string> {
43
+ return activeExporter(paneId).exporter(filename);
33
44
  }
34
45
 
35
46
  /**
@@ -42,7 +53,9 @@ export async function exportPaneTableCsv(
42
53
  notify: (notification: { body: string; type: "success" | "error" }) => void,
43
54
  ): Promise<void> {
44
55
  try {
45
- const location = await exportPaneTable(paneId, createCsvExportFilename(title));
56
+ // The file is named after what the table is of when it says (the watchlist shown), else the pane.
57
+ const named = exporters.get(paneId)?.size === 1 ? activeExporter(paneId).name?.()?.trim() : null;
58
+ const location = await exportPaneTable(paneId, createCsvExportFilename(named || title));
46
59
  notify({ body: `Exported to ${location}`, type: "success" });
47
60
  } catch {
48
61
  notify({ body: "Failed to export CSV", type: "error" });
@@ -1,5 +1,6 @@
1
1
  import { beforeEach } from "bun:test";
2
2
  import { resetSeenPaneNoticesForTest } from "../components/pane-notice-seen";
3
+ import { resetListingIndexForTests } from "../tickers/search/listing-index";
3
4
  import { resetCrashReporterForTests } from "../telemetry/crash-reports";
4
5
  import { setCliAsciiLocaleOverride, setCliColorEnabledOverride, setCliPlainOverride, setCliWidthOverride } from "../utils/cli-output";
5
6
 
@@ -16,11 +17,14 @@ import { setCliAsciiLocaleOverride, setCliColorEnabledOverride, setCliPlainOverr
16
17
  * columns. Start each test with the default output modes and terminal width.
17
18
  *
18
19
  * Data warnings the user has opened are remembered the same way, and would
19
- * leave a later test's footer icon muted instead of warning yellow.
20
+ * leave a later test's footer icon muted instead of warning yellow. So are the
21
+ * listings search answered, which would name a later test's symbol before its
22
+ * own search does.
20
23
  */
21
24
  beforeEach(() => {
22
25
  resetCrashReporterForTests();
23
26
  resetSeenPaneNoticesForTest();
27
+ resetListingIndexForTests();
24
28
  setCliAsciiLocaleOverride(null);
25
29
  setCliColorEnabledOverride(null);
26
30
  setCliPlainOverride(null);
@@ -1,6 +1,6 @@
1
1
  import { blendForContrast, blendForContrastOnSurfaces, blendHex, higherContrast } from "./color-utils";
2
2
  import { getTheme, DEFAULT_THEME, type Theme } from "./themes";
3
- import { hoverColour, themeCssVariables } from "./ui-tokens";
3
+ import { hoverColour, placeholderColour, themeCssVariables } from "./ui-tokens";
4
4
 
5
5
  export type ThemeColors = Readonly<Omit<Theme, "name" | "description">>;
6
6
 
@@ -94,6 +94,14 @@ export function hoverBg(palette: ThemeColors = colors): string {
94
94
  return hoverColour(palette);
95
95
  }
96
96
 
97
+ /**
98
+ * Placeholder text in a field (ui-tokens `placeholderColour`); `surface` is
99
+ * what the field sits on when that is not the page or a panel.
100
+ */
101
+ export function placeholderText(palette: ThemeColors = colors, surface?: string): string {
102
+ return placeholderColour(palette, surface);
103
+ }
104
+
97
105
  /** Body-text contrast, which text on a hovered control keeps whatever the surface. */
98
106
  const HOVER_TEXT_MIN_CONTRAST = 4.5;
99
107
 
@@ -34,9 +34,27 @@ export interface Theme {
34
34
 
35
35
  commandBg: string;
36
36
  commandBorder: string;
37
+
38
+ /**
39
+ * The up, down, warning and neutral colours in a selected row, read against
40
+ * its fill. Only a light or colour-blind theme has them, set by the registry:
41
+ * it reads its tones at body contrast (TONE_TEXT_MIN) everywhere, so it lifts
42
+ * them there (the vermillion of a loss read 3.16:1 on colorblind-light's
43
+ * selection). Without them a tone is drawn as it is.
44
+ */
45
+ selectedPositive?: string;
46
+ selectedNegative?: string;
47
+ selectedWarning?: string;
48
+ selectedNeutral?: string;
37
49
  }
38
50
 
39
51
  const BODY_TEXT_MIN = 4.5;
52
+ /**
53
+ * What the up, down, warning and neutral colours keep in a light or colour-blind
54
+ * theme, on the page and in a selected row: body contrast, because a loss, a
55
+ * delay or a warning is read, not just seen. Dark themes keep SUBTLE_TEXT_MIN.
56
+ */
57
+ export const TONE_TEXT_MIN = 4.5;
40
58
  /** What muted text and the up, down and warning colours keep against the page. */
41
59
  export const SUBTLE_TEXT_MIN = 3.6;
42
60
  const SELECTED_SURFACE_MIN = 1.75;
@@ -49,7 +67,25 @@ function highestMinimumContrast(surfaces: readonly string[], candidates: readonl
49
67
  });
50
68
  }
51
69
 
52
- function normalizeTheme(theme: Theme): Theme {
70
+ /**
71
+ * `base` walked toward `toward` in small steps until it reads at `min` on every
72
+ * surface: the least change that does, so a tone keeps its hue. `toward` itself
73
+ * when no step reads.
74
+ */
75
+ function tintForContrast(base: string, surfaces: readonly string[], toward: string, min: number): string {
76
+ for (let step = 0; step <= 50; step += 1) {
77
+ const candidate = step === 0 ? base : blendHex(base, toward, step / 50);
78
+ if (surfaces.every((surface) => contrastRatio(candidate, surface) >= min)) return candidate;
79
+ }
80
+ return toward;
81
+ }
82
+
83
+ interface ThemeNorms {
84
+ /** Light and colour-blind themes: tones at TONE_TEXT_MIN on the page and in a selected row. */
85
+ readableTones: boolean;
86
+ }
87
+
88
+ function normalizeTheme(theme: Theme, { readableTones }: ThemeNorms): Theme {
53
89
  const bodySurfaces = [theme.bg, theme.panel] as const;
54
90
  const bodyContrastExtreme = highestMinimumContrast(bodySurfaces, ["#ffffff", "#000000"]);
55
91
  const text = blendForContrastOnSurfaces(
@@ -112,19 +148,22 @@ function normalizeTheme(theme: Theme): Theme {
112
148
  highestMinimumContrast([selected], [text, theme.textBright, "#f2f2f2"]),
113
149
  BODY_TEXT_MIN,
114
150
  );
115
-
151
+ const tones = { positive, negative, warning, neutral };
152
+ if (!readableTones) return { ...theme, text, textDim, textMuted, ...tones, headerText, selected, selectedText };
153
+ // Toward the page's far end on the page; toward the row's far end in a selected row.
154
+ const bodyExtreme = highestMinimumContrast(bodySurfaces, ["#ffffff", "#000000"]);
155
+ const selectedExtreme = highestMinimumContrast([selected], ["#ffffff", "#000000"]);
156
+ const readable = (tone: string) => tintForContrast(tone, bodySurfaces, bodyExtreme, TONE_TEXT_MIN);
157
+ const onSelected = (tone: string) => tintForContrast(tone, [selected], selectedExtreme, TONE_TEXT_MIN);
158
+ const page = {
159
+ positive: readable(positive), negative: readable(negative), warning: readable(warning), neutral: readable(neutral),
160
+ };
116
161
  return {
117
- ...theme,
118
- text,
119
- textDim,
120
- textMuted,
121
- positive,
122
- negative,
123
- neutral,
124
- warning,
125
- headerText,
126
- selected,
127
- selectedText,
162
+ ...theme, text, textDim, textMuted, ...page, headerText, selected, selectedText,
163
+ selectedPositive: onSelected(page.positive),
164
+ selectedNegative: onSelected(page.negative),
165
+ selectedWarning: onSelected(page.warning),
166
+ selectedNeutral: onSelected(page.neutral),
128
167
  };
129
168
  }
130
169
 
@@ -674,7 +713,9 @@ const rawThemes: Record<string, Theme> = {
674
713
  textBright: "#000000",
675
714
  textMuted: "#646b75",
676
715
  positive: "#0072b2",
677
- negative: "#a84100",
716
+ // A shade under the Okabe-Ito vermillion: the amber warning, darkened to
717
+ // 4.5:1 on the panel, would otherwise sit too close to it for protanopia.
718
+ negative: "#9e3400",
678
719
  neutral: "#5f6670",
679
720
  warning: "#a27409",
680
721
  header: "#e9ecef",
@@ -711,8 +752,13 @@ const rawThemes: Record<string, Theme> = {
711
752
  },
712
753
  };
713
754
 
755
+ /** The colour-blind safe themes (THEME_TRAITS), which read their tones at body contrast as the light ones do. */
756
+ const COLORBLIND_SAFE_THEMES = new Set(["colorblind", "colorblind-light", "high-contrast"]);
757
+
714
758
  export const themes: Record<string, Theme> = Object.fromEntries(
715
- Object.entries(rawThemes).map(([id, theme]) => [id, normalizeTheme(theme)]),
759
+ Object.entries(rawThemes).map(([id, theme]) => [id, normalizeTheme(theme, {
760
+ readableTones: COLORBLIND_SAFE_THEMES.has(id) || relativeLuminance(theme.text) < relativeLuminance(theme.bg),
761
+ })]),
716
762
  ) as Record<string, Theme>;
717
763
 
718
764
  // The monochrome theme the website and web app show, so a new install looks
@@ -740,6 +786,7 @@ export function getTheme(id: string): Theme {
740
786
 
741
787
  type ThemeTrait = "colorblind-safe" | "high-contrast";
742
788
 
789
+ // Keep the colour-blind safe ids in COLORBLIND_SAFE_THEMES as well.
743
790
  const THEME_TRAITS: Readonly<Record<string, readonly ThemeTrait[]>> = {
744
791
  colorblind: ["colorblind-safe"],
745
792
  "colorblind-light": ["colorblind-safe"],
@@ -0,0 +1,40 @@
1
+ import { blendForContrast, higherContrast } from "./color-utils";
2
+ import { colors, floatingPaneTitleBg, paneTitleBg } from "./colors";
3
+ import type { ThemeColors } from "./colors";
4
+
5
+ /**
6
+ * Whether the theme reads its text at body contrast on every surface, its
7
+ * tones and hints included: the light and colour-blind themes, which the
8
+ * registry gives selected-row tones (Theme.selectedWarning). Dark themes
9
+ * draw as they always have.
10
+ */
11
+ export function readsAtBodyContrast(palette: ThemeColors = colors): boolean {
12
+ return palette.selectedWarning !== undefined;
13
+ }
14
+
15
+ /**
16
+ * A cell's colour in a selected row: an up, down, warning or neutral tone as the
17
+ * theme lifts it to read on the selection (Theme.selectedNegative), any other
18
+ * colour as it is. Data tables draw every coloured cell of the selected row
19
+ * through it, in the terminal and on the desktop alike.
20
+ */
21
+ export function selectedCellColor<T extends string | undefined>(color: T, palette: ThemeColors = colors): T | string {
22
+ if (color === undefined) return color;
23
+ if (color === palette.positive) return palette.selectedPositive ?? color;
24
+ if (color === palette.negative) return palette.selectedNegative ?? color;
25
+ if (color === palette.warning) return palette.selectedWarning ?? color;
26
+ if (color === palette.neutral) return palette.selectedNeutral ?? color;
27
+ return color;
28
+ }
29
+
30
+ /**
31
+ * A tone on the pane title bar, such as a quick setting that is on (the live
32
+ * ⚡): lifted to body contrast on the bar in a theme that reads its tones so
33
+ * (Theme.selectedWarning is set), since the bar sits darker than the page
34
+ * its tokens are checked on; as it is in any other theme.
35
+ */
36
+ export function paneTitleTone(tone: string, focused: boolean, floating = false, palette: ThemeColors = colors): string {
37
+ if (!readsAtBodyContrast(palette)) return tone;
38
+ const bar = floating ? floatingPaneTitleBg(focused, palette) : paneTitleBg(focused, palette);
39
+ return blendForContrast(tone, bar, higherContrast("#000000", "#ffffff", bar), 4.5);
40
+ }
@@ -1,5 +1,5 @@
1
- import { blendHex } from "./color-utils";
2
- import type { Theme } from "./themes";
1
+ import { blendForContrast, blendHex, higherContrast } from "./color-utils";
2
+ import { SUBTLE_TEXT_MIN, type Theme } from "./themes";
3
3
 
4
4
  type Palette = Readonly<Omit<Theme, "name" | "description">>;
5
5
 
@@ -53,6 +53,22 @@ function surfaceSunkenColour(palette: Palette): string {
53
53
  return palette.bg;
54
54
  }
55
55
 
56
+ /**
57
+ * Placeholder text in every field, the command bar's prompt included: the
58
+ * muted text, which a theme keeps at the subtle-text contrast against the page
59
+ * and its panels. A field on a surface of its own (the header, the command
60
+ * bar) passes that surface, and the colour is lifted only as far as it needs
61
+ * to keep the same contrast there.
62
+ */
63
+ export function placeholderColour(palette: Palette, surface: string = palette.bg): string {
64
+ return blendForContrast(
65
+ palette.textMuted,
66
+ surface,
67
+ higherContrast(palette.text, palette.textBright, surface),
68
+ SUBTLE_TEXT_MIN,
69
+ );
70
+ }
71
+
56
72
  /** A row or control under the pointer: halfway from the background to the selection. */
57
73
  export function hoverColour(palette: Palette): string {
58
74
  return blendHex(palette.bg, palette.selected, 0.5);
@@ -72,11 +88,15 @@ function roleColours(palette: Palette): Array<[string, string]> {
72
88
  ["--gloom-link-hover", palette.textBright],
73
89
  ["--gloom-error", palette.negative],
74
90
  ["--gloom-locked", palette.textDim],
91
+ ["--gloom-placeholder", placeholderColour(palette)],
75
92
  ];
76
93
  }
77
94
 
95
+ /** A theme's own colours: the derived ones it may leave out (the tones in a selected row) are not variables. */
96
+ type PaletteColour = { [K in keyof Palette]-?: undefined extends Palette[K] ? never : K }[keyof Palette];
97
+
78
98
  /** The palette entries styles.css reads as they are. */
79
- const PALETTE_VARIABLES: Array<[keyof Palette, string]> = [
99
+ const PALETTE_VARIABLES: Array<[PaletteColour, string]> = [
80
100
  ["bg", "--gloom-bg"],
81
101
  ["panel", "--gloom-panel"],
82
102
  ["border", "--gloom-border"],
@@ -3,7 +3,7 @@ import type { Quote } from "../types/financials";
3
3
  import type { InstrumentSearchResult } from "../types/instrument";
4
4
  import { logFailure } from "../utils/log-failure";
5
5
  import { chunked } from "../utils/concurrency";
6
- import { isNoProviderMessage, isProviderBusy } from "../sources/provider-errors";
6
+ import { createProviderMiss, isNoProviderMessage, isNoSourceAnswer, isProviderBusy, notATickerSymbol } from "../sources/provider-errors";
7
7
  import { ApiRequestError } from "../api-client/errors";
8
8
 
9
9
  /** The service refusing a request for the caller's rate (429). */
@@ -47,6 +47,13 @@ export interface BatchedLookups {
47
47
  dataProvider: DataProvider;
48
48
  /** Whether a symbol's searches were all answered in a batch, so its lookup asks the sources for quotes alone. */
49
49
  answered(plan: ListLookupPlan): boolean;
50
+ /**
51
+ * Whether the service answered every search a symbol's lookup runs, found or
52
+ * not, and its own quote without refusing it: a symbol it then finds nothing
53
+ * for is not found, whatever it refused the others, and asking again gives
54
+ * the same answer.
55
+ */
56
+ settled(plan: ListLookupPlan): boolean;
50
57
  }
51
58
 
52
59
  const searchKey = (query: string) => query.trim().toUpperCase();
@@ -66,7 +73,7 @@ export async function batchedListLookups(
66
73
  plans: readonly ListLookupPlan[],
67
74
  ): Promise<BatchedLookups> {
68
75
  // Symbols that are all saved already are looked up with no source at all.
69
- if (!dataProvider) return { dataProvider, answered: () => false };
76
+ if (!dataProvider) return { dataProvider, answered: () => false, settled: () => false };
70
77
  const queries = [...new Set(plans.flatMap((plan) => plan.searches.map(searchKey)))];
71
78
  const changeSymbols = [...new Set(plans.flatMap((plan) => plan.changes ? [plan.changes] : []))];
72
79
  // The changes first: a request or so for the whole list, which the searches,
@@ -81,7 +88,7 @@ export async function batchedListLookups(
81
88
  const searches = queries.length && dataProvider.searchBatch
82
89
  ? await dataProvider.searchBatch(queries, { limit: BATCHED_SEARCH_LIMIT }).catch(logFailure("tickers.batched-lookups", "Batched search failed", null))
83
90
  : null;
84
- if (!searches?.size && !changes?.size && !quotes) return { dataProvider, answered: () => false };
91
+ if (!searches?.size && !changes?.size && !quotes) return { dataProvider, answered: () => false, settled: () => false };
85
92
 
86
93
  // An empty answer is asked again on its own, so a fallback source still gets its turn.
87
94
  const searched = (query: string) => (searches?.get(searchKey(query))?.length ?? 0) > 0;
@@ -107,6 +114,8 @@ export async function batchedListLookups(
107
114
  return {
108
115
  dataProvider: withOverrides(dataProvider, overrides),
109
116
  answered: (plan) => plan.searches.length > 0 && plan.searches.every(searched),
117
+ settled: (plan) => plan.searches.length > 0 && plan.searches.every((query) => !!searches?.has(searchKey(query)))
118
+ && (!plan.quote || !quotes || quotes.answered(plan.quote, "")),
110
119
  };
111
120
  }
112
121
 
@@ -156,6 +165,8 @@ interface PendingQuote {
156
165
  */
157
166
  class QuoteGatherer {
158
167
  private readonly answers = new Map<string, Promise<Quote>>();
168
+ /** Listings the service answered, with a quote or with why there is none, rather than refusing. */
169
+ private readonly told = new Set<string>();
159
170
  private pending: PendingQuote[] = [];
160
171
  private timer: ReturnType<typeof setTimeout> | null = null;
161
172
 
@@ -169,11 +180,19 @@ class QuoteGatherer {
169
180
  this.pending.push({ ticker, exchange, resolve, reject });
170
181
  });
171
182
  this.answers.set(key, answer);
183
+ answer.then(() => this.told.add(key), (error: unknown) => {
184
+ if (!isProviderBusy(error) && !isRateRefusal(error)) this.told.add(key);
185
+ });
172
186
  if (this.pending.length >= QUOTE_BATCH_SIZE) this.flush();
173
187
  else this.timer ??= setTimeout(() => this.flush(), QUOTE_GATHER_MS);
174
188
  return answer;
175
189
  }
176
190
 
191
+ /** Whether a listing's quote was answered rather than refused. */
192
+ answered(ticker: string, exchange: string): boolean {
193
+ return this.told.has(listingKey(ticker, exchange));
194
+ }
195
+
177
196
  private flush(): void {
178
197
  if (this.timer) clearTimeout(this.timer);
179
198
  this.timer = null;
@@ -338,6 +357,9 @@ export class RequestAllowance {
338
357
  }
339
358
  }
340
359
 
360
+ /** A listing's quote answered with none, as `listLookups` keeps it beside the errors that said so. */
361
+ const NO_QUOTE = Symbol("no quote");
362
+
341
363
  /**
342
364
  * The data provider one command's lookups of a list read through, each
343
365
  * answer kept for the command: what reading the list's names asked (their
@@ -404,10 +426,28 @@ export function listLookups(dataProvider: DataProvider, { allowances = null }: {
404
426
  return new Map(queries.map((query) => [query, firstRows(rowsOf(query), limit)]));
405
427
  };
406
428
  }
429
+ // A listing no source has a quote for (a source's miss, "Not a ticker"), as answered: asked again it is refused again,
430
+ // so the command's later reads get the same answer without a request. A refusal or a failure is still asked again.
431
+ const missing = new Map<string, unknown>();
407
432
  overrides.getQuote = async (ticker, exchange, context) => {
408
433
  if (!plainContext(context)) return paced(1, () => dataProvider.getQuote(ticker, exchange, context));
409
434
  const key = listingKey(ticker, exchange);
410
- const quote = quotes.get(key) ?? await paced(1, () => dataProvider.getQuote(ticker, exchange, context));
435
+ if (missing.has(key)) {
436
+ const miss = missing.get(key);
437
+ if (miss === NO_QUOTE) return null as unknown as Quote;
438
+ throw miss;
439
+ }
440
+ let quote = quotes.get(key);
441
+ if (!quote) {
442
+ try {
443
+ quote = await paced(1, () => dataProvider.getQuote(ticker, exchange, context));
444
+ } catch (error) {
445
+ if (isNoSourceAnswer(error)) missing.set(key, error);
446
+ throw error;
447
+ }
448
+ // Answered with no quote at all: the same answer next time.
449
+ if (!quote) missing.set(key, NO_QUOTE);
450
+ }
411
451
  if (quote) quotes.set(key, quote);
412
452
  return quote;
413
453
  };
@@ -415,16 +455,25 @@ export function listLookups(dataProvider: DataProvider, { allowances = null }: {
415
455
  overrides.getQuotesBatch = async (targets, options) => {
416
456
  // A batch asked with options of its own (a refresh, deferred follow-ups) is asked as it is.
417
457
  if (options && Object.values(options).some((value) => value != null)) return paced(targets.length, () => dataProvider.getQuotesBatch!(targets, options));
418
- const asked = targets.filter((target) => !quotes.has(listingKey(target.symbol, target.exchange)));
458
+ const asked = targets.filter((target) => !quotes.has(listingKey(target.symbol, target.exchange)) && !missing.has(listingKey(target.symbol, target.exchange)));
419
459
  const answers = asked.length ? await paced(asked.length, () => dataProvider.getQuotesBatch!(asked)) : [];
420
- for (const answer of answers) if (answer.quote) quotes.set(listingKey(answer.target.symbol, answer.target.exchange), answer.quote);
460
+ for (const answer of answers) {
461
+ const key = listingKey(answer.target.symbol, answer.target.exchange);
462
+ if (answer.quote) quotes.set(key, answer.quote);
463
+ // The source asked it alone already and none has it: later reads get that answer, not another request.
464
+ else if (answer.error instanceof Error && isNoSourceAnswer(answer.error)) missing.set(key, answer.error);
465
+ // "Not a ticker: MURATA.", the service's own answer that it lists nothing as the symbol.
466
+ else if (typeof answer.error === "string" && notATickerSymbol(answer.error)) missing.set(key, createProviderMiss(answer.error, undefined, { notFound: true }));
467
+ else if (answer.error == null && !answer.followUp) missing.set(key, NO_QUOTE);
468
+ }
421
469
  const byTarget = new Map(answers.map((answer) => [answer.target, answer] as const));
422
470
  return targets.map((target) => {
423
471
  const answer = byTarget.get(target);
424
472
  if (answer) return answer;
425
473
  const quote = quotes.get(listingKey(target.symbol, target.exchange));
426
- // A source that left a target out answers nothing for it, as it would have alone.
427
- return quote ? { target, quote } : { target, quote: null };
474
+ // A listing already answered with no quote gets that answer; a source that left a target out answers nothing for it.
475
+ const miss = missing.get(listingKey(target.symbol, target.exchange));
476
+ return quote ? { target, quote } : miss && miss !== NO_QUOTE ? { target, quote: null, error: miss } : { target, quote: null };
428
477
  });
429
478
  };
430
479
  }