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
@@ -31,6 +31,24 @@ import {
31
31
  } from "../core/connection-health";
32
32
 
33
33
  const QUOTE_SUBSCRIPTION_FLUSH_MS = 25;
34
+ /** How long a connection may take to open before the attempt is dropped and tried again. */
35
+ export const SOCKET_CONNECT_TIMEOUT_MS = 10_000;
36
+ /**
37
+ * An open connection that has sent nothing for this long is asked whether it
38
+ * is still there: a `ping`, which the server answers with a `pong`.
39
+ */
40
+ export const SOCKET_QUIET_PING_MS = 10_000;
41
+ /**
42
+ * A connection that has not answered a ping in this long, nothing else come
43
+ * back meanwhile, is taken for dead (a half-open link: a laptop that slept, a
44
+ * network that changed under it). It is dropped and opened again; until then
45
+ * prices it streamed read as stale. Only an unanswered ping drops it: silence
46
+ * alone does not, since a check that runs late (a hidden tab's throttled
47
+ * timers, a wake from sleep) finds any connection silent.
48
+ */
49
+ export const SOCKET_PING_ANSWER_MS = 10_000;
50
+ /** How often an open connection's silence is checked; it never needs to be exact. */
51
+ const SOCKET_SILENCE_CHECK_MS = 2_500;
34
52
  /**
35
53
  * Protocol features this client can read. A server lists the ones it offers
36
54
  * in "ready"; the client opts into the shared ones, so an older server never
@@ -96,6 +114,8 @@ type CloudApiSocketDelegate = {
96
114
  clearWebSocketTokenForFallback: () => boolean;
97
115
  markCurrentUserUnverified: () => void;
98
116
  updateCurrentUserFromSocket: (user: Partial<AuthUser>) => void;
117
+ /** The service answered on this connection (it opened, or sent a frame); see `CloudApiRequestTransport.noteServiceAnswered`. */
118
+ onServiceAnswered?: () => void;
99
119
  };
100
120
 
101
121
  type ChatSendMessage = (
@@ -122,6 +142,13 @@ export class CloudApiSocket {
122
142
  private ws: WebSocket | null = null;
123
143
  private reconnectTimer: ReturnType<typeof setTimeout> | null = null;
124
144
  private reconnectDelayMs = 1000;
145
+ /** Gives up on a connection that has not opened in SOCKET_CONNECT_TIMEOUT_MS. */
146
+ private connectTimer: ReturnType<typeof setTimeout> | null = null;
147
+ /** Checks the open connection's silence (SOCKET_QUIET_PING_MS, SOCKET_PING_ANSWER_MS). */
148
+ private silenceTimer: ReturnType<typeof setInterval> | null = null;
149
+ /** When the open connection last sent anything, and when the ping still unanswered went out. */
150
+ private lastFrameAt = 0;
151
+ private pingedAt: number | null = null;
125
152
 
126
153
  private readonly channelListeners = new Map<string, Set<ChannelListener>>();
127
154
  private readonly chatMentionCandidatesListeners = new Set<() => void>();
@@ -196,6 +223,7 @@ export class CloudApiSocket {
196
223
  clearTimeout(this.reconnectTimer);
197
224
  this.reconnectTimer = null;
198
225
  }
226
+ this.stopWatching();
199
227
  const ws = this.ws;
200
228
  this.ws = null;
201
229
  if (ws) {
@@ -860,9 +888,16 @@ export class CloudApiSocket {
860
888
  return;
861
889
  }
862
890
  this.ws = ws;
891
+ // A link that swallows the handshake never says so: the attempt is dropped and tried again.
892
+ this.connectTimer = setTimeout(() => {
893
+ this.connectTimer = null;
894
+ if (this.ws === ws) this.dropUnansweredSocket(ws, "Connecting timed out");
895
+ }, SOCKET_CONNECT_TIMEOUT_MS);
863
896
 
864
897
  ws.onopen = () => {
865
898
  if (this.ws !== ws) return;
899
+ this.watchSilence();
900
+ this.delegate.onServiceAnswered?.();
866
901
  cloudApiLog.info("websocket open");
867
902
  this.health.reportSocketState(
868
903
  GLOOM_CLOUD_SOCKET_CONNECTION_ID,
@@ -878,6 +913,9 @@ export class CloudApiSocket {
878
913
 
879
914
  ws.onmessage = (event) => {
880
915
  if (this.ws !== ws) return;
916
+ this.lastFrameAt = Date.now();
917
+ this.pingedAt = null;
918
+ this.delegate.onServiceAnswered?.();
881
919
  void this.handleSocketMessage(String(event.data));
882
920
  };
883
921
 
@@ -885,6 +923,7 @@ export class CloudApiSocket {
885
923
  const activeSocket = this.ws === ws;
886
924
  if (this.ws === ws) {
887
925
  this.ws = null;
926
+ this.stopWatching();
888
927
  this.emitTapeStatus({ type: "disconnected", reason: "Stream disconnected; observed window may contain gaps" });
889
928
  }
890
929
  const closeEvent = event as CloseEvent | undefined;
@@ -927,6 +966,62 @@ export class CloudApiSocket {
927
966
  };
928
967
  }
929
968
 
969
+ /** From the open: the connection's silence is checked until it closes. */
970
+ private watchSilence(): void {
971
+ this.stopWatching();
972
+ this.lastFrameAt = Date.now();
973
+ this.pingedAt = null;
974
+ this.silenceTimer = setInterval(() => this.checkSilence(), SOCKET_SILENCE_CHECK_MS);
975
+ }
976
+
977
+ private stopWatching(): void {
978
+ if (this.connectTimer) clearTimeout(this.connectTimer);
979
+ if (this.silenceTimer) clearInterval(this.silenceTimer);
980
+ this.connectTimer = null;
981
+ this.silenceTimer = null;
982
+ }
983
+
984
+ /**
985
+ * A connection that went quiet is pinged; one that leaves the ping
986
+ * unanswered for SOCKET_PING_ANSWER_MS is half open, and is dropped and
987
+ * opened again. Anything it sends answers the ping.
988
+ */
989
+ private checkSilence(): void {
990
+ const ws = this.ws;
991
+ if (!ws || ws.readyState !== WebSocket.OPEN) return;
992
+ const now = Date.now();
993
+ if (this.pingedAt != null) {
994
+ if (now - this.pingedAt >= SOCKET_PING_ANSWER_MS) this.dropUnansweredSocket(ws, "No answer from the stream");
995
+ return;
996
+ }
997
+ if (now - this.lastFrameAt >= SOCKET_QUIET_PING_MS) {
998
+ this.pingedAt = now;
999
+ this.sendFrame({ type: "ping" });
1000
+ }
1001
+ }
1002
+
1003
+ /**
1004
+ * Gives up on a connection that never opened or went silent: what it was
1005
+ * carrying is reported as interrupted (the stream's health turns to error,
1006
+ * which marks its prices stale), and a new one is opened with the backoff.
1007
+ * Its close, if it ever comes, is for a socket no longer in use.
1008
+ */
1009
+ private dropUnansweredSocket(ws: WebSocket, reason: string): void {
1010
+ if (this.ws !== ws) return;
1011
+ this.ws = null;
1012
+ this.stopWatching();
1013
+ cloudApiLog.warn("websocket unanswered; reconnecting", { reason, quoteTargets: this.quoteTargets.size });
1014
+ try {
1015
+ ws.close();
1016
+ } catch {
1017
+ // Intentional ignore: a socket that cannot close is dropped all the same.
1018
+ }
1019
+ this.emitTapeStatus({ type: "disconnected", reason: "Stream disconnected; observed window may contain gaps" });
1020
+ this.emitConnection("closed");
1021
+ this.health.reportSocketState(GLOOM_CLOUD_SOCKET_CONNECTION_ID, "error", reason);
1022
+ this.scheduleReconnect();
1023
+ }
1024
+
930
1025
  /**
931
1026
  * A socket that could not be constructed is an error to show, not to throw:
932
1027
  * ensureSocket runs from effects and timers nobody awaits. The reconnect
@@ -85,7 +85,7 @@ export const KEYBINDING_ACTIONS: readonly KeybindingActionDef[] = [
85
85
  {
86
86
  id: "ticker-search",
87
87
  category: "Global Keys",
88
- description: "Open ticker search directly.",
88
+ description: "Change the focused pane's ticker.",
89
89
  // One chord on purpose: the command bar already searches symbols for
90
90
  // free text, so a layout without a backtick key still has Ctrl+P and
91
91
  // typing. A dedicated key is a rebind away for anyone who wants one.
@@ -185,7 +185,7 @@ export function useAppPaneRuntime({
185
185
  const dockedPaneIds = getDockedPaneIds(nextLayout);
186
186
 
187
187
  if (options?.placement === "floating" || (options?.placement !== "docked" && paneDef.defaultMode === "floating")) {
188
- nextLayout = addPaneFloating(nextLayout, instance, width, height, paneDef);
188
+ nextLayout = addPaneFloating(nextLayout, instance, width, height, paneDef, { focusedPaneId });
189
189
  } else if (relativeTo && findDockLeaf(nextLayout, relativeTo)) {
190
190
  nextLayout = addPaneToLayout(nextLayout, instance, { relativeTo, position: relativePosition });
191
191
  } else if (dockedPaneIds.length === 0) {
@@ -106,7 +106,7 @@ export function useAppTickerInspectorRuntime({
106
106
  const sourceDocked = findDockLeaf(state.config.layout, sourcePaneId);
107
107
  const layout = sourceDocked && paneDef.defaultMode !== "floating"
108
108
  ? addPaneToLayout(state.config.layout, instance, { relativeTo: sourcePaneId, position: "right" })
109
- : addPaneFloating(state.config.layout, instance, width, height, paneDef);
109
+ : addPaneFloating(state.config.layout, instance, width, height, paneDef, { focusedPaneId: sourcePaneId });
110
110
  return { layout, instance };
111
111
  }, [pluginRegistry, resolveInspectorPane, state.config.layout]);
112
112
 
@@ -173,7 +173,7 @@ export function useAppTickerOpenRuntime({
173
173
  const { width, height } = pluginRegistry.getTermSize();
174
174
  const shouldFloat = options?.floating ?? true;
175
175
  const nextLayout = shouldFloat
176
- ? addPaneFloating(currentLayout, instance, width, height, paneDef)
176
+ ? addPaneFloating(currentLayout, instance, width, height, paneDef, { focusedPaneId: currentState.focusedPaneId })
177
177
  : addPaneToLayout(
178
178
  currentLayout,
179
179
  instance,
@@ -5,6 +5,7 @@ import type { TickerRecord } from "../../types/ticker";
5
5
  import type { TickerOpenTarget } from "../../tickers/open-target";
6
6
  import { AmbiguousTickerError } from "../../tickers/search";
7
7
  import { isDialogOpen } from "../../ui/dialog-stack";
8
+ import { SECURITY_DESCRIPTION_SEARCH } from "../../core/state/app/command-bar-launch";
8
9
 
9
10
  /**
10
11
  * A resolved open joins the app's tickers: the store takes the record when it
@@ -24,8 +25,17 @@ export function publishTickerOpenTarget(target: TickerOpenTarget, { tickers, dis
24
25
  }
25
26
  }
26
27
 
27
- /** An open whose symbol names several listings offers them in ticker search, unless a dialog would sit over the bar. */
28
+ /**
29
+ * An open whose symbol names several listings offers them in ticker search, unless a dialog would
30
+ * sit over the bar. The pick opens the listing, as the open would have, rather than changing the
31
+ * focused pane's ticker.
32
+ */
28
33
  export function offerTickerListings(error: unknown, rawSymbol: string, dispatch: Dispatch<AppAction>): void {
29
34
  if (!(error instanceof AmbiguousTickerError) || isDialogOpen()) return;
30
- dispatch({ type: "SET_COMMAND_BAR", open: true, query: rawSymbol, launch: { kind: "ticker-search", query: rawSymbol } });
35
+ dispatch({
36
+ type: "SET_COMMAND_BAR",
37
+ open: true,
38
+ query: rawSymbol,
39
+ launch: { kind: "ticker-search", query: rawSymbol, payload: SECURITY_DESCRIPTION_SEARCH },
40
+ });
31
41
  }
@@ -1,4 +1,5 @@
1
1
  import type { CliCommandContext } from "../../types/plugin";
2
+ import { currencyNameStop } from "../currency-name-hint";
2
3
 
3
4
  export function takeOption(args: string[], name: string): string | undefined {
4
5
  const equalsPrefix = `${name}=`;
@@ -71,6 +72,9 @@ export function requireOneArg(
71
72
  ctx: CliCommandContext,
72
73
  ): string {
73
74
  const value = requireArg(args[0], `Usage: gloom ${usage}`, ctx);
75
+ // A currency's name in words (`ticker swiss franc`) is its pair, not two symbols.
76
+ const currency = noun === "symbol" && args.length > 1 ? currencyNameStop(args, usage.split(" ")[0]!) : null;
77
+ if (currency) ctx.fail(currency.message, currency.details);
74
78
  rejectExtraArgs(args, 1, { usage, takes: `one ${noun}`, advice: `Run it once per ${noun}.` }, ctx);
75
79
  return value;
76
80
  }
@@ -134,6 +134,7 @@ import {
134
134
  historyBarStatusNote,
135
135
  venueTradingDay,
136
136
  historyCoverageWarning,
137
+ historyExportUnit,
137
138
  historyFacts,
138
139
  historyFlagNote,
139
140
  historyWickNote,
@@ -155,7 +156,7 @@ import {
155
156
  quotedPriceDivisor,
156
157
  historyVolume,
157
158
  historyVolumeBasis,
158
- historyVolumeText,
159
+ historyVolumeNote,
159
160
  type HistoryRow,
160
161
  type HistoryUnit,
161
162
  type HistoryVolume,
@@ -250,11 +251,13 @@ import {
250
251
  meantQuestion,
251
252
  movedSymbolLine,
252
253
  ListingArgError,
254
+ isNoProviderError,
253
255
  requireCliListing,
254
256
  resolveCliListing,
255
257
  type CliListing,
256
258
  type ListingIdentity,
257
259
  } from "../listing-arg";
260
+ import { currencyNameMiss, currencyNameStop } from "../currency-name-hint";
258
261
  import { bareListingNote, listingFateNotes, noLongerTradingNote, SUCCESSOR_CHANGE_WAIT_MS, tradingListing } from "../../tickers/listing-fate";
259
262
  import { isYieldIndexSymbol } from "../../tickers/index-roots";
260
263
  import {
@@ -454,7 +457,7 @@ async function readListedSymbols(
454
457
  const QUOTE_CSV_SECTION = {
455
458
  title: "CSV",
456
459
  lines: [
457
- "Last, Chg%, Prev Close and each extended print are plain numbers, the currency in Cur and currency_or_unit. A pre-market, after-hours or overnight print's move is in Pre-Market Chg%, After Hours Chg% or Overnight Chg%, and compare's day range in Day Low and Day High, after the columns the export already had.",
460
+ "Last, Chg%, Prev Close and each extended print are plain numbers. Cur is the currency; currency_or_unit is the unit: the currency, a pair's quote currency per base (JPY per USD for USDJPY=X), index points or pct for a yield. A pre-market, after-hours or overnight print's move is in Pre-Market Chg%, After Hours Chg% or Overnight Chg%, and compare's day range in Day Low and Day High, after the columns the export already had.",
458
461
  "A row with no figure says why in its status column, never NaN; a symbol with no quote is also named on standard error.",
459
462
  ],
460
463
  };
@@ -594,6 +597,12 @@ const EXTENDED_CHANGE_EXPORT_COLUMNS = EXTENDED_SESSIONS.map((session) => ({
594
597
  * Why an exported quote row's figures are empty, for its status column: the
595
598
  * symbol's failure as the warning says it, or the figure it has no value for.
596
599
  */
600
+ /** A pair's rate unit for an export (`JPY per USD` for USDJPY=X) when its quote is in the counter currency; null otherwise. */
601
+ function pairExportUnit(symbol: string, currency: string): string | null {
602
+ const unit = historyUnit(symbol, { currency });
603
+ return unit.kind === "pair" && unit.currency === currency ? unit.unit : null;
604
+ }
605
+
597
606
  function quoteExportStatus(row: QuoteRow): string {
598
607
  if (row.rawPrice == null || !Number.isFinite(row.rawPrice)) return row.error || "Last: no price";
599
608
  if (row.changePercent == null || !Number.isFinite(row.changePercent)) return "Chg%: no previous close";
@@ -1008,6 +1017,9 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
1008
1017
  const listed = file != null || args.includes("-");
1009
1018
  const entries = normalizeSymbols(args);
1010
1019
  if (entries.length === 0 && !listed) ctx.fail(usage);
1020
+ // A currency's name in words (`quote japanese yen`) is its pair, not a symbol a word.
1021
+ const currency = exchange || listed ? null : currencyNameStop(args, commandName);
1022
+ if (currency) ctx.fail(currency.message, currency.details);
1011
1023
  // One quoted argument with spaces is a company's name, a pasted line of tickers, or a phrase to search for.
1012
1024
  const phrase = exchange || listed ? null : quotedPhrase(args);
1013
1025
 
@@ -1163,7 +1175,9 @@ async function runQuote(rawArgs: string[], ctx: Parameters<CliCommandDef["execut
1163
1175
  // An index row's Cur is blank, its level having no currency; the export names what it is in instead.
1164
1176
  exportIdentity: (row) => ({
1165
1177
  symbolOrSeries: row.symbol,
1166
- currencyOrUnit: row.currency || (row.yieldIndex ? "pct" : isIndexLevel(row.instrumentType) ? INDEX_POINTS_EXPORT_UNIT : null),
1178
+ // A pair's rate is its quote currency per base: JPY per USD, as `history` and `fx` export it.
1179
+ currencyOrUnit: (row.currency && pairExportUnit(row.symbol, row.currency))
1180
+ || row.currency || (row.yieldIndex ? "pct" : isIndexLevel(row.instrumentType) ? INDEX_POINTS_EXPORT_UNIT : null),
1167
1181
  }),
1168
1182
  // A row with no price or move says why in its status column, as the warnings do.
1169
1183
  exportStatus: quoteExportStatus,
@@ -1461,11 +1475,13 @@ async function loadListingHistory(
1461
1475
  const delayedTail = quote?.dataSource === "delayed" && !quote.delisting && (dayToDate || (intraday && sessionTrading));
1462
1476
  // The source that served the bars, a broker or another source when Gloom Cloud could not.
1463
1477
  const source = loaded.sourceName ? { source: loaded.sourceName } : {};
1478
+ // A coin's volume unit, or what an index's volume counts (a day's total, an intraday count).
1479
+ const volumeNote = historyVolumeNote(volume, interval, historyVolumeBasis(data));
1464
1480
  // A window that closed before today is the history asked for: no later bar makes it stale.
1465
1481
  const freshness = withSavedCopy(window && isPastPriceWindow(window) ? rowsFreshness(data, {
1466
1482
  ...source,
1467
1483
  status: "not-a-feed", basis: `${interval ? BAR_INTERVAL_LABELS[interval] : "price"} bars, ${priceWindowText(window)}`, observedKey: "date", oldest: null,
1468
- ...(volume ? { note: historyVolumeText(volume, interval, historyVolumeBasis(data)) } : {}),
1484
+ ...(volumeNote ? { note: volumeNote } : {}),
1469
1485
  }) : rowsFreshness(data, {
1470
1486
  ...source,
1471
1487
  ...barHistoryFreshness(intraday ? null : barResolutionFromDates(data.map((row) => row.date))),
@@ -1477,7 +1493,7 @@ async function loadListingHistory(
1477
1493
  ...(forming ? { periodToDate: forming.periodToDate } : closedDay ? { asOf: closedDay } : {}),
1478
1494
  ...(dayToDate ? { basis: "daily bars", ...(quote && Number.isFinite(quote.lastUpdated) ? { asOf: new Date(quote.lastUpdated).toISOString() } : {}) } : {}),
1479
1495
  ...(delayedTail ? { status: "delayed" as const, delayMinutes: CLOUD_QUOTE_DELAY_MINUTES } : {}),
1480
- ...(volume || dayToDate ? { note: [volume ? historyVolumeText(volume, interval, historyVolumeBasis(data)) : null, dayToDate ? `the newest bar is ${DAY_SO_FAR_TEXT}` : null].filter(Boolean).join("; ") } : {}),
1496
+ ...(volumeNote || dayToDate ? { note: [volumeNote, dayToDate ? `the newest bar is ${DAY_SO_FAR_TEXT}` : null].filter(Boolean).join("; ") } : {}),
1481
1497
  // The rows are drawn from the bars served, which say whether they are the saved copy.
1482
1498
  }), loaded);
1483
1499
  const gaps = historyGapNote(data, traded);
@@ -1602,16 +1618,26 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
1602
1618
  const window = historyWindowOption(args, rangeOption, ctx);
1603
1619
  const ask: HistoryAsk = { range: parseRange(rangeOption, ctx), window };
1604
1620
  const requestedExchange = takeOption(args, "--exchange");
1621
+ // One row a date and a close column a symbol, as a spreadsheet lays several series side by side.
1622
+ const wide = takeFlag(args, "--wide");
1605
1623
  // A list from a file or standard input (`-`), or several symbols typed (AAPL MSFT, AAPL,MSFT), is one long table.
1606
1624
  // One argument with spaces stays one, as before: it may be a company's name.
1607
1625
  const file = args.some((arg) => arg === "--file" || arg.startsWith("--file=")) ? takeOption(args, "--file") ?? "" : undefined;
1608
- if (file != null || args.includes("-") || uniqueEntries(args).length > 1 || args.some((arg) => /[,;]/.test(arg))) {
1609
- return runHistoryList(args, file, requestedExchange, ask, ctx);
1626
+ // `history swiss franc` is the franc's pair, not SWISS (a Copenhagen listing) and FRANC.
1627
+ const currency = file != null || requestedExchange ? null : currencyNameStop(args, "history");
1628
+ if (currency) ctx.fail(currency.message, currency.details);
1629
+ if (wide || file != null || args.includes("-") || uniqueEntries(args).length > 1 || args.some((arg) => /[,;]/.test(arg))) {
1630
+ return runHistoryList(args, file, requestedExchange, ask, ctx, { wide });
1610
1631
  }
1611
1632
  const raw = requireOneArg(args, HISTORY_USAGE, "symbol", ctx);
1612
1633
  await withMarketData(ctx, async (market) => {
1613
1634
  const listing = await requireCliListing(raw, requestedExchange, market, ctx);
1614
- const history = await loadListingHistory(listing, market, ctx, ask, { lookups: true });
1635
+ const history = await loadListingHistory(listing, market, ctx, ask, { lookups: true }).catch((error: unknown) => {
1636
+ // A word no source serves that names a currency (`history yen`) says which pair to ask for.
1637
+ const currency = !requestedExchange && isNoProviderError(error) ? currencyNameMiss(raw, "history") : null;
1638
+ if (currency) ctx.fail(currency.message, currency.details);
1639
+ throw error;
1640
+ });
1615
1641
  const { identity, unit, data, interval, intraday, volume, freshness, notes } = history;
1616
1642
  const price = historyPrice(history.decimals);
1617
1643
  // A bar without volume in a history that reports it prints as missing.
@@ -1655,7 +1681,8 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
1655
1681
  columns: historyExportColumns(data),
1656
1682
  exportStatus: historyExportStatus,
1657
1683
  // Every exported row says what it is a bar of, the currency a price is in and its bar size, so it survives head and concatenation.
1658
- exportIdentity: { symbolOrSeries: history.listing.key, currencyOrUnit: unit.currency ?? unit.unit, interval },
1684
+ // A pair's rate is in its quote currency per base: JPY per USD, as the JSON's unit and every other export say.
1685
+ exportIdentity: { symbolOrSeries: history.listing.key, currencyOrUnit: historyExportUnit(unit), interval },
1659
1686
  });
1660
1687
  });
1661
1688
  }
@@ -1663,6 +1690,44 @@ async function runHistory(rawArgs: string[], ctx: Parameters<CliCommandDef["exec
1663
1690
  /** A symbol of a list: its bars, or why it has none. */
1664
1691
  type ListedHistory = { symbol: string; history: ListingHistory } | { symbol: string; error: string };
1665
1692
 
1693
+ /**
1694
+ * `history USDJPY=X USDCHF=X EURCHF=X --wide`: one row a date and one close
1695
+ * column a symbol, its unit in the header (`USDJPY=X close (JPY per USD)`),
1696
+ * as a spreadsheet sets several series side by side. A symbol with no bar on
1697
+ * a date (another market's holiday) leaves its cell blank. `interval` is the
1698
+ * bars' size when every symbol came in one, else null.
1699
+ */
1700
+ function wideHistoryTable(served: readonly ListingHistory[]): {
1701
+ rows: Array<Record<string, string | number | null>>;
1702
+ columns: CliResultColumn[];
1703
+ interval: string | null;
1704
+ } {
1705
+ const histories = served.filter((history, index) => served.findIndex((other) => other.listing.key === history.listing.key) === index);
1706
+ const key = (history: ListingHistory) => `close:${history.listing.key}`;
1707
+ const dates = [...new Set(histories.flatMap((history) => history.data.map((row) => row.date)))].sort();
1708
+ const closes = histories.map((history) => new Map(history.data.map((row) => [row.date, row.close] as const)));
1709
+ const rows = dates.map((date) => Object.fromEntries([
1710
+ ["date", date],
1711
+ ...histories.map((history, index) => [key(history), closes[index]!.get(date) ?? null] as const),
1712
+ ]));
1713
+ const intervals = new Set(histories.map((history) => history.interval));
1714
+ return {
1715
+ rows,
1716
+ columns: [
1717
+ { key: "date", header: histories.some((history) => history.intraday) ? "Time" : "Date" },
1718
+ ...histories.map((history): CliResultColumn => {
1719
+ const unit = historyExportUnit(history.unit);
1720
+ const price = historyPrice(history.decimals);
1721
+ return {
1722
+ key: key(history), header: `${history.listing.key} close${unit ? ` (${unit})` : ""}`, align: "right",
1723
+ format: (value) => value == null ? "" : price(value),
1724
+ };
1725
+ }),
1726
+ ],
1727
+ interval: intervals.size === 1 ? [...intervals][0] ?? null : null,
1728
+ };
1729
+ }
1730
+
1666
1731
  /**
1667
1732
  * `history --file holdings.txt` (or several symbols, or `-` for standard
1668
1733
  * input): every symbol's bars in one long table, `HISTORY_LIST_CONCURRENCY`
@@ -1675,6 +1740,7 @@ async function runHistoryList(
1675
1740
  exchange: string | undefined,
1676
1741
  ask: HistoryAsk,
1677
1742
  ctx: Parameters<CliCommandDef["execute"]>[1],
1743
+ { wide = false }: { wide?: boolean } = {},
1678
1744
  ) {
1679
1745
  const usage = `Usage: gloom ${HISTORY_USAGE}`;
1680
1746
  await withMarketData(ctx, async (market) => {
@@ -1723,6 +1789,39 @@ async function runHistoryList(
1723
1789
  // reads it there): the list ends "couldn't refresh; saved copy from <time>" for the oldest copy among its symbols.
1724
1790
  const savedAt = served.flatMap((history) => history.freshness?.savedAt ?? []).sort()[0];
1725
1791
  const freshness = listFreshness && savedAt && !listFreshness.savedAt ? { ...listFreshness, savedAt } : listFreshness;
1792
+ const symbolsMetadata = listed.map((entry) => "history" in entry ? {
1793
+ ...listingMetadata(entry.history.identity),
1794
+ currency: entry.history.unit.currency,
1795
+ unit: entry.history.unit.unit,
1796
+ interval: entry.history.interval,
1797
+ firstDate: entry.history.data[0]?.date ?? null,
1798
+ lastDate: entry.history.data.at(-1)?.date ?? null,
1799
+ bars: entry.history.data.length,
1800
+ asOf: entry.history.freshness?.asOf ?? null,
1801
+ } : { symbol: entry.symbol, error: entry.error });
1802
+ if (wide) {
1803
+ const table = wideHistoryTable(served);
1804
+ ctx.printResult({
1805
+ data: table.rows,
1806
+ metadata: {
1807
+ range: ask.window ? null : ask.range,
1808
+ requestedRange: ask.window ? null : ask.range,
1809
+ ...(ask.window ? { requestedWindow: ask.window } : {}),
1810
+ symbols: symbolsMetadata,
1811
+ },
1812
+ ...(notes.length > 0 ? { warnings: notes } : {}),
1813
+ ...(served.length === 0 ? { failure: { code: "cli_error", message: `No history for ${symbols.join(", ")}.` } } : {}),
1814
+ freshness,
1815
+ ...(freshness ? {} : { exportFreshness: rowsFreshness([], { status: "not-a-feed", basis: "price bars" }) }),
1816
+ }, {
1817
+ dateKey: "date",
1818
+ columns: table.columns,
1819
+ // The unit is in each close column's header; a row of several symbols has no one symbol or unit to name.
1820
+ exportIdentity: { symbolOrSeries: null, currencyOrUnit: null, interval: table.interval },
1821
+ });
1822
+ if (served.length === 0) process.exitCode = CLI_EXIT_CODES.error;
1823
+ return;
1824
+ }
1726
1825
  const decimals = (row: Record<string, unknown>) => bySymbol.get(String(row.symbol))?.decimals ?? 2;
1727
1826
  const intraday = served.some((history) => history.intraday);
1728
1827
  const textColumns = historyTextColumns(intraday, (value, row) => historyPrice(decimals(row))(value)).map((column) => column.key !== "volume" ? column
@@ -1737,16 +1836,7 @@ async function runHistoryList(
1737
1836
  requestedRange: ask.window ? null : ask.range,
1738
1837
  ...(ask.window ? { requestedWindow: ask.window } : {}),
1739
1838
  // Each symbol as a single `history` describes it, or the reason it has no bars.
1740
- symbols: listed.map((entry) => "history" in entry ? {
1741
- ...listingMetadata(entry.history.identity),
1742
- currency: entry.history.unit.currency,
1743
- unit: entry.history.unit.unit,
1744
- interval: entry.history.interval,
1745
- firstDate: entry.history.data[0]?.date ?? null,
1746
- lastDate: entry.history.data.at(-1)?.date ?? null,
1747
- bars: entry.history.data.length,
1748
- asOf: entry.history.freshness?.asOf ?? null,
1749
- } : { symbol: entry.symbol, error: entry.error }),
1839
+ symbols: symbolsMetadata,
1750
1840
  },
1751
1841
  ...(notes.length > 0 ? { warnings: notes } : {}),
1752
1842
  ...(served.length === 0 ? { failure: { code: "cli_error", message: `No history for ${symbols.join(", ")}.` } } : {}),
@@ -1765,7 +1855,7 @@ async function runHistoryList(
1765
1855
  const history = bySymbol.get(String(row.symbol));
1766
1856
  return {
1767
1857
  symbolOrSeries: String(row.symbol),
1768
- currencyOrUnit: history ? history.unit.currency ?? history.unit.unit : null,
1858
+ currencyOrUnit: history ? historyExportUnit(history.unit) : null,
1769
1859
  interval: history?.interval ?? null,
1770
1860
  // A symbol with no bars has no as-of of its own.
1771
1861
  asOf: history ? history.freshness?.asOf ?? undefined : null,
@@ -3052,7 +3142,7 @@ async function runFxOnDate(
3052
3142
  warnings: warnings.length > 0 ? warnings : undefined,
3053
3143
  }, {
3054
3144
  text: () => amount == null ? describeFxRate(request, rate) : `${describeFxConversion(request, amount, rate)}\n${describeFxRate(request, rate)}`,
3055
- exportIdentity: { symbolOrSeries: pair, currencyOrUnit: baseCurrency, interval: "1day" },
3145
+ exportIdentity: { symbolOrSeries: pair, currencyOrUnit: `${baseCurrency} per ${currency}`, interval: "1day" },
3056
3146
  columns: [
3057
3147
  { key: "currency", header: "Currency" },
3058
3148
  { key: "baseCurrency", header: "Base" },
@@ -3180,7 +3270,7 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
3180
3270
  `${baseCurrency} rate: ${describeShortRate(quote.rate)}`,
3181
3271
  `Covered interest parity: ${formatFxRate(rate)} × ${growth(quote.rate)} / ${growth(base.rate)}; each rate earns simple interest over the ${tenor.days} days, standing in for a ${tenor.label} term rate.`,
3182
3272
  ].join("\n"),
3183
- exportIdentity: { symbolOrSeries: pair, currencyOrUnit: baseCurrency, interval: `forward ${tenor.label}` },
3273
+ exportIdentity: { symbolOrSeries: pair, currencyOrUnit: `${baseCurrency} per ${currency}`, interval: `forward ${tenor.label}` },
3184
3274
  columns: [
3185
3275
  { key: "pair", header: "Pair" },
3186
3276
  { key: "tenor", header: "Tenor" },
@@ -3216,8 +3306,8 @@ async function runFx(rawArgs: string[], ctx: Parameters<CliCommandDef["execute"]
3216
3306
  rateText,
3217
3307
  ...peso ? pesoDollarRateLines(peso) : [],
3218
3308
  ].join("\n"),
3219
- // The rate is the base currency's price of one unit of the other, at the latest quote of each leg.
3220
- exportIdentity: { symbolOrSeries: pair, currencyOrUnit: baseCurrency, interval: "spot" },
3309
+ // The rate is the base currency's price of one unit of the other, at the latest quote of each leg: USD per ZAR.
3310
+ exportIdentity: { symbolOrSeries: pair, currencyOrUnit: `${baseCurrency} per ${currency}`, interval: "spot" },
3221
3311
  columns: [
3222
3312
  { key: "currency", header: "Currency" },
3223
3313
  { key: "baseCurrency", header: "Base" },
@@ -3347,6 +3437,7 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
3347
3437
  { flags: "--from <year|date>, --start <year|date>", description: `${PRICE_WINDOW_FROM_HELP}. Up to five years come in daily bars, up to twenty weekly, longer monthly` },
3348
3438
  { flags: "--to <year|date>, --end <year|date>", description: PRICE_WINDOW_TO_HELP },
3349
3439
  { flags: "--file <path>", description: "Read the symbols from a text or CSV file, one per line (- reads standard input), and write every symbol's bars in one table" },
3440
+ { flags: "--wide", description: "One row per date and one close column per symbol, its unit in the header, in place of one long table" },
3350
3441
  EXCHANGE_OPTION,
3351
3442
  ],
3352
3443
  sections: [{
@@ -3360,14 +3451,15 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
3360
3451
  }, {
3361
3452
  title: "CSV",
3362
3453
  lines: [
3363
- "Every --csv has one header, whatever the symbol, range or market state: Date, Open, High, Low, Close, Volume, Flag, Partial, Filled, Unsettled, Volume unit, Volume note, Venue volume, Volume venue, Volume basis, status, then symbol_or_series, currency_or_unit, interval, source and as_of. Prices are plain numbers in the currency currency_or_unit names. Partial, Filled and Unsettled are true or false, and status says why a row has no prices.",
3454
+ "Every --csv has one header, whatever the symbol, range or market state: Date, Open, High, Low, Close, Volume, Flag, Partial, Filled, Unsettled, Volume unit, Volume note, Venue volume, Volume venue, Volume basis, status, then symbol_or_series, currency_or_unit, interval, source and as_of. Prices are plain numbers in the unit currency_or_unit names: the currency, a pair's quote currency per base (JPY per USD for USDJPY=X) or index points. Partial, Filled and Unsettled are true or false, and status says why a row has no prices.",
3364
3455
  "A continuous future whose bars name their contracts (NG=F) adds Contract, Roll and Thin before status: the contract per bar, and true or false for the bar it rolled at and a bar that traded far below those around it.",
3365
3456
  ],
3366
3457
  }, {
3367
3458
  title: "Several symbols",
3368
3459
  lines: [
3369
- `history AAPL MSFT 000660.KS, or --file with one symbol a line (- reads standard input), writes every symbol's bars in one long table, ${HISTORY_LIST_CONCURRENCY} symbols loading at once. Each row names its symbol, its currency and the as-of of that symbol's bars in symbol_or_series, currency_or_unit and as_of.`,
3460
+ `history AAPL MSFT 000660.KS, or --file with one symbol a line (- reads standard input), writes every symbol's bars in one long table, ${HISTORY_LIST_CONCURRENCY} symbols loading at once. Each row names its symbol, its unit and the as-of of that symbol's bars in symbol_or_series, currency_or_unit and as_of.`,
3370
3461
  "A symbol with no history is one row with its reason in status, and a warning names it; the command fails only when no symbol has any. --tail 5 keeps each symbol's newest five bars.",
3462
+ "--wide sets the symbols side by side instead: one row per date, one close column per symbol headed with its unit (USDJPY=X close (JPY per USD)), a blank where a symbol has no bar that day. history USDJPY=X USDCHF=X EURCHF=X --csv --wide is a spreadsheet of the three closes; --tail 5 keeps the newest five dates.",
3371
3463
  ],
3372
3464
  }, {
3373
3465
  title: "Long history",
@@ -3645,7 +3737,7 @@ export const marketDataCliCommands: BuiltinCliCommandDef[] = [
3645
3737
  }, {
3646
3738
  title: "Amounts",
3647
3739
  lines: [
3648
- "An amount in front converts it from the first currency to the second: fx 1234.5 EUR/USD, or fx 1234,5 EUR USD. It takes either decimal mark (1.234,5 and 1,234.5 are 1234.5) and reads as an amount of the first currency: 1,234 or 1.234 EUR are thousands, a third decimal being below a cent, while in a currency with three decimals (KWD) fx asks which. An amount and one currency converts to USD. The answer gives the converted amount, then the rate it used, dated by the source line; --json adds amount and converted.",
3740
+ "An amount in front converts it from the first currency to the second: fx 1234.5 EUR/USD, or fx 1234,5 EUR USD. It takes either decimal mark (1.234,5 and 1,234.5 are 1234.5) and reads as an amount of the first currency: 1.234 EUR is thousands, a third decimal being below a cent, while in a currency with three decimals (KWD) fx asks which. A comma before exactly three digits (fx 1,234 EUR) could be either, so fx asks which: type 1234 or 1.2340. An amount and one currency converts to USD. The answer gives the converted amount, then the rate it used, dated by the source line; --json adds amount and converted.",
3649
3741
  ],
3650
3742
  }, {
3651
3743
  title: "A past day",
@@ -541,7 +541,7 @@ export function buildSearchReport({
541
541
  if (bank) lines.push("", wrapToTerminal(centralBankLine(bank)));
542
542
  const setting = commandPointer(query);
543
543
  if (setting) lines.push("", wrapToTerminal(setting));
544
- const charted = renderSeriesMatches(query, series, SEARCH_SERIES_LIMIT, cliTerminalWidth() ?? 100, "catalog");
544
+ const charted = renderSeriesMatches(query, series, SEARCH_SERIES_LIMIT, cliTerminalWidth() ?? 100);
545
545
  // A query that names the data ("carbon", "day-ahead") lists its series first; words that happen to
546
546
  // be in a series name ("apple") list them after the tickers.
547
547
  const seriesFirst = series.some((match) => match.exact);
@@ -73,7 +73,7 @@ import {
73
73
  } from "../helpers";
74
74
  import { NotesFiles } from "../../plugins/builtin/notes/files";
75
75
  import { getFormDescription } from "../../plugins/builtin/sec/model";
76
- import { rowSummary, rowSummaryTarget } from "../../plugins/builtin/sec/row-summaries";
76
+ import { ownerNames, rowSummary, rowSummaryTarget } from "../../plugins/builtin/sec/row-summaries";
77
77
  import { isKnownNonUsListing, secFilingItemCodes, US_FUND_FACTS_ONLY } from "../../utils/sec";
78
78
  import { currentReportItemsLabel, hiddenFilingsNote, loadLatestFilings, type HiddenFilings } from "../../utils/sec-filings";
79
79
  import { canonicalExchange, exchangeLabel, isKnownExchangeCode, isUsListingExchange } from "../../utils/exchanges";
@@ -321,14 +321,18 @@ async function withFilingSummaries(
321
321
  dataProvider: { getSecFilingContent?(filing: SecFilingItem): Promise<string | null> },
322
322
  ): Promise<RecentFiling[]> {
323
323
  if (!dataProvider.getSecFilingContent) return [...filings];
324
- return Promise.all(filings.map(async (filing) => {
324
+ const contents = await Promise.all(filings.map(async (filing) => {
325
325
  const target = rowSummaryTarget(filing);
326
- if (!target) return filing;
327
- const content = await Promise.resolve().then(() => dataProvider.getSecFilingContent!(target))
326
+ if (!target) return null;
327
+ return Promise.resolve().then(() => dataProvider.getSecFilingContent!(target))
328
328
  .catch(logFailure("cli.commands-ticker", "Read an insider filing failed", null));
329
- const summary = rowSummary(filing.form, content)?.title;
330
- return summary ? { ...filing, summary } : filing;
331
329
  }));
330
+ // A Form 144 names its seller freely; the insider forms read beside it say which way round.
331
+ const knownOwners = filings.flatMap((filing, index) => ownerNames(filing.form, contents[index]));
332
+ return filings.map((filing, index) => {
333
+ const summary = rowSummary(filing.form, contents[index], knownOwners)?.title;
334
+ return summary ? { ...filing, summary } : filing;
335
+ });
332
336
  }
333
337
 
334
338
  /** What the form is: the filing's own description, else the form's meaning ("Insider Transaction"); none beside an 8-K's items. */