gloomberb 0.20.4 → 0.20.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 (316) hide show
  1. package/README.md +3 -1
  2. package/README.zh-CN.md +1 -1
  3. package/bin/gloom +9 -0
  4. package/bin/without-bun.cjs +98 -0
  5. package/package.json +4 -1
  6. package/src/api-client/data.ts +148 -37
  7. package/src/api-client/hk-tenders.ts +59 -0
  8. package/src/api-client/index.ts +1 -0
  9. package/src/api-client/types/econ.ts +30 -0
  10. package/src/api-client/yield-curves.ts +1 -1
  11. package/src/app/global-shortcuts.ts +4 -1
  12. package/src/app/keybindings/actions.ts +6 -0
  13. package/src/app/keybindings/config.ts +2 -1
  14. package/src/app/keybindings/index.ts +1 -0
  15. package/src/app/keybindings/labels.ts +6 -1
  16. package/src/app/keybindings/resolve.ts +23 -4
  17. package/src/app/keybindings/terminal-keys.ts +35 -0
  18. package/src/app/pane-runtime/index.tsx +2 -2
  19. package/src/app/pane-runtime/ticker-open-runtime.ts +68 -40
  20. package/src/app.tsx +18 -13
  21. package/src/architecture/floating-promise-allowlist.json +313 -0
  22. package/src/architecture/ui-literals-allowlist.json +1 -1
  23. package/src/capabilities/chart-series.ts +27 -1
  24. package/src/cli/commands/keybindings.ts +5 -5
  25. package/src/cli/commands/market.ts +238 -57
  26. package/src/cli/commands/news-search.ts +81 -14
  27. package/src/cli/commands/overview.ts +27 -6
  28. package/src/cli/commands/remote.ts +16 -17
  29. package/src/cli/commands/system.ts +1 -1
  30. package/src/cli/commands/ticker.ts +3 -1
  31. package/src/cli/early-command.ts +2 -0
  32. package/src/cli/errors.ts +10 -1
  33. package/src/cli/fx-forward.ts +89 -7
  34. package/src/cli/fx-pair.ts +1 -1
  35. package/src/cli/fx-quote-rate.ts +23 -0
  36. package/src/cli/glossary.ts +19 -5
  37. package/src/cli/help.ts +1 -0
  38. package/src/cli/history-rows.ts +5 -3
  39. package/src/cli/index-roots.ts +5 -4
  40. package/src/cli/index.ts +40 -3
  41. package/src/cli/known-gaps.ts +38 -9
  42. package/src/cli/listing-arg.ts +17 -5
  43. package/src/cli/name-entries.ts +5 -1
  44. package/src/cli/not-a-ticker.ts +4 -0
  45. package/src/cli/options.ts +52 -3
  46. package/src/cli/output-file.ts +5 -3
  47. package/src/cli/pane-functions/catalog.ts +15 -0
  48. package/src/cli/pane-functions/function-help.ts +4 -4
  49. package/src/cli/pane-functions/headless.ts +9 -4
  50. package/src/cli/pane-functions/index.ts +6 -4
  51. package/src/cli/pane-functions/resolver.ts +2 -2
  52. package/src/cli/result.ts +21 -2
  53. package/src/cli/spreadsheet-hint.ts +7 -3
  54. package/src/cli/treasury-yields.ts +5 -3
  55. package/src/components/chart/composite/legend.tsx +40 -2
  56. package/src/components/command-bar/pane-settings.ts +2 -2
  57. package/src/components/command-bar/routes/root/results.ts +6 -2
  58. package/src/components/command-bar/workflow/tickers.ts +2 -2
  59. package/src/components/data-table/view.tsx +9 -2
  60. package/src/components/input-search-bar.tsx +9 -2
  61. package/src/components/layout/pane/header.tsx +2 -0
  62. package/src/components/layout/shell/pane/capture.ts +4 -1
  63. package/src/components/layout/status-bar.tsx +6 -1
  64. package/src/components/onboarding/first-run-workspace.ts +44 -2
  65. package/src/components/onboarding/onboarding-frame.tsx +11 -2
  66. package/src/components/onboarding/onboarding-keyboard.ts +16 -0
  67. package/src/components/onboarding/onboarding-wizard.tsx +8 -8
  68. package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
  69. package/src/components/onboarding/use-onboarding-progress.ts +12 -4
  70. package/src/components/pane-settings-dialog/desktop.tsx +2 -2
  71. package/src/components/pane-settings-dialog/tui.tsx +2 -2
  72. package/src/components/pane-settings-dialog/value.ts +6 -0
  73. package/src/components/pane-settings-dialog.tsx +3 -3
  74. package/src/components/reader/detail-reader.tsx +4 -0
  75. package/src/components/ui/data-table/opentui/index.tsx +11 -4
  76. package/src/components/ui/data-table/opentui/model.ts +8 -6
  77. package/src/components/ui/data-table/types.ts +6 -1
  78. package/src/components/ui/index.ts +1 -1
  79. package/src/components/ui/page-stack-view.tsx +3 -0
  80. package/src/components/ui/pane-link-chip.tsx +269 -54
  81. package/src/components/ui/query-bar.tsx +2 -1
  82. package/src/components/ui/table-layout.ts +38 -1
  83. package/src/components/ui/tabs.tsx +97 -19
  84. package/src/core/state/app/layout-reducer.ts +7 -0
  85. package/src/core/state/app/layout.ts +44 -7
  86. package/src/core/state/app/state.ts +1 -1
  87. package/src/core/state/app/types.ts +22 -2
  88. package/src/docs/snapshot.json +30 -13
  89. package/src/market-data/depositary-pair.ts +5 -3
  90. package/src/market-data/market/change-basis.ts +9 -5
  91. package/src/market-data/market/dated-previous-close.ts +147 -17
  92. package/src/market-data/market/status.ts +17 -1
  93. package/src/market-data/quotes/contributions.ts +2 -0
  94. package/src/market-data/quotes/listing-enterprise-value.ts +50 -0
  95. package/src/plugins/builtin/alerts/metric-data.ts +15 -2
  96. package/src/plugins/builtin/analytics/risk-client.ts +10 -4
  97. package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
  98. package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
  99. package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
  100. package/src/plugins/builtin/awards/index.tsx +1 -1
  101. package/src/plugins/builtin/backtest/headless.ts +1 -1
  102. package/src/plugins/builtin/buildout/index.tsx +1 -0
  103. package/src/plugins/builtin/catalysts/index.tsx +2 -2
  104. package/src/plugins/builtin/cds/headless.ts +4 -0
  105. package/src/plugins/builtin/cds/model.ts +0 -6
  106. package/src/plugins/builtin/chart-composer/formula.ts +16 -3
  107. package/src/plugins/builtin/chart-composer/headless-schema.ts +2 -0
  108. package/src/plugins/builtin/chart-composer/headless.ts +4 -2
  109. package/src/plugins/builtin/chart-composer/index.tsx +1 -0
  110. package/src/plugins/builtin/chart-composer/presets.ts +1 -0
  111. package/src/plugins/builtin/chat/content/composer.tsx +5 -4
  112. package/src/plugins/builtin/chat/content/index.tsx +12 -2
  113. package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
  114. package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
  115. package/src/plugins/builtin/chat/layout.ts +5 -2
  116. package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
  117. package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
  118. package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
  119. package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
  120. package/src/plugins/builtin/cloud/askg/pane.tsx +55 -13
  121. package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
  122. package/src/plugins/builtin/cloud/terminal-relay/redact.ts +5 -3
  123. package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
  124. package/src/plugins/builtin/company-attention/index.tsx +1 -1
  125. package/src/plugins/builtin/company-kpis/headless.ts +3 -1
  126. package/src/plugins/builtin/company-kpis/index.tsx +2 -2
  127. package/src/plugins/builtin/cot/index.tsx +1 -1
  128. package/src/plugins/builtin/cpi/index.tsx +1 -1
  129. package/src/plugins/builtin/credit-boards/cdx-pane.tsx +20 -7
  130. package/src/plugins/builtin/credit-boards/client.ts +8 -0
  131. package/src/plugins/builtin/credit-boards/headless.ts +4 -1
  132. package/src/plugins/builtin/credit-boards/model.ts +58 -4
  133. package/src/plugins/builtin/credit-boards/series.ts +63 -6
  134. package/src/plugins/builtin/credit-boards/sovr-pane.tsx +3 -2
  135. package/src/plugins/builtin/credit-conditions/headless.ts +24 -6
  136. package/src/plugins/builtin/credit-conditions/index.tsx +1 -1
  137. package/src/plugins/builtin/credit-conditions/model.ts +12 -6
  138. package/src/plugins/builtin/credit-conditions/series.ts +2 -1
  139. package/src/plugins/builtin/crypto-board/index.tsx +1 -0
  140. package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
  141. package/src/plugins/builtin/doe/index.tsx +1 -1
  142. package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
  143. package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
  144. package/src/plugins/builtin/econ/calendar-model.ts +115 -8
  145. package/src/plugins/builtin/econ/calendar-source.ts +7 -1
  146. package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
  147. package/src/plugins/builtin/econ/index.tsx +42 -8
  148. package/src/plugins/builtin/econ/types.ts +3 -0
  149. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  150. package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
  151. package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
  152. package/src/plugins/builtin/executives/index.tsx +1 -0
  153. package/src/plugins/builtin/filing-events/index.tsx +1 -0
  154. package/src/plugins/builtin/fixed-income/index.tsx +3 -0
  155. package/src/plugins/builtin/futures-curve/headless.ts +3 -3
  156. package/src/plugins/builtin/futures-curve/index.tsx +1 -1
  157. package/src/plugins/builtin/futures-curve/model.ts +18 -0
  158. package/src/plugins/builtin/fx-matrix/index.tsx +44 -14
  159. package/src/plugins/builtin/gpu/index.tsx +1 -1
  160. package/src/plugins/builtin/help/functions-table.tsx +1 -1
  161. package/src/plugins/builtin/help/index.tsx +11 -1
  162. package/src/plugins/builtin/help/keybindings-editor.tsx +7 -3
  163. package/src/plugins/builtin/holders/index.tsx +1 -0
  164. package/src/plugins/builtin/holders/report-header.ts +2 -2
  165. package/src/plugins/builtin/insider/index.tsx +1 -0
  166. package/src/plugins/builtin/iv-history/index.tsx +1 -1
  167. package/src/plugins/builtin/jobs/index.tsx +1 -0
  168. package/src/plugins/builtin/macro-day/headless.ts +27 -8
  169. package/src/plugins/builtin/macro-day/index.tsx +1 -1
  170. package/src/plugins/builtin/macro-day/model.ts +19 -3
  171. package/src/plugins/builtin/macro-day/pane.tsx +14 -9
  172. package/src/plugins/builtin/macro-day/releases.ts +25 -7
  173. package/src/plugins/builtin/market-valuation/index.tsx +1 -0
  174. package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
  175. package/src/plugins/builtin/members/index.tsx +1 -1
  176. package/src/plugins/builtin/mna/index.tsx +1 -0
  177. package/src/plugins/builtin/news/index.tsx +1 -0
  178. package/src/plugins/builtin/news/wire/index.tsx +5 -1
  179. package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
  180. package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
  181. package/src/plugins/builtin/options/index.tsx +1 -0
  182. package/src/plugins/builtin/options-positioning/index.tsx +1 -0
  183. package/src/plugins/builtin/pe-band/index.tsx +1 -1
  184. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
  185. package/src/plugins/builtin/portfolio-list/cli/render.ts +20 -3
  186. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -1
  187. package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
  188. package/src/plugins/builtin/power/index.tsx +1 -1
  189. package/src/plugins/builtin/realized-vol/index.tsx +1 -1
  190. package/src/plugins/builtin/research/headless-schema.ts +4 -3
  191. package/src/plugins/builtin/research/headless.ts +10 -4
  192. package/src/plugins/builtin/research/index.tsx +4 -0
  193. package/src/plugins/builtin/research/relative-valuation-columns.ts +145 -47
  194. package/src/plugins/builtin/research/relative-valuation-currency.ts +31 -0
  195. package/src/plugins/builtin/research/relative-valuation-headless.ts +25 -8
  196. package/src/plugins/builtin/research/relative-valuation-model.ts +40 -9
  197. package/src/plugins/builtin/research/relative-valuation-pane.tsx +3 -2
  198. package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -2
  199. package/src/plugins/builtin/research-search/index.tsx +1 -0
  200. package/src/plugins/builtin/research-search/pane.tsx +8 -0
  201. package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
  202. package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
  203. package/src/plugins/builtin/risk-factors/index.tsx +1 -0
  204. package/src/plugins/builtin/scanner/headless.ts +52 -13
  205. package/src/plugins/builtin/seasonality/index.tsx +1 -1
  206. package/src/plugins/builtin/sec/index.tsx +1 -0
  207. package/src/plugins/builtin/series-inventory.ts +1 -1
  208. package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
  209. package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
  210. package/src/plugins/builtin/short-interest/index.tsx +1 -0
  211. package/src/plugins/builtin/social-mentions/index.tsx +1 -1
  212. package/src/plugins/builtin/supply-chain/index.tsx +1 -0
  213. package/src/plugins/builtin/thirteenf/api.ts +47 -4
  214. package/src/plugins/builtin/thirteenf/data.ts +43 -10
  215. package/src/plugins/builtin/thirteenf/headless.ts +55 -11
  216. package/src/plugins/builtin/thirteenf/model.ts +25 -9
  217. package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
  218. package/src/plugins/builtin/thirteenf/types.ts +2 -0
  219. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
  220. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +8 -7
  221. package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +8 -5
  222. package/src/plugins/builtin/ticker-detail/financials/model.ts +18 -2
  223. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
  224. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +6 -6
  225. package/src/plugins/builtin/ticker-detail/headless.ts +24 -17
  226. package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
  227. package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
  228. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +6 -4
  229. package/src/plugins/builtin/time-sales/client.ts +9 -11
  230. package/src/plugins/builtin/time-sales/index.tsx +1 -1
  231. package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
  232. package/src/plugins/builtin/treasury-auctions/cache.ts +54 -5
  233. package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
  234. package/src/plugins/builtin/treasury-auctions/headless.ts +150 -22
  235. package/src/plugins/builtin/treasury-auctions/hk-headless.ts +126 -0
  236. package/src/plugins/builtin/treasury-auctions/hk-view.tsx +347 -0
  237. package/src/plugins/builtin/treasury-auctions/hk.ts +363 -0
  238. package/src/plugins/builtin/treasury-auctions/index.tsx +27 -4
  239. package/src/plugins/builtin/treasury-auctions/model.ts +264 -28
  240. package/src/plugins/builtin/treasury-auctions/pane.tsx +176 -41
  241. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
  242. package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
  243. package/src/plugins/builtin/vol-surface/index.tsx +1 -1
  244. package/src/plugins/builtin/world-venue-map/index.ts +1 -0
  245. package/src/plugins/builtin/yield-curve/curves.ts +10 -4
  246. package/src/plugins/builtin/yield-curve/headless.ts +6 -2
  247. package/src/plugins/builtin/yield-curve/index.tsx +3 -3
  248. package/src/plugins/builtin/yield-curve/series.ts +10 -0
  249. package/src/plugins/builtin/yield-curve/world.ts +3 -1
  250. package/src/portfolio/collection-name.ts +22 -0
  251. package/src/portfolio/column-values.ts +2 -1
  252. package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
  253. package/src/public/remote.ts +7 -1
  254. package/src/remote/client.ts +191 -11
  255. package/src/remote/controller-utils.ts +13 -1
  256. package/src/remote/controller.ts +88 -26
  257. package/src/remote/endpoint.ts +24 -0
  258. package/src/remote/form.ts +59 -4
  259. package/src/remote/resources.ts +44 -18
  260. package/src/remote/schema.ts +21 -9
  261. package/src/remote/secrets.ts +12 -0
  262. package/src/remote/semantic-tree.tsx +14 -2
  263. package/src/remote/server.ts +2 -1
  264. package/src/remote/surface.tsx +192 -0
  265. package/src/remote/types.ts +5 -0
  266. package/src/renderers/dom/data-table/frozen-column.ts +3 -1
  267. package/src/renderers/dom/data-table/index.tsx +27 -9
  268. package/src/renderers/dom/data-table/row.tsx +2 -0
  269. package/src/renderers/electrobun/bun/desktop/backend.ts +27 -24
  270. package/src/renderers/electrobun/bun/desktop/detached-windows.ts +3 -3
  271. package/src/renderers/electrobun/bun/desktop/snapshot-commit.ts +77 -0
  272. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  273. package/src/renderers/electrobun/view/backend-rpc.ts +3 -0
  274. package/src/renderers/electrobun/view/desktop/window/bridge.ts +3 -0
  275. package/src/renderers/opentui/host.tsx +6 -0
  276. package/src/series/standalone.ts +2 -2
  277. package/src/shares/api.ts +21 -4
  278. package/src/shares/item.ts +73 -0
  279. package/src/shares/pane-item.ts +205 -0
  280. package/src/shares/pane.ts +4 -0
  281. package/src/shares/payload.ts +9 -5
  282. package/src/sources/gloomberb-cloud/news.ts +2 -0
  283. package/src/sources/gloomberb-cloud/normalizers.ts +9 -5
  284. package/src/sources/provider-router/cache.ts +3 -1
  285. package/src/sync/controller.ts +17 -2
  286. package/src/sync/other-window-tabs.ts +32 -1
  287. package/src/sync/react.ts +4 -4
  288. package/src/tickers/renamed-listings.ts +105 -0
  289. package/src/tickers/search/index.ts +103 -16
  290. package/src/time-series/bar-spacing.ts +33 -0
  291. package/src/time-series/base-series.ts +21 -3
  292. package/src/time-series/chart-bounds.ts +31 -0
  293. package/src/time-series/field-catalog.ts +17 -0
  294. package/src/time-series/fundamentals.ts +143 -11
  295. package/src/time-series/ice-credit.ts +32 -6
  296. package/src/time-series/resolve.ts +11 -7
  297. package/src/time-series/session-bar.ts +78 -9
  298. package/src/time-series/studies/formula.ts +53 -10
  299. package/src/time-series/studies/pair.ts +18 -7
  300. package/src/time-series/studies/units.ts +49 -2
  301. package/src/time-series/types.ts +12 -0
  302. package/src/types/desktop-window.ts +2 -0
  303. package/src/types/financials.ts +7 -0
  304. package/src/types/headless.ts +8 -0
  305. package/src/types/plugin-pane-settings.ts +2 -0
  306. package/src/types/plugin-panes.ts +22 -0
  307. package/src/utils/central-banks.ts +86 -1
  308. package/src/utils/cli-output.ts +6 -3
  309. package/src/utils/datetime-format.ts +12 -3
  310. package/src/utils/depositary-receipt.ts +28 -3
  311. package/src/utils/ebitda.ts +128 -0
  312. package/src/utils/format.ts +1 -1
  313. package/src/utils/fundamentals.ts +14 -0
  314. package/src/utils/max-drawdown.ts +97 -16
  315. package/src/utils/shell-word.ts +13 -0
  316. package/src/utils/untrusted-text.ts +29 -0
@@ -1,11 +1,14 @@
1
- import type { ScreenDefinition, ScreenMetric, ScreenRow } from "../../../api-client/equity-screener";
2
1
  import type { HeadlessPaneColumn, HeadlessPaneContext, HeadlessPaneRow } from "../../../types/headless";
3
- import type { TickerFinancials } from "../../../types/financials";
2
+ import type { FinancialStatement, TickerFinancials } from "../../../types/financials";
4
3
  import { isUsListingExchange, parsePublicTickerKey } from "../../../utils/exchanges";
5
4
  import { errorMessage } from "../../../utils/errors";
6
- import { formatNumber } from "../../../utils/format";
5
+ import { formatLevelPercent, formatNumber } from "../../../utils/format";
7
6
  import { formatPriceEarnings, NOT_MEANINGFUL } from "../../../utils/price-earnings";
8
- import { fetchScreen } from "../equity-screener/client";
7
+ import { BANK_OR_INSURER_EBITDA, ebitdaLacksDepreciation, ebitdaOperatingIncomeBasis, isBankOrInsurerIndustry } from "../../../utils/ebitda";
8
+ import { fiscalPeriodLabel, fiscalYearEndMonth } from "../../../utils/fiscal-period";
9
+ import { latestFinancialPeriod } from "../../../utils/latest-financial-period";
10
+ import { listingEnterpriseValue } from "../../../market-data/quotes/listing-enterprise-value";
11
+ import { currentTrailingValuation, latestTrailingStatement, listingStatementConversion } from "../../../time-series/fundamentals";
9
12
  import { refusedLock } from "../shared/cloud-denied";
10
13
  import { resolveHeadlessInstrument } from "../shared/headless-market-data";
11
14
  import { loadShortInterest } from "../short-interest/client";
@@ -64,6 +67,8 @@ export function parseExtraColumns(value: unknown): ExtraColumnId[] {
64
67
  }
65
68
 
66
69
  const percent = (value: unknown) => (typeof value === "number" && Number.isFinite(value) ? `${value.toFixed(2)}%` : "-");
70
+ /** Why a statement column's cell is blank ("no D&A"), in its place; "-" when nothing says. */
71
+ const gap = (row: HeadlessPaneRow, key: string) => (typeof row[key] === "string" && row[key] ? row[key] as string : "-");
67
72
  const text = (value: unknown) => (typeof value === "string" && value ? value : "-");
68
73
 
69
74
  /** Each added column, then (exports only) the source and as-of of its cells. */
@@ -111,20 +116,21 @@ const COLUMN_SPECS: Record<ExtraColumnId, ColumnSpec> = {
111
116
  },
112
117
  grossMargin: {
113
118
  label: "Gross Margin",
114
- columns: [{ key: "grossMarginPercent", header: "Gross Margin", align: "right", format: percent }],
119
+ // Trailing twelve months, as TTM Op Margin; a fiscal year's margin, where the company reports no quarters, names its year.
120
+ columns: [{ key: "grossMarginPercent", header: "Gross Margin", align: "right", format: (value, row) => (typeof value !== "number" ? gap(row, "grossMarginGap")
121
+ : typeof row.grossMarginPeriod === "string" ? `${formatLevelPercent(value / 100)} ${row.grossMarginPeriod}` : formatLevelPercent(value / 100)) }],
115
122
  sourceKey: "grossMarginSource",
116
123
  asOfKey: "grossMarginAsOf",
117
- // The screener stores the fiscal year's margin (its FY GROSS MGN%), dated by the year's end.
118
- basis: (dates) => `fiscal year to ${dates}`,
124
+ basis: (dates) => `trailing twelve months to ${dates}`,
119
125
  },
120
126
  evEbitda: {
121
127
  label: "EV/EBITDA",
122
- // N/M over an EV or EBITDA at or below zero, as EQS shows it.
128
+ // GE's EV/EBITDA: the listing's EV over trailing operating income plus D&A. N/M over an EV or EBITDA at or below zero.
123
129
  columns: [{ key: "evEbitda", header: "EV/EBITDA", align: "right", format: (value, row) => (typeof value === "number" ? formatNumber(value, 1)
124
- : row.evEbitdaNotMeaningful ? formatPriceEarnings(NOT_MEANINGFUL) : "-") }],
130
+ : row.evEbitdaNotMeaningful ? formatPriceEarnings(NOT_MEANINGFUL) : gap(row, "evEbitdaGap")) }],
125
131
  sourceKey: "evEbitdaSource",
126
132
  asOfKey: "evEbitdaAsOf",
127
- basis: (dates) => `statements to ${dates}`,
133
+ basis: (dates) => `trailing twelve months to ${dates}`,
128
134
  },
129
135
  };
130
136
 
@@ -264,57 +270,149 @@ async function loadTargetFields(symbols: readonly string[], ctx: HeadlessPaneCon
264
270
  }));
265
271
  }
266
272
 
267
- function metricFields(metric: ScreenMetric | undefined): { value: number | null; source: string | null; asOf: string | null } | null {
268
- if (!metric || metric.value == null || !Number.isFinite(metric.value) || metric.state === "unavailable") return null;
269
- return { value: metric.value, source: metric.source || null, asOf: metric.asOf ?? metric.observedAt ?? null };
273
+ const STATEMENTS_SOURCE = "Gloom Cloud financial statements";
274
+
275
+ /** Why a trailing figure is missing: fewer than four quarters, or a line the latest ones lack. */
276
+ function trailingGap(financials: TickerFinancials, line: string): string {
277
+ const latest = latestTrailingStatement(financials);
278
+ if (!latest) return financials.quarterlyStatements.length > 0 ? "< 4 quarters" : "no quarters";
279
+ return `no ${line}`;
270
280
  }
271
281
 
272
- /** Gross margin and EV/EBITDA as the screener stores them, each with its own source and statement date. */
273
- async function loadScreenerFields(ids: readonly ExtraColumnId[], symbols: readonly string[], ctx: HeadlessPaneContext, out: ExtraColumnsResult) {
274
- const wanted = ids.filter((id) => id === "grossMargin" || id === "evEbitda");
275
- const listed = symbols.flatMap((symbol) => {
276
- const bare = usListing(symbol);
277
- return bare ? [{ symbol, bare }] : [];
278
- });
279
- if (wanted.length === 0 || listed.length === 0) return;
280
- const definition: ScreenDefinition = {
281
- version: 1,
282
- criteria: [{ field: "symbol", op: "in", value: [...new Set(listed.map(({ bare }) => bare))] }],
283
- sort: { field: "symbol", direction: "asc" },
284
- currency: null,
282
+ /**
283
+ * Gross margin over the trailing twelve months, from the statements GE's
284
+ * `ttm` series sums; the latest fiscal year's, named for it ("FY25"), only for
285
+ * a company that reports no quarters.
286
+ */
287
+ function grossMarginFields(financials: TickerFinancials): HeadlessPaneRow {
288
+ const trailing = latestTrailingStatement(financials);
289
+ if (trailing) {
290
+ const { grossProfit, totalRevenue } = trailing;
291
+ if (typeof grossProfit === "number" && typeof totalRevenue === "number" && totalRevenue > 0) {
292
+ return { grossMarginPercent: 100 * grossProfit / totalRevenue, grossMarginSource: STATEMENTS_SOURCE, grossMarginAsOf: trailing.date.slice(0, 10) };
293
+ }
294
+ return { grossMarginGap: typeof totalRevenue === "number" && totalRevenue > 0 ? "no gross profit" : "no revenue" };
295
+ }
296
+ if (financials.quarterlyStatements.length > 0) return { grossMarginGap: trailingGap(financials, "gross profit") };
297
+ const year = latestFinancialPeriod(financials.annualStatements, (row) => row.date);
298
+ if (!year || typeof year.grossProfit !== "number" || typeof year.totalRevenue !== "number" || year.totalRevenue <= 0) return { grossMarginGap: "not reported" };
299
+ const label = fiscalPeriodLabel(year.date, "annual", fiscalYearEndMonth(financials.annualStatements));
300
+ return {
301
+ grossMarginPercent: 100 * year.grossProfit / year.totalRevenue,
302
+ grossMarginPeriod: /^FY\d{2}(\d{2})$/.test(label) ? `FY${label.slice(-2)}` : label,
303
+ grossMarginSource: STATEMENTS_SOURCE,
304
+ grossMarginAsOf: year.date.slice(0, 10),
285
305
  };
286
- let rows: ScreenRow[];
287
- try {
288
- rows = (await fetchScreen(definition, null, ctx.signal, ctx.apiClient)).rows;
289
- } catch (error) {
290
- out.errors.push(failureMessage(wanted.map((id) => COLUMN_SPECS[id].label).join(" and "), error));
291
- return;
306
+ }
307
+
308
+ const DAY_MS = 86_400_000;
309
+
310
+ /**
311
+ * Where the trailing EBITDA's operating income was derived, not reported
312
+ * (utils/ebitda): `operating income derived as pretax income for the quarter
313
+ * to 2026-09-30`, one clause a basis. Null where every period reported it.
314
+ */
315
+ function derivedOperatingIncomeNote(financials: TickerFinancials, statement: FinancialStatement): string | null {
316
+ const end = Date.parse(statement.date);
317
+ // The quarters the trailing twelve months sum, and the fiscal year a fourth quarter is completed from.
318
+ const window = [...financials.quarterlyStatements, ...financials.annualStatements].filter((row) => {
319
+ const time = Date.parse(row.date);
320
+ return Number.isFinite(time) && time <= end && time > end - 350 * DAY_MS;
321
+ });
322
+ const bases = new Map<string, string[]>();
323
+ for (const row of window.sort((left, right) => Date.parse(left.date) - Date.parse(right.date))) {
324
+ const basis = ebitdaOperatingIncomeBasis(row);
325
+ if (!basis) continue;
326
+ const date = row.date.slice(0, 10);
327
+ if (!bases.get(basis)?.includes(date)) bases.set(basis, [...bases.get(basis) ?? [], date]);
292
328
  }
293
- for (const { symbol, bare } of listed) {
294
- const row = rows.find((candidate) => candidate.symbol.toUpperCase() === bare && isUsListingExchange(candidate.exchange));
295
- if (!row) continue;
296
- const fields = out.fields.get(symbol)!;
297
- if (wanted.includes("grossMargin")) {
298
- const gross = metricFields(row.metrics.grossMarginPercent);
299
- if (gross) Object.assign(fields, { grossMarginPercent: gross.value, grossMarginSource: gross.source, grossMarginAsOf: gross.asOf });
300
- }
301
- if (wanted.includes("evEbitda")) {
302
- const multiple = metricFields(row.metrics.evToEbitda);
303
- if (multiple) Object.assign(fields, { evEbitda: multiple.value, evEbitdaSource: multiple.source, evEbitdaAsOf: multiple.asOf });
304
- else if (row.metrics.evToEbitda?.notMeaningful) Object.assign(fields, { evEbitda: null, evEbitdaNotMeaningful: row.metrics.evToEbitda.reason ?? true });
329
+ if (bases.size === 0) return null;
330
+ return [...bases].map(([basis, dates]) => `operating income derived as ${basis} for the ${dates.length === 1 ? "period" : "periods"} to ${dates.join(" and ")}`).join("; ");
331
+ }
332
+
333
+ /**
334
+ * What a computed EV/EBITDA divided: the EV over the trailing EBITDA, and,
335
+ * for the note under the table, the rate an ADR's statements took and any
336
+ * derived operating income (`detail`).
337
+ */
338
+ function evEbitdaSource(financials: TickerFinancials, enterpriseValue: ReturnType<typeof listingEnterpriseValue>, statement: FinancialStatement): { source: string; detail: string | null } {
339
+ const ev = enterpriseValue.kind === "value" && enterpriseValue.basis === "computed" ? "Market cap + total debt - cash" : "Gloom Cloud enterprise value";
340
+ const conversion = listingStatementConversion(financials, statement);
341
+ const detail = [
342
+ ...conversion ? [`statements in ${conversion.from} at ${conversion.rate.toPrecision(4)} ${conversion.to}`] : [],
343
+ ...[derivedOperatingIncomeNote(financials, statement) ?? []].flat(),
344
+ ].join("; ") || null;
345
+ return { source: `${ev} over trailing operating income plus D&A${detail ? `; ${detail}` : ""}`, detail };
346
+ }
347
+
348
+ /**
349
+ * EV/EBITDA as GE's trailing series ends on it (currentTrailingValuation):
350
+ * the listing's enterprise value at the regular session price over the latest
351
+ * four quarters of operating income plus D&A, an ADR's converted at its EV
352
+ * check's rate. N/M where either is at or below zero, and for a bank or an
353
+ * insurer; otherwise a blank says why.
354
+ */
355
+ function evEbitdaFields(financials: TickerFinancials): HeadlessPaneRow & { evEbitdaNote?: string } {
356
+ if (isBankOrInsurerIndustry(financials.profile?.industry)) {
357
+ return { evEbitda: null, evEbitdaNotMeaningful: BANK_OR_INSURER_EBITDA, evEbitdaNote: `N/M, ${BANK_OR_INSURER_EBITDA}` };
358
+ }
359
+ const enterpriseValue = listingEnterpriseValue(financials);
360
+ // EV/S's note already says why the EV is not meaningful.
361
+ if (enterpriseValue.kind === "not-meaningful") return { evEbitda: null, evEbitdaNotMeaningful: enterpriseValue.reason };
362
+ const current = currentTrailingValuation(financials, "evEbitda");
363
+ if (current) {
364
+ const { source, detail } = evEbitdaSource(financials, enterpriseValue, current.statement);
365
+ const dated = { evEbitdaSource: source, evEbitdaAsOf: current.periodEnd };
366
+ if (current.value === null) {
367
+ return { evEbitda: null, evEbitdaNotMeaningful: current.notMeaningful, evEbitdaNote: `N/M, ${current.notMeaningful!.charAt(0).toLowerCase()}${current.notMeaningful!.slice(1)}`, ...dated };
305
368
  }
369
+ if (current.value <= 0) return { evEbitda: null, evEbitdaNotMeaningful: "Enterprise value is not positive", ...dated };
370
+ return { evEbitda: current.value, ...detail ? { evEbitdaNote: detail } : {}, ...dated };
306
371
  }
372
+ const trailing = latestTrailingStatement(financials);
373
+ const statementCurrency = trailing?.currency ?? financials.financialCurrency;
374
+ const quoteCurrency = financials.quote?.currency;
375
+ if (trailing && statementCurrency && quoteCurrency && statementCurrency !== quoteCurrency) return { evEbitdaGap: `statements in ${statementCurrency}` };
376
+ if (trailing && typeof trailing.ebitda !== "number") {
377
+ const quarters = financials.quarterlyStatements;
378
+ return { evEbitdaGap: quarters.some(ebitdaLacksDepreciation) || ebitdaLacksDepreciation(trailing) ? "no D&A" : "no EBITDA" };
379
+ }
380
+ if (!trailing) return { evEbitdaGap: trailingGap(financials, "EBITDA") };
381
+ return { evEbitdaGap: enterpriseValue.kind === "unavailable" ? "EV unavailable" : "not reported" };
382
+ }
383
+
384
+ /**
385
+ * Gross margin and EV/EBITDA from the statements GE reads (the extended
386
+ * history it loads), each with its source and the quarter it runs to.
387
+ */
388
+ async function loadStatementFields(ids: readonly ExtraColumnId[], symbols: readonly string[], ctx: HeadlessPaneContext, out: ExtraColumnsResult) {
389
+ const wanted = ids.filter((id) => id === "grossMargin" || id === "evEbitda");
390
+ if (wanted.length === 0) return;
391
+ const notes = new Map<string, string>();
392
+ await Promise.all(symbols.map(async (symbol) => {
393
+ try {
394
+ const { symbol: ticker, exchange } = await resolveHeadlessInstrument(ctx, symbol);
395
+ const financials = await ctx.marketData.getTickerFinancials(ticker, exchange ?? "", { statementHistory: "extended" });
396
+ const { evEbitdaNote, ...evEbitda } = wanted.includes("evEbitda") ? evEbitdaFields(financials) : {};
397
+ Object.assign(out.fields.get(symbol)!, wanted.includes("grossMargin") ? grossMarginFields(financials) : {}, evEbitda);
398
+ // Said under the table: why a cell is N/M, an ADR's rate, operating income derived from other lines.
399
+ if (evEbitdaNote) notes.set(symbol, `${symbol}: EV/EBITDA ${evEbitdaNote}.`);
400
+ } catch (error) {
401
+ out.errors.push(failureMessage(wanted.map((id) => COLUMN_SPECS[id].label).join(" and "), error, symbol));
402
+ }
403
+ }));
404
+ out.notes.push(...symbols.flatMap((symbol) => notes.get(symbol) ?? []));
307
405
  }
308
406
 
309
407
  /** The US-only columns among `ids`, which a listing abroad leaves blank. */
310
- const US_ONLY: ReadonlySet<ExtraColumnId> = new Set(["shortInterest", "nextEarnings", "grossMargin", "evEbitda"]);
408
+ const US_ONLY: ReadonlySet<ExtraColumnId> = new Set(["shortInterest", "nextEarnings"]);
311
409
 
312
410
  /**
313
411
  * The added fields for every symbol, each column read apart so one that
314
412
  * fails (or is locked) leaves the others: short interest from FINRA's
315
413
  * settlements, the next report date from the earnings calendar, the mean
316
414
  * target and analyst count from analyst research, gross margin and EV/EBITDA
317
- * from the screener's stored figures.
415
+ * from the statements GE reads.
318
416
  */
319
417
  export async function loadExtraColumns(
320
418
  ids: readonly ExtraColumnId[],
@@ -328,7 +426,7 @@ export async function loadExtraColumns(
328
426
  ids.includes("shortInterest") ? loadShortInterestFields(symbols, financials, ctx, out) : null,
329
427
  ids.includes("nextEarnings") ? loadNextEarningsFields(symbols, ctx, out) : null,
330
428
  ids.includes("target") ? loadTargetFields(symbols, ctx, out) : null,
331
- loadScreenerFields(ids, symbols, ctx, out),
429
+ loadStatementFields(ids, symbols, ctx, out),
332
430
  ]);
333
431
  ctx.signal.throwIfAborted();
334
432
  const abroad = symbols.filter((symbol) => !usListing(symbol));
@@ -93,6 +93,37 @@ export function convertMarketCaps<Row extends CapRow>(
93
93
  };
94
94
  }
95
95
 
96
+ /**
97
+ * Every row's mean analyst target in `target`, at the rates the caps convert
98
+ * at (convertMarketCaps): `targetMeanNative` and `targetNativeCurrency` keep
99
+ * the target as served. A currency with no usable rate keeps its targets.
100
+ */
101
+ export function convertTargets<Row extends { symbol: string; targetMean?: unknown; targetCurrency?: unknown }>(
102
+ rows: readonly Row[],
103
+ target: string,
104
+ rates: ReadonlyMap<string, UsdRate>,
105
+ ): { rows: Row[]; conversions: CapConversion[]; unconverted: Array<{ currency: string; symbols: string[] }> } {
106
+ const amounts = convertMarketCaps(rows.map((row) => ({
107
+ symbol: row.symbol,
108
+ marketCap: typeof row.targetMean === "number" && Number.isFinite(row.targetMean) ? row.targetMean : null,
109
+ marketCapCurrency: typeof row.targetCurrency === "string" && row.targetCurrency ? row.targetCurrency : null,
110
+ })), target, rates);
111
+ return {
112
+ rows: rows.map((row, index) => {
113
+ const converted = amounts.rows[index]!;
114
+ return converted.marketCapNative === undefined ? row : {
115
+ ...row,
116
+ targetMean: converted.marketCap,
117
+ targetCurrency: converted.marketCapCurrency,
118
+ targetMeanNative: converted.marketCapNative,
119
+ targetNativeCurrency: converted.marketCapNativeCurrency,
120
+ };
121
+ }),
122
+ conversions: amounts.conversions,
123
+ unconverted: amounts.unconverted,
124
+ };
125
+ }
126
+
96
127
  /** A rate as a dealer quotes it: `EUR/USD 1.1612`, `USD/JPY 151.20`; a cross of two other currencies as `from/to`. */
97
128
  export function conversionPairText({ from, to, rate }: Pick<CapConversion, "from" | "to" | "rate">): string {
98
129
  const figure = (value: number) => value.toPrecision(5);
@@ -14,7 +14,7 @@ import {
14
14
  } from "./relative-valuation-peers";
15
15
  import { extraColumns, extraColumnsBasis, loadExtraColumns, parseExtraColumns } from "./relative-valuation-columns";
16
16
  import { fundamentalsBasisParts } from "./relative-valuation-basis";
17
- import { conversionNote, convertMarketCaps, loadFxLegs } from "./relative-valuation-currency";
17
+ import { conversionNote, convertMarketCaps, convertTargets, loadFxLegs, type CapConversion } from "./relative-valuation-currency";
18
18
 
19
19
  const price = (value: unknown, row: Record<string, unknown>) => (
20
20
  value == null || !row.currency ? "-" : formatCurrency(Number(value), String(row.currency))
@@ -158,21 +158,38 @@ export const relativeValuationHeadless: HeadlessPaneDefinition<"rows"> = {
158
158
  const extraIds = parseExtraColumns(args.options.columns);
159
159
  const financials = new Map(loaded.entries.map(({ symbol, data }) => [symbol, data] as const));
160
160
  const extra = await loadExtraColumns(extraIds, capRows.map((row) => row.symbol), financials, ctx);
161
- const rows = capRows.map((row) => ({ ...row, ...extra.fields.get(row.symbol) }));
161
+ const extraRows = capRows.map((row) => ({ ...row, ...extra.fields.get(row.symbol) }));
162
+ // Analyst targets go into the asked currency with the caps, at the same rates.
163
+ const targetCurrencies = capCurrency && fx ? extraRows.flatMap((row): string[] => {
164
+ const currency = (row as Record<string, unknown>).targetCurrency;
165
+ return typeof currency === "string" && currency ? [currency] : [];
166
+ }) : [];
167
+ const targetFx = targetCurrencies.length > 0 ? await loadFxLegs(targetCurrencies.filter((currency) => !fx!.legs.has(resolveCurrencyUnit(currency).currency)), ctx) : null;
168
+ const targets = capCurrency && fx && targetCurrencies.length > 0
169
+ ? convertTargets(extraRows, capCurrency, new Map([...fx.legs, ...targetFx?.legs ?? []])) : null;
170
+ const rows = targets?.rows ?? extraRows;
171
+ const conversions = [...converted?.conversions ?? [], ...targets?.conversions ?? []]
172
+ .filter((conversion, index, all): conversion is CapConversion => all.findIndex((other) => other.from === conversion.from) === index);
162
173
 
163
174
  const errors = [...loaded.errors,
164
175
  ...staleSymbols.map((symbol) => `${symbol}: ${RELATIVE_VALUATION_STALE_QUOTE_NOTICE}`),
165
176
  ...staleFundamentalsSymbols.map((symbol) => `${symbol}: ${RELATIVE_VALUATION_STALE_FUNDAMENTALS_NOTICE}`),
166
177
  ...extra.errors,
167
178
  ];
168
- const warnings = converted?.unconverted.map(({ currency, symbols: left }) => {
169
- const reason = fx?.failed.find((failure) => failure.currency === resolveCurrencyUnit(currency).currency)?.reason;
170
- return `No ${currency} rate${reason ? ` (${reason})` : ""}: ${left.join(", ")} ${left.length === 1 ? "keeps its" : "keep their"} market cap in ${currency}.`;
171
- }) ?? [];
179
+ const failedRates = [...fx?.failed ?? [], ...targetFx?.failed ?? []];
180
+ const unconvertedWarning = (what: string) => ({ currency, symbols: left }: { currency: string; symbols: string[] }) => {
181
+ const reason = failedRates.find((failure) => failure.currency === resolveCurrencyUnit(currency).currency)?.reason;
182
+ return `No ${currency} rate${reason ? ` (${reason})` : ""}: ${left.join(", ")} ${left.length === 1 ? "keeps its" : "keep their"} ${what} in ${currency}.`;
183
+ };
184
+ const warnings = [
185
+ ...converted?.unconverted.map(unconvertedWarning("market cap")) ?? [],
186
+ ...targets?.unconverted.map(unconvertedWarning("analyst target")) ?? [],
187
+ ];
172
188
  // The footer: the rates the caps were converted at, the statement period the figures run through, and the
173
189
  // basis of each column that is not trailing twelve months.
174
190
  const footnote = [
175
- ...capCurrency && converted ? [conversionNote(capCurrency, converted.conversions)] : [],
191
+ ...capCurrency && converted ? [conversionNote(capCurrency, conversions,
192
+ targets?.conversions.length ? `market caps and analyst targets in ${capCurrency}` : undefined)] : [],
176
193
  ...fundamentalsBasisParts(rows, REVENUE_GROWTH_HEADER),
177
194
  ...extraColumnsBasis(extraIds, rows),
178
195
  ].filter(Boolean).join(" · ");
@@ -202,7 +219,7 @@ export const relativeValuationHeadless: HeadlessPaneDefinition<"rows"> = {
202
219
  ...(selection ? { peerSelection: selection } : {}),
203
220
  ...(converted && capCurrency ? { marketCapConversion: { currency: capCurrency, rates: converted.conversions,
204
221
  basis: "marketCap is converted into the asked currency at each currency's US dollar rate, the rate the app's converted totals use; marketCapNative and marketCapNativeCurrency keep the cap as served." } } : {}),
205
- ...(extraIds.length > 0 ? { addedColumnsBasis: "Each added column keeps its own source and as-of beside it: short interest at its FINRA settlement date, analyst targets at retrieval, the next earnings date at the calendar's retrieval, gross margin and EV/EBITDA at the screener's statement date." } : {}),
222
+ ...(extraIds.length > 0 ? { addedColumnsBasis: "Each added column keeps its own source and as-of beside it: short interest at its FINRA settlement date, analyst targets at retrieval (converted with the caps under --currency, targetMeanNative keeping the served one), the next earnings date at the calendar's retrieval, gross margin and EV/EBITDA at the end of the latest quarter they sum. EV/EBITDA is the listing's enterprise value over the trailing four quarters of operating income plus D&A, as GE's EV/EBITDA ends." } : {}),
206
223
  quoteBasis: "Stale quote fields are excluded from comparison; reportedQuote retains the rejected observation and quoteAsOf retains its source timestamp.",
207
224
  priceBasis: "price, change and changePercent are the regular session: after the close, its close and that close's move. A pre-market, after-hours or overnight print is in extendedPrice, extendedChange and extendedChangePercent, measured from that close (extendedMark when it is a bid and ask midpoint). marketCap, the P/E multiples, evSales (through the equity part of the enterprise value) and fcfYield are measured at that regular session price.",
208
225
  fundamentalsBasis: "Provider multiples and operating metrics retain independent fundamentalsProvenance. Retrieval time does not establish the valuation date.",
@@ -1,4 +1,4 @@
1
- import { formatCurrency } from "../../../utils/format";
1
+ import { formatCompact, formatCurrency } from "../../../utils/format";
2
2
  import { comparablePriceEarnings, notMeaningfulMultiples } from "../../../utils/price-earnings";
3
3
  import { marketCapBasisNote, viewMarketCapitalization, withheldMarketCap } from "../../../utils/market-capitalization";
4
4
  import {
@@ -9,6 +9,7 @@ import { getExtendedSessionDisplay, getQuoteSessionFields } from "../../../marke
9
9
  import { atRegularSessionPrice, movePriceDerivedFigures, regularSessionValuationPrice } from "../../../market-data/quotes/regular-session-valuation";
10
10
  import { fiscalPeriodLabel, fiscalYearEndMonth } from "../../../utils/fiscal-period";
11
11
  import { latestFinancialPeriod, latestReportedPeriod } from "../../../utils/latest-financial-period";
12
+ import { listingEnterpriseValue } from "../../../market-data/quotes/listing-enterprise-value";
12
13
  import type { Quote, TickerFinancials } from "../../../types/financials";
13
14
 
14
15
  export function formatRelativePrice(price: number | null | undefined, currency: string | null | undefined): string {
@@ -111,12 +112,15 @@ export function relativeValuationValues(snapshot: TickerFinancials | null) {
111
112
  ...(forwardNotMeaningful ? { forwardPE: forwardNotMeaningful } : {}),
112
113
  ...(evSalesNotMeaningful ? { evSales: evSalesNotMeaningful } : {}),
113
114
  };
114
- const evSalesWithdrawn = enterpriseValueWithdrawn(fundamentals);
115
- const evSales = !compatibleCurrency || enterpriseValueGap || evSalesNotMeaningful ? null
116
- : fundamentals?.enterpriseToRevenue != null && Number.isFinite(fundamentals.enterpriseToRevenue)
117
- ? fundamentals.enterpriseToRevenue
118
- : enterpriseValue != null && fundamentals?.revenue != null && fundamentals.revenue > 0
119
- ? enterpriseValue / fundamentals.revenue : null;
115
+ // A provider EV Gloom Cloud withdrew falls back to the market cap + total debt - cash it was checked against.
116
+ const fallback = snapshot && enterpriseValueWithdrawn(fundamentals) ? computedEnterpriseValueSales(snapshot, fundamentals) : null;
117
+ const evSalesWithdrawn = enterpriseValueWithdrawn(fundamentals) && !fallback;
118
+ const evSales = fallback ? fallback.evSales
119
+ : !compatibleCurrency || enterpriseValueGap || evSalesNotMeaningful ? null
120
+ : fundamentals?.enterpriseToRevenue != null && Number.isFinite(fundamentals.enterpriseToRevenue)
121
+ ? fundamentals.enterpriseToRevenue
122
+ : enterpriseValue != null && fundamentals?.revenue != null && fundamentals.revenue > 0
123
+ ? enterpriseValue / fundamentals.revenue : null;
120
124
  const fcfYield = capitalization && fundamentals?.financialCurrency === capitalization.currency
121
125
  && fundamentals.freeCashFlow != null && Number.isFinite(fundamentals.freeCashFlow) && capitalization.value > 0
122
126
  ? fundamentals.freeCashFlow / capitalization.value : null;
@@ -175,9 +179,11 @@ export function relativeValuationValues(snapshot: TickerFinancials | null) {
175
179
  /** Why EV/S is missing when the provider's EV was withdrawn, as `valuation` says it; null otherwise. */
176
180
  evSalesUnavailable: evSalesWithdrawn
177
181
  ? enterpriseValueReconciliationNote(fundamentals) ?? "EV unavailable." : null,
178
- /** Why EV/S is N/M, as `valuation` says it: "EV N/M: cash and short-term investments exceed ..."; null otherwise. */
179
- evSalesNote: evSalesNotMeaningful
182
+ /** Why EV/S is N/M, as `valuation` says it: "EV N/M: cash and short-term investments exceed ..."; or, for EV/S over a computed EV, what it was computed from; null otherwise. */
183
+ evSalesNote: fallback ? fallback.note : evSalesNotMeaningful
180
184
  ? enterpriseValueReconciliationNote(fundamentals) ?? (isBankEnterpriseValue(fundamentals) ? `EV ${BANK_ENTERPRISE_VALUE}.` : null) : null,
185
+ /** `computed` where EV/S divides market cap + total debt - cash in place of a withdrawn provider EV; `served` otherwise. */
186
+ evSalesBasis: fallback ? "computed" as const : evSales != null ? "served" as const : null,
181
187
  fcfYield,
182
188
  revenueGrowth,
183
189
  operatingMargin,
@@ -189,6 +195,31 @@ export function relativeValuationValues(snapshot: TickerFinancials | null) {
189
195
  };
190
196
  }
191
197
 
198
+ /**
199
+ * EV/S over the market cap + total debt - cash a withdrawn provider EV was
200
+ * checked against (listingEnterpriseValue), with the note that says so: TTM
201
+ * revenue in the EV's currency, or converted at the rate the check's balance
202
+ * sheet was ("EUR at 1.133 USD"). Null when there is no such EV or no revenue
203
+ * in a currency it can be divided in.
204
+ */
205
+ function computedEnterpriseValueSales(snapshot: TickerFinancials, fundamentals: TickerFinancials["fundamentals"]) {
206
+ const listing = listingEnterpriseValue(snapshot);
207
+ if (listing.kind !== "value" || listing.basis !== "computed" || !listing.check) return null;
208
+ const revenue = fundamentals?.revenue;
209
+ const currency = fundamentals?.financialCurrency;
210
+ if (!finiteNumber(revenue) || revenue <= 0 || !currency) return null;
211
+ const fx = listing.check.fx;
212
+ const rate = currency === listing.currency ? 1 : fx && fx.from === currency && finiteNumber(fx.rate) && fx.rate > 0 ? fx.rate : null;
213
+ if (rate == null) return null;
214
+ const converted = fx && finiteNumber(fx.rate) ? `, ${fx.from} at ${fx.rate.toPrecision(4)} ${listing.currency}` : "";
215
+ const sheet = listing.check.balanceSheetDate ? ` (balance sheet ${listing.check.balanceSheetDate}${converted})` : "";
216
+ const provider = finiteNumber(listing.check.source) ? `; the provider's ${formatCompact(listing.check.source)} ${listing.currency} failed validation against it` : "";
217
+ return {
218
+ evSales: listing.value / (revenue * rate),
219
+ note: `EV ${formatCompact(listing.value)} ${listing.currency} computed from market cap + total debt - cash${sheet}${provider}.`,
220
+ };
221
+ }
222
+
192
223
  function scaled(value: number | undefined, ratio: number): number | undefined {
193
224
  return value != null && Number.isFinite(value) ? value * ratio : value;
194
225
  }
@@ -18,7 +18,7 @@ import { useLiveQuoteEntries } from "../../../state/hooks/quote-streaming";
18
18
  import { useSampledValue } from "../../../state/hooks/live-ticker-financials";
19
19
  import type { QuoteSubscriptionTarget } from "../../../types/data-provider";
20
20
  import type { TickerFinancials } from "../../../types/financials";
21
- import { normalizeSymbol } from "../../../utils/exchanges";
21
+ import { canonicalTickerKey, normalizeSymbol } from "../../../utils/exchanges";
22
22
  import { colors, priceColor, shownPriceColor } from "../../../theme/colors";
23
23
  import { extendedSessionStateLabel, type ExtendedSession } from "../../../market-data/market/status";
24
24
  import { compareSortValues, nextHeaderSort, type SortDirection } from "../../../utils/sort-values";
@@ -330,7 +330,8 @@ export function RelativeValuationPane({ focused, width, height }: PaneProps) {
330
330
  const renderCell = useCallback((row: RelativeRow, column: RelativeColumn): DataTableCell => {
331
331
  switch (column.id) {
332
332
  case "symbol":
333
- return { text: row.symbol, color: row.error || row.quoteStale || row.fundamentalsProvenance?.stale ? colors.warning : colors.textBright, attributes: TextAttributes.BOLD };
333
+ // The listing as the CLI names it (ASML:AMS), not the key it is stored under (ASML:XAMS).
334
+ return { text: canonicalTickerKey(row.symbol), color: row.error || row.quoteStale || row.fundamentalsProvenance?.stale ? colors.warning : colors.textBright, attributes: TextAttributes.BOLD };
334
335
  case "price":
335
336
  return { text: formatRelativePrice(row.price, row.currency), color: colors.text };
336
337
  case "changePercent":
@@ -1,7 +1,7 @@
1
1
  import type { ScreenDefinition, ScreenRow } from "../../../api-client/equity-screener";
2
2
  import type { HeadlessPaneContext } from "../../../types/headless";
3
3
  import type { TickerFinancials } from "../../../types/financials";
4
- import { isUsListingExchange, parsePublicTickerKey } from "../../../utils/exchanges";
4
+ import { canonicalTickerKey, isUsListingExchange, parsePublicTickerKey } from "../../../utils/exchanges";
5
5
  import { errorMessage } from "../../../utils/errors";
6
6
  import { isRecord } from "../../../utils/guards";
7
7
  import { formatTickerListInput } from "../../../tickers/list";
@@ -364,7 +364,7 @@ export function peerMethodTitle(selection: PeerSelection, { automatic = false }:
364
364
  export function relativeValuationTitle(symbols: readonly string[], selection: PeerSelection | null): string {
365
365
  return selection
366
366
  ? `RV ${selection.subject} + ${peerMethodTitle(selection, { automatic: true })}`
367
- : `RV ${formatTickerListInput([...symbols])}`;
367
+ : `RV ${formatTickerListInput(symbols.map((symbol) => canonicalTickerKey(symbol)))}`;
368
368
  }
369
369
 
370
370
  function screenSymbol(row: ScreenRow): string {
@@ -39,6 +39,7 @@ export const researchSearchPlugin: GloomPlugin = {
39
39
  reportFreshness: { status: "not-a-feed", basis: "search results" },
40
40
  name: "Research Search",
41
41
  icon: "RS",
42
+ shareItem: { open: true },
42
43
  get component(): typeof import("./pane").ResearchSearchPane { const { ResearchSearchPane } = require("./pane"); return ResearchSearchPane; },
43
44
  defaultPosition: "right",
44
45
  defaultMode: "floating",
@@ -26,6 +26,8 @@ import { useDialog } from "../../../ui/dialog";
26
26
  import { isPlainArrowUp, stopSearchFocusNavigation } from "../../../utils/search-focus-navigation";
27
27
  import { usePaneSettingValue } from "../../../state/app/context";
28
28
  import { usePluginPaneState } from "../../runtime";
29
+ import { shareItemExcerpt } from "../../../shares/item";
30
+ import { usePaneShareItem } from "../../../shares/pane-item";
29
31
  import type { PaneProps } from "../../../types/plugin";
30
32
  import type {
31
33
  CloudSavedSearch,
@@ -149,6 +151,12 @@ export function ResearchSearchPane({ focused, paneId, width, height }: PaneProps
149
151
  [hits, openHitId],
150
152
  );
151
153
  const openHit = openHitIndex >= 0 ? hits[openHitIndex]! : null;
154
+ // A link to the pane says what it is on: the result open or picked. Never
155
+ // the words typed in the search, which are the person's own.
156
+ usePaneShareItem(() => {
157
+ const picked = openHit ?? hits.find((hit) => hit.id === selectedHitId);
158
+ return picked ? { title: picked.title, excerpt: shareItemExcerpt(snippetPlainText(picked.snippet)) } : null;
159
+ });
152
160
  // The document the cache holds paints at once; another document never
153
161
  // shows under this hit's title while its own loads.
154
162
  const [seededDocumentKey, setSeededDocumentKey] = useState<string | null>(null);
@@ -33,6 +33,7 @@ export const revenueBreakdownModule: PluginModule = {
33
33
  icon: "R",
34
34
  component: RevenueBreakdownPane,
35
35
  defaultPosition: "right",
36
+ shareItem: { ticker: true },
36
37
  tickerFollower: true,
37
38
  instruments: ["equity"],
38
39
  defaultMode: "floating",
@@ -6,7 +6,7 @@ import { DISCOUNT_OPTIONS, MARGIN_OPTIONS, ReverseDcfPane } from "./pane";
6
6
  export const reverseDcfModule: PluginModule = {
7
7
  panes: [{
8
8
  id: "reverse-dcf", name: "Reverse DCF", icon: "R", component: ReverseDcfPane,
9
- defaultPosition: "right", tickerFollower: true, instruments: ["equity"], defaultMode: "floating", defaultFloatingSize: { width: 80, height: 20 },
9
+ defaultPosition: "right", shareItem: { ticker: true }, tickerFollower: true, instruments: ["equity"], defaultMode: "floating", defaultFloatingSize: { width: 80, height: 20 },
10
10
  tableExport: true,
11
11
  // Dated as `fn RDCF` dates it, by the regular close the enterprise value is measured at, not by the quote's latest print.
12
12
  reportFreshness: reverseDcfHeadless.freshness,
@@ -41,6 +41,7 @@ export const riskFactorsModule: PluginModule = {
41
41
  component: RiskFactorsPane,
42
42
  headless: riskFactorsHeadless,
43
43
  defaultPosition: "right",
44
+ shareItem: { ticker: true },
44
45
  tickerFollower: true,
45
46
  instruments: ["equity"],
46
47
  defaultMode: "floating",