@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,446 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared half of the options row lanes (`option_strikes`, `option_contract_state`, `option_surface`,
|
|
3
|
+
* `option_prints`, `option_contract_flow`, each a file under `./row-lanes/`): the chart's options chain as the run
|
|
4
|
+
* resolves it (once per run, on the main thread), the ONE chain resolver a chain lane reads its chain through
|
|
5
|
+
* (`resolveWrunLaneChainChart` then `decideWrunLaneChain`: the plane, the exchange, the underlying, the coin and the
|
|
6
|
+
* book), the knob words of the options classes and their refusals by name.
|
|
7
|
+
*
|
|
8
|
+
* ONE venue decision for every chain class: the options chain lane (wrun-overlay-run.util
|
|
9
|
+
* `wrunOptionsChainLaneExtrasFor`) and the chain row lanes resolve the chart's chain through the same function
|
|
10
|
+
* (`resolveWrunChartChain`, over the chart's market and category) and decide a venue word through the same one
|
|
11
|
+
* (`decideWrunLaneChainIdentity`), so a package reading `options_chain` and `option_surface` never mixes venues.
|
|
12
|
+
*
|
|
13
|
+
* The OPRA-only lanes keep their own wrappers over the same chart resolution (`resolveWrunLaneOpraChain`,
|
|
14
|
+
* `resolveWrunOpraLaneUnderlying`) with their words unchanged, until they read the one resolver too.
|
|
15
|
+
*
|
|
16
|
+
* LIGHT at module load: the row-lane registry loads every lane file, and so this module, on the row builder's import
|
|
17
|
+
* graph. Types, the refusal helpers, the governed exchange predicates (constant sets) and pure parsers only; the
|
|
18
|
+
* resolver (the chain directory service, the option venue gates, the venue table) and pb-common are imported lazily
|
|
19
|
+
* inside the async helpers.
|
|
20
|
+
*/
|
|
21
|
+
import { wrunChartHostEnv } from '../../../host-env.js';
|
|
22
|
+
import { isCmeGoverned } from '../../chart/cme-realtime.util.js';
|
|
23
|
+
import { refuseWrunPollInput } from './wrun-poll-lane.types.js';
|
|
24
|
+
import { wrunLaneChainPlaneOf } from './wrun-row-lane.types.js';
|
|
25
|
+
import { decideWrunOptionsChainIdentity, WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_IDS, WRUN_OPTIONS_CHAIN_UNAVAILABLE_CODE, } from '../wrun-options-chain.util.js';
|
|
26
|
+
import { refuseWrunOptionKnob } from '../wrun-option-knobs.util.js';
|
|
27
|
+
import { attachWrunRefusal, wrunOptionsStopSeed } from '../wrun-refusal.util.js';
|
|
28
|
+
import { gateSessionHeldElsewhere } from '../../v2/gate-session-latch.util.js';
|
|
29
|
+
/** The chart market a lane resolves its chain for, keyed (one resolution per chart per run). */
|
|
30
|
+
export function wrunLaneChartKey(ctx) {
|
|
31
|
+
return `${ctx.exchange}|${ctx.symbol}|${ctx.coin}`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolve the chart's chain (lazy imports: the resolver reaches the chain directory service): the ONE resolution every
|
|
35
|
+
* chain class reads, the options chain lane's (over the chart's own metadata) and each row lane's
|
|
36
|
+
* (`resolveWrunLaneChartChain`, over its context's market and category). The chart's options controls' resolver
|
|
37
|
+
* (`resolveOptionsChartSource`: an option contract chart on a crypto venue reads its own contract's chain), and a chain
|
|
38
|
+
* directory's own failure on a chart its plane governs (a CME futures chart, a chart on the OPRA plane) as that plane's
|
|
39
|
+
* evidence; any other resolver failure fails the run. Off every plane, the chart's stop reason rides along
|
|
40
|
+
* (`opraStop`, opra-options-gate.util `opraOptionPlaneStop`: the `opra` flag dark, an index chart), so every chain
|
|
41
|
+
* decision over the chart says why it reads no US chain. On a plane another screen holds the session of, nothing is
|
|
42
|
+
* read (`heldElsewhere`): the chain stops by that name at once.
|
|
43
|
+
*/
|
|
44
|
+
export async function resolveWrunChartChain(metadata) {
|
|
45
|
+
const [{ resolveOptionsChartSource }, { governedOptionPlane, opraOptionPlaneStop }] = await Promise.all([
|
|
46
|
+
wrunChartHostEnv().market.loadOptionsChartSource(),
|
|
47
|
+
wrunChartHostEnv().market.loadOptionsGate(),
|
|
48
|
+
]);
|
|
49
|
+
const exchange = typeof metadata?.exchange === 'string' ? metadata.exchange : undefined;
|
|
50
|
+
// Another screen holds the session of the plane this chart's chain lists on (gate-session-latch.util): its reader
|
|
51
|
+
// dials nothing until the take-back, so a directory read would wait out its budget. None is sent. The chart's plane
|
|
52
|
+
// is read only while a latch is held, so every other resolution reads exactly as before.
|
|
53
|
+
if (gateSessionHeldElsewhere('cme') || gateSessionHeldElsewhere('opra')) {
|
|
54
|
+
const plane = governedOptionPlane({ exchange });
|
|
55
|
+
if (plane !== null && gateSessionHeldElsewhere(plane))
|
|
56
|
+
return { heldElsewhere: plane };
|
|
57
|
+
}
|
|
58
|
+
let chartSource;
|
|
59
|
+
try {
|
|
60
|
+
chartSource = (await resolveOptionsChartSource(metadata));
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (isCmeGoverned(exchange))
|
|
64
|
+
return { directoryFailed: 'cme' };
|
|
65
|
+
if (governedOptionPlane({ exchange }) === 'opra')
|
|
66
|
+
return { directoryFailed: 'opra' };
|
|
67
|
+
// A chart whose options list on OPRA but ride no plane stops for a known reason (the flag, the router): that
|
|
68
|
+
// reason decides without a chain, whatever the fallback resolver threw.
|
|
69
|
+
const opraStop = opraOptionPlaneStop({ exchange });
|
|
70
|
+
if (opraStop !== undefined)
|
|
71
|
+
return { opraStop };
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
// A chain on a gate plane stopped nothing. Off every plane, the known reason a chart whose options list on OPRA
|
|
75
|
+
// rides none (the flag, the router) is decided beside the chain the resolver fell back to: that fallback (the coin's
|
|
76
|
+
// Deribit chain) reads "no option chain", which is not why.
|
|
77
|
+
if (chartSource.venue === 'opra' || chartSource.venue === 'cme')
|
|
78
|
+
return { chartSource };
|
|
79
|
+
const opraStop = opraOptionPlaneStop({ exchange });
|
|
80
|
+
return { chartSource, ...(opraStop !== undefined ? { opraStop } : {}) };
|
|
81
|
+
}
|
|
82
|
+
/** An OPRA-only lane on a chart whose plane another screen holds the session of: refused by that name before any read
|
|
83
|
+
* (`options-stopped` / `session-elsewhere`, Resume here), never "the directory did not answer". */
|
|
84
|
+
function refuseWrunLaneSessionElsewhere(ctx, plane) {
|
|
85
|
+
return refuseWrunPollInput(ctx, `reads US options data, but the ${plane.toUpperCase()} options data session is open on another screen: Resume here takes it back`, wrunOptionsStopSeed('session-elsewhere', { severity: 'paused', plane }));
|
|
86
|
+
}
|
|
87
|
+
/** Resolve the chart's chain for a lane: `resolveWrunChartChain` over the lane context's market and category. */
|
|
88
|
+
export function resolveWrunLaneChartChain(ctx) {
|
|
89
|
+
return resolveWrunChartChain({
|
|
90
|
+
exchange: ctx.exchange,
|
|
91
|
+
symbol: ctx.symbol,
|
|
92
|
+
coin: ctx.coin,
|
|
93
|
+
...(typeof ctx.category === 'number' ? { category: ctx.category } : {}),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The OPRA chain an OPRA-only lane reads on this chart (`option_contract_state`: admitted only where the chart's
|
|
98
|
+
* options ride the OPRA plane): its exchange and underlying, or a refusal by name with the options chain's own seeds
|
|
99
|
+
* (the directory did not answer: a service that did not answer; no chain: no options here). A wrapper over the chart's
|
|
100
|
+
* chain resolution, its words unchanged, for the OPRA-only lanes that still import it.
|
|
101
|
+
*/
|
|
102
|
+
export async function resolveWrunLaneOpraChain(ctx) {
|
|
103
|
+
const { chartSource, directoryFailed, heldElsewhere } = await resolveWrunLaneChartChain(ctx);
|
|
104
|
+
if (heldElsewhere !== undefined)
|
|
105
|
+
return refuseWrunLaneSessionElsewhere(ctx, heldElsewhere);
|
|
106
|
+
const market = `${ctx.exchange}/${ctx.symbol}`;
|
|
107
|
+
if (directoryFailed !== undefined) {
|
|
108
|
+
return refuseWrunPollInput(ctx, `reads US options data, and the US option chain directory did not answer for the chart market ${market}: Run again`, { cls: 'service-no-answer', variant: directoryFailed === 'opra' ? 'opra-directory' : 'cme-directory' });
|
|
109
|
+
}
|
|
110
|
+
if (chartSource?.venue === 'opra' && chartSource.exchange.length > 0 && chartSource.underlying.length > 0) {
|
|
111
|
+
return { exchange: chartSource.exchange, underlying: chartSource.underlying };
|
|
112
|
+
}
|
|
113
|
+
return refuseWrunPollInput(ctx, `reads US options data, and OPRA lists no option chain for the chart market ${market} (an index's options do not attach to a stock chart); open a US stock or ETF chart that lists options`, { cls: 'no-options', variant: 'chain', ...(ctx.coin !== '' ? { params: { coin: ctx.coin } } : {}) });
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The underlying the OPRA plane keys an OPRA-only lane's series by (`option_prints`, `option_contract_flow`: a US
|
|
117
|
+
* stock or ETF chart's ticker, an OPRA contract chart's underlying, upper case), or a refusal by name before any
|
|
118
|
+
* fetch: any failure of the chart's chain resolution is the US directory that did not answer (`service-no-answer` /
|
|
119
|
+
* `opra-directory`, Retry), and a chart OPRA lists no options for is `no-options` / `chain`. A wrapper over the
|
|
120
|
+
* chart's chain resolution, its words unchanged (wrun-opra-underlying.util re-exports it for its importers).
|
|
121
|
+
*/
|
|
122
|
+
export async function resolveWrunOpraLaneUnderlying(ctx) {
|
|
123
|
+
const market = `${ctx.exchange}/${ctx.symbol}`;
|
|
124
|
+
const chain = await resolveWrunLaneChartChain(ctx).catch(() => ({ directoryFailed: 'opra' }));
|
|
125
|
+
if (chain.heldElsewhere !== undefined)
|
|
126
|
+
return refuseWrunLaneSessionElsewhere(ctx, chain.heldElsewhere);
|
|
127
|
+
if (chain.directoryFailed !== undefined) {
|
|
128
|
+
return refuseWrunPollInput(ctx, `reads US options data, but the US option chain directory did not answer for the chart market ${market}: Run again`, { cls: 'service-no-answer', variant: 'opra-directory' });
|
|
129
|
+
}
|
|
130
|
+
const source = chain.chartSource;
|
|
131
|
+
const underlying = source?.venue === 'opra' && typeof source.underlying === 'string' ? source.underlying.trim() : '';
|
|
132
|
+
if (underlying === '') {
|
|
133
|
+
return refuseWrunPollInput(ctx, `reads US options data, but OPRA lists no options for the chart market ${market} (an index's options do not ` +
|
|
134
|
+
'attach to a stock chart): open a US stock or ETF chart that lists options, or one of its option contracts', { cls: 'no-options', variant: 'chain', params: ctx.coin !== '' ? { coin: ctx.coin } : {} });
|
|
135
|
+
}
|
|
136
|
+
return underlying.toUpperCase();
|
|
137
|
+
}
|
|
138
|
+
/** The crypto venue words a chain decision reads on this chart: on the OPRA plane no crypto venue lists a US
|
|
139
|
+
* stock's options (the words refuse by the flag alone, no listing asked); anywhere else the run's own resolver
|
|
140
|
+
* over every crypto word (the listing is asked once per coin, and only with the crypto-options gate on). */
|
|
141
|
+
export async function resolveWrunLaneCryptoVenues(chain, chartCoin) {
|
|
142
|
+
const { resolveWrunOptionsChainCryptoVenues } = await wrunChartHostEnv().market.loadOptionsChainVenues();
|
|
143
|
+
const words = Object.keys(WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_IDS);
|
|
144
|
+
const onOpraPlane = chain.chartSource?.venue === 'opra' || chain.directoryFailed === 'opra' || chain.heldElsewhere === 'opra';
|
|
145
|
+
const resolved = await resolveWrunOptionsChainCryptoVenues({
|
|
146
|
+
words: onOpraPlane ? [] : words,
|
|
147
|
+
chartSource: chain.chartSource,
|
|
148
|
+
chartCoin,
|
|
149
|
+
});
|
|
150
|
+
return resolved;
|
|
151
|
+
}
|
|
152
|
+
// ---------------------------------------------------------------------------
|
|
153
|
+
// The one chain resolver (OPTIONS-PORT P1: a chain lane reads the chart's chain on whatever plane it lists on)
|
|
154
|
+
// ---------------------------------------------------------------------------
|
|
155
|
+
// The plane an exchange rides (wrun-row-lane.types, beside the chain mark, so the planner reads it without this
|
|
156
|
+
// module): re-exported for the lanes and the specs that read the resolver.
|
|
157
|
+
export { wrunLaneChainPlaneOf };
|
|
158
|
+
/** The `book` knob's default word: the series named after the chain's coin, else the first series in series order,
|
|
159
|
+
* resolved to that one series when the run plans (`decideWrunLaneChain`), never per answer. */
|
|
160
|
+
export const WRUN_LANE_CHAIN_BOOK_AUTO = 'auto';
|
|
161
|
+
/** A series name as a venue spells it first in its option symbols (tsdb-gateway optionstats `SeriesKey`). */
|
|
162
|
+
const WRUN_LANE_CHAIN_BOOK_RE = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
163
|
+
/** The words `book` takes, for a refusal. */
|
|
164
|
+
const WRUN_LANE_CHAIN_BOOK_WORDS = '"auto" (the series named after the chain\'s coin, else the first series in series order) or one series name of ' +
|
|
165
|
+
"the chain (letters, digits, '_' and '-')";
|
|
166
|
+
/** The expiry a venue writes after the series in an option symbol (optionstats `isOptionExpiryToken`): all digits,
|
|
167
|
+
* `260926` or `20260926`, or a day, month and year, `16OCT26` or `2OCT26`. */
|
|
168
|
+
const WRUN_OPTION_EXPIRY_TOKEN_RE = /^(?:\d{6}|\d{8}|\d{1,2}[A-Z]{3}\d{2})$/;
|
|
169
|
+
/**
|
|
170
|
+
* The series (the book) a listed option belongs to, as the data plane names it: tsdb-gateway optionstats `SeriesKey`,
|
|
171
|
+
* ported. The segments of the symbol before its first expiry token, joined by '-' (Deribit `BTC_USDC-16OCT26-...` is
|
|
172
|
+
* BTC_USDC, OKX `BTC-USD_UM-260926-...` BTC-USD_UM, Bullish `BTC-USDC-20260926-...` BTC-USDC); the coin itself for a
|
|
173
|
+
* symbol that spells no expiry (CME `ESH7 C10000`, OPRA's OSI symbols) or leads with it. Upper case.
|
|
174
|
+
*/
|
|
175
|
+
export function wrunOptionSeriesOf(coin, rawSymbol) {
|
|
176
|
+
const segments = rawSymbol.toUpperCase().split('-');
|
|
177
|
+
const at = segments.findIndex((segment) => WRUN_OPTION_EXPIRY_TOKEN_RE.test(segment));
|
|
178
|
+
return at > 0 ? segments.slice(0, at).join('-') : coin.toUpperCase();
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The default book over a chain's series (D11): the series named after the chain's underlying (the coin the surface
|
|
182
|
+
* job files the chain under: a crypto venue's root coin, the CME futures contract, the OPRA ticker), else the first
|
|
183
|
+
* series in byte order (the job's own order). A chain listing none reads the underlying's own series. Upper case.
|
|
184
|
+
*/
|
|
185
|
+
export function wrunLaneChainDefaultBook(series, underlying) {
|
|
186
|
+
const own = underlying.toUpperCase();
|
|
187
|
+
const listed = [...new Set([...series].map((name) => name.toUpperCase()))].sort();
|
|
188
|
+
return listed.length === 0 || listed.includes(own) ? own : listed[0];
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The book `auto` reads on a decided chain (D11), resolved when the run plans, from the chain's own listing and never
|
|
192
|
+
* from the rows an answer holds, so every ask of one instance (each tier segment, the coarser tier's fallback, each
|
|
193
|
+
* live reconcile) reads the same book:
|
|
194
|
+
* - a CME or OPRA chain: the underlying's own series. Their symbols spell no series (`ESH7 C10000`, OPRA's OSI
|
|
195
|
+
* symbols), so `SeriesKey` files every contract of the chain under the underlying itself: the chain has that one
|
|
196
|
+
* book, and no directory is asked.
|
|
197
|
+
* - a crypto chain: the default book (`wrunLaneChainDefaultBook`) over the series the chain directory lists (the
|
|
198
|
+
* option chain service of the chain's exchange, `optionChainServiceForExchange`: its expiries, then each expiry's
|
|
199
|
+
* instruments, the registry rows the surface job measures), each raw symbol's series by `wrunOptionSeriesOf`. The
|
|
200
|
+
* nearest expiry is read first, and listing the underlying's own series there ends the read (the rule over every
|
|
201
|
+
* expiry picks that series too); otherwise every expiry is read.
|
|
202
|
+
* - a crypto chain whose directory lists no instrument or does not answer: the underlying's own series, the default
|
|
203
|
+
* rule's first choice and the one series name every chain spells without its directory (the job writes it with no
|
|
204
|
+
* series tail). A chain listing no such series (OKX's BTC-USD and BTC-USD_UM) then reads that book empty, until a
|
|
205
|
+
* run whose directory read answers.
|
|
206
|
+
*/
|
|
207
|
+
export async function resolveWrunLaneChainAutoBook(chain) {
|
|
208
|
+
const own = chain.underlying.toUpperCase();
|
|
209
|
+
if (chain.plane !== 'plain' || own === '')
|
|
210
|
+
return own;
|
|
211
|
+
try {
|
|
212
|
+
const listed = await readWrunLaneChainSeries(chain.exchange, chain.underlying);
|
|
213
|
+
return listed === undefined ? own : wrunLaneChainDefaultBook(listed, own);
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
console.warn(`[wrun] the ${chain.exchange} ${chain.underlying} option chain directory did not answer for its books: ` +
|
|
217
|
+
"reading the underlying's own series", error);
|
|
218
|
+
return own;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/** The series a crypto chain's directory lists (see `resolveWrunLaneChainAutoBook`): the nearest expiry's alone when
|
|
222
|
+
* it lists the underlying's own series, else every expiry's that answered; undefined when it lists none. */
|
|
223
|
+
async function readWrunLaneChainSeries(exchangeName, underlying) {
|
|
224
|
+
const [{ optionChainServiceForExchange }, { Exchange }, { withWrunDeadline, WRUN_SOURCE_FETCH_DEADLINE_MS }] = await Promise.all([
|
|
225
|
+
wrunChartHostEnv().market.loadOptionChainService(),
|
|
226
|
+
import('@orangecharts/orange-v2-pb-common'),
|
|
227
|
+
import('../wrun-deadline.util.js'),
|
|
228
|
+
]);
|
|
229
|
+
const exchange = Exchange[exchangeName];
|
|
230
|
+
if (typeof exchange !== 'number')
|
|
231
|
+
return undefined;
|
|
232
|
+
const service = optionChainServiceForExchange(exchangeName);
|
|
233
|
+
const request = { exchange, underlying };
|
|
234
|
+
const label = `wrun option_surface book directory for ${exchangeName}:${underlying}`;
|
|
235
|
+
const expiries = await withWrunDeadline(service.listOptionExpiries(request), WRUN_SOURCE_FETCH_DEADLINE_MS, label);
|
|
236
|
+
const own = underlying.toUpperCase();
|
|
237
|
+
const seriesAt = async (expiryUnix) => {
|
|
238
|
+
const chain = await withWrunDeadline(service.getOptionExpiryChain({ ...request, expiryUnix }), WRUN_SOURCE_FETCH_DEADLINE_MS, label);
|
|
239
|
+
const series = new Set();
|
|
240
|
+
for (const strike of chain?.strikes ?? []) {
|
|
241
|
+
for (const contract of [...strike.calls, ...strike.puts])
|
|
242
|
+
series.add(wrunOptionSeriesOf(own, contract.rawSymbol));
|
|
243
|
+
}
|
|
244
|
+
return series;
|
|
245
|
+
};
|
|
246
|
+
const [nearest, ...later] = expiries;
|
|
247
|
+
if (nearest === undefined)
|
|
248
|
+
return undefined;
|
|
249
|
+
const first = await seriesAt(nearest.expiryUnix).catch(() => undefined);
|
|
250
|
+
if (first?.has(own))
|
|
251
|
+
return first;
|
|
252
|
+
const listed = new Set(first ?? []);
|
|
253
|
+
for (const answer of await Promise.allSettled(later.map((expiry) => seriesAt(expiry.expiryUnix)))) {
|
|
254
|
+
if (answer.status === 'fulfilled')
|
|
255
|
+
for (const series of answer.value)
|
|
256
|
+
listed.add(series);
|
|
257
|
+
}
|
|
258
|
+
return listed.size > 0 ? listed : undefined;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Resolve the chart for the one chain resolver (lazy imports: the chain directory, the venue listing and table, the
|
|
262
|
+
* continuous lead resolver): the chart's chain (`resolveWrunLaneChartChain`, the options chain lane's own), the crypto
|
|
263
|
+
* venue words (`resolveWrunLaneCryptoVenues`), for a CME chain on a continuous alias the contract leading it now
|
|
264
|
+
* (option-chain.service `resolveChainContract`, the roll rule the terminal identity admits the alias by), and each
|
|
265
|
+
* decided chain's default book (`resolveWrunLaneChainAutoBook`, asked once per chain for this chart).
|
|
266
|
+
*/
|
|
267
|
+
export async function resolveWrunLaneChainChart(ctx) {
|
|
268
|
+
const chain = await resolveWrunLaneChartChain(ctx);
|
|
269
|
+
const [cryptoVenues, { hasDeribitOptions }, { OPTION_VENUES }] = await Promise.all([
|
|
270
|
+
resolveWrunLaneCryptoVenues(chain, ctx.coin),
|
|
271
|
+
wrunChartHostEnv().market.loadDeribitOptions(),
|
|
272
|
+
import('../../../constants/option-venues.constants.js'),
|
|
273
|
+
]);
|
|
274
|
+
const venueIds = WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_IDS;
|
|
275
|
+
// A venue word's plain venue table row: a crypto word by its id, any other word naming its row's id itself.
|
|
276
|
+
const plainVenueOf = (word) => {
|
|
277
|
+
const venue = OPTION_VENUES.find((candidate) => candidate.id === (venueIds[word] ?? word));
|
|
278
|
+
return venue?.lane === 'plain' ? venue : undefined;
|
|
279
|
+
};
|
|
280
|
+
const source = chain.chartSource;
|
|
281
|
+
let cmeLead;
|
|
282
|
+
if (source?.venue === 'cme' && source.exchange.length > 0 && source.underlying.length > 0) {
|
|
283
|
+
const { default: optionChainService } = await wrunChartHostEnv().market.loadOptionChainService();
|
|
284
|
+
const contract = await optionChainService.resolveChainContract(source.exchange, source.underlying);
|
|
285
|
+
if (contract !== source.underlying)
|
|
286
|
+
cmeLead = { alias: source.underlying, contract };
|
|
287
|
+
}
|
|
288
|
+
const autoBooks = new Map();
|
|
289
|
+
return {
|
|
290
|
+
chain,
|
|
291
|
+
cryptoVenues,
|
|
292
|
+
deribitListed: hasDeribitOptions,
|
|
293
|
+
venueExchange: (word) => plainVenueOf(word)?.exchanges[0],
|
|
294
|
+
...(cmeLead !== undefined ? { cmeLead } : {}),
|
|
295
|
+
autoBook: (decided) => {
|
|
296
|
+
const key = `${decided.plane}|${decided.exchange}|${decided.underlying}`;
|
|
297
|
+
let book = autoBooks.get(key);
|
|
298
|
+
if (book === undefined) {
|
|
299
|
+
book = resolveWrunLaneChainAutoBook(decided);
|
|
300
|
+
autoBooks.set(key, book);
|
|
301
|
+
}
|
|
302
|
+
return book;
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* The ONE venue decision of every chain class (the options chain lane, `option_surface`): one input's `venue` word
|
|
308
|
+
* against the chart's resolved chain, by the options chain decision (`decideWrunOptionsChainIdentity`: `auto` reads
|
|
309
|
+
* the chart's own options market, a CME future's, a US stock's or a crypto option contract's, else the coin's Deribit
|
|
310
|
+
* chain, else the first venue whose listing names the coin; a pinned word that venue's chain; the `crypto-options`
|
|
311
|
+
* flag, the listing, the directory and the OPRA wall by name). A refusal comes back as the decision's own.
|
|
312
|
+
*/
|
|
313
|
+
export function decideWrunLaneChainIdentity(chart, venue, who) {
|
|
314
|
+
return decideWrunOptionsChainIdentity({
|
|
315
|
+
venue: venue === undefined ? undefined : String(venue),
|
|
316
|
+
chartSource: chart.chain.chartSource,
|
|
317
|
+
chartCoin: who.coin,
|
|
318
|
+
deribitListed: chart.deribitListed,
|
|
319
|
+
cryptoVenues: chart.cryptoVenues,
|
|
320
|
+
marketLabel: who.marketLabel ?? `${who.exchange}/${who.symbol}`,
|
|
321
|
+
inputName: who.inputName,
|
|
322
|
+
official: who.official === true,
|
|
323
|
+
opraUserScripts: who.opraUserScripts === true,
|
|
324
|
+
...(chart.chain.directoryFailed !== undefined ? { directoryFailed: chart.chain.directoryFailed } : {}),
|
|
325
|
+
...(chart.chain.opraStop !== undefined ? { opraStop: chart.chain.opraStop } : {}),
|
|
326
|
+
...(chart.chain.heldElsewhere !== undefined ? { heldElsewhere: chart.chain.heldElsewhere } : {}),
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
/** The input's `book`, validated: `auto` (absent too) or one series name upper case, else a refusal by name
|
|
330
|
+
* (`wrun_option_knob_invalid`, om's one name for an options knob outside its words). */
|
|
331
|
+
export function wrunLaneChainBook(value, ctx) {
|
|
332
|
+
if (value === undefined || value === WRUN_LANE_CHAIN_BOOK_AUTO)
|
|
333
|
+
return WRUN_LANE_CHAIN_BOOK_AUTO;
|
|
334
|
+
if (typeof value === 'string' && WRUN_LANE_CHAIN_BOOK_RE.test(value))
|
|
335
|
+
return value.toUpperCase();
|
|
336
|
+
return refuseWrunOptionKnob(ctx, 'book', value, WRUN_LANE_CHAIN_BOOK_WORDS);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* The ONE chain resolver's decision for one input, over the chart `resolveWrunLaneChainChart` resolved: its `venue`
|
|
340
|
+
* word decided by the venue decision every chain class shares (`decideWrunLaneChainIdentity`, so `auto` reads exactly
|
|
341
|
+
* the chain `options_chain`'s `auto` reads on the same chart), then its `book`, ONE series decided here (a pinned
|
|
342
|
+
* series, or for `auto` the chain's default book, `WrunLaneChainChart.autoBook`). The answer names the plane, the
|
|
343
|
+
* exchange, the underlying the plane files the series under (a CME continuous alias read as the contract leading it
|
|
344
|
+
* now), the coin and the book. Refuses by name with the options chain's own reasons and seeds (a coin no venue lists:
|
|
345
|
+
* `no-chain`), a continuous CME chart whose lead cannot be resolved (`cme-unresolved`, Retry), and a book outside its
|
|
346
|
+
* words.
|
|
347
|
+
*/
|
|
348
|
+
export async function decideWrunLaneChain(chart, knobs, ctx) {
|
|
349
|
+
const decision = decideWrunLaneChainIdentity(chart, knobs.venue, ctx);
|
|
350
|
+
if (!decision.ok)
|
|
351
|
+
throw wrunLaneChainRefusalError(decision, ctx.sourceClass);
|
|
352
|
+
const book = wrunLaneChainBook(knobs.book, ctx);
|
|
353
|
+
const chain = wrunLaneChainOf(decision.identity, chart, ctx);
|
|
354
|
+
return { ...chain, book: book === WRUN_LANE_CHAIN_BOOK_AUTO ? await chart.autoBook(chain) : book };
|
|
355
|
+
}
|
|
356
|
+
/** A decided identity as the chain one input reads, before its book (`decideWrunLaneChain`). */
|
|
357
|
+
function wrunLaneChainOf(identity, chart, ctx) {
|
|
358
|
+
switch (identity.venue) {
|
|
359
|
+
case 'deribit': {
|
|
360
|
+
const exchange = chart.venueExchange(identity.venue) ?? '';
|
|
361
|
+
return { plane: wrunLaneChainPlaneOf(exchange), exchange, underlying: identity.coin, coin: identity.coin };
|
|
362
|
+
}
|
|
363
|
+
case 'crypto': {
|
|
364
|
+
const { exchange, coin } = identity.source;
|
|
365
|
+
return { plane: wrunLaneChainPlaneOf(exchange), exchange, underlying: coin, coin };
|
|
366
|
+
}
|
|
367
|
+
default: {
|
|
368
|
+
const lead = chart.cmeLead;
|
|
369
|
+
if (identity.venue === 'cme' && lead !== undefined && lead.alias === identity.underlying) {
|
|
370
|
+
if (lead.contract === null) {
|
|
371
|
+
throw wrunLaneChainRefusalError({
|
|
372
|
+
ok: false,
|
|
373
|
+
code: WRUN_OPTIONS_CHAIN_UNAVAILABLE_CODE,
|
|
374
|
+
message: `Input '${ctx.inputName}' reads options_chain cells, but the CME option chain of the chart market ` +
|
|
375
|
+
`${ctx.exchange}/${ctx.symbol} could not be resolved (${WRUN_OPTIONS_CHAIN_UNAVAILABLE_CODE}): the ` +
|
|
376
|
+
`contract leading ${lead.alias} could not be resolved; Run again`,
|
|
377
|
+
reason: 'cme-unresolved',
|
|
378
|
+
...(ctx.coin !== '' ? { coin: ctx.coin } : {}),
|
|
379
|
+
}, ctx.sourceClass);
|
|
380
|
+
}
|
|
381
|
+
return {
|
|
382
|
+
plane: wrunLaneChainPlaneOf(identity.exchange),
|
|
383
|
+
exchange: identity.exchange,
|
|
384
|
+
underlying: lead.contract,
|
|
385
|
+
coin: ctx.coin !== '' ? ctx.coin.toUpperCase() : lead.contract,
|
|
386
|
+
continuous: lead.alias,
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
const governedCoin = identity.venue === 'cme' && ctx.coin !== '' ? ctx.coin.toUpperCase() : identity.underlying;
|
|
390
|
+
return {
|
|
391
|
+
plane: wrunLaneChainPlaneOf(identity.exchange),
|
|
392
|
+
exchange: identity.exchange,
|
|
393
|
+
underlying: identity.underlying,
|
|
394
|
+
coin: governedCoin,
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* The record seed of a refused chain decision: the run's own mapping for the options chain
|
|
401
|
+
* (wrun-overlay-run.util `wrunOptionsChainRefusalSeed`, which this light module cannot import; a spec pins the two
|
|
402
|
+
* equal for every reason).
|
|
403
|
+
*/
|
|
404
|
+
export function wrunLaneChainRefusalSeed(refusal) {
|
|
405
|
+
const coin = refusal.coin !== undefined && refusal.coin !== '' ? { coin: refusal.coin } : {};
|
|
406
|
+
const venue = refusal.venueName !== undefined && refusal.venueName !== '' ? { venue: refusal.venueName } : {};
|
|
407
|
+
switch (refusal.reason) {
|
|
408
|
+
// The chart's options read no chain for a known reason: the record says that reason (options-stopped).
|
|
409
|
+
case 'options-stopped':
|
|
410
|
+
return refusal.stop !== undefined
|
|
411
|
+
? wrunOptionsStopSeed(refusal.stop, {
|
|
412
|
+
severity: 'paused',
|
|
413
|
+
...(refusal.plane !== undefined ? { plane: refusal.plane } : {}),
|
|
414
|
+
})
|
|
415
|
+
: { cls: 'run-failed', variant: 'generic' };
|
|
416
|
+
case 'flag-off':
|
|
417
|
+
return { cls: 'no-options', variant: 'flag-off', params: { ...venue, ...coin } };
|
|
418
|
+
case 'venue-not-listed':
|
|
419
|
+
return { cls: 'no-options', variant: 'venue', params: { ...venue, ...coin } };
|
|
420
|
+
case 'cme-venue':
|
|
421
|
+
return { cls: 'no-options', variant: 'cme-venue', params: { ...coin } };
|
|
422
|
+
case 'cme-unresolved':
|
|
423
|
+
return { cls: 'no-options', variant: 'unresolved', params: { ...coin } };
|
|
424
|
+
case 'no-chain':
|
|
425
|
+
return { cls: 'no-options', variant: 'chain', params: { ...coin } };
|
|
426
|
+
case 'cme-directory':
|
|
427
|
+
return { cls: 'service-no-answer', variant: 'cme-directory' };
|
|
428
|
+
case 'opra-official-only':
|
|
429
|
+
return { cls: 'cme-wall', variant: 'opra' };
|
|
430
|
+
case 'opra-directory':
|
|
431
|
+
return { cls: 'service-no-answer', variant: 'opra-directory' };
|
|
432
|
+
default:
|
|
433
|
+
return { cls: 'run-failed', variant: 'generic' };
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
/** A refused chain decision as the error a lane refuses with: the decision's technical words with the input's class
|
|
437
|
+
* in place of `options_chain` (om names the class it reads), and its record's seed. */
|
|
438
|
+
export function wrunLaneChainRefusalError(refusal, sourceClass) {
|
|
439
|
+
return attachWrunRefusal(new Error(refusal.message.replace('reads options_chain cells', `reads ${sourceClass} cells`)), wrunLaneChainRefusalSeed(refusal));
|
|
440
|
+
}
|
|
441
|
+
/** The seed of a knob the author fixes in the code: a failed run, its words in the details. */
|
|
442
|
+
const WRUN_LANE_KNOB_SEED = Object.freeze({ cls: 'run-failed', variant: 'generic' });
|
|
443
|
+
/** Refuse a knob the class does not take, by name (om's sheet refusal for a stray knob). */
|
|
444
|
+
export function refuseWrunLaneStrayKnob(ctx, knob, owners) {
|
|
445
|
+
return refuseWrunPollInput(ctx, `declares ${knob}, which is only valid on ${owners} sources: drop it`, WRUN_LANE_KNOB_SEED);
|
|
446
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { WrunPollLane, WrunPollLaneModule } from './wrun-poll-lane.types.js';
|
|
2
|
+
/** The lanes of the listed modules (index key `./lanes/<file>.ts` -> module), in file order, each
|
|
3
|
+
* file checked against its name and the whole set against the registry's rules. Exported for the spec. */
|
|
4
|
+
export declare function wrunPollLanesOfModules(modules: Readonly<Record<string, WrunPollLaneModule>>): WrunPollLane[];
|
|
5
|
+
/** Every registered lane, in file order. */
|
|
6
|
+
export declare function wrunPollLanes(): readonly WrunPollLane[];
|
|
7
|
+
export declare function wrunPollLaneByKey(laneKey: string): WrunPollLane | undefined;
|
|
8
|
+
/** The lanes serving a source class (several when its fields ride different K controls). */
|
|
9
|
+
export declare function wrunPollLanesOfClass(sourceClass: unknown): readonly WrunPollLane[];
|
|
10
|
+
/** The source classes the registry serves, once each, in file order. */
|
|
11
|
+
export declare function wrunPollLaneClasses(): string[];
|
|
12
|
+
/** The classes served on every chart, index-mode ones included (`global` lanes), once each, in
|
|
13
|
+
* file order. */
|
|
14
|
+
export declare function wrunPollLaneGlobalClasses(): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Spec hook: replace the registry with `lanes` (checked like discovered ones, minus the file
|
|
17
|
+
* name rule), or restore the discovered lanes with `null`. Every consumer reads the registry at
|
|
18
|
+
* call time, so a spec injects a lane, exercises the real run pass, row builder and tick, and
|
|
19
|
+
* restores in its teardown.
|
|
20
|
+
*/
|
|
21
|
+
export declare function __setWrunPollLanesForTest(lanes: readonly WrunPollLane[] | null): void;
|