gloomberb 0.19.5 → 0.20.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 +0 -4
- package/package.json +6 -5
- package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
- package/patches/electrobun-devkit@2.0.5.patch +148 -0
- package/src/api-client/bond-trades.ts +59 -0
- package/src/api-client/data.ts +21 -0
- package/src/api-client/equity-screener.ts +23 -0
- package/src/api-client/index.ts +2 -0
- package/src/api-client/types/account.ts +86 -0
- package/src/api-client/types/assist.ts +32 -0
- package/src/api-client/types/auth.ts +63 -0
- package/src/api-client/types/billing.ts +54 -0
- package/src/api-client/types/chat.ts +180 -0
- package/src/api-client/types/congress.ts +107 -0
- package/src/api-client/types/credit.ts +110 -0
- package/src/api-client/types/econ.ts +158 -0
- package/src/api-client/types/equity-diagnostic.ts +73 -0
- package/src/api-client/types/filings-and-calls.ts +350 -0
- package/src/api-client/types/index.ts +25 -0
- package/src/api-client/types/jobs.ts +147 -0
- package/src/api-client/types/market.ts +122 -0
- package/src/api-client/types/news.ts +91 -0
- package/src/api-client/types/notes-and-theses.ts +172 -0
- package/src/api-client/types/quotes.ts +28 -0
- package/src/api-client/types/scanners.ts +125 -0
- package/src/api-client/types/screener.ts +65 -0
- package/src/api-client/types/search.ts +107 -0
- package/src/api-client/types/sync.ts +14 -0
- package/src/api-client/types/team-collections.ts +43 -0
- package/src/api-client/types/team-views.ts +32 -0
- package/src/api-client/types/teams.ts +135 -0
- package/src/api-client/types/ticker-data.ts +57 -0
- package/src/api-client/types/tweets.ts +59 -0
- package/src/api-client/types/world-venues.ts +23 -0
- package/src/app/pane-runtime/index.tsx +2 -0
- package/src/app/pane-runtime/plugin-bindings.ts +10 -1
- package/src/app/runtime/desktop-deeplink.ts +41 -6
- package/src/app/star-prompt/status-line.tsx +1 -1
- package/src/app.tsx +64 -23
- package/src/architecture/ui-tokens-allowlist.json +0 -8
- package/src/cli/commands/market.ts +149 -10
- package/src/cli/commands/search.ts +21 -3
- package/src/cli/commands/ticker.ts +90 -36
- package/src/cli/desktop-pane-shot-browser.ts +69 -3
- package/src/cli/glossary.ts +3 -3
- package/src/cli/known-gaps.ts +8 -0
- package/src/cli/listing-arg.ts +12 -0
- package/src/cli/pane-functions/capabilities.ts +2 -0
- package/src/cli/pane-functions/catalog.ts +25 -5
- package/src/cli/pane-functions/function-help.ts +8 -5
- package/src/cli/pane-functions/headless.ts +4 -3
- package/src/cli/pane-functions/resolver.ts +75 -2
- package/src/cli/quote-answer.ts +9 -0
- package/src/cli/symbol-list.ts +54 -2
- package/src/cli/symbol-rows.ts +14 -2
- package/src/cli/ticker-resolution.ts +89 -20
- package/src/components/chart/composite/axis-overlays.tsx +60 -27
- package/src/components/chart/composite/composite-chart.tsx +118 -63
- package/src/components/chart/composite/cursor-source.ts +111 -0
- package/src/components/chart/composite/format.ts +168 -6
- package/src/components/chart/composite/legend.tsx +8 -4
- package/src/components/chart/composite/panel-labels.ts +20 -1
- package/src/components/chart/composite/panel-surface.tsx +201 -92
- package/src/components/chart/composite/price-axis-labels.tsx +92 -46
- package/src/components/chart/composite/price-series.ts +31 -8
- package/src/components/chart/composite/scene.ts +154 -59
- package/src/components/chart/composite/series-axis-tags.tsx +4 -2
- package/src/components/chart/composite/time-axis.ts +13 -5
- package/src/components/chart/composite/time-scale.ts +211 -56
- package/src/components/chart/composite/types.ts +11 -1
- package/src/components/chart/composite/use-composite-chart-keyboard.ts +43 -14
- package/src/components/chart/curve/curve-surface.tsx +5 -2
- package/src/components/chart/curve/model.ts +4 -1
- package/src/components/chart/native/use-bitmap-metrics.ts +81 -0
- package/src/components/chart/static/series.ts +3 -0
- package/src/components/command-bar/commands/collection-list.ts +81 -0
- package/src/components/command-bar/commands/direct/index.ts +6 -0
- package/src/components/command-bar/commands/registry.ts +8 -0
- package/src/components/command-bar/layout-items/current-layout.ts +22 -1
- package/src/components/command-bar/layout-items/focused-pane.ts +22 -1
- package/src/components/command-bar/pane-templates/items.ts +19 -3
- package/src/components/command-bar/pane-templates/workflow.ts +5 -0
- package/src/components/command-bar/routes/root/results.ts +23 -3
- package/src/components/command-bar/routes/root/selection.ts +4 -2
- package/src/components/command-bar/routes/root/shortcut-feedback.ts +1 -1
- package/src/components/command-bar/routes/root/shortcut-items.ts +3 -4
- package/src/components/command-bar/routes/root/shortcuts.ts +58 -14
- package/src/components/command-bar/routes/root/ticker-first.ts +32 -0
- package/src/components/command-bar/surface/environment.ts +2 -0
- package/src/components/command-bar/view-model.ts +7 -0
- package/src/components/command-bar/workflow/ops.ts +2 -1
- package/src/components/command-bar/workflow/tickers.ts +20 -0
- package/src/components/data-table/export.ts +4 -1
- package/src/components/layout/detached-pane-shell.tsx +10 -37
- package/src/components/layout/double-escape-close.ts +90 -0
- package/src/components/layout/header.tsx +3 -2
- package/src/components/layout/market-summary.ts +6 -3
- package/src/components/layout/pane/footer/index.tsx +2 -6
- package/src/components/layout/pane/footer/model.ts +6 -12
- package/src/components/layout/shell/active-drag.ts +53 -11
- package/src/components/layout/shell/drag/magnets.ts +128 -19
- package/src/components/layout/shell/menu.ts +15 -1
- package/src/components/layout/shell/pane/actions.ts +10 -2
- package/src/components/layout/shell/pane/management-shortcuts.ts +13 -51
- package/src/components/layout/shell/ticker-link-menu.ts +12 -3
- package/src/components/layout/status-bar.tsx +24 -78
- package/src/components/layout/status-widget-space.ts +5 -5
- package/src/components/onboarding/onboarding-keyboard.ts +5 -1
- package/src/components/onboarding/onboarding-wizard.tsx +15 -4
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +9 -6
- package/src/components/onboarding/use-onboarding-progress.ts +20 -1
- package/src/components/price-sparkline/view.tsx +14 -6
- package/src/components/ticker/badge/index.tsx +8 -4
- package/src/components/ticker/badge/list.tsx +23 -7
- package/src/components/ui/column-grid.tsx +8 -2
- package/src/components/ui/data-table/index.tsx +5 -1
- package/src/components/ui/data-table/opentui/model.ts +4 -1
- package/src/components/ui/data-table/render-cell.ts +19 -0
- package/src/components/ui/delayed-mark.tsx +59 -7
- package/src/components/ui/icon.tsx +1 -8
- package/src/components/ui/menu.tsx +6 -1
- package/src/components/ui/tabs.tsx +5 -2
- package/src/core/state/app/layout.ts +18 -3
- package/src/core/state/app/state.ts +2 -0
- package/src/core/state/app/types.ts +5 -0
- package/src/data/config/layout.ts +3 -0
- package/src/data/config/store/normalize.ts +39 -4
- package/src/i18n/es.ts +13 -3
- package/src/i18n/ja.ts +13 -3
- package/src/i18n/ko.ts +13 -3
- package/src/i18n/zh-cn.ts +13 -3
- package/src/i18n/zh-tw.ts +13 -3
- package/src/layout/pane-manager/floating-placement.ts +7 -4
- package/src/layout/pane-manager/floating.ts +5 -2
- package/src/market-data/bond-funds.ts +19 -0
- package/src/market-data/futures-contract.ts +14 -3
- package/src/market-data/market/freshness.ts +18 -0
- package/src/market-data/market/status.ts +15 -2
- package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
- package/src/plugins/builtin/bond-calculator/index.tsx +1 -1
- package/src/plugins/builtin/bond-calculator/model.ts +14 -5
- package/src/plugins/builtin/bond-calculator/pane.tsx +1 -1
- package/src/plugins/builtin/buildout/cells.tsx +25 -45
- package/src/plugins/builtin/buildout/detail/company.tsx +3 -3
- package/src/plugins/builtin/buildout/detail/index.tsx +1 -1
- package/src/plugins/builtin/buildout/detail/intel.tsx +4 -7
- package/src/plugins/builtin/buildout/detail/site.tsx +4 -4
- package/src/plugins/builtin/buildout/detail/ui.tsx +39 -38
- package/src/plugins/builtin/buildout/format.ts +23 -1
- package/src/plugins/builtin/buildout/model/types.ts +1 -0
- package/src/plugins/builtin/buildout/pane/index.tsx +2 -8
- package/src/plugins/builtin/buildout/table-model.ts +12 -4
- package/src/plugins/builtin/cds/headless.ts +1 -0
- package/src/plugins/builtin/cds/index.tsx +1 -1
- package/src/plugins/builtin/chat/content/composer.tsx +21 -27
- package/src/plugins/builtin/chat/content/index.tsx +31 -3
- package/src/plugins/builtin/chat/content/shortcuts.ts +4 -2
- package/src/plugins/builtin/chat/content/snapshot.ts +0 -3
- package/src/plugins/builtin/cloud/auth-actions.tsx +51 -23
- package/src/plugins/builtin/cloud/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +3 -3
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +44 -12
- package/src/plugins/builtin/congress-trades/model.ts +2 -1
- package/src/plugins/builtin/congress-trades/pane.tsx +3 -0
- package/src/plugins/builtin/correlation/headless.ts +3 -2
- package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
- package/src/plugins/builtin/custom-view/index.tsx +1 -1
- package/src/plugins/builtin/custom-view/loader.ts +85 -8
- package/src/plugins/builtin/custom-view/view-spec.ts +28 -0
- package/src/plugins/builtin/debt-maturities/headless.ts +11 -2
- package/src/plugins/builtin/debt-maturities/model.ts +66 -0
- package/src/plugins/builtin/debt-maturities/pane.tsx +23 -4
- package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
- package/src/plugins/builtin/econ/calendar-model.ts +28 -6
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +16 -19
- package/src/plugins/builtin/equity-screener/headless.ts +37 -3
- package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
- package/src/plugins/builtin/equity-screener/model.ts +238 -27
- package/src/plugins/builtin/equity-screener/pane.tsx +88 -18
- package/src/plugins/builtin/equity-screener/screen-check.ts +7 -4
- package/src/plugins/builtin/equity-screener/watchlist.ts +33 -0
- package/src/plugins/builtin/executives/format.ts +5 -4
- package/src/plugins/builtin/executives/pane.tsx +1 -1
- package/src/plugins/builtin/futures-curve/client.ts +19 -0
- package/src/plugins/builtin/futures-curve/headless.ts +52 -13
- package/src/plugins/builtin/futures-curve/index.tsx +1 -1
- package/src/plugins/builtin/futures-curve/model.ts +77 -6
- package/src/plugins/builtin/futures-curve/pane.tsx +19 -3
- package/src/plugins/builtin/help/index.tsx +55 -1
- package/src/plugins/builtin/insider/model.ts +30 -2
- package/src/plugins/builtin/jobs/model.ts +2 -2
- package/src/plugins/builtin/macro-day/client.ts +41 -0
- package/src/plugins/builtin/macro-day/headless.ts +19 -9
- package/src/plugins/builtin/macro-day/model.ts +3 -1
- package/src/plugins/builtin/market-movers/index.tsx +4 -3
- package/src/plugins/builtin/mna/distress/headless.ts +1 -0
- package/src/plugins/builtin/mna/model.ts +2 -2
- package/src/plugins/builtin/notes/files.ts +2 -0
- package/src/plugins/builtin/notes/owner.tsx +20 -1
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +22 -4
- package/src/plugins/builtin/notes/store.ts +6 -1
- package/src/plugins/builtin/perps/pane.tsx +3 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +17 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/header.tsx +1 -1
- package/src/plugins/builtin/rate-path/headless.ts +24 -10
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -25
- package/src/plugins/builtin/research/event-model.ts +10 -3
- package/src/plugins/builtin/research/events-headless.ts +20 -2
- package/src/plugins/builtin/sec/fund-facts.ts +17 -1
- package/src/plugins/builtin/sec/index.tsx +1 -1
- package/src/plugins/builtin/series-inventory.ts +1 -0
- package/src/plugins/builtin/shared/earnings-report.ts +7 -2
- package/src/plugins/builtin/shared/members-menu.tsx +103 -38
- package/src/plugins/builtin/shared/use-quote-board.ts +85 -46
- package/src/plugins/builtin/short-interest/headless.ts +1 -1
- package/src/plugins/builtin/short-interest/model.ts +15 -6
- package/src/plugins/builtin/short-interest/publications-model.ts +22 -1
- package/src/plugins/builtin/short-interest/publications-pane.tsx +13 -4
- package/src/plugins/builtin/short-interest/types.ts +2 -0
- package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
- package/src/plugins/builtin/thirteenf/overlap-pane.tsx +3 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +3 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +5 -3
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +4 -4
- package/src/plugins/builtin/time-sales/pane.tsx +3 -2
- package/src/plugins/builtin/trace-bonds/client.ts +7 -4
- package/src/plugins/builtin/trace-bonds/detail.tsx +198 -0
- package/src/plugins/builtin/trace-bonds/headless.ts +62 -4
- package/src/plugins/builtin/trace-bonds/history.ts +155 -0
- package/src/plugins/builtin/trace-bonds/index.tsx +1 -1
- package/src/plugins/builtin/trace-bonds/pane.tsx +64 -5
- package/src/plugins/builtin/volatility/client.ts +6 -1
- package/src/plugins/builtin/volatility/headless.ts +0 -1
- package/src/plugins/builtin/yield-curve/curves.ts +15 -0
- package/src/plugins/builtin/yield-curve/headless.ts +6 -1
- package/src/plugins/builtin/yield-curve/index.tsx +5 -8
- package/src/plugins/host-modules.ts +22 -3
- package/src/plugins/host-smoke.ts +6 -3
- package/src/plugins/installer.ts +16 -3
- package/src/plugins/plugin-names.ts +11 -2
- package/src/portfolio/collection-name.ts +19 -0
- package/src/remote/controller.ts +9 -2
- package/src/remote/schema.ts +2 -1
- package/src/renderers/browser/http-proxy-transport.ts +78 -8
- package/src/renderers/cloudflare/http-proxy.ts +73 -3
- package/src/renderers/cloudflare/proxy-session.ts +47 -24
- package/src/renderers/cloudflare/worker.ts +44 -4
- package/src/renderers/desktop/geometry.ts +279 -0
- package/src/renderers/desktop/screen-setup.ts +246 -0
- package/src/renderers/desktop/sequential-window-host.ts +179 -0
- package/src/renderers/desktop/test-utils.ts +71 -0
- package/src/renderers/desktop/window-controller.ts +433 -0
- package/src/renderers/desktop/window-host.ts +70 -0
- package/src/renderers/desktop/window-layouts.ts +630 -0
- package/src/renderers/dom/data-frames.ts +15 -4
- package/src/renderers/dom/desktop/icons.tsx +0 -2
- package/src/renderers/dom/styles.css +0 -3
- package/src/renderers/electrobun/bun/application-menu/click.ts +1 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +4 -1
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +19 -8
- package/src/renderers/electrobun/bun/desktop/backend.ts +320 -19
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +4 -14
- package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
- package/src/renderers/electrobun/bun/desktop/install-records.ts +59 -0
- package/src/renderers/electrobun/bun/desktop/installer-folder.ts +208 -592
- package/src/renderers/electrobun/bun/desktop/macos-objc.ts +14 -0
- package/src/renderers/electrobun/bun/desktop/screen-setup-file.ts +55 -0
- package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +44 -8
- package/src/renderers/electrobun/bun/desktop/update.ts +1 -1
- package/src/renderers/electrobun/bun/desktop/workspace/index.ts +298 -97
- package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +44 -6
- package/src/renderers/electrobun/bun/index.ts +22 -109
- package/src/renderers/electrobun/bun/window/create.ts +23 -3
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
- package/src/renderers/electrobun/bun/window/events.ts +4 -4
- package/src/renderers/electrobun/bun/window/focus.ts +0 -25
- package/src/renderers/electrobun/bun/window/frame.ts +2 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +322 -0
- package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
- package/src/renderers/electrobun/shared/protocol.ts +44 -2
- package/src/renderers/electrobun/view/backend-rpc.ts +16 -1
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
- package/src/renderers/electrobun/view/main.tsx +13 -7
- package/src/series/fred-argument.ts +17 -0
- package/src/sources/gloomberb-cloud/index.ts +5 -7
- package/src/sources/provider-router/batches.ts +18 -3
- package/src/sources/provider-router/financial-routes.ts +7 -1
- package/src/sources/provider-router/financials.ts +18 -4
- package/src/state/app/context/index.tsx +16 -2
- package/src/state/desktop-windows.ts +63 -0
- package/src/sync/other-window-tabs.ts +62 -0
- package/src/tickers/company-name-listing.ts +23 -3
- package/src/tickers/listing-fate.ts +147 -1
- package/src/tickers/terminal-codes.ts +5 -0
- package/src/time-series/types.ts +6 -0
- package/src/types/config.ts +10 -1
- package/src/types/data-provider.ts +14 -0
- package/src/types/desktop-window.ts +71 -2
- package/src/types/financials.ts +19 -3
- package/src/types/headless.ts +21 -0
- package/src/types/plugin.ts +6 -0
- package/src/ui/index.tsx +14 -13
- package/src/ui/same-props.ts +58 -0
- package/src/utils/cli-output.ts +33 -4
- package/src/utils/double-escape-close.ts +38 -16
- package/src/utils/format.ts +30 -5
- package/src/utils/futures-generic.ts +12 -0
- package/src/utils/http-proxy-upstream.ts +6 -2
- package/src/utils/plugin-proxy-hosts.json +0 -4
- package/src/utils/plugin-proxy-hosts.ts +22 -0
- package/src/utils/price-earnings.ts +18 -0
- package/src/utils/sec-filings.ts +7 -1
- package/patches/electrobun@1.18.1.patch +0 -633
- package/src/api-client/types.ts +0 -2441
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
observeDesktopDeepLinks,
|
|
39
39
|
} from "../../../api-client/research-activity";
|
|
40
40
|
import { createDesktopWindowBridge } from "./desktop/window/bridge";
|
|
41
|
+
import { setDesktopWindows } from "../../../state/desktop-windows";
|
|
41
42
|
import type { DesktopApplicationMenuBridge } from "../../../types/desktop-menu";
|
|
42
43
|
import { prepareDetachedSnapshot } from "./desktop/window/snapshot";
|
|
43
44
|
import { createElectrobunAppServices } from "./app-services";
|
|
@@ -144,6 +145,9 @@ async function boot() {
|
|
|
144
145
|
backendRequest("capability.invoke", { capabilityId: NOTES_FILES_CAPABILITY_ID, operationId, payload })
|
|
145
146
|
)));
|
|
146
147
|
const init = await measurePerfAsync("startup.electrobun.backend-init", () => backendInitPromise);
|
|
148
|
+
// The main window does the app-wide work (account sync, the Dock badge,
|
|
149
|
+
// remote control, the boot frame); every other window draws its tabs.
|
|
150
|
+
const primaryWindow = init.windowKind === "main" && (init.windowId ?? "main") === "main";
|
|
147
151
|
// The environment's opt-out comes from the Bun process; the config
|
|
148
152
|
// switches are read live, so the command bar toggles apply at once.
|
|
149
153
|
installCrashReporter({
|
|
@@ -163,16 +167,16 @@ async function boot() {
|
|
|
163
167
|
installAttentionCounter({
|
|
164
168
|
allowed: () => !init.telemetry.optedOut && !browserDoNotTrack(),
|
|
165
169
|
launchConfig: () => init.config,
|
|
166
|
-
//
|
|
167
|
-
...(
|
|
170
|
+
// Only the main window syncs, and sends the other windows the settings it pulled.
|
|
171
|
+
...(!primaryWindow ? { accountSettingsPulled: () => true } : {}),
|
|
168
172
|
});
|
|
169
173
|
// Desktop has no Debug Log: this window's freezes go to the Bun process, which keeps the stall log.
|
|
170
174
|
setStallSink(forwardAttendedStalls(sendElectrobunStall).sink);
|
|
171
175
|
installElectrobunCapabilityStreamClient();
|
|
172
176
|
installFocusScopeRelease();
|
|
173
177
|
installElectrobunWindowFullscreenTracking();
|
|
174
|
-
if (
|
|
175
|
-
installDomMarketDataFrames();
|
|
178
|
+
if (primaryWindow) installElectrobunAppBadgeHost();
|
|
179
|
+
installDomMarketDataFrames((listener) => onBackendMessage("desktop.windowVisibility", ({ visible }) => listener(visible)));
|
|
176
180
|
installScreenshotWatermark();
|
|
177
181
|
const desktopSnapshot = init.windowKind === "detached" && init.paneId && init.desktopSnapshot
|
|
178
182
|
? prepareDetachedSnapshot(init.desktopSnapshot, init.paneId)
|
|
@@ -182,6 +186,8 @@ async function boot() {
|
|
|
182
186
|
// Said by the app once it is up, as the terminal says it.
|
|
183
187
|
setPluginSeedNotice(init.pluginSeedNotice ?? null);
|
|
184
188
|
const desktopWindowBridge = createDesktopWindowBridge(init.windowKind, init.paneId);
|
|
189
|
+
// Menus and the command bar offer the other windows from here.
|
|
190
|
+
setDesktopWindows(desktopWindowBridge.windows ?? null);
|
|
185
191
|
const desktopApplicationMenuBridge: DesktopApplicationMenuBridge = {
|
|
186
192
|
subscribe: (listener) => onBackendMessage("application-menu.select", ({ command }) => listener(command)),
|
|
187
193
|
};
|
|
@@ -190,7 +196,7 @@ async function boot() {
|
|
|
190
196
|
// id is made at the first push, and a gloom.sh link can bring a visitor id.
|
|
191
197
|
const viewStorage = viewIdStorage();
|
|
192
198
|
if (viewStorage) restoreViewIds(viewStorage, init.viewIds);
|
|
193
|
-
const mirrorViewIds = viewStorage &&
|
|
199
|
+
const mirrorViewIds = viewStorage && primaryWindow
|
|
194
200
|
? createViewIdMirror(viewStorage, init.viewIds, (ids) => backendRequest("host.saveViewIds", { ids }))
|
|
195
201
|
: () => {};
|
|
196
202
|
mirrorViewIds();
|
|
@@ -257,7 +263,7 @@ async function boot() {
|
|
|
257
263
|
if (marketplace) void activateUpdatedPlugins(directories, marketplace, pluginManager);
|
|
258
264
|
});
|
|
259
265
|
|
|
260
|
-
const remoteControlAdapter =
|
|
266
|
+
const remoteControlAdapter = primaryWindow
|
|
261
267
|
? {
|
|
262
268
|
registerHandler: setElectrobunRemoteRequestHandler,
|
|
263
269
|
terminalDevice: { kind: "desktop" as const, name: init.hostName?.trim() || "Gloom desktop" },
|
|
@@ -292,7 +298,7 @@ async function boot() {
|
|
|
292
298
|
});
|
|
293
299
|
// A layout with neither panes nor a status bar has nothing to wait for.
|
|
294
300
|
window.setTimeout(releaseBootFrame, BOOT_FRAME_RELEASE_FALLBACK_MS);
|
|
295
|
-
if (
|
|
301
|
+
if (primaryWindow) {
|
|
296
302
|
startBootFrameRecorder({
|
|
297
303
|
doc: document,
|
|
298
304
|
root: appRootElement,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isKnownExchangeCode } from "../utils/exchanges";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The FRED series a typed `FRED:<id>` names (`FRED:T10Y2Y` is T10Y2Y), as the
|
|
5
|
+
* catalog and `fn G` write a series: never the symbol FRED on a venue called
|
|
6
|
+
* T10Y2Y. A venue the app knows (`FRED:TSXV`) is that listing, so null, as is
|
|
7
|
+
* any other text.
|
|
8
|
+
*/
|
|
9
|
+
export function fredSeriesArgument(text: string): string | null {
|
|
10
|
+
const id = /^FRED:([A-Z0-9_]+)$/i.exec(text.trim())?.[1]?.toUpperCase();
|
|
11
|
+
return id && !isKnownExchangeCode(id) ? id : null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** What a command that reads listings says to `FRED:T10Y2Y`: it is a series, and where series are read. */
|
|
15
|
+
export function fredSeriesNotListing(id: string): { message: string; details: string } {
|
|
16
|
+
return { message: `FRED:${id} is a FRED series, not a listing.`, details: `Chart it with gloom fn G FRED:${id}, or read it with gloom fred ${id}.` };
|
|
17
|
+
}
|
|
@@ -618,13 +618,11 @@ export class GloomberbCloudProvider implements AssetDataProvider {
|
|
|
618
618
|
const { matched, missing } = matchCloudBatchItems(submitted, payload.items);
|
|
619
619
|
return [...rejected, ...matched.map(({ target, item }) => {
|
|
620
620
|
// A successful batch can contain an expired cache fallback for only
|
|
621
|
-
// one listing
|
|
622
|
-
//
|
|
623
|
-
//
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
return { target, quote: null, error: createProviderMiss(`Cloud quotes are stale for ${target.symbol}`) };
|
|
627
|
-
}
|
|
621
|
+
// one listing: the last price the service has, flagged stale as the
|
|
622
|
+
// single-quote route flags it. No freshness check passes it, so the
|
|
623
|
+
// router asks for that listing alone and keeps this price only when
|
|
624
|
+
// that read brings none. A listing that no longer trades has only
|
|
625
|
+
// that last quote too.
|
|
628
626
|
if ((item.status === "success" || item.status === "partial") && item.data) {
|
|
629
627
|
const answered = mapQuote(item.data);
|
|
630
628
|
if (pricesOtherListing(answered, cloudInstrumentTarget(target.symbol, target.exchange))) {
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
hasRecentFinancialProfileAttempt,
|
|
22
22
|
hasDetailedStatementRows,
|
|
23
23
|
isProviderQuoteUsableForCurrentSession,
|
|
24
|
+
lastKnownProviderQuote,
|
|
24
25
|
providerFinancialsMatchTarget,
|
|
25
26
|
quoteWithFreshnessExchange,
|
|
26
27
|
type CachedFinancialsSelection,
|
|
@@ -58,6 +59,8 @@ export class ProviderRouterBatchRoutes {
|
|
|
58
59
|
const providerOptions = { forceRefresh: options.forceRefresh };
|
|
59
60
|
const forceRefresh = options.forceRefresh === true;
|
|
60
61
|
const results = new Array<QuoteBatchResult | null>(targets.length).fill(null);
|
|
62
|
+
// A dated price the batch answered that is not current: shown, flagged stale, when asking alone brings none.
|
|
63
|
+
const lastKnown = new Array<Quote | null>(targets.length).fill(null);
|
|
61
64
|
const misses: Array<{ index: number; target: QuoteSubscriptionTarget }> = [];
|
|
62
65
|
|
|
63
66
|
targets.forEach((target, index) => {
|
|
@@ -104,8 +107,12 @@ export class ProviderRouterBatchRoutes {
|
|
|
104
107
|
return logFailure("sources.provider-router.batches", "Loading batch quotes failed", [] as QuoteBatchResult[])(error);
|
|
105
108
|
});
|
|
106
109
|
for (const item of batchResults) {
|
|
107
|
-
if (!isProviderQuoteUsableForCurrentSession(item.quote, item.target.exchange, item.target.symbol, { recentAnswer: true })) continue;
|
|
108
110
|
const key = this.quoteBatchKey(item.target);
|
|
111
|
+
if (!isProviderQuoteUsableForCurrentSession(item.quote, item.target.exchange, item.target.symbol, { recentAnswer: true })) {
|
|
112
|
+
const fallback = lastKnownProviderQuote(item.quote, item.target.exchange, item.target.symbol);
|
|
113
|
+
if (fallback) for (const entry of providerIndexes.get(key) ?? []) lastKnown[entry.index] = fallback;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
109
116
|
const sourceKey = this.deps.providerSourceKey(batchProvider);
|
|
110
117
|
for (const entry of providerIndexes.get(key) ?? []) {
|
|
111
118
|
const entityKey = this.deps.getEntityKey(entry.target.symbol, entry.target.context?.instrument);
|
|
@@ -119,16 +126,24 @@ export class ProviderRouterBatchRoutes {
|
|
|
119
126
|
// The batch never reached the data service: a copy saved a moment ago is still a saved copy, not the
|
|
120
127
|
// service's answer, so each is asked for as a refresh, which fails at once and says it answers from that copy.
|
|
121
128
|
const unreached = isNetworkFailure(batchFailure) ? new Set(providerMisses.map(({ index }) => index)) : null;
|
|
129
|
+
const followUp = (index: number): "default" | "refresh" => (forceRefresh || unreached?.has(index) ? "refresh" : "default");
|
|
130
|
+
if (options.deferFollowUps) {
|
|
131
|
+
for (const { index, target } of misses) {
|
|
132
|
+
results[index] ??= { target, quote: lastKnown[index] ?? null, followUp: followUp(index) };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
122
135
|
await Promise.all(misses.map(async ({ index, target }) => {
|
|
123
136
|
if (results[index]) return;
|
|
124
137
|
try {
|
|
125
138
|
const quote = await this.deps.getQuote(target.symbol, target.exchange, {
|
|
126
139
|
...target.context,
|
|
127
|
-
cacheMode:
|
|
140
|
+
cacheMode: followUp(index),
|
|
128
141
|
});
|
|
129
142
|
results[index] = { target, quote };
|
|
130
143
|
} catch (error) {
|
|
131
|
-
|
|
144
|
+
// Asked alone it brought nothing: the batch's dated price, flagged stale, rather than none, as the quote route answers.
|
|
145
|
+
const fallback = lastKnown[index];
|
|
146
|
+
results[index] = fallback ? { target, quote: fallback } : { target, quote: null, error };
|
|
132
147
|
}
|
|
133
148
|
}));
|
|
134
149
|
|
|
@@ -110,12 +110,18 @@ export class ProviderRouterFinancialRoutes {
|
|
|
110
110
|
exchange?: string,
|
|
111
111
|
context?: MarketDataRequestContext,
|
|
112
112
|
): Promise<TickerFinancials> {
|
|
113
|
+
// An index files no statements, so its financials come back without a
|
|
114
|
+
// quote: the quote is asked beside them, not a round trip after.
|
|
115
|
+
const indexQuote = ticker.startsWith("^") ? this.getQuote(ticker, exchange, context) : null;
|
|
116
|
+
indexQuote?.catch(() => {
|
|
117
|
+
// Intentional ignore: the quote is awaited below when the financials lack one, and its failure handled there.
|
|
118
|
+
});
|
|
113
119
|
const financials = await this.loadTickerFinancials(ticker, exchange, context);
|
|
114
120
|
if (financials.quote) return financials;
|
|
115
121
|
// Statement depth does not establish quote freshness. Use the same quote
|
|
116
122
|
// fallback route as QQ, including its cache and broker/listing context.
|
|
117
123
|
try {
|
|
118
|
-
const quote = await this.getQuote(ticker, exchange, context);
|
|
124
|
+
const quote = await (indexQuote ?? this.getQuote(ticker, exchange, context));
|
|
119
125
|
return resolveTickerFinancialsQuoteState(financials, quote) ?? financials;
|
|
120
126
|
} catch {
|
|
121
127
|
// Delisted or temporarily unquoted issuers can still have valid accounts.
|
|
@@ -443,7 +443,15 @@ function mergeDefinedObject<T extends object>(preferred: T | null | undefined, f
|
|
|
443
443
|
return Object.fromEntries(mergedEntries) as T;
|
|
444
444
|
}
|
|
445
445
|
|
|
446
|
-
|
|
446
|
+
/** Forward P/E, its consensus EPS and the year it is for: one observation, never pieced together from two. */
|
|
447
|
+
const FORWARD_FIELDS = ["forwardPE", "forwardEps", "forwardEpsCurrency", "forwardEpsPeriodEnd", "forwardEpsObservedAt"] as const;
|
|
448
|
+
|
|
449
|
+
/** A block that read next year's consensus says what it found, even none: its forward fields stand whole. */
|
|
450
|
+
function readsConsensus(fundamentals: Fundamentals | undefined): boolean {
|
|
451
|
+
return fundamentals?.forwardEpsPeriodEnd !== undefined;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function setOrDelete<K extends "dividendRate" | (typeof FORWARD_FIELDS)[number]>(target: Fundamentals, key: K, value: Fundamentals[K]): void {
|
|
447
455
|
if (value === undefined) delete target[key];
|
|
448
456
|
else target[key] = value;
|
|
449
457
|
}
|
|
@@ -483,10 +491,14 @@ function mergeFundamentals(primary: Fundamentals | undefined, fallback: Fundamen
|
|
|
483
491
|
merged.dividendYieldSource = dividend.dividendYieldSource;
|
|
484
492
|
setOrDelete(merged, "dividendRate", dividend.dividendRate);
|
|
485
493
|
}
|
|
486
|
-
const forward = primary?.forwardPE != null ? primary : fallback;
|
|
494
|
+
const forward = primary?.forwardPE != null || readsConsensus(primary) ? primary : fallback;
|
|
487
495
|
// Forward EPS reprices the forward multiple, so it pairs with that multiple's
|
|
488
|
-
// observation; a withdrawn one never comes back from an older fallback
|
|
489
|
-
|
|
496
|
+
// observation; a withdrawn one never comes back from an older fallback, and
|
|
497
|
+
// a consensus that is a loss or none never takes an older multiple.
|
|
498
|
+
if (merged && forward) {
|
|
499
|
+
if (readsConsensus(forward)) for (const key of FORWARD_FIELDS) setOrDelete(merged, key, forward[key]);
|
|
500
|
+
else setOrDelete(merged, "forwardEps", forward.forwardEps);
|
|
501
|
+
}
|
|
490
502
|
if (merged && primary && !primary.financialCurrency && [
|
|
491
503
|
primary.revenue, primary.netIncome, primary.operatingCashFlow, primary.freeCashFlow, primary.eps,
|
|
492
504
|
].some((value) => value != null)) {
|
|
@@ -576,6 +588,8 @@ export function mergeRefreshedFinancials(cached: TickerFinancials, fresh: Ticker
|
|
|
576
588
|
if (!currencyConflict && typeof statistics[field] === "number" && Number.isFinite(statistics[field])) update[field] = statistics[field];
|
|
577
589
|
}
|
|
578
590
|
if (!currencyConflict && statistics.enterpriseValueCheck) update.enterpriseValueCheck = statistics.enterpriseValueCheck;
|
|
591
|
+
// Fresh statistics that read next year's consensus replace the forward figures whole, a loss or none included.
|
|
592
|
+
if (readsConsensus(statistics)) for (const key of FORWARD_FIELDS) if (statistics[key] !== undefined) update[key] = statistics[key] as never;
|
|
579
593
|
let fundamentals = mergeFundamentals(update, merged.fundamentals);
|
|
580
594
|
// The source serving a multiple or yield without its per-share base has
|
|
581
595
|
// withdrawn that base, so an older one must not keep repricing the figure.
|
|
@@ -52,6 +52,7 @@ export {
|
|
|
52
52
|
getEffectiveThemeId,
|
|
53
53
|
getFocusedCollectionId,
|
|
54
54
|
getFocusedTickerSymbol,
|
|
55
|
+
linkedSourceIds,
|
|
55
56
|
resolveCollectionForPane,
|
|
56
57
|
syncConfigActiveLayoutState,
|
|
57
58
|
resolveTickerForPane,
|
|
@@ -464,6 +465,9 @@ export function AppProvider({
|
|
|
464
465
|
const storeRef = useRef<AppContextStoreValue | null>(null);
|
|
465
466
|
const lastMainSyncRef = useRef<string | null>(null);
|
|
466
467
|
const latestMainStateRevisionRef = useRef(desktopSnapshot?.mainStateRevision ?? 0);
|
|
468
|
+
// The last state this window took from the desktop process. Its syncs name
|
|
469
|
+
// it, so what another window changed since is not undone by this one.
|
|
470
|
+
const lastTakenStateSeqRef = useRef<number | null>(desktopSnapshot?.stateSeq ?? null);
|
|
467
471
|
const lastDetachedPaneSyncRef = useRef<string | null>(null);
|
|
468
472
|
const lastThemePreviewSyncRef = useRef<string | null | undefined>(undefined);
|
|
469
473
|
|
|
@@ -490,12 +494,15 @@ export function AppProvider({
|
|
|
490
494
|
rawDispatch(dispatchedAction);
|
|
491
495
|
}, [desktopBridge, rawDispatch]);
|
|
492
496
|
|
|
497
|
+
// The linked tickers go back as they came, so the desktop process knows
|
|
498
|
+
// this window holds them; it never reads them from a window.
|
|
493
499
|
const buildDesktopSnapshot = useCallback((currentState: AppState): DesktopSharedStateSnapshot => ({
|
|
494
500
|
config: currentState.config,
|
|
495
501
|
paneState: currentState.paneState,
|
|
496
502
|
focusedPaneId: currentState.focusedPaneId,
|
|
497
503
|
statusBarVisible: currentState.statusBarVisible,
|
|
498
504
|
brokerSyncErrors: currentState.brokerSyncErrors,
|
|
505
|
+
...(currentState.linkedTickers ? { linkedTickers: currentState.linkedTickers } : {}),
|
|
499
506
|
}), []);
|
|
500
507
|
|
|
501
508
|
const serializeDesktopSnapshot = useCallback((snapshot: DesktopSharedStateSnapshot): string => JSON.stringify({
|
|
@@ -504,6 +511,7 @@ export function AppProvider({
|
|
|
504
511
|
focusedPaneId: snapshot.focusedPaneId,
|
|
505
512
|
statusBarVisible: snapshot.statusBarVisible,
|
|
506
513
|
brokerSyncErrors: snapshot.brokerSyncErrors ?? {},
|
|
514
|
+
linkedTickers: snapshot.linkedTickers ?? {},
|
|
507
515
|
}), []);
|
|
508
516
|
|
|
509
517
|
const serializePaneState = useCallback((paneState: PaneRuntimeState | undefined): string => JSON.stringify(paneState ?? {}), []);
|
|
@@ -559,6 +567,7 @@ export function AppProvider({
|
|
|
559
567
|
snapshot.mainStateRevision,
|
|
560
568
|
);
|
|
561
569
|
}
|
|
570
|
+
if (typeof snapshot.stateSeq === "number") lastTakenStateSeqRef.current = snapshot.stateSeq;
|
|
562
571
|
const currentSignature = serializeDesktopSnapshot(buildDesktopSnapshot(stateRef.current));
|
|
563
572
|
const nextSignature = serializeDesktopSnapshot(snapshot);
|
|
564
573
|
if (currentSignature === nextSignature) return;
|
|
@@ -582,7 +591,10 @@ export function AppProvider({
|
|
|
582
591
|
// a newer one has replaced it, so the next effect run sends it again. The
|
|
583
592
|
// two syncs below dedupe the same way.
|
|
584
593
|
fireAndForget(
|
|
585
|
-
desktopBridge.syncMainState(
|
|
594
|
+
desktopBridge.syncMainState(
|
|
595
|
+
{ ...snapshot, mainStateRevision: latestMainStateRevisionRef.current },
|
|
596
|
+
lastTakenStateSeqRef.current,
|
|
597
|
+
),
|
|
586
598
|
"desktop.syncMainState",
|
|
587
599
|
() => {
|
|
588
600
|
if (lastMainSyncRef.current === signature) lastMainSyncRef.current = null;
|
|
@@ -609,9 +621,11 @@ export function AppProvider({
|
|
|
609
621
|
});
|
|
610
622
|
}, [desktopBridge, state.themePreview]);
|
|
611
623
|
|
|
624
|
+
// Every window previews the theme Settings is trying out in another one.
|
|
612
625
|
useEffect(() => {
|
|
613
|
-
if (desktopBridge?.
|
|
626
|
+
if (!desktopBridge?.subscribeThemePreview) return;
|
|
614
627
|
return desktopBridge.subscribeThemePreview((preview) => {
|
|
628
|
+
lastThemePreviewSyncRef.current = preview.theme;
|
|
615
629
|
dispatch({ type: "PREVIEW_THEME", theme: preview.theme });
|
|
616
630
|
});
|
|
617
631
|
}, [desktopBridge, dispatch]);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { t, tf } from "../i18n";
|
|
2
|
+
import type { DesktopWindowInfo, DesktopWindowsBridge, DesktopWindowTarget } from "../types/desktop-window";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The desktop app's full windows, as the window this runs in sees them: set
|
|
6
|
+
* once at startup by the desktop view, absent in the terminal, the browser
|
|
7
|
+
* and a popped-out pane's window. Menus and the command bar read it when
|
|
8
|
+
* they open.
|
|
9
|
+
*/
|
|
10
|
+
let desktopWindows: DesktopWindowsBridge | null = null;
|
|
11
|
+
|
|
12
|
+
export function setDesktopWindows(bridge: DesktopWindowsBridge | null): void {
|
|
13
|
+
desktopWindows = bridge;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getDesktopWindows(): DesktopWindowsBridge | null {
|
|
17
|
+
return desktopWindows;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function windowLabel(info: DesktopWindowInfo): string {
|
|
21
|
+
return info.number <= 1 ? t("Main Window") : tf("Window {number}", { number: String(info.number) });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A place a tab or pane of this window can go. Labels are ready to show. */
|
|
25
|
+
export interface WindowMoveTarget {
|
|
26
|
+
key: string;
|
|
27
|
+
label: string;
|
|
28
|
+
/** The tab the other window shows, to tell windows apart. */
|
|
29
|
+
detail?: string;
|
|
30
|
+
target: DesktopWindowTarget;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Each other window, then a new one; empty where there is only one window and nothing can go. */
|
|
34
|
+
export function windowMoveTargets(
|
|
35
|
+
bridge: DesktopWindowsBridge,
|
|
36
|
+
options: { newWindow?: boolean; prefix?: "pane" | "layout" } = {},
|
|
37
|
+
): WindowMoveTarget[] {
|
|
38
|
+
const layout = options.prefix === "layout";
|
|
39
|
+
const others = bridge.list().filter((info) => info.id !== bridge.windowId);
|
|
40
|
+
const targets: WindowMoveTarget[] = others.map((info) => ({
|
|
41
|
+
key: info.id,
|
|
42
|
+
label: tf(layout ? "Move Layout to {window}" : "Move to {window}", { window: windowLabel(info) }),
|
|
43
|
+
...(info.activeLayoutName ? { detail: info.activeLayoutName } : {}),
|
|
44
|
+
target: { windowId: info.id },
|
|
45
|
+
}));
|
|
46
|
+
if (options.newWindow !== false) {
|
|
47
|
+
targets.push({
|
|
48
|
+
key: "new",
|
|
49
|
+
label: layout ? "Move Layout to New Window" : "Move to New Window",
|
|
50
|
+
target: { newWindow: true },
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return targets;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Where one of this window's tabs can go: the main window keeps its last
|
|
58
|
+
* tab, and a window's only tab gains nothing from a new window of its own.
|
|
59
|
+
*/
|
|
60
|
+
export function layoutMoveTargets(bridge: DesktopWindowsBridge, tabCount: number): WindowMoveTarget[] {
|
|
61
|
+
if (tabCount <= 1 && bridge.windowId === "main") return [];
|
|
62
|
+
return windowMoveTargets(bridge, { prefix: "layout", newWindow: tabCount > 1 });
|
|
63
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { AppState } from "../core/state/app/state";
|
|
2
|
+
import type { AppConfig } from "../types/config";
|
|
3
|
+
import type { OtherWindowTab } from "../types/desktop-window";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Cloud sync runs in the desktop app's main window, whose state holds only
|
|
7
|
+
* its own tabs while other windows are open. Sync sees every window's tabs:
|
|
8
|
+
* the main window's as it has them now, the others' at their places among
|
|
9
|
+
* them. Without this, a push would leave out the tabs in other windows, and
|
|
10
|
+
* other devices would take them as deleted.
|
|
11
|
+
*
|
|
12
|
+
* The same state, unchanged, with one window, in the terminal and the browser.
|
|
13
|
+
*/
|
|
14
|
+
export function withOtherWindowTabs(state: AppState, others: readonly OtherWindowTab[]): AppState {
|
|
15
|
+
if (others.length === 0) return state;
|
|
16
|
+
const own = state.config.layouts;
|
|
17
|
+
const layouts = [...own];
|
|
18
|
+
for (const { at, tab } of [...others].sort((a, b) => a.at - b.at)) {
|
|
19
|
+
// A pulled copy the main window holds for a moment, until the backend gives it back to its window.
|
|
20
|
+
if (tab.id && layouts.some((entry) => entry.id === tab.id)) continue;
|
|
21
|
+
layouts.splice(Math.min(at, layouts.length), 0, tab);
|
|
22
|
+
}
|
|
23
|
+
const active = own[state.config.activeLayoutIndex];
|
|
24
|
+
const activeLayoutIndex = active ? layouts.indexOf(active) : state.config.activeLayoutIndex;
|
|
25
|
+
return { ...state, config: { ...state.config, layouts, activeLayoutIndex: Math.max(0, activeLayoutIndex) } };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Whether a config sync applies changes a tab another window holds. The whole
|
|
30
|
+
* config is then saved at once: the backend keeps such a tab in its window
|
|
31
|
+
* and takes the change where the pull made it. A later save of the main
|
|
32
|
+
* window's own tabs would not carry it.
|
|
33
|
+
*/
|
|
34
|
+
export function changesOtherWindowTabs(config: AppConfig, others: readonly OtherWindowTab[]): boolean {
|
|
35
|
+
const pulled = new Map(config.layouts.flatMap((entry) => (entry.id ? [[entry.id, entry] as const] : [])));
|
|
36
|
+
return others.some(({ tab }) => {
|
|
37
|
+
const next = tab.id ? pulled.get(tab.id) : undefined;
|
|
38
|
+
return !!next && JSON.stringify(next) !== JSON.stringify(tab);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A config sync applies, as the main window keeps it: without the other
|
|
44
|
+
* windows' tabs, which reach their windows through the whole config saved
|
|
45
|
+
* (`changesOtherWindowTabs`). The main window stays on the tab it shows when
|
|
46
|
+
* that tab is still there.
|
|
47
|
+
*/
|
|
48
|
+
export function withoutOtherWindowTabs(config: AppConfig, others: readonly OtherWindowTab[], current: AppConfig): AppConfig {
|
|
49
|
+
const ids = new Set(others.flatMap(({ tab }) => (tab.id ? [tab.id] : [])));
|
|
50
|
+
if (ids.size === 0) return config;
|
|
51
|
+
const layouts = config.layouts.filter((entry) => !entry.id || !ids.has(entry.id));
|
|
52
|
+
if (layouts.length === config.layouts.length || layouts.length === 0) return config;
|
|
53
|
+
const shownId = current.layouts[current.activeLayoutIndex]?.id;
|
|
54
|
+
const active = config.layouts[config.activeLayoutIndex];
|
|
55
|
+
const byShown = shownId ? layouts.findIndex((entry) => entry.id === shownId) : -1;
|
|
56
|
+
const byActive = active ? layouts.indexOf(active) : -1;
|
|
57
|
+
const activeLayoutIndex = byActive >= 0 ? byActive : byShown >= 0 ? byShown : 0;
|
|
58
|
+
const shown = layouts[activeLayoutIndex]!;
|
|
59
|
+
// The live layout is the shown tab's: one of another window's tabs would draw here.
|
|
60
|
+
const layout = byActive >= 0 ? config.layout : shown.layout;
|
|
61
|
+
return { ...config, layouts, activeLayoutIndex, layout };
|
|
62
|
+
}
|
|
@@ -253,6 +253,20 @@ export async function marksAnotherListing(dataProvider: Partial<Pick<DataProvide
|
|
|
253
253
|
result.symbol.toUpperCase() !== word.trim().toUpperCase() && namedByService(word, result));
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
/**
|
|
257
|
+
* The listing of `symbol` the service marks with `word` (`^VIX` on CXI for
|
|
258
|
+
* "VIX"), as `marksAnotherListing` reads the same search; null when search
|
|
259
|
+
* marks no listing of it, cannot search or is too busy to say.
|
|
260
|
+
*/
|
|
261
|
+
export async function serviceMarkedListing(dataProvider: Partial<Pick<DataProvider, "search">>, word: string,
|
|
262
|
+
symbol: string): Promise<{ symbol: string; exchange: string; name: string } | null> {
|
|
263
|
+
if (typeof dataProvider.search !== "function") return null;
|
|
264
|
+
const answer = await searchListings(dataProvider as Pick<DataProvider, "search">, word.trim());
|
|
265
|
+
const marked = Array.isArray(answer) ? answer.find((result) => result.symbol.toUpperCase() === symbol.toUpperCase()
|
|
266
|
+
&& namedByService(word, result)) : undefined;
|
|
267
|
+
return marked ? { symbol: marked.symbol.toUpperCase(), exchange: listedExchange(marked), name: marked.name } : null;
|
|
268
|
+
}
|
|
269
|
+
|
|
256
270
|
function searchListings(dataProvider: Pick<DataProvider, "search">, query: string): Promise<InstrumentSearchResult[] | ProviderBusyError> {
|
|
257
271
|
return dataProvider.search(query, { limit: LISTING_SEARCH_LIMIT })
|
|
258
272
|
.catch((error: unknown): InstrumentSearchResult[] | ProviderBusyError => {
|
|
@@ -307,8 +321,10 @@ const shareClassSymbol = (symbol: string) => symbol.trim().toUpperCase().replace
|
|
|
307
321
|
* be too ("Putnam US Equity", "Global US Equity"), so one for the US, or typed
|
|
308
322
|
* in lower case, is one only when search lists its root there (JPM on a US
|
|
309
323
|
* exchange, VOD on LSE); otherwise it is the name it reads as, and is searched
|
|
310
|
-
* as one. One in capitals naming a venue abroad (`MC FP`)
|
|
311
|
-
*
|
|
324
|
+
* as one. One in capitals naming a venue abroad (`MC FP`), or the US with its
|
|
325
|
+
* yellow key as the terminal writes it (`SEAS US Equity`, never all in
|
|
326
|
+
* capitals), is one as typed: the venue's own check speaks
|
|
327
|
+
* when the symbol is not there. A code that can name
|
|
312
328
|
* several listings (`VOLVB SS` is VOLVB or VOLV.B in Stockholm, `RY CN`
|
|
313
329
|
* Toronto or the Venture exchange) is the first of them search lists. A
|
|
314
330
|
* search that fails says nothing either way, and the code stands. Null for
|
|
@@ -321,7 +337,11 @@ export async function readTerminalCodeArg(
|
|
|
321
337
|
const code = readTerminalListingCode(typed);
|
|
322
338
|
if (!code?.market) return code;
|
|
323
339
|
const us = !code.exchange || isUsListingExchange(code.exchange);
|
|
324
|
-
|
|
340
|
+
// Its root in capitals and its yellow key typed as the terminal shows it (`SEAS US Equity`), a US code is one as
|
|
341
|
+
// typed, as a code abroad is: a line that stopped trading is one search no longer lists, and it is still that
|
|
342
|
+
// symbol, never a name. All in capitals (`PUTNAM US EQUITY`) it may be a fund's name, so search decides.
|
|
343
|
+
const keyed = /\s[Ee]quity$/.test(code.typed) && !/\p{Ll}/u.test(code.typed.split(" ")[0]!);
|
|
344
|
+
const verify = (us && !keyed) || /\p{Ll}/u.test(code.typed.split(" ")[0]!);
|
|
325
345
|
if (!verify && !code.alternatives) return code;
|
|
326
346
|
const listings: TerminalListing[] = [code, ...code.alternatives ?? []];
|
|
327
347
|
try {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { logFailure } from "../utils/log-failure";
|
|
2
2
|
import type { DataProvider } from "../types/data-provider";
|
|
3
|
-
import type { Quote } from "../types/financials";
|
|
3
|
+
import type { CompanyProfile, ListingDelisting, PricePoint, Quote } from "../types/financials";
|
|
4
|
+
import { savedCopyAt } from "../data/saved-copies";
|
|
5
|
+
import { sameCompany } from "./company-name";
|
|
4
6
|
import type { TickerChanges } from "../types/ticker-changes";
|
|
5
7
|
import {
|
|
6
8
|
describeFormerIssuer,
|
|
@@ -77,6 +79,150 @@ export function noLongerTradingNote(label: string, quote: Quote, now = Date.now(
|
|
|
77
79
|
: `${label}: no longer trading since ${date} (last price ${price})`;
|
|
78
80
|
}
|
|
79
81
|
|
|
82
|
+
// A listing with no quote whose newest bar is this old has not traded since; a newer one is a quiet month.
|
|
83
|
+
const NO_QUOTE_ENDED_AFTER_MS = 30 * 24 * 60 * 60_000;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* When a listing the service has no quote for last traded, and whether the
|
|
87
|
+
* service says it no longer trades. `recorded`: its history carries the
|
|
88
|
+
* service's delisting record, whose last day wins over the bars. Otherwise
|
|
89
|
+
* only its newest bar, over 30 days old, says it: a retired line and a thin
|
|
90
|
+
* one that has not traded in a month look alike, so that says no more than
|
|
91
|
+
* "no trades since".
|
|
92
|
+
*/
|
|
93
|
+
export interface NoQuoteLastTrade {
|
|
94
|
+
date: string;
|
|
95
|
+
recorded: boolean;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* When a listing the service has no quote for last traded (`NoQuoteLastTrade`).
|
|
100
|
+
* Null for one that traded within the month, has no bars, or whose bars are a
|
|
101
|
+
* copy saved earlier because the refresh failed: the age of a saved copy's
|
|
102
|
+
* bars says when it was saved, not that the listing stopped.
|
|
103
|
+
*/
|
|
104
|
+
export function noQuoteLastTraded(
|
|
105
|
+
history: { points: readonly Pick<PricePoint, "date">[]; delisting?: ListingDelisting; savedCopyBehind?: true },
|
|
106
|
+
now = Date.now(),
|
|
107
|
+
): NoQuoteLastTrade | null {
|
|
108
|
+
if (history.delisting) return { date: history.delisting.lastTradeDate, recorded: true };
|
|
109
|
+
if (history.savedCopyBehind || savedCopyAt(history) != null) return null;
|
|
110
|
+
const newest = Math.max(...history.points.map((point) => new Date(point.date).getTime()).filter(Number.isFinite));
|
|
111
|
+
return Number.isFinite(newest) && now - newest > NO_QUOTE_ENDED_AFTER_MS
|
|
112
|
+
? { date: new Date(newest).toISOString().slice(0, 10), recorded: false }
|
|
113
|
+
: null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** "FLAT last traded 2020-06-03; no longer listed": what `quote`, `ticker`, `history` and `search` say of such a listing. */
|
|
117
|
+
export function noLongerListedNote(symbol: string, lastTraded: string): string {
|
|
118
|
+
return `${symbol} last traded ${lastTraded}; no longer listed`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* What a command says of a listing with no quote that has not traded in over
|
|
123
|
+
* a month: "no longer listed" only on the service's record of it, else "XYZ:
|
|
124
|
+
* no trades since 2026-08-14".
|
|
125
|
+
*/
|
|
126
|
+
export function noQuoteLastTradeNote(symbol: string, lastTrade: NoQuoteLastTrade): string {
|
|
127
|
+
return lastTrade.recorded ? noLongerListedNote(symbol, lastTrade.date) : `${symbol}: no trades since ${lastTrade.date}`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** What says whether a profile served under a stopped listing's symbol is its own (`otherListingProfile`). */
|
|
131
|
+
export interface ListingProfileEvidence {
|
|
132
|
+
/** The listing asked for is a US line: a bare symbol, read on its US line, or one on a US venue. */
|
|
133
|
+
usLine: boolean;
|
|
134
|
+
/** The names on record for the symbol's own issuer: its saved listing's, its ticker change's, a former issuer's. */
|
|
135
|
+
issuerNames?: readonly (string | null | undefined)[];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const US_COUNTRY = /^(?:us|usa|united states(?: of america)?)$/i;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The name of the other listing a profile served under a stopped listing's
|
|
142
|
+
* symbol is of (STPP: a UCITS fund domiciled abroad took the symbol after the
|
|
143
|
+
* iPath steepener ended), only on evidence: it names a company none of the
|
|
144
|
+
* names on record for the symbol's issuer are, or, with none of those
|
|
145
|
+
* matching it, its issuer is domiciled outside the US while the listing asked
|
|
146
|
+
* for is a US line. Otherwise the profile is the listing's own (a stopped
|
|
147
|
+
* company keeps its profile), and the answer is null. A profile that names no
|
|
148
|
+
* one, shown to be abroad, is named by its country.
|
|
149
|
+
*/
|
|
150
|
+
export function otherListingProfile(
|
|
151
|
+
profile: Pick<CompanyProfile, "name" | "country"> | null | undefined,
|
|
152
|
+
evidence: ListingProfileEvidence,
|
|
153
|
+
): string | null {
|
|
154
|
+
const named = profile?.name?.trim() || null;
|
|
155
|
+
const country = profile?.country?.trim() || null;
|
|
156
|
+
const issuers = (evidence.issuerNames ?? []).flatMap((name) => name?.trim() ? [name.trim()] : []);
|
|
157
|
+
const ownName = !!named && issuers.some((issuer) => sameCompany(issuer, named));
|
|
158
|
+
const otherIssuer = !!named && issuers.length > 0 && !ownName;
|
|
159
|
+
const abroad = evidence.usLine && !!country && !US_COUNTRY.test(country) && !ownName;
|
|
160
|
+
if (!otherIssuer && !abroad) return null;
|
|
161
|
+
return named ?? `a company domiciled in ${country}`;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** "The profile served under STPP is another listing's (...), not shown.": the line for `otherListingProfile`'s answer. */
|
|
165
|
+
export function otherListingProfileNote(symbol: string, other: string): string {
|
|
166
|
+
return `The profile served under ${symbol} is another listing's (${other}), not shown.`;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The US venue to read a bare symbol's own US line on, where a source can
|
|
171
|
+
* otherwise answer it with a listing abroad: the one its listing metadata
|
|
172
|
+
* names, else NYSE. The US exchanges share one symbol, and the service reads
|
|
173
|
+
* any of them as the symbol's one US line (STPP's ended on BATS in 2020).
|
|
174
|
+
*/
|
|
175
|
+
export async function usVenueOf(
|
|
176
|
+
symbol: string,
|
|
177
|
+
dataProvider: Pick<DataProvider, "getQuoteMetadata">,
|
|
178
|
+
): Promise<string> {
|
|
179
|
+
const venue = (await dataProvider.getQuoteMetadata?.(symbol, "")
|
|
180
|
+
.catch(logFailure("tickers-listing-fate", "Read a stopped listing's venue failed", null)))?.listingExchangeName;
|
|
181
|
+
return venue && isUsListingExchange(venue) ? venue : "NYSE";
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** When a listing with no quote last traded (`NoQuoteLastTrade`), and its last close then. */
|
|
185
|
+
export interface NoQuoteEnding extends NoQuoteLastTrade {
|
|
186
|
+
lastClose: number | null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* `noQuoteLastTraded` for a listing a command has no quote for, from its
|
|
191
|
+
* latest month of daily bars (a listing that stopped answers its last ones),
|
|
192
|
+
* with its last close: a bare symbol's on the US venue its metadata names,
|
|
193
|
+
* whose bars a source can otherwise answer with a listing abroad's. Fails
|
|
194
|
+
* soft: a source that does not answer says nothing.
|
|
195
|
+
*/
|
|
196
|
+
export async function loadNoQuoteEnding(
|
|
197
|
+
listing: { symbol: string; exchange?: string | null },
|
|
198
|
+
dataProvider: Pick<DataProvider, "getPriceHistory" | "getPriceHistoryWithMetadata" | "getQuoteMetadata">,
|
|
199
|
+
now = Date.now(),
|
|
200
|
+
): Promise<NoQuoteEnding | null> {
|
|
201
|
+
try {
|
|
202
|
+
const exchange = listing.exchange || await usVenueOf(listing.symbol, dataProvider);
|
|
203
|
+
// Asked afresh: a copy saved for the bare symbol (a listing abroad's bars) can otherwise answer for the venue.
|
|
204
|
+
const history = dataProvider.getPriceHistoryWithMetadata
|
|
205
|
+
? await dataProvider.getPriceHistoryWithMetadata(listing.symbol, exchange, "1M", { cacheMode: "refresh" })
|
|
206
|
+
: { points: await dataProvider.getPriceHistory(listing.symbol, exchange, "1M", { cacheMode: "refresh" }) };
|
|
207
|
+
const lastTrade = noQuoteLastTraded(history, now);
|
|
208
|
+
const close = history.points.at(-1)?.close;
|
|
209
|
+
return lastTrade ? { ...lastTrade, lastClose: typeof close === "number" && Number.isFinite(close) ? close : null } : null;
|
|
210
|
+
} catch (error) {
|
|
211
|
+
logFailure("tickers-listing-fate", "Could not read a listing's last bars")(error);
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** `loadNoQuoteEnding` without the close: what `quote`, `ticker` and `history` say of a listing with no quote. */
|
|
217
|
+
export async function loadNoQuoteLastTraded(
|
|
218
|
+
listing: { symbol: string; exchange?: string | null },
|
|
219
|
+
dataProvider: Pick<DataProvider, "getPriceHistory" | "getPriceHistoryWithMetadata" | "getQuoteMetadata">,
|
|
220
|
+
now = Date.now(),
|
|
221
|
+
): Promise<NoQuoteLastTrade | null> {
|
|
222
|
+
const ending = await loadNoQuoteEnding(listing, dataProvider, now);
|
|
223
|
+
return ending ? { date: ending.date, recorded: ending.recorded } : null;
|
|
224
|
+
}
|
|
225
|
+
|
|
80
226
|
/**
|
|
81
227
|
* What became of a symbol, from what `quote` reads it by: the listing's own
|
|
82
228
|
* quote, which says when it stopped trading, and the symbol's ticker changes
|