gloomberb 0.19.4 → 0.19.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 (128) hide show
  1. package/package.json +3 -1
  2. package/src/cli/commands/command-utils.ts +4 -0
  3. package/src/cli/commands/market.ts +119 -27
  4. package/src/cli/commands/search.ts +1 -1
  5. package/src/cli/commands/ticker.ts +10 -6
  6. package/src/cli/currency-name-hint.ts +60 -0
  7. package/src/cli/history-rows.ts +18 -1
  8. package/src/cli/known-gaps.ts +17 -2
  9. package/src/cli/not-a-ticker.ts +5 -3
  10. package/src/cli/pane-functions/catalog.ts +9 -1
  11. package/src/cli/pane-functions/headless.ts +7 -3
  12. package/src/cli/pane-functions/market-session.ts +6 -7
  13. package/src/cli/series-search.ts +4 -5
  14. package/src/components/chart/composite/panel-bitmap.ts +28 -2
  15. package/src/components/chart/composite/time-axis.ts +17 -2
  16. package/src/components/layout/shell/active-drag.ts +38 -7
  17. package/src/components/layout/shell/drag/magnets.ts +106 -0
  18. package/src/components/layout/window-controls.tsx +96 -35
  19. package/src/components/layout/window-fullscreen.ts +20 -0
  20. package/src/components/quote-flash.ts +36 -32
  21. package/src/market-data/coordinator/events.ts +17 -1
  22. package/src/market-data/frame-scheduler.ts +47 -10
  23. package/src/market-data/frame-wake.ts +74 -0
  24. package/src/market-data/futures-board.ts +7 -6
  25. package/src/market-data/hooks.tsx +12 -3
  26. package/src/market-data/performance.ts +78 -9
  27. package/src/market-data/request-types.ts +6 -3
  28. package/src/plugins/builtin/alerts/cli.ts +2 -1
  29. package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
  30. package/src/plugins/builtin/attention/evidence.ts +1 -1
  31. package/src/plugins/builtin/awards/client.ts +1 -1
  32. package/src/plugins/builtin/awards/evidence.ts +1 -1
  33. package/src/plugins/builtin/awards/pane.tsx +2 -1
  34. package/src/plugins/builtin/bond-calculator/math.ts +1 -1
  35. package/src/plugins/builtin/broker-manager/footer.ts +3 -2
  36. package/src/plugins/builtin/broker-manager/index.tsx +2 -1
  37. package/src/plugins/builtin/broker-manager/keyboard.ts +2 -1
  38. package/src/plugins/builtin/catalysts/evidence.ts +1 -1
  39. package/src/plugins/builtin/catalysts/pane.tsx +2 -1
  40. package/src/plugins/builtin/chart-composer/headless.ts +40 -1
  41. package/src/plugins/builtin/cloud-tweets/table.tsx +3 -2
  42. package/src/plugins/builtin/comment-letters/client.ts +2 -1
  43. package/src/plugins/builtin/company-kpis/client.ts +1 -1
  44. package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
  45. package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
  46. package/src/plugins/builtin/cot/headless.ts +9 -3
  47. package/src/plugins/builtin/cot/model.ts +44 -3
  48. package/src/plugins/builtin/credit-documents/client.ts +1 -1
  49. package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
  50. package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
  51. package/src/plugins/builtin/earnings-calls/pane.tsx +1 -1
  52. package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
  53. package/src/plugins/builtin/econ/calendar-model.ts +2 -0
  54. package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
  55. package/src/plugins/builtin/econ/print-watch.ts +3 -1
  56. package/src/plugins/builtin/futures/series.ts +16 -1
  57. package/src/plugins/builtin/fx-matrix/headless.ts +4 -2
  58. package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
  59. package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
  60. package/src/plugins/builtin/gpu/headless.ts +2 -1
  61. package/src/plugins/builtin/help/function-card.tsx +2 -1
  62. package/src/plugins/builtin/help/index.tsx +2 -1
  63. package/src/plugins/builtin/insider/display.ts +45 -6
  64. package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
  65. package/src/plugins/builtin/iv-history/client.ts +2 -1
  66. package/src/plugins/builtin/iv-history/headless.ts +2 -1
  67. package/src/plugins/builtin/jobs/pages.ts +4 -4
  68. package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
  69. package/src/plugins/builtin/market-heatmap/index.tsx +2 -1
  70. package/src/plugins/builtin/members/client.ts +1 -1
  71. package/src/plugins/builtin/mna/distress/client.ts +1 -0
  72. package/src/plugins/builtin/mna/pane.tsx +4 -1
  73. package/src/plugins/builtin/options/market-reference.ts +1 -1
  74. package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
  75. package/src/plugins/builtin/options/view.tsx +2 -1
  76. package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
  77. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
  78. package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
  79. package/src/plugins/builtin/options-scenario/csp.ts +28 -9
  80. package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
  81. package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
  82. package/src/plugins/builtin/perps/client.ts +1 -1
  83. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
  84. package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
  85. package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
  86. package/src/plugins/builtin/research/analyst-model.ts +1 -0
  87. package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
  88. package/src/plugins/builtin/research/index.tsx +1 -0
  89. package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
  90. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
  91. package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
  92. package/src/plugins/builtin/research-search/snippet.ts +1 -0
  93. package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
  94. package/src/plugins/builtin/seasonality/headless.ts +2 -1
  95. package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
  96. package/src/plugins/builtin/sec/index.tsx +7 -4
  97. package/src/plugins/builtin/sec/row-summaries.ts +28 -12
  98. package/src/plugins/builtin/short-interest/watch-client.ts +2 -1
  99. package/src/plugins/builtin/social-mentions/client.ts +2 -1
  100. package/src/plugins/builtin/supply-chain/client.ts +1 -1
  101. package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
  102. package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
  103. package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
  104. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
  105. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
  106. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
  107. package/src/plugins/builtin/time-sales/client.ts +1 -0
  108. package/src/plugins/builtin/vol-surface/client.ts +2 -1
  109. package/src/plugins/builtin/yield-curve/headless.ts +3 -1
  110. package/src/portfolio/column-values.ts +76 -10
  111. package/src/renderers/dom/host/box.tsx +204 -176
  112. package/src/renderers/dom/host/style.ts +49 -20
  113. package/src/renderers/dom/host/text.tsx +3 -2
  114. package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
  115. package/src/renderers/electrobun/bun/desktop/host-requests.ts +25 -1
  116. package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
  117. package/src/renderers/electrobun/bun/desktop/windows-script.ts +9 -6
  118. package/src/renderers/electrobun/bun/window/windows-native.ts +26 -1
  119. package/src/renderers/electrobun/shared/protocol.ts +6 -0
  120. package/src/renderers/electrobun/view/ui-host.tsx +7 -0
  121. package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
  122. package/src/sources/provider-router/index.ts +7 -1
  123. package/src/time-series/price-units.ts +11 -0
  124. package/src/ui/host.tsx +2 -0
  125. package/src/utils/currency-names.ts +20 -0
  126. package/src/utils/currency-pair.ts +6 -0
  127. package/src/utils/exchange-rate-snapshot.ts +20 -2
  128. package/src/utils/fx-market-hours.ts +43 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gloomberb",
3
- "version": "0.19.4",
3
+ "version": "0.19.5",
4
4
  "packageManager": "bun@1.3.14",
5
5
  "description": "Market research and portfolio tracker for the terminal",
6
6
  "module": "src/public/index.ts",
@@ -99,6 +99,7 @@
99
99
  "kit:page": "bun run scripts/pane-chrome/kit-page.ts",
100
100
  "audit:ui:compare": "bun run scripts/pane-chrome/ui-audit-compare.ts",
101
101
  "benchmark:pane-drag:compare": "bun run scripts/pane-chrome/frame-budget.ts",
102
+ "benchmark:pane-drag:smoothness": "bun run scripts/pane-chrome/drag-smoothness.ts",
102
103
  "test:global-upgrade": "bun run scripts/smoke-global-upgrade.ts",
103
104
  "release": "./scripts/release.sh"
104
105
  },
@@ -125,6 +126,7 @@
125
126
  "playwright-core": "1.60.0",
126
127
  "png-to-ico": "^2.1.8",
127
128
  "rcedit": "^4.0.1",
129
+ "resedit": "^3.1.0",
128
130
  "typescript": "^5.9.2",
129
131
  "wrangler": "^4.0.0"
130
132
  },
@@ -1,4 +1,5 @@
1
1
  import type { CliCommandContext } from "../../types/plugin";
2
+ import { currencyNameStop } from "../currency-name-hint";
2
3
 
3
4
  export function takeOption(args: string[], name: string): string | undefined {
4
5
  const equalsPrefix = `${name}=`;
@@ -71,6 +72,9 @@ export function requireOneArg(
71
72
  ctx: CliCommandContext,
72
73
  ): string {
73
74
  const value = requireArg(args[0], `Usage: gloom ${usage}`, ctx);
75
+ // A currency's name in words (`ticker swiss franc`) is its pair, not two symbols.
76
+ const currency = noun === "symbol" && args.length > 1 ? currencyNameStop(args, usage.split(" ")[0]!) : null;
77
+ if (currency) ctx.fail(currency.message, currency.details);
74
78
  rejectExtraArgs(args, 1, { usage, takes: `one ${noun}`, advice: `Run it once per ${noun}.` }, ctx);
75
79
  return value;
76
80
  }
@@ -134,6 +134,7 @@ import {
134
134
  historyBarStatusNote,
135
135
  venueTradingDay,
136
136
  historyCoverageWarning,
137
+ historyExportUnit,
137
138
  historyFacts,
138
139
  historyFlagNote,
139
140
  historyWickNote,
@@ -155,7 +156,7 @@ import {
155
156
  quotedPriceDivisor,
156
157
  historyVolume,
157
158
  historyVolumeBasis,
158
- historyVolumeText,
159
+ historyVolumeNote,
159
160
  type HistoryRow,
160
161
  type HistoryUnit,
161
162
  type HistoryVolume,
@@ -250,11 +251,13 @@ import {
250
251
  meantQuestion,
251
252
  movedSymbolLine,
252
253
  ListingArgError,
254
+ isNoProviderError,
253
255
  requireCliListing,
254
256
  resolveCliListing,
255
257
  type CliListing,
256
258
  type ListingIdentity,
257
259
  } from "../listing-arg";
260
+ import { currencyNameMiss, currencyNameStop } from "../currency-name-hint";
258
261
  import { bareListingNote, listingFateNotes, noLongerTradingNote, SUCCESSOR_CHANGE_WAIT_MS, tradingListing } from "../../tickers/listing-fate";
259
262
  import { isYieldIndexSymbol } from "../../tickers/index-roots";
260
263
  import {
@@ -454,7 +457,7 @@ async function readListedSymbols(
454
457
  const QUOTE_CSV_SECTION = {
455
458
  title: "CSV",
456
459
  lines: [
457
- "Last, Chg%, Prev Close and each extended print are plain numbers, the currency in Cur and currency_or_unit. A pre-market, after-hours or overnight print's move is in Pre-Market Chg%, After Hours Chg% or Overnight Chg%, and compare's day range in Day Low and Day High, after the columns the export already had.",
460
+ "Last, Chg%, Prev Close and each extended print are plain numbers. Cur is the currency; currency_or_unit is the unit: the currency, a pair's quote currency per base (JPY per USD for USDJPY=X), index points or pct for a yield. A pre-market, after-hours or overnight print's move is in Pre-Market Chg%, After Hours Chg% or Overnight Chg%, and compare's day range in Day Low and Day High, after the columns the export already had.",
458
461
  "A row with no figure says why in its status column, never NaN; a symbol with no quote is also named on standard error.",
459
462
  ],
460
463
  };
@@ -594,6 +597,12 @@ const EXTENDED_CHANGE_EXPORT_COLUMNS = EXTENDED_SESSIONS.map((session) => ({
594
597
  * Why an exported quote row's figures are empty, for its status column: the
595
598
  * symbol's failure as the warning says it, or the figure it has no value for.
596
599
  */
600
+ /** A pair's rate unit for an export (`JPY per USD` for USDJPY=X) when its quote is in the counter currency; null otherwise. */
601
+ function pairExportUnit(symbol: string, currency: string): string | null {
602
+ const unit = historyUnit(symbol, { currency });
603
+ return unit.kind === "pair" && unit.currency === currency ? unit.unit : null;
604
+ }
605
+
597
606
  function quoteExportStatus(row: QuoteRow): string {
598
607
  if (row.rawPrice == null || !Number.isFinite(row.rawPrice)) return row.error || "Last: no price";
599
608
  if (row.changePercent == null || !Number.isFinite(row.changePercent)) return "Chg%: no previous close";
@@ -1008,6 +1017,9 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
1008
1017
  const listed = file != null || args.includes("-");
1009
1018
  const entries = normalizeSymbols(args);
1010
1019
  if (entries.length === 0 && !listed) ctx.fail(usage);
1020
+ // A currency's name in words (`quote japanese yen`) is its pair, not a symbol a word.
1021
+ const currency = exchange || listed ? null : currencyNameStop(args, commandName);
1022
+ if (currency) ctx.fail(currency.message, currency.details);
1011
1023
  // One quoted argument with spaces is a company's name, a pasted line of tickers, or a phrase to search for.
1012
1024
  const phrase = exchange || listed ? null : quotedPhrase(args);
1013
1025
 
@@ -1163,7 +1175,9 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
1163
1175
  // An index row's Cur is blank, its level having no currency; the export names what it is in instead.
1164
1176
  exportIdentity: (row) => ({
1165
1177
  symbolOrSeries: row.symbol,
1166
- currencyOrUnit: row.currency || (row.yieldIndex ? "pct" : isIndexLevel(row.instrumentType) ? INDEX_POINTS_EXPORT_UNIT : null),
1178
+ // A pair's rate is its quote currency per base: JPY per USD, as `history` and `fx` export it.
1179
+ currencyOrUnit: (row.currency && pairExportUnit(row.symbol, row.currency))
1180
+ || row.currency || (row.yieldIndex ? "pct" : isIndexLevel(row.instrumentType) ? INDEX_POINTS_EXPORT_UNIT : null),
1167
1181
  }),
1168
1182
  // A row with no price or move says why in its status column, as the warnings do.
1169
1183
  exportStatus: quoteExportStatus,
@@ -1461,11 +1475,13 @@ async function loadListingHistory(
1461
1475
  const delayedTail = quote?.dataSource === "delayed" && !quote.delisting && (dayToDate || (intraday && sessionTrading));
1462
1476
  // The source that served the bars, a broker or another source when Gloom Cloud could not.
1463
1477
  const source = loaded.sourceName ? { source: loaded.sourceName } : {};
1478
+ // A coin's volume unit, or what an index's volume counts (a day's total, an intraday count).
1479
+ const volumeNote = historyVolumeNote(volume, interval, historyVolumeBasis(data));
1464
1480
  // A window that closed before today is the history asked for: no later bar makes it stale.
1465
1481
  const freshness = withSavedCopy(window && isPastPriceWindow(window) ? rowsFreshness(data, {
1466
1482
  ...source,
1467
1483
  status: "not-a-feed", basis: `${interval ? BAR_INTERVAL_LABELS[interval] : "price"} bars, ${priceWindowText(window)}`, observedKey: "date", oldest: null,
1468
- ...(volume ? { note: historyVolumeText(volume, interval, historyVolumeBasis(data)) } : {}),
1484
+ ...(volumeNote ? { note: volumeNote } : {}),
1469
1485
  }) : rowsFreshness(data, {
1470
1486
  ...source,
1471
1487
  ...barHistoryFreshness(intraday ? null : barResolutionFromDates(data.map((row) => row.date))),
@@ -1477,7 +1493,7 @@ async function loadListingHistory(
1477
1493
  ...(forming ? { periodToDate: forming.periodToDate } : closedDay ? { asOf: closedDay } : {}),
1478
1494
  ...(dayToDate ? { basis: "daily bars", ...(quote && Number.isFinite(quote.lastUpdated) ? { asOf: new Date(quote.lastUpdated).toISOString() } : {}) } : {}),
1479
1495
  ...(delayedTail ? { status: "delayed" as const, delayMinutes: CLOUD_QUOTE_DELAY_MINUTES } : {}),
1480
- ...(volume || dayToDate ? { note: [volume ? historyVolumeText(volume, interval, historyVolumeBasis(data)) : null, dayToDate ? `the newest bar is ${DAY_SO_FAR_TEXT}` : null].filter(Boolean).join("; ") } : {}),
1496
+ ...(volumeNote || dayToDate ? { note: [volumeNote, dayToDate ? `the newest bar is ${DAY_SO_FAR_TEXT}` : null].filter(Boolean).join("; ") } : {}),
1481
1497
  // The rows are drawn from the bars served, which say whether they are the saved copy.
1482
1498
  }), loaded);
1483
1499
  const gaps = historyGapNote(data, traded);
@@ -1602,16 +1618,26 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
1602
1618
  const window = historyWindowOption(args, rangeOption, ctx);
1603
1619
  const ask: HistoryAsk = { range: parseRange(rangeOption, ctx), window };
1604
1620
  const requestedExchange = takeOption(args, "--exchange");
1621
+ // One row a date and a close column a symbol, as a spreadsheet lays several series side by side.
1622
+ const wide = takeFlag(args, "--wide");
1605
1623
  // A list from a file or standard input (`-`), or several symbols typed (AAPL MSFT, AAPL,MSFT), is one long table.
1606
1624
  // One argument with spaces stays one, as before: it may be a company's name.
1607
1625
  const file = args.some((arg) => arg === "--file" || arg.startsWith("--file=")) ? takeOption(args, "--file") ?? "" : undefined;
1608
- if (file != null || args.includes("-") || uniqueEntries(args).length > 1 || args.some((arg) => /[,;]/.test(arg))) {
1609
- return runHistoryList(args, file, requestedExchange, ask, ctx);
1626
+ // `history swiss franc` is the franc's pair, not SWISS (a Copenhagen listing) and FRANC.
1627
+ const currency = file != null || requestedExchange ? null : currencyNameStop(args, "history");
1628
+ if (currency) ctx.fail(currency.message, currency.details);
1629
+ if (wide || file != null || args.includes("-") || uniqueEntries(args).length > 1 || args.some((arg) => /[,;]/.test(arg))) {
1630
+ return runHistoryList(args, file, requestedExchange, ask, ctx, { wide });
1610
1631
  }
1611
1632
  const raw = requireOneArg(args, HISTORY_USAGE, "symbol", ctx);
1612
1633
  await withMarketData(ctx, async (market) => {
1613
1634
  const listing = await requireCliListing(raw, requestedExchange, market, ctx);
1614
- const history = await loadListingHistory(listing, market, ctx, ask, { lookups: true });
1635
+ const history = await loadListingHistory(listing, market, ctx, ask, { lookups: true }).catch((error: unknown) => {
1636
+ // A word no source serves that names a currency (`history yen`) says which pair to ask for.
1637
+ const currency = !requestedExchange && isNoProviderError(error) ? currencyNameMiss(raw, "history") : null;
1638
+ if (currency) ctx.fail(currency.message, currency.details);
1639
+ throw error;
1640
+ });
1615
1641
  const { identity, unit, data, interval, intraday, volume, freshness, notes } = history;
1616
1642
  const price = historyPrice(history.decimals);
1617
1643
  // A bar without volume in a history that reports it prints as missing.
@@ -1655,7 +1681,8 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
1655
1681
  columns: historyExportColumns(data),
1656
1682
  exportStatus: historyExportStatus,
1657
1683
  // Every exported row says what it is a bar of, the currency a price is in and its bar size, so it survives head and concatenation.
1658
- exportIdentity: { symbolOrSeries: history.listing.key, currencyOrUnit: unit.currency ?? unit.unit, interval },
1684
+ // A pair's rate is in its quote currency per base: JPY per USD, as the JSON's unit and every other export say.
1685
+ exportIdentity: { symbolOrSeries: history.listing.key, currencyOrUnit: historyExportUnit(unit), interval },
1659
1686
  });
1660
1687
  });
1661
1688
  }
@@ -1663,6 +1690,44 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
1663
1690
  /** A symbol of a list: its bars, or why it has none. */
1664
1691
  type ListedHistory = { symbol: string; history: ListingHistory } | { symbol: string; error: string };
1665
1692
 
1693
+ /**
1694
+ * `history USDJPY=X USDCHF=X EURCHF=X --wide`: one row a date and one close
1695
+ * column a symbol, its unit in the header (`USDJPY=X close (JPY per USD)`),
1696
+ * as a spreadsheet sets several series side by side. A symbol with no bar on
1697
+ * a date (another market's holiday) leaves its cell blank. `interval` is the
1698
+ * bars' size when every symbol came in one, else null.
1699
+ */
1700
+ function wideHistoryTable(served: readonly ListingHistory[]): {
1701
+ rows: Array<Record<string, string | number | null>>;
1702
+ columns: CliResultColumn[];
1703
+ interval: string | null;
1704
+ } {
1705
+ const histories = served.filter((history, index) => served.findIndex((other) => other.listing.key === history.listing.key) === index);
1706
+ const key = (history: ListingHistory) => `close:${history.listing.key}`;
1707
+ const dates = [...new Set(histories.flatMap((history) => history.data.map((row) => row.date)))].sort();
1708
+ const closes = histories.map((history) => new Map(history.data.map((row) => [row.date, row.close] as const)));
1709
+ const rows = dates.map((date) => Object.fromEntries([
1710
+ ["date", date],
1711
+ ...histories.map((history, index) => [key(history), closes[index]!.get(date) ?? null] as const),
1712
+ ]));
1713
+ const intervals = new Set(histories.map((history) => history.interval));
1714
+ return {
1715
+ rows,
1716
+ columns: [
1717
+ { key: "date", header: histories.some((history) => history.intraday) ? "Time" : "Date" },
1718
+ ...histories.map((history): CliResultColumn => {
1719
+ const unit = historyExportUnit(history.unit);
1720
+ const price = historyPrice(history.decimals);
1721
+ return {
1722
+ key: key(history), header: `${history.listing.key} close${unit ? ` (${unit})` : ""}`, align: "right",
1723
+ format: (value) => value == null ? "" : price(value),
1724
+ };
1725
+ }),
1726
+ ],
1727
+ interval: intervals.size === 1 ? [...intervals][0] ?? null : null,
1728
+ };
1729
+ }
1730
+
1666
1731
  /**
1667
1732
  * `history --file holdings.txt` (or several symbols, or `-` for standard
1668
1733
  * input): every symbol's bars in one long table, `HISTORY_LIST_CONCURRENCY`
@@ -1675,6 +1740,7 @@ async function runHistoryList(
1675
1740
  exchange: string | undefined,
1676
1741
  ask: HistoryAsk,
1677
1742
  ctx: Parameters<CliCommandDef["execute"]>[1],
1743
+ { wide = false }: { wide?: boolean } = {},
1678
1744
  ) {
1679
1745
  const usage = `Usage: gloom ${HISTORY_USAGE}`;
1680
1746
  await withMarketData(ctx, async (market) => {
@@ -1723,6 +1789,39 @@ async function runHistoryList(
1723
1789
  // reads it there): the list ends "couldn't refresh; saved copy from <time>" for the oldest copy among its symbols.
1724
1790
  const savedAt = served.flatMap((history) => history.freshness?.savedAt ?? []).sort()[0];
1725
1791
  const freshness = listFreshness && savedAt && !listFreshness.savedAt ? { ...listFreshness, savedAt } : listFreshness;
1792
+ const symbolsMetadata = listed.map((entry) => "history" in entry ? {
1793
+ ...listingMetadata(entry.history.identity),
1794
+ currency: entry.history.unit.currency,
1795
+ unit: entry.history.unit.unit,
1796
+ interval: entry.history.interval,
1797
+ firstDate: entry.history.data[0]?.date ?? null,
1798
+ lastDate: entry.history.data.at(-1)?.date ?? null,
1799
+ bars: entry.history.data.length,
1800
+ asOf: entry.history.freshness?.asOf ?? null,
1801
+ } : { symbol: entry.symbol, error: entry.error });
1802
+ if (wide) {
1803
+ const table = wideHistoryTable(served);
1804
+ ctx.printResult({
1805
+ data: table.rows,
1806
+ metadata: {
1807
+ range: ask.window ? null : ask.range,
1808
+ requestedRange: ask.window ? null : ask.range,
1809
+ ...(ask.window ? { requestedWindow: ask.window } : {}),
1810
+ symbols: symbolsMetadata,
1811
+ },
1812
+ ...(notes.length > 0 ? { warnings: notes } : {}),
1813
+ ...(served.length === 0 ? { failure: { code: "cli_error", message: `No history for ${symbols.join(", ")}.` } } : {}),
1814
+ freshness,
1815
+ ...(freshness ? {} : { exportFreshness: rowsFreshness([], { status: "not-a-feed", basis: "price bars" }) }),
1816
+ }, {
1817
+ dateKey: "date",
1818
+ columns: table.columns,
1819
+ // The unit is in each close column's header; a row of several symbols has no one symbol or unit to name.
1820
+ exportIdentity: { symbolOrSeries: null, currencyOrUnit: null, interval: table.interval },
1821
+ });
1822
+ if (served.length === 0) process.exitCode = CLI_EXIT_CODES.error;
1823
+ return;
1824
+ }
1726
1825
  const decimals = (row: Record<string, unknown>) => bySymbol.get(String(row.symbol))?.decimals ?? 2;
1727
1826
  const intraday = served.some((history) => history.intraday);
1728
1827
  const textColumns = historyTextColumns(intraday, (value, row) => historyPrice(decimals(row))(value)).map((column) => column.key !== "volume" ? column
@@ -1737,16 +1836,7 @@ async function runHistoryList(
1737
1836
  requestedRange: ask.window ? null : ask.range,
1738
1837
  ...(ask.window ? { requestedWindow: ask.window } : {}),
1739
1838
  // Each symbol as a single `history` describes it, or the reason it has no bars.
1740
- symbols: listed.map((entry) => "history" in entry ? {
1741
- ...listingMetadata(entry.history.identity),
1742
- currency: entry.history.unit.currency,
1743
- unit: entry.history.unit.unit,
1744
- interval: entry.history.interval,
1745
- firstDate: entry.history.data[0]?.date ?? null,
1746
- lastDate: entry.history.data.at(-1)?.date ?? null,
1747
- bars: entry.history.data.length,
1748
- asOf: entry.history.freshness?.asOf ?? null,
1749
- } : { symbol: entry.symbol, error: entry.error }),
1839
+ symbols: symbolsMetadata,
1750
1840
  },
1751
1841
  ...(notes.length > 0 ? { warnings: notes } : {}),
1752
1842
  ...(served.length === 0 ? { failure: { code: "cli_error", message: `No history for ${symbols.join(", ")}.` } } : {}),
@@ -1765,7 +1855,7 @@ async function runHistoryList(
1765
1855
  const history = bySymbol.get(String(row.symbol));
1766
1856
  return {
1767
1857
  symbolOrSeries: String(row.symbol),
1768
- currencyOrUnit: history ? history.unit.currency ?? history.unit.unit : null,
1858
+ currencyOrUnit: history ? historyExportUnit(history.unit) : null,
1769
1859
  interval: history?.interval ?? null,
1770
1860
  // A symbol with no bars has no as-of of its own.
1771
1861
  asOf: history ? history.freshness?.asOf ?? undefined : null,
@@ -3052,7 +3142,7 @@ async function runFxOnDate(
3052
3142
  warnings: warnings.length > 0 ? warnings : undefined,
3053
3143
  }, {
3054
3144
  text: () => amount == null ? describeFxRate(request, rate) : `${describeFxConversion(request, amount, rate)}\n${describeFxRate(request, rate)}`,
3055
- exportIdentity: { symbolOrSeries: pair, currencyOrUnit: baseCurrency, interval: "1day" },
3145
+ exportIdentity: { symbolOrSeries: pair, currencyOrUnit: `${baseCurrency} per ${currency}`, interval: "1day" },
3056
3146
  columns: [
3057
3147
  { key: "currency", header: "Currency" },
3058
3148
  { key: "baseCurrency", header: "Base" },
@@ -3180,7 +3270,7 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
3180
3270
  `${baseCurrency} rate: ${describeShortRate(quote.rate)}`,
3181
3271
  `Covered interest parity: ${formatFxRate(rate)} × ${growth(quote.rate)} / ${growth(base.rate)}; each rate earns simple interest over the ${tenor.days} days, standing in for a ${tenor.label} term rate.`,
3182
3272
  ].join("\n"),
3183
- exportIdentity: { symbolOrSeries: pair, currencyOrUnit: baseCurrency, interval: `forward ${tenor.label}` },
3273
+ exportIdentity: { symbolOrSeries: pair, currencyOrUnit: `${baseCurrency} per ${currency}`, interval: `forward ${tenor.label}` },
3184
3274
  columns: [
3185
3275
  { key: "pair", header: "Pair" },
3186
3276
  { key: "tenor", header: "Tenor" },
@@ -3216,8 +3306,8 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
3216
3306
  rateText,
3217
3307
  ...peso ? pesoDollarRateLines(peso) : [],
3218
3308
  ].join("\n"),
3219
- // The rate is the base currency's price of one unit of the other, at the latest quote of each leg.
3220
- exportIdentity: { symbolOrSeries: pair, currencyOrUnit: baseCurrency, interval: "spot" },
3309
+ // The rate is the base currency's price of one unit of the other, at the latest quote of each leg: USD per ZAR.
3310
+ exportIdentity: { symbolOrSeries: pair, currencyOrUnit: `${baseCurrency} per ${currency}`, interval: "spot" },
3221
3311
  columns: [
3222
3312
  { key: "currency", header: "Currency" },
3223
3313
  { key: "baseCurrency", header: "Base" },
@@ -3347,6 +3437,7 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
3347
3437
  { flags: "--from <year|date>, --start <year|date>", description: `${PRICE_WINDOW_FROM_HELP}. Up to five years come in daily bars, up to twenty weekly, longer monthly` },
3348
3438
  { flags: "--to <year|date>, --end <year|date>", description: PRICE_WINDOW_TO_HELP },
3349
3439
  { flags: "--file <path>", description: "Read the symbols from a text or CSV file, one per line (- reads standard input), and write every symbol's bars in one table" },
3440
+ { flags: "--wide", description: "One row per date and one close column per symbol, its unit in the header, in place of one long table" },
3350
3441
  EXCHANGE_OPTION,
3351
3442
  ],
3352
3443
  sections: [{
@@ -3360,14 +3451,15 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
3360
3451
  }, {
3361
3452
  title: "CSV",
3362
3453
  lines: [
3363
- "Every --csv has one header, whatever the symbol, range or market state: Date, Open, High, Low, Close, Volume, Flag, Partial, Filled, Unsettled, Volume unit, Volume note, Venue volume, Volume venue, Volume basis, status, then symbol_or_series, currency_or_unit, interval, source and as_of. Prices are plain numbers in the currency currency_or_unit names. Partial, Filled and Unsettled are true or false, and status says why a row has no prices.",
3454
+ "Every --csv has one header, whatever the symbol, range or market state: Date, Open, High, Low, Close, Volume, Flag, Partial, Filled, Unsettled, Volume unit, Volume note, Venue volume, Volume venue, Volume basis, status, then symbol_or_series, currency_or_unit, interval, source and as_of. Prices are plain numbers in the unit currency_or_unit names: the currency, a pair's quote currency per base (JPY per USD for USDJPY=X) or index points. Partial, Filled and Unsettled are true or false, and status says why a row has no prices.",
3364
3455
  "A continuous future whose bars name their contracts (NG=F) adds Contract, Roll and Thin before status: the contract per bar, and true or false for the bar it rolled at and a bar that traded far below those around it.",
3365
3456
  ],
3366
3457
  }, {
3367
3458
  title: "Several symbols",
3368
3459
  lines: [
3369
- `history AAPL MSFT 000660.KS, or --file with one symbol a line (- reads standard input), writes every symbol's bars in one long table, ${HISTORY_LIST_CONCURRENCY} symbols loading at once. Each row names its symbol, its currency and the as-of of that symbol's bars in symbol_or_series, currency_or_unit and as_of.`,
3460
+ `history AAPL MSFT 000660.KS, or --file with one symbol a line (- reads standard input), writes every symbol's bars in one long table, ${HISTORY_LIST_CONCURRENCY} symbols loading at once. Each row names its symbol, its unit and the as-of of that symbol's bars in symbol_or_series, currency_or_unit and as_of.`,
3370
3461
  "A symbol with no history is one row with its reason in status, and a warning names it; the command fails only when no symbol has any. --tail 5 keeps each symbol's newest five bars.",
3462
+ "--wide sets the symbols side by side instead: one row per date, one close column per symbol headed with its unit (USDJPY=X close (JPY per USD)), a blank where a symbol has no bar that day. history USDJPY=X USDCHF=X EURCHF=X --csv --wide is a spreadsheet of the three closes; --tail 5 keeps the newest five dates.",
3371
3463
  ],
3372
3464
  }, {
3373
3465
  title: "Long history",
@@ -3645,7 +3737,7 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
3645
3737
  }, {
3646
3738
  title: "Amounts",
3647
3739
  lines: [
3648
- "An amount in front converts it from the first currency to the second: fx 1234.5 EUR/USD, or fx 1234,5 EUR USD. It takes either decimal mark (1.234,5 and 1,234.5 are 1234.5) and reads as an amount of the first currency: 1,234 or 1.234 EUR are thousands, a third decimal being below a cent, while in a currency with three decimals (KWD) fx asks which. An amount and one currency converts to USD. The answer gives the converted amount, then the rate it used, dated by the source line; --json adds amount and converted.",
3740
+ "An amount in front converts it from the first currency to the second: fx 1234.5 EUR/USD, or fx 1234,5 EUR USD. It takes either decimal mark (1.234,5 and 1,234.5 are 1234.5) and reads as an amount of the first currency: 1.234 EUR is thousands, a third decimal being below a cent, while in a currency with three decimals (KWD) fx asks which. A comma before exactly three digits (fx 1,234 EUR) could be either, so fx asks which: type 1234 or 1.2340. An amount and one currency converts to USD. The answer gives the converted amount, then the rate it used, dated by the source line; --json adds amount and converted.",
3649
3741
  ],
3650
3742
  }, {
3651
3743
  title: "A past day",
@@ -541,7 +541,7 @@ export function buildSearchReport({
541
541
  if (bank) lines.push("", wrapToTerminal(centralBankLine(bank)));
542
542
  const setting = commandPointer(query);
543
543
  if (setting) lines.push("", wrapToTerminal(setting));
544
- const charted = renderSeriesMatches(query, series, SEARCH_SERIES_LIMIT, cliTerminalWidth() ?? 100, "catalog");
544
+ const charted = renderSeriesMatches(query, series, SEARCH_SERIES_LIMIT, cliTerminalWidth() ?? 100);
545
545
  // A query that names the data ("carbon", "day-ahead") lists its series first; words that happen to
546
546
  // be in a series name ("apple") list them after the tickers.
547
547
  const seriesFirst = series.some((match) => match.exact);
@@ -73,7 +73,7 @@ import {
73
73
  } from "../helpers";
74
74
  import { NotesFiles } from "../../plugins/builtin/notes/files";
75
75
  import { getFormDescription } from "../../plugins/builtin/sec/model";
76
- import { rowSummary, rowSummaryTarget } from "../../plugins/builtin/sec/row-summaries";
76
+ import { ownerNames, rowSummary, rowSummaryTarget } from "../../plugins/builtin/sec/row-summaries";
77
77
  import { isKnownNonUsListing, secFilingItemCodes, US_FUND_FACTS_ONLY } from "../../utils/sec";
78
78
  import { currentReportItemsLabel, hiddenFilingsNote, loadLatestFilings, type HiddenFilings } from "../../utils/sec-filings";
79
79
  import { canonicalExchange, exchangeLabel, isKnownExchangeCode, isUsListingExchange } from "../../utils/exchanges";
@@ -321,14 +321,18 @@ async function withFilingSummaries(
321
321
  dataProvider: { getSecFilingContent?(filing: SecFilingItem): Promise<string | null> },
322
322
  ): Promise<RecentFiling[]> {
323
323
  if (!dataProvider.getSecFilingContent) return [...filings];
324
- return Promise.all(filings.map(async (filing) => {
324
+ const contents = await Promise.all(filings.map(async (filing) => {
325
325
  const target = rowSummaryTarget(filing);
326
- if (!target) return filing;
327
- const content = await Promise.resolve().then(() => dataProvider.getSecFilingContent!(target))
326
+ if (!target) return null;
327
+ return Promise.resolve().then(() => dataProvider.getSecFilingContent!(target))
328
328
  .catch(logFailure("cli.commands-ticker", "Read an insider filing failed", null));
329
- const summary = rowSummary(filing.form, content)?.title;
330
- return summary ? { ...filing, summary } : filing;
331
329
  }));
330
+ // A Form 144 names its seller freely; the insider forms read beside it say which way round.
331
+ const knownOwners = filings.flatMap((filing, index) => ownerNames(filing.form, contents[index]));
332
+ return filings.map((filing, index) => {
333
+ const summary = rowSummary(filing.form, contents[index], knownOwners)?.title;
334
+ return summary ? { ...filing, summary } : filing;
335
+ });
332
336
  }
333
337
 
334
338
  /** What the form is: the filing's own description, else the form's meaning ("Insider Transaction"); none beside an 8-K's items. */
@@ -0,0 +1,60 @@
1
+ import { currenciesNamed } from "../utils/currency-names";
2
+ import { dollarPairListing } from "../utils/currency-pair";
3
+
4
+ /** A currency a name typed in words stands for, and its pair against the dollar as a listing. */
5
+ export interface NamedCurrencyPair {
6
+ /** The words as typed: `swiss franc`. */
7
+ typed: string;
8
+ code: string;
9
+ /** USDCHF=X for the franc, EURUSD=X for the euro. */
10
+ pair: string;
11
+ }
12
+
13
+ /**
14
+ * The one currency words name (`swiss franc` is CHF, `yen` JPY) with its
15
+ * pair against the dollar. Null for words that name none, several (`peso`)
16
+ * or the dollar itself, which has no pair of its own.
17
+ */
18
+ export function namedCurrencyPair(typed: string): NamedCurrencyPair | null {
19
+ const words = typed.trim().replace(/\s+/g, " ");
20
+ if (!words || /[^\p{L}\s.'-]/u.test(words)) return null;
21
+ const named = currenciesNamed(words);
22
+ const code = named.length === 1 ? named[0]!.code : null;
23
+ return code && code !== "USD" ? { typed: words, code, pair: dollarPairListing(code) } : null;
24
+ }
25
+
26
+ /** "swiss franc is a currency (CHF), not a ticker.", then what to run: `gloom fx CHF` for its rate, `gloom history USDCHF=X` for its pair. */
27
+ function currencyStop(named: NamedCurrencyPair, command: string): { message: string; details: string } {
28
+ return {
29
+ message: `${named.typed} is a currency (${named.code}), not a ticker.`,
30
+ details: `Its rate: gloom fx ${named.code}\nIts pair: gloom ${command} ${named.pair}`,
31
+ };
32
+ }
33
+
34
+ /**
35
+ * The stop for a symbol command given a currency's name in several words
36
+ * (`history swiss franc`, `quote japanese yen`), which would otherwise read
37
+ * each word as a symbol (SWISS, a Copenhagen listing). One word is a ticker
38
+ * first (`history real` is The RealReal); `currencyNameMiss` names its
39
+ * currency once it fails as one. Null for anything else.
40
+ */
41
+ export function currencyNameStop(words: readonly string[], command: string): { message: string; details: string } | null {
42
+ const typed = words.map((word) => word.trim()).filter(Boolean);
43
+ if (typed.length === 0 || typed.some((word) => word.startsWith("-"))) return null;
44
+ const phrase = typed.join(" ");
45
+ if (!/\s/.test(phrase)) return null;
46
+ const named = namedCurrencyPair(phrase);
47
+ return named ? currencyStop(named, command) : null;
48
+ }
49
+
50
+ /** The stop for one word that failed as a symbol and names a currency (`history yen`), else null. */
51
+ export function currencyNameMiss(word: string, command: string): { message: string; details: string } | null {
52
+ const named = namedCurrencyPair(word);
53
+ return named ? currencyStop(named, command) : null;
54
+ }
55
+
56
+ /** The hint after "Not a ticker: YEN." for a word that names a currency: "Try `gloom fx JPY` for the yen's rate, or its pair USDJPY=X." */
57
+ export function currencyNameHint(typed: string): string | null {
58
+ const named = namedCurrencyPair(typed);
59
+ return named ? `Try \`gloom fx ${named.code}\` for the ${named.typed}'s rate, or its pair ${named.pair}.` : null;
60
+ }
@@ -511,12 +511,24 @@ export function historyVolume(
511
511
  * with a volume says the same (`historyVolumeBasis`): `volume in USD per UTC day, aggregate across venues`, `volume in
512
512
  * USD summed over 3 spot venues`.
513
513
  */
514
- export function historyVolumeText(volume: HistoryVolume, interval: ManualChartResolution | null, basis: string | null = null): string {
514
+ function historyVolumeText(volume: HistoryVolume, interval: ManualChartResolution | null, basis: string | null = null): string {
515
515
  const text = interval === "1d" ? `volume in ${volume.unit} per UTC day` : `volume in ${volume.unit}`;
516
516
  if (!basis) return text;
517
517
  return basis === "aggregate" ? `${text}, aggregate across venues` : `${text} summed over ${basis}`;
518
518
  }
519
519
 
520
+ /**
521
+ * What the status line says of a history's volume: a coin's unit and basis
522
+ * (historyVolumeText), or, for bars whose volume has no unit to state, what
523
+ * it counts when the history says (`volume basis: daily total` on an index's
524
+ * daily bars, `volume basis: intraday count` on its hourly ones, which sum
525
+ * below the day's). Null when neither is known.
526
+ */
527
+ export function historyVolumeNote(volume: HistoryVolume | null, interval: ManualChartResolution | null, basis: string | null): string | null {
528
+ if (volume) return historyVolumeText(volume, interval, basis);
529
+ return basis ? `volume basis: ${basis}` : null;
530
+ }
531
+
520
532
  /** What the volume of every bar that has one counts, when they all say the same; null otherwise. */
521
533
  export function historyVolumeBasis(rows: readonly Pick<HistoryRow, "volume" | "volumeBasis">[]): string | null {
522
534
  const bases = new Set(rows.filter((row) => row.volume != null).map((row) => row.volumeBasis ?? null));
@@ -738,6 +750,11 @@ export function historyUnit(listing: string, quote: { currency?: string; instrum
738
750
  : { kind: "unknown", currency: null, unit: null };
739
751
  }
740
752
 
753
+ /** The unit an export names for a history's prices: a pair's quote currency per base (`JPY per USD`), else its currency or unit. */
754
+ export function historyExportUnit(unit: HistoryUnit): string | null {
755
+ return unit.kind === "pair" ? unit.unit : unit.currency ?? unit.unit;
756
+ }
757
+
741
758
  function historyDate(value: string): string {
742
759
  return value.length > 10 ? formatUtcTime(value) : value;
743
760
  }
@@ -5,6 +5,9 @@ import { parsePublicTickerKey } from "../utils/exchanges";
5
5
  import { listingAbroadVenue } from "../utils/sec";
6
6
  import { nimCommand } from "./bank-section";
7
7
  import { treasuryYieldLine, treasuryYieldTenor } from "./treasury-yields";
8
+ import { namedCurrencyPair } from "./currency-name-hint";
9
+ import { dollarPairListing } from "../utils/currency-pair";
10
+ import { currencyCodeTyped } from "../utils/currency-names";
8
11
 
9
12
  /**
10
13
  * What a listing is to a sub-minute ask: a US listing, which has a tape; one
@@ -347,9 +350,21 @@ const COMMAND_POINTERS: ReadonlyArray<{
347
350
  },
348
351
  ];
349
352
 
350
- /** The command for a query that names a setting ("light theme") or a portfolio report ("drip"), else null. */
353
+ /** The command for a query that names a setting ("light theme"), a portfolio report ("drip") or a currency ("yen"), else null. */
351
354
  export function commandPointer(query: string): string | null {
352
- return findCommandPointer(query)?.line ?? null;
355
+ return findCommandPointer(query)?.line ?? currencyPointer(query);
356
+ }
357
+
358
+ /**
359
+ * `fx` for a query that is one currency, by its code (`jpy`, `CHF`) or its
360
+ * name (`yen`, `swiss franc`): its rate and its pair. A code that is also an
361
+ * English word counts only in capitals (`TRY`, not "try"). Null for the
362
+ * dollar, which has no pair of its own, and for anything else.
363
+ */
364
+ function currencyPointer(query: string): string | null {
365
+ const code = currencyCodeTyped(query) ?? namedCurrencyPair(query)?.code;
366
+ if (!code || code === "USD") return null;
367
+ return `The ${code} rate: gloom fx ${code}; its pair's history: gloom history ${dollarPairListing(code)}`;
353
368
  }
354
369
 
355
370
  /**
@@ -1,11 +1,12 @@
1
1
  import { notATickerSymbol } from "../sources/provider-errors";
2
2
  import { boardCoinFor } from "./board-coins";
3
+ import { currencyNameHint } from "./currency-name-hint";
3
4
  import { splitSymbolArgs, splitSymbolWords } from "./symbol-args";
4
5
  import { treasuryYieldHint, treasuryYieldTenor } from "./treasury-yields";
5
6
 
6
7
  // "Not a ticker: APPLE." as the router words it; the symbol ends at the sentence's own period.
7
- // One that already names what to try (a search, a FRED series, a yield, the pair search offered) is left alone.
8
- const NOT_A_TICKER_SENTENCE = /Not a ticker: ((?:(?!\.\s)[^\n`\x1b])+?)\.(?=\s|\x1b|$)(?! Try `gloom (?:search|fred|quote) | Did you mean )/g;
8
+ // One that already names what to try (a search, a FRED series, a yield, a currency's rate, the pair search offered) is left alone.
9
+ const NOT_A_TICKER_SENTENCE = /Not a ticker: ((?:(?!\.\s)[^\n`\x1b])+?)\.(?=\s|\x1b|$)(?! Try `gloom (?:search|fred|quote|fx) | Did you mean )/g;
9
10
 
10
11
  /**
11
12
  * The symbol as the user typed it on the command line (`Apple`), not as the router saw it (`APPLE`).
@@ -53,7 +54,8 @@ export function withSearchHints(text: string, args: readonly string[], isFredSer
53
54
  const coin = boardCoinFor(id);
54
55
  if (coin) return `${sentence} Did you mean ${coin.symbol}${coin.name && coin.name.toUpperCase() !== coin.symbol ? ` (${coin.name})` : ""}?`;
55
56
  const tenor = treasuryYieldTenor(typed);
56
- return `${sentence} ${tenor ? treasuryYieldHint(tenor) : searchHint(typed)}`;
57
+ // A currency's name (`yen`) is its rate and its pair, not a ticker search could find.
58
+ return `${sentence} ${tenor ? treasuryYieldHint(tenor) : currencyNameHint(typed) ?? searchHint(typed)}`;
57
59
  })
58
60
  : named;
59
61
  }
@@ -647,6 +647,9 @@ export function limitationSentence(text: string): string {
647
647
  return !trimmed || /[.!?]["')\]]*$/.test(trimmed) ? trimmed : `${trimmed}.`;
648
648
  }
649
649
 
650
+ /** A data requirement that is an account: a sign-in (free or verified) or Gloom Pro, as `catalog` names under Requires. */
651
+ const ACCOUNT_REQUIREMENT = /\bsign-in\b|\baccount\b|\bPro\b/;
652
+
650
653
  /**
651
654
  * Names as lines of at most `width`, each name whole and the names apart by
652
655
  * semicolons, since a name may hold a comma (Furnishings, Fixtures & Appliances).
@@ -688,7 +691,12 @@ function renderCatalogEntry(entry: PaneCatalogEntry): string {
688
691
  const mnemonics = new Set([entry.token, ...entry.aliases].map((value) => value.toLowerCase()));
689
692
  const keywords = capability.aliases.filter((keyword) => !mnemonics.has(keyword.toLowerCase()));
690
693
  if (keywords.length > 0) stats.push(["Keywords", keywords.join(", ")]);
691
- if (capability.dataRequirements.length > 0) stats.push(["Requires", capability.dataRequirements.join(", ")]);
694
+ // "Requires" is what a reader must have, a sign-in or Pro; the rest says where the data comes from, which a
695
+ // signed-out run reads too (COT's CFTC history, CBR's rates).
696
+ const required = capability.dataRequirements.filter((requirement) => ACCOUNT_REQUIREMENT.test(requirement));
697
+ const sources = capability.dataRequirements.filter((requirement) => !ACCOUNT_REQUIREMENT.test(requirement));
698
+ if (required.length > 0) stats.push(["Requires", required.join(", ")]);
699
+ if (sources.length > 0) stats.push(["Data", sources.join(", ")]);
692
700
  if (capability.limitations.length > 0) stats.push(["Limitations", capability.limitations.map(limitationSentence).join(" ")]);
693
701
  lines.push(renderStats(stats));
694
702
 
@@ -1,3 +1,4 @@
1
+ import { currencyRateUnitText } from "../../time-series/price-units";
1
2
  import { getSharedRegistry } from "../../plugins/registry";
2
3
  import { seriesExpression, seriesNamedBy } from "../../series/registry";
3
4
  import { findCachedPortfolioAccount } from "../../plugins/builtin/portfolio-list/cached-account";
@@ -378,7 +379,9 @@ export function serializeHeadlessPaneResult(
378
379
  case "series": {
379
380
  const series = result as HeadlessSeriesResult;
380
381
  // `textDecimals` and `textCompact` only shape the text report; JSON keeps every digit and does not carry them.
381
- return { ...common, series: series.series.map(({ textDecimals: _decimals, textCompact: _compact, ...kept }) => kept), ...(series.stats ? { stats: series.stats } : {}) };
382
+ return { ...common, series: series.series.map(({ textDecimals: _decimals, textCompact: _compact, ...kept }) => (
383
+ kept.unit ? { ...kept, unit: currencyRateUnitText(kept.unit) } : kept
384
+ )), ...(series.stats ? { stats: series.stats } : {}) };
382
385
  }
383
386
  case "snapshot": {
384
387
  const snapshot = result as HeadlessSnapshotResult;
@@ -600,7 +603,7 @@ function renderSeries(result: HeadlessSeriesResult): string[] {
600
603
  name: series.name?.trim() || null,
601
604
  latest: latest ? seriesLatestDate(series, latest.date) : "-",
602
605
  value: seriesValue(series, latest?.value ?? latest?.close ?? null),
603
- unit: series.unit?.trim() || null,
606
+ unit: series.unit?.trim() ? currencyRateUnitText(series.unit.trim()) : null,
604
607
  points: observationCount(series),
605
608
  };
606
609
  });
@@ -646,7 +649,8 @@ function seriesTable(series: HeadlessSeries): CliReportTable {
646
649
  title: series.label,
647
650
  identity: {
648
651
  ...(series.symbol?.trim() ? { symbolOrSeries: series.symbol.trim() } : {}),
649
- ...(series.unit?.trim() ? { currencyOrUnit: series.unit.trim() } : {}),
652
+ // A rate reads `JPY per USD` here as in every other export.
653
+ ...(series.unit?.trim() ? { currencyOrUnit: currencyRateUnitText(series.unit.trim()) } : {}),
650
654
  ...(series.interval?.trim() ? { interval: series.interval.trim() } : {}),
651
655
  },
652
656
  columns: [dates.every((date) => date.length <= 10) ? "Date" : "Time", ...fields.map(header)],