@orangecharts/wrun-chart-host 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -8
- package/dist/constants/common.constants.d.ts +15 -0
- package/dist/constants/common.constants.js +23 -0
- package/dist/constants/data-source.constants.d.ts +1 -0
- package/dist/constants/data-source.constants.js +1 -0
- package/dist/constants/economic.constants.d.ts +39 -0
- package/dist/constants/economic.constants.js +77 -0
- package/dist/constants/etf-covered-coins.constants.d.ts +1 -0
- package/dist/constants/etf-covered-coins.constants.js +9 -0
- package/dist/constants/feature-flags.constants.d.ts +60 -0
- package/dist/constants/feature-flags.constants.js +308 -0
- package/dist/constants/feature-limits.constants.d.ts +134 -0
- package/dist/constants/feature-limits.constants.js +155 -0
- package/dist/constants/marketCapabilities.constants.d.ts +87 -0
- package/dist/constants/marketCapabilities.constants.js +213 -0
- package/dist/constants/option-venues.constants.d.ts +100 -0
- package/dist/constants/option-venues.constants.js +167 -0
- package/dist/constants/overlay-data.constants.d.ts +53 -0
- package/dist/constants/overlay-data.constants.js +80 -0
- package/dist/constants/pane-grid.constants.d.ts +15 -0
- package/dist/constants/pane-grid.constants.js +17 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +133 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.js +451 -0
- package/dist/constants/venue-presets.constants.d.ts +10 -0
- package/dist/constants/venue-presets.constants.js +22 -0
- package/dist/enums/chart.enum.d.ts +68 -0
- package/dist/enums/chart.enum.js +70 -0
- package/dist/helpers/data.helpers.d.ts +2 -0
- package/dist/helpers/data.helpers.js +14 -0
- package/dist/host-env.d.ts +163 -5
- package/dist/host-ports.types.d.ts +431 -0
- package/dist/host-ports.types.js +1 -0
- package/dist/index.d.ts +138 -0
- package/dist/index.js +138 -0
- package/dist/indicators/controls/technical-script/technical-script-input-rendering.d.ts +86 -0
- package/dist/indicators/controls/technical-script/technical-script-input-rendering.js +179 -0
- package/dist/interfaces/asset-venue.interface.d.ts +91 -0
- package/dist/interfaces/asset-venue.interface.js +1 -0
- package/dist/interfaces/cancel-reason.interface.d.ts +24 -0
- package/dist/interfaces/cancel-reason.interface.js +2 -0
- package/dist/interfaces/catalog-display.interface.d.ts +3 -0
- package/dist/interfaces/catalog-display.interface.js +1 -0
- package/dist/interfaces/cme-realtime.interface.d.ts +251 -0
- package/dist/interfaces/cme-realtime.interface.js +46 -0
- package/dist/interfaces/feed.interface.d.ts +80 -0
- package/dist/interfaces/feed.interface.js +7 -0
- package/dist/interfaces/market-kind.interface.d.ts +8 -0
- package/dist/interfaces/market-kind.interface.js +1 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +224 -0
- package/dist/interfaces/opra-realtime.interface.js +105 -0
- package/dist/interfaces/option-instrument.interface.d.ts +32 -0
- package/dist/interfaces/option-instrument.interface.js +1 -0
- package/dist/interfaces/options-chain-scope.interface.d.ts +29 -0
- package/dist/interfaces/options-chain-scope.interface.js +7 -0
- package/dist/interfaces/prediction-market.interface.d.ts +88 -0
- package/dist/interfaces/prediction-market.interface.js +8 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +5 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +185 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +357 -0
- package/dist/settings-templates/frvp-fields.d.ts +27 -0
- package/dist/settings-templates/frvp-fields.js +108 -0
- package/dist/settings-templates/index.d.ts +119 -0
- package/dist/settings-templates/index.js +442 -0
- package/dist/settings-templates/indicator-fields.d.ts +56 -0
- package/dist/settings-templates/indicator-fields.js +793 -0
- package/dist/settings-templates/tool-rules.d.ts +59 -0
- package/dist/settings-templates/tool-rules.js +49 -0
- package/dist/settings-templates/tool-tables.generated.d.ts +2 -0
- package/dist/settings-templates/tool-tables.generated.js +1668 -0
- package/dist/utility/blk-market.util.d.ts +5 -0
- package/dist/utility/blk-market.util.js +12 -0
- package/dist/utility/chart/chart-load-phase.util.d.ts +32 -0
- package/dist/utility/chart/chart-load-phase.util.js +78 -0
- package/dist/utility/chart/cme-cache-context.util.d.ts +108 -0
- package/dist/utility/chart/cme-cache-context.util.js +166 -0
- package/dist/utility/chart/cme-session-bucket.util.d.ts +82 -0
- package/dist/utility/chart/cme-session-bucket.util.js +343 -0
- package/dist/utility/chart/cme-trade-calendar.util.d.ts +26 -0
- package/dist/utility/chart/cme-trade-calendar.util.js +147 -0
- package/dist/utility/chart/continuous-contracts.util.d.ts +138 -0
- package/dist/utility/chart/continuous-contracts.util.js +374 -0
- package/dist/utility/chart/date-labelled-interval.leaf.d.ts +15 -0
- package/dist/utility/chart/date-labelled-interval.leaf.js +19 -0
- package/dist/utility/chart/feed-interval.util.d.ts +119 -0
- package/dist/utility/chart/feed-interval.util.js +321 -0
- package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +110 -0
- package/dist/utility/chart/fetch-dedupe-policy.util.js +407 -0
- package/dist/utility/chart/footprint-band.util.d.ts +76 -0
- package/dist/utility/chart/footprint-band.util.js +205 -0
- package/dist/utility/chart/footprint-cell-identity.util.d.ts +82 -0
- package/dist/utility/chart/footprint-cell-identity.util.js +346 -0
- package/dist/utility/chart/formula-calendar.util.d.ts +27 -0
- package/dist/utility/chart/formula-calendar.util.js +59 -0
- package/dist/utility/chart/history-wall.util.d.ts +67 -0
- package/dist/utility/chart/history-wall.util.js +87 -0
- package/dist/utility/chart/index-mode.util.d.ts +66 -0
- package/dist/utility/chart/index-mode.util.js +360 -0
- package/dist/utility/chart/indicator-coverage-planner.util.d.ts +217 -0
- package/dist/utility/chart/indicator-coverage-planner.util.js +443 -0
- package/dist/utility/chart/indicator-coverage-state.util.d.ts +33 -0
- package/dist/utility/chart/indicator-coverage-state.util.js +110 -0
- package/dist/utility/chart/indicator-gap-detector.util.d.ts +127 -0
- package/dist/utility/chart/indicator-gap-detector.util.js +260 -0
- package/dist/utility/chart/indicator-gap-repair.util.d.ts +88 -0
- package/dist/utility/chart/indicator-gap-repair.util.js +177 -0
- package/dist/utility/chart/indicator-inflight-registry.util.d.ts +26 -0
- package/dist/utility/chart/indicator-inflight-registry.util.js +254 -0
- package/dist/utility/chart/indicator-run-interval.util.d.ts +130 -0
- package/dist/utility/chart/indicator-run-interval.util.js +268 -0
- package/dist/utility/chart/interval-registry.util.d.ts +23 -0
- package/dist/utility/chart/interval-registry.util.js +83 -0
- package/dist/utility/chart/kscript-main-grid-stages.util.d.ts +21 -0
- package/dist/utility/chart/kscript-main-grid-stages.util.js +332 -0
- package/dist/utility/chart/legacy-exchange.leaf.d.ts +11 -0
- package/dist/utility/chart/legacy-exchange.leaf.js +43 -0
- package/dist/utility/chart/live-bucket.util.d.ts +66 -0
- package/dist/utility/chart/live-bucket.util.js +165 -0
- package/dist/utility/chart/market-session-schedule.util.d.ts +91 -0
- package/dist/utility/chart/market-session-schedule.util.js +337 -0
- package/dist/utility/chart/marketKind.util.d.ts +181 -0
- package/dist/utility/chart/marketKind.util.js +371 -0
- package/dist/utility/chart/opra-read-access.leaf.d.ts +26 -0
- package/dist/utility/chart/opra-read-access.leaf.js +25 -0
- package/dist/utility/chart/prediction-identity.util.d.ts +159 -0
- package/dist/utility/chart/prediction-identity.util.js +236 -0
- package/dist/utility/chart/rth-session.util.d.ts +352 -0
- package/dist/utility/chart/rth-session.util.js +926 -0
- package/dist/utility/chart/titan-constants.pin.d.ts +43 -0
- package/dist/utility/chart/titan-constants.pin.js +50 -0
- package/dist/utility/chart/us-equities-session.util.d.ts +127 -0
- package/dist/utility/chart/us-equities-session.util.js +251 -0
- package/dist/utility/chart/window-geometry.leaf.d.ts +119 -0
- package/dist/utility/chart/window-geometry.leaf.js +391 -0
- package/dist/utility/chart/window-owner.leaf.d.ts +19 -0
- package/dist/utility/chart/window-owner.leaf.js +24 -0
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +100 -0
- package/dist/utility/chart/wrun-bar-session-facts.util.js +354 -0
- package/dist/utility/chart/wrun-wire-ref.util.d.ts +23 -0
- package/dist/utility/chart/wrun-wire-ref.util.js +16 -0
- package/dist/utility/common/safe-math-eval.d.ts +18 -0
- package/dist/utility/common/safe-math-eval.js +160 -0
- package/dist/utility/common/time.util.d.ts +134 -0
- package/dist/utility/common/time.util.js +428 -0
- package/dist/utility/common/transformations.util.d.ts +126 -0
- package/dist/utility/common/transformations.util.js +711 -0
- package/dist/utility/common/visible-timeout.util.d.ts +17 -0
- package/dist/utility/common/visible-timeout.util.js +75 -0
- package/dist/utility/exchange-normalization.util.d.ts +8 -0
- package/dist/utility/exchange-normalization.util.js +32 -0
- package/dist/utility/html-escape.leaf.d.ts +11 -0
- package/dist/utility/html-escape.leaf.js +20 -0
- package/dist/utility/intl-locale.util.d.ts +2 -0
- package/dist/utility/intl-locale.util.js +28 -0
- package/dist/utility/number-format.util.d.ts +14 -1
- package/dist/utility/number-format.util.js +50 -19
- package/dist/utility/options/option-symbol.util.d.ts +28 -0
- package/dist/utility/options/option-symbol.util.js +176 -0
- package/dist/utility/options/option-trade-units.util.d.ts +190 -0
- package/dist/utility/options/option-trade-units.util.js +283 -0
- package/dist/utility/options/option-venue.util.d.ts +75 -0
- package/dist/utility/options/option-venue.util.js +85 -0
- package/dist/utility/pool-symbol.leaf.d.ts +34 -0
- package/dist/utility/pool-symbol.leaf.js +95 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +109 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +302 -0
- package/dist/utility/symbol-selection/contract-expiry.util.d.ts +39 -0
- package/dist/utility/symbol-selection/contract-expiry.util.js +111 -0
- package/dist/utility/v2/gate-plane.util.d.ts +58 -0
- package/dist/utility/v2/gate-plane.util.js +99 -0
- package/dist/utility/v2/gate-session-latch.util.d.ts +22 -0
- package/dist/utility/v2/gate-session-latch.util.js +34 -0
- package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +76 -0
- package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +221 -0
- package/dist/utility/wrun/sources/host-grid-landing.d.ts +15 -0
- package/dist/utility/wrun/sources/host-grid-landing.js +26 -0
- package/dist/utility/wrun/sources/lanes/bitfinex_funding.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/bitfinex_funding.js +85 -0
- package/dist/utility/wrun/sources/lanes/economic.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/economic.js +79 -0
- package/dist/utility/wrun/sources/lanes/etf_holdings.d.ts +35 -0
- package/dist/utility/wrun/sources/lanes/etf_holdings.js +165 -0
- package/dist/utility/wrun/sources/lanes/etf_premium.d.ts +19 -0
- package/dist/utility/wrun/sources/lanes/etf_premium.js +114 -0
- package/dist/utility/wrun/sources/lanes/ethena_positions.d.ts +30 -0
- package/dist/utility/wrun/sources/lanes/ethena_positions.js +51 -0
- package/dist/utility/wrun/sources/lanes/index.d.ts +2 -0
- package/dist/utility/wrun/sources/lanes/index.js +32 -0
- package/dist/utility/wrun/sources/lanes/long_short_ratio.d.ts +17 -0
- package/dist/utility/wrun/sources/lanes/long_short_ratio.js +47 -0
- package/dist/utility/wrun/sources/lanes/option_daily.d.ts +58 -0
- package/dist/utility/wrun/sources/lanes/option_daily.js +111 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.js +21 -0
- package/dist/utility/wrun/sources/lanes/options_flow.d.ts +50 -0
- package/dist/utility/wrun/sources/lanes/options_flow.js +155 -0
- package/dist/utility/wrun/sources/lanes/options_oi.d.ts +29 -0
- package/dist/utility/wrun/sources/lanes/options_oi.js +59 -0
- package/dist/utility/wrun/sources/lanes/options_volume.d.ts +38 -0
- package/dist/utility/wrun/sources/lanes/options_volume.js +63 -0
- package/dist/utility/wrun/sources/lanes/series.d.ts +67 -0
- package/dist/utility/wrun/sources/lanes/series.js +321 -0
- package/dist/utility/wrun/sources/lanes/token_supply.d.ts +30 -0
- package/dist/utility/wrun/sources/lanes/token_supply.js +145 -0
- package/dist/utility/wrun/sources/lanes/treasury_balance.d.ts +25 -0
- package/dist/utility/wrun/sources/lanes/treasury_balance.js +47 -0
- package/dist/utility/wrun/sources/lanes/volatility_index.d.ts +21 -0
- package/dist/utility/wrun/sources/lanes/volatility_index.js +11 -0
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +215 -0
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +477 -0
- package/dist/utility/wrun/sources/registry.d.ts +21 -0
- package/dist/utility/wrun/sources/registry.js +237 -0
- package/dist/utility/wrun/sources/row-lane-registry.d.ts +28 -0
- package/dist/utility/wrun/sources/row-lane-registry.js +230 -0
- package/dist/utility/wrun/sources/row-lanes/index.d.ts +2 -0
- package/dist/utility/wrun/sources/row-lanes/index.js +12 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +2 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +38 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +55 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +126 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +4 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +191 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +62 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +147 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +70 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +144 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +309 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.js +26 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +350 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +576 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +275 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.js +16 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +207 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +450 -0
- package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +28 -0
- package/dist/utility/wrun/wrun-browser-sources.leaf.js +66 -0
- package/dist/utility/wrun/wrun-cloud-record.util.d.ts +65 -0
- package/dist/utility/wrun/wrun-cloud-record.util.js +121 -0
- package/dist/utility/wrun/wrun-daily-lane.util.d.ts +95 -0
- package/dist/utility/wrun/wrun-daily-lane.util.js +297 -0
- package/dist/utility/wrun/wrun-deadline.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-deadline.util.js +82 -0
- package/dist/utility/wrun/wrun-etf-flow-lane.util.d.ts +94 -0
- package/dist/utility/wrun/wrun-etf-flow-lane.util.js +224 -0
- package/dist/utility/wrun/wrun-etf-funds.util.d.ts +82 -0
- package/dist/utility/wrun/wrun-etf-funds.util.js +242 -0
- package/dist/utility/wrun/wrun-frames.d.ts +20 -1
- package/dist/utility/wrun/wrun-frames.js +103 -49
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +27 -0
- package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +22 -0
- package/dist/utility/wrun/wrun-lane-refusal.leaf.js +32 -0
- package/dist/utility/wrun/wrun-lane-warmup.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-lane-warmup.util.js +112 -0
- package/dist/utility/wrun/wrun-leg-close.util.d.ts +57 -0
- package/dist/utility/wrun/wrun-leg-close.util.js +187 -0
- package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +144 -0
- package/dist/utility/wrun/wrun-leg-fetch.util.js +212 -0
- package/dist/utility/wrun/wrun-leg-stream-classes.d.ts +73 -0
- package/dist/utility/wrun/wrun-leg-stream-classes.js +86 -0
- package/dist/utility/wrun/wrun-levels-child.util.d.ts +101 -6
- package/dist/utility/wrun/wrun-levels-child.util.js +335 -157
- package/dist/utility/wrun/wrun-memory-clamp.util.d.ts +33 -0
- package/dist/utility/wrun/wrun-memory-clamp.util.js +146 -0
- package/dist/utility/wrun/wrun-odds-template-market.util.d.ts +51 -0
- package/dist/utility/wrun/wrun-odds-template-market.util.js +251 -0
- package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +65 -0
- package/dist/utility/wrun/wrun-opra-flow.leaf.js +94 -0
- package/dist/utility/wrun/wrun-opra-lane.util.d.ts +47 -0
- package/dist/utility/wrun/wrun-opra-lane.util.js +58 -0
- package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +49 -0
- package/dist/utility/wrun/wrun-opra-stats.leaf.js +115 -0
- package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +12 -0
- package/dist/utility/wrun/wrun-opra-underlying.util.js +1 -0
- package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +142 -0
- package/dist/utility/wrun/wrun-option-contract-flow.util.js +451 -0
- package/dist/utility/wrun/wrun-option-knobs.util.d.ts +43 -0
- package/dist/utility/wrun/wrun-option-knobs.util.js +81 -0
- package/dist/utility/wrun/wrun-option-prints.util.d.ts +144 -0
- package/dist/utility/wrun/wrun-option-prints.util.js +356 -0
- package/dist/utility/wrun/wrun-option-summary-lane.util.d.ts +102 -0
- package/dist/utility/wrun/wrun-option-summary-lane.util.js +143 -0
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +308 -0
- package/dist/utility/wrun/wrun-options-chain.util.js +502 -0
- package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +9 -4
- package/dist/utility/wrun/wrun-overlay-identity.util.js +16 -6
- package/dist/utility/wrun/wrun-panel-mount.lazy.d.ts +10 -0
- package/dist/utility/wrun/wrun-panel-mount.lazy.js +68 -0
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +377 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +2251 -0
- package/dist/utility/wrun/wrun-param-map.util.d.ts +298 -0
- package/dist/utility/wrun/wrun-param-map.util.js +581 -0
- package/dist/utility/wrun/wrun-pause-dim.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-pause-dim.util.js +153 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +149 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.js +523 -0
- package/dist/utility/wrun/wrun-pin-venues.util.d.ts +116 -0
- package/dist/utility/wrun/wrun-pin-venues.util.js +320 -0
- package/dist/utility/wrun/wrun-pinned-interval.util.d.ts +20 -0
- package/dist/utility/wrun/wrun-pinned-interval.util.js +47 -0
- package/dist/utility/wrun/wrun-plot-gate.types.d.ts +23 -0
- package/dist/utility/wrun/wrun-plot-gate.types.js +7 -0
- package/dist/utility/wrun/wrun-present-bits.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-present-bits.util.js +73 -0
- package/dist/utility/wrun/wrun-protocol-pending.util.d.ts +33 -0
- package/dist/utility/wrun/wrun-protocol-pending.util.js +57 -0
- package/dist/utility/wrun/wrun-refusal.util.d.ts +41 -1
- package/dist/utility/wrun/wrun-refusal.util.js +69 -2
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +1 -14
- package/dist/utility/wrun/wrun-registry-errors.util.js +0 -16
- package/dist/utility/wrun/wrun-row-source.d.ts +158 -0
- package/dist/utility/wrun/wrun-row-source.js +75 -0
- package/dist/utility/wrun/wrun-run-health.util.d.ts +155 -0
- package/dist/utility/wrun/wrun-run-health.util.js +273 -0
- package/dist/utility/wrun/wrun-run-interval-projection.types.d.ts +14 -0
- package/dist/utility/wrun/wrun-run-interval-projection.types.js +1 -0
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +439 -0
- package/dist/utility/wrun/wrun-socket-row-source.js +1689 -0
- package/dist/utility/wrun/wrun-socket-session-losses.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-socket-session-losses.util.js +25 -0
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +911 -0
- package/dist/utility/wrun/wrun-source-rows.util.js +2597 -0
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +82 -0
- package/dist/utility/wrun/wrun-tape-source.util.js +151 -0
- package/dist/utility/wrun/wrun-tier-grid.util.d.ts +137 -0
- package/dist/utility/wrun/wrun-tier-grid.util.js +279 -0
- package/dist/utility/wrun/wrun-trades-lane.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-trades-lane.util.js +58 -0
- package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +41 -0
- package/dist/utility/wrun/wrun-volume-profile-lane.util.js +66 -0
- package/dist/utility/wrun-display-name.util.d.ts +33 -0
- package/dist/utility/wrun-display-name.util.js +64 -0
- package/dist/workers/constants/kscript-transport-codes.d.ts +15 -0
- package/dist/workers/constants/kscript-transport-codes.js +15 -0
- package/dist/workers/constants/socket-slots.d.ts +574 -0
- package/dist/workers/constants/socket-slots.js +539 -0
- package/dist/workers/utils/number.worker.util.d.ts +5 -0
- package/dist/workers/utils/number.worker.util.js +10 -0
- package/dist/workers/utils/time.worker.util.d.ts +12 -0
- package/dist/workers/utils/time.worker.util.js +24 -0
- package/dist/workers/utils/volume-profile.worker.util.d.ts +200 -0
- package/dist/workers/utils/volume-profile.worker.util.js +631 -0
- package/package.json +10 -4
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `option_contract_flow` class (UW-PARITY source contract v2, S4): one 17-value tuple per contract of the
|
|
3
|
+
* chart's underlying that traded in the bar, summed per host bar from OPTION_PRINT_AGG's CONTRACT rows (one per
|
|
4
|
+
* contract per tier bucket). Pure and light: the row lane (`sources/row-lanes/option_contract_flow.ts`), its K
|
|
5
|
+
* control (`K_OPTION_CONTRACT_FLOW`) and the worker twin read the same rules from here.
|
|
6
|
+
*
|
|
7
|
+
* The tuple: `[root_code, expiry_ms, side_cp, strike, vol_ask, vol_bid, vol_mid, vol_none, prem_ask, prem_bid,
|
|
8
|
+
* share_delta_net, vwap, last_price, iv_last, vol_above_ask, vol_below_bid, present]`.
|
|
9
|
+
* - `vwap` = sum_px_size / sum_size over the bar (bit 0 when sum_size > 0);
|
|
10
|
+
* - `share_delta_net` = share_delta_ask - share_delta_bid, buyer-initiated minus seller-initiated delta in shares
|
|
11
|
+
* (mid and none left out; bit 2 when either side is present);
|
|
12
|
+
* - `last_price` the bar's last print price and `iv_last` its last IV among the prints that had one (bit 1 when
|
|
13
|
+
* set): the backend's own rollup of a coarser bucket (`last(iv_last) FILTER (WHERE iv_last IS NOT NULL)`), so a
|
|
14
|
+
* bar read from 5m buckets equals one read from its 1h bucket;
|
|
15
|
+
* - a side sum over no print is unset on the wire and reads 0 here.
|
|
16
|
+
*
|
|
17
|
+
* Tier-invariant by construction: every value the fold reads is a sum, a contract's newest last price or its newest
|
|
18
|
+
* set IV, and the strike window's reference is the bar's contract-weighted underlying (sum_spot_size / size_priced
|
|
19
|
+
* summed over every contract row of the bar), so a bar folds to the same tuples from any tier that fits it (the lane
|
|
20
|
+
* takes the coarsest tier choice, wrun-tier-grid.util).
|
|
21
|
+
*
|
|
22
|
+
* The backend (tsdb-gateway `pkg/tsdb/selects/option_print_agg.go`): a request with no scope word is a CONTRACT
|
|
23
|
+
* read, by underlying (`coin`), served from `option_print_agg_<tier>` (1m kept 7 days, 5m 30 days, 1h and 1d kept).
|
|
24
|
+
* The worker asks one tier per ask (the lane's tier rule) and answers one row per bucket `[bucketMs, raw, ...]`,
|
|
25
|
+
* each raw tuple the bucket's sums for one contract (`WRUN_OPTION_CONTRACT_FLOW_RAW_WIDTH` values); the lane's
|
|
26
|
+
* per-bar fold sums them per contract and applies the knobs that need the whole bar.
|
|
27
|
+
*/
|
|
28
|
+
import { newYorkDayNumber, newYorkInstantMs, parseOptionSymbol } from '../options/option-symbol.util.js';
|
|
29
|
+
import { WRUN_PLANE_PAYLOAD_KEY } from '../chart/opra-read-access.leaf.js';
|
|
30
|
+
import { wrunPresentMaskOf } from './wrun-present-bits.util.js';
|
|
31
|
+
import { encodeSymbol } from './wrun-symbol-code.util.js';
|
|
32
|
+
import { wrunNearestExpiryTuples, wrunOptionExpiriesOf } from './wrun-option-knobs.util.js';
|
|
33
|
+
/** The gateway type the class reads, by name. */
|
|
34
|
+
export const WRUN_OPTION_PRINT_AGG_TYPE = 'OPTION_PRINT_AGG';
|
|
35
|
+
/** f64s per tuple, the `present` mask included. */
|
|
36
|
+
export const WRUN_OPTION_CONTRACT_FLOW_WIDTH = 17;
|
|
37
|
+
/** The tuple's columns. */
|
|
38
|
+
export const WRUN_OPTION_CONTRACT_FLOW_COLUMN = Object.freeze({
|
|
39
|
+
root: 0,
|
|
40
|
+
expiry: 1,
|
|
41
|
+
side: 2,
|
|
42
|
+
strike: 3,
|
|
43
|
+
volAsk: 4,
|
|
44
|
+
volBid: 5,
|
|
45
|
+
volMid: 6,
|
|
46
|
+
volNone: 7,
|
|
47
|
+
premAsk: 8,
|
|
48
|
+
premBid: 9,
|
|
49
|
+
shareDeltaNet: 10,
|
|
50
|
+
vwap: 11,
|
|
51
|
+
lastPrice: 12,
|
|
52
|
+
ivLast: 13,
|
|
53
|
+
volAboveAsk: 14,
|
|
54
|
+
volBelowBid: 15,
|
|
55
|
+
present: 16,
|
|
56
|
+
});
|
|
57
|
+
/** The `present` bits by name (14, the partial bar, is the shared one). */
|
|
58
|
+
export const WRUN_OPTION_CONTRACT_FLOW_BIT = Object.freeze({ vwap: 0, iv: 1, shareDelta: 2 });
|
|
59
|
+
const MINUTE_MS = 60_000;
|
|
60
|
+
const DAY_MS = 86_400_000;
|
|
61
|
+
/** The delayed OPRA embargo with the governed route's margin (15 minutes plus 120 s): a delayed read ends that far
|
|
62
|
+
* behind now, and the reader serves the bucket holding its end whole. */
|
|
63
|
+
const DELAYED_WINDOW_LAG_MS = 17 * MINUTE_MS;
|
|
64
|
+
/** OPTION_PRINT_AGG's contract tiers (tsdb-gateway `option_print_agg_{1m,5m,1h,1d}`): 1m kept 7 days, 5m 30, the
|
|
65
|
+
* hour and the day for good. Each key is the interval word the K control asks the tier by.
|
|
66
|
+
* `servedLagMs` (read by the coarsest tier choice only: the 1m tier stays the fallback for every bar): how long after
|
|
67
|
+
* a bar ends a coarser tier may serve it.
|
|
68
|
+
* - Every coarser tier waits out the delayed window's lag, so a delayed read's end never falls inside one of its
|
|
69
|
+
* buckets: the reader serves that bucket whole, and a 5m or wider bucket would carry prints younger than the
|
|
70
|
+
* 15-minute delay (the 120 s margin covers a 1m bucket only).
|
|
71
|
+
* - The hour and the day are materialized only (no forming bucket), each landing a closed bucket at its refresh
|
|
72
|
+
* job's next run past the job's end offset (tsdb-gateway values.cme.yaml): the hour by `option-print` (every 2
|
|
73
|
+
* minutes, 5 minutes back), the day by `option-print-slow` (hourly at :30, 4 hours back); the lags add a margin for
|
|
74
|
+
* the run. */
|
|
75
|
+
export const WRUN_OPTION_PRINT_AGG_TIERS = Object.freeze([
|
|
76
|
+
{ key: '1m', ms: MINUTE_MS, retentionMs: 7 * DAY_MS },
|
|
77
|
+
{ key: '5m', ms: 5 * MINUTE_MS, retentionMs: 30 * DAY_MS, servedLagMs: DELAYED_WINDOW_LAG_MS },
|
|
78
|
+
{ key: '1h', ms: 60 * MINUTE_MS, servedLagMs: 20 * MINUTE_MS },
|
|
79
|
+
{ key: '1d', ms: DAY_MS, servedLagMs: 6 * 60 * MINUTE_MS },
|
|
80
|
+
]);
|
|
81
|
+
/** The most contract rows one read may hold: the worker twin fails a window past it loudly, never truncated, and the
|
|
82
|
+
* lane's row budget keeps its asks under it before any fetch. */
|
|
83
|
+
export const WRUN_OPTION_CONTRACT_FLOW_MAX_ROWS = 500_000;
|
|
84
|
+
/**
|
|
85
|
+
* The contract rows one regular session holds at each tier (one row per contract per bucket it traded in), the row
|
|
86
|
+
* budget's projection for EVERY underlying: SPY's, measured on 2026-10-14 (120 of its 13,168 listed contracts sampled
|
|
87
|
+
* at random, every 1m trade bar of the session, scaled to the chain), the upper end of a bootstrap 90% interval (the
|
|
88
|
+
* point estimates: 169k, 84k, 23k and 6.0k). A smaller chain is projected as SPY's (its older bars go partial sooner
|
|
89
|
+
* than they need to); a larger one could still reach the worker's cap, which then fails loudly.
|
|
90
|
+
*/
|
|
91
|
+
export const WRUN_OPTION_CONTRACT_FLOW_SESSION_ROWS = Object.freeze({
|
|
92
|
+
'1m': 262_000,
|
|
93
|
+
'5m': 113_000,
|
|
94
|
+
'1h': 28_000,
|
|
95
|
+
'1d': 7_000,
|
|
96
|
+
});
|
|
97
|
+
/** A regular session's print span in New York, 09:30 to 16:15 (ETF options trade to 16:15), in minutes. */
|
|
98
|
+
const SESSION_PRINT_MINUTES = 405;
|
|
99
|
+
/** Each New York trade day's print span `[open, close)` in ms, by day number (memoized: a window walks the same days
|
|
100
|
+
* again on every plan). */
|
|
101
|
+
const sessionSpans = new Map();
|
|
102
|
+
const SESSION_SPANS_MAX = 4_096;
|
|
103
|
+
function sessionSpanOfDay(day) {
|
|
104
|
+
const held = sessionSpans.get(day);
|
|
105
|
+
if (held !== undefined)
|
|
106
|
+
return held;
|
|
107
|
+
const date = new Date(day * DAY_MS);
|
|
108
|
+
const [year, month, dayOfMonth] = [date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()];
|
|
109
|
+
const span = [
|
|
110
|
+
newYorkInstantMs(year, month, dayOfMonth, 9, 30),
|
|
111
|
+
newYorkInstantMs(year, month, dayOfMonth, 16, 15),
|
|
112
|
+
];
|
|
113
|
+
if (sessionSpans.size >= SESSION_SPANS_MAX)
|
|
114
|
+
sessionSpans.clear();
|
|
115
|
+
sessionSpans.set(day, span);
|
|
116
|
+
return span;
|
|
117
|
+
}
|
|
118
|
+
/** The regular-session print minutes inside `[fromMs, toMs)`: each weekday's 09:30 to 16:15 New York (a holiday
|
|
119
|
+
* counts as a session, so the projection only errs high). */
|
|
120
|
+
export function wrunOptionPrintSessionMinutes(fromMs, toMs) {
|
|
121
|
+
if (!Number.isFinite(fromMs) || !Number.isFinite(toMs) || !(toMs > fromMs))
|
|
122
|
+
return 0;
|
|
123
|
+
let minutes = 0;
|
|
124
|
+
const lastDay = newYorkDayNumber(toMs - 1);
|
|
125
|
+
for (let day = newYorkDayNumber(fromMs); day <= lastDay; day += 1) {
|
|
126
|
+
const weekday = new Date(day * DAY_MS).getUTCDay();
|
|
127
|
+
if (weekday === 0 || weekday === 6)
|
|
128
|
+
continue;
|
|
129
|
+
const [open, close] = sessionSpanOfDay(day);
|
|
130
|
+
const overlap = Math.min(toMs, close) - Math.max(fromMs, open);
|
|
131
|
+
if (overlap > 0)
|
|
132
|
+
minutes += overlap / MINUTE_MS;
|
|
133
|
+
}
|
|
134
|
+
return minutes;
|
|
135
|
+
}
|
|
136
|
+
/** The rows one host bar is projected to read at its tier, up to the clock (the lane's row budget): the session's
|
|
137
|
+
* rows at that tier in proportion to the print minutes the bar covers. No tier: none. */
|
|
138
|
+
export function wrunOptionContractFlowBarRows(bar, nowMs) {
|
|
139
|
+
const perSession = bar.tier === undefined ? undefined : WRUN_OPTION_CONTRACT_FLOW_SESSION_ROWS[bar.tier.key];
|
|
140
|
+
if (perSession === undefined)
|
|
141
|
+
return 0;
|
|
142
|
+
return (perSession * wrunOptionPrintSessionMinutes(bar.openMs, Math.min(bar.endMs, nowMs))) / SESSION_PRINT_MINUTES;
|
|
143
|
+
}
|
|
144
|
+
/** One bucket's sums for one contract, as the worker hands them to the fold. */
|
|
145
|
+
export const WRUN_OPTION_CONTRACT_FLOW_RAW = Object.freeze({
|
|
146
|
+
root: 0,
|
|
147
|
+
expiry: 1,
|
|
148
|
+
side: 2,
|
|
149
|
+
strike: 3,
|
|
150
|
+
volAsk: 4,
|
|
151
|
+
volBid: 5,
|
|
152
|
+
volMid: 6,
|
|
153
|
+
volNone: 7,
|
|
154
|
+
premAsk: 8,
|
|
155
|
+
premBid: 9,
|
|
156
|
+
shareDeltaAsk: 10,
|
|
157
|
+
shareDeltaBid: 11,
|
|
158
|
+
sumPxSize: 12,
|
|
159
|
+
sumSize: 13,
|
|
160
|
+
lastPrice: 14,
|
|
161
|
+
ivLast: 15,
|
|
162
|
+
/** Underlying price x contracts over the bucket's prints that carried an underlying (`sum_spot_size`). */
|
|
163
|
+
sumSpotSize: 16,
|
|
164
|
+
volAboveAsk: 17,
|
|
165
|
+
volBelowBid: 18,
|
|
166
|
+
flags: 19,
|
|
167
|
+
/** The contracts of those prints (`size_priced`). */
|
|
168
|
+
sizePriced: 20,
|
|
169
|
+
});
|
|
170
|
+
export const WRUN_OPTION_CONTRACT_FLOW_RAW_WIDTH = 21;
|
|
171
|
+
/** The raw tuple's `flags`: which optional sums the bucket carried. */
|
|
172
|
+
const RAW_FLAG = Object.freeze({ shareDeltaAsk: 1, shareDeltaBid: 2, ivLast: 4 });
|
|
173
|
+
/** An instance's payload as its acquisition (knob fields that are not valid read absent). */
|
|
174
|
+
export function wrunOptionContractFlowAcquisitionOf(extras) {
|
|
175
|
+
const positive = (value) => typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : undefined;
|
|
176
|
+
const strikeWindowPct = positive(extras?.strikeWindowPct);
|
|
177
|
+
const minVolume = positive(extras?.minVolume);
|
|
178
|
+
return {
|
|
179
|
+
coin: typeof extras?.coin === 'string' ? extras.coin : '',
|
|
180
|
+
...(typeof extras?.expiries === 'string' ? { expiries: extras.expiries } : {}),
|
|
181
|
+
...(strikeWindowPct !== undefined ? { strikeWindowPct } : {}),
|
|
182
|
+
...(minVolume !== undefined ? { minVolume } : {}),
|
|
183
|
+
...(typeof extras?.tier === 'string' ? { tier: extras.tier } : {}),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/** Whether a payload is an `option_contract_flow` lane ask the K control serves: it names the OPRA plane, a coin and
|
|
187
|
+
* one of the contract tiers (any other caller is declined, fail closed). */
|
|
188
|
+
export function isWrunOptionContractFlowAsk(payload) {
|
|
189
|
+
const acquisition = wrunOptionContractFlowAcquisitionOf(payload);
|
|
190
|
+
return (payload?.[WRUN_PLANE_PAYLOAD_KEY] === 'opra' &&
|
|
191
|
+
acquisition.coin !== '' &&
|
|
192
|
+
WRUN_OPTION_PRINT_AGG_TIERS.some((tier) => tier.key === acquisition.tier));
|
|
193
|
+
}
|
|
194
|
+
/** The tier a key names (one of the contract tiers), or undefined. */
|
|
195
|
+
export function wrunOptionPrintAggTierOf(key) {
|
|
196
|
+
return WRUN_OPTION_PRINT_AGG_TIERS.find((tier) => tier.key === key);
|
|
197
|
+
}
|
|
198
|
+
const drops = { time: 0, contract: 0, root: 0, scope: 0, value: 0 };
|
|
199
|
+
/** The rows this thread dropped since load, by reason (the lane's diagnostics: a refused root among them). */
|
|
200
|
+
export function wrunOptionContractFlowDrops() {
|
|
201
|
+
return { ...drops };
|
|
202
|
+
}
|
|
203
|
+
/** Spec hook: zero the drop counters. */
|
|
204
|
+
export function __resetWrunOptionContractFlowDropsForTest() {
|
|
205
|
+
for (const reason of Object.keys(drops))
|
|
206
|
+
drops[reason] = 0;
|
|
207
|
+
}
|
|
208
|
+
function numberOf(value) {
|
|
209
|
+
if (typeof value === 'number')
|
|
210
|
+
return value;
|
|
211
|
+
if (typeof value === 'bigint')
|
|
212
|
+
return Number(value);
|
|
213
|
+
if (typeof value === 'string' && value.trim() !== '')
|
|
214
|
+
return Number(value);
|
|
215
|
+
return Number.NaN;
|
|
216
|
+
}
|
|
217
|
+
function optionalNumberOf(value) {
|
|
218
|
+
if (value === undefined || value === null)
|
|
219
|
+
return undefined;
|
|
220
|
+
const number = numberOf(value);
|
|
221
|
+
return Number.isFinite(number) ? number : undefined;
|
|
222
|
+
}
|
|
223
|
+
/** A bucket's start in ms off its Timestamp (whole seconds). */
|
|
224
|
+
function bucketMsOf(timestamp) {
|
|
225
|
+
if (timestamp === null || typeof timestamp !== 'object')
|
|
226
|
+
return Number.NaN;
|
|
227
|
+
const stamp = timestamp;
|
|
228
|
+
return numberOf(stamp.signedSeconds ?? stamp.signed_seconds ?? stamp.seconds ?? stamp.s) * 1000;
|
|
229
|
+
}
|
|
230
|
+
/** Whether a row is a CONTRACT row: its scope unset or CONTRACT (0, or its JSON name). */
|
|
231
|
+
function isContractRow(scope) {
|
|
232
|
+
return scope === undefined || scope === null || scope === 0 || scope === 'OPTION_PRINT_AGG_SCOPE_CONTRACT';
|
|
233
|
+
}
|
|
234
|
+
const CONTRACT_CACHE_MAX = 50_000;
|
|
235
|
+
const contracts = new Map();
|
|
236
|
+
function contractOf(symbol) {
|
|
237
|
+
const cached = contracts.get(symbol);
|
|
238
|
+
if (cached !== undefined)
|
|
239
|
+
return cached;
|
|
240
|
+
const parsed = parseOptionSymbol('opra', symbol);
|
|
241
|
+
const contract = parsed === null ? null : { rootCode: encodeSymbol(parsed.root), side: parsed.side };
|
|
242
|
+
if (contracts.size >= CONTRACT_CACHE_MAX)
|
|
243
|
+
contracts.clear();
|
|
244
|
+
contracts.set(symbol, contract);
|
|
245
|
+
return contract;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* One OPTION_PRINT_AGG CONTRACT row as a raw tuple (the history shape: a reshaped protobuf-es message, int64 as
|
|
249
|
+
* bigint, unset optionals undefined; a JSON shape reads the same). `series` names the contract (its OSI symbol, the
|
|
250
|
+
* option type). A scope row, a row missing its time or contract, or one whose root the codec refuses is dropped and
|
|
251
|
+
* counted.
|
|
252
|
+
*/
|
|
253
|
+
export function wrunOptionContractFlowRowOf(point, series) {
|
|
254
|
+
const drop = (reason) => {
|
|
255
|
+
drops[reason] += 1;
|
|
256
|
+
return reason;
|
|
257
|
+
};
|
|
258
|
+
if (!point)
|
|
259
|
+
return drop('value');
|
|
260
|
+
if (!isContractRow(point.scope))
|
|
261
|
+
return drop('scope');
|
|
262
|
+
const bucketMs = bucketMsOf(point.timestamp);
|
|
263
|
+
if (!Number.isFinite(bucketMs))
|
|
264
|
+
return drop('time');
|
|
265
|
+
const symbol = typeof series?.symbol === 'string' ? series.symbol : '';
|
|
266
|
+
const contract = symbol === '' ? null : contractOf(symbol);
|
|
267
|
+
if (contract === null)
|
|
268
|
+
return drop('contract');
|
|
269
|
+
if (contract.rootCode === undefined)
|
|
270
|
+
return drop('root');
|
|
271
|
+
const optionType = series?.optionType;
|
|
272
|
+
const side = optionType === 'CALL' || optionType === 2
|
|
273
|
+
? 1
|
|
274
|
+
: optionType === 'PUT' || optionType === 1
|
|
275
|
+
? -1
|
|
276
|
+
: contract.side === 'call'
|
|
277
|
+
? 1
|
|
278
|
+
: -1;
|
|
279
|
+
const expiryMs = numberOf(point.expiryMs);
|
|
280
|
+
const strike = numberOf(point.strike);
|
|
281
|
+
if (!Number.isFinite(expiryMs) || !Number.isFinite(strike))
|
|
282
|
+
return drop('value');
|
|
283
|
+
const shareDeltaAsk = optionalNumberOf(point.shareDeltaAsk);
|
|
284
|
+
const shareDeltaBid = optionalNumberOf(point.shareDeltaBid);
|
|
285
|
+
const ivLast = optionalNumberOf(point.ivLast);
|
|
286
|
+
const sum = (value) => optionalNumberOf(value) ?? 0;
|
|
287
|
+
const flags = (shareDeltaAsk !== undefined ? RAW_FLAG.shareDeltaAsk : 0) +
|
|
288
|
+
(shareDeltaBid !== undefined ? RAW_FLAG.shareDeltaBid : 0) +
|
|
289
|
+
(ivLast !== undefined ? RAW_FLAG.ivLast : 0);
|
|
290
|
+
return {
|
|
291
|
+
bucketMs,
|
|
292
|
+
raw: [
|
|
293
|
+
contract.rootCode,
|
|
294
|
+
expiryMs,
|
|
295
|
+
side,
|
|
296
|
+
strike,
|
|
297
|
+
sum(point.volAsk),
|
|
298
|
+
sum(point.volBid),
|
|
299
|
+
sum(point.volMid),
|
|
300
|
+
sum(point.volNone),
|
|
301
|
+
sum(point.premAsk),
|
|
302
|
+
sum(point.premBid),
|
|
303
|
+
shareDeltaAsk ?? 0,
|
|
304
|
+
shareDeltaBid ?? 0,
|
|
305
|
+
sum(point.sumPxSize),
|
|
306
|
+
sum(point.sumSize),
|
|
307
|
+
sum(point.lastPrice),
|
|
308
|
+
ivLast ?? 0,
|
|
309
|
+
sum(point.sumSpotSize),
|
|
310
|
+
sum(point.volAboveAsk),
|
|
311
|
+
sum(point.volBelowBid),
|
|
312
|
+
flags,
|
|
313
|
+
sum(point.sizePriced),
|
|
314
|
+
],
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/** Whether a contract row is a "0dte" row: its expiry falls on the trade date of its bucket (the New York date at
|
|
318
|
+
* the bucket's middle, so a UTC day bucket reads its own session's date). */
|
|
319
|
+
export function wrunOptionContractFlowRowIsZeroDte(row, tierMs) {
|
|
320
|
+
const middle = row.bucketMs + Math.floor(Math.max(0, tierMs) / 2);
|
|
321
|
+
return newYorkDayNumber(middle) === newYorkDayNumber(row.raw[WRUN_OPTION_CONTRACT_FLOW_RAW.expiry]);
|
|
322
|
+
}
|
|
323
|
+
/** Whether a cell is a raw contract tuple: exactly the raw width of finite numbers. */
|
|
324
|
+
function isRawTuple(cell) {
|
|
325
|
+
return (Array.isArray(cell) &&
|
|
326
|
+
cell.length === WRUN_OPTION_CONTRACT_FLOW_RAW_WIDTH &&
|
|
327
|
+
cell.every((value) => typeof value === 'number' && Number.isFinite(value)));
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* One host bar's contract tuples from its buckets' raw rows (in bucket order), under the acquisition's knobs:
|
|
331
|
+
* - every contract's sums over the bar, its last price from its newest bucket and its IV from its newest bucket that
|
|
332
|
+
* had one;
|
|
333
|
+
* - `expiries: "nearest:N"`: the contracts of the bar's N nearest expiries (among every contract that traded);
|
|
334
|
+
* - `strike_window_pct`: the strikes within that many percent of the bar's underlying, its contract-weighted price
|
|
335
|
+
* over the bar's prints that carried one (sum_spot_size / size_priced over every contract row of the bar: the same
|
|
336
|
+
* from any tier and any row order; a bar no priced print reached keeps every strike, there being nothing to judge
|
|
337
|
+
* by);
|
|
338
|
+
* - `min_volume`: a contract whose bar total contracts (`sum_size`) is below it is dropped.
|
|
339
|
+
* Sorted by root, expiry, strike, then side.
|
|
340
|
+
*/
|
|
341
|
+
export function foldWrunOptionContractFlowBar(rows, acquisition) {
|
|
342
|
+
const knobs = wrunOptionContractFlowAcquisitionOf(acquisition);
|
|
343
|
+
const R = WRUN_OPTION_CONTRACT_FLOW_RAW;
|
|
344
|
+
const byContract = new Map();
|
|
345
|
+
let spotSize = 0;
|
|
346
|
+
let sizePriced = 0;
|
|
347
|
+
for (const row of rows) {
|
|
348
|
+
const at = Number(row[0]);
|
|
349
|
+
for (let index = 1; index < row.length; index += 1) {
|
|
350
|
+
const raw = row[index];
|
|
351
|
+
if (!isRawTuple(raw))
|
|
352
|
+
continue;
|
|
353
|
+
const flags = raw[R.flags];
|
|
354
|
+
spotSize += raw[R.sumSpotSize];
|
|
355
|
+
sizePriced += raw[R.sizePriced];
|
|
356
|
+
const key = `${raw[R.root]}|${raw[R.expiry]}|${raw[R.side]}|${raw[R.strike]}`;
|
|
357
|
+
const sum = byContract.get(key);
|
|
358
|
+
if (sum === undefined) {
|
|
359
|
+
byContract.set(key, {
|
|
360
|
+
raw: [...raw],
|
|
361
|
+
flags,
|
|
362
|
+
lastAt: at,
|
|
363
|
+
ivAt: (flags & RAW_FLAG.ivLast) !== 0 ? at : Number.NEGATIVE_INFINITY,
|
|
364
|
+
});
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
for (const column of [
|
|
368
|
+
R.volAsk,
|
|
369
|
+
R.volBid,
|
|
370
|
+
R.volMid,
|
|
371
|
+
R.volNone,
|
|
372
|
+
R.premAsk,
|
|
373
|
+
R.premBid,
|
|
374
|
+
R.shareDeltaAsk,
|
|
375
|
+
R.shareDeltaBid,
|
|
376
|
+
R.sumPxSize,
|
|
377
|
+
R.sumSize,
|
|
378
|
+
R.volAboveAsk,
|
|
379
|
+
R.volBelowBid,
|
|
380
|
+
]) {
|
|
381
|
+
sum.raw[column] += raw[column];
|
|
382
|
+
}
|
|
383
|
+
sum.flags |= flags & (RAW_FLAG.shareDeltaAsk | RAW_FLAG.shareDeltaBid);
|
|
384
|
+
if (at >= sum.lastAt) {
|
|
385
|
+
sum.raw[R.lastPrice] = raw[R.lastPrice];
|
|
386
|
+
sum.lastAt = at;
|
|
387
|
+
}
|
|
388
|
+
if ((flags & RAW_FLAG.ivLast) !== 0 && at >= sum.ivAt) {
|
|
389
|
+
sum.raw[R.ivLast] = raw[R.ivLast];
|
|
390
|
+
sum.ivAt = at;
|
|
391
|
+
sum.flags |= RAW_FLAG.ivLast;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
let sums = [...byContract.values()];
|
|
396
|
+
const expiries = wrunOptionExpiriesOf(knobs.expiries);
|
|
397
|
+
if (expiries?.kind === 'nearest') {
|
|
398
|
+
const kept = new Set(wrunNearestExpiryTuples(sums.map((sum) => sum.raw), expiries.count, R.expiry));
|
|
399
|
+
sums = sums.filter((sum) => kept.has(sum.raw));
|
|
400
|
+
}
|
|
401
|
+
const pct = knobs.strikeWindowPct;
|
|
402
|
+
const spot = sizePriced > 0 ? spotSize / sizePriced : undefined;
|
|
403
|
+
if (pct !== undefined && spot !== undefined && spot > 0) {
|
|
404
|
+
const reach = (spot * pct) / 100;
|
|
405
|
+
sums = sums.filter((sum) => Math.abs(sum.raw[R.strike] - spot) <= reach);
|
|
406
|
+
}
|
|
407
|
+
const floor = knobs.minVolume;
|
|
408
|
+
if (floor !== undefined)
|
|
409
|
+
sums = sums.filter((sum) => sum.raw[R.sumSize] >= floor);
|
|
410
|
+
return sums
|
|
411
|
+
.map((sum) => contractFlowTuple(sum))
|
|
412
|
+
.sort((a, b) => a[WRUN_OPTION_CONTRACT_FLOW_COLUMN.root] - b[WRUN_OPTION_CONTRACT_FLOW_COLUMN.root] ||
|
|
413
|
+
a[WRUN_OPTION_CONTRACT_FLOW_COLUMN.expiry] - b[WRUN_OPTION_CONTRACT_FLOW_COLUMN.expiry] ||
|
|
414
|
+
a[WRUN_OPTION_CONTRACT_FLOW_COLUMN.strike] - b[WRUN_OPTION_CONTRACT_FLOW_COLUMN.strike] ||
|
|
415
|
+
b[WRUN_OPTION_CONTRACT_FLOW_COLUMN.side] - a[WRUN_OPTION_CONTRACT_FLOW_COLUMN.side]);
|
|
416
|
+
}
|
|
417
|
+
/** A contract's bar sums as the class's tuple. */
|
|
418
|
+
function contractFlowTuple(sum) {
|
|
419
|
+
const R = WRUN_OPTION_CONTRACT_FLOW_RAW;
|
|
420
|
+
const raw = sum.raw;
|
|
421
|
+
const sumSize = raw[R.sumSize];
|
|
422
|
+
const hasVwap = sumSize > 0;
|
|
423
|
+
const hasIv = (sum.flags & RAW_FLAG.ivLast) !== 0;
|
|
424
|
+
const hasDelta = (sum.flags & (RAW_FLAG.shareDeltaAsk | RAW_FLAG.shareDeltaBid)) !== 0;
|
|
425
|
+
const bits = [];
|
|
426
|
+
if (hasVwap)
|
|
427
|
+
bits.push(WRUN_OPTION_CONTRACT_FLOW_BIT.vwap);
|
|
428
|
+
if (hasIv)
|
|
429
|
+
bits.push(WRUN_OPTION_CONTRACT_FLOW_BIT.iv);
|
|
430
|
+
if (hasDelta)
|
|
431
|
+
bits.push(WRUN_OPTION_CONTRACT_FLOW_BIT.shareDelta);
|
|
432
|
+
return [
|
|
433
|
+
raw[R.root],
|
|
434
|
+
raw[R.expiry],
|
|
435
|
+
raw[R.side],
|
|
436
|
+
raw[R.strike],
|
|
437
|
+
raw[R.volAsk],
|
|
438
|
+
raw[R.volBid],
|
|
439
|
+
raw[R.volMid],
|
|
440
|
+
raw[R.volNone],
|
|
441
|
+
raw[R.premAsk],
|
|
442
|
+
raw[R.premBid],
|
|
443
|
+
hasDelta ? raw[R.shareDeltaAsk] - raw[R.shareDeltaBid] : 0,
|
|
444
|
+
hasVwap ? raw[R.sumPxSize] / sumSize : 0,
|
|
445
|
+
raw[R.lastPrice],
|
|
446
|
+
hasIv ? raw[R.ivLast] : 0,
|
|
447
|
+
raw[R.volAboveAsk],
|
|
448
|
+
raw[R.volBelowBid],
|
|
449
|
+
wrunPresentMaskOf(bits),
|
|
450
|
+
];
|
|
451
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** A knob of an OPRA class outside its words: om's one name for every such refusal. */
|
|
2
|
+
export declare const WRUN_OPTION_KNOB_INVALID_CODE = "wrun_option_knob_invalid";
|
|
3
|
+
/** The `expiries` words, as the om kit reads them. */
|
|
4
|
+
export type WrunOptionExpiries = {
|
|
5
|
+
kind: 'all';
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'nearest';
|
|
8
|
+
count: number;
|
|
9
|
+
} | {
|
|
10
|
+
kind: '0dte';
|
|
11
|
+
};
|
|
12
|
+
/** The words `expiries` takes, for a refusal. */
|
|
13
|
+
export declare const WRUN_OPTION_EXPIRIES_WORDS = "\"all\", \"nearest:N\" (the N nearest live expiries, 1 to 999) or \"0dte\" (the expiries on the trade date)";
|
|
14
|
+
/** The most `strike_window_pct` may be. */
|
|
15
|
+
export declare const WRUN_OPTION_STRIKE_WINDOW_MAX_PCT = 100;
|
|
16
|
+
/** An `expiries` knob as its words read (absent is "all"), or undefined for a word outside them. */
|
|
17
|
+
export declare function wrunOptionExpiriesOf(value: unknown): WrunOptionExpiries | undefined;
|
|
18
|
+
/** The canonical facet word of an `expiries` reading: absent for "all" (one acquisition with an absent knob). */
|
|
19
|
+
export declare function wrunOptionExpiriesWord(expiries: WrunOptionExpiries): string | undefined;
|
|
20
|
+
/** The canonical spelling of an `expiries` reading with "all" spelled out (the state lane's ask word; equal words
|
|
21
|
+
* share one fetch). */
|
|
22
|
+
export declare function wrunOptionExpiriesText(expiries: WrunOptionExpiries): string;
|
|
23
|
+
/** Refuse an OPRA class's knob by name (`wrun_option_knob_invalid`), a gate the author fixes in the code. */
|
|
24
|
+
export declare function refuseWrunOptionKnob(ctx: {
|
|
25
|
+
inputName: string;
|
|
26
|
+
sourceClass: string;
|
|
27
|
+
}, knob: string, value: unknown, takes: string): never;
|
|
28
|
+
/** The input's `expiries`, validated: its reading, or a refusal by name. */
|
|
29
|
+
export declare function wrunOptionExpiriesKnob(source: Readonly<Record<string, unknown>>, ctx: {
|
|
30
|
+
inputName: string;
|
|
31
|
+
sourceClass: string;
|
|
32
|
+
}): WrunOptionExpiries;
|
|
33
|
+
/** The input's `strike_window_pct`, validated: the percent, undefined when absent, or a refusal by name. */
|
|
34
|
+
export declare function wrunOptionStrikeWindowKnob(source: Readonly<Record<string, unknown>>, ctx: {
|
|
35
|
+
inputName: string;
|
|
36
|
+
sourceClass: string;
|
|
37
|
+
}): number | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* A bar's tuples kept to the `count` nearest expiries among them: the `count` smallest distinct values of the
|
|
40
|
+
* expiry column (`expiryColumn`), every tuple of those expiries kept in its order. Fewer distinct expiries: every
|
|
41
|
+
* tuple.
|
|
42
|
+
*/
|
|
43
|
+
export declare function wrunNearestExpiryTuples<T extends ReadonlyArray<number>>(tuples: readonly T[], count: number, expiryColumn: number): T[];
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The knob words of the OPRA option classes (UW-PARITY source contract v2, global rule 4), one spelling each, the om
|
|
3
|
+
* kit's own (`wrunOptionExpiries` and the knob tables in wrun-host/option-cells.ts, `optionCellFacets` in
|
|
4
|
+
* wrun-host/plan.ts): a sheet om validated reads the same here, and one that bypassed om is refused by the same names.
|
|
5
|
+
*
|
|
6
|
+
* - `expiries`: "all" (an absent knob too), "nearest:N" (the N nearest live expiries, N 1 to 999) or "0dte" (the
|
|
7
|
+
* expiries on the trade date of the print or bucket). Anything else refuses `wrun_option_knob_invalid`.
|
|
8
|
+
* - `strike_window_pct`: a number above 0, at most 100 (the strikes within that many percent of the underlying,
|
|
9
|
+
* either side).
|
|
10
|
+
* - The per-bar `nearest:N` selection over a bar's tuples (`wrunNearestExpiryTuples`): the N smallest distinct
|
|
11
|
+
* expiries among the bar's tuples.
|
|
12
|
+
* - Without a refusal (the worker twins, the contract flow fold): `wrunOptionExpiriesOf`, and its canonical spelling
|
|
13
|
+
* with "all" (`wrunOptionExpiriesText`, `option_contract_state`'s ask word).
|
|
14
|
+
*
|
|
15
|
+
* Pure and light (the lane files read it at module load) and worker-safe: its one runtime import is the refusal
|
|
16
|
+
* record's attach (wrun-refusal.util, worker-safe by design), so a worker control reads it too.
|
|
17
|
+
*/
|
|
18
|
+
import { refuseWrunPollInput, WRUN_POLL_AUTHOR_GATE_SEED } from './sources/wrun-poll-lane.types.js';
|
|
19
|
+
/** A knob of an OPRA class outside its words: om's one name for every such refusal. */
|
|
20
|
+
export const WRUN_OPTION_KNOB_INVALID_CODE = 'wrun_option_knob_invalid';
|
|
21
|
+
const NEAREST_RE = /^nearest:([1-9]\d{0,2})$/;
|
|
22
|
+
/** The words `expiries` takes, for a refusal. */
|
|
23
|
+
export const WRUN_OPTION_EXPIRIES_WORDS = '"all", "nearest:N" (the N nearest live expiries, 1 to 999) or "0dte" (the expiries on the trade date)';
|
|
24
|
+
/** The most `strike_window_pct` may be. */
|
|
25
|
+
export const WRUN_OPTION_STRIKE_WINDOW_MAX_PCT = 100;
|
|
26
|
+
/** An `expiries` knob as its words read (absent is "all"), or undefined for a word outside them. */
|
|
27
|
+
export function wrunOptionExpiriesOf(value) {
|
|
28
|
+
if (value === undefined || value === 'all')
|
|
29
|
+
return { kind: 'all' };
|
|
30
|
+
if (value === '0dte')
|
|
31
|
+
return { kind: '0dte' };
|
|
32
|
+
if (typeof value !== 'string')
|
|
33
|
+
return undefined;
|
|
34
|
+
const match = NEAREST_RE.exec(value);
|
|
35
|
+
return match ? { kind: 'nearest', count: Number(match[1]) } : undefined;
|
|
36
|
+
}
|
|
37
|
+
/** The canonical facet word of an `expiries` reading: absent for "all" (one acquisition with an absent knob). */
|
|
38
|
+
export function wrunOptionExpiriesWord(expiries) {
|
|
39
|
+
if (expiries.kind === 'all')
|
|
40
|
+
return undefined;
|
|
41
|
+
return expiries.kind === 'nearest' ? `nearest:${expiries.count}` : '0dte';
|
|
42
|
+
}
|
|
43
|
+
/** The canonical spelling of an `expiries` reading with "all" spelled out (the state lane's ask word; equal words
|
|
44
|
+
* share one fetch). */
|
|
45
|
+
export function wrunOptionExpiriesText(expiries) {
|
|
46
|
+
return expiries.kind === 'nearest' ? `nearest:${expiries.count}` : expiries.kind;
|
|
47
|
+
}
|
|
48
|
+
/** Refuse an OPRA class's knob by name (`wrun_option_knob_invalid`), a gate the author fixes in the code. */
|
|
49
|
+
export function refuseWrunOptionKnob(ctx, knob, value, takes) {
|
|
50
|
+
return refuseWrunPollInput(ctx, `reads ${ctx.sourceClass} with ${knob} ${JSON.stringify(value) ?? String(value)} ` +
|
|
51
|
+
`(${WRUN_OPTION_KNOB_INVALID_CODE}): ${knob} takes ${takes}`, WRUN_POLL_AUTHOR_GATE_SEED);
|
|
52
|
+
}
|
|
53
|
+
/** The input's `expiries`, validated: its reading, or a refusal by name. */
|
|
54
|
+
export function wrunOptionExpiriesKnob(source, ctx) {
|
|
55
|
+
const expiries = wrunOptionExpiriesOf(source.expiries);
|
|
56
|
+
if (expiries === undefined)
|
|
57
|
+
return refuseWrunOptionKnob(ctx, 'expiries', source.expiries, WRUN_OPTION_EXPIRIES_WORDS);
|
|
58
|
+
return expiries;
|
|
59
|
+
}
|
|
60
|
+
/** The input's `strike_window_pct`, validated: the percent, undefined when absent, or a refusal by name. */
|
|
61
|
+
export function wrunOptionStrikeWindowKnob(source, ctx) {
|
|
62
|
+
const pct = source.strike_window_pct;
|
|
63
|
+
if (pct === undefined)
|
|
64
|
+
return undefined;
|
|
65
|
+
if (typeof pct === 'number' && Number.isFinite(pct) && pct > 0 && pct <= WRUN_OPTION_STRIKE_WINDOW_MAX_PCT)
|
|
66
|
+
return pct;
|
|
67
|
+
return refuseWrunOptionKnob(ctx, 'strike_window_pct', pct, `a number above 0 and at most ${WRUN_OPTION_STRIKE_WINDOW_MAX_PCT} (the strikes within that many percent of the ` +
|
|
68
|
+
'underlying, either side)');
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A bar's tuples kept to the `count` nearest expiries among them: the `count` smallest distinct values of the
|
|
72
|
+
* expiry column (`expiryColumn`), every tuple of those expiries kept in its order. Fewer distinct expiries: every
|
|
73
|
+
* tuple.
|
|
74
|
+
*/
|
|
75
|
+
export function wrunNearestExpiryTuples(tuples, count, expiryColumn) {
|
|
76
|
+
const expiries = [...new Set(tuples.map((tuple) => tuple[expiryColumn]))].sort((a, b) => a - b);
|
|
77
|
+
if (expiries.length <= count)
|
|
78
|
+
return [...tuples];
|
|
79
|
+
const kept = new Set(expiries.slice(0, count));
|
|
80
|
+
return tuples.filter((tuple) => kept.has(tuple[expiryColumn]));
|
|
81
|
+
}
|