@orangecharts/wrun-chart-host 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -6
- package/dist/constants/exchange-names.leaf.d.ts +8 -0
- package/dist/constants/exchange-names.leaf.js +101 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +15 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.js +40 -0
- package/dist/constants/opra-compliance.constants.d.ts +19 -0
- package/dist/constants/opra-compliance.constants.js +19 -0
- package/dist/constants/replay-ladder.leaf.d.ts +30 -0
- package/dist/constants/replay-ladder.leaf.js +99 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +133 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.js +451 -0
- package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +168 -0
- package/dist/constants/scriptEditor/cme-official-scripts.constants.js +398 -0
- package/dist/constants/scriptEditor/converted-script-id.leaf.d.ts +8 -0
- package/dist/constants/scriptEditor/converted-script-id.leaf.js +10 -0
- package/dist/constants/scriptEditor/execution.constants.d.ts +4 -0
- package/dist/constants/scriptEditor/execution.constants.js +14 -0
- package/dist/constants/wrun-prefix-safe.constants.d.ts +23 -0
- package/dist/constants/wrun-prefix-safe.constants.js +26 -0
- package/dist/host-env.d.ts +321 -24
- package/dist/host-env.js +15 -0
- package/dist/host-ports.types.d.ts +857 -35
- package/dist/index.d.ts +149 -2
- package/dist/index.js +149 -2
- package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +31 -0
- package/dist/instances/script-engine-worker-ohlcv-transfer.js +164 -0
- package/dist/interfaces/market-event.interface.d.ts +231 -0
- package/dist/interfaces/market-event.interface.js +15 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +70 -134
- package/dist/interfaces/opra-realtime.interface.js +34 -59
- package/dist/interfaces/replay.interface.d.ts +285 -0
- package/dist/interfaces/replay.interface.js +1 -0
- package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +1 -0
- package/dist/kscript-data/controls/live-ohlcv-merge.util.js +93 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +5 -1
- package/dist/kscript-data/controls/live-trades-merge.util.js +2 -2
- package/dist/market-data/billing.interface.d.ts +219 -0
- package/dist/market-data/billing.interface.js +58 -0
- package/dist/market-data/venue-governed.util.d.ts +2 -0
- package/dist/market-data/venue-governed.util.js +10 -0
- package/dist/market-data/venue.d.ts +122 -0
- package/dist/market-data/venue.js +1 -0
- package/dist/market-data/venues/index.d.ts +97 -0
- package/dist/market-data/venues/index.js +33 -0
- package/dist/market-data/venues/opra.contract.copy.json +35 -0
- package/dist/market-data/venues/opra.d.ts +70 -0
- package/dist/market-data/venues/opra.js +74 -0
- package/dist/replay/replayIndicatorRows.d.ts +31 -0
- package/dist/replay/replayIndicatorRows.js +117 -0
- package/dist/replay/replayLadder.d.ts +85 -0
- package/dist/replay/replayLadder.js +388 -0
- package/dist/utility/auth/server-clock.util.d.ts +81 -0
- package/dist/utility/auth/server-clock.util.js +238 -0
- package/dist/utility/chart/builtin-identity.util.d.ts +18 -0
- package/dist/utility/chart/builtin-identity.util.js +51 -0
- package/dist/utility/chart/cache-alignment.util.d.ts +454 -0
- package/dist/utility/chart/cache-alignment.util.js +926 -0
- package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +15 -0
- package/dist/utility/chart/chart-data-fetch-generation.util.js +22 -0
- package/dist/utility/chart/chart-mount-epoch.util.d.ts +5 -0
- package/dist/utility/chart/chart-mount-epoch.util.js +29 -0
- package/dist/utility/chart/chart-time-domain.util.d.ts +12 -0
- package/dist/utility/chart/chart-time-domain.util.js +23 -0
- package/dist/utility/chart/color-customization.leaf.d.ts +10 -0
- package/dist/utility/chart/color-customization.leaf.js +16 -0
- package/dist/utility/chart/date-labelled-interval.leaf.d.ts +15 -0
- package/dist/utility/chart/date-labelled-interval.leaf.js +19 -0
- package/dist/utility/chart/footprint-tick-grid.util.d.ts +106 -0
- package/dist/utility/chart/footprint-tick-grid.util.js +167 -0
- package/dist/utility/chart/gesture-timing.leaf.d.ts +29 -0
- package/dist/utility/chart/gesture-timing.leaf.js +29 -0
- package/dist/utility/chart/governed-contract-coin.util.d.ts +22 -0
- package/dist/utility/chart/governed-contract-coin.util.js +39 -0
- package/dist/utility/chart/host-bar-placement.util.d.ts +107 -0
- package/dist/utility/chart/host-bar-placement.util.js +447 -0
- package/dist/utility/chart/index-host-tier.util.d.ts +31 -0
- package/dist/utility/chart/index-host-tier.util.js +118 -0
- package/dist/utility/chart/index-mode-admission.util.d.ts +34 -0
- package/dist/utility/chart/index-mode-admission.util.js +67 -0
- package/dist/utility/chart/indicator-error-message.util.d.ts +35 -0
- package/dist/utility/chart/indicator-error-message.util.js +44 -0
- package/dist/utility/chart/indicator-run-interval.util.d.ts +130 -0
- package/dist/utility/chart/indicator-run-interval.util.js +268 -0
- package/dist/utility/chart/kscript-apply-fingerprint.util.d.ts +65 -0
- package/dist/utility/chart/kscript-apply-fingerprint.util.js +357 -0
- package/dist/utility/chart/kscript-chart-flush.leaf.d.ts +22 -0
- package/dist/utility/chart/kscript-chart-flush.leaf.js +13 -0
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +6 -0
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +27 -0
- package/dist/utility/chart/kscript-integration-decision.leaf.d.ts +89 -0
- package/dist/utility/chart/kscript-integration-decision.leaf.js +80 -0
- package/dist/utility/chart/kscript-live-coalesce.util.d.ts +76 -0
- package/dist/utility/chart/kscript-live-coalesce.util.js +156 -0
- package/dist/utility/chart/kscript-live-rest-pace.util.d.ts +34 -0
- package/dist/utility/chart/kscript-live-rest-pace.util.js +134 -0
- package/dist/utility/chart/kscript-live-source-identity.util.d.ts +98 -0
- package/dist/utility/chart/kscript-live-source-identity.util.js +121 -0
- package/dist/utility/chart/kscript-mounted-plot-set.leaf.d.ts +48 -0
- package/dist/utility/chart/kscript-mounted-plot-set.leaf.js +145 -0
- package/dist/utility/chart/kscript-perf-tracker.util.d.ts +243 -0
- package/dist/utility/chart/kscript-perf-tracker.util.js +522 -0
- package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +43 -0
- package/dist/utility/chart/kscript-run-interval-projection.util.js +471 -0
- package/dist/utility/chart/kscript-run-result-equality.util.d.ts +38 -0
- package/dist/utility/chart/kscript-run-result-equality.util.js +89 -0
- package/dist/utility/chart/kscript-settings-revision.leaf.d.ts +2 -0
- package/dist/utility/chart/kscript-settings-revision.leaf.js +12 -0
- package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +63 -0
- package/dist/utility/chart/kscript-source-degrade.leaf.js +68 -0
- package/dist/utility/chart/kscript-source-retention.util.d.ts +134 -0
- package/dist/utility/chart/kscript-source-retention.util.js +218 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +57 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.js +61 -0
- package/dist/utility/chart/kscript-titancharts-preparation.util.d.ts +15 -0
- package/dist/utility/chart/kscript-titancharts-preparation.util.js +376 -0
- package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +9 -0
- package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +130 -0
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +217 -0
- package/dist/utility/chart/kscript-venue-policy.util.js +324 -0
- package/dist/utility/chart/live-cadence.util.d.ts +38 -0
- package/dist/utility/chart/live-cadence.util.js +37 -0
- package/dist/utility/chart/live-feed-series-match.leaf.d.ts +13 -0
- package/dist/utility/chart/live-feed-series-match.leaf.js +21 -0
- package/dist/utility/chart/local-engine-self-heal-backoff.util.d.ts +46 -0
- package/dist/utility/chart/local-engine-self-heal-backoff.util.js +46 -0
- package/dist/utility/chart/local-engine-uninit.leaf.d.ts +21 -0
- package/dist/utility/chart/local-engine-uninit.leaf.js +22 -0
- package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +62 -0
- package/dist/utility/chart/local-kscript-source-revalidation.util.js +123 -0
- package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +214 -0
- package/dist/utility/chart/local-kscript-warmup-depth.util.js +376 -0
- package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.d.ts +85 -0
- package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.js +197 -0
- package/dist/utility/chart/local-technical-script-range.leaf.d.ts +72 -0
- package/dist/utility/chart/local-technical-script-range.leaf.js +126 -0
- package/dist/utility/chart/mixed-mode.util.d.ts +167 -0
- package/dist/utility/chart/mixed-mode.util.js +139 -0
- package/dist/utility/chart/ohlcv-row-readiness.util.d.ts +36 -0
- package/dist/utility/chart/ohlcv-row-readiness.util.js +90 -0
- package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +19 -0
- package/dist/utility/chart/opra-user-scripts-gate.util.js +32 -0
- package/dist/utility/chart/overlay-execution-guard-key.leaf.d.ts +8 -0
- package/dist/utility/chart/overlay-execution-guard-key.leaf.js +10 -0
- package/dist/utility/chart/price-precision.util.d.ts +40 -0
- package/dist/utility/chart/price-precision.util.js +70 -0
- package/dist/utility/chart/profile-block-size.util.d.ts +64 -0
- package/dist/utility/chart/profile-block-size.util.js +141 -0
- package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.d.ts +11 -0
- package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.js +29 -0
- package/dist/utility/chart/protected-kscript-empty-output.util.d.ts +28 -0
- package/dist/utility/chart/protected-kscript-empty-output.util.js +84 -0
- package/dist/utility/chart/run-interval-unservable.leaf.d.ts +9 -0
- package/dist/utility/chart/run-interval-unservable.leaf.js +20 -0
- package/dist/utility/chart/run-interval-warmup.leaf.d.ts +19 -0
- package/dist/utility/chart/run-interval-warmup.leaf.js +35 -0
- package/dist/utility/chart/titan-constants.pin.d.ts +9 -5
- package/dist/utility/chart/titan-constants.pin.js +18 -5
- package/dist/utility/chart/warmup-backfill-retry.leaf.d.ts +9 -0
- package/dist/utility/chart/warmup-backfill-retry.leaf.js +9 -0
- package/dist/utility/chart/window-geometry.leaf.d.ts +119 -0
- package/dist/utility/chart/window-geometry.leaf.js +391 -0
- package/dist/utility/chart/window-owner.leaf.d.ts +19 -0
- package/dist/utility/chart/window-owner.leaf.js +24 -0
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +11 -2
- package/dist/utility/chart/wrun-bar-session-facts.util.js +10 -3
- package/dist/utility/chart/wrun-run-result.util.d.ts +5 -1
- package/dist/utility/chart/wrun-run-result.util.js +20 -14
- package/dist/utility/common/data-processing.util.d.ts +138 -0
- package/dist/utility/common/data-processing.util.js +346 -0
- package/dist/utility/common/visible-timeout.util.d.ts +13 -4
- package/dist/utility/common/visible-timeout.util.js +23 -8
- package/dist/utility/exchange-format.leaf.d.ts +1 -0
- package/dist/utility/exchange-format.leaf.js +47 -0
- package/dist/utility/html-escape.leaf.d.ts +11 -0
- package/dist/utility/html-escape.leaf.js +20 -0
- package/dist/utility/market-events/earnings-scope.util.d.ts +60 -0
- package/dist/utility/market-events/earnings-scope.util.js +92 -0
- package/dist/utility/market-events/market-events.util.d.ts +147 -0
- package/dist/utility/market-events/market-events.util.js +392 -0
- package/dist/utility/market-events/zoned-clock.util.d.ts +1 -0
- package/dist/utility/market-events/zoned-clock.util.js +11 -0
- package/dist/utility/options/option-venue-disclosure.util.d.ts +43 -0
- package/dist/utility/options/option-venue-disclosure.util.js +56 -0
- package/dist/utility/scriptEditor/package-semver.util.d.ts +51 -0
- package/dist/utility/scriptEditor/package-semver.util.js +120 -0
- package/dist/utility/scriptEditor/temp-script-id.util.d.ts +18 -0
- package/dist/utility/scriptEditor/temp-script-id.util.js +25 -0
- package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.d.ts +20 -0
- package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.js +81 -0
- package/dist/utility/v2/governed-tier.leaf.d.ts +103 -0
- package/dist/utility/v2/governed-tier.leaf.js +113 -0
- package/dist/utility/watchlist/import/import-request.leaf.d.ts +10 -0
- package/dist/utility/watchlist/import/import-request.leaf.js +10 -0
- package/dist/utility/wrun/sources/lanes/option_daily.d.ts +43 -15
- package/dist/utility/wrun/sources/lanes/option_daily.js +78 -20
- package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +14 -10
- package/dist/utility/wrun/sources/lanes/option_stats_10m.js +5 -4
- package/dist/utility/wrun/sources/lanes/series.js +2 -2
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +22 -3
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +38 -7
- package/dist/utility/wrun/sources/registry.js +31 -1
- package/dist/utility/wrun/sources/row-lane-registry.js +5 -5
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +49 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +75 -20
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +49 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +57 -47
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +36 -4
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +6 -12
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +37 -3
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +128 -2
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +233 -51
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +0 -8
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +26 -24
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +85 -104
- package/dist/utility/wrun/wrun-alert-outputs.registry.d.ts +166 -0
- package/dist/utility/wrun/wrun-alert-outputs.registry.js +219 -0
- package/dist/utility/wrun/wrun-bar-count.util.d.ts +83 -0
- package/dist/utility/wrun/wrun-bar-count.util.js +259 -0
- package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +84 -0
- package/dist/utility/wrun/wrun-chart-context-names.util.js +186 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +253 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +731 -0
- package/dist/utility/wrun/wrun-cloud-opra-stamp.util.d.ts +28 -0
- package/dist/utility/wrun/wrun-cloud-opra-stamp.util.js +45 -0
- package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-coin-lane-live.util.js +47 -0
- package/dist/utility/wrun/wrun-deadline.util.js +2 -1
- package/dist/utility/wrun/wrun-debug-output.util.d.ts +39 -0
- package/dist/utility/wrun/wrun-debug-output.util.js +63 -0
- package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +113 -0
- package/dist/utility/wrun/wrun-declared-warmup.util.js +181 -0
- package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +43 -0
- package/dist/utility/wrun/wrun-draft-legend-note.util.js +158 -0
- package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +181 -0
- package/dist/utility/wrun/wrun-draft-overlay.util.js +357 -0
- package/dist/utility/wrun/wrun-draw-skipped.leaf.d.ts +16 -0
- package/dist/utility/wrun/wrun-draw-skipped.leaf.js +16 -0
- package/dist/utility/wrun/wrun-earnings-facts.util.d.ts +42 -0
- package/dist/utility/wrun/wrun-earnings-facts.util.js +131 -0
- package/dist/utility/wrun/wrun-first-run-depth.util.d.ts +32 -0
- package/dist/utility/wrun/wrun-first-run-depth.util.js +118 -0
- package/dist/utility/wrun/wrun-gate-plane-readers.util.d.ts +24 -0
- package/dist/utility/wrun/wrun-gate-plane-readers.util.js +31 -0
- package/dist/utility/wrun/wrun-held-lanes.util.d.ts +32 -0
- package/dist/utility/wrun/wrun-held-lanes.util.js +94 -0
- package/dist/utility/wrun/wrun-host-visible-clock.util.d.ts +2 -0
- package/dist/utility/wrun/wrun-host-visible-clock.util.js +17 -0
- package/dist/utility/wrun/wrun-host.service.d.ts +266 -0
- package/dist/utility/wrun/wrun-host.service.js +655 -0
- package/dist/utility/wrun/wrun-inert-legend.util.d.ts +33 -0
- package/dist/utility/wrun/wrun-inert-legend.util.js +125 -0
- package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +155 -0
- package/dist/utility/wrun/wrun-input-requirements.leaf.js +450 -0
- package/dist/utility/wrun/wrun-integration-route.util.d.ts +51 -0
- package/dist/utility/wrun/wrun-integration-route.util.js +59 -0
- package/dist/utility/wrun/wrun-latest-history.leaf.d.ts +8 -0
- package/dist/utility/wrun/wrun-latest-history.leaf.js +8 -0
- package/dist/utility/wrun/wrun-legend-hover.lazy.d.ts +12 -0
- package/dist/utility/wrun/wrun-legend-hover.lazy.js +96 -0
- package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +21 -0
- package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +21 -0
- package/dist/utility/wrun/wrun-live-hidden-hold.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-live-hidden-hold.util.js +13 -0
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +374 -0
- package/dist/utility/wrun/wrun-live-intake.util.js +2027 -0
- package/dist/utility/wrun/wrun-live-patch.util.d.ts +116 -0
- package/dist/utility/wrun/wrun-live-patch.util.js +523 -0
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +619 -0
- package/dist/utility/wrun/wrun-live-tick.util.js +4974 -0
- package/dist/utility/wrun/wrun-loading-owner.util.d.ts +58 -0
- package/dist/utility/wrun/wrun-loading-owner.util.js +89 -0
- package/dist/utility/wrun/wrun-official-scope.leaf.d.ts +29 -0
- package/dist/utility/wrun/wrun-official-scope.leaf.js +36 -0
- package/dist/utility/wrun/wrun-oi-lane.util.d.ts +27 -0
- package/dist/utility/wrun/wrun-oi-lane.util.js +42 -0
- package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +29 -10
- package/dist/utility/wrun/wrun-opra-stats.leaf.js +29 -10
- package/dist/utility/wrun/wrun-options-stop.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-options-stop.util.js +123 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +719 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +1180 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +50 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +131 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +118 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +466 -0
- package/dist/utility/wrun/wrun-overlay-metadata.util.d.ts +45 -0
- package/dist/utility/wrun/wrun-overlay-metadata.util.js +112 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +114 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +971 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +858 -0
- package/dist/utility/wrun/wrun-overlay-run.util.js +11013 -0
- package/dist/utility/wrun/wrun-panel-mount.lazy.d.ts +10 -0
- package/dist/utility/wrun/wrun-panel-mount.lazy.js +68 -0
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +392 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +2346 -0
- package/dist/utility/wrun/wrun-param-map.util.d.ts +19 -4
- package/dist/utility/wrun/wrun-param-map.util.js +40 -47
- package/dist/utility/wrun/wrun-param-values.util.d.ts +9 -3
- package/dist/utility/wrun/wrun-param-values.util.js +5 -5
- package/dist/utility/wrun/wrun-pause-dim.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-pause-dim.util.js +153 -0
- package/dist/utility/wrun/wrun-plot-gate.types.d.ts +23 -0
- package/dist/utility/wrun/wrun-plot-gate.types.js +7 -0
- package/dist/utility/wrun/wrun-prefix-cohort.util.d.ts +93 -0
- package/dist/utility/wrun/wrun-prefix-cohort.util.js +484 -0
- package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +114 -0
- package/dist/utility/wrun/wrun-prefix-lanes.util.js +486 -0
- package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +317 -0
- package/dist/utility/wrun/wrun-prefix-proof.util.js +630 -0
- package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +73 -0
- package/dist/utility/wrun/wrun-refusal-surface.util.js +380 -0
- package/dist/utility/wrun/wrun-refusal-text.util.d.ts +15 -0
- package/dist/utility/wrun/wrun-refusal-text.util.js +40 -0
- package/dist/utility/wrun/wrun-replay-lane.util.d.ts +139 -0
- package/dist/utility/wrun/wrun-replay-lane.util.js +520 -0
- package/dist/utility/wrun/wrun-replay-rows.util.d.ts +21 -0
- package/dist/utility/wrun/wrun-replay-rows.util.js +172 -0
- package/dist/utility/wrun/wrun-row-source-factory.d.ts +53 -0
- package/dist/utility/wrun/wrun-row-source-factory.js +435 -0
- package/dist/utility/wrun/wrun-run-cells.util.d.ts +36 -0
- package/dist/utility/wrun/wrun-run-cells.util.js +46 -0
- package/dist/utility/wrun/wrun-run-interval-projection.types.d.ts +14 -0
- package/dist/utility/wrun/wrun-run-interval-projection.types.js +1 -0
- package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +133 -0
- package/dist/utility/wrun/wrun-run-interval-session.util.js +121 -0
- package/dist/utility/wrun/wrun-run-interval.util.d.ts +98 -0
- package/dist/utility/wrun/wrun-run-interval.util.js +207 -0
- package/dist/utility/wrun/wrun-run-retained.util.d.ts +122 -0
- package/dist/utility/wrun/wrun-run-retained.util.js +255 -0
- package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +184 -0
- package/dist/utility/wrun/wrun-sandbox-row-source.js +444 -0
- package/dist/utility/wrun/wrun-script-inputs.util.js +4 -4
- package/dist/utility/wrun/wrun-series-stream.util.d.ts +86 -0
- package/dist/utility/wrun/wrun-series-stream.util.js +537 -0
- package/dist/utility/wrun/wrun-sheet-remembered.util.d.ts +21 -0
- package/dist/utility/wrun/wrun-sheet-remembered.util.js +36 -0
- package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.d.ts +7 -0
- package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.js +12 -0
- package/dist/utility/wrun/wrun-socket-row-source.js +4 -2
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +175 -3
- package/dist/utility/wrun/wrun-source-rows.util.js +294 -8
- package/dist/utility/wrun/wrun-stats-strip.util.d.ts +46 -0
- package/dist/utility/wrun/wrun-stats-strip.util.js +87 -0
- package/dist/utility/wrun/wrun-table-chrome.util.d.ts +163 -0
- package/dist/utility/wrun/wrun-table-chrome.util.js +557 -0
- package/dist/utility/wrun/wrun-text-params.util.d.ts +11 -6
- package/dist/utility/wrun/wrun-text-params.util.js +19 -30
- package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +64 -0
- package/dist/utility/wrun/wrun-transient-rerun.util.js +317 -0
- package/dist/utility/wrun/wrun-twin-lookback.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-twin-lookback.util.js +43 -0
- package/dist/utility/wrun/wrun-warmup-head-store.util.d.ts +41 -0
- package/dist/utility/wrun/wrun-warmup-head-store.util.js +120 -0
- package/dist/utility/wrun-alert-params.leaf.d.ts +24 -0
- package/dist/utility/wrun-alert-params.leaf.js +24 -0
- package/dist/utils/replay/replay-buffer-math.d.ts +148 -0
- package/dist/utils/replay/replay-buffer-math.js +684 -0
- package/dist/workers/wrun/wrun-abi-host.d.ts +190 -0
- package/dist/workers/wrun/wrun-abi-host.js +1201 -0
- package/dist/workers/wrun/wrun-engine-handler.d.ts +37 -0
- package/dist/workers/wrun/wrun-engine-handler.js +211 -0
- package/package.json +3 -3
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
import { Intervals } from '../../constants/interval.constants.js';
|
|
62
62
|
import { cmeSessionBucketMs } from './cme-session-bucket.util.js';
|
|
63
63
|
import { isCmeGoverned } from './cme-realtime.util.js';
|
|
64
|
+
import { liveBucketVenueOf } from './live-bucket.util.js';
|
|
64
65
|
import { getMarketKind } from './marketKind.util.js';
|
|
65
66
|
import { getGovernedFuturesScheduleStatusForSymbol, GOVERNED_FUTURES_TIME_ZONE, isCmeAlwaysOnSymbol, } from './market-session-schedule.util.js';
|
|
66
67
|
import { engineRthWindowForSymbol, sessionWindowsInRange, } from './rth-session.util.js';
|
|
@@ -84,8 +85,9 @@ export function wrunBarFactsMarketOf(exchange) {
|
|
|
84
85
|
}
|
|
85
86
|
/**
|
|
86
87
|
* The venue of chart metadata (or a live context's market) at the series'
|
|
87
|
-
* bar interval
|
|
88
|
-
* the interval is a positive
|
|
88
|
+
* bar interval, with the chart's bar grid (`barGrid`): undefined unless
|
|
89
|
+
* exchange and symbol are non-empty strings and the interval is a positive
|
|
90
|
+
* number.
|
|
89
91
|
*/
|
|
90
92
|
export function wrunBarVenueOf(market, intervalMs) {
|
|
91
93
|
if (!market || typeof market !== 'object')
|
|
@@ -97,7 +99,12 @@ export function wrunBarVenueOf(market, intervalMs) {
|
|
|
97
99
|
return undefined;
|
|
98
100
|
if (!Number.isFinite(intervalMs) || intervalMs <= 0)
|
|
99
101
|
return undefined;
|
|
100
|
-
return {
|
|
102
|
+
return {
|
|
103
|
+
exchange,
|
|
104
|
+
symbol,
|
|
105
|
+
intervalMs,
|
|
106
|
+
barGrid: liveBucketVenueOf(market),
|
|
107
|
+
};
|
|
101
108
|
}
|
|
102
109
|
const NO_FACTS = Object.freeze({ tradeDateSec: Number.NaN, session: Number.NaN });
|
|
103
110
|
/** Every session code, indexable by its own value. */
|
|
@@ -827,7 +827,11 @@ export declare function wrunRunNoticesOf(runResult: Pick<WrunRunResult, 'notices
|
|
|
827
827
|
* param's rendered value; a placeholder naming no param stays as written.
|
|
828
828
|
* `texts` is the run's text settings by name (absent = the declared words):
|
|
829
829
|
* the words are inserted after the one placeholder pass and never re-read
|
|
830
|
-
* as a template (a typed `{{close}}` arrives literally).
|
|
830
|
+
* as a template (a typed `{{close}}` arrives literally). The result is a
|
|
831
|
+
* legend suffix, so each value is LITERAL legend text (wrunLegendLiteral:
|
|
832
|
+
* its own characters, each `$` kept out of the `$token` pass titan runs
|
|
833
|
+
* over the raw settings before it shows `define.customTitle` as text); the
|
|
834
|
+
* template's own characters stay as the author wrote them. */
|
|
831
835
|
export declare function resolveWrunLegendTitle(template: string, params: ReadonlyArray<WrunMetadataParam>, values?: Readonly<Record<string, number>>, texts?: Readonly<Record<string, string>>): string;
|
|
832
836
|
/** The legend colours of a mounted result's outputs: entry i is the colour
|
|
833
837
|
* legend line i paints (titan's legend text colour, alpha stripped, so the
|
|
@@ -796,8 +796,8 @@ function wrunRunDefine(options, position) {
|
|
|
796
796
|
: typeof template === 'string' && template !== ''
|
|
797
797
|
? resolveWrunCustomTitle(template, metadata.params ?? [], options.params, options.texts)
|
|
798
798
|
: undefined;
|
|
799
|
-
// The note rides after the args, in the args' grey, as a literal (titan
|
|
800
|
-
//
|
|
799
|
+
// The note rides after the args, in the args' grey, as a literal (titan's `$token` pass never
|
|
800
|
+
// reads it): " (14, close) · draft · only in this browser", or " · draft · ..." alone.
|
|
801
801
|
const note = typeof options.legendNote === 'string' ? options.legendNote.trim() : '';
|
|
802
802
|
const customTitle = note ? `${resolvedTitle ?? ''} · ${wrunLegendLiteral(note)}` : resolvedTitle;
|
|
803
803
|
return {
|
|
@@ -816,14 +816,7 @@ function wrunLegendSuffix(resolved) {
|
|
|
816
816
|
/** A param's value rendered the way a legend reads it: a select as its
|
|
817
817
|
* option label, a colour as its colour string, a boolean as true / false
|
|
818
818
|
* (the custom-title path's own word for a toggle), a text setting as its
|
|
819
|
-
* plain words (never markup), a number as written.
|
|
820
|
-
* as LITERAL legend text (wrunLegendLiteral: the HTML specials and `$` as
|
|
821
|
-
* entities), because titan writes `define.customTitle` through innerHTML
|
|
822
|
-
* after its own `$token` pass over the raw settings; the template's own
|
|
823
|
-
* characters stay as the author wrote them. */
|
|
824
|
-
function wrunParamLegendValue(param, value, text) {
|
|
825
|
-
return wrunLegendLiteral(wrunParamLegendWords(param, value, text));
|
|
826
|
-
}
|
|
819
|
+
* plain words (never markup), a number as written. */
|
|
827
820
|
function wrunParamLegendWords(param, value, text) {
|
|
828
821
|
// A coded value (a choice, a multi, a time, a session clock) prints as its words, never its code
|
|
829
822
|
// (wrun-setting-words.util); an empty multi and an unset time (0) print the dash a missing number does.
|
|
@@ -851,15 +844,28 @@ function wrunParamLegendWords(param, value, text) {
|
|
|
851
844
|
* param's rendered value; a placeholder naming no param stays as written.
|
|
852
845
|
* `texts` is the run's text settings by name (absent = the declared words):
|
|
853
846
|
* the words are inserted after the one placeholder pass and never re-read
|
|
854
|
-
* as a template (a typed `{{close}}` arrives literally).
|
|
847
|
+
* as a template (a typed `{{close}}` arrives literally). The result is a
|
|
848
|
+
* legend suffix, so each value is LITERAL legend text (wrunLegendLiteral:
|
|
849
|
+
* its own characters, each `$` kept out of the `$token` pass titan runs
|
|
850
|
+
* over the raw settings before it shows `define.customTitle` as text); the
|
|
851
|
+
* template's own characters stay as the author wrote them. */
|
|
855
852
|
export function resolveWrunLegendTitle(template, params, values, texts) {
|
|
853
|
+
return resolveWrunTitleTemplate(template, params, values, texts, wrunLegendLiteral);
|
|
854
|
+
}
|
|
855
|
+
/** A declared pane title against the run's param values, the same way, with
|
|
856
|
+
* the words as they are: it is the child overlay's NAME, which titan shows
|
|
857
|
+
* as text and never runs a `$token` pass over. */
|
|
858
|
+
function resolveWrunPaneTitle(template, params, values, texts) {
|
|
859
|
+
return resolveWrunTitleTemplate(template, params, values, texts, (words) => words);
|
|
860
|
+
}
|
|
861
|
+
function resolveWrunTitleTemplate(template, params, values, texts, insert) {
|
|
856
862
|
const byName = new Map(params.map((param) => [param.name, param]));
|
|
857
863
|
return resolveWrunPlaceholders(template, (name) => {
|
|
858
864
|
const param = byName.get(name);
|
|
859
865
|
if (param === undefined)
|
|
860
866
|
return undefined;
|
|
861
867
|
const fallback = typeof param.default === 'number' ? param.default : 0;
|
|
862
|
-
return
|
|
868
|
+
return insert(wrunParamLegendWords(param, values?.[name] ?? fallback, texts?.[name]));
|
|
863
869
|
});
|
|
864
870
|
}
|
|
865
871
|
/** A theme token word (`theme.<t>`, or the wire's `theme.<t>/aa`): the
|
|
@@ -3779,7 +3785,7 @@ function buildWrunRunResultWithSelection(options, memo) {
|
|
|
3779
3785
|
...withWrunLineFills(parentHandles),
|
|
3780
3786
|
];
|
|
3781
3787
|
// A child pane's define: the declared pane title resolved like
|
|
3782
|
-
// `legend_title
|
|
3788
|
+
// `legend_title`, its words as they are (a name, no customTitle), else the parent's title and suffix;
|
|
3783
3789
|
// its own position; the declared pane's scale look and axis format
|
|
3784
3790
|
// (wrun-output-style.util, OT18 OT19).
|
|
3785
3791
|
const homePane = plan.home;
|
|
@@ -3787,7 +3793,7 @@ function buildWrunRunResultWithSelection(options, memo) {
|
|
|
3787
3793
|
const title = pane?.title;
|
|
3788
3794
|
const own = typeof title === 'string' && title.trim() !== ''
|
|
3789
3795
|
? {
|
|
3790
|
-
title:
|
|
3796
|
+
title: resolveWrunPaneTitle(title, metadata.params ?? [], options.params, options.texts),
|
|
3791
3797
|
position: routePane(route),
|
|
3792
3798
|
axis: define.axis,
|
|
3793
3799
|
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { BlockBookSnapshot } from '@orangecharts/orange-v2-pb-common';
|
|
2
|
+
export declare function timestampToTsdbTimestamp(timestamp: any): number;
|
|
3
|
+
/**
|
|
4
|
+
* Convert the tsdb timestamp to milliseconds
|
|
5
|
+
* @param timestamp - The timestamp to convert
|
|
6
|
+
* @returns The timestamp in milliseconds
|
|
7
|
+
*/
|
|
8
|
+
export declare function tsdbTimestampToMs(timestamp: {
|
|
9
|
+
seconds: number;
|
|
10
|
+
nanoseconds?: number;
|
|
11
|
+
}): number;
|
|
12
|
+
/**
|
|
13
|
+
* Round the timestamp to the nearest interval in the past. A calendar length
|
|
14
|
+
* (1M 3M 6M 1Y) rounds onto its UTC calendar boundary, where its candles open.
|
|
15
|
+
* @param timestamp - The timestamp to round
|
|
16
|
+
* @param interval - The interval to round to
|
|
17
|
+
* @returns The rounded timestamp
|
|
18
|
+
*/
|
|
19
|
+
export declare function roundObTimestamp(timestamp: number, interval: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* Parses flattened orderbook data, transforming
|
|
22
|
+
* [numPriceLevels, timestamp_μs, price1, amount1, ...]
|
|
23
|
+
* into
|
|
24
|
+
* [segmentSize, timestamp_ms, price1, amount1, ...]
|
|
25
|
+
*
|
|
26
|
+
* Orderbook consumers must additionally call `shiftOrderbookTimestamps` to
|
|
27
|
+
* align timestamps with the candle interval start. TPSL consumers skip the
|
|
28
|
+
* shift since their timestamps are used as-is.
|
|
29
|
+
*
|
|
30
|
+
* @param flatPoints - Flattened data from backend
|
|
31
|
+
* @returns Float64Array with format [segmentSize, timestamp_ms, price1, amount1, ...]
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseOrderbookFlatData(flatPoints: number[]): Float64Array;
|
|
34
|
+
/**
|
|
35
|
+
* The bar an END-stamped book point paints on: one interval back on a fixed
|
|
36
|
+
* grid, the calendar bar the stamp closes at a calendar length (1M 3M 6M 1Y:
|
|
37
|
+
* a bar of 28 to 366 days, where one average-length step back lands mid-bar
|
|
38
|
+
* or inside the bar before). The ladder projections (orderbook-ladder.util)
|
|
39
|
+
* must place a stamp exactly as this does: both heatmap paths paint one grid.
|
|
40
|
+
*/
|
|
41
|
+
export declare function bookBarStartMs(stampMs: number, intervalMs: number): number;
|
|
42
|
+
/**
|
|
43
|
+
* Moves each segment's timestamp, in place, from the bucket-end stamp to the
|
|
44
|
+
* start of the bar it closes (`bookBarStartMs`), so the orderbook heatmap
|
|
45
|
+
* aligns with the candles. TPSL does not need this.
|
|
46
|
+
*
|
|
47
|
+
* @param data - Float64Array produced by `parseOrderbookFlatData`
|
|
48
|
+
* @param intervalMs - The chart interval in ms
|
|
49
|
+
*/
|
|
50
|
+
export declare function shiftOrderbookTimestamps(data: Float64Array, intervalMs: number): void;
|
|
51
|
+
/**
|
|
52
|
+
* Process block book snapshot data (live feed)
|
|
53
|
+
* @param point - The point to process
|
|
54
|
+
* @returns Float64Array
|
|
55
|
+
*
|
|
56
|
+
* @note The data is sorted by ascending price
|
|
57
|
+
*/
|
|
58
|
+
export declare function processBlockBookSnapshot(point: {
|
|
59
|
+
blockBookSnapshot?: BlockBookSnapshot;
|
|
60
|
+
}): Float64Array;
|
|
61
|
+
export declare function processBlockBookSnapshots(points: {
|
|
62
|
+
blockBookSnapshot?: BlockBookSnapshot;
|
|
63
|
+
}[]): Float64Array[];
|
|
64
|
+
/**
|
|
65
|
+
* The bid level count of a flat book frame (`processBlockBookSnapshot`), so a
|
|
66
|
+
* kScript riding a heatmap's stream can split the price-ascending flat back
|
|
67
|
+
* into sides on the main thread (`kScriptOrderbookRowFromFlatBook`). The flat
|
|
68
|
+
* merges levels by price, so the split is only knowable when every wire level
|
|
69
|
+
* survived: -1 when the flat's level count differs from the snapshot's bid
|
|
70
|
+
* pairs plus ask pairs (a duplicate price inside a side, or one price on both
|
|
71
|
+
* sides), or when both sides exist and the book is crossed, locked or merged
|
|
72
|
+
* (`!(bids[0] < asks[0])`, best levels first on the wire). A -1 makes the
|
|
73
|
+
* rider skip that frame instead of guessing the boundary.
|
|
74
|
+
*/
|
|
75
|
+
export declare function flatBookBidLevels(flat: ArrayLike<number>, bids: ArrayLike<number>, asks: ArrayLike<number>): number;
|
|
76
|
+
export interface KScriptBlockBookSnapshotOptions {
|
|
77
|
+
maxDepth?: number;
|
|
78
|
+
sourceBlockSize?: number;
|
|
79
|
+
targetBlockSize?: number;
|
|
80
|
+
}
|
|
81
|
+
export declare function processKScriptBlockBookSnapshot(point: {
|
|
82
|
+
blockBookSnapshot?: BlockBookSnapshot;
|
|
83
|
+
}, options?: number | KScriptBlockBookSnapshotOptions): Float64Array;
|
|
84
|
+
export declare function processKScriptBlockBookSnapshots(points: {
|
|
85
|
+
blockBookSnapshot?: BlockBookSnapshot;
|
|
86
|
+
}[], options?: number | KScriptBlockBookSnapshotOptions): Float64Array[];
|
|
87
|
+
/**
|
|
88
|
+
* Rows `[ts, value per subset]` from values keyed by subset name and ms timestamp: each `subsetEnum` member (bar the
|
|
89
|
+
* zero member) at its enum value's index, null where it has no value at that ts; ts ascending over every subset.
|
|
90
|
+
*/
|
|
91
|
+
export declare function subsetRows(values: ReadonlyMap<string, ReadonlyMap<number, number>>, subsetEnum: Record<string | number, string | number>): Array<Array<number | null>>;
|
|
92
|
+
/**
|
|
93
|
+
* The column `subsetRows` gives a subset inside each row: the subset's enum
|
|
94
|
+
* VALUE (the timestamp holds column 0, the slot of the enum's zero member), so a subset is read
|
|
95
|
+
* by its enum member, whichever members the enum gains later. Undefined for a name the enum
|
|
96
|
+
* does not hold.
|
|
97
|
+
*/
|
|
98
|
+
export declare function subsetPointColumn(subsetEnum: Record<string, unknown>, subsetName: string): number | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Whether the gateway-side BLOCK_BOOK replay clip still applies to history
|
|
101
|
+
* windows on this request interval.
|
|
102
|
+
*
|
|
103
|
+
* SECOND (intervalSec === 1) windows are served directly up to now since
|
|
104
|
+
* tsdb-gateway MR !1954 (coin-grouped SUM in the 1s BLOCK_BOOK_SNAPSHOT_AGG
|
|
105
|
+
* fold, gateway issue #13), so they are exempt from the client clip, and so
|
|
106
|
+
* are the other sub-minute rungs (5s 15s 30s: the 1s fold labelled and
|
|
107
|
+
* gapfilled on the bar's grid, tsdb-gateway !2189). Every other interval
|
|
108
|
+
* (MINUTE and coarser, or callers that do not declare an interval) keeps the
|
|
109
|
+
* 3-minute clip: the gateway hard-errors ("internal error") on younger
|
|
110
|
+
* windows there. If the gateway ever regresses on young SECOND windows,
|
|
111
|
+
* re-enforcing here restores the full clip and widens the seam top-up's owned
|
|
112
|
+
* window from the boot subscribe seam back to the whole young window
|
|
113
|
+
* (heatmap-seam-topup.util.ts).
|
|
114
|
+
*/
|
|
115
|
+
export declare const isObReplayCapEnforcedForIntervalSec: (intervalSec?: number, exchange?: string) => boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Calculates a safe replay cap timestamp for orderbook data.
|
|
118
|
+
* Clip-enforced intervals cap at truncate(now, 3 minutes); exempt intervals
|
|
119
|
+
* (sub-minute, see isObReplayCapEnforcedForIntervalSec) cap at now. `now` is
|
|
120
|
+
* the server's: the gateway clips on its own clock, and a device clock an
|
|
121
|
+
* hour ahead put the cap an hour past it (the young window it refuses was
|
|
122
|
+
* asked), one an hour behind cut the newest hour off every window.
|
|
123
|
+
* Returns UNIX seconds.
|
|
124
|
+
*/
|
|
125
|
+
export declare const calculateObReplayCapInSeconds: (intervalSec?: number, exchange?: string) => number;
|
|
126
|
+
/**
|
|
127
|
+
* Applies the orderbook replay cap to data requests: prevents fetching the
|
|
128
|
+
* last 3 minutes on clip-enforced intervals, passes exempt intervals
|
|
129
|
+
* (sub-minute) through capped at now.
|
|
130
|
+
*
|
|
131
|
+
* @param from - The start timestamp in seconds
|
|
132
|
+
* @param period - The period duration in seconds
|
|
133
|
+
* @param intervalSec - The request interval in seconds, when the caller knows it
|
|
134
|
+
*/
|
|
135
|
+
export declare const applyObReplayCap: (from: number, period: number, intervalSec?: number, exchange?: string) => {
|
|
136
|
+
from: number;
|
|
137
|
+
period: number;
|
|
138
|
+
};
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { Intervals } from '../../constants/interval.constants.js';
|
|
3
|
+
import { serverNowMs } from '../auth/server-clock.util.js';
|
|
4
|
+
import { isCmeGoverned } from '../chart/cme-realtime.util.js';
|
|
5
|
+
import { calendarBarStartMs, calendarMonthsOfMs } from '../chart/calendar-interval.util.js';
|
|
6
|
+
function findMonday(timestamp) {
|
|
7
|
+
const date = new Date(timestamp);
|
|
8
|
+
const day = date.getUTCDay();
|
|
9
|
+
const daysSinceMonday = (day + 6) % 7;
|
|
10
|
+
return Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate() - daysSinceMonday);
|
|
11
|
+
}
|
|
12
|
+
export function timestampToTsdbTimestamp(timestamp) {
|
|
13
|
+
return Number(`${timestamp.seconds}000`);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Convert the tsdb timestamp to milliseconds
|
|
17
|
+
* @param timestamp - The timestamp to convert
|
|
18
|
+
* @returns The timestamp in milliseconds
|
|
19
|
+
*/
|
|
20
|
+
export function tsdbTimestampToMs(timestamp) {
|
|
21
|
+
const ts = timestamp.seconds + (timestamp.nanoseconds ?? 0) * 1e-9;
|
|
22
|
+
return ts * 1000;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The start of the calendar bar (1M 3M 6M 1Y) a book stamp belongs to: a stamp
|
|
26
|
+
* exactly on a calendar boundary closes the bar before it, as an exact
|
|
27
|
+
* multiple does on a fixed grid (block book stamps are END labels).
|
|
28
|
+
*/
|
|
29
|
+
function calendarBookBarStartMs(timestamp, months) {
|
|
30
|
+
const start = calendarBarStartMs(timestamp, months);
|
|
31
|
+
return start === timestamp ? calendarBarStartMs(timestamp - 1, months) : start;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Round the timestamp to the nearest interval in the past. A calendar length
|
|
35
|
+
* (1M 3M 6M 1Y) rounds onto its UTC calendar boundary, where its candles open.
|
|
36
|
+
* @param timestamp - The timestamp to round
|
|
37
|
+
* @param interval - The interval to round to
|
|
38
|
+
* @returns The rounded timestamp
|
|
39
|
+
*/
|
|
40
|
+
export function roundObTimestamp(timestamp, interval) {
|
|
41
|
+
if (interval === Intervals.WEEK) {
|
|
42
|
+
return findMonday(timestamp);
|
|
43
|
+
}
|
|
44
|
+
const months = calendarMonthsOfMs(interval);
|
|
45
|
+
if (months !== null)
|
|
46
|
+
return calendarBookBarStartMs(timestamp, months);
|
|
47
|
+
const remainder = timestamp % interval;
|
|
48
|
+
if (remainder === 0) {
|
|
49
|
+
timestamp -= interval;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
timestamp -= remainder;
|
|
53
|
+
}
|
|
54
|
+
return timestamp;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Parses flattened orderbook data, transforming
|
|
58
|
+
* [numPriceLevels, timestamp_μs, price1, amount1, ...]
|
|
59
|
+
* into
|
|
60
|
+
* [segmentSize, timestamp_ms, price1, amount1, ...]
|
|
61
|
+
*
|
|
62
|
+
* Orderbook consumers must additionally call `shiftOrderbookTimestamps` to
|
|
63
|
+
* align timestamps with the candle interval start. TPSL consumers skip the
|
|
64
|
+
* shift since their timestamps are used as-is.
|
|
65
|
+
*
|
|
66
|
+
* @param flatPoints - Flattened data from backend
|
|
67
|
+
* @returns Float64Array with format [segmentSize, timestamp_ms, price1, amount1, ...]
|
|
68
|
+
*/
|
|
69
|
+
export function parseOrderbookFlatData(flatPoints) {
|
|
70
|
+
if (!flatPoints?.length)
|
|
71
|
+
return new Float64Array();
|
|
72
|
+
// Copy flatPointsto Float64Array
|
|
73
|
+
const result = new Float64Array(flatPoints.length);
|
|
74
|
+
result.set(flatPoints);
|
|
75
|
+
let index = 0;
|
|
76
|
+
while (index < result.length) {
|
|
77
|
+
if (index + 1 >= result.length)
|
|
78
|
+
break;
|
|
79
|
+
const numPriceLevels = result[index];
|
|
80
|
+
const timestamp = result[index + 1];
|
|
81
|
+
// Calculate segment size: count + timestamp + price/amount pairs
|
|
82
|
+
// [count, timestamp, price1, amount1, price2, amount2, ...]
|
|
83
|
+
const segmentSize = 2 + numPriceLevels * 2;
|
|
84
|
+
// Check bounds
|
|
85
|
+
if (index + segmentSize > result.length)
|
|
86
|
+
break;
|
|
87
|
+
// Transform the first element from numPriceLevels to segmentSize
|
|
88
|
+
result[index] = segmentSize;
|
|
89
|
+
result[index + 1] = timestamp / 1000;
|
|
90
|
+
index += segmentSize;
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The bar an END-stamped book point paints on: one interval back on a fixed
|
|
96
|
+
* grid, the calendar bar the stamp closes at a calendar length (1M 3M 6M 1Y:
|
|
97
|
+
* a bar of 28 to 366 days, where one average-length step back lands mid-bar
|
|
98
|
+
* or inside the bar before). The ladder projections (orderbook-ladder.util)
|
|
99
|
+
* must place a stamp exactly as this does: both heatmap paths paint one grid.
|
|
100
|
+
*/
|
|
101
|
+
export function bookBarStartMs(stampMs, intervalMs) {
|
|
102
|
+
const months = calendarMonthsOfMs(intervalMs);
|
|
103
|
+
return months === null ? stampMs - intervalMs : calendarBookBarStartMs(stampMs, months);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Moves each segment's timestamp, in place, from the bucket-end stamp to the
|
|
107
|
+
* start of the bar it closes (`bookBarStartMs`), so the orderbook heatmap
|
|
108
|
+
* aligns with the candles. TPSL does not need this.
|
|
109
|
+
*
|
|
110
|
+
* @param data - Float64Array produced by `parseOrderbookFlatData`
|
|
111
|
+
* @param intervalMs - The chart interval in ms
|
|
112
|
+
*/
|
|
113
|
+
export function shiftOrderbookTimestamps(data, intervalMs) {
|
|
114
|
+
let index = 0;
|
|
115
|
+
while (index < data.length) {
|
|
116
|
+
const segmentSize = data[index];
|
|
117
|
+
if (!segmentSize || index + segmentSize > data.length)
|
|
118
|
+
break;
|
|
119
|
+
data[index + 1] = bookBarStartMs(data[index + 1], intervalMs);
|
|
120
|
+
index += segmentSize;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Process block book snapshot data (live feed)
|
|
125
|
+
* @param point - The point to process
|
|
126
|
+
* @returns Float64Array
|
|
127
|
+
*
|
|
128
|
+
* @note The data is sorted by ascending price
|
|
129
|
+
*/
|
|
130
|
+
export function processBlockBookSnapshot(point) {
|
|
131
|
+
if (!point)
|
|
132
|
+
return new Float64Array();
|
|
133
|
+
const snapshot = point.blockBookSnapshot;
|
|
134
|
+
if (!snapshot)
|
|
135
|
+
return new Float64Array();
|
|
136
|
+
const { timestamp, bids = [], asks = [] } = snapshot;
|
|
137
|
+
const formattedData = [];
|
|
138
|
+
formattedData.push(bids.length + asks.length + 2);
|
|
139
|
+
formattedData.push(timestampToTsdbTimestamp(timestamp)); // timestamp needs to be adjusted to the interval in main thread
|
|
140
|
+
const quantities = new Map(); // price -> total quantity
|
|
141
|
+
for (let i = 0; i < bids.length; i += 2) {
|
|
142
|
+
quantities.set(bids[i], (quantities.get(bids[i]) || 0) + bids[i + 1]);
|
|
143
|
+
}
|
|
144
|
+
for (let i = 0; i < asks.length; i += 2) {
|
|
145
|
+
quantities.set(asks[i], (quantities.get(asks[i]) || 0) + asks[i + 1]);
|
|
146
|
+
}
|
|
147
|
+
// Sort by price ascending (lowest price first)
|
|
148
|
+
const sortedQuantities = Array.from(quantities.entries()).sort((a, b) => a[0] - b[0]);
|
|
149
|
+
for (const [price, quantity] of sortedQuantities) {
|
|
150
|
+
formattedData.push(price, quantity);
|
|
151
|
+
}
|
|
152
|
+
// Correct the length of the data
|
|
153
|
+
formattedData[0] = formattedData.length;
|
|
154
|
+
return new Float64Array(formattedData);
|
|
155
|
+
}
|
|
156
|
+
export function processBlockBookSnapshots(points) {
|
|
157
|
+
if (!points)
|
|
158
|
+
return [];
|
|
159
|
+
return points.map((point) => processBlockBookSnapshot(point));
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The bid level count of a flat book frame (`processBlockBookSnapshot`), so a
|
|
163
|
+
* kScript riding a heatmap's stream can split the price-ascending flat back
|
|
164
|
+
* into sides on the main thread (`kScriptOrderbookRowFromFlatBook`). The flat
|
|
165
|
+
* merges levels by price, so the split is only knowable when every wire level
|
|
166
|
+
* survived: -1 when the flat's level count differs from the snapshot's bid
|
|
167
|
+
* pairs plus ask pairs (a duplicate price inside a side, or one price on both
|
|
168
|
+
* sides), or when both sides exist and the book is crossed, locked or merged
|
|
169
|
+
* (`!(bids[0] < asks[0])`, best levels first on the wire). A -1 makes the
|
|
170
|
+
* rider skip that frame instead of guessing the boundary.
|
|
171
|
+
*/
|
|
172
|
+
export function flatBookBidLevels(flat, bids, asks) {
|
|
173
|
+
const bidPairs = bids.length / 2;
|
|
174
|
+
const askPairs = asks.length / 2;
|
|
175
|
+
const flatLevels = (flat.length - 2) / 2;
|
|
176
|
+
if (!Number.isInteger(bidPairs) || !Number.isInteger(askPairs) || flatLevels !== bidPairs + askPairs)
|
|
177
|
+
return -1;
|
|
178
|
+
if (bidPairs > 0 && askPairs > 0 && !(bids[0] < asks[0]))
|
|
179
|
+
return -1;
|
|
180
|
+
return bidPairs;
|
|
181
|
+
}
|
|
182
|
+
function clipOrderbookLevels(levels, maxDepth) {
|
|
183
|
+
const maxLevels = Number(maxDepth);
|
|
184
|
+
if (!Number.isFinite(maxLevels) || maxLevels <= 0)
|
|
185
|
+
return levels;
|
|
186
|
+
return levels.slice(0, Math.floor(maxLevels) * 2);
|
|
187
|
+
}
|
|
188
|
+
function normalizeKScriptBlockBookSnapshotOptions(options) {
|
|
189
|
+
return typeof options === 'number' ? { maxDepth: options } : (options ?? {});
|
|
190
|
+
}
|
|
191
|
+
function normalizeOrderbookBucketPrice(price, blockSize, side) {
|
|
192
|
+
const rawBucket = side === 'ask' ? Math.ceil(price / blockSize) * blockSize : Math.floor(price / blockSize) * blockSize;
|
|
193
|
+
return Number(rawBucket.toFixed(8));
|
|
194
|
+
}
|
|
195
|
+
function aggregateOrderbookLevelsByBlock(levels, side, options) {
|
|
196
|
+
const sourceBlockSize = Number(options.sourceBlockSize);
|
|
197
|
+
const targetBlockSize = Number(options.targetBlockSize);
|
|
198
|
+
if (!Number.isFinite(sourceBlockSize) ||
|
|
199
|
+
!Number.isFinite(targetBlockSize) ||
|
|
200
|
+
sourceBlockSize <= 0 ||
|
|
201
|
+
targetBlockSize <= 0 ||
|
|
202
|
+
sourceBlockSize >= targetBlockSize) {
|
|
203
|
+
return levels;
|
|
204
|
+
}
|
|
205
|
+
const quantitiesByBucket = new Map();
|
|
206
|
+
for (let index = 0; index < levels.length; index += 2) {
|
|
207
|
+
const price = Number(levels[index]);
|
|
208
|
+
const quantity = Number(levels[index + 1]);
|
|
209
|
+
if (!Number.isFinite(price) || !Number.isFinite(quantity))
|
|
210
|
+
continue;
|
|
211
|
+
const bucketPrice = normalizeOrderbookBucketPrice(price, targetBlockSize, side);
|
|
212
|
+
quantitiesByBucket.set(bucketPrice, (quantitiesByBucket.get(bucketPrice) ?? 0) + quantity);
|
|
213
|
+
}
|
|
214
|
+
return Array.from(quantitiesByBucket.entries()).flat();
|
|
215
|
+
}
|
|
216
|
+
export function processKScriptBlockBookSnapshot(point, options) {
|
|
217
|
+
if (!point)
|
|
218
|
+
return new Float64Array();
|
|
219
|
+
const snapshot = point.blockBookSnapshot;
|
|
220
|
+
if (!snapshot)
|
|
221
|
+
return new Float64Array();
|
|
222
|
+
const normalizedOptions = normalizeKScriptBlockBookSnapshotOptions(options);
|
|
223
|
+
const timestamp = timestampToTsdbTimestamp(snapshot.timestamp); // timestamp needs to be adjusted to the interval in main thread
|
|
224
|
+
const bids = clipOrderbookLevels(aggregateOrderbookLevelsByBlock(snapshot.bids ?? [], 'bid', normalizedOptions), normalizedOptions.maxDepth);
|
|
225
|
+
const snapshotAsks = clipOrderbookLevels(aggregateOrderbookLevelsByBlock(snapshot.asks ?? [], 'ask', normalizedOptions), normalizedOptions.maxDepth);
|
|
226
|
+
// sort asks reversely
|
|
227
|
+
const askMap = new Map();
|
|
228
|
+
for (let i = 0; i < snapshotAsks.length; i += 2) {
|
|
229
|
+
askMap.set(snapshotAsks[i], -snapshotAsks[i + 1]); // set ask amounts to negative
|
|
230
|
+
}
|
|
231
|
+
const asks = Array.from(askMap.entries())
|
|
232
|
+
.sort((a, b) => b[0] - a[0])
|
|
233
|
+
.flat();
|
|
234
|
+
const float64Array = new Float64Array(bids.length + asks.length + 1);
|
|
235
|
+
float64Array[0] = timestamp;
|
|
236
|
+
float64Array.set(bids, 1);
|
|
237
|
+
float64Array.set(asks, bids.length + 1);
|
|
238
|
+
return float64Array;
|
|
239
|
+
}
|
|
240
|
+
export function processKScriptBlockBookSnapshots(points, options) {
|
|
241
|
+
if (!points)
|
|
242
|
+
return [];
|
|
243
|
+
return points.map((point) => processKScriptBlockBookSnapshot(point, options));
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Rows `[ts, value per subset]` from values keyed by subset name and ms timestamp: each `subsetEnum` member (bar the
|
|
247
|
+
* zero member) at its enum value's index, null where it has no value at that ts; ts ascending over every subset.
|
|
248
|
+
*/
|
|
249
|
+
export function subsetRows(values, subsetEnum) {
|
|
250
|
+
const elementSize = Object.keys(subsetEnum).filter((key) => isNaN(Number(key))).length - 1;
|
|
251
|
+
const times = [...new Set([...values.values()].flatMap((byTs) => [...byTs.keys()]))].sort((a, b) => a - b);
|
|
252
|
+
return times.map((time) => [
|
|
253
|
+
time,
|
|
254
|
+
...Array.from({ length: elementSize }, (_, i) => values.get(subsetEnum[i + 1])?.get(time) ?? null),
|
|
255
|
+
]);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The column `subsetRows` gives a subset inside each row: the subset's enum
|
|
259
|
+
* VALUE (the timestamp holds column 0, the slot of the enum's zero member), so a subset is read
|
|
260
|
+
* by its enum member, whichever members the enum gains later. Undefined for a name the enum
|
|
261
|
+
* does not hold.
|
|
262
|
+
*/
|
|
263
|
+
export function subsetPointColumn(subsetEnum, subsetName) {
|
|
264
|
+
const value = subsetEnum[subsetName];
|
|
265
|
+
return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Whether the gateway-side BLOCK_BOOK replay clip still applies to history
|
|
269
|
+
* windows on this request interval.
|
|
270
|
+
*
|
|
271
|
+
* SECOND (intervalSec === 1) windows are served directly up to now since
|
|
272
|
+
* tsdb-gateway MR !1954 (coin-grouped SUM in the 1s BLOCK_BOOK_SNAPSHOT_AGG
|
|
273
|
+
* fold, gateway issue #13), so they are exempt from the client clip, and so
|
|
274
|
+
* are the other sub-minute rungs (5s 15s 30s: the 1s fold labelled and
|
|
275
|
+
* gapfilled on the bar's grid, tsdb-gateway !2189). Every other interval
|
|
276
|
+
* (MINUTE and coarser, or callers that do not declare an interval) keeps the
|
|
277
|
+
* 3-minute clip: the gateway hard-errors ("internal error") on younger
|
|
278
|
+
* windows there. If the gateway ever regresses on young SECOND windows,
|
|
279
|
+
* re-enforcing here restores the full clip and widens the seam top-up's owned
|
|
280
|
+
* window from the boot subscribe seam back to the whole young window
|
|
281
|
+
* (heatmap-seam-topup.util.ts).
|
|
282
|
+
*/
|
|
283
|
+
export const isObReplayCapEnforcedForIntervalSec = (intervalSec, exchange) => {
|
|
284
|
+
if (intervalSec === undefined || !(intervalSec > 0 && intervalSec < 60))
|
|
285
|
+
return true;
|
|
286
|
+
// The young-SECOND exemption is a PER-GATEWAY capability, not a global one:
|
|
287
|
+
// the crypto gateway serves young SECOND book windows (gw !1954), while the
|
|
288
|
+
// governed CME gate still hard-errors ("internal error") on windows younger
|
|
289
|
+
// than its 3-minute fold boundary (2026-08-12 field report: ES1! 1s heatmap
|
|
290
|
+
// refetch stuck in a transport-retry loop) and serves the other sub-minute
|
|
291
|
+
// rungs like 1s. Governed venues keep the clip; the seam boot-bridge +
|
|
292
|
+
// top-up own the young window there at 1s.
|
|
293
|
+
return isCmeGoverned(exchange);
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Calculates a safe replay cap timestamp for orderbook data.
|
|
297
|
+
* Clip-enforced intervals cap at truncate(now, 3 minutes); exempt intervals
|
|
298
|
+
* (sub-minute, see isObReplayCapEnforcedForIntervalSec) cap at now. `now` is
|
|
299
|
+
* the server's: the gateway clips on its own clock, and a device clock an
|
|
300
|
+
* hour ahead put the cap an hour past it (the young window it refuses was
|
|
301
|
+
* asked), one an hour behind cut the newest hour off every window.
|
|
302
|
+
* Returns UNIX seconds.
|
|
303
|
+
*/
|
|
304
|
+
export const calculateObReplayCapInSeconds = (intervalSec, exchange) => {
|
|
305
|
+
const now = serverNowMs();
|
|
306
|
+
if (!isObReplayCapEnforcedForIntervalSec(intervalSec, exchange))
|
|
307
|
+
return Math.floor(now / 1000);
|
|
308
|
+
const replayCap = now - (now % Intervals.MINUTE3);
|
|
309
|
+
return Math.floor(replayCap / 1000);
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Applies the orderbook replay cap to data requests: prevents fetching the
|
|
313
|
+
* last 3 minutes on clip-enforced intervals, passes exempt intervals
|
|
314
|
+
* (sub-minute) through capped at now.
|
|
315
|
+
*
|
|
316
|
+
* @param from - The start timestamp in seconds
|
|
317
|
+
* @param period - The period duration in seconds
|
|
318
|
+
* @param intervalSec - The request interval in seconds, when the caller knows it
|
|
319
|
+
*/
|
|
320
|
+
export const applyObReplayCap = (from, period, intervalSec, exchange) => {
|
|
321
|
+
// Ensure integer timestamps
|
|
322
|
+
const startTime = Math.floor(from);
|
|
323
|
+
const duration = Math.floor(Math.max(60, period));
|
|
324
|
+
const replayCapTime = calculateObReplayCapInSeconds(intervalSec, exchange);
|
|
325
|
+
const endTime = startTime + duration;
|
|
326
|
+
// If the entire request is before the cap, return as-is
|
|
327
|
+
if (endTime <= replayCapTime) {
|
|
328
|
+
return {
|
|
329
|
+
from: startTime,
|
|
330
|
+
period: duration,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
// If the request starts after or at the cap, return zero period
|
|
334
|
+
if (startTime >= replayCapTime) {
|
|
335
|
+
return {
|
|
336
|
+
from: startTime,
|
|
337
|
+
period: 0, // No data available
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
// Truncate the period to end at the replay cap
|
|
341
|
+
const truncatedDuration = Math.floor(Math.max(0, replayCapTime - startTime));
|
|
342
|
+
return {
|
|
343
|
+
from: startTime,
|
|
344
|
+
period: truncatedDuration,
|
|
345
|
+
};
|
|
346
|
+
};
|
|
@@ -6,12 +6,21 @@ export interface VisibleTimeout {
|
|
|
6
6
|
/** Time since the start spent not visible; frozen once fired or cleared. */
|
|
7
7
|
hiddenMs(): number;
|
|
8
8
|
}
|
|
9
|
+
/** A host's suspended state beside the page's visibility: calls `listener` with the host's state at once and on
|
|
10
|
+
* every change, and answers the unsubscribe (wrun-chart-host's `clock.watchHostSuspended`). */
|
|
11
|
+
export type VisibleTimeoutSuspendedWatch = (listener: (suspended: boolean) => void) => () => void;
|
|
12
|
+
export interface VisibleTimeoutOptions {
|
|
13
|
+
/** The host's suspended state: the clock pauses while it reads suspended, as while the page is hidden. Absent,
|
|
14
|
+
* only the page's visibility pauses it. */
|
|
15
|
+
watchSuspended?: VisibleTimeoutSuspendedWatch;
|
|
16
|
+
}
|
|
9
17
|
/**
|
|
10
18
|
* Runs `callback` once `budgetMs` of visible time has passed since the call. Outside a
|
|
11
19
|
* browser (no `document`) every millisecond counts, as with a plain timeout, and so it
|
|
12
20
|
* does for a document that reports no visibility state: only an explicit `hidden`
|
|
13
|
-
* pauses the clock, so a deadline can never be parked forever by a missing API.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
21
|
+
* pauses the clock, so a deadline can never be parked forever by a missing API. A host's
|
|
22
|
+
* suspension (`options.watchSuspended`) pauses it too. Whatever a deadline armed is
|
|
23
|
+
* released by `clear()`, by its own fire, and so by a caller's re-arm (clear the old
|
|
24
|
+
* handle, start a new one).
|
|
16
25
|
*/
|
|
17
|
-
export declare function startVisibleTimeout(callback: () => unknown, budgetMs: number): VisibleTimeout;
|
|
26
|
+
export declare function startVisibleTimeout(callback: () => unknown, budgetMs: number, options?: VisibleTimeoutOptions): VisibleTimeout;
|