@orangecharts/wrun-chart-host 0.4.0 → 0.6.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 +17 -5
- package/dist/constants/exchange-names.leaf.d.ts +8 -0
- package/dist/constants/exchange-names.leaf.js +101 -0
- package/dist/constants/feature-flags.constants.js +7 -2
- 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/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 +301 -22
- package/dist/host-env.js +15 -0
- package/dist/host-ports.types.d.ts +853 -29
- package/dist/index.d.ts +140 -2
- package/dist/index.js +140 -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/interfaces/wrun-runtime.interface.d.ts +88 -13
- package/dist/interfaces/wrun-runtime.interface.js +17 -3
- 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 +17 -0
- package/dist/utility/chart/chart-mount-epoch.util.js +61 -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/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/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/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/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/series.js +2 -2
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +4 -4
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +5 -6
- 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 +94 -0
- package/dist/utility/wrun/wrun-bar-count.util.js +274 -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 +330 -0
- package/dist/utility/wrun/wrun-host.service.js +855 -0
- package/dist/utility/wrun/wrun-hover.util.d.ts +3 -0
- package/dist/utility/wrun/wrun-hover.util.js +25 -4
- 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-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-pack.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +24 -9
- package/dist/utility/wrun/wrun-panel-mount.util.js +138 -43
- 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-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-registry-errors.util.d.ts +5 -3
- 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-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-sha256.leaf.d.ts +13 -0
- package/dist/utility/wrun/wrun-sha256.leaf.js +84 -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 +203 -0
- package/dist/workers/wrun/wrun-abi-host.js +1220 -0
- package/dist/workers/wrun/wrun-engine-handler.d.ts +20 -0
- package/dist/workers/wrun/wrun-engine-handler.js +380 -0
- package/package.json +3 -3
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run-interval projection: the adapter stage that shows a run-interval overlay on its chart
|
|
3
|
+
* (HTF-NATIVE-PLAN.md section 3.2). A built-in whose `timeframe` input is coarser than its chart
|
|
4
|
+
* runs its engine at that interval (indicator-run-interval.util.ts), so its run result carries one
|
|
5
|
+
* row per run bar: one per hour on a 5m chart. Mounted as is, the adapter NaN-pads every chart bar
|
|
6
|
+
* between two hourly rows (isolated dots) and the legend reads 11 bars of 12 as empty. This stage
|
|
7
|
+
* rewrites the result onto the chart's bars before the rest of the preparation sees it:
|
|
8
|
+
*
|
|
9
|
+
* - plots, bgcolor and barcolor: one row per chart bar, carrying the run bar that chart bar shows
|
|
10
|
+
* (projectRunRowsOntoChart: wait for close on shows the last run bar that closed before it; off
|
|
11
|
+
* also shows the forming run bar on the chart bars inside its own bucket);
|
|
12
|
+
* - markers, labels, shapes and ranges: once, on the first chart bar that shows their run bar;
|
|
13
|
+
* - drawing and range anchors: where their run bar's value first shows (projectRunTimeOntoChart);
|
|
14
|
+
* a time past the newest run bar is no run bar (a zone drawn ahead of the last bar) and keeps its
|
|
15
|
+
* distance from it, one run bar later like every run bar once wait for close shows the newest one
|
|
16
|
+
* at its close on the chart (aheadAt). A line, polyline or box shown entirely before the chart's
|
|
17
|
+
* first bar leaves (with the line fills that shade it); a line or polyline crossing that bar
|
|
18
|
+
* starts on it at the price where it crosses, rather than folding an end onto it at its own price;
|
|
19
|
+
* - `combinedTimes`, `createdBar` and `mutatedBar`: the chart bars the projection covers.
|
|
20
|
+
*
|
|
21
|
+
* The run's own rows bound the projection: it starts at the first chart bar that shows one of them
|
|
22
|
+
* and stops before the chart bars the run bar after its newest one would own, so a tail-only live
|
|
23
|
+
* result or a windowed replay rewrites only the chart bars it computed (the live replace and the
|
|
24
|
+
* partial-replay merge keep the mounted rows outside them).
|
|
25
|
+
*
|
|
26
|
+
* A row a forward display offset stamps past the engine's newest bar (a wrun output's
|
|
27
|
+
* `displacement_bars`) is no run bar: it bounds nothing and keeps its distance past the chart's last
|
|
28
|
+
* bar like a drawing anchor, the way a chart at the run interval draws it ahead (aheadFromOf).
|
|
29
|
+
*
|
|
30
|
+
* Every run bar's open and close is read by runBarSpan: `[stamp, stamp + runMs)`, or the session's
|
|
31
|
+
* on the CME session lattice (OverlayRunInterval.sessionLattice, the wrun twins on a CME chart),
|
|
32
|
+
* where a 1D or 1W bar is stamped after its own evening open and a session gap holds no run bar.
|
|
33
|
+
*/
|
|
34
|
+
import { nextRunBarCloseMs, projectRunRowsOntoChart, projectRunTimeOntoChart, runBarSpan, } from './indicator-run-interval.util.js';
|
|
35
|
+
import { KSCRIPT_OFFCHART_MARKER_PARENT_FALLBACK_PLOT_TYPES } from './kscript-output-role.util.js';
|
|
36
|
+
import { isKScriptForeignPanePlotType } from './kscript-run-result-normalize.util.js';
|
|
37
|
+
import { isRecord } from './kscript-run-result-shape.util.js';
|
|
38
|
+
const ROW_KEYS = ['data', 'rawData', 'activeData'];
|
|
39
|
+
// Event outputs, drawn once per run bar (the markers ride KSCRIPT_OFFCHART_MARKER_PARENT_FALLBACK_PLOT_TYPES).
|
|
40
|
+
const ONCE_PLOT_TYPES = new Set(['label', 'priceLabel', 'range', 'shape', 'text', 'verticalLine']);
|
|
41
|
+
// Off the time axis: a table draws its cells, a foreign pane its own domain. An hline draws its
|
|
42
|
+
// `value` and carries no rows, so projecting it changes nothing, except a wrun guide a fill reads:
|
|
43
|
+
// its `[ts, level]` rows ride the chart's bars like a plot's, on the fill's own bar grid.
|
|
44
|
+
const UNPROJECTED_PLOT_TYPES = new Set(['table']);
|
|
45
|
+
// Drawing props that hold a time (epoch ms) on the chart's x axis, by drawing kind (a line's ends
|
|
46
|
+
// and a polyline's points clip at the first chart bar: projectLineProps, projectPolylinePoints).
|
|
47
|
+
const DRAWING_TIME_PROPS = new Map([
|
|
48
|
+
['box', ['left', 'right', 'x1', 'x2']],
|
|
49
|
+
['label', ['x']],
|
|
50
|
+
]);
|
|
51
|
+
// A polyline point's time key and the price key beside it.
|
|
52
|
+
const POLYLINE_POINT_KEYS = [
|
|
53
|
+
['time', 'price'],
|
|
54
|
+
['x', 'y'],
|
|
55
|
+
];
|
|
56
|
+
const POLYLINE_POINT_TIME_KEYS = POLYLINE_POINT_KEYS.map(([time]) => time);
|
|
57
|
+
// Range payloads (`[ts, { time1, time2, price1, price2, ... }]`) anchor on their own times.
|
|
58
|
+
const PAYLOAD_TIME_KEYS = ['time1', 'time2'];
|
|
59
|
+
function projectionKindOf(output) {
|
|
60
|
+
const plotType = output.plotType ?? output.plot;
|
|
61
|
+
if (typeof plotType !== 'string' || UNPROJECTED_PLOT_TYPES.has(plotType) || isKScriptForeignPanePlotType(plotType)) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return KSCRIPT_OFFCHART_MARKER_PARENT_FALLBACK_PLOT_TYPES.has(plotType) || ONCE_PLOT_TYPES.has(plotType)
|
|
65
|
+
? 'once'
|
|
66
|
+
: 'fill';
|
|
67
|
+
}
|
|
68
|
+
/** The engine's bar timeline, whose positions scalar series and drawing bar indexes refer to; empty when unreadable. */
|
|
69
|
+
function engineTimelineOf(runResult) {
|
|
70
|
+
const times = runResult.combinedTimes;
|
|
71
|
+
if (!Array.isArray(times) || !times.every((time) => typeof time === 'number' && Number.isFinite(time)))
|
|
72
|
+
return [];
|
|
73
|
+
return times;
|
|
74
|
+
}
|
|
75
|
+
/** An output's rows on the time axis: `[ts, ...cells]` rows, or a scalar series paired with the engine's timeline. */
|
|
76
|
+
function timedRows(value, engineTimes) {
|
|
77
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
78
|
+
return null;
|
|
79
|
+
const probe = value.find((row) => row != null);
|
|
80
|
+
if (probe === undefined)
|
|
81
|
+
return null;
|
|
82
|
+
if (!Array.isArray(probe)) {
|
|
83
|
+
if (value.length !== engineTimes.length)
|
|
84
|
+
return null;
|
|
85
|
+
return value.map((cell, index) => [engineTimes[index], cell ?? Number.NaN]);
|
|
86
|
+
}
|
|
87
|
+
return value.filter((row) => Array.isArray(row) && Number.isFinite(row[0]));
|
|
88
|
+
}
|
|
89
|
+
function forEachOutput(node, visit) {
|
|
90
|
+
if (!isRecord(node))
|
|
91
|
+
return;
|
|
92
|
+
visit(node);
|
|
93
|
+
if (isRecord(node.outputs))
|
|
94
|
+
Object.values(node.outputs).forEach((child) => forEachOutput(child, visit));
|
|
95
|
+
if (Array.isArray(node.nestedMeta))
|
|
96
|
+
node.nestedMeta.forEach((child) => forEachOutput(child, visit));
|
|
97
|
+
}
|
|
98
|
+
function mapOutputTree(node, project) {
|
|
99
|
+
let next = project(node);
|
|
100
|
+
if (isRecord(node.outputs)) {
|
|
101
|
+
let outputs = null;
|
|
102
|
+
for (const [key, child] of Object.entries(node.outputs)) {
|
|
103
|
+
if (!isRecord(child))
|
|
104
|
+
continue;
|
|
105
|
+
const mapped = mapOutputTree(child, project);
|
|
106
|
+
if (mapped !== child)
|
|
107
|
+
(outputs ??= { ...node.outputs })[key] = mapped;
|
|
108
|
+
}
|
|
109
|
+
if (outputs)
|
|
110
|
+
next = { ...next, outputs };
|
|
111
|
+
}
|
|
112
|
+
if (Array.isArray(node.nestedMeta)) {
|
|
113
|
+
let changed = false;
|
|
114
|
+
const nestedMeta = node.nestedMeta.map((child) => {
|
|
115
|
+
const mapped = isRecord(child) ? mapOutputTree(child, project) : child;
|
|
116
|
+
changed ||= mapped !== child;
|
|
117
|
+
return mapped;
|
|
118
|
+
});
|
|
119
|
+
if (changed)
|
|
120
|
+
next = { ...next, nestedMeta };
|
|
121
|
+
}
|
|
122
|
+
return next;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Where rows stop being the run's: the close of the engine's newest bar. A forward display offset
|
|
126
|
+
* stamps rows past it (the value of run bar i drawn on bar i + d), ahead of the run, so no run bar
|
|
127
|
+
* is theirs. Without the engine's timeline every row is the run's.
|
|
128
|
+
*/
|
|
129
|
+
function aheadFromOf(engineTimes, run) {
|
|
130
|
+
if (engineTimes.length === 0)
|
|
131
|
+
return Number.POSITIVE_INFINITY;
|
|
132
|
+
let newest = engineTimes[0];
|
|
133
|
+
for (const time of engineTimes)
|
|
134
|
+
if (time > newest)
|
|
135
|
+
newest = time;
|
|
136
|
+
return runBarSpan(newest, run).close;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The run bars the result computed: the times of its plot rows (a plot emits a row on every bar),
|
|
140
|
+
* else of its event rows, else the engine's timeline. Rows ahead of the run are none of them.
|
|
141
|
+
*/
|
|
142
|
+
function runTimelineOf(runResult, engineTimes, aheadFrom) {
|
|
143
|
+
const plotTimes = new Set();
|
|
144
|
+
const eventTimes = new Set();
|
|
145
|
+
forEachOutput(runResult, (output) => {
|
|
146
|
+
const kind = projectionKindOf(output);
|
|
147
|
+
if (!kind)
|
|
148
|
+
return;
|
|
149
|
+
for (const key of ROW_KEYS) {
|
|
150
|
+
for (const row of timedRows(output[key], engineTimes) ?? []) {
|
|
151
|
+
const time = row[0];
|
|
152
|
+
if (time < aheadFrom)
|
|
153
|
+
(kind === 'fill' ? plotTimes : eventTimes).add(time);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
const times = plotTimes.size ? plotTimes : eventTimes.size ? eventTimes : new Set(engineTimes);
|
|
158
|
+
return [...times].sort((a, b) => a - b);
|
|
159
|
+
}
|
|
160
|
+
/** The last index whose time is at or before `time`, else -1. */
|
|
161
|
+
function floorIndex(times, time) {
|
|
162
|
+
let lo = 0;
|
|
163
|
+
let hi = times.length - 1;
|
|
164
|
+
let found = -1;
|
|
165
|
+
while (lo <= hi) {
|
|
166
|
+
const mid = (lo + hi) >> 1;
|
|
167
|
+
if (times[mid] <= time) {
|
|
168
|
+
found = mid;
|
|
169
|
+
lo = mid + 1;
|
|
170
|
+
}
|
|
171
|
+
else
|
|
172
|
+
hi = mid - 1;
|
|
173
|
+
}
|
|
174
|
+
return found;
|
|
175
|
+
}
|
|
176
|
+
function buildProjection(timeline, chartTimes, run, aheadFrom) {
|
|
177
|
+
const { intervalMs: runMs, waitForClose } = run;
|
|
178
|
+
const lattice = run.sessionLattice === true;
|
|
179
|
+
const newest = timeline[timeline.length - 1];
|
|
180
|
+
const newestSpan = runBarSpan(newest, run);
|
|
181
|
+
const lastChartTime = chartTimes[chartTimes.length - 1];
|
|
182
|
+
// Wait for close off shows the newest run bar only while it forms, its span holding the chart's
|
|
183
|
+
// last bar. Behind the chart (a windowed replay, a run that has not seen the new bucket yet) it is
|
|
184
|
+
// a closed bar like every other.
|
|
185
|
+
const showsForming = !waitForClose && lastChartTime >= newestSpan.open && lastChartTime < newestSpan.close;
|
|
186
|
+
const shownRows = projectRunRowsOntoChart(timeline.map((time, index) => [time, index]), chartTimes, runMs, !showsForming, lattice);
|
|
187
|
+
// From here on a chart bar shows the run bar after the newest one, which this result does not carry
|
|
188
|
+
// (on the session lattice the first one past a gap: a weekend or a holiday holds none).
|
|
189
|
+
const coverageEnd = nextRunBarCloseMs(newest, chartTimes, run);
|
|
190
|
+
const times = [];
|
|
191
|
+
const shown = [];
|
|
192
|
+
const firstShown = new Map();
|
|
193
|
+
for (const [chartTime, index] of shownRows) {
|
|
194
|
+
if (chartTime >= coverageEnd)
|
|
195
|
+
break;
|
|
196
|
+
if (!Number.isInteger(index))
|
|
197
|
+
continue;
|
|
198
|
+
if (!firstShown.has(index))
|
|
199
|
+
firstShown.set(index, times.length);
|
|
200
|
+
times.push(chartTime);
|
|
201
|
+
shown.push(index);
|
|
202
|
+
}
|
|
203
|
+
const waitsForClose = (time) => !(showsForming && time === newest);
|
|
204
|
+
// Wait for close shows every run bar one run bar late, at its close. Once the newest run bar has
|
|
205
|
+
// closed on the chart, what lies past it (a cloud projected ahead, a row displaced forward) moves
|
|
206
|
+
// one run bar too: the chart at the run interval viewed one bar later. A newest run bar that still
|
|
207
|
+
// forms (wait for close off shows it in its own bucket; on, its close is not on the chart yet)
|
|
208
|
+
// leaves those times as they are.
|
|
209
|
+
const shiftsAhead = waitForClose && lastChartTime >= newestSpan.close;
|
|
210
|
+
const aheadAt = (time) => (shiftsAhead ? runBarSpan(time, run).close : time);
|
|
211
|
+
const anchor = (time) => time > newest ? aheadAt(time) : projectRunTimeOntoChart(time, chartTimes, runMs, waitsForClose(time), lattice);
|
|
212
|
+
// projectRunTimeOntoChart's target: the run bar's close (its open while it forms, wait for close off).
|
|
213
|
+
const shownAt = (time) => {
|
|
214
|
+
if (time > newest)
|
|
215
|
+
return aheadAt(time);
|
|
216
|
+
const span = runBarSpan(time, run);
|
|
217
|
+
return waitsForClose(time) ? span.close : span.open;
|
|
218
|
+
};
|
|
219
|
+
const firstChartTime = chartTimes[0];
|
|
220
|
+
const before = (time) => time <= newest && shownAt(time) < firstChartTime;
|
|
221
|
+
return {
|
|
222
|
+
timeline,
|
|
223
|
+
times,
|
|
224
|
+
shown,
|
|
225
|
+
firstShown,
|
|
226
|
+
anchor,
|
|
227
|
+
aheadAt,
|
|
228
|
+
shownAt,
|
|
229
|
+
before,
|
|
230
|
+
firstChartTime,
|
|
231
|
+
aheadFrom,
|
|
232
|
+
lastChartTime,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* The rows ahead of the run, as copies past the chart's last bar (`aheadAt`). One that falls on a
|
|
237
|
+
* chart bar belongs to a run bar this result does not carry yet (the run is behind the chart) and is
|
|
238
|
+
* dropped.
|
|
239
|
+
*/
|
|
240
|
+
function rowsAhead(rows, projection) {
|
|
241
|
+
return rows
|
|
242
|
+
.filter((row) => row[0] >= projection.aheadFrom)
|
|
243
|
+
.map((row) => restamp(row, projection.aheadAt(row[0]), row.length))
|
|
244
|
+
.filter((row) => row[0] > projection.lastChartTime)
|
|
245
|
+
.sort((a, b) => a[0] - b[0]);
|
|
246
|
+
}
|
|
247
|
+
/** `row`'s cells on chart time `time`; NaN cells (`width` wide, timestamp included) without a row. */
|
|
248
|
+
function restamp(row, time, width) {
|
|
249
|
+
const next = new Array(row ? row.length : width);
|
|
250
|
+
next[0] = time;
|
|
251
|
+
for (let cell = 1; cell < next.length; cell++)
|
|
252
|
+
next[cell] = row ? row[cell] : Number.NaN;
|
|
253
|
+
return next;
|
|
254
|
+
}
|
|
255
|
+
function fillEveryBar(rows, projection) {
|
|
256
|
+
const rowAt = new Map();
|
|
257
|
+
let width = 1;
|
|
258
|
+
for (const row of rows) {
|
|
259
|
+
width = Math.max(width, row.length);
|
|
260
|
+
if (row[0] >= projection.aheadFrom)
|
|
261
|
+
continue;
|
|
262
|
+
const index = floorIndex(projection.timeline, row[0]);
|
|
263
|
+
if (index >= 0)
|
|
264
|
+
rowAt.set(index, row);
|
|
265
|
+
}
|
|
266
|
+
return [
|
|
267
|
+
...projection.times.map((time, bar) => restamp(rowAt.get(projection.shown[bar]), time, width)),
|
|
268
|
+
...rowsAhead(rows, projection),
|
|
269
|
+
];
|
|
270
|
+
}
|
|
271
|
+
function isFiniteNumber(value) {
|
|
272
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
273
|
+
}
|
|
274
|
+
/** `record` with each of `keys` that holds a time anchored on the chart's time axis. */
|
|
275
|
+
function projectTimeProps(record, keys, anchor) {
|
|
276
|
+
let next = record;
|
|
277
|
+
for (const key of keys) {
|
|
278
|
+
const time = record[key];
|
|
279
|
+
if (!isFiniteNumber(time))
|
|
280
|
+
continue;
|
|
281
|
+
if (next === record)
|
|
282
|
+
next = { ...record };
|
|
283
|
+
next[key] = anchor(time);
|
|
284
|
+
}
|
|
285
|
+
return next;
|
|
286
|
+
}
|
|
287
|
+
function placeOnce(rows, projection) {
|
|
288
|
+
const placed = [];
|
|
289
|
+
for (const row of rows) {
|
|
290
|
+
if (row[0] >= projection.aheadFrom)
|
|
291
|
+
continue;
|
|
292
|
+
const bar = projection.firstShown.get(floorIndex(projection.timeline, row[0]));
|
|
293
|
+
if (bar === undefined)
|
|
294
|
+
continue;
|
|
295
|
+
placed.push(restamp(row, projection.times[bar], row.length));
|
|
296
|
+
}
|
|
297
|
+
placed.push(...rowsAhead(rows, projection));
|
|
298
|
+
for (const row of placed) {
|
|
299
|
+
if (isRecord(row[1]))
|
|
300
|
+
row[1] = projectTimeProps(row[1], PAYLOAD_TIME_KEYS, projection.anchor);
|
|
301
|
+
}
|
|
302
|
+
return placed;
|
|
303
|
+
}
|
|
304
|
+
function projectOutput(output, engineTimes, projection) {
|
|
305
|
+
const kind = projectionKindOf(output);
|
|
306
|
+
if (!kind)
|
|
307
|
+
return output;
|
|
308
|
+
let next = output;
|
|
309
|
+
for (const key of ROW_KEYS) {
|
|
310
|
+
const rows = timedRows(output[key], engineTimes);
|
|
311
|
+
if (!rows)
|
|
312
|
+
continue;
|
|
313
|
+
if (next === output)
|
|
314
|
+
next = { ...output };
|
|
315
|
+
next[key] = kind === 'once' ? placeOnce(rows, projection) : fillEveryBar(rows, projection);
|
|
316
|
+
}
|
|
317
|
+
return next;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Where the segment from `outside` (shown before the chart's first bar) to `inside` (on the chart)
|
|
321
|
+
* crosses the first bar: the price along the segment as drawn, `outside`'s own price when either
|
|
322
|
+
* price is no number.
|
|
323
|
+
*/
|
|
324
|
+
function crossingPrice(outside, inside, projection) {
|
|
325
|
+
const from = projection.shownAt(outside.time);
|
|
326
|
+
const to = projection.anchor(inside.time);
|
|
327
|
+
if (!isFiniteNumber(outside.price) || !isFiniteNumber(inside.price) || !(to > from))
|
|
328
|
+
return outside.price;
|
|
329
|
+
return outside.price + ((inside.price - outside.price) * (projection.firstChartTime - from)) / (to - from);
|
|
330
|
+
}
|
|
331
|
+
/** A line's ends on the chart; null when both show before its first bar. */
|
|
332
|
+
function projectLineProps(props, projection) {
|
|
333
|
+
const next = projectTimeProps(props, ['x1', 'x2'], projection.anchor);
|
|
334
|
+
const { x1, x2 } = props;
|
|
335
|
+
if (!isFiniteNumber(x1) || !isFiniteNumber(x2))
|
|
336
|
+
return next;
|
|
337
|
+
const before1 = projection.before(x1);
|
|
338
|
+
const before2 = projection.before(x2);
|
|
339
|
+
if (before1 && before2)
|
|
340
|
+
return null;
|
|
341
|
+
if (before1 === before2)
|
|
342
|
+
return next;
|
|
343
|
+
// The end before the chart is on the first bar already (the anchor's clamp): it takes the price
|
|
344
|
+
// where the line crosses it.
|
|
345
|
+
const end1 = { time: x1, price: props.y1 };
|
|
346
|
+
const end2 = { time: x2, price: props.y2 };
|
|
347
|
+
return before1
|
|
348
|
+
? { ...next, y1: crossingPrice(end1, end2, projection) }
|
|
349
|
+
: { ...next, y2: crossingPrice(end2, end1, projection) };
|
|
350
|
+
}
|
|
351
|
+
function polylineEnd(point, projection) {
|
|
352
|
+
if (!isRecord(point))
|
|
353
|
+
return undefined;
|
|
354
|
+
for (const [timeKey, priceKey] of POLYLINE_POINT_KEYS) {
|
|
355
|
+
const time = point[timeKey];
|
|
356
|
+
if (isFiniteNumber(time))
|
|
357
|
+
return { point, time, price: point[priceKey], priceKey, before: projection.before(time) };
|
|
358
|
+
}
|
|
359
|
+
return undefined;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* A polyline's points on the chart: the ones shown before its first bar leave, and where the line
|
|
363
|
+
* crosses that bar a point joins at the crossing's price. Null when every point shows before it.
|
|
364
|
+
*/
|
|
365
|
+
function projectPolylinePoints(points, projection) {
|
|
366
|
+
const projected = [];
|
|
367
|
+
let onChart = points.length === 0;
|
|
368
|
+
let previous;
|
|
369
|
+
for (const point of points) {
|
|
370
|
+
const end = polylineEnd(point, projection);
|
|
371
|
+
if (previous && end && previous.before !== end.before) {
|
|
372
|
+
const [outside, inside] = end.before ? [end, previous] : [previous, end];
|
|
373
|
+
// An inside point on the first bar is the crossing itself.
|
|
374
|
+
if (projection.anchor(inside.time) !== projection.firstChartTime) {
|
|
375
|
+
projected.push({
|
|
376
|
+
...projectTimeProps(outside.point, POLYLINE_POINT_TIME_KEYS, projection.anchor),
|
|
377
|
+
[outside.priceKey]: crossingPrice(outside, inside, projection),
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (!end?.before) {
|
|
382
|
+
projected.push(isRecord(point) ? projectTimeProps(point, POLYLINE_POINT_TIME_KEYS, projection.anchor) : point);
|
|
383
|
+
onChart = true;
|
|
384
|
+
}
|
|
385
|
+
previous = end;
|
|
386
|
+
}
|
|
387
|
+
return onChart ? projected : null;
|
|
388
|
+
}
|
|
389
|
+
/** A drawing's props on the chart's time axis; null for a drawing shown entirely before its first bar. */
|
|
390
|
+
function projectDrawingProps(kind, props, projection) {
|
|
391
|
+
// A pane-anchored drawing sits in pane units, not on the time axis.
|
|
392
|
+
if (typeof props.anchor === 'string')
|
|
393
|
+
return props;
|
|
394
|
+
if (kind === 'line')
|
|
395
|
+
return projectLineProps(props, projection);
|
|
396
|
+
if (kind === 'polyline') {
|
|
397
|
+
if (!Array.isArray(props.points))
|
|
398
|
+
return props;
|
|
399
|
+
const points = projectPolylinePoints(props.points, projection);
|
|
400
|
+
return points && { ...props, points };
|
|
401
|
+
}
|
|
402
|
+
const keys = (typeof kind === 'string' && DRAWING_TIME_PROPS.get(kind)) || [];
|
|
403
|
+
// A box shown entirely before the first bar leaves; one crossing it starts on it and keeps its
|
|
404
|
+
// right edge (the anchor's clamp).
|
|
405
|
+
const times = keys.map((key) => props[key]).filter(isFiniteNumber);
|
|
406
|
+
if (kind === 'box' && times.length > 0 && times.every(projection.before))
|
|
407
|
+
return null;
|
|
408
|
+
return projectTimeProps(props, keys, projection.anchor);
|
|
409
|
+
}
|
|
410
|
+
/** A drawing's bar index on the engine's timeline as an index on the projected `combinedTimes`. */
|
|
411
|
+
function projectBarIndex(bar, engineTimes, projection) {
|
|
412
|
+
if (typeof bar !== 'number' || !Number.isInteger(bar) || bar < 0 || bar >= engineTimes.length)
|
|
413
|
+
return bar;
|
|
414
|
+
if (projection.times.length === 0)
|
|
415
|
+
return 0;
|
|
416
|
+
const chartTime = projection.anchor(engineTimes[bar]);
|
|
417
|
+
return Math.max(0, Math.min(floorIndex(projection.times, chartTime), projection.times.length - 1));
|
|
418
|
+
}
|
|
419
|
+
function projectDrawings(drawings, engineTimes, projection) {
|
|
420
|
+
const dropped = new Set();
|
|
421
|
+
const projected = drawings.flatMap((drawing) => {
|
|
422
|
+
if (!isRecord(drawing))
|
|
423
|
+
return [drawing];
|
|
424
|
+
const next = { ...drawing };
|
|
425
|
+
if (isRecord(drawing.props)) {
|
|
426
|
+
const props = projectDrawingProps(drawing.kind, drawing.props, projection);
|
|
427
|
+
if (!props) {
|
|
428
|
+
dropped.add(drawing.id);
|
|
429
|
+
return [];
|
|
430
|
+
}
|
|
431
|
+
next.props = props;
|
|
432
|
+
}
|
|
433
|
+
for (const key of ['createdBar', 'mutatedBar']) {
|
|
434
|
+
if (Object.prototype.hasOwnProperty.call(drawing, key)) {
|
|
435
|
+
next[key] = projectBarIndex(drawing[key], engineTimes, projection);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return [next];
|
|
439
|
+
});
|
|
440
|
+
if (dropped.size === 0)
|
|
441
|
+
return projected;
|
|
442
|
+
// A line fill shades between two lines: it leaves with either of them.
|
|
443
|
+
return projected.filter((drawing) => !(isRecord(drawing) &&
|
|
444
|
+
drawing.kind === 'linefill' &&
|
|
445
|
+
isRecord(drawing.props) &&
|
|
446
|
+
(dropped.has(drawing.props.line1Id) || dropped.has(drawing.props.line2Id))));
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* The run result of an overlay whose engine ran at `runInterval`, projected onto the chart bars at
|
|
450
|
+
* `chartTimes` (ascending open times). Returns `runResult` itself when it carries nothing on a time
|
|
451
|
+
* axis; never mutates it.
|
|
452
|
+
*/
|
|
453
|
+
export function projectKScriptRunResultOntoChartBars(runResult, chartTimes, runInterval) {
|
|
454
|
+
if (!isRecord(runResult) || !(runInterval.intervalMs > 0))
|
|
455
|
+
return runResult;
|
|
456
|
+
const engineTimes = engineTimelineOf(runResult);
|
|
457
|
+
const aheadFrom = aheadFromOf(engineTimes, runInterval);
|
|
458
|
+
const timeline = runTimelineOf(runResult, engineTimes, aheadFrom);
|
|
459
|
+
if (timeline.length === 0)
|
|
460
|
+
return runResult;
|
|
461
|
+
const projection = buildProjection(timeline, chartTimes, runInterval, aheadFrom);
|
|
462
|
+
const projected = {
|
|
463
|
+
...mapOutputTree(runResult, (output) => projectOutput(output, engineTimes, projection)),
|
|
464
|
+
// Titan pads an output with no rows from combinedTimes, and every bar index reads through it.
|
|
465
|
+
combinedTimes: projection.times,
|
|
466
|
+
};
|
|
467
|
+
if (Array.isArray(runResult.drawings)) {
|
|
468
|
+
projected.drawings = projectDrawings(runResult.drawings, engineTimes, projection);
|
|
469
|
+
}
|
|
470
|
+
return projected;
|
|
471
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render-equality of two kScript run results.
|
|
3
|
+
*
|
|
4
|
+
* A source-cache revalidation (SWR: stale paints, fresh replaces) re-runs
|
|
5
|
+
* the script over the recorded range with every source leg fetched live.
|
|
6
|
+
* When the fresh rows equal the cached rows the run result is identical to
|
|
7
|
+
* the one already mounted, and integrating it again (apply-remount: legend
|
|
8
|
+
* rows rebuilt, every plot repainted) is pure churn: three toolkits added
|
|
9
|
+
* together paid two remounts each inside their first 15s on the QA dump.
|
|
10
|
+
*
|
|
11
|
+
* Equality rides the apply-skip fingerprint (below); diagnostics, print
|
|
12
|
+
* outputs and timings are outside it: they never change what is painted, and
|
|
13
|
+
* the caller keeps their side channels fresh on the skip.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Render-equality = the SAME identity the mounted-rows apply-skip gate uses
|
|
17
|
+
* (`fingerprintKScriptRunResultForApplySkip`: rows, outputs, drawings, tables,
|
|
18
|
+
* settings colors, capped and failing open on oversized drawings). One
|
|
19
|
+
* identity for "nothing changed" everywhere; a null fingerprint (fail open)
|
|
20
|
+
* is never equal.
|
|
21
|
+
*/
|
|
22
|
+
export declare function kscriptRunResultsRenderEqual(a: unknown, b: unknown): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The render identity of ONE run result as a string: equal strings mean equal
|
|
25
|
+
* paint. Stricter than `kscriptRunResultsRenderEqual` (which rides the
|
|
26
|
+
* apply-skip fingerprint): it also covers every per-output field, the
|
|
27
|
+
* run-level settings, the timeline and every unknown key, and fails open to
|
|
28
|
+
* `null` (never equal) on anything it cannot hash. The worker decides whether
|
|
29
|
+
* a live result crosses as a compact "unchanged" post with it, and the proxy
|
|
30
|
+
* checks that post against the result it last accepted, so this is the one
|
|
31
|
+
* definition both sides share (`fingerprintKScriptRunResultRenderIdentity`).
|
|
32
|
+
*/
|
|
33
|
+
export declare function kscriptRunResultRenderIdentity(result: unknown): string | null;
|
|
34
|
+
/**
|
|
35
|
+
* Same plot set (output keys, plot types): the mounted-rows fast path can
|
|
36
|
+
* absorb such a result as a rows refresh; a changed plot set needs a remount.
|
|
37
|
+
*/
|
|
38
|
+
export declare function kscriptRunResultsSameOutputKeys(a: unknown, b: unknown): boolean;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render-equality of two kScript run results.
|
|
3
|
+
*
|
|
4
|
+
* A source-cache revalidation (SWR: stale paints, fresh replaces) re-runs
|
|
5
|
+
* the script over the recorded range with every source leg fetched live.
|
|
6
|
+
* When the fresh rows equal the cached rows the run result is identical to
|
|
7
|
+
* the one already mounted, and integrating it again (apply-remount: legend
|
|
8
|
+
* rows rebuilt, every plot repainted) is pure churn: three toolkits added
|
|
9
|
+
* together paid two remounts each inside their first 15s on the QA dump.
|
|
10
|
+
*
|
|
11
|
+
* Equality rides the apply-skip fingerprint (below); diagnostics, print
|
|
12
|
+
* outputs and timings are outside it: they never change what is painted, and
|
|
13
|
+
* the caller keeps their side channels fresh on the skip.
|
|
14
|
+
*/
|
|
15
|
+
import { fingerprintKScriptRunResultForApplySkip, fingerprintKScriptRunResultRenderIdentity, } from './kscript-apply-fingerprint.util.js';
|
|
16
|
+
/**
|
|
17
|
+
* Render-equality = the SAME identity the mounted-rows apply-skip gate uses
|
|
18
|
+
* (`fingerprintKScriptRunResultForApplySkip`: rows, outputs, drawings, tables,
|
|
19
|
+
* settings colors, capped and failing open on oversized drawings). One
|
|
20
|
+
* identity for "nothing changed" everywhere; a null fingerprint (fail open)
|
|
21
|
+
* is never equal.
|
|
22
|
+
*/
|
|
23
|
+
export function kscriptRunResultsRenderEqual(a, b) {
|
|
24
|
+
if (a === b)
|
|
25
|
+
return true;
|
|
26
|
+
// The fingerprint hashes rows, drawings, tables and colors but not the plot
|
|
27
|
+
// set itself (keys / plot types / nested panes): the plot-set check owns that.
|
|
28
|
+
if (!kscriptRunResultsSameOutputKeys(a, b))
|
|
29
|
+
return false;
|
|
30
|
+
const fa = fingerprintKScriptRunResultForApplySkip(a);
|
|
31
|
+
if (fa === null || fa !== fingerprintKScriptRunResultForApplySkip(b))
|
|
32
|
+
return false;
|
|
33
|
+
const na = nestedOf(a);
|
|
34
|
+
const nb = nestedOf(b);
|
|
35
|
+
for (let i = 0; i < na.length; i++)
|
|
36
|
+
if (!kscriptRunResultsRenderEqual(na[i], nb[i]))
|
|
37
|
+
return false;
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The render identity of ONE run result as a string: equal strings mean equal
|
|
42
|
+
* paint. Stricter than `kscriptRunResultsRenderEqual` (which rides the
|
|
43
|
+
* apply-skip fingerprint): it also covers every per-output field, the
|
|
44
|
+
* run-level settings, the timeline and every unknown key, and fails open to
|
|
45
|
+
* `null` (never equal) on anything it cannot hash. The worker decides whether
|
|
46
|
+
* a live result crosses as a compact "unchanged" post with it, and the proxy
|
|
47
|
+
* checks that post against the result it last accepted, so this is the one
|
|
48
|
+
* definition both sides share (`fingerprintKScriptRunResultRenderIdentity`).
|
|
49
|
+
*/
|
|
50
|
+
export function kscriptRunResultRenderIdentity(result) {
|
|
51
|
+
return fingerprintKScriptRunResultRenderIdentity(result);
|
|
52
|
+
}
|
|
53
|
+
function nestedOf(value) {
|
|
54
|
+
const nested = value && typeof value === 'object' ? value.nestedMeta : undefined;
|
|
55
|
+
return Array.isArray(nested) ? nested : [];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Same plot set (output keys, plot types): the mounted-rows fast path can
|
|
59
|
+
* absorb such a result as a rows refresh; a changed plot set needs a remount.
|
|
60
|
+
*/
|
|
61
|
+
export function kscriptRunResultsSameOutputKeys(a, b) {
|
|
62
|
+
const oa = a && typeof a === 'object' ? a.outputs : null;
|
|
63
|
+
const ob = b && typeof b === 'object' ? b.outputs : null;
|
|
64
|
+
const ka = oa && typeof oa === 'object' ? Object.keys(oa).sort() : [];
|
|
65
|
+
const kb = ob && typeof ob === 'object' ? Object.keys(ob).sort() : [];
|
|
66
|
+
if (ka.length !== kb.length)
|
|
67
|
+
return false;
|
|
68
|
+
for (let i = 0; i < ka.length; i++) {
|
|
69
|
+
if (ka[i] !== kb[i])
|
|
70
|
+
return false;
|
|
71
|
+
const x = oa[ka[i]];
|
|
72
|
+
const y = ob[kb[i]];
|
|
73
|
+
if ((x && typeof x === 'object' ? x.plotType : undefined) !== (y && typeof y === 'object' ? y.plotType : undefined)) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const na = a && typeof a === 'object' && Array.isArray(a.nestedMeta)
|
|
78
|
+
? a.nestedMeta
|
|
79
|
+
: [];
|
|
80
|
+
const nb = b && typeof b === 'object' && Array.isArray(b.nestedMeta)
|
|
81
|
+
? b.nestedMeta
|
|
82
|
+
: [];
|
|
83
|
+
if (na.length !== nb.length)
|
|
84
|
+
return false;
|
|
85
|
+
for (let i = 0; i < na.length; i++)
|
|
86
|
+
if (!kscriptRunResultsSameOutputKeys(na[i], nb[i]))
|
|
87
|
+
return false;
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A kScript overlay's settings revision as its settings carry it (a leaf of utility/chart/kscript-settings-save.util.ts;
|
|
3
|
+
* P2/inventory.md section 1.1): the compute generation a run is noted with, which the wrun executor reads at its head.
|
|
4
|
+
* Pure, one constants import, so it moves into the chart-host package with the phase 2 closure; the settings save
|
|
5
|
+
* module imports and re-exports it.
|
|
6
|
+
*/
|
|
7
|
+
import { KSCRIPT_SETTINGS_REVISION_KEY } from '../../constants/scriptEditor/execution.constants.js';
|
|
8
|
+
/** The revision the settings carry; 0 for settings with none (or none that reads as a positive number). */
|
|
9
|
+
export function kScriptSettingsRevision(settings) {
|
|
10
|
+
const revision = Number(settings?.[KSCRIPT_SETTINGS_REVISION_KEY]);
|
|
11
|
+
return Number.isFinite(revision) && revision > 0 ? revision : 0;
|
|
12
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A secondary source's retry and budget numbers (a leaf of utility/chart/kscript-source-degrade.util.ts;
|
|
3
|
+
* P2/inventory.md section 1.1): the constants recovery reads and the budget the executor reads. The degrade registry and
|
|
4
|
+
* its mutators stay in the old module (the chart store and the engine manager share it) behind the chart-host members
|
|
5
|
+
* `chart.markSourcesTerminal`, `chart.markSourceDegraded` and the rest; this leaf holds no state, so it moves into the
|
|
6
|
+
* chart-host package with the phase 2 closure. The old module re-exports it.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* SRCDEGRADE: per-source acquisition budget for browser-run kScript overlays.
|
|
10
|
+
*
|
|
11
|
+
* A secondary source (order flow, open interest, funding, orderbook, any
|
|
12
|
+
* non-ohlcv leg that does not own the timeline) that is slow or unavailable
|
|
13
|
+
* must never hold the whole run: after KSCRIPT_SECONDARY_SOURCE_BUDGET_MS the
|
|
14
|
+
* proxy answers the worker with ok:false for that request, the engine stores
|
|
15
|
+
* an EMPTY series for the source (engine 3.0.84 contract, pinned by
|
|
16
|
+
* tests/instances/script-engine-source-degrade.engine.spec.ts) and the run
|
|
17
|
+
* proceeds candles-only. Recovery rides the engine's own refresh(from, to,
|
|
18
|
+
* true), never a one-source injection.
|
|
19
|
+
*
|
|
20
|
+
* This module owns the pure rules (predicate, budget, ladder) and the
|
|
21
|
+
* per-overlay registry the legend chip is DERIVED from at the diagnostics
|
|
22
|
+
* choke point (chart.ts setIndicatorDiagnostics), so no diagnostics writer
|
|
23
|
+
* can drop the chip and no writer ever sets it directly.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Base budget (the floor). Provisional instrumented SLO (2026-09-03): the
|
|
27
|
+
* healthy field dump's 2.4s volume_profile wall was a replay-cache hit, so
|
|
28
|
+
* there was no wire p95; the first field read (dump 2026-09-03T07:30Z, two
|
|
29
|
+
* scripts, ~4-day 1m windows: volume_profile at 5 ticks/bar, liquidations,
|
|
30
|
+
* buy_sell_volume) showed 10 of 10 degrades at exactly this floor, so the
|
|
31
|
+
* budget now SCALES with the requested window (resolveSecondarySourceBudgetMs)
|
|
32
|
+
* and is anchored at wire dispatch (fetchOptions.onDispatched) instead of at
|
|
33
|
+
* request arrival. Against the failing dump the floor still lands ~7s before
|
|
34
|
+
* the attention probe convicts the socket and ~12.6s before it re-opens.
|
|
35
|
+
*/
|
|
36
|
+
export declare const KSCRIPT_SECONDARY_SOURCE_BUDGET_MS = 10000;
|
|
37
|
+
/** Extra budget per 1000 expected rows of the requested window (window / source interval). */
|
|
38
|
+
export declare const KSCRIPT_SECONDARY_SOURCE_BUDGET_PER_1K_ROWS_MS = 2500;
|
|
39
|
+
/** Ceiling of the window-scaled budget: a dead socket after dispatch still degrades within this. */
|
|
40
|
+
export declare const KSCRIPT_SECONDARY_SOURCE_BUDGET_MAX_MS = 40000;
|
|
41
|
+
/**
|
|
42
|
+
* The window-scaled budget: floor + PER_1K_ROWS per thousand expected rows
|
|
43
|
+
* of the requested window, capped at BUDGET_MAX. Anything unresolvable
|
|
44
|
+
* (missing or non-finite bounds, an empty or inverted window, no interval)
|
|
45
|
+
* yields the floor. A 250-bar window adds ~0.6s; a 4-day 1m window (5760
|
|
46
|
+
* rows) lands at ~24s; the cap holds everything past 12k rows.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveSecondarySourceBudgetMs(window: {
|
|
49
|
+
fromMs?: number;
|
|
50
|
+
toMs?: number;
|
|
51
|
+
intervalMs?: number;
|
|
52
|
+
}): number;
|
|
53
|
+
/**
|
|
54
|
+
* Gaps between recovery attempts (each is one forced refetch of the overlay
|
|
55
|
+
* with retryAttempt stamped on the degraded names only): the first fires 15s
|
|
56
|
+
* after the degrade (~2.4s after the socket re-open in the failing dump), the
|
|
57
|
+
* second 20s after the first settles (the last attempt inside a minute). A
|
|
58
|
+
* stale-arrival recovery (the original request landing late with rows) fires
|
|
59
|
+
* after KSCRIPT_SECONDARY_SOURCE_STALE_ARRIVAL_RECOVERY_DELAY_MS instead.
|
|
60
|
+
*/
|
|
61
|
+
export declare const KSCRIPT_SECONDARY_SOURCE_RETRY_DELAYS_MS: readonly number[];
|
|
62
|
+
/** Total recovery attempts per degrade episode (ladder + stale-arrival), reset by a user rebuild. */
|
|
63
|
+
export declare const KSCRIPT_SECONDARY_SOURCE_MAX_RECOVERY_ATTEMPTS = 3;
|