@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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { GloomPlugin } from "../types/plugin";
|
|
2
1
|
import { logFailure } from "../utils/log-failure";
|
|
3
2
|
import { SeriesRegistry } from "./registry";
|
|
3
|
+
import { type SeriesPlugins, pluginsOf } from "./standalone";
|
|
4
4
|
import type { SeriesCatalogEntry } from "./types";
|
|
5
5
|
|
|
6
6
|
let standaloneEntries: (() => readonly SeriesCatalogEntry[]) | null = null;
|
|
@@ -10,7 +10,7 @@ let standaloneEntries: (() => readonly SeriesCatalogEntry[]) | null = null;
|
|
|
10
10
|
* where no plugin runtime runs: the series the plugins declare, registered
|
|
11
11
|
* once on first read. Null forgets it.
|
|
12
12
|
*/
|
|
13
|
-
export function setStandaloneSeriesCatalog(plugins:
|
|
13
|
+
export function setStandaloneSeriesCatalog(plugins: SeriesPlugins | null, disabledPlugins: readonly string[] = []): void {
|
|
14
14
|
if (!plugins) {
|
|
15
15
|
standaloneEntries = null;
|
|
16
16
|
return;
|
|
@@ -18,8 +18,9 @@ export function setStandaloneSeriesCatalog(plugins: readonly GloomPlugin[] | nul
|
|
|
18
18
|
let entries: readonly SeriesCatalogEntry[] | null = null;
|
|
19
19
|
standaloneEntries = () => {
|
|
20
20
|
if (entries) return entries;
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const all = pluginsOf(plugins);
|
|
22
|
+
const registry = new SeriesRegistry({ pluginHosts: (pluginId) => all.find((plugin) => plugin.id === pluginId)?.hosts });
|
|
23
|
+
for (const plugin of all) {
|
|
23
24
|
if (disabledPlugins.includes(plugin.id)) continue;
|
|
24
25
|
for (const definition of plugin.series ?? []) {
|
|
25
26
|
try {
|
package/src/series/standalone.ts
CHANGED
|
@@ -7,6 +7,11 @@ import { readSeriesFolder } from "./files";
|
|
|
7
7
|
import { SeriesRegistry, seriesExpression, seriesNamedBy } from "./registry";
|
|
8
8
|
import type { SeriesDefinition } from "./types";
|
|
9
9
|
|
|
10
|
+
/** The plugins a series lookup reads: a list, or a function that gives it once a series is first asked for. */
|
|
11
|
+
export type SeriesPlugins = readonly GloomPlugin[] | (() => readonly GloomPlugin[]);
|
|
12
|
+
|
|
13
|
+
export const pluginsOf = (plugins: SeriesPlugins): readonly GloomPlugin[] => typeof plugins === "function" ? plugins() : plugins;
|
|
14
|
+
|
|
10
15
|
/**
|
|
11
16
|
* Charts the catalog's loaded series where no plugin runtime runs, such as a
|
|
12
17
|
* `gloom fn G` report: the series plugins declare, and the files in the
|
|
@@ -14,13 +19,14 @@ import type { SeriesDefinition } from "./types";
|
|
|
14
19
|
* need the app.
|
|
15
20
|
*/
|
|
16
21
|
export function standaloneSeriesInvoker(
|
|
17
|
-
plugins:
|
|
22
|
+
plugins: SeriesPlugins,
|
|
18
23
|
dataDir: string,
|
|
19
24
|
disabledPlugins: readonly string[] = [],
|
|
20
25
|
): CapabilityInvoker {
|
|
21
26
|
let registry: Promise<SeriesRegistry> | null = null;
|
|
22
27
|
const build = async () => {
|
|
23
|
-
const
|
|
28
|
+
const all = pluginsOf(plugins);
|
|
29
|
+
const built = new SeriesRegistry({ pluginHosts: (pluginId) => all.find((plugin) => plugin.id === pluginId)?.hosts });
|
|
24
30
|
const register = (pluginId: string, definitions: readonly Parameters<SeriesRegistry["register"]>[1][]) => {
|
|
25
31
|
for (const definition of definitions) {
|
|
26
32
|
try {
|
|
@@ -30,7 +36,7 @@ export function standaloneSeriesInvoker(
|
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
38
|
};
|
|
33
|
-
for (const plugin of
|
|
39
|
+
for (const plugin of all) {
|
|
34
40
|
if (!disabledPlugins.includes(plugin.id)) register(plugin.id, plugin.series ?? []);
|
|
35
41
|
}
|
|
36
42
|
register("user", await readSeriesFolder(dataDir));
|
|
@@ -56,14 +62,14 @@ export function standaloneSeriesInvoker(
|
|
|
56
62
|
* the registry's `findByExpression` does.
|
|
57
63
|
*/
|
|
58
64
|
export function standaloneSeriesCatalog(
|
|
59
|
-
plugins:
|
|
65
|
+
plugins: SeriesPlugins,
|
|
60
66
|
disabledPlugins: readonly string[] = [],
|
|
61
67
|
): (expression: string) => SeriesDefinition | undefined {
|
|
62
68
|
let byExpression: Map<string, SeriesDefinition> | null = null;
|
|
63
69
|
return (expression) => {
|
|
64
70
|
if (!byExpression) {
|
|
65
71
|
byExpression = new Map();
|
|
66
|
-
for (const plugin of plugins) {
|
|
72
|
+
for (const plugin of pluginsOf(plugins)) {
|
|
67
73
|
if (disabledPlugins.includes(plugin.id)) continue;
|
|
68
74
|
for (const definition of plugin.series ?? []) {
|
|
69
75
|
if (definition.input) continue;
|
|
@@ -78,9 +84,9 @@ export function standaloneSeriesCatalog(
|
|
|
78
84
|
|
|
79
85
|
/** The catalog series a bare word is an alias of (`hashrate`), where no plugin runtime runs; see `seriesNamedBy`. */
|
|
80
86
|
export function standaloneSeriesNamed(
|
|
81
|
-
plugins:
|
|
87
|
+
plugins: SeriesPlugins,
|
|
82
88
|
disabledPlugins: readonly string[] = [],
|
|
83
89
|
): (word: string) => SeriesDefinition | undefined {
|
|
84
|
-
const definitions = () => plugins.filter((plugin) => !disabledPlugins.includes(plugin.id)).flatMap((plugin) => plugin.series ?? []);
|
|
90
|
+
const definitions = () => pluginsOf(plugins).filter((plugin) => !disabledPlugins.includes(plugin.id)).flatMap((plugin) => plugin.series ?? []);
|
|
85
91
|
return (word) => seriesNamedBy(definitions(), word);
|
|
86
92
|
}
|
|
@@ -88,6 +88,7 @@ import {
|
|
|
88
88
|
perpetualTarget,
|
|
89
89
|
searchPerpetualMarkets,
|
|
90
90
|
boardSearchesFrom,
|
|
91
|
+
PerpetualBoardCache,
|
|
91
92
|
} from "./perpetuals";
|
|
92
93
|
import { predictionMarketListing } from "../../tickers/prediction-listing";
|
|
93
94
|
import { cleanListingName } from "../../tickers/company-name";
|
|
@@ -105,6 +106,11 @@ const QUOTE_BATCHES_IN_FLIGHT = 3;
|
|
|
105
106
|
const PERPETUAL_SEARCH_WAIT_MS = 2_000;
|
|
106
107
|
/** How long a batched search waits for the board it answers every query's perpetual markets from. */
|
|
107
108
|
const PERPETUAL_BOARD_WAIT_MS = 5_000;
|
|
109
|
+
/** A bare symbol a command looks up (AAPL, MCO), not a search the person typed to browse: `search` and the command bar keep the contracts. */
|
|
110
|
+
function isSymbolLookup(query: string, context?: SearchRequestContext): boolean {
|
|
111
|
+
return !context?.interactive && context?.perpetuals !== "always" && /^[A-Za-z][A-Za-z0-9]{1,5}$/.test(query.trim());
|
|
112
|
+
}
|
|
113
|
+
|
|
108
114
|
const CLOUD_RESOLUTION_SUPPORT = normalizeChartResolutionSupport([
|
|
109
115
|
{ resolution: "1m", maxRange: "1W" },
|
|
110
116
|
{ resolution: "5m", maxRange: "1M" },
|
|
@@ -254,8 +260,9 @@ function mapCloudPriceHistory(
|
|
|
254
260
|
&& requestedStart.getTime() < Date.parse(coverageStart)) throw new HistoryCoverageError(coverageStart);
|
|
255
261
|
// The server marks a cached copy it could not refresh in time. Bars that
|
|
256
262
|
// reach the venue's latest settled session still answer, and the router's
|
|
257
|
-
// own current-window check applies to them as to any other copy. Older bars
|
|
258
|
-
//
|
|
263
|
+
// own current-window check applies to them as to any other copy. Older bars
|
|
264
|
+
// are a miss that carries them, shown as behind when no source has the
|
|
265
|
+
// present; a stale answer without bars is a miss.
|
|
259
266
|
const stale = isStaleCloudResponse(response);
|
|
260
267
|
if (stale && response.status !== "success" && response.status !== "partial") {
|
|
261
268
|
throw new StaleHistoryError(`Cloud chart data is stale for ${ticker}`);
|
|
@@ -282,9 +289,6 @@ function mapCloudPriceHistory(
|
|
|
282
289
|
`Cloud chart data is unavailable for ${ticker}`,
|
|
283
290
|
).map((point) => mapPricePoint(point, divisor, exchange, coin)),
|
|
284
291
|
);
|
|
285
|
-
if (stale && !reachesLatestSettledSession(points, Date.now(), { symbol: ticker, exchange, intervalMs: priceHistoryIntervalMs(interval) })) {
|
|
286
|
-
throw new StaleHistoryError(`Cloud chart data is stale for ${ticker}`);
|
|
287
|
-
}
|
|
288
292
|
const intraday = /^\d+(min|h)$/i.test(interval);
|
|
289
293
|
// Daily bars answering an intraday range: the listing has no intraday bars.
|
|
290
294
|
const dailyBars = intraday && response.servedResolution === "1day";
|
|
@@ -309,7 +313,7 @@ function mapCloudPriceHistory(
|
|
|
309
313
|
// Sessions of daily bars the answer left out for a close at or below zero.
|
|
310
314
|
const nonPositiveCloseDates = resolution === "1d" ? cloudNonPositiveCloseDates(response.omittedSessions) : undefined;
|
|
311
315
|
const delisting = parseListingDelisting(response.delisting);
|
|
312
|
-
|
|
316
|
+
const result: PriceHistoryResult = {
|
|
313
317
|
points,
|
|
314
318
|
resolution,
|
|
315
319
|
...(delisting ? { delisting } : {}),
|
|
@@ -319,6 +323,10 @@ function mapCloudPriceHistory(
|
|
|
319
323
|
...(coverageNote ? { coverageNote } : {}),
|
|
320
324
|
...(extendedHours ? { extendedHours: true } : {}),
|
|
321
325
|
};
|
|
326
|
+
if (stale && !reachesLatestSettledSession(points, Date.now(), { symbol: ticker, exchange, intervalMs: priceHistoryIntervalMs(interval) })) {
|
|
327
|
+
throw new StaleHistoryError(`Cloud chart data is stale for ${ticker}`, result);
|
|
328
|
+
}
|
|
329
|
+
return result;
|
|
322
330
|
}
|
|
323
331
|
|
|
324
332
|
/**
|
|
@@ -524,6 +532,10 @@ function perpetualFinancials(quote: Quote): TickerFinancials {
|
|
|
524
532
|
}
|
|
525
533
|
|
|
526
534
|
export class GloomberbCloudProvider implements AssetDataProvider {
|
|
535
|
+
/** See `AssetDataProvider.knownUsStock`; this provider asks for no perpetual contracts of such a symbol either. */
|
|
536
|
+
knownUsStock?: (symbol: string) => boolean;
|
|
537
|
+
private readonly perpetualBoards = new PerpetualBoardCache();
|
|
538
|
+
|
|
527
539
|
readonly id = providerId;
|
|
528
540
|
readonly name = "Gloom Cloud";
|
|
529
541
|
readonly priority = 100;
|
|
@@ -733,7 +745,8 @@ export class GloomberbCloudProvider implements AssetDataProvider {
|
|
|
733
745
|
async search(query: string, context?: SearchRequestContext): Promise<InstrumentSearchResult[]> {
|
|
734
746
|
// Perpetual markets are listings too, asked for beside the others. They are optional: a failed lookup leaves the
|
|
735
747
|
// other results, and a keystroke waits for them only briefly once the listings are in, unless the query names one.
|
|
736
|
-
const pending =
|
|
748
|
+
const pending = isSymbolLookup(query, context) && this.knownUsStock?.(query) === true ? null
|
|
749
|
+
: searchPerpetualMarkets(query, apiClient, this.perpetualBoards).catch(logFailure("sources.gloomberb-cloud.index", "Searching perpetual markets failed", [] as InstrumentSearchResult[]));
|
|
737
750
|
// A crypto exchange's line of a coin pair, which no source quotes, is offered as the crypto venue's listing.
|
|
738
751
|
const listings = await withCloudFallback(
|
|
739
752
|
async () => withExchangeLinesAsCoinListings(withCleanNames(
|
|
@@ -743,7 +756,7 @@ export class GloomberbCloudProvider implements AssetDataProvider {
|
|
|
743
756
|
// Rate limited or overloaded: the search was not run, which is not a search that found nothing.
|
|
744
757
|
throw isRetryableApiError(error) ? new ProviderBusyError("Cloud search is busy", { cause: error }) : error;
|
|
745
758
|
});
|
|
746
|
-
const perpetuals = await settleWithin(pending, namesPerpetualMarket(query) || !context?.interactive ? PERPETUAL_SEARCH_WAIT_MS : 250) ?? [];
|
|
759
|
+
const perpetuals = pending ? await settleWithin(pending, namesPerpetualMarket(query) || !context?.interactive ? PERPETUAL_SEARCH_WAIT_MS : 250) ?? [] : [];
|
|
747
760
|
// Ahead of the listings, so a contract found by its plain name ("brent" for BZUSDT:BINANCE) is not cut
|
|
748
761
|
// behind every warrant that names it; an exact symbol still leads.
|
|
749
762
|
return perpetuals.length ? [...perpetuals, ...listings] : listings;
|
|
@@ -860,7 +873,7 @@ export class GloomberbCloudProvider implements AssetDataProvider {
|
|
|
860
873
|
// on its own, which finds them then; a board that does not answer leaves them out, as a search does.
|
|
861
874
|
const found = queries.filter((query) => answers.get(query)?.length);
|
|
862
875
|
const board = found.length
|
|
863
|
-
? await settleWithin(
|
|
876
|
+
? await settleWithin(this.perpetualBoards.read(apiClient).catch(logFailure("sources.gloomberb-cloud.index", "Reading the perpetual board failed", null)), PERPETUAL_BOARD_WAIT_MS)
|
|
864
877
|
: null;
|
|
865
878
|
if (!board) return answers;
|
|
866
879
|
const client = boardSearchesFrom(board);
|
|
@@ -2,6 +2,7 @@ import { normalizeNewsFeed } from "../../news/news-model";
|
|
|
2
2
|
import { readableNewsSource } from "../../news/source-label";
|
|
3
3
|
import { collectNewsDisplayTickers } from "../../news/ticker-symbols";
|
|
4
4
|
import type { NewsAccess, NewsArticle, NewsQuery, NewsStoryItem } from "../../types/news-source";
|
|
5
|
+
import type { NewsInsiderFiling } from "../../news/types";
|
|
5
6
|
import { CLOUD_NEWS_DELAY_HOURS } from "../../api-client/plan-rules";
|
|
6
7
|
import type {
|
|
7
8
|
apiClient,
|
|
@@ -82,6 +83,39 @@ function mapCloudNewsStoryItem(
|
|
|
82
83
|
};
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
const ISO_DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
87
|
+
const ACCESSION = /^\d{10}-\d{2}-\d{6}$/;
|
|
88
|
+
const positive = (value: unknown): value is number => typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
89
|
+
|
|
90
|
+
/** The Form 4s a story reports, each one whole: a filing a field of which does not read is left out. */
|
|
91
|
+
function insiderFilings(payload: CloudNewsPayload["insiderFilings"]): NewsInsiderFiling[] {
|
|
92
|
+
if (!Array.isArray(payload)) return [];
|
|
93
|
+
return payload.flatMap((filing): NewsInsiderFiling[] => {
|
|
94
|
+
if (!filing || !ACCESSION.test(filing.accession) || !filing.insider?.trim()) return [];
|
|
95
|
+
if (!ISO_DAY.test(filing.firstTradeDate) || !ISO_DAY.test(filing.lastTradeDate) || !ISO_DAY.test(filing.filedOn)) return [];
|
|
96
|
+
if (!positive(filing.shares) || !positive(filing.value) || !positive(filing.weightedPrice) || !Number.isInteger(filing.lines)) return [];
|
|
97
|
+
if (filing.side !== "sale" && filing.side !== "purchase") return [];
|
|
98
|
+
return [{
|
|
99
|
+
accession: filing.accession,
|
|
100
|
+
form: filing.form || "4",
|
|
101
|
+
filedOn: filing.filedOn,
|
|
102
|
+
issuerName: filing.issuerName?.trim() || null,
|
|
103
|
+
ticker: filing.ticker?.trim().toUpperCase() || null,
|
|
104
|
+
insider: filing.insider.trim(),
|
|
105
|
+
title: filing.title?.trim() || null,
|
|
106
|
+
side: filing.side,
|
|
107
|
+
firstTradeDate: filing.firstTradeDate,
|
|
108
|
+
lastTradeDate: filing.lastTradeDate,
|
|
109
|
+
lines: filing.lines,
|
|
110
|
+
shares: filing.shares,
|
|
111
|
+
value: filing.value,
|
|
112
|
+
weightedPrice: filing.weightedPrice,
|
|
113
|
+
rule10b51: typeof filing.rule10b51 === "boolean" ? filing.rule10b51 : null,
|
|
114
|
+
url: /^https:\/\/www\.sec\.gov\//.test(filing.url) ? filing.url : "",
|
|
115
|
+
}];
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
85
119
|
/** A folded row's notices, when the service says how many (two or more) and since when. */
|
|
86
120
|
function routineNotices(payload: CloudNewsPayload["routine"]): NewsArticle["routine"] | null {
|
|
87
121
|
if (!payload || !Number.isInteger(payload.notices) || payload.notices < 2) return null;
|
|
@@ -133,6 +167,7 @@ export function mapCloudNewsArticle(
|
|
|
133
167
|
sourceCount: item.sourceCount,
|
|
134
168
|
items: item.items?.map(mapCloudNewsStoryItem) ?? [],
|
|
135
169
|
...(routineNotices(item.routine) ? { routine: routineNotices(item.routine)! } : {}),
|
|
170
|
+
...(item.insiderFilings ? { insiderFilings: insiderFilings(item.insiderFilings) } : {}),
|
|
136
171
|
};
|
|
137
172
|
}
|
|
138
173
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { apiClient } from "../../api-client";
|
|
2
|
+
import { logFailure } from "../../utils/log-failure";
|
|
2
3
|
import type { PerpBoardPayload, PerpBoardRow, PerpMarketPayload } from "../../api-client/perps";
|
|
3
4
|
import type { InstrumentSearchResult } from "../../types/instrument";
|
|
4
5
|
import type { PricePoint, Quote } from "../../types/financials";
|
|
@@ -23,7 +24,7 @@ import { GLOOMBERB_CLOUD_PROVIDER_ID } from "./normalizers";
|
|
|
23
24
|
* its history is Pro, as in PERP.
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
|
-
type PerpsClient = Pick<typeof apiClient, "getCloudPerpsMarket" | "getCloudPerpsBoard" | "getCloudPerpsHistory"
|
|
27
|
+
type PerpsClient = Pick<typeof apiClient, "getCloudPerpsMarket" | "getCloudPerpsBoard" | "getCloudPerpsHistory"> & Partial<Pick<typeof apiClient, "hasSessionCredential" | "getSessionToken">>;
|
|
27
28
|
|
|
28
29
|
/** What the history of a perpetual says to a free account, as PERP's History tab does. */
|
|
29
30
|
export const PERPETUAL_HISTORY_LOCKED = "Full history requires Gloom Pro.";
|
|
@@ -207,6 +208,57 @@ export function boardSearchesFrom(board: PerpBoardPayload, client: PerpsClient =
|
|
|
207
208
|
};
|
|
208
209
|
}
|
|
209
210
|
|
|
211
|
+
/** How long the board a signed-out search reads stays in memory: a command lives for seconds, an open app for much longer. */
|
|
212
|
+
const SEARCH_BOARD_TTL_MS = 5 * 60_000;
|
|
213
|
+
|
|
214
|
+
/** Who a client is asking for: no one, the session it holds, or the browser's own cookie. The board differs between them. */
|
|
215
|
+
function boardAudience(client: PerpsClient): string {
|
|
216
|
+
if (!client.hasSessionCredential?.()) return "signed-out";
|
|
217
|
+
return client.getSessionToken?.() ?? "cookie";
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The board without a search, read once while it is fresh and for whom it was read. A signed-out account's search is
|
|
222
|
+
* the preview rows that hold its word (`boardSearchesFrom`), so every search of a command costs this one request. A
|
|
223
|
+
* signed-in account's board is the whole of it, which only a list's searches (`searchBatch`) read. A provider holds
|
|
224
|
+
* one, so a process reads the board once however many symbols it looks up; signing in, out or into another account
|
|
225
|
+
* reads it again, since the rows a signed-out preview leaves out are the ones a Pro account is shown.
|
|
226
|
+
*/
|
|
227
|
+
export class PerpetualBoardCache {
|
|
228
|
+
private kept: { readAt: number; audience: string; board: Promise<PerpBoardPayload> } | null = null;
|
|
229
|
+
|
|
230
|
+
read(client: PerpsClient = apiClient): Promise<PerpBoardPayload> {
|
|
231
|
+
const audience = boardAudience(client);
|
|
232
|
+
const kept = this.kept;
|
|
233
|
+
if (kept && kept.audience === audience && Date.now() - kept.readAt < SEARCH_BOARD_TTL_MS) return kept.board;
|
|
234
|
+
const entry = { readAt: Date.now(), audience, board: client.getCloudPerpsBoard({}) };
|
|
235
|
+
this.kept = entry;
|
|
236
|
+
void entry.board.catch(() => {
|
|
237
|
+
if (this.kept === entry) this.kept = null;
|
|
238
|
+
});
|
|
239
|
+
return entry.board;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* The client a search asks the board with: a signed-out account's one-word search is answered from the board read
|
|
245
|
+
* once, with the rows the service would have sent; any other search goes to the service.
|
|
246
|
+
*/
|
|
247
|
+
function searchBoardClient(client: PerpsClient, boards: PerpetualBoardCache): PerpsClient {
|
|
248
|
+
if (client.hasSessionCredential?.()) return client;
|
|
249
|
+
return {
|
|
250
|
+
getCloudPerpsMarket: client.getCloudPerpsMarket,
|
|
251
|
+
getCloudPerpsHistory: client.getCloudPerpsHistory,
|
|
252
|
+
getCloudPerpsBoard: async (query = {}) => {
|
|
253
|
+
const { search, ...rest } = query;
|
|
254
|
+
const word = search?.trim();
|
|
255
|
+
if (!word || /\s/.test(word) || Object.values(rest).some((value) => value !== undefined)) return client.getCloudPerpsBoard(query);
|
|
256
|
+
const board = await boards.read(client).catch(logFailure("sources.gloomberb-cloud.perpetuals", "Reading the perpetual board for a search failed", null));
|
|
257
|
+
return board ? boardSearchesFrom(board, client).getCloudPerpsBoard({ search: word }) : client.getCloudPerpsBoard(query);
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
210
262
|
/** The one market a query names by its market id or listing key; null for a search. */
|
|
211
263
|
const namedListing = (query: string) => typedPerpetualListing(query) ?? (query.includes(":") ? perpetualListing(query) : null);
|
|
212
264
|
|
|
@@ -224,7 +276,11 @@ const MAX_ALIAS_SEARCHES = 3;
|
|
|
224
276
|
* Hyperliquid's BRENTOIL). A free account searches the board's preview, as
|
|
225
277
|
* PERP's own search does, but can still name any one market.
|
|
226
278
|
*/
|
|
227
|
-
export async function searchPerpetualMarkets(
|
|
279
|
+
export async function searchPerpetualMarkets(
|
|
280
|
+
query: string,
|
|
281
|
+
client: PerpsClient = apiClient,
|
|
282
|
+
cache: PerpetualBoardCache = new PerpetualBoardCache(),
|
|
283
|
+
): Promise<InstrumentSearchResult[]> {
|
|
228
284
|
const trimmed = query.trim();
|
|
229
285
|
const named = namedListing(trimmed);
|
|
230
286
|
if (named) {
|
|
@@ -252,8 +308,9 @@ export async function searchPerpetualMarkets(query: string, client: PerpsClient
|
|
|
252
308
|
keep: (row: PerpBoardRow) => row.assetClass === assetClass && row.baseAsset.toUpperCase() === symbol,
|
|
253
309
|
})),
|
|
254
310
|
];
|
|
311
|
+
const boardClient = searchBoardClient(client, cache);
|
|
255
312
|
const boards = await Promise.all(searches.map(async ({ search, keep }) => {
|
|
256
|
-
const board = await
|
|
313
|
+
const board = await boardClient.getCloudPerpsBoard({ search });
|
|
257
314
|
return (Array.isArray(board?.rows) ? board.rows : []).filter((row) => !row.delisted && keep(row));
|
|
258
315
|
}));
|
|
259
316
|
const seen = new Set<string>();
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DataServiceUnreachableError, isNetworkFailure } from "../utils/network-failure";
|
|
2
|
-
import {
|
|
2
|
+
import { OperationTimeoutError } from "../utils/async-deadline";
|
|
3
|
+
import { ApiRequestError, isTransientFailure, wasAskedTwice } from "../api-client/errors";
|
|
4
|
+
import type { PriceHistoryResult } from "../types/price-history";
|
|
3
5
|
|
|
4
6
|
// Registered, so a miss raised by another copy of this module (a plugin that
|
|
5
7
|
// resolved `gloomberb/market-data` from the source tree) is still recognized.
|
|
@@ -47,11 +49,18 @@ export function createProviderMiss(message?: string, reason?: unknown, options?:
|
|
|
47
49
|
return new ProviderMissError(message, reason, options);
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* A source has the listing's bars but not up to the present: it answered, just
|
|
54
|
+
* behind. `behind` is what it answered, which the router shows, said to be
|
|
55
|
+
* behind, when no source has the present.
|
|
56
|
+
*/
|
|
51
57
|
export class StaleHistoryError extends ProviderMissError {
|
|
52
|
-
|
|
58
|
+
readonly behind?: PriceHistoryResult;
|
|
59
|
+
|
|
60
|
+
constructor(message: string, behind?: PriceHistoryResult) {
|
|
53
61
|
super(message);
|
|
54
62
|
this.name = "StaleHistoryError";
|
|
63
|
+
if (behind) this.behind = behind;
|
|
55
64
|
}
|
|
56
65
|
}
|
|
57
66
|
|
|
@@ -136,8 +145,15 @@ export function isNoProviderMessage(message: string): boolean {
|
|
|
136
145
|
* data, since asked again in a moment it may. "for SYMBOL" closes the first
|
|
137
146
|
* sentence, so a table's note can name several symbols in front of it.
|
|
138
147
|
*/
|
|
139
|
-
export function serviceDidNotAnswerMessage(symbol?: string): string {
|
|
140
|
-
|
|
148
|
+
export function serviceDidNotAnswerMessage(symbol?: string, failure?: unknown): string {
|
|
149
|
+
// A source the service reads that took too long (TIMEOUT) is said as a timeout, never as no source for the symbol.
|
|
150
|
+
const then = serviceSourceTimedOut(failure) ? "Its source timed out; try again in a moment." : "Try again in a moment.";
|
|
151
|
+
return `Gloom's data service did not answer${symbol ? ` for ${symbol}` : ""}. ${then}`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Whether the data service answered that the source it reads timed out (reason TIMEOUT), asked twice. */
|
|
155
|
+
function serviceSourceTimedOut(failure: unknown): boolean {
|
|
156
|
+
return failure instanceof Error && failure.message.trim() === "TIMEOUT";
|
|
141
157
|
}
|
|
142
158
|
|
|
143
159
|
/** The router's generic answer that no provider served a request, holding the failure behind it when a provider failed rather than missed. */
|
|
@@ -154,7 +170,8 @@ class NoProviderError extends Error {
|
|
|
154
170
|
* the data service, and a listing read the data service failed to answer twice
|
|
155
171
|
* (`wasAskedTwice`, `serviceDidNotAnswerMessage`), each of which says that
|
|
156
172
|
* rather than that no source has the symbol; any other failure, a 5xx on a read
|
|
157
|
-
* that is not asked again among them, keeps the generic message.
|
|
173
|
+
* that is not asked again among them, keeps the generic message. A timeout
|
|
174
|
+
* on a working connection is kept in its own words as well.
|
|
158
175
|
*/
|
|
159
176
|
export function noProviderError(message: string, note: ProviderMissNote | undefined, symbol?: string): Error {
|
|
160
177
|
if (note?.reason) return createProviderMiss(note.reason, note.reason);
|
|
@@ -162,7 +179,8 @@ export function noProviderError(message: string, note: ProviderMissNote | undefi
|
|
|
162
179
|
if (isNetworkFailure(note?.failure)) {
|
|
163
180
|
return note!.failure instanceof DataServiceUnreachableError ? note!.failure : new DataServiceUnreachableError(note!.failure);
|
|
164
181
|
}
|
|
165
|
-
if (
|
|
182
|
+
if (note?.failure instanceof OperationTimeoutError) return new NoProviderError(note.failure.message, note.failure);
|
|
183
|
+
if (wasAskedTwice(note?.failure)) return new NoProviderError(serviceDidNotAnswerMessage(symbol, note!.failure), note!.failure);
|
|
166
184
|
if (note?.failure instanceof ApiRequestError && note.failure.status === 429) {
|
|
167
185
|
return new NoProviderError(rateLimitedMessage(symbol, note.failure.retryAfterMs), note.failure);
|
|
168
186
|
}
|
|
@@ -188,6 +206,15 @@ export function isSourceFailure(error: unknown): boolean {
|
|
|
188
206
|
return error instanceof NoProviderError && error.failure !== undefined;
|
|
189
207
|
}
|
|
190
208
|
|
|
209
|
+
/**
|
|
210
|
+
* A source failure (`isSourceFailure`) that asking again shortly may get
|
|
211
|
+
* past: the source timed out, was rate limited or overloaded
|
|
212
|
+
* (`isTransientFailure`). A source that refused the read is not one.
|
|
213
|
+
*/
|
|
214
|
+
export function isTransientSourceFailure(error: unknown): boolean {
|
|
215
|
+
return error instanceof NoProviderError && error.failure !== undefined && isTransientFailure(error.failure);
|
|
216
|
+
}
|
|
217
|
+
|
|
191
218
|
/**
|
|
192
219
|
* The router's bare "No history provider available": no source failed, none
|
|
193
220
|
* gave a reason or said the symbol is unknown, and none served bars it could
|
|
@@ -148,35 +148,42 @@ function isQuoteInActiveSession(quote: Quote, now: number): boolean {
|
|
|
148
148
|
const OPENING_AUCTION_MS = 15 * 60_000;
|
|
149
149
|
|
|
150
150
|
/**
|
|
151
|
-
* Whether Gloom Cloud vouches that a
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
151
|
+
* Whether Gloom Cloud vouches that a quote is current, however long ago its
|
|
152
|
+
* last trade was. The service judges more than that trade's age: it knows
|
|
153
|
+
* when it asked for the quote and how often the listing trades, so a thinly
|
|
154
|
+
* traded listing's hour-old trade can be the current price while its venue
|
|
155
|
+
* trades. Its verdict stands in for the age bound when:
|
|
156
156
|
* - the service answered on this request, or a cache entry still inside its
|
|
157
157
|
* TTL holds that answer (`recentAnswer`); a copy past the TTL is not vouched for;
|
|
158
158
|
* - the answer says `stale: false`. One without the flag vouches for nothing,
|
|
159
159
|
* and one flagged stale never gets this far;
|
|
160
|
-
* - the quote is delayed. The service bounds a delayed quote's feed age itself
|
|
161
|
-
* but not a real-time one's, so real-time quotes keep the age bound;
|
|
162
|
-
* - it reports the regular session, the venue's session is in progress as
|
|
163
|
-
* the delayed feed shows it, and the trade belongs to that session; a
|
|
164
|
-
* currency pair's session is the service's to judge; or
|
|
165
160
|
* - it reports a US extended-hours session and the trade is no older than
|
|
166
161
|
* the regular session that session extends: after the close, today's
|
|
167
162
|
* regular session or its after-hours; before the open, the previous
|
|
168
163
|
* regular session or anything since. Whether the quote carries the
|
|
169
|
-
* session's price is the freshness rule's call, made before this one.
|
|
164
|
+
* session's price is the freshness rule's call, made before this one. The
|
|
165
|
+
* service bounds an extended-hours print's age itself, real-time or
|
|
166
|
+
* delayed: past half an hour it asks the source again and keeps the print
|
|
167
|
+
* only when the source shows nothing has traded since. GS after hours on
|
|
168
|
+
* 16 Nov 2026 went more than ten minutes between trades, and its real-time
|
|
169
|
+
* quote was dropped as stuck, so the put screen had no price for it; or
|
|
170
|
+
* - the quote is delayed, it reports the regular session, the venue's
|
|
171
|
+
* session is in progress as the delayed feed shows it, and the trade
|
|
172
|
+
* belongs to that session; a currency pair's session is the service's to
|
|
173
|
+
* judge. The service bounds a delayed quote's feed age in the regular
|
|
174
|
+
* session but not a real-time one's, so there real-time quotes keep the
|
|
175
|
+
* age bound.
|
|
170
176
|
* The answer says nothing about how often a listing trades, so a liquid
|
|
171
177
|
* listing the service wrongly vouches for is accepted too. The service's own
|
|
172
178
|
* bound for liquid listings, about twenty minutes, is tighter than this one.
|
|
173
179
|
*/
|
|
174
180
|
function isVouchedCurrentByService(quote: Quote, exchange: string | undefined, now: number): boolean {
|
|
175
|
-
if (quote.providerId !== "gloomberb-cloud" || quote.stale !== false
|
|
181
|
+
if (quote.providerId !== "gloomberb-cloud" || quote.stale !== false) return false;
|
|
182
|
+
if (quote.dataSource !== "live" && quote.dataSource !== "delayed") return false;
|
|
176
183
|
if (quote.marketState === "PRE" || quote.marketState === "POST") {
|
|
177
184
|
return isUsExtendedHoursSessionPrint(quote.lastUpdated, exchange, quote.marketState, now);
|
|
178
185
|
}
|
|
179
|
-
if (quote.marketState !== "REGULAR") return false;
|
|
186
|
+
if (quote.dataSource !== "delayed" || quote.marketState !== "REGULAR") return false;
|
|
180
187
|
// A currency pair trades around the clock through the week, and the service
|
|
181
188
|
// measures its silence against how often that pair prints: a pegged or
|
|
182
189
|
// exotic pair such as SAR=X goes hours without a print while its feed is fine.
|
|
@@ -87,6 +87,18 @@ interface HistoryAttempts {
|
|
|
87
87
|
misses: ProviderMissNote;
|
|
88
88
|
coverageError?: HistoryCoverageError;
|
|
89
89
|
retention?: HistoryRetention;
|
|
90
|
+
/** The furthest-reaching bars a source answered and marked as stopping short of the present (StaleHistoryError). */
|
|
91
|
+
behind?: PriceHistoryResult;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function noteBehindAnswer(attempts: HistoryAttempts | undefined, value: PriceHistoryResult): void {
|
|
95
|
+
if (!attempts || !hasUsablePriceHistory(value.points)) return;
|
|
96
|
+
if (!attempts.behind || lastBarTime(value) > lastBarTime(attempts.behind)) attempts.behind = value;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function lastBarTime(value: PriceHistoryResult): number {
|
|
100
|
+
const last = value.points.at(-1);
|
|
101
|
+
return last ? getPricePointTimestamp(last) : Number.NEGATIVE_INFINITY;
|
|
90
102
|
}
|
|
91
103
|
|
|
92
104
|
function recordHistoryOutcome(attempts: HistoryAttempts | undefined, sourceKey: string, outcome: HistorySourceOutcome["outcome"], status?: number): void {
|
|
@@ -128,6 +140,7 @@ function recordHistoryError(attempts: HistoryAttempts | undefined, request: Hist
|
|
|
128
140
|
if (error instanceof StaleHistoryError) {
|
|
129
141
|
// It has the bars, only not up to the present: behind, as a stale copy it served would be.
|
|
130
142
|
recordHistoryOutcome(attempts, sourceKey, "stale");
|
|
143
|
+
if (error.behind) noteBehindAnswer(attempts, normalizeRequestResult({ ...error.behind, sourceKey }, request));
|
|
131
144
|
} else if (error instanceof InvalidHistoryResultError) {
|
|
132
145
|
recordHistoryOutcome(attempts, sourceKey, "malformed");
|
|
133
146
|
} else if (isHistoryRetentionError(error)) {
|
|
@@ -750,11 +763,21 @@ export class ProviderRouterHistoryRoutes {
|
|
|
750
763
|
// empty chart. Intraday copies expire two days after they are saved. A
|
|
751
764
|
// coin never closes, so its old copy is not shown: the miss says why.
|
|
752
765
|
const coin = isRoundTheClockCoin(target.symbol, target.exchange || request.target.exchange);
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
.filter((record) => !supersededCacheSources.has(record.sourceKey));
|
|
766
|
+
const fallbackEntries = ranked.filter((entry) => !supersededCacheSources.has(entry.record.sourceKey));
|
|
767
|
+
const fallbackRecords = fallbackEntries.map((entry) => entry.record);
|
|
756
768
|
const fallbackRecord = fallbackRecords.find((record) => !request.isCachedValueStale(record.value, record.fetchedAt))
|
|
757
769
|
?? (coin ? undefined : fallbackRecords[0]);
|
|
770
|
+
// A source's own answer that stops short of the present (the service's
|
|
771
|
+
// stored series while its source refuses) is shown, said to be behind, as
|
|
772
|
+
// a saved copy short of the latest session is: unless a copy is current or
|
|
773
|
+
// reaches further. A coin's is not, in the current window, for the reason
|
|
774
|
+
// its old copy is not.
|
|
775
|
+
const behindAnswer = coin && currentWindow ? undefined : attempts.behind;
|
|
776
|
+
const fallbackCurrent = !!fallbackRecord && !request.isCachedValueStale(fallbackRecord.value, fallbackRecord.fetchedAt)
|
|
777
|
+
&& fallbackEntries.find((entry) => entry.record === fallbackRecord)?.tier === 0;
|
|
778
|
+
if (behindAnswer && !fallbackCurrent && (!fallbackRecord || lastBarTime(behindAnswer) >= lastBarTime(fallbackRecord.value))) {
|
|
779
|
+
return withReportedGaps({ ...behindAnswer, savedCopyBehind: true });
|
|
780
|
+
}
|
|
758
781
|
if (fallbackRecord) {
|
|
759
782
|
// A copy short of the latest session says so, so the chart can tell it
|
|
760
783
|
// from a current one: a thin listing's complete copy is not behind.
|
|
@@ -773,10 +796,13 @@ export class ProviderRouterHistoryRoutes {
|
|
|
773
796
|
const candidates = [...attempts.candidates.values()].sort((a, b) => sourceOrder.indexOf(a.sourceKey) - sourceOrder.indexOf(b.sourceKey));
|
|
774
797
|
throw new HistoryRetentionError(candidates[0]?.retention ?? attempts.retention, { candidates, outcomes: [...attempts.outcomes.values()] });
|
|
775
798
|
}
|
|
799
|
+
// A source answered but its history stops short of the present, and was not shown (a coin's, one without
|
|
800
|
+
// bars, or one this router's own check finds behind): say so, not that nothing answered.
|
|
801
|
+
if (!providerResult && !reportedGaps.some((value) => value.points.length > 0)
|
|
802
|
+
&& [...attempts.outcomes.values()].some((outcome) => outcome.outcome === "stale")) {
|
|
803
|
+
throw new Error(`Latest history for ${target.symbol} is behind`);
|
|
804
|
+
}
|
|
776
805
|
if (!providerResult && request.missingProviderError && !reportedGaps.some((value) => value.points.length > 0)) {
|
|
777
|
-
// A source answered a coin's history but it stops short of the present: say so, not that nothing answered.
|
|
778
|
-
const behind = coin && [...attempts.outcomes.values()].some((outcome) => outcome.outcome === "stale");
|
|
779
|
-
if (behind) throw new Error(`Latest history for ${target.symbol} is behind`);
|
|
780
806
|
// A reason the service gave ("ADX listings have daily bars only.") says why; one that has no
|
|
781
807
|
// listing for the symbol says it is not a ticker; otherwise no source answered. A coin trades
|
|
782
808
|
// around the clock and its sources are there: they could not answer just now. So could a
|
|
@@ -409,6 +409,10 @@ export class AssetDataRouter implements DataProvider {
|
|
|
409
409
|
return this.searchRoutes.searchBatch(queries, options);
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
+
knownUsStock(symbol: string): boolean {
|
|
413
|
+
return this.providersInPriorityOrder().some((provider) => provider.knownUsStock?.(symbol) === true);
|
|
414
|
+
}
|
|
415
|
+
|
|
412
416
|
/** The first source that answers a batch of symbol changes; null when none can or it fails. */
|
|
413
417
|
async getTickerChangesBatch(symbols: string[], options?: { signal?: AbortSignal }): Promise<Map<string, TickerChanges | null> | null> {
|
|
414
418
|
const provider = this.providersInPriorityOrder().find((candidate) => candidate.getTickerChangesBatch);
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
} from "./analytics-payload";
|
|
25
25
|
import { idEntries } from "./broker-instances";
|
|
26
26
|
import { CORE_CONFIG_CONTRIBUTOR_ID, log } from "./config-contributor";
|
|
27
|
-
import { sanitizePortfolio, sanitizeWatchlist, WATCHLISTS_CARRY_GROUPS } from "./sanitize";
|
|
27
|
+
import { PORTFOLIOS_CARRY_OTHER_CASH, sanitizePortfolio, sanitizeWatchlist, WATCHLISTS_CARRY_GROUPS } from "./sanitize";
|
|
28
28
|
import {
|
|
29
29
|
lastSyncedTickersById,
|
|
30
30
|
latestBrokerPortfolioSyncs,
|
|
@@ -55,6 +55,8 @@ export function collectCoreCollectionsPayload(
|
|
|
55
55
|
baseCurrency: config.baseCurrency,
|
|
56
56
|
exchangeRates: { USD: 1 },
|
|
57
57
|
portfolios: config.portfolios.map(sanitizePortfolio),
|
|
58
|
+
// The portfolios carry their cash in other currencies, as the config payload's do.
|
|
59
|
+
[PORTFOLIOS_CARRY_OTHER_CASH]: true,
|
|
58
60
|
watchlists: config.watchlists.map(sanitizeWatchlist),
|
|
59
61
|
// The lists carry their groups, as the config payload's do: a reader can tell a list without them from an older build's.
|
|
60
62
|
[WATCHLISTS_CARRY_GROUPS]: true,
|
package/src/sync/config-merge.ts
CHANGED
|
@@ -29,11 +29,13 @@ import {
|
|
|
29
29
|
type LayoutMergeContext,
|
|
30
30
|
} from "./layout-merge";
|
|
31
31
|
import {
|
|
32
|
+
PORTFOLIOS_CARRY_OTHER_CASH,
|
|
32
33
|
sanitizeBrokerInstance,
|
|
33
34
|
sanitizePortfolio,
|
|
34
35
|
sanitizeUnknown,
|
|
35
36
|
sanitizeWatchlist,
|
|
36
37
|
WATCHLISTS_CARRY_GROUPS,
|
|
38
|
+
withLocalOtherCash,
|
|
37
39
|
withLocalPluginSecrets,
|
|
38
40
|
withLocalWatchlistGroups,
|
|
39
41
|
} from "./sanitize";
|
|
@@ -44,6 +46,8 @@ export function collectCoreConfigPayload(config: AppConfig) {
|
|
|
44
46
|
baseCurrency: config.baseCurrency,
|
|
45
47
|
refreshIntervalMinutes: config.refreshIntervalMinutes,
|
|
46
48
|
portfolios: config.portfolios.map(sanitizePortfolio),
|
|
49
|
+
// The portfolios carry their cash in other currencies: one without it holds no more.
|
|
50
|
+
[PORTFOLIOS_CARRY_OTHER_CASH]: true,
|
|
47
51
|
watchlists: config.watchlists.map(sanitizeWatchlist),
|
|
48
52
|
[WATCHLISTS_CARRY_GROUPS]: true,
|
|
49
53
|
...collectLayoutPayload(config),
|
|
@@ -166,10 +170,15 @@ export function mergeConfigPayload(
|
|
|
166
170
|
payload.brokerInstancesMergedById === true,
|
|
167
171
|
);
|
|
168
172
|
}
|
|
173
|
+
// An older build pushes its portfolios without their cash in other currencies: they keep what they hold here.
|
|
169
174
|
if ("portfolios" in payload && canApply("portfolios")) {
|
|
170
175
|
const syncedPortfolios = payload.portfolios;
|
|
171
176
|
next.portfolios = Array.isArray(syncedPortfolios)
|
|
172
|
-
? mergeLocalBrokerPortfolioIdentity(
|
|
177
|
+
? mergeLocalBrokerPortfolioIdentity(
|
|
178
|
+
config.portfolios,
|
|
179
|
+
withLocalOtherCash(syncedPortfolios, config.portfolios, payload[PORTFOLIOS_CARRY_OTHER_CASH] === true),
|
|
180
|
+
next.brokerInstances,
|
|
181
|
+
)
|
|
173
182
|
: syncedPortfolios as AppConfig["portfolios"];
|
|
174
183
|
}
|
|
175
184
|
// An older build pushes its lists without their groups: they keep the groups they have here.
|