@gloom-sh/terminal 0.20.4 → 0.20.5

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 (217) hide show
  1. package/README.md +2 -0
  2. package/bin/gloom +9 -0
  3. package/bin/without-bun.cjs +98 -0
  4. package/package.json +3 -1
  5. package/src/api-client/data.ts +138 -35
  6. package/src/api-client/types/econ.ts +12 -0
  7. package/src/api-client/yield-curves.ts +1 -1
  8. package/src/app/global-shortcuts.ts +4 -1
  9. package/src/app/keybindings/actions.ts +6 -0
  10. package/src/app/keybindings/config.ts +2 -1
  11. package/src/app/keybindings/index.ts +1 -0
  12. package/src/app/keybindings/labels.ts +6 -1
  13. package/src/app/keybindings/resolve.ts +23 -4
  14. package/src/app/keybindings/terminal-keys.ts +35 -0
  15. package/src/app/pane-runtime/index.tsx +2 -2
  16. package/src/app/pane-runtime/ticker-open-runtime.ts +68 -40
  17. package/src/architecture/ui-literals-allowlist.json +1 -1
  18. package/src/capabilities/chart-series.ts +27 -1
  19. package/src/cli/commands/keybindings.ts +5 -5
  20. package/src/cli/commands/market.ts +78 -21
  21. package/src/cli/commands/news-search.ts +59 -7
  22. package/src/cli/commands/overview.ts +16 -1
  23. package/src/cli/commands/remote.ts +16 -17
  24. package/src/cli/commands/system.ts +1 -1
  25. package/src/cli/fx-forward.ts +25 -7
  26. package/src/cli/glossary.ts +19 -5
  27. package/src/cli/history-rows.ts +5 -3
  28. package/src/cli/known-gaps.ts +27 -1
  29. package/src/cli/listing-arg.ts +11 -1
  30. package/src/cli/name-entries.ts +5 -1
  31. package/src/cli/not-a-ticker.ts +4 -0
  32. package/src/cli/pane-functions/function-help.ts +2 -2
  33. package/src/components/command-bar/pane-settings.ts +2 -2
  34. package/src/components/command-bar/routes/root/results.ts +6 -2
  35. package/src/components/input-search-bar.tsx +9 -2
  36. package/src/components/layout/pane/header.tsx +2 -0
  37. package/src/components/layout/shell/pane/capture.ts +4 -1
  38. package/src/components/layout/status-bar.tsx +6 -1
  39. package/src/components/onboarding/first-run-workspace.ts +44 -2
  40. package/src/components/onboarding/onboarding-frame.tsx +11 -2
  41. package/src/components/onboarding/onboarding-keyboard.ts +16 -0
  42. package/src/components/onboarding/onboarding-wizard.tsx +8 -8
  43. package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
  44. package/src/components/onboarding/use-onboarding-progress.ts +12 -4
  45. package/src/components/pane-settings-dialog/desktop.tsx +2 -2
  46. package/src/components/pane-settings-dialog/tui.tsx +2 -2
  47. package/src/components/pane-settings-dialog/value.ts +6 -0
  48. package/src/components/pane-settings-dialog.tsx +3 -3
  49. package/src/components/reader/detail-reader.tsx +4 -0
  50. package/src/components/ui/index.ts +1 -1
  51. package/src/components/ui/page-stack-view.tsx +3 -0
  52. package/src/components/ui/pane-link-chip.tsx +269 -54
  53. package/src/components/ui/query-bar.tsx +2 -1
  54. package/src/components/ui/tabs.tsx +97 -19
  55. package/src/core/state/app/layout-reducer.ts +7 -0
  56. package/src/core/state/app/layout.ts +44 -7
  57. package/src/core/state/app/state.ts +1 -1
  58. package/src/core/state/app/types.ts +22 -2
  59. package/src/docs/snapshot.json +27 -10
  60. package/src/market-data/depositary-pair.ts +5 -3
  61. package/src/market-data/market/dated-previous-close.ts +94 -15
  62. package/src/market-data/market/status.ts +17 -1
  63. package/src/plugins/builtin/analytics/risk-client.ts +10 -4
  64. package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
  65. package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
  66. package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
  67. package/src/plugins/builtin/awards/index.tsx +1 -1
  68. package/src/plugins/builtin/buildout/index.tsx +1 -0
  69. package/src/plugins/builtin/catalysts/index.tsx +2 -2
  70. package/src/plugins/builtin/cds/headless.ts +4 -0
  71. package/src/plugins/builtin/chart-composer/headless.ts +2 -1
  72. package/src/plugins/builtin/chart-composer/index.tsx +1 -0
  73. package/src/plugins/builtin/chat/content/composer.tsx +5 -4
  74. package/src/plugins/builtin/chat/content/index.tsx +12 -2
  75. package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
  76. package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
  77. package/src/plugins/builtin/chat/layout.ts +5 -2
  78. package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
  79. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  80. package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
  81. package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
  82. package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
  83. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +5 -3
  84. package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
  85. package/src/plugins/builtin/company-attention/index.tsx +1 -1
  86. package/src/plugins/builtin/company-kpis/headless.ts +3 -1
  87. package/src/plugins/builtin/company-kpis/index.tsx +2 -2
  88. package/src/plugins/builtin/cot/index.tsx +1 -1
  89. package/src/plugins/builtin/cpi/index.tsx +1 -1
  90. package/src/plugins/builtin/crypto-board/index.tsx +1 -0
  91. package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
  92. package/src/plugins/builtin/doe/index.tsx +1 -1
  93. package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
  94. package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
  95. package/src/plugins/builtin/econ/calendar-model.ts +74 -1
  96. package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
  97. package/src/plugins/builtin/econ/index.tsx +1 -0
  98. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  99. package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
  100. package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
  101. package/src/plugins/builtin/executives/index.tsx +1 -0
  102. package/src/plugins/builtin/filing-events/index.tsx +1 -0
  103. package/src/plugins/builtin/fixed-income/index.tsx +1 -0
  104. package/src/plugins/builtin/futures-curve/headless.ts +3 -3
  105. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  106. package/src/plugins/builtin/futures-curve/model.ts +18 -0
  107. package/src/plugins/builtin/gpu/index.tsx +1 -1
  108. package/src/plugins/builtin/help/functions-table.tsx +1 -1
  109. package/src/plugins/builtin/help/index.tsx +11 -1
  110. package/src/plugins/builtin/help/keybindings-editor.tsx +1 -1
  111. package/src/plugins/builtin/holders/index.tsx +1 -0
  112. package/src/plugins/builtin/holders/report-header.ts +2 -2
  113. package/src/plugins/builtin/insider/index.tsx +1 -0
  114. package/src/plugins/builtin/iv-history/index.tsx +1 -1
  115. package/src/plugins/builtin/jobs/index.tsx +1 -0
  116. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  117. package/src/plugins/builtin/macro-day/index.tsx +1 -1
  118. package/src/plugins/builtin/macro-day/model.ts +19 -3
  119. package/src/plugins/builtin/macro-day/pane.tsx +14 -9
  120. package/src/plugins/builtin/macro-day/releases.ts +25 -7
  121. package/src/plugins/builtin/market-valuation/index.tsx +1 -0
  122. package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
  123. package/src/plugins/builtin/members/index.tsx +1 -1
  124. package/src/plugins/builtin/mna/index.tsx +1 -0
  125. package/src/plugins/builtin/news/index.tsx +1 -0
  126. package/src/plugins/builtin/news/wire/index.tsx +5 -1
  127. package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
  128. package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
  129. package/src/plugins/builtin/options/index.tsx +1 -0
  130. package/src/plugins/builtin/options-positioning/index.tsx +1 -0
  131. package/src/plugins/builtin/pe-band/index.tsx +1 -1
  132. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
  133. package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
  134. package/src/plugins/builtin/power/index.tsx +1 -1
  135. package/src/plugins/builtin/realized-vol/index.tsx +1 -1
  136. package/src/plugins/builtin/research/headless.ts +10 -4
  137. package/src/plugins/builtin/research/index.tsx +4 -0
  138. package/src/plugins/builtin/research-search/index.tsx +1 -0
  139. package/src/plugins/builtin/research-search/pane.tsx +8 -0
  140. package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
  141. package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
  142. package/src/plugins/builtin/risk-factors/index.tsx +1 -0
  143. package/src/plugins/builtin/scanner/headless.ts +52 -13
  144. package/src/plugins/builtin/seasonality/index.tsx +1 -1
  145. package/src/plugins/builtin/sec/index.tsx +1 -0
  146. package/src/plugins/builtin/series-inventory.ts +1 -1
  147. package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
  148. package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
  149. package/src/plugins/builtin/short-interest/index.tsx +1 -0
  150. package/src/plugins/builtin/social-mentions/index.tsx +1 -1
  151. package/src/plugins/builtin/supply-chain/index.tsx +1 -0
  152. package/src/plugins/builtin/thirteenf/data.ts +43 -10
  153. package/src/plugins/builtin/thirteenf/headless.ts +55 -11
  154. package/src/plugins/builtin/thirteenf/model.ts +25 -9
  155. package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
  156. package/src/plugins/builtin/thirteenf/types.ts +2 -0
  157. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
  158. package/src/plugins/builtin/ticker-detail/financials/model.ts +12 -0
  159. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
  160. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +5 -5
  161. package/src/plugins/builtin/ticker-detail/headless.ts +18 -13
  162. package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
  163. package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
  164. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +6 -4
  165. package/src/plugins/builtin/time-sales/client.ts +9 -11
  166. package/src/plugins/builtin/time-sales/index.tsx +1 -1
  167. package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
  168. package/src/plugins/builtin/treasury-auctions/cache.ts +18 -3
  169. package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
  170. package/src/plugins/builtin/treasury-auctions/headless.ts +109 -19
  171. package/src/plugins/builtin/treasury-auctions/index.tsx +14 -4
  172. package/src/plugins/builtin/treasury-auctions/model.ts +256 -28
  173. package/src/plugins/builtin/treasury-auctions/pane.tsx +139 -28
  174. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
  175. package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
  176. package/src/plugins/builtin/vol-surface/index.tsx +1 -1
  177. package/src/plugins/builtin/world-venue-map/index.ts +1 -0
  178. package/src/plugins/builtin/yield-curve/curves.ts +10 -4
  179. package/src/plugins/builtin/yield-curve/headless.ts +6 -2
  180. package/src/plugins/builtin/yield-curve/index.tsx +3 -3
  181. package/src/plugins/builtin/yield-curve/series.ts +10 -0
  182. package/src/plugins/builtin/yield-curve/world.ts +3 -1
  183. package/src/portfolio/column-values.ts +2 -1
  184. package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
  185. package/src/public/remote.ts +7 -1
  186. package/src/remote/client.ts +191 -11
  187. package/src/remote/controller-utils.ts +13 -1
  188. package/src/remote/controller.ts +88 -26
  189. package/src/remote/endpoint.ts +24 -0
  190. package/src/remote/form.ts +59 -4
  191. package/src/remote/resources.ts +44 -18
  192. package/src/remote/schema.ts +21 -9
  193. package/src/remote/secrets.ts +12 -0
  194. package/src/remote/semantic-tree.tsx +14 -2
  195. package/src/remote/server.ts +2 -1
  196. package/src/remote/surface.tsx +192 -0
  197. package/src/remote/types.ts +5 -0
  198. package/src/renderers/opentui/host.tsx +6 -0
  199. package/src/series/standalone.ts +2 -2
  200. package/src/shares/api.ts +21 -4
  201. package/src/shares/item.ts +73 -0
  202. package/src/shares/pane-item.ts +205 -0
  203. package/src/shares/pane.ts +4 -0
  204. package/src/shares/payload.ts +9 -5
  205. package/src/sources/gloomberb-cloud/news.ts +2 -0
  206. package/src/tickers/renamed-listings.ts +105 -0
  207. package/src/tickers/search/index.ts +103 -16
  208. package/src/time-series/resolve.ts +2 -2
  209. package/src/types/financials.ts +1 -0
  210. package/src/types/plugin-pane-settings.ts +2 -0
  211. package/src/types/plugin-panes.ts +22 -0
  212. package/src/utils/central-banks.ts +86 -1
  213. package/src/utils/datetime-format.ts +12 -3
  214. package/src/utils/depositary-receipt.ts +28 -3
  215. package/src/utils/fundamentals.ts +14 -0
  216. package/src/utils/max-drawdown.ts +97 -16
  217. package/src/utils/untrusted-text.ts +29 -0
@@ -434,8 +434,9 @@ interface HoldingLine {
434
434
  /**
435
435
  * Each line's split factor by row id, new shares per old: 1 when its corporate
436
436
  * actions show no split between the filings, null when they could not be read.
437
+ * `late` holds the lines left unread because the lookups' time ran out.
437
438
  */
438
- export type SplitFactors = ReadonlyMap<string, number | null>;
439
+ export type SplitFactors = ReadonlyMap<string, number | null> & { readonly late?: ReadonlySet<string> };
439
440
 
440
441
  /**
441
442
  * The Est P&L of a line held through the quarter, and the value of the shares
@@ -490,8 +491,13 @@ export interface FilingQuarterReturn {
490
491
  percent: number | null;
491
492
  /** Lines split between the filings, priced on split-adjusted shares, with the new shares per old (10 for 10:1, 0.1 for 1:10). */
492
493
  splits: Array<FilingLine & { ratio: number }>;
493
- /** Lines that moved as across a split whose corporate actions could not be read, left out. */
494
- skipped: FilingLine[];
494
+ /**
495
+ * Lines that moved as across a split whose corporate actions could not be read, left out, largest at the
496
+ * quarter's start first; `late` when the lookups' time ran out before them.
497
+ */
498
+ skipped: Array<FilingLine & { previousValue: number; late?: boolean }>;
499
+ /** What `skipped` weighed in the book at the quarter's start, as a fraction; null when none is left out or the book has no value. */
500
+ skippedShare: number | null;
495
501
  }
496
502
 
497
503
  /** The least change in a line's share count that reads as a split: 3:2. */
@@ -531,7 +537,11 @@ export function formatSplitRatio(ratio: number): string {
531
537
  * no factor is known.
532
538
  */
533
539
  export function filingSplitCandidates(data: FundDetailData): Array<FilingLine & { id: string }> {
534
- return buildFundHoldingRows(data).filter((row) => row.splitUnread).map((row) => ({ id: row.id, ticker: row.ticker, issuer: row.issuer }));
540
+ return buildFundHoldingRows(data)
541
+ .filter((row) => row.splitUnread)
542
+ // Largest at the start of the quarter first: the lines that weigh most on an estimate are read first.
543
+ .sort((a, b) => (b.previousValue ?? 0) - (a.previousValue ?? 0))
544
+ .map((row) => ({ id: row.id, ticker: row.ticker, issuer: row.issuer }));
535
545
  }
536
546
 
537
547
  /**
@@ -551,20 +561,26 @@ export function filingSplitCandidates(data: FundDetailData): Array<FilingLine &
551
561
  */
552
562
  export function estimateFilingQuarterReturn(data: FundDetailData, splits: SplitFactors = new Map()): FilingQuarterReturn {
553
563
  const adjusted: FilingQuarterReturn["splits"] = [];
554
- const skipped: FilingLine[] = [];
555
- if (!hasComparable13FQuarter(data)) return { percent: null, splits: adjusted, skipped };
564
+ const skipped: FilingQuarterReturn["skipped"] = [];
565
+ if (!hasComparable13FQuarter(data)) return { percent: null, splits: adjusted, skipped, skippedShare: null };
556
566
  let pnl = 0;
557
567
  let base = 0;
568
+ let book = 0;
558
569
  for (const row of buildFundHoldingRows(data)) {
570
+ book += row.previousValue != null && row.previousValue > 0 ? row.previousValue : 0;
559
571
  const estimate = estimateHolding(row, splits);
560
572
  const line = { ticker: row.ticker, issuer: row.issuer };
561
- if (estimate.kind === "unread") skipped.push(line);
573
+ if (estimate.kind === "unread") {
574
+ skipped.push({ ...line, previousValue: row.previousValue ?? 0, ...(splits.late?.has(row.id) ? { late: true } : {}) });
575
+ }
562
576
  if (estimate.kind !== "priced") continue;
563
577
  if (estimate.ratio !== 1) adjusted.push({ ...line, ratio: estimate.ratio });
564
578
  pnl += estimate.pnl;
565
579
  base += estimate.base;
566
580
  }
567
- return { percent: base > 0 ? (pnl / base) * 100 : null, splits: adjusted, skipped };
581
+ skipped.sort((left, right) => right.previousValue - left.previousValue);
582
+ const left = skipped.reduce((sum, line) => sum + line.previousValue, 0);
583
+ return { percent: base > 0 ? (pnl / base) * 100 : null, splits: adjusted, skipped, skippedShare: skipped.length && book > 0 ? left / book : null };
568
584
  }
569
585
 
570
586
  export function hasComparable13FQuarter(data: FundDetailData): boolean {
@@ -672,7 +688,7 @@ export function buildFundHoldingRows(data: FundDetailData | null, splits?: Split
672
688
  valueChange,
673
689
  estimatedPnl: estimate.kind === "priced" ? estimate.pnl : null,
674
690
  ...(ratio !== 1 ? { splitRatio: ratio } : {}),
675
- ...(estimate.kind === "unread" ? { splitUnread: true } : {}),
691
+ ...(estimate.kind === "unread" ? { splitUnread: true, ...(splits?.late?.has(id) ? { splitLate: true } : {}) } : {}),
676
692
  sharesChange,
677
693
  sharesChangePercent,
678
694
  action: comparable ? resolveAction(currentHolding, previousHolding, ratio) : "unknown",
@@ -140,19 +140,40 @@ export function splitAdjustedText(lines: readonly (SplitLine & { ratio: number }
140
140
  return `${prefix}: ${listedLines(lines, (line) => `${lineName(line)} ${formatSplitRatio(line.ratio)}`)} (split between the filings, as the corporate actions show)`;
141
141
  }
142
142
 
143
- /** "No Est P&L: XYZ (shares and value per share moved as across a split, and the corporate actions could not be read to tell)": lines left without a figure, `leftOut` opening it. */
144
- export function splitUnreadText(lines: readonly SplitLine[], leftOut: string): string {
145
- return `${leftOut}: ${listedLines(lines, lineName)} (shares and value per share moved as across a split, and the corporate actions could not be read to tell)`;
143
+ /** Why lines that moved as across a split have no figure: their corporate actions could not be read, or the time to read them ran out. */
144
+ function unreadReason(lines: readonly (SplitLine & { late?: boolean })[]): string {
145
+ const late = lines.filter((line) => line.late).length;
146
+ const failed = lines.length - late;
147
+ if (late === 0) return "the corporate actions could not be read to tell";
148
+ if (failed === 0) return "the report ran out of time before reading their corporate actions";
149
+ return `the report ran out of time before reading the corporate actions of ${count(late)}; those of ${count(failed)} could not be read`;
146
150
  }
147
151
 
152
+ /** "4.2%" of a book, or "under 0.1%". */
153
+ function bookShareText(share: number): string {
154
+ return share < 0.001 ? "under 0.1%" : `${(share * 100).toFixed(1)}%`;
155
+ }
156
+
157
+ /**
158
+ * "No Est P&L: XYZ (shares and value per share moved as across a split, and the corporate actions could not be
159
+ * read to tell)": lines left without a figure, in the order given (largest first), `leftOut` opening it, and with
160
+ * `bookShare` what they weighed in the book at the quarter's start.
161
+ */
162
+ export function splitUnreadText(lines: readonly (SplitLine & { late?: boolean })[], leftOut: string, bookShare?: number | null): string {
163
+ const share = bookShare != null && bookShare > 0 ? `, ${bookShareText(bookShare)} of the book at the quarter's start` : "";
164
+ return `${leftOut}${share}: ${listedLines(lines, lineName)} (shares and value per share moved as across a split, and ${unreadReason(lines)})`;
165
+ }
166
+
167
+ type UnreadRow = SplitLine & { splitUnread?: boolean; splitLate?: boolean };
168
+
148
169
  /** The note for the lines of a Holdings table left without an Est P&L because their split could not be confirmed: a data limitation, the pane's notice as well as the report's. */
149
- export function holdingUnreadNotes(rows: readonly (SplitLine & { splitUnread?: boolean })[]): string[] {
150
- const unread = rows.filter((row) => row.splitUnread);
170
+ export function holdingUnreadNotes(rows: readonly UnreadRow[]): string[] {
171
+ const unread = rows.filter((row) => row.splitUnread).map((row) => ({ ...row, late: row.splitLate }));
151
172
  return unread.length ? [splitUnreadText(unread, "No Est P&L")] : [];
152
173
  }
153
174
 
154
175
  /** What a Holdings report says of its lines that moved as across a split: the ones priced split-adjusted (method, so a report's note only), and the ones left without a figure. */
155
- export function holdingSplitNotes(rows: readonly (SplitLine & { splitRatio?: number; splitUnread?: boolean })[]): string[] {
176
+ export function holdingSplitNotes(rows: readonly (UnreadRow & { splitRatio?: number })[]): string[] {
156
177
  const adjusted = rows.flatMap((row) => row.splitRatio ? [{ ...row, ratio: row.splitRatio }] : []);
157
178
  return [...(adjusted.length ? [splitAdjustedText(adjusted, "Est P&L split-adjusted")] : []), ...holdingUnreadNotes(rows)];
158
179
  }
@@ -195,6 +195,8 @@ export interface FundHoldingRow {
195
195
  splitRatio?: number;
196
196
  /** The line moved as across a split and its corporate actions could not be read to tell: Est P&L is left empty, not priced as a crash or a surge, and its share change stays as filed. */
197
197
  splitUnread?: boolean;
198
+ /** With `splitUnread`: the lookups' time ran out before its corporate actions were read. */
199
+ splitLate?: boolean;
198
200
  sharesChange: number | null;
199
201
  sharesChangePercent: number | null;
200
202
  action: HoldingAction;
@@ -90,7 +90,7 @@ export function adrPairFigures(comparison: DepositaryPairComparison): AdrPairFig
90
90
  value: comparison.premiumPercent == null ? "—" : premiumText(comparison.premiumPercent),
91
91
  ...(comparison.premiumPercent == null ? {} : { detail: "at spot" }),
92
92
  },
93
- { id: "ratio", label: "Ratio", value: adrRatioText(comparison.ratio) ?? `1:${ratioCount(comparison.ratio)}` },
93
+ { id: "ratio", label: "Ratio", value: adrRatioText(comparison.ratio, comparison.home.symbol) ?? `1:${ratioCount(comparison.ratio)}` },
94
94
  ];
95
95
  }
96
96
 
@@ -99,6 +99,18 @@ export function statementMetricValue(
99
99
 
100
100
  export const FINANCIAL_COL_W = 18;
101
101
  export const FINANCIAL_LABEL_W = 28;
102
+ const FINANCIAL_LABEL_MIN_W = 12;
103
+
104
+ /**
105
+ * The metric column's width in a table `width` cells wide: 28 where a period
106
+ * fits beside it, narrower (down to 12, labels cut with an ellipsis) where it
107
+ * would otherwise take every value off screen, as a 36-column Financials pane
108
+ * once showed nothing but metric names and "more →". The other 6 cells are the
109
+ * pane's padding, the table's, the column gap and the scrollbar.
110
+ */
111
+ export function financialLabelWidth(width: number): number {
112
+ return Math.max(FINANCIAL_LABEL_MIN_W, Math.min(FINANCIAL_LABEL_W, width - FINANCIAL_COL_W - 6));
113
+ }
102
114
  const FINANCIAL_GROWTH_W = 7;
103
115
  const FINANCIAL_VALUE_W = FINANCIAL_COL_W - FINANCIAL_GROWTH_W;
104
116
 
@@ -12,7 +12,7 @@ import type { PricePoint } from "../../../../types/financials";
12
12
  import { padTo } from "../../../../utils/format";
13
13
  import { useBoundTicker, useTickerRequest } from "../../shared/ticker-request";
14
14
  import type { FinancialTableStatement } from "./aggregation";
15
- import { FINANCIAL_COL_W, FINANCIAL_LABEL_W } from "./model";
15
+ import { FINANCIAL_COL_W, financialLabelWidth } from "./model";
16
16
  import { loadPeriodEndHistory } from "./period-end-history";
17
17
  import {
18
18
  formatRatioInput,
@@ -170,6 +170,6 @@ export function RatioTable({
170
170
  );
171
171
  }
172
172
 
173
- export function ratioMetricColumn(): RatioTableColumn {
174
- return { id: "metric", kind: "metric", label: "Ratio", width: FINANCIAL_LABEL_W, align: "left" };
173
+ export function ratioMetricColumn(width: number): RatioTableColumn {
174
+ return { id: "metric", kind: "metric", label: "Ratio", width: financialLabelWidth(width), align: "left" };
175
175
  }
@@ -19,7 +19,7 @@ import { padTo } from "../../../../utils/format";
19
19
  import { filledPeriodsNote, stalePeriodNote } from "../../../../utils/financial-statements";
20
20
  import {
21
21
  FINANCIAL_COL_W,
22
- FINANCIAL_LABEL_W,
22
+ financialLabelWidth,
23
23
  FINANCIAL_SUB_TABS,
24
24
  buildFinancialRows,
25
25
  canCompareFinancialRow,
@@ -305,7 +305,7 @@ export function ResolvedFinancialsTab({
305
305
  id: "metric",
306
306
  kind: "metric",
307
307
  label: "Metric",
308
- width: FINANCIAL_LABEL_W,
308
+ width: financialLabelWidth(width),
309
309
  align: "left",
310
310
  },
311
311
  ...displayStatements.map((statement, index): FinancialTableColumn => ({
@@ -323,7 +323,7 @@ export function ResolvedFinancialsTab({
323
323
  align: "right",
324
324
  headerColor: statement.date === "TTM" ? colors.textBright : colors.textDim,
325
325
  })),
326
- ], [annualDates, comparisonCurrency, displayStatements, isAnnual, yearEndMonth]);
326
+ ], [annualDates, comparisonCurrency, displayStatements, isAnnual, width, yearEndMonth]);
327
327
  const { rows, unit } = useMemo(
328
328
  () => shareFinancialUnit(buildFinancialRows(subTab.rows, displayStatements, collapsedGroups)),
329
329
  [collapsedGroups, displayStatements, subTab.rows],
@@ -440,9 +440,9 @@ export function ResolvedFinancialsTab({
440
440
  isValuation, quarterlyStatements, ratioTab, resolvedPeriod, financials?.profile,
441
441
  ]);
442
442
  const ratioColumns = useMemo<RatioTableColumn[]>(() => [
443
- ratioMetricColumn(),
443
+ ratioMetricColumn(width),
444
444
  ...columns.flatMap((column, index) => column.kind === "statement" ? [{ ...column, index: index - 1 }] : []),
445
- ], [columns]);
445
+ ], [columns, width]);
446
446
 
447
447
  // The Balance Sheet and Liquidity show cash, which an offering filed since the latest balance sheet is not in yet.
448
448
  const { symbol: boundSymbol, exchange: boundExchange } = useBoundTicker();
@@ -45,7 +45,9 @@ import {
45
45
  quotedPriceDivisor,
46
46
  } from "../../../cli/history-rows";
47
47
  import { formatUtcTime } from "../../../utils/utc-time";
48
- import { maxDrawdown, maxDrawdownText } from "../../../utils/max-drawdown";
48
+ import { closeMoves } from "../../../utils/max-drawdown";
49
+ import { isYieldIndexSymbol } from "../../../tickers/index-roots";
50
+ import { parsePublicTickerKey } from "../../../utils/exchanges";
49
51
  import { isPastPriceWindow, loadPriceWindowHistory, priceWindowText, readPriceWindow, type PriceWindow } from "../../../utils/price-window";
50
52
  import { historyCoverageNotice } from "../../../sources/history-coverage";
51
53
  import { getChartResolutionLabel, isIntradayResolution, RANGE_HISTORY_RESOLUTION, type ManualChartResolution } from "../../../time-series/resolution";
@@ -111,7 +113,8 @@ export const financialStatementsHeadless: HeadlessPaneDefinition<"rows"> = {
111
113
  const receiptPeriods = table?.statements.filter(({ shareBasis }) => shareBasis === "depositary_receipt").map(({ date }) => date) ?? [];
112
114
  const allReceipts = receiptPeriods.length > 0 && receiptPeriods.length === table?.statements.length;
113
115
  const shareBases = new Set(table?.statements.map(({ shareBasis }) => shareBasis ?? null));
114
- const ratio = adrRatioText(financials.fundamentals?.adrRatio ?? financials.quote?.adrRatio);
116
+ const ratio = adrRatioText(financials.fundamentals?.adrRatio ?? financials.quote?.adrRatio,
117
+ (financials.fundamentals?.depositaryPair ?? financials.quote?.depositaryPair)?.ordinary[0]);
115
118
  const shareBasisNotice = receiptPeriods.length === 0 || !table?.rows.some(isPerShareFinancialRow) ? null
116
119
  : allReceipts
117
120
  ? `Share counts are in ADRs and EPS is per ADR${ratio ? `; ${ratio}` : ""}.`
@@ -461,13 +464,12 @@ export const historicalPricesHeadless: HeadlessPaneDefinition<"rows"> = {
461
464
  ...(forming ? { periodToDate: forming } : closedDay ? { asOf: closedDay } : quotedAt ? { asOf: quotedAt } : {}),
462
465
  ...(dayToDate ? { basis: "daily bars", note: `the newest bar is ${DAY_SO_FAR_TEXT}`, ...(quote ? { asOf: new Date(quote.lastUpdated).toISOString() } : {}) } : {}),
463
466
  };
464
- // The largest fall from a close to a later one in the bars shown, said under the title.
465
- const drawdown = maxDrawdown(shown);
466
- const drawdownLine = drawdown ? maxDrawdownText(drawdown, { basis: `${historyBarSizeWord(size)} closes`, price: (value) => formatBarPrice(value, decimals),
467
- date: (value) => isDailyOrLongerBar(size) ? value.slice(0, 10) : formatUtcTime(value) }) : null;
467
+ // The largest fall from a close to a later one in the bars shown, said under the title; a yield's in bp, with its largest rise.
468
+ const { drawdown, runUp, lines: moveLines } = closeMoves(shown, drawdownScaleOf(symbol), { basis: `${historyBarSizeWord(size)} closes`,
469
+ price: (value) => formatBarPrice(value, decimals), date: (value) => isDailyOrLongerBar(size) ? value.slice(0, 10) : formatUtcTime(value) });
468
470
  // A wick left out of the range is said, though the bar's close still counts.
469
471
  const wickNotice = priceHistoryWickNotice(points.filter((point) => pricePointWickFlags(point).length > 0).length);
470
- const reportNotices = [drawdownLine, notice, wickNotice].filter((line): line is string => line != null);
472
+ const reportNotices = [...moveLines, notice, wickNotice].filter((line): line is string => line != null);
471
473
  return {
472
474
  rows: shown,
473
475
  columns: historyColumns(size, marked, false, false, decimals),
@@ -478,7 +480,7 @@ export const historicalPricesHeadless: HeadlessPaneDefinition<"rows"> = {
478
480
  ...(notice ? { complete: false } : {}),
479
481
  unavailableSymbols: rows.some((row) => row.close !== null) ? [] : [symbol],
480
482
  metadata: { symbol, range: window ? null : range, ...(window ? { requestedWindow: window } : {}), ...(size === "intraday" ? {} : { interval: size }),
481
- ...(allStart ? { sourceStart: allStart } : {}), maxDrawdown: drawdown,
483
+ ...(allStart ? { sourceStart: allStart } : {}), maxDrawdown: drawdown, ...(runUp ? { maxRunUp: runUp } : {}),
482
484
  ...(reportNotices.length ? { notices: reportNotices } : {}) },
483
485
  };
484
486
  },
@@ -535,10 +537,9 @@ export const returnsHeadless: HeadlessPaneDefinition<"rows"> = {
535
537
  const dayToDate = isTodayReturnRow(returns.at(-1), series.resolution, venue, now);
536
538
  const rows = forming || dayToDate ? [...unmarked.slice(0, -1), { ...unmarked.at(-1)!, partial: true }] : unmarked;
537
539
  const price = (value: unknown) => typeof value === "number" && Number.isFinite(value) ? value.toFixed(decimals) : "-";
538
- // The largest fall from a close to a later one in the window, said under the title.
539
- const drawdown = maxDrawdown(unmarked.map((row) => ({ date: row.time, close: row.close })));
540
- const maxDrawdownLine = drawdown ? maxDrawdownText(drawdown, { basis: `${BAR_INTERVAL_LABELS[series.resolution]} closes`, price,
541
- date: (value) => intraday ? formatUtcTime(value) : value.slice(0, 10) }) : null;
540
+ // The largest fall from a close to a later one in the window, said under the title; a yield's in bp, with its largest rise.
541
+ const { drawdown, runUp, lines: moveLines } = closeMoves(unmarked.map((row) => ({ date: row.time, close: row.close })), drawdownScaleOf(symbol),
542
+ { basis: `${BAR_INTERVAL_LABELS[series.resolution]} closes`, price, date: (value) => intraday ? formatUtcTime(value) : value.slice(0, 10) });
542
543
  const figures: HeadlessPaneColumn[] = [
543
544
  { key: "close", header: "Price", align: "right", format: price },
544
545
  { key: "intervalChange", header: "Int $", align: "right", format: price },
@@ -565,7 +566,7 @@ export const returnsHeadless: HeadlessPaneDefinition<"rows"> = {
565
566
  const textColumns: HeadlessPaneColumn[] = [timeColumn(true), ...textFigures];
566
567
  // An interval the range is too long for is served in the nearest longer bar; say so rather than switch silently.
567
568
  const notices = [
568
- maxDrawdownLine,
569
+ ...moveLines,
569
570
  baseDay ? `Totals ${periodBaseText(baseDay, now)}.` : null,
570
571
  series.resolution !== requested
571
572
  ? `${getChartResolutionLabel(requested)} bars do not ${window ? `cover ${priceWindowText(window)}` : `reach back ${range}`}; these are ${getChartResolutionLabel(series.resolution)} bars.`
@@ -605,8 +606,12 @@ export const returnsHeadless: HeadlessPaneDefinition<"rows"> = {
605
606
  ...(series.lastSession ? { marketClosed: true, lastSession: series.lastSession } : {}),
606
607
  basis: "Price returns of bar closes; dividends are not included",
607
608
  maxDrawdown: drawdown,
609
+ ...(runUp ? { maxRunUp: runUp } : {}),
608
610
  ...(notices.length ? { notices } : {}),
609
611
  },
610
612
  };
611
613
  },
612
614
  };
615
+
616
+ /** A Cboe yield index (^TNX) moves by its level, in bp; anything else by its return. */
617
+ const drawdownScaleOf = (symbol: string) => isYieldIndexSymbol(parsePublicTickerKey(symbol).symbol) ? "yield" as const : "return" as const;
@@ -45,6 +45,7 @@ export const tickerDetailModule: PluginModule = {
45
45
  icon: "D",
46
46
  get component(): typeof import("./pane").TickerResearchPane { const { TickerResearchPane } = require("./pane"); return TickerResearchPane; },
47
47
  defaultPosition: "right",
48
+ shareItem: { ticker: true },
48
49
  tickerFollower: true,
49
50
  // DES and ADR open this pane; ADR's window is named by its params (the tab it asked for), so settings never say whose a window is.
50
51
  identitySettings: [],
@@ -71,6 +72,7 @@ export const tickerDetailModule: PluginModule = {
71
72
  get component(): typeof import("./financials/pane").FinancialAnalysisPane { const { FinancialAnalysisPane } = require("./financials/pane"); return FinancialAnalysisPane; },
72
73
  headless: financialStatementsHeadless,
73
74
  defaultPosition: "right",
75
+ shareItem: { ticker: true },
74
76
  tickerFollower: true,
75
77
  defaultMode: "floating",
76
78
  defaultFloatingSize: { width: 98, height: 30 },
@@ -100,6 +102,7 @@ export const tickerDetailModule: PluginModule = {
100
102
  get component(): typeof import("./data-panes/historical-prices").HistoricalPricesPane { const { HistoricalPricesPane } = require("./data-panes/historical-prices"); return HistoricalPricesPane; },
101
103
  headless: historicalPricesHeadless,
102
104
  defaultPosition: "right",
105
+ shareItem: { ticker: true },
103
106
  tickerFollower: true,
104
107
  defaultMode: "floating",
105
108
  defaultFloatingSize: { width: 92, height: 26 },
@@ -113,6 +116,7 @@ export const tickerDetailModule: PluginModule = {
113
116
  get component(): typeof import("./data-panes/returns-pane").ReturnsPane { const { ReturnsPane } = require("./data-panes/returns-pane"); return ReturnsPane; },
114
117
  headless: returnsHeadless,
115
118
  defaultPosition: "right",
119
+ shareItem: { ticker: true },
116
120
  tickerFollower: true,
117
121
  defaultMode: "floating",
118
122
  defaultFloatingSize: { width: 100, height: 28 },
@@ -31,7 +31,7 @@ import { getPortfolioPositionMetrics, getPortfolioQuoteDisplay, resolvePortfolio
31
31
  import { listingDividendYield, liveForwardPE, liveMarketCapitalization, liveTrailingPE } from "../../../../market-data/quotes/live-valuation";
32
32
  import { atRegularSessionPrice } from "../../../../market-data/quotes/regular-session-valuation";
33
33
  import { formatReportedMoney, REPORTING_CURRENCY_NOT_SOURCED } from "../../../../utils/reported-money";
34
- import { enterpriseValueCheck, enterpriseValueNotMeaningful, fundamentalsCurrency, isBankEnterpriseValue, fundamentalsEpsCurrency, reportedEnterpriseValue } from "../../../../utils/fundamentals";
34
+ import { enterpriseValueCheck, enterpriseValueGapIsLarge, enterpriseValueNotMeaningful, fundamentalsCurrency, isBankEnterpriseValue, fundamentalsEpsCurrency, reportedEnterpriseValue } from "../../../../utils/fundamentals";
35
35
  import { formatShortDate } from "../../../../utils/datetime-format";
36
36
  import { safeExternalUrl } from "../../../../utils/external-url";
37
37
  import type { FundBondFacts } from "../../../../api-client/fund-facts";
@@ -232,7 +232,7 @@ export function buildOverviewStats({
232
232
  const { pair, receiptSide } = depositaryPair;
233
233
  const count = ratioCount(pair.ratio);
234
234
  stats.push(receiptSide
235
- ? { label: "ADR Ratio", value: `1:${count}`, detail: [adrRatioText(pair.ratio)!, `${count} sh per ADR`], link: ADR_PAIR }
235
+ ? { label: "ADR Ratio", value: `1:${count}`, detail: [adrRatioText(pair.ratio, pair.ordinary[0])!, `${count} sh per ADR`], link: ADR_PAIR }
236
236
  : { label: "ADR", value: pair.receipt, detail: [`1 ADR = ${count} of these shares`, `1:${count}`], link: ADR_PAIR });
237
237
  }
238
238
  if (cedearRatio) {
@@ -334,9 +334,11 @@ export function buildOverviewStats({
334
334
  } else if (fundamentals?.unavailableFields?.includes("enterpriseValue")) {
335
335
  stats.push({ label: "EV", value: "—" });
336
336
  } else if (enterpriseValue != null) {
337
- // More than 5% from market cap + debt - cash: the provider's, with the computed figure where it fits.
337
+ // More than 10% from market cap + debt - cash: the provider's, with the computed figure where it fits.
338
+ // Closer than that it is the valuation panes' detail (enterpriseValueGapIsLarge).
338
339
  const check = enterpriseValueCheck(priced);
339
- const computed = check?.status === "differs" && check.computed != null ? formatCompact(check.computed) : undefined;
340
+ const computed = check?.status === "differs" && check.computed != null && enterpriseValueGapIsLarge(priced)
341
+ ? formatCompact(check.computed) : undefined;
340
342
  stats.push({
341
343
  label: "EV",
342
344
  value: formatCompactCurrency(enterpriseValue, quoteCurrency),
@@ -38,7 +38,7 @@ import type { TickerRecord } from "../../../types/ticker";
38
38
  import { Box, ScrollBox, Text, useUiCapabilities } from "../../../ui";
39
39
  import { publicTickerKey, resolveExchangeTimeZone } from "../../../utils/exchanges";
40
40
  import { convertCurrency, displayWidth, formatPercentRaw, truncateToDisplayWidth } from "../../../utils/format";
41
- import { appTtmRate, enterpriseValueReconciliationNote, ttmAtAppRate, ttmConversionNote, withBankEnterpriseValue } from "../../../utils/fundamentals";
41
+ import { appTtmRate, enterpriseValueGapIsLarge, enterpriseValueReconciliationNote, ttmAtAppRate, ttmConversionNote, withBankEnterpriseValue } from "../../../utils/fundamentals";
42
42
  import { atRegularSessionPrice } from "../../../market-data/quotes/regular-session-valuation";
43
43
  import { zonedDateKey } from "../../../utils/zoned-date-time";
44
44
  import { sharesOutstandingInReceipts } from "../../../utils/depositary-receipt";
@@ -250,9 +250,11 @@ function ResolvedOverviewTab({ width, height, focused = false, ticker, financial
250
250
  panelId: "price",
251
251
  timeBasis: chartTimeZone ? { kind: "market", timeZone: chartTimeZone } : undefined,
252
252
  });
253
- // A provider EV off market cap + debt - cash, or why a withdrawn one is unavailable, at the
254
- // regular session price the EV beside it is shown at.
255
- const enterpriseValueNote = enterpriseValueReconciliationNote(atRegularSessionPrice({ quote, fundamentals: withBankEnterpriseValue(fundamentals, profile) }).fundamentals);
253
+ // A provider EV well off market cap + debt - cash, or why a withdrawn one is unavailable, at the
254
+ // regular session price the EV beside it is shown at. A gap of a few percent is the valuation panes' detail.
255
+ const pricedForEnterpriseValue = atRegularSessionPrice({ quote, fundamentals: withBankEnterpriseValue(fundamentals, profile) }).fundamentals;
256
+ const enterpriseValueNote = enterpriseValueGapIsLarge(pricedForEnterpriseValue)
257
+ ? enterpriseValueReconciliationNote(pricedForEnterpriseValue) : undefined;
256
258
  // Months of cash, for a company that burns it, and an offering since its balance sheet that the cash is not in yet.
257
259
  const runway = useMemo(() => financials ? cashRunway(financials) : null, [financials]);
258
260
  const runwayOfferingNote = useOfferingNote(ticker.metadata.ticker, ticker.metadata.exchange, runway?.periodEnd ?? null, runway?.trailing?.kind === "months");
@@ -61,25 +61,23 @@ export function validateTape(data: TapeSnapshot, symbol: string, exchange: strin
61
61
  /** The latest tape, or with a `range` that window of the session. */
62
62
  export async function fetchTape(symbol: string, exchange: string, signal?: AbortSignal,
63
63
  client: Pick<typeof apiClient, "getCloudTape"> = apiClient, range?: TapeRange): Promise<TapeSnapshot> {
64
- try { return validateTape(await (range ? client.getCloudTape(symbol, exchange, signal, range) : client.getCloudTape(symbol, exchange, signal)), symbol, exchange); }
64
+ // The tape names US venues by their codes: a listing found as NYSEARCA is asked as ARCA, as it is answered.
65
+ const venue = canonicalExchange(exchange);
66
+ try { return validateTape(await (range ? client.getCloudTape(symbol, venue, signal, range) : client.getCloudTape(symbol, venue, signal)), symbol, exchange); }
65
67
  catch (error) {
66
68
  if (error instanceof ApiRequestError && [404, 503].includes(error.status ?? 0)) throw new Error("Time and sales is not available yet.");
67
69
  // A rejected request answers with an unavailable snapshot; show its reason, not the JSON body.
68
70
  if (error instanceof ApiRequestError) {
69
- const reason = tapeRejection(error.message);
71
+ const reason = tapeGap(error.details);
70
72
  if (reason) throw new Error(reason);
71
73
  }
72
74
  throw error;
73
75
  }
74
76
  }
75
77
 
76
- /** The first stated gap of an unavailable tape snapshot sent as an error body. */
77
- export function tapeRejection(body: string): string | null {
78
- try {
79
- const value = JSON.parse(body) as { gaps?: unknown };
80
- return Array.isArray(value?.gaps) && typeof value.gaps[0] === "string" ? value.gaps[0] : null;
81
- } catch {
82
- // Intentional ignore: an error body that is not JSON names no gap, so the request's own error stands.
83
- return null;
84
- }
78
+ /** The first stated gap of an unavailable tape snapshot, as the request's parsed error body holds it. */
79
+ function tapeGap(details: Readonly<Record<string, unknown>> | undefined): string | null {
80
+ const gaps = details?.gaps;
81
+ return Array.isArray(gaps) && typeof gaps[0] === "string" ? gaps[0] : null;
85
82
  }
83
+
@@ -3,7 +3,7 @@ import { createTickerSurfacePaneTemplate } from "../shared/ticker-surface";
3
3
  import { quoteRecapHeadless, timeSalesHeadless } from "./headless";
4
4
  export const timeSalesModule: PluginModule = {
5
5
  panes: [{ id: "time-sales", name: "Time and Sales", icon: "T", get component(): typeof import("./pane").TimeSalesPane { const { TimeSalesPane } = require("./pane"); return TimeSalesPane; },
6
- defaultPosition: "right", tickerFollower: true, defaultMode: "floating", defaultFloatingSize: { width: 104, height: 28 },
6
+ defaultPosition: "right", shareItem: { ticker: true }, tickerFollower: true, defaultMode: "floating", defaultFloatingSize: { width: 104, height: 28 },
7
7
  tableExport: true, headless: timeSalesHeadless, settings: { title: "Time and Sales", fields: [{ key: "tab", label: "View", type: "select", options: [{ value: "trades", label: "Trades" }, { value: "quotes", label: "NBBO" }] }] } }],
8
8
  paneTemplates: [
9
9
  { ...createTickerSurfacePaneTemplate({ id: "time-sales-tas", paneId: "time-sales", label: "Time and Sales",