gloomberb 0.20.13 → 0.20.16

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 (275) hide show
  1. package/package.json +2 -1
  2. package/patches/@opentui%2Fcore@0.3.2.patch +22 -4
  3. package/src/account/auth-dialog.tsx +22 -4
  4. package/src/account/auth-form.tsx +6 -1
  5. package/src/account/checkout-handoff.tsx +7 -14
  6. package/src/account/device-signin-dialog.tsx +35 -24
  7. package/src/api-client/crypto-markets.ts +10 -0
  8. package/src/api-client/errors.ts +3 -1
  9. package/src/api-client/index.ts +54 -0
  10. package/src/api-client/install-experiments.ts +8 -7
  11. package/src/api-client/money-markets.ts +7 -0
  12. package/src/api-client/paths.ts +2 -1
  13. package/src/api-client/product-waitlist.ts +63 -0
  14. package/src/api-client/request.ts +16 -4
  15. package/src/api-client/types/billing.ts +45 -0
  16. package/src/api-client/yearly-plan.ts +132 -0
  17. package/src/app/global-shortcuts.ts +5 -3
  18. package/src/app/pane-runtime/index.tsx +2 -2
  19. package/src/app/pane-runtime/plugin-bindings.ts +3 -1
  20. package/src/app/pane-runtime/ticker-open-runtime.ts +6 -1
  21. package/src/app/since-last-visit/keys.ts +26 -0
  22. package/src/app/since-last-visit/model.ts +266 -0
  23. package/src/app/since-last-visit/strip.tsx +193 -0
  24. package/src/app/since-last-visit/use-since-last-visit.ts +289 -0
  25. package/src/app/since-last-visit/visit-tracker.ts +191 -0
  26. package/src/app.tsx +15 -0
  27. package/src/architecture/floating-promise-allowlist.json +0 -1
  28. package/src/brokers/signed-in/sign-in-dialog.tsx +38 -38
  29. package/src/cli/commands/market.ts +103 -27
  30. package/src/cli/commands/overview.ts +18 -4
  31. package/src/cli/commands/system.ts +29 -1
  32. package/src/cli/commands/ticker.ts +12 -5
  33. package/src/cli/desktop-pane-shot-api-policy.ts +4 -1
  34. package/src/cli/desktop-pane-shot-browser.ts +2 -1
  35. package/src/cli/desktop-pane-shot-view.ts +3 -7
  36. package/src/cli/desktop-pane-shot.ts +26 -28
  37. package/src/cli/errors.ts +3 -1
  38. package/src/cli/freshness.ts +7 -2
  39. package/src/cli/glossary.ts +10 -5
  40. package/src/cli/help.ts +1 -0
  41. package/src/cli/helpers.ts +8 -16
  42. package/src/cli/history-export.ts +4 -0
  43. package/src/cli/history-rows.ts +24 -0
  44. package/src/cli/index.ts +4 -0
  45. package/src/cli/known-gaps.ts +2 -2
  46. package/src/cli/listing-arg.ts +79 -11
  47. package/src/cli/not-a-ticker.ts +4 -0
  48. package/src/cli/options.ts +29 -1
  49. package/src/cli/pane-functions/catalog.ts +70 -12
  50. package/src/cli/pane-functions/function-help.ts +1 -1
  51. package/src/cli/pane-functions/headless.ts +68 -3
  52. package/src/cli/pane-functions/index.ts +2 -2
  53. package/src/cli/pane-functions/options.ts +7 -0
  54. package/src/cli/pane-functions/resolver.ts +104 -15
  55. package/src/cli/pane-functions/screenshot-payload.ts +3 -0
  56. package/src/cli/report-tables.ts +20 -5
  57. package/src/cli/result.ts +22 -4
  58. package/src/cli/shot-temp-dir.ts +30 -0
  59. package/src/cli/suffixed-listing-rows.ts +11 -0
  60. package/src/cli/symbol-args.ts +5 -3
  61. package/src/cli/symbol-list.ts +23 -10
  62. package/src/cli/symbol-rows.ts +135 -3
  63. package/src/cli/treasury-yields.ts +15 -1
  64. package/src/components/chart/composite/composite-chart.tsx +3 -3
  65. package/src/components/chart/composite/format.ts +2 -1
  66. package/src/components/chart/composite/panel-surface/axis-markers.ts +133 -0
  67. package/src/components/chart/composite/panel-surface/level-labels.tsx +78 -0
  68. package/src/components/chart/composite/panel-surface/overlays.ts +108 -0
  69. package/src/components/chart/composite/panel-surface/pan-coast.ts +54 -0
  70. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +138 -0
  71. package/src/components/chart/composite/panel-surface/panel-levels.ts +47 -0
  72. package/src/components/chart/composite/panel-surface/plot-gestures.ts +403 -0
  73. package/src/components/chart/composite/panel-surface/plot-pointer.ts +65 -0
  74. package/src/components/chart/composite/panel-surface/plot-wheel.ts +102 -0
  75. package/src/components/chart/composite/panel-surface/pointer.ts +12 -0
  76. package/src/components/chart/composite/panel-surface/props.ts +79 -0
  77. package/src/components/chart/composite/panel-surface/tool-readout.ts +151 -0
  78. package/src/components/chart/composite/panel-surface/value-axis-gestures.ts +152 -0
  79. package/src/components/chart/composite/panel-surface.tsx +81 -1177
  80. package/src/components/command-bar/commands/collection-list.ts +1 -0
  81. package/src/components/command-bar/commands/direct/index.ts +31 -8
  82. package/src/components/command-bar/commands/registry.ts +7 -0
  83. package/src/components/command-bar/routes/root/command-items.ts +8 -0
  84. package/src/components/command-bar/routes/root/results.ts +19 -2
  85. package/src/components/command-bar/routes/root/runtime.ts +3 -2
  86. package/src/components/command-bar/routes/root/selection.ts +3 -2
  87. package/src/components/command-bar/routes/root/shortcuts.ts +15 -0
  88. package/src/components/company-logo.tsx +10 -3
  89. package/src/components/data-table/sections.ts +6 -1
  90. package/src/components/layout/pane/title.ts +16 -6
  91. package/src/components/layout/shell/index.tsx +5 -1
  92. package/src/components/layout/shell/ticker-link-menu.ts +12 -9
  93. package/src/components/pane-settings-dialog/tui.tsx +6 -3
  94. package/src/components/pane-settings-dialog.tsx +2 -1
  95. package/src/components/pane-template-wizard.tsx +2 -0
  96. package/src/components/ticker/badge/format.ts +12 -3
  97. package/src/components/ticker/badge/index.tsx +9 -3
  98. package/src/components/ticker/list-table-view.tsx +119 -17
  99. package/src/components/ui/choice-dialog.tsx +1 -1
  100. package/src/components/ui/confirm-dialog.tsx +3 -2
  101. package/src/components/ui/data-table/display-columns.ts +16 -0
  102. package/src/components/ui/data-table/index.tsx +40 -9
  103. package/src/components/ui/data-table/types.ts +14 -0
  104. package/src/components/ui/frame.tsx +7 -3
  105. package/src/components/ui/icon.tsx +4 -2
  106. package/src/components/ui/list-view.tsx +8 -0
  107. package/src/components/ui/number-prompt-dialog.tsx +2 -1
  108. package/src/components/use-pane-notice-footer.tsx +3 -1
  109. package/src/core/state/app/layout-reducer.ts +3 -1
  110. package/src/core/state/app/layout.ts +2 -2
  111. package/src/data/config/layout.ts +14 -0
  112. package/src/data/config/store/normalize.ts +11 -1
  113. package/src/docs/snapshot.json +2 -2
  114. package/src/i18n/es.ts +39 -0
  115. package/src/i18n/ja.ts +39 -0
  116. package/src/i18n/ko.ts +39 -0
  117. package/src/i18n/zh-cn.ts +39 -0
  118. package/src/i18n/zh-tw.ts +39 -0
  119. package/src/layout/pane-follow.ts +141 -4
  120. package/src/layout/pane-layout-move.ts +10 -7
  121. package/src/layout/ticker-navigation.ts +13 -19
  122. package/src/layout/ticker-retarget.ts +3 -2
  123. package/src/market-data/market/format.ts +35 -1
  124. package/src/market-data/market/index-level.ts +19 -0
  125. package/src/market-data/quotes/contributions.ts +13 -0
  126. package/src/market-data/quotes/export-identity.ts +36 -1
  127. package/src/market-data/quotes/resolution.ts +16 -0
  128. package/src/plugins/builtin/account-management/keyboard.ts +14 -0
  129. package/src/plugins/builtin/account-management/model.ts +2 -0
  130. package/src/plugins/builtin/account-management/pane.tsx +79 -7
  131. package/src/plugins/builtin/account-management/password-dialog.tsx +2 -2
  132. package/src/plugins/builtin/account-management/payment-recovery-row.tsx +97 -0
  133. package/src/plugins/builtin/account-management/yearly-plan-row.tsx +359 -0
  134. package/src/plugins/builtin/analytics/risk-client.ts +12 -2
  135. package/src/plugins/builtin/analytics/risk-headless.ts +66 -6
  136. package/src/plugins/builtin/analytics/risk-math.ts +23 -6
  137. package/src/plugins/builtin/analytics/risk-model.ts +20 -9
  138. package/src/plugins/builtin/analytics/risk-pane.tsx +2 -2
  139. package/src/plugins/builtin/awards/pane.tsx +6 -8
  140. package/src/plugins/builtin/changelog/index.tsx +6 -44
  141. package/src/plugins/builtin/changelog/versions.ts +17 -68
  142. package/src/plugins/builtin/chart-composer/catalog-inventory.ts +5 -2
  143. package/src/plugins/builtin/chart-composer/editor.tsx +1 -0
  144. package/src/plugins/builtin/chart-composer/pane.tsx +1 -1
  145. package/src/plugins/builtin/chart-composer/quick-add.tsx +4 -1
  146. package/src/plugins/builtin/chart-composer/series-catalog.ts +17 -1
  147. package/src/plugins/builtin/cloud/askg/executor.ts +2 -1
  148. package/src/plugins/builtin/cloud/askg/sources.ts +2 -1
  149. package/src/plugins/builtin/cloud/plugin.tsx +2 -0
  150. package/src/plugins/builtin/cloud/thesis/module.tsx +2 -0
  151. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +6 -2
  152. package/src/plugins/builtin/cpi/headless.ts +6 -1
  153. package/src/plugins/builtin/cpi/model.ts +17 -0
  154. package/src/plugins/builtin/cpi/pane.tsx +4 -2
  155. package/src/plugins/builtin/crypto-board/client.ts +6 -1
  156. package/src/plugins/builtin/crypto-board/headless.ts +10 -2
  157. package/src/plugins/builtin/crypto-board/model.ts +89 -11
  158. package/src/plugins/builtin/crypto-board/pane.tsx +20 -5
  159. package/src/plugins/builtin/debt-maturities/model.ts +1 -1
  160. package/src/plugins/builtin/dividend-yield/client.ts +24 -2
  161. package/src/plugins/builtin/dividend-yield/headless.ts +4 -2
  162. package/src/plugins/builtin/dividend-yield/ranking.ts +2 -1
  163. package/src/plugins/builtin/dividend-yield/view.ts +5 -1
  164. package/src/plugins/builtin/earnings/board-table.ts +1 -1
  165. package/src/plugins/builtin/earnings/board.tsx +36 -16
  166. package/src/plugins/builtin/earnings/highlight.ts +47 -0
  167. package/src/plugins/builtin/earnings/history-table.ts +9 -1
  168. package/src/plugins/builtin/earnings/index.tsx +1 -1
  169. package/src/plugins/builtin/earnings-calls/pane.tsx +2 -2
  170. package/src/plugins/builtin/earnings-ripple/index.tsx +2 -0
  171. package/src/plugins/builtin/econ/calendar-model.ts +17 -1
  172. package/src/plugins/builtin/econ/fred-catalog.ts +33 -4
  173. package/src/plugins/builtin/econ-statistics/headless.ts +21 -0
  174. package/src/plugins/builtin/estimate-revisions/model.ts +1 -1
  175. package/src/plugins/builtin/exposure/index.tsx +1 -1
  176. package/src/plugins/builtin/macro-day/headless.ts +21 -10
  177. package/src/plugins/builtin/macro-day/model.ts +42 -3
  178. package/src/plugins/builtin/macro-day/pane.tsx +26 -8
  179. package/src/plugins/builtin/macro-day/releases.ts +24 -1
  180. package/src/plugins/builtin/market-valuation/detail.tsx +3 -3
  181. package/src/plugins/builtin/market-valuation/headless.ts +11 -4
  182. package/src/plugins/builtin/market-valuation/pane.tsx +3 -1
  183. package/src/plugins/builtin/market-valuation/view.ts +14 -0
  184. package/src/plugins/builtin/money-markets/client.ts +4 -1
  185. package/src/plugins/builtin/money-markets/headless.ts +15 -4
  186. package/src/plugins/builtin/money-markets/index.tsx +1 -1
  187. package/src/plugins/builtin/money-markets/pane.tsx +7 -1
  188. package/src/plugins/builtin/news/wire/news/detail-view.tsx +20 -8
  189. package/src/plugins/builtin/pe-band/pane.tsx +1 -1
  190. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -2
  191. package/src/plugins/builtin/portfolio-list/cli/period-report.ts +61 -11
  192. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +11 -3
  193. package/src/plugins/builtin/portfolio-list/cli/render.ts +8 -1
  194. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +178 -17
  195. package/src/plugins/builtin/portfolio-list/headless.ts +33 -6
  196. package/src/plugins/builtin/portfolio-list/pane/groups.tsx +220 -0
  197. package/src/plugins/builtin/portfolio-list/pane/index.tsx +95 -18
  198. package/src/plugins/builtin/portfolio-list/pane/period-pnl.ts +24 -6
  199. package/src/plugins/builtin/portfolio-list/period-pnl.ts +16 -1
  200. package/src/plugins/builtin/portfolio-list/summary/index.tsx +4 -1
  201. package/src/plugins/builtin/portfolio-list/summary/totals.ts +6 -4
  202. package/src/plugins/builtin/portfolio-list/table.tsx +38 -16
  203. package/src/plugins/builtin/research/corporate-actions-pane.tsx +4 -2
  204. package/src/plugins/builtin/research/relative-valuation-headless.ts +15 -5
  205. package/src/plugins/builtin/research/relative-valuation-model.ts +7 -1
  206. package/src/plugins/builtin/research/relative-valuation-pane.tsx +7 -4
  207. package/src/plugins/builtin/shared/cloud-upgrade.ts +4 -2
  208. package/src/plugins/builtin/shared/cpi-year-gap.ts +67 -0
  209. package/src/plugins/builtin/shared/headless-options.ts +1 -1
  210. package/src/plugins/builtin/social-mentions/model.ts +2 -2
  211. package/src/plugins/builtin/thirteenf/pane.tsx +1 -1
  212. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +45 -2
  213. package/src/plugins/builtin/ticker-detail/financials/model.ts +51 -16
  214. package/src/plugins/builtin/ticker-detail/financials/nopat.ts +16 -0
  215. package/src/plugins/builtin/ticker-detail/financials/ratios.ts +44 -13
  216. package/src/plugins/builtin/ticker-detail/financials/schema.ts +33 -2
  217. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +4 -2
  218. package/src/plugins/builtin/ticker-detail/headless-schema.ts +30 -4
  219. package/src/plugins/builtin/ticker-detail/headless.ts +280 -35
  220. package/src/plugins/builtin/ticker-detail/overview/components.tsx +4 -5
  221. package/src/plugins/builtin/ticker-detail/overview/model.ts +9 -2
  222. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +10 -2
  223. package/src/plugins/builtin/ticker-detail/pharma-signals/eligibility.ts +32 -0
  224. package/src/plugins/builtin/ticker-detail/pharma-signals/tab.tsx +162 -0
  225. package/src/plugins/builtin/ticker-detail/pharma-signals/waitlist.ts +126 -0
  226. package/src/plugins/builtin/ticker-detail/research-groups.ts +6 -4
  227. package/src/plugins/builtin/ticker-detail/research-tabs.ts +11 -0
  228. package/src/portfolio/collection-name.ts +2 -1
  229. package/src/portfolio/column-values.ts +34 -12
  230. package/src/portfolio/listed-symbol.ts +4 -2
  231. package/src/portfolio/period-pnl.ts +51 -1
  232. package/src/portfolio/suffixed-listings.ts +3 -1
  233. package/src/portfolio/watchlist-groups.ts +212 -0
  234. package/src/react/ticker-source.ts +3 -1
  235. package/src/renderers/dom/dialog-host.tsx +5 -5
  236. package/src/renderers/dom/styles.css +7 -0
  237. package/src/renderers/electrobun/view/remote/capability-invoker.ts +1 -1
  238. package/src/renderers/opentui/dialog-host.tsx +3 -4
  239. package/src/sources/gloomberb-cloud/normalizers.ts +5 -0
  240. package/src/sources/provider-router/history.ts +5 -2
  241. package/src/state/app/bootstrap.ts +11 -0
  242. package/src/state/app/context/index.tsx +6 -0
  243. package/src/sync/collections-contributor.ts +5 -2
  244. package/src/sync/config-merge.ts +10 -2
  245. package/src/sync/sanitize.ts +28 -0
  246. package/src/telemetry/usage-counts.ts +17 -0
  247. package/src/test-support/plugin-persistence.ts +12 -0
  248. package/src/tickers/company-name-listing.ts +4 -3
  249. package/src/tickers/company-name.ts +19 -1
  250. package/src/tickers/instrument-coverage.ts +27 -0
  251. package/src/tickers/search/home-listing.ts +38 -1
  252. package/src/tickers/search/index.ts +3 -2
  253. package/src/tickers/search/ranking.ts +21 -2
  254. package/src/time-series/base-series.ts +4 -0
  255. package/src/time-series/chart-seed.ts +1 -1
  256. package/src/time-series/financial-period-coverage.ts +4 -12
  257. package/src/time-series/parsed-history-cache.ts +1 -1
  258. package/src/time-series/resolve.ts +1 -1
  259. package/src/time-series/types.ts +5 -2
  260. package/src/time-series/use-chart-resolution.ts +6 -1
  261. package/src/types/config.ts +32 -0
  262. package/src/types/financials.ts +13 -0
  263. package/src/types/headless.ts +7 -0
  264. package/src/types/plugin-context.ts +5 -0
  265. package/src/types/ticker.ts +14 -0
  266. package/src/ui/ascii-font.ts +1 -4
  267. package/src/ui/dialog-stack.ts +17 -0
  268. package/src/ui/dialog.tsx +6 -2
  269. package/src/utils/async-deadline.ts +2 -2
  270. package/src/utils/crypto-pair.ts +9 -0
  271. package/src/utils/csv.ts +44 -5
  272. package/src/utils/exchanges.ts +13 -0
  273. package/src/utils/financial-statements.ts +60 -3
  274. package/src/utils/futures-generic.ts +17 -0
  275. package/src/utils/trailing-dividend.ts +13 -3
@@ -24,9 +24,10 @@ import { isVenueAbroad, lineMayHaveMoved, listingChangeLine, loadListingFate, Mo
24
24
  import { quotedListingName } from "../tickers/listing-name";
25
25
  import { withdrawalLabel } from "../market-data/quotes/delisting";
26
26
  import { cliStyles } from "../utils/cli-output";
27
- import { companyNameExtraWords, groupByCompany, namesDepositaryReceipt, sameCompany, sameCompanyName, sameListedName, shortCompanyName } from "../tickers/company-name";
27
+ import { companyLinesName, companyNameExtraWords, groupByCompany, namesDepositaryReceipt, sameCompany, sameCompanyName, sameListedName, shortCompanyName } from "../tickers/company-name";
28
28
  import {
29
29
  canonicalExchange,
30
+ displayTickerKey,
30
31
  exchangeCodeVenues,
31
32
  exchangeLabel,
32
33
  exchangeName,
@@ -258,6 +259,45 @@ function tradesOn(symbol: string, venues: readonly ListingVenue[]): string {
258
259
  return venues.length > 0 ? ` ${symbol} trades on: ${venues.map((venue) => venue.exchange).join(", ")}.` : "";
259
260
  }
260
261
 
262
+ /** The companies a symbol's venues are asked about for their line on another venue: the first few, home lines first. */
263
+ const MAX_COMPANIES_ASKED = 4;
264
+
265
+ /**
266
+ * " Prudential plc trades on HKEX as 2378:HKEX." when a company that lists
267
+ * as `symbol` elsewhere has a line of its own on `exchange`: PRU on LSE is
268
+ * Prudential plc, whose Hong Kong line is 2378, and HSBC on NYSE is HSBC
269
+ * Holdings, whose is 0005. Each company is asked once, by one of its venues;
270
+ * empty when none has a line there or the service cannot say.
271
+ */
272
+ async function companyLineOn(symbol: string, exchange: string, venues: readonly ListingVenue[], deps: ListingDeps): Promise<string> {
273
+ const { getIssuerListings } = deps.dataProvider;
274
+ if (!getIssuerListings) return "";
275
+ const byCompany = new Map<string, ListingVenue>();
276
+ for (const venue of [...venues].sort((a, b) => Number(!!b.home) - Number(!!a.home))) {
277
+ const company = venue.companyId ?? venue.name;
278
+ if (!byCompany.has(company)) byCompany.set(company, venue);
279
+ }
280
+ const asked = [...byCompany.values()].slice(0, MAX_COMPANIES_ASKED);
281
+ const issuers = await Promise.all(asked.map((venue) => Promise.resolve()
282
+ .then(() => getIssuerListings.call(deps.dataProvider, venue.symbol ?? symbol, venue.exchange))
283
+ .catch(logFailure("cli.listing-arg", "Read a company's listings failed", null))));
284
+ const lines = new Map<string, string>();
285
+ issuers.forEach((issuer, index) => {
286
+ const line = issuer?.listings.find((listing) => canonicalExchange(listing.exchange) === exchange);
287
+ if (!issuer || !line) return;
288
+ const key = parsePublicTickerKey(line.symbol).exchange ? displayTickerKey(line.symbol) : `${line.symbol}:${exchange}`;
289
+ // The name search writes the line asked about under, its home line first (Prudential plc), as ADR names it.
290
+ lines.set(key, `${companyLinesName(asked[index]!.name, issuer.name)} trades on ${exchange} as ${key}.`);
291
+ });
292
+ return [...lines.values()].map((line) => ` ${line}`).join("");
293
+ }
294
+
295
+ /** "PRU does not trade on HKEX. Prudential plc trades on HKEX as 2378:HKEX. PRU trades on: LSE, NYSE." */
296
+ async function notTradedText(listing: Pick<ListingArg, "symbol" | "exchange">, venues: readonly ListingVenue[], deps: ListingDeps): Promise<string> {
297
+ const companyLine = await companyLineOn(listing.symbol, listing.exchange, venues, deps);
298
+ return `${listing.symbol} does not trade on ${listing.exchange}.${companyLine}${tradesOn(listing.symbol, venues)}`;
299
+ }
300
+
261
301
  /** "Toronto Stock Exchange (TSX) or Tokyo Stock Exchange (JPX)". */
262
302
  function venueChoices(venues: readonly string[]): string {
263
303
  const labels = venues.map(exchangeLabel);
@@ -351,7 +391,7 @@ export async function notTradedMessage(
351
391
  if (withdrawn) return withdrawnListingMessage(listing, withdrawn);
352
392
  if (venues.length === 0 || venues.some((venue) => venue.exchange === listing.exchange)) return null;
353
393
  if (await quotedOnVenue(listing, deps)) return null;
354
- return `${listing.symbol} does not trade on ${listing.exchange}.${tradesOn(listing.symbol, venues)}`;
394
+ return notTradedText(listing, venues, deps);
355
395
  }
356
396
 
357
397
  /**
@@ -1581,13 +1621,18 @@ export async function resolveCliListing(
1581
1621
  const read = await readTerminalCodeArg(deps.dataProvider, typed);
1582
1622
  // A company's name, an entry of a comma list (`WHR, Whirlpool Corporation`), is the listing search names for it.
1583
1623
  // A name before a legal form ("SAP SE", "SIEMENS AG") is looked up first: SE is also SIX Swiss's market code.
1584
- const named = !read || endsInLegalForm(typed) ? await companyNameListingArg(raw, deps) : null;
1624
+ const legalForm = !!read && endsInLegalForm(typed);
1625
+ const asName = !read || legalForm ? await companyNameListingArg(raw, deps) : null;
1626
+ // Read both ways as two companies ("ZURN SE": Zurich Insurance on SIX, Zurn Elkay by name), the code's listing wins.
1627
+ const codeWins = legalForm && asName ? await codeOverCompanyName(read!, asName.found, deps) : null;
1628
+ const named = codeWins ? null : asName?.listing ?? null;
1585
1629
  const terminal = named ? null : read;
1586
1630
  // "AAPL GP" is written as a code, with a market code no venue answers to and no company's name: one entry, never AAPL and GP.
1587
1631
  if (!terminal && !named) await refuseUnknownMarketCode(typed, deps);
1588
1632
  // `BP.` is London's code for BP: its London line where London lists it, and `GE.` a US ticker with a stray dot.
1589
1633
  const dotted = terminal || named || exchangeOption?.trim() ? null : readLondonDottedSymbol(typed);
1590
1634
  let parsed = named ?? (dotted ? await londonDottedListing(dotted, deps) : parseListingArg(raw, exchangeOption, { ...options, terminalCode: terminal }));
1635
+ if (codeWins) parsed = { ...parsed, readAs: codeWins };
1591
1636
  if (!parsed.symbol) throw new ListingArgError("Ticker symbol is required.");
1592
1637
  // $VIX is Schwab's code for ^VIX, unless a security trades as VIX: $AAPL is a cashtag.
1593
1638
  const index = named || parsed.exchange ? null : await readDollarIndexCode(raw, deps);
@@ -1645,6 +1690,33 @@ export async function resolveCliListing(
1645
1690
  };
1646
1691
  }
1647
1692
 
1693
+ /**
1694
+ * How a symbol and a market code read when the words are also a company's name
1695
+ * before its legal form, SE being both SIX Swiss's code and a European
1696
+ * company's form: "ZURN SE" is Zurich Insurance on SIX as a code and Zurn
1697
+ * Elkay Water Solutions as a name, "NOVN SE" Novartis and Novan, "SAP SE" SAP
1698
+ * either way. Two companies: the code names one listing on one venue, as a
1699
+ * desk typing a terminal's codes means it, so it wins, and the note names the
1700
+ * company the words would be ("Read "ZURN SE" as ZURN:SWX (Zurich Insurance
1701
+ * Group AG), not ZWS:NYSE (Zurn Elkay ...)"). One company, by the service's
1702
+ * company ids or by name: null, so the name reads the company's home listing
1703
+ * (SAP on Xetra, not its SIX line). Null too when the code's venue lists
1704
+ * nothing under the symbol.
1705
+ */
1706
+ async function codeOverCompanyName(code: TerminalListingCode, found: CompanyNameListing, deps: ListingDeps): Promise<string | null> {
1707
+ if (!code.exchange) return null;
1708
+ const venues = await listingVenues(code.symbol, deps).catch(logFailure("cli.listing-arg", "Read a market code's listing failed", [] as ListingVenue[]));
1709
+ const line = venues.find((venue) => venue.exchange === code.exchange && venue.name.trim());
1710
+ if (!line) return null;
1711
+ const company = found.meant ?? found;
1712
+ const companyLine = company.symbol.toUpperCase() === code.symbol.toUpperCase()
1713
+ ? venues.find((venue) => venue.exchange === company.exchange) : undefined;
1714
+ const ids = [line.companyId, companyLine?.companyId];
1715
+ if (ids[0] && ids[1] ? ids[0] === ids[1] : sameCompany(line.name, company.name)) return null;
1716
+ const key = company.exchange ? `${company.symbol}:${company.exchange}` : company.symbol;
1717
+ return `${terminalCodeReadAs(code).replace(/\.$/, "")} (${line.name.trim()}), not ${key} (${company.name.trim()}).`;
1718
+ }
1719
+
1648
1720
  /** A US share class typed with a space for its mark: `BRK B`, `brk b`. */
1649
1721
  const SPACED_SHARE_CLASS = /^([A-Za-z]{1,5})\s+([A-Za-z])$/;
1650
1722
  /** A US share class typed with no mark at all, in capitals: `BRKB`, `BFB`. */
@@ -1757,7 +1829,7 @@ async function checkTerminalCodeVenue(listing: ListingArg, market: string, deps:
1757
1829
  if (!hint && !isSearchOnlyVenue(listing.exchange)) return;
1758
1830
  const venues = await listingVenues(listing.symbol, deps).catch(logFailure("cli.listing-arg", "Read listing venues failed", []));
1759
1831
  if (venues.length === 0 || venues.some((venue) => venue.exchange === listing.exchange)) return;
1760
- throw new ListingArgError(`${listing.symbol} does not trade on ${listing.exchange}.${tradesOn(listing.symbol, venues)}`, hint ?? undefined);
1832
+ throw new ListingArgError(await notTradedText(listing, venues, deps), hint ?? undefined);
1761
1833
  }
1762
1834
 
1763
1835
  /**
@@ -1958,9 +2030,10 @@ async function japaneseNameListing(
1958
2030
  * symbol, and for a name search finds no listing for, which then fails as a
1959
2031
  * symbol would.
1960
2032
  */
1961
- async function companyNameListingArg(raw: string, deps: ListingDeps): Promise<ListingArg | null> {
2033
+ async function companyNameListingArg(raw: string, deps: ListingDeps): Promise<{ listing: ListingArg; found: CompanyNameListing } | null> {
1962
2034
  const typed = stripStrayEdges(raw).text || raw;
1963
- return isCompanyNameInput(typed) ? readCompanyName(typed, deps) : null;
2035
+ const found = isCompanyNameInput(typed) ? await findCompanyName(typed, deps) : null;
2036
+ return found ? { listing: companyListingArg(typed, found), found } : null;
1964
2037
  }
1965
2038
 
1966
2039
  /** `Read "crude oil" as CL=F (WTI Crude Oil), the benchmark future; Brent is BZ=F.` */
@@ -2104,11 +2177,6 @@ function movedWithoutQuote(change: ListingFate["change"], name: string | null):
2104
2177
  return moved && sameCompany(name, moved.issuer) ? moved : null;
2105
2178
  }
2106
2179
 
2107
- async function readCompanyName(typed: string, deps: Pick<ListingDeps, "dataProvider">, options: { oneWord?: boolean } = {}): Promise<ListingArg | null> {
2108
- const found = await findCompanyName(typed, deps, options);
2109
- return found ? companyListingArg(typed, found) : null;
2110
- }
2111
-
2112
2180
  function companyListingArg(typed: string, found: CompanyNameListing): ListingArg {
2113
2181
  const key = found.exchange ? `${found.symbol}:${found.exchange}` : found.symbol;
2114
2182
  // A fund or an index carrying the name asks about the company's stock: "Did you mean JPM (JPMorgan Chase & Co.)?".
@@ -1,4 +1,5 @@
1
1
  import { futuresContractByWord } from "../market-data/futures-board";
2
+ import { venueOfDatedContract } from "../utils/futures-generic";
2
3
  import { notATickerSymbol } from "../sources/provider-errors";
3
4
  import { renamedListingFor, renamedListingHint } from "../tickers/renamed-listings";
4
5
  import { boardCoinFor } from "./board-coins";
@@ -58,6 +59,9 @@ export function withSearchHints(text: string, args: readonly string[], isFredSer
58
59
  if (renamed) return `${sentence} ${renamedListingHint(renamed)}`;
59
60
  const coin = boardCoinFor(id);
60
61
  if (coin) return `${sentence} Did you mean ${coin.symbol}${coin.name && coin.name.toUpperCase() !== coin.symbol ? ` (${coin.name})` : ""}?`;
62
+ // A dated contract typed without its venue (ZQZ26) is quoted with it: ZQZ26.CBT, as WIRP prints it.
63
+ const contract = venueOfDatedContract(id);
64
+ if (contract) return `${sentence} Did you mean ${contract}?`;
61
65
  const tenor = treasuryYieldTenor(typed);
62
66
  // A currency's name (`yen`) is its rate and its pair, not a ticker search could find; a commodity's word
63
67
  // (`oil`, `brent`) is its future, which no search for the word finds first.
@@ -1,3 +1,4 @@
1
+ import type { CsvDecimal } from "../utils/csv";
1
2
  export type CliOutputFormat = "text" | "json" | "csv" | "ndjson";
2
3
 
3
4
  export interface CliGlobalOptions {
@@ -27,6 +28,12 @@ export interface CliGlobalOptions {
27
28
  * `--output` read the flag themselves.
28
29
  */
29
30
  output?: string;
31
+ /**
32
+ * `--decimal comma|dot`: the decimal mark of a `--csv` export, for this run.
33
+ * A decimal comma separates the cells with `;`. Unset, the `csvDecimal`
34
+ * setting decides, and without it the dot.
35
+ */
36
+ decimal?: CsvDecimal;
30
37
  }
31
38
 
32
39
  export interface ParsedCliArgs {
@@ -75,6 +82,14 @@ function parseColumnCount(value: string | undefined): number {
75
82
  return parsed;
76
83
  }
77
84
 
85
+ /** The decimal mark `--decimal` names: `comma` (or `,`), or `dot` (`.`, `point`). */
86
+ export function parseCsvDecimal(value: string | undefined, flag = "--decimal"): CsvDecimal {
87
+ const word = value?.trim().toLowerCase();
88
+ if (word === "comma" || word === ",") return "comma";
89
+ if (word === "dot" || word === "." || word === "point" || word === "period") return "dot";
90
+ throw new Error(`${flag} takes comma or dot: --csv --decimal comma writes 17,2 with cells split by ;, for a spreadsheet that reads a decimal comma.`);
91
+ }
92
+
78
93
  function parseOutputFile(value: string | undefined): string {
79
94
  if (!value?.trim() || value.startsWith("--")) throw new Error("--output needs a file to write, such as --csv --output report.csv.");
80
95
  return value;
@@ -85,7 +100,7 @@ function commandWord(rawArgs: readonly string[]): string | undefined {
85
100
  for (let index = 0; index < rawArgs.length; index += 1) {
86
101
  const arg = rawArgs[index]!;
87
102
  if (arg === "--") return rawArgs[index + 1];
88
- if (arg === "--limit" || arg === "--tail" || arg === "--width" || arg === "--output" || arg === "--out") index += 1;
103
+ if (arg === "--limit" || arg === "--tail" || arg === "--width" || arg === "--output" || arg === "--out" || arg === "--decimal") index += 1;
89
104
  else if (!arg.startsWith("-")) return arg;
90
105
  }
91
106
  return undefined;
@@ -183,6 +198,15 @@ export function parseCliGlobalArgs(rawArgs: string[], settings: { ownsOutput?: b
183
198
  options.output = parseOutputFile(arg.slice(arg.indexOf("=") + 1));
184
199
  continue;
185
200
  }
201
+ if (arg === "--decimal") {
202
+ index += 1;
203
+ options.decimal = parseCsvDecimal(rawArgs[index]);
204
+ continue;
205
+ }
206
+ if (arg.startsWith("--decimal=")) {
207
+ options.decimal = parseCsvDecimal(arg.slice("--decimal=".length));
208
+ continue;
209
+ }
186
210
  if (arg === "--limit" || arg === "--tail") {
187
211
  index += 1;
188
212
  options[arg === "--limit" ? "limit" : "tail"] = parseRowCount(arg, rawArgs[index]);
@@ -212,4 +236,8 @@ export function checkCliOutputFormat(parsed: Pick<ParsedCliArgs, "options" | "he
212
236
  if (parsed.options.output !== undefined && parsed.options.format === "text" && !parsed.help) {
213
237
  throw new Error("--output writes an export: add --csv, --json or --ndjson, such as --csv --output report.csv.");
214
238
  }
239
+ // The text a terminal prints and JSON's numbers keep their dot: only a CSV is read by a spreadsheet's locale.
240
+ if (parsed.options.decimal !== undefined && parsed.options.format !== "csv" && !parsed.help) {
241
+ throw new Error("--decimal sets the decimal mark of a CSV export: add --csv, such as --csv --decimal comma.");
242
+ }
215
243
  }
@@ -1,4 +1,6 @@
1
+ import type { TickerRecord } from "../../types/ticker";
1
2
  import { logFailure } from "../../utils/log-failure";
3
+ import { shellWord } from "../../utils/shell-word";
2
4
  import { commands as builtInCommands, getCommandPrefixes } from "../../components/command-bar/commands/registry";
3
5
  import type { HeadlessPaneDefinition, PaneDef, PaneTemplateCreateOptions, PaneTemplateDef } from "../../types/plugin";
4
6
  import type { MarketContext } from "../types";
@@ -12,6 +14,7 @@ import {
12
14
  getPaneFunctionCapability,
13
15
  MAX_INLINE_CHOICES,
14
16
  optionChoices,
17
+ optionFlag,
15
18
  optionFlags,
16
19
  paneFunctionArgument,
17
20
  type PaneFunctionCapability,
@@ -297,6 +300,7 @@ async function buildTemplateCatalogEntry(
297
300
  pane: PaneDef,
298
301
  context: MarketContext | null,
299
302
  token: string,
303
+ listName?: string | null,
300
304
  ): Promise<PaneCatalogEntry> {
301
305
  const sampleArg = sampleArgForTemplate(template);
302
306
  const createOptions: PaneTemplateCreateOptions | undefined = buildCreateOptions(template, sampleArg);
@@ -326,7 +330,7 @@ async function buildTemplateCatalogEntry(
326
330
  aliases: [...(template.shortcut?.aliases ?? [])],
327
331
  argKind: argument.kind,
328
332
  argPlaceholder: argument.placeholder,
329
- ...context ? argExamples(headless, context, pane) : null,
333
+ ...context ? argExamples(headless, context, pane, listName) : null,
330
334
  ...(headless?.argument.kind === "tickers" && template.shortcut?.argKind === "ticker"
331
335
  ? { shotArgument: argumentHint({ argKind: "ticker", argPlaceholder: template.shortcut.argPlaceholder }) } : {}),
332
336
  keywords: template.keywords ?? [],
@@ -337,19 +341,34 @@ async function buildTemplateCatalogEntry(
337
341
 
338
342
  /**
339
343
  * The arguments a function's examples show past its placeholder: its own, and
340
- * for a list of more than two symbols, a watchlist's name, which stands for
341
- * its symbols (the reader's first watchlist).
344
+ * for a list of more than two symbols, a list's name, which stands for its
345
+ * symbols: the reader's first watchlist or portfolio that holds any
346
+ * (`listName`), so the example runs as printed.
342
347
  */
343
- function argExamples(headless: HeadlessPaneDefinition | undefined, context: MarketContext, pane?: PaneDef): { argExamples: readonly string[] } | null {
348
+ function argExamples(
349
+ headless: HeadlessPaneDefinition | undefined,
350
+ context: MarketContext,
351
+ pane?: PaneDef,
352
+ listName: string | null = context.config.watchlists[0]?.name ?? "Watchlist",
353
+ ): { argExamples: readonly string[] } | null {
344
354
  // A rendered view's own examples (VIEW's spec) stand where a headless model would give them.
345
355
  const own = headless?.argument.examples ?? pane?.reportArgument?.examples ?? [];
346
356
  const argument = headless?.argument;
347
357
  const list = (argument?.kind === "symbol-list" || argument?.kind === "tickers") && (argument.maximum == null || argument.maximum > 2);
348
- const name = context.config.watchlists[0]?.name ?? "Watchlist";
349
- const examples = list ? [...own, /^[\w.-]+$/.test(name) ? name : `'${name.replace(/'/g, "'\\''")}'`] : own;
358
+ const examples = list && listName ? [...own, shellWord(listName)] : own;
350
359
  return examples.length > 0 ? { argExamples: examples } : null;
351
360
  }
352
361
 
362
+ /** The first watchlist, else portfolio, that holds a symbol: the list a function's example names. Null when none does. */
363
+ async function exampleListName(context: MarketContext): Promise<string | null> {
364
+ const tickers = await Promise.resolve().then(() => context.store.loadAllTickers())
365
+ .catch(logFailure("cli-catalog", "Read the lists for an example failed", [] as TickerRecord[]));
366
+ const watchlist = context.config.watchlists.find((list) => tickers.some((ticker) => ticker.metadata.watchlists.includes(list.id)));
367
+ const portfolio = watchlist ? null : context.config.portfolios.find((list) => tickers.some((ticker) => ticker.metadata.portfolios.includes(list.id)
368
+ || ticker.metadata.positions.some((position) => position.portfolio === list.id && position.shares !== 0)));
369
+ return (watchlist ?? portfolio)?.name ?? null;
370
+ }
371
+
353
372
  /**
354
373
  * The functions `gloom catalog` and search list. An unlisted one (`listed:
355
374
  * false`) is left out, and its pane is not listed in its place; `unlisted`
@@ -363,6 +382,8 @@ export async function buildPaneCatalogEntries(
363
382
  { unlisted = false, appPanes = false }: { unlisted?: boolean; appPanes?: boolean } = {},
364
383
  ): Promise<PaneCatalogEntry[]> {
365
384
  const entries: PaneCatalogEntry[] = [];
385
+ // Read once, when an example first needs it.
386
+ let listName: Promise<string | null> | undefined;
366
387
  const templatedPaneIds = new Set<string>();
367
388
  const codedPaneIds = new Set([...registry.paneTemplates.values()]
368
389
  .filter((template) => template.shortcut?.prefix && template.listed !== false)
@@ -377,7 +398,8 @@ export async function buildPaneCatalogEntries(
377
398
  if (!forUsers && !unlisted && !appPanes) continue;
378
399
  // A template only the UI audits list keeps the id an older catalog listed it by, so a base and a head picture it under one name.
379
400
  const token = forUsers || unlisted ? paneFunctionCode(template, pane, registry) : template.id;
380
- entries.push(await buildTemplateCatalogEntry(template, pane, context, token));
401
+ listName ??= context ? exampleListName(context) : Promise.resolve(null);
402
+ entries.push(await buildTemplateCatalogEntry(template, pane, context, token, await listName));
381
403
  }
382
404
 
383
405
  for (const pane of registry.panes.values()) {
@@ -394,7 +416,7 @@ export async function buildPaneCatalogEntries(
394
416
  aliases,
395
417
  argKind: argument.kind,
396
418
  argPlaceholder: argument.placeholder,
397
- ...context ? argExamples(pane.headless, context, pane) : null,
419
+ ...context ? argExamples(pane.headless, context, pane, await (listName ??= exampleListName(context))) : null,
398
420
  keywords: [],
399
421
  defaultSettings: {},
400
422
  capability: getPaneFunctionCapability(undefined, pane),
@@ -518,6 +540,9 @@ function scorePaneCatalogEntry(entry: PaneCatalogEntry, query: string): CatalogM
518
540
  ].filter((value): value is string => !!value).map((value) => normalizeLookupToken(value));
519
541
  const flagKeys = entry.capability.options
520
542
  .flatMap((option) => [option.key, ...(option.aliases ?? [])]).map((value) => normalizeLookupToken(value));
543
+ // A value one of its options takes names the function as a flag's own name does: `compounders` is EQS's preset.
544
+ const flagValues = new Set(entry.capability.options.flatMap((option) => (option.values ?? [])
545
+ .flatMap((value) => [value.value, ...(value.aliases ?? [])])).map((value) => normalizeLookupToken(value)));
521
546
  const named = nameAndDescription(entry);
522
547
  const flags = flagText(entry);
523
548
  const wholeQuery = query.toLowerCase().trim().replace(/\s+/g, " ");
@@ -554,7 +579,7 @@ function scorePaneCatalogEntry(entry: PaneCatalogEntry, query: string): CatalogM
554
579
  } else if (normalized !== term && named.includes(normalized)) {
555
580
  score += 1;
556
581
  matchedNamed += 1;
557
- } else if (flagKeys.includes(normalized)) {
582
+ } else if (flagKeys.includes(normalized) || flagValues.has(normalized)) {
558
583
  score += 2;
559
584
  matchedFlagKeys += 1;
560
585
  } else if (containsPhrase(flags, term)) {
@@ -566,6 +591,9 @@ function scorePaneCatalogEntry(entry: PaneCatalogEntry, query: string): CatalogM
566
591
  }
567
592
 
568
593
  if (matchedTerms === 0) return none;
594
+ // The whole query a value an option takes (GF's `operating margin` metric) is a name the function answers to.
595
+ const valueNamed = terms.length > 1 && flagValues.has(normalizeLookupToken(wholeQuery));
596
+ if (valueNamed) matchedNamed = terms.length;
569
597
  // Words found only in a function's flags make a match when they are a flag's own name ("expiration") or,
570
598
  // together, cover the whole query ("funding rate" in two flags); one stray word in a flag's description
571
599
  // ("budget" in OSA's hedge budget) does not.
@@ -909,6 +937,30 @@ function renderCatalogEntry(entry: PaneCatalogEntry): string {
909
937
  return lines.join("\n");
910
938
  }
911
939
 
940
+ /**
941
+ * The command that runs a function with the option value a query names (`compounders` is EQS's `--preset
942
+ * compounders`), with the argument it needs first; null when the query is no value of its options.
943
+ */
944
+ function optionValueCommand(entry: PaneCatalogEntry, query: string): string | null {
945
+ const wanted = normalizeLookupToken(query);
946
+ if (!wanted) return null;
947
+ // A word that opens one case of the function (FA's `roic`) runs it with that case's options.
948
+ const opening = entry.capability.opens?.find((candidate) => candidate.words.some((word) => normalizeLookupToken(word) === wanted));
949
+ if (opening?.options && Object.keys(opening.options).length > 0) {
950
+ const argument = opening.argument || argumentHint(entry);
951
+ const flags = Object.entries(opening.options).map(([key, value]) => `${optionFlag(key)} ${value}`).join(" ");
952
+ return `gloom fn ${entry.token}${argument ? ` ${argument}` : ""} ${flags}`;
953
+ }
954
+ for (const option of entry.capability.options) {
955
+ const value = option.values?.find((candidate) => [candidate.value, ...(candidate.aliases ?? [])]
956
+ .some((name) => normalizeLookupToken(name) === wanted));
957
+ if (!value) continue;
958
+ const argument = argumentHint(entry);
959
+ return `gloom fn ${entry.token}${argument ? ` ${argument}` : ""} ${optionFlag(option.key)} ${value.value}`;
960
+ }
961
+ return null;
962
+ }
963
+
912
964
  /** The functions a search lists, one row each. */
913
965
  function renderMatchesTable(shown: readonly PaneCatalogEntry[]): string {
914
966
  return renderTable(
@@ -1004,9 +1056,12 @@ export function renderPaneCatalogReport(
1004
1056
  const withGap = (text: string) => withSetting([gap ? wrapText(gap, width).join("\n") : "", text].filter(Boolean).join("\n\n"));
1005
1057
  const withTerms = (text: string) => withGap([text, charted, terms].filter(Boolean).join("\n\n"));
1006
1058
  if (args.query && entries.length === 1) {
1007
- // A function found only through a word of its description or keywords is the closest there is, and says so.
1008
- const closest = isClosestCatalogMatch(entries[0]!, args.query)
1009
- ? `${cliStyles.muted(`Closest match for "${args.query.trim()}": no function is named for it.`)}\n\n` : "";
1059
+ // A value of one of its options (EQS's `compounders` preset) is run with that option; a function found only
1060
+ // through a word of its description or keywords is the closest there is, and says so.
1061
+ const run = optionValueCommand(entries[0]!, args.query);
1062
+ const closest = run ? `${cliStyles.muted(`"${args.query.trim()}": ${run}`)}\n\n`
1063
+ : isClosestCatalogMatch(entries[0]!, args.query)
1064
+ ? `${cliStyles.muted(`Closest match for "${args.query.trim()}": no function is named for it.`)}\n\n` : "";
1010
1065
  return withTerms(`${closest}${renderCatalogEntry(entries[0]!)}`);
1011
1066
  }
1012
1067
 
@@ -1028,10 +1083,13 @@ export function renderPaneCatalogReport(
1028
1083
  const more = args.query
1029
1084
  ? `${hidden} more ${hidden === 1 ? "match" : "matches"}: refine the query, or add --all to list every match.`
1030
1085
  : `Add --all to list all ${entries.length}.`;
1086
+ // The functions that take the query as an option's value, with the command that runs them on it.
1087
+ const runs = args.query ? shown.flatMap((entry) => optionValueCommand(entry, args.query) ?? []).slice(0, 3) : [];
1031
1088
  const lines = [
1032
1089
  `${renderSection(title)} ${cliStyles.muted(`(${count})`)}`,
1033
1090
  renderMatchesTable(shown),
1034
1091
  "",
1092
+ ...runs.length > 0 ? [note(`"${args.query.trim()}": ${runs.join("; ")}`)] : [],
1035
1093
  note([
1036
1094
  loose ? "No function carries every word of the query; these are the closest." : "",
1037
1095
  "gloom catalog <function> shows its options and examples.",
@@ -411,7 +411,7 @@ export const FUNCTION_HELP: Readonly<Record<string, FunctionHelp>> = {
411
411
  bloomberg: ["CACS"],
412
412
  },
413
413
  EVTS: {
414
- summary: "The market board: report days with implied and past moves, or a past or coming week or day of them; a ticker highlights its row.",
414
+ summary: "The market board: report days with implied and past moves. In the pane, a ticker opens its next report day, or its latest past one, with its row selected. An explicit week or day keeps that range.",
415
415
  usage: ["EVTS", "EVTS NVDA", "gloom fn EVTS --week last", "gloom fn EVTS --date 2026-10-15"],
416
416
  keys: [key("t", "icker"), key("e", "stimates"), key("c", "alls"), key("a", "nalysts")],
417
417
  data: EARNINGS_DAYS,
@@ -55,6 +55,7 @@ import { noArgumentMessage } from "./capabilities";
55
55
  import { lockedHeadlessReport } from "./lock-note";
56
56
  import { resumeStateKey } from "../../plugins/registry/plugin-state";
57
57
  import { logFailure } from "../../utils/log-failure";
58
+ import { windowRows, type RowWindow, type RowWindowOptions } from "../row-window";
58
59
 
59
60
  interface SerializableHeadlessColumn {
60
61
  key: string;
@@ -539,7 +540,11 @@ function seriesValue(series: HeadlessSeries, value: number | null): string {
539
540
  if (unit === "%" || unit === "pp") return value.toFixed(2);
540
541
  if (unit === "x" || unit === "ratio") return value !== 0 && Math.abs(value) < 0.1 ? value.toPrecision(3) : value.toFixed(2);
541
542
  if (unit === "score") return value.toFixed(1);
542
- return displayNumber(value);
543
+ // A count or amount of five digits or more groups its thousands as every other table does (27,256,037 shares).
544
+ const plain = displayNumber(value);
545
+ const [whole, fraction] = plain.split(".");
546
+ return Math.abs(value) >= 10_000 && /^-?\d+(?:\.\d+)?$/.test(plain)
547
+ ? `${whole!.replace(/\B(?=(\d{3})+$)/g, ",")}${fraction ? `.${fraction}` : ""}` : plain;
543
548
  }
544
549
 
545
550
  function renderRows(
@@ -867,8 +872,11 @@ export function headlessReportTables(
867
872
  const columns = displayedColumns(columnsFor(rowsResult.rows, rowsResult.columns, definition.columns));
868
873
  const rowIdentities = rowIdentitiesOf(rowsResult.rows, rowsResult);
869
874
  const own = exportRowsTable(title, columns, rowsResult.rows, { status: true, ...(rowsResult.rowUnitKey ? { rowUnitKey: rowsResult.rowUnitKey } : {}) });
870
- const interval = rowsResult.interval?.trim();
871
- tables = [{ ...own, ...(rowIdentities ? { rowIdentities } : {}), ...(interval ? { identity: { interval } } : {}) }, ...(rowsResult.exportTables ?? []).map((extra) => {
875
+ const ownIdentity = {
876
+ ...(rowsResult.unit?.trim() ? { currencyOrUnit: rowsResult.unit.trim() } : {}),
877
+ ...(rowsResult.interval?.trim() ? { interval: rowsResult.interval.trim() } : {}),
878
+ };
879
+ tables = [{ ...own, ...(rowIdentities ? { rowIdentities } : {}), ...(Object.keys(ownIdentity).length > 0 ? { identity: ownIdentity } : {}) }, ...(rowsResult.exportTables ?? []).map((extra) => {
872
880
  const identity = {
873
881
  ...(extra.unit?.trim() ? { currencyOrUnit: extra.unit.trim() } : {}),
874
882
  ...(extra.interval?.trim() ? { interval: extra.interval.trim() } : {}),
@@ -1097,6 +1105,62 @@ function withUnreached(
1097
1105
  return nothingServed && unreached ? { ...freshness, unreached: true } : freshness;
1098
1106
  }
1099
1107
 
1108
+ /** What a cut says: which rows of how many it kept, and of which table when the report has several. */
1109
+ function cutNote(window: RowWindowOptions, cut: RowWindow<unknown>, table?: string): string | null {
1110
+ if (cut.rows.length >= cut.total) return null;
1111
+ const kept = `${window.tail != null ? (cut.kept === "newest" ? "newest" : "last") : "first"} ${cut.rows.length} of ${cut.total} rows`;
1112
+ return `${table ? `${table}: ` : ""}${cut.note ?? `${kept} (--${window.tail != null ? "tail" : "limit"} ${window.tail ?? window.limit})`}`;
1113
+ }
1114
+
1115
+ /**
1116
+ * The report's rows as `--limit` and `--tail` keep them, for a function with no option of its own for them
1117
+ * (`fn CTM CL --limit 3`): the first or last n of each table, of a series' points the oldest or newest n, as every
1118
+ * command that prints a list keeps them; the notes say what was cut.
1119
+ */
1120
+ function windowHeadlessResult(shape: HeadlessPaneDefinition["shape"], result: HeadlessPaneResult, window: RowWindowOptions): HeadlessPaneResult {
1121
+ const notes: string[] = [];
1122
+ const cut = <Row,>(rows: readonly Row[], table?: string, dateOf?: (row: Row) => unknown): Row[] => {
1123
+ const kept = windowRows(rows, window, dateOf);
1124
+ const note = cutNote(window, kept, table);
1125
+ if (note) notes.push(note);
1126
+ return kept.rows;
1127
+ };
1128
+ const quiet = <Row,>(rows: readonly Row[] | undefined) => rows ? windowRows(rows, window).rows : undefined;
1129
+ let windowed: HeadlessPaneResult;
1130
+ switch (shape) {
1131
+ case "rows": {
1132
+ const rows = result as HeadlessRowsResult;
1133
+ windowed = { ...rows, rows: cut(rows.rows), ...(rows.textRows ? { textRows: quiet(rows.textRows)! } : {}) };
1134
+ break;
1135
+ }
1136
+ case "bundle": {
1137
+ const bundle = result as HeadlessBundleResult;
1138
+ const several = bundle.sections.filter((section) => section.rows).length > 1;
1139
+ windowed = { ...bundle, sections: bundle.sections.map((section) => !section.rows ? section : {
1140
+ ...section, rows: cut(section.rows, several ? section.title : undefined), ...(section.textRows ? { textRows: quiet(section.textRows)! } : {}),
1141
+ }) };
1142
+ break;
1143
+ }
1144
+ case "series": {
1145
+ const series = result as HeadlessSeriesResult;
1146
+ windowed = { ...series, series: series.series.map((entry) => ({
1147
+ ...entry, points: cut(entry.points, series.series.length > 1 ? entry.label : undefined, (point) => point.date),
1148
+ })) };
1149
+ break;
1150
+ }
1151
+ case "snapshot": {
1152
+ const snapshot = result as HeadlessSnapshotResult;
1153
+ windowed = { ...snapshot, items: cut(snapshot.items) };
1154
+ break;
1155
+ }
1156
+ default: {
1157
+ const _exhaustive: never = shape;
1158
+ return _exhaustive;
1159
+ }
1160
+ }
1161
+ return notes.length > 0 ? { ...windowed, notes: [...windowed.notes ?? [], ...notes] } : windowed;
1162
+ }
1163
+
1100
1164
  export async function buildHeadlessFunctionReport(
1101
1165
  resolved: ResolvedPaneFunction,
1102
1166
  context: MarketContext,
@@ -1105,6 +1169,7 @@ export async function buildHeadlessFunctionReport(
1105
1169
  let loaded: LoadedHeadlessPaneModel;
1106
1170
  try {
1107
1171
  loaded = await loadResolvedHeadlessPaneModel(resolved, context, rawArgument);
1172
+ if (resolved.rowWindow) loaded = { ...loaded, result: windowHeadlessResult(loaded.definition.shape, loaded.result, resolved.rowWindow) };
1108
1173
  } catch (error) {
1109
1174
  // A Pro pane the server refused reports what its wall covers, as its rendered view does.
1110
1175
  const locked = await lockedHeadlessReport(resolved, error, () => (
@@ -75,7 +75,7 @@ async function withPaneRuntime<T>(
75
75
  registry: PaneFunctionCatalog;
76
76
  resolved: ResolvedPaneFunction;
77
77
  }) => Promise<T>,
78
- settings: { strictHeadlessOptions?: boolean; tableSection?: boolean; command?: "fn" | "shot" } = {},
78
+ settings: { strictHeadlessOptions?: boolean; tableSection?: boolean; rowWindow?: boolean; command?: "fn" | "shot" } = {},
79
79
  ): Promise<T> {
80
80
  return withMarketData(ctx, async (market) => {
81
81
  const context: MarketContext = ctx.cliOptions.refresh ? { ...market, refresh: true } : market;
@@ -485,7 +485,7 @@ export async function runPaneFunction(args: string[], ctx: CliCommandContext) {
485
485
  }
486
486
  ctx.printResult(result, render);
487
487
  if (failure) process.exitCode = CLI_EXIT_CODES.error;
488
- }, { strictHeadlessOptions: true, tableSection: true });
488
+ }, { strictHeadlessOptions: true, tableSection: true, rowWindow: true });
489
489
  });
490
490
  }
491
491
 
@@ -67,6 +67,11 @@ export interface ParsedPaneFunctionArgs {
67
67
  * pair with no options of its own): an export still has a row for each, its reason in the status column.
68
68
  */
69
69
  refusedListings?: Array<{ symbol: string; reason: string }>;
70
+ /**
71
+ * The argument's words as the shell passed them, when one holds a space: it was quoted (`fn G "VOD LN"`), so
72
+ * its words are one entry, not several typed apart (`fn G AAPL MSFT`). `arg` joins them either way.
73
+ */
74
+ quotedWords?: string[];
70
75
  }
71
76
 
72
77
  export interface ParsedPaneCatalogArgs {
@@ -227,6 +232,7 @@ export function parsePaneFunctionArgs(
227
232
 
228
233
  const target = positionals[0]?.trim() ?? "";
229
234
  const arg = positionals.slice(1).join(" ").trim();
235
+ const quoted = positionals.slice(1).some((word) => /\s/.test(word.trim()));
230
236
  // The outer CLI parser consumes --limit and --tail before fn/shot sees its arguments.
231
237
  // Restore them for the pane's own schema and loader, including bounds checks,
232
238
  // so a function without a tail option says so instead of ignoring it.
@@ -239,6 +245,7 @@ export function parsePaneFunctionArgs(
239
245
  ...(explain ? { explain } : {}),
240
246
  ...(strict ? { strict } : {}),
241
247
  ...(shotOnly.length > 0 ? { shotOnly } : {}),
248
+ ...(quoted ? { quotedWords: positionals.slice(1) } : {}),
242
249
  };
243
250
  }
244
251