gloomberb 0.19.3 → 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 (226) hide show
  1. package/package.json +4 -2
  2. package/src/api-client/errors.ts +8 -0
  3. package/src/api-client/index.ts +18 -0
  4. package/src/api-client/request.ts +295 -42
  5. package/src/api-client/socket.ts +95 -0
  6. package/src/app/keybindings/actions.ts +1 -1
  7. package/src/app/pane-runtime/index.tsx +1 -1
  8. package/src/app/pane-runtime/ticker-inspector-runtime.ts +1 -1
  9. package/src/app/pane-runtime/ticker-open-runtime.ts +1 -1
  10. package/src/app/pane-runtime/ticker-open-target.ts +12 -2
  11. package/src/cli/commands/command-utils.ts +4 -0
  12. package/src/cli/commands/market.ts +119 -27
  13. package/src/cli/commands/search.ts +1 -1
  14. package/src/cli/commands/ticker.ts +10 -6
  15. package/src/cli/currency-name-hint.ts +60 -0
  16. package/src/cli/desktop-pane-shot-api-policy.ts +10 -2
  17. package/src/cli/desktop-pane-shot.ts +2 -1
  18. package/src/cli/history-rows.ts +18 -1
  19. package/src/cli/known-gaps.ts +17 -2
  20. package/src/cli/not-a-ticker.ts +5 -3
  21. package/src/cli/pane-functions/catalog.ts +9 -1
  22. package/src/cli/pane-functions/headless.ts +7 -3
  23. package/src/cli/pane-functions/market-session.ts +6 -7
  24. package/src/cli/series-search.ts +4 -5
  25. package/src/components/chart/composite/panel-bitmap.ts +28 -2
  26. package/src/components/chart/composite/time-axis.ts +17 -2
  27. package/src/components/command-bar/action-runtime.ts +2 -0
  28. package/src/components/command-bar/commands/direct/runtime.ts +3 -3
  29. package/src/components/command-bar/helpers.ts +2 -0
  30. package/src/components/command-bar/list/model.ts +9 -0
  31. package/src/components/command-bar/pane-actions.ts +46 -35
  32. package/src/components/command-bar/pane-templates/workflow.ts +6 -0
  33. package/src/components/command-bar/panel/index.tsx +30 -3
  34. package/src/components/command-bar/panel/types.ts +7 -0
  35. package/src/components/command-bar/routes/root/results.ts +4 -4
  36. package/src/components/command-bar/routes/root/selection.ts +3 -2
  37. package/src/components/command-bar/routes/ticker-search/actions.ts +21 -16
  38. package/src/components/command-bar/routing/launch-request.ts +3 -2
  39. package/src/components/command-bar/routing/list-state.ts +4 -1
  40. package/src/components/command-bar/surface/index.tsx +15 -1
  41. package/src/components/layout/floating-pane.tsx +10 -0
  42. package/src/components/layout/pane/frame.tsx +6 -0
  43. package/src/components/layout/pane/header.tsx +244 -42
  44. package/src/components/layout/pane/index.tsx +20 -2
  45. package/src/components/layout/shell/active-drag.ts +160 -28
  46. package/src/components/layout/shell/drag/index.ts +99 -96
  47. package/src/components/layout/shell/drag/live.ts +3 -17
  48. package/src/components/layout/shell/drag/magnets.ts +304 -0
  49. package/src/components/layout/shell/drag/overlays.tsx +77 -75
  50. package/src/components/layout/shell/drag/runtime.ts +12 -7
  51. package/src/components/layout/shell/index.tsx +66 -32
  52. package/src/components/layout/shell/native/pointer-runtime.ts +7 -2
  53. package/src/components/layout/shell/native/surfaces.ts +1 -9
  54. package/src/components/layout/shell/native/window-state.ts +21 -25
  55. package/src/components/layout/shell/pane/layers.tsx +153 -24
  56. package/src/components/layout/shell/shortcuts.ts +4 -1
  57. package/src/components/layout/shell/terminal-pointer-runtime.ts +24 -1
  58. package/src/components/layout/shell/window-mode/overlays.tsx +14 -6
  59. package/src/components/layout/status-bar.tsx +75 -6
  60. package/src/components/layout/window-controls.tsx +96 -35
  61. package/src/components/layout/window-fullscreen.ts +20 -0
  62. package/src/components/quote-flash.ts +36 -32
  63. package/src/core/app-runtime.ts +4 -1
  64. package/src/core/connection-health.ts +76 -1
  65. package/src/core/state/app/command-bar-launch.ts +12 -0
  66. package/src/core/state/app/layout.ts +4 -3
  67. package/src/core/state/app/types.ts +4 -1
  68. package/src/data/config/layout.ts +2 -2
  69. package/src/data/config/store/fold-panes.ts +6 -1
  70. package/src/i18n/es.ts +8 -1
  71. package/src/i18n/ja.ts +8 -1
  72. package/src/i18n/ko.ts +8 -1
  73. package/src/i18n/zh-cn.ts +8 -1
  74. package/src/i18n/zh-tw.ts +8 -1
  75. package/src/layout/pane-follow.ts +3 -2
  76. package/src/layout/pane-layout-move.ts +2 -1
  77. package/src/layout/pane-manager/dock-stack.ts +38 -0
  78. package/src/layout/pane-manager/dock-tree.ts +76 -15
  79. package/src/layout/pane-manager/docking.ts +48 -6
  80. package/src/layout/pane-manager/floating-actions.ts +12 -3
  81. package/src/layout/pane-manager/floating-placement.ts +189 -0
  82. package/src/layout/pane-manager/floating.ts +23 -4
  83. package/src/layout/pane-manager/gridlock.ts +16 -4
  84. package/src/layout/pane-manager/hidden-panes.ts +30 -1
  85. package/src/layout/pane-manager/index.ts +2 -0
  86. package/src/layout/pane-manager/layout-state.ts +17 -0
  87. package/src/layout/pane-manager/types.ts +4 -1
  88. package/src/layout/ticker-retarget.ts +88 -0
  89. package/src/layout-marketplace/cloud.ts +9 -1
  90. package/src/market-data/connection-follow.ts +68 -0
  91. package/src/market-data/coordinator/entries.ts +15 -3
  92. package/src/market-data/coordinator/events.ts +17 -1
  93. package/src/market-data/coordinator/financials.ts +20 -7
  94. package/src/market-data/coordinator/index.ts +217 -4
  95. package/src/market-data/coordinator/quotes.ts +10 -0
  96. package/src/market-data/frame-scheduler.ts +47 -10
  97. package/src/market-data/frame-wake.ts +74 -0
  98. package/src/market-data/futures-board.ts +7 -6
  99. package/src/market-data/hooks.tsx +43 -3
  100. package/src/market-data/performance.ts +78 -9
  101. package/src/market-data/request-types.ts +6 -3
  102. package/src/news/aggregator.ts +12 -1
  103. package/src/plugins/builtin/alerts/cli.ts +2 -1
  104. package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
  105. package/src/plugins/builtin/attention/evidence.ts +1 -1
  106. package/src/plugins/builtin/awards/client.ts +1 -1
  107. package/src/plugins/builtin/awards/evidence.ts +1 -1
  108. package/src/plugins/builtin/awards/pane.tsx +2 -1
  109. package/src/plugins/builtin/bond-calculator/math.ts +1 -1
  110. package/src/plugins/builtin/broker-manager/footer.ts +3 -2
  111. package/src/plugins/builtin/broker-manager/index.tsx +2 -1
  112. package/src/plugins/builtin/broker-manager/keyboard.ts +2 -1
  113. package/src/plugins/builtin/buildout/company/pane.tsx +2 -1
  114. package/src/plugins/builtin/buildout/model/index.ts +6 -0
  115. package/src/plugins/builtin/buildout/pane/index.tsx +2 -1
  116. package/src/plugins/builtin/catalysts/evidence.ts +1 -1
  117. package/src/plugins/builtin/catalysts/pane.tsx +2 -1
  118. package/src/plugins/builtin/chart-composer/headless.ts +40 -1
  119. package/src/plugins/builtin/chart-composer/index.tsx +13 -0
  120. package/src/plugins/builtin/chat/controller/index.ts +10 -3
  121. package/src/plugins/builtin/chat/controller/session-runtime.ts +9 -2
  122. package/src/plugins/builtin/chat/status-widget.tsx +3 -1
  123. package/src/plugins/builtin/cloud-tweets/table.tsx +3 -2
  124. package/src/plugins/builtin/comment-letters/client.ts +2 -1
  125. package/src/plugins/builtin/company-kpis/client.ts +1 -1
  126. package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
  127. package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
  128. package/src/plugins/builtin/cot/headless.ts +9 -3
  129. package/src/plugins/builtin/cot/model.ts +44 -3
  130. package/src/plugins/builtin/credit-documents/client.ts +1 -1
  131. package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
  132. package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
  133. package/src/plugins/builtin/earnings-calls/pane.tsx +1 -1
  134. package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
  135. package/src/plugins/builtin/econ/calendar-model.ts +2 -0
  136. package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
  137. package/src/plugins/builtin/econ/print-watch.ts +3 -1
  138. package/src/plugins/builtin/futures/series.ts +16 -1
  139. package/src/plugins/builtin/fx-matrix/headless.ts +4 -2
  140. package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
  141. package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
  142. package/src/plugins/builtin/gpu/headless.ts +2 -1
  143. package/src/plugins/builtin/help/function-card.tsx +2 -1
  144. package/src/plugins/builtin/help/index.tsx +3 -2
  145. package/src/plugins/builtin/insider/display.ts +45 -6
  146. package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
  147. package/src/plugins/builtin/iv-history/client.ts +2 -1
  148. package/src/plugins/builtin/iv-history/headless.ts +2 -1
  149. package/src/plugins/builtin/jobs/pages.ts +4 -4
  150. package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
  151. package/src/plugins/builtin/market-heatmap/index.tsx +2 -1
  152. package/src/plugins/builtin/members/client.ts +1 -1
  153. package/src/plugins/builtin/mna/distress/client.ts +1 -0
  154. package/src/plugins/builtin/mna/pane.tsx +4 -1
  155. package/src/plugins/builtin/options/market-reference.ts +1 -1
  156. package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
  157. package/src/plugins/builtin/options/view.tsx +2 -1
  158. package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
  159. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
  160. package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
  161. package/src/plugins/builtin/options-scenario/csp.ts +28 -9
  162. package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
  163. package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
  164. package/src/plugins/builtin/perps/client.ts +1 -1
  165. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
  166. package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
  167. package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
  168. package/src/plugins/builtin/research/analyst-model.ts +1 -0
  169. package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
  170. package/src/plugins/builtin/research/index.tsx +1 -0
  171. package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
  172. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
  173. package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
  174. package/src/plugins/builtin/research-search/snippet.ts +1 -0
  175. package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
  176. package/src/plugins/builtin/seasonality/headless.ts +2 -1
  177. package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
  178. package/src/plugins/builtin/sec/index.tsx +7 -4
  179. package/src/plugins/builtin/sec/row-summaries.ts +28 -12
  180. package/src/plugins/builtin/sectors/client.ts +18 -8
  181. package/src/plugins/builtin/sectors/index.tsx +19 -5
  182. package/src/plugins/builtin/short-interest/watch-client.ts +2 -1
  183. package/src/plugins/builtin/social-mentions/client.ts +2 -1
  184. package/src/plugins/builtin/supply-chain/client.ts +1 -1
  185. package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
  186. package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
  187. package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
  188. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
  189. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
  190. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
  191. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -1
  192. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +25 -2
  193. package/src/plugins/builtin/time-sales/client.ts +1 -0
  194. package/src/plugins/builtin/vol-surface/client.ts +2 -1
  195. package/src/plugins/builtin/yield-curve/headless.ts +3 -1
  196. package/src/portfolio/column-values.ts +76 -10
  197. package/src/react/async-resource.ts +12 -0
  198. package/src/remote/controller.ts +3 -1
  199. package/src/renderers/browser/app-services.ts +8 -1
  200. package/src/renderers/browser/cloud-transport.ts +6 -1
  201. package/src/renderers/cloudflare/worker.ts +24 -2
  202. package/src/renderers/dom/host/box.tsx +204 -176
  203. package/src/renderers/dom/host/style.ts +49 -20
  204. package/src/renderers/dom/host/text.tsx +3 -2
  205. package/src/renderers/dom/styles.css +32 -0
  206. package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
  207. package/src/renderers/electrobun/bun/desktop/host-requests.ts +25 -1
  208. package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
  209. package/src/renderers/electrobun/bun/desktop/windows-script.ts +9 -6
  210. package/src/renderers/electrobun/bun/window/windows-native.ts +26 -1
  211. package/src/renderers/electrobun/shared/protocol.ts +6 -0
  212. package/src/renderers/electrobun/view/ui-host.tsx +7 -0
  213. package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
  214. package/src/shares/portable-layout.ts +99 -2
  215. package/src/sources/provider-router/index.ts +9 -3
  216. package/src/sources/provider-router/sources.ts +26 -1
  217. package/src/sync/core-contributors.ts +18 -4
  218. package/src/time-series/price-units.ts +11 -0
  219. package/src/time-series/resolve.ts +12 -0
  220. package/src/types/config.ts +17 -1
  221. package/src/types/plugin.ts +6 -0
  222. package/src/ui/host.tsx +2 -0
  223. package/src/utils/currency-names.ts +20 -0
  224. package/src/utils/currency-pair.ts +6 -0
  225. package/src/utils/exchange-rate-snapshot.ts +20 -2
  226. package/src/utils/fx-market-hours.ts +43 -0
@@ -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
+ }
@@ -16,11 +16,14 @@ const AUTH_IN_FAMILY = /^\/cloud\/auth(?:\/|$)/;
16
16
  * session cut to its user, see `isShotSessionPath`), plan prices, the service
17
17
  * probe, the roadmap, the layout gallery (marketplace and team layouts),
18
18
  * theses, and a signed-in broker's catalog, connection status, holdings,
19
- * orders and fills.
19
+ * orders and fills. The Buildout plan is one: its answer is the plan and its
20
+ * prices, never the token `POST /account/buildout/token` mints, which stays
21
+ * refused, so the Buildout panes cannot be drawn with a plan's data.
20
22
  */
21
23
  const READ_PATHS = [
22
24
  /^\/auth\/get-session$/,
23
25
  /^\/account\/cloud$/,
26
+ /^\/account\/buildout$/,
24
27
  /^\/pricing$/,
25
28
  /^\/health$/,
26
29
  /^\/roadmap$/,
@@ -30,8 +33,13 @@ const READ_PATHS = [
30
33
  /^\/brokers\/connectors$/,
31
34
  /^\/brokers\/[a-z][a-z0-9-]{0,31}(?:\/(?:snapshot|orders|executions))?$/,
32
35
  ];
33
- /** Reads sent as a POST because their query is a list: batches, scans and analyses. */
36
+ /**
37
+ * Reads sent as a POST because their query is a list or a definition: batches,
38
+ * scans, analyses and the equity screen's query. Its saved-screen writes,
39
+ * ticker check and export are not here.
40
+ */
34
41
  const READ_POSTS = new Set([
42
+ "/cloud/equity-screener/query",
35
43
  "/cloud/exposure/analyze",
36
44
  "/cloud/perps/equities",
37
45
  "/market/financials/batch",
@@ -30,6 +30,7 @@ import {
30
30
  type ShotApiSocketCall,
31
31
  type ShotApiSocketReply,
32
32
  } from "./desktop-pane-shot-routes";
33
+ import { SHOT_REQUEST_REFUSED } from "../api-client/errors";
33
34
  import { SESSION_COOKIE_NAMES } from "../api-client/session-cookie";
34
35
  import { isShotApiRequestAllowed, isShotSessionPath } from "./desktop-pane-shot-api-policy";
35
36
  import { renderElectrobunViewHtml } from "../renderers/dom/build-assets";
@@ -472,7 +473,7 @@ async function proxyShotApiRequest(
472
473
  const basePath = baseUrl.pathname.replace(/\/+$/, "");
473
474
  let path = requestUrl.pathname.slice(SHOT_API_PROXY_PREFIX.length) || "/";
474
475
  let method = request.method.toUpperCase();
475
- if (!isShotApiRequestAllowed(method, path)) return shotApiError("The pane screenshot does not send this request.", 403);
476
+ if (!isShotApiRequestAllowed(method, path)) return shotApiError(SHOT_REQUEST_REFUSED, 403);
476
477
  const headers = new Headers();
477
478
  for (const name of SHOT_API_REQUEST_HEADERS) {
478
479
  const value = request.headers.get(name);
@@ -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)],
@@ -8,7 +8,7 @@ import {
8
8
  nextRegularSessionOpen,
9
9
  } from "../../market-data/market/freshness";
10
10
  import { futuresWeekendClosure } from "../../market-data/market/futures-week";
11
- import { currentFxClosureStart, isFxMarketOpen } from "../../utils/fx-market-hours";
11
+ import { currentFxClosureStart, isFxMarketOpen, isFxWeekClosePrint } from "../../utils/fx-market-hours";
12
12
  import { zonedDateKey } from "../../utils/zoned-date-time";
13
13
  import type { ReportTime } from "../../utils/utc-time";
14
14
  import type { QuoteIndexSession } from "../../types/financials";
@@ -118,7 +118,6 @@ function quotedSessions({ timeZone, current, regular }: QuoteIndexSession, now:
118
118
 
119
119
  /** The venue spot FX pairs trade on. It has no session calendar here; its week is in `fx-market-hours`. */
120
120
  const FX_VENUE = "CCY";
121
- const DAY_MS = 24 * 60 * 60_000;
122
121
 
123
122
  /**
124
123
  * The newest observation is its venue's latest close: the venue has not
@@ -128,13 +127,13 @@ const DAY_MS = 24 * 60 * 60_000;
128
127
  function closeDateOf(observation: SessionObservation, session: VenueSession, now: number): string | null {
129
128
  const time = observation.time;
130
129
  if (!time || time.dateOnly) return null;
131
- // FX closes once a week, Friday 17:00 New York time, and its trading day turns
132
- // at 17:00: a print from that last day, after Thursday's 17:00 close through
133
- // Friday's, is that Friday's close. A tick after it, over the weekend, is no
134
- // price of the week and keeps its own time.
130
+ // FX closes once a week, Friday 17:00 New York time: a print in its last
131
+ // minute is that Friday's close. An earlier print of the day (20:39Z) is no
132
+ // close, and a tick after it, over the weekend, is no price of the week:
133
+ // both keep their own time.
135
134
  const weekClose = canonicalExchange(observation.exchange) === FX_VENUE ? currentFxClosureStart(now) : null;
136
135
  if (weekClose != null) {
137
- return time.time > weekClose - DAY_MS && time.time <= weekClose ? zonedDateKey(weekClose - 1, "America/New_York") : null;
136
+ return isFxWeekClosePrint(time.time, weekClose) ? zonedDateKey(weekClose - 1, "America/New_York") : null;
138
137
  }
139
138
  if (session.last && session.timeZone) {
140
139
  if (session.last.open != null && time.time < session.last.open) return null;
@@ -82,27 +82,26 @@ function shellArgument(expression: string): string {
82
82
 
83
83
  /**
84
84
  * The series part of `catalog` or `search`: a table of the first `limit`
85
- * matches with the expression `fn G` charts, and how to see the rest.
85
+ * matches with the expression `fn G` charts, and how to see the rest:
86
+ * `catalog <words> --all`, which lists every one.
86
87
  */
87
88
  export function renderSeriesMatches(
88
89
  query: string,
89
90
  matches: readonly SeriesMatch[],
90
91
  limit: number,
91
92
  width: number,
92
- /** Where the rest are listed: `shot CAT` from the catalog, the catalog from a search. */
93
- rest: "catalog" | "data-catalog" = "data-catalog",
94
93
  ): string {
95
94
  if (matches.length === 0) return "";
96
95
  const shown = matches.slice(0, limit);
97
96
  const count = shown.length < matches.length ? `${shown.length} of ${matches.length}` : String(matches.length);
98
- const quoted = `"${query.replace(/"/g, "")}"`;
97
+ const words = query.replace(/"/g, "").trim();
99
98
  // A FRED series named by its id is also one `gloom fred` prints.
100
99
  const asked = query.trim().toUpperCase().replace(/^FRED:/, "");
101
100
  const fred = matches.find((match) => match.exact && fredSeriesIdOf(match.expression) === asked);
102
101
  const hint = fred
103
102
  ? `Print it with gloom fred ${asked}; chart it with gloom fn G ${fred.expression}.`
104
103
  : shown.length < matches.length
105
- ? `Chart one with gloom fn G <chart>; gloom ${rest === "catalog" ? `catalog ${quoted}` : `shot CAT ${quoted}`} lists all ${matches.length}.`
104
+ ? `Chart one with gloom fn G <chart>; gloom catalog ${shellArgument(words)} --all lists all ${matches.length}.`
106
105
  : "Chart one with gloom fn G <chart>.";
107
106
  return [
108
107
  `${renderSection(`Series for "${query}"`)} ${cliStyles.muted(`(${count})`)}`,
@@ -77,6 +77,13 @@ export function useCompositePanelBitmap({
77
77
  const desktopRenderedSizeRef = useRef<{ pixelWidth: number; pixelHeight: number } | null>(null);
78
78
  const desktopCancelRenderRef = useRef<(() => void) | null>(null);
79
79
  const desktopActiveRef = useRef(false);
80
+ /** What the current desktop bitmap was drawn from. */
81
+ const desktopDrawnRef = useRef<{
82
+ panel: CompositePanelScene;
83
+ pixelWidth: number;
84
+ pixelHeight: number;
85
+ colors: CompositeChartColors;
86
+ } | null>(null);
80
87
  const pixelWidth = bitmapSize?.pixelWidth ?? null;
81
88
  const pixelHeight = bitmapSize?.pixelHeight ?? null;
82
89
 
@@ -84,6 +91,18 @@ export function useCompositePanelBitmap({
84
91
  ? { panel, pixelWidth, pixelHeight, colors }
85
92
  : null;
86
93
 
94
+ // New data at the size and palette already drawn (a live quote moving the
95
+ // last bar) is drawn in this render. Drawn in the layout effect, its state
96
+ // update would render the panel a second time, a commit per tick; the paint
97
+ // is the same either way, since the effect also draws before it.
98
+ const drawn = desktopDrawnRef.current;
99
+ if (isDesktopWeb && desktopActiveRef.current && desktopBitmapRef.current && drawn && drawn.panel !== panel
100
+ && drawn.pixelWidth === pixelWidth && drawn.pixelHeight === pixelHeight && drawn.colors === colors
101
+ && desktopCancelRenderRef.current === null && !desktopUnpaintedRef.current && !revealed) {
102
+ desktopBitmapRef.current = renderPanelBitmap(panel, { pixelWidth, pixelHeight }, colors);
103
+ desktopDrawnRef.current = { panel, pixelWidth, pixelHeight, colors };
104
+ }
105
+
87
106
  // The cursor is drawn as a separate overlay, so the plot raster stays cached
88
107
  // (and resident in the terminal) while the crosshair moves.
89
108
  const terminalBitmap = useMemo(() => {
@@ -114,6 +133,7 @@ export function useCompositePanelBitmap({
114
133
  };
115
134
  desktopRenderedColorsRef.current = input.colors;
116
135
  desktopBitmapRef.current = next;
136
+ desktopDrawnRef.current = input;
117
137
  setDesktopBitmap(next);
118
138
  // A chart that fills its box when it opens takes its measured size
119
139
  // before its first paint, by the end of the frame after next. Later
@@ -140,6 +160,7 @@ export function useCompositePanelBitmap({
140
160
  desktopRequestedSizeRef.current = null;
141
161
  desktopRenderedSizeRef.current = null;
142
162
  desktopBitmapRef.current = null;
163
+ desktopDrawnRef.current = null;
143
164
  setDesktopBitmap((current) => current === null ? current : null);
144
165
  return;
145
166
  }
@@ -158,7 +179,11 @@ export function useCompositePanelBitmap({
158
179
 
159
180
  if (!desktopBitmapRef.current || sizeAlreadyRendered || desktopRenderedColorsRef.current !== colors || desktopUnpaintedRef.current || revealed) {
160
181
  cancelRender();
161
- render();
182
+ const current = desktopDrawnRef.current;
183
+ // The render drew this data already.
184
+ const drawnNow = !!desktopBitmapRef.current && current?.panel === panel && current.colors === colors
185
+ && current.pixelWidth === pixelWidth && current.pixelHeight === pixelHeight;
186
+ if (!drawnNow) render();
162
187
  return;
163
188
  }
164
189
 
@@ -176,5 +201,6 @@ export function useCompositePanelBitmap({
176
201
  }, []);
177
202
 
178
203
  if (!bitmapSize) return null;
179
- return isDesktopWeb ? desktopBitmap : terminalBitmap;
204
+ // The state only renders the panel again; the ref also holds what this render drew.
205
+ return isDesktopWeb ? desktopBitmapRef.current ?? desktopBitmap : terminalBitmap;
180
206
  }
@@ -492,6 +492,17 @@ function addCandidate(
492
492
  if (!duplicate) candidates.push(candidate);
493
493
  }
494
494
 
495
+ /**
496
+ * Blank cells a regular tick keeps from the start and end labels: half the
497
+ * room between two ticks, from 3 to 5 cells. Those two are the longest labels
498
+ * on the axis (a date with its year), and a tick closer than that reads as a
499
+ * part of one ("Oct Oct 29 2026") instead of a mark of its own.
500
+ */
501
+ function endpointLabelGap(interval: CompositeTimeAxisInterval, span: number, axisWidth: number): number {
502
+ const tickRoom = (axisWidth * interval.approximateMs) / span;
503
+ return clamp(Math.round(tickRoom / 2), 3, 5);
504
+ }
505
+
495
506
  function layoutTimeAxis({
496
507
  startTime,
497
508
  endTime,
@@ -641,6 +652,9 @@ function layoutTimeAxis({
641
652
  const minimumGap = interval.unit === "month" || interval.unit === "year" ? 2 : 1;
642
653
  let previousTimestamp = firstTimestamp;
643
654
  let previousEnd = startLabel.length - 1;
655
+ const endpointGap = endpointLabelGap(interval, span, axisWidth);
656
+ // The first tick follows the start label, the rest follow a tick.
657
+ let previousGap = endpointGap;
644
658
  for (const candidate of candidates.filter((entry) => !entry.boundary)) {
645
659
  const label = formatInteriorLabel(candidate.timestamp, previousTimestamp, interval, clock);
646
660
  // A year boundary inside the final year would repeat the right endpoint's year.
@@ -648,8 +662,8 @@ function layoutTimeAxis({
648
662
  const center = candidate.ratio * Math.max(axisWidth - 1, 0);
649
663
  const start = resolveLabelStart(center, label, axisWidth);
650
664
  const end = start + label.length - 1;
651
- if (start <= previousEnd + minimumGap) continue;
652
- if (end >= endStart - minimumGap) continue;
665
+ if (start <= previousEnd + previousGap) continue;
666
+ if (end >= endStart - endpointGap) continue;
653
667
  writeLabel(axis, start, label);
654
668
  placed.push({
655
669
  timestamp: candidate.timestamp,
@@ -660,6 +674,7 @@ function layoutTimeAxis({
660
674
  });
661
675
  previousTimestamp = candidate.timestamp;
662
676
  previousEnd = end;
677
+ previousGap = minimumGap;
663
678
  }
664
679
 
665
680
  writeLabel(axis, endStart, endLabel);
@@ -74,6 +74,7 @@ export function useCommandBarActionRuntime({
74
74
  tickers,
75
75
  }: UseCommandBarActionRuntimeOptions) {
76
76
  const {
77
+ changePaneTicker,
77
78
  duplicatePane,
78
79
  focusTicker,
79
80
  persistLayoutChange,
@@ -90,6 +91,7 @@ export function useCommandBarActionRuntime({
90
91
  readTickerSearchCache,
91
92
  writeTickerSearchCache,
92
93
  } = useCommandBarTickerSearchActions({
94
+ changePaneTicker,
93
95
  closeAll,
94
96
  dispatch,
95
97
  focusTicker,
@@ -14,7 +14,7 @@ import { normalizeTickerInput } from "../../../../tickers/search";
14
14
  import { useRendererHost } from "../../../../ui";
15
15
  import type { ThemePickerHandle } from "../../theme-picker";
16
16
  import type { Command } from "../registry";
17
- import type { CollectionCommandId } from "../../helpers";
17
+ import { SECURITY_DESCRIPTION_SEARCH, type CollectionCommandId } from "../../helpers";
18
18
  import {
19
19
  runDirectCommandAction,
20
20
  } from "./index";
@@ -93,7 +93,7 @@ export function useCommandBarDirectCommandRuntime({
93
93
  closeAll({ revertThemePreview: false });
94
94
  return;
95
95
  }
96
- openModeRoute("ticker-search", "");
96
+ openModeRoute("ticker-search", "", SECURITY_DESCRIPTION_SEARCH);
97
97
  return;
98
98
  }
99
99
 
@@ -113,7 +113,7 @@ export function useCommandBarDirectCommandRuntime({
113
113
  closeAll({ revertThemePreview: false });
114
114
  return;
115
115
  }
116
- openModeRoute("ticker-search", trimmed);
116
+ openModeRoute("ticker-search", trimmed, SECURITY_DESCRIPTION_SEARCH);
117
117
  }, [
118
118
  activeCollectionId,
119
119
  activeTickerSymbol,
@@ -15,6 +15,8 @@ export {
15
15
  export type RouteCommandId = "security-description" | "layout";
16
16
  export type CollectionCommandId = "add-watchlist" | "add-portfolio" | "remove-watchlist" | "remove-portfolio";
17
17
 
18
+ export { SECURITY_DESCRIPTION_SEARCH } from "../../core/state/app/command-bar-launch";
19
+
18
20
  export function isRouteCommandId(commandId: string): commandId is RouteCommandId {
19
21
  return commandId === "security-description"
20
22
  || commandId === "layout";
@@ -40,6 +40,12 @@ export interface ResultItem {
40
40
  listing?: TickerListingRef;
41
41
  /** Materialize this exact listing when another command consumes the row. */
42
42
  resolveTicker?: () => Promise<TickerRecord>;
43
+ /**
44
+ * A ticker row's three choices: `des` opens it as DES does (the row's `action`), `new` in a
45
+ * new research pane (its `secondaryAction`), and `pane` changes the focused pane's ticker, as
46
+ * ticker search's Enter does.
47
+ */
48
+ pickTicker?: (how: TickerPick) => void;
43
49
  /**
44
50
  * What the pane this row opens will load, so the bar can warm it while the
45
51
  * row is the pick. Unset when only opening can tell (a broker contract, a
@@ -73,6 +79,9 @@ export interface ResultItem {
73
79
  action: () => void | Promise<void>;
74
80
  }
75
81
 
82
+ /** What choosing a ticker row does; see `ResultItem.pickTicker`. */
83
+ export type TickerPick = "des" | "pane" | "new";
84
+
76
85
  /** A row plain Enter can run, so the untouched selection may rest on it. */
77
86
  export function isDefaultSelectable(item: ResultItem): boolean {
78
87
  return item.disabled !== true && item.defaultSelectable !== false;