@orangecharts/wrun-chart-host 0.11.1 → 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 +17 -0
- package/dist/index.js +18 -0
- package/dist/indicators/controls/tpo-session.util.d.ts +52 -12
- package/dist/indicators/controls/tpo-session.util.js +113 -16
- 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/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-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 +7 -3
- 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 +5 -5
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session lattices: the client mirror of how tsdb-gateway labels a session
|
|
3
|
+
* venue's history at 4h, 1d, 1w and the rolled-up presets. The gateway keeps
|
|
4
|
+
* ONE rollup for every venue that owns its trading day (pkg/tsdb/selects/
|
|
5
|
+
* session_profile.go `sessionProfile`, generalised from the CME rollup by
|
|
6
|
+
* !2483): a profile names the wall clock the bars are cut on, the venues, the
|
|
7
|
+
* intervals and the weekend rule, and the rollup re-groups source-tier rows on
|
|
8
|
+
* that wall clock. This module is the same table: a venue with its own trading
|
|
9
|
+
* day is one more profile here, and every live writer, fetch window, run-bar
|
|
10
|
+
* span and trading-day anchor reads the profile instead of naming a venue.
|
|
11
|
+
*
|
|
12
|
+
* The two profiles the gateway serves today:
|
|
13
|
+
*
|
|
14
|
+
* - CME Group (`cmeSession`, cme.go, since c645fd6; the presets since !2151):
|
|
15
|
+
* 17:00 America/Chicago, on the CME trade calendar (a weekday holiday's
|
|
16
|
+
* session belongs to the next trade date, cme-trade-calendar.util, !2154),
|
|
17
|
+
* a weekend day keeps its own date (the 24/7 crypto products trade it).
|
|
18
|
+
* Served for TRADE_AGG, TRADE_SIDE_AGNOSTIC_AGG and the per-symbol
|
|
19
|
+
* VOLUME_PROFILE_AGG / BLOCK_BOOK_SNAPSHOT_AGG of CME, CBOT, NYMEX, COMEX.
|
|
20
|
+
* - Forex (`forexSession`, forex_session.go, !2483, Discord ticket 603): 17:00
|
|
21
|
+
* America/New_York, the day TradingView and MT4 cut on, no calendar, and a
|
|
22
|
+
* session day falling on a weekend moves to the Monday after (Sunday's
|
|
23
|
+
* 17:00 open starts Monday's bar; there is no Sunday bar). Served for
|
|
24
|
+
* FX_OTC TICKER_AGG at 4h and wider only: finer bars nest in the hours.
|
|
25
|
+
*
|
|
26
|
+
* How the gateway stamps a bar (`sessionProfile.bucketExpression`):
|
|
27
|
+
*
|
|
28
|
+
* - intraday widths: `time_bucket(width, ts, timezone => zone, offset =>
|
|
29
|
+
* open modulo the width)`, so the open starts a bar. 4h on a 17:00 open:
|
|
30
|
+
* local 01/05/09/13/17/21 (22/02/06/10/14/18Z in daylight time, an hour
|
|
31
|
+
* later in standard time); 2h and 8h offset 1h, 6h and 12h 5h, 45m 30m,
|
|
32
|
+
* 2m 3m 10m none. The source tier is the coarsest of 1h/15m/5m/1m dividing
|
|
33
|
+
* both the width and that offset (`sourceStepMs`);
|
|
34
|
+
* - 1d: the trade date (the date flips at the open), stamped at 00:00Z of
|
|
35
|
+
* that date, so an evening print belongs to TOMORROW's bar; the weekend
|
|
36
|
+
* rule, then the calendar, move the date;
|
|
37
|
+
* - 3d: the trade dates in threes (the calendar's `DayGroupStart`, else the
|
|
38
|
+
* weekday grid from 2000-01-03), labeled by the first;
|
|
39
|
+
* - 1w: the Monday of the trade-date week, 00:00Z;
|
|
40
|
+
* - 1M 3M 6M 1Y: the months of the trade dates, stamped on the first month's
|
|
41
|
+
* 1st at 00:00Z (29dda19, intervals part 4); a weekend day joins the Friday
|
|
42
|
+
* before, so a stale weekend book never opens a month.
|
|
43
|
+
*
|
|
44
|
+
* A live writer that floored session frames on the UTC grid instead split the
|
|
45
|
+
* forming bar (a 04:00 ET CME candle beside the 02:00 ET one; an FX 4h candle
|
|
46
|
+
* frozen for two hours after each lattice open) and titan dropped the frames
|
|
47
|
+
* keyed before it.
|
|
48
|
+
*
|
|
49
|
+
* Pure and worker-safe: Intl only, no dayjs.
|
|
50
|
+
*/
|
|
51
|
+
/** A venue's trade calendar, the holidays its trade dates skip (the gateway's `tradecalendar.Calendar`). */
|
|
52
|
+
export interface SessionTradeCalendar {
|
|
53
|
+
isTradeDate(dayMs: number): boolean;
|
|
54
|
+
tradeDateOnOrAfter(dayMs: number): number;
|
|
55
|
+
tradeDateOnOrBefore(dayMs: number): number;
|
|
56
|
+
dayGroupStartMs(tradeDateMs: number, days: number): number;
|
|
57
|
+
}
|
|
58
|
+
export type SessionLatticeId = 'cme' | 'forex';
|
|
59
|
+
/**
|
|
60
|
+
* One venue group's trading day (the gateway's `sessionProfile`): the wall
|
|
61
|
+
* clock its bars are cut on, the venues, the intraday widths the gateway
|
|
62
|
+
* buckets on the lattice (1d, 3d, 1w and the calendar rungs always are), the
|
|
63
|
+
* weekend rule and the trade calendar. Plain data, so a profile can be named
|
|
64
|
+
* in a context that crosses a worker boundary by its `id`.
|
|
65
|
+
*/
|
|
66
|
+
export interface SessionLatticeProfile {
|
|
67
|
+
readonly id: SessionLatticeId;
|
|
68
|
+
readonly timeZone: string;
|
|
69
|
+
/** The zone's standard-time and daylight-time UTC offsets (Postgres reads an ambiguous wall time as standard). */
|
|
70
|
+
readonly standardOffsetMs: number;
|
|
71
|
+
readonly daylightOffsetMs: number;
|
|
72
|
+
/** The session open on the zone's wall clock, a whole evening hour: everything at or after it trades toward the next date. */
|
|
73
|
+
readonly openHour: number;
|
|
74
|
+
/** The exchange codes the gateway rolls up on this lattice (`isExplicitExchangePlan`), upper case. */
|
|
75
|
+
readonly exchanges: ReadonlySet<string>;
|
|
76
|
+
readonly intradayLatticeMs: ReadonlySet<number>;
|
|
77
|
+
/** A session day on a weekend moves to the Monday after it (rows stamped on a weekend date join the session they open). */
|
|
78
|
+
readonly weekendToMonday: boolean;
|
|
79
|
+
readonly calendar: SessionTradeCalendar | null;
|
|
80
|
+
}
|
|
81
|
+
/** CME Group: 17:00 America/Chicago on the CME trade calendar (gateway `cmeSession`). GLOBEX is a metadata alias with no gate mapping. */
|
|
82
|
+
export declare const CME_SESSION_LATTICE: SessionLatticeProfile;
|
|
83
|
+
/** Forex: 17:00 America/New_York, Sunday's open starts Monday's bar (gateway `forexSession`, 4h and wider only). */
|
|
84
|
+
export declare const FOREX_SESSION_LATTICE: SessionLatticeProfile;
|
|
85
|
+
/** Every venue group with a trading day of its own (the gateway's `sessionProfiles`). */
|
|
86
|
+
export declare const SESSION_LATTICE_PROFILES: readonly SessionLatticeProfile[];
|
|
87
|
+
/** The profile named `id`, or null. */
|
|
88
|
+
export declare function sessionLatticeById(id: unknown): SessionLatticeProfile | null;
|
|
89
|
+
/** The lattice the gateway rolls `exchange` up on, or null for a venue that keeps the UTC aggregates. */
|
|
90
|
+
export declare function sessionLatticeOf(exchange: unknown): SessionLatticeProfile | null;
|
|
91
|
+
/** The intervals the gateway serves on the profile's lattice: its intraday widths, 1d, 3d, 1w and the calendar rungs. */
|
|
92
|
+
export declare function isSessionLatticeIntervalMs(profile: SessionLatticeProfile, intervalMs: unknown): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* The first trade date (00:00Z) of the 3d session bar holding the trade date
|
|
95
|
+
* `dayMs` (gateway `sessionGridStart`, session_grid.go): trade dates are
|
|
96
|
+
* counted in weekdays from 2000-01-03, a Monday, three to a bar; a weekend
|
|
97
|
+
* date counts as the Friday before it. The regular US equities session and
|
|
98
|
+
* the forex lattice (no calendar); CME rides the trade calendar, every other
|
|
99
|
+
* market's 3d is the calendar floor.
|
|
100
|
+
*/
|
|
101
|
+
export declare function sessionGridStartMs(dayMs: number): number;
|
|
102
|
+
/**
|
|
103
|
+
* The bar key the gateway stamps for the profile's session bar holding
|
|
104
|
+
* `tsMs`: the intraday bucket start, or the trade-date label (00:00Z of the
|
|
105
|
+
* trade date, not the open instant) at 1d, the first trade date of its 3d
|
|
106
|
+
* group, the Monday of its week at 1w, and the 1st of its trade date's month,
|
|
107
|
+
* quarter, half or year at a calendar length. Null when the interval is not a
|
|
108
|
+
* lattice interval of the profile or the input is not a number.
|
|
109
|
+
*/
|
|
110
|
+
export declare function sessionLatticeBucketMs(profile: SessionLatticeProfile, tsMs: number, intervalMs: number): number | null;
|
|
111
|
+
/**
|
|
112
|
+
* The instant the session bar stamped `barMs` (a key `sessionLatticeBucketMs` stamps) stops taking
|
|
113
|
+
* source rows: the end of the last source row the lattice books to it, for a reader that must never
|
|
114
|
+
* take a bar before it closes (a pinned wrun leg). At 1d, 3d and 1w the key only advances with the
|
|
115
|
+
* session day, so the bar ends at the first source row booked elsewhere: a 3d bar runs to the open of
|
|
116
|
+
* the next group's first session, a weekend or a weekday holiday inside it (Thursday, Friday and
|
|
117
|
+
* Monday close at Monday's open), a 1d bar to the open that starts the next session day (a forex
|
|
118
|
+
* Monday, which holds the weekend before it, still ends at Monday's 17:00 New York). An intraday bar
|
|
119
|
+
* ends at its stamp plus its width, except across a DST change: on the fall-back Sunday a bucket
|
|
120
|
+
* reaching the repeated hour holds its rows an hour longer (the 01:00 4h bar runs five real hours),
|
|
121
|
+
* and the 45m lattice books rows of the repeated hour back to an earlier stamp, so the end is the end
|
|
122
|
+
* of the LAST row booked to it within its width and an hour. A calendar bar runs to the next one's
|
|
123
|
+
* open (July 2026 to Sunday 8/2 at 17:00 CDT). Null off the lattice intervals, or for a stamp the
|
|
124
|
+
* lattice books no row to.
|
|
125
|
+
*/
|
|
126
|
+
export declare function sessionLatticeBarEndMs(profile: SessionLatticeProfile, barMs: number, intervalMs: number): number | null;
|
|
127
|
+
/**
|
|
128
|
+
* The instant the session bar holding `tsMs` opens, for a fetch window that
|
|
129
|
+
* must cover the whole bar: the intraday bucket start, or the open before the
|
|
130
|
+
* first session day booked to the label (1d, 3d, 1w and the calendar rungs,
|
|
131
|
+
* where the bar key is a 00:00Z label that runs ahead of the open): the
|
|
132
|
+
* 17:00 open before a trade date, Sunday's open before a week's Monday, a
|
|
133
|
+
* month's first trade date (August 2026 opens Sunday 8/2). A 1d or 3d bar
|
|
134
|
+
* after a weekday holiday opens with the holiday's session (9/8 opens Sunday
|
|
135
|
+
* 9/6); a forex Monday opens at Friday's close, where its weekend prints
|
|
136
|
+
* start. Null off the lattice intervals.
|
|
137
|
+
*/
|
|
138
|
+
export declare function sessionLatticeBarOpenMs(profile: SessionLatticeProfile, tsMs: number, intervalMs: number): number | null;
|
|
139
|
+
/**
|
|
140
|
+
* The stamp of the session bar after `barMs` (a stamp `sessionLatticeBucketMs` gives), for a walk that must visit
|
|
141
|
+
* every bar of a window once: the first later stamp a source row is booked to, read row by row from `barMs` at the
|
|
142
|
+
* gateway's source step (an hour on the daily and calendar bars). Never the bucket of `barMs + intervalMs`: a
|
|
143
|
+
* lattice bar can outlast its width (the 01:00 4h bar runs five real hours on a fall-back Sunday, a 3d bar holds the
|
|
144
|
+
* weekend inside it, a 31-day month outlasts the 1M width), and inside such a bar that bucket is the bar itself, so
|
|
145
|
+
* a walk stepping it never moves (the k-trades grid spun until the data worker's heap ran out, 2026-11-05). Rows
|
|
146
|
+
* after the change can book back to an earlier stamp (the 45m lattice's repeated hour), so the first LATER stamp is
|
|
147
|
+
* the next bar, never the bar the last row of `barMs` ends at. Null off the lattice intervals or when no later
|
|
148
|
+
* stamp sits within reach.
|
|
149
|
+
*/
|
|
150
|
+
export declare function sessionLatticeNextBarMs(profile: SessionLatticeProfile, barMs: number, intervalMs: number): number | null;
|
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session lattices: the client mirror of how tsdb-gateway labels a session
|
|
3
|
+
* venue's history at 4h, 1d, 1w and the rolled-up presets. The gateway keeps
|
|
4
|
+
* ONE rollup for every venue that owns its trading day (pkg/tsdb/selects/
|
|
5
|
+
* session_profile.go `sessionProfile`, generalised from the CME rollup by
|
|
6
|
+
* !2483): a profile names the wall clock the bars are cut on, the venues, the
|
|
7
|
+
* intervals and the weekend rule, and the rollup re-groups source-tier rows on
|
|
8
|
+
* that wall clock. This module is the same table: a venue with its own trading
|
|
9
|
+
* day is one more profile here, and every live writer, fetch window, run-bar
|
|
10
|
+
* span and trading-day anchor reads the profile instead of naming a venue.
|
|
11
|
+
*
|
|
12
|
+
* The two profiles the gateway serves today:
|
|
13
|
+
*
|
|
14
|
+
* - CME Group (`cmeSession`, cme.go, since c645fd6; the presets since !2151):
|
|
15
|
+
* 17:00 America/Chicago, on the CME trade calendar (a weekday holiday's
|
|
16
|
+
* session belongs to the next trade date, cme-trade-calendar.util, !2154),
|
|
17
|
+
* a weekend day keeps its own date (the 24/7 crypto products trade it).
|
|
18
|
+
* Served for TRADE_AGG, TRADE_SIDE_AGNOSTIC_AGG and the per-symbol
|
|
19
|
+
* VOLUME_PROFILE_AGG / BLOCK_BOOK_SNAPSHOT_AGG of CME, CBOT, NYMEX, COMEX.
|
|
20
|
+
* - Forex (`forexSession`, forex_session.go, !2483, Discord ticket 603): 17:00
|
|
21
|
+
* America/New_York, the day TradingView and MT4 cut on, no calendar, and a
|
|
22
|
+
* session day falling on a weekend moves to the Monday after (Sunday's
|
|
23
|
+
* 17:00 open starts Monday's bar; there is no Sunday bar). Served for
|
|
24
|
+
* FX_OTC TICKER_AGG at 4h and wider only: finer bars nest in the hours.
|
|
25
|
+
*
|
|
26
|
+
* How the gateway stamps a bar (`sessionProfile.bucketExpression`):
|
|
27
|
+
*
|
|
28
|
+
* - intraday widths: `time_bucket(width, ts, timezone => zone, offset =>
|
|
29
|
+
* open modulo the width)`, so the open starts a bar. 4h on a 17:00 open:
|
|
30
|
+
* local 01/05/09/13/17/21 (22/02/06/10/14/18Z in daylight time, an hour
|
|
31
|
+
* later in standard time); 2h and 8h offset 1h, 6h and 12h 5h, 45m 30m,
|
|
32
|
+
* 2m 3m 10m none. The source tier is the coarsest of 1h/15m/5m/1m dividing
|
|
33
|
+
* both the width and that offset (`sourceStepMs`);
|
|
34
|
+
* - 1d: the trade date (the date flips at the open), stamped at 00:00Z of
|
|
35
|
+
* that date, so an evening print belongs to TOMORROW's bar; the weekend
|
|
36
|
+
* rule, then the calendar, move the date;
|
|
37
|
+
* - 3d: the trade dates in threes (the calendar's `DayGroupStart`, else the
|
|
38
|
+
* weekday grid from 2000-01-03), labeled by the first;
|
|
39
|
+
* - 1w: the Monday of the trade-date week, 00:00Z;
|
|
40
|
+
* - 1M 3M 6M 1Y: the months of the trade dates, stamped on the first month's
|
|
41
|
+
* 1st at 00:00Z (29dda19, intervals part 4); a weekend day joins the Friday
|
|
42
|
+
* before, so a stale weekend book never opens a month.
|
|
43
|
+
*
|
|
44
|
+
* A live writer that floored session frames on the UTC grid instead split the
|
|
45
|
+
* forming bar (a 04:00 ET CME candle beside the 02:00 ET one; an FX 4h candle
|
|
46
|
+
* frozen for two hours after each lattice open) and titan dropped the frames
|
|
47
|
+
* keyed before it.
|
|
48
|
+
*
|
|
49
|
+
* Pure and worker-safe: Intl only, no dayjs.
|
|
50
|
+
*/
|
|
51
|
+
import { Intervals } from '../../constants/interval.constants.js';
|
|
52
|
+
import { barEndMs, calendarBarStartMs, calendarMonthsOfMs } from './calendar-interval.util.js';
|
|
53
|
+
import { cmeDayGroupStartMs, cmeTradeDateOnOrAfter, cmeTradeDateOnOrBefore, isCmeTradeDate, } from './cme-trade-calendar.util.js';
|
|
54
|
+
const MINUTE_MS = 60_000;
|
|
55
|
+
const HOUR_MS = 3_600_000;
|
|
56
|
+
const DAY_MS = 86_400_000;
|
|
57
|
+
const ONE_DAY_MS = Intervals.map_unit['1d'];
|
|
58
|
+
const THREE_DAYS_MS = Intervals.map_unit['3d'];
|
|
59
|
+
const ONE_WEEK_MS = Intervals.map_unit['1w'];
|
|
60
|
+
const intervalSet = (labels) => new Set(labels.map((label) => Intervals.map_unit[label]));
|
|
61
|
+
const CME_TRADE_CALENDAR = {
|
|
62
|
+
isTradeDate: isCmeTradeDate,
|
|
63
|
+
tradeDateOnOrAfter: cmeTradeDateOnOrAfter,
|
|
64
|
+
tradeDateOnOrBefore: cmeTradeDateOnOrBefore,
|
|
65
|
+
dayGroupStartMs: cmeDayGroupStartMs,
|
|
66
|
+
};
|
|
67
|
+
/** CME Group: 17:00 America/Chicago on the CME trade calendar (gateway `cmeSession`). GLOBEX is a metadata alias with no gate mapping. */
|
|
68
|
+
export const CME_SESSION_LATTICE = Object.freeze({
|
|
69
|
+
id: 'cme',
|
|
70
|
+
timeZone: 'America/Chicago',
|
|
71
|
+
standardOffsetMs: -6 * HOUR_MS,
|
|
72
|
+
daylightOffsetMs: -5 * HOUR_MS,
|
|
73
|
+
openHour: 17,
|
|
74
|
+
exchanges: new Set(['CME', 'CBOT', 'NYMEX', 'COMEX']),
|
|
75
|
+
intradayLatticeMs: intervalSet(['2m', '3m', '10m', '45m', '2h', '4h', '6h', '8h', '12h']),
|
|
76
|
+
weekendToMonday: false,
|
|
77
|
+
calendar: CME_TRADE_CALENDAR,
|
|
78
|
+
});
|
|
79
|
+
/** Forex: 17:00 America/New_York, Sunday's open starts Monday's bar (gateway `forexSession`, 4h and wider only). */
|
|
80
|
+
export const FOREX_SESSION_LATTICE = Object.freeze({
|
|
81
|
+
id: 'forex',
|
|
82
|
+
timeZone: 'America/New_York',
|
|
83
|
+
standardOffsetMs: -5 * HOUR_MS,
|
|
84
|
+
daylightOffsetMs: -4 * HOUR_MS,
|
|
85
|
+
openHour: 17,
|
|
86
|
+
exchanges: new Set(['FX_OTC']),
|
|
87
|
+
intradayLatticeMs: intervalSet(['4h', '6h', '8h', '12h']),
|
|
88
|
+
weekendToMonday: true,
|
|
89
|
+
calendar: null,
|
|
90
|
+
});
|
|
91
|
+
/** Every venue group with a trading day of its own (the gateway's `sessionProfiles`). */
|
|
92
|
+
export const SESSION_LATTICE_PROFILES = Object.freeze([
|
|
93
|
+
CME_SESSION_LATTICE,
|
|
94
|
+
FOREX_SESSION_LATTICE,
|
|
95
|
+
]);
|
|
96
|
+
/** The profile named `id`, or null. */
|
|
97
|
+
export function sessionLatticeById(id) {
|
|
98
|
+
return SESSION_LATTICE_PROFILES.find((profile) => profile.id === id) ?? null;
|
|
99
|
+
}
|
|
100
|
+
/** The lattice the gateway rolls `exchange` up on, or null for a venue that keeps the UTC aggregates. */
|
|
101
|
+
export function sessionLatticeOf(exchange) {
|
|
102
|
+
if (typeof exchange !== 'string')
|
|
103
|
+
return null;
|
|
104
|
+
const code = exchange.toUpperCase();
|
|
105
|
+
return SESSION_LATTICE_PROFILES.find((profile) => profile.exchanges.has(code)) ?? null;
|
|
106
|
+
}
|
|
107
|
+
/** The intervals the gateway serves on the profile's lattice: its intraday widths, 1d, 3d, 1w and the calendar rungs. */
|
|
108
|
+
export function isSessionLatticeIntervalMs(profile, intervalMs) {
|
|
109
|
+
return (typeof intervalMs === 'number' &&
|
|
110
|
+
(profile.intradayLatticeMs.has(intervalMs) ||
|
|
111
|
+
intervalMs === ONE_DAY_MS ||
|
|
112
|
+
intervalMs === THREE_DAYS_MS ||
|
|
113
|
+
intervalMs === ONE_WEEK_MS ||
|
|
114
|
+
calendarMonthsOfMs(intervalMs) !== null));
|
|
115
|
+
}
|
|
116
|
+
const floorTo = (value, step) => value - (((value % step) + step) % step);
|
|
117
|
+
const isWeekendDay = (dayMs) => {
|
|
118
|
+
const weekday = new Date(dayMs).getUTCDay();
|
|
119
|
+
return weekday === 0 || weekday === 6;
|
|
120
|
+
};
|
|
121
|
+
/** The session open's offset into a width: a 17:00 open sits on the lattice (4h: 01:00, 05:00, ... 21:00). */
|
|
122
|
+
const openOffsetMs = (profile, widthMs) => (profile.openHour * HOUR_MS) % widthMs;
|
|
123
|
+
/** The source tier the gateway re-buckets for a width (`sessionTier`): the coarsest dividing width and offset. */
|
|
124
|
+
function sourceStepMs(profile, widthMs) {
|
|
125
|
+
const offsetMs = openOffsetMs(profile, widthMs);
|
|
126
|
+
for (const stepMs of [HOUR_MS, 15 * MINUTE_MS, 5 * MINUTE_MS]) {
|
|
127
|
+
if (widthMs % stepMs === 0 && offsetMs % stepMs === 0)
|
|
128
|
+
return stepMs;
|
|
129
|
+
}
|
|
130
|
+
return MINUTE_MS;
|
|
131
|
+
}
|
|
132
|
+
const OFFSET_CACHE_MAX = 8192;
|
|
133
|
+
const BAR_END_CACHE_MAX = 8192;
|
|
134
|
+
const states = new Map();
|
|
135
|
+
function stateOf(profile) {
|
|
136
|
+
let state = states.get(profile.id);
|
|
137
|
+
if (!state) {
|
|
138
|
+
state = { formatter: null, offsetByUtcDay: new Map(), offsetByUtcHour: new Map(), barEnd: new Map() };
|
|
139
|
+
states.set(profile.id, state);
|
|
140
|
+
}
|
|
141
|
+
return state;
|
|
142
|
+
}
|
|
143
|
+
function formatterOf(profile) {
|
|
144
|
+
const state = stateOf(profile);
|
|
145
|
+
if (!state.formatter) {
|
|
146
|
+
state.formatter = new Intl.DateTimeFormat('en-US', {
|
|
147
|
+
timeZone: profile.timeZone,
|
|
148
|
+
year: 'numeric',
|
|
149
|
+
month: '2-digit',
|
|
150
|
+
day: '2-digit',
|
|
151
|
+
hour: '2-digit',
|
|
152
|
+
minute: '2-digit',
|
|
153
|
+
second: '2-digit',
|
|
154
|
+
hourCycle: 'h23',
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return state.formatter;
|
|
158
|
+
}
|
|
159
|
+
function intlZoneOffsetMs(profile, utcMs) {
|
|
160
|
+
const wall = { year: 0, month: 1, day: 1, hour: 0, minute: 0, second: 0 };
|
|
161
|
+
for (const part of formatterOf(profile).formatToParts(utcMs)) {
|
|
162
|
+
if (part.type in wall)
|
|
163
|
+
wall[part.type] = Number(part.value);
|
|
164
|
+
}
|
|
165
|
+
return Date.UTC(wall.year, wall.month - 1, wall.day, wall.hour % 24, wall.minute, wall.second) - utcMs;
|
|
166
|
+
}
|
|
167
|
+
function cacheOffset(cache, key, offset) {
|
|
168
|
+
if (cache.size >= OFFSET_CACHE_MAX)
|
|
169
|
+
cache.clear();
|
|
170
|
+
cache.set(key, offset);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* The zone's UTC offset at `utcMs`. US transitions happen at 02:00 local, a
|
|
174
|
+
* whole UTC hour, at most once per UTC day, so a day whose first and last
|
|
175
|
+
* hours agree holds one offset throughout: it caches per day (a CVD candle
|
|
176
|
+
* commit buckets years of rows, the live path one frame at a time), and only
|
|
177
|
+
* a transition day falls back to per-hour reads. NaN marks a transition day.
|
|
178
|
+
*/
|
|
179
|
+
function zoneOffsetMs(profile, utcMs) {
|
|
180
|
+
const state = stateOf(profile);
|
|
181
|
+
const dayMs = floorTo(utcMs, DAY_MS);
|
|
182
|
+
let dayOffset = state.offsetByUtcDay.get(dayMs);
|
|
183
|
+
if (dayOffset === undefined) {
|
|
184
|
+
const first = intlZoneOffsetMs(profile, dayMs);
|
|
185
|
+
dayOffset = first === intlZoneOffsetMs(profile, dayMs + 23 * HOUR_MS) ? first : Number.NaN;
|
|
186
|
+
cacheOffset(state.offsetByUtcDay, dayMs, dayOffset);
|
|
187
|
+
}
|
|
188
|
+
if (!Number.isNaN(dayOffset))
|
|
189
|
+
return dayOffset;
|
|
190
|
+
const hourMs = floorTo(utcMs, HOUR_MS);
|
|
191
|
+
let hourOffset = state.offsetByUtcHour.get(hourMs);
|
|
192
|
+
if (hourOffset === undefined) {
|
|
193
|
+
hourOffset = intlZoneOffsetMs(profile, hourMs);
|
|
194
|
+
cacheOffset(state.offsetByUtcHour, hourMs, hourOffset);
|
|
195
|
+
}
|
|
196
|
+
return hourOffset;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* The instant a zone wall time (expressed as if it were UTC) names, read the
|
|
200
|
+
* way Postgres does (DetermineTimeZoneOffset): a wall time that occurs twice
|
|
201
|
+
* (fall back) or never (spring forward) reads as standard time.
|
|
202
|
+
*/
|
|
203
|
+
function wallToUtcMs(profile, wallAsUtcMs) {
|
|
204
|
+
const standard = wallAsUtcMs - profile.standardOffsetMs;
|
|
205
|
+
if (zoneOffsetMs(profile, standard) === profile.standardOffsetMs)
|
|
206
|
+
return standard;
|
|
207
|
+
const daylight = wallAsUtcMs - profile.daylightOffsetMs;
|
|
208
|
+
if (zoneOffsetMs(profile, daylight) === profile.daylightOffsetMs)
|
|
209
|
+
return daylight;
|
|
210
|
+
return standard;
|
|
211
|
+
}
|
|
212
|
+
/** The zone wall clock (as if it were UTC) of the gateway's source row: the 1h bucket holding `tsMs`. */
|
|
213
|
+
function wallOfSourceRow(profile, tsMs) {
|
|
214
|
+
const rowMs = floorTo(tsMs, HOUR_MS);
|
|
215
|
+
return rowMs + zoneOffsetMs(profile, rowMs);
|
|
216
|
+
}
|
|
217
|
+
/** The calendar date of the session close `tsMs` trades toward (gateway `sessionProfile.day`): it flips at the open. */
|
|
218
|
+
function sessionDayMs(profile, tsMs) {
|
|
219
|
+
return floorTo(wallOfSourceRow(profile, tsMs) + (24 - profile.openHour) * HOUR_MS, DAY_MS);
|
|
220
|
+
}
|
|
221
|
+
/** The session day with the weekend rule applied (gateway `tradeDay`): Saturday and Sunday move to the Monday after. */
|
|
222
|
+
function tradeDayMs(profile, dayMs) {
|
|
223
|
+
if (!profile.weekendToMonday)
|
|
224
|
+
return dayMs;
|
|
225
|
+
const weekday = new Date(dayMs).getUTCDay();
|
|
226
|
+
return weekday === 6 ? dayMs + 2 * DAY_MS : weekday === 0 ? dayMs + DAY_MS : dayMs;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* The trade date the session day `dayMs` is booked to, stamped at 00:00Z
|
|
230
|
+
* (gateway `currentLabel` at DAY): the weekend rule, then the calendar moves a
|
|
231
|
+
* weekday holiday's session to the next trade date; a weekend day keeps its
|
|
232
|
+
* own date on a profile without the weekend rule.
|
|
233
|
+
*/
|
|
234
|
+
function tradeDateOfDay(profile, dayMs) {
|
|
235
|
+
const day = tradeDayMs(profile, dayMs);
|
|
236
|
+
return profile.calendar && !isWeekendDay(day) ? profile.calendar.tradeDateOnOrAfter(day) : day;
|
|
237
|
+
}
|
|
238
|
+
/** The 3d bar's first trade date: on a calendar a weekend day joins the previous trade date's bar, else the weekday grid. */
|
|
239
|
+
function threeDayLabelOfDay(profile, dayMs) {
|
|
240
|
+
const day = tradeDayMs(profile, dayMs);
|
|
241
|
+
if (profile.calendar) {
|
|
242
|
+
const tradeDate = isWeekendDay(day)
|
|
243
|
+
? profile.calendar.tradeDateOnOrBefore(day)
|
|
244
|
+
: profile.calendar.tradeDateOnOrAfter(day);
|
|
245
|
+
return profile.calendar.dayGroupStartMs(tradeDate, 3);
|
|
246
|
+
}
|
|
247
|
+
return sessionGridStartMs(day);
|
|
248
|
+
}
|
|
249
|
+
/** The Monday (00:00Z) of the trade-date week: date_trunc('week'), ISO weeks from Monday; 1970-01-01 was a Thursday (ISO index 3). */
|
|
250
|
+
function weekLabelOfDay(profile, dayMs) {
|
|
251
|
+
const tradeDate = tradeDateOfDay(profile, dayMs);
|
|
252
|
+
const isoWeekday = (((Math.floor(tradeDate / DAY_MS) + 3) % 7) + 7) % 7;
|
|
253
|
+
return tradeDate - isoWeekday * DAY_MS;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* The calendar bar holding the session day (gateway `bucketExpression` at a calendar interval): the months of its
|
|
257
|
+
* trade date, a weekend day counted on the Friday before it, so a stale weekend book never opens a month. Under the
|
|
258
|
+
* weekend rule the day is never a weekend day: it already moved to Monday.
|
|
259
|
+
*/
|
|
260
|
+
function calendarLabelOfDay(profile, dayMs, months) {
|
|
261
|
+
const day = tradeDayMs(profile, dayMs);
|
|
262
|
+
const weekday = new Date(day).getUTCDay();
|
|
263
|
+
const tradeDateMs = weekday === 6
|
|
264
|
+
? day - DAY_MS
|
|
265
|
+
: weekday === 0
|
|
266
|
+
? day - 2 * DAY_MS
|
|
267
|
+
: profile.calendar
|
|
268
|
+
? profile.calendar.tradeDateOnOrAfter(day)
|
|
269
|
+
: day;
|
|
270
|
+
return calendarBarStartMs(tradeDateMs, months);
|
|
271
|
+
}
|
|
272
|
+
/** The bar key the gateway stamps for the session day `dayMs` at a label interval (1d, 3d, 1w, the calendar rungs); null elsewhere. */
|
|
273
|
+
function labelOfDay(profile, dayMs, intervalMs) {
|
|
274
|
+
if (intervalMs === ONE_DAY_MS)
|
|
275
|
+
return tradeDateOfDay(profile, dayMs);
|
|
276
|
+
if (intervalMs === THREE_DAYS_MS)
|
|
277
|
+
return threeDayLabelOfDay(profile, dayMs);
|
|
278
|
+
if (intervalMs === ONE_WEEK_MS)
|
|
279
|
+
return weekLabelOfDay(profile, dayMs);
|
|
280
|
+
const months = calendarMonthsOfMs(intervalMs);
|
|
281
|
+
return months === null ? null : calendarLabelOfDay(profile, dayMs, months);
|
|
282
|
+
}
|
|
283
|
+
/** The open that starts the session day `dayMs`: the profile's open hour on the calendar day before it. */
|
|
284
|
+
const sessionOpenMs = (profile, dayMs) => wallToUtcMs(profile, dayMs - DAY_MS + profile.openHour * HOUR_MS);
|
|
285
|
+
/** How far a session day can sit from the label it is booked to: a long weekend and the holidays around it. */
|
|
286
|
+
const LABEL_REACH_DAYS = 7;
|
|
287
|
+
/**
|
|
288
|
+
* The first session day booked to the bar stamped `labelMs`. Labels are monotone in the session day, so the first
|
|
289
|
+
* day in reach whose label is `labelMs` opens the bar: a weekday holiday just before a trade date opens with it (CME
|
|
290
|
+
* 9/8 opens Sunday 9/6; New Year's Day opens January), a weekend before a Monday opens it under the weekend rule
|
|
291
|
+
* (forex Monday holds the weekend's stale prints back to Friday's close), a weekend 1st opens its month on the
|
|
292
|
+
* Monday after (August 2026 opens Sunday 8/2). Null for a stamp the lattice books no day to.
|
|
293
|
+
*
|
|
294
|
+
* A profile without the weekend rule keeps the shared host's reading of its 1d, 3d and 1w opens
|
|
295
|
+
* (`@orangecharts/indicator-kit/host` session-calendar, the copy the wrun lane reads; pinned by
|
|
296
|
+
* tests/utility/chart/cme-calendar.package-parity.spec.ts): a week opens with its Monday's session, and a trade
|
|
297
|
+
* date or a 3d group opens with the weekday holidays right before it, never across a weekend. The gateway books a
|
|
298
|
+
* Friday holiday's session to the Monday after (sessionProfile.sourceRange: "Monday's bar with a Friday holiday's
|
|
299
|
+
* Thursday 17:00 open"), which the scan above would read and the host's copy does not; the two copies move
|
|
300
|
+
* together, not here.
|
|
301
|
+
*/
|
|
302
|
+
function firstSessionDayOfLabel(profile, labelMs, intervalMs) {
|
|
303
|
+
if (!profile.weekendToMonday && calendarMonthsOfMs(intervalMs) === null) {
|
|
304
|
+
if (intervalMs === ONE_WEEK_MS)
|
|
305
|
+
return labelMs;
|
|
306
|
+
let day = labelMs;
|
|
307
|
+
for (let prev = day - DAY_MS; !isWeekendDay(prev) && profile.calendar !== null && !profile.calendar.isTradeDate(prev); prev -= DAY_MS) {
|
|
308
|
+
day = prev;
|
|
309
|
+
}
|
|
310
|
+
return day;
|
|
311
|
+
}
|
|
312
|
+
for (let day = labelMs - LABEL_REACH_DAYS * DAY_MS; day <= labelMs + LABEL_REACH_DAYS * DAY_MS; day += DAY_MS) {
|
|
313
|
+
if (labelOfDay(profile, day, intervalMs) === labelMs)
|
|
314
|
+
return day;
|
|
315
|
+
}
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* The gateway's intraday bucket start for the source row holding `tsMs`, in
|
|
320
|
+
* the order TimescaleDB runs `time_bucket` with a timezone and an offset
|
|
321
|
+
* (src/time_bucket.c `ts_timestamptz_timezone_bucket`, 2.25+ #9129): take
|
|
322
|
+
* the offset off in UTC, bucket the zone wall clock from local midnight,
|
|
323
|
+
* read the start back, step back while it lands after the shifted instant
|
|
324
|
+
* (the fall-back guard), put the offset back in UTC. On the fall-back
|
|
325
|
+
* Sunday the 01:00 4h bar spans five real hours from 06:00Z; only CME's 24/7
|
|
326
|
+
* crypto products trade then (forex opens Sunday 17:00, after the change).
|
|
327
|
+
* Every lattice width divides a day, so flooring the wall clock from the
|
|
328
|
+
* epoch is flooring it from local midnight.
|
|
329
|
+
*/
|
|
330
|
+
function intradayBucketStartMs(profile, tsMs, widthMs) {
|
|
331
|
+
const offsetMs = openOffsetMs(profile, widthMs);
|
|
332
|
+
const shifted = floorTo(tsMs, sourceStepMs(profile, widthMs)) - offsetMs;
|
|
333
|
+
let start = wallToUtcMs(profile, floorTo(shifted + zoneOffsetMs(profile, shifted), widthMs));
|
|
334
|
+
while (start > shifted)
|
|
335
|
+
start -= widthMs;
|
|
336
|
+
return start + offsetMs;
|
|
337
|
+
}
|
|
338
|
+
const SESSION_GRID_ORIGIN_MS = Date.UTC(2000, 0, 3);
|
|
339
|
+
const SESSION_GRID_DAYS = 3;
|
|
340
|
+
/**
|
|
341
|
+
* The first trade date (00:00Z) of the 3d session bar holding the trade date
|
|
342
|
+
* `dayMs` (gateway `sessionGridStart`, session_grid.go): trade dates are
|
|
343
|
+
* counted in weekdays from 2000-01-03, a Monday, three to a bar; a weekend
|
|
344
|
+
* date counts as the Friday before it. The regular US equities session and
|
|
345
|
+
* the forex lattice (no calendar); CME rides the trade calendar, every other
|
|
346
|
+
* market's 3d is the calendar floor.
|
|
347
|
+
*/
|
|
348
|
+
export function sessionGridStartMs(dayMs) {
|
|
349
|
+
const days = Math.floor((dayMs - SESSION_GRID_ORIGIN_MS) / DAY_MS);
|
|
350
|
+
const weeks = Math.floor(days / 7);
|
|
351
|
+
const weekday = 5 * weeks + Math.min(days - 7 * weeks, 4);
|
|
352
|
+
const start = SESSION_GRID_DAYS * Math.floor(weekday / SESSION_GRID_DAYS);
|
|
353
|
+
const startWeeks = Math.floor(start / 5);
|
|
354
|
+
return SESSION_GRID_ORIGIN_MS + (7 * startWeeks + start - 5 * startWeeks) * DAY_MS;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* The bar key the gateway stamps for the profile's session bar holding
|
|
358
|
+
* `tsMs`: the intraday bucket start, or the trade-date label (00:00Z of the
|
|
359
|
+
* trade date, not the open instant) at 1d, the first trade date of its 3d
|
|
360
|
+
* group, the Monday of its week at 1w, and the 1st of its trade date's month,
|
|
361
|
+
* quarter, half or year at a calendar length. Null when the interval is not a
|
|
362
|
+
* lattice interval of the profile or the input is not a number.
|
|
363
|
+
*/
|
|
364
|
+
export function sessionLatticeBucketMs(profile, tsMs, intervalMs) {
|
|
365
|
+
if (!Number.isFinite(tsMs))
|
|
366
|
+
return null;
|
|
367
|
+
if (profile.intradayLatticeMs.has(intervalMs))
|
|
368
|
+
return intradayBucketStartMs(profile, tsMs, intervalMs);
|
|
369
|
+
if (intervalMs !== ONE_DAY_MS &&
|
|
370
|
+
intervalMs !== THREE_DAYS_MS &&
|
|
371
|
+
intervalMs !== ONE_WEEK_MS &&
|
|
372
|
+
calendarMonthsOfMs(intervalMs) === null) {
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
return labelOfDay(profile, sessionDayMs(profile, tsMs), intervalMs);
|
|
376
|
+
}
|
|
377
|
+
/** The longest a daily-class bar can run past its stamp: a week and the holidays around it. */
|
|
378
|
+
const DAILY_BAR_SCAN_MS = 21 * DAY_MS;
|
|
379
|
+
/**
|
|
380
|
+
* The instant the session bar stamped `barMs` (a key `sessionLatticeBucketMs` stamps) stops taking
|
|
381
|
+
* source rows: the end of the last source row the lattice books to it, for a reader that must never
|
|
382
|
+
* take a bar before it closes (a pinned wrun leg). At 1d, 3d and 1w the key only advances with the
|
|
383
|
+
* session day, so the bar ends at the first source row booked elsewhere: a 3d bar runs to the open of
|
|
384
|
+
* the next group's first session, a weekend or a weekday holiday inside it (Thursday, Friday and
|
|
385
|
+
* Monday close at Monday's open), a 1d bar to the open that starts the next session day (a forex
|
|
386
|
+
* Monday, which holds the weekend before it, still ends at Monday's 17:00 New York). An intraday bar
|
|
387
|
+
* ends at its stamp plus its width, except across a DST change: on the fall-back Sunday a bucket
|
|
388
|
+
* reaching the repeated hour holds its rows an hour longer (the 01:00 4h bar runs five real hours),
|
|
389
|
+
* and the 45m lattice books rows of the repeated hour back to an earlier stamp, so the end is the end
|
|
390
|
+
* of the LAST row booked to it within its width and an hour. A calendar bar runs to the next one's
|
|
391
|
+
* open (July 2026 to Sunday 8/2 at 17:00 CDT). Null off the lattice intervals, or for a stamp the
|
|
392
|
+
* lattice books no row to.
|
|
393
|
+
*/
|
|
394
|
+
export function sessionLatticeBarEndMs(profile, barMs, intervalMs) {
|
|
395
|
+
if (!Number.isFinite(barMs) || !isSessionLatticeIntervalMs(profile, intervalMs))
|
|
396
|
+
return null;
|
|
397
|
+
const state = stateOf(profile);
|
|
398
|
+
const cacheKey = `${intervalMs}:${barMs}`;
|
|
399
|
+
const cached = state.barEnd.get(cacheKey);
|
|
400
|
+
if (cached !== undefined)
|
|
401
|
+
return cached;
|
|
402
|
+
let end = null;
|
|
403
|
+
const months = calendarMonthsOfMs(intervalMs);
|
|
404
|
+
if (months !== null) {
|
|
405
|
+
if (calendarBarStartMs(barMs, months) === barMs) {
|
|
406
|
+
const next = firstSessionDayOfLabel(profile, barEndMs(barMs, intervalMs), intervalMs);
|
|
407
|
+
end = next === null ? null : sessionOpenMs(profile, next);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
else if (profile.intradayLatticeMs.has(intervalMs)) {
|
|
411
|
+
const windowEndMs = barMs + intervalMs + HOUR_MS;
|
|
412
|
+
if (zoneOffsetMs(profile, barMs - intervalMs - HOUR_MS) === zoneOffsetMs(profile, windowEndMs)) {
|
|
413
|
+
// No DST change within reach: the lattice is a plain run of widths here. (A spring-forward
|
|
414
|
+
// change just before the stamp shortens the bar, so the window reaches back a width too.)
|
|
415
|
+
end = sessionLatticeBucketMs(profile, barMs, intervalMs) === barMs ? barMs + intervalMs : null;
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
const stepMs = sourceStepMs(profile, intervalMs);
|
|
419
|
+
for (let rowMs = barMs; rowMs < windowEndMs; rowMs += stepMs) {
|
|
420
|
+
if (sessionLatticeBucketMs(profile, rowMs, intervalMs) === barMs)
|
|
421
|
+
end = rowMs + stepMs;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
else if (sessionLatticeBucketMs(profile, barMs, intervalMs) === barMs) {
|
|
426
|
+
let rowMs = barMs + HOUR_MS;
|
|
427
|
+
while (rowMs < barMs + DAILY_BAR_SCAN_MS && sessionLatticeBucketMs(profile, rowMs, intervalMs) === barMs) {
|
|
428
|
+
rowMs += HOUR_MS;
|
|
429
|
+
}
|
|
430
|
+
end = rowMs < barMs + DAILY_BAR_SCAN_MS ? rowMs : null;
|
|
431
|
+
}
|
|
432
|
+
if (state.barEnd.size >= BAR_END_CACHE_MAX)
|
|
433
|
+
state.barEnd.clear();
|
|
434
|
+
state.barEnd.set(cacheKey, end);
|
|
435
|
+
return end;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* The instant the session bar holding `tsMs` opens, for a fetch window that
|
|
439
|
+
* must cover the whole bar: the intraday bucket start, or the open before the
|
|
440
|
+
* first session day booked to the label (1d, 3d, 1w and the calendar rungs,
|
|
441
|
+
* where the bar key is a 00:00Z label that runs ahead of the open): the
|
|
442
|
+
* 17:00 open before a trade date, Sunday's open before a week's Monday, a
|
|
443
|
+
* month's first trade date (August 2026 opens Sunday 8/2). A 1d or 3d bar
|
|
444
|
+
* after a weekday holiday opens with the holiday's session (9/8 opens Sunday
|
|
445
|
+
* 9/6); a forex Monday opens at Friday's close, where its weekend prints
|
|
446
|
+
* start. Null off the lattice intervals.
|
|
447
|
+
*/
|
|
448
|
+
export function sessionLatticeBarOpenMs(profile, tsMs, intervalMs) {
|
|
449
|
+
const bucketMs = sessionLatticeBucketMs(profile, tsMs, intervalMs);
|
|
450
|
+
if (bucketMs === null || profile.intradayLatticeMs.has(intervalMs))
|
|
451
|
+
return bucketMs;
|
|
452
|
+
const first = firstSessionDayOfLabel(profile, bucketMs, intervalMs);
|
|
453
|
+
return first === null ? null : sessionOpenMs(profile, first);
|
|
454
|
+
}
|
|
455
|
+
/** How far past a bar's stamp the next bar's first source row can sit: a calendar bar's months and the holidays
|
|
456
|
+
* around its next open, a daily-class bar's long weekend and holidays, an intraday bar's width and the repeated
|
|
457
|
+
* fall-back hour. */
|
|
458
|
+
function nextBarReachMs(profile, intervalMs) {
|
|
459
|
+
const months = calendarMonthsOfMs(intervalMs);
|
|
460
|
+
if (months !== null)
|
|
461
|
+
return (months * 31 + LABEL_REACH_DAYS) * DAY_MS;
|
|
462
|
+
if (profile.intradayLatticeMs.has(intervalMs))
|
|
463
|
+
return intervalMs + 2 * HOUR_MS;
|
|
464
|
+
return DAILY_BAR_SCAN_MS;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* The stamp of the session bar after `barMs` (a stamp `sessionLatticeBucketMs` gives), for a walk that must visit
|
|
468
|
+
* every bar of a window once: the first later stamp a source row is booked to, read row by row from `barMs` at the
|
|
469
|
+
* gateway's source step (an hour on the daily and calendar bars). Never the bucket of `barMs + intervalMs`: a
|
|
470
|
+
* lattice bar can outlast its width (the 01:00 4h bar runs five real hours on a fall-back Sunday, a 3d bar holds the
|
|
471
|
+
* weekend inside it, a 31-day month outlasts the 1M width), and inside such a bar that bucket is the bar itself, so
|
|
472
|
+
* a walk stepping it never moves (the k-trades grid spun until the data worker's heap ran out, 2026-11-05). Rows
|
|
473
|
+
* after the change can book back to an earlier stamp (the 45m lattice's repeated hour), so the first LATER stamp is
|
|
474
|
+
* the next bar, never the bar the last row of `barMs` ends at. Null off the lattice intervals or when no later
|
|
475
|
+
* stamp sits within reach.
|
|
476
|
+
*/
|
|
477
|
+
export function sessionLatticeNextBarMs(profile, barMs, intervalMs) {
|
|
478
|
+
if (!Number.isFinite(barMs) || !isSessionLatticeIntervalMs(profile, intervalMs))
|
|
479
|
+
return null;
|
|
480
|
+
const stepMs = profile.intradayLatticeMs.has(intervalMs) ? sourceStepMs(profile, intervalMs) : HOUR_MS;
|
|
481
|
+
const reachMs = barMs + nextBarReachMs(profile, intervalMs);
|
|
482
|
+
for (let rowMs = floorTo(barMs, stepMs) + stepMs; rowMs <= reachMs; rowMs += stepMs) {
|
|
483
|
+
const stampMs = sessionLatticeBucketMs(profile, rowMs, intervalMs);
|
|
484
|
+
if (stampMs !== null && stampMs > barMs)
|
|
485
|
+
return stampMs;
|
|
486
|
+
}
|
|
487
|
+
return null;
|
|
488
|
+
}
|