@gloom-sh/terminal 0.20.22 → 0.20.23

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 (195) hide show
  1. package/package.json +1 -1
  2. package/src/account/heard-from-question.tsx +6 -4
  3. package/src/account/heard-from.ts +3 -4
  4. package/src/api-client/exchange-announcements.ts +2 -2
  5. package/src/api-client/heard-from.ts +5 -7
  6. package/src/api-client/ownership-disclosures.ts +38 -5
  7. package/src/api-client/types/ticker-data.ts +3 -1
  8. package/src/architecture/dom-cell-metrics-allowlist.json +2 -2
  9. package/src/cli/commands/market.ts +5 -3
  10. package/src/cli/commands/overview.ts +7 -9
  11. package/src/cli/listing-arg.ts +45 -18
  12. package/src/cli/pane-functions/catalog-snapshot.json +2 -2
  13. package/src/cli/pane-functions/data.ts +3 -1
  14. package/src/cli/pane-functions/freshness.ts +6 -1
  15. package/src/cli/pane-functions/function-help.ts +0 -2
  16. package/src/cli/pane-functions/market-session.ts +12 -2
  17. package/src/cli/pane-functions/screenshot-payload.ts +3 -1
  18. package/src/cli/symbol-list.ts +52 -14
  19. package/src/cli/ticker-resolution.ts +133 -38
  20. package/src/components/chart/composite/composite-chart.tsx +12 -0
  21. package/src/components/chart/composite/types.ts +18 -0
  22. package/src/components/chart/composite/use-composite-chart-keyboard.ts +38 -15
  23. package/src/components/chart-table/header.tsx +11 -5
  24. package/src/components/chart-table/selection.ts +20 -1
  25. package/src/components/data-table/view.tsx +2 -0
  26. package/src/components/feed-data-table/stack-view.tsx +85 -5
  27. package/src/components/layout/pane/header.tsx +12 -30
  28. package/src/components/ticker/badge/index.tsx +9 -4
  29. package/src/components/ticker/badge/list.tsx +3 -1
  30. package/src/components/ui/data-table/index.tsx +7 -1
  31. package/src/components/ui/data-table/muted-row.tsx +47 -0
  32. package/src/components/ui/data-table/opentui/index.tsx +42 -11
  33. package/src/components/ui/data-table/spill.ts +36 -0
  34. package/src/components/ui/data-table/types.ts +17 -1
  35. package/src/components/ui/data-table/use-column-order.ts +11 -0
  36. package/src/components/ui/icon.tsx +50 -3
  37. package/src/components/ui/list-view.tsx +2 -2
  38. package/src/components/ui/table-layout.ts +32 -0
  39. package/src/components/ui/terminal-hover-label.tsx +49 -0
  40. package/src/components/use-pinned-moment.ts +222 -13
  41. package/src/core/state/app/state.ts +11 -2
  42. package/src/core/state/app/types.ts +2 -1
  43. package/src/data/sqlite/access.ts +14 -1
  44. package/src/data/sqlite/checkpointer.ts +2 -2
  45. package/src/data/sqlite/database.ts +4 -0
  46. package/src/docs/snapshot.json +180 -26
  47. package/src/i18n/es.ts +1 -0
  48. package/src/i18n/ja.ts +1 -0
  49. package/src/i18n/ko.ts +1 -0
  50. package/src/i18n/zh-cn.ts +1 -0
  51. package/src/i18n/zh-tw.ts +1 -0
  52. package/src/market-data/market/freshness.ts +2 -2
  53. package/src/market-data/market/globex-day.ts +14 -0
  54. package/src/market-data/published-us-sessions.ts +3 -2
  55. package/src/market-data/quotes/live-valuation.ts +4 -2
  56. package/src/market-data/quotes/metadata.ts +48 -5
  57. package/src/market-data/quotes/regular-session-valuation.ts +12 -1
  58. package/src/plugins/builtin/alerts/history-pane.tsx +19 -3
  59. package/src/plugins/builtin/broker-trading/orders.tsx +4 -2
  60. package/src/plugins/builtin/chat/attachments/desktop.tsx +46 -12
  61. package/src/plugins/builtin/chat/channels.ts +5 -2
  62. package/src/plugins/builtin/chat/content/composer-runtime.ts +64 -65
  63. package/src/plugins/builtin/chat/content/footer.tsx +17 -7
  64. package/src/plugins/builtin/chat/content/index.tsx +108 -36
  65. package/src/plugins/builtin/chat/content/new-dm-dialog.tsx +21 -8
  66. package/src/plugins/builtin/chat/content/selection-runtime.ts +16 -0
  67. package/src/plugins/builtin/chat/content/shortcuts.ts +3 -0
  68. package/src/plugins/builtin/chat/content/snapshot.ts +37 -13
  69. package/src/plugins/builtin/chat/content/transcript.tsx +12 -0
  70. package/src/plugins/builtin/chat/content/types.ts +2 -0
  71. package/src/plugins/builtin/chat/controller/channels.ts +15 -15
  72. package/src/plugins/builtin/chat/controller/index.ts +140 -34
  73. package/src/plugins/builtin/chat/controller/lifecycle.ts +8 -12
  74. package/src/plugins/builtin/chat/controller/persistence.ts +32 -4
  75. package/src/plugins/builtin/chat/controller/send.ts +41 -17
  76. package/src/plugins/builtin/chat/controller/session-runtime.ts +28 -27
  77. package/src/plugins/builtin/chat/controller/state.ts +17 -8
  78. package/src/plugins/builtin/chat/controller/storage.ts +41 -4
  79. package/src/plugins/builtin/chat/controller/view.ts +6 -3
  80. package/src/plugins/builtin/chat/index.tsx +1 -1
  81. package/src/plugins/builtin/chat/layout.ts +8 -1
  82. package/src/plugins/builtin/chat/message/desktop.tsx +15 -11
  83. package/src/plugins/builtin/chat/message/header.tsx +112 -30
  84. package/src/plugins/builtin/chat/message/reactions.tsx +10 -11
  85. package/src/plugins/builtin/chat/message/render-state.ts +4 -2
  86. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  87. package/src/plugins/builtin/chat/message/types.ts +5 -0
  88. package/src/plugins/builtin/cloud-tweets/table.tsx +25 -2
  89. package/src/plugins/builtin/company-kpis/model.ts +11 -3
  90. package/src/plugins/builtin/correlation/compute.ts +6 -1
  91. package/src/plugins/builtin/custom-view/loader.ts +95 -34
  92. package/src/plugins/builtin/custom-view/pane.tsx +31 -41
  93. package/src/plugins/builtin/custom-view/table.ts +201 -0
  94. package/src/plugins/builtin/dividend-yield/client.ts +14 -17
  95. package/src/plugins/builtin/dividend-yield/headless.ts +0 -1
  96. package/src/plugins/builtin/dividend-yield/model.ts +45 -6
  97. package/src/plugins/builtin/dividend-yield/pane.tsx +70 -7
  98. package/src/plugins/builtin/dividend-yield/types.ts +2 -3
  99. package/src/plugins/builtin/dividend-yield/view.ts +22 -2
  100. package/src/plugins/builtin/econ/calendar-model.ts +135 -0
  101. package/src/plugins/builtin/econ/columns.ts +132 -0
  102. package/src/plugins/builtin/econ/index.tsx +25 -65
  103. package/src/plugins/builtin/holders/disclosures-view.tsx +9 -6
  104. package/src/plugins/builtin/holders/disclosures.ts +20 -6
  105. package/src/plugins/builtin/holders/headless.ts +2 -2
  106. package/src/plugins/builtin/ipo-calendar/model.ts +30 -1
  107. package/src/plugins/builtin/ipo-calendar/pane.tsx +7 -3
  108. package/src/plugins/builtin/kelly-sizer/headless.ts +9 -4
  109. package/src/plugins/builtin/kelly-sizer/pane.tsx +19 -9
  110. package/src/plugins/builtin/kelly-sizer/units.ts +26 -0
  111. package/src/plugins/builtin/market-halts/pane.tsx +14 -2
  112. package/src/plugins/builtin/news/wire/news/row.ts +5 -12
  113. package/src/plugins/builtin/news/wire/news/table.tsx +32 -41
  114. package/src/plugins/builtin/pe-band/headless.ts +1 -1
  115. package/src/plugins/builtin/pe-band/model.ts +41 -18
  116. package/src/plugins/builtin/pe-band/pane.tsx +6 -5
  117. package/src/plugins/builtin/perps/equity-row.tsx +4 -6
  118. package/src/plugins/builtin/perps/markets-section.tsx +19 -15
  119. package/src/plugins/builtin/perps/model.ts +10 -2
  120. package/src/plugins/builtin/portfolio-list/cli/import-positions.ts +6 -18
  121. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +1 -1
  122. package/src/plugins/builtin/portfolio-list/pane/purchase-date-fx.ts +1 -1
  123. package/src/plugins/builtin/portfolio-list/positions-import/index.tsx +1 -1
  124. package/src/plugins/builtin/portfolio-list/positions-import/lookup.ts +28 -57
  125. package/src/plugins/builtin/research/event-data.ts +3 -1
  126. package/src/plugins/builtin/research/event-model.ts +17 -15
  127. package/src/plugins/builtin/research/relative-valuation-columns.ts +19 -6
  128. package/src/plugins/builtin/research/relative-valuation-headless.ts +1 -1
  129. package/src/plugins/builtin/scanner/flow-pane.tsx +10 -0
  130. package/src/plugins/builtin/sec/exchange-filings.ts +32 -7
  131. package/src/plugins/builtin/sec/headless.ts +8 -8
  132. package/src/plugins/builtin/sec/index.tsx +69 -29
  133. package/src/plugins/builtin/shared/report-freshness.ts +4 -1
  134. package/src/plugins/builtin/ticker-detail/financials/aggregation.ts +1 -2
  135. package/src/plugins/builtin/ticker-detail/financials/exchange-table.tsx +61 -0
  136. package/src/plugins/builtin/ticker-detail/financials/model.ts +38 -4
  137. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +9 -2
  138. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +68 -39
  139. package/src/plugins/builtin/ticker-detail/headless.ts +4 -1
  140. package/src/plugins/builtin/ticker-detail/overview/model.ts +61 -15
  141. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +5 -0
  142. package/src/plugins/builtin/time-sales/model.ts +16 -9
  143. package/src/plugins/builtin/time-sales/pane.tsx +27 -24
  144. package/src/plugins/builtin/treasury-daily/client.ts +43 -9
  145. package/src/plugins/builtin/treasury-daily/pane.tsx +48 -27
  146. package/src/plugins/builtin/treasury-daily/resource.ts +33 -0
  147. package/src/portfolio/positions-import/parse.ts +14 -6
  148. package/src/portfolio/positions-import/plan.ts +3 -2
  149. package/src/react/async-resource.ts +3 -1
  150. package/src/renderers/dom/data-table/index.tsx +40 -0
  151. package/src/renderers/dom/data-table/row.tsx +39 -3
  152. package/src/renderers/dom/desktop/icons.tsx +147 -3
  153. package/src/renderers/dom/desktop/popover.tsx +2 -2
  154. package/src/renderers/dom/host/media-surface.tsx +204 -45
  155. package/src/renderers/dom/host/tabs.tsx +1 -0
  156. package/src/renderers/dom/styles.css +14 -2
  157. package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
  158. package/src/renderers/electrobun/bun/desktop/rpc-timing.ts +9 -3
  159. package/src/renderers/electrobun/shared/protocol.ts +2 -0
  160. package/src/renderers/electrobun/view/backend-rpc.ts +5 -2
  161. package/src/renderers/electrobun/view/rpc-timeout.ts +44 -3
  162. package/src/sources/gloomberb-cloud/index.ts +8 -7
  163. package/src/sources/gloomberb-cloud/normalizers.ts +7 -2
  164. package/src/sources/listing-symbols.ts +7 -1
  165. package/src/sources/provider-router/cache.ts +5 -4
  166. package/src/sources/provider-router/financials.ts +40 -18
  167. package/src/state/app/tab-cursor.ts +47 -6
  168. package/src/telemetry/stall-clocks.ts +3 -0
  169. package/src/telemetry/stall-reports.ts +12 -3
  170. package/src/telemetry/windows-process-activity.ts +41 -0
  171. package/src/telemetry/windows-time.ts +32 -0
  172. package/src/test-support/scoped-earnings.ts +24 -0
  173. package/src/tickers/terminal-codes.ts +1 -6
  174. package/src/time-series/daily-valuation.ts +13 -6
  175. package/src/time-series/filed-trailing-eps.ts +16 -3
  176. package/src/time-series/fundamentals/current-valuation.ts +8 -0
  177. package/src/time-series/fundamentals/historical-valuation.ts +20 -0
  178. package/src/time-series/fundamentals/series.ts +13 -1
  179. package/src/time-series/valuation-currency.ts +2 -0
  180. package/src/types/financials.ts +46 -10
  181. package/src/ui/dialog-context.ts +8 -0
  182. package/src/utils/datetime-format.ts +23 -1
  183. package/src/utils/declared-dividends.ts +12 -2
  184. package/src/utils/exchange-announcements.ts +4 -1
  185. package/src/utils/exchange-notation.generated.ts +3 -1
  186. package/src/utils/exchanges.ts +2 -1
  187. package/src/utils/fundamentals.ts +1 -0
  188. package/src/utils/main-thread-stall.ts +9 -1
  189. package/src/utils/rpc-timeout-error.ts +36 -11
  190. package/src/utils/sec.ts +3 -1
  191. package/src/utils/share-multiples.ts +1 -1
  192. package/src/utils/stall-process-activity.ts +70 -0
  193. package/src/utils/statement-scope.ts +103 -0
  194. package/src/utils/trailing-eps.ts +1 -1
  195. package/src/utils/zoned-date-time.ts +1 -0
@@ -1,7 +1,7 @@
1
1
  import { Box, useShortcutLabel, useUiCapabilities } from "../../../ui";
2
2
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
3
  import { TextAttributes, type ScrollBoxRenderable } from "../../../ui";
4
- import { COUNTRY_FLAG_CELLS, withCountryFlag } from "../../../components/ui/country-flag";
4
+ import { withCountryFlag } from "../../../components/ui/country-flag";
5
5
  import {
6
6
  Button,
7
7
  DataTableStackView,
@@ -15,7 +15,7 @@ import {
15
15
  } from "../../../components";
16
16
  import { usePluginPaneState } from "../../runtime";
17
17
  import { useAppConfig, usePaneSettingValue } from "../../../public/react";
18
- import { readerTimeZone, timeZoneCity, zonedClock } from "../../../utils/utc-time";
18
+ import { readerTimeZone, zonedClock } from "../../../utils/utc-time";
19
19
  import { usePaneInstance } from "../../../state/app/context";
20
20
  import { commandRequestParams } from "../shared/command-tab";
21
21
  import { useAsyncResource } from "../../../react/async-resource";
@@ -29,21 +29,23 @@ import { hasNoReleaseTime, hasNoStatedTime, isAllDayEvent, type EconEvent } from
29
29
  import { FRED_CATALOG_SERIES } from "./fred-catalog";
30
30
  import { ECON_PRINT_NOTIFICATIONS_ENABLED_KEY, retainVisiblePrintRefresh, setupHighImpactPrintNotifications } from "./print-watch";
31
31
  import { EconDetailView } from "./detail-view";
32
+ import { countryColumnShown, econCalendarColumns } from "./columns";
32
33
  import {
33
34
  COUNTRY_CYCLE,
34
35
  COUNTRY_FILTER_HINT,
35
36
  countriesWithoutEvents,
36
37
  DEFAULT_IMPACT_FILTER,
37
38
  FILTER_CYCLE,
39
+ actualNoteWidth,
38
40
  attachEconCalendarPersistence,
39
41
  awaitsConsensus,
40
42
  figureGap,
41
43
  figureGapText,
42
44
  calendarDisplayRows,
43
- CALENDAR_TIME_ZONE_LABEL,
44
45
  dayLabel,
45
46
  econEventName,
46
47
  econFigureCell,
48
+ listedEventName,
47
49
  filteredEmptyTitle,
48
50
  formatStaleness,
49
51
  getCalendarCache,
@@ -67,7 +69,6 @@ import {
67
69
  shortCalendarEnd,
68
70
  shortDayLabel,
69
71
  timeLabel,
70
- valueColumnWidth,
71
72
  type CountryFilter,
72
73
  type DisplayRow,
73
74
  type EconCalendarColumn,
@@ -76,8 +77,8 @@ import {
76
77
  } from "./calendar-model";
77
78
  import { MISSING_VALUE } from "../../../utils/format";
78
79
  import { usePaneStatusFooter } from "../../../components/layout/pane/status-footer";
80
+ import { createDataTableCsv } from "../../../components/data-table/export";
79
81
  import { handleRefreshKey } from "../../../components/data-table/table-pane";
80
- import { tableColumnWidth } from "../../../components/ui/table-layout";
81
82
  import { useRemoteUiNode } from "../../../remote/semantic-tree";
82
83
 
83
84
  const IMPACT_LABELS: Record<ImpactFilter, string> = {
@@ -90,10 +91,6 @@ const IMPACT_LABELS: Record<ImpactFilter, string> = {
90
91
  const NO_EVENTS: EconEvent[] = [];
91
92
  /** The start (UTC) of a YYYY-MM-DD day, to label it. */
92
93
  const dayStart = (day: string) => new Date(`${day}T00:00:00Z`);
93
- const SPELLED_IMPACT = "IMPACT";
94
- const SPELLED_COUNTRY = "COUNTRY";
95
- /** Event names this wide still read; past it the headers spell themselves out. */
96
- const SPELLED_HEADER_MIN_EVENT_WIDTH = 24;
97
94
  /** A result says whether a forced reload asked for it, so its answer can reset the cursor. */
98
95
  type CalendarResult = EconCalendarLoadResult & { forced?: boolean };
99
96
  const loadEvents = async (force: boolean): Promise<CalendarResult> => ({
@@ -283,59 +280,13 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
283
280
  const flagged = useUiCapabilities().nativePaneChrome === true;
284
281
  // A reader who set a time zone (`config set timezone`) gets their clock in a column beside UTC.
285
282
  const readerZone = readerTimeZone(useAppConfig().timezone);
286
- const columns = useMemo<EconCalendarColumn[]>(() => {
287
- // Named by its zone, as the reader's column is by its city: "TIME (UTC)" took 13
288
- // cells over "07:00" while EVENT read "GDP Growth Ra…" (review, 12 Nov 2026).
289
- const timeLabelText = CALENDAR_TIME_ZONE_LABEL;
290
- const timeWidth = tableColumnWidth({ width: filtered.some(isAllDayEvent) ? "All day".length : 5, label: timeLabelText });
291
- const compact = width < 58;
292
- // One country, or one impact level, is the filter's: no column repeats it on each row.
293
- const showCountry = !/^[A-Z]{2}$/.test(countryFilter) || countryFilter === "EU";
294
- const showImpact = impactFilter === "all";
295
- const actualLabel = compact ? "ACT" : "ACTUAL";
296
- const forecastLabel = compact ? "EST" : "FORECAST";
297
- const actualWidth = tableColumnWidth({ width: valueColumnWidth(filtered, "actual", compact ? 3 : 9), label: actualLabel });
298
- const forecastWidth = tableColumnWidth({ width: valueColumnWidth(filtered, "forecast", compact ? 3 : 10), label: forecastLabel });
299
- const priorWidth = tableColumnWidth({ width: valueColumnWidth(filtered, "prior", compact ? 5 : 9), label: "PRIOR" });
300
- const minEventWidth = tableColumnWidth({ width: compact ? 5 : 12, label: "EVENT" });
301
- // The reader's clock, with the weekday on rows where it is another day than the UTC one they are listed under.
302
- const readerLabel = readerZone ? timeZoneCity(readerZone).toUpperCase() : null;
303
- const readerWidth = !readerZone || !readerLabel ? 0 : tableColumnWidth({ label: readerLabel,
304
- width: filtered.some((ev) => !hasNoReleaseTime(ev) && zonedClock(ev.date.getTime(), readerZone).label.length > 5) ? 9 : 5 });
305
- // Padding, one gap per column boundary, and the vertical scrollbar lane;
306
- // one column short of that clipped the PRIOR values at the right edge.
307
- const roomBeside = (count: number, timesWidth: number) => (impactWidth: number, countryWidth: number) => (
308
- width - 3 - count + (showCountry ? 0 : 1) + (showImpact ? 0 : 1)
309
- - (timesWidth + (showImpact ? impactWidth : 0) + (showCountry ? countryWidth : 0) + actualWidth + forecastWidth + priorWidth)
310
- );
311
- const codeWidth = 2 + (flagged ? COUNTRY_FLAG_CELLS : 0);
312
- // The reader's column only where the event names keep room to read beside it, under the short headers.
313
- const withReader = readerWidth > 0 && roomBeside(8, timeWidth + readerWidth)(4, Math.max(3, codeWidth)) >= minEventWidth;
314
- const eventRoom = withReader ? roomBeside(8, timeWidth + readerWidth) : roomBeside(7, timeWidth);
315
- // IMPACT and COUNTRY in words while event names keep room to read; the
316
- // short labels otherwise, with the word on hover where there is one.
317
- const spelledImpactWidth = tableColumnWidth({ width: 1, label: SPELLED_IMPACT });
318
- const spelledCountryWidth = Math.max(codeWidth, tableColumnWidth({ width: 1, label: SPELLED_COUNTRY }));
319
- const spelled = eventRoom(spelledImpactWidth, spelledCountryWidth) >= SPELLED_HEADER_MIN_EVENT_WIDTH;
320
- const impactColumn = spelled
321
- ? { label: SPELLED_IMPACT, width: spelledImpactWidth }
322
- : { label: "IMP", width: 4, title: "Impact" };
323
- const countryColumn = spelled
324
- ? { label: SPELLED_COUNTRY, width: spelledCountryWidth }
325
- : { label: "CTY", width: Math.max(3, codeWidth), title: "Country" };
326
- const eventWidth = Math.max(minEventWidth, eventRoom(tableColumnWidth(impactColumn), tableColumnWidth(countryColumn)));
327
-
328
- return [
329
- { id: "time", label: timeLabelText, width: timeWidth, align: "left" },
330
- ...withReader ? [{ id: "readerTime" as const, label: readerLabel!, width: readerWidth, align: "left" as const, title: readerZone! }] : [],
331
- ...showImpact ? [{ id: "impact" as const, ...impactColumn, align: "left" as const }] : [],
332
- ...showCountry ? [{ id: "country" as const, ...countryColumn, align: "left" as const }] : [],
333
- { id: "event", label: "EVENT", width: eventWidth, align: "left" },
334
- { id: "actual", label: actualLabel, title: "Actual", width: actualWidth, align: "right" },
335
- { id: "forecast", label: forecastLabel, title: "Forecast", width: forecastWidth, align: "right" },
336
- { id: "prior", label: "PRIOR", width: priorWidth, align: "right" },
337
- ];
338
- }, [countryFilter, filtered, flagged, impactFilter, readerZone, width]);
283
+ // `awaiting` under Actual on a release past its time: the column keeps the word whole.
284
+ const actualNote = useMemo(() => actualNoteWidth(filtered, now, events), [events, filtered, now]);
285
+ const { columns, exportColumns, exportInReaderOrder } = useMemo(
286
+ () => econCalendarColumns({ width, events: filtered, countryFilter, impactFilter, flagged, readerZone, actualNote }),
287
+ [actualNote, countryFilter, filtered, flagged, impactFilter, readerZone, width],
288
+ );
289
+ const countryShown = countryColumnShown(countryFilter);
339
290
  const separatorBg = blendHex(colors.bg, colors.border, 0.3);
340
291
  const staleness = fetchedAt ? formatStaleness(fetchedAt, now) : "";
341
292
  // The calendar has events and the filters hid them all: say which, with the way back.
@@ -511,14 +462,18 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
511
462
  const country = eventCountry(ev);
512
463
  return withCountryFlag({ text: country, color: colors.textMuted }, country, flagged);
513
464
  }
514
- case "event":
515
- return { text: econEventName(ev), color: colors.text };
465
+ case "event": {
466
+ // Beside its country a name leaves out the country's adjective; the export writes it whole.
467
+ const name = econEventName(ev);
468
+ const listed = listedEventName(ev, countryShown);
469
+ return { text: listed, color: colors.text, ...listed === name ? {} : { value: name } };
470
+ }
516
471
  case "actual":
517
472
  case "forecast":
518
473
  case "prior":
519
474
  return econFigureCell(column.id, ev, now, events);
520
475
  }
521
- }, [events, flagged, now, readerZone]);
476
+ }, [countryShown, events, flagged, now, readerZone]);
522
477
 
523
478
  const selectedEvent = filtered[selectedIdx];
524
479
  const filterControls = (
@@ -587,6 +542,11 @@ function EconCalendarPane({ focused, width, height }: PaneProps) {
587
542
  onActivate={openDisplayRow}
588
543
  renderSectionHeader={renderSectionHeader}
589
544
  renderCell={renderCell}
545
+ // Export CSV keeps every figure and the reader's clock at any width: only the table drawn leaves columns out,
546
+ // and what it fits beside the names never decides what the file holds. A column the reader moved stays moved.
547
+ exportCsv={(inReaderOrder) => createDataTableCsv({
548
+ columns: exportInReaderOrder ? inReaderOrder(exportColumns) : exportColumns, items: rows, renderCell, renderSectionHeader,
549
+ })}
590
550
  selectedTextOverridesCellColor
591
551
  status={{ loading: loading && !rows.length, error: !loading && !events.length ? error : null, subject: "economic events" }}
592
552
  emptyContent={filterEmptyTitle ? (
@@ -10,9 +10,9 @@ import { logFailure } from "../../../utils/log-failure";
10
10
  import { useRendererHost } from "../../../ui";
11
11
  import { SignInWall } from "../cloud/auth-actions";
12
12
  import { isCloudSessionRequired, useResearchCloudSession } from "../shared/research-cloud-session";
13
- import { disclosureColumns, disclosureWarnings } from "./disclosures";
13
+ import { disclosureColumns, disclosureEmpty, disclosureWarnings } from "./disclosures";
14
14
 
15
- const keyOf = (row: OwnershipDisclosure) => JSON.stringify([row.url, row.owner, row.role, row.date, row.securities, row.pledged]);
15
+ const keyOf = (row: OwnershipDisclosure) => row.id ?? JSON.stringify([row.url, row.owner, row.role, row.date, row.position, row.securities, row.pledged]);
16
16
 
17
17
  export function OwnershipDisclosureView({listing, focused, width, onCycle}: {
18
18
  listing: string; focused: boolean; width: number; onCycle: () => void;
@@ -31,7 +31,8 @@ export function OwnershipDisclosureView({listing, focused, width, onCycle}: {
31
31
  void host.openExternal(row.url).catch(logFailure("holders.disclosures", "Open ownership source failed"));
32
32
  };
33
33
  const warnings = payload ? disclosureWarnings(payload).join(" ") : "";
34
- const truncated = payload && rows.length < payload.total ? `Latest ${rows.length} of ${payload.total}` : "";
34
+ const empty = payload && !rows.length;
35
+ const truncated = payload && rows.length < payload.total ? `Showing ${rows.length} of ${payload.total}` : "";
35
36
  usePaneFooter("holder-disclosures", () => ({
36
37
  info: [
37
38
  {id: "source", parts: [{text: [payload?.publisher, truncated, warnings].filter(Boolean).join(" · "), tone: "muted" as const}]},
@@ -39,11 +40,11 @@ export function OwnershipDisclosureView({listing, focused, width, onCycle}: {
39
40
  ],
40
41
  hints: current ? [{id: "source", key: "o", label: "pen source", onPress: () => open(current)}] : [],
41
42
  }), [payload, truncated, warnings, current, host, loading, error]);
42
- const columns = disclosureColumns(rows).map(([id,label,width]) => ({id,label,width,align: (["securities", "change", "pledged", "percent"].includes(id) ? "right" : "left") as "right" | "left"}));
43
+ const columns = disclosureColumns(rows).map(([id,label,width]) => ({id,label,width,align: (["securities", "involved", "change", "pledged", "percent", "direct", "deemed"].includes(id) ? "right" : "left") as "right" | "left"}));
43
44
  if (isCloudSessionRequired(error)) {
44
45
  return <SignInWall placement="holders-disclosures-signin" action="view ownership disclosures" needsVerification={session.needsVerification} />;
45
46
  }
46
- return <PaneStatusBody loading={loading && !payload} error={payload ? null : error} subject="ownership disclosures" empty={!!payload && !rows.length} emptyTitle={warnings || "No ownership disclosures in the published registers."}>
47
+ return <PaneStatusBody loading={loading && !payload} error={payload ? null : error} subject="ownership disclosures" empty={!!empty} emptyTitle={warnings || (empty ? disclosureEmpty(payload) : undefined)}>
47
48
  <DataTableView focused={focused} rootWidth={width} items={rows} columns={columns} sortColumnId={null} sortDirection="desc"
48
49
  selection={{kind: "id", selectedId: current ? keyOf(current) : null, getId: keyOf, onChange: setSelected}}
49
50
  getItemKey={keyOf} resetScrollKey={listing} onActivate={open} freezeFirstColumn showHorizontalScrollbar
@@ -56,7 +57,9 @@ export function OwnershipDisclosureView({listing, focused, width, onCycle}: {
56
57
  rowNote={row => row.reason ?? null}
57
58
  renderCell={(row, column) => {
58
59
  const value = row[column.id];
59
- return {text: typeof value === "number" ? value.toLocaleString("en-US") : value ?? MISSING_VALUE};
60
+ return {text: typeof value === "number"
61
+ ? value.toLocaleString("en-US", row.filing ? { maximumFractionDigits: 20 } : undefined)
62
+ : value ?? MISSING_VALUE};
60
63
  }}
61
64
  emptyStateTitle="No ownership disclosures." />
62
65
  </PaneStatusBody>;
@@ -3,19 +3,33 @@ import type { HeadlessPaneColumn } from "../../../types/plugin";
3
3
 
4
4
  const columns = [
5
5
  ["owner", "Holder", 22], ["date", "Date", 10], ["dateBasis", "Date basis", 10], ["kind", "Disclosure", 22],
6
- ["role", "Role / filing type", 18], ["securities", "Securities", 15], ["percent", "Held %", 8], ["change", "Change", 13],
7
- ["pledged", "Pledged", 13],
6
+ ["role", "Role / filing type", 18], ["position", "Position", 12], ["securities", "Securities", 15], ["percent", "Held %", 8],
7
+ ["involved", "Shares involved", 16], ["change", "Change", 13],
8
+ ["pledged", "Pledged", 13], ["direct", "Direct", 15], ["deemed", "Deemed", 15],
8
9
  ] as const;
9
10
  export function disclosureColumns(rows: OwnershipDisclosure[]) {
10
- return columns.filter(([key]) => !["percent", "change", "pledged"].includes(key) || rows.some(row => row[key] != null));
11
+ return columns.filter(([key]) => !["position", "involved", "percent", "change", "pledged", "direct", "deemed"].includes(key) || rows.some(row => row[key] != null));
11
12
  }
12
13
 
13
14
  export function disclosureWarnings(payload: OwnershipDisclosures) {
14
- return payload.registers.filter(register => register.status !== "read").map(register => {
15
- const name = register.kind === "major" ? "Major shareholder disclosures" : "Insider disclosures";
15
+ const warnings = payload.registers.filter(register => register.status !== "read").map(register => {
16
+ const name = register.kind === "major" ? "Major shareholder disclosures"
17
+ : register.kind === "major-notices" ? "Major shareholder notices" : "Insider disclosures";
16
18
  return register.status === "unavailable" ? name + " unavailable." : name + " from the saved read on " + register.retrievedAt?.slice(0, 10) + ".";
17
19
  });
20
+ const pending = payload.registers.reduce((total, register) => total + (register.pending ?? 0), 0);
21
+ const unreadable = payload.registers.reduce((total, register) => total + (register.unreadable ?? 0), 0);
22
+ if (pending) warnings.push(`${pending} SGX ${pending === 1 ? "notice" : "notices"} pending.`);
23
+ if (unreadable) warnings.push(`${unreadable} SGX ${unreadable === 1 ? "notice" : "notices"} could not be fully read.`);
24
+ return warnings;
18
25
  }
26
+
27
+ export function disclosureEmpty(payload: OwnershipDisclosures) {
28
+ return payload.listing.endsWith(":SGX")
29
+ ? "No SGX ownership notices in the past year."
30
+ : "No ownership disclosures in the published registers.";
31
+ }
32
+
19
33
  export function disclosureReport(payload: OwnershipDisclosures) {
20
34
  const warnings = disclosureWarnings(payload);
21
35
  const columns: HeadlessPaneColumn[] = disclosureColumns(payload.rows).map(([key, header]) => ({ key, header }));
@@ -28,6 +42,6 @@ export function disclosureReport(payload: OwnershipDisclosures) {
28
42
  },
29
43
  freshness: {source: payload.publisher, status: "not-a-feed" as const, basis: "ownership disclosures", asOf: payload.rows[0]?.date ?? null, oldest: null},
30
44
  ...(warnings.length ? {warnings, complete: false} : {}),
31
- ...(!payload.rows.length ? {empty: warnings.length ? warnings.join(" ") : "No ownership disclosures in the published registers."} : {}),
45
+ ...(!payload.rows.length ? {empty: warnings.length ? warnings.join(" ") : disclosureEmpty(payload)} : {}),
32
46
  };
33
47
  }
@@ -144,7 +144,7 @@ export function createHoldersHeadless(
144
144
  },
145
145
  {
146
146
  key: "view",
147
- description: "Rendered pane view: the holder table, the ownership treemap, 13D/13G beneficial owners, or ownership disclosures for Korea and Taiwan.",
147
+ description: "Rendered pane view: the holder table, the ownership treemap, 13D/13G beneficial owners, or ownership disclosures for Hong Kong, Korea, Singapore and Taiwan.",
148
148
  type: "enum",
149
149
  values: [{ value: "table" }, { value: "chart" }, { value: "13dg", aliases: ["beneficial"] }, { value: "disclosures" }],
150
150
  defaultValue: "table",
@@ -180,7 +180,7 @@ export function createHoldersHeadless(
180
180
  const symbol = args.symbols[0]!;
181
181
  if (args.options.view === "disclosures") {
182
182
  const listing = disclosureListing(symbol) ?? disclosureListing(symbol, (await resolveHeadlessIssuerListing(ctx, symbol))?.exchange);
183
- if (!listing) throw new Error("Ownership disclosures cover TWSE, TPEx, KRX and KOSDAQ listings.");
183
+ if (!listing) throw new Error("Ownership disclosures cover HKEX, SGX, TWSE, TPEx, KRX and KOSDAQ listings.");
184
184
  return disclosureReport(await ctx.apiClient.getOwnershipDisclosures(listing, Number(args.options.limit ?? 25), ctx.signal));
185
185
  }
186
186
  const requestedForm = parseHolderForm(args.options.form) ?? "13f";
@@ -1,6 +1,6 @@
1
1
  import type { IpoDeal, IpoRegion, IpoSourceHealth, IpoStatus } from "../../../api-client/ipo";
2
2
  import type { DataTableColumn } from "../../../components";
3
- import { dropColumnsToFit, getTableWidth } from "../../../components/ui/table-layout";
3
+ import { dropColumnsToFit, getTableWidth, narrowColumnsForName } from "../../../components/ui/table-layout";
4
4
  import { publicTickerKey } from "../../../utils/exchanges";
5
5
  import { MISSING_VALUE, displayWidth, formatCompact } from "../../../utils/format";
6
6
  import { compareSortValues, type SortPreference } from "../../../utils/sort-values";
@@ -477,6 +477,35 @@ export function marketColumnWidth(deals: readonly IpoDeal[]): number {
477
477
  return Math.min(14, Math.max(5, longest));
478
478
  }
479
479
 
480
+ /** The cells a venue takes in MKT (`Shanghai`, `Nasdaq`, `HKEX`): one longer (`NYSE American`) gives them to the names. */
481
+ const PLAIN_VENUE_WIDTH = 8;
482
+
483
+ /**
484
+ * The cells the longest company name on the board takes: MKT gives the
485
+ * company column what one long venue took until these are whole.
486
+ */
487
+ export function longestIpoCompany(deals: readonly Pick<IpoDeal, "company">[]): number {
488
+ return deals.reduce((longest, deal) => Math.max(longest, displayWidth(deal.company)), 0);
489
+ }
490
+
491
+ /**
492
+ * `columns` (buildIpoColumns, less any the list leaves quiet) with the cells
493
+ * MKT holds for one long venue (`NYSE American`, among deals in `Nasdaq` and
494
+ * `Tokyo`) given to COMPANY while its names are cut, down to a plain venue's
495
+ * (`flagCells` more for the flag the desktop and the web draw). That venue is
496
+ * then cut, and whole in the deal's detail. `width` is the pane's, as
497
+ * buildIpoColumns takes it; COMPANY takes what the others leave.
498
+ */
499
+ export function ipoColumnsBesideNames<C extends IpoColumn>(columns: readonly C[], width: number, longestCompany: number, flagCells = 0): C[] {
500
+ const company = columns.find((column) => column.id === "company");
501
+ const market = columns.find((column) => column.id === "market");
502
+ if (!company || !market) return [...columns];
503
+ const drawn = (venue: C) => columns.map((column) => (column === market ? venue : column));
504
+ const [fitted] = narrowColumnsForName([market], ([venue]) => company.width + width - ipoTableWidth(drawn(venue!)), longestCompany,
505
+ PLAIN_VENUE_WIDTH + flagCells);
506
+ return fitted === market ? [...columns] : drawn(fitted!);
507
+ }
508
+
480
509
  /** DATE and LOCKUP widths that fit every date the board shows (ipoDateColumnWidths); the narrowest by default. */
481
510
  export interface IpoDateWidths {
482
511
  date: number;
@@ -53,6 +53,8 @@ import {
53
53
  marketsBehind,
54
54
  marketsBehindText,
55
55
  marketColumnWidth,
56
+ longestIpoCompany,
57
+ ipoColumnsBesideNames,
56
58
  MISSING,
57
59
  sortIpoDeals,
58
60
  type IpoBoardStatus,
@@ -141,11 +143,13 @@ export function IpoCalendarPane({ focused, width, height }: PaneProps) {
141
143
  const flagged = useUiCapabilities().nativePaneChrome === true;
142
144
  const marketWidth = useMemo(() => marketColumnWidth(deals) + (flagged ? COUNTRY_FLAG_CELLS : 0), [deals, flagged]);
143
145
  const dateWidths = useMemo(() => ipoDateColumnWidths(deals, now), [deals, now]);
146
+ const longestCompany = useMemo(() => longestIpoCompany(rows), [rows]);
144
147
  // STATUS says only what differs from the list's own (priced among the upcoming deals), and goes when nothing does;
145
- // LOCKUP goes when no deal listed has an estimate (one outside the US).
146
- const columns = useMemo(() => withoutQuietColumns(buildIpoColumns(width, marketWidth, list, dateWidths), rows,
148
+ // LOCKUP goes when no deal listed has an estimate (one outside the US). MKT then gives the company names listed
149
+ // what one long venue took, before a name is cut.
150
+ const columns = useMemo(() => ipoColumnsBesideNames(withoutQuietColumns(buildIpoColumns(width, marketWidth, list, dateWidths), rows,
147
151
  (deal, id) => (id === "status" ? ipoListStatus(deal, list, now) : id === "lockup" ? formatIpoLockupDate(deal.lockup?.endsOn, now) : null),
148
- QUIET_COLUMNS) as IpoColumn[], [dateWidths, list, marketWidth, now, rows, width]);
152
+ QUIET_COLUMNS) as IpoColumn[], width, longestCompany, flagged ? COUNTRY_FLAG_CELLS : 0), [dateWidths, flagged, list, longestCompany, marketWidth, now, rows, width]);
149
153
 
150
154
  const openDeal = useCallback((deal: IpoDeal) => {
151
155
  const key = ipoTickerKey(deal);
@@ -20,7 +20,7 @@ import { formatPct, formatSignedPct } from "./view";
20
20
  import { logFailure } from "../../../utils/log-failure";
21
21
  import { isoDayEntries } from "../shared/day-entries";
22
22
  import { loadFuturesContractTerms } from "../../../market-data/futures-contract";
23
- import { kellyCount, kellyCountMultiplier, type KellyCount } from "./units";
23
+ import { formatKellySizingPrice, kellyCount, kellyCountMultiplier, kellySizingPrice, type KellyCount } from "./units";
24
24
 
25
25
  /** The fractions of full Kelly a report sizes, largest first. */
26
26
  const KELLY_FRACTIONS = [
@@ -125,9 +125,10 @@ export const kellyHeadless: HeadlessPaneDefinition<"bundle"> = {
125
125
  const bankrollValue = args.options.bankroll;
126
126
  const bankroll = typeof bankrollValue === "number" && bankrollValue > 0 ? bankrollValue : null;
127
127
  const baseCurrency = ctx.config.baseCurrency || "USD";
128
- const price = quote && quote.price > 0 && Number.isFinite(quote.price) ? quote.price : null;
129
128
  // A future is counted in contracts, each its price times the contract's multiplier.
130
129
  const count = kellyCount(symbol, exchange, quote?.instrumentType);
130
+ const sizingPrice = kellySizingPrice(quote, count);
131
+ const price = sizingPrice?.value ?? null;
131
132
  const [multiplier, basePrice] = bankroll == null || price == null ? [null, null] : await Promise.all([
132
133
  kellyCountMultiplier(symbol, count, (key) => loadFuturesContractTerms(key, ctx.apiClient)),
133
134
  // The price in the bankroll's currency, at the rate the portfolio values holdings at; null without one.
@@ -170,7 +171,11 @@ export const kellyHeadless: HeadlessPaneDefinition<"bundle"> = {
170
171
  notes,
171
172
  sections: [
172
173
  // The window's days read first in the text; JSON and CSV keep them in ISO.
173
- { title: "Inputs", ...isoDayEntries(inputEntries(inputs, solve.expectedReturn)) },
174
+ { title: "Inputs", ...isoDayEntries([...inputEntries(inputs, solve.expectedReturn),
175
+ ...(bankroll != null && sizingPrice ? [{ key: "sizingPrice", label: "Sizing price", value: sizingPrice.value,
176
+ formatted: formatKellySizingPrice(sizingPrice), unit: sizingPrice.currency ?? undefined,
177
+ asOf: typeof sizingPrice.asOf === "number" ? new Date(sizingPrice.asOf).toISOString() : sizingPrice.asOf }] : []),
178
+ ]) },
174
179
  {
175
180
  title: bankroll == null ? "Sizing" : `Sizing on ${formatNumber(bankroll, 0)} ${baseCurrency}`,
176
181
  columns: [
@@ -193,7 +198,7 @@ export const kellyHeadless: HeadlessPaneDefinition<"bundle"> = {
193
198
  expectedLogGrowth: solve.expectedLogGrowth,
194
199
  bankroll,
195
200
  currency: baseCurrency,
196
- price: price == null ? null : { value: price, currency: quote?.currency ?? null, asOf: quote?.lastUpdated ?? null },
201
+ price: sizingPrice,
197
202
  ...(basePrice != null && quote?.currency !== baseCurrency ? { priceInBase: { value: basePrice, currency: baseCurrency } } : {}),
198
203
  ...(count === "contracts" && multiplier != null ? { contractMultiplier: multiplier } : {}),
199
204
  units: count,
@@ -6,6 +6,7 @@ import { colors } from "../../../theme/colors";
6
6
  import {
7
7
  EmptyState,
8
8
  FieldGrid,
9
+ KeyValueRow,
9
10
  QueryBar,
10
11
  StatGrid,
11
12
  fieldGridColumns,
@@ -22,7 +23,8 @@ import { useChartQueries, useFxRatesMap, useResolvedEntryValue } from "../../../
22
23
  import { buildChartKey } from "../../../market-data/selectors";
23
24
  import { useLiveTickerFinancials, useLiveTickerFinancialsMap } from "../../../state/hooks/live-ticker-financials";
24
25
  import { buildPortfolioFinancialsMap } from "../../../market-data/portfolio-financials";
25
- import { convertCurrency, formatCurrency } from "../../../utils/format";
26
+ import { convertCurrency } from "../../../utils/format";
27
+ import { formatUtcTime } from "../../../utils/utc-time";
26
28
  import {
27
29
  useAppDispatch,
28
30
  getFocusedCollectionId,
@@ -69,7 +71,7 @@ import {
69
71
  kellyTrailingHistoryRequest,
70
72
  } from "./history";
71
73
  import { historyReadUnanswered } from "../../../time-series/calendar-month-returns";
72
- import { kellyCount, kellyCountMultiplier } from "./units";
74
+ import { formatKellySizingPrice, kellyCount, kellyCountMultiplier, kellySizingPrice } from "./units";
73
75
  import { KELLY_PANE_ID } from "./constants";
74
76
  import {
75
77
  buildKellyCurveXAxisLabels,
@@ -286,12 +288,13 @@ export function KellySizerPane({ focused, width, height }: PaneProps) {
286
288
  });
287
289
  const bankroll = bankrollOverride ?? sourceBankroll;
288
290
  const currentValue = currentValueOverride ?? sourceCurrentValue;
289
- const price = positionFinancials?.quote?.price ?? null;
290
291
  const priceCurrency = positionFinancials?.quote?.currency || ticker?.metadata.currency || config.baseCurrency;
291
292
  // A future is counted in contracts, each worth its price times the contract's multiplier from its terms.
292
293
  const count = ticker
293
294
  ? kellyCount(ticker.metadata.ticker, ticker.metadata.exchange ?? "", positionFinancials?.quote?.instrumentType ?? ticker.metadata.assetCategory)
294
295
  : "shares";
296
+ const sizingPrice = kellySizingPrice(positionFinancials?.quote, count, positionFinancials?.quote?.instrumentType ?? ticker?.metadata.assetCategory);
297
+ const price = sizingPrice?.value ?? null;
295
298
  const [contractMultiplier, setContractMultiplier] = useState<{ symbol: string; value: number | null } | null>(null);
296
299
  const tickerSymbol = ticker?.metadata.ticker ?? null;
297
300
  useEffect(() => {
@@ -560,15 +563,13 @@ export function KellySizerPane({ focused, width, height }: PaneProps) {
560
563
  }),
561
564
  ];
562
565
  const resultRows = statGridRows(resultItems, width, gridColumns);
563
- // Query bar, the mode strip when it is not in the title bar, inputs, results.
564
- const bodyRows = Math.max(0, height - 1 - tabRows - gridRows - resultRows);
566
+ const priceLine = sizingPrice ? formatKellySizingPrice(sizingPrice) : null;
567
+ const splitPriceLine = sizingPrice?.asOf != null && priceLine != null && width < priceLine.length + 8;
568
+ const priceRows = priceLine ? splitPriceLine ? 2 : 1 : 0;
569
+ const bodyRows = Math.max(0, height - 1 - tabRows - gridRows - resultRows - priceRows);
565
570
  const chartHeight = showSensitivity ? 0 : bodyRows;
566
571
  const showChart = !showSensitivity && chartHeight >= 6 && curvePoints.length > 0;
567
- const quoteCurrency = positionFinancials?.quote?.currency || ticker?.metadata.currency || config.baseCurrency;
568
- // The search shows the ticker and the Portfolio filter the account, so the
569
- // context is the price first, then the account only when there is no filter.
570
572
  const meta = [
571
- price != null ? formatCurrency(price, quoteCurrency) : null,
572
573
  portfolioTabs.length > 1 ? null : activePortfolio?.name ?? null,
573
574
  bankrollOverride != null || currentValueOverride != null ? "override" : null,
574
575
  tickerSearchStatus,
@@ -646,6 +647,15 @@ export function KellySizerPane({ focused, width, height }: PaneProps) {
646
647
 
647
648
  {tabStrip && <Box height={1} paddingX={1}>{tabStrip}</Box>}
648
649
 
650
+ {sizingPrice && priceLine && (
651
+ <Box flexDirection="column" paddingX={1} flexShrink={0}>
652
+ <KeyValueRow label="Price" value={splitPriceLine ? formatKellySizingPrice({ ...sizingPrice, asOf: null }) : priceLine}
653
+ labelWidth={6} width={width - 2} emphasis={false} />
654
+ {splitPriceLine && sizingPrice.asOf != null && <KeyValueRow label="As of" value={formatUtcTime(sizingPrice.asOf)}
655
+ labelWidth={6} width={width - 2} emphasis={false} />}
656
+ </Box>
657
+ )}
658
+
649
659
  <FieldGrid
650
660
  fields={gridFields}
651
661
  activeId={activeInputId}
@@ -1,8 +1,14 @@
1
1
  import type { FuturesContractTermsPayload } from "../../../api-client/futures-curve";
2
2
  import { isFuturesInstrument, loadFuturesContractTermsCached } from "../../../market-data/futures-contract";
3
+ import { resolveAssetDisplayKind } from "../../../market-data/market/format";
4
+ import { getCompletedRegularSessionDisplay, getExtendedSessionDisplay } from "../../../market-data/market/status";
5
+ import { regularSessionValuationPrice, regularSessionValuationTime } from "../../../market-data/quotes/regular-session-valuation";
3
6
  import { futuresContractSize } from "../../../portfolio/futures-positions";
7
+ import type { Quote } from "../../../types/financials";
4
8
  import { isRoundTheClockCoin } from "../../../utils/crypto-pair";
9
+ import { formatCurrencyCode, formatNumber } from "../../../utils/format";
5
10
  import { logFailure } from "../../../utils/log-failure";
11
+ import { formatUtcTime } from "../../../utils/utc-time";
6
12
 
7
13
  /** What a Kelly position is counted in: shares of a stock or fund, units of a coin, contracts of a future. */
8
14
  export type KellyCount = "shares" | "units" | "contracts";
@@ -12,6 +18,26 @@ export function kellyCount(symbol: string, exchange: string, instrumentType: str
12
18
  return isRoundTheClockCoin(symbol, exchange) ? "units" : "shares";
13
19
  }
14
20
 
21
+ export function kellySizingPrice(quote: Quote | null | undefined, count: KellyCount, instrumentType = quote?.instrumentType) {
22
+ if (!quote) return null;
23
+ const equity = count === "shares" && resolveAssetDisplayKind({ assetCategory: instrumentType }) === "equity";
24
+ const completed = equity && getCompletedRegularSessionDisplay(quote) != null;
25
+ if (equity && !completed && (getExtendedSessionDisplay(quote) || quote.marketState === "PRE" || quote.marketState === "POST")) return null;
26
+ const value = equity ? regularSessionValuationPrice(quote) : quote.price;
27
+ if (value == null || !Number.isFinite(value) || value <= 0) return null;
28
+ const stamp = equity ? regularSessionValuationTime(quote)
29
+ : Number.isFinite(quote.lastUpdated) && quote.lastUpdated > 0 ? { time: quote.lastUpdated, dateOnly: false } : null;
30
+ const asOf = stamp?.dateOnly ? new Date(stamp.time).toISOString().slice(0, 10) : stamp?.time ?? null;
31
+ const session = completed || (equity && quote.marketState === "CLOSED") ? "Regular close"
32
+ : equity && quote.marketState === "REGULAR" ? "Regular session" : "Last quote";
33
+ return { value, currency: quote.currency || null, asOf, session };
34
+ }
35
+
36
+ export function formatKellySizingPrice(price: NonNullable<ReturnType<typeof kellySizingPrice>>) {
37
+ const amount = price.currency ? formatCurrencyCode(price.value, price.currency) : formatNumber(price.value, 4);
38
+ return [amount, price.session, price.asOf == null ? null : formatUtcTime(price.asOf)].filter(Boolean).join(" · ");
39
+ }
40
+
15
41
  /**
16
42
  * What one of the count is worth per unit of price: a future's contract
17
43
  * multiplier from the exchange's terms (ES's $50 a point, ZC's 5,000 bushels
@@ -7,6 +7,7 @@ import {
7
7
  type DataTableKeyEvent
8
8
  } from "../../../components";
9
9
  import { handleRefreshKey } from "../../../components/data-table/table-pane";
10
+ import { usePinnedList } from "../../../components/use-pinned-moment";
10
11
  import { useAsyncResource } from "../../../react/async-resource";
11
12
  import { useShortcut } from "../../../react/input";
12
13
  import { colors } from "../../../theme/colors";
@@ -44,6 +45,9 @@ import {
44
45
  type HaltSortPreference,
45
46
  } from "./model";
46
47
 
48
+ const haltId = (row: HaltRecord) => row.id;
49
+ const haltMoment = (row: HaltRecord) => row.haltedAt;
50
+
47
51
  /** Halted rows flip to resumed on the clock alone, so the pane re-reads it. */
48
52
  const EMPTY_RECORDS: HaltRecord[] = [];
49
53
  const STATUS_TICK_MS = 15_000;
@@ -79,10 +83,17 @@ export function MarketHaltsPane({ focused, width, height }: PaneProps) {
79
83
  [filter, now, records, sortPreference],
80
84
  );
81
85
 
86
+ // A crosshair pinned in the tab picks the newest halt by then and mutes
87
+ // the later ones; the selection follows the pin when it moves, not when a
88
+ // refresh brings a halt in. Status and age still read the clock now.
89
+ const { pinnedRow, isAfterPin } = usePinnedList<HaltRecord>("market-halts:pin", {
90
+ rows, getId: haltId, moment: haltMoment, selectedId, select: setSelectedId,
91
+ });
92
+
82
93
  useEffect(() => {
83
94
  if (selectedId && rows.some((row) => row.id === selectedId)) return;
84
- setSelectedId(rows[0]?.id ?? null);
85
- }, [rows, selectedId]);
95
+ setSelectedId((pinnedRow ?? rows[0])?.id ?? null);
96
+ }, [pinnedRow, rows, selectedId]);
86
97
 
87
98
  const refresh = useCallback(() => load(), [load]);
88
99
  const selectFilter = useCallback((value: string) => setFilter(value as HaltFilter), [setFilter]);
@@ -235,6 +246,7 @@ export function MarketHaltsPane({ focused, width, height }: PaneProps) {
235
246
  getItemKey={(row) => row.id}
236
247
  onActivate={openTicker}
237
248
  renderCell={renderCell}
249
+ isRowMuted={isAfterPin}
238
250
  emptyStateTitle={haltsEmptyTitle(filter)}
239
251
  />
240
252
  </Box>
@@ -23,15 +23,8 @@ export interface NewsRowCell {
23
23
  attributes?: number;
24
24
  }
25
25
 
26
- /** A story out after a moment the list is pinned to reads muted and plain throughout. */
27
- interface NewsRowTone {
28
- later?: boolean;
29
- }
30
-
31
- const tone = (color: string, { later = false }: NewsRowTone) => later ? colors.textMuted : color;
32
-
33
- export function newsTimeCell(article: MarketNewsItem, options: NewsRowTone = {}): NewsRowCell {
34
- return { text: formatFeedTime(article.publishedAt), color: tone(colors.textDim, options) };
26
+ export function newsTimeCell(article: MarketNewsItem): NewsRowCell {
27
+ return { text: formatFeedTime(article.publishedAt), color: colors.textDim };
35
28
  }
36
29
 
37
30
  export function newsSourceCell(article: MarketNewsItem): NewsRowCell {
@@ -40,12 +33,12 @@ export function newsSourceCell(article: MarketNewsItem): NewsRowCell {
40
33
 
41
34
  export function newsHeadlineCell(
42
35
  article: MarketNewsItem,
43
- { read = false, title, ...options }: NewsRowTone & { read?: boolean; title?: string } = {},
36
+ { read = false, title }: { read?: boolean; title?: string } = {},
44
37
  ): NewsRowCell {
45
38
  return {
46
39
  // A row standing for a run of routine notices says how many after its headline.
47
40
  text: title ?? listedHeadline(article),
48
- color: tone(colors.text, options),
49
- attributes: options.later || read ? TextAttributes.NONE : TextAttributes.BOLD,
41
+ color: colors.text,
42
+ attributes: read ? TextAttributes.NONE : TextAttributes.BOLD,
50
43
  };
51
44
  }