@gloom-sh/terminal 0.20.14 → 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.
- package/package.json +1 -1
- package/src/api-client/index.ts +54 -0
- package/src/api-client/install-experiments.ts +8 -7
- package/src/api-client/paths.ts +2 -1
- package/src/api-client/product-waitlist.ts +63 -0
- package/src/api-client/request.ts +4 -2
- package/src/api-client/types/billing.ts +45 -0
- package/src/api-client/yearly-plan.ts +132 -0
- package/src/app/global-shortcuts.ts +5 -3
- package/src/app/pane-runtime/index.tsx +2 -2
- package/src/app/pane-runtime/plugin-bindings.ts +3 -1
- package/src/app/pane-runtime/ticker-open-runtime.ts +6 -1
- package/src/app/since-last-visit/keys.ts +26 -0
- package/src/app/since-last-visit/model.ts +266 -0
- package/src/app/since-last-visit/strip.tsx +193 -0
- package/src/app/since-last-visit/use-since-last-visit.ts +289 -0
- package/src/app/since-last-visit/visit-tracker.ts +191 -0
- package/src/app.tsx +15 -0
- package/src/cli/commands/market.ts +8 -4
- package/src/cli/commands/system.ts +29 -1
- package/src/cli/commands/ticker.ts +12 -5
- package/src/cli/desktop-pane-shot-api-policy.ts +4 -1
- package/src/cli/desktop-pane-shot-browser.ts +2 -1
- package/src/cli/desktop-pane-shot-view.ts +3 -7
- package/src/cli/desktop-pane-shot.ts +26 -28
- package/src/cli/help.ts +1 -0
- package/src/cli/history-rows.ts +24 -0
- package/src/cli/index.ts +4 -0
- package/src/cli/options.ts +29 -1
- package/src/cli/pane-functions/catalog.ts +41 -4
- package/src/cli/pane-functions/function-help.ts +1 -1
- package/src/cli/pane-functions/headless.ts +63 -1
- package/src/cli/pane-functions/index.ts +2 -2
- package/src/cli/pane-functions/resolver.ts +43 -0
- package/src/cli/pane-functions/screenshot-payload.ts +3 -0
- package/src/cli/report-tables.ts +20 -5
- package/src/cli/shot-temp-dir.ts +30 -0
- package/src/cli/suffixed-listing-rows.ts +11 -0
- package/src/components/chart/composite/composite-chart.tsx +3 -3
- package/src/components/command-bar/commands/direct/index.ts +31 -8
- package/src/components/command-bar/commands/registry.ts +7 -0
- package/src/components/command-bar/routes/root/command-items.ts +8 -0
- package/src/components/command-bar/routes/root/results.ts +16 -0
- package/src/components/company-logo.tsx +10 -3
- package/src/components/data-table/sections.ts +6 -1
- package/src/components/layout/pane/title.ts +6 -2
- package/src/components/layout/shell/index.tsx +5 -1
- package/src/components/layout/shell/ticker-link-menu.ts +12 -9
- package/src/components/ticker/badge/format.ts +12 -3
- package/src/components/ticker/badge/index.tsx +9 -3
- package/src/components/ticker/list-table-view.tsx +119 -17
- package/src/components/ui/data-table/display-columns.ts +16 -0
- package/src/components/ui/data-table/index.tsx +40 -9
- package/src/components/ui/data-table/types.ts +14 -0
- package/src/core/state/app/layout-reducer.ts +3 -1
- package/src/core/state/app/layout.ts +2 -2
- package/src/data/config/layout.ts +14 -0
- package/src/data/config/store/normalize.ts +11 -1
- package/src/i18n/es.ts +38 -0
- package/src/i18n/ja.ts +38 -0
- package/src/i18n/ko.ts +38 -0
- package/src/i18n/zh-cn.ts +38 -0
- package/src/i18n/zh-tw.ts +38 -0
- package/src/layout/pane-follow.ts +141 -4
- package/src/layout/pane-layout-move.ts +10 -7
- package/src/layout/ticker-navigation.ts +13 -19
- package/src/layout/ticker-retarget.ts +3 -2
- package/src/market-data/market/index-level.ts +19 -0
- package/src/plugins/builtin/account-management/keyboard.ts +14 -0
- package/src/plugins/builtin/account-management/model.ts +2 -0
- package/src/plugins/builtin/account-management/pane.tsx +79 -7
- package/src/plugins/builtin/account-management/payment-recovery-row.tsx +97 -0
- package/src/plugins/builtin/account-management/yearly-plan-row.tsx +359 -0
- package/src/plugins/builtin/awards/pane.tsx +6 -8
- package/src/plugins/builtin/changelog/index.tsx +6 -44
- package/src/plugins/builtin/changelog/versions.ts +17 -68
- package/src/plugins/builtin/cloud/askg/executor.ts +2 -1
- package/src/plugins/builtin/cloud/askg/sources.ts +2 -1
- package/src/plugins/builtin/cpi/pane.tsx +1 -1
- package/src/plugins/builtin/debt-maturities/model.ts +1 -1
- package/src/plugins/builtin/earnings/board-table.ts +1 -1
- package/src/plugins/builtin/earnings/board.tsx +36 -16
- package/src/plugins/builtin/earnings/highlight.ts +47 -0
- package/src/plugins/builtin/earnings/history-table.ts +1 -1
- package/src/plugins/builtin/earnings/index.tsx +1 -1
- package/src/plugins/builtin/earnings-calls/pane.tsx +2 -2
- package/src/plugins/builtin/estimate-revisions/model.ts +1 -1
- package/src/plugins/builtin/exposure/index.tsx +1 -1
- package/src/plugins/builtin/macro-day/model.ts +6 -4
- package/src/plugins/builtin/market-valuation/detail.tsx +3 -3
- package/src/plugins/builtin/market-valuation/headless.ts +11 -4
- package/src/plugins/builtin/market-valuation/pane.tsx +3 -1
- package/src/plugins/builtin/market-valuation/view.ts +14 -0
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +20 -8
- package/src/plugins/builtin/pe-band/pane.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/cli/render.ts +8 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +176 -17
- package/src/plugins/builtin/portfolio-list/pane/groups.tsx +220 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +90 -15
- package/src/plugins/builtin/portfolio-list/table.tsx +13 -1
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +4 -2
- package/src/plugins/builtin/research/relative-valuation-headless.ts +15 -5
- package/src/plugins/builtin/research/relative-valuation-model.ts +7 -1
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +7 -4
- package/src/plugins/builtin/shared/headless-options.ts +1 -1
- package/src/plugins/builtin/social-mentions/model.ts +2 -2
- package/src/plugins/builtin/thirteenf/pane.tsx +1 -1
- package/src/plugins/builtin/ticker-detail/financials/model.ts +51 -16
- package/src/plugins/builtin/ticker-detail/financials/nopat.ts +16 -0
- package/src/plugins/builtin/ticker-detail/financials/ratios.ts +44 -13
- package/src/plugins/builtin/ticker-detail/financials/schema.ts +33 -2
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +4 -2
- package/src/plugins/builtin/ticker-detail/headless-schema.ts +30 -4
- package/src/plugins/builtin/ticker-detail/headless.ts +254 -34
- package/src/plugins/builtin/ticker-detail/overview/model.ts +7 -3
- package/src/plugins/builtin/ticker-detail/pharma-signals/eligibility.ts +32 -0
- package/src/plugins/builtin/ticker-detail/pharma-signals/tab.tsx +162 -0
- package/src/plugins/builtin/ticker-detail/pharma-signals/waitlist.ts +126 -0
- package/src/plugins/builtin/ticker-detail/research-groups.ts +6 -4
- package/src/plugins/builtin/ticker-detail/research-tabs.ts +11 -0
- package/src/portfolio/column-values.ts +20 -8
- package/src/portfolio/suffixed-listings.ts +3 -1
- package/src/portfolio/watchlist-groups.ts +212 -0
- package/src/react/ticker-source.ts +3 -1
- package/src/renderers/dom/styles.css +7 -0
- package/src/state/app/bootstrap.ts +11 -0
- package/src/state/app/context/index.tsx +6 -0
- package/src/sync/collections-contributor.ts +5 -2
- package/src/sync/config-merge.ts +10 -2
- package/src/sync/sanitize.ts +28 -0
- package/src/telemetry/usage-counts.ts +17 -0
- package/src/time-series/chart-seed.ts +1 -1
- package/src/time-series/financial-period-coverage.ts +4 -12
- package/src/time-series/parsed-history-cache.ts +1 -1
- package/src/time-series/resolve.ts +1 -1
- package/src/time-series/use-chart-resolution.ts +6 -1
- package/src/types/config.ts +32 -0
- package/src/types/headless.ts +5 -0
- package/src/types/plugin-context.ts +5 -0
- package/src/types/ticker.ts +14 -0
- package/src/ui/ascii-font.ts +1 -4
- package/src/utils/async-deadline.ts +2 -2
- package/src/utils/csv.ts +44 -5
- package/src/utils/futures-generic.ts +3 -0
|
@@ -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(() => {
|
|
@@ -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
|
|
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`):
|
|
304
|
-
*
|
|
305
|
-
* `
|
|
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
|
-
|
|
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 =
|
|
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
|
|
505
|
-
*
|
|
506
|
-
*
|
|
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,
|
|
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
|
-
|
|
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(
|
|
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);
|
|
@@ -7,6 +7,9 @@ import { PRICE_WINDOW_FROM_HELP, PRICE_WINDOW_TO_HELP } from "../../../utils/pri
|
|
|
7
7
|
import type { HeadlessPaneOptionDef } from "../../../types/headless";
|
|
8
8
|
import { QUOTE_MONITOR_MAX_TICKERS } from "../../../tickers/list";
|
|
9
9
|
|
|
10
|
+
/** The most tickers one FA report reads: each is a full statements load. */
|
|
11
|
+
const FINANCIAL_REPORT_MAX_TICKERS = 10;
|
|
12
|
+
|
|
10
13
|
/** `--from 2007 --to 2009`: the report's bars for those dates. The pane keeps its range, so a capture refuses them. */
|
|
11
14
|
const WINDOW_OPTIONS: HeadlessPaneOptionDef[] = [
|
|
12
15
|
{ key: "from", type: "string", placeholder: "year|date", description: PRICE_WINDOW_FROM_HELP, example: "--from 2007 --to 2009",
|
|
@@ -19,7 +22,12 @@ type PaneSchema = Pick<HeadlessPaneDefinition, "argument" | "options" | "discove
|
|
|
19
22
|
|
|
20
23
|
export const paneSchemas = {
|
|
21
24
|
"financial-analysis-pane": {
|
|
22
|
-
|
|
25
|
+
// A ticker, or several in one long table; the pane, and so `shot`, shows one.
|
|
26
|
+
argument: {
|
|
27
|
+
kind: "tickers", maximum: FINANCIAL_REPORT_MAX_TICKERS, placeholder: "ticker",
|
|
28
|
+
description: `Company ticker, or up to ${FINANCIAL_REPORT_MAX_TICKERS} in one long table (Ticker, Period, Period End, Metric, Value, Unit).`,
|
|
29
|
+
examples: ["V MCO CPRT --statement profitability"],
|
|
30
|
+
},
|
|
23
31
|
options: [
|
|
24
32
|
FINANCIAL_PERIOD_OPTION,
|
|
25
33
|
{
|
|
@@ -39,14 +47,32 @@ export const paneSchemas = {
|
|
|
39
47
|
],
|
|
40
48
|
defaultValue: "income",
|
|
41
49
|
},
|
|
50
|
+
{
|
|
51
|
+
key: "layout",
|
|
52
|
+
description: "wide: one ticker's periods as columns, as the pane shows them. long: a row per ticker, fiscal period and metric, each with its period end and unit, for pasting several companies into one table. Default wide for one ticker, long for several.",
|
|
53
|
+
type: "enum",
|
|
54
|
+
values: [{ value: "wide" }, { value: "long", aliases: ["tidy", "rows"] }],
|
|
55
|
+
example: "--layout long --csv",
|
|
56
|
+
shot: { reportOnly: "lays the report's rows out a row per period and metric" },
|
|
57
|
+
},
|
|
42
58
|
],
|
|
43
59
|
discovery: {
|
|
44
60
|
id: "financial-statements",
|
|
45
61
|
aliases: ["financials", "financial statement", "income statement", "balance sheet", "cash flow statement", "financial ratios"],
|
|
46
|
-
//
|
|
47
|
-
|
|
62
|
+
// What a memo asks for by name: `catalog roic` and `catalog "operating margin"` find FA, and `fn ROIC V` opens
|
|
63
|
+
// the tab with it, as `fn runway VKTX` is the liquidity view, where cash + ST investments, burn and runway are.
|
|
64
|
+
intents: [
|
|
65
|
+
"ROIC (return on invested capital), ROE, ROA and gross, operating and net margins, with NOPAT and invested capital",
|
|
66
|
+
"Capex, capex as a share of revenue, free cash flow and reinvestment rate by fiscal year",
|
|
67
|
+
],
|
|
68
|
+
opens: [
|
|
69
|
+
{ words: ["runway", "cash runway", "burn", "cash burn", "months of cash"], argument: "", options: { statement: "liquidity" } },
|
|
70
|
+
{ words: ["roic", "return on invested capital", "nopat", "operating margin", "gross margin", "net margin", "margins"], argument: "",
|
|
71
|
+
options: { statement: "profitability" } },
|
|
72
|
+
{ words: ["capex", "capital expenditure", "capital expenditures", "reinvestment rate"], argument: "", options: { statement: "cashflow" } },
|
|
73
|
+
],
|
|
48
74
|
limitations: [
|
|
49
|
-
"
|
|
75
|
+
"Several companies come as one long table, a row per figure; GF charts one metric across companies over more years.",
|
|
50
76
|
"Excludes bank regulatory capital (CET1, risk-weighted assets) and REIT FFO/AFFO.",
|
|
51
77
|
],
|
|
52
78
|
screenshotReadiness: "ready",
|