@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
package/src/i18n/ja.ts
CHANGED
|
@@ -1612,6 +1612,12 @@ export const ja: Record<string, string> = {
|
|
|
1612
1612
|
"TICKERS": "銘柄",
|
|
1613
1613
|
"Which tickers do you follow?": "どの銘柄をフォローしていますか?",
|
|
1614
1614
|
"Pick up to 3 for your watchlist.": "ウォッチリストに入れる銘柄を最大3つ選べます。",
|
|
1615
|
+
// "Where did you hear about Gloom?", once, after an account signs up
|
|
1616
|
+
"Where did you hear about Gloom?": "Gloom をどこで知りましたか?",
|
|
1617
|
+
"AI assistant": "AI アシスタント",
|
|
1618
|
+
"Friend or colleague": "友人・同僚",
|
|
1619
|
+
"Article or newsletter": "記事・ニュースレター",
|
|
1620
|
+
"Where?": "どこで?",
|
|
1615
1621
|
"Skip": "スキップ",
|
|
1616
1622
|
"Equities": "株式",
|
|
1617
1623
|
"Futures & commodities": "先物・コモディティ",
|
|
@@ -1822,4 +1828,25 @@ export const ja: Record<string, string> = {
|
|
|
1822
1828
|
"pre": "開始前",
|
|
1823
1829
|
"post": "時間外",
|
|
1824
1830
|
"closed": "休場",
|
|
1831
|
+
// ── Pro: the first weeks' row and the paid cancel ──────────
|
|
1832
|
+
"Try Pro on your tickers": "あなたの銘柄で Pro を試す",
|
|
1833
|
+
"Try Pro": "Pro を試す",
|
|
1834
|
+
"Stop suggesting Pro functions": "Pro 機能の提案を表示しない",
|
|
1835
|
+
"Open {command}": "{command} を開く",
|
|
1836
|
+
"Options flow": "オプションフロー",
|
|
1837
|
+
"X mentions": "X での言及",
|
|
1838
|
+
"Hiring": "採用",
|
|
1839
|
+
"8-K events": "8-K イベント",
|
|
1840
|
+
"Risk factors": "リスク要因",
|
|
1841
|
+
"Cancel Pro": "Pro を解約",
|
|
1842
|
+
"Cancel Pro?": "Pro を解約しますか?",
|
|
1843
|
+
"Keep Pro": "Pro を続ける",
|
|
1844
|
+
"Pro until {date}": "Pro({date} まで)",
|
|
1845
|
+
"Cancelling...": "解約中...",
|
|
1846
|
+
"Cancel Subscription": "サブスクリプションを解約",
|
|
1847
|
+
"Keep My Subscription": "サブスクリプションを続ける",
|
|
1848
|
+
"Continue Cancellation": "解約を続ける",
|
|
1849
|
+
"Pro stays on until {date}.": "Pro は {date} までご利用いただけます。",
|
|
1850
|
+
"Pro stays on until {date}. Cancelling now stops the renewal after that date.": "Pro は {date} までご利用いただけます。今解約すると、その日以降は更新されません。",
|
|
1851
|
+
"Cancelled. Pro stays on until {date}.": "解約しました。Pro は {date} までご利用いただけます。",
|
|
1825
1852
|
};
|
package/src/i18n/ko.ts
CHANGED
|
@@ -1610,6 +1610,12 @@ export const ko: Record<string, string> = {
|
|
|
1610
1610
|
"TICKERS": "종목",
|
|
1611
1611
|
"Which tickers do you follow?": "어떤 종목을 팔로우하시나요?",
|
|
1612
1612
|
"Pick up to 3 for your watchlist.": "관심 목록에 넣을 종목을 최대 3개까지 고르세요.",
|
|
1613
|
+
// "Where did you hear about Gloom?", once, after an account signs up
|
|
1614
|
+
"Where did you hear about Gloom?": "Gloom을 어디서 알게 되셨나요?",
|
|
1615
|
+
"AI assistant": "AI 어시스턴트",
|
|
1616
|
+
"Friend or colleague": "친구 또는 동료",
|
|
1617
|
+
"Article or newsletter": "기사 또는 뉴스레터",
|
|
1618
|
+
"Where?": "어디서?",
|
|
1613
1619
|
"Skip": "건너뛰기",
|
|
1614
1620
|
"Equities": "주식",
|
|
1615
1621
|
"Futures & commodities": "선물 및 원자재",
|
|
@@ -1820,4 +1826,25 @@ export const ko: Record<string, string> = {
|
|
|
1820
1826
|
"pre": "장전",
|
|
1821
1827
|
"post": "장후",
|
|
1822
1828
|
"closed": "휴장",
|
|
1829
|
+
// ── Pro: the first weeks' row and the paid cancel ──────────
|
|
1830
|
+
"Try Pro on your tickers": "내 종목으로 Pro 써보기",
|
|
1831
|
+
"Try Pro": "Pro 써보기",
|
|
1832
|
+
"Stop suggesting Pro functions": "Pro 기능 추천 그만 보기",
|
|
1833
|
+
"Open {command}": "{command} 열기",
|
|
1834
|
+
"Options flow": "옵션 플로우",
|
|
1835
|
+
"X mentions": "X 언급",
|
|
1836
|
+
"Hiring": "채용",
|
|
1837
|
+
"8-K events": "8-K 이벤트",
|
|
1838
|
+
"Risk factors": "위험 요인",
|
|
1839
|
+
"Cancel Pro": "Pro 해지",
|
|
1840
|
+
"Cancel Pro?": "Pro를 해지할까요?",
|
|
1841
|
+
"Keep Pro": "Pro 유지",
|
|
1842
|
+
"Pro until {date}": "Pro ({date}까지)",
|
|
1843
|
+
"Cancelling...": "해지 중...",
|
|
1844
|
+
"Cancel Subscription": "구독 해지",
|
|
1845
|
+
"Keep My Subscription": "구독 유지",
|
|
1846
|
+
"Continue Cancellation": "계속 해지",
|
|
1847
|
+
"Pro stays on until {date}.": "Pro는 {date}까지 유지됩니다.",
|
|
1848
|
+
"Pro stays on until {date}. Cancelling now stops the renewal after that date.": "Pro는 {date}까지 유지됩니다. 지금 해지하면 그 날짜 이후 갱신되지 않습니다.",
|
|
1849
|
+
"Cancelled. Pro stays on until {date}.": "해지되었습니다. Pro는 {date}까지 유지됩니다.",
|
|
1823
1850
|
};
|
package/src/i18n/zh-cn.ts
CHANGED
|
@@ -1612,6 +1612,12 @@ export const zhCN: Record<string, string> = {
|
|
|
1612
1612
|
"TICKERS": "标的",
|
|
1613
1613
|
"Which tickers do you follow?": "你关注哪些标的?",
|
|
1614
1614
|
"Pick up to 3 for your watchlist.": "最多选 3 个加入自选列表。",
|
|
1615
|
+
// "Where did you hear about Gloom?", once, after an account signs up
|
|
1616
|
+
"Where did you hear about Gloom?": "你是从哪里知道 Gloom 的?",
|
|
1617
|
+
"AI assistant": "AI 助手",
|
|
1618
|
+
"Friend or colleague": "朋友或同事",
|
|
1619
|
+
"Article or newsletter": "文章或新闻通讯",
|
|
1620
|
+
"Where?": "在哪里?",
|
|
1615
1621
|
"Skip": "跳过",
|
|
1616
1622
|
"Equities": "股票",
|
|
1617
1623
|
"Futures & commodities": "期货与大宗商品",
|
|
@@ -1822,4 +1828,25 @@ export const zhCN: Record<string, string> = {
|
|
|
1822
1828
|
"pre": "盘前",
|
|
1823
1829
|
"post": "盘后",
|
|
1824
1830
|
"closed": "休市",
|
|
1831
|
+
// ── Pro: the first weeks' row and the paid cancel ──────────
|
|
1832
|
+
"Try Pro on your tickers": "在你的标的上试试 Pro",
|
|
1833
|
+
"Try Pro": "试试 Pro",
|
|
1834
|
+
"Stop suggesting Pro functions": "不再推荐 Pro 功能",
|
|
1835
|
+
"Open {command}": "打开 {command}",
|
|
1836
|
+
"Options flow": "期权流",
|
|
1837
|
+
"X mentions": "X 提及",
|
|
1838
|
+
"Hiring": "招聘",
|
|
1839
|
+
"8-K events": "8-K 事件",
|
|
1840
|
+
"Risk factors": "风险因素",
|
|
1841
|
+
"Cancel Pro": "取消 Pro",
|
|
1842
|
+
"Cancel Pro?": "取消 Pro?",
|
|
1843
|
+
"Keep Pro": "保留 Pro",
|
|
1844
|
+
"Pro until {date}": "Pro 至 {date}",
|
|
1845
|
+
"Cancelling...": "正在取消...",
|
|
1846
|
+
"Cancel Subscription": "取消订阅",
|
|
1847
|
+
"Keep My Subscription": "保留我的订阅",
|
|
1848
|
+
"Continue Cancellation": "继续取消",
|
|
1849
|
+
"Pro stays on until {date}.": "Pro 将保留至 {date}。",
|
|
1850
|
+
"Pro stays on until {date}. Cancelling now stops the renewal after that date.": "Pro 将保留至 {date}。现在取消会在该日期后停止续订。",
|
|
1851
|
+
"Cancelled. Pro stays on until {date}.": "已取消。Pro 将保留至 {date}。",
|
|
1825
1852
|
};
|
package/src/i18n/zh-tw.ts
CHANGED
|
@@ -1612,6 +1612,12 @@ export const zhTW: Record<string, string> = {
|
|
|
1612
1612
|
"TICKERS": "標的",
|
|
1613
1613
|
"Which tickers do you follow?": "你關注哪些標的?",
|
|
1614
1614
|
"Pick up to 3 for your watchlist.": "最多選 3 個加入自選清單。",
|
|
1615
|
+
// "Where did you hear about Gloom?", once, after an account signs up
|
|
1616
|
+
"Where did you hear about Gloom?": "你是從哪裡知道 Gloom 的?",
|
|
1617
|
+
"AI assistant": "AI 助理",
|
|
1618
|
+
"Friend or colleague": "朋友或同事",
|
|
1619
|
+
"Article or newsletter": "文章或電子報",
|
|
1620
|
+
"Where?": "在哪裡?",
|
|
1615
1621
|
"Skip": "略過",
|
|
1616
1622
|
"Equities": "股票",
|
|
1617
1623
|
"Futures & commodities": "期貨與大宗商品",
|
|
@@ -1822,4 +1828,25 @@ export const zhTW: Record<string, string> = {
|
|
|
1822
1828
|
"pre": "盤前",
|
|
1823
1829
|
"post": "盤後",
|
|
1824
1830
|
"closed": "休市",
|
|
1831
|
+
// ── Pro: the first weeks' row and the paid cancel ──────────
|
|
1832
|
+
"Try Pro on your tickers": "在你的標的上試試 Pro",
|
|
1833
|
+
"Try Pro": "試試 Pro",
|
|
1834
|
+
"Stop suggesting Pro functions": "不再推薦 Pro 功能",
|
|
1835
|
+
"Open {command}": "開啟 {command}",
|
|
1836
|
+
"Options flow": "選擇權流向",
|
|
1837
|
+
"X mentions": "X 提及",
|
|
1838
|
+
"Hiring": "招聘",
|
|
1839
|
+
"8-K events": "8-K 事件",
|
|
1840
|
+
"Risk factors": "風險因素",
|
|
1841
|
+
"Cancel Pro": "取消 Pro",
|
|
1842
|
+
"Cancel Pro?": "取消 Pro?",
|
|
1843
|
+
"Keep Pro": "保留 Pro",
|
|
1844
|
+
"Pro until {date}": "Pro 至 {date}",
|
|
1845
|
+
"Cancelling...": "正在取消...",
|
|
1846
|
+
"Cancel Subscription": "取消訂閱",
|
|
1847
|
+
"Keep My Subscription": "保留我的訂閱",
|
|
1848
|
+
"Continue Cancellation": "繼續取消",
|
|
1849
|
+
"Pro stays on until {date}.": "Pro 將保留至 {date}。",
|
|
1850
|
+
"Pro stays on until {date}. Cancelling now stops the renewal after that date.": "Pro 將保留至 {date}。現在取消會在該日期後停止續訂。",
|
|
1851
|
+
"Cancelled. Pro stays on until {date}.": "已取消。Pro 將保留至 {date}。",
|
|
1825
1852
|
};
|
|
@@ -197,8 +197,8 @@ function DiscoverStatus({ controller }: { controller: LayoutGalleryController })
|
|
|
197
197
|
<EmptyState title="Log in to browse community layouts." />
|
|
198
198
|
{/* The sidebar is narrow, so the pair wraps instead of running under the divider. */}
|
|
199
199
|
<Box flexDirection="row" flexWrap="wrap" gap={1} marginTop={1}>
|
|
200
|
-
<Button label={t("
|
|
201
|
-
<Button label={t("
|
|
200
|
+
<Button label={t("Sign up free")} variant="primary" compact onPress={controller.requestSignUp} />
|
|
201
|
+
<Button label={t("Log in")} variant="secondary" compact onPress={controller.requestSignIn} />
|
|
202
202
|
</Box>
|
|
203
203
|
</SidebarState>
|
|
204
204
|
);
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { IssuerListings } from "../types/issuer-listings";
|
|
2
|
+
import { canonicalExchange, parsePublicTickerKey } from "../utils/exchanges";
|
|
3
|
+
import { hongKongListingCode, listingSuffixCandidate } from "../sources/listing-symbols";
|
|
4
|
+
import { pricesTimingNote, type PairPriceInput } from "./depositary-pair";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A company listed twice in China: its A shares in Shanghai or Shenzhen, in
|
|
8
|
+
* yuan, and its H shares in Hong Kong, in Hong Kong dollars (China Shenhua's
|
|
9
|
+
* 601088:SSE and 1088:HKEX, CATL's 300750:SZSE and 3750:HKEX). The two are
|
|
10
|
+
* one class of the company's shares, so the H price against the A price at
|
|
11
|
+
* spot is the A/H premium a Hong Kong desk quotes: on 17 Nov 2026 CATL's H
|
|
12
|
+
* shares closed at HK$366.80 against CN¥238.50 for its A shares, HK$280.80 at
|
|
13
|
+
* 1.1772 Hong Kong dollars a yuan, the H shares about 31% over the A.
|
|
14
|
+
*/
|
|
15
|
+
export interface AhPair {
|
|
16
|
+
/** The H share line, `1088:HKEX`. */
|
|
17
|
+
h: string;
|
|
18
|
+
/** The A share line, `601088:SSE`. */
|
|
19
|
+
a: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const A_SHARE_VENUES = new Set(["SSE", "SZSE"]);
|
|
23
|
+
|
|
24
|
+
/** A listing of the company universe as a key: `1088:HKEX`, `601088:SSE`. */
|
|
25
|
+
function listingKey(line: { symbol: string; exchange: string }): string {
|
|
26
|
+
const { symbol, exchange } = parsePublicTickerKey(line.symbol);
|
|
27
|
+
const venue = canonicalExchange(exchange ?? line.exchange);
|
|
28
|
+
return `${hongKongListingCode(symbol, venue)}:${venue}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The A and H lines of the company Gloom Cloud's company universe holds them
|
|
33
|
+
* for: exactly one line in Hong Kong and one in Shanghai or Shenzhen. Null for
|
|
34
|
+
* any other company, and for one with more lines there than one of each.
|
|
35
|
+
*/
|
|
36
|
+
export function ahPairOf(issuer: Pick<IssuerListings, "listings"> | null | undefined): AhPair | null {
|
|
37
|
+
const lines = issuer?.listings ?? [];
|
|
38
|
+
const h = lines.filter((line) => canonicalExchange(line.exchange) === "HKEX");
|
|
39
|
+
const a = lines.filter((line) => A_SHARE_VENUES.has(canonicalExchange(line.exchange)));
|
|
40
|
+
return h.length === 1 && a.length === 1 ? { h: listingKey(h[0]!), a: listingKey(a[0]!) } : null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A listing as the pair writes its lines: `1088:HKEX` for 1088 on HKEX,
|
|
45
|
+
* `1088.HK` or `1088:HKEX`, the venue read from the key, a vendor's suffix or
|
|
46
|
+
* `exchange`.
|
|
47
|
+
*/
|
|
48
|
+
export function ahListingKey(symbol: string, exchange?: string | null): string {
|
|
49
|
+
const parsed = parsePublicTickerKey(symbol);
|
|
50
|
+
const suffixed = parsed.exchange ? null : listingSuffixCandidate(parsed.symbol);
|
|
51
|
+
return listingKey({ symbol: suffixed?.symbol ?? parsed.symbol, exchange: canonicalExchange(parsed.exchange ?? suffixed?.exchange ?? exchange ?? "") });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Venues whose own lists state a line's board lot, which the company universe serves with its listings. */
|
|
55
|
+
const BOARD_LOT_VENUES: ReadonlySet<string> = new Set(["HKEX", "SGX"]);
|
|
56
|
+
|
|
57
|
+
/** Whether a listing trades on a venue that states its board lot (`BOARD_LOT_VENUES`), so its company's listings are worth reading for it. */
|
|
58
|
+
export function statesBoardLot(symbol: string | null | undefined, exchange?: string | null): boolean {
|
|
59
|
+
return !!symbol && BOARD_LOT_VENUES.has(parsePublicTickerKey(ahListingKey(symbol, exchange)).exchange ?? "");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The shares one lot of a listing trades in, as its company's listings carry
|
|
64
|
+
* it: 500 for Zijin Mining's 2899:HKEX, 400 for HSBC's 0005:HKEX. Null where
|
|
65
|
+
* the listing is not among them or its lot is not a positive whole number.
|
|
66
|
+
*/
|
|
67
|
+
export function listingBoardLot(issuer: Pick<IssuerListings, "listings"> | null | undefined, symbol: string, exchange?: string | null): number | null {
|
|
68
|
+
const key = ahListingKey(symbol, exchange);
|
|
69
|
+
const lot = issuer?.listings.find((line) => listingKey(line) === key)?.boardLot;
|
|
70
|
+
return typeof lot === "number" && Number.isSafeInteger(lot) && lot > 0 ? lot : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Which line of the pair a listing is (`ahListingKey`); null for neither. */
|
|
74
|
+
export function ahPairSide(pair: AhPair, symbol: string, exchange?: string | null): "h" | "a" | null {
|
|
75
|
+
const key = ahListingKey(symbol, exchange);
|
|
76
|
+
return key === pair.h ? "h" : key === pair.a ? "a" : null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Hong Kong dollars a yuan, from each currency's dollar value as exchange rates are served, and when it was read. */
|
|
80
|
+
export interface AhSpot {
|
|
81
|
+
rate: number;
|
|
82
|
+
observedAt: number | null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The rate from each currency's US dollar value (dollars a unit), as exchange
|
|
87
|
+
* rates are served and observed (`asOf`), dated by the older of the two reads.
|
|
88
|
+
* Null without both.
|
|
89
|
+
*/
|
|
90
|
+
export function ahSpotFromUsdValues(
|
|
91
|
+
cny: { rate: number | null | undefined; asOf?: number | null } | null | undefined,
|
|
92
|
+
hkd: { rate: number | null | undefined; asOf?: number | null } | null | undefined,
|
|
93
|
+
): AhSpot | null {
|
|
94
|
+
const yuan = cny?.rate;
|
|
95
|
+
const dollar = hkd?.rate;
|
|
96
|
+
if (yuan == null || dollar == null || !(yuan > 0) || !(dollar > 0) || !Number.isFinite(yuan / dollar)) return null;
|
|
97
|
+
const times = [cny?.asOf, hkd?.asOf].filter((time): time is number => time != null && Number.isFinite(time));
|
|
98
|
+
return { rate: yuan / dollar, observedAt: times.length === 2 ? Math.min(...times) : null };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface AhComparison {
|
|
102
|
+
h: PairPriceInput;
|
|
103
|
+
a: PairPriceInput;
|
|
104
|
+
spot: AhSpot | null;
|
|
105
|
+
/** The A price in Hong Kong dollars at spot. */
|
|
106
|
+
aInHkd: number | null;
|
|
107
|
+
/** The H price over the A price at spot, in percent: H / (A × spot) - 1. */
|
|
108
|
+
premiumPercent: number | null;
|
|
109
|
+
/** Said when the two prices were not set together; null when they were. */
|
|
110
|
+
timingNote: string | null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The comparison, or null without both prices, each in its own currency (HKD and CNY). */
|
|
114
|
+
export function compareAhPair(h: PairPriceInput | null, a: PairPriceInput | null, spot: AhSpot | null, now = Date.now()): AhComparison | null {
|
|
115
|
+
if (!h || !a || h.currency !== "HKD" || a.currency !== "CNY") return null;
|
|
116
|
+
const aInHkd = spot ? a.price * spot.rate : null;
|
|
117
|
+
const premiumPercent = aInHkd != null && aInHkd > 0 ? (h.price / aInHkd - 1) * 100 : null;
|
|
118
|
+
return { h, a, spot, aInHkd, premiumPercent, timingNote: pricesTimingNote(a, h, now) };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** `CNY/HKD`: Hong Kong dollars a yuan, as `fx` names the pair. */
|
|
122
|
+
export const AH_SPOT_LABEL = "CNY/HKD";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { hasUsablePriceHistory } from "../../utils/price-history";
|
|
2
2
|
import { isTransientFailure } from "../../api-client/errors";
|
|
3
|
+
import { isTransientSourceFailure } from "../../sources/provider-errors";
|
|
3
4
|
import type { PricePoint, Quote, TickerFinancials } from "../../types/financials";
|
|
4
5
|
import { hasFreshQuoteForCurrentSession, isQuoteStaleForCurrentSession } from "../quotes/freshness";
|
|
5
6
|
import type { InstrumentRef } from "../request-types";
|
|
@@ -20,7 +21,7 @@ export const FX_CACHE_TTL_MS = 30 * 60_000;
|
|
|
20
21
|
|
|
21
22
|
export function classifyError(error: unknown): { reasonCode: ProviderReasonCode; message: string } {
|
|
22
23
|
const message = error instanceof Error ? error.message : String(error ?? "");
|
|
23
|
-
if (/timeout/i.test(message)) return { reasonCode: "TIMEOUT", message };
|
|
24
|
+
if (/timeout|timed out/i.test(message)) return { reasonCode: "TIMEOUT", message };
|
|
24
25
|
if (/unsupported/i.test(message)) return { reasonCode: "UNSUPPORTED_RANGE", message };
|
|
25
26
|
if (/mapping|symbol/i.test(message)) return { reasonCode: "BAD_MAPPING", message };
|
|
26
27
|
if (/not found|no data|unavailable|delisted/i.test(message)) return { reasonCode: "NOT_FOUND", message };
|
|
@@ -30,11 +31,12 @@ export function classifyError(error: unknown): { reasonCode: ProviderReasonCode;
|
|
|
30
31
|
/**
|
|
31
32
|
* How a load that threw is recorded: `retryable_error` for a failure asking
|
|
32
33
|
* again may get past (no connection, a timeout, 429, a 5xx:
|
|
33
|
-
* `isTransientFailure`),
|
|
34
|
-
* (`
|
|
34
|
+
* `isTransientFailure`), including the router's answer that no source served
|
|
35
|
+
* it because one timed out (`isTransientSourceFailure`), whose kept data is
|
|
36
|
+
* then a saved copy (`savedCopyEntryAt`), and `fatal_error` for any other.
|
|
35
37
|
*/
|
|
36
38
|
export function errorStatus(error: unknown): "retryable_error" | "fatal_error" {
|
|
37
|
-
return isTransientFailure(error) ? "retryable_error" : "fatal_error";
|
|
39
|
+
return isTransientFailure(error) || isTransientSourceFailure(error) ? "retryable_error" : "fatal_error";
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
/**
|
|
@@ -861,7 +861,9 @@ export class MarketDataCoordinator {
|
|
|
861
861
|
delayMinutes: result?.delayMinutes,
|
|
862
862
|
staleAt: result?.staleAt ?? null,
|
|
863
863
|
error: classified ?? (!loading && empty ? { reasonCode: "NO_DATA", message: "No data available" } : null),
|
|
864
|
-
|
|
864
|
+
// A read that failed with nothing to show records the failure too, so its entry says whether asking again may answer.
|
|
865
|
+
attempts: result ? [createAttempt(result.source, result.fetchedAt, error ? errorStatus(error) : empty ? "empty" : "success", classified?.reasonCode, classified?.message)]
|
|
866
|
+
: error ? [createAttempt(this.dataProvider.id, Date.now(), errorStatus(error), classified?.reasonCode, classified?.message)] : [],
|
|
865
867
|
});
|
|
866
868
|
};
|
|
867
869
|
const existing = this.cachedQueries.get(key);
|
|
@@ -1125,8 +1127,17 @@ export function resolveEntryValue<T>(entry: QueryEntry<T>): T | null {
|
|
|
1125
1127
|
*/
|
|
1126
1128
|
export function savedCopyEntryAt<T>(entry: QueryEntry<T> | null | undefined): number | null {
|
|
1127
1129
|
if (!entry?.error || entry.fetchedAt == null || !resolveEntryData(entry)) return null;
|
|
1130
|
+
return entryFailedTransiently(entry) ? entry.fetchedAt : null;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* Whether `entry`'s last load failed for a reason asking again may get past:
|
|
1135
|
+
* no connection, a timeout, 429 or a 5xx (a `retryable_error` attempt), as
|
|
1136
|
+
* opposed to an answer that there is nothing or a refusal.
|
|
1137
|
+
*/
|
|
1138
|
+
export function entryFailedTransiently<T>(entry: QueryEntry<T> | null | undefined): boolean {
|
|
1139
|
+
if (!entry?.error) return false;
|
|
1128
1140
|
const { reasonCode, message } = entry.error;
|
|
1129
|
-
|
|
1141
|
+
return entry.attempts.at(-1)?.status === "retryable_error"
|
|
1130
1142
|
|| reasonCode === "TIMEOUT" || message === DATA_SERVICE_UNREACHABLE_MESSAGE || isNetworkFailure(message);
|
|
1131
|
-
return transient ? entry.fetchedAt : null;
|
|
1132
1143
|
}
|
|
@@ -156,7 +156,11 @@ export function pairTimeText(time: number, now = Date.now()): string {
|
|
|
156
156
|
return `${formatUtcDayTime({ time, dateOnly: false }, now)} UTC`;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Said when two prices compared were not set together (one market closed, or
|
|
161
|
+
* both closed half an hour or more apart); null when they were.
|
|
162
|
+
*/
|
|
163
|
+
export function pricesTimingNote(receipt: PairPriceInput, home: PairPriceInput, now: number): string | null {
|
|
160
164
|
if (receipt.open && home.open) return null;
|
|
161
165
|
if (receipt.observedAt == null || home.observedAt == null) return null;
|
|
162
166
|
const gap = Math.abs(receipt.observedAt - home.observedAt);
|
|
@@ -181,7 +185,7 @@ export function compareDepositaryPair(
|
|
|
181
185
|
const impliedFx = (home.price * ratio) / receipt.price;
|
|
182
186
|
if (!Number.isFinite(impliedFx) || impliedFx <= 0) return null;
|
|
183
187
|
const premiumPercent = spot ? (spot.rate / impliedFx - 1) * 100 : null;
|
|
184
|
-
return { ratio, receipt, home, impliedFx, spot, premiumPercent, timingNote:
|
|
188
|
+
return { ratio, receipt, home, impliedFx, spot, premiumPercent, timingNote: pricesTimingNote(receipt, home, now) };
|
|
185
189
|
}
|
|
186
190
|
|
|
187
191
|
/** `1,651.28`, `28.4942`, `0.890625`: a dollar rate to its useful digits. */
|
|
@@ -28,9 +28,12 @@ export interface FuturesContract {
|
|
|
28
28
|
/** Lists a contract for every calendar month. */
|
|
29
29
|
everyMonth?: true;
|
|
30
30
|
/**
|
|
31
|
-
* What a price counts
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* What a price counts when the server's contract terms are not at hand: a
|
|
32
|
+
* terms read that failed, or a root the server sends none for. Dutch TTF gas
|
|
33
|
+
* quotes in euros per MWh, which a bare "EUR" does not say, live cattle in US
|
|
34
|
+
* cents per pound, where the server's "USX" does not, and copper in USD / lb,
|
|
35
|
+
* not a bare USD. Worded as the server's terms word it (checked 2026-11-17),
|
|
36
|
+
* which win when they come.
|
|
34
37
|
*/
|
|
35
38
|
unit?: string;
|
|
36
39
|
/**
|
|
@@ -110,40 +113,44 @@ export const FUTURES_CONTRACTS: FuturesContract[] = [
|
|
|
110
113
|
{ symbol: "ZB=F", code: "ZB", name: "30-Year T-Bond", sector: "rates", venue: "CBT", bareCode: true },
|
|
111
114
|
{ symbol: "UB=F", code: "UB", name: "Ultra T-Bond", sector: "rates", venue: "CBT", bareCode: true },
|
|
112
115
|
|
|
113
|
-
{ symbol: "CL=F", code: "CL", name: "WTI Crude Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.01, aliases: ["oil"] },
|
|
116
|
+
{ symbol: "CL=F", code: "CL", name: "WTI Crude Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.01, unit: "USD / barrel", aliases: ["oil"] },
|
|
114
117
|
// NYMEX's Brent, cash-settled to the ICE Brent futures settlement; ICE's own contract (B) is not carried.
|
|
115
|
-
{ symbol: "BZ=F", code: "BZ", name: "Brent Crude Oil Last Day Financial", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.01 },
|
|
116
|
-
{ symbol: "NG=F", code: "NG", name: "Natural Gas", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.001, aliases: ["natgas", "nat gas"] },
|
|
118
|
+
{ symbol: "BZ=F", code: "BZ", name: "Brent Crude Oil Last Day Financial", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.01, unit: "USD / barrel" },
|
|
119
|
+
{ symbol: "NG=F", code: "NG", name: "Natural Gas", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.001, unit: "USD / MMBtu", aliases: ["natgas", "nat gas"] },
|
|
117
120
|
// Quoted in euros per MWh.
|
|
118
121
|
{ symbol: "TTF=F", code: "TTF", name: "Dutch TTF Gas", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.001, unit: "EUR / MWh", bareCode: true },
|
|
119
|
-
{ symbol: "RB=F", code: "RB", name: "RBOB Gasoline", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.0001 },
|
|
120
|
-
{ symbol: "HO=F", code: "HO", name: "Heating Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.0001 },
|
|
122
|
+
{ symbol: "RB=F", code: "RB", name: "RBOB Gasoline", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.0001, unit: "USD / gallon" },
|
|
123
|
+
{ symbol: "HO=F", code: "HO", name: "Heating Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.0001, unit: "USD / gallon" },
|
|
121
124
|
// Cash settled on the CL and NG final settlements.
|
|
122
|
-
{ symbol: "QM=F", code: "QM", name: "E-Mini Crude Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.025, bareCode: true },
|
|
123
|
-
{ symbol: "MCL=F", code: "MCL", name: "Micro WTI Crude Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.01 },
|
|
124
|
-
{ symbol: "QG=F", code: "QG", name: "E-Mini Natural Gas", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.005, bareCode: true },
|
|
125
|
-
{ symbol: "MNG=F", code: "MNG", name: "Micro Henry Hub Natural Gas", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.001 },
|
|
126
|
-
{ symbol: "HH=F", code: "HH", name: "Henry Hub Last Day Financial", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.001 },
|
|
127
|
-
|
|
128
|
-
{ symbol: "GC=F", code: "GC", name: "Gold", sector: "metals", venue: "CMX", tick: 0.1 },
|
|
129
|
-
{ symbol: "SI=F", code: "SI", name: "Silver", sector: "metals", venue: "CMX", tick: 0.005 },
|
|
130
|
-
{ symbol: "HG=F", code: "HG", name: "Copper", sector: "metals", venue: "CMX", tick: 0.0005 },
|
|
125
|
+
{ symbol: "QM=F", code: "QM", name: "E-Mini Crude Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.025, unit: "USD / barrel", bareCode: true },
|
|
126
|
+
{ symbol: "MCL=F", code: "MCL", name: "Micro WTI Crude Oil", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.01, unit: "USD / barrel" },
|
|
127
|
+
{ symbol: "QG=F", code: "QG", name: "E-Mini Natural Gas", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.005, unit: "USD / MMBtu", bareCode: true },
|
|
128
|
+
{ symbol: "MNG=F", code: "MNG", name: "Micro Henry Hub Natural Gas", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.001, unit: "USD / MMBtu" },
|
|
129
|
+
{ symbol: "HH=F", code: "HH", name: "Henry Hub Last Day Financial", sector: "energy", venue: "NYM", everyMonth: true, tick: 0.001, unit: "USD / MMBtu" },
|
|
130
|
+
|
|
131
|
+
{ symbol: "GC=F", code: "GC", name: "Gold", sector: "metals", venue: "CMX", tick: 0.1, unit: "USD / troy oz" },
|
|
132
|
+
{ symbol: "SI=F", code: "SI", name: "Silver", sector: "metals", venue: "CMX", tick: 0.005, unit: "USD / troy oz" },
|
|
133
|
+
{ symbol: "HG=F", code: "HG", name: "Copper", sector: "metals", venue: "CMX", tick: 0.0005, unit: "USD / lb" },
|
|
134
|
+
// COMEX's micro metals, each settled daily at its full-size contract's settlement for the month.
|
|
135
|
+
{ symbol: "MGC=F", code: "MGC", name: "Micro Gold", sector: "metals", venue: "CMX", tick: 0.1, unit: "USD / troy oz" },
|
|
136
|
+
{ symbol: "SIL=F", code: "SIL", name: "Micro Silver", sector: "metals", venue: "CMX", tick: 0.005, unit: "USD / troy oz" },
|
|
137
|
+
{ symbol: "MHG=F", code: "MHG", name: "Micro Copper", sector: "metals", venue: "CMX", tick: 0.0005, unit: "USD / lb" },
|
|
131
138
|
{ symbol: "ALI=F", code: "ALI", name: "Aluminum", sector: "metals", venue: "CMX", tick: 0.25, unit: "USD / metric ton" },
|
|
132
|
-
{ symbol: "PL=F", code: "PL", name: "Platinum", sector: "metals", venue: "NYM", tick: 0.1 },
|
|
133
|
-
{ symbol: "PA=F", code: "PA", name: "Palladium", sector: "metals", venue: "NYM", tick: 0.1 },
|
|
139
|
+
{ symbol: "PL=F", code: "PL", name: "Platinum", sector: "metals", venue: "NYM", tick: 0.1, unit: "USD / troy oz" },
|
|
140
|
+
{ symbol: "PA=F", code: "PA", name: "Palladium", sector: "metals", venue: "NYM", tick: 0.1, unit: "USD / troy oz" },
|
|
134
141
|
|
|
135
142
|
// Most grains and softs quote in US cents (cocoa, soybean meal and lumber in
|
|
136
143
|
// dollars); a tick is in the quote's own units.
|
|
137
|
-
{ symbol: "ZC=F", code: "ZC", name: "Corn", sector: "agriculture", venue: "CBT", tick: 0.25 },
|
|
138
|
-
{ symbol: "ZS=F", code: "ZS", name: "Soybeans", sector: "agriculture", venue: "CBT", tick: 0.25 },
|
|
139
|
-
{ symbol: "ZM=F", code: "ZM", name: "Soybean Meal", sector: "agriculture", venue: "CBT", tick: 0.1 },
|
|
140
|
-
{ symbol: "ZL=F", code: "ZL", name: "Soybean Oil", sector: "agriculture", venue: "CBT", tick: 0.01, bareCode: true },
|
|
141
|
-
{ symbol: "ZW=F", code: "ZW", name: "Chicago SRW Wheat", sector: "agriculture", venue: "CBT", tick: 0.25, bareCode: true },
|
|
142
|
-
{ symbol: "KE=F", code: "KE", name: "KC HRW Wheat", sector: "agriculture", venue: "CBT", tick: 0.25 },
|
|
143
|
-
{ symbol: "KC=F", code: "KC", name: "Coffee", sector: "agriculture", venue: "NYB", tick: 0.05 },
|
|
144
|
-
{ symbol: "SB=F", code: "SB", name: "Sugar #11", sector: "agriculture", venue: "NYB", tick: 0.01 },
|
|
145
|
-
{ symbol: "CC=F", code: "CC", name: "Cocoa", sector: "agriculture", venue: "NYB", tick: 1 },
|
|
146
|
-
{ symbol: "CT=F", code: "CT", name: "Cotton #2", sector: "agriculture", venue: "NYB", tick: 0.01, bareCode: true },
|
|
144
|
+
{ symbol: "ZC=F", code: "ZC", name: "Corn", sector: "agriculture", venue: "CBT", tick: 0.25, unit: "US cents / bushel" },
|
|
145
|
+
{ symbol: "ZS=F", code: "ZS", name: "Soybeans", sector: "agriculture", venue: "CBT", tick: 0.25, unit: "US cents / bushel" },
|
|
146
|
+
{ symbol: "ZM=F", code: "ZM", name: "Soybean Meal", sector: "agriculture", venue: "CBT", tick: 0.1, unit: "USD / short ton" },
|
|
147
|
+
{ symbol: "ZL=F", code: "ZL", name: "Soybean Oil", sector: "agriculture", venue: "CBT", tick: 0.01, unit: "US cents / lb", bareCode: true },
|
|
148
|
+
{ symbol: "ZW=F", code: "ZW", name: "Chicago SRW Wheat", sector: "agriculture", venue: "CBT", tick: 0.25, unit: "US cents / bushel", bareCode: true },
|
|
149
|
+
{ symbol: "KE=F", code: "KE", name: "KC HRW Wheat", sector: "agriculture", venue: "CBT", tick: 0.25, unit: "US cents / bushel" },
|
|
150
|
+
{ symbol: "KC=F", code: "KC", name: "Coffee", sector: "agriculture", venue: "NYB", tick: 0.05, unit: "US cents / lb" },
|
|
151
|
+
{ symbol: "SB=F", code: "SB", name: "Sugar #11", sector: "agriculture", venue: "NYB", tick: 0.01, unit: "US cents / lb" },
|
|
152
|
+
{ symbol: "CC=F", code: "CC", name: "Cocoa", sector: "agriculture", venue: "NYB", tick: 1, unit: "USD / metric ton" },
|
|
153
|
+
{ symbol: "CT=F", code: "CT", name: "Cotton #2", sector: "agriculture", venue: "NYB", tick: 0.01, unit: "US cents / lb", bareCode: true },
|
|
147
154
|
{ symbol: "OJ=F", code: "OJ", name: "Orange Juice", sector: "agriculture", venue: "NYB", tick: 0.05, unit: "US cents / lb", bareCode: true },
|
|
148
155
|
{ symbol: "LBR=F", code: "LBR", name: "Lumber", sector: "agriculture", venue: "CME", tick: 0.5, unit: "USD / 1,000 board ft", bareCode: true },
|
|
149
156
|
|
|
@@ -5,6 +5,7 @@ import { classifyInstrumentType } from "../tickers/instrument-kind";
|
|
|
5
5
|
import type { Quote } from "../types/financials";
|
|
6
6
|
import { parsePublicTickerKey } from "../utils/exchanges";
|
|
7
7
|
import { logFailure } from "../utils/log-failure";
|
|
8
|
+
import { createPluginCache, savedCopyForTransientFailure } from "../data/plugin-cache";
|
|
8
9
|
import { futuresBoardContract, futuresContractByCode, type FuturesContract } from "./futures-board";
|
|
9
10
|
import { formatMarketPrice, formatMarketPriceWithCurrency, quoteFormatOptions, withCurrencyMinorDigits } from "./market/format";
|
|
10
11
|
import { previousPublishedSession } from "./market/freshness";
|
|
@@ -463,6 +464,37 @@ export function validateFuturesContractTerms(data: FuturesContractTermsPayload):
|
|
|
463
464
|
return invalid.length ? { ...data, ...Object.fromEntries(invalid.map(([key]) => [key, null])) } : data;
|
|
464
465
|
}
|
|
465
466
|
|
|
467
|
+
/**
|
|
468
|
+
* A futures symbol's terms as last read, kept where the profile keeps saved
|
|
469
|
+
* copies once a command or the app attaches it. Every read asks the service
|
|
470
|
+
* again (a contract rolls, its settlement moves each session); a read the
|
|
471
|
+
* service could not answer is answered from the copy, which a command dates
|
|
472
|
+
* as saved (`servedFromSavedCopy`). Offline, DES GC=F and `quote GC=F` kept
|
|
473
|
+
* the saved price but lost the settle, the Contract block and the unit.
|
|
474
|
+
*/
|
|
475
|
+
const savedTerms = createPluginCache<FuturesContractTermsPayload>({
|
|
476
|
+
kind: "futures-contract-terms",
|
|
477
|
+
source: "gloom-cloud",
|
|
478
|
+
policy: { staleMs: 0, expireMs: 14 * 86_400_000 },
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
/** Where the terms read are saved for a later read the service cannot answer: a command's profile, or the app's. */
|
|
482
|
+
export const attachFuturesTermsPersistence = savedTerms.attach;
|
|
483
|
+
|
|
484
|
+
const savedTermsKey = (symbol: string) => parsePublicTickerKey(symbol).symbol.trim().toUpperCase();
|
|
485
|
+
|
|
486
|
+
/** Keeps terms read on another path (a capture's page asking through its proxy) as `loadFuturesContractTerms` keeps its own. */
|
|
487
|
+
export function rememberFuturesContractTerms(symbol: string, terms: FuturesContractTermsPayload): void {
|
|
488
|
+
void savedTerms.load(savedTermsKey(symbol), async () => validateFuturesContractTerms(terms), { force: true })
|
|
489
|
+
.catch(logFailure("market-data.futures-contract", "Saving futures contract terms failed"));
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/** The terms saved for a symbol, and when (ms), however old; null when none were. */
|
|
493
|
+
export function savedFuturesContractTerms(symbol: string): { terms: FuturesContractTermsPayload; savedAt: number } | null {
|
|
494
|
+
const saved = savedTerms.get(savedTermsKey(symbol), { allowExpired: true });
|
|
495
|
+
return saved ? { terms: saved.data, savedAt: saved.fetchedAt } : null;
|
|
496
|
+
}
|
|
497
|
+
|
|
466
498
|
/** A futures symbol's contract, terms and latest confirmed settlement; throws when the server has none for it. */
|
|
467
499
|
export async function loadFuturesContractTerms(
|
|
468
500
|
symbol: string,
|
|
@@ -471,7 +503,11 @@ export async function loadFuturesContractTerms(
|
|
|
471
503
|
options: { batch?: boolean } = {},
|
|
472
504
|
): Promise<FuturesContractTermsPayload> {
|
|
473
505
|
// The terms are the contract's wherever it is listed: GC=F:CMX asks for GC=F.
|
|
474
|
-
|
|
506
|
+
const read = async () => validateFuturesContractTerms(await client.getCloudFuturesContract(parsePublicTickerKey(symbol).symbol, options));
|
|
507
|
+
// A board's rows, read in batches every minute, and a caller's own client are not kept: one symbol's read is.
|
|
508
|
+
if (options.batch || client !== apiClient) return read();
|
|
509
|
+
// A failure asking again may get past (no connection, a timeout) is answered from the saved copy; a refusal is not.
|
|
510
|
+
return savedCopyForTransientFailure(await savedTerms.load(savedTermsKey(symbol), read, { force: true })).data;
|
|
475
511
|
}
|
|
476
512
|
|
|
477
513
|
/**
|
|
@@ -26,8 +26,8 @@ import {
|
|
|
26
26
|
} from "./selectors";
|
|
27
27
|
import { instrumentIdentityKey } from "../utils/instrument-identity";
|
|
28
28
|
import { createBaselineChartRequest } from "./coordinator/chart";
|
|
29
|
-
import { fateListing, LATE_CHANGE_WAIT_MS, listingFateGate, type ListingFateGate } from "../tickers/listing-fate";
|
|
30
|
-
import type
|
|
29
|
+
import { fateListing, LATE_CHANGE_WAIT_MS, listingChangeLine, listingFateGate, tradingListing, type ListingFateGate } from "../tickers/listing-fate";
|
|
30
|
+
import { describeFormerIssuer, describeTickerChange, type TickerChangeLookup } from "../tickers/ticker-changes";
|
|
31
31
|
import type { TickerChanges } from "../types/ticker-changes";
|
|
32
32
|
|
|
33
33
|
const TICKER_FINANCIALS_LOAD_DELAY_MS = 250;
|
|
@@ -425,6 +425,37 @@ export function useListingFateGate(symbol: string | null | undefined, ticker: Ti
|
|
|
425
425
|
return waiting && expired === instrumentKey ? SERVE_GATE : gate;
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
+
/**
|
|
429
|
+
* What `quote` says beside a symbol whose company left it while something
|
|
430
|
+
* else lists there now ("FB now lists ProShares S&P 500 Dynamic Buffer ETF;
|
|
431
|
+
* FB was Meta Platforms before, now META (changed 2022-06-09)"), or whose
|
|
432
|
+
* company merged into another, for a pane that shows the listing there now.
|
|
433
|
+
* Null for a symbol nothing became of, and until its changes are read.
|
|
434
|
+
*/
|
|
435
|
+
export function useTickerChangeNote(symbol: string | null | undefined, ticker: TickerRecord | null | undefined, quote: Quote | null | undefined): string | null {
|
|
436
|
+
const coordinator = getSharedMarketDataCoordinator();
|
|
437
|
+
const instrument = useTickerInstrument(symbol, ticker);
|
|
438
|
+
const instrumentKey = instrument ? instrumentIdentityKey(instrument) : null;
|
|
439
|
+
const listing = useMemo(() => (instrument ? fateListing(instrument) : null), [instrumentKey]);
|
|
440
|
+
const lookup = useMemo(
|
|
441
|
+
() => (coordinator && instrument && listing ? coordinator.lookupTickerChanges(instrument) : null),
|
|
442
|
+
[coordinator, instrumentKey],
|
|
443
|
+
);
|
|
444
|
+
const [answer, setAnswer] = useState<{ lookup: TickerChangeLookup; changes: TickerChanges | null } | null>(null);
|
|
445
|
+
const changes = !lookup ? null : answer?.lookup === lookup ? answer.changes : lookup.peek();
|
|
446
|
+
useEffect(() => {
|
|
447
|
+
if (!lookup || lookup.peek() !== undefined) return;
|
|
448
|
+
let current = true;
|
|
449
|
+
lookup.settle(LATE_CHANGE_WAIT_MS).then((value) => {
|
|
450
|
+
if (current) setAnswer({ lookup, changes: value });
|
|
451
|
+
}, logFailure("market-data.hooks", "Read a symbol's ticker changes failed"));
|
|
452
|
+
return () => { current = false; };
|
|
453
|
+
}, [lookup]);
|
|
454
|
+
if (!listing || !changes) return null;
|
|
455
|
+
const now = tradingListing(quote);
|
|
456
|
+
return listingChangeLine({ change: describeTickerChange(listing.symbol, changes, now), formerIssuer: describeFormerIssuer(listing.symbol, changes, now) });
|
|
457
|
+
}
|
|
458
|
+
|
|
428
459
|
/**
|
|
429
460
|
* Observe quote entries already populated by the shared stream without issuing
|
|
430
461
|
* one HTTP snapshot request per instrument.
|
|
@@ -380,6 +380,15 @@ function sessionDay(date: string, now: number): string {
|
|
|
380
380
|
return formatUtcDayTime({ time: Date.parse(`${date}T00:00:00Z`), dateOnly: true }, now);
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
+
/**
|
|
384
|
+
* The close a headline price is, by its session's day: "Tue 17 Nov close",
|
|
385
|
+
* worded as the close a move is from ("vs Mon 16 Nov close"), so a report that
|
|
386
|
+
* shows an after-hours print beside it dates the two apart (headlineCloseDate).
|
|
387
|
+
*/
|
|
388
|
+
export function closeDayLabel(date: string, now = Date.now()): string {
|
|
389
|
+
return `${sessionDay(date, now)} close`;
|
|
390
|
+
}
|
|
391
|
+
|
|
383
392
|
/**
|
|
384
393
|
* The words a change line ends with, the same on every surface: "vs Fri 16
|
|
385
394
|
* Oct close", "vs Fri 16 Oct settle", "vs prev close", "since 00:00 UTC",
|
|
@@ -435,7 +444,8 @@ export function combinedChangeBasisLabel(bases: Iterable<QuoteChangeBasis | null
|
|
|
435
444
|
}
|
|
436
445
|
|
|
437
446
|
/** An extended session as a day's move names its print in words, where there is room: "after hours vs Tue 10 Nov close". */
|
|
438
|
-
|
|
447
|
+
/** An extended session in a sentence: "the move after hours vs Tue 10 Nov close", "Last price 158.78 after hours". */
|
|
448
|
+
export const EXTENDED_PRINT_WORDS: Record<ExtendedSession, string> = { PRE: "pre-market", POST: "after hours", OVERNIGHT: "overnight" };
|
|
439
449
|
|
|
440
450
|
/**
|
|
441
451
|
* The basis of a day's move summed over the prices a book is valued at, when
|
|
@@ -152,3 +152,14 @@ export function sanitizeHeaderMarketChoice(value: unknown): HeaderMarketChoice |
|
|
|
152
152
|
const exchange = typeof value.exchange === "string" ? value.exchange.trim() : "";
|
|
153
153
|
return exchange ? { symbol, exchange } : { symbol };
|
|
154
154
|
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The venue of the market the user works in, as the header shows it: a
|
|
158
|
+
* benchmark's (HKEX for the Hang Seng), or a listing's own exchange. Search
|
|
159
|
+
* leads with this venue's line of the company a word names
|
|
160
|
+
* (`withHomeVenueLead`). Null when the header names no venue.
|
|
161
|
+
*/
|
|
162
|
+
export function homeMarketVenue(choice: HeaderMarketChoice | undefined, timeZone: string | null | undefined): string | null {
|
|
163
|
+
const target = resolveHeaderMarket(choice, timeZone);
|
|
164
|
+
return target.venue ?? (target.exchange || null);
|
|
165
|
+
}
|