gloomberb 0.20.0 → 0.20.2

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 (481) hide show
  1. package/README.md +16 -26
  2. package/README.zh-CN.md +21 -65
  3. package/package.json +1 -1
  4. package/patches/electrobun-devkit@2.0.5.patch +268 -8
  5. package/src/account/auth-model.ts +20 -1
  6. package/src/account/upgrade-dialog.tsx +8 -4
  7. package/src/api-client/askg.ts +7 -1
  8. package/src/api-client/auth.ts +27 -0
  9. package/src/api-client/catalysts.ts +2 -0
  10. package/src/api-client/company-kpis.ts +2 -1
  11. package/src/api-client/cot.ts +14 -2
  12. package/src/api-client/crypto-markets.ts +20 -2
  13. package/src/api-client/data.ts +3 -2
  14. package/src/api-client/earnings.ts +46 -3
  15. package/src/api-client/fund-facts.ts +23 -1
  16. package/src/api-client/futures-curve.ts +17 -0
  17. package/src/api-client/index.ts +4 -1
  18. package/src/api-client/one-tap-reasons.ts +42 -0
  19. package/src/api-client/perps.ts +2 -1
  20. package/src/api-client/request.ts +3 -1
  21. package/src/api-client/research-activity.ts +16 -3
  22. package/src/api-client/types/filings-and-calls.ts +9 -0
  23. package/src/api-client/types/search.ts +3 -0
  24. package/src/app/keybindings/chord.ts +153 -9
  25. package/src/app/keybindings/index.ts +1 -1
  26. package/src/app/keybindings/labels.ts +49 -6
  27. package/src/app/runtime/desktop-deeplink.ts +73 -8
  28. package/src/app/runtime/plugin-seed.ts +119 -0
  29. package/src/app/runtime/startup.ts +45 -9
  30. package/src/app.tsx +8 -1
  31. package/src/architecture/core-builtin-allowlist.json +1 -2
  32. package/src/architecture/pane-tabs-allowlist.json +2 -1
  33. package/src/architecture/shortcut-labels-allowlist.json +11 -0
  34. package/src/architecture/ui-literals-allowlist.json +8 -8
  35. package/src/brokers/broker-portfolio-sync.ts +1 -1
  36. package/src/cli/bank-section.ts +26 -12
  37. package/src/cli/board-coins.ts +38 -5
  38. package/src/cli/commands/crypto-hints.ts +8 -1
  39. package/src/cli/commands/market.ts +294 -100
  40. package/src/cli/commands/overview.ts +13 -6
  41. package/src/cli/commands/ticker.ts +73 -21
  42. package/src/cli/company-name-hint.ts +19 -0
  43. package/src/cli/desktop-pane-shot-browser.ts +47 -31
  44. package/src/cli/desktop-pane-shot.ts +15 -0
  45. package/src/cli/entry.ts +15 -4
  46. package/src/cli/export-source.ts +7 -1
  47. package/src/cli/freshness.ts +0 -16
  48. package/src/cli/fx-pair.ts +64 -12
  49. package/src/cli/fx-quote-rate.ts +144 -0
  50. package/src/cli/glossary.ts +30 -0
  51. package/src/cli/helpers.ts +4 -2
  52. package/src/cli/history-back-adjust.ts +122 -0
  53. package/src/cli/history-rows.ts +114 -10
  54. package/src/cli/index.ts +4 -1
  55. package/src/cli/known-gaps.ts +45 -3
  56. package/src/cli/listing-arg.ts +48 -4
  57. package/src/cli/name-entries.ts +25 -5
  58. package/src/cli/not-a-ticker.ts +26 -1
  59. package/src/cli/pane-functions/catalog.ts +12 -2
  60. package/src/cli/pane-functions/dom.ts +4 -2
  61. package/src/cli/pane-functions/freshness.ts +45 -29
  62. package/src/cli/pane-functions/headless.ts +8 -5
  63. package/src/cli/pane-functions/index.ts +3 -0
  64. package/src/cli/pane-functions/market-session.ts +14 -5
  65. package/src/cli/pane-functions/resolver.ts +4 -1
  66. package/src/cli/pane-functions/screenshot-assessment.ts +15 -3
  67. package/src/cli/pane-functions/screenshot-payload.ts +130 -66
  68. package/src/cli/pane-functions/screenshot-render.ts +14 -2
  69. package/src/cli/pane-functions/screenshot-types.ts +4 -0
  70. package/src/cli/restore-plugins.ts +164 -51
  71. package/src/cli/symbol-rows.ts +22 -2
  72. package/src/cli/ticker-resolution.ts +74 -17
  73. package/src/components/chart/composite/axis-overlays.tsx +13 -3
  74. package/src/components/chart/composite/composite-chart.tsx +8 -1
  75. package/src/components/chart/composite/format.ts +16 -1
  76. package/src/components/chart/composite/legend.tsx +4 -3
  77. package/src/components/chart/composite/panel-labels.ts +2 -1
  78. package/src/components/chart/composite/panel-surface.tsx +33 -4
  79. package/src/components/chart/composite/time-scale.ts +1 -1
  80. package/src/components/chart/composite/toolbar.tsx +8 -4
  81. package/src/components/chart/composite/types.ts +17 -1
  82. package/src/components/chart/composite/use-composite-chart-keyboard.ts +15 -5
  83. package/src/components/chart/composite/use-composite-viewport.ts +31 -8
  84. package/src/components/chart/static/scatter-chart-surface.tsx +25 -9
  85. package/src/components/chart-table/axis.ts +11 -0
  86. package/src/components/chart-table/header.tsx +10 -1
  87. package/src/components/chart-table/layout.ts +14 -5
  88. package/src/components/command-bar/assist/inventory.ts +3 -2
  89. package/src/components/command-bar/commands/collection-list.ts +3 -2
  90. package/src/components/command-bar/panel/index.tsx +13 -0
  91. package/src/components/command-bar/panel/layout.ts +15 -1
  92. package/src/components/command-bar/panel/prompt-width.ts +34 -0
  93. package/src/components/command-bar/panel/runtime.ts +1 -0
  94. package/src/components/command-bar/panel/state.ts +4 -0
  95. package/src/components/command-bar/panel/types.ts +2 -0
  96. package/src/components/command-bar/routes/root/search-providers.ts +3 -2
  97. package/src/components/command-bar/routes/root/search-report.ts +2 -2
  98. package/src/components/command-bar/workflow/ticker-listing-picker.ts +1 -0
  99. package/src/components/company-logo.tsx +2 -2
  100. package/src/components/data-table/view.tsx +11 -2
  101. package/src/components/feed-data-table/stack-view.tsx +20 -6
  102. package/src/components/feedback-dialog.tsx +3 -1
  103. package/src/components/form-modal/field-row.tsx +1 -1
  104. package/src/components/form-modal/routes.ts +1 -0
  105. package/src/components/index.ts +1 -1
  106. package/src/components/layout/header.tsx +12 -3
  107. package/src/components/layout/market-summary.ts +2 -1
  108. package/src/components/layout/pane/footer/index.tsx +9 -5
  109. package/src/components/layout/pane/footer/model.ts +26 -10
  110. package/src/components/layout/pane/footer/registration.tsx +60 -1
  111. package/src/components/layout/pane/header-tabs.tsx +17 -3
  112. package/src/components/layout/pane/header.tsx +5 -2
  113. package/src/components/layout/pane/pane-tabs.tsx +57 -3
  114. package/src/components/layout/shell/active-drag.ts +38 -30
  115. package/src/components/layout/shell/drag/index.ts +51 -21
  116. package/src/components/layout/shell/menu.ts +3 -5
  117. package/src/components/layout/shell/pane/actions.ts +4 -1
  118. package/src/components/layout/shell/pane/ask.ts +5 -2
  119. package/src/components/layout/status-bar.tsx +59 -54
  120. package/src/components/markdown-text.tsx +35 -10
  121. package/src/components/onboarding/first-run-workspace.ts +25 -23
  122. package/src/components/onboarding/onboarding-keyboard.ts +6 -1
  123. package/src/components/onboarding/onboarding-wizard.tsx +12 -2
  124. package/src/components/onboarding/portfolio-step/positions-panel.tsx +3 -3
  125. package/src/components/onboarding/use-onboarding-broker-form.ts +2 -1
  126. package/src/components/onboarding/use-onboarding-progress.ts +11 -4
  127. package/src/components/onboarding/use-onboarding-upgrade.ts +3 -2
  128. package/src/components/onboarding/wizard-positions.ts +8 -1
  129. package/src/components/pane-notice-seen.ts +125 -0
  130. package/src/components/pane-settings-dialog/field-dialogs.tsx +2 -1
  131. package/src/components/pane-settings-dialog.tsx +7 -6
  132. package/src/components/sign-in-code-panel.tsx +3 -2
  133. package/src/components/speedometer-gauge/terminal.tsx +30 -9
  134. package/src/components/ticker/list-table-view.tsx +39 -3
  135. package/src/components/ui/confirm-dialog.tsx +2 -1
  136. package/src/components/ui/data-table/index.tsx +4 -2
  137. package/src/components/ui/data-table/opentui/index.tsx +15 -5
  138. package/src/components/ui/data-table/types.ts +8 -0
  139. package/src/components/ui/external-link.tsx +4 -1
  140. package/src/components/ui/field-grid.tsx +1 -1
  141. package/src/components/ui/index.ts +2 -0
  142. package/src/components/ui/inline-quick-add.tsx +5 -0
  143. package/src/components/ui/multi-select/dialog.tsx +10 -9
  144. package/src/components/ui/pane-link-chip.tsx +354 -0
  145. package/src/components/ui/query-bar.tsx +22 -13
  146. package/src/components/ui/ratio-bar.tsx +24 -1
  147. package/src/components/ui/select-button.tsx +2 -1
  148. package/src/components/ui/shortcut-hint.tsx +6 -3
  149. package/src/components/ui/table-layout.ts +81 -0
  150. package/src/components/ui/tabs.tsx +45 -6
  151. package/src/components/use-pane-notice-footer.tsx +12 -4
  152. package/src/core/app-service-ports.ts +1 -1
  153. package/src/data/plugin-state-store.ts +44 -8
  154. package/src/docs/snapshot.json +53 -32
  155. package/src/i18n/es.ts +28 -6
  156. package/src/i18n/ja.ts +28 -5
  157. package/src/i18n/ko.ts +28 -5
  158. package/src/i18n/zh-cn.ts +28 -5
  159. package/src/i18n/zh-tw.ts +28 -5
  160. package/src/layout/pane-manager/gridlock-inference.ts +2 -1
  161. package/src/layout/pane-manager/gridlock.ts +47 -2
  162. package/src/layout-marketplace/api.ts +1 -0
  163. package/src/layout-marketplace/gallery.tsx +4 -3
  164. package/src/layout-marketplace/linked.ts +6 -4
  165. package/src/layout-marketplace/model.ts +3 -2
  166. package/src/market-data/fund-facts.ts +7 -1
  167. package/src/market-data/futures-contract.ts +77 -31
  168. package/src/market-data/fx-closes.ts +5 -2
  169. package/src/market-data/hooks.tsx +23 -0
  170. package/src/market-data/market/change-basis.ts +92 -14
  171. package/src/market-data/market/format.ts +81 -13
  172. package/src/market-data/market/futures-week.ts +3 -1
  173. package/src/market-data/market/globex-day.ts +73 -0
  174. package/src/market-data/market/index-level.ts +10 -1
  175. package/src/market-data/quotes/intraday-bar.ts +1 -1
  176. package/src/market-data/quotes/session-split.ts +28 -0
  177. package/src/plugins/builtin/account-management/pane.tsx +1 -1
  178. package/src/plugins/builtin/analytics/account-returns.ts +1 -1
  179. package/src/plugins/builtin/analytics/index.tsx +10 -3
  180. package/src/plugins/builtin/analytics/pane-model.ts +1 -1
  181. package/src/plugins/builtin/analytics/risk-client.ts +4 -1
  182. package/src/plugins/builtin/analytics/risk-episodes.ts +422 -0
  183. package/src/plugins/builtin/analytics/risk-fx.ts +1 -1
  184. package/src/plugins/builtin/analytics/risk-headless.ts +28 -10
  185. package/src/plugins/builtin/analytics/risk-math.ts +1 -1
  186. package/src/plugins/builtin/analytics/risk-model.ts +115 -26
  187. package/src/plugins/builtin/analytics/risk-pane.tsx +201 -23
  188. package/src/plugins/builtin/analytics/sharpe-cadence.ts +1 -1
  189. package/src/plugins/builtin/backtest/format.ts +14 -0
  190. package/src/plugins/builtin/backtest/pane.tsx +3 -3
  191. package/src/plugins/builtin/backtest/report.ts +5 -3
  192. package/src/plugins/builtin/broker-manager/add-request.ts +10 -1
  193. package/src/plugins/builtin/broker-trading/pane.tsx +20 -2
  194. package/src/plugins/builtin/buildout/company/flow.tsx +5 -5
  195. package/src/plugins/builtin/buildout/company/model.ts +14 -2
  196. package/src/plugins/builtin/catalysts/detail.tsx +2 -2
  197. package/src/plugins/builtin/catalysts/model.ts +7 -2
  198. package/src/plugins/builtin/catalysts/pane.tsx +2 -2
  199. package/src/plugins/builtin/chart-composer/headless.ts +57 -17
  200. package/src/plugins/builtin/chart-composer/session-range.ts +82 -3
  201. package/src/plugins/builtin/chat/message/pane-chip.tsx +36 -208
  202. package/src/plugins/builtin/cloud/askg/answer-follow-ups.tsx +61 -0
  203. package/src/plugins/builtin/cloud/askg/answer-sources.tsx +102 -0
  204. package/src/plugins/builtin/cloud/askg/controller.ts +7 -1
  205. package/src/plugins/builtin/cloud/askg/host.ts +57 -0
  206. package/src/plugins/builtin/cloud/askg/model.ts +45 -5
  207. package/src/plugins/builtin/cloud/askg/pane.tsx +304 -25
  208. package/src/plugins/builtin/cloud/askg/protocol.ts +26 -1
  209. package/src/plugins/builtin/cloud/askg/sources.ts +466 -0
  210. package/src/plugins/builtin/cloud/one-tap/controller.ts +309 -0
  211. package/src/plugins/builtin/cloud/one-tap/google-identity.ts +142 -0
  212. package/src/plugins/builtin/cloud/one-tap/one-tap-prompt.tsx +101 -0
  213. package/src/plugins/builtin/cloud/plugin.tsx +7 -1
  214. package/src/plugins/builtin/company-kpis/client.ts +4 -3
  215. package/src/plugins/builtin/company-kpis/model.ts +34 -3
  216. package/src/plugins/builtin/correlation/compute.ts +8 -2
  217. package/src/plugins/builtin/correlation/headless.ts +10 -9
  218. package/src/plugins/builtin/correlation/history.ts +30 -0
  219. package/src/plugins/builtin/correlation/index.tsx +39 -167
  220. package/src/plugins/builtin/correlation/matrix/grid.tsx +285 -0
  221. package/src/plugins/builtin/correlation/matrix/model.ts +10 -10
  222. package/src/plugins/builtin/correlation/relationship/model.ts +3 -6
  223. package/src/plugins/builtin/correlation/relationship/pane.tsx +7 -9
  224. package/src/plugins/builtin/correlation/relationship/view-model.ts +14 -5
  225. package/src/plugins/builtin/cot/client.ts +8 -3
  226. package/src/plugins/builtin/cot/headless.ts +65 -12
  227. package/src/plugins/builtin/cot/pane.tsx +11 -5
  228. package/src/plugins/builtin/crypto-board/client.ts +6 -1
  229. package/src/plugins/builtin/crypto-board/defi-view.tsx +12 -1
  230. package/src/plugins/builtin/crypto-board/defi.ts +44 -7
  231. package/src/plugins/builtin/crypto-board/headless.ts +83 -12
  232. package/src/plugins/builtin/crypto-board/model.ts +30 -6
  233. package/src/plugins/builtin/crypto-board/pane.tsx +13 -2
  234. package/src/plugins/builtin/earnings/client.ts +40 -6
  235. package/src/plugins/builtin/earnings/fiscal-quarter.ts +54 -0
  236. package/src/plugins/builtin/earnings/headless.ts +47 -11
  237. package/src/plugins/builtin/earnings/history-model.ts +136 -24
  238. package/src/plugins/builtin/earnings/history-table.ts +42 -10
  239. package/src/plugins/builtin/earnings/history.tsx +23 -8
  240. package/src/plugins/builtin/earnings-ripple/client.ts +5 -2
  241. package/src/plugins/builtin/earnings-ripple/headless.ts +8 -3
  242. package/src/plugins/builtin/earnings-ripple/model.ts +21 -0
  243. package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -3
  244. package/src/plugins/builtin/econ/index.tsx +5 -4
  245. package/src/plugins/builtin/econ-statistics/stats.ts +13 -5
  246. package/src/plugins/builtin/equity-screener/headless.ts +2 -1
  247. package/src/plugins/builtin/filing-events/feed.ts +56 -18
  248. package/src/plugins/builtin/filing-events/pane.tsx +8 -2
  249. package/src/plugins/builtin/futures/index.tsx +32 -10
  250. package/src/plugins/builtin/futures/model.ts +93 -6
  251. package/src/plugins/builtin/futures/returns.ts +29 -7
  252. package/src/plugins/builtin/futures/table.tsx +59 -17
  253. package/src/plugins/builtin/futures/use-front-returns.ts +32 -6
  254. package/src/plugins/builtin/futures-curve/client.ts +12 -2
  255. package/src/plugins/builtin/futures-curve/headless.ts +58 -17
  256. package/src/plugins/builtin/futures-curve/model.ts +111 -15
  257. package/src/plugins/builtin/futures-curve/pane.tsx +11 -6
  258. package/src/plugins/builtin/fx-matrix/amount.ts +132 -0
  259. package/src/plugins/builtin/fx-matrix/headless.ts +53 -13
  260. package/src/plugins/builtin/fx-matrix/index.tsx +205 -42
  261. package/src/plugins/builtin/fx-matrix/pairs.ts +10 -8
  262. package/src/plugins/builtin/fx-matrix/settings.ts +22 -1
  263. package/src/plugins/builtin/help/index.tsx +68 -61
  264. package/src/plugins/builtin/holders/format.ts +7 -2
  265. package/src/plugins/builtin/holders/pane.tsx +11 -3
  266. package/src/plugins/builtin/holders/report-header.ts +5 -4
  267. package/src/plugins/builtin/holders/report-rows.ts +4 -1
  268. package/src/plugins/builtin/holders/treemap.tsx +5 -3
  269. package/src/plugins/builtin/insider/signals-model.ts +4 -5
  270. package/src/plugins/builtin/ipo-calendar/headless.ts +18 -7
  271. package/src/plugins/builtin/ipo-calendar/listing-ipo.ts +3 -1
  272. package/src/plugins/builtin/ipo-calendar/model.ts +28 -8
  273. package/src/plugins/builtin/ipo-calendar/pane.tsx +2 -1
  274. package/src/plugins/builtin/kelly-sizer/headless.ts +4 -0
  275. package/src/plugins/builtin/perps/headless.ts +81 -19
  276. package/src/plugins/builtin/perps/index.tsx +3 -1
  277. package/src/plugins/builtin/perps/model.ts +1 -1
  278. package/src/plugins/builtin/perps/pane.tsx +2 -0
  279. package/src/plugins/builtin/portfolio-list/cell-version.ts +1 -0
  280. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +20 -1
  281. package/src/plugins/builtin/portfolio-list/cli/import-positions.ts +260 -0
  282. package/src/plugins/builtin/portfolio-list/cli/period-report.ts +154 -0
  283. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +64 -22
  284. package/src/plugins/builtin/portfolio-list/cli/render.ts +18 -7
  285. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -3
  286. package/src/plugins/builtin/portfolio-list/grid.tsx +56 -12
  287. package/src/plugins/builtin/portfolio-list/headless.ts +128 -0
  288. package/src/plugins/builtin/portfolio-list/pane/index.tsx +42 -4
  289. package/src/plugins/builtin/portfolio-list/pane/period-pnl.ts +124 -0
  290. package/src/plugins/builtin/portfolio-list/period-pnl.ts +179 -0
  291. package/src/plugins/builtin/portfolio-list/positions-import/dialog.tsx +445 -0
  292. package/src/plugins/builtin/portfolio-list/positions-import/index.tsx +255 -0
  293. package/src/plugins/builtin/portfolio-list/positions-import/lookup.ts +78 -0
  294. package/src/plugins/builtin/portfolio-list/positions-import/read-file.ts +32 -0
  295. package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +186 -50
  296. package/src/plugins/builtin/portfolio-list/quick-add/resolution.ts +118 -4
  297. package/src/plugins/builtin/portfolio-list/settings.ts +25 -0
  298. package/src/plugins/builtin/portfolio-list/summary/index.tsx +16 -1
  299. package/src/plugins/builtin/portfolio-list/summary/totals.ts +7 -5
  300. package/src/plugins/builtin/portfolio-list/table.tsx +105 -6
  301. package/src/plugins/builtin/power/headless.ts +47 -9
  302. package/src/plugins/builtin/research/relative-valuation-model.ts +8 -3
  303. package/src/plugins/builtin/research-search/article.ts +12 -2
  304. package/src/plugins/builtin/research-search/data.ts +5 -2
  305. package/src/plugins/builtin/research-search/document-view.tsx +1 -1
  306. package/src/plugins/builtin/research-search/model.ts +47 -3
  307. package/src/plugins/builtin/research-search/pane.tsx +3 -2
  308. package/src/plugins/builtin/reverse-dcf/model.ts +7 -4
  309. package/src/plugins/builtin/risk-factors/headless.ts +3 -2
  310. package/src/plugins/builtin/risk-factors/index.tsx +2 -28
  311. package/src/plugins/builtin/risk-factors/lock-note.ts +58 -0
  312. package/src/plugins/builtin/risk-factors/pane.tsx +14 -5
  313. package/src/plugins/builtin/scanner/flow-model.ts +17 -13
  314. package/src/plugins/builtin/scanner/flow-pane.tsx +8 -9
  315. package/src/plugins/builtin/scanner/flow-session.ts +2 -9
  316. package/src/plugins/builtin/scanner/hilo-model.ts +4 -3
  317. package/src/plugins/builtin/sec/filing-display.tsx +0 -5
  318. package/src/plugins/builtin/sec/forms.ts +19 -0
  319. package/src/plugins/builtin/sec/fund-facts.ts +45 -11
  320. package/src/plugins/builtin/sec/headless.ts +37 -12
  321. package/src/plugins/builtin/sec/index.tsx +37 -8
  322. package/src/plugins/builtin/shared/earnings-calendar.ts +6 -3
  323. package/src/plugins/builtin/shared/earnings-report.ts +1 -1
  324. package/src/plugins/builtin/shared/fx-rate-freshness.ts +0 -35
  325. package/src/plugins/builtin/shared/pro-lock-note.ts +5 -1
  326. package/src/plugins/builtin/shared/use-quote-board.ts +42 -27
  327. package/src/plugins/builtin/supply-chain/graph-model.ts +7 -1
  328. package/src/plugins/builtin/supply-chain/headless.ts +20 -10
  329. package/src/plugins/builtin/supply-chain/model.ts +117 -20
  330. package/src/plugins/builtin/supply-chain/pane.tsx +22 -15
  331. package/src/plugins/builtin/supply-chain/row-evidence.tsx +1 -1
  332. package/src/plugins/builtin/ticker-detail/data-panes/returns-chart-model.ts +69 -0
  333. package/src/plugins/builtin/ticker-detail/data-panes/returns-chart.tsx +118 -0
  334. package/src/plugins/builtin/ticker-detail/data-panes/returns-model.ts +1 -1
  335. package/src/plugins/builtin/ticker-detail/data-panes/returns-pane.tsx +103 -40
  336. package/src/plugins/builtin/ticker-detail/headless-schema.ts +10 -1
  337. package/src/plugins/builtin/ticker-detail/headless.ts +8 -1
  338. package/src/plugins/builtin/ticker-detail/overview/components.tsx +2 -1
  339. package/src/plugins/builtin/ticker-detail/overview/model.ts +18 -8
  340. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +11 -8
  341. package/src/plugins/builtin/ticker-detail/pane.tsx +95 -20
  342. package/src/plugins/builtin/ticker-detail/research-groups.ts +89 -0
  343. package/src/plugins/builtin/ticker-detail/settings.ts +4 -3
  344. package/src/plugins/builtin/time-sales/headless.ts +23 -7
  345. package/src/plugins/builtin/time-sales/index.tsx +2 -2
  346. package/src/plugins/builtin/volatility/charts.tsx +2 -2
  347. package/src/plugins/extracted-plugins.ts +49 -24
  348. package/src/plugins/host-resolver.ts +3 -2
  349. package/src/plugins/installer.ts +220 -31
  350. package/src/plugins/running-installs.ts +34 -0
  351. package/src/plugins/seed-progress.ts +72 -0
  352. package/src/portfolio/column-values.ts +42 -8
  353. package/src/portfolio/futures-positions.ts +10 -2
  354. package/src/portfolio/mutations.ts +4 -3
  355. package/src/portfolio/period-pnl.ts +119 -0
  356. package/src/portfolio/positions-import/describe.ts +89 -0
  357. package/src/portfolio/positions-import/parse.ts +682 -0
  358. package/src/portfolio/positions-import/plan.ts +295 -0
  359. package/src/{plugins/builtin/analytics/metrics.ts → portfolio/return-metrics.ts} +24 -11
  360. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  361. package/src/react/jsx-dev-fallback.ts +62 -0
  362. package/src/renderers/browser/cloud-transport.ts +1 -1
  363. package/src/renderers/browser/config-host.ts +3 -1
  364. package/src/renderers/browser/deeplink-bridge.ts +8 -1
  365. package/src/renderers/browser/http-proxy-transport.ts +9 -2
  366. package/src/renderers/browser/main.tsx +2 -1
  367. package/src/renderers/browser/research-entry.ts +12 -0
  368. package/src/renderers/cloudflare/http-proxy.ts +8 -2
  369. package/src/renderers/cloudflare/proxy-session.ts +1 -0
  370. package/src/renderers/cloudflare/worker.ts +12 -3
  371. package/src/renderers/dom/desktop/audio-player.tsx +2 -2
  372. package/src/renderers/dom/desktop/controls.tsx +1 -1
  373. package/src/renderers/dom/desktop/dialog-actions.tsx +10 -24
  374. package/src/renderers/dom/desktop/icons.tsx +4 -2
  375. package/src/renderers/dom/desktop/query-bar.tsx +23 -19
  376. package/src/renderers/dom/dom-host-providers.tsx +7 -2
  377. package/src/renderers/dom/host/box.tsx +2 -2
  378. package/src/renderers/dom/host/input.tsx +13 -0
  379. package/src/renderers/dom/key-event.ts +1 -0
  380. package/src/renderers/dom/styles.css +3 -0
  381. package/src/renderers/electrobun/bun/context-menu/click.ts +1 -0
  382. package/src/renderers/electrobun/bun/desktop/backend.ts +15 -0
  383. package/src/renderers/electrobun/bun/desktop/capability-bridge.ts +5 -4
  384. package/src/renderers/electrobun/bun/desktop/host-requests.ts +19 -11
  385. package/src/renderers/electrobun/bun/desktop/http-fetch.ts +1 -0
  386. package/src/renderers/electrobun/bun/desktop/http-stream.ts +1 -1
  387. package/src/renderers/electrobun/bun/desktop/initialization.ts +27 -15
  388. package/src/renderers/electrobun/bun/desktop/install-records.ts +4 -1
  389. package/src/renderers/electrobun/bun/desktop/installer-folder.ts +5 -2
  390. package/src/renderers/electrobun/bun/desktop/macos-objc.ts +3 -1
  391. package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +9 -4
  392. package/src/renderers/electrobun/bun/desktop/update.ts +27 -13
  393. package/src/renderers/electrobun/bun/desktop/windows-script.ts +6 -2
  394. package/src/renderers/electrobun/bun/index.ts +5 -0
  395. package/src/renderers/electrobun/bun/window/attention.ts +1 -0
  396. package/src/renderers/electrobun/bun/window/boot-frame.ts +1 -0
  397. package/src/renderers/electrobun/bun/window/context-menu-thread.ts +84 -0
  398. package/src/renderers/electrobun/bun/window/create.ts +1 -0
  399. package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +13 -8
  400. package/src/renderers/electrobun/bun/window/native-call-thread.ts +224 -0
  401. package/src/renderers/electrobun/bun/window/native-min-size.ts +1 -1
  402. package/src/renderers/electrobun/bun/window/native-timing.ts +10 -0
  403. package/src/renderers/electrobun/bun/window/remembered-frame.ts +1 -0
  404. package/src/renderers/electrobun/bun/window/script-for-webview.ts +15 -0
  405. package/src/renderers/electrobun/bun/window/webview-script-thread.ts +82 -0
  406. package/src/renderers/electrobun/bun/window/windows-native.ts +3 -1
  407. package/src/renderers/electrobun/bun/window/windows-quit.ts +3 -1
  408. package/src/renderers/electrobun/shared/protocol.ts +13 -2
  409. package/src/renderers/electrobun/view/app-badge-host.ts +2 -1
  410. package/src/renderers/electrobun/view/backend-rpc.ts +7 -0
  411. package/src/renderers/electrobun/view/capability-subscription.ts +2 -1
  412. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +7 -10
  413. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +1 -1
  414. package/src/renderers/electrobun/view/cli-pane-shot-mutations.ts +36 -0
  415. package/src/renderers/electrobun/view/http-fetch.ts +2 -1
  416. package/src/renderers/electrobun/view/main.tsx +13 -7
  417. package/src/renderers/electrobun/view/remote/capability-invoker.ts +6 -3
  418. package/src/renderers/electrobun/view/remote/persistence.ts +63 -27
  419. package/src/renderers/electrobun/view/rpc-timeout.ts +1 -0
  420. package/src/renderers/electrobun/view/ui-host.tsx +3 -2
  421. package/src/renderers/electrobun/view/window-fullscreen.ts +3 -1
  422. package/src/renderers/opentui/browser-open.ts +2 -1
  423. package/src/renderers/opentui/dialog-host.tsx +1 -1
  424. package/src/renderers/opentui/interaction-performance.ts +3 -1
  425. package/src/renderers/opentui/start.tsx +5 -1
  426. package/src/renderers/opentui/terminal-media.ts +11 -6
  427. package/src/renderers/opentui/ui-host.tsx +5 -8
  428. package/src/shares/open.ts +22 -1
  429. package/src/shares/pane.ts +2 -1
  430. package/src/sources/gloomberb-cloud/normalizers.ts +3 -0
  431. package/src/sync/analytics-payload.ts +194 -0
  432. package/src/sync/baseline.ts +19 -9
  433. package/src/sync/broker-identity.ts +171 -0
  434. package/src/sync/broker-instances.ts +137 -0
  435. package/src/sync/collections-contributor.ts +173 -0
  436. package/src/sync/config-contributor.ts +100 -0
  437. package/src/sync/config-merge.ts +229 -0
  438. package/src/sync/controller.ts +139 -28
  439. package/src/sync/core-contributors.ts +8 -1583
  440. package/src/sync/history-memo.ts +32 -0
  441. package/src/sync/layout-merge.ts +259 -0
  442. package/src/sync/sanitize.ts +114 -0
  443. package/src/sync/ticker-merge.ts +208 -0
  444. package/src/sync/ticker-payload.ts +81 -0
  445. package/src/sync/types.ts +15 -1
  446. package/src/telemetry/attention-setting.ts +1 -1
  447. package/src/telemetry/stall-reports.ts +21 -4
  448. package/src/telemetry/usage-counts.ts +16 -0
  449. package/src/test-support/preload.ts +5 -0
  450. package/src/theme/color-utils.ts +10 -0
  451. package/src/theme/font-scale.ts +34 -3
  452. package/src/theme/series-colors.ts +44 -0
  453. package/src/theme/themes.ts +2 -1
  454. package/src/tickers/batched-lookups.ts +263 -6
  455. package/src/tickers/company-name-listing.ts +44 -2
  456. package/src/tickers/company-name.ts +7 -2
  457. package/src/tickers/search/upsert.ts +16 -1
  458. package/src/time-series/base-series.ts +18 -4
  459. package/src/time-series/studies/indicators.ts +3 -1
  460. package/src/time-series/studies/resolve.ts +1 -1
  461. package/src/time-series/types.ts +6 -0
  462. package/src/types/financials.ts +18 -0
  463. package/src/types/headless.ts +11 -0
  464. package/src/ui/host.tsx +26 -3
  465. package/src/ui/index.tsx +1 -0
  466. package/src/utils/concurrency.ts +6 -0
  467. package/src/utils/currency-pair.ts +56 -4
  468. package/src/utils/datetime-format.ts +11 -0
  469. package/src/utils/decimal-comma.ts +9 -6
  470. package/src/utils/exchanges.ts +32 -0
  471. package/src/utils/fundamentals.ts +41 -0
  472. package/src/utils/main-thread-stall.ts +21 -5
  473. package/src/utils/markdown.ts +4 -2
  474. package/src/utils/pasted-lines.ts +14 -0
  475. package/src/utils/perf-marks.ts +88 -9
  476. package/src/utils/price-window.ts +2 -1
  477. package/src/utils/reported-money.ts +9 -2
  478. package/src/utils/sec-filings.ts +17 -0
  479. package/src/utils/sec.ts +37 -25
  480. package/src/utils/shortcut-labels.ts +6 -30
  481. package/src/plugins/seed-notice.ts +0 -20
@@ -1,9 +1,10 @@
1
1
  import { logFailure } from "../../utils/log-failure";
2
+ import { normalizeTickerSymbol } from "../../tickers/search/ranking";
2
3
  import type { CliCommandDef } from "../../types/plugin";
3
4
  import { TIME_RANGES, type TimeRange } from "../../time-series/range";
4
5
  import { CHART_RESOLUTION_STEP_MS } from "../../time-series/resolution";
5
6
  import { yearToDateStartIndex } from "../../market-data/market/year-to-date";
6
- import type { EarningsEvent, QuoteBatchResult, QuoteSubscriptionTarget, SecFilingItem } from "../../types/data-provider";
7
+ import type { EarningsEvent, MarketDataRequestContext, QuoteBatchResult, QuoteSubscriptionTarget, SecFilingItem } from "../../types/data-provider";
7
8
  import { companyDataNotes, type CompanyFrom } from "../../types/company-from";
8
9
  import type { NewsArticle, NewsFeed, NewsQuery } from "../../news/types";
9
10
  import { newsSummaryLine } from "../../news/news-model";
@@ -13,12 +14,13 @@ import type {
13
14
  CorporateActionsData,
14
15
  HolderData,
15
16
  OptionsChain,
17
+ PricePoint,
16
18
  Quote,
17
19
  TickerFinancials,
18
20
  } from "../../types/financials";
19
- import { currencyPriceMinDigits, formatMarketPrice, formatMarketPriceWithCurrency, penceFigure, quoteFormatOptions, resolveAssetDisplayKind, withCurrencyMinorDigits } from "../../market-data/market/format";
21
+ import { currencyPriceMinDigits, formatMarketPrice, formatMarketPriceWithCurrency, nearParCoinPriceDigits, penceFigure, quoteFormatOptions, withCurrencyMinorDigits } from "../../market-data/market/format";
20
22
  import { INDEX_POINTS_EXPORT_UNIT, isIndexLevel, reportedQuoteVolume } from "../../market-data/market/index-level";
21
- import { changeBasisJson, changeBasisLabel, changeBasisNote, quoteChangeBasis, quotePreviousCloseDate, quoteSettleText } from "../../market-data/market/change-basis";
23
+ import { changeBasisJson, changeBasisLabel, changeBasisNote, futuresQuoteFromSettle, printPredatesChangeBasis, quoteChangeBasis, quotePreviousCloseDate, quoteSettleText } from "../../market-data/market/change-basis";
22
24
  import {
23
25
  EXTENDED_SESSION_LABELS,
24
26
  getExtendedSessionDisplay,
@@ -73,7 +75,7 @@ import { latestFinancialPeriod } from "../../utils/latest-financial-period";
73
75
  import type { FuturesContractTermsPayload } from "../../api-client/futures-curve";
74
76
  import { currencyCodeLabel } from "../../utils/currency-units";
75
77
  import {
76
- futuresContractLines, futuresPricePer, futuresRollLines, isFuturesInstrument, loadUsdPerMmbtu, usdPerMmbtuText, type UsdPerMmbtu,
78
+ futuresContractLines, futuresPricePer, futuresRollLines, isFuturesInstrument, loadFuturesPriceUnit, loadUsdPerMmbtu, usdPerMmbtuText, type UsdPerMmbtu,
77
79
  } from "../../market-data/futures-contract";
78
80
  import {
79
81
  chainHasExpiry,
@@ -125,6 +127,8 @@ import {
125
127
  type CliReportTables,
126
128
  } from "../report-tables";
127
129
  import { historyCoverageNotice } from "../../sources/history-coverage";
130
+ import { fetchHistoryResult } from "../../sources/history-result";
131
+ import { settleWithin } from "../../utils/async-deadline";
128
132
  import { maxDrawdownText } from "../../utils/max-drawdown";
129
133
  import { isPastPriceWindow, loadPriceWindowHistory, PRICE_WINDOW_FROM_HELP, PRICE_WINDOW_TO_HELP, priceWindowText, readPriceWindow, type PriceWindow } from "../../utils/price-window";
130
134
  import {
@@ -144,6 +148,7 @@ import {
144
148
  historyGapNote,
145
149
  historyJumpNote,
146
150
  historyUnbrokenFrom,
151
+ dailyRebuildSpans,
147
152
  historyAllRangeYears,
148
153
  historyIntervalsByRange,
149
154
  historyMissingVolumeNote,
@@ -151,16 +156,20 @@ import {
151
156
  historyNotes,
152
157
  historyReportsVolume,
153
158
  historyPriceDecimals,
159
+ historyRolls,
154
160
  historyRows,
155
161
  historyUnit,
156
162
  quotedPriceDivisor,
163
+ withDailyRebuiltBars,
157
164
  historyVolume,
158
165
  historyVolumeBasis,
159
166
  historyVolumeNote,
167
+ type HistoryRoll,
160
168
  type HistoryRow,
161
169
  type HistoryUnit,
162
170
  type HistoryVolume,
163
171
  } from "../history-rows";
172
+ import { backAdjustHistory, contractCloses, stitchedRollsNote, type BackAdjustMethod, type StitchedRoll } from "../history-back-adjust";
164
173
  import {
165
174
  historyExportColumns,
166
175
  historyExportStatus,
@@ -170,7 +179,7 @@ import {
170
179
  type HistoryListRow,
171
180
  } from "../history-export";
172
181
  import { fail, isCliFailure, NO_DATA_CODE } from "../errors";
173
- import { mapWithConcurrency } from "../../utils/concurrency";
182
+ import { createConcurrencyLimiter, mapWithConcurrency } from "../../utils/concurrency";
174
183
  import { MISSING_VOLUME_TEXT } from "../../utils/price-history-integrity";
175
184
  import { CRYPTO_BOARD_HINT, quoteNotes } from "./crypto-hints";
176
185
  import { bareFuturesCode, futuresBoardContract } from "../../market-data/futures-board";
@@ -196,12 +205,13 @@ import {
196
205
  searchNewsStories,
197
206
  wordMeansMore,
198
207
  } from "./news-search";
199
- import { formatUtcTime } from "../../utils/utc-time";
208
+ import { formatUtcDayTime, formatUtcTime } from "../../utils/utc-time";
200
209
  import { DAY_SO_FAR_TEXT, withSessionBar } from "../../time-series/session-bar";
201
210
  import { isFiniteNumber } from "../../utils/guards";
202
211
  import { exportedFundamentals } from "../../utils/price-earnings";
203
- import { fundamentalsFreshness, fxPairFreshness, quotesFreshness, rowsFreshness, valuationFreshness } from "../freshness";
204
- import { fxRateNotes, refreshedFxRateNotes } from "../../plugins/builtin/shared/fx-rate-freshness";
212
+ import { withBankEnterpriseValue } from "../../utils/fundamentals";
213
+ import { fundamentalsFreshness, quotesFreshness, rowsFreshness, valuationFreshness } from "../freshness";
214
+ import { fxPairListing, fxQuoteRateObservation, readFxQuoteRate } from "../fx-quote-rate";
205
215
  import { quoteBarNotes } from "../../market-data/quotes/intraday-bar";
206
216
  import { cedearRatioText, depositaryPairText, isReceiptSide, listingCedearRatio, listingDepositaryPair } from "../../market-data/depositary-pair";
207
217
  import { isPesoDollarPair, loadPesoDollarRates, pesoDollarRateLines, pesoDollarRatesJson } from "../peso-dollar-rates";
@@ -258,7 +268,8 @@ import {
258
268
  type ListingIdentity,
259
269
  } from "../listing-arg";
260
270
  import { currencyNameMiss, currencyNameStop } from "../currency-name-hint";
261
- import { bareListingNote, listingFateNotes, loadNoQuoteLastTraded, noLongerTradingNote, noQuoteLastTraded, noQuoteLastTradeNote, SUCCESSOR_CHANGE_WAIT_MS, tradingListing, usVenueOf } from "../../tickers/listing-fate";
271
+ import { liveCompanyQuestion } from "../company-name-hint";
272
+ import { bareListingNote, listingFateNotes, loadNoQuoteLastTraded, noLongerTradingNote, noQuoteLastTraded, noQuoteLastTradeNote, SUCCESSOR_CHANGE_WAIT_MS, tradingListing, usVenueOf, type NoQuoteLastTrade } from "../../tickers/listing-fate";
262
273
  import { isYieldIndexSymbol } from "../../tickers/index-roots";
263
274
  import {
264
275
  analyzeTaxEquivalent, distributionBasis, loadTreasuryTenors, parseTaxRates, TAX_RATE_HELP_OPTIONS, taxEquivalentJson, type TaxRates,
@@ -290,7 +301,7 @@ import { noSecReportsNotice, nonUsSecListingVenue, secFilingItemCodes } from "..
290
301
  import type { MarketContext } from "../types";
291
302
  import { windowRows } from "../row-window";
292
303
  import { answerQuote, errorMessage, notUsTickerSentence } from "../quote-answer";
293
- import { crossRate, describeFxConversion, describeFxRate, formatFxRate, FX_USAGE, isUsableRate, parseFxArgs } from "../fx-pair";
304
+ import { crossRate, describeFxConversion, describeFxLegs, describeFxRate, formatFxRate, FX_USAGE, parseFxArgs, type FxQuotedFigure } from "../fx-pair";
294
305
  import {
295
306
  describeShortRate,
296
307
  formatForwardPoints,
@@ -336,8 +347,8 @@ import {
336
347
  loadIndexedHolders,
337
348
  withIndexedHolders,
338
349
  } from "../../plugins/builtin/holders/index-holders";
339
- import { filingFormMatches, SEC_FILING_FETCH_LIMIT } from "../../plugins/builtin/sec/forms";
340
- import { currentReportItemsLabel } from "../../utils/sec-filings";
350
+ import { loadShownSecFilings } from "../../plugins/builtin/sec/forms";
351
+ import { currentReportItemsLabel, hiddenFilingsMetadata, hiddenFilingsNote, type HiddenFilings } from "../../utils/sec-filings";
341
352
  import { INSIDER_REPORT_FILINGS, loadParsedInsiderFilings } from "../../plugins/builtin/insider/client";
342
353
  import { insiderEmptyNotice, loadHomeInsiderReportsNote } from "../../plugins/builtin/insider/issuer";
343
354
  import { buildInsiderSummary } from "../../plugins/builtin/insider/model";
@@ -509,6 +520,8 @@ const QUOTE_LEAD_COLUMNS = [
509
520
  header: "Chg%",
510
521
  align: "right" as const,
511
522
  format: (value: unknown, row: QuoteRow) => {
523
+ // A print older than what the move is from has no move as of now.
524
+ if (row.predatesChangeBasis) return "—";
512
525
  const move = row.yieldIndex ? yieldChangeCell(row) : formatChangePercentCell(value);
513
526
  // Keep a rolling move's short label with the value when narrow tables drop Chg Basis.
514
527
  return move && row.changeBasis === "24h" ? `${move} ${cliStyles.muted("24h")}` : move;
@@ -519,7 +532,8 @@ const QUOTE_LEAD_COLUMNS = [
519
532
  extendedColumn("POST"),
520
533
  extendedColumn("OVERNIGHT"),
521
534
  // An export keeps the market state (PRE-MKT); the table names the close a pre-market with no trade stands at (Thu close).
522
- { key: "session", header: "Session", shrink: false, format: (_value: unknown, row: QuoteRow) => row.sessionLabel },
535
+ // A print older than its move's basis has no session of its own either.
536
+ { key: "session", header: "Session", shrink: false, format: (_value: unknown, row: QuoteRow) => row.predatesChangeBasis ? "—" : row.sessionLabel },
523
537
  ];
524
538
 
525
539
  type QuoteRow = ReturnType<typeof quoteRows>[number];
@@ -617,6 +631,7 @@ function pairExportUnit(symbol: string, currency: string): string | null {
617
631
 
618
632
  function quoteExportStatus(row: QuoteRow): string {
619
633
  if (row.rawPrice == null || !Number.isFinite(row.rawPrice)) return row.error || "Last: no price";
634
+ if (row.predatesChangeBasis) return row.predatesChangeBasis;
620
635
  if (row.changePercent == null || !Number.isFinite(row.changePercent)) return "Chg%: no previous close";
621
636
  return "";
622
637
  }
@@ -697,21 +712,6 @@ function quoteFeedState(quote: QuoteCliRecord["quote"], now: number): "stale" |
697
712
  return quote.dataSource === "live" || quote.dataSource === "delayed" ? quote.dataSource : "";
698
713
  }
699
714
 
700
- /** A hundredth of a cent, one basis point of a dollar peg: the decimals CRYP prints a stablecoin to. */
701
- const STABLECOIN_PRICE_DIGITS = 4;
702
-
703
- /**
704
- * A coin trading near a dollar, a dollar stablecoin, prints to four decimals
705
- * either side of par (0.9987, 1.0003), as CRYP does, whatever digits its
706
- * source sent (0.99874, 0.99968725); below a dollar a coin otherwise keeps up to eight.
707
- */
708
- function nearParCoin(quote: QuoteCliRecord["quote"]): boolean {
709
- if (!quote || resolveAssetDisplayKind({ assetCategory: quote.instrumentType }) !== "crypto") return false;
710
- if ((quote.currency ?? "USD").trim().toUpperCase() !== "USD") return false;
711
- const reference = [quote.previousClose, quote.price].find((value) => typeof value === "number" && Number.isFinite(value) && value > 0);
712
- return reference != null && reference >= 0.9 && reference < 1.1;
713
- }
714
-
715
715
  /** What a row's move is measured from, worded as its Chg Basis cell: empty without a move. */
716
716
  function rowChangeBasis(result: Pick<QuoteCliRecord, "quote" | "futuresContract">) {
717
717
  return quoteChangeBasis(result.quote, { terms: result.futuresContract });
@@ -749,6 +749,10 @@ function quoteSessionFields(quote: Quote | null | undefined) {
749
749
  function quoteRows(results: QuoteCliRecord[], now = Date.now()) {
750
750
  return results.map((result) => {
751
751
  const quote = result.quote;
752
+ // A print older than what its move is from (a coin's last trade before 00:00 UTC) has no move as of now,
753
+ // and the session the market is in is not its own: both read "—", and the Feed cell says it is stale.
754
+ const basis = rowChangeBasis(result);
755
+ const predates = printPredatesChangeBasis(quote, basis, now);
752
756
  // Last and Chg% are the regular session, as `ticker` and the quote monitor read it; a
753
757
  // pre-market or after-hours print is its own column, measured from that session's close.
754
758
  const display = quoteSessionFields(quote);
@@ -758,10 +762,12 @@ function quoteRows(results: QuoteCliRecord[], now = Date.now()) {
758
762
  const indexPoints = isIndexLevel(quote?.instrumentType);
759
763
  // Pad to two decimals so a column lines up, but never past the currency's minor unit (JPY has none).
760
764
  // Points have no minor unit, so a yen-listed index still pads to two.
765
+ const nearParDigits = nearParCoinPriceDigits(quote);
761
766
  const options = {
762
767
  ...quoteFormatOptions(quote),
763
768
  minimumFractionDigits: indexPoints ? 2 : currencyPriceMinDigits(quote?.currency),
764
- ...nearParCoin(quote) ? { fixedFractionDigits: STABLECOIN_PRICE_DIGITS } : {},
769
+ // A coin near a dollar prints to four decimals, as `ticker`, `G` and CRYP print it.
770
+ ...nearParDigits != null ? { fixedFractionDigits: nearParDigits } : {},
765
771
  };
766
772
  const price = (value: number | null | undefined) => (
767
773
  quote && value != null
@@ -780,8 +786,10 @@ function quoteRows(results: QuoteCliRecord[], now = Date.now()) {
780
786
  rawPrice: display.price,
781
787
  priceBasis: quote?.priceBasis ?? null,
782
788
  instrumentType: quote?.instrumentType ?? null,
783
- change: display.change,
784
- changePercent: roundedPercent(display.changePercent ?? undefined),
789
+ change: predates ? null : display.change,
790
+ changePercent: predates ? null : roundedPercent(display.changePercent ?? undefined),
791
+ // Why Chg% is empty when it is for that reason, for an export's status column.
792
+ predatesChangeBasis: !predates ? "" : basis?.kind === "24h" ? "Chg%: last print over 24h old" : "Chg%: last print before 00:00 UTC",
785
793
  // A Cboe yield index is read as a yield in percent and moves in basis points.
786
794
  yieldIndex,
787
795
  changeBasisPoints: yieldIndex && display.change != null ? toBasisPoints(display.change, 1) : null,
@@ -792,8 +800,8 @@ function quoteRows(results: QuoteCliRecord[], now = Date.now()) {
792
800
  extendedChangePercent: roundedPercent(extended?.changePercent),
793
801
  // The extended price is the session's bid and ask midpoint, nothing having traded in it.
794
802
  extendedMark: extended?.mark === true,
795
- session: quoteSessionStateLabel(quote, now) ?? "",
796
- sessionLabel: quoteSessionLabel(quote, now) ?? "",
803
+ session: predates ? "" : quoteSessionStateLabel(quote, now) ?? "",
804
+ sessionLabel: predates ? "" : quoteSessionLabel(quote, now) ?? "",
797
805
  // The close the shown move is measured from: the one before the session Last is.
798
806
  previousClose: price(previousClose),
799
807
  rawPreviousClose: previousClose ?? null,
@@ -812,7 +820,7 @@ function quoteRows(results: QuoteCliRecord[], now = Date.now()) {
812
820
  updatedAt: quote?.lastUpdated ? new Date(quoteHeadlineTime(quote)).toISOString() : "",
813
821
  error: result.error ?? "",
814
822
  // Last, so a row read by position keeps every field where it was.
815
- changeBasis: basisLabel(result, now),
823
+ changeBasis: predates ? "" : basisLabel(result, now),
816
824
  changeBasisNote: changeBasisNote(rowChangeBasis(result), now) ?? "",
817
825
  };
818
826
  });
@@ -1097,10 +1105,16 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
1097
1105
  const formerIssuers = symbolChanges.map(({ formerIssuer }) => formerIssuer);
1098
1106
  // A symbol with no quote whose bars stopped over a month ago says when it last traded, in place of why no quote
1099
1107
  // came: no longer listed on the service's record (FLAT, a retired ETN), else no trades since. Each costs a history
1100
- // read, so a long list says only why.
1101
- const lastTraded = await Promise.all(answers.map(({ result, listing }) => !result.quote && !isNetworkFailure(result.error)
1102
- && answers.length <= MAX_CHOICE_LOOKUPS ? loadNoQuoteLastTraded(listing.request, market.dataProvider, now) : null));
1108
+ // read, so a long list says only why. A quote the service did not answer is asked after too: a dead listing's
1109
+ // quote can fail where its history still says when it stopped (FRC), and an unreachable service fails it at once.
1110
+ const lastTraded = await Promise.all(answers.map(async ({ result, listing }) => !result.quote && answers.length <= MAX_CHOICE_LOOKUPS
1111
+ ? await loadNoQuoteLastTraded(listing.request, market.dataProvider, now) ?? await searchedDelisting(listing, market)
1112
+ : null));
1103
1113
  const endedNotes = answers.map(({ listing }, index) => lastTraded[index] ? `${noQuoteLastTradeNote(listing.symbol, lastTraded[index]!)}.` : null);
1114
+ // A bare symbol whose listing stopped asks after the company by that name that still trades (DBS: D05 on SGX).
1115
+ const liveCompanies = await Promise.all(answers.map(({ result, listing }) => result.quote && !listing.exchange
1116
+ && answers.length <= MAX_CHOICE_LOOKUPS && noLongerTradingNote(listing.symbol, result.quote, now)
1117
+ ? liveCompanyQuestion(listing.typed ?? listing.symbol, market, now) : null));
1104
1118
  if (symbols.length === 1 && endedNotes[0]) ctx.fail(endedNotes[0], quoteChangeLine(tickerChanges[0], formerIssuers[0]) || undefined);
1105
1119
  const failed = answers[0]?.failure;
1106
1120
  if (symbols.length === 1 && failed) {
@@ -1110,6 +1124,14 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
1110
1124
  const contracts = await Promise.all(answers.map(({ result }) => commandName === "quote" && result.quote
1111
1125
  ? cliFuturesContract(result.quote.symbol || result.target.symbol, result.quote.instrumentType)
1112
1126
  : null));
1127
+ // A future's move the source measured from something other than the session before's settlement of the same contract is measured from it, in the row and in every line.
1128
+ const sourceMoves = answers.map((answer, index) => {
1129
+ const sent = answer.result.quote;
1130
+ const quote = futuresQuoteFromSettle(sent, contracts[index]);
1131
+ if (!sent || quote === sent) return null;
1132
+ answers[index] = { ...answer, result: { ...answer.result, quote } };
1133
+ return { change: sent.change, changePercent: sent.changePercent, previousClose: sent.previousClose };
1134
+ });
1113
1135
  // A contract that is not its root's front (NGF27, NG2) prints the front's own price beside it, read in one batch.
1114
1136
  const fronts = await loadFuturesFrontQuotes(contracts, market.dataProvider);
1115
1137
  // A per-MWh gas price (TTF) adds its dollars per MMBtu at the day's rate, to read beside Henry Hub.
@@ -1128,11 +1150,12 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
1128
1150
  const data = answers.map(({ result, listing, failure }, index) => ({
1129
1151
  target: result.target,
1130
1152
  listing: listingMetadata(listingIdentity(listing, result.quote)),
1131
- // The figures the table shows, beside the quote as the source sent it.
1153
+ // The figures the table shows, beside the quote they come from: a future's move as the table measures it, and the source's own beside it when that differs.
1132
1154
  ...quoteSessionFields(result.quote),
1133
1155
  // What `change` is measured from, with the label and holiday note the table shows.
1134
1156
  changeBasis: changeBasisJson(quoteChangeBasis(result.quote, { terms: contracts[index] }), now),
1135
1157
  quote: withPreviousCloseDate(result.quote),
1158
+ ...sourceMoves[index] ? { sourceMove: sourceMoves[index] } : {},
1136
1159
  ...contracts[index] ? { futuresContract: contracts[index] } : {},
1137
1160
  ...fronts[index] ? { futuresFront: fronts[index] } : {},
1138
1161
  ...gasInUsd[index] ? { usdPerMmbtu: gasInUsd[index] } : {},
@@ -1157,10 +1180,11 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
1157
1180
  ...answers.flatMap((answer) => answer.notes),
1158
1181
  // A row that stopped trading long ago reads as a quote that is merely stale, and one with
1159
1182
  // nothing printed in a session the calendar has open (a feed that stalled, a typhoon day) says since when.
1160
- ...data.flatMap((row) => {
1183
+ ...data.flatMap((row, index) => {
1161
1184
  if (!row.quote) return [];
1162
1185
  const label = `${row.target.symbol}${row.listing.name ? ` (${row.listing.name})` : ""}`;
1163
- const ended = noLongerTradingNote(label, row.quote, now);
1186
+ const stopped = noLongerTradingNote(label, row.quote, now);
1187
+ const ended = stopped && liveCompanies[index] ? `${stopped}. ${liveCompanies[index]}` : stopped;
1164
1188
  const quiet = ended ? null : noPrintsTodayText(row.quote, now);
1165
1189
  return [ended ?? (quiet ? `${label}: ${quiet}` : []), quoteBarNotes(label, row.quote, now)].flat();
1166
1190
  }),
@@ -1424,6 +1448,43 @@ function historyCommand({ range, window }: HistoryAsk): string {
1424
1448
  return window ? `history --from ${window.from}${isPastPriceWindow(window) ? ` --to ${window.to}` : ""}` : range === "1Y" ? "history" : `history --range ${range}`;
1425
1449
  }
1426
1450
 
1451
+ /** How long `history` waits for a future's contract terms to name its unit before using the catalog's. */
1452
+ const HISTORY_PRICE_UNIT_WAIT_MS = 1_500;
1453
+
1454
+ /** How long `history` waits for the daily bars that rebuild contradictory monthly bars before printing them with blanks. */
1455
+ const MONTHLY_REBUILD_WAIT_MS = 8_000;
1456
+ /** Reads of daily bars in flight at once to rebuild them. */
1457
+ const MONTHLY_REBUILD_CONCURRENCY = 3;
1458
+
1459
+ /**
1460
+ * Monthly bars whose prices contradict each other, rebuilt from the daily
1461
+ * bars of the months they span (dailyRebuildSpans, withDailyRebuiltBars),
1462
+ * each day the one `venue` trades it on. Any other history, and months
1463
+ * whose daily bars fail or do not answer in time, come back as they are.
1464
+ */
1465
+ async function withMonthlyBarsRebuilt(
1466
+ rows: HistoryRow[], market: MarketContext, symbol: string, exchange: string,
1467
+ context: MarketDataRequestContext, priceDivisor: number, venue: string,
1468
+ ): Promise<HistoryRow[]> {
1469
+ const flagged = rows.filter((row) => row.interval === "1mo" && row.close != null && row.open == null && row.flag
1470
+ && row.flag.split(",").some((code) => /^(high<|low>)/.test(code)));
1471
+ if (flagged.length === 0) return rows;
1472
+ // Neighbouring months share a read, a few reads at a time; what has come by the deadline is used, and no read starts after it.
1473
+ const spans = dailyRebuildSpans(flagged.map((row) => row.date.slice(0, 7)));
1474
+ const points: PricePoint[] = [];
1475
+ let reading = true;
1476
+ await settleWithin(mapWithConcurrency(spans, MONTHLY_REBUILD_CONCURRENCY, async ({ from, to }) => {
1477
+ if (!reading) return;
1478
+ const start = new Date(`${from}-01T00:00:00Z`);
1479
+ const end = new Date(Date.UTC(Number(to.slice(0, 4)), Number(to.slice(5, 7)), 0, 23, 59, 59));
1480
+ const result = await fetchHistoryResult(market.dataProvider, symbol, exchange, { kind: "detail", start, end, interval: "1d" }, context)
1481
+ .catch(logFailure("cli.commands-market", "Daily bars to rebuild a monthly bar failed", null));
1482
+ if (reading && result?.points) points.push(...result.points);
1483
+ }), MONTHLY_REBUILD_WAIT_MS);
1484
+ reading = false;
1485
+ return points.length ? withDailyRebuiltBars(rows, points, priceDivisor, venue) : rows;
1486
+ }
1487
+
1427
1488
  /**
1428
1489
  * One listing's bars, dated and checked as `history` prints them. Without
1429
1490
  * `lookups` it does not look up the other venues of a bare symbol or whether
@@ -1447,6 +1508,8 @@ async function loadListingHistory(
1447
1508
  ? market.dataProvider.getPriceHistoryWithMetadata(symbol, exchange, loadRange, context)
1448
1509
  : market.dataProvider.getPriceHistory(symbol, exchange, loadRange, context).then((points): PriceHistoryResult => ({ points, resolution: null }));
1449
1510
  const quoteAnswer = loadListingQuoteAnswer(market.dataProvider, listing);
1511
+ // A future's prices are in its contract's unit (US cents / bushel), as FUT and G spell it; asked beside the bars.
1512
+ const priceUnit = isFuturesInstrument(symbol, null) ? settleWithin(loadFuturesPriceUnit(symbol), HISTORY_PRICE_UNIT_WAIT_MS) : Promise.resolve(null);
1450
1513
  const quoted = quoteAnswer.then((answer) => answer.quote);
1451
1514
  const fate = lookups ? listingFateLoader(listing, market, quoted, { successor: true }) : null;
1452
1515
  const request = { command: historyCommand(ask), noun: "history", ...(fate ? { fate } : {}) };
@@ -1470,7 +1533,7 @@ async function loadListingHistory(
1470
1533
  const identity = listingIdentity(listing, quote);
1471
1534
  // Without a quote currency, the listing metadata research reads (as `ticker` does) may still state it.
1472
1535
  const listed = quote?.currency ? quote : await market.dataProvider.getQuoteMetadata?.(symbol, exchange).catch(logFailure("cli.commands-market", "Read quote metadata for history failed", null));
1473
- const unit = historyUnit(listing.key, listed ?? quote);
1536
+ const unit = historyUnit(listing.key, listed ?? quote, await priceUnit);
1474
1537
  const traded = {
1475
1538
  listing: listing.key, exchange: quote?.listingExchangeName || exchange || undefined, instrumentType: quote?.instrumentType,
1476
1539
  };
@@ -1480,7 +1543,10 @@ async function loadListingHistory(
1480
1543
  const pair = quote?.instrumentType === "CURRENCY" || isCurrencyPairListing(symbol, exchange);
1481
1544
  // A London line's bars were priced in pence: cleaned there, and printed to the pence decimals `quote` shows.
1482
1545
  const priceDivisor = quotedPriceDivisor(quote);
1483
- const rows = historyRows(pair ? points.map(({ volume: _volume, ...point }) => point) : points, resolution, unit.currency, unit.unit, volume, priceDivisor);
1546
+ const barRows = historyRows(pair ? points.map(({ volume: _volume, ...point }) => point) : points, resolution, unit.currency, unit.unit, volume, priceDivisor);
1547
+ // A monthly bar whose prices contradict each other keeps its close; its open, high and low come from the daily bars.
1548
+ const rows = await withMonthlyBarsRebuilt(barRows, market, symbol, exchange, context, priceDivisor,
1549
+ quote?.listingExchangeName || exchange || "");
1484
1550
  // Bars stop arriving on the listing's own trading days, not New York's.
1485
1551
  const venue = quote?.listingExchangeName || exchange || undefined;
1486
1552
  const served = range === "YTD" && !window ? rows.slice(Math.max(0, yearToDateStartIndex(rows.map((row) => row.date), rows[0]?.interval, venue))) : rows;
@@ -1665,10 +1731,14 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
1665
1731
  const rangeOption = takeOption(args, "--range");
1666
1732
  // --from 2007 --to 2009: those years' bars, daily up to five years, in place of a range ending now.
1667
1733
  const window = historyWindowOption(args, rangeOption, ctx);
1668
- const ask: HistoryAsk = { range: parseRange(rangeOption, ctx), window };
1734
+ const range = parseRange(rangeOption, ctx);
1669
1735
  const requestedExchange = takeOption(args, "--exchange");
1670
1736
  // One row a date and a close column a symbol, as a spreadsheet lays several series side by side.
1671
1737
  const wide = takeFlag(args, "--wide");
1738
+ // A continuous future stitched across its rolls, by difference unless `ratio` follows.
1739
+ const backAdjust = takeBackAdjust(args, ctx);
1740
+ // Stitching reads daily bars: five years, which come weekly as a range, are read as the window from five years back, which comes daily.
1741
+ const ask: HistoryAsk = { range, window: window ?? (backAdjust && range === "5Y" ? yearsBackWindow(5) : null) };
1672
1742
  // A list from a file or standard input (`-`), or several symbols typed (AAPL MSFT, AAPL,MSFT), is one long table.
1673
1743
  // One argument with spaces stays one, as before: it may be a company's name.
1674
1744
  const file = args.some((arg) => arg === "--file" || arg.startsWith("--file=")) ? takeOption(args, "--file") ?? "" : undefined;
@@ -1676,6 +1746,7 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
1676
1746
  const currency = file != null || requestedExchange ? null : currencyNameStop(args, "history");
1677
1747
  if (currency) ctx.fail(currency.message, currency.details);
1678
1748
  if (wide || file != null || args.includes("-") || uniqueEntries(args).length > 1 || args.some((arg) => /[,;]/.test(arg))) {
1749
+ if (backAdjust) ctx.fail("--back-adjust stitches one continuous future, such as ES=F.", `Usage: gloom ${HISTORY_USAGE}`);
1679
1750
  return runHistoryList(args, file, requestedExchange, ask, ctx, { wide });
1680
1751
  }
1681
1752
  const raw = requireOneArg(args, HISTORY_USAGE, "symbol", ctx);
@@ -1687,7 +1758,11 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
1687
1758
  if (currency) ctx.fail(currency.message, currency.details);
1688
1759
  throw error;
1689
1760
  });
1690
- const { identity, unit, data, interval, intraday, volume, freshness, notes } = history;
1761
+ const { identity, unit, interval, intraday, volume, freshness } = history;
1762
+ // Raw stays the default; --back-adjust stitches the contracts at the rolls the warning names, and lists them.
1763
+ const stitched = backAdjust ? await backAdjustListingHistory(history, backAdjust, market, ctx) : null;
1764
+ const data = stitched?.rows ?? history.data;
1765
+ const notes = stitched ? [stitched.note, ...history.notes] : history.notes;
1691
1766
  const price = historyPrice(history.decimals);
1692
1767
  // A bar without volume in a history that reports it prints as missing.
1693
1768
  const missingVolume = historyReportsVolume(data) ? MISSING_VOLUME_TEXT : "";
@@ -1716,6 +1791,7 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
1716
1791
  maxDrawdown: drawdown && contractDrawdown?.contract ? { ...drawdown, contract: contractDrawdown.contract } : drawdown,
1717
1792
  asOf: freshness?.asOf ?? null,
1718
1793
  ...(volume ? { volumeUnit: volume.unit, volumePeriod: interval === "1d" ? "UTC day" : interval } : {}),
1794
+ ...(stitched ? { backAdjust: { method: backAdjust, rolls: stitched.rolls, ...(stitched.unstitched.length > 0 ? { unstitched: stitched.unstitched } : {}) } } : {}),
1719
1795
  },
1720
1796
  ...(notes.length > 0 ? { warnings: notes } : {}),
1721
1797
  freshness,
@@ -1736,6 +1812,84 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
1736
1812
  });
1737
1813
  }
1738
1814
 
1815
+ /** The window from `years` back to today. */
1816
+ function yearsBackWindow(years: number): PriceWindow | null {
1817
+ const from = new Date();
1818
+ from.setUTCFullYear(from.getUTCFullYear() - years);
1819
+ return readPriceWindow(from.toISOString().slice(0, 10), undefined);
1820
+ }
1821
+
1822
+ /** `--back-adjust` and the method after it (`ratio` or `difference`, the default); null without it. */
1823
+ function takeBackAdjust(args: string[], ctx: Parameters<CliCommandDef["execute"]>[1]): BackAdjustMethod | null {
1824
+ const methods = new Set(["difference", "ratio"]);
1825
+ const equals = args.findIndex((arg) => arg.startsWith("--back-adjust="));
1826
+ if (equals >= 0) {
1827
+ const value = args.splice(equals, 1)[0]!.slice("--back-adjust=".length).toLowerCase();
1828
+ if (!methods.has(value)) ctx.fail(`--back-adjust is by difference or ratio, not "${value}".`, `Usage: gloom ${HISTORY_USAGE}`);
1829
+ return value as BackAdjustMethod;
1830
+ }
1831
+ const index = args.indexOf("--back-adjust");
1832
+ if (index < 0) return null;
1833
+ const next = args[index + 1]?.toLowerCase();
1834
+ const method = next && methods.has(next) ? next as BackAdjustMethod : "difference";
1835
+ args.splice(index, next && methods.has(next) ? 2 : 1);
1836
+ return method;
1837
+ }
1838
+
1839
+ /** Contract reads a back-adjusted history makes at once. */
1840
+ const BACK_ADJUST_READ_LIMIT = 4;
1841
+ /** How far before a roll a contract's bars must reach for its close: past a long holiday weekend. */
1842
+ const ROLL_READ_DAYS = 10;
1843
+ /** The ranges a contract's bars are read over, each with the days it spans at least. */
1844
+ const BACK_ADJUST_READ_RANGES: ReadonlyArray<readonly [TimeRange, number]> = [["1M", 28], ["3M", 89], ["6M", 181], ["1Y", 365], ["5Y", 1826]];
1845
+
1846
+ /**
1847
+ * A continuous future's daily bars back-adjusted at its rolls
1848
+ * (backAdjustHistory): each outgoing and incoming contract's bars read
1849
+ * around its roll, the stitched rolls and the warning that lists them. Fails
1850
+ * for a symbol that is not a continuous future whose bars name their
1851
+ * contracts, for bars coarser than daily, and when a roll cannot be priced.
1852
+ */
1853
+ async function backAdjustListingHistory(
1854
+ history: ListingHistory,
1855
+ method: BackAdjustMethod,
1856
+ market: MarketContext,
1857
+ ctx: Parameters<CliCommandDef["execute"]>[1],
1858
+ ): Promise<{ rows: HistoryRow[]; rolls: StitchedRoll[]; unstitched: HistoryRoll[]; note: string }> {
1859
+ const symbol = history.listing.symbol;
1860
+ const board = futuresBoardContract(symbol);
1861
+ if (!/=F$/i.test(symbol) || !board || !history.data.some((row) => row.contract)) {
1862
+ ctx.fail(`--back-adjust stitches a continuous future's contracts, such as ES=F; ${history.listing.key} is not one whose bars name them.`);
1863
+ }
1864
+ if (history.interval !== "1d") {
1865
+ ctx.fail("--back-adjust stitches daily bars: ask for --range 5Y or less, or a --from window of up to five years.", `Usage: gloom ${HISTORY_USAGE}`);
1866
+ }
1867
+ const rolls = historyRolls(history.data);
1868
+ // Each contract's daily bars over the shortest range that reaches back past its earliest roll.
1869
+ const oldest = new Map<string, number>();
1870
+ for (const roll of rolls) {
1871
+ for (const contract of [roll.from, roll.to]) {
1872
+ const at = Date.parse(`${roll.date.slice(0, 10)}T00:00:00Z`) - ROLL_READ_DAYS * 86_400_000;
1873
+ oldest.set(contract, Math.min(oldest.get(contract) ?? at, at));
1874
+ }
1875
+ }
1876
+ const context = { cacheMode: ctx.cliOptions.refresh ? "refresh" as const : "default" as const };
1877
+ // A few contracts at a time: five years of rolls is forty-odd contracts.
1878
+ const read = createConcurrencyLimiter(BACK_ADJUST_READ_LIMIT);
1879
+ const loaded = await Promise.all([...oldest].map(([contract, from]) => read(() => {
1880
+ const range = BACK_ADJUST_READ_RANGES.find(([, days]) => Date.now() - days * 86_400_000 <= from)?.[0] ?? "5Y";
1881
+ return market.dataProvider.getPriceHistory(`${contract}.${board!.venue}`, "", range, context)
1882
+ .then((points) => ({ contract, closes: contractCloses(points) }))
1883
+ .catch(logFailure("cli.commands-market", "Read a futures contract's bars to back-adjust failed", { contract, closes: new Map<string, number>() }));
1884
+ })));
1885
+ const closes = new Map(loaded.map(({ contract, closes: read }) => [contract, read]));
1886
+ // A contract the source has no bars of leaves its rolls as traded, named in the warning, and the rest are stitched.
1887
+ const unserved = new Set(loaded.flatMap(({ contract, closes: read }) => read.size === 0 ? [contract] : []));
1888
+ const stitched = backAdjustHistory(history.data, method, (contract) => closes.get(contract));
1889
+ const named = history.data.findIndex((row) => row.contract);
1890
+ return { ...stitched, note: stitchedRollsNote(symbol, method, stitched.rolls, named > 0 ? history.data[named]!.date : null, stitched.unstitched, unserved) };
1891
+ }
1892
+
1739
1893
  /** A symbol of a list: its bars, or why it has none. */
1740
1894
  type ListedHistory = { symbol: string; history: ListingHistory } | { symbol: string; error: string };
1741
1895
 
@@ -2134,7 +2288,9 @@ async function runFinancials(rawArgs: string[], ctx: Parameters<CliCommandDef["e
2134
2288
  marketCap: capitalization?.value ?? null,
2135
2289
  marketCapCurrency: capitalization?.currency ?? null,
2136
2290
  } : {},
2137
- fundamentals: priced.fundamentals && exportedDividendFundamentals(exportedFundamentals(priced.fundamentals)!, report.distributions),
2291
+ // A bank's EV and EV/revenue are null with why: n/m for banks.
2292
+ fundamentals: priced.fundamentals && exportedDividendFundamentals(
2293
+ exportedFundamentals(withBankEnterpriseValue(priced.fundamentals, priced.profile))!, report.distributions),
2138
2294
  // A bond fund's sponsor figures; fundamentals.dividendYield is then its distribution yield, not its SEC yield.
2139
2295
  ...bond ? { bondFund: bond } : {},
2140
2296
  ...view === "fundamentals" ? { statementFilings, bank: bank.bank, ...bank.note ? { bankNote: bank.note } : {} } : {},
@@ -2361,8 +2517,12 @@ async function runNews(rawArgs: string[], ctx: Parameters<CliCommandDef["execute
2361
2517
  // to its future: the stories that mention the word are the news.
2362
2518
  const word = commodity ?? (unfiled ? newsFallbackText(args[0]!) : null);
2363
2519
  const futuresCode = !!word && !!bareFuturesCode(word) && isFuturesInstrument(listing!.symbol, quote?.instrumentType);
2520
+ // A word typed as a word ("corn", not CORN) that a ticker answers to but no story is filed under: the stories
2521
+ // that mention the word, said to be that (Teucrium Corn Fund had none on 5 Nov 2026; corn's market had plenty).
2522
+ const typedWord = !!word && /^[A-Za-z]{3,}$/.test(word) && /[a-z]/.test(word);
2364
2523
  const reason = commodity ? `the commodity ${future!.symbol} trades`
2365
- : !resolved ? "no ticker by that name" : futuresCode ? "a futures code, not a ticker" : null;
2524
+ : !resolved ? "no ticker by that name" : futuresCode ? "a futures code, not a ticker"
2525
+ : typedWord ? `no stories filed under ${listing!.symbol}${identity?.name ? ` (${identity.name})` : ""}` : null;
2366
2526
  const emptyMessage = (searched: boolean) => listing && identity
2367
2527
  ? newsEmptyMessage(searched && word ? word : listing.symbol, listingTitle(identity), quote, resolved, searched)
2368
2528
  : undefined;
@@ -2464,7 +2624,10 @@ async function runFilings(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
2464
2624
  const count = parsePositiveInt(takeOption(args, "--count"), ctx.cliOptions.tail ?? ctx.cliOptions.limit ?? 15, "Count", ctx);
2465
2625
  const exchangeOption = takeOption(args, "--exchange");
2466
2626
  const form = takeOption(args, "--form")?.trim() || null;
2467
- const raw = requireOneArg(args, "filings <symbol> [--count <n>] [--form <form>]", "symbol", ctx);
2627
+ // As in fn SEC: a bank's pricing supplements and a trust's other funds stay out unless --all, and the list
2628
+ // says how many it left out.
2629
+ const all = takeFlag(args, "--all");
2630
+ const raw = requireOneArg(args, "filings <symbol> [--count <n>] [--form <form>] [--all]", "symbol", ctx);
2468
2631
  await withMarketData(ctx, async (market) => {
2469
2632
  // NST.AX is NST:ASX, as quote, valuation and the pane functions read it: the SEC is asked by venue.
2470
2633
  const listing = await requireCliListing(raw, exchangeOption, market, ctx, { venueSuffix: true });
@@ -2478,15 +2641,19 @@ async function runFilings(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
2478
2641
  const pageLine = page ? `${page.name}: ${page.url}` : null;
2479
2642
  try {
2480
2643
  const context = identity?.name ? { listingName: identity.name } : undefined;
2644
+ const load = (rows: number) => market.dataProvider.getSecFilings(symbol, rows, exchange, context);
2645
+ let hidden: HiddenFilings | null = null;
2481
2646
  const [filings, quote] = await Promise.all([
2482
- loadForListing(listing, market, ctx, () => form
2483
- // A form filter searches every filing the service lists for the issuer, as the SEC pane does.
2484
- ? market.dataProvider.getSecFilings(symbol, SEC_FILING_FETCH_LIMIT, exchange, context)
2485
- .then((all) => all.filter((filing) => filingFormMatches(filing.form, form)).slice(0, count))
2486
- : market.dataProvider.getSecFilings(symbol, count, exchange, context),
2647
+ // What fn SEC shows: a form filter searches every filing listed for the issuer; without one, what fn SEC
2648
+ // leaves out by default stays out unless --all.
2649
+ loadForListing(listing, market, ctx, () => loadShownSecFilings(load, count, { form, all }).then((shown) => {
2650
+ hidden = shown.hidden;
2651
+ return shown.filings;
2652
+ }),
2487
2653
  (found) => found.length === 0),
2488
2654
  quotePromise,
2489
2655
  ]);
2656
+ const hiddenNote = hidden ? hiddenFilingsNote(hidden) : null;
2490
2657
  const resolved = identity ?? listingIdentity(listing, quote);
2491
2658
  const choice = await listingChoiceNotes(listing, market, quote, venues);
2492
2659
  // A company on ASX that files nothing with the SEC lists its ASX announcements instead.
@@ -2499,6 +2666,7 @@ async function runFilings(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
2499
2666
  metadata: {
2500
2667
  ...listingMetadata(resolved), ...(form ? { form } : {}),
2501
2668
  ...(page ? { announcementsPage: page.url } : {}),
2669
+ ...hiddenFilingsMetadata(hidden),
2502
2670
  },
2503
2671
  freshness: rowsFreshness(filingRows(filings), SEC_FILING_ROWS),
2504
2672
  ...(choice.length > 0 ? { warnings: choice } : {}),
@@ -2512,7 +2680,7 @@ async function runFilings(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
2512
2680
  empty: [form ? `No ${form} filings found for ${listingTitle(resolved)}.`
2513
2681
  : identity ? noSecReportsNotice(resolved)
2514
2682
  : `No SEC filings found for ${listingTitle(resolved)}.`, pageLine].filter(Boolean).join("\n"),
2515
- ...filingsFootnote(pageLine, filings[0]?.companyFrom),
2683
+ ...filingsFootnote(pageLine, filings[0]?.companyFrom, hiddenNote),
2516
2684
  });
2517
2685
  } catch (error) {
2518
2686
  if (!(error instanceof SecRegistrantMismatchError)) throw error;
@@ -2531,12 +2699,29 @@ async function runFilings(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
2531
2699
  }
2532
2700
 
2533
2701
  /**
2534
- * The lines `filings` prints under its rows and CSV writes as notes: an ASX
2535
- * listing's announcements page, and whose filings a foreign line shows when
2536
- * they are its company's home line's.
2702
+ * A bare symbol's own row that search marks as delisted (FRC: inactive, last
2703
+ * traded 2023-04-28), the service's record of it, for a symbol whose quote
2704
+ * and bars said nothing: "FRC last traded 2023-04-28; no longer listed".
2537
2705
  */
2538
- function filingsFootnote(pageLine: string | null | undefined, companyFrom: CompanyFrom | undefined): { footnote?: string; exportNotes?: string[] } {
2539
- const lines = [...(pageLine ? [pageLine] : []), ...companyDataNotes(companyFrom)];
2706
+ async function searchedDelisting(listing: CliListing, market: MarketContext): Promise<NoQuoteLastTrade | null> {
2707
+ if (listing.exchange || !market.dataProvider.search || !/^[A-Z][A-Z0-9.-]{0,9}$/.test(listing.symbol)) return null;
2708
+ const rows = await market.dataProvider.search(listing.symbol).catch(logFailure("cli.market", "Search a delisted symbol failed", []));
2709
+ const row = rows.find((result) => result.delisting && normalizeTickerSymbol(result.symbol) === listing.symbol);
2710
+ return row?.delisting ? { date: row.delisting.lastTradeDate, recorded: true } : null;
2711
+ }
2712
+
2713
+ /**
2714
+ * The lines `filings` prints under its rows and CSV writes as notes: how
2715
+ * many pricing supplements it left out, an ASX listing's announcements page,
2716
+ * and whose filings a foreign line shows when they are its company's home
2717
+ * line's.
2718
+ */
2719
+ function filingsFootnote(
2720
+ pageLine: string | null | undefined,
2721
+ companyFrom: CompanyFrom | undefined,
2722
+ hiddenNote: string | null = null,
2723
+ ): { footnote?: string; exportNotes?: string[] } {
2724
+ const lines = [...(hiddenNote ? [hiddenNote] : []), ...(pageLine ? [pageLine] : []), ...companyDataNotes(companyFrom)];
2540
2725
  return lines.length ? { footnote: lines.join("\n"), exportNotes: lines } : {};
2541
2726
  }
2542
2727
 
@@ -3259,7 +3444,15 @@ async function runFxOnDate(
3259
3444
  }
3260
3445
  }
3261
3446
  const from = legs.get(currency), into = legs.get(baseCurrency);
3447
+ // Converted at the closes as sent, never at a rounded rate; the line names each close it used.
3262
3448
  const rate = currency === baseCurrency ? 1 : crossRate(from?.rate, into?.rate);
3449
+ const closes: FxQuotedFigure[] = codes.flatMap((code) => {
3450
+ const leg = dailyFxLeg(code), close = legs.get(code)?.close;
3451
+ return leg && close != null ? [{ pair: leg.invert ? `USD/${code}` : `${code}/USD`, figure: close }] : [];
3452
+ });
3453
+ const rateLine = closes.length > 1
3454
+ ? `${describeFxRate(request, rate)} · ${describeFxLegs(closes)}`
3455
+ : describeFxRate(request, rate, closes[0]);
3263
3456
  // A cross is as old as its older close; a weekend or holiday reads the trading day before it.
3264
3457
  const closeDate = [...legs.values()].map((leg) => leg.date).sort()[0]!;
3265
3458
  const converted = amount == null ? null : amount * rate;
@@ -3280,7 +3473,7 @@ async function runFxOnDate(
3280
3473
  freshness: rowsFreshness([], { status: "not-a-feed", basis: "daily FX close", asOf: closeDate }),
3281
3474
  warnings: warnings.length > 0 ? warnings : undefined,
3282
3475
  }, {
3283
- text: () => amount == null ? describeFxRate(request, rate) : `${describeFxConversion(request, amount, rate)}\n${describeFxRate(request, rate)}`,
3476
+ text: () => amount == null ? rateLine : `${describeFxConversion(request, amount, rate)}\n${rateLine}`,
3284
3477
  exportIdentity: { symbolOrSeries: pair, currencyOrUnit: `${baseCurrency} per ${currency}`, interval: "1day" },
3285
3478
  columns: [
3286
3479
  { key: "currency", header: "Currency" },
@@ -3331,49 +3524,43 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
3331
3524
  (payload) => ({ payload }),
3332
3525
  (error: unknown) => ({ error: unavailableOnServer(error, "Forwards are not available from Gloom Cloud yet: it serves no short rates.") }),
3333
3526
  ) : null;
3334
- const reasons = new Map<string, string>();
3335
- const load = (code: string) => market.dataProvider.getCachedQuery("getExchangeRate", [code])
3336
- .load({ force: ctx.cliOptions.refresh }).catch((error) => {
3337
- const reason = providerMissReason(error);
3338
- if (reason) reasons.set(code, reason);
3339
- return null;
3340
- });
3341
- // Every rate is a cross of two USD legs; a code priced in itself needs none.
3342
- const codes = currency === baseCurrency ? [] : [currency, baseCurrency];
3343
- const legs = await Promise.all(codes.map(load));
3344
- const missing = codes.filter((_code, index) => !isUsableRate(legs[index]?.value));
3345
- if (missing.length > 0) {
3346
- // A reason the data service gave for the first missing leg says more than the generic line.
3347
- const reason = missing.map((code) => reasons.get(code)).find(Boolean);
3527
+ // The pair's own quote, as `quote` and the FX board read it; a pair with none is crossed through the dollar.
3528
+ const now = Date.now();
3529
+ const read = await readFxQuoteRate(currency, baseCurrency, (targets, options) => market.dataProvider.getQuotesBatch(targets, options),
3530
+ { forceRefresh: ctx.cliOptions.refresh, now });
3531
+ if (read && "missing" in read) {
3532
+ // A reason the data service gave for a missing quote (spot gold is not quoted) says more than the generic line;
3533
+ // a symbol that names nothing (USDXYZ=X) or a source with nothing to say (No quote provider available) does not.
3534
+ const reason = read.errors.map((error) => providerMissReason(error)
3535
+ ?? (typeof error === "string" && !/^(?:Not a ticker|No quote provider)\b|unavailable/i.test(error) ? error : undefined)).find(Boolean);
3348
3536
  if (reason) ctx.fail(reason);
3349
3537
  ctx.fail(
3350
- `Exchange rate unavailable for ${missing.join(" and ")}.`,
3351
- `${pair} is crossed from each currency's USD rate, and none came back for ${missing.join(" or ")}. Check the ISO code.`,
3538
+ `Exchange rate unavailable for ${read.missing.join(" and ")}.`,
3539
+ `No quote came back for ${fxPairListing(currency, baseCurrency).symbol}${currency !== "USD" && baseCurrency !== "USD" ? " or the dollar pairs it crosses from" : ""}. Check the ISO code.`,
3352
3540
  );
3353
3541
  }
3354
- const rate = codes.length === 0 ? 1 : crossRate(legs[0]?.value, legs[1]?.value);
3355
- // A cross rate is only as current as its older leg.
3356
- const observed = legs.flatMap((leg) => leg?.asOf ?? []);
3357
- const asOf = observed.length > 0 ? new Date(Math.min(...observed)).toISOString() : null;
3358
- const stale = legs.some((leg) => leg != null && (leg.staleAt <= Date.now() || leg.refreshError != null));
3542
+ const quoted = read && !("missing" in read) ? read : null;
3543
+ // A conversion uses the quote as sent (or the cross of the dollar pairs as sent), never a rounded rate,
3544
+ // and the rate line prints each figure it used.
3545
+ const rate = quoted ? quoted.rate : 1;
3546
+ const observation = quoted ? fxQuoteRateObservation(quoted, now) : null;
3547
+ const asOf = observation && Number.isFinite(observation.updatedAt) ? new Date(observation.updatedAt).toISOString() : null;
3548
+ // A rate older than its feed's delay is stale, as `quote` says of the same quote.
3549
+ const stale = observation?.stale === true;
3359
3550
  const converted = amount == null ? null : amount * rate;
3360
- const row = { currency, baseCurrency, rate, asOf, stale, pair, inverse: 1 / rate, ...(amount == null ? {} : { amount, converted }) };
3361
- // The closing line dates the rate, and says when it is stale, as `fn FXC` does.
3362
- const loaded = new Map(codes.flatMap((code, index) => {
3363
- const leg = legs[index];
3364
- return leg ? [[code, {
3365
- rate: leg.value,
3366
- timing: {
3367
- asOf: leg.asOf, staleAt: leg.staleAt, error: leg.refreshError, delayMinutes: leg.delayMinutes,
3368
- intradayBar: leg.intradayBar, staleReason: leg.staleReason,
3369
- },
3370
- }] as const] : [];
3371
- }));
3372
- const freshness = fxPairFreshness(loaded);
3373
- // A rate that is its pair's bar says which bar, and a stale one why it stands.
3374
- const timings = new Map([...loaded].map(([code, leg]) => [code, leg.timing]));
3375
- // --refresh read every leg again: one that is still stale says the data service has no newer rate.
3376
- const rateNotes = [...fxRateNotes(timings), ...ctx.cliOptions.refresh ? refreshedFxRateNotes(timings) : []];
3551
+ const row = {
3552
+ currency, baseCurrency, rate, asOf, stale, pair, inverse: 1 / rate,
3553
+ ...(quoted ? { quotes: quoted.quotes.map(({ symbol }) => symbol), ...(quoted.viaUsd ? { via: "USD" } : {}) } : {}),
3554
+ ...(amount == null ? {} : { amount, converted }),
3555
+ };
3556
+ // The closing line is the quote's own, as `quote` prints it: its time, and stale once older than the feed's delay.
3557
+ const freshness = observation ? rowsFreshness([observation], undefined, undefined, now) : undefined;
3558
+ // A rate that is its pair's bar says which bar, and a stale one why it stands; --refresh says when it found nothing newer.
3559
+ const rateNotes = (quoted?.quotes ?? []).flatMap(({ symbol, quote }) => [
3560
+ ...quoteBarNotes(symbol, quote, now),
3561
+ ...ctx.cliOptions.refresh && !quote.staleReason && isQuoteStaleForCurrentSession(quote, now)
3562
+ ? [`${symbol}: --refresh found no newer quote than ${formatUtcDayTime({ time: quote.lastUpdated, dateOnly: false }, now)} UTC.`] : [],
3563
+ ]);
3377
3564
  if (tenor && shortRates && !("error" in tenor)) {
3378
3565
  const read = await shortRates;
3379
3566
  if ("error" in read) throw read.error;
@@ -3437,7 +3624,12 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
3437
3624
  ? await loadPesoDollarRates((targets) => market.dataProvider.getQuotesBatch(targets, { forceRefresh: ctx.cliOptions.refresh }))
3438
3625
  : null;
3439
3626
  if (peso && peso.missing.length > 0) warnings.push(`No price for ${peso.missing.join(", ")}, so the rates from ${peso.missing.length === 1 ? "it are" : "them are"} left out.`);
3440
- const rateText = peso ? `${describeFxRate(request, rate)} · ${peso.spotKind} rate` : describeFxRate(request, rate);
3627
+ // A cross says so, naming the dollar pairs it is read from: the pair has no quote of its own.
3628
+ const rateText = [
3629
+ describeFxRate(request, rate, quoted && !quoted.viaUsd ? quoted.quotes[0] : undefined),
3630
+ ...quoted?.viaUsd ? [describeFxLegs(quoted.quotes)] : [],
3631
+ ...peso ? [`${peso.spotKind} rate`] : [],
3632
+ ].join(" · ");
3441
3633
  ctx.printResult({ data: [peso ? { ...row, ...pesoDollarRatesJson(peso) } : row], freshness, warnings: warnings.length > 0 ? warnings : undefined }, {
3442
3634
  // The conversion, then the rate it used; the source line under it dates that rate.
3443
3635
  text: () => [
@@ -3577,6 +3769,7 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
3577
3769
  { flags: "--to <year|date>, --end <year|date>", description: PRICE_WINDOW_TO_HELP },
3578
3770
  { flags: "--file <path>", description: "Read the symbols from a text or CSV file, one per line (- reads standard input), and write every symbol's bars in one table" },
3579
3771
  { flags: "--wide", description: "One row per date and one close column per symbol, its unit in the header, in place of one long table" },
3772
+ { flags: "--back-adjust [ratio]", description: "A continuous future (ES=F) stitched into one series at the rolls its bars name: every price before a roll moved by the gap between the two contracts that day (by difference, or scaled by their ratio with ratio), the rolls listed in a warning and in --json metadata.backAdjust. Daily bars, --range 5Y included; a roll whose contracts the source serves no bars of is left as traded and named. Raw front-month prices are the default" },
3580
3773
  EXCHANGE_OPTION,
3581
3774
  ],
3582
3775
  sections: [{
@@ -3825,10 +4018,11 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
3825
4018
  description: "Fetch recent SEC filings; a listing abroad gets its exchange's announcements page, and ASX's list",
3826
4019
  help: {
3827
4020
  group: CLI_COMMAND_GROUPS.companyData,
3828
- usage: ["filings <symbol> [--count <n>] [--form <form>]"],
4021
+ usage: ["filings <symbol> [--count <n>] [--form <form>] [--all]"],
3829
4022
  options: [
3830
4023
  { flags: "--count <n>", description: "Number of filings (default 15)" },
3831
4024
  { flags: "--form <form>", description: "Only this form and its amendments, such as 10-K or 13D" },
4025
+ { flags: "--all", description: "Also list what fn SEC leaves out by default: the pricing supplements and term sheets (424B2, FWP) a bank files for each structured note, and a fund trust's filings for its other funds" },
3832
4026
  EXCHANGE_OPTION,
3833
4027
  ],
3834
4028
  examples: ["filings AAPL", "filings BHP:ASX", "filings NST.AX", "filings AAPL --count 40 --json", "filings CAR --form 13G"],
@@ -3876,7 +4070,7 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
3876
4070
  }, {
3877
4071
  title: "Amounts",
3878
4072
  lines: [
3879
- "An amount in front converts it from the first currency to the second: fx 1234.5 EUR/USD, or fx 1234,5 EUR USD. It takes either decimal mark (1.234,5 and 1,234.5 are 1234.5) and reads as an amount of the first currency: 1.234 EUR is thousands, a third decimal being below a cent, while in a currency with three decimals (KWD) fx asks which. A comma before exactly three digits (fx 1,234 EUR) could be either, so fx asks which: type 1234 or 1.2340. An amount and one currency converts to USD. The answer gives the converted amount, then the rate it used, dated by the source line; --json adds amount and converted.",
4073
+ "An amount in front converts it from the first currency to the second: fx 1234.5 EUR/USD, or fx 1234,5 EUR USD. It takes either decimal mark (1.234,5 and 1,234.5 are 1234.5; 1.5 and 1,5 are 1.5). A lone comma or dot before exactly three digits (fx 1,234 EUR, fx 1.234 EUR) could be thousands or a decimal, so fx asks which: type 1234 or 1.2340. An amount and one currency converts to USD. The answer gives the converted amount, then the rate it used, dated by the source line; --json adds amount and converted.",
3880
4074
  ],
3881
4075
  }, {
3882
4076
  title: "A past day",