@gloom-sh/terminal 0.19.5 → 0.19.6

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 (208) hide show
  1. package/package.json +1 -1
  2. package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
  3. package/src/api-client/equity-screener.ts +23 -0
  4. package/src/app/pane-runtime/index.tsx +2 -0
  5. package/src/app/pane-runtime/plugin-bindings.ts +10 -1
  6. package/src/app.tsx +63 -16
  7. package/src/cli/commands/market.ts +149 -10
  8. package/src/cli/commands/search.ts +21 -3
  9. package/src/cli/commands/ticker.ts +74 -33
  10. package/src/cli/glossary.ts +3 -3
  11. package/src/cli/known-gaps.ts +8 -0
  12. package/src/cli/listing-arg.ts +12 -0
  13. package/src/cli/pane-functions/capabilities.ts +2 -0
  14. package/src/cli/pane-functions/catalog.ts +22 -4
  15. package/src/cli/pane-functions/function-help.ts +8 -5
  16. package/src/cli/pane-functions/headless.ts +4 -3
  17. package/src/cli/pane-functions/resolver.ts +75 -2
  18. package/src/cli/quote-answer.ts +9 -0
  19. package/src/cli/symbol-list.ts +54 -2
  20. package/src/cli/symbol-rows.ts +14 -2
  21. package/src/cli/ticker-resolution.ts +89 -20
  22. package/src/components/chart/composite/axis-overlays.tsx +60 -27
  23. package/src/components/chart/composite/composite-chart.tsx +118 -63
  24. package/src/components/chart/composite/cursor-source.ts +111 -0
  25. package/src/components/chart/composite/format.ts +168 -6
  26. package/src/components/chart/composite/legend.tsx +8 -4
  27. package/src/components/chart/composite/panel-labels.ts +20 -1
  28. package/src/components/chart/composite/panel-surface.tsx +201 -92
  29. package/src/components/chart/composite/price-axis-labels.tsx +92 -46
  30. package/src/components/chart/composite/price-series.ts +31 -8
  31. package/src/components/chart/composite/scene.ts +154 -59
  32. package/src/components/chart/composite/series-axis-tags.tsx +4 -2
  33. package/src/components/chart/composite/time-axis.ts +13 -5
  34. package/src/components/chart/composite/time-scale.ts +211 -56
  35. package/src/components/chart/composite/types.ts +11 -1
  36. package/src/components/chart/composite/use-composite-chart-keyboard.ts +32 -12
  37. package/src/components/chart/curve/curve-surface.tsx +5 -2
  38. package/src/components/chart/curve/model.ts +4 -1
  39. package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
  40. package/src/components/chart/static/series.ts +3 -0
  41. package/src/components/command-bar/commands/collection-list.ts +81 -0
  42. package/src/components/command-bar/commands/direct/index.ts +6 -0
  43. package/src/components/command-bar/commands/registry.ts +8 -0
  44. package/src/components/command-bar/layout-items/current-layout.ts +22 -1
  45. package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
  46. package/src/components/command-bar/pane-templates/items.ts +19 -3
  47. package/src/components/command-bar/pane-templates/workflow.ts +5 -0
  48. package/src/components/command-bar/routes/root/results.ts +23 -3
  49. package/src/components/command-bar/routes/root/selection.ts +4 -2
  50. package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
  51. package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
  52. package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
  53. package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
  54. package/src/components/command-bar/surface/environment.ts +2 -0
  55. package/src/components/command-bar/view-model.ts +7 -0
  56. package/src/components/command-bar/workflow/ops.ts +2 -1
  57. package/src/components/command-bar/workflow/tickers.ts +20 -0
  58. package/src/components/layout/shell/menu.ts +15 -1
  59. package/src/components/layout/shell/pane/actions.ts +4 -0
  60. package/src/components/layout/shell/ticker-link-menu.ts +12 -3
  61. package/src/components/layout/status-bar.tsx +20 -0
  62. package/src/components/onboarding/onboarding-keyboard.ts +5 -1
  63. package/src/components/onboarding/onboarding-wizard.tsx +15 -4
  64. package/src/components/onboarding/portfolio-step/positions-panel.tsx +8 -5
  65. package/src/components/onboarding/use-onboarding-progress.ts +20 -1
  66. package/src/components/price-sparkline/view.tsx +14 -6
  67. package/src/components/ticker/badge/index.tsx +8 -4
  68. package/src/components/ticker/badge/list.tsx +23 -7
  69. package/src/components/ui/column-grid.tsx +8 -2
  70. package/src/components/ui/data-table/opentui/model.ts +4 -1
  71. package/src/components/ui/tabs.tsx +5 -2
  72. package/src/core/state/app/layout.ts +18 -3
  73. package/src/core/state/app/state.ts +2 -0
  74. package/src/core/state/app/types.ts +5 -0
  75. package/src/data/config/layout.ts +3 -0
  76. package/src/data/config/store/normalize.ts +39 -4
  77. package/src/i18n/es.ts +10 -0
  78. package/src/i18n/ja.ts +10 -0
  79. package/src/i18n/ko.ts +10 -0
  80. package/src/i18n/zh-cn.ts +10 -0
  81. package/src/i18n/zh-tw.ts +10 -0
  82. package/src/layout/pane-manager/floating-placement.ts +7 -4
  83. package/src/layout/pane-manager/floating.ts +5 -2
  84. package/src/market-data/bond-funds.ts +19 -0
  85. package/src/market-data/futures-contract.ts +14 -3
  86. package/src/market-data/market/freshness.ts +18 -0
  87. package/src/market-data/market/status.ts +15 -2
  88. package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
  89. package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
  90. package/src/plugins/builtin/bond-calculator/model.ts +14 -5
  91. package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
  92. package/src/plugins/builtin/buildout/cells.tsx +25 -45
  93. package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
  94. package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
  95. package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
  96. package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
  97. package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
  98. package/src/plugins/builtin/buildout/format.ts +23 -1
  99. package/src/plugins/builtin/buildout/model/types.ts +1 -0
  100. package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
  101. package/src/plugins/builtin/buildout/table-model.ts +12 -4
  102. package/src/plugins/builtin/cds/headless.ts +1 -0
  103. package/src/plugins/builtin/cds/index.tsx +1 -1
  104. package/src/plugins/builtin/cloud/plugin.tsx +2 -0
  105. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +28 -3
  106. package/src/plugins/builtin/correlation/headless.ts +3 -2
  107. package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
  108. package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
  109. package/src/plugins/builtin/debt-maturities/model.ts +66 -0
  110. package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
  111. package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
  112. package/src/plugins/builtin/econ/calendar-model.ts +28 -6
  113. package/src/plugins/builtin/equity-screener/client.ts +1 -1
  114. package/src/plugins/builtin/equity-screener/criterion-editor.tsx +4 -16
  115. package/src/plugins/builtin/equity-screener/headless.ts +4 -2
  116. package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
  117. package/src/plugins/builtin/equity-screener/model.ts +180 -12
  118. package/src/plugins/builtin/equity-screener/pane.tsx +52 -12
  119. package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
  120. package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
  121. package/src/plugins/builtin/futures-curve/client.ts +19 -0
  122. package/src/plugins/builtin/futures-curve/headless.ts +52 -13
  123. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  124. package/src/plugins/builtin/futures-curve/model.ts +77 -6
  125. package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
  126. package/src/plugins/builtin/macro-day/client.ts +41 -0
  127. package/src/plugins/builtin/macro-day/headless.ts +19 -9
  128. package/src/plugins/builtin/macro-day/model.ts +3 -1
  129. package/src/plugins/builtin/market-movers/index.tsx +4 -3
  130. package/src/plugins/builtin/mna/distress/headless.ts +1 -0
  131. package/src/plugins/builtin/perps/pane.tsx +3 -1
  132. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
  133. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
  134. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
  135. package/src/plugins/builtin/rate-path/headless.ts +24 -10
  136. package/src/plugins/builtin/research/event-model.ts +10 -3
  137. package/src/plugins/builtin/research/events-headless.ts +20 -2
  138. package/src/plugins/builtin/sec/fund-facts.ts +17 -1
  139. package/src/plugins/builtin/sec/index.tsx +1 -1
  140. package/src/plugins/builtin/shared/members-menu.tsx +103 -38
  141. package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
  142. package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
  143. package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
  144. package/src/plugins/builtin/time-sales/pane.tsx +3 -2
  145. package/src/plugins/builtin/trace-bonds/client.ts +7 -4
  146. package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
  147. package/src/plugins/builtin/volatility/client.ts +6 -1
  148. package/src/plugins/builtin/volatility/headless.ts +0 -1
  149. package/src/plugins/builtin/yield-curve/curves.ts +15 -0
  150. package/src/plugins/builtin/yield-curve/headless.ts +6 -1
  151. package/src/plugins/builtin/yield-curve/index.tsx +5 -8
  152. package/src/plugins/host-modules.ts +22 -3
  153. package/src/plugins/host-smoke.ts +6 -3
  154. package/src/portfolio/collection-name.ts +19 -0
  155. package/src/renderers/browser/http-proxy-transport.ts +78 -8
  156. package/src/renderers/cloudflare/http-proxy.ts +13 -2
  157. package/src/renderers/cloudflare/proxy-session.ts +47 -24
  158. package/src/renderers/cloudflare/worker.ts +15 -2
  159. package/src/renderers/desktop/geometry.ts +279 -0
  160. package/src/renderers/desktop/screen-setup.ts +246 -0
  161. package/src/renderers/desktop/sequential-window-host.ts +179 -0
  162. package/src/renderers/desktop/test-utils.ts +71 -0
  163. package/src/renderers/desktop/window-controller.ts +433 -0
  164. package/src/renderers/desktop/window-host.ts +70 -0
  165. package/src/renderers/desktop/window-layouts.ts +630 -0
  166. package/src/renderers/dom/data-frames.ts +15 -4
  167. package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
  168. package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
  169. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
  170. package/src/renderers/electrobun/bun/desktop/backend.ts +320 -19
  171. package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
  172. package/src/renderers/electrobun/bun/desktop/host-requests.ts +4 -14
  173. package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
  174. package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
  175. package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
  176. package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
  177. package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
  178. package/src/renderers/electrobun/bun/index.ts +4 -97
  179. package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
  180. package/src/renderers/electrobun/bun/window/focus.ts +0 -25
  181. package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
  182. package/src/renderers/electrobun/shared/protocol.ts +44 -2
  183. package/src/renderers/electrobun/view/backend-rpc.ts +15 -0
  184. package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
  185. package/src/renderers/electrobun/view/main.tsx +13 -7
  186. package/src/series/fred-argument.ts +17 -0
  187. package/src/sources/provider-router/financial-routes.ts +7 -1
  188. package/src/state/app/context/index.tsx +16 -2
  189. package/src/state/desktop-windows.ts +63 -0
  190. package/src/sync/other-window-tabs.ts +62 -0
  191. package/src/tickers/company-name-listing.ts +23 -3
  192. package/src/tickers/listing-fate.ts +147 -1
  193. package/src/tickers/terminal-codes.ts +5 -0
  194. package/src/time-series/types.ts +6 -0
  195. package/src/types/config.ts +10 -1
  196. package/src/types/desktop-window.ts +71 -2
  197. package/src/types/financials.ts +4 -0
  198. package/src/types/headless.ts +19 -0
  199. package/src/types/plugin.ts +6 -0
  200. package/src/ui/index.tsx +14 -13
  201. package/src/ui/same-props.ts +58 -0
  202. package/src/utils/cli-output.ts +33 -4
  203. package/src/utils/format.ts +7 -2
  204. package/src/utils/futures-generic.ts +12 -0
  205. package/src/utils/http-proxy-upstream.ts +6 -2
  206. package/src/utils/plugin-proxy-hosts.json +0 -4
  207. package/src/utils/plugin-proxy-hosts.ts +22 -0
  208. package/src/utils/sec-filings.ts +7 -1
@@ -76,6 +76,47 @@ export async function loadMacroDayHistory(
76
76
  }
77
77
  }
78
78
 
79
+ /** A FRED series read as closes: its daily values, and whether a value is a rate, whose moves read in bp. */
80
+ export interface MacroDaySeriesHistory extends MacroDayHistory {
81
+ /** The series is in percent (a yield or a spread such as T10Y2Y): a move is the change in its level. */
82
+ rate: boolean;
83
+ /** FRED's title for it, "10-Year Treasury Constant Maturity Minus 2-Year Treasury Constant Maturity". */
84
+ title: string | null;
85
+ }
86
+
87
+ /** The five years of daily values a release-day study reads, as the price history is. */
88
+ const SERIES_LOOKBACK_DAYS = 5 * 366;
89
+
90
+ /**
91
+ * A FRED series (`FRED:T10Y2Y`) as the study's closes: each dated value, with
92
+ * blank days (holidays FRED lists as no value) left out. A rate or spread in
93
+ * percent moves by its level, read in basis points; any other series by its
94
+ * return. Never rejects but on cancel.
95
+ */
96
+ export async function loadMacroDaySeriesHistory(
97
+ request: { seriesId: string; signal?: AbortSignal },
98
+ client: Pick<typeof apiClient, "getCloudFredSeries"> = apiClient,
99
+ now = Date.now(),
100
+ ): Promise<MacroDaySeriesHistory> {
101
+ if (request.signal?.aborted) throw abortError(CANCELLED);
102
+ const startDate = new Date(now - SERIES_LOOKBACK_DAYS * 86_400_000).toISOString().slice(0, 10);
103
+ try {
104
+ const payload = await abortable(client.getCloudFredSeries(request.seriesId, { startDate, sortOrder: "asc" },
105
+ request.signal ? { signal: request.signal } : {}), request.signal, CANCELLED);
106
+ const history = payload.observations
107
+ .filter((point) => typeof point.value === "number" && Number.isFinite(point.value) && /^\d{4}-\d{2}-\d{2}$/.test(point.date))
108
+ .map((point) => ({ date: new Date(`${point.date}T00:00:00Z`), close: point.value! }))
109
+ .sort((left, right) => left.date.getTime() - right.date.getTime());
110
+ const fetchedAt = payload.fetchedAt ? Date.parse(payload.fetchedAt) : now;
111
+ return { history, stale: payload.stale === true, error: history.length ? null : `No values for FRED:${request.seriesId}`,
112
+ fetchedAt: Number.isFinite(fetchedAt) ? fetchedAt : now,
113
+ rate: /^percent\b/i.test(payload.info?.units?.trim() ?? ""), title: payload.info?.title?.trim() || null };
114
+ } catch (error) {
115
+ if (request.signal?.aborted || (error instanceof Error && error.name === "AbortError")) throw abortError(CANCELLED);
116
+ return { history: [], stale: false, error: errorMessage(error), fetchedAt: now, rate: false, title: null };
117
+ }
118
+ }
119
+
79
120
  export interface MacroDayEarnings {
80
121
  reports: MacroDayEarningsReport[];
81
122
  stale: boolean;
@@ -1,6 +1,7 @@
1
1
  import type { HeadlessPaneDefinition } from "../../../types/plugin";
2
2
  import { resolveHeadlessInstrument } from "../shared/headless-market-data";
3
- import { loadMacroDayEarnings, loadMacroDayHistory, loadMacroReleases, macroDayEarningsNotice } from "./client";
3
+ import { loadMacroDayEarnings, loadMacroDayHistory, loadMacroDaySeriesHistory, loadMacroReleases, macroDayEarningsNotice, type MacroDayEarnings } from "./client";
4
+ import { fredSeriesArgument } from "../../../series/fred-argument";
4
5
  import { formatMacroDayMove, macroDayEventLabel, macroDayStats, matchesSurprise, projectMacroDays, type MacroDayStats } from "./model";
5
6
  import { MACRO_EVENT_KINDS, MACRO_EVENT_LABELS, MACRO_RELEASE_SOURCES, MACRO_SURPRISE_LABELS, MACRO_SURPRISES, staleMacroReleasesNotice,
6
7
  type MacroEventKind, type MacroSurprise } from "./releases";
@@ -11,13 +12,15 @@ const multiple = (value: unknown) => typeof value === "number" ? `${value.toFixe
11
12
  const share = (value: unknown) => typeof value === "number" ? `${Math.round(value * 100)}%` : "--";
12
13
 
13
14
  export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
14
- shape: "bundle", argument: { kind: "ticker", description: "Ticker" },
15
+ shape: "bundle", argument: { kind: "ticker", description: "Ticker, or a FRED series such as FRED:T10Y2Y", examples: ["TLT", "FRED:T10Y2Y"] },
15
16
  usListingsOnly: "Macro release day data",
17
+ // A spread the catalog prints (FRED:T10Y2Y) moves on release days too: its moves in bp.
18
+ fredSeriesArgument: true,
16
19
  // Dated by the release list (releasesThrough) as much as by the closes, so no session schedule applies.
17
20
  freshness: { status: "not-a-feed", basis: "release-day study on daily closes" },
18
21
  describe: (args) => `MDAY ${args.symbols[0] ?? ""}`,
19
22
  discovery: { screenshotReadiness: "live-dom", limitations: [
20
- "US listings; close-to-close on the release day.",
23
+ "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.",
21
24
  "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.",
22
25
  "Actual, forecast and prior for the days Gloom Cloud has them (the US headlines from its kept economic calendar, IPCA from the central bank's SGS series); --surprise keeps the days that came in hot, cool or in line with the forecast.",
23
26
  "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.",
@@ -31,11 +34,18 @@ export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
31
34
  { key: "lookbackYears", type: "integer", minimum: 1, maximum: 5, defaultValue: 5, description: "Years of daily closes" },
32
35
  ],
33
36
  async load(args, ctx) {
34
- const instrument = await resolveHeadlessInstrument(ctx, args.symbols[0]!);
35
- const [history, releases, earnings] = await Promise.all([loadMacroDayHistory({ instrument, signal: ctx.signal }, ctx.marketData), loadMacroReleases(),
36
- loadMacroDayEarnings({ instrument, signal: ctx.signal })]);
37
+ // FRED:T10Y2Y is a series, read from FRED: it has no earnings, and a rate or spread moves by its level.
38
+ const seriesId = fredSeriesArgument(args.symbols[0]!);
39
+ const instrument = seriesId ? null : await resolveHeadlessInstrument(ctx, args.symbols[0]!);
40
+ const symbol = instrument?.symbol ?? `FRED:${seriesId}`;
41
+ const [history, releases, earnings] = await Promise.all([
42
+ instrument ? loadMacroDayHistory({ instrument, signal: ctx.signal }, ctx.marketData) : loadMacroDaySeriesHistory({ seriesId: seriesId!, signal: ctx.signal }, ctx.apiClient),
43
+ loadMacroReleases(),
44
+ instrument ? loadMacroDayEarnings({ instrument, signal: ctx.signal }) : Promise.resolve<MacroDayEarnings>({ reports: [], stale: false, error: null }),
45
+ ]);
46
+ const basis = "rate" in history ? history.rate ? "yield" as const : "return" as const : undefined;
37
47
  ctx.signal.throwIfAborted();
38
- const model = projectMacroDays(history.history, { symbol: instrument.symbol, lookbackYears: Number(args.options.lookbackYears) || 5,
48
+ const model = projectMacroDays(history.history, { symbol, basis, lookbackYears: Number(args.options.lookbackYears) || 5,
39
49
  releases: releases.releases, coveredThrough: releases.coveredThrough, earnings: earnings.reports });
40
50
  const notes = [staleMacroReleasesNotice(releases), macroDayEarningsNotice(earnings)].filter((note): note is string => !!note);
41
51
  const row = (label: string, stats: MacroDayStats) => ({ label, ...stats });
@@ -67,10 +77,10 @@ export const macroDayHeadless: HeadlessPaneDefinition<"bundle"> = {
67
77
  ...(figures ? { headline: figures.event } : {}) })) },
68
78
  ],
69
79
  complete: !history.stale && !earnings.stale && !history.error && !notes.length && model.events.length > 0,
70
- unavailableSymbols: model.events.length ? [] : [instrument.symbol],
80
+ unavailableSymbols: model.events.length ? [] : [symbol],
71
81
  errors: history.error ? [history.error] : [],
72
82
  ...(notes.length ? { notes } : {}),
73
- metadata: { unit: yieldMoves ? "change in the yield in percentage points, close to close on the release day"
83
+ metadata: { unit: yieldMoves ? `change in the ${seriesId ? "rate" : "yield"} in percentage points, close to close on the release day`
74
84
  : "decimal return, close to close on the release day", start: model.start, asOf: model.asOf,
75
85
  releasesThrough: releases.coveredThrough, releaseSources: Object.values(MACRO_RELEASE_SOURCES),
76
86
  stale: history.stale || earnings.stale, fetchedAt: history.fetchedAt, methodology: "docs/research-data.md#macro-day-reaction" },
@@ -164,6 +164,8 @@ const US_KINDS: ReadonlySet<MacroEventKind> = new Set(US_MACRO_EVENT_KINDS);
164
164
  */
165
165
  export function projectMacroDays(history: readonly PricePoint[], options: {
166
166
  symbol: string;
167
+ /** How a move is measured when the symbol does not say: a FRED rate or spread moves by its level, in bp. */
168
+ basis?: MacroDayMoveBasis;
167
169
  lookbackYears: number;
168
170
  releases: readonly MacroRelease[];
169
171
  /** The release list's last covered day. */
@@ -172,7 +174,7 @@ export function projectMacroDays(history: readonly PricePoint[], options: {
172
174
  earnings?: readonly MacroDayEarningsReport[];
173
175
  }): MacroDayModel {
174
176
  const { coveredThrough } = options;
175
- const basis = macroDayMoveBasis(options.symbol);
177
+ const basis = options.basis ?? macroDayMoveBasis(options.symbol);
176
178
  const byDate = new Map<string, number>();
177
179
  for (const point of history) {
178
180
  const time = new Date(point.date).getTime();
@@ -114,12 +114,13 @@ function MarketMoversPane({ focused, width, height }: PaneProps) {
114
114
  .filter((quote): quote is MarketSummaryQuote => !!quote)
115
115
  ), [summaryBoard, summarySymbols]);
116
116
 
117
- const tabItems = tabs.map((tab) => ({ label: tab.label, value: tab.id }));
118
- const selectTab = (value: string) => {
117
+ // Kept between quotes, so the tab strip skips the renders a board update gives the pane.
118
+ const tabItems = useMemo(() => tabs.map((tab) => ({ label: tab.label, value: tab.id })), [tabs]);
119
+ const selectTab = useCallback((value: string) => {
119
120
  setSavedTab(value as TabId);
120
121
  setPickedIn(session.key);
121
122
  if (requestedTab) setRequestedTab(null);
122
- };
123
+ }, [requestedTab, session.key, setPickedIn, setRequestedTab, setSavedTab]);
123
124
  const { strip: tabStrip } = usePaneTabs({ tabs: tabItems, activeValue: activeTab, onSelect: selectTab, focused, compact: true, variant: "bare" });
124
125
 
125
126
  return (
@@ -146,6 +146,7 @@ export const distressHeadless: HeadlessPaneDefinition<"rows"> = {
146
146
  argument: { kind: "none" },
147
147
  discovery: {
148
148
  aliases: ["DIST"],
149
+ intents: ["distressed exchange", "chapter 11", "bankruptcy", "missed payment", "forbearance", "going concern", "covenant waiver", "delisting notice"],
149
150
  dataRequirements: ["Public SEC EDGAR filings and financial statement notes, TWSE and TPEx open data, BODACC and The Gazette notices"],
150
151
  limitations: [
151
152
  "A company missing from a list may still be in difficulty; absence is not a finding.",
@@ -411,7 +411,9 @@ export function PerpsPane({ width, height, focused, marketAction }: Pick<PanePro
411
411
  }, [assetOnly, carried, compareAsset, marketTab, setSearch, setCompareAsset, setTab]);
412
412
  const openMarket = useCallback((row: PerpBoardRow, next: PerpTab = openingTab(row.marketId, access.hasProAccess)) => { setSearch(row.marketId); setTab(next); }, [setSearch, setTab, access.hasProAccess]);
413
413
  const openMarketId = useCallback((marketId: string) => { setSearch(marketId); setTab(openingTab(marketId, access.hasProAccess)); }, [setSearch, setTab, access.hasProAccess]);
414
- const { strip, rows: tabRows } = usePaneTabs({ tabs: PERP_TABS.map((value) => ({ value, label: label(value) })), activeValue: tab, onSelect: selectTab, focused, dense: true });
414
+ // Kept between board updates, so the tab strip skips the renders they give the pane.
415
+ const tabItems = useMemo(() => PERP_TABS.map((value) => ({ value, label: label(value) })), []);
416
+ const { strip, rows: tabRows } = usePaneTabs({ tabs: tabItems, activeValue: tab, onSelect: selectTab, focused, dense: true });
415
417
  const refreshMarket = useCallback(() => { void resource.reload(); }, [resource.reload]);
416
418
  useAutoRefresh(resource.updatedAt, resource.load, { intervalMs: 60_000 });
417
419
  usePaneRefreshKey(refreshMarket, { focused: focused && marketTab && !querySearch.active && (tab !== "history" || !active) });
@@ -237,6 +237,23 @@ export function retryNotice(ctx: CliCommandContext): (count: number, waitMs: num
237
237
  };
238
238
  }
239
239
 
240
+ /** A list this long says how far its lookup has got, so a long add never looks stuck. */
241
+ const PROGRESS_FROM = 50;
242
+ const PROGRESS_EVERY_MS = 5_000;
243
+
244
+ /**
245
+ * Lines on standard error while a long add looks its symbols up: "Looked up
246
+ * 120 of 300 symbols." every few seconds, and nothing for a short list.
247
+ */
248
+ export function progressNotice(ctx: CliCommandContext, now = () => Date.now()): (looked: number, total: number) => void {
249
+ let last = now();
250
+ return (looked, total) => {
251
+ if (ctx.cliOptions.quiet || total < PROGRESS_FROM || looked >= total || now() - last < PROGRESS_EVERY_MS) return;
252
+ last = now();
253
+ console.error(cliStyles.muted(`Looked up ${looked} of ${total} symbols.`));
254
+ };
255
+ }
256
+
240
257
  /**
241
258
  * The symbols an add or remove was given, failing the command when there are
242
259
  * none or the file cannot be read. An add reads a typed company's name with
@@ -74,7 +74,7 @@ import {
74
74
  requirePortfolio,
75
75
  takeCollectionName,
76
76
  } from "./shared";
77
- import { addOneSymbol, addSymbols, FILE_OPTION, printSymbolRows, removeSymbols, requireSymbolList, retryNotice, shellWord, SYMBOL_LIST_HELP } from "./bulk-symbols";
77
+ import { addOneSymbol, addSymbols, FILE_OPTION, printSymbolRows, progressNotice, removeSymbols, requireSymbolList, retryNotice, shellWord, SYMBOL_LIST_HELP } from "./bulk-symbols";
78
78
  import { readNameEntries } from "../../../../cli/name-entries";
79
79
  import { DRIP_DEFAULT_YEARS, DRIP_MAX_YEARS, parseDripYears, parseWithholding } from "../income";
80
80
 
@@ -263,6 +263,7 @@ async function addToPortfolioCommand(args: string[], file: string | undefined, e
263
263
  suggest: true,
264
264
  dryRun,
265
265
  onRetry: retryNotice(ctx),
266
+ onProgress: progressNotice(ctx),
266
267
  retry,
267
268
  add: (ticker) => addTickerToPortfolio(ticker, portfolio.id),
268
269
  });
@@ -22,7 +22,7 @@ import {
22
22
  } from "../../../../portfolio/mutations";
23
23
  import { showCollection } from "./render";
24
24
  import { listingFields, misplacedSymbolList, refuseDryRun, takeCollectionName } from "./shared";
25
- import { addOneSymbol, addSymbols, FILE_OPTION, printSymbolRows, removeSymbols, requireSymbolList, retryNotice, shellWord, SYMBOL_LIST_HELP } from "./bulk-symbols";
25
+ import { addOneSymbol, addSymbols, FILE_OPTION, printSymbolRows, progressNotice, removeSymbols, requireSymbolList, retryNotice, shellWord, SYMBOL_LIST_HELP } from "./bulk-symbols";
26
26
  import { readNameEntries } from "../../../../cli/name-entries";
27
27
  import { CLI_COMMAND_GROUPS } from "../../../../cli/help";
28
28
 
@@ -123,6 +123,7 @@ async function addToWatchlistCommand(args: string[], file: string | undefined, e
123
123
  store: market.store,
124
124
  dataProvider: market.dataProvider,
125
125
  onRetry: retryNotice(ctx),
126
+ onProgress: progressNotice(ctx),
126
127
  retry,
127
128
  suggest: true,
128
129
  dryRun,
@@ -1,4 +1,4 @@
1
- import type { RateMeeting } from "../../../api-client/rates";
1
+ import type { RateMeeting, RatePathPayload } from "../../../api-client/rates";
2
2
  import type { HeadlessPaneColumn, HeadlessPaneDefinition } from "../../../types/plugin";
3
3
  import { fetchRatePath } from "./client";
4
4
  import { meetingMoves, moveOddsText, movesPriced, movesText, rateText } from "./model";
@@ -25,8 +25,9 @@ const probabilities = (value: unknown) => {
25
25
  : outcomes.map((outcome) => `${outcome.targetMidpoint.toFixed(3)}% ${(outcome.probability * 100).toFixed(0)}%`).join(" / ");
26
26
  };
27
27
 
28
+ const STALE_COLUMN: HeadlessPaneColumn = { key: "stale", header: "Data stale", stackPriority: 2, format: yesNo };
28
29
  // A narrow terminal leaves out the sample count, status, percentile and quote time (the closing line has it),
29
- // then moves the staleness and month under each row.
30
+ // then moves the month under each row.
30
31
  const contractColumns: HeadlessPaneColumn[] = [
31
32
  { key: "symbol", header: "Symbol", shrink: false }, { key: "month", header: "Month", shrink: false, stackPriority: 1 },
32
33
  { key: "price", header: "Price", align: "right", format: (value) => finiteOrNull(value)?.toFixed(3) ?? "--" },
@@ -34,8 +35,17 @@ const contractColumns: HeadlessPaneColumn[] = [
34
35
  { key: "percentile", header: "Pctl 1Y", align: "right", stackPriority: 4, stackRows: 0, format: pctl },
35
36
  { key: "samples", header: "Samples", align: "right", stackPriority: 6, stackRows: 0 },
36
37
  { key: "asOf", header: "As of UTC", shrink: false, stackPriority: 3, stackRows: 0, format: timestamp },
37
- { key: "status", header: "Status", stackPriority: 5, stackRows: 0 }, { key: "stale", header: "Data stale", stackPriority: 2, format: yesNo },
38
+ { key: "status", header: "Status", stackPriority: 5, stackRows: 0 }, STALE_COLUMN,
38
39
  ];
40
+ /** The text says once which rows are stale, under the tables (`staleNote`), not "no" on every row; JSON keeps the column. */
41
+ const textColumns = (columns: HeadlessPaneColumn[]) => columns.filter((column) => column.key !== "stale");
42
+
43
+ /** "Stale: Effective fed funds rate, ZQX26.CBT.", naming each row whose figure is stale; null when none is. */
44
+ function staleNote(data: Pick<RatePathPayload, "current" | "fedFunds" | "sofr">): string | null {
45
+ const stale = [...Object.entries(data.current).filter(([, metric]) => metric.stale).map(([name]) => policyLabel(name)),
46
+ ...[...data.fedFunds, ...data.sofr].filter((contract) => contract.stale && contract.status !== "unavailable").map((contract) => contract.symbol)];
47
+ return stale.length ? `Stale: ${stale.join(", ")}.` : null;
48
+ }
39
49
 
40
50
  /**
41
51
  * How far the fed funds and SOFR futures quotes are held back. The rate-path
@@ -60,14 +70,17 @@ export const ratePathHeadless: HeadlessPaneDefinition<"bundle"> = {
60
70
  // (FRED) keep their own date and stale flag in their table, and the meetings are read from the contracts.
61
71
  const contracts = [...data.fedFunds, ...data.sofr].filter((contract) => contract.status !== "unavailable")
62
72
  .map(({ asOf, stale }) => ({ asOf, stale }));
73
+ const policyColumns: HeadlessPaneColumn[] = [
74
+ { key: "name", header: "Name", minWidth: 18, format: policyLabel }, { key: "value", header: "Value", align: "right", format: rate },
75
+ { key: "asOf", header: "As of", shrink: false }, { key: "percentile", header: "Pctl 1Y", align: "right", stackPriority: 1, format: pctl },
76
+ { key: "samples", header: "Samples", align: "right", stackPriority: 2, stackRows: 0 }, { key: "stale", header: "Data stale", format: yesNo },
77
+ ];
78
+ const stale = staleNote(data);
63
79
  return {
64
80
  freshness: { observedKey: "asOf", observations: contracts },
65
81
  sections: [
66
- { title: "Current policy", columns: [
67
- { key: "name", header: "Name", minWidth: 18, format: policyLabel }, { key: "value", header: "Value", align: "right", format: rate },
68
- { key: "asOf", header: "As of", shrink: false }, { key: "percentile", header: "Pctl 1Y", align: "right", stackPriority: 1, format: pctl },
69
- { key: "samples", header: "Samples", align: "right", stackPriority: 2, stackRows: 0 }, { key: "stale", header: "Data stale", format: yesNo },
70
- ], rows: Object.entries(data.current).map(([name, metric]) => ({ name, ...metric })) },
82
+ { title: "Current policy", columns: policyColumns, textColumns: textColumns(policyColumns),
83
+ rows: Object.entries(data.current).map(([name, metric]) => ({ name, ...metric })) },
71
84
  // A narrow terminal keeps the moves and change, prints the probabilities of the next two meetings
72
85
  // under their rows, and leaves out the rest; a reason a meeting has no rate stays under its row.
73
86
  { title: "FOMC meetings", columns: [
@@ -83,9 +96,10 @@ export const ratePathHeadless: HeadlessPaneDefinition<"bundle"> = {
83
96
  { key: "probabilities", header: "Probabilities", shrink: false, stackPriority: 4, stackRows: 2, format: probabilities },
84
97
  { key: "method", header: "Method", stackPriority: 9, stackRows: 0 }, { key: "reason", header: "Reason", stackPriority: 10 },
85
98
  ], rows: data.meetings.map((meeting) => ({ ...meeting, moves: movesPriced(meeting), moveOdds: moves.get(meeting.date) ?? null })) },
86
- { title: "Fed funds contracts", columns: contractColumns, rows: data.fedFunds.map((contract) => ({ ...contract })) },
87
- { title: "SOFR contracts", columns: contractColumns, rows: data.sofr.map((contract) => ({ ...contract })) },
99
+ { title: "Fed funds contracts", columns: contractColumns, textColumns: textColumns(contractColumns), rows: data.fedFunds.map((contract) => ({ ...contract })) },
100
+ { title: "SOFR contracts", columns: contractColumns, textColumns: textColumns(contractColumns), rows: data.sofr.map((contract) => ({ ...contract })) },
88
101
  ],
102
+ ...(stale ? { notes: [stale] } : {}),
89
103
  errors: data.gaps,
90
104
  metadata: { ...data, probabilityBasis: data.probabilityAssumption, units: "percent", complete: data.status === "available" },
91
105
  };
@@ -14,6 +14,7 @@ import {
14
14
  formatPercentRaw,
15
15
  } from "../../../utils/format";
16
16
  import { computeTTM } from "../ticker-detail/financials/aggregation";
17
+ import { classifyInstrumentType } from "../../../tickers/instrument-kind";
17
18
  import { declaredDividends } from "../../../utils/declared-dividends";
18
19
  import { fundamentalsEpsCurrency, SERVED_TRAILING_EPS } from "../../../utils/fundamentals";
19
20
  import {
@@ -180,10 +181,16 @@ function estimateValue(pair: EstimatePair): string {
180
181
  */
181
182
  export type EventFinancials = Pick<TickerFinancials, "quarterlyStatements" | "financialCurrency"> & {
182
183
  fundamentals?: Pick<NonNullable<TickerFinancials["fundamentals"]>, "eps" | "epsCurrency" | "financialCurrency" | "marketCapCurrency" | "trailingEpsSource"> | null;
183
- /** The listing's currency, which says whether an unlabelled EPS can be in the statements' (fundamentalsCurrency). */
184
- quote?: Pick<NonNullable<TickerFinancials["quote"]>, "currency"> | null;
184
+ /** The listing's currency, which says whether an unlabelled EPS can be in the statements' (fundamentalsCurrency), and its type. */
185
+ quote?: Pick<NonNullable<TickerFinancials["quote"]>, "currency" | "instrumentType"> | null;
186
+ quoteMetadata?: Pick<NonNullable<TickerFinancials["quoteMetadata"]>, "instrumentType"> | null;
185
187
  };
186
188
 
189
+ /** A fund (an ETF, a closed-end fund) reports no earnings: a feed's EPS rows for one are another company's or noise. */
190
+ function isFundListing(financials: EventFinancials | null): boolean {
191
+ return [financials?.quote?.instrumentType, financials?.quoteMetadata?.instrumentType].some((type) => classifyInstrumentType(type) === "fund");
192
+ }
193
+
187
194
  /**
188
195
  * The four reported rows behind the latest four statement quarters, summed, only when every one is on the adjusted
189
196
  * basis and in one currency. Quarters of different or unknown bases never add up to anything.
@@ -325,7 +332,7 @@ export function buildEventRows(
325
332
  ): EventRow[] {
326
333
  const rows: EventRow[] = [];
327
334
  const quarterlyStatements = sortedQuarterlyStatements(financials);
328
- const earnings = data?.earnings ?? [];
335
+ const earnings = isFundListing(financials) ? [] : data?.earnings ?? [];
329
336
  const ttm = ttmRow(quarterlyStatements, earnings, financials);
330
337
  if (ttm) rows.push(ttm);
331
338
 
@@ -12,6 +12,10 @@ import { buildEventRows, eventSourceNotice, CORPORATE_ACTION_COVERAGE } from "./
12
12
  import { EVENT_COLUMNS, loadEventSources } from "./event-sources";
13
13
  import { REPORTED_DATA } from "../shared/report-freshness";
14
14
  import { EPS_BASIS_NOTE } from "../shared/earnings-report";
15
+ import { loadNoQuoteLastTraded, noQuoteLastTradeNote, otherListingProfile } from "../../../tickers/listing-fate";
16
+ import { isUsSymbolVenue } from "../../../tickers/ticker-changes";
17
+ import { parsePublicTickerKey } from "../../../utils/exchanges";
18
+ import type { EventStatus } from "./event-model";
15
19
 
16
20
  interface EventHeadlessData {
17
21
  actions: CorporateActionsData | null;
@@ -23,6 +27,9 @@ interface EventHeadlessData {
23
27
  financialsError?: string | null;
24
28
  }
25
29
 
30
+ /** The rows drawn from the research served under a symbol (its reports and estimates), not from its own corporate actions. */
31
+ const RESEARCH_EVENTS: ReadonlySet<EventStatus> = new Set(["Earnings", "Q Est", "FY Est", "TTM"]);
32
+
26
33
  export interface EventsHeadlessDependencies {
27
34
  load(
28
35
  args: HeadlessPaneLoadArgs,
@@ -65,9 +72,20 @@ export function createEventsHeadless(
65
72
  const errors = [notice?.failed ? notice.text : null,
66
73
  data.financialsError ? `Financial statements unavailable: ${data.financialsError}` : null,
67
74
  ].filter((error): error is string => !!error);
75
+ // A symbol with no quote whose listing stopped trading says when it last traded. The issuer's own events after
76
+ // that stay (a cash-out, a liquidating distribution); only where the research served under the symbol is shown
77
+ // to be another listing's (STPP: a fund abroad's profile) are the reports and estimates after it dropped.
78
+ const lastTrade = data.financials?.quote ? null : await loadNoQuoteLastTraded({ symbol }, ctx.marketData);
79
+ const other = lastTrade ? otherListingProfile(data.financials?.profile, { usLine: isUsSymbolVenue(parsePublicTickerKey(symbol).exchange) }) : null;
80
+ const rows = buildEventRows(data.actions, data.estimates, data.financials, data.currency);
81
+ const own = lastTrade && other
82
+ ? rows.filter((row) => !RESEARCH_EVENTS.has(row.status) || row.date.slice(0, 10) <= lastTrade.date) : rows;
83
+ const hidden = rows.length - own.length;
84
+ const ended = lastTrade ? `${noQuoteLastTradeNote(symbol, lastTrade)}.${hidden > 0
85
+ ? ` ${hidden} later ${hidden === 1 ? "report is" : "reports are"} another listing's (${other}), not shown.` : ""}` : null;
68
86
  return {
69
- rows: buildEventRows(data.actions, data.estimates, data.financials, data.currency)
70
- .map((row) => ({ ...row })),
87
+ rows: own.map((row) => ({ ...row })),
88
+ ...(ended ? { notes: [ended] } : {}),
71
89
  errors: errors.length > 0 ? errors : undefined,
72
90
  metadata: { symbol, currency: data.currency, coverage: data.actions?.coverage,
73
91
  coverageNote: CORPORATE_ACTION_COVERAGE, epsBasis: EPS_BASIS_NOTE,
@@ -7,7 +7,7 @@ import { createPluginCache } from "../../../data/plugin-cache";
7
7
  import type { HeadlessPaneEntry } from "../../../types/plugin";
8
8
  import { errorMessage } from "../../../utils/errors";
9
9
  import { formatCompact } from "../../../utils/format";
10
- import { bondClassText, bondFigures } from "../../../market-data/bond-funds";
10
+ import { bondClassText, bondFigures, DV01_FROM_DURATION, durationDv01PerShare, formatDv01PerShare } from "../../../market-data/bond-funds";
11
11
  import { readFundFacts, validateFundFacts } from "../../../market-data/fund-facts";
12
12
  import { cachedCloudResource, loadCloudResource, unavailableOnServer } from "../shared/cloud-resource";
13
13
 
@@ -242,6 +242,8 @@ export function fundFactItems(facts: FundFactsPayload): StatItem[] {
242
242
  for (const figure of facts.bond ? bondFigures(facts.bond) : []) {
243
243
  items.push(cell(figure.key, figure.label, figure.text, { detail: figure.date, marked: facts.stale }));
244
244
  }
245
+ const dv01 = fundDv01(facts);
246
+ if (dv01) items.push(cell("dv01", "DV01", formatDv01PerShare(dv01.value), { detail: DV01_FROM_DURATION, marked: facts.stale }));
245
247
  // A metal trust's metal in trust, in tonnes as the market quotes it and ounces as the trust counts it, then its day's change.
246
248
  const metal = facts.metalHoldings;
247
249
  if (metal) {
@@ -267,6 +269,18 @@ export function fundFactItems(facts: FundFactsPayload): StatItem[] {
267
269
  return items;
268
270
  }
269
271
 
272
+ /**
273
+ * A bond fund's DV01 per share, derived from its duration at the closing
274
+ * price (NAV without one), with the price it was read at.
275
+ */
276
+ function fundDv01(facts: FundFactsPayload): { value: number; price: string } | null {
277
+ const price = facts.closingPrice ?? facts.nav;
278
+ const value = durationDv01PerShare(price?.value, facts.bond);
279
+ if (value == null || !price) return null;
280
+ const date = price.asOf ? ` ${price.asOf}` : "";
281
+ return { value, price: facts.closingPrice ? `closing price${date}` : `NAV${date}` };
282
+ }
283
+
270
284
  /** A DES figure: `warn` when it is older than it looks, which DES draws in the warning colour. */
271
285
  interface FundFactOverviewField {
272
286
  label: string;
@@ -373,6 +387,8 @@ export function fundFactEntries(facts: FundFactsPayload): HeadlessPaneEntry[] {
373
387
  add(keys[figure.key], figure.key === "secYield" ? "30-day SEC yield" : figure.label, figure.value,
374
388
  provenance(figure.text, figure.date, figure.source), figure.key === "duration" ? "years" : "%");
375
389
  }
390
+ const dv01 = fundDv01(facts);
391
+ if (dv01) add("dv01PerShare", "DV01", dv01.value, provenance(formatDv01PerShare(dv01.value), DV01_FROM_DURATION, dv01.price), "USD per bp");
376
392
  }
377
393
  if (facts.sponsor) add("sponsor", "Sponsor", facts.sponsor.value, facts.sponsor.value);
378
394
  if (facts.inception) add("inception", "Inception", facts.inception.value, facts.inception.value);
@@ -637,7 +637,7 @@ export const secModule: PluginModule = {
637
637
  label: "Fund Facts",
638
638
  description: "A US-listed fund's fee, NAV, premium or discount, net assets, sponsor, inception and index, a leveraged or inverse fund's daily objective, then the fund's own SEC filings: prospectus updates, shareholder reports, N-CEN and N-PORT.",
639
639
  keywords: ["etf", "fund", "expense ratio", "fee", "nav", "premium", "discount", "aum", "net assets", "n-1a", "485bpos", "497", "n-csr", "n-cen", "n-port", "prospectus",
640
- "leveraged", "inverse", "daily objective", "daily-reset", "decay"],
640
+ "leveraged", "inverse", "daily objective", "daily-reset", "decay", "bond fund", "duration", "dv01", "hedge ratio", "steepener"],
641
641
  shortcut: "ETF",
642
642
  viewKey: "etf",
643
643
  canCreate: (_context, options) => !options?.ticker || mayBeUsEquityOrFundTicker(options.ticker),