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.
- package/package.json +2 -1
- package/patches/@opentui%2Fcore@0.3.2.patch +22 -4
- package/src/account/auth-dialog.tsx +22 -4
- package/src/account/auth-form.tsx +6 -1
- package/src/account/checkout-handoff.tsx +7 -14
- package/src/account/device-signin-dialog.tsx +35 -24
- package/src/api-client/crypto-markets.ts +10 -0
- package/src/api-client/errors.ts +3 -1
- package/src/api-client/index.ts +54 -0
- package/src/api-client/install-experiments.ts +8 -7
- package/src/api-client/money-markets.ts +7 -0
- package/src/api-client/paths.ts +2 -1
- package/src/api-client/product-waitlist.ts +63 -0
- package/src/api-client/request.ts +16 -4
- 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/architecture/floating-promise-allowlist.json +0 -1
- package/src/brokers/signed-in/sign-in-dialog.tsx +38 -38
- package/src/cli/commands/market.ts +103 -27
- package/src/cli/commands/overview.ts +18 -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/errors.ts +3 -1
- package/src/cli/freshness.ts +7 -2
- package/src/cli/glossary.ts +10 -5
- package/src/cli/help.ts +1 -0
- package/src/cli/helpers.ts +8 -16
- package/src/cli/history-export.ts +4 -0
- package/src/cli/history-rows.ts +24 -0
- package/src/cli/index.ts +4 -0
- package/src/cli/known-gaps.ts +2 -2
- package/src/cli/listing-arg.ts +79 -11
- package/src/cli/not-a-ticker.ts +4 -0
- package/src/cli/options.ts +29 -1
- package/src/cli/pane-functions/catalog.ts +70 -12
- package/src/cli/pane-functions/function-help.ts +1 -1
- package/src/cli/pane-functions/headless.ts +68 -3
- package/src/cli/pane-functions/index.ts +2 -2
- package/src/cli/pane-functions/options.ts +7 -0
- package/src/cli/pane-functions/resolver.ts +104 -15
- package/src/cli/pane-functions/screenshot-payload.ts +3 -0
- package/src/cli/report-tables.ts +20 -5
- package/src/cli/result.ts +22 -4
- package/src/cli/shot-temp-dir.ts +30 -0
- package/src/cli/suffixed-listing-rows.ts +11 -0
- package/src/cli/symbol-args.ts +5 -3
- package/src/cli/symbol-list.ts +23 -10
- package/src/cli/symbol-rows.ts +135 -3
- package/src/cli/treasury-yields.ts +15 -1
- package/src/components/chart/composite/composite-chart.tsx +3 -3
- package/src/components/chart/composite/format.ts +2 -1
- package/src/components/chart/composite/panel-surface/axis-markers.ts +133 -0
- package/src/components/chart/composite/panel-surface/level-labels.tsx +78 -0
- package/src/components/chart/composite/panel-surface/overlays.ts +108 -0
- package/src/components/chart/composite/panel-surface/pan-coast.ts +54 -0
- package/src/components/chart/composite/panel-surface/panel-cursor.tsx +138 -0
- package/src/components/chart/composite/panel-surface/panel-levels.ts +47 -0
- package/src/components/chart/composite/panel-surface/plot-gestures.ts +403 -0
- package/src/components/chart/composite/panel-surface/plot-pointer.ts +65 -0
- package/src/components/chart/composite/panel-surface/plot-wheel.ts +102 -0
- package/src/components/chart/composite/panel-surface/pointer.ts +12 -0
- package/src/components/chart/composite/panel-surface/props.ts +79 -0
- package/src/components/chart/composite/panel-surface/tool-readout.ts +151 -0
- package/src/components/chart/composite/panel-surface/value-axis-gestures.ts +152 -0
- package/src/components/chart/composite/panel-surface.tsx +81 -1177
- package/src/components/command-bar/commands/collection-list.ts +1 -0
- 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 +19 -2
- package/src/components/command-bar/routes/root/runtime.ts +3 -2
- package/src/components/command-bar/routes/root/selection.ts +3 -2
- package/src/components/command-bar/routes/root/shortcuts.ts +15 -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 +16 -6
- package/src/components/layout/shell/index.tsx +5 -1
- package/src/components/layout/shell/ticker-link-menu.ts +12 -9
- package/src/components/pane-settings-dialog/tui.tsx +6 -3
- package/src/components/pane-settings-dialog.tsx +2 -1
- package/src/components/pane-template-wizard.tsx +2 -0
- 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/choice-dialog.tsx +1 -1
- package/src/components/ui/confirm-dialog.tsx +3 -2
- 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/components/ui/frame.tsx +7 -3
- package/src/components/ui/icon.tsx +4 -2
- package/src/components/ui/list-view.tsx +8 -0
- package/src/components/ui/number-prompt-dialog.tsx +2 -1
- package/src/components/use-pane-notice-footer.tsx +3 -1
- 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/docs/snapshot.json +2 -2
- package/src/i18n/es.ts +39 -0
- package/src/i18n/ja.ts +39 -0
- package/src/i18n/ko.ts +39 -0
- package/src/i18n/zh-cn.ts +39 -0
- package/src/i18n/zh-tw.ts +39 -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/format.ts +35 -1
- package/src/market-data/market/index-level.ts +19 -0
- package/src/market-data/quotes/contributions.ts +13 -0
- package/src/market-data/quotes/export-identity.ts +36 -1
- package/src/market-data/quotes/resolution.ts +16 -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/password-dialog.tsx +2 -2
- 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/analytics/risk-client.ts +12 -2
- package/src/plugins/builtin/analytics/risk-headless.ts +66 -6
- package/src/plugins/builtin/analytics/risk-math.ts +23 -6
- package/src/plugins/builtin/analytics/risk-model.ts +20 -9
- package/src/plugins/builtin/analytics/risk-pane.tsx +2 -2
- 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/chart-composer/catalog-inventory.ts +5 -2
- package/src/plugins/builtin/chart-composer/editor.tsx +1 -0
- package/src/plugins/builtin/chart-composer/pane.tsx +1 -1
- package/src/plugins/builtin/chart-composer/quick-add.tsx +4 -1
- package/src/plugins/builtin/chart-composer/series-catalog.ts +17 -1
- package/src/plugins/builtin/cloud/askg/executor.ts +2 -1
- package/src/plugins/builtin/cloud/askg/sources.ts +2 -1
- package/src/plugins/builtin/cloud/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/thesis/module.tsx +2 -0
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +6 -2
- package/src/plugins/builtin/cpi/headless.ts +6 -1
- package/src/plugins/builtin/cpi/model.ts +17 -0
- package/src/plugins/builtin/cpi/pane.tsx +4 -2
- package/src/plugins/builtin/crypto-board/client.ts +6 -1
- package/src/plugins/builtin/crypto-board/headless.ts +10 -2
- package/src/plugins/builtin/crypto-board/model.ts +89 -11
- package/src/plugins/builtin/crypto-board/pane.tsx +20 -5
- package/src/plugins/builtin/debt-maturities/model.ts +1 -1
- package/src/plugins/builtin/dividend-yield/client.ts +24 -2
- package/src/plugins/builtin/dividend-yield/headless.ts +4 -2
- package/src/plugins/builtin/dividend-yield/ranking.ts +2 -1
- package/src/plugins/builtin/dividend-yield/view.ts +5 -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 +9 -1
- package/src/plugins/builtin/earnings/index.tsx +1 -1
- package/src/plugins/builtin/earnings-calls/pane.tsx +2 -2
- package/src/plugins/builtin/earnings-ripple/index.tsx +2 -0
- package/src/plugins/builtin/econ/calendar-model.ts +17 -1
- package/src/plugins/builtin/econ/fred-catalog.ts +33 -4
- package/src/plugins/builtin/econ-statistics/headless.ts +21 -0
- 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/headless.ts +21 -10
- package/src/plugins/builtin/macro-day/model.ts +42 -3
- package/src/plugins/builtin/macro-day/pane.tsx +26 -8
- package/src/plugins/builtin/macro-day/releases.ts +24 -1
- 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/money-markets/client.ts +4 -1
- package/src/plugins/builtin/money-markets/headless.ts +15 -4
- package/src/plugins/builtin/money-markets/index.tsx +1 -1
- package/src/plugins/builtin/money-markets/pane.tsx +7 -1
- 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/bulk-symbols.ts +4 -2
- package/src/plugins/builtin/portfolio-list/cli/period-report.ts +61 -11
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +11 -3
- package/src/plugins/builtin/portfolio-list/cli/render.ts +8 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +178 -17
- package/src/plugins/builtin/portfolio-list/headless.ts +33 -6
- package/src/plugins/builtin/portfolio-list/pane/groups.tsx +220 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +95 -18
- package/src/plugins/builtin/portfolio-list/pane/period-pnl.ts +24 -6
- package/src/plugins/builtin/portfolio-list/period-pnl.ts +16 -1
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +4 -1
- package/src/plugins/builtin/portfolio-list/summary/totals.ts +6 -4
- package/src/plugins/builtin/portfolio-list/table.tsx +38 -16
- 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/cloud-upgrade.ts +4 -2
- package/src/plugins/builtin/shared/cpi-year-gap.ts +67 -0
- 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/adr-pair/headless.ts +45 -2
- 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 +280 -35
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +4 -5
- package/src/plugins/builtin/ticker-detail/overview/model.ts +9 -2
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +10 -2
- 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/collection-name.ts +2 -1
- package/src/portfolio/column-values.ts +34 -12
- package/src/portfolio/listed-symbol.ts +4 -2
- package/src/portfolio/period-pnl.ts +51 -1
- 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/dialog-host.tsx +5 -5
- package/src/renderers/dom/styles.css +7 -0
- package/src/renderers/electrobun/view/remote/capability-invoker.ts +1 -1
- package/src/renderers/opentui/dialog-host.tsx +3 -4
- package/src/sources/gloomberb-cloud/normalizers.ts +5 -0
- package/src/sources/provider-router/history.ts +5 -2
- 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/test-support/plugin-persistence.ts +12 -0
- package/src/tickers/company-name-listing.ts +4 -3
- package/src/tickers/company-name.ts +19 -1
- package/src/tickers/instrument-coverage.ts +27 -0
- package/src/tickers/search/home-listing.ts +38 -1
- package/src/tickers/search/index.ts +3 -2
- package/src/tickers/search/ranking.ts +21 -2
- package/src/time-series/base-series.ts +4 -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/types.ts +5 -2
- package/src/time-series/use-chart-resolution.ts +6 -1
- package/src/types/config.ts +32 -0
- package/src/types/financials.ts +13 -0
- package/src/types/headless.ts +7 -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/ui/dialog-stack.ts +17 -0
- package/src/ui/dialog.tsx +6 -2
- package/src/utils/async-deadline.ts +2 -2
- package/src/utils/crypto-pair.ts +9 -0
- package/src/utils/csv.ts +44 -5
- package/src/utils/exchanges.ts +13 -0
- package/src/utils/financial-statements.ts +60 -3
- package/src/utils/futures-generic.ts +17 -0
- package/src/utils/trailing-dividend.ts +13 -3
|
@@ -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",
|
|
@@ -5,7 +5,9 @@ import {
|
|
|
5
5
|
import { canonicalExchange } from "../../../utils/exchanges";
|
|
6
6
|
import { hasValidQuoteObservationTime } from "../../../market-data/quotes/freshness";
|
|
7
7
|
import { quoteMonitorColumns, quoteMonitorRow, QUOTE_MONITOR_BASE_COLUMNS, QUOTE_MONITOR_ROW_KEYS } from "./quote-monitor/rows";
|
|
8
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
HeadlessPaneColumn, HeadlessPaneContext, HeadlessPaneDefinition, HeadlessPaneFreshness, HeadlessPaneOptionValues, HeadlessRowsResult,
|
|
10
|
+
} from "../../../types/headless";
|
|
9
11
|
import type { TimeRange } from "../../../time-series/range";
|
|
10
12
|
import { MISSING_VALUE, formatNumber } from "../../../utils/format";
|
|
11
13
|
import { formatPriceObservation, penceFigure, quoteFormatOptions } from "../../../market-data/market/format";
|
|
@@ -15,8 +17,8 @@ import {
|
|
|
15
17
|
} from "../../../utils/price-history-integrity";
|
|
16
18
|
import { indexBarVolume } from "../../../market-data/market/index-level";
|
|
17
19
|
import {
|
|
18
|
-
buildFinancialTableModel, financialStatementCurrency, financialStatementDateNotice, financialStatementLimitations,
|
|
19
|
-
financialReportHeader, financialStatementPeriods, financialSubTabFields, isPerShareFinancialRow, receiptShareCountLabel,
|
|
20
|
+
buildFinancialTableModel, financialColumnLabel, financialStatementCurrency, financialStatementDateNotice, financialStatementLimitations,
|
|
21
|
+
financialReportHeader, financialStatementPeriods, financialSubTabFields, formatFinancialAmount, isPerShareFinancialRow, receiptShareCountLabel,
|
|
20
22
|
} from "./financials/model";
|
|
21
23
|
import { fiscalYearEndMonth } from "../../../utils/fiscal-period";
|
|
22
24
|
import type { FinancialStatement } from "../../../types/financials";
|
|
@@ -25,7 +27,8 @@ import { paneSchemas } from "./headless-schema";
|
|
|
25
27
|
import { loadPeriodEndHistory } from "./financials/period-end-history";
|
|
26
28
|
import { loadExchangeResultsNotes } from "./financials/exchange-results";
|
|
27
29
|
import { latestBalanceSheetDate, loadOfferingNote } from "./financials/offerings";
|
|
28
|
-
import { reportsShortTermTotal, runwayMethod } from "../../../utils/cash-runway";
|
|
30
|
+
import { formatRunwayMonths, reportsShortTermTotal, runwayMethod } from "../../../utils/cash-runway";
|
|
31
|
+
import { formatPerShareNumber } from "../../../utils/reported-money";
|
|
29
32
|
import { logFailure } from "../../../utils/log-failure";
|
|
30
33
|
import {
|
|
31
34
|
RATIO_GAP_TEXT,
|
|
@@ -46,7 +49,7 @@ import {
|
|
|
46
49
|
import { barHistoryFreshness, REPORTED_DATA } from "../shared/report-freshness";
|
|
47
50
|
import {
|
|
48
51
|
BAR_INTERVAL_LABELS, barPriceDecimals, cleanBarPrice, cleanFloat32Price, formatBarPrice, historyAllStart, historyAllStartNote, historyBarFlags,
|
|
49
|
-
historyBarValues, historyMissingPeriodsNote, historyPriceDecimals, priceTableIntegrityNotice, quotedPriceDivisor,
|
|
52
|
+
historyBarValues, historyExportUnit, historyMissingPeriodsNote, historyPriceDecimals, historyUnit, priceTableIntegrityNotice, quotedPriceDivisor,
|
|
50
53
|
} from "../../../cli/history-rows";
|
|
51
54
|
import { formatUtcTime } from "../../../utils/utc-time";
|
|
52
55
|
import { closeMoves } from "../../../utils/max-drawdown";
|
|
@@ -84,6 +87,22 @@ function reportWindowText(options: HeadlessPaneOptionValues): string | null {
|
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
|
|
90
|
+
/**
|
|
91
|
+
* What a listing's bars are priced in, as `history` exports it in `currency_or_unit` (`GBP`, `JPY per USD`, `index
|
|
92
|
+
* points`): by its quote, else by the listing facts research reads, as `history` falls back to them. Null when neither says.
|
|
93
|
+
*/
|
|
94
|
+
async function barPriceUnit(
|
|
95
|
+
ctx: Pick<HeadlessContext, "marketData">,
|
|
96
|
+
key: string,
|
|
97
|
+
listing: string,
|
|
98
|
+
exchange: string | undefined,
|
|
99
|
+
quote: { currency?: string; instrumentType?: string } | null,
|
|
100
|
+
): Promise<string | null> {
|
|
101
|
+
const listed = quote?.currency ? quote
|
|
102
|
+
: await ctx.marketData.getQuoteMetadata?.(listing, exchange ?? "").catch(logFailure("ticker-detail.headless", "Read listing facts for a bar unit failed", null));
|
|
103
|
+
return historyExportUnit(historyUnit(key, listed ?? quote));
|
|
104
|
+
}
|
|
105
|
+
|
|
87
106
|
/** Bars of a window that closed before today: the history asked for, which no later bar makes stale. */
|
|
88
107
|
function pastWindowFreshness(window: PriceWindow, size: HistoryBarSize, observedKey: string): HeadlessPaneFreshness {
|
|
89
108
|
return { status: "not-a-feed", basis: `${historyBarSizeWord(size)} bars, ${priceWindowText(window)}`, observedKey, oldest: null };
|
|
@@ -92,12 +111,189 @@ function pastWindowFreshness(window: PriceWindow, size: HistoryBarSize, observed
|
|
|
92
111
|
export const financialStatementsHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
93
112
|
...paneSchemas["financial-analysis-pane"],
|
|
94
113
|
shape: "rows",
|
|
95
|
-
// Dated by the latest reported period; earlier periods are the statement's history.
|
|
96
|
-
freshness: { ...REPORTED_DATA, basis: "financial statements", observedKey: "
|
|
97
|
-
description: "Annual or quarterly financial statement rows for one ticker: the income statement, balance sheet, cash flow, or a ratio table.",
|
|
98
|
-
describe: ({ symbols, options }) => `Financial Statements | ${symbols
|
|
114
|
+
// Dated by the latest reported period (each row's `periodEnd`); earlier periods are the statement's history.
|
|
115
|
+
freshness: { ...REPORTED_DATA, basis: "financial statements", observedKey: "periodEnd", oldest: null, retrievedToo: true },
|
|
116
|
+
description: "Annual or quarterly financial statement rows for one ticker, or several in one long table: the income statement, balance sheet, cash flow, or a ratio table.",
|
|
117
|
+
describe: ({ symbols, options }) => `Financial Statements | ${symbols.join(", ")} | ${options.period} | ${options.statement}`,
|
|
99
118
|
async load({ symbols, options }, ctx) {
|
|
100
|
-
|
|
119
|
+
if (financialReportLayout(symbols, options) === "long") return loadLongFinancialReport(symbols, options, ctx);
|
|
120
|
+
return loadFinancialReport(symbols[0]!, options, ctx);
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Wide, one column per period, for one ticker; long, a row per ticker, period and metric, for several or when
|
|
126
|
+
* `--layout long` asks for it. Several tickers have no shared columns, so they are never laid out wide.
|
|
127
|
+
*/
|
|
128
|
+
function financialReportLayout(symbols: readonly string[], options: HeadlessPaneOptionValues): "wide" | "long" {
|
|
129
|
+
if (options.layout === "wide" && symbols.length > 1) {
|
|
130
|
+
throw new Error(`--layout wide is one ticker's periods as columns; ${symbols.length} tickers have no shared columns. Leave --layout out for one long table, or run FA once per ticker.`);
|
|
131
|
+
}
|
|
132
|
+
return options.layout === "long" || symbols.length > 1 ? "long" : "wide";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** How a figure of an FA row reads: the kind of number it is, which names its unit and draws it. */
|
|
136
|
+
type FigureFormat = "money" | "count" | "perShare" | "percent" | "multiple" | "days" | "months";
|
|
137
|
+
|
|
138
|
+
const DIVISOR_WORDS: Record<number, string> = { 1e3: "k", 1e6: "mn", 1e9: "bn", 1e12: "tn" };
|
|
139
|
+
|
|
140
|
+
/** The unit a figure of this kind is in, as exports name it in `currency_or_unit`: `USD bn`, `%`, `USD per share`, `bn shares`. */
|
|
141
|
+
function figureUnit(format: FigureFormat, currency: string | null, divisor: number, shares = "shares"): string {
|
|
142
|
+
const scale = DIVISOR_WORDS[divisor] ?? "";
|
|
143
|
+
switch (format) {
|
|
144
|
+
case "money": return [currency, scale].filter(Boolean).join(" ");
|
|
145
|
+
case "count": return [scale, shares].filter(Boolean).join(" ");
|
|
146
|
+
case "perShare": return currency ? `${currency} per ${shares === "shares" ? "share" : "ADR"}` : "per share";
|
|
147
|
+
case "percent": return "%";
|
|
148
|
+
case "multiple": return "x";
|
|
149
|
+
case "days": return "days";
|
|
150
|
+
case "months": return "months";
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** A figure as FA's table draws it, from the row's kind and unit: what the text prints and an export reads the scale of. */
|
|
155
|
+
function drawFigure(format: FigureFormat, value: number, divisor: number, ratio = false): string {
|
|
156
|
+
if (format === "percent") return ratio ? formatRatioValue("percent", value) : `${formatNumber(value * 100, 1)}%`;
|
|
157
|
+
if (format === "perShare") return formatPerShareNumber(value);
|
|
158
|
+
if (format === "money" || format === "count") return ratio ? formatRatioInput("money", value, divisor) : formatFinancialAmount(value, divisor);
|
|
159
|
+
return format === "days" && !ratio ? formatNumber(value, 1) : formatRatioValue(format, value);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** A statement row's kind of figure. */
|
|
163
|
+
function statementFigure(row: { format: "compact" | "eps" | "percent"; moneyUnit: string | null }): FigureFormat {
|
|
164
|
+
return row.format === "percent" ? "percent" : row.format === "eps" ? "perShare" : row.moneyUnit == null ? "count" : "money";
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* A period column of a wide FA table: the cell as the table drew it, its growth beside it in text. The figure is
|
|
169
|
+
* drawn from the value it is handed, so an export reads its scale, and a reason drawn in place of a missing one
|
|
170
|
+
* (`needs prior period`, `N/M`) goes to the `status` column rather than into a column of numbers.
|
|
171
|
+
*/
|
|
172
|
+
function financialPeriodColumn(date: string, header: string, index: number, withGrowth: boolean): HeadlessPaneColumn {
|
|
173
|
+
type Cell = { formatted: string; growthFormatted?: string };
|
|
174
|
+
const cellOf = (row: Record<string, unknown>) => (row.cells as Cell[] | undefined)?.[index];
|
|
175
|
+
const draw = (value: unknown, row: Record<string, unknown>) => {
|
|
176
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return cellOf(row)?.formatted ?? MISSING_VALUE;
|
|
177
|
+
const format = row.figure as FigureFormat | undefined;
|
|
178
|
+
return format ? drawFigure(format, value, Number(row.divisor) || 1, row.kind === "ratio" || row.kind === "input") : value.toFixed(2);
|
|
179
|
+
};
|
|
180
|
+
return {
|
|
181
|
+
key: date, header, align: "right",
|
|
182
|
+
// Exports write the amount alone, every digit; its growth (or N/M) is in the JSON and on the text table.
|
|
183
|
+
format: draw,
|
|
184
|
+
...withGrowth ? {
|
|
185
|
+
textFormat: (value: unknown, row: Record<string, unknown>) => [draw(value, row), cellOf(row)?.growthFormatted].filter(Boolean).join(" "),
|
|
186
|
+
} : {},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** The newest period end of a table's columns, which dates every row of it. */
|
|
191
|
+
function newestPeriodEnd(columns: ReadonlyArray<{ periodEnd: string }>): string | null {
|
|
192
|
+
return columns.map(({ periodEnd }) => periodEnd).filter(Boolean).sort().at(-1) ?? null;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** A figure of the long layout as the text prints it: the number in the row's unit, which the Unit column names. */
|
|
196
|
+
function drawLongFigure(format: FigureFormat, value: number, divisor: number): string {
|
|
197
|
+
switch (format) {
|
|
198
|
+
case "percent": return formatNumber(value * 100, 1);
|
|
199
|
+
case "money": case "count": return formatFinancialAmount(value, divisor);
|
|
200
|
+
case "perShare": return formatPerShareNumber(value);
|
|
201
|
+
case "multiple": return formatNumber(value, Math.abs(value) < 10 ? 2 : 1);
|
|
202
|
+
case "days": return formatNumber(value, 1);
|
|
203
|
+
case "months": return formatRunwayMonths(value, "");
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** The figure in its long-layout unit: a percent as percent, money and share counts in their unit, the rest as they are. */
|
|
208
|
+
function longFigureValue(format: FigureFormat, value: number, divisor: number): number {
|
|
209
|
+
return format === "percent" ? value * 100 : format === "money" || format === "count" ? value / divisor : value;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const mostCommon = (values: readonly number[]): number | undefined => {
|
|
213
|
+
const counts = new Map<number, number>();
|
|
214
|
+
for (const value of values) counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
215
|
+
return [...counts].sort((left, right) => right[1] - left[1] || right[0] - left[0])[0]?.[0];
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Text columns of the long layout. The export keeps Ticker to Value: each row's unit is its `currency_or_unit`,
|
|
220
|
+
* its period end its `as_of`, and a reason a figure is missing its `status`.
|
|
221
|
+
*/
|
|
222
|
+
const LONG_FINANCIAL_COLUMNS: HeadlessPaneColumn[] = [
|
|
223
|
+
{ key: "ticker", header: "Ticker" },
|
|
224
|
+
{ key: "period", header: "Period" },
|
|
225
|
+
{ key: "periodEnd", header: "Period End" },
|
|
226
|
+
{ key: "metric", header: "Metric" },
|
|
227
|
+
{ key: "value", header: "Value", align: "right", unitKey: "unit",
|
|
228
|
+
format: (value, row) => typeof value === "number" && Number.isFinite(value) ? String(row.formatted) : String(row.gap ?? MISSING_VALUE) },
|
|
229
|
+
];
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* FA for several tickers, or one with `--layout long`: a row per ticker, fiscal period and metric (Ticker, Period,
|
|
233
|
+
* Period End, Metric, Value, Unit), each ticker's table as `fn FA <ticker>` reads it. Money is in the one unit most
|
|
234
|
+
* of the tables' money rows take, so a figure pasted beside another ticker's needs no conversion; a ratio's input
|
|
235
|
+
* that several ratios share (Net Income under ROE, ROA and Net Margin) is one row.
|
|
236
|
+
*/
|
|
237
|
+
async function loadLongFinancialReport(symbols: string[], options: HeadlessPaneOptionValues, ctx: HeadlessPaneContext): Promise<HeadlessRowsResult> {
|
|
238
|
+
const loaded = await loadHeadlessSymbols(symbols, ctx, (symbol) => loadFinancialReport(symbol, options, ctx));
|
|
239
|
+
type WideRow = { kind: string; label: string; figure: FigureFormat; divisor: number;
|
|
240
|
+
cells: Array<{ value: number | null; formatted: string; gap?: string | null }> };
|
|
241
|
+
type WideColumn = { period: string; periodEnd: string; currency: string | null };
|
|
242
|
+
const tables = loaded.entries.map(({ symbol, data }) => ({
|
|
243
|
+
symbol, data, rows: data.rows as unknown as WideRow[], columns: (data.metadata?.columns ?? []) as WideColumn[],
|
|
244
|
+
}));
|
|
245
|
+
const divisor = mostCommon(tables.flatMap(({ rows }) => rows.filter((row) => row.figure === "money").map((row) => row.divisor))) ?? 1;
|
|
246
|
+
const rows = tables.flatMap(({ symbol, rows: wide, columns }) => {
|
|
247
|
+
const said = new Set<string>();
|
|
248
|
+
return wide.flatMap((row) => {
|
|
249
|
+
// An input is named without the operator that joins it to its ratio, and once.
|
|
250
|
+
const metric = row.kind === "input" ? row.label.replace(/^[÷+−-]\s*/, "") : row.label;
|
|
251
|
+
if (said.has(metric)) return [];
|
|
252
|
+
said.add(metric);
|
|
253
|
+
const rowDivisor = row.figure === "money" ? divisor : row.divisor;
|
|
254
|
+
return columns.map((column, index) => {
|
|
255
|
+
const cell = row.cells[index];
|
|
256
|
+
const value = typeof cell?.value === "number" && Number.isFinite(cell.value) ? cell.value : null;
|
|
257
|
+
return {
|
|
258
|
+
ticker: symbol, period: column.period, periodEnd: column.periodEnd, metric,
|
|
259
|
+
value: value == null ? null : longFigureValue(row.figure, value, rowDivisor),
|
|
260
|
+
unit: figureUnit(row.figure, column.currency, rowDivisor),
|
|
261
|
+
formatted: value == null ? null : drawLongFigure(row.figure, value, rowDivisor),
|
|
262
|
+
gap: value == null ? cell?.gap ?? (cell?.formatted && cell.formatted !== MISSING_VALUE ? cell.formatted : null) : null,
|
|
263
|
+
};
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
// A note every table makes is said once; one only some make names the ticker. The headers' date sources are
|
|
268
|
+
// not in this layout's columns, so neither is what they mean.
|
|
269
|
+
const kept = (note: string) => note !== SEC_DATE_NOTE && note !== PROVIDER_DATE_NOTE;
|
|
270
|
+
for (const table of tables) table.data = { ...table.data, notes: (table.data.notes ?? []).filter(kept) };
|
|
271
|
+
const notes = tables.flatMap(({ data }) => data.notes ?? []);
|
|
272
|
+
const shared = (note: string) => tables.every(({ data }) => (data.notes ?? []).includes(note));
|
|
273
|
+
const ownNotes = tables.flatMap(({ symbol, data }) => (data.notes ?? []).filter((note) => !shared(note)).map((note) => `${symbol}: ${note}`));
|
|
274
|
+
const empty = tables.filter(({ rows: wide }) => wide.length === 0);
|
|
275
|
+
const first = tables[0]?.data.metadata ?? {};
|
|
276
|
+
return {
|
|
277
|
+
rows,
|
|
278
|
+
columns: LONG_FINANCIAL_COLUMNS,
|
|
279
|
+
textColumns: [...LONG_FINANCIAL_COLUMNS, { key: "unit", header: "Unit" }],
|
|
280
|
+
rowUnitKey: "unit", rowSymbolKey: "ticker", rowAsOfKey: "periodEnd",
|
|
281
|
+
interval: options.period === "quarterly" ? "quarterly" : "annual",
|
|
282
|
+
unavailableSymbols: [...loaded.unavailableSymbols, ...empty.flatMap(({ data }) => data.unavailableSymbols ?? [])],
|
|
283
|
+
errors: [...loaded.errors, ...tables.flatMap(({ symbol, data }) => (data.errors ?? []).map((error) => error.startsWith(symbol) ? error : `${symbol}: ${error}`))],
|
|
284
|
+
notes: [...new Set([...notes.filter(shared), ...ownNotes])],
|
|
285
|
+
metadata: {
|
|
286
|
+
symbols, layout: "long", statement: first.statement ?? options.statement, statementLabel: first.statementLabel ?? null,
|
|
287
|
+
period: options.period === "quarterly" ? "quarterly" : "annual",
|
|
288
|
+
notices: [...new Set(tables.flatMap(({ data }) => (data.metadata?.notices ?? []) as string[]))],
|
|
289
|
+
limitations: [...new Set(tables.flatMap(({ data }) => (data.metadata?.limitations ?? []) as string[]))],
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** One ticker's statement or ratio table, its periods as columns. */
|
|
295
|
+
async function loadFinancialReport(symbol: string, options: HeadlessPaneOptionValues, ctx: HeadlessPaneContext): Promise<HeadlessRowsResult> {
|
|
296
|
+
{
|
|
101
297
|
const financials = await loadHeadlessFinancials(ctx, symbol);
|
|
102
298
|
const requestedPeriod = options.period === "quarterly" ? "quarterly" : "annual";
|
|
103
299
|
const hasRequestedStatements = (requestedPeriod === "quarterly"
|
|
@@ -148,29 +344,30 @@ export const financialStatementsHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
148
344
|
dateSource: date === "TTM" ? "derived" : dateSource ?? "provider",
|
|
149
345
|
providerDate: date === "TTM" ? null : providerDate ?? null,
|
|
150
346
|
dateEvidence: date === "TTM" || dateSource !== "sec" ? null : dateEvidence ?? null,
|
|
151
|
-
//
|
|
347
|
+
// The fiscal period as the pane names it, and the day it ends, which the long layout and exports date it by.
|
|
348
|
+
period: financialColumnLabel(statement, requestedPeriod, yearEndMonth),
|
|
349
|
+
periodEnd: ratioPeriodEnd(statement),
|
|
350
|
+
// Rows in the table's one money unit do not name it, so the header does.
|
|
152
351
|
label: financialReportHeader(statement, [currency ?? statementCurrency, table.unit].filter(Boolean).join(" ") || undefined, requestedPeriod, yearEndMonth, listRows),
|
|
153
352
|
};
|
|
154
353
|
}) ?? [];
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
354
|
+
const asOf = newestPeriodEnd(dates);
|
|
355
|
+
const rows = table?.rows.map((row) => {
|
|
356
|
+
const figure = statementFigure(row);
|
|
357
|
+
return {
|
|
358
|
+
id: row.id, kind: row.kind, metric: allReceipts ? receiptShareCountLabel(row) : row.unitLabel, label: row.label,
|
|
359
|
+
// What the figures are in, which exports name in `currency_or_unit`, and the newest period they run to.
|
|
360
|
+
figure, divisor: row.divisor, unit: figureUnit(figure, statementCurrency ?? null, row.divisor, allReceipts ? "ADRs" : "shares"), periodEnd: asOf,
|
|
361
|
+
cells: row.cells.map((cell, index) => ({
|
|
362
|
+
date: dates[index]?.date ?? "", value: cell.value ?? null,
|
|
363
|
+
growth: cell.growth ?? null, formatted: cell.valueText.trim(), growthFormatted: cell.growthText.trim(),
|
|
364
|
+
})),
|
|
365
|
+
...Object.fromEntries(row.cells.map((cell, index) => [dates[index]!.date, cell.value ?? null])),
|
|
366
|
+
};
|
|
367
|
+
}) ?? [];
|
|
163
368
|
const columns: HeadlessPaneColumn[] = [
|
|
164
369
|
{ key: "metric", header: "Metric" },
|
|
165
|
-
...dates.map(({ date, label }, index) => (
|
|
166
|
-
key: date, header: label, align: "right" as const,
|
|
167
|
-
// Exports write the amount alone, every digit; its growth (or N/M) is in the JSON and on the text table.
|
|
168
|
-
format: (_value: unknown, row: Record<string, unknown>) => (row.cells as Array<{ formatted: string }>)[index]!.formatted,
|
|
169
|
-
textFormat: (_value: unknown, row: Record<string, unknown>) => {
|
|
170
|
-
const cell = (row.cells as Array<{ formatted: string; growthFormatted: string }>)[index]!;
|
|
171
|
-
return [cell.formatted, cell.growthFormatted].filter(Boolean).join(" ");
|
|
172
|
-
},
|
|
173
|
-
})),
|
|
370
|
+
...dates.map(({ date, label }, index) => financialPeriodColumn(date, label, index, true)),
|
|
174
371
|
];
|
|
175
372
|
// The balance sheet's cash, when an offering since is not in it yet.
|
|
176
373
|
const offering = table?.subTab.key === "balance" ? await reportOfferingNote(ctx, symbol, financials) : null;
|
|
@@ -186,9 +383,12 @@ export const financialStatementsHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
186
383
|
return {
|
|
187
384
|
rows, columns, unavailableSymbols: rows.length ? [] : [symbol],
|
|
188
385
|
...(missing ? { errors: [missing] } : {}),
|
|
386
|
+
// Each exported row names its unit, the statements' period and the newest period end it runs to.
|
|
387
|
+
rowUnitKey: "unit", rowAsOfKey: "periodEnd", interval: requestedPeriod,
|
|
189
388
|
// The report closes with how old its latest period is, how far back its periods go, and how to read further.
|
|
190
389
|
notes: [...announced, ...stale ? [stale] : [], ...filled ? [filled] : [], ...offering ? [offering] : [],
|
|
191
|
-
...statementHistoryNotes(requestedPeriod, periodDates, symbol, await reportOlderStatements(ctx, symbol, requestedPeriod, periodDates))
|
|
390
|
+
...statementHistoryNotes(requestedPeriod, periodDates, symbol, await reportOlderStatements(ctx, symbol, requestedPeriod, periodDates)),
|
|
391
|
+
...table?.subTab.key === "cashflow" ? [CASH_FLOW_NOTE] : [], ...dateSourceNotes(dates)],
|
|
192
392
|
metadata: {
|
|
193
393
|
symbol, name: financials.quote?.name ?? symbol, currency: statementCurrency ?? null, unit: table?.unit ?? null, quoteCurrency: financials.quote?.currency ?? null,
|
|
194
394
|
statement: table?.subTab.key ?? options.statement, statementLabel: table?.subTab.name ?? null,
|
|
@@ -202,11 +402,34 @@ export const financialStatementsHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
202
402
|
dateProvenance: financialStatementDateNotice(table?.statements ?? []),
|
|
203
403
|
},
|
|
204
404
|
};
|
|
205
|
-
}
|
|
206
|
-
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
207
407
|
|
|
208
408
|
const reportAmount = (amount: RatioAmount) => (typeof amount === "number" ? amount : null);
|
|
209
409
|
|
|
410
|
+
/** What the profitability tab's figures are, said under it, as docs/financial-ratios.md defines them. */
|
|
411
|
+
const PROFITABILITY_NOTES = [
|
|
412
|
+
"ROIC is NOPAT / average (equity + total debt), cash not netted; ROIC ex Cash takes cash and short-term investments out of that capital.",
|
|
413
|
+
"NOPAT is operating income x (1 - tax provision / pretax income), the rate held between 0% and 100%; a pretax loss pays no tax.",
|
|
414
|
+
"Margins and NOPAT are GAAP, as the income statement reports them, not the company's adjusted (non-GAAP) figures.",
|
|
415
|
+
];
|
|
416
|
+
|
|
417
|
+
const NEEDS_OPENING_NOTE = "needs prior period: an average of the opening and closing balance has no opening balance sheet on file, the period before the column's (the prior year end for a year, the prior quarter end for a quarter, the quarter a year earlier for TTM), as for the oldest column or a year whose prior year is missing.";
|
|
418
|
+
|
|
419
|
+
/** What the cash flow table works out of its own lines. */
|
|
420
|
+
const CASH_FLOW_NOTE = "CapEx / Revenue is capex over revenue; Reinvestment Rate is capex plus acquisitions less D&A, over NOPAT.";
|
|
421
|
+
|
|
422
|
+
const SEC_DATE_NOTE = "SEC date: the period end the company's 10-K or 10-Q states.";
|
|
423
|
+
const PROVIDER_DATE_NOTE = "provider date: the period end as the statements source dates it, which can be a few days off the company's own.";
|
|
424
|
+
|
|
425
|
+
/** What a column header's `(SEC date)` and `(provider date)` mean, for the ones the table has. */
|
|
426
|
+
function dateSourceNotes(columns: ReadonlyArray<{ dateSource: string }>): string[] {
|
|
427
|
+
return [
|
|
428
|
+
...columns.some(({ dateSource }) => dateSource === "sec") ? [SEC_DATE_NOTE] : [],
|
|
429
|
+
...columns.some(({ dateSource }) => dateSource === "provider") ? [PROVIDER_DATE_NOTE] : [],
|
|
430
|
+
];
|
|
431
|
+
}
|
|
432
|
+
|
|
210
433
|
/**
|
|
211
434
|
* What a table of quarters says its growth is measured against; a half filled
|
|
212
435
|
* from a results announcement is measured against the same half a year earlier.
|
|
@@ -299,11 +522,15 @@ async function loadRatioReport(
|
|
|
299
522
|
const yearEndMonth = fiscalYearEndMonth(financials.annualStatements);
|
|
300
523
|
const dates = table?.periods.map(({ statement }) => ({
|
|
301
524
|
date: statement.date,
|
|
525
|
+
// The fiscal period as the pane names it, and the day it ends.
|
|
526
|
+
period: financialColumnLabel(statement, period, yearEndMonth),
|
|
302
527
|
periodEnd: ratioPeriodEnd(statement),
|
|
303
528
|
currency: statement.currency ?? statementCurrency ?? null,
|
|
529
|
+
dateSource: statement.date === "TTM" ? "derived" : statement.dateSource ?? "provider",
|
|
304
530
|
label: financialReportHeader(statement, statement.currency ?? statementCurrency, period, yearEndMonth,
|
|
305
531
|
period === "quarterly" ? financials.quarterlyStatements : financials.annualStatements),
|
|
306
532
|
})) ?? [];
|
|
533
|
+
const asOf = newestPeriodEnd(dates);
|
|
307
534
|
const rows = table?.rows.map((row) => {
|
|
308
535
|
const cells = table.cells.get(row.def.id)!.map((cell, index) => {
|
|
309
536
|
const amount = row.kind === "ratio" ? cell.value : cell.inputs[row.index]!;
|
|
@@ -316,19 +543,23 @@ async function loadRatioReport(
|
|
|
316
543
|
: formatRatioInput(row.def.inputs[row.index]!.format, amount, row.divisor),
|
|
317
544
|
};
|
|
318
545
|
});
|
|
546
|
+
const figure: FigureFormat = row.kind === "ratio" ? row.def.format : row.def.inputs[row.index]!.format;
|
|
547
|
+
const divisor = row.kind === "ratio" ? 1 : row.divisor;
|
|
319
548
|
return {
|
|
320
549
|
id: row.id, kind: row.kind, metric: row.kind === "ratio" ? row.label : row.unitLabel,
|
|
550
|
+
label: row.kind === "ratio" ? row.label : row.unitLabel.replace(/ \([a-z]+\)$/, ""),
|
|
551
|
+
// What the figures are in, which exports name in `currency_or_unit`, and the newest period they run to.
|
|
552
|
+
figure, divisor, unit: figureUnit(figure, statementCurrency ?? null, divisor), periodEnd: asOf,
|
|
321
553
|
cells,
|
|
322
554
|
...Object.fromEntries(cells.map((cell) => [cell.date, cell.value])),
|
|
323
555
|
};
|
|
324
556
|
}) ?? [];
|
|
325
557
|
const columns: HeadlessPaneColumn[] = [
|
|
326
558
|
{ key: "metric", header: "Ratio" },
|
|
327
|
-
...dates.map(({ date, label }, index) => (
|
|
328
|
-
key: date, header: label, align: "right" as const,
|
|
329
|
-
format: (_value: unknown, row: Record<string, unknown>) => (row.cells as Array<{ formatted: string }>)[index]!.formatted,
|
|
330
|
-
})),
|
|
559
|
+
...dates.map(({ date, label }, index) => financialPeriodColumn(date, label, index, false)),
|
|
331
560
|
];
|
|
561
|
+
// An average with no opening balance sheet on file (the oldest column, a year after a missing one, TTM) says what it needs.
|
|
562
|
+
const needsOpening = rows.some((row) => row.cells.some((cell) => cell.gap === RATIO_GAP_TEXT["no-opening"]));
|
|
332
563
|
// Liquidity's runway says how it counts months, and that the cash predates an offering since.
|
|
333
564
|
const liquidity = tab.key === "liquidity" && table;
|
|
334
565
|
const runwayShown = liquidity && table.ratios.some((def) => def.format === "months"
|
|
@@ -340,12 +571,17 @@ async function loadRatioReport(
|
|
|
340
571
|
rows, columns, unavailableSymbols: rows.length ? [] : [symbol],
|
|
341
572
|
...(missing ? { errors: [missing] } : {}),
|
|
342
573
|
...(tab.key === "valuation" && hasRequestedStatements && !history?.length ? { complete: false } : {}),
|
|
574
|
+
// Each exported row names its unit, the statements' period and the newest period end it runs to.
|
|
575
|
+
rowUnitKey: "unit", rowAsOfKey: "periodEnd", interval: period,
|
|
343
576
|
notes: [
|
|
344
577
|
...[stalePeriodNote(dates.map(({ periodEnd }) => ({ date: periodEnd, lead: true })))].filter((note): note is string => !!note),
|
|
345
578
|
...[filledPeriodsNote(table?.periods.map(({ statement }) => statement) ?? [])].filter((note): note is string => !!note),
|
|
346
579
|
...offering ? [offering] : [],
|
|
347
580
|
...runwayShown ? [runwayMethod(reportsShortTermTotal([...financials.quarterlyStatements, ...financials.annualStatements]))] : [],
|
|
348
581
|
...statementHistoryNotes(period, periodDates, symbol, await reportOlderStatements(ctx, symbol, period, periodDates)),
|
|
582
|
+
...tab.key === "profitability" && rows.length ? PROFITABILITY_NOTES : [],
|
|
583
|
+
...needsOpening ? [NEEDS_OPENING_NOTE] : [],
|
|
584
|
+
...dateSourceNotes(dates),
|
|
349
585
|
],
|
|
350
586
|
metadata: {
|
|
351
587
|
symbol, name: financials.quote?.name ?? symbol, currency: statementCurrency ?? null,
|
|
@@ -528,8 +764,13 @@ export const historicalPricesHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
528
764
|
const openNotice = priceHistoryOpenNotice(points.filter(pricePointOpenWithheld).length);
|
|
529
765
|
const reportNotices = [...moveLines, notice, openNotice, wickNotice, priceHistoryRescaleNotice(points)].filter((line): line is string => line != null);
|
|
530
766
|
const flagged = rows.some((row) => row.flag);
|
|
767
|
+
// Every exported bar names what it is priced in and its size, as `history --csv` does.
|
|
768
|
+
const unit = await barPriceUnit(ctx, symbol, listing, exchange, quote);
|
|
769
|
+
const barInterval = size === "intraday" ? isIntradayResolution(requested) ? requested : null : size;
|
|
531
770
|
return {
|
|
532
771
|
rows: shown,
|
|
772
|
+
...(unit ? { unit } : {}),
|
|
773
|
+
...(barInterval ? { interval: barInterval } : {}),
|
|
533
774
|
columns: historyColumns(size, marked, false, false, decimals, undefined, flagged),
|
|
534
775
|
textColumns: historyColumns(size, marked, true, volumeMissing > 0, decimals,
|
|
535
776
|
(close) => penceFigure(Number(close.toFixed(Math.min(20, decimals))), quote, decimals), flagged),
|
|
@@ -627,6 +868,8 @@ export const returnsHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
627
868
|
const textFigures = figures.map((column) => column.key === "intervalChange" ? { ...column, optional: true, dropPriority: 2 }
|
|
628
869
|
: column.key === "totalChange" ? { ...column, optional: true, dropPriority: 1 } : column);
|
|
629
870
|
const textColumns: HeadlessPaneColumn[] = [timeColumn(true), ...textFigures];
|
|
871
|
+
// Every exported row names what its prices are in and the bars' size, as `history --csv` does.
|
|
872
|
+
const unit = rows.length ? await barPriceUnit(ctx, key, symbol, exchange, null) : null;
|
|
630
873
|
// An interval the range is too long for is served in the nearest longer bar; say so rather than switch silently.
|
|
631
874
|
const notices = [
|
|
632
875
|
...moveLines,
|
|
@@ -641,6 +884,8 @@ export const returnsHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
641
884
|
rows,
|
|
642
885
|
columns,
|
|
643
886
|
textColumns,
|
|
887
|
+
...(unit ? { unit } : {}),
|
|
888
|
+
interval: series.resolution,
|
|
644
889
|
unavailableSymbols: rows.length ? [] : [key],
|
|
645
890
|
...(rows.length ? {} : { errors: [`${key}: No bars in this window.`] }),
|
|
646
891
|
freshness: pastWindow ? pastWindowFreshness(window, series.resolution, "time") : {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import { ActionRow, ColumnGrid, ColumnGridPair, RangeTrack, usePaneLinkMenuEntry, type ColumnGridCell, type ColumnGridColumn } from "../../../../components";
|
|
3
3
|
import { t, tf } from "../../../../i18n";
|
|
4
|
-
import { formatMarketPrice, formatMarketPriceWithCurrency, liveQuoteFormatOptions, type MarketFormatOptions } from "../../../../market-data/market/format";
|
|
4
|
+
import { formatMarketPrice, formatMarketPriceRange, formatMarketPriceWithCurrency, liveQuoteFormatOptions, type MarketFormatOptions } from "../../../../market-data/market/format";
|
|
5
5
|
import { colors, hoverBg, priceColor } from "../../../../theme/colors";
|
|
6
6
|
import type { Quote } from "../../../../types/financials";
|
|
7
7
|
import { Box, Text, useUiCapabilities } from "../../../../ui";
|
|
@@ -60,7 +60,7 @@ function compactRangeOptions(low: number, high: number, priceOptions: MarketForm
|
|
|
60
60
|
return priceOptions;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
/** A range's two ends, in `style
|
|
63
|
+
/** A range's two ends, in `style`, both to one number of decimals. */
|
|
64
64
|
function formatRangeEndpoints(
|
|
65
65
|
low: number,
|
|
66
66
|
high: number,
|
|
@@ -68,9 +68,8 @@ function formatRangeEndpoints(
|
|
|
68
68
|
priceOptions: MarketFormatOptions,
|
|
69
69
|
style: RangeEndpointStyle = "price",
|
|
70
70
|
): [string, string] {
|
|
71
|
-
if (style === "price") return
|
|
72
|
-
|
|
73
|
-
return [formatMarketPrice(low, options), formatMarketPrice(high, options)];
|
|
71
|
+
if (style === "price") return formatMarketPriceRange(low, high, priceOptions, currency);
|
|
72
|
+
return formatMarketPriceRange(low, high, compactRangeOptions(low, high, priceOptions));
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
/** The longest endpoint among ranges drawn together, so stacked tracks start and end in one column. */
|
|
@@ -27,7 +27,8 @@ import {
|
|
|
27
27
|
formatMarketQuantity,
|
|
28
28
|
withCurrencyMinorDigits,
|
|
29
29
|
} from "../../../../market-data/market/format";
|
|
30
|
-
import { reportedQuoteVolume } from "../../../../market-data/market/index-level";
|
|
30
|
+
import { quoteVolumeCurrency, reportedQuoteVolume } from "../../../../market-data/market/index-level";
|
|
31
|
+
import { formatChartLegendValue } from "../../../../components/chart/composite/format";
|
|
31
32
|
import type { OverviewFunctionLink, PositionTableRow, StatField } from "./types";
|
|
32
33
|
import type { OverviewDividendState } from "./dividend";
|
|
33
34
|
import { lapseValue } from "../../../../utils/forward-dividend";
|
|
@@ -40,6 +41,7 @@ import { formatShortDate } from "../../../../utils/datetime-format";
|
|
|
40
41
|
import { safeExternalUrl } from "../../../../utils/external-url";
|
|
41
42
|
import type { FundBondFacts } from "../../../../api-client/fund-facts";
|
|
42
43
|
import { bondFigures } from "../../../../market-data/bond-funds";
|
|
44
|
+
import { quoteStatsBasisText } from "../../../../market-data/quotes/export-identity";
|
|
43
45
|
import { formatRunwayMonths, type CashRunway, type RunwayEstimate } from "../../../../utils/cash-runway";
|
|
44
46
|
|
|
45
47
|
type CurrencyConverter = (value: number, fromCurrency: string) => number;
|
|
@@ -210,7 +212,12 @@ export function buildOverviewStats({
|
|
|
210
212
|
const volume = reportedQuoteVolume(quote);
|
|
211
213
|
if (volume != null) {
|
|
212
214
|
// Live figures keep their decimals (12.30M, not 12.3M) so the digits hold still.
|
|
213
|
-
|
|
215
|
+
// A coin's volume is the value it traded in its quote currency, written as the chart's volume reads ($47.94B),
|
|
216
|
+
// and the composite's or one exchange's own day, said beside it as its range's is.
|
|
217
|
+
const basis = quoteStatsBasisText(quote, false);
|
|
218
|
+
const currency = quoteVolumeCurrency(quote);
|
|
219
|
+
const value = currency ? formatChartLegendValue(volume, currency, "volume") : formatCompact(volume, { fixedDecimals: true });
|
|
220
|
+
stats.push({ label: "Volume", value, ...(basis ? { detail: basis } : {}) });
|
|
214
221
|
}
|
|
215
222
|
// Price-derived statistics follow the quote; see live-valuation for when a stored figure is kept.
|
|
216
223
|
// Market cap and EV read in the currency they are reported in, as the revenue and income beside them do, with
|
|
@@ -76,6 +76,7 @@ import { taxEquivalentFields, useOverviewTaxEquivalent } from "./overview/tax-eq
|
|
|
76
76
|
import { distributionBasis, type TaxRates } from "../../../market-data/tax-equivalent";
|
|
77
77
|
import { currentListingName } from "../../../tickers/listing-name";
|
|
78
78
|
import { isYieldIndexSymbol } from "../../../tickers/index-roots";
|
|
79
|
+
import { coinPriceVenueText, quoteStatsBasisText } from "../../../market-data/quotes/export-identity";
|
|
79
80
|
import { hiddenOnLogScale, logScaleHiddenWarning } from "../../../time-series/log-scale";
|
|
80
81
|
import {
|
|
81
82
|
autoOverviewChartScale, resolveOverviewChartScale, toggledOverviewChartScale, type OverviewChartScaleChoice,
|
|
@@ -328,12 +329,17 @@ function ResolvedOverviewTab({
|
|
|
328
329
|
// The pane title already names the ticker, so the line leads with the company and drops a name that only repeats it.
|
|
329
330
|
// The listing's own quote names it first: BA on LSE is BAE Systems, whatever name a search gave the row it was saved from.
|
|
330
331
|
const companyName = currentListingName(ticker, quote) ?? "";
|
|
331
|
-
|
|
332
|
+
// A coin's price says where it is from and when, where a listing names its venue: the crypto venue's own code
|
|
333
|
+
// would tell a reader nothing about whose price it is.
|
|
334
|
+
const coinVenue = instrumentKind === "crypto" ? coinPriceVenueText(quote) : "";
|
|
335
|
+
const shownVenue = coinVenue || listingVenue;
|
|
336
|
+
const venueText = shownVenue ? (companyName ? ` (${shownVenue})` : shownVenue) : "";
|
|
332
337
|
const sessionLabel = quoteSessionLabel(quote);
|
|
333
338
|
const marketStateText = sessionLabel ? t(sessionLabel) : "";
|
|
334
339
|
// Signed out or free, the headline price is the delayed one. The status bar says so for the
|
|
335
340
|
// app; where it is hidden, or in a capture of the pane alone, the mark says so after the session.
|
|
336
|
-
|
|
341
|
+
// A coin's venue already says when its price is held back.
|
|
342
|
+
const delayMinutes = sessionQuote && !coinVenue ? quoteDelayMinutes : null;
|
|
337
343
|
const delayCells = delayMinutes != null ? delayedMarkWidth(delayMinutes, nativePaneChrome === true) + 1 : 0;
|
|
338
344
|
const hasIdentityLine = Boolean(companyName || venueText || marketStateText || delayMinutes != null);
|
|
339
345
|
// The desktop logo is a square from the top of the company name's capitals down to the
|
|
@@ -596,6 +602,8 @@ function ResolvedOverviewTab({
|
|
|
596
602
|
low={quote.low!}
|
|
597
603
|
high={quote.high!}
|
|
598
604
|
label={dayRangeLabel}
|
|
605
|
+
// A coin's range is the composite's or one exchange's own day: said, so a switch between them shows.
|
|
606
|
+
note={quoteStatsBasisText(quote) || undefined}
|
|
599
607
|
shortLabel={delisted ? t("Last") : t("Day")}
|
|
600
608
|
labelWidth={rangeLabelWidth}
|
|
601
609
|
endpointWidth={rangeEndpointCells}
|