@orangecharts/wrun-chart-host 0.2.0 → 0.4.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 +22 -8
- package/dist/constants/common.constants.d.ts +15 -0
- package/dist/constants/common.constants.js +23 -0
- package/dist/constants/data-source.constants.d.ts +1 -0
- package/dist/constants/data-source.constants.js +1 -0
- package/dist/constants/economic.constants.d.ts +39 -0
- package/dist/constants/economic.constants.js +77 -0
- package/dist/constants/etf-covered-coins.constants.d.ts +1 -0
- package/dist/constants/etf-covered-coins.constants.js +9 -0
- package/dist/constants/feature-flags.constants.d.ts +60 -0
- package/dist/constants/feature-flags.constants.js +308 -0
- package/dist/constants/feature-limits.constants.d.ts +134 -0
- package/dist/constants/feature-limits.constants.js +155 -0
- package/dist/constants/marketCapabilities.constants.d.ts +87 -0
- package/dist/constants/marketCapabilities.constants.js +213 -0
- package/dist/constants/option-venues.constants.d.ts +100 -0
- package/dist/constants/option-venues.constants.js +167 -0
- package/dist/constants/overlay-data.constants.d.ts +53 -0
- package/dist/constants/overlay-data.constants.js +80 -0
- package/dist/constants/pane-grid.constants.d.ts +15 -0
- package/dist/constants/pane-grid.constants.js +17 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +133 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.js +451 -0
- package/dist/constants/venue-presets.constants.d.ts +10 -0
- package/dist/constants/venue-presets.constants.js +22 -0
- package/dist/enums/chart.enum.d.ts +68 -0
- package/dist/enums/chart.enum.js +70 -0
- package/dist/helpers/data.helpers.d.ts +2 -0
- package/dist/helpers/data.helpers.js +14 -0
- package/dist/host-env.d.ts +163 -5
- package/dist/host-ports.types.d.ts +431 -0
- package/dist/host-ports.types.js +1 -0
- package/dist/index.d.ts +138 -0
- package/dist/index.js +138 -0
- package/dist/indicators/controls/technical-script/technical-script-input-rendering.d.ts +86 -0
- package/dist/indicators/controls/technical-script/technical-script-input-rendering.js +179 -0
- package/dist/interfaces/asset-venue.interface.d.ts +91 -0
- package/dist/interfaces/asset-venue.interface.js +1 -0
- package/dist/interfaces/cancel-reason.interface.d.ts +24 -0
- package/dist/interfaces/cancel-reason.interface.js +2 -0
- package/dist/interfaces/catalog-display.interface.d.ts +3 -0
- package/dist/interfaces/catalog-display.interface.js +1 -0
- package/dist/interfaces/cme-realtime.interface.d.ts +251 -0
- package/dist/interfaces/cme-realtime.interface.js +46 -0
- package/dist/interfaces/feed.interface.d.ts +80 -0
- package/dist/interfaces/feed.interface.js +7 -0
- package/dist/interfaces/market-kind.interface.d.ts +8 -0
- package/dist/interfaces/market-kind.interface.js +1 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +224 -0
- package/dist/interfaces/opra-realtime.interface.js +105 -0
- package/dist/interfaces/option-instrument.interface.d.ts +32 -0
- package/dist/interfaces/option-instrument.interface.js +1 -0
- package/dist/interfaces/options-chain-scope.interface.d.ts +29 -0
- package/dist/interfaces/options-chain-scope.interface.js +7 -0
- package/dist/interfaces/prediction-market.interface.d.ts +88 -0
- package/dist/interfaces/prediction-market.interface.js +8 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +5 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +185 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +357 -0
- package/dist/settings-templates/frvp-fields.d.ts +27 -0
- package/dist/settings-templates/frvp-fields.js +108 -0
- package/dist/settings-templates/index.d.ts +119 -0
- package/dist/settings-templates/index.js +442 -0
- package/dist/settings-templates/indicator-fields.d.ts +56 -0
- package/dist/settings-templates/indicator-fields.js +793 -0
- package/dist/settings-templates/tool-rules.d.ts +59 -0
- package/dist/settings-templates/tool-rules.js +49 -0
- package/dist/settings-templates/tool-tables.generated.d.ts +2 -0
- package/dist/settings-templates/tool-tables.generated.js +1668 -0
- package/dist/utility/blk-market.util.d.ts +5 -0
- package/dist/utility/blk-market.util.js +12 -0
- package/dist/utility/chart/chart-load-phase.util.d.ts +32 -0
- package/dist/utility/chart/chart-load-phase.util.js +78 -0
- package/dist/utility/chart/cme-cache-context.util.d.ts +108 -0
- package/dist/utility/chart/cme-cache-context.util.js +166 -0
- package/dist/utility/chart/cme-session-bucket.util.d.ts +82 -0
- package/dist/utility/chart/cme-session-bucket.util.js +343 -0
- package/dist/utility/chart/cme-trade-calendar.util.d.ts +26 -0
- package/dist/utility/chart/cme-trade-calendar.util.js +147 -0
- package/dist/utility/chart/continuous-contracts.util.d.ts +138 -0
- package/dist/utility/chart/continuous-contracts.util.js +374 -0
- package/dist/utility/chart/date-labelled-interval.leaf.d.ts +15 -0
- package/dist/utility/chart/date-labelled-interval.leaf.js +19 -0
- package/dist/utility/chart/feed-interval.util.d.ts +119 -0
- package/dist/utility/chart/feed-interval.util.js +321 -0
- package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +110 -0
- package/dist/utility/chart/fetch-dedupe-policy.util.js +407 -0
- package/dist/utility/chart/footprint-band.util.d.ts +76 -0
- package/dist/utility/chart/footprint-band.util.js +205 -0
- package/dist/utility/chart/footprint-cell-identity.util.d.ts +82 -0
- package/dist/utility/chart/footprint-cell-identity.util.js +346 -0
- package/dist/utility/chart/formula-calendar.util.d.ts +27 -0
- package/dist/utility/chart/formula-calendar.util.js +59 -0
- package/dist/utility/chart/history-wall.util.d.ts +67 -0
- package/dist/utility/chart/history-wall.util.js +87 -0
- package/dist/utility/chart/index-mode.util.d.ts +66 -0
- package/dist/utility/chart/index-mode.util.js +360 -0
- package/dist/utility/chart/indicator-coverage-planner.util.d.ts +217 -0
- package/dist/utility/chart/indicator-coverage-planner.util.js +443 -0
- package/dist/utility/chart/indicator-coverage-state.util.d.ts +33 -0
- package/dist/utility/chart/indicator-coverage-state.util.js +110 -0
- package/dist/utility/chart/indicator-gap-detector.util.d.ts +127 -0
- package/dist/utility/chart/indicator-gap-detector.util.js +260 -0
- package/dist/utility/chart/indicator-gap-repair.util.d.ts +88 -0
- package/dist/utility/chart/indicator-gap-repair.util.js +177 -0
- package/dist/utility/chart/indicator-inflight-registry.util.d.ts +26 -0
- package/dist/utility/chart/indicator-inflight-registry.util.js +254 -0
- package/dist/utility/chart/indicator-run-interval.util.d.ts +130 -0
- package/dist/utility/chart/indicator-run-interval.util.js +268 -0
- package/dist/utility/chart/interval-registry.util.d.ts +23 -0
- package/dist/utility/chart/interval-registry.util.js +83 -0
- package/dist/utility/chart/kscript-main-grid-stages.util.d.ts +21 -0
- package/dist/utility/chart/kscript-main-grid-stages.util.js +332 -0
- package/dist/utility/chart/legacy-exchange.leaf.d.ts +11 -0
- package/dist/utility/chart/legacy-exchange.leaf.js +43 -0
- package/dist/utility/chart/live-bucket.util.d.ts +66 -0
- package/dist/utility/chart/live-bucket.util.js +165 -0
- package/dist/utility/chart/market-session-schedule.util.d.ts +91 -0
- package/dist/utility/chart/market-session-schedule.util.js +337 -0
- package/dist/utility/chart/marketKind.util.d.ts +181 -0
- package/dist/utility/chart/marketKind.util.js +371 -0
- package/dist/utility/chart/opra-read-access.leaf.d.ts +26 -0
- package/dist/utility/chart/opra-read-access.leaf.js +25 -0
- package/dist/utility/chart/prediction-identity.util.d.ts +159 -0
- package/dist/utility/chart/prediction-identity.util.js +236 -0
- package/dist/utility/chart/rth-session.util.d.ts +352 -0
- package/dist/utility/chart/rth-session.util.js +926 -0
- package/dist/utility/chart/titan-constants.pin.d.ts +43 -0
- package/dist/utility/chart/titan-constants.pin.js +50 -0
- package/dist/utility/chart/us-equities-session.util.d.ts +127 -0
- package/dist/utility/chart/us-equities-session.util.js +251 -0
- package/dist/utility/chart/window-geometry.leaf.d.ts +119 -0
- package/dist/utility/chart/window-geometry.leaf.js +391 -0
- package/dist/utility/chart/window-owner.leaf.d.ts +19 -0
- package/dist/utility/chart/window-owner.leaf.js +24 -0
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +100 -0
- package/dist/utility/chart/wrun-bar-session-facts.util.js +354 -0
- package/dist/utility/chart/wrun-wire-ref.util.d.ts +23 -0
- package/dist/utility/chart/wrun-wire-ref.util.js +16 -0
- package/dist/utility/common/safe-math-eval.d.ts +18 -0
- package/dist/utility/common/safe-math-eval.js +160 -0
- package/dist/utility/common/time.util.d.ts +134 -0
- package/dist/utility/common/time.util.js +428 -0
- package/dist/utility/common/transformations.util.d.ts +126 -0
- package/dist/utility/common/transformations.util.js +711 -0
- package/dist/utility/common/visible-timeout.util.d.ts +17 -0
- package/dist/utility/common/visible-timeout.util.js +75 -0
- package/dist/utility/exchange-normalization.util.d.ts +8 -0
- package/dist/utility/exchange-normalization.util.js +32 -0
- package/dist/utility/html-escape.leaf.d.ts +11 -0
- package/dist/utility/html-escape.leaf.js +20 -0
- package/dist/utility/intl-locale.util.d.ts +2 -0
- package/dist/utility/intl-locale.util.js +28 -0
- package/dist/utility/number-format.util.d.ts +14 -1
- package/dist/utility/number-format.util.js +50 -19
- package/dist/utility/options/option-symbol.util.d.ts +28 -0
- package/dist/utility/options/option-symbol.util.js +176 -0
- package/dist/utility/options/option-trade-units.util.d.ts +190 -0
- package/dist/utility/options/option-trade-units.util.js +283 -0
- package/dist/utility/options/option-venue.util.d.ts +75 -0
- package/dist/utility/options/option-venue.util.js +85 -0
- package/dist/utility/pool-symbol.leaf.d.ts +34 -0
- package/dist/utility/pool-symbol.leaf.js +95 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +109 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +302 -0
- package/dist/utility/symbol-selection/contract-expiry.util.d.ts +39 -0
- package/dist/utility/symbol-selection/contract-expiry.util.js +111 -0
- package/dist/utility/v2/gate-plane.util.d.ts +58 -0
- package/dist/utility/v2/gate-plane.util.js +99 -0
- package/dist/utility/v2/gate-session-latch.util.d.ts +22 -0
- package/dist/utility/v2/gate-session-latch.util.js +34 -0
- package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +76 -0
- package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +221 -0
- package/dist/utility/wrun/sources/host-grid-landing.d.ts +15 -0
- package/dist/utility/wrun/sources/host-grid-landing.js +26 -0
- package/dist/utility/wrun/sources/lanes/bitfinex_funding.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/bitfinex_funding.js +85 -0
- package/dist/utility/wrun/sources/lanes/economic.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/economic.js +79 -0
- package/dist/utility/wrun/sources/lanes/etf_holdings.d.ts +35 -0
- package/dist/utility/wrun/sources/lanes/etf_holdings.js +165 -0
- package/dist/utility/wrun/sources/lanes/etf_premium.d.ts +19 -0
- package/dist/utility/wrun/sources/lanes/etf_premium.js +114 -0
- package/dist/utility/wrun/sources/lanes/ethena_positions.d.ts +30 -0
- package/dist/utility/wrun/sources/lanes/ethena_positions.js +51 -0
- package/dist/utility/wrun/sources/lanes/index.d.ts +2 -0
- package/dist/utility/wrun/sources/lanes/index.js +32 -0
- package/dist/utility/wrun/sources/lanes/long_short_ratio.d.ts +17 -0
- package/dist/utility/wrun/sources/lanes/long_short_ratio.js +47 -0
- package/dist/utility/wrun/sources/lanes/option_daily.d.ts +58 -0
- package/dist/utility/wrun/sources/lanes/option_daily.js +111 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.js +21 -0
- package/dist/utility/wrun/sources/lanes/options_flow.d.ts +50 -0
- package/dist/utility/wrun/sources/lanes/options_flow.js +155 -0
- package/dist/utility/wrun/sources/lanes/options_oi.d.ts +29 -0
- package/dist/utility/wrun/sources/lanes/options_oi.js +59 -0
- package/dist/utility/wrun/sources/lanes/options_volume.d.ts +38 -0
- package/dist/utility/wrun/sources/lanes/options_volume.js +63 -0
- package/dist/utility/wrun/sources/lanes/series.d.ts +67 -0
- package/dist/utility/wrun/sources/lanes/series.js +321 -0
- package/dist/utility/wrun/sources/lanes/token_supply.d.ts +30 -0
- package/dist/utility/wrun/sources/lanes/token_supply.js +145 -0
- package/dist/utility/wrun/sources/lanes/treasury_balance.d.ts +25 -0
- package/dist/utility/wrun/sources/lanes/treasury_balance.js +47 -0
- package/dist/utility/wrun/sources/lanes/volatility_index.d.ts +21 -0
- package/dist/utility/wrun/sources/lanes/volatility_index.js +11 -0
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +215 -0
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +477 -0
- package/dist/utility/wrun/sources/registry.d.ts +21 -0
- package/dist/utility/wrun/sources/registry.js +237 -0
- package/dist/utility/wrun/sources/row-lane-registry.d.ts +28 -0
- package/dist/utility/wrun/sources/row-lane-registry.js +230 -0
- package/dist/utility/wrun/sources/row-lanes/index.d.ts +2 -0
- package/dist/utility/wrun/sources/row-lanes/index.js +12 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +2 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +38 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +55 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +126 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +4 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +191 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +62 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +147 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +70 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +144 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +309 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.js +26 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +350 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +576 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +275 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.js +16 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +207 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +450 -0
- package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +28 -0
- package/dist/utility/wrun/wrun-browser-sources.leaf.js +66 -0
- package/dist/utility/wrun/wrun-cloud-record.util.d.ts +65 -0
- package/dist/utility/wrun/wrun-cloud-record.util.js +121 -0
- package/dist/utility/wrun/wrun-daily-lane.util.d.ts +95 -0
- package/dist/utility/wrun/wrun-daily-lane.util.js +297 -0
- package/dist/utility/wrun/wrun-deadline.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-deadline.util.js +82 -0
- package/dist/utility/wrun/wrun-etf-flow-lane.util.d.ts +94 -0
- package/dist/utility/wrun/wrun-etf-flow-lane.util.js +224 -0
- package/dist/utility/wrun/wrun-etf-funds.util.d.ts +82 -0
- package/dist/utility/wrun/wrun-etf-funds.util.js +242 -0
- package/dist/utility/wrun/wrun-frames.d.ts +20 -1
- package/dist/utility/wrun/wrun-frames.js +103 -49
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +27 -0
- package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +22 -0
- package/dist/utility/wrun/wrun-lane-refusal.leaf.js +32 -0
- package/dist/utility/wrun/wrun-lane-warmup.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-lane-warmup.util.js +112 -0
- package/dist/utility/wrun/wrun-leg-close.util.d.ts +57 -0
- package/dist/utility/wrun/wrun-leg-close.util.js +187 -0
- package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +144 -0
- package/dist/utility/wrun/wrun-leg-fetch.util.js +212 -0
- package/dist/utility/wrun/wrun-leg-stream-classes.d.ts +73 -0
- package/dist/utility/wrun/wrun-leg-stream-classes.js +86 -0
- package/dist/utility/wrun/wrun-levels-child.util.d.ts +101 -6
- package/dist/utility/wrun/wrun-levels-child.util.js +335 -157
- package/dist/utility/wrun/wrun-memory-clamp.util.d.ts +33 -0
- package/dist/utility/wrun/wrun-memory-clamp.util.js +146 -0
- package/dist/utility/wrun/wrun-odds-template-market.util.d.ts +51 -0
- package/dist/utility/wrun/wrun-odds-template-market.util.js +251 -0
- package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +65 -0
- package/dist/utility/wrun/wrun-opra-flow.leaf.js +94 -0
- package/dist/utility/wrun/wrun-opra-lane.util.d.ts +47 -0
- package/dist/utility/wrun/wrun-opra-lane.util.js +58 -0
- package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +49 -0
- package/dist/utility/wrun/wrun-opra-stats.leaf.js +115 -0
- package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +12 -0
- package/dist/utility/wrun/wrun-opra-underlying.util.js +1 -0
- package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +142 -0
- package/dist/utility/wrun/wrun-option-contract-flow.util.js +451 -0
- package/dist/utility/wrun/wrun-option-knobs.util.d.ts +43 -0
- package/dist/utility/wrun/wrun-option-knobs.util.js +81 -0
- package/dist/utility/wrun/wrun-option-prints.util.d.ts +144 -0
- package/dist/utility/wrun/wrun-option-prints.util.js +356 -0
- package/dist/utility/wrun/wrun-option-summary-lane.util.d.ts +102 -0
- package/dist/utility/wrun/wrun-option-summary-lane.util.js +143 -0
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +308 -0
- package/dist/utility/wrun/wrun-options-chain.util.js +502 -0
- package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +9 -4
- package/dist/utility/wrun/wrun-overlay-identity.util.js +16 -6
- package/dist/utility/wrun/wrun-panel-mount.lazy.d.ts +10 -0
- package/dist/utility/wrun/wrun-panel-mount.lazy.js +68 -0
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +377 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +2251 -0
- package/dist/utility/wrun/wrun-param-map.util.d.ts +298 -0
- package/dist/utility/wrun/wrun-param-map.util.js +581 -0
- package/dist/utility/wrun/wrun-pause-dim.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-pause-dim.util.js +153 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +149 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.js +523 -0
- package/dist/utility/wrun/wrun-pin-venues.util.d.ts +116 -0
- package/dist/utility/wrun/wrun-pin-venues.util.js +320 -0
- package/dist/utility/wrun/wrun-pinned-interval.util.d.ts +20 -0
- package/dist/utility/wrun/wrun-pinned-interval.util.js +47 -0
- package/dist/utility/wrun/wrun-plot-gate.types.d.ts +23 -0
- package/dist/utility/wrun/wrun-plot-gate.types.js +7 -0
- package/dist/utility/wrun/wrun-present-bits.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-present-bits.util.js +73 -0
- package/dist/utility/wrun/wrun-protocol-pending.util.d.ts +33 -0
- package/dist/utility/wrun/wrun-protocol-pending.util.js +57 -0
- package/dist/utility/wrun/wrun-refusal.util.d.ts +41 -1
- package/dist/utility/wrun/wrun-refusal.util.js +69 -2
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +1 -14
- package/dist/utility/wrun/wrun-registry-errors.util.js +0 -16
- package/dist/utility/wrun/wrun-row-source.d.ts +158 -0
- package/dist/utility/wrun/wrun-row-source.js +75 -0
- package/dist/utility/wrun/wrun-run-health.util.d.ts +155 -0
- package/dist/utility/wrun/wrun-run-health.util.js +273 -0
- package/dist/utility/wrun/wrun-run-interval-projection.types.d.ts +14 -0
- package/dist/utility/wrun/wrun-run-interval-projection.types.js +1 -0
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +439 -0
- package/dist/utility/wrun/wrun-socket-row-source.js +1689 -0
- package/dist/utility/wrun/wrun-socket-session-losses.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-socket-session-losses.util.js +25 -0
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +911 -0
- package/dist/utility/wrun/wrun-source-rows.util.js +2597 -0
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +82 -0
- package/dist/utility/wrun/wrun-tape-source.util.js +151 -0
- package/dist/utility/wrun/wrun-tier-grid.util.d.ts +137 -0
- package/dist/utility/wrun/wrun-tier-grid.util.js +279 -0
- package/dist/utility/wrun/wrun-trades-lane.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-trades-lane.util.js +58 -0
- package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +41 -0
- package/dist/utility/wrun/wrun-volume-profile-lane.util.js +66 -0
- package/dist/utility/wrun-display-name.util.d.ts +33 -0
- package/dist/utility/wrun-display-name.util.js +64 -0
- package/dist/workers/constants/kscript-transport-codes.d.ts +15 -0
- package/dist/workers/constants/kscript-transport-codes.js +15 -0
- package/dist/workers/constants/socket-slots.d.ts +574 -0
- package/dist/workers/constants/socket-slots.js +539 -0
- package/dist/workers/utils/number.worker.util.d.ts +5 -0
- package/dist/workers/utils/number.worker.util.js +10 -0
- package/dist/workers/utils/time.worker.util.d.ts +12 -0
- package/dist/workers/utils/time.worker.util.js +24 -0
- package/dist/workers/utils/volume-profile.worker.util.d.ts +200 -0
- package/dist/workers/utils/volume-profile.worker.util.js +631 -0
- package/package.json +10 -4
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { MIN_ROWS_FOR_MEDIAN } from './indicator-gap-detector.util.js';
|
|
2
|
+
const INDICATOR_GAP_REPAIR_TYPES = new Set([
|
|
3
|
+
'AGGREGATED_CUMULATIVE_VOLUME_DELTA',
|
|
4
|
+
'AGGREGATED_FUNDING_RATE',
|
|
5
|
+
'AGGREGATED_OPEN_INTEREST',
|
|
6
|
+
'CUMULATIVE_VOLUME_DELTA',
|
|
7
|
+
// 2026-07-27 incident: excluded here (and from the recovery allowlist), a
|
|
8
|
+
// pan-back CVD_BY_SIZE hole was never scanned after the waves settled and
|
|
9
|
+
// rendered as a flat bridge; see INDICATOR_GAP_RECOVERY_ALLOWLIST.
|
|
10
|
+
'CVD_BY_SIZE',
|
|
11
|
+
// 2026-07-27 QA report, same chunks-missing class as CVD_BY_SIZE: pan-back
|
|
12
|
+
// CVD_FLOW_DOMINANCE holes were never scanned after the waves settled
|
|
13
|
+
// because the type was in neither self-heal set; see
|
|
14
|
+
// INDICATOR_GAP_RECOVERY_ALLOWLIST for the full rationale (including why it
|
|
15
|
+
// stays out of the render allowlist).
|
|
16
|
+
'CVD_FLOW_DOMINANCE',
|
|
17
|
+
'FUNDING_RATE',
|
|
18
|
+
'LONG_SHORT_RATIO',
|
|
19
|
+
'OPEN_INTEREST',
|
|
20
|
+
'ORDERBOOK_DEPTH',
|
|
21
|
+
'SECTOR_FUNDING_RATE',
|
|
22
|
+
'SECTOR_OPEN_INTEREST',
|
|
23
|
+
'VOLUME_DELTA',
|
|
24
|
+
]);
|
|
25
|
+
const GAP_THRESHOLD_MULTIPLIER = 1.5;
|
|
26
|
+
const VIEWPORT_REPAIR_PADDING_MULTIPLIER = 1;
|
|
27
|
+
const VIEWPORT_REPAIR_MIN_PADDING_BARS = 500;
|
|
28
|
+
export function isIndicatorGapRepairType(indicatorType) {
|
|
29
|
+
return !!indicatorType && INDICATOR_GAP_REPAIR_TYPES.has(indicatorType);
|
|
30
|
+
}
|
|
31
|
+
function uniqueSortedRowsInRange(rows, fromMs, toMs) {
|
|
32
|
+
if (!rows?.length)
|
|
33
|
+
return [];
|
|
34
|
+
const sorted = rows
|
|
35
|
+
.filter((row) => Array.isArray(row) && Number.isFinite(row[0]) && row[0] >= fromMs && row[0] <= toMs)
|
|
36
|
+
.sort((a, b) => a[0] - b[0]);
|
|
37
|
+
const unique = [];
|
|
38
|
+
let lastTs;
|
|
39
|
+
for (const row of sorted) {
|
|
40
|
+
if (row[0] === lastTs)
|
|
41
|
+
continue;
|
|
42
|
+
unique.push(row);
|
|
43
|
+
lastTs = row[0];
|
|
44
|
+
}
|
|
45
|
+
return unique;
|
|
46
|
+
}
|
|
47
|
+
function median(values) {
|
|
48
|
+
if (!values.length)
|
|
49
|
+
return undefined;
|
|
50
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
51
|
+
const middle = Math.floor(sorted.length / 2);
|
|
52
|
+
return sorted.length % 2 === 0 ? (sorted[middle - 1] + sorted[middle]) / 2 : sorted[middle];
|
|
53
|
+
}
|
|
54
|
+
function hasMainBarsBetween(mainRows, fromMs, toMs) {
|
|
55
|
+
return mainRows.some((row) => row[0] > fromMs && row[0] < toMs);
|
|
56
|
+
}
|
|
57
|
+
function pushGap(gaps, mainRows, fromMs, toMs, thresholdMs) {
|
|
58
|
+
if (toMs - fromMs <= thresholdMs)
|
|
59
|
+
return;
|
|
60
|
+
if (!hasMainBarsBetween(mainRows, fromMs, toMs))
|
|
61
|
+
return;
|
|
62
|
+
gaps.push({ fromMs, toMs });
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Find indicator holes that are inconsistent with both the loaded main series
|
|
66
|
+
* and the indicator's own cadence. Funding-like indicators can naturally be
|
|
67
|
+
* sparse on a 1h chart, so the threshold is based on the overlay median delta
|
|
68
|
+
* when enough rows exist, with the chart interval as the fallback.
|
|
69
|
+
*/
|
|
70
|
+
export function findIndicatorDataGaps(indicatorRows, mainRows, intervalMs) {
|
|
71
|
+
if (!mainRows?.length || mainRows.length < 2 || intervalMs <= 0)
|
|
72
|
+
return [];
|
|
73
|
+
const sortedMainRows = uniqueSortedRowsInRange(mainRows, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY);
|
|
74
|
+
if (sortedMainRows.length < 2)
|
|
75
|
+
return [];
|
|
76
|
+
const mainStartMs = sortedMainRows[0][0];
|
|
77
|
+
const mainEndMs = sortedMainRows[sortedMainRows.length - 1][0];
|
|
78
|
+
if (mainEndMs <= mainStartMs)
|
|
79
|
+
return [];
|
|
80
|
+
const sortedIndicatorRows = uniqueSortedRowsInRange(indicatorRows, mainStartMs, mainEndMs);
|
|
81
|
+
if (sortedIndicatorRows.length === 0) {
|
|
82
|
+
return [{ fromMs: mainStartMs, toMs: mainEndMs }];
|
|
83
|
+
}
|
|
84
|
+
const deltas = [];
|
|
85
|
+
for (let i = 1; i < sortedIndicatorRows.length; i++) {
|
|
86
|
+
const delta = sortedIndicatorRows[i][0] - sortedIndicatorRows[i - 1][0];
|
|
87
|
+
if (delta > 0)
|
|
88
|
+
deltas.push(delta);
|
|
89
|
+
}
|
|
90
|
+
const medianDelta = median(deltas);
|
|
91
|
+
const cadenceMs = Math.max(intervalMs, medianDelta ?? intervalMs);
|
|
92
|
+
const thresholdMs = cadenceMs * GAP_THRESHOLD_MULTIPLIER;
|
|
93
|
+
const gaps = [];
|
|
94
|
+
pushGap(gaps, sortedMainRows, mainStartMs, sortedIndicatorRows[0][0], thresholdMs);
|
|
95
|
+
for (let i = 1; i < sortedIndicatorRows.length; i++) {
|
|
96
|
+
pushGap(gaps, sortedMainRows, sortedIndicatorRows[i - 1][0], sortedIndicatorRows[i][0], thresholdMs);
|
|
97
|
+
}
|
|
98
|
+
pushGap(gaps, sortedMainRows, sortedIndicatorRows[sortedIndicatorRows.length - 1][0], mainEndMs, thresholdMs);
|
|
99
|
+
return gaps;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Range-independent half of the covered-repair verdict: the series-sized
|
|
103
|
+
* sorts and the detector run happen ONCE per (overlayRows, mainRows)
|
|
104
|
+
* snapshot; `coveredRepairRangeVouched` then answers per range in O(gaps).
|
|
105
|
+
* Returns null whenever the detector cannot judge (the guard's fail-open
|
|
106
|
+
* classes), so callers fail open exactly as before.
|
|
107
|
+
*/
|
|
108
|
+
export function prepareCoveredRepairRangeVerdict(input) {
|
|
109
|
+
const { overlayRows, mainRows, intervalMs } = input;
|
|
110
|
+
if (!(intervalMs > 0))
|
|
111
|
+
return null;
|
|
112
|
+
if (!overlayRows?.length)
|
|
113
|
+
return null;
|
|
114
|
+
if (!mainRows || mainRows.length < 2)
|
|
115
|
+
return null;
|
|
116
|
+
const mainFirstTs = mainRows[0]?.[0];
|
|
117
|
+
const mainLastTs = mainRows[mainRows.length - 1]?.[0];
|
|
118
|
+
if (!Number.isFinite(mainFirstTs) || !Number.isFinite(mainLastTs))
|
|
119
|
+
return null;
|
|
120
|
+
if (uniqueSortedRowsInRange(overlayRows, mainFirstTs, mainLastTs).length < MIN_ROWS_FOR_MEDIAN)
|
|
121
|
+
return null;
|
|
122
|
+
return {
|
|
123
|
+
mainFirstTs: mainFirstTs,
|
|
124
|
+
mainLastTs: mainLastTs,
|
|
125
|
+
gaps: findIndicatorDataGaps(overlayRows, mainRows, intervalMs),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Per-range half: bounds inside the judged main span AND no detected gap
|
|
130
|
+
* intersecting. A range reaching outside the loaded main span fails open
|
|
131
|
+
* (a cluster-scan history extension wants rows the chart does not hold yet)
|
|
132
|
+
* UNLESS `clampToMainSpan`: an overlay whose apply keeps only rows with a
|
|
133
|
+
* main bar (the reconcile coverage class `depth`) can never be covered
|
|
134
|
+
* outside the main span, so the judged range is cut to it and the part
|
|
135
|
+
* outside counts as served by construction. Without the clamp the
|
|
136
|
+
* planner's bucket-floored head chunk (2026-09-18 dump: 143 bars older than
|
|
137
|
+
* the chart's first candle) was re-bought and re-committed on every
|
|
138
|
+
* gap-recovery round until the attempt cap, each commit repainting the pane.
|
|
139
|
+
*/
|
|
140
|
+
export function coveredRepairRangeVouched(prep, fromSec, periodSec, options = {}) {
|
|
141
|
+
if (!(fromSec > 0) || !(periodSec > 0))
|
|
142
|
+
return false;
|
|
143
|
+
let fromMs = fromSec * 1000;
|
|
144
|
+
let toMs = (fromSec + periodSec) * 1000;
|
|
145
|
+
if (options.clampToMainSpan === true) {
|
|
146
|
+
fromMs = Math.max(fromMs, prep.mainFirstTs);
|
|
147
|
+
toMs = Math.min(toMs, prep.mainLastTs);
|
|
148
|
+
if (fromMs >= toMs)
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
if (fromMs < prep.mainFirstTs || toMs > prep.mainLastTs)
|
|
152
|
+
return false;
|
|
153
|
+
return !prep.gaps.some((gap) => gap.fromMs < toMs && gap.toMs > fromMs);
|
|
154
|
+
}
|
|
155
|
+
export function shouldSkipCoveredRepairRangeFetch(input) {
|
|
156
|
+
const prep = prepareCoveredRepairRangeVerdict(input);
|
|
157
|
+
if (!prep)
|
|
158
|
+
return false;
|
|
159
|
+
return coveredRepairRangeVouched(prep, input.fromSec, input.periodSec, { clampToMainSpan: input.clampToMainSpan });
|
|
160
|
+
}
|
|
161
|
+
export function clampIndicatorGapToViewportCushion(gap, viewportStartMs, viewportEndMs, intervalMs) {
|
|
162
|
+
if (!Number.isFinite(gap.fromMs) ||
|
|
163
|
+
!Number.isFinite(gap.toMs) ||
|
|
164
|
+
!Number.isFinite(viewportStartMs) ||
|
|
165
|
+
!Number.isFinite(viewportEndMs) ||
|
|
166
|
+
!Number.isFinite(intervalMs) ||
|
|
167
|
+
gap.fromMs >= gap.toMs ||
|
|
168
|
+
viewportStartMs >= viewportEndMs ||
|
|
169
|
+
intervalMs <= 0) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
const viewportSpanMs = viewportEndMs - viewportStartMs;
|
|
173
|
+
const paddingMs = Math.max(viewportSpanMs * VIEWPORT_REPAIR_PADDING_MULTIPLIER, intervalMs * VIEWPORT_REPAIR_MIN_PADDING_BARS);
|
|
174
|
+
const fromMs = Math.max(gap.fromMs, viewportStartMs - paddingMs);
|
|
175
|
+
const toMs = Math.min(gap.toMs, viewportEndMs + paddingMs);
|
|
176
|
+
return fromMs < toMs ? { fromMs, toMs } : null;
|
|
177
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type IndicatorInflightProfile = 'protected' | 'plain';
|
|
2
|
+
export interface IndicatorInflightRange {
|
|
3
|
+
startMs: number;
|
|
4
|
+
endMs: number;
|
|
5
|
+
}
|
|
6
|
+
export type IndicatorInflightRunner = (range: IndicatorInflightRange) => Promise<unknown> | unknown;
|
|
7
|
+
export type IndicatorInflightScheduleStatus = 'ignored-invalid' | 'scheduled' | 'updated-pending' | 'started-max-defer' | 'covered-by-inflight' | 'queued-after-inflight';
|
|
8
|
+
export interface IndicatorInflightScheduleResult {
|
|
9
|
+
key: string;
|
|
10
|
+
status: IndicatorInflightScheduleStatus;
|
|
11
|
+
range: IndicatorInflightRange;
|
|
12
|
+
inFlightRange?: IndicatorInflightRange;
|
|
13
|
+
/** Settles when this request's range has been covered (see module doc). */
|
|
14
|
+
completion: Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export interface IndicatorInflightScheduleOptions {
|
|
17
|
+
profile?: IndicatorInflightProfile;
|
|
18
|
+
settleMs?: number;
|
|
19
|
+
maxDeferMs?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function __setIndicatorInflightClockForTests(fn: (() => number) | null): void;
|
|
22
|
+
export declare function scheduleIndicatorInflightFetch(chartIndex: number, overlayId: string, range: IndicatorInflightRange, runner: IndicatorInflightRunner, options?: IndicatorInflightScheduleOptions): IndicatorInflightScheduleResult;
|
|
23
|
+
export declare function hasPendingIndicatorInflight(chartIndex?: number, profile?: IndicatorInflightProfile): boolean;
|
|
24
|
+
export declare function clearIndicatorInflight(chartIndex: number, overlayId?: string, profile?: IndicatorInflightProfile): void;
|
|
25
|
+
export declare function clearAllIndicatorInflight(profile?: IndicatorInflightProfile): void;
|
|
26
|
+
export declare function __getPendingIndicatorInflightCountForTests(profile?: IndicatorInflightProfile): number;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ONE in-flight range registry for indicator history fetches (fan-out
|
|
3
|
+
* unification P2). The mechanism is the protected kScript lazy-refetch
|
|
4
|
+
* scheduler's, generalized: per-overlay single flight with settle/max-defer
|
|
5
|
+
* timers, union-not-replace coalescing, covered-by-inflight dedupe, and
|
|
6
|
+
* re-arm when a completed run does not contain the ranges queued behind it.
|
|
7
|
+
* protected-kscript-lazy-refetch.util.ts remains as a thin profile shim so
|
|
8
|
+
* its status golden and its call sites are unchanged.
|
|
9
|
+
*
|
|
10
|
+
* Profiles:
|
|
11
|
+
* - 'protected': settle 600 / max-defer 3000 (unchanged timing); entries
|
|
12
|
+
* participate in chart load-phase tracking (boot spinners wait on them).
|
|
13
|
+
* - 'plain': settle 0 / max-defer 0, i.e. the runner starts immediately when
|
|
14
|
+
* the overlay is idle; the registry only removes concurrent same-overlay
|
|
15
|
+
* duplicates. Plain entries are INVISIBLE to load-phase tracking.
|
|
16
|
+
*
|
|
17
|
+
* Completion: schedule() also returns a promise that settles when the
|
|
18
|
+
* requested range has been covered by a finished run (the current one for
|
|
19
|
+
* covered-by-inflight, the re-armed union run for queued work). It RESOLVES
|
|
20
|
+
* even when the runner throws (the fetch paths own their error handling and
|
|
21
|
+
* diagnostics; callers that need error visibility keep it inside their
|
|
22
|
+
* runner) and when the entry is cleared, so pacing awaits can never hang on
|
|
23
|
+
* teardown.
|
|
24
|
+
*
|
|
25
|
+
* Coalescing must UNION, not replace: two producers share one overlay key
|
|
26
|
+
* (the lazy wave requests the full loaded span; gap repair requests a narrow
|
|
27
|
+
* missing range), and replacing would let the later narrow request shrink a
|
|
28
|
+
* pending full-span recompute. A covering span is always a valid protected
|
|
29
|
+
* request — the server computes supersets safely, never subsets.
|
|
30
|
+
*/
|
|
31
|
+
import { notifyChartLoadPhaseInputChanged } from './chart-load-phase.util.js';
|
|
32
|
+
const PROFILE_DEFAULTS = {
|
|
33
|
+
protected: { settleMs: 600, maxDeferMs: 3000 },
|
|
34
|
+
plain: { settleMs: 0, maxDeferMs: 0 },
|
|
35
|
+
};
|
|
36
|
+
function createDeferred() {
|
|
37
|
+
let resolve;
|
|
38
|
+
const promise = new Promise((res) => {
|
|
39
|
+
resolve = res;
|
|
40
|
+
});
|
|
41
|
+
return { promise, resolve };
|
|
42
|
+
}
|
|
43
|
+
const entriesByKey = new Map();
|
|
44
|
+
let nowFn = () => Date.now();
|
|
45
|
+
export function __setIndicatorInflightClockForTests(fn) {
|
|
46
|
+
nowFn = fn ?? (() => Date.now());
|
|
47
|
+
}
|
|
48
|
+
function indicatorInflightKey(chartIndex, overlayId) {
|
|
49
|
+
return `${chartIndex}:${overlayId}`;
|
|
50
|
+
}
|
|
51
|
+
function cloneRange(range) {
|
|
52
|
+
return { startMs: range.startMs, endMs: range.endMs };
|
|
53
|
+
}
|
|
54
|
+
function isValidRange(range) {
|
|
55
|
+
return Number.isFinite(range.startMs) && Number.isFinite(range.endMs) && range.startMs < range.endMs;
|
|
56
|
+
}
|
|
57
|
+
function containsRange(outer, inner) {
|
|
58
|
+
return outer.startMs <= inner.startMs && outer.endMs >= inner.endMs;
|
|
59
|
+
}
|
|
60
|
+
function unionRange(a, b) {
|
|
61
|
+
if (!a)
|
|
62
|
+
return cloneRange(b);
|
|
63
|
+
return { startMs: Math.min(a.startMs, b.startMs), endMs: Math.max(a.endMs, b.endMs) };
|
|
64
|
+
}
|
|
65
|
+
function clearEntryTimer(entry) {
|
|
66
|
+
if (entry.timer !== null) {
|
|
67
|
+
clearTimeout(entry.timer);
|
|
68
|
+
entry.timer = null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Load-phase tracking watches protected entries only (boot spinners). */
|
|
72
|
+
function notifyEntryChanged(entry) {
|
|
73
|
+
if (entry.profile === 'protected') {
|
|
74
|
+
notifyChartLoadPhaseInputChanged(entry.chartIndex);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function resolveEntryDeferreds(entry) {
|
|
78
|
+
entry.inFlightDeferred?.resolve();
|
|
79
|
+
entry.inFlightDeferred = undefined;
|
|
80
|
+
entry.desiredDeferred?.resolve();
|
|
81
|
+
entry.desiredDeferred = undefined;
|
|
82
|
+
}
|
|
83
|
+
function startEntry(entry) {
|
|
84
|
+
clearEntryTimer(entry);
|
|
85
|
+
const range = entry.desiredRange;
|
|
86
|
+
if (!range || entry.inFlightRange)
|
|
87
|
+
return;
|
|
88
|
+
entry.desiredRange = undefined;
|
|
89
|
+
entry.inFlightRange = cloneRange(range);
|
|
90
|
+
entry.inFlightDeferred = entry.desiredDeferred;
|
|
91
|
+
entry.desiredDeferred = undefined;
|
|
92
|
+
notifyEntryChanged(entry);
|
|
93
|
+
void Promise.resolve()
|
|
94
|
+
.then(() => entry.runner(cloneRange(range)))
|
|
95
|
+
.catch(() => {
|
|
96
|
+
// The fetch paths already own user-visible errors and retry
|
|
97
|
+
// diagnostics. This registry only prevents the promise from becoming an
|
|
98
|
+
// unhandled rejection and lets future requests re-arm normally.
|
|
99
|
+
})
|
|
100
|
+
.finally(() => {
|
|
101
|
+
const completedDeferred = entry.inFlightDeferred;
|
|
102
|
+
if (entriesByKey.get(entry.key) !== entry) {
|
|
103
|
+
// Replaced or cleared mid-flight; the clear already resolved (or a
|
|
104
|
+
// replacement owns) the other deferreds, but this run's awaiters must
|
|
105
|
+
// never hang.
|
|
106
|
+
completedDeferred?.resolve();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const completedRange = entry.inFlightRange;
|
|
110
|
+
entry.inFlightRange = undefined;
|
|
111
|
+
entry.inFlightDeferred = undefined;
|
|
112
|
+
const desiredRange = entry.desiredRange;
|
|
113
|
+
if (completedRange && desiredRange && !containsRange(completedRange, desiredRange)) {
|
|
114
|
+
completedDeferred?.resolve();
|
|
115
|
+
entry.firstDeferredAt = nowFn();
|
|
116
|
+
armEntryTimer(entry, entry.settleMs);
|
|
117
|
+
notifyEntryChanged(entry);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// Drained (any queued range was contained in the completed run, so its
|
|
121
|
+
// awaiters are covered too).
|
|
122
|
+
entriesByKey.delete(entry.key);
|
|
123
|
+
completedDeferred?.resolve();
|
|
124
|
+
resolveEntryDeferreds(entry);
|
|
125
|
+
notifyEntryChanged(entry);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function armEntryTimer(entry, delayMs) {
|
|
129
|
+
clearEntryTimer(entry);
|
|
130
|
+
entry.timer = setTimeout(() => startEntry(entry), Math.max(0, delayMs));
|
|
131
|
+
}
|
|
132
|
+
export function scheduleIndicatorInflightFetch(chartIndex, overlayId, range, runner, options = {}) {
|
|
133
|
+
const key = indicatorInflightKey(chartIndex, overlayId);
|
|
134
|
+
const normalizedRange = cloneRange(range);
|
|
135
|
+
if (!isValidRange(normalizedRange)) {
|
|
136
|
+
return { key, status: 'ignored-invalid', range: normalizedRange, completion: Promise.resolve() };
|
|
137
|
+
}
|
|
138
|
+
const profile = options.profile ?? 'protected';
|
|
139
|
+
const defaults = PROFILE_DEFAULTS[profile];
|
|
140
|
+
const settleMs = Math.max(0, options.settleMs ?? defaults.settleMs);
|
|
141
|
+
const maxDeferMs = Math.max(settleMs, options.maxDeferMs ?? defaults.maxDeferMs);
|
|
142
|
+
let entry = entriesByKey.get(key);
|
|
143
|
+
const hadEntry = Boolean(entry);
|
|
144
|
+
if (!entry) {
|
|
145
|
+
entry = {
|
|
146
|
+
key,
|
|
147
|
+
chartIndex,
|
|
148
|
+
overlayId,
|
|
149
|
+
profile,
|
|
150
|
+
desiredRange: normalizedRange,
|
|
151
|
+
runner,
|
|
152
|
+
timer: null,
|
|
153
|
+
firstDeferredAt: nowFn(),
|
|
154
|
+
settleMs,
|
|
155
|
+
maxDeferMs,
|
|
156
|
+
};
|
|
157
|
+
entriesByKey.set(key, entry);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
entry.runner = runner;
|
|
161
|
+
entry.profile = profile;
|
|
162
|
+
entry.settleMs = settleMs;
|
|
163
|
+
entry.maxDeferMs = maxDeferMs;
|
|
164
|
+
}
|
|
165
|
+
if (entry.inFlightRange) {
|
|
166
|
+
if (containsRange(entry.inFlightRange, normalizedRange)) {
|
|
167
|
+
return {
|
|
168
|
+
key,
|
|
169
|
+
status: 'covered-by-inflight',
|
|
170
|
+
range: normalizedRange,
|
|
171
|
+
inFlightRange: cloneRange(entry.inFlightRange),
|
|
172
|
+
completion: (entry.inFlightDeferred ??= createDeferred()).promise,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
entry.desiredRange = unionRange(entry.desiredRange, normalizedRange);
|
|
176
|
+
entry.desiredDeferred ??= createDeferred();
|
|
177
|
+
notifyEntryChanged(entry);
|
|
178
|
+
return {
|
|
179
|
+
key,
|
|
180
|
+
status: 'queued-after-inflight',
|
|
181
|
+
range: cloneRange(entry.desiredRange),
|
|
182
|
+
inFlightRange: cloneRange(entry.inFlightRange),
|
|
183
|
+
completion: entry.desiredDeferred.promise,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
const status = hadEntry ? 'updated-pending' : 'scheduled';
|
|
187
|
+
entry.desiredRange = unionRange(entry.desiredRange, normalizedRange);
|
|
188
|
+
entry.desiredDeferred ??= createDeferred();
|
|
189
|
+
const completion = entry.desiredDeferred.promise;
|
|
190
|
+
if (!entry.timer) {
|
|
191
|
+
entry.firstDeferredAt = nowFn();
|
|
192
|
+
}
|
|
193
|
+
if (nowFn() - entry.firstDeferredAt >= entry.maxDeferMs) {
|
|
194
|
+
startEntry(entry);
|
|
195
|
+
return { key, status: 'started-max-defer', range: normalizedRange, completion };
|
|
196
|
+
}
|
|
197
|
+
armEntryTimer(entry, entry.settleMs);
|
|
198
|
+
notifyEntryChanged(entry);
|
|
199
|
+
return { key, status, range: normalizedRange, completion };
|
|
200
|
+
}
|
|
201
|
+
export function hasPendingIndicatorInflight(chartIndex, profile) {
|
|
202
|
+
for (const entry of entriesByKey.values()) {
|
|
203
|
+
if (chartIndex !== undefined && entry.chartIndex !== chartIndex)
|
|
204
|
+
continue;
|
|
205
|
+
if (profile !== undefined && entry.profile !== profile)
|
|
206
|
+
continue;
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
export function clearIndicatorInflight(chartIndex, overlayId, profile) {
|
|
212
|
+
const notifyChartIndexes = new Set();
|
|
213
|
+
for (const [key, entry] of entriesByKey) {
|
|
214
|
+
if (entry.chartIndex !== chartIndex)
|
|
215
|
+
continue;
|
|
216
|
+
if (overlayId !== undefined && entry.overlayId !== overlayId)
|
|
217
|
+
continue;
|
|
218
|
+
if (profile !== undefined && entry.profile !== profile)
|
|
219
|
+
continue;
|
|
220
|
+
clearEntryTimer(entry);
|
|
221
|
+
entriesByKey.delete(key);
|
|
222
|
+
resolveEntryDeferreds(entry);
|
|
223
|
+
if (entry.profile === 'protected')
|
|
224
|
+
notifyChartIndexes.add(entry.chartIndex);
|
|
225
|
+
}
|
|
226
|
+
for (const notifyChartIndex of notifyChartIndexes) {
|
|
227
|
+
notifyChartLoadPhaseInputChanged(notifyChartIndex);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
export function clearAllIndicatorInflight(profile) {
|
|
231
|
+
const notifyChartIndexes = new Set();
|
|
232
|
+
for (const [key, entry] of entriesByKey) {
|
|
233
|
+
if (profile !== undefined && entry.profile !== profile)
|
|
234
|
+
continue;
|
|
235
|
+
clearEntryTimer(entry);
|
|
236
|
+
entriesByKey.delete(key);
|
|
237
|
+
resolveEntryDeferreds(entry);
|
|
238
|
+
if (entry.profile === 'protected')
|
|
239
|
+
notifyChartIndexes.add(entry.chartIndex);
|
|
240
|
+
}
|
|
241
|
+
for (const notifyChartIndex of notifyChartIndexes) {
|
|
242
|
+
notifyChartLoadPhaseInputChanged(notifyChartIndex);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
export function __getPendingIndicatorInflightCountForTests(profile) {
|
|
246
|
+
if (profile === undefined)
|
|
247
|
+
return entriesByKey.size;
|
|
248
|
+
let count = 0;
|
|
249
|
+
for (const entry of entriesByKey.values()) {
|
|
250
|
+
if (entry.profile === profile)
|
|
251
|
+
count++;
|
|
252
|
+
}
|
|
253
|
+
return count;
|
|
254
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { BuiltinInputReader } from '../../constants/scriptEditor/builtin-script-snippets.js';
|
|
2
|
+
/**
|
|
3
|
+
* Built-ins whose `timeframe` input runs the engine at that interval: every built-in template with
|
|
4
|
+
* the input, the 14 classics (P2, 2026-10-03) and the 14 TradingView staples (2026-10-04), each
|
|
5
|
+
* pinned by tests/utility/chart/indicator-run-interval.parity.spec.ts against its own chart at that
|
|
6
|
+
* interval. A built-in without the input (Zig Zag, Pivot Points, Volume Bubbles) and every
|
|
7
|
+
* community script run at the chart's interval.
|
|
8
|
+
*/
|
|
9
|
+
export declare const NATIVE_RUN_INTERVAL_SUBTYPES: ReadonlySet<string>;
|
|
10
|
+
/**
|
|
11
|
+
* The lookback, in run bars, a converted built-in's chart path computes over where the engine's
|
|
12
|
+
* declared lookback misses a term. The declaration pass reports the deepest single input of each
|
|
13
|
+
* function it sees (MACD's slow period, the Ichimoku lagging span, the stochastic %K window, one
|
|
14
|
+
* Wilder period for ADX), not the chain the template runs: MACD's signal EMA runs over the slow
|
|
15
|
+
* EMA, Ichimoku displaces its spans past the lagging window, the stochastic smooths %K and then
|
|
16
|
+
* %D (and an oscillator smoothing after that), ADX averages period DX values that each need
|
|
17
|
+
* period true ranges. The warm-up (run-interval-engine.util) takes the deeper of this and the
|
|
18
|
+
* declared lookback, so every other converted built-in, whose declaration is right (a period, a
|
|
19
|
+
* volume MA length, none for the path-dependent ADL, OBV and PSAR, which read the warm-up floor),
|
|
20
|
+
* needs no entry. Mirrors WRUN_RUN_INTERVAL_TWINS (wrun-run-interval.util) with the templates' input
|
|
21
|
+
* names. `inputs` reads each input as set on the overlay, else as the template declares it, else 0.
|
|
22
|
+
*
|
|
23
|
+
* The staples (measured against the declaration pass, 2026-10-04): the pass does not trace an input
|
|
24
|
+
* into atr(), wpr() or highestbars(), so Supertrend, Keltner's ATR bands, Williams %R and Aroon
|
|
25
|
+
* declare nothing for it; an offset reads the line that many bars back (Donchian, WMA, VWMA); Hull
|
|
26
|
+
* runs its outer average over round(sqrt(period)) hull inputs; the Stochastic RSI chains the RSI,
|
|
27
|
+
* its stochastic window and the K and D averages. ATR, CMF, Momentum, ROC and the Awesome
|
|
28
|
+
* Oscillator declare their own lookback right. Supertrend is path-dependent beyond its ATR (its
|
|
29
|
+
* bands and trend carry from the first loaded bar), like PSAR.
|
|
30
|
+
*/
|
|
31
|
+
export declare const NATIVE_RUN_INTERVAL_LOOKBACK_BARS: Readonly<Record<string, (inputs: BuiltinInputReader) => number>>;
|
|
32
|
+
export interface OverlayRunInterval {
|
|
33
|
+
/** Chart interval key the engine runs at ("1h", "1d"). */
|
|
34
|
+
interval: string;
|
|
35
|
+
intervalMs: number;
|
|
36
|
+
/**
|
|
37
|
+
* On: every chart bar shows the last run bar that closed before it. Off: the same, except the
|
|
38
|
+
* chart bars of the newest run bar's bucket show that (forming) bar.
|
|
39
|
+
*/
|
|
40
|
+
waitForClose: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The run bars ride the CME session lattice: the chart's venue is one the gateway rolls up on it
|
|
43
|
+
* (CME, CBOT, NYMEX, COMEX; overlayWrunRunInterval sets it, for the wrun twins only). A run bar's
|
|
44
|
+
* span is then read on the session calendar (runBarSpan): at 4h, 1D and 1W its session bar's
|
|
45
|
+
* open and close, a 1D bar stamped 00:00Z of its trade date after its 17:00 Chicago open the
|
|
46
|
+
* evening before, a 1W bar on the Monday after its Sunday open; at the widths that divide an hour
|
|
47
|
+
* the lattice is the plain grid. A session gap (the daily halt, a weekend, a holiday) holds no run
|
|
48
|
+
* bar of its own (nextRunBarCloseMs). Data, never a function: the stamp rides contexts and
|
|
49
|
+
* results. Absent everywhere else.
|
|
50
|
+
*/
|
|
51
|
+
sessionLattice?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/** What a run bar's span reads: the run interval and whether its bars ride the CME session lattice. */
|
|
54
|
+
export type RunBarCalendar = Pick<OverlayRunInterval, 'intervalMs' | 'sessionLattice'>;
|
|
55
|
+
/** A run bar's span: it takes trades from `open` until `close`. */
|
|
56
|
+
export interface RunBarSpan {
|
|
57
|
+
open: number;
|
|
58
|
+
close: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The [open, close) of the run bar stamped `stamp`: `[stamp, stamp + intervalMs)`, or on the CME
|
|
62
|
+
* session lattice its session bar's (cmeSessionBarOpenMs, cmeSessionBarEndMs: a 1D bar stamped at
|
|
63
|
+
* 00:00Z of its trade date opens at the 17:00 Chicago open before it and closes at the next one).
|
|
64
|
+
* A stamp the lattice books no bar to (a width that divides an hour, a regular-hours bar, a time
|
|
65
|
+
* that is no run bar's) reads the plain span.
|
|
66
|
+
*/
|
|
67
|
+
export declare function runBarSpan(stamp: number, run: RunBarCalendar): RunBarSpan;
|
|
68
|
+
/**
|
|
69
|
+
* The close of the run bar after the one stamped `stamp`: from there on a chart bar shows a run bar
|
|
70
|
+
* later than it. Plain, the next run bar opens at its close (`stamp + 2 * intervalMs`). On the
|
|
71
|
+
* session lattice a gap (the daily halt, a weekend, a holiday) holds no run bar, so the next one is
|
|
72
|
+
* the run bar of the first chart bar (`chartTimes`, ascending) at or after its close: that chart
|
|
73
|
+
* bar's session bar when `stamp` is one, else the run bar it opens (a session reopens on a run
|
|
74
|
+
* bar's open, a regular-hours one included). Infinity when no chart bar reaches that close.
|
|
75
|
+
*/
|
|
76
|
+
export declare function nextRunBarCloseMs(stamp: number, chartTimes: readonly number[], run: RunBarCalendar): number;
|
|
77
|
+
export interface RunIntervalInput {
|
|
78
|
+
/** The overlay's `settings.subType` ("RSI"). */
|
|
79
|
+
subType: unknown;
|
|
80
|
+
/** The overlay's settings: input values live flat under each input's name. */
|
|
81
|
+
settings: unknown;
|
|
82
|
+
/** The chart's interval, as a key ("5m") or milliseconds. */
|
|
83
|
+
chartInterval: unknown;
|
|
84
|
+
/** Market replay keeps the template path. */
|
|
85
|
+
replay?: boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The run interval a Timeframe option label ("1h", "1D") selects on a chart of `chartInterval`:
|
|
89
|
+
* coarser than the chart, else null (the chart's own interval, an unknown label, "chart"). Shared
|
|
90
|
+
* by the kScript built-ins (resolveRunInterval) and their wrun Indicators (wrun-run-interval.util).
|
|
91
|
+
*/
|
|
92
|
+
export declare function runIntervalOfTimeframeLabel(label: unknown, chartInterval: unknown): Pick<OverlayRunInterval, 'interval' | 'intervalMs'> | null;
|
|
93
|
+
/**
|
|
94
|
+
* Whether a Timeframe option label selects the chart's own interval or a finer one. Such a
|
|
95
|
+
* selection means "chart" (HTF-NATIVE-PLAN.md D3a): the resolver below answers null for it, and the
|
|
96
|
+
* engine must see `timeframe: "chart"` too (chartIntervalEngineMetadata), or the template's
|
|
97
|
+
* selected-timeframe branch calls htf() with an interval below its base and the engine throws on
|
|
98
|
+
* every update ("htf() timeframe 900000ms must be >= base interval 3600000ms": a 15m selection
|
|
99
|
+
* on a 1h chart froze the line at its last good run, Kyle's 2026-10-03 INT dump). Their wrun twins
|
|
100
|
+
* read it too (wrunTimeframeIsChartOrFiner, wrun-run-interval.util).
|
|
101
|
+
*/
|
|
102
|
+
export declare function timeframeIsChartOrFiner(label: unknown, chartInterval: unknown): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* The interval an overlay's engine runs at when it is coarser than the chart's, else null (the
|
|
105
|
+
* overlay runs at the chart's interval, as before). A selection at or below the chart's interval
|
|
106
|
+
* is the chart's own, so it takes the plain chart path too.
|
|
107
|
+
*/
|
|
108
|
+
export declare function resolveRunInterval(input: RunIntervalInput): OverlayRunInterval | null;
|
|
109
|
+
/** The settings the engine sees for a run-interval overlay: the template takes its plain chart path. */
|
|
110
|
+
export declare function engineSettingsForRunInterval<T extends object>(settings: T): T & {
|
|
111
|
+
timeframe: 'chart';
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Projects run-interval rows (oldest first, `row[0]` = the run bar's stamp, its open off the
|
|
115
|
+
* session lattice) onto the chart's bars: one row per chart time, with the cells of the run row that
|
|
116
|
+
* bar shows. Each run bar's span is read by runBarSpan (`sessionLattice`: the CME session calendar).
|
|
117
|
+
*
|
|
118
|
+
* Wait for close on: a chart bar shows the last run bar that closed at or before it
|
|
119
|
+
* (`close <= chartTime`, plain `stamp + runMs`), so a 5m bar in hour b shows hour b - 1. Off: the
|
|
120
|
+
* same, except the chart bars inside the newest run row's span show that row (the forming bar,
|
|
121
|
+
* live; on the lattice from its session open, before a 1D or 1W stamp). Chart bars before the first
|
|
122
|
+
* shown row get NaN cells. Run rows before the first chart bar (the warm-up) are dropped.
|
|
123
|
+
*/
|
|
124
|
+
export declare function projectRunRowsOntoChart(rows: readonly (readonly unknown[] | null | undefined)[], chartTimes: readonly number[], runMs: number, waitForClose: boolean, sessionLattice?: boolean): unknown[][];
|
|
125
|
+
/**
|
|
126
|
+
* The chart time a run-bar time anchor (a drawing point at a run bar's stamp) lands on: where that
|
|
127
|
+
* bar's value first shows (its close with wait for close on, its open with it off, read by
|
|
128
|
+
* runBarSpan), clamped to the chart's loaded bars.
|
|
129
|
+
*/
|
|
130
|
+
export declare function projectRunTimeOntoChart(runTime: number, chartTimes: readonly number[], runMs: number, waitForClose: boolean, sessionLattice?: boolean): number;
|