gloomberb 0.19.4 → 0.19.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -1
- package/patches/@opentui%2Fcore@0.3.2.patch +86 -25
- package/src/api-client/equity-screener.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.tsx +63 -16
- package/src/cli/commands/command-utils.ts +4 -0
- package/src/cli/commands/market.ts +264 -33
- package/src/cli/commands/search.ts +22 -4
- package/src/cli/commands/ticker.ts +84 -39
- package/src/cli/currency-name-hint.ts +60 -0
- package/src/cli/glossary.ts +3 -3
- package/src/cli/history-rows.ts +18 -1
- package/src/cli/known-gaps.ts +25 -2
- package/src/cli/listing-arg.ts +12 -0
- package/src/cli/not-a-ticker.ts +5 -3
- package/src/cli/pane-functions/capabilities.ts +2 -0
- package/src/cli/pane-functions/catalog.ts +31 -5
- package/src/cli/pane-functions/function-help.ts +8 -5
- package/src/cli/pane-functions/headless.ts +11 -6
- package/src/cli/pane-functions/market-session.ts +6 -7
- package/src/cli/pane-functions/resolver.ts +75 -2
- package/src/cli/quote-answer.ts +9 -0
- package/src/cli/series-search.ts +4 -5
- 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-bitmap.ts +28 -2
- 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 +30 -7
- 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 +32 -12
- 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/layout/shell/active-drag.ts +38 -7
- package/src/components/layout/shell/drag/magnets.ts +106 -0
- package/src/components/layout/shell/menu.ts +15 -1
- package/src/components/layout/shell/pane/actions.ts +4 -0
- package/src/components/layout/shell/ticker-link-menu.ts +12 -3
- package/src/components/layout/status-bar.tsx +20 -0
- package/src/components/layout/window-controls.tsx +96 -35
- package/src/components/layout/window-fullscreen.ts +20 -0
- 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 +8 -5
- package/src/components/onboarding/use-onboarding-progress.ts +20 -1
- package/src/components/price-sparkline/view.tsx +14 -6
- package/src/components/quote-flash.ts +36 -32
- 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/opentui/model.ts +4 -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 +10 -0
- package/src/i18n/ja.ts +10 -0
- package/src/i18n/ko.ts +10 -0
- package/src/i18n/zh-cn.ts +10 -0
- package/src/i18n/zh-tw.ts +10 -0
- 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/coordinator/events.ts +17 -1
- package/src/market-data/frame-scheduler.ts +47 -10
- package/src/market-data/frame-wake.ts +74 -0
- package/src/market-data/futures-board.ts +7 -6
- package/src/market-data/futures-contract.ts +14 -3
- package/src/market-data/hooks.tsx +12 -3
- package/src/market-data/market/freshness.ts +18 -0
- package/src/market-data/market/status.ts +15 -2
- package/src/market-data/performance.ts +78 -9
- package/src/market-data/request-types.ts +6 -3
- package/src/plugins/builtin/alerts/cli.ts +2 -1
- package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
- package/src/plugins/builtin/attention/evidence.ts +1 -1
- package/src/plugins/builtin/awards/client.ts +1 -1
- package/src/plugins/builtin/awards/evidence.ts +1 -1
- package/src/plugins/builtin/awards/pane.tsx +2 -1
- 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/math.ts +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/broker-manager/footer.ts +3 -2
- package/src/plugins/builtin/broker-manager/index.tsx +2 -1
- package/src/plugins/builtin/broker-manager/keyboard.ts +2 -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/catalysts/evidence.ts +1 -1
- package/src/plugins/builtin/catalysts/pane.tsx +2 -1
- package/src/plugins/builtin/cds/headless.ts +1 -0
- package/src/plugins/builtin/cds/index.tsx +1 -1
- package/src/plugins/builtin/chart-composer/headless.ts +40 -1
- package/src/plugins/builtin/cloud/plugin.tsx +2 -0
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +28 -3
- package/src/plugins/builtin/cloud-tweets/table.tsx +3 -2
- package/src/plugins/builtin/comment-letters/client.ts +2 -1
- package/src/plugins/builtin/company-kpis/client.ts +1 -1
- package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
- package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
- package/src/plugins/builtin/correlation/headless.ts +3 -2
- package/src/plugins/builtin/cot/headless.ts +9 -3
- package/src/plugins/builtin/cot/model.ts +44 -3
- package/src/plugins/builtin/credit-documents/client.ts +1 -1
- package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
- package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
- package/src/plugins/builtin/crypto-board/pane.tsx +5 -4
- 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-calls/pane.tsx +1 -1
- package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
- package/src/plugins/builtin/earnings-ripple/pane.tsx +1 -1
- package/src/plugins/builtin/econ/calendar-model.ts +30 -6
- package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
- package/src/plugins/builtin/econ/print-watch.ts +3 -1
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +4 -16
- package/src/plugins/builtin/equity-screener/headless.ts +4 -2
- package/src/plugins/builtin/equity-screener/ideas.ts +67 -3
- package/src/plugins/builtin/equity-screener/model.ts +180 -12
- package/src/plugins/builtin/equity-screener/pane.tsx +52 -12
- 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/futures/series.ts +16 -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/fx-matrix/headless.ts +4 -2
- package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
- package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
- package/src/plugins/builtin/gpu/headless.ts +2 -1
- package/src/plugins/builtin/help/function-card.tsx +2 -1
- package/src/plugins/builtin/help/index.tsx +2 -1
- package/src/plugins/builtin/insider/display.ts +45 -6
- package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
- package/src/plugins/builtin/iv-history/client.ts +2 -1
- package/src/plugins/builtin/iv-history/headless.ts +2 -1
- package/src/plugins/builtin/jobs/pages.ts +4 -4
- package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
- 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-heatmap/index.tsx +2 -1
- package/src/plugins/builtin/market-movers/index.tsx +4 -3
- package/src/plugins/builtin/members/client.ts +1 -1
- package/src/plugins/builtin/mna/distress/client.ts +1 -0
- package/src/plugins/builtin/mna/distress/headless.ts +1 -0
- package/src/plugins/builtin/mna/pane.tsx +4 -1
- package/src/plugins/builtin/options/market-reference.ts +1 -1
- package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
- package/src/plugins/builtin/options/view.tsx +2 -1
- package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
- package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
- package/src/plugins/builtin/options-scenario/csp.ts +28 -9
- package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
- package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
- package/src/plugins/builtin/perps/client.ts +1 -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 +4 -2
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
- package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
- package/src/plugins/builtin/rate-path/headless.ts +24 -10
- package/src/plugins/builtin/research/analyst-model.ts +1 -0
- package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
- package/src/plugins/builtin/research/event-model.ts +10 -3
- package/src/plugins/builtin/research/events-headless.ts +20 -2
- package/src/plugins/builtin/research/index.tsx +1 -0
- package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
- package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
- package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
- package/src/plugins/builtin/research-search/snippet.ts +1 -0
- package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
- package/src/plugins/builtin/seasonality/headless.ts +2 -1
- package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
- package/src/plugins/builtin/sec/fund-facts.ts +17 -1
- package/src/plugins/builtin/sec/index.tsx +8 -5
- package/src/plugins/builtin/sec/row-summaries.ts +28 -12
- package/src/plugins/builtin/shared/members-menu.tsx +103 -38
- 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/watch-client.ts +2 -1
- package/src/plugins/builtin/short-interest/watch-model.ts +1 -1
- package/src/plugins/builtin/social-mentions/client.ts +2 -1
- package/src/plugins/builtin/supply-chain/client.ts +1 -1
- package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
- package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
- package/src/plugins/builtin/time-sales/client.ts +1 -0
- 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/index.tsx +1 -1
- package/src/plugins/builtin/vol-surface/client.ts +2 -1
- 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 +9 -2
- 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/portfolio/collection-name.ts +19 -0
- package/src/portfolio/column-values.ts +76 -10
- package/src/renderers/browser/http-proxy-transport.ts +78 -8
- package/src/renderers/cloudflare/http-proxy.ts +13 -2
- package/src/renderers/cloudflare/proxy-session.ts +47 -24
- package/src/renderers/cloudflare/worker.ts +15 -2
- 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/host/box.tsx +204 -176
- package/src/renderers/dom/host/style.ts +49 -20
- package/src/renderers/dom/host/text.tsx +3 -2
- 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 +322 -19
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +83 -61
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +29 -15
- package/src/renderers/electrobun/bun/desktop/initialization.ts +30 -11
- package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
- 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/windows-script.ts +9 -6
- 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 +4 -97
- package/src/renderers/electrobun/bun/window/electrobun-window-host.ts +306 -0
- package/src/renderers/electrobun/bun/window/focus.ts +0 -25
- package/src/renderers/electrobun/bun/window/remembered-frame.ts +4 -82
- package/src/renderers/electrobun/bun/window/windows-native.ts +26 -1
- package/src/renderers/electrobun/shared/protocol.ts +50 -2
- package/src/renderers/electrobun/view/backend-rpc.ts +15 -0
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +63 -3
- package/src/renderers/electrobun/view/main.tsx +13 -7
- package/src/renderers/electrobun/view/ui-host.tsx +7 -0
- package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
- package/src/series/fred-argument.ts +17 -0
- package/src/sources/provider-router/financial-routes.ts +7 -1
- package/src/sources/provider-router/index.ts +7 -1
- 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/price-units.ts +11 -0
- package/src/time-series/types.ts +6 -0
- package/src/types/config.ts +10 -1
- package/src/types/desktop-window.ts +71 -2
- package/src/types/financials.ts +4 -0
- package/src/types/headless.ts +19 -0
- package/src/types/plugin.ts +6 -0
- package/src/ui/host.tsx +2 -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/currency-names.ts +20 -0
- package/src/utils/currency-pair.ts +6 -0
- package/src/utils/exchange-rate-snapshot.ts +20 -2
- package/src/utils/format.ts +7 -2
- package/src/utils/futures-generic.ts +12 -0
- package/src/utils/fx-market-hours.ts +43 -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/sec-filings.ts +7 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { logFailure } from "../utils/log-failure";
|
|
2
|
+
import { ApiRequestError, wasAskedTwice } from "../api-client/errors";
|
|
3
|
+
import { isNoSourceAnswer, isProviderBusy, SEARCH_BUSY_MESSAGE } from "../sources/provider-errors";
|
|
2
4
|
import type { DataProvider } from "../types/data-provider";
|
|
3
5
|
import type { Quote } from "../types/financials";
|
|
4
6
|
import type { InstrumentSearchResult } from "../types/instrument";
|
|
@@ -103,6 +105,13 @@ export interface CliTicker {
|
|
|
103
105
|
* still to be asked.
|
|
104
106
|
*/
|
|
105
107
|
otherVenues: string[] | null;
|
|
108
|
+
/**
|
|
109
|
+
* A bare US-style symbol whose quote could not be read (the service refused
|
|
110
|
+
* or failed it): whether the listing still trades is unknown, so an add
|
|
111
|
+
* cannot tell a live match from a dead one (`choiceNeeded`). A list looks
|
|
112
|
+
* it up again with the symbols that failed.
|
|
113
|
+
*/
|
|
114
|
+
unchecked?: true;
|
|
106
115
|
}
|
|
107
116
|
|
|
108
117
|
export interface CliTickerOptions {
|
|
@@ -226,7 +235,8 @@ export async function resolveCliTicker(
|
|
|
226
235
|
// A saved listing names what lists there; the issuer that left, if it is that one, is its old line.
|
|
227
236
|
if (listing.saved) {
|
|
228
237
|
const saved = options.refreshName === false ? { ticker: listing.saved, quote: null } : await nameFromListingQuote(listing.saved, store, dataProvider, null);
|
|
229
|
-
|
|
238
|
+
// A saved line that stopped trading is the old line, not something listed under the symbol now.
|
|
239
|
+
return withChange({ ...withEnded(saved, read), ...uncheckedIf(listing, saved) }, saved.quote ? tradingListing(saved.quote) : { name: saved.ticker.metadata.name });
|
|
230
240
|
}
|
|
231
241
|
// A listing its own quote names is found as `quote` finds it, the quote cache first, so a busy search never
|
|
232
242
|
// blocks a listing the quote knows. Search is asked after, for the venues a note names, and may fail.
|
|
@@ -287,11 +297,12 @@ export async function resolveCliTicker(
|
|
|
287
297
|
}
|
|
288
298
|
if (resolved.kind === "local") {
|
|
289
299
|
const local = options.refreshName === false ? { ticker: resolved.ticker, quote: null } : await nameFromListingQuote(resolved.ticker, store, dataProvider, bareQuote);
|
|
290
|
-
return withChange({ ...withEnded(local, [...read, ...bareNote ? [bareNote] : []]), otherVenues: bareNote ? bareVenues : null }, { name: local.ticker.metadata.name });
|
|
300
|
+
return withChange({ ...withEnded(local, [...read, ...bareNote ? [bareNote] : []]), otherVenues: bareNote ? bareVenues : null, ...uncheckedIf(listing, local) }, local.quote ? tradingListing(local.quote) : { name: local.ticker.metadata.name });
|
|
291
301
|
}
|
|
292
302
|
|
|
293
303
|
const { ticker, created } = await upsertTickerFromSearchResult(store, resolved.result);
|
|
294
|
-
|
|
304
|
+
// A listing saved before (by an earlier look at a list) is read again too: its quote says whether it still trades.
|
|
305
|
+
const named = created || !bareQuote ? await nameFromListingQuote(ticker, store, dataProvider, bareQuote) : { ticker, quote: bareQuote };
|
|
295
306
|
const saved = savedListingName(named.ticker);
|
|
296
307
|
const others = resolved.otherListings?.map((key) => parsePublicTickerKey(key).exchange ?? key) ?? [];
|
|
297
308
|
// Several companies' listings name the company it went to and theirs; one company's name its other venues.
|
|
@@ -307,9 +318,15 @@ export async function resolveCliTicker(
|
|
|
307
318
|
notes: [...read, venueNote, ended].filter((note): note is string => !!note),
|
|
308
319
|
ended,
|
|
309
320
|
otherVenues: bareNote ? bareVenues : others,
|
|
321
|
+
...uncheckedIf(listing, named),
|
|
310
322
|
}, current);
|
|
311
323
|
}
|
|
312
324
|
|
|
325
|
+
/** `unchecked` for a bare US-style symbol whose quote could not be read (`CliTicker.unchecked`). */
|
|
326
|
+
function uncheckedIf(listing: Pick<CliListing, "symbol" | "exchange">, read: { failed?: true }): { unchecked?: true } {
|
|
327
|
+
return read.failed && !listing.exchange && tickerChangeSymbol(listing.symbol) ? { unchecked: true } : {};
|
|
328
|
+
}
|
|
329
|
+
|
|
313
330
|
/**
|
|
314
331
|
* The listing a symbol's own quote names, asked as `quote` asks it (the quote
|
|
315
332
|
* cache first): a priced quote answering for that symbol, on the venue named
|
|
@@ -399,22 +416,49 @@ async function nameFromListingQuote(
|
|
|
399
416
|
store: AppTickerRepositoryPort,
|
|
400
417
|
dataProvider: DataProvider,
|
|
401
418
|
known: Quote | null,
|
|
402
|
-
): Promise<{ ticker: TickerRecord; quote: Quote | null }> {
|
|
419
|
+
): Promise<{ ticker: TickerRecord; quote: Quote | null; failed?: true }> {
|
|
403
420
|
const { metadata } = ticker;
|
|
404
421
|
try {
|
|
405
422
|
const quote = known ?? await dataProvider.getQuote(metadata.ticker, metadata.exchange);
|
|
406
423
|
const name = quote.name?.trim();
|
|
407
|
-
// A quote that names no listing may be another venue's line served from cache.
|
|
424
|
+
// A quote that names no listing may be another venue's line served from cache. A bare US row (RAD, no
|
|
425
|
+
// venue) is asked with none, and its own quote names none when the line stopped trading.
|
|
408
426
|
const quoteExchange = canonicalExchange(quote.listingExchangeName || quote.exchangeName);
|
|
409
|
-
|
|
427
|
+
const ownExchange = canonicalExchange(metadata.exchange);
|
|
428
|
+
if (quoteExchange !== ownExchange || (!quoteExchange && !quote.delisting)) return { ticker, quote: null };
|
|
410
429
|
if (!name || name === metadata.name) return { ticker, quote };
|
|
411
430
|
const named: TickerRecord = { ...ticker, metadata: { ...metadata, name } };
|
|
412
431
|
await store.saveTicker(named);
|
|
413
432
|
return { ticker: named, quote };
|
|
414
|
-
} catch {
|
|
415
|
-
// Without a quote the catalogue name stands.
|
|
416
|
-
|
|
433
|
+
} catch (error) {
|
|
434
|
+
// Without a quote the catalogue name stands. Refused, whether the listing still trades is unknown; answered
|
|
435
|
+
// with an error of the listing's own, a later look would answer the same, so the match stands as it is.
|
|
436
|
+
return { ticker, quote: null, ...quoteRefused(error) ? { failed: true as const } : {} };
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Whether a quote failed as the service refusing or not reaching it (a rate
|
|
442
|
+
* limit, an overload, a timeout, no connection), which a later look may get
|
|
443
|
+
* past. A failure the service gave for the listing itself (no quote for it, a
|
|
444
|
+
* 4xx, a source that failed it twice) is the listing's own: a symbol whose
|
|
445
|
+
* quote always errors costs no wait. What cannot be told apart is taken for
|
|
446
|
+
* a refusal, so a busy service never lets a line that stopped trading pass as
|
|
447
|
+
* one that trades.
|
|
448
|
+
*/
|
|
449
|
+
function quoteRefused(error: unknown): boolean {
|
|
450
|
+
if (isNoSourceAnswer(error)) return false;
|
|
451
|
+
for (let current = error, depth = 0; current && typeof current === "object" && depth < 5; depth += 1) {
|
|
452
|
+
if (current instanceof ApiRequestError) {
|
|
453
|
+
const { status } = current;
|
|
454
|
+
if (status === 408 || status === 429 || status === 503) return true;
|
|
455
|
+
if (status !== undefined && status >= 400 && status < 500) return false;
|
|
456
|
+
return !wasAskedTwice(current);
|
|
457
|
+
}
|
|
458
|
+
if (wasAskedTwice(current)) return false;
|
|
459
|
+
current = (current as { failure?: unknown }).failure ?? (current as { cause?: unknown }).cause;
|
|
417
460
|
}
|
|
461
|
+
return true;
|
|
418
462
|
}
|
|
419
463
|
|
|
420
464
|
export type CliTickerResolution =
|
|
@@ -435,9 +479,10 @@ const MARKET_OPERATION = /^(?:GET|POST) \/market\//;
|
|
|
435
479
|
/**
|
|
436
480
|
* Waits before each new look at the symbols that failed while requests were
|
|
437
481
|
* failing. The first outlasts the five seconds the router keeps an empty
|
|
438
|
-
* search answer
|
|
482
|
+
* search answer. Two, so a long add is done within a minute: what is still
|
|
483
|
+
* refused after them is named with the command that adds it.
|
|
439
484
|
*/
|
|
440
|
-
const RETRY_WAITS_MS = [6_000, 15_000
|
|
485
|
+
const RETRY_WAITS_MS = [6_000, 15_000];
|
|
441
486
|
|
|
442
487
|
/**
|
|
443
488
|
* Counts the data service's market requests that fail while it watches. A
|
|
@@ -466,16 +511,33 @@ function lookUpTickers(
|
|
|
466
511
|
symbols: readonly string[],
|
|
467
512
|
concurrency: number,
|
|
468
513
|
resolve: (symbol: string) => Promise<CliTicker>,
|
|
514
|
+
looked?: () => void,
|
|
469
515
|
): Promise<CliTickerResolution[]> {
|
|
470
516
|
return mapWithConcurrency(symbols, concurrency, async (input): Promise<CliTickerResolution> => {
|
|
471
517
|
try {
|
|
472
518
|
return { input, ...await resolve(input) };
|
|
473
519
|
} catch (error) {
|
|
474
520
|
return { input, error: error instanceof Error ? error : new Error(String(error)) };
|
|
521
|
+
} finally {
|
|
522
|
+
looked?.();
|
|
475
523
|
}
|
|
476
524
|
});
|
|
477
525
|
}
|
|
478
526
|
|
|
527
|
+
/**
|
|
528
|
+
* Whether a lookup failed as busy: a search no source answered in time
|
|
529
|
+
* ("Search is busy"), which gives up before its request fails, so the
|
|
530
|
+
* requests the service failed do not count it.
|
|
531
|
+
*/
|
|
532
|
+
function busyLookup(entry: CliTickerResolution): boolean {
|
|
533
|
+
return !!entry.error && (entry.error.message === SEARCH_BUSY_MESSAGE || isProviderBusy(entry.error));
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/** Whether a lookup is to be made again while requests fail: one that failed as refused, or a match whose quote was refused. */
|
|
537
|
+
function lookAgain(entry: CliTickerResolution): boolean {
|
|
538
|
+
return entry.error ? mayBeRefusal(entry.error) : entry.unchecked === true;
|
|
539
|
+
}
|
|
540
|
+
|
|
479
541
|
/**
|
|
480
542
|
* What a symbol of a list asks the sources for, so the whole list's searches
|
|
481
543
|
* and change lookups go out in batches first: a bare symbol searches its
|
|
@@ -520,16 +582,21 @@ export async function resolveTickersForCli(
|
|
|
520
582
|
retry,
|
|
521
583
|
askWhenAmbiguous,
|
|
522
584
|
onRetry,
|
|
585
|
+
onProgress,
|
|
523
586
|
retryWaitsMs = RETRY_WAITS_MS,
|
|
524
587
|
}: Pick<CliTickerOptions, "retry" | "askWhenAmbiguous"> & {
|
|
525
588
|
/** Told before each new look, with how many symbols and how long it waits first. */
|
|
526
589
|
onRetry?: (count: number, waitMs: number) => void;
|
|
590
|
+
/** Told as each symbol of the first look is settled, with how many are and how many there are. */
|
|
591
|
+
onProgress?: (looked: number, total: number) => void;
|
|
527
592
|
retryWaitsMs?: readonly number[];
|
|
528
593
|
} = {},
|
|
529
594
|
): Promise<CliTickerResolution[]> {
|
|
530
595
|
const plans = new Map(symbols.map((input) => [input, listLookupPlan(input, exchange)] as const));
|
|
596
|
+
let settled = 0;
|
|
597
|
+
const progress = onProgress ? () => onProgress(++settled, symbols.length) : undefined;
|
|
531
598
|
// Each look asks for its symbols' searches and changes in batches first.
|
|
532
|
-
const look = async (inputs: readonly string[], concurrency: number): Promise<Map<string, CliTickerResolution>> => {
|
|
599
|
+
const look = async (inputs: readonly string[], concurrency: number, looked?: () => void): Promise<Map<string, CliTickerResolution>> => {
|
|
533
600
|
const batched = await batchedListLookups(dataProvider, inputs.map((input) => plans.get(input)!));
|
|
534
601
|
const resolve = (symbol: string) => resolveCliTicker(symbol, store, batched.dataProvider, exchange, {
|
|
535
602
|
retry, askWhenAmbiguous, ownExchangeWins: true, changeGraceMs: LOOKUP_TIMEOUT_MS,
|
|
@@ -537,28 +604,30 @@ export async function resolveTickersForCli(
|
|
|
537
604
|
// Symbols whose searches were answered ask only for quotes, which go out together; the rest ask as before.
|
|
538
605
|
const answered = (input: string) => batched.answered(plans.get(input)!);
|
|
539
606
|
return new Map((await Promise.all([
|
|
540
|
-
lookUpTickers(inputs.filter(answered), ANSWERED_CONCURRENCY, resolve),
|
|
541
|
-
lookUpTickers(inputs.filter((input) => !answered(input)), concurrency, resolve),
|
|
607
|
+
lookUpTickers(inputs.filter(answered), ANSWERED_CONCURRENCY, resolve, looked),
|
|
608
|
+
lookUpTickers(inputs.filter((input) => !answered(input)), concurrency, resolve, looked),
|
|
542
609
|
])).flat().map((entry) => [entry.input, entry] as const));
|
|
543
610
|
};
|
|
544
611
|
const failedRequests = watchFailedRequests();
|
|
545
612
|
try {
|
|
546
|
-
const looked = await look(symbols, RESOLVE_CONCURRENCY);
|
|
613
|
+
const looked = await look(symbols, RESOLVE_CONCURRENCY, progress);
|
|
547
614
|
let lookups = symbols.map((input) => looked.get(input)!);
|
|
548
|
-
let failing = failedRequests.count() > 0;
|
|
615
|
+
let failing = failedRequests.count() > 0 || lookups.some(busyLookup);
|
|
549
616
|
for (const waitMs of retryWaitsMs) {
|
|
550
|
-
|
|
617
|
+
// A match whose quote was refused is looked at again too, so it gets the check a first look gives.
|
|
618
|
+
const failed = lookups.filter(lookAgain).map((entry) => entry.input);
|
|
551
619
|
if (!failing || failed.length === 0) break;
|
|
552
620
|
onRetry?.(failed.length, waitMs);
|
|
553
621
|
await new Promise((resolveWait) => setTimeout(resolveWait, waitMs));
|
|
554
622
|
const before = failedRequests.count();
|
|
555
623
|
const again = await look(failed, RETRY_CONCURRENCY);
|
|
556
624
|
lookups = lookups.map((entry) => again.get(entry.input) ?? entry);
|
|
557
|
-
failing = failedRequests.count() > before;
|
|
625
|
+
failing = failedRequests.count() > before || [...again.values()].some(busyLookup);
|
|
558
626
|
}
|
|
559
627
|
if (!failing) return lookups;
|
|
560
|
-
// Still refused after the last wait: a failure may only be the refusal, so none is called not found
|
|
561
|
-
|
|
628
|
+
// Still refused after the last wait: a failure may only be the refusal, so none is called not found,
|
|
629
|
+
// and a match whose quote was refused is not taken as trading.
|
|
630
|
+
return lookups.map((entry) => lookAgain(entry)
|
|
562
631
|
? { input: entry.input, error: new LookupUnansweredError(entry.input) }
|
|
563
632
|
: entry);
|
|
564
633
|
} finally {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { memo } from "react";
|
|
1
2
|
import { Box, Text, useUiCapabilities } from "../../../ui";
|
|
2
3
|
import type { CompositeChartXMarker } from "./types";
|
|
3
4
|
|
|
@@ -102,6 +103,49 @@ export interface StaticXAxisMarker {
|
|
|
102
103
|
color: string;
|
|
103
104
|
}
|
|
104
105
|
|
|
106
|
+
/** A time label at its place on the axis, which holds still while the cursor moves past. */
|
|
107
|
+
const PositionedTimeLabel = memo(function PositionedTimeLabel({ label, color, left, right, transform }: {
|
|
108
|
+
label: string;
|
|
109
|
+
color: string | undefined;
|
|
110
|
+
left: number | string | undefined;
|
|
111
|
+
right: number | string | undefined;
|
|
112
|
+
transform: number | string | undefined;
|
|
113
|
+
}) {
|
|
114
|
+
return (
|
|
115
|
+
<Text
|
|
116
|
+
fg={color}
|
|
117
|
+
selectable={false}
|
|
118
|
+
// The label against the right edge, which a floating pane's resize grip may cover.
|
|
119
|
+
data-gloom-edge={right !== undefined ? "end" : undefined}
|
|
120
|
+
style={{
|
|
121
|
+
position: "absolute",
|
|
122
|
+
top: 0,
|
|
123
|
+
whiteSpace: "pre",
|
|
124
|
+
pointerEvents: "none",
|
|
125
|
+
...(left !== undefined ? { left } : {}),
|
|
126
|
+
...(right !== undefined ? { right } : {}),
|
|
127
|
+
...(transform !== undefined ? { transform } : {}),
|
|
128
|
+
}}
|
|
129
|
+
>
|
|
130
|
+
{label}
|
|
131
|
+
</Text>
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
/** A stretch of the axis text in the terminal, which renders only when its text does. */
|
|
136
|
+
const TimeLabelSegment = memo(function TimeLabelSegment({ width, text, color, end }: {
|
|
137
|
+
width: number;
|
|
138
|
+
text: string;
|
|
139
|
+
color: string | undefined;
|
|
140
|
+
end: boolean;
|
|
141
|
+
}) {
|
|
142
|
+
return (
|
|
143
|
+
<Box width={width} overflow="hidden" data-gloom-edge={end ? "end-segment" : undefined}>
|
|
144
|
+
<Text fg={color}>{text}</Text>
|
|
145
|
+
</Box>
|
|
146
|
+
);
|
|
147
|
+
});
|
|
148
|
+
|
|
105
149
|
export function StaticXAxisLabels({
|
|
106
150
|
labels,
|
|
107
151
|
positionedLabels,
|
|
@@ -235,38 +279,27 @@ export function StaticXAxisLabels({
|
|
|
235
279
|
>
|
|
236
280
|
{visiblePositionedLabels.length > 0 && (isDesktop || visibleLabels.length === 0) ? (
|
|
237
281
|
<Box position="absolute" left={0} top={0} width={width} height={1} style={isDesktop ? { width: "100%" } : undefined}>
|
|
238
|
-
{positionedPlacements.map(({ entry, index, edgeStyle }) =>
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
top: 0,
|
|
249
|
-
whiteSpace: "pre",
|
|
250
|
-
pointerEvents: "none",
|
|
251
|
-
...edgeStyle,
|
|
252
|
-
}}
|
|
253
|
-
>
|
|
254
|
-
{entry.label}
|
|
255
|
-
</Text>
|
|
256
|
-
);
|
|
257
|
-
})}
|
|
282
|
+
{positionedPlacements.map(({ entry, index, edgeStyle }) => (
|
|
283
|
+
<PositionedTimeLabel
|
|
284
|
+
key={`${entry.label}:${entry.ratio}:${index}`}
|
|
285
|
+
label={entry.label}
|
|
286
|
+
color={color}
|
|
287
|
+
left={edgeStyle.left}
|
|
288
|
+
right={edgeStyle.right}
|
|
289
|
+
transform={edgeStyle.transform}
|
|
290
|
+
/>
|
|
291
|
+
))}
|
|
258
292
|
</Box>
|
|
259
293
|
) : (
|
|
260
294
|
<Box width={width} height={1} flexDirection="row">
|
|
261
295
|
{visibleLabels.map((label, index) => (
|
|
262
|
-
<
|
|
296
|
+
<TimeLabelSegment
|
|
263
297
|
key={`${label}:${index}`}
|
|
264
|
-
width={segmentWidths[index]}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
</Box>
|
|
298
|
+
width={segmentWidths[index]!}
|
|
299
|
+
text={flowText[index]!}
|
|
300
|
+
color={color}
|
|
301
|
+
end={index === visibleLabels.length - 1 && visibleLabels.length > 1}
|
|
302
|
+
/>
|
|
270
303
|
))}
|
|
271
304
|
</Box>
|
|
272
305
|
)}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useCallback,
|
|
3
|
+
useEffect,
|
|
4
|
+
useId,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
useSyncExternalStore,
|
|
9
|
+
type ComponentProps,
|
|
10
|
+
type ReactNode,
|
|
11
|
+
} from "react";
|
|
2
12
|
import { useCompositeChartKeyboard } from "./use-composite-chart-keyboard";
|
|
3
13
|
import { useCompositeViewport } from "./use-composite-viewport";
|
|
4
14
|
import { CompositePanelSurface } from "./panel-surface";
|
|
@@ -40,6 +50,12 @@ import { useChartViewResetListener } from "../core/view-reset";
|
|
|
40
50
|
import { useShowChartTextFallback } from "../native/use-chart-text-fallback";
|
|
41
51
|
import { StaticXAxisLabels, StaticXMarkerLabels, StaticXMarkerOverlay } from "./axis-overlays";
|
|
42
52
|
import { formatCompositeCursorAxisDate } from "./format";
|
|
53
|
+
import {
|
|
54
|
+
createCompositeCursorSource,
|
|
55
|
+
createValueStore,
|
|
56
|
+
useCursorScene,
|
|
57
|
+
type CompositeCursorSource,
|
|
58
|
+
} from "./cursor-source";
|
|
43
59
|
import {
|
|
44
60
|
resolveCompositeWheelPan,
|
|
45
61
|
resolveCompositeWheelZoom,
|
|
@@ -51,10 +67,8 @@ import { useCompositeValueScales } from "./use-composite-value-scales";
|
|
|
51
67
|
import { COMPOSITE_RIGHT_OFFSET_RATIO } from "./time-scale";
|
|
52
68
|
import {
|
|
53
69
|
allocateCompositePanelHeights,
|
|
54
|
-
applyCompositeChartCursor,
|
|
55
70
|
buildCompositeChartScene,
|
|
56
71
|
compositeCursorAsOf,
|
|
57
|
-
compositeLinkedCursorTime,
|
|
58
72
|
resizeCompositePanel,
|
|
59
73
|
resolveAdjacentCompositeCursorDate,
|
|
60
74
|
} from "./scene";
|
|
@@ -93,6 +107,11 @@ const NO_X_MARKERS: readonly CompositeChartXMarker[] = [];
|
|
|
93
107
|
const subscribeToNothing = () => () => {};
|
|
94
108
|
const holdsNothing = () => false;
|
|
95
109
|
|
|
110
|
+
function finiteTimestampOrNull(date: Date | null | undefined): number | null {
|
|
111
|
+
const timestamp = date?.getTime() ?? null;
|
|
112
|
+
return timestamp !== null && Number.isFinite(timestamp) ? timestamp : null;
|
|
113
|
+
}
|
|
114
|
+
|
|
96
115
|
/**
|
|
97
116
|
* Desktop: the rows below the plot span the chart's box and their labels the
|
|
98
117
|
* width the gutters leave, so when a resize draws the box at a new size
|
|
@@ -215,7 +234,9 @@ function ThemedCompositeChart({
|
|
|
215
234
|
const { cellWidthPx = 8, cellHeightPx = 18, pixelRatio = 1, fractionalViewport = false } = useUiCapabilities();
|
|
216
235
|
const isDesktopWeb = useUiCapabilities().nativePaneChrome === true;
|
|
217
236
|
const showTextFallback = useShowChartTextFallback();
|
|
218
|
-
|
|
237
|
+
// The chart's own cursor, in epoch ms. A pointer move sets it without
|
|
238
|
+
// rendering the chart: only what draws the crosshair renders (see `cursorSource`).
|
|
239
|
+
const [ownCursor] = useState(() => createValueStore<number | null>(null));
|
|
219
240
|
const [toolSpan, setToolSpan] = useState<ChartToolSpan | null>(null);
|
|
220
241
|
const [pointerDragging, setPointerDragging] = useState(false);
|
|
221
242
|
const paneFocused = usePaneFocused();
|
|
@@ -255,8 +276,7 @@ function ThemedCompositeChart({
|
|
|
255
276
|
// pointer moves it as on any chart, and the pointer leaving returns it.
|
|
256
277
|
const restingCursor = cursorDate !== undefined && !onCursorDateChange;
|
|
257
278
|
const ownsCursor = cursorDate === undefined || restingCursor;
|
|
258
|
-
const
|
|
259
|
-
: restingCursor ? internalCursorDate ?? cursorDate : cursorDate;
|
|
279
|
+
const ownerCursorTimestamp = finiteTimestampOrNull(cursorDate);
|
|
260
280
|
const totalWidth = Math.max(1, Math.floor(width));
|
|
261
281
|
const totalHeight = Math.max(1, Math.floor(height));
|
|
262
282
|
const seriesIdentityRef = useRef<ResolvedSeries[]>([]);
|
|
@@ -483,10 +503,12 @@ function ThemedCompositeChart({
|
|
|
483
503
|
};
|
|
484
504
|
return downsampleCompositeChartScene(laidOut, downsampleWidth);
|
|
485
505
|
}, [downsampleWidth, layoutPanels, maximizedPanelId, plotWidth, projectedScene]);
|
|
486
|
-
|
|
487
|
-
const
|
|
488
|
-
?
|
|
489
|
-
|
|
506
|
+
// The cursor shown: the chart's own, or else the owner's.
|
|
507
|
+
const currentCursorTimestamp = useCallback(
|
|
508
|
+
() => (ownsCursor ? ownCursor.get() : null) ?? ownerCursorTimestamp,
|
|
509
|
+
[ownCursor, ownerCursorTimestamp, ownsCursor],
|
|
510
|
+
);
|
|
511
|
+
const normalizedCursorTimestamp = currentCursorTimestamp();
|
|
490
512
|
// A custom x axis is not time, so there is no time to share. Otherwise an
|
|
491
513
|
// interactive chart in a pane shares its crosshair with every chart in the
|
|
492
514
|
// pane's layout tab, its siblings in the pane included: each chart is its
|
|
@@ -506,43 +528,40 @@ function ThemedCompositeChart({
|
|
|
506
528
|
const sharedTime = link?.time;
|
|
507
529
|
// Charts sharing a cursor show one: another chart's while it holds it, in
|
|
508
530
|
// place of this one's own. An owner's resting cursor, such as a table's
|
|
509
|
-
// selected row, comes back when it clears.
|
|
510
|
-
//
|
|
511
|
-
// chart under a 30-minute one's cursor moves once a session.
|
|
531
|
+
// selected row, comes back when it clears. Whether one shows renders the
|
|
532
|
+
// chart; where it is renders only what draws it (see `cursorSource`).
|
|
512
533
|
const showsSharedCursor = useSyncExternalStore(subscribeToLink, useCallback(() => sharedTime?.() != null, [sharedTime]));
|
|
513
|
-
const sharedCursorBar = useSyncExternalStore(subscribeToLink, useCallback(() => {
|
|
514
|
-
const time = sharedTime?.() ?? null;
|
|
515
|
-
return time === null || !baseScene ? null : compositeLinkedCursorTime(baseScene, time);
|
|
516
|
-
}, [baseScene, sharedTime]));
|
|
517
534
|
const holdsSharedCursor = useSyncExternalStore(subscribeToLink, link?.held ?? holdsNothing);
|
|
518
535
|
const pinnedCursor = useSyncExternalStore(subscribeToLink, link?.pinned ?? holdsNothing);
|
|
519
536
|
const publishCursor = link?.publish;
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
baseScene,
|
|
527
|
-
normalizedCursorTimestamp === null ? null : new Date(normalizedCursorTimestamp),
|
|
528
|
-
);
|
|
529
|
-
}, [baseScene, normalizedCursorTimestamp, sharedCursorBar, showsSharedCursor]);
|
|
537
|
+
const cursorSource = useMemo<CompositeCursorSource | null>(() => baseScene ? createCompositeCursorSource({
|
|
538
|
+
baseScene,
|
|
539
|
+
own: ownsCursor ? ownCursor : null,
|
|
540
|
+
fallback: ownerCursorTimestamp,
|
|
541
|
+
link,
|
|
542
|
+
}) : null, [baseScene, link, ownCursor, ownerCursorTimestamp, ownsCursor]);
|
|
530
543
|
const lastCursorTimestampRef = useRef<number | null>(normalizedCursorTimestamp);
|
|
531
544
|
const renderedCursorTimestampRef = useRef<number | null>(normalizedCursorTimestamp);
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
545
|
+
// The cursor last shown, which a move to the same time does not report
|
|
546
|
+
// again. It follows the chart's own cursor as it moves, between renders.
|
|
547
|
+
const syncShownCursor = useCallback(() => {
|
|
548
|
+
const shown = currentCursorTimestamp();
|
|
549
|
+
if (renderedCursorTimestampRef.current === shown) return;
|
|
550
|
+
renderedCursorTimestampRef.current = shown;
|
|
551
|
+
lastCursorTimestampRef.current = shown;
|
|
552
|
+
}, [currentCursorTimestamp]);
|
|
553
|
+
syncShownCursor();
|
|
554
|
+
useEffect(() => ownCursor.subscribe(syncShownCursor), [ownCursor, syncShownCursor]);
|
|
536
555
|
|
|
537
556
|
const updateCursor = useCallback((date: Date | null) => {
|
|
538
557
|
const timestamp = date?.getTime() ?? null;
|
|
539
558
|
const nextTimestamp = timestamp !== null && Number.isFinite(timestamp) ? timestamp : null;
|
|
540
559
|
if (lastCursorTimestampRef.current === nextTimestamp) return;
|
|
541
560
|
lastCursorTimestampRef.current = nextTimestamp;
|
|
542
|
-
if (ownsCursor)
|
|
561
|
+
if (ownsCursor) ownCursor.set(nextTimestamp);
|
|
543
562
|
onCursorDateChange?.(date);
|
|
544
563
|
publishCursor?.(date && baseScene && nextTimestamp !== null ? compositeCursorAsOf(baseScene, date) : null);
|
|
545
|
-
}, [baseScene, onCursorDateChange, ownsCursor, publishCursor]);
|
|
564
|
+
}, [baseScene, onCursorDateChange, ownCursor, ownsCursor, publishCursor]);
|
|
546
565
|
// Another chart taking the cursor, or clearing it, takes it from this one,
|
|
547
566
|
// so it does not come back here later. Read live: a move since the render
|
|
548
567
|
// makes this chart's cursor the shared one again.
|
|
@@ -570,12 +589,15 @@ function ThemedCompositeChart({
|
|
|
570
589
|
// The last time sits in a ref, so a moving crosshair costs no extra render,
|
|
571
590
|
// and the footer's pin is there from the start: a hint appearing mid-hover
|
|
572
591
|
// would move the plot under the pointer.
|
|
573
|
-
const cursorAt = scene?.cursorDate?.getTime() ?? null;
|
|
574
592
|
const lastCursorAtRef = useRef<{ time: number; shared: boolean } | null>(null);
|
|
575
|
-
|
|
576
|
-
const
|
|
593
|
+
const noteShownCursor = useCallback(() => {
|
|
594
|
+
const cursorAt = cursorSource?.scene().cursorDate?.getTime() ?? null;
|
|
595
|
+
if (cursorAt === null) return;
|
|
596
|
+
const shared = sharedTime?.() ?? null;
|
|
577
597
|
lastCursorAtRef.current = shared !== null ? { time: shared, shared: true } : { time: cursorAt, shared: false };
|
|
578
|
-
}
|
|
598
|
+
}, [cursorSource, sharedTime]);
|
|
599
|
+
noteShownCursor();
|
|
600
|
+
useEffect(() => cursorSource?.subscribe(noteShownCursor), [cursorSource, noteShownCursor]);
|
|
579
601
|
const pinnable = !!link?.pin;
|
|
580
602
|
const togglePin = useCallback(() => {
|
|
581
603
|
if (!link?.pin) return;
|
|
@@ -702,7 +724,8 @@ function ThemedCompositeChart({
|
|
|
702
724
|
interactive,
|
|
703
725
|
navigable,
|
|
704
726
|
showLegend,
|
|
705
|
-
scene,
|
|
727
|
+
scene: baseScene,
|
|
728
|
+
cursor: cursorSource,
|
|
706
729
|
cursorDate,
|
|
707
730
|
updateCursor: updateKeyboardCursor,
|
|
708
731
|
pin: pinnable ? { pinned: pinnedCursor, toggle: togglePin } : null,
|
|
@@ -882,7 +905,7 @@ function ThemedCompositeChart({
|
|
|
882
905
|
() => baseScene && showTimeAxis ? buildCompositeTimeAxisLayout(baseScene, plotWidth) : null,
|
|
883
906
|
[baseScene, plotWidth, showTimeAxis],
|
|
884
907
|
);
|
|
885
|
-
const emptyTimeAxisLayout = !
|
|
908
|
+
const emptyTimeAxisLayout = !baseScene && showTimeAxis && effectiveViewport
|
|
886
909
|
? buildCompositeViewportTimeAxisLayout(effectiveViewport, plotWidth)
|
|
887
910
|
: null;
|
|
888
911
|
|
|
@@ -898,7 +921,7 @@ function ThemedCompositeChart({
|
|
|
898
921
|
? { width: "auto", height: "auto", right: `calc(${rightPadding} * var(--cell-w))`, bottom: `calc(${timeAxisRows + xMarkerRows} * var(--cell-h))` }
|
|
899
922
|
: undefined;
|
|
900
923
|
|
|
901
|
-
if (!
|
|
924
|
+
if (!baseScene || !cursorSource) {
|
|
902
925
|
const emptyPlotHeight = Math.max(0, totalHeight - legendRows - timeAxisRows - xMarkerRows);
|
|
903
926
|
return (
|
|
904
927
|
<Box
|
|
@@ -985,29 +1008,18 @@ function ThemedCompositeChart({
|
|
|
985
1008
|
// while a tool picked from the keys is in hand, so the plot says which one.
|
|
986
1009
|
const toolbarFolded = showToolbar && chartLayout.toolbarHidden === true && armedTool === null;
|
|
987
1010
|
// Bars shorter than a day carry a time of day the cursor reads out.
|
|
988
|
-
const intradayBars =
|
|
1011
|
+
const intradayBars = baseScene.timeZone !== undefined || visibleSeries.some((entry) => (
|
|
989
1012
|
!!entry.historyResolution && isIntradayResolution(entry.historyResolution)
|
|
990
1013
|
));
|
|
991
|
-
const timeAxisCursorColumn = scene.cursorXRatio === null
|
|
992
|
-
? null
|
|
993
|
-
: scene.cursorXRatio * Math.max(plotWidth - 1, 0);
|
|
994
|
-
const timeAxisCursorPixelX = timeAxisCursorColumn === null
|
|
995
|
-
? null
|
|
996
|
-
: timeAxisCursorColumn * cellWidthPx;
|
|
997
|
-
const timeAxisCursorLabel = xAxis?.formatCursor && scene.cursorXRatio !== null
|
|
998
|
-
? xAxis.formatCursor(scene.cursorXRatio)
|
|
999
|
-
: scene.cursorDate
|
|
1000
|
-
? formatCompositeCursorAxisDate(scene.cursorDate, scene.startTime, scene.endTime, scene.timeZone, intradayBars)
|
|
1001
|
-
: null;
|
|
1002
1014
|
// The crosshair labels the moving end, so the axis only adds the anchor.
|
|
1003
1015
|
const timeAxisMarkers = toolSpan
|
|
1004
1016
|
? [{
|
|
1005
1017
|
ratio: toolSpan.startXRatio,
|
|
1006
1018
|
label: formatCompositeCursorAxisDate(
|
|
1007
1019
|
new Date(toolSpan.startTime),
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1020
|
+
baseScene.startTime,
|
|
1021
|
+
baseScene.endTime,
|
|
1022
|
+
baseScene.timeZone,
|
|
1011
1023
|
intradayBars,
|
|
1012
1024
|
),
|
|
1013
1025
|
color: toolSpan.color,
|
|
@@ -1028,10 +1040,10 @@ function ThemedCompositeChart({
|
|
|
1028
1040
|
data-gloom-data={navigationFrame ? `${navigationFrame.dataStart}:${navigationFrame.dataEnd}` : undefined}
|
|
1029
1041
|
>
|
|
1030
1042
|
{showLegend ? (
|
|
1031
|
-
<
|
|
1043
|
+
<CursorLegend
|
|
1032
1044
|
// Every series' value at the crosshair, the latest ones when the
|
|
1033
1045
|
// pointer leaves; the price and the time under it sit on the axes.
|
|
1034
|
-
|
|
1046
|
+
cursor={cursorSource}
|
|
1035
1047
|
series={visibleLegendSeries}
|
|
1036
1048
|
visibleSeriesIds={visibleSeriesIds}
|
|
1037
1049
|
lineCues={lineCues}
|
|
@@ -1122,11 +1134,12 @@ function ThemedCompositeChart({
|
|
|
1122
1134
|
onRestore={setDrawings}
|
|
1123
1135
|
/>
|
|
1124
1136
|
) : null}
|
|
1125
|
-
{
|
|
1137
|
+
{baseScene.panels.map((panel, index) => (
|
|
1126
1138
|
<CompositePanelSurface
|
|
1127
1139
|
key={panel.id}
|
|
1128
1140
|
panel={panel}
|
|
1129
|
-
scene={
|
|
1141
|
+
scene={baseScene}
|
|
1142
|
+
cursor={cursorSource}
|
|
1130
1143
|
plotWidth={plotWidth}
|
|
1131
1144
|
leftAxisWidth={leftAxisWidth}
|
|
1132
1145
|
rightAxisWidth={rightAxisWidth}
|
|
@@ -1217,14 +1230,15 @@ function ThemedCompositeChart({
|
|
|
1217
1230
|
data-gloom-role="composite-chart-time-scale"
|
|
1218
1231
|
>
|
|
1219
1232
|
{leftPadding > 0 ? <Box width={leftPadding} /> : null}
|
|
1220
|
-
<
|
|
1233
|
+
<CursorTimeAxis
|
|
1234
|
+
cursor={cursorSource}
|
|
1235
|
+
formatCursor={xAxis?.formatCursor}
|
|
1236
|
+
intradayBars={intradayBars}
|
|
1237
|
+
cellWidthPx={cellWidthPx}
|
|
1221
1238
|
labels={xAxis?.ticks ? [] : xAxis?.labels ? [...xAxis.labels] : [timeAxisLayout.text]}
|
|
1222
1239
|
positionedLabels={xAxis?.ticks ?? (xAxis?.labels ? undefined : timeAxisLayout.ticks)}
|
|
1223
1240
|
width={plotWidth}
|
|
1224
1241
|
color={resolvedColors.textDim}
|
|
1225
|
-
cursorColumn={timeAxisCursorColumn}
|
|
1226
|
-
cursorPixelX={timeAxisCursorPixelX}
|
|
1227
|
-
cursorLabel={timeAxisCursorLabel}
|
|
1228
1242
|
cursorColor={resolvedColors.crosshair}
|
|
1229
1243
|
cursorBackgroundColor={resolvedColors.background}
|
|
1230
1244
|
extraMarkers={timeAxisMarkers}
|
|
@@ -1246,3 +1260,44 @@ function ThemedCompositeChart({
|
|
|
1246
1260
|
</Box>
|
|
1247
1261
|
);
|
|
1248
1262
|
}
|
|
1263
|
+
|
|
1264
|
+
/** The legend, rendering with the crosshair: its values are the series' at the cursor. */
|
|
1265
|
+
function CursorLegend({ cursor, ...props }: Omit<ComponentProps<typeof CompositeLegend>, "scene"> & {
|
|
1266
|
+
cursor: CompositeCursorSource;
|
|
1267
|
+
}) {
|
|
1268
|
+
return <CompositeLegend {...props} scene={useCursorScene(cursor)} />;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/** The time axis, rendering with the crosshair: its label sits at the cursor, and the ticks under it step aside. */
|
|
1272
|
+
function CursorTimeAxis({
|
|
1273
|
+
cursor,
|
|
1274
|
+
formatCursor,
|
|
1275
|
+
intradayBars,
|
|
1276
|
+
cellWidthPx,
|
|
1277
|
+
width,
|
|
1278
|
+
...props
|
|
1279
|
+
}: Omit<ComponentProps<typeof StaticXAxisLabels>, "cursorColumn" | "cursorPixelX" | "cursorLabel"> & {
|
|
1280
|
+
cursor: CompositeCursorSource;
|
|
1281
|
+
formatCursor?: (ratio: number) => string;
|
|
1282
|
+
intradayBars: boolean;
|
|
1283
|
+
cellWidthPx: number;
|
|
1284
|
+
}) {
|
|
1285
|
+
const scene = useCursorScene(cursor);
|
|
1286
|
+
const cursorColumn = scene.cursorXRatio === null
|
|
1287
|
+
? null
|
|
1288
|
+
: scene.cursorXRatio * Math.max(width - 1, 0);
|
|
1289
|
+
const cursorLabel = formatCursor && scene.cursorXRatio !== null
|
|
1290
|
+
? formatCursor(scene.cursorXRatio)
|
|
1291
|
+
: scene.cursorDate
|
|
1292
|
+
? formatCompositeCursorAxisDate(scene.cursorDate, scene.startTime, scene.endTime, scene.timeZone, intradayBars)
|
|
1293
|
+
: null;
|
|
1294
|
+
return (
|
|
1295
|
+
<StaticXAxisLabels
|
|
1296
|
+
{...props}
|
|
1297
|
+
width={width}
|
|
1298
|
+
cursorColumn={cursorColumn}
|
|
1299
|
+
cursorPixelX={cursorColumn === null ? null : cursorColumn * cellWidthPx}
|
|
1300
|
+
cursorLabel={cursorLabel}
|
|
1301
|
+
/>
|
|
1302
|
+
);
|
|
1303
|
+
}
|