@orangecharts/wrun-chart-host 0.11.1 → 0.15.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 +1 -0
- package/dist/constants/feature-flags.constants.d.ts +4 -4
- package/dist/constants/feature-flags.constants.js +38 -52
- package/dist/constants/feature-limits.constants.d.ts +1 -1
- package/dist/constants/feature-limits.constants.js +5 -4
- package/dist/constants/interval.constants.d.ts +7 -0
- package/dist/constants/interval.constants.js +7 -0
- package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +20 -149
- package/dist/constants/scriptEditor/cme-official-scripts.constants.js +20 -309
- package/dist/constants/stocks-compliance.constants.d.ts +15 -0
- package/dist/constants/stocks-compliance.constants.js +15 -0
- package/dist/host-env.d.ts +69 -3
- package/dist/host-env.js +21 -0
- package/dist/host-ports.types.d.ts +36 -3
- package/dist/index.d.ts +18 -0
- package/dist/index.js +19 -0
- package/dist/indicators/controls/tpo-session.util.d.ts +52 -12
- package/dist/indicators/controls/tpo-session.util.js +113 -16
- package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +6 -0
- package/dist/instances/script-engine-worker-ohlcv-transfer.js +16 -0
- package/dist/interfaces/cme-realtime.interface.d.ts +8 -0
- package/dist/interfaces/cme-realtime.interface.js +2 -1
- package/dist/interfaces/feed.interface.d.ts +15 -1
- package/dist/interfaces/replay.interface.d.ts +5 -0
- package/dist/interfaces/stocks-realtime.interface.d.ts +4 -3
- package/dist/interfaces/stocks-realtime.interface.js +5 -4
- package/dist/interfaces/wrun-runtime.interface.d.ts +141 -20
- package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +17 -0
- package/dist/kscript-data/controls/live-ohlcv-merge.util.js +22 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +46 -40
- package/dist/kscript-data/controls/live-trades-merge.util.js +80 -107
- package/dist/market-data/billing.interface.d.ts +9 -1
- package/dist/market-data/venue.d.ts +1 -1
- package/dist/market-data/venues/index.d.ts +5 -5
- package/dist/market-data/venues/opra.js +3 -3
- package/dist/market-data/venues/stocks.contract.copy.json +6 -5
- package/dist/market-data/venues/stocks.d.ts +5 -5
- package/dist/market-data/venues/stocks.js +21 -18
- package/dist/settings-templates/frvp-fields.d.ts +12 -1
- package/dist/settings-templates/frvp-fields.js +15 -4
- package/dist/settings-templates/index.js +12 -5
- package/dist/settings-templates/indicator-fields.js +43 -2
- package/dist/settings-templates/tool-rules.d.ts +17 -8
- package/dist/settings-templates/tool-rules.js +15 -8
- package/dist/settings-templates/tool-tables.generated.js +4 -2
- package/dist/utility/auth/server-clock.util.d.ts +3 -1
- package/dist/utility/auth/server-clock.util.js +3 -1
- package/dist/utility/chart/book-live-bucket.util.js +2 -2
- package/dist/utility/chart/cache-alignment.util.d.ts +38 -7
- package/dist/utility/chart/cache-alignment.util.js +50 -13
- package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +2 -0
- package/dist/utility/chart/chart-data-fetch-generation.util.js +16 -0
- package/dist/utility/chart/cme-session-bucket.util.d.ts +18 -75
- package/dist/utility/chart/cme-session-bucket.util.js +25 -332
- package/dist/utility/chart/continuous-contracts.util.js +6 -5
- package/dist/utility/chart/display-offset.leaf.d.ts +24 -0
- package/dist/utility/chart/display-offset.leaf.js +41 -0
- package/dist/utility/chart/effective-chart-session.util.d.ts +2 -1
- package/dist/utility/chart/effective-chart-session.util.js +13 -5
- package/dist/utility/chart/feed-interval.util.d.ts +6 -20
- package/dist/utility/chart/feed-interval.util.js +13 -22
- package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +27 -7
- package/dist/utility/chart/fetch-dedupe-policy.util.js +86 -11
- package/dist/utility/chart/footprint-band.util.d.ts +21 -5
- package/dist/utility/chart/footprint-band.util.js +53 -14
- package/dist/utility/chart/host-bar-placement.util.d.ts +7 -4
- package/dist/utility/chart/host-bar-placement.util.js +8 -2
- package/dist/utility/chart/indicator-inflight-registry.util.d.ts +32 -0
- package/dist/utility/chart/indicator-inflight-registry.util.js +52 -0
- package/dist/utility/chart/indicator-run-interval.util.d.ts +10 -4
- package/dist/utility/chart/indicator-run-interval.util.js +21 -12
- package/dist/utility/chart/interval-registry.util.d.ts +1 -1
- package/dist/utility/chart/interval-registry.util.js +1 -1
- package/dist/utility/chart/kscript-legend-entries.util.d.ts +12 -0
- package/dist/utility/chart/kscript-legend-entries.util.js +16 -0
- package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +1 -1
- package/dist/utility/chart/kscript-run-interval-projection.util.js +4 -2
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +53 -62
- package/dist/utility/chart/kscript-venue-policy.util.js +85 -94
- package/dist/utility/chart/live-bucket.util.d.ts +39 -17
- package/dist/utility/chart/live-bucket.util.js +103 -57
- package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +58 -20
- package/dist/utility/chart/local-kscript-source-revalidation.util.js +98 -23
- package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +35 -11
- package/dist/utility/chart/local-kscript-warmup-depth.util.js +24 -3
- package/dist/utility/chart/market-session-schedule.util.d.ts +8 -0
- package/dist/utility/chart/market-session-schedule.util.js +39 -1
- package/dist/utility/chart/market-session.util.d.ts +136 -0
- package/dist/utility/chart/market-session.util.js +341 -0
- package/dist/utility/chart/om-panel.util.d.ts +5 -3
- package/dist/utility/chart/om-panel.util.js +42 -7
- package/dist/utility/chart/om-target.util.d.ts +14 -1
- package/dist/utility/chart/om-target.util.js +22 -5
- package/dist/utility/chart/opra-read-access.leaf.d.ts +16 -1
- package/dist/utility/chart/opra-read-access.leaf.js +22 -0
- package/dist/utility/chart/profile-row-height.util.d.ts +49 -16
- package/dist/utility/chart/profile-row-height.util.js +74 -37
- package/dist/utility/chart/rth-session.util.d.ts +55 -20
- package/dist/utility/chart/rth-session.util.js +94 -46
- package/dist/utility/chart/session-lattice.util.d.ts +150 -0
- package/dist/utility/chart/session-lattice.util.js +488 -0
- package/dist/utility/chart/trading-day.util.d.ts +40 -2
- package/dist/utility/chart/trading-day.util.js +84 -7
- package/dist/utility/chart/us-equities-session.util.d.ts +32 -11
- package/dist/utility/chart/us-equities-session.util.js +44 -15
- package/dist/utility/chart/window-geometry.leaf.d.ts +28 -7
- package/dist/utility/chart/window-geometry.leaf.js +57 -8
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +21 -14
- package/dist/utility/chart/wrun-bar-session-facts.util.js +32 -38
- package/dist/utility/chart/wrun-run-result.util.d.ts +38 -13
- package/dist/utility/chart/wrun-run-result.util.js +97 -27
- package/dist/utility/common/time.util.js +5 -4
- package/dist/utility/market-events/earnings-scope.util.d.ts +10 -5
- package/dist/utility/market-events/earnings-scope.util.js +17 -9
- package/dist/utility/market-events/market-events.util.d.ts +14 -7
- package/dist/utility/market-events/market-events.util.js +30 -17
- package/dist/utility/number-format.util.d.ts +14 -21
- package/dist/utility/number-format.util.js +38 -24
- package/dist/utility/options/option-venue-disclosure.util.d.ts +40 -6
- package/dist/utility/options/option-venue-disclosure.util.js +71 -11
- package/dist/utility/options/option-venue.util.d.ts +1 -1
- package/dist/utility/options/option-venue.util.js +1 -1
- package/dist/utility/pool-symbol.leaf.d.ts +7 -0
- package/dist/utility/pool-symbol.leaf.js +50 -5
- package/dist/utility/stocks/stock-display.util.d.ts +15 -0
- package/dist/utility/stocks/stock-display.util.js +37 -0
- package/dist/utility/symbol-selection/contract-expiry.util.js +5 -4
- package/dist/utility/v2/gate-plane.util.d.ts +6 -0
- package/dist/utility/v2/gate-plane.util.js +11 -1
- package/dist/utility/v2/gate-session-latch.util.d.ts +1 -1
- package/dist/utility/v2/gate-session-latch.util.js +3 -3
- package/dist/utility/v2/governed-tier.leaf.d.ts +17 -16
- package/dist/utility/v2/governed-tier.leaf.js +17 -16
- package/dist/utility/v2/stocks-governed.util.d.ts +5 -0
- package/dist/utility/v2/stocks-governed.util.js +14 -0
- package/dist/utility/v2/v2-enums.leaf.d.ts +13 -0
- package/dist/utility/v2/v2-enums.leaf.js +458 -0
- package/dist/utility/wrun/derived-roots.leaf.d.ts +21 -1
- package/dist/utility/wrun/derived-roots.leaf.js +27 -1
- package/dist/utility/wrun/derived-roots.util.d.ts +44 -32
- package/dist/utility/wrun/derived-roots.util.js +97 -56
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -3
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -3
- package/dist/utility/wrun/sources/lanes/option_daily.d.ts +2 -1
- package/dist/utility/wrun/sources/lanes/option_daily.js +2 -1
- package/dist/utility/wrun/sources/lanes/options_flow.d.ts +3 -0
- package/dist/utility/wrun/sources/lanes/options_flow.js +23 -5
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +3 -4
- package/dist/utility/wrun/sources/row-lane-registry.js +9 -4
- package/dist/utility/wrun/sources/row-lanes/dark_pool.d.ts +19 -0
- package/dist/utility/wrun/sources/row-lanes/dark_pool.js +104 -0
- package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
- package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.d.ts +20 -0
- package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.js +103 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -2
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +15 -13
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +49 -23
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +14 -9
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +75 -27
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +139 -82
- package/dist/utility/wrun/wrun-app-layer.leaf.d.ts +78 -0
- package/dist/utility/wrun/wrun-app-layer.leaf.js +89 -0
- package/dist/utility/wrun/wrun-bar-count.util.d.ts +11 -7
- package/dist/utility/wrun/wrun-bar-count.util.js +12 -8
- package/dist/utility/wrun/wrun-batched-kinds.leaf.d.ts +13 -0
- package/dist/utility/wrun/wrun-batched-kinds.leaf.js +18 -0
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +46 -23
- package/dist/utility/wrun/wrun-batched-marks.util.js +260 -62
- package/dist/utility/wrun/wrun-batched-readout.util.d.ts +26 -19
- package/dist/utility/wrun/wrun-batched-readout.util.js +81 -27
- package/dist/utility/wrun/wrun-book-bands.leaf.d.ts +8 -0
- package/dist/utility/wrun/wrun-book-bands.leaf.js +7 -0
- package/dist/utility/wrun/wrun-candle-equal.leaf.d.ts +19 -0
- package/dist/utility/wrun/wrun-candle-equal.leaf.js +40 -0
- package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -2
- package/dist/utility/wrun/wrun-canvases.util.d.ts +24 -7
- package/dist/utility/wrun/wrun-canvases.util.js +99 -30
- package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +6 -3
- package/dist/utility/wrun/wrun-chart-context-names.util.js +8 -4
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +47 -29
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +201 -201
- package/dist/utility/wrun/wrun-child-overlay-id.util.js +2 -1
- package/dist/utility/wrun/wrun-cme-legs-note.util.d.ts +15 -0
- package/dist/utility/wrun/wrun-cme-legs-note.util.js +49 -0
- package/dist/utility/wrun/wrun-cme-root-specs.util.d.ts +38 -0
- package/dist/utility/wrun/wrun-cme-root-specs.util.js +81 -0
- package/dist/utility/wrun/wrun-coin-lane-live.util.js +3 -0
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-color-settings.util.js +32 -7
- package/dist/utility/wrun/wrun-dark-pool.util.d.ts +50 -0
- package/dist/utility/wrun/wrun-dark-pool.util.js +127 -0
- package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +67 -12
- package/dist/utility/wrun/wrun-declared-warmup.util.js +165 -13
- package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +18 -8
- package/dist/utility/wrun/wrun-draft-legend-note.util.js +57 -11
- package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +14 -10
- package/dist/utility/wrun/wrun-draft-overlay.util.js +26 -14
- package/dist/utility/wrun/wrun-earnings-facts.util.js +3 -2
- package/dist/utility/wrun/wrun-etf-funds.util.d.ts +2 -0
- package/dist/utility/wrun/wrun-etf-funds.util.js +4 -0
- package/dist/utility/wrun/wrun-held-lanes.util.js +8 -2
- package/dist/utility/wrun/wrun-history-as-of.util.d.ts +77 -0
- package/dist/utility/wrun/wrun-history-as-of.util.js +108 -0
- package/dist/utility/wrun/wrun-host.service.d.ts +64 -14
- package/dist/utility/wrun/wrun-host.service.js +137 -27
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +3 -3
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +12 -2
- package/dist/utility/wrun/wrun-hover.util.d.ts +8 -2
- package/dist/utility/wrun/wrun-hover.util.js +24 -13
- package/dist/utility/wrun/wrun-inert-legend.util.d.ts +13 -0
- package/dist/utility/wrun/wrun-inert-legend.util.js +31 -3
- package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +7 -5
- package/dist/utility/wrun/wrun-input-requirements.leaf.js +16 -6
- package/dist/utility/wrun/wrun-install-pacer.util.d.ts +26 -0
- package/dist/utility/wrun/wrun-install-pacer.util.js +145 -0
- package/dist/utility/wrun/wrun-kit-refusal-stages.types.d.ts +22 -0
- package/dist/utility/wrun/wrun-kit-refusal-stages.types.js +1 -0
- package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +12 -5
- package/dist/utility/wrun/wrun-lane-refusal.leaf.js +23 -5
- package/dist/utility/wrun/wrun-lane-warmup.util.js +22 -4
- package/dist/utility/wrun/wrun-leg-close.util.d.ts +6 -5
- package/dist/utility/wrun/wrun-leg-close.util.js +11 -9
- package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +3 -1
- package/dist/utility/wrun/wrun-leg-fetch.util.js +9 -2
- package/dist/utility/wrun/wrun-levels-child.util.d.ts +2 -0
- package/dist/utility/wrun/wrun-levels-child.util.js +6 -0
- package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -0
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +15 -6
- package/dist/utility/wrun/wrun-live-intake.util.js +167 -47
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +52 -8
- package/dist/utility/wrun/wrun-live-tick.util.js +655 -97
- package/dist/utility/wrun/wrun-market-facts.util.d.ts +16 -2
- package/dist/utility/wrun/wrun-market-facts.util.js +32 -3
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +27 -27
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +28 -16
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +34 -5
- package/dist/utility/wrun/wrun-oi-lane.util.d.ts +10 -7
- package/dist/utility/wrun/wrun-oi-lane.util.js +16 -10
- package/dist/utility/wrun/wrun-option-strike-flow.util.js +1 -1
- package/dist/utility/wrun/wrun-option-views.util.d.ts +2 -2
- package/dist/utility/wrun/wrun-option-views.util.js +5 -2
- package/dist/utility/wrun/wrun-options-flow-underlying.leaf.d.ts +5 -0
- package/dist/utility/wrun/wrun-options-flow-underlying.leaf.js +16 -0
- package/dist/utility/wrun/wrun-options-stop.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-options-stop.util.js +6 -4
- package/dist/utility/wrun/wrun-output-words.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-output-words.util.js +51 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +116 -11
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +208 -43
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +20 -10
- package/dist/utility/wrun/wrun-overlay-park.util.d.ts +84 -0
- package/dist/utility/wrun/wrun-overlay-park.util.js +135 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +37 -4
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +26 -14
- package/dist/utility/wrun/wrun-overlay-result.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +247 -26
- package/dist/utility/wrun/wrun-overlay-run.util.js +2234 -408
- package/dist/utility/wrun/wrun-pack.util.d.ts +8 -5
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +11 -2
- package/dist/utility/wrun/wrun-panel-mount.util.js +122 -19
- package/dist/utility/wrun/wrun-panel-style.util.d.ts +4 -2
- package/dist/utility/wrun/wrun-panel-style.util.js +3 -2
- package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +7 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.js +18 -4
- package/dist/utility/wrun/wrun-pin-venues.util.d.ts +26 -17
- package/dist/utility/wrun/wrun-pin-venues.util.js +43 -36
- package/dist/utility/wrun/wrun-pinned-lanes.util.d.ts +58 -0
- package/dist/utility/wrun/wrun-pinned-lanes.util.js +72 -0
- package/dist/utility/wrun/wrun-prefix-cohort.util.js +2 -1
- package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +22 -9
- package/dist/utility/wrun/wrun-prefix-lanes.util.js +145 -26
- package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +29 -0
- package/dist/utility/wrun/wrun-prefix-proof.util.js +23 -5
- package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +9 -1
- package/dist/utility/wrun/wrun-refusal-surface.util.js +15 -1
- package/dist/utility/wrun/wrun-refusal.util.d.ts +19 -1
- package/dist/utility/wrun/wrun-refusal.util.js +103 -16
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +20 -6
- package/dist/utility/wrun/wrun-registry-errors.util.js +20 -6
- package/dist/utility/wrun/wrun-replay-rows.util.js +6 -10
- package/dist/utility/wrun/wrun-run-health.util.d.ts +95 -5
- package/dist/utility/wrun/wrun-run-health.util.js +209 -3
- package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +2 -2
- package/dist/utility/wrun/wrun-run-interval-session.util.js +2 -2
- package/dist/utility/wrun/wrun-run-interval.util.d.ts +9 -8
- package/dist/utility/wrun/wrun-run-interval.util.js +13 -11
- package/dist/utility/wrun/wrun-sandbox-row-source.js +5 -2
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +38 -11
- package/dist/utility/wrun/wrun-script-inputs.util.js +194 -56
- package/dist/utility/wrun/wrun-session-composition.util.d.ts +81 -0
- package/dist/utility/wrun/wrun-session-composition.util.js +169 -0
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +10 -7
- package/dist/utility/wrun/wrun-setting-words.util.js +25 -7
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +94 -28
- package/dist/utility/wrun/wrun-source-rows.util.js +738 -93
- package/dist/utility/wrun/wrun-stream-clock.util.d.ts +45 -0
- package/dist/utility/wrun/wrun-stream-clock.util.js +108 -0
- package/dist/utility/wrun/wrun-style-names.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-style-names.util.js +74 -0
- package/dist/utility/wrun/wrun-tape-coins.util.d.ts +116 -0
- package/dist/utility/wrun/wrun-tape-coins.util.js +110 -0
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +62 -32
- package/dist/utility/wrun/wrun-tape-source.util.js +72 -34
- package/dist/utility/wrun/wrun-tier-grid.util.d.ts +13 -5
- package/dist/utility/wrun/wrun-tier-grid.util.js +23 -13
- package/dist/utility/wrun/wrun-tpo-rows.util.js +2 -1
- package/dist/utility/wrun/wrun-trades-lane.util.d.ts +73 -0
- package/dist/utility/wrun/wrun-trades-lane.util.js +82 -0
- package/dist/utility/wrun/wrun-twin-compute-inputs.util.d.ts +5 -0
- package/dist/utility/wrun/wrun-twin-compute-inputs.util.js +9 -2
- package/dist/utility/wrun/wrun-visibility-table.d.ts +13 -0
- package/dist/utility/wrun/wrun-visibility-table.js +9 -0
- package/dist/utility/wrun/wrun-volume-profile.util.js +7 -3
- package/dist/utils/replay/replay-buffer-math.d.ts +16 -6
- package/dist/utils/replay/replay-buffer-math.js +60 -30
- package/dist/workers/constants/socket-slots.d.ts +11 -7
- package/dist/workers/constants/socket-slots.js +6 -5
- package/package.json +5 -5
|
@@ -179,6 +179,21 @@
|
|
|
179
179
|
* Any other class refuses by name (fail closed), matching the daemon's
|
|
180
180
|
* serving-gate behavior for unserved classes.
|
|
181
181
|
*
|
|
182
|
+
* Market pins on typed feeds and the book (U9e, wrun-pinned-lanes.util): a
|
|
183
|
+
* secondary `book`, `oi`, `funding` or `liquidations` input pinned to one
|
|
184
|
+
* whole market (`symbol` AND `exchange`) reads a lane of its own there
|
|
185
|
+
* (`pinnedLaneRows`, keyed `<class>@<exchange>|<symbol>`), in its class's row
|
|
186
|
+
* dialect on the chart's bars: the shared host's foreign ask of the class is
|
|
187
|
+
* answered from the lane of the ask's market, never from the chart's own lane
|
|
188
|
+
* (an own book and a pinned book in one package read one lane each). It takes
|
|
189
|
+
* no interval of its own (one equal to the chart's is the chart's grid) and no
|
|
190
|
+
* view. Which classes a pin is served on is ONE table every gate reads
|
|
191
|
+
* (`WRUN_BROWSER_PINNED_LANE_CLASSES`: this planner's refusal, the push
|
|
192
|
+
* intake's eligibility and the run's admission); a pin on any other class
|
|
193
|
+
* (`implied_volatility`, `skew`, `volume_profile`, `tape`, ...) refuses by
|
|
194
|
+
* name: "the chart reads <class> on its own market only; a market pin on it
|
|
195
|
+
* is not served yet".
|
|
196
|
+
*
|
|
182
197
|
* Scalar missingness honors the declared `missing` policy: absent = 'carry'
|
|
183
198
|
* (the latest eligible value forward-fills; until every carry input has a
|
|
184
199
|
* first value the row abstains, absent from the rows), 'nan' delivers NaN,
|
|
@@ -310,10 +325,13 @@
|
|
|
310
325
|
* The builders take a `clock: { intervalMs, nowMs }` whenever a leg or a
|
|
311
326
|
* typed pin exists and refuse to guess without one (an open-stamped coarse
|
|
312
327
|
* leg is exactly the lookahead leak the clock prevents). Refused by name
|
|
313
|
-
* before any fetch: a market pin on
|
|
314
|
-
*
|
|
315
|
-
* input
|
|
316
|
-
*
|
|
328
|
+
* before any fetch: a market pin on a class the one table leaves out (the
|
|
329
|
+
* chart reads it on its own market only; the served pins are a secondary
|
|
330
|
+
* `ohlcv` input's leg, a trades leg, a lane stream's leg and a secondary
|
|
331
|
+
* book, oi, funding or liquidations input's lane), a half pin, a pin on the
|
|
332
|
+
* primary input (it follows the chart's market; an `odds` input is the
|
|
333
|
+
* exception, it pins its own Polymarket market, primary included), an
|
|
334
|
+
* interval or a view on a pinned typed feed, a finer pin, a leg that is not a whole
|
|
317
335
|
* multiple of the chart interval (7 days for WEEK), a pin on a celled,
|
|
318
336
|
* `time`, trades, liquidations, implied_volatility or skew input, an
|
|
319
337
|
* interval pin on the primary input (index 0), an interval the vocabulary
|
|
@@ -335,22 +353,27 @@
|
|
|
335
353
|
* tail build gives the same answer.
|
|
336
354
|
*/
|
|
337
355
|
import { wrunChartHostEnv } from '../../host-env.js';
|
|
356
|
+
import { packedOhlcvRowViews, unpackOhlcvRows, } from '../../instances/script-engine-worker-ohlcv-transfer.js';
|
|
338
357
|
import { FeatureFlag } from '../../constants/feature-flags.constants.js';
|
|
339
358
|
import { Intervals } from '../../constants/interval.constants.js';
|
|
340
359
|
import { barEndMs, calendarBarStartMs, calendarLongestBarMs, calendarMonthsOfMs, isCalendarIntervalMs, } from '../chart/calendar-interval.util.js';
|
|
341
360
|
import { WRUN_PINNED_INTERVALS, wrunPinnedIntervalOf } from './wrun-pinned-interval.util.js';
|
|
342
361
|
import { realMainRows } from '../chart/indicator-gap-detector.util.js';
|
|
343
362
|
import { placeRowsInHostBars, rowLastInstantMs } from '../chart/host-bar-placement.util.js';
|
|
344
|
-
import { liveBucketVenueOf } from '../chart/live-bucket.util.js';
|
|
363
|
+
import { liveBucketBarsAreLabels, liveBucketBarsOnUtcLattice, liveBucketStartMs, liveBucketStartsInRange, liveBucketVenueOf, } from '../chart/live-bucket.util.js';
|
|
345
364
|
import { findMonday } from '../chart/titan-constants.pin.js';
|
|
346
365
|
import { wrunBarSessionFactsResolver, } from '../chart/wrun-bar-session-facts.util.js';
|
|
347
366
|
import { wrunSettingRefusedMessage } from '../scriptEditor/wrun-runtime-diagnostics.leaf.js';
|
|
348
367
|
import { attachWrunRefusal, wrunPinFinerSeed } from './wrun-refusal.util.js';
|
|
349
|
-
import { isWrunAskedTapeSource, wrunTapeFloorParamOf } from './wrun-tape-source.util.js';
|
|
368
|
+
import { isWrunAskedTapeSource, WRUN_TAPE_COINS_PLAN_FLOOR, wrunTapeFloorFacetOf, wrunTapeFloorParamOf, } from './wrun-tape-source.util.js';
|
|
350
369
|
import { WRUN_BROWSER_REFUSED_CLASS_CODES } from './wrun-browser-sources.leaf.js';
|
|
351
370
|
import { wrunProtocolPendingSeed } from './wrun-protocol-pending.util.js';
|
|
371
|
+
import { wrunClockHistoryAsOfMs } from './wrun-history-as-of.util.js';
|
|
372
|
+
import { isWrunBandedBookSource, WRUN_BOOK_BAND_TUPLE_WIDTH } from './wrun-book-bands.leaf.js';
|
|
352
373
|
import { planWrunRowLaneInputs, wrunRowLaneCellRows } from './sources/wrun-row-lanes.util.js';
|
|
353
374
|
import { wrunTradesLaneOf, wrunTradesLegLaneOf, wrunTradesLegOf } from './wrun-trades-lane.util.js';
|
|
375
|
+
import { isWrunPinnedLaneClass, wrunPinnedClassRefusal, wrunPinnedLaneIdOf, wrunPinnedLaneOfSource, } from './wrun-pinned-lanes.util.js';
|
|
376
|
+
import { WRUN_BROWSER_PINNED_LANE_CLASSES } from './wrun-input-requirements.leaf.js';
|
|
354
377
|
import { planWrunPollLaneInputs } from './sources/wrun-poll-lanes.util.js';
|
|
355
378
|
import { planWrunEtfFlowColumns } from './wrun-etf-flow-lane.util.js';
|
|
356
379
|
import { planWrunOptionSummaryLane } from './wrun-option-summary-lane.util.js';
|
|
@@ -445,26 +468,18 @@ const WRUN_CHART_GRID_CHECK_ROWS = 8;
|
|
|
445
468
|
const WRUN_CHART_GRID_COARSER_FACTOR = 2.5;
|
|
446
469
|
/** This many bar phases or more among the newest rows is another interval's bars (a DST shift moves a session-bound venue's bars by one phase). */
|
|
447
470
|
const WRUN_CHART_GRID_MIXED_PHASES = 3;
|
|
471
|
+
/** On a session lattice, this many of the venue's own bars skipped on every spacing is a coarser interval's (two and a half intervals on the UTC lattice). */
|
|
472
|
+
const WRUN_CHART_SESSION_COARSER_SKIPS = 2;
|
|
473
|
+
/** This many label spacings under half the interval is a finer interval's day bars; one alone is a forming bar the live writer keyed on its own label. */
|
|
474
|
+
const WRUN_CHART_LABEL_SHORT_SPACINGS = 2;
|
|
448
475
|
/**
|
|
449
|
-
* Why `rows` are not the chart's candles at `intervalMs
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
* three of four 300 ms storms, Ichimoku Cloud and EMA). The full run asks this before it plans and
|
|
455
|
-
* waits for the next chart trigger instead (`WrunNoBarsError`), as for no rows at all.
|
|
456
|
-
*
|
|
457
|
-
* Judged on the newest rows alone (a chart holds one interval at a time):
|
|
458
|
-
* - `mixed-phase`: the rows open on three or more phases of the interval (4h bars on a 1d chart
|
|
459
|
-
* open on six); a DST shift moves a session-bound venue's bars by one phase, never two;
|
|
460
|
-
* - `coarser`: every spacing between the newest rows is at least two and a half intervals (1d
|
|
461
|
-
* bars on a 4h chart); a session-bound venue's overnight or weekend gap is one spacing among
|
|
462
|
-
* several, never all of them.
|
|
463
|
-
* A calendar interval (1M, 3M, 6M, 1Y) opens on the 1st of a month at no fixed phase, a non-time
|
|
464
|
-
* interval has no grid, and a chart of fewer rows than the check reads (a new listing, a spec's
|
|
465
|
-
* three-row chart) leaves nothing to judge: all pass.
|
|
476
|
+
* Why `rows` are not the chart's candles at `intervalMs` yet, judged on the bar grid `venue` keeps (`live-bucket.util`),
|
|
477
|
+
* or null when they are: a run planned between an interval switch's cached paint and its commit would read the previous
|
|
478
|
+
* interval's bars, so the full run waits for the next chart trigger instead (`WrunNoBarsError`). `mixed-phase` names
|
|
479
|
+
* finer bars, `coarser` bars that skip the chart's own on every spacing. A calendar or non-time interval, or fewer rows
|
|
480
|
+
* than the check reads, pass.
|
|
466
481
|
*/
|
|
467
|
-
export function wrunChartRowsOffIntervalGrid(rows, intervalMs) {
|
|
482
|
+
export function wrunChartRowsOffIntervalGrid(rows, intervalMs, venue) {
|
|
468
483
|
if (!(intervalMs > 0) || isCalendarIntervalMs(intervalMs))
|
|
469
484
|
return null;
|
|
470
485
|
const newest = [];
|
|
@@ -475,18 +490,62 @@ export function wrunChartRowsOffIntervalGrid(rows, intervalMs) {
|
|
|
475
490
|
}
|
|
476
491
|
if (newest.length < WRUN_CHART_GRID_CHECK_ROWS)
|
|
477
492
|
return null;
|
|
493
|
+
if (liveBucketBarsAreLabels(intervalMs, venue))
|
|
494
|
+
return wrunLabelRowsOffGrid(newest, intervalMs);
|
|
495
|
+
// A session lattice's own bars (a stock 8h chart's one bar a session) are judged by the bars the venue keeps.
|
|
496
|
+
const onSessionLattice = !liveBucketBarsOnUtcLattice(intervalMs, venue) &&
|
|
497
|
+
newest.every((ts) => liveBucketStartMs(ts, intervalMs, venue) === ts);
|
|
498
|
+
if (onSessionLattice)
|
|
499
|
+
return wrunRowsSkipSessionBars(newest, intervalMs, venue) ? 'coarser' : null;
|
|
500
|
+
return wrunRowsOffIntervalPhase(newest, intervalMs);
|
|
501
|
+
}
|
|
502
|
+
/** The UTC lattice's verdict: three or more phases of the interval (4h bars on a 1d chart open on six), or every spacing
|
|
503
|
+
* two and a half intervals or wider (1d bars on a 4h chart; an overnight or weekend gap is one spacing among several). */
|
|
504
|
+
function wrunRowsOffIntervalPhase(newest, intervalMs) {
|
|
478
505
|
const phases = new Set();
|
|
479
506
|
for (const ts of newest)
|
|
480
507
|
phases.add(((ts % intervalMs) + intervalMs) % intervalMs);
|
|
481
508
|
if (phases.size >= WRUN_CHART_GRID_MIXED_PHASES)
|
|
482
509
|
return 'mixed-phase';
|
|
510
|
+
for (let i = 1; i < newest.length; i += 1) {
|
|
511
|
+
if (newest[i] - newest[i - 1] < WRUN_CHART_GRID_COARSER_FACTOR * intervalMs)
|
|
512
|
+
return null;
|
|
513
|
+
}
|
|
514
|
+
return 'coarser';
|
|
515
|
+
}
|
|
516
|
+
/** Whether rows on the venue's session lattice skip at least two of its bars on every spacing, counted on the lattice:
|
|
517
|
+
* wall-clock spacing misreads a session holding one bar (a day between 8h bars) as wide. */
|
|
518
|
+
function wrunRowsSkipSessionBars(newest, intervalMs, venue) {
|
|
519
|
+
const opens = liveBucketStartsInRange(newest[0], newest[newest.length - 1], intervalMs, venue);
|
|
520
|
+
let at = 0;
|
|
521
|
+
for (let i = 1; i < newest.length; i += 1) {
|
|
522
|
+
while (at < opens.length && opens[at] <= newest[i - 1])
|
|
523
|
+
at += 1;
|
|
524
|
+
let skipped = 0;
|
|
525
|
+
for (; at < opens.length && opens[at] < newest[i]; at += 1)
|
|
526
|
+
skipped += 1;
|
|
527
|
+
if (skipped < WRUN_CHART_SESSION_COARSER_SKIPS)
|
|
528
|
+
return false;
|
|
529
|
+
}
|
|
530
|
+
return true;
|
|
531
|
+
}
|
|
532
|
+
/** The verdict on a label grid (a stock or CME 3d group, CME 1d and 1w): labels sit at 00:00Z a varying number of days
|
|
533
|
+
* apart, so a stamp inside a day is an intraday bar, short spacings are finer day bars, and every spacing two and a
|
|
534
|
+
* half intervals or wider is coarser. Never the exact labels: the stock 3d model counts weekdays, the gateway trade dates. */
|
|
535
|
+
function wrunLabelRowsOffGrid(newest, intervalMs) {
|
|
536
|
+
if (newest.some((ts) => ((ts % Intervals.DAY) + Intervals.DAY) % Intervals.DAY !== 0))
|
|
537
|
+
return 'mixed-phase';
|
|
538
|
+
let short = 0;
|
|
483
539
|
let coarser = true;
|
|
484
540
|
for (let i = 1; i < newest.length; i += 1) {
|
|
485
|
-
|
|
541
|
+
const spacing = newest[i] - newest[i - 1];
|
|
542
|
+
if (spacing < intervalMs / 2)
|
|
543
|
+
short += 1;
|
|
544
|
+
if (spacing < WRUN_CHART_GRID_COARSER_FACTOR * intervalMs)
|
|
486
545
|
coarser = false;
|
|
487
|
-
break;
|
|
488
|
-
}
|
|
489
546
|
}
|
|
547
|
+
if (short >= WRUN_CHART_LABEL_SHORT_SPACINGS)
|
|
548
|
+
return 'mixed-phase';
|
|
490
549
|
return coarser ? 'coarser' : null;
|
|
491
550
|
}
|
|
492
551
|
/** Record the rows `traded` left out of `raw` (a subsequence of the same row
|
|
@@ -568,15 +627,18 @@ function wrunUnaskedCelledInput(input, source) {
|
|
|
568
627
|
* C1.4): the dollar lane `trades_usd` (rows `buySellVolumeUsdRows`) for
|
|
569
628
|
* `currency: "USD"`, the coin lane `trades` (the chart's own buy/sell lane)
|
|
570
629
|
* otherwise, and a trades input pinned to one whole market its quote's leg lane
|
|
571
|
-
* there (kit 0.77.0, `trades@BYBIT|BTCUSDT`);
|
|
572
|
-
*
|
|
573
|
-
*
|
|
630
|
+
* there (kit 0.77.0, `trades@BYBIT|BTCUSDT`); a book, oi, funding or
|
|
631
|
+
* liquidations input pinned to one whole market reads that class's lane there
|
|
632
|
+
* (U9e, wrun-pinned-lanes.util, `book@COINBASE|BTC-USD`); none for an
|
|
633
|
+
* undemanded input (wrunDemandedSourceClass) or a trades half pin (refused by
|
|
634
|
+
* name). The one rule the full run's lane fetches, the live intake and the
|
|
635
|
+
* reconcile share.
|
|
574
636
|
*/
|
|
575
637
|
export function wrunSourceLane(source) {
|
|
576
638
|
if (source === undefined || source.undemanded === true)
|
|
577
639
|
return undefined;
|
|
578
640
|
if (source.source !== 'trades')
|
|
579
|
-
return source.source;
|
|
641
|
+
return wrunPinnedLaneOfSource(source) ?? source.source;
|
|
580
642
|
if (source.symbol === undefined && source.exchange === undefined && !wrunFollowsCoin(source)) {
|
|
581
643
|
return wrunTradesLaneOf(source);
|
|
582
644
|
}
|
|
@@ -1443,17 +1505,33 @@ export function planWrunPinnedWires(metadata, chartIntervalMs) {
|
|
|
1443
1505
|
}
|
|
1444
1506
|
}
|
|
1445
1507
|
else if (market !== undefined) {
|
|
1446
|
-
// A market pin is served
|
|
1447
|
-
//
|
|
1448
|
-
//
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1508
|
+
// A market pin is served where the one table every pin gate reads says the browser reads its class pinned
|
|
1509
|
+
// (WRUN_BROWSER_PINNED_LANE_CLASSES): a secondary ohlcv input's leg, and a secondary book, oi, funding or
|
|
1510
|
+
// liquidations input's lane of its own on that market (wrun-pinned-lanes.util). Every other class reads the
|
|
1511
|
+
// chart's own market on this lane, refused by name, and the primary input IS the chart's market on every host.
|
|
1512
|
+
if (!WRUN_BROWSER_PINNED_LANE_CLASSES.has(source.source)) {
|
|
1513
|
+
throw new Error(wrunPinnedClassRefusal(name, source.source, marketLabel(source)));
|
|
1452
1514
|
}
|
|
1453
1515
|
if (input.index === 0) {
|
|
1454
|
-
throw new Error(`Input '${name}' (
|
|
1516
|
+
throw new Error(`Input '${name}' (${source.source}) pins the market '${marketLabel(source)}' on the primary input (index 0): ` +
|
|
1455
1517
|
`the primary input follows the chart's market; market pins are served on secondary inputs only`);
|
|
1456
1518
|
}
|
|
1519
|
+
if (isWrunPinnedLaneClass(source.source)) {
|
|
1520
|
+
// A pinned lane plans no leg and no wire: the shared host asks the class on that market, and the row builder
|
|
1521
|
+
// answers the ask from the lane's rows (`wrunHostRunOf`).
|
|
1522
|
+
checkWrunPinnedLaneInput(input, source, chartKnown ? chartIntervalMs : undefined);
|
|
1523
|
+
if (source.source === 'book' && (metadata.heatmaps ?? []).some((heatmap) => heatmap.cells === name)) {
|
|
1524
|
+
// The book canvases paint the chart's own book rows: a pinned book's cells are read, never painted, so a
|
|
1525
|
+
// heatmap over them refuses by name rather than paint the chart's own book in their place.
|
|
1526
|
+
throw new Error(`Input '${name}' (book) pins the market '${marketLabel(source)}' and a heatmap paints its cells: ` +
|
|
1527
|
+
`the chart paints a book heatmap over its own market's book only`);
|
|
1528
|
+
}
|
|
1529
|
+
continue;
|
|
1530
|
+
}
|
|
1531
|
+
if (input.cellType === 'array') {
|
|
1532
|
+
throw new Error(`Input '${name}' (${source.source}) is celled and pins the market '${marketLabel(source)}': ` +
|
|
1533
|
+
`${source.source} serves one scalar per bar`);
|
|
1534
|
+
}
|
|
1457
1535
|
}
|
|
1458
1536
|
if (source.interval === undefined) {
|
|
1459
1537
|
if (view !== undefined) {
|
|
@@ -1643,6 +1721,37 @@ function checkWrunTradesPin(input, source) {
|
|
|
1643
1721
|
throw new Error(`Input '${name}' declares view '${source.view}' without an interval pin: views need an interval pin coarser than the chart's`);
|
|
1644
1722
|
}
|
|
1645
1723
|
}
|
|
1724
|
+
/** A pinned lane input's shape (wrun-pinned-lanes.util), refused by name before any fetch: one whole market (symbol AND
|
|
1725
|
+
* exchange together), read at the chart's interval (an interval pin equal to the chart's is the chart's own grid),
|
|
1726
|
+
* with no view (a view needs a coarser interval pin, which a pinned feed does not take). An undemanded one reads its
|
|
1727
|
+
* fill. */
|
|
1728
|
+
function checkWrunPinnedLaneInput(input, source, chartIntervalMs) {
|
|
1729
|
+
if (source.undemanded === true)
|
|
1730
|
+
return;
|
|
1731
|
+
const name = input.name;
|
|
1732
|
+
const cls = source.source;
|
|
1733
|
+
if (source.symbol === undefined || source.exchange === undefined) {
|
|
1734
|
+
throw new Error(`Input '${name}' (${cls}) pins the market '${marketLabel(source)}': a market pin carries symbol AND exchange together`);
|
|
1735
|
+
}
|
|
1736
|
+
if (source.interval !== undefined) {
|
|
1737
|
+
const interval = wrunPinnedIntervalOf(source.interval);
|
|
1738
|
+
if (interval === undefined || chartIntervalMs === undefined || interval.ms !== chartIntervalMs) {
|
|
1739
|
+
throw new Error(`Input '${name}' (${cls}) pins the market '${marketLabel(source)}' and interval '${source.interval}': ` +
|
|
1740
|
+
`a pinned ${cls} lane reads its market at the chart's interval (interval pins on typed feeds are served on the chart's own market only)`);
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
if (source.view !== undefined) {
|
|
1744
|
+
throw new Error(`Input '${name}' declares view '${source.view}' on the pinned market '${marketLabel(source)}': ` +
|
|
1745
|
+
`views need an interval pin coarser than the chart's, which a pinned ${cls} lane does not take`);
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
/** The pinned lane rows the shared host's foreign ask of a class reads (wrun-pinned-lanes.util), by the ask's own
|
|
1749
|
+
* market: a lane the run never asked reads none (its inputs read their fill), never the chart's own lane. */
|
|
1750
|
+
function wrunPinnedLaneRowsOf(sources, cls, ask) {
|
|
1751
|
+
if (typeof ask?.exchange !== 'string' || typeof ask.symbol !== 'string')
|
|
1752
|
+
return [];
|
|
1753
|
+
return sources.pinnedLaneRows?.[wrunPinnedLaneIdOf(cls, ask.exchange, ask.symbol)] ?? [];
|
|
1754
|
+
}
|
|
1646
1755
|
function requireSource(metadata, inputName) {
|
|
1647
1756
|
const source = metadata.inputSources[inputName];
|
|
1648
1757
|
if (!source) {
|
|
@@ -2145,11 +2254,13 @@ function wrunTapePlanSettings(metadata, settings) {
|
|
|
2145
2254
|
}
|
|
2146
2255
|
/** The params an asked tape input's floor (`min_size` or `min_value`) names: the host resolves that
|
|
2147
2256
|
* floor itself, from the run's settings (its planTapeFloors), so the plan reads their declarations
|
|
2148
|
-
* and their values. An unasked tape (`isWrunAskedTapeSource`) is planned as no tape at all
|
|
2257
|
+
* and their values. An unasked tape (`isWrunAskedTapeSource`) is planned as no tape at all, and a
|
|
2258
|
+
* coins tape as a literal priced floor (`wrunPlannedTapeSource`), so its coins param never reaches
|
|
2259
|
+
* the plan: its coin bounds would judge a dollar number. */
|
|
2149
2260
|
function wrunTapeFloorParams(metadata) {
|
|
2150
2261
|
const names = new Set();
|
|
2151
2262
|
for (const source of Object.values(metadata.inputSources)) {
|
|
2152
|
-
if (!isWrunAskedTapeSource(source))
|
|
2263
|
+
if (!isWrunAskedTapeSource(source) || wrunTapeFloorFacetOf(source) === 'min_coins')
|
|
2153
2264
|
continue;
|
|
2154
2265
|
const paramName = wrunTapeFloorParamOf(source);
|
|
2155
2266
|
if (paramName !== undefined)
|
|
@@ -2163,7 +2274,10 @@ function wrunTapeFloorParams(metadata) {
|
|
|
2163
2274
|
* whatever the unit (its cell adapter keeps `size >= floor`), and the browser lane serves a dollar tape's cells sized
|
|
2164
2275
|
* by their dollar value (k-trades.worker, the live fold's `tradesTapeCellSize`), so the floor and the column it reads
|
|
2165
2276
|
* are one unit there. The installed kit (0.91.1) declares no `min_value` facet and refuses a tape without its own
|
|
2166
|
-
* floor; this is the browser lane's own plan input, never the package's sheet. A raw floor plans as declared.
|
|
2277
|
+
* floor; this is the browser lane's own plan input, never the package's sheet. A raw floor plans as declared. A coins
|
|
2278
|
+
* floor (`min_coins`, C-COINS item 2), a param or a literal, plans as the literal dollar floor the run priced
|
|
2279
|
+
* (`coinsFloor`, the row build's `WRUN_TAPE_COINS_PLAN_FLOOR` setting): its cells are dollars, and the coins param's
|
|
2280
|
+
* bounds never judge a dollar number. No priced floor plans none, which the host refuses by name: never a guess.
|
|
2167
2281
|
*/
|
|
2168
2282
|
/**
|
|
2169
2283
|
* A source as the shared host plans it, without `needed_by` (kit 0.72.0, and on a secondary tape kit 0.95.0): the
|
|
@@ -2179,11 +2293,17 @@ function wrunPlannedWithoutDemandWord(source) {
|
|
|
2179
2293
|
const { needed_by: _decided, ...planned } = source;
|
|
2180
2294
|
return planned;
|
|
2181
2295
|
}
|
|
2182
|
-
function wrunPlannedTapeSource(source) {
|
|
2183
|
-
if (source.
|
|
2296
|
+
function wrunPlannedTapeSource(source, coinsFloor) {
|
|
2297
|
+
if (source.min_size !== undefined)
|
|
2298
|
+
return source;
|
|
2299
|
+
if (source.min_value !== undefined) {
|
|
2300
|
+
const { min_value: minValue, ...rest } = source;
|
|
2301
|
+
return { ...rest, min_size: minValue };
|
|
2302
|
+
}
|
|
2303
|
+
if (source.min_coins === undefined)
|
|
2184
2304
|
return source;
|
|
2185
|
-
const {
|
|
2186
|
-
return { ...rest, min_size:
|
|
2305
|
+
const { min_coins: _coins, ...rest } = source;
|
|
2306
|
+
return Number.isFinite(coinsFloor) && coinsFloor > 0 ? { ...rest, min_size: coinsFloor } : rest;
|
|
2187
2307
|
}
|
|
2188
2308
|
/**
|
|
2189
2309
|
* The sheet the shared host plans for one build: every lane read (`WrunLaneRead`) as the lane
|
|
@@ -2198,7 +2318,8 @@ function wrunPlannedTapeSource(source) {
|
|
|
2198
2318
|
* inputs (wrunSheetWithSettings). The one exception is a param an asked tape input's floor names,
|
|
2199
2319
|
* which the plan resolves from the run's settings (`wrunTapeFloorParams`).
|
|
2200
2320
|
*/
|
|
2201
|
-
function wrunPlannedSheet(metadata, lanes, stamps, shift, cellLanes = new Map()) {
|
|
2321
|
+
function wrunPlannedSheet(metadata, lanes, stamps, shift, cellLanes = new Map(), settings) {
|
|
2322
|
+
const coinsFloor = Number(settings?.[WRUN_TAPE_COINS_PLAN_FLOOR]);
|
|
2202
2323
|
const inputSources = {};
|
|
2203
2324
|
for (const input of metadata.inputs) {
|
|
2204
2325
|
const declared = metadata.inputSources[input.name];
|
|
@@ -2229,7 +2350,7 @@ function wrunPlannedSheet(metadata, lanes, stamps, shift, cellLanes = new Map())
|
|
|
2229
2350
|
inputSources[input.name] = { ...source, field: 'open' };
|
|
2230
2351
|
}
|
|
2231
2352
|
else if (source.source === 'tape') {
|
|
2232
|
-
inputSources[input.name] = wrunPlannedTapeSource(source);
|
|
2353
|
+
inputSources[input.name] = wrunPlannedTapeSource(source, coinsFloor);
|
|
2233
2354
|
}
|
|
2234
2355
|
else {
|
|
2235
2356
|
inputSources[input.name] = source;
|
|
@@ -2330,6 +2451,11 @@ function wrunRowsStepMs(stamps) {
|
|
|
2330
2451
|
}
|
|
2331
2452
|
return step;
|
|
2332
2453
|
}
|
|
2454
|
+
const windowConversions = { build: 0, advance: 0, tail: 0, combined: 0, recovered: 0 };
|
|
2455
|
+
/** A copy of the page's full-window conversion counts (above). */
|
|
2456
|
+
export function wrunWindowConversionCounts() {
|
|
2457
|
+
return { ...windowConversions };
|
|
2458
|
+
}
|
|
2333
2459
|
/** The index of the last row of ascending `rows` stamped at or before `ms` (-1 when none is). */
|
|
2334
2460
|
function wrunLastRowAtOrBefore(rows, ms) {
|
|
2335
2461
|
let low = 0;
|
|
@@ -2348,10 +2474,335 @@ function wrunLastRowAtOrBefore(rows, ms) {
|
|
|
2348
2474
|
function wrunLaneRowsAfter(rows, afterTs) {
|
|
2349
2475
|
return rows === undefined ? [] : rows.filter((row) => !(Number(row[0]) <= afterTs));
|
|
2350
2476
|
}
|
|
2351
|
-
/**
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
*
|
|
2477
|
+
/** Every packed book block a run keeps, by its transferred buffer (each row of the lane is a view of it). */
|
|
2478
|
+
const WRUN_PACKED_BOOK_BLOCKS = new WeakMap();
|
|
2479
|
+
/** The f64 blocks the book adapter writes (`wrunBookCellRows`): a cell block that is a view of one of them is the
|
|
2480
|
+
* adapter's own, never written after the build, and rides to the packer uncopied (`wrunPackerBlock`). */
|
|
2481
|
+
const WRUN_BOOK_CELL_BUFFERS = new WeakSet();
|
|
2482
|
+
/**
|
|
2483
|
+
* A lane's packed transfer as the run reads it (WRUN-PANBACK-2 S2). A K_ORDERBOOK lane (`orderbook`) keeps the worker's
|
|
2484
|
+
* block: its rows are zero-copy views of the transferred buffer (`packedOhlcvRowViews`, the zero padding past a shorter
|
|
2485
|
+
* row cut off by its length), recorded with the overlay that fetched them, so no row of the lane becomes a plain array
|
|
2486
|
+
* and the book adapter reads the block where it stands. Every other lane unpacks to plain rows, as before.
|
|
2487
|
+
*/
|
|
2488
|
+
export function wrunPackedLaneRows(type, payload, owner) {
|
|
2489
|
+
if (type !== 'orderbook')
|
|
2490
|
+
return unpackOhlcvRows(payload);
|
|
2491
|
+
WRUN_PACKED_BOOK_BLOCKS.set(payload.buffer, {
|
|
2492
|
+
chartIndex: owner.chartIndex,
|
|
2493
|
+
indicatorId: owner.indicatorId,
|
|
2494
|
+
rows: payload.rows,
|
|
2495
|
+
cols: payload.cols,
|
|
2496
|
+
});
|
|
2497
|
+
return packedOhlcvRowViews(payload);
|
|
2498
|
+
}
|
|
2499
|
+
/** A book row's stamp as the shared host's cell adapter reads it (its `toMs`): a number or a numeric string, finite,
|
|
2500
|
+
* in the facts' unit; NaN otherwise. */
|
|
2501
|
+
function wrunBookRowStampMs(raw, facts) {
|
|
2502
|
+
const value = typeof raw === 'string' ? Number(raw) : raw;
|
|
2503
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
2504
|
+
return Number.NaN;
|
|
2505
|
+
return facts.tsUnit === 's' ? value * 1000 : value;
|
|
2506
|
+
}
|
|
2507
|
+
/** How a book row's levels of one side are written: in the row's own order, in its reverse, or sorted. */
|
|
2508
|
+
const BOOK_SIDE_AS_STORED = 0;
|
|
2509
|
+
const BOOK_SIDE_REVERSED = 1;
|
|
2510
|
+
const BOOK_SIDE_SORTED = 2;
|
|
2511
|
+
/** Whether a finite size is an ask level's: the lane stores ask sizes negated, a negated zero included. */
|
|
2512
|
+
function isWrunBookAskSize(size) {
|
|
2513
|
+
return size < 0 || Object.is(size, -0);
|
|
2514
|
+
}
|
|
2515
|
+
/** The finite `[price, size]` pairs of a book row (from index 1, a trailing lone value ignored), by side. Allocates
|
|
2516
|
+
* nothing per level. */
|
|
2517
|
+
function wrunBookRowSides(row) {
|
|
2518
|
+
const bids = { levels: 0, first: -1, last: -1, order: BOOK_SIDE_AS_STORED };
|
|
2519
|
+
const asks = { levels: 0, first: -1, last: -1, order: BOOK_SIDE_AS_STORED };
|
|
2520
|
+
let asksStored = true;
|
|
2521
|
+
let asksReversed = true;
|
|
2522
|
+
let lastBid = Number.NaN;
|
|
2523
|
+
let lastAsk = Number.NaN;
|
|
2524
|
+
for (let at = 1; at + 1 < row.length; at += 2) {
|
|
2525
|
+
const price = Number(row[at]);
|
|
2526
|
+
const size = Number(row[at + 1]);
|
|
2527
|
+
if (!Number.isFinite(price) || !Number.isFinite(size))
|
|
2528
|
+
continue;
|
|
2529
|
+
if (isWrunBookAskSize(size)) {
|
|
2530
|
+
if (asks.levels > 0) {
|
|
2531
|
+
if (price < lastAsk)
|
|
2532
|
+
asksStored = false;
|
|
2533
|
+
else
|
|
2534
|
+
asksReversed = false;
|
|
2535
|
+
}
|
|
2536
|
+
else {
|
|
2537
|
+
asks.first = at;
|
|
2538
|
+
}
|
|
2539
|
+
asks.last = at;
|
|
2540
|
+
lastAsk = price;
|
|
2541
|
+
asks.levels += 1;
|
|
2542
|
+
}
|
|
2543
|
+
else {
|
|
2544
|
+
if (bids.levels > 0) {
|
|
2545
|
+
if (price > lastBid)
|
|
2546
|
+
bids.order = BOOK_SIDE_SORTED;
|
|
2547
|
+
}
|
|
2548
|
+
else {
|
|
2549
|
+
bids.first = at;
|
|
2550
|
+
}
|
|
2551
|
+
bids.last = at;
|
|
2552
|
+
lastBid = price;
|
|
2553
|
+
bids.levels += 1;
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
asks.order = asksStored ? BOOK_SIDE_AS_STORED : asksReversed ? BOOK_SIDE_REVERSED : BOOK_SIDE_SORTED;
|
|
2557
|
+
return { bids, asks };
|
|
2558
|
+
}
|
|
2559
|
+
/** Visit one side of a book row's finite levels in the side's order (bids by price descending, asks ascending, equal
|
|
2560
|
+
* prices in lane order: `WrunBookRowSide.order`), handing `visit` each level's price and its size as the lane holds it
|
|
2561
|
+
* (an ask's negated), until `visit` answers false: a walk stops at the first level past its edge. */
|
|
2562
|
+
function visitWrunBookSide(row, ask, side, visit) {
|
|
2563
|
+
if (side.levels === 0)
|
|
2564
|
+
return;
|
|
2565
|
+
// The pair at `at` when it is a finite level of this side: visited. False once the visitor stops.
|
|
2566
|
+
const take = (at) => {
|
|
2567
|
+
const price = Number(row[at]);
|
|
2568
|
+
const size = Number(row[at + 1]);
|
|
2569
|
+
if (!Number.isFinite(price) || !Number.isFinite(size) || isWrunBookAskSize(size) !== ask)
|
|
2570
|
+
return true;
|
|
2571
|
+
return visit(price, size);
|
|
2572
|
+
};
|
|
2573
|
+
if (side.order === BOOK_SIDE_AS_STORED) {
|
|
2574
|
+
for (let at = side.first; at <= side.last; at += 2)
|
|
2575
|
+
if (!take(at))
|
|
2576
|
+
return;
|
|
2577
|
+
return;
|
|
2578
|
+
}
|
|
2579
|
+
if (side.order === BOOK_SIDE_REVERSED) {
|
|
2580
|
+
for (let at = side.last; at >= side.first; at -= 2)
|
|
2581
|
+
if (!take(at))
|
|
2582
|
+
return;
|
|
2583
|
+
return;
|
|
2584
|
+
}
|
|
2585
|
+
// The rare row out of order: a stable sort of the side's pair indexes by price, the shared host's comparator on the
|
|
2586
|
+
// same sequence, so equal prices keep their lane order.
|
|
2587
|
+
const pairs = [];
|
|
2588
|
+
for (let at = side.first; at <= side.last; at += 2) {
|
|
2589
|
+
const price = Number(row[at]);
|
|
2590
|
+
const size = Number(row[at + 1]);
|
|
2591
|
+
if (Number.isFinite(price) && Number.isFinite(size) && isWrunBookAskSize(size) === ask)
|
|
2592
|
+
pairs.push(at);
|
|
2593
|
+
}
|
|
2594
|
+
const priceAt = (at) => Number(row[at]);
|
|
2595
|
+
pairs.sort(ask ? (a, b) => priceAt(a) - priceAt(b) : (a, b) => priceAt(b) - priceAt(a));
|
|
2596
|
+
for (const at of pairs)
|
|
2597
|
+
if (!take(at))
|
|
2598
|
+
return;
|
|
2599
|
+
}
|
|
2600
|
+
/** Write one side of a book row as `[price, |size|, side]` cells from `cursor`, in the side's order; answers the cursor
|
|
2601
|
+
* past them. */
|
|
2602
|
+
function writeWrunBookSide(row, ask, side, out, cursor) {
|
|
2603
|
+
const sideCell = ask ? -1 : 1;
|
|
2604
|
+
visitWrunBookSide(row, ask, side, (price, size) => {
|
|
2605
|
+
out[cursor] = price;
|
|
2606
|
+
out[cursor + 1] = ask ? Math.abs(size) : size;
|
|
2607
|
+
out[cursor + 2] = sideCell;
|
|
2608
|
+
cursor += 3;
|
|
2609
|
+
return true;
|
|
2610
|
+
});
|
|
2611
|
+
return cursor;
|
|
2612
|
+
}
|
|
2613
|
+
/** The rows a book lane answers, ascending by stamp (the shared host's cell adapter's rule): a row with no finite stamp
|
|
2614
|
+
* is skipped, and a later row of a stamp replaces an earlier one. */
|
|
2615
|
+
function wrunBookAnsweringRows(rows, facts) {
|
|
2616
|
+
const stamps = [];
|
|
2617
|
+
const lastRowOf = new Map();
|
|
2618
|
+
let ascending = true;
|
|
2619
|
+
for (let at = 0; at < rows.length; at += 1) {
|
|
2620
|
+
const row = rows[at];
|
|
2621
|
+
const ts = row === null || row === undefined ? Number.NaN : wrunBookRowStampMs(row[0], facts);
|
|
2622
|
+
if (!Number.isFinite(ts))
|
|
2623
|
+
continue;
|
|
2624
|
+
if (lastRowOf.has(ts) || (stamps.length > 0 && ts < stamps[stamps.length - 1]))
|
|
2625
|
+
ascending = false;
|
|
2626
|
+
if (!lastRowOf.has(ts))
|
|
2627
|
+
stamps.push(ts);
|
|
2628
|
+
lastRowOf.set(ts, at);
|
|
2629
|
+
}
|
|
2630
|
+
if (!ascending)
|
|
2631
|
+
stamps.sort((a, b) => a - b);
|
|
2632
|
+
return stamps.map((ts) => ({ ts, row: rows[lastRowOf.get(ts)] }));
|
|
2633
|
+
}
|
|
2634
|
+
/**
|
|
2635
|
+
* The book lane's cell rows (WRUN-PANBACK-2 S2): what the shared host's cell adapter answers for a book ask in the
|
|
2636
|
+
* kScript row dialect with its depth unbounded (`adaptWrunCells`: the lane was asked at the sheet's depth), written
|
|
2637
|
+
* straight into ONE f64 block, each row's cells a view of it. The same cells in the same order: a row with no finite
|
|
2638
|
+
* stamp is skipped, a later row of a stamp replaces an earlier one, rows ascend by stamp; in a row the finite
|
|
2639
|
+
* `[price, size]` pairs (`wrunBookRowSides`), bids by price descending and then asks ascending, equal prices in lane
|
|
2640
|
+
* order, each level `[price, |size|, side]` with side +1 bid and -1 ask, a zero size kept. A row is read where it
|
|
2641
|
+
* stands (a view of the worker's packed block, `wrunPackedLaneRows`; a live frame's typed row; a plain array), so no
|
|
2642
|
+
* row is copied to a plain array first and no level becomes an array of its own.
|
|
2643
|
+
*/
|
|
2644
|
+
function wrunBookCellRows(rows, facts) {
|
|
2645
|
+
const answering = wrunBookAnsweringRows(rows, facts);
|
|
2646
|
+
const sides = answering.map(({ row }) => wrunBookRowSides(row));
|
|
2647
|
+
let cells = 0;
|
|
2648
|
+
for (const side of sides)
|
|
2649
|
+
cells += 3 * (side.bids.levels + side.asks.levels);
|
|
2650
|
+
const out = new Float64Array(cells);
|
|
2651
|
+
WRUN_BOOK_CELL_BUFFERS.add(out.buffer);
|
|
2652
|
+
let cursor = 0;
|
|
2653
|
+
const answered = answering.map(({ ts, row }, at) => {
|
|
2654
|
+
const from = cursor;
|
|
2655
|
+
cursor = writeWrunBookSide(row, false, sides[at].bids, out, cursor);
|
|
2656
|
+
cursor = writeWrunBookSide(row, true, sides[at].asks, out, cursor);
|
|
2657
|
+
return { ts, cells: out.subarray(from, cursor) };
|
|
2658
|
+
});
|
|
2659
|
+
// The kit types a cell row's cells as an array; its aligner reads a block's length and hands the block on as an
|
|
2660
|
+
// `ArrayLike<number>` (`WrunCellBlocks`), so the view rides where the adapter's array did.
|
|
2661
|
+
return answered;
|
|
2662
|
+
}
|
|
2663
|
+
/** The frozen refusal of a book input's `bands` no reduction can walk (kit 0.109.0). */
|
|
2664
|
+
const WRUN_BOOK_BANDS_INVALID_CODE = 'wrun_book_bands_invalid';
|
|
2665
|
+
/** The most bands one book input declares. */
|
|
2666
|
+
const WRUN_BOOK_BANDS_MAX = 8;
|
|
2667
|
+
/** A banded book input's percents (`WrunInputSource.bands`), refused by name unless they are 1 to 8 finite numbers,
|
|
2668
|
+
* each above 0 and at most 10, strictly ascending: the reduction walks them as nested edges from the touch, so a list
|
|
2669
|
+
* out of range or out of order never reaches it. */
|
|
2670
|
+
function wrunBookInputBands(metadata, name, bands) {
|
|
2671
|
+
const valid = Array.isArray(bands) &&
|
|
2672
|
+
bands.length >= 1 &&
|
|
2673
|
+
bands.length <= WRUN_BOOK_BANDS_MAX &&
|
|
2674
|
+
bands.every((pct, at) => typeof pct === 'number' && Number.isFinite(pct) && pct > 0 && pct <= 10 && (at === 0 || pct > bands[at - 1]));
|
|
2675
|
+
if (!valid) {
|
|
2676
|
+
throw new Error(`WRUN ${metadata.id}: input '${name}' declares bands ${JSON.stringify(bands)} (${WRUN_BOOK_BANDS_INVALID_CODE}): ` +
|
|
2677
|
+
`declare 1 to ${WRUN_BOOK_BANDS_MAX} percents of the touch, each above 0 and at most 10, strictly ascending`);
|
|
2678
|
+
}
|
|
2679
|
+
return bands;
|
|
2680
|
+
}
|
|
2681
|
+
/** The key a banded book input's rows ride: the ask's own (one lane, one fetch: `bands` is no part of the ask) and its
|
|
2682
|
+
* percents, so a raw input and each list of bands keep blocks of their own. */
|
|
2683
|
+
function wrunBookBandsKey(askKey, bands) {
|
|
2684
|
+
return `${askKey}|bands=${bands.join(',')}`;
|
|
2685
|
+
}
|
|
2686
|
+
/**
|
|
2687
|
+
* One side's band sums at `out[at]`, `out[at + 2]`, ... (one per band, in the bands' order), the package's walk
|
|
2688
|
+
* (Bar Statistics `sumBids` / `sumAsks`): from the touch (the side's first level), adding each level's |size| to a sum
|
|
2689
|
+
* from 0 while the level holds inside the band's edge, `touch - touch * (pct / 100)` for bids and
|
|
2690
|
+
* `touch + touch * (pct / 100)` for asks, the edge itself inside; a side with no level sums 0. The bands are walked
|
|
2691
|
+
* as ONE walk, each band's sum read where the walk first meets a level past that band's edge: nested edges make every
|
|
2692
|
+
* band the prefix sum a walk of its own adds, in the same order from the same 0, so bit-identical to it. Edges nest
|
|
2693
|
+
* on every positive touch; where a wider percent gives a narrower edge (a touch at or below zero), each band walks
|
|
2694
|
+
* on its own instead.
|
|
2695
|
+
*/
|
|
2696
|
+
function writeWrunBookBandSums(row, ask, side, bands, edges, out, at) {
|
|
2697
|
+
const count = bands.length;
|
|
2698
|
+
// Past an edge: a bid below it, an ask above it.
|
|
2699
|
+
const outside = (price, edge) => (ask ? price > edge : price < edge);
|
|
2700
|
+
let band = 0;
|
|
2701
|
+
let sum = 0;
|
|
2702
|
+
let touched = false;
|
|
2703
|
+
let nested = true;
|
|
2704
|
+
visitWrunBookSide(row, ask, side, (price, size) => {
|
|
2705
|
+
if (!touched) {
|
|
2706
|
+
touched = true;
|
|
2707
|
+
for (let b = 0; b < count; b += 1) {
|
|
2708
|
+
edges[b] = ask ? price + price * (bands[b] / 100) : price - price * (bands[b] / 100);
|
|
2709
|
+
if (b > 0 && outside(edges[b - 1], edges[b]))
|
|
2710
|
+
nested = false;
|
|
2711
|
+
}
|
|
2712
|
+
if (!nested)
|
|
2713
|
+
return false;
|
|
2714
|
+
}
|
|
2715
|
+
while (outside(price, edges[band])) {
|
|
2716
|
+
out[at + 2 * band] = sum;
|
|
2717
|
+
band += 1;
|
|
2718
|
+
if (band === count)
|
|
2719
|
+
return false;
|
|
2720
|
+
}
|
|
2721
|
+
sum += Math.abs(size);
|
|
2722
|
+
return true;
|
|
2723
|
+
});
|
|
2724
|
+
if (nested) {
|
|
2725
|
+
// The walk ran out of levels: every band it did not close holds the whole walk.
|
|
2726
|
+
for (; band < count; band += 1)
|
|
2727
|
+
out[at + 2 * band] = sum;
|
|
2728
|
+
return;
|
|
2729
|
+
}
|
|
2730
|
+
for (let b = 0; b < count; b += 1) {
|
|
2731
|
+
let own = 0;
|
|
2732
|
+
visitWrunBookSide(row, ask, side, (price, size) => {
|
|
2733
|
+
if (outside(price, edges[b]))
|
|
2734
|
+
return false;
|
|
2735
|
+
own += Math.abs(size);
|
|
2736
|
+
return true;
|
|
2737
|
+
});
|
|
2738
|
+
out[at + 2 * b] = own;
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
/**
|
|
2742
|
+
* A banded book input's rows (`bands`, kit 0.109.0): on each row the book lane answers (`wrunBookAnsweringRows`, the
|
|
2743
|
+
* raw input's own rows), the bid and ask size sums per band, `[bid_0, ask_0, bid_1, ask_1, ...]`, written into ONE f64
|
|
2744
|
+
* block, each row's cells a view of it (`wrunPackerBlock` hands them on uncopied). The levels are the ones the raw input
|
|
2745
|
+
* reads on that row, in its order (`visitWrunBookSide`), each side walked once (`writeWrunBookBandSums`); a row with no
|
|
2746
|
+
* finite level answers an empty block, as the raw input reads it. Every build reads it through `wrunHostRunOf`, so the
|
|
2747
|
+
* full build, a tail (the forming bar's bands from its newest snapshot) and a carry advance reduce alike.
|
|
2748
|
+
*/
|
|
2749
|
+
function wrunBookBandRows(rows, facts, bands) {
|
|
2750
|
+
const answering = wrunBookAnsweringRows(rows, facts);
|
|
2751
|
+
const sides = answering.map(({ row }) => wrunBookRowSides(row));
|
|
2752
|
+
const width = WRUN_BOOK_BAND_TUPLE_WIDTH * bands.length;
|
|
2753
|
+
let booked = 0;
|
|
2754
|
+
for (const side of sides)
|
|
2755
|
+
if (side.bids.levels + side.asks.levels > 0)
|
|
2756
|
+
booked += 1;
|
|
2757
|
+
const out = new Float64Array(booked * width);
|
|
2758
|
+
WRUN_BOOK_CELL_BUFFERS.add(out.buffer);
|
|
2759
|
+
const edges = new Float64Array(bands.length);
|
|
2760
|
+
let cursor = 0;
|
|
2761
|
+
const answered = answering.map(({ ts, row }, at) => {
|
|
2762
|
+
const { bids, asks } = sides[at];
|
|
2763
|
+
if (bids.levels + asks.levels === 0)
|
|
2764
|
+
return { ts, cells: out.subarray(cursor, cursor) };
|
|
2765
|
+
writeWrunBookBandSums(row, false, bids, bands, edges, out, cursor);
|
|
2766
|
+
writeWrunBookBandSums(row, true, asks, bands, edges, out, cursor + 1);
|
|
2767
|
+
cursor += width;
|
|
2768
|
+
return { ts, cells: out.subarray(cursor - width, cursor) };
|
|
2769
|
+
});
|
|
2770
|
+
// As the book's cells: the aligner hands the view on as an `ArrayLike<number>` (`WrunCellBlocks`).
|
|
2771
|
+
return answered;
|
|
2772
|
+
}
|
|
2773
|
+
/** The ring of a whole-window book adapt over a kept packed block (WRUN-PANBACK-2 S2): the overlay that fetched it, the
|
|
2774
|
+
* rows adapted and the block's column width (the widest, when the lane holds rows of more than one block). A lane that
|
|
2775
|
+
* holds no kept block (the plain K_ORDERBOOK lane) rings nothing. Advisory: a host that binds no diagnostics port (a
|
|
2776
|
+
* spec, a lean host) never fails a build over the ring. */
|
|
2777
|
+
function ringWrunBookLaneAdapted(rows) {
|
|
2778
|
+
let owner;
|
|
2779
|
+
let cols = 0;
|
|
2780
|
+
let seen;
|
|
2781
|
+
for (const row of rows) {
|
|
2782
|
+
if (!(row instanceof Float64Array) || row.buffer === seen)
|
|
2783
|
+
continue;
|
|
2784
|
+
seen = row.buffer;
|
|
2785
|
+
const block = WRUN_PACKED_BOOK_BLOCKS.get(row.buffer);
|
|
2786
|
+
if (block === undefined)
|
|
2787
|
+
continue;
|
|
2788
|
+
owner ??= block;
|
|
2789
|
+
cols = Math.max(cols, block.cols);
|
|
2790
|
+
}
|
|
2791
|
+
if (owner === undefined)
|
|
2792
|
+
return;
|
|
2793
|
+
try {
|
|
2794
|
+
wrunChartHostEnv().diagnostics.debug('wrun-book-lane-adapted', {
|
|
2795
|
+
chartIndex: owner.chartIndex,
|
|
2796
|
+
indicatorId: owner.indicatorId,
|
|
2797
|
+
rows: rows.length,
|
|
2798
|
+
cols,
|
|
2799
|
+
path: 'packed',
|
|
2800
|
+
});
|
|
2801
|
+
}
|
|
2802
|
+
catch {
|
|
2803
|
+
// No diagnostics port: the cells stand without the ring.
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2355
2806
|
/** A profile stream's adapted rows, kept per leg buffer and ask: the buffer is replaced whole by every merge of its
|
|
2356
2807
|
* fetch, so a tail build over the same buffer (a live tick) adapts nothing again. */
|
|
2357
2808
|
const WRUN_LEG_STREAM_CELL_ROWS = new WeakMap();
|
|
@@ -2370,6 +2821,10 @@ function wrunLegStreamCellRows(host, ask, rows) {
|
|
|
2370
2821
|
byAsk.set(ask.key, adapted);
|
|
2371
2822
|
return adapted;
|
|
2372
2823
|
}
|
|
2824
|
+
/** A lane's rows as the host's cell adapter reads them. The adapter takes `Array.isArray` rows only and skips any other
|
|
2825
|
+
* row without a word, so a typed row is copied to a plain array; plain rows pass as they are. The book lane, whose
|
|
2826
|
+
* rows are typed (the packed block's views, every live row the push intake folds in or the heatmap rider feeds), is
|
|
2827
|
+
* never read here: its own adapter reads them where they stand (`wrunBookCellRows`). */
|
|
2373
2828
|
function wrunPlainLaneRows(rows) {
|
|
2374
2829
|
return rows.some((row) => !Array.isArray(row))
|
|
2375
2830
|
? rows.map((row) => (Array.isArray(row) ? row : Array.from(row)))
|
|
@@ -2441,9 +2896,10 @@ function wrunSessionAnswersOf(host, plan, session, intervalMs) {
|
|
|
2441
2896
|
* `cellsAfterTs`: a tail build's or a carry advance's carry `throughTs`. The host's pass starts at
|
|
2442
2897
|
* the first row after it and a cell block never carries, so only the celled lanes' rows stamped
|
|
2443
2898
|
* after it are adapted and only an intrabar leg's candles those rows can hold are sliced (a live
|
|
2444
|
-
* tick never converts the whole window's book, profile or finer candles again).
|
|
2899
|
+
* tick never converts the whole window's book, profile or finer candles again). Without it the run
|
|
2900
|
+
* converts the whole window, counted by `site` (`wrunWindowConversionCounts`).
|
|
2445
2901
|
*/
|
|
2446
|
-
function wrunHostRunOf(metadata, sources, clock, cellsAfterTs) {
|
|
2902
|
+
function wrunHostRunOf(metadata, sources, clock, site, cellsAfterTs) {
|
|
2447
2903
|
const ohlcvRows = sources.ohlcvRows ?? [];
|
|
2448
2904
|
const reads = checkWrunRowReads(metadata, sources, clock, ohlcvRows.length > 0);
|
|
2449
2905
|
const primaryRows = wrunPrimaryRows(metadata, reads.wires, ohlcvRows);
|
|
@@ -2455,6 +2911,8 @@ function wrunHostRunOf(metadata, sources, clock, cellsAfterTs) {
|
|
|
2455
2911
|
}
|
|
2456
2912
|
if (gridTs.length === 0)
|
|
2457
2913
|
return undefined;
|
|
2914
|
+
if (cellsAfterTs === undefined)
|
|
2915
|
+
windowConversions[site] += 1;
|
|
2458
2916
|
const firstTs = gridTs[0];
|
|
2459
2917
|
const lastTs = gridTs[gridTs.length - 1];
|
|
2460
2918
|
const intervalMs = clock?.intervalMs ?? sources.venue?.intervalMs ?? wrunRowsStepMs(gridTs) ?? Intervals.MINUTE;
|
|
@@ -2479,7 +2937,7 @@ function wrunHostRunOf(metadata, sources, clock, cellsAfterTs) {
|
|
|
2479
2937
|
...wrunRowsOptionsChains(metadata, host),
|
|
2480
2938
|
...wrunRowsCoinLegs(metadata),
|
|
2481
2939
|
};
|
|
2482
|
-
const planned = host.planWrunRun(wrunPlannedSheet(metadata, reads.lanes, stamps, shift, reads.cellLanes), context, 'chart-browser');
|
|
2940
|
+
const planned = host.planWrunRun(wrunPlannedSheet(metadata, reads.lanes, stamps, shift, reads.cellLanes, sources.settings), context, 'chart-browser');
|
|
2483
2941
|
// The session calendar's answers, keyed as the aligner reads them; the intrabar slice below reads
|
|
2484
2942
|
// them too.
|
|
2485
2943
|
const session = wrunSessionAnswersOf(host, planned, sources.session, intervalMs);
|
|
@@ -2490,6 +2948,12 @@ function wrunHostRunOf(metadata, sources, clock, cellsAfterTs) {
|
|
|
2490
2948
|
const laneWires = new Map();
|
|
2491
2949
|
const cellLaneWires = new Map();
|
|
2492
2950
|
const cellLegKeys = new Map();
|
|
2951
|
+
// A banded book input's rows key (`wrunBookBandsKey`), by input; the book lane's rows this build reads (past the
|
|
2952
|
+
// carry on a tail), sliced once for every book input; whether the whole-window adapt rang.
|
|
2953
|
+
const bookBandKeys = new Map();
|
|
2954
|
+
// Each book lane's rows this build reads, by its market ('' the chart's own, `<exchange>|<symbol>` a pinned lane's):
|
|
2955
|
+
// sliced once a build for every input reading it.
|
|
2956
|
+
const bookLaneRows = new Map();
|
|
2493
2957
|
const softRefused = new Set();
|
|
2494
2958
|
// The inputs this market does not need (wrunSheetWithLaneDemand: their needed_by leaves it out), and
|
|
2495
2959
|
// the candles lanes gated off on this chart (wrunSheetWithLaneGate): no lane was asked for them, so
|
|
@@ -2595,13 +3059,16 @@ function wrunHostRunOf(metadata, sources, clock, cellsAfterTs) {
|
|
|
2595
3059
|
intrabarRows.set(leg.fetchKey, read);
|
|
2596
3060
|
return read;
|
|
2597
3061
|
};
|
|
2598
|
-
|
|
2599
|
-
const
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
3062
|
+
// A liquidations lane's per-row totals (buy + sell), once per lane: the chart's own, or a pinned lane's.
|
|
3063
|
+
const liquidationTotals = new Map();
|
|
3064
|
+
const liquidationTotalRows = (rows) => {
|
|
3065
|
+
const lane = rows ?? [];
|
|
3066
|
+
let totals = liquidationTotals.get(lane);
|
|
3067
|
+
if (totals === undefined) {
|
|
3068
|
+
totals = lane.map((row) => [Number(row[0]), Number(row[1]) + Number(row[2])]);
|
|
3069
|
+
liquidationTotals.set(lane, totals);
|
|
3070
|
+
}
|
|
3071
|
+
return totals;
|
|
2605
3072
|
};
|
|
2606
3073
|
// The chart's own candles at the chart's span: the chart's rows first, then the forming
|
|
2607
3074
|
// pre-roll (strictly before the first row: the fold's reach, never a row).
|
|
@@ -2698,26 +3165,62 @@ function wrunHostRunOf(metadata, sources, clock, cellsAfterTs) {
|
|
|
2698
3165
|
const source = requireSource(metadata, wire.inputName);
|
|
2699
3166
|
if (wire.kind === 'cells') {
|
|
2700
3167
|
const ask = askByKey.get(key);
|
|
2701
|
-
if (ask === undefined
|
|
3168
|
+
if (ask === undefined)
|
|
3169
|
+
continue;
|
|
3170
|
+
if (ask.class === 'book') {
|
|
3171
|
+
// The book lane is asked at the sheet's depth already, so its rows are read whole, straight into one f64 block
|
|
3172
|
+
// (WRUN-PANBACK-2 S2, `wrunBookCellRows`); past the carry only (`cellsAfterTs`). A banded input reads its band
|
|
3173
|
+
// sums off the same rows (`wrunBookBandRows`) under a key of its own, its wire re-pointed below: `bands` is no
|
|
3174
|
+
// part of the ask, so a raw and a banded input read one lane and one fetch. A whole-window adapt over a kept
|
|
3175
|
+
// packed block rings once a build.
|
|
3176
|
+
const bands = isWrunBandedBookSource(source)
|
|
3177
|
+
? wrunBookInputBands(metadata, wire.inputName, source.bands)
|
|
3178
|
+
: undefined;
|
|
3179
|
+
const answerKey = bands === undefined ? key : wrunBookBandsKey(key, bands);
|
|
3180
|
+
if (bands !== undefined)
|
|
3181
|
+
bookBandKeys.set(wire.inputIndex, answerKey);
|
|
3182
|
+
if (cellAnswers.has(answerKey))
|
|
3183
|
+
continue;
|
|
3184
|
+
// A foreign ask (a book pinned to another market, wrun-pinned-lanes.util) reads that market's lane, the
|
|
3185
|
+
// chart's own ask the chart's own book: an own book and a pinned one in one package each read their own.
|
|
3186
|
+
const laneKey = ask.foreign === true ? `${ask.exchange}|${ask.symbol}` : '';
|
|
3187
|
+
let laneRows = bookLaneRows.get(laneKey);
|
|
3188
|
+
if (laneRows === undefined) {
|
|
3189
|
+
const rows = ask.foreign === true ? wrunPinnedLaneRowsOf(sources, 'book', ask) : sources.bookRows;
|
|
3190
|
+
laneRows = cellsAfterTs === undefined ? (rows ?? []) : wrunLaneRowsAfter(rows, cellsAfterTs);
|
|
3191
|
+
bookLaneRows.set(laneKey, laneRows);
|
|
3192
|
+
if (cellsAfterTs === undefined)
|
|
3193
|
+
ringWrunBookLaneAdapted(laneRows);
|
|
3194
|
+
}
|
|
3195
|
+
const facts = wrunLaneCellFacts(ask);
|
|
3196
|
+
cellAnswers.set(answerKey, bands === undefined ? wrunBookCellRows(laneRows, facts) : wrunBookBandRows(laneRows, facts, bands));
|
|
2702
3197
|
continue;
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
const adapted = ask.class === 'book' ? { ...ask, max_depth: undefined } : ask;
|
|
3198
|
+
}
|
|
3199
|
+
if (cellAnswers.has(key))
|
|
3200
|
+
continue;
|
|
3201
|
+
const lane = source.source === 'volume_profile'
|
|
3202
|
+
? sources.volumeProfileRows
|
|
3203
|
+
: source.source === 'trade_volume_by_size'
|
|
3204
|
+
? sources.tradeVolumeBySizeRows
|
|
3205
|
+
: source.source === 'tape'
|
|
3206
|
+
? sources.tapeRows
|
|
3207
|
+
: sources.optionsChainRows;
|
|
2714
3208
|
// Past the carry only (`cellsAfterTs`), except the options chain: the live row reads its newest poll, however old.
|
|
2715
3209
|
const rows = wrunPlainLaneRows(cellsAfterTs === undefined || source.source === 'options_chain'
|
|
2716
3210
|
? (lane ?? [])
|
|
2717
3211
|
: wrunLaneRowsAfter(lane, cellsAfterTs));
|
|
2718
|
-
cellAnswers.set(key, host.adaptWrunCells(
|
|
3212
|
+
cellAnswers.set(key, host.adaptWrunCells(ask, rows, wrunLaneCellFacts(ask)));
|
|
2719
3213
|
continue;
|
|
2720
3214
|
}
|
|
3215
|
+
// A typed feed pinned to another market (wrun-pinned-lanes.util): the shared host's foreign ask, answered from the
|
|
3216
|
+
// lane of its class and market. A pin on a venue the gateway does not serve to scripts yet was never asked: its
|
|
3217
|
+
// read is the plan's unserved wire, its fill on every row (a candle pin's rule).
|
|
3218
|
+
const scalarAsk = askByKey.get(key);
|
|
3219
|
+
const pinnedAsk = scalarAsk?.foreign === true && isWrunPinnedLaneClass(source.source) ? scalarAsk : undefined;
|
|
3220
|
+
const pinnedLane = (cls) => wrunPinnedLaneRowsOf(sources, cls, pinnedAsk);
|
|
3221
|
+
if (pinnedAsk !== undefined && wrunPinVenueVerdict(String(pinnedAsk.exchange)) === 'unserved') {
|
|
3222
|
+
softRefused.add(wire.inputIndex);
|
|
3223
|
+
}
|
|
2721
3224
|
switch (source.source) {
|
|
2722
3225
|
case 'trades': {
|
|
2723
3226
|
const lane = wrunSourceLane(source);
|
|
@@ -2735,22 +3238,24 @@ function wrunHostRunOf(metadata, sources, clock, cellsAfterTs) {
|
|
|
2735
3238
|
}
|
|
2736
3239
|
break;
|
|
2737
3240
|
}
|
|
2738
|
-
case 'liquidations':
|
|
3241
|
+
case 'liquidations': {
|
|
3242
|
+
const rows = pinnedAsk !== undefined ? pinnedLane('liquidations') : sources.liquidationRows;
|
|
2739
3243
|
if (source.side === undefined) {
|
|
2740
|
-
offer(key, liquidationTotalRows());
|
|
3244
|
+
offer(key, liquidationTotalRows(rows));
|
|
2741
3245
|
columns.set(wire.inputIndex, 1);
|
|
2742
3246
|
}
|
|
2743
3247
|
else {
|
|
2744
|
-
offer(key,
|
|
3248
|
+
offer(key, rows);
|
|
2745
3249
|
columns.set(wire.inputIndex, source.side === 'SELL' ? 2 : 1);
|
|
2746
3250
|
}
|
|
2747
3251
|
break;
|
|
3252
|
+
}
|
|
2748
3253
|
case 'funding':
|
|
2749
|
-
offer(key, sources.fundingRateRows);
|
|
3254
|
+
offer(key, pinnedAsk !== undefined ? pinnedLane('funding') : sources.fundingRateRows);
|
|
2750
3255
|
columns.set(wire.inputIndex, 1);
|
|
2751
3256
|
break;
|
|
2752
3257
|
case 'oi':
|
|
2753
|
-
offer(key, sources.openInterestRows);
|
|
3258
|
+
offer(key, pinnedAsk !== undefined ? pinnedLane('oi') : sources.openInterestRows);
|
|
2754
3259
|
columns.set(wire.inputIndex, OI_FIELD_COLUMNS[source.field ?? '']);
|
|
2755
3260
|
break;
|
|
2756
3261
|
default:
|
|
@@ -2780,6 +3285,19 @@ function wrunHostRunOf(metadata, sources, clock, cellsAfterTs) {
|
|
|
2780
3285
|
...(laneRead.input.source.missing === 'empty' ? { missing: 'empty' } : {}),
|
|
2781
3286
|
};
|
|
2782
3287
|
}
|
|
3288
|
+
const bandsKey = bookBandKeys.get(wire.inputIndex);
|
|
3289
|
+
if (bandsKey !== undefined) {
|
|
3290
|
+
// A banded book input reads its band sums (`wrunBookBandRows`): their own rows, two values a tuple. The kit's
|
|
3291
|
+
// planner marks the wire for the aligner's own reduction (`bookBands`, kit 0.109 align.ts: the om and cloud
|
|
3292
|
+
// hosts' way); this host reduced already, so the mark comes off here: with it, the exact join would read the
|
|
3293
|
+
// [bid, ask] sums as raw levels and reduce them a second time, to nothing.
|
|
3294
|
+
const { bookBands: _reducedHere, ...reduced } = wire;
|
|
3295
|
+
return {
|
|
3296
|
+
...reduced,
|
|
3297
|
+
fetchKey: bandsKey,
|
|
3298
|
+
cell: { ...wire.cell, tupleWidth: WRUN_BOOK_BAND_TUPLE_WIDTH },
|
|
3299
|
+
};
|
|
3300
|
+
}
|
|
2783
3301
|
const own = cellLegKeys.get(wire.inputIndex);
|
|
2784
3302
|
if (own === undefined)
|
|
2785
3303
|
return wire;
|
|
@@ -2833,20 +3351,92 @@ function wrunHostRunOf(metadata, sources, clock, cellsAfterTs) {
|
|
|
2833
3351
|
const emptyBlocks = metadata.inputs
|
|
2834
3352
|
.filter((input) => !reads.cellLanes.has(input.index) && wrunUnaskedCelledInput(input, metadata.inputSources[input.name]))
|
|
2835
3353
|
.map((input) => input.index);
|
|
2836
|
-
|
|
3354
|
+
// The instant the declared depth counts back from, when it is earlier than the build's now (a session's pin, a
|
|
3355
|
+
// replay's present): a full build splits at it (`wrunAlignHostRows`).
|
|
3356
|
+
const historyAsOfMs = clock === undefined ? nowMs : wrunClockHistoryAsOfMs(clock);
|
|
3357
|
+
return {
|
|
3358
|
+
plan,
|
|
3359
|
+
sources: answered,
|
|
3360
|
+
clock: hostClock,
|
|
3361
|
+
shift,
|
|
3362
|
+
stamps,
|
|
3363
|
+
emptyBlocks,
|
|
3364
|
+
...(historyAsOfMs < nowMs ? { historyAsOfMs } : {}),
|
|
3365
|
+
};
|
|
3366
|
+
}
|
|
3367
|
+
/**
|
|
3368
|
+
* Where a full build splits at its clock's as-of (`WrunAlignClock.historyAsOfMs`), and the clock the rows before the
|
|
3369
|
+
* split align under (the as-of as its now). The split is the open of the first row the as-of has not closed (a row's
|
|
3370
|
+
* bounds: the session's on a venue layer, a calendar row's end), or on a dense primary the bar of the chart's phase
|
|
3371
|
+
* holding the as-of when that comes first, so every row before it closed by the as-of. Undefined (the plain build)
|
|
3372
|
+
* when the clock names no as-of earlier than its now, when no leg names a declared depth (`bars`: for a row the as-of
|
|
3373
|
+
* closed, every other reading of the clock answers the same under either instant), or when no row precedes the split.
|
|
3374
|
+
*/
|
|
3375
|
+
function wrunHistoryAsOfSplit(run) {
|
|
3376
|
+
const asOfMs = run.historyAsOfMs;
|
|
3377
|
+
if (asOfMs === undefined)
|
|
3378
|
+
return undefined;
|
|
3379
|
+
if (!run.plan.wires.some((wire) => wire.kind !== 'time' && wire.leg?.bars !== undefined))
|
|
3380
|
+
return undefined;
|
|
3381
|
+
const grid = run.clock.primaryTs ?? [];
|
|
3382
|
+
if (grid.length === 0)
|
|
3383
|
+
return undefined;
|
|
3384
|
+
const intervalMs = run.clock.intervalMs;
|
|
3385
|
+
const rowBounds = run.clock.rowBounds ?? wrunCalendarRowBounds(intervalMs);
|
|
3386
|
+
const { wrunLegRowBoundsMs } = wrunChartHostEnv().sharedHost();
|
|
3387
|
+
// Rows ascend, and so do their closes: the first one the as-of has not closed, by bisection.
|
|
3388
|
+
let low = 0;
|
|
3389
|
+
let high = grid.length;
|
|
3390
|
+
while (low < high) {
|
|
3391
|
+
const mid = (low + high) >>> 1;
|
|
3392
|
+
if (wrunLegRowBoundsMs(grid[mid], intervalMs, rowBounds).closeMs <= asOfMs)
|
|
3393
|
+
low = mid + 1;
|
|
3394
|
+
else
|
|
3395
|
+
high = mid;
|
|
3396
|
+
}
|
|
3397
|
+
let tailFromTs = low < grid.length ? grid[low] : Number.POSITIVE_INFINITY;
|
|
3398
|
+
// A dense primary walks every bar of the chart's phase, the chart's missing bars too (a fixed span only: a calendar
|
|
3399
|
+
// or session chart walks its own rows).
|
|
3400
|
+
const primary = run.plan.wires[0];
|
|
3401
|
+
if (primary?.kind === 'scalar' && primary.densify === true && primary.unserved !== true && rowBounds === undefined) {
|
|
3402
|
+
tailFromTs = Math.min(tailFromTs, grid[0] + Math.floor((asOfMs - grid[0]) / intervalMs) * intervalMs);
|
|
3403
|
+
}
|
|
3404
|
+
if (!(tailFromTs > grid[0]))
|
|
3405
|
+
return undefined;
|
|
3406
|
+
return { tailFromTs, clock: { ...run.clock, nowMs: asOfMs } };
|
|
3407
|
+
}
|
|
3408
|
+
/**
|
|
3409
|
+
* The shared host's alignment of a full build: the plain one, or split at the clock's as-of (`wrunHistoryAsOfSplit`):
|
|
3410
|
+
* the rows before the split under the as-of, then the tail from the carry they leave under the clock's now. It is the
|
|
3411
|
+
* build a live session made at its first run followed by the tail its drains made since: every reading of a row
|
|
3412
|
+
* matches the plain build's but a declared depth, whose backlog (the leg core's `wrunLegFetchStart`, its `bars`
|
|
3413
|
+
* counted back from the clock's now) counts back from the as-of. So a later run of the session hands its first
|
|
3414
|
+
* delivered row the block that row had, and no row's block outgrows what the input's capacity held then.
|
|
3415
|
+
*/
|
|
3416
|
+
function wrunAlignHostRows(run) {
|
|
3417
|
+
const host = wrunChartHostEnv().sharedHost();
|
|
3418
|
+
const split = wrunHistoryAsOfSplit(run);
|
|
3419
|
+
if (split === undefined)
|
|
3420
|
+
return host.alignWrunRows(run.plan, run.sources, run.clock);
|
|
3421
|
+
const head = host.alignWrunRows(run.plan, run.sources, split.clock).filter((row) => row.ts < split.tailFromTs);
|
|
3422
|
+
if (!Number.isFinite(split.tailFromTs))
|
|
3423
|
+
return head;
|
|
3424
|
+
const carry = host.advanceWrunCarry(run.plan, head, host.emptyWrunInputCarry(), run.sources, split.clock);
|
|
3425
|
+
return [...head, ...host.alignWrunTailRows(run.plan, run.sources, run.clock, split.tailFromTs, carry)];
|
|
2837
3426
|
}
|
|
2838
3427
|
/** The host's rows as the browser packs them: the scalar block (the prepended chart close
|
|
2839
3428
|
* dropped), and the celled inputs' blocks by the sheet's input index (absent when the row carries
|
|
2840
3429
|
* none; a present empty block for a candles lane gated off on this chart, `emptyBlocks`); the
|
|
2841
|
-
* strategy bar rides the broker feed. A block is the host's own array for this build
|
|
2842
|
-
* writes to it, so it rides uncopied: `packWrunRows` makes
|
|
3430
|
+
* strategy bar rides the broker feed. A block is the host's own array for this build, or a view of the book
|
|
3431
|
+
* adapter's own f64 block (`wrunPackerBlock`), and nothing writes to it, so it rides uncopied: `packWrunRows` makes
|
|
3432
|
+
* the one copy. */
|
|
2843
3433
|
function wrunBrowserRowsOf(rows, run) {
|
|
2844
3434
|
const { shift, emptyBlocks } = run;
|
|
2845
3435
|
return rows.map((row) => {
|
|
2846
3436
|
let cellBlocks;
|
|
2847
3437
|
if (row.cellBlocks !== undefined) {
|
|
2848
3438
|
for (const [index, block] of Object.entries(row.cellBlocks)) {
|
|
2849
|
-
(cellBlocks ??= new Map()).set(Number(index) - shift,
|
|
3439
|
+
(cellBlocks ??= new Map()).set(Number(index) - shift, wrunPackerBlock(block));
|
|
2850
3440
|
}
|
|
2851
3441
|
}
|
|
2852
3442
|
for (const index of emptyBlocks)
|
|
@@ -2859,6 +3449,15 @@ function wrunBrowserRowsOf(rows, run) {
|
|
|
2859
3449
|
return { ts: row.ts, values, ...(cellBlocks !== undefined ? { cellBlocks } : {}) };
|
|
2860
3450
|
});
|
|
2861
3451
|
}
|
|
3452
|
+
/** A cell block as the packer takes it: an array as it is, a view of the book adapter's own f64 block uncopied (no one
|
|
3453
|
+
* writes to it), any other array-like copied to an array. */
|
|
3454
|
+
function wrunPackerBlock(block) {
|
|
3455
|
+
if (Array.isArray(block))
|
|
3456
|
+
return block;
|
|
3457
|
+
if (block instanceof Float64Array && WRUN_BOOK_CELL_BUFFERS.has(block.buffer))
|
|
3458
|
+
return block;
|
|
3459
|
+
return Array.from(block);
|
|
3460
|
+
}
|
|
2862
3461
|
/** The browser's rows as the host's carry reads them (a replay reads the last stamp; a carry
|
|
2863
3462
|
* input's value off the rows when there is nothing to replay). */
|
|
2864
3463
|
function wrunHostRowsOf(rows, shift) {
|
|
@@ -2880,13 +3479,40 @@ export function emptyWrunInputCarry() {
|
|
|
2880
3479
|
* session venue or a daily-landed lane, where it walks the chart's own rows too
|
|
2881
3480
|
* (`wrunNeedsChartPrimary`). `clock` is required when any input pins a leg, a typed feed or a daily
|
|
2882
3481
|
* lane (the as-of alignment), and carries the chart's exact interval: a calendar chart is known by
|
|
2883
|
-
* it.
|
|
3482
|
+
* it. A clock naming an as-of earlier than its now (`historyAsOfMs`: a live session's pin, a replay's
|
|
3483
|
+
* present) splits the build there (`wrunAlignHostRows`), so each declared depth counts back from it.
|
|
2884
3484
|
*/
|
|
2885
3485
|
export function buildWrunInputRows(metadata, sources, clock) {
|
|
2886
|
-
const run = wrunHostRunOf(metadata, sources, clock);
|
|
3486
|
+
const run = wrunHostRunOf(metadata, sources, clock, 'build');
|
|
2887
3487
|
if (run === undefined)
|
|
2888
3488
|
return [];
|
|
2889
|
-
return wrunBrowserRowsOf(
|
|
3489
|
+
return wrunBrowserRowsOf(wrunAlignHostRows(run), run);
|
|
3490
|
+
}
|
|
3491
|
+
/**
|
|
3492
|
+
* `buildWrunInputRows` and the carry seed a session takes from it, from ONE conversion of the window's lanes: the rows
|
|
3493
|
+
* exactly as `buildWrunInputRows(metadata, sources, clock)` builds them, and the carry exactly as
|
|
3494
|
+
* `advanceWrunInputCarry(metadata, emptyWrunInputCarry(), rows.slice(0, -1), sources, clock)` advances it (a full run's
|
|
3495
|
+
* and a reseed's seed). That advance runs `wrunHostRunOf` again with the build's own arguments: the empty seed names no
|
|
3496
|
+
* `throughTs`, so no lane row is skipped, and rows to advance over are the chart rows' own (its replay branch), so it
|
|
3497
|
+
* converts every celled lane row of the window a second time. Here the carry advances on the build's run instead.
|
|
3498
|
+
*
|
|
3499
|
+
* The run reads the sources once, as they stand at the call: a caller that awaits before it seeds the carry (the
|
|
3500
|
+
* worker's answer) gets the carry of the rows it evaluated, never of buffers rewritten in place meanwhile.
|
|
3501
|
+
*/
|
|
3502
|
+
export function buildWrunInputRowsAndCarry(metadata, sources, clock) {
|
|
3503
|
+
const host = wrunChartHostEnv().sharedHost();
|
|
3504
|
+
const seed = host.emptyWrunInputCarry();
|
|
3505
|
+
const run = wrunHostRunOf(metadata, sources, clock, 'combined');
|
|
3506
|
+
const rows = run === undefined ? [] : wrunBrowserRowsOf(wrunAlignHostRows(run), run);
|
|
3507
|
+
const closedRows = rows.slice(0, -1);
|
|
3508
|
+
if (run === undefined || closedRows.length === 0)
|
|
3509
|
+
return { rows, carry: host.cloneWrunInputCarry(seed) };
|
|
3510
|
+
// A run's grid is the chart rows' own, so rows to advance over mean chart rows: the advance's replay branch, on this
|
|
3511
|
+
// run. Without chart rows the advance plans over the rows' stamps, another run, which it makes itself.
|
|
3512
|
+
const replay = sources.ohlcvRows !== undefined && sources.ohlcvRows.length > 0;
|
|
3513
|
+
if (!replay)
|
|
3514
|
+
return { rows, carry: advanceWrunInputCarry(metadata, seed, closedRows, sources, clock) };
|
|
3515
|
+
return { rows, carry: wrunCarryOverRun(host, run, seed, closedRows, true) };
|
|
2890
3516
|
}
|
|
2891
3517
|
/**
|
|
2892
3518
|
* The TAIL of the full build: the input rows for every primary bar at or after `fromTs`, resumed
|
|
@@ -2895,7 +3521,7 @@ export function buildWrunInputRows(metadata, sources, clock) {
|
|
|
2895
3521
|
* >= fromTs)` (the host's `alignWrunTailRows`).
|
|
2896
3522
|
*/
|
|
2897
3523
|
export function buildWrunInputTailRows(metadata, sources, fromTs, carrySeed, clock) {
|
|
2898
|
-
const run = wrunHostRunOf(metadata, sources, clock, carrySeed.throughTs);
|
|
3524
|
+
const run = wrunHostRunOf(metadata, sources, clock, 'tail', carrySeed.throughTs);
|
|
2899
3525
|
if (run === undefined)
|
|
2900
3526
|
return [];
|
|
2901
3527
|
return wrunBrowserRowsOf(wrunChartHostEnv().sharedHost().alignWrunTailRows(run.plan, run.sources, run.clock, fromTs, carrySeed), run);
|
|
@@ -2905,21 +3531,40 @@ export function buildWrunInputTailRows(metadata, sources, fromTs, carrySeed, clo
|
|
|
2905
3531
|
* full build holds after them (the host's `advanceWrunCarry`: the aligner's own pass replayed
|
|
2906
3532
|
* through the last closed row over the same rows and clock; with no rows handed in, a plan that
|
|
2907
3533
|
* reads no leg advances from the rows' carry values alone). Returns a NEW carry; the seed is never
|
|
2908
|
-
* mutated.
|
|
3534
|
+
* mutated. From the empty seed, a clock naming an as-of advances the way the full build aligned
|
|
3535
|
+
* (`wrunHistoryAsOfSplit`): under the as-of through the split, then under the clock. `site` names the conversion
|
|
3536
|
+
* count it moves (`advance`, or `recovered` for the advance that replaces a combined build's moved carry).
|
|
2909
3537
|
*/
|
|
2910
|
-
export function advanceWrunInputCarry(metadata, seed, closedRows, sources, clock) {
|
|
3538
|
+
export function advanceWrunInputCarry(metadata, seed, closedRows, sources, clock, site = 'advance') {
|
|
2911
3539
|
const host = wrunChartHostEnv().sharedHost();
|
|
2912
3540
|
if (closedRows.length === 0)
|
|
2913
3541
|
return host.cloneWrunInputCarry(seed);
|
|
2914
3542
|
const replay = sources?.ohlcvRows !== undefined && sources.ohlcvRows.length > 0;
|
|
2915
3543
|
// With no chart rows handed in, the committed rows' stamps stand for them (the plan alone).
|
|
2916
|
-
const run = wrunHostRunOf(metadata, replay ? sources : { ...sources, ohlcvRows: closedRows.map((row) => [row.ts]) }, clock, seed.throughTs);
|
|
3544
|
+
const run = wrunHostRunOf(metadata, replay ? sources : { ...sources, ohlcvRows: closedRows.map((row) => [row.ts]) }, clock, site, seed.throughTs);
|
|
2917
3545
|
if (run === undefined)
|
|
2918
3546
|
return host.cloneWrunInputCarry(seed);
|
|
3547
|
+
return wrunCarryOverRun(host, run, seed, closedRows, replay);
|
|
3548
|
+
}
|
|
3549
|
+
/**
|
|
3550
|
+
* The carry advance on a run already made (`advanceWrunInputCarry` past its `wrunHostRunOf`, and
|
|
3551
|
+
* `buildWrunInputRowsAndCarry` on its build's run): `replay`, the aligner's own pass replayed through the last closed
|
|
3552
|
+
* row over the run's rows and clock, from the empty seed split at the clock's as-of as the full build aligned; else the
|
|
3553
|
+
* plan alone over the rows' carry values.
|
|
3554
|
+
*/
|
|
3555
|
+
function wrunCarryOverRun(host, run, seed, closedRows, replay) {
|
|
2919
3556
|
const rows = wrunHostRowsOf(closedRows, run.shift);
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
3557
|
+
if (!replay)
|
|
3558
|
+
return host.advanceWrunCarry(run.plan, rows, seed);
|
|
3559
|
+
const split = seed.throughTs === undefined ? wrunHistoryAsOfSplit(run) : undefined;
|
|
3560
|
+
if (split === undefined)
|
|
3561
|
+
return host.advanceWrunCarry(run.plan, rows, seed, run.sources, run.clock);
|
|
3562
|
+
const before = rows.filter((row) => row.ts < split.tailFromTs);
|
|
3563
|
+
const after = rows.filter((row) => row.ts >= split.tailFromTs);
|
|
3564
|
+
const carry = before.length > 0 ? host.advanceWrunCarry(run.plan, before, seed, run.sources, split.clock) : seed;
|
|
3565
|
+
if (after.length > 0)
|
|
3566
|
+
return host.advanceWrunCarry(run.plan, after, carry, run.sources, run.clock);
|
|
3567
|
+
return before.length > 0 ? carry : host.cloneWrunInputCarry(seed);
|
|
2923
3568
|
}
|
|
2924
3569
|
/** init()'s positional argument block: declared param defaults overlaid with
|
|
2925
3570
|
* any user-provided values by param name (wrunParamValuesFromSettings reads
|