gloomberb 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -54
- package/package.json +14 -13
- package/patches/{@opentui%2Fcore@0.1.90.patch → @opentui%2Fcore@0.3.2.patch} +175 -90
- package/src/api-client/chat.ts +8 -0
- package/src/api-client/index.test.ts +30 -0
- package/src/api-client/index.ts +4 -0
- package/src/api-client/normalizers.ts +1 -0
- package/src/api-client/types.ts +1 -0
- package/src/app/global-shortcuts.test.tsx +54 -4
- package/src/app/global-shortcuts.ts +11 -5
- package/src/capabilities/factories.ts +4 -0
- package/src/components/chart/comparison/data.test.ts +54 -0
- package/src/components/chart/comparison/data.ts +47 -24
- package/src/components/chart/core/projection.ts +51 -27
- package/src/components/command-bar/action-runtime.ts +1 -0
- package/src/components/command-bar/layout-items/current-layout.test.ts +115 -0
- package/src/components/command-bar/layout-items/current-layout.ts +33 -0
- package/src/components/command-bar/list/view.tsx +3 -1
- package/src/components/command-bar/pane-templates/items.ts +4 -1
- package/src/components/command-bar/panel/body.tsx +1 -0
- package/src/components/command-bar/routes/root/results.ts +0 -30
- package/src/components/command-bar/routes/root/runtime.ts +2 -20
- package/src/components/command-bar/routes/ticker-search/actions.ts +42 -4
- package/src/components/command-bar/routes/ticker-search/route.ts +4 -1
- package/src/components/command-bar/routing/launch-request.ts +14 -7
- package/src/components/command-bar/routing/list-state.ts +1 -3
- package/src/components/command-bar/surface/index.test.tsx +76 -4
- package/src/components/command-bar/surface/index.tsx +0 -2
- package/src/components/command-bar/surface/pane.test.tsx +1 -0
- package/src/components/command-bar/surface/test-harness.tsx +1 -0
- package/src/components/command-bar/view-model.ts +3 -3
- package/src/components/data-table/stack-view.test.tsx +14 -11
- package/src/components/data-table/stack-view.tsx +1 -2
- package/src/components/data-table/view.test.tsx +24 -18
- package/src/components/data-table/view.tsx +313 -83
- package/src/components/feed-data-table/stack-view.tsx +6 -8
- package/src/components/layout/pane/footer/index.test.tsx +6 -0
- package/src/components/layout/pane/footer/index.tsx +14 -2
- package/src/components/layout/pane/title.ts +5 -1
- package/src/components/layout/shell/index.test.tsx +120 -2
- package/src/components/layout/shell/index.tsx +2 -0
- package/src/components/layout/shell/menu.ts +1 -7
- package/src/components/layout/shell/pane/actions.ts +8 -0
- package/src/components/layout/shell/pane/management-shortcuts.ts +12 -2
- package/src/components/layout/shell/shortcuts.ts +14 -6
- package/src/components/layout/shell/window-mode/index.ts +8 -3
- package/src/components/layout/window-edit/presentation.ts +4 -4
- package/src/components/onboarding/onboarding-steps.tsx +3 -2
- package/src/components/pane-settings-dialog/field-dialogs.tsx +0 -2
- package/src/components/pane-settings-dialog/tui.tsx +1 -1
- package/src/components/ticker/list-table-view.tsx +17 -25
- package/src/components/ui/choice-dialog.tsx +12 -2
- package/src/components/ui/multi-select/dialog.tsx +17 -5
- package/src/components/ui/remote-image.tsx +1 -14
- package/src/components/ui/shortcut-hint.tsx +14 -2
- package/src/components/ui/table-layout.test.ts +2 -2
- package/src/components/ui/table-layout.ts +8 -2
- package/src/components/ui/tabs.tsx +115 -86
- package/src/components/ui/ui.test.tsx +83 -4
- package/src/core/state/app/types.ts +12 -4
- package/src/market-data/coordinator/auxiliary.ts +29 -1
- package/src/market-data/coordinator/index.ts +17 -1
- package/src/market-data/hooks.tsx +17 -1
- package/src/market-data/selectors.ts +4 -0
- package/src/plugins/builtin/account-management/form-components.tsx +0 -4
- package/src/plugins/builtin/account-management/model.test.ts +54 -0
- package/src/plugins/builtin/account-management/model.ts +13 -3
- package/src/plugins/builtin/account-management/pane.tsx +5 -11
- package/src/plugins/builtin/account-management/password-dialog.tsx +1 -1
- package/src/plugins/builtin/alerts/pane.tsx +5 -3
- package/src/plugins/builtin/analytics/index.tsx +0 -3
- package/src/plugins/builtin/analytics/view.tsx +6 -5
- package/src/plugins/builtin/broker-manager/index.tsx +6 -6
- package/src/plugins/builtin/buildout/pane/index.tsx +6 -6
- package/src/plugins/builtin/changelog/index.tsx +40 -27
- package/src/plugins/builtin/changelog/model.test.ts +77 -0
- package/src/plugins/builtin/changelog/model.ts +98 -0
- package/src/plugins/builtin/chat/channel-labels.ts +53 -0
- package/src/plugins/builtin/chat/channels.test.ts +28 -0
- package/src/plugins/builtin/chat/channels.ts +36 -19
- package/src/plugins/builtin/chat/chat.test.tsx +264 -5
- package/src/plugins/builtin/chat/content/channel-navigation.ts +50 -11
- package/src/plugins/builtin/chat/content/composer-runtime.test.tsx +144 -0
- package/src/plugins/builtin/chat/content/composer-runtime.ts +151 -20
- package/src/plugins/builtin/chat/content/composer.tsx +23 -2
- package/src/plugins/builtin/chat/content/index.tsx +66 -4
- package/src/plugins/builtin/chat/content/layout-metrics.ts +3 -1
- package/src/plugins/builtin/chat/content/shortcuts.ts +27 -1
- package/src/plugins/builtin/chat/content/transcript.tsx +8 -0
- package/src/plugins/builtin/chat/content/types.ts +1 -0
- package/src/plugins/builtin/chat/controller/index.ts +41 -0
- package/src/plugins/builtin/chat/controller/messages.ts +18 -0
- package/src/plugins/builtin/chat/controller/notifications.ts +10 -4
- package/src/plugins/builtin/chat/controller/utils.ts +6 -3
- package/src/plugins/builtin/chat/controller/view.ts +1 -1
- package/src/plugins/builtin/chat/controller.test.ts +189 -0
- package/src/plugins/builtin/chat/edit-window.ts +24 -0
- package/src/plugins/builtin/chat/layout.ts +94 -31
- package/src/plugins/builtin/chat/message/action-chip.tsx +1 -0
- package/src/plugins/builtin/chat/message/desktop.tsx +53 -20
- package/src/plugins/builtin/chat/message/inline-tokens.tsx +16 -10
- package/src/plugins/builtin/chat/message/render-state.ts +5 -1
- package/src/plugins/builtin/chat/message/terminal.tsx +49 -20
- package/src/plugins/builtin/chat/message/types.ts +2 -0
- package/src/plugins/builtin/chat/pane.tsx +35 -7
- package/src/plugins/builtin/chat/sidebar.test.tsx +72 -0
- package/src/plugins/builtin/chat/status-widget.tsx +29 -11
- package/src/plugins/builtin/chat/test-harness.tsx +2 -0
- package/src/plugins/builtin/cloud/plugin.tsx +3 -0
- package/src/plugins/builtin/cloud-tweets/table.tsx +7 -11
- package/src/plugins/builtin/congress-trades/pane.tsx +14 -22
- package/src/plugins/builtin/earnings/index.tsx +8 -7
- package/src/plugins/builtin/econ/index.tsx +6 -8
- package/src/plugins/builtin/help/components.tsx +1 -1
- package/src/plugins/builtin/help/index.test.tsx +105 -30
- package/src/plugins/builtin/help/index.tsx +326 -164
- package/src/plugins/builtin/help/shortcut-model.ts +5 -6
- package/src/plugins/builtin/holders/pane.tsx +7 -6
- package/src/plugins/builtin/market-movers/index.tsx +6 -3
- package/src/plugins/builtin/news/wire/news/table.tsx +7 -6
- package/src/plugins/builtin/options/view.tsx +16 -8
- package/src/plugins/builtin/portfolio-list/column-values.ts +304 -1
- package/src/plugins/builtin/portfolio-list/metrics.test.ts +93 -0
- package/src/plugins/builtin/portfolio-list/pane/data.ts +7 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +25 -2
- package/src/plugins/builtin/portfolio-list/pane/supplemental.ts +281 -0
- package/src/plugins/builtin/portfolio-list/settings.ts +27 -0
- package/src/plugins/builtin/portfolio-list/table.tsx +4 -2
- package/src/plugins/builtin/portfolio-list/use-throttled-cursor-symbol.ts +10 -68
- package/src/plugins/builtin/research/analyst-pane.tsx +1 -2
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +358 -7
- package/src/plugins/builtin/research/index.test.ts +30 -1
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +6 -8
- package/src/plugins/builtin/sec/filing-documents.ts +66 -0
- package/src/plugins/builtin/sec/index.tsx +132 -20
- package/src/plugins/builtin/sectors/index.tsx +13 -23
- package/src/plugins/builtin/shared/ticker-request.ts +1 -0
- package/src/plugins/builtin/substack/api/auth.ts +185 -0
- package/src/plugins/builtin/substack/api/cache.ts +78 -0
- package/src/plugins/builtin/substack/api/loaders.ts +146 -0
- package/src/plugins/builtin/substack/api/store.ts +186 -0
- package/src/plugins/builtin/substack/api/types.ts +40 -0
- package/src/plugins/builtin/substack/api.test.ts +298 -0
- package/src/plugins/builtin/substack/article-detail.tsx +359 -0
- package/src/plugins/builtin/substack/article-stack.tsx +129 -0
- package/src/plugins/builtin/substack/content.ts +478 -0
- package/src/plugins/builtin/substack/feed-tabs.tsx +41 -0
- package/src/plugins/builtin/substack/index.tsx +49 -0
- package/src/plugins/builtin/substack/login-view.tsx +126 -0
- package/src/plugins/builtin/substack/model.test.ts +155 -0
- package/src/plugins/builtin/substack/normalize.ts +343 -0
- package/src/plugins/builtin/substack/pane-footer.ts +71 -0
- package/src/plugins/builtin/substack/pane-state.ts +170 -0
- package/src/plugins/builtin/substack/pane.tsx +500 -0
- package/src/plugins/builtin/substack/table.ts +111 -0
- package/src/plugins/builtin/substack/types.ts +71 -0
- package/src/plugins/builtin/substack/utils.ts +131 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +26 -25
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/content.tsx +5 -4
- package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +5 -4
- package/src/plugins/builtin/ticker-detail/data-panes/provider-search.tsx +6 -5
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +10 -8
- package/src/plugins/builtin/ticker-detail/index.test.tsx +16 -2
- package/src/plugins/builtin/ticker-detail/index.tsx +1 -0
- package/src/plugins/builtin/ticker-detail/pane.tsx +13 -1
- package/src/plugins/builtin/world-indices/index.tsx +9 -6
- package/src/plugins/catalog-ui.ts +2 -0
- package/src/plugins/pane-manager/layout-state.ts +11 -0
- package/src/plugins/pane-manager.ts +1 -1
- package/src/plugins/prediction-markets/pane.tsx +10 -9
- package/src/plugins/registry/index.ts +3 -0
- package/src/plugins/runtime/context.tsx +1 -0
- package/src/plugins/runtime/index.tsx +4 -0
- package/src/react/use-throttled-commit-value.ts +116 -0
- package/src/renderers/electrobun/bun/desktop/http-fetch.test.ts +42 -0
- package/src/renderers/electrobun/bun/desktop/http-fetch.ts +5 -0
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +1 -0
- package/src/renderers/electrobun/view/data-table/index.tsx +3 -2
- package/src/renderers/electrobun/view/data-table/row.tsx +2 -2
- package/src/renderers/electrobun/view/host/input.tsx +23 -2
- package/src/renderers/electrobun/view/http-fetch.ts +10 -3
- package/src/renderers/electrobun/view/remote/asset-data-client.ts +1 -0
- package/src/sources/gloomberb-cloud/index.ts +4 -0
- package/src/sources/provider-router/cache.ts +1 -0
- package/src/sources/provider-router/document-routes.ts +45 -0
- package/src/sources/provider-router/index.ts +4 -0
- package/src/sources/sec-edgar/content.ts +9 -3
- package/src/sources/sec-edgar.test.ts +108 -1
- package/src/sources/sec-edgar.ts +105 -1
- package/src/sources/yahoo-finance.ts +4 -0
- package/src/state/app/context/index.test.tsx +16 -0
- package/src/test-support/plugin-runtime.ts +1 -0
- package/src/tickers/search/index.ts +1 -0
- package/src/types/data-provider.ts +11 -0
- package/src/ui/host.tsx +1 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef, useState, type Dispatch, type SetStateAction } from "react";
|
|
2
|
+
import type { ColumnConfig } from "../../../../types/config";
|
|
3
|
+
import type { AnalystResearchData, CorporateActionsData } from "../../../../types/financials";
|
|
4
|
+
import type { DataProvider, EarningsEvent } from "../../../../types/data-provider";
|
|
5
|
+
import type { TickerRecord } from "../../../../types/ticker";
|
|
6
|
+
import { useAssetData } from "../../../runtime";
|
|
7
|
+
import { loadEarningsCalendar } from "../../earnings/data/cache";
|
|
8
|
+
|
|
9
|
+
const SUPPLEMENTAL_BATCH_LIMIT = 6;
|
|
10
|
+
const ANALYST_COLUMN_IDS = new Set(["target", "target_pct", "rating"]);
|
|
11
|
+
const CORPORATE_COLUMN_IDS = new Set(["ex_div", "next_earn"]);
|
|
12
|
+
const EARNINGS_COLUMN_IDS = new Set(["next_earn"]);
|
|
13
|
+
|
|
14
|
+
interface SupplementalTarget {
|
|
15
|
+
symbol: string;
|
|
16
|
+
exchange: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface PortfolioSupplementalData {
|
|
20
|
+
analystResearch: Map<string, AnalystResearchData | null>;
|
|
21
|
+
corporateActions: Map<string, CorporateActionsData | null>;
|
|
22
|
+
earningsEvents: Map<string, EarningsEvent | null>;
|
|
23
|
+
version: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type SupplementalState = PortfolioSupplementalData;
|
|
27
|
+
|
|
28
|
+
function targetKey(targets: SupplementalTarget[]): string {
|
|
29
|
+
return targets.map((target) => `${target.symbol}:${target.exchange}`).join("|");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function targetsFromTickers(tickers: TickerRecord[]): SupplementalTarget[] {
|
|
33
|
+
return tickers.map((ticker) => ({
|
|
34
|
+
symbol: ticker.metadata.ticker,
|
|
35
|
+
exchange: ticker.metadata.exchange ?? "",
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function needsAnyColumn(columns: ColumnConfig[], ids: Set<string>): boolean {
|
|
40
|
+
return columns.some((column) => ids.has(column.id));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function pickMissingBatch<T>(
|
|
44
|
+
targets: SupplementalTarget[],
|
|
45
|
+
values: Map<string, T | null>,
|
|
46
|
+
inFlight: Set<string>,
|
|
47
|
+
): SupplementalTarget[] {
|
|
48
|
+
const batch: SupplementalTarget[] = [];
|
|
49
|
+
for (const target of targets) {
|
|
50
|
+
if (values.has(target.symbol) || inFlight.has(target.symbol)) continue;
|
|
51
|
+
batch.push(target);
|
|
52
|
+
if (batch.length >= SUPPLEMENTAL_BATCH_LIMIT) break;
|
|
53
|
+
}
|
|
54
|
+
return batch;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function markMissing<T>(
|
|
58
|
+
targets: SupplementalTarget[],
|
|
59
|
+
values: Map<string, T | null>,
|
|
60
|
+
): Map<string, T | null> | null {
|
|
61
|
+
let changed = false;
|
|
62
|
+
const next = new Map(values);
|
|
63
|
+
for (const target of targets) {
|
|
64
|
+
if (next.has(target.symbol)) continue;
|
|
65
|
+
next.set(target.symbol, null);
|
|
66
|
+
changed = true;
|
|
67
|
+
}
|
|
68
|
+
return changed ? next : null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function setAnalystValues(
|
|
72
|
+
current: SupplementalState,
|
|
73
|
+
entries: Array<readonly [string, AnalystResearchData | null]>,
|
|
74
|
+
): SupplementalState {
|
|
75
|
+
const analystResearch = new Map(current.analystResearch);
|
|
76
|
+
for (const [symbol, data] of entries) {
|
|
77
|
+
analystResearch.set(symbol, data);
|
|
78
|
+
}
|
|
79
|
+
return { ...current, analystResearch, version: current.version + 1 };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function setCorporateValues(
|
|
83
|
+
current: SupplementalState,
|
|
84
|
+
entries: Array<readonly [string, CorporateActionsData | null]>,
|
|
85
|
+
): SupplementalState {
|
|
86
|
+
const corporateActions = new Map(current.corporateActions);
|
|
87
|
+
for (const [symbol, data] of entries) {
|
|
88
|
+
corporateActions.set(symbol, data);
|
|
89
|
+
}
|
|
90
|
+
return { ...current, corporateActions, version: current.version + 1 };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function setEarningsValues(
|
|
94
|
+
current: SupplementalState,
|
|
95
|
+
symbols: string[],
|
|
96
|
+
events: EarningsEvent[],
|
|
97
|
+
): SupplementalState {
|
|
98
|
+
const eventsBySymbol = new Map<string, EarningsEvent>();
|
|
99
|
+
const now = Date.now();
|
|
100
|
+
for (const event of events) {
|
|
101
|
+
const symbol = event.symbol.trim().toUpperCase();
|
|
102
|
+
if (!symbol || event.earningsDate.getTime() < now) continue;
|
|
103
|
+
const currentEvent = eventsBySymbol.get(symbol);
|
|
104
|
+
if (!currentEvent || event.earningsDate < currentEvent.earningsDate) {
|
|
105
|
+
eventsBySymbol.set(symbol, event);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const earningsEvents = new Map(current.earningsEvents);
|
|
110
|
+
for (const symbol of symbols) {
|
|
111
|
+
earningsEvents.set(symbol, eventsBySymbol.get(symbol) ?? null);
|
|
112
|
+
}
|
|
113
|
+
return { ...current, earningsEvents, version: current.version + 1 };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function useAnalystSupplemental(
|
|
117
|
+
provider: DataProvider | null | undefined,
|
|
118
|
+
targets: SupplementalTarget[],
|
|
119
|
+
enabled: boolean,
|
|
120
|
+
state: SupplementalState,
|
|
121
|
+
setState: Dispatch<SetStateAction<SupplementalState>>,
|
|
122
|
+
) {
|
|
123
|
+
const inFlightRef = useRef(new Set<string>());
|
|
124
|
+
const targetsKey = targetKey(targets);
|
|
125
|
+
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if (!enabled || targets.length === 0) return;
|
|
128
|
+
if (!provider?.getAnalystResearch) {
|
|
129
|
+
setState((current) => {
|
|
130
|
+
const missing = markMissing(targets, current.analystResearch);
|
|
131
|
+
return missing ? { ...current, analystResearch: missing, version: current.version + 1 } : current;
|
|
132
|
+
});
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const batch = pickMissingBatch(targets, state.analystResearch, inFlightRef.current);
|
|
137
|
+
if (batch.length === 0) return;
|
|
138
|
+
for (const target of batch) inFlightRef.current.add(target.symbol);
|
|
139
|
+
|
|
140
|
+
let cancelled = false;
|
|
141
|
+
Promise.all(batch.map(async (target) => {
|
|
142
|
+
try {
|
|
143
|
+
const data = await provider.getAnalystResearch!(target.symbol, target.exchange);
|
|
144
|
+
return [target.symbol, data] as const;
|
|
145
|
+
} catch {
|
|
146
|
+
return [target.symbol, null] as const;
|
|
147
|
+
} finally {
|
|
148
|
+
inFlightRef.current.delete(target.symbol);
|
|
149
|
+
}
|
|
150
|
+
})).then((entries) => {
|
|
151
|
+
if (cancelled) return;
|
|
152
|
+
setState((current) => setAnalystValues(current, entries));
|
|
153
|
+
}).catch(() => {});
|
|
154
|
+
|
|
155
|
+
return () => {
|
|
156
|
+
cancelled = true;
|
|
157
|
+
};
|
|
158
|
+
}, [enabled, provider, setState, state.analystResearch, targetsKey]);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function useCorporateSupplemental(
|
|
162
|
+
provider: DataProvider | null | undefined,
|
|
163
|
+
targets: SupplementalTarget[],
|
|
164
|
+
enabled: boolean,
|
|
165
|
+
state: SupplementalState,
|
|
166
|
+
setState: Dispatch<SetStateAction<SupplementalState>>,
|
|
167
|
+
) {
|
|
168
|
+
const inFlightRef = useRef(new Set<string>());
|
|
169
|
+
const targetsKey = targetKey(targets);
|
|
170
|
+
|
|
171
|
+
useEffect(() => {
|
|
172
|
+
if (!enabled || targets.length === 0) return;
|
|
173
|
+
if (!provider?.getCorporateActions) {
|
|
174
|
+
setState((current) => {
|
|
175
|
+
const missing = markMissing(targets, current.corporateActions);
|
|
176
|
+
return missing ? { ...current, corporateActions: missing, version: current.version + 1 } : current;
|
|
177
|
+
});
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const batch = pickMissingBatch(targets, state.corporateActions, inFlightRef.current);
|
|
182
|
+
if (batch.length === 0) return;
|
|
183
|
+
for (const target of batch) inFlightRef.current.add(target.symbol);
|
|
184
|
+
|
|
185
|
+
let cancelled = false;
|
|
186
|
+
Promise.all(batch.map(async (target) => {
|
|
187
|
+
try {
|
|
188
|
+
const data = await provider.getCorporateActions!(target.symbol, target.exchange);
|
|
189
|
+
return [target.symbol, data] as const;
|
|
190
|
+
} catch {
|
|
191
|
+
return [target.symbol, null] as const;
|
|
192
|
+
} finally {
|
|
193
|
+
inFlightRef.current.delete(target.symbol);
|
|
194
|
+
}
|
|
195
|
+
})).then((entries) => {
|
|
196
|
+
if (cancelled) return;
|
|
197
|
+
setState((current) => setCorporateValues(current, entries));
|
|
198
|
+
}).catch(() => {});
|
|
199
|
+
|
|
200
|
+
return () => {
|
|
201
|
+
cancelled = true;
|
|
202
|
+
};
|
|
203
|
+
}, [enabled, provider, setState, state.corporateActions, targetsKey]);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function useEarningsSupplemental(
|
|
207
|
+
provider: DataProvider | null | undefined,
|
|
208
|
+
targets: SupplementalTarget[],
|
|
209
|
+
enabled: boolean,
|
|
210
|
+
state: SupplementalState,
|
|
211
|
+
setState: Dispatch<SetStateAction<SupplementalState>>,
|
|
212
|
+
) {
|
|
213
|
+
const inFlightRef = useRef(false);
|
|
214
|
+
const targetsKey = targetKey(targets);
|
|
215
|
+
|
|
216
|
+
useEffect(() => {
|
|
217
|
+
if (!enabled || targets.length === 0) return;
|
|
218
|
+
if (!provider?.getEarningsCalendar) {
|
|
219
|
+
setState((current) => {
|
|
220
|
+
const missing = markMissing(targets, current.earningsEvents);
|
|
221
|
+
return missing ? { ...current, earningsEvents: missing, version: current.version + 1 } : current;
|
|
222
|
+
});
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const missingSymbols = targets
|
|
227
|
+
.map((target) => target.symbol)
|
|
228
|
+
.filter((symbol) => !state.earningsEvents.has(symbol));
|
|
229
|
+
if (missingSymbols.length === 0 || inFlightRef.current) return;
|
|
230
|
+
|
|
231
|
+
inFlightRef.current = true;
|
|
232
|
+
let cancelled = false;
|
|
233
|
+
loadEarningsCalendar(provider, missingSymbols)
|
|
234
|
+
.then((events) => {
|
|
235
|
+
if (cancelled) return;
|
|
236
|
+
setState((current) => setEarningsValues(current, missingSymbols, events));
|
|
237
|
+
})
|
|
238
|
+
.catch(() => {
|
|
239
|
+
if (cancelled) return;
|
|
240
|
+
setState((current) => ({
|
|
241
|
+
...current,
|
|
242
|
+
earningsEvents: markMissing(
|
|
243
|
+
missingSymbols.map((symbol) => ({ symbol, exchange: "" })),
|
|
244
|
+
current.earningsEvents,
|
|
245
|
+
) ?? current.earningsEvents,
|
|
246
|
+
version: current.version + 1,
|
|
247
|
+
}));
|
|
248
|
+
})
|
|
249
|
+
.finally(() => {
|
|
250
|
+
inFlightRef.current = false;
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
return () => {
|
|
254
|
+
cancelled = true;
|
|
255
|
+
};
|
|
256
|
+
}, [enabled, provider, setState, state.earningsEvents, targetsKey]);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export function usePortfolioSupplementalData(
|
|
260
|
+
tickers: TickerRecord[],
|
|
261
|
+
columns: ColumnConfig[],
|
|
262
|
+
appActive: boolean,
|
|
263
|
+
): PortfolioSupplementalData {
|
|
264
|
+
const provider = useAssetData();
|
|
265
|
+
const targets = useMemo(() => targetsFromTickers(tickers), [tickers]);
|
|
266
|
+
const [state, setState] = useState<SupplementalState>(() => ({
|
|
267
|
+
analystResearch: new Map(),
|
|
268
|
+
corporateActions: new Map(),
|
|
269
|
+
earningsEvents: new Map(),
|
|
270
|
+
version: 0,
|
|
271
|
+
}));
|
|
272
|
+
const needsAnalyst = appActive && needsAnyColumn(columns, ANALYST_COLUMN_IDS);
|
|
273
|
+
const needsCorporate = appActive && needsAnyColumn(columns, CORPORATE_COLUMN_IDS);
|
|
274
|
+
const needsEarnings = appActive && needsAnyColumn(columns, EARNINGS_COLUMN_IDS);
|
|
275
|
+
|
|
276
|
+
useAnalystSupplemental(provider, targets, needsAnalyst, state, setState);
|
|
277
|
+
useCorporateSupplemental(provider, targets, needsCorporate, state, setState);
|
|
278
|
+
useEarningsSupplemental(provider, targets, needsEarnings, state, setState);
|
|
279
|
+
|
|
280
|
+
return state;
|
|
281
|
+
}
|
|
@@ -21,30 +21,57 @@ export interface CollectionEntry {
|
|
|
21
21
|
const PORTFOLIO_COLUMN_DEFS: ColumnConfig[] = [
|
|
22
22
|
...DEFAULT_COLUMNS,
|
|
23
23
|
{ id: PRICE_SPARKLINE_COLUMN_ID, label: PRICE_SPARKLINE_PERIOD_LABEL, width: 6, align: "left" },
|
|
24
|
+
{ id: "name", label: "NAME", width: 16, align: "left" },
|
|
25
|
+
{ id: "asset_type", label: "TYPE", width: 5, align: "left" },
|
|
26
|
+
{ id: "exchange", label: "EXCH", width: 8, align: "left" },
|
|
27
|
+
{ id: "currency", label: "CCY", width: 4, align: "left" },
|
|
28
|
+
{ id: "sector", label: "SECTOR", width: 14, align: "left" },
|
|
29
|
+
{ id: "industry", label: "INDUSTRY", width: 16, align: "left" },
|
|
30
|
+
{ id: "tags", label: "TAGS", width: 14, align: "left" },
|
|
31
|
+
{ id: "volume", label: "VOL", width: 8, align: "right", format: "compact" },
|
|
32
|
+
{ id: "dollar_volume", label: "$VOL", width: 9, align: "right", format: "compact" },
|
|
33
|
+
{ id: "range_52w", label: "52W%", width: 7, align: "right", format: "percent" },
|
|
24
34
|
{ id: "bid", label: "BID", width: 10, align: "right", format: "currency" },
|
|
25
35
|
{ id: "ask", label: "ASK", width: 10, align: "right", format: "currency" },
|
|
26
36
|
{ id: "spread", label: "SPREAD", width: 10, align: "right", format: "currency" },
|
|
37
|
+
{ id: "spread_pct", label: "SPR%", width: 7, align: "right", format: "percent" },
|
|
38
|
+
{ id: "bid_ask_size", label: "B/A SZ", width: 9, align: "right", format: "compact" },
|
|
27
39
|
{ id: "change", label: "CHG", width: 9, align: "right", format: "currency" },
|
|
28
40
|
{ id: "ext_hours", label: "EXT%", width: 8, align: "right", format: "percent" },
|
|
29
41
|
{ id: "dividend_yield", label: "DIV%", width: 7, align: "right", format: "percent" },
|
|
42
|
+
{ id: "target", label: "TARGET", width: 10, align: "right", format: "currency" },
|
|
43
|
+
{ id: "target_pct", label: "TARGET%", width: 8, align: "right", format: "percent" },
|
|
44
|
+
{ id: "rating", label: "RATING", width: 7, align: "right", format: "number" },
|
|
45
|
+
{ id: "ex_div", label: "EX-DIV", width: 7, align: "right" },
|
|
46
|
+
{ id: "next_earn", label: "ERN", width: 7, align: "right" },
|
|
47
|
+
{ id: "side", label: "SIDE", width: 5, align: "left" },
|
|
30
48
|
{ id: "shares", label: "SHARES", width: 9, align: "right", format: "number" },
|
|
31
49
|
{ id: "avg_cost", label: "AVG COST", width: 10, align: "right", format: "currency" },
|
|
32
50
|
{ id: "cost_basis", label: "COST", width: 10, align: "right", format: "compact" },
|
|
33
51
|
{ id: "mkt_value", label: "MKT VAL", width: 10, align: "right", format: "compact" },
|
|
52
|
+
{ id: "weight", label: "WEIGHT", width: 8, align: "right", format: "percent" },
|
|
34
53
|
{ id: "day_pnl", label: "DAY", width: 10, align: "right", format: "compact" },
|
|
35
54
|
{ id: "pnl", label: "P&L", width: 10, align: "right", format: "compact" },
|
|
36
55
|
{ id: "pnl_pct", label: "P&L%", width: 8, align: "right", format: "percent" },
|
|
56
|
+
{ id: "mark_delta", label: "MARK%", width: 8, align: "right", format: "percent" },
|
|
57
|
+
{ id: "acq_date", label: "ACQ", width: 7, align: "right" },
|
|
58
|
+
{ id: "held", label: "HELD", width: 6, align: "right" },
|
|
37
59
|
];
|
|
38
60
|
|
|
39
61
|
const PORTFOLIO_COLUMNS_BY_ID = new Map(PORTFOLIO_COLUMN_DEFS.map((column) => [column.id, column]));
|
|
40
62
|
const PORTFOLIO_ONLY_COLUMN_IDS = new Set([
|
|
63
|
+
"side",
|
|
41
64
|
"shares",
|
|
42
65
|
"avg_cost",
|
|
43
66
|
"cost_basis",
|
|
44
67
|
"mkt_value",
|
|
68
|
+
"weight",
|
|
45
69
|
"day_pnl",
|
|
46
70
|
"pnl",
|
|
47
71
|
"pnl_pct",
|
|
72
|
+
"mark_delta",
|
|
73
|
+
"acq_date",
|
|
74
|
+
"held",
|
|
48
75
|
]);
|
|
49
76
|
const COLLECTION_SCOPE_OPTIONS: PaneSettingOption[] = [
|
|
50
77
|
{
|
|
@@ -32,7 +32,7 @@ function buildCellVersion(
|
|
|
32
32
|
financials: TickerFinancials | undefined,
|
|
33
33
|
context: ColumnContext,
|
|
34
34
|
): string {
|
|
35
|
-
const
|
|
35
|
+
const timeSensitiveNow = column.id === "latency" || column.id === "held" ? context.now : 0;
|
|
36
36
|
return [
|
|
37
37
|
column.id,
|
|
38
38
|
objectVersion(ticker),
|
|
@@ -40,7 +40,9 @@ function buildCellVersion(
|
|
|
40
40
|
objectVersion(context.exchangeRates),
|
|
41
41
|
context.activeTab ?? "",
|
|
42
42
|
context.baseCurrency,
|
|
43
|
-
|
|
43
|
+
context.portfolioTotalMarketValue ?? 0,
|
|
44
|
+
context.supplementalVersion ?? 0,
|
|
45
|
+
timeSensitiveNow,
|
|
44
46
|
].join("|");
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useThrottledCommitValue } from "../../../react/use-throttled-commit-value";
|
|
2
2
|
|
|
3
3
|
const FOLLOW_CURSOR_THROTTLE_MS = 150;
|
|
4
4
|
|
|
@@ -7,75 +7,17 @@ export function useThrottledCursorSymbol(
|
|
|
7
7
|
setCommittedCursorSymbol: (symbol: string | null) => void,
|
|
8
8
|
throttleMs = FOLLOW_CURSOR_THROTTLE_MS,
|
|
9
9
|
) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const clearPendingCursorCommit = useCallback(() => {
|
|
17
|
-
if (commitTimerRef.current) {
|
|
18
|
-
clearTimeout(commitTimerRef.current);
|
|
19
|
-
commitTimerRef.current = null;
|
|
20
|
-
}
|
|
21
|
-
hasPendingCommitRef.current = false;
|
|
22
|
-
}, []);
|
|
23
|
-
|
|
24
|
-
const commitCursorSymbol = useCallback((nextCursorSymbol?: string | null) => {
|
|
25
|
-
const targetCursorSymbol = nextCursorSymbol ?? pendingCursorSymbolRef.current;
|
|
26
|
-
clearPendingCursorCommit();
|
|
27
|
-
pendingCursorSymbolRef.current = targetCursorSymbol;
|
|
28
|
-
|
|
29
|
-
if (Object.is(appliedCursorSymbolRef.current, targetCursorSymbol)) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
appliedCursorSymbolRef.current = targetCursorSymbol;
|
|
34
|
-
setCommittedCursorSymbol(targetCursorSymbol);
|
|
35
|
-
}, [clearPendingCursorCommit, setCommittedCursorSymbol]);
|
|
36
|
-
|
|
37
|
-
const scheduleCursorSymbol = useCallback((nextCursorSymbol: string | null, options?: { immediate?: boolean }) => {
|
|
38
|
-
setCursorSymbolState((current) => (Object.is(current, nextCursorSymbol) ? current : nextCursorSymbol));
|
|
39
|
-
pendingCursorSymbolRef.current = nextCursorSymbol;
|
|
40
|
-
|
|
41
|
-
if (options?.immediate) {
|
|
42
|
-
commitCursorSymbol(nextCursorSymbol);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
clearPendingCursorCommit();
|
|
47
|
-
|
|
48
|
-
if (Object.is(appliedCursorSymbolRef.current, nextCursorSymbol)) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
hasPendingCommitRef.current = true;
|
|
53
|
-
commitTimerRef.current = setTimeout(() => {
|
|
54
|
-
commitCursorSymbol();
|
|
55
|
-
}, throttleMs);
|
|
56
|
-
}, [clearPendingCursorCommit, commitCursorSymbol, throttleMs]);
|
|
57
|
-
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (hasPendingCommitRef.current && Object.is(committedCursorSymbol, pendingCursorSymbolRef.current)) {
|
|
60
|
-
clearPendingCursorCommit();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (!hasPendingCommitRef.current) {
|
|
64
|
-
appliedCursorSymbolRef.current = committedCursorSymbol;
|
|
65
|
-
setCursorSymbolState((current) => (Object.is(current, committedCursorSymbol) ? current : committedCursorSymbol));
|
|
66
|
-
}
|
|
67
|
-
}, [clearPendingCursorCommit, committedCursorSymbol]);
|
|
68
|
-
|
|
69
|
-
useEffect(() => () => {
|
|
70
|
-
if (commitTimerRef.current) {
|
|
71
|
-
clearTimeout(commitTimerRef.current);
|
|
72
|
-
}
|
|
73
|
-
}, []);
|
|
10
|
+
const {
|
|
11
|
+
value: cursorSymbol,
|
|
12
|
+
setValue,
|
|
13
|
+
flushValue,
|
|
14
|
+
cancelPendingValue,
|
|
15
|
+
} = useThrottledCommitValue(committedCursorSymbol, setCommittedCursorSymbol, throttleMs);
|
|
74
16
|
|
|
75
17
|
return {
|
|
76
18
|
cursorSymbol,
|
|
77
|
-
setCursorSymbol:
|
|
78
|
-
flushCursorSymbol:
|
|
79
|
-
cancelPendingCursorSymbol:
|
|
19
|
+
setCursorSymbol: setValue,
|
|
20
|
+
flushCursorSymbol: flushValue,
|
|
21
|
+
cancelPendingCursorSymbol: cancelPendingValue,
|
|
80
22
|
};
|
|
81
23
|
}
|
|
@@ -364,6 +364,7 @@ export function AnalystResearchView({ focused, width, height }: { focused: boole
|
|
|
364
364
|
return (
|
|
365
365
|
<DataTableView<AnalystResearchData["ratings"][number], RatingColumn>
|
|
366
366
|
focused={focused}
|
|
367
|
+
selection={{ kind: "none" }}
|
|
367
368
|
rootWidth={width}
|
|
368
369
|
rootHeight={height}
|
|
369
370
|
rootBefore={<AnalystSummary data={data} />}
|
|
@@ -374,8 +375,6 @@ export function AnalystResearchView({ focused, width, height }: { focused: boole
|
|
|
374
375
|
sortDirection={sortPreference.direction}
|
|
375
376
|
onHeaderClick={handleHeaderClick}
|
|
376
377
|
getItemKey={(row, index) => `${row.date}:${row.firm}:${index}`}
|
|
377
|
-
isSelected={() => false}
|
|
378
|
-
onSelect={() => {}}
|
|
379
378
|
renderCell={renderCell}
|
|
380
379
|
emptyStateTitle={loading ? "Loading analyst data..." : error ?? "No analyst data"}
|
|
381
380
|
/>
|