@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
|
@@ -8,13 +8,17 @@ import { canonicalExchange, displayTickerKey, isUsListingExchange, parsePublicTi
|
|
|
8
8
|
import { listingSuffixCandidate } from "../../../../sources/listing-symbols";
|
|
9
9
|
import { companyLinesName } from "../../../../tickers/company-name";
|
|
10
10
|
import { logFailure } from "../../../../utils/log-failure";
|
|
11
|
-
import { adrPairComparison, adrPairFigures, adrPairInputRows, adrPairLegs, ADR_PAIR_TEMPLATE_ID } from "./model";
|
|
11
|
+
import { adrPairComparison, adrPairFigures, adrPairInputRows, adrPairLegs, ahPairFigures, ahPairInputRows, ADR_PAIR_TEMPLATE_ID } from "./model";
|
|
12
|
+
import { ahPairOf, ahPairSide, compareAhPair, type AhComparison, type AhPair, type AhSpot } from "../../../../market-data/ah-pair";
|
|
13
|
+
import { pairPriceInput } from "../../../../market-data/depositary-pair";
|
|
14
|
+
import { mayBeAhLine } from "./ah";
|
|
12
15
|
|
|
13
16
|
/** Words that ask for this report's figures without being its code: `fn CCL` answers with ADR. */
|
|
14
17
|
export const ADR_PAIR_KEYWORDS = [
|
|
15
18
|
"adr", "adrs", "adr vs home", "adr ratio", "adr premium", "adr discount", "depositary receipt", "depositary receipts",
|
|
16
19
|
"home listing", "home line", "implied fx", "implied exchange rate", "implied dollar", "ccl", "contado con liquidacion",
|
|
17
20
|
"dolar ccl", "mep", "dolar mep", "dolar bolsa", "blue chip swap", "cross listing", "dual listing",
|
|
21
|
+
"a/h premium", "ah premium", "a+h premium",
|
|
18
22
|
];
|
|
19
23
|
|
|
20
24
|
type LoadContext = Parameters<HeadlessPaneDefinition["load"]>[1];
|
|
@@ -73,41 +77,137 @@ function otherLinesNote(other: { issuer: string; lines: string[] } | null, home:
|
|
|
73
77
|
return `${companyLinesName(home?.name, other.issuer)} also lists ${list}.`;
|
|
74
78
|
}
|
|
75
79
|
|
|
80
|
+
/** An A+H pair's comparison, with the quotes it read; null for a listing of no such pair. */
|
|
81
|
+
interface AhRead {
|
|
82
|
+
pair: AhPair;
|
|
83
|
+
quotes: { h: Quote | null; a: Quote | null };
|
|
84
|
+
comparison: AhComparison | null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The A+H pair of the listing `key`, from the company's lines Gloom Cloud
|
|
89
|
+
* holds, both lines read through the quote path and the yuan's Hong Kong
|
|
90
|
+
* dollar rate from both dollar rates (as `fx` dates them). Null for a listing
|
|
91
|
+
* off HKEX, SSE and SZSE, or of a company that is no such pair.
|
|
92
|
+
*/
|
|
93
|
+
async function readAhPair(key: string, ctx: LoadContext, failed: (label: string) => (error: unknown) => null): Promise<AhRead | null> {
|
|
94
|
+
const { getIssuerListings } = ctx.marketData;
|
|
95
|
+
const instrument = await resolveHeadlessInstrument(ctx, key);
|
|
96
|
+
if (!getIssuerListings || !mayBeAhLine(instrument.symbol, instrument.exchange)) return null;
|
|
97
|
+
const issuer = await Promise.resolve().then(() => getIssuerListings.call(ctx.marketData, instrument.symbol, instrument.exchange || undefined))
|
|
98
|
+
.catch(logFailure("plugins.adr-pair", "Reading the company's listings failed", null));
|
|
99
|
+
const pair = ahPairOf(issuer);
|
|
100
|
+
if (!pair || !ahPairSide(pair, instrument.symbol, instrument.exchange)) return null;
|
|
101
|
+
const [h, a, cny, hkd] = await Promise.all([
|
|
102
|
+
readQuote(pair.h, ctx, failed(pair.h)),
|
|
103
|
+
readQuote(pair.a, ctx, failed(pair.a)),
|
|
104
|
+
readSpot("CNY", ctx).catch(failed(dollarPairLabel("CNY"))),
|
|
105
|
+
readSpot("HKD", ctx).catch(failed(dollarPairLabel("HKD"))),
|
|
106
|
+
]);
|
|
107
|
+
// Units a dollar, so Hong Kong dollars a yuan is the one over the other.
|
|
108
|
+
const spot: AhSpot | null = cny && hkd ? {
|
|
109
|
+
rate: hkd.rate / cny.rate,
|
|
110
|
+
observedAt: cny.observedAt != null && hkd.observedAt != null ? Math.min(cny.observedAt, hkd.observedAt) : null,
|
|
111
|
+
} : null;
|
|
112
|
+
return { pair, quotes: { h, a }, comparison: compareAhPair(pairPriceInput(pair.h, h), pairPriceInput(pair.a, a), spot) };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const INPUT_COLUMNS = [
|
|
116
|
+
{ key: "listing", header: "Listing" },
|
|
117
|
+
{ key: "role", header: "Role" },
|
|
118
|
+
{ key: "price", header: "Price", align: "right" as const },
|
|
119
|
+
{ key: "asOf", header: "As of (UTC)" },
|
|
120
|
+
{ key: "session", header: "Session" },
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
/** The A+H pair's figures and inputs as report sections, leaving out an input line `listed` already holds. */
|
|
124
|
+
function ahSections(read: AhRead & { comparison: AhComparison }, listed: readonly string[] = []) {
|
|
125
|
+
const { comparison } = read;
|
|
126
|
+
return [
|
|
127
|
+
{
|
|
128
|
+
title: `${read.pair.h} vs ${read.pair.a}`,
|
|
129
|
+
entries: ahPairFigures(comparison, read.quotes.h).map((figure) => ({
|
|
130
|
+
key: figure.id, label: figure.label,
|
|
131
|
+
value: figure.id === "ah-premium" ? comparison.premiumPercent
|
|
132
|
+
: figure.id === "ah-a-in-hkd" ? comparison.aInHkd
|
|
133
|
+
: comparison.spot?.rate ?? null,
|
|
134
|
+
formatted: figure.detail ? `${figure.value} (${figure.detail})` : figure.value,
|
|
135
|
+
})),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
title: "A+H inputs",
|
|
139
|
+
columns: INPUT_COLUMNS,
|
|
140
|
+
rows: ahPairInputRows(comparison, read.quotes, listed).map(({ opens: _opens, ...row }) => row),
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** What the report's metadata says of an A+H pair. */
|
|
146
|
+
function ahMetadata(read: AhRead & { comparison: AhComparison }) {
|
|
147
|
+
const { comparison } = read;
|
|
148
|
+
return {
|
|
149
|
+
hShare: read.pair.h, aShare: read.pair.a, ahPremiumPercent: comparison.premiumPercent, aInHkd: comparison.aInHkd,
|
|
150
|
+
hPrice: comparison.h.price, hObservedAt: comparison.h.observedAt, aPrice: comparison.a.price, aObservedAt: comparison.a.observedAt,
|
|
151
|
+
cnyHkd: comparison.spot?.rate ?? null, cnyHkdObservedAt: comparison.spot?.observedAt ?? null,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const hasComparison = (read: AhRead | null): read is AhRead & { comparison: AhComparison } => !!read?.comparison;
|
|
156
|
+
|
|
76
157
|
export const adrPairHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
77
158
|
shape: "bundle",
|
|
78
|
-
argument: { kind: "ticker", description: "A depositary receipt (GGAL, TSM)
|
|
159
|
+
argument: { kind: "ticker", description: "A depositary receipt (GGAL, TSM), its home listing (GGAL.BA, 2330.TW), or a line of an A+H company (1088:HKEX, 601088:SSE)" },
|
|
79
160
|
options: [],
|
|
80
161
|
discovery: {
|
|
81
162
|
// CCL is also a ticker (Carnival), so neither word opens ADR: `fn CCL` and `catalog ccl` point to it.
|
|
82
163
|
suggestFor: ["CCL", "MEP"],
|
|
83
164
|
screenshotReadiness: "ready",
|
|
84
165
|
limitations: [
|
|
85
|
-
"Listings Gloom Cloud pairs with a receipt only; the ratio is the depositary's, checked against both lines' prices.",
|
|
166
|
+
"Listings Gloom Cloud pairs with a receipt, or whose company it holds as an A+H pair, only; the ratio is the depositary's, checked against both lines' prices.",
|
|
86
167
|
],
|
|
87
168
|
},
|
|
88
|
-
description: "A depositary receipt beside its home listing: the ratio, both regular-session prices with when each was set, the dollar rate they imply (home × ratio / ADR, the CCL rate for an Argentine pair), spot, and the receipt's premium or discount at spot.",
|
|
169
|
+
description: "A depositary receipt beside its home listing: the ratio, both regular-session prices with when each was set, the dollar rate they imply (home × ratio / ADR, the CCL rate for an Argentine pair), spot, and the receipt's premium or discount at spot. A line of an A+H company adds its other line: the H price over the A price at the yuan's spot rate, each price in its own currency with when it was set.",
|
|
89
170
|
describe: ({ symbols }) => `ADR vs Home | ${symbols[0] ?? ""}`,
|
|
90
171
|
async load({ symbols }, ctx) {
|
|
91
172
|
const key = symbols[0]!;
|
|
92
173
|
const financials = await loadHeadlessFinancials(ctx, key);
|
|
93
174
|
ctx.signal.throwIfAborted();
|
|
94
175
|
const legs = adrPairLegs(financials, null, key);
|
|
176
|
+
const errors: string[] = [];
|
|
177
|
+
const failed = (label: string) => (error: unknown) => {
|
|
178
|
+
errors.push(`${label}: ${error instanceof Error ? error.message : String(error)}`);
|
|
179
|
+
return null;
|
|
180
|
+
};
|
|
95
181
|
if (!legs) {
|
|
182
|
+
// A line of an A+H company with no receipt: its two lines alone.
|
|
183
|
+
const ah = await readAhPair(key, ctx, failed);
|
|
184
|
+
ctx.signal.throwIfAborted();
|
|
185
|
+
if (hasComparison(ah)) {
|
|
186
|
+
return {
|
|
187
|
+
sections: ahSections(ah),
|
|
188
|
+
...(ah.comparison.timingNote ? { notes: [ah.comparison.timingNote] } : {}),
|
|
189
|
+
...(errors.length > 0 ? { errors } : {}),
|
|
190
|
+
freshness: {
|
|
191
|
+
observations: [ah.quotes.h, ah.quotes.a].filter((quote): quote is Quote => !!quote).map((quote) => ({ ...quoteObservation(quote) })),
|
|
192
|
+
},
|
|
193
|
+
metadata: { ...ahMetadata(ah), template: ADR_PAIR_TEMPLATE_ID },
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
if (ah) {
|
|
197
|
+
const missing = !ah.quotes.h ? ah.pair.h : ah.pair.a;
|
|
198
|
+
return { sections: [], empty: `No price for ${missing}, so the pair cannot be compared.`, unavailableSymbols: [missing], errors };
|
|
199
|
+
}
|
|
96
200
|
return {
|
|
97
201
|
sections: [],
|
|
98
|
-
empty: `${key} has no depositary receipt pair on record. ADR takes a receipt (GGAL, TSM)
|
|
202
|
+
empty: `${key} has no depositary receipt or A+H pair on record. ADR takes a receipt (GGAL, TSM), its home listing (GGAL.BA, 2330.TW) or a line of an A+H company (1088:HKEX, 601088:SSE).`,
|
|
99
203
|
unavailableSymbols: [key],
|
|
100
204
|
};
|
|
101
205
|
}
|
|
102
|
-
const
|
|
103
|
-
const failed = (label: string) => (error: unknown) => {
|
|
104
|
-
errors.push(`${label}: ${error instanceof Error ? error.message : String(error)}`);
|
|
105
|
-
return null;
|
|
106
|
-
};
|
|
107
|
-
const [receipt, home, other] = await Promise.all([
|
|
206
|
+
const [receipt, home, other, ah] = await Promise.all([
|
|
108
207
|
readQuote(legs.receiptKey, ctx, failed(legs.receiptKey)),
|
|
109
208
|
readQuote(legs.homeKey, ctx, failed(legs.homeKey)),
|
|
110
209
|
otherLines(legs.receiptKey, legs.homeKey, ctx),
|
|
210
|
+
readAhPair(key, ctx, failed),
|
|
111
211
|
]);
|
|
112
212
|
ctx.signal.throwIfAborted();
|
|
113
213
|
const quotes = { receipt, home };
|
|
@@ -123,6 +223,8 @@ export const adrPairHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
123
223
|
const figures = adrPairFigures(comparison);
|
|
124
224
|
const rows = adrPairInputRows(comparison, quotes);
|
|
125
225
|
const kind = spotRateKind(homeCurrency);
|
|
226
|
+
const pairNotes = [comparison.timingNote, ...hasComparison(ah) ? [ah.comparison.timingNote] : [], otherLinesText]
|
|
227
|
+
.filter((note): note is string => !!note);
|
|
126
228
|
return {
|
|
127
229
|
sections: [
|
|
128
230
|
{
|
|
@@ -138,20 +240,16 @@ export const adrPairHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
138
240
|
},
|
|
139
241
|
{
|
|
140
242
|
title: "Inputs",
|
|
141
|
-
columns:
|
|
142
|
-
{ key: "listing", header: "Listing" },
|
|
143
|
-
{ key: "role", header: "Role" },
|
|
144
|
-
{ key: "price", header: "Price", align: "right" },
|
|
145
|
-
{ key: "asOf", header: "As of (UTC)" },
|
|
146
|
-
{ key: "session", header: "Session" },
|
|
147
|
-
],
|
|
243
|
+
columns: INPUT_COLUMNS,
|
|
148
244
|
rows: rows.map(({ opens: _opens, ...row }) => row),
|
|
149
245
|
},
|
|
246
|
+
...hasComparison(ah) ? ahSections(ah, rows.map((row) => row.listing)) : [],
|
|
150
247
|
],
|
|
151
|
-
...(
|
|
248
|
+
...(pairNotes.length > 0 ? { notes: pairNotes } : {}),
|
|
152
249
|
...(errors.length > 0 ? { errors } : {}),
|
|
153
250
|
freshness: {
|
|
154
|
-
observations: [quotes.receipt, quotes.home
|
|
251
|
+
observations: [quotes.receipt, quotes.home, ...hasComparison(ah) ? [ah.quotes.a] : []]
|
|
252
|
+
.filter((quote): quote is Quote => !!quote).map((quote) => ({ ...quoteObservation(quote) })),
|
|
155
253
|
},
|
|
156
254
|
metadata: {
|
|
157
255
|
receipt: legs.receiptKey, home: legs.homeKey, ratio: comparison.ratio, currency: homeCurrency,
|
|
@@ -160,6 +258,7 @@ export const adrPairHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
160
258
|
receiptPrice: comparison.receipt.price, receiptObservedAt: comparison.receipt.observedAt,
|
|
161
259
|
homePrice: comparison.home.price, homeObservedAt: comparison.home.observedAt,
|
|
162
260
|
spotObservedAt: comparison.spot?.observedAt ?? null, template: ADR_PAIR_TEMPLATE_ID,
|
|
261
|
+
...hasComparison(ah) ? ahMetadata(ah) : {},
|
|
163
262
|
},
|
|
164
263
|
};
|
|
165
264
|
},
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
compareDepositaryPair, dollarPairLabel, formatPairRate, isReceiptSide, listingDepositaryPair, pairPriceInput, pairTimeText,
|
|
11
11
|
premiumText, ratioCount, spotRateKind, type DepositaryPairComparison, type PairPriceInput, type PairSpotInput,
|
|
12
12
|
} from "../../../../market-data/depositary-pair";
|
|
13
|
+
import { AH_SPOT_LABEL, ahListingKey, type AhComparison } from "../../../../market-data/ah-pair";
|
|
13
14
|
|
|
14
15
|
/** The DES tab a listing with a known receipt pair gets, and the function that opens DES on it. */
|
|
15
16
|
export const ADR_PAIR_TAB_ID = "adr-vs-home";
|
|
@@ -112,7 +113,7 @@ export function adrPairFigures(comparison: DepositaryPairComparison): AdrPairFig
|
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
export interface AdrPairInputRow {
|
|
115
|
-
id: "home" | "receipt" | "spot";
|
|
116
|
+
id: "home" | "receipt" | "spot" | "h-share" | "a-share" | "ah-spot";
|
|
116
117
|
listing: string;
|
|
117
118
|
role: string;
|
|
118
119
|
price: string;
|
|
@@ -167,3 +168,52 @@ export function adrPairInputRows(
|
|
|
167
168
|
}] : [],
|
|
168
169
|
];
|
|
169
170
|
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* The figures an A+H company's two lines add: the H price over the A price at
|
|
174
|
+
* spot, the A price in Hong Kong dollars (to the decimals of `hQuote`, the H
|
|
175
|
+
* line's), and the spot rate it is read at.
|
|
176
|
+
*/
|
|
177
|
+
export function ahPairFigures(comparison: AhComparison, hQuote?: Quote | null): AdrPairFigure[] {
|
|
178
|
+
const { premiumPercent, aInHkd, spot } = comparison;
|
|
179
|
+
return [
|
|
180
|
+
{
|
|
181
|
+
id: "ah-premium", label: "H vs A",
|
|
182
|
+
value: premiumPercent == null ? MISSING_VALUE : premiumText(premiumPercent),
|
|
183
|
+
...(premiumPercent == null ? {} : { detail: "at spot" }),
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
id: "ah-a-in-hkd", label: "A in HKD",
|
|
187
|
+
// To the H price's own decimals, which it is read beside.
|
|
188
|
+
value: aInHkd == null ? MISSING_VALUE
|
|
189
|
+
: formatMarketPriceWithCurrency(aInHkd, "HKD", { ...legPriceOptions(comparison.h, hQuote), currencyCode: true }),
|
|
190
|
+
...(aInHkd == null ? {} : { detail: "A × spot" }),
|
|
191
|
+
},
|
|
192
|
+
{ id: "ah-spot", label: `Spot ${AH_SPOT_LABEL}`, value: spot ? formatPairRate(spot.rate) : MISSING_VALUE },
|
|
193
|
+
];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The A+H prices, each in its own currency and dated, and the spot rate,
|
|
198
|
+
* leaving out a line `listed` already holds (the H line that is a receipt's
|
|
199
|
+
* home line).
|
|
200
|
+
*/
|
|
201
|
+
export function ahPairInputRows(
|
|
202
|
+
comparison: AhComparison,
|
|
203
|
+
quotes: { h: Quote | null | undefined; a: Quote | null | undefined },
|
|
204
|
+
listed: readonly string[] = [],
|
|
205
|
+
now = Date.now(),
|
|
206
|
+
): AdrPairInputRow[] {
|
|
207
|
+
const { h, a, spot } = comparison;
|
|
208
|
+
const time = (value: number | null) => value == null ? MISSING_VALUE : pairTimeText(value, now).replace(/ UTC$/, "");
|
|
209
|
+
const leg = (id: "h-share" | "a-share", role: string, input: PairPriceInput, quote: Quote | null | undefined): AdrPairInputRow => ({
|
|
210
|
+
id, listing: input.symbol, role,
|
|
211
|
+
price: formatMarketPriceWithCurrency(input.price, input.currency, { ...legPriceOptions(input, quote), currencyCode: true }),
|
|
212
|
+
asOf: time(input.observedAt), session: sessionText(input), opens: input.symbol,
|
|
213
|
+
});
|
|
214
|
+
return [
|
|
215
|
+
...listed.some((key) => ahListingKey(key) === h.symbol) ? [] : [leg("h-share", "H share", h, quotes.h)],
|
|
216
|
+
leg("a-share", "A share", a, quotes.a),
|
|
217
|
+
...spot ? [{ id: "ah-spot" as const, listing: AH_SPOT_LABEL, role: "Spot", price: formatPairRate(spot.rate), asOf: time(spot.observedAt), session: "", opens: null }] : [],
|
|
218
|
+
];
|
|
219
|
+
}
|
|
@@ -10,7 +10,8 @@ import { heldCurrencyUnit } from "../../../../utils/currency-units";
|
|
|
10
10
|
import type { TickerResearchTabProps } from "../../../../types/plugin";
|
|
11
11
|
import { Box } from "../../../../ui";
|
|
12
12
|
import { useOpenDescription } from "../../shared/open-description";
|
|
13
|
-
import { adrPairComparison, adrPairFigures, adrPairInputRows, adrPairLegs, adrPairQuotes, type AdrPairInputRow } from "./model";
|
|
13
|
+
import { adrPairComparison, adrPairFigures, adrPairInputRows, adrPairLegs, adrPairQuotes, ahPairFigures, ahPairInputRows, type AdrPairInputRow } from "./model";
|
|
14
|
+
import { useAhPair } from "./ah";
|
|
14
15
|
|
|
15
16
|
// The price and its time first: a narrow pane keeps them and drops the role.
|
|
16
17
|
const COLUMNS: DataTableColumn[] = [
|
|
@@ -29,13 +30,16 @@ function renderCell(row: AdrPairInputRow, column: DataTableColumn): DataTableCel
|
|
|
29
30
|
* DES "ADR vs home": a receipt beside its home line, for a listing Gloom
|
|
30
31
|
* Cloud pairs with one. The ratio, both prices, the dollar rate they imply
|
|
31
32
|
* (home × ratio / ADR), spot, and the receipt's premium or discount at spot,
|
|
32
|
-
* each price dated, and a note when the two were not set together.
|
|
33
|
+
* each price dated, and a note when the two were not set together. A line of
|
|
34
|
+
* an A+H company adds its other line: the H price over the A price at spot,
|
|
35
|
+
* the A price in Hong Kong dollars and the yuan's rate, each price in its own
|
|
36
|
+
* currency and dated (`useAhPair`).
|
|
33
37
|
*/
|
|
34
38
|
export function AdrPairResearchTab({ width, height, focused }: TickerResearchTabProps) {
|
|
35
39
|
const { symbol, ticker, financials } = usePaneTicker();
|
|
36
40
|
const legs = adrPairLegs(financials, ticker, symbol);
|
|
37
41
|
// Both legs through the quote path, so each is read alike whichever side the pane is on.
|
|
38
|
-
const ownEntry = useQuoteEntry(
|
|
42
|
+
const ownEntry = useQuoteEntry(ticker?.metadata.ticker ?? symbol, ticker);
|
|
39
43
|
const otherEntry = useQuoteEntry(legs?.otherKey ?? null, null);
|
|
40
44
|
const quotes = legs
|
|
41
45
|
? adrPairQuotes(legs, { own: resolveEntryData(ownEntry), other: resolveEntryData(otherEntry) }, financials?.quote)
|
|
@@ -48,28 +52,35 @@ export function AdrPairResearchTab({ width, height, focused }: TickerResearchTab
|
|
|
48
52
|
const observed = useFxRateObservations([homeCurrency]).get(homeCurrency);
|
|
49
53
|
const spot = spotFromUsdValue(observed?.rate, observed?.asOf);
|
|
50
54
|
const comparison = legs ? adrPairComparison(legs, { receipt: receiptQuote, home: homeQuote }, spot) : null;
|
|
55
|
+
const ah = useAhPair(ticker?.metadata.ticker ?? symbol, ticker?.metadata.exchange || financials?.quote?.listingExchangeName,
|
|
56
|
+
resolveEntryData(ownEntry) ?? financials?.quote);
|
|
57
|
+
const ahComparison = ah?.comparison ?? null;
|
|
51
58
|
const openDescription = useOpenDescription();
|
|
52
59
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
53
60
|
|
|
54
|
-
const
|
|
55
|
-
const
|
|
61
|
+
const adrRows = comparison ? adrPairInputRows(comparison, { receipt: receiptQuote, home: homeQuote }) : [];
|
|
62
|
+
const stats: StatItem[] = [...comparison ? adrPairFigures(comparison) : [], ...ahComparison && ah ? ahPairFigures(ahComparison, ah.quotes.h) : []];
|
|
63
|
+
const rows = [...adrRows, ...ahComparison && ah ? ahPairInputRows(ahComparison, ah.quotes, adrRows.map((row) => row.listing)) : []];
|
|
56
64
|
|
|
57
|
-
if (!legs) return <EmptyState title="No ADR pair for this listing." />;
|
|
65
|
+
if (!legs && !ah) return <EmptyState title="No ADR pair for this listing." />;
|
|
58
66
|
const pending = (entry: typeof receiptEntry) => !entry || entry.phase === "loading" || entry.phase === "idle";
|
|
59
67
|
// A leg with a quote is not waiting on its read.
|
|
60
|
-
const loading =
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
const loading = legs
|
|
69
|
+
? !comparison && ((!receiptQuote && pending(receiptEntry)) || (!homeQuote && pending(homeEntry)))
|
|
70
|
+
: !ahComparison && !!ah?.loading;
|
|
71
|
+
const error = rows.length === 0 && !loading
|
|
72
|
+
? `Prices unavailable for ${legs ? !receiptQuote ? legs.receiptKey : legs.homeKey : ah!.side === "h" ? ah!.pair.a : ah!.pair.h}.`
|
|
63
73
|
: null;
|
|
64
|
-
|
|
65
|
-
|
|
74
|
+
const notes = [comparison?.timingNote, ahComparison?.timingNote].filter((note): note is string => !!note);
|
|
75
|
+
// Each note wraps to the pane's width, less its inset.
|
|
76
|
+
const noteRows = notes.reduce((total, note) => total + Math.ceil(note.length / Math.max(1, width - 2)), 0);
|
|
66
77
|
const tableHeight = Math.max(3, height - statGridRows(stats, width) - noteRows);
|
|
67
78
|
|
|
68
79
|
return <Box width={width} height={height} flexDirection="column" overflow="hidden">
|
|
69
|
-
<PaneStatusBody subject="ADR pair" loading={loading} error={error} width={width} height={height}>
|
|
70
|
-
{
|
|
80
|
+
<PaneStatusBody subject={legs ? "ADR pair" : "A+H pair"} loading={loading} error={error} width={width} height={height}>
|
|
81
|
+
{rows.length > 0 ? <>
|
|
71
82
|
<StatGrid items={stats} width={width} />
|
|
72
|
-
{
|
|
83
|
+
{notes.map((note) => <Box key={note} paddingX={1} flexShrink={0}><Notice>{note}</Notice></Box>)}
|
|
73
84
|
<DataTableView<AdrPairInputRow>
|
|
74
85
|
focused={focused}
|
|
75
86
|
columns={COLUMNS}
|
|
@@ -131,8 +131,8 @@ const FINANCIAL_LABEL_MIN_W = 12;
|
|
|
131
131
|
* once showed nothing but metric names and "more →". The other 6 cells are the
|
|
132
132
|
* pane's padding, the table's, the column gap and the scrollbar.
|
|
133
133
|
*/
|
|
134
|
-
export function financialLabelWidth(width: number): number {
|
|
135
|
-
return Math.max(FINANCIAL_LABEL_MIN_W, Math.min(FINANCIAL_LABEL_W, width -
|
|
134
|
+
export function financialLabelWidth(width: number, periodWidth = FINANCIAL_COL_W): number {
|
|
135
|
+
return Math.max(FINANCIAL_LABEL_MIN_W, Math.min(FINANCIAL_LABEL_W, width - periodWidth - 6));
|
|
136
136
|
}
|
|
137
137
|
/** The growth after a period's value: a blank and up to six characters (`+466%`, `<-99T%`). */
|
|
138
138
|
const FINANCIAL_GROWTH_W = 7;
|
|
@@ -298,19 +298,6 @@ export function formatFinancialAmount(value: number, divisor: number): string {
|
|
|
298
298
|
return Number(scaled.toPrecision(2)).toString();
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
/**
|
|
302
|
-
* A statement column's header for reports. The compact form is the period as
|
|
303
|
-
* the pane prints it without a fiscal calendar: `TTM`, or the period end date
|
|
304
|
-
* the query bar shows as of. Table columns use `financialColumnLabel`.
|
|
305
|
-
*/
|
|
306
|
-
export function formatFinancialHeader(date: string, currency?: string, dateSource?: FinancialStatement["dateSource"], compact = false, periodEnd?: string): string {
|
|
307
|
-
if (compact) return date === "TTM" ? "TTM" : date.slice(0, 10);
|
|
308
|
-
const period = date === "TTM" ? (periodEnd ? `TTM ${periodEnd}` : "TTM") : date.slice(0, 10);
|
|
309
|
-
const label = currency ? `${period} ${currency}` : period;
|
|
310
|
-
if (date === "TTM") return label;
|
|
311
|
-
return `${label} ${dateSource === "sec" ? "(SEC date)" : "(provider date)"}`;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
301
|
/**
|
|
315
302
|
* A report column's header (`gloom fn FA`): the fiscal period as the pane's
|
|
316
303
|
* column names it and the day it ends (`FY2026 2026-09-30 USD bn (SEC
|
|
@@ -329,26 +316,17 @@ export function financialReportHeader(
|
|
|
329
316
|
yearEndMonth: number | null,
|
|
330
317
|
rows: readonly FinancialStatement[] = [],
|
|
331
318
|
): string {
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (date === "TTM") {
|
|
336
|
-
const end = statement.aggregation?.periodEnd;
|
|
337
|
-
const period = end ? named(financialColumnLabel(statement, kind, yearEndMonth), end) : "TTM";
|
|
338
|
-
return currency ? `${period} ${currency}` : period;
|
|
339
|
-
}
|
|
340
|
-
const end = date.slice(0, 10);
|
|
341
|
-
const months = kind === "quarterly" ? statementPeriodMonths(statement) : undefined;
|
|
342
|
-
const longer = months && months > 3 ? longerPeriodLabel(end, months, yearEndMonth) : null;
|
|
343
|
-
const period = named(longer ?? financialColumnLabel(statement, kind, yearEndMonth), end);
|
|
319
|
+
const period = financialFiscalHeader(statement, kind, yearEndMonth);
|
|
320
|
+
const header = currency ? `${period} ${currency}` : period;
|
|
321
|
+
if (statement.date === "TTM") return header;
|
|
344
322
|
const filled = statement.filledFrom?.source === "results" ? fillDate(statement, rows) : null;
|
|
345
|
-
const source = filled ? fillDateText(filled) : dateSource === "sec" ? "SEC date" : "provider date";
|
|
346
|
-
return `${
|
|
323
|
+
const source = filled ? fillDateText(filled) : statement.dateSource === "sec" ? "SEC date" : "provider date";
|
|
324
|
+
return `${header} (${source})`;
|
|
347
325
|
}
|
|
348
326
|
|
|
349
327
|
/**
|
|
350
|
-
*
|
|
351
|
-
*
|
|
328
|
+
* The fiscal period, with a half in the quarterly list named as a half
|
|
329
|
+
* (`H1 FY26`), and `TTM` with the quarter or half it runs to.
|
|
352
330
|
*/
|
|
353
331
|
export function financialColumnLabel(
|
|
354
332
|
statement: FinancialTableStatement,
|
|
@@ -360,7 +338,19 @@ export function financialColumnLabel(
|
|
|
360
338
|
return ttmPeriodLabel(periodEnd, yearEndMonth, interimMonths);
|
|
361
339
|
}
|
|
362
340
|
|
|
363
|
-
|
|
341
|
+
export function financialFiscalHeader(statement: FinancialTableStatement, kind: FinancialPeriod, yearEndMonth: number | null): string {
|
|
342
|
+
const end = statement.date === "TTM" ? statement.aggregation?.periodEnd : statement.date.slice(0, 10);
|
|
343
|
+
const months = kind === "quarterly" && statement.date !== "TTM" ? statementPeriodMonths(statement) : undefined;
|
|
344
|
+
const longer = end && months && months > 3 ? longerPeriodLabel(end, months, yearEndMonth) : null;
|
|
345
|
+
const name = longer ?? financialColumnLabel(statement, kind, yearEndMonth);
|
|
346
|
+
return end && !name.endsWith(end) ? `${name} ${end}` : name;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** An annual balance sheet can lead with a newer interim position. */
|
|
350
|
+
export function financialColumnPeriod(statement: FinancialTableStatement, period: FinancialPeriod, annualDates: ReadonlySet<string>): FinancialPeriod {
|
|
351
|
+
return period === "annual" && (statement.date === "TTM" || annualDates.has(statement.date)) ? "annual" : "quarterly";
|
|
352
|
+
}
|
|
353
|
+
|
|
364
354
|
export function latestFinancialPeriodEnd(statements: readonly FinancialTableStatement[]): string | undefined {
|
|
365
355
|
return statements
|
|
366
356
|
.map((statement) => statement.date === "TTM" ? statement.aggregation?.periodEnd : statement.date.slice(0, 10))
|
|
@@ -28,7 +28,8 @@ import {
|
|
|
28
28
|
collectDefaultCollapsedGroupIds,
|
|
29
29
|
collectGroupIds,
|
|
30
30
|
financialCellParts,
|
|
31
|
-
|
|
31
|
+
financialColumnPeriod,
|
|
32
|
+
financialFiscalHeader,
|
|
32
33
|
formatFinancialCell,
|
|
33
34
|
formatFinancialCellValue,
|
|
34
35
|
financialStatementCurrency,
|
|
@@ -111,7 +112,7 @@ function financialColumnHeader(
|
|
|
111
112
|
yearEndMonth: number | null,
|
|
112
113
|
sharedCurrency: string | undefined,
|
|
113
114
|
): string {
|
|
114
|
-
const header =
|
|
115
|
+
const header = financialFiscalHeader(statement, kind, yearEndMonth);
|
|
115
116
|
return !sharedCurrency && statement.currency ? `${header} ${statement.currency}` : header;
|
|
116
117
|
}
|
|
117
118
|
|
|
@@ -350,15 +351,15 @@ export function ResolvedFinancialsTab({
|
|
|
350
351
|
// The annual balance sheet leads with a newer quarter-end position.
|
|
351
352
|
const periodHeaders = useMemo(() => displayStatements.map((statement) => financialColumnHeader(
|
|
352
353
|
statement,
|
|
353
|
-
|
|
354
|
+
financialColumnPeriod(statement, resolvedPeriod, annualDates),
|
|
354
355
|
yearEndMonth,
|
|
355
356
|
comparisonCurrency,
|
|
356
|
-
)), [annualDates, comparisonCurrency, displayStatements,
|
|
357
|
+
)), [annualDates, comparisonCurrency, displayStatements, resolvedPeriod, yearEndMonth]);
|
|
357
358
|
// In the terminal a period is as wide as its widest value and growth, so each pair sits as far from the next
|
|
358
359
|
// as from its own growth and more periods fit. The ratio tabs keep the statement columns' width. Every line of
|
|
359
360
|
// the statement counts, a collapsed group's too, so opening or closing one leaves the periods where they are.
|
|
360
361
|
const periodWidth = useMemo(() => {
|
|
361
|
-
if (nativePaneChrome || ratioTab) return FINANCIAL_COL_W;
|
|
362
|
+
if (nativePaneChrome || ratioTab) return Math.max(FINANCIAL_COL_W, financialPeriodWidth([], periodHeaders));
|
|
362
363
|
const everyRow = shareFinancialUnit(buildFinancialRows(subTab.rows, displayStatements, NO_COLLAPSED_GROUPS)).rows;
|
|
363
364
|
const values = [...everyRow, ...rows].flatMap((row) => displayStatements.map((statement) => (
|
|
364
365
|
formatFinancialCellValue(row, statement)
|
|
@@ -370,7 +371,7 @@ export function ResolvedFinancialsTab({
|
|
|
370
371
|
id: "metric",
|
|
371
372
|
kind: "metric",
|
|
372
373
|
label: metricHeader,
|
|
373
|
-
width: financialLabelWidth(width),
|
|
374
|
+
width: financialLabelWidth(width, periodWidth),
|
|
374
375
|
align: "left",
|
|
375
376
|
},
|
|
376
377
|
...displayStatements.map((statement, index): FinancialTableColumn => ({
|
|
@@ -525,8 +526,6 @@ export function ResolvedFinancialsTab({
|
|
|
525
526
|
);
|
|
526
527
|
}
|
|
527
528
|
|
|
528
|
-
const asOf = periodEnd ? `as of ${periodEnd}` : undefined;
|
|
529
|
-
// The as-of is the bar's own segment, which keeps its place when the pane is narrow; the context after it gives way.
|
|
530
529
|
const queryBar = (meta: string) => (
|
|
531
530
|
<QueryBar
|
|
532
531
|
width={Math.max(1, width - 2)}
|
|
@@ -553,7 +552,6 @@ export function ResolvedFinancialsTab({
|
|
|
553
552
|
],
|
|
554
553
|
onChange: (value: string) => setPeriod(value as FinancialPeriod),
|
|
555
554
|
}}
|
|
556
|
-
asOf={asOf}
|
|
557
555
|
meta={meta || undefined}
|
|
558
556
|
/>
|
|
559
557
|
);
|
|
@@ -6,6 +6,7 @@ import { RETURN_INTERVAL_VALUES, RETURN_RANGES } from "./data-panes/returns-mode
|
|
|
6
6
|
import { PRICE_WINDOW_FROM_HELP, PRICE_WINDOW_TO_HELP } from "../../../utils/price-window";
|
|
7
7
|
import type { HeadlessPaneOptionDef } from "../../../types/headless";
|
|
8
8
|
import { QUOTE_MONITOR_MAX_TICKERS } from "../../../tickers/list";
|
|
9
|
+
import { STATEMENT_CURRENCY_OPTION } from "../shared/statement-currency";
|
|
9
10
|
|
|
10
11
|
/** The most tickers one FA report reads: each is a full statements load. */
|
|
11
12
|
const FINANCIAL_REPORT_MAX_TICKERS = 10;
|
|
@@ -30,6 +31,7 @@ export const paneSchemas = {
|
|
|
30
31
|
},
|
|
31
32
|
options: [
|
|
32
33
|
FINANCIAL_PERIOD_OPTION,
|
|
34
|
+
{ ...STATEMENT_CURRENCY_OPTION, shot: { reportOnly: "compares converted statement rows; GF charts converted figures" } },
|
|
33
35
|
{
|
|
34
36
|
key: "statement",
|
|
35
37
|
description: "Statement or ratio tab to display.",
|
|
@@ -30,6 +30,7 @@ import { latestBalanceSheetDate, loadOfferingNote } from "./financials/offerings
|
|
|
30
30
|
import { formatRunwayMonths, reportsShortTermTotal, runwayMethod } from "../../../utils/cash-runway";
|
|
31
31
|
import { formatPerShareNumber } from "../../../utils/reported-money";
|
|
32
32
|
import { logFailure } from "../../../utils/log-failure";
|
|
33
|
+
import { loadStatementCurrency } from "../shared/statement-currency";
|
|
33
34
|
import {
|
|
34
35
|
RATIO_GAP_TEXT,
|
|
35
36
|
findRatioTab,
|
|
@@ -126,10 +127,10 @@ export const financialStatementsHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
|
126
127
|
* `--layout long` asks for it. Several tickers have no shared columns, so they are never laid out wide.
|
|
127
128
|
*/
|
|
128
129
|
function financialReportLayout(symbols: readonly string[], options: HeadlessPaneOptionValues): "wide" | "long" {
|
|
129
|
-
if (options.layout === "wide" && symbols.length > 1) {
|
|
130
|
-
throw new Error(
|
|
130
|
+
if (options.layout === "wide" && (symbols.length > 1 || options.currency)) {
|
|
131
|
+
throw new Error("--layout wide shows one ticker in its reporting currency. Leave --layout out for converted figures or multiple tickers.");
|
|
131
132
|
}
|
|
132
|
-
return options.layout === "long" || symbols.length > 1 ? "long" : "wide";
|
|
133
|
+
return options.layout === "long" || symbols.length > 1 || options.currency ? "long" : "wide";
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
/** How a figure of an FA row reads: the kind of number it is, which names its unit and draws it. */
|
|
@@ -243,6 +244,8 @@ async function loadLongFinancialReport(symbols: string[], options: HeadlessPaneO
|
|
|
243
244
|
symbol, data, rows: data.rows as unknown as WideRow[], columns: (data.metadata?.columns ?? []) as WideColumn[],
|
|
244
245
|
}));
|
|
245
246
|
const divisor = mostCommon(tables.flatMap(({ rows }) => rows.filter((row) => row.figure === "money").map((row) => row.divisor))) ?? 1;
|
|
247
|
+
const target = typeof options.currency === "string" ? options.currency : null;
|
|
248
|
+
const fx = target ? await loadStatementCurrency(target, tables.flatMap(({ columns }) => columns.flatMap(({ currency }) => currency ? [currency] : [])), ctx) : null;
|
|
246
249
|
const rows = tables.flatMap(({ symbol, rows: wide, columns }) => {
|
|
247
250
|
const said = new Set<string>();
|
|
248
251
|
return wide.flatMap((row) => {
|
|
@@ -253,13 +256,19 @@ async function loadLongFinancialReport(symbols: string[], options: HeadlessPaneO
|
|
|
253
256
|
const rowDivisor = row.figure === "money" ? divisor : row.divisor;
|
|
254
257
|
return columns.map((column, index) => {
|
|
255
258
|
const cell = row.cells[index];
|
|
256
|
-
const
|
|
259
|
+
const native = typeof cell?.value === "number" && Number.isFinite(cell.value) ? cell.value : null;
|
|
260
|
+
const monetary = row.figure === "money" || row.figure === "perShare";
|
|
261
|
+
const rate = fx && monetary ? fx.rates.get(column.currency ?? "") : 1;
|
|
262
|
+
const value = native != null && rate != null ? native * rate : null;
|
|
263
|
+
const nativeUnit = figureUnit(row.figure, column.currency, rowDivisor);
|
|
257
264
|
return {
|
|
258
265
|
ticker: symbol, period: column.period, periodEnd: column.periodEnd, metric,
|
|
259
266
|
value: value == null ? null : longFigureValue(row.figure, value, rowDivisor),
|
|
260
|
-
unit: figureUnit(row.figure, column.currency, rowDivisor),
|
|
267
|
+
unit: figureUnit(row.figure, monetary && target ? target : column.currency, rowDivisor),
|
|
261
268
|
formatted: value == null ? null : drawLongFigure(row.figure, value, rowDivisor),
|
|
262
|
-
gap: value == null ? cell?.gap ?? (cell?.formatted && cell.formatted !== MISSING_VALUE ? cell.formatted : null) : null,
|
|
269
|
+
gap: native != null && rate == null ? "No FX rate" : value == null ? cell?.gap ?? (cell?.formatted && cell.formatted !== MISSING_VALUE ? cell.formatted : null) : null,
|
|
270
|
+
...(fx && monetary && native != null ? { nativeValue: longFigureValue(row.figure, native, rowDivisor), nativeUnit,
|
|
271
|
+
nativeFormatted: `${drawLongFigure(row.figure, native, rowDivisor)} ${nativeUnit}` } : {}),
|
|
263
272
|
};
|
|
264
273
|
});
|
|
265
274
|
});
|
|
@@ -273,18 +282,21 @@ async function loadLongFinancialReport(symbols: string[], options: HeadlessPaneO
|
|
|
273
282
|
const ownNotes = tables.flatMap(({ symbol, data }) => (data.notes ?? []).filter((note) => !shared(note)).map((note) => `${symbol}: ${note}`));
|
|
274
283
|
const empty = tables.filter(({ rows: wide }) => wide.length === 0);
|
|
275
284
|
const first = tables[0]?.data.metadata ?? {};
|
|
285
|
+
const nativeColumn: HeadlessPaneColumn = { key: "nativeValue", header: "Native", align: "right", unitKey: "nativeUnit",
|
|
286
|
+
format: (_value, row) => String(row.nativeFormatted ?? "") };
|
|
276
287
|
return {
|
|
277
288
|
rows,
|
|
278
|
-
columns: LONG_FINANCIAL_COLUMNS,
|
|
279
|
-
textColumns: [...LONG_FINANCIAL_COLUMNS, { key: "unit", header: "Unit" }],
|
|
289
|
+
columns: fx ? [...LONG_FINANCIAL_COLUMNS, nativeColumn] : LONG_FINANCIAL_COLUMNS,
|
|
290
|
+
textColumns: [...LONG_FINANCIAL_COLUMNS, { key: "unit", header: "Unit" }, ...(fx ? [nativeColumn] : [])],
|
|
280
291
|
rowUnitKey: "unit", rowSymbolKey: "ticker", rowAsOfKey: "periodEnd",
|
|
281
292
|
interval: options.period === "quarterly" ? "quarterly" : "annual",
|
|
282
293
|
unavailableSymbols: [...loaded.unavailableSymbols, ...empty.flatMap(({ data }) => data.unavailableSymbols ?? [])],
|
|
283
294
|
errors: [...loaded.errors, ...tables.flatMap(({ symbol, data }) => (data.errors ?? []).map((error) => error.startsWith(symbol) ? error : `${symbol}: ${error}`))],
|
|
284
|
-
notes: [...new Set([...notes.filter(shared), ...ownNotes])],
|
|
295
|
+
notes: [...new Set([...notes.filter(shared), ...ownNotes, ...(fx?.note ? [fx.note] : []), ...fx?.failures ?? []])],
|
|
285
296
|
metadata: {
|
|
286
297
|
symbols, layout: "long", statement: first.statement ?? options.statement, statementLabel: first.statementLabel ?? null,
|
|
287
298
|
period: options.period === "quarterly" ? "quarterly" : "annual",
|
|
299
|
+
...(fx ? { currency: target, conversions: fx.conversions } : {}),
|
|
288
300
|
notices: [...new Set(tables.flatMap(({ data }) => (data.metadata?.notices ?? []) as string[]))],
|
|
289
301
|
limitations: [...new Set(tables.flatMap(({ data }) => (data.metadata?.limitations ?? []) as string[]))],
|
|
290
302
|
},
|
|
@@ -453,8 +465,9 @@ function reportOlderStatements(ctx: HeadlessContext, symbol: string, period: "an
|
|
|
453
465
|
/**
|
|
454
466
|
* Why a statements report has no rows, and what to read instead: a listing
|
|
455
467
|
* with years but no quarters names its years, and says so of a company that
|
|
456
|
-
* reports half-yearly (Qantas on ASX)
|
|
457
|
-
*
|
|
468
|
+
* reports half-yearly (Qantas on ASX); one with quarters but no full year
|
|
469
|
+
* reported (O8A:FWB2) names its quarters. Null when it has years and
|
|
470
|
+
* quarters, whatever this table lacks.
|
|
458
471
|
*/
|
|
459
472
|
async function missingPeriodsError(
|
|
460
473
|
ctx: HeadlessContext,
|
|
@@ -465,12 +478,15 @@ async function missingPeriodsError(
|
|
|
465
478
|
statement: unknown,
|
|
466
479
|
): Promise<string | null> {
|
|
467
480
|
const hasYears = financials.annualStatements.length > 0;
|
|
481
|
+
const tab = typeof statement === "string" && statement && statement !== "income" ? ` --statement ${statement}` : "";
|
|
482
|
+
if (period === "annual" && !hasRequestedStatements && financials.quarterlyStatements.length > 0) {
|
|
483
|
+
return `${symbol}: No annual financial statement coverage. For its quarters: gloom fn FA ${symbol} --period quarterly${tab}`;
|
|
484
|
+
}
|
|
468
485
|
if (period === "annual" || !hasYears) return hasRequestedStatements ? null : `${symbol}: No ${period} financial statement coverage.`;
|
|
469
486
|
const exchange = await resolveHeadlessInstrument(ctx, symbol).then(({ exchange }) => canonicalExchange(exchange ?? ""))
|
|
470
487
|
.catch(logFailure("ticker-detail.headless", "Resolving the listing of a statements report failed", ""));
|
|
471
488
|
const halfYearly = reportsHalfYearly(exchange, financials.quarterlyStatements, financials.annualStatements);
|
|
472
489
|
if (hasRequestedStatements && !halfYearly) return null;
|
|
473
|
-
const tab = typeof statement === "string" && statement && statement !== "income" ? ` --statement ${statement}` : "";
|
|
474
490
|
const years = `For its years: gloom fn FA ${symbol} --period annual${tab}`;
|
|
475
491
|
return halfYearly ? `${symbol} reports half-yearly, not quarterly. ${years}` : `${symbol}: No quarterly financial statement coverage. ${years}`;
|
|
476
492
|
}
|