@orangecharts/wrun-chart-host 0.2.0 → 0.3.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 +14 -6
- 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/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 +161 -5
- package/dist/host-ports.types.d.ts +446 -0
- package/dist/host-ports.types.js +1 -0
- package/dist/index.d.ts +128 -0
- package/dist/index.js +128 -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/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/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/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/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 +30 -0
- package/dist/utility/wrun/sources/lanes/option_daily.js +53 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +23 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.js +20 -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 +196 -0
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +446 -0
- package/dist/utility/wrun/sources/registry.d.ts +21 -0
- package/dist/utility/wrun/sources/registry.js +207 -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 +6 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +70 -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 +13 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +137 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +38 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +150 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +275 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.js +26 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +224 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +394 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +283 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.js +16 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +205 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +469 -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 +30 -0
- package/dist/utility/wrun/wrun-opra-stats.leaf.js +96 -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-param-map.util.d.ts +298 -0
- package/dist/utility/wrun/wrun-param-map.util.js +581 -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-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-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,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `tape` input source's browser-side contract (WRUN-BIG-TRADES-PLAN C1): how a package's
|
|
3
|
+
* `inputSources.<name> = { source: "tape", min_size, history }` becomes the ONE acquisition the
|
|
4
|
+
* K_TRADES large lane fetches and the live intake folds. Pure: no store, no chart, no fetch; the
|
|
5
|
+
* run pass calls it at its head, before any lane fetch, so every refusal here lands by name and
|
|
6
|
+
* at zero fetches.
|
|
7
|
+
*
|
|
8
|
+
* - `min_size: number | string`. A number literal is the smallest print size served (base units:
|
|
9
|
+
* contracts on futures, coins on crypto). A string names a declared numeric `param`, resolved
|
|
10
|
+
* from the run's CURRENT param values (`wrunParamValuesFromSettings`, the values `init()`
|
|
11
|
+
* receives, so a settings edit moves the threshold with the module). The resolved value must be
|
|
12
|
+
* finite and above zero, else the run refuses `wrun_tape_min_size_invalid` naming the input and
|
|
13
|
+
* the param. `min_size` rides the wire as the gateway's `minAmount` (the K_TRADES worker), so an
|
|
14
|
+
* unfiltered tape is never requested. The table's own floor ($10k quote on USD-quoted markets)
|
|
15
|
+
* is a fact a package cannot lower: a `min_size` below it is served at the floor (documented,
|
|
16
|
+
* never enforced here).
|
|
17
|
+
* - `history: "0" | <duration>`: `"0"` (the default) is the live edge only; a duration
|
|
18
|
+
* `^\d+(s|m|h|d)$` seeds that much history from TRADE_LARGE, at most `WRUN_TAPE_HISTORY_MAX_SEC`
|
|
19
|
+
* (30 days); a zero-length spelling ("0m") is the live edge too. Anything else refuses
|
|
20
|
+
* `wrun_tape_history_invalid`. The lane serves `min(history, the chart's loaded window)`, and no
|
|
21
|
+
* more than the gateway's bar limit lets it today (`WRUN_TAPE_HISTORY_SERVED_MAX_SEC`: 15,000
|
|
22
|
+
* one-minute points, about 10.4 days; k-trades.control.ts opens the ask at the first bar after it),
|
|
23
|
+
* so the acquisition's `historySeconds` is the history served, capped there; `history` stays the
|
|
24
|
+
* declared spelling the K_TRADES payload carries.
|
|
25
|
+
* - Every tape input of a package must be celled (`cellType: "array"`) and resolve to the SAME
|
|
26
|
+
* `min_size` and `history`: the browser lane serves one tape acquisition per package (one
|
|
27
|
+
* K_TRADES fetch, one live fold), and silently serving a second input at the first input's
|
|
28
|
+
* threshold would be a wrong-but-plausible block. Two inputs that differ refuse by name.
|
|
29
|
+
* The om daemon shares the vocabulary (`wrun_tape_min_size_invalid`, `wrun_tape_history_invalid`).
|
|
30
|
+
*/
|
|
31
|
+
import type { WrunIndicatorMetadata, WrunInputSource } from '../../interfaces/wrun-runtime.interface.js';
|
|
32
|
+
/** A tape `min_size` that resolves to nothing servable (absent, a param the package does not
|
|
33
|
+
* declare, non-finite or not above zero). */
|
|
34
|
+
export declare const WRUN_TAPE_MIN_SIZE_INVALID_CODE = "wrun_tape_min_size_invalid";
|
|
35
|
+
/** A tape `history` outside the contract ("0" or `^\d+(s|m|h|d)$` at most 30 days). */
|
|
36
|
+
export declare const WRUN_TAPE_HISTORY_INVALID_CODE = "wrun_tape_history_invalid";
|
|
37
|
+
/** A tape input on a chart interval the lane does not serve (a one-second or any sub-minute chart, a
|
|
38
|
+
* calendar interval of a month or coarser): the shared host's refusal code (`WrunHostRefusalCode`,
|
|
39
|
+
* the kit's `WRUN_TAPE_INTERVAL_UNSUPPORTED_CODE`), whose words its `wrunRefusalMessage` gives. */
|
|
40
|
+
export declare const WRUN_TAPE_INTERVAL_UNSUPPORTED_CODE = "wrun_tape_interval_unsupported";
|
|
41
|
+
/** The longest tape history a package may declare, in seconds (30 days). */
|
|
42
|
+
export declare const WRUN_TAPE_HISTORY_MAX_SEC = 2592000;
|
|
43
|
+
/** The longest tape history the lane serves today, in seconds: the gateway's bar limit on an
|
|
44
|
+
* unaggregated read (TRADES_LARGE_BAR_LIMIT_SEC, about 10.4 days). A longer declared history (up to
|
|
45
|
+
* the 30-day contract) is served from that horizon. */
|
|
46
|
+
export declare const WRUN_TAPE_HISTORY_SERVED_MAX_SEC: number;
|
|
47
|
+
/** The one tape acquisition a package resolves to: the K_TRADES payload extras the history fetch
|
|
48
|
+
* and the reconcile ride (`minSize` in base units, `history` as declared), plus the inputs it
|
|
49
|
+
* serves. */
|
|
50
|
+
export interface WrunTapeAcquisition {
|
|
51
|
+
minSize: number;
|
|
52
|
+
history: string;
|
|
53
|
+
/** The history served, in seconds: the declared one, capped at WRUN_TAPE_HISTORY_SERVED_MAX_SEC. */
|
|
54
|
+
historySeconds: number;
|
|
55
|
+
/** The tape inputs, by name, in declaration order. */
|
|
56
|
+
inputNames: string[];
|
|
57
|
+
}
|
|
58
|
+
/** The declared `history` as the lane reads it: "0" when absent. */
|
|
59
|
+
export declare function wrunTapeHistoryOf(source: Pick<WrunInputSource, 'history'>): string;
|
|
60
|
+
/** The seconds a valid tape history declares (0 for the live edge), or a refusal by name. */
|
|
61
|
+
export declare function parseWrunTapeHistory(metadata: Pick<WrunIndicatorMetadata, 'id'>, inputName: string, history: string): number;
|
|
62
|
+
/** The smallest print size a tape input serves: the literal, or the named param's current value;
|
|
63
|
+
* refused by name when it is not finite and above zero (an unfiltered tape is the one request the
|
|
64
|
+
* lane never makes). */
|
|
65
|
+
export declare function resolveWrunTapeMinSize(metadata: Pick<WrunIndicatorMetadata, 'id' | 'params'>, inputName: string, source: Pick<WrunInputSource, 'min_size'>, paramValues: Readonly<Record<string, number>>): number;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve every declared tape input against the run's param values into the package's one tape
|
|
68
|
+
* acquisition, refusing by name before any fetch; undefined when the package declares no tape
|
|
69
|
+
* input.
|
|
70
|
+
*/
|
|
71
|
+
export declare function resolveWrunTapeAcquisition(metadata: Pick<WrunIndicatorMetadata, 'id' | 'params' | 'inputs' | 'inputSources'>, paramValues: Readonly<Record<string, number>>): WrunTapeAcquisition | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* The settings a row build hands the shared host's plan for a param-bound floor
|
|
74
|
+
* (`WrunChartSourceRows.settings`): the floor the lane's acquisition was asked at, under the name
|
|
75
|
+
* of every param a tape input's `min_size` names. The host resolves that floor itself from the
|
|
76
|
+
* settings it is handed (its planTapeFloors), so the plan's tape ask carries the floor the run
|
|
77
|
+
* resolved from the overlay's current settings (`resolveWrunTapeAcquisition`): a full run hands its
|
|
78
|
+
* acquisition's floor, a live build its session's (`context.acquisition.tape`), so a tail, a carry
|
|
79
|
+
* advance or a reseed plans the ask its full run planned whatever the settings say meanwhile (a
|
|
80
|
+
* refused settings run keeps the session). Undefined without a finite floor or a bound param.
|
|
81
|
+
*/
|
|
82
|
+
export declare function wrunTapeFloorSettings(metadata: Pick<WrunIndicatorMetadata, 'inputSources'>, minSize: unknown): Record<string, number> | undefined;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `tape` input source's browser-side contract (WRUN-BIG-TRADES-PLAN C1): how a package's
|
|
3
|
+
* `inputSources.<name> = { source: "tape", min_size, history }` becomes the ONE acquisition the
|
|
4
|
+
* K_TRADES large lane fetches and the live intake folds. Pure: no store, no chart, no fetch; the
|
|
5
|
+
* run pass calls it at its head, before any lane fetch, so every refusal here lands by name and
|
|
6
|
+
* at zero fetches.
|
|
7
|
+
*
|
|
8
|
+
* - `min_size: number | string`. A number literal is the smallest print size served (base units:
|
|
9
|
+
* contracts on futures, coins on crypto). A string names a declared numeric `param`, resolved
|
|
10
|
+
* from the run's CURRENT param values (`wrunParamValuesFromSettings`, the values `init()`
|
|
11
|
+
* receives, so a settings edit moves the threshold with the module). The resolved value must be
|
|
12
|
+
* finite and above zero, else the run refuses `wrun_tape_min_size_invalid` naming the input and
|
|
13
|
+
* the param. `min_size` rides the wire as the gateway's `minAmount` (the K_TRADES worker), so an
|
|
14
|
+
* unfiltered tape is never requested. The table's own floor ($10k quote on USD-quoted markets)
|
|
15
|
+
* is a fact a package cannot lower: a `min_size` below it is served at the floor (documented,
|
|
16
|
+
* never enforced here).
|
|
17
|
+
* - `history: "0" | <duration>`: `"0"` (the default) is the live edge only; a duration
|
|
18
|
+
* `^\d+(s|m|h|d)$` seeds that much history from TRADE_LARGE, at most `WRUN_TAPE_HISTORY_MAX_SEC`
|
|
19
|
+
* (30 days); a zero-length spelling ("0m") is the live edge too. Anything else refuses
|
|
20
|
+
* `wrun_tape_history_invalid`. The lane serves `min(history, the chart's loaded window)`, and no
|
|
21
|
+
* more than the gateway's bar limit lets it today (`WRUN_TAPE_HISTORY_SERVED_MAX_SEC`: 15,000
|
|
22
|
+
* one-minute points, about 10.4 days; k-trades.control.ts opens the ask at the first bar after it),
|
|
23
|
+
* so the acquisition's `historySeconds` is the history served, capped there; `history` stays the
|
|
24
|
+
* declared spelling the K_TRADES payload carries.
|
|
25
|
+
* - Every tape input of a package must be celled (`cellType: "array"`) and resolve to the SAME
|
|
26
|
+
* `min_size` and `history`: the browser lane serves one tape acquisition per package (one
|
|
27
|
+
* K_TRADES fetch, one live fold), and silently serving a second input at the first input's
|
|
28
|
+
* threshold would be a wrong-but-plausible block. Two inputs that differ refuse by name.
|
|
29
|
+
* The om daemon shares the vocabulary (`wrun_tape_min_size_invalid`, `wrun_tape_history_invalid`).
|
|
30
|
+
*/
|
|
31
|
+
import { TRADES_LARGE_BAR_LIMIT_SEC } from '../../kscript-data/controls/live-trades-merge.util.js';
|
|
32
|
+
/** A tape `min_size` that resolves to nothing servable (absent, a param the package does not
|
|
33
|
+
* declare, non-finite or not above zero). */
|
|
34
|
+
export const WRUN_TAPE_MIN_SIZE_INVALID_CODE = 'wrun_tape_min_size_invalid';
|
|
35
|
+
/** A tape `history` outside the contract ("0" or `^\d+(s|m|h|d)$` at most 30 days). */
|
|
36
|
+
export const WRUN_TAPE_HISTORY_INVALID_CODE = 'wrun_tape_history_invalid';
|
|
37
|
+
/** A tape input on a chart interval the lane does not serve (a one-second or any sub-minute chart, a
|
|
38
|
+
* calendar interval of a month or coarser): the shared host's refusal code (`WrunHostRefusalCode`,
|
|
39
|
+
* the kit's `WRUN_TAPE_INTERVAL_UNSUPPORTED_CODE`), whose words its `wrunRefusalMessage` gives. */
|
|
40
|
+
export const WRUN_TAPE_INTERVAL_UNSUPPORTED_CODE = 'wrun_tape_interval_unsupported';
|
|
41
|
+
/** The longest tape history a package may declare, in seconds (30 days). */
|
|
42
|
+
export const WRUN_TAPE_HISTORY_MAX_SEC = 2_592_000;
|
|
43
|
+
/** The longest tape history the lane serves today, in seconds: the gateway's bar limit on an
|
|
44
|
+
* unaggregated read (TRADES_LARGE_BAR_LIMIT_SEC, about 10.4 days). A longer declared history (up to
|
|
45
|
+
* the 30-day contract) is served from that horizon. */
|
|
46
|
+
export const WRUN_TAPE_HISTORY_SERVED_MAX_SEC = TRADES_LARGE_BAR_LIMIT_SEC;
|
|
47
|
+
const WRUN_TAPE_HISTORY_PATTERN = /^(\d+)(s|m|h|d)$/;
|
|
48
|
+
const WRUN_TAPE_HISTORY_UNIT_SEC = { s: 1, m: 60, h: 3600, d: 86_400 };
|
|
49
|
+
/** The declared `history` as the lane reads it: "0" when absent. */
|
|
50
|
+
export function wrunTapeHistoryOf(source) {
|
|
51
|
+
return source.history === undefined ? '0' : String(source.history);
|
|
52
|
+
}
|
|
53
|
+
/** The seconds a valid tape history declares (0 for the live edge), or a refusal by name. */
|
|
54
|
+
export function parseWrunTapeHistory(metadata, inputName, history) {
|
|
55
|
+
if (history === '0')
|
|
56
|
+
return 0;
|
|
57
|
+
const match = WRUN_TAPE_HISTORY_PATTERN.exec(history);
|
|
58
|
+
if (!match) {
|
|
59
|
+
throw new Error(`WRUN ${metadata.id}: input '${inputName}' (tape) declares history '${history}' (${WRUN_TAPE_HISTORY_INVALID_CODE}): ` +
|
|
60
|
+
'history is "0" (live prints only) or a duration such as "30m", "12h" or "7d"');
|
|
61
|
+
}
|
|
62
|
+
const seconds = Number(match[1]) * WRUN_TAPE_HISTORY_UNIT_SEC[match[2]];
|
|
63
|
+
if (!Number.isFinite(seconds) || seconds > WRUN_TAPE_HISTORY_MAX_SEC) {
|
|
64
|
+
throw new Error(`WRUN ${metadata.id}: input '${inputName}' (tape) declares history '${history}', over the 30-day cap ` +
|
|
65
|
+
`(${WRUN_TAPE_HISTORY_INVALID_CODE}): the large-print lane serves at most 30 days of history`);
|
|
66
|
+
}
|
|
67
|
+
return seconds;
|
|
68
|
+
}
|
|
69
|
+
/** The smallest print size a tape input serves: the literal, or the named param's current value;
|
|
70
|
+
* refused by name when it is not finite and above zero (an unfiltered tape is the one request the
|
|
71
|
+
* lane never makes). */
|
|
72
|
+
export function resolveWrunTapeMinSize(metadata, inputName, source, paramValues) {
|
|
73
|
+
const declared = source.min_size;
|
|
74
|
+
const refuse = (detail) => {
|
|
75
|
+
throw new Error(`WRUN ${metadata.id}: input '${inputName}' (tape) ${detail} (${WRUN_TAPE_MIN_SIZE_INVALID_CODE})`);
|
|
76
|
+
};
|
|
77
|
+
if (typeof declared === 'string') {
|
|
78
|
+
if (!metadata.params.some((param) => param.name === declared)) {
|
|
79
|
+
return refuse(`binds min_size to param '${declared}', which the package does not declare: min_size is a positive ` +
|
|
80
|
+
'number or the name of a numeric param');
|
|
81
|
+
}
|
|
82
|
+
const value = Number(paramValues[declared]);
|
|
83
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
84
|
+
return refuse(`binds min_size to param '${declared}', which is ${String(paramValues[declared])}: the smallest print ` +
|
|
85
|
+
'size must be finite and above zero');
|
|
86
|
+
}
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
if (declared === undefined) {
|
|
90
|
+
return refuse('declares no min_size: the smallest print size to serve is required (a positive number or the name of a ' +
|
|
91
|
+
'numeric param)');
|
|
92
|
+
}
|
|
93
|
+
const value = Number(declared);
|
|
94
|
+
if (typeof declared !== 'number' || !Number.isFinite(value) || value <= 0) {
|
|
95
|
+
return refuse(`declares min_size ${JSON.stringify(declared)}: the smallest print size must be finite and above zero`);
|
|
96
|
+
}
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Resolve every declared tape input against the run's param values into the package's one tape
|
|
101
|
+
* acquisition, refusing by name before any fetch; undefined when the package declares no tape
|
|
102
|
+
* input.
|
|
103
|
+
*/
|
|
104
|
+
export function resolveWrunTapeAcquisition(metadata, paramValues) {
|
|
105
|
+
let acquisition;
|
|
106
|
+
const inputs = [...metadata.inputs].sort((a, b) => a.index - b.index);
|
|
107
|
+
for (const input of inputs) {
|
|
108
|
+
const source = metadata.inputSources[input.name];
|
|
109
|
+
if (!source || source.source !== 'tape')
|
|
110
|
+
continue;
|
|
111
|
+
const name = input.name;
|
|
112
|
+
if (input.cellType !== 'array') {
|
|
113
|
+
throw new Error(`WRUN ${metadata.id}: input '${name}' (tape) is not celled: declare cellType "array" with max_cells`);
|
|
114
|
+
}
|
|
115
|
+
const history = wrunTapeHistoryOf(source);
|
|
116
|
+
const historySeconds = Math.min(parseWrunTapeHistory(metadata, name, history), WRUN_TAPE_HISTORY_SERVED_MAX_SEC);
|
|
117
|
+
const minSize = resolveWrunTapeMinSize(metadata, name, source, paramValues);
|
|
118
|
+
if (acquisition === undefined) {
|
|
119
|
+
acquisition = { minSize, history, historySeconds, inputNames: [name] };
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (acquisition.minSize !== minSize || acquisition.historySeconds !== historySeconds) {
|
|
123
|
+
throw new Error(`WRUN ${metadata.id}: input '${name}' (tape) resolves to min_size ${minSize} and history '${history}', but ` +
|
|
124
|
+
`input '${acquisition.inputNames[0]}' resolves to min_size ${acquisition.minSize} and history ` +
|
|
125
|
+
`'${acquisition.history}': the browser lane serves one tape acquisition per package`);
|
|
126
|
+
}
|
|
127
|
+
acquisition.inputNames.push(name);
|
|
128
|
+
}
|
|
129
|
+
return acquisition;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The settings a row build hands the shared host's plan for a param-bound floor
|
|
133
|
+
* (`WrunChartSourceRows.settings`): the floor the lane's acquisition was asked at, under the name
|
|
134
|
+
* of every param a tape input's `min_size` names. The host resolves that floor itself from the
|
|
135
|
+
* settings it is handed (its planTapeFloors), so the plan's tape ask carries the floor the run
|
|
136
|
+
* resolved from the overlay's current settings (`resolveWrunTapeAcquisition`): a full run hands its
|
|
137
|
+
* acquisition's floor, a live build its session's (`context.acquisition.tape`), so a tail, a carry
|
|
138
|
+
* advance or a reseed plans the ask its full run planned whatever the settings say meanwhile (a
|
|
139
|
+
* refused settings run keeps the session). Undefined without a finite floor or a bound param.
|
|
140
|
+
*/
|
|
141
|
+
export function wrunTapeFloorSettings(metadata, minSize) {
|
|
142
|
+
const floor = Number(minSize);
|
|
143
|
+
if (minSize === undefined || minSize === null || !Number.isFinite(floor))
|
|
144
|
+
return undefined;
|
|
145
|
+
let settings;
|
|
146
|
+
for (const source of Object.values(metadata.inputSources)) {
|
|
147
|
+
if (source?.source === 'tape' && typeof source.min_size === 'string')
|
|
148
|
+
(settings ??= {})[source.min_size] = floor;
|
|
149
|
+
}
|
|
150
|
+
return settings;
|
|
151
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { type LiveBucketVenue } from '../chart/live-bucket.util.js';
|
|
2
|
+
/** One backend tier a per-bar class is read at: its bucket width, and how long the backend keeps it
|
|
3
|
+
* (`retentionMs`; absent: kept for good). `key` names it in an ask (the interval word the lane's K control
|
|
4
|
+
* asks the tier by). */
|
|
5
|
+
export interface WrunBackendTier {
|
|
6
|
+
key: string;
|
|
7
|
+
ms: number;
|
|
8
|
+
retentionMs?: number;
|
|
9
|
+
/** How long after a bar ends this tier may serve it: an aggregate materialized only by a refresh job holds no
|
|
10
|
+
* forming bucket and lands a closed one at its next refresh; a governed tier also waits out a delayed read's
|
|
11
|
+
* window lag, so the bucket holding that read's end (served whole) is never younger than the delay. Absent: served
|
|
12
|
+
* as it forms. Read by the coarsest choice only. */
|
|
13
|
+
servedLagMs?: number;
|
|
14
|
+
}
|
|
15
|
+
/** How a tier's rows fold onto one host bar: summed (a flow) or the newest sealed row (a snapshot). */
|
|
16
|
+
export type WrunTierLanding = 'flow' | 'snapshot';
|
|
17
|
+
/** Which fitting tier builds a host bar: `finest` (rule 9, every lane's default) or `coarsest` (a lane whose fold is
|
|
18
|
+
* tier-invariant: the coarsest fitting tier that retains the bar and already serves it, so fewer buckets are read). */
|
|
19
|
+
export type WrunTierChoice = 'finest' | 'coarsest';
|
|
20
|
+
/** Whether a tier fits a host bar: its width divides the bar's span (a day for a calendar bar) and the bar's
|
|
21
|
+
* open sits on the tier's UTC grid, so the bar is a whole number of the tier's buckets. */
|
|
22
|
+
export declare function wrunTierFitsBar(tier: Pick<WrunBackendTier, 'ms'>, barOpenMs: number, barMs: number): boolean;
|
|
23
|
+
/** The finest tier that fits a host bar (the one its live bar is built from), or undefined when none fits
|
|
24
|
+
* (a bar finer than every tier, or one whose open sits on no tier's grid). */
|
|
25
|
+
export declare function wrunFinestTier(tiers: readonly WrunBackendTier[], barOpenMs: number, barMs: number): WrunBackendTier | undefined;
|
|
26
|
+
/** One host bar's tier: the fitting tier the choice picks among those that still retain it (the finest by default),
|
|
27
|
+
* and whether it is partial (no fitting tier retains it any more: `tier` is then the finest fitting one, or undefined
|
|
28
|
+
* when none fits at all). */
|
|
29
|
+
export interface WrunBarTier {
|
|
30
|
+
barOpenMs: number;
|
|
31
|
+
tier?: WrunBackendTier;
|
|
32
|
+
partial: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** The tier rule over a host grid's bar opens (ascending): each bar's fitting tier that still retains it (the
|
|
35
|
+
* finest, or with `choice: 'coarsest'` the coarsest that already serves the bar), else partial. */
|
|
36
|
+
export declare function wrunBarTiers(args: {
|
|
37
|
+
tiers: readonly WrunBackendTier[];
|
|
38
|
+
barOpens: readonly number[];
|
|
39
|
+
barMs: number;
|
|
40
|
+
nowMs: number;
|
|
41
|
+
choice?: WrunTierChoice;
|
|
42
|
+
}): WrunBarTier[];
|
|
43
|
+
/** One ask of a tier-planned fetch: a tier and the span of host bars it builds, `[fromMs, toMs)` (the last
|
|
44
|
+
* bar's end, its calendar close on a calendar chart, so every bucket inside it is asked). */
|
|
45
|
+
export interface WrunTierSegment {
|
|
46
|
+
tier: WrunBackendTier;
|
|
47
|
+
fromMs: number;
|
|
48
|
+
toMs: number;
|
|
49
|
+
}
|
|
50
|
+
/** The asks a tier plan needs: each run of consecutive bars that read the same tier, as one segment (a
|
|
51
|
+
* partial bar asks nothing, it is marked instead). */
|
|
52
|
+
export declare function wrunTierSegments(barTiers: readonly WrunBarTier[], barMs: number): WrunTierSegment[];
|
|
53
|
+
/** Where a host-grid lane asks its tier rows through, for a chart window whose last bar opens at
|
|
54
|
+
* `lastBarOpenMs`: that bar's END (`barEndMs`: its calendar close on a calendar chart, whose length is an
|
|
55
|
+
* average), so the buckets inside the forming bar are asked too (a bar join asks the last open alone: its rows
|
|
56
|
+
* are stamped at the chart's opens). */
|
|
57
|
+
export declare function wrunHostGridFetchTo(lastBarOpenMs: number, intervalMs: number): number;
|
|
58
|
+
/** One ask of a host-grid lane over a chart window: its span `[fromMs, toMs)` and the tier it reads
|
|
59
|
+
* (absent: the lane names no tiers, its rows are asked as the control answers them). */
|
|
60
|
+
export interface WrunHostGridAsk {
|
|
61
|
+
tier?: WrunBackendTier;
|
|
62
|
+
fromMs: number;
|
|
63
|
+
toMs: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The asks a host-grid lane makes over a chart window: with no tiers, ONE ask from the first bar's open to the
|
|
67
|
+
* last bar's end; with tiers, one ask per run of bars on one tier (`wrunBarTiers` under the lane's `choice`, then
|
|
68
|
+
* `wrunTierSegments`), and the bars no fitting tier retains, which ask nothing and are partial. `barOpens` are the
|
|
69
|
+
* host bars of the window, ascending (`liveBucketStartsInRange` over the chart's bar grid).
|
|
70
|
+
*/
|
|
71
|
+
export declare function wrunHostGridAsks(args: {
|
|
72
|
+
tiers?: readonly WrunBackendTier[];
|
|
73
|
+
barOpens: readonly number[];
|
|
74
|
+
intervalMs: number;
|
|
75
|
+
nowMs: number;
|
|
76
|
+
choice?: WrunTierChoice;
|
|
77
|
+
}): {
|
|
78
|
+
asks: WrunHostGridAsk[];
|
|
79
|
+
partialBars: number[];
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* The asks that read again, one tier coarser, the host bars a snapshot's tier answered nothing for (OPTIONS-PORT D12:
|
|
83
|
+
* a CME surface keeps its settlement DAY rows while its 5m tier fills only inside a session where rows exist, so a
|
|
84
|
+
* daily bar whose 5m answer is empty reads its DAY row, never nothing). Each bar `asks` covered at a tier that holds no
|
|
85
|
+
* landed row (`landedBars`) is read from the next coarser tier that fits it and still retains it; one ask per run of
|
|
86
|
+
* such consecutive bars on one tier (a bar holding a row, or with no coarser tier, ends the run). Empty when every
|
|
87
|
+
* asked bar landed a row or none has a coarser tier (an intraday bar under a day tier).
|
|
88
|
+
*/
|
|
89
|
+
export declare function wrunHostGridFallbackAsks(args: {
|
|
90
|
+
tiers: readonly WrunBackendTier[];
|
|
91
|
+
asks: readonly WrunHostGridAsk[];
|
|
92
|
+
barOpens: readonly number[];
|
|
93
|
+
landedBars: ReadonlySet<number>;
|
|
94
|
+
intervalMs: number;
|
|
95
|
+
nowMs: number;
|
|
96
|
+
}): WrunHostGridAsk[];
|
|
97
|
+
/** The host bar a tier row stamped `tsMs` lands on (`liveBucketStartMs` over the chart's bar-grid venue),
|
|
98
|
+
* or null when it lands on none (off session on an anchored grid). */
|
|
99
|
+
export declare function wrunHostBarOf(tsMs: number, intervalMs: number, barGrid?: LiveBucketVenue | null): number | null;
|
|
100
|
+
/** What both landings read: the chart's bar span and grid, the clock, and the tier the rows ride. */
|
|
101
|
+
export interface WrunHostGridLanding {
|
|
102
|
+
/** The host chart's bar span (the run interval on a run at another interval). */
|
|
103
|
+
intervalMs: number;
|
|
104
|
+
/** The chart's bar-grid venue (`liveBucketVenueOf(metadata)`); absent: the UTC floor. */
|
|
105
|
+
barGrid?: LiveBucketVenue | null;
|
|
106
|
+
/** The tier the rows ride, its bucket width: a snapshot reads only rows whose bucket has closed. Absent:
|
|
107
|
+
* every row is sealed (rows already stamped per host bar). */
|
|
108
|
+
tierMs?: number;
|
|
109
|
+
nowMs: number;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Scalar lane rows `[ts, ...columns]` at a tier landed on the host bars `[barOpen, ...columns]`, ascending:
|
|
113
|
+
* a flow sums each column's finite values (a column with none in the bar stays null: the `missing` policy
|
|
114
|
+
* speaks for it, never a made-up 0), a snapshot takes the newest sealed row of the bar whole (a bar holding
|
|
115
|
+
* no sealed row yet has none).
|
|
116
|
+
*/
|
|
117
|
+
export declare function wrunLandScalarRowsOnHostBars(rows: ReadonlyArray<ArrayLike<unknown>>, landing: WrunTierLanding, grid: WrunHostGridLanding): Array<Array<number | null>>;
|
|
118
|
+
/** The tuples of one host bar a celled lane folds itself (a lane whose flow sums per contract, or re-bases an
|
|
119
|
+
* offset column on the host bar's open): the bar's open, its rows in time order (each `[ts, ...tuples]`). */
|
|
120
|
+
export interface WrunHostBarGroup {
|
|
121
|
+
barOpenMs: number;
|
|
122
|
+
rows: ReadonlyArray<ReadonlyArray<unknown>>;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Celled lane rows `[ts, tuple, tuple, ...]` at a tier landed on the host bars `[barOpen, ...tuples]`,
|
|
126
|
+
* ascending: a flow keeps every tuple of the bar's rows in time order, a snapshot the newest sealed row's
|
|
127
|
+
* tuples (a bar holding no sealed row yet has none). `fold` replaces the default per bar (a lane summing per
|
|
128
|
+
* contract); a bar it folds to no tuple carries none.
|
|
129
|
+
*/
|
|
130
|
+
export declare function wrunLandCellRowsOnHostBars(rows: ReadonlyArray<ReadonlyArray<unknown>>, landing: WrunTierLanding, grid: WrunHostGridLanding, fold?: (group: WrunHostBarGroup) => ReadonlyArray<ReadonlyArray<number>>): unknown[][];
|
|
131
|
+
/**
|
|
132
|
+
* Celled host-bar rows `[barOpen, ...tuples]` with the PARTIAL bars marked (rule 1, bit 14): every tuple of a
|
|
133
|
+
* partial bar carries the bit, and a partial bar holding no row gets one with a single marker tuple (every value
|
|
134
|
+
* 0, bit 14 alone), so a package never reads a bar the backend no longer holds as a quiet one. `partialBars`
|
|
135
|
+
* are host bar opens; `width` counts the `present` column. Ascending.
|
|
136
|
+
*/
|
|
137
|
+
export declare function wrunCellRowsWithPartialBars(rows: ReadonlyArray<ReadonlyArray<unknown>>, partialBars: Iterable<number>, width: number): unknown[][];
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host-grid rules of the per-bar wrun source classes (UW-PARITY source contract v2, global rule 9),
|
|
3
|
+
* pure: which backend tier builds each host bar, and how a tier's rows land on the host chart's bars.
|
|
4
|
+
*
|
|
5
|
+
* The tier rule. A per-bar class is stored at a few backend tiers (a 1m aggregate kept 7 days, a 5m one kept
|
|
6
|
+
* 30, an hourly and a daily one kept for good: each lane names its own). A host bar is built from the
|
|
7
|
+
* FINEST tier that fits it (`wrunTierFitsBar`: its width divides the bar, and the bar's open sits on the
|
|
8
|
+
* tier's grid, so the bar is a whole number of the tier's buckets) and still retains it. The grids: a stock
|
|
9
|
+
* chart's anchored bars open at 09:30 New York (13:30Z or 14:30Z, so 1m, 5m and 30m buckets fit a 1h bar and an
|
|
10
|
+
* hourly one does not); an OPRA contract chart's bars, and every daily or calendar bar, open on UTC. A bar no
|
|
11
|
+
* fitting tier retains any more is PARTIAL: bit 14 of its tuples' `present` mask, or one marker tuple when it
|
|
12
|
+
* holds none (wrun-present-bits.util). The fit is read off the bar's own open, so a DST move needs no table.
|
|
13
|
+
*
|
|
14
|
+
* The coarsest choice (`WrunTierChoice`, a lane's opt-in; every other lane keeps the finest). A lane whose fold reads
|
|
15
|
+
* the same per-bar values from any fitting tier (a per-contract sum: the backend rolls each tier up from the 1m one)
|
|
16
|
+
* reads each bar from the COARSEST fitting tier that retains it and already serves the whole bar, so a 5m bar reads
|
|
17
|
+
* one 5m bucket instead of five 1m ones and a sealed daily bar one day bucket instead of its minutes. A tier with a
|
|
18
|
+
* `servedLagMs` (an hourly or daily aggregate materialized after its buckets close, a governed tier waiting out a
|
|
19
|
+
* delayed read's window) serves a bar only once the bar has ended that long ago, so the forming bar, and a bar that
|
|
20
|
+
* closed inside the lag, read the next finer tier that serves them (the finest when none does). Which bars are
|
|
21
|
+
* partial does not change.
|
|
22
|
+
*
|
|
23
|
+
* The landing. A tier's rows are stamped at their bucket opens; each lands on the host bar holding it
|
|
24
|
+
* (`liveBucketStartMs` over the chart's bar-grid venue, `liveBucketVenueOf(metadata)`: the 09:30-anchored
|
|
25
|
+
* bucket of a regular-session stock chart, the UTC floor elsewhere; an off-session row lands nowhere), and the
|
|
26
|
+
* bar's rows fold by the class's landing: a FLOW sums (every tuple of a celled flow is kept, in time order; a
|
|
27
|
+
* scalar column sums its finite values), a SNAPSHOT takes the newest SEALED row of the bar (a row whose tier
|
|
28
|
+
* bucket has closed by the clock: a forming bucket is never read as the bar's state).
|
|
29
|
+
*/
|
|
30
|
+
import { barEndMs, calendarMonthsOfMs } from '../chart/calendar-interval.util.js';
|
|
31
|
+
import { liveBucketStartMs } from '../chart/live-bucket.util.js';
|
|
32
|
+
import { wrunPartialMarkerTuple, wrunTuplesMarkedPartial } from './wrun-present-bits.util.js';
|
|
33
|
+
const DAY_MS = 86_400_000;
|
|
34
|
+
/** The span a tier must divide: the bar's own, or a day for a calendar bar (its span is no fixed number). */
|
|
35
|
+
function divisionSpanMs(barMs) {
|
|
36
|
+
return calendarMonthsOfMs(barMs) !== null ? DAY_MS : barMs;
|
|
37
|
+
}
|
|
38
|
+
/** Whether a tier fits a host bar: its width divides the bar's span (a day for a calendar bar) and the bar's
|
|
39
|
+
* open sits on the tier's UTC grid, so the bar is a whole number of the tier's buckets. */
|
|
40
|
+
export function wrunTierFitsBar(tier, barOpenMs, barMs) {
|
|
41
|
+
const span = divisionSpanMs(barMs);
|
|
42
|
+
if (!(tier.ms > 0) || !(span > 0) || !Number.isFinite(barOpenMs))
|
|
43
|
+
return false;
|
|
44
|
+
return span % tier.ms === 0 && barOpenMs % tier.ms === 0;
|
|
45
|
+
}
|
|
46
|
+
/** Whether a tier still holds a host bar whole at `nowMs`: kept for good, or the bar opened inside the
|
|
47
|
+
* retention. */
|
|
48
|
+
function tierRetainsBar(tier, barOpenMs, nowMs) {
|
|
49
|
+
return tier.retentionMs === undefined || barOpenMs >= nowMs - tier.retentionMs;
|
|
50
|
+
}
|
|
51
|
+
/** The tiers that fit a host bar, finest first. */
|
|
52
|
+
function fittingTiers(tiers, barOpenMs, barMs) {
|
|
53
|
+
return tiers.filter((tier) => wrunTierFitsBar(tier, barOpenMs, barMs)).sort((a, b) => a.ms - b.ms);
|
|
54
|
+
}
|
|
55
|
+
/** The finest tier that fits a host bar (the one its live bar is built from), or undefined when none fits
|
|
56
|
+
* (a bar finer than every tier, or one whose open sits on no tier's grid). */
|
|
57
|
+
export function wrunFinestTier(tiers, barOpenMs, barMs) {
|
|
58
|
+
return fittingTiers(tiers, barOpenMs, barMs)[0];
|
|
59
|
+
}
|
|
60
|
+
/** The coarsest of a bar's retaining tiers (finest first) that already serves the whole bar: a tier with a
|
|
61
|
+
* `servedLagMs` serves it once the bar ended that long ago. None serving: the finest (the finest choice's tier). */
|
|
62
|
+
function coarsestServingTier(retaining, barOpenMs, barMs, nowMs) {
|
|
63
|
+
const barEnd = barEndMs(barOpenMs, barMs);
|
|
64
|
+
for (let at = retaining.length - 1; at > 0; at -= 1) {
|
|
65
|
+
const lag = retaining[at].servedLagMs;
|
|
66
|
+
if (lag === undefined || barEnd + lag <= nowMs)
|
|
67
|
+
return retaining[at];
|
|
68
|
+
}
|
|
69
|
+
return retaining[0];
|
|
70
|
+
}
|
|
71
|
+
/** The tier rule over a host grid's bar opens (ascending): each bar's fitting tier that still retains it (the
|
|
72
|
+
* finest, or with `choice: 'coarsest'` the coarsest that already serves the bar), else partial. */
|
|
73
|
+
export function wrunBarTiers(args) {
|
|
74
|
+
return args.barOpens.map((barOpenMs) => {
|
|
75
|
+
const fitting = fittingTiers(args.tiers, barOpenMs, args.barMs);
|
|
76
|
+
const retaining = fitting.filter((tier) => tierRetainsBar(tier, barOpenMs, args.nowMs));
|
|
77
|
+
if (retaining.length > 0) {
|
|
78
|
+
const tier = args.choice === 'coarsest' ? coarsestServingTier(retaining, barOpenMs, args.barMs, args.nowMs) : retaining[0];
|
|
79
|
+
return { barOpenMs, tier, partial: false };
|
|
80
|
+
}
|
|
81
|
+
return fitting.length > 0 ? { barOpenMs, tier: fitting[0], partial: true } : { barOpenMs, partial: true };
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/** The asks a tier plan needs: each run of consecutive bars that read the same tier, as one segment (a
|
|
85
|
+
* partial bar asks nothing, it is marked instead). */
|
|
86
|
+
export function wrunTierSegments(barTiers, barMs) {
|
|
87
|
+
const segments = [];
|
|
88
|
+
let open;
|
|
89
|
+
for (const bar of barTiers) {
|
|
90
|
+
if (bar.partial || bar.tier === undefined) {
|
|
91
|
+
open = undefined;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const endMs = barEndMs(bar.barOpenMs, barMs);
|
|
95
|
+
if (open !== undefined && open.tier.key === bar.tier.key) {
|
|
96
|
+
open.toMs = endMs;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
open = { tier: bar.tier, fromMs: bar.barOpenMs, toMs: endMs };
|
|
100
|
+
segments.push(open);
|
|
101
|
+
}
|
|
102
|
+
return segments;
|
|
103
|
+
}
|
|
104
|
+
/** Where a host-grid lane asks its tier rows through, for a chart window whose last bar opens at
|
|
105
|
+
* `lastBarOpenMs`: that bar's END (`barEndMs`: its calendar close on a calendar chart, whose length is an
|
|
106
|
+
* average), so the buckets inside the forming bar are asked too (a bar join asks the last open alone: its rows
|
|
107
|
+
* are stamped at the chart's opens). */
|
|
108
|
+
export function wrunHostGridFetchTo(lastBarOpenMs, intervalMs) {
|
|
109
|
+
return intervalMs > 0 ? barEndMs(lastBarOpenMs, intervalMs) : lastBarOpenMs;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The asks a host-grid lane makes over a chart window: with no tiers, ONE ask from the first bar's open to the
|
|
113
|
+
* last bar's end; with tiers, one ask per run of bars on one tier (`wrunBarTiers` under the lane's `choice`, then
|
|
114
|
+
* `wrunTierSegments`), and the bars no fitting tier retains, which ask nothing and are partial. `barOpens` are the
|
|
115
|
+
* host bars of the window, ascending (`liveBucketStartsInRange` over the chart's bar grid).
|
|
116
|
+
*/
|
|
117
|
+
export function wrunHostGridAsks(args) {
|
|
118
|
+
const { barOpens, intervalMs } = args;
|
|
119
|
+
if (barOpens.length === 0)
|
|
120
|
+
return { asks: [], partialBars: [] };
|
|
121
|
+
if (args.tiers === undefined || args.tiers.length === 0) {
|
|
122
|
+
return {
|
|
123
|
+
asks: [{ fromMs: barOpens[0], toMs: wrunHostGridFetchTo(barOpens[barOpens.length - 1], intervalMs) }],
|
|
124
|
+
partialBars: [],
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const bars = wrunBarTiers({
|
|
128
|
+
tiers: args.tiers,
|
|
129
|
+
barOpens,
|
|
130
|
+
barMs: intervalMs,
|
|
131
|
+
nowMs: args.nowMs,
|
|
132
|
+
choice: args.choice,
|
|
133
|
+
});
|
|
134
|
+
return {
|
|
135
|
+
asks: wrunTierSegments(bars, intervalMs),
|
|
136
|
+
partialBars: bars.filter((bar) => bar.partial).map((bar) => bar.barOpenMs),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The asks that read again, one tier coarser, the host bars a snapshot's tier answered nothing for (OPTIONS-PORT D12:
|
|
141
|
+
* a CME surface keeps its settlement DAY rows while its 5m tier fills only inside a session where rows exist, so a
|
|
142
|
+
* daily bar whose 5m answer is empty reads its DAY row, never nothing). Each bar `asks` covered at a tier that holds no
|
|
143
|
+
* landed row (`landedBars`) is read from the next coarser tier that fits it and still retains it; one ask per run of
|
|
144
|
+
* such consecutive bars on one tier (a bar holding a row, or with no coarser tier, ends the run). Empty when every
|
|
145
|
+
* asked bar landed a row or none has a coarser tier (an intraday bar under a day tier).
|
|
146
|
+
*/
|
|
147
|
+
export function wrunHostGridFallbackAsks(args) {
|
|
148
|
+
const bars = args.barOpens.map((barOpenMs) => {
|
|
149
|
+
const asked = args.asks.find((ask) => ask.tier !== undefined && barOpenMs >= ask.fromMs && barOpenMs < ask.toMs);
|
|
150
|
+
const finer = asked?.tier;
|
|
151
|
+
if (finer === undefined || args.landedBars.has(barOpenMs))
|
|
152
|
+
return { barOpenMs, partial: true };
|
|
153
|
+
const coarser = fittingTiers(args.tiers, barOpenMs, args.intervalMs).find((tier) => tier.ms > finer.ms && tierRetainsBar(tier, barOpenMs, args.nowMs));
|
|
154
|
+
// A bar with nothing coarser to read ends the run like a landed one (`wrunTierSegments` asks no partial bar).
|
|
155
|
+
return coarser === undefined ? { barOpenMs, partial: true } : { barOpenMs, tier: coarser, partial: false };
|
|
156
|
+
});
|
|
157
|
+
return wrunTierSegments(bars, args.intervalMs);
|
|
158
|
+
}
|
|
159
|
+
/** The host bar a tier row stamped `tsMs` lands on (`liveBucketStartMs` over the chart's bar-grid venue),
|
|
160
|
+
* or null when it lands on none (off session on an anchored grid). */
|
|
161
|
+
export function wrunHostBarOf(tsMs, intervalMs, barGrid) {
|
|
162
|
+
if (!Number.isFinite(tsMs) || !(intervalMs > 0))
|
|
163
|
+
return null;
|
|
164
|
+
return liveBucketStartMs(tsMs, intervalMs, barGrid ?? undefined);
|
|
165
|
+
}
|
|
166
|
+
/** A tier row is sealed once its bucket has closed by the clock (`tierMs` absent: every row is). */
|
|
167
|
+
function sealed(tsMs, tierMs, nowMs) {
|
|
168
|
+
return tierMs === undefined || !(tierMs > 0) || tsMs + tierMs <= nowMs;
|
|
169
|
+
}
|
|
170
|
+
/** Rows grouped by the host bar each lands on, ascending, every group's rows in time order. */
|
|
171
|
+
function groupByHostBar(rows, intervalMs, barGrid) {
|
|
172
|
+
const groups = new Map();
|
|
173
|
+
for (const row of rows) {
|
|
174
|
+
const ts = Number(row[0]);
|
|
175
|
+
const bar = wrunHostBarOf(ts, intervalMs, barGrid);
|
|
176
|
+
if (bar === null)
|
|
177
|
+
continue;
|
|
178
|
+
const group = groups.get(bar);
|
|
179
|
+
if (group === undefined)
|
|
180
|
+
groups.set(bar, [row]);
|
|
181
|
+
else
|
|
182
|
+
group.push(row);
|
|
183
|
+
}
|
|
184
|
+
return [...groups.entries()]
|
|
185
|
+
.sort((a, b) => a[0] - b[0])
|
|
186
|
+
.map(([barOpenMs, group]) => ({ barOpenMs, rows: group.sort((a, b) => Number(a[0]) - Number(b[0])) }));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Scalar lane rows `[ts, ...columns]` at a tier landed on the host bars `[barOpen, ...columns]`, ascending:
|
|
190
|
+
* a flow sums each column's finite values (a column with none in the bar stays null: the `missing` policy
|
|
191
|
+
* speaks for it, never a made-up 0), a snapshot takes the newest sealed row of the bar whole (a bar holding
|
|
192
|
+
* no sealed row yet has none).
|
|
193
|
+
*/
|
|
194
|
+
export function wrunLandScalarRowsOnHostBars(rows, landing, grid) {
|
|
195
|
+
const landed = [];
|
|
196
|
+
for (const group of groupByHostBar(rows, grid.intervalMs, grid.barGrid)) {
|
|
197
|
+
if (landing === 'snapshot') {
|
|
198
|
+
const newest = [...group.rows].reverse().find((row) => sealed(Number(row[0]), grid.tierMs, grid.nowMs));
|
|
199
|
+
if (newest === undefined)
|
|
200
|
+
continue;
|
|
201
|
+
landed.push([group.barOpenMs, ...Array.from(newest).slice(1).map(cellOrNull)]);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
const width = Math.max(...group.rows.map((row) => row.length));
|
|
205
|
+
const sums = new Array(Math.max(0, width - 1)).fill(null);
|
|
206
|
+
for (const row of group.rows) {
|
|
207
|
+
for (let column = 1; column < row.length; column += 1) {
|
|
208
|
+
const value = cellOrNull(row[column]);
|
|
209
|
+
if (value === null)
|
|
210
|
+
continue;
|
|
211
|
+
sums[column - 1] = (sums[column - 1] ?? 0) + value;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
landed.push([group.barOpenMs, ...sums]);
|
|
215
|
+
}
|
|
216
|
+
return landed;
|
|
217
|
+
}
|
|
218
|
+
function cellOrNull(cell) {
|
|
219
|
+
if (cell === null || cell === undefined)
|
|
220
|
+
return null;
|
|
221
|
+
const value = Number(cell);
|
|
222
|
+
return Number.isFinite(value) ? value : null;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Celled lane rows `[ts, tuple, tuple, ...]` at a tier landed on the host bars `[barOpen, ...tuples]`,
|
|
226
|
+
* ascending: a flow keeps every tuple of the bar's rows in time order, a snapshot the newest sealed row's
|
|
227
|
+
* tuples (a bar holding no sealed row yet has none). `fold` replaces the default per bar (a lane summing per
|
|
228
|
+
* contract); a bar it folds to no tuple carries none.
|
|
229
|
+
*/
|
|
230
|
+
export function wrunLandCellRowsOnHostBars(rows, landing, grid, fold) {
|
|
231
|
+
const landed = [];
|
|
232
|
+
for (const group of groupByHostBar(rows, grid.intervalMs, grid.barGrid)) {
|
|
233
|
+
let tuples;
|
|
234
|
+
if (fold !== undefined) {
|
|
235
|
+
tuples = fold(group);
|
|
236
|
+
}
|
|
237
|
+
else if (landing === 'snapshot') {
|
|
238
|
+
const newest = [...group.rows].reverse().find((row) => sealed(Number(row[0]), grid.tierMs, grid.nowMs));
|
|
239
|
+
if (newest === undefined)
|
|
240
|
+
continue;
|
|
241
|
+
tuples = newest.slice(1);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
tuples = group.rows.flatMap((row) => row.slice(1));
|
|
245
|
+
}
|
|
246
|
+
if (tuples.length === 0)
|
|
247
|
+
continue;
|
|
248
|
+
landed.push([group.barOpenMs, ...tuples]);
|
|
249
|
+
}
|
|
250
|
+
return landed;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Celled host-bar rows `[barOpen, ...tuples]` with the PARTIAL bars marked (rule 1, bit 14): every tuple of a
|
|
254
|
+
* partial bar carries the bit, and a partial bar holding no row gets one with a single marker tuple (every value
|
|
255
|
+
* 0, bit 14 alone), so a package never reads a bar the backend no longer holds as a quiet one. `partialBars`
|
|
256
|
+
* are host bar opens; `width` counts the `present` column. Ascending.
|
|
257
|
+
*/
|
|
258
|
+
export function wrunCellRowsWithPartialBars(rows, partialBars, width) {
|
|
259
|
+
const partial = new Set(partialBars);
|
|
260
|
+
if (partial.size === 0)
|
|
261
|
+
return rows.map((row) => [...row]);
|
|
262
|
+
const out = [];
|
|
263
|
+
const seen = new Set();
|
|
264
|
+
for (const row of rows) {
|
|
265
|
+
const ts = Number(row[0]);
|
|
266
|
+
if (!partial.has(ts)) {
|
|
267
|
+
out.push([...row]);
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
seen.add(ts);
|
|
271
|
+
const tuples = row.slice(1).filter((cell) => Array.isArray(cell));
|
|
272
|
+
out.push([ts, ...(tuples.length > 0 ? wrunTuplesMarkedPartial(tuples, width) : [wrunPartialMarkerTuple(width)])]);
|
|
273
|
+
}
|
|
274
|
+
for (const ts of partial) {
|
|
275
|
+
if (!seen.has(ts) && Number.isFinite(ts))
|
|
276
|
+
out.push([ts, wrunPartialMarkerTuple(width)]);
|
|
277
|
+
}
|
|
278
|
+
return out.sort((a, b) => Number(a[0]) - Number(b[0]));
|
|
279
|
+
}
|