gloomberb 0.10.4 → 0.11.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/LICENSE +1 -1
- package/README.md +30 -3
- package/README.zh-CN.md +1 -1
- package/package.json +5 -5
- package/src/api-client/auth.ts +34 -0
- package/src/api-client/data.ts +25 -0
- package/src/api-client/index.test.ts +81 -0
- package/src/api-client/index.ts +37 -0
- package/src/api-client/request.test.ts +30 -0
- package/src/api-client/request.ts +44 -20
- package/src/api-client/socket-health.test.ts +79 -0
- package/src/api-client/socket.ts +108 -5
- package/src/api-client/types.ts +139 -0
- package/src/app/global-shortcuts.test.tsx +144 -9
- package/src/app/global-shortcuts.ts +33 -11
- package/src/app/runtime/broker-import.ts +39 -5
- package/src/app/runtime/startup.ts +7 -1
- package/src/app/runtime/update.ts +26 -1
- package/src/app.tsx +36 -19
- package/src/brokers/broker-ticker-sync.ts +3 -8
- package/src/brokers/sync-broker-instance.test.ts +59 -0
- package/src/brokers/sync-broker-instance.ts +37 -13
- package/src/capabilities/chart-series.ts +318 -0
- package/src/capabilities/factories.ts +46 -0
- package/src/capabilities/index.ts +1 -0
- package/src/capabilities/registry.test.ts +135 -0
- package/src/capabilities/registry.ts +31 -4
- package/src/capabilities/types.ts +52 -0
- package/src/cli/commands/overview.ts +2 -2
- package/src/cli/desktop-pane-shot.ts +2 -0
- package/src/cli/entry.ts +11 -1
- package/src/cli/native-smoke.ts +5 -0
- package/src/cli/pane-functions/catalog.ts +4 -0
- package/src/cli/pane-functions/data.ts +6 -1
- package/src/cli/pane-functions/discovery.ts +76 -10
- package/src/cli/pane-functions/report.test.ts +76 -0
- package/src/cli/pane-functions/report.ts +7 -1
- package/src/cli/pane-functions/resolver.ts +4 -1
- package/src/cli/pane-functions/screenshot.test.ts +56 -3
- package/src/cli/pane-functions/screenshot.ts +68 -5
- package/src/components/chart/composite/composite-chart.test.tsx +54 -0
- package/src/components/chart/composite/composite-chart.tsx +92 -15
- package/src/components/chart/composite/downsample.test.ts +136 -0
- package/src/components/chart/composite/downsample.ts +208 -0
- package/src/components/chart/composite/panel-series.test.ts +66 -0
- package/src/components/chart/composite/panel-series.ts +101 -0
- package/src/components/chart/multi-line/renderer.ts +1 -0
- package/src/components/chart/native/kitty/index.test.ts +25 -3
- package/src/components/chart/native/kitty/support.ts +37 -3
- package/src/components/chart/native/use-chart-text-fallback.ts +19 -0
- package/src/components/chart/static/chart/surface.tsx +43 -12
- package/src/components/chart/static/multi-line-chart-surface.tsx +41 -5
- package/src/components/command-bar/commands/direct/index.ts +18 -0
- package/src/components/command-bar/commands/registry.ts +14 -0
- package/src/components/command-bar/routes/root/article-results.test.ts +83 -0
- package/src/components/command-bar/routes/root/article-results.ts +55 -0
- package/src/components/command-bar/routes/root/command-items.ts +3 -0
- package/src/components/command-bar/routes/root/provider-search.ts +7 -3
- package/src/components/command-bar/routes/root/results.ts +38 -11
- package/src/components/command-bar/routes/root/runtime.ts +6 -2
- package/src/components/command-bar/routes/ticker-search/actions.ts +1 -1
- package/src/components/command-bar/routes/ticker-search/results.test.ts +34 -0
- package/src/components/command-bar/routes/ticker-search/results.ts +4 -6
- package/src/components/command-bar/routes/ticker-search/route.ts +2 -2
- package/src/components/command-bar/routing/list-state.ts +2 -1
- package/src/components/command-bar/surface/assist.test.tsx +13 -6
- package/src/components/command-bar/surface/index.test.tsx +65 -0
- package/src/components/command-bar/surface/index.tsx +35 -0
- package/src/components/command-bar/view-model.test.ts +43 -0
- package/src/components/command-bar/view-model.ts +41 -4
- package/src/components/command-bar/workflow/collection-actions.test.ts +94 -0
- package/src/components/command-bar/workflow/collection-actions.ts +14 -3
- package/src/components/command-bar/workflow/ops.test.ts +136 -0
- package/src/components/command-bar/workflow/ops.ts +71 -1
- package/src/components/index.ts +1 -1
- package/src/components/layout/header.test.tsx +35 -0
- package/src/components/layout/header.tsx +101 -9
- package/src/components/layout/pane/cycle-order.test.ts +0 -1
- package/src/components/layout/pane/footer/index.test.tsx +19 -19
- package/src/components/layout/pane/header.tsx +2 -13
- package/src/components/layout/shell/index.tsx +3 -0
- package/src/components/layout/status-bar.test.tsx +36 -1
- package/src/components/layout/status-bar.tsx +48 -2
- package/src/components/onboarding/account-step/chooser-panel.tsx +27 -50
- package/src/components/onboarding/account-step/form-panel.tsx +85 -29
- package/src/components/onboarding/account-step/index.tsx +10 -1
- package/src/components/onboarding/account-step/model.ts +3 -3
- package/src/components/onboarding/account-step/qr-panel.tsx +68 -0
- package/src/components/onboarding/account-step/signed-in-panel.tsx +4 -7
- package/src/components/onboarding/onboarding-frame.tsx +517 -0
- package/src/components/onboarding/onboarding-steps.tsx +0 -264
- package/src/components/onboarding/onboarding-wizard.test.tsx +626 -200
- package/src/components/onboarding/onboarding-wizard.tsx +848 -266
- package/src/components/onboarding/portfolio-step/broker-fields-panel.tsx +81 -51
- package/src/components/onboarding/portfolio-step/broker-setup-panel.tsx +14 -20
- package/src/components/onboarding/portfolio-step/broker-sync-panel.tsx +8 -11
- package/src/components/onboarding/portfolio-step/choose-panel.tsx +18 -22
- package/src/components/onboarding/portfolio-step/index.tsx +3 -0
- package/src/components/onboarding/portfolio-step/types.ts +3 -0
- package/src/components/onboarding/wizard-account.ts +38 -3
- package/src/components/onboarding/wizard-broker-sync.ts +45 -67
- package/src/components/onboarding/wizard-model.ts +18 -2
- package/src/components/ui/data-table/opentui/index.tsx +29 -9
- package/src/components/ui/data-table/types.ts +2 -0
- package/src/components/ui/external-link.tsx +4 -2
- package/src/components/ui/loading.tsx +1 -1
- package/src/components/ui/status.tsx +76 -4
- package/src/components/ui/table-layout.test.ts +24 -0
- package/src/components/ui/table-layout.ts +90 -23
- package/src/components/ui/tabs.tsx +86 -4
- package/src/core/app-services.ts +14 -3
- package/src/core/connection-health.test.ts +143 -0
- package/src/core/connection-health.ts +295 -0
- package/src/core/state/app/layout-reducer.ts +34 -0
- package/src/core/state/app/layout.ts +21 -0
- package/src/core/state/app/state.ts +10 -0
- package/src/core/state/app/types.ts +7 -1
- package/src/data/config/chart-settings.ts +11 -2
- package/src/data/config/store/index.test.ts +83 -9
- package/src/data/config/store/migrations.ts +16 -0
- package/src/data/config/store/normalize.ts +59 -1
- package/src/data/fred-series.ts +8 -2
- package/src/i18n/es.ts +126 -0
- package/src/i18n/ja.ts +126 -0
- package/src/i18n/ko.ts +126 -0
- package/src/i18n/zh-cn.ts +126 -0
- package/src/i18n/zh-tw.ts +126 -0
- package/src/market-data/coordinator/chart.ts +3 -2
- package/src/market-data/hooks.tsx +3 -2
- package/src/market-data/market/status.test.ts +12 -0
- package/src/market-data/market/status.ts +34 -17
- package/src/news/aggregator.test.ts +39 -0
- package/src/news/aggregator.ts +78 -22
- package/src/news/hooks.ts +4 -0
- package/src/notifications/app-notifier.test.ts +28 -6
- package/src/notifications/app-notifier.ts +24 -5
- package/src/plugins/broker-sync/broker-sync.test.ts +130 -0
- package/src/plugins/broker-sync/native-loader.ts +10 -0
- package/src/plugins/broker-sync/normalize.ts +271 -0
- package/src/plugins/broker-sync/public.ts +122 -0
- package/src/plugins/broker-sync/robinhood-native.ts +367 -0
- package/src/plugins/broker-sync/robinhood.ts +114 -0
- package/src/plugins/broker-sync/simplefin-native.ts +201 -0
- package/src/plugins/broker-sync/simplefin.ts +70 -0
- package/src/plugins/builtin/account-management/footer.ts +8 -19
- package/src/plugins/builtin/account-management/pane.tsx +13 -8
- package/src/plugins/builtin/ai/pi/host.ts +6 -5
- package/src/plugins/builtin/ai/providers.ts +1 -1
- package/src/plugins/builtin/ai/screener/footer.ts +0 -7
- package/src/plugins/builtin/ai/screener/pane.test.tsx +2 -1
- package/src/plugins/builtin/ai/screener/pane.tsx +3 -1
- package/src/plugins/builtin/ai/screener/results-view.tsx +8 -0
- package/src/plugins/builtin/ai/screener/runner.ts +7 -3
- package/src/plugins/builtin/ai/workspace/pane.tsx +13 -2
- package/src/plugins/builtin/alerts/alert-engine.ts +13 -0
- package/src/plugins/builtin/alerts/constants.ts +2 -1
- package/src/plugins/builtin/alerts/index.tsx +67 -36
- package/src/plugins/builtin/alerts/pane.tsx +17 -65
- package/src/plugins/builtin/analytics/index.tsx +24 -11
- package/src/plugins/builtin/analytics/pane-model.ts +48 -14
- package/src/plugins/builtin/analytics/portfolio-selection.ts +19 -0
- package/src/plugins/builtin/analytics/view.tsx +5 -3
- package/src/plugins/builtin/broker-manager/detail.tsx +7 -2
- package/src/plugins/builtin/broker-manager/footer.ts +4 -9
- package/src/plugins/builtin/broker-manager/index.tsx +1 -6
- package/src/plugins/builtin/buildout/detail/ui.tsx +15 -4
- package/src/plugins/builtin/buildout/pane/header.tsx +1 -0
- package/src/plugins/builtin/changelog/index.tsx +60 -45
- package/src/plugins/builtin/chart-composer/catalog-inventory.test.ts +97 -0
- package/src/plugins/builtin/chart-composer/catalog-inventory.ts +366 -0
- package/src/plugins/builtin/chart-composer/chart-spec.ts +21 -1
- package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +307 -0
- package/src/plugins/builtin/chart-composer/editor/controller.ts +1 -1
- package/src/plugins/builtin/chart-composer/index.tsx +45 -5
- package/src/plugins/builtin/chart-composer/pane.tsx +7 -88
- package/src/plugins/builtin/chart-composer/presets.test.ts +48 -0
- package/src/plugins/builtin/chart-composer/presets.ts +69 -3
- package/src/plugins/builtin/chart-composer/quick-add.tsx +8 -5
- package/src/plugins/builtin/chart-composer/semantic.ts +18 -14
- package/src/plugins/builtin/chart-composer/series-catalog.test.ts +39 -0
- package/src/plugins/builtin/chart-composer/series-catalog.ts +104 -3
- package/src/plugins/builtin/chart-composer/shortcuts.test.ts +10 -10
- package/src/plugins/builtin/chart-composer/shortcuts.ts +4 -12
- package/src/plugins/builtin/chart-composer/use-series-catalog.ts +230 -23
- package/src/plugins/builtin/chat/chat.test.tsx +22 -0
- package/src/plugins/builtin/chat/content/composer.tsx +6 -4
- package/src/plugins/builtin/chat/content/index.tsx +7 -0
- package/src/plugins/builtin/chat/content/snapshot.ts +9 -2
- package/src/plugins/builtin/chat/content/transcript.tsx +10 -0
- package/src/plugins/builtin/chat/controller/channel-actions.ts +11 -1
- package/src/plugins/builtin/chat/controller/channels.ts +13 -3
- package/src/plugins/builtin/chat/controller/index.ts +61 -7
- package/src/plugins/builtin/chat/controller/lifecycle.ts +3 -0
- package/src/plugins/builtin/chat/controller/message-loading.ts +5 -1
- package/src/plugins/builtin/chat/controller/messages.ts +3 -1
- package/src/plugins/builtin/chat/controller/notifications.ts +32 -11
- package/src/plugins/builtin/chat/controller/state.ts +7 -0
- package/src/plugins/builtin/chat/controller/view.ts +1 -0
- package/src/plugins/builtin/chat/controller.test.ts +117 -28
- package/src/plugins/builtin/cloud/auth-commands.ts +18 -0
- package/src/plugins/builtin/cloud/device-signin-dialog.tsx +243 -0
- package/src/plugins/builtin/cloud/device-signin.test.ts +217 -0
- package/src/plugins/builtin/cloud/device-signin.ts +240 -0
- package/src/plugins/builtin/cloud/plugin.tsx +7 -1
- package/src/plugins/builtin/cloud-tweets/table.tsx +57 -10
- package/src/plugins/builtin/composite-plugins.ts +39 -5
- package/src/plugins/builtin/congress-trades/detail.tsx +2 -4
- package/src/plugins/builtin/congress-trades/footer.ts +7 -16
- package/src/plugins/builtin/congress-trades/pane.tsx +12 -20
- package/src/plugins/builtin/connections/index.ts +53 -0
- package/src/plugins/builtin/connections/pane.test.tsx +79 -0
- package/src/plugins/builtin/connections/pane.tsx +258 -0
- package/src/plugins/builtin/correlation/index.test.tsx +2 -1
- package/src/plugins/builtin/correlation/index.tsx +58 -19
- package/src/plugins/builtin/correlation/matrix/model.ts +18 -7
- package/src/plugins/builtin/correlation/relationship/pane.tsx +43 -19
- package/src/plugins/builtin/correlation/settings.ts +1 -1
- package/src/plugins/builtin/credit-conditions/client.test.ts +80 -0
- package/src/plugins/builtin/credit-conditions/client.ts +105 -0
- package/src/plugins/builtin/credit-conditions/index.test.tsx +111 -0
- package/src/plugins/builtin/credit-conditions/index.tsx +227 -0
- package/src/plugins/builtin/credit-conditions/model.test.ts +43 -0
- package/src/plugins/builtin/credit-conditions/model.ts +64 -0
- package/src/plugins/builtin/debug/index.tsx +11 -6
- package/src/plugins/builtin/dividend-yield/client.test.ts +58 -0
- package/src/plugins/builtin/dividend-yield/client.ts +252 -0
- package/src/plugins/builtin/dividend-yield/index.tsx +61 -0
- package/src/plugins/builtin/dividend-yield/model.ts +83 -0
- package/src/plugins/builtin/dividend-yield/pane.tsx +305 -0
- package/src/plugins/builtin/dividend-yield/types.ts +22 -0
- package/src/plugins/builtin/earnings/data/cache.test.ts +10 -7
- package/src/plugins/builtin/earnings/data/cache.ts +23 -9
- package/src/plugins/builtin/earnings/index.tsx +57 -6
- package/src/plugins/builtin/econ/calendar-model.test.ts +37 -3
- package/src/plugins/builtin/econ/calendar-model.ts +32 -26
- package/src/plugins/builtin/econ/fred-cache.test.ts +8 -1
- package/src/plugins/builtin/econ/fred-series-map.ts +18 -0
- package/src/plugins/builtin/econ/index.test.tsx +105 -0
- package/src/plugins/builtin/econ/index.tsx +95 -52
- package/src/plugins/builtin/fear-greed/cache.test.ts +18 -3
- package/src/plugins/builtin/fear-greed/cache.ts +18 -6
- package/src/plugins/builtin/fear-greed/charts.tsx +9 -2
- package/src/plugins/builtin/fear-greed/format.ts +0 -9
- package/src/plugins/builtin/fear-greed/pane.tsx +21 -21
- package/src/plugins/builtin/futures/contracts.ts +100 -0
- package/src/plugins/builtin/futures/index.tsx +298 -0
- package/src/plugins/builtin/futures/model.test.ts +129 -0
- package/src/plugins/builtin/futures/model.ts +136 -0
- package/src/plugins/builtin/futures/pane.test.tsx +239 -0
- package/src/plugins/builtin/futures/table.test.ts +155 -0
- package/src/plugins/builtin/futures/table.tsx +241 -0
- package/src/plugins/builtin/fx-matrix/index.tsx +160 -134
- package/src/plugins/builtin/fx-matrix/pairs.ts +12 -1
- package/src/plugins/builtin/fx-matrix/pane.test.tsx +109 -0
- package/src/plugins/builtin/help/components.tsx +1 -30
- package/src/plugins/builtin/help/index.tsx +5 -25
- package/src/plugins/builtin/holders/pane.tsx +17 -12
- package/src/plugins/builtin/holders/treemap.tsx +4 -2
- package/src/plugins/builtin/insider/index.tsx +20 -10
- package/src/plugins/builtin/ipo-calendar/cache.ts +101 -0
- package/src/plugins/builtin/ipo-calendar/client.test.ts +31 -0
- package/src/plugins/builtin/ipo-calendar/client.ts +296 -0
- package/src/plugins/builtin/ipo-calendar/index.tsx +65 -0
- package/src/plugins/builtin/ipo-calendar/model.ts +145 -0
- package/src/plugins/builtin/ipo-calendar/pane.tsx +328 -0
- package/src/plugins/builtin/ipo-calendar/types.ts +19 -0
- package/src/plugins/builtin/kelly-sizer/index.test.tsx +3 -3
- package/src/plugins/builtin/kelly-sizer/model.ts +8 -1
- package/src/plugins/builtin/kelly-sizer/pane.tsx +33 -15
- package/src/plugins/builtin/kelly-sizer/view.tsx +12 -5
- package/src/plugins/builtin/market-halts/client.ts +114 -0
- package/src/plugins/builtin/market-halts/index.tsx +29 -0
- package/src/plugins/builtin/market-halts/model.test.ts +187 -0
- package/src/plugins/builtin/market-halts/model.ts +291 -0
- package/src/plugins/builtin/market-halts/pane.tsx +256 -0
- package/src/plugins/builtin/market-heatmap/data.test.ts +1 -0
- package/src/plugins/builtin/market-heatmap/data.ts +12 -3
- package/src/plugins/builtin/market-heatmap/index.tsx +131 -46
- package/src/plugins/builtin/market-movers/index.tsx +145 -63
- package/src/plugins/builtin/market-movers/model.ts +19 -3
- package/src/plugins/builtin/market-movers/screener.test.ts +108 -0
- package/src/plugins/builtin/market-movers/screener.ts +168 -10
- package/src/plugins/builtin/news/index.tsx +78 -99
- package/src/plugins/builtin/news/wire/article-search.test.ts +72 -0
- package/src/plugins/builtin/news/wire/article-search.ts +140 -0
- package/src/plugins/builtin/news/wire/breaking/pane.tsx +18 -8
- package/src/plugins/builtin/news/wire/categories.ts +35 -0
- package/src/plugins/builtin/news/wire/default-feeds.ts +47 -1
- package/src/plugins/builtin/news/wire/feed-config.test.ts +10 -5
- package/src/plugins/builtin/news/wire/index.tsx +41 -4
- package/src/plugins/builtin/news/wire/industry-pane.tsx +38 -19
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +10 -5
- package/src/plugins/builtin/news/wire/news/footer.ts +1 -0
- package/src/plugins/builtin/news/wire/news/preset-pane.tsx +15 -6
- package/src/plugins/builtin/news/wire/news/query-presets.ts +16 -2
- package/src/plugins/builtin/news/wire/news/table.test.tsx +54 -0
- package/src/plugins/builtin/news/wire/news/table.tsx +111 -17
- package/src/plugins/builtin/notes/files.test.ts +18 -0
- package/src/plugins/builtin/notes/files.ts +10 -4
- package/src/plugins/builtin/notes/index.tsx +4 -1
- package/src/plugins/builtin/notes/quick-notes-pane.test.tsx +182 -0
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +74 -31
- package/src/plugins/builtin/notes/ticker-notes-tab.test.tsx +380 -0
- package/src/plugins/builtin/notes/ticker-notes-tab.tsx +97 -40
- package/src/plugins/builtin/options/calc-seed.test.ts +118 -0
- package/src/plugins/builtin/options/calc-seed.ts +52 -0
- package/src/plugins/builtin/options/footer.ts +4 -1
- package/src/plugins/builtin/options/index.tsx +22 -1
- package/src/plugins/builtin/options/live-quotes.ts +8 -0
- package/src/plugins/builtin/options/table.ts +3 -1
- package/src/plugins/builtin/options/view.test.tsx +5 -1
- package/src/plugins/builtin/options/view.tsx +112 -17
- package/src/plugins/builtin/options-calculator/index.tsx +35 -0
- package/src/plugins/builtin/options-calculator/model.test.ts +172 -0
- package/src/plugins/builtin/options-calculator/model.ts +273 -0
- package/src/plugins/builtin/options-calculator/pane.test.tsx +138 -0
- package/src/plugins/builtin/options-calculator/pane.tsx +218 -0
- package/src/plugins/builtin/plugin-module.test.ts +16 -2
- package/src/plugins/builtin/plugin-module.ts +5 -1
- package/src/plugins/builtin/polls/client.ts +57 -0
- package/src/plugins/builtin/polls/hooks.ts +20 -0
- package/src/plugins/builtin/polls/index.tsx +35 -0
- package/src/plugins/builtin/polls/normalize.test.ts +230 -0
- package/src/plugins/builtin/polls/normalize.ts +319 -0
- package/src/plugins/builtin/polls/pane.tsx +722 -0
- package/src/plugins/builtin/polls/types.ts +77 -0
- package/src/plugins/builtin/portfolio-list/header.tsx +15 -4
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
- package/src/plugins/builtin/portfolio-list/pane/supplemental.ts +1 -1
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +2 -0
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -1
- package/src/plugins/builtin/research/analyst-pane.tsx +40 -67
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +25 -19
- package/src/plugins/builtin/research/index.test.ts +6 -25
- package/src/plugins/builtin/research/index.tsx +11 -5
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +86 -26
- package/src/plugins/builtin/scanner/denied.tsx +31 -0
- package/src/plugins/builtin/scanner/feed.ts +94 -0
- package/src/plugins/builtin/scanner/flow-model.test.ts +85 -0
- package/src/plugins/builtin/scanner/flow-model.ts +133 -0
- package/src/plugins/builtin/scanner/flow-pane.tsx +197 -0
- package/src/plugins/builtin/scanner/hilo-bars.tsx +121 -0
- package/src/plugins/builtin/scanner/hilo-model.test.ts +44 -0
- package/src/plugins/builtin/scanner/hilo-model.ts +75 -0
- package/src/plugins/builtin/scanner/hilo-pane.tsx +165 -0
- package/src/plugins/builtin/scanner/index.ts +109 -0
- package/src/plugins/builtin/scanner/waiting.tsx +11 -0
- package/src/plugins/builtin/sec/index.tsx +11 -7
- package/src/plugins/builtin/sectors/index.tsx +105 -81
- package/src/plugins/builtin/sectors/move-bar.tsx +43 -0
- package/src/plugins/builtin/sectors/sector-data.ts +18 -0
- package/src/plugins/builtin/sectors/sector-model.ts +13 -15
- package/src/plugins/builtin/shared/auto-refresh.ts +51 -0
- package/src/plugins/builtin/shared/cloud-upgrade.ts +29 -5
- package/src/plugins/builtin/shared/pane-footer.ts +16 -3
- package/src/plugins/builtin/shared/screener-live-quotes.test.ts +91 -0
- package/src/plugins/builtin/shared/screener-live-quotes.ts +134 -0
- package/src/plugins/builtin/shared/table-pane.ts +1 -5
- package/src/plugins/builtin/shared/use-quote-board.test.tsx +211 -0
- package/src/plugins/builtin/shared/use-quote-board.ts +195 -0
- package/src/plugins/builtin/short-interest/client.ts +124 -0
- package/src/plugins/builtin/short-interest/index.tsx +62 -0
- package/src/plugins/builtin/short-interest/model.ts +113 -0
- package/src/plugins/builtin/short-interest/pane.tsx +252 -0
- package/src/plugins/builtin/short-interest/types.ts +9 -0
- package/src/plugins/builtin/substack/article-detail.tsx +15 -1
- package/src/plugins/builtin/substack/pane-footer.ts +3 -22
- package/src/plugins/builtin/substack/pane.tsx +1 -2
- package/src/plugins/builtin/thirteenf/api.ts +4 -1
- package/src/plugins/builtin/thirteenf/model.ts +2 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +6 -2
- package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +10 -4
- package/src/plugins/builtin/ticker-detail/data-panes/provider-search.tsx +67 -11
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +15 -8
- package/src/plugins/builtin/ticker-detail/index.tsx +5 -21
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +72 -32
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +0 -10
- package/src/plugins/builtin/ticker-detail/pane.tsx +4 -1
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.test.tsx +70 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +34 -26
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +96 -49
- package/src/plugins/builtin/ticker-detail/research-tabs.ts +32 -0
- package/src/plugins/builtin/ticker-research-backend-plugin.ts +2 -9
- package/src/plugins/builtin/ticker-research-plugin.ts +6 -0
- package/src/plugins/builtin/treasury-auctions/cache.test.ts +173 -0
- package/src/plugins/builtin/treasury-auctions/cache.ts +104 -0
- package/src/plugins/builtin/treasury-auctions/client.test.ts +181 -0
- package/src/plugins/builtin/treasury-auctions/client.ts +151 -0
- package/src/plugins/builtin/treasury-auctions/index.tsx +90 -0
- package/src/plugins/builtin/treasury-auctions/model.test.ts +147 -0
- package/src/plugins/builtin/treasury-auctions/model.ts +188 -0
- package/src/plugins/builtin/treasury-auctions/pane.test.tsx +170 -0
- package/src/plugins/builtin/treasury-auctions/pane.tsx +417 -0
- package/src/plugins/builtin/treasury-auctions/types.ts +59 -0
- package/src/plugins/builtin/tv/pane.tsx +67 -7
- package/src/plugins/builtin/tv/youtube-embed.test.ts +84 -0
- package/src/plugins/builtin/tv/youtube-embed.ts +173 -0
- package/src/plugins/builtin/tv/youtube-stream.ts +27 -2
- package/src/plugins/builtin/volatility/client.ts +87 -0
- package/src/plugins/builtin/volatility/index.test.tsx +107 -0
- package/src/plugins/builtin/volatility/index.tsx +193 -0
- package/src/plugins/builtin/volatility/model.test.ts +66 -0
- package/src/plugins/builtin/volatility/model.ts +113 -0
- package/src/plugins/builtin/world-indices/footer.ts +43 -23
- package/src/plugins/builtin/world-indices/index.tsx +44 -93
- package/src/plugins/builtin/world-indices/indices.ts +11 -2
- package/src/plugins/builtin/world-indices/model.ts +17 -24
- package/src/plugins/builtin/world-indices/pane.test.tsx +116 -0
- package/src/plugins/builtin/world-indices/table.tsx +82 -37
- package/src/plugins/builtin/yield-curve/index.tsx +16 -7
- package/src/plugins/builtin/yield-curve/treasury-data.test.ts +25 -0
- package/src/plugins/builtin/yield-curve/treasury-data.ts +16 -0
- package/src/plugins/catalog-backend.ts +8 -0
- package/src/plugins/catalog-ui.ts +8 -0
- package/src/plugins/event-bus.ts +1 -0
- package/src/plugins/ibkr/gateway/account-loaders.ts +1 -1
- package/src/plugins/ibkr/trade/tab/footer.ts +9 -23
- package/src/plugins/ibkr/trade/tab/index.tsx +1 -5
- package/src/plugins/ibkr/trading/pane-view.tsx +149 -87
- package/src/plugins/ibkr/trading/pane.tsx +2 -2
- package/src/plugins/ownership.ts +3 -0
- package/src/plugins/pane-manager/floating.ts +8 -2
- package/src/plugins/pane-manager.test.ts +13 -0
- package/src/plugins/prediction-markets/backend-plugin.ts +2 -0
- package/src/plugins/prediction-markets/capability.test.ts +281 -0
- package/src/plugins/prediction-markets/capability.ts +171 -0
- package/src/plugins/prediction-markets/chart.tsx +18 -26
- package/src/plugins/prediction-markets/columns.ts +3 -2
- package/src/plugins/prediction-markets/controller/catalog.ts +15 -12
- package/src/plugins/prediction-markets/controller/detail.ts +4 -0
- package/src/plugins/prediction-markets/controller/index.ts +0 -15
- package/src/plugins/prediction-markets/detail/book.tsx +3 -23
- package/src/plugins/prediction-markets/detail/overview.tsx +0 -18
- package/src/plugins/prediction-markets/detail/pane.tsx +36 -12
- package/src/plugins/prediction-markets/detail.test.tsx +1 -1
- package/src/plugins/prediction-markets/index.tsx +2 -0
- package/src/plugins/prediction-markets/metrics.ts +28 -18
- package/src/plugins/prediction-markets/navigation.ts +1 -0
- package/src/plugins/prediction-markets/pane.test.tsx +1 -1
- package/src/plugins/prediction-markets/pane.tsx +0 -1
- package/src/plugins/prediction-markets/services/fetch.ts +3 -2
- package/src/plugins/prediction-markets/services/kalshi/adapter.ts +82 -23
- package/src/plugins/prediction-markets/services/kalshi/normalize.ts +3 -1
- package/src/plugins/prediction-markets/services/kalshi/types.ts +14 -0
- package/src/plugins/prediction-markets/services/polymarket/adapter.ts +26 -14
- package/src/plugins/prediction-markets/services/polymarket/detail.ts +67 -18
- package/src/plugins/prediction-markets/test-helpers.tsx +0 -1
- package/src/plugins/prediction-markets/types.ts +3 -9
- package/src/plugins/registry/context.ts +6 -1
- package/src/plugins/registry/index.test.ts +2 -0
- package/src/plugins/registry/index.ts +53 -3
- package/src/plugins/runtime/context.tsx +4 -2
- package/src/plugins/runtime/index.tsx +9 -0
- package/src/remote/controller.test.ts +17 -4
- package/src/renderers/electrobun/bun/application-menu/index.ts +1 -1
- package/src/renderers/electrobun/bun/core-capabilities.ts +2 -2
- package/src/renderers/electrobun/bun/desktop/capability-bridge.test.ts +64 -0
- package/src/renderers/electrobun/bun/desktop/capability-bridge.ts +41 -7
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +5 -2
- package/src/renderers/electrobun/bun/desktop/http-fetch.test.ts +33 -0
- package/src/renderers/electrobun/bun/desktop/http-fetch.ts +53 -6
- package/src/renderers/electrobun/bun/desktop/initialization.test.ts +27 -0
- package/src/renderers/electrobun/bun/desktop/initialization.ts +6 -1
- package/src/renderers/electrobun/bun/index.ts +1 -0
- package/src/renderers/electrobun/shared/protocol.ts +2 -0
- package/src/renderers/electrobun/view/app-services.ts +25 -2
- package/src/renderers/electrobun/view/build-assets.ts +5 -0
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +186 -65
- package/src/renderers/electrobun/view/cli-pane-shot-health.test.ts +25 -0
- package/src/renderers/electrobun/view/cli-pane-shot-health.ts +31 -0
- package/src/renderers/electrobun/view/data-table/index.tsx +10 -11
- package/src/renderers/electrobun/view/data-table/row.tsx +2 -0
- package/src/renderers/electrobun/view/desktop/controls.test.tsx +68 -0
- package/src/renderers/electrobun/view/desktop/controls.tsx +25 -1
- package/src/renderers/electrobun/view/host/box.test.tsx +80 -0
- package/src/renderers/electrobun/view/host/media-surface.tsx +70 -3
- package/src/renderers/electrobun/view/host/tabs.tsx +97 -5
- package/src/renderers/electrobun/view/host/text.tsx +5 -2
- package/src/renderers/electrobun/view/input-host.test.tsx +140 -0
- package/src/renderers/electrobun/view/input-host.tsx +4 -2
- package/src/renderers/electrobun/view/native-stubs/backend-rpc.ts +19 -1
- package/src/renderers/electrobun/view/native-stubs/broker-sync-native-loader.ts +7 -0
- package/src/renderers/electrobun/view/native-stubs/chart/kitty-support.ts +10 -0
- package/src/renderers/electrobun/view/remote/capability-invoker.test.ts +46 -0
- package/src/renderers/electrobun/view/remote/capability-invoker.ts +34 -13
- package/src/renderers/electrobun/view/remote/connection-health-backend.ts +19 -0
- package/src/renderers/electrobun/view/remote/connection-health.test.ts +44 -0
- package/src/renderers/electrobun/view/remote/connection-health.ts +49 -0
- package/src/renderers/electrobun/view/styles.css +5 -0
- package/src/renderers/opentui/dialog-host.tsx +279 -80
- package/src/renderers/opentui/host.tsx +15 -1
- package/src/renderers/opentui/terminal-media.test.ts +102 -0
- package/src/renderers/opentui/terminal-media.ts +142 -0
- package/src/renderers/opentui/test-utils.tsx +9 -6
- package/src/renderers/opentui/toast-host.tsx +136 -7
- package/src/renderers/opentui/ui-host.tsx +19 -3
- package/src/sources/provider-router/connection-health.test.ts +28 -0
- package/src/sources/provider-router/connection-health.ts +47 -0
- package/src/sources/provider-router/history.test.ts +53 -4
- package/src/sources/provider-router/history.ts +119 -14
- package/src/sources/provider-router/index.ts +12 -1
- package/src/sources/yahoo-finance/history.ts +2 -9
- package/src/sources/yahoo-finance/http.ts +1 -1
- package/src/sources/yahoo-finance/symbols.ts +1 -1
- package/src/sources/yahoo-finance/types.ts +19 -0
- package/src/state/app/context/index.test.tsx +101 -0
- package/src/state/app/context/index.tsx +10 -0
- package/src/state/config-save-scheduler.ts +1 -6
- package/src/state/persist-scheduler.test.ts +31 -0
- package/src/state/persist-scheduler.ts +21 -8
- package/src/sync/auth-transition.test.ts +36 -0
- package/src/sync/auth-transition.ts +22 -0
- package/src/sync/core-contributors.test.ts +58 -1
- package/src/sync/core-contributors.ts +39 -2
- package/src/sync/react.ts +9 -0
- package/src/test-support/plugin-runtime.ts +3 -0
- package/src/theme/font-scale.test.ts +14 -0
- package/src/theme/font-scale.ts +69 -0
- package/src/tickers/search/index.test.ts +284 -2
- package/src/tickers/search/index.ts +55 -18
- package/src/tickers/search/ranking.ts +143 -18
- package/src/tickers/search/types.ts +1 -0
- package/src/time-series/alignment.ts +15 -11
- package/src/time-series/field-catalog.ts +10 -0
- package/src/time-series/fundamentals.ts +19 -11
- package/src/time-series/hooks.ts +8 -2
- package/src/time-series/parsed-history-cache.ts +35 -0
- package/src/time-series/resolution.ts +10 -0
- package/src/time-series/resolve.test.ts +332 -3
- package/src/time-series/resolve.ts +225 -25
- package/src/time-series/spec-studies.test.ts +23 -0
- package/src/time-series/spec.ts +21 -2
- package/src/time-series/transforms.test.ts +76 -1
- package/src/time-series/transforms.ts +39 -8
- package/src/time-series/types.ts +9 -2
- package/src/time-series/use-chart-resolution.test.tsx +105 -1
- package/src/time-series/use-chart-resolution.ts +67 -13
- package/src/types/config.ts +30 -27
- package/src/types/media.ts +2 -0
- package/src/types/plugin.ts +8 -1
- package/src/ui/host.tsx +4 -0
- package/src/ui/pointer-drag.ts +12 -0
- package/src/ui/qr.test.ts +79 -0
- package/src/ui/qr.ts +82 -0
- package/src/updater/github-releases.test.ts +3 -3
- package/src/updater/github-releases.ts +1 -1
- package/src/updater.test.ts +117 -16
- package/src/updater.ts +32 -5
- package/src/utils/exchanges.ts +1 -0
- package/src/utils/external-url.test.ts +32 -0
- package/src/utils/external-url.ts +23 -0
- package/src/utils/sort-values.ts +31 -0
- package/src/utils/zoned-date-time.ts +67 -0
- package/src/components/onboarding/wizard-keyboard.ts +0 -306
- package/src/plugins/builtin/chart-composer/date-window-dialog.tsx +0 -120
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type { MarketState
|
|
1
|
+
import type { MarketState } from "../../../types/financials";
|
|
2
2
|
import { compareSortValues, type SortDirection } from "../../../utils/sort-values";
|
|
3
|
+
import type { BoardQuoteMap } from "../shared/use-quote-board";
|
|
3
4
|
import { REGION_ORDER, type IndexEntry } from "./indices";
|
|
4
5
|
|
|
5
|
-
export interface IndexQuoteState {
|
|
6
|
-
quote: Quote | null;
|
|
7
|
-
loading: boolean;
|
|
8
|
-
error: string | null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type QuoteMap = Map<string, IndexQuoteState>;
|
|
12
|
-
|
|
13
6
|
export type WorldIndexTableRow =
|
|
14
7
|
| { type: "header"; region: IndexEntry["region"] }
|
|
15
8
|
| { type: "row"; entry: IndexEntry };
|
|
16
9
|
|
|
17
|
-
export type WorldIndexColumnId =
|
|
10
|
+
export type WorldIndexColumnId =
|
|
11
|
+
| "status"
|
|
12
|
+
| "symbol"
|
|
13
|
+
| "name"
|
|
14
|
+
| "price"
|
|
15
|
+
| "change"
|
|
16
|
+
| "changePercent"
|
|
17
|
+
| "time";
|
|
18
18
|
|
|
19
19
|
export interface WorldIndexSortPreference {
|
|
20
20
|
columnId: WorldIndexColumnId | null;
|
|
@@ -38,7 +38,7 @@ const MARKET_STATE_SORT_ORDER: Partial<Record<MarketState, number>> = {
|
|
|
38
38
|
function getSortValue(
|
|
39
39
|
columnId: WorldIndexColumnId,
|
|
40
40
|
entry: IndexEntry,
|
|
41
|
-
quotes:
|
|
41
|
+
quotes: BoardQuoteMap,
|
|
42
42
|
): string | number | null {
|
|
43
43
|
const quote = quotes.get(entry.symbol)?.quote;
|
|
44
44
|
|
|
@@ -51,15 +51,19 @@ function getSortValue(
|
|
|
51
51
|
return entry.name;
|
|
52
52
|
case "price":
|
|
53
53
|
return quote?.price ?? null;
|
|
54
|
+
case "change":
|
|
55
|
+
return quote?.change ?? null;
|
|
54
56
|
case "changePercent":
|
|
55
57
|
return quote?.changePercent ?? null;
|
|
58
|
+
case "time":
|
|
59
|
+
return quote?.lastUpdated ?? null;
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
function sortEntries(
|
|
60
64
|
entries: IndexEntry[],
|
|
61
65
|
sortPreference: WorldIndexSortPreference,
|
|
62
|
-
quotes:
|
|
66
|
+
quotes: BoardQuoteMap,
|
|
63
67
|
): IndexEntry[] {
|
|
64
68
|
const sortColumnId = sortPreference.columnId;
|
|
65
69
|
if (!sortColumnId) return entries;
|
|
@@ -73,7 +77,7 @@ function sortEntries(
|
|
|
73
77
|
export function buildFlatRows(
|
|
74
78
|
indicesByRegion: Map<IndexEntry["region"], IndexEntry[]>,
|
|
75
79
|
sortPreference: WorldIndexSortPreference,
|
|
76
|
-
quotes:
|
|
80
|
+
quotes: BoardQuoteMap,
|
|
77
81
|
): WorldIndexTableRow[] {
|
|
78
82
|
const rows: WorldIndexTableRow[] = [];
|
|
79
83
|
for (const region of REGION_ORDER) {
|
|
@@ -100,14 +104,3 @@ export function nextSortPreference(
|
|
|
100
104
|
}
|
|
101
105
|
return DEFAULT_SORT_PREFERENCE;
|
|
102
106
|
}
|
|
103
|
-
|
|
104
|
-
export function countLoadingQuotes(quotes: QuoteMap): number {
|
|
105
|
-
return Array.from(quotes.values()).filter((state) => state.loading).length;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export function latestQuoteTimestamp(quotes: QuoteMap): number {
|
|
109
|
-
return Math.max(
|
|
110
|
-
0,
|
|
111
|
-
...Array.from(quotes.values()).map((state) => state.quote?.lastUpdated ?? 0),
|
|
112
|
-
);
|
|
113
|
-
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import { act, useMemo, useState } from "react";
|
|
3
|
+
import { testRender } from "../../../renderers/opentui/test-utils";
|
|
4
|
+
import { AppContext, createInitialState, PaneInstanceProvider } from "../../../state/app/context";
|
|
5
|
+
import { createDefaultConfig } from "../../../types/config";
|
|
6
|
+
import type { QuoteBatchResult } from "../../../types/data-provider";
|
|
7
|
+
import { PluginRenderProvider, type PluginRuntimeAccess } from "../../runtime";
|
|
8
|
+
import { worldIndicesModule } from "./index";
|
|
9
|
+
|
|
10
|
+
const WorldIndicesPane = worldIndicesModule.panes![0]!.component as (props: {
|
|
11
|
+
paneId: string;
|
|
12
|
+
paneType: string;
|
|
13
|
+
focused: boolean;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
}) => React.ReactNode;
|
|
17
|
+
|
|
18
|
+
const PRICES: Record<string, number> = { "^GSPC": 6_812.44, "^FTSE": 9_431.2 };
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Provider identity is what the board's poll effect keys on, so swapping in a
|
|
22
|
+
* failing provider is how a test drives a second load without a 60s wait.
|
|
23
|
+
*/
|
|
24
|
+
function makeProvider(mode: "ok" | "fail") {
|
|
25
|
+
return {
|
|
26
|
+
getQuotesBatch: async (targets: Array<{ symbol: string }>): Promise<QuoteBatchResult[]> => (
|
|
27
|
+
targets.map((target) => ({
|
|
28
|
+
target: { symbol: target.symbol, exchange: "" },
|
|
29
|
+
quote: mode === "fail" ? null : {
|
|
30
|
+
symbol: target.symbol,
|
|
31
|
+
price: PRICES[target.symbol] ?? 1_000,
|
|
32
|
+
change: 12.5,
|
|
33
|
+
changePercent: 0.42,
|
|
34
|
+
currency: "USD",
|
|
35
|
+
marketState: "REGULAR" as const,
|
|
36
|
+
lastUpdated: Date.now(),
|
|
37
|
+
},
|
|
38
|
+
error: mode === "fail" ? new Error("upstream 503") : undefined,
|
|
39
|
+
})) as QuoteBatchResult[]
|
|
40
|
+
),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let breakProvider: () => void = () => {};
|
|
45
|
+
|
|
46
|
+
function Harness() {
|
|
47
|
+
const state = createInitialState(createDefaultConfig("/tmp/gloomberb-wei-pane-test"));
|
|
48
|
+
const [mode, setMode] = useState<"ok" | "fail">("ok");
|
|
49
|
+
breakProvider = () => setMode("fail");
|
|
50
|
+
const runtime = useMemo(() => {
|
|
51
|
+
const provider = makeProvider(mode);
|
|
52
|
+
return { getMarketData: () => provider } as unknown as PluginRuntimeAccess;
|
|
53
|
+
}, [mode]);
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<AppContext value={{ state, dispatch: () => {} }}>
|
|
57
|
+
<PluginRenderProvider runtime={runtime} pluginId="market-overview">
|
|
58
|
+
<PaneInstanceProvider paneId="world-indices">
|
|
59
|
+
<WorldIndicesPane
|
|
60
|
+
paneId="world-indices"
|
|
61
|
+
paneType="world-indices"
|
|
62
|
+
focused
|
|
63
|
+
width={80}
|
|
64
|
+
height={24}
|
|
65
|
+
/>
|
|
66
|
+
</PaneInstanceProvider>
|
|
67
|
+
</PluginRenderProvider>
|
|
68
|
+
</AppContext>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let testSetup: Awaited<ReturnType<typeof testRender>> | undefined;
|
|
73
|
+
|
|
74
|
+
afterEach(async () => {
|
|
75
|
+
if (!testSetup) return;
|
|
76
|
+
await act(async () => {
|
|
77
|
+
testSetup!.renderer.destroy();
|
|
78
|
+
});
|
|
79
|
+
testSetup = undefined;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
async function settle() {
|
|
83
|
+
await act(async () => {
|
|
84
|
+
await testSetup!.renderOnce();
|
|
85
|
+
await testSetup!.renderOnce();
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
describe("WorldIndicesPane", () => {
|
|
90
|
+
test("renders regions and prices from the shared quote board", async () => {
|
|
91
|
+
testSetup = await testRender(<Harness />, { width: 80, height: 24 });
|
|
92
|
+
await settle();
|
|
93
|
+
|
|
94
|
+
const frame = testSetup.captureCharFrame();
|
|
95
|
+
expect(frame).toContain("Americas");
|
|
96
|
+
expect(frame).toContain("SPX");
|
|
97
|
+
expect(frame).toContain("6,812.44");
|
|
98
|
+
expect(frame).toContain("+0.42%");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("keeps the last good prices when the provider starts failing", async () => {
|
|
102
|
+
testSetup = await testRender(<Harness />, { width: 80, height: 24 });
|
|
103
|
+
await settle();
|
|
104
|
+
expect(testSetup.captureCharFrame()).toContain("6,812.44");
|
|
105
|
+
|
|
106
|
+
await act(async () => {
|
|
107
|
+
breakProvider();
|
|
108
|
+
});
|
|
109
|
+
await settle();
|
|
110
|
+
|
|
111
|
+
// Regression: a failed load blanked every price to "—" mid-session.
|
|
112
|
+
const frame = testSetup.captureCharFrame();
|
|
113
|
+
expect(frame).toContain("6,812.44");
|
|
114
|
+
expect(frame).toContain("SPX");
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -1,54 +1,80 @@
|
|
|
1
1
|
import type { DataTableCell, DataTableColumn } from "../../../components";
|
|
2
|
+
import { marketStateColor, marketStateLabel } from "../../../market-data/market/status";
|
|
2
3
|
import { colors, priceColor } from "../../../theme/colors";
|
|
3
|
-
import type { MarketState } from "../../../types/financials";
|
|
4
4
|
import { TextAttributes } from "../../../ui";
|
|
5
|
-
import { formatCurrency, formatPercentRaw } from "../../../utils/format";
|
|
5
|
+
import { formatCurrency, formatNumber, formatPercentRaw } from "../../../utils/format";
|
|
6
|
+
import { marketStatusDot, type BoardQuoteMap } from "../shared/use-quote-board";
|
|
6
7
|
import type {
|
|
7
|
-
QuoteMap,
|
|
8
8
|
WorldIndexColumnId,
|
|
9
9
|
WorldIndexTableRow,
|
|
10
10
|
} from "./model";
|
|
11
11
|
|
|
12
12
|
export type WorldIndexColumn = DataTableColumn & { id: WorldIndexColumnId };
|
|
13
13
|
|
|
14
|
+
const SESSION_TEXT_MIN_WIDTH = 84;
|
|
15
|
+
const CHANGE_MIN_WIDTH = 62;
|
|
16
|
+
const TIME_MIN_WIDTH = 78;
|
|
17
|
+
|
|
18
|
+
/** A colored dot needs a legend; the session word does not, so wide panes spell it out. */
|
|
19
|
+
export function usesSessionText(width: number): boolean {
|
|
20
|
+
return width >= SESSION_TEXT_MIN_WIDTH;
|
|
21
|
+
}
|
|
22
|
+
|
|
14
23
|
export function createWorldIndexColumns(width: number): WorldIndexColumn[] {
|
|
15
|
-
const statusWidth = 1;
|
|
24
|
+
const statusWidth = usesSessionText(width) ? 9 : 1;
|
|
16
25
|
const symbolWidth = 8;
|
|
17
26
|
const priceWidth = 15;
|
|
18
|
-
const changeWidth =
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
const changeWidth = 12;
|
|
28
|
+
const changePercentWidth = 9;
|
|
29
|
+
// 5-char 24h time in an 8-wide column: the shared table's floating-pane width
|
|
30
|
+
// accounting runs a few cells long, and the slack keeps the value intact.
|
|
31
|
+
const timeWidth = 8;
|
|
32
|
+
const showChange = width >= CHANGE_MIN_WIDTH;
|
|
33
|
+
const showTime = width >= TIME_MIN_WIDTH;
|
|
34
|
+
|
|
35
|
+
const trailing: WorldIndexColumn[] = [
|
|
36
|
+
{ id: "price", label: "LAST", width: priceWidth, align: "right" },
|
|
37
|
+
...(showChange
|
|
38
|
+
? [{ id: "change" as const, label: "CHG", width: changeWidth, align: "right" as const }]
|
|
39
|
+
: []),
|
|
40
|
+
{ id: "changePercent", label: "CHG%", width: changePercentWidth, align: "right" },
|
|
41
|
+
// Left-aligned on purpose: the shared table trims a few cells off the right
|
|
42
|
+
// edge of a floating pane, and a right-aligned value would lose digits.
|
|
43
|
+
...(showTime
|
|
44
|
+
? [{ id: "time" as const, label: "TIME", width: timeWidth, align: "left" as const }]
|
|
45
|
+
: []),
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
const columnCount = trailing.length + 3;
|
|
49
|
+
const fixedWidth = statusWidth + symbolWidth
|
|
50
|
+
+ trailing.reduce((total, column) => total + (column.width ?? 0), 0);
|
|
51
|
+
// Leaves room for the pane border and scrollbar gutter; the name column grows
|
|
52
|
+
// back into any slack because it is the flexible one.
|
|
53
|
+
const nameWidth = Math.max(10, width - 6 - columnCount - fixedWidth);
|
|
22
54
|
|
|
23
55
|
return [
|
|
24
|
-
{ id: "status", label: "", width: statusWidth, align: "left" },
|
|
56
|
+
{ id: "status", label: usesSessionText(width) ? "SESSION" : "", width: statusWidth, align: "left" },
|
|
25
57
|
{ id: "symbol", label: "INDEX", width: symbolWidth, align: "left" },
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{ id: "
|
|
58
|
+
// The leftover width lands here rather than being spread across the number
|
|
59
|
+
// columns, which is what left a dead zone between NAME and LAST.
|
|
60
|
+
{ id: "name", label: "NAME", width: nameWidth, align: "left", flexGrow: 1 },
|
|
61
|
+
...trailing,
|
|
29
62
|
];
|
|
30
63
|
}
|
|
31
64
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
case "POST":
|
|
38
|
-
case "PREPRE":
|
|
39
|
-
case "POSTPOST":
|
|
40
|
-
return { char: "●", color: colors.warning };
|
|
41
|
-
case "CLOSED":
|
|
42
|
-
default:
|
|
43
|
-
return { char: "●", color: colors.negative };
|
|
44
|
-
}
|
|
65
|
+
/** 24-hour so the cell stays 5 wide in every locale and never clips. */
|
|
66
|
+
export function formatQuoteTime(lastUpdated: number | undefined): string {
|
|
67
|
+
if (!lastUpdated) return "—";
|
|
68
|
+
const date = new Date(lastUpdated);
|
|
69
|
+
return `${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
|
|
45
70
|
}
|
|
46
71
|
|
|
47
72
|
export function renderWorldIndexCell(
|
|
48
73
|
row: WorldIndexTableRow,
|
|
49
74
|
column: WorldIndexColumn,
|
|
50
75
|
rowState: { selected: boolean },
|
|
51
|
-
quotes:
|
|
76
|
+
quotes: BoardQuoteMap,
|
|
77
|
+
options?: { sessionText?: boolean },
|
|
52
78
|
): DataTableCell {
|
|
53
79
|
if (row.type === "header") return { text: "" };
|
|
54
80
|
|
|
@@ -56,11 +82,24 @@ export function renderWorldIndexCell(
|
|
|
56
82
|
const state = quotes.get(entry.symbol);
|
|
57
83
|
const quote = state?.quote;
|
|
58
84
|
const selectedColor = rowState.selected ? colors.selectedText : undefined;
|
|
85
|
+
const dimmed = rowState.selected ? colors.selectedText : colors.textDim;
|
|
86
|
+
// One row must not mix a loading marker with a no-data marker.
|
|
87
|
+
const loadingCell = !quote && (state?.loading ?? true);
|
|
59
88
|
|
|
60
89
|
switch (column.id) {
|
|
61
90
|
case "status": {
|
|
91
|
+
if (loadingCell) return { text: "", color: dimmed };
|
|
92
|
+
if (options?.sessionText) {
|
|
93
|
+
const marketState = quote?.marketState;
|
|
94
|
+
return {
|
|
95
|
+
text: marketState ? marketStateLabel(marketState) : "—",
|
|
96
|
+
color: rowState.selected
|
|
97
|
+
? colors.selectedText
|
|
98
|
+
: marketState ? marketStateColor(marketState) : colors.textDim,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
62
101
|
const dot = marketStatusDot(quote?.marketState);
|
|
63
|
-
return { text: dot.char, color: dot.color };
|
|
102
|
+
return { text: dot.char, color: rowState.selected ? colors.selectedText : dot.color };
|
|
64
103
|
}
|
|
65
104
|
case "symbol":
|
|
66
105
|
return {
|
|
@@ -74,23 +113,29 @@ export function renderWorldIndexCell(
|
|
|
74
113
|
color: selectedColor,
|
|
75
114
|
};
|
|
76
115
|
case "price":
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (state?.error || quote?.price === undefined) {
|
|
81
|
-
return { text: "—", color: rowState.selected ? colors.selectedText : colors.textDim };
|
|
82
|
-
}
|
|
116
|
+
if (loadingCell) return { text: "…", color: dimmed };
|
|
117
|
+
if (quote?.price === undefined) return { text: "—", color: dimmed };
|
|
118
|
+
// A retained quote still beats a dash; dim it so stale is visible.
|
|
83
119
|
return {
|
|
84
120
|
text: formatCurrency(quote.price, quote.currency ?? "USD"),
|
|
85
|
-
color: selectedColor,
|
|
121
|
+
color: state?.stale ? dimmed : selectedColor,
|
|
122
|
+
};
|
|
123
|
+
case "change":
|
|
124
|
+
if (loadingCell) return { text: "…", color: dimmed };
|
|
125
|
+
if (!quote || !Number.isFinite(quote.change)) return { text: "—", color: dimmed };
|
|
126
|
+
return {
|
|
127
|
+
text: `${quote.change >= 0 ? "+" : "-"}${formatNumber(Math.abs(quote.change), 2)}`,
|
|
128
|
+
color: selectedColor ?? priceColor(quote.change),
|
|
86
129
|
};
|
|
87
130
|
case "changePercent":
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
}
|
|
131
|
+
if (loadingCell) return { text: "…", color: dimmed };
|
|
132
|
+
if (!quote || quote.changePercent === undefined) return { text: "—", color: dimmed };
|
|
91
133
|
return {
|
|
92
134
|
text: formatPercentRaw(quote.changePercent),
|
|
93
135
|
color: selectedColor ?? priceColor(quote.changePercent),
|
|
94
136
|
};
|
|
137
|
+
case "time":
|
|
138
|
+
if (loadingCell) return { text: "…", color: dimmed };
|
|
139
|
+
return { text: formatQuoteTime(quote?.lastUpdated), color: dimmed };
|
|
95
140
|
}
|
|
96
141
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Box, ScrollBox, Text } from "../../../ui";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { useShortcut } from "../../../react/input";
|
|
4
|
-
import { StaticChartSurface, type PaneFooterSegment } from "../../../components";
|
|
4
|
+
import { Button, EmptyState, Spinner, StaticChartSurface, type PaneFooterSegment } from "../../../components";
|
|
5
5
|
import type { PaneProps } from "../../../types/plugin";
|
|
6
6
|
import type { PluginModule } from "../plugin-module";
|
|
7
7
|
import { colors } from "../../../theme/colors";
|
|
8
8
|
import { resolveChartPalette } from "../../../components/chart/core/renderer";
|
|
9
9
|
import type { ProjectedChartPoint } from "../../../components/chart/core/data";
|
|
10
10
|
import {
|
|
11
|
+
curveAsOf,
|
|
11
12
|
loadYieldCurve,
|
|
12
13
|
parseYieldPoints,
|
|
13
14
|
isInverted,
|
|
@@ -15,6 +16,7 @@ import {
|
|
|
15
16
|
type YieldPoint,
|
|
16
17
|
} from "./treasury-data";
|
|
17
18
|
import { usePaneStatusFooter } from "../shared/pane-footer";
|
|
19
|
+
import { useAutoRefresh, useUpdatedAgo } from "../shared/auto-refresh";
|
|
18
20
|
|
|
19
21
|
function formatYield(y: number | null): string {
|
|
20
22
|
if (y == null) return "—";
|
|
@@ -36,6 +38,7 @@ function YieldCurvePane({ focused, width, height }: PaneProps) {
|
|
|
36
38
|
const [points, setPoints] = useState<YieldPoint[]>([]);
|
|
37
39
|
const [loading, setLoading] = useState(false);
|
|
38
40
|
const [error, setError] = useState<string | null>(null);
|
|
41
|
+
const [lastUpdated, setLastUpdated] = useState<number | null>(null);
|
|
39
42
|
|
|
40
43
|
const fetchGenRef = useRef(0);
|
|
41
44
|
|
|
@@ -49,6 +52,7 @@ function YieldCurvePane({ focused, width, height }: PaneProps) {
|
|
|
49
52
|
const data = await loadYieldCurve();
|
|
50
53
|
if (fetchGenRef.current !== gen) return;
|
|
51
54
|
setPoints(data);
|
|
55
|
+
setLastUpdated(Date.now());
|
|
52
56
|
} catch (err) {
|
|
53
57
|
if (fetchGenRef.current !== gen) return;
|
|
54
58
|
setError(err instanceof Error ? err.message : String(err));
|
|
@@ -60,6 +64,8 @@ function YieldCurvePane({ focused, width, height }: PaneProps) {
|
|
|
60
64
|
useEffect(() => {
|
|
61
65
|
load();
|
|
62
66
|
}, [load]);
|
|
67
|
+
useAutoRefresh(lastUpdated, load);
|
|
68
|
+
const updatedAgo = useUpdatedAgo(lastUpdated);
|
|
63
69
|
|
|
64
70
|
useShortcut((ev) => {
|
|
65
71
|
if (!focused) return;
|
|
@@ -70,11 +76,16 @@ function YieldCurvePane({ focused, width, height }: PaneProps) {
|
|
|
70
76
|
|
|
71
77
|
const inverted = isInverted(points);
|
|
72
78
|
const bp = spreadBp(points);
|
|
79
|
+
// Treasury series are daily closes, so which session the curve represents is
|
|
80
|
+
// status the user needs; "updated Xm ago" only says when we last fetched it.
|
|
81
|
+
const asOf = curveAsOf(points);
|
|
73
82
|
|
|
74
83
|
const yieldStatus = useMemo<PaneFooterSegment[]>(() => [
|
|
75
84
|
...(inverted ? [{ id: "inverted", parts: [{ text: "INVERTED", tone: "warning" as const, bold: true }] }] : []),
|
|
76
85
|
...(bp != null ? [{ id: "spread", parts: [{ text: `2Y-10Y ${bp >= 0 ? "+" : ""}${bp}bp`, tone: bp < 0 ? "warning" as const : "muted" as const }] }] : []),
|
|
77
|
-
|
|
86
|
+
...(asOf ? [{ id: "as-of", parts: [{ text: `as of ${asOf}`, tone: "muted" as const }] }] : []),
|
|
87
|
+
...(updatedAgo ? [{ id: "updated", parts: [{ text: `updated ${updatedAgo}`, tone: "muted" as const }] }] : []),
|
|
88
|
+
], [asOf, bp, inverted, updatedAgo]);
|
|
78
89
|
usePaneStatusFooter({
|
|
79
90
|
registrationId: "yield-curve",
|
|
80
91
|
loading,
|
|
@@ -86,7 +97,7 @@ function YieldCurvePane({ focused, width, height }: PaneProps) {
|
|
|
86
97
|
return (
|
|
87
98
|
<Box flexDirection="column" width={width} height={height}>
|
|
88
99
|
<Box flexGrow={1} justifyContent="center" alignItems="center">
|
|
89
|
-
<
|
|
100
|
+
<Spinner label="Loading yield curve..." />
|
|
90
101
|
</Box>
|
|
91
102
|
</Box>
|
|
92
103
|
);
|
|
@@ -94,10 +105,8 @@ function YieldCurvePane({ focused, width, height }: PaneProps) {
|
|
|
94
105
|
|
|
95
106
|
if (error && points.length === 0) {
|
|
96
107
|
return (
|
|
97
|
-
<Box flexDirection="column" width={width} height={height}>
|
|
98
|
-
<
|
|
99
|
-
<Text fg={colors.negative}>{error}</Text>
|
|
100
|
-
</Box>
|
|
108
|
+
<Box flexDirection="column" width={width} height={height} padding={1} gap={1}>
|
|
109
|
+
<EmptyState title="Yield curve unavailable." message={error} />
|
|
101
110
|
</Box>
|
|
102
111
|
);
|
|
103
112
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import { curveAsOf, type YieldPoint } from "./treasury-data";
|
|
3
|
+
|
|
4
|
+
function point(maturity: string, years: number, value: number | null, asOf?: string | null): YieldPoint {
|
|
5
|
+
return { maturity, maturityYears: years, yield: value, asOf };
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
test("dates the curve from the newest observation present", () => {
|
|
9
|
+
expect(curveAsOf([
|
|
10
|
+
point("2Y", 2, 4.19, "2026-08-15"),
|
|
11
|
+
point("10Y", 10, 4.72, "2026-08-17"),
|
|
12
|
+
point("30Y", 30, 5.31, "2026-08-17"),
|
|
13
|
+
])).toBe("2026-08-17");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("ignores points with no date rather than dropping the curve date", () => {
|
|
17
|
+
expect(curveAsOf([
|
|
18
|
+
point("2Y", 2, 4.19, null),
|
|
19
|
+
point("10Y", 10, 4.72, "2026-08-17"),
|
|
20
|
+
])).toBe("2026-08-17");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("reports no date when the server predates the field", () => {
|
|
24
|
+
expect(curveAsOf([point("2Y", 2, 4.19), point("10Y", 10, 4.72)])).toBeNull();
|
|
25
|
+
});
|
|
@@ -4,6 +4,7 @@ export interface YieldPoint {
|
|
|
4
4
|
maturity: string; // "1M", "3M", "6M", "1Y", "2Y", "5Y", "7Y", "10Y", "20Y", "30Y"
|
|
5
5
|
maturityYears: number; // 0.083, 0.25, 0.5, 1, 2, 5, 7, 10, 20, 30
|
|
6
6
|
yield: number | null; // percent, e.g., 4.29
|
|
7
|
+
asOf?: string | null; // FRED observation date, absent on older servers
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export const TREASURY_MATURITIES: Array<{ maturity: string; years: number; seriesId: string }> = [
|
|
@@ -29,6 +30,21 @@ export function parseYieldPoints(points: YieldPoint[]): YieldPoint[] {
|
|
|
29
30
|
.sort((a, b) => a.maturityYears - b.maturityYears);
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
/**
|
|
34
|
+
* The newest observation date across the curve. Treasury series publish
|
|
35
|
+
* together, but a single stale series must not date the whole curve forward,
|
|
36
|
+
* so this reports the latest date actually present.
|
|
37
|
+
*/
|
|
38
|
+
export function curveAsOf(points: readonly YieldPoint[]): string | null {
|
|
39
|
+
let latest: string | null = null;
|
|
40
|
+
for (const point of points) {
|
|
41
|
+
const asOf = point.asOf;
|
|
42
|
+
if (!asOf) continue;
|
|
43
|
+
if (!latest || asOf > latest) latest = asOf;
|
|
44
|
+
}
|
|
45
|
+
return latest;
|
|
46
|
+
}
|
|
47
|
+
|
|
32
48
|
export function isInverted(points: YieldPoint[]): boolean {
|
|
33
49
|
const y2 = points.find((p) => p.maturity === "2Y")?.yield;
|
|
34
50
|
const y10 = points.find((p) => p.maturity === "10Y")?.yield;
|
|
@@ -16,7 +16,11 @@ import { substackPlugin } from "./builtin/substack";
|
|
|
16
16
|
import { tickerResearchBackendPlugin } from "./builtin/ticker-research-backend-plugin";
|
|
17
17
|
import { yahooPlugin } from "./builtin/yahoo";
|
|
18
18
|
import { ibkrPlugin } from "./ibkr";
|
|
19
|
+
import { publicPlugin } from "./broker-sync/public";
|
|
20
|
+
import { robinhoodPlugin } from "./broker-sync/robinhood";
|
|
21
|
+
import { simpleFinPlugin } from "./broker-sync/simplefin";
|
|
19
22
|
import { predictionMarketsBackendPlugin } from "./prediction-markets/backend-plugin";
|
|
23
|
+
import { pollsPlugin } from "./builtin/polls";
|
|
20
24
|
|
|
21
25
|
const desktopBackendPlugins: GloomPlugin[] = [
|
|
22
26
|
yahooPlugin,
|
|
@@ -25,12 +29,16 @@ const desktopBackendPlugins: GloomPlugin[] = [
|
|
|
25
29
|
tickerResearchBackendPlugin,
|
|
26
30
|
brokerPlugin,
|
|
27
31
|
ibkrPlugin,
|
|
32
|
+
publicPlugin,
|
|
33
|
+
robinhoodPlugin,
|
|
34
|
+
simpleFinPlugin,
|
|
28
35
|
applicationPlugin,
|
|
29
36
|
newsPlugin,
|
|
30
37
|
substackPlugin,
|
|
31
38
|
notesPlugin,
|
|
32
39
|
aiPlugin,
|
|
33
40
|
predictionMarketsBackendPlugin,
|
|
41
|
+
pollsPlugin,
|
|
34
42
|
marketOverviewPlugin,
|
|
35
43
|
macroPlugin,
|
|
36
44
|
alertsPlugin,
|
|
@@ -5,7 +5,11 @@ import { substackPlugin } from "./builtin/substack";
|
|
|
5
5
|
import { aiPlugin } from "./builtin/ai";
|
|
6
6
|
import { gloomberbCloudPlugin } from "./builtin/cloud";
|
|
7
7
|
import { ibkrPlugin } from "./ibkr";
|
|
8
|
+
import { publicPlugin } from "./broker-sync/public";
|
|
9
|
+
import { robinhoodPlugin } from "./broker-sync/robinhood";
|
|
10
|
+
import { simpleFinPlugin } from "./broker-sync/simplefin";
|
|
8
11
|
import { predictionMarketsPlugin } from "./prediction-markets";
|
|
12
|
+
import { pollsPlugin } from "./builtin/polls";
|
|
9
13
|
import { alertsPlugin } from "./builtin/alerts";
|
|
10
14
|
import {
|
|
11
15
|
applicationPlugin,
|
|
@@ -22,12 +26,16 @@ export const uiBuiltinPlugins: GloomPlugin[] = [
|
|
|
22
26
|
tickerResearchPlugin,
|
|
23
27
|
brokerPlugin,
|
|
24
28
|
ibkrPlugin,
|
|
29
|
+
publicPlugin,
|
|
30
|
+
robinhoodPlugin,
|
|
31
|
+
simpleFinPlugin,
|
|
25
32
|
applicationPlugin,
|
|
26
33
|
newsPlugin,
|
|
27
34
|
substackPlugin,
|
|
28
35
|
notesPlugin,
|
|
29
36
|
aiPlugin,
|
|
30
37
|
predictionMarketsPlugin,
|
|
38
|
+
pollsPlugin,
|
|
31
39
|
marketOverviewPlugin,
|
|
32
40
|
macroPlugin,
|
|
33
41
|
alertsPlugin,
|
package/src/plugins/event-bus.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface PluginEvents {
|
|
|
11
11
|
"ticker:refreshed": { symbol: string; financials: TickerFinancials };
|
|
12
12
|
"ticker:added": { symbol: string; ticker: TickerRecord };
|
|
13
13
|
"ticker:removed": { symbol: string };
|
|
14
|
+
"command-bar:portfolio-membership-persisted": { symbol: string; portfolioId: string };
|
|
14
15
|
"config:changed": { config: AppConfig };
|
|
15
16
|
"plugin:registered": { pluginId: string };
|
|
16
17
|
"plugin:unregistered": { pluginId: string };
|
|
@@ -135,7 +135,7 @@ export async function loadIbkrPositions({
|
|
|
135
135
|
ticker: position.contract.localSymbol || position.contract.symbol,
|
|
136
136
|
exchange: position.contract.primaryExch || position.contract.exchange || "",
|
|
137
137
|
shares: Math.abs(position.pos),
|
|
138
|
-
avgCost:
|
|
138
|
+
avgCost: portfolioSnapshot?.avgCost ?? position.avgCost,
|
|
139
139
|
currency: position.contract.currency || "USD",
|
|
140
140
|
accountId,
|
|
141
141
|
name: position.contract.description || position.contract.localSymbol || position.contract.symbol,
|
|
@@ -1,47 +1,37 @@
|
|
|
1
1
|
import { usePaneFooter } from "../../../../components";
|
|
2
2
|
import type { TickerRecord } from "../../../../types/ticker";
|
|
3
3
|
import type { TradeTicketState } from "../../trading/state";
|
|
4
|
-
import type { TradeTone } from "../utils";
|
|
5
4
|
import type { TradeTabActions } from "./actions";
|
|
6
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Ticket status (next step, capture state, last message) lives in the tab header,
|
|
8
|
+
* which shows it untruncated and interactively, so the footer only carries actions.
|
|
9
|
+
*/
|
|
7
10
|
export function useTradeTabFooter({
|
|
8
11
|
actions,
|
|
9
|
-
|
|
10
|
-
nextStep,
|
|
12
|
+
canEnterOrder,
|
|
11
13
|
showLimit,
|
|
12
14
|
showStop,
|
|
13
|
-
statusText,
|
|
14
|
-
statusTone,
|
|
15
15
|
symbol,
|
|
16
16
|
ticketState,
|
|
17
17
|
ticker,
|
|
18
|
-
workflowTone,
|
|
19
18
|
}: {
|
|
20
19
|
actions: TradeTabActions;
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
/** False until a broker profile and account are picked, so order fields cannot be edited yet. */
|
|
21
|
+
canEnterOrder: boolean;
|
|
23
22
|
showLimit: boolean;
|
|
24
23
|
showStop: boolean;
|
|
25
|
-
statusText: string;
|
|
26
|
-
statusTone: TradeTone;
|
|
27
24
|
symbol: string | null;
|
|
28
25
|
ticketState: TradeTicketState;
|
|
29
26
|
ticker: TickerRecord | null;
|
|
30
|
-
workflowTone: TradeTone;
|
|
31
27
|
}) {
|
|
32
28
|
usePaneFooter("ibkr-trade", () => ({
|
|
33
|
-
info: [
|
|
34
|
-
{ id: "next", parts: [{ text: nextStep, tone: workflowTone === "positive" ? "positive" : workflowTone === "accent" ? "value" : "muted", bold: workflowTone !== "neutral" }] },
|
|
35
|
-
{ id: "ticket", parts: [{ text: interactive ? "captured" : "standby", tone: interactive ? "positive" : "muted" }] },
|
|
36
|
-
...(statusText ? [{ id: "status", parts: [{ text: statusText, tone: statusTone === "negative" ? "negative" as const : statusTone === "positive" ? "positive" as const : "muted" as const }] }] : []),
|
|
37
|
-
],
|
|
38
29
|
hints: [
|
|
39
30
|
...(!ticketState.busy ? [
|
|
40
|
-
{ id: "refresh", key: "r", label: "efresh", onPress: () => actions.refresh().catch(() => {}) },
|
|
41
31
|
{ id: "profile", key: "i", label: "profile", onPress: () => actions.chooseBrokerInstance().catch(() => {}) },
|
|
42
32
|
{ id: "account", key: "a", label: "ccount", onPress: () => actions.chooseAccount().catch(() => {}) },
|
|
43
33
|
] : []),
|
|
44
|
-
...(!ticketState.busy && symbol && ticker ? [
|
|
34
|
+
...(!ticketState.busy && canEnterOrder && symbol && ticker ? [
|
|
45
35
|
{ id: "side", key: "b/v", label: "side", onPress: actions.toggleSide },
|
|
46
36
|
{ id: "quantity", key: "q", label: "ty", onPress: () => actions.editQuantity().catch(() => {}) },
|
|
47
37
|
{ id: "type", key: "t", label: "ype", onPress: () => actions.editOrderType().catch(() => {}) },
|
|
@@ -52,16 +42,12 @@ export function useTradeTabFooter({
|
|
|
52
42
|
],
|
|
53
43
|
}), [
|
|
54
44
|
actions,
|
|
55
|
-
|
|
56
|
-
nextStep,
|
|
45
|
+
canEnterOrder,
|
|
57
46
|
showLimit,
|
|
58
47
|
showStop,
|
|
59
|
-
statusText,
|
|
60
|
-
statusTone,
|
|
61
48
|
symbol,
|
|
62
49
|
ticketState.busy,
|
|
63
50
|
ticketState.draft,
|
|
64
51
|
ticker,
|
|
65
|
-
workflowTone,
|
|
66
52
|
]);
|
|
67
53
|
}
|