@orangecharts/wrun-chart-host 0.4.0 → 0.6.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 +17 -5
- package/dist/constants/exchange-names.leaf.d.ts +8 -0
- package/dist/constants/exchange-names.leaf.js +101 -0
- package/dist/constants/feature-flags.constants.js +7 -2
- package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +15 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.js +40 -0
- package/dist/constants/opra-compliance.constants.d.ts +19 -0
- package/dist/constants/opra-compliance.constants.js +19 -0
- package/dist/constants/replay-ladder.leaf.d.ts +30 -0
- package/dist/constants/replay-ladder.leaf.js +99 -0
- package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +168 -0
- package/dist/constants/scriptEditor/cme-official-scripts.constants.js +398 -0
- package/dist/constants/scriptEditor/converted-script-id.leaf.d.ts +8 -0
- package/dist/constants/scriptEditor/converted-script-id.leaf.js +10 -0
- package/dist/constants/scriptEditor/execution.constants.d.ts +4 -0
- package/dist/constants/scriptEditor/execution.constants.js +14 -0
- package/dist/constants/wrun-prefix-safe.constants.d.ts +23 -0
- package/dist/constants/wrun-prefix-safe.constants.js +26 -0
- package/dist/host-env.d.ts +301 -22
- package/dist/host-env.js +15 -0
- package/dist/host-ports.types.d.ts +853 -29
- package/dist/index.d.ts +140 -2
- package/dist/index.js +140 -2
- package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +31 -0
- package/dist/instances/script-engine-worker-ohlcv-transfer.js +164 -0
- package/dist/interfaces/market-event.interface.d.ts +231 -0
- package/dist/interfaces/market-event.interface.js +15 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +70 -134
- package/dist/interfaces/opra-realtime.interface.js +34 -59
- package/dist/interfaces/replay.interface.d.ts +285 -0
- package/dist/interfaces/replay.interface.js +1 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +88 -13
- package/dist/interfaces/wrun-runtime.interface.js +17 -3
- package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +1 -0
- package/dist/kscript-data/controls/live-ohlcv-merge.util.js +93 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +5 -1
- package/dist/kscript-data/controls/live-trades-merge.util.js +2 -2
- package/dist/market-data/billing.interface.d.ts +219 -0
- package/dist/market-data/billing.interface.js +58 -0
- package/dist/market-data/venue-governed.util.d.ts +2 -0
- package/dist/market-data/venue-governed.util.js +10 -0
- package/dist/market-data/venue.d.ts +122 -0
- package/dist/market-data/venue.js +1 -0
- package/dist/market-data/venues/index.d.ts +97 -0
- package/dist/market-data/venues/index.js +33 -0
- package/dist/market-data/venues/opra.contract.copy.json +35 -0
- package/dist/market-data/venues/opra.d.ts +70 -0
- package/dist/market-data/venues/opra.js +74 -0
- package/dist/replay/replayIndicatorRows.d.ts +31 -0
- package/dist/replay/replayIndicatorRows.js +117 -0
- package/dist/replay/replayLadder.d.ts +85 -0
- package/dist/replay/replayLadder.js +388 -0
- package/dist/utility/auth/server-clock.util.d.ts +81 -0
- package/dist/utility/auth/server-clock.util.js +238 -0
- package/dist/utility/chart/builtin-identity.util.d.ts +18 -0
- package/dist/utility/chart/builtin-identity.util.js +51 -0
- package/dist/utility/chart/cache-alignment.util.d.ts +454 -0
- package/dist/utility/chart/cache-alignment.util.js +926 -0
- package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +15 -0
- package/dist/utility/chart/chart-data-fetch-generation.util.js +22 -0
- package/dist/utility/chart/chart-mount-epoch.util.d.ts +17 -0
- package/dist/utility/chart/chart-mount-epoch.util.js +61 -0
- package/dist/utility/chart/chart-time-domain.util.d.ts +12 -0
- package/dist/utility/chart/chart-time-domain.util.js +23 -0
- package/dist/utility/chart/color-customization.leaf.d.ts +10 -0
- package/dist/utility/chart/color-customization.leaf.js +16 -0
- package/dist/utility/chart/footprint-tick-grid.util.d.ts +106 -0
- package/dist/utility/chart/footprint-tick-grid.util.js +167 -0
- package/dist/utility/chart/gesture-timing.leaf.d.ts +29 -0
- package/dist/utility/chart/gesture-timing.leaf.js +29 -0
- package/dist/utility/chart/governed-contract-coin.util.d.ts +22 -0
- package/dist/utility/chart/governed-contract-coin.util.js +39 -0
- package/dist/utility/chart/host-bar-placement.util.d.ts +107 -0
- package/dist/utility/chart/host-bar-placement.util.js +447 -0
- package/dist/utility/chart/index-host-tier.util.d.ts +31 -0
- package/dist/utility/chart/index-host-tier.util.js +118 -0
- package/dist/utility/chart/index-mode-admission.util.d.ts +34 -0
- package/dist/utility/chart/index-mode-admission.util.js +67 -0
- package/dist/utility/chart/indicator-error-message.util.d.ts +35 -0
- package/dist/utility/chart/indicator-error-message.util.js +44 -0
- package/dist/utility/chart/kscript-apply-fingerprint.util.d.ts +65 -0
- package/dist/utility/chart/kscript-apply-fingerprint.util.js +357 -0
- package/dist/utility/chart/kscript-chart-flush.leaf.d.ts +22 -0
- package/dist/utility/chart/kscript-chart-flush.leaf.js +13 -0
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +6 -0
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +27 -0
- package/dist/utility/chart/kscript-integration-decision.leaf.d.ts +89 -0
- package/dist/utility/chart/kscript-integration-decision.leaf.js +80 -0
- package/dist/utility/chart/kscript-live-coalesce.util.d.ts +76 -0
- package/dist/utility/chart/kscript-live-coalesce.util.js +156 -0
- package/dist/utility/chart/kscript-live-rest-pace.util.d.ts +34 -0
- package/dist/utility/chart/kscript-live-rest-pace.util.js +134 -0
- package/dist/utility/chart/kscript-live-source-identity.util.d.ts +98 -0
- package/dist/utility/chart/kscript-live-source-identity.util.js +121 -0
- package/dist/utility/chart/kscript-mounted-plot-set.leaf.d.ts +48 -0
- package/dist/utility/chart/kscript-mounted-plot-set.leaf.js +145 -0
- package/dist/utility/chart/kscript-perf-tracker.util.d.ts +243 -0
- package/dist/utility/chart/kscript-perf-tracker.util.js +522 -0
- package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +43 -0
- package/dist/utility/chart/kscript-run-interval-projection.util.js +471 -0
- package/dist/utility/chart/kscript-run-result-equality.util.d.ts +38 -0
- package/dist/utility/chart/kscript-run-result-equality.util.js +89 -0
- package/dist/utility/chart/kscript-settings-revision.leaf.d.ts +2 -0
- package/dist/utility/chart/kscript-settings-revision.leaf.js +12 -0
- package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +63 -0
- package/dist/utility/chart/kscript-source-degrade.leaf.js +68 -0
- package/dist/utility/chart/kscript-source-retention.util.d.ts +134 -0
- package/dist/utility/chart/kscript-source-retention.util.js +218 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +57 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.js +61 -0
- package/dist/utility/chart/kscript-titancharts-preparation.util.d.ts +15 -0
- package/dist/utility/chart/kscript-titancharts-preparation.util.js +376 -0
- package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +9 -0
- package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +130 -0
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +217 -0
- package/dist/utility/chart/kscript-venue-policy.util.js +324 -0
- package/dist/utility/chart/live-cadence.util.d.ts +38 -0
- package/dist/utility/chart/live-cadence.util.js +37 -0
- package/dist/utility/chart/live-feed-series-match.leaf.d.ts +13 -0
- package/dist/utility/chart/live-feed-series-match.leaf.js +21 -0
- package/dist/utility/chart/local-engine-self-heal-backoff.util.d.ts +46 -0
- package/dist/utility/chart/local-engine-self-heal-backoff.util.js +46 -0
- package/dist/utility/chart/local-engine-uninit.leaf.d.ts +21 -0
- package/dist/utility/chart/local-engine-uninit.leaf.js +22 -0
- package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +62 -0
- package/dist/utility/chart/local-kscript-source-revalidation.util.js +123 -0
- package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +214 -0
- package/dist/utility/chart/local-kscript-warmup-depth.util.js +376 -0
- package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.d.ts +85 -0
- package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.js +197 -0
- package/dist/utility/chart/local-technical-script-range.leaf.d.ts +72 -0
- package/dist/utility/chart/local-technical-script-range.leaf.js +126 -0
- package/dist/utility/chart/mixed-mode.util.d.ts +167 -0
- package/dist/utility/chart/mixed-mode.util.js +139 -0
- package/dist/utility/chart/ohlcv-row-readiness.util.d.ts +36 -0
- package/dist/utility/chart/ohlcv-row-readiness.util.js +90 -0
- package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +19 -0
- package/dist/utility/chart/opra-user-scripts-gate.util.js +32 -0
- package/dist/utility/chart/overlay-execution-guard-key.leaf.d.ts +8 -0
- package/dist/utility/chart/overlay-execution-guard-key.leaf.js +10 -0
- package/dist/utility/chart/price-precision.util.d.ts +40 -0
- package/dist/utility/chart/price-precision.util.js +70 -0
- package/dist/utility/chart/profile-block-size.util.d.ts +64 -0
- package/dist/utility/chart/profile-block-size.util.js +141 -0
- package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.d.ts +11 -0
- package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.js +29 -0
- package/dist/utility/chart/protected-kscript-empty-output.util.d.ts +28 -0
- package/dist/utility/chart/protected-kscript-empty-output.util.js +84 -0
- package/dist/utility/chart/run-interval-unservable.leaf.d.ts +9 -0
- package/dist/utility/chart/run-interval-unservable.leaf.js +20 -0
- package/dist/utility/chart/run-interval-warmup.leaf.d.ts +19 -0
- package/dist/utility/chart/run-interval-warmup.leaf.js +35 -0
- package/dist/utility/chart/titan-constants.pin.d.ts +9 -5
- package/dist/utility/chart/titan-constants.pin.js +18 -5
- package/dist/utility/chart/warmup-backfill-retry.leaf.d.ts +9 -0
- package/dist/utility/chart/warmup-backfill-retry.leaf.js +9 -0
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +11 -2
- package/dist/utility/chart/wrun-bar-session-facts.util.js +10 -3
- package/dist/utility/chart/wrun-run-result.util.d.ts +5 -1
- package/dist/utility/chart/wrun-run-result.util.js +20 -14
- package/dist/utility/common/data-processing.util.d.ts +138 -0
- package/dist/utility/common/data-processing.util.js +346 -0
- package/dist/utility/common/visible-timeout.util.d.ts +13 -4
- package/dist/utility/common/visible-timeout.util.js +23 -8
- package/dist/utility/exchange-format.leaf.d.ts +1 -0
- package/dist/utility/exchange-format.leaf.js +47 -0
- package/dist/utility/market-events/earnings-scope.util.d.ts +60 -0
- package/dist/utility/market-events/earnings-scope.util.js +92 -0
- package/dist/utility/market-events/market-events.util.d.ts +147 -0
- package/dist/utility/market-events/market-events.util.js +392 -0
- package/dist/utility/market-events/zoned-clock.util.d.ts +1 -0
- package/dist/utility/market-events/zoned-clock.util.js +11 -0
- package/dist/utility/options/option-venue-disclosure.util.d.ts +43 -0
- package/dist/utility/options/option-venue-disclosure.util.js +56 -0
- package/dist/utility/scriptEditor/package-semver.util.d.ts +51 -0
- package/dist/utility/scriptEditor/package-semver.util.js +120 -0
- package/dist/utility/scriptEditor/temp-script-id.util.d.ts +18 -0
- package/dist/utility/scriptEditor/temp-script-id.util.js +25 -0
- package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.d.ts +20 -0
- package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.js +81 -0
- package/dist/utility/v2/governed-tier.leaf.d.ts +103 -0
- package/dist/utility/v2/governed-tier.leaf.js +113 -0
- package/dist/utility/watchlist/import/import-request.leaf.d.ts +10 -0
- package/dist/utility/watchlist/import/import-request.leaf.js +10 -0
- package/dist/utility/wrun/sources/lanes/series.js +2 -2
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +4 -4
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +5 -6
- package/dist/utility/wrun/wrun-alert-outputs.registry.d.ts +166 -0
- package/dist/utility/wrun/wrun-alert-outputs.registry.js +219 -0
- package/dist/utility/wrun/wrun-bar-count.util.d.ts +94 -0
- package/dist/utility/wrun/wrun-bar-count.util.js +274 -0
- package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +84 -0
- package/dist/utility/wrun/wrun-chart-context-names.util.js +186 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +253 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +731 -0
- package/dist/utility/wrun/wrun-cloud-opra-stamp.util.d.ts +28 -0
- package/dist/utility/wrun/wrun-cloud-opra-stamp.util.js +45 -0
- package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-coin-lane-live.util.js +47 -0
- package/dist/utility/wrun/wrun-deadline.util.js +2 -1
- package/dist/utility/wrun/wrun-debug-output.util.d.ts +39 -0
- package/dist/utility/wrun/wrun-debug-output.util.js +63 -0
- package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +113 -0
- package/dist/utility/wrun/wrun-declared-warmup.util.js +181 -0
- package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +43 -0
- package/dist/utility/wrun/wrun-draft-legend-note.util.js +158 -0
- package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +181 -0
- package/dist/utility/wrun/wrun-draft-overlay.util.js +357 -0
- package/dist/utility/wrun/wrun-draw-skipped.leaf.d.ts +16 -0
- package/dist/utility/wrun/wrun-draw-skipped.leaf.js +16 -0
- package/dist/utility/wrun/wrun-earnings-facts.util.d.ts +42 -0
- package/dist/utility/wrun/wrun-earnings-facts.util.js +131 -0
- package/dist/utility/wrun/wrun-first-run-depth.util.d.ts +32 -0
- package/dist/utility/wrun/wrun-first-run-depth.util.js +118 -0
- package/dist/utility/wrun/wrun-gate-plane-readers.util.d.ts +24 -0
- package/dist/utility/wrun/wrun-gate-plane-readers.util.js +31 -0
- package/dist/utility/wrun/wrun-held-lanes.util.d.ts +32 -0
- package/dist/utility/wrun/wrun-held-lanes.util.js +94 -0
- package/dist/utility/wrun/wrun-host-visible-clock.util.d.ts +2 -0
- package/dist/utility/wrun/wrun-host-visible-clock.util.js +17 -0
- package/dist/utility/wrun/wrun-host.service.d.ts +330 -0
- package/dist/utility/wrun/wrun-host.service.js +855 -0
- package/dist/utility/wrun/wrun-hover.util.d.ts +3 -0
- package/dist/utility/wrun/wrun-hover.util.js +25 -4
- package/dist/utility/wrun/wrun-inert-legend.util.d.ts +33 -0
- package/dist/utility/wrun/wrun-inert-legend.util.js +125 -0
- package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +155 -0
- package/dist/utility/wrun/wrun-input-requirements.leaf.js +450 -0
- package/dist/utility/wrun/wrun-integration-route.util.d.ts +51 -0
- package/dist/utility/wrun/wrun-integration-route.util.js +59 -0
- package/dist/utility/wrun/wrun-latest-history.leaf.d.ts +8 -0
- package/dist/utility/wrun/wrun-latest-history.leaf.js +8 -0
- package/dist/utility/wrun/wrun-legend-hover.lazy.d.ts +12 -0
- package/dist/utility/wrun/wrun-legend-hover.lazy.js +96 -0
- package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +21 -0
- package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +21 -0
- package/dist/utility/wrun/wrun-live-hidden-hold.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-live-hidden-hold.util.js +13 -0
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +374 -0
- package/dist/utility/wrun/wrun-live-intake.util.js +2027 -0
- package/dist/utility/wrun/wrun-live-patch.util.d.ts +116 -0
- package/dist/utility/wrun/wrun-live-patch.util.js +523 -0
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +619 -0
- package/dist/utility/wrun/wrun-live-tick.util.js +4974 -0
- package/dist/utility/wrun/wrun-loading-owner.util.d.ts +58 -0
- package/dist/utility/wrun/wrun-loading-owner.util.js +89 -0
- package/dist/utility/wrun/wrun-official-scope.leaf.d.ts +29 -0
- package/dist/utility/wrun/wrun-official-scope.leaf.js +36 -0
- package/dist/utility/wrun/wrun-oi-lane.util.d.ts +27 -0
- package/dist/utility/wrun/wrun-oi-lane.util.js +42 -0
- package/dist/utility/wrun/wrun-options-stop.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-options-stop.util.js +123 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +719 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +1180 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +50 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +131 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +118 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +466 -0
- package/dist/utility/wrun/wrun-overlay-metadata.util.d.ts +45 -0
- package/dist/utility/wrun/wrun-overlay-metadata.util.js +112 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +114 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +971 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +858 -0
- package/dist/utility/wrun/wrun-overlay-run.util.js +11013 -0
- package/dist/utility/wrun/wrun-pack.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +24 -9
- package/dist/utility/wrun/wrun-panel-mount.util.js +138 -43
- package/dist/utility/wrun/wrun-param-map.util.d.ts +19 -4
- package/dist/utility/wrun/wrun-param-map.util.js +40 -47
- package/dist/utility/wrun/wrun-param-values.util.d.ts +9 -3
- package/dist/utility/wrun/wrun-param-values.util.js +5 -5
- package/dist/utility/wrun/wrun-prefix-cohort.util.d.ts +93 -0
- package/dist/utility/wrun/wrun-prefix-cohort.util.js +484 -0
- package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +114 -0
- package/dist/utility/wrun/wrun-prefix-lanes.util.js +486 -0
- package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +317 -0
- package/dist/utility/wrun/wrun-prefix-proof.util.js +630 -0
- package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +73 -0
- package/dist/utility/wrun/wrun-refusal-surface.util.js +380 -0
- package/dist/utility/wrun/wrun-refusal-text.util.d.ts +15 -0
- package/dist/utility/wrun/wrun-refusal-text.util.js +40 -0
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
- package/dist/utility/wrun/wrun-replay-lane.util.d.ts +139 -0
- package/dist/utility/wrun/wrun-replay-lane.util.js +520 -0
- package/dist/utility/wrun/wrun-replay-rows.util.d.ts +21 -0
- package/dist/utility/wrun/wrun-replay-rows.util.js +172 -0
- package/dist/utility/wrun/wrun-row-source-factory.d.ts +53 -0
- package/dist/utility/wrun/wrun-row-source-factory.js +435 -0
- package/dist/utility/wrun/wrun-run-cells.util.d.ts +36 -0
- package/dist/utility/wrun/wrun-run-cells.util.js +46 -0
- package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +133 -0
- package/dist/utility/wrun/wrun-run-interval-session.util.js +121 -0
- package/dist/utility/wrun/wrun-run-interval.util.d.ts +98 -0
- package/dist/utility/wrun/wrun-run-interval.util.js +207 -0
- package/dist/utility/wrun/wrun-run-retained.util.d.ts +122 -0
- package/dist/utility/wrun/wrun-run-retained.util.js +255 -0
- package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +184 -0
- package/dist/utility/wrun/wrun-sandbox-row-source.js +444 -0
- package/dist/utility/wrun/wrun-script-inputs.util.js +4 -4
- package/dist/utility/wrun/wrun-series-stream.util.d.ts +86 -0
- package/dist/utility/wrun/wrun-series-stream.util.js +537 -0
- package/dist/utility/wrun/wrun-sha256.leaf.d.ts +13 -0
- package/dist/utility/wrun/wrun-sha256.leaf.js +84 -0
- package/dist/utility/wrun/wrun-sheet-remembered.util.d.ts +21 -0
- package/dist/utility/wrun/wrun-sheet-remembered.util.js +36 -0
- package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.d.ts +7 -0
- package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.js +12 -0
- package/dist/utility/wrun/wrun-socket-row-source.js +4 -2
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +175 -3
- package/dist/utility/wrun/wrun-source-rows.util.js +294 -8
- package/dist/utility/wrun/wrun-stats-strip.util.d.ts +46 -0
- package/dist/utility/wrun/wrun-stats-strip.util.js +87 -0
- package/dist/utility/wrun/wrun-table-chrome.util.d.ts +163 -0
- package/dist/utility/wrun/wrun-table-chrome.util.js +557 -0
- package/dist/utility/wrun/wrun-text-params.util.d.ts +11 -6
- package/dist/utility/wrun/wrun-text-params.util.js +19 -30
- package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +64 -0
- package/dist/utility/wrun/wrun-transient-rerun.util.js +317 -0
- package/dist/utility/wrun/wrun-twin-lookback.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-twin-lookback.util.js +43 -0
- package/dist/utility/wrun/wrun-warmup-head-store.util.d.ts +41 -0
- package/dist/utility/wrun/wrun-warmup-head-store.util.js +120 -0
- package/dist/utility/wrun-alert-params.leaf.d.ts +24 -0
- package/dist/utility/wrun-alert-params.leaf.js +24 -0
- package/dist/utils/replay/replay-buffer-math.d.ts +148 -0
- package/dist/utils/replay/replay-buffer-math.js +684 -0
- package/dist/workers/wrun/wrun-abi-host.d.ts +203 -0
- package/dist/workers/wrun/wrun-abi-host.js +1220 -0
- package/dist/workers/wrun/wrun-engine-handler.d.ts +20 -0
- package/dist/workers/wrun/wrun-engine-handler.js +380 -0
- package/package.json +3 -3
|
@@ -0,0 +1,731 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the chart fills for a wrun package's market facts (WRUN-GAPS-1005
|
|
3
|
+
* CONTRACT.md "What each host fills", the chart row): `market.kind()`,
|
|
4
|
+
* `market.point_value()`, `market.zone()`, `market.quote_is_usd()` and
|
|
5
|
+
* `market.session_open()` (WRUN-SESSION) of the chart's own market, as the
|
|
6
|
+
* codes of wrun-market-facts.util.
|
|
7
|
+
*
|
|
8
|
+
* One answer per market on every host. om fills the same five from its market
|
|
9
|
+
* directory row (the asset class and the quote) and its venue tables (om
|
|
10
|
+
* `packages/cli/src/runner/wrun/market-facts.ts`, `wrunMarketFactsOf`), so the
|
|
11
|
+
* chart reads the SAME directory row (the markets service: one bounded
|
|
12
|
+
* exact-match search per market, only for a package that declares a fact the
|
|
13
|
+
* row answers, `kind` or `quote_is_usd`, never on a venue whose listings om
|
|
14
|
+
* never reads) through the same rules, and adds only what om does not know:
|
|
15
|
+
*
|
|
16
|
+
* kind the row's asset class: a coin 1, a stock or an ETF 2 (a
|
|
17
|
+
* stock perpetual on a crypto venue included), forex 3, a
|
|
18
|
+
* commodity whose base is a metal 4 (another commodity 0), an
|
|
19
|
+
* index 5, an economic series 6, a prediction market 0. A
|
|
20
|
+
* market without a row takes its venue's kind (US listings 2,
|
|
21
|
+
* POLYGON_INDICES 5, forex 3 or 4 for a metal base, LBMA and
|
|
22
|
+
* LME 4), then the chart's own: a CME root by what it trades
|
|
23
|
+
* (CME_ROOT_SPECS), an economic venue 6. A crypto venue settles
|
|
24
|
+
* no kind on its own (it lists stock, ETF and metal perpetuals
|
|
25
|
+
* too), so a coin there reads 1 once the row answers, 0 before.
|
|
26
|
+
* point_value the CME contract's point value (CME_ROOT_SPECS, in the
|
|
27
|
+
* quote currency; 0 for a root off the table and for an
|
|
28
|
+
* option contract); 0 on ICE and
|
|
29
|
+
* PLATTS, whose multipliers the chart does not hold; 1 on every
|
|
30
|
+
* other market the chart serves, all priced per unit (spot,
|
|
31
|
+
* perpetuals, stocks, ETFs, forex, indices, metals, prediction
|
|
32
|
+
* markets, economic series).
|
|
33
|
+
* zone om's venue rule: US listings and POLYGON_INDICES New York,
|
|
34
|
+
* the CME family Chicago, LBMA and LME London, every other
|
|
35
|
+
* venue 0 (UTC, the clock every 24/7 market keeps).
|
|
36
|
+
* quote_is_usd the row's quote (`quoteAssetId`, else `quoteCoinName`): USD
|
|
37
|
+
* 1, anything else 2, a dollar stablecoin included; without
|
|
38
|
+
* one, US listings and POLYGON_INDICES 1, then the market's
|
|
39
|
+
* own quote as the chart spells it (a CME root's quotation
|
|
40
|
+
* currency, the pair's quote in `EUR/USD` or `C:EURUSD`, the
|
|
41
|
+
* tail of the directory's normalized symbol `BTC-USDT`), else 0.
|
|
42
|
+
* session_open om's venue rule: the minute on the venue's clock its trade day
|
|
43
|
+
* opens, 1020 (17:00 Chicago, WRUN_MARKET_SESSION_OPEN_CME) for
|
|
44
|
+
* the CME family, the zone's Chicago branch, else 0 (midnight).
|
|
45
|
+
*
|
|
46
|
+
* Beside the five the host fill carries `market.option_multiplier()` (kit 0.87.0,
|
|
47
|
+
* om WRUN_OPTION_FACT_FILLS, which only the chart's browser lane fills): the US
|
|
48
|
+
* dollars one price unit times one size unit of an option on the chart's options
|
|
49
|
+
* chain is worth, 100 on OPRA, the CME root's point value, 1 on a crypto chart,
|
|
50
|
+
* else 0 (wrunChartOptionMultiplier).
|
|
51
|
+
*
|
|
52
|
+
* The 0 rule: a fact the chart does not know is 0, never a guess. Main thread
|
|
53
|
+
* only (the directory read goes through the markets service); the hosted lanes
|
|
54
|
+
* carry the numbers to the worker inside `wrunHostFill`.
|
|
55
|
+
*/
|
|
56
|
+
import { AssetClass, Category, Exchange } from '@orangecharts/orange-v2-pb-common';
|
|
57
|
+
import { wrunChartHostEnv } from '../../host-env.js';
|
|
58
|
+
import { isCmeGoverned } from '../chart/cme-realtime.util.js';
|
|
59
|
+
import { governedContractCoin } from '../chart/governed-contract-coin.util.js';
|
|
60
|
+
import { checkIsEconomic, getMarketKind } from '../chart/marketKind.util.js';
|
|
61
|
+
import { optionVenueForExchange, optionVenueForUnderlyingExchange } from '../options/option-venue.util.js';
|
|
62
|
+
import { WRUN_LANE_CURRENCY_AUTO, WRUN_MARKET_FACT_FILLS, WRUN_MARKET_KINDS, WRUN_MARKET_QUOTE_IS_USD, WRUN_MARKET_SESSION_OPEN_CME, wrunLaneCurrency, wrunMarketSizeUnit, wrunMarketZoneCode, wrunCoinLegSource, wrunFollowsCoin, wrunRowVisibleHere, wrunVisibleByNeedsKind, } from './wrun-market-facts.util.js';
|
|
63
|
+
import { isWrunLegStreamClass } from './wrun-leg-stream-classes.js';
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// om's venue tables, mirrored (each names its om source): the chart must
|
|
66
|
+
// answer every market om knows the way om does.
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
/** om `packages/cli/src/shared/session-venues.ts` US_EQUITY_EXCHANGES: every
|
|
69
|
+
* US listing code (the chart's tradfi codes among them). */
|
|
70
|
+
const US_LISTING_EXCHANGES = new Set([
|
|
71
|
+
'POLYGON',
|
|
72
|
+
'CONSOLIDATED_TAPE_ASSOCIATION',
|
|
73
|
+
'UNLISTED_TRADING_PRIVILEGES',
|
|
74
|
+
'UNKNOWN_EXCHANGE',
|
|
75
|
+
'BLACKROCK',
|
|
76
|
+
'FIDELITY',
|
|
77
|
+
'BITWISE',
|
|
78
|
+
'ARK',
|
|
79
|
+
'INVESCO',
|
|
80
|
+
'FRANKLIN',
|
|
81
|
+
'VALKYRIE',
|
|
82
|
+
'WISDOMTREE',
|
|
83
|
+
'US_EQUITIES',
|
|
84
|
+
'ARCA',
|
|
85
|
+
'AMEX',
|
|
86
|
+
'NYSE',
|
|
87
|
+
'NYSE_AMERICAN',
|
|
88
|
+
'NYSE_NATIONAL',
|
|
89
|
+
'NYSE_ARCA',
|
|
90
|
+
'NYSE_CHICAGO',
|
|
91
|
+
'NASDAQ',
|
|
92
|
+
'NASDAQ_BX',
|
|
93
|
+
'NASDAQ_ISE',
|
|
94
|
+
'NASDAQ_PHILADELPHIA',
|
|
95
|
+
'NASDAQ_PSX',
|
|
96
|
+
'NASDAQ_INT',
|
|
97
|
+
'CBOE',
|
|
98
|
+
'CBOE_EDGA',
|
|
99
|
+
'CBOE_EDGX',
|
|
100
|
+
'CBOE_BYX',
|
|
101
|
+
'CBOE_BZX',
|
|
102
|
+
'IEX',
|
|
103
|
+
'LTSE',
|
|
104
|
+
'MIAX_PEARL',
|
|
105
|
+
'MEMBERS_EXCHANGE',
|
|
106
|
+
'OTC_EQUITY_SECURITY',
|
|
107
|
+
'FINRA',
|
|
108
|
+
'NYSE.F',
|
|
109
|
+
'NASDAQ.F',
|
|
110
|
+
'CBOE.F',
|
|
111
|
+
]);
|
|
112
|
+
/** om `packages/cli/src/shared/session-venues.ts` CME_FAMILY_EXCHANGES (the
|
|
113
|
+
* chart's governed codes, isCmeGoverned, are all in it). */
|
|
114
|
+
const CME_FAMILY_EXCHANGES = new Set([
|
|
115
|
+
'CME',
|
|
116
|
+
'CME_MINI',
|
|
117
|
+
'CBOT',
|
|
118
|
+
'CBOT_MINI',
|
|
119
|
+
'NYMEX',
|
|
120
|
+
'COMEX',
|
|
121
|
+
'CFE',
|
|
122
|
+
'GLOBEX',
|
|
123
|
+
]);
|
|
124
|
+
/** om `packages/cli/src/runner/data-transport.ts` TRADFI_EXCHANGES: venues
|
|
125
|
+
* whose listings om never reads its directory for. */
|
|
126
|
+
const TRADFI_EXCHANGES = new Set([
|
|
127
|
+
'POLYGON',
|
|
128
|
+
'POLYGON_FX',
|
|
129
|
+
'POLYGON_INDICES',
|
|
130
|
+
'FX_OTC',
|
|
131
|
+
'LBMA',
|
|
132
|
+
'LME',
|
|
133
|
+
'ICE',
|
|
134
|
+
'PLATTS',
|
|
135
|
+
]);
|
|
136
|
+
/** om `market-facts.ts`: the venues that settle a kind (and a quote) alone. */
|
|
137
|
+
const INDEX_EXCHANGES = new Set(['POLYGON_INDICES']);
|
|
138
|
+
const FOREX_EXCHANGES = new Set(['FX_OTC', 'POLYGON_FX']);
|
|
139
|
+
const METAL_EXCHANGES = new Set(['LBMA', 'LME']);
|
|
140
|
+
/** om `market-facts.ts` METAL_BASES: a commodity is a metal when its base is
|
|
141
|
+
* one of these (XAUUSDT on Binance, GOLD on HIP-3). */
|
|
142
|
+
const METAL_BASES = new Set([
|
|
143
|
+
'XAU',
|
|
144
|
+
'XAG',
|
|
145
|
+
'XPT',
|
|
146
|
+
'XPD',
|
|
147
|
+
'XCU',
|
|
148
|
+
'GOLD',
|
|
149
|
+
'SILVER',
|
|
150
|
+
'PLATINUM',
|
|
151
|
+
'PALLADIUM',
|
|
152
|
+
'COPPER',
|
|
153
|
+
]);
|
|
154
|
+
/** om `market-facts.ts` ASSET_CLASS_KINDS: the asset classes that settle a
|
|
155
|
+
* kind on their own (a commodity reads its base; any other class is 0). */
|
|
156
|
+
const ASSET_CLASS_KINDS = {
|
|
157
|
+
ASSET_CLASS_CRYPTO: 'crypto',
|
|
158
|
+
ASSET_CLASS_STOCK: 'stock',
|
|
159
|
+
ASSET_CLASS_ETF: 'stock',
|
|
160
|
+
ASSET_CLASS_FOREX: 'forex',
|
|
161
|
+
ASSET_CLASS_INDEX: 'index',
|
|
162
|
+
ASSET_CLASS_ECONOMIC: 'economic',
|
|
163
|
+
};
|
|
164
|
+
const COMMODITY_ASSET_CLASS = 'ASSET_CLASS_COMMODITY';
|
|
165
|
+
/** Venues that list contracts whose multipliers the chart does not hold. */
|
|
166
|
+
const UNKNOWN_MULTIPLIER_EXCHANGES = new Set(['ICE', 'PLATTS']);
|
|
167
|
+
/** Read-only outside this module: the paper venue reads each contract's point value from it. */
|
|
168
|
+
export const CME_ROOT_SPECS = {
|
|
169
|
+
// Equity index futures, quoted in index points: the dollar multiplier.
|
|
170
|
+
ES: { kind: 'index', pointValue: 50, quote: 'usd' }, // $50 x S&P 500: equities/sp/e-mini-sandp500
|
|
171
|
+
MES: { kind: 'index', pointValue: 5, quote: 'usd' }, // $5 x S&P 500: equities/sp/micro-e-mini-sandp-500
|
|
172
|
+
NQ: { kind: 'index', pointValue: 20, quote: 'usd' }, // $20 x Nasdaq-100: equities/nasdaq/e-mini-nasdaq-100
|
|
173
|
+
MNQ: { kind: 'index', pointValue: 2, quote: 'usd' }, // $2 x Nasdaq-100: equities/nasdaq/micro-e-mini-nasdaq-100
|
|
174
|
+
RTY: { kind: 'index', pointValue: 50, quote: 'usd' }, // $50 x Russell 2000: equities/russell/e-mini-russell-2000
|
|
175
|
+
M2K: { kind: 'index', pointValue: 5, quote: 'usd' }, // $5 x Russell 2000: equities/russell/micro-e-mini-russell-2000
|
|
176
|
+
YM: { kind: 'index', pointValue: 5, quote: 'usd' }, // $5 x DJIA: equities/dow-jones/e-mini-dow
|
|
177
|
+
MYM: { kind: 'index', pointValue: 0.5, quote: 'usd' }, // $0.50 x DJIA: equities/dow-jones/micro-e-mini-dow
|
|
178
|
+
// FX futures, quoted in US dollars per unit of the foreign currency (6J per yen, 0.00xxxx).
|
|
179
|
+
'6E': { kind: 'forex', pointValue: 125_000, quote: 'usd' }, // 125,000 euro: fx/g10/euro-fx
|
|
180
|
+
'6B': { kind: 'forex', pointValue: 62_500, quote: 'usd' }, // 62,500 pounds: fx/g10/british-pound
|
|
181
|
+
'6J': { kind: 'forex', pointValue: 12_500_000, quote: 'usd' }, // 12,500,000 yen: fx/g10/japanese-yen
|
|
182
|
+
'6C': { kind: 'forex', pointValue: 100_000, quote: 'usd' }, // 100,000 CAD: fx/g10/canadian-dollar
|
|
183
|
+
// US Treasury futures, quoted in points of par (100): the face value / 100 per point.
|
|
184
|
+
ZT: { kind: 'unknown', pointValue: 2_000, quote: 'usd' }, // $200,000 face: interest-rates/us-treasury/2-year-us-treasury-note
|
|
185
|
+
ZF: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/5-year-us-treasury-note
|
|
186
|
+
ZN: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/10-year-us-treasury-note
|
|
187
|
+
TN: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/ultra-10-year-us-treasury-note
|
|
188
|
+
ZB: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/30-year-us-treasury-bond
|
|
189
|
+
UB: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/ultra-t-bond
|
|
190
|
+
// Energy (NYMEX), quoted in US dollars per unit of the commodity.
|
|
191
|
+
CL: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // 1,000 barrels: energy/crude-oil/light-sweet-crude
|
|
192
|
+
MCL: { kind: 'unknown', pointValue: 100, quote: 'usd' }, // 100 barrels: energy/crude-oil/micro-wti-crude-oil
|
|
193
|
+
NG: { kind: 'unknown', pointValue: 10_000, quote: 'usd' }, // 10,000 MMBtu: energy/natural-gas/natural-gas
|
|
194
|
+
RB: { kind: 'unknown', pointValue: 42_000, quote: 'usd' }, // 42,000 gallons: energy/refined-products/rbob-gasoline
|
|
195
|
+
HO: { kind: 'unknown', pointValue: 42_000, quote: 'usd' }, // 42,000 gallons: energy/refined-products/heating-oil
|
|
196
|
+
BZ: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // 1,000 barrels: energy/crude-oil/brent-crude-oil-last-day
|
|
197
|
+
// Metals (COMEX), quoted in US dollars per troy ounce (copper per pound).
|
|
198
|
+
GC: { kind: 'metal', pointValue: 100, quote: 'usd' }, // 100 troy ounces: metals/precious/gold
|
|
199
|
+
MGC: { kind: 'metal', pointValue: 10, quote: 'usd' }, // 10 troy ounces: metals/precious/e-micro-gold
|
|
200
|
+
SI: { kind: 'metal', pointValue: 5_000, quote: 'usd' }, // 5,000 troy ounces: metals/precious/silver
|
|
201
|
+
SIL: { kind: 'metal', pointValue: 1_000, quote: 'usd' }, // 1,000 troy ounces: metals/precious/1000-oz-silver
|
|
202
|
+
HG: { kind: 'metal', pointValue: 25_000, quote: 'usd' }, // 25,000 pounds: metals/base/copper
|
|
203
|
+
MHG: { kind: 'metal', pointValue: 2_500, quote: 'usd' }, // 2,500 pounds: metals/base/micro-copper
|
|
204
|
+
// Grains (CBOT), quoted in US cents per bushel (soybean oil per pound), the unit the chart
|
|
205
|
+
// draws (corn near 460): a whole point is one cent, worth the contract size in cents, and
|
|
206
|
+
// the quote is US cents, not dollars (Pine reads `syminfo.currency` "USX" there).
|
|
207
|
+
ZC: { kind: 'unknown', pointValue: 5_000, quote: 'other' }, // 5,000 bushels: agriculture/grains/corn
|
|
208
|
+
ZW: { kind: 'unknown', pointValue: 5_000, quote: 'other' }, // 5,000 bushels: agriculture/grains/wheat
|
|
209
|
+
KE: { kind: 'unknown', pointValue: 5_000, quote: 'other' }, // 5,000 bushels: agriculture/grains/kc-wheat
|
|
210
|
+
ZS: { kind: 'unknown', pointValue: 5_000, quote: 'other' }, // 5,000 bushels: agriculture/oilseeds/soybean
|
|
211
|
+
ZL: { kind: 'unknown', pointValue: 60_000, quote: 'other' }, // 60,000 pounds: agriculture/oilseeds/soybean-oil
|
|
212
|
+
// Cryptocurrency futures (CME), quoted in US dollars per coin.
|
|
213
|
+
BTC: { kind: 'crypto', pointValue: 5, quote: 'usd' }, // 5 bitcoin: cryptocurrencies/bitcoin/bitcoin
|
|
214
|
+
MBT: { kind: 'crypto', pointValue: 0.1, quote: 'usd' }, // 0.1 bitcoin: cryptocurrencies/bitcoin/micro-bitcoin
|
|
215
|
+
ETH: { kind: 'crypto', pointValue: 50, quote: 'usd' }, // 50 ether: cryptocurrencies/ether/ether
|
|
216
|
+
MET: { kind: 'crypto', pointValue: 0.1, quote: 'usd' }, // 0.1 ether: cryptocurrencies/ether/micro-ether
|
|
217
|
+
};
|
|
218
|
+
// ---------------------------------------------------------------------------
|
|
219
|
+
// The facts of one market
|
|
220
|
+
// ---------------------------------------------------------------------------
|
|
221
|
+
const kindCode = (kind) => WRUN_MARKET_KINDS.indexOf(kind);
|
|
222
|
+
const quoteCode = (quote) => WRUN_MARKET_QUOTE_IS_USD.indexOf(quote);
|
|
223
|
+
const NEW_YORK = wrunMarketZoneCode('America/New_York');
|
|
224
|
+
const CHICAGO = wrunMarketZoneCode('America/Chicago');
|
|
225
|
+
const LONDON = wrunMarketZoneCode('Europe/London');
|
|
226
|
+
function upperText(value) {
|
|
227
|
+
if (typeof value !== 'string')
|
|
228
|
+
return undefined;
|
|
229
|
+
const text = value.trim().toUpperCase();
|
|
230
|
+
return text.length > 0 ? text : undefined;
|
|
231
|
+
}
|
|
232
|
+
function isCmeFamily(venue) {
|
|
233
|
+
return CME_FAMILY_EXCHANGES.has(venue) || isCmeGoverned(venue);
|
|
234
|
+
}
|
|
235
|
+
function isOptionContract(category) {
|
|
236
|
+
return category === Category.OPTION || category === 'OPTION';
|
|
237
|
+
}
|
|
238
|
+
/** A directory row's asset class as its enum name (the raw page keeps the
|
|
239
|
+
* number, a JSON frame the name), undefined when it states none. */
|
|
240
|
+
function assetClassName(value) {
|
|
241
|
+
if (typeof value === 'string')
|
|
242
|
+
return value !== '' && value !== 'UNKNOWN_ASSET_CLASS' ? value : undefined;
|
|
243
|
+
if (typeof value === 'number' && value > 0) {
|
|
244
|
+
const name = AssetClass[value];
|
|
245
|
+
return name !== undefined && name !== 'UNKNOWN_ASSET_CLASS' ? name : undefined;
|
|
246
|
+
}
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
/** om `forexBase`: a forex symbol's base currency (`EUR/USD`, `XAU-USD`, `C:XAUUSD`). */
|
|
250
|
+
function forexBase(symbol) {
|
|
251
|
+
return /^(?:C:)?([A-Z]{3})[/-]?[A-Z]{3}$/.exec(symbol.trim().toUpperCase())?.[1];
|
|
252
|
+
}
|
|
253
|
+
/** om `venueKind`: the kind the venue alone settles, or undefined where a
|
|
254
|
+
* venue lists several kinds (every crypto venue). */
|
|
255
|
+
function venueKind(venue, symbol) {
|
|
256
|
+
if (US_LISTING_EXCHANGES.has(venue))
|
|
257
|
+
return 'stock';
|
|
258
|
+
if (INDEX_EXCHANGES.has(venue))
|
|
259
|
+
return 'index';
|
|
260
|
+
if (METAL_EXCHANGES.has(venue))
|
|
261
|
+
return 'metal';
|
|
262
|
+
if (FOREX_EXCHANGES.has(venue)) {
|
|
263
|
+
const base = forexBase(symbol);
|
|
264
|
+
return base !== undefined && METAL_BASES.has(base) ? 'metal' : 'forex';
|
|
265
|
+
}
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
|
268
|
+
/** om `rowKind`: the row's asset class as a kind, undefined when it states none. */
|
|
269
|
+
function rowKind(row) {
|
|
270
|
+
const assetClass = assetClassName(row.assetClass);
|
|
271
|
+
if (assetClass === undefined)
|
|
272
|
+
return undefined;
|
|
273
|
+
if (assetClass === COMMODITY_ASSET_CLASS) {
|
|
274
|
+
const base = upperText(row.coin) ?? upperText(row.underlyingSymbol);
|
|
275
|
+
return base !== undefined && METAL_BASES.has(base) ? 'metal' : 'unknown';
|
|
276
|
+
}
|
|
277
|
+
return ASSET_CLASS_KINDS[assetClass] ?? 'unknown';
|
|
278
|
+
}
|
|
279
|
+
/** om `rowQuote`: the row's quote, undefined when it states none. */
|
|
280
|
+
function rowQuote(row) {
|
|
281
|
+
const quote = upperText(row.quoteAssetId) ?? upperText(row.quoteCoinName);
|
|
282
|
+
if (quote === undefined)
|
|
283
|
+
return undefined;
|
|
284
|
+
return quote === 'USD' ? 'usd' : 'other';
|
|
285
|
+
}
|
|
286
|
+
/** The quote currency the chart's own spelling of the market names: the
|
|
287
|
+
* pair's quote (`EUR/USD`, `AAPL/USD`, `C:EURUSD` on a forex venue), else
|
|
288
|
+
* the tail of the directory's normalized symbol (`BTC-USDT`). */
|
|
289
|
+
function spelledQuote(venue, market) {
|
|
290
|
+
const symbol = upperText(market.symbol);
|
|
291
|
+
if (symbol !== undefined) {
|
|
292
|
+
const pair = /^(?:C:)?[A-Z0-9.]+\/([A-Z0-9]+)$/.exec(symbol);
|
|
293
|
+
if (pair)
|
|
294
|
+
return pair[1];
|
|
295
|
+
if (FOREX_EXCHANGES.has(venue)) {
|
|
296
|
+
const joined = /^(?:C:)?[A-Z]{3}([A-Z]{3})$/.exec(symbol);
|
|
297
|
+
if (joined)
|
|
298
|
+
return joined[1];
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const normalized = upperText(market.normalizedSymbol);
|
|
302
|
+
const tail = normalized === undefined ? undefined : /^[A-Z0-9.]+-([A-Z0-9]+)$/.exec(normalized)?.[1];
|
|
303
|
+
return tail;
|
|
304
|
+
}
|
|
305
|
+
/** The CME root's spec, undefined off the table (and for an option contract). */
|
|
306
|
+
function cmeRootSpec(market) {
|
|
307
|
+
if (isOptionContract(market.category))
|
|
308
|
+
return undefined;
|
|
309
|
+
const root = governedContractCoin(typeof market.symbol === 'string' ? market.symbol : undefined);
|
|
310
|
+
return root === null ? undefined : CME_ROOT_SPECS[root.toUpperCase()];
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The five facts the chart fills for `market` (the module doc): om's rules
|
|
314
|
+
* over the directory `row` (undefined when the chart has none: not read, not
|
|
315
|
+
* listed, or not answered yet) and the venue tables, then the chart's own
|
|
316
|
+
* knowledge where om's answer is unknown. Pure.
|
|
317
|
+
*/
|
|
318
|
+
export function wrunChartMarketFacts(market, row) {
|
|
319
|
+
const venue = upperText(market?.exchange) ?? '';
|
|
320
|
+
const symbol = typeof market?.symbol === 'string' ? market.symbol : '';
|
|
321
|
+
if (market === undefined || venue === '')
|
|
322
|
+
return { kind: 0, pointValue: 0, zone: 0, quoteIsUsd: 0, sessionOpen: 0 };
|
|
323
|
+
const cme = isCmeFamily(venue);
|
|
324
|
+
const spec = cme ? cmeRootSpec(market) : undefined;
|
|
325
|
+
const ownKind = spec?.kind ?? (checkIsEconomic(venue) ? 'economic' : undefined);
|
|
326
|
+
const kind = (row !== undefined ? rowKind(row) : undefined) ?? venueKind(venue, symbol) ?? ownKind ?? 'unknown';
|
|
327
|
+
const pointValue = cme ? (spec?.pointValue ?? 0) : UNKNOWN_MULTIPLIER_EXCHANGES.has(venue) ? 0 : 1;
|
|
328
|
+
const zone = US_LISTING_EXCHANGES.has(venue) || INDEX_EXCHANGES.has(venue)
|
|
329
|
+
? NEW_YORK
|
|
330
|
+
: cme
|
|
331
|
+
? CHICAGO
|
|
332
|
+
: METAL_EXCHANGES.has(venue)
|
|
333
|
+
? LONDON
|
|
334
|
+
: 0;
|
|
335
|
+
const venueQuote = US_LISTING_EXCHANGES.has(venue) || INDEX_EXCHANGES.has(venue) ? 'usd' : undefined;
|
|
336
|
+
const spelled = cme ? undefined : spelledQuote(venue, market);
|
|
337
|
+
const ownQuote = cme
|
|
338
|
+
? spec?.quote
|
|
339
|
+
: spelled === undefined
|
|
340
|
+
? undefined
|
|
341
|
+
: spelled === 'USD'
|
|
342
|
+
? 'usd'
|
|
343
|
+
: 'other';
|
|
344
|
+
const quote = (row !== undefined ? rowQuote(row) : undefined) ?? venueQuote ?? ownQuote ?? 'unknown';
|
|
345
|
+
const sessionOpen = cme ? WRUN_MARKET_SESSION_OPEN_CME : 0;
|
|
346
|
+
return { kind: kindCode(kind), pointValue, zone, quoteIsUsd: quoteCode(quote), sessionOpen };
|
|
347
|
+
}
|
|
348
|
+
/** An OPRA chain's multiplier: US listed options are priced per share and sized in contracts of 100 shares. */
|
|
349
|
+
const OPRA_OPTION_MULTIPLIER = 100;
|
|
350
|
+
/** A crypto chain's multiplier, on every venue: prices in US dollars per coin, sizes in coin. */
|
|
351
|
+
const CRYPTO_OPTION_MULTIPLIER = 1;
|
|
352
|
+
/** The market kinds of a crypto chart (getMarketKind): a crypto exchange of any category (spot, perpetual, dated
|
|
353
|
+
* future, option contract), a DEX pool, a Hyperliquid HIP-3 market. */
|
|
354
|
+
const CRYPTO_CHART_KINDS = new Set(['crypto', 'dex', 'hip3']);
|
|
355
|
+
/** Whether the chart is on a crypto exchange (CRYPTO_CHART_KINDS). getMarketKind files every code it does not map as
|
|
356
|
+
* crypto (its back-compat default), so a code pb-common does not name, and om's TradFi family (the index venue among
|
|
357
|
+
* them), are no crypto chart. */
|
|
358
|
+
function isCryptoChartVenue(venue) {
|
|
359
|
+
if (typeof Exchange[venue] !== 'number')
|
|
360
|
+
return false;
|
|
361
|
+
return !TRADFI_EXCHANGES.has(venue) && CRYPTO_CHART_KINDS.has(getMarketKind(venue));
|
|
362
|
+
}
|
|
363
|
+
/** The CME root spec of the chart's options chain: the chart's own contract's root (`ES1!`, `ESZ6`), or an option
|
|
364
|
+
* contract's underlying future's (`ESZ6 C6000`: the chain lists under its future); undefined off the table. */
|
|
365
|
+
function cmeChainRootSpec(market) {
|
|
366
|
+
const [contract] = typeof market.symbol === 'string' ? market.symbol.trim().split(/\s+/) : [];
|
|
367
|
+
const root = governedContractCoin(contract);
|
|
368
|
+
return root === null ? undefined : CME_ROOT_SPECS[root.toUpperCase()];
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* `market.option_multiplier()` of the chart market `market` (kit 0.87.0): the US dollars one price unit times one
|
|
372
|
+
* size unit of an option on the chart's options chain is worth, so a package's premium is size x price x the fact.
|
|
373
|
+
* The chain is the one the options chain decision's `auto` reads for the chart (optionsChartSource
|
|
374
|
+
* `resolveOptionsChartSource`, then opra-option-lanes.util `decideWrunLaneChainIdentity`), and its family follows the
|
|
375
|
+
* chart's own exchange and the venue table:
|
|
376
|
+
*
|
|
377
|
+
* CME a CME-governed chart reads the chain of its own root: the root's point value (CME_ROOT_SPECS, ES 50,
|
|
378
|
+
* NQ 20) when the root is quoted in US dollars; a root off the table, or quoted in another unit (a CBOT
|
|
379
|
+
* grain quotes US cents), is 0.
|
|
380
|
+
* OPRA a chart whose options list on OPRA (the venue table: an OPRA contract chart, a US stock or ETF chart):
|
|
381
|
+
* 100.
|
|
382
|
+
* crypto a chart on a crypto exchange, whichever venue and category (isCryptoChartVenue): its chain, when it has
|
|
383
|
+
* one, is a crypto chain (its own option venue's, the coin's Deribit chain, or another crypto venue's that
|
|
384
|
+
* lists the coin), priced in dollars per coin on every venue: 1. A crypto chart with no chain serves no
|
|
385
|
+
* option rows, so the 1 multiplies nothing.
|
|
386
|
+
* else 0: the chart has no options family (a forex pair, a metal, an index chart, an equity OPRA lists no chain
|
|
387
|
+
* for on its venue, an economic series, a prediction market, an unknown venue, no market).
|
|
388
|
+
*
|
|
389
|
+
* Synchronous, like every fact the host fill reads, where the run's chain decision is asynchronous and per input (it
|
|
390
|
+
* reads the chain directory, the crypto venues' listing and the flags): the family alone decides, so a chain that a
|
|
391
|
+
* flag, the plane router or an empty directory stops still reads its family's multiplier (its lane serves no rows to
|
|
392
|
+
* multiply). Pure.
|
|
393
|
+
*/
|
|
394
|
+
export function wrunChartOptionMultiplier(market) {
|
|
395
|
+
const venue = upperText(market?.exchange);
|
|
396
|
+
if (market === undefined || venue === undefined)
|
|
397
|
+
return 0;
|
|
398
|
+
if (isCmeGoverned(venue)) {
|
|
399
|
+
const spec = cmeChainRootSpec(market);
|
|
400
|
+
return spec?.quote === 'usd' ? spec.pointValue : 0;
|
|
401
|
+
}
|
|
402
|
+
const options = optionVenueForExchange(venue) ?? optionVenueForUnderlyingExchange(venue);
|
|
403
|
+
if (options?.plane === 'opra')
|
|
404
|
+
return OPRA_OPTION_MULTIPLIER;
|
|
405
|
+
return isCryptoChartVenue(venue) ? CRYPTO_OPTION_MULTIPLIER : 0;
|
|
406
|
+
}
|
|
407
|
+
/** The host_fill words whose values the host fill carries off the chart's market (wrunMarketFactsFor): the five
|
|
408
|
+
* market facts and the option multiplier (om WRUN_OPTION_FACT_FILLS, a word of the kit's WrunParamHostFill since
|
|
409
|
+
* 0.87.0, which the kit exports no runtime list for). */
|
|
410
|
+
const WRUN_CHART_MARKET_FILLS = new Set([
|
|
411
|
+
...WRUN_MARKET_FACT_FILLS,
|
|
412
|
+
'option_multiplier',
|
|
413
|
+
]);
|
|
414
|
+
/** True when the sheet declares one of the market's facts (a host-filled
|
|
415
|
+
* param on `kind`, `point_value`, `zone`, `quote_is_usd`, `session_open` or
|
|
416
|
+
* `option_multiplier`): the runs whose host fill carries the market's facts.
|
|
417
|
+
* Only a sheet that declares a directory fact waits for the read
|
|
418
|
+
* (wrunMarketFactsNeedDirectory). */
|
|
419
|
+
export function wrunReadsMarketFacts(metadata) {
|
|
420
|
+
return (metadata?.params ?? []).some((param) => param.host_fill !== undefined && WRUN_CHART_MARKET_FILLS.has(param.host_fill));
|
|
421
|
+
}
|
|
422
|
+
/** The facts the directory row answers: wrunChartMarketFacts reads the row for
|
|
423
|
+
* `kind` (its asset class) and `quote_is_usd` (its quote) alone. The other
|
|
424
|
+
* three are the venue tables' (`point_value` the CME root's or the venue's
|
|
425
|
+
* unit rule, `zone` the venue's clock, `session_open` the CME family's open):
|
|
426
|
+
* no row moves them. */
|
|
427
|
+
const WRUN_DIRECTORY_MARKET_FACTS = new Set(['kind', 'quote_is_usd']);
|
|
428
|
+
/** True when the sheet declares a fact the directory row answers (`kind`,
|
|
429
|
+
* `quote_is_usd`), or a `visible_by` list on a setting or an output, or a
|
|
430
|
+
* `needed_by` list on an input source (wrunLaneDemandNeedsDirectory), that
|
|
431
|
+
* only the kind decides (wrunVisibleByNeedsKind): the only runs that ask the
|
|
432
|
+
* directory and wait for its answer before the host fill and the mount. A
|
|
433
|
+
* sheet whose facts are all the venue tables' (`point_value`, `zone`,
|
|
434
|
+
* `session_open`) fills them at once and asks nothing, so its first paint
|
|
435
|
+
* never waits on a read it does not need. */
|
|
436
|
+
export function wrunMarketFactsNeedDirectory(metadata) {
|
|
437
|
+
return ((metadata?.params ?? []).some((param) => (param.host_fill !== undefined && WRUN_DIRECTORY_MARKET_FACTS.has(param.host_fill)) ||
|
|
438
|
+
wrunVisibleByNeedsKind(param.visible_by)) ||
|
|
439
|
+
(metadata?.outputs ?? []).some((output) => wrunVisibleByNeedsKind(output.visible_by)) ||
|
|
440
|
+
wrunLaneDemandNeedsDirectory(metadata));
|
|
441
|
+
}
|
|
442
|
+
/** True when an input source's `needed_by` list (kit 0.72.0) needs the market's kind to decide
|
|
443
|
+
* (wrunVisibleByNeedsKind: it names some but not all of 0, 1 and 2): the sheet's lane demand on a
|
|
444
|
+
* market (wrunSheetWithLaneDemand) then waits on the directory row, so a crypto venue's coin is
|
|
445
|
+
* never read as unit 0 before the row answers. A list deciding on contracts alone (`[0, 1, 2]`,
|
|
446
|
+
* `[3]`) needs only the point value and the zone and waits on nothing. */
|
|
447
|
+
export function wrunLaneDemandNeedsDirectory(sheet) {
|
|
448
|
+
return Object.values(sheet?.inputSources ?? {}).some((source) => wrunVisibleByNeedsKind(source?.needed_by));
|
|
449
|
+
}
|
|
450
|
+
/** The hidden params the kit generates for the directory facts (`market_<word>`). */
|
|
451
|
+
const WRUN_DIRECTORY_MARKET_FACT_PARAM_NAMES = new Set([...WRUN_DIRECTORY_MARKET_FACTS].map((fill) => `market_${fill}`));
|
|
452
|
+
/** wrunMarketFactsNeedDirectory over an overlay's declared inputs
|
|
453
|
+
* (`settings.scriptInputs`), for a lane that holds no sheet (the cloud
|
|
454
|
+
* payload): a row under a directory fact's generated name. */
|
|
455
|
+
export function wrunDeclaredMarketFactsNeedDirectory(declarations) {
|
|
456
|
+
return (Array.isArray(declarations) &&
|
|
457
|
+
declarations.some((row) => row !== null &&
|
|
458
|
+
typeof row === 'object' &&
|
|
459
|
+
(WRUN_DIRECTORY_MARKET_FACT_PARAM_NAMES.has(String(row.name)) ||
|
|
460
|
+
wrunVisibleByNeedsKind(row.visibleBy))));
|
|
461
|
+
}
|
|
462
|
+
// ---------------------------------------------------------------------------
|
|
463
|
+
// The size unit on the chart's market (kit 0.69.0: `currency: "Auto"`, `visible_by`)
|
|
464
|
+
// ---------------------------------------------------------------------------
|
|
465
|
+
/** The size unit (`market.size_unit()`, wrunMarketSizeUnit) of the chart market `market`, over the
|
|
466
|
+
* facts the chart fills for it now (wrunMarketFactsFor: the directory row once it answered, the 0
|
|
467
|
+
* rule before). The point value and the zone decide contracts, so the unit a lane's "Auto"
|
|
468
|
+
* resolves on never waits on a read. */
|
|
469
|
+
export function wrunChartSizeUnit(market) {
|
|
470
|
+
const facts = wrunMarketFactsFor(market);
|
|
471
|
+
return wrunMarketSizeUnit(facts.kind, facts.pointValue, facts.zone);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* The sheet a run plans its lanes from on a market of size unit `sizeUnit`: every input source whose
|
|
475
|
+
* `currency` is "Auto" (a `trades` or `volume_profile` lane; the sheet refuses it beside a pin, so it
|
|
476
|
+
* always follows the chart's own market) reads the unit wrunLaneCurrency resolves it to there,
|
|
477
|
+
* "Coin" on contracts and "USD" elsewhere. Every reader past this seam (the profile lane's extras,
|
|
478
|
+
* the trades lane of each quote, the shared host's plan, the live intake and the reconcile) reads
|
|
479
|
+
* the word as written and never sees "Auto". The sheet itself when no source says "Auto"; else a
|
|
480
|
+
* copy with its own `inputSources`, every other key shared.
|
|
481
|
+
*/
|
|
482
|
+
export function wrunSheetWithLaneCurrencies(sheet, sizeUnit) {
|
|
483
|
+
let resolved;
|
|
484
|
+
for (const [name, source] of Object.entries(sheet.inputSources ?? {})) {
|
|
485
|
+
if (source?.currency !== WRUN_LANE_CURRENCY_AUTO)
|
|
486
|
+
continue;
|
|
487
|
+
resolved ??= { ...sheet.inputSources };
|
|
488
|
+
resolved[name] = { ...source, currency: wrunLaneCurrency(source.currency, sizeUnit) };
|
|
489
|
+
}
|
|
490
|
+
return resolved === undefined ? sheet : { ...sheet, inputSources: resolved };
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* The sheet a run plans its lanes from on a market of size unit `sizeUnit`: every input source whose
|
|
494
|
+
* `needed_by` (kit 0.72.0) leaves that size unit out, read by the predicate a row's `visible_by` is
|
|
495
|
+
* (wrunRowVisibleHere), is marked `undemanded`, so no reader past this seam asks, subscribes, folds
|
|
496
|
+
* or re-asks its lane (wrunSourceLane answers none for it), and the row builder reads the input's
|
|
497
|
+
* fill on every bar (NaN, 0 under `missing: "zero"`) without ever holding the run. An input without
|
|
498
|
+
* the word is needed on every market. The sheet itself when every input is needed here; else a copy
|
|
499
|
+
* with its own `inputSources`.
|
|
500
|
+
*/
|
|
501
|
+
export function wrunSheetWithLaneDemand(sheet, sizeUnit) {
|
|
502
|
+
let marked;
|
|
503
|
+
for (const [name, source] of Object.entries(sheet.inputSources ?? {})) {
|
|
504
|
+
if (source === undefined || wrunRowVisibleHere(source.needed_by, sizeUnit))
|
|
505
|
+
continue;
|
|
506
|
+
marked ??= { ...sheet.inputSources };
|
|
507
|
+
marked[name] = { ...source, undemanded: true };
|
|
508
|
+
}
|
|
509
|
+
return marked === undefined ? sheet : { ...sheet, inputSources: marked };
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* The sheet a run plans its lanes from on a chart of span `chartIntervalMs`, with every leg stream lane (`candles`,
|
|
513
|
+
* `oi_candles`, `volume_profile_candles`: wrun-leg-stream-classes) its `chart_interval_below` gates off there (the kit's own `wrunLaneGatedOff`, read off the shared
|
|
514
|
+
* host: the chart's span known and not finer than the word's) left undemanded: such an input is marked
|
|
515
|
+
* `undemanded`, so no reader past this seam plans, fetches, subscribes, wall-checks or diagnoses its
|
|
516
|
+
* leg (no warning row, no refusal), and the row builder hands it a present EMPTY block on every row,
|
|
517
|
+
* the `missing: "empty"` picture. An unknown chart interval gates nothing. Evaluated before any
|
|
518
|
+
* celled-leg check, so a lane gated off on a coarse chart is never refused for its cells there. The
|
|
519
|
+
* sheet itself when no lane is gated off; else a copy with its own `inputSources`. A `candles` input
|
|
520
|
+
* reads the rule off the loaded host, so the run loads it first (the env's loadSharedHost). A hosted run's
|
|
521
|
+
* cloud plans its lanes from its own copy of the sheet.
|
|
522
|
+
*/
|
|
523
|
+
export function wrunSheetWithLaneGate(sheet, chartIntervalMs) {
|
|
524
|
+
let marked;
|
|
525
|
+
for (const [name, source] of Object.entries(sheet.inputSources ?? {})) {
|
|
526
|
+
if (!isWrunLegStreamClass(source?.source) || source?.undemanded === true)
|
|
527
|
+
continue;
|
|
528
|
+
if (!wrunChartHostEnv().sharedHost().wrunLaneGatedOff(source.chart_interval_below, chartIntervalMs))
|
|
529
|
+
continue;
|
|
530
|
+
marked ??= { ...sheet.inputSources };
|
|
531
|
+
marked[name] = { ...source, undemanded: true };
|
|
532
|
+
}
|
|
533
|
+
return marked === undefined ? sheet : { ...sheet, inputSources: marked };
|
|
534
|
+
}
|
|
535
|
+
// ---------------------------------------------------------------------------
|
|
536
|
+
// Coin legs on the chart's coin (kit 0.77.0, `follow: "coin"`)
|
|
537
|
+
// ---------------------------------------------------------------------------
|
|
538
|
+
/** The venues the sheet's coin legs name (`follow: "coin"` beside `exchange`), first occurrence
|
|
539
|
+
* order, each once: the choice the run hands the native venue resolver (resolveVenueLegs). */
|
|
540
|
+
export function wrunCoinLegVenues(sheet) {
|
|
541
|
+
const venues = new Set();
|
|
542
|
+
for (const source of Object.values(sheet.inputSources ?? {})) {
|
|
543
|
+
if (source !== undefined && wrunFollowsCoin(source) && typeof source.exchange === 'string' && source.exchange) {
|
|
544
|
+
venues.add(source.exchange);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return [...venues];
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* The run's answer for every coin-leg venue, from the native venue resolver's verdict on the chart's
|
|
551
|
+
* coin (resolveVenueLegs, TRADE_AGG, the chart's venue as the host): a venue among the legs reads
|
|
552
|
+
* its primary market's raw symbol; a venue the coin is unlisted on, and every venue when no venue
|
|
553
|
+
* lists it (`none-listed`), the chart names no coin (`no-coin`) or its venue keeps its own pins
|
|
554
|
+
* (`host-refused`: CME-governed, prediction-market and DEX charts), reads null (the input reads its
|
|
555
|
+
* fill). Undefined when the listing lookup failed (`lookup-failed`): the run refuses by name
|
|
556
|
+
* (wrun_coin_leg_unresolved), never guessing a market.
|
|
557
|
+
*/
|
|
558
|
+
export function wrunCoinLegsOf(venues, verdict) {
|
|
559
|
+
if (verdict.status === 'lookup-failed')
|
|
560
|
+
return undefined;
|
|
561
|
+
const coinLegs = {};
|
|
562
|
+
for (const venue of venues)
|
|
563
|
+
coinLegs[venue] = null;
|
|
564
|
+
for (const leg of verdict.legs)
|
|
565
|
+
if (Object.hasOwn(coinLegs, leg.exchange))
|
|
566
|
+
coinLegs[leg.exchange] = leg.symbol;
|
|
567
|
+
return coinLegs;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* The sheet a run plans its lanes from with every coin leg resolved on the chart's coin
|
|
571
|
+
* (`coinLegs`, wrunCoinLegsOf): a leg whose venue lists a market for the coin becomes a literal pin
|
|
572
|
+
* (`follow` dropped, `symbol` written: the kit's wrunCoinLegSource), which every reader past this
|
|
573
|
+
* seam reads like any trades pin (its leg lane, the venue verdict of wrun-pin-venues.util, its live
|
|
574
|
+
* channel); a leg whose venue lists none keeps `follow` and is marked `undemanded`, so nothing asks
|
|
575
|
+
* its lane and the row builder reads its fill on every bar (the plan reads the same answer,
|
|
576
|
+
* wrunRowsCoinLegs). A venue the map holds no answer for is left as declared (the row builder
|
|
577
|
+
* refuses it by name). The sheet itself when it declares no coin leg; else a copy with its own
|
|
578
|
+
* `inputSources`. Resolved again by every run: a coin switch re-runs the overlay, so the legs
|
|
579
|
+
* follow the new coin.
|
|
580
|
+
*/
|
|
581
|
+
export function wrunSheetWithCoinLegs(sheet, coinLegs) {
|
|
582
|
+
let resolved;
|
|
583
|
+
for (const [name, source] of Object.entries(sheet.inputSources ?? {})) {
|
|
584
|
+
if (source === undefined || !wrunFollowsCoin(source))
|
|
585
|
+
continue;
|
|
586
|
+
const leg = wrunCoinLegSource(source, coinLegs);
|
|
587
|
+
if (leg === undefined)
|
|
588
|
+
continue;
|
|
589
|
+
resolved ??= { ...sheet.inputSources };
|
|
590
|
+
resolved[name] = leg === null ? { ...source, undemanded: true } : leg;
|
|
591
|
+
}
|
|
592
|
+
return resolved === undefined ? sheet : { ...sheet, inputSources: resolved };
|
|
593
|
+
}
|
|
594
|
+
/** The facts a hosted run's cloud reads the market's size unit from, under the shared host's own
|
|
595
|
+
* `hostFills` words (createScript's and wrunTestRun's `wrunFacts.hostFills`): the chart market's
|
|
596
|
+
* kind, point value and zone (wrunMarketFactsFor). The point value and the zone are venue-table
|
|
597
|
+
* facts and decide contracts, all a lane's `currency: "Auto"` needs; the kind tells coins, shares
|
|
598
|
+
* and units apart for an input's `needed_by` list that names some of them. It is the directory
|
|
599
|
+
* row's once the row answered (the 0 rule before), so a hosted payload whose `needed_by` needs it
|
|
600
|
+
* waits on the row first (getReqPayload, wrunLaneDemandNeedsDirectory). The chart resolves nothing
|
|
601
|
+
* for the cloud: the cloud plans the lanes from its own copy of the sheet and runs the rules itself. */
|
|
602
|
+
export function wrunHostedLaneFills(market) {
|
|
603
|
+
const facts = wrunMarketFactsFor(market);
|
|
604
|
+
return { kind: facts.kind, point_value: facts.pointValue, zone: facts.zone };
|
|
605
|
+
}
|
|
606
|
+
// ---------------------------------------------------------------------------
|
|
607
|
+
// The directory read (main thread): om's rules for when and how
|
|
608
|
+
// ---------------------------------------------------------------------------
|
|
609
|
+
/** Rows one directory search reads per page, and the pages it reads before
|
|
610
|
+
* it gives up on a definite answer (om's MARKET_FACTS_* budget). */
|
|
611
|
+
const DIRECTORY_PAGE_SIZE = 50;
|
|
612
|
+
const DIRECTORY_MAX_PAGES = 4;
|
|
613
|
+
/** How long a market whose search failed answers without its row before a
|
|
614
|
+
* run asks the directory again. */
|
|
615
|
+
const DIRECTORY_RETRY_MS = 60_000;
|
|
616
|
+
const DIRECTORY_TIMEOUT_MS = 15_000;
|
|
617
|
+
/** Definite answers by market for the session: the row, or null (not listed). */
|
|
618
|
+
const settledRows = new Map();
|
|
619
|
+
/** Searches in flight by market: concurrent runs on one market share one. */
|
|
620
|
+
const pendingRows = new Map();
|
|
621
|
+
/** When a market whose search failed may be asked again (epoch ms). */
|
|
622
|
+
const retryAfter = new Map();
|
|
623
|
+
function directoryKey(venue, symbol) {
|
|
624
|
+
return `${venue}\u0000${symbol.trim().toUpperCase()}`;
|
|
625
|
+
}
|
|
626
|
+
/** om `directoryAnswers`: whether the directory can add a fact on `venue`
|
|
627
|
+
* (never a US listing, which the venue tables settle whole, nor the TradFi
|
|
628
|
+
* family or the CME family, whose listings om never reads). */
|
|
629
|
+
function directoryAnswers(venue) {
|
|
630
|
+
return venue !== '' && !US_LISTING_EXCHANGES.has(venue) && !isCmeFamily(venue) && !TRADFI_EXCHANGES.has(venue);
|
|
631
|
+
}
|
|
632
|
+
/** The search ran its page budget with rows still ahead and no exact match. */
|
|
633
|
+
class DirectoryIncomplete extends Error {
|
|
634
|
+
}
|
|
635
|
+
/** The directory row of `symbol` on `venue` (an exact, case-insensitive raw or
|
|
636
|
+
* normalized spelling on that venue), null when the search ran out of rows
|
|
637
|
+
* without one. Throws when a page cannot be read, when it is no answer (a
|
|
638
|
+
* deadline-empty page the markets service vetoed, a partial page: the
|
|
639
|
+
* service documents both as a failed fetch), or when the budget runs out:
|
|
640
|
+
* the caller retries those after a minute, never settles them as absent. */
|
|
641
|
+
async function findDirectoryRow(venue, symbol) {
|
|
642
|
+
const exchange = Exchange[venue];
|
|
643
|
+
if (typeof exchange !== 'number')
|
|
644
|
+
return null;
|
|
645
|
+
const [{ default: metadataService }, { normalizeMarketSymbols }] = await Promise.all([
|
|
646
|
+
wrunChartHostEnv().market.loadMetadataService(),
|
|
647
|
+
wrunChartHostEnv().market.loadSearchPayloadToMarketsRequest(),
|
|
648
|
+
]);
|
|
649
|
+
const want = symbol.trim().toUpperCase();
|
|
650
|
+
for (let page = 0; page < DIRECTORY_MAX_PAGES; page += 1) {
|
|
651
|
+
const raw = await metadataService.getMarketsRaw({
|
|
652
|
+
exchange: [exchange],
|
|
653
|
+
symbolFilter: symbol.trim(),
|
|
654
|
+
pageSize: DIRECTORY_PAGE_SIZE,
|
|
655
|
+
...(page > 0 ? { pageOffset: page * DIRECTORY_PAGE_SIZE } : {}),
|
|
656
|
+
}, { timeoutMs: DIRECTORY_TIMEOUT_MS });
|
|
657
|
+
const rows = normalizeMarketSymbols(raw.marketSymbols);
|
|
658
|
+
const match = rows.find((candidate) => upperText(candidate.exchange) === venue &&
|
|
659
|
+
[candidate.rawSymbol, candidate.normalizedSymbol].some((name) => upperText(name) === want));
|
|
660
|
+
if (match !== undefined)
|
|
661
|
+
return match;
|
|
662
|
+
if (raw.vetoed === true || raw.incomplete === true || (raw.failedSources?.length ?? 0) > 0) {
|
|
663
|
+
throw new DirectoryIncomplete(`${venue}:${symbol}`);
|
|
664
|
+
}
|
|
665
|
+
// The raw page's own size before the service's filter (pageCount when it dropped rows).
|
|
666
|
+
if ((raw.pageCount ?? raw.marketSymbols.length) < DIRECTORY_PAGE_SIZE)
|
|
667
|
+
return null;
|
|
668
|
+
}
|
|
669
|
+
throw new DirectoryIncomplete(`${venue}:${symbol}`);
|
|
670
|
+
}
|
|
671
|
+
/** The market's venue and symbol, undefined when it names no market. */
|
|
672
|
+
function marketKeyParts(market) {
|
|
673
|
+
const venue = upperText(market?.exchange);
|
|
674
|
+
const symbol = typeof market?.symbol === 'string' ? market.symbol.trim() : '';
|
|
675
|
+
return venue === undefined || symbol === '' ? undefined : { venue, symbol };
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Ask the directory for `market`'s row (om's read): once per market for the
|
|
679
|
+
* session, a definite answer (the row, or not listed) kept; concurrent callers
|
|
680
|
+
* share one search; a failure is asked again a minute later and meanwhile the
|
|
681
|
+
* facts read as the chart knows them without the row. Never rejects. A venue
|
|
682
|
+
* whose listings om never reads asks nothing.
|
|
683
|
+
*/
|
|
684
|
+
export function warmWrunMarketFacts(market) {
|
|
685
|
+
const parts = marketKeyParts(market);
|
|
686
|
+
if (parts === undefined || !directoryAnswers(parts.venue))
|
|
687
|
+
return Promise.resolve();
|
|
688
|
+
const key = directoryKey(parts.venue, parts.symbol);
|
|
689
|
+
if (settledRows.has(key))
|
|
690
|
+
return Promise.resolve();
|
|
691
|
+
if (Date.now() < (retryAfter.get(key) ?? 0))
|
|
692
|
+
return Promise.resolve();
|
|
693
|
+
let search = pendingRows.get(key);
|
|
694
|
+
if (search === undefined) {
|
|
695
|
+
search = findDirectoryRow(parts.venue, parts.symbol)
|
|
696
|
+
.then((row) => {
|
|
697
|
+
settledRows.set(key, row);
|
|
698
|
+
retryAfter.delete(key);
|
|
699
|
+
})
|
|
700
|
+
.catch(() => {
|
|
701
|
+
retryAfter.set(key, Date.now() + DIRECTORY_RETRY_MS);
|
|
702
|
+
})
|
|
703
|
+
.finally(() => pendingRows.delete(key));
|
|
704
|
+
pendingRows.set(key, search);
|
|
705
|
+
}
|
|
706
|
+
return search;
|
|
707
|
+
}
|
|
708
|
+
/** True when a read of `market`'s facts now would wait on nothing: the
|
|
709
|
+
* directory answered, failed recently, or is never asked for its venue. */
|
|
710
|
+
export function wrunMarketFactsSettled(market) {
|
|
711
|
+
const parts = marketKeyParts(market);
|
|
712
|
+
if (parts === undefined || !directoryAnswers(parts.venue))
|
|
713
|
+
return true;
|
|
714
|
+
const key = directoryKey(parts.venue, parts.symbol);
|
|
715
|
+
return settledRows.has(key) || Date.now() < (retryAfter.get(key) ?? 0);
|
|
716
|
+
}
|
|
717
|
+
/** The facts the chart fills for `market` now (synchronous): the five over the
|
|
718
|
+
* directory row once warmWrunMarketFacts settled it, else without one, and
|
|
719
|
+
* the option multiplier of its options chain (wrunChartOptionMultiplier: the
|
|
720
|
+
* venue tables alone, no read). */
|
|
721
|
+
export function wrunMarketFactsFor(market) {
|
|
722
|
+
const parts = marketKeyParts(market);
|
|
723
|
+
const row = parts === undefined ? undefined : settledRows.get(directoryKey(parts.venue, parts.symbol));
|
|
724
|
+
return { ...wrunChartMarketFacts(market, row ?? undefined), optionMultiplier: wrunChartOptionMultiplier(market) };
|
|
725
|
+
}
|
|
726
|
+
/** Forget every kept answer (spec isolation). */
|
|
727
|
+
export function clearWrunMarketFactsMemo() {
|
|
728
|
+
settledRows.clear();
|
|
729
|
+
pendingRows.clear();
|
|
730
|
+
retryAfter.clear();
|
|
731
|
+
}
|