gloomberb 0.15.7 → 0.16.0
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/README.md +11 -2
- package/package.json +1 -1
- package/src/api-client/app-attention.ts +147 -0
- package/src/api-client/attention.ts +26 -0
- package/src/api-client/awards.ts +215 -0
- package/src/api-client/catalysts.ts +160 -0
- package/src/api-client/chat.ts +137 -14
- package/src/api-client/company-kpis.ts +153 -0
- package/src/api-client/cpi.ts +52 -0
- package/src/api-client/credit-documents.ts +107 -0
- package/src/api-client/data.ts +192 -3
- package/src/api-client/distress.ts +164 -0
- package/src/api-client/doe.ts +75 -0
- package/src/api-client/equity-screener.ts +11 -0
- package/src/api-client/exposure.ts +202 -0
- package/src/api-client/gpu.ts +93 -0
- package/src/api-client/hiring.ts +110 -0
- package/src/api-client/index.ts +78 -3
- package/src/api-client/normalizers.ts +31 -1
- package/src/api-client/paths.ts +3 -0
- package/src/api-client/perps.ts +127 -0
- package/src/api-client/power.ts +148 -0
- package/src/api-client/request.ts +58 -1
- package/src/api-client/research-activity.ts +172 -13
- package/src/api-client/socket.ts +75 -27
- package/src/api-client/supply-chain-graph.ts +40 -0
- package/src/api-client/supply-chain.ts +98 -0
- package/src/api-client/telemetry.ts +29 -0
- package/src/api-client/themes.ts +28 -0
- package/src/api-client/types.ts +33 -1
- package/src/api-client/wall-experiments.ts +100 -0
- package/src/api-client/wall-summary.ts +49 -0
- package/src/api-client/web-experiments.ts +136 -0
- package/src/app/pane-runtime/plugin-bindings.ts +5 -0
- package/src/app/pane-runtime/ticker-open-runtime.ts +8 -2
- package/src/app/runtime/update.ts +13 -1
- package/src/cli/commands/system.ts +2 -0
- package/src/cli/desktop-pane-shot.ts +3 -4
- package/src/cli/pane-functions/data.ts +78 -0
- package/src/cli/pane-functions/financial-ratio-shot.ts +160 -0
- package/src/cli/pane-functions/function-help.ts +220 -8
- package/src/cli/pane-functions/headless.ts +4 -0
- package/src/cli/pane-functions/screenshot-evidence.ts +21 -0
- package/src/cli/pane-functions/screenshot.ts +49 -5
- package/src/components/chart/composite/composite-chart.tsx +15 -2
- package/src/components/chart/composite/format.ts +24 -11
- package/src/components/chart/composite/rasterizer.ts +67 -16
- package/src/components/chart/composite/scene.ts +53 -2
- package/src/components/chart/composite/session-shading.ts +3 -2
- package/src/components/chart/composite/text-renderer.ts +52 -1
- package/src/components/chart/composite/time-axis.ts +100 -30
- package/src/components/chart/composite/tools.ts +2 -1
- package/src/components/chart/composite/types.ts +4 -0
- package/src/components/chart-table/index.ts +1 -0
- package/src/components/chart-table/layout.ts +15 -0
- package/src/components/command-bar/action-runtime.ts +1 -0
- package/src/components/command-bar/commands/direct/index.ts +32 -0
- package/src/components/command-bar/commands/registry.ts +7 -0
- package/src/components/command-bar/pane-templates/items.ts +11 -0
- package/src/components/command-bar/pane-templates/workflow.ts +19 -4
- package/src/components/command-bar/routes/root/command-items.ts +6 -0
- package/src/components/command-bar/routes/root/provider-search.ts +2 -0
- package/src/components/command-bar/routes/root/results.ts +64 -0
- package/src/components/command-bar/routes/root/runtime.ts +8 -0
- package/src/components/command-bar/routes/ticker-search/results.ts +89 -24
- package/src/components/command-bar/routes/ticker-search/route.ts +2 -0
- package/src/components/command-bar/surface/index.tsx +15 -0
- package/src/components/command-bar/view-model.ts +3 -0
- package/src/components/command-bar/workflow/collection-actions.ts +9 -7
- package/src/components/command-bar/workflow/ops.ts +19 -0
- package/src/components/command-bar/workflow/tickers.ts +5 -0
- package/src/components/company-logo.tsx +15 -2
- package/src/components/data-table/table-pane.ts +2 -1
- package/src/components/index.ts +1 -0
- package/src/components/layout/detached-pane-shell.tsx +12 -1
- package/src/components/layout/missing-pane.tsx +87 -23
- package/src/components/layout/pane/footer/index.tsx +64 -18
- package/src/components/layout/pane/footer/model.ts +85 -0
- package/src/components/layout/pane/sidebar.tsx +19 -1
- package/src/components/layout/shell/index.tsx +38 -28
- package/src/components/layout/shell/pane/management-shortcuts.ts +13 -1
- package/src/components/layout/status-bar.tsx +93 -28
- package/src/components/layout/status-widget-space.ts +72 -0
- package/src/components/onboarding/first-run-workspace.ts +8 -2
- package/src/components/onboarding/onboarding-wizard.tsx +35 -16
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +14 -5
- package/src/components/onboarding/wizard-model.ts +13 -5
- package/src/components/onboarding/wizard-positions.ts +56 -7
- package/src/components/price-performance.tsx +31 -34
- package/src/components/ui/data-table/index.tsx +11 -8
- package/src/components/ui/display.tsx +15 -6
- package/src/components/ui/fields.tsx +5 -0
- package/src/components/ui/figure.tsx +94 -0
- package/src/components/ui/header-case.ts +25 -3
- package/src/components/ui/icon.tsx +3 -1
- package/src/components/ui/message-composer.tsx +8 -1
- package/src/components/ui/query-bar.tsx +8 -1
- package/src/components/ui/ratio-bar.tsx +84 -0
- package/src/components/ui/toggle.tsx +3 -1
- package/src/components/use-scrollbox-layout.ts +17 -0
- package/src/core/state/app/layout.ts +35 -1
- package/src/core/state/app/state.ts +15 -0
- package/src/core/state/app/types.ts +1 -0
- package/src/data/config/store/normalize.ts +24 -0
- package/src/i18n/es.ts +2 -0
- package/src/i18n/ja.ts +2 -0
- package/src/i18n/ko.ts +2 -0
- package/src/i18n/zh-cn.ts +2 -0
- package/src/i18n/zh-tw.ts +2 -0
- package/src/layout-marketplace/pane-imagery.ts +1 -0
- package/src/market-data/coordinator/entries.ts +13 -0
- package/src/market-data/coordinator/financials.ts +33 -8
- package/src/market-data/market/freshness.ts +16 -5
- package/src/market-data/market/trading-sessions.ts +65 -1
- package/src/market-data/published-cn-sessions.ts +25 -0
- package/src/market-data/published-nse-sessions.ts +20 -0
- package/src/news/aggregator.ts +4 -0
- package/src/plugins/builtin/account-management/model.ts +6 -1
- package/src/plugins/builtin/account-management/pane.tsx +36 -25
- package/src/plugins/builtin/alerts/catalysts.ts +77 -0
- package/src/plugins/builtin/alerts/events-pane.tsx +3 -0
- package/src/plugins/builtin/alerts/events.ts +10 -4
- package/src/plugins/builtin/alerts/history-pane.tsx +1 -1
- package/src/plugins/builtin/alerts/history.ts +1 -0
- package/src/plugins/builtin/alerts/index.tsx +6 -0
- package/src/plugins/builtin/alerts/research-builder.ts +10 -3
- package/src/plugins/builtin/alerts/research-rules.ts +15 -1
- package/src/plugins/builtin/analytics/risk-client.ts +15 -3
- package/src/plugins/builtin/analytics/risk-headless.ts +123 -18
- package/src/plugins/builtin/attention/client.ts +80 -0
- package/src/plugins/builtin/attention/evidence.ts +30 -0
- package/src/plugins/builtin/attention/headless.ts +33 -0
- package/src/plugins/builtin/attention/index.tsx +18 -0
- package/src/plugins/builtin/attention/model.ts +59 -0
- package/src/plugins/builtin/attention/pane.tsx +211 -0
- package/src/plugins/builtin/attention/trending.tsx +59 -0
- package/src/plugins/builtin/awards/alerts.ts +32 -0
- package/src/plugins/builtin/awards/client.ts +82 -0
- package/src/plugins/builtin/awards/detail.tsx +107 -0
- package/src/plugins/builtin/awards/evidence.ts +36 -0
- package/src/plugins/builtin/awards/headless.ts +55 -0
- package/src/plugins/builtin/awards/index.tsx +20 -0
- package/src/plugins/builtin/awards/model.ts +42 -0
- package/src/plugins/builtin/awards/pane.tsx +263 -0
- package/src/plugins/builtin/catalysts/client.ts +28 -0
- package/src/plugins/builtin/catalysts/detail.tsx +88 -0
- package/src/plugins/builtin/catalysts/evidence.ts +47 -0
- package/src/plugins/builtin/catalysts/headless.ts +42 -0
- package/src/plugins/builtin/catalysts/history.ts +26 -0
- package/src/plugins/builtin/catalysts/index.tsx +29 -0
- package/src/plugins/builtin/catalysts/model.ts +135 -0
- package/src/plugins/builtin/catalysts/pane.tsx +159 -0
- package/src/plugins/builtin/chart-composer/cli-options.ts +4 -0
- package/src/plugins/builtin/chart-composer/headless-schema.ts +6 -0
- package/src/plugins/builtin/chart-composer/index.tsx +8 -1
- package/src/plugins/builtin/chart-composer/pane.tsx +28 -1
- package/src/plugins/builtin/chat/attachments/desktop.tsx +610 -0
- package/src/plugins/builtin/chat/attachments/files.ts +45 -0
- package/src/plugins/builtin/chat/attachments/model.ts +164 -0
- package/src/plugins/builtin/chat/attachments/terminal.tsx +72 -0
- package/src/plugins/builtin/chat/attachments/transfer.ts +165 -0
- package/src/plugins/builtin/chat/content/channel-navigation.ts +13 -12
- package/src/plugins/builtin/chat/content/composer-runtime.ts +25 -4
- package/src/plugins/builtin/chat/content/composer.tsx +46 -4
- package/src/plugins/builtin/chat/content/footer.tsx +46 -8
- package/src/plugins/builtin/chat/content/index.tsx +263 -62
- package/src/plugins/builtin/chat/content/layout-metrics.ts +10 -2
- package/src/plugins/builtin/chat/content/open-targets.ts +17 -3
- package/src/plugins/builtin/chat/content/scroll.ts +7 -1
- package/src/plugins/builtin/chat/content/shortcuts.ts +36 -11
- package/src/plugins/builtin/chat/content/snapshot.ts +3 -0
- package/src/plugins/builtin/chat/content/transcript.tsx +17 -1
- package/src/plugins/builtin/chat/content/types.ts +7 -0
- package/src/plugins/builtin/chat/controller/attachments.ts +213 -0
- package/src/plugins/builtin/chat/controller/connections.ts +3 -1
- package/src/plugins/builtin/chat/controller/index.ts +114 -2
- package/src/plugins/builtin/chat/controller/lifecycle.ts +9 -0
- package/src/plugins/builtin/chat/controller/messages.ts +35 -2
- package/src/plugins/builtin/chat/controller/send.ts +128 -25
- package/src/plugins/builtin/chat/controller/state.ts +12 -1
- package/src/plugins/builtin/chat/controller/utils.ts +7 -5
- package/src/plugins/builtin/chat/controller/view.ts +2 -0
- package/src/plugins/builtin/chat/index.tsx +21 -0
- package/src/plugins/builtin/chat/layout.ts +9 -4
- package/src/plugins/builtin/chat/message/desktop.tsx +55 -20
- package/src/plugins/builtin/chat/message/header.tsx +30 -5
- package/src/plugins/builtin/chat/message/inline-tokens.tsx +9 -0
- package/src/plugins/builtin/chat/message/pending-send.ts +35 -0
- package/src/plugins/builtin/chat/message/profile-popover.tsx +5 -1
- package/src/plugins/builtin/chat/message/render-state.ts +12 -2
- package/src/plugins/builtin/chat/message/terminal.tsx +51 -4
- package/src/plugins/builtin/chat/message/types.ts +6 -1
- package/src/plugins/builtin/chat/pane-state.ts +59 -1
- package/src/plugins/builtin/chat/profile-popover.ts +50 -1
- package/src/plugins/builtin/chat/sidebar.tsx +8 -3
- package/src/plugins/builtin/chat/status-widget.tsx +29 -12
- package/src/plugins/builtin/chat/unread-inbox-pane.tsx +143 -0
- package/src/plugins/builtin/chat/unread-inbox.ts +91 -0
- package/src/plugins/builtin/clinical-trials/client.ts +237 -0
- package/src/plugins/builtin/clinical-trials/index.tsx +74 -0
- package/src/plugins/builtin/clinical-trials/pane.tsx +225 -0
- package/src/plugins/builtin/clinical-trials/types.ts +2 -0
- package/src/plugins/builtin/cloud/askg/controller.ts +37 -6
- package/src/plugins/builtin/cloud/askg/executor.ts +59 -44
- package/src/plugins/builtin/cloud/askg/host.ts +8 -1
- package/src/plugins/builtin/cloud/askg/manifest.ts +29 -2
- package/src/plugins/builtin/cloud/askg/model.ts +47 -13
- package/src/plugins/builtin/cloud/askg/notes.ts +100 -0
- package/src/plugins/builtin/cloud/askg/pane.tsx +50 -14
- package/src/plugins/builtin/cloud/askg/protocol.ts +39 -1
- package/src/plugins/builtin/cloud/askg/result-budget.ts +156 -0
- package/src/plugins/builtin/cloud/askg/user-data.ts +89 -0
- package/src/plugins/builtin/cloud/auth-actions.tsx +55 -31
- package/src/plugins/builtin/cloud/plugin.tsx +4 -1
- package/src/plugins/builtin/cloud/team/pane-sections.tsx +10 -1
- package/src/plugins/builtin/cloud/team/pane.tsx +3 -2
- package/src/plugins/builtin/cloud/thesis/board-pane.tsx +2 -2
- package/src/plugins/builtin/cloud/thesis/detail.tsx +1 -1
- package/src/plugins/builtin/cloud/thesis/ticker-tab.tsx +2 -2
- package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +202 -0
- package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
- package/src/plugins/builtin/cloud/upgrade-dialog.tsx +29 -3
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +1 -1
- package/src/plugins/builtin/cloud-tweets/table.tsx +1 -1
- package/src/plugins/builtin/comment-letters/client.ts +342 -0
- package/src/plugins/builtin/comment-letters/index.tsx +74 -0
- package/src/plugins/builtin/comment-letters/pane.tsx +295 -0
- package/src/plugins/builtin/comment-letters/types.ts +43 -0
- package/src/plugins/builtin/company-attention/app-rank.tsx +79 -0
- package/src/plugins/builtin/company-attention/client.ts +69 -0
- package/src/plugins/builtin/company-attention/evidence.ts +45 -0
- package/src/plugins/builtin/company-attention/headless.ts +47 -0
- package/src/plugins/builtin/company-attention/index.tsx +30 -0
- package/src/plugins/builtin/company-attention/model.ts +129 -0
- package/src/plugins/builtin/company-attention/pane.tsx +183 -0
- package/src/plugins/builtin/company-kpis/client.ts +92 -0
- package/src/plugins/builtin/company-kpis/headless.ts +32 -0
- package/src/plugins/builtin/company-kpis/index.tsx +26 -0
- package/src/plugins/builtin/company-kpis/model.ts +124 -0
- package/src/plugins/builtin/company-kpis/pane.tsx +226 -0
- package/src/plugins/builtin/company-kpis/related.ts +11 -0
- package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +44 -0
- package/src/plugins/builtin/composite-plugins.ts +34 -0
- package/src/plugins/builtin/correlation/history.ts +4 -1
- package/src/plugins/builtin/correlation/index.tsx +139 -80
- package/src/plugins/builtin/correlation/matrix/pair-chart.tsx +48 -0
- package/src/plugins/builtin/correlation/matrix/selection.ts +77 -0
- package/src/plugins/builtin/correlation/relationship/model.ts +2 -2
- package/src/plugins/builtin/cpi/client.ts +66 -0
- package/src/plugins/builtin/cpi/headless.ts +78 -0
- package/src/plugins/builtin/cpi/index.tsx +31 -0
- package/src/plugins/builtin/cpi/model.ts +198 -0
- package/src/plugins/builtin/cpi/pane.tsx +157 -0
- package/src/plugins/builtin/credit-documents/client.ts +99 -0
- package/src/plugins/builtin/credit-documents/detail.tsx +109 -0
- package/src/plugins/builtin/credit-documents/evidence.ts +64 -0
- package/src/plugins/builtin/credit-documents/gauge.tsx +55 -0
- package/src/plugins/builtin/credit-documents/headless.ts +40 -0
- package/src/plugins/builtin/credit-documents/index.tsx +19 -0
- package/src/plugins/builtin/credit-documents/model.ts +336 -0
- package/src/plugins/builtin/credit-documents/pane.tsx +185 -0
- package/src/plugins/builtin/custom-view/view-spec.ts +14 -2
- package/src/plugins/builtin/debt-maturities/pane.tsx +1 -0
- package/src/plugins/builtin/dividend-yield/pane.tsx +1 -1
- package/src/plugins/builtin/doe/client.ts +73 -0
- package/src/plugins/builtin/doe/headless.ts +93 -0
- package/src/plugins/builtin/doe/index.tsx +41 -0
- package/src/plugins/builtin/doe/model.ts +215 -0
- package/src/plugins/builtin/doe/pane.tsx +148 -0
- package/src/plugins/builtin/doe/range-bar.tsx +45 -0
- package/src/plugins/builtin/earnings/board.tsx +3 -0
- package/src/plugins/builtin/earnings/index.tsx +2 -0
- package/src/plugins/builtin/earnings-calls/pane.tsx +7 -1
- package/src/plugins/builtin/earnings-calls/transcript-view.tsx +7 -7
- package/src/plugins/builtin/earnings-ripple/client.ts +60 -0
- package/src/plugins/builtin/earnings-ripple/headless.ts +35 -0
- package/src/plugins/builtin/earnings-ripple/index.tsx +35 -0
- package/src/plugins/builtin/earnings-ripple/model.ts +98 -0
- package/src/plugins/builtin/earnings-ripple/pane.tsx +103 -0
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +1 -1
- package/src/plugins/builtin/equity-screener/model.ts +74 -9
- package/src/plugins/builtin/equity-screener/pane.tsx +2 -0
- package/src/plugins/builtin/estimate-revisions/pane.tsx +3 -0
- package/src/plugins/builtin/executives/pane.tsx +7 -5
- package/src/plugins/builtin/exposure/charts.tsx +66 -0
- package/src/plugins/builtin/exposure/client.ts +53 -0
- package/src/plugins/builtin/exposure/drivers.ts +29 -0
- package/src/plugins/builtin/exposure/editor.tsx +61 -0
- package/src/plugins/builtin/exposure/evidence.ts +39 -0
- package/src/plugins/builtin/exposure/headless.ts +51 -0
- package/src/plugins/builtin/exposure/holdings.ts +56 -0
- package/src/plugins/builtin/exposure/index.tsx +13 -0
- package/src/plugins/builtin/exposure/model.ts +104 -0
- package/src/plugins/builtin/exposure/pane.tsx +247 -0
- package/src/plugins/builtin/fear-greed/charts.tsx +1 -1
- package/src/plugins/builtin/fear-greed/pane.tsx +2 -9
- package/src/plugins/builtin/filing-events/pane.tsx +2 -1
- package/src/plugins/builtin/gpu/board.tsx +163 -0
- package/src/plugins/builtin/gpu/changes.tsx +94 -0
- package/src/plugins/builtin/gpu/client.ts +130 -0
- package/src/plugins/builtin/gpu/equities.tsx +112 -0
- package/src/plugins/builtin/gpu/headless.ts +67 -0
- package/src/plugins/builtin/gpu/history.tsx +140 -0
- package/src/plugins/builtin/gpu/index.tsx +18 -0
- package/src/plugins/builtin/gpu/ladder.tsx +127 -0
- package/src/plugins/builtin/gpu/model.ts +317 -0
- package/src/plugins/builtin/gpu/pane.tsx +63 -0
- package/src/plugins/builtin/help/index.tsx +19 -2
- package/src/plugins/builtin/holders/pane.tsx +5 -9
- package/src/plugins/builtin/insider/detail.tsx +119 -0
- package/src/plugins/builtin/insider/display.ts +221 -0
- package/src/plugins/builtin/insider/headless.ts +24 -3
- package/src/plugins/builtin/insider/index.tsx +206 -108
- package/src/plugins/builtin/insider/insider-data.ts +31 -3
- package/src/plugins/builtin/insider/model.ts +53 -4
- package/src/plugins/builtin/insider/table-model.ts +226 -0
- package/src/plugins/builtin/insider/table.tsx +79 -0
- package/src/plugins/builtin/iv-history/screen-pane.tsx +1 -1
- package/src/plugins/builtin/jobs/pane.tsx +14 -7
- package/src/plugins/builtin/kelly-sizer/pane.tsx +1 -1
- package/src/plugins/builtin/macro-day/client.ts +50 -0
- package/src/plugins/builtin/macro-day/headless.ts +51 -0
- package/src/plugins/builtin/macro-day/index.tsx +21 -0
- package/src/plugins/builtin/macro-day/model.ts +137 -0
- package/src/plugins/builtin/macro-day/pane.tsx +118 -0
- package/src/plugins/builtin/macro-day/releases.ts +58 -0
- package/src/plugins/builtin/market-halts/model.ts +30 -17
- package/src/plugins/builtin/market-halts/pane.tsx +15 -21
- package/src/plugins/builtin/market-heatmap/data.ts +1 -1
- package/src/plugins/builtin/market-heatmap/index.tsx +198 -50
- package/src/plugins/builtin/market-heatmap/portfolio.ts +220 -0
- package/src/plugins/builtin/market-movers/index.tsx +1 -0
- package/src/plugins/builtin/market-movers/session-body.tsx +5 -2
- package/src/plugins/builtin/mna/distress/client.ts +326 -0
- package/src/plugins/builtin/mna/distress/detail.tsx +247 -0
- package/src/plugins/builtin/mna/distress/headless.ts +257 -0
- package/src/plugins/builtin/mna/distress/model.ts +427 -0
- package/src/plugins/builtin/mna/distress/pane.tsx +606 -0
- package/src/plugins/builtin/mna/index.tsx +15 -0
- package/src/plugins/builtin/mna/pane.tsx +42 -1
- package/src/plugins/builtin/news/index.tsx +62 -16
- package/src/plugins/builtin/news/wire/filter-articles.ts +54 -0
- package/src/plugins/builtin/news/wire/index.tsx +37 -3
- package/src/plugins/builtin/news/wire/industry-pane.tsx +29 -13
- package/src/plugins/builtin/news/wire/mutes.ts +253 -0
- package/src/plugins/builtin/news/wire/news/command-bar-search.ts +117 -0
- package/src/plugins/builtin/news/wire/news/footer.ts +4 -0
- package/src/plugins/builtin/news/wire/news/list-search.ts +34 -0
- package/src/plugins/builtin/news/wire/news/pop-out.tsx +158 -0
- package/src/plugins/builtin/news/wire/news/preset-pane.tsx +64 -19
- package/src/plugins/builtin/openfda/client.ts +300 -0
- package/src/plugins/builtin/openfda/index.tsx +71 -0
- package/src/plugins/builtin/openfda/pane.tsx +382 -0
- package/src/plugins/builtin/openfda/types.ts +76 -0
- package/src/plugins/builtin/options/footer.ts +1 -0
- package/src/plugins/builtin/options/view.tsx +1 -1
- package/src/plugins/builtin/options-calculator/pane.tsx +0 -1
- package/src/plugins/builtin/options-positioning/index.tsx +4 -2
- package/src/plugins/builtin/options-positioning/pane.tsx +1 -1
- package/src/plugins/builtin/pe-band/client.ts +61 -0
- package/src/plugins/builtin/pe-band/headless.ts +51 -0
- package/src/plugins/builtin/pe-band/index.tsx +20 -0
- package/src/plugins/builtin/pe-band/model.ts +267 -0
- package/src/plugins/builtin/pe-band/pane.tsx +159 -0
- package/src/plugins/builtin/perps/client.ts +66 -0
- package/src/plugins/builtin/perps/equity-row.tsx +28 -0
- package/src/plugins/builtin/perps/headless.ts +34 -0
- package/src/plugins/builtin/perps/index.tsx +14 -0
- package/src/plugins/builtin/perps/model.ts +58 -0
- package/src/plugins/builtin/perps/pane.tsx +185 -0
- package/src/plugins/builtin/plugin-marketplace/pane.tsx +0 -1
- package/src/plugins/builtin/portfolio-list/cli/render.ts +177 -87
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +6 -20
- package/src/plugins/builtin/portfolio-list/command-bar.ts +6 -2
- package/src/plugins/builtin/portfolio-list/headless.ts +237 -0
- package/src/plugins/builtin/portfolio-list/index.tsx +2 -0
- package/src/plugins/builtin/portfolio-list/mutations.ts +70 -1
- package/src/plugins/builtin/portfolio-list/pane/data.ts +17 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +88 -5
- package/src/plugins/builtin/portfolio-list/pane/remove-ticker.ts +85 -0
- package/src/plugins/builtin/portfolio-list/pane/streaming.ts +18 -12
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +6 -0
- package/src/plugins/builtin/power/client.ts +100 -0
- package/src/plugins/builtin/power/detail.tsx +82 -0
- package/src/plugins/builtin/power/evidence.ts +56 -0
- package/src/plugins/builtin/power/generation.tsx +37 -0
- package/src/plugins/builtin/power/headless.ts +43 -0
- package/src/plugins/builtin/power/index.tsx +16 -0
- package/src/plugins/builtin/power/model.ts +89 -0
- package/src/plugins/builtin/power/pane.tsx +209 -0
- package/src/plugins/builtin/power/query.ts +25 -0
- package/src/plugins/builtin/relative-rotation/pane.tsx +3 -3
- package/src/plugins/builtin/research/analyst-pane.tsx +1 -1
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +13 -4
- package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +11 -9
- package/src/plugins/builtin/research-search/pane.tsx +21 -7
- package/src/plugins/builtin/revenue-breakdown/pane.tsx +1 -1
- package/src/plugins/builtin/reverse-dcf/client.ts +35 -0
- package/src/plugins/builtin/reverse-dcf/headless.ts +44 -0
- package/src/plugins/builtin/reverse-dcf/index.tsx +20 -0
- package/src/plugins/builtin/reverse-dcf/model.ts +87 -0
- package/src/plugins/builtin/reverse-dcf/pane.tsx +107 -0
- package/src/plugins/builtin/risk-factors/pane.tsx +6 -5
- package/src/plugins/builtin/scanner/denied.tsx +4 -2
- package/src/plugins/builtin/scanner/feed.ts +1 -0
- package/src/plugins/builtin/scanner/flow-pane.tsx +3 -2
- package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
- package/src/plugins/builtin/seasonality/client.ts +4 -1
- package/src/plugins/builtin/sec/command-bar-search.ts +217 -0
- package/src/plugins/builtin/sec/forms.ts +54 -0
- package/src/plugins/builtin/sec/headless.ts +31 -5
- package/src/plugins/builtin/sec/index.tsx +67 -11
- package/src/plugins/builtin/sec/model.ts +35 -5
- package/src/plugins/builtin/sectors/headless.ts +1 -0
- package/src/plugins/builtin/sectors/index.tsx +72 -26
- package/src/plugins/builtin/shared/cloud-upgrade.ts +143 -39
- package/src/plugins/builtin/shared/pro-feature-wall.tsx +8 -4
- package/src/plugins/builtin/shared/research-cells.tsx +107 -0
- package/src/plugins/builtin/shared/series-list-detail.tsx +5 -1
- package/src/plugins/builtin/shared/ticker-request.ts +1 -1
- package/src/plugins/builtin/shared/wall-teaser-catalog.ts +80 -0
- package/src/plugins/builtin/shared/wall-teaser.tsx +192 -0
- package/src/plugins/builtin/shared/wall-view-lifecycle.ts +43 -0
- package/src/plugins/builtin/short-interest/index.tsx +31 -0
- package/src/plugins/builtin/short-interest/watch-client.ts +70 -0
- package/src/plugins/builtin/short-interest/watch-headless.ts +49 -0
- package/src/plugins/builtin/short-interest/watch-model.ts +185 -0
- package/src/plugins/builtin/short-interest/watch-pane.tsx +169 -0
- package/src/plugins/builtin/short-volume/pane.tsx +1 -1
- package/src/plugins/builtin/social-mentions/pane.tsx +1 -1
- package/src/plugins/builtin/supply-chain/client.ts +104 -0
- package/src/plugins/builtin/supply-chain/disclosure-quote.tsx +17 -0
- package/src/plugins/builtin/supply-chain/evidence.ts +88 -0
- package/src/plugins/builtin/supply-chain/flow-layout.ts +133 -0
- package/src/plugins/builtin/supply-chain/flow.tsx +323 -0
- package/src/plugins/builtin/supply-chain/graph-client.ts +83 -0
- package/src/plugins/builtin/supply-chain/graph-evidence.ts +25 -0
- package/src/plugins/builtin/supply-chain/graph-model.ts +45 -0
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +218 -0
- package/src/plugins/builtin/supply-chain/graph.tsx +163 -0
- package/src/plugins/builtin/supply-chain/headless.ts +105 -0
- package/src/plugins/builtin/supply-chain/index.tsx +17 -0
- package/src/plugins/builtin/supply-chain/model.ts +145 -0
- package/src/plugins/builtin/supply-chain/pane.tsx +276 -0
- package/src/plugins/builtin/supply-chain/row-evidence.tsx +96 -0
- package/src/plugins/builtin/supply-chain/trust.ts +34 -0
- package/src/plugins/builtin/themes/client.ts +39 -0
- package/src/plugins/builtin/themes/headless.ts +38 -0
- package/src/plugins/builtin/themes/model.ts +92 -0
- package/src/plugins/builtin/themes/pane.tsx +125 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +6 -15
- package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +5 -6
- package/src/plugins/builtin/ticker-detail/data-panes/returns-model.ts +201 -0
- package/src/plugins/builtin/ticker-detail/data-panes/returns-pane.tsx +327 -0
- package/src/plugins/builtin/ticker-detail/financials/period-end-history.ts +5 -2
- package/src/plugins/builtin/ticker-detail/financials/ratios.ts +60 -12
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +2 -1
- package/src/plugins/builtin/ticker-detail/headless.ts +7 -2
- package/src/plugins/builtin/ticker-detail/index.tsx +22 -0
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +53 -30
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +2 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +112 -47
- package/src/plugins/builtin/ticker-detail/pane.tsx +50 -6
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +21 -42
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +3 -0
- package/src/plugins/builtin/time-sales/pane.tsx +1 -1
- package/src/plugins/builtin/world-indices/indices.ts +1 -0
- package/src/plugins/catalog-browser.ts +40 -0
- package/src/plugins/catalog-manifest.ts +3 -0
- package/src/plugins/catalog-ui.ts +6 -0
- package/src/plugins/current-target.ts +0 -9
- package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
- package/src/renderers/browser/cloud-transport.ts +66 -1
- package/src/renderers/browser/main.tsx +2 -0
- package/src/renderers/dom/data-table/row.tsx +2 -0
- package/src/renderers/dom/desktop/controls.tsx +38 -25
- package/src/renderers/dom/desktop/icons.tsx +8 -0
- package/src/renderers/dom/host/chart-surface.tsx +36 -2
- package/src/renderers/dom/host/focus-scope.ts +11 -1
- package/src/renderers/dom/styles.css +28 -0
- package/src/renderers/electrobun/view/backend-rpc.ts +3 -2
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +1 -1
- package/src/renderers/electrobun/view/http-fetch.ts +2 -0
- package/src/renderers/electrobun/view/main.tsx +3 -1
- package/src/renderers/electrobun/view/rpc-timeout.ts +59 -0
- package/src/renderers/opentui/start.tsx +3 -0
- package/src/shares/api.ts +3 -1
- package/src/sources/gloomberb-cloud/index.ts +47 -13
- package/src/sources/history-result.ts +1 -0
- package/src/sources/history-retention.ts +16 -0
- package/src/sources/provider-router/history.ts +4 -2
- package/src/sources/sec-edgar/identity.ts +36 -0
- package/src/sources/sec-edgar.ts +1 -34
- package/src/state/app/context/index.tsx +8 -0
- package/src/sync/core-contributors.ts +20 -2
- package/src/telemetry/attention-counts.ts +164 -0
- package/src/telemetry/live-config.ts +7 -0
- package/src/test-support/rpc-loopback.ts +7 -3
- package/src/test-support/shell-pane-keys.tsx +34 -0
- package/src/tickers/instrument-kind.ts +12 -6
- package/src/tickers/open-target.ts +1 -1
- package/src/tickers/search/asset-classes.ts +91 -0
- package/src/tickers/search/index.ts +62 -15
- package/src/tickers/search/ranking.ts +22 -3
- package/src/tickers/search/upsert.ts +4 -1
- package/src/time-series/live-bars.ts +8 -3
- package/src/time-series/resolve.ts +224 -17
- package/src/time-series/spec.ts +1 -0
- package/src/time-series/types.ts +9 -1
- package/src/types/config.ts +23 -1
- package/src/types/data-provider.ts +2 -0
- package/src/types/headless.ts +17 -0
- package/src/types/price-history.ts +2 -0
- package/src/ui/host.tsx +6 -0
- package/src/utils/double-escape-close.ts +20 -0
- package/src/utils/exchanges.ts +1 -0
- package/src/utils/html-entities.ts +15 -0
- package/src/utils/http-proxy-response.ts +44 -7
- package/src/utils/plugin-proxy-hosts.json +3 -0
- package/src/utils/price-history.ts +35 -1
- package/src/utils/sec.ts +21 -2
- package/src/utils/text-wrap.ts +13 -8
- package/src/utils/zoned-date-time.ts +67 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { THEME_PERIODS } from "../../../api-client/themes";
|
|
2
|
+
import type { HeadlessPaneColumn, HeadlessPaneDefinition } from "../../../types/plugin";
|
|
3
|
+
import { fetchThemeMembers, fetchThemes } from "./client";
|
|
4
|
+
import { aggregateText, DEFAULT_SORT, matchTheme, memberPrice, percent, PERIOD_LABELS, sortMembers, sortThemes } from "./model";
|
|
5
|
+
|
|
6
|
+
const periods: HeadlessPaneColumn[] = THEME_PERIODS.map((key) => ({ key, header: PERIOD_LABELS[key], align: "right", format: (value) => percent(value as number | null) }));
|
|
7
|
+
export const themesHeadless: HeadlessPaneDefinition<"rows"> = {
|
|
8
|
+
shape: "rows",
|
|
9
|
+
argument: { kind: "free-text", optional: true, placeholder: "theme", description: "Theme name or keyword, such as nuclear; omit for all themes." },
|
|
10
|
+
options: [],
|
|
11
|
+
discovery: { aliases: ["THEM"], dataRequirements: ["Gloom Cloud stored equity snapshot"],
|
|
12
|
+
limitations: ["Updated every 15 minutes for Free and Pro", "Equal-weight price returns; missing observations reduce coverage", "Below half coverage a period is unavailable"] },
|
|
13
|
+
describe: (args) => args.rawArgument ? `Thematic baskets | ${args.rawArgument}` : "Thematic baskets",
|
|
14
|
+
async load(args, context) {
|
|
15
|
+
const board = await fetchThemes(context.apiClient);
|
|
16
|
+
const argument = Array.isArray(args.argument) ? args.argument.join(" ") : args.argument;
|
|
17
|
+
if (argument) {
|
|
18
|
+
const theme = matchTheme(board.themes, argument);
|
|
19
|
+
if (!theme) throw new Error(`No theme matches ${argument}`);
|
|
20
|
+
const data = await fetchThemeMembers(theme.id, context.apiClient);
|
|
21
|
+
return { rows: sortMembers(data.members, DEFAULT_SORT).map((row) => ({ ...row })),
|
|
22
|
+
columns: [{ key: "symbol", header: "Ticker" }, { key: "name", header: "Name" },
|
|
23
|
+
{ key: "price", header: "Price $", align: "right", format: (value) => memberPrice(value as number | null) }, ...periods],
|
|
24
|
+
complete: !data.stale && data.members.every((row) => row.present && THEME_PERIODS.every((period) => row[period] !== null)),
|
|
25
|
+
unavailableSymbols: data.members.filter((row) => !row.present).map((row) => row.symbol),
|
|
26
|
+
metadata: { asOf: data.asOf, stale: data.stale, snapshotId: data.snapshotId, theme: data.theme } };
|
|
27
|
+
}
|
|
28
|
+
return { rows: sortThemes(board.themes, DEFAULT_SORT).map((row) => ({ name: row.name, memberCount: row.memberCount,
|
|
29
|
+
...Object.fromEntries(THEME_PERIODS.map((period) => [period, row.returns[period].value])), breadth: row.breadth.value, coverage: row.returns,
|
|
30
|
+
breadthCoverage: row.breadth, best: row.best?.symbol ?? null, worst: row.worst?.symbol ?? null })),
|
|
31
|
+
columns: [{ key: "name", header: "Theme" }, { key: "memberCount", header: "N", align: "right" },
|
|
32
|
+
...periods.map((column) => ({ ...column, format: (_value: unknown, row: Record<string, unknown>) => aggregateText((row.coverage as typeof board.themes[number]["returns"])[column.key as typeof THEME_PERIODS[number]]) })),
|
|
33
|
+
{ key: "breadth", header: "Breadth", align: "right", format: (_value, row) => aggregateText(row.breadthCoverage as typeof board.themes[number]["breadth"], true) },
|
|
34
|
+
{ key: "best", header: "Best 1D" }, { key: "worst", header: "Worst 1D" }],
|
|
35
|
+
complete: !board.stale && board.themes.every((row) => THEME_PERIODS.every((period) => row.returns[period].covered === row.memberCount)),
|
|
36
|
+
metadata: { asOf: board.asOf, stale: board.stale, snapshotId: board.snapshotId } };
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { THEME_PERIODS, type ThemeAggregate, type ThemeMember, type ThemePeriod, type ThemeSummary } from "../../../api-client/themes";
|
|
2
|
+
import type { DataTableColumn } from "../../../components";
|
|
3
|
+
import { getTableWidth } from "../../../components/ui/table-layout";
|
|
4
|
+
import { compareSortValues, type SortDirection } from "../../../utils/sort-values";
|
|
5
|
+
|
|
6
|
+
export const PERIOD_LABELS: Record<ThemePeriod, string> = { changePercent: "1D", return1WPercent: "1W", return1MPercent: "1M", return3MPercent: "3M", returnYtdPercent: "YTD" };
|
|
7
|
+
export interface ThemeSort { columnId: string; direction: SortDirection }
|
|
8
|
+
export const DEFAULT_SORT: ThemeSort = { columnId: "changePercent", direction: "desc" };
|
|
9
|
+
export function percent(value: number | null): string {
|
|
10
|
+
if (value === null || !Number.isFinite(value)) return "--";
|
|
11
|
+
const rounded = Number(value.toFixed(2));
|
|
12
|
+
return `${rounded > 0 ? "+" : ""}${rounded.toFixed(2)}%`;
|
|
13
|
+
}
|
|
14
|
+
export function aggregateText(metric: ThemeAggregate, breadth = false): string {
|
|
15
|
+
const value = breadth && metric.value !== null ? `${Math.round(metric.value)}%` : percent(metric.value);
|
|
16
|
+
return `${value}${metric.covered < metric.total ? ` ${metric.covered}/${metric.total}` : ""}`;
|
|
17
|
+
}
|
|
18
|
+
export const memberPrice = (value: number | null) => value === null ? "--" : value.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
19
|
+
export const coverageWidth = (metrics: readonly ThemeAggregate[]) => Math.max(0, ...metrics.map((metric) => metric.covered < metric.total ? `${metric.covered}/${metric.total}`.length + 1 : 0));
|
|
20
|
+
export function sortThemes(rows: readonly ThemeSummary[], sort: ThemeSort): ThemeSummary[] {
|
|
21
|
+
const value = (row: ThemeSummary) => {
|
|
22
|
+
if (sort.columnId === "name") return row.name;
|
|
23
|
+
if (sort.columnId === "memberCount") return row.memberCount;
|
|
24
|
+
if (sort.columnId === "breadth") return row.breadth.value;
|
|
25
|
+
if (sort.columnId === "best" || sort.columnId === "worst") return row[sort.columnId]?.changePercent;
|
|
26
|
+
return row.returns[sort.columnId as ThemePeriod]?.value;
|
|
27
|
+
};
|
|
28
|
+
return [...rows].sort((a, b) => compareSortValues(value(a), value(b), sort.direction) || a.name.localeCompare(b.name));
|
|
29
|
+
}
|
|
30
|
+
export function sortMembers(rows: readonly ThemeMember[], sort: ThemeSort): ThemeMember[] {
|
|
31
|
+
const value = (row: ThemeMember) => row[sort.columnId as "price" | "symbol" | "name"];
|
|
32
|
+
return [...rows].sort((a, b) => compareSortValues(value(a), value(b), sort.direction) || a.symbol.localeCompare(b.symbol));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Exact id/name, then words, then a subsequence. Server keywords keep new themes searchable. */
|
|
36
|
+
export function matchTheme(rows: readonly ThemeSummary[], input: string): ThemeSummary | null {
|
|
37
|
+
const query = input.trim().toLowerCase();
|
|
38
|
+
if (!query) return null;
|
|
39
|
+
const exact = rows.find((row) => row.id === query || row.name.toLowerCase() === query);
|
|
40
|
+
if (exact) return exact;
|
|
41
|
+
const words = query.split(/\s+/);
|
|
42
|
+
const candidates = rows.map((row) => {
|
|
43
|
+
const labels = [row.name, ...row.keywords].map((label) => label.toLowerCase());
|
|
44
|
+
const score = labels.some((label) => label === query) ? 0
|
|
45
|
+
: labels.some((label) => label.startsWith(query)) ? 1
|
|
46
|
+
: words.every((word) => labels.some((label) => label.includes(word))) ? 2
|
|
47
|
+
: labels.some((label) => { let i = 0; for (const char of label) if (char === query[i]) i++; return i === query.length; }) ? 3 : 4;
|
|
48
|
+
return { row, score };
|
|
49
|
+
}).filter(({ score }) => score < 4).sort((a, b) => a.score - b.score || a.row.name.localeCompare(b.row.name));
|
|
50
|
+
return candidates[0]?.row ?? null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const column = (id: string, label: string, width: number, align: "left" | "right" = "right"): DataTableColumn => ({ id, label, width, align });
|
|
54
|
+
/** Drop leaders/laggards first, then longer windows; keep the day's move and breadth. */
|
|
55
|
+
export function themeColumns(width: number, rows: readonly ThemeSummary[]): DataTableColumn[] {
|
|
56
|
+
const suffixWidth = (period: ThemePeriod) => coverageWidth(rows.map((row) => row.returns[period]));
|
|
57
|
+
const metricWidth = (period: ThemePeriod) => Math.max(8, ...rows.map((row) => percent(row.returns[period].value).length)) + suffixWidth(period);
|
|
58
|
+
const columns = [column("name", "Theme", 26, "left"), column("memberCount", "N", 3),
|
|
59
|
+
// The same trailing space is reserved in every cell and its header. A note
|
|
60
|
+
// occupies that space without moving the number away from its label.
|
|
61
|
+
...THEME_PERIODS.map((period) => column(period, PERIOD_LABELS[period] + " ".repeat(suffixWidth(period)), metricWidth(period))),
|
|
62
|
+
column("breadth", "Breadth" + " ".repeat(coverageWidth(rows.map((row) => row.breadth))), 7 + coverageWidth(rows.map((row) => row.breadth))),
|
|
63
|
+
column("best", "Best 1D", 15), column("worst", "Worst 1D", 15)];
|
|
64
|
+
return fitColumns(columns, width, ["worst", "best", "return3MPercent", "returnYtdPercent", "return1MPercent", "return1WPercent", "memberCount"]);
|
|
65
|
+
}
|
|
66
|
+
export function memberColumns(width: number): DataTableColumn[] {
|
|
67
|
+
return fitColumns([column("symbol", "Ticker", 7, "left"), column("name", "Name", 24, "left"), column("price", "Price $", 10),
|
|
68
|
+
...THEME_PERIODS.map((period) => column(period, PERIOD_LABELS[period], 9))], width,
|
|
69
|
+
["return3MPercent", "returnYtdPercent", "return1MPercent", "return1WPercent", "name", "price"]);
|
|
70
|
+
}
|
|
71
|
+
function fitColumns(columns: DataTableColumn[], width: number, drop: string[]): DataTableColumn[] {
|
|
72
|
+
const used = () => getTableWidth(columns);
|
|
73
|
+
for (const id of drop) {
|
|
74
|
+
if (used() <= width) break;
|
|
75
|
+
columns = columns.filter((col) => col.id !== id);
|
|
76
|
+
}
|
|
77
|
+
const name = columns.find((col) => col.id === "name") ?? columns[0]!;
|
|
78
|
+
const spare = width - used();
|
|
79
|
+
name.width = Math.max(8, name.width + Math.min(spare, Math.max(0, 36 - name.width)));
|
|
80
|
+
name.flexGrow = 1;
|
|
81
|
+
// Wide boards share room across the figures instead of separating every name
|
|
82
|
+
// from its daily move with an almost pane-wide blank name column.
|
|
83
|
+
const figures = columns.filter((col) => col.align === "right" && col.id !== "memberCount");
|
|
84
|
+
let remaining = Math.max(0, width - used());
|
|
85
|
+
for (const [index, col] of figures.entries()) {
|
|
86
|
+
const extra = Math.floor(remaining / (figures.length - index));
|
|
87
|
+
col.width += extra;
|
|
88
|
+
col.flexGrow = 1;
|
|
89
|
+
remaining -= extra;
|
|
90
|
+
}
|
|
91
|
+
return columns;
|
|
92
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { useCallback, useMemo, type ReactNode } from "react";
|
|
2
|
+
import type { ThemeMember, ThemePeriod, ThemeSummary } from "../../../api-client/themes";
|
|
3
|
+
import { DataTableStackView, DataTableView, PaneStatusBody, usePaneNoticeFooter, usePaneStatusFooter, type DataTableCell, type DataTableColumn } from "../../../components";
|
|
4
|
+
import { usePaneRefreshKey } from "../../../components/data-table/table-pane";
|
|
5
|
+
import { useAsyncResource, useAutoRefresh, usePluginPaneState, usePluginTickerActions, useUpdatedAgo } from "../../../public/react";
|
|
6
|
+
import { usePaneInstance } from "../../../state/app/context";
|
|
7
|
+
import { priceColor } from "../../../theme/colors";
|
|
8
|
+
import { useThemeColors } from "../../../theme/theme-context";
|
|
9
|
+
import { Box, Text } from "../../../ui";
|
|
10
|
+
import { nextHeaderSort } from "../../../utils/sort-values";
|
|
11
|
+
import { cachedMembers, cachedThemes, loadMembers, loadThemes } from "./client";
|
|
12
|
+
import { aggregateText, coverageWidth, DEFAULT_SORT, matchTheme, memberColumns, memberPrice, percent, sortMembers, sortThemes, themeColumns, type ThemeSort } from "./model";
|
|
13
|
+
|
|
14
|
+
function useSnapshotFooter(id: string, resource: { loading: boolean; error: string | null; data: { payload: { asOf: string; stale: boolean }; stale: boolean; refreshError: string | null } | null }, focused: boolean, enabled = true) {
|
|
15
|
+
const data = resource.data;
|
|
16
|
+
const age = useUpdatedAgo(data ? Date.parse(data.payload.asOf) : null);
|
|
17
|
+
const info = useMemo(() => age ? [{ id: "snapshot", parts: [{ text: `15m delayed · snapshot ${age}`, tone: "muted" as const }] }] : [], [age]);
|
|
18
|
+
// The server flag includes retained historical returns; it does not mean the daily board is old.
|
|
19
|
+
const snapshotStale = !!data && Date.now() - Date.parse(data.payload.asOf) > 30 * 60_000;
|
|
20
|
+
usePaneStatusFooter({ registrationId: id, enabled, loading: resource.loading && !!data,
|
|
21
|
+
error: data ? null : resource.error, stale: !!data && (data.stale || snapshotStale || !!resource.error), info });
|
|
22
|
+
usePaneNoticeFooter({ registrationId: `${id}:notices`, focused, enabled,
|
|
23
|
+
notices: data?.refreshError ? [data.refreshError] : [] });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function Members({ id, width, height, focused }: { id: string; width: number; height: number; focused: boolean }) {
|
|
27
|
+
const colors = useThemeColors();
|
|
28
|
+
const { navigateTicker } = usePluginTickerActions();
|
|
29
|
+
const loader = useCallback((force: boolean) => loadMembers(id, force), [id]);
|
|
30
|
+
const initialData = useCallback(() => cachedMembers(id), [id]);
|
|
31
|
+
const resource = useAsyncResource(loader, { initialData });
|
|
32
|
+
const data = resource.data?.payload;
|
|
33
|
+
const [sort, setSort] = usePluginPaneState<ThemeSort>("memberSort", DEFAULT_SORT);
|
|
34
|
+
const [selected, setSelected] = usePluginPaneState<string | null>("member", null);
|
|
35
|
+
const rows = useMemo(() => sortMembers(data?.members ?? [], sort), [data, sort]);
|
|
36
|
+
const columns = useMemo(() => memberColumns(width), [width]);
|
|
37
|
+
useAutoRefresh(resource.updatedAt, resource.load);
|
|
38
|
+
usePaneRefreshKey(() => void resource.reload(), { focused });
|
|
39
|
+
useSnapshotFooter("themes:members", resource, focused);
|
|
40
|
+
const renderCell = useCallback((row: ThemeMember, column: DataTableColumn): DataTableCell => {
|
|
41
|
+
if (column.id === "symbol") return { text: row.symbol, color: colors.textBright };
|
|
42
|
+
if (column.id === "name") return { text: row.name ?? "--", color: colors.text };
|
|
43
|
+
if (column.id === "price") return { text: memberPrice(row.price), value: row.price };
|
|
44
|
+
const value = row[column.id as ThemePeriod];
|
|
45
|
+
return { text: percent(value), value, color: value === null ? colors.textMuted : priceColor(value, colors) };
|
|
46
|
+
}, [colors]);
|
|
47
|
+
return <PaneStatusBody subject="theme members" loading={!data && resource.loading} error={!data ? resource.error : null}>
|
|
48
|
+
{data ? <DataTableView<ThemeMember> columns={columns} items={rows} focused={focused} rootWidth={width} rootHeight={height}
|
|
49
|
+
selection={{ kind: "id", selectedId: selected, getId: (row) => row.symbol, onChange: setSelected }}
|
|
50
|
+
getItemKey={(row) => row.symbol} onActivate={(row) => navigateTicker(row.exchange ? `${row.symbol}:${row.exchange}` : row.symbol)}
|
|
51
|
+
renderCell={renderCell} sortColumnId={sort.columnId} sortDirection={sort.direction}
|
|
52
|
+
onHeaderClick={(columnId) => setSort((current) => nextHeaderSort(current, columnId, { firstDirection: ["symbol", "name"].includes(columnId) ? "asc" : "desc" }))}
|
|
53
|
+
onSortChange={(columnId, direction) => setSort({ columnId, direction })}
|
|
54
|
+
resetScrollKey={`${id}:${sort.columnId}:${sort.direction}`} selectedTextOverridesCellColor emptyStateTitle="No members in this theme." /> : null}
|
|
55
|
+
</PaneStatusBody>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The open theme: the `THEM nuclear` argument until the user moves, then what
|
|
60
|
+
* they opened. Null means "use fallback" in pane persistence; an empty string
|
|
61
|
+
* explicitly returns to the list.
|
|
62
|
+
*/
|
|
63
|
+
export function useOpenTheme() {
|
|
64
|
+
return usePluginPaneState("openTheme", usePaneInstance()?.params?.theme ?? "");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface ThemesBoardProps {
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
70
|
+
focused: boolean;
|
|
71
|
+
/** The pane's tab strip, kept above the list and an open theme alike. */
|
|
72
|
+
tabStrip?: ReactNode;
|
|
73
|
+
tabRows?: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The Themes tab of the Sector Performance pane (`THEM`). */
|
|
77
|
+
export function ThemesBoard({ width, height, focused, tabStrip, tabRows = 0 }: ThemesBoardProps) {
|
|
78
|
+
const colors = useThemeColors();
|
|
79
|
+
const [opened, setOpened] = useOpenTheme();
|
|
80
|
+
const bodyHeight = Math.max(1, height - tabRows);
|
|
81
|
+
const [selected, setSelected] = usePluginPaneState<string | null>("theme", null);
|
|
82
|
+
const [sort, setSort] = usePluginPaneState<ThemeSort>("sort", DEFAULT_SORT);
|
|
83
|
+
const resource = useAsyncResource(loadThemes, { initialData: cachedThemes });
|
|
84
|
+
const data = resource.data?.payload;
|
|
85
|
+
const rows = useMemo(() => sortThemes(data?.themes ?? [], sort), [data, sort]);
|
|
86
|
+
const columns = useMemo(() => themeColumns(width, data?.themes ?? []), [width, data]);
|
|
87
|
+
const theme = opened && data ? matchTheme(data.themes, opened) : null;
|
|
88
|
+
useAutoRefresh(resource.updatedAt, resource.load);
|
|
89
|
+
usePaneRefreshKey(() => void resource.reload(), { focused, enabled: !opened });
|
|
90
|
+
useSnapshotFooter("themes:list", resource, focused, !opened || !data);
|
|
91
|
+
const renderCell = useCallback((row: ThemeSummary, column: DataTableColumn): DataTableCell => {
|
|
92
|
+
if (column.id === "name") return { text: row.name, color: colors.textBright };
|
|
93
|
+
if (column.id === "memberCount") return { text: String(row.memberCount), value: row.memberCount, color: colors.textMuted };
|
|
94
|
+
if (column.id === "best" || column.id === "worst") {
|
|
95
|
+
const member = row[column.id];
|
|
96
|
+
return { text: member ? `${member.symbol} ${percent(member.changePercent)}` : "--", value: member?.changePercent ?? null,
|
|
97
|
+
color: member ? priceColor(member.changePercent, colors) : colors.textMuted };
|
|
98
|
+
}
|
|
99
|
+
const breadth = column.id === "breadth";
|
|
100
|
+
const metric = breadth ? row.breadth : row.returns[column.id as ThemePeriod];
|
|
101
|
+
const suffixWidth = coverageWidth((data?.themes ?? []).map((theme) => breadth ? theme.breadth : theme.returns[column.id as ThemePeriod]));
|
|
102
|
+
const color = metric.value === null || breadth ? colors.textMuted : priceColor(metric.value, colors);
|
|
103
|
+
const valueText = breadth && metric.value !== null ? `${Math.round(metric.value)}%` : percent(metric.value);
|
|
104
|
+
const suffix = metric.covered < metric.total ? `${metric.covered}/${metric.total}` : "";
|
|
105
|
+
return { text: aggregateText(metric, breadth), value: metric.value,
|
|
106
|
+
color, content: suffixWidth ? <Box flexDirection="row" width={column.width} justifyContent="flex-end">
|
|
107
|
+
<Text fg={color}>{valueText}</Text><Text fg={colors.textMuted}>{suffix.padStart(suffixWidth)}</Text>
|
|
108
|
+
</Box> : undefined };
|
|
109
|
+
}, [colors, data]);
|
|
110
|
+
return <Box width={width} height={height} flexDirection="column">
|
|
111
|
+
{tabStrip}
|
|
112
|
+
<PaneStatusBody subject="thematic baskets" loading={!data && resource.loading} error={!data ? resource.error : null}>
|
|
113
|
+
{data ? <DataTableStackView<ThemeSummary> columns={columns} items={rows} rootWidth={width} rootHeight={bodyHeight} focused={focused}
|
|
114
|
+
selection={{ kind: "id", selectedId: selected, getId: (row) => row.id, onChange: setSelected }}
|
|
115
|
+
getItemKey={(row) => row.id} onActivate={(row) => setOpened(row.id)}
|
|
116
|
+
detailOpen={!!opened} onBack={() => setOpened("")} detailTitle={theme?.name ?? opened}
|
|
117
|
+
detailContent={theme ? <Members key={theme.id} id={theme.id} width={width} height={Math.max(1, bodyHeight - 1)} focused={focused} />
|
|
118
|
+
: <PaneStatusBody subject="theme" error="No matching theme. Return to the list to choose a basket." />}
|
|
119
|
+
renderCell={renderCell} sortColumnId={sort.columnId} sortDirection={sort.direction}
|
|
120
|
+
onHeaderClick={(columnId) => setSort((current) => nextHeaderSort(current, columnId, { firstDirection: columnId === "name" ? "asc" : "desc" }))}
|
|
121
|
+
onSortChange={(columnId, direction) => setSort({ columnId, direction })}
|
|
122
|
+
resetScrollKey={`${sort.columnId}:${sort.direction}`} selectedTextOverridesCellColor emptyStateTitle="No themes available." /> : null}
|
|
123
|
+
</PaneStatusBody>
|
|
124
|
+
</Box>;
|
|
125
|
+
}
|
|
@@ -230,13 +230,7 @@ function ThirteenFBrowserPane({ focused, width, height, onDetailChange }: PanePr
|
|
|
230
230
|
focusSearch();
|
|
231
231
|
return true;
|
|
232
232
|
}
|
|
233
|
-
|
|
234
|
-
event.preventDefault?.();
|
|
235
|
-
event.stopPropagation?.();
|
|
236
|
-
refresh();
|
|
237
|
-
return true;
|
|
238
|
-
}
|
|
239
|
-
return false;
|
|
233
|
+
return handleRefreshKey(event, refresh, { stopPropagation: true });
|
|
240
234
|
}, [focusSearch, refresh]);
|
|
241
235
|
|
|
242
236
|
const handleTickerRootKeyDown = useCallback((
|
|
@@ -567,7 +561,7 @@ export function FundDetailView({
|
|
|
567
561
|
}}
|
|
568
562
|
onActivate={(row) => openFilingInPane(row)}
|
|
569
563
|
onDetailKeyDown={(event) => {
|
|
570
|
-
if (event
|
|
564
|
+
if (!isPlainKey(event, "o") || !openFiling?.url) return false;
|
|
571
565
|
event.preventDefault?.();
|
|
572
566
|
event.stopPropagation?.();
|
|
573
567
|
void rendererHost.openExternal(openFiling.url);
|
|
@@ -670,13 +664,10 @@ function FilingDetailView({
|
|
|
670
664
|
pinTicker(row.ticker, { floating: true, paneType: TICKER_RESEARCH_PANE_ID });
|
|
671
665
|
}, [pinTicker]);
|
|
672
666
|
|
|
673
|
-
const handlePositionKeyDown = useCallback(
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
refresh();
|
|
678
|
-
return true;
|
|
679
|
-
}, [refresh]);
|
|
667
|
+
const handlePositionKeyDown = useCallback(
|
|
668
|
+
(event: DataTableKeyEvent) => handleRefreshKey(event, refresh, { stopPropagation: true }),
|
|
669
|
+
[refresh],
|
|
670
|
+
);
|
|
680
671
|
|
|
681
672
|
usePaneNoticeFooter({ registrationId: "thirteenf-filing-notices", notices: [...new Set([...sourceWarnings, ...warnings])], focused });
|
|
682
673
|
|
|
@@ -16,6 +16,7 @@ import type { PaneProps } from "../../../../types/plugin";
|
|
|
16
16
|
import type { PricePoint } from "../../../../types/financials";
|
|
17
17
|
import { colors, priceColor } from "../../../../theme/colors";
|
|
18
18
|
import { formatCompact, formatPercent } from "../../../../utils/format";
|
|
19
|
+
import { isPlainKeyboardEvent } from "../../../../utils/keyboard";
|
|
19
20
|
import { publicTickerKey } from "../../../../utils/exchanges";
|
|
20
21
|
import { formatPriceObservation, quoteFormatOptions } from "../../../../market-data/market/format";
|
|
21
22
|
import { cleanFloat32Price, historyPriceDecimals } from "../../../../cli/history-rows";
|
|
@@ -26,7 +27,7 @@ import {
|
|
|
26
27
|
usePluginPaneState,
|
|
27
28
|
} from "../../../runtime";
|
|
28
29
|
import { usePaneTicker } from "../../../../state/app/context";
|
|
29
|
-
import { useClampSelectedIndex } from "../../../../components/data-table/table-pane";
|
|
30
|
+
import { handleRefreshKey, useClampSelectedIndex } from "../../../../components/data-table/table-pane";
|
|
30
31
|
import { useBoundTicker, useTickerRequest } from "../../shared/ticker-request";
|
|
31
32
|
|
|
32
33
|
type HistoryColumnId = "date" | "open" | "high" | "low" | "close" | "change" | "changePercent" | "volume";
|
|
@@ -193,11 +194,9 @@ export function HistoricalPricesPane({ focused, width, height }: PaneProps) {
|
|
|
193
194
|
useClampSelectedIndex(rows.length, selectedIdx, setSelectedIdx);
|
|
194
195
|
|
|
195
196
|
const handleKeyDown = useCallback((event: DataTableKeyEvent) => {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return true;
|
|
200
|
-
}
|
|
197
|
+
// A modified key is an app chord (Cmd/Ctrl+Shift+R resizes the pane).
|
|
198
|
+
if (!isPlainKeyboardEvent(event)) return false;
|
|
199
|
+
if (handleRefreshKey(event, reload)) return true;
|
|
201
200
|
if (event.name === "t") {
|
|
202
201
|
event.preventDefault?.();
|
|
203
202
|
cycleRange();
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { subtractTimeRange } from "../../../../time-series/date-window";
|
|
2
|
+
import type { TimeRange } from "../../../../time-series/range";
|
|
3
|
+
import {
|
|
4
|
+
CHART_RESOLUTION_STEP_MS,
|
|
5
|
+
DEFAULT_CHART_RESOLUTION_SUPPORT,
|
|
6
|
+
getSupportedChartResolutionsForViewport,
|
|
7
|
+
isIntradayResolution,
|
|
8
|
+
type ChartResolutionSupport,
|
|
9
|
+
type ManualChartResolution,
|
|
10
|
+
} from "../../../../time-series/resolution";
|
|
11
|
+
import type { PricePoint } from "../../../../types/financials";
|
|
12
|
+
import { pricePointValues } from "../../../../utils/price-history-integrity";
|
|
13
|
+
|
|
14
|
+
export type ReturnRange = "6H" | "1D" | "5D" | TimeRange;
|
|
15
|
+
|
|
16
|
+
export const RETURN_RANGES: readonly ReturnRange[] = ["6H", "1D", "5D", "1W", "1M", "3M", "6M", "1Y", "5Y", "ALL"];
|
|
17
|
+
|
|
18
|
+
const HOUR_MS = 60 * 60_000;
|
|
19
|
+
const DAY_MS = 24 * HOUR_MS;
|
|
20
|
+
|
|
21
|
+
/** The chart range whose interval limits cover this window. */
|
|
22
|
+
export function returnSupportRange(range: ReturnRange): TimeRange {
|
|
23
|
+
if (range === "6H" || range === "1D") return "1D";
|
|
24
|
+
if (range === "5D") return "1W";
|
|
25
|
+
return range;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Where a window of `range` ending at `end` starts, by the UTC calendar charts use. */
|
|
29
|
+
export function returnWindowStart(range: ReturnRange, end: number): number {
|
|
30
|
+
if (range === "6H") return end - 6 * HOUR_MS;
|
|
31
|
+
if (range === "5D") return end - 5 * DAY_MS;
|
|
32
|
+
return subtractTimeRange(new Date(end), range).getTime();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Where the rows start, exclusive: the window's start for intraday bars. A
|
|
37
|
+
* daily or longer bar is stamped with its date at midnight UTC, so the window
|
|
38
|
+
* takes every bar from its start date on.
|
|
39
|
+
*/
|
|
40
|
+
export function returnVisibleFrom(range: ReturnRange, resolution: ManualChartResolution, end: number): number {
|
|
41
|
+
const start = returnWindowStart(range, end);
|
|
42
|
+
if (isIntradayResolution(resolution)) return start;
|
|
43
|
+
const day = new Date(start);
|
|
44
|
+
day.setUTCHours(0, 0, 0, 0);
|
|
45
|
+
return day.getTime() - 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A closed market leaves these windows without a bar when they end now, so
|
|
50
|
+
* they end at the latest bar: on a weekend 1D is the last session.
|
|
51
|
+
*/
|
|
52
|
+
export function endsAtLatestBar(range: ReturnRange): boolean {
|
|
53
|
+
return range === "6H" || range === "1D";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const WINDOW_DAYS: Record<ReturnRange, number> = {
|
|
57
|
+
"6H": 0.25, "1D": 1, "5D": 5, "1W": 7, "1M": 31, "3M": 92, "6M": 183, "1Y": 366, "5Y": 1827, ALL: Number.POSITIVE_INFINITY,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/** Covers a weekend and a holiday, so the bar before the window is loaded. */
|
|
61
|
+
function lookbackDays(resolution: ManualChartResolution): number {
|
|
62
|
+
if (isIntradayResolution(resolution)) return 4;
|
|
63
|
+
if (resolution === "1d") return 5;
|
|
64
|
+
if (resolution === "1wk") return 21;
|
|
65
|
+
return 62;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* How far before the window the request reaches. The bar just before the
|
|
70
|
+
* window is the base of every return, so the request covers a weekend or
|
|
71
|
+
* holiday before it, when that stays inside the history the source keeps at
|
|
72
|
+
* this interval; otherwise it reaches back one interval.
|
|
73
|
+
*/
|
|
74
|
+
export function returnLookbackMs(
|
|
75
|
+
range: ReturnRange,
|
|
76
|
+
resolution: ManualChartResolution,
|
|
77
|
+
support: readonly ChartResolutionSupport[],
|
|
78
|
+
): number {
|
|
79
|
+
const maxRange = (support.length > 0 ? support : DEFAULT_CHART_RESOLUTION_SUPPORT)
|
|
80
|
+
.find((entry) => entry.resolution === resolution)?.maxRange;
|
|
81
|
+
const days = lookbackDays(resolution);
|
|
82
|
+
if (maxRange && WINDOW_DAYS[range] + days < WINDOW_DAYS[maxRange]) return days * DAY_MS;
|
|
83
|
+
return resolution === "1mo" ? 31 * DAY_MS : CHART_RESOLUTION_STEP_MS[resolution];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function availableReturnResolutions(
|
|
87
|
+
range: ReturnRange,
|
|
88
|
+
support: readonly ChartResolutionSupport[],
|
|
89
|
+
): ManualChartResolution[] {
|
|
90
|
+
return getSupportedChartResolutionsForViewport(
|
|
91
|
+
returnSupportRange(range),
|
|
92
|
+
support.length > 0 ? support : DEFAULT_CHART_RESOLUTION_SUPPORT,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The chosen interval when the range allows it, else the nearest coarser one the source serves. */
|
|
97
|
+
export function effectiveReturnResolution(
|
|
98
|
+
range: ReturnRange,
|
|
99
|
+
resolution: ManualChartResolution,
|
|
100
|
+
support: readonly ChartResolutionSupport[],
|
|
101
|
+
): ManualChartResolution {
|
|
102
|
+
const available = availableReturnResolutions(range, support);
|
|
103
|
+
if (available.includes(resolution)) return resolution;
|
|
104
|
+
const step = CHART_RESOLUTION_STEP_MS[resolution];
|
|
105
|
+
return available.find((candidate) => CHART_RESOLUTION_STEP_MS[candidate] >= step) ?? available.at(-1) ?? "1d";
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface ReturnRow {
|
|
109
|
+
key: string;
|
|
110
|
+
timestamp: number;
|
|
111
|
+
/** The bar's close; null when its prices contradict each other. */
|
|
112
|
+
price: number | null;
|
|
113
|
+
intervalChange: number | null;
|
|
114
|
+
intervalPercent: number | null;
|
|
115
|
+
cumulativeChange: number | null;
|
|
116
|
+
cumulativePercent: number | null;
|
|
117
|
+
/** The bar's OHLC contradict each other, so it takes no part in any return. */
|
|
118
|
+
inconsistent: boolean;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface Bar {
|
|
122
|
+
timestamp: number;
|
|
123
|
+
close: number | null;
|
|
124
|
+
inconsistent: boolean;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function pointTime(point: PricePoint): number | null {
|
|
128
|
+
const value = point.date instanceof Date ? point.date.getTime() : new Date(point.date).getTime();
|
|
129
|
+
return Number.isFinite(value) ? value : null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Chronological bars, one per timestamp (a repeated timestamp keeps its last value). */
|
|
133
|
+
function toBars(points: readonly PricePoint[]): Bar[] {
|
|
134
|
+
const byTime = new Map<number, Bar>();
|
|
135
|
+
for (const point of points) {
|
|
136
|
+
const timestamp = pointTime(point);
|
|
137
|
+
if (timestamp === null) continue;
|
|
138
|
+
const values = pricePointValues(point);
|
|
139
|
+
byTime.set(timestamp, { timestamp, close: values.close, inconsistent: !!values.integrity });
|
|
140
|
+
}
|
|
141
|
+
return [...byTime.values()].sort((left, right) => left.timestamp - right.timestamp);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function change(price: number | null, base: number | null): { change: number | null; percent: number | null } {
|
|
145
|
+
if (price === null || base === null) return { change: null, percent: null };
|
|
146
|
+
const value = price - base;
|
|
147
|
+
return { change: value, percent: base === 0 ? null : value / base };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Interval and cumulative price returns of the bars after `visibleFrom`
|
|
152
|
+
* through `visibleTo`, newest first.
|
|
153
|
+
*
|
|
154
|
+
* The bar just before the window, when it was loaded, is the base: the first
|
|
155
|
+
* row's interval runs from it and every cumulative return is measured against
|
|
156
|
+
* it, so compounding the interval returns gives the cumulative one. Without
|
|
157
|
+
* it (or when its prices are unusable), the first priced bar in the window is
|
|
158
|
+
* the base and the window's first bar has no interval return. A
|
|
159
|
+
* bar with contradictory prices has no price, so the returns that need it are
|
|
160
|
+
* gaps rather than a longer move presented as one interval.
|
|
161
|
+
*/
|
|
162
|
+
export function buildReturnRows(
|
|
163
|
+
points: readonly PricePoint[],
|
|
164
|
+
visibleFrom = Number.NEGATIVE_INFINITY,
|
|
165
|
+
visibleTo = Number.POSITIVE_INFINITY,
|
|
166
|
+
): ReturnRow[] {
|
|
167
|
+
const bars = toBars(points);
|
|
168
|
+
const first = bars.findIndex((bar) => bar.timestamp > visibleFrom);
|
|
169
|
+
if (first < 0) return [];
|
|
170
|
+
const prior = first > 0 ? bars[first - 1]!.close : null;
|
|
171
|
+
const base = prior ?? bars.slice(first).find((bar) => bar.close !== null)?.close ?? null;
|
|
172
|
+
const rows: ReturnRow[] = [];
|
|
173
|
+
for (let index = first; index < bars.length; index += 1) {
|
|
174
|
+
const bar = bars[index]!;
|
|
175
|
+
if (bar.timestamp > visibleTo) break;
|
|
176
|
+
const previous = index > 0 ? bars[index - 1]!.close : null;
|
|
177
|
+
const interval = change(bar.close, previous);
|
|
178
|
+
const cumulative = change(bar.close, base);
|
|
179
|
+
rows.push({
|
|
180
|
+
key: String(bar.timestamp),
|
|
181
|
+
timestamp: bar.timestamp,
|
|
182
|
+
price: bar.close,
|
|
183
|
+
intervalChange: interval.change,
|
|
184
|
+
intervalPercent: interval.percent,
|
|
185
|
+
cumulativeChange: cumulative.change,
|
|
186
|
+
cumulativePercent: cumulative.percent,
|
|
187
|
+
inconsistent: bar.inconsistent,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
return rows.reverse();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** The latest bar time in a loaded history, or null when it has none. */
|
|
194
|
+
export function latestBarTime(points: readonly PricePoint[]): number | null {
|
|
195
|
+
let latest: number | null = null;
|
|
196
|
+
for (const point of points) {
|
|
197
|
+
const timestamp = pointTime(point);
|
|
198
|
+
if (timestamp !== null && (latest === null || timestamp > latest)) latest = timestamp;
|
|
199
|
+
}
|
|
200
|
+
return latest;
|
|
201
|
+
}
|