gloomberb 0.20.13 → 0.20.16

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 (275) hide show
  1. package/package.json +2 -1
  2. package/patches/@opentui%2Fcore@0.3.2.patch +22 -4
  3. package/src/account/auth-dialog.tsx +22 -4
  4. package/src/account/auth-form.tsx +6 -1
  5. package/src/account/checkout-handoff.tsx +7 -14
  6. package/src/account/device-signin-dialog.tsx +35 -24
  7. package/src/api-client/crypto-markets.ts +10 -0
  8. package/src/api-client/errors.ts +3 -1
  9. package/src/api-client/index.ts +54 -0
  10. package/src/api-client/install-experiments.ts +8 -7
  11. package/src/api-client/money-markets.ts +7 -0
  12. package/src/api-client/paths.ts +2 -1
  13. package/src/api-client/product-waitlist.ts +63 -0
  14. package/src/api-client/request.ts +16 -4
  15. package/src/api-client/types/billing.ts +45 -0
  16. package/src/api-client/yearly-plan.ts +132 -0
  17. package/src/app/global-shortcuts.ts +5 -3
  18. package/src/app/pane-runtime/index.tsx +2 -2
  19. package/src/app/pane-runtime/plugin-bindings.ts +3 -1
  20. package/src/app/pane-runtime/ticker-open-runtime.ts +6 -1
  21. package/src/app/since-last-visit/keys.ts +26 -0
  22. package/src/app/since-last-visit/model.ts +266 -0
  23. package/src/app/since-last-visit/strip.tsx +193 -0
  24. package/src/app/since-last-visit/use-since-last-visit.ts +289 -0
  25. package/src/app/since-last-visit/visit-tracker.ts +191 -0
  26. package/src/app.tsx +15 -0
  27. package/src/architecture/floating-promise-allowlist.json +0 -1
  28. package/src/brokers/signed-in/sign-in-dialog.tsx +38 -38
  29. package/src/cli/commands/market.ts +103 -27
  30. package/src/cli/commands/overview.ts +18 -4
  31. package/src/cli/commands/system.ts +29 -1
  32. package/src/cli/commands/ticker.ts +12 -5
  33. package/src/cli/desktop-pane-shot-api-policy.ts +4 -1
  34. package/src/cli/desktop-pane-shot-browser.ts +2 -1
  35. package/src/cli/desktop-pane-shot-view.ts +3 -7
  36. package/src/cli/desktop-pane-shot.ts +26 -28
  37. package/src/cli/errors.ts +3 -1
  38. package/src/cli/freshness.ts +7 -2
  39. package/src/cli/glossary.ts +10 -5
  40. package/src/cli/help.ts +1 -0
  41. package/src/cli/helpers.ts +8 -16
  42. package/src/cli/history-export.ts +4 -0
  43. package/src/cli/history-rows.ts +24 -0
  44. package/src/cli/index.ts +4 -0
  45. package/src/cli/known-gaps.ts +2 -2
  46. package/src/cli/listing-arg.ts +79 -11
  47. package/src/cli/not-a-ticker.ts +4 -0
  48. package/src/cli/options.ts +29 -1
  49. package/src/cli/pane-functions/catalog.ts +70 -12
  50. package/src/cli/pane-functions/function-help.ts +1 -1
  51. package/src/cli/pane-functions/headless.ts +68 -3
  52. package/src/cli/pane-functions/index.ts +2 -2
  53. package/src/cli/pane-functions/options.ts +7 -0
  54. package/src/cli/pane-functions/resolver.ts +104 -15
  55. package/src/cli/pane-functions/screenshot-payload.ts +3 -0
  56. package/src/cli/report-tables.ts +20 -5
  57. package/src/cli/result.ts +22 -4
  58. package/src/cli/shot-temp-dir.ts +30 -0
  59. package/src/cli/suffixed-listing-rows.ts +11 -0
  60. package/src/cli/symbol-args.ts +5 -3
  61. package/src/cli/symbol-list.ts +23 -10
  62. package/src/cli/symbol-rows.ts +135 -3
  63. package/src/cli/treasury-yields.ts +15 -1
  64. package/src/components/chart/composite/composite-chart.tsx +3 -3
  65. package/src/components/chart/composite/format.ts +2 -1
  66. package/src/components/chart/composite/panel-surface/axis-markers.ts +133 -0
  67. package/src/components/chart/composite/panel-surface/level-labels.tsx +78 -0
  68. package/src/components/chart/composite/panel-surface/overlays.ts +108 -0
  69. package/src/components/chart/composite/panel-surface/pan-coast.ts +54 -0
  70. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +138 -0
  71. package/src/components/chart/composite/panel-surface/panel-levels.ts +47 -0
  72. package/src/components/chart/composite/panel-surface/plot-gestures.ts +403 -0
  73. package/src/components/chart/composite/panel-surface/plot-pointer.ts +65 -0
  74. package/src/components/chart/composite/panel-surface/plot-wheel.ts +102 -0
  75. package/src/components/chart/composite/panel-surface/pointer.ts +12 -0
  76. package/src/components/chart/composite/panel-surface/props.ts +79 -0
  77. package/src/components/chart/composite/panel-surface/tool-readout.ts +151 -0
  78. package/src/components/chart/composite/panel-surface/value-axis-gestures.ts +152 -0
  79. package/src/components/chart/composite/panel-surface.tsx +81 -1177
  80. package/src/components/command-bar/commands/collection-list.ts +1 -0
  81. package/src/components/command-bar/commands/direct/index.ts +31 -8
  82. package/src/components/command-bar/commands/registry.ts +7 -0
  83. package/src/components/command-bar/routes/root/command-items.ts +8 -0
  84. package/src/components/command-bar/routes/root/results.ts +19 -2
  85. package/src/components/command-bar/routes/root/runtime.ts +3 -2
  86. package/src/components/command-bar/routes/root/selection.ts +3 -2
  87. package/src/components/command-bar/routes/root/shortcuts.ts +15 -0
  88. package/src/components/company-logo.tsx +10 -3
  89. package/src/components/data-table/sections.ts +6 -1
  90. package/src/components/layout/pane/title.ts +16 -6
  91. package/src/components/layout/shell/index.tsx +5 -1
  92. package/src/components/layout/shell/ticker-link-menu.ts +12 -9
  93. package/src/components/pane-settings-dialog/tui.tsx +6 -3
  94. package/src/components/pane-settings-dialog.tsx +2 -1
  95. package/src/components/pane-template-wizard.tsx +2 -0
  96. package/src/components/ticker/badge/format.ts +12 -3
  97. package/src/components/ticker/badge/index.tsx +9 -3
  98. package/src/components/ticker/list-table-view.tsx +119 -17
  99. package/src/components/ui/choice-dialog.tsx +1 -1
  100. package/src/components/ui/confirm-dialog.tsx +3 -2
  101. package/src/components/ui/data-table/display-columns.ts +16 -0
  102. package/src/components/ui/data-table/index.tsx +40 -9
  103. package/src/components/ui/data-table/types.ts +14 -0
  104. package/src/components/ui/frame.tsx +7 -3
  105. package/src/components/ui/icon.tsx +4 -2
  106. package/src/components/ui/list-view.tsx +8 -0
  107. package/src/components/ui/number-prompt-dialog.tsx +2 -1
  108. package/src/components/use-pane-notice-footer.tsx +3 -1
  109. package/src/core/state/app/layout-reducer.ts +3 -1
  110. package/src/core/state/app/layout.ts +2 -2
  111. package/src/data/config/layout.ts +14 -0
  112. package/src/data/config/store/normalize.ts +11 -1
  113. package/src/docs/snapshot.json +2 -2
  114. package/src/i18n/es.ts +39 -0
  115. package/src/i18n/ja.ts +39 -0
  116. package/src/i18n/ko.ts +39 -0
  117. package/src/i18n/zh-cn.ts +39 -0
  118. package/src/i18n/zh-tw.ts +39 -0
  119. package/src/layout/pane-follow.ts +141 -4
  120. package/src/layout/pane-layout-move.ts +10 -7
  121. package/src/layout/ticker-navigation.ts +13 -19
  122. package/src/layout/ticker-retarget.ts +3 -2
  123. package/src/market-data/market/format.ts +35 -1
  124. package/src/market-data/market/index-level.ts +19 -0
  125. package/src/market-data/quotes/contributions.ts +13 -0
  126. package/src/market-data/quotes/export-identity.ts +36 -1
  127. package/src/market-data/quotes/resolution.ts +16 -0
  128. package/src/plugins/builtin/account-management/keyboard.ts +14 -0
  129. package/src/plugins/builtin/account-management/model.ts +2 -0
  130. package/src/plugins/builtin/account-management/pane.tsx +79 -7
  131. package/src/plugins/builtin/account-management/password-dialog.tsx +2 -2
  132. package/src/plugins/builtin/account-management/payment-recovery-row.tsx +97 -0
  133. package/src/plugins/builtin/account-management/yearly-plan-row.tsx +359 -0
  134. package/src/plugins/builtin/analytics/risk-client.ts +12 -2
  135. package/src/plugins/builtin/analytics/risk-headless.ts +66 -6
  136. package/src/plugins/builtin/analytics/risk-math.ts +23 -6
  137. package/src/plugins/builtin/analytics/risk-model.ts +20 -9
  138. package/src/plugins/builtin/analytics/risk-pane.tsx +2 -2
  139. package/src/plugins/builtin/awards/pane.tsx +6 -8
  140. package/src/plugins/builtin/changelog/index.tsx +6 -44
  141. package/src/plugins/builtin/changelog/versions.ts +17 -68
  142. package/src/plugins/builtin/chart-composer/catalog-inventory.ts +5 -2
  143. package/src/plugins/builtin/chart-composer/editor.tsx +1 -0
  144. package/src/plugins/builtin/chart-composer/pane.tsx +1 -1
  145. package/src/plugins/builtin/chart-composer/quick-add.tsx +4 -1
  146. package/src/plugins/builtin/chart-composer/series-catalog.ts +17 -1
  147. package/src/plugins/builtin/cloud/askg/executor.ts +2 -1
  148. package/src/plugins/builtin/cloud/askg/sources.ts +2 -1
  149. package/src/plugins/builtin/cloud/plugin.tsx +2 -0
  150. package/src/plugins/builtin/cloud/thesis/module.tsx +2 -0
  151. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +6 -2
  152. package/src/plugins/builtin/cpi/headless.ts +6 -1
  153. package/src/plugins/builtin/cpi/model.ts +17 -0
  154. package/src/plugins/builtin/cpi/pane.tsx +4 -2
  155. package/src/plugins/builtin/crypto-board/client.ts +6 -1
  156. package/src/plugins/builtin/crypto-board/headless.ts +10 -2
  157. package/src/plugins/builtin/crypto-board/model.ts +89 -11
  158. package/src/plugins/builtin/crypto-board/pane.tsx +20 -5
  159. package/src/plugins/builtin/debt-maturities/model.ts +1 -1
  160. package/src/plugins/builtin/dividend-yield/client.ts +24 -2
  161. package/src/plugins/builtin/dividend-yield/headless.ts +4 -2
  162. package/src/plugins/builtin/dividend-yield/ranking.ts +2 -1
  163. package/src/plugins/builtin/dividend-yield/view.ts +5 -1
  164. package/src/plugins/builtin/earnings/board-table.ts +1 -1
  165. package/src/plugins/builtin/earnings/board.tsx +36 -16
  166. package/src/plugins/builtin/earnings/highlight.ts +47 -0
  167. package/src/plugins/builtin/earnings/history-table.ts +9 -1
  168. package/src/plugins/builtin/earnings/index.tsx +1 -1
  169. package/src/plugins/builtin/earnings-calls/pane.tsx +2 -2
  170. package/src/plugins/builtin/earnings-ripple/index.tsx +2 -0
  171. package/src/plugins/builtin/econ/calendar-model.ts +17 -1
  172. package/src/plugins/builtin/econ/fred-catalog.ts +33 -4
  173. package/src/plugins/builtin/econ-statistics/headless.ts +21 -0
  174. package/src/plugins/builtin/estimate-revisions/model.ts +1 -1
  175. package/src/plugins/builtin/exposure/index.tsx +1 -1
  176. package/src/plugins/builtin/macro-day/headless.ts +21 -10
  177. package/src/plugins/builtin/macro-day/model.ts +42 -3
  178. package/src/plugins/builtin/macro-day/pane.tsx +26 -8
  179. package/src/plugins/builtin/macro-day/releases.ts +24 -1
  180. package/src/plugins/builtin/market-valuation/detail.tsx +3 -3
  181. package/src/plugins/builtin/market-valuation/headless.ts +11 -4
  182. package/src/plugins/builtin/market-valuation/pane.tsx +3 -1
  183. package/src/plugins/builtin/market-valuation/view.ts +14 -0
  184. package/src/plugins/builtin/money-markets/client.ts +4 -1
  185. package/src/plugins/builtin/money-markets/headless.ts +15 -4
  186. package/src/plugins/builtin/money-markets/index.tsx +1 -1
  187. package/src/plugins/builtin/money-markets/pane.tsx +7 -1
  188. package/src/plugins/builtin/news/wire/news/detail-view.tsx +20 -8
  189. package/src/plugins/builtin/pe-band/pane.tsx +1 -1
  190. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -2
  191. package/src/plugins/builtin/portfolio-list/cli/period-report.ts +61 -11
  192. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +11 -3
  193. package/src/plugins/builtin/portfolio-list/cli/render.ts +8 -1
  194. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +178 -17
  195. package/src/plugins/builtin/portfolio-list/headless.ts +33 -6
  196. package/src/plugins/builtin/portfolio-list/pane/groups.tsx +220 -0
  197. package/src/plugins/builtin/portfolio-list/pane/index.tsx +95 -18
  198. package/src/plugins/builtin/portfolio-list/pane/period-pnl.ts +24 -6
  199. package/src/plugins/builtin/portfolio-list/period-pnl.ts +16 -1
  200. package/src/plugins/builtin/portfolio-list/summary/index.tsx +4 -1
  201. package/src/plugins/builtin/portfolio-list/summary/totals.ts +6 -4
  202. package/src/plugins/builtin/portfolio-list/table.tsx +38 -16
  203. package/src/plugins/builtin/research/corporate-actions-pane.tsx +4 -2
  204. package/src/plugins/builtin/research/relative-valuation-headless.ts +15 -5
  205. package/src/plugins/builtin/research/relative-valuation-model.ts +7 -1
  206. package/src/plugins/builtin/research/relative-valuation-pane.tsx +7 -4
  207. package/src/plugins/builtin/shared/cloud-upgrade.ts +4 -2
  208. package/src/plugins/builtin/shared/cpi-year-gap.ts +67 -0
  209. package/src/plugins/builtin/shared/headless-options.ts +1 -1
  210. package/src/plugins/builtin/social-mentions/model.ts +2 -2
  211. package/src/plugins/builtin/thirteenf/pane.tsx +1 -1
  212. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +45 -2
  213. package/src/plugins/builtin/ticker-detail/financials/model.ts +51 -16
  214. package/src/plugins/builtin/ticker-detail/financials/nopat.ts +16 -0
  215. package/src/plugins/builtin/ticker-detail/financials/ratios.ts +44 -13
  216. package/src/plugins/builtin/ticker-detail/financials/schema.ts +33 -2
  217. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +4 -2
  218. package/src/plugins/builtin/ticker-detail/headless-schema.ts +30 -4
  219. package/src/plugins/builtin/ticker-detail/headless.ts +280 -35
  220. package/src/plugins/builtin/ticker-detail/overview/components.tsx +4 -5
  221. package/src/plugins/builtin/ticker-detail/overview/model.ts +9 -2
  222. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +10 -2
  223. package/src/plugins/builtin/ticker-detail/pharma-signals/eligibility.ts +32 -0
  224. package/src/plugins/builtin/ticker-detail/pharma-signals/tab.tsx +162 -0
  225. package/src/plugins/builtin/ticker-detail/pharma-signals/waitlist.ts +126 -0
  226. package/src/plugins/builtin/ticker-detail/research-groups.ts +6 -4
  227. package/src/plugins/builtin/ticker-detail/research-tabs.ts +11 -0
  228. package/src/portfolio/collection-name.ts +2 -1
  229. package/src/portfolio/column-values.ts +34 -12
  230. package/src/portfolio/listed-symbol.ts +4 -2
  231. package/src/portfolio/period-pnl.ts +51 -1
  232. package/src/portfolio/suffixed-listings.ts +3 -1
  233. package/src/portfolio/watchlist-groups.ts +212 -0
  234. package/src/react/ticker-source.ts +3 -1
  235. package/src/renderers/dom/dialog-host.tsx +5 -5
  236. package/src/renderers/dom/styles.css +7 -0
  237. package/src/renderers/electrobun/view/remote/capability-invoker.ts +1 -1
  238. package/src/renderers/opentui/dialog-host.tsx +3 -4
  239. package/src/sources/gloomberb-cloud/normalizers.ts +5 -0
  240. package/src/sources/provider-router/history.ts +5 -2
  241. package/src/state/app/bootstrap.ts +11 -0
  242. package/src/state/app/context/index.tsx +6 -0
  243. package/src/sync/collections-contributor.ts +5 -2
  244. package/src/sync/config-merge.ts +10 -2
  245. package/src/sync/sanitize.ts +28 -0
  246. package/src/telemetry/usage-counts.ts +17 -0
  247. package/src/test-support/plugin-persistence.ts +12 -0
  248. package/src/tickers/company-name-listing.ts +4 -3
  249. package/src/tickers/company-name.ts +19 -1
  250. package/src/tickers/instrument-coverage.ts +27 -0
  251. package/src/tickers/search/home-listing.ts +38 -1
  252. package/src/tickers/search/index.ts +3 -2
  253. package/src/tickers/search/ranking.ts +21 -2
  254. package/src/time-series/base-series.ts +4 -0
  255. package/src/time-series/chart-seed.ts +1 -1
  256. package/src/time-series/financial-period-coverage.ts +4 -12
  257. package/src/time-series/parsed-history-cache.ts +1 -1
  258. package/src/time-series/resolve.ts +1 -1
  259. package/src/time-series/types.ts +5 -2
  260. package/src/time-series/use-chart-resolution.ts +6 -1
  261. package/src/types/config.ts +32 -0
  262. package/src/types/financials.ts +13 -0
  263. package/src/types/headless.ts +7 -0
  264. package/src/types/plugin-context.ts +5 -0
  265. package/src/types/ticker.ts +14 -0
  266. package/src/ui/ascii-font.ts +1 -4
  267. package/src/ui/dialog-stack.ts +17 -0
  268. package/src/ui/dialog.tsx +6 -2
  269. package/src/utils/async-deadline.ts +2 -2
  270. package/src/utils/crypto-pair.ts +9 -0
  271. package/src/utils/csv.ts +44 -5
  272. package/src/utils/exchanges.ts +13 -0
  273. package/src/utils/financial-statements.ts +60 -3
  274. package/src/utils/futures-generic.ts +17 -0
  275. package/src/utils/trailing-dividend.ts +13 -3
@@ -110,6 +110,7 @@ function buildRelativeColumns(
110
110
  peNamesYear = false,
111
111
  growthLabel = REVENUE_GROWTH_LABEL,
112
112
  symbolWidth = SYMBOL_WIDTH,
113
+ forwardNamesYear = false,
113
114
  ): RelativeColumn[] {
114
115
  // The name gives back what a wide ticker takes, so the figures keep their place.
115
116
  const nameWidth = Math.max(10, 16 - (symbolWidth - SYMBOL_WIDTH));
@@ -129,7 +130,8 @@ function buildRelativeColumns(
129
130
  { id: "marketCap", label: `MCAP ${baseCurrency}`, width: capWidth, align: "right" },
130
131
  // Wider while a peer's P/E is on its latest fiscal year's EPS and names it ("24.6 FY Mar-26").
131
132
  { id: "trailingPE", label: "P/E", width: peNamesYear ? 14 : metricWidth, align: "right" },
132
- { id: "forwardPE", label: "FWD", width: metricWidth, align: "right" },
133
+ // Wider while a peer's forward P/E names the fiscal year of its consensus ("24.8 FY28").
134
+ { id: "forwardPE", label: "FWD", width: forwardNamesYear ? 10 : metricWidth, align: "right" },
133
135
  { id: "evSales", label: "EV/S", width: metricWidth, align: "right" },
134
136
  { id: "fcfYield", label: "FCF%", width: metricWidth, align: "right" },
135
137
  // Latest quarter against the year before, and a trailing-twelve-month margin.
@@ -284,11 +286,12 @@ export function RelativeValuationPane({ focused, width, height }: PaneProps) {
284
286
  const extendedSessionsKey = extendedSessionsOf(rows).join(",");
285
287
  const marginNamesYear = rows.some((row) => row.operatingMarginPeriod != null);
286
288
  const peNamesYear = rows.some((row) => row.trailingPEPeriod != null);
289
+ const forwardNamesYear = rows.some((row) => row.forwardPEPeriod != null);
287
290
  const growthLabel = revenueGrowthHeader(rows, REVENUE_GROWTH_LABEL, PERIOD_REVENUE_GROWTH_LABEL);
288
291
  const columns = useMemo(
289
292
  () => buildRelativeColumns(baseCurrency, extendedSessionsKey ? extendedSessionsKey.split(",") as ExtendedSession[] : [], marginNamesYear, peNamesYear,
290
- growthLabel, symbolWidth),
291
- [baseCurrency, extendedSessionsKey, marginNamesYear, peNamesYear, growthLabel, symbolWidth],
293
+ growthLabel, symbolWidth, forwardNamesYear),
294
+ [baseCurrency, extendedSessionsKey, marginNamesYear, peNamesYear, growthLabel, symbolWidth, forwardNamesYear],
292
295
  );
293
296
 
294
297
  const comparableRows = useMemo(() => rows.map((row) => ({
@@ -382,7 +385,7 @@ export function RelativeValuationPane({ focused, width, height }: PaneProps) {
382
385
  return { text: `${formatPriceEarnings(row.reportedMultiples.trailingPE)}${row.trailingPEPeriod ? ` ${row.trailingPEPeriod}` : ""}`, color: colors.text };
383
386
  case "forwardPE":
384
387
  if (row.notMeaningful.forwardPE) return notMeaningfulCell();
385
- return { text: formatPriceEarnings(row.reportedMultiples.forwardPE), color: colors.text };
388
+ return { text: `${formatPriceEarnings(row.reportedMultiples.forwardPE)}${row.forwardPEPeriod ? ` ${row.forwardPEPeriod}` : ""}`, color: colors.text };
386
389
  case "evSales":
387
390
  // A withdrawn EV says so, one at or below zero reads N/M as a P/E over a loss does; the footer says why.
388
391
  if (row.evSales == null && row.notMeaningful.evSales) return notMeaningfulCell();
@@ -53,6 +53,8 @@ interface CloudUpgradeOptions {
53
53
  * never for a press ignored as a repeat.
54
54
  */
55
55
  onOpening?: () => void;
56
+ /** What the press is about, said under the sign-up dialog's title when it opens first (`Stock quotes are 15 min delayed`). */
57
+ reason?: string;
56
58
  }
57
59
 
58
60
  function recordUpgradeIntent(placement: string | undefined): void {
@@ -178,7 +180,7 @@ export function openCloudUpgradeUrl(placement: string): boolean {
178
180
  return true;
179
181
  }
180
182
 
181
- const CLOUD_UPGRADE_OPTION_KEYS: ReadonlyArray<keyof CloudUpgradeOptions> = ["placement", "interval", "recordIntent", "sheet", "onOpening"];
183
+ const CLOUD_UPGRADE_OPTION_KEYS: ReadonlyArray<keyof CloudUpgradeOptions> = ["placement", "interval", "recordIntent", "sheet", "onOpening", "reason"];
182
184
 
183
185
  /** A press event carries none of these keys, so it never reads as options. */
184
186
  function isCloudUpgradeOptions(value: unknown): value is CloudUpgradeOptions {
@@ -243,7 +245,7 @@ export function useCloudUpgradeAction(placement: string): (options?: unknown) =>
243
245
  if (resolvePlanAccess(apiClient.getCurrentUser()).hasProAccess) return;
244
246
  void openUpgradeRef.current({ ...checkout, recordIntent: false });
245
247
  };
246
- if (requestAuthDialog({ mode: "signup", onSignedIn: continueSignedIn })) {
248
+ if (requestAuthDialog({ mode: "signup", onSignedIn: continueSignedIn, ...(checkout.reason ? { reason: checkout.reason } : {}) })) {
247
249
  if (checkout.recordIntent !== false) recordUpgradeIntent(checkout.placement);
248
250
  return;
249
251
  }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * The months BLS never published a CPI index for: October 2025, which the
3
+ * 2025 shutdown left uncollected. Every index of the release, all items and
4
+ * core among them, has no level that month, so a change against it has none.
5
+ */
6
+ const UNPUBLISHED_CPI_MONTHS: ReadonlySet<string> = new Set(["2025-10"]);
7
+
8
+ const MONTH_NAMES = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November",
9
+ "December"];
10
+
11
+ /** "October 2025" from 2025-10 (a `YYYY-MM-DD` date names its month too). */
12
+ const monthName = (period: string) => `${MONTH_NAMES[Number(period.slice(5, 7)) - 1]} ${period.slice(0, 4)}`;
13
+
14
+ /** The month before or after one, `YYYY-MM`. */
15
+ function shiftMonth(period: string, months: number): string {
16
+ const at = new Date(Date.UTC(Number(period.slice(0, 4)), Number(period.slice(5, 7)) - 1 + months, 1));
17
+ return at.toISOString().slice(0, 7);
18
+ }
19
+
20
+ /**
21
+ * Why a CPI month has no change over twelve months, when the month a year
22
+ * before it has no index: "BLS published no October 2025 index, so no
23
+ * October 2026 y/y". Null for any other month (`YYYY-MM`).
24
+ */
25
+ function cpiYearGapReason(period: string): string | null {
26
+ const yearAgo = shiftMonth(period, -12);
27
+ return UNPUBLISHED_CPI_MONTHS.has(yearAgo) ? `BLS published no ${monthName(yearAgo)} index, so no ${monthName(period)} y/y` : null;
28
+ }
29
+
30
+ /**
31
+ * The line a CPI table with no year-over-year change for `period` closes on:
32
+ * why, and the latest change it has, "BLS published no October 2025 index, so
33
+ * no October 2026 y/y; All items 3.7% in September 2026." `latest` is the
34
+ * latest month that has one and its change in percent, to one decimal as BLS
35
+ * prints it. Null when the month has its change or none is missing for that reason.
36
+ */
37
+ export function cpiYearGapNote(period: string, label: string, latest: { period: string; value: number } | null): string | null {
38
+ const reason = cpiYearGapReason(period);
39
+ if (!reason) return null;
40
+ return latest ? `${reason}; ${label} ${latest.value.toFixed(1)}% in ${monthName(latest.period)}.` : `${reason}.`;
41
+ }
42
+
43
+ /**
44
+ * For a CPI series whose latest change over twelve months is for `latest`
45
+ * (`YYYY-MM`, or its first day), why the month after it has none, and the
46
+ * latest month's name: ECST's CPI y/y reads September 2026 after October's
47
+ * CPI is out, as October has no y/y. Null when the next month has its change.
48
+ */
49
+ export function cpiNextYearGap(latest: string): { reason: string; latestMonth: string } | null {
50
+ const month = latest.slice(0, 7);
51
+ const reason = cpiYearGapReason(shiftMonth(month, 1));
52
+ return reason ? { reason, latestMonth: monthName(month) } : null;
53
+ }
54
+
55
+ /** The US CPI changes over twelve months the economic calendar lists, all items and core, under the ids it gives them. */
56
+ const US_CPI_YOY_INDICATORS: ReadonlySet<string> = new Set(["us-inflation-rate-yoy", "us-core-inflation-rate-yoy"]);
57
+
58
+ /**
59
+ * Why an economic calendar row of a US CPI change over twelve months has no
60
+ * actual, when the month a year before the one it covers has no index: the
61
+ * release of 10 November 2026 covers October 2026, and October 2025 was never
62
+ * published. A US CPI release covers the month before it. Null for any other row.
63
+ */
64
+ export function cpiCalendarYearGapReason(row: { country: string; indicatorId?: string | null; actual: string | null; date: Date }): string | null {
65
+ if (row.country !== "US" || !row.indicatorId || !US_CPI_YOY_INDICATORS.has(row.indicatorId) || row.actual?.trim()) return null;
66
+ return cpiYearGapReason(shiftMonth(row.date.toISOString().slice(0, 7), -1));
67
+ }
@@ -36,7 +36,7 @@ export const FINANCIAL_PERIOD_OPTION: HeadlessPaneOptionDef = {
36
36
 
37
37
  export const FINANCIAL_PERIOD_COUNT_OPTION: HeadlessPaneOptionDef = {
38
38
  key: "periods",
39
- description: "Keep only the latest N annual or quarterly observations per ticker.",
39
+ description: "Keep only the latest N annual or quarterly periods per ticker; a period without a value stays as a gap.",
40
40
  type: "integer",
41
41
  aliases: ["years", "limit"],
42
42
  minimum: 1,
@@ -47,8 +47,8 @@ export type SocialColumn = Omit<DataTableColumn, "id"> & { id: SocialColumnId };
47
47
  export const SOCIAL_COLUMNS: SocialColumn[] = [
48
48
  { id: "day", label: "DATE", width: 12, align: "left" },
49
49
  { id: "mentions", label: "POSTS", width: 9, align: "right" },
50
- { id: "ratio", label: "VS MEDIAN", width: 10, align: "right" },
51
- { id: "wikiViews", label: "WIKI", width: 8, align: "right" },
50
+ { id: "ratio", label: "VS MEDIAN", width: 10, align: "right", omitWhenEmpty: true },
51
+ { id: "wikiViews", label: "WIKI", width: 8, align: "right", omitWhenEmpty: true },
52
52
  { id: "redditMentions", label: "REDDIT", width: 8, align: "right" },
53
53
  { id: "stance", label: "STANCE", width: 8, align: "right" },
54
54
  { id: "topPost", label: "TOP POST", width: 24, flexGrow: 1, align: "left" },
@@ -178,7 +178,7 @@ function ThirteenFBrowserPane({ focused, width, height, onDetailChange }: PanePr
178
178
  const columns = useMemo(() => {
179
179
  if (browserMode !== "performance") return buildBrowserColumns(false);
180
180
  const history = rows[0]?.priorReturns ?? [];
181
- return [...buildBrowserColumns().filter(column => !["rows", "filed"].includes(column.id)), ...history.map((point, index) => ({ id: `return${index + 1}` as FundBrowserColumnId, label: point.quarter, width: 10, align: "right" as const }))];
181
+ return [...buildBrowserColumns().filter(column => !["rows", "filed"].includes(column.id)), ...history.map((point, index) => ({ id: `return${index + 1}` as FundBrowserColumnId, label: point.quarter, width: 10, align: "right" as const, omitWhenEmpty: true }))];
182
182
  }, [browserMode, rows]);
183
183
 
184
184
  useEffect(() => {
@@ -4,6 +4,10 @@ import { dollarPairLabel, spotFromUsdValue, spotRateKind } from "../../../../mar
4
4
  import { loadHeadlessFinancials, resolveHeadlessInstrument } from "../../shared/headless-market-data";
5
5
  import { quoteObservation } from "../../shared/report-freshness";
6
6
  import { heldCurrencyUnit } from "../../../../utils/currency-units";
7
+ import { canonicalExchange, displayTickerKey, isUsListingExchange, parsePublicTickerKey } from "../../../../utils/exchanges";
8
+ import { listingSuffixCandidate } from "../../../../sources/listing-symbols";
9
+ import { companyLinesName } from "../../../../tickers/company-name";
10
+ import { logFailure } from "../../../../utils/log-failure";
7
11
  import { adrPairComparison, adrPairFigures, adrPairInputRows, adrPairLegs, ADR_PAIR_TEMPLATE_ID } from "./model";
8
12
 
9
13
  /** Words that ask for this report's figures without being its code: `fn CCL` answers with ADR. */
@@ -32,6 +36,43 @@ async function readQuote(key: string, ctx: LoadContext, failed: (error: unknown)
32
36
  return ctx.marketData.getQuote(instrument.symbol, instrument.exchange ?? "").catch(failed);
33
37
  }
34
38
 
39
+ /** The company's other lines a note names before it counts the rest ("and 2 more"). */
40
+ const OTHER_LINES_NAMED = 3;
41
+
42
+ /**
43
+ * The company's lines on venues other than the pair's, as their listings
44
+ * (Hong Kong's 0005:HKEX for HSBC beside its London home line), with the
45
+ * issuer's name. Null when the service cannot say.
46
+ */
47
+ async function otherLines(receiptKey: string, homeKey: string, ctx: LoadContext): Promise<{ issuer: string; lines: string[] } | null> {
48
+ const { getIssuerListings } = ctx.marketData;
49
+ if (!getIssuerListings) return null;
50
+ const [receipt, home] = await Promise.all([resolveHeadlessInstrument(ctx, receiptKey), resolveHeadlessInstrument(ctx, homeKey)]);
51
+ const homeVenue = canonicalExchange(home.exchange || listingSuffixCandidate(home.symbol)?.exchange || parsePublicTickerKey(homeKey).exchange);
52
+ const issuer = await Promise.resolve().then(() => getIssuerListings.call(ctx.marketData, receipt.symbol, receipt.exchange || undefined))
53
+ .catch(logFailure("plugins.adr-pair", "Reading the company's listings failed", null));
54
+ if (!issuer) return null;
55
+ // The receipt is the company's US line; another US line or the home venue's is no line abroad to add.
56
+ const lines = issuer.listings.filter((line) => {
57
+ const venue = canonicalExchange(line.exchange);
58
+ return venue && venue !== homeVenue && !isUsListingExchange(venue);
59
+ }).map((line) => parsePublicTickerKey(line.symbol).exchange ? displayTickerKey(line.symbol) : `${line.symbol}:${canonicalExchange(line.exchange)}`);
60
+ return { issuer: issuer.name, lines: [...new Set(lines)] };
61
+ }
62
+
63
+ /**
64
+ * "HSBC Holdings plc also lists 0005:HKEX.", the company named as the
65
+ * not-traded message names it (`companyLinesName`, by its home line's name),
66
+ * the first few lines and how many more. Null when it has no other line.
67
+ */
68
+ function otherLinesNote(other: { issuer: string; lines: string[] } | null, home: Quote | null): string | null {
69
+ if (!other || other.lines.length === 0) return null;
70
+ const named = other.lines.slice(0, OTHER_LINES_NAMED);
71
+ const more = other.lines.length - named.length;
72
+ const list = more > 0 ? `${named.join(", ")} and ${more} more` : named.join(", ");
73
+ return `${companyLinesName(home?.name, other.issuer)} also lists ${list}.`;
74
+ }
75
+
35
76
  export const adrPairHeadless: HeadlessPaneDefinition<"bundle"> = {
36
77
  shape: "bundle",
37
78
  argument: { kind: "ticker", description: "A depositary receipt (GGAL, TSM) or its home listing (GGAL.BA, 2330.TW)" },
@@ -63,12 +104,14 @@ export const adrPairHeadless: HeadlessPaneDefinition<"bundle"> = {
63
104
  errors.push(`${label}: ${error instanceof Error ? error.message : String(error)}`);
64
105
  return null;
65
106
  };
66
- const [receipt, home] = await Promise.all([
107
+ const [receipt, home, other] = await Promise.all([
67
108
  readQuote(legs.receiptKey, ctx, failed(legs.receiptKey)),
68
109
  readQuote(legs.homeKey, ctx, failed(legs.homeKey)),
110
+ otherLines(legs.receiptKey, legs.homeKey, ctx),
69
111
  ]);
70
112
  ctx.signal.throwIfAborted();
71
113
  const quotes = { receipt, home };
114
+ const otherLinesText = otherLinesNote(other, home);
72
115
  // A minor unit (GBp) is read as its currency, as the comparison reads the price.
73
116
  const homeCurrency = quotes.home?.currency ? heldCurrencyUnit(quotes.home.currency).currency : "";
74
117
  const spot = homeCurrency ? await readSpot(homeCurrency, ctx).catch(failed(dollarPairLabel(homeCurrency))) : null;
@@ -105,7 +148,7 @@ export const adrPairHeadless: HeadlessPaneDefinition<"bundle"> = {
105
148
  rows: rows.map(({ opens: _opens, ...row }) => row),
106
149
  },
107
150
  ],
108
- ...(comparison.timingNote ? { notes: [comparison.timingNote] } : {}),
151
+ ...(comparison.timingNote || otherLinesText ? { notes: [comparison.timingNote, otherLinesText].filter((note): note is string => !!note) } : {}),
109
152
  ...(errors.length > 0 ? { errors } : {}),
110
153
  freshness: {
111
154
  observations: [quotes.receipt, quotes.home].filter((quote): quote is Quote => !!quote).map((quote) => ({ ...quoteObservation(quote) })),
@@ -10,7 +10,6 @@ import {
10
10
  displayWidth,
11
11
  formatGrowthShort,
12
12
  formatNumber,
13
- formatWithDivisor,
14
13
  padTo,
15
14
  pickUnit,
16
15
  } from "../../../../utils/format";
@@ -283,7 +282,20 @@ function formatFinancialValue(
283
282
  if (value == null || !Number.isFinite(value)) return MISSING_VALUE;
284
283
  if (row.format === "eps") return formatPerShareNumber(value);
285
284
  if (row.format === "percent") return `${formatNumber(value * 100, 1)}%`;
286
- return formatWithDivisor(value, row.divisor);
285
+ return formatFinancialAmount(value, row.divisor);
286
+ }
287
+
288
+ /**
289
+ * An amount in the table's one unit, to about three significant figures: `23.73` and `1,265.6`, a line a
290
+ * thousandth of the others as `0.001` rather than `0.00`, so no row needs a unit of its own.
291
+ */
292
+ export function formatFinancialAmount(value: number, divisor: number): string {
293
+ const scaled = value / divisor;
294
+ const magnitude = Math.abs(scaled);
295
+ if (magnitude >= 100) return formatNumber(scaled, 1);
296
+ if (magnitude >= 1 || scaled === 0) return scaled.toFixed(2);
297
+ if (magnitude >= 0.001) return scaled.toFixed(3);
298
+ return Number(scaled.toPrecision(2)).toString();
287
299
  }
288
300
 
289
301
  /**
@@ -300,9 +312,11 @@ export function formatFinancialHeader(date: string, currency?: string, dateSourc
300
312
  }
301
313
 
302
314
  /**
303
- * A report column's header (`gloom fn FA`): `formatFinancialHeader`, with a
304
- * half in the quarterly list named as one (`H1 FY26 2026-06-30`, or
305
- * `6M 2026-06-30` off the fiscal calendar), and a column Gloom Cloud filled
315
+ * A report column's header (`gloom fn FA`): the fiscal period as the pane's
316
+ * column names it and the day it ends (`FY2026 2026-09-30 USD bn (SEC
317
+ * date)`, `TTM Q3 FY26 2026-09-30 USD`), with a half in the quarterly list
318
+ * named as one (`H1 FY26 2026-06-30`, or `6M 2026-06-30` off the fiscal
319
+ * calendar), and a column Gloom Cloud filled
306
320
  * from the company's results announcements dated by them alone (fillDate):
307
321
  * `(announced 2026-08-20)` for its own results, `(comparative in the
308
322
  * 2026-08-20 announcement)` for a later period's comparative column. `rows`
@@ -316,11 +330,17 @@ export function financialReportHeader(
316
330
  rows: readonly FinancialStatement[] = [],
317
331
  ): string {
318
332
  const { date, dateSource } = statement;
319
- if (date === "TTM") return formatFinancialHeader(date, currency, dateSource, false, statement.aggregation?.periodEnd).trim();
333
+ // The fiscal period as the pane names it (`FY2026`, `Q3 FY26`, `TTM Q3 FY26`), then the day it ends.
334
+ const named = (name: string, end: string) => (name.endsWith(end) ? name : `${name} ${end}`);
335
+ if (date === "TTM") {
336
+ const end = statement.aggregation?.periodEnd;
337
+ const period = end ? named(financialColumnLabel(statement, kind, yearEndMonth), end) : "TTM";
338
+ return currency ? `${period} ${currency}` : period;
339
+ }
320
340
  const end = date.slice(0, 10);
321
341
  const months = kind === "quarterly" ? statementPeriodMonths(statement) : undefined;
322
342
  const longer = months && months > 3 ? longerPeriodLabel(end, months, yearEndMonth) : null;
323
- const period = !longer ? end : longer.endsWith(end) ? longer : `${longer} ${end}`;
343
+ const period = named(longer ?? financialColumnLabel(statement, kind, yearEndMonth), end);
324
344
  const filled = statement.filledFrom?.source === "results" ? fillDate(statement, rows) : null;
325
345
  const source = filled ? fillDateText(filled) : dateSource === "sec" ? "SEC date" : "provider date";
326
346
  return `${currency ? `${period} ${currency}` : period} (${source})`;
@@ -501,9 +521,11 @@ function resolveMetricUnit(
501
521
  }
502
522
 
503
523
  /**
504
- * The money unit most rows share (`bn`), said once beside the currency. Rows
505
- * in that unit drop their `(bn)`, and money rows too small for any unit are
506
- * shown in it; rows in another unit, and share counts, keep theirs.
524
+ * The money unit of the whole table (`bn`), said once beside the currency:
525
+ * the unit most rows would take on their own. Every money row is shown in it,
526
+ * a smaller line to more decimals (formatFinancialAmount), so a column copied
527
+ * out of the table is in one unit and no row carries a `(mn)` of its own.
528
+ * Share counts are no money and keep theirs.
507
529
  */
508
530
  export function shareFinancialUnit<T extends { unitLabel: string; label: string; moneyUnit: string | null; divisor: number }>(
509
531
  rows: readonly T[],
@@ -513,11 +535,7 @@ export function shareFinancialUnit<T extends { unitLabel: string; label: string;
513
535
  const unit = [...counts].sort((left, right) => right[1] - left[1])[0]?.[0];
514
536
  if (!unit) return { rows: [...rows], unit: undefined };
515
537
  return {
516
- rows: rows.map((row) => {
517
- if (row.moneyUnit === unit) return { ...row, unitLabel: row.label };
518
- if (row.moneyUnit === "") return { ...row, unitLabel: row.label, moneyUnit: unit, divisor: UNIT_DIVISORS[unit]! };
519
- return row;
520
- }),
538
+ rows: rows.map((row) => row.moneyUnit == null ? row : { ...row, unitLabel: row.label, moneyUnit: unit, divisor: UNIT_DIVISORS[unit]! }),
521
539
  unit,
522
540
  };
523
541
  }
@@ -527,6 +545,8 @@ export function buildFinancialRows(
527
545
  statements: FinancialStatement[],
528
546
  collapsedGroups: ReadonlySet<string>,
529
547
  depth = 0,
548
+ /** The lines the table already shows, above this one: a line equal to one of them is left out. */
549
+ shown: Array<Pick<MetricDef, "key" | "compute" | "format">> = [],
530
550
  ): FinancialTableRow[] {
531
551
  const rows: FinancialTableRow[] = [];
532
552
 
@@ -534,6 +554,11 @@ export function buildFinancialRows(
534
554
  if (!hasFinancialRowValue(def, statements)) continue;
535
555
 
536
556
  if (!isFinancialGroup(def)) {
557
+ // The same amount under another name further down (CapEx, then Purchase PPE) is shown once, where it is
558
+ // reported in every period the line above is; a line that differs in any period stays.
559
+ if (shown.some((line) => line.format === (def.format ?? "compact") && (line.key !== def.key || line.compute !== def.compute)
560
+ && repeatsLine(def, line, statements))) continue;
561
+ shown.push({ key: def.key, compute: def.compute, format: def.format ?? "compact" });
537
562
  const { unitLabel, moneyUnit, divisor, format } = resolveMetricUnit(statements, def, def.label);
538
563
  rows.push({
539
564
  kind: "metric",
@@ -561,6 +586,7 @@ export function buildFinancialRows(
561
586
  ? resolveMetricUnit(statements, { key: def.summaryKey, format: def.format ?? "compact" }, def.label)
562
587
  : { unitLabel: def.label, moneyUnit: null, divisor: 1, format: def.format ?? "compact" };
563
588
 
589
+ if (def.summaryKey) shown.push({ key: def.summaryKey, format: def.format ?? "compact" });
564
590
  rows.push({
565
591
  kind: "group",
566
592
  id: def.id,
@@ -577,7 +603,7 @@ export function buildFinancialRows(
577
603
  });
578
604
 
579
605
  if (expanded) {
580
- rows.push(...buildFinancialRows(children, statements, collapsedGroups, depth + 1));
606
+ rows.push(...buildFinancialRows(children, statements, collapsedGroups, depth + 1, shown));
581
607
  }
582
608
  }
583
609
 
@@ -618,6 +644,12 @@ interface FinancialTableModelRow {
618
644
  summaryKey?: keyof FinancialStatement;
619
645
  label: string;
620
646
  unitLabel: string;
647
+ /** How the row's figures read: money or a share count (`compact`), per-share earnings, or a percent of a fraction. */
648
+ format: FinancialMetricFormat;
649
+ /** What a `compact` figure is divided by to read in the row's unit (1e9 for `bn`). */
650
+ divisor: number;
651
+ /** The money unit word the figures are in (`bn`); null for share counts, per-share figures and percents. */
652
+ moneyUnit: string | null;
621
653
  depth: number;
622
654
  growthDirection: FinancialGrowthDirection;
623
655
  cells: FinancialTableCellModel[];
@@ -783,6 +815,9 @@ export function buildFinancialTableModel(
783
815
  summaryKey: row.kind === "group" ? row.summaryKey : undefined,
784
816
  label: row.label,
785
817
  unitLabel: row.unitLabel,
818
+ format: row.format,
819
+ divisor: row.divisor,
820
+ moneyUnit: row.moneyUnit,
786
821
  depth: row.depth,
787
822
  growthDirection: row.growthDirection,
788
823
  cells,
@@ -0,0 +1,16 @@
1
+ import type { FinancialStatement } from "../../../../types/financials";
2
+
3
+ const finite = (value: unknown): number | undefined => (typeof value === "number" && Number.isFinite(value) ? value : undefined);
4
+
5
+ /**
6
+ * Operating income after tax at the period's effective rate (tax provision ÷ pretax income, held between 0% and
7
+ * 100%); a pretax loss pays no tax. Undefined when a line is missing. ROIC and the reinvestment rate read it.
8
+ */
9
+ export function statementNopat(statement: FinancialStatement): number | undefined {
10
+ const operating = finite(statement.operatingIncome);
11
+ const tax = finite(statement.taxProvision);
12
+ const pretax = finite(statement.pretaxIncome);
13
+ if (operating === undefined || tax === undefined || pretax === undefined) return undefined;
14
+ const rate = pretax > 0 ? Math.min(1, Math.max(0, tax / pretax)) : 0;
15
+ return operating * (1 - rate);
16
+ }
@@ -4,6 +4,7 @@ import { MISSING_VALUE, formatNumber, pickUnit } from "../../../../utils/format"
4
4
  import { pricePointIntegrity } from "../../../../utils/price-history-integrity";
5
5
  import { formatPerShareNumber } from "../../../../utils/reported-money";
6
6
  import { hasStatementGap } from "../../../../utils/statement-gaps";
7
+ import { statementNopat } from "./nopat";
7
8
  import { debtAndLeases, leaseBasis, type LeaseBasis } from "../../../../utils/lease-liabilities";
8
9
  import { cashAndShortTermInvestments, excludesCashRunway, formatRunwayMonths, SHORT_RUNWAY_HISTORY, monthlyOperatingBurn, QUARTER_MONTHS, reportsShortTermTotal, runwayMonths, YEAR_MONTHS } from "../../../../utils/cash-runway";
9
10
  import {
@@ -21,17 +22,21 @@ import {
21
22
 
22
23
  /**
23
24
  * Why a ratio or one of its inputs has no number: a line the statements do
24
- * not carry for the period, a ratio whose denominator makes it meaningless
25
+ * not carry for the period, an average with no opening balance sheet on file
26
+ * (the period before the column's), a ratio whose denominator makes it meaningless
25
27
  * (a loss under P/E, negative equity under ROE), no close at the period end,
26
28
  * a close still loading, a quarter with fewer than four quarters to sum
27
29
  * for a trailing flow, or operations that brought cash in, where a runway
28
30
  * has no burn to divide by.
29
31
  */
30
- export type RatioGap = "not-reported" | "short-history" | "no-burn" | "not-meaningful" | "no-price" | "loading";
32
+ export type RatioGap = "not-reported" | "no-opening" | "short-history" | "no-burn" | "not-meaningful" | "no-price" | "loading";
31
33
  export type RatioAmount = number | RatioGap;
32
34
 
33
35
  export const RATIO_GAP_TEXT: Record<RatioGap, string> = {
34
36
  "not-reported": "not reported",
37
+ // An average of the opening and closing balance with no opening balance sheet on file: the oldest column's, a year's
38
+ // whose prior year is missing, a TTM column's without the quarter a year earlier.
39
+ "no-opening": "needs prior period",
35
40
  "short-history": SHORT_RUNWAY_HISTORY,
36
41
  "no-burn": "no burn",
37
42
  "not-meaningful": "N/M",
@@ -155,10 +160,11 @@ const balanceEnds = (...lines: BalanceLine[]) => ({ statement, opening }: RatioP
155
160
  return undefined;
156
161
  };
157
162
 
158
- /** The mean of the opening and closing balance. */
163
+ /** The mean of the opening and closing balance; a period with no opening balance sheet on file says it needs it. */
159
164
  const average = (...lines: BalanceLine[]) => {
160
165
  const ends = balanceEnds(...lines);
161
166
  return (period: RatioPeriod): RatioAmount => {
167
+ if (!period.opening) return "no-opening";
162
168
  const pair = ends(period);
163
169
  return pair ? (pair[0] + pair[1]) / 2 : "not-reported";
164
170
  };
@@ -201,6 +207,23 @@ const debtPlusEquity: BalanceLine = (statement) => {
201
207
  const common = equity(statement);
202
208
  return debt !== undefined && common !== undefined ? debt + common : undefined;
203
209
  };
210
+ /** Invested capital as ROIC reads it: the data vendor's line, else total debt plus equity. */
211
+ const investedCapital = line("investedCapital");
212
+
213
+ /**
214
+ * Invested capital less cash and short-term investments, averaged as ROIC averages it (both ends from the same
215
+ * line): the capital the operations use, so a debt-free company holding cash is not read as using it.
216
+ */
217
+ function averageOperatingCapital(period: RatioPeriod): RatioAmount {
218
+ const { statement, opening, shortTermTotalOnFile } = period;
219
+ if (!opening) return "no-opening";
220
+ const cash = (at: FinancialStatement) => cashAndShortTermInvestments(at, shortTermTotalOnFile)?.amount;
221
+ const [closeCash, openCash] = [cash(statement), cash(opening)];
222
+ if (closeCash === undefined || openCash === undefined) return "not-reported";
223
+ const ends = balanceEnds(investedCapital, debtPlusEquity)(period);
224
+ return ends ? (ends[0] - openCash + ends[1] - closeCash) / 2 : "not-reported";
225
+ }
226
+
204
227
  const freeCashFlow: BalanceLine = (statement) => {
205
228
  const reportedFlow = finite(statement.freeCashFlow);
206
229
  if (reportedFlow !== undefined) return reportedFlow;
@@ -240,14 +263,9 @@ const netIncome = flow("Net Income", line("netIncome"));
240
263
  const revenue = line("totalRevenue");
241
264
  const costOfRevenue = line("costOfRevenue");
242
265
 
243
- /** Operating income after tax at the period's effective rate; a pretax loss pays no tax. */
266
+ /** Operating income after tax at the period's effective rate; a pretax loss pays no tax (statementNopat). */
244
267
  function nopat({ statement }: RatioPeriod): RatioAmount {
245
- const operating = finite(statement.operatingIncome);
246
- const tax = finite(statement.taxProvision);
247
- const pretax = finite(statement.pretaxIncome);
248
- if (operating === undefined || tax === undefined || pretax === undefined) return "not-reported";
249
- const rate = pretax > 0 ? Math.min(1, Math.max(0, tax / pretax)) : 0;
250
- return operating * (1 - rate);
268
+ return reported(statementNopat(statement));
251
269
  }
252
270
 
253
271
  function dilutedEps({ statement }: RatioPeriod): RatioAmount {
@@ -366,7 +384,7 @@ export const RATIO_TABS: RatioTabDef[] = [
366
384
  inputs: [netIncome, { label: "Avg Equity", operator: "÷", format: "money", value: average(...equityLines) }],
367
385
  compute: ([income], period) => {
368
386
  const ends = equityEnds(period);
369
- return ends ? returnOnEquity(income!, ends) : "not-reported";
387
+ return ends ? returnOnEquity(income!, ends) : period.opening ? "not-reported" : "no-opening";
370
388
  },
371
389
  },
372
390
  {
@@ -384,7 +402,20 @@ export const RATIO_TABS: RatioTabDef[] = [
384
402
  signed: true,
385
403
  inputs: [
386
404
  { label: "NOPAT", format: "money", annualized: true, value: nopat },
387
- { label: "Avg Invested Capital", operator: "÷", format: "money", value: average(line("investedCapital"), debtPlusEquity) },
405
+ { label: "Avg Invested Capital", operator: "÷", format: "money", value: average(investedCapital, debtPlusEquity) },
406
+ ],
407
+ compute: ([income, base]) => over(income!, base!),
408
+ },
409
+ {
410
+ // ROIC with cash and short-term investments taken out of invested capital: Copart, debt free with its
411
+ // cash in its equity, reads its operations' return rather than one diluted by the cash.
412
+ id: "roic-ex-cash",
413
+ label: "ROIC ex Cash",
414
+ format: "percent",
415
+ signed: true,
416
+ inputs: [
417
+ { label: "NOPAT", format: "money", annualized: true, value: nopat },
418
+ { label: "Avg IC less Cash", operator: "÷", format: "money", value: averageOperatingCapital },
388
419
  ],
389
420
  compute: ([income, base]) => over(income!, base!),
390
421
  },
@@ -602,7 +633,7 @@ export const RATIO_TAB_KEYS = new Set(RATIO_TABS.map((tab) => tab.key));
602
633
  * report explains more than a missing close, and a close still loading may
603
634
  * yet arrive.
604
635
  */
605
- const GAP_ORDER: RatioGap[] = ["not-reported", "short-history", "no-burn", "not-meaningful", "no-price", "loading"];
636
+ const GAP_ORDER: RatioGap[] = ["not-reported", "no-opening", "short-history", "no-burn", "not-meaningful", "no-price", "loading"];
606
637
 
607
638
  function inputAmount(input: RatioInputDef, period: RatioPeriod): RatioAmount {
608
639
  if (!input.trailing || !period.quarterly) return input.value(period);
@@ -1,9 +1,26 @@
1
- import { revenueMargin } from "../../../../utils/growth";
1
+ import { revenueMargin, type Rate } from "../../../../utils/growth";
2
+ import type { FinancialStatement } from "../../../../types/financials";
2
3
  import type { FinancialSubTab } from "./model";
4
+ import { statementNopat } from "./nopat";
3
5
 
4
6
  /** A line over revenue: N/M where revenue is zero or negative. */
5
7
  const financialRatio = revenueMargin;
6
8
 
9
+ /** What went out on a line kept as a negative number (capex, acquisitions), as a positive amount. */
10
+ const spent = (value: number | undefined): number | undefined => (typeof value === "number" && Number.isFinite(value) ? Math.abs(value) : undefined);
11
+
12
+ /**
13
+ * The share of after-tax operating profit put back into the business: capex and acquisitions less D&A, over NOPAT
14
+ * (statementNopat). Acquisitions count where the statement reports them; N/M over NOPAT at or below zero.
15
+ */
16
+ function reinvestmentRate(statement: FinancialStatement): Rate | undefined {
17
+ const capex = spent(statement.capitalExpenditure);
18
+ const depreciation = statement.depreciationAndAmortization ?? statement.depreciationAmortizationDepletion;
19
+ const nopat = statementNopat(statement);
20
+ if (capex === undefined || typeof depreciation !== "number" || !Number.isFinite(depreciation) || nopat === undefined) return undefined;
21
+ return financialRatio(capex + (spent(statement.purchaseOfBusiness) ?? 0) - depreciation, nopat);
22
+ }
23
+
7
24
  const LOWER_IS_BETTER = "lower" as const;
8
25
  const NEUTRAL_GROWTH = "neutral" as const;
9
26
 
@@ -130,9 +147,23 @@ export const FINANCIAL_SUB_TABS: FinancialSubTab[] = [
130
147
  label: "Free Cash Flow",
131
148
  summaryKey: "freeCashFlow",
132
149
  defaultExpanded: true,
150
+ // Operating cash flow is the Operating group's own line below; a row here would repeat it.
133
151
  children: [
134
- { label: "Operating CF", key: "operatingCashFlow", format: "compact" },
135
152
  { label: "CapEx", key: "capitalExpenditure", format: "compact", outflow: true },
153
+ {
154
+ label: "CapEx / Revenue",
155
+ id: "capex-revenue",
156
+ compute: (statement) => financialRatio(spent(statement.capitalExpenditure), statement.totalRevenue),
157
+ format: "percent",
158
+ growthDirection: NEUTRAL_GROWTH,
159
+ },
160
+ {
161
+ label: "Reinvestment Rate",
162
+ id: "reinvestment-rate",
163
+ compute: reinvestmentRate,
164
+ format: "percent",
165
+ growthDirection: NEUTRAL_GROWTH,
166
+ },
136
167
  ],
137
168
  },
138
169
  {
@@ -150,10 +150,12 @@ export function ResolvedFinancialsTab({
150
150
  const [storedSubTab, setStoredSubTab] = usePaneStateValue<string>("financialSubTab", FINANCIAL_SUB_TABS[0]!.key);
151
151
  const resolvedSubTabKey = resolveFinancialSectionKey(storedSubTab);
152
152
  const subTabIdx = Math.max(0, FINANCIAL_SECTIONS.findIndex((tab) => tab.key === resolvedSubTabKey));
153
- // Ratios open collapsed: the inputs behind each one show on demand.
153
+ // Ratios open collapsed: the inputs behind each one show on demand. A capture of a ratio tab opens them all
154
+ // (`financialRatiosExpanded`), so the picture holds the inputs the report lists.
155
+ const [ratiosExpanded] = usePaneStateValue<boolean>("financialRatiosExpanded", false);
154
156
  const [collapsedGroups, setCollapsedGroups] = useState<Set<string>>(() => new Set([
155
157
  ...collectDefaultCollapsedGroupIds(FINANCIAL_SUB_TABS.flatMap((tab) => tab.rows)),
156
- ...RATIO_TABS.flatMap((tab) => tab.ratios.map((ratio) => ratio.id)),
158
+ ...ratiosExpanded ? [] : RATIO_TABS.flatMap((tab) => tab.ratios.map((ratio) => ratio.id)),
157
159
  ]));
158
160
  const [selectedRowId, setSelectedRowId] = useState<string | null>(null);
159
161
  const bodyScrollRef = useRef<ScrollBoxRenderable>(null);