gloomberb 0.19.6 → 0.20.0

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 (137) hide show
  1. package/LICENSE +0 -4
  2. package/package.json +6 -5
  3. package/patches/electrobun-devkit@2.0.5.patch +148 -0
  4. package/src/api-client/bond-trades.ts +59 -0
  5. package/src/api-client/data.ts +21 -0
  6. package/src/api-client/index.ts +2 -0
  7. package/src/api-client/types/account.ts +86 -0
  8. package/src/api-client/types/assist.ts +32 -0
  9. package/src/api-client/types/auth.ts +63 -0
  10. package/src/api-client/types/billing.ts +54 -0
  11. package/src/api-client/types/chat.ts +180 -0
  12. package/src/api-client/types/congress.ts +107 -0
  13. package/src/api-client/types/credit.ts +110 -0
  14. package/src/api-client/types/econ.ts +158 -0
  15. package/src/api-client/types/equity-diagnostic.ts +73 -0
  16. package/src/api-client/types/filings-and-calls.ts +350 -0
  17. package/src/api-client/types/index.ts +25 -0
  18. package/src/api-client/types/jobs.ts +147 -0
  19. package/src/api-client/types/market.ts +122 -0
  20. package/src/api-client/types/news.ts +91 -0
  21. package/src/api-client/types/notes-and-theses.ts +172 -0
  22. package/src/api-client/types/quotes.ts +28 -0
  23. package/src/api-client/types/scanners.ts +125 -0
  24. package/src/api-client/types/screener.ts +65 -0
  25. package/src/api-client/types/search.ts +107 -0
  26. package/src/api-client/types/sync.ts +14 -0
  27. package/src/api-client/types/team-collections.ts +43 -0
  28. package/src/api-client/types/team-views.ts +32 -0
  29. package/src/api-client/types/teams.ts +135 -0
  30. package/src/api-client/types/ticker-data.ts +57 -0
  31. package/src/api-client/types/tweets.ts +59 -0
  32. package/src/api-client/types/world-venues.ts +23 -0
  33. package/src/app/runtime/desktop-deeplink.ts +41 -6
  34. package/src/app/star-prompt/status-line.tsx +1 -1
  35. package/src/app.tsx +1 -7
  36. package/src/architecture/ui-tokens-allowlist.json +0 -8
  37. package/src/cli/commands/ticker.ts +17 -4
  38. package/src/cli/desktop-pane-shot-browser.ts +69 -3
  39. package/src/cli/pane-functions/catalog.ts +3 -1
  40. package/src/components/chart/composite/use-composite-chart-keyboard.ts +11 -2
  41. package/src/components/data-table/export.ts +4 -1
  42. package/src/components/layout/detached-pane-shell.tsx +10 -37
  43. package/src/components/layout/double-escape-close.ts +90 -0
  44. package/src/components/layout/header.tsx +3 -2
  45. package/src/components/layout/market-summary.ts +6 -3
  46. package/src/components/layout/pane/footer/index.tsx +2 -6
  47. package/src/components/layout/pane/footer/model.ts +6 -12
  48. package/src/components/layout/shell/active-drag.ts +53 -11
  49. package/src/components/layout/shell/drag/magnets.ts +128 -19
  50. package/src/components/layout/shell/pane/actions.ts +6 -2
  51. package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
  52. package/src/components/layout/status-bar.tsx +4 -78
  53. package/src/components/layout/status-widget-space.ts +5 -5
  54. package/src/components/onboarding/portfolio-step/positions-panel.tsx +1 -1
  55. package/src/components/ui/data-table/index.tsx +5 -1
  56. package/src/components/ui/data-table/render-cell.ts +19 -0
  57. package/src/components/ui/delayed-mark.tsx +59 -7
  58. package/src/components/ui/icon.tsx +1 -8
  59. package/src/components/ui/menu.tsx +6 -1
  60. package/src/i18n/es.ts +3 -3
  61. package/src/i18n/ja.ts +3 -3
  62. package/src/i18n/ko.ts +3 -3
  63. package/src/i18n/zh-cn.ts +3 -3
  64. package/src/i18n/zh-tw.ts +3 -3
  65. package/src/plugins/builtin/chat/content/composer.tsx +21 -27
  66. package/src/plugins/builtin/chat/content/index.tsx +31 -3
  67. package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
  68. package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
  69. package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
  70. package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
  71. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +32 -25
  72. package/src/plugins/builtin/congress-trades/model.ts +2 -1
  73. package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
  74. package/src/plugins/builtin/custom-view/index.tsx +1 -1
  75. package/src/plugins/builtin/custom-view/loader.ts +85 -8
  76. package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
  77. package/src/plugins/builtin/equity-screener/criterion-editor.tsx +13 -4
  78. package/src/plugins/builtin/equity-screener/headless.ts +33 -1
  79. package/src/plugins/builtin/equity-screener/model.ts +58 -15
  80. package/src/plugins/builtin/equity-screener/pane.tsx +36 -6
  81. package/src/plugins/builtin/executives/format.ts +5 -4
  82. package/src/plugins/builtin/executives/pane.tsx +1 -1
  83. package/src/plugins/builtin/help/index.tsx +55 -1
  84. package/src/plugins/builtin/insider/model.ts +30 -2
  85. package/src/plugins/builtin/jobs/model.ts +2 -2
  86. package/src/plugins/builtin/mna/model.ts +2 -2
  87. package/src/plugins/builtin/notes/files.ts +2 -0
  88. package/src/plugins/builtin/notes/owner.tsx +20 -1
  89. package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
  90. package/src/plugins/builtin/notes/store.ts +6 -1
  91. package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
  92. package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
  93. package/src/plugins/builtin/series-inventory.ts +1 -0
  94. package/src/plugins/builtin/shared/earnings-report.ts +7 -2
  95. package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
  96. package/src/plugins/builtin/short-interest/headless.ts +1 -1
  97. package/src/plugins/builtin/short-interest/model.ts +15 -6
  98. package/src/plugins/builtin/short-interest/types.ts +2 -0
  99. package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
  100. package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
  101. package/src/plugins/builtin/ticker-detail/overview/model.ts +5 -3
  102. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
  103. package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
  104. package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
  105. package/src/plugins/builtin/trace-bonds/history.ts +155 -0
  106. package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
  107. package/src/plugins/installer.ts +16 -3
  108. package/src/plugins/plugin-names.ts +11 -2
  109. package/src/remote/controller.ts +9 -2
  110. package/src/remote/schema.ts +2 -1
  111. package/src/renderers/cloudflare/http-proxy.ts +67 -8
  112. package/src/renderers/cloudflare/proxy-session.ts +1 -1
  113. package/src/renderers/cloudflare/worker.ts +29 -2
  114. package/src/renderers/dom/desktop/icons.tsx +0 -2
  115. package/src/renderers/dom/styles.css +0 -3
  116. package/src/renderers/electrobun/bun/desktop/install-records.ts +59 -0
  117. package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
  118. package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
  119. package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
  120. package/src/renderers/electrobun/bun/index.ts +19 -13
  121. package/src/renderers/electrobun/bun/window/create.ts +23 -3
  122. package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +4 -4
  123. package/src/renderers/electrobun/bun/window/events.ts +4 -4
  124. package/src/renderers/electrobun/bun/window/frame.ts +2 -1
  125. package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
  126. package/src/renderers/electrobun/view/backend-rpc.ts +1 -1
  127. package/src/sources/gloomberb-cloud/index.ts +5 -7
  128. package/src/sources/provider-router/batches.ts +18 -3
  129. package/src/sources/provider-router/financials.ts +18 -4
  130. package/src/types/data-provider.ts +14 -0
  131. package/src/types/financials.ts +15 -3
  132. package/src/types/headless.ts +2 -0
  133. package/src/utils/double-escape-close.ts +38 -16
  134. package/src/utils/format.ts +23 -3
  135. package/src/utils/price-earnings.ts +18 -0
  136. package/patches/electrobun@1.18.1.patch +0 -633
  137. package/src/api-client/types.ts +0 -2441
@@ -6,7 +6,7 @@ import { QueryBar } from "../../../components/ui/query-bar";
6
6
  import { Box } from "../../../ui";
7
7
  import type { DialogApi, PromptContext } from "../../../ui/dialog";
8
8
  import { colors } from "../../../theme/colors";
9
- import { teamAccentHex, teamPrefix } from "../../../team/model";
9
+ import { canManageTeam, teamAccentHex, teamPrefix } from "../../../team/model";
10
10
  import { teamStore } from "../../../team/store";
11
11
  import { logFailure } from "../../../utils/log-failure";
12
12
  import { NoteConflictError, type NoteOwner, noteOwnerKey } from "./store";
@@ -18,6 +18,25 @@ export function useNoteTeams(): TeamSummary[] {
18
18
  ).teams;
19
19
  }
20
20
 
21
+ /**
22
+ * Whether the server lets me delete a note: any of mine, and a team note I
23
+ * wrote or whose team I run. A team note without an author is one I just
24
+ * added, or one from a server that lets any member delete.
25
+ */
26
+ export function mayDeleteNote(
27
+ note: { owner: NoteOwner; createdBy?: string | null },
28
+ teams: readonly TeamSummary[],
29
+ selfUserId: string | null,
30
+ ): boolean {
31
+ const { owner } = note;
32
+ if (owner.kind === "user" || note.createdBy === undefined) return true;
33
+ if (selfUserId !== null && note.createdBy === selfUserId) return true;
34
+ return canManageTeam(teams.find((team) => team.id === owner.teamId)?.role);
35
+ }
36
+
37
+ /** Why a teammate's note offers no delete. */
38
+ export const NOT_YOUR_NOTE = "Only its author or a team admin can delete this note.";
39
+
21
40
  /** The owner a new note defaults to: the focused team, else me. */
22
41
  export function defaultNoteOwner(): NoteOwner {
23
42
  const teamId = teamStore.getDefaultTeamId();
@@ -1,4 +1,5 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import { apiClient } from "../../../api-client";
2
3
  import { Box, Text, type InputRenderable, type TextareaRenderable } from "../../../ui";
3
4
  import { useShortcut } from "../../../react/input";
4
5
  import { isPlainKey } from "../../../utils/keyboard";
@@ -17,7 +18,15 @@ import {
17
18
  generateNoteId,
18
19
  type QuickNoteEntry,
19
20
  } from "./model";
20
- import { chooseNoteOwner, ownerColor, ownerLabel, resolveNoteConflict, useNoteTeams } from "./owner";
21
+ import {
22
+ chooseNoteOwner,
23
+ mayDeleteNote,
24
+ NOT_YOUR_NOTE,
25
+ ownerColor,
26
+ ownerLabel,
27
+ resolveNoteConflict,
28
+ useNoteTeams,
29
+ } from "./owner";
21
30
  import { NoteConflictError, type NoteOwner, noteOwnerKey, type NotesStoreRegistry } from "./store";
22
31
  import { useSyncedText } from "./text-state";
23
32
 
@@ -63,6 +72,10 @@ export function createQuickNotesPane(registry: NotesStoreRegistry) {
63
72
  const unreadableIndexRef = useRef(new Set<string>());
64
73
  const [indexError, setIndexError] = useState<{ message: string; owners: NoteOwner[] } | null>(null);
65
74
  const activeTab = tabs.find((tab) => tab.id === activeTabId);
75
+ // Closing a tab deletes its note, which a teammate's team note refuses.
76
+ const mayDelete = useCallback((tab: OwnedQuickNote) => (
77
+ mayDeleteNote(tab, teams, apiClient.getCurrentUser()?.id ?? null)
78
+ ), [teams]);
66
79
 
67
80
  const saveQuickNotesIndex = useCallback((entries: OwnedQuickNote[]) => {
68
81
  // Each owner keeps its own index; a title change only touches that store.
@@ -296,6 +309,10 @@ export function createQuickNotesPane(registry: NotesStoreRegistry) {
296
309
 
297
310
  const requestRemoveTab = useCallback(async (id: string) => {
298
311
  const tab = tabs.find((entry) => entry.id === id);
312
+ if (tab && !mayDelete(tab)) {
313
+ notify({ body: NOT_YOUR_NOTE, type: "info" });
314
+ return;
315
+ }
299
316
  const store = storeFor(tab?.owner ?? { kind: "user" });
300
317
  const text = id === activeTabId
301
318
  ? readActiveNoteText()
@@ -317,7 +334,7 @@ export function createQuickNotesPane(registry: NotesStoreRegistry) {
317
334
  }
318
335
 
319
336
  removeTab(id);
320
- }, [activeTabId, dialog, readActiveNoteText, removeTab, storeFor, tabs]);
337
+ }, [activeTabId, dialog, mayDelete, notify, readActiveNoteText, removeTab, storeFor, tabs]);
321
338
 
322
339
  const startRename = useCallback(() => {
323
340
  if (!activeTab) return;
@@ -404,7 +421,8 @@ export function createQuickNotesPane(registry: NotesStoreRegistry) {
404
421
 
405
422
  // Deleting the only note when it is empty just swaps in another empty one,
406
423
  // and a note that failed to load reads as empty, so it would go unconfirmed.
407
- const canDelete = !!activeTabId && !readError && (tabs.length > 1 || noteText.trim().length > 0);
424
+ const canDelete = !!activeTabId && !readError && (tabs.length > 1 || noteText.trim().length > 0)
425
+ && (!activeTab || mayDelete(activeTab));
408
426
 
409
427
  usePaneFooter("quick-notes", () => ({
410
428
  info: footerWarning
@@ -426,7 +444,7 @@ export function createQuickNotesPane(registry: NotesStoreRegistry) {
426
444
  label: tab.owner.kind === "team" ? `${ownerLabel(tab.owner, teams)} ${tab.title}` : tab.title,
427
445
  value: tab.id,
428
446
  ...(tab.owner.kind === "team" ? { fg: ownerColor(tab.owner, teams) } : {}),
429
- onClose: tabs.length > 1 ? (id: string) => { void requestRemoveTab(id); } : undefined,
447
+ onClose: tabs.length > 1 && mayDelete(tab) ? (id: string) => { void requestRemoveTab(id); } : undefined,
430
448
  onDoubleClick: startRenameTab,
431
449
  }));
432
450
  const selectTab = (id: string) => {
@@ -240,7 +240,12 @@ export class CloudNotesStore implements NotesStore {
240
240
  return [...index.values()]
241
241
  .filter((summary) => summary.kind === "quick")
242
242
  .sort((a, b) => a.createdAt.localeCompare(b.createdAt))
243
- .map((summary) => ({ id: summary.key, title: summary.title ?? "Note", updatedAt: Date.parse(summary.updatedAt) || undefined }));
243
+ .map((summary) => ({
244
+ id: summary.key,
245
+ title: summary.title ?? "Note",
246
+ updatedAt: Date.parse(summary.updatedAt) || undefined,
247
+ ...(summary.createdBy !== undefined ? { createdBy: summary.createdBy } : {}),
248
+ }));
244
249
  }
245
250
 
246
251
  /**
@@ -55,7 +55,7 @@ export function PortfolioCashMarginDrawer({
55
55
  <Text fg={colors.textDim}>{" qty "}</Text>
56
56
  <Text fg={colors.text}>{padTo(formatMarketQuantity(balance.quantity, { isCashBalance: true, maxWidth: 14 }), 14, "right")}</Text>
57
57
  <Text fg={colors.textDim}>{" value "}</Text>
58
- <Text fg={colors.text}>{padTo(balance.baseValue != null ? formatCompact(balance.baseValue) : "—", 10, "right")}</Text>
58
+ <Text fg={colors.text}>{padTo(balance.baseValue != null ? formatCompact(balance.baseValue, { fixedDecimals: true }) : "—", 10, "right")}</Text>
59
59
  </Box>
60
60
  ))
61
61
  )}
@@ -141,15 +141,20 @@ export function matchEarningsSecFiling(row: { status: string; date: string; date
141
141
  return best?.filing ?? null;
142
142
  }
143
143
 
144
- /** Share the currency label; EE marks any unstated currencies separately. */
145
- function sharedMetricCurrency(rows: readonly EventRow[], allowUnstated = false): string | undefined {
146
- const currencies = new Set<string | undefined>();
144
+ /**
145
+ * The one currency every stated EPS and revenue amount is in, named once above
146
+ * the table (EVT and EE alike). An amount whose source stated no currency is
147
+ * marked `?` beside it rather than counted, so it never reads as that currency;
148
+ * amounts in several currencies keep their own codes.
149
+ */
150
+ function sharedMetricCurrency(rows: readonly EventRow[]): string | undefined {
151
+ const currencies = new Set<string>();
147
152
  for (const row of rows) {
148
153
  for (const [value, currency] of [
149
154
  [row.qEps, row.epsCurrency], [row.annualEps, row.epsCurrency],
150
155
  [row.qRevenue, row.revenueCurrency], [row.annualRevenue, row.revenueCurrency],
151
156
  ] as const) {
152
- if (value != null && Number.isFinite(value) && (currency || !allowUnstated)) currencies.add(currency || undefined);
157
+ if (value != null && Number.isFinite(value) && currency) currencies.add(currency);
153
158
  }
154
159
  }
155
160
  const [only] = currencies;
@@ -169,15 +174,14 @@ export function buildEventColumns(width: number, unit?: string, variant: "corpor
169
174
  { id: "detail", label: "DETAIL", width: 9, align: "left", flexGrow: 1 },
170
175
  ], width, ["detail", "growth", "revenue"]);
171
176
  }
172
- const withUnit = (label: string) => unit ? `${label} ${unit}` : label;
173
177
  const columns: EventColumn[] = [
174
178
  { id: "date", label: "DATE", width: 10, align: "left" },
175
179
  { id: "status", label: "EVENT", width: 8, align: "left" },
176
180
  { id: "period", label: "PERIOD", width: 12, align: "left" },
177
- { id: "qEps", label: withUnit("Q EPS"), width: 12, align: "right" },
178
- { id: "qRevenue", label: withUnit("Q REV"), width: 12, align: "right" },
179
- { id: "annualEps", label: withUnit("ANN EPS"), width: 12, align: "right" },
180
- { id: "annualRevenue", label: withUnit("ANN REV"), width: 12, align: "right" },
181
+ { id: "qEps", label: "Q EPS", width: 12, align: "right" },
182
+ { id: "qRevenue", label: "Q REV", width: 12, align: "right" },
183
+ { id: "annualEps", label: "ANN EPS", width: 12, align: "right" },
184
+ { id: "annualRevenue", label: "ANN REV", width: 12, align: "right" },
181
185
  { id: "value", label: "VALUE", width: 11, align: "right" },
182
186
  { id: "detail", label: "DETAIL", width: 9, align: "left", flexGrow: 1 },
183
187
  ];
@@ -498,7 +502,7 @@ export function CorporateActionsView({
498
502
  ? allRows.filter((row) => EARNINGS_STATUSES.has(row.status))
499
503
  : allRows
500
504
  ), [allRows, variant]);
501
- const unit = useMemo(() => sharedMetricCurrency(rows, variant === "earnings-estimates"), [rows, variant]);
505
+ const unit = useMemo(() => sharedMetricCurrency(rows), [rows]);
502
506
  const hasUnstatedCurrency = rows.some((row) =>
503
507
  ((row.qEps != null || row.annualEps != null) && !row.epsCurrency)
504
508
  || ((row.qRevenue != null || row.annualRevenue != null) && !row.revenueCurrency));
@@ -618,6 +622,11 @@ export function CorporateActionsView({
618
622
  row: EventRow,
619
623
  column: EventColumn,
620
624
  ): DataTableCell => {
625
+ // Bare under the currency named above the table, with its own code otherwise, `?` when its source stated none.
626
+ const metric = (value: number | undefined, currency: string | undefined, kind: "eps" | "revenue"): DataTableCell => {
627
+ const text = formatEventMetric(value, unit ? undefined : currency, kind);
628
+ return { text: value != null && !currency ? `${text} ?` : text, value: unit && currency ? value : undefined, color: colors.textDim };
629
+ };
621
630
  switch (column.id) {
622
631
  case "date":
623
632
  return { text: row.date, color: colors.textDim };
@@ -626,26 +635,21 @@ export function CorporateActionsView({
626
635
  case "period":
627
636
  return { text: row.period, color: colors.textDim };
628
637
  case "eps":
629
- case "revenue": {
630
- const eps = column.id === "eps";
631
- const value = eps ? row.qEps ?? row.annualEps : row.qRevenue ?? row.annualRevenue;
632
- const currency = eps ? row.epsCurrency : row.revenueCurrency;
633
- const text = formatEventMetric(value, unit ? undefined : currency, eps ? "eps" : "revenue");
634
- return { text: value != null && !currency ? `${text} ?` : text,
635
- value: unit && currency ? value : undefined, color: colors.textDim };
636
- }
638
+ return metric(row.qEps ?? row.annualEps, row.epsCurrency, "eps");
639
+ case "revenue":
640
+ return metric(row.qRevenue ?? row.annualRevenue, row.revenueCurrency, "revenue");
637
641
  case "surprise":
638
642
  return { text: row.status === "Earnings" ? row.value : "-", value: row.surprisePercent, color: row.status === "Earnings" ? toneColor(row.tone) : colors.textDim };
639
643
  case "growth":
640
644
  return { text: row.estimateGrowthMetric && row.value !== "-" ? `${row.value} ${row.estimateGrowthMetric === "eps" ? "EPS" : "rev"}` : "-", color: row.estimateGrowthMetric ? toneColor(row.tone) : colors.textDim };
641
645
  case "qEps":
642
- return { text: formatEventMetric(row.qEps, unit ? undefined : row.epsCurrency, "eps"), color: colors.textDim };
646
+ return metric(row.qEps, row.epsCurrency, "eps");
643
647
  case "qRevenue":
644
- return { text: formatEventMetric(row.qRevenue, unit ? undefined : row.revenueCurrency, "revenue"), color: colors.textDim };
648
+ return metric(row.qRevenue, row.revenueCurrency, "revenue");
645
649
  case "annualEps":
646
- return { text: formatEventMetric(row.annualEps, unit ? undefined : row.epsCurrency, "eps"), color: colors.textDim };
650
+ return metric(row.annualEps, row.epsCurrency, "eps");
647
651
  case "annualRevenue":
648
- return { text: formatEventMetric(row.annualRevenue, unit ? undefined : row.revenueCurrency, "revenue"), color: colors.textDim };
652
+ return metric(row.annualRevenue, row.revenueCurrency, "revenue");
649
653
  case "value":
650
654
  return { text: row.value, color: toneColor(row.tone) };
651
655
  case "detail":
@@ -694,7 +698,7 @@ export function CorporateActionsView({
694
698
  rootWidth={width}
695
699
  rootHeight={height}
696
700
  rootBefore={<ChartTableHeader width={width} height={height} tableRows={rows.length} tableColumns={columns}
697
- query={variant === "earnings-estimates" && currencyMeta ? <QueryBar width={width} meta={currencyMeta} /> : undefined} />}
701
+ query={currencyMeta ? <QueryBar width={width} meta={currencyMeta} /> : undefined} />}
698
702
  onRootKeyDown={handleKeyDown}
699
703
  columns={columns}
700
704
  items={rows}
@@ -702,10 +706,10 @@ export function CorporateActionsView({
702
706
  sortDirection="desc"
703
707
  getItemKey={eventRowKey}
704
708
  renderCell={renderCell}
705
- getExportMetadata={variant === "earnings-estimates" ? () => [
709
+ getExportMetadata={() => [
706
710
  ...(unit ? [["Currency", unit]] : []),
707
711
  ...(hasUnstatedCurrency ? [["?", "Currency unstated"]] : []),
708
- ] : undefined}
712
+ ]}
709
713
  selectedTextOverridesCellColor
710
714
  getRowBackgroundColor={rowBackground}
711
715
  emptyStateTitle={loading
@@ -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
 
@@ -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
  }
@@ -4,6 +4,7 @@ import { useShortcut } from "../../../react/input";
4
4
  import { colors } from "../../../theme/colors";
5
5
  import { Box, type ScrollBoxRenderable } from "../../../ui";
6
6
  import { isDetailBackNavigationKey } from "../../../utils/back-navigation";
7
+ import { countEscapeTowardClose } from "../../../utils/double-escape-close";
7
8
  import { isPlainKey } from "../../../utils/keyboard";
8
9
  import { nextHeaderSort, type SortDirection } from "../../../utils/sort-values";
9
10
  import { usePluginPaneState, usePluginTickerActions } from "../../runtime";
@@ -106,6 +107,8 @@ export function FundOverlapView({ data, focused, width }: { data: FundDetailData
106
107
  const closeDetail = useCallback(() => { setTarget(null); setEtf(null); }, [setTarget, setEtf]);
107
108
  useShortcut(event => {
108
109
  if (!focused || !open || event.targetEditable || !isDetailBackNavigationKey(event)) return;
110
+ // Ahead of the shell's own Esc handler when restored with it, so it counts the Esc itself.
111
+ countEscapeTowardClose(event);
109
112
  event.preventDefault?.(); event.stopPropagation?.(); closeDetail();
110
113
  }, { phase: "before" });
111
114
  useShortcut(event => {
@@ -16,6 +16,7 @@ import {
16
16
  type ScrollBoxRenderable,
17
17
  } from "../../../ui";
18
18
  import { isDetailBackNavigationKey } from "../../../utils/back-navigation";
19
+ import { countEscapeTowardClose } from "../../../utils/double-escape-close";
19
20
  import { isPlainKey } from "../../../utils/keyboard";
20
21
  import { logFailure } from "../../../utils/log-failure";
21
22
  import { isPlainArrowUp, stopSearchFocusNavigation } from "../../../utils/search-focus-navigation";
@@ -493,6 +494,8 @@ export function FundDetailView({
493
494
  useShortcut((event) => {
494
495
  if (!focused || !openFiling || event.targetEditable) return;
495
496
  if (!isDetailBackNavigationKey(event)) return;
497
+ // Ahead of the shell's own Esc handler when restored with it, so it counts the Esc itself.
498
+ countEscapeTowardClose(event);
496
499
  event.preventDefault?.();
497
500
  event.stopPropagation?.();
498
501
  closeOpenFiling();
@@ -1,4 +1,4 @@
1
- import { formatPriceEarnings, NOT_MEANINGFUL } from "../../../../utils/price-earnings";
1
+ import { forwardFiscalYear, forwardPEAsked, formatPriceEarnings, NOT_MEANINGFUL } from "../../../../utils/price-earnings";
2
2
  import { convertMarketCapitalization } from "../../../../utils/market-capitalization";
3
3
  import { priceColor } from "../../../../theme/colors";
4
4
  import type { CedearRatio, CompanyProfile, DepositaryPair, NextEarnings, Quote, TickerFinancials } from "../../../../types/financials";
@@ -235,9 +235,11 @@ export function buildOverviewStats({
235
235
  if (trailingPE != null) {
236
236
  stats.push({ label: "P/E (TTM)", value: formatPriceEarnings(trailingPE) });
237
237
  }
238
+ // Next fiscal year's consensus, and the year it is for: N/M over a loss, a dash when there is none.
238
239
  const forwardPE = liveForwardPE(quote, fundamentals);
239
- if (forwardPE != null) {
240
- stats.push({ label: "Fwd P/E", value: formatPriceEarnings(forwardPE) });
240
+ if (forwardPE != null || forwardPEAsked(fundamentals)) {
241
+ const year = forwardFiscalYear(fundamentals?.forwardEpsPeriodEnd);
242
+ stats.push({ label: year ? `Fwd P/E ${year}` : "Fwd P/E", value: formatPriceEarnings(forwardPE) });
241
243
  }
242
244
  if (fundamentals?.eps != null) {
243
245
  stats.push({ label: "EPS", value: formatReportedMoney(fundamentals.eps, fundamentalsEpsCurrency({ fundamentals, financialCurrency, quote }), true) });