@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,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clamp-at-load for a wrun module's linear memory: the browser twin of the hosted lane's
|
|
3
|
+
* `validateAndClampWrunMemory` (kscript-backend wrun-host.ts), same rules, same splice.
|
|
4
|
+
*
|
|
5
|
+
* The worker's memory check (checkMemoryLimit in wrun-abi-host) reads the memory only AFTER a
|
|
6
|
+
* guest call returns, and the modules the compiler emits declare their memory with no maximum,
|
|
7
|
+
* so one onBar() call could grow the memory to hundreds of MB before that check ran. Bounding
|
|
8
|
+
* the memory in the module itself closes that hole: the engine then refuses memory.grow past
|
|
9
|
+
* the maximum INSIDE the call (the guest traps) and never commits the pages.
|
|
10
|
+
*
|
|
11
|
+
* - a declared memory with NO maximum is rewritten to carry maximum = the limit in pages,
|
|
12
|
+
* with zero toolchain or republish churn (requiring authors to declare one would refuse
|
|
13
|
+
* every package already published);
|
|
14
|
+
* - a declared maximum above the limit, a starting size above it, shared or 64-bit memory,
|
|
15
|
+
* a maximum below the starting size, or a memory count other than one are refused;
|
|
16
|
+
* - a module that declares no memory, or a maximum within the limit, comes back unchanged
|
|
17
|
+
* (the very same bytes object).
|
|
18
|
+
*
|
|
19
|
+
* The rewrite is a minimal LEB128 splice of the memory section; every other byte of the module
|
|
20
|
+
* is untouched. Callers compile the RETURNED bytes.
|
|
21
|
+
*/
|
|
22
|
+
/** One WebAssembly page. */
|
|
23
|
+
const WASM_PAGE_BYTES = 64 * 1024;
|
|
24
|
+
/** The memory one wrun module may hold in the browser, the one source of the 4 MiB: the worker's
|
|
25
|
+
* ceiling (WRUN_DEFAULT_MEMORY_LIMIT_BYTES in wrun-abi-host) reads it from here: this module
|
|
26
|
+
* imports nothing, while the main thread imports the worker host for its types only. */
|
|
27
|
+
export const WRUN_MEMORY_LIMIT_BYTES = 4 * 1024 * 1024;
|
|
28
|
+
/** The limit as the maximum stamped on a module's memory: 64 pages. */
|
|
29
|
+
export const WRUN_MEMORY_LIMIT_PAGES = WRUN_MEMORY_LIMIT_BYTES / WASM_PAGE_BYTES;
|
|
30
|
+
const MEMORY_SECTION_ID = 5;
|
|
31
|
+
/** The memory type's flags: bit 0 = a maximum follows; any other bit (shared, 64-bit) is refused. */
|
|
32
|
+
const MEMORY_HAS_MAXIMUM = 0x01;
|
|
33
|
+
const KIB = 1024;
|
|
34
|
+
const MIB = 1024 * KIB;
|
|
35
|
+
/** `\0asm` then version 1. */
|
|
36
|
+
const WASM_HEADER = [0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00];
|
|
37
|
+
/** A size in the words a person reads: whole MiB or KiB when it is one, else bytes. */
|
|
38
|
+
function sizeInWords(bytes) {
|
|
39
|
+
if (bytes % MIB === 0)
|
|
40
|
+
return `${bytes / MIB} MiB`;
|
|
41
|
+
if (bytes % KIB === 0)
|
|
42
|
+
return `${bytes / KIB} KiB`;
|
|
43
|
+
return `${bytes} bytes`;
|
|
44
|
+
}
|
|
45
|
+
/** One unsigned LEB128 u32 at `offset`, bounded by `end`: its value and the offset after it.
|
|
46
|
+
* A fifth byte may carry only the top four bits (the format's own rule for a u32). */
|
|
47
|
+
function readVarUint32(bytes, offset, end) {
|
|
48
|
+
let value = 0;
|
|
49
|
+
let cursor = offset;
|
|
50
|
+
for (let shift = 0; shift <= 28; shift += 7) {
|
|
51
|
+
if (cursor >= end)
|
|
52
|
+
throw new Error('WRUN module is cut short: a size or count runs past the end of the file');
|
|
53
|
+
const byte = bytes[cursor];
|
|
54
|
+
cursor += 1;
|
|
55
|
+
if (shift === 28 && (byte & 0x70) !== 0) {
|
|
56
|
+
throw new Error('WRUN module has a size or count too large to read');
|
|
57
|
+
}
|
|
58
|
+
value |= (byte & 0x7f) << shift;
|
|
59
|
+
if ((byte & 0x80) === 0)
|
|
60
|
+
return { value: value >>> 0, next: cursor };
|
|
61
|
+
}
|
|
62
|
+
throw new Error('WRUN module has a size or count too large to read');
|
|
63
|
+
}
|
|
64
|
+
function encodeVarUint32(value) {
|
|
65
|
+
const out = [];
|
|
66
|
+
let rest = value >>> 0;
|
|
67
|
+
do {
|
|
68
|
+
let byte = rest & 0x7f;
|
|
69
|
+
rest >>>= 7;
|
|
70
|
+
if (rest !== 0)
|
|
71
|
+
byte |= 0x80;
|
|
72
|
+
out.push(byte);
|
|
73
|
+
} while (rest !== 0);
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
/** The memory section's span (section id byte to the end of its body), or null when the module
|
|
77
|
+
* declares none. Walks the section headers only; no section body but the memory's is read. */
|
|
78
|
+
function findMemorySection(bytes) {
|
|
79
|
+
let memorySection = null;
|
|
80
|
+
let offset = WASM_HEADER.length;
|
|
81
|
+
while (offset < bytes.length) {
|
|
82
|
+
const start = offset;
|
|
83
|
+
const id = bytes[offset];
|
|
84
|
+
const size = readVarUint32(bytes, offset + 1, bytes.length);
|
|
85
|
+
const bodyStart = size.next;
|
|
86
|
+
const end = bodyStart + size.value;
|
|
87
|
+
if (end > bytes.length)
|
|
88
|
+
throw new Error('WRUN module is cut short: a section runs past the end of the file');
|
|
89
|
+
if (id === MEMORY_SECTION_ID)
|
|
90
|
+
memorySection = { start, bodyStart, end };
|
|
91
|
+
offset = end;
|
|
92
|
+
}
|
|
93
|
+
return memorySection;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Validate a wrun module's memory against the limit and clamp an absent maximum to it. Returns
|
|
97
|
+
* the bytes to COMPILE: the same object when nothing needed rewriting, else a copy whose memory
|
|
98
|
+
* section carries maximum = the limit in pages. Throws a plain-words Error on a refusal.
|
|
99
|
+
*/
|
|
100
|
+
export function clampWrunModuleMemory(bytes, limitBytes = WRUN_MEMORY_LIMIT_BYTES) {
|
|
101
|
+
if (bytes.length < WASM_HEADER.length || WASM_HEADER.some((byte, index) => bytes[index] !== byte)) {
|
|
102
|
+
throw new Error('WRUN module is not a version 1 WebAssembly file');
|
|
103
|
+
}
|
|
104
|
+
const capPages = Math.max(1, Math.floor(limitBytes / WASM_PAGE_BYTES));
|
|
105
|
+
const limit = sizeInWords(limitBytes);
|
|
106
|
+
const section = findMemorySection(bytes);
|
|
107
|
+
if (section === null)
|
|
108
|
+
return bytes; // No declared memory: nothing to bound.
|
|
109
|
+
const count = readVarUint32(bytes, section.bodyStart, section.end);
|
|
110
|
+
if (count.value !== 1) {
|
|
111
|
+
throw new Error(`WRUN module declares ${count.value} memories; an Indicator runs with exactly one`);
|
|
112
|
+
}
|
|
113
|
+
if (count.next >= section.end) {
|
|
114
|
+
throw new Error('WRUN module is cut short: its memory section ends early');
|
|
115
|
+
}
|
|
116
|
+
const flags = bytes[count.next];
|
|
117
|
+
if ((flags & ~MEMORY_HAS_MAXIMUM) !== 0) {
|
|
118
|
+
throw new Error('WRUN module asks for shared or 64-bit memory, which an Indicator cannot use');
|
|
119
|
+
}
|
|
120
|
+
const initial = readVarUint32(bytes, count.next + 1, section.end);
|
|
121
|
+
if (initial.value > capPages) {
|
|
122
|
+
throw new Error(`WRUN module starts with ${sizeInWords(initial.value * WASM_PAGE_BYTES)} of memory, ` +
|
|
123
|
+
`more than the ${limit} an Indicator may use`);
|
|
124
|
+
}
|
|
125
|
+
if ((flags & MEMORY_HAS_MAXIMUM) !== 0) {
|
|
126
|
+
const maximum = readVarUint32(bytes, initial.next, section.end);
|
|
127
|
+
if (maximum.value < initial.value) {
|
|
128
|
+
throw new Error('WRUN module sets its memory maximum below its starting size');
|
|
129
|
+
}
|
|
130
|
+
if (maximum.value > capPages) {
|
|
131
|
+
throw new Error(`WRUN module lets its memory grow to ${sizeInWords(maximum.value * WASM_PAGE_BYTES)}, ` +
|
|
132
|
+
`more than the ${limit} an Indicator may use; build it with no memory maximum, ` +
|
|
133
|
+
`or with one of ${limit} or less`);
|
|
134
|
+
}
|
|
135
|
+
return bytes; // Already bounded within the limit.
|
|
136
|
+
}
|
|
137
|
+
// Clamp: rebuild the memory section as {count 1, flags "has maximum", initial, maximum =
|
|
138
|
+
// capPages} and splice it in place of the original section.
|
|
139
|
+
const body = [1, MEMORY_HAS_MAXIMUM, ...encodeVarUint32(initial.value), ...encodeVarUint32(capPages)];
|
|
140
|
+
const rebuilt = [MEMORY_SECTION_ID, ...encodeVarUint32(body.length), ...body];
|
|
141
|
+
const clamped = new Uint8Array(bytes.length - (section.end - section.start) + rebuilt.length);
|
|
142
|
+
clamped.set(bytes.subarray(0, section.start), 0);
|
|
143
|
+
clamped.set(rebuilt, section.start);
|
|
144
|
+
clamped.set(bytes.subarray(section.end), section.start + rebuilt.length);
|
|
145
|
+
return clamped;
|
|
146
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** The kit starters' stand-in odds market: the same bytes as om's WRUN_PLACEHOLDER_CONDITION_ID. */
|
|
2
|
+
export declare const WRUN_ODDS_PLACEHOLDER_MARKET: string;
|
|
3
|
+
/** A market a starter can be pinned to. */
|
|
4
|
+
export interface WrunOddsTemplateMarket {
|
|
5
|
+
/** The condition id, lower-case. */
|
|
6
|
+
conditionId: string;
|
|
7
|
+
/** The market's question, written into the comment above the stamped input (and the starter's
|
|
8
|
+
* `market_kind` and `market` settings). */
|
|
9
|
+
question: string;
|
|
10
|
+
/** When the market ends, epoch ms: it settles (`resolutionTime`), else its trading closes
|
|
11
|
+
* (`availableTo`). The starter's `market_end` setting. */
|
|
12
|
+
endMs?: number;
|
|
13
|
+
}
|
|
14
|
+
/** One market row as the catalog sends it, flattened off its event. */
|
|
15
|
+
export interface WrunOddsMarketCandidate {
|
|
16
|
+
conditionId?: string;
|
|
17
|
+
question?: string;
|
|
18
|
+
lastPrice?: number;
|
|
19
|
+
totalVolume?: number;
|
|
20
|
+
closed?: boolean;
|
|
21
|
+
/** When trading ends, epoch ms: the pick's runway and the picked market's end. */
|
|
22
|
+
availableToMs?: number;
|
|
23
|
+
}
|
|
24
|
+
/** The settings a pinned market fills in a starter that declares them (C5), by param name. */
|
|
25
|
+
export type WrunOddsMarketParam = 'market_end' | 'market_kind' | 'market';
|
|
26
|
+
/** What a market's question asks of the price: the `market_kind` options, verbatim (C5). */
|
|
27
|
+
export type WrunOddsMarketKind = 'Above on the date' | 'Below on the date' | 'Reaches by the date';
|
|
28
|
+
/** Whether a starter's text still pins the stand-in market. */
|
|
29
|
+
export declare function wrunSourcePinsPlaceholderMarket(source: string): boolean;
|
|
30
|
+
/** The dollar strike of a "will X reach / be above $N" question; undefined for any other shape
|
|
31
|
+
* (a dip, a band, an up-or-down, two amounts or none). */
|
|
32
|
+
export declare function wrunMarketUpsideStrike(question: string): number | undefined;
|
|
33
|
+
/** What `question` asks of the price: the kind whose word comes first ("below $80,000 over the
|
|
34
|
+
* weekend" asks below); undefined when no word asks (a band, an up-or-down, a non-price question). */
|
|
35
|
+
export declare function wrunMarketKind(question: string): WrunOddsMarketKind | undefined;
|
|
36
|
+
/** A Bitcoin reach/above market: the shape every starter's BTC leg and strike param read. */
|
|
37
|
+
export declare function wrunIsBitcoinUpsideMarket(question: string): boolean;
|
|
38
|
+
/** The default market for a starter: an open Bitcoin reach/above market, by the tiers above, the
|
|
39
|
+
* most traded of its tier. With `nearPrice` (the Bitcoin price, for a starter whose math measures
|
|
40
|
+
* BTC against the market's strike) the market whose strike sits nearest that price wins its tier
|
|
41
|
+
* instead, volume breaking ties: a strike far from the price leaves that math flat. The pick ends
|
|
42
|
+
* when its trading does. Undefined when nothing qualifies. */
|
|
43
|
+
export declare function pickWrunDefaultOddsMarket(candidates: ReadonlyArray<WrunOddsMarketCandidate>, nowMs: number, nearPrice?: number): WrunOddsTemplateMarket | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The starter's text pinned to `market`: every stand-in id becomes the market's condition id, the
|
|
46
|
+
* kit's "replace the placeholder" note right above each such input gives way to two lines naming
|
|
47
|
+
* the market and how to repoint it, `strikeParam` (the starter's "price the market is anchored on" param) takes the
|
|
48
|
+
* market's dollar strike as its default when the question has one, and each of `marketParams` the
|
|
49
|
+
* starter declares takes the market's end, kind or question (MARKET_PARAM_STAMPS).
|
|
50
|
+
*/
|
|
51
|
+
export declare function stampWrunTemplateOddsMarket(source: string, market: WrunOddsTemplateMarket, strikeParam?: string, marketParams?: ReadonlyArray<WrunOddsMarketParam>): string;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A live Polymarket market for the kit's prediction-market starters.
|
|
3
|
+
*
|
|
4
|
+
* The kit ships every odds starter (polymarket-odds, conviction-score, event-asset-divergence,
|
|
5
|
+
* escalation-risk) pinned to a stand-in condition id, `0x` followed by 64 `a`s (om's
|
|
6
|
+
* WRUN_PLACEHOLDER_CONDITION_ID): authoring stamps it, om's publish guard refuses it, and the run
|
|
7
|
+
* planner refuses it by name (`wrun_odds_placeholder_market`, wrun-source-rows.util.ts). On the
|
|
8
|
+
* command line the author searches a market and repoints the input; in the chart nobody can be
|
|
9
|
+
* asked for a condition id, so the editor pins one right after such a starter is picked
|
|
10
|
+
* (KScriptWorkspace `onTemplatePick` -> wrun-odds-default-market.ts `wrunPinStarterMarket`): the
|
|
11
|
+
* active chart's own market when it is a Polymarket market, else the most-traded live "Bitcoin
|
|
12
|
+
* reach/above $X" market. The stamped text is an ordinary pinned starter: the id is visible and
|
|
13
|
+
* editable in the buffer, a save keeps it, nothing re-resolves it later.
|
|
14
|
+
*
|
|
15
|
+
* The same pick fills the settings a starter declares about its market (contract C5, by kit id in
|
|
16
|
+
* WRUN_TEMPLATE_MARKET_PARAMS): `market_end` (when the market ends, UTC to the minute),
|
|
17
|
+
* `market_kind` (what its question asks of the price) and `market` (the question its legend
|
|
18
|
+
* prints). A starter that declares none keeps its text, and a value the declaration would refuse is
|
|
19
|
+
* never written.
|
|
20
|
+
*
|
|
21
|
+
* A PURE LEAF (its one import, the kit-mirrored text rule, is a leaf too): the run planner reads
|
|
22
|
+
* the stand-in id from here, and node specs run the stamp over the real kit sources.
|
|
23
|
+
*/
|
|
24
|
+
import { WRUN_DEFAULT_TEXT_PARAM_BYTES, wrunPlainText, wrunTextByteLength } from './wrun-text-params.util.js';
|
|
25
|
+
/** The kit starters' stand-in odds market: the same bytes as om's WRUN_PLACEHOLDER_CONDITION_ID. */
|
|
26
|
+
export const WRUN_ODDS_PLACEHOLDER_MARKET = `0x${'a'.repeat(64)}`;
|
|
27
|
+
/** The stand-in id in a starter's text, any case (the planner lower-cases before it refuses). */
|
|
28
|
+
const PLACEHOLDER_ID_RE = /0x[aA]{64}(?![0-9a-fA-F])/;
|
|
29
|
+
const PLACEHOLDER_ID_RE_G = new RegExp(PLACEHOLDER_ID_RE.source, 'g');
|
|
30
|
+
const CONDITION_ID_RE = /^0x[0-9a-f]{64}$/i;
|
|
31
|
+
/** Whether a starter's text still pins the stand-in market. */
|
|
32
|
+
export function wrunSourcePinsPlaceholderMarket(source) {
|
|
33
|
+
return PLACEHOLDER_ID_RE.test(source);
|
|
34
|
+
}
|
|
35
|
+
/** YES is the price at or over the strike. */
|
|
36
|
+
const UPSIDE_RE = /\b(?:reach|hit|above|exceeds?|greater than)\b/i;
|
|
37
|
+
/** A question that also reads down or as a band has no single upside strike. */
|
|
38
|
+
const NOT_UPSIDE_RE = /\b(?:dip|below|under|less than|between|fall|drop)\b/i;
|
|
39
|
+
const DOLLAR_RE = /\$\s?(\d[\d,]*(?:\.\d+)?)\s*([kmb])?\b/gi;
|
|
40
|
+
const DOLLAR_SCALE = { k: 1e3, m: 1e6, b: 1e9 };
|
|
41
|
+
/** The dollar strike of a "will X reach / be above $N" question; undefined for any other shape
|
|
42
|
+
* (a dip, a band, an up-or-down, two amounts or none). */
|
|
43
|
+
export function wrunMarketUpsideStrike(question) {
|
|
44
|
+
if (!UPSIDE_RE.test(question) || NOT_UPSIDE_RE.test(question))
|
|
45
|
+
return undefined;
|
|
46
|
+
const amounts = [...question.matchAll(DOLLAR_RE)];
|
|
47
|
+
if (amounts.length !== 1)
|
|
48
|
+
return undefined;
|
|
49
|
+
const [, digits, scale] = amounts[0];
|
|
50
|
+
const value = Number(digits.replace(/,/g, '')) * (scale ? DOLLAR_SCALE[scale.toLowerCase()] : 1);
|
|
51
|
+
return Number.isFinite(value) && value > 0 ? value : undefined;
|
|
52
|
+
}
|
|
53
|
+
/** The words that ask each kind (C5). */
|
|
54
|
+
const MARKET_KIND_WORDS = [
|
|
55
|
+
['Reaches by the date', /\b(?:reach(?:es)?|hits?|(?:dips?|falls?|drops?)\s+to)\b/i],
|
|
56
|
+
['Above on the date', /\b(?:above|exceeds?|greater\s+than|over)\b/i],
|
|
57
|
+
['Below on the date', /\b(?:below|under|less\s+than)\b/i],
|
|
58
|
+
];
|
|
59
|
+
/** What `question` asks of the price: the kind whose word comes first ("below $80,000 over the
|
|
60
|
+
* weekend" asks below); undefined when no word asks (a band, an up-or-down, a non-price question). */
|
|
61
|
+
export function wrunMarketKind(question) {
|
|
62
|
+
let first;
|
|
63
|
+
for (const [kind, words] of MARKET_KIND_WORDS) {
|
|
64
|
+
const at = words.exec(question)?.index;
|
|
65
|
+
if (at !== undefined && (first === undefined || at < first.at))
|
|
66
|
+
first = { kind, at };
|
|
67
|
+
}
|
|
68
|
+
return first?.kind;
|
|
69
|
+
}
|
|
70
|
+
const BITCOIN_RE = /\b(?:bitcoin|btc)\b/i;
|
|
71
|
+
/** A Bitcoin reach/above market: the shape every starter's BTC leg and strike param read. */
|
|
72
|
+
export function wrunIsBitcoinUpsideMarket(question) {
|
|
73
|
+
return BITCOIN_RE.test(question) && wrunMarketUpsideStrike(question) !== undefined;
|
|
74
|
+
}
|
|
75
|
+
const DAY_MS = 86_400_000;
|
|
76
|
+
/** First a market with two weeks of runway whose odds still move (a market priced at 0.02 draws a
|
|
77
|
+
* flat line), then anything open for another day. */
|
|
78
|
+
const PICK_TIERS = [
|
|
79
|
+
{ runwayMs: 14 * DAY_MS, lively: true },
|
|
80
|
+
{ runwayMs: DAY_MS, lively: false },
|
|
81
|
+
];
|
|
82
|
+
function isLively(price) {
|
|
83
|
+
return typeof price === 'number' && price >= 0.1 && price <= 0.9;
|
|
84
|
+
}
|
|
85
|
+
/** How far a market's strike sits from `nearPrice`, as a fraction of it. */
|
|
86
|
+
function strikeGap(question, nearPrice) {
|
|
87
|
+
return Math.abs((wrunMarketUpsideStrike(question) ?? Number.POSITIVE_INFINITY) - nearPrice) / nearPrice;
|
|
88
|
+
}
|
|
89
|
+
/** The default market for a starter: an open Bitcoin reach/above market, by the tiers above, the
|
|
90
|
+
* most traded of its tier. With `nearPrice` (the Bitcoin price, for a starter whose math measures
|
|
91
|
+
* BTC against the market's strike) the market whose strike sits nearest that price wins its tier
|
|
92
|
+
* instead, volume breaking ties: a strike far from the price leaves that math flat. The pick ends
|
|
93
|
+
* when its trading does. Undefined when nothing qualifies. */
|
|
94
|
+
export function pickWrunDefaultOddsMarket(candidates, nowMs, nearPrice) {
|
|
95
|
+
const near = nearPrice !== undefined && Number.isFinite(nearPrice) && nearPrice > 0 ? nearPrice : undefined;
|
|
96
|
+
const eligible = candidates.filter((candidate) => typeof candidate.conditionId === 'string' &&
|
|
97
|
+
CONDITION_ID_RE.test(candidate.conditionId) &&
|
|
98
|
+
!wrunSourcePinsPlaceholderMarket(candidate.conditionId) &&
|
|
99
|
+
!candidate.closed &&
|
|
100
|
+
typeof candidate.question === 'string' &&
|
|
101
|
+
wrunIsBitcoinUpsideMarket(candidate.question));
|
|
102
|
+
for (const tier of PICK_TIERS) {
|
|
103
|
+
let best;
|
|
104
|
+
for (const candidate of eligible) {
|
|
105
|
+
if ((candidate.availableToMs ?? 0) < nowMs + tier.runwayMs)
|
|
106
|
+
continue;
|
|
107
|
+
if (tier.lively && !isLively(candidate.lastPrice))
|
|
108
|
+
continue;
|
|
109
|
+
if (!best) {
|
|
110
|
+
best = candidate;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const gap = near === undefined ? 0 : strikeGap(candidate.question, near) - strikeGap(best.question, near);
|
|
114
|
+
if (gap < 0 || (gap === 0 && (candidate.totalVolume ?? 0) > (best.totalVolume ?? 0)))
|
|
115
|
+
best = candidate;
|
|
116
|
+
}
|
|
117
|
+
if (best) {
|
|
118
|
+
return { conditionId: best.conditionId.toLowerCase(), question: best.question.trim(), endMs: best.availableToMs };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
/** The kit's authoring note above a stand-in input ("replace the placeholder condition id…"). */
|
|
124
|
+
const PLACEHOLDER_NOTE_RE = /placeholder/i;
|
|
125
|
+
const COMMENT_LINE_RE = /^\s*\/\//;
|
|
126
|
+
/**
|
|
127
|
+
* The starter's text pinned to `market`: every stand-in id becomes the market's condition id, the
|
|
128
|
+
* kit's "replace the placeholder" note right above each such input gives way to two lines naming
|
|
129
|
+
* the market and how to repoint it, `strikeParam` (the starter's "price the market is anchored on" param) takes the
|
|
130
|
+
* market's dollar strike as its default when the question has one, and each of `marketParams` the
|
|
131
|
+
* starter declares takes the market's end, kind or question (MARKET_PARAM_STAMPS).
|
|
132
|
+
*/
|
|
133
|
+
export function stampWrunTemplateOddsMarket(source, market, strikeParam, marketParams = []) {
|
|
134
|
+
const question = market.question.replace(/\s+/g, ' ').trim();
|
|
135
|
+
const lines = [];
|
|
136
|
+
for (const line of source.split('\n')) {
|
|
137
|
+
if (!PLACEHOLDER_ID_RE.test(line)) {
|
|
138
|
+
lines.push(line);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
let note = lines.length;
|
|
142
|
+
while (note > 0 && COMMENT_LINE_RE.test(lines[note - 1]))
|
|
143
|
+
note -= 1;
|
|
144
|
+
if (lines.slice(note).some((comment) => PLACEHOLDER_NOTE_RE.test(comment)))
|
|
145
|
+
lines.length = note;
|
|
146
|
+
const indent = /^\s*/.exec(line)?.[0] ?? '';
|
|
147
|
+
lines.push(`${indent}// Pinned to the Polymarket market "${question}"`);
|
|
148
|
+
lines.push(`${indent}// To follow another market, paste its condition id (0x…) into symbol.`);
|
|
149
|
+
lines.push(line.replace(PLACEHOLDER_ID_RE_G, market.conditionId.toLowerCase()));
|
|
150
|
+
}
|
|
151
|
+
const stamped = lines.join('\n');
|
|
152
|
+
const strike = strikeParam === undefined ? undefined : wrunMarketUpsideStrike(question);
|
|
153
|
+
const anchored = strikeParam === undefined || strike === undefined ? stamped : withParamDefault(stamped, strikeParam, strike);
|
|
154
|
+
const pinned = { ...market, question };
|
|
155
|
+
return marketParams.reduce((text, param) => MARKET_PARAM_STAMPS[param](text, pinned), anchored);
|
|
156
|
+
}
|
|
157
|
+
/** `param.number("<name>", <default>, …)` with `value` as the default, unless it falls outside the
|
|
158
|
+
* declaration's own `min` / `max`. */
|
|
159
|
+
function withParamDefault(source, name, value) {
|
|
160
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
161
|
+
const declaration = new RegExp(`^(\\s*param\\.number\\(\\s*"${escaped}"\\s*,\\s*)-?\\d+(?:\\.\\d+)?(?=\\s*[,)])(.*)$`, 'm');
|
|
162
|
+
return source.replace(declaration, (whole, head, rest) => {
|
|
163
|
+
const min = /\bmin\s*:\s*(-?\d+(?:\.\d+)?)/.exec(rest)?.[1];
|
|
164
|
+
const max = /\bmax\s*:\s*(-?\d+(?:\.\d+)?)/.exec(rest)?.[1];
|
|
165
|
+
if ((min !== undefined && value < Number(min)) || (max !== undefined && value > Number(max)))
|
|
166
|
+
return whole;
|
|
167
|
+
return `${head}${value}${rest}`;
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/** Each market setting's stamp (C5): the declaration's default becomes the market's value, or the
|
|
171
|
+
* text stays when the market has none or the declaration would refuse it. */
|
|
172
|
+
const MARKET_PARAM_STAMPS = {
|
|
173
|
+
market_end: (source, { endMs }) => {
|
|
174
|
+
const end = utcMinute(endMs);
|
|
175
|
+
return end === undefined ? source : withQuotedDefault(source, 'time', 'market_end', () => end);
|
|
176
|
+
},
|
|
177
|
+
market_kind: (source, { question }) => {
|
|
178
|
+
const kind = wrunMarketKind(question);
|
|
179
|
+
return kind === undefined
|
|
180
|
+
? source
|
|
181
|
+
: withQuotedDefault(source, 'choice', 'market_kind', (head) => (listsOption(head, kind) ? kind : undefined));
|
|
182
|
+
},
|
|
183
|
+
// Plain one-line text within the declaration's byte cap; a chart market known only by its
|
|
184
|
+
// condition id has no question to print.
|
|
185
|
+
market: (source, { question }) => withQuotedDefault(source, 'text', 'market', (_head, rest) => {
|
|
186
|
+
const text = wrunPlainText(question).trim();
|
|
187
|
+
const cap = Number(/\bmax_bytes\s*:\s*(\d+)/.exec(rest)?.[1] ?? WRUN_DEFAULT_TEXT_PARAM_BYTES);
|
|
188
|
+
return text && !CONDITION_ID_RE.test(text) && wrunTextByteLength(text) <= cap ? text : undefined;
|
|
189
|
+
}),
|
|
190
|
+
};
|
|
191
|
+
/** `ms` as a `param.time` default: "YYYY-MM-DD HH:MM" in UTC, the seconds dropped; undefined for
|
|
192
|
+
* an instant the format cannot write. */
|
|
193
|
+
function utcMinute(ms) {
|
|
194
|
+
if (ms === undefined || !(ms > 0))
|
|
195
|
+
return undefined;
|
|
196
|
+
const date = new Date(ms);
|
|
197
|
+
if (Number.isNaN(date.getTime()))
|
|
198
|
+
return undefined;
|
|
199
|
+
const match = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/.exec(date.toISOString());
|
|
200
|
+
return match ? `${match[1]} ${match[2]}` : undefined;
|
|
201
|
+
}
|
|
202
|
+
/** A double-quoted string literal on one line. */
|
|
203
|
+
const QUOTED_LITERAL = String.raw `"(?:[^"\\\n]|\\.)*"`;
|
|
204
|
+
/**
|
|
205
|
+
* `param.<kind>("<name>", …)` with its string default (after the options list, for a choice) set to
|
|
206
|
+
* `value(head, rest)`: `head` is the declaration up to the default, `rest` what follows it up to the
|
|
207
|
+
* declaration's closing parenthesis. Undefined keeps the text. Only a declaration that opens a line
|
|
208
|
+
* counts, as for the strike, so a comment never matches.
|
|
209
|
+
*/
|
|
210
|
+
function withQuotedDefault(source, kind, name, value) {
|
|
211
|
+
const options = kind === 'choice' ? String.raw `\[[^\]]*\]\s*,\s*` : '';
|
|
212
|
+
const declaration = new RegExp(String.raw `^([ \t]*param\.${kind}\(\s*"${name}"\s*,\s*${options})${QUOTED_LITERAL}`, 'm');
|
|
213
|
+
const match = declaration.exec(source);
|
|
214
|
+
if (!match)
|
|
215
|
+
return source;
|
|
216
|
+
const end = match.index + match[0].length;
|
|
217
|
+
const next = value(match[1], declarationRest(source, end));
|
|
218
|
+
if (next === undefined)
|
|
219
|
+
return source;
|
|
220
|
+
// The kit's string reader takes back \\ and \" (a question carries no other escape once plain).
|
|
221
|
+
const literal = `"${next.replace(/[\\"]/g, '\\$&')}"`;
|
|
222
|
+
return `${source.slice(0, match.index)}${match[1]}${literal}${source.slice(end)}`;
|
|
223
|
+
}
|
|
224
|
+
/** Whether a choice declaration's options list (in `head`) names `option`. */
|
|
225
|
+
function listsOption(head, option) {
|
|
226
|
+
const list = /\[([^\]]*)\]/.exec(head)?.[1] ?? '';
|
|
227
|
+
return [...list.matchAll(/"((?:[^"\\\n]|\\.)*)"/g)].some(([, label]) => label === option);
|
|
228
|
+
}
|
|
229
|
+
/** The text from `from` to the parenthesis that closes the declaration around it (string literals
|
|
230
|
+
* skipped): the rest of its arguments. */
|
|
231
|
+
function declarationRest(source, from) {
|
|
232
|
+
let depth = 0;
|
|
233
|
+
for (let at = from; at < source.length; at += 1) {
|
|
234
|
+
const char = source[at];
|
|
235
|
+
if (char === '"' || char === "'") {
|
|
236
|
+
for (at += 1; at < source.length && source[at] !== char && source[at] !== '\n'; at += 1) {
|
|
237
|
+
if (source[at] === '\\')
|
|
238
|
+
at += 1;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
else if (char === '(' || char === '[' || char === '{') {
|
|
242
|
+
depth += 1;
|
|
243
|
+
}
|
|
244
|
+
else if (char === ')' || char === ']' || char === '}') {
|
|
245
|
+
if (depth === 0)
|
|
246
|
+
return source.slice(from, at);
|
|
247
|
+
depth -= 1;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return source.slice(from);
|
|
251
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `options_flow` source class (UW-PARITY source S2) as both threads read it: the field list and its order (the
|
|
3
|
+
* lane row's columns after the stamp), the knob words, and how each knob names the OPTION_PRINT_AGG flow scope rows a
|
|
4
|
+
* bar sums. The lane file (main thread), the K control and its worker twin read this one table, never copies.
|
|
5
|
+
*
|
|
6
|
+
* The rows (tsdb-gateway `pkg/tsdb/selects/option_print_agg.go`, U4; columns `contracts/flow-scope-columns.md`; the
|
|
7
|
+
* dimensions U6's `1792198478_add_option_print_agg_scopes` migration computes):
|
|
8
|
+
* - scope `ticker`: COIN rows of the chart's underlying (raw symbol `COIN`, the coin beside it);
|
|
9
|
+
* - scope `market`: MARKET rows of every issue type (`MARKET`); `equity`, `etf`, `index`: MARKET rows of that issue
|
|
10
|
+
* type (`EQUITY` stock 4, `ETF` 3, `INDEX` 7);
|
|
11
|
+
* - scope `venue`: VENUE rows of one venue (`VENUE:<publisher id>`, the Databento publisher id the rows carry);
|
|
12
|
+
* - a COIN or MARKET row is keyed by option type, `dte_bucket` (1 the print's trade date, 2 one to seven days, 3 eight
|
|
13
|
+
* to thirty-five, 4 later; 0 a print past its expiry) and `moneyness` (+1 out of the money, -1 in the money, unset
|
|
14
|
+
* without an underlying price); a VENUE row by option type and issue type. Side is never a dimension: every row
|
|
15
|
+
* splits its totals by side in its `_ask`, `_bid`, `_mid` and `_none` columns.
|
|
16
|
+
*
|
|
17
|
+
* Import-free: a lane file stays light at module load and the worker twin reads it too.
|
|
18
|
+
*/
|
|
19
|
+
/** The fields, in the kit's order (om `WRUN_OPTIONS_FLOW_FIELDS`); field i is lane row column i + 1. */
|
|
20
|
+
export declare const WRUN_OPTIONS_FLOW_FIELDS: readonly ["call_prem_ask", "call_prem_bid", "call_prem_mid", "call_prem_none", "put_prem_ask", "put_prem_bid", "put_prem_mid", "put_prem_none", "call_prem_total", "put_prem_total", "call_contracts_ask", "call_contracts_bid", "call_contracts_mid", "call_contracts_none", "put_contracts_ask", "put_contracts_bid", "put_contracts_mid", "put_contracts_none", "call_contracts_total", "put_contracts_total", "net_call_prem", "net_put_prem", "net_call_prem_capped", "net_put_prem_capped", "share_delta_ask", "share_delta_bid", "vega_ask", "vega_bid", "prints", "vol_above_ask", "vol_below_bid", "n_priced"];
|
|
21
|
+
export type WrunOptionsFlowField = (typeof WRUN_OPTIONS_FLOW_FIELDS)[number];
|
|
22
|
+
/** The fields scope `venue` serves (om `WRUN_OPTIONS_FLOW_VENUE_FIELDS`): the venue rows carry premium by side,
|
|
23
|
+
* prints and the contracts' sum, no side, DTE or moneyness split. */
|
|
24
|
+
export declare const WRUN_OPTIONS_FLOW_VENUE_FIELDS: readonly WrunOptionsFlowField[];
|
|
25
|
+
/** `scope` (om `WRUN_OPTIONS_FLOW_SCOPES`); an absent knob reads `ticker`. */
|
|
26
|
+
export declare const WRUN_OPTIONS_FLOW_SCOPES: readonly ["ticker", "market", "equity", "etf", "index", "venue"];
|
|
27
|
+
export type WrunOptionsFlowScope = (typeof WRUN_OPTIONS_FLOW_SCOPES)[number];
|
|
28
|
+
/** `dte` (om `WRUN_OPTIONS_FLOW_DTE`); an absent knob reads `all`. */
|
|
29
|
+
export declare const WRUN_OPTIONS_FLOW_DTE: readonly ["all", "0dte", "week", "month", "later"];
|
|
30
|
+
export type WrunOptionsFlowDte = (typeof WRUN_OPTIONS_FLOW_DTE)[number];
|
|
31
|
+
/** `moneyness` (om `WRUN_OPTIONS_FLOW_MONEYNESS`); an absent knob reads `all`. */
|
|
32
|
+
export declare const WRUN_OPTIONS_FLOW_MONEYNESS: readonly ["all", "otm", "itm"];
|
|
33
|
+
export type WrunOptionsFlowMoneyness = (typeof WRUN_OPTIONS_FLOW_MONEYNESS)[number];
|
|
34
|
+
/** `venue` (scope `venue` only, required there; om `WRUN_OPTIONS_FLOW_VENUE_RE`): an exchange id, 2 to 16 upper-case
|
|
35
|
+
* letters, digits or underscores. */
|
|
36
|
+
export declare const WRUN_OPTIONS_FLOW_VENUE_RE: RegExp;
|
|
37
|
+
/** The `dte_bucket` a `dte` word keeps (`all` keeps every bucket, unknown ones included). */
|
|
38
|
+
export declare const WRUN_OPTIONS_FLOW_DTE_BUCKET: Readonly<Record<Exclude<WrunOptionsFlowDte, 'all'>, number>>;
|
|
39
|
+
/** The `moneyness` a `moneyness` word keeps (`all` keeps every row, an unpriced one included). */
|
|
40
|
+
export declare const WRUN_OPTIONS_FLOW_MONEYNESS_CODE: Readonly<Record<Exclude<WrunOptionsFlowMoneyness, 'all'>, number>>;
|
|
41
|
+
/** The raw-symbol word of a scope that spans underlyings (a MARKET read, one issue type of it). */
|
|
42
|
+
export declare const WRUN_OPTIONS_FLOW_MARKET_WORDS: Readonly<Record<'market' | 'equity' | 'etf' | 'index', string>>;
|
|
43
|
+
/** The backend type the class reads, by name (a lane refuses it by name while the protocol package lacks it). */
|
|
44
|
+
export declare const WRUN_OPTIONS_FLOW_TYPE = "OPTION_PRINT_AGG";
|
|
45
|
+
/** The K type the lane asks (`K_OPTION_PRINT_AGG_SCOPE`): om's fetch type for the class. */
|
|
46
|
+
export declare const WRUN_OPTION_PRINT_AGG_SCOPE_KTYPE = "option_print_agg_scope";
|
|
47
|
+
/** The named refusal of a scope read while the gateway's `read.option_print_scopes` switch is off. */
|
|
48
|
+
export declare const WRUN_OPTION_SCOPE_READS_OFF_CODE = "option-scope-reads-off";
|
|
49
|
+
/** The backend tiers a bar is read from (UW-PARITY rule 9, ADDENDUM-2 B3): 1m kept 7 days, 5m kept 30, 1d kept for
|
|
50
|
+
* good. The keys are the intervals the K control asks. */
|
|
51
|
+
export declare const WRUN_OPTIONS_FLOW_TIER_KEYS: readonly ["1m", "5m", "1d"];
|
|
52
|
+
export type WrunOptionsFlowTier = (typeof WRUN_OPTIONS_FLOW_TIER_KEYS)[number];
|
|
53
|
+
/** One acquisition: the payload the lane's plan answers and the K control forwards (plus the tier it is asked at). */
|
|
54
|
+
export interface WrunOptionsFlowAsk {
|
|
55
|
+
scope: WrunOptionsFlowScope;
|
|
56
|
+
/** Scope `ticker`: the chart's underlying, upper case. */
|
|
57
|
+
coin?: string;
|
|
58
|
+
/** Scope `venue`: the venue's Databento publisher id. */
|
|
59
|
+
venueId?: number;
|
|
60
|
+
dte: WrunOptionsFlowDte;
|
|
61
|
+
moneyness: WrunOptionsFlowMoneyness;
|
|
62
|
+
tier: WrunOptionsFlowTier;
|
|
63
|
+
}
|
|
64
|
+
/** The raw symbol a scope's read names (the scope word alone; a ticker read adds its coin beside it). */
|
|
65
|
+
export declare function wrunOptionsFlowScopeSymbol(ask: Pick<WrunOptionsFlowAsk, 'scope' | 'venueId'>): string;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `options_flow` source class (UW-PARITY source S2) as both threads read it: the field list and its order (the
|
|
3
|
+
* lane row's columns after the stamp), the knob words, and how each knob names the OPTION_PRINT_AGG flow scope rows a
|
|
4
|
+
* bar sums. The lane file (main thread), the K control and its worker twin read this one table, never copies.
|
|
5
|
+
*
|
|
6
|
+
* The rows (tsdb-gateway `pkg/tsdb/selects/option_print_agg.go`, U4; columns `contracts/flow-scope-columns.md`; the
|
|
7
|
+
* dimensions U6's `1792198478_add_option_print_agg_scopes` migration computes):
|
|
8
|
+
* - scope `ticker`: COIN rows of the chart's underlying (raw symbol `COIN`, the coin beside it);
|
|
9
|
+
* - scope `market`: MARKET rows of every issue type (`MARKET`); `equity`, `etf`, `index`: MARKET rows of that issue
|
|
10
|
+
* type (`EQUITY` stock 4, `ETF` 3, `INDEX` 7);
|
|
11
|
+
* - scope `venue`: VENUE rows of one venue (`VENUE:<publisher id>`, the Databento publisher id the rows carry);
|
|
12
|
+
* - a COIN or MARKET row is keyed by option type, `dte_bucket` (1 the print's trade date, 2 one to seven days, 3 eight
|
|
13
|
+
* to thirty-five, 4 later; 0 a print past its expiry) and `moneyness` (+1 out of the money, -1 in the money, unset
|
|
14
|
+
* without an underlying price); a VENUE row by option type and issue type. Side is never a dimension: every row
|
|
15
|
+
* splits its totals by side in its `_ask`, `_bid`, `_mid` and `_none` columns.
|
|
16
|
+
*
|
|
17
|
+
* Import-free: a lane file stays light at module load and the worker twin reads it too.
|
|
18
|
+
*/
|
|
19
|
+
/** The fields, in the kit's order (om `WRUN_OPTIONS_FLOW_FIELDS`); field i is lane row column i + 1. */
|
|
20
|
+
export const WRUN_OPTIONS_FLOW_FIELDS = Object.freeze([
|
|
21
|
+
'call_prem_ask',
|
|
22
|
+
'call_prem_bid',
|
|
23
|
+
'call_prem_mid',
|
|
24
|
+
'call_prem_none',
|
|
25
|
+
'put_prem_ask',
|
|
26
|
+
'put_prem_bid',
|
|
27
|
+
'put_prem_mid',
|
|
28
|
+
'put_prem_none',
|
|
29
|
+
'call_prem_total',
|
|
30
|
+
'put_prem_total',
|
|
31
|
+
'call_contracts_ask',
|
|
32
|
+
'call_contracts_bid',
|
|
33
|
+
'call_contracts_mid',
|
|
34
|
+
'call_contracts_none',
|
|
35
|
+
'put_contracts_ask',
|
|
36
|
+
'put_contracts_bid',
|
|
37
|
+
'put_contracts_mid',
|
|
38
|
+
'put_contracts_none',
|
|
39
|
+
'call_contracts_total',
|
|
40
|
+
'put_contracts_total',
|
|
41
|
+
'net_call_prem',
|
|
42
|
+
'net_put_prem',
|
|
43
|
+
'net_call_prem_capped',
|
|
44
|
+
'net_put_prem_capped',
|
|
45
|
+
'share_delta_ask',
|
|
46
|
+
'share_delta_bid',
|
|
47
|
+
'vega_ask',
|
|
48
|
+
'vega_bid',
|
|
49
|
+
'prints',
|
|
50
|
+
'vol_above_ask',
|
|
51
|
+
'vol_below_bid',
|
|
52
|
+
'n_priced',
|
|
53
|
+
]);
|
|
54
|
+
/** The fields scope `venue` serves (om `WRUN_OPTIONS_FLOW_VENUE_FIELDS`): the venue rows carry premium by side,
|
|
55
|
+
* prints and the contracts' sum, no side, DTE or moneyness split. */
|
|
56
|
+
export const WRUN_OPTIONS_FLOW_VENUE_FIELDS = Object.freeze([
|
|
57
|
+
'call_prem_total',
|
|
58
|
+
'put_prem_total',
|
|
59
|
+
'call_contracts_total',
|
|
60
|
+
'put_contracts_total',
|
|
61
|
+
'prints',
|
|
62
|
+
]);
|
|
63
|
+
/** `scope` (om `WRUN_OPTIONS_FLOW_SCOPES`); an absent knob reads `ticker`. */
|
|
64
|
+
export const WRUN_OPTIONS_FLOW_SCOPES = Object.freeze(['ticker', 'market', 'equity', 'etf', 'index', 'venue']);
|
|
65
|
+
/** `dte` (om `WRUN_OPTIONS_FLOW_DTE`); an absent knob reads `all`. */
|
|
66
|
+
export const WRUN_OPTIONS_FLOW_DTE = Object.freeze(['all', '0dte', 'week', 'month', 'later']);
|
|
67
|
+
/** `moneyness` (om `WRUN_OPTIONS_FLOW_MONEYNESS`); an absent knob reads `all`. */
|
|
68
|
+
export const WRUN_OPTIONS_FLOW_MONEYNESS = Object.freeze(['all', 'otm', 'itm']);
|
|
69
|
+
/** `venue` (scope `venue` only, required there; om `WRUN_OPTIONS_FLOW_VENUE_RE`): an exchange id, 2 to 16 upper-case
|
|
70
|
+
* letters, digits or underscores. */
|
|
71
|
+
export const WRUN_OPTIONS_FLOW_VENUE_RE = /^[A-Z][A-Z0-9_]{1,15}$/;
|
|
72
|
+
/** The `dte_bucket` a `dte` word keeps (`all` keeps every bucket, unknown ones included). */
|
|
73
|
+
export const WRUN_OPTIONS_FLOW_DTE_BUCKET = Object.freeze({ '0dte': 1, week: 2, month: 3, later: 4 });
|
|
74
|
+
/** The `moneyness` a `moneyness` word keeps (`all` keeps every row, an unpriced one included). */
|
|
75
|
+
export const WRUN_OPTIONS_FLOW_MONEYNESS_CODE = Object.freeze({ otm: 1, itm: -1 });
|
|
76
|
+
/** The raw-symbol word of a scope that spans underlyings (a MARKET read, one issue type of it). */
|
|
77
|
+
export const WRUN_OPTIONS_FLOW_MARKET_WORDS = Object.freeze({ market: 'MARKET', equity: 'EQUITY', etf: 'ETF', index: 'INDEX' });
|
|
78
|
+
/** The backend type the class reads, by name (a lane refuses it by name while the protocol package lacks it). */
|
|
79
|
+
export const WRUN_OPTIONS_FLOW_TYPE = 'OPTION_PRINT_AGG';
|
|
80
|
+
/** The K type the lane asks (`K_OPTION_PRINT_AGG_SCOPE`): om's fetch type for the class. */
|
|
81
|
+
export const WRUN_OPTION_PRINT_AGG_SCOPE_KTYPE = 'option_print_agg_scope';
|
|
82
|
+
/** The named refusal of a scope read while the gateway's `read.option_print_scopes` switch is off. */
|
|
83
|
+
export const WRUN_OPTION_SCOPE_READS_OFF_CODE = 'option-scope-reads-off';
|
|
84
|
+
/** The backend tiers a bar is read from (UW-PARITY rule 9, ADDENDUM-2 B3): 1m kept 7 days, 5m kept 30, 1d kept for
|
|
85
|
+
* good. The keys are the intervals the K control asks. */
|
|
86
|
+
export const WRUN_OPTIONS_FLOW_TIER_KEYS = Object.freeze(['1m', '5m', '1d']);
|
|
87
|
+
/** The raw symbol a scope's read names (the scope word alone; a ticker read adds its coin beside it). */
|
|
88
|
+
export function wrunOptionsFlowScopeSymbol(ask) {
|
|
89
|
+
if (ask.scope === 'ticker')
|
|
90
|
+
return 'COIN';
|
|
91
|
+
if (ask.scope === 'venue')
|
|
92
|
+
return `VENUE:${ask.venueId}`;
|
|
93
|
+
return WRUN_OPTIONS_FLOW_MARKET_WORDS[ask.scope];
|
|
94
|
+
}
|