gloomberb 0.20.13 → 0.20.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/patches/@opentui%2Fcore@0.3.2.patch +22 -4
- package/src/account/auth-dialog.tsx +22 -4
- package/src/account/auth-form.tsx +6 -1
- package/src/account/checkout-handoff.tsx +7 -14
- package/src/account/device-signin-dialog.tsx +35 -24
- package/src/api-client/crypto-markets.ts +10 -0
- package/src/api-client/errors.ts +3 -1
- package/src/api-client/index.ts +54 -0
- package/src/api-client/install-experiments.ts +8 -7
- package/src/api-client/money-markets.ts +7 -0
- package/src/api-client/paths.ts +2 -1
- package/src/api-client/product-waitlist.ts +63 -0
- package/src/api-client/request.ts +16 -4
- package/src/api-client/types/billing.ts +45 -0
- package/src/api-client/yearly-plan.ts +132 -0
- package/src/app/global-shortcuts.ts +5 -3
- package/src/app/pane-runtime/index.tsx +2 -2
- package/src/app/pane-runtime/plugin-bindings.ts +3 -1
- package/src/app/pane-runtime/ticker-open-runtime.ts +6 -1
- package/src/app/since-last-visit/keys.ts +26 -0
- package/src/app/since-last-visit/model.ts +266 -0
- package/src/app/since-last-visit/strip.tsx +193 -0
- package/src/app/since-last-visit/use-since-last-visit.ts +289 -0
- package/src/app/since-last-visit/visit-tracker.ts +191 -0
- package/src/app.tsx +15 -0
- package/src/architecture/floating-promise-allowlist.json +0 -1
- package/src/brokers/signed-in/sign-in-dialog.tsx +38 -38
- package/src/cli/commands/market.ts +103 -27
- package/src/cli/commands/overview.ts +18 -4
- package/src/cli/commands/system.ts +29 -1
- package/src/cli/commands/ticker.ts +12 -5
- package/src/cli/desktop-pane-shot-api-policy.ts +4 -1
- package/src/cli/desktop-pane-shot-browser.ts +2 -1
- package/src/cli/desktop-pane-shot-view.ts +3 -7
- package/src/cli/desktop-pane-shot.ts +26 -28
- package/src/cli/errors.ts +3 -1
- package/src/cli/freshness.ts +7 -2
- package/src/cli/glossary.ts +10 -5
- package/src/cli/help.ts +1 -0
- package/src/cli/helpers.ts +8 -16
- package/src/cli/history-export.ts +4 -0
- package/src/cli/history-rows.ts +24 -0
- package/src/cli/index.ts +4 -0
- package/src/cli/known-gaps.ts +2 -2
- package/src/cli/listing-arg.ts +79 -11
- package/src/cli/not-a-ticker.ts +4 -0
- package/src/cli/options.ts +29 -1
- package/src/cli/pane-functions/catalog.ts +70 -12
- package/src/cli/pane-functions/function-help.ts +1 -1
- package/src/cli/pane-functions/headless.ts +68 -3
- package/src/cli/pane-functions/index.ts +2 -2
- package/src/cli/pane-functions/options.ts +7 -0
- package/src/cli/pane-functions/resolver.ts +104 -15
- package/src/cli/pane-functions/screenshot-payload.ts +3 -0
- package/src/cli/report-tables.ts +20 -5
- package/src/cli/result.ts +22 -4
- package/src/cli/shot-temp-dir.ts +30 -0
- package/src/cli/suffixed-listing-rows.ts +11 -0
- package/src/cli/symbol-args.ts +5 -3
- package/src/cli/symbol-list.ts +23 -10
- package/src/cli/symbol-rows.ts +135 -3
- package/src/cli/treasury-yields.ts +15 -1
- package/src/components/chart/composite/composite-chart.tsx +3 -3
- package/src/components/chart/composite/format.ts +2 -1
- package/src/components/chart/composite/panel-surface/axis-markers.ts +133 -0
- package/src/components/chart/composite/panel-surface/level-labels.tsx +78 -0
- package/src/components/chart/composite/panel-surface/overlays.ts +108 -0
- package/src/components/chart/composite/panel-surface/pan-coast.ts +54 -0
- package/src/components/chart/composite/panel-surface/panel-cursor.tsx +138 -0
- package/src/components/chart/composite/panel-surface/panel-levels.ts +47 -0
- package/src/components/chart/composite/panel-surface/plot-gestures.ts +403 -0
- package/src/components/chart/composite/panel-surface/plot-pointer.ts +65 -0
- package/src/components/chart/composite/panel-surface/plot-wheel.ts +102 -0
- package/src/components/chart/composite/panel-surface/pointer.ts +12 -0
- package/src/components/chart/composite/panel-surface/props.ts +79 -0
- package/src/components/chart/composite/panel-surface/tool-readout.ts +151 -0
- package/src/components/chart/composite/panel-surface/value-axis-gestures.ts +152 -0
- package/src/components/chart/composite/panel-surface.tsx +81 -1177
- package/src/components/command-bar/commands/collection-list.ts +1 -0
- package/src/components/command-bar/commands/direct/index.ts +31 -8
- package/src/components/command-bar/commands/registry.ts +7 -0
- package/src/components/command-bar/routes/root/command-items.ts +8 -0
- package/src/components/command-bar/routes/root/results.ts +19 -2
- package/src/components/command-bar/routes/root/runtime.ts +3 -2
- package/src/components/command-bar/routes/root/selection.ts +3 -2
- package/src/components/command-bar/routes/root/shortcuts.ts +15 -0
- package/src/components/company-logo.tsx +10 -3
- package/src/components/data-table/sections.ts +6 -1
- package/src/components/layout/pane/title.ts +16 -6
- package/src/components/layout/shell/index.tsx +5 -1
- package/src/components/layout/shell/ticker-link-menu.ts +12 -9
- package/src/components/pane-settings-dialog/tui.tsx +6 -3
- package/src/components/pane-settings-dialog.tsx +2 -1
- package/src/components/pane-template-wizard.tsx +2 -0
- package/src/components/ticker/badge/format.ts +12 -3
- package/src/components/ticker/badge/index.tsx +9 -3
- package/src/components/ticker/list-table-view.tsx +119 -17
- package/src/components/ui/choice-dialog.tsx +1 -1
- package/src/components/ui/confirm-dialog.tsx +3 -2
- package/src/components/ui/data-table/display-columns.ts +16 -0
- package/src/components/ui/data-table/index.tsx +40 -9
- package/src/components/ui/data-table/types.ts +14 -0
- package/src/components/ui/frame.tsx +7 -3
- package/src/components/ui/icon.tsx +4 -2
- package/src/components/ui/list-view.tsx +8 -0
- package/src/components/ui/number-prompt-dialog.tsx +2 -1
- package/src/components/use-pane-notice-footer.tsx +3 -1
- package/src/core/state/app/layout-reducer.ts +3 -1
- package/src/core/state/app/layout.ts +2 -2
- package/src/data/config/layout.ts +14 -0
- package/src/data/config/store/normalize.ts +11 -1
- package/src/docs/snapshot.json +2 -2
- package/src/i18n/es.ts +39 -0
- package/src/i18n/ja.ts +39 -0
- package/src/i18n/ko.ts +39 -0
- package/src/i18n/zh-cn.ts +39 -0
- package/src/i18n/zh-tw.ts +39 -0
- package/src/layout/pane-follow.ts +141 -4
- package/src/layout/pane-layout-move.ts +10 -7
- package/src/layout/ticker-navigation.ts +13 -19
- package/src/layout/ticker-retarget.ts +3 -2
- package/src/market-data/market/format.ts +35 -1
- package/src/market-data/market/index-level.ts +19 -0
- package/src/market-data/quotes/contributions.ts +13 -0
- package/src/market-data/quotes/export-identity.ts +36 -1
- package/src/market-data/quotes/resolution.ts +16 -0
- package/src/plugins/builtin/account-management/keyboard.ts +14 -0
- package/src/plugins/builtin/account-management/model.ts +2 -0
- package/src/plugins/builtin/account-management/pane.tsx +79 -7
- package/src/plugins/builtin/account-management/password-dialog.tsx +2 -2
- package/src/plugins/builtin/account-management/payment-recovery-row.tsx +97 -0
- package/src/plugins/builtin/account-management/yearly-plan-row.tsx +359 -0
- package/src/plugins/builtin/analytics/risk-client.ts +12 -2
- package/src/plugins/builtin/analytics/risk-headless.ts +66 -6
- package/src/plugins/builtin/analytics/risk-math.ts +23 -6
- package/src/plugins/builtin/analytics/risk-model.ts +20 -9
- package/src/plugins/builtin/analytics/risk-pane.tsx +2 -2
- package/src/plugins/builtin/awards/pane.tsx +6 -8
- package/src/plugins/builtin/changelog/index.tsx +6 -44
- package/src/plugins/builtin/changelog/versions.ts +17 -68
- package/src/plugins/builtin/chart-composer/catalog-inventory.ts +5 -2
- package/src/plugins/builtin/chart-composer/editor.tsx +1 -0
- package/src/plugins/builtin/chart-composer/pane.tsx +1 -1
- package/src/plugins/builtin/chart-composer/quick-add.tsx +4 -1
- package/src/plugins/builtin/chart-composer/series-catalog.ts +17 -1
- package/src/plugins/builtin/cloud/askg/executor.ts +2 -1
- package/src/plugins/builtin/cloud/askg/sources.ts +2 -1
- package/src/plugins/builtin/cloud/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/thesis/module.tsx +2 -0
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +6 -2
- package/src/plugins/builtin/cpi/headless.ts +6 -1
- package/src/plugins/builtin/cpi/model.ts +17 -0
- package/src/plugins/builtin/cpi/pane.tsx +4 -2
- package/src/plugins/builtin/crypto-board/client.ts +6 -1
- package/src/plugins/builtin/crypto-board/headless.ts +10 -2
- package/src/plugins/builtin/crypto-board/model.ts +89 -11
- package/src/plugins/builtin/crypto-board/pane.tsx +20 -5
- package/src/plugins/builtin/debt-maturities/model.ts +1 -1
- package/src/plugins/builtin/dividend-yield/client.ts +24 -2
- package/src/plugins/builtin/dividend-yield/headless.ts +4 -2
- package/src/plugins/builtin/dividend-yield/ranking.ts +2 -1
- package/src/plugins/builtin/dividend-yield/view.ts +5 -1
- package/src/plugins/builtin/earnings/board-table.ts +1 -1
- package/src/plugins/builtin/earnings/board.tsx +36 -16
- package/src/plugins/builtin/earnings/highlight.ts +47 -0
- package/src/plugins/builtin/earnings/history-table.ts +9 -1
- package/src/plugins/builtin/earnings/index.tsx +1 -1
- package/src/plugins/builtin/earnings-calls/pane.tsx +2 -2
- package/src/plugins/builtin/earnings-ripple/index.tsx +2 -0
- package/src/plugins/builtin/econ/calendar-model.ts +17 -1
- package/src/plugins/builtin/econ/fred-catalog.ts +33 -4
- package/src/plugins/builtin/econ-statistics/headless.ts +21 -0
- package/src/plugins/builtin/estimate-revisions/model.ts +1 -1
- package/src/plugins/builtin/exposure/index.tsx +1 -1
- package/src/plugins/builtin/macro-day/headless.ts +21 -10
- package/src/plugins/builtin/macro-day/model.ts +42 -3
- package/src/plugins/builtin/macro-day/pane.tsx +26 -8
- package/src/plugins/builtin/macro-day/releases.ts +24 -1
- package/src/plugins/builtin/market-valuation/detail.tsx +3 -3
- package/src/plugins/builtin/market-valuation/headless.ts +11 -4
- package/src/plugins/builtin/market-valuation/pane.tsx +3 -1
- package/src/plugins/builtin/market-valuation/view.ts +14 -0
- package/src/plugins/builtin/money-markets/client.ts +4 -1
- package/src/plugins/builtin/money-markets/headless.ts +15 -4
- package/src/plugins/builtin/money-markets/index.tsx +1 -1
- package/src/plugins/builtin/money-markets/pane.tsx +7 -1
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +20 -8
- package/src/plugins/builtin/pe-band/pane.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -2
- package/src/plugins/builtin/portfolio-list/cli/period-report.ts +61 -11
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +11 -3
- package/src/plugins/builtin/portfolio-list/cli/render.ts +8 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +178 -17
- package/src/plugins/builtin/portfolio-list/headless.ts +33 -6
- package/src/plugins/builtin/portfolio-list/pane/groups.tsx +220 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +95 -18
- package/src/plugins/builtin/portfolio-list/pane/period-pnl.ts +24 -6
- package/src/plugins/builtin/portfolio-list/period-pnl.ts +16 -1
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +4 -1
- package/src/plugins/builtin/portfolio-list/summary/totals.ts +6 -4
- package/src/plugins/builtin/portfolio-list/table.tsx +38 -16
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +4 -2
- package/src/plugins/builtin/research/relative-valuation-headless.ts +15 -5
- package/src/plugins/builtin/research/relative-valuation-model.ts +7 -1
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +7 -4
- package/src/plugins/builtin/shared/cloud-upgrade.ts +4 -2
- package/src/plugins/builtin/shared/cpi-year-gap.ts +67 -0
- package/src/plugins/builtin/shared/headless-options.ts +1 -1
- package/src/plugins/builtin/social-mentions/model.ts +2 -2
- package/src/plugins/builtin/thirteenf/pane.tsx +1 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +45 -2
- package/src/plugins/builtin/ticker-detail/financials/model.ts +51 -16
- package/src/plugins/builtin/ticker-detail/financials/nopat.ts +16 -0
- package/src/plugins/builtin/ticker-detail/financials/ratios.ts +44 -13
- package/src/plugins/builtin/ticker-detail/financials/schema.ts +33 -2
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +4 -2
- package/src/plugins/builtin/ticker-detail/headless-schema.ts +30 -4
- package/src/plugins/builtin/ticker-detail/headless.ts +280 -35
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +4 -5
- package/src/plugins/builtin/ticker-detail/overview/model.ts +9 -2
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +10 -2
- package/src/plugins/builtin/ticker-detail/pharma-signals/eligibility.ts +32 -0
- package/src/plugins/builtin/ticker-detail/pharma-signals/tab.tsx +162 -0
- package/src/plugins/builtin/ticker-detail/pharma-signals/waitlist.ts +126 -0
- package/src/plugins/builtin/ticker-detail/research-groups.ts +6 -4
- package/src/plugins/builtin/ticker-detail/research-tabs.ts +11 -0
- package/src/portfolio/collection-name.ts +2 -1
- package/src/portfolio/column-values.ts +34 -12
- package/src/portfolio/listed-symbol.ts +4 -2
- package/src/portfolio/period-pnl.ts +51 -1
- package/src/portfolio/suffixed-listings.ts +3 -1
- package/src/portfolio/watchlist-groups.ts +212 -0
- package/src/react/ticker-source.ts +3 -1
- package/src/renderers/dom/dialog-host.tsx +5 -5
- package/src/renderers/dom/styles.css +7 -0
- package/src/renderers/electrobun/view/remote/capability-invoker.ts +1 -1
- package/src/renderers/opentui/dialog-host.tsx +3 -4
- package/src/sources/gloomberb-cloud/normalizers.ts +5 -0
- package/src/sources/provider-router/history.ts +5 -2
- package/src/state/app/bootstrap.ts +11 -0
- package/src/state/app/context/index.tsx +6 -0
- package/src/sync/collections-contributor.ts +5 -2
- package/src/sync/config-merge.ts +10 -2
- package/src/sync/sanitize.ts +28 -0
- package/src/telemetry/usage-counts.ts +17 -0
- package/src/test-support/plugin-persistence.ts +12 -0
- package/src/tickers/company-name-listing.ts +4 -3
- package/src/tickers/company-name.ts +19 -1
- package/src/tickers/instrument-coverage.ts +27 -0
- package/src/tickers/search/home-listing.ts +38 -1
- package/src/tickers/search/index.ts +3 -2
- package/src/tickers/search/ranking.ts +21 -2
- package/src/time-series/base-series.ts +4 -0
- package/src/time-series/chart-seed.ts +1 -1
- package/src/time-series/financial-period-coverage.ts +4 -12
- package/src/time-series/parsed-history-cache.ts +1 -1
- package/src/time-series/resolve.ts +1 -1
- package/src/time-series/types.ts +5 -2
- package/src/time-series/use-chart-resolution.ts +6 -1
- package/src/types/config.ts +32 -0
- package/src/types/financials.ts +13 -0
- package/src/types/headless.ts +7 -0
- package/src/types/plugin-context.ts +5 -0
- package/src/types/ticker.ts +14 -0
- package/src/ui/ascii-font.ts +1 -4
- package/src/ui/dialog-stack.ts +17 -0
- package/src/ui/dialog.tsx +6 -2
- package/src/utils/async-deadline.ts +2 -2
- package/src/utils/crypto-pair.ts +9 -0
- package/src/utils/csv.ts +44 -5
- package/src/utils/exchanges.ts +13 -0
- package/src/utils/financial-statements.ts +60 -3
- package/src/utils/futures-generic.ts +17 -0
- package/src/utils/trailing-dividend.ts +13 -3
|
@@ -115,7 +115,7 @@ import { withPurchaseDateCostFx } from "../../../../portfolio/cost-fx";
|
|
|
115
115
|
import { usePortfolioFuturesTerms } from "./futures-terms";
|
|
116
116
|
import { useFuturesFrontNotes } from "./futures-front";
|
|
117
117
|
import { usePurchaseDateCostFx } from "./purchase-date-fx";
|
|
118
|
-
import {
|
|
118
|
+
import { periodPnlLabel, periodPnlNotices, periodSummaryLines, usePanePeriodPnl } from "./period-pnl";
|
|
119
119
|
import type { LoadedPeriodPnl } from "../period-pnl";
|
|
120
120
|
import {
|
|
121
121
|
allocationFigures,
|
|
@@ -127,6 +127,10 @@ import {
|
|
|
127
127
|
} from "../../../../portfolio/allocation";
|
|
128
128
|
import { allocationSummaryRows, CASH_ROW_KEY } from "../allocation-rows";
|
|
129
129
|
import { useTargetWeightActions, type TargetRow } from "./target-weights";
|
|
130
|
+
import { groupIdOfRowKey, groupRowKey } from "../../../../components/ticker/list-table-view";
|
|
131
|
+
import { withoutWatchlistGroupSymbols } from "../../../../portfolio/watchlist-groups";
|
|
132
|
+
import { scheduleConfigSave } from "../../../../state/config-save-scheduler";
|
|
133
|
+
import { buildWatchlistTableGroups, toggleCollapsedGroup, useWatchlistGroupActions, type CollapsedGroup } from "./groups";
|
|
130
134
|
|
|
131
135
|
/** Columns that need the portfolio's total. */
|
|
132
136
|
const ALLOCATION_COLUMN_IDS = new Set(["weight", "drift", "trade", "trade_value"]);
|
|
@@ -142,6 +146,9 @@ const firstSortDirection = (columnId: string) => columnId === "drift" ? "desc" a
|
|
|
142
146
|
const NO_COLLECTION_SORTS: Record<string, CollectionSortPreference> = {};
|
|
143
147
|
/** What the pane's `cursorSummaryRow` holds while the cursor is on the CASH row. */
|
|
144
148
|
const CASH_SUMMARY_ROW = "cash";
|
|
149
|
+
/** What it holds, before the group's id, while the cursor is on a watchlist group's header. */
|
|
150
|
+
const GROUP_SUMMARY_ROW = "group:";
|
|
151
|
+
const NO_COLLAPSED_GROUPS: CollapsedGroup[] = [];
|
|
145
152
|
|
|
146
153
|
export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
147
154
|
const activateTicker = useTickerSourceActivate();
|
|
@@ -157,20 +164,29 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
157
164
|
|
|
158
165
|
const [currentCollectionId, setCurrentCollectionId] = usePaneStateValue<string>("collectionId", paneCollection.collectionId ?? "");
|
|
159
166
|
const [committedCursorSymbol, setCommittedCursorSymbol] = usePaneStateValue<string | null>("cursorSymbol", null);
|
|
160
|
-
// The CASH row's cursor
|
|
161
|
-
// read, only ever holds a ticker, and keeps the last one while the cursor is on
|
|
167
|
+
// The CASH row's and a group header's cursor have a key of their own: `cursorSymbol`, which followers, recent
|
|
168
|
+
// tickers and saved layouts read, only ever holds a ticker, and keeps the last one while the cursor is on them.
|
|
162
169
|
const [cursorSummaryRow, setCursorSummaryRow] = usePaneStateValue<string | null>("cursorSummaryRow", null);
|
|
163
|
-
const committedCursorRow = cursorSummaryRow === CASH_SUMMARY_ROW ? CASH_ROW_KEY
|
|
170
|
+
const committedCursorRow = cursorSummaryRow === CASH_SUMMARY_ROW ? CASH_ROW_KEY
|
|
171
|
+
: cursorSummaryRow?.startsWith(GROUP_SUMMARY_ROW) ? groupRowKey(cursorSummaryRow.slice(GROUP_SUMMARY_ROW.length))
|
|
172
|
+
: committedCursorSymbol;
|
|
164
173
|
const commitCursorRow = useCallback((row: string | null) => {
|
|
165
174
|
if (row === CASH_ROW_KEY) {
|
|
166
175
|
setCursorSummaryRow(CASH_SUMMARY_ROW);
|
|
167
176
|
return;
|
|
168
177
|
}
|
|
178
|
+
const group = groupIdOfRowKey(row);
|
|
179
|
+
if (group != null) {
|
|
180
|
+
setCursorSummaryRow(`${GROUP_SUMMARY_ROW}${group}`);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
169
183
|
setCursorSummaryRow(null);
|
|
170
184
|
setCommittedCursorSymbol(row);
|
|
171
185
|
}, [setCommittedCursorSymbol, setCursorSummaryRow]);
|
|
172
186
|
const [collectionSorts, setCollectionSorts] = usePaneStateValue<Record<string, CollectionSortPreference>>("collectionSorts", NO_COLLECTION_SORTS);
|
|
173
187
|
const [cashDrawerExpanded, setCashDrawerExpanded] = usePaneStateValue<boolean>("cashDrawerExpanded", false);
|
|
188
|
+
// The watchlist groups this pane shows collapsed, of any list.
|
|
189
|
+
const [collapsedGroups, setCollapsedGroups] = usePaneStateValue<CollapsedGroup[]>("collapsedGroups", NO_COLLAPSED_GROUPS);
|
|
174
190
|
const [, setViewMode] = usePaneSettingValue<PortfolioViewMode>("viewMode", "table");
|
|
175
191
|
const updateColumnIds = useOptionalPaneSettingUpdater(paneInstance?.instanceId ?? null, "columnIds");
|
|
176
192
|
|
|
@@ -204,6 +220,9 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
204
220
|
? config.portfolios.find((portfolio) => portfolio.id === activeCollectionId) ?? null
|
|
205
221
|
: null
|
|
206
222
|
), [activeCollectionId, config.portfolios, isPortfolioTab]);
|
|
223
|
+
const currentWatchlist = useMemo(() => (
|
|
224
|
+
isPortfolioTab ? null : config.watchlists.find((watchlist) => watchlist.id === activeCollectionId) ?? null
|
|
225
|
+
), [activeCollectionId, config.watchlists, isPortfolioTab]);
|
|
207
226
|
const viewMode: PortfolioViewMode = isPortfolioTab ? paneSettings.viewMode : "table";
|
|
208
227
|
const valuationBasis = paneSettings.valueAtClose ? "regular-close" as const : "latest-print" as const;
|
|
209
228
|
|
|
@@ -373,7 +392,7 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
373
392
|
perpetualsVersion: perpetuals.version,
|
|
374
393
|
futuresTerms: futuresTerms.terms,
|
|
375
394
|
futuresTermsVersion: futuresTerms.version,
|
|
376
|
-
...(periodColumns ? { periodPnl: { rows: periodColumns.rows, pending: periodColumns.pending,
|
|
395
|
+
...(periodColumns ? { periodPnl: { rows: periodColumns.rows, pending: periodColumns.pending, lines: periodSummaryLines(periodColumns.result) }, periodPnlVersion: periodColumns.version } : {}),
|
|
377
396
|
}), [
|
|
378
397
|
activeCollectionId,
|
|
379
398
|
exchangeRates,
|
|
@@ -421,6 +440,22 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
421
440
|
}),
|
|
422
441
|
[orderedSymbols, tickerBySymbol],
|
|
423
442
|
);
|
|
443
|
+
// A watchlist with groups shows its rows under them, each group sorted on its own; any other list has none.
|
|
444
|
+
const tableGroups = useMemo(
|
|
445
|
+
() => viewMode === "table" ? buildWatchlistTableGroups(currentWatchlist, sortedTickers, collapsedGroups) : undefined,
|
|
446
|
+
[collapsedGroups, currentWatchlist, sortedTickers, viewMode],
|
|
447
|
+
);
|
|
448
|
+
// The rows the table shows, in its order: a collapsed group's are left out.
|
|
449
|
+
const displayedTickers = useMemo(
|
|
450
|
+
() => tableGroups ? tableGroups.flatMap((group) => group.collapsed ? [] : group.tickers) : sortedTickers,
|
|
451
|
+
[sortedTickers, tableGroups],
|
|
452
|
+
);
|
|
453
|
+
// The order quotes stream in: the rows shown, which the visible range counts, then a collapsed group's, off screen.
|
|
454
|
+
const streamOrder = useMemo(
|
|
455
|
+
() => tableGroups ? [...displayedTickers, ...tableGroups.flatMap((group) => group.collapsed ? group.tickers : [])] : sortedTickers,
|
|
456
|
+
[displayedTickers, sortedTickers, tableGroups],
|
|
457
|
+
);
|
|
458
|
+
const shownGroupKeys = useMemo(() => new Set(tableGroups?.map((group) => groupRowKey(group.id))), [tableGroups]);
|
|
424
459
|
|
|
425
460
|
// What LAST shows for each row, snapshotted when the table goes out of sight.
|
|
426
461
|
const priceColumn = viewMode === "table" ? columns.find((column) => column.id === "price") : undefined;
|
|
@@ -454,7 +489,7 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
454
489
|
getSharedMarketDataCoordinator()?.warmTickerGaps(instrument);
|
|
455
490
|
}, []);
|
|
456
491
|
const noteCursorForPrefetch = useCursorNeighborPrefetch({
|
|
457
|
-
tickers:
|
|
492
|
+
tickers: displayedTickers,
|
|
458
493
|
cursorSymbol,
|
|
459
494
|
portfolioId: financialsInstrumentOptions.portfolioId,
|
|
460
495
|
enabled: appActive,
|
|
@@ -506,12 +541,14 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
506
541
|
brokerPortfolio,
|
|
507
542
|
valuationBasis,
|
|
508
543
|
cashInTable: cashRowShown,
|
|
544
|
+
otherCurrencies,
|
|
509
545
|
period: periodColumns ? {
|
|
510
546
|
label: periodPnlLabel(periodColumns),
|
|
511
547
|
total: periodColumns.result?.total ?? null,
|
|
512
548
|
contribution: periodColumns.result?.totalContribution ?? null,
|
|
513
549
|
} : null,
|
|
514
|
-
}), [brokerPortfolio, cashRowShown, config.baseCurrency, convertAccountValue, isPortfolioTab, manualCash, periodColumns, portfolioSummaryTotals,
|
|
550
|
+
}), [brokerPortfolio, cashRowShown, config.baseCurrency, convertAccountValue, isPortfolioTab, manualCash, otherCurrencies, periodColumns, portfolioSummaryTotals,
|
|
551
|
+
summaryAccountState, totalsCurrency, valuationBasis]);
|
|
515
552
|
// The header row sits in the pane's one-cell side padding, like the table.
|
|
516
553
|
const summaryWidth = Math.max(0, width - 2);
|
|
517
554
|
const summaryLayout = useMemo(() => layoutPortfolioSummaryHeader(summarySegments, summaryWidth, {
|
|
@@ -636,25 +673,27 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
636
673
|
return;
|
|
637
674
|
}
|
|
638
675
|
|
|
639
|
-
// The cash row
|
|
640
|
-
const hasSelection = cursorSymbol && ((cursorSymbol === CASH_ROW_KEY && cashRowShown)
|
|
641
|
-
||
|
|
676
|
+
// The cash row and a group's header take the cursor too, while they are shown.
|
|
677
|
+
const hasSelection = cursorSymbol && ((cursorSymbol === CASH_ROW_KEY && cashRowShown) || shownGroupKeys.has(cursorSymbol)
|
|
678
|
+
|| displayedTickers.some((ticker) => ticker.metadata.ticker === cursorSymbol));
|
|
642
679
|
if (!hasSelection) {
|
|
643
|
-
|
|
680
|
+
// Every group collapsed: the first header.
|
|
681
|
+
const first = displayedTickers[0]?.metadata.ticker ?? (tableGroups?.[0] ? groupRowKey(tableGroups[0].id) : null);
|
|
682
|
+
if (first) setCursorSymbol(first, { immediate: true });
|
|
644
683
|
}
|
|
645
|
-
}, [cashRowShown, cursorSymbol, setCursorSymbol, sortedTickers]);
|
|
684
|
+
}, [cashRowShown, cursorSymbol, displayedTickers, setCursorSymbol, shownGroupKeys, sortedTickers.length, tableGroups]);
|
|
646
685
|
|
|
647
686
|
const effectiveStreamWindow = useMemo(() => (
|
|
648
687
|
viewMode === "grid"
|
|
649
688
|
? { start: 0, end: Math.min(sortedTickers.length, 96) }
|
|
650
689
|
: {
|
|
651
690
|
start: streamWindow.start,
|
|
652
|
-
end: Math.min(
|
|
691
|
+
end: Math.min(displayedTickers.length, Math.max(streamWindow.end, height + 4)),
|
|
653
692
|
}
|
|
654
|
-
), [height, sortedTickers.length, streamWindow, viewMode]);
|
|
693
|
+
), [displayedTickers.length, height, sortedTickers.length, streamWindow, viewMode]);
|
|
655
694
|
|
|
656
695
|
const perpetualsInViewKey = showsPerpetuals
|
|
657
|
-
?
|
|
696
|
+
? displayedTickers.slice(effectiveStreamWindow.start, effectiveStreamWindow.end).map((ticker) => ticker.metadata.ticker).join("\u001f")
|
|
658
697
|
: "";
|
|
659
698
|
useEffect(() => {
|
|
660
699
|
setPerpetualsInView(new Set(perpetualsInViewKey ? perpetualsInViewKey.split("\u001f") : []));
|
|
@@ -663,7 +702,7 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
663
702
|
usePortfolioPaneStreaming({
|
|
664
703
|
appActive,
|
|
665
704
|
activeCollectionId: isPortfolioTab ? activeCollectionId : undefined,
|
|
666
|
-
sortedTickers,
|
|
705
|
+
sortedTickers: streamOrder,
|
|
667
706
|
cursorSymbol,
|
|
668
707
|
streamWindow: effectiveStreamWindow,
|
|
669
708
|
isPortfolioTab,
|
|
@@ -719,8 +758,8 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
719
758
|
[activeCollectionId, config],
|
|
720
759
|
);
|
|
721
760
|
const selectedTicker = cursorSymbol ? tickerBySymbol.get(cursorSymbol) : undefined;
|
|
722
|
-
const sortedTickersRef = useRef(
|
|
723
|
-
sortedTickersRef.current =
|
|
761
|
+
const sortedTickersRef = useRef(displayedTickers);
|
|
762
|
+
sortedTickersRef.current = displayedTickers;
|
|
724
763
|
const removingRef = useRef(false);
|
|
725
764
|
// Asks first: a manual portfolio's position goes with the row, and a stray
|
|
726
765
|
// key should not take either.
|
|
@@ -750,6 +789,15 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
750
789
|
const symbols = sortedTickersRef.current.map((ticker) => ticker.metadata.ticker);
|
|
751
790
|
setCursorSymbol(cursorAfterRemoval(symbols, symbol), { immediate: true });
|
|
752
791
|
dispatch({ type: "UPDATE_TICKER", ticker: result.ticker });
|
|
792
|
+
// Out of its group too: added back later, it starts in none.
|
|
793
|
+
if (collection.kind === "watchlist") {
|
|
794
|
+
const config = appStateRef.current.config;
|
|
795
|
+
const next = withoutWatchlistGroupSymbols(config, collection.id, [symbol]);
|
|
796
|
+
if (next !== config) {
|
|
797
|
+
dispatch({ type: "SET_CONFIG", config: next });
|
|
798
|
+
scheduleConfigSave(next);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
753
801
|
notify({ type: "success", body: tf("Removed {symbol} from {collection}.", { symbol, collection: collection.name }) });
|
|
754
802
|
} catch {
|
|
755
803
|
notify({ type: "error", body: tf("Failed to remove {symbol}.", { symbol }) });
|
|
@@ -794,6 +842,32 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
794
842
|
const listedSymbols = useMemo(() => new Set(collectionTickers.map((ticker) => ticker.metadata.ticker)), [collectionTickers]);
|
|
795
843
|
useTargetWeightActions({ portfolio: currentPortfolio, row: targetRow, listedSymbols, enabled: focused && viewMode === "table" && !quickAddFocused });
|
|
796
844
|
|
|
845
|
+
// A group's header collapses or expands its rows; one collapsing with the cursor in it leaves the cursor on it.
|
|
846
|
+
const toggleGroup = useCallback((id: string) => {
|
|
847
|
+
const group = tableGroups?.find((entry) => entry.id === id);
|
|
848
|
+
if (!group || !activeCollectionId) return;
|
|
849
|
+
if (!group.collapsed && group.tickers.some((ticker) => ticker.metadata.ticker === cursorSymbol)) {
|
|
850
|
+
setCursorSymbol(groupRowKey(id), { immediate: true });
|
|
851
|
+
}
|
|
852
|
+
setCollapsedGroups((current) => toggleCollapsedGroup(current, activeCollectionId, id));
|
|
853
|
+
}, [activeCollectionId, cursorSymbol, setCollapsedGroups, setCursorSymbol, tableGroups]);
|
|
854
|
+
// A row moved to a group that is collapsed opens it, so the cursor stays on the row.
|
|
855
|
+
const showMovedRow = useCallback((symbol: string, group: string | null) => {
|
|
856
|
+
if (!activeCollectionId) return;
|
|
857
|
+
const id = group ?? "";
|
|
858
|
+
setCollapsedGroups((current) => current.filter((entry) => entry.list !== activeCollectionId || entry.group !== id));
|
|
859
|
+
setCursorSymbol(symbol, { immediate: true });
|
|
860
|
+
}, [activeCollectionId, setCollapsedGroups, setCursorSymbol]);
|
|
861
|
+
const cursorGroupId = groupIdOfRowKey(cursorSymbol);
|
|
862
|
+
const groupRowMenuItems = useWatchlistGroupActions({
|
|
863
|
+
watchlist: currentWatchlist,
|
|
864
|
+
cursorTicker: selectedTicker ?? null,
|
|
865
|
+
// Ungrouped has no name to change.
|
|
866
|
+
cursorGroup: cursorGroupId ? cursorGroupId : null,
|
|
867
|
+
enabled: focused && viewMode === "table" && !quickAddFocused,
|
|
868
|
+
onMoved: showMovedRow,
|
|
869
|
+
});
|
|
870
|
+
|
|
797
871
|
usePaneFooter("portfolio-list", () => ({
|
|
798
872
|
info: [
|
|
799
873
|
...offlineBrokerFooter.asOf,
|
|
@@ -940,6 +1014,9 @@ export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
|
940
1014
|
exportName={activeCollectionEntry?.name}
|
|
941
1015
|
allocationRows={allocationRows}
|
|
942
1016
|
columnReorder={columnReorder}
|
|
1017
|
+
groups={tableGroups}
|
|
1018
|
+
onToggleGroup={toggleGroup}
|
|
1019
|
+
rowMenuItems={groupRowMenuItems}
|
|
943
1020
|
/>
|
|
944
1021
|
) : (
|
|
945
1022
|
<PortfolioGrid
|
|
@@ -6,9 +6,11 @@ import type { PeriodPnlRow } from "../../../../portfolio/period-pnl";
|
|
|
6
6
|
import type { Quote, TickerFinancials } from "../../../../types/financials";
|
|
7
7
|
import type { TickerRecord } from "../../../../types/ticker";
|
|
8
8
|
import { errorMessage } from "../../../../utils/errors";
|
|
9
|
+
import { displayTickerKey } from "../../../../utils/exchanges";
|
|
9
10
|
import { readPriceWindow, type PriceWindow } from "../../../../utils/price-window";
|
|
10
11
|
import { useAssetData } from "../../../runtime";
|
|
11
|
-
import { loadPeriodPnl, periodBoughtText, periodUnpricedText, type LoadedPeriodPnl } from "../period-pnl";
|
|
12
|
+
import { loadPeriodPnl, periodBoughtText, periodCurrencyParts, periodFxLabel, periodUnpricedText, type LoadedPeriodPnl } from "../period-pnl";
|
|
13
|
+
import type { PeriodSummaryLine } from "../../../../portfolio/column-values";
|
|
12
14
|
|
|
13
15
|
export interface PanePeriodPnl {
|
|
14
16
|
window: PriceWindow | null;
|
|
@@ -40,10 +42,25 @@ export function periodPnlLabel(period: PanePeriodPnl): string {
|
|
|
40
42
|
return `P&L ${dayMonth(start)}–${dayMonth(end)}`;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
/**
|
|
46
|
+
* The lines under the rows of a book in more than one currency, a block per
|
|
47
|
+
* currency, the book's own first: its holdings' price P&L (`HKD local`), its
|
|
48
|
+
* FX line (`FX HKD`) and the two together (`HKD total`). The book's own
|
|
49
|
+
* currency has no FX, so its one line is its total. The rows and the FX lines
|
|
50
|
+
* add up to the header's total. Empty when every holding is in the book's
|
|
51
|
+
* currency, whose total the header gives; only the FX line when every holding
|
|
52
|
+
* is in one other currency, whose total is the header's too.
|
|
53
|
+
*/
|
|
54
|
+
export function periodSummaryLines(result: LoadedPeriodPnl | null): PeriodSummaryLine[] {
|
|
55
|
+
const parts = periodCurrencyParts(result ?? { currencies: [] });
|
|
56
|
+
if (parts.length === 1) return parts.map((part) => ({ id: `period-fx-${part.currency}`, label: periodFxLabel(part.currency), pnl: part.fx, contribution: part.fxContribution }));
|
|
57
|
+
return parts.flatMap((part): PeriodSummaryLine[] => part.own
|
|
58
|
+
? [{ id: `period-total-${part.currency}`, label: `${part.currency} total`, pnl: part.total, contribution: part.contribution }]
|
|
59
|
+
: [
|
|
60
|
+
{ id: `period-local-${part.currency}`, label: `${part.currency} local`, pnl: part.local, contribution: part.localContribution },
|
|
61
|
+
{ id: `period-fx-${part.currency}`, label: periodFxLabel(part.currency), pnl: part.fx, contribution: part.fxContribution },
|
|
62
|
+
{ id: `period-total-${part.currency}`, label: `${part.currency} total`, pnl: part.total, contribution: part.contribution },
|
|
63
|
+
]);
|
|
47
64
|
}
|
|
48
65
|
|
|
49
66
|
/** What the period's P&L leaves out or could not read, and the holdings bought inside it, for the pane's notices. */
|
|
@@ -51,7 +68,8 @@ export function periodPnlNotices(period: PanePeriodPnl | null): string[] {
|
|
|
51
68
|
if (!period) return [];
|
|
52
69
|
if (period.error) return [`P&L period: ${period.error}`];
|
|
53
70
|
if (!period.result) return [];
|
|
54
|
-
|
|
71
|
+
// Each holding by the listing it is (ES3:SGX), not a venue's code it is saved under (ES3:XSES).
|
|
72
|
+
return [periodUnpricedText(period.result, displayTickerKey), periodBoughtText(period.result, displayTickerKey)].filter((notice): notice is string => !!notice);
|
|
55
73
|
}
|
|
56
74
|
|
|
57
75
|
/** The pane's P&L From and To as `portfolio show --from --to` reads them, or why they do not read. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Quote } from "../../../types/financials";
|
|
2
2
|
import { loadCostFxRate, type CostFxHistoryClient } from "../../../portfolio/cost-fx";
|
|
3
3
|
import { withFuturesContractSize, isFuturesTicker, type PortfolioFuturesTerms } from "../../../portfolio/futures-positions";
|
|
4
|
-
import { periodCurrency, periodPnl, type PeriodClose, type PeriodPnl, type PeriodPnlHolding, type PeriodPnlRow } from "../../../portfolio/period-pnl";
|
|
4
|
+
import { periodCurrency, periodPnl, type PeriodClose, type PeriodCurrencyPnl, type PeriodPnl, type PeriodPnlHolding, type PeriodPnlRow } from "../../../portfolio/period-pnl";
|
|
5
5
|
import { getPortfolioPositionMetrics } from "../../../portfolio/position-metrics";
|
|
6
6
|
import { barSessionDay, periodDayText } from "../../../market-data/market/period-return";
|
|
7
7
|
import { quoteHeadlineTime } from "../../../market-data/market/status";
|
|
@@ -203,6 +203,21 @@ export function periodBasisText(result: LoadedPeriodPnl, { futuresHeld, now = Da
|
|
|
203
203
|
return `P&L from ${start} to ${end}${futures}, on the holdings held now`;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
+
/**
|
|
207
|
+
* The book by currency, as a report of the period lists it: each currency's
|
|
208
|
+
* price P&L, FX and total once the book holds a currency other than its own,
|
|
209
|
+
* the book's own first. Empty for a book in one currency, whose total says it.
|
|
210
|
+
*/
|
|
211
|
+
export function periodCurrencyParts(result: Pick<PeriodPnl, "currencies">): PeriodCurrencyPnl[] {
|
|
212
|
+
const parts = result.currencies ?? [];
|
|
213
|
+
return parts.some((part) => !part.own) ? parts : [];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** An FX line's label, as every report of a period writes it: `FX (HKD)`. */
|
|
217
|
+
export function periodFxLabel(currency: string): string {
|
|
218
|
+
return `FX (${currency})`;
|
|
219
|
+
}
|
|
220
|
+
|
|
206
221
|
/** `No P&L for GC=F (contract size unknown), 2382 (no close before 2020-03-18). The total leaves them out.` Null when every holding has one. */
|
|
207
222
|
export function periodUnpricedText(result: LoadedPeriodPnl, label: (symbol: string) => string = (symbol) => symbol): string | null {
|
|
208
223
|
if (!result.unpricedReasons.length) return null;
|
|
@@ -256,8 +256,11 @@ export function buildPortfolioSummarySegments({
|
|
|
256
256
|
valuationBasis,
|
|
257
257
|
period = null,
|
|
258
258
|
cashInTable = false,
|
|
259
|
+
otherCurrencies = false,
|
|
259
260
|
}: {
|
|
260
261
|
totals: PortfolioSummaryTotals;
|
|
262
|
+
/** The book holds a currency other than its own: its amounts name theirs ($1,179,156), a bare one beside HK$ prices being unclear. */
|
|
263
|
+
otherCurrencies?: boolean;
|
|
261
264
|
/** The table shows the cash as its own row (with its target and trade), so the header leaves it out. */
|
|
262
265
|
cashInTable?: boolean;
|
|
263
266
|
/**
|
|
@@ -281,7 +284,7 @@ export function buildPortfolioSummarySegments({
|
|
|
281
284
|
/** Cash entered by hand, in the totals currency, with the total it is weighed against. */
|
|
282
285
|
manualCash?: (PortfolioCashLine & { total: number | null }) | null;
|
|
283
286
|
}): PortfolioSummarySegment[] {
|
|
284
|
-
const money = (value: number | undefined, signed = false) => formatPortfolioAmount(value, currency, { signed, baseCurrency });
|
|
287
|
+
const money = (value: number | undefined, signed = false) => formatPortfolioAmount(value, currency, { signed, baseCurrency, named: otherCurrencies });
|
|
285
288
|
if (!isPortfolioTab) {
|
|
286
289
|
return totals.watchlistCount > 0
|
|
287
290
|
? [createSummarySegment("avg-day", [
|
|
@@ -104,16 +104,18 @@ function bookAmountText(value: number | undefined, currency: string, signed: boo
|
|
|
104
104
|
/**
|
|
105
105
|
* A total in the portfolio's currency (bookAmountText): never rounded to a
|
|
106
106
|
* hundred, as a compact 1.6k for $1,587.80 was. Bare when both it and the
|
|
107
|
-
* app's base currency are USD, as the pane has always shown it
|
|
108
|
-
*
|
|
107
|
+
* app's base currency are USD, as the pane has always shown it, unless the
|
|
108
|
+
* book holds another currency (`named`), beside whose prices a bare total
|
|
109
|
+
* would not say which it is in; otherwise it leads with the currency symbol,
|
|
110
|
+
* as prices do: A$108,612, +$600.12.
|
|
109
111
|
*/
|
|
110
112
|
export function formatPortfolioAmount(
|
|
111
113
|
value: number | undefined,
|
|
112
114
|
currency: string,
|
|
113
|
-
{ signed = false, baseCurrency = "USD" }: { signed?: boolean; baseCurrency?: string } = {},
|
|
115
|
+
{ signed = false, baseCurrency = "USD", named = false }: { signed?: boolean; baseCurrency?: string; named?: boolean } = {},
|
|
114
116
|
): string {
|
|
115
117
|
const text = bookAmountText(value, currency, signed);
|
|
116
|
-
const bare = currency === "USD" && (currencyCode(baseCurrency) ?? "USD") === "USD";
|
|
118
|
+
const bare = !named && currency === "USD" && (currencyCode(baseCurrency) ?? "USD") === "USD";
|
|
117
119
|
if (bare || value == null || !Number.isFinite(value)) return text;
|
|
118
120
|
const sign = text.startsWith("+") || text.startsWith("-") ? text.charAt(0) : "";
|
|
119
121
|
return `${sign}${getCurrencySymbol(currency)}${text.slice(sign.length)}`;
|
|
@@ -8,7 +8,8 @@ import { useDataTableSortMenu } from "../../../components/data-table/sort-menu";
|
|
|
8
8
|
import { followLiveSparklinePrice } from "../../../components/price-sparkline/model";
|
|
9
9
|
import { PRICE_SPARKLINE_COLUMN_ID } from "../../../components/price-sparkline/view";
|
|
10
10
|
import type { QuoteFlashDirection } from "../../../components/quote-flash";
|
|
11
|
-
import type { TickerTableCell, TickerTableSummaryRow } from "../../../components/ticker/list-table-view";
|
|
11
|
+
import type { TickerTableCell, TickerTableGroup, TickerTableSummaryRow } from "../../../components/ticker/list-table-view";
|
|
12
|
+
import type { ContextMenuItem } from "../../../types/context-menu";
|
|
12
13
|
import { createRowValueCache } from "../../../components/ui/row-value-cache";
|
|
13
14
|
import type { DataTableColumnReorder } from "../../../components/ui";
|
|
14
15
|
import type { ColumnConfig } from "../../../types/config";
|
|
@@ -74,6 +75,12 @@ const COMPANY_COLUMN_IDS: ReadonlySet<string> = new Set([
|
|
|
74
75
|
* still gives.
|
|
75
76
|
*/
|
|
76
77
|
const NARROW_BOOK_DROP_ORDER = ["forward_pe", "pe", "dividend_yield", "market_cap", "cost_basis", PRICE_SPARKLINE_COLUMN_ID, "as_of"];
|
|
78
|
+
/**
|
|
79
|
+
* What a narrow book over a period gives up next, so the period's P&L and
|
|
80
|
+
* CONTRIB stay on screen: today's columns (the day's P&L, its change, the
|
|
81
|
+
* latest price) and the cost a period's P&L does not read.
|
|
82
|
+
*/
|
|
83
|
+
const NARROW_PERIOD_DROP_ORDER = [...NARROW_BOOK_DROP_ORDER, "day_pnl", "change_pct", "avg_cost", "price"];
|
|
77
84
|
/** Columns of a held position: a list that shows one is a book, whose value outranks its valuation. */
|
|
78
85
|
const POSITION_COLUMN_IDS: ReadonlySet<string> = new Set(["shares", "avg_cost", "cost_basis", "mkt_value", "weight", "day_pnl", "pnl", "pnl_pct"]);
|
|
79
86
|
|
|
@@ -109,13 +116,15 @@ export function fitPortfolioColumns(
|
|
|
109
116
|
rows: readonly { cell: (column: ColumnConfig) => string; settled: boolean }[],
|
|
110
117
|
width: number | undefined,
|
|
111
118
|
hidden: ReadonlySet<string> = new Set(),
|
|
119
|
+
/** The book shows P&L over a period: today's columns go before its P&L and CONTRIB. */
|
|
120
|
+
period = false,
|
|
112
121
|
): ColumnConfig[] {
|
|
113
122
|
const settled = rows.length > 0 && rows.every((row) => row.settled);
|
|
114
123
|
const figured = (column: ColumnConfig) => rows.some((row) => row.settled && !isEmptyCell(row.cell(column)));
|
|
115
124
|
const shown = columns.filter((column) => !COMPANY_COLUMN_IDS.has(column.id)
|
|
116
125
|
|| (settled ? figured(column) : !hidden.has(column.id) || figured(column)));
|
|
117
126
|
if (width == null || !shown.some((column) => POSITION_COLUMN_IDS.has(column.id))) return shown;
|
|
118
|
-
return dropColumnsToFit(shown, width - 1, NARROW_BOOK_DROP_ORDER);
|
|
127
|
+
return dropColumnsToFit(shown, width - 1, period ? NARROW_PERIOD_DROP_ORDER : NARROW_BOOK_DROP_ORDER);
|
|
119
128
|
}
|
|
120
129
|
|
|
121
130
|
/** A cell recomputes only when its row's records or a context input it reads change. */
|
|
@@ -207,6 +216,9 @@ export function PortfolioTickerTable({
|
|
|
207
216
|
exportName,
|
|
208
217
|
allocationRows,
|
|
209
218
|
columnReorder,
|
|
219
|
+
groups,
|
|
220
|
+
onToggleGroup,
|
|
221
|
+
rowMenuItems,
|
|
210
222
|
}: {
|
|
211
223
|
columns: ColumnConfig[];
|
|
212
224
|
focused?: boolean;
|
|
@@ -245,6 +257,11 @@ export function PortfolioTickerTable({
|
|
|
245
257
|
allocationRows?: readonly TickerTableSummaryRow[];
|
|
246
258
|
/** Header drags rewrite the pane's Columns setting (`DataTableProps.columnReorder`). */
|
|
247
259
|
columnReorder?: DataTableColumnReorder;
|
|
260
|
+
/** A watchlist's groups, each holding its share of `sortedTickers` in their order. */
|
|
261
|
+
groups?: readonly TickerTableGroup[];
|
|
262
|
+
onToggleGroup?: (id: string) => void;
|
|
263
|
+
/** The pane's own items in a row's menu. */
|
|
264
|
+
rowMenuItems?: (ticker: TickerRecord) => ContextMenuItem[];
|
|
248
265
|
}) {
|
|
249
266
|
const cellCacheRef = useRef(createRowValueCache<string, ReturnType<typeof getColumnValue> & TickerTableCell>(5000));
|
|
250
267
|
const openPerpetualRef = useRef(onOpenPerpetual);
|
|
@@ -304,11 +321,13 @@ export function PortfolioTickerTable({
|
|
|
304
321
|
tableFinancialsMap.get(ticker.metadata.ticker)?.quote?.yearRangeBasis === "daily-bars")
|
|
305
322
|
? rangeColumn.width + displayWidth(RANGE_FROM_BARS_NOTE) + 1
|
|
306
323
|
: 0, [rangeColumn, sortedTickers, tableFinancialsMap]);
|
|
307
|
-
// The Ticker column grows to its longest symbol, so ETH-USD and BA:LSE show whole beside their market-state dot
|
|
324
|
+
// The Ticker column grows to its longest symbol, so ETH-USD and BA:LSE show whole beside their market-state dot,
|
|
325
|
+
// and to a period's lines under the rows (HKD total).
|
|
326
|
+
const summaryLabels = columnContext.periodPnl?.lines?.map((line) => line.label).join("\n") ?? "";
|
|
308
327
|
const tickerWidth = useMemo(() => Math.min(MAX_TICKER_COLUMN_WIDTH, sortedTickers.reduce(
|
|
309
328
|
(widest, ticker) => Math.max(widest, TICKER_DOT_WIDTH + displayWidth(listedSymbol(ticker, tickerDisplayName(ticker), columnContext.homeMarket))),
|
|
310
|
-
0,
|
|
311
|
-
)), [columnContext.homeMarket, sortedTickers]);
|
|
329
|
+
summaryLabels ? Math.max(...summaryLabels.split("\n").map((label) => TICKER_DOT_WIDTH + displayWidth(label))) : 0,
|
|
330
|
+
)), [columnContext.homeMarket, sortedTickers, summaryLabels]);
|
|
312
331
|
// A book that holds a short weighs its positions against gross exposure, and the header says so.
|
|
313
332
|
const grossWeights = columnContext.portfolioWeightBasis === "gross";
|
|
314
333
|
// Market caps, values and P&L read in the book's currency, which their headers name (MKT VAL (CAD)), as the CLI's do.
|
|
@@ -338,34 +357,34 @@ export function PortfolioTickerTable({
|
|
|
338
357
|
cell: (column: ColumnConfig) => resolveCell(column, ticker, financials).text,
|
|
339
358
|
settled: companyDataSettled(financials, !!answeredSnapshots?.has(ticker.metadata.ticker)),
|
|
340
359
|
};
|
|
341
|
-
}), width, hiddenCompanyRef.current.ids).map((column) => column.id));
|
|
360
|
+
}), width, hiddenCompanyRef.current.ids, period).map((column) => column.id));
|
|
342
361
|
return sizedColumns.filter((column) => !shown.has(column.id)).map((column) => column.id).join(",");
|
|
343
|
-
}, [answeredSnapshots, resolveCell, sizedColumns, sortedTickers, tableFinancialsMap, width]);
|
|
362
|
+
}, [answeredSnapshots, period, resolveCell, sizedColumns, sortedTickers, tableFinancialsMap, width]);
|
|
344
363
|
hiddenCompanyRef.current.ids = new Set(hiddenColumnIds.split(",").filter((id) => COMPANY_COLUMN_IDS.has(id)));
|
|
345
364
|
const displayColumns = useMemo(() => {
|
|
346
365
|
const hidden = new Set(hiddenColumnIds.split(","));
|
|
347
366
|
return hiddenColumnIds ? sizedColumns.filter((column) => !hidden.has(column.id)) : sizedColumns;
|
|
348
367
|
}, [hiddenColumnIds, sizedColumns]);
|
|
349
|
-
// Over a period,
|
|
350
|
-
const
|
|
368
|
+
// Over a period, each currency's part under the rows, so P&L adds up to the header's total as portfolio show --from prints it.
|
|
369
|
+
const periodLines = columnContext.periodPnl?.lines ?? null;
|
|
351
370
|
const summaryRows = useMemo<TickerTableSummaryRow[] | undefined>(() => {
|
|
352
371
|
// A row's label goes in TICKER, or the first column when the pane shows none.
|
|
353
372
|
const labelColumn = displayColumns.some((column) => column.id === "ticker") ? "ticker" : displayColumns[0]?.id ?? "ticker";
|
|
354
373
|
const labelled = (row: TickerTableSummaryRow): TickerTableSummaryRow => labelColumn === "ticker" || !row.cells.ticker ? row
|
|
355
374
|
: { ...row, cells: { ...row.cells, [labelColumn]: row.cells.ticker } };
|
|
356
375
|
const rows = [
|
|
357
|
-
...(
|
|
358
|
-
id:
|
|
376
|
+
...(periodLines ?? []).map((line) => ({
|
|
377
|
+
id: line.id,
|
|
359
378
|
cells: {
|
|
360
|
-
ticker: { text:
|
|
361
|
-
pnl: periodPnlFigure(
|
|
362
|
-
pnl_pct: periodPnlFigure(
|
|
379
|
+
ticker: { text: line.label },
|
|
380
|
+
pnl: periodPnlFigure(line.pnl, "pnl"),
|
|
381
|
+
pnl_pct: periodPnlFigure(line.contribution, "contribution"),
|
|
363
382
|
},
|
|
364
|
-
}
|
|
383
|
+
})),
|
|
365
384
|
...(allocationRows ?? []),
|
|
366
385
|
].map(labelled);
|
|
367
386
|
return rows.length > 0 ? rows : undefined;
|
|
368
|
-
}, [allocationRows, displayColumns,
|
|
387
|
+
}, [allocationRows, displayColumns, periodLines]);
|
|
369
388
|
// The table offers "Sort by…" while it has a sort column. A watchlist starts
|
|
370
389
|
// unsorted and a third header click turns sorting off, so the unsorted state
|
|
371
390
|
// needs its own entry until TickerListTableView takes `sortable`.
|
|
@@ -403,6 +422,9 @@ export function PortfolioTickerTable({
|
|
|
403
422
|
rootHeight={rootHeight}
|
|
404
423
|
exportName={exportName}
|
|
405
424
|
columnReorder={columnReorder}
|
|
425
|
+
groups={groups}
|
|
426
|
+
onToggleGroup={onToggleGroup}
|
|
427
|
+
rowMenuItems={rowMenuItems}
|
|
406
428
|
/>
|
|
407
429
|
);
|
|
408
430
|
}
|
|
@@ -164,8 +164,8 @@ export function buildEventColumns(width: number, unit?: string, variant: "corpor
|
|
|
164
164
|
{ id: "period", label: "PERIOD", width: 9, align: "left" },
|
|
165
165
|
{ id: "eps", label: "EPS", width: unit ? 7 : 11, align: "right" },
|
|
166
166
|
{ id: "revenue", label: "REVENUE", width: unit ? 9 : 13, align: "right" },
|
|
167
|
-
{ id: "surprise", label: "EPS SURP", width: 9, align: "right" },
|
|
168
|
-
{ id: "growth", label: "YOY GROWTH", width: 14, align: "right" },
|
|
167
|
+
{ id: "surprise", label: "EPS SURP", width: 9, align: "right", omitWhenEmpty: "visible" },
|
|
168
|
+
{ id: "growth", label: "YOY GROWTH", width: 14, align: "right", omitWhenEmpty: true },
|
|
169
169
|
{ id: "detail", label: "DETAIL", width: 9, align: "left", flexGrow: 1 },
|
|
170
170
|
], width, ["detail", "growth", "revenue"]);
|
|
171
171
|
}
|
|
@@ -713,6 +713,8 @@ export function CorporateActionsView({
|
|
|
713
713
|
onRootKeyDown={handleKeyDown}
|
|
714
714
|
columns={columns}
|
|
715
715
|
items={rows}
|
|
716
|
+
scrollToIndex={selectedIdx}
|
|
717
|
+
scrollToIndexVersion={rows.length}
|
|
716
718
|
sortColumnId={null}
|
|
717
719
|
sortDirection="asc"
|
|
718
720
|
getItemKey={eventRowKey}
|
|
@@ -6,6 +6,7 @@ import { EXTENDED_SESSION_LABELS, type ExtendedSession } from "../../../market-d
|
|
|
6
6
|
import { MISSING_VALUE, formatCompact, formatCurrency, formatLevelPercent, formatNumber, formatPercent, formatPercentRaw } from "../../../utils/format";
|
|
7
7
|
import { loadHeadlessFinancials, loadHeadlessSymbols } from "../shared/headless-market-data";
|
|
8
8
|
import { quoteFreshnessFields } from "../shared/report-freshness";
|
|
9
|
+
import { formatUtcWeekdayTime } from "../../../utils/utc-time";
|
|
9
10
|
import {
|
|
10
11
|
RELATIVE_VALUATION_STALE_FUNDAMENTALS_NOTICE, RELATIVE_VALUATION_STALE_QUOTE_NOTICE, relativeValuationValues, type RelativeValuationGapKey,
|
|
11
12
|
} from "./relative-valuation-model";
|
|
@@ -36,10 +37,13 @@ function gapText(row: Record<string, unknown>, key: RelativeValuationGapKey): st
|
|
|
36
37
|
function extendedColumn(session: ExtendedSession): HeadlessPaneColumn {
|
|
37
38
|
return {
|
|
38
39
|
key: "extendedPrice",
|
|
39
|
-
header:
|
|
40
|
+
// When the print was, in UTC as the header says: a Friday evening's after-hours print read on a Sunday says so.
|
|
41
|
+
header: `${EXTENDED_SESSION_LABELS[session]} UTC`,
|
|
42
|
+
literalHeader: true,
|
|
40
43
|
align: "right",
|
|
41
44
|
format: (value, row) => row.extendedSession === session && typeof value === "number"
|
|
42
|
-
? `${price(value, row)}${row.extendedMark ? " mid" : ""} ${percent(row.extendedChangePercent)}
|
|
45
|
+
? [`${price(value, row)}${row.extendedMark ? " mid" : ""} ${percent(row.extendedChangePercent)}`,
|
|
46
|
+
typeof row.quoteAsOf === "number" ? formatUtcWeekdayTime(row.quoteAsOf) : ""].filter(Boolean).join(" ")
|
|
43
47
|
: MISSING_VALUE,
|
|
44
48
|
};
|
|
45
49
|
}
|
|
@@ -99,10 +103,12 @@ const VALUATION_COLUMNS: HeadlessPaneColumn[] = [
|
|
|
99
103
|
const multiple = multipleOf(value, row);
|
|
100
104
|
return multiple == null ? gapText(row, key) : formatPriceEarnings(multiple);
|
|
101
105
|
},
|
|
102
|
-
// A P/E on a fiscal year's EPS, where no four newer quarters were filed, says which year
|
|
106
|
+
// A P/E on a fiscal year's EPS, where no four newer quarters were filed, says which year, and a forward P/E the
|
|
107
|
+
// year of its consensus; an export has them in P/E period and Fwd P/E period.
|
|
103
108
|
textFormat: (value: unknown, row: Record<string, unknown>) => {
|
|
104
109
|
const multiple = multipleOf(value, row);
|
|
105
|
-
const
|
|
110
|
+
const values = row as Partial<ReturnType<typeof relativeValuationValues>>;
|
|
111
|
+
const year = multiple === NOT_MEANINGFUL ? null : key === "trailingPE" ? values.trailingPEPeriod : values.forwardPEPeriod;
|
|
106
112
|
return multiple == null ? gapText(row, key) : year ? `${formatPriceEarnings(multiple)} ${year}` : formatPriceEarnings(multiple);
|
|
107
113
|
},
|
|
108
114
|
};
|
|
@@ -130,13 +136,17 @@ const VALUATION_COLUMNS: HeadlessPaneColumn[] = [
|
|
|
130
136
|
|
|
131
137
|
/**
|
|
132
138
|
* The period each export's figure is of, in a column after it, where the text
|
|
133
|
-
* table puts it beside the figure: a P/E on a fiscal year's EPS (`FY Mar-26`),
|
|
139
|
+
* table puts it beside the figure: a P/E on a fiscal year's EPS (`FY Mar-26`), a
|
|
140
|
+
* forward P/E's consensus year (`FY28`),
|
|
134
141
|
* a half's revenue growth (`H2 FY26 vs H2 FY25`) or a quarter's (`quarter to
|
|
135
142
|
* 2026-09-30`), a fiscal year's margin (`FY25`); `TTM` for a trailing figure.
|
|
136
143
|
*/
|
|
137
144
|
const VALUATION_PERIOD_COLUMNS: Record<string, HeadlessPaneColumn> = {
|
|
138
145
|
trailingPE: { key: "trailingPEPeriod", header: "P/E period",
|
|
139
146
|
format: (value, row) => row.trailingPE == null && !(row.reportedMultiples as Record<string, unknown> | undefined)?.trailingPE ? "" : typeof value === "string" && value ? value : "TTM" },
|
|
147
|
+
// Added after the export's other columns: it closes the row, so none of theirs moves.
|
|
148
|
+
forwardPE: { key: "forwardPEPeriod", header: "Fwd P/E period", exportLast: true,
|
|
149
|
+
format: (value, row) => row.forwardPE == null && !(row.reportedMultiples as Record<string, unknown> | undefined)?.forwardPE ? "" : typeof value === "string" ? value : "" },
|
|
140
150
|
revenueGrowth: { key: "revenueGrowthHalf", header: "Revenue YoY period",
|
|
141
151
|
format: (value, row) => row.revenueGrowth == null ? "" : typeof value === "string" && value ? value
|
|
142
152
|
: typeof row.revenueGrowthQuarter === "string" ? `quarter to ${row.revenueGrowthQuarter}` : "" },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MISSING_VALUE, formatCompact, formatCurrency } from "../../../utils/format";
|
|
2
|
-
import { comparablePriceEarnings, notMeaningfulMultiples } from "../../../utils/price-earnings";
|
|
2
|
+
import { comparablePriceEarnings, forwardFiscalYear, notMeaningfulMultiples } from "../../../utils/price-earnings";
|
|
3
3
|
import { marketCapBasisNote, viewMarketCapitalization, withheldMarketCap } from "../../../utils/market-capitalization";
|
|
4
4
|
import {
|
|
5
5
|
enterpriseValueNotMeaningful, enterpriseValueReconciliationNote, enterpriseValueWithdrawn, fundamentalsCurrency,
|
|
@@ -170,6 +170,10 @@ export function relativeValuationValues(snapshot: TickerFinancials | null) {
|
|
|
170
170
|
const trailingPEPeriod = reportedMultiples.trailingPE != null && !trailingNotMeaningful && financials
|
|
171
171
|
? trailingEpsFiscalYear(financials) ?? null : null;
|
|
172
172
|
const forwardPE = forwardNotMeaningful ? null : comparablePriceEarnings(reportedMultiples.forwardPE);
|
|
173
|
+
// The fiscal year the consensus is for, as `valuation` and DES name it (`FY28`): for a September filer, next year
|
|
174
|
+
// is two fiscal years out.
|
|
175
|
+
const forwardPEPeriod = (forwardPE != null || reportedMultiples.forwardPE != null) && !forwardNotMeaningful
|
|
176
|
+
? forwardFiscalYear(fundamentals?.forwardEpsPeriodEnd) : null;
|
|
173
177
|
// Every figure a row lacks says why, so an export's blank cell is never silent: N/M multiples say so themselves.
|
|
174
178
|
const gaps: Partial<Record<RelativeValuationGapKey, string>> = {};
|
|
175
179
|
if (session.price == null) gaps.price = quoteStale ? QUOTE_STALE : NOT_REPORTED;
|
|
@@ -218,6 +222,8 @@ export function relativeValuationValues(snapshot: TickerFinancials | null) {
|
|
|
218
222
|
/** The fiscal year the P/E's EPS is ("FY Mar-26") when it is a year's filed figure, not the trailing four quarters'; null otherwise. */
|
|
219
223
|
trailingPEPeriod,
|
|
220
224
|
forwardPE,
|
|
225
|
+
/** The fiscal year of the consensus EPS the forward P/E is on (`FY28`); null when unknown or there is none. */
|
|
226
|
+
forwardPEPeriod,
|
|
221
227
|
reportedMultiples,
|
|
222
228
|
/**
|
|
223
229
|
* Why a figure is N/M: a P/E's earnings base is zero or a loss, EV/S's enterprise value is at or below zero,
|