@gloom-sh/terminal 0.19.6 → 0.20.1

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 (209) hide show
  1. package/LICENSE +0 -4
  2. package/package.json +6 -5
  3. package/patches/electrobun-devkit@2.0.5.patch +408 -0
  4. package/src/api-client/bond-trades.ts +59 -0
  5. package/src/api-client/crypto-markets.ts +20 -2
  6. package/src/api-client/data.ts +21 -0
  7. package/src/api-client/fund-facts.ts +23 -1
  8. package/src/api-client/index.ts +2 -0
  9. package/src/api-client/types/account.ts +86 -0
  10. package/src/api-client/types/assist.ts +32 -0
  11. package/src/api-client/types/auth.ts +63 -0
  12. package/src/api-client/types/billing.ts +54 -0
  13. package/src/api-client/types/chat.ts +180 -0
  14. package/src/api-client/types/congress.ts +107 -0
  15. package/src/api-client/types/credit.ts +110 -0
  16. package/src/api-client/types/econ.ts +158 -0
  17. package/src/api-client/types/equity-diagnostic.ts +73 -0
  18. package/src/api-client/types/filings-and-calls.ts +356 -0
  19. package/src/api-client/types/index.ts +25 -0
  20. package/src/api-client/types/jobs.ts +147 -0
  21. package/src/api-client/types/market.ts +122 -0
  22. package/src/api-client/types/news.ts +91 -0
  23. package/src/api-client/types/notes-and-theses.ts +172 -0
  24. package/src/api-client/types/quotes.ts +28 -0
  25. package/src/api-client/types/scanners.ts +125 -0
  26. package/src/api-client/types/screener.ts +65 -0
  27. package/src/api-client/types/search.ts +107 -0
  28. package/src/api-client/types/sync.ts +14 -0
  29. package/src/api-client/types/team-collections.ts +43 -0
  30. package/src/api-client/types/team-views.ts +32 -0
  31. package/src/api-client/types/teams.ts +135 -0
  32. package/src/api-client/types/ticker-data.ts +57 -0
  33. package/src/api-client/types/tweets.ts +59 -0
  34. package/src/api-client/types/world-venues.ts +23 -0
  35. package/src/app/runtime/desktop-deeplink.ts +41 -6
  36. package/src/app/runtime/plugin-seed.ts +119 -0
  37. package/src/app/runtime/startup.ts +45 -9
  38. package/src/app/star-prompt/status-line.tsx +1 -1
  39. package/src/app.tsx +2 -7
  40. package/src/architecture/ui-tokens-allowlist.json +0 -8
  41. package/src/cli/board-coins.ts +38 -5
  42. package/src/cli/commands/crypto-hints.ts +8 -1
  43. package/src/cli/commands/market.ts +29 -26
  44. package/src/cli/commands/overview.ts +13 -6
  45. package/src/cli/commands/ticker.ts +78 -18
  46. package/src/cli/company-name-hint.ts +19 -0
  47. package/src/cli/desktop-pane-shot-browser.ts +69 -3
  48. package/src/cli/entry.ts +10 -4
  49. package/src/cli/glossary.ts +25 -0
  50. package/src/cli/helpers.ts +4 -2
  51. package/src/cli/not-a-ticker.ts +26 -1
  52. package/src/cli/pane-functions/catalog.ts +3 -1
  53. package/src/cli/pane-functions/freshness.ts +45 -29
  54. package/src/cli/pane-functions/market-session.ts +14 -5
  55. package/src/cli/restore-plugins.ts +164 -51
  56. package/src/components/chart/composite/use-composite-chart-keyboard.ts +11 -2
  57. package/src/components/chart-table/header.tsx +10 -1
  58. package/src/components/chart-table/layout.ts +14 -5
  59. package/src/components/command-bar/panel/index.tsx +13 -0
  60. package/src/components/command-bar/panel/layout.ts +7 -0
  61. package/src/components/command-bar/panel/runtime.ts +1 -0
  62. package/src/components/command-bar/panel/types.ts +2 -0
  63. package/src/components/data-table/export.ts +4 -1
  64. package/src/components/layout/detached-pane-shell.tsx +10 -37
  65. package/src/components/layout/double-escape-close.ts +90 -0
  66. package/src/components/layout/header.tsx +3 -2
  67. package/src/components/layout/market-summary.ts +6 -3
  68. package/src/components/layout/pane/footer/index.tsx +2 -6
  69. package/src/components/layout/pane/footer/model.ts +6 -12
  70. package/src/components/layout/shell/active-drag.ts +53 -11
  71. package/src/components/layout/shell/drag/magnets.ts +128 -19
  72. package/src/components/layout/shell/pane/actions.ts +6 -2
  73. package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
  74. package/src/components/layout/status-bar.tsx +4 -78
  75. package/src/components/layout/status-widget-space.ts +5 -5
  76. package/src/components/onboarding/portfolio-step/positions-panel.tsx +1 -1
  77. package/src/components/ui/data-table/index.tsx +5 -1
  78. package/src/components/ui/data-table/render-cell.ts +19 -0
  79. package/src/components/ui/delayed-mark.tsx +59 -7
  80. package/src/components/ui/icon.tsx +1 -8
  81. package/src/components/ui/menu.tsx +6 -1
  82. package/src/i18n/es.ts +6 -3
  83. package/src/i18n/ja.ts +6 -3
  84. package/src/i18n/ko.ts +6 -3
  85. package/src/i18n/zh-cn.ts +6 -3
  86. package/src/i18n/zh-tw.ts +6 -3
  87. package/src/market-data/fund-facts.ts +7 -1
  88. package/src/market-data/market/change-basis.ts +20 -0
  89. package/src/market-data/market/format.ts +62 -2
  90. package/src/market-data/market/futures-week.ts +3 -1
  91. package/src/plugins/builtin/chart-composer/headless.ts +57 -17
  92. package/src/plugins/builtin/chart-composer/session-range.ts +82 -3
  93. package/src/plugins/builtin/chat/content/composer.tsx +21 -27
  94. package/src/plugins/builtin/chat/content/index.tsx +31 -3
  95. package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
  96. package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
  97. package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
  98. package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
  99. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +32 -25
  100. package/src/plugins/builtin/congress-trades/model.ts +2 -1
  101. package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
  102. package/src/plugins/builtin/correlation/compute.ts +8 -2
  103. package/src/plugins/builtin/correlation/headless.ts +10 -9
  104. package/src/plugins/builtin/correlation/history.ts +30 -0
  105. package/src/plugins/builtin/correlation/matrix/model.ts +10 -10
  106. package/src/plugins/builtin/correlation/relationship/model.ts +3 -6
  107. package/src/plugins/builtin/correlation/relationship/pane.tsx +1 -2
  108. package/src/plugins/builtin/crypto-board/client.ts +6 -1
  109. package/src/plugins/builtin/crypto-board/defi-view.tsx +12 -1
  110. package/src/plugins/builtin/crypto-board/defi.ts +44 -7
  111. package/src/plugins/builtin/crypto-board/headless.ts +83 -12
  112. package/src/plugins/builtin/crypto-board/model.ts +30 -6
  113. package/src/plugins/builtin/crypto-board/pane.tsx +13 -2
  114. package/src/plugins/builtin/custom-view/index.tsx +1 -1
  115. package/src/plugins/builtin/custom-view/loader.ts +85 -8
  116. package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
  117. package/src/plugins/builtin/equity-screener/criterion-editor.tsx +13 -4
  118. package/src/plugins/builtin/equity-screener/headless.ts +33 -1
  119. package/src/plugins/builtin/equity-screener/model.ts +58 -15
  120. package/src/plugins/builtin/equity-screener/pane.tsx +36 -6
  121. package/src/plugins/builtin/executives/format.ts +5 -4
  122. package/src/plugins/builtin/executives/pane.tsx +1 -1
  123. package/src/plugins/builtin/help/index.tsx +55 -1
  124. package/src/plugins/builtin/insider/model.ts +30 -2
  125. package/src/plugins/builtin/jobs/model.ts +2 -2
  126. package/src/plugins/builtin/mna/model.ts +2 -2
  127. package/src/plugins/builtin/notes/files.ts +2 -0
  128. package/src/plugins/builtin/notes/owner.tsx +20 -1
  129. package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
  130. package/src/plugins/builtin/notes/store.ts +6 -1
  131. package/src/plugins/builtin/perps/headless.ts +8 -2
  132. package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
  133. package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
  134. package/src/plugins/builtin/risk-factors/index.tsx +2 -28
  135. package/src/plugins/builtin/risk-factors/lock-note.ts +58 -0
  136. package/src/plugins/builtin/risk-factors/pane.tsx +10 -3
  137. package/src/plugins/builtin/scanner/hilo-model.ts +4 -3
  138. package/src/plugins/builtin/sec/fund-facts.ts +45 -11
  139. package/src/plugins/builtin/sec/headless.ts +30 -1
  140. package/src/plugins/builtin/sec/index.tsx +26 -5
  141. package/src/plugins/builtin/series-inventory.ts +1 -0
  142. package/src/plugins/builtin/shared/earnings-report.ts +7 -2
  143. package/src/plugins/builtin/shared/pro-lock-note.ts +5 -1
  144. package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
  145. package/src/plugins/builtin/short-interest/headless.ts +1 -1
  146. package/src/plugins/builtin/short-interest/model.ts +15 -6
  147. package/src/plugins/builtin/short-interest/types.ts +2 -0
  148. package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
  149. package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
  150. package/src/plugins/builtin/ticker-detail/overview/model.ts +19 -9
  151. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
  152. package/src/plugins/builtin/time-sales/headless.ts +23 -7
  153. package/src/plugins/builtin/time-sales/index.tsx +2 -2
  154. package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
  155. package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
  156. package/src/plugins/builtin/trace-bonds/history.ts +155 -0
  157. package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
  158. package/src/plugins/extracted-plugins.ts +49 -24
  159. package/src/plugins/installer.ts +234 -32
  160. package/src/plugins/plugin-names.ts +11 -2
  161. package/src/plugins/running-installs.ts +34 -0
  162. package/src/plugins/seed-progress.ts +72 -0
  163. package/src/remote/controller.ts +9 -2
  164. package/src/remote/schema.ts +2 -1
  165. package/src/renderers/cloudflare/http-proxy.ts +67 -8
  166. package/src/renderers/cloudflare/proxy-session.ts +1 -1
  167. package/src/renderers/cloudflare/worker.ts +29 -2
  168. package/src/renderers/dom/desktop/icons.tsx +0 -2
  169. package/src/renderers/dom/styles.css +0 -3
  170. package/src/renderers/electrobun/bun/desktop/backend.ts +14 -0
  171. package/src/renderers/electrobun/bun/desktop/host-requests.ts +14 -7
  172. package/src/renderers/electrobun/bun/desktop/initialization.ts +24 -14
  173. package/src/renderers/electrobun/bun/desktop/install-records.ts +59 -0
  174. package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
  175. package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
  176. package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
  177. package/src/renderers/electrobun/bun/index.ts +24 -13
  178. package/src/renderers/electrobun/bun/window/context-menu-thread.ts +84 -0
  179. package/src/renderers/electrobun/bun/window/create.ts +23 -3
  180. package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +4 -4
  181. package/src/renderers/electrobun/bun/window/events.ts +4 -4
  182. package/src/renderers/electrobun/bun/window/frame.ts +2 -1
  183. package/src/renderers/electrobun/bun/window/native-call-thread.ts +224 -0
  184. package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
  185. package/src/renderers/electrobun/bun/window/native-timing.ts +10 -0
  186. package/src/renderers/electrobun/bun/window/script-for-webview.ts +15 -0
  187. package/src/renderers/electrobun/bun/window/webview-script-thread.ts +82 -0
  188. package/src/renderers/electrobun/shared/protocol.ts +13 -2
  189. package/src/renderers/electrobun/view/backend-rpc.ts +8 -1
  190. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +1 -1
  191. package/src/renderers/electrobun/view/main.tsx +4 -3
  192. package/src/renderers/opentui/start.tsx +3 -0
  193. package/src/sources/gloomberb-cloud/index.ts +5 -7
  194. package/src/sources/provider-router/batches.ts +18 -3
  195. package/src/sources/provider-router/financials.ts +18 -4
  196. package/src/telemetry/stall-reports.ts +21 -4
  197. package/src/types/data-provider.ts +14 -0
  198. package/src/types/financials.ts +15 -3
  199. package/src/types/headless.ts +2 -0
  200. package/src/utils/double-escape-close.ts +38 -16
  201. package/src/utils/format.ts +23 -3
  202. package/src/utils/main-thread-stall.ts +21 -5
  203. package/src/utils/perf-marks.ts +88 -9
  204. package/src/utils/price-earnings.ts +18 -0
  205. package/src/utils/reported-money.ts +9 -2
  206. package/src/utils/sec.ts +34 -3
  207. package/patches/electrobun@1.18.1.patch +0 -633
  208. package/src/api-client/types.ts +0 -2441
  209. package/src/plugins/seed-notice.ts +0 -20
@@ -98,8 +98,9 @@ export function filterHiloRows(
98
98
 
99
99
  /**
100
100
  * What an empty table says. The price filter when rows came in and it hid them all, or when the market is open and
101
- * nothing has printed a new extreme yet. A closed market says so and when it reopens, in the status line's words
102
- * (`Markets closed until Mon.`), as SCAN says its own close: its session has no new highs or lows to count.
101
+ * nothing has printed a new extreme yet. A closed market says so and when it reopens, on the status line's clocks
102
+ * (`Markets closed until Mon 13:30 UTC, 09:30 ET.`), as SCAN says its own close: its session has no new highs or lows
103
+ * to count.
103
104
  */
104
105
  export function hiloEmptyState(
105
106
  { filtered, status, now }: { filtered: boolean; status: ScannerStatus | undefined; now: number },
@@ -107,7 +108,7 @@ export function hiloEmptyState(
107
108
  if (filtered || status !== "closed") return { title: "Nothing above the price filter yet." };
108
109
  const line = venueMarketLine("NYSE", now);
109
110
  return {
110
- title: line?.state === "closed" ? `${line.text[0]!.toUpperCase()}${line.text.slice(1)}.` : "Market closed.",
111
+ title: line?.state !== "closed" ? "Market closed." : line.reopens ? `Markets closed until ${line.reopens}.` : "Markets closed.",
111
112
  hint: "New highs and lows resume at the open.",
112
113
  };
113
114
  }
@@ -1,12 +1,12 @@
1
1
  import { apiClient } from "../../../api-client";
2
- import type { FundFactsPayload, FundLeverage, FundMetalHoldings, FundStructure } from "../../../api-client/fund-facts";
2
+ import type { FundCoinHoldings, FundFactsPayload, FundLeverage, FundMetalHoldings, FundStructure } from "../../../api-client/fund-facts";
3
3
  import type { StatItem } from "../../../components/ui/stat-grid";
4
4
  import { leverageFactorLabel } from "../../../time-series/leverage";
5
5
  import { t, tf } from "../../../i18n";
6
6
  import { createPluginCache } from "../../../data/plugin-cache";
7
7
  import type { HeadlessPaneEntry } from "../../../types/plugin";
8
8
  import { errorMessage } from "../../../utils/errors";
9
- import { formatCompact } from "../../../utils/format";
9
+ import { formatCompact, formatCurrency } from "../../../utils/format";
10
10
  import { bondClassText, bondFigures, DV01_FROM_DURATION, durationDv01PerShare, formatDv01PerShare } from "../../../market-data/bond-funds";
11
11
  import { readFundFacts, validateFundFacts } from "../../../market-data/fund-facts";
12
12
  import { cachedCloudResource, loadCloudResource, unavailableOnServer } from "../shared/cloud-resource";
@@ -55,6 +55,25 @@ function formatNav(value: number): string {
55
55
  return `$${value.toFixed(value < 1 ? 4 : 2)}`;
56
56
  }
57
57
 
58
+ /**
59
+ * A NAV or closing price in the fund's own currency: a Hong Kong counter's
60
+ * (HK$5.2842, $0.6736) to the four decimals its issuer states, a US fund's
61
+ * as before.
62
+ */
63
+ function fundPrice(facts: Pick<FundFactsPayload, "currency">, value: number): string {
64
+ return facts.currency ? formatCurrency(value, facts.currency, 4) : formatNav(value);
65
+ }
66
+
67
+ /** Units in issue per coin held, whole (`3,262`), under the label that names the coin. */
68
+ const unitsPerCoinText = (holdings: FundCoinHoldings) => Math.round(holdings.unitsPerCoin).toLocaleString("en-US");
69
+
70
+ /** `Units per ETH`, `Units per BTC`. */
71
+ const unitsPerCoinLabel = (holdings: FundCoinHoldings) => tf("Units per {asset}", { asset: holdings.asset });
72
+
73
+ /** Coins held as the issuer states them: `18,453 ETH`. */
74
+ const coinsText = (holdings: FundCoinHoldings) =>
75
+ `${holdings.coins.toLocaleString("en-US", { maximumFractionDigits: 4 })} ${holdings.asset}`;
76
+
58
77
  function formatNetAssets(value: number): string {
59
78
  return `$${formatCompact(value)}`;
60
79
  }
@@ -107,7 +126,8 @@ const metalLabel = (holdings: FundMetalHoldings) => holdings.metal === "gold" ?
107
126
  * call a fee a sponsor fee.
108
127
  */
109
128
  function expenseRatioLabel(facts: Pick<FundFactsPayload, "expenseRatio">): string {
110
- return facts.expenseRatio?.kind === "sponsor-fee" ? "Sponsor fee" : "Expense ratio";
129
+ const kind = facts.expenseRatio?.kind;
130
+ return kind === "sponsor-fee" ? "Sponsor fee" : kind === "management-fee" ? "Management fee" : "Expense ratio";
111
131
  }
112
132
 
113
133
  function feeBasis(facts: FundFactsPayload): "net" | "gross" | null {
@@ -220,7 +240,7 @@ export function fundFactItems(facts: FundFactsPayload): StatItem[] {
220
240
  const estimate = facts.nav.estimate;
221
241
  const nav = estimate && dated.nav.detail
222
242
  ? { ...dated.nav, detail: `${dated.nav.detail} · ${tf("est. {range}", { range: estimateRange(estimate) })}` } : dated.nav;
223
- items.push(cell("nav", "NAV", formatNav(facts.nav.value), nav));
243
+ items.push(cell("nav", "NAV", fundPrice(facts, facts.nav.value), nav));
224
244
  }
225
245
  if (facts.premiumDiscount) items.push(cell("premium", "Premium/discount", formatPremiumPercent(facts.premiumDiscount.value), dated.premium));
226
246
  if (facts.expenseRatio) items.push(cell("fee", expenseRatioLabel(facts), formatFeePercent(facts.expenseRatio.value), dated.fee));
@@ -230,6 +250,12 @@ export function fundFactItems(facts: FundFactsPayload): StatItem[] {
230
250
  items.push(cell("shares", "Shares outstanding", formatCompact(facts.sharesOutstanding.value),
231
251
  { detail: facts.sharesOutstanding.asOf ?? undefined, marked: facts.stale }));
232
252
  }
253
+ // A spot coin fund's units per coin, with the coins it holds that day.
254
+ const coins = facts.coinHoldings;
255
+ if (coins) {
256
+ items.push(cell("units-per-coin", unitsPerCoinLabel(coins), unitsPerCoinText(coins),
257
+ { detail: `${coinsText(coins)} · ${coins.asOf}`, marked: facts.stale }));
258
+ }
233
259
  if (facts.flows) {
234
260
  // In dollars with the shares beside them; in shares alone when a day had no NAV to value them at.
235
261
  const flows = facts.flows;
@@ -305,7 +331,7 @@ export function fundFactOverviewFields(facts: FundFactsPayload): FundFactOvervie
305
331
  const forms = figure.detail ? [figure.detail, withoutYear(figure.detail), ...(short ? [short, withoutYear(short)] : [])] : [];
306
332
  return { label, value, ...(forms.length ? { detail: [...new Set(forms)] } : {}), ...(figure.marked ? { warn: true } : {}) };
307
333
  };
308
- if (facts.nav) fields.push(field("NAV", formatNav(facts.nav.value), dated.nav));
334
+ if (facts.nav) fields.push(field("NAV", fundPrice(facts, facts.nav.value), dated.nav));
309
335
  if (facts.premiumDiscount) fields.push(field("Prem/Disc", formatPremiumPercent(facts.premiumDiscount.value), dated.premium, facts.premiumDiscount.asOf ?? undefined));
310
336
  if (facts.netAssets) {
311
337
  // N-PORT's long form gives way to the month end alone before the bare date.
@@ -313,8 +339,9 @@ export function fundFactOverviewFields(facts: FundFactsPayload): FundFactOvervie
313
339
  fields.push(field(wholeFund(facts) ? "Fund Assets" : "Net Assets", formatNetAssets(facts.netAssets.value), dated.netAssets, monthEnd));
314
340
  }
315
341
  if (facts.expenseRatio) {
316
- const fee = facts.expenseRatio.kind === "sponsor-fee";
317
- fields.push(field(fee ? "Sponsor Fee" : "Exp Ratio", formatFeePercent(facts.expenseRatio.value), dated.fee, facts.expenseRatio.asOf ?? undefined));
342
+ const kind = facts.expenseRatio.kind;
343
+ const label = kind === "sponsor-fee" ? "Sponsor Fee" : kind === "management-fee" ? "Mgmt Fee" : "Exp Ratio";
344
+ fields.push(field(label, formatFeePercent(facts.expenseRatio.value), dated.fee, facts.expenseRatio.asOf ?? undefined));
318
345
  }
319
346
  if (facts.inception) fields.push({ label: "Inception", value: facts.inception.value });
320
347
  return fields;
@@ -345,10 +372,10 @@ export function fundFactEntries(facts: FundFactsPayload): HeadlessPaneEntry[] {
345
372
  if (facts.nav) {
346
373
  const date = facts.nav.asOf && monthEndNav(facts) ? `${facts.nav.asOf} month-end` : facts.nav.asOf;
347
374
  const estimate = facts.nav.estimate ? `estimate ${estimateRange(facts.nav.estimate)}` : null;
348
- add("nav", "NAV", facts.nav.value, provenance(formatNav(facts.nav.value), date, estimate, facts.nav.source), "USD");
375
+ add("nav", "NAV", facts.nav.value, provenance(fundPrice(facts, facts.nav.value), date, estimate, facts.nav.source), facts.currency ?? "USD");
349
376
  }
350
377
  if (facts.closingPrice) add("closingPrice", "Closing price", facts.closingPrice.value,
351
- provenance(formatNav(facts.closingPrice.value), facts.closingPrice.asOf, facts.closingPrice.source), "USD");
378
+ provenance(fundPrice(facts, facts.closingPrice.value), facts.closingPrice.asOf, facts.closingPrice.source), facts.currency ?? "USD");
352
379
  if (facts.premiumDiscount) {
353
380
  const basis = facts.premiumDiscount.basis !== "computed" ? null
354
381
  : facts.premiumDiscount.estimate ? "closing price vs NAV estimate midpoint" : "closing price vs NAV";
@@ -365,6 +392,12 @@ export function fundFactEntries(facts: FundFactsPayload): HeadlessPaneEntry[] {
365
392
  add("sharesOutstanding", "Shares outstanding", facts.sharesOutstanding.value,
366
393
  provenance(facts.sharesOutstanding.value.toLocaleString("en-US"), facts.sharesOutstanding.asOf, facts.sharesOutstanding.source), "shares");
367
394
  }
395
+ if (facts.coinHoldings) {
396
+ const holdings = facts.coinHoldings;
397
+ add("unitsPerCoin", `Units per ${holdings.asset}`, holdings.unitsPerCoin,
398
+ provenance(unitsPerCoinText(holdings), holdings.asOf, holdings.source), `units per ${holdings.asset}`);
399
+ add("coinsHeld", "Coins held", holdings.coins, provenance(coinsText(holdings), holdings.asOf, holdings.source), holdings.asset);
400
+ }
368
401
  if (facts.flows) {
369
402
  // JSON keeps the dollar figure (null when a day had no NAV); `fundFacts.flows` has the shares.
370
403
  const flows = facts.flows;
@@ -399,7 +432,7 @@ export function fundFactEntries(facts: FundFactsPayload): HeadlessPaneEntry[] {
399
432
  if (facts.index) add("index", BENCHMARK_LABEL, facts.index.value, provenance(facts.index.value, facts.index.source));
400
433
  const url = facts.nav?.url ?? facts.expenseRatio?.url ?? facts.netAssets?.url;
401
434
  // The figures' own page: the sponsor's, or the SEC filing they were read from (a prospectus, an N-PORT, an 8-K).
402
- if (url) add("url", /^https:\/\/www\.sec\.gov\//.test(url) ? "SEC filing" : "Sponsor page", url, url);
435
+ if (url) add("url", /^https:\/\/www\.sec\.gov\//.test(url) ? "SEC filing" : facts.expenseRatio?.kind === "management-fee" ? "Issuer page" : "Sponsor page", url, url);
403
436
  return entries;
404
437
  }
405
438
 
@@ -415,7 +448,8 @@ export function listNames(names: readonly string[]): string {
415
448
  */
416
449
  export function fundFactPublishers(facts: FundFactsPayload): string[] {
417
450
  return [...new Set([...[facts.nav, facts.expenseRatio, facts.netAssets, facts.sharesOutstanding, facts.flows, facts.leverage, facts.index, facts.bond?.secYield, facts.bond?.yieldToWorst, facts.bond?.duration]
418
- .flatMap((value) => value ? [value.source] : []), ...facts.metalHoldings ? [facts.metalHoldings.source.publisher] : []])];
451
+ .flatMap((value) => value ? [value.source] : []), ...facts.metalHoldings ? [facts.metalHoldings.source.publisher] : [],
452
+ ...facts.coinHoldings ? [facts.coinHoldings.source] : []])];
419
453
  }
420
454
 
421
455
  /** The newest NAV is stale: one line saying since when, as the report's note says it. */
@@ -7,10 +7,11 @@ import type {
7
7
  HeadlessPaneRow,
8
8
  } from "../../../types/plugin";
9
9
  import { parsePublicTickerKey } from "../../../utils/exchanges";
10
- import { US_FUND_FACTS_ONLY } from "../../../utils/sec";
10
+ import { hasFundFactsAbroad, US_FUND_FACTS_ONLY } from "../../../utils/sec";
11
11
  import type { SecFilingItem } from "../../../types/data-provider";
12
12
  import type { FundFactsPayload } from "../../../api-client/fund-facts";
13
13
  import { errorMessage } from "../../../utils/errors";
14
+ import { logFailure } from "../../../utils/log-failure";
14
15
  import { loadSecFilings } from "./client";
15
16
  import { ETF_FILING_FORMS, filingFormMatches, filterFilingsByForms, fundSeriesFilings, SEC_FILING_FETCH_LIMIT } from "./forms";
16
17
  import { hiddenFilingsNote, loadLatestFilings } from "../../../utils/sec-filings";
@@ -202,6 +203,29 @@ function fundAbroadResult(symbol: string, venue: string, profile: FundAbroadProf
202
203
  };
203
204
  }
204
205
 
206
+ /**
207
+ * ETF for a Hong Kong spot bitcoin or ether fund's counter (3046:HKEX): its
208
+ * issuer's figures, the NAV in the counter's own currency, and the units per
209
+ * coin. It files nothing with the SEC, so there is no filings section.
210
+ */
211
+ function fundAbroadFactsResult(symbol: string, venue: string, facts: FundFactsPayload): HeadlessBundleResult {
212
+ const publishers = fundFactPublishers(facts);
213
+ const stale = fundFactsStaleNote(symbol, facts);
214
+ return {
215
+ sections: [{ title: "Fund facts", entries: fundFactEntries(facts) }],
216
+ complete: true,
217
+ ...(stale ? { notes: [stale] } : {}),
218
+ freshness: {
219
+ source: listNames(publishers) || "Fund issuer",
220
+ ...(publishers.length ? { publisher: listNames(publishers) } : {}),
221
+ status: "not-a-feed",
222
+ basis: "published fund data",
223
+ ...(facts.nav?.asOf ? { asOf: facts.nav.asOf } : {}),
224
+ },
225
+ metadata: { symbol, venue, fundFacts: facts },
226
+ };
227
+ }
228
+
205
229
  /**
206
230
  * ETF: a US-listed fund's facts (fee, NAV, premium or discount, net assets,
207
231
  * sponsor, inception, index) as its sponsor publishes them, then its fund
@@ -229,6 +253,11 @@ export function createFundHeadless(dependencies: FundHeadlessDependencies = defa
229
253
  const symbol = args.symbols[0]!;
230
254
  const abroad = venueAbroad(symbol);
231
255
  if (abroad) {
256
+ // A Hong Kong spot coin fund has its issuer's figures; any other fund abroad, or a server without them, keeps the issuer link.
257
+ const facts = hasFundFactsAbroad(abroad)
258
+ ? await dependencies.loadFacts(symbol, ctx).catch(logFailure("sec.fund-headless", "Read fund facts abroad failed", null))
259
+ : null;
260
+ if (facts?.covered) return fundAbroadFactsResult(symbol, abroad, facts);
232
261
  try {
233
262
  const profile = await (dependencies.loadAbroadProfile ?? defaultFundDependencies.loadAbroadProfile)(symbol, ctx);
234
263
  return fundAbroadResult(symbol, abroad, profile);
@@ -19,7 +19,8 @@ import type { ThemeColors } from "../../../theme/colors";
19
19
  import { useThemeColors } from "../../../theme/theme-context";
20
20
  import { useOpenDescription } from "../shared/open-description";
21
21
  import { toneColor } from "../shared/research-cells";
22
- import { mayBeUsEquityOrFundTicker, mayBeUsEquityTicker, secFilingItemCodes, US_FUND_FACTS_ONLY } from "../../../utils/sec";
22
+ import { publicTickerKey } from "../../../utils/exchanges";
23
+ import { fundFactsAbroadKey, hasFundFactsAbroad, mayBeFundViewTicker, mayBeUsEquityOrFundTicker, mayBeUsEquityTicker, secFilingItemCodes, US_FUND_FACTS_ONLY } from "../../../utils/sec";
23
24
  import { fundAbroadProfile, venueAbroad, type FundAbroadProfile } from "./fund-abroad";
24
25
  import { listingAnnouncementsPage } from "../../../utils/exchange-announcements";
25
26
  import { pricingSupplementTest } from "../../../utils/sec-filings";
@@ -279,7 +280,10 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
279
280
  // A form list is the fund filings view (ETF), which US-listed funds open too.
280
281
  const eligibleTicker = forms ? mayBeUsEquityOrFundTicker(ticker) : mayBeUsEquityTicker(ticker);
281
282
  // A fund listed abroad (3042.HK) gets what `ticker` says of it and its issuer's page, as `fn ETF` does.
282
- const abroadVenue = forms && !eligibleTicker && ticker ? venueAbroad(ticker.metadata.ticker) : null;
283
+ // By its key or suffix (3042:HKEX, 3042.HK), else the venue its metadata names (3042 on HKEX).
284
+ const abroadVenue = forms && !eligibleTicker && ticker
285
+ ? venueAbroad(ticker.metadata.ticker) ?? venueAbroad(publicTickerKey(ticker.metadata.ticker, ticker.metadata.exchange))
286
+ : null;
283
287
  const abroadFinancials = useTickerFinancials(abroadVenue ? ticker?.metadata.ticker : null, abroadVenue ? ticker : null);
284
288
  const abroad = abroadVenue ? fundAbroadProfile(abroadFinancials) : null;
285
289
  const abroadPage = abroad?.page ?? null;
@@ -288,7 +292,14 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
288
292
  ? listingAnnouncementsPage(ticker.metadata.ticker, ticker.metadata.exchange)
289
293
  : null;
290
294
  // The fund view (ETF) leads with the fund's facts, which load apart from its filings, so a filings wall or failure leaves them on screen.
291
- const fundFacts = useFundFacts(forms && eligibleTicker ? ticker?.metadata.ticker : null);
295
+ // A fund in Hong Kong asks too: its spot bitcoin and ether ETFs have their issuers' figures.
296
+ const factsAbroad = hasFundFactsAbroad(abroadVenue);
297
+ // Asked for by its listing's key, so a bare 3046 on HKEX is Hong Kong's, not a US ticker.
298
+ const factsKey = !ticker || !forms ? null
299
+ : eligibleTicker ? ticker.metadata.ticker
300
+ : factsAbroad ? fundFactsAbroadKey(ticker.metadata.ticker, ticker.metadata.exchange)
301
+ : null;
302
+ const fundFacts = useFundFacts(factsKey);
292
303
  const facts = fundFacts.data?.payload ?? null;
293
304
  const factsUrl = facts?.covered ? facts.nav?.url ?? facts.expenseRatio?.url ?? facts.netAssets?.url ?? null : null;
294
305
  const instrument = instrumentFromTicker(ticker, ticker?.metadata.ticker ?? null);
@@ -527,7 +538,17 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
527
538
  if (!ticker) {
528
539
  return <EmptyState title="No ticker selected." message="Select a ticker to view SEC filings." />;
529
540
  }
530
- if (abroadVenue) return <FundAbroadNotice profile={abroad} />;
541
+ if (abroadVenue) {
542
+ // Its issuer's figures when the server has them (3046.HK), the issuer link otherwise; a first read is one muted line.
543
+ if (factsAbroad && (facts?.covered || (fundFacts.loading && !facts))) {
544
+ return (
545
+ <Box flexDirection="column" width={width} overflow="hidden" {...(nativePaneChrome ? FILL_REST : { height })}>
546
+ <FundFactsSummary symbol={ticker.metadata.ticker} width={width} facts={facts} loading={fundFacts.loading} error={null} />
547
+ </Box>
548
+ );
549
+ }
550
+ return <FundAbroadNotice profile={abroad} />;
551
+ }
531
552
  if (!eligibleTicker) {
532
553
  return renderFilingNotice(forms ? "Fund filings are only shown for US-listed funds and equities." : "SEC filings are only shown for US equities.");
533
554
  }
@@ -640,7 +661,7 @@ export const secModule: PluginModule = {
640
661
  "leveraged", "inverse", "daily objective", "daily-reset", "decay", "bond fund", "duration", "dv01", "hedge ratio", "steepener"],
641
662
  shortcut: "ETF",
642
663
  viewKey: "etf",
643
- canCreate: (_context, options) => !options?.ticker || mayBeUsEquityOrFundTicker(options.ticker),
664
+ canCreate: (_context, options) => !options?.ticker || mayBeFundViewTicker(options.ticker),
644
665
  settings: () => ({ forms: ETF_FORMS_SETTING }),
645
666
  }),
646
667
  headless: fundHeadless,
@@ -53,6 +53,7 @@ export const SERIES_INVENTORY: readonly SeriesInventoryEntry[] = [
53
53
  { module: "credit-conditions", chart: "Corporate bond spreads by rating", series: ["fred:BAML*"] },
54
54
  { module: "credit-boards", chart: "Index CDS (CDX, iTraxx) and sovereign 5Y CDS", series: ["cdx:*", "sovereign-cds:*"] },
55
55
  { module: "cds", chart: "A company's 5Y CDS spread", series: ["cds:*"] },
56
+ { module: "trace-bonds", chart: "A bond's daily closing price since it was kept", notInCatalog: "not-yet", reason: "Daily and dated per CUSIP, kept only for the bonds Pro accounts looked up; none is registered for the composer yet." },
56
57
  { module: "credit-documents", chart: "Principal due by year", notInCatalog: "not-a-time-series", reason: "A maturity schedule, not a history." },
57
58
  { module: "debt-maturities", chart: "A company's principal and the share due soon, across annual filings", series: ["debt-maturities:*"] },
58
59
  { module: "debt-maturities", chart: "A company's maturity wall", notInCatalog: "not-a-time-series", reason: "A schedule by maturity year from one filing; its total and near-term shares across filings are in the catalog." },
@@ -54,8 +54,13 @@ export function epsBasisShort(basis: EarningsEpsBasis | null): string {
54
54
  return basis === "gaap" ? "GAAP" : basis === "adjusted" ? "adj" : "?";
55
55
  }
56
56
 
57
- /** A reported row's detail names its basis as ERN's Basis column does, unknown included. */
58
- const BASIS_TEXT: Record<EpsBasisName, string> = { GAAP: "GAAP", adjusted: "adj", unknown: "unknown" };
57
+ /**
58
+ * A reported row's detail names a known basis as ERN's Basis column does. An
59
+ * unknown one says nothing a reader can use in a sentence ("unknown, +0.07 vs
60
+ * est"), so the detail leaves it out; the row's `epsBasis`, its drilldown and
61
+ * ERN's column still say it.
62
+ */
63
+ const BASIS_TEXT: Record<EpsBasisName, string> = { GAAP: "GAAP", adjusted: "adj", unknown: "" };
59
64
 
60
65
  type EarningsRecord = CorporateActionsData["earnings"][number];
61
66
 
@@ -124,6 +124,9 @@ export async function proLockNote(
124
124
  * says when every route answered that the symbol has none. The note then
125
125
  * names no command for the symbol, which would read nothing once unlocked
126
126
  * either: IAG:LSE files neither form, and LHA:XETRA has no options served.
127
+ * A function that reads only the one ticker has nothing to unlock for it,
128
+ * so the note does not ask for an upgrade; a board (FLOW) still has the
129
+ * rest of the market.
127
130
  */
128
131
  noneFor?: (ticker: string) => string;
129
132
  },
@@ -146,10 +149,11 @@ export async function proLockNote(
146
149
  const uncovered = noneHasData && !!pane.noneFor;
147
150
  const bare = pane.argument === "none" || (pane.argument === "optional" && (!symbol || uncovered));
148
151
  const command = bare ? `gloom fn ${token}` : `gloom fn ${token} ${uncovered ? "<ticker>" : ticker}`;
152
+ const nothingToUnlock = uncovered && (pane.argument ?? "ticker") === "ticker";
149
153
  return [
150
154
  `${token} ${what}: ${pane.does}. ${without} it shows none of ${pane.shows}.`,
151
155
  ...free ? [`Free, with no sign-in: ${free.text(ticker, symbol ?? "the company")}`] : [],
152
156
  ...uncovered ? [pane.noneFor!(ticker)] : [],
153
- `${unlock}; ${command} then reads with that session.`,
157
+ ...nothingToUnlock ? [] : [`${unlock}; ${command} then reads with that session.`],
154
158
  ].join("\n");
155
159
  }
@@ -11,7 +11,7 @@ import { buildQuoteKey, resolveEntryData } from "../../../market-data/selectors"
11
11
  import { useAppVisible, usePaneVisible } from "../../../state/app/activity";
12
12
  import { useQuoteStreaming } from "../../../state/hooks/quote-streaming";
13
13
  import { colors, priceColor } from "../../../theme/colors";
14
- import type { QuoteSubscriptionTarget } from "../../../types/data-provider";
14
+ import type { MarketDataRequestContext, QuoteBatchResult, QuoteSubscriptionTarget } from "../../../types/data-provider";
15
15
  import type { MarketState, Quote } from "../../../types/financials";
16
16
  import { formatPercentRaw } from "../../../utils/format";
17
17
  import { useAssetData } from "../../runtime";
@@ -41,10 +41,10 @@ export interface QuoteBoardOptions {
41
41
  fallbackIntervalMs?: number;
42
42
  /**
43
43
  * Paint each listed symbol's cached quote, however old, as the network is
44
- * asked, and refresh the listed symbols in a few batches at once, each
45
- * given up after `refreshTimeoutMs` so one slow symbol cannot hold the
46
- * rest. A row whose refresh fails or times out keeps its cached quote,
47
- * marked stale.
44
+ * asked, and refresh the listed symbols in a few batches at once. A batch
45
+ * is given up after `refreshTimeoutMs`, and so is each symbol it left to
46
+ * be asked for alone, so one slow symbol cannot hold the rest. A row whose
47
+ * refresh fails or times out keeps its cached quote, marked stale.
48
48
  */
49
49
  cacheFirst?: boolean;
50
50
  /**
@@ -54,7 +54,7 @@ export interface QuoteBoardOptions {
54
54
  * Keep the reference stable until its contents change.
55
55
  */
56
56
  listedSymbols?: ReadonlySet<string> | null;
57
- /** How long a cache-first refresh waits for one batch. */
57
+ /** How long a cache-first refresh waits for one batch, and for each symbol it asks for alone. */
58
58
  refreshTimeoutMs?: number;
59
59
  }
60
60
 
@@ -73,7 +73,10 @@ const STREAM_CONNECT_GRACE_MS = 10_000;
73
73
  const QUOTE_REFRESH_BATCHES = 4;
74
74
  /** And sends no batch smaller than this, so a short list is one request. */
75
75
  const QUOTE_REFRESH_MIN_BATCH = 8;
76
- /** A batch still unanswered after this long is given up and its rows keep their cached quote. */
76
+ /**
77
+ * A batch still unanswered after this long is given up and its rows keep
78
+ * their cached quote; so is a symbol it left to be asked for alone.
79
+ */
77
80
  const QUOTE_REFRESH_TIMEOUT_MS = 5_000;
78
81
 
79
82
  const EMPTY_STATE: BoardQuoteState = { quote: null, loading: false, error: null, stale: false };
@@ -86,19 +89,28 @@ function boardInstrument(symbol: string): InstrumentRef {
86
89
  return { symbol, exchange: "" };
87
90
  }
88
91
 
92
+ /** A price its source answered as its last, not a current one. A listing that no longer trades has nothing newer. */
93
+ function isFlaggedStale(quote: Quote): boolean {
94
+ return quote.stale === true && !quote.delisting;
95
+ }
96
+
89
97
  /**
90
98
  * A failed refresh must not blank a board that was showing prices a second
91
- * ago: keep the last good quote and mark it stale instead.
99
+ * ago: keep the last good quote and mark it stale instead. A load that
100
+ * brings only a price flagged stale shows the newer of it and the last one,
101
+ * marked stale too.
92
102
  */
93
103
  function mergeQuotes(previous: BoardQuoteMap, loaded: BoardQuoteMap): BoardQuoteMap {
94
104
  const next: BoardQuoteMap = new Map(previous);
95
105
  for (const [symbol, state] of loaded) {
96
- const retained = state.quote ?? previous.get(symbol)?.quote ?? null;
106
+ const current = state.quote && !isFlaggedStale(state.quote) ? state.quote : null;
107
+ const kept = previous.get(symbol)?.quote ?? null;
108
+ const retained = current ?? (state.quote && (state.quote.lastUpdated ?? 0) >= (kept?.lastUpdated ?? 0) ? state.quote : kept);
97
109
  next.set(symbol, {
98
110
  quote: retained,
99
111
  loading: false,
100
112
  error: state.error,
101
- stale: !state.quote && retained !== null,
113
+ stale: !current && retained !== null,
102
114
  });
103
115
  }
104
116
  return next;
@@ -135,42 +147,73 @@ function overlayStreamQuote(base: BoardQuoteState, streamed: Quote | null): Boar
135
147
  return { quote: streamed, loading: base.loading, error: null, stale: streamed.stale === true };
136
148
  }
137
149
 
138
- /** Quotes for `subset`, one state per symbol; throws only when the whole request fails. */
150
+ /** `promise`, or a timeout error once `timeoutMs` has passed (never, without one); `onTimeout` runs first. */
151
+ function within<T>(promise: Promise<T>, timeoutMs: number | undefined, onTimeout?: () => void): Promise<T> {
152
+ if (timeoutMs == null) return promise;
153
+ let timer: ReturnType<typeof setTimeout> | undefined;
154
+ const timedOut = new Promise<never>((_, reject) => {
155
+ timer = setTimeout(() => {
156
+ onTimeout?.();
157
+ reject(new Error("Quote refresh timed out"));
158
+ }, timeoutMs);
159
+ });
160
+ return Promise.race([promise, timedOut]).finally(() => clearTimeout(timer));
161
+ }
162
+
163
+ /**
164
+ * Quotes for `subset`, handed to `apply` as they land: the batch's answer at
165
+ * once, then each symbol it left without a current quote, asked for alone
166
+ * into its own row. Such a symbol whose own read fails shows the dated price
167
+ * the batch had, flagged stale, when it had one. Each request is given
168
+ * `timeoutMs`, when set. Throws only when the batch itself fails, before
169
+ * anything was applied.
170
+ */
139
171
  async function requestBoardQuotes(
140
172
  dataProvider: NonNullable<ReturnType<typeof useAssetData>>,
141
173
  subset: readonly string[],
142
174
  forceRefresh: boolean,
143
- signal?: AbortSignal,
144
- ): Promise<BoardQuoteMap> {
145
- const next: BoardQuoteMap = new Map();
175
+ apply: (loaded: BoardQuoteMap) => void,
176
+ timeoutMs?: number,
177
+ ): Promise<void> {
178
+ const askAlone = async (symbol: string, context: MarketDataRequestContext | undefined, fallback: Quote | null = null) => {
179
+ let state: BoardQuoteState;
180
+ try {
181
+ state = { quote: await within(dataProvider.getQuote(symbol, "", context), timeoutMs), loading: false, error: null, stale: false };
182
+ } catch (error: unknown) {
183
+ state = { quote: fallback, loading: false, error: fallback ? null : errorMessage(error), stale: false };
184
+ }
185
+ apply(new Map([[symbol, state]]));
186
+ };
187
+
146
188
  if (dataProvider.getQuotesBatch) {
147
- const results = await dataProvider.getQuotesBatch(
189
+ const controller = new AbortController();
190
+ const results = await within(dataProvider.getQuotesBatch(
148
191
  subset.map((symbol) => ({ symbol, exchange: "" })),
149
- { forceRefresh, ...(signal ? { signal } : {}) },
150
- );
192
+ { forceRefresh, deferFollowUps: true, signal: controller.signal },
193
+ ), timeoutMs, () => controller.abort());
151
194
  const bySymbol = new Map(results.map((result) => [result.target.symbol, result]));
195
+ const answered: BoardQuoteMap = new Map();
196
+ const followUps: QuoteBatchResult[] = [];
152
197
  for (const symbol of subset) {
153
198
  const result = bySymbol.get(symbol);
154
- next.set(symbol, {
199
+ if (result?.followUp) {
200
+ followUps.push(result);
201
+ continue;
202
+ }
203
+ answered.set(symbol, {
155
204
  quote: result?.quote ?? null,
156
205
  loading: false,
157
206
  error: result?.error ? errorMessage(result.error) : null,
158
207
  stale: false,
159
208
  });
160
209
  }
161
- return next;
210
+ if (answered.size > 0) apply(answered);
211
+ await Promise.all(followUps.map((result) => askAlone(result.target.symbol, { cacheMode: result.followUp }, result.quote)));
212
+ return;
162
213
  }
163
214
 
164
215
  const context = forceRefresh ? { cacheMode: "refresh" as const } : undefined;
165
- await Promise.all(subset.map(async (symbol) => {
166
- try {
167
- const quote = await dataProvider.getQuote(symbol, "", context);
168
- next.set(symbol, { quote, loading: false, error: null, stale: false });
169
- } catch (error: unknown) {
170
- next.set(symbol, { quote: null, loading: false, error: errorMessage(error), stale: false });
171
- }
172
- }));
173
- return next;
216
+ await Promise.all(subset.map((symbol) => askAlone(symbol, context)));
174
217
  }
175
218
 
176
219
  /**
@@ -287,7 +330,7 @@ export function useQuoteBoard(symbols: string[], options: QuoteBoardOptions = {}
287
330
  }
288
331
  if (!dataProvider || subset.length === 0) return;
289
332
 
290
- requestBoardQuotes(dataProvider, subset, forceRefresh).then((loaded) => {
333
+ requestBoardQuotes(dataProvider, subset, forceRefresh, (loaded) => {
291
334
  if (fetchGenRef.current !== gen) return;
292
335
  setSnapshots((prev) => mergeQuotes(prev, loaded));
293
336
  }).catch((error: unknown) => {
@@ -306,28 +349,24 @@ export function useQuoteBoard(symbols: string[], options: QuoteBoardOptions = {}
306
349
  // Symbols a cache-first board has asked the network for since its last full load.
307
350
  const requestedRef = useRef(new Set<string>());
308
351
 
309
- /** Refreshes `subset` a few batches at once; a batch that fails or times out keeps its rows' cached quotes. */
352
+ /**
353
+ * Refreshes `subset` a few batches at once. Each batch's rows paint as it
354
+ * answers, and a symbol it leaves to be asked for alone fills its own row
355
+ * later; a batch or a symbol that fails or times out keeps its rows' cached
356
+ * quotes.
357
+ */
310
358
  const refreshInBatches = useCallback((subset: readonly string[], forceRefresh: boolean, gen: number) => {
311
359
  if (!dataProvider) return;
360
+ const apply = (loaded: BoardQuoteMap) => {
361
+ if (fetchGenRef.current !== gen) return;
362
+ setSnapshots((prev) => mergeQuotes(prev, loaded));
363
+ };
312
364
  for (const batch of inBatches(subset)) {
313
- const controller = new AbortController();
314
- let timer: ReturnType<typeof setTimeout> | undefined;
315
- const timedOut = new Promise<never>((_, reject) => {
316
- timer = setTimeout(() => {
317
- controller.abort();
318
- reject(new Error("Quote refresh timed out"));
319
- }, refreshTimeoutMs);
320
- });
321
- Promise.race([requestBoardQuotes(dataProvider, batch, forceRefresh, controller.signal), timedOut])
322
- .catch((error: unknown): BoardQuoteMap => new Map(batch.map((symbol) => [
365
+ requestBoardQuotes(dataProvider, batch, forceRefresh, apply, refreshTimeoutMs)
366
+ .catch((error: unknown) => apply(new Map(batch.map((symbol) => [
323
367
  symbol,
324
368
  { quote: null, loading: false, error: errorMessage(error), stale: false },
325
- ])))
326
- .then((loaded) => {
327
- clearTimeout(timer);
328
- if (fetchGenRef.current !== gen) return;
329
- setSnapshots((prev) => mergeQuotes(prev, loaded));
330
- });
369
+ ]))));
331
370
  }
332
371
  }, [dataProvider, refreshTimeoutMs]);
333
372
 
@@ -137,7 +137,7 @@ export function createShortInterestHeadless(
137
137
  daysToCover: row.record.shortRatio,
138
138
  averageDailyVolume: row.record.averageDailyVolume,
139
139
  shortPercentFloat: row.record.shortPercentFloat,
140
- floatAsOf: row.floatAsOf === "-" ? null : row.floatAsOf,
140
+ floatAsOf: row.record.shortPercentFloat != null ? row.record.floatAsOf || null : null,
141
141
  }));
142
142
  const schedule = shortInterestFreshness(rows.map((row) => row.settlementDate).sort().at(-1));
143
143
  // A cut at a past date is as current as that date allowed, not stale by today's clock.
@@ -23,7 +23,11 @@ export interface ShortInterestRow {
23
23
  settlementDate: string;
24
24
  /** When FINRA published the settlement, `YYYY-MM-DD`; `-` when the date is not one. */
25
25
  publishedDate: string;
26
- /** The day of the share count the percent of float is read on; `-` when it is undated or there is none. */
26
+ /**
27
+ * The day of the share count the percent of float is read on; `current` for
28
+ * the newest settlement's, read on today's float when that float is undated,
29
+ * so the column never looks missing beside a percent; `-` when there is none.
30
+ */
27
31
  floatAsOf: string;
28
32
  sharesShort: string;
29
33
  shortRatio: string;
@@ -52,6 +56,9 @@ export function formatMaybeCompact(value: number | null): string {
52
56
  return value == null ? "-" : formatCompact(value);
53
57
  }
54
58
 
59
+ /** A table column's figure: its decimals kept, so 12.00M lines up under 10.73M. */
60
+ const columnFigure = (value: number | null) => value == null ? "-" : formatCompact(value, { fixedDecimals: true });
61
+
55
62
  function formatRatio(value: number | null): string {
56
63
  return value == null ? "-" : formatNumber(value, 2);
57
64
  }
@@ -133,7 +140,8 @@ export function withPercentFloat(
133
140
  return records.map((record) => {
134
141
  if (record === latest) {
135
142
  const percent = settlementPercentFloat(record, floatShares, current.statistics);
136
- return { ...record, shortPercentFloat: percent, floatAsOf: percent != null ? current.floatAsOf ?? null : null };
143
+ return { ...record, shortPercentFloat: percent, floatAsOf: percent != null ? current.floatAsOf ?? null : null,
144
+ ...(percent != null ? { floatCurrent: true } : {}) };
137
145
  }
138
146
  if (record.shortPercentFloat != null || floating == null || !finiteNumber(record.sharesOutstanding)) return record;
139
147
  return {
@@ -150,10 +158,10 @@ export function buildRows(records: ShortInterestRecord[]): ShortInterestRow[] {
150
158
  record,
151
159
  settlementDate: formatDate(record.settlementDate),
152
160
  publishedDate: shortInterestPublished(formatDate(record.settlementDate)) ?? "-",
153
- floatAsOf: record.shortPercentFloat != null && record.floatAsOf ? record.floatAsOf : "-",
154
- sharesShort: formatMaybeCompact(record.sharesShort),
161
+ floatAsOf: record.shortPercentFloat == null ? "-" : record.floatAsOf || (record.floatCurrent ? "current" : "-"),
162
+ sharesShort: columnFigure(record.sharesShort),
155
163
  shortRatio: formatRatio(record.shortRatio),
156
- averageDailyVolume: formatMaybeCompact(record.averageDailyVolume),
164
+ averageDailyVolume: columnFigure(record.averageDailyVolume),
157
165
  shortPercentFloat: formatPercent(record.shortPercentFloat),
158
166
  }));
159
167
  }
@@ -165,6 +173,7 @@ function sortValue(row: ShortInterestRow, columnId: ShortInterestColumnId): stri
165
173
  case "publishedDate":
166
174
  return row.publishedDate === "-" ? null : row.publishedDate;
167
175
  case "floatAsOf":
176
+ // `current` is today's float, so it sorts after every dated one.
168
177
  return row.floatAsOf === "-" ? null : row.floatAsOf;
169
178
  case "sharesShort":
170
179
  return row.record.sharesShort;
@@ -197,7 +206,7 @@ export function buildColumns(
197
206
  records: readonly ShortInterestRecord[] = [],
198
207
  ): ShortInterestColumn[] {
199
208
  const hasPercentFloat = records.some((record) => record.shortPercentFloat != null);
200
- const hasFloatDate = records.some((record) => record.shortPercentFloat != null && !!record.floatAsOf);
209
+ const hasFloatDate = records.some((record) => record.shortPercentFloat != null && (!!record.floatAsOf || record.floatCurrent));
201
210
  const dateWidth = 11;
202
211
  const sharesWidth = 12;
203
212
  const ratioWidth = 12;
@@ -13,4 +13,6 @@ export interface ShortInterestRecord {
13
13
  sharesOutstandingAsOf?: string | null;
14
14
  /** YYYY-MM-DD of the share count `shortPercentFloat` is read on, when that count is dated. */
15
15
  floatAsOf?: string | null;
16
+ /** `shortPercentFloat` is read on today's float (the newest settlement's), dated or not. */
17
+ floatCurrent?: boolean;
16
18
  }