@orangecharts/wrun-chart-host 0.4.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 +15 -4
- 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/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 +313 -18
- package/dist/host-env.js +15 -0
- package/dist/host-ports.types.d.ts +853 -16
- package/dist/index.d.ts +139 -2
- package/dist/index.js +139 -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/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 +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-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.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-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-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
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The run allocation bound of the browser worker (WRUN-BATCHED-MARKS round 2, fold 4): a run block
|
|
3
|
+
* holds one f64 cell per row and declared output (`rowCount x outputCount`, the packed outputs the
|
|
4
|
+
* worker answers), allocated in one buffer before any row is evaluated. A batched section multiplies
|
|
5
|
+
* the outputs a sheet declares (Big Trades 0.4.0: 97 of them), so the worker checks the product
|
|
6
|
+
* BEFORE the buffer and refuses a run past `WRUN_MAX_RUN_CELLS` by name (`wrun_run_cells_too_large`,
|
|
7
|
+
* a refusal of the kit's vocabulary and of the chart's refusal table, run-failure-props.util). The
|
|
8
|
+
* mounted budget of the batched children (2,000,000 cells, overlay-execution-guard) is the chart's
|
|
9
|
+
* second bound, over what stays mounted.
|
|
10
|
+
*
|
|
11
|
+
* The main thread never sends a block past the bound (WRUN-MARKS-CONTRACT design 5): the run's
|
|
12
|
+
* retained range (wrun-run-retained.util) asks the newest `wrunRunCellsRows(outputCount)` rows at
|
|
13
|
+
* most, so the refusal is the backstop of a request the planner did not size.
|
|
14
|
+
*
|
|
15
|
+
* Imports nothing: the worker host (wrun-abi-host) reads it, and the main thread names the refusal.
|
|
16
|
+
*/
|
|
17
|
+
/** The largest `rowCount x outputCount` one run block may allocate (32 MB of f64 cells). */
|
|
18
|
+
export declare const WRUN_MAX_RUN_CELLS = 4000000;
|
|
19
|
+
/** The refusal names the run allocation raises (a code of the kit's refusal table). */
|
|
20
|
+
export declare const WRUN_RUN_CELLS_REFUSALS: {
|
|
21
|
+
/** A run block whose rows times declared outputs pass WRUN_MAX_RUN_CELLS. */
|
|
22
|
+
readonly tooLarge: "wrun_run_cells_too_large";
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The most rows one run block of `outputCount` declared outputs may hold under WRUN_MAX_RUN_CELLS:
|
|
26
|
+
* `floor(WRUN_MAX_RUN_CELLS / outputCount)` (Big Trades 0.4.0, 97 outputs: 41,237 rows). Null for a
|
|
27
|
+
* run that declares no outputs (a frame-only run allocates no cells) and for a count that is not a
|
|
28
|
+
* positive finite number.
|
|
29
|
+
*/
|
|
30
|
+
export declare function wrunRunCellsRows(outputCount: number): number | null;
|
|
31
|
+
/**
|
|
32
|
+
* The words a run block of `rowCount` rows and `outputCount` declared outputs refuses with, named by
|
|
33
|
+
* `wrun_run_cells_too_large`; null when the block's cells fit WRUN_MAX_RUN_CELLS. A count that is not
|
|
34
|
+
* a finite number refuses too: its allocation could not be checked.
|
|
35
|
+
*/
|
|
36
|
+
export declare function wrunRunCellsRefusal(rowCount: number, outputCount: number): string | null;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The run allocation bound of the browser worker (WRUN-BATCHED-MARKS round 2, fold 4): a run block
|
|
3
|
+
* holds one f64 cell per row and declared output (`rowCount x outputCount`, the packed outputs the
|
|
4
|
+
* worker answers), allocated in one buffer before any row is evaluated. A batched section multiplies
|
|
5
|
+
* the outputs a sheet declares (Big Trades 0.4.0: 97 of them), so the worker checks the product
|
|
6
|
+
* BEFORE the buffer and refuses a run past `WRUN_MAX_RUN_CELLS` by name (`wrun_run_cells_too_large`,
|
|
7
|
+
* a refusal of the kit's vocabulary and of the chart's refusal table, run-failure-props.util). The
|
|
8
|
+
* mounted budget of the batched children (2,000,000 cells, overlay-execution-guard) is the chart's
|
|
9
|
+
* second bound, over what stays mounted.
|
|
10
|
+
*
|
|
11
|
+
* The main thread never sends a block past the bound (WRUN-MARKS-CONTRACT design 5): the run's
|
|
12
|
+
* retained range (wrun-run-retained.util) asks the newest `wrunRunCellsRows(outputCount)` rows at
|
|
13
|
+
* most, so the refusal is the backstop of a request the planner did not size.
|
|
14
|
+
*
|
|
15
|
+
* Imports nothing: the worker host (wrun-abi-host) reads it, and the main thread names the refusal.
|
|
16
|
+
*/
|
|
17
|
+
/** The largest `rowCount x outputCount` one run block may allocate (32 MB of f64 cells). */
|
|
18
|
+
export const WRUN_MAX_RUN_CELLS = 4_000_000;
|
|
19
|
+
/** The refusal names the run allocation raises (a code of the kit's refusal table). */
|
|
20
|
+
export const WRUN_RUN_CELLS_REFUSALS = {
|
|
21
|
+
/** A run block whose rows times declared outputs pass WRUN_MAX_RUN_CELLS. */
|
|
22
|
+
tooLarge: 'wrun_run_cells_too_large',
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The most rows one run block of `outputCount` declared outputs may hold under WRUN_MAX_RUN_CELLS:
|
|
26
|
+
* `floor(WRUN_MAX_RUN_CELLS / outputCount)` (Big Trades 0.4.0, 97 outputs: 41,237 rows). Null for a
|
|
27
|
+
* run that declares no outputs (a frame-only run allocates no cells) and for a count that is not a
|
|
28
|
+
* positive finite number.
|
|
29
|
+
*/
|
|
30
|
+
export function wrunRunCellsRows(outputCount) {
|
|
31
|
+
if (!Number.isFinite(outputCount) || outputCount <= 0)
|
|
32
|
+
return null;
|
|
33
|
+
return Math.floor(WRUN_MAX_RUN_CELLS / outputCount);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The words a run block of `rowCount` rows and `outputCount` declared outputs refuses with, named by
|
|
37
|
+
* `wrun_run_cells_too_large`; null when the block's cells fit WRUN_MAX_RUN_CELLS. A count that is not
|
|
38
|
+
* a finite number refuses too: its allocation could not be checked.
|
|
39
|
+
*/
|
|
40
|
+
export function wrunRunCellsRefusal(rowCount, outputCount) {
|
|
41
|
+
const cells = rowCount * outputCount;
|
|
42
|
+
if (Number.isFinite(cells) && cells <= WRUN_MAX_RUN_CELLS)
|
|
43
|
+
return null;
|
|
44
|
+
return (`WRUN ${WRUN_RUN_CELLS_REFUSALS.tooLarge}: this run holds ${rowCount} rows x ${outputCount} outputs = ` +
|
|
45
|
+
`${cells} cells, over the ${WRUN_MAX_RUN_CELLS} a run may allocate; load a shorter range or declare fewer outputs`);
|
|
46
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session half of a wrun run at another interval (WRUN-HTF-NATIVE-PLAN.md 3.2 to 3.4): what a
|
|
3
|
+
* live session whose package computes at its run interval X (wrun-run-interval.util) keeps beside
|
|
4
|
+
* its live context, and the pure rules the full run, the reseed, the live intake and the live tick
|
|
5
|
+
* share.
|
|
6
|
+
*
|
|
7
|
+
* - The session's primary rows are its run bars: the X candles the full run fetched with their
|
|
8
|
+
* warm-up (or reused from the previous session, planWrunRunIntervalRows), never the chart's
|
|
9
|
+
* candles. The live intake folds the chart market's candle frames into the forming run bar, the
|
|
10
|
+
* tick's reconcile re-asks the newest run bars, the reseed rebuilds from them.
|
|
11
|
+
* - Wait for close on, the package computes on the closed run bars only (the forming one waits in
|
|
12
|
+
* the buffer until the chart shows a bar past it, wrunRunIntervalComputeRows): inside the
|
|
13
|
+
* forming bucket a tick only re-applies the held result, the roll computes the bar that closed.
|
|
14
|
+
* Off, the forming run bar is computed on every tick.
|
|
15
|
+
* - `run` is the stamp the full run read once: the projection, the HUD snapshot and every tick of
|
|
16
|
+
* the session read it, never the overlay's current settings.
|
|
17
|
+
* - The chart clock stays beside it: the history check keys on the chart's first bar, the plan
|
|
18
|
+
* clock on the chart's newest bar.
|
|
19
|
+
* - Every rule reads a run bar's open and close by runBarSpan (indicator-run-interval.util): on the
|
|
20
|
+
* CME session lattice (`run.sessionLattice`) a 1D or 1W run bar is stamped 00:00Z after its own
|
|
21
|
+
* evening open, so its stamp is neither its open nor a whole interval before its close.
|
|
22
|
+
*
|
|
23
|
+
* Kept beside the context object (the full run installs a new context per run, so the state goes
|
|
24
|
+
* with the one it was built for), like the session's chart names (wrun-chart-context-names.util).
|
|
25
|
+
*/
|
|
26
|
+
import { type OverlayRunInterval, type RunBarCalendar } from '../chart/indicator-run-interval.util.js';
|
|
27
|
+
import type { WrunRunInterval } from './wrun-run-interval.util.js';
|
|
28
|
+
import type { WrunRunIntervalProjection } from './wrun-run-interval-projection.types.js';
|
|
29
|
+
export type { WrunRunIntervalProjection };
|
|
30
|
+
/** The intake queue key the chart market's candle frames ride for a session at another interval
|
|
31
|
+
* (beside the grid legs' queues, never a leg's fetch key). */
|
|
32
|
+
export declare const WRUN_RUN_INTERVAL_ROWS_KEY = "run-interval|main";
|
|
33
|
+
export interface WrunRunIntervalSession {
|
|
34
|
+
/** The run interval the session computes at, as the full run read it. */
|
|
35
|
+
run: WrunRunInterval;
|
|
36
|
+
/** Identity of the run bars (wrunRunIntervalCoverageKey): the run interval and the chart market. */
|
|
37
|
+
key: string;
|
|
38
|
+
/** The chart's own interval in ms (the chart clock beside the run clock). */
|
|
39
|
+
chartIntervalMs: number;
|
|
40
|
+
/** The chart's first loaded bar the session was built over: a chart whose first bar moved
|
|
41
|
+
* rebuilds (a lazy page, a shed head), whatever the run bars hold. */
|
|
42
|
+
chartFirstTs: number;
|
|
43
|
+
/** The start the run bars were asked from (the warm-up's first run bar): what the buffer covers
|
|
44
|
+
* even when the market's history starts later. */
|
|
45
|
+
coveredFromTs: number;
|
|
46
|
+
/** The end of the last window an ask answered for the run bars (the full run's, then each
|
|
47
|
+
* reconcile's); a failed re-ask leaves it behind and the next window reaches back to it. */
|
|
48
|
+
coveredThroughTs: number;
|
|
49
|
+
/** The run bars [ts, open, high, low, close, volume], ascending, the forming one included:
|
|
50
|
+
* replaced (never mutated) by every fold and every reconcile merge. */
|
|
51
|
+
rows: ArrayLike<number>[];
|
|
52
|
+
/** The newest trade stamp (ms) a live candle frame folded into `rows`: a replayed frame at or
|
|
53
|
+
* before it re-sends increments the fold already holds. */
|
|
54
|
+
newestTradeStampMs?: number;
|
|
55
|
+
/** The input row the package last evaluated as its newest (the full run's, the reseed's, each
|
|
56
|
+
* block's): with wait for close on, a block that would re-send it unchanged computes nothing. */
|
|
57
|
+
lastSentRow?: {
|
|
58
|
+
ts: number;
|
|
59
|
+
values: number[];
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** Store the run-interval state of a live context (the full run, right after it installs it). */
|
|
63
|
+
export declare function rememberWrunRunIntervalSession(context: object, session: WrunRunIntervalSession): void;
|
|
64
|
+
/** The run-interval state of a live context; undefined for a session on the chart's own bars. */
|
|
65
|
+
export declare function wrunRunIntervalSessionOf(context: object | undefined): WrunRunIntervalSession | undefined;
|
|
66
|
+
/** The run interval in ms the overlay's live session computes at, undefined when it computes on
|
|
67
|
+
* the chart's bars (or holds no session): the bucket a rider's rows are floored on. */
|
|
68
|
+
export declare function wrunLiveRunIntervalMs(indicatorId: string): number | undefined;
|
|
69
|
+
/** The identity of the run bars a session holds: the run interval and the chart market they were
|
|
70
|
+
* fetched for (exchange, symbol, transformations), never the chart's own interval. */
|
|
71
|
+
export declare function wrunRunIntervalCoverageKey(run: Pick<OverlayRunInterval, 'interval'>, market: {
|
|
72
|
+
exchange?: unknown;
|
|
73
|
+
symbol?: unknown;
|
|
74
|
+
transformations?: unknown;
|
|
75
|
+
} | null | undefined): string;
|
|
76
|
+
/** The run bars open at or before the chart's newest bar: a frame or an answer may hold the next
|
|
77
|
+
* bucket before the chart shows a bar in it. A bar opens at its stamp, on the session lattice at
|
|
78
|
+
* its session open (a CME trade date is stamped after its own evening bars, and its forming bar
|
|
79
|
+
* passes from that open on). The same array when every row passes. */
|
|
80
|
+
export declare function wrunRunIntervalRowsThrough(run: RunBarCalendar, rows: ReadonlyArray<ArrayLike<number>>, lastChartTs: number): ArrayLike<number>[];
|
|
81
|
+
/**
|
|
82
|
+
* The run bars a session computes over at the chart's newest bar. Wait for close on: the closed
|
|
83
|
+
* ones only (a run bar closes once the chart shows a bar at or past its close), so every output the
|
|
84
|
+
* package draws as of its newest bar (a projected cloud, a zone, a label) is the last closed bar's,
|
|
85
|
+
* like its lines on the forming bucket's chart bars; the forming bar stays in the buffer until it
|
|
86
|
+
* closes. Off: the forming bar too (the chart bars of its bucket show it).
|
|
87
|
+
*/
|
|
88
|
+
export declare function wrunRunIntervalComputeRows(run: Pick<OverlayRunInterval, 'intervalMs' | 'waitForClose' | 'sessionLattice'>, rows: ReadonlyArray<ArrayLike<number>>, lastChartTs: number): ArrayLike<number>[];
|
|
89
|
+
/** The input row a session last evaluated as its newest, copied (wrunRunIntervalSession.lastSentRow). */
|
|
90
|
+
export declare function wrunRunIntervalSentRow(row: {
|
|
91
|
+
ts: number;
|
|
92
|
+
values: ArrayLike<number>;
|
|
93
|
+
}): {
|
|
94
|
+
ts: number;
|
|
95
|
+
values: number[];
|
|
96
|
+
};
|
|
97
|
+
export interface WrunRunIntervalRowsPlan {
|
|
98
|
+
/** The start the run bars are asked from, or were (held). */
|
|
99
|
+
fromTs: number;
|
|
100
|
+
/** The previous session's run bars when they still cover the chart and its full warm-up: the run
|
|
101
|
+
* recomputes over them and fetches nothing. */
|
|
102
|
+
held?: ArrayLike<number>[];
|
|
103
|
+
/** With `held`, what the next session inherits from the held one: its covered watermark (a failed
|
|
104
|
+
* re-ask's obligation, which the next reconcile reaches back to) and the newest trade its fold
|
|
105
|
+
* took (a replayed frame at or before it re-sends trades the bars hold). */
|
|
106
|
+
carry?: {
|
|
107
|
+
coveredThroughTs: number;
|
|
108
|
+
newestTradeStampMs?: number;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Which run bars one full run computes over (run-interval-engine.util's planRunIntervalRefresh
|
|
113
|
+
* rule, on the session's buffer): the previous session's run bars when they are the same run
|
|
114
|
+
* interval on the same market (`key`), were asked from at or before the warm-up the chart's first
|
|
115
|
+
* bar needs (`warmupBars` run bars below the run bar holding it), hold the run bar of the chart's
|
|
116
|
+
* newest bar (one still open there: its close past it) and hold no bar stamped past their coverage
|
|
117
|
+
* (the ask windows' end, read on stamps; the intake extends the forming bar it opened at the
|
|
118
|
+
* coverage end; a bar further on, appended after a failed or missed window, may stand past a hole
|
|
119
|
+
* no answer filled); else a fetch from that warm-up start. Without the warm-up term, consecutive
|
|
120
|
+
* prepended pages would erode the warm-up toward zero run bars. Every full run passes here (a lazy
|
|
121
|
+
* page, a settings save, a live rebuild), so a style edit or a pan inside the held warm-up reuses
|
|
122
|
+
* the bars while another timeframe (a new key) or a raised lookback (an earlier start) refetches.
|
|
123
|
+
* The live reconcile right after the run refreshes the newest run bars either way.
|
|
124
|
+
*/
|
|
125
|
+
export declare function planWrunRunIntervalRows(input: {
|
|
126
|
+
run: WrunRunInterval;
|
|
127
|
+
key: string;
|
|
128
|
+
chartFirstTs: number;
|
|
129
|
+
chartLastTs: number;
|
|
130
|
+
held: WrunRunIntervalSession | undefined;
|
|
131
|
+
}): WrunRunIntervalRowsPlan;
|
|
132
|
+
/** The projection a run's integrates pass: its stamp on its chart. */
|
|
133
|
+
export declare function wrunRunIntervalProjectionOf(run: OverlayRunInterval, chartIndex: number, chartExchange: unknown): WrunRunIntervalProjection;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session half of a wrun run at another interval (WRUN-HTF-NATIVE-PLAN.md 3.2 to 3.4): what a
|
|
3
|
+
* live session whose package computes at its run interval X (wrun-run-interval.util) keeps beside
|
|
4
|
+
* its live context, and the pure rules the full run, the reseed, the live intake and the live tick
|
|
5
|
+
* share.
|
|
6
|
+
*
|
|
7
|
+
* - The session's primary rows are its run bars: the X candles the full run fetched with their
|
|
8
|
+
* warm-up (or reused from the previous session, planWrunRunIntervalRows), never the chart's
|
|
9
|
+
* candles. The live intake folds the chart market's candle frames into the forming run bar, the
|
|
10
|
+
* tick's reconcile re-asks the newest run bars, the reseed rebuilds from them.
|
|
11
|
+
* - Wait for close on, the package computes on the closed run bars only (the forming one waits in
|
|
12
|
+
* the buffer until the chart shows a bar past it, wrunRunIntervalComputeRows): inside the
|
|
13
|
+
* forming bucket a tick only re-applies the held result, the roll computes the bar that closed.
|
|
14
|
+
* Off, the forming run bar is computed on every tick.
|
|
15
|
+
* - `run` is the stamp the full run read once: the projection, the HUD snapshot and every tick of
|
|
16
|
+
* the session read it, never the overlay's current settings.
|
|
17
|
+
* - The chart clock stays beside it: the history check keys on the chart's first bar, the plan
|
|
18
|
+
* clock on the chart's newest bar.
|
|
19
|
+
* - Every rule reads a run bar's open and close by runBarSpan (indicator-run-interval.util): on the
|
|
20
|
+
* CME session lattice (`run.sessionLattice`) a 1D or 1W run bar is stamped 00:00Z after its own
|
|
21
|
+
* evening open, so its stamp is neither its open nor a whole interval before its close.
|
|
22
|
+
*
|
|
23
|
+
* Kept beside the context object (the full run installs a new context per run, so the state goes
|
|
24
|
+
* with the one it was built for), like the session's chart names (wrun-chart-context-names.util).
|
|
25
|
+
*/
|
|
26
|
+
import { runBarSpan } from '../chart/indicator-run-interval.util.js';
|
|
27
|
+
import { runIntervalWarmupStartTs } from '../chart/run-interval-warmup.leaf.js';
|
|
28
|
+
import { getWrunOverlayLiveContext } from './wrun-overlay-drivers.util.js';
|
|
29
|
+
/** The intake queue key the chart market's candle frames ride for a session at another interval
|
|
30
|
+
* (beside the grid legs' queues, never a leg's fetch key). */
|
|
31
|
+
export const WRUN_RUN_INTERVAL_ROWS_KEY = 'run-interval|main';
|
|
32
|
+
const sessions = new WeakMap();
|
|
33
|
+
/** Store the run-interval state of a live context (the full run, right after it installs it). */
|
|
34
|
+
export function rememberWrunRunIntervalSession(context, session) {
|
|
35
|
+
sessions.set(context, session);
|
|
36
|
+
}
|
|
37
|
+
/** The run-interval state of a live context; undefined for a session on the chart's own bars. */
|
|
38
|
+
export function wrunRunIntervalSessionOf(context) {
|
|
39
|
+
return context === undefined ? undefined : sessions.get(context);
|
|
40
|
+
}
|
|
41
|
+
/** The run interval in ms the overlay's live session computes at, undefined when it computes on
|
|
42
|
+
* the chart's bars (or holds no session): the bucket a rider's rows are floored on. */
|
|
43
|
+
export function wrunLiveRunIntervalMs(indicatorId) {
|
|
44
|
+
return wrunRunIntervalSessionOf(getWrunOverlayLiveContext(indicatorId))?.run.intervalMs;
|
|
45
|
+
}
|
|
46
|
+
/** The identity of the run bars a session holds: the run interval and the chart market they were
|
|
47
|
+
* fetched for (exchange, symbol, transformations), never the chart's own interval. */
|
|
48
|
+
export function wrunRunIntervalCoverageKey(run, market) {
|
|
49
|
+
return [run.interval, market?.exchange, market?.symbol, market?.transformations]
|
|
50
|
+
.map((part) => (part === undefined || part === null ? '' : String(part)))
|
|
51
|
+
.join('|');
|
|
52
|
+
}
|
|
53
|
+
/** The run bars open at or before the chart's newest bar: a frame or an answer may hold the next
|
|
54
|
+
* bucket before the chart shows a bar in it. A bar opens at its stamp, on the session lattice at
|
|
55
|
+
* its session open (a CME trade date is stamped after its own evening bars, and its forming bar
|
|
56
|
+
* passes from that open on). The same array when every row passes. */
|
|
57
|
+
export function wrunRunIntervalRowsThrough(run, rows, lastChartTs) {
|
|
58
|
+
let end = rows.length;
|
|
59
|
+
while (end > 0 && !(runBarSpan(Number(rows[end - 1][0]), run).open <= lastChartTs))
|
|
60
|
+
end -= 1;
|
|
61
|
+
return end === rows.length ? rows : rows.slice(0, end);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The run bars a session computes over at the chart's newest bar. Wait for close on: the closed
|
|
65
|
+
* ones only (a run bar closes once the chart shows a bar at or past its close), so every output the
|
|
66
|
+
* package draws as of its newest bar (a projected cloud, a zone, a label) is the last closed bar's,
|
|
67
|
+
* like its lines on the forming bucket's chart bars; the forming bar stays in the buffer until it
|
|
68
|
+
* closes. Off: the forming bar too (the chart bars of its bucket show it).
|
|
69
|
+
*/
|
|
70
|
+
export function wrunRunIntervalComputeRows(run, rows, lastChartTs) {
|
|
71
|
+
if (!run.waitForClose)
|
|
72
|
+
return wrunRunIntervalRowsThrough(run, rows, lastChartTs);
|
|
73
|
+
let end = rows.length;
|
|
74
|
+
while (end > 0 && !(runBarSpan(Number(rows[end - 1][0]), run).close <= lastChartTs))
|
|
75
|
+
end -= 1;
|
|
76
|
+
return end === rows.length ? rows : rows.slice(0, end);
|
|
77
|
+
}
|
|
78
|
+
/** The input row a session last evaluated as its newest, copied (wrunRunIntervalSession.lastSentRow). */
|
|
79
|
+
export function wrunRunIntervalSentRow(row) {
|
|
80
|
+
return { ts: row.ts, values: Array.from(row.values) };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Which run bars one full run computes over (run-interval-engine.util's planRunIntervalRefresh
|
|
84
|
+
* rule, on the session's buffer): the previous session's run bars when they are the same run
|
|
85
|
+
* interval on the same market (`key`), were asked from at or before the warm-up the chart's first
|
|
86
|
+
* bar needs (`warmupBars` run bars below the run bar holding it), hold the run bar of the chart's
|
|
87
|
+
* newest bar (one still open there: its close past it) and hold no bar stamped past their coverage
|
|
88
|
+
* (the ask windows' end, read on stamps; the intake extends the forming bar it opened at the
|
|
89
|
+
* coverage end; a bar further on, appended after a failed or missed window, may stand past a hole
|
|
90
|
+
* no answer filled); else a fetch from that warm-up start. Without the warm-up term, consecutive
|
|
91
|
+
* prepended pages would erode the warm-up toward zero run bars. Every full run passes here (a lazy
|
|
92
|
+
* page, a settings save, a live rebuild), so a style edit or a pan inside the held warm-up reuses
|
|
93
|
+
* the bars while another timeframe (a new key) or a raised lookback (an earlier start) refetches.
|
|
94
|
+
* The live reconcile right after the run refreshes the newest run bars either way.
|
|
95
|
+
*/
|
|
96
|
+
export function planWrunRunIntervalRows(input) {
|
|
97
|
+
const { run, held } = input;
|
|
98
|
+
const fromTs = runIntervalWarmupStartTs(input.chartFirstTs, run.intervalMs, run.warmupBars);
|
|
99
|
+
if (held === undefined || held.key !== input.key || held.coveredFromTs > fromTs)
|
|
100
|
+
return { fromTs };
|
|
101
|
+
const rows = wrunRunIntervalRowsThrough(run, held.rows, input.chartLastTs);
|
|
102
|
+
const newestTs = rows.length > 0 ? Number(rows[rows.length - 1][0]) : Number.NaN;
|
|
103
|
+
if (!(runBarSpan(newestTs, run).close > input.chartLastTs) || newestTs > held.coveredThroughTs)
|
|
104
|
+
return { fromTs };
|
|
105
|
+
return {
|
|
106
|
+
fromTs: held.coveredFromTs,
|
|
107
|
+
held: rows,
|
|
108
|
+
carry: {
|
|
109
|
+
coveredThroughTs: held.coveredThroughTs,
|
|
110
|
+
...(held.newestTradeStampMs !== undefined ? { newestTradeStampMs: held.newestTradeStampMs } : {}),
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/** The projection a run's integrates pass: its stamp on its chart. */
|
|
115
|
+
export function wrunRunIntervalProjectionOf(run, chartIndex, chartExchange) {
|
|
116
|
+
return {
|
|
117
|
+
runInterval: run,
|
|
118
|
+
chartIndex,
|
|
119
|
+
...(typeof chartExchange === 'string' ? { chartExchange } : {}),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { type OverlayRunInterval } from '../chart/indicator-run-interval.util.js';
|
|
2
|
+
/** The param a twin selects its timeframe with, and the one that says whether to wait for closes. */
|
|
3
|
+
export declare const WRUN_TIMEFRAME_PARAM = "timeframe";
|
|
4
|
+
export declare const WRUN_WAIT_FOR_CLOSE_PARAM = "wait_for_close";
|
|
5
|
+
/** The twins' timeframe option labels by option value (index), the fallback when the overlay's
|
|
6
|
+
* persisted `scriptInputs` carry none. Index 0 is the chart's own interval. */
|
|
7
|
+
export declare const WRUN_TWIN_TIMEFRAME_LABELS: readonly string[];
|
|
8
|
+
/** The option value of the chart path, the value the host forces for a run at another interval. */
|
|
9
|
+
export declare const WRUN_TIMEFRAME_CHART_VALUE = "0";
|
|
10
|
+
type TwinSettings = Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* The proven twins whose `timeframe` runs at its own interval, each with the lookback (in run bars)
|
|
13
|
+
* its current settings need before a value settles: the warm-up is runIntervalWarmupBars of it
|
|
14
|
+
* (max(300, 16 x lookback), capped). Param names are the ports' (WRUN-OFFICIAL-PORTS
|
|
15
|
+
* ports/<name>/src/gen/params.ts at the proven 0.3.0); a cumulative or path-dependent twin (ADL,
|
|
16
|
+
* OBV, PSAR) reads 0, the warm-up floor. The staples' twins (WRUN-PARITY-REST A3, their proven
|
|
17
|
+
* sheets' params) take their built-in's lookback term for term: the declared window inputs where
|
|
18
|
+
* the declaration is right (ATR, CMF, Momentum, ROC, the Awesome Oscillator's longer SMA),
|
|
19
|
+
* NATIVE_RUN_INTERVAL_LOOKBACK_BARS where it misses a term (the offset of Donchian, WMA and VWMA,
|
|
20
|
+
* Hull's outer average, the input the pass does not trace into atr(), wpr() and highestbars(),
|
|
21
|
+
* Keltner's ATR bands, the Stochastic RSI's chain).
|
|
22
|
+
*/
|
|
23
|
+
export declare const WRUN_RUN_INTERVAL_TWINS: Readonly<Record<string, (settings: TwinSettings) => number>>;
|
|
24
|
+
/**
|
|
25
|
+
* The lookback a proven twin's current settings need before a value settles, in bars of the
|
|
26
|
+
* interval it runs at (WRUN_RUN_INTERVAL_TWINS), null for any other overlay (a twin outside the
|
|
27
|
+
* table, an authored Indicator): the run-interval warm-up sizes from it, and a run on the chart's
|
|
28
|
+
* own bars hands it to the warm-up ask as the declared lookback (local-kscript-warmup-backfill-ask.util).
|
|
29
|
+
*/
|
|
30
|
+
export declare function wrunTwinLookbackBars(settings: unknown): number | null;
|
|
31
|
+
/** A wrun overlay's run interval: the kScript shape plus the warm-up its settings need, in run bars. */
|
|
32
|
+
export interface WrunRunInterval extends OverlayRunInterval {
|
|
33
|
+
warmupBars: number;
|
|
34
|
+
}
|
|
35
|
+
export interface WrunRunIntervalInput {
|
|
36
|
+
/** The overlay's settings: params flat under their names, `builtinTwinOf`, `scriptInputs`. */
|
|
37
|
+
settings: unknown;
|
|
38
|
+
/** The chart's interval, as a key ("5m") or milliseconds. */
|
|
39
|
+
chartInterval: unknown;
|
|
40
|
+
/** Market replay keeps the package's own path. */
|
|
41
|
+
replay?: boolean;
|
|
42
|
+
/** An index-mode chart (forex, equities, DEX) keeps the package's own path. */
|
|
43
|
+
indexMode?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* A market whose run bars one candle ask at the chart's venue and symbol cannot reproduce keeps the
|
|
46
|
+
* package's own path: a formula chart (several legs) or a prediction market (event-sparse candles
|
|
47
|
+
* the chart's own request gap-fills). A CME-family venue runs at its interval (its run bars ride
|
|
48
|
+
* the session lattice: OverlayRunInterval.sessionLattice).
|
|
49
|
+
*/
|
|
50
|
+
unsupportedMarket?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** The label of the timeframe option a twin's settings select: through its persisted select's
|
|
53
|
+
* `optionLabels`, else the twins' fixed list. Undefined when unreadable. */
|
|
54
|
+
export declare function wrunTimeframeLabel(settings: unknown): string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Whether a proven twin's Timeframe selects the chart's own interval or a finer one. Such a
|
|
57
|
+
* selection means "chart" for its built-in (timeframeIsChartOrFiner: the engine sees
|
|
58
|
+
* `timeframe: "chart"`, chartIntervalEngineMetadata), so the twin's package must compute its plain
|
|
59
|
+
* chart path too, its Timeframe forced to the chart option in the init args
|
|
60
|
+
* (wrunSettingsForRunInterval): its selected-timeframe branch shows each bar one closed bar late at
|
|
61
|
+
* the chart's interval and refuses (or draws nothing) below it. Read the built-in's way: every
|
|
62
|
+
* proven twin (`builtinTwinOf`), listed in WRUN_RUN_INTERVAL_TWINS or not, on replay, index mode and
|
|
63
|
+
* the unsupported markets alike; an authored Indicator's own `timeframe` param is its author's.
|
|
64
|
+
*/
|
|
65
|
+
export declare function wrunTimeframeIsChartOrFiner(settings: unknown, chartInterval: unknown): boolean;
|
|
66
|
+
/** Whether a twin waits for the selected bar to close (the param defaults on). */
|
|
67
|
+
export declare function wrunWaitsForClose(settings: unknown): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The interval a wrun overlay's package runs at when it is coarser than the chart's, else null (the
|
|
70
|
+
* package runs on the chart's bars, as before): a proven twin listed in WRUN_RUN_INTERVAL_TWINS,
|
|
71
|
+
* off replay, index mode and the markets one candle ask cannot serve (`unsupportedMarket`), whose
|
|
72
|
+
* timeframe selects an interval coarser than the chart. A selection at or below the chart's interval
|
|
73
|
+
* is the chart's own (wrunTimeframeIsChartOrFiner).
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveWrunRunInterval(input: WrunRunIntervalInput): WrunRunInterval | null;
|
|
76
|
+
/** Whether one candle ask at the chart's venue and symbol cannot stand in for the chart's own series
|
|
77
|
+
* (see WrunRunIntervalInput.unsupportedMarket): a formula chart or a prediction market
|
|
78
|
+
* (isRunIntervalUnservableMarket). Unlike the kScript built-ins' predicate
|
|
79
|
+
* (isRunIntervalUnsupportedMarket), a CME-family venue is supported: its run bars are read on the
|
|
80
|
+
* session lattice. */
|
|
81
|
+
export declare function isWrunRunIntervalUnsupportedMarket(exchange: string | undefined, transformations: string | null | undefined): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* The run interval of one mounted wrun overlay: its settings against the chart's interval, venue,
|
|
84
|
+
* series (`chartTransformations`, a formula chart's legs) and replay state. `chartExchange` is the
|
|
85
|
+
* chart's venue; omitted, the overlay's own `settings.exchange` stands in. A venue that rides the CME
|
|
86
|
+
* session lattice (CME, CBOT, NYMEX, COMEX: isCmeSessionLatticeExchange, the rule the chart's own
|
|
87
|
+
* live bars and the run bars' live fold key on) stamps the run `sessionLattice`.
|
|
88
|
+
*/
|
|
89
|
+
export declare function overlayWrunRunInterval(chartIndex: number, overlay: {
|
|
90
|
+
settings?: unknown;
|
|
91
|
+
} | null | undefined, chartInterval: unknown, chartExchange?: string | null, chartTransformations?: string | null): WrunRunInterval | null;
|
|
92
|
+
/**
|
|
93
|
+
* The settings a run at another interval sends the package: the twin's `timeframe` forced to its
|
|
94
|
+
* chart option, on a copy. Only the values the package computes with (the init args); the
|
|
95
|
+
* persisted settings, the dialog, the legend title and the alert arm keep the user's choice.
|
|
96
|
+
*/
|
|
97
|
+
export declare function wrunSettingsForRunInterval<T extends object>(settings: T): T;
|
|
98
|
+
export {};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run interval for the wrun Indicators that stand in for the built-ins (WRUN-HTF-NATIVE-PLAN.md):
|
|
3
|
+
* TradingView's Timeframe model, at the host.
|
|
4
|
+
*
|
|
5
|
+
* A proven twin (`builtinTwinOf`, wrun-builtin-twin.util) carries the built-in's `timeframe`
|
|
6
|
+
* select (option values "0".."7", labels chart, 5m, 15m, 30m, 1h, 4h, 1D, 1W) and, inside the
|
|
7
|
+
* package, rebuilt the selected timeframe from the chart's loaded bars (./sdk/resample), so smoothed
|
|
8
|
+
* values never settled and long windows stayed blank until the user zoomed out. When the selected
|
|
9
|
+
* timeframe is coarser than the chart, the host now runs the package AT that interval instead: on
|
|
10
|
+
* real candles of that interval fetched with a warm-up before the chart's first bar, with the
|
|
11
|
+
* package's own `timeframe` forced to its chart option (the package takes its plain chart path, the
|
|
12
|
+
* resampler never runs), and the run rows are projected onto the chart's bars by the kScript
|
|
13
|
+
* adapter stage (kscript-run-interval-projection.util), exactly as for the kScript built-ins
|
|
14
|
+
* (indicator-run-interval.util). The package and the kit never notice.
|
|
15
|
+
*
|
|
16
|
+
* Read the run interval ONCE per run and carry it on that run's context: the full run, the live
|
|
17
|
+
* ticks, the reseed and the projection must agree on it.
|
|
18
|
+
*
|
|
19
|
+
* A Timeframe at or below the chart's interval is the chart's own for every twin, as for its
|
|
20
|
+
* built-in (wrunTimeframeIsChartOrFiner): the package must compute its plain chart path on the
|
|
21
|
+
* chart's bars, never its selected-timeframe branch.
|
|
22
|
+
*
|
|
23
|
+
* On a CME Group chart the twins run at their interval too, where the kScript built-ins keep their
|
|
24
|
+
* template path (isRunIntervalUnsupportedMarket): the run is stamped `sessionLattice`, so every
|
|
25
|
+
* rule reads a run bar's span on the session calendar (runBarSpan: a 1D bar is its trade date,
|
|
26
|
+
* stamped 00:00Z after its 17:00 Chicago open; a 1W bar its trade-date week; a 4h bar the 17:00
|
|
27
|
+
* lattice) and steps over the session gaps, as the built-in's native higher-timeframe leg does.
|
|
28
|
+
*/
|
|
29
|
+
import { wrunChartHostEnv } from '../../host-env.js';
|
|
30
|
+
import { runIntervalOfTimeframeLabel, timeframeIsChartOrFiner, } from '../chart/indicator-run-interval.util.js';
|
|
31
|
+
import { isCmeSessionLatticeExchange } from '../chart/cme-session-bucket.util.js';
|
|
32
|
+
import { checkIsIndexMode } from '../chart/index-mode.util.js';
|
|
33
|
+
import { isRunIntervalUnservableMarket } from '../chart/run-interval-unservable.leaf.js';
|
|
34
|
+
import { runIntervalWarmupBars } from '../chart/run-interval-warmup.leaf.js';
|
|
35
|
+
import { builtinTwinOf } from './wrun-builtin-twin.util.js';
|
|
36
|
+
/** The param a twin selects its timeframe with, and the one that says whether to wait for closes. */
|
|
37
|
+
export const WRUN_TIMEFRAME_PARAM = 'timeframe';
|
|
38
|
+
export const WRUN_WAIT_FOR_CLOSE_PARAM = 'wait_for_close';
|
|
39
|
+
/** The twins' timeframe option labels by option value (index), the fallback when the overlay's
|
|
40
|
+
* persisted `scriptInputs` carry none. Index 0 is the chart's own interval. */
|
|
41
|
+
export const WRUN_TWIN_TIMEFRAME_LABELS = ['chart', '5m', '15m', '30m', '1h', '4h', '1D', '1W'];
|
|
42
|
+
/** The option value of the chart path, the value the host forces for a run at another interval. */
|
|
43
|
+
export const WRUN_TIMEFRAME_CHART_VALUE = '0';
|
|
44
|
+
function num(value) {
|
|
45
|
+
const parsed = typeof value === 'number' ? value : typeof value === 'string' ? Number(value) : Number.NaN;
|
|
46
|
+
return Number.isFinite(parsed) && parsed > 0 ? Math.ceil(parsed) : 0;
|
|
47
|
+
}
|
|
48
|
+
/** The smoothing MA the oscillator twins chain after their value (`smoothing_type` 0 = None). */
|
|
49
|
+
function smoothing(settings) {
|
|
50
|
+
const type = settings.smoothing_type;
|
|
51
|
+
const off = type === undefined || type === null || type === 0 || type === '0' || type === 'None';
|
|
52
|
+
return off ? 0 : num(settings.smoothing_length);
|
|
53
|
+
}
|
|
54
|
+
/** Keltner's band smoothing, as its built-in's (keltnerBandBars, indicator-run-interval.util): its ATR
|
|
55
|
+
* period on ATR bands (`band_style` 0, the default), nothing more on True Range or Range bands. */
|
|
56
|
+
function keltnerBandBars(settings) {
|
|
57
|
+
const style = settings.band_style;
|
|
58
|
+
const atr = style === undefined || style === null || style === 0 || style === '0';
|
|
59
|
+
return atr ? num(settings.atr_period) : 0;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The proven twins whose `timeframe` runs at its own interval, each with the lookback (in run bars)
|
|
63
|
+
* its current settings need before a value settles: the warm-up is runIntervalWarmupBars of it
|
|
64
|
+
* (max(300, 16 x lookback), capped). Param names are the ports' (WRUN-OFFICIAL-PORTS
|
|
65
|
+
* ports/<name>/src/gen/params.ts at the proven 0.3.0); a cumulative or path-dependent twin (ADL,
|
|
66
|
+
* OBV, PSAR) reads 0, the warm-up floor. The staples' twins (WRUN-PARITY-REST A3, their proven
|
|
67
|
+
* sheets' params) take their built-in's lookback term for term: the declared window inputs where
|
|
68
|
+
* the declaration is right (ATR, CMF, Momentum, ROC, the Awesome Oscillator's longer SMA),
|
|
69
|
+
* NATIVE_RUN_INTERVAL_LOOKBACK_BARS where it misses a term (the offset of Donchian, WMA and VWMA,
|
|
70
|
+
* Hull's outer average, the input the pass does not trace into atr(), wpr() and highestbars(),
|
|
71
|
+
* Keltner's ATR bands, the Stochastic RSI's chain).
|
|
72
|
+
*/
|
|
73
|
+
export const WRUN_RUN_INTERVAL_TWINS = {
|
|
74
|
+
ADL: () => 0,
|
|
75
|
+
ADX: (s) => 2 * num(s.period),
|
|
76
|
+
AO: (s) => Math.max(num(s.fast_length), num(s.slow_length)),
|
|
77
|
+
AROON: (s) => num(s.length) + 1,
|
|
78
|
+
ATR: (s) => num(s.period),
|
|
79
|
+
BOLLINGER_BANDS: (s) => num(s.period),
|
|
80
|
+
CCI: (s) => num(s.period) + smoothing(s),
|
|
81
|
+
CMF: (s) => num(s.length),
|
|
82
|
+
DONCHIAN: (s) => num(s.period) + num(s.offset),
|
|
83
|
+
EMA: (s) => num(s.period),
|
|
84
|
+
HMA: (s) => num(s.period) + Math.round(Math.sqrt(num(s.period))),
|
|
85
|
+
ICHI_CLOUD: (s) => Math.max(num(s.conversion_period), num(s.base_period), num(s.lagging_span_period)) + num(s.displacement),
|
|
86
|
+
KELTNER: (s) => Math.max(num(s.period), keltnerBandBars(s)),
|
|
87
|
+
MACD: (s) => Math.max(num(s.fast_period), num(s.slow_period)) + num(s.signal_period),
|
|
88
|
+
MFI: (s) => num(s.period) + smoothing(s),
|
|
89
|
+
MOMENTUM: (s) => num(s.length),
|
|
90
|
+
OBV: () => 0,
|
|
91
|
+
PSAR: () => 0,
|
|
92
|
+
ROC: (s) => num(s.length),
|
|
93
|
+
RSI: (s) => num(s.period) + smoothing(s),
|
|
94
|
+
SMA: (s) => num(s.period),
|
|
95
|
+
STOCH: (s) => num(s.k_period) + num(s.k_smoothing) + num(s.d_period) + smoothing(s),
|
|
96
|
+
STOCH_RSI: (s) => num(s.rsi_length) + num(s.stoch_length) + num(s.k_smoothing) + num(s.d_smoothing),
|
|
97
|
+
SUPERTREND: (s) => num(s.atr_period),
|
|
98
|
+
VOLUME_BAR: (s) => num(s.ma_length),
|
|
99
|
+
VWMA: (s) => num(s.period) + num(s.offset),
|
|
100
|
+
WILLIAMS_R: (s) => num(s.length),
|
|
101
|
+
WMA: (s) => num(s.period) + num(s.offset),
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* The lookback a proven twin's current settings need before a value settles, in bars of the
|
|
105
|
+
* interval it runs at (WRUN_RUN_INTERVAL_TWINS), null for any other overlay (a twin outside the
|
|
106
|
+
* table, an authored Indicator): the run-interval warm-up sizes from it, and a run on the chart's
|
|
107
|
+
* own bars hands it to the warm-up ask as the declared lookback (local-kscript-warmup-backfill-ask.util).
|
|
108
|
+
*/
|
|
109
|
+
export function wrunTwinLookbackBars(settings) {
|
|
110
|
+
const twin = builtinTwinOf(settings);
|
|
111
|
+
const lookback = twin ? WRUN_RUN_INTERVAL_TWINS[twin] : undefined;
|
|
112
|
+
return lookback ? lookback(settings) : null;
|
|
113
|
+
}
|
|
114
|
+
/** The label of the timeframe option a twin's settings select: through its persisted select's
|
|
115
|
+
* `optionLabels`, else the twins' fixed list. Undefined when unreadable. */
|
|
116
|
+
export function wrunTimeframeLabel(settings) {
|
|
117
|
+
if (!settings || typeof settings !== 'object')
|
|
118
|
+
return undefined;
|
|
119
|
+
const record = settings;
|
|
120
|
+
const value = record[WRUN_TIMEFRAME_PARAM];
|
|
121
|
+
if (value === undefined || value === null)
|
|
122
|
+
return undefined;
|
|
123
|
+
const optionValue = String(value);
|
|
124
|
+
const inputs = Array.isArray(record.scriptInputs) ? record.scriptInputs : [];
|
|
125
|
+
const input = inputs.find((candidate) => !!candidate && typeof candidate === 'object' && candidate.name === WRUN_TIMEFRAME_PARAM);
|
|
126
|
+
if (input && Array.isArray(input.options) && Array.isArray(input.optionLabels)) {
|
|
127
|
+
const index = input.options.map(String).indexOf(optionValue);
|
|
128
|
+
const label = index >= 0 ? input.optionLabels[index] : undefined;
|
|
129
|
+
if (typeof label === 'string')
|
|
130
|
+
return label;
|
|
131
|
+
}
|
|
132
|
+
const index = Number(optionValue);
|
|
133
|
+
return Number.isInteger(index) ? WRUN_TWIN_TIMEFRAME_LABELS[index] : undefined;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Whether a proven twin's Timeframe selects the chart's own interval or a finer one. Such a
|
|
137
|
+
* selection means "chart" for its built-in (timeframeIsChartOrFiner: the engine sees
|
|
138
|
+
* `timeframe: "chart"`, chartIntervalEngineMetadata), so the twin's package must compute its plain
|
|
139
|
+
* chart path too, its Timeframe forced to the chart option in the init args
|
|
140
|
+
* (wrunSettingsForRunInterval): its selected-timeframe branch shows each bar one closed bar late at
|
|
141
|
+
* the chart's interval and refuses (or draws nothing) below it. Read the built-in's way: every
|
|
142
|
+
* proven twin (`builtinTwinOf`), listed in WRUN_RUN_INTERVAL_TWINS or not, on replay, index mode and
|
|
143
|
+
* the unsupported markets alike; an authored Indicator's own `timeframe` param is its author's.
|
|
144
|
+
*/
|
|
145
|
+
export function wrunTimeframeIsChartOrFiner(settings, chartInterval) {
|
|
146
|
+
return builtinTwinOf(settings) !== undefined && timeframeIsChartOrFiner(wrunTimeframeLabel(settings), chartInterval);
|
|
147
|
+
}
|
|
148
|
+
/** Whether a twin waits for the selected bar to close (the param defaults on). */
|
|
149
|
+
export function wrunWaitsForClose(settings) {
|
|
150
|
+
const value = settings && typeof settings === 'object' ? settings[WRUN_WAIT_FOR_CLOSE_PARAM] : undefined;
|
|
151
|
+
return !(value === false || value === 0 || value === '0' || value === 'false');
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The interval a wrun overlay's package runs at when it is coarser than the chart's, else null (the
|
|
155
|
+
* package runs on the chart's bars, as before): a proven twin listed in WRUN_RUN_INTERVAL_TWINS,
|
|
156
|
+
* off replay, index mode and the markets one candle ask cannot serve (`unsupportedMarket`), whose
|
|
157
|
+
* timeframe selects an interval coarser than the chart. A selection at or below the chart's interval
|
|
158
|
+
* is the chart's own (wrunTimeframeIsChartOrFiner).
|
|
159
|
+
*/
|
|
160
|
+
export function resolveWrunRunInterval(input) {
|
|
161
|
+
if (input.replay || input.indexMode || input.unsupportedMarket)
|
|
162
|
+
return null;
|
|
163
|
+
const lookbackBars = wrunTwinLookbackBars(input.settings);
|
|
164
|
+
if (lookbackBars === null)
|
|
165
|
+
return null;
|
|
166
|
+
const run = runIntervalOfTimeframeLabel(wrunTimeframeLabel(input.settings), input.chartInterval);
|
|
167
|
+
if (!run)
|
|
168
|
+
return null;
|
|
169
|
+
return { ...run, waitForClose: wrunWaitsForClose(input.settings), warmupBars: runIntervalWarmupBars(lookbackBars) };
|
|
170
|
+
}
|
|
171
|
+
/** Whether one candle ask at the chart's venue and symbol cannot stand in for the chart's own series
|
|
172
|
+
* (see WrunRunIntervalInput.unsupportedMarket): a formula chart or a prediction market
|
|
173
|
+
* (isRunIntervalUnservableMarket). Unlike the kScript built-ins' predicate
|
|
174
|
+
* (isRunIntervalUnsupportedMarket), a CME-family venue is supported: its run bars are read on the
|
|
175
|
+
* session lattice. */
|
|
176
|
+
export function isWrunRunIntervalUnsupportedMarket(exchange, transformations) {
|
|
177
|
+
return isRunIntervalUnservableMarket(exchange, transformations);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The run interval of one mounted wrun overlay: its settings against the chart's interval, venue,
|
|
181
|
+
* series (`chartTransformations`, a formula chart's legs) and replay state. `chartExchange` is the
|
|
182
|
+
* chart's venue; omitted, the overlay's own `settings.exchange` stands in. A venue that rides the CME
|
|
183
|
+
* session lattice (CME, CBOT, NYMEX, COMEX: isCmeSessionLatticeExchange, the rule the chart's own
|
|
184
|
+
* live bars and the run bars' live fold key on) stamps the run `sessionLattice`.
|
|
185
|
+
*/
|
|
186
|
+
export function overlayWrunRunInterval(chartIndex, overlay, chartInterval, chartExchange, chartTransformations) {
|
|
187
|
+
const settings = overlay?.settings;
|
|
188
|
+
const exchange = chartExchange ?? settings?.exchange;
|
|
189
|
+
const venue = typeof exchange === 'string' ? exchange : undefined;
|
|
190
|
+
const run = resolveWrunRunInterval({
|
|
191
|
+
settings,
|
|
192
|
+
chartInterval,
|
|
193
|
+
// The replay flags are web's (replay/replayFlags.ts `isChartReplaying`, the same Set read at call time).
|
|
194
|
+
replay: wrunChartHostEnv().chart.isReplaying(chartIndex),
|
|
195
|
+
indexMode: checkIsIndexMode(venue),
|
|
196
|
+
unsupportedMarket: isWrunRunIntervalUnsupportedMarket(venue, chartTransformations),
|
|
197
|
+
});
|
|
198
|
+
return run && isCmeSessionLatticeExchange(venue) ? { ...run, sessionLattice: true } : run;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The settings a run at another interval sends the package: the twin's `timeframe` forced to its
|
|
202
|
+
* chart option, on a copy. Only the values the package computes with (the init args); the
|
|
203
|
+
* persisted settings, the dialog, the legend title and the alert arm keep the user's choice.
|
|
204
|
+
*/
|
|
205
|
+
export function wrunSettingsForRunInterval(settings) {
|
|
206
|
+
return { ...settings, [WRUN_TIMEFRAME_PARAM]: WRUN_TIMEFRAME_CHART_VALUE };
|
|
207
|
+
}
|