@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,17 @@
|
|
|
1
|
+
export interface VisibleTimeout {
|
|
2
|
+
/** Stops the deadline: drops its timer and its visibility listener. Idempotent, and a no-op once fired. */
|
|
3
|
+
clear(): void;
|
|
4
|
+
/** Visible time counted toward the budget; frozen once fired or cleared. */
|
|
5
|
+
visibleElapsedMs(): number;
|
|
6
|
+
/** Time since the start spent not visible; frozen once fired or cleared. */
|
|
7
|
+
hiddenMs(): number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Runs `callback` once `budgetMs` of visible time has passed since the call. Outside a
|
|
11
|
+
* browser (no `document`) every millisecond counts, as with a plain timeout, and so it
|
|
12
|
+
* does for a document that reports no visibility state: only an explicit `hidden`
|
|
13
|
+
* pauses the clock, so a deadline can never be parked forever by a missing API. Whatever
|
|
14
|
+
* a deadline armed is released by `clear()`, by its own fire, and so by a caller's
|
|
15
|
+
* re-arm (clear the old handle, start a new one).
|
|
16
|
+
*/
|
|
17
|
+
export declare function startVisibleTimeout(callback: () => unknown, budgetMs: number): VisibleTimeout;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Leaf module: a deadline that counts only the time the tab is visible.
|
|
2
|
+
//
|
|
3
|
+
// A background tab pauses frame-driven work (the chart's candle apply waits for a
|
|
4
|
+
// visible frame), so a wall-clock deadline on that work runs out while nobody is
|
|
5
|
+
// looking and fires on return over work that completes the moment the tab shows.
|
|
6
|
+
// While the document is visible a setTimeout runs for the remaining budget; a hide
|
|
7
|
+
// clears it and banks the visible time spent; a show re-arms the remainder. Armed
|
|
8
|
+
// while hidden, the clock starts at the first visible moment, so the callback only
|
|
9
|
+
// ever runs while the tab is visible.
|
|
10
|
+
//
|
|
11
|
+
// Deliberately no import: the chart boot path loads it (hidden-paced-loop.util says
|
|
12
|
+
// why a leaf here must not pull document-visibility.util in).
|
|
13
|
+
/**
|
|
14
|
+
* Runs `callback` once `budgetMs` of visible time has passed since the call. Outside a
|
|
15
|
+
* browser (no `document`) every millisecond counts, as with a plain timeout, and so it
|
|
16
|
+
* does for a document that reports no visibility state: only an explicit `hidden`
|
|
17
|
+
* pauses the clock, so a deadline can never be parked forever by a missing API. Whatever
|
|
18
|
+
* a deadline armed is released by `clear()`, by its own fire, and so by a caller's
|
|
19
|
+
* re-arm (clear the old handle, start a new one).
|
|
20
|
+
*/
|
|
21
|
+
export function startVisibleTimeout(callback, budgetMs) {
|
|
22
|
+
const doc = typeof document === 'undefined' ? null : document;
|
|
23
|
+
const isVisible = () => doc?.visibilityState !== 'hidden';
|
|
24
|
+
// Monotonic, like the timers themselves: a wall-clock jump must not bank visible time.
|
|
25
|
+
const now = () => performance.now();
|
|
26
|
+
const startedAt = now();
|
|
27
|
+
let bankedVisibleMs = 0;
|
|
28
|
+
let visibleSince = null;
|
|
29
|
+
let stoppedAt = null;
|
|
30
|
+
let timer = null;
|
|
31
|
+
const visibleAt = (at) => bankedVisibleMs + (visibleSince === null ? 0 : at - visibleSince);
|
|
32
|
+
// The visible stretch that just ended joins the bank, and its timer goes with it.
|
|
33
|
+
const pause = () => {
|
|
34
|
+
bankedVisibleMs = visibleAt(now());
|
|
35
|
+
visibleSince = null;
|
|
36
|
+
if (timer !== null)
|
|
37
|
+
clearTimeout(timer);
|
|
38
|
+
timer = null;
|
|
39
|
+
};
|
|
40
|
+
const stop = () => {
|
|
41
|
+
if (stoppedAt !== null)
|
|
42
|
+
return;
|
|
43
|
+
pause();
|
|
44
|
+
stoppedAt = now();
|
|
45
|
+
doc?.removeEventListener?.('visibilitychange', onVisibilityChange);
|
|
46
|
+
};
|
|
47
|
+
const fire = () => {
|
|
48
|
+
timer = null;
|
|
49
|
+
stop();
|
|
50
|
+
callback();
|
|
51
|
+
};
|
|
52
|
+
const resume = () => {
|
|
53
|
+
visibleSince = now();
|
|
54
|
+
timer = setTimeout(fire, Math.max(0, budgetMs - bankedVisibleMs));
|
|
55
|
+
};
|
|
56
|
+
// Acts on edges only: a repeated `visible` never stacks a second timer.
|
|
57
|
+
function onVisibilityChange() {
|
|
58
|
+
const visible = isVisible();
|
|
59
|
+
if (visible && visibleSince === null)
|
|
60
|
+
resume();
|
|
61
|
+
else if (!visible && visibleSince !== null)
|
|
62
|
+
pause();
|
|
63
|
+
}
|
|
64
|
+
doc?.addEventListener?.('visibilitychange', onVisibilityChange);
|
|
65
|
+
if (isVisible())
|
|
66
|
+
resume();
|
|
67
|
+
return {
|
|
68
|
+
clear: stop,
|
|
69
|
+
visibleElapsedMs: () => visibleAt(now()),
|
|
70
|
+
hiddenMs: () => {
|
|
71
|
+
const at = stoppedAt ?? now();
|
|
72
|
+
return at - startedAt - visibleAt(at);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display-form suffixes used by processExchangesIntoDisplayExchanges. Callers
|
|
3
|
+
* that need to distinguish a stored token's display form from its actual form
|
|
4
|
+
* should check against this list.
|
|
5
|
+
*/
|
|
6
|
+
export declare const EXCHANGE_DISPLAY_SUFFIXES: readonly [".F", ".O", ".D", ".S"];
|
|
7
|
+
/** Converts exchange display suffixes to their wire exchange form. */
|
|
8
|
+
export declare function formatDisplayToExchange(displayExchange: string): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { gateProviderForExchange } from './v2/gate-plane.util.js';
|
|
2
|
+
/**
|
|
3
|
+
* Display-form suffixes used by processExchangesIntoDisplayExchanges. Callers
|
|
4
|
+
* that need to distinguish a stored token's display form from its actual form
|
|
5
|
+
* should check against this list.
|
|
6
|
+
*/
|
|
7
|
+
export const EXCHANGE_DISPLAY_SUFFIXES = ['.F', '.O', '.D', '.S'];
|
|
8
|
+
/** Converts exchange display suffixes to their wire exchange form. */
|
|
9
|
+
export function formatDisplayToExchange(displayExchange) {
|
|
10
|
+
const reverseSuffixMap = {
|
|
11
|
+
'.F': '_FUTURES',
|
|
12
|
+
'.O': '_OPTIONS',
|
|
13
|
+
'.D': '_DERIVATIVES',
|
|
14
|
+
'.S': '_SWAP',
|
|
15
|
+
};
|
|
16
|
+
// Bybit display futures and the gate-governed venues (the CME markets, the OPRA options feed) use
|
|
17
|
+
// the bare venue on the wire: OPRA.O read as OPRA_OPTIONS names a venue that does not exist.
|
|
18
|
+
if (displayExchange.toUpperCase().startsWith('BYBIT')) {
|
|
19
|
+
for (const suffix of Object.keys(reverseSuffixMap)) {
|
|
20
|
+
if (displayExchange.endsWith(suffix))
|
|
21
|
+
return displayExchange.slice(0, -suffix.length);
|
|
22
|
+
}
|
|
23
|
+
return displayExchange;
|
|
24
|
+
}
|
|
25
|
+
for (const [suffix, replacement] of Object.entries(reverseSuffixMap)) {
|
|
26
|
+
if (!displayExchange.endsWith(suffix))
|
|
27
|
+
continue;
|
|
28
|
+
const bare = displayExchange.slice(0, -suffix.length);
|
|
29
|
+
return gateProviderForExchange(bare) !== null ? bare : bare + replacement;
|
|
30
|
+
}
|
|
31
|
+
return displayExchange;
|
|
32
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// `cn` is not a BCP 47 language: Intl silently falls back to the runtime default for it.
|
|
2
|
+
const INTL_LOCALES = {
|
|
3
|
+
en: 'en-US',
|
|
4
|
+
cn: 'zh-CN',
|
|
5
|
+
ko: 'ko-KR',
|
|
6
|
+
ja: 'ja-JP',
|
|
7
|
+
ru: 'ru-RU',
|
|
8
|
+
hi: 'hi-IN',
|
|
9
|
+
es: 'es-ES',
|
|
10
|
+
tr: 'tr-TR',
|
|
11
|
+
};
|
|
12
|
+
const INTL_TAGS = new Set(Object.values(INTL_LOCALES));
|
|
13
|
+
/** The Intl tag for an app locale code. Idempotent: a value that already is an Intl tag passes through. */
|
|
14
|
+
export function getDateLocale(locale) {
|
|
15
|
+
if (!locale)
|
|
16
|
+
return INTL_LOCALES.en;
|
|
17
|
+
const mapped = INTL_LOCALES[locale];
|
|
18
|
+
if (mapped)
|
|
19
|
+
return mapped;
|
|
20
|
+
if (INTL_TAGS.has(locale))
|
|
21
|
+
return locale;
|
|
22
|
+
try {
|
|
23
|
+
return Intl.getCanonicalLocales(locale)[0];
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return INTL_LOCALES.en;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -31,7 +31,20 @@ export declare function formatDelta(num: number): string;
|
|
|
31
31
|
* is lowercase k / uppercase M.
|
|
32
32
|
*/
|
|
33
33
|
export declare function formatCompactCount(count: number): string;
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* The compact number label (volume legends, volume and indicator axes and pills, indicator legends, the data window,
|
|
36
|
+
* the footprint hover inspector, the trades panel). From 1,000 one rule holds in every unit: the K/M/B mantissa
|
|
37
|
+
* prints at least three significant digits and at least the caller's `defaultDecimalPlaces`, trailing zeros dropped.
|
|
38
|
+
* A volume asking 0 to 2 decimals reads 1,820 "1.82K", 18,200 "18.2K", 182,000 "182K", 1,820,000 "1.82M", 2,000
|
|
39
|
+
* "2K", 1,499 "1.5K". An axis asking 2 keeps neighbouring ticks apart (12,340,000 "12.34M", 12,350,000 "12.35M"),
|
|
40
|
+
* and a price asking 4 keeps its digits (1,234,500 "1.2345M"). The unit comes from the rounded value, so no
|
|
41
|
+
* mantissa reads 1000 (999,999 prints "1M"). Below 1,000 the value prints at `defaultDecimalPlaces` (999 at 2 is
|
|
42
|
+
* "999.00").
|
|
43
|
+
*
|
|
44
|
+
* `_shouldRound` has no effect. It pre-rounded the M/B branch alone, so 1,820,000 printed "1.80M"; callers still
|
|
45
|
+
* pass it.
|
|
46
|
+
*/
|
|
47
|
+
export declare function formatNumbers(num: number, defaultDecimalPlaces?: number, _shouldRound?: boolean): string;
|
|
35
48
|
export declare function changeNumberFormat(value: number, precision: number): string;
|
|
36
49
|
/**
|
|
37
50
|
* Compact positive-volume numeral with sub-unit honesty: values >= 1 keep the
|
|
@@ -63,28 +63,59 @@ export function formatCompactCount(count) {
|
|
|
63
63
|
return `${parseFloat((count / 1000).toFixed(1))}k`;
|
|
64
64
|
return String(count);
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
/** K/M/B, smallest first: a label takes the largest unit the value reaches, and the next one up when its rounded
|
|
67
|
+
* mantissa reaches 1000. */
|
|
68
|
+
const COMPACT_UNITS = [
|
|
69
|
+
{ size: 1e3, suffix: 'K' },
|
|
70
|
+
{ size: 1e6, suffix: 'M' },
|
|
71
|
+
{ size: 1e9, suffix: 'B' },
|
|
72
|
+
];
|
|
73
|
+
/** Significant digits a compact mantissa keeps at least, whatever the unit. */
|
|
74
|
+
const COMPACT_SIGNIFICANT_DIGITS = 3;
|
|
75
|
+
/** The most decimals a caller can ask of a compact mantissa (toFixed's portable range). */
|
|
76
|
+
const MAX_COMPACT_DECIMALS = 20;
|
|
77
|
+
/**
|
|
78
|
+
* `magnitude` as a mantissa of the unit `size`, and the decimals it prints at: enough for three significant digits,
|
|
79
|
+
* never fewer than `minDecimals`. The rounding runs on the unscaled value, half away from zero, so an integer volume
|
|
80
|
+
* rounds exactly (1,005 to 1.01K). Past 999B the mantissa keeps every whole digit.
|
|
81
|
+
*/
|
|
82
|
+
function compactMantissa(magnitude, size, minDecimals) {
|
|
83
|
+
const wholeDigits = Math.floor(Math.log10(magnitude / size)) + 1;
|
|
84
|
+
const decimals = Math.max(minDecimals, COMPACT_SIGNIFICANT_DIGITS - wholeDigits);
|
|
85
|
+
const step = size / 10 ** decimals;
|
|
86
|
+
return { decimals, mantissa: (Math.round(magnitude / step) * step) / size };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The compact number label (volume legends, volume and indicator axes and pills, indicator legends, the data window,
|
|
90
|
+
* the footprint hover inspector, the trades panel). From 1,000 one rule holds in every unit: the K/M/B mantissa
|
|
91
|
+
* prints at least three significant digits and at least the caller's `defaultDecimalPlaces`, trailing zeros dropped.
|
|
92
|
+
* A volume asking 0 to 2 decimals reads 1,820 "1.82K", 18,200 "18.2K", 182,000 "182K", 1,820,000 "1.82M", 2,000
|
|
93
|
+
* "2K", 1,499 "1.5K". An axis asking 2 keeps neighbouring ticks apart (12,340,000 "12.34M", 12,350,000 "12.35M"),
|
|
94
|
+
* and a price asking 4 keeps its digits (1,234,500 "1.2345M"). The unit comes from the rounded value, so no
|
|
95
|
+
* mantissa reads 1000 (999,999 prints "1M"). Below 1,000 the value prints at `defaultDecimalPlaces` (999 at 2 is
|
|
96
|
+
* "999.00").
|
|
97
|
+
*
|
|
98
|
+
* `_shouldRound` has no effect. It pre-rounded the M/B branch alone, so 1,820,000 printed "1.80M"; callers still
|
|
99
|
+
* pass it.
|
|
100
|
+
*/
|
|
101
|
+
export function formatNumbers(num, defaultDecimalPlaces = 1, _shouldRound) {
|
|
67
102
|
if (typeof num != 'number')
|
|
68
103
|
return num;
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
let digits = 1;
|
|
81
|
-
if (Math.abs(numInKs) >= 100) {
|
|
82
|
-
numInKs = Math.round(numInKs);
|
|
83
|
-
digits = 0;
|
|
84
|
-
}
|
|
85
|
-
return numInKs.toFixed(digits) + 'K';
|
|
104
|
+
const magnitude = Math.abs(num);
|
|
105
|
+
if (Number.isNaN(num) || magnitude < COMPACT_UNITS[0].size)
|
|
106
|
+
return num.toFixed(defaultDecimalPlaces);
|
|
107
|
+
const minDecimals = Math.min(MAX_COMPACT_DECIMALS, Math.max(0, Math.trunc(defaultDecimalPlaces) || 0));
|
|
108
|
+
let unit = COMPACT_UNITS.length - 1;
|
|
109
|
+
while (unit > 0 && magnitude < COMPACT_UNITS[unit].size)
|
|
110
|
+
unit--;
|
|
111
|
+
let { decimals, mantissa } = compactMantissa(magnitude, COMPACT_UNITS[unit].size, minDecimals);
|
|
112
|
+
if (mantissa >= 1000 && unit < COMPACT_UNITS.length - 1) {
|
|
113
|
+
unit++;
|
|
114
|
+
({ decimals, mantissa } = compactMantissa(magnitude, COMPACT_UNITS[unit].size, minDecimals));
|
|
86
115
|
}
|
|
87
|
-
|
|
116
|
+
const fixed = mantissa.toFixed(decimals);
|
|
117
|
+
const text = fixed.includes('.') ? fixed.replace(/\.?0+$/, '') : fixed;
|
|
118
|
+
return `${num < 0 ? '-' : ''}${text}${COMPACT_UNITS[unit].suffix}`;
|
|
88
119
|
}
|
|
89
120
|
export function changeNumberFormat(value, precision) {
|
|
90
121
|
// Nine Zeroes for Billions
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { OptionVenue } from '../../constants/option-venues.constants.js';
|
|
2
|
+
/** `inverse` contracts are coin-margined (Deribit `BTC-…`, OKX `BTC-USD-…`); `linear` ones settle in a stablecoin. */
|
|
3
|
+
export type OptionSettlementFamily = 'inverse' | 'linear';
|
|
4
|
+
export interface ParsedOptionSymbol {
|
|
5
|
+
root: string;
|
|
6
|
+
expiryUnix: number;
|
|
7
|
+
strike: number;
|
|
8
|
+
side: 'call' | 'put';
|
|
9
|
+
quoteAsset?: string;
|
|
10
|
+
family?: OptionSettlementFamily;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Roots whose final settlement is struck from the expiry morning's opening prints, so the
|
|
14
|
+
* contract ends at the 09:30 New York open; every other root ends at the 16:00 close. The same
|
|
15
|
+
* reference table metadata-instrument keeps (neither Databento nor Polygon publishes it), so the
|
|
16
|
+
* parsed instant matches the gateway's expiryUnix exactly.
|
|
17
|
+
*/
|
|
18
|
+
export declare const OPRA_AM_SETTLED_ROOTS: ReadonlySet<string>;
|
|
19
|
+
/** The New York calendar day an instant falls on, in days since the epoch: the US options trade date. */
|
|
20
|
+
export declare function newYorkDayNumber(instantMs: number): number;
|
|
21
|
+
/**
|
|
22
|
+
* The instant at which a New York wall-clock time occurs (DST-aware, no zone tables: the offset is
|
|
23
|
+
* read back from Intl, which workers carry). Two passes settle a reading that lands on a DST change.
|
|
24
|
+
*/
|
|
25
|
+
export declare function newYorkInstantMs(year: number, monthIndex: number, day: number, hour: number, minute: number): number;
|
|
26
|
+
/** When an OPRA contract on `root` expiring on a date stops trading, as the gateway stamps it. */
|
|
27
|
+
export declare function opraExpiryUnix(root: string, year: number, monthIndex: number, day: number): number;
|
|
28
|
+
export declare function parseOptionSymbol(venueId: OptionVenue['id'], rawSymbol: string): ParsedOptionSymbol | null;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { contractExpiryEndMs, parseCmeContractExpiry } from '../symbol-selection/contract-expiry.util.js';
|
|
2
|
+
const MONTHS = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'];
|
|
3
|
+
// Same contract pattern `OptionChainService.resolveOptionContractSelection` reads, e.g. `ESU6 C5400`.
|
|
4
|
+
const CME_OPTION_RE = /^(.+?) ([CP])(\d+(?:\.\d+)?)$/;
|
|
5
|
+
// Every crypto venue's catalog `availableTo` lands at 08:00 UTC on the expiry day (measured 2026-09-28).
|
|
6
|
+
const CRYPTO_EXPIRY_HOUR_UTC = 8;
|
|
7
|
+
// Each format captures its date code and reads it as [year, monthIndex, day].
|
|
8
|
+
const EXPIRY_FORMATS = {
|
|
9
|
+
DDMONYY: {
|
|
10
|
+
code: '\\d{1,2}[A-Z]{3}\\d{2}',
|
|
11
|
+
read: (code) => [2000 + Number(code.slice(-2)), MONTHS.indexOf(code.slice(-5, -2)), Number(code.slice(0, -5))],
|
|
12
|
+
},
|
|
13
|
+
YYMMDD: {
|
|
14
|
+
code: '\\d{6}',
|
|
15
|
+
read: (code) => [2000 + Number(code.slice(0, 2)), Number(code.slice(2, 4)) - 1, Number(code.slice(4))],
|
|
16
|
+
},
|
|
17
|
+
YYYYMMDD: {
|
|
18
|
+
code: '\\d{8}',
|
|
19
|
+
read: (code) => [Number(code.slice(0, 4)), Number(code.slice(4, 6)) - 1, Number(code.slice(6))],
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
function side(code) {
|
|
23
|
+
return code === 'C' ? 'call' : 'put';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* One crypto venue's symbol shape. `shape` spells the symbol with `{root}`, `{expiry}`, `{strike}`
|
|
27
|
+
* and `{side}` slots plus an optional named `settle` group; `settlement` maps that token to the
|
|
28
|
+
* contract's family and quote asset.
|
|
29
|
+
*/
|
|
30
|
+
function cryptoOptionParser(shape, expiryFormat, settlement, quirks = {}) {
|
|
31
|
+
const format = EXPIRY_FORMATS[expiryFormat];
|
|
32
|
+
const decimalMark = quirks.strikeDecimalMark ? `[.${quirks.strikeDecimalMark}]` : '\\.';
|
|
33
|
+
const pattern = new RegExp(`^${shape
|
|
34
|
+
.replace('{root}', '(?<root>[A-Z0-9]+)')
|
|
35
|
+
.replace('{expiry}', `(?<expiry>${format.code})`)
|
|
36
|
+
.replace('{strike}', `(?<strike>\\d+(?:${decimalMark}\\d+)?)`)
|
|
37
|
+
.replace('{side}', '(?<side>[CP])')}$`);
|
|
38
|
+
return (rawSymbol) => {
|
|
39
|
+
const groups = pattern.exec(rawSymbol)?.groups;
|
|
40
|
+
if (!groups)
|
|
41
|
+
return null;
|
|
42
|
+
const [year, monthIndex, day] = format.read(groups.expiry);
|
|
43
|
+
const expiryHour = quirks.expiryHourByRoot?.[groups.root] ?? CRYPTO_EXPIRY_HOUR_UTC;
|
|
44
|
+
const expiry = new Date(Date.UTC(year, monthIndex, day, expiryHour));
|
|
45
|
+
const strike = Number(quirks.strikeDecimalMark ? groups.strike.replace(quirks.strikeDecimalMark, '.') : groups.strike);
|
|
46
|
+
if (monthIndex < 0 || expiry.getUTCMonth() !== monthIndex || expiry.getUTCDate() !== day)
|
|
47
|
+
return null;
|
|
48
|
+
if (!(strike > 0))
|
|
49
|
+
return null;
|
|
50
|
+
const { family, quoteAsset } = settlement(groups.settle, groups.root);
|
|
51
|
+
return {
|
|
52
|
+
root: groups.root,
|
|
53
|
+
expiryUnix: expiry.getTime() / 1000,
|
|
54
|
+
strike,
|
|
55
|
+
side: side(groups.side),
|
|
56
|
+
...(quoteAsset ? { quoteAsset } : {}),
|
|
57
|
+
family,
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// Compact OSI, as OPRA contracts are listed: root (1 to 6 characters), YYMMDD, C or P, then the
|
|
62
|
+
// strike in thousandths over eight digits (AAPL261016C00250000 = AAPL 2026-10-16 call 250.000).
|
|
63
|
+
const OSI_OPTION_RE = /^(?<root>[A-Z0-9.]{1,6})(?<expiry>\d{6})(?<side>[CP])(?<strike>\d{8})$/;
|
|
64
|
+
const OSI_NEW_YORK = 'America/New_York';
|
|
65
|
+
const OSI_PM_CLOSE = { hour: 16, minute: 0 };
|
|
66
|
+
const OSI_AM_OPEN = { hour: 9, minute: 30 };
|
|
67
|
+
/**
|
|
68
|
+
* Roots whose final settlement is struck from the expiry morning's opening prints, so the
|
|
69
|
+
* contract ends at the 09:30 New York open; every other root ends at the 16:00 close. The same
|
|
70
|
+
* reference table metadata-instrument keeps (neither Databento nor Polygon publishes it), so the
|
|
71
|
+
* parsed instant matches the gateway's expiryUnix exactly.
|
|
72
|
+
*/
|
|
73
|
+
export const OPRA_AM_SETTLED_ROOTS = new Set(['SPX', 'NDX', 'RUT', 'VIX', 'VIXW', 'DJX']);
|
|
74
|
+
const NEW_YORK_PARTS = new Intl.DateTimeFormat('en-US', {
|
|
75
|
+
timeZone: OSI_NEW_YORK,
|
|
76
|
+
hourCycle: 'h23',
|
|
77
|
+
year: 'numeric',
|
|
78
|
+
month: '2-digit',
|
|
79
|
+
day: '2-digit',
|
|
80
|
+
hour: '2-digit',
|
|
81
|
+
minute: '2-digit',
|
|
82
|
+
});
|
|
83
|
+
/** The New York wall clock of an instant, as a UTC-shaped epoch (minutes precision) for offset arithmetic. */
|
|
84
|
+
function newYorkWallClockMs(instantMs) {
|
|
85
|
+
const read = {};
|
|
86
|
+
for (const part of NEW_YORK_PARTS.formatToParts(new Date(instantMs))) {
|
|
87
|
+
if (part.type !== 'literal')
|
|
88
|
+
read[part.type] = Number(part.value);
|
|
89
|
+
}
|
|
90
|
+
return Date.UTC(read.year, read.month - 1, read.day, read.hour, read.minute);
|
|
91
|
+
}
|
|
92
|
+
/** The New York calendar day an instant falls on, in days since the epoch: the US options trade date. */
|
|
93
|
+
export function newYorkDayNumber(instantMs) {
|
|
94
|
+
return Math.floor(newYorkWallClockMs(instantMs) / 86_400_000);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The instant at which a New York wall-clock time occurs (DST-aware, no zone tables: the offset is
|
|
98
|
+
* read back from Intl, which workers carry). Two passes settle a reading that lands on a DST change.
|
|
99
|
+
*/
|
|
100
|
+
export function newYorkInstantMs(year, monthIndex, day, hour, minute) {
|
|
101
|
+
const wanted = Date.UTC(year, monthIndex, day, hour, minute);
|
|
102
|
+
let guess = wanted;
|
|
103
|
+
for (let pass = 0; pass < 2; pass += 1)
|
|
104
|
+
guess += wanted - newYorkWallClockMs(guess);
|
|
105
|
+
return guess;
|
|
106
|
+
}
|
|
107
|
+
/** When an OPRA contract on `root` expiring on a date stops trading, as the gateway stamps it. */
|
|
108
|
+
export function opraExpiryUnix(root, year, monthIndex, day) {
|
|
109
|
+
const close = OPRA_AM_SETTLED_ROOTS.has(root) ? OSI_AM_OPEN : OSI_PM_CLOSE;
|
|
110
|
+
return newYorkInstantMs(year, monthIndex, day, close.hour, close.minute) / 1000;
|
|
111
|
+
}
|
|
112
|
+
function parseOsiOptionSymbol(rawSymbol) {
|
|
113
|
+
const groups = OSI_OPTION_RE.exec(rawSymbol)?.groups;
|
|
114
|
+
if (!groups)
|
|
115
|
+
return null;
|
|
116
|
+
const [year, monthIndex, day] = EXPIRY_FORMATS.YYMMDD.read(groups.expiry);
|
|
117
|
+
const probe = new Date(Date.UTC(year, monthIndex, day));
|
|
118
|
+
if (probe.getUTCMonth() !== monthIndex || probe.getUTCDate() !== day)
|
|
119
|
+
return null;
|
|
120
|
+
const strike = Number(groups.strike) / 1000;
|
|
121
|
+
if (!(strike > 0))
|
|
122
|
+
return null;
|
|
123
|
+
return {
|
|
124
|
+
root: groups.root,
|
|
125
|
+
expiryUnix: opraExpiryUnix(groups.root, year, monthIndex, day),
|
|
126
|
+
strike,
|
|
127
|
+
side: side(groups.side),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function parseCmeOptionSymbol(rawSymbol) {
|
|
131
|
+
const match = CME_OPTION_RE.exec(rawSymbol);
|
|
132
|
+
if (!match)
|
|
133
|
+
return null;
|
|
134
|
+
const parent = parseCmeContractExpiry(match[1]);
|
|
135
|
+
const strike = Number(match[3]);
|
|
136
|
+
if (!parent || !(strike > 0))
|
|
137
|
+
return null;
|
|
138
|
+
// The code carries only the parent's delivery month; its conservative end stands in for the listed expiry.
|
|
139
|
+
return {
|
|
140
|
+
root: parent.root,
|
|
141
|
+
expiryUnix: Math.floor(contractExpiryEndMs(parent) / 1000),
|
|
142
|
+
strike,
|
|
143
|
+
side: side(match[2]),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
// Binance exchangeInfo 2026-09-29: XAGUSDT and XAUUSDT expire 21:00 UTC, every crypto underlying 08:00.
|
|
147
|
+
const BINANCE_OPTIONS_EXPIRY_HOUR_BY_ROOT = { XAG: 21, XAU: 21 };
|
|
148
|
+
// One row per venue: the Record type makes a new registry id without a parser a type error.
|
|
149
|
+
// Crypto rows follow the symbols measured 2026-09-28; the parser spec holds one sample per venue and family.
|
|
150
|
+
const OPTION_SYMBOL_PARSERS = {
|
|
151
|
+
cme: parseCmeOptionSymbol,
|
|
152
|
+
opra: parseOsiOptionSymbol,
|
|
153
|
+
// `BTC-26SEP26-76000-P` settles in BTC; `BTC_USDC-26SEP26-76000-P` settles in USDC.
|
|
154
|
+
deribit: cryptoOptionParser('{root}(?:_(?<settle>[A-Z0-9]+))?-{expiry}-{strike}-{side}', 'DDMONYY', (settle, root) => (settle ? { family: 'linear', quoteAsset: settle } : { family: 'inverse', quoteAsset: root }), { strikeDecimalMark: 'D' }),
|
|
155
|
+
'binance-options': cryptoOptionParser('{root}-{expiry}-{strike}-{side}', 'YYMMDD', () => ({ family: 'linear', quoteAsset: 'USDT' }), { expiryHourByRoot: BINANCE_OPTIONS_EXPIRY_HOUR_BY_ROOT }),
|
|
156
|
+
// `BTC-USD-260929-82000-P` is coin-margined; `BTC-USD_UM-261016-82000-P` is USDT-margined.
|
|
157
|
+
'okx-options': cryptoOptionParser('{root}-USD(?<settle>_UM)?-{expiry}-{strike}-{side}', 'YYMMDD', (settle) => settle ? { family: 'linear', quoteAsset: 'USDT' } : { family: 'inverse', quoteAsset: 'USD' }),
|
|
158
|
+
// `BTC-26SEP26-85500-C-USDT`; a symbol without the suffix carries no quote asset.
|
|
159
|
+
bybit: cryptoOptionParser('{root}-{expiry}-{strike}-{side}(?:-(?<settle>[A-Z0-9]+))?', 'DDMONYY', (settle) => ({
|
|
160
|
+
family: 'linear',
|
|
161
|
+
...(settle ? { quoteAsset: settle } : {}),
|
|
162
|
+
})),
|
|
163
|
+
bullish: cryptoOptionParser('{root}-(?<settle>[A-Z0-9]+)-{expiry}-{strike}-{side}', 'YYYYMMDD', (settle) => ({
|
|
164
|
+
family: 'linear',
|
|
165
|
+
quoteAsset: settle,
|
|
166
|
+
})),
|
|
167
|
+
derive: cryptoOptionParser('{root}-{expiry}-{strike}-{side}', 'YYYYMMDD', () => ({
|
|
168
|
+
family: 'linear',
|
|
169
|
+
quoteAsset: 'USDC',
|
|
170
|
+
})),
|
|
171
|
+
};
|
|
172
|
+
export function parseOptionSymbol(venueId, rawSymbol) {
|
|
173
|
+
if (!Object.hasOwn(OPTION_SYMBOL_PARSERS, venueId))
|
|
174
|
+
return null;
|
|
175
|
+
return OPTION_SYMBOL_PARSERS[venueId](rawSymbol.trim().toUpperCase());
|
|
176
|
+
}
|