gloomberb 0.20.0 → 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 (86) hide show
  1. package/package.json +1 -1
  2. package/patches/electrobun-devkit@2.0.5.patch +268 -8
  3. package/src/api-client/crypto-markets.ts +20 -2
  4. package/src/api-client/fund-facts.ts +23 -1
  5. package/src/api-client/types/filings-and-calls.ts +6 -0
  6. package/src/app/runtime/plugin-seed.ts +119 -0
  7. package/src/app/runtime/startup.ts +45 -9
  8. package/src/app.tsx +1 -0
  9. package/src/cli/board-coins.ts +38 -5
  10. package/src/cli/commands/crypto-hints.ts +8 -1
  11. package/src/cli/commands/market.ts +29 -26
  12. package/src/cli/commands/overview.ts +13 -6
  13. package/src/cli/commands/ticker.ts +61 -14
  14. package/src/cli/company-name-hint.ts +19 -0
  15. package/src/cli/entry.ts +10 -4
  16. package/src/cli/glossary.ts +25 -0
  17. package/src/cli/helpers.ts +4 -2
  18. package/src/cli/not-a-ticker.ts +26 -1
  19. package/src/cli/pane-functions/freshness.ts +45 -29
  20. package/src/cli/pane-functions/market-session.ts +14 -5
  21. package/src/cli/restore-plugins.ts +164 -51
  22. package/src/components/chart-table/header.tsx +10 -1
  23. package/src/components/chart-table/layout.ts +14 -5
  24. package/src/components/command-bar/panel/index.tsx +13 -0
  25. package/src/components/command-bar/panel/layout.ts +7 -0
  26. package/src/components/command-bar/panel/runtime.ts +1 -0
  27. package/src/components/command-bar/panel/types.ts +2 -0
  28. package/src/i18n/es.ts +3 -0
  29. package/src/i18n/ja.ts +3 -0
  30. package/src/i18n/ko.ts +3 -0
  31. package/src/i18n/zh-cn.ts +3 -0
  32. package/src/i18n/zh-tw.ts +3 -0
  33. package/src/market-data/fund-facts.ts +7 -1
  34. package/src/market-data/market/change-basis.ts +20 -0
  35. package/src/market-data/market/format.ts +62 -2
  36. package/src/market-data/market/futures-week.ts +3 -1
  37. package/src/plugins/builtin/chart-composer/headless.ts +57 -17
  38. package/src/plugins/builtin/chart-composer/session-range.ts +82 -3
  39. package/src/plugins/builtin/correlation/compute.ts +8 -2
  40. package/src/plugins/builtin/correlation/headless.ts +10 -9
  41. package/src/plugins/builtin/correlation/history.ts +30 -0
  42. package/src/plugins/builtin/correlation/matrix/model.ts +10 -10
  43. package/src/plugins/builtin/correlation/relationship/model.ts +3 -6
  44. package/src/plugins/builtin/correlation/relationship/pane.tsx +1 -2
  45. package/src/plugins/builtin/crypto-board/client.ts +6 -1
  46. package/src/plugins/builtin/crypto-board/defi-view.tsx +12 -1
  47. package/src/plugins/builtin/crypto-board/defi.ts +44 -7
  48. package/src/plugins/builtin/crypto-board/headless.ts +83 -12
  49. package/src/plugins/builtin/crypto-board/model.ts +30 -6
  50. package/src/plugins/builtin/crypto-board/pane.tsx +13 -2
  51. package/src/plugins/builtin/perps/headless.ts +8 -2
  52. package/src/plugins/builtin/risk-factors/index.tsx +2 -28
  53. package/src/plugins/builtin/risk-factors/lock-note.ts +58 -0
  54. package/src/plugins/builtin/risk-factors/pane.tsx +10 -3
  55. package/src/plugins/builtin/scanner/hilo-model.ts +4 -3
  56. package/src/plugins/builtin/sec/fund-facts.ts +45 -11
  57. package/src/plugins/builtin/sec/headless.ts +30 -1
  58. package/src/plugins/builtin/sec/index.tsx +26 -5
  59. package/src/plugins/builtin/shared/pro-lock-note.ts +5 -1
  60. package/src/plugins/builtin/ticker-detail/overview/model.ts +14 -6
  61. package/src/plugins/builtin/time-sales/headless.ts +23 -7
  62. package/src/plugins/builtin/time-sales/index.tsx +2 -2
  63. package/src/plugins/extracted-plugins.ts +49 -24
  64. package/src/plugins/installer.ts +220 -31
  65. package/src/plugins/running-installs.ts +34 -0
  66. package/src/plugins/seed-progress.ts +72 -0
  67. package/src/renderers/electrobun/bun/desktop/backend.ts +14 -0
  68. package/src/renderers/electrobun/bun/desktop/host-requests.ts +14 -7
  69. package/src/renderers/electrobun/bun/desktop/initialization.ts +24 -14
  70. package/src/renderers/electrobun/bun/index.ts +5 -0
  71. package/src/renderers/electrobun/bun/window/context-menu-thread.ts +84 -0
  72. package/src/renderers/electrobun/bun/window/native-call-thread.ts +224 -0
  73. package/src/renderers/electrobun/bun/window/native-timing.ts +10 -0
  74. package/src/renderers/electrobun/bun/window/script-for-webview.ts +15 -0
  75. package/src/renderers/electrobun/bun/window/webview-script-thread.ts +82 -0
  76. package/src/renderers/electrobun/shared/protocol.ts +13 -2
  77. package/src/renderers/electrobun/view/backend-rpc.ts +7 -0
  78. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +1 -1
  79. package/src/renderers/electrobun/view/main.tsx +4 -3
  80. package/src/renderers/opentui/start.tsx +3 -0
  81. package/src/telemetry/stall-reports.ts +21 -4
  82. package/src/utils/main-thread-stall.ts +21 -5
  83. package/src/utils/perf-marks.ts +88 -9
  84. package/src/utils/reported-money.ts +9 -2
  85. package/src/utils/sec.ts +34 -3
  86. package/src/plugins/seed-notice.ts +0 -20
@@ -1,13 +1,11 @@
1
1
  import type { PluginModule } from "../plugin-module";
2
- import type { PaneLock } from "../../../types/plugin";
3
- import { filesForm } from "../shared/free-routes";
4
- import { proLockNote } from "../shared/pro-lock-note";
5
2
  import { createTickerSurfacePaneTemplate } from "../shared/ticker-surface";
6
3
  import {
7
4
  attachRiskFactorsPersistence,
8
5
  resetRiskFactorsPersistence,
9
6
  } from "./data";
10
7
  import { riskFactorsHeadless } from "./headless";
8
+ import { riskFactorsLockNote } from "./lock-note";
11
9
 
12
10
 
13
11
  import { RISK_FACTORS_PANE_ID, RiskFactorsPane, RiskFactorsResearchTab } from "./pane";
@@ -16,30 +14,6 @@ import { isKnownNonUsListing } from "../../../utils/sec";
16
14
  const description =
17
15
  "The company's 10-K risk factors, and what was added, dropped, or rewritten since the prior year.";
18
16
 
19
- /**
20
- * RISK is Pro whole (`useProFeatureWall`). The 10-Ks it reads are in the SEC
21
- * filing list, which needs no account: `filings` lists them with a link to
22
- * each, where Item 1A is the risk factors as written, without RISK's grouping
23
- * or its changes since the year before. A foreign issuer files a 20-F instead
24
- * (ASML), whose Item 3.D holds them. A company that files neither (IAG on
25
- * LSE) has nothing in RISK either, and the note says so.
26
- */
27
- function riskFactorsLockNote(lock: PaneLock): Promise<string> {
28
- return proLockNote(lock, {
29
- token: "RISK",
30
- does: "it groups a 10-K's risk factors by theme and shows what was added, dropped or reworded since the year before",
31
- shows: "it",
32
- free: [{
33
- text: (ticker, company) => `gloom filings ${ticker} --form 10-K lists ${company}'s annual reports, each with its filing date and a link to the filing, whose Item 1A holds the risk factors as written.`,
34
- answers: (symbol, context) => filesForm(symbol, "10-K", context),
35
- }, {
36
- text: (ticker, company) => `gloom filings ${ticker} --form 20-F lists ${company}'s annual reports, each with its filing date and a link to the filing, whose Item 3.D holds the risk factors as written.`,
37
- answers: (symbol, context) => filesForm(symbol, "20-F", context),
38
- }],
39
- noneFor: (ticker) => `${ticker}'s company files no 10-K or 20-F with the SEC, so RISK has no risk factors for it.`,
40
- });
41
- }
42
-
43
17
  export const riskFactorsModule: PluginModule = {
44
18
  setup(ctx) {
45
19
  attachRiskFactorsPersistence(ctx.persistence);
@@ -60,7 +34,7 @@ export const riskFactorsModule: PluginModule = {
60
34
  panes: [
61
35
  {
62
36
  id: RISK_FACTORS_PANE_ID,
63
- reportLockNote: riskFactorsLockNote,
37
+ reportLockNote: (lock) => riskFactorsLockNote(lock),
64
38
  reportRequirements: ["Gloom Cloud Pro"],
65
39
  name: "Risk Factors",
66
40
  icon: "R",
@@ -0,0 +1,58 @@
1
+ import { getWallSummary, type WallSummary } from "../../../api-client/wall-summary";
2
+ import type { PaneLock } from "../../../types/plugin";
3
+ import { filesForm } from "../shared/free-routes";
4
+ import { resolveHeadlessInstrument } from "../shared/headless-market-data";
5
+ import { proLockNote, type FreeRoute } from "../shared/pro-lock-note";
6
+
7
+ type ReadSummary = (wall: string, symbol: string, exchange?: string) => Promise<WallSummary | null>;
8
+
9
+ /**
10
+ * How gloom.sh spells a US ticker in a page's address: lower case, a share
11
+ * class after a dash (`brk-b`), as its canonical link does. The venue is no
12
+ * part of it: `aapl:nasdaq` is no page.
13
+ */
14
+ const pageTicker = (symbol: string) => symbol.trim().toLowerCase().replace(/[./]/g, "-");
15
+
16
+ /**
17
+ * The company's risk factor page on gloom.sh, which needs no account: each
18
+ * 10-K's risks with what was added, dropped or reworded. It is there for a
19
+ * company RISK has read a 10-K of, which the public wall summary counts, and
20
+ * named by the listing that check resolved, not the argument as typed.
21
+ */
22
+ function webRoute(readSummary: ReadSummary): FreeRoute {
23
+ let resolved: string | null = null;
24
+ return {
25
+ text: (ticker, company) => `gloom.sh/stocks/${pageTicker(resolved ?? ticker)}/risk-factors has ${company}'s risk factors from each 10-K, with what was added, dropped or reworded since the year before.`,
26
+ answers: async (symbol, context) => {
27
+ const { symbol: ticker, exchange } = await resolveHeadlessInstrument(context, symbol);
28
+ const summary = await readSummary("risk-wall", ticker, exchange);
29
+ const has = summary?.items.some((item) => item.label === "risk_count" && Number(item.value) > 0) ?? false;
30
+ if (has) resolved = ticker;
31
+ return has;
32
+ },
33
+ };
34
+ }
35
+
36
+ /**
37
+ * RISK is Pro whole (`useProFeatureWall`). Its reports are open on gloom.sh,
38
+ * one page per company, and the 10-Ks it reads are in the SEC filing list,
39
+ * which needs no account either: `filings` lists them with a link to each,
40
+ * where Item 1A is the risk factors as written. A foreign issuer files a 20-F
41
+ * instead (ASML), whose Item 3.D holds them. A company that files neither
42
+ * (IAG on LSE) has nothing in RISK either, and the note says so.
43
+ */
44
+ export function riskFactorsLockNote(lock: PaneLock, readSummary: ReadSummary = getWallSummary): Promise<string> {
45
+ return proLockNote(lock, {
46
+ token: "RISK",
47
+ does: "it groups a 10-K's risk factors by theme and shows what was added, dropped or reworded since the year before",
48
+ shows: "it",
49
+ free: [webRoute(readSummary), {
50
+ text: (ticker, company) => `gloom filings ${ticker} --form 10-K lists ${company}'s annual reports, each with its filing date and a link to the filing, whose Item 1A holds the risk factors as written.`,
51
+ answers: (symbol, context) => filesForm(symbol, "10-K", context),
52
+ }, {
53
+ text: (ticker, company) => `gloom filings ${ticker} --form 20-F lists ${company}'s annual reports, each with its filing date and a link to the filing, whose Item 3.D holds the risk factors as written.`,
54
+ answers: (symbol, context) => filesForm(symbol, "20-F", context),
55
+ }],
56
+ noneFor: (ticker) => `${ticker}'s company files no 10-K or 20-F with the SEC, so RISK has no risk factors for it.`,
57
+ });
58
+ }
@@ -71,6 +71,8 @@ function RiskLine({
71
71
  );
72
72
  }
73
73
 
74
+ const NO_RISK_FACTORS = "This 10-K lists no risk factors.";
75
+
74
76
  const RISK_WALL: ProFeatureWallCopy = {
75
77
  placement: "risk-wall",
76
78
  action: "read risk factors",
@@ -170,14 +172,17 @@ function RiskFactorsReader({
170
172
  if (year === null) return <EmptyState title={`No 10-K risk factors on file for ${ticker}.`} />;
171
173
 
172
174
  const diff = report?.diff ?? null;
175
+ // A smaller reporting company's 10-K need not list risk factors. Its report
176
+ // has none to read or compare, only the filing to open.
177
+ const listsNone = report ? report.listsNoRiskFactors === true || report.riskCount === 0 : false;
173
178
  // A choice of years names the year in the tabs or the filter; a single
174
179
  // report says which one it is here.
175
180
  const meta = report
176
181
  ? [
177
182
  years.length > 1 ? null : `${report.reportYear} 10-K`,
178
183
  `Filed ${report.filedAt?.slice(0, 10) || "unavailable"}`,
179
- `updated ${report.updatedAt?.slice(0, 10) || "unavailable"}`,
180
- diff ? null : "no prior year on file",
184
+ listsNone ? null : `updated ${report.updatedAt?.slice(0, 10) || "unavailable"}`,
185
+ diff || listsNone ? null : "no prior year on file",
181
186
  ].filter(Boolean).join(" · ")
182
187
  : "";
183
188
 
@@ -208,7 +213,9 @@ function RiskFactorsReader({
208
213
  scrollY
209
214
  paddingX={1}
210
215
  >
211
- {report ? (
216
+ {report && listsNone ? (
217
+ <PaneStatusBody empty emptyTitle={report.overview || NO_RISK_FACTORS} />
218
+ ) : report ? (
212
219
  <Box
213
220
  flexDirection="column"
214
221
  width={nativePaneChrome ? "100%" : bodyWidth}
@@ -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,
@@ -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
  }
@@ -30,7 +30,7 @@ import { NO_CURRENT_DIVIDEND } from "../../../../utils/forward-dividend";
30
30
  import { getPortfolioPositionMetrics, getPortfolioQuoteDisplay, resolvePortfolioMarketValue, resolvePortfolioPositionPnl, portfolioPnlPercent, signedPositionDirection } from "../../../../portfolio/position-metrics";
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
- import { formatReportedMoney } from "../../../../utils/reported-money";
33
+ import { formatReportedMoney, REPORTING_CURRENCY_NOT_SOURCED } from "../../../../utils/reported-money";
34
34
  import { enterpriseValueCheck, enterpriseValueNotMeaningful, fundamentalsCurrency, fundamentalsEpsCurrency, reportedEnterpriseValue } from "../../../../utils/fundamentals";
35
35
  import { formatShortDate } from "../../../../utils/datetime-format";
36
36
  import { safeExternalUrl } from "../../../../utils/external-url";
@@ -185,7 +185,15 @@ export function buildOverviewStats({
185
185
  runway?: CashRunway | null;
186
186
  }): StatField[] {
187
187
  const stats: StatField[] = [];
188
- const money = (value: number, perShare = false) => formatReportedMoney(value, fundamentalsCurrency({ fundamentals, financialCurrency, quote }), perShare);
188
+ // Amounts no source names the currency of are bare; the first says so after it, once for all of them.
189
+ let unsourcedSaid = false;
190
+ const reported = (value: number, currency: string | undefined, perShare = false): Pick<StatField, "value" | "detail"> => {
191
+ const text = formatReportedMoney(value, currency, perShare);
192
+ if (currency?.trim() || unsourcedSaid || !Number.isFinite(value)) return { value: text };
193
+ unsourcedSaid = true;
194
+ return { value: text, detail: [REPORTING_CURRENCY_NOT_SOURCED, "currency not sourced"] };
195
+ };
196
+ const money = (value: number) => reported(value, fundamentalsCurrency({ fundamentals, financialCurrency, quote }));
189
197
 
190
198
  // An index's 0 is volume nobody counts, not a quiet session: no Volume row.
191
199
  const volume = reportedQuoteVolume(quote);
@@ -242,7 +250,7 @@ export function buildOverviewStats({
242
250
  stats.push({ label: year ? `Fwd P/E ${year}` : "Fwd P/E", value: formatPriceEarnings(forwardPE) });
243
251
  }
244
252
  if (fundamentals?.eps != null) {
245
- stats.push({ label: "EPS", value: formatReportedMoney(fundamentals.eps, fundamentalsEpsCurrency({ fundamentals, financialCurrency, quote }), true) });
253
+ stats.push({ label: "EPS", ...reported(fundamentals.eps, fundamentalsEpsCurrency({ fundamentals, financialCurrency, quote }), true) });
246
254
  }
247
255
  if (fundamentals?.pegRatio != null) {
248
256
  stats.push({ label: "PEG", value: formatPriceEarnings(fundamentals.pegRatio, 2) });
@@ -290,13 +298,13 @@ export function buildOverviewStats({
290
298
  });
291
299
  }
292
300
  if (fundamentals?.revenue != null) {
293
- stats.push({ label: "Revenue", value: money(fundamentals.revenue) });
301
+ stats.push({ label: "Revenue", ...money(fundamentals.revenue) });
294
302
  }
295
303
  if (fundamentals?.netIncome != null) {
296
- stats.push({ label: "Net Income", value: money(fundamentals.netIncome) });
304
+ stats.push({ label: "Net Income", ...money(fundamentals.netIncome) });
297
305
  }
298
306
  if (fundamentals?.freeCashFlow != null) {
299
- stats.push({ label: "FCF", value: money(fundamentals.freeCashFlow) });
307
+ stats.push({ label: "FCF", ...money(fundamentals.freeCashFlow) });
300
308
  }
301
309
  const runwayField = runwayStat(runway);
302
310
  if (runwayField) stats.push(runwayField);
@@ -29,6 +29,12 @@ function listedNote(range: TapeRange, served: number, listed: number): string[]
29
29
 
30
30
  const WINDOW_OPTION = { reportOnly: "lists a window of the session in the text report" };
31
31
 
32
+ /** What each low and high of the report is taken over; the session's is the rule quote and GIP read the day's range by. */
33
+ function tapeRangeBasis(window: string): string {
34
+ return `${window} low and high: every print listed, odd lots included. Regular session low and high: consolidated prints that set a price, `
35
+ + "as quote and GIP read them; odd lots and special-condition prints set none.";
36
+ }
37
+
32
38
  /**
33
39
  * The window `--from`/`--to` ask for, read against the session the latest tape
34
40
  * serves, then fetched as that window. A server that predates windows answers
@@ -75,15 +81,17 @@ export const timeSalesHeadless: HeadlessPaneDefinition<"bundle"> = {
75
81
  ],
76
82
  discovery: { aliases: ["TAS", "QR"], dataRequirements: ["Gloom Cloud SIP trade and quote feed"],
77
83
  limitations: ["Bounded observed window, not a complete session.", "SIP is delayed fifteen minutes without realtime entitlement.", "Quote sizes are round lots.", "No Level 2 or inferred aggressor side."] },
78
- describe: (args) => `Time and sales ${args.argument ?? ""}`,
84
+ // QR is the NBBO view of the same tape: its report leads with the quotes, named as such.
85
+ describe: (args, result) => `${result?.metadata?.view === "quotes" ? "Quote recap" : "Time and sales"} ${args.argument ?? ""}`,
79
86
  async load(args, ctx) {
80
87
  const symbol = args.symbols[0] ?? (typeof args.argument === "string" ? args.argument : "");
81
88
  const instrument = await ctx.resolveInstrument?.(symbol);
82
89
  if (listedAbroad(symbol, instrument?.exchange)) {
83
90
  // Say why the table is empty and where the finest bars for it are, rather than the tape's bare "unavailable".
91
+ const quotesView = ctx.settings?.tab === "quotes";
84
92
  return { complete: false, sections: [
85
- { title: ctx.settings?.tab === "quotes" ? "NBBO" : "Trades", rows: [], empty: subMinuteDataMessage(symbol, "abroad") },
86
- ] };
93
+ { title: quotesView ? "NBBO" : "Trades", rows: [], empty: subMinuteDataMessage(symbol, "abroad") },
94
+ ], ...(quotesView ? { metadata: { view: "quotes" } } : {}) };
87
95
  }
88
96
  const exchange = instrument?.exchange ?? "";
89
97
  const from = String(args.options.from ?? "").trim(), to = String(args.options.to ?? "").trim();
@@ -104,14 +112,22 @@ export const timeSalesHeadless: HeadlessPaneDefinition<"bundle"> = {
104
112
  const freshness = data.feed === "sip"
105
113
  ? { status: "live" as const, cadence: "daily" as const }
106
114
  : { status: "delayed" as const, delayMinutes: Math.round(data.delaySeconds / 60), cadence: "daily" as const };
107
- return { freshness, ...(notes.length ? { notes } : {}), sections: [
115
+ const nbbo = { title: "NBBO", columns: formattedColumns(quotes, { bps }), rows: quotes };
116
+ const tape = [
108
117
  // The last price's rank among the window's prints, whole, as the pane shows it.
109
118
  { title: windowed ? "Window" : "Observed window", columns: formattedColumns(window, { vwap: price, low: price, high: price, pricePercentile: whole }), rows: window },
110
119
  { title: "Regular session", columns: formattedColumns([data.session], { high: price, low: price }), rows: [data.session] },
111
120
  { title: "Trades", columns: formattedColumns(trades, { price }), rows: trades },
112
- { title: "NBBO", columns: formattedColumns(quotes, { bps }), rows: quotes },
113
- ], errors: data.gaps, metadata: { source: data.source, feed: data.feed, delaySeconds: data.delaySeconds,
121
+ ];
122
+ // Each low says what it is the low of: the window's every print, the session's as quote and GIP read it.
123
+ const lows = [...notes, tapeRangeBasis(tape[0]!.title)];
124
+ const quotesView = ctx.settings?.tab === "quotes";
125
+ return { freshness, notes: lows, sections: quotesView ? [nbbo, ...tape] : [...tape, nbbo], errors: data.gaps, metadata: { source: data.source, feed: data.feed, delaySeconds: data.delaySeconds,
114
126
  asOf: data.asOf, observedFrom: data.observedFrom, generatedAt: data.generatedAt, status: data.status, ...(windowed ? { window: windowed.range } : {}),
115
- complete: data.status === "available", capacity: data.capacity, dropped: data.dropped, corrections: data.corrections, cancels: data.cancels, connected: data.connected } };
127
+ complete: data.status === "available", capacity: data.capacity, dropped: data.dropped, corrections: data.corrections, cancels: data.cancels, connected: data.connected,
128
+ ...(quotesView ? { view: "quotes" } : {}) } };
116
129
  },
117
130
  };
131
+
132
+ /** QR: the same tape, its NBBO first, named as such where it answers a listing abroad too. */
133
+ export const quoteRecapHeadless: HeadlessPaneDefinition<"bundle"> = { ...timeSalesHeadless, usListingsOnly: "Quote recap" };
@@ -1,6 +1,6 @@
1
1
  import type { PluginModule } from "../plugin-module";
2
2
  import { createTickerSurfacePaneTemplate } from "../shared/ticker-surface";
3
- import { timeSalesHeadless } from "./headless";
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
6
  defaultPosition: "right", tickerFollower: true, defaultMode: "floating", defaultFloatingSize: { width: 104, height: 28 },
@@ -12,6 +12,6 @@ export const timeSalesModule: PluginModule = {
12
12
  { ...createTickerSurfacePaneTemplate({ id: "time-sales-qr", paneId: "time-sales", label: "Quote Recap",
13
13
  description: "NBBO history: bid and ask with sizes, venues and spread.",
14
14
  keywords: ["nbbo", "quotes", "bid", "ask", "recap", "qr", "trades", "tick", "ticks", "tick data", "second", "seconds", "intraday", "milliseconds"],
15
- shortcut: "QR", viewKey: "QR", settings: () => ({ tab: "quotes" }) }), headless: timeSalesHeadless },
15
+ shortcut: "QR", viewKey: "QR", settings: () => ({ tab: "quotes" }) }), headless: quoteRecapHeadless },
16
16
  ],
17
17
  };