@gloom-sh/terminal 0.20.22 → 0.20.23
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/account/heard-from-question.tsx +6 -4
- package/src/account/heard-from.ts +3 -4
- package/src/api-client/exchange-announcements.ts +2 -2
- package/src/api-client/heard-from.ts +5 -7
- package/src/api-client/ownership-disclosures.ts +38 -5
- package/src/api-client/types/ticker-data.ts +3 -1
- package/src/architecture/dom-cell-metrics-allowlist.json +2 -2
- package/src/cli/commands/market.ts +5 -3
- package/src/cli/commands/overview.ts +7 -9
- package/src/cli/listing-arg.ts +45 -18
- package/src/cli/pane-functions/catalog-snapshot.json +2 -2
- package/src/cli/pane-functions/data.ts +3 -1
- package/src/cli/pane-functions/freshness.ts +6 -1
- package/src/cli/pane-functions/function-help.ts +0 -2
- package/src/cli/pane-functions/market-session.ts +12 -2
- package/src/cli/pane-functions/screenshot-payload.ts +3 -1
- package/src/cli/symbol-list.ts +52 -14
- package/src/cli/ticker-resolution.ts +133 -38
- package/src/components/chart/composite/composite-chart.tsx +12 -0
- package/src/components/chart/composite/types.ts +18 -0
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +38 -15
- package/src/components/chart-table/header.tsx +11 -5
- package/src/components/chart-table/selection.ts +20 -1
- package/src/components/data-table/view.tsx +2 -0
- package/src/components/feed-data-table/stack-view.tsx +85 -5
- package/src/components/layout/pane/header.tsx +12 -30
- package/src/components/ticker/badge/index.tsx +9 -4
- package/src/components/ticker/badge/list.tsx +3 -1
- package/src/components/ui/data-table/index.tsx +7 -1
- package/src/components/ui/data-table/muted-row.tsx +47 -0
- package/src/components/ui/data-table/opentui/index.tsx +42 -11
- package/src/components/ui/data-table/spill.ts +36 -0
- package/src/components/ui/data-table/types.ts +17 -1
- package/src/components/ui/data-table/use-column-order.ts +11 -0
- package/src/components/ui/icon.tsx +50 -3
- package/src/components/ui/list-view.tsx +2 -2
- package/src/components/ui/table-layout.ts +32 -0
- package/src/components/ui/terminal-hover-label.tsx +49 -0
- package/src/components/use-pinned-moment.ts +222 -13
- package/src/core/state/app/state.ts +11 -2
- package/src/core/state/app/types.ts +2 -1
- package/src/data/sqlite/access.ts +14 -1
- package/src/data/sqlite/checkpointer.ts +2 -2
- package/src/data/sqlite/database.ts +4 -0
- package/src/docs/snapshot.json +180 -26
- package/src/i18n/es.ts +1 -0
- package/src/i18n/ja.ts +1 -0
- package/src/i18n/ko.ts +1 -0
- package/src/i18n/zh-cn.ts +1 -0
- package/src/i18n/zh-tw.ts +1 -0
- package/src/market-data/market/freshness.ts +2 -2
- package/src/market-data/market/globex-day.ts +14 -0
- package/src/market-data/published-us-sessions.ts +3 -2
- package/src/market-data/quotes/live-valuation.ts +4 -2
- package/src/market-data/quotes/metadata.ts +48 -5
- package/src/market-data/quotes/regular-session-valuation.ts +12 -1
- package/src/plugins/builtin/alerts/history-pane.tsx +19 -3
- package/src/plugins/builtin/broker-trading/orders.tsx +4 -2
- package/src/plugins/builtin/chat/attachments/desktop.tsx +46 -12
- package/src/plugins/builtin/chat/channels.ts +5 -2
- package/src/plugins/builtin/chat/content/composer-runtime.ts +64 -65
- package/src/plugins/builtin/chat/content/footer.tsx +17 -7
- package/src/plugins/builtin/chat/content/index.tsx +108 -36
- package/src/plugins/builtin/chat/content/new-dm-dialog.tsx +21 -8
- package/src/plugins/builtin/chat/content/selection-runtime.ts +16 -0
- package/src/plugins/builtin/chat/content/shortcuts.ts +3 -0
- package/src/plugins/builtin/chat/content/snapshot.ts +37 -13
- package/src/plugins/builtin/chat/content/transcript.tsx +12 -0
- package/src/plugins/builtin/chat/content/types.ts +2 -0
- package/src/plugins/builtin/chat/controller/channels.ts +15 -15
- package/src/plugins/builtin/chat/controller/index.ts +140 -34
- package/src/plugins/builtin/chat/controller/lifecycle.ts +8 -12
- package/src/plugins/builtin/chat/controller/persistence.ts +32 -4
- package/src/plugins/builtin/chat/controller/send.ts +41 -17
- package/src/plugins/builtin/chat/controller/session-runtime.ts +28 -27
- package/src/plugins/builtin/chat/controller/state.ts +17 -8
- package/src/plugins/builtin/chat/controller/storage.ts +41 -4
- package/src/plugins/builtin/chat/controller/view.ts +6 -3
- package/src/plugins/builtin/chat/index.tsx +1 -1
- package/src/plugins/builtin/chat/layout.ts +8 -1
- package/src/plugins/builtin/chat/message/desktop.tsx +15 -11
- package/src/plugins/builtin/chat/message/header.tsx +112 -30
- package/src/plugins/builtin/chat/message/reactions.tsx +10 -11
- package/src/plugins/builtin/chat/message/render-state.ts +4 -2
- package/src/plugins/builtin/chat/message/terminal.tsx +13 -15
- package/src/plugins/builtin/chat/message/types.ts +5 -0
- package/src/plugins/builtin/cloud-tweets/table.tsx +25 -2
- package/src/plugins/builtin/company-kpis/model.ts +11 -3
- package/src/plugins/builtin/correlation/compute.ts +6 -1
- package/src/plugins/builtin/custom-view/loader.ts +95 -34
- package/src/plugins/builtin/custom-view/pane.tsx +31 -41
- package/src/plugins/builtin/custom-view/table.ts +201 -0
- package/src/plugins/builtin/dividend-yield/client.ts +14 -17
- package/src/plugins/builtin/dividend-yield/headless.ts +0 -1
- package/src/plugins/builtin/dividend-yield/model.ts +45 -6
- package/src/plugins/builtin/dividend-yield/pane.tsx +70 -7
- package/src/plugins/builtin/dividend-yield/types.ts +2 -3
- package/src/plugins/builtin/dividend-yield/view.ts +22 -2
- package/src/plugins/builtin/econ/calendar-model.ts +135 -0
- package/src/plugins/builtin/econ/columns.ts +132 -0
- package/src/plugins/builtin/econ/index.tsx +25 -65
- package/src/plugins/builtin/holders/disclosures-view.tsx +9 -6
- package/src/plugins/builtin/holders/disclosures.ts +20 -6
- package/src/plugins/builtin/holders/headless.ts +2 -2
- package/src/plugins/builtin/ipo-calendar/model.ts +30 -1
- package/src/plugins/builtin/ipo-calendar/pane.tsx +7 -3
- package/src/plugins/builtin/kelly-sizer/headless.ts +9 -4
- package/src/plugins/builtin/kelly-sizer/pane.tsx +19 -9
- package/src/plugins/builtin/kelly-sizer/units.ts +26 -0
- package/src/plugins/builtin/market-halts/pane.tsx +14 -2
- package/src/plugins/builtin/news/wire/news/row.ts +5 -12
- package/src/plugins/builtin/news/wire/news/table.tsx +32 -41
- package/src/plugins/builtin/pe-band/headless.ts +1 -1
- package/src/plugins/builtin/pe-band/model.ts +41 -18
- package/src/plugins/builtin/pe-band/pane.tsx +6 -5
- package/src/plugins/builtin/perps/equity-row.tsx +4 -6
- package/src/plugins/builtin/perps/markets-section.tsx +19 -15
- package/src/plugins/builtin/perps/model.ts +10 -2
- package/src/plugins/builtin/portfolio-list/cli/import-positions.ts +6 -18
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +1 -1
- package/src/plugins/builtin/portfolio-list/pane/purchase-date-fx.ts +1 -1
- package/src/plugins/builtin/portfolio-list/positions-import/index.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/positions-import/lookup.ts +28 -57
- package/src/plugins/builtin/research/event-data.ts +3 -1
- package/src/plugins/builtin/research/event-model.ts +17 -15
- package/src/plugins/builtin/research/relative-valuation-columns.ts +19 -6
- package/src/plugins/builtin/research/relative-valuation-headless.ts +1 -1
- package/src/plugins/builtin/scanner/flow-pane.tsx +10 -0
- package/src/plugins/builtin/sec/exchange-filings.ts +32 -7
- package/src/plugins/builtin/sec/headless.ts +8 -8
- package/src/plugins/builtin/sec/index.tsx +69 -29
- package/src/plugins/builtin/shared/report-freshness.ts +4 -1
- package/src/plugins/builtin/ticker-detail/financials/aggregation.ts +1 -2
- package/src/plugins/builtin/ticker-detail/financials/exchange-table.tsx +61 -0
- package/src/plugins/builtin/ticker-detail/financials/model.ts +38 -4
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +68 -39
- package/src/plugins/builtin/ticker-detail/headless.ts +4 -1
- package/src/plugins/builtin/ticker-detail/overview/model.ts +61 -15
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +5 -0
- package/src/plugins/builtin/time-sales/model.ts +16 -9
- package/src/plugins/builtin/time-sales/pane.tsx +27 -24
- package/src/plugins/builtin/treasury-daily/client.ts +43 -9
- package/src/plugins/builtin/treasury-daily/pane.tsx +48 -27
- package/src/plugins/builtin/treasury-daily/resource.ts +33 -0
- package/src/portfolio/positions-import/parse.ts +14 -6
- package/src/portfolio/positions-import/plan.ts +3 -2
- package/src/react/async-resource.ts +3 -1
- package/src/renderers/dom/data-table/index.tsx +40 -0
- package/src/renderers/dom/data-table/row.tsx +39 -3
- package/src/renderers/dom/desktop/icons.tsx +147 -3
- package/src/renderers/dom/desktop/popover.tsx +2 -2
- package/src/renderers/dom/host/media-surface.tsx +204 -45
- package/src/renderers/dom/host/tabs.tsx +1 -0
- package/src/renderers/dom/styles.css +14 -2
- package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
- package/src/renderers/electrobun/bun/desktop/rpc-timing.ts +9 -3
- package/src/renderers/electrobun/shared/protocol.ts +2 -0
- package/src/renderers/electrobun/view/backend-rpc.ts +5 -2
- package/src/renderers/electrobun/view/rpc-timeout.ts +44 -3
- package/src/sources/gloomberb-cloud/index.ts +8 -7
- package/src/sources/gloomberb-cloud/normalizers.ts +7 -2
- package/src/sources/listing-symbols.ts +7 -1
- package/src/sources/provider-router/cache.ts +5 -4
- package/src/sources/provider-router/financials.ts +40 -18
- package/src/state/app/tab-cursor.ts +47 -6
- package/src/telemetry/stall-clocks.ts +3 -0
- package/src/telemetry/stall-reports.ts +12 -3
- package/src/telemetry/windows-process-activity.ts +41 -0
- package/src/telemetry/windows-time.ts +32 -0
- package/src/test-support/scoped-earnings.ts +24 -0
- package/src/tickers/terminal-codes.ts +1 -6
- package/src/time-series/daily-valuation.ts +13 -6
- package/src/time-series/filed-trailing-eps.ts +16 -3
- package/src/time-series/fundamentals/current-valuation.ts +8 -0
- package/src/time-series/fundamentals/historical-valuation.ts +20 -0
- package/src/time-series/fundamentals/series.ts +13 -1
- package/src/time-series/valuation-currency.ts +2 -0
- package/src/types/financials.ts +46 -10
- package/src/ui/dialog-context.ts +8 -0
- package/src/utils/datetime-format.ts +23 -1
- package/src/utils/declared-dividends.ts +12 -2
- package/src/utils/exchange-announcements.ts +4 -1
- package/src/utils/exchange-notation.generated.ts +3 -1
- package/src/utils/exchanges.ts +2 -1
- package/src/utils/fundamentals.ts +1 -0
- package/src/utils/main-thread-stall.ts +9 -1
- package/src/utils/rpc-timeout-error.ts +36 -11
- package/src/utils/sec.ts +3 -1
- package/src/utils/share-multiples.ts +1 -1
- package/src/utils/stall-process-activity.ts +70 -0
- package/src/utils/statement-scope.ts +103 -0
- package/src/utils/trailing-eps.ts +1 -1
- package/src/utils/zoned-date-time.ts +1 -0
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
HeadlessBundleResult,
|
|
3
|
+
HeadlessPaneColumn,
|
|
4
|
+
HeadlessPaneDefinition,
|
|
5
|
+
HeadlessPaneResult,
|
|
6
|
+
HeadlessPaneRow,
|
|
7
|
+
HeadlessRowsResult,
|
|
8
|
+
HeadlessSeries,
|
|
9
|
+
HeadlessSeriesResult,
|
|
10
|
+
HeadlessSnapshotResult,
|
|
11
|
+
} from "../../../types/headless";
|
|
12
|
+
import { loadResolvedHeadlessPaneModel } from "../../../cli/pane-functions/headless";
|
|
3
13
|
import { resolvePaneFunction, UnknownPaneFunctionError } from "../../../cli/pane-functions/resolver";
|
|
4
14
|
import type { AppConfig } from "../../../types/config";
|
|
15
|
+
import { formatCompact } from "../../../utils/format";
|
|
5
16
|
import { getSharedRegistry, type PluginRegistry } from "../../registry";
|
|
6
17
|
import { marketContextFromRegistry } from "../cloud/askg/host";
|
|
7
18
|
import { notViewSourceMessage, unknownViewSourceMessage } from "./sources";
|
|
19
|
+
import { withViewRowSource } from "./table";
|
|
8
20
|
import { applyViewProjection, unknownViewKeys, type UnknownViewKey, type ViewKeyPlace, type ViewRow, type ViewSource, type ViewSpec } from "./view-spec";
|
|
9
21
|
|
|
10
22
|
export interface LoadedView {
|
|
11
23
|
rows: ViewRow[];
|
|
24
|
+
/** The source's columns as it defines them, formats included, so the view draws a value as the source does. */
|
|
12
25
|
columns: HeadlessPaneColumn[];
|
|
13
26
|
errors: string[];
|
|
14
27
|
sourceLabel: string;
|
|
@@ -23,40 +36,89 @@ export function setViewRefResolver(resolver: ViewRefResolver | null): void {
|
|
|
23
36
|
refResolver = resolver;
|
|
24
37
|
}
|
|
25
38
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
/** Every key the rows carry, headed by the key, for a source that lists no columns. */
|
|
40
|
+
function rowKeyColumns(rows: readonly HeadlessPaneRow[]): HeadlessPaneColumn[] {
|
|
41
|
+
const keys = new Set<string>();
|
|
42
|
+
for (const row of rows) for (const key of Object.keys(row)) keys.add(key);
|
|
43
|
+
return [...keys].map((key) => ({ key, header: key }));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A section of entries flattens into rows of its label and value. */
|
|
47
|
+
const ENTRY_COLUMNS: HeadlessPaneColumn[] = [{ key: "label", header: "Label" }, { key: "value", header: "Value" }];
|
|
48
|
+
const ENTRY_COLUMN_MAP: ReadonlyMap<string, HeadlessPaneColumn> = new Map(ENTRY_COLUMNS.map((column) => [column.key, column]));
|
|
49
|
+
|
|
50
|
+
/** A series value at the decimals or in the short form the text report prints it with. */
|
|
51
|
+
function seriesFormat(series: HeadlessSeries): Pick<HeadlessPaneColumn, "format"> {
|
|
52
|
+
const { textDecimals, textCompact } = series;
|
|
53
|
+
if (textCompact) return { format: (value) => (typeof value === "number" ? formatCompact(value) : "") };
|
|
54
|
+
if (textDecimals !== undefined) return { format: (value) => (typeof value === "number" ? value.toFixed(textDecimals) : "") };
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** A point's date as the text it sorts and filters by: an ISO instant for a time, the string the source gave otherwise. */
|
|
59
|
+
function seriesDate(date: HeadlessSeries["points"][number]["date"]): string {
|
|
60
|
+
if (date instanceof Date) return Number.isFinite(date.getTime()) ? date.toISOString() : "";
|
|
61
|
+
if (typeof date === "number") return Number.isFinite(date) ? new Date(date).toISOString() : "";
|
|
62
|
+
return String(date);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The source's result as one table, with the columns that draw it as the
|
|
67
|
+
* source defines them (their formats too). A bundle flattens into one table
|
|
68
|
+
* with a section column, each row tagged with its own section's columns,
|
|
69
|
+
* since two sections can format one key apart; a series into rows of date
|
|
70
|
+
* plus one column per series.
|
|
71
|
+
*/
|
|
72
|
+
function viewTableFrom(definition: HeadlessPaneDefinition, result: HeadlessPaneResult): { rows: ViewRow[]; columns: HeadlessPaneColumn[] } {
|
|
73
|
+
switch (definition.shape) {
|
|
74
|
+
case "rows": {
|
|
75
|
+
const { rows, columns } = result as HeadlessRowsResult;
|
|
76
|
+
return { rows, columns: columns ?? definition.columns ?? rowKeyColumns(rows) };
|
|
41
77
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
78
|
+
case "snapshot": {
|
|
79
|
+
const { items } = result as HeadlessSnapshotResult;
|
|
80
|
+
return { rows: items, columns: definition.columns ?? rowKeyColumns(items) };
|
|
81
|
+
}
|
|
82
|
+
case "bundle": {
|
|
83
|
+
const rows: ViewRow[] = [];
|
|
84
|
+
const columns = new Map<string, HeadlessPaneColumn>([["section", { key: "section", header: "Section" }]]);
|
|
85
|
+
for (const section of (result as HeadlessBundleResult).sections) {
|
|
86
|
+
if (section.entries) {
|
|
87
|
+
for (const column of ENTRY_COLUMNS) if (!columns.has(column.key)) columns.set(column.key, column);
|
|
88
|
+
for (const entry of section.entries) {
|
|
89
|
+
rows.push(withViewRowSource({ section: section.title, label: entry.label, value: entry.value }, {
|
|
90
|
+
columns: ENTRY_COLUMN_MAP,
|
|
91
|
+
...(entry.formatted !== undefined ? { text: { value: entry.formatted } } : {}),
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const own = section.columns ?? definition.columns ?? rowKeyColumns(section.rows);
|
|
97
|
+
for (const column of own) columns.set(column.key, column);
|
|
98
|
+
const byKey = new Map(own.map((column) => [column.key, column]));
|
|
99
|
+
for (const row of section.rows) rows.push(withViewRowSource({ section: section.title, ...row }, { columns: byKey }));
|
|
100
|
+
}
|
|
101
|
+
return { rows, columns: [...columns.values()] };
|
|
102
|
+
}
|
|
103
|
+
case "series": {
|
|
104
|
+
const byDate = new Map<string, ViewRow>();
|
|
105
|
+
const columns: HeadlessPaneColumn[] = [{ key: "date", header: "Date" }];
|
|
106
|
+
for (const series of (result as HeadlessSeriesResult).series) {
|
|
107
|
+
columns.push({ key: series.id, header: series.label, align: "right", ...seriesFormat(series) });
|
|
108
|
+
for (const point of series.points) {
|
|
109
|
+
const date = seriesDate(point.date);
|
|
110
|
+
const row = byDate.get(date) ?? { date };
|
|
111
|
+
row[series.id] = point.value ?? point.close ?? null;
|
|
112
|
+
byDate.set(date, row);
|
|
113
|
+
}
|
|
55
114
|
}
|
|
115
|
+
return { rows: [...byDate.values()], columns };
|
|
116
|
+
}
|
|
117
|
+
default: {
|
|
118
|
+
const _exhaustive: never = definition.shape;
|
|
119
|
+
return _exhaustive;
|
|
56
120
|
}
|
|
57
|
-
return { rows: [...byDate.values()], columns };
|
|
58
121
|
}
|
|
59
|
-
return { rows: [], columns: [] };
|
|
60
122
|
}
|
|
61
123
|
|
|
62
124
|
/**
|
|
@@ -101,8 +163,7 @@ export async function loadViewSource(
|
|
|
101
163
|
});
|
|
102
164
|
if (!resolved.headless) throw new Error(notViewSourceMessage(registry, resolved.label));
|
|
103
165
|
const loaded = await loadResolvedHeadlessPaneModel(resolved, context, spec.source.argument ?? "", signal);
|
|
104
|
-
const
|
|
105
|
-
const { rows, columns } = rowsFromResult(serialized);
|
|
166
|
+
const { rows, columns } = viewTableFrom(loaded.definition, loaded.result);
|
|
106
167
|
return {
|
|
107
168
|
rows,
|
|
108
169
|
columns,
|
|
@@ -9,7 +9,6 @@ import { teamStore } from "../../../team/store";
|
|
|
9
9
|
import { teamViewsStore } from "../cloud/team/views";
|
|
10
10
|
import { setPaneSettings } from "../../../pane-settings";
|
|
11
11
|
import { customViewInstanceSettings } from "./index";
|
|
12
|
-
import type { DataTableColumn } from "../../../components/ui/data-table/types";
|
|
13
12
|
import { PaneStatusBody, TextPromptDialog, usePaneFooter } from "../../../components";
|
|
14
13
|
import { useAsyncResource } from "../../../react/async-resource";
|
|
15
14
|
import { useShortcut } from "../../../react/input";
|
|
@@ -36,14 +35,13 @@ import {
|
|
|
36
35
|
viewStreamTargets,
|
|
37
36
|
type ViewRowRange,
|
|
38
37
|
} from "./live-quotes";
|
|
39
|
-
import { loadViewSource
|
|
38
|
+
import { loadViewSource } from "./loader";
|
|
39
|
+
import { sizeViewColumns, viewCellColumns, viewCellExportValue, viewCellText, type ViewTableColumn } from "./table";
|
|
40
40
|
import {
|
|
41
41
|
applyViewProjection,
|
|
42
42
|
EXAMPLE_VIEW_SPEC,
|
|
43
|
-
formatViewValue,
|
|
44
43
|
growViewColumnDecimals,
|
|
45
44
|
parseViewSpecOr,
|
|
46
|
-
type ViewColumn,
|
|
47
45
|
type ViewRow,
|
|
48
46
|
type ViewSort,
|
|
49
47
|
type ViewSpec,
|
|
@@ -52,9 +50,6 @@ import {
|
|
|
52
50
|
export const CUSTOM_VIEW_PANE_ID = "custom-view";
|
|
53
51
|
export const CUSTOM_VIEW_SPEC_SETTING = "spec";
|
|
54
52
|
|
|
55
|
-
type Column = DataTableColumn & { key: string; transform?: ViewColumn["transform"] };
|
|
56
|
-
|
|
57
|
-
const DEFAULT_COLUMN_WIDTH = 14;
|
|
58
53
|
const NO_ROWS: ViewRow[] = [];
|
|
59
54
|
const NO_SYMBOLS: readonly (string | null)[] = [];
|
|
60
55
|
const NO_TARGETS: QuoteSubscriptionTarget[] = [];
|
|
@@ -72,24 +67,15 @@ function sameSymbols(left: readonly (string | null)[], right: readonly (string |
|
|
|
72
67
|
return left.length === right.length && left.every((symbol, index) => symbol === right[index]);
|
|
73
68
|
}
|
|
74
69
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
id: column.key,
|
|
85
|
-
key: column.key,
|
|
86
|
-
label: column.label ?? source?.header ?? column.key,
|
|
87
|
-
align: align === "right" ? "right" : "left",
|
|
88
|
-
width: column.width ?? (index === 0 ? 18 : DEFAULT_COLUMN_WIDTH),
|
|
89
|
-
...(index === 0 ? { flexGrow: 1 } : {}),
|
|
90
|
-
transform: column.transform,
|
|
91
|
-
};
|
|
92
|
-
});
|
|
70
|
+
/** The first number a column holds, which an `index100` column is rebased to. */
|
|
71
|
+
function indexBases(columns: readonly { key: string; transform?: string }[], rows: readonly ViewRow[]): Map<string, number> {
|
|
72
|
+
const bases = new Map<string, number>();
|
|
73
|
+
for (const column of columns) {
|
|
74
|
+
if (column.transform !== "index100") continue;
|
|
75
|
+
const first = rows.find((row) => typeof row[column.key] === "number")?.[column.key];
|
|
76
|
+
if (typeof first === "number") bases.set(column.key, first);
|
|
77
|
+
}
|
|
78
|
+
return bases;
|
|
93
79
|
}
|
|
94
80
|
|
|
95
81
|
/** What an empty view says: ask for one, or open one from a spec that works as typed. */
|
|
@@ -125,7 +111,7 @@ export function CustomViewPane({ focused, width, height }: PaneProps) {
|
|
|
125
111
|
setSort(undefined);
|
|
126
112
|
}, [spec]);
|
|
127
113
|
|
|
128
|
-
const columns = useMemo(() => (spec ?
|
|
114
|
+
const columns = useMemo(() => (spec ? viewCellColumns(spec, data?.columns ?? []) : []), [data?.columns, spec]);
|
|
129
115
|
const symbolKey = spec?.presentation.symbolKey ?? (columns.some((column) => column.key === "symbol") ? "symbol" : null);
|
|
130
116
|
|
|
131
117
|
// Price, change and volume columns of rows that name a symbol stream through
|
|
@@ -182,15 +168,7 @@ export function CustomViewPane({ focused, width, height }: PaneProps) {
|
|
|
182
168
|
useEffect(() => {
|
|
183
169
|
setStreamOrder((current) => (sameSymbols(current, displayedSymbols) ? current : displayedSymbols));
|
|
184
170
|
}, [displayedSymbols]);
|
|
185
|
-
const baseByColumn = useMemo(() =>
|
|
186
|
-
const bases = new Map<string, number>();
|
|
187
|
-
for (const column of columns) {
|
|
188
|
-
if (column.transform !== "index100") continue;
|
|
189
|
-
const first = rows.find((row) => typeof row[column.key] === "number")?.[column.key];
|
|
190
|
-
if (typeof first === "number") bases.set(column.key, first);
|
|
191
|
-
}
|
|
192
|
-
return bases;
|
|
193
|
-
}, [columns, rows]);
|
|
171
|
+
const baseByColumn = useMemo(() => indexBases(columns, rows), [columns, rows]);
|
|
194
172
|
const decimalFloors = useMemo(() => liveViewDecimalFloors(sourceRows, liveFields), [liveFields, sourceRows]);
|
|
195
173
|
// A column's decimals only grow while this spec is shown, so a tick that
|
|
196
174
|
// crosses 100 or lands on a whole number never reflows the column.
|
|
@@ -205,15 +183,27 @@ export function CustomViewPane({ focused, width, height }: PaneProps) {
|
|
|
205
183
|
heldDecimals.current = { spec, decimals };
|
|
206
184
|
return decimals;
|
|
207
185
|
}, [columns, decimalFloors, rows, spec]);
|
|
186
|
+
// Sized on the rows as loaded, so a live tick never moves a column; again only when a column's decimals grow.
|
|
187
|
+
const liveKeys = useMemo(() => new Set(liveFields.keys()), [liveFields]);
|
|
188
|
+
const tableColumns = useMemo(() => {
|
|
189
|
+
const bases = indexBases(columns, sourceRows);
|
|
190
|
+
return sizeViewColumns(columns, sourceRows, (row, column) => (
|
|
191
|
+
viewCellText(row, column, bases.get(column.key), decimalsByColumn.get(column.key))
|
|
192
|
+
), liveKeys);
|
|
193
|
+
}, [columns, decimalsByColumn, liveKeys, sourceRows]);
|
|
208
194
|
const activeSort = sort === undefined ? spec?.projection.sort ?? null : sort;
|
|
209
195
|
// Memoized so the table's row memo holds while the selection moves.
|
|
210
196
|
const rowKey = useCallback((row: ViewRow, index: number) => (
|
|
211
197
|
`${symbolKey && typeof row[symbolKey] === "string" ? row[symbolKey] : ""}:${index}`
|
|
212
198
|
), [symbolKey]);
|
|
213
|
-
const renderRowCell = useCallback((row: ViewRow, column:
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
199
|
+
const renderRowCell = useCallback((row: ViewRow, column: ViewTableColumn) => {
|
|
200
|
+
const value = viewCellExportValue(row, column);
|
|
201
|
+
return {
|
|
202
|
+
text: viewCellText(row, column, baseByColumn.get(column.key), decimalsByColumn.get(column.key)),
|
|
203
|
+
...(value !== undefined ? { value } : {}),
|
|
204
|
+
color: column.key === symbolKey ? colors.textBright : undefined,
|
|
205
|
+
};
|
|
206
|
+
}, [baseByColumn, decimalsByColumn, symbolKey]);
|
|
217
207
|
|
|
218
208
|
/**
|
|
219
209
|
* Publishes this view to a team. An inline view becomes a new team view
|
|
@@ -385,7 +375,7 @@ export function CustomViewPane({ focused, width, height }: PaneProps) {
|
|
|
385
375
|
}
|
|
386
376
|
|
|
387
377
|
return (
|
|
388
|
-
<DataTableView<ViewRow,
|
|
378
|
+
<DataTableView<ViewRow, ViewTableColumn>
|
|
389
379
|
focused={focused}
|
|
390
380
|
rootWidth={width}
|
|
391
381
|
rootHeight={height}
|
|
@@ -394,7 +384,7 @@ export function CustomViewPane({ focused, width, height }: PaneProps) {
|
|
|
394
384
|
selectedIndex,
|
|
395
385
|
onChange: (index) => setSelectedIndex(index),
|
|
396
386
|
}}
|
|
397
|
-
columns={
|
|
387
|
+
columns={tableColumns}
|
|
398
388
|
items={rows}
|
|
399
389
|
sortColumnId={activeSort?.by ?? null}
|
|
400
390
|
sortDirection={activeSort?.direction ?? "desc"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a view's table draws its source's rows: the text of each cell, from
|
|
3
|
+
* the spec's transform or the source's own format, and how wide each column
|
|
4
|
+
* is set (docs/pane-conventions.md, "Columns in a narrow pane"): codes and
|
|
5
|
+
* figures as wide as what they hold, the columns of names and sentences set
|
|
6
|
+
* to grow with the pane.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { DataTableColumn } from "../../../components/ui/data-table/types";
|
|
10
|
+
import type { HeadlessPaneColumn } from "../../../types/headless";
|
|
11
|
+
import { displayWidth } from "../../../utils/format";
|
|
12
|
+
import { formatViewValue, type ViewColumn, type ViewRow, type ViewSpec, type ViewTransform } from "./view-spec";
|
|
13
|
+
|
|
14
|
+
/** A view's column before it is sized: what heads it and draws its cells. */
|
|
15
|
+
interface ViewCellColumn {
|
|
16
|
+
key: string;
|
|
17
|
+
label: string;
|
|
18
|
+
align?: "left" | "right";
|
|
19
|
+
/** The width the spec set, which the table keeps whatever the cells hold. */
|
|
20
|
+
width?: number;
|
|
21
|
+
transform?: ViewTransform;
|
|
22
|
+
/** The source's own column for the key, whose format draws its cells; absent for a key the source lists no column for. */
|
|
23
|
+
source?: HeadlessPaneColumn;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type ViewTableColumn = DataTableColumn & Pick<ViewCellColumn, "key" | "transform" | "source">;
|
|
27
|
+
|
|
28
|
+
const ROW_SOURCE = Symbol("view row source");
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* How the source drew one row's cells, where the view's columns cannot say
|
|
32
|
+
* it: a bundle's sections each format their own keys, and two sections can
|
|
33
|
+
* format one key apart; an entry carries its value's text already formatted.
|
|
34
|
+
*/
|
|
35
|
+
interface ViewRowSource {
|
|
36
|
+
columns: ReadonlyMap<string, HeadlessPaneColumn>;
|
|
37
|
+
/** Cell text the source wrote itself, by key. */
|
|
38
|
+
text?: Readonly<Record<string, string>>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type SourcedRow = ViewRow & { [ROW_SOURCE]?: ViewRowSource };
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Tags `row` with the columns and text its source drew it with. A symbol key
|
|
45
|
+
* is no row key: filters, sorts, the source's key list and exports never see
|
|
46
|
+
* it, and the copy a live quote makes of the row keeps it.
|
|
47
|
+
*/
|
|
48
|
+
export function withViewRowSource(row: ViewRow, source: ViewRowSource): ViewRow {
|
|
49
|
+
(row as SourcedRow)[ROW_SOURCE] = source;
|
|
50
|
+
return row;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The spec's columns, or the source's when it names none, with their source column and the header, alignment and width the spec set. */
|
|
54
|
+
export function viewCellColumns(spec: ViewSpec, columns: readonly HeadlessPaneColumn[]): ViewCellColumn[] {
|
|
55
|
+
const known = new Map(columns.map((column) => [column.key, column]));
|
|
56
|
+
const picked: ViewColumn[] = spec.projection.columns.length > 0 ? spec.projection.columns : columns.map((column) => ({ key: column.key }));
|
|
57
|
+
return picked.map((column) => {
|
|
58
|
+
const source = known.get(column.key);
|
|
59
|
+
const align = column.align ?? source?.align;
|
|
60
|
+
return {
|
|
61
|
+
key: column.key,
|
|
62
|
+
label: column.label ?? source?.header ?? column.key,
|
|
63
|
+
// Center reads as left in a table; a column neither aligns is aligned by what it holds (sizeViewColumns).
|
|
64
|
+
...(align ? { align: align === "right" ? "right" as const : "left" as const } : {}),
|
|
65
|
+
...(column.width !== undefined ? { width: column.width } : {}),
|
|
66
|
+
...(column.transform ? { transform: column.transform } : {}),
|
|
67
|
+
...(source ? { source } : {}),
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** A source format's text, or null where the row is one it cannot read. */
|
|
73
|
+
function formattedText(format: NonNullable<HeadlessPaneColumn["format"]>, value: unknown, row: ViewRow): string | null {
|
|
74
|
+
try {
|
|
75
|
+
return format(value, row);
|
|
76
|
+
} catch {
|
|
77
|
+
// Intentional ignore: a source's format written for its own rows that cannot read a live or flattened one shows the plain value.
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The format a source draws a column's cells with: the text report's, which
|
|
84
|
+
* says more than an export's (a time to the second, a list joined), except
|
|
85
|
+
* for a value the report prints under its row rather than in its column.
|
|
86
|
+
*/
|
|
87
|
+
function sourceFormat(column: HeadlessPaneColumn): HeadlessPaneColumn["format"] {
|
|
88
|
+
return column.underRow ? column.format : column.textFormat ?? column.format;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A cell's text: the spec's transform when the column names one, else the
|
|
93
|
+
* text the source draws the value with (the row's own section's format where
|
|
94
|
+
* it has one), else the plain value.
|
|
95
|
+
* `base` and `decimals` are formatViewValue's.
|
|
96
|
+
*/
|
|
97
|
+
export function viewCellText(row: ViewRow, column: Pick<ViewCellColumn, "key" | "transform" | "source">, base?: number, decimals?: number): string {
|
|
98
|
+
const value = row[column.key];
|
|
99
|
+
if (!column.transform) {
|
|
100
|
+
const own = (row as SourcedRow)[ROW_SOURCE];
|
|
101
|
+
const written = own?.text?.[column.key];
|
|
102
|
+
if (written !== undefined) return written;
|
|
103
|
+
// A row with columns of its own never takes another section's format for a key they leave out.
|
|
104
|
+
const source = own ? own.columns.get(column.key) : column.source;
|
|
105
|
+
const format = source ? sourceFormat(source) : undefined;
|
|
106
|
+
const text = format ? formattedText(format, value, row) : null;
|
|
107
|
+
if (text !== null) return text;
|
|
108
|
+
}
|
|
109
|
+
return formatViewValue(value, column.transform, base, decimals);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The number a cell exports, for a column that shows it in its own unit:
|
|
114
|
+
* CSV and `fn VIEW` keep the source's figure (123456789 for 123.46M) rather
|
|
115
|
+
* than read it back from the text. A percent, an absolute value or an index
|
|
116
|
+
* shows another number, which exports as it reads.
|
|
117
|
+
*/
|
|
118
|
+
export function viewCellExportValue(row: ViewRow, column: Pick<ViewCellColumn, "key" | "transform">): number | undefined {
|
|
119
|
+
const value = row[column.key];
|
|
120
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return undefined;
|
|
121
|
+
return column.transform === undefined || column.transform === "raw" || column.transform === "compact" ? value : undefined;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Text no wider than this is a code, whatever it says: a ticker, a currency, an exchange, a short date. */
|
|
125
|
+
const CODE_WIDTH = 12;
|
|
126
|
+
/** The widest a column of names or sentences is set; the cells past it end in an ellipsis. */
|
|
127
|
+
const TEXT_WIDTH = 40;
|
|
128
|
+
/**
|
|
129
|
+
* The width the column that grows is set to: it takes what the pane has
|
|
130
|
+
* beyond the other columns, up to its whole text, so a narrow pane cuts a
|
|
131
|
+
* long name before it pushes a figure out of view.
|
|
132
|
+
*/
|
|
133
|
+
const GROWING_WIDTH = 20;
|
|
134
|
+
/** The widest a column of codes or figures is set, so one odd value cannot take the pane. */
|
|
135
|
+
const FIGURE_WIDTH = 32;
|
|
136
|
+
/** The rows a column is measured on; a longer list is read that far. */
|
|
137
|
+
const MEASURED_ROWS = 500;
|
|
138
|
+
|
|
139
|
+
/** Most of what the cells say is letters: names and sentences, not dates, times or numbers with a unit. */
|
|
140
|
+
function isWording(texts: readonly string[]): boolean {
|
|
141
|
+
let letters = 0;
|
|
142
|
+
let characters = 0;
|
|
143
|
+
for (const text of texts) {
|
|
144
|
+
for (const character of text) {
|
|
145
|
+
if (/\s/.test(character)) continue;
|
|
146
|
+
characters += 1;
|
|
147
|
+
if (/\p{L}/u.test(character)) letters += 1;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return characters > 0 && letters * 2 >= characters;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Sets each column's width from what it holds on `rows`, the source's rows
|
|
155
|
+
* as loaded, so a live tick never moves a column. A column of numbers is
|
|
156
|
+
* right-aligned unless the spec or source aligns it; it and a column of
|
|
157
|
+
* codes are as wide as their widest text, a cell more for a figure that
|
|
158
|
+
* streams (`live`), whose next tick can be a digit longer. A column of names
|
|
159
|
+
* or sentences (the source's `shrink`, or text longer than a code that is
|
|
160
|
+
* mostly letters) is set to its widest text up to TEXT_WIDTH, except the one
|
|
161
|
+
* with the longest text, which is set to at most GROWING_WIDTH and grows
|
|
162
|
+
* with the pane: a name or a headline gets the pane's spare width, and a
|
|
163
|
+
* ticker, a date or a publisher does not. A width the spec set is kept.
|
|
164
|
+
*/
|
|
165
|
+
export function sizeViewColumns(
|
|
166
|
+
columns: readonly ViewCellColumn[],
|
|
167
|
+
rows: readonly ViewRow[],
|
|
168
|
+
text: (row: ViewRow, column: ViewCellColumn) => string,
|
|
169
|
+
live: ReadonlySet<string> = new Set(),
|
|
170
|
+
): ViewTableColumn[] {
|
|
171
|
+
const measured = rows.length > MEASURED_ROWS ? rows.slice(0, MEASURED_ROWS) : rows;
|
|
172
|
+
const read = columns.map((column) => {
|
|
173
|
+
const texts = measured.map((row) => text(row, column));
|
|
174
|
+
const widest = texts.reduce((most, cell) => Math.max(most, displayWidth(cell)), 0);
|
|
175
|
+
const values = measured.map((row) => row[column.key]).filter((value) => value !== null && value !== undefined && value !== "");
|
|
176
|
+
const numeric = values.length > 0 && values.every((value) => typeof value === "number");
|
|
177
|
+
const wording = !numeric && column.source?.shrink !== false
|
|
178
|
+
&& (column.source?.shrink === true || (widest > CODE_WIDTH && isWording(texts)));
|
|
179
|
+
return { column, widest, numeric, wording };
|
|
180
|
+
});
|
|
181
|
+
// The first of the widest, so a name ahead of a description of the same length keeps the room.
|
|
182
|
+
const grows = read.reduce<(typeof read)[number] | null>((best, entry) => (
|
|
183
|
+
entry.wording && (!best || entry.widest > best.widest) ? entry : best
|
|
184
|
+
), null);
|
|
185
|
+
return read.map((entry) => {
|
|
186
|
+
const { column, widest, numeric, wording } = entry;
|
|
187
|
+
const width = column.width ?? (entry === grows ? Math.min(widest, GROWING_WIDTH)
|
|
188
|
+
: wording ? Math.min(widest, TEXT_WIDTH)
|
|
189
|
+
: Math.min(widest + (numeric && live.has(column.key) ? 1 : 0), FIGURE_WIDTH));
|
|
190
|
+
return {
|
|
191
|
+
id: column.key,
|
|
192
|
+
key: column.key,
|
|
193
|
+
label: column.label,
|
|
194
|
+
align: column.align ?? (numeric ? "right" : "left"),
|
|
195
|
+
width: Math.max(1, width),
|
|
196
|
+
...(entry === grows ? { flexGrow: 1 } : {}),
|
|
197
|
+
...(column.transform ? { transform: column.transform } : {}),
|
|
198
|
+
...(column.source ? { source: column.source } : {}),
|
|
199
|
+
};
|
|
200
|
+
});
|
|
201
|
+
}
|
|
@@ -8,7 +8,7 @@ import { cashDistribution, combinedPaymentTimes, dividendReferencePrice, dividen
|
|
|
8
8
|
import { dividendQuotePriceMetadata } from "./reference-price";
|
|
9
9
|
import { mapQuote } from "../../../sources/gloomberb-cloud/normalizers";
|
|
10
10
|
import { regularSessionValuationPrice } from "../../../market-data/quotes/regular-session-valuation";
|
|
11
|
-
import { declaredDividends } from "../../../utils/declared-dividends";
|
|
11
|
+
import { declaredDividends, dividendNoticeSource } from "../../../utils/declared-dividends";
|
|
12
12
|
import { atSourcePrecision, cashInMajorUnits } from "../../../utils/dividend-cash";
|
|
13
13
|
import { lapsedDividend, monthlyHistoryEnd } from "../../../utils/forward-dividend";
|
|
14
14
|
import type { DeclaredCash, DeclaredDividendAction, TickerFinancials } from "../../../types/financials";
|
|
@@ -145,13 +145,6 @@ function formParts(value: unknown, amount: number): { amount: number; special: b
|
|
|
145
145
|
return parts.length === value.length && Math.abs(sum - amount) <= 1e-6 * Math.max(1, amount) ? parts : null;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
/** A row's publisher when the server names one (a fund's sponsor), else null. */
|
|
149
|
-
function distributionSource(value: unknown): { publisher: string; url: string } | null {
|
|
150
|
-
const source = value as { publisher?: unknown; url?: unknown } | null | undefined;
|
|
151
|
-
return typeof source?.publisher === "string" && source.publisher.trim() && typeof source.url === "string"
|
|
152
|
-
? { publisher: source.publisher.trim(), url: source.url } : null;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
148
|
/**
|
|
156
149
|
* The declared amount of each paid row by its ex-date: a company declaring in
|
|
157
150
|
* another currency than the listing pays. Rows in the listing's own currency,
|
|
@@ -239,10 +232,6 @@ export async function fetchDividendData(
|
|
|
239
232
|
: null;
|
|
240
233
|
const statedFields = !summary && stated && (!cashCurrency || stated.currency === cashCurrency) ? statedRateSummary(stated) : null;
|
|
241
234
|
const quoteFields = summary ?? statedFields;
|
|
242
|
-
let summaryError = !summary ? unavailableDividendSummary(triedAt, { forward: quoteFields != null, payDate: !!actions?.declaredCash?.announced?.payDate })
|
|
243
|
-
: response.data.summaryError ?? ([summary.exDividendDate, summary.dividendDate]
|
|
244
|
-
.some((timestamp) => timestamp != null && reportedDividendDate(timestamp) === null)
|
|
245
|
-
? INVALID_DIVIDEND_SUMMARY_DATE : undefined);
|
|
246
235
|
const summaryUnit = resolveCurrencyUnit(quoteFields?.currency);
|
|
247
236
|
const currency = cashCurrency || summaryUnit.currency;
|
|
248
237
|
let historyError = !actions && response.data.historyError ? unavailableDividendHistory(triedAt) : response.data.historyError;
|
|
@@ -261,7 +250,7 @@ export async function fetchDividendData(
|
|
|
261
250
|
const listed = cashCurrency ? distributions.flatMap(action => {
|
|
262
251
|
const payment = toDividendPayment(action.exDate, action.amount, cashCurrency);
|
|
263
252
|
const declared = declaredCash.get(action.exDate);
|
|
264
|
-
const source =
|
|
253
|
+
const source = dividendNoticeSource(action.source);
|
|
265
254
|
const row = payment ? { ...payment, paymentDate: action.payDate ? reportedDividendDate(Date.parse(action.payDate) / 1000) : null,
|
|
266
255
|
recordDate: action.recordDate ? reportedDividendDate(Date.parse(action.recordDate) / 1000) : null,
|
|
267
256
|
...(declared ? { declared } : {}), ...("cashEstimate" in action && action.cashEstimate ? { cashEstimate: action.cashEstimate } : {}),
|
|
@@ -321,9 +310,11 @@ export async function fetchDividendData(
|
|
|
321
310
|
metrics = repriceDividendMetrics({ ...metrics, forwardRate: atSourcePrecision(row.amount * annualCount) }, price);
|
|
322
311
|
}
|
|
323
312
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
313
|
+
const summaryError = !summary
|
|
314
|
+
? unavailableDividendSummary(triedAt, { forward: quoteFields != null || metrics.forwardRate != null, payDate: metrics.nextPayDate != null })
|
|
315
|
+
: response.data.summaryError ?? ([summary.exDividendDate, summary.dividendDate]
|
|
316
|
+
.some((timestamp) => timestamp != null && reportedDividendDate(timestamp) === null)
|
|
317
|
+
? INVALID_DIVIDEND_SUMMARY_DATE : undefined);
|
|
327
318
|
if (metrics.forwardRate != null && metrics.forwardBasis === "uneven" && metrics.trailingEstimates?.length) {
|
|
328
319
|
metrics.forwardEstimate = metrics.trailingEstimates.at(-1);
|
|
329
320
|
} else if (metrics.forwardRate != null && metrics.forwardBasis !== "uneven" && convertedFrom && (!announced || announced.paidAmount == null || !annualCount)) {
|
|
@@ -398,6 +389,7 @@ export function buildDividendMetrics(
|
|
|
398
389
|
declared?: readonly DeclaredDividendAction[] } = {},
|
|
399
390
|
): DividendMetrics {
|
|
400
391
|
const now = options.now ?? new Date();
|
|
392
|
+
const declared = options.declared ?? [];
|
|
401
393
|
const eligible = payments.filter((payment) => payment.exDate <= now && Number.isFinite(payment.amount) && payment.amount > 0);
|
|
402
394
|
// The trailing rate every trailing yield reads (trailingDividendRate), fundamentals' for a fund included.
|
|
403
395
|
const trailingRate = options.historyAvailable !== false
|
|
@@ -416,12 +408,18 @@ export function buildDividendMetrics(
|
|
|
416
408
|
if (reportedExDate && reportedExDate <= now) pastExDates.push(reportedExDate.getTime());
|
|
417
409
|
const latestExDate = pastExDates.length > 0 ? new Date(Math.max(...pastExDates)) : null;
|
|
418
410
|
const upcomingExDates = payments.filter((payment) => payment.exDate > now).map((payment) => payment.exDate.getTime());
|
|
411
|
+
const declaredExDates = declared.map((row) => Date.parse(row.exDate)).filter((time) => time > now.getTime());
|
|
412
|
+
upcomingExDates.push(...declaredExDates);
|
|
419
413
|
if (reportedExDate && reportedExDate > now) upcomingExDates.push(reportedExDate.getTime());
|
|
420
414
|
const nextExDividendDate = upcomingExDates.length > 0 ? new Date(Math.min(...upcomingExDates)) : null;
|
|
421
415
|
|
|
422
416
|
const reportedPayDate = reportedDividendDate(quoteFields?.dividendDate ?? null);
|
|
423
417
|
const today = new Date(now.toISOString().slice(0, 10));
|
|
424
418
|
const paymentDates = payments.flatMap((payment) => payment.paymentDate && payment.paymentDate >= today ? [payment.paymentDate] : []);
|
|
419
|
+
for (const row of declared) {
|
|
420
|
+
const date = new Date(row.payDate ?? "");
|
|
421
|
+
if (date >= today) paymentDates.push(date);
|
|
422
|
+
}
|
|
425
423
|
if (reportedPayDate && reportedPayDate >= today) paymentDates.push(reportedPayDate);
|
|
426
424
|
const nextPayDate = paymentDates.length ? new Date(Math.min(...paymentDates.map((date) => date.getTime()))) : null;
|
|
427
425
|
// A date the summary carries from the company's other listing names it, where it is the one shown.
|
|
@@ -432,7 +430,6 @@ export function buildDividendMetrics(
|
|
|
432
430
|
|
|
433
431
|
// A dividend that has stopped has no forward rate, whatever is still stated for it.
|
|
434
432
|
// Without a usable history only the latest date known says it, on the annual window.
|
|
435
|
-
const declared = options.declared ?? [];
|
|
436
433
|
// A monthly payer's history that stops short says so, and its forward rate, trailing yield and last ex-date stop with it:
|
|
437
434
|
// a rate stated for a distribution the history does not hold (IEF's as of 2026-11-02 beside its 2026-09-01) is not shown.
|
|
438
435
|
const historyEnd = options.historyAvailable !== false
|
|
@@ -208,7 +208,6 @@ export function projectDividendYieldHeadless(
|
|
|
208
208
|
// The issuer's own form's dividend type, where a form types the row ("Final", "Other Special Dividend").
|
|
209
209
|
...(payment?.formType ? { formType: payment.formType } : {}),
|
|
210
210
|
...(row.declared ? { declared: row.declared.amount, declaredCurrency: row.declared.currency } : {}),
|
|
211
|
-
...(payment?.source ? { source: payment.source.publisher, sourceUrl: payment.source.url } : {}),
|
|
212
211
|
};
|
|
213
212
|
});
|
|
214
213
|
// A listing paid in another currency than its company declares (South32's rand) has its amounts converted from that one.
|