@orangecharts/wrun-chart-host 0.11.0 → 0.14.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 +1 -0
- package/dist/constants/feature-flags.constants.d.ts +3 -4
- package/dist/constants/feature-flags.constants.js +34 -52
- package/dist/constants/feature-limits.constants.d.ts +1 -1
- package/dist/constants/feature-limits.constants.js +5 -4
- package/dist/constants/interval.constants.d.ts +7 -0
- package/dist/constants/interval.constants.js +7 -0
- package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +20 -149
- package/dist/constants/scriptEditor/cme-official-scripts.constants.js +20 -309
- package/dist/constants/stocks-compliance.constants.d.ts +15 -0
- package/dist/constants/stocks-compliance.constants.js +15 -0
- package/dist/host-env.d.ts +55 -3
- package/dist/host-env.js +6 -0
- package/dist/host-ports.types.d.ts +36 -3
- package/dist/index.d.ts +18 -0
- package/dist/index.js +19 -0
- package/dist/indicators/controls/tpo-session.util.d.ts +78 -15
- package/dist/indicators/controls/tpo-session.util.js +320 -242
- package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +6 -0
- package/dist/instances/script-engine-worker-ohlcv-transfer.js +16 -0
- package/dist/interfaces/cme-realtime.interface.d.ts +8 -0
- package/dist/interfaces/cme-realtime.interface.js +2 -1
- package/dist/interfaces/feed.interface.d.ts +15 -1
- package/dist/interfaces/replay.interface.d.ts +5 -0
- package/dist/interfaces/stocks-realtime.interface.d.ts +4 -3
- package/dist/interfaces/stocks-realtime.interface.js +5 -4
- package/dist/interfaces/wrun-runtime.interface.d.ts +97 -19
- package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +17 -0
- package/dist/kscript-data/controls/live-ohlcv-merge.util.js +22 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +46 -40
- package/dist/kscript-data/controls/live-trades-merge.util.js +80 -107
- package/dist/market-data/billing.interface.d.ts +9 -1
- package/dist/market-data/venue.d.ts +1 -1
- package/dist/market-data/venues/index.d.ts +4 -4
- package/dist/market-data/venues/stocks.contract.copy.json +4 -4
- package/dist/market-data/venues/stocks.d.ts +4 -4
- package/dist/market-data/venues/stocks.js +15 -13
- package/dist/settings-templates/frvp-fields.d.ts +12 -1
- package/dist/settings-templates/frvp-fields.js +15 -4
- package/dist/settings-templates/index.js +12 -5
- package/dist/settings-templates/indicator-fields.js +28 -2
- package/dist/settings-templates/tool-rules.d.ts +17 -8
- package/dist/settings-templates/tool-rules.js +15 -8
- package/dist/settings-templates/tool-tables.generated.js +4 -2
- package/dist/utility/auth/server-clock.util.d.ts +3 -1
- package/dist/utility/auth/server-clock.util.js +3 -1
- package/dist/utility/chart/book-live-bucket.util.js +2 -2
- package/dist/utility/chart/cache-alignment.util.d.ts +15 -7
- package/dist/utility/chart/cache-alignment.util.js +14 -7
- package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +2 -0
- package/dist/utility/chart/chart-data-fetch-generation.util.js +16 -0
- package/dist/utility/chart/cme-session-bucket.util.d.ts +18 -75
- package/dist/utility/chart/cme-session-bucket.util.js +25 -332
- package/dist/utility/chart/continuous-contracts.util.js +6 -5
- package/dist/utility/chart/display-offset.leaf.d.ts +24 -0
- package/dist/utility/chart/display-offset.leaf.js +41 -0
- package/dist/utility/chart/effective-chart-session.util.d.ts +2 -1
- package/dist/utility/chart/effective-chart-session.util.js +13 -5
- package/dist/utility/chart/feed-interval.util.d.ts +6 -20
- package/dist/utility/chart/feed-interval.util.js +13 -22
- package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +27 -7
- package/dist/utility/chart/fetch-dedupe-policy.util.js +86 -11
- package/dist/utility/chart/host-bar-placement.util.d.ts +7 -4
- package/dist/utility/chart/host-bar-placement.util.js +8 -2
- package/dist/utility/chart/indicator-inflight-registry.util.d.ts +32 -0
- package/dist/utility/chart/indicator-inflight-registry.util.js +52 -0
- package/dist/utility/chart/indicator-run-interval.util.d.ts +10 -4
- package/dist/utility/chart/indicator-run-interval.util.js +21 -12
- package/dist/utility/chart/interval-registry.util.d.ts +1 -1
- package/dist/utility/chart/interval-registry.util.js +1 -1
- package/dist/utility/chart/kscript-legend-entries.util.d.ts +12 -0
- package/dist/utility/chart/kscript-legend-entries.util.js +16 -0
- package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +1 -1
- package/dist/utility/chart/kscript-run-interval-projection.util.js +4 -2
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +53 -62
- package/dist/utility/chart/kscript-venue-policy.util.js +85 -94
- package/dist/utility/chart/live-bucket.util.d.ts +39 -17
- package/dist/utility/chart/live-bucket.util.js +103 -57
- package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +58 -20
- package/dist/utility/chart/local-kscript-source-revalidation.util.js +98 -23
- package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +35 -11
- package/dist/utility/chart/local-kscript-warmup-depth.util.js +24 -3
- package/dist/utility/chart/market-session-schedule.util.d.ts +8 -0
- package/dist/utility/chart/market-session-schedule.util.js +39 -1
- package/dist/utility/chart/market-session.util.d.ts +136 -0
- package/dist/utility/chart/market-session.util.js +341 -0
- package/dist/utility/chart/market-sessions.util.d.ts +83 -0
- package/dist/utility/chart/market-sessions.util.js +220 -0
- package/dist/utility/chart/om-panel.util.d.ts +5 -3
- package/dist/utility/chart/om-panel.util.js +42 -7
- package/dist/utility/chart/om-target.util.d.ts +14 -1
- package/dist/utility/chart/om-target.util.js +22 -5
- package/dist/utility/chart/opra-read-access.leaf.d.ts +16 -1
- package/dist/utility/chart/opra-read-access.leaf.js +22 -0
- package/dist/utility/chart/profile-row-height.util.d.ts +49 -16
- package/dist/utility/chart/profile-row-height.util.js +74 -37
- package/dist/utility/chart/rth-session.util.d.ts +55 -20
- package/dist/utility/chart/rth-session.util.js +94 -46
- package/dist/utility/chart/session-interval.util.d.ts +2 -1
- package/dist/utility/chart/session-interval.util.js +1 -3
- package/dist/utility/chart/session-lattice.util.d.ts +150 -0
- package/dist/utility/chart/session-lattice.util.js +488 -0
- package/dist/utility/chart/trading-day.util.d.ts +40 -2
- package/dist/utility/chart/trading-day.util.js +84 -7
- package/dist/utility/chart/us-equities-session.util.d.ts +32 -11
- package/dist/utility/chart/us-equities-session.util.js +44 -15
- package/dist/utility/chart/window-geometry.leaf.d.ts +28 -7
- package/dist/utility/chart/window-geometry.leaf.js +57 -8
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +21 -14
- package/dist/utility/chart/wrun-bar-session-facts.util.js +32 -38
- package/dist/utility/chart/wrun-run-result.util.d.ts +29 -12
- package/dist/utility/chart/wrun-run-result.util.js +89 -25
- package/dist/utility/common/time.util.js +5 -4
- package/dist/utility/market-events/earnings-scope.util.d.ts +10 -5
- package/dist/utility/market-events/earnings-scope.util.js +17 -9
- package/dist/utility/market-events/market-events.util.d.ts +14 -7
- package/dist/utility/market-events/market-events.util.js +30 -17
- package/dist/utility/number-format.util.d.ts +14 -21
- package/dist/utility/number-format.util.js +38 -24
- package/dist/utility/options/option-venue-disclosure.util.d.ts +40 -6
- package/dist/utility/options/option-venue-disclosure.util.js +71 -11
- package/dist/utility/options/option-venue.util.d.ts +1 -1
- package/dist/utility/options/option-venue.util.js +1 -1
- package/dist/utility/pool-symbol.leaf.d.ts +7 -0
- package/dist/utility/pool-symbol.leaf.js +50 -5
- package/dist/utility/stocks/stock-display.util.d.ts +15 -0
- package/dist/utility/stocks/stock-display.util.js +37 -0
- package/dist/utility/symbol-selection/contract-expiry.util.js +5 -4
- package/dist/utility/v2/gate-plane.util.d.ts +6 -0
- package/dist/utility/v2/gate-plane.util.js +11 -1
- package/dist/utility/v2/gate-session-latch.util.d.ts +1 -1
- package/dist/utility/v2/gate-session-latch.util.js +3 -3
- package/dist/utility/v2/governed-tier.leaf.d.ts +17 -16
- package/dist/utility/v2/governed-tier.leaf.js +17 -16
- package/dist/utility/v2/stocks-governed.util.d.ts +5 -0
- package/dist/utility/v2/stocks-governed.util.js +14 -0
- package/dist/utility/v2/v2-enums.leaf.d.ts +13 -0
- package/dist/utility/v2/v2-enums.leaf.js +458 -0
- package/dist/utility/wrun/derived-roots.leaf.d.ts +21 -1
- package/dist/utility/wrun/derived-roots.leaf.js +27 -1
- package/dist/utility/wrun/derived-roots.util.d.ts +44 -32
- package/dist/utility/wrun/derived-roots.util.js +97 -56
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -3
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -3
- package/dist/utility/wrun/sources/lanes/option_daily.d.ts +2 -1
- package/dist/utility/wrun/sources/lanes/option_daily.js +2 -1
- package/dist/utility/wrun/sources/lanes/options_flow.d.ts +3 -0
- package/dist/utility/wrun/sources/lanes/options_flow.js +23 -5
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +3 -4
- package/dist/utility/wrun/sources/row-lane-registry.js +9 -4
- package/dist/utility/wrun/sources/row-lanes/dark_pool.d.ts +19 -0
- package/dist/utility/wrun/sources/row-lanes/dark_pool.js +104 -0
- package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
- package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.d.ts +20 -0
- package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.js +103 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -2
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +15 -13
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +49 -23
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +14 -9
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +75 -27
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +139 -82
- package/dist/utility/wrun/wrun-app-layer.leaf.d.ts +78 -0
- package/dist/utility/wrun/wrun-app-layer.leaf.js +89 -0
- package/dist/utility/wrun/wrun-bar-count.util.d.ts +11 -7
- package/dist/utility/wrun/wrun-bar-count.util.js +12 -8
- package/dist/utility/wrun/wrun-batched-kinds.leaf.d.ts +13 -0
- package/dist/utility/wrun/wrun-batched-kinds.leaf.js +18 -0
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +41 -22
- package/dist/utility/wrun/wrun-batched-marks.util.js +255 -59
- package/dist/utility/wrun/wrun-batched-readout.util.d.ts +26 -19
- package/dist/utility/wrun/wrun-batched-readout.util.js +81 -27
- package/dist/utility/wrun/wrun-book-bands.leaf.d.ts +8 -0
- package/dist/utility/wrun/wrun-book-bands.leaf.js +7 -0
- package/dist/utility/wrun/wrun-candle-equal.leaf.d.ts +19 -0
- package/dist/utility/wrun/wrun-candle-equal.leaf.js +40 -0
- package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -2
- package/dist/utility/wrun/wrun-canvases.util.js +7 -3
- package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +6 -3
- package/dist/utility/wrun/wrun-chart-context-names.util.js +8 -4
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +47 -29
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +201 -201
- package/dist/utility/wrun/wrun-child-overlay-id.util.js +2 -1
- package/dist/utility/wrun/wrun-cme-legs-note.util.d.ts +15 -0
- package/dist/utility/wrun/wrun-cme-legs-note.util.js +49 -0
- package/dist/utility/wrun/wrun-cme-root-specs.util.d.ts +38 -0
- package/dist/utility/wrun/wrun-cme-root-specs.util.js +81 -0
- package/dist/utility/wrun/wrun-coin-lane-live.util.js +3 -0
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-color-settings.util.js +32 -7
- package/dist/utility/wrun/wrun-dark-pool.util.d.ts +50 -0
- package/dist/utility/wrun/wrun-dark-pool.util.js +127 -0
- package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +67 -12
- package/dist/utility/wrun/wrun-declared-warmup.util.js +165 -13
- package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +18 -8
- package/dist/utility/wrun/wrun-draft-legend-note.util.js +57 -11
- package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +14 -10
- package/dist/utility/wrun/wrun-draft-overlay.util.js +26 -14
- package/dist/utility/wrun/wrun-earnings-facts.util.js +3 -2
- package/dist/utility/wrun/wrun-etf-funds.util.d.ts +2 -0
- package/dist/utility/wrun/wrun-etf-funds.util.js +4 -0
- package/dist/utility/wrun/wrun-held-lanes.util.js +8 -2
- package/dist/utility/wrun/wrun-history-as-of.util.d.ts +77 -0
- package/dist/utility/wrun/wrun-history-as-of.util.js +108 -0
- package/dist/utility/wrun/wrun-host.service.d.ts +64 -14
- package/dist/utility/wrun/wrun-host.service.js +137 -27
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +3 -3
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +12 -2
- package/dist/utility/wrun/wrun-inert-legend.util.d.ts +13 -0
- package/dist/utility/wrun/wrun-inert-legend.util.js +31 -3
- package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +7 -5
- package/dist/utility/wrun/wrun-input-requirements.leaf.js +16 -6
- package/dist/utility/wrun/wrun-install-pacer.util.d.ts +26 -0
- package/dist/utility/wrun/wrun-install-pacer.util.js +145 -0
- package/dist/utility/wrun/wrun-kit-refusal-stages.types.d.ts +22 -0
- package/dist/utility/wrun/wrun-kit-refusal-stages.types.js +1 -0
- package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +12 -5
- package/dist/utility/wrun/wrun-lane-refusal.leaf.js +23 -5
- package/dist/utility/wrun/wrun-lane-warmup.util.js +22 -4
- package/dist/utility/wrun/wrun-leg-close.util.d.ts +6 -5
- package/dist/utility/wrun/wrun-leg-close.util.js +11 -9
- package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +3 -1
- package/dist/utility/wrun/wrun-leg-fetch.util.js +9 -2
- package/dist/utility/wrun/wrun-levels-child.util.d.ts +2 -0
- package/dist/utility/wrun/wrun-levels-child.util.js +6 -0
- package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -0
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +15 -6
- package/dist/utility/wrun/wrun-live-intake.util.js +167 -47
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +52 -8
- package/dist/utility/wrun/wrun-live-tick.util.js +648 -97
- package/dist/utility/wrun/wrun-market-facts.util.d.ts +16 -2
- package/dist/utility/wrun/wrun-market-facts.util.js +32 -3
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +27 -27
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +28 -16
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +34 -5
- package/dist/utility/wrun/wrun-oi-lane.util.d.ts +10 -7
- package/dist/utility/wrun/wrun-oi-lane.util.js +16 -10
- package/dist/utility/wrun/wrun-option-strike-flow.util.js +1 -1
- package/dist/utility/wrun/wrun-option-views.util.d.ts +2 -2
- package/dist/utility/wrun/wrun-option-views.util.js +5 -2
- package/dist/utility/wrun/wrun-options-flow-underlying.leaf.d.ts +5 -0
- package/dist/utility/wrun/wrun-options-flow-underlying.leaf.js +16 -0
- package/dist/utility/wrun/wrun-options-stop.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-options-stop.util.js +6 -4
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +75 -11
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +176 -43
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +20 -10
- package/dist/utility/wrun/wrun-overlay-park.util.d.ts +84 -0
- package/dist/utility/wrun/wrun-overlay-park.util.js +135 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +37 -4
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +26 -14
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +239 -24
- package/dist/utility/wrun/wrun-overlay-run.util.js +2204 -405
- package/dist/utility/wrun/wrun-pack.util.d.ts +8 -5
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-panel-mount.util.js +20 -14
- package/dist/utility/wrun/wrun-panel-style.util.d.ts +4 -2
- package/dist/utility/wrun/wrun-panel-style.util.js +3 -2
- package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +7 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.js +18 -4
- package/dist/utility/wrun/wrun-pin-venues.util.d.ts +26 -17
- package/dist/utility/wrun/wrun-pin-venues.util.js +43 -36
- package/dist/utility/wrun/wrun-pinned-lanes.util.d.ts +58 -0
- package/dist/utility/wrun/wrun-pinned-lanes.util.js +72 -0
- package/dist/utility/wrun/wrun-prefix-cohort.util.js +2 -1
- package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +22 -9
- package/dist/utility/wrun/wrun-prefix-lanes.util.js +145 -26
- package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +29 -0
- package/dist/utility/wrun/wrun-prefix-proof.util.js +23 -5
- package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +9 -1
- package/dist/utility/wrun/wrun-refusal-surface.util.js +15 -1
- package/dist/utility/wrun/wrun-refusal.util.d.ts +19 -1
- package/dist/utility/wrun/wrun-refusal.util.js +103 -16
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +20 -6
- package/dist/utility/wrun/wrun-registry-errors.util.js +20 -6
- package/dist/utility/wrun/wrun-replay-rows.util.js +6 -10
- package/dist/utility/wrun/wrun-run-health.util.d.ts +89 -2
- package/dist/utility/wrun/wrun-run-health.util.js +204 -1
- package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +2 -2
- package/dist/utility/wrun/wrun-run-interval-session.util.js +2 -2
- package/dist/utility/wrun/wrun-run-interval.util.d.ts +9 -8
- package/dist/utility/wrun/wrun-run-interval.util.js +13 -11
- package/dist/utility/wrun/wrun-sandbox-row-source.js +5 -2
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +13 -3
- package/dist/utility/wrun/wrun-script-inputs.util.js +51 -13
- package/dist/utility/wrun/wrun-session-composition.util.d.ts +81 -0
- package/dist/utility/wrun/wrun-session-composition.util.js +169 -0
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +10 -7
- package/dist/utility/wrun/wrun-setting-words.util.js +25 -7
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +94 -28
- package/dist/utility/wrun/wrun-source-rows.util.js +738 -93
- package/dist/utility/wrun/wrun-stream-clock.util.d.ts +45 -0
- package/dist/utility/wrun/wrun-stream-clock.util.js +108 -0
- package/dist/utility/wrun/wrun-tape-coins.util.d.ts +116 -0
- package/dist/utility/wrun/wrun-tape-coins.util.js +110 -0
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +62 -32
- package/dist/utility/wrun/wrun-tape-source.util.js +72 -34
- package/dist/utility/wrun/wrun-tier-grid.util.d.ts +13 -5
- package/dist/utility/wrun/wrun-tier-grid.util.js +23 -13
- package/dist/utility/wrun/wrun-tpo-rows.util.js +2 -1
- package/dist/utility/wrun/wrun-trades-lane.util.d.ts +73 -0
- package/dist/utility/wrun/wrun-trades-lane.util.js +82 -0
- package/dist/utility/wrun/wrun-twin-compute-inputs.util.d.ts +5 -0
- package/dist/utility/wrun/wrun-twin-compute-inputs.util.js +9 -2
- package/dist/utility/wrun/wrun-visibility-table.d.ts +13 -0
- package/dist/utility/wrun/wrun-visibility-table.js +9 -0
- package/dist/utility/wrun/wrun-volume-profile.util.js +44 -32
- package/dist/utils/replay/replay-buffer-math.d.ts +16 -6
- package/dist/utils/replay/replay-buffer-math.js +60 -30
- package/dist/workers/constants/socket-slots.d.ts +11 -7
- package/dist/workers/constants/socket-slots.js +6 -5
- package/package.json +11 -11
|
@@ -1,343 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The CME session lattice
|
|
3
|
-
*
|
|
4
|
-
* cme.go
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* - 3d: a year's trade dates in threes from its first (`DayGroupStart`), the
|
|
19
|
-
* way TradingView groups them, labeled by the first, so Thu-Fri-Mon is one
|
|
20
|
-
* bar and a holiday never leaves one short;
|
|
21
|
-
* - 1w: the Monday of the trade-date week, 00:00Z (Sunday's open starts it);
|
|
22
|
-
* - 1M 3M 6M 1Y: the months of the trade dates, stamped on the first month's
|
|
23
|
-
* 1st at 00:00Z (29dda19, intervals part 4); a weekend day joins the Friday
|
|
24
|
-
* before, so a month opens at the 17:00 Chicago open before its first trade
|
|
25
|
-
* date.
|
|
26
|
-
*
|
|
27
|
-
* The rollup covers explicit CME-group plans only (every exchange CME, CBOT,
|
|
28
|
-
* NYMEX or COMEX) for TRADE_AGG, TRADE_SIDE_AGNOSTIC_AGG, and the per-symbol
|
|
29
|
-
* VOLUME_PROFILE_AGG / BLOCK_BOOK_SNAPSHOT_AGG; open interest, settlement and
|
|
30
|
-
* coin-aggregated series stay on UTC buckets. A live writer that floored CME
|
|
31
|
-
* frames on the UTC grid instead split the forming bar (a 04:00 ET candle
|
|
32
|
-
* beside the 02:00 ET one) and titan dropped the frames keyed before it.
|
|
33
|
-
*
|
|
34
|
-
* Pure and worker-safe: Intl only, no dayjs.
|
|
35
|
-
*/
|
|
36
|
-
import { Intervals } from '../../constants/interval.constants.js';
|
|
37
|
-
import { barEndMs, calendarBarStartMs, calendarMonthsOfMs } from './calendar-interval.util.js';
|
|
38
|
-
import { cmeDayGroupStartMs, cmeTradeDateOnOrAfter, cmeTradeDateOnOrBefore, isCmeTradeDate, } from './cme-trade-calendar.util.js';
|
|
39
|
-
const MINUTE_MS = 60_000;
|
|
40
|
-
const HOUR_MS = 3_600_000;
|
|
41
|
-
const DAY_MS = 86_400_000;
|
|
42
|
-
const ONE_DAY_MS = Intervals.map_unit['1d'];
|
|
43
|
-
const THREE_DAYS_MS = Intervals.map_unit['3d'];
|
|
44
|
-
const ONE_WEEK_MS = Intervals.map_unit['1w'];
|
|
45
|
-
/** The intraday widths the gateway buckets on the lattice. */
|
|
46
|
-
const INTRADAY_LATTICE_MS = new Set(['2m', '3m', '10m', '45m', '2h', '4h', '6h', '8h', '12h'].map((label) => Intervals.map_unit[label]));
|
|
47
|
-
const CME_SESSION_TIME_ZONE = 'America/Chicago';
|
|
48
|
-
/** The session open on the Chicago wall clock (gateway `cmeSessionOpenHour`). */
|
|
49
|
-
const CME_SESSION_OPEN_HOUR = 17;
|
|
50
|
-
/** The session open's offset into a width: 17:00 sits on the lattice (4h: 01:00, 05:00, ... 21:00). */
|
|
51
|
-
const openOffsetMs = (widthMs) => (CME_SESSION_OPEN_HOUR * HOUR_MS) % widthMs;
|
|
52
|
-
/** The source tier the gateway re-buckets for a width (`sessionTier`): the coarsest dividing width and offset. */
|
|
53
|
-
function sourceStepMs(widthMs) {
|
|
54
|
-
const offsetMs = openOffsetMs(widthMs);
|
|
55
|
-
for (const stepMs of [HOUR_MS, 15 * MINUTE_MS, 5 * MINUTE_MS]) {
|
|
56
|
-
if (widthMs % stepMs === 0 && offsetMs % stepMs === 0)
|
|
57
|
-
return stepMs;
|
|
58
|
-
}
|
|
59
|
-
return MINUTE_MS;
|
|
60
|
-
}
|
|
61
|
-
/** Central Standard Time. Postgres reads a Chicago wall time that occurs twice or never as standard time. */
|
|
62
|
-
const CHICAGO_STANDARD_OFFSET_MS = -6 * HOUR_MS;
|
|
63
|
-
const CHICAGO_DAYLIGHT_OFFSET_MS = -5 * HOUR_MS;
|
|
64
|
-
/** The venues the gateway rolls up (`isCMEGroupExchange`); GLOBEX is a metadata alias with no gate mapping. */
|
|
65
|
-
const CME_SESSION_LATTICE_EXCHANGES = new Set(['CME', 'CBOT', 'NYMEX', 'COMEX']);
|
|
2
|
+
* The CME session lattice by its CME names: the CME Group profile of
|
|
3
|
+
* session-lattice.util (the client mirror of tsdb-gateway's `cmeSession`,
|
|
4
|
+
* pkg/tsdb/selects/cme.go: 17:00 America/Chicago on the CME trade calendar,
|
|
5
|
+
* for CME, CBOT, NYMEX and COMEX). The lattice math, the forex profile and
|
|
6
|
+
* the venue-generic API (`sessionLatticeOf`, `sessionLatticeBucketMs`,
|
|
7
|
+
* `sessionLatticeBarEndMs`, `sessionLatticeBarOpenMs`) live there; a reader
|
|
8
|
+
* that keys a SERIES' own market on its lattice reads the generic API
|
|
9
|
+
* (live-bucket.util `venueSessionLatticeBucketMs`), never this module, so a
|
|
10
|
+
* venue the gateway adds to its profiles needs no new call site. These names
|
|
11
|
+
* stay for the readers that mean CME Group itself (the CME-underlying option
|
|
12
|
+
* anchors, the per-order tape floor, the wrun host ABI) and for the kit's
|
|
13
|
+
* host entry, which exports the same names.
|
|
14
|
+
*/
|
|
15
|
+
import { CME_SESSION_LATTICE, isSessionLatticeIntervalMs, sessionLatticeBarEndMs, sessionLatticeBarOpenMs, sessionLatticeBucketMs, sessionLatticeOf, } from './session-lattice.util.js';
|
|
16
|
+
export { sessionGridStartMs } from './session-lattice.util.js';
|
|
17
|
+
/** The venues the gateway rolls up on the CME lattice (`isCMEGroupExchange`); GLOBEX is a metadata alias with no gate mapping. */
|
|
66
18
|
export function isCmeSessionLatticeExchange(exchange) {
|
|
67
|
-
return
|
|
19
|
+
return sessionLatticeOf(exchange) === CME_SESSION_LATTICE;
|
|
68
20
|
}
|
|
69
|
-
/** The intervals the gateway serves on the
|
|
21
|
+
/** The intervals the gateway serves on the CME lattice: the intraday widths, 1d, 3d, 1w and the calendar rungs. */
|
|
70
22
|
export function isCmeSessionLatticeIntervalMs(intervalMs) {
|
|
71
|
-
return (
|
|
72
|
-
(INTRADAY_LATTICE_MS.has(intervalMs) ||
|
|
73
|
-
intervalMs === ONE_DAY_MS ||
|
|
74
|
-
intervalMs === THREE_DAYS_MS ||
|
|
75
|
-
intervalMs === ONE_WEEK_MS ||
|
|
76
|
-
calendarMonthsOfMs(intervalMs) !== null));
|
|
77
|
-
}
|
|
78
|
-
const floorTo = (value, step) => value - (((value % step) + step) % step);
|
|
79
|
-
let chicagoFormatter = null;
|
|
80
|
-
function getChicagoFormatter() {
|
|
81
|
-
if (!chicagoFormatter) {
|
|
82
|
-
chicagoFormatter = new Intl.DateTimeFormat('en-US', {
|
|
83
|
-
timeZone: CME_SESSION_TIME_ZONE,
|
|
84
|
-
year: 'numeric',
|
|
85
|
-
month: '2-digit',
|
|
86
|
-
day: '2-digit',
|
|
87
|
-
hour: '2-digit',
|
|
88
|
-
minute: '2-digit',
|
|
89
|
-
second: '2-digit',
|
|
90
|
-
hourCycle: 'h23',
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
return chicagoFormatter;
|
|
94
|
-
}
|
|
95
|
-
function intlChicagoOffsetMs(utcMs) {
|
|
96
|
-
const wall = { year: 0, month: 1, day: 1, hour: 0, minute: 0, second: 0 };
|
|
97
|
-
for (const part of getChicagoFormatter().formatToParts(utcMs)) {
|
|
98
|
-
if (part.type in wall)
|
|
99
|
-
wall[part.type] = Number(part.value);
|
|
100
|
-
}
|
|
101
|
-
return Date.UTC(wall.year, wall.month - 1, wall.day, wall.hour % 24, wall.minute, wall.second) - utcMs;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Chicago's UTC offset at `utcMs`. US transitions happen at 02:00 local, a
|
|
105
|
-
* whole UTC hour, at most once per UTC day, so a day whose first and last
|
|
106
|
-
* hours agree holds one offset throughout: it caches per day (a CVD candle
|
|
107
|
-
* commit buckets years of rows, the live path one frame at a time), and only
|
|
108
|
-
* a transition day falls back to per-hour reads. NaN marks a transition day.
|
|
109
|
-
*/
|
|
110
|
-
const offsetByUtcDay = new Map();
|
|
111
|
-
const offsetByUtcHour = new Map();
|
|
112
|
-
const OFFSET_CACHE_MAX = 8192;
|
|
113
|
-
function cacheOffset(cache, key, offset) {
|
|
114
|
-
if (cache.size >= OFFSET_CACHE_MAX)
|
|
115
|
-
cache.clear();
|
|
116
|
-
cache.set(key, offset);
|
|
117
|
-
}
|
|
118
|
-
function chicagoOffsetMs(utcMs) {
|
|
119
|
-
const dayMs = floorTo(utcMs, DAY_MS);
|
|
120
|
-
let dayOffset = offsetByUtcDay.get(dayMs);
|
|
121
|
-
if (dayOffset === undefined) {
|
|
122
|
-
const first = intlChicagoOffsetMs(dayMs);
|
|
123
|
-
dayOffset = first === intlChicagoOffsetMs(dayMs + 23 * HOUR_MS) ? first : Number.NaN;
|
|
124
|
-
cacheOffset(offsetByUtcDay, dayMs, dayOffset);
|
|
125
|
-
}
|
|
126
|
-
if (!Number.isNaN(dayOffset))
|
|
127
|
-
return dayOffset;
|
|
128
|
-
const hourMs = floorTo(utcMs, HOUR_MS);
|
|
129
|
-
let hourOffset = offsetByUtcHour.get(hourMs);
|
|
130
|
-
if (hourOffset === undefined) {
|
|
131
|
-
hourOffset = intlChicagoOffsetMs(hourMs);
|
|
132
|
-
cacheOffset(offsetByUtcHour, hourMs, hourOffset);
|
|
133
|
-
}
|
|
134
|
-
return hourOffset;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* The instant a Chicago wall time (expressed as if it were UTC) names, read
|
|
138
|
-
* the way Postgres does (DetermineTimeZoneOffset): a wall time that occurs
|
|
139
|
-
* twice (fall back) or never (spring forward) reads as standard time.
|
|
140
|
-
*/
|
|
141
|
-
function chicagoWallToUtcMs(wallAsUtcMs) {
|
|
142
|
-
const standard = wallAsUtcMs - CHICAGO_STANDARD_OFFSET_MS;
|
|
143
|
-
if (chicagoOffsetMs(standard) === CHICAGO_STANDARD_OFFSET_MS)
|
|
144
|
-
return standard;
|
|
145
|
-
const daylight = wallAsUtcMs - CHICAGO_DAYLIGHT_OFFSET_MS;
|
|
146
|
-
if (chicagoOffsetMs(daylight) === CHICAGO_DAYLIGHT_OFFSET_MS)
|
|
147
|
-
return daylight;
|
|
148
|
-
return standard;
|
|
149
|
-
}
|
|
150
|
-
/** The Chicago wall clock (as if it were UTC) of the gateway's source row: the 1h bucket holding `tsMs`. */
|
|
151
|
-
function chicagoWallOfSourceRow(tsMs) {
|
|
152
|
-
const rowMs = floorTo(tsMs, HOUR_MS);
|
|
153
|
-
return rowMs + chicagoOffsetMs(rowMs);
|
|
154
|
-
}
|
|
155
|
-
/** The calendar date of the session close `tsMs` trades toward (gateway `cmeSessionDay`): it flips at the 17:00 open. */
|
|
156
|
-
function sessionDayMs(tsMs) {
|
|
157
|
-
return floorTo(chicagoWallOfSourceRow(tsMs) + (24 - CME_SESSION_OPEN_HOUR) * HOUR_MS, DAY_MS);
|
|
158
|
-
}
|
|
159
|
-
const isWeekendDay = (dayMs) => {
|
|
160
|
-
const weekday = new Date(dayMs).getUTCDay();
|
|
161
|
-
return weekday === 0 || weekday === 6;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* The trade date holding `tsMs`, stamped at 00:00Z (gateway
|
|
165
|
-
* `cmeCurrentSessionLabel`): a weekday holiday's session moves to the next
|
|
166
|
-
* trade date, a weekend day keeps its own date.
|
|
167
|
-
*/
|
|
168
|
-
function tradeDateLabelMs(tsMs) {
|
|
169
|
-
const day = sessionDayMs(tsMs);
|
|
170
|
-
return isWeekendDay(day) ? day : cmeTradeDateOnOrAfter(day);
|
|
171
|
-
}
|
|
172
|
-
/** The 3d bar's first trade date: a weekend day joins the previous trade date's bar. */
|
|
173
|
-
function threeDayLabelMs(tsMs) {
|
|
174
|
-
const day = sessionDayMs(tsMs);
|
|
175
|
-
return cmeDayGroupStartMs(isWeekendDay(day) ? cmeTradeDateOnOrBefore(day) : cmeTradeDateOnOrAfter(day), 3);
|
|
23
|
+
return isSessionLatticeIntervalMs(CME_SESSION_LATTICE, intervalMs);
|
|
176
24
|
}
|
|
177
|
-
/** The
|
|
178
|
-
function firstSessionDayMs(labelMs) {
|
|
179
|
-
let day = labelMs;
|
|
180
|
-
for (let prev = day - DAY_MS; !isWeekendDay(prev) && !isCmeTradeDate(prev); prev -= DAY_MS)
|
|
181
|
-
day = prev;
|
|
182
|
-
return day;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* The calendar bar holding `tsMs` (gateway `cmeSessionBucketExpression`): the months of its trade
|
|
186
|
-
* date, a weekend day counted on the Friday before it, so a stale weekend book never opens a month.
|
|
187
|
-
*/
|
|
188
|
-
function calendarLabelMs(tsMs, months) {
|
|
189
|
-
const day = sessionDayMs(tsMs);
|
|
190
|
-
const weekday = new Date(day).getUTCDay();
|
|
191
|
-
const tradeDateMs = weekday === 6 ? day - DAY_MS : weekday === 0 ? day - 2 * DAY_MS : cmeTradeDateOnOrAfter(day);
|
|
192
|
-
return calendarBarStartMs(tradeDateMs, months);
|
|
193
|
-
}
|
|
194
|
-
/** The first session day booked to the calendar bar stamped `labelMs`: the first weekday after the last trade date
|
|
195
|
-
* before it (a holiday just before the month opens with it, as New Year's Day opens January). */
|
|
196
|
-
function firstCalendarSessionDayMs(labelMs) {
|
|
197
|
-
let day = cmeTradeDateOnOrBefore(labelMs - DAY_MS) + DAY_MS;
|
|
198
|
-
while (isWeekendDay(day))
|
|
199
|
-
day += DAY_MS;
|
|
200
|
-
return day;
|
|
201
|
-
}
|
|
202
|
-
/** The 17:00 Chicago open that starts the session day `dayMs`, on the calendar day before it. */
|
|
203
|
-
const sessionOpenMs = (dayMs) => chicagoWallToUtcMs(dayMs - DAY_MS + CME_SESSION_OPEN_HOUR * HOUR_MS);
|
|
204
|
-
/**
|
|
205
|
-
* The gateway's intraday bucket start for the source row holding `tsMs`, in
|
|
206
|
-
* the order TimescaleDB runs `time_bucket` with a timezone and an offset
|
|
207
|
-
* (src/time_bucket.c `ts_timestamptz_timezone_bucket`, 2.25+ #9129): take
|
|
208
|
-
* the offset off in UTC, bucket the Chicago wall clock from local midnight,
|
|
209
|
-
* read the start back, step back while it lands after the shifted instant
|
|
210
|
-
* (the fall-back guard), put the offset back in UTC. On the fall-back
|
|
211
|
-
* Sunday the 01:00 4h bar spans five real hours from 06:00Z; only CME's 24/7
|
|
212
|
-
* crypto products trade then. Every lattice width divides a day, so flooring
|
|
213
|
-
* the wall clock from the epoch is flooring it from local midnight.
|
|
214
|
-
*/
|
|
215
|
-
function intradayBucketStartMs(tsMs, widthMs) {
|
|
216
|
-
const offsetMs = openOffsetMs(widthMs);
|
|
217
|
-
const shifted = floorTo(tsMs, sourceStepMs(widthMs)) - offsetMs;
|
|
218
|
-
let start = chicagoWallToUtcMs(floorTo(shifted + chicagoOffsetMs(shifted), widthMs));
|
|
219
|
-
while (start > shifted)
|
|
220
|
-
start -= widthMs;
|
|
221
|
-
return start + offsetMs;
|
|
222
|
-
}
|
|
223
|
-
const SESSION_GRID_ORIGIN_MS = Date.UTC(2000, 0, 3);
|
|
224
|
-
const SESSION_GRID_DAYS = 3;
|
|
225
|
-
/**
|
|
226
|
-
* The first trade date (00:00Z) of the 3d session bar holding the trade date
|
|
227
|
-
* `dayMs` (gateway `sessionGridStart`, session_grid.go): trade dates are
|
|
228
|
-
* counted in weekdays from 2000-01-03, a Monday, three to a bar; a weekend
|
|
229
|
-
* date counts as the Friday before it. The regular US equities session only
|
|
230
|
-
* (the gateway's NYSE calendar is not wired yet); CME rides the trade
|
|
231
|
-
* calendar, every other market's 3d is the calendar floor.
|
|
232
|
-
*/
|
|
233
|
-
export function sessionGridStartMs(dayMs) {
|
|
234
|
-
const days = Math.floor((dayMs - SESSION_GRID_ORIGIN_MS) / DAY_MS);
|
|
235
|
-
const weeks = Math.floor(days / 7);
|
|
236
|
-
const weekday = 5 * weeks + Math.min(days - 7 * weeks, 4);
|
|
237
|
-
const start = SESSION_GRID_DAYS * Math.floor(weekday / SESSION_GRID_DAYS);
|
|
238
|
-
const startWeeks = Math.floor(start / 5);
|
|
239
|
-
return SESSION_GRID_ORIGIN_MS + (7 * startWeeks + start - 5 * startWeeks) * DAY_MS;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* The bar key the gateway stamps for the CME session bar holding `tsMs`: the
|
|
243
|
-
* intraday bucket start, or the trade-date label (00:00Z of the trade date,
|
|
244
|
-
* not the 17:00 open instant) at 1d, the first trade date of its 3d group,
|
|
245
|
-
* the Monday of its week at 1w, and the 1st of its trade date's month,
|
|
246
|
-
* quarter, half or year at a calendar length. Null when the interval is not a
|
|
247
|
-
* session-lattice interval or the input is not a number.
|
|
248
|
-
*/
|
|
25
|
+
/** The bar key the gateway stamps for the CME session bar holding `tsMs` (`sessionLatticeBucketMs` on the CME profile). */
|
|
249
26
|
export function cmeSessionBucketMs(tsMs, intervalMs) {
|
|
250
|
-
|
|
251
|
-
return null;
|
|
252
|
-
if (INTRADAY_LATTICE_MS.has(intervalMs))
|
|
253
|
-
return intradayBucketStartMs(tsMs, intervalMs);
|
|
254
|
-
if (intervalMs === ONE_DAY_MS)
|
|
255
|
-
return tradeDateLabelMs(tsMs);
|
|
256
|
-
if (intervalMs === THREE_DAYS_MS)
|
|
257
|
-
return threeDayLabelMs(tsMs);
|
|
258
|
-
if (intervalMs === ONE_WEEK_MS) {
|
|
259
|
-
const dayMs = tradeDateLabelMs(tsMs);
|
|
260
|
-
// date_trunc('week'): ISO weeks start Monday; 1970-01-01 was a Thursday (ISO index 3).
|
|
261
|
-
const isoWeekday = (((Math.floor(dayMs / DAY_MS) + 3) % 7) + 7) % 7;
|
|
262
|
-
return dayMs - isoWeekday * DAY_MS;
|
|
263
|
-
}
|
|
264
|
-
const months = calendarMonthsOfMs(intervalMs);
|
|
265
|
-
return months === null ? null : calendarLabelMs(tsMs, months);
|
|
27
|
+
return sessionLatticeBucketMs(CME_SESSION_LATTICE, tsMs, intervalMs);
|
|
266
28
|
}
|
|
267
|
-
/**
|
|
268
|
-
const barEndCache = new Map();
|
|
269
|
-
const BAR_END_CACHE_MAX = 8192;
|
|
270
|
-
/** The longest a daily-class bar can run past its stamp: a week and the holidays around it. */
|
|
271
|
-
const DAILY_BAR_SCAN_MS = 21 * DAY_MS;
|
|
272
|
-
/**
|
|
273
|
-
* The instant the CME session bar stamped `barMs` (a key `cmeSessionBucketMs` stamps) stops
|
|
274
|
-
* taking source rows: the end of the last source row the lattice books to it, for a reader that
|
|
275
|
-
* must never take a bar before it closes (a pinned wrun leg). At 1d, 3d and 1w the key only
|
|
276
|
-
* advances with the session day, so the bar ends at the first source row booked elsewhere: a 3d
|
|
277
|
-
* bar runs to the 17:00 Chicago open of the next group's first session, a weekend or a weekday
|
|
278
|
-
* holiday inside it (Thursday, Friday and Monday close at Monday's 17:00), and a 1d bar to the
|
|
279
|
-
* 17:00 open that starts the next session day. An intraday bar ends at its stamp plus its width,
|
|
280
|
-
* except across a DST change: on the fall-back Sunday a bucket reaching the repeated hour holds
|
|
281
|
-
* its rows an hour longer (the 01:00 4h bar runs five real hours), and the 45m lattice books
|
|
282
|
-
* rows of the repeated hour back to an earlier stamp, so the end is the end of the LAST row
|
|
283
|
-
* booked to it within its width and an hour. A calendar bar runs to the next one's open (July 2026
|
|
284
|
-
* to Sunday 8/2 at 17:00 CDT). Null off the lattice intervals, or for a stamp the lattice books no
|
|
285
|
-
* row to.
|
|
286
|
-
*/
|
|
29
|
+
/** When the CME session bar stamped `barMs` stops taking source rows (`sessionLatticeBarEndMs` on the CME profile). */
|
|
287
30
|
export function cmeSessionBarEndMs(barMs, intervalMs) {
|
|
288
|
-
|
|
289
|
-
return null;
|
|
290
|
-
const cacheKey = `${intervalMs}:${barMs}`;
|
|
291
|
-
const cached = barEndCache.get(cacheKey);
|
|
292
|
-
if (cached !== undefined)
|
|
293
|
-
return cached;
|
|
294
|
-
let end = null;
|
|
295
|
-
const months = calendarMonthsOfMs(intervalMs);
|
|
296
|
-
if (months !== null) {
|
|
297
|
-
if (calendarBarStartMs(barMs, months) === barMs) {
|
|
298
|
-
end = sessionOpenMs(firstCalendarSessionDayMs(barEndMs(barMs, intervalMs)));
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
else if (INTRADAY_LATTICE_MS.has(intervalMs)) {
|
|
302
|
-
const windowEndMs = barMs + intervalMs + HOUR_MS;
|
|
303
|
-
if (chicagoOffsetMs(barMs - intervalMs - HOUR_MS) === chicagoOffsetMs(windowEndMs)) {
|
|
304
|
-
// No DST change within reach: the lattice is a plain run of widths here. (A spring-forward
|
|
305
|
-
// change just before the stamp shortens the bar, so the window reaches back a width too.)
|
|
306
|
-
end = cmeSessionBucketMs(barMs, intervalMs) === barMs ? barMs + intervalMs : null;
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
const stepMs = sourceStepMs(intervalMs);
|
|
310
|
-
for (let rowMs = barMs; rowMs < windowEndMs; rowMs += stepMs) {
|
|
311
|
-
if (cmeSessionBucketMs(rowMs, intervalMs) === barMs)
|
|
312
|
-
end = rowMs + stepMs;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
else if (cmeSessionBucketMs(barMs, intervalMs) === barMs) {
|
|
317
|
-
let rowMs = barMs + HOUR_MS;
|
|
318
|
-
while (rowMs < barMs + DAILY_BAR_SCAN_MS && cmeSessionBucketMs(rowMs, intervalMs) === barMs)
|
|
319
|
-
rowMs += HOUR_MS;
|
|
320
|
-
end = rowMs < barMs + DAILY_BAR_SCAN_MS ? rowMs : null;
|
|
321
|
-
}
|
|
322
|
-
if (barEndCache.size >= BAR_END_CACHE_MAX)
|
|
323
|
-
barEndCache.clear();
|
|
324
|
-
barEndCache.set(cacheKey, end);
|
|
325
|
-
return end;
|
|
31
|
+
return sessionLatticeBarEndMs(CME_SESSION_LATTICE, barMs, intervalMs);
|
|
326
32
|
}
|
|
327
|
-
/**
|
|
328
|
-
* The instant the CME session bar holding `tsMs` opens, for a fetch window
|
|
329
|
-
* that must cover the whole bar: the intraday bucket start, or the 17:00
|
|
330
|
-
* Chicago open before the trade date (1d), the 3d group's first trade date
|
|
331
|
-
* and the week's Monday (1w), where the bar key is a 00:00Z label that runs
|
|
332
|
-
* ahead of the open, and a calendar bar's first trade date (August 2026 opens
|
|
333
|
-
* Sunday 8/2). A 1d or 3d bar after a weekday holiday opens with the holiday's
|
|
334
|
-
* session (9/8 opens Sunday 9/6). Null off the lattice intervals.
|
|
335
|
-
*/
|
|
33
|
+
/** When the CME session bar holding `tsMs` opens (`sessionLatticeBarOpenMs` on the CME profile). */
|
|
336
34
|
export function cmeSessionBarOpenMs(tsMs, intervalMs) {
|
|
337
|
-
|
|
338
|
-
if (bucketMs === null || INTRADAY_LATTICE_MS.has(intervalMs))
|
|
339
|
-
return bucketMs;
|
|
340
|
-
if (calendarMonthsOfMs(intervalMs) !== null)
|
|
341
|
-
return sessionOpenMs(firstCalendarSessionDayMs(bucketMs));
|
|
342
|
-
return sessionOpenMs(intervalMs === ONE_WEEK_MS ? bucketMs : firstSessionDayMs(bucketMs));
|
|
35
|
+
return sessionLatticeBarOpenMs(CME_SESSION_LATTICE, tsMs, intervalMs);
|
|
343
36
|
}
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
//
|
|
13
13
|
// PARITY CONTRACT: the per-family constants below and the era math are pinned
|
|
14
14
|
// by src/utility/chart/__fixtures__/continuous-golden/continuous_golden.json,
|
|
15
|
-
// whose byte-identical
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
// (gateway) and the live lead (
|
|
15
|
+
// whose byte-identical twins live in the tsdb-gateway repo (asserted by its Go
|
|
16
|
+
// tests) and in the mobile app repo (asserted by its jest test). Never edit
|
|
17
|
+
// the fixture here alone and never let these constants drift from it: change
|
|
18
|
+
// all three repos in lockstep or the splice (gateway) and the live lead (web,
|
|
19
|
+
// app) disagree at the roll boundary.
|
|
19
20
|
//
|
|
20
21
|
// Worker-safe and pure: no Vue, no stores, no i18n. The only runtime import is
|
|
21
22
|
// the existing contract-code parser (shared regex, one source of truth for
|
|
@@ -37,7 +38,7 @@ export const CONTINUOUS_FAMILIES = {
|
|
|
37
38
|
cycle: ['H', 'M', 'U', 'Z'],
|
|
38
39
|
roots: ['ES', 'NQ', 'RTY', 'YM', 'MES', 'MNQ', 'M2K', 'MYM'],
|
|
39
40
|
},
|
|
40
|
-
fx: { nBusinessDays: 5, cycle: ['H', 'M', 'U', 'Z'], roots: ['6E', '6B', '6J', '6C'] },
|
|
41
|
+
fx: { nBusinessDays: 5, cycle: ['H', 'M', 'U', 'Z'], roots: ['6E', '6B', '6J', '6C', '6A', '6S', '6N'] },
|
|
41
42
|
treasuries: { nBusinessDays: 20, cycle: ['H', 'M', 'U', 'Z'], roots: ['ZT', 'ZF', 'ZN', 'TN', 'ZB', 'UB'] },
|
|
42
43
|
energy: { nBusinessDays: 3, cycle: ALL_MONTHS, roots: ['CL', 'MCL', 'NG', 'RB', 'HO', 'BZ'] },
|
|
43
44
|
metals: {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chart's display offset as the package's readers take it, with no import (docs/features/chart/time-axis-clock.md,
|
|
3
|
+
* "Display time zone"): one fixed shift (a fixed UTC+N row, UTC), or the shift at each instant (a zone that moves its
|
|
4
|
+
* clock). Web's one reader builds it (`chartDisplayOffset`, src/utility/chart/chart-display-timezone.util.ts, over the
|
|
5
|
+
* shared zone clock: one Intl reading per zone per UTC day), and the package's day keys, calendar windows, panel time
|
|
6
|
+
* labels and time words read it at each instant they print or group, never one offset read now for every instant.
|
|
7
|
+
* The one implementation of this algebra: web's display-timezone-offset.util re-exports it (the package never imports
|
|
8
|
+
* src/), and tests/structure/zone-offset-one-clock.spec.ts fails on a second declaration.
|
|
9
|
+
*/
|
|
10
|
+
/** A display offset in ms east of UTC: one fixed shift, or the shift at each instant (a zone that moves its clock). */
|
|
11
|
+
export type DisplayOffset = number | ((ms: number) => number);
|
|
12
|
+
/** A display offset read at one instant. */
|
|
13
|
+
export declare const displayOffsetAt: (offset: DisplayOffset, ms: number) => number;
|
|
14
|
+
/** An instant's wall clock in the display zone, as a UTC-shaped epoch: read it with UTC getters or `timeZone: 'UTC'`. */
|
|
15
|
+
export declare const displayWallMs: (offset: DisplayOffset, ms: number) => number;
|
|
16
|
+
/**
|
|
17
|
+
* The instant a display wall time names (the inverse of `displayWallMs`), on the wall time's own offset. A wall time
|
|
18
|
+
* the clock repeats (the hour a fall change repeats) names its first pass, or with `referenceMs` (the instant being
|
|
19
|
+
* edited) the pass on the reference's own offset: a field showing a point in the second pass reads back to that point,
|
|
20
|
+
* and a time typed inside that hour stays on its pass. One the clock skips (the hour a spring change skips, a midnight
|
|
21
|
+
* a zone jumps over) names the instant its earlier offset gives, past the jump: a zone day whose midnight is skipped
|
|
22
|
+
* starts where its clock jumps.
|
|
23
|
+
*/
|
|
24
|
+
export declare function displayWallToUtcMs(offset: DisplayOffset, wallMs: number, referenceMs?: number): number;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chart's display offset as the package's readers take it, with no import (docs/features/chart/time-axis-clock.md,
|
|
3
|
+
* "Display time zone"): one fixed shift (a fixed UTC+N row, UTC), or the shift at each instant (a zone that moves its
|
|
4
|
+
* clock). Web's one reader builds it (`chartDisplayOffset`, src/utility/chart/chart-display-timezone.util.ts, over the
|
|
5
|
+
* shared zone clock: one Intl reading per zone per UTC day), and the package's day keys, calendar windows, panel time
|
|
6
|
+
* labels and time words read it at each instant they print or group, never one offset read now for every instant.
|
|
7
|
+
* The one implementation of this algebra: web's display-timezone-offset.util re-exports it (the package never imports
|
|
8
|
+
* src/), and tests/structure/zone-offset-one-clock.spec.ts fails on a second declaration.
|
|
9
|
+
*/
|
|
10
|
+
/** The offsets either side of a wall time are read this far from it: past every candidate instant (an offset stays
|
|
11
|
+
* within a day of UTC), short of the next clock change (months apart). */
|
|
12
|
+
const SIDE_MS = 24 * 3_600_000;
|
|
13
|
+
/** A display offset read at one instant. */
|
|
14
|
+
export const displayOffsetAt = (offset, ms) => typeof offset === 'number' ? offset : offset(ms);
|
|
15
|
+
/** An instant's wall clock in the display zone, as a UTC-shaped epoch: read it with UTC getters or `timeZone: 'UTC'`. */
|
|
16
|
+
export const displayWallMs = (offset, ms) => ms + displayOffsetAt(offset, ms);
|
|
17
|
+
/**
|
|
18
|
+
* The instant a display wall time names (the inverse of `displayWallMs`), on the wall time's own offset. A wall time
|
|
19
|
+
* the clock repeats (the hour a fall change repeats) names its first pass, or with `referenceMs` (the instant being
|
|
20
|
+
* edited) the pass on the reference's own offset: a field showing a point in the second pass reads back to that point,
|
|
21
|
+
* and a time typed inside that hour stays on its pass. One the clock skips (the hour a spring change skips, a midnight
|
|
22
|
+
* a zone jumps over) names the instant its earlier offset gives, past the jump: a zone day whose midnight is skipped
|
|
23
|
+
* starts where its clock jumps.
|
|
24
|
+
*/
|
|
25
|
+
export function displayWallToUtcMs(offset, wallMs, referenceMs) {
|
|
26
|
+
if (typeof offset === 'number')
|
|
27
|
+
return wallMs - offset;
|
|
28
|
+
const near = wallMs - offset(wallMs);
|
|
29
|
+
const before = offset(near - SIDE_MS);
|
|
30
|
+
const after = offset(near + SIDE_MS);
|
|
31
|
+
// The first pass reads the larger offset; when that reading is not the clock's there, the smaller one is.
|
|
32
|
+
const high = Math.max(before, after);
|
|
33
|
+
const low = Math.min(before, after);
|
|
34
|
+
const early = wallMs - high;
|
|
35
|
+
if (offset(early) !== high)
|
|
36
|
+
return wallMs - low;
|
|
37
|
+
// Both readings hold only for a wall time the clock repeats: the reference picks the pass on its own offset.
|
|
38
|
+
const late = wallMs - low;
|
|
39
|
+
const repeated = low !== high && offset(late) === low;
|
|
40
|
+
return repeated && referenceMs !== undefined && offset(referenceMs) === low ? late : early;
|
|
41
|
+
}
|
|
@@ -3,7 +3,8 @@ export type ChartSessionWord = 'regular' | 'extended';
|
|
|
3
3
|
* The session the chart rides on this market at this interval. An absent or unknown word reads as the market's
|
|
4
4
|
* default. On a market with an RTH window the answer is 'regular' only while `isChartRthActive` holds for a
|
|
5
5
|
* 'regular' choice at `interval` (the chart's interval label or milliseconds; an unknown interval reads as
|
|
6
|
-
* inactive), else 'extended'.
|
|
6
|
+
* inactive), else 'extended'. On a US stock it is 'extended' only while `isEquityExtendedSession` holds at
|
|
7
|
+
* `interval` (an unknown interval keeps the choice), else 'regular'. Every other market keeps the normalised word.
|
|
7
8
|
*/
|
|
8
9
|
export declare function effectiveChartSessionType(exchange: unknown, symbol: unknown, interval: unknown, sessionType: unknown): ChartSessionWord;
|
|
9
10
|
/**
|
|
@@ -9,22 +9,30 @@
|
|
|
9
9
|
* stamps the default onto a document that never carried the word) and a 'regular' a future keeps at daily and higher,
|
|
10
10
|
* where the chart rides the full session. Left out of an identity, a real flip went unseen.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* A US stock (a Polygon venue) rides 'extended' only while `isEquityExtendedSession` holds: the word, the
|
|
13
|
+
* extended-hours option on, and an intraday interval. Daily and longer bars ride the regular session, so a stock's
|
|
14
|
+
* 'extended' at daily and higher reads 'regular' here, the twin of a future's 'regular' there. Every other market
|
|
15
|
+
* without an RTH window (crypto, unmapped CME roots) keeps the normalised word.
|
|
14
16
|
*
|
|
15
|
-
* A pure leaf: it imports the
|
|
16
|
-
* modules that read it (the pane planner, the wrun drivers registry)
|
|
17
|
+
* A pure leaf: it imports the two session deciders only (rth-session.util and us-equities-session.util, both
|
|
18
|
+
* worker-safe and store-free), so the store-free modules that read it (the pane planner, the wrun drivers registry)
|
|
19
|
+
* keep the chart store out of their eager graph.
|
|
17
20
|
*/
|
|
18
21
|
import { chartIntervalToMs, defaultChartSessionType, hasRthWindow, isChartRthActive } from './rth-session.util.js';
|
|
22
|
+
import { isEquityRegularSessionGated } from './us-equities-session.util.js';
|
|
19
23
|
/**
|
|
20
24
|
* The session the chart rides on this market at this interval. An absent or unknown word reads as the market's
|
|
21
25
|
* default. On a market with an RTH window the answer is 'regular' only while `isChartRthActive` holds for a
|
|
22
26
|
* 'regular' choice at `interval` (the chart's interval label or milliseconds; an unknown interval reads as
|
|
23
|
-
* inactive), else 'extended'.
|
|
27
|
+
* inactive), else 'extended'. On a US stock it is 'extended' only while `isEquityExtendedSession` holds at
|
|
28
|
+
* `interval` (an unknown interval keeps the choice), else 'regular'. Every other market keeps the normalised word.
|
|
24
29
|
*/
|
|
25
30
|
export function effectiveChartSessionType(exchange, symbol, interval, sessionType) {
|
|
26
31
|
const word = sessionType === 'regular' || sessionType === 'extended' ? sessionType : null;
|
|
27
32
|
const chosen = word ?? defaultChartSessionType(symbol, exchange);
|
|
33
|
+
// A US stock rides the regular session wherever its gate holds at this interval; else its 'extended' stands below.
|
|
34
|
+
if (isEquityRegularSessionGated(exchange, chosen, interval))
|
|
35
|
+
return 'regular';
|
|
28
36
|
if (chosen === 'extended' || !hasRthWindow(symbol, exchange))
|
|
29
37
|
return chosen;
|
|
30
38
|
return isChartRthActive(exchange, symbol, 'regular', chartIntervalToMs(interval)) ? 'regular' : 'extended';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FeedCombineRule, FeedHead, FeedWireBar, FeedWireRow } from '../../interfaces/feed.interface.js';
|
|
1
|
+
import type { FeedCombineRule, FeedHead, FeedValueKey, FeedWireBar, FeedWireRow } from '../../interfaces/feed.interface.js';
|
|
2
2
|
/** C2: the intervals the relay regroups bars on, ascending. */
|
|
3
3
|
export declare const FEED_BAR_INTERVALS_S: readonly [60, 300, 900, 1800, 3600, 14400, 86400, 604800];
|
|
4
4
|
/** C4 poll: never more often than this. */
|
|
@@ -14,8 +14,7 @@ export type FeedRequest = {
|
|
|
14
14
|
};
|
|
15
15
|
/** C4: true when the feed draws its raw rows at their own timestamps on this chart interval. */
|
|
16
16
|
export declare function feedDrawsRows(cadenceS: number, chartIntervalMs: number): boolean;
|
|
17
|
-
|
|
18
|
-
export declare function chooseFeedRequest(cadenceS: number, chartIntervalMs: number): FeedRequest;
|
|
17
|
+
export declare function chooseFeedRequest(cadenceS: number, chartIntervalMs: number, columnIndex?: number): FeedRequest;
|
|
19
18
|
/** Two requests ask for the same thing (a regroup on the same interval, or the rows). */
|
|
20
19
|
export declare function sameFeedRequest(a: FeedRequest | null, b: FeedRequest | null): boolean;
|
|
21
20
|
/** C4 poll period: every `max(10, cadence_s / 2)` seconds (irregular feeds every 10 s). */
|
|
@@ -46,29 +45,17 @@ export interface FeedFetchWindowInput {
|
|
|
46
45
|
cadenceS: number;
|
|
47
46
|
chartIntervalMs: number;
|
|
48
47
|
nowMs: number;
|
|
49
|
-
|
|
50
|
-
mainFirstMs: number | null;
|
|
48
|
+
firstBarMs: number | null;
|
|
51
49
|
/** The feed's newest row (head `last_ts`), seconds: always inside the window, so the legend has a value. */
|
|
52
50
|
lastTs?: number | null;
|
|
53
51
|
}
|
|
54
|
-
/**
|
|
55
|
-
* The window a full read covers, seconds: from one cadence (or one bar)
|
|
56
|
-
* before the first candle, so the line enters from the left edge, to now.
|
|
57
|
-
* The newest row is always inside, so a slow feed on a short chart still
|
|
58
|
-
* shows its value.
|
|
59
|
-
*/
|
|
60
52
|
export declare function feedFetchWindow(input: FeedFetchWindowInput): {
|
|
61
53
|
fromSec: number;
|
|
62
54
|
toSec: number;
|
|
63
55
|
};
|
|
64
|
-
|
|
65
|
-
export declare function feedRowsToSeries(rows: readonly FeedWireRow[]): number[][];
|
|
66
|
-
|
|
67
|
-
* Wire bars to chart rows: `[ts_ms, value]` for a line, `[ts_ms, open, high, low, close]` for
|
|
68
|
-
* candles. A line's value is the bar's `combined` (position 6, P3 C7: the value's rule over the
|
|
69
|
-
* bucket, a sum for a volume) when the bar carries one, else its close (position 4).
|
|
70
|
-
*/
|
|
71
|
-
export declare function feedBarsToSeries(bars: readonly FeedWireBar[], plot: FeedPlot): number[][];
|
|
56
|
+
export declare function feedColumnIndex(values: readonly FeedValueKey[] | null | undefined, column: string): number;
|
|
57
|
+
export declare function feedRowsToSeries(rows: readonly FeedWireRow[], columnIndex?: number): number[][];
|
|
58
|
+
export declare function feedBarsToSeries(bars: readonly FeedWireBar[], plot: FeedPlot, columnIndex?: number): number[][];
|
|
72
59
|
/** Union by stamp, ascending; an incoming row replaces a held row at the same stamp. */
|
|
73
60
|
export declare function mergeFeedSeries(held: readonly number[][], incoming: readonly number[][]): number[][];
|
|
74
61
|
/** The newest stamp of a series, seconds; null when empty. */
|
|
@@ -76,7 +63,6 @@ export declare function feedSeriesLastTsSec(series: readonly number[][]): number
|
|
|
76
63
|
export interface FeedReadingInput {
|
|
77
64
|
/** The reading's stamp, seconds. */
|
|
78
65
|
ts: number;
|
|
79
|
-
/** Its first value (the plotted key); a null reading breaks a line and leaves bars as they are. */
|
|
80
66
|
value: number | string | null;
|
|
81
67
|
request: FeedRequest;
|
|
82
68
|
plot: FeedPlot;
|
|
@@ -45,9 +45,8 @@ export function feedDrawsRows(cadenceS, chartIntervalMs) {
|
|
|
45
45
|
return true;
|
|
46
46
|
return chartIntervalMs <= cadenceS * 1_000;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (feedDrawsRows(cadenceS, chartIntervalMs))
|
|
48
|
+
export function chooseFeedRequest(cadenceS, chartIntervalMs, columnIndex = 0) {
|
|
49
|
+
if (columnIndex !== 0 || feedDrawsRows(cadenceS, chartIntervalMs))
|
|
51
50
|
return { kind: 'rows' };
|
|
52
51
|
let intervalS = 0;
|
|
53
52
|
for (const candidate of FEED_BAR_INTERVALS_S) {
|
|
@@ -130,16 +129,10 @@ export function feedChartIntervalLabel(chartIntervalMs) {
|
|
|
130
129
|
return label;
|
|
131
130
|
return feedIntervalLabel(chartIntervalMs / 1_000);
|
|
132
131
|
}
|
|
133
|
-
/**
|
|
134
|
-
* The window a full read covers, seconds: from one cadence (or one bar)
|
|
135
|
-
* before the first candle, so the line enters from the left edge, to now.
|
|
136
|
-
* The newest row is always inside, so a slow feed on a short chart still
|
|
137
|
-
* shows its value.
|
|
138
|
-
*/
|
|
139
132
|
export function feedFetchWindow(input) {
|
|
140
133
|
const nowSec = Math.ceil(input.nowMs / 1_000);
|
|
141
|
-
const firstSec = input.
|
|
142
|
-
? Math.floor(input.
|
|
134
|
+
const firstSec = input.firstBarMs !== null && Number.isFinite(input.firstBarMs)
|
|
135
|
+
? Math.floor(input.firstBarMs / 1_000)
|
|
143
136
|
: Math.floor((input.nowMs - FEED_DEFAULT_LOOKBACK_BARS * Math.max(1, input.chartIntervalMs)) / 1_000);
|
|
144
137
|
const reachS = input.request.kind === 'bars' ? input.request.interval_s : Math.max(0, input.cadenceS);
|
|
145
138
|
let fromSec = firstSec - reachS;
|
|
@@ -151,24 +144,22 @@ export function feedFetchWindow(input) {
|
|
|
151
144
|
return { fromSec: Math.max(0, fromSec), toSec: nowSec };
|
|
152
145
|
}
|
|
153
146
|
const cell = (value) => (typeof value === 'number' && Number.isFinite(value) ? value : Number.NaN);
|
|
154
|
-
|
|
155
|
-
|
|
147
|
+
export function feedColumnIndex(values, column) {
|
|
148
|
+
if (!column)
|
|
149
|
+
return 0;
|
|
150
|
+
return (values ?? []).findIndex((value) => value.key === column);
|
|
151
|
+
}
|
|
152
|
+
export function feedRowsToSeries(rows, columnIndex = 0) {
|
|
156
153
|
const series = rows
|
|
157
154
|
.filter((row) => Array.isArray(row) && typeof row[0] === 'number' && Number.isFinite(row[0]))
|
|
158
|
-
.map((row) => [row[0] * 1_000, cell(row[1])]);
|
|
155
|
+
.map((row) => [row[0] * 1_000, columnIndex >= 0 ? cell(row[1 + columnIndex]) : Number.NaN]);
|
|
159
156
|
return dedupeAscending(series);
|
|
160
157
|
}
|
|
161
|
-
|
|
162
|
-
* Wire bars to chart rows: `[ts_ms, value]` for a line, `[ts_ms, open, high, low, close]` for
|
|
163
|
-
* candles. A line's value is the bar's `combined` (position 6, P3 C7: the value's rule over the
|
|
164
|
-
* bucket, a sum for a volume) when the bar carries one, else its close (position 4).
|
|
165
|
-
*/
|
|
166
|
-
export function feedBarsToSeries(bars, plot) {
|
|
158
|
+
export function feedBarsToSeries(bars, plot, columnIndex = 0) {
|
|
167
159
|
const series = bars
|
|
168
160
|
.filter((bar) => Array.isArray(bar) && typeof bar[0] === 'number' && Number.isFinite(bar[0]))
|
|
169
161
|
.map((bar) => {
|
|
170
|
-
|
|
171
|
-
const isStateBar = typeof bar[1] === 'string';
|
|
162
|
+
const isStateBar = typeof bar[1] === 'string' || columnIndex !== 0;
|
|
172
163
|
const open = isStateBar ? Number.NaN : cell(bar[1]);
|
|
173
164
|
const high = isStateBar ? Number.NaN : cell(bar[2]);
|
|
174
165
|
const low = isStateBar ? Number.NaN : cell(bar[3]);
|