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
@@ -21,7 +21,8 @@ import {
21
21
  import { t } from "../../../../i18n";
22
22
  import { isQuoteStaleForCurrentSession } from "../../../../market-data/quotes/freshness";
23
23
  import { delistingLabel, delistingStateLabel } from "../../../../market-data/quotes/delisting";
24
- import { formatQuoteNavAsOf } from "../../../../market-data/quotes/time";
24
+ import { formatQuoteNavAsOf, formatQuoteSessionAsOf } from "../../../../market-data/quotes/time";
25
+ import { ClippedText } from "../../../../components/ui/display";
25
26
  import { useQuoteFlashDirection } from "../../../../components/quote-flash";
26
27
  import { followLiveSparklinePrice } from "../../../../components/price-sparkline/model";
27
28
  import {
@@ -62,6 +63,21 @@ function extendedLineParts(
62
63
 
63
64
  const DESKTOP_DETAIL_TEXT_STYLE = { fontSize: "var(--gloom-type-ui)", lineHeight: "14px", whiteSpace: "nowrap" };
64
65
 
66
+ /** The desktop card's muted lines: the name under its symbol, and what the price is as of. */
67
+ /** A line set over the sparkline, backed in the card's colour (the theme's, as drawn) so the line does not run through it. */
68
+ function backedLineStyle() {
69
+ return { alignSelf: "start", maxWidth: "100%", backgroundColor: colors.bg, boxShadow: `0 0 0 2px ${colors.bg}`, paddingRight: 2 };
70
+ }
71
+
72
+ const DESKTOP_META_LINE_STYLE = {
73
+ fontSize: "var(--gloom-type-ui)",
74
+ lineHeight: "14px",
75
+ maxWidth: "100%",
76
+ overflow: "hidden",
77
+ textOverflow: "ellipsis",
78
+ whiteSpace: "nowrap",
79
+ };
80
+
65
81
  function ExtendedSessionLine({
66
82
  parts,
67
83
  color,
@@ -170,6 +186,10 @@ export function QuoteMonitorCard({
170
186
  const quoteStatus = resolveQuoteStatus(quoteEntry, symbol, quote);
171
187
  const quoteFailed = quoteStatus.failed && !!display;
172
188
  const navAsOf = formatQuoteNavAsOf(quote);
189
+ // Each card says what its own price is as of (`CLOSED · 08:09 UTC` beside `15 min delayed · 21:20 UTC`);
190
+ // a fund says its NAV's date instead.
191
+ const sessionAsOf = quoteStatus.ended ? null : formatQuoteSessionAsOf(quote);
192
+ const desktopAsOf = nativePaneChrome ? navAsOf ?? sessionAsOf : null;
173
193
  const changeColor = quoteFailed ? colors.textDim : priceColor(display?.change ?? 0);
174
194
  const flashing = !!flashDirection && !headlineHolds;
175
195
  const currency = quote?.currency || ticker?.metadata.currency || "USD";
@@ -206,8 +226,12 @@ export function QuoteMonitorCard({
206
226
  const trend = quoteTrend(display?.change);
207
227
  const terminalSparklineHeight = !nativePaneChrome && !stacked && height >= 4 ? 2 : 1;
208
228
  const statusRows = (quoteFailed && !compactQuoteFailure ? 1 : 0) + (navAsOf && !compactNavAsOf ? 1 : 0);
229
+ const headerRows = stacked ? 3 : 2;
209
230
  const showTerminalSparkline = (!quoteFailed && !navAsOf)
210
- || height >= (stacked ? 3 : 2) + statusRows + terminalSparklineHeight;
231
+ || height >= headerRows + statusRows + terminalSparklineHeight;
232
+ // The terminal gives the as-of line a row only where the card has one to spare: the sparkline keeps its rows.
233
+ const showTerminalSessionAsOf = !!sessionAsOf
234
+ && height >= headerRows + statusRows + (perpetuals ? 1 : 0) + (showTerminalSparkline ? terminalSparklineHeight : 0) + 1;
211
235
  // Figures sit over the sparkline, so the desktop rings them in the card colour.
212
236
  const figureHalo = { textShadow: `0 1px 2px ${colors.bg}` };
213
237
  // The card's title: a heading over the app's 12px name, under the 20px price.
@@ -272,7 +296,8 @@ export function QuoteMonitorCard({
272
296
  display: "grid",
273
297
  // The name gives way first; the price keeps its natural width.
274
298
  gridTemplateColumns: "minmax(0, 1fr) auto",
275
- gridTemplateRows: "auto 1fr auto auto",
299
+ // The symbol and price, what the price is as of, an extended print, the range, a perpetual.
300
+ gridTemplateRows: "auto auto 1fr auto auto",
276
301
  columnGap: "var(--gloom-space-md)",
277
302
  width: "100%",
278
303
  height: "100%",
@@ -283,7 +308,7 @@ export function QuoteMonitorCard({
283
308
  minWidth={0}
284
309
  style={{
285
310
  gridColumn: "1",
286
- gridRow: extendedParts || endedRow ? "1" : "1 / span 2",
311
+ gridRow: extendedParts || endedRow || desktopAsOf ? "1" : "1 / span 3",
287
312
  minWidth: 0,
288
313
  overflow: "hidden",
289
314
  }}
@@ -297,25 +322,10 @@ export function QuoteMonitorCard({
297
322
  </Text>
298
323
  )}
299
324
  {!quoteFailed && ticker?.metadata.name && (
300
- <Text
301
- fg={colors.textDim}
302
- style={{
303
- fontSize: "var(--gloom-type-ui)",
304
- lineHeight: "14px",
305
- maxWidth: "100%",
306
- overflow: "hidden",
307
- textOverflow: "ellipsis",
308
- whiteSpace: "nowrap",
309
- }}
310
- >
325
+ <Text fg={colors.textDim} style={DESKTOP_META_LINE_STYLE}>
311
326
  {ticker.metadata.name}
312
327
  </Text>
313
328
  )}
314
- {navAsOf && (
315
- <Text fg={colors.textDim} style={{ fontSize: "var(--gloom-type-ui)", lineHeight: "14px" }}>
316
- {navAsOf}
317
- </Text>
318
- )}
319
329
  </Box>
320
330
 
321
331
  <Box
@@ -339,6 +349,16 @@ export function QuoteMonitorCard({
339
349
  </Box>
340
350
  </Box>
341
351
 
352
+ {desktopAsOf && (
353
+ // Across the card under the name and the price, so the time is never cut beside a wide price.
354
+ <Text
355
+ fg={colors.textDim}
356
+ style={{ ...DESKTOP_META_LINE_STYLE, gridColumn: "1 / -1", gridRow: "2", justifySelf: "start", ...backedLineStyle() }}
357
+ >
358
+ {desktopAsOf}
359
+ </Text>
360
+ )}
361
+
342
362
  {endedRow && (
343
363
  // Under the price, across the card, so the date is never cut on a narrow card;
344
364
  // backed like the price so the sparkline does not run through it.
@@ -346,7 +366,7 @@ export function QuoteMonitorCard({
346
366
  fg={colors.warning}
347
367
  style={{
348
368
  gridColumn: "1 / -1",
349
- gridRow: "2",
369
+ gridRow: "3",
350
370
  justifySelf: "start",
351
371
  alignSelf: "start",
352
372
  fontSize: "var(--gloom-type-ui)",
@@ -368,7 +388,7 @@ export function QuoteMonitorCard({
368
388
  dim={extendedDim}
369
389
  desktopStyle={{
370
390
  gridColumn: "1 / -1",
371
- gridRow: "2",
391
+ gridRow: "3",
372
392
  justifySelf: "start",
373
393
  alignSelf: "start",
374
394
  maxWidth: "100%",
@@ -380,13 +400,13 @@ export function QuoteMonitorCard({
380
400
  />
381
401
  )}
382
402
 
383
- {perpetuals && <Box style={{ gridColumn: "1 / -1", gridRow: "4", alignSelf: "end" }}>{perpetuals}</Box>}
403
+ {perpetuals && <Box style={{ gridColumn: "1 / -1", gridRow: "5", alignSelf: "end" }}>{perpetuals}</Box>}
384
404
  {rangeLabel && (
385
405
  <Text
386
406
  fg={colors.textDim}
387
407
  style={{
388
408
  gridColumn: "2",
389
- gridRow: "3",
409
+ gridRow: "4",
390
410
  justifySelf: "end",
391
411
  alignSelf: "end",
392
412
  fontSize: "var(--gloom-type-ui)",
@@ -466,6 +486,9 @@ export function QuoteMonitorCard({
466
486
  {navAsOf && !compactNavAsOf && (
467
487
  <Box height={1} overflow="hidden"><Text fg={colors.textDim}>{navAsOf}</Text></Box>
468
488
  )}
489
+ {showTerminalSessionAsOf && (
490
+ <Box height={1} overflow="hidden"><ClippedText text={sessionAsOf!} width={Math.max(1, width - 2)} fg={colors.textDim} /></Box>
491
+ )}
469
492
  {perpetuals}
470
493
  {showTerminalSparkline && <Box height={terminalSparklineHeight} flexDirection="row" alignItems="center" gap={1}>
471
494
  <PriceSparkline
@@ -0,0 +1,46 @@
1
+ import type { Quote } from "../../../../types/financials";
2
+ import type { HeadlessPaneRow } from "../../../../types/headless";
3
+ import { EXCEL_CSV_BOM } from "../../../../utils/csv";
4
+ import { exportedListingSymbol } from "../../../../portfolio/listed-symbol";
5
+ import type { BrokerNameOf } from "../../../../market-data/quotes/export-identity";
6
+ import { exportRowsTable, renderReportCsv } from "../../../../cli/report-tables";
7
+ import { deriveHeadlessFreshness } from "../../../../cli/pane-functions/freshness";
8
+ import { quoteMonitorColumns, quoteMonitorRow } from "./rows";
9
+
10
+ export interface QuoteMonitorExportEntry {
11
+ /** The symbol as the board shows it (0005.HK). */
12
+ symbol: string;
13
+ /** The listing it was read as, when the board knows its venue. */
14
+ instrument: { symbol: string; exchange?: string } | null;
15
+ quote: Quote | null | undefined;
16
+ }
17
+
18
+ /** A card with no quote: its ticker and why the row is empty, as `fn QQ` names a symbol it found nothing for. */
19
+ function unquotedRow(symbol: string): HeadlessPaneRow {
20
+ return { symbol, name: "", price: null, change: null, changePercent: null, unit: null, updatedAt: null, source: "" };
21
+ }
22
+
23
+ /**
24
+ * The board's Export CSV, the file `fn QQ --csv` writes for the same tickers:
25
+ * each card's listing with its venue (0005:HKEX), name, Last, the change and
26
+ * percent change to the digits the board shows, what the move is from, its
27
+ * session and feed, a yield's move in bp, then its unit, source and the time
28
+ * its own price was observed. The closing source lines are left out, as every
29
+ * pane export leaves them.
30
+ */
31
+ export function quoteMonitorCsv(entries: readonly QuoteMonitorExportEntry[], now = Date.now(), brokerName?: BrokerNameOf): string {
32
+ const rows = entries.map(({ symbol, instrument, quote }) => {
33
+ const listing = instrument ? exportedListingSymbol(instrument.symbol, instrument.exchange, quote?.instrumentType) : symbol;
34
+ return quote ? quoteMonitorRow(listing, quote, now, brokerName) : unquotedRow(listing);
35
+ });
36
+ const table = exportRowsTable("Quote Monitor", quoteMonitorColumns(rows), rows, { status: true, rowUnitKey: "unit" });
37
+ const text = (value: unknown) => typeof value === "string" ? value : null;
38
+ const rowIdentities = rows.map((row) => ({
39
+ symbolOrSeries: text(row.symbol),
40
+ currencyOrUnit: text(row.unit),
41
+ asOf: typeof row.updatedAt === "number" && Number.isFinite(row.updatedAt) ? new Date(row.updatedAt).toISOString() : null,
42
+ source: text(row.source),
43
+ }));
44
+ const freshness = deriveHeadlessFreshness({ shape: "rows", freshness: { datesEachVenue: true } }, { rows }, now);
45
+ return `${EXCEL_CSV_BOM}${renderReportCsv({ tables: [{ ...table, rowIdentities }], footer: [] }, freshness)}`;
46
+ }
@@ -1,7 +1,7 @@
1
1
  import { logFailure } from "../../../../utils/log-failure";
2
2
  import { PerpEquityRow } from "../../perps/equity-row";
3
3
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
4
- import { Box, useUiCapabilities } from "../../../../ui";
4
+ import { Box, useRendererHost, useUiCapabilities } from "../../../../ui";
5
5
  import type { PaneProps } from "../../../../types/plugin";
6
6
  import { TICKER_RESEARCH_PANE_ID } from "../../../../types/config";
7
7
  import type { QuoteSubscriptionTarget } from "../../../../types/data-provider";
@@ -21,6 +21,9 @@ import { useShortcut, type KeyEventLike } from "../../../../react/input";
21
21
  import { isPlainKey } from "../../../../utils/keyboard";
22
22
  import { QuoteMonitorCard } from "./card";
23
23
  import { useLiveStreamingSetting } from "../../../../state/hooks/live-streaming";
24
+ import { registerPaneTableExporter } from "../../../../state/pane-table-export-registry";
25
+ import { quoteMonitorCsv } from "./export";
26
+ import { getSharedRegistry } from "../../../registry";
24
27
 
25
28
  interface BoardEntry {
26
29
  symbol: string;
@@ -176,6 +179,22 @@ export function QuoteMonitorPane({ paneId, focused, width, height }: PaneProps)
176
179
  if (!coordinator || !liveStreaming || boardInstruments.length === 0) return;
177
180
  void coordinator.loadQuotesBatch(boardInstruments).catch(logFailure("ticker-detail.quote-monitor", "Warm quote monitor board failed"));
178
181
  }, [boardInstrumentKey, liveStreaming]);
182
+ // Export CSV writes the board's quotes as `fn QQ --csv` does, each card its own as-of and session.
183
+ const renderer = useRendererHost();
184
+ const exportCsvRef = useRef<() => string>(() => "");
185
+ exportCsvRef.current = () => quoteMonitorCsv(boardEntries.map((entry) => ({
186
+ symbol: entry.symbol,
187
+ instrument: entry.instrument,
188
+ quote: (entry.quoteKey ? resolveEntryData(quoteEntries.get(entry.quoteKey)) : null) ?? financialsBySymbol.get(entry.symbol)?.quote,
189
+ })), Date.now(), (providerId) => getSharedRegistry()?.getBrokerAdapter(providerId)?.name);
190
+ useEffect(() => {
191
+ if (!renderer.saveTextFile) return;
192
+ return registerPaneTableExporter(paneId, (filename) => renderer.saveTextFile!({
193
+ name: filename,
194
+ text: exportCsvRef.current(),
195
+ mimeType: "text/csv;charset=utf-8",
196
+ }));
197
+ }, [paneId, renderer]);
179
198
  const { pinTicker } = usePluginTickerActions();
180
199
  const { openPaneSettings } = usePluginAppActions();
181
200
  const { nativePaneChrome } = useUiCapabilities();
@@ -0,0 +1,120 @@
1
+ import type { Quote } from "../../../../types/financials";
2
+ import type { HeadlessPaneColumn, HeadlessPaneRow } from "../../../../types/headless";
3
+ import { EXTENDED_SESSION_LABELS, getQuoteSessionFields, quoteHeadlineTime, quoteSessionStateLabel, type ExtendedSession } from "../../../../market-data/market/status";
4
+ import { changeBasisLabel, quoteChangeBasis } from "../../../../market-data/market/change-basis";
5
+ import {
6
+ formatMarketChangeWithCurrency, formatMarketPrice, formatMarketPriceWithCurrency, resolveAssetDisplayKind, withCurrencyMinorDigits,
7
+ type MarketFormatOptions,
8
+ } from "../../../../market-data/market/format";
9
+ import { quoteExportFeed, quoteExportUnit, quoteSourceName, type BrokerNameOf } from "../../../../market-data/quotes/export-identity";
10
+ import { isYieldIndexSymbol } from "../../../../tickers/index-roots";
11
+ import { toBasisPoints } from "../../../../utils/basis-points";
12
+ import { formatPercentRaw } from "../../../../utils/format";
13
+ import { parsePublicTickerKey } from "../../../../utils/exchanges";
14
+ import { quoteFreshnessFields } from "../../shared/report-freshness";
15
+
16
+ /**
17
+ * The Quote Monitor's rows as `fn QQ` reports them and the pane's Export CSV
18
+ * writes them: one model, so the board's file and the CLI's agree cell for cell.
19
+ */
20
+
21
+ /** A price or move in the row's own currency, as the cards draw it. */
22
+ function quoteAmount(value: unknown, row: Record<string, unknown>, signed = false): string {
23
+ if (typeof value !== "number" || !Number.isFinite(value)) return "—";
24
+ const currency = typeof row.currency === "string" && row.currency.trim() ? row.currency : undefined;
25
+ const base: MarketFormatOptions = { assetCategory: typeof row.instrumentType === "string" ? row.instrumentType : undefined,
26
+ priceBasis: row.priceBasis === "per-unit" || row.priceBasis === "percent-of-par" ? row.priceBasis : undefined };
27
+ // Par quotes keep two decimals; money pads to its currency's minor unit (none for JPY).
28
+ const options = base.priceBasis === "percent-of-par" ? { ...base, minimumFractionDigits: 2 } : withCurrencyMinorDigits(base, currency);
29
+ // A currency pair's move is written at the pair's precision, as its price is (-$0.00108 on EUR/USD 1.16023).
30
+ if (signed && currency && typeof row.price === "number" && resolveAssetDisplayKind(options) === "cash") {
31
+ return formatMarketChangeWithCurrency(value, currency, options, row.price);
32
+ }
33
+ const amount = currency
34
+ ? formatMarketPriceWithCurrency(value, currency, options)
35
+ : formatMarketPrice(value, options);
36
+ return amount === "—" ? amount : `${signed && value >= 0 ? "+" : ""}${amount}`;
37
+ }
38
+
39
+ function percentCell(value: unknown): string {
40
+ return formatPercentRaw(typeof value === "number" && Number.isFinite(value) ? value : undefined);
41
+ }
42
+
43
+ // Last and Change are in each row's own unit, which an export names in `currency_or_unit` and leaves out of the figures.
44
+ // An export writes the move to the digits the board shows (-315.12, -1.27), and Last whole, as `quote --csv` does
45
+ // (a yield's 4.859, which the board draws 4.86); JSON keeps every figure whole.
46
+ const QUOTE_MONITOR_COLUMNS: HeadlessPaneColumn[] = [
47
+ { key: "symbol", header: "Ticker" },
48
+ { key: "name", header: "Name" },
49
+ { key: "price", header: "Last", align: "right", unitKey: "unit", format: (value, row) => quoteAmount(value, row) },
50
+ { key: "change", header: "Change", align: "right", unitKey: "unit", exportAsShown: true, format: (value, row) => quoteAmount(value, row, true) },
51
+ { key: "changePercent", header: "Change %", align: "right", exportAsShown: true, format: percentCell },
52
+ ];
53
+
54
+ /**
55
+ * What each row's figures are as of, as `quote --csv` says it: the session
56
+ * (CLOSED, REGULAR, PRE-MKT), whether the feed is live, delayed or stale, and
57
+ * what the move is from. A narrow terminal drops them before it cuts a name.
58
+ */
59
+ const QUOTE_MONITOR_SESSION_COLUMNS: HeadlessPaneColumn[] = [
60
+ { key: "changeBasis", header: "Chg Basis", optional: true, dropPriority: 1 },
61
+ { key: "session", header: "Session", optional: true, dropPriority: 3 },
62
+ { key: "feed", header: "Feed", optional: true, dropPriority: 2 },
63
+ ];
64
+
65
+ /** A Cboe yield's move in basis points, the figure its card reads (+2.2bp), as `quote --csv` exports it. */
66
+ const CHANGE_BP_COLUMN: HeadlessPaneColumn = {
67
+ key: "changeBasisPoints", header: "Chg bp", align: "right", optional: true, dropPriority: 0,
68
+ format: (value) => typeof value === "number" && Number.isFinite(value) ? `${value >= 0 ? "+" : ""}${value.toFixed(1)}` : "",
69
+ };
70
+
71
+ /** The pre-market, after-hours or overnight print and its move from the regular close, for the rows that have one. */
72
+ function extendedSessionColumn(session: ExtendedSession): HeadlessPaneColumn {
73
+ return {
74
+ key: "extendedPrice", header: EXTENDED_SESSION_LABELS[session], align: "right",
75
+ format: (value, row) => row.extendedSession === session
76
+ ? `${quoteAmount(value, row)} ${percentCell(row.extendedChangePercent)}`
77
+ : "—",
78
+ };
79
+ }
80
+
81
+ /** Every column a board's rows draw: an extended session's only when a row has its print, Chg bp only beside a yield. */
82
+ export function quoteMonitorColumns(rows: readonly HeadlessPaneRow[]): HeadlessPaneColumn[] {
83
+ const extended = (["PRE", "POST", "OVERNIGHT"] as const)
84
+ .filter((session) => rows.some((row) => row.extendedSession === session))
85
+ .map(extendedSessionColumn);
86
+ const yields = rows.some((row) => row.changeBasisPoints != null);
87
+ return [...QUOTE_MONITOR_COLUMNS, ...extended, ...QUOTE_MONITOR_SESSION_COLUMNS, ...yields ? [CHANGE_BP_COLUMN] : []];
88
+ }
89
+
90
+ /** The columns a board starts with, before its rows say which sessions and yields it holds. */
91
+ export const QUOTE_MONITOR_BASE_COLUMNS: HeadlessPaneColumn[] = [...QUOTE_MONITOR_COLUMNS, ...QUOTE_MONITOR_SESSION_COLUMNS];
92
+
93
+ /** The row fields an export reads each row's identity from: its listing, unit, source and as-of. */
94
+ export const QUOTE_MONITOR_ROW_KEYS = { rowSymbolKey: "symbol", rowUnitKey: "unit", rowAsOfKey: "updatedAt", rowSourceKey: "source" } as const;
95
+
96
+ /**
97
+ * One card as a row: the regular session's Last, change and percent change,
98
+ * any extended print, what the move is from, the session and feed, and each
99
+ * row's own as-of (Hong Kong's close beside New York's), its unit and source.
100
+ * `symbol` is the listing with its venue (0005:HKEX).
101
+ */
102
+ export function quoteMonitorRow(symbol: string, quote: Quote, now = Date.now(), brokerName?: BrokerNameOf): HeadlessPaneRow {
103
+ // As the pane's cards show them: the regular session, then any extended print from its close.
104
+ const { price, change, changePercent, ...extended } = getQuoteSessionFields(quote);
105
+ const basis = quoteChangeBasis(quote);
106
+ const yieldIndex = isYieldIndexSymbol(parsePublicTickerKey(symbol).symbol);
107
+ return {
108
+ symbol, name: quote.name ?? "", price, currency: quote.currency, unit: quoteExportUnit(symbol, quote),
109
+ ...(quote.instrumentType ? { instrumentType: quote.instrumentType } : {}),
110
+ ...(quote.priceBasis ? { priceBasis: quote.priceBasis } : {}),
111
+ change, changePercent, ...extended,
112
+ ...(yieldIndex && change != null && Number.isFinite(change) ? { changeBasisPoints: toBasisPoints(change, 1) } : {}),
113
+ session: quoteSessionStateLabel(quote, now) ?? "",
114
+ feed: quoteExportFeed(quote, now),
115
+ changeBasis: basis ? changeBasisLabel(basis, now) : "",
116
+ source: quoteSourceName(quote, brokerName),
117
+ marketCap: quote.marketCap ?? null, updatedAt: quoteHeadlineTime(quote),
118
+ ...quoteFreshnessFields(quote, now),
119
+ };
120
+ }
@@ -1,14 +1,10 @@
1
- import type { TickerFinancials } from "../../../types/financials";
2
1
  import type { TickerResearchTabDef } from "../../../types/plugin";
3
2
  import { FinancialsResearchTab } from "./financials/pane";
4
3
  import { OverviewResearchTab } from "./overview/pane";
5
4
  import { AdrPairResearchTab } from "./adr-pair/tab";
6
5
  import { ADR_PAIR_TAB_ID } from "./adr-pair/model";
7
6
  import { listingDepositaryPair } from "../../../market-data/depositary-pair";
8
-
9
- function hasStatementFinancials(financials: TickerFinancials | null | undefined): boolean {
10
- return (financials?.annualStatements.length ?? 0) > 0 || (financials?.quarterlyStatements.length ?? 0) > 0;
11
- }
7
+ import { hasStatementFinancials } from "./financials/model";
12
8
 
13
9
  /**
14
10
  * Tabs this module owns. They are registered through `setup()` like any other
@@ -4,7 +4,7 @@ import type { TickerRecord } from "../../../types/ticker";
4
4
  import type { AppConfig } from "../../../types/config";
5
5
  import type { PriceSparklinePeriod } from "../../../components/price-sparkline/view";
6
6
  import { getSharedRegistry } from "../../registry";
7
- import { formatTickerListInput, MAX_TICKER_LIST_SIZE, parseTickerListInput } from "../../../tickers/list";
7
+ import { formatTickerListInput, parseTickerListInput, QUOTE_MONITOR_MAX_TICKERS } from "../../../tickers/list";
8
8
  import { resolveTickerInstrumentKind } from "../../../tickers/instrument-kind";
9
9
  import { groupTickerResearchTabs, type TickerResearchTabSummary } from "./research-groups";
10
10
 
@@ -95,9 +95,9 @@ function coerceQuoteMonitorSymbols(value: unknown): string[] {
95
95
  if (!Array.isArray(value)) return [];
96
96
  const parsed = value.filter((entry): entry is string => typeof entry === "string");
97
97
  try {
98
- return parseTickerListInput(parsed.join(", "), MAX_TICKER_LIST_SIZE);
98
+ return parseTickerListInput(parsed.join(", "), QUOTE_MONITOR_MAX_TICKERS);
99
99
  } catch {
100
- return parsed.slice(0, MAX_TICKER_LIST_SIZE);
100
+ return parsed.slice(0, QUOTE_MONITOR_MAX_TICKERS);
101
101
  }
102
102
  }
103
103
 
@@ -118,7 +118,7 @@ export function getQuoteMonitorPaneSettings(
118
118
 
119
119
  if (symbols.length === 0 && storedText.trim().length > 0) {
120
120
  try {
121
- symbols = parseTickerListInput(storedText, MAX_TICKER_LIST_SIZE);
121
+ symbols = parseTickerListInput(storedText, QUOTE_MONITOR_MAX_TICKERS);
122
122
  } catch {
123
123
  // Intentional ignore: unparseable saved ticker text falls back to the legacy symbol or the pane's ticker.
124
124
  symbols = [];
@@ -126,7 +126,7 @@ export function getQuoteMonitorPaneSettings(
126
126
  }
127
127
  if (symbols.length === 0 && legacySymbol) {
128
128
  try {
129
- symbols = parseTickerListInput(legacySymbol, MAX_TICKER_LIST_SIZE);
129
+ symbols = parseTickerListInput(legacySymbol, QUOTE_MONITOR_MAX_TICKERS);
130
130
  } catch {
131
131
  symbols = [legacySymbol.toUpperCase()];
132
132
  }
@@ -157,7 +157,7 @@ export function buildQuoteMonitorSettingsDef(settings: Record<string, unknown> |
157
157
  {
158
158
  key: "symbolsText",
159
159
  label: "Tickers",
160
- description: `Enter up to ${MAX_TICKER_LIST_SIZE} tickers separated by commas.`,
160
+ description: `Enter up to ${QUOTE_MONITOR_MAX_TICKERS} tickers separated by commas.`,
161
161
  type: "text",
162
162
  placeholder: "AAPL, MSFT, NVDA",
163
163
  },
@@ -1,4 +1,4 @@
1
- import { createPluginCache, savedCopyForTransientFailure } from "../../../data/plugin-cache";
1
+ import { createPluginCache, savedCopyForTransientFailure, type PluginCacheResult } from "../../../data/plugin-cache";
2
2
  import { servedFromSavedCopy } from "../../../data/saved-copies";
3
3
  import type { ConnectionHealthRegistry } from "../../../core/connection-health";
4
4
  import type { PluginPersistence } from "../../../types/plugin";
@@ -6,16 +6,20 @@ import {
6
6
  AUCTION_ARCHIVE_PAGE_SIZE, AUCTION_HISTORY_ALL, AUCTION_HISTORY_DAYS, AUCTION_HISTORY_START, auctionArchiveBoundary,
7
7
  auctionWindowQuery, fetchTreasuryAuctions, type AuctionHistoryWindow, type AuctionQuery,
8
8
  } from "./client";
9
+ import { mergeAuctionSources } from "./model";
10
+ import { DIRECT_LOOKBACK_DAYS, fetchDirectAuctions } from "./treasury-direct";
9
11
  import type { TreasuryAuction } from "./types";
10
12
 
11
13
  const CACHE_KIND = "treasury-auctions";
12
14
  const CACHE_SOURCE = "treasury-fiscal-data";
15
+ const DIRECT_CACHE_SOURCE = "treasury-direct";
13
16
  /**
14
17
  * 3: every reported page was validated before this board was cached.
15
18
  * 4: boards carry direct takedown and bill discount rates, which a v3 board lacks.
16
19
  */
17
20
  const CACHE_SCHEMA_VERSION = 4;
18
21
  export const TREASURY_FISCAL_DATA_CONNECTION_ID = "treasury-fiscal-data";
22
+ export const TREASURY_DIRECT_CONNECTION_ID = "treasury-direct";
19
23
  /**
20
24
  * Refresh the auction board hourly; the week-long expiry keeps an offline
21
25
  * start usable without treating the cached observations as a current fetch.
@@ -53,47 +57,109 @@ const cache = createPluginCache<TreasuryAuction[]>({
53
57
  const archiveCache = createPluginCache<TreasuryAuction[]>({
54
58
  kind: CACHE_KIND, source: CACHE_SOURCE, schemaVersion: CACHE_SCHEMA_VERSION, policy: ARCHIVE_CACHE_POLICY, decode,
55
59
  });
60
+ /** TreasuryDirect's last weeks and announcements, refreshed as often as the board they are merged into. */
61
+ const directCache = createPluginCache<TreasuryAuction[]>({
62
+ kind: CACHE_KIND, source: DIRECT_CACHE_SOURCE, schemaVersion: 1, policy: CACHE_POLICY, decode,
63
+ });
56
64
  let connectionHealth: ConnectionHealthRegistry | null = null;
57
65
 
58
66
  export function attachTreasuryAuctionsPersistence(next: PluginPersistence, health?: ConnectionHealthRegistry): void {
59
67
  cache.attach(next);
60
68
  archiveCache.attach(next);
69
+ directCache.attach(next);
61
70
  connectionHealth = health ?? null;
62
71
  }
63
72
 
64
73
  export function resetTreasuryAuctionsPersistence(): void {
65
74
  cache.reset();
66
75
  archiveCache.reset();
76
+ directCache.reset();
67
77
  connectionHealth = null;
68
78
  }
69
79
 
70
80
  type AuctionLoader = (query: AuctionQuery) => Promise<TreasuryAuction[]>;
81
+ /** The auctions of the last `days` days and the announced ones, from TreasuryDirect. */
82
+ type DirectLoader = (days: number) => Promise<TreasuryAuction[]>;
71
83
 
72
84
  /** One walk, reported through Connections; an empty one is invalid and must never replace the last good board. */
73
- function walk(loader: AuctionLoader, query: () => AuctionQuery) {
85
+ function walk(source: { id: string; name: string }, load: () => Promise<TreasuryAuction[]>) {
74
86
  return async () => {
75
- const request = () => loader(query());
76
- const auctions = await (connectionHealth?.hasSource(TREASURY_FISCAL_DATA_CONNECTION_ID)
77
- ? connectionHealth.track(TREASURY_FISCAL_DATA_CONNECTION_ID, "fetchAuctions", request)
78
- : request());
79
- if (auctions.length === 0) throw new Error("Treasury Fiscal Data returned no auctions");
87
+ const auctions = await (connectionHealth?.hasSource(source.id)
88
+ ? connectionHealth.track(source.id, "fetchAuctions", load)
89
+ : load());
90
+ if (auctions.length === 0) throw new Error(`${source.name} returned no auctions`);
80
91
  return auctions;
81
92
  };
82
93
  }
83
94
 
95
+ const FISCAL_DATA = { id: TREASURY_FISCAL_DATA_CONNECTION_ID, name: "Treasury Fiscal Data" };
96
+ const TREASURY_DIRECT = { id: TREASURY_DIRECT_CONNECTION_ID, name: "TreasuryDirect" };
97
+
98
+ /** One source's answer, or why it gave none: the other source's board stands in for it. */
99
+ type Answer = { read: PluginCacheResult<TreasuryAuction[]> } | { failed: unknown };
100
+
101
+ async function answer(read: Promise<PluginCacheResult<TreasuryAuction[]>>): Promise<Answer> {
102
+ try {
103
+ return { read: savedCopyForTransientFailure(await read) };
104
+ } catch (failed) {
105
+ return { failed };
106
+ }
107
+ }
108
+
109
+ const failureMessage = (failed: unknown) => failed instanceof Error ? failed.message : String(failed);
110
+
111
+ /**
112
+ * The recent auctions from both sources: Fiscal Data's walk of `fiscalKey`
113
+ * and TreasuryDirect's last weeks and announcements, each cached and refreshed
114
+ * on its own, then merged (`mergeAuctionSources`). One source that gives
115
+ * nothing, for lack of an answer and a saved copy or for a refusal, leaves the
116
+ * board to the other and says so as a refresh error; both failing is Fiscal
117
+ * Data's failure, as before TreasuryDirect was read. With no `direct` loader
118
+ * (a test's stand-in for the whole board) only the first is read.
119
+ */
120
+ async function loadRecentBoard(
121
+ force: boolean,
122
+ fiscalKey: string,
123
+ fiscal: () => Promise<TreasuryAuction[]>,
124
+ direct: { days: number; load: DirectLoader } | null,
125
+ from: () => string,
126
+ ): Promise<TreasuryAuctionsResult> {
127
+ const [primary, supplement] = await Promise.all([
128
+ answer(cache.load(fiscalKey, walk(FISCAL_DATA, fiscal), { force })),
129
+ direct ? answer(directCache.load(`direct:${direct.days}`, walk(TREASURY_DIRECT, () => direct.load(direct.days)), { force })) : null,
130
+ ]);
131
+ if ("failed" in primary && (!supplement || "failed" in supplement)) throw primary.failed;
132
+
133
+ const answers = [primary, supplement].filter((entry): entry is { read: PluginCacheResult<TreasuryAuction[]> } => !!entry && "read" in entry);
134
+ const failed = [primary, supplement].find((entry): entry is { failed: unknown } => !!entry && "failed" in entry);
135
+ const saved = answers.filter(({ read }) => read.source === "stale-fallback");
136
+ const refreshError = answers.find(({ read }) => read.refreshError)?.read.refreshError ?? (failed ? failureMessage(failed.failed) : undefined);
137
+ return {
138
+ auctions: mergeAuctionSources("read" in primary ? primary.read.data : [], supplement && "read" in supplement ? supplement.read.data : [], from()),
139
+ // The oldest part: how old what is shown can be.
140
+ fetchedAt: Math.min(...answers.map(({ read }) => read.fetchedAt)),
141
+ stale: !!failed || answers.some(({ read }) => read.stale),
142
+ ...(saved.length ? { savedAt: Math.min(...saved.map(({ read }) => read.fetchedAt)) } : {}),
143
+ ...(refreshError ? { refreshError } : {}),
144
+ };
145
+ }
146
+
84
147
  export async function loadTreasuryAuctions(
85
148
  force = false,
86
149
  loader: AuctionLoader = fetchTreasuryAuctions,
87
150
  window: AuctionHistoryWindow = AUCTION_HISTORY_DAYS,
151
+ // A loader of the caller's own stands for the whole board.
152
+ direct: DirectLoader | null = loader === fetchTreasuryAuctions ? fetchDirectAuctions : null,
88
153
  ): Promise<TreasuryAuctionsResult> {
89
- if (window === AUCTION_HISTORY_ALL) return loadAllTreasuryAuctions(force, loader);
154
+ if (window === AUCTION_HISTORY_ALL) return loadAllTreasuryAuctions(force, loader, direct);
90
155
  // A saved board answers only for a failure asking again may get past; a refusal or an invalid page is the error.
91
- const result = savedCopyForTransientFailure(await cache.load(`recent:${window}`, walk(loader, () => auctionWindowQuery(window)), { force }));
92
- return answered({
93
- auctions: result.data, fetchedAt: result.fetchedAt, stale: result.stale,
94
- ...(result.source === "stale-fallback" ? { savedAt: result.fetchedAt } : {}),
95
- ...(result.refreshError ? { refreshError: result.refreshError } : {}),
96
- });
156
+ return answered(await loadRecentBoard(
157
+ force,
158
+ `recent:${window}`,
159
+ () => loader(auctionWindowQuery(window)),
160
+ direct && { days: Math.min(window, DIRECT_LOOKBACK_DAYS), load: direct },
161
+ () => auctionWindowQuery(window).from,
162
+ ));
97
163
  }
98
164
 
99
165
  /** A board a saved copy answered: marked as one, so a command ends by saying when it was saved, not with its failure. */
@@ -107,18 +173,18 @@ function answered(result: TreasuryAuctionsResult): TreasuryAuctionsResult {
107
173
  * a refresh only refetches what can still change. Both must load; a board
108
174
  * missing its archive would pass for the full history.
109
175
  */
110
- async function loadAllTreasuryAuctions(force: boolean, loader: AuctionLoader): Promise<TreasuryAuctionsResult> {
176
+ async function loadAllTreasuryAuctions(force: boolean, loader: AuctionLoader, direct: DirectLoader | null): Promise<TreasuryAuctionsResult> {
111
177
  const boundary = auctionArchiveBoundary();
112
178
  const [recent, archive] = await Promise.all([
113
- cache.load(`since:${boundary}`, walk(loader, () => ({ from: boundary })), { force }).then(savedCopyForTransientFailure),
114
- archiveCache.load(`archive:${boundary}`, walk(loader, () => ({
179
+ loadRecentBoard(force, `since:${boundary}`, () => loader({ from: boundary }), direct && { days: DIRECT_LOOKBACK_DAYS, load: direct }, () => boundary),
180
+ archiveCache.load(`archive:${boundary}`, walk(FISCAL_DATA, () => loader({
115
181
  from: AUCTION_HISTORY_START, before: boundary, pageSize: AUCTION_ARCHIVE_PAGE_SIZE,
116
182
  }))).then(savedCopyForTransientFailure),
117
183
  ]);
118
184
  const seen = new Set<string>();
119
- const auctions = [...recent.data, ...archive.data].filter((auction) => !seen.has(auction.id) && Boolean(seen.add(auction.id)));
185
+ const auctions = [...recent.auctions, ...archive.data].filter((auction) => !seen.has(auction.id) && Boolean(seen.add(auction.id)));
120
186
  const refreshError = recent.refreshError ?? archive.refreshError;
121
- const savedAt = Math.min(...[recent, archive].map((part) => part.source === "stale-fallback" ? part.fetchedAt : Infinity));
187
+ const savedAt = Math.min(recent.savedAt ?? Infinity, archive.source === "stale-fallback" ? archive.fetchedAt : Infinity);
122
188
  return answered({
123
189
  auctions, fetchedAt: recent.fetchedAt, stale: recent.stale || archive.stale,
124
190
  ...(Number.isFinite(savedAt) ? { savedAt } : {}),