gloomberb 0.20.4 → 0.20.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/README.zh-CN.md +1 -1
- package/bin/gloom +9 -0
- package/bin/without-bun.cjs +98 -0
- package/package.json +4 -1
- package/src/api-client/data.ts +148 -37
- package/src/api-client/hk-tenders.ts +59 -0
- package/src/api-client/index.ts +1 -0
- package/src/api-client/types/econ.ts +30 -0
- package/src/api-client/yield-curves.ts +1 -1
- package/src/app/global-shortcuts.ts +4 -1
- package/src/app/keybindings/actions.ts +6 -0
- package/src/app/keybindings/config.ts +2 -1
- package/src/app/keybindings/index.ts +1 -0
- package/src/app/keybindings/labels.ts +6 -1
- package/src/app/keybindings/resolve.ts +23 -4
- package/src/app/keybindings/terminal-keys.ts +35 -0
- package/src/app/pane-runtime/index.tsx +2 -2
- package/src/app/pane-runtime/ticker-open-runtime.ts +68 -40
- package/src/app.tsx +18 -13
- package/src/architecture/floating-promise-allowlist.json +313 -0
- package/src/architecture/ui-literals-allowlist.json +1 -1
- package/src/capabilities/chart-series.ts +27 -1
- package/src/cli/commands/keybindings.ts +5 -5
- package/src/cli/commands/market.ts +238 -57
- package/src/cli/commands/news-search.ts +81 -14
- package/src/cli/commands/overview.ts +27 -6
- package/src/cli/commands/remote.ts +16 -17
- package/src/cli/commands/system.ts +1 -1
- package/src/cli/commands/ticker.ts +3 -1
- package/src/cli/early-command.ts +2 -0
- package/src/cli/errors.ts +10 -1
- package/src/cli/fx-forward.ts +89 -7
- package/src/cli/fx-pair.ts +1 -1
- package/src/cli/fx-quote-rate.ts +23 -0
- package/src/cli/glossary.ts +19 -5
- package/src/cli/help.ts +1 -0
- package/src/cli/history-rows.ts +5 -3
- package/src/cli/index-roots.ts +5 -4
- package/src/cli/index.ts +40 -3
- package/src/cli/known-gaps.ts +38 -9
- package/src/cli/listing-arg.ts +17 -5
- package/src/cli/name-entries.ts +5 -1
- package/src/cli/not-a-ticker.ts +4 -0
- package/src/cli/options.ts +52 -3
- package/src/cli/output-file.ts +5 -3
- package/src/cli/pane-functions/catalog.ts +15 -0
- package/src/cli/pane-functions/function-help.ts +4 -4
- package/src/cli/pane-functions/headless.ts +9 -4
- package/src/cli/pane-functions/index.ts +6 -4
- package/src/cli/pane-functions/resolver.ts +2 -2
- package/src/cli/result.ts +21 -2
- package/src/cli/spreadsheet-hint.ts +7 -3
- package/src/cli/treasury-yields.ts +5 -3
- package/src/components/chart/composite/legend.tsx +40 -2
- package/src/components/command-bar/pane-settings.ts +2 -2
- package/src/components/command-bar/routes/root/results.ts +6 -2
- package/src/components/command-bar/workflow/tickers.ts +2 -2
- package/src/components/data-table/view.tsx +9 -2
- package/src/components/input-search-bar.tsx +9 -2
- package/src/components/layout/pane/header.tsx +2 -0
- package/src/components/layout/shell/pane/capture.ts +4 -1
- package/src/components/layout/status-bar.tsx +6 -1
- package/src/components/onboarding/first-run-workspace.ts +44 -2
- package/src/components/onboarding/onboarding-frame.tsx +11 -2
- package/src/components/onboarding/onboarding-keyboard.ts +16 -0
- package/src/components/onboarding/onboarding-wizard.tsx +8 -8
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +62 -1
- package/src/components/onboarding/use-onboarding-progress.ts +12 -4
- package/src/components/pane-settings-dialog/desktop.tsx +2 -2
- package/src/components/pane-settings-dialog/tui.tsx +2 -2
- package/src/components/pane-settings-dialog/value.ts +6 -0
- package/src/components/pane-settings-dialog.tsx +3 -3
- package/src/components/reader/detail-reader.tsx +4 -0
- package/src/components/ui/data-table/opentui/index.tsx +11 -4
- package/src/components/ui/data-table/opentui/model.ts +8 -6
- package/src/components/ui/data-table/types.ts +6 -1
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/page-stack-view.tsx +3 -0
- package/src/components/ui/pane-link-chip.tsx +269 -54
- package/src/components/ui/query-bar.tsx +2 -1
- package/src/components/ui/table-layout.ts +38 -1
- package/src/components/ui/tabs.tsx +97 -19
- package/src/core/state/app/layout-reducer.ts +7 -0
- package/src/core/state/app/layout.ts +44 -7
- package/src/core/state/app/state.ts +1 -1
- package/src/core/state/app/types.ts +22 -2
- package/src/docs/snapshot.json +30 -13
- package/src/market-data/depositary-pair.ts +5 -3
- package/src/market-data/market/change-basis.ts +9 -5
- package/src/market-data/market/dated-previous-close.ts +147 -17
- package/src/market-data/market/status.ts +17 -1
- package/src/market-data/quotes/contributions.ts +2 -0
- package/src/market-data/quotes/listing-enterprise-value.ts +50 -0
- package/src/plugins/builtin/alerts/metric-data.ts +15 -2
- package/src/plugins/builtin/analytics/risk-client.ts +10 -4
- package/src/plugins/builtin/analytics/risk-episodes.ts +5 -4
- package/src/plugins/builtin/analytics/risk-headless.ts +4 -2
- package/src/plugins/builtin/analytics/risk-sectors.ts +91 -0
- package/src/plugins/builtin/awards/index.tsx +1 -1
- package/src/plugins/builtin/backtest/headless.ts +1 -1
- package/src/plugins/builtin/buildout/index.tsx +1 -0
- package/src/plugins/builtin/catalysts/index.tsx +2 -2
- package/src/plugins/builtin/cds/headless.ts +4 -0
- package/src/plugins/builtin/cds/model.ts +0 -6
- package/src/plugins/builtin/chart-composer/formula.ts +16 -3
- package/src/plugins/builtin/chart-composer/headless-schema.ts +2 -0
- package/src/plugins/builtin/chart-composer/headless.ts +4 -2
- package/src/plugins/builtin/chart-composer/index.tsx +1 -0
- package/src/plugins/builtin/chart-composer/presets.ts +1 -0
- package/src/plugins/builtin/chat/content/composer.tsx +5 -4
- package/src/plugins/builtin/chat/content/index.tsx +12 -2
- package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -3
- package/src/plugins/builtin/chat/content/open-targets.ts +3 -3
- package/src/plugins/builtin/chat/layout.ts +5 -2
- package/src/plugins/builtin/chat/message/pane-chip.tsx +61 -40
- package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
- package/src/plugins/builtin/chat/pane-links/previews.ts +51 -5
- package/src/plugins/builtin/chat/pane-links/share-card.ts +36 -0
- package/src/plugins/builtin/cloud/askg/pane.tsx +55 -13
- package/src/plugins/builtin/cloud/askg/tool-display.ts +1 -0
- package/src/plugins/builtin/cloud/terminal-relay/redact.ts +5 -3
- package/src/plugins/builtin/commodity-balances/index.tsx +1 -0
- package/src/plugins/builtin/company-attention/index.tsx +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +3 -1
- package/src/plugins/builtin/company-kpis/index.tsx +2 -2
- package/src/plugins/builtin/cot/index.tsx +1 -1
- package/src/plugins/builtin/cpi/index.tsx +1 -1
- package/src/plugins/builtin/credit-boards/cdx-pane.tsx +20 -7
- package/src/plugins/builtin/credit-boards/client.ts +8 -0
- package/src/plugins/builtin/credit-boards/headless.ts +4 -1
- package/src/plugins/builtin/credit-boards/model.ts +58 -4
- package/src/plugins/builtin/credit-boards/series.ts +63 -6
- package/src/plugins/builtin/credit-boards/sovr-pane.tsx +3 -2
- package/src/plugins/builtin/credit-conditions/headless.ts +24 -6
- package/src/plugins/builtin/credit-conditions/index.tsx +1 -1
- package/src/plugins/builtin/credit-conditions/model.ts +12 -6
- package/src/plugins/builtin/credit-conditions/series.ts +2 -1
- package/src/plugins/builtin/crypto-board/index.tsx +1 -0
- package/src/plugins/builtin/dividend-yield/index.tsx +1 -0
- package/src/plugins/builtin/doe/index.tsx +1 -1
- package/src/plugins/builtin/earnings-calls/headless.ts +5 -1
- package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
- package/src/plugins/builtin/econ/calendar-model.ts +115 -8
- package/src/plugins/builtin/econ/calendar-source.ts +7 -1
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -1
- package/src/plugins/builtin/econ/index.tsx +42 -8
- package/src/plugins/builtin/econ/types.ts +3 -0
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/pane.tsx +6 -0
- package/src/plugins/builtin/estimate-revisions/index.tsx +1 -0
- package/src/plugins/builtin/executives/index.tsx +1 -0
- package/src/plugins/builtin/filing-events/index.tsx +1 -0
- package/src/plugins/builtin/fixed-income/index.tsx +3 -0
- package/src/plugins/builtin/futures-curve/headless.ts +3 -3
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +18 -0
- package/src/plugins/builtin/fx-matrix/index.tsx +44 -14
- package/src/plugins/builtin/gpu/index.tsx +1 -1
- package/src/plugins/builtin/help/functions-table.tsx +1 -1
- package/src/plugins/builtin/help/index.tsx +11 -1
- package/src/plugins/builtin/help/keybindings-editor.tsx +7 -3
- package/src/plugins/builtin/holders/index.tsx +1 -0
- package/src/plugins/builtin/holders/report-header.ts +2 -2
- package/src/plugins/builtin/insider/index.tsx +1 -0
- package/src/plugins/builtin/iv-history/index.tsx +1 -1
- package/src/plugins/builtin/jobs/index.tsx +1 -0
- package/src/plugins/builtin/macro-day/headless.ts +27 -8
- package/src/plugins/builtin/macro-day/index.tsx +1 -1
- package/src/plugins/builtin/macro-day/model.ts +19 -3
- package/src/plugins/builtin/macro-day/pane.tsx +14 -9
- package/src/plugins/builtin/macro-day/releases.ts +25 -7
- package/src/plugins/builtin/market-valuation/index.tsx +1 -0
- package/src/plugins/builtin/market-valuation/pane.tsx +8 -0
- package/src/plugins/builtin/members/index.tsx +1 -1
- package/src/plugins/builtin/mna/index.tsx +1 -0
- package/src/plugins/builtin/news/index.tsx +1 -0
- package/src/plugins/builtin/news/wire/index.tsx +5 -1
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +4 -0
- package/src/plugins/builtin/news/wire/news/list-search.ts +5 -2
- package/src/plugins/builtin/options/index.tsx +1 -0
- package/src/plugins/builtin/options-positioning/index.tsx +1 -0
- package/src/plugins/builtin/pe-band/index.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +25 -0
- package/src/plugins/builtin/portfolio-list/cli/render.ts +20 -3
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +5 -1
- package/src/plugins/builtin/portfolio-list/headless.ts +15 -6
- package/src/plugins/builtin/power/index.tsx +1 -1
- package/src/plugins/builtin/realized-vol/index.tsx +1 -1
- package/src/plugins/builtin/research/headless-schema.ts +4 -3
- package/src/plugins/builtin/research/headless.ts +10 -4
- package/src/plugins/builtin/research/index.tsx +4 -0
- package/src/plugins/builtin/research/relative-valuation-columns.ts +145 -47
- package/src/plugins/builtin/research/relative-valuation-currency.ts +31 -0
- package/src/plugins/builtin/research/relative-valuation-headless.ts +25 -8
- package/src/plugins/builtin/research/relative-valuation-model.ts +40 -9
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +3 -2
- package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -2
- package/src/plugins/builtin/research-search/index.tsx +1 -0
- package/src/plugins/builtin/research-search/pane.tsx +8 -0
- package/src/plugins/builtin/revenue-breakdown/index.tsx +1 -0
- package/src/plugins/builtin/reverse-dcf/index.tsx +1 -1
- package/src/plugins/builtin/risk-factors/index.tsx +1 -0
- package/src/plugins/builtin/scanner/headless.ts +52 -13
- package/src/plugins/builtin/seasonality/index.tsx +1 -1
- package/src/plugins/builtin/sec/index.tsx +1 -0
- package/src/plugins/builtin/series-inventory.ts +1 -1
- package/src/plugins/builtin/shared/scanner-capture.ts +11 -3
- package/src/plugins/builtin/shared/series-list-detail.tsx +5 -0
- package/src/plugins/builtin/short-interest/index.tsx +1 -0
- package/src/plugins/builtin/social-mentions/index.tsx +1 -1
- package/src/plugins/builtin/supply-chain/index.tsx +1 -0
- package/src/plugins/builtin/thirteenf/api.ts +47 -4
- package/src/plugins/builtin/thirteenf/data.ts +43 -10
- package/src/plugins/builtin/thirteenf/headless.ts +55 -11
- package/src/plugins/builtin/thirteenf/model.ts +25 -9
- package/src/plugins/builtin/thirteenf/report-notes.ts +27 -6
- package/src/plugins/builtin/thirteenf/types.ts +2 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +1 -1
- package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +8 -7
- package/src/plugins/builtin/ticker-detail/data-panes/history-bars.ts +8 -5
- package/src/plugins/builtin/ticker-detail/financials/model.ts +18 -2
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -3
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +6 -6
- package/src/plugins/builtin/ticker-detail/headless.ts +24 -17
- package/src/plugins/builtin/ticker-detail/index.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +6 -4
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +6 -4
- package/src/plugins/builtin/time-sales/client.ts +9 -11
- package/src/plugins/builtin/time-sales/index.tsx +1 -1
- package/src/plugins/builtin/treasury-auctions/after.ts +267 -0
- package/src/plugins/builtin/treasury-auctions/cache.ts +54 -5
- package/src/plugins/builtin/treasury-auctions/client.ts +33 -2
- package/src/plugins/builtin/treasury-auctions/headless.ts +150 -22
- package/src/plugins/builtin/treasury-auctions/hk-headless.ts +126 -0
- package/src/plugins/builtin/treasury-auctions/hk-view.tsx +347 -0
- package/src/plugins/builtin/treasury-auctions/hk.ts +363 -0
- package/src/plugins/builtin/treasury-auctions/index.tsx +27 -4
- package/src/plugins/builtin/treasury-auctions/model.ts +264 -28
- package/src/plugins/builtin/treasury-auctions/pane.tsx +176 -41
- package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +5 -2
- package/src/plugins/builtin/treasury-auctions/types.ts +7 -1
- package/src/plugins/builtin/vol-surface/index.tsx +1 -1
- package/src/plugins/builtin/world-venue-map/index.ts +1 -0
- package/src/plugins/builtin/yield-curve/curves.ts +10 -4
- package/src/plugins/builtin/yield-curve/headless.ts +6 -2
- package/src/plugins/builtin/yield-curve/index.tsx +3 -3
- package/src/plugins/builtin/yield-curve/series.ts +10 -0
- package/src/plugins/builtin/yield-curve/world.ts +3 -1
- package/src/portfolio/collection-name.ts +22 -0
- package/src/portfolio/column-values.ts +2 -1
- package/src/public/__snapshots__/public-api.test.ts.snap +4 -0
- package/src/public/remote.ts +7 -1
- package/src/remote/client.ts +191 -11
- package/src/remote/controller-utils.ts +13 -1
- package/src/remote/controller.ts +88 -26
- package/src/remote/endpoint.ts +24 -0
- package/src/remote/form.ts +59 -4
- package/src/remote/resources.ts +44 -18
- package/src/remote/schema.ts +21 -9
- package/src/remote/secrets.ts +12 -0
- package/src/remote/semantic-tree.tsx +14 -2
- package/src/remote/server.ts +2 -1
- package/src/remote/surface.tsx +192 -0
- package/src/remote/types.ts +5 -0
- package/src/renderers/dom/data-table/frozen-column.ts +3 -1
- package/src/renderers/dom/data-table/index.tsx +27 -9
- package/src/renderers/dom/data-table/row.tsx +2 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +27 -24
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +3 -3
- package/src/renderers/electrobun/bun/desktop/snapshot-commit.ts +77 -0
- package/src/renderers/electrobun/shared/protocol.ts +4 -0
- package/src/renderers/electrobun/view/backend-rpc.ts +3 -0
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +3 -0
- package/src/renderers/opentui/host.tsx +6 -0
- package/src/series/standalone.ts +2 -2
- package/src/shares/api.ts +21 -4
- package/src/shares/item.ts +73 -0
- package/src/shares/pane-item.ts +205 -0
- package/src/shares/pane.ts +4 -0
- package/src/shares/payload.ts +9 -5
- package/src/sources/gloomberb-cloud/news.ts +2 -0
- package/src/sources/gloomberb-cloud/normalizers.ts +9 -5
- package/src/sources/provider-router/cache.ts +3 -1
- package/src/sync/controller.ts +17 -2
- package/src/sync/other-window-tabs.ts +32 -1
- package/src/sync/react.ts +4 -4
- package/src/tickers/renamed-listings.ts +105 -0
- package/src/tickers/search/index.ts +103 -16
- package/src/time-series/bar-spacing.ts +33 -0
- package/src/time-series/base-series.ts +21 -3
- package/src/time-series/chart-bounds.ts +31 -0
- package/src/time-series/field-catalog.ts +17 -0
- package/src/time-series/fundamentals.ts +143 -11
- package/src/time-series/ice-credit.ts +32 -6
- package/src/time-series/resolve.ts +11 -7
- package/src/time-series/session-bar.ts +78 -9
- package/src/time-series/studies/formula.ts +53 -10
- package/src/time-series/studies/pair.ts +18 -7
- package/src/time-series/studies/units.ts +49 -2
- package/src/time-series/types.ts +12 -0
- package/src/types/desktop-window.ts +2 -0
- package/src/types/financials.ts +7 -0
- package/src/types/headless.ts +8 -0
- package/src/types/plugin-pane-settings.ts +2 -0
- package/src/types/plugin-panes.ts +22 -0
- package/src/utils/central-banks.ts +86 -1
- package/src/utils/cli-output.ts +6 -3
- package/src/utils/datetime-format.ts +12 -3
- package/src/utils/depositary-receipt.ts +28 -3
- package/src/utils/ebitda.ts +128 -0
- package/src/utils/format.ts +1 -1
- package/src/utils/fundamentals.ts +14 -0
- package/src/utils/max-drawdown.ts +97 -16
- package/src/utils/shell-word.ts +13 -0
- package/src/utils/untrusted-text.ts +29 -0
|
@@ -3,7 +3,7 @@ import type { ManualChartResolution } from "../resolution";
|
|
|
3
3
|
import type { ChartStudySpec, ResolvedSeries, SeriesPeriod, TimeSeriesPoint } from "../types";
|
|
4
4
|
import { isFiniteNumber } from "../../utils/guards";
|
|
5
5
|
import { derivedPoint, outputSeries, studyPeriod } from "./shared";
|
|
6
|
-
import { derivedValueDecimals, isPriceGroup, ratioUnit } from "./units";
|
|
6
|
+
import { derivedValueDecimals, isPriceGroup, PLAIN_RATIO_UNIT, percentBasisPointRatioScale, ratioUnit } from "./units";
|
|
7
7
|
|
|
8
8
|
interface PairedSample {
|
|
9
9
|
point: TimeSeriesPoint;
|
|
@@ -49,6 +49,11 @@ function pairedHistoryResolution(left: ResolvedSeries, right: ResolvedSeries): M
|
|
|
49
49
|
return left.historyResolution === right.historyResolution ? left.historyResolution : null;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/** A pair's leg as its formula names it: a published series as written, anything else by its label. */
|
|
53
|
+
function pairLegName(series: ResolvedSeries): string {
|
|
54
|
+
return series.expression ?? series.label;
|
|
55
|
+
}
|
|
56
|
+
|
|
52
57
|
export function resolvePairStudy(
|
|
53
58
|
spec: ChartStudySpec,
|
|
54
59
|
left: ResolvedSeries,
|
|
@@ -58,15 +63,19 @@ export function resolvePairStudy(
|
|
|
58
63
|
const paired = pairedSamples(left, right, spec.kind !== "correlation");
|
|
59
64
|
if (spec.kind === "ratio" || spec.kind === "spread") {
|
|
60
65
|
const multiplier = isFiniteNumber(spec.parameters.multiplier) ? spec.parameters.multiplier : 1;
|
|
66
|
+
const ratioStudy = spec.kind === "ratio";
|
|
67
|
+
// A percent over basis points cancels to a plain number, 100 times the quotient (4.1% over 61bp is 6.72),
|
|
68
|
+
// rounded off the float's last digits.
|
|
69
|
+
const percentScale = ratioStudy ? percentBasisPointRatioScale(left, right) : null;
|
|
61
70
|
const points = paired.map((sample) => derivedPoint(
|
|
62
71
|
{ point: sample.point, value: sample.left },
|
|
63
|
-
|
|
64
|
-
? sample.right === 0 ? null : sample.left / sample.right
|
|
72
|
+
ratioStudy
|
|
73
|
+
? sample.right === 0 ? null : percentScale === null ? sample.left / sample.right
|
|
74
|
+
: Number((sample.left / sample.right * percentScale).toPrecision(12))
|
|
65
75
|
: sample.left - sample.right * multiplier,
|
|
66
76
|
));
|
|
67
|
-
const ratioStudy = spec.kind === "ratio";
|
|
68
77
|
const outputUnit = ratioStudy
|
|
69
|
-
? ratioUnit(left, right)
|
|
78
|
+
? percentScale === null ? ratioUnit(left, right) : PLAIN_RATIO_UNIT
|
|
70
79
|
: { unit: left.unit, unitGroup: left.unitGroup };
|
|
71
80
|
// A price over an FX rate is a price in the other currency (EUR / barrel),
|
|
72
81
|
// stated as a future's unit is; a plain ratio keeps its own decimals.
|
|
@@ -75,9 +84,11 @@ export function resolvePairStudy(
|
|
|
75
84
|
return [outputSeries(spec, left, {
|
|
76
85
|
...(convertedPrice ? { statedUnit: outputUnit.unit, priceAssetCategory: null } : {}),
|
|
77
86
|
...(valueDecimals !== undefined ? { valueDecimals } : {}),
|
|
87
|
+
// A published series reads as it is written (FRED:BAMLC0A0CM - CAP:cdx:ig): its long title would
|
|
88
|
+
// read like the leg's own line in a legend that has to shorten.
|
|
78
89
|
label: ratioStudy
|
|
79
|
-
? `${left
|
|
80
|
-
: `${left
|
|
90
|
+
? `${pairLegName(left)} / ${pairLegName(right)}`
|
|
91
|
+
: `${pairLegName(left)} - ${multiplier === 1 ? "" : `${multiplier}×`}${pairLegName(right)}`,
|
|
81
92
|
points,
|
|
82
93
|
color,
|
|
83
94
|
unit: outputUnit.unit,
|
|
@@ -57,9 +57,9 @@ export function knownUnitSignature(series: Pick<ResolvedSeries, "unit" | "unitGr
|
|
|
57
57
|
return `${basis ?? ""}|${parts.map(unitFactorIdentity).join("/")}`;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
/** A leg as an error
|
|
60
|
+
/** A leg as a formula and an error name it: its ticker (HO=F), else as it is written (FRED:BAMLC0A0CM), else its label. */
|
|
61
61
|
export function legName(series: ResolvedSeries): string {
|
|
62
|
-
return series.listing?.symbol || series.label;
|
|
62
|
+
return series.listing?.symbol || series.expression || series.label;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/** What a leg's unit is, in words: "is USD / gallon", "is in %", "is in USD per an unknown quantity". */
|
|
@@ -97,6 +97,10 @@ export function unitMismatchMessage(
|
|
|
97
97
|
if (gallons && leftCurrency === rightCurrency) {
|
|
98
98
|
return `${named}: write ${GALLONS_PER_BARREL}*${gallons} to compare per barrel.`;
|
|
99
99
|
}
|
|
100
|
+
// A percent beside basis points is 100 short of them, a known conversion as 42 gallons are a barrel.
|
|
101
|
+
const percent = isPercentUnit(left.unit) && isBasisPointUnit(right.unit) ? leftName
|
|
102
|
+
: isBasisPointUnit(left.unit) && isPercentUnit(right.unit) ? rightName : null;
|
|
103
|
+
if (percent) return `${named}: write ${BP_PER_PERCENT}*${percent} to compare in bp.`;
|
|
100
104
|
const subject = kind === "spread" ? "a spread" : "a formula";
|
|
101
105
|
if (leftCurrency && rightCurrency && leftCurrency !== rightCurrency) return `${named}: ${subject} does not convert currencies.`;
|
|
102
106
|
const known = knownUnitSignature({ unit: left.unit, unitGroup: left.series.unitGroup }) !== null
|
|
@@ -122,6 +126,49 @@ export interface SeriesUnit {
|
|
|
122
126
|
unitGroup: string;
|
|
123
127
|
}
|
|
124
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Basis points, in the group a catalog series in bp draws in (CDX IG), so a
|
|
131
|
+
* spread converted to bp shares its axis.
|
|
132
|
+
*/
|
|
133
|
+
export const BASIS_POINT_UNIT: SeriesUnit = { unit: "bp", unitGroup: "series:bp" };
|
|
134
|
+
/** Percent, in the group FRED's percent series and a catalog series in % draw in. */
|
|
135
|
+
const PERCENT_UNIT: SeriesUnit = { unit: "%", unitGroup: "percent" };
|
|
136
|
+
/** Basis points in a percentage point: 0.93% is 93bp. */
|
|
137
|
+
export const BP_PER_PERCENT = 100;
|
|
138
|
+
|
|
139
|
+
function isPercentUnit(unit: string): boolean {
|
|
140
|
+
return unit.trim() === "%";
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function isBasisPointUnit(unit: string): boolean {
|
|
144
|
+
return /^bps?$/i.test(unit.trim());
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The unit a leg reads in once its multiplier converts it: times 100, a
|
|
149
|
+
* percent is basis points (0.93% is 93bp); times 0.01, basis points are a
|
|
150
|
+
* percent. Null when the conversion does not apply to the unit.
|
|
151
|
+
*/
|
|
152
|
+
export function percentBasisPointUnit(unit: string, direction: 1 | -1): SeriesUnit | null {
|
|
153
|
+
if (direction === 1 && isPercentUnit(unit)) return BASIS_POINT_UNIT;
|
|
154
|
+
if (direction === -1 && isBasisPointUnit(unit)) return PERCENT_UNIT;
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* What a percent over basis points, or basis points over a percent, is
|
|
160
|
+
* multiplied by to cancel to a plain number: 100 for % over bp, 0.01 for bp
|
|
161
|
+
* over %. 4.1% over 61bp is 410bp over 61bp, 6.72. Null for any other pair.
|
|
162
|
+
*/
|
|
163
|
+
export function percentBasisPointRatioScale(numerator: Pick<SeriesUnit, "unit">, denominator: Pick<SeriesUnit, "unit">): number | null {
|
|
164
|
+
if (isPercentUnit(numerator.unit) && isBasisPointUnit(denominator.unit)) return BP_PER_PERCENT;
|
|
165
|
+
if (isBasisPointUnit(numerator.unit) && isPercentUnit(denominator.unit)) return 1 / BP_PER_PERCENT;
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** A plain number: a ratio whose units cancel. */
|
|
170
|
+
export const PLAIN_RATIO_UNIT: SeriesUnit = { unit: "x", unitGroup: "ratio" };
|
|
171
|
+
|
|
125
172
|
const UNKNOWN_UNIT: SeriesUnit = { unit: "unknown", unitGroup: "derived-unit:unknown" };
|
|
126
173
|
|
|
127
174
|
export function isPriceGroup(unitGroup: string): boolean {
|
package/src/time-series/types.ts
CHANGED
|
@@ -238,6 +238,12 @@ export interface ResolvedSeries {
|
|
|
238
238
|
* figures of the period asked for, while its annual ones exist.
|
|
239
239
|
*/
|
|
240
240
|
unreportedPeriod?: "quarterly";
|
|
241
|
+
/**
|
|
242
|
+
* Set where the series' current value is not meaningful (N/M): EV/EBITDA
|
|
243
|
+
* over EBITDA at or below zero, or a bank's or an insurer's, with why and
|
|
244
|
+
* the period it would end on (`valuationNotMeaningful`).
|
|
245
|
+
*/
|
|
246
|
+
notMeaningful?: { reason: string; asOf: string };
|
|
241
247
|
/** Acquired market-history cadence; null is explicitly unknown, undefined is legacy or nonmarket. */
|
|
242
248
|
historyResolution?: ManualChartResolution | null;
|
|
243
249
|
/**
|
|
@@ -265,6 +271,12 @@ export interface ResolvedSeries {
|
|
|
265
271
|
* VWAP follow. Set even where no exchange time zone is known (futures).
|
|
266
272
|
*/
|
|
267
273
|
listing?: { symbol: string; exchange: string };
|
|
274
|
+
/**
|
|
275
|
+
* A dataset series as a formula writes it (`FRED:BAMLC0A0CM`,
|
|
276
|
+
* `CAP:cdx:ig`): what a formula's label and its unit errors name it by,
|
|
277
|
+
* so they read as written rather than as the source's long title.
|
|
278
|
+
*/
|
|
279
|
+
expression?: string;
|
|
268
280
|
/** Price/volume observations and their derived studies, including 24/7
|
|
269
281
|
* markets. Independent of whether the chart compresses exchange sessions.
|
|
270
282
|
* `dataset`: a capability's published observations (vessel transits),
|
|
@@ -105,4 +105,6 @@ export interface DesktopWindowBridge {
|
|
|
105
105
|
subscribeState(listener: (snapshot: DesktopSharedStateSnapshot) => void): () => void;
|
|
106
106
|
subscribeDockPreview?(listener: (preview: DesktopDockPreviewState) => void): () => void;
|
|
107
107
|
subscribeThemePreview?(listener: (preview: DesktopThemePreviewState) => void): () => void;
|
|
108
|
+
/** A window change the desktop app could not save (a window closed, a pane docked or moved), in the main window. */
|
|
109
|
+
subscribeSaveFailures?(listener: () => void): () => void;
|
|
108
110
|
}
|
package/src/types/financials.ts
CHANGED
|
@@ -167,6 +167,12 @@ export interface Quote extends DepositaryReceiptFacts {
|
|
|
167
167
|
* date the close (PreviousCloseDates); a source may set it too.
|
|
168
168
|
*/
|
|
169
169
|
previousCloseDate?: string;
|
|
170
|
+
/**
|
|
171
|
+
* A thin listing that did not trade in the session its venue's calendar
|
|
172
|
+
* puts before the move's, and whose daily closes do not say which day its
|
|
173
|
+
* previousClose is from (PreviousCloseDates): its move names no day.
|
|
174
|
+
*/
|
|
175
|
+
previousCloseUndated?: boolean;
|
|
170
176
|
/** Official close of a completed regular session, in this quote's currency. */
|
|
171
177
|
regularClose?: number;
|
|
172
178
|
/** Exchange-local date of regularClose; separate from the daily previous-close reference. */
|
|
@@ -546,6 +552,7 @@ export interface AnalystRatingRecord {
|
|
|
546
552
|
}
|
|
547
553
|
|
|
548
554
|
export interface AnalystEstimateRecord {
|
|
555
|
+
epsBasis?: "gaap" | "adjusted" | "unknown";
|
|
549
556
|
date: string;
|
|
550
557
|
period: string;
|
|
551
558
|
/** Explicit currency for these estimates; independent of the listing currency. */
|
package/src/types/headless.ts
CHANGED
|
@@ -497,6 +497,12 @@ interface HeadlessPaneResultBase {
|
|
|
497
497
|
*/
|
|
498
498
|
warnings?: string[];
|
|
499
499
|
metadata?: Record<string, unknown>;
|
|
500
|
+
/**
|
|
501
|
+
* Options the load settled from what it was given rather than from a flag
|
|
502
|
+
* (AUCT's market, from a search naming Hong Kong's paper): the report's
|
|
503
|
+
* `options` show these, so they name what was used, not the default.
|
|
504
|
+
*/
|
|
505
|
+
appliedOptions?: HeadlessPaneOptionValues;
|
|
500
506
|
/** What this load knows about its data's source and age; overrides the definition's `freshness`. */
|
|
501
507
|
freshness?: HeadlessPaneFreshness;
|
|
502
508
|
}
|
|
@@ -692,6 +698,8 @@ export interface HeadlessSeries {
|
|
|
692
698
|
textCompact?: boolean;
|
|
693
699
|
/** Each point's `value` is its bar's close: `--csv` and `--ndjson` write Close alone, JSON keeps both. */
|
|
694
700
|
valueIsClose?: boolean;
|
|
701
|
+
/** The series' current value is not meaningful: the report prints N/M dated by the period, and why. */
|
|
702
|
+
notMeaningful?: { reason: string; asOf: string };
|
|
695
703
|
points: HeadlessSeriesPoint[];
|
|
696
704
|
}
|
|
697
705
|
|
|
@@ -40,6 +40,8 @@ export interface PaneSettingTextField extends PaneSettingFieldBase {
|
|
|
40
40
|
interface PaneSettingSelectField extends PaneSettingFieldBase {
|
|
41
41
|
type: "select";
|
|
42
42
|
options: PaneSettingOption[];
|
|
43
|
+
/** The option an unset value reads as: shown as the current choice, and where the picker starts. */
|
|
44
|
+
defaultValue?: string;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
interface PaneSettingMultiSelectField extends PaneSettingFieldBase {
|
|
@@ -169,6 +169,13 @@ export interface PaneDef {
|
|
|
169
169
|
settings?: PaneSettingsDef | ((context: PaneSettingsContext) => PaneSettingsDef | null);
|
|
170
170
|
/** Portable sharing is public by default; list the few pane-owned fields that must remain local. */
|
|
171
171
|
portableShare?: PanePortableShareDef;
|
|
172
|
+
/**
|
|
173
|
+
* What a public link to the pane may name as the item it was on, beside the
|
|
174
|
+
* pane (`shares/pane-item.ts`); unset, the link names the pane alone. Only for
|
|
175
|
+
* a pane of public data, and only the app's own panes: a plugin loaded from
|
|
176
|
+
* outside the app names nothing, whatever it sets here.
|
|
177
|
+
*/
|
|
178
|
+
shareItem?: PaneShareItemDef;
|
|
172
179
|
/**
|
|
173
180
|
* The person's own data the pane shows, so copying a public link to it,
|
|
174
181
|
* posting its picture in a bug report and attaching it to an Ask Gloom
|
|
@@ -189,6 +196,21 @@ export interface PaneDef {
|
|
|
189
196
|
quickSettings?: readonly PaneQuickSettingDef[];
|
|
190
197
|
}
|
|
191
198
|
|
|
199
|
+
export interface PaneShareItemDef {
|
|
200
|
+
/**
|
|
201
|
+
* What the pane has open or picked: what it says with `usePaneShareItem`,
|
|
202
|
+
* else its stack's detail title and its reader's opening.
|
|
203
|
+
*/
|
|
204
|
+
open?: true;
|
|
205
|
+
/** The one ticker the pane shows, when it follows one (`tickerFollower`). */
|
|
206
|
+
ticker?: true;
|
|
207
|
+
/**
|
|
208
|
+
* The option the pane's function was opened with (`NI CRYPTO`), when the
|
|
209
|
+
* function lists it (`argOptions`). Free text is never named.
|
|
210
|
+
*/
|
|
211
|
+
argument?: true;
|
|
212
|
+
}
|
|
213
|
+
|
|
192
214
|
/**
|
|
193
215
|
* Kinds of personal data a pane can show: `holdings` (positions, balances,
|
|
194
216
|
* orders, profit and loss), `account` (account numbers, email, plan),
|
|
@@ -13,6 +13,10 @@ export interface CentralBank {
|
|
|
13
13
|
aliases: readonly string[];
|
|
14
14
|
/** The FRED series the board reads the row from; the other rows come from BIS. */
|
|
15
15
|
fredSeriesIds?: readonly string[];
|
|
16
|
+
/** The committee and the rate its decisions are reported by, where those are not its names: Copom, Selic. */
|
|
17
|
+
decisionWords?: readonly string[];
|
|
18
|
+
/** Names another company goes by in the news too (BCB Bancorp), never searched for its stories or matched in them. */
|
|
19
|
+
sharedNames?: readonly string[];
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
/**
|
|
@@ -35,7 +39,7 @@ export const CENTRAL_BANKS: readonly CentralBank[] = [
|
|
|
35
39
|
{ id: "ID", place: "Indonesia", name: "Bank Indonesia", short: "Bank Indonesia", instrument: "7-day reverse repo rate", aliases: [] },
|
|
36
40
|
{ id: "KR", place: "South Korea", name: "Bank of Korea", short: "BoK", instrument: "base rate", aliases: [] },
|
|
37
41
|
{ id: "BR", place: "Brazil", name: "Central Bank of Brazil", short: "BCB", instrument: "Selic target",
|
|
38
|
-
aliases: ["Banco Central do Brasil"] },
|
|
42
|
+
aliases: ["Banco Central do Brasil"], decisionWords: ["Copom", "Selic"], sharedNames: ["BCB"] },
|
|
39
43
|
{ id: "MX", place: "Mexico", name: "Bank of Mexico", short: "Banxico", instrument: "overnight rate target",
|
|
40
44
|
aliases: ["Banco de México"] },
|
|
41
45
|
{ id: "RU", place: "Russia", name: "Bank of Russia", short: "Bank of Russia", instrument: "key rate",
|
|
@@ -69,6 +73,18 @@ export function centralBankNamed(query: string): CentralBank | null {
|
|
|
69
73
|
return CENTRAL_BANKS.find((bank) => centralBankNames(bank).some((name) => nameKey(name) === wanted)) ?? null;
|
|
70
74
|
}
|
|
71
75
|
|
|
76
|
+
/**
|
|
77
|
+
* The bank a single word is the short name of, in any case: what a sentence
|
|
78
|
+
* calls it or a one-word alias (ECB, BoJ, RBA, Fed, FOMC, Banxico). Never a
|
|
79
|
+
* name it shares with a company (BCB, BCB Bancorp's too). Null otherwise.
|
|
80
|
+
*/
|
|
81
|
+
export function centralBankShortNamed(word: string): CentralBank | null {
|
|
82
|
+
const wanted = nameKey(word);
|
|
83
|
+
if (!wanted || wanted.includes(" ")) return null;
|
|
84
|
+
return CENTRAL_BANKS.find((bank) => [bank.short, ...bank.aliases]
|
|
85
|
+
.some((name) => nameKey(name) === wanted && !(bank.sharedNames ?? []).some((shared) => nameKey(shared) === wanted))) ?? null;
|
|
86
|
+
}
|
|
87
|
+
|
|
72
88
|
/** Words a query puts beside a bank's name when it asks for its policy rate: "Bank of Japan rate", "ECB rate decision", "Fed funds rate". */
|
|
73
89
|
const POLICY_RATE_WORDS = new Set([
|
|
74
90
|
"rate", "rates", "policy", "interest", "decision", "decisions", "meeting", "meetings", "target", "funds",
|
|
@@ -116,3 +132,72 @@ export function centralBankCiting(fredSeriesId: string): CentralBank | null {
|
|
|
116
132
|
const wanted = fredSeriesId.trim().toUpperCase();
|
|
117
133
|
return CENTRAL_BANKS.find((bank) => bank.fredSeriesIds?.includes(wanted)) ?? null;
|
|
118
134
|
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The bank a news search names: by its names as `centralBankAskedAbout` reads
|
|
138
|
+
* them, or by the committee and rate its decisions are reported by ("copom",
|
|
139
|
+
* "copom selic", "Selic rate"). Null for anything else.
|
|
140
|
+
*/
|
|
141
|
+
export function centralBankInNews(query: string): CentralBank | null {
|
|
142
|
+
const asked = centralBankAskedAbout(query);
|
|
143
|
+
if (asked) return asked;
|
|
144
|
+
const words = nameKey(query).split(" ").filter(Boolean);
|
|
145
|
+
if (words.length === 0) return null;
|
|
146
|
+
return CENTRAL_BANKS.find((bank) => {
|
|
147
|
+
const decision = (bank.decisionWords ?? []).map((word) => nameKey(word).split(" "));
|
|
148
|
+
if (decision.length === 0) return false;
|
|
149
|
+
// Every word is one of the decision words or a word asking for the rate, and at least one is a decision word.
|
|
150
|
+
const named = words.filter((word) => decision.some((parts) => parts.includes(word)));
|
|
151
|
+
return named.length > 0 && words.every((word) => named.includes(word) || POLICY_RATE_WORDS.has(word));
|
|
152
|
+
}) ?? null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Words that ask for the newest of something without being what a story says: "latest Fed decision". */
|
|
156
|
+
const ASKING_WORDS = new Set(["current", "latest", "today"]);
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* What a news search asks of the bank besides naming it, lower case: "rate
|
|
160
|
+
* cut" of "fed rate cut", "" of "copom selic" or "Bank of Mexico". Its
|
|
161
|
+
* names, place and decision words are taken out, and the words that only ask
|
|
162
|
+
* for the newest.
|
|
163
|
+
*/
|
|
164
|
+
export function centralBankNewsTopic(bank: CentralBank, query: string): string {
|
|
165
|
+
let words = nameKey(query).split(" ").filter(Boolean);
|
|
166
|
+
const names = [`${bank.place} central bank`, ...centralBankNames(bank), bank.place, ...bank.decisionWords ?? []]
|
|
167
|
+
.map((name) => nameKey(name).split(" ")).sort((left, right) => right.length - left.length);
|
|
168
|
+
for (const name of names) {
|
|
169
|
+
for (let start = wordsIndex(words, name); start >= 0; start = wordsIndex(words, name)) {
|
|
170
|
+
words = [...words.slice(0, start), ...words.slice(start + name.length)];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return words.filter((word) => !ASKING_WORDS.has(word)).join(" ");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* What a bank's decisions are reported under, for a news search of each: its
|
|
178
|
+
* name, what a sentence calls it, its other names, "<place> central bank" and
|
|
179
|
+
* the committee and rate (Copom, Selic). Stories of the 5 Nov 2026 Banxico cut
|
|
180
|
+
* said "Bank of Mexico" or "Mexico's central bank", rarely "Banxico". A name
|
|
181
|
+
* another company shares (BCB) is left out.
|
|
182
|
+
*/
|
|
183
|
+
export function centralBankNewsQueries(bank: CentralBank): string[] {
|
|
184
|
+
const names = centralBankNames(bank).filter((name) => !bank.sharedNames?.includes(name));
|
|
185
|
+
return [...new Set([...names, `${bank.place} central bank`, ...bank.decisionWords ?? []])];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** An acronym (ECB, RBA, FOMC) is matched as a word in capitals: "the fomc" in lower case is no headline's. */
|
|
189
|
+
const ACRONYM = /^[A-Z]{2,5}$/;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Whether a story is about the bank: its title or summary names it as one of
|
|
193
|
+
* the phrases it is searched by, or as "<place>'s central bank", each as
|
|
194
|
+
* whole words. The search matches words anywhere, so "Bank of Mexico" also
|
|
195
|
+
* finds Citi Mexico's banks.
|
|
196
|
+
*/
|
|
197
|
+
export function storyNamesCentralBank(bank: CentralBank, text: string): boolean {
|
|
198
|
+
const story = ` ${nameKey(text)} `;
|
|
199
|
+
const phrases = [...centralBankNewsQueries(bank), `${bank.place}s central bank`];
|
|
200
|
+
return phrases.some((phrase) => ACRONYM.test(phrase)
|
|
201
|
+
? new RegExp(`(^|[^A-Za-z0-9])${phrase}([^A-Za-z0-9]|$)`).test(text)
|
|
202
|
+
: story.includes(` ${nameKey(phrase)} `));
|
|
203
|
+
}
|
package/src/utils/cli-output.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface CliTableColumn {
|
|
|
9
9
|
maxWidth?: number;
|
|
10
10
|
/** The narrowest a text column wraps to (MIN_WRAPPED_COLUMN_WIDTH unless set), or a `shrink: true` column is cut to; a narrower table moves columns under their rows. */
|
|
11
11
|
minWidth?: number;
|
|
12
|
-
/** Dropped, rightmost first, before any column is cut or moved to fit a terminal. */
|
|
12
|
+
/** Dropped, rightmost first, before any column is cut or moved to fit a terminal. Plain output keeps it, moved under its row. */
|
|
13
13
|
optional?: boolean;
|
|
14
14
|
/** Among optional columns, a higher priority is dropped sooner; equal ones go rightmost first. */
|
|
15
15
|
dropPriority?: number;
|
|
@@ -711,12 +711,14 @@ function renderTableLayout(
|
|
|
711
711
|
}) : [];
|
|
712
712
|
const ownStacked = stacked.filter((entry) => !shared.includes(entry));
|
|
713
713
|
// Columns moved under the rows print there as `Header value`, as many to a line as fit.
|
|
714
|
+
// Plain output keeps a moved column's empty cell as its dash, so every row reads the same columns.
|
|
715
|
+
const keepsEmpty = cliPlainEnabled();
|
|
714
716
|
const renderStacked = (entries: readonly TableEntry[], cells: string[], rowIndex: number, lineIndent: string, width: number): string[] => {
|
|
715
717
|
const lines: string[] = [];
|
|
716
718
|
let line = "";
|
|
717
719
|
for (const { column, index } of entries) {
|
|
718
720
|
const value = cells[index] ?? "";
|
|
719
|
-
if (rowIndex >= (column.stackRows ?? Infinity) || EMPTY_CELL.test(stripAnsi(value).trim())) continue;
|
|
721
|
+
if (rowIndex >= (column.stackRows ?? Infinity) || (!keepsEmpty && EMPTY_CELL.test(stripAnsi(value).trim()))) continue;
|
|
720
722
|
const piece = `${cliStyles.muted(column.header)} ${value}`;
|
|
721
723
|
if (line && visibleLength(line) + COLUMN_GAP + visibleLength(piece) <= width) {
|
|
722
724
|
line += `${" ".repeat(COLUMN_GAP)}${piece}`;
|
|
@@ -774,7 +776,8 @@ export function renderTable(columns: CliTableColumn[], rows: string[][], options
|
|
|
774
776
|
if (available == null || tableWidth(shown.map((entry) => entry.width)) <= available) {
|
|
775
777
|
return renderTableLayout(columns, rows, options, shown, [], available, false);
|
|
776
778
|
}
|
|
777
|
-
|
|
779
|
+
// Plain output keeps every column (`--plain` promises it): an optional one moves under its row instead.
|
|
780
|
+
while (!cliPlainEnabled() && tableWidth(shown.map((entry) => entry.width)) > available) {
|
|
778
781
|
const dropped = shown.reduce<(typeof shown)[number] | undefined>((pick, entry) => (
|
|
779
782
|
entry.column.optional && (!pick || (entry.column.dropPriority ?? 0) >= (pick.column.dropPriority ?? 0)) ? entry : pick
|
|
780
783
|
), undefined);
|
|
@@ -155,15 +155,24 @@ function utcMidnight(date: Date): number {
|
|
|
155
155
|
* in another year). A weekday never names a day a week or more back. With
|
|
156
156
|
* `utc`, the same in UTC, for a column whose header names the zone.
|
|
157
157
|
*/
|
|
158
|
-
export function formatFeedTime(
|
|
158
|
+
export function formatFeedTime(
|
|
159
|
+
value: DisplayDateValue,
|
|
160
|
+
now = Date.now(),
|
|
161
|
+
fallback = "-",
|
|
162
|
+
{ utc = false, dayToday = false }: {
|
|
163
|
+
utc?: boolean;
|
|
164
|
+
/** Today's time carries its weekday too ("Sat 00:47"), for a column whose other rows name theirs ("Fri 21:00"). */
|
|
165
|
+
dayToday?: boolean;
|
|
166
|
+
} = {},
|
|
167
|
+
): string {
|
|
159
168
|
const date = parseDisplayDate(value);
|
|
160
169
|
if (!date) return fallback;
|
|
161
170
|
const today = new Date(now);
|
|
162
171
|
const midnight = utc ? utcMidnight : localMidnight;
|
|
163
172
|
// Rounded, since a day with a DST change is 23 or 25 hours long.
|
|
164
173
|
const daysAgo = Math.round((midnight(today) - midnight(date)) / 86_400_000);
|
|
165
|
-
if (daysAgo === 0) return (utc ? utcClockFormatter : clockFormatter).format(date);
|
|
166
|
-
if (daysAgo
|
|
174
|
+
if (daysAgo === 0 && !dayToday) return (utc ? utcClockFormatter : clockFormatter).format(date);
|
|
175
|
+
if (daysAgo >= 0 && daysAgo < 7) return (utc ? utcWeekdayClockFormatter : weekdayClockFormatter).format(date).replace(",", "");
|
|
167
176
|
const sameYear = utc ? date.getUTCFullYear() === today.getUTCFullYear() : date.getFullYear() === today.getFullYear();
|
|
168
177
|
return formatShortDate(date, { year: sameYear ? false : "2-digit", utc });
|
|
169
178
|
}
|
|
@@ -62,9 +62,34 @@ export function sharesOutstandingInReceipts(
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
/**
|
|
66
|
-
|
|
65
|
+
/**
|
|
66
|
+
* What a receipt's home line is a unit of, from how its market writes the
|
|
67
|
+
* code: a B3 code ending in 4 to 8 is a preferred share (PETR4, ITUB4) and
|
|
68
|
+
* one ending in 11 a unit; a BMV line marked CPO holds certificates
|
|
69
|
+
* (TLEVISACPO) and one marked UB, UBD or UBL units (FEMSAUBD, KOFUBL); a
|
|
70
|
+
* Korean code ending in 5, 7 or 9 is a preferred share (005935), and any
|
|
71
|
+
* other line on those three markets an ordinary share (VALE3, WALMEX). A home
|
|
72
|
+
* line elsewhere, or none, says plain shares: its code does not say its class
|
|
73
|
+
* (PFBCOLOM is Bancolombia's preferred).
|
|
74
|
+
*/
|
|
75
|
+
function homeShareClass(home: string | null | undefined): { one: string; many: string } {
|
|
76
|
+
const ticker = (home ?? "").trim().toUpperCase();
|
|
77
|
+
const [code = "", venue = ""] = ticker.includes(":") ? ticker.split(":") : [ticker.replace(/\.[A-Z]+$/, ""), ticker.match(/\.([A-Z]+)$/)?.[1] ?? ""];
|
|
78
|
+
const b3 = venue === "SA" || venue === "B3" || venue === "BVMF" || venue === "SAO" || venue === "BOVESPA";
|
|
79
|
+
const bmv = venue === "MX" || venue === "BMV";
|
|
80
|
+
const korea = venue === "KS" || venue === "KQ" || venue === "KRX" || venue === "KOSDAQ";
|
|
81
|
+
if (b3 && /^[A-Z]{4}(4|5|6|7|8)$/.test(code)) return { one: "preferred share", many: "preferred shares" };
|
|
82
|
+
if (b3 && /^[A-Z]{4}11$/.test(code)) return { one: "unit", many: "units" };
|
|
83
|
+
if (bmv && /CPO$/.test(code)) return { one: "CPO", many: "CPOs" };
|
|
84
|
+
if (bmv && /UB[DLC]?$/.test(code)) return { one: "unit", many: "units" };
|
|
85
|
+
if (korea && /^\d{5}[579]$/.test(code)) return { one: "preferred share", many: "preferred shares" };
|
|
86
|
+
return b3 || bmv || korea ? { one: "ordinary share", many: "ordinary shares" } : { one: "share", many: "shares" };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** "1 ADR = 2 shares" ("2 preferred shares" of PETR4.SA, `homeShareClass`), or null without a usable ratio. */
|
|
90
|
+
export function adrRatioText(ratio: number | null | undefined, home?: string | null): string | null {
|
|
67
91
|
if (typeof ratio !== "number" || !Number.isFinite(ratio) || ratio <= 0) return null;
|
|
68
92
|
const count = Number.isInteger(ratio) ? String(ratio) : String(Number(ratio.toPrecision(6)));
|
|
69
|
-
|
|
93
|
+
const unit = homeShareClass(home);
|
|
94
|
+
return `1 ADR = ${count} ${ratio === 1 ? unit.one : unit.many}`;
|
|
70
95
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { FinancialStatement } from "../types/financials";
|
|
2
|
+
import { completeAvailability, statementFieldAvailability } from "./financial-statements";
|
|
3
|
+
|
|
4
|
+
const finite = (value: unknown): value is number => typeof value === "number" && Number.isFinite(value);
|
|
5
|
+
|
|
6
|
+
type DepreciationField = "depreciationAndAmortization" | "depreciationAmortizationDepletion";
|
|
7
|
+
|
|
8
|
+
/** The row's D&A: the cash flow statement's line, or D&A with depletion where only that is reported. */
|
|
9
|
+
function depreciation(row: FinancialStatement): { value: number; field: DepreciationField } | null {
|
|
10
|
+
for (const field of ["depreciationAndAmortization", "depreciationAmortizationDepletion"] as const) {
|
|
11
|
+
const value = row[field];
|
|
12
|
+
// An add-back: some sources sign it as the cash flow line, others as the expense.
|
|
13
|
+
if (finite(value)) return { value: Math.abs(value), field };
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Operating income, and how it was read when the row does not report it: the lines it was derived from. */
|
|
19
|
+
interface OperatingIncome {
|
|
20
|
+
value: number;
|
|
21
|
+
/** Null where the row reports operating income; else what it was derived as ("pretax income + interest expense - other income"). */
|
|
22
|
+
basis: string | null;
|
|
23
|
+
fields: readonly (keyof FinancialStatement)[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The row's operating income: the reported line, or, where a row lacks it (an
|
|
28
|
+
* energy major's quarter filed without one), derived from the lines it
|
|
29
|
+
* carries: revenue less total expenses, revenue less cost of revenue and
|
|
30
|
+
* operating expenses, else pretax income (or net income with its income tax
|
|
31
|
+
* added back) with interest expense added back and non-operating items taken
|
|
32
|
+
* out, as far as the row carries them. On Exxon Mobil's 2025 year each gives
|
|
33
|
+
* the 33.94B it reported.
|
|
34
|
+
*/
|
|
35
|
+
function operatingIncome(row: FinancialStatement, derive: boolean): OperatingIncome | null {
|
|
36
|
+
if (finite(row.operatingIncome)) return { value: row.operatingIncome, basis: null, fields: ["operatingIncome"] };
|
|
37
|
+
if (!derive) return null;
|
|
38
|
+
if (finite(row.totalRevenue) && finite(row.totalExpenses)) {
|
|
39
|
+
return { value: row.totalRevenue - row.totalExpenses, basis: "revenue less total expenses", fields: ["totalRevenue", "totalExpenses"] };
|
|
40
|
+
}
|
|
41
|
+
if (finite(row.totalRevenue) && finite(row.costOfRevenue) && finite(row.operatingExpense)) {
|
|
42
|
+
return {
|
|
43
|
+
value: row.totalRevenue - row.costOfRevenue - row.operatingExpense,
|
|
44
|
+
basis: "revenue less cost of revenue and operating expenses",
|
|
45
|
+
fields: ["totalRevenue", "costOfRevenue", "operatingExpense"],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const pretax = pretaxIncome(row);
|
|
49
|
+
if (!pretax) return null;
|
|
50
|
+
const interest = finite(row.interestExpense) ? Math.abs(row.interestExpense) : null;
|
|
51
|
+
// Other income and expense is every non-operating line together; the other non-operating line alone is part of it.
|
|
52
|
+
const nonOperating = finite(row.otherIncomeExpense) ? { value: row.otherIncomeExpense, field: "otherIncomeExpense" as const }
|
|
53
|
+
: finite(row.otherNonOperatingIncomeExpenses) ? { value: row.otherNonOperatingIncomeExpenses, field: "otherNonOperatingIncomeExpenses" as const }
|
|
54
|
+
: null;
|
|
55
|
+
return {
|
|
56
|
+
value: pretax.value + (interest ?? 0) - (nonOperating?.value ?? 0),
|
|
57
|
+
basis: [pretax.basis, ...interest !== null ? ["+ interest expense"] : [], ...nonOperating ? ["- non-operating items"] : []].join(" "),
|
|
58
|
+
fields: [...pretax.fields, ...interest !== null ? ["interestExpense" as const] : [], ...nonOperating ? [nonOperating.field] : []],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Pretax income as reported, or as net income (with minority interests) plus its income tax (Chevron's quarters file no pretax line). */
|
|
63
|
+
function pretaxIncome(row: FinancialStatement): { value: number; basis: string; fields: readonly (keyof FinancialStatement)[] } | null {
|
|
64
|
+
if (finite(row.pretaxIncome)) return { value: row.pretaxIncome, basis: "pretax income", fields: ["pretaxIncome"] };
|
|
65
|
+
if (!finite(row.taxProvision)) return null;
|
|
66
|
+
const income = finite(row.netIncomeIncludingNoncontrollingInterests) ? "netIncomeIncludingNoncontrollingInterests" as const
|
|
67
|
+
: finite(row.netIncome) ? "netIncome" as const : null;
|
|
68
|
+
return income ? { value: row[income]! + row.taxProvision, basis: "net income + income tax", fields: [income, "taxProvision"] } : null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Whether a company's statements carry no EBITDA that means anything: a bank's
|
|
73
|
+
* or an insurer's interest and claims are its operations, so operating income
|
|
74
|
+
* is not derived for it and an EV over its EBITDA reads N/M.
|
|
75
|
+
*/
|
|
76
|
+
export function isBankOrInsurerIndustry(industry: string | null | undefined): boolean {
|
|
77
|
+
return /\b(banks?|insurance|insurers?|reinsurance)\b/i.test(industry ?? "");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** What an EV/EBITDA reads for a bank or an insurer (isBankOrInsurerIndustry). */
|
|
81
|
+
export const BANK_OR_INSURER_EBITDA = "not meaningful for banks and insurers";
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* EBITDA as the glossary defines it and sell-side comps read it: operating
|
|
85
|
+
* income with D&A added back. Null when the row lacks either; a source's own
|
|
86
|
+
* EBITDA line can carry non-operating income and is never used in its place.
|
|
87
|
+
*/
|
|
88
|
+
function statementEbitda(row: FinancialStatement, derive: boolean): { value: number; income: OperatingIncome; amortization: { value: number; field: DepreciationField } } | null {
|
|
89
|
+
const amortization = depreciation(row);
|
|
90
|
+
const income = operatingIncome(row, derive);
|
|
91
|
+
return income && amortization ? { value: income.value + amortization.value, income, amortization } : null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Whether the row's EBITDA is missing for want of D&A beside a reported operating income, which a cell says. */
|
|
95
|
+
export function ebitdaLacksDepreciation(row: FinancialStatement | null | undefined): boolean {
|
|
96
|
+
return !!row && !finite(row.ebitda) && finite(row.operatingIncome) && !depreciation(row);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* How the row's EBITDA read its operating income where the row reports none:
|
|
101
|
+
* `pretax income + interest expense - non-operating items`. Null where it was
|
|
102
|
+
* reported, or where the row has no EBITDA.
|
|
103
|
+
*/
|
|
104
|
+
export function ebitdaOperatingIncomeBasis(row: FinancialStatement | null | undefined): string | null {
|
|
105
|
+
if (!row || !finite(row.ebitda) || finite(row.operatingIncome)) return null;
|
|
106
|
+
return operatingIncome(row, true)?.basis ?? null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The row with `ebitda` on that definition, dated by the later of its inputs:
|
|
111
|
+
* the source's figure is dropped, and a row without D&A has none. `derive`
|
|
112
|
+
* false (a bank's or an insurer's rows) reads reported operating income alone.
|
|
113
|
+
*/
|
|
114
|
+
export function withStatementEbitda<T extends FinancialStatement>(row: T, derive = true): T {
|
|
115
|
+
const ebitda = statementEbitda(row, derive);
|
|
116
|
+
const value = ebitda?.value ?? null;
|
|
117
|
+
const availableAt = ebitda
|
|
118
|
+
? completeAvailability([...ebitda.income.fields, ebitda.amortization.field].map((field) => statementFieldAvailability(row, field)))
|
|
119
|
+
: undefined;
|
|
120
|
+
if (row.ebitda === (value ?? undefined) && (!row.fieldAvailability || row.fieldAvailability.ebitda === availableAt)) return row;
|
|
121
|
+
const { ebitda: _source, ...rest } = row;
|
|
122
|
+
const next = (value === null ? rest : { ...rest, ebitda: value }) as T;
|
|
123
|
+
if (row.fieldAvailability) {
|
|
124
|
+
const { ebitda: _dated, ...fieldAvailability } = row.fieldAvailability;
|
|
125
|
+
next.fieldAvailability = availableAt ? { ...fieldAvailability, ebitda: availableAt } : fieldAvailability;
|
|
126
|
+
}
|
|
127
|
+
return next;
|
|
128
|
+
}
|
package/src/utils/format.ts
CHANGED
|
@@ -353,7 +353,7 @@ export function displayWidth(value: string): number {
|
|
|
353
353
|
return segmentGraphemes(value).reduce((total, segment) => total + graphemeWidth(segment), 0);
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
function truncateToWidth(value: string, width: number): string {
|
|
356
|
+
export function truncateToWidth(value: string, width: number): string {
|
|
357
357
|
if (width <= 0) return "";
|
|
358
358
|
if (SINGLE_WIDTH_ASCII_RE.test(value)) return value.slice(0, width);
|
|
359
359
|
let output = "";
|
|
@@ -126,6 +126,20 @@ export function enterpriseValueLabel(fundamentals: Parameters<typeof enterpriseV
|
|
|
126
126
|
return status === "differs" ? "provider" : status === "withdrawn" || enterpriseValueWithdrawn(fundamentals) ? "unavailable" : undefined;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Whether a company's overview names the gap between the provider's EV and market cap + debt - cash: past 10% of
|
|
131
|
+
* the computed figure. A smaller gap (a 4.87T EV beside 5T computed) is a data detail the
|
|
132
|
+
* valuation panes (RV, the reverse DCF) still give in full, not a warning to greet a first look at the company.
|
|
133
|
+
* Any other check (withdrawn, not meaningful) is always named: it is why a figure is missing.
|
|
134
|
+
*/
|
|
135
|
+
export function enterpriseValueGapIsLarge(fundamentals: Parameters<typeof enterpriseValueCheck>[0]): boolean {
|
|
136
|
+
const check = enterpriseValueCheck(fundamentals);
|
|
137
|
+
if (check?.status !== "differs" || !finiteNumber(check.source) || !finiteNumber(check.computed) || check.computed <= 0) return true;
|
|
138
|
+
return Math.abs(check.source / check.computed - 1) > OVERVIEW_ENTERPRISE_VALUE_GAP;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const OVERVIEW_ENTERPRISE_VALUE_GAP = 0.1;
|
|
142
|
+
|
|
129
143
|
/**
|
|
130
144
|
* The reconciliation line under a labelled, withdrawn or not meaningful EV: "EV 61.75B USD (provider) vs 63.75B
|
|
131
145
|
* computed from market cap + total debt - cash (balance sheet 2026-06-30).", "EV N/M: cash and short-term investments
|