@gloom-sh/terminal 0.20.18 → 0.20.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/api-client/cot.ts +5 -6
- package/src/api-client/data.ts +11 -1
- package/src/api-client/index.ts +1 -0
- package/src/api-client/request.ts +162 -40
- package/src/api-client/types/news.ts +45 -0
- package/src/api-client/types/world-venues.ts +9 -0
- package/src/app.tsx +4 -2
- package/src/architecture/floating-promise-allowlist.json +1 -1
- package/src/cli/commands/market.ts +53 -17
- package/src/cli/commands/ticker.ts +13 -6
- package/src/cli/context.ts +8 -0
- package/src/cli/desktop-pane-shot-browser.ts +3 -1
- package/src/cli/desktop-pane-shot-view.ts +0 -1
- package/src/cli/desktop-pane-shot.ts +204 -43
- package/src/cli/errors.ts +3 -9
- package/src/cli/exit-codes.ts +1 -1
- package/src/cli/glossary.ts +1 -1
- package/src/cli/help.ts +1 -1
- package/src/cli/history-rows.ts +2 -2
- package/src/cli/index.ts +1 -1
- package/src/cli/listing-arg.ts +87 -23
- package/src/cli/pane-functions/catalog-snapshot.json +17 -6
- package/src/cli/pane-functions/dom.ts +30 -2
- package/src/cli/pane-functions/freshness.ts +23 -4
- package/src/cli/pane-functions/function-help.ts +3 -3
- package/src/cli/pane-functions/headless.ts +9 -1
- package/src/cli/pane-functions/index.ts +77 -10
- package/src/cli/pane-functions/report-notices.ts +10 -0
- package/src/cli/pane-functions/resolver.ts +3 -2
- package/src/cli/pane-functions/screenshot-assessment.ts +10 -5
- package/src/cli/pane-functions/screenshot-data-evidence.ts +7 -15
- package/src/cli/pane-functions/screenshot-payload.ts +24 -10
- package/src/cli/pane-functions/screenshot-render.ts +21 -8
- package/src/cli/pane-functions/screenshot-types.ts +9 -0
- package/src/cli/quote-answer.ts +1 -1
- package/src/cli/result.ts +17 -0
- package/src/cli/scroll-truncation.ts +7 -2
- package/src/cli/ticker-resolution.ts +1 -1
- package/src/cli/unreachable.ts +21 -0
- package/src/components/chart/composite/drawing-store.ts +11 -7
- package/src/components/chart/composite/format.ts +1 -0
- package/src/components/chart/composite/legend.tsx +5 -2
- package/src/components/chart/composite/panel-surface/plot-gestures.ts +9 -2
- package/src/components/chart/composite/panel-surface.tsx +1 -1
- package/src/components/chart/composite/tools.ts +164 -39
- package/src/components/chart-table/header.tsx +2 -2
- package/src/components/chart-table/layout.ts +5 -6
- package/src/components/command-bar/routes/root/runtime.ts +11 -3
- package/src/components/command-bar/routes/ticker-search/results.ts +5 -0
- package/src/components/command-bar/selection-runtime.ts +29 -5
- package/src/components/command-bar/surface/index.tsx +4 -1
- package/src/components/command-bar/workflow/alert.ts +13 -5
- package/src/components/layout/pane/footer/model.ts +10 -2
- package/src/components/layout/pane/status-footer.ts +24 -0
- package/src/components/price-performance.tsx +26 -8
- package/src/components/reader/article-reader.tsx +12 -5
- package/src/components/ui/data-table/opentui/index.tsx +7 -0
- package/src/components/ui/table-layout.ts +32 -1
- package/src/market-data/ah-pair.ts +19 -0
- package/src/market-data/coordinator/entries.ts +6 -4
- package/src/market-data/coordinator/index.ts +14 -3
- package/src/market-data/futures-board.ts +36 -29
- package/src/market-data/futures-contract.ts +37 -1
- package/src/market-data/market/change-basis.ts +9 -0
- package/src/market-data/market/status.ts +40 -4
- package/src/market-data/performance.ts +127 -32
- package/src/market-data/quotes/time.ts +5 -2
- package/src/news/types.ts +28 -0
- package/src/notifications/app-badge.ts +2 -3
- package/src/notifications/app-notifier.ts +5 -0
- package/src/plugins/builtin/alerts/cli.ts +65 -18
- package/src/plugins/builtin/alerts/command.ts +39 -9
- package/src/plugins/builtin/alerts/event-rows.ts +9 -3
- package/src/plugins/builtin/alerts/events-pane.tsx +16 -10
- package/src/plugins/builtin/alerts/headless.ts +12 -6
- package/src/plugins/builtin/alerts/index.tsx +60 -8
- package/src/plugins/builtin/alerts/option-contract.ts +197 -0
- package/src/plugins/builtin/alerts/price.ts +30 -5
- package/src/plugins/builtin/alerts/pro-rules.ts +62 -0
- package/src/plugins/builtin/alerts/research-builder.ts +5 -10
- package/src/plugins/builtin/analytics/account-returns.ts +1 -1
- package/src/plugins/builtin/analytics/pane-model.ts +2 -2
- package/src/plugins/builtin/analytics/risk-client.ts +1 -1
- package/src/plugins/builtin/buildout/company/pane.tsx +4 -14
- package/src/plugins/builtin/catalysts/model.ts +2 -1
- package/src/plugins/builtin/chart-composer/chart-spec.ts +5 -0
- package/src/plugins/builtin/chart-composer/cli-options.ts +5 -3
- package/src/plugins/builtin/chart-composer/headless-schema.ts +14 -10
- package/src/plugins/builtin/chart-composer/headless.ts +2 -0
- package/src/plugins/builtin/chart-composer/index.tsx +17 -5
- package/src/plugins/builtin/chart-composer/pane.tsx +14 -4
- package/src/plugins/builtin/chart-composer/viewport-labels.ts +2 -17
- package/src/plugins/builtin/chat/controller/notifications.ts +1 -0
- package/src/plugins/builtin/chat/index.tsx +0 -1
- package/src/plugins/builtin/commodities-energy/index.tsx +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +1 -1
- package/src/plugins/builtin/company-kpis/model.ts +21 -9
- package/src/plugins/builtin/congress-trades/model.ts +9 -5
- package/src/plugins/builtin/cot/client.ts +2 -3
- package/src/plugins/builtin/cot/headless.ts +16 -16
- package/src/plugins/builtin/cot/index.tsx +6 -6
- package/src/plugins/builtin/cot/model.ts +25 -5
- package/src/plugins/builtin/cot/pane.tsx +11 -6
- package/src/plugins/builtin/cot/series.ts +11 -8
- package/src/plugins/builtin/cpi/model.ts +15 -4
- package/src/plugins/builtin/cpi/pane.tsx +29 -7
- package/src/plugins/builtin/doe/model.ts +30 -0
- package/src/plugins/builtin/doe/pane.tsx +8 -2
- package/src/plugins/builtin/earnings/board-table.ts +9 -4
- package/src/plugins/builtin/earnings/headless.ts +10 -3
- package/src/plugins/builtin/earnings/history-table.ts +4 -2
- package/src/plugins/builtin/earnings-calls/calendar.tsx +4 -3
- package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -2
- package/src/plugins/builtin/econ/index.tsx +4 -2
- package/src/plugins/builtin/futures/model.ts +14 -1
- package/src/plugins/builtin/futures/series.ts +1 -8
- package/src/plugins/builtin/fx-matrix/index.tsx +2 -2
- package/src/plugins/builtin/insider/detail.tsx +36 -7
- package/src/plugins/builtin/insider/filing-stories.ts +110 -0
- package/src/plugins/builtin/insider/headless.ts +37 -2
- package/src/plugins/builtin/insider/index.tsx +79 -10
- package/src/plugins/builtin/insider/model.ts +43 -5
- package/src/plugins/builtin/ipo-calendar/client.ts +11 -1
- package/src/plugins/builtin/ipo-calendar/model.ts +3 -7
- package/src/plugins/builtin/jobs/headless.ts +2 -1
- package/src/plugins/builtin/jobs/model.ts +6 -0
- package/src/plugins/builtin/jobs/pane.tsx +8 -3
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +118 -10
- package/src/plugins/builtin/news/wire/news/story-evidence.ts +178 -0
- package/src/plugins/builtin/options/analytics.ts +1 -1
- package/src/plugins/builtin/options/view.tsx +18 -11
- package/src/plugins/builtin/options-positioning/model.ts +11 -0
- package/src/plugins/builtin/options-positioning/pane.tsx +22 -1
- package/src/plugins/builtin/options-scenario/client.ts +49 -8
- package/src/plugins/builtin/options-scenario/headless.ts +7 -3
- package/src/plugins/builtin/options-scenario/model.ts +33 -2
- package/src/plugins/builtin/options-scenario/pane.tsx +3 -4
- package/src/plugins/builtin/perps/cascade.ts +4 -3
- package/src/plugins/builtin/perps/markets-section.tsx +5 -2
- package/src/plugins/builtin/perps/model.ts +4 -3
- package/src/plugins/builtin/portfolio-list/table.tsx +3 -2
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -14
- package/src/plugins/builtin/research/event-model.ts +12 -6
- package/src/plugins/builtin/research-search/index.tsx +3 -1
- package/src/plugins/builtin/scanner/denied.tsx +16 -4
- package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
- package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
- package/src/plugins/builtin/sec/filing-display.tsx +14 -2
- package/src/plugins/builtin/sec/headless.ts +42 -4
- package/src/plugins/builtin/sec/index.tsx +21 -1
- package/src/plugins/builtin/sectors/sector-model.ts +1 -1
- package/src/plugins/builtin/shared/earnings-report.ts +32 -3
- package/src/plugins/builtin/shared/options-pro-copy.ts +34 -0
- package/src/plugins/builtin/shared/statement-currency.ts +23 -0
- package/src/plugins/builtin/shared/ticker-surface.ts +1 -1
- package/src/plugins/builtin/supply-chain/pane.tsx +4 -3
- package/src/plugins/builtin/themes/headless.ts +4 -4
- package/src/plugins/builtin/themes/model.ts +11 -8
- package/src/plugins/builtin/themes/pane.tsx +2 -2
- package/src/plugins/builtin/ticker-detail/financials/model.ts +22 -32
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +7 -9
- package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -0
- package/src/plugins/builtin/ticker-detail/headless.ts +28 -12
- package/src/plugins/builtin/ticker-detail/overview/board-lot.ts +21 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +11 -1
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +61 -13
- package/src/plugins/builtin/volatility/pane.tsx +3 -3
- package/src/plugins/builtin/world-venue-map/headless.ts +4 -2
- package/src/plugins/builtin/world-venue-map/model.ts +6 -1
- package/src/plugins/builtin/world-venue-map/venue-header.tsx +5 -3
- package/src/plugins/catalog-browser.ts +10 -1
- package/src/renderers/browser/activity.ts +16 -0
- package/src/renderers/browser/app-badge-host.ts +14 -0
- package/src/renderers/browser/main.tsx +5 -0
- package/src/renderers/browser/notifications.ts +103 -0
- package/src/renderers/browser/ui-host.tsx +4 -0
- package/src/renderers/dom/data-table/index.tsx +27 -4
- package/src/renderers/electrobun/view/http-fetch.ts +3 -2
- package/src/sources/gloomberb-cloud/index.ts +8 -6
- package/src/sources/gloomberb-cloud/news.ts +35 -0
- package/src/sources/provider-errors.ts +34 -7
- package/src/sources/provider-router/history.ts +32 -6
- package/src/time-series/base-series.ts +39 -6
- package/src/time-series/chart-seed.ts +2 -2
- package/src/time-series/history-quality.ts +4 -1
- package/src/time-series/hooks.ts +2 -0
- package/src/time-series/price-comparison.ts +17 -23
- package/src/time-series/reporting.ts +1 -1
- package/src/time-series/resolution.ts +13 -0
- package/src/time-series/resolve-context.ts +6 -0
- package/src/time-series/resolve.ts +39 -2
- package/src/time-series/types.ts +2 -1
- package/src/types/financials.ts +9 -1
- package/src/types/headless.ts +1 -0
- package/src/types/issuer-listings.ts +2 -0
- package/src/types/plugin-notifications.ts +3 -0
- package/src/types/price-history.ts +6 -4
- package/src/ui/host.tsx +2 -0
- package/src/utils/exchange-announcements.ts +7 -2
- package/src/utils/fundamentals.ts +40 -0
- package/src/utils/network-failure.ts +2 -0
- package/src/utils/price-history-integrity.ts +9 -1
|
@@ -7,7 +7,7 @@ import { useShortcut } from "../../../react/input";
|
|
|
7
7
|
import { isPlainKey } from "../../../utils/keyboard";
|
|
8
8
|
import { logFailure } from "../../../utils/log-failure";
|
|
9
9
|
import { instrumentFromTicker } from "../../../market-data/request-types";
|
|
10
|
-
import { useDebouncedPluginPaneState, usePluginPaneState } from "../../runtime";
|
|
10
|
+
import { useDebouncedPluginPaneState, usePluginAppActions, usePluginPaneState } from "../../runtime";
|
|
11
11
|
import { usePaneSettingValue } from "../../../state/app/context";
|
|
12
12
|
import { Box, Text, useUiCapabilities, type ScrollBoxRenderable } from "../../../ui";
|
|
13
13
|
import { FILL_REST } from "../../../components/ui/fill";
|
|
@@ -27,6 +27,7 @@ import { fundAbroadProfile, venueAbroad, type FundAbroadProfile } from "./fund-a
|
|
|
27
27
|
import { listingAnnouncementsPage, type ExchangeAnnouncementsPage } from "../../../utils/exchange-announcements";
|
|
28
28
|
import { form4TradeText, isOtherIssuerForm4, pricingSupplementTest } from "../../../utils/sec-filings";
|
|
29
29
|
import { formatInsiderName } from "../insider/display";
|
|
30
|
+
import { filingStorySource, useFilingStories, type FilingStory } from "../insider/filing-stories";
|
|
30
31
|
import { parseForm4Xml } from "../insider/insider-data";
|
|
31
32
|
import { createTickerSurfacePaneTemplate } from "../shared/ticker-surface";
|
|
32
33
|
import {
|
|
@@ -176,6 +177,8 @@ function toFeedItems(
|
|
|
176
177
|
loadingDocuments: boolean,
|
|
177
178
|
documentsError: string | null,
|
|
178
179
|
contentErrors: Map<string, string>,
|
|
180
|
+
/** The stories that report the open filing, a Form 4, each a fact that opens it. */
|
|
181
|
+
openStories: { accession: string; stories: readonly FilingStory[]; open: (story: FilingStory) => void } | null = null,
|
|
179
182
|
): FeedDataTableItem[] {
|
|
180
183
|
// A Form 144 names its seller freely; the insider forms read beside it say which way round.
|
|
181
184
|
const knownOwners = filings.flatMap((filing) => ownerNames(filing.form, contentCache.get(filing.accessionNumber)));
|
|
@@ -231,6 +234,13 @@ function toFeedItems(
|
|
|
231
234
|
...(acceptedAt ? [{ label: "SEC-reported acceptance", value: acceptedAt }] : []),
|
|
232
235
|
...(items ? [{ label: "Items", value: items }] : []),
|
|
233
236
|
{ label: "Accession", value: filing.accessionNumber },
|
|
237
|
+
...(openStories?.accession === filing.accessionNumber
|
|
238
|
+
? openStories.stories.map((story) => ({
|
|
239
|
+
label: "Story",
|
|
240
|
+
value: `${story.headline} (${filingStorySource(story)})`,
|
|
241
|
+
link: { label: `Open story: ${story.headline}`, onOpen: () => openStories.open(story) },
|
|
242
|
+
}))
|
|
243
|
+
: []),
|
|
234
244
|
];
|
|
235
245
|
|
|
236
246
|
return {
|
|
@@ -383,6 +393,15 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
|
|
|
383
393
|
const openFiling = openItemId
|
|
384
394
|
? filings.find((filing) => filing.accessionNumber === openItemId) ?? null
|
|
385
395
|
: null;
|
|
396
|
+
// An open Form 4 names the stories that report it, each opening in a pane: back from the filing to the news.
|
|
397
|
+
const openInsiderAccession = openFiling && /^4(?:\/A)?$/i.test(openFiling.form.trim()) ? openFiling.accessionNumber : null;
|
|
398
|
+
const openFilingStories = useFilingStories(openInsiderAccession);
|
|
399
|
+
const { createPaneFromTemplate } = usePluginAppActions();
|
|
400
|
+
const storyLinks = useMemo(() => (openInsiderAccession && openFilingStories.length > 0 ? {
|
|
401
|
+
accession: openInsiderAccession,
|
|
402
|
+
stories: openFilingStories,
|
|
403
|
+
open: (story: FilingStory) => createPaneFromTemplate("news-story-pane", { arg: story.id, values: { title: story.headline } }),
|
|
404
|
+
} : null), [createPaneFromTemplate, openFilingStories, openInsiderAccession]);
|
|
386
405
|
const documentsEntry = useSecFilingDocuments(openFiling ?? null);
|
|
387
406
|
const openDocuments = useResolvedEntryValue(documentsEntry) ?? [];
|
|
388
407
|
const documentsError = documentsEntry?.error && documentsEntry.error.reasonCode !== "NO_DATA" ? documentsEntry.error.message : null;
|
|
@@ -626,6 +645,7 @@ function SecView({ width, height, focused, paneType }: { width: number; height:
|
|
|
626
645
|
loadingDocuments,
|
|
627
646
|
documentsError,
|
|
628
647
|
contentErrors,
|
|
648
|
+
storyLinks,
|
|
629
649
|
)}
|
|
630
650
|
selectedIdx={selectedIdx}
|
|
631
651
|
onSelect={setSelectedIdx}
|
|
@@ -328,7 +328,7 @@ export function sectorRowIssues(row: SectorRow): string[] {
|
|
|
328
328
|
if (row.quoteIssue) issues.push(row.quoteIssue);
|
|
329
329
|
else if (row.quoteUnavailable) issues.push("quote unavailable");
|
|
330
330
|
for (const range of ["1M", "1Y"] as const) {
|
|
331
|
-
if (row.returnIntegrity?.[range]) issues.push(`${range}:
|
|
331
|
+
if (row.returnIntegrity?.[range]) issues.push(`${range}: contradictory prices at the return's start or end`);
|
|
332
332
|
else if (row[range === "1M" ? "return1M" : "return1Y"] == null) issues.push(`${range}: history does not cover the shared window`);
|
|
333
333
|
}
|
|
334
334
|
return issues;
|
|
@@ -53,6 +53,34 @@ export function isProvisionalActual(row: { epsActual?: number | null; epsActualS
|
|
|
53
53
|
*/
|
|
54
54
|
export const NO_CONSENSUS = "no consensus";
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
* A report that is out with no actual yet (the calendar fills it the next
|
|
58
|
+
* day, a press release only when it proves the figure) says so where its
|
|
59
|
+
* actual would be, one word everywhere: ERN, the board, EE's detail. A
|
|
60
|
+
* listing abroad's figures come from its own results documents, with Gloom
|
|
61
|
+
* Pro only, so its row without one is not waiting on anything: it keeps its
|
|
62
|
+
* dash.
|
|
63
|
+
*/
|
|
64
|
+
export const ACTUAL_PENDING = "pending";
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Gloom Cloud reads a report's date from the calendar for a week after it, so
|
|
68
|
+
* an actual is pending only that long: an older report with none (a 2023
|
|
69
|
+
* report known only from its results filing) has none coming, and keeps its
|
|
70
|
+
* dash.
|
|
71
|
+
*/
|
|
72
|
+
const PENDING_DAYS = 7;
|
|
73
|
+
|
|
74
|
+
export function actualPending(
|
|
75
|
+
row: { date?: string | null; epsActual?: number | null; dateStatus?: string | null },
|
|
76
|
+
abroad = false,
|
|
77
|
+
now = Date.now(),
|
|
78
|
+
): boolean {
|
|
79
|
+
if (abroad || row.epsActual != null || row.dateStatus !== "reported") return false;
|
|
80
|
+
const date = Date.parse(`${String(row.date ?? "").slice(0, 10)}T00:00:00Z`);
|
|
81
|
+
return !Number.isFinite(date) || now - date <= (PENDING_DAYS + 1) * 86_400_000;
|
|
82
|
+
}
|
|
83
|
+
|
|
56
84
|
/** NO_CONSENSUS where a column is narrow. */
|
|
57
85
|
export const NO_CONSENSUS_SHORT = "no est";
|
|
58
86
|
|
|
@@ -82,13 +110,14 @@ type EarningsRecord = CorporateActionsData["earnings"][number];
|
|
|
82
110
|
/**
|
|
83
111
|
* What follows an earnings row's EPS, one phrase per part. A reported row
|
|
84
112
|
* names its basis, whether the figure is provisional, and its beat, or that
|
|
85
|
-
* no consensus is on record for it;
|
|
86
|
-
*
|
|
113
|
+
* no consensus is on record for it; one out with no actual yet that it is
|
|
114
|
+
* pending; one still to come whether its date is announced; and both their
|
|
115
|
+
* analysts and an adjusted estimate's basis.
|
|
87
116
|
*/
|
|
88
117
|
export function earningsDetailParts(earning: EarningsRecord): string[] {
|
|
89
118
|
if (earning.epsActual == null) {
|
|
90
119
|
const status = earningsDateStatus(earning.dateStatus);
|
|
91
|
-
return [status === "reported" ? null : status, earning.epsAnalysts != null ? `${earning.epsAnalysts} analysts` : null,
|
|
120
|
+
return [status === "reported" ? (actualPending(earning) ? ACTUAL_PENDING : null) : status, earning.epsAnalysts != null ? `${earning.epsAnalysts} analysts` : null,
|
|
92
121
|
earningsEpsBasis(earning.epsBasis) === "adjusted" ? BASIS_TEXT.adjusted : null].filter((part): part is string => !!part);
|
|
93
122
|
}
|
|
94
123
|
return [BASIS_TEXT[epsBasisName(earningsEpsBasis(earning.epsBasis))], isProvisionalActual(earning) ? "provisional" : null,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// The words every surface uses for the options features that need Pro
|
|
2
|
+
// (options flow, an IV spike alert) and what a free account has instead:
|
|
3
|
+
// the FLOW walls, Add Event Alert, ALRT's Events tab, `fn ALRT`, and
|
|
4
|
+
// `alerts add` and `alerts list`. Short on purpose, and kept here so they
|
|
5
|
+
// read the same everywhere.
|
|
6
|
+
|
|
7
|
+
/** What a free account has instead of options flow. */
|
|
8
|
+
export const FLOW_FREE = "Free: OMON chain, price and move alerts.";
|
|
9
|
+
|
|
10
|
+
/** What a free account has instead of an IV spike alert: the IV level alert the app checks comes first. */
|
|
11
|
+
const IV_SPIKE_FREE = "Free: IV level alerts, OMON chain, price and move alerts.";
|
|
12
|
+
|
|
13
|
+
/** The FLOW wall's line for a signed-out reader: options flow is Pro, and what is free. */
|
|
14
|
+
export const FLOW_PRO_NOTE = `Options flow is Pro. ${FLOW_FREE}`;
|
|
15
|
+
|
|
16
|
+
/** What is free instead of a Pro alert of `kind`; an IV spike's list leads with IV level alerts. */
|
|
17
|
+
export function proAlertFree(kind: string): string {
|
|
18
|
+
return kind === "iv_spike" ? IV_SPIKE_FREE : FLOW_FREE;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** What is free instead of any of `kinds`: the IV spike list when one of them is an IV spike, which covers flow's too. */
|
|
22
|
+
export function proAlertsFree(kinds: readonly string[]): string {
|
|
23
|
+
return kinds.includes("iv_spike") ? IV_SPIKE_FREE : FLOW_FREE;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Add Event Alert's line under a Pro kind's first field. */
|
|
27
|
+
export function proAlertFormNote(kind: string): string {
|
|
28
|
+
return `Pro: saved now, checked only with Pro. ${proAlertFree(kind)}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** What `alerts add` and the saved toast say after a Pro alert saved without Pro. */
|
|
32
|
+
export function proAlertSavedNote(kind: string): string {
|
|
33
|
+
return `Checked only with Pro. ${proAlertFree(kind)}`;
|
|
34
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HeadlessPaneContext, HeadlessPaneOptionDef } from "../../../types/headless";
|
|
2
|
+
import { conversionNote, convertMarketCaps, loadFxLegs, normalizeCapCurrency } from "../research/relative-valuation-currency";
|
|
3
|
+
|
|
4
|
+
export const STATEMENT_CURRENCY_OPTION: HeadlessPaneOptionDef = {
|
|
5
|
+
key: "currency", type: "string", placeholder: "code", normalize: normalizeCapCurrency,
|
|
6
|
+
description: "Convert reported money at the app's FX rates, naming each rate and time and keeping the native figures.",
|
|
7
|
+
example: "--currency SGD",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export async function loadStatementCurrency(target: string, nativeCurrencies: readonly string[], context: Pick<HeadlessPaneContext, "marketData">) {
|
|
11
|
+
const currencies = [...new Set(nativeCurrencies)];
|
|
12
|
+
const { legs } = await loadFxLegs(currencies.some((currency) => currency !== target) ? [target, ...currencies] : [], context);
|
|
13
|
+
const { rows, conversions, unconverted } = convertMarketCaps(currencies.map((currency) => ({
|
|
14
|
+
symbol: currency, marketCap: 1, marketCapCurrency: currency,
|
|
15
|
+
})), target, legs);
|
|
16
|
+
return {
|
|
17
|
+
rates: new Map(rows.filter((row) => row.marketCapCurrency === target).map((row) => [row.symbol, row.marketCap!])),
|
|
18
|
+
conversions,
|
|
19
|
+
note: conversionNote(target, conversions, `Statements in ${target}`),
|
|
20
|
+
rateNotes: conversions.flatMap((conversion) => conversionNote(target, [conversion], `Statements in ${target}`) ?? []),
|
|
21
|
+
failures: unconverted.map(({ currency }) => `No ${currency}/${target} rate; ${currency} figures are not converted.`),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -28,7 +28,7 @@ export interface TickerSurfacePaneTemplateOptions {
|
|
|
28
28
|
symbol: string,
|
|
29
29
|
context: PaneTemplateContext,
|
|
30
30
|
options: PaneTemplateCreateOptions | undefined,
|
|
31
|
-
) => Record<string, unknown
|
|
31
|
+
) => Record<string, unknown> | undefined;
|
|
32
32
|
canCreate?: (
|
|
33
33
|
context: PaneTemplateContext,
|
|
34
34
|
options: PaneTemplateCreateOptions | undefined,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { staticSeries } from "../../../components/chart/static/series";
|
|
12
12
|
import { ClippedText } from "../../../components/ui/display";
|
|
13
13
|
import { RatioBar } from "../../../components/ui/ratio-bar";
|
|
14
|
-
import { getTableWidth } from "../../../components/ui/table-layout";
|
|
14
|
+
import { getTableWidth, hiddenTableColumnRows, markHiddenTableColumns } from "../../../components/ui/table-layout";
|
|
15
15
|
import { chromeBarRows } from "../../../components/layout/pane/sizing";
|
|
16
16
|
import { usePaneRefreshKey } from "../../../components/data-table/table-pane";
|
|
17
17
|
import { useAsyncResource, useAutoRefresh, usePaneSettingValue, usePluginAppActions, usePluginPaneState } from "../../../public/react";
|
|
@@ -121,6 +121,7 @@ export function tableColumns(width: number, desktop: boolean, locked: boolean, v
|
|
|
121
121
|
];
|
|
122
122
|
const preferred = { share: share.width, name: name.width };
|
|
123
123
|
// The table ignores its last trailing gutter when deciding whether it fits.
|
|
124
|
+
const original = columns;
|
|
124
125
|
const overflow = () => getTableWidth(columns) - width - 1;
|
|
125
126
|
// Native units keep their column before the share keeps its bar or its whole wording.
|
|
126
127
|
const withBar = SHARE_BAR_MIN_CELLS + 1;
|
|
@@ -154,7 +155,7 @@ export function tableColumns(width: number, desktop: boolean, locked: boolean, v
|
|
|
154
155
|
if (overflow() > 0 && shares) fit(plain + bare);
|
|
155
156
|
if (overflow() > 0) fit(shares ? plain + bare : SHARE_FIGURE_CELLS + 2, 12);
|
|
156
157
|
if (overflow() > 0 && shares) fit(plain + SHARE_BASIS_LAST_CELLS, 12);
|
|
157
|
-
return columns;
|
|
158
|
+
return markHiddenTableColumns(original, columns);
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
/**
|
|
@@ -398,7 +399,7 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
|
|
|
398
399
|
: <Box flexDirection="column" flexShrink={0}>{query}<StatGrid items={figures} width={width} /></Box>;
|
|
399
400
|
// The rows the table leaves free under its last row: the query bar, the figures, the column header and the rows,
|
|
400
401
|
// and a scrollbar row a wide table may draw.
|
|
401
|
-
const spareRows = bodyHeight - 1 - statGridRows(figures, width) - 1 - items.length - 1;
|
|
402
|
+
const spareRows = bodyHeight - 1 - statGridRows(figures, width) - 1 - hiddenTableColumnRows(columns, items.length) - items.length - 1;
|
|
402
403
|
const disclosureBand = tab === "table" && !concentrationChart && !openRow && selected && spareRows >= DISCLOSURE_BAND_MIN_ROWS
|
|
403
404
|
? <SelectedDisclosure row={selected} width={width} height={spareRows} /> : null;
|
|
404
405
|
const flowFigureColumns = Math.min(Math.max(1, figures.length), Math.max(1, Math.floor(width / 24)));
|
|
@@ -6,7 +6,7 @@ import { formatRelativeAge } from "../../../utils/datetime-format";
|
|
|
6
6
|
import { fetchThemeMembers, fetchThemes } from "./client";
|
|
7
7
|
import {
|
|
8
8
|
aggregateText, boardClose, boardYtdBase, DEFAULT_SORT, matchTheme, memberExtended, memberExtendedSessions, memberPrice, percent, periodLabel,
|
|
9
|
-
isLiveBoard, SNAPSHOT_STALE_MS, sortMembers, sortThemes,
|
|
9
|
+
isLiveBoard, SNAPSHOT_STALE_MS, sortMembers, sortThemes, THEME_LISTING_SCOPE,
|
|
10
10
|
} from "./model";
|
|
11
11
|
|
|
12
12
|
/** The period columns; YTD names the close it is measured from, `YTD vs 31 Dec close`. */
|
|
@@ -71,10 +71,10 @@ function boardObservation(payload: ThemesPayload | ThemeMembersPayload, now = Da
|
|
|
71
71
|
*/
|
|
72
72
|
function themeReportTitle(query: string | undefined, theme: Pick<ThemeSummary, "id" | "name"> | undefined): string {
|
|
73
73
|
const typed = query?.trim();
|
|
74
|
-
if (!typed) return
|
|
75
|
-
if (!theme) return `Thematic baskets | ${typed}`;
|
|
74
|
+
if (!typed) return `Thematic baskets · ${THEME_LISTING_SCOPE}`;
|
|
75
|
+
if (!theme) return `Thematic baskets · ${THEME_LISTING_SCOPE} | ${typed}`;
|
|
76
76
|
const named = [theme.id, theme.name].some((label) => label.toLowerCase() === typed.toLowerCase());
|
|
77
|
-
return `Thematic baskets | ${theme.name}${named ? "" : ` (matched ${typed})`}`;
|
|
77
|
+
return `Thematic baskets · ${THEME_LISTING_SCOPE} | ${theme.name}${named ? "" : ` (matched ${typed})`}`;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export const themesHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MISSING_VALUE } from "../../../utils/format";
|
|
2
2
|
import { THEME_PERIODS, type ThemeAggregate, type ThemeMember, type ThemePeriod, type ThemeSummary } from "../../../api-client/themes";
|
|
3
3
|
import type { DataTableColumn } from "../../../components";
|
|
4
|
-
import { dropColumnsToFit, getTableWidth } from "../../../components/ui/table-layout";
|
|
4
|
+
import { dropColumnsToFit, getTableWidth, TABLE_COLUMN_GAP } from "../../../components/ui/table-layout";
|
|
5
5
|
import { extendedSessionStateLabel, type ExtendedSession } from "../../../market-data/market/status";
|
|
6
6
|
import { yearToDateBaseLabel } from "../../../market-data/market/year-to-date";
|
|
7
7
|
import { compareSortValues, type SortDirection } from "../../../utils/sort-values";
|
|
@@ -148,6 +148,7 @@ export function matchTheme(rows: readonly ThemeSummary[], input: string): ThemeS
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
const column = (id: string, label: string, width: number, align: "left" | "right" = "right"): DataTableColumn => ({ id, label, width, align });
|
|
151
|
+
export const THEME_LISTING_SCOPE = "US-listed";
|
|
151
152
|
/** Room a header has in its column: the sort indicator takes two cells. */
|
|
152
153
|
const HEADER_ROOM = 2;
|
|
153
154
|
/**
|
|
@@ -163,7 +164,7 @@ export function themeColumns(width: number, rows: readonly ThemeSummary[], ytdBa
|
|
|
163
164
|
const label = (period: ThemePeriod, room: number) => periodLabel(period, ytdBase, room) + " ".repeat(suffixWidth(period));
|
|
164
165
|
// The board always keeps room for `YTD vs 31 Dec`, so even a narrow one says what its YTD is measured against.
|
|
165
166
|
const leastRoom = ytdBase ? `YTD vs ${ytdBase}`.length : 0;
|
|
166
|
-
const columns = [column("name",
|
|
167
|
+
const columns = [column("name", `Theme · ${THEME_LISTING_SCOPE}`, 26, "left"), column("memberCount", "N", 3),
|
|
167
168
|
...THEME_PERIODS.map((period) => column(period, label(period, leastRoom), Math.max(metricWidth(period), label(period, leastRoom).length + HEADER_ROOM))),
|
|
168
169
|
column("breadth", "Breadth" + " ".repeat(coverageWidth(rows.map((row) => row.breadth))), 7 + coverageWidth(rows.map((row) => row.breadth))),
|
|
169
170
|
column("best", "Best 1D", 15), column("worst", "Worst 1D", 15)];
|
|
@@ -175,15 +176,17 @@ export function themeColumns(width: number, rows: readonly ThemeSummary[], ytdBa
|
|
|
175
176
|
/**
|
|
176
177
|
* The member table at `width`. Price and 1D are the regular session's; a
|
|
177
178
|
* PRE-MKT or AFTER-HRS column, named as BI and MOST name it, follows 1D for
|
|
178
|
-
* each session in `extendedSessions`.
|
|
179
|
-
*
|
|
179
|
+
* each session in `extendedSessions`. Longer windows give way first, then
|
|
180
|
+
* extended sessions; the name shortens when the daily columns need the room.
|
|
180
181
|
*/
|
|
181
182
|
export function memberColumns(width: number, extendedSessions: readonly ExtendedSession[] = [], ytdBase: string | null = null): DataTableColumn[] {
|
|
182
183
|
const extended = extendedSessions.map((session) => column(session === "PRE" ? "preMarket" : "afterHours", extendedSessionStateLabel(session), 9));
|
|
183
184
|
const [day, ...windows] = THEME_PERIODS.map((period) => column(period, periodLabel(period, ytdBase, 0), Math.max(9, periodLabel(period, ytdBase, 0).length + HEADER_ROOM)));
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
const symbol = column("symbol", "Ticker", 7, "left");
|
|
186
|
+
const price = column("price", "Price $", 10);
|
|
187
|
+
const nameWidth = Math.max(8, Math.min(24, width - getTableWidth([symbol, price, day!]) - TABLE_COLUMN_GAP));
|
|
188
|
+
const fitted = fitColumns([symbol, column("name", "Name", nameWidth, "left"), price, day!, ...extended, ...windows], width,
|
|
189
|
+
["return3MPercent", "returnYtdPercent", "return1MPercent", "return1WPercent", "preMarket", "afterHours"]);
|
|
187
190
|
const ytd = fitted.find((col) => col.id === "returnYtdPercent");
|
|
188
191
|
if (ytd) ytd.label = periodLabel("returnYtdPercent", ytdBase, ytd.width - HEADER_ROOM);
|
|
189
192
|
return fitted;
|
|
@@ -193,7 +196,7 @@ function fitColumns(columns: DataTableColumn[], width: number, drop: string[]):
|
|
|
193
196
|
const used = () => getTableWidth(columns);
|
|
194
197
|
const name = columns.find((col) => col.id === "name") ?? columns[0]!;
|
|
195
198
|
const spare = width - used();
|
|
196
|
-
name.width
|
|
199
|
+
name.width += Math.min(Math.max(0, spare), Math.max(0, 36 - name.width));
|
|
197
200
|
name.flexGrow = 1;
|
|
198
201
|
// Wide boards share room across the figures instead of separating every name
|
|
199
202
|
// from its daily move with an almost pane-wide blank name column.
|
|
@@ -14,7 +14,7 @@ import { useMembersMenu } from "../shared/members-menu";
|
|
|
14
14
|
import { cachedMembers, cachedThemes, loadMembers, loadThemes } from "./client";
|
|
15
15
|
import {
|
|
16
16
|
aggregateText, boardYtdBase, coverageText, coverageWidth, DEFAULT_SORT, extendedMove, matchTheme, memberColumns, memberExtendedSessions, memberPrice, percent,
|
|
17
|
-
isLiveBoard, LIVE_BOARD_REFRESH_MS, SNAPSHOT_STALE_MS, snapshotFooterText, sortMembers, sortThemes, themeColumns, type ThemeSort,
|
|
17
|
+
isLiveBoard, LIVE_BOARD_REFRESH_MS, SNAPSHOT_STALE_MS, snapshotFooterText, sortMembers, sortThemes, themeColumns, THEME_LISTING_SCOPE, type ThemeSort,
|
|
18
18
|
} from "./model";
|
|
19
19
|
|
|
20
20
|
const LIVE_LEAD = "live · ";
|
|
@@ -155,7 +155,7 @@ export function ThemesBoard({ width, height, focused, tabStrip, tabRows = 0 }: T
|
|
|
155
155
|
{data ? <DataTableStackView<ThemeSummary> columns={columns} items={rows} rootWidth={width} rootHeight={bodyHeight} focused={focused}
|
|
156
156
|
selection={{ kind: "id", selectedId: selected, getId: (row) => row.id, onChange: setSelected }}
|
|
157
157
|
getItemKey={(row) => row.id} onActivate={(row) => setOpened(row.id)}
|
|
158
|
-
detailOpen={!!opened} onBack={() => setOpened("")} detailTitle={theme
|
|
158
|
+
detailOpen={!!opened} onBack={() => setOpened("")} detailTitle={theme ? `${theme.name} · ${THEME_LISTING_SCOPE}` : opened}
|
|
159
159
|
detailContent={theme ? <Members key={theme.id} id={theme.id} width={width} height={Math.max(1, bodyHeight - 1)} focused={focused} />
|
|
160
160
|
: <PaneStatusBody subject="theme" error="No matching theme. Return to the list to choose a basket." />}
|
|
161
161
|
renderCell={renderCell} sortColumnId={sort.columnId} sortDirection={sort.direction}
|
|
@@ -131,8 +131,8 @@ const FINANCIAL_LABEL_MIN_W = 12;
|
|
|
131
131
|
* once showed nothing but metric names and "more →". The other 6 cells are the
|
|
132
132
|
* pane's padding, the table's, the column gap and the scrollbar.
|
|
133
133
|
*/
|
|
134
|
-
export function financialLabelWidth(width: number): number {
|
|
135
|
-
return Math.max(FINANCIAL_LABEL_MIN_W, Math.min(FINANCIAL_LABEL_W, width -
|
|
134
|
+
export function financialLabelWidth(width: number, periodWidth = FINANCIAL_COL_W): number {
|
|
135
|
+
return Math.max(FINANCIAL_LABEL_MIN_W, Math.min(FINANCIAL_LABEL_W, width - periodWidth - 6));
|
|
136
136
|
}
|
|
137
137
|
/** The growth after a period's value: a blank and up to six characters (`+466%`, `<-99T%`). */
|
|
138
138
|
const FINANCIAL_GROWTH_W = 7;
|
|
@@ -298,19 +298,6 @@ export function formatFinancialAmount(value: number, divisor: number): string {
|
|
|
298
298
|
return Number(scaled.toPrecision(2)).toString();
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
/**
|
|
302
|
-
* A statement column's header for reports. The compact form is the period as
|
|
303
|
-
* the pane prints it without a fiscal calendar: `TTM`, or the period end date
|
|
304
|
-
* the query bar shows as of. Table columns use `financialColumnLabel`.
|
|
305
|
-
*/
|
|
306
|
-
export function formatFinancialHeader(date: string, currency?: string, dateSource?: FinancialStatement["dateSource"], compact = false, periodEnd?: string): string {
|
|
307
|
-
if (compact) return date === "TTM" ? "TTM" : date.slice(0, 10);
|
|
308
|
-
const period = date === "TTM" ? (periodEnd ? `TTM ${periodEnd}` : "TTM") : date.slice(0, 10);
|
|
309
|
-
const label = currency ? `${period} ${currency}` : period;
|
|
310
|
-
if (date === "TTM") return label;
|
|
311
|
-
return `${label} ${dateSource === "sec" ? "(SEC date)" : "(provider date)"}`;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
301
|
/**
|
|
315
302
|
* A report column's header (`gloom fn FA`): the fiscal period as the pane's
|
|
316
303
|
* column names it and the day it ends (`FY2026 2026-09-30 USD bn (SEC
|
|
@@ -329,26 +316,17 @@ export function financialReportHeader(
|
|
|
329
316
|
yearEndMonth: number | null,
|
|
330
317
|
rows: readonly FinancialStatement[] = [],
|
|
331
318
|
): string {
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (date === "TTM") {
|
|
336
|
-
const end = statement.aggregation?.periodEnd;
|
|
337
|
-
const period = end ? named(financialColumnLabel(statement, kind, yearEndMonth), end) : "TTM";
|
|
338
|
-
return currency ? `${period} ${currency}` : period;
|
|
339
|
-
}
|
|
340
|
-
const end = date.slice(0, 10);
|
|
341
|
-
const months = kind === "quarterly" ? statementPeriodMonths(statement) : undefined;
|
|
342
|
-
const longer = months && months > 3 ? longerPeriodLabel(end, months, yearEndMonth) : null;
|
|
343
|
-
const period = named(longer ?? financialColumnLabel(statement, kind, yearEndMonth), end);
|
|
319
|
+
const period = financialFiscalHeader(statement, kind, yearEndMonth);
|
|
320
|
+
const header = currency ? `${period} ${currency}` : period;
|
|
321
|
+
if (statement.date === "TTM") return header;
|
|
344
322
|
const filled = statement.filledFrom?.source === "results" ? fillDate(statement, rows) : null;
|
|
345
|
-
const source = filled ? fillDateText(filled) : dateSource === "sec" ? "SEC date" : "provider date";
|
|
346
|
-
return `${
|
|
323
|
+
const source = filled ? fillDateText(filled) : statement.dateSource === "sec" ? "SEC date" : "provider date";
|
|
324
|
+
return `${header} (${source})`;
|
|
347
325
|
}
|
|
348
326
|
|
|
349
327
|
/**
|
|
350
|
-
*
|
|
351
|
-
*
|
|
328
|
+
* The fiscal period, with a half in the quarterly list named as a half
|
|
329
|
+
* (`H1 FY26`), and `TTM` with the quarter or half it runs to.
|
|
352
330
|
*/
|
|
353
331
|
export function financialColumnLabel(
|
|
354
332
|
statement: FinancialTableStatement,
|
|
@@ -360,7 +338,19 @@ export function financialColumnLabel(
|
|
|
360
338
|
return ttmPeriodLabel(periodEnd, yearEndMonth, interimMonths);
|
|
361
339
|
}
|
|
362
340
|
|
|
363
|
-
|
|
341
|
+
export function financialFiscalHeader(statement: FinancialTableStatement, kind: FinancialPeriod, yearEndMonth: number | null): string {
|
|
342
|
+
const end = statement.date === "TTM" ? statement.aggregation?.periodEnd : statement.date.slice(0, 10);
|
|
343
|
+
const months = kind === "quarterly" && statement.date !== "TTM" ? statementPeriodMonths(statement) : undefined;
|
|
344
|
+
const longer = end && months && months > 3 ? longerPeriodLabel(end, months, yearEndMonth) : null;
|
|
345
|
+
const name = longer ?? financialColumnLabel(statement, kind, yearEndMonth);
|
|
346
|
+
return end && !name.endsWith(end) ? `${name} ${end}` : name;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** An annual balance sheet can lead with a newer interim position. */
|
|
350
|
+
export function financialColumnPeriod(statement: FinancialTableStatement, period: FinancialPeriod, annualDates: ReadonlySet<string>): FinancialPeriod {
|
|
351
|
+
return period === "annual" && (statement.date === "TTM" || annualDates.has(statement.date)) ? "annual" : "quarterly";
|
|
352
|
+
}
|
|
353
|
+
|
|
364
354
|
export function latestFinancialPeriodEnd(statements: readonly FinancialTableStatement[]): string | undefined {
|
|
365
355
|
return statements
|
|
366
356
|
.map((statement) => statement.date === "TTM" ? statement.aggregation?.periodEnd : statement.date.slice(0, 10))
|
|
@@ -28,7 +28,8 @@ import {
|
|
|
28
28
|
collectDefaultCollapsedGroupIds,
|
|
29
29
|
collectGroupIds,
|
|
30
30
|
financialCellParts,
|
|
31
|
-
|
|
31
|
+
financialColumnPeriod,
|
|
32
|
+
financialFiscalHeader,
|
|
32
33
|
formatFinancialCell,
|
|
33
34
|
formatFinancialCellValue,
|
|
34
35
|
financialStatementCurrency,
|
|
@@ -111,7 +112,7 @@ function financialColumnHeader(
|
|
|
111
112
|
yearEndMonth: number | null,
|
|
112
113
|
sharedCurrency: string | undefined,
|
|
113
114
|
): string {
|
|
114
|
-
const header =
|
|
115
|
+
const header = financialFiscalHeader(statement, kind, yearEndMonth);
|
|
115
116
|
return !sharedCurrency && statement.currency ? `${header} ${statement.currency}` : header;
|
|
116
117
|
}
|
|
117
118
|
|
|
@@ -350,15 +351,15 @@ export function ResolvedFinancialsTab({
|
|
|
350
351
|
// The annual balance sheet leads with a newer quarter-end position.
|
|
351
352
|
const periodHeaders = useMemo(() => displayStatements.map((statement) => financialColumnHeader(
|
|
352
353
|
statement,
|
|
353
|
-
|
|
354
|
+
financialColumnPeriod(statement, resolvedPeriod, annualDates),
|
|
354
355
|
yearEndMonth,
|
|
355
356
|
comparisonCurrency,
|
|
356
|
-
)), [annualDates, comparisonCurrency, displayStatements,
|
|
357
|
+
)), [annualDates, comparisonCurrency, displayStatements, resolvedPeriod, yearEndMonth]);
|
|
357
358
|
// In the terminal a period is as wide as its widest value and growth, so each pair sits as far from the next
|
|
358
359
|
// as from its own growth and more periods fit. The ratio tabs keep the statement columns' width. Every line of
|
|
359
360
|
// the statement counts, a collapsed group's too, so opening or closing one leaves the periods where they are.
|
|
360
361
|
const periodWidth = useMemo(() => {
|
|
361
|
-
if (nativePaneChrome || ratioTab) return FINANCIAL_COL_W;
|
|
362
|
+
if (nativePaneChrome || ratioTab) return Math.max(FINANCIAL_COL_W, financialPeriodWidth([], periodHeaders));
|
|
362
363
|
const everyRow = shareFinancialUnit(buildFinancialRows(subTab.rows, displayStatements, NO_COLLAPSED_GROUPS)).rows;
|
|
363
364
|
const values = [...everyRow, ...rows].flatMap((row) => displayStatements.map((statement) => (
|
|
364
365
|
formatFinancialCellValue(row, statement)
|
|
@@ -370,7 +371,7 @@ export function ResolvedFinancialsTab({
|
|
|
370
371
|
id: "metric",
|
|
371
372
|
kind: "metric",
|
|
372
373
|
label: metricHeader,
|
|
373
|
-
width: financialLabelWidth(width),
|
|
374
|
+
width: financialLabelWidth(width, periodWidth),
|
|
374
375
|
align: "left",
|
|
375
376
|
},
|
|
376
377
|
...displayStatements.map((statement, index): FinancialTableColumn => ({
|
|
@@ -525,8 +526,6 @@ export function ResolvedFinancialsTab({
|
|
|
525
526
|
);
|
|
526
527
|
}
|
|
527
528
|
|
|
528
|
-
const asOf = periodEnd ? `as of ${periodEnd}` : undefined;
|
|
529
|
-
// The as-of is the bar's own segment, which keeps its place when the pane is narrow; the context after it gives way.
|
|
530
529
|
const queryBar = (meta: string) => (
|
|
531
530
|
<QueryBar
|
|
532
531
|
width={Math.max(1, width - 2)}
|
|
@@ -553,7 +552,6 @@ export function ResolvedFinancialsTab({
|
|
|
553
552
|
],
|
|
554
553
|
onChange: (value: string) => setPeriod(value as FinancialPeriod),
|
|
555
554
|
}}
|
|
556
|
-
asOf={asOf}
|
|
557
555
|
meta={meta || undefined}
|
|
558
556
|
/>
|
|
559
557
|
);
|
|
@@ -6,6 +6,7 @@ import { RETURN_INTERVAL_VALUES, RETURN_RANGES } from "./data-panes/returns-mode
|
|
|
6
6
|
import { PRICE_WINDOW_FROM_HELP, PRICE_WINDOW_TO_HELP } from "../../../utils/price-window";
|
|
7
7
|
import type { HeadlessPaneOptionDef } from "../../../types/headless";
|
|
8
8
|
import { QUOTE_MONITOR_MAX_TICKERS } from "../../../tickers/list";
|
|
9
|
+
import { STATEMENT_CURRENCY_OPTION } from "../shared/statement-currency";
|
|
9
10
|
|
|
10
11
|
/** The most tickers one FA report reads: each is a full statements load. */
|
|
11
12
|
const FINANCIAL_REPORT_MAX_TICKERS = 10;
|
|
@@ -30,6 +31,7 @@ export const paneSchemas = {
|
|
|
30
31
|
},
|
|
31
32
|
options: [
|
|
32
33
|
FINANCIAL_PERIOD_OPTION,
|
|
34
|
+
{ ...STATEMENT_CURRENCY_OPTION, shot: { reportOnly: "compares converted statement rows; GF charts converted figures" } },
|
|
33
35
|
{
|
|
34
36
|
key: "statement",
|
|
35
37
|
description: "Statement or ratio tab to display.",
|
|
@@ -30,6 +30,7 @@ import { latestBalanceSheetDate, loadOfferingNote } from "./financials/offerings
|
|
|
30
30
|
import { formatRunwayMonths, reportsShortTermTotal, runwayMethod } from "../../../utils/cash-runway";
|
|
31
31
|
import { formatPerShareNumber } from "../../../utils/reported-money";
|
|
32
32
|
import { logFailure } from "../../../utils/log-failure";
|
|
33
|
+
import { loadStatementCurrency } from "../shared/statement-currency";
|
|
33
34
|
import {
|
|
34
35
|
RATIO_GAP_TEXT,
|
|
35
36
|
findRatioTab,
|
|
@@ -126,10 +127,10 @@ export const financialStatementsHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
126
127
|
* `--layout long` asks for it. Several tickers have no shared columns, so they are never laid out wide.
|
|
127
128
|
*/
|
|
128
129
|
function financialReportLayout(symbols: readonly string[], options: HeadlessPaneOptionValues): "wide" | "long" {
|
|
129
|
-
if (options.layout === "wide" && symbols.length > 1) {
|
|
130
|
-
throw new Error(
|
|
130
|
+
if (options.layout === "wide" && (symbols.length > 1 || options.currency)) {
|
|
131
|
+
throw new Error("--layout wide shows one ticker in its reporting currency. Leave --layout out for converted figures or multiple tickers.");
|
|
131
132
|
}
|
|
132
|
-
return options.layout === "long" || symbols.length > 1 ? "long" : "wide";
|
|
133
|
+
return options.layout === "long" || symbols.length > 1 || options.currency ? "long" : "wide";
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
/** How a figure of an FA row reads: the kind of number it is, which names its unit and draws it. */
|
|
@@ -243,6 +244,8 @@ async function loadLongFinancialReport(symbols: string[], options: HeadlessPaneO
|
|
|
243
244
|
symbol, data, rows: data.rows as unknown as WideRow[], columns: (data.metadata?.columns ?? []) as WideColumn[],
|
|
244
245
|
}));
|
|
245
246
|
const divisor = mostCommon(tables.flatMap(({ rows }) => rows.filter((row) => row.figure === "money").map((row) => row.divisor))) ?? 1;
|
|
247
|
+
const target = typeof options.currency === "string" ? options.currency : null;
|
|
248
|
+
const fx = target ? await loadStatementCurrency(target, tables.flatMap(({ columns }) => columns.flatMap(({ currency }) => currency ? [currency] : [])), ctx) : null;
|
|
246
249
|
const rows = tables.flatMap(({ symbol, rows: wide, columns }) => {
|
|
247
250
|
const said = new Set<string>();
|
|
248
251
|
return wide.flatMap((row) => {
|
|
@@ -253,13 +256,19 @@ async function loadLongFinancialReport(symbols: string[], options: HeadlessPaneO
|
|
|
253
256
|
const rowDivisor = row.figure === "money" ? divisor : row.divisor;
|
|
254
257
|
return columns.map((column, index) => {
|
|
255
258
|
const cell = row.cells[index];
|
|
256
|
-
const
|
|
259
|
+
const native = typeof cell?.value === "number" && Number.isFinite(cell.value) ? cell.value : null;
|
|
260
|
+
const monetary = row.figure === "money" || row.figure === "perShare";
|
|
261
|
+
const rate = fx && monetary ? fx.rates.get(column.currency ?? "") : 1;
|
|
262
|
+
const value = native != null && rate != null ? native * rate : null;
|
|
263
|
+
const nativeUnit = figureUnit(row.figure, column.currency, rowDivisor);
|
|
257
264
|
return {
|
|
258
265
|
ticker: symbol, period: column.period, periodEnd: column.periodEnd, metric,
|
|
259
266
|
value: value == null ? null : longFigureValue(row.figure, value, rowDivisor),
|
|
260
|
-
unit: figureUnit(row.figure, column.currency, rowDivisor),
|
|
267
|
+
unit: figureUnit(row.figure, monetary && target ? target : column.currency, rowDivisor),
|
|
261
268
|
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,
|
|
269
|
+
gap: native != null && rate == null ? "No FX rate" : value == null ? cell?.gap ?? (cell?.formatted && cell.formatted !== MISSING_VALUE ? cell.formatted : null) : null,
|
|
270
|
+
...(fx && monetary && native != null ? { nativeValue: longFigureValue(row.figure, native, rowDivisor), nativeUnit,
|
|
271
|
+
nativeFormatted: `${drawLongFigure(row.figure, native, rowDivisor)} ${nativeUnit}` } : {}),
|
|
263
272
|
};
|
|
264
273
|
});
|
|
265
274
|
});
|
|
@@ -273,18 +282,21 @@ async function loadLongFinancialReport(symbols: string[], options: HeadlessPaneO
|
|
|
273
282
|
const ownNotes = tables.flatMap(({ symbol, data }) => (data.notes ?? []).filter((note) => !shared(note)).map((note) => `${symbol}: ${note}`));
|
|
274
283
|
const empty = tables.filter(({ rows: wide }) => wide.length === 0);
|
|
275
284
|
const first = tables[0]?.data.metadata ?? {};
|
|
285
|
+
const nativeColumn: HeadlessPaneColumn = { key: "nativeValue", header: "Native", align: "right", unitKey: "nativeUnit",
|
|
286
|
+
format: (_value, row) => String(row.nativeFormatted ?? "") };
|
|
276
287
|
return {
|
|
277
288
|
rows,
|
|
278
|
-
columns: LONG_FINANCIAL_COLUMNS,
|
|
279
|
-
textColumns: [...LONG_FINANCIAL_COLUMNS, { key: "unit", header: "Unit" }],
|
|
289
|
+
columns: fx ? [...LONG_FINANCIAL_COLUMNS, nativeColumn] : LONG_FINANCIAL_COLUMNS,
|
|
290
|
+
textColumns: [...LONG_FINANCIAL_COLUMNS, { key: "unit", header: "Unit" }, ...(fx ? [nativeColumn] : [])],
|
|
280
291
|
rowUnitKey: "unit", rowSymbolKey: "ticker", rowAsOfKey: "periodEnd",
|
|
281
292
|
interval: options.period === "quarterly" ? "quarterly" : "annual",
|
|
282
293
|
unavailableSymbols: [...loaded.unavailableSymbols, ...empty.flatMap(({ data }) => data.unavailableSymbols ?? [])],
|
|
283
294
|
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])],
|
|
295
|
+
notes: [...new Set([...notes.filter(shared), ...ownNotes, ...(fx?.note ? [fx.note] : []), ...fx?.failures ?? []])],
|
|
285
296
|
metadata: {
|
|
286
297
|
symbols, layout: "long", statement: first.statement ?? options.statement, statementLabel: first.statementLabel ?? null,
|
|
287
298
|
period: options.period === "quarterly" ? "quarterly" : "annual",
|
|
299
|
+
...(fx ? { currency: target, conversions: fx.conversions } : {}),
|
|
288
300
|
notices: [...new Set(tables.flatMap(({ data }) => (data.metadata?.notices ?? []) as string[]))],
|
|
289
301
|
limitations: [...new Set(tables.flatMap(({ data }) => (data.metadata?.limitations ?? []) as string[]))],
|
|
290
302
|
},
|
|
@@ -453,8 +465,9 @@ function reportOlderStatements(ctx: HeadlessContext, symbol: string, period: "an
|
|
|
453
465
|
/**
|
|
454
466
|
* Why a statements report has no rows, and what to read instead: a listing
|
|
455
467
|
* with years but no quarters names its years, and says so of a company that
|
|
456
|
-
* reports half-yearly (Qantas on ASX)
|
|
457
|
-
*
|
|
468
|
+
* reports half-yearly (Qantas on ASX); one with quarters but no full year
|
|
469
|
+
* reported (O8A:FWB2) names its quarters. Null when it has years and
|
|
470
|
+
* quarters, whatever this table lacks.
|
|
458
471
|
*/
|
|
459
472
|
async function missingPeriodsError(
|
|
460
473
|
ctx: HeadlessContext,
|
|
@@ -465,12 +478,15 @@ async function missingPeriodsError(
|
|
|
465
478
|
statement: unknown,
|
|
466
479
|
): Promise<string | null> {
|
|
467
480
|
const hasYears = financials.annualStatements.length > 0;
|
|
481
|
+
const tab = typeof statement === "string" && statement && statement !== "income" ? ` --statement ${statement}` : "";
|
|
482
|
+
if (period === "annual" && !hasRequestedStatements && financials.quarterlyStatements.length > 0) {
|
|
483
|
+
return `${symbol}: No annual financial statement coverage. For its quarters: gloom fn FA ${symbol} --period quarterly${tab}`;
|
|
484
|
+
}
|
|
468
485
|
if (period === "annual" || !hasYears) return hasRequestedStatements ? null : `${symbol}: No ${period} financial statement coverage.`;
|
|
469
486
|
const exchange = await resolveHeadlessInstrument(ctx, symbol).then(({ exchange }) => canonicalExchange(exchange ?? ""))
|
|
470
487
|
.catch(logFailure("ticker-detail.headless", "Resolving the listing of a statements report failed", ""));
|
|
471
488
|
const halfYearly = reportsHalfYearly(exchange, financials.quarterlyStatements, financials.annualStatements);
|
|
472
489
|
if (hasRequestedStatements && !halfYearly) return null;
|
|
473
|
-
const tab = typeof statement === "string" && statement && statement !== "income" ? ` --statement ${statement}` : "";
|
|
474
490
|
const years = `For its years: gloom fn FA ${symbol} --period annual${tab}`;
|
|
475
491
|
return halfYearly ? `${symbol} reports half-yearly, not quarterly. ${years}` : `${symbol}: No quarterly financial statement coverage. ${years}`;
|
|
476
492
|
}
|