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
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
import {
|
|
18
18
|
buildCompositeTimeScale,
|
|
19
19
|
COMPOSITE_RIGHT_OFFSET_RATIO,
|
|
20
|
+
compositeTimeProjector,
|
|
20
21
|
projectCompositeTimestamp,
|
|
21
22
|
unprojectCompositeTimestamp,
|
|
22
23
|
} from "./time-scale";
|
|
@@ -108,10 +109,33 @@ interface NormalizedPointsCache {
|
|
|
108
109
|
// the last point in place, so the cache also keys on its time and value.
|
|
109
110
|
const normalizedPointsCache = new WeakMap<ResolvedSeries, NormalizedPointsCache>();
|
|
110
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Points already in time order, one per instant and with no fiscal period,
|
|
114
|
+
* normalise in order: each is its own observation, at its own date. Null for
|
|
115
|
+
* anything else, which goes through the keyed sort.
|
|
116
|
+
*/
|
|
117
|
+
function orderedSourcePoints(points: readonly TimeSeriesPoint[]): NormalizedSourcePoint[] | null {
|
|
118
|
+
const normalized: NormalizedSourcePoint[] = [];
|
|
119
|
+
let previous = Number.NEGATIVE_INFINITY;
|
|
120
|
+
for (const point of points) {
|
|
121
|
+
if (point.periodLabel !== undefined) return null;
|
|
122
|
+
const timestamp = pointTime(point);
|
|
123
|
+
if (timestamp === null || timestamp <= previous) return null;
|
|
124
|
+
previous = timestamp;
|
|
125
|
+
normalized.push({ point, timestamp, value: resolveTimeSeriesPointValue(point) });
|
|
126
|
+
}
|
|
127
|
+
return normalized;
|
|
128
|
+
}
|
|
129
|
+
|
|
111
130
|
function computeNormalizedSourcePoints(
|
|
112
131
|
series: ResolvedSeries,
|
|
113
132
|
timeScale?: CompositeTimeScale,
|
|
114
133
|
): NormalizedSourcePoint[] {
|
|
134
|
+
// Placed at their own dates, points in time order are already normalised;
|
|
135
|
+
// a live chart re-resolves its series on every tick.
|
|
136
|
+
const effectiveTimes = timeScale?.kind === "market" && !isMarketObservationSeries(series);
|
|
137
|
+
const ordered = effectiveTimes ? null : orderedSourcePoints(series.points);
|
|
138
|
+
if (ordered) return ordered;
|
|
115
139
|
const byObservation = new Map<string, NormalizedSourcePoint>();
|
|
116
140
|
for (const point of series.points) {
|
|
117
141
|
const sourceTimestamp = pointTime(point);
|
|
@@ -165,16 +189,34 @@ function normalizedSourcePoints(
|
|
|
165
189
|
return normalized;
|
|
166
190
|
}
|
|
167
191
|
|
|
168
|
-
function
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
192
|
+
function hasDrawableValue(series: ResolvedSeries): boolean {
|
|
193
|
+
return normalizedSourcePoints(series).some((entry) => entry.value !== null);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The sorted union of timestamp lists that are each sorted, as
|
|
198
|
+
* `[...new Set(lists.flat())].sort()` gives it, merged in one pass.
|
|
199
|
+
*/
|
|
200
|
+
function mergeSortedTimestamps(lists: readonly (readonly number[])[]): number[] {
|
|
201
|
+
let merged: number[] = [];
|
|
202
|
+
for (const list of lists) {
|
|
203
|
+
const next: number[] = [];
|
|
204
|
+
let left = 0;
|
|
205
|
+
let right = 0;
|
|
206
|
+
while (left < merged.length || right < list.length) {
|
|
207
|
+
const fromLeft = right >= list.length || (left < merged.length && merged[left]! <= list[right]!);
|
|
208
|
+
const value = fromLeft ? merged[left++]! : list[right++]!;
|
|
209
|
+
if (next.length === 0 || next[next.length - 1] !== value) next.push(value);
|
|
210
|
+
}
|
|
211
|
+
merged = next;
|
|
212
|
+
}
|
|
213
|
+
return merged;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function timestampsOf(points: readonly NormalizedSourcePoint[]): number[] {
|
|
217
|
+
const timestamps = new Array<number>(points.length);
|
|
218
|
+
for (let index = 0; index < points.length; index += 1) timestamps[index] = points[index]!.timestamp;
|
|
219
|
+
return timestamps;
|
|
178
220
|
}
|
|
179
221
|
|
|
180
222
|
function explicitViewport(
|
|
@@ -198,10 +240,11 @@ function scopeSeriesToViewport(
|
|
|
198
240
|
const placement = timeScale.kind === "market" && !isMarketObservationSeries(series)
|
|
199
241
|
? "next-market-slot" as const
|
|
200
242
|
: "timestamp" as const;
|
|
243
|
+
const project = compositeTimeProjector(timeScale, placement);
|
|
201
244
|
const visible = points.filter(({ timestamp }) => {
|
|
202
245
|
if (timestamp >= startTime && timestamp <= endTime) return true;
|
|
203
246
|
if (clipToViewport) return false;
|
|
204
|
-
const projected =
|
|
247
|
+
const projected = project(timestamp);
|
|
205
248
|
return !!projected && projected.ratio >= 0 && projected.ratio <= 1;
|
|
206
249
|
});
|
|
207
250
|
if (series.interpolation === "step-after" || series.style === "step") {
|
|
@@ -271,31 +314,67 @@ export function allocateCompositePanelHeights(
|
|
|
271
314
|
return heights;
|
|
272
315
|
}
|
|
273
316
|
|
|
274
|
-
|
|
275
|
-
|
|
317
|
+
/**
|
|
318
|
+
* The extremes of a set of values, of all of them and of the positive ones a
|
|
319
|
+
* log axis can show, gathered without keeping the values.
|
|
320
|
+
*/
|
|
321
|
+
interface DomainExtent {
|
|
322
|
+
count: number;
|
|
323
|
+
min: number;
|
|
324
|
+
max: number;
|
|
325
|
+
positiveCount: number;
|
|
326
|
+
positiveMin: number;
|
|
327
|
+
positiveMax: number;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function emptyDomainExtent(): DomainExtent {
|
|
331
|
+
return {
|
|
332
|
+
count: 0,
|
|
333
|
+
min: Number.POSITIVE_INFINITY,
|
|
334
|
+
max: Number.NEGATIVE_INFINITY,
|
|
335
|
+
positiveCount: 0,
|
|
336
|
+
positiveMin: Number.POSITIVE_INFINITY,
|
|
337
|
+
positiveMax: Number.NEGATIVE_INFINITY,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function addDomainValue(extent: DomainExtent, value: number): void {
|
|
342
|
+
extent.count += 1;
|
|
343
|
+
extent.min = Math.min(extent.min, value);
|
|
344
|
+
extent.max = Math.max(extent.max, value);
|
|
345
|
+
if (value > 0) {
|
|
346
|
+
extent.positiveCount += 1;
|
|
347
|
+
extent.positiveMin = Math.min(extent.positiveMin, value);
|
|
348
|
+
extent.positiveMax = Math.max(extent.positiveMax, value);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** Every value a series holds its axis open for: its points, their bar extremes or band, and zero under columns. */
|
|
353
|
+
function addSeriesDomainValues(extent: DomainExtent, series: ResolvedSeries): void {
|
|
354
|
+
const ohlc = series.dataShape === "ohlcv";
|
|
355
|
+
const band = !ohlc && series.style === "band";
|
|
276
356
|
for (const point of series.points) {
|
|
277
357
|
const scalar = resolveTimeSeriesPointValue(point);
|
|
278
|
-
if (scalar !== null)
|
|
279
|
-
if (
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
358
|
+
if (scalar !== null) addDomainValue(extent, scalar);
|
|
359
|
+
if (ohlc) {
|
|
360
|
+
if (isFiniteNumber(point.open)) addDomainValue(extent, point.open);
|
|
361
|
+
if (isFiniteNumber(point.high)) addDomainValue(extent, point.high);
|
|
362
|
+
if (isFiniteNumber(point.low)) addDomainValue(extent, point.low);
|
|
363
|
+
if (isFiniteNumber(point.close)) addDomainValue(extent, point.close);
|
|
364
|
+
} else if (band) {
|
|
365
|
+
if (isFiniteNumber(point.high)) addDomainValue(extent, point.high);
|
|
366
|
+
if (isFiniteNumber(point.low)) addDomainValue(extent, point.low);
|
|
287
367
|
}
|
|
288
368
|
}
|
|
289
|
-
if (series.style === "columns")
|
|
290
|
-
return values;
|
|
369
|
+
if (series.style === "columns") addDomainValue(extent, 0);
|
|
291
370
|
}
|
|
292
371
|
|
|
293
|
-
function paddedDomain(
|
|
294
|
-
const usable = scale === "log" ?
|
|
295
|
-
if (usable
|
|
372
|
+
function paddedDomain(extent: DomainExtent, scale: PanelScale): { min: number; max: number } {
|
|
373
|
+
const usable = scale === "log" ? extent.positiveCount : extent.count;
|
|
374
|
+
if (usable === 0) return scale === "log" ? { min: 1, max: 10 } : { min: 0, max: 1 };
|
|
296
375
|
|
|
297
|
-
const rawMin =
|
|
298
|
-
const rawMax =
|
|
376
|
+
const rawMin = scale === "log" ? extent.positiveMin : extent.min;
|
|
377
|
+
const rawMax = scale === "log" ? extent.positiveMax : extent.max;
|
|
299
378
|
if (rawMin === rawMax) {
|
|
300
379
|
if (scale === "log") {
|
|
301
380
|
return { min: rawMin / 1.1, max: rawMax * 1.1 };
|
|
@@ -342,15 +421,11 @@ function axisPriceReferences(axisSeries: ResolvedSeries[]): Record<string, numbe
|
|
|
342
421
|
* session range of the bars, so a quiet session still shows where it opened
|
|
343
422
|
* from; a far gap leaves the bars their full height.
|
|
344
423
|
*/
|
|
345
|
-
function priorCloseInReach(series: readonly ResolvedSeries[], values:
|
|
424
|
+
function priorCloseInReach(series: readonly ResolvedSeries[], values: DomainExtent): number[] {
|
|
346
425
|
const reference = series.find((entry) => isFiniteNumber(entry.priorClose) && entry.points.length > 0)?.priorClose;
|
|
347
|
-
if (reference === undefined || values.
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
for (const value of values) {
|
|
351
|
-
if (value < low) low = value;
|
|
352
|
-
if (value > high) high = value;
|
|
353
|
-
}
|
|
426
|
+
if (reference === undefined || values.count === 0) return [];
|
|
427
|
+
const low = values.min;
|
|
428
|
+
const high = values.max;
|
|
354
429
|
const span = high - low;
|
|
355
430
|
return reference >= low - span && reference <= high + span ? [reference] : [];
|
|
356
431
|
}
|
|
@@ -365,11 +440,16 @@ function buildAxisDomain(
|
|
|
365
440
|
): CompositeAxisDomain | undefined {
|
|
366
441
|
const axisSeries = series.filter((entry) => entry.axis === side);
|
|
367
442
|
if (axisSeries.length === 0) return undefined;
|
|
368
|
-
const values =
|
|
443
|
+
const values = emptyDomainExtent();
|
|
444
|
+
for (const entry of axisSeries) addSeriesDomainValues(values, entry);
|
|
369
445
|
const references = referenceLevels && axisSeries.some((entry) => entry.id === referenceLevels.seriesId)
|
|
370
446
|
? referenceLevels.items.map((level) => level.value).filter(Number.isFinite)
|
|
371
447
|
: [];
|
|
372
|
-
const
|
|
448
|
+
const extra = [...priorCloseInReach(axisSeries, values), ...references];
|
|
449
|
+
const fitted = paddedDomain(extra.length === 0 ? values : extra.reduce((extent, value) => {
|
|
450
|
+
addDomainValue(extent, value);
|
|
451
|
+
return extent;
|
|
452
|
+
}, { ...values }), scale);
|
|
373
453
|
const scaleKey = valueScaleKey(scale, axisSeries);
|
|
374
454
|
// A range set by hand holds while the axis plots the same series and some
|
|
375
455
|
// of their data is in it; otherwise the axis fits the data again.
|
|
@@ -390,6 +470,7 @@ function buildAxisDomain(
|
|
|
390
470
|
seriesIds: axisSeries.map((entry) => entry.id),
|
|
391
471
|
maxTicks: compositeAxisMaxTicks(rows),
|
|
392
472
|
tickRows: rows,
|
|
473
|
+
...(first.tickGrid ? { tickGrid: first.tickGrid } : {}),
|
|
393
474
|
scaleKey,
|
|
394
475
|
...(manual ? { manual: true } : {}),
|
|
395
476
|
};
|
|
@@ -463,6 +544,7 @@ function projectSeries(
|
|
|
463
544
|
? "next-market-slot" as const
|
|
464
545
|
: "timestamp" as const;
|
|
465
546
|
const stepSeries = series.interpolation === "step-after" || series.style === "step";
|
|
547
|
+
const project = compositeTimeProjector(timeScale, placement);
|
|
466
548
|
for (const { point, timestamp, value } of normalizedSourcePoints(series, timeScale)) {
|
|
467
549
|
if (value === null) {
|
|
468
550
|
breakBefore = true;
|
|
@@ -473,7 +555,7 @@ function projectSeries(
|
|
|
473
555
|
breakBefore = true;
|
|
474
556
|
continue;
|
|
475
557
|
}
|
|
476
|
-
const projectedTime =
|
|
558
|
+
const projectedTime = project(timestamp);
|
|
477
559
|
if (!projectedTime) continue;
|
|
478
560
|
const beforeViewportStepAnchor = stepSeries
|
|
479
561
|
&& timestamp < startTime
|
|
@@ -667,6 +749,28 @@ function cursorPointForSeries(
|
|
|
667
749
|
return points[low - 1] ?? null;
|
|
668
750
|
}
|
|
669
751
|
|
|
752
|
+
/**
|
|
753
|
+
* The latest unavailable observation at or before the cursor and after the
|
|
754
|
+
* value it reads there, which ends that value. Points are in time order, so
|
|
755
|
+
* the search stops at the first one older than that value.
|
|
756
|
+
*/
|
|
757
|
+
function gapAfterCursorValue(
|
|
758
|
+
points: readonly NormalizedSourcePoint[],
|
|
759
|
+
cursorTime: number,
|
|
760
|
+
projected: CompositeProjectedPoint | null,
|
|
761
|
+
): NormalizedSourcePoint | undefined {
|
|
762
|
+
const after = projected?.timestamp ?? Number.NEGATIVE_INFINITY;
|
|
763
|
+
for (let index = points.length - 1; index >= 0; index -= 1) {
|
|
764
|
+
const entry = points[index]!;
|
|
765
|
+
const { timestamp, point, value } = entry;
|
|
766
|
+
if (timestamp < after) return undefined;
|
|
767
|
+
if (timestamp > cursorTime) continue;
|
|
768
|
+
const later = timestamp > after || (timestamp === projected?.timestamp && point.observedAt > projected.point.observedAt);
|
|
769
|
+
if (later && (point.provenance?.priceHistoryIntegrity || value === null)) return entry;
|
|
770
|
+
}
|
|
771
|
+
return undefined;
|
|
772
|
+
}
|
|
773
|
+
|
|
670
774
|
function buildCursorValues(
|
|
671
775
|
panels: CompositePanelScene[],
|
|
672
776
|
cursorDate: Date | null,
|
|
@@ -688,11 +792,7 @@ function buildCursorValues(
|
|
|
688
792
|
let projected = cursorPointForSeries(entry, cursorTime);
|
|
689
793
|
// Sparse observations can carry forward, but an explicitly unavailable
|
|
690
794
|
// observation ends that value at its date, including the idle legend.
|
|
691
|
-
const gap = normalizedSourcePoints(entry.source, viewport.timeScale)
|
|
692
|
-
timestamp <= cursorTime && (timestamp > (projected?.timestamp ?? Number.NEGATIVE_INFINITY)
|
|
693
|
-
|| (timestamp === projected?.timestamp && point.observedAt > projected.point.observedAt))
|
|
694
|
-
&& (point.provenance?.priceHistoryIntegrity || value === null)
|
|
695
|
-
));
|
|
795
|
+
const gap = gapAfterCursorValue(normalizedSourcePoints(entry.source, viewport.timeScale), cursorTime, projected);
|
|
696
796
|
if (gap) projected = null;
|
|
697
797
|
// The drawn navigation buffer can include observations after the chosen
|
|
698
798
|
// end. An unarmed legend describes the active window, including when the
|
|
@@ -799,13 +899,12 @@ export function buildCompositeChartScene(
|
|
|
799
899
|
): CompositeChartScene | null {
|
|
800
900
|
const dataSeries = series
|
|
801
901
|
.map((entry) => entry.style === "heikin-ashi" ? { ...entry, points: heikinAshiPoints(entry.points) } : entry)
|
|
802
|
-
.filter(
|
|
902
|
+
.filter(hasDrawableValue);
|
|
803
903
|
if (dataSeries.length === 0) return null;
|
|
804
904
|
|
|
805
905
|
// A known missing observation owns a date even though it has no drawable
|
|
806
906
|
// value. Retain it in the window and cursor timeline, including trailing gaps.
|
|
807
|
-
const
|
|
808
|
-
const uniqueTimes = [...new Set(times)].sort((left, right) => left - right);
|
|
907
|
+
const uniqueTimes = mergeSortedTimestamps(dataSeries.map((entry) => timestampsOf(normalizedSourcePoints(entry))));
|
|
809
908
|
if (uniqueTimes.length === 0) return null;
|
|
810
909
|
const firstTime = uniqueTimes[0]!;
|
|
811
910
|
const lastTime = uniqueTimes.at(-1)!;
|
|
@@ -844,15 +943,12 @@ export function buildCompositeChartScene(
|
|
|
844
943
|
// observation must remain inspectable. Other exchanges can trade before
|
|
845
944
|
// or after its anchors. Nonmarket source dates stay excluded: filings
|
|
846
945
|
// retain their availability-based placement on eligible market slots.
|
|
847
|
-
?
|
|
848
|
-
|
|
946
|
+
? mergeSortedTimestamps([
|
|
947
|
+
timeScale.anchors.map(({ timestamp }) => timestamp),
|
|
849
948
|
...scopedSeries.filter(isMarketObservationSeries)
|
|
850
|
-
.
|
|
851
|
-
.filter(({ value, point }) => value !== null || point.provenance?.priceHistoryIntegrity)
|
|
852
|
-
|
|
853
|
-
])]
|
|
854
|
-
.filter((time) => time >= startTime && time <= plotEndTime)
|
|
855
|
-
.sort((left, right) => left - right)
|
|
949
|
+
.map((entry) => timestampsOf(normalizedSourcePoints(entry)
|
|
950
|
+
.filter(({ value, point }) => value !== null || point.provenance?.priceHistoryIntegrity))),
|
|
951
|
+
]).filter((time) => time >= startTime && time <= plotEndTime)
|
|
856
952
|
: [];
|
|
857
953
|
const cursorTimes = timeScale.kind === "market" ? marketTimes : visibleTimes;
|
|
858
954
|
const dates = (cursorTimes.length > 0
|
|
@@ -861,9 +957,8 @@ export function buildCompositeChartScene(
|
|
|
861
957
|
? [...new Set([startTime, endTime])]
|
|
862
958
|
: uniqueTimes
|
|
863
959
|
).map((time) => new Date(time));
|
|
864
|
-
const
|
|
865
|
-
|
|
866
|
-
));
|
|
960
|
+
const projectDate = compositeTimeProjector(timeScale);
|
|
961
|
+
const dateRatios = dates.map((date) => projectDate(date.getTime())?.ratio ?? 0);
|
|
867
962
|
const requestedCursor = options.cursorDate ?? null;
|
|
868
963
|
const cursorDate = requestedCursor ? nearestDate(dates, requestedCursor) : null;
|
|
869
964
|
const cursorXRatio = cursorDate
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { memo } from "react";
|
|
1
2
|
import { Box, Text } from "../../../ui";
|
|
2
3
|
import { clamp } from "../../../utils/math";
|
|
3
4
|
import type { SeriesAxisTag } from "./panel-labels";
|
|
@@ -28,7 +29,8 @@ export function placeSeriesAxisTags(tags: readonly SeriesAxisTag[], pixelHeight:
|
|
|
28
29
|
return placed;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
/** Each series' value at the cursor, beside the axis; it renders when they move, not with the pointer's height. */
|
|
33
|
+
export const SeriesAxisTags = memo(function SeriesAxisTags({ placed, pixelHeight, lanes, background }: {
|
|
32
34
|
placed: ReturnType<typeof placeSeriesAxisTags>;
|
|
33
35
|
pixelHeight: number;
|
|
34
36
|
lanes: number;
|
|
@@ -71,4 +73,4 @@ export function SeriesAxisTags({ placed, pixelHeight, lanes, background }: {
|
|
|
71
73
|
</Box>
|
|
72
74
|
</Box>;
|
|
73
75
|
});
|
|
74
|
-
}
|
|
76
|
+
});
|
|
@@ -349,13 +349,21 @@ function lowerBoundSample(samples: readonly CompositeTimeAxisSample[], timestamp
|
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
function normalizeMarketSamples(scene: CompositeChartScene): CompositeTimeAxisSample[] {
|
|
352
|
-
const samples =
|
|
352
|
+
const samples: CompositeTimeAxisSample[] = [];
|
|
353
|
+
// A scene's dates come in time order, their ratios rising with them.
|
|
354
|
+
let ordered = true;
|
|
355
|
+
scene.dates.forEach((date, index) => {
|
|
353
356
|
const timestamp = date.getTime();
|
|
354
357
|
const ratio = scene.dateRatios[index];
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
358
|
+
if (!validTimestamp(timestamp) || typeof ratio !== "number" || !Number.isFinite(ratio)) return;
|
|
359
|
+
const sample = { timestamp, ratio: clamp(ratio, 0, 1) };
|
|
360
|
+
const previous = samples[samples.length - 1];
|
|
361
|
+
if (previous && (previous.timestamp > timestamp || (previous.timestamp === timestamp && previous.ratio > sample.ratio))) {
|
|
362
|
+
ordered = false;
|
|
363
|
+
}
|
|
364
|
+
samples.push(sample);
|
|
365
|
+
});
|
|
366
|
+
if (!ordered) samples.sort((left, right) => left.timestamp - right.timestamp || left.ratio - right.ratio);
|
|
359
367
|
|
|
360
368
|
return samples.filter((sample, index) => (
|
|
361
369
|
index === 0
|
|
@@ -492,6 +500,17 @@ function addCandidate(
|
|
|
492
500
|
if (!duplicate) candidates.push(candidate);
|
|
493
501
|
}
|
|
494
502
|
|
|
503
|
+
/**
|
|
504
|
+
* Blank cells a regular tick keeps from the start and end labels: half the
|
|
505
|
+
* room between two ticks, from 3 to 5 cells. Those two are the longest labels
|
|
506
|
+
* on the axis (a date with its year), and a tick closer than that reads as a
|
|
507
|
+
* part of one ("Oct Oct 29 2026") instead of a mark of its own.
|
|
508
|
+
*/
|
|
509
|
+
function endpointLabelGap(interval: CompositeTimeAxisInterval, span: number, axisWidth: number): number {
|
|
510
|
+
const tickRoom = (axisWidth * interval.approximateMs) / span;
|
|
511
|
+
return clamp(Math.round(tickRoom / 2), 3, 5);
|
|
512
|
+
}
|
|
513
|
+
|
|
495
514
|
function layoutTimeAxis({
|
|
496
515
|
startTime,
|
|
497
516
|
endTime,
|
|
@@ -641,6 +660,9 @@ function layoutTimeAxis({
|
|
|
641
660
|
const minimumGap = interval.unit === "month" || interval.unit === "year" ? 2 : 1;
|
|
642
661
|
let previousTimestamp = firstTimestamp;
|
|
643
662
|
let previousEnd = startLabel.length - 1;
|
|
663
|
+
const endpointGap = endpointLabelGap(interval, span, axisWidth);
|
|
664
|
+
// The first tick follows the start label, the rest follow a tick.
|
|
665
|
+
let previousGap = endpointGap;
|
|
644
666
|
for (const candidate of candidates.filter((entry) => !entry.boundary)) {
|
|
645
667
|
const label = formatInteriorLabel(candidate.timestamp, previousTimestamp, interval, clock);
|
|
646
668
|
// A year boundary inside the final year would repeat the right endpoint's year.
|
|
@@ -648,8 +670,8 @@ function layoutTimeAxis({
|
|
|
648
670
|
const center = candidate.ratio * Math.max(axisWidth - 1, 0);
|
|
649
671
|
const start = resolveLabelStart(center, label, axisWidth);
|
|
650
672
|
const end = start + label.length - 1;
|
|
651
|
-
if (start <= previousEnd +
|
|
652
|
-
if (end >= endStart -
|
|
673
|
+
if (start <= previousEnd + previousGap) continue;
|
|
674
|
+
if (end >= endStart - endpointGap) continue;
|
|
653
675
|
writeLabel(axis, start, label);
|
|
654
676
|
placed.push({
|
|
655
677
|
timestamp: candidate.timestamp,
|
|
@@ -660,6 +682,7 @@ function layoutTimeAxis({
|
|
|
660
682
|
});
|
|
661
683
|
previousTimestamp = candidate.timestamp;
|
|
662
684
|
previousEnd = end;
|
|
685
|
+
previousGap = minimumGap;
|
|
663
686
|
}
|
|
664
687
|
|
|
665
688
|
writeLabel(axis, endStart, endLabel);
|