gloomberb 0.20.4 → 0.20.6

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 (316) hide show
  1. package/README.md +3 -1
  2. package/README.zh-CN.md +1 -1
  3. package/bin/gloom +9 -0
  4. package/bin/without-bun.cjs +98 -0
  5. package/package.json +4 -1
  6. package/src/api-client/data.ts +148 -37
  7. package/src/api-client/hk-tenders.ts +59 -0
  8. package/src/api-client/index.ts +1 -0
  9. package/src/api-client/types/econ.ts +30 -0
  10. package/src/api-client/yield-curves.ts +1 -1
  11. package/src/app/global-shortcuts.ts +4 -1
  12. package/src/app/keybindings/actions.ts +6 -0
  13. package/src/app/keybindings/config.ts +2 -1
  14. package/src/app/keybindings/index.ts +1 -0
  15. package/src/app/keybindings/labels.ts +6 -1
  16. package/src/app/keybindings/resolve.ts +23 -4
  17. package/src/app/keybindings/terminal-keys.ts +35 -0
  18. package/src/app/pane-runtime/index.tsx +2 -2
  19. package/src/app/pane-runtime/ticker-open-runtime.ts +68 -40
  20. package/src/app.tsx +18 -13
  21. package/src/architecture/floating-promise-allowlist.json +313 -0
  22. package/src/architecture/ui-literals-allowlist.json +1 -1
  23. package/src/capabilities/chart-series.ts +27 -1
  24. package/src/cli/commands/keybindings.ts +5 -5
  25. package/src/cli/commands/market.ts +238 -57
  26. package/src/cli/commands/news-search.ts +81 -14
  27. package/src/cli/commands/overview.ts +27 -6
  28. package/src/cli/commands/remote.ts +16 -17
  29. package/src/cli/commands/system.ts +1 -1
  30. package/src/cli/commands/ticker.ts +3 -1
  31. package/src/cli/early-command.ts +2 -0
  32. package/src/cli/errors.ts +10 -1
  33. package/src/cli/fx-forward.ts +89 -7
  34. package/src/cli/fx-pair.ts +1 -1
  35. package/src/cli/fx-quote-rate.ts +23 -0
  36. package/src/cli/glossary.ts +19 -5
  37. package/src/cli/help.ts +1 -0
  38. package/src/cli/history-rows.ts +5 -3
  39. package/src/cli/index-roots.ts +5 -4
  40. package/src/cli/index.ts +40 -3
  41. package/src/cli/known-gaps.ts +38 -9
  42. package/src/cli/listing-arg.ts +17 -5
  43. package/src/cli/name-entries.ts +5 -1
  44. package/src/cli/not-a-ticker.ts +4 -0
  45. package/src/cli/options.ts +52 -3
  46. package/src/cli/output-file.ts +5 -3
  47. package/src/cli/pane-functions/catalog.ts +15 -0
  48. package/src/cli/pane-functions/function-help.ts +4 -4
  49. package/src/cli/pane-functions/headless.ts +9 -4
  50. package/src/cli/pane-functions/index.ts +6 -4
  51. package/src/cli/pane-functions/resolver.ts +2 -2
  52. package/src/cli/result.ts +21 -2
  53. package/src/cli/spreadsheet-hint.ts +7 -3
  54. package/src/cli/treasury-yields.ts +5 -3
  55. package/src/components/chart/composite/legend.tsx +40 -2
  56. package/src/components/command-bar/pane-settings.ts +2 -2
  57. package/src/components/command-bar/routes/root/results.ts +6 -2
  58. package/src/components/command-bar/workflow/tickers.ts +2 -2
  59. package/src/components/data-table/view.tsx +9 -2
  60. package/src/components/input-search-bar.tsx +9 -2
  61. package/src/components/layout/pane/header.tsx +2 -0
  62. package/src/components/layout/shell/pane/capture.ts +4 -1
  63. package/src/components/layout/status-bar.tsx +6 -1
  64. package/src/components/onboarding/first-run-workspace.ts +44 -2
  65. package/src/components/onboarding/onboarding-frame.tsx +11 -2
  66. package/src/components/onboarding/onboarding-keyboard.ts +16 -0
  67. package/src/components/onboarding/onboarding-wizard.tsx +8 -8
  68. package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
  69. package/src/components/onboarding/use-onboarding-progress.ts +12 -4
  70. package/src/components/pane-settings-dialog/desktop.tsx +2 -2
  71. package/src/components/pane-settings-dialog/tui.tsx +2 -2
  72. package/src/components/pane-settings-dialog/value.ts +6 -0
  73. package/src/components/pane-settings-dialog.tsx +3 -3
  74. package/src/components/reader/detail-reader.tsx +4 -0
  75. package/src/components/ui/data-table/opentui/index.tsx +11 -4
  76. package/src/components/ui/data-table/opentui/model.ts +8 -6
  77. package/src/components/ui/data-table/types.ts +6 -1
  78. package/src/components/ui/index.ts +1 -1
  79. package/src/components/ui/page-stack-view.tsx +3 -0
  80. package/src/components/ui/pane-link-chip.tsx +269 -54
  81. package/src/components/ui/query-bar.tsx +2 -1
  82. package/src/components/ui/table-layout.ts +38 -1
  83. package/src/components/ui/tabs.tsx +97 -19
  84. package/src/core/state/app/layout-reducer.ts +7 -0
  85. package/src/core/state/app/layout.ts +44 -7
  86. package/src/core/state/app/state.ts +1 -1
  87. package/src/core/state/app/types.ts +22 -2
  88. package/src/docs/snapshot.json +30 -13
  89. package/src/market-data/depositary-pair.ts +5 -3
  90. package/src/market-data/market/change-basis.ts +9 -5
  91. package/src/market-data/market/dated-previous-close.ts +147 -17
  92. package/src/market-data/market/status.ts +17 -1
  93. package/src/market-data/quotes/contributions.ts +2 -0
  94. package/src/market-data/quotes/listing-enterprise-value.ts +50 -0
  95. package/src/plugins/builtin/alerts/metric-data.ts +15 -2
  96. package/src/plugins/builtin/analytics/risk-client.ts +10 -4
  97. package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
  98. package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
  99. package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
  100. package/src/plugins/builtin/awards/index.tsx +1 -1
  101. package/src/plugins/builtin/backtest/headless.ts +1 -1
  102. package/src/plugins/builtin/buildout/index.tsx +1 -0
  103. package/src/plugins/builtin/catalysts/index.tsx +2 -2
  104. package/src/plugins/builtin/cds/headless.ts +4 -0
  105. package/src/plugins/builtin/cds/model.ts +0 -6
  106. package/src/plugins/builtin/chart-composer/formula.ts +16 -3
  107. package/src/plugins/builtin/chart-composer/headless-schema.ts +2 -0
  108. package/src/plugins/builtin/chart-composer/headless.ts +4 -2
  109. package/src/plugins/builtin/chart-composer/index.tsx +1 -0
  110. package/src/plugins/builtin/chart-composer/presets.ts +1 -0
  111. package/src/plugins/builtin/chat/content/composer.tsx +5 -4
  112. package/src/plugins/builtin/chat/content/index.tsx +12 -2
  113. package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
  114. package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
  115. package/src/plugins/builtin/chat/layout.ts +5 -2
  116. package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
  117. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  118. package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
  119. package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
  120. package/src/plugins/builtin/cloud/askg/pane.tsx +55 -13
  121. package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
  122. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +5 -3
  123. package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
  124. package/src/plugins/builtin/company-attention/index.tsx +1 -1
  125. package/src/plugins/builtin/company-kpis/headless.ts +3 -1
  126. package/src/plugins/builtin/company-kpis/index.tsx +2 -2
  127. package/src/plugins/builtin/cot/index.tsx +1 -1
  128. package/src/plugins/builtin/cpi/index.tsx +1 -1
  129. package/src/plugins/builtin/credit-boards/cdx-pane.tsx +20 -7
  130. package/src/plugins/builtin/credit-boards/client.ts +8 -0
  131. package/src/plugins/builtin/credit-boards/headless.ts +4 -1
  132. package/src/plugins/builtin/credit-boards/model.ts +58 -4
  133. package/src/plugins/builtin/credit-boards/series.ts +63 -6
  134. package/src/plugins/builtin/credit-boards/sovr-pane.tsx +3 -2
  135. package/src/plugins/builtin/credit-conditions/headless.ts +24 -6
  136. package/src/plugins/builtin/credit-conditions/index.tsx +1 -1
  137. package/src/plugins/builtin/credit-conditions/model.ts +12 -6
  138. package/src/plugins/builtin/credit-conditions/series.ts +2 -1
  139. package/src/plugins/builtin/crypto-board/index.tsx +1 -0
  140. package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
  141. package/src/plugins/builtin/doe/index.tsx +1 -1
  142. package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
  143. package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
  144. package/src/plugins/builtin/econ/calendar-model.ts +115 -8
  145. package/src/plugins/builtin/econ/calendar-source.ts +7 -1
  146. package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
  147. package/src/plugins/builtin/econ/index.tsx +42 -8
  148. package/src/plugins/builtin/econ/types.ts +3 -0
  149. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  150. package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
  151. package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
  152. package/src/plugins/builtin/executives/index.tsx +1 -0
  153. package/src/plugins/builtin/filing-events/index.tsx +1 -0
  154. package/src/plugins/builtin/fixed-income/index.tsx +3 -0
  155. package/src/plugins/builtin/futures-curve/headless.ts +3 -3
  156. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  157. package/src/plugins/builtin/futures-curve/model.ts +18 -0
  158. package/src/plugins/builtin/fx-matrix/index.tsx +44 -14
  159. package/src/plugins/builtin/gpu/index.tsx +1 -1
  160. package/src/plugins/builtin/help/functions-table.tsx +1 -1
  161. package/src/plugins/builtin/help/index.tsx +11 -1
  162. package/src/plugins/builtin/help/keybindings-editor.tsx +7 -3
  163. package/src/plugins/builtin/holders/index.tsx +1 -0
  164. package/src/plugins/builtin/holders/report-header.ts +2 -2
  165. package/src/plugins/builtin/insider/index.tsx +1 -0
  166. package/src/plugins/builtin/iv-history/index.tsx +1 -1
  167. package/src/plugins/builtin/jobs/index.tsx +1 -0
  168. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  169. package/src/plugins/builtin/macro-day/index.tsx +1 -1
  170. package/src/plugins/builtin/macro-day/model.ts +19 -3
  171. package/src/plugins/builtin/macro-day/pane.tsx +14 -9
  172. package/src/plugins/builtin/macro-day/releases.ts +25 -7
  173. package/src/plugins/builtin/market-valuation/index.tsx +1 -0
  174. package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
  175. package/src/plugins/builtin/members/index.tsx +1 -1
  176. package/src/plugins/builtin/mna/index.tsx +1 -0
  177. package/src/plugins/builtin/news/index.tsx +1 -0
  178. package/src/plugins/builtin/news/wire/index.tsx +5 -1
  179. package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
  180. package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
  181. package/src/plugins/builtin/options/index.tsx +1 -0
  182. package/src/plugins/builtin/options-positioning/index.tsx +1 -0
  183. package/src/plugins/builtin/pe-band/index.tsx +1 -1
  184. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
  185. package/src/plugins/builtin/portfolio-list/cli/render.ts +20 -3
  186. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -1
  187. package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
  188. package/src/plugins/builtin/power/index.tsx +1 -1
  189. package/src/plugins/builtin/realized-vol/index.tsx +1 -1
  190. package/src/plugins/builtin/research/headless-schema.ts +4 -3
  191. package/src/plugins/builtin/research/headless.ts +10 -4
  192. package/src/plugins/builtin/research/index.tsx +4 -0
  193. package/src/plugins/builtin/research/relative-valuation-columns.ts +145 -47
  194. package/src/plugins/builtin/research/relative-valuation-currency.ts +31 -0
  195. package/src/plugins/builtin/research/relative-valuation-headless.ts +25 -8
  196. package/src/plugins/builtin/research/relative-valuation-model.ts +40 -9
  197. package/src/plugins/builtin/research/relative-valuation-pane.tsx +3 -2
  198. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -2
  199. package/src/plugins/builtin/research-search/index.tsx +1 -0
  200. package/src/plugins/builtin/research-search/pane.tsx +8 -0
  201. package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
  202. package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
  203. package/src/plugins/builtin/risk-factors/index.tsx +1 -0
  204. package/src/plugins/builtin/scanner/headless.ts +52 -13
  205. package/src/plugins/builtin/seasonality/index.tsx +1 -1
  206. package/src/plugins/builtin/sec/index.tsx +1 -0
  207. package/src/plugins/builtin/series-inventory.ts +1 -1
  208. package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
  209. package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
  210. package/src/plugins/builtin/short-interest/index.tsx +1 -0
  211. package/src/plugins/builtin/social-mentions/index.tsx +1 -1
  212. package/src/plugins/builtin/supply-chain/index.tsx +1 -0
  213. package/src/plugins/builtin/thirteenf/api.ts +47 -4
  214. package/src/plugins/builtin/thirteenf/data.ts +43 -10
  215. package/src/plugins/builtin/thirteenf/headless.ts +55 -11
  216. package/src/plugins/builtin/thirteenf/model.ts +25 -9
  217. package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
  218. package/src/plugins/builtin/thirteenf/types.ts +2 -0
  219. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
  220. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +8 -7
  221. package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +8 -5
  222. package/src/plugins/builtin/ticker-detail/financials/model.ts +18 -2
  223. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
  224. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +6 -6
  225. package/src/plugins/builtin/ticker-detail/headless.ts +24 -17
  226. package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
  227. package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
  228. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +6 -4
  229. package/src/plugins/builtin/time-sales/client.ts +9 -11
  230. package/src/plugins/builtin/time-sales/index.tsx +1 -1
  231. package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
  232. package/src/plugins/builtin/treasury-auctions/cache.ts +54 -5
  233. package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
  234. package/src/plugins/builtin/treasury-auctions/headless.ts +150 -22
  235. package/src/plugins/builtin/treasury-auctions/hk-headless.ts +126 -0
  236. package/src/plugins/builtin/treasury-auctions/hk-view.tsx +347 -0
  237. package/src/plugins/builtin/treasury-auctions/hk.ts +363 -0
  238. package/src/plugins/builtin/treasury-auctions/index.tsx +27 -4
  239. package/src/plugins/builtin/treasury-auctions/model.ts +264 -28
  240. package/src/plugins/builtin/treasury-auctions/pane.tsx +176 -41
  241. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
  242. package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
  243. package/src/plugins/builtin/vol-surface/index.tsx +1 -1
  244. package/src/plugins/builtin/world-venue-map/index.ts +1 -0
  245. package/src/plugins/builtin/yield-curve/curves.ts +10 -4
  246. package/src/plugins/builtin/yield-curve/headless.ts +6 -2
  247. package/src/plugins/builtin/yield-curve/index.tsx +3 -3
  248. package/src/plugins/builtin/yield-curve/series.ts +10 -0
  249. package/src/plugins/builtin/yield-curve/world.ts +3 -1
  250. package/src/portfolio/collection-name.ts +22 -0
  251. package/src/portfolio/column-values.ts +2 -1
  252. package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
  253. package/src/public/remote.ts +7 -1
  254. package/src/remote/client.ts +191 -11
  255. package/src/remote/controller-utils.ts +13 -1
  256. package/src/remote/controller.ts +88 -26
  257. package/src/remote/endpoint.ts +24 -0
  258. package/src/remote/form.ts +59 -4
  259. package/src/remote/resources.ts +44 -18
  260. package/src/remote/schema.ts +21 -9
  261. package/src/remote/secrets.ts +12 -0
  262. package/src/remote/semantic-tree.tsx +14 -2
  263. package/src/remote/server.ts +2 -1
  264. package/src/remote/surface.tsx +192 -0
  265. package/src/remote/types.ts +5 -0
  266. package/src/renderers/dom/data-table/frozen-column.ts +3 -1
  267. package/src/renderers/dom/data-table/index.tsx +27 -9
  268. package/src/renderers/dom/data-table/row.tsx +2 -0
  269. package/src/renderers/electrobun/bun/desktop/backend.ts +27 -24
  270. package/src/renderers/electrobun/bun/desktop/detached-windows.ts +3 -3
  271. package/src/renderers/electrobun/bun/desktop/snapshot-commit.ts +77 -0
  272. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  273. package/src/renderers/electrobun/view/backend-rpc.ts +3 -0
  274. package/src/renderers/electrobun/view/desktop/window/bridge.ts +3 -0
  275. package/src/renderers/opentui/host.tsx +6 -0
  276. package/src/series/standalone.ts +2 -2
  277. package/src/shares/api.ts +21 -4
  278. package/src/shares/item.ts +73 -0
  279. package/src/shares/pane-item.ts +205 -0
  280. package/src/shares/pane.ts +4 -0
  281. package/src/shares/payload.ts +9 -5
  282. package/src/sources/gloomberb-cloud/news.ts +2 -0
  283. package/src/sources/gloomberb-cloud/normalizers.ts +9 -5
  284. package/src/sources/provider-router/cache.ts +3 -1
  285. package/src/sync/controller.ts +17 -2
  286. package/src/sync/other-window-tabs.ts +32 -1
  287. package/src/sync/react.ts +4 -4
  288. package/src/tickers/renamed-listings.ts +105 -0
  289. package/src/tickers/search/index.ts +103 -16
  290. package/src/time-series/bar-spacing.ts +33 -0
  291. package/src/time-series/base-series.ts +21 -3
  292. package/src/time-series/chart-bounds.ts +31 -0
  293. package/src/time-series/field-catalog.ts +17 -0
  294. package/src/time-series/fundamentals.ts +143 -11
  295. package/src/time-series/ice-credit.ts +32 -6
  296. package/src/time-series/resolve.ts +11 -7
  297. package/src/time-series/session-bar.ts +78 -9
  298. package/src/time-series/studies/formula.ts +53 -10
  299. package/src/time-series/studies/pair.ts +18 -7
  300. package/src/time-series/studies/units.ts +49 -2
  301. package/src/time-series/types.ts +12 -0
  302. package/src/types/desktop-window.ts +2 -0
  303. package/src/types/financials.ts +7 -0
  304. package/src/types/headless.ts +8 -0
  305. package/src/types/plugin-pane-settings.ts +2 -0
  306. package/src/types/plugin-panes.ts +22 -0
  307. package/src/utils/central-banks.ts +86 -1
  308. package/src/utils/cli-output.ts +6 -3
  309. package/src/utils/datetime-format.ts +12 -3
  310. package/src/utils/depositary-receipt.ts +28 -3
  311. package/src/utils/ebitda.ts +128 -0
  312. package/src/utils/format.ts +1 -1
  313. package/src/utils/fundamentals.ts +14 -0
  314. package/src/utils/max-drawdown.ts +97 -16
  315. package/src/utils/shell-word.ts +13 -0
  316. package/src/utils/untrusted-text.ts +29 -0
@@ -40,13 +40,32 @@ import { captureScannerEvent, SCANNER_SNAPSHOT_TIMEOUT_MS } from "../shared/scan
40
40
  import { flowLockNote } from "./lock-note";
41
41
  import { buildHiloBarRows, filterHiloRows, formatHiloPrice, type HiloMinPrice, type HiloSort } from "./hilo-model";
42
42
 
43
+ /**
44
+ * How long a report waits for a scanner that is starting: an idle one can take
45
+ * most of the 30 s a capture gives it to win its lock and seed (a cold HILO
46
+ * took 30 s on a weekend), past what an Ask Gloom call is given. After this it
47
+ * answers with what the starting scanner holds, said to be stale.
48
+ */
49
+ const HEADLESS_SCANNER_WAIT_MS = 12_000;
50
+
51
+ /**
52
+ * The most a FLOW report waits in all, inside the 20 s a script gives a call:
53
+ * its recorded prints and session sums get what the live feed's wait left,
54
+ * and one not answered by then is said under errors.
55
+ */
56
+ const FLOW_REPORT_BUDGET_MS = 16_000;
57
+
58
+ /** What a report of a scanner still starting says in place of its empty list. */
59
+ const SCANNER_STARTING_TEXT = "The scanner is still starting and has nothing to list yet. Ask again in a few seconds.";
60
+
43
61
  function loadScannerSnapshot<T extends ScannerPayload>(
44
62
  client: Pick<HeadlessPaneApiClient, "subscribeScanner">,
45
63
  scanner: ScannerKind,
46
64
  signal: AbortSignal,
47
65
  timeoutMs = SCANNER_SNAPSHOT_TIMEOUT_MS,
66
+ options: { acceptStarting?: boolean } = {},
48
67
  ): Promise<T> {
49
- return captureScannerEvent(client, scanner, signal, timeoutMs).then((event) => {
68
+ return captureScannerEvent(client, scanner, signal, timeoutMs, options).then((event) => {
50
69
  if (event.type !== "denied") return event.payload as T;
51
70
  // The refusal a read gets from the server: 402 for a plan without access, 401 for no session.
52
71
  throw event.reason === "pro_required"
@@ -63,6 +82,15 @@ export function loadHiloSnapshot(
63
82
  return loadScannerSnapshot<ScannerHiloPayload>(client, "hilo", signal, timeoutMs);
64
83
  }
65
84
 
85
+ /** A report's read of a scanner: HEADLESS_SCANNER_WAIT_MS at most, after which a starting scanner is answered as one. */
86
+ function loadReportSnapshot<T extends ScannerPayload>(
87
+ client: Pick<HeadlessPaneApiClient, "subscribeScanner">,
88
+ scanner: ScannerKind,
89
+ signal: AbortSignal,
90
+ ): Promise<T> {
91
+ return loadScannerSnapshot<T>(client, scanner, signal, HEADLESS_SCANNER_WAIT_MS, { acceptStarting: true });
92
+ }
93
+
66
94
  /**
67
95
  * The scanner says which instance served it, real-time or the delayed one free
68
96
  * accounts get, and whether it is running: a closed session's scan is final,
@@ -70,7 +98,7 @@ export function loadHiloSnapshot(
70
98
  */
71
99
  function scannerFreshness(payload: Pick<ScannerHiloPayload, "access" | "delayMinutes" | "status">): HeadlessPaneFreshness {
72
100
  if (payload.status === "closed") return { status: "not-a-feed", basis: "closed session" };
73
- if (payload.status === "degraded") return { status: "stale" };
101
+ if (payload.status === "degraded" || payload.status === "starting") return { status: "stale" };
74
102
  return payload.access === "realtime" ? { status: "live" } : { status: "delayed", delayMinutes: payload.delayMinutes };
75
103
  }
76
104
 
@@ -84,6 +112,10 @@ function projectHiloSnapshot(
84
112
  return {
85
113
  asOf: new Date(payload.asOf).toISOString(),
86
114
  items: [...lows, ...highs],
115
+ // The lists are the session's: between sessions the scanner holds none, and last session's are not today's.
116
+ empty: payload.status === "closed" ? "The US market is closed. New highs and lows list again from the next session's open."
117
+ : payload.status === "starting" ? SCANNER_STARTING_TEXT
118
+ : "No new highs or lows under these filters this session.",
87
119
  ...(payload.status === "degraded" ? { errors: ["Scanner feed degraded"] } : {}),
88
120
  freshness: scannerFreshness(payload),
89
121
  metadata: {
@@ -107,7 +139,7 @@ export interface HiloHeadlessDependencies {
107
139
  }
108
140
 
109
141
  const defaultDependencies: HiloHeadlessDependencies = {
110
- load: (_args, client, signal) => loadHiloSnapshot(client, signal),
142
+ load: (_args, client, signal) => loadReportSnapshot<ScannerHiloPayload>(client, "hilo", signal),
111
143
  };
112
144
 
113
145
  export function createHiloHeadless(
@@ -279,7 +311,8 @@ function projectFlowReport(
279
311
  title: symbol ? `${symbol} prints` : "Prints",
280
312
  columns: PRINT_COLUMNS,
281
313
  rows: prints.map((event) => ({ ...event })),
282
- empty: symbol ? `No ${symbol} prints under these filters.` : "No prints on the tape under these filters.",
314
+ empty: payload.status === "starting" ? SCANNER_STARTING_TEXT
315
+ : symbol ? `No ${symbol} prints under these filters.` : "No prints on the tape under these filters.",
283
316
  });
284
317
  }
285
318
  if (shows("tide")) {
@@ -331,7 +364,7 @@ interface FlowHeadlessDependencies {
331
364
  }
332
365
 
333
366
  const flowDependencies: FlowHeadlessDependencies = {
334
- load: (_args, client, signal) => loadScannerSnapshot<ScannerFlowPayload>(client, "flow", signal),
367
+ load: (_args, client, signal) => loadReportSnapshot<ScannerFlowPayload>(client, "flow", signal),
335
368
  recorded: (search, client, signal) => client.getScannerFlowHistory(search, signalWithTimeout(signal, 20_000)),
336
369
  session: (search, client, signal) => client.getScannerFlowSession(search, signalWithTimeout(signal, 20_000)),
337
370
  };
@@ -375,11 +408,17 @@ export function createFlowHeadless(
375
408
  const refuse = async (error: unknown): Promise<never> => {
376
409
  throw await explainRefusal(error, flowLockNote, { symbol, context: ctx });
377
410
  };
378
- // The live feed answers the entitlement first, as the pane's does.
411
+ // The live feed answers the entitlement first, as the pane's does; it waits HEADLESS_SCANNER_WAIT_MS at most.
412
+ const startedAt = Date.now();
379
413
  const payload = await dependencies.load(args, ctx.apiClient, ctx.signal).catch(refuse);
380
- // The recorded prints and the session's sums add to the tape: one that
381
- // fails (a timeout, a server without the route) is said under errors and
382
- // the rest of the report stands. A wall still refuses the whole read.
414
+ // The recorded prints and the session's sums add to the tape in what is
415
+ // left of FLOW_REPORT_BUDGET_MS: one that fails (a timeout, a server
416
+ // without the route) is said under errors and the rest of the report
417
+ // stands. A wall still refuses the whole read.
418
+ const leftMs = Math.max(0, FLOW_REPORT_BUDGET_MS - (Date.now() - startedAt));
419
+ const outOfTime = new AbortController();
420
+ const deadline = setTimeout(() => outOfTime.abort(), leftMs);
421
+ const budget = AbortSignal.any([ctx.signal, outOfTime.signal]);
383
422
  const failures: string[] = [];
384
423
  const extra = async <T>(load: Promise<T> | null, what: string): Promise<T | null> => {
385
424
  if (!load) return null;
@@ -387,7 +426,7 @@ export function createFlowHeadless(
387
426
  return await load;
388
427
  } catch (error) {
389
428
  if (ctx.signal.aborted || refusedLock(error)) return refuse(error);
390
- failures.push(`${what} unavailable: ${errorMessage(error)}`);
429
+ failures.push(`${what} unavailable: ${outOfTime.signal.aborted ? `no answer within ${Math.round(leftMs / 1000)} s` : errorMessage(error)}`);
391
430
  return null;
392
431
  }
393
432
  };
@@ -395,10 +434,10 @@ export function createFlowHeadless(
395
434
  const wantsSession = !tab || tab === "tide" || tab === "strikes";
396
435
  const [recorded, session] = await Promise.all([
397
436
  extra(symbol && wantsPrints
398
- ? dependencies.recorded(flowHistorySearch(flowHistoryQuery(filters, scope, undefined, FLOW_REPORT_RECORDED)), ctx.apiClient, ctx.signal)
437
+ ? dependencies.recorded(flowHistorySearch(flowHistoryQuery(filters, scope, undefined, FLOW_REPORT_RECORDED)), ctx.apiClient, budget)
399
438
  : null, "Recorded prints"),
400
- extra(wantsSession ? dependencies.session(flowSessionSearch(filters, scope), ctx.apiClient, ctx.signal) : null, "Session totals"),
401
- ]);
439
+ extra(wantsSession ? dependencies.session(flowSessionSearch(filters, scope), ctx.apiClient, budget) : null, "Session totals"),
440
+ ]).finally(() => clearTimeout(deadline));
402
441
  // Asked for the session's sums alone, a failure to read them is the report's.
403
442
  if (!wantsPrints && failures.length > 0) throw new Error(failures[0]);
404
443
  const report = projectFlowReport({ payload, recorded, session }, filters, scope, wantsSession && !session ? "prints" : tab);
@@ -6,7 +6,7 @@ import { LOOKBACK_OPTIONS, SeasonalityPane } from "./pane";
6
6
  export const seasonalityModule: PluginModule = {
7
7
  panes: [{
8
8
  id: "seasonality", name: "Seasonality", icon: "S", component: SeasonalityPane,
9
- defaultPosition: "right", tickerFollower: true, defaultMode: "floating", defaultFloatingSize: { width: 112, height: 30 },
9
+ defaultPosition: "right", shareItem: { ticker: true }, tickerFollower: true, defaultMode: "floating", defaultFloatingSize: { width: 112, height: 30 },
10
10
  tableExport: true,
11
11
  settings: { title: "Seasonality Settings", fields: [
12
12
  { key: "lookbackYears", label: "Lookback", type: "select", options: LOOKBACK_OPTIONS },
@@ -640,6 +640,7 @@ export const secModule: PluginModule = {
640
640
  icon: "S",
641
641
  component: SecView,
642
642
  defaultPosition: "right",
643
+ shareItem: { ticker: true },
643
644
  tickerFollower: true,
644
645
  defaultMode: "floating",
645
646
  defaultFloatingSize: { width: 100, height: 32 },
@@ -42,7 +42,7 @@ export const SERIES_INVENTORY: readonly SeriesInventoryEntry[] = [
42
42
  { module: "options-scenario", chart: "Option payoff by underlying price", notInCatalog: "not-a-time-series", reason: "A payoff curve over prices." },
43
43
  { module: "kelly-sizer", chart: "Position size against win rate", notInCatalog: "account", reason: "Drawn from the inputs typed into the sizer." },
44
44
  { module: "yield-curve", chart: "Treasury curve and each maturity's history", series: ["ust:*", "fred:T10Y2Y", "fred:T10Y3M", "fred:DFII*"] },
45
- { module: "yield-curve", chart: "Government curves for Germany, the UK, Japan, Canada and euro AAA", series: ["bond-yield:*"] },
45
+ { module: "yield-curve", chart: "Government curves for Germany, the UK, Japan, Canada, euro AAA, Mexico and Brazil", series: ["bond-yield:*"] },
46
46
  { module: "rate-path", chart: "Implied policy path by meeting", notInCatalog: "not-a-time-series", reason: "A path over future meetings; the rates it starts from are FRED series in the catalog." },
47
47
  { module: "money-markets", chart: "Money market rates, bill yields, liquidity and net liquidity", series: ["money-markets:*", "fred:SOFR", "fred:EFFR", "fred:IORB", "fred:OBFR", "fred:DTB*", "fred:RRPONTSYD", "fred:WDTGAL", "fred:WRESBAL", "fred:WALCL"] },
48
48
  { module: "central-bank-rates", chart: "Policy rate history for each central bank", series: ["policy-rate:*"] },
@@ -51,19 +51,23 @@ const SCANNER_LABELS: Record<ScannerKind, string> = {
51
51
  * Resolves on the first live or closed payload, or on the server's refusal. A
52
52
  * degraded payload is kept and returned only if nothing better arrives before
53
53
  * the deadline, since a scanner warming up can pass through a stale row on its
54
- * way to live.
54
+ * way to live. With `acceptStarting`, so is a starting one, for a report that
55
+ * says the scanner is starting rather than failing; a screenshot keeps failing
56
+ * on one, as it would only picture an empty pane.
55
57
  */
56
58
  export function captureScannerEvent(
57
59
  client: ScannerClient,
58
60
  scanner: ScannerKind,
59
61
  signal: AbortSignal,
60
62
  timeoutMs = SCANNER_SNAPSHOT_TIMEOUT_MS,
63
+ { acceptStarting = false }: { acceptStarting?: boolean } = {},
61
64
  ): Promise<ScannerFeedEvent> {
62
65
  const label = SCANNER_LABELS[scanner];
63
66
  return new Promise((resolve, reject) => {
64
67
  let settled = false;
65
68
  let unsubscribe: (() => void) | null = null;
66
69
  let degraded: ScannerFeedEvent | null = null;
70
+ let starting: ScannerFeedEvent | null = null;
67
71
  const finish = (callback: () => void) => {
68
72
  if (settled) return;
69
73
  settled = true;
@@ -76,7 +80,8 @@ export function captureScannerEvent(
76
80
  ? signal.reason
77
81
  : new Error(`${label} snapshot aborted`)));
78
82
  const timer = setTimeout(() => finish(() => {
79
- if (degraded) resolve(degraded);
83
+ const latest = degraded ?? starting;
84
+ if (latest) resolve(latest);
80
85
  else reject(new Error(`${label} snapshot timed out`));
81
86
  }), timeoutMs);
82
87
  signal.addEventListener("abort", onAbort, { once: true });
@@ -85,7 +90,10 @@ export function captureScannerEvent(
85
90
  finish(() => resolve(event));
86
91
  return;
87
92
  }
88
- if (event.payload.status === "starting") return;
93
+ if (event.payload.status === "starting") {
94
+ if (acceptStarting) starting = event;
95
+ return;
96
+ }
89
97
  if (event.payload.status === "degraded") {
90
98
  degraded = event;
91
99
  return;
@@ -15,6 +15,7 @@ import { FILL_REST } from "../../../components/ui/fill";
15
15
  import { useShortcut } from "../../../react/input";
16
16
  import { Box, ScrollBox, useUiCapabilities } from "../../../ui";
17
17
  import { isPlainKey } from "../../../utils/keyboard";
18
+ import { usePaneShareItem, type PaneShareItemPart } from "../../../shares/pane-item";
18
19
 
19
20
  /** Below this the detail sits under the table instead of beside it. */
20
21
  const SPLIT_MIN_WIDTH = 108;
@@ -54,6 +55,7 @@ export function useSeriesList<Item, R extends string>({
54
55
  onSelect,
55
56
  reload,
56
57
  range,
58
+ shareItem,
57
59
  }: {
58
60
  focused: boolean;
59
61
  /** Every selectable series, in list order. */
@@ -66,6 +68,8 @@ export function useSeriesList<Item, R extends string>({
66
68
  onSelect: (id: string) => void;
67
69
  reload: () => void;
68
70
  range: Pick<QueryBarView<R>, "value" | "options" | "onChange" | "chartRange">;
71
+ /** What a link to the pane says it is on: the series its detail shows. */
72
+ shareItem?: (item: Item) => PaneShareItemPart | null;
69
73
  }) {
70
74
  const [query, setQuery] = useState("");
71
75
  const { active: searchFocused, searchProps } = useQueryBarSearch();
@@ -93,6 +97,7 @@ export function useSeriesList<Item, R extends string>({
93
97
  const selected = items.find((item) => getId(item) === selectedId) ?? items[0] ?? null;
94
98
  const selectedItemId = selected ? getId(selected) : null;
95
99
  const selectionOnScreen = visible.some((item) => getId(item) === selectedItemId);
100
+ usePaneShareItem(selected && shareItem ? () => shareItem(selected) : null);
96
101
 
97
102
  const choose = useCallback((id: string, reason: DataTableSelectionChangeReason) => {
98
103
  if (!shouldPersistSelection({
@@ -58,6 +58,7 @@ export const shortInterestModule: PluginModule = {
58
58
  icon: "S",
59
59
  component: ShortInterestSurface,
60
60
  defaultPosition: "right",
61
+ shareItem: { ticker: true },
61
62
  tickerFollower: followsWithoutFinraOverride,
62
63
  defaultMode: "floating",
63
64
  defaultFloatingSize: { width: 90, height: 25 },
@@ -14,7 +14,7 @@ const socialMentionsSettings = [
14
14
  export const socialMentionsModule: PluginModule = {
15
15
  series: SOCIAL_MENTION_SERIES,
16
16
  panes: [{ id: "social-mentions", reportLockNote: socialMentionsLockNote, name: "Social Mentions", icon: "B", get component(): typeof import("./pane").SocialMentionsPane { const { SocialMentionsPane } = require("./pane"); return SocialMentionsPane; },
17
- defaultPosition: "right", tickerFollower: true, defaultMode: "floating", defaultFloatingSize: { width: 96, height: 30 },
17
+ defaultPosition: "right", shareItem: { ticker: true }, tickerFollower: true, defaultMode: "floating", defaultFloatingSize: { width: 96, height: 30 },
18
18
  tableExport: true, headless: socialMentionsHeadless, settings: { title: "Social Mentions", fields: socialMentionsSettings } }],
19
19
  paneTemplates: [{ ...createTickerSurfacePaneTemplate({ id: "social-mentions-pane", paneId: "social-mentions", label: "Social Mentions",
20
20
  description: "Daily posts on X naming the ticker's cashtag, the day's top posts and their stance; alone, the tickers whose posts jump above their own median.",
@@ -14,6 +14,7 @@ export const supplyChainModule: PluginModule = {
14
14
  dispose() { supplyChainCache.reset(); graphCache.reset(); },
15
15
  panes: [{ id: "supply-chain", name: "Supply Chain", icon: "S", get component(): typeof import("./pane").SupplyChainPane { const { SupplyChainPane } = require("./pane"); return SupplyChainPane; },
16
16
  defaultPosition: "right", defaultMode: "floating", defaultFloatingSize: { width: 130, height: 30 },
17
+ shareItem: { ticker: true },
17
18
  tickerFollower: true, instruments: ["equity"], tableExport: true, headless: supplyChainHeadless }],
18
19
  paneTemplates: [{ ...createTickerSurfacePaneTemplate({ id: "supply-chain-pane", paneId: "supply-chain", label: "Supply Chain",
19
20
  description: "Pro global supply chain evidence from filings, company announcements, calls and news, with trust tiers, original quotes, native units, four-hop graphs, ranked paths and a free preview.",
@@ -141,6 +141,38 @@ export function thirteenFReadError(error: unknown): unknown {
141
141
  );
142
142
  }
143
143
 
144
+ /** What a 13F read says when Gloom Cloud was reached and its 13F source failed. */
145
+ export const THIRTEENF_SOURCE_UNAVAILABLE = "The 13F source is unavailable right now";
146
+
147
+ /**
148
+ * A 13F read the service answered with a failure of its own (a 5xx: the 13F
149
+ * source down and nothing stored to answer for it, or the service busy), in
150
+ * the app's words. It answered, so the connection is not what to check. A
151
+ * failure the service named otherwise (EDGAR's) and any other answer (a rate
152
+ * limit, a refused parameter) are as they came.
153
+ */
154
+ function thirteenFSourceError(error: unknown): unknown {
155
+ if (!(error instanceof ApiRequestError) || error.status === undefined || error.status < 500) return error;
156
+ if (error.code && error.code !== "source_unavailable") return error;
157
+ return new ApiRequestError(THIRTEENF_SOURCE_UNAVAILABLE, error.status, error.retryAfterMs, "source_unavailable", error.details);
158
+ }
159
+
160
+ /**
161
+ * When the copy Gloom Cloud answered from was read from the 13F source (ms),
162
+ * or null for a fresh answer. While the source is unavailable the service
163
+ * answers from a copy it stored, each row saying when it was read
164
+ * (`stored_as_of`); the oldest is the answer's.
165
+ */
166
+ function storedCopyTime(value: unknown): number | null {
167
+ const rows = Array.isArray(value) ? value : [value];
168
+ let oldest = Number.POSITIVE_INFINITY;
169
+ for (const row of rows) {
170
+ const at = Date.parse(stringOrEmpty(asRecord(row).stored_as_of));
171
+ if (Number.isFinite(at)) oldest = Math.min(oldest, at);
172
+ }
173
+ return Number.isFinite(oldest) ? oldest : null;
174
+ }
175
+
144
176
  async function fetchForms13F<T>(
145
177
  path: string,
146
178
  params: Record<string, string | number | undefined>,
@@ -184,22 +216,33 @@ async function fetchForms13F<T>(
184
216
  } catch (cloudError) {
185
217
  options.signal?.throwIfAborted();
186
218
  const error = thirteenFReadError(cloudError);
187
- if (options.cloudOnly) throw error;
219
+ if (options.cloudOnly) throw thirteenFSourceError(error);
188
220
  const url = `${FORMS_13F_BASE_URL}${path}?${searchParams.toString()}`;
189
- // The service's own limit says when to ask again; a direct read that fails as well says less.
221
+ // A service that answered says what failed (its limit and when to ask again, its source being
222
+ // down); a direct read that cannot connect as well says less: the source is down, not this
223
+ // computer's connection.
224
+ const answered = !isNetworkFailure(error);
190
225
  const response = await httpFetch(url, {
191
226
  headers: { Accept: "application/json" },
192
227
  signal: options.signal,
193
228
  }).catch((fallbackError: unknown) => {
194
- throw isRateLimited(error) ? error : fallbackError;
229
+ throw answered ? thirteenFSourceError(error) : fallbackError;
195
230
  });
196
231
  if (!response.ok) {
197
232
  if (isRateLimited(error)) throw error;
198
- throw new ApiRequestError(`Forms13F ${response.status} for ${path}`, response.status);
233
+ throw thirteenFSourceError(new ApiRequestError(`Forms13F ${response.status} for ${path}`, response.status));
199
234
  }
200
235
  value = await response.json() as T;
201
236
  }
202
237
  options.signal?.throwIfAborted();
238
+ // The service's stored copy, while its 13F source is unavailable: said like a saved copy, and
239
+ // not kept as a fresh one, so the next read asks again.
240
+ const storedAt = storedCopyTime(value);
241
+ if (storedAt != null) {
242
+ if (current()) failedRefreshes.add(key);
243
+ options.onSavedCopy?.(storedAt);
244
+ return value;
245
+ }
203
246
  if (current()) {
204
247
  failedRefreshes.delete(key);
205
248
  if (value != null && options.cache !== false) {
@@ -13,7 +13,7 @@ import {
13
13
  searchThirteenFFunds,
14
14
  } from "./api";
15
15
  import { isoDateDaysAgo, isoDateToday, isoDateYearsAgo } from "../../../utils/calendar-date";
16
- import { abortable, withDeadline } from "../../../utils/async-deadline";
16
+ import { abortable, OperationTimeoutError, withDeadline } from "../../../utils/async-deadline";
17
17
  import { logFailure } from "../../../utils/log-failure";
18
18
  import {
19
19
  amendmentKind,
@@ -27,6 +27,7 @@ import {
27
27
  dedupeLatestForms,
28
28
  filingSplitCandidates,
29
29
  type FilingQuarterReturn,
30
+ type SplitFactors,
30
31
  } from "./model";
31
32
  import { mapWithConcurrency } from "../../../utils/concurrency";
32
33
  import { describeTickerChange, movedAwayChange, startTickerChangeLookup } from "../../../tickers/ticker-changes";
@@ -373,6 +374,8 @@ export interface FundPerformanceResult extends BrowserLoadResult {
373
374
  /** Lines of a filings estimate split between the filings (priced split-adjusted) and those left out; see estimateFilingQuarterReturn. */
374
375
  splits?: FilingQuarterReturn["splits"];
375
376
  skipped?: FilingQuarterReturn["skipped"];
377
+ /** What the lines left out weighed in the book at the quarter's start, as a fraction. */
378
+ skippedShare?: number;
376
379
  /** What EDGAR shows for the quarter after the fund's latest report, when it is behind (loadFundDetail). */
377
380
  filingGap?: ThirteenFFilingGap | null;
378
381
  /** Why there is no estimate, when there is none. */
@@ -429,31 +432,60 @@ const SPLIT_LOOKUP_CONCURRENCY = 6;
429
432
  /** How long one ticker's corporate actions are waited for before its split reads as unconfirmed. */
430
433
  const SPLIT_LOOKUP_TIMEOUT_MS = 10_000;
431
434
 
435
+ /** Which split candidates loadSplitFactors reads. */
436
+ export interface SplitFactorScope {
437
+ /** Only these row ids: a report of a large filer's biggest positions reads theirs, not the hundreds of lines across its book that move like a split. */
438
+ only?: ReadonlySet<string>;
439
+ /**
440
+ * How long the whole pass may take. Lines are read largest first, and one not answered by then reads as
441
+ * unconfirmed, as a lookup past its own timeout does, and is listed in the result's `late`.
442
+ */
443
+ budgetMs?: number;
444
+ }
445
+
432
446
  /**
433
447
  * The split factor between a fund's two quarter ends for each of its split
434
448
  * candidates (filingSplitCandidates), by row id, for estimateFilingQuarterReturn
435
449
  * and the Holdings rows: a few lookups at once, each as the lookup answers it.
436
450
  * A line the lookup cannot answer for (no ticker, a failure, no answer in time)
437
- * is null, unconfirmed. Only an abort rejects. A fund with no candidates, or
438
- * without two comparable quarters, makes no lookup.
451
+ * is null, unconfirmed; one the budget ran out on is in `late` as well. Only
452
+ * an abort rejects. A fund with no candidates, or without two comparable
453
+ * quarters, makes no lookup.
439
454
  */
440
- export async function loadSplitFactors(detail: FundDetailData, lookup: SplitFactorLookup, signal?: AbortSignal): Promise<Map<string, number | null>> {
455
+ export async function loadSplitFactors(
456
+ detail: FundDetailData,
457
+ lookup: SplitFactorLookup,
458
+ signal?: AbortSignal,
459
+ scope: SplitFactorScope = {},
460
+ ): Promise<Map<string, number | null> & { late: ReadonlySet<string> }> {
461
+ const late = new Set<string>();
441
462
  const period = detail.latestForm?.periodOfReport;
442
463
  const previousPeriod = detail.previousForm?.periodOfReport;
443
- if (!period || !previousPeriod) return new Map();
444
- return new Map(await mapWithConcurrency(filingSplitCandidates(detail), SPLIT_LOOKUP_CONCURRENCY, async (line) => {
464
+ if (!period || !previousPeriod) return Object.assign(new Map<string, number | null>(), { late });
465
+ const candidates = filingSplitCandidates(detail).filter((line) => !scope.only || scope.only.has(line.id));
466
+ const endsAt = scope.budgetMs == null ? Infinity : Date.now() + scope.budgetMs;
467
+ const factors = await mapWithConcurrency(candidates, SPLIT_LOOKUP_CONCURRENCY, async (line) => {
445
468
  signal?.throwIfAborted();
446
469
  if (!line.ticker) return [line.id, null] as const;
470
+ const left = Math.min(SPLIT_LOOKUP_TIMEOUT_MS, endsAt - Date.now());
471
+ if (left <= 0) {
472
+ late.add(line.id);
473
+ return [line.id, null] as const;
474
+ }
475
+ // A deadline shorter than a lookup's own is the budget's end.
476
+ const budgetEnds = left < SPLIT_LOOKUP_TIMEOUT_MS;
447
477
  const factor = await abortable(
448
- withDeadline(lookup(line.ticker, previousPeriod, period), SPLIT_LOOKUP_TIMEOUT_MS, `${line.ticker} split lookup timed out`),
478
+ withDeadline(lookup(line.ticker, previousPeriod, period), left, `${line.ticker} split lookup timed out`),
449
479
  signal,
450
480
  "Split lookup aborted",
451
481
  ).catch((error: unknown) => {
452
482
  if (signal?.aborted) throw error;
483
+ if (budgetEnds && error instanceof OperationTimeoutError) late.add(line.id);
453
484
  return null;
454
485
  });
455
486
  return [line.id, factor] as const;
456
- }));
487
+ });
488
+ return Object.assign(new Map<string, number | null>(factors), { late });
457
489
  }
458
490
 
459
491
  /**
@@ -468,7 +500,7 @@ export async function loadFundPerformance(
468
500
  cik: string,
469
501
  fallbackName: string,
470
502
  signal?: AbortSignal,
471
- options: Pick<Forms13FReadOptions, "forceRefresh" | "onSavedCopy"> & { splitFactor?: SplitFactorLookup } = {},
503
+ options: Pick<Forms13FReadOptions, "forceRefresh" | "onSavedCopy"> & { splitFactor?: SplitFactorLookup; splitBudgetMs?: number } = {},
472
504
  ): Promise<FundPerformanceResult> {
473
505
  const warnings: string[] = [];
474
506
  const saved = savedCopies(options.onSavedCopy);
@@ -490,7 +522,7 @@ export async function loadFundPerformance(
490
522
  const own = ranked?.find((fund) => fund.cik === detail.cik && fund.periodOfReport === period);
491
523
  const ranking = !quarter ? null : !ranked ? "unavailable" : own ? "ranked" : "unranked";
492
524
  // A line that moved as across a split is priced by its corporate actions: split-adjusted, as a trade, or left out unread.
493
- const factors = own?.pnl != null || !options.splitFactor ? new Map<string, number | null>() : await loadSplitFactors(detail, options.splitFactor, signal);
525
+ const factors: SplitFactors = own?.pnl != null || !options.splitFactor ? new Map() : await loadSplitFactors(detail, options.splitFactor, signal, { budgetMs: options.splitBudgetMs });
494
526
  const filed = own?.pnl != null ? null : estimateFilingQuarterReturn(detail, factors);
495
527
  const estimate = own?.pnl ?? filed?.percent ?? null;
496
528
  const basis = own?.pnl != null ? "ranking" : estimate != null ? "filings" : null;
@@ -520,6 +552,7 @@ export async function loadFundPerformance(
520
552
  rows: [row], ...(quarter ? { quarter } : {}), ...(period ? { period } : {}), hasMore: false, basis, ranking,
521
553
  ...(filed?.splits.length ? { splits: filed.splits } : {}),
522
554
  ...(filed?.skipped.length ? { skipped: filed.skipped } : {}),
555
+ ...(filed?.skippedShare != null ? { skippedShare: filed.skippedShare } : {}),
523
556
  ...(detail.filingGap ? { filingGap: detail.filingGap } : {}),
524
557
  ...(unavailable ? { unavailable } : {}), ...(warning ? { warning } : {}),
525
558
  };
@@ -72,6 +72,7 @@ import {
72
72
  sortBrowserRows,
73
73
  sortHoldingRows,
74
74
  sortTimelineRows,
75
+ type SplitFactors,
75
76
  } from "./model";
76
77
  import {
77
78
  actionLabel,
@@ -216,8 +217,8 @@ export interface ThirteenFHeadlessDependencies {
216
217
  args: HeadlessPaneLoadArgs,
217
218
  ctx: HeadlessPaneContext,
218
219
  ): Promise<FundDetailData>;
219
- /** The split factor of each of a fund's split candidates between its two quarter ends (loadSplitFactors), for its Est P&L. */
220
- loadSplitFactors?(detail: FundDetailData, ctx: HeadlessPaneContext): Promise<Map<string, number | null>>;
220
+ /** The split factor of each of a fund's split candidates between its two quarter ends (loadSplitFactors), for its Est P&L; with `only`, of those rows alone. */
221
+ loadSplitFactors?(detail: FundDetailData, ctx: HeadlessPaneContext, only?: ReadonlySet<string>): Promise<SplitFactors>;
221
222
  /** What a fund in a search filed for the newest quarter past its deadline, from EDGAR. */
222
223
  loadFilingGap?(cik: string, latestPeriod: string | null | undefined, ctx: HeadlessPaneContext): Promise<ThirteenFFilingGap | null>;
223
224
  /** 13F filers whose names contain `query`, without their reports. */
@@ -255,6 +256,16 @@ async function readingSavedCopies<T extends object>(ctx: HeadlessPaneContext, ru
255
256
  }
256
257
  }
257
258
 
259
+ /**
260
+ * How long a report waits on its split lookups, largest lines first. A large
261
+ * filer off the ranking has a few hundred lines that move like a split (its
262
+ * Est 13F reads them all), and its 200 largest can hold dozens (its Holdings
263
+ * read theirs); read cold, they took 15 to 35 s, past what an Ask Gloom tool
264
+ * call is given. A line not read in time has no Est P&L, is left out of the
265
+ * Est 13F, and is named as one the time ran out on.
266
+ */
267
+ const SPLIT_LOOKUP_BUDGET_MS = 8_000;
268
+
258
269
  const defaultDependencies: Required<ThirteenFHeadlessDependencies> = {
259
270
  loadBrowser: (tab, query, limit, _args, ctx) => loadBrowserRows(
260
271
  tab,
@@ -264,15 +275,17 @@ const defaultDependencies: Required<ThirteenFHeadlessDependencies> = {
264
275
  ),
265
276
  // An overlap never shows a fund's missed quarter, so it does not ask EDGAR.
266
277
  loadDetail: (cik, name, args, ctx) => loadFundDetail(cik, name, ctx.signal, { filingGap: !isOverlapLoad(args), onSavedCopy: noteSavedCopy(ctx) }),
267
- loadSplitFactors: (detail, ctx) => loadSplitFactors(
278
+ loadSplitFactors: (detail, ctx, only) => loadSplitFactors(
268
279
  detail,
269
280
  (ticker, after, through) => corporateSplitFactor(ctx.marketData, ticker, after, through),
270
281
  ctx.signal,
282
+ { only, budgetMs: SPLIT_LOOKUP_BUDGET_MS },
271
283
  ),
272
284
  loadFilingGap: (cik, latestPeriod, ctx) => loadFilingGap(cik, latestPeriod, ctx.signal),
273
285
  searchFunds: (query, ctx) => searchThirteenFFunds(query, THIRTEENF_MAX_LIMIT, ctx.signal),
274
286
  loadPerformance: (cik, name, ctx) => loadFundPerformance(cik, name, ctx.signal, {
275
287
  splitFactor: (ticker, after, through) => corporateSplitFactor(ctx.marketData, ticker, after, through),
288
+ splitBudgetMs: SPLIT_LOOKUP_BUDGET_MS,
276
289
  onSavedCopy: noteSavedCopy(ctx),
277
290
  }),
278
291
  loadEtfFunds: async (ctx) => (await fetchFunds(ctx.apiClient)).funds,
@@ -333,10 +346,24 @@ function browserTab(view: HeadlessThirteenFView, query: string): ThirteenFBrowse
333
346
  /** What to search by instead, after a search that found no 13F filer. */
334
347
  const SEARCH_HINT = 'Search by fund name or CIK, as in fn 13F "Berkshire Hathaway".';
335
348
 
349
+ /** Legal forms a manager's filed name ends with and nobody says: "Citadel Advisors" is CITADEL ADVISORS LLC. */
350
+ const LEGAL_FORMS = new Set(["llc", "lp", "llp", "lllp", "pllc", "inc", "incorporated", "corp", "corporation", "co", "company", "ltd", "limited", "plc", "sa", "ag", "gmbh", "nv", "bv", "se", "the"]);
351
+
352
+ /** A manager's name as said: lowercase words, without punctuation or a trailing legal form. */
353
+ function spokenName(name: string): string {
354
+ const words = name.toLocaleLowerCase().replace(/\./g, "").split(/[^\p{L}\p{N}&]+/u).filter(Boolean);
355
+ while (words.length > 1 && LEGAL_FORMS.has(words.at(-1)!)) words.pop();
356
+ return words.join(" ");
357
+ }
358
+
336
359
  /**
337
360
  * The manager a fund name or CIK names: a CIK as given, else the one fund
338
- * whose name matches exactly, else the only match. `search` lists funds by
339
- * name, as the 13F browser does.
361
+ * whose name matches exactly, as said without its legal form, or as the
362
+ * first whole words of its name ("ARK Investment Management" is ARK
363
+ * Investment Management LLC, not Spark Investment Management), else the only
364
+ * match. Several managers that fit are named, those that fit first and the
365
+ * largest books first, for the caller to pick one by CIK. `search` lists
366
+ * funds by name, as the 13F browser does.
340
367
  */
341
368
  async function findThirteenFFund(
342
369
  query: string,
@@ -348,13 +375,27 @@ async function findThirteenFFund(
348
375
  const result = await search(query, 25);
349
376
  await result.reportsLoaded;
350
377
  const candidates = [...new Map(result.rows.map((row) => [row.cik, row])).values()];
378
+ const said = spokenName(query);
351
379
  const exact = candidates.filter((row) => row.name.toLocaleLowerCase() === query.toLocaleLowerCase());
352
- if (exactOnly) return exact.length === 1 ? { cik: exact[0]!.cik, name: exact[0]!.name } : null;
353
- const fund = exact.length === 1 ? exact[0]
354
- : candidates.length === 1 && !result.hasMore ? candidates[0] : undefined;
380
+ const named = candidates.filter((row) => spokenName(row.name) === said);
381
+ const leading = candidates.filter((row) => spokenName(row.name).startsWith(`${said} `) || spokenName(row.name) === said);
382
+ const only = (rows: typeof candidates) => (rows.length === 1 ? rows[0] : undefined);
383
+ // A word that may be a ticker ("SPY") names a manager only by its exact name, never by "SPY Inc".
384
+ if (exactOnly) {
385
+ const match = only(exact);
386
+ return match ? { cik: match.cik, name: match.name } : null;
387
+ }
388
+ // A name only some funds start with names one of them only when the search listed every fund it matched.
389
+ const complete = !result.hasMore;
390
+ const fund = only(exact) ?? only(named) ?? (complete ? only(leading) : undefined) ?? (candidates.length === 1 && complete ? candidates[0] : undefined);
355
391
  if (candidates.length === 0) throw new Error(notFound ?? `No 13F fund found for "${query}". ${SEARCH_HINT}`);
356
392
  if (!fund) {
357
- const choices = candidates.slice(0, 5).map((row) => `${row.name} (${row.cik})`).join("; ");
393
+ const fits = new Set(leading);
394
+ const choices = candidates
395
+ .toSorted((left, right) => Number(fits.has(right)) - Number(fits.has(left)) || (right.tableValueTotal ?? -1) - (left.tableValueTotal ?? -1))
396
+ .slice(0, 5)
397
+ .map((row) => `${row.name} (${row.cik}${row.tableValueTotal ? `, ${formatMoneyCompact(row.tableValueTotal)} reported` : ""})`)
398
+ .join("; ");
358
399
  throw new Error(`Ambiguous 13F fund "${query}". Use an exact fund name or CIK: ${choices}.`);
359
400
  }
360
401
  return { cik: fund.cik, name: fund.name };
@@ -755,8 +796,11 @@ export function createThirteenFHeadless(
755
796
  };
756
797
  }
757
798
  // A line that moved as across a split gets its Est P&L from its corporate actions: split-adjusted, as a trade, or none.
799
+ // The rows go largest value first, which no split moves, so only the rows shown have theirs read: a large
800
+ // filer's book holds hundreds of such lines (Citadel's 264 took 27 s), its top 50 a handful.
801
+ const shown = new Set(sortHoldingRows(buildFundHoldingRows(detail), DEFAULT_HOLDING_SORT).slice(0, limit).map((row) => row.id));
758
802
  const all = sortHoldingRows(
759
- buildFundHoldingRows(detail, await dependencies.loadSplitFactors(detail, ctx)),
803
+ buildFundHoldingRows(detail, await dependencies.loadSplitFactors(detail, ctx, shown)),
760
804
  DEFAULT_HOLDING_SORT,
761
805
  );
762
806
  const previousPeriod = detail.previousForm?.periodOfReport ?? null;
@@ -864,7 +908,7 @@ export function createThirteenFHeadless(
864
908
  ...flagNotices,
865
909
  estimated ? `Est 13F: from the ${estimated} filings, the Est P&L of positions held through the quarter over their value at its start${rankingText ? ` (${rankingText})` : ""}` : "",
866
910
  performance.splits?.length ? splitAdjustedText(performance.splits) : "",
867
- performance.skipped?.length ? splitUnreadText(performance.skipped, "Left out of Est 13F") : "",
911
+ performance.skipped?.length ? splitUnreadText(performance.skipped, "Left out of Est 13F", performance.skippedShare) : "",
868
912
  performance.unavailable ? `No Est 13F${rankingText ? ` (${rankingText})` : ""}: ${performance.unavailable}` : "",
869
913
  ...filingGapNotes(performance.period ?? null, performance.filingGap ?? null),
870
914
  `Copy this basket: gloom portfolio import --13f ${row.cik}`,