@gloom-sh/terminal 0.20.17 → 0.20.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -1
- package/src/account/auth-dialog.tsx +19 -1
- package/src/account/billing.ts +2 -1
- package/src/account/heard-from-question.tsx +235 -0
- package/src/account/heard-from.ts +97 -0
- package/src/api-client/cot.ts +5 -6
- package/src/api-client/data.ts +14 -3
- package/src/api-client/heard-from.ts +72 -0
- package/src/api-client/index.ts +64 -6
- package/src/api-client/mna.ts +18 -0
- package/src/api-client/request.ts +162 -40
- package/src/api-client/supply-chain.ts +9 -0
- package/src/api-client/types/billing.ts +35 -1
- package/src/api-client/types/news.ts +45 -0
- package/src/api-client/types/world-venues.ts +9 -0
- package/src/app/global-shortcuts.ts +5 -3
- package/src/app/pro-welcome/keys.ts +27 -0
- package/src/app/pro-welcome/model.ts +158 -0
- package/src/app/pro-welcome/row.tsx +176 -0
- package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
- package/src/app/runtime/external-profile-changes.ts +135 -0
- package/src/app.tsx +37 -4
- package/src/architecture/core-builtin-allowlist.json +1 -1
- package/src/architecture/floating-promise-allowlist.json +1 -2
- package/src/architecture/shortcut-labels-allowlist.json +1 -0
- package/src/cli/alert-listing.ts +98 -0
- package/src/cli/commands/market.ts +191 -39
- package/src/cli/commands/overview.ts +7 -1
- package/src/cli/commands/plugins.ts +3 -2
- package/src/cli/commands/search.ts +30 -6
- package/src/cli/commands/ticker.ts +13 -6
- package/src/cli/context.ts +24 -5
- package/src/cli/csv-export.ts +2 -1
- package/src/cli/desktop-pane-shot-browser.ts +3 -1
- package/src/cli/desktop-pane-shot-view.ts +0 -1
- package/src/cli/desktop-pane-shot.ts +276 -52
- package/src/cli/errors.ts +3 -9
- package/src/cli/exit-codes.ts +1 -1
- package/src/cli/glossary.ts +65 -11
- package/src/cli/help.ts +1 -1
- package/src/cli/history-demergers.ts +117 -0
- package/src/cli/history-rows.ts +8 -4
- package/src/cli/index.ts +2 -1
- package/src/cli/known-gaps.ts +16 -0
- package/src/cli/known-us-stocks.ts +18 -0
- package/src/cli/listing-arg.ts +192 -38
- package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
- package/src/cli/pane-functions/catalog-snapshot.json +877 -0
- package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
- package/src/cli/pane-functions/catalog.ts +50 -16
- package/src/cli/pane-functions/data.ts +16 -4
- package/src/cli/pane-functions/dom.ts +54 -8
- package/src/cli/pane-functions/freshness.ts +39 -4
- package/src/cli/pane-functions/function-help.ts +3 -3
- package/src/cli/pane-functions/headless.ts +9 -1
- package/src/cli/pane-functions/index.ts +175 -50
- package/src/cli/pane-functions/report-notices.ts +10 -0
- package/src/cli/pane-functions/resolver.ts +11 -7
- package/src/cli/pane-functions/screenshot-assessment.ts +38 -10
- package/src/cli/pane-functions/screenshot-data-evidence.ts +7 -15
- package/src/cli/pane-functions/screenshot-payload.ts +36 -1
- package/src/cli/pane-functions/screenshot-render.ts +24 -9
- package/src/cli/pane-functions/screenshot-types.ts +9 -0
- package/src/cli/quote-answer.ts +33 -17
- package/src/cli/registry.ts +22 -2
- package/src/cli/result.ts +22 -4
- package/src/cli/scroll-truncation.ts +7 -2
- package/src/cli/series-search.ts +45 -6
- package/src/cli/shot-temp-dir.ts +4 -9
- package/src/cli/ticker-resolution.ts +1 -1
- package/src/cli/unreachable.ts +21 -0
- package/src/components/chart/composite/drawing-store.ts +11 -7
- package/src/components/chart/composite/format.ts +1 -0
- package/src/components/chart/composite/legend.tsx +48 -20
- package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
- package/src/components/chart/composite/panel-surface/plot-gestures.ts +9 -2
- package/src/components/chart/composite/panel-surface.tsx +1 -1
- package/src/components/chart/composite/price-axis-labels.tsx +7 -5
- package/src/components/chart/composite/tools.ts +164 -39
- package/src/components/chart-table/header.tsx +11 -2
- package/src/components/chart-table/layout.ts +16 -17
- package/src/components/command-bar/pane-templates/items.ts +17 -1
- package/src/components/command-bar/routes/root/provider-search.ts +10 -1
- package/src/components/command-bar/routes/root/results.ts +34 -2
- package/src/components/command-bar/routes/root/runtime.ts +19 -4
- package/src/components/command-bar/routes/ticker-search/results.ts +5 -0
- package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
- package/src/components/command-bar/selection-runtime.ts +29 -5
- package/src/components/command-bar/surface/index.tsx +4 -1
- package/src/components/command-bar/workflow/alert.ts +32 -13
- package/src/components/data-table/view.tsx +15 -2
- package/src/components/form-modal/content.tsx +9 -4
- package/src/components/index.ts +1 -1
- package/src/components/layout/header.tsx +9 -5
- package/src/components/layout/pane/capture-status.ts +6 -0
- package/src/components/layout/pane/footer/index.tsx +2 -0
- package/src/components/layout/pane/footer/model.ts +123 -17
- package/src/components/layout/pane/header.tsx +16 -2
- package/src/components/layout/pane/status-footer.ts +24 -0
- package/src/components/market-board/index.tsx +4 -2
- package/src/components/onboarding/onboarding-frame.tsx +6 -2
- package/src/components/onboarding/onboarding-keyboard.ts +7 -1
- package/src/components/onboarding/onboarding-wizard.tsx +3 -1
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
- package/src/components/onboarding/setup-cards.ts +36 -0
- package/src/components/onboarding/use-onboarding-progress.ts +22 -1
- package/src/components/onboarding/wizard-account.ts +6 -1
- package/src/components/onboarding/wizard-model.ts +32 -6
- package/src/components/onboarding/wizard-positions.ts +1 -1
- package/src/components/price-performance.tsx +26 -8
- package/src/components/reader/article-reader.tsx +12 -5
- package/src/components/sign-in-gate.tsx +3 -1
- package/src/components/toggle-list.tsx +6 -8
- package/src/components/ui/confirm-dialog.tsx +47 -7
- package/src/components/ui/data-table/opentui/index.tsx +7 -0
- package/src/components/ui/data-table/types.ts +8 -0
- package/src/components/ui/display.tsx +17 -2
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/stat-grid.tsx +4 -0
- package/src/components/ui/status.tsx +13 -1
- package/src/components/ui/table-layout.ts +34 -2
- package/src/components/use-pane-notice-footer.tsx +16 -3
- package/src/data/config/store/index.ts +31 -0
- package/src/data/config/store/node.ts +61 -11
- package/src/data/config/store/normalize.ts +4 -6
- package/src/data/config/store/shared-file.ts +309 -0
- package/src/data/profile-merge.ts +299 -0
- package/src/data/sqlite/checkpointer.ts +11 -1
- package/src/data/sqlite/database.ts +1 -1
- package/src/data/ticker-repository.ts +134 -10
- package/src/data/ticker-store.ts +67 -0
- package/src/data/ticker-writes.ts +5 -0
- package/src/i18n/es.ts +27 -0
- package/src/i18n/ja.ts +27 -0
- package/src/i18n/ko.ts +27 -0
- package/src/i18n/zh-cn.ts +27 -0
- package/src/i18n/zh-tw.ts +27 -0
- package/src/layout-marketplace/gallery-desktop.tsx +2 -2
- package/src/market-data/ah-pair.ts +122 -0
- package/src/market-data/coordinator/entries.ts +6 -4
- package/src/market-data/coordinator/index.ts +14 -3
- package/src/market-data/depositary-pair.ts +6 -2
- package/src/market-data/futures-board.ts +36 -29
- package/src/market-data/futures-contract.ts +37 -1
- package/src/market-data/hooks.tsx +33 -2
- package/src/market-data/market/change-basis.ts +11 -1
- package/src/market-data/market/header-market.ts +11 -0
- package/src/market-data/market/status.ts +40 -4
- package/src/market-data/performance.ts +127 -32
- package/src/market-data/quotes/time.ts +5 -2
- package/src/market-data/split-terms.ts +28 -0
- package/src/news/types.ts +28 -0
- package/src/notifications/app-badge.ts +2 -3
- package/src/notifications/app-notifier.ts +5 -0
- package/src/plugins/builtin/account-management/footer.ts +1 -1
- package/src/plugins/builtin/account-management/keyboard.ts +4 -0
- package/src/plugins/builtin/account-management/model.ts +1 -0
- package/src/plugins/builtin/account-management/pane.tsx +75 -7
- package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
- package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
- package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
- package/src/plugins/builtin/alerts/cli-move.ts +2 -2
- package/src/plugins/builtin/alerts/cli.ts +101 -48
- package/src/plugins/builtin/alerts/command.ts +39 -9
- package/src/plugins/builtin/alerts/constants.ts +10 -0
- package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
- package/src/plugins/builtin/alerts/event-rows.ts +9 -3
- package/src/plugins/builtin/alerts/events-pane.tsx +16 -10
- package/src/plugins/builtin/alerts/format.ts +24 -8
- package/src/plugins/builtin/alerts/headless.ts +12 -6
- package/src/plugins/builtin/alerts/index.tsx +97 -16
- package/src/plugins/builtin/alerts/move-checks.ts +7 -0
- package/src/plugins/builtin/alerts/option-contract.ts +197 -0
- package/src/plugins/builtin/alerts/pane.tsx +1 -1
- package/src/plugins/builtin/alerts/price.ts +30 -5
- package/src/plugins/builtin/alerts/pro-rules.ts +62 -0
- package/src/plugins/builtin/alerts/quotes.ts +26 -2
- package/src/plugins/builtin/alerts/research-builder.ts +5 -10
- package/src/plugins/builtin/alerts/scheduled.ts +6 -1
- package/src/plugins/builtin/alerts/types.ts +7 -0
- package/src/plugins/builtin/analytics/account-returns.ts +1 -1
- package/src/plugins/builtin/analytics/manual-value.ts +61 -0
- package/src/plugins/builtin/analytics/pane-model.ts +2 -2
- package/src/plugins/builtin/analytics/risk-book.ts +7 -7
- package/src/plugins/builtin/analytics/risk-client.ts +27 -14
- package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
- package/src/plugins/builtin/analytics/risk-model.ts +92 -4
- package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
- package/src/plugins/builtin/awards/pane.tsx +1 -1
- package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
- package/src/plugins/builtin/buildout/company/pane.tsx +4 -14
- package/src/plugins/builtin/catalysts/model.ts +2 -1
- package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
- package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
- package/src/plugins/builtin/chart-composer/chart-spec.ts +5 -0
- package/src/plugins/builtin/chart-composer/cli-options.ts +9 -5
- package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
- package/src/plugins/builtin/chart-composer/headless-schema.ts +14 -10
- package/src/plugins/builtin/chart-composer/headless.ts +2 -0
- package/src/plugins/builtin/chart-composer/index.tsx +17 -5
- package/src/plugins/builtin/chart-composer/pane.tsx +19 -6
- package/src/plugins/builtin/chart-composer/viewport-labels.ts +2 -17
- package/src/plugins/builtin/chat/controller/notifications.ts +1 -0
- package/src/plugins/builtin/chat/index.tsx +0 -1
- package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
- package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
- package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
- package/src/plugins/builtin/commodities-energy/index.tsx +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +10 -5
- package/src/plugins/builtin/company-kpis/latest.ts +45 -0
- package/src/plugins/builtin/company-kpis/model.ts +57 -15
- package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
- package/src/plugins/builtin/composite/alt-data.ts +20 -0
- package/src/plugins/builtin/composite/application.ts +14 -0
- package/src/plugins/builtin/composite/broker.ts +12 -0
- package/src/plugins/builtin/composite/credit.ts +33 -0
- package/src/plugins/builtin/composite/crypto.ts +10 -0
- package/src/plugins/builtin/composite/earnings.ts +12 -0
- package/src/plugins/builtin/composite/filings.ts +13 -0
- package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
- package/src/plugins/builtin/composite/global-markets.ts +12 -0
- package/src/plugins/builtin/composite/options-volatility.ts +23 -0
- package/src/plugins/builtin/composite/ownership.ts +23 -0
- package/src/plugins/builtin/composite/portfolio.ts +10 -0
- package/src/plugins/builtin/composite/quant.ts +15 -0
- package/src/plugins/builtin/composite/rates-macro.ts +30 -0
- package/src/plugins/builtin/composite/screeners.ts +11 -0
- package/src/plugins/builtin/composite/shared.ts +11 -0
- package/src/plugins/builtin/composite/ticker-core.ts +36 -0
- package/src/plugins/builtin/congress-trades/headless.ts +31 -3
- package/src/plugins/builtin/congress-trades/model.ts +9 -5
- package/src/plugins/builtin/correlation/index.tsx +13 -17
- package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
- package/src/plugins/builtin/cot/client.ts +2 -3
- package/src/plugins/builtin/cot/headless.ts +16 -16
- package/src/plugins/builtin/cot/index.tsx +6 -6
- package/src/plugins/builtin/cot/model.ts +25 -5
- package/src/plugins/builtin/cot/pane.tsx +11 -6
- package/src/plugins/builtin/cot/series.ts +11 -8
- package/src/plugins/builtin/cpi/model.ts +15 -4
- package/src/plugins/builtin/cpi/pane.tsx +29 -7
- package/src/plugins/builtin/dividend-yield/client.ts +57 -16
- package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
- package/src/plugins/builtin/dividend-yield/model.ts +4 -3
- package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
- package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
- package/src/plugins/builtin/dividend-yield/types.ts +4 -0
- package/src/plugins/builtin/dividend-yield/view.ts +23 -12
- package/src/plugins/builtin/doe/model.ts +30 -0
- package/src/plugins/builtin/doe/pane.tsx +8 -2
- package/src/plugins/builtin/earnings/board-table.ts +9 -4
- package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
- package/src/plugins/builtin/earnings/headless.ts +16 -6
- package/src/plugins/builtin/earnings/history-model.ts +6 -4
- package/src/plugins/builtin/earnings/history-table.ts +7 -4
- package/src/plugins/builtin/earnings-calls/calendar.tsx +4 -3
- package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
- package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -2
- package/src/plugins/builtin/econ/calendar-model.ts +16 -0
- package/src/plugins/builtin/econ/index.tsx +7 -2
- package/src/plugins/builtin/equity-screener/headless.ts +4 -1
- package/src/plugins/builtin/equity-screener/model.ts +7 -6
- package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
- package/src/plugins/builtin/exposure/model.ts +10 -0
- package/src/plugins/builtin/exposure/pane.tsx +10 -3
- package/src/plugins/builtin/futures/model.ts +14 -1
- package/src/plugins/builtin/futures/series.ts +1 -8
- package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
- package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
- package/src/plugins/builtin/fx-matrix/index.tsx +25 -7
- package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
- package/src/plugins/builtin/insider/detail.tsx +36 -7
- package/src/plugins/builtin/insider/filing-stories.ts +110 -0
- package/src/plugins/builtin/insider/headless.ts +37 -2
- package/src/plugins/builtin/insider/index.tsx +79 -10
- package/src/plugins/builtin/insider/model.ts +43 -5
- package/src/plugins/builtin/ipo-calendar/client.ts +11 -1
- package/src/plugins/builtin/ipo-calendar/model.ts +3 -7
- package/src/plugins/builtin/jobs/headless.ts +2 -1
- package/src/plugins/builtin/jobs/model.ts +6 -0
- package/src/plugins/builtin/jobs/pane.tsx +8 -3
- package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
- package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
- package/src/plugins/builtin/mna/detail.tsx +67 -6
- package/src/plugins/builtin/mna/headless.ts +128 -13
- package/src/plugins/builtin/mna/model.ts +219 -16
- package/src/plugins/builtin/mna/pane.tsx +34 -6
- package/src/plugins/builtin/money-markets/model.ts +14 -5
- package/src/plugins/builtin/money-markets/pane.tsx +4 -3
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +118 -10
- package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
- package/src/plugins/builtin/news/wire/news/story-evidence.ts +178 -0
- package/src/plugins/builtin/options/analytics.ts +1 -1
- package/src/plugins/builtin/options/view.tsx +18 -11
- package/src/plugins/builtin/options-positioning/model.ts +11 -0
- package/src/plugins/builtin/options-positioning/pane.tsx +22 -1
- package/src/plugins/builtin/options-scenario/client.ts +49 -8
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
- package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
- package/src/plugins/builtin/options-scenario/headless.ts +7 -3
- package/src/plugins/builtin/options-scenario/model.ts +33 -2
- package/src/plugins/builtin/options-scenario/pane.tsx +3 -4
- package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
- package/src/plugins/builtin/pe-band/client.ts +13 -1
- package/src/plugins/builtin/pe-band/headless.ts +2 -2
- package/src/plugins/builtin/pe-band/model.ts +63 -10
- package/src/plugins/builtin/pe-band/pane.tsx +5 -5
- package/src/plugins/builtin/perps/cascade.ts +4 -3
- package/src/plugins/builtin/perps/markets-section.tsx +5 -2
- package/src/plugins/builtin/perps/model.ts +4 -3
- package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
- package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
- package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
- package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
- package/src/plugins/builtin/portfolio-list/table.tsx +3 -2
- package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +33 -14
- package/src/plugins/builtin/research/event-model.ts +43 -19
- package/src/plugins/builtin/research/headless.ts +8 -1
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
- package/src/plugins/builtin/research-search/index.tsx +3 -1
- package/src/plugins/builtin/scanner/denied.tsx +16 -4
- package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
- package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
- package/src/plugins/builtin/sec/filing-display.tsx +14 -2
- package/src/plugins/builtin/sec/headless.ts +42 -4
- package/src/plugins/builtin/sec/index.tsx +21 -1
- package/src/plugins/builtin/sectors/index.tsx +6 -9
- package/src/plugins/builtin/sectors/sector-model.ts +1 -1
- package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
- package/src/plugins/builtin/shared/earnings-report.ts +49 -5
- package/src/plugins/builtin/shared/options-pro-copy.ts +34 -0
- package/src/plugins/builtin/shared/report-freshness.ts +2 -3
- package/src/plugins/builtin/shared/statement-currency.ts +23 -0
- package/src/plugins/builtin/shared/ticker-surface.ts +1 -1
- package/src/plugins/builtin/supply-chain/client.ts +34 -9
- package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
- package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
- package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
- package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
- package/src/plugins/builtin/supply-chain/headless.ts +19 -4
- package/src/plugins/builtin/supply-chain/model.ts +50 -6
- package/src/plugins/builtin/supply-chain/pane.tsx +79 -18
- package/src/plugins/builtin/themes/headless.ts +4 -4
- package/src/plugins/builtin/themes/model.ts +11 -8
- package/src/plugins/builtin/themes/pane.tsx +2 -2
- package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +51 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +25 -14
- package/src/plugins/builtin/ticker-detail/financials/model.ts +22 -32
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +7 -9
- package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -0
- package/src/plugins/builtin/ticker-detail/headless.ts +28 -12
- package/src/plugins/builtin/ticker-detail/overview/board-lot.ts +21 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +28 -2
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +8 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +68 -13
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
- package/src/plugins/builtin/volatility/model.ts +17 -0
- package/src/plugins/builtin/volatility/pane.tsx +16 -7
- package/src/plugins/builtin/world-indices/index.tsx +2 -0
- package/src/plugins/builtin/world-indices/table.tsx +15 -0
- package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
- package/src/plugins/builtin/world-venue-map/headless.ts +32 -18
- package/src/plugins/builtin/world-venue-map/index.ts +19 -6
- package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
- package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
- package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
- package/src/plugins/builtin/world-venue-map/model.ts +6 -1
- package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
- package/src/plugins/builtin/world-venue-map/place.ts +119 -0
- package/src/plugins/builtin/world-venue-map/venue-header.tsx +5 -3
- package/src/plugins/catalog-browser.ts +10 -1
- package/src/plugins/catalog-data.ts +20 -0
- package/src/plugins/catalog-lazy.ts +51 -0
- package/src/plugins/catalog-ui.ts +16 -18
- package/src/plugins/host-smoke.ts +5 -2
- package/src/portfolio/allocation.ts +79 -19
- package/src/portfolio/cash-balances.ts +76 -0
- package/src/portfolio/mutations.ts +43 -8
- package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
- package/src/renderers/browser/activity.ts +16 -0
- package/src/renderers/browser/app-badge-host.ts +14 -0
- package/src/renderers/browser/main.tsx +5 -0
- package/src/renderers/browser/notifications.ts +103 -0
- package/src/renderers/browser/ui-host.tsx +4 -0
- package/src/renderers/desktop/window-layouts.ts +14 -0
- package/src/renderers/dom/data-table/index.tsx +27 -4
- package/src/renderers/dom/data-table/row.tsx +2 -0
- package/src/renderers/dom/host/tabs.tsx +57 -8
- package/src/renderers/dom/styles.css +13 -5
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
- package/src/renderers/electrobun/shared/protocol.ts +4 -0
- package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
- package/src/renderers/electrobun/view/http-fetch.ts +3 -2
- package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
- package/src/series/standalone-catalog.ts +5 -4
- package/src/series/standalone.ts +13 -7
- package/src/sources/gloomberb-cloud/index.ts +22 -9
- package/src/sources/gloomberb-cloud/news.ts +35 -0
- package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
- package/src/sources/provider-errors.ts +34 -7
- package/src/sources/provider-router/financials.ts +20 -13
- package/src/sources/provider-router/history.ts +32 -6
- package/src/sources/provider-router/index.ts +4 -0
- package/src/sources/provider-router/search.ts +1 -0
- package/src/sync/collections-contributor.ts +3 -1
- package/src/sync/config-merge.ts +10 -1
- package/src/sync/sanitize.ts +26 -2
- package/src/tickers/company-name-listing.ts +16 -2
- package/src/tickers/listing-fate.ts +12 -8
- package/src/tickers/renamed-listings.ts +43 -10
- package/src/tickers/search/home-listing.ts +28 -0
- package/src/tickers/search/index.ts +19 -7
- package/src/tickers/terminal-codes.ts +11 -1
- package/src/time-series/base-series.ts +39 -6
- package/src/time-series/chart-seed.ts +2 -2
- package/src/time-series/history-quality.ts +4 -1
- package/src/time-series/hooks.ts +2 -0
- package/src/time-series/price-comparison.ts +17 -23
- package/src/time-series/reporting.ts +1 -1
- package/src/time-series/resolution.ts +13 -0
- package/src/time-series/resolve-context.ts +6 -0
- package/src/time-series/resolve.ts +42 -3
- package/src/time-series/spec.ts +2 -2
- package/src/time-series/types.ts +3 -2
- package/src/types/data-provider.ts +11 -0
- package/src/types/financials.ts +48 -4
- package/src/types/headless.ts +1 -0
- package/src/types/issuer-listings.ts +2 -0
- package/src/types/plugin-notifications.ts +3 -0
- package/src/types/price-history.ts +6 -4
- package/src/types/ticker.ts +10 -2
- package/src/ui/host.tsx +2 -0
- package/src/utils/cli-output.ts +1 -1
- package/src/utils/declared-dividends.ts +13 -1
- package/src/utils/dividend-cash.ts +5 -1
- package/src/utils/exchange-announcements.ts +7 -2
- package/src/utils/forward-dividend.ts +4 -3
- package/src/utils/fundamentals.ts +40 -0
- package/src/utils/network-failure.ts +2 -0
- package/src/utils/price-history-integrity.ts +9 -1
- package/src/utils/remove-folder.ts +37 -0
- package/src/utils/trailing-dividend.ts +1 -1
- package/src/plugins/builtin/composite-plugins.ts +0 -285
|
@@ -2,7 +2,7 @@ import type { CloudWorldVenuePayload } from "../../../api-client";
|
|
|
2
2
|
import { colors } from "../../../theme/colors";
|
|
3
3
|
import { CountryFlagLead } from "../../../components/ui/country-flag";
|
|
4
4
|
import { Box, Text, TextAttributes, useUiCapabilities } from "../../../ui";
|
|
5
|
-
import { formatVenueCountdown, formatVenueLocalTime, venueRemainingSeconds } from "./model";
|
|
5
|
+
import { formatVenueCountdown, formatVenueLocalTime, venueRemainingSeconds, venueSession } from "./model";
|
|
6
6
|
|
|
7
7
|
export function SelectedVenueHeader({
|
|
8
8
|
venue,
|
|
@@ -18,7 +18,9 @@ export function SelectedVenueHeader({
|
|
|
18
18
|
const desktop = useUiCapabilities().nativePaneChrome === true;
|
|
19
19
|
if (!venue) return <Box height={2} />;
|
|
20
20
|
const remaining = formatVenueCountdown(venueRemainingSeconds(venue, checkedAt, now));
|
|
21
|
-
|
|
21
|
+
// A holiday, or a US venue's pre-market and after-hours, says so: "closed" alone read as nothing trading.
|
|
22
|
+
const session = venueSession(venue);
|
|
23
|
+
const state = session.toUpperCase();
|
|
22
24
|
const transition = remaining ? `${venue.isOpen ? "closes" : "opens"} ${remaining}` : "";
|
|
23
25
|
const place = (
|
|
24
26
|
<Text fg={colors.textMuted}>
|
|
@@ -29,7 +31,7 @@ export function SelectedVenueHeader({
|
|
|
29
31
|
<Box flexDirection="column" height={2} width={width} paddingX={1}>
|
|
30
32
|
<Box flexDirection="row" justifyContent="space-between" width="100%">
|
|
31
33
|
<Text fg={colors.textBright} attributes={TextAttributes.BOLD}>{venue.mic}</Text>
|
|
32
|
-
<Text fg={venue.isOpen ? colors.positive : colors.textDim}>{state}</Text>
|
|
34
|
+
<Text fg={venue.isOpen ? colors.positive : session === "pre-market" || session === "after-hours" ? colors.warning : colors.textDim}>{state}</Text>
|
|
33
35
|
</Box>
|
|
34
36
|
{desktop ? (
|
|
35
37
|
// The desktop and the web lead the venue's place with its country's flag.
|
|
@@ -44,6 +44,7 @@ import { clinicalTrialsPlugin } from "./builtin/clinical-trials";
|
|
|
44
44
|
import { commentLettersPlugin } from "./builtin/comment-letters";
|
|
45
45
|
import { openFdaPlugin } from "./builtin/openfda";
|
|
46
46
|
import { gloomberbCloudPlugin } from "./builtin/cloud";
|
|
47
|
+
import { browserChatSettings } from "../renderers/browser/notifications";
|
|
47
48
|
import { changelogModule } from "./builtin/changelog";
|
|
48
49
|
import { roadmapModule } from "./builtin/roadmap";
|
|
49
50
|
import { chartComposerModule } from "./builtin/chart-composer";
|
|
@@ -298,7 +299,15 @@ const browserEarningsPlugin = composeBuiltinPlugin({
|
|
|
298
299
|
* browser-safe public API are absent rather than registered behind stubs.
|
|
299
300
|
*/
|
|
300
301
|
export const browserBuiltinPlugins: readonly GloomPlugin[] = [
|
|
301
|
-
|
|
302
|
+
{
|
|
303
|
+
...gloomberbCloudPlugin,
|
|
304
|
+
panes: gloomberbCloudPlugin.panes?.map((pane) => pane.id === "chat"
|
|
305
|
+
? Object.create(Object.getPrototypeOf(pane), {
|
|
306
|
+
...Object.getOwnPropertyDescriptors(pane),
|
|
307
|
+
settings: { value: browserChatSettings, enumerable: true },
|
|
308
|
+
})
|
|
309
|
+
: pane),
|
|
310
|
+
},
|
|
302
311
|
browserPortfolioPlugin,
|
|
303
312
|
browserTickerCorePlugin,
|
|
304
313
|
browserOptionsVolatilityPlugin,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { GloomPlugin } from "../types/plugin";
|
|
2
|
+
import type { LoadedExternalPlugin } from "./loader";
|
|
3
|
+
import { loadBuiltinPlugin } from "./catalog-lazy";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The built-in plugins that contribute an `asset-data` or `news` capability, which is all a command that reads
|
|
7
|
+
* market data needs from the plugins it runs with. Naming them here keeps such a command from loading every
|
|
8
|
+
* other plugin's panes; `catalog-data.test.ts` fails when a plugin outside this list declares one.
|
|
9
|
+
*/
|
|
10
|
+
export const BUILTIN_DATA_PLUGIN_IDS: readonly string[] = ["gloomberb-cloud"];
|
|
11
|
+
|
|
12
|
+
/** The built-in data plugins and the installed plugins that loaded, which may carry data capabilities of their own. */
|
|
13
|
+
export function getLoadableDataPlugins(externalPlugins: LoadedExternalPlugin[] = []): GloomPlugin[] {
|
|
14
|
+
return [
|
|
15
|
+
...BUILTIN_DATA_PLUGIN_IDS.flatMap((id) => loadBuiltinPlugin(id) ?? []),
|
|
16
|
+
...externalPlugins
|
|
17
|
+
.filter((entry) => !entry.needsRestart && !entry.error && !entry.unsupportedTarget)
|
|
18
|
+
.map((entry) => entry.plugin),
|
|
19
|
+
];
|
|
20
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { GloomPlugin } from "../types/plugin";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The built-in plugins of the catalog, each loaded when first asked for. A command line that needs one function,
|
|
5
|
+
* or only the plugin that serves market data, takes that plugin's code and not the other thirty's.
|
|
6
|
+
* `catalog-lazy.test.ts` keeps this list the same as `uiBuiltinPlugins`, which the apps load whole.
|
|
7
|
+
*/
|
|
8
|
+
export interface LazyBuiltinPlugin {
|
|
9
|
+
id: string;
|
|
10
|
+
load(): GloomPlugin;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const lazy = (id: string, load: () => GloomPlugin): LazyBuiltinPlugin => ({ id, load });
|
|
14
|
+
|
|
15
|
+
export const lazyBuiltinPlugins: readonly LazyBuiltinPlugin[] = [
|
|
16
|
+
lazy("gloomberb-cloud", () => require("./builtin/cloud").gloomberbCloudPlugin),
|
|
17
|
+
lazy("portfolio", () => require("./builtin/composite/portfolio").portfolioPlugin),
|
|
18
|
+
lazy("ticker-core", () => require("./builtin/composite/ticker-core").tickerCorePlugin),
|
|
19
|
+
lazy("options-volatility", () => require("./builtin/composite/options-volatility").optionsVolatilityPlugin),
|
|
20
|
+
lazy("ownership", () => require("./builtin/composite/ownership").ownershipPlugin),
|
|
21
|
+
lazy("filings", () => require("./builtin/composite/filings").filingsPlugin),
|
|
22
|
+
lazy("broker", () => require("./builtin/composite/broker").brokerPlugin),
|
|
23
|
+
lazy("application", () => require("./builtin/composite/application").applicationPlugin),
|
|
24
|
+
lazy("news", () => require("./builtin/news").newsPlugin),
|
|
25
|
+
lazy("notes", () => require("./builtin/notes").notesPlugin),
|
|
26
|
+
lazy("custom-view", () => require("./builtin/custom-view").customViewPlugin),
|
|
27
|
+
lazy("global-markets", () => require("./builtin/composite/global-markets").globalMarketsPlugin),
|
|
28
|
+
lazy("screeners", () => require("./builtin/composite/screeners").screenersPlugin),
|
|
29
|
+
lazy("futures-commodities", () => require("./builtin/composite/futures-commodities").futuresCommoditiesPlugin),
|
|
30
|
+
lazy("crypto", () => require("./builtin/composite/crypto").cryptoPlugin),
|
|
31
|
+
lazy("alt-data", () => require("./builtin/composite/alt-data").altDataPlugin),
|
|
32
|
+
lazy("quant", () => require("./builtin/composite/quant").quantPlugin),
|
|
33
|
+
lazy("market-heatmap", () => require("./builtin/market-heatmap").marketHeatmapPlugin),
|
|
34
|
+
lazy("market-halts", () => require("./builtin/market-halts").marketHaltsPlugin),
|
|
35
|
+
lazy("fear-greed", () => require("./builtin/fear-greed").fearGreedPlugin),
|
|
36
|
+
lazy("members", () => require("./builtin/members").membersPlugin),
|
|
37
|
+
lazy("ipo-calendar", () => require("./builtin/ipo-calendar").ipoCalendarPlugin),
|
|
38
|
+
lazy("clinical-trials", () => require("./builtin/clinical-trials").clinicalTrialsPlugin),
|
|
39
|
+
lazy("comment-letters", () => require("./builtin/comment-letters").commentLettersPlugin),
|
|
40
|
+
lazy("openfda", () => require("./builtin/openfda").openFdaPlugin),
|
|
41
|
+
lazy("rates-macro", () => require("./builtin/composite/rates-macro").ratesMacroPlugin),
|
|
42
|
+
lazy("credit", () => require("./builtin/composite/credit").creditPlugin),
|
|
43
|
+
lazy("earnings", () => require("./builtin/composite/earnings").earningsPlugin),
|
|
44
|
+
lazy("alerts", () => require("./builtin/alerts").alertsPlugin),
|
|
45
|
+
lazy("research-search", () => require("./builtin/research-search").researchSearchPlugin),
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
/** The built-in plugin with this id, loaded now; undefined for an id no built-in plugin has. */
|
|
49
|
+
export function loadBuiltinPlugin(id: string): GloomPlugin | undefined {
|
|
50
|
+
return lazyBuiltinPlugins.find((plugin) => plugin.id === id)?.load();
|
|
51
|
+
}
|
|
@@ -14,24 +14,22 @@ import { ipoCalendarPlugin } from "./builtin/ipo-calendar";
|
|
|
14
14
|
import { clinicalTrialsPlugin } from "./builtin/clinical-trials";
|
|
15
15
|
import { commentLettersPlugin } from "./builtin/comment-letters";
|
|
16
16
|
import { openFdaPlugin } from "./builtin/openfda";
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
tickerCorePlugin,
|
|
34
|
-
} from "./builtin/composite-plugins";
|
|
17
|
+
import { altDataPlugin } from "./builtin/composite/alt-data";
|
|
18
|
+
import { applicationPlugin } from "./builtin/composite/application";
|
|
19
|
+
import { brokerPlugin } from "./builtin/composite/broker";
|
|
20
|
+
import { creditPlugin } from "./builtin/composite/credit";
|
|
21
|
+
import { cryptoPlugin } from "./builtin/composite/crypto";
|
|
22
|
+
import { earningsPlugin } from "./builtin/composite/earnings";
|
|
23
|
+
import { filingsPlugin } from "./builtin/composite/filings";
|
|
24
|
+
import { futuresCommoditiesPlugin } from "./builtin/composite/futures-commodities";
|
|
25
|
+
import { globalMarketsPlugin } from "./builtin/composite/global-markets";
|
|
26
|
+
import { optionsVolatilityPlugin } from "./builtin/composite/options-volatility";
|
|
27
|
+
import { ownershipPlugin } from "./builtin/composite/ownership";
|
|
28
|
+
import { portfolioPlugin } from "./builtin/composite/portfolio";
|
|
29
|
+
import { quantPlugin } from "./builtin/composite/quant";
|
|
30
|
+
import { ratesMacroPlugin } from "./builtin/composite/rates-macro";
|
|
31
|
+
import { screenersPlugin } from "./builtin/composite/screeners";
|
|
32
|
+
import { tickerCorePlugin } from "./builtin/composite/ticker-core";
|
|
35
33
|
|
|
36
34
|
export const uiBuiltinPlugins: GloomPlugin[] = [
|
|
37
35
|
gloomberbCloudPlugin,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { mkdirSync, mkdtempSync,
|
|
1
|
+
import { mkdirSync, mkdtempSync, writeFileSync } from "fs";
|
|
2
2
|
import { tmpdir } from "os";
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
|
|
5
|
+
import { logFailure } from "../utils/log-failure";
|
|
6
|
+
import { removeFolder } from "../utils/remove-folder";
|
|
5
7
|
import { loadExternalPlugin } from "./loader";
|
|
6
8
|
|
|
7
9
|
/**
|
|
@@ -101,6 +103,7 @@ export async function smokePluginHostLoad(): Promise<void> {
|
|
|
101
103
|
throw new Error(`The smoke plugin's dependency resolved to its "${probe.platform}" entry instead of "node".`);
|
|
102
104
|
}
|
|
103
105
|
} finally {
|
|
104
|
-
|
|
106
|
+
// A folder Windows still has locked is left behind, not reported as a failed load.
|
|
107
|
+
if (await removeFolder(pluginDir) !== null) logFailure("plugins", "Could not remove the plugin host smoke's temporary folder")(null);
|
|
105
108
|
}
|
|
106
109
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Portfolio, PortfolioCash } from "../types/ticker";
|
|
2
2
|
import type { BrokerAccount } from "../types/trading";
|
|
3
|
+
import { portfolioCashBalances } from "./cash-balances";
|
|
3
4
|
import { currencyMinorDigits, getCurrencySymbol, resolveAssetDisplayKind } from "../market-data/market/format";
|
|
4
5
|
import { MISSING_VALUE, formatNumber } from "../utils/format";
|
|
5
6
|
import { parseTypedNumber } from "../utils/decimal-comma";
|
|
@@ -13,7 +14,8 @@ import { parseTypedNumber } from "../utils/decimal-comma";
|
|
|
13
14
|
* at their net market value plus the cash line. A book that holds a short
|
|
14
15
|
* weighs against its gross exposure instead (WeightBasis). A holding without
|
|
15
16
|
* a price is left out of the total and the weights and is listed as
|
|
16
|
-
* unpriced, never valued at zero
|
|
17
|
+
* unpriced, never valued at zero; so is a currency's cash without a rate
|
|
18
|
+
* into the portfolio's currency.
|
|
17
19
|
*/
|
|
18
20
|
|
|
19
21
|
/** The cash line's symbol in targets and reports. */
|
|
@@ -50,9 +52,33 @@ export interface AllocationFigures {
|
|
|
50
52
|
|
|
51
53
|
type PortfolioAllocationRow = AllocationHolding & AllocationFigures;
|
|
52
54
|
|
|
55
|
+
/** One currency of a portfolio's cash, valued in the portfolio's currency. */
|
|
56
|
+
export interface AllocationCashBalance {
|
|
57
|
+
currency: string;
|
|
58
|
+
/** In `currency`. */
|
|
59
|
+
amount: number;
|
|
60
|
+
/**
|
|
61
|
+
* In the portfolio's currency; null without a rate to convert it, which
|
|
62
|
+
* leaves it out of the total and the weights as a holding without a price is.
|
|
63
|
+
*/
|
|
64
|
+
value: number | null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface PortfolioCashBalanceLine extends AllocationCashBalance {
|
|
68
|
+
/** Its own share of the weight base: null without a value, or against a hedged book's gross exposure. */
|
|
69
|
+
weight: number | null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The cash line: all the portfolio's cash, whatever currencies it is in. Its
|
|
74
|
+
* target (`CASH`), drift and trade are the whole line's; each currency's
|
|
75
|
+
* balance has its own value and weight.
|
|
76
|
+
*/
|
|
53
77
|
export interface PortfolioCashLine extends AllocationFigures {
|
|
54
|
-
/**
|
|
55
|
-
value: number;
|
|
78
|
+
/** All the cash in the portfolio's currency; null while a balance has no rate. */
|
|
79
|
+
value: number | null;
|
|
80
|
+
/** One per currency, largest first, those without a value last; none for a target without cash. */
|
|
81
|
+
balances: PortfolioCashBalanceLine[];
|
|
56
82
|
}
|
|
57
83
|
|
|
58
84
|
export interface PortfolioAllocation {
|
|
@@ -60,7 +86,7 @@ export interface PortfolioAllocation {
|
|
|
60
86
|
rows: PortfolioAllocationRow[];
|
|
61
87
|
/** Present when the portfolio has cash or a cash target. */
|
|
62
88
|
cash: PortfolioCashLine | null;
|
|
63
|
-
/** Priced holdings plus cash; null when it cannot be valued. */
|
|
89
|
+
/** Priced holdings plus the cash that has a value; null when it cannot be valued. */
|
|
64
90
|
total: number | null;
|
|
65
91
|
/** What the weights are a share of. */
|
|
66
92
|
weightBasis: WeightBasis;
|
|
@@ -68,6 +94,8 @@ export interface PortfolioAllocation {
|
|
|
68
94
|
weightBase: number | null;
|
|
69
95
|
/** Held symbols without a price, left out of the total and the weights. */
|
|
70
96
|
unpriced: string[];
|
|
97
|
+
/** The currencies of cash without a rate into the portfolio's, left out of the total and the weights. */
|
|
98
|
+
unpricedCash: string[];
|
|
71
99
|
/** The targets of the listed symbols and cash added up; null when none is set. */
|
|
72
100
|
targetSum: number | null;
|
|
73
101
|
}
|
|
@@ -167,26 +195,43 @@ export function allocationTotal(holdings: readonly AllocationHolding[], cashValu
|
|
|
167
195
|
return Number.isFinite(total) ? total : null;
|
|
168
196
|
}
|
|
169
197
|
|
|
198
|
+
/**
|
|
199
|
+
* The cash the total counts, in the portfolio's currency: every balance with a
|
|
200
|
+
* value. Null without cash, so a book of holdings alone totals as before.
|
|
201
|
+
*/
|
|
202
|
+
export function pricedCashValue(balances: readonly Pick<AllocationCashBalance, "value">[] | null | undefined): number | null {
|
|
203
|
+
if (!balances?.length) return null;
|
|
204
|
+
return balances.reduce((sum, balance) => sum + (finite(balance.value) ? balance.value : 0), 0);
|
|
205
|
+
}
|
|
206
|
+
|
|
170
207
|
export function buildPortfolioAllocation({
|
|
171
208
|
holdings,
|
|
172
|
-
|
|
209
|
+
cash = [],
|
|
173
210
|
targets,
|
|
174
211
|
}: {
|
|
175
212
|
holdings: readonly AllocationHolding[];
|
|
176
|
-
/**
|
|
177
|
-
|
|
213
|
+
/** Each currency's cash, valued in the portfolio's currency (null without a rate). */
|
|
214
|
+
cash?: readonly AllocationCashBalance[] | null;
|
|
178
215
|
targets?: Readonly<Record<string, number>>;
|
|
179
216
|
}): PortfolioAllocation {
|
|
217
|
+
const balances = cash ?? [];
|
|
218
|
+
const cashValue = pricedCashValue(balances);
|
|
180
219
|
const total = allocationTotal(holdings, cashValue);
|
|
181
220
|
const base = allocationWeightBase(holdings, cashValue);
|
|
221
|
+
// Cash is no exposure: against a gross base it keeps its target but has no weight or trade.
|
|
222
|
+
const cashBase = base.basis === "gross" ? null : base.value;
|
|
182
223
|
const rows = holdings.map((holding) => ({ ...holding, ...allocationFigures(holding, base.value, holdingTarget(targets, holding.symbol)) }));
|
|
183
224
|
const cashTarget = targets?.[CASH_SYMBOL];
|
|
184
|
-
|
|
225
|
+
// The whole line is unknown while one balance is: its weight and trade would leave that balance out.
|
|
226
|
+
const lineValue = balances.every((balance) => finite(balance.value)) ? cashValue ?? 0 : null;
|
|
227
|
+
const cashLine = balances.length > 0 || finite(cashTarget)
|
|
185
228
|
? {
|
|
186
|
-
value:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
229
|
+
value: lineValue,
|
|
230
|
+
balances: balances
|
|
231
|
+
.map((balance) => ({ ...balance, weight: finite(balance.value) ? lotWeight(balance.value, cashBase) : null }))
|
|
232
|
+
.sort((left, right) => (finite(left.value) ? 0 : 1) - (finite(right.value) ? 0 : 1)
|
|
233
|
+
|| Math.abs(right.value ?? 0) - Math.abs(left.value ?? 0)),
|
|
234
|
+
...allocationFigures({ held: true, marketValue: lineValue, units: 0, unitPrice: null }, cashBase, cashTarget),
|
|
190
235
|
}
|
|
191
236
|
: null;
|
|
192
237
|
let targetSum: number | null = null;
|
|
@@ -196,11 +241,12 @@ export function buildPortfolioAllocation({
|
|
|
196
241
|
}
|
|
197
242
|
return {
|
|
198
243
|
rows,
|
|
199
|
-
cash,
|
|
244
|
+
cash: cashLine,
|
|
200
245
|
total,
|
|
201
246
|
weightBasis: base.basis,
|
|
202
247
|
weightBase: base.value,
|
|
203
248
|
unpriced: holdings.filter((holding) => holding.held && !finite(holding.marketValue)).map((holding) => holding.symbol),
|
|
249
|
+
unpricedCash: balances.filter((balance) => !finite(balance.value)).map((balance) => balance.currency),
|
|
204
250
|
targetSum,
|
|
205
251
|
};
|
|
206
252
|
}
|
|
@@ -218,18 +264,32 @@ export function hasTargetWeights(portfolio: Pick<Portfolio, "targetWeights"> | n
|
|
|
218
264
|
return !!portfolio?.targetWeights && Object.keys(portfolio.targetWeights).length > 0;
|
|
219
265
|
}
|
|
220
266
|
|
|
267
|
+
/** A portfolio's cash, in the currencies it is held in, and where it is from. */
|
|
268
|
+
export interface ResolvedPortfolioCash {
|
|
269
|
+
/** Recorded with `portfolio cash set`, or reported by the broker account. */
|
|
270
|
+
source: "broker" | "manual";
|
|
271
|
+
/** One balance per currency: the broker account's total cash, or each currency entered by hand. */
|
|
272
|
+
balances: PortfolioCash[];
|
|
273
|
+
}
|
|
274
|
+
|
|
221
275
|
/**
|
|
222
|
-
* The portfolio's cash
|
|
223
|
-
*
|
|
276
|
+
* The portfolio's cash. A broker account that reports its cash is used
|
|
277
|
+
* instead of the balances entered by hand, so the two never add up.
|
|
224
278
|
*/
|
|
225
279
|
export function resolvePortfolioCash(
|
|
226
|
-
portfolio: Pick<Portfolio, "cash"> | null | undefined,
|
|
280
|
+
portfolio: Pick<Portfolio, "cash" | "otherCash"> | null | undefined,
|
|
227
281
|
account: Pick<BrokerAccount, "totalCashValue" | "currency"> | null | undefined,
|
|
228
|
-
):
|
|
282
|
+
): ResolvedPortfolioCash | null {
|
|
229
283
|
if (account && finite(account.totalCashValue)) {
|
|
230
|
-
return { amount: account.totalCashValue, currency: account.currency?.trim().toUpperCase() ?? ""
|
|
284
|
+
return { source: "broker", balances: [{ amount: account.totalCashValue, currency: account.currency?.trim().toUpperCase() ?? "" }] };
|
|
231
285
|
}
|
|
232
|
-
|
|
286
|
+
const balances = portfolioCashBalances(portfolio);
|
|
287
|
+
return balances.length > 0 ? { source: "manual", balances } : null;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** What a cash row is called: `CASH`, or `CASH TRY` for a currency other than the portfolio's or one of several. */
|
|
291
|
+
export function cashLineLabel(currency: string | null | undefined, portfolioCurrency: string, several = false): string {
|
|
292
|
+
return currency && (several || currency !== portfolioCurrency) ? `${CASH_SYMBOL} ${currency}` : CASH_SYMBOL;
|
|
233
293
|
}
|
|
234
294
|
|
|
235
295
|
/**
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Portfolio, PortfolioCash } from "../types/ticker";
|
|
2
|
+
import { isRecord } from "../utils/guards";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A manual portfolio's cash, one balance per currency (HKD and USD side by
|
|
6
|
+
* side). The first balance is saved in `Portfolio.cash`, which every build
|
|
7
|
+
* before several currencies reads, and the others in `Portfolio.otherCash`,
|
|
8
|
+
* so such a build sees one valid balance and never a second copy of it.
|
|
9
|
+
* Every reader takes the balances from `portfolioCashBalances`, which counts
|
|
10
|
+
* each currency once, and every writer saves them with
|
|
11
|
+
* `withPortfolioCashBalances`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const CURRENCY_CODE = /^[A-Z]{3}$/;
|
|
15
|
+
|
|
16
|
+
/** A balance as saved: a finite amount in an upper-case ISO code; null for anything else. */
|
|
17
|
+
function savedBalance(value: unknown): PortfolioCash | null {
|
|
18
|
+
if (!isRecord(value) || typeof value.amount !== "number" || !Number.isFinite(value.amount)) return null;
|
|
19
|
+
return typeof value.currency === "string" && CURRENCY_CODE.test(value.currency)
|
|
20
|
+
? { amount: value.amount, currency: value.currency }
|
|
21
|
+
: null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The portfolio's cash entered by hand, `cash` first and then the other
|
|
26
|
+
* currencies in the order they were set. A currency is counted once: a
|
|
27
|
+
* second entry of it (an older build that set `cash` to a currency
|
|
28
|
+
* `otherCash` also holds) gives way to the first, which is `cash`.
|
|
29
|
+
*/
|
|
30
|
+
export function portfolioCashBalances(portfolio: Pick<Portfolio, "cash" | "otherCash"> | null | undefined): PortfolioCash[] {
|
|
31
|
+
if (!portfolio) return [];
|
|
32
|
+
const balances: PortfolioCash[] = [];
|
|
33
|
+
const others: unknown[] = Array.isArray(portfolio.otherCash) ? portfolio.otherCash : [];
|
|
34
|
+
for (const entry of [portfolio.cash, ...others]) {
|
|
35
|
+
const balance = savedBalance(entry);
|
|
36
|
+
if (balance && !balances.some((kept) => kept.currency === balance.currency)) balances.push(balance);
|
|
37
|
+
}
|
|
38
|
+
return balances;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The portfolio holding these balances: the first in `cash`, the others in
|
|
43
|
+
* `otherCash`, neither field when there are none. Each currency once, the
|
|
44
|
+
* first entry of it kept.
|
|
45
|
+
*/
|
|
46
|
+
export function withPortfolioCashBalances<T extends object>(
|
|
47
|
+
portfolio: T,
|
|
48
|
+
balances: readonly PortfolioCash[],
|
|
49
|
+
): Omit<T, "cash" | "otherCash"> & Pick<Portfolio, "cash" | "otherCash"> {
|
|
50
|
+
const { cash: _cash, otherCash: _otherCash, ...rest } = portfolio as T & Pick<Portfolio, "cash" | "otherCash">;
|
|
51
|
+
const [first, ...others] = portfolioCashBalances({ otherCash: [...balances] });
|
|
52
|
+
return {
|
|
53
|
+
...rest,
|
|
54
|
+
...(first ? { cash: first } : {}),
|
|
55
|
+
...(others.length > 0 ? { otherCash: others } : {}),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A pulled portfolio from a build that does not send `otherCash` (an older
|
|
61
|
+
* desktop build, which strips it from every push), keeping the other
|
|
62
|
+
* currencies this device holds. That build saw `cash` alone, so its `cash`
|
|
63
|
+
* stands, set, replaced or cleared, and a balance here in that same currency
|
|
64
|
+
* gives way to it rather than counting twice. Anything else is taken as it
|
|
65
|
+
* came.
|
|
66
|
+
*/
|
|
67
|
+
export function withKeptOtherCash(pulled: unknown, local: Pick<Portfolio, "cash" | "otherCash"> | null | undefined): unknown {
|
|
68
|
+
if (!isRecord(pulled) || pulled.otherCash !== undefined || !local) return pulled;
|
|
69
|
+
const [, ...others] = portfolioCashBalances(local);
|
|
70
|
+
if (others.length === 0) return pulled;
|
|
71
|
+
const seen = savedBalance(pulled.cash);
|
|
72
|
+
return withPortfolioCashBalances(pulled, [
|
|
73
|
+
...(seen ? [seen] : []),
|
|
74
|
+
...others.filter((balance) => balance.currency !== seen?.currency),
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
@@ -6,6 +6,7 @@ import { parseCollectionRef } from "../team/collections";
|
|
|
6
6
|
import { findNamedCollection } from "./collection-name";
|
|
7
7
|
import { isFuturesTicker } from "./futures-positions";
|
|
8
8
|
import { manualPortfolioLots, mergeLotCostTerms, type LotCostFxConflict } from "./manual-lots";
|
|
9
|
+
import { portfolioCashBalances, withPortfolioCashBalances } from "./cash-balances";
|
|
9
10
|
|
|
10
11
|
export interface DeleteWatchlistResult {
|
|
11
12
|
config: AppConfig;
|
|
@@ -225,20 +226,54 @@ function updatePortfolio(config: AppConfig, portfolioId: string, update: (portfo
|
|
|
225
226
|
};
|
|
226
227
|
}
|
|
227
228
|
|
|
228
|
-
/**
|
|
229
|
-
|
|
229
|
+
/**
|
|
230
|
+
* Records the cash a portfolio holds in one currency, beside its positions and
|
|
231
|
+
* its cash in any other currency, which stay. `replaced` is that currency's
|
|
232
|
+
* earlier balance when it differs from the new one, for the caller to say
|
|
233
|
+
* what went (HK$38,000.00 replaced by HK$39,000.00), and null when there was
|
|
234
|
+
* none or it was the same. `balances` is all the cash after the change.
|
|
235
|
+
*/
|
|
236
|
+
export function setPortfolioCash(
|
|
237
|
+
config: AppConfig,
|
|
238
|
+
portfolioId: string,
|
|
239
|
+
cash: PortfolioCash,
|
|
240
|
+
): { config: AppConfig; replaced: PortfolioCash | null; balances: PortfolioCash[] } {
|
|
230
241
|
const currency = cash.currency.trim().toUpperCase();
|
|
231
242
|
if (!Number.isFinite(cash.amount)) throw new Error("Cash amount must be a valid number.");
|
|
232
243
|
if (!/^[A-Z]{3}$/.test(currency)) throw new Error(`"${cash.currency}" is not a currency code such as USD or EUR.`);
|
|
233
|
-
|
|
244
|
+
const before = portfolioCashBalances(config.portfolios.find((portfolio) => portfolio.id === portfolioId));
|
|
245
|
+
const previous = before.find((balance) => balance.currency === currency);
|
|
246
|
+
const replaced = previous && previous.amount !== 0 && previous.amount !== cash.amount ? { ...previous } : null;
|
|
247
|
+
// A currency held already keeps its place, so the first balance stays the one an older build reads.
|
|
248
|
+
const balances = previous
|
|
249
|
+
? before.map((balance) => (balance.currency === currency ? { amount: cash.amount, currency } : balance))
|
|
250
|
+
: [...before, { amount: cash.amount, currency }];
|
|
251
|
+
return {
|
|
252
|
+
config: updatePortfolio(config, portfolioId, (portfolio) => withPortfolioCashBalances(portfolio, balances)),
|
|
253
|
+
replaced,
|
|
254
|
+
balances,
|
|
255
|
+
};
|
|
234
256
|
}
|
|
235
257
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Clears a portfolio's cash in one currency, or in every currency when none
|
|
260
|
+
* is given. `removed` is the balances cleared, empty when there was nothing
|
|
261
|
+
* to clear; `balances` is the cash left.
|
|
262
|
+
*/
|
|
263
|
+
export function clearPortfolioCash(
|
|
264
|
+
config: AppConfig,
|
|
265
|
+
portfolioId: string,
|
|
266
|
+
currency?: string,
|
|
267
|
+
): { config: AppConfig; removed: PortfolioCash[]; balances: PortfolioCash[] } {
|
|
268
|
+
const wanted = currency?.trim().toUpperCase();
|
|
269
|
+
const before = portfolioCashBalances(config.portfolios.find((entry) => entry.id === portfolioId));
|
|
270
|
+
const removed = before.filter((balance) => wanted == null || balance.currency === wanted);
|
|
271
|
+
if (removed.length === 0) return { config, removed, balances: before };
|
|
272
|
+
const balances = before.filter((balance) => !removed.includes(balance));
|
|
239
273
|
return {
|
|
240
|
-
config: updatePortfolio(config, portfolioId, (
|
|
241
|
-
|
|
274
|
+
config: updatePortfolio(config, portfolioId, (portfolio) => withPortfolioCashBalances(portfolio, balances)),
|
|
275
|
+
removed,
|
|
276
|
+
balances,
|
|
242
277
|
};
|
|
243
278
|
}
|
|
244
279
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function isBrowserAppActive(): boolean {
|
|
2
|
+
return !document.hidden && document.hasFocus();
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function subscribeBrowserAppActivity(listener: (active: boolean) => void): () => void {
|
|
6
|
+
const update = () => listener(isBrowserAppActive());
|
|
7
|
+
window.addEventListener("focus", update);
|
|
8
|
+
window.addEventListener("blur", update);
|
|
9
|
+
document.addEventListener("visibilitychange", update);
|
|
10
|
+
update();
|
|
11
|
+
return () => {
|
|
12
|
+
window.removeEventListener("focus", update);
|
|
13
|
+
window.removeEventListener("blur", update);
|
|
14
|
+
document.removeEventListener("visibilitychange", update);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { installAppBadgeHost } from "../../notifications/app-badge";
|
|
2
|
+
|
|
3
|
+
export function installBrowserAppBadgeHost(doc: Pick<Document, "title"> = document): () => void {
|
|
4
|
+
const title = doc.title;
|
|
5
|
+
const uninstall = installAppBadgeHost({
|
|
6
|
+
setBadge(label) {
|
|
7
|
+
doc.title = label ? `(${label}) ${title}` : title;
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
return () => {
|
|
11
|
+
uninstall();
|
|
12
|
+
doc.title = title;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -20,6 +20,9 @@ import {
|
|
|
20
20
|
import { loadWebBundledPlugins } from "./bundled-plugins";
|
|
21
21
|
import { BROWSER_DATA_DIR, hasSavedBrowserConfig, installBrowserConfigStore } from "./config-host";
|
|
22
22
|
import { browserRendererHost, browserUiHost } from "./ui-host";
|
|
23
|
+
import { installBrowserAppBadgeHost } from "./app-badge-host";
|
|
24
|
+
import { isBrowserAppActive } from "./activity";
|
|
25
|
+
import { setAppActive } from "../../state/app/activity";
|
|
23
26
|
import { createBrowserDeepLinkBridge } from "./deeplink-bridge";
|
|
24
27
|
import { initializeBrowserResearchActivity, recordResearchActivity } from "../../api-client/research-activity";
|
|
25
28
|
import { flushPendingPersistence } from "../../state/persist-scheduler";
|
|
@@ -101,6 +104,8 @@ async function boot(): Promise<void> {
|
|
|
101
104
|
applyLanguageFromConfig(config);
|
|
102
105
|
const externalPlugins = await bundledPlugins;
|
|
103
106
|
const deepLinkBridge = createBrowserDeepLinkBridge();
|
|
107
|
+
installBrowserAppBadgeHost();
|
|
108
|
+
setAppActive(isBrowserAppActive());
|
|
104
109
|
root.render(
|
|
105
110
|
<DomErrorBoundary label="Browser renderer crashed" fallback={(error) => (
|
|
106
111
|
<div className="gloom-fatal">
|