gloomberb 0.1.0 → 0.3.1
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/LICENSE +25 -0
- package/README.md +68 -121
- package/bin/gloomberb +3 -0
- package/package.json +13 -4
- package/patches/@opentui%2Fcore@0.1.90.patch +356 -0
- package/src/app.tsx +1330 -0
- package/src/brokers/sync-broker-instance.test.ts +100 -0
- package/src/brokers/sync-broker-instance.ts +341 -0
- package/src/cli/commands/plugins.ts +173 -0
- package/src/cli/commands/portfolio.ts +210 -0
- package/src/cli/commands/search.ts +120 -0
- package/src/cli/commands/ticker.ts +375 -0
- package/src/cli/commands/watchlist.ts +210 -0
- package/src/cli/context.ts +62 -0
- package/src/cli/errors.ts +13 -0
- package/src/cli/helpers.ts +85 -0
- package/src/cli/index.ts +143 -0
- package/src/cli/ticker-resolution.ts +39 -0
- package/src/cli/types.ts +15 -0
- package/src/cli.test.ts +361 -0
- package/src/components/chart/chart-data.ts +239 -0
- package/src/components/chart/chart-renderer.ts +1199 -0
- package/src/components/chart/chart-types.ts +82 -0
- package/src/components/chart/chart-viewport.ts +21 -0
- package/src/components/chart/chart.test.ts +439 -0
- package/src/components/chart/comparison-chart-data.test.ts +109 -0
- package/src/components/chart/comparison-chart-data.ts +316 -0
- package/src/components/chart/comparison-chart-renderer.test.ts +84 -0
- package/src/components/chart/comparison-chart-renderer.ts +354 -0
- package/src/components/chart/comparison-stock-chart.tsx +1486 -0
- package/src/components/chart/cursor-motion.ts +48 -0
- package/src/components/chart/native/chart-rasterizer.ts +732 -0
- package/src/components/chart/native/kitty-adapter.ts +12 -0
- package/src/components/chart/native/kitty-manager.ts +142 -0
- package/src/components/chart/native/kitty-protocol.ts +110 -0
- package/src/components/chart/native/kitty-support.ts +71 -0
- package/src/components/chart/native/kitty.test.ts +620 -0
- package/src/components/chart/native/renderer-selection.ts +24 -0
- package/src/components/chart/native/surface-manager.ts +225 -0
- package/src/components/chart/native/surface-sync.ts +34 -0
- package/src/components/chart/stock-chart-renderer-switch.test.tsx +165 -0
- package/src/components/chart/stock-chart.test.ts +107 -0
- package/src/components/chart/stock-chart.tsx +1556 -0
- package/src/components/command-bar/__snapshots__/command-bar.test.tsx.snap +137 -0
- package/src/components/command-bar/command-bar.test.tsx +1524 -0
- package/src/components/command-bar/command-bar.tsx +4823 -0
- package/src/components/command-bar/command-registry.ts +261 -0
- package/src/components/command-bar/helpers.test.ts +224 -0
- package/src/components/command-bar/helpers.ts +371 -0
- package/src/components/command-bar/root-shortcuts.ts +158 -0
- package/src/components/command-bar/view-model.test.ts +152 -0
- package/src/components/command-bar/view-model.ts +185 -0
- package/src/components/command-bar/workflow-ops.test.ts +70 -0
- package/src/components/command-bar/workflow-ops.ts +433 -0
- package/src/components/command-bar/workflow-types.ts +127 -0
- package/src/components/detail-feed-view.test.tsx +105 -0
- package/src/components/detail-feed-view.tsx +295 -0
- package/src/components/index.ts +32 -0
- package/src/components/layout/floating-pane.tsx +49 -0
- package/src/components/layout/header.tsx +129 -0
- package/src/components/layout/pane-header.tsx +44 -0
- package/src/components/layout/pane.tsx +49 -0
- package/src/components/layout/pixel-mouse-mode.test.ts +122 -0
- package/src/components/layout/pixel-mouse.test.ts +40 -0
- package/src/components/layout/shell.test.tsx +625 -0
- package/src/components/layout/shell.tsx +1200 -0
- package/src/components/layout/status-bar.test.tsx +173 -0
- package/src/components/layout/status-bar.tsx +138 -0
- package/src/components/markdown-editor.tsx +134 -0
- package/src/components/onboarding/onboarding-wizard.test.tsx +184 -0
- package/src/components/onboarding/onboarding-wizard.tsx +1365 -0
- package/src/components/pane-settings-dialog.tsx +468 -0
- package/src/components/pane-template-wizard.test.tsx +52 -0
- package/src/components/pane-template-wizard.tsx +199 -0
- package/src/components/price-selector-dialog.tsx +195 -0
- package/src/components/spinner.tsx +2 -0
- package/src/components/tab-bar.tsx +17 -0
- package/src/components/ticker-badge-text.test.tsx +160 -0
- package/src/components/ticker-badge-text.tsx +58 -0
- package/src/components/ticker-badge.tsx +88 -0
- package/src/components/ticker-list-table.tsx +188 -0
- package/src/components/toggle-list.tsx +74 -0
- package/src/components/ui/button.tsx +77 -0
- package/src/components/ui/data-table.tsx +210 -0
- package/src/components/ui/external-link.tsx +22 -0
- package/src/components/ui/fields.tsx +187 -0
- package/src/components/ui/frame.tsx +73 -0
- package/src/components/ui/index.ts +53 -0
- package/src/components/ui/list-view.tsx +166 -0
- package/src/components/ui/loading.tsx +70 -0
- package/src/components/ui/status.tsx +83 -0
- package/src/components/ui/tabs.tsx +47 -0
- package/src/components/ui/toggle.tsx +164 -0
- package/src/components/ui/ui.test.tsx +134 -0
- package/src/data/app-persistence.ts +25 -0
- package/src/data/config-store.test.ts +310 -0
- package/src/data/config-store.ts +469 -0
- package/src/data/plugin-state-store.ts +102 -0
- package/src/data/resource-store.ts +323 -0
- package/src/data/session-store.ts +52 -0
- package/src/data/sqlite-cache.test.ts +103 -0
- package/src/data/sqlite-database.ts +62 -0
- package/src/data/sqlite-json.ts +19 -0
- package/src/data/ticker-repository.ts +45 -0
- package/src/data/ticker-store.ts +46 -0
- package/src/index.tsx +67 -0
- package/src/market-data/coordinator.test.ts +369 -0
- package/src/market-data/coordinator.ts +580 -0
- package/src/market-data/hooks.tsx +234 -0
- package/src/market-data/query-store.ts +28 -0
- package/src/market-data/request-types.test.ts +64 -0
- package/src/market-data/request-types.ts +70 -0
- package/src/market-data/result-types.ts +56 -0
- package/src/market-data/selectors.ts +166 -0
- package/src/market-data/trace.ts +7 -0
- package/src/pane-settings.test.ts +71 -0
- package/src/pane-settings.ts +73 -0
- package/src/plugins/builtin/ai/ask-ai-detail-tab.tsx +338 -0
- package/src/plugins/builtin/ai/gloomberb-cli.ts +70 -0
- package/src/plugins/builtin/ai/index.test.tsx +139 -0
- package/src/plugins/builtin/ai/index.tsx +86 -0
- package/src/plugins/builtin/ai/providers.ts +99 -0
- package/src/plugins/builtin/ai/runner.ts +82 -0
- package/src/plugins/builtin/ai/screener-contract.test.ts +117 -0
- package/src/plugins/builtin/ai/screener-contract.ts +174 -0
- package/src/plugins/builtin/ai/screener-pane.test.tsx +365 -0
- package/src/plugins/builtin/ai/screener-pane.tsx +1161 -0
- package/src/plugins/builtin/ai/settings.ts +79 -0
- package/src/plugins/builtin/ai/ticker-context.ts +64 -0
- package/src/plugins/builtin/ai/utils.ts +71 -0
- package/src/plugins/builtin/ask-ai.test.tsx +258 -0
- package/src/plugins/builtin/ask-ai.tsx +9 -0
- package/src/plugins/builtin/chat-controller.test.ts +217 -0
- package/src/plugins/builtin/chat-controller.ts +340 -0
- package/src/plugins/builtin/chat.test.tsx +451 -0
- package/src/plugins/builtin/chat.tsx +620 -0
- package/src/plugins/builtin/comparison-chart.test.tsx +277 -0
- package/src/plugins/builtin/comparison-chart.tsx +169 -0
- package/src/plugins/builtin/data-providers.ts +16 -0
- package/src/plugins/builtin/debug.tsx +351 -0
- package/src/plugins/builtin/help.test.tsx +110 -0
- package/src/plugins/builtin/help.tsx +281 -0
- package/src/plugins/builtin/layout-manager.tsx +264 -0
- package/src/plugins/builtin/manual-entry.tsx +25 -0
- package/src/plugins/builtin/news.tsx +143 -0
- package/src/plugins/builtin/notes-files.ts +58 -0
- package/src/plugins/builtin/notes.tsx +396 -0
- package/src/plugins/builtin/options-availability.test.tsx +179 -0
- package/src/plugins/builtin/options-availability.ts +158 -0
- package/src/plugins/builtin/options.tsx +364 -0
- package/src/plugins/builtin/portfolio-list/header.tsx +227 -0
- package/src/plugins/builtin/portfolio-list/index.tsx +99 -0
- package/src/plugins/builtin/portfolio-list/metrics.ts +436 -0
- package/src/plugins/builtin/portfolio-list/pane.tsx +533 -0
- package/src/plugins/builtin/portfolio-list/settings.ts +280 -0
- package/src/plugins/builtin/portfolio-list/summary.tsx +270 -0
- package/src/plugins/builtin/portfolio-list/table.tsx +64 -0
- package/src/plugins/builtin/portfolio-list.test.ts +74 -0
- package/src/plugins/builtin/portfolio-list.test.tsx +1164 -0
- package/src/plugins/builtin/portfolio-metrics.test.ts +153 -0
- package/src/plugins/builtin/quote-monitor.test.tsx +114 -0
- package/src/plugins/builtin/sec.tsx +250 -0
- package/src/plugins/builtin/ticker-detail/chart-tab.tsx +43 -0
- package/src/plugins/builtin/ticker-detail/financials-tab.tsx +390 -0
- package/src/plugins/builtin/ticker-detail/index.tsx +80 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +242 -0
- package/src/plugins/builtin/ticker-detail/pane.tsx +183 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor.tsx +83 -0
- package/src/plugins/builtin/ticker-detail/settings.ts +132 -0
- package/src/plugins/builtin/ticker-detail-chart-tab-switch.test.tsx +193 -0
- package/src/plugins/builtin/ticker-detail.test.tsx +578 -0
- package/src/plugins/builtin/yahoo.ts +18 -0
- package/src/plugins/event-bus.ts +37 -0
- package/src/plugins/ibkr/__snapshots__/trade-tab.test.tsx.snap +35 -0
- package/src/plugins/ibkr/account-cache.test.ts +101 -0
- package/src/plugins/ibkr/account-cache.ts +137 -0
- package/src/plugins/ibkr/broker-adapter.ts +168 -0
- package/src/plugins/ibkr/config.test.ts +68 -0
- package/src/plugins/ibkr/config.ts +262 -0
- package/src/plugins/ibkr/dialogs.tsx +83 -0
- package/src/plugins/ibkr/flex.test.ts +107 -0
- package/src/plugins/ibkr/flex.ts +267 -0
- package/src/plugins/ibkr/fundamental-parser.ts +149 -0
- package/src/plugins/ibkr/gateway-helpers.ts +28 -0
- package/src/plugins/ibkr/gateway-selection.ts +51 -0
- package/src/plugins/ibkr/gateway-service.test.ts +450 -0
- package/src/plugins/ibkr/gateway-service.ts +2228 -0
- package/src/plugins/ibkr/index.test.tsx +183 -0
- package/src/plugins/ibkr/index.tsx +153 -0
- package/src/plugins/ibkr/instance-selection.test.ts +121 -0
- package/src/plugins/ibkr/instance-selection.ts +36 -0
- package/src/plugins/ibkr/price-normalization.test.ts +38 -0
- package/src/plugins/ibkr/price-normalization.ts +59 -0
- package/src/plugins/ibkr/trade-badge.tsx +27 -0
- package/src/plugins/ibkr/trade-tab.test.tsx +225 -0
- package/src/plugins/ibkr/trade-tab.tsx +1050 -0
- package/src/plugins/ibkr/trade-utils.test.ts +175 -0
- package/src/plugins/ibkr/trade-utils.ts +149 -0
- package/src/plugins/ibkr/trading-pane.tsx +438 -0
- package/src/plugins/ibkr/trading-state.test.ts +109 -0
- package/src/plugins/ibkr/trading-state.ts +339 -0
- package/src/plugins/loader.ts +71 -0
- package/src/plugins/pane-manager.test.ts +103 -0
- package/src/plugins/pane-manager.ts +974 -0
- package/src/plugins/plugin-persistence.ts +85 -0
- package/src/plugins/plugin-runtime.test.tsx +185 -0
- package/src/plugins/plugin-runtime.tsx +175 -0
- package/src/plugins/prediction-markets/cache.ts +114 -0
- package/src/plugins/prediction-markets/categories.ts +223 -0
- package/src/plugins/prediction-markets/chart.tsx +512 -0
- package/src/plugins/prediction-markets/columns.ts +133 -0
- package/src/plugins/prediction-markets/controller-data.ts +614 -0
- package/src/plugins/prediction-markets/controller.ts +725 -0
- package/src/plugins/prediction-markets/detail/book.tsx +118 -0
- package/src/plugins/prediction-markets/detail/outcomes.tsx +102 -0
- package/src/plugins/prediction-markets/detail/overview.tsx +73 -0
- package/src/plugins/prediction-markets/detail/pane.tsx +308 -0
- package/src/plugins/prediction-markets/detail/rules.tsx +16 -0
- package/src/plugins/prediction-markets/detail/shared.tsx +29 -0
- package/src/plugins/prediction-markets/detail/trades.tsx +30 -0
- package/src/plugins/prediction-markets/detail.test.tsx +47 -0
- package/src/plugins/prediction-markets/index.tsx +102 -0
- package/src/plugins/prediction-markets/keyboard.ts +64 -0
- package/src/plugins/prediction-markets/launch.test.ts +126 -0
- package/src/plugins/prediction-markets/launch.ts +240 -0
- package/src/plugins/prediction-markets/metrics.ts +311 -0
- package/src/plugins/prediction-markets/navigation.ts +90 -0
- package/src/plugins/prediction-markets/outcome-order.ts +19 -0
- package/src/plugins/prediction-markets/pane.test.tsx +425 -0
- package/src/plugins/prediction-markets/pane.tsx +294 -0
- package/src/plugins/prediction-markets/plugin.test.tsx +570 -0
- package/src/plugins/prediction-markets/rows.ts +229 -0
- package/src/plugins/prediction-markets/services/fetch.ts +97 -0
- package/src/plugins/prediction-markets/services/kalshi-adapter.ts +555 -0
- package/src/plugins/prediction-markets/services/polymarket-adapter.ts +660 -0
- package/src/plugins/prediction-markets/services/polymarket-ws.ts +108 -0
- package/src/plugins/prediction-markets/settings.ts +164 -0
- package/src/plugins/prediction-markets/status.ts +24 -0
- package/src/plugins/prediction-markets/table.tsx +84 -0
- package/src/plugins/prediction-markets/test-helpers.tsx +636 -0
- package/src/plugins/prediction-markets/types.ts +186 -0
- package/src/plugins/registry.ts +633 -0
- package/src/sources/exchange-rates.ts +18 -0
- package/src/sources/gloomberb-cloud.test.ts +199 -0
- package/src/sources/gloomberb-cloud.ts +326 -0
- package/src/sources/provider-errors.ts +19 -0
- package/src/sources/provider-router.test.ts +1476 -0
- package/src/sources/provider-router.ts +1405 -0
- package/src/sources/sec-edgar.test.ts +286 -0
- package/src/sources/sec-edgar.ts +526 -0
- package/src/sources/yahoo-finance.test.ts +14 -0
- package/src/sources/yahoo-finance.ts +1017 -0
- package/src/state/app-activity.test.ts +41 -0
- package/src/state/app-activity.ts +106 -0
- package/src/state/app-bootstrap.test.ts +471 -0
- package/src/state/app-bootstrap.ts +308 -0
- package/src/state/app-context.test.ts +406 -0
- package/src/state/app-context.test.tsx +132 -0
- package/src/state/app-context.tsx +969 -0
- package/src/state/selectors.ts +67 -0
- package/src/state/session-persistence.test.ts +128 -0
- package/src/state/session-persistence.ts +161 -0
- package/src/state/ticker-refresh-queue.test.ts +46 -0
- package/src/state/ticker-refresh-queue.ts +40 -0
- package/src/state/use-inline-tickers.ts +174 -0
- package/src/state/use-quote-streaming.test.ts +37 -0
- package/src/state/use-quote-streaming.test.tsx +70 -0
- package/src/state/use-quote-streaming.ts +80 -0
- package/src/state/use-session-snapshot.ts +84 -0
- package/src/test-support/data-provider.ts +22 -0
- package/src/theme/color-utils.ts +67 -0
- package/src/theme/colors.ts +128 -0
- package/src/theme/themes.test.ts +45 -0
- package/src/theme/themes.ts +491 -0
- package/src/types/broker.ts +105 -0
- package/src/types/config.ts +434 -0
- package/src/types/data-provider.ts +81 -0
- package/src/types/financials.ts +142 -0
- package/src/types/instrument.ts +29 -0
- package/src/types/persistence.ts +21 -0
- package/src/types/plugin.ts +354 -0
- package/src/types/ticker.ts +58 -0
- package/src/types/trading.ts +85 -0
- package/src/updater.test.ts +162 -0
- package/src/updater.ts +247 -0
- package/src/utils/api-client.ts +666 -0
- package/src/utils/ascii-chart.ts +172 -0
- package/src/utils/broker-instances.ts +47 -0
- package/src/utils/cli-output.ts +83 -0
- package/src/utils/currency-units.test.ts +49 -0
- package/src/utils/currency-units.ts +82 -0
- package/src/utils/debug-log.ts +133 -0
- package/src/utils/exchange-rate-map.ts +8 -0
- package/src/utils/format.ts +158 -0
- package/src/utils/fuzzy-search.ts +34 -0
- package/src/utils/market-status.ts +95 -0
- package/src/utils/options.ts +86 -0
- package/src/utils/price-history.ts +39 -0
- package/src/utils/quote-time.test.ts +22 -0
- package/src/utils/quote-time.ts +50 -0
- package/src/utils/sec.test.ts +55 -0
- package/src/utils/sec.ts +45 -0
- package/src/utils/ticker-list.test.ts +22 -0
- package/src/utils/ticker-list.ts +35 -0
- package/src/utils/ticker-metadata.ts +51 -0
- package/src/utils/ticker-search.test.ts +227 -0
- package/src/utils/ticker-search.ts +764 -0
- package/src/utils/ticker-tokenizer.test.ts +48 -0
- package/src/utils/ticker-tokenizer.ts +72 -0
- package/src/version.ts +1 -0
- package/install.mjs +0 -69
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { useKeyboard } from "@opentui/react";
|
|
3
|
+
import type { ScrollBoxRenderable } from "@opentui/core";
|
|
4
|
+
import { TabBar } from "../../../components/tab-bar";
|
|
5
|
+
import { getSharedRegistry } from "../../registry";
|
|
6
|
+
import { getSharedMarketDataCoordinator } from "../../../market-data/coordinator";
|
|
7
|
+
import { useFxRatesMap, useTickerFinancialsMap } from "../../../market-data/hooks";
|
|
8
|
+
import { instrumentFromTicker, quoteSubscriptionTargetFromTicker } from "../../../market-data/request-types";
|
|
9
|
+
import { useAppActive } from "../../../state/app-activity";
|
|
10
|
+
import {
|
|
11
|
+
useAppState,
|
|
12
|
+
usePaneCollection,
|
|
13
|
+
usePaneInstance,
|
|
14
|
+
usePaneInstanceId,
|
|
15
|
+
usePaneStateValue,
|
|
16
|
+
type CollectionSortPreference,
|
|
17
|
+
} from "../../../state/app-context";
|
|
18
|
+
import { getCollectionTickers, getCollectionType } from "../../../state/selectors";
|
|
19
|
+
import { useQuoteStreaming } from "../../../state/use-quote-streaming";
|
|
20
|
+
import { selectEffectiveExchangeRates } from "../../../utils/exchange-rate-map";
|
|
21
|
+
import { getActiveQuoteDisplay } from "../../../utils/market-status";
|
|
22
|
+
import type { ColumnConfig } from "../../../types/config";
|
|
23
|
+
import type { TickerRecord } from "../../../types/ticker";
|
|
24
|
+
import type { PaneProps } from "../../../types/plugin";
|
|
25
|
+
import type { TickerFinancials } from "../../../types/financials";
|
|
26
|
+
import { getSortValue, resolveCollectionSortPreference, type ColumnContext } from "./metrics";
|
|
27
|
+
import {
|
|
28
|
+
PortfolioCashMarginDrawer,
|
|
29
|
+
PortfolioSummaryBar,
|
|
30
|
+
shouldToggleCashMarginDrawer,
|
|
31
|
+
usePortfolioAccountState,
|
|
32
|
+
} from "./header";
|
|
33
|
+
import type { ResolvedPortfolioAccountState } from "./summary";
|
|
34
|
+
import {
|
|
35
|
+
getCollectionEntries,
|
|
36
|
+
getPortfolioPaneSettings,
|
|
37
|
+
resolveActiveCollectionId,
|
|
38
|
+
resolveScopedCollectionEntries,
|
|
39
|
+
resolveVisibleColumns,
|
|
40
|
+
} from "./settings";
|
|
41
|
+
import { PortfolioTickerTable, type QuoteFlashDirection } from "./table";
|
|
42
|
+
|
|
43
|
+
const VISIBLE_FINANCIAL_REFRESH_COOLDOWN_MS = 5 * 60_000;
|
|
44
|
+
|
|
45
|
+
function needsVisibleFinancialWarmup(ticker: TickerRecord, financials: TickerFinancials | undefined): boolean {
|
|
46
|
+
if (ticker.metadata.assetCategory === "OPT") return false;
|
|
47
|
+
if (!financials) return true;
|
|
48
|
+
if (Object.keys(financials.fundamentals ?? {}).length === 0) return true;
|
|
49
|
+
return financials.priceHistory.length === 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function selectStreamTickers(
|
|
53
|
+
tickers: TickerRecord[],
|
|
54
|
+
_visibleRange: { start: number; end: number },
|
|
55
|
+
_cursorSymbol: string | null,
|
|
56
|
+
) {
|
|
57
|
+
return tickers;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function buildTrackedCurrencies(
|
|
61
|
+
tickers: TickerRecord[],
|
|
62
|
+
financialsMap: Map<string, TickerFinancials>,
|
|
63
|
+
accountState: ResolvedPortfolioAccountState | null,
|
|
64
|
+
baseCurrency: string,
|
|
65
|
+
): string[] {
|
|
66
|
+
const currencies = new Set<string>([baseCurrency]);
|
|
67
|
+
|
|
68
|
+
for (const ticker of tickers) {
|
|
69
|
+
if (ticker.metadata.currency) {
|
|
70
|
+
currencies.add(ticker.metadata.currency);
|
|
71
|
+
}
|
|
72
|
+
for (const position of ticker.metadata.positions) {
|
|
73
|
+
if (position.currency) {
|
|
74
|
+
currencies.add(position.currency);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const financials = financialsMap.get(ticker.metadata.ticker);
|
|
78
|
+
if (financials?.quote?.currency) {
|
|
79
|
+
currencies.add(financials.quote.currency);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
for (const balance of accountState?.visibleCashBalances ?? []) {
|
|
84
|
+
if (balance.currency) {
|
|
85
|
+
currencies.add(balance.currency);
|
|
86
|
+
}
|
|
87
|
+
if (balance.baseCurrency) {
|
|
88
|
+
currencies.add(balance.baseCurrency);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return [...currencies];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function sortTickers(
|
|
96
|
+
tickers: TickerRecord[],
|
|
97
|
+
financialsMap: Map<string, TickerFinancials>,
|
|
98
|
+
sortPreference: CollectionSortPreference,
|
|
99
|
+
columnContext: ColumnContext,
|
|
100
|
+
columns: ColumnConfig[],
|
|
101
|
+
) {
|
|
102
|
+
if (!sortPreference.columnId) return tickers;
|
|
103
|
+
|
|
104
|
+
const sortColumn = columns.find((column) => column.id === sortPreference.columnId);
|
|
105
|
+
if (!sortColumn) return tickers;
|
|
106
|
+
|
|
107
|
+
return [...tickers].sort((leftTicker, rightTicker) => {
|
|
108
|
+
const leftValue = getSortValue(sortColumn, leftTicker, financialsMap.get(leftTicker.metadata.ticker), columnContext);
|
|
109
|
+
const rightValue = getSortValue(sortColumn, rightTicker, financialsMap.get(rightTicker.metadata.ticker), columnContext);
|
|
110
|
+
|
|
111
|
+
if (leftValue == null && rightValue == null) return 0;
|
|
112
|
+
if (leftValue == null) return 1;
|
|
113
|
+
if (rightValue == null) return -1;
|
|
114
|
+
|
|
115
|
+
const comparison = typeof leftValue === "string" && typeof rightValue === "string"
|
|
116
|
+
? leftValue.localeCompare(rightValue)
|
|
117
|
+
: (leftValue as number) - (rightValue as number);
|
|
118
|
+
|
|
119
|
+
return sortPreference.direction === "asc" ? comparison : -comparison;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function PortfolioListPane({ focused, width, height }: PaneProps) {
|
|
124
|
+
const registry = getSharedRegistry();
|
|
125
|
+
const paneId = usePaneInstanceId();
|
|
126
|
+
const paneInstance = usePaneInstance();
|
|
127
|
+
const appActive = useAppActive();
|
|
128
|
+
const { state } = useAppState();
|
|
129
|
+
const paneCollection = usePaneCollection();
|
|
130
|
+
|
|
131
|
+
const [currentCollectionId, setCurrentCollectionId] = usePaneStateValue<string>("collectionId", paneCollection.collectionId ?? "");
|
|
132
|
+
const [cursorSymbol, setCursorSymbol] = usePaneStateValue<string | null>("cursorSymbol", null);
|
|
133
|
+
const [collectionSorts, setCollectionSorts] = usePaneStateValue<Record<string, CollectionSortPreference>>("collectionSorts", {});
|
|
134
|
+
const [cashDrawerExpanded, setCashDrawerExpanded] = usePaneStateValue<boolean>("cashDrawerExpanded", false);
|
|
135
|
+
|
|
136
|
+
const [hoveredIdx, setHoveredIdx] = useState<number | null>(null);
|
|
137
|
+
const [now, setNow] = useState(Date.now());
|
|
138
|
+
const [flashSymbols, setFlashSymbols] = useState<Map<string, QuoteFlashDirection>>(new Map());
|
|
139
|
+
const [streamWindow, setStreamWindow] = useState({ start: 0, end: 24 });
|
|
140
|
+
|
|
141
|
+
const previousPricesRef = useRef<Map<string, number>>(new Map());
|
|
142
|
+
const mountedRef = useRef(true);
|
|
143
|
+
const warmupInFlightRef = useRef(new Set<string>());
|
|
144
|
+
const warmupAttemptRef = useRef(new Map<string, number>());
|
|
145
|
+
const scrollRef = useRef<ScrollBoxRenderable>(null);
|
|
146
|
+
const headerScrollRef = useRef<ScrollBoxRenderable>(null);
|
|
147
|
+
|
|
148
|
+
const paneSettings = useMemo(
|
|
149
|
+
() => getPortfolioPaneSettings(paneInstance?.settings),
|
|
150
|
+
[paneInstance?.settings],
|
|
151
|
+
);
|
|
152
|
+
const collectionEntries = useMemo(
|
|
153
|
+
() => getCollectionEntries(state.config),
|
|
154
|
+
[state.config],
|
|
155
|
+
);
|
|
156
|
+
const visibleCollections = useMemo(
|
|
157
|
+
() => resolveScopedCollectionEntries(collectionEntries, paneSettings),
|
|
158
|
+
[collectionEntries, paneSettings],
|
|
159
|
+
);
|
|
160
|
+
const activeCollectionId = resolveActiveCollectionId(currentCollectionId, visibleCollections, paneSettings);
|
|
161
|
+
const isPortfolioTab = getCollectionType(state, activeCollectionId) === "portfolio";
|
|
162
|
+
const currentPortfolio = isPortfolioTab
|
|
163
|
+
? state.config.portfolios.find((portfolio) => portfolio.id === activeCollectionId) ?? null
|
|
164
|
+
: null;
|
|
165
|
+
|
|
166
|
+
const tickers = getCollectionTickers(state, activeCollectionId);
|
|
167
|
+
const marketFinancialsMap = useTickerFinancialsMap(tickers);
|
|
168
|
+
const sharedCoordinator = getSharedMarketDataCoordinator();
|
|
169
|
+
const financialsMap = useMemo(() => {
|
|
170
|
+
const merged = sharedCoordinator ? new Map<string, TickerFinancials>() : new Map(state.financials);
|
|
171
|
+
for (const [symbol, financials] of marketFinancialsMap) {
|
|
172
|
+
merged.set(symbol, financials);
|
|
173
|
+
}
|
|
174
|
+
return merged;
|
|
175
|
+
}, [marketFinancialsMap, sharedCoordinator, state.financials]);
|
|
176
|
+
|
|
177
|
+
const accountState = usePortfolioAccountState(currentPortfolio, state);
|
|
178
|
+
const columns = useMemo(
|
|
179
|
+
() => resolveVisibleColumns(paneSettings.columnIds, isPortfolioTab),
|
|
180
|
+
[isPortfolioTab, paneSettings.columnIds],
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const trackedCurrencies = useMemo(
|
|
184
|
+
() => buildTrackedCurrencies(tickers, financialsMap, accountState, state.config.baseCurrency),
|
|
185
|
+
[tickers, financialsMap, accountState, state.config.baseCurrency],
|
|
186
|
+
);
|
|
187
|
+
const fetchedExchangeRates = useFxRatesMap(trackedCurrencies);
|
|
188
|
+
const effectiveExchangeRates = selectEffectiveExchangeRates(fetchedExchangeRates, state.exchangeRates);
|
|
189
|
+
|
|
190
|
+
const columnContext: ColumnContext = useMemo(() => ({
|
|
191
|
+
activeTab: isPortfolioTab ? activeCollectionId : undefined,
|
|
192
|
+
baseCurrency: state.config.baseCurrency,
|
|
193
|
+
exchangeRates: effectiveExchangeRates,
|
|
194
|
+
now,
|
|
195
|
+
}), [activeCollectionId, effectiveExchangeRates, isPortfolioTab, now, state.config.baseCurrency]);
|
|
196
|
+
|
|
197
|
+
const activeSort = resolveCollectionSortPreference(activeCollectionId, isPortfolioTab, collectionSorts);
|
|
198
|
+
const sortedTickers = useMemo(
|
|
199
|
+
() => sortTickers(tickers, financialsMap, activeSort, columnContext, columns),
|
|
200
|
+
[tickers, financialsMap, activeSort, columnContext, columns],
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
const currentTabIdx = visibleCollections.findIndex((collection) => collection.id === activeCollectionId);
|
|
204
|
+
const selectedIdx = sortedTickers.findIndex((ticker) => ticker.metadata.ticker === cursorSymbol);
|
|
205
|
+
const safeSelectedIdx = selectedIdx >= 0 ? selectedIdx : 0;
|
|
206
|
+
|
|
207
|
+
const showCashDrawer = !paneSettings.hideCash && !!(isPortfolioTab && currentPortfolio?.brokerInstanceId && accountState);
|
|
208
|
+
const requestedDrawerHeight = showCashDrawer
|
|
209
|
+
? (cashDrawerExpanded ? Math.min(6, Math.max(3, 2 + accountState.visibleCashBalances.length)) : 1)
|
|
210
|
+
: 0;
|
|
211
|
+
const headerHeight = paneSettings.hideHeader
|
|
212
|
+
? (paneSettings.hideTabs ? 0 : 1)
|
|
213
|
+
: paneSettings.hideTabs ? 1 : 2;
|
|
214
|
+
const drawerHeight = showCashDrawer
|
|
215
|
+
? Math.min(requestedDrawerHeight, Math.max(1, height - (headerHeight + 2)))
|
|
216
|
+
: 0;
|
|
217
|
+
|
|
218
|
+
const syncHeaderScroll = useCallback(() => {
|
|
219
|
+
const bodyScrollBox = scrollRef.current;
|
|
220
|
+
const headerScrollBox = headerScrollRef.current;
|
|
221
|
+
if (bodyScrollBox && headerScrollBox && headerScrollBox.scrollLeft !== bodyScrollBox.scrollLeft) {
|
|
222
|
+
headerScrollBox.scrollLeft = bodyScrollBox.scrollLeft;
|
|
223
|
+
}
|
|
224
|
+
}, []);
|
|
225
|
+
|
|
226
|
+
const updateStreamWindow = useCallback(() => {
|
|
227
|
+
const scrollBox = scrollRef.current;
|
|
228
|
+
if (!scrollBox) return;
|
|
229
|
+
|
|
230
|
+
const buffer = 3;
|
|
231
|
+
const start = Math.max(0, scrollBox.scrollTop - buffer);
|
|
232
|
+
const end = Math.min(sortedTickers.length, scrollBox.scrollTop + scrollBox.viewport.height + buffer);
|
|
233
|
+
setStreamWindow((current) => (
|
|
234
|
+
current.start === start && current.end === end ? current : { start, end }
|
|
235
|
+
));
|
|
236
|
+
}, [sortedTickers.length]);
|
|
237
|
+
|
|
238
|
+
const handleBodyScrollActivity = useCallback(() => {
|
|
239
|
+
syncHeaderScroll();
|
|
240
|
+
updateStreamWindow();
|
|
241
|
+
}, [syncHeaderScroll, updateStreamWindow]);
|
|
242
|
+
|
|
243
|
+
const setSortPreference = useCallback((preference: CollectionSortPreference) => {
|
|
244
|
+
if (!activeCollectionId) return;
|
|
245
|
+
setCollectionSorts({
|
|
246
|
+
...collectionSorts,
|
|
247
|
+
[activeCollectionId]: preference,
|
|
248
|
+
});
|
|
249
|
+
}, [activeCollectionId, collectionSorts, setCollectionSorts]);
|
|
250
|
+
|
|
251
|
+
const handleHeaderClick = useCallback((columnId: string) => {
|
|
252
|
+
if (activeSort.columnId === columnId) {
|
|
253
|
+
setSortPreference(
|
|
254
|
+
activeSort.direction === "asc"
|
|
255
|
+
? { columnId, direction: "desc" }
|
|
256
|
+
: { columnId: null, direction: "asc" },
|
|
257
|
+
);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
setSortPreference({ columnId, direction: "asc" });
|
|
261
|
+
}, [activeSort.columnId, activeSort.direction, setSortPreference]);
|
|
262
|
+
|
|
263
|
+
const handleKeyboard = useCallback((event: { name?: string; shift?: boolean }) => {
|
|
264
|
+
if (!focused) return;
|
|
265
|
+
|
|
266
|
+
const key = event.name;
|
|
267
|
+
const isEnter = key === "enter" || key === "return";
|
|
268
|
+
|
|
269
|
+
if (isEnter && event.shift) {
|
|
270
|
+
const ticker = sortedTickers[safeSelectedIdx];
|
|
271
|
+
if (ticker) {
|
|
272
|
+
registry?.pinTickerFn(ticker.metadata.ticker, { floating: true, paneType: "ticker-detail" });
|
|
273
|
+
}
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (shouldToggleCashMarginDrawer(key, showCashDrawer)) {
|
|
278
|
+
setCashDrawerExpanded(!cashDrawerExpanded);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (key === "j" || key === "down") {
|
|
283
|
+
const nextTicker = sortedTickers[Math.min(safeSelectedIdx + 1, sortedTickers.length - 1)];
|
|
284
|
+
if (nextTicker) setCursorSymbol(nextTicker.metadata.ticker);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (key === "k" || key === "up") {
|
|
289
|
+
const nextTicker = sortedTickers[Math.max(safeSelectedIdx - 1, 0)];
|
|
290
|
+
if (nextTicker) setCursorSymbol(nextTicker.metadata.ticker);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (!paneSettings.hideTabs && (key === "h" || key === "left")) {
|
|
295
|
+
const previousCollection = visibleCollections[Math.max(currentTabIdx - 1, 0)];
|
|
296
|
+
if (previousCollection) setCurrentCollectionId(previousCollection.id);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (!paneSettings.hideTabs && (key === "l" || key === "right")) {
|
|
301
|
+
const nextCollection = visibleCollections[Math.min(currentTabIdx + 1, visibleCollections.length - 1)];
|
|
302
|
+
if (nextCollection) setCurrentCollectionId(nextCollection.id);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (!isEnter) return;
|
|
307
|
+
|
|
308
|
+
const follower = state.config.layout.instances.find((instance) =>
|
|
309
|
+
instance.paneId === "ticker-detail"
|
|
310
|
+
&& instance.binding?.kind === "follow"
|
|
311
|
+
&& instance.binding.sourceInstanceId === paneId,
|
|
312
|
+
);
|
|
313
|
+
if (follower) {
|
|
314
|
+
registry?.focusPaneFn(follower.instanceId);
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
registry?.showPaneFn("ticker-detail");
|
|
318
|
+
}, [
|
|
319
|
+
cashDrawerExpanded,
|
|
320
|
+
currentTabIdx,
|
|
321
|
+
focused,
|
|
322
|
+
paneId,
|
|
323
|
+
paneSettings.hideTabs,
|
|
324
|
+
registry,
|
|
325
|
+
safeSelectedIdx,
|
|
326
|
+
setCashDrawerExpanded,
|
|
327
|
+
setCursorSymbol,
|
|
328
|
+
setCurrentCollectionId,
|
|
329
|
+
showCashDrawer,
|
|
330
|
+
sortedTickers,
|
|
331
|
+
state.config.layout.instances,
|
|
332
|
+
visibleCollections,
|
|
333
|
+
]);
|
|
334
|
+
|
|
335
|
+
useKeyboard(handleKeyboard);
|
|
336
|
+
|
|
337
|
+
useEffect(() => {
|
|
338
|
+
if (activeCollectionId !== currentCollectionId) {
|
|
339
|
+
setCurrentCollectionId(activeCollectionId);
|
|
340
|
+
}
|
|
341
|
+
}, [activeCollectionId, currentCollectionId, setCurrentCollectionId]);
|
|
342
|
+
|
|
343
|
+
useEffect(() => {
|
|
344
|
+
return () => {
|
|
345
|
+
mountedRef.current = false;
|
|
346
|
+
};
|
|
347
|
+
}, []);
|
|
348
|
+
|
|
349
|
+
useEffect(() => {
|
|
350
|
+
if (headerScrollRef.current) {
|
|
351
|
+
headerScrollRef.current.horizontalScrollBar.visible = false;
|
|
352
|
+
}
|
|
353
|
+
syncHeaderScroll();
|
|
354
|
+
}, [syncHeaderScroll]);
|
|
355
|
+
|
|
356
|
+
useEffect(() => {
|
|
357
|
+
const scrollBox = scrollRef.current;
|
|
358
|
+
if (!scrollBox) return;
|
|
359
|
+
|
|
360
|
+
const viewportHeight = scrollBox.viewport.height;
|
|
361
|
+
if (safeSelectedIdx < scrollBox.scrollTop) {
|
|
362
|
+
scrollBox.scrollTo(safeSelectedIdx);
|
|
363
|
+
} else if (safeSelectedIdx >= scrollBox.scrollTop + viewportHeight) {
|
|
364
|
+
scrollBox.scrollTo(safeSelectedIdx - viewportHeight + 1);
|
|
365
|
+
}
|
|
366
|
+
queueMicrotask(updateStreamWindow);
|
|
367
|
+
}, [safeSelectedIdx, updateStreamWindow]);
|
|
368
|
+
|
|
369
|
+
useEffect(() => {
|
|
370
|
+
const scrollBox = scrollRef.current;
|
|
371
|
+
if (!scrollBox) return;
|
|
372
|
+
scrollBox.verticalScrollBar.visible = sortedTickers.length > scrollBox.viewport.height;
|
|
373
|
+
updateStreamWindow();
|
|
374
|
+
}, [sortedTickers.length, drawerHeight, cashDrawerExpanded, updateStreamWindow]);
|
|
375
|
+
|
|
376
|
+
useEffect(() => {
|
|
377
|
+
if (!appActive) return;
|
|
378
|
+
const timerId = setInterval(() => setNow(Date.now()), 1000);
|
|
379
|
+
return () => clearInterval(timerId);
|
|
380
|
+
}, [appActive]);
|
|
381
|
+
|
|
382
|
+
useEffect(() => {
|
|
383
|
+
const changed = new Map<string, QuoteFlashDirection>();
|
|
384
|
+
|
|
385
|
+
for (const [symbol, financials] of financialsMap) {
|
|
386
|
+
const price = getActiveQuoteDisplay(financials.quote)?.price ?? financials.quote?.price;
|
|
387
|
+
if (price == null) continue;
|
|
388
|
+
|
|
389
|
+
const previousPrice = previousPricesRef.current.get(symbol);
|
|
390
|
+
if (previousPrice != null && previousPrice !== price) {
|
|
391
|
+
changed.set(symbol, price > previousPrice ? "up" : price < previousPrice ? "down" : "flat");
|
|
392
|
+
}
|
|
393
|
+
previousPricesRef.current.set(symbol, price);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if (changed.size === 0) return;
|
|
397
|
+
|
|
398
|
+
setFlashSymbols(changed);
|
|
399
|
+
const timeoutId = setTimeout(() => setFlashSymbols(new Map()), 450);
|
|
400
|
+
return () => clearTimeout(timeoutId);
|
|
401
|
+
}, [financialsMap]);
|
|
402
|
+
|
|
403
|
+
useEffect(() => {
|
|
404
|
+
if (sortedTickers.length === 0) {
|
|
405
|
+
if (cursorSymbol !== null) setCursorSymbol(null);
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const hasSelection = cursorSymbol && sortedTickers.some((ticker) => ticker.metadata.ticker === cursorSymbol);
|
|
410
|
+
if (!hasSelection) {
|
|
411
|
+
setCursorSymbol(sortedTickers[0]!.metadata.ticker);
|
|
412
|
+
}
|
|
413
|
+
}, [cursorSymbol, setCursorSymbol, sortedTickers]);
|
|
414
|
+
|
|
415
|
+
const streamTickers = useMemo(
|
|
416
|
+
() => selectStreamTickers(sortedTickers, streamWindow, cursorSymbol),
|
|
417
|
+
[cursorSymbol, sortedTickers, streamWindow],
|
|
418
|
+
);
|
|
419
|
+
const streamTargets = useMemo(() => (
|
|
420
|
+
streamTickers
|
|
421
|
+
.map((ticker) => quoteSubscriptionTargetFromTicker(ticker, ticker.metadata.ticker, "provider"))
|
|
422
|
+
.filter((target): target is NonNullable<typeof target> => target != null)
|
|
423
|
+
), [streamTickers]);
|
|
424
|
+
const visibleFinancialTickers = useMemo(
|
|
425
|
+
() => sortedTickers.slice(streamWindow.start, streamWindow.end),
|
|
426
|
+
[sortedTickers, streamWindow.end, streamWindow.start],
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
useEffect(() => {
|
|
430
|
+
if (!appActive) return;
|
|
431
|
+
if (!sharedCoordinator) return;
|
|
432
|
+
|
|
433
|
+
const nowTimestamp = Date.now();
|
|
434
|
+
const queue = visibleFinancialTickers.filter((ticker) => {
|
|
435
|
+
const key = `${ticker.metadata.ticker}:${ticker.metadata.exchange ?? ""}`;
|
|
436
|
+
if (warmupInFlightRef.current.has(key)) return false;
|
|
437
|
+
if (nowTimestamp - (warmupAttemptRef.current.get(key) ?? 0) < VISIBLE_FINANCIAL_REFRESH_COOLDOWN_MS) return false;
|
|
438
|
+
return needsVisibleFinancialWarmup(ticker, financialsMap.get(ticker.metadata.ticker));
|
|
439
|
+
});
|
|
440
|
+
if (queue.length === 0) return;
|
|
441
|
+
|
|
442
|
+
const runNext = async (): Promise<void> => {
|
|
443
|
+
const nextTicker = queue.shift();
|
|
444
|
+
if (!nextTicker) return;
|
|
445
|
+
|
|
446
|
+
const key = `${nextTicker.metadata.ticker}:${nextTicker.metadata.exchange ?? ""}`;
|
|
447
|
+
const instrument = instrumentFromTicker(nextTicker, nextTicker.metadata.ticker);
|
|
448
|
+
warmupInFlightRef.current.add(key);
|
|
449
|
+
warmupAttemptRef.current.set(key, nowTimestamp);
|
|
450
|
+
try {
|
|
451
|
+
if (instrument) {
|
|
452
|
+
await sharedCoordinator.loadSnapshot(instrument);
|
|
453
|
+
}
|
|
454
|
+
} catch {
|
|
455
|
+
// Best-effort warmup for visible rows only.
|
|
456
|
+
} finally {
|
|
457
|
+
warmupInFlightRef.current.delete(key);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
if (mountedRef.current) {
|
|
461
|
+
await runNext();
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
const workers = Array.from({ length: Math.min(3, queue.length) }, () => runNext());
|
|
466
|
+
void Promise.all(workers);
|
|
467
|
+
}, [appActive, financialsMap, sharedCoordinator, visibleFinancialTickers]);
|
|
468
|
+
|
|
469
|
+
useQuoteStreaming(streamTargets);
|
|
470
|
+
|
|
471
|
+
return (
|
|
472
|
+
<box flexDirection="column" flexGrow={1}>
|
|
473
|
+
<box flexDirection="column" height={headerHeight}>
|
|
474
|
+
{!paneSettings.hideTabs && (
|
|
475
|
+
<box flexDirection="row" height={1}>
|
|
476
|
+
<box flexShrink={1} overflow="hidden">
|
|
477
|
+
<TabBar
|
|
478
|
+
tabs={visibleCollections.map((collection) => ({ label: collection.name, value: collection.id }))}
|
|
479
|
+
activeValue={activeCollectionId}
|
|
480
|
+
onSelect={setCurrentCollectionId}
|
|
481
|
+
compact
|
|
482
|
+
/>
|
|
483
|
+
</box>
|
|
484
|
+
</box>
|
|
485
|
+
)}
|
|
486
|
+
{!paneSettings.hideHeader && (
|
|
487
|
+
<box height={1}>
|
|
488
|
+
<PortfolioSummaryBar
|
|
489
|
+
tickers={sortedTickers}
|
|
490
|
+
financialsMap={financialsMap}
|
|
491
|
+
state={state}
|
|
492
|
+
isPortfolio={isPortfolioTab}
|
|
493
|
+
collectionId={activeCollectionId}
|
|
494
|
+
width={Math.max(0, width)}
|
|
495
|
+
accountState={accountState}
|
|
496
|
+
/>
|
|
497
|
+
</box>
|
|
498
|
+
)}
|
|
499
|
+
</box>
|
|
500
|
+
|
|
501
|
+
<PortfolioTickerTable
|
|
502
|
+
columns={columns}
|
|
503
|
+
sortColumnId={activeSort.columnId}
|
|
504
|
+
sortDirection={activeSort.direction}
|
|
505
|
+
onHeaderClick={handleHeaderClick}
|
|
506
|
+
headerScrollRef={headerScrollRef}
|
|
507
|
+
scrollRef={scrollRef}
|
|
508
|
+
syncHeaderScroll={syncHeaderScroll}
|
|
509
|
+
onBodyScrollActivity={handleBodyScrollActivity}
|
|
510
|
+
sortedTickers={sortedTickers}
|
|
511
|
+
cursorSymbol={cursorSymbol}
|
|
512
|
+
hoveredIdx={hoveredIdx}
|
|
513
|
+
setHoveredIdx={setHoveredIdx}
|
|
514
|
+
setCursorSymbol={setCursorSymbol}
|
|
515
|
+
financialsMap={financialsMap}
|
|
516
|
+
columnContext={columnContext}
|
|
517
|
+
flashSymbols={flashSymbols}
|
|
518
|
+
/>
|
|
519
|
+
|
|
520
|
+
{showCashDrawer && accountState && (
|
|
521
|
+
<box height={drawerHeight} paddingX={1}>
|
|
522
|
+
<PortfolioCashMarginDrawer
|
|
523
|
+
accountState={accountState}
|
|
524
|
+
expanded={cashDrawerExpanded}
|
|
525
|
+
onToggle={() => setCashDrawerExpanded(!cashDrawerExpanded)}
|
|
526
|
+
width={Math.max(0, width - 2)}
|
|
527
|
+
height={drawerHeight}
|
|
528
|
+
/>
|
|
529
|
+
</box>
|
|
530
|
+
)}
|
|
531
|
+
</box>
|
|
532
|
+
);
|
|
533
|
+
}
|