@gloom-sh/terminal 0.20.9 → 0.20.11

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 (212) hide show
  1. package/package.json +1 -1
  2. package/patches/@opentui%2Fcore@0.3.2.patch +16 -0
  3. package/src/api-client/auth.ts +6 -0
  4. package/src/api-client/data.ts +1 -0
  5. package/src/api-client/earnings.ts +15 -0
  6. package/src/api-client/index.ts +14 -3
  7. package/src/api-client/socket-connection.ts +355 -0
  8. package/src/api-client/socket-features.ts +75 -0
  9. package/src/api-client/socket-frames.ts +161 -0
  10. package/src/api-client/socket-listeners.ts +207 -0
  11. package/src/api-client/socket-quotes.ts +332 -0
  12. package/src/api-client/socket.ts +150 -983
  13. package/src/api-client/types/account.ts +10 -0
  14. package/src/api-client/types/billing.ts +10 -0
  15. package/src/api-client/types/econ.ts +19 -7
  16. package/src/api-client/types/market.ts +7 -0
  17. package/src/api-client/types/screener.ts +2 -0
  18. package/src/brokers/signed-in/adapter.ts +19 -5
  19. package/src/brokers/signed-in/client.ts +13 -1
  20. package/src/brokers/signed-in/sign-in-dialog.tsx +33 -9
  21. package/src/cli/commands/market.ts +18 -8
  22. package/src/cli/commands/overview.ts +26 -7
  23. package/src/cli/commands/ticker.ts +40 -15
  24. package/src/cli/desktop-pane-shot.ts +39 -0
  25. package/src/cli/errors.ts +20 -3
  26. package/src/cli/fx-pair.ts +11 -2
  27. package/src/cli/history-rows.ts +34 -3
  28. package/src/cli/index.ts +1 -1
  29. package/src/cli/listing-arg.ts +51 -13
  30. package/src/cli/pane-functions/headless.ts +4 -2
  31. package/src/cli/pane-functions/index.ts +1 -0
  32. package/src/cli/pane-functions/resolver.ts +2 -1
  33. package/src/cli/pane-functions/screenshot-assessment.ts +73 -5
  34. package/src/cli/pane-functions/screenshot-types.ts +4 -0
  35. package/src/components/chart/composite/chart-layout.ts +7 -4
  36. package/src/components/chart/composite/composite-chart.tsx +6 -16
  37. package/src/components/chart/composite/toolbar.tsx +258 -82
  38. package/src/components/chart/composite/use-composite-chart-keyboard.ts +5 -6
  39. package/src/components/chart/native/kitty/manager.ts +2 -0
  40. package/src/components/chart/native/surface/manager.ts +211 -11
  41. package/src/components/command-bar/list/model.ts +13 -0
  42. package/src/components/command-bar/panel/index.tsx +2 -13
  43. package/src/components/command-bar/panel/layout.ts +1 -7
  44. package/src/components/command-bar/panel/runtime.ts +0 -1
  45. package/src/components/command-bar/panel/types.ts +0 -2
  46. package/src/components/command-bar/routes/ticker-search/actions.ts +2 -0
  47. package/src/components/command-bar/routes/ticker-search/results.ts +15 -8
  48. package/src/components/command-bar/surface/index.tsx +10 -5
  49. package/src/components/command-bar/workflow/alert.ts +21 -7
  50. package/src/components/data-table/column-menu.tsx +89 -0
  51. package/src/components/data-table/sort-menu.tsx +9 -2
  52. package/src/components/data-table/table-pane.ts +3 -1
  53. package/src/components/data-table/view.tsx +33 -6
  54. package/src/components/form-modal/content.tsx +10 -0
  55. package/src/components/index.ts +1 -1
  56. package/src/components/layout/pane/footer/index.tsx +25 -11
  57. package/src/components/layout/pane/footer/model.ts +88 -21
  58. package/src/components/layout/pane/sidebar.tsx +125 -15
  59. package/src/components/layout/shell/active-drag.ts +18 -13
  60. package/src/components/layout/shell/drag/magnets.ts +34 -18
  61. package/src/components/metric-treemap/heat-surface.tsx +2 -1
  62. package/src/components/metric-treemap/index.tsx +3 -2
  63. package/src/components/ticker/list-table-view.tsx +5 -0
  64. package/src/components/ui/confirm-dialog.tsx +253 -7
  65. package/src/components/ui/data-table/column-order.ts +180 -0
  66. package/src/components/ui/data-table/index.tsx +13 -2
  67. package/src/components/ui/data-table/opentui/index.tsx +267 -23
  68. package/src/components/ui/data-table/opentui/model.ts +43 -4
  69. package/src/components/ui/data-table/types.ts +56 -0
  70. package/src/components/ui/data-table/use-column-order.ts +135 -0
  71. package/src/components/ui/index.ts +1 -1
  72. package/src/components/ui/list-view.tsx +4 -3
  73. package/src/components/ui/status.tsx +9 -6
  74. package/src/components/ui/table-layout.ts +120 -0
  75. package/src/docs/snapshot.json +39 -2
  76. package/src/i18n/es.ts +14 -0
  77. package/src/i18n/ja.ts +14 -0
  78. package/src/i18n/ko.ts +14 -0
  79. package/src/i18n/zh-cn.ts +14 -0
  80. package/src/i18n/zh-tw.ts +14 -0
  81. package/src/market-data/coordinator/index.ts +4 -3
  82. package/src/market-data/coordinator/quotes.ts +12 -4
  83. package/src/market-data/fx-closes.ts +14 -2
  84. package/src/market-data/market/change-basis.ts +35 -1
  85. package/src/market-data/market/status.ts +37 -0
  86. package/src/market-data/performance.ts +4 -1
  87. package/src/market-data/quotes/freshness.ts +12 -0
  88. package/src/market-data/quotes/live-valuation.ts +26 -3
  89. package/src/market-data/quotes/regular-session-valuation.ts +1 -1
  90. package/src/market-data/realized-volatility.ts +3 -0
  91. package/src/market-data/us-bond-market.ts +115 -0
  92. package/src/plugins/builtin/account-management/invite-row.tsx +54 -0
  93. package/src/plugins/builtin/account-management/keyboard.ts +3 -0
  94. package/src/plugins/builtin/account-management/model.ts +1 -0
  95. package/src/plugins/builtin/account-management/pane.tsx +51 -5
  96. package/src/plugins/builtin/account-management/trial-cancel.ts +32 -7
  97. package/src/plugins/builtin/broker-manager/detail.tsx +5 -3
  98. package/src/plugins/builtin/broker-manager/index.tsx +6 -6
  99. package/src/plugins/builtin/broker-manager/model.ts +15 -6
  100. package/src/plugins/builtin/broker-manager/pane-actions.tsx +11 -4
  101. package/src/plugins/builtin/broker-manager/sign-in-end.ts +50 -19
  102. package/src/plugins/builtin/broker-manager/table.ts +10 -4
  103. package/src/plugins/builtin/chat/sidebar.tsx +33 -16
  104. package/src/plugins/builtin/cloud/askg/pane-session.ts +94 -0
  105. package/src/plugins/builtin/cloud/askg/pane.tsx +40 -83
  106. package/src/plugins/builtin/cloud/askg/tool-timeline.tsx +2 -0
  107. package/src/plugins/builtin/congress-trades/pane.tsx +8 -2
  108. package/src/plugins/builtin/correlation/compute.ts +4 -3
  109. package/src/plugins/builtin/earnings/board-model.ts +33 -0
  110. package/src/plugins/builtin/earnings/board-table.ts +50 -11
  111. package/src/plugins/builtin/earnings/board.tsx +29 -13
  112. package/src/plugins/builtin/earnings/calendar.tsx +15 -3
  113. package/src/plugins/builtin/earnings/client.ts +4 -1
  114. package/src/plugins/builtin/earnings/headless.ts +27 -14
  115. package/src/plugins/builtin/econ/calendar-source.ts +3 -0
  116. package/src/plugins/builtin/equity-screener/live.ts +74 -18
  117. package/src/plugins/builtin/equity-screener/model.ts +19 -4
  118. package/src/plugins/builtin/equity-screener/pane.tsx +19 -14
  119. package/src/plugins/builtin/equity-screener/refresh-anchor.ts +45 -0
  120. package/src/plugins/builtin/equity-screener/results.ts +22 -2
  121. package/src/plugins/builtin/equity-screener/screen-check.ts +9 -3
  122. package/src/plugins/builtin/futures/index.tsx +15 -1
  123. package/src/plugins/builtin/futures/table.tsx +1 -1
  124. package/src/plugins/builtin/fx-matrix/index.tsx +2 -0
  125. package/src/plugins/builtin/help/index.tsx +1 -1
  126. package/src/plugins/builtin/holders/pane.tsx +30 -20
  127. package/src/plugins/builtin/ipo-calendar/model.ts +3 -3
  128. package/src/plugins/builtin/iv-history/events.ts +5 -0
  129. package/src/plugins/builtin/iv-history/headless.ts +19 -12
  130. package/src/plugins/builtin/kelly-sizer/sections.tsx +2 -0
  131. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  132. package/src/plugins/builtin/macro-day/model.ts +17 -4
  133. package/src/plugins/builtin/macro-day/releases.ts +36 -15
  134. package/src/plugins/builtin/market-halts/model.ts +3 -2
  135. package/src/plugins/builtin/market-movers/headless.ts +2 -1
  136. package/src/plugins/builtin/market-movers/index.tsx +3 -2
  137. package/src/plugins/builtin/market-movers/model.ts +75 -22
  138. package/src/plugins/builtin/market-movers/screener.ts +2 -1
  139. package/src/plugins/builtin/market-movers/table.ts +7 -5
  140. package/src/plugins/builtin/options/view.tsx +2 -0
  141. package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
  142. package/src/plugins/builtin/pe-band/model.ts +4 -0
  143. package/src/plugins/builtin/perps/cascade-tabs.tsx +2 -1
  144. package/src/plugins/builtin/portfolio-list/cell-version.ts +4 -4
  145. package/src/plugins/builtin/portfolio-list/cli/render.ts +9 -4
  146. package/src/plugins/builtin/portfolio-list/pane/index.tsx +15 -1
  147. package/src/plugins/builtin/portfolio-list/summary/index.tsx +24 -7
  148. package/src/plugins/builtin/portfolio-list/summary/totals.ts +40 -11
  149. package/src/plugins/builtin/portfolio-list/table.tsx +18 -1
  150. package/src/plugins/builtin/rate-path/pane.tsx +2 -0
  151. package/src/plugins/builtin/research/analyst-headless.ts +9 -1
  152. package/src/plugins/builtin/research/analyst-pane.tsx +10 -4
  153. package/src/plugins/builtin/research/client.ts +25 -1
  154. package/src/plugins/builtin/research/corporate-actions-pane.tsx +2 -1
  155. package/src/plugins/builtin/research/event-model.ts +3 -13
  156. package/src/plugins/builtin/research/event-sources.ts +3 -1
  157. package/src/plugins/builtin/revenue-breakdown/pane.tsx +2 -0
  158. package/src/plugins/builtin/reverse-dcf/pane.tsx +2 -1
  159. package/src/plugins/builtin/seasonality/pane.tsx +2 -1
  160. package/src/plugins/builtin/short-interest/headless.ts +2 -0
  161. package/src/plugins/builtin/short-interest/publications-headless.ts +2 -0
  162. package/src/plugins/builtin/short-interest/watch-headless.ts +1 -0
  163. package/src/plugins/builtin/thirteenf/pane.tsx +2 -0
  164. package/src/plugins/builtin/ticker-detail/financials/model.ts +28 -6
  165. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +26 -9
  166. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +58 -35
  167. package/src/plugins/builtin/vol-surface/heat-grid.tsx +2 -1
  168. package/src/plugins/builtin/vol-surface/pane.tsx +2 -1
  169. package/src/plugins/builtin/world-indices/index.tsx +5 -1
  170. package/src/plugins/builtin/yield-curve/headless.ts +5 -1
  171. package/src/plugins/builtin/yield-curve/index.tsx +7 -1
  172. package/src/portfolio/column-values.ts +47 -14
  173. package/src/portfolio/return-metrics.ts +4 -2
  174. package/src/renderers/dom/data-table/column-drag.ts +147 -0
  175. package/src/renderers/dom/data-table/index.tsx +22 -0
  176. package/src/renderers/dom/data-table/row.tsx +27 -5
  177. package/src/renderers/dom/host/image-surface.tsx +19 -9
  178. package/src/renderers/dom/host/input.tsx +4 -0
  179. package/src/renderers/dom/styles.css +22 -0
  180. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +23 -1
  181. package/src/renderers/opentui/chart-surface.tsx +1 -0
  182. package/src/renderers/opentui/frame-hits.ts +33 -0
  183. package/src/renderers/opentui/host.tsx +2 -0
  184. package/src/renderers/opentui/native-surface.ts +14 -21
  185. package/src/renderers/opentui/test-utils.tsx +3 -0
  186. package/src/sources/gloomberb-cloud/normalizers.ts +2 -0
  187. package/src/sources/provider-errors.ts +12 -0
  188. package/src/sources/provider-router/index.ts +12 -4
  189. package/src/state/app/context/index.tsx +22 -0
  190. package/src/state/pane-session.ts +145 -0
  191. package/src/test-support/app-store.ts +24 -1
  192. package/src/tickers/search/home-listing.ts +44 -1
  193. package/src/tickers/search/index.ts +5 -2
  194. package/src/tickers/search/ranking.ts +7 -7
  195. package/src/tickers/us-listing.ts +11 -5
  196. package/src/time-series/base-series.ts +7 -1
  197. package/src/time-series/fundamentals/current-valuation.ts +8 -0
  198. package/src/time-series/fundamentals/series.ts +6 -0
  199. package/src/time-series/live-quotes.ts +3 -9
  200. package/src/time-series/resolve.ts +1 -0
  201. package/src/types/financials.ts +20 -0
  202. package/src/types/headless.ts +9 -0
  203. package/src/ui/host.tsx +20 -0
  204. package/src/ui/pointer-drag.ts +11 -2
  205. package/src/utils/exchanges.ts +13 -8
  206. package/src/utils/fundamentals.ts +14 -3
  207. package/src/utils/price-earnings.ts +17 -10
  208. package/src/utils/price-history-integrity.ts +15 -0
  209. package/src/utils/reason-codes.ts +79 -0
  210. package/src/utils/share-multiples.cases.json +1667 -0
  211. package/src/utils/share-multiples.ts +384 -0
  212. package/src/utils/untrusted-text.ts +11 -0
@@ -8,7 +8,16 @@ import { logFailure } from "../../../utils/log-failure";
8
8
  import { fetchScreen } from "./client";
9
9
  import { appendScreenPage } from "./model";
10
10
 
11
- /** Query changes and pagination cannot exchange data across immutable snapshots. */
11
+ /** A refresh re-reads what a long list holds, up to this many rows, so it does not walk an endless one. */
12
+ const REFRESH_ROW_LIMIT = 1_000;
13
+
14
+ /**
15
+ * Query changes and pagination cannot exchange data across immutable snapshots.
16
+ * A refresh of a screen already loaded replaces its rows in place: the first
17
+ * page of the new snapshot, then as many more as the list held, swapped in
18
+ * together so the table keeps its length and its scroll position. A refresh
19
+ * that finds the same snapshot keeps the pages as they are.
20
+ */
12
21
  export function useScreenResults(
13
22
  definition: ScreenDefinition,
14
23
  sessionKey: string,
@@ -42,6 +51,7 @@ export function useScreenResults(
42
51
  moreController.current = null;
43
52
  const request = new AbortController();
44
53
  controller.current = request;
54
+ const held = stateRef.current.identity === identity ? stateRef.current.data : null;
45
55
  setState((current) => ({
46
56
  identity,
47
57
  data: current.identity === identity ? current.data : null,
@@ -51,8 +61,18 @@ export function useScreenResults(
51
61
  updatedAt: current.identity === identity ? current.updatedAt : null,
52
62
  }));
53
63
  try {
54
- const data = await fetcher(definition, null, request.signal);
64
+ let data = await fetcher(definition, null, request.signal);
55
65
  if (request.signal.aborted || activeIdentity.current !== identity) return;
66
+ if (held?.snapshot && data.snapshot?.id === held.snapshot.id) {
67
+ data = held;
68
+ } else if (held) {
69
+ const wanted = Math.min(held.rows.length, REFRESH_ROW_LIMIT);
70
+ while (data.nextCursor && data.rows.length < wanted) {
71
+ const page = await fetcher(definition, data.nextCursor, request.signal);
72
+ if (request.signal.aborted || activeIdentity.current !== identity) return;
73
+ data = appendScreenPage(data, page);
74
+ }
75
+ }
56
76
  setState({
57
77
  identity,
58
78
  data,
@@ -1,10 +1,16 @@
1
1
  import type { NumericField, ScreenCheckPayload, ScreenCriterion, ScreenDefinition } from "../../../api-client/equity-screener";
2
- import { canonicalExchange, parsePublicTickerKey } from "../../../utils/exchanges";
2
+ import { parseListingArg } from "../../../cli/listing-arg";
3
+ import { canonicalExchange } from "../../../utils/exchanges";
3
4
  import { criterionText, formatScreenValue, GRADE_DISPLAY_FIELDS, parseScreenDefinition, screenDefinitionKey, screenLabel } from "./model";
4
5
 
5
- /** One listing, with the same exchange aliases the rest of the app accepts. */
6
+ /**
7
+ * One listing, read as `quote` reads it before it asks: 700:HKEX, 700.HK and
8
+ * 00700.HK are 0700:HKEX, GARAN.IS is GARAN:BIST, "VOD LN" VOD:LSE. A bare
9
+ * symbol stays bare, for the screen to pick its listing.
10
+ */
6
11
  export function screenCheckTicker(text: string): { symbol: string; exchange?: string } {
7
- const ticker = parsePublicTickerKey(text.trim());
12
+ const listing = parseListingArg(text.trim(), null, { listingSuffix: true });
13
+ const ticker = listing.exchange ? { symbol: listing.symbol, exchange: listing.exchange } : { symbol: listing.symbol };
8
14
  if (!/^[A-Z0-9][A-Z0-9./-]{0,31}$/.test(ticker.symbol)
9
15
  || (ticker.exchange !== undefined && !/^[A-Z0-9_-]{1,24}$/.test(ticker.exchange)))
10
16
  throw new Error("Enter one ticker, such as NVDA or NVDA:NASDAQ.");
@@ -15,7 +15,7 @@ import {
15
15
  import { handleRefreshKey } from "../../../components/data-table/table-pane";
16
16
  import { useRemoteUiNode } from "../../../remote/semantic-tree";
17
17
  import { usePaneVisible } from "../../../state/app/activity";
18
- import { usePaneInstance, usePaneSettingValue } from "../../../state/app/context";
18
+ import { useOptionalPaneSettingUpdater, usePaneInstance, usePaneSettingValue } from "../../../state/app/context";
19
19
  import { TICKER_RESEARCH_PANE_ID } from "../../../types/config";
20
20
  import type { PaneProps } from "../../../types/plugin";
21
21
  import { isPlainKey } from "../../../utils/keyboard";
@@ -60,6 +60,7 @@ import {
60
60
  } from "./model";
61
61
  import {
62
62
  createFuturesColumns,
63
+ DEFAULT_FUTURES_COLUMN_IDS,
63
64
  FUTURES_COLUMN_DEFS,
64
65
  FUTURES_REPORT_COLUMNS,
65
66
  renderFuturesCell,
@@ -88,6 +89,7 @@ export function FuturesPane({ focused, width, height }: PaneProps) {
88
89
  const { pinTicker } = usePluginTickerActions();
89
90
  const dataProvider = useAssetData();
90
91
  const paneInstance = usePaneInstance();
92
+ const updateColumnIds = useOptionalPaneSettingUpdater(paneInstance?.instanceId ?? null, "columnIds");
91
93
  const liveStreaming = useLiveStreamingSetting();
92
94
  const [selectedId, setSelectedId] = useState<string | null>(null);
93
95
  const [sortPreference, setSortPreference] = useState<FuturesSortPreference>(DEFAULT_FUTURES_SORT);
@@ -154,6 +156,17 @@ export function FuturesPane({ focused, width, height }: PaneProps) {
154
156
  })), [columns, returns]);
155
157
  const titledColumns = useMemo(() => returnBases.size === 0 ? columns
156
158
  : columns.map((column) => returnBases.has(column.id) ? { ...column, title: returnBases.get(column.id) } : column), [columns, returnBases]);
159
+ // A header dragged to a new place rewrites the Columns setting; back in the default order, the setting goes, so
160
+ // columns later added to the defaults still show. The session mark and the symbol name the row and stay first.
161
+ const anchoredColumns = columns.findIndex((column) => column.id !== "status" && column.id !== "code");
162
+ const columnReorder = useMemo(() => ({
163
+ anchored: anchoredColumns > 0 ? anchoredColumns : undefined,
164
+ control: {
165
+ order: visibleColumnIds,
166
+ defaultOrder: DEFAULT_FUTURES_COLUMN_IDS,
167
+ onChange: (ids: string[] | undefined) => updateColumnIds(() => ids),
168
+ },
169
+ }), [anchoredColumns, updateColumnIds, visibleColumnIds]);
157
170
  useRemoteUiNode(returnBases.size > 0 ? {
158
171
  role: "report-notice",
159
172
  label: "Return base dates",
@@ -369,6 +382,7 @@ export function FuturesPane({ focused, width, height }: PaneProps) {
369
382
  rootWidth={width}
370
383
  rootHeight={height}
371
384
  columns={titledColumns}
385
+ columnReorder={columnReorder}
372
386
  items={dataProvider ? rows : []}
373
387
  sortable
374
388
  sortColumnId={sortPreference.columnId}
@@ -37,7 +37,7 @@ export const FUTURES_COLUMN_DEFS: readonly FuturesColumnDef[] = [
37
37
  { id: "time", label: "Time", description: "UTC time of the last quote." },
38
38
  ];
39
39
 
40
- const DEFAULT_FUTURES_COLUMN_IDS = FUTURES_COLUMN_DEFS.map((column) => column.id);
40
+ export const DEFAULT_FUTURES_COLUMN_IDS = FUTURES_COLUMN_DEFS.map((column) => column.id);
41
41
 
42
42
  /**
43
43
  * Extra columns only earn their width once the board is wide enough to keep a
@@ -405,6 +405,8 @@ function FxMatrixPane({ focused, width, height }: PaneProps) {
405
405
  resetScrollKey={amount ? storedFxBoardAmount(amount) : ""}
406
406
  // A pane too narrow for every currency scrolls to the rest, as other wide tables do; the row's code stays.
407
407
  columns={allColumns}
408
+ // Each column is a row's currency in the same order: the matrix reads across and down alike.
409
+ columnReorder={false}
408
410
  freezeFirstColumn
409
411
  getExportMetadata={() => createFxExportMetadata(currencies, rates,
410
412
  (currency) => rateEntries.get(currency))}
@@ -340,7 +340,7 @@ function HelpPane({ focused, width, height }: PaneProps) {
340
340
  ? keyEntry("panel-height", ["Shift+Up/Down"], "Make the top panel taller or shorter; Reset Panel Heights in the pane menu puts back the split.")
341
341
  : keyEntry("panel-height", ["Drag", "Shift+Up/Down"], tf("Drag the line between two panels to resize them, double-click it for the default split; {taller} and {shorter} resize the top panel.", { taller: keyLabel("Shift+Up"), shorter: keyLabel("Shift+Down") })),
342
342
  keyEntry("panel-max", ["Double-click"], "Double-click a panel to give it the whole chart, and again to show every panel."),
343
- keyEntry("tools-hide", ["Shift+T"], "Hide the drawing tools to a single button, or show them again."),
343
+ keyEntry("tools-hide", ["Shift+T"], "Keep the drawing tools open, or let them fold again to a single button showing the tool in hand that opens under the pointer."),
344
344
  keyEntry("legend-fold", ["Shift+L"], "Fold the legend to its first series and a count of the rest, or open it again."),
345
345
  ],
346
346
  },
@@ -19,7 +19,7 @@ import { useAsyncResource } from "../../../react/async-resource";
19
19
  import { useShortcut } from "../../../react/input";
20
20
  import { colors, priceColor } from "../../../theme/colors";
21
21
  import type { HolderData } from "../../../types/financials";
22
- import { clipToDisplayWidth, formatCompact } from "../../../utils/format";
22
+ import { clipToDisplayWidth, displayWidth, formatCompact } from "../../../utils/format";
23
23
  import { isPlainKey } from "../../../utils/keyboard";
24
24
  import { nextHeaderSort } from "../../../utils/sort-values";
25
25
  import { useAssetData, usePluginAppActions, usePluginPaneState } from "../../runtime";
@@ -66,6 +66,34 @@ function cikMatches(rows: readonly HolderRow[]): Map<string, Holder13FMatch> {
66
66
  /** The width of a three-letter badge ("13F", "ADR"): the label and its padding. */
67
67
  const BADGE_WIDTH = 5;
68
68
 
69
+ /**
70
+ * A holder's name and its markers. ADR: a position held as receipts on a home line's list. 13F: a fund
71
+ * whose filing opens on Enter or o. The name gives way first, so the markers survive a narrow column;
72
+ * the cell says how wide it draws whole (`contentWidth`), so the table fits the column to it.
73
+ */
74
+ export function holderNameCell(
75
+ name: string,
76
+ { receipts, fund }: { receipts: string; fund: boolean },
77
+ color: string,
78
+ width: number,
79
+ ): DataTableCell {
80
+ if (!receipts && !fund) return { text: name, color, attributes: TextAttributes.BOLD };
81
+ const badges = (receipts ? 1 : 0) + (fund ? 1 : 0);
82
+ return {
83
+ text: [name, receipts, fund ? "13F" : ""].filter(Boolean).join(" "),
84
+ contentWidth: displayWidth(name) + badges * (BADGE_WIDTH + 1),
85
+ content: (
86
+ <Box flexDirection="row" gap={1} width={width} overflow="hidden">
87
+ <Text fg={color} attributes={TextAttributes.BOLD}>
88
+ {clipToDisplayWidth(name, Math.max(1, width - badges * (BADGE_WIDTH + 1)))}
89
+ </Text>
90
+ {receipts ? <Badge label={receipts} /> : null}
91
+ {fund ? <Badge label="13F" tone="accent" /> : null}
92
+ </Box>
93
+ ),
94
+ };
95
+ }
96
+
69
97
  export function HoldersView({ focused, width, height }: { focused: boolean; width: number; height: number }) {
70
98
  const { nativePaneChrome } = useUiCapabilities();
71
99
  const { symbol, ticker, financials } = usePaneTicker();
@@ -286,25 +314,7 @@ export function HoldersView({ focused, width, height }: { focused: boolean; widt
286
314
  switch (column.id) {
287
315
  case "holder": {
288
316
  const color = rowState.selected ? colors.selectedText : colors.textBright;
289
- // ADR: a position held as receipts on a home line's list. 13F: a fund
290
- // whose filing opens on Enter or o.
291
- const receipts = holderShareBasisMarker(row);
292
- const fund = fundMatches.has(row.id);
293
- if (!receipts && !fund) return { text: row.name, color, attributes: TextAttributes.BOLD };
294
- const badges = (receipts ? 1 : 0) + (fund ? 1 : 0);
295
- // The name gives way first, so the markers survive a narrow column.
296
- return {
297
- text: [row.name, receipts, fund ? "13F" : ""].filter(Boolean).join(" "),
298
- content: (
299
- <Box flexDirection="row" gap={1} width={column.width} overflow="hidden">
300
- <Text fg={color} attributes={TextAttributes.BOLD}>
301
- {clipToDisplayWidth(row.name, Math.max(1, column.width - badges * (BADGE_WIDTH + 1)))}
302
- </Text>
303
- {receipts ? <Badge label={receipts} /> : null}
304
- {fund ? <Badge label="13F" tone="accent" /> : null}
305
- </Box>
306
- ),
307
- };
317
+ return holderNameCell(row.name, { receipts: holderShareBasisMarker(row), fund: fundMatches.has(row.id) }, color, column.width);
308
318
  }
309
319
  case "value":
310
320
  return { text: formatMoneyCompact(row.value, currency, { code: currencyCode }), color: colors.text };
@@ -334,9 +334,9 @@ const IPO_COLUMNS: readonly IpoColumn[] = [
334
334
  { id: "status", label: "STATUS", width: 9, align: "left" },
335
335
  // "HK$26.20-28.50".
336
336
  { id: "price", label: "PRICE", width: 14, align: "right" },
337
- // "$218.82M".
338
- { id: "size", label: "SIZE", width: 8, align: "right" },
339
- { id: "return", label: "RETURN", width: 8, align: "right" },
337
+ // "$218.82M". A deal's size comes with its terms and its return with its first day: an upcoming one has neither.
338
+ { id: "size", label: "SIZE", width: 8, align: "right", mayBeBlank: true },
339
+ { id: "return", label: "RETURN", width: 8, align: "right", mayBeBlank: true },
340
340
  ];
341
341
 
342
342
  /**
@@ -20,6 +20,10 @@ interface ReleaseOffsetRow {
20
20
  /** 25-delta put IV minus call IV, and the risk reversal, call minus put. */
21
21
  skew25d: number | null;
22
22
  rr25d: number | null;
23
+ /** What a policy decision did (held, raised 75bp) and the rate after it and before, where Gloom Cloud has them. */
24
+ decision: string | null;
25
+ actual: string | null;
26
+ prior: string | null;
23
27
  }
24
28
 
25
29
  export interface ReleaseOffsets {
@@ -132,6 +136,7 @@ export function releaseOffsetRows(
132
136
  iv30: iv30.get(date) ?? null, iv90: iv90.get(date) ?? null, iv365: iv365.get(date) ?? null,
133
137
  hv: hv.get(date) ?? null, spread: spread.get(date) ?? null,
134
138
  skew25d: skewValue, rr25d: skewValue == null ? null : -skewValue,
139
+ decision: release.figures?.decision ?? null, actual: release.figures?.actual ?? null, prior: release.figures?.prior ?? null,
135
140
  });
136
141
  }
137
142
  return result;
@@ -7,7 +7,7 @@ import { HV_WINDOWS, type HvWindow, type IvLookback, type IvStatRow, projectIvHi
7
7
  import { vcaUniverse } from "./universe";
8
8
  import { offsetText, releaseOffsetRows } from "./events";
9
9
  import { loadMacroReleases } from "../macro-day/client";
10
- import { MACRO_EVENT_LABELS, MACRO_RELEASE_SOURCES, staleMacroReleasesNotice, US_MACRO_EVENT_KINDS, type MacroRelease, type UsMacroEventKind,
10
+ import { IV_EVENT_KINDS, MACRO_EVENT_LABELS, MACRO_RELEASE_SOURCES, staleMacroReleasesNotice, type MacroEventKind, type MacroRelease,
11
11
  type MacroReleaseList } from "../macro-day/releases";
12
12
  import { lookupScheduledDates } from "../alerts/scheduled";
13
13
  import { fetchCpiBoard } from "../cpi/client";
@@ -37,17 +37,17 @@ export const ivHistoryHeadless: HeadlessPaneDefinition<"bundle"> = {
37
37
  options: [
38
38
  { key: "lookback", type: "enum", values: [{ value: "1Y" }, { value: "2Y" }, { value: "ALL" }], defaultValue: "1Y", description: "Visible history" },
39
39
  { key: "hvWindow", type: "enum", values: HV_WINDOWS.map((window) => ({ value: String(window) })), defaultValue: "20", description: "Realized volatility window in sessions" },
40
- { key: "event", type: "enum", aliases: ["release"], values: US_MACRO_EVENT_KINDS.map((value) => ({ value, ...value === "jobs" ? { aliases: ["nfp", "payrolls"] } : {} })),
41
- description: "One row per release of this kind whose session at --offset has closed (the next scheduled FOMC or CPI included), in place of the daily history",
40
+ { key: "event", type: "enum", aliases: ["release"], values: IV_EVENT_KINDS.map((value) => ({ value, ...value === "jobs" ? { aliases: ["nfp", "payrolls"] } : {} })),
41
+ description: "One row per release of this kind whose session at --offset has closed (the next scheduled FOMC, CPI or ECB decision included), in place of the daily history",
42
42
  example: "--event fomc --offset -6", shot: { reportOnly: "lists the readings around past release days" } },
43
43
  { key: "offset", type: "integer", minimum: -60, maximum: 60, defaultValue: 0,
44
44
  description: "Sessions from each release with --event: 0 is the first session on or after the release day, -6 the sixth session before that",
45
45
  example: "--event cpi --offset -1", shot: { reportOnly: "picks the session read around each release" } },
46
46
  ],
47
47
  async load(args, ctx) {
48
- const event = typeof args.options.event === "string" && args.options.event ? args.options.event as UsMacroEventKind : null;
48
+ const event = typeof args.options.event === "string" && args.options.event ? args.options.event as MacroEventKind : null;
49
49
  const offset = Number(args.options.offset) || 0;
50
- if (!event && offset !== 0) throw new Error("--offset counts sessions from a release day: add --event fomc, cpi or jobs.");
50
+ if (!event && offset !== 0) throw new Error("--offset counts sessions from a release day: add --event fomc, cpi, jobs or ecb.");
51
51
  const instrument = await resolveHeadlessInstrument(ctx, args.symbols[0]!);
52
52
  // What became of the symbol, as `quote` reads it, looked up beside the figures: FB's are the fund listed
53
53
  // there now, TWTR stopped trading, and HFC, which became DINO, has none of its own.
@@ -102,15 +102,20 @@ export const ivHistoryHeadless: HeadlessPaneDefinition<"bundle"> = {
102
102
  releases.upcomingNote,
103
103
  staleMacroReleasesNotice(releases.list),
104
104
  ].filter((note): note is string => !!note);
105
- const eventColumns = [{ key: "releaseDate", header: "Release date" }, { key: "session", header: "Session" },
105
+ // A policy decision's row says what it did (ECB raised 75bp to 0.75%), as MDAY's does; the export keeps the rate before too.
106
+ const decisionColumns = event === "fomc" || event === "ecb"
107
+ ? [{ key: "decision", header: "Decision" }, { key: "actual", header: "Actual" }, { key: "prior", header: "Prior" }] : [];
108
+ const eventColumns = [{ key: "releaseDate", header: "Release date" }, ...decisionColumns, { key: "session", header: "Session" },
106
109
  ...historyColumns.slice(1), ...skewColumns];
110
+ const decided = offsets.rows.some((row) => row.decision != null);
111
+ const textColumns = eventColumns.filter((column) => decided ? column.key !== "prior" : !decisionColumns.includes(column));
107
112
  return {
108
113
  sections: [{
109
114
  title: `${label} releases, ${offsetText(offset)}`,
110
115
  // The export names the release and the offset on every row, so files of several offsets or releases join.
111
116
  columns: [{ key: "release", header: "Release" }, eventColumns[0]!, { key: "offset", header: "Offset (sessions)" }, ...eventColumns.slice(1)],
112
117
  rows: offsets.rows.map(({ date, ...row }) => ({ ...row, session: date, release: label })),
113
- textColumns: offsets.rows.some((row) => row.skew25d != null) ? eventColumns : eventColumns.slice(0, -skewColumns.length),
118
+ textColumns: offsets.rows.some((row) => row.skew25d != null) ? textColumns : textColumns.slice(0, -skewColumns.length),
114
119
  }],
115
120
  complete: payload.status === "ready" && errors.length === 0,
116
121
  unavailableSymbols: offsets.rows.some((row) => row.iv30 != null) ? [] : [instrument.symbol], errors,
@@ -237,27 +242,29 @@ export const ivScreenHeadless: HeadlessPaneDefinition<"bundle"> = {
237
242
  * The releases of `event` HIVG reads around: the days MDAY studies (the list
238
243
  * the app ships with, extended by Gloom Cloud's), and the next one scheduled,
239
244
  * from the CPI board's release calendar or the FOMC meetings WIRP prices, as
240
- * scheduled alerts read them. Payrolls have no schedule to read.
245
+ * scheduled alerts read them, or the ECB's next decision as Gloom Cloud lists
246
+ * it with its decision days. Payrolls have no schedule to read.
241
247
  */
242
- async function eventReleases(event: UsMacroEventKind, ctx: HeadlessPaneContext): Promise<{
248
+ async function eventReleases(event: MacroEventKind, ctx: HeadlessPaneContext): Promise<{
243
249
  list: MacroReleaseList; upcoming: string | null; upcomingNote: string | null;
244
250
  }> {
245
251
  const label = MACRO_EVENT_LABELS[event];
246
252
  const [published, next] = await Promise.all([
247
253
  loadMacroReleases({}, () => ctx.apiClient.getCloudMacroReleaseDays()),
248
- event === "jobs" ? null : lookupScheduledDates([{ kind: "macro", event }], {
254
+ event !== "cpi" && event !== "fomc" ? null : lookupScheduledDates([{ kind: "macro", event }], {
249
255
  earnings: async () => [],
250
256
  cpi: () => fetchCpiBoard(ctx.apiClient),
251
257
  fomc: async () => (await fetchRatePath(ctx.apiClient)).meetings,
252
258
  }, zonedDateKey(Date.now(), "America/New_York")).then((dates) => dates.get(`macro:${event}`) ?? { date: null }),
253
259
  ]);
254
- const upcoming = next && "date" in next ? next.date : null;
260
+ const upcoming = event === "ecb" ? published.scheduled?.ecb ?? null : next && "date" in next ? next.date : null;
255
261
  const listed = upcoming != null && published.releases.some((release) => release.kind === event && release.date === upcoming);
256
262
  const releases: MacroRelease[] = upcoming && !listed ? [...published.releases, { kind: event, date: upcoming }] : published.releases;
257
263
  return {
258
264
  list: { ...published, releases },
259
265
  upcoming,
260
- upcomingNote: next == null ? `The next ${label} release is not scheduled here, so it has no row yet.`
266
+ upcomingNote: event === "ecb" ? upcoming ? null : `The next ${label} decision is not scheduled here, so it has no row yet.`
267
+ : next == null ? `The next ${label} release is not scheduled here, so it has no row yet.`
261
268
  : "error" in next ? `The next ${label} date could not be loaded (${next.error}), so it has no row.` : null,
262
269
  };
263
270
  }
@@ -204,6 +204,8 @@ export function KellySensitivitySection({
204
204
  return (
205
205
  <DataTableView<SensitivityRow>
206
206
  columns={columns}
207
+ // Prices or returns in order: a sensitivity grid's axis.
208
+ columnReorder={false}
207
209
  items={rows}
208
210
  getItemKey={(row) => row.id}
209
211
  selection={{ kind: "none" }}
@@ -5,7 +5,7 @@ import { fredSeriesArgument } from "../../../series/fred-argument";
5
5
  import { formatMacroDayMove, macroDayEventLabel, macroDayReleaseName, macroDayStats, macroFigureGapNotices, matchesSurprise, projectMacroDays, type MacroDayEvent,
6
6
  type MacroDayStats } from "./model";
7
7
  import { MACRO_EVENT_KINDS, MACRO_EVENT_LABELS, MACRO_RELEASE_SOURCES, MACRO_SURPRISE_LABELS, MACRO_SURPRISES, staleMacroReleasesNotice,
8
- type MacroEventKind, type MacroReleaseFigures, type MacroSurprise } from "./releases";
8
+ US_MACRO_EVENT_KINDS, type MacroEventKind, type MacroReleaseFigures, type MacroSurprise } from "./releases";
9
9
 
10
10
  // A mean that rounds to zero reads 0.00%, never -0.00%.
11
11
  const percent = (value: unknown) => typeof value !== "number" ? "--" : /[1-9]/.test((value * 100).toFixed(2)) ? `${(value * 100).toFixed(2)}%` : "0.00%";
@@ -15,6 +15,8 @@ const share = (value: unknown) => typeof value === "number" ? `${Math.round(valu
15
15
  export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
16
16
  shape: "bundle", argument: { kind: "ticker", description: "Ticker, or a FRED series such as FRED:T10Y2Y", examples: ["TLT", "FRED:T10Y2Y"] },
17
17
  usListingsOnly: "Macro release day data",
18
+ // Daily closes in the US session, which a line over the counter has as a listed one does.
19
+ usListingsOtc: true,
18
20
  // A spread the catalog prints (FRED:T10Y2Y) moves on release days too: its moves in bp.
19
21
  fredSeriesArgument: true,
20
22
  // Dated by the release list (releasesThrough) as much as by the closes, so no session schedule applies.
@@ -22,8 +24,9 @@ export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
22
24
  describe: (args) => `MDAY ${args.symbols[0] ?? ""}`,
23
25
  discovery: { screenshotReadiness: "live-dom", limitations: [
24
26
  "US listings, or a FRED series (FRED:T10Y2Y, whose moves in a rate or spread read in bp); close-to-close on the release day.",
25
- "Published CPI, jobs and FOMC days, and Brazil's IPCA days from Gloom Cloud; sessions after the list's last covered day (releasesThrough) are left out.",
26
- "Actual, forecast and prior for the days Gloom Cloud has them (the US headlines from its kept economic calendar, under either feed's title; an FOMC day's are the federal funds target range and whether it held or moved; IPCA from the central bank's SGS series); --surprise keeps the days that came in hot, cool or in line with the forecast.",
27
+ "Published CPI, jobs and FOMC days, and from Gloom Cloud Brazil's IPCA days and the ECB's decision days (every Governing Council monetary policy meeting); sessions after the list's last covered day (releasesThrough) are left out.",
28
+ "Actual, forecast and prior for the days Gloom Cloud has them (the US headlines from its kept economic calendar, under either feed's title; an FOMC day's are the federal funds target range and whether it held or moved, an ECB day's the deposit facility rate; IPCA from the central bank's SGS series); --surprise keeps the days that came in hot, cool or in line with the forecast.",
29
+ "A CPI day the calendar lists without its year-on-year actual takes one computed from the CPI index against a year earlier, labelled computed.",
27
30
  "A release day without figures says why: before the kept calendar starts, or listed without them.",
28
31
  "A release day that is also the reaction session of the company's own earnings report is marked earnings and left out of the release averages and the normal day.",
29
32
  ] },
@@ -63,13 +66,24 @@ export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
63
66
  // The days the filter keeps get a row of their own: how the name moved on hot CPI days.
64
67
  const selected = surprise === "all" ? [] : [row(`${MACRO_SURPRISE_LABELS[surprise]} ${release === "all" ? "release"
65
68
  : MACRO_EVENT_LABELS[release as MacroEventKind]}`, macroDayStats(events, model.normal.meanAbs))];
66
- // A day without figures says why: before the kept calendar (one note for them all), or the calendar's own gap.
69
+ // A day without figures says why: before the kept calendar (one note for them all), or the calendar's own gap. An ECB
70
+ // decision before it has its rates (Gloom Cloud reads them off the deposit rate series) and lacks only the forecast.
67
71
  const figuresFrom = releases.figuresFrom;
68
- const beforeCalendar = (event: MacroDayEvent) => !!figuresFrom && event.kind !== "ipca" && !event.figures && event.date < figuresFrom;
72
+ const predates = (event: MacroDayEvent) => !!figuresFrom && event.kind !== "ipca" && event.date < figuresFrom;
73
+ const beforeCalendar = (event: MacroDayEvent) => predates(event) && !event.figures;
74
+ const noForecast = (event: MacroDayEvent) => predates(event) && !!event.figures && event.figures.forecast == null;
75
+ /** "CPI and Jobs days": the kinds of the listed days `pick` takes, in the order the summary lists them. */
76
+ const daysOf = (pick: (event: MacroDayEvent) => boolean) => {
77
+ const labels = model.kinds.filter((kind) => events.some((event) => event.kind === kind && pick(event))).map((kind) => MACRO_EVENT_LABELS[kind]);
78
+ return `${labels.length > 1 ? `${labels.slice(0, -1).join(", ")} and ${labels.at(-1)}` : labels[0]} days`;
79
+ };
80
+ // A release Gloom Cloud alone lists (IPCA, the ECB) is summed up on its own: "Any release" is then the US ones'.
81
+ const usOnly = model.kinds.some((kind) => !US_MACRO_EVENT_KINDS.includes(kind as (typeof US_MACRO_EVENT_KINDS)[number]));
69
82
  const missing = (event: MacroDayEvent) => event.figures ? null : event.figuresMissing
70
83
  ?? (beforeCalendar(event) ? `before ${figuresFrom}, when Gloom Cloud's economic calendar starts` : null);
71
84
  const figureNotes = [
72
- ...(events.some(beforeCalendar) ? [`Release days before ${figuresFrom} have no actual, forecast or prior: Gloom Cloud's economic calendar starts then.`] : []),
85
+ ...(events.some(beforeCalendar) ? [`${daysOf(beforeCalendar)} before ${figuresFrom} have no actual, forecast or prior: Gloom Cloud's economic calendar starts then.`] : []),
86
+ ...(events.some(noForecast) ? [`Forecasts start ${figuresFrom}, with Gloom Cloud's economic calendar: ${daysOf(noForecast)} before it have an actual and prior, no forecast or surprise.`] : []),
73
87
  ...macroFigureGapNotices(events),
74
88
  ];
75
89
  return {
@@ -78,12 +92,15 @@ export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
78
92
  { key: "meanAbs", header: header("Avg |move|"), format: absMove }, { key: "multiple", header: "vs normal", format: multiple },
79
93
  { key: "mean", header: header("Avg move"), format: move }, { key: "hitRate", header: "Up", format: share }],
80
94
  rows: [...model.kinds.map((kind) => row(MACRO_EVENT_LABELS[kind], model.byKind[kind])), ...selected,
81
- row(model.kinds.includes("ipca") ? "Any US release" : "Any release", model.allEvents), ...(model.earnings.count ? [row("Earnings", model.earnings)] : []), row("Normal day", model.normal)] },
95
+ row(usOnly ? "Any US release" : "Any release", model.allEvents), ...(model.earnings.count ? [row("Earnings", model.earnings)] : []), row("Normal day", model.normal)] },
82
96
  { title: "Release days", columns: [{ key: "date", header: "Date" },
83
97
  // The text table reads the decision beside its release (FOMC held), as the pane does; exports keep the two apart.
84
98
  { key: "event", header: "Release", textFormat: (_value, row) => macroDayEventLabel({ kind: row.kind as MacroEventKind,
85
99
  earnings: row.earnings === true, figures: typeof row.decision === "string" ? { decision: row.decision } as MacroReleaseFigures : null }) },
86
- { key: "actual", header: "Actual" }, { key: "forecast", header: "Forecast" }, { key: "prior", header: "Prior" },
100
+ // A computed actual (a CPI's year-on-year change from the index) says so beside it; the export keeps the flag apart.
101
+ { key: "actual", header: "Actual", textFormat: (value, row) => typeof value !== "string" ? "-"
102
+ : row.actualComputed === true ? `${value} (computed)` : value },
103
+ { key: "forecast", header: "Forecast" }, { key: "prior", header: "Prior" },
87
104
  { key: "surprise", header: "Surprise" },
88
105
  { key: "session", header: "Session" }, { key: "move", header: header("Move"), format: move }, { key: "multiple", header: "vs normal", format: multiple }],
89
106
  rows: events.map((day) => {
@@ -92,6 +109,8 @@ export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
92
109
  return { ...event, event: macroDayReleaseName(day), actual: figures?.actual ?? null,
93
110
  forecast: figures?.forecast ?? null, prior: figures?.prior ?? null, surprise: figures?.surprise ?? null,
94
111
  ...(figures ? { headline: figures.event } : {}), ...(figures?.decision ? { decision: figures.decision } : {}),
112
+ ...(figures?.computed ? { actualComputed: true, actualBasis: figures.computed } : {}),
113
+ ...(figures?.actualMissing ? { actualMissing: figures.actualMissing } : {}),
95
114
  ...(why ? { figuresMissing: why } : {}) };
96
115
  }) },
97
116
  ],
@@ -3,6 +3,7 @@ import type { PricePoint } from "../../../types/financials";
3
3
  import { zonedDateTimeParts } from "../../../utils/zoned-date-time";
4
4
  import { toBasisPoints } from "../../../utils/basis-points";
5
5
  import { isYieldIndexSymbol } from "../../../tickers/index-roots";
6
+ import { pricePointCloseCopied } from "../../../utils/price-history-integrity";
6
7
  import { MACRO_EVENT_KINDS, MACRO_EVENT_LABELS, US_MACRO_EVENT_KINDS, type MacroEventKind, type MacroRelease, type MacroReleaseFigures,
7
8
  type MacroSurprise } from "./releases";
8
9
 
@@ -107,10 +108,18 @@ export const macroDayEventLabel = (event: Pick<MacroDayEvent, "kind" | "earnings
107
108
  export const macroDayReleaseName = (event: Pick<MacroDayEvent, "kind" | "earnings">) =>
108
109
  event.earnings ? `${MACRO_EVENT_LABELS[event.kind]} (earnings)` : MACRO_EVENT_LABELS[event.kind];
109
110
 
110
- /** One line for each release day the economic calendar covers that has no figures, saying why. */
111
+ /**
112
+ * One line for each release day the economic calendar covers that has no
113
+ * figures, or no actual, saying why, and for each whose actual is computed
114
+ * (a CPI's year-on-year change from the index), saying how.
115
+ */
111
116
  export const macroFigureGapNotices = (events: readonly Pick<MacroDayEvent, "kind" | "date" | "figures" | "figuresMissing">[]) =>
112
- events.filter((event) => !event.figures && event.figuresMissing)
113
- .map((event) => `${event.date} ${MACRO_EVENT_LABELS[event.kind]} has no figures: ${event.figuresMissing}.`);
117
+ events.flatMap((event) => {
118
+ const label = `${event.date} ${MACRO_EVENT_LABELS[event.kind]}`;
119
+ if (!event.figures) return event.figuresMissing ? [`${label} has no figures: ${event.figuresMissing}.`] : [];
120
+ if (event.figures.computed) return [`${label} actual is ${event.figures.computed}.`];
121
+ return event.figures.actualMissing ? [`${label} has no actual: ${event.figures.actualMissing}.`] : [];
122
+ });
114
123
 
115
124
  /** What a row adds to its release's name: a policy decision's move, and the earnings marker. */
116
125
  export const macroDayEventNote = (event: Pick<MacroDayEvent, "earnings" | "figures">) =>
@@ -191,17 +200,20 @@ export function projectMacroDays(history: readonly PricePoint[], options: {
191
200
  const { coveredThrough } = options;
192
201
  const basis = options.basis ?? macroDayMoveBasis(options.symbol);
193
202
  const byDate = new Map<string, number>();
203
+ // A pair's sessions whose close the source copied from the open, which nothing rebuilt: no move into or out of them is a day's.
204
+ const copied = new Set<string>();
194
205
  for (const point of history) {
195
206
  const time = new Date(point.date).getTime();
196
207
  // A yield can sit at zero or below it; a price cannot.
197
208
  if (!Number.isFinite(time) || !Number.isFinite(point.close) || (basis === "return" && point.close <= 0)) continue;
198
209
  byDate.set(sessionDate(time), point.close);
210
+ if (pricePointCloseCopied(point)) copied.add(sessionDate(time));
199
211
  }
200
212
  const sessions = [...byDate.keys()].sort();
201
213
  const last = sessions.at(-1) ?? null;
202
214
  const empty = (): MacroDayStats => stats([], null);
203
215
  const kinds = MACRO_EVENT_KINDS.filter((kind) => US_KINDS.has(kind) || options.releases.some((release) => release.kind === kind));
204
- if (!last) return { symbol: options.symbol, basis, events: [], kinds, byKind: { cpi: empty(), jobs: empty(), fomc: empty(), ipca: empty() },
216
+ if (!last) return { symbol: options.symbol, basis, events: [], kinds, byKind: { cpi: empty(), jobs: empty(), fomc: empty(), ipca: empty(), ecb: empty() },
205
217
  allEvents: empty(), earnings: empty(), normal: empty(), start: null, asOf: null };
206
218
 
207
219
  // Sessions after the published lists end may be unlisted release days, so they are left out of both sides.
@@ -217,6 +229,7 @@ export function projectMacroDays(history: readonly PricePoint[], options: {
217
229
  for (let index = 1; index < sessions.length; index++) {
218
230
  const date = sessions[index]!, previous = sessions[index - 1]!;
219
231
  if (date <= start || date > end || dayNumber(date) - dayNumber(previous) > MAX_SESSION_GAP_DAYS) continue;
232
+ if (copied.has(date) || copied.has(previous)) continue;
220
233
  moves.set(date, basis === "yield" ? byDate.get(date)! - byDate.get(previous)! : byDate.get(date)! / byDate.get(previous)! - 1);
221
234
  }
222
235