@gloom-sh/terminal 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
|
@@ -14,22 +14,30 @@ import { MAX_CORRELATION_TICKERS } from "../correlation/settings";
|
|
|
14
14
|
import { ROTATION_LIMIT } from "../relative-rotation/model";
|
|
15
15
|
import { SHORT_WATCH_LIMIT } from "../short-interest/watch-model";
|
|
16
16
|
|
|
17
|
-
/** One
|
|
17
|
+
/** One member of a theme, a fund or a screen's matches, in the order its list shows it. */
|
|
18
18
|
export interface MemberListing {
|
|
19
19
|
symbol: string;
|
|
20
20
|
name?: string | null;
|
|
21
21
|
exchange?: string | null;
|
|
22
|
+
/** The listing's quote currency; theme and fund members are US listings in dollars. */
|
|
23
|
+
currency?: string | null;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
/** The members a pane shows, and what to call them. */
|
|
25
27
|
export interface MemberList {
|
|
26
|
-
/** Names the members in dialog titles: a theme's name or a
|
|
28
|
+
/** Names the members in dialog titles: a theme's name, a fund's ticker or a screen's name. */
|
|
27
29
|
title: string;
|
|
28
30
|
/** The name the save dialog suggests. */
|
|
29
31
|
watchlistName: string;
|
|
30
32
|
members: readonly MemberListing[];
|
|
31
33
|
/** A search narrowing the list: what was typed and how many members the whole list has. */
|
|
32
34
|
search?: { query: string; total: number } | null;
|
|
35
|
+
/** What the dialogs and the report call them, plural: members unless said (a screen's are matches). */
|
|
36
|
+
noun?: string;
|
|
37
|
+
/** How many the whole list holds when `members` is its first part, as a screen's first page of matches is. */
|
|
38
|
+
total?: number;
|
|
39
|
+
/** Whether to offer the functions that take a list of tickers (RRG, CORR, SIW, RIPL); on unless false. */
|
|
40
|
+
openIn?: boolean;
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
interface MemberDestination {
|
|
@@ -98,23 +106,52 @@ export function memberDestinationChoices(symbols: readonly string[], destination
|
|
|
98
106
|
/**
|
|
99
107
|
* The dialog text for `count` distinct members. A search says what it matched
|
|
100
108
|
* and how many members the whole list has, so a saved or opened subset never
|
|
101
|
-
* reads as the whole fund
|
|
109
|
+
* reads as the whole fund; so does a list that is the first part of a larger
|
|
110
|
+
* one (`total`), as a screen's loaded matches are.
|
|
102
111
|
*/
|
|
103
|
-
function memberListText(list: Pick<MemberList, "title" | "search">, count: number) {
|
|
112
|
+
export function memberListText(list: Pick<MemberList, "title" | "search" | "noun" | "total">, count: number) {
|
|
113
|
+
const noun = list.noun ?? "members";
|
|
104
114
|
const query = list.search?.query.trim();
|
|
105
115
|
const search = query ? { query, total: list.search!.total } : null;
|
|
106
116
|
const saved = Math.min(count, MEMBER_WATCHLIST_LIMIT);
|
|
117
|
+
const total = Math.max(count, list.total ?? count);
|
|
107
118
|
return {
|
|
108
|
-
openTitle: search ? tf("Open {title}
|
|
109
|
-
: tf("Open {title}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
: tf("
|
|
119
|
+
openTitle: search ? tf("Open {title} {noun} matching \"{query}\" in", { title: list.title, noun, query: search.query })
|
|
120
|
+
: tf("Open {title} {noun} in", { title: list.title, noun }),
|
|
121
|
+
saveTitle: tf("Save {title} {noun} to", { title: list.title, noun }),
|
|
122
|
+
saveBody: saved < count
|
|
123
|
+
? search ? tf("The first {count} of the {matching} {noun} matching \"{query}\", as listed.", { count: saved, matching: count, noun, query: search.query })
|
|
124
|
+
: tf("The first {count} of {total} {noun}, as listed.", { count: saved, total, noun })
|
|
125
|
+
: search ? tf("{count} of {total} {noun} match \"{query}\".", { count, total: search.total, noun, query: search.query })
|
|
126
|
+
: saved < total ? tf("The first {count} of {total} {noun}, as listed.", { count: saved, total, noun })
|
|
127
|
+
: tf("All {count} {noun}.", { count, noun }),
|
|
115
128
|
};
|
|
116
129
|
}
|
|
117
130
|
|
|
131
|
+
/** The save dialog's choice that names a new watchlist rather than one already there. */
|
|
132
|
+
export const NEW_WATCHLIST_CHOICE = "watchlist:new";
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Where a list can be saved: a new watchlist, then each watchlist there is,
|
|
136
|
+
* in the order the app lists them, with how many tickers it holds.
|
|
137
|
+
*/
|
|
138
|
+
export function watchlistTargetChoices(
|
|
139
|
+
watchlists: readonly { id: string; name: string }[],
|
|
140
|
+
tickers: ReadonlyMap<string, TickerRecord>,
|
|
141
|
+
) {
|
|
142
|
+
const held = new Map<string, number>();
|
|
143
|
+
for (const ticker of tickers.values())
|
|
144
|
+
for (const id of ticker.metadata.watchlists) held.set(id, (held.get(id) ?? 0) + 1);
|
|
145
|
+
return [
|
|
146
|
+
{ id: NEW_WATCHLIST_CHOICE, label: t("New watchlist…") },
|
|
147
|
+
...watchlists.map((watchlist) => ({
|
|
148
|
+
id: watchlist.id,
|
|
149
|
+
label: watchlist.name,
|
|
150
|
+
detail: tf("{count} tickers", { count: held.get(watchlist.id) ?? 0 }),
|
|
151
|
+
})),
|
|
152
|
+
];
|
|
153
|
+
}
|
|
154
|
+
|
|
118
155
|
/** The requested name, numbered when a watchlist already has that name or id. */
|
|
119
156
|
export function uniqueWatchlistName(requested: string, watchlists: readonly { id: string; name: string }[]): string {
|
|
120
157
|
const base = requested.trim();
|
|
@@ -158,18 +195,20 @@ export function planMemberWatchlist(
|
|
|
158
195
|
}
|
|
159
196
|
continue;
|
|
160
197
|
}
|
|
161
|
-
// Theme and fund members are US listings quoted in dollars
|
|
162
|
-
// left to the ticker's profile,
|
|
163
|
-
|
|
198
|
+
// Theme and fund members are US listings quoted in dollars; a screen's
|
|
199
|
+
// matches say their currency. The sector is left to the ticker's profile,
|
|
200
|
+
// so a list never mixes two sector schemes.
|
|
201
|
+
create.push({ ticker: key, name: member.name || symbol, exchange, currency: member.currency?.trim() || "USD",
|
|
164
202
|
portfolios: [], watchlists: [watchlistId], positions: [], custom: {}, tags: [] });
|
|
165
203
|
}
|
|
166
204
|
return { create, update, count: seen.size };
|
|
167
205
|
}
|
|
168
206
|
|
|
169
207
|
/**
|
|
170
|
-
* Pane menu entries for a list of members (a theme's, a fund's
|
|
171
|
-
* RRG, CORR, SIW or RIPL, or save them
|
|
172
|
-
*
|
|
208
|
+
* Pane menu entries for a list of members (a theme's, a fund's, a screen's
|
|
209
|
+
* matches): open them in RRG, CORR, SIW or RIPL, or save them to a new
|
|
210
|
+
* watchlist or one already there. Functions of disabled plugins are left out;
|
|
211
|
+
* each destination gets as many as it takes.
|
|
173
212
|
*/
|
|
174
213
|
export function useMembersMenu(registrationId: string, list: MemberList | null) {
|
|
175
214
|
const dialog = useOptionalDialog();
|
|
@@ -185,8 +224,9 @@ export function useMembersMenu(registrationId: string, list: MemberList | null)
|
|
|
185
224
|
registry.paneTemplates.has(destination.templateId)
|
|
186
225
|
&& !registry.getDisabledPaneTemplateOwner?.(destination.templateId, disabledPlugins)
|
|
187
226
|
));
|
|
188
|
-
const choices = memberDestinationChoices(symbols, destinations);
|
|
227
|
+
const choices = list.openIn === false ? [] : memberDestinationChoices(symbols, destinations);
|
|
189
228
|
const text = memberListText(list, symbols.length);
|
|
229
|
+
const noun = list.noun ?? "members";
|
|
190
230
|
const openIn = () => {
|
|
191
231
|
void dialog.prompt<string>({
|
|
192
232
|
closeOnClickOutside: true,
|
|
@@ -198,16 +238,21 @@ export function useMembersMenu(registrationId: string, list: MemberList | null)
|
|
|
198
238
|
if (choice) createPaneFromTemplate(choice.id, { symbols: choice.symbols, arg: formatTickerListInput(choice.symbols) });
|
|
199
239
|
}).catch(logFailure("shared.members-menu", "Open members in a function failed"));
|
|
200
240
|
};
|
|
201
|
-
const
|
|
241
|
+
const saveToWatchlist = async (target: { name: string } | { id: string }) => {
|
|
202
242
|
// The writes hold the app for about a second with a hundred names; let the dialog close on screen first.
|
|
203
243
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
244
|
+
let watchlist = "id" in target ? getState().config.watchlists.find((entry) => entry.id === target.id) : undefined;
|
|
245
|
+
if ("name" in target) {
|
|
246
|
+
const requested = uniqueWatchlistName(target.name, getState().config.watchlists);
|
|
247
|
+
await createFormCollectionActions({ dataProvider: registry.marketData, dispatch, getState, pluginRegistry: registry,
|
|
248
|
+
tickerRepository: registry.tickerRepository }, (body, options) => {
|
|
249
|
+
if (options?.type === "error") notify({ body, type: "error" });
|
|
250
|
+
}).createWatchlist(requested);
|
|
251
|
+
watchlist = getState().config.watchlists.find((entry) => entry.name === requested);
|
|
252
|
+
if (!watchlist) throw new Error(t("The watchlist was not created."));
|
|
253
|
+
}
|
|
254
|
+
if (!watchlist) throw new Error(t("The watchlist is no longer there."));
|
|
255
|
+
const name = watchlist.name;
|
|
211
256
|
const plan = planMemberWatchlist(getState().tickers, watchlist.id, list.members);
|
|
212
257
|
// One ticker that fails to save leaves the others on the list; the toast says how many made it.
|
|
213
258
|
let failed = 0;
|
|
@@ -238,23 +283,43 @@ export function useMembersMenu(registrationId: string, list: MemberList | null)
|
|
|
238
283
|
}
|
|
239
284
|
for (const ticker of created) registry.events.emit("ticker:added", { symbol: ticker.metadata.ticker, ticker });
|
|
240
285
|
notify(failed
|
|
241
|
-
? { type: "error", body: tf("Saved {saved} of {count}
|
|
242
|
-
: { type: "success", body: tf("Saved {count}
|
|
286
|
+
? { type: "error", body: tf("Saved {saved} of {count} {noun} to {name}. {failed} could not be added.", { saved: plan.count - failed, count: plan.count, noun, name, failed }) }
|
|
287
|
+
: { type: "success", body: tf("Saved {count} {noun} to {name}.", { count: plan.count, noun, name }) });
|
|
288
|
+
};
|
|
289
|
+
const save = (target: { name: string } | { id: string }) => {
|
|
290
|
+
saveToWatchlist(target).catch((error: unknown) => {
|
|
291
|
+
notify({ type: "error", body: error instanceof Error ? error.message : t("The watchlist was not saved.") });
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
const nameNewWatchlist = () => {
|
|
295
|
+
// 54 columns fill the dialog; the prompt's default field is wider and runs past its frame.
|
|
296
|
+
void dialog.prompt<string>({
|
|
297
|
+
closeOnClickOutside: true,
|
|
298
|
+
content: (context: PromptContext<string>) => <TextPromptDialog {...context} title={t("New Watchlist")}
|
|
299
|
+
body={[text.saveBody]} label={t("Name")} initialValue={list.watchlistName} confirmLabel={t("Save")} width={54} />,
|
|
300
|
+
}).then((name) => {
|
|
301
|
+
if (name?.trim()) save({ name });
|
|
302
|
+
}).catch(logFailure("shared.members-menu", "Open save members as watchlist prompt failed"));
|
|
243
303
|
};
|
|
244
304
|
return [
|
|
245
305
|
...(choices.length ? [{ id: "members-open-in", label: t("Open Members In…"), onSelect: openIn }] : []),
|
|
246
|
-
{ id: "members-save-watchlist", label: t("Save
|
|
247
|
-
//
|
|
306
|
+
{ id: "members-save-watchlist", label: t("Save to Watchlist…"), onSelect: () => {
|
|
307
|
+
// With no watchlist yet there is nothing to choose: the name comes first.
|
|
308
|
+
const watchlists = getState().config.watchlists;
|
|
309
|
+
if (!watchlists.length) {
|
|
310
|
+
nameNewWatchlist();
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
248
313
|
void dialog.prompt<string>({
|
|
249
314
|
closeOnClickOutside: true,
|
|
250
|
-
content: (context: PromptContext<string>) => <
|
|
251
|
-
|
|
252
|
-
}).then((
|
|
253
|
-
if (!
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
});
|
|
257
|
-
}).catch(logFailure("shared.members-menu", "Open save members
|
|
315
|
+
content: (context: PromptContext<string>) => <ChoiceDialog {...context} title={text.saveTitle}
|
|
316
|
+
choices={watchlistTargetChoices(watchlists, getState().tickers)} footer={text.saveBody} />,
|
|
317
|
+
}).then((id) => {
|
|
318
|
+
if (!id) return;
|
|
319
|
+
// The name prompt opens once the choice has closed and handed focus back, so its field takes the keys.
|
|
320
|
+
if (id === NEW_WATCHLIST_CHOICE) setTimeout(nameNewWatchlist, 0);
|
|
321
|
+
else save({ id });
|
|
322
|
+
}).catch(logFailure("shared.members-menu", "Open save members to watchlist choice failed"));
|
|
258
323
|
} },
|
|
259
324
|
];
|
|
260
325
|
}, [createPaneFromTemplate, dialog, disabledPlugins, dispatch, getState, list, notify]);
|
|
@@ -11,7 +11,7 @@ import { buildQuoteKey, resolveEntryData } from "../../../market-data/selectors"
|
|
|
11
11
|
import { useAppVisible, usePaneVisible } from "../../../state/app/activity";
|
|
12
12
|
import { useQuoteStreaming } from "../../../state/hooks/quote-streaming";
|
|
13
13
|
import { colors, priceColor } from "../../../theme/colors";
|
|
14
|
-
import type { QuoteSubscriptionTarget } from "../../../types/data-provider";
|
|
14
|
+
import type { MarketDataRequestContext, QuoteBatchResult, QuoteSubscriptionTarget } from "../../../types/data-provider";
|
|
15
15
|
import type { MarketState, Quote } from "../../../types/financials";
|
|
16
16
|
import { formatPercentRaw } from "../../../utils/format";
|
|
17
17
|
import { useAssetData } from "../../runtime";
|
|
@@ -41,10 +41,10 @@ export interface QuoteBoardOptions {
|
|
|
41
41
|
fallbackIntervalMs?: number;
|
|
42
42
|
/**
|
|
43
43
|
* Paint each listed symbol's cached quote, however old, as the network is
|
|
44
|
-
* asked, and refresh the listed symbols in a few batches at once
|
|
45
|
-
* given up after `refreshTimeoutMs
|
|
46
|
-
*
|
|
47
|
-
* marked stale.
|
|
44
|
+
* asked, and refresh the listed symbols in a few batches at once. A batch
|
|
45
|
+
* is given up after `refreshTimeoutMs`, and so is each symbol it left to
|
|
46
|
+
* be asked for alone, so one slow symbol cannot hold the rest. A row whose
|
|
47
|
+
* refresh fails or times out keeps its cached quote, marked stale.
|
|
48
48
|
*/
|
|
49
49
|
cacheFirst?: boolean;
|
|
50
50
|
/**
|
|
@@ -54,7 +54,7 @@ export interface QuoteBoardOptions {
|
|
|
54
54
|
* Keep the reference stable until its contents change.
|
|
55
55
|
*/
|
|
56
56
|
listedSymbols?: ReadonlySet<string> | null;
|
|
57
|
-
/** How long a cache-first refresh waits for one batch. */
|
|
57
|
+
/** How long a cache-first refresh waits for one batch, and for each symbol it asks for alone. */
|
|
58
58
|
refreshTimeoutMs?: number;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -73,7 +73,10 @@ const STREAM_CONNECT_GRACE_MS = 10_000;
|
|
|
73
73
|
const QUOTE_REFRESH_BATCHES = 4;
|
|
74
74
|
/** And sends no batch smaller than this, so a short list is one request. */
|
|
75
75
|
const QUOTE_REFRESH_MIN_BATCH = 8;
|
|
76
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* A batch still unanswered after this long is given up and its rows keep
|
|
78
|
+
* their cached quote; so is a symbol it left to be asked for alone.
|
|
79
|
+
*/
|
|
77
80
|
const QUOTE_REFRESH_TIMEOUT_MS = 5_000;
|
|
78
81
|
|
|
79
82
|
const EMPTY_STATE: BoardQuoteState = { quote: null, loading: false, error: null, stale: false };
|
|
@@ -86,19 +89,28 @@ function boardInstrument(symbol: string): InstrumentRef {
|
|
|
86
89
|
return { symbol, exchange: "" };
|
|
87
90
|
}
|
|
88
91
|
|
|
92
|
+
/** A price its source answered as its last, not a current one. A listing that no longer trades has nothing newer. */
|
|
93
|
+
function isFlaggedStale(quote: Quote): boolean {
|
|
94
|
+
return quote.stale === true && !quote.delisting;
|
|
95
|
+
}
|
|
96
|
+
|
|
89
97
|
/**
|
|
90
98
|
* A failed refresh must not blank a board that was showing prices a second
|
|
91
|
-
* ago: keep the last good quote and mark it stale instead.
|
|
99
|
+
* ago: keep the last good quote and mark it stale instead. A load that
|
|
100
|
+
* brings only a price flagged stale shows the newer of it and the last one,
|
|
101
|
+
* marked stale too.
|
|
92
102
|
*/
|
|
93
103
|
function mergeQuotes(previous: BoardQuoteMap, loaded: BoardQuoteMap): BoardQuoteMap {
|
|
94
104
|
const next: BoardQuoteMap = new Map(previous);
|
|
95
105
|
for (const [symbol, state] of loaded) {
|
|
96
|
-
const
|
|
106
|
+
const current = state.quote && !isFlaggedStale(state.quote) ? state.quote : null;
|
|
107
|
+
const kept = previous.get(symbol)?.quote ?? null;
|
|
108
|
+
const retained = current ?? (state.quote && (state.quote.lastUpdated ?? 0) >= (kept?.lastUpdated ?? 0) ? state.quote : kept);
|
|
97
109
|
next.set(symbol, {
|
|
98
110
|
quote: retained,
|
|
99
111
|
loading: false,
|
|
100
112
|
error: state.error,
|
|
101
|
-
stale: !
|
|
113
|
+
stale: !current && retained !== null,
|
|
102
114
|
});
|
|
103
115
|
}
|
|
104
116
|
return next;
|
|
@@ -135,42 +147,73 @@ function overlayStreamQuote(base: BoardQuoteState, streamed: Quote | null): Boar
|
|
|
135
147
|
return { quote: streamed, loading: base.loading, error: null, stale: streamed.stale === true };
|
|
136
148
|
}
|
|
137
149
|
|
|
138
|
-
/**
|
|
150
|
+
/** `promise`, or a timeout error once `timeoutMs` has passed (never, without one); `onTimeout` runs first. */
|
|
151
|
+
function within<T>(promise: Promise<T>, timeoutMs: number | undefined, onTimeout?: () => void): Promise<T> {
|
|
152
|
+
if (timeoutMs == null) return promise;
|
|
153
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
154
|
+
const timedOut = new Promise<never>((_, reject) => {
|
|
155
|
+
timer = setTimeout(() => {
|
|
156
|
+
onTimeout?.();
|
|
157
|
+
reject(new Error("Quote refresh timed out"));
|
|
158
|
+
}, timeoutMs);
|
|
159
|
+
});
|
|
160
|
+
return Promise.race([promise, timedOut]).finally(() => clearTimeout(timer));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Quotes for `subset`, handed to `apply` as they land: the batch's answer at
|
|
165
|
+
* once, then each symbol it left without a current quote, asked for alone
|
|
166
|
+
* into its own row. Such a symbol whose own read fails shows the dated price
|
|
167
|
+
* the batch had, flagged stale, when it had one. Each request is given
|
|
168
|
+
* `timeoutMs`, when set. Throws only when the batch itself fails, before
|
|
169
|
+
* anything was applied.
|
|
170
|
+
*/
|
|
139
171
|
async function requestBoardQuotes(
|
|
140
172
|
dataProvider: NonNullable<ReturnType<typeof useAssetData>>,
|
|
141
173
|
subset: readonly string[],
|
|
142
174
|
forceRefresh: boolean,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
175
|
+
apply: (loaded: BoardQuoteMap) => void,
|
|
176
|
+
timeoutMs?: number,
|
|
177
|
+
): Promise<void> {
|
|
178
|
+
const askAlone = async (symbol: string, context: MarketDataRequestContext | undefined, fallback: Quote | null = null) => {
|
|
179
|
+
let state: BoardQuoteState;
|
|
180
|
+
try {
|
|
181
|
+
state = { quote: await within(dataProvider.getQuote(symbol, "", context), timeoutMs), loading: false, error: null, stale: false };
|
|
182
|
+
} catch (error: unknown) {
|
|
183
|
+
state = { quote: fallback, loading: false, error: fallback ? null : errorMessage(error), stale: false };
|
|
184
|
+
}
|
|
185
|
+
apply(new Map([[symbol, state]]));
|
|
186
|
+
};
|
|
187
|
+
|
|
146
188
|
if (dataProvider.getQuotesBatch) {
|
|
147
|
-
const
|
|
189
|
+
const controller = new AbortController();
|
|
190
|
+
const results = await within(dataProvider.getQuotesBatch(
|
|
148
191
|
subset.map((symbol) => ({ symbol, exchange: "" })),
|
|
149
|
-
{ forceRefresh,
|
|
150
|
-
);
|
|
192
|
+
{ forceRefresh, deferFollowUps: true, signal: controller.signal },
|
|
193
|
+
), timeoutMs, () => controller.abort());
|
|
151
194
|
const bySymbol = new Map(results.map((result) => [result.target.symbol, result]));
|
|
195
|
+
const answered: BoardQuoteMap = new Map();
|
|
196
|
+
const followUps: QuoteBatchResult[] = [];
|
|
152
197
|
for (const symbol of subset) {
|
|
153
198
|
const result = bySymbol.get(symbol);
|
|
154
|
-
|
|
199
|
+
if (result?.followUp) {
|
|
200
|
+
followUps.push(result);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
answered.set(symbol, {
|
|
155
204
|
quote: result?.quote ?? null,
|
|
156
205
|
loading: false,
|
|
157
206
|
error: result?.error ? errorMessage(result.error) : null,
|
|
158
207
|
stale: false,
|
|
159
208
|
});
|
|
160
209
|
}
|
|
161
|
-
|
|
210
|
+
if (answered.size > 0) apply(answered);
|
|
211
|
+
await Promise.all(followUps.map((result) => askAlone(result.target.symbol, { cacheMode: result.followUp }, result.quote)));
|
|
212
|
+
return;
|
|
162
213
|
}
|
|
163
214
|
|
|
164
215
|
const context = forceRefresh ? { cacheMode: "refresh" as const } : undefined;
|
|
165
|
-
await Promise.all(subset.map(
|
|
166
|
-
try {
|
|
167
|
-
const quote = await dataProvider.getQuote(symbol, "", context);
|
|
168
|
-
next.set(symbol, { quote, loading: false, error: null, stale: false });
|
|
169
|
-
} catch (error: unknown) {
|
|
170
|
-
next.set(symbol, { quote: null, loading: false, error: errorMessage(error), stale: false });
|
|
171
|
-
}
|
|
172
|
-
}));
|
|
173
|
-
return next;
|
|
216
|
+
await Promise.all(subset.map((symbol) => askAlone(symbol, context)));
|
|
174
217
|
}
|
|
175
218
|
|
|
176
219
|
/**
|
|
@@ -287,7 +330,7 @@ export function useQuoteBoard(symbols: string[], options: QuoteBoardOptions = {}
|
|
|
287
330
|
}
|
|
288
331
|
if (!dataProvider || subset.length === 0) return;
|
|
289
332
|
|
|
290
|
-
requestBoardQuotes(dataProvider, subset, forceRefresh
|
|
333
|
+
requestBoardQuotes(dataProvider, subset, forceRefresh, (loaded) => {
|
|
291
334
|
if (fetchGenRef.current !== gen) return;
|
|
292
335
|
setSnapshots((prev) => mergeQuotes(prev, loaded));
|
|
293
336
|
}).catch((error: unknown) => {
|
|
@@ -306,28 +349,24 @@ export function useQuoteBoard(symbols: string[], options: QuoteBoardOptions = {}
|
|
|
306
349
|
// Symbols a cache-first board has asked the network for since its last full load.
|
|
307
350
|
const requestedRef = useRef(new Set<string>());
|
|
308
351
|
|
|
309
|
-
/**
|
|
352
|
+
/**
|
|
353
|
+
* Refreshes `subset` a few batches at once. Each batch's rows paint as it
|
|
354
|
+
* answers, and a symbol it leaves to be asked for alone fills its own row
|
|
355
|
+
* later; a batch or a symbol that fails or times out keeps its rows' cached
|
|
356
|
+
* quotes.
|
|
357
|
+
*/
|
|
310
358
|
const refreshInBatches = useCallback((subset: readonly string[], forceRefresh: boolean, gen: number) => {
|
|
311
359
|
if (!dataProvider) return;
|
|
360
|
+
const apply = (loaded: BoardQuoteMap) => {
|
|
361
|
+
if (fetchGenRef.current !== gen) return;
|
|
362
|
+
setSnapshots((prev) => mergeQuotes(prev, loaded));
|
|
363
|
+
};
|
|
312
364
|
for (const batch of inBatches(subset)) {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const timedOut = new Promise<never>((_, reject) => {
|
|
316
|
-
timer = setTimeout(() => {
|
|
317
|
-
controller.abort();
|
|
318
|
-
reject(new Error("Quote refresh timed out"));
|
|
319
|
-
}, refreshTimeoutMs);
|
|
320
|
-
});
|
|
321
|
-
Promise.race([requestBoardQuotes(dataProvider, batch, forceRefresh, controller.signal), timedOut])
|
|
322
|
-
.catch((error: unknown): BoardQuoteMap => new Map(batch.map((symbol) => [
|
|
365
|
+
requestBoardQuotes(dataProvider, batch, forceRefresh, apply, refreshTimeoutMs)
|
|
366
|
+
.catch((error: unknown) => apply(new Map(batch.map((symbol) => [
|
|
323
367
|
symbol,
|
|
324
368
|
{ quote: null, loading: false, error: errorMessage(error), stale: false },
|
|
325
|
-
])))
|
|
326
|
-
.then((loaded) => {
|
|
327
|
-
clearTimeout(timer);
|
|
328
|
-
if (fetchGenRef.current !== gen) return;
|
|
329
|
-
setSnapshots((prev) => mergeQuotes(prev, loaded));
|
|
330
|
-
});
|
|
369
|
+
]))));
|
|
331
370
|
}
|
|
332
371
|
}, [dataProvider, refreshTimeoutMs]);
|
|
333
372
|
|
|
@@ -137,7 +137,7 @@ export function createShortInterestHeadless(
|
|
|
137
137
|
daysToCover: row.record.shortRatio,
|
|
138
138
|
averageDailyVolume: row.record.averageDailyVolume,
|
|
139
139
|
shortPercentFloat: row.record.shortPercentFloat,
|
|
140
|
-
floatAsOf: row.
|
|
140
|
+
floatAsOf: row.record.shortPercentFloat != null ? row.record.floatAsOf || null : null,
|
|
141
141
|
}));
|
|
142
142
|
const schedule = shortInterestFreshness(rows.map((row) => row.settlementDate).sort().at(-1));
|
|
143
143
|
// A cut at a past date is as current as that date allowed, not stale by today's clock.
|
|
@@ -23,7 +23,11 @@ export interface ShortInterestRow {
|
|
|
23
23
|
settlementDate: string;
|
|
24
24
|
/** When FINRA published the settlement, `YYYY-MM-DD`; `-` when the date is not one. */
|
|
25
25
|
publishedDate: string;
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* The day of the share count the percent of float is read on; `current` for
|
|
28
|
+
* the newest settlement's, read on today's float when that float is undated,
|
|
29
|
+
* so the column never looks missing beside a percent; `-` when there is none.
|
|
30
|
+
*/
|
|
27
31
|
floatAsOf: string;
|
|
28
32
|
sharesShort: string;
|
|
29
33
|
shortRatio: string;
|
|
@@ -52,6 +56,9 @@ export function formatMaybeCompact(value: number | null): string {
|
|
|
52
56
|
return value == null ? "-" : formatCompact(value);
|
|
53
57
|
}
|
|
54
58
|
|
|
59
|
+
/** A table column's figure: its decimals kept, so 12.00M lines up under 10.73M. */
|
|
60
|
+
const columnFigure = (value: number | null) => value == null ? "-" : formatCompact(value, { fixedDecimals: true });
|
|
61
|
+
|
|
55
62
|
function formatRatio(value: number | null): string {
|
|
56
63
|
return value == null ? "-" : formatNumber(value, 2);
|
|
57
64
|
}
|
|
@@ -133,7 +140,8 @@ export function withPercentFloat(
|
|
|
133
140
|
return records.map((record) => {
|
|
134
141
|
if (record === latest) {
|
|
135
142
|
const percent = settlementPercentFloat(record, floatShares, current.statistics);
|
|
136
|
-
return { ...record, shortPercentFloat: percent, floatAsOf: percent != null ? current.floatAsOf ?? null : null
|
|
143
|
+
return { ...record, shortPercentFloat: percent, floatAsOf: percent != null ? current.floatAsOf ?? null : null,
|
|
144
|
+
...(percent != null ? { floatCurrent: true } : {}) };
|
|
137
145
|
}
|
|
138
146
|
if (record.shortPercentFloat != null || floating == null || !finiteNumber(record.sharesOutstanding)) return record;
|
|
139
147
|
return {
|
|
@@ -150,10 +158,10 @@ export function buildRows(records: ShortInterestRecord[]): ShortInterestRow[] {
|
|
|
150
158
|
record,
|
|
151
159
|
settlementDate: formatDate(record.settlementDate),
|
|
152
160
|
publishedDate: shortInterestPublished(formatDate(record.settlementDate)) ?? "-",
|
|
153
|
-
floatAsOf: record.shortPercentFloat
|
|
154
|
-
sharesShort:
|
|
161
|
+
floatAsOf: record.shortPercentFloat == null ? "-" : record.floatAsOf || (record.floatCurrent ? "current" : "-"),
|
|
162
|
+
sharesShort: columnFigure(record.sharesShort),
|
|
155
163
|
shortRatio: formatRatio(record.shortRatio),
|
|
156
|
-
averageDailyVolume:
|
|
164
|
+
averageDailyVolume: columnFigure(record.averageDailyVolume),
|
|
157
165
|
shortPercentFloat: formatPercent(record.shortPercentFloat),
|
|
158
166
|
}));
|
|
159
167
|
}
|
|
@@ -165,6 +173,7 @@ function sortValue(row: ShortInterestRow, columnId: ShortInterestColumnId): stri
|
|
|
165
173
|
case "publishedDate":
|
|
166
174
|
return row.publishedDate === "-" ? null : row.publishedDate;
|
|
167
175
|
case "floatAsOf":
|
|
176
|
+
// `current` is today's float, so it sorts after every dated one.
|
|
168
177
|
return row.floatAsOf === "-" ? null : row.floatAsOf;
|
|
169
178
|
case "sharesShort":
|
|
170
179
|
return row.record.sharesShort;
|
|
@@ -197,7 +206,7 @@ export function buildColumns(
|
|
|
197
206
|
records: readonly ShortInterestRecord[] = [],
|
|
198
207
|
): ShortInterestColumn[] {
|
|
199
208
|
const hasPercentFloat = records.some((record) => record.shortPercentFloat != null);
|
|
200
|
-
const hasFloatDate = records.some((record) => record.shortPercentFloat != null && !!record.floatAsOf);
|
|
209
|
+
const hasFloatDate = records.some((record) => record.shortPercentFloat != null && (!!record.floatAsOf || record.floatCurrent));
|
|
201
210
|
const dateWidth = 11;
|
|
202
211
|
const sharesWidth = 12;
|
|
203
212
|
const ratioWidth = 12;
|
|
@@ -32,7 +32,28 @@ const ATS_COLUMNS: PublicationColumn[] = [
|
|
|
32
32
|
{ id: "atsTrades", label: "ATS TRADES", detailLabel: "ATS trades", width: 14, align: "right", format: shares },
|
|
33
33
|
{ id: "nonAtsTrades", label: "NON-ATS TRADES", detailLabel: "Non-ATS trades", width: 16, align: "right", format: shares },
|
|
34
34
|
];
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* What every fail row names: one CUSIP and one security, as a ticker with a
|
|
37
|
+
* single issue has. A shared value is said once above the table (and in the
|
|
38
|
+
* export's notes), not on every row; a ticker with several CUSIPs, or a
|
|
39
|
+
* security the filings spell differently over time, keeps the column.
|
|
40
|
+
*/
|
|
41
|
+
interface FailIdentity {
|
|
42
|
+
cusip: string | null;
|
|
43
|
+
security: string | null;
|
|
44
|
+
}
|
|
45
|
+
const NO_IDENTITY: FailIdentity = { cusip: null, security: null };
|
|
46
|
+
export function sharedFailIdentity(rows: readonly PublicationRow[]): FailIdentity {
|
|
47
|
+
const shared = (id: "cusip" | "description"): string | null => {
|
|
48
|
+
const values = new Set(rows.map((row) => row[id]));
|
|
49
|
+
const [value] = values;
|
|
50
|
+
return values.size === 1 && typeof value === "string" && value.trim() ? value : null;
|
|
51
|
+
};
|
|
52
|
+
return rows.length ? { cusip: shared("cusip"), security: shared("description") } : NO_IDENTITY;
|
|
53
|
+
}
|
|
54
|
+
export const publicationColumns = (kind: PublicationKind, shared: FailIdentity = NO_IDENTITY) => kind === "ftd"
|
|
55
|
+
? FTD_COLUMNS.filter((column) => !(column.id === "cusip" && shared.cusip) && !(column.id === "description" && shared.security))
|
|
56
|
+
: ATS_COLUMNS;
|
|
36
57
|
export function publicationRows(data: PublicationPayload): PublicationRow[] {
|
|
37
58
|
return data.history.toReversed().map((row) => "cusip" in row
|
|
38
59
|
? { ...row, id: `${row.date}:${row.cusip}` }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useMemo } from "react";
|
|
2
|
-
import { DataTableStackView, EmptyState, PaneStatusBody, usePaneNoticeFooter, usePaneStatusLinkFooter, type DataTableCell } from "../../../components";
|
|
2
|
+
import { DataTableStackView, EmptyState, PaneStatusBody, StatGrid, usePaneNoticeFooter, usePaneStatusLinkFooter, type DataTableCell, type StatItem } from "../../../components";
|
|
3
3
|
import { ageFooterSegment } from "../../../components/layout/pane/footer";
|
|
4
4
|
import { DetailReader } from "../../../components/reader/detail-reader";
|
|
5
5
|
import { usePaneRefreshKey } from "../../../components/data-table/table-pane";
|
|
@@ -10,7 +10,7 @@ import type { PaneProps } from "../../../types/plugin";
|
|
|
10
10
|
import { isKnownNonUsEquityTicker } from "../../../utils/sec";
|
|
11
11
|
import { listingIdentity } from "../shared/ticker-request";
|
|
12
12
|
import { cachedPublication, loadPublication, type PublicationKind } from "./publications-client";
|
|
13
|
-
import { publicationCell, publicationColumns, publicationRows, type PublicationColumn, type PublicationRow } from "./publications-model";
|
|
13
|
+
import { publicationCell, publicationColumns, publicationRows, sharedFailIdentity, type PublicationColumn, type PublicationRow } from "./publications-model";
|
|
14
14
|
|
|
15
15
|
function renderCell(row: PublicationRow, column: PublicationColumn, _index: number, state: { selected: boolean }): DataTableCell {
|
|
16
16
|
const value = row[column.id] ?? null;
|
|
@@ -27,7 +27,14 @@ export function ShortSidePublicationPane({ kind, width, height, focused }: Pick<
|
|
|
27
27
|
});
|
|
28
28
|
const data = resource.data?.payload;
|
|
29
29
|
const rows = useMemo(() => data ? publicationRows(data) : [], [data]);
|
|
30
|
-
const
|
|
30
|
+
const shared = useMemo(() => kind === "ftd" ? sharedFailIdentity(rows) : undefined, [kind, rows]);
|
|
31
|
+
// The open detail names every fact of its row; the table drops what every row shares.
|
|
32
|
+
const detailColumns = publicationColumns(kind);
|
|
33
|
+
const columns = publicationColumns(kind, shared);
|
|
34
|
+
const identity = useMemo<StatItem[]>(() => [
|
|
35
|
+
...(shared?.cusip ? [{ id: "cusip", label: "CUSIP", value: shared.cusip }] : []),
|
|
36
|
+
...(shared?.security ? [{ id: "security", label: "Security", value: shared.security }] : []),
|
|
37
|
+
], [shared]);
|
|
31
38
|
const [selectedId, setSelectedId] = usePluginPaneState<string | null>(`${kind}:selected`, null);
|
|
32
39
|
const [openId, setOpenId] = usePluginPaneState<string | null>(`${kind}:open`, null);
|
|
33
40
|
const rowKey = (row: PublicationRow) => `${symbol}:${row.id}`;
|
|
@@ -51,12 +58,14 @@ export function ShortSidePublicationPane({ kind, width, height, focused }: Pick<
|
|
|
51
58
|
{data ? <DataTableStackView<PublicationRow, PublicationColumn>
|
|
52
59
|
focused={focused} rootWidth={width} rootHeight={height} columns={columns} items={rows} freezeFirstColumn
|
|
53
60
|
sortColumnId={null} sortDirection="desc" emptyStateTitle={`No published ${subject} for this stock.`}
|
|
61
|
+
rootBefore={identity.length ? <StatGrid items={identity} width={width} /> : undefined}
|
|
62
|
+
getExportMetadata={() => [...(shared?.cusip ? [["cusip", shared.cusip]] : []), ...(shared?.security ? [["security", shared.security]] : [])]}
|
|
54
63
|
getItemKey={rowKey} renderCell={renderCell} resetScrollKey={`${kind}:${symbol}`}
|
|
55
64
|
selection={{ kind: "index", selectedIndex: rows.length ? selectedIndex : -1, onChange: (index) => setSelectedId(rows[index] ? rowKey(rows[index]!) : null) }}
|
|
56
65
|
onActivate={(row) => setOpenId(rowKey(row))} detailOpen={!!openRow} onBack={() => setOpenId(null)}
|
|
57
66
|
detailTitle={openRow ? kind === "ftd" ? `${openRow.date} · ${openRow.cusip}` : `Week of ${openRow.date}` : undefined}
|
|
58
67
|
detailContent={openRow ? <DetailReader width={width} resetScrollKey={rowKey(openRow)} facts={[
|
|
59
|
-
...
|
|
68
|
+
...detailColumns.filter((column) => column.id !== "date" && column.id !== "cusip").map((column) => ({ label: column.detailLabel,
|
|
60
69
|
value: openRow[column.id] == null ? "Not published" : typeof openRow[column.id] === "number" && column.id !== "atsSharePercent" && column.id !== "price"
|
|
61
70
|
? Number(openRow[column.id]).toLocaleString("en-US", { maximumFractionDigits: 6 }) : publicationCell(column, openRow[column.id] ?? null) })),
|
|
62
71
|
{ label: "Published through", value: data.sourceAsOf ?? "--" },
|
|
@@ -13,4 +13,6 @@ export interface ShortInterestRecord {
|
|
|
13
13
|
sharesOutstandingAsOf?: string | null;
|
|
14
14
|
/** YYYY-MM-DD of the share count `shortPercentFloat` is read on, when that count is dated. */
|
|
15
15
|
floatAsOf?: string | null;
|
|
16
|
+
/** `shortPercentFloat` is read on today's float (the newest settlement's), dated or not. */
|
|
17
|
+
floatCurrent?: boolean;
|
|
16
18
|
}
|
|
@@ -26,7 +26,7 @@ const LISTED_TYPES = new Set(["", "STK", "EQUITY", "COMMONSTOCK", "ADR", "ETF",
|
|
|
26
26
|
export type ShortWatchSetup = "crowded-rising" | "crowded";
|
|
27
27
|
|
|
28
28
|
export function setupLabel(setup: ShortWatchSetup | null): string {
|
|
29
|
-
return setup === "crowded-rising" ? "Crowded,
|
|
29
|
+
return setup === "crowded-rising" ? "Crowded, px up" : setup === "crowded" ? "Crowded" : "";
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface ShortWatchRow {
|
|
@@ -4,6 +4,7 @@ import { useShortcut } from "../../../react/input";
|
|
|
4
4
|
import { colors } from "../../../theme/colors";
|
|
5
5
|
import { Box, type ScrollBoxRenderable } from "../../../ui";
|
|
6
6
|
import { isDetailBackNavigationKey } from "../../../utils/back-navigation";
|
|
7
|
+
import { countEscapeTowardClose } from "../../../utils/double-escape-close";
|
|
7
8
|
import { isPlainKey } from "../../../utils/keyboard";
|
|
8
9
|
import { nextHeaderSort, type SortDirection } from "../../../utils/sort-values";
|
|
9
10
|
import { usePluginPaneState, usePluginTickerActions } from "../../runtime";
|
|
@@ -106,6 +107,8 @@ export function FundOverlapView({ data, focused, width }: { data: FundDetailData
|
|
|
106
107
|
const closeDetail = useCallback(() => { setTarget(null); setEtf(null); }, [setTarget, setEtf]);
|
|
107
108
|
useShortcut(event => {
|
|
108
109
|
if (!focused || !open || event.targetEditable || !isDetailBackNavigationKey(event)) return;
|
|
110
|
+
// Ahead of the shell's own Esc handler when restored with it, so it counts the Esc itself.
|
|
111
|
+
countEscapeTowardClose(event);
|
|
109
112
|
event.preventDefault?.(); event.stopPropagation?.(); closeDetail();
|
|
110
113
|
}, { phase: "before" });
|
|
111
114
|
useShortcut(event => {
|