@orangecharts/wrun-chart-host 0.15.0 → 0.16.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.
Files changed (175) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/economic.constants.d.ts +2 -0
  3. package/dist/constants/economic.constants.js +2 -0
  4. package/dist/constants/feature-flags.constants.d.ts +10 -0
  5. package/dist/constants/feature-flags.constants.js +52 -4
  6. package/dist/constants/feature-limits.constants.d.ts +72 -4
  7. package/dist/constants/feature-limits.constants.js +98 -20
  8. package/dist/constants/interval.constants.js +5 -0
  9. package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +12 -0
  10. package/dist/constants/kscript-data-interval-restrictions.constants.js +14 -0
  11. package/dist/constants/typed-width-fold.leaf.d.ts +50 -0
  12. package/dist/constants/typed-width-fold.leaf.js +99 -0
  13. package/dist/constants/typed-width-source.leaf.d.ts +24 -0
  14. package/dist/constants/typed-width-source.leaf.js +126 -0
  15. package/dist/constants/typed-width.leaf.d.ts +57 -0
  16. package/dist/constants/typed-width.leaf.js +78 -0
  17. package/dist/host-env.d.ts +10 -0
  18. package/dist/host-env.js +7 -0
  19. package/dist/host-ports.types.d.ts +11 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/index.js +3 -0
  22. package/dist/interfaces/kscript-diagnostics.interface.d.ts +28 -0
  23. package/dist/interfaces/wrun-runtime.interface.d.ts +63 -3
  24. package/dist/interfaces/wrun-runtime.interface.js +11 -0
  25. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
  26. package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
  27. package/dist/market-data/billing.interface.d.ts +12 -45
  28. package/dist/market-data/billing.interface.js +2 -2
  29. package/dist/replay/replayLadder.js +7 -4
  30. package/dist/settings-templates/footprint-rows.d.ts +6 -0
  31. package/dist/settings-templates/footprint-rows.js +6 -0
  32. package/dist/settings-templates/frvp-fields.js +14 -0
  33. package/dist/settings-templates/indicator-fields.js +31 -0
  34. package/dist/settings-templates/tool-tables.generated.js +19 -1
  35. package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
  36. package/dist/utility/chart/cache-alignment.util.d.ts +42 -0
  37. package/dist/utility/chart/cache-alignment.util.js +88 -18
  38. package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
  39. package/dist/utility/chart/calendar-interval.util.js +152 -4
  40. package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
  41. package/dist/utility/chart/candle-bar-end.util.js +17 -6
  42. package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
  43. package/dist/utility/chart/chart-time-domain.util.js +13 -4
  44. package/dist/utility/chart/feed-interval.util.d.ts +4 -2
  45. package/dist/utility/chart/feed-interval.util.js +5 -2
  46. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
  47. package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
  48. package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
  49. package/dist/utility/chart/footprint-display-mode.util.js +5 -0
  50. package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
  51. package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
  52. package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
  53. package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
  54. package/dist/utility/chart/history-wall.util.d.ts +13 -2
  55. package/dist/utility/chart/history-wall.util.js +11 -4
  56. package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
  57. package/dist/utility/chart/interval-ladder.util.js +44 -4
  58. package/dist/utility/chart/interval-registry.util.d.ts +22 -1
  59. package/dist/utility/chart/interval-registry.util.js +50 -2
  60. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
  61. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
  62. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
  63. package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
  64. package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
  65. package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
  66. package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
  67. package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
  68. package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
  69. package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
  70. package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
  71. package/dist/utility/chart/live-bucket.util.d.ts +29 -4
  72. package/dist/utility/chart/live-bucket.util.js +45 -12
  73. package/dist/utility/chart/market-session.util.d.ts +62 -10
  74. package/dist/utility/chart/market-session.util.js +93 -13
  75. package/dist/utility/chart/marketKind.util.d.ts +1 -7
  76. package/dist/utility/chart/marketKind.util.js +6 -8
  77. package/dist/utility/chart/mixed-mode.util.d.ts +17 -0
  78. package/dist/utility/chart/om-target.util.js +6 -4
  79. package/dist/utility/chart/price-precision.util.d.ts +20 -6
  80. package/dist/utility/chart/price-precision.util.js +34 -7
  81. package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
  82. package/dist/utility/chart/profile-frame-window.util.js +12 -0
  83. package/dist/utility/chart/rth-session.util.d.ts +3 -1
  84. package/dist/utility/chart/rth-session.util.js +3 -1
  85. package/dist/utility/chart/script-source-session.util.d.ts +43 -0
  86. package/dist/utility/chart/script-source-session.util.js +61 -0
  87. package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
  88. package/dist/utility/chart/typed-width-grid.util.js +203 -0
  89. package/dist/utility/common/transformations.util.d.ts +6 -0
  90. package/dist/utility/common/transformations.util.js +28 -4
  91. package/dist/utility/number-format.util.d.ts +14 -1
  92. package/dist/utility/number-format.util.js +22 -4
  93. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
  94. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +113 -0
  95. package/dist/utility/v2/v2-enums.leaf.js +3 -0
  96. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +9 -3
  97. package/dist/utility/wrun/wrun-batched-marks.util.js +65 -17
  98. package/dist/utility/wrun/wrun-canvases.util.d.ts +4 -2
  99. package/dist/utility/wrun/wrun-canvases.util.js +7 -12
  100. package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
  101. package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
  102. package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
  103. package/dist/utility/wrun/wrun-card-style.util.js +2 -2
  104. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +8 -0
  105. package/dist/utility/wrun/wrun-chart-market-facts.util.js +13 -1
  106. package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
  107. package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
  108. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
  109. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
  110. package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
  111. package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
  112. package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
  113. package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
  114. package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
  115. package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
  116. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
  117. package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
  118. package/dist/utility/wrun/wrun-frames.d.ts +1 -1
  119. package/dist/utility/wrun/wrun-frames.js +2 -2
  120. package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
  121. package/dist/utility/wrun/wrun-handles.util.js +1 -1
  122. package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
  123. package/dist/utility/wrun/wrun-host.service.js +44 -2
  124. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
  125. package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
  126. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
  127. package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
  128. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
  129. package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
  130. package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
  131. package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
  132. package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
  133. package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
  134. package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
  135. package/dist/utility/wrun/wrun-live-tick.util.js +59 -4
  136. package/dist/utility/wrun/wrun-overlay-drivers.util.js +3 -0
  137. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +15 -0
  138. package/dist/utility/wrun/wrun-overlay-run.util.js +274 -47
  139. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +1 -1
  140. package/dist/utility/wrun/wrun-panel-mount.util.js +42 -13
  141. package/dist/utility/wrun/wrun-pin-venues.util.js +5 -1
  142. package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
  143. package/dist/utility/wrun/wrun-refusal.util.js +102 -13
  144. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
  145. package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
  146. package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
  147. package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
  148. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
  149. package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
  150. package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
  151. package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
  152. package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
  153. package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
  154. package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
  155. package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
  156. package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
  157. package/dist/utility/wrun/wrun-style-words.util.js +46 -15
  158. package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
  159. package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
  160. package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
  161. package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
  162. package/dist/utility/wrun-display-name.util.d.ts +10 -0
  163. package/dist/utility/wrun-display-name.util.js +21 -0
  164. package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
  165. package/dist/utils/replay/replay-buffer-math.js +2 -0
  166. package/dist/workers/constants/socket-slots.d.ts +1 -1
  167. package/dist/workers/utils/time.worker.util.js +2 -2
  168. package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
  169. package/dist/workers/utils/volume-profile.worker.util.js +20 -0
  170. package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
  171. package/dist/workers/wrun/wrun-abi-host.js +82 -5
  172. package/dist/workers/wrun/wrun-engine-handler.js +53 -4
  173. package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
  174. package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
  175. package/package.json +11 -11
@@ -25,10 +25,84 @@
25
25
  *
26
26
  * Worker-safe: no Vue, store or i18n imports (workers and the live-feed gates call these per row and per frame).
27
27
  */
28
- import { footprintFoldBucketEndMs, getRthWindowForSymbol, hasRthWindow, isChartRthActive, isIntradayIntervalMs, isRthSessionHoursActive, isWithinRthWindow, latestRthSessionBoundsAtOrBefore, rthAnchoredBucketEndMs, rthAnchoredBucketStartMs, rthBucketOverlapsSessionMs, rthSessionCloseMs, rthSessionOpenMs, rthWindowsInRange, sessionDayBoundsFor, } from './rth-session.util.js';
28
+ import { footprintFoldBucketEndMs, getRthWindowForSymbol, hasRthWindow, isChartRthActive, isIntradayIntervalMs, isRthSessionHoursActive, isWithinRthWindow, latestRthSessionBoundsAtOrBefore, rthAnchoredBucketEndMs, rthAnchoredBucketStartMs, rthBucketOverlapsSessionMs, rthEffectiveFetchTfMs, rthSessionCloseMs, rthSessionOpenMs, rthWindowsInRange, sessionDayBoundsFor, } from './rth-session.util.js';
29
29
  import { isEquityRegularSessionGated, US_EQUITIES_REGULAR_WINDOW, usEquityRegularWindowsInRange, } from './us-equities-session.util.js';
30
30
  import { checkIsPolygon } from './marketKind.util.js';
31
+ import { intervalLabelForMs } from './interval-registry.util.js';
31
32
  import { isStocksTapeGoverned } from '../v2/stocks-governed.util.js';
33
+ /**
34
+ * The day-and-longer widths whose US stock tape order flow (VOLUME_PROFILE_AGG) the gateway serves under the regular
35
+ * session, by label: its tradfi profile family reads DAY, WEEK and the calendar widths per trading session, and refuses
36
+ * THREE_DAYS (tsdb-gateway volume_profile_tradfi.go `tradfiVPProfile`). Every day-plus label the app offers has a row
37
+ * (tests/utility/chart/order-flow-session.interval-rule.spec.ts).
38
+ */
39
+ export const US_EQUITY_DAY_PLUS_REGULAR_ORDER_FLOW = Object.freeze({
40
+ '1d': true,
41
+ '3d': false,
42
+ '1w': true,
43
+ '1M': true,
44
+ '3M': true,
45
+ '6M': true,
46
+ '1Y': true,
47
+ });
48
+ /** Whether a US stock's order flow can be read under the regular session at `tfMs` (milliseconds): every intraday width, and the day-plus rows the gateway serves. */
49
+ export function isUsEquityRegularOrderFlowIntervalMs(tfMs) {
50
+ if (isIntradayIntervalMs(tfMs))
51
+ return true;
52
+ if (typeof tfMs !== 'number' || !(tfMs > 0))
53
+ return false;
54
+ const label = intervalLabelForMs(tfMs);
55
+ return label !== undefined && US_EQUITY_DAY_PLUS_REGULAR_ORDER_FLOW[label] === true;
56
+ }
57
+ /** A day or longer bar starts at midnight, outside every session, so its key cannot judge a trade: a session filter there reads each trade's own instant. */
58
+ export function sessionFilterJudgesTradeInstant(tfMs) {
59
+ return typeof tfMs === 'number' && tfMs > 0 && !isIntradayIntervalMs(tfMs);
60
+ }
61
+ /**
62
+ * Whether the gateway reads this stock order flow per trading session at `tfMs` (a day-plus chart width or span rung),
63
+ * so a REGULAR read keeps its midnight-stamped rows. tsdb-gateway `tradfiVPProfile` serves only a stock tape
64
+ * (kiyotaka-go venue `ProfileFor`), at DAY, WEEK and the calendar widths (`US_EQUITY_DAY_PLUS_REGULAR_ORDER_FLOW`), and
65
+ * excludes a USD-normalized read, a coin sum and a custom time range; no session-active VP read sends the last two.
66
+ * Anywhere else the fallback keeps a REGULAR bucket by its start, so every day row would be dropped.
67
+ */
68
+ export function readsUsEquitySessionPerTradingDay(read, tfMs) {
69
+ if (!read || !sessionFilterJudgesTradeInstant(tfMs) || !isUsEquityRegularOrderFlowIntervalMs(tfMs))
70
+ return false;
71
+ if (typeof read.exchange !== 'string' || !isStocksTapeGoverned(read.exchange))
72
+ return false;
73
+ return read.currency !== 'USD';
74
+ }
75
+ /** Whether a stock order-flow read at `readTfMs` can be held to the regular session: by bucket start below a day, else per trading session. */
76
+ export function isUsEquityRegularOrderFlowRead(read, readTfMs) {
77
+ return isIntradayIntervalMs(readTfMs) || readsUsEquitySessionPerTradingDay(read, readTfMs);
78
+ }
79
+ /**
80
+ * The wire width of a session-filtered order-flow read at `tfMs` (the chart width, or a fixed or developing profile's
81
+ * span rung) on a chart of `chartTfMs` (the read's own width when it is the chart's): the width itself where the
82
+ * gateway reads it per trading session AND the chart is day-plus, else the at-most-15m effective width (rth-session.util
83
+ * `rthEffectiveFetchTfMs`, on whose grid the opens and closes sit). A day row is stamped at midnight, so on an intraday
84
+ * chart it would lose a box's intraday edges: there a rung reads exactly as before the day-plus rule. The one width
85
+ * every fetch, row grid, live fold and cache identity of a session-active profile reads, so they cannot disagree.
86
+ */
87
+ export function regularSessionReadTfMs(tfMs, read, chartTfMs = tfMs) {
88
+ return sessionFilterJudgesTradeInstant(chartTfMs) && readsUsEquitySessionPerTradingDay(read, tfMs)
89
+ ? tfMs
90
+ : rthEffectiveFetchTfMs(tfMs);
91
+ }
92
+ /**
93
+ * Whether an overlay that reads at its own width `readTfMs` (a fixed or developing profile's span rung, or its live
94
+ * fold grid) is session-active on a chart of `chartTfMs`. Below a day the chart decides, exactly as before the day-plus
95
+ * rule; from a day up the read itself must be holdable to the regular session (`isUsEquityRegularOrderFlowRead`): an
96
+ * intraday read, or a per-session one.
97
+ */
98
+ export function isMarketSessionReadActive(settings, chartTfMs, chartRegularKind, readTfMs) {
99
+ return isMarketSessionHoursActive(settings, chartTfMs, chartRegularKind, sessionFilterJudgesTradeInstant(chartTfMs) ? readTfMs : chartTfMs);
100
+ }
101
+ /** A span-rung profile's whole session read (FRVP, DSP): whether it is session-active, and the width its rows are read, gridded and folded at. */
102
+ export function rungSessionRead(settings, chartTfMs, chartRegularKind, rungMs) {
103
+ const active = isMarketSessionReadActive(settings, chartTfMs, chartRegularKind, rungMs);
104
+ return { active, readTfMs: active ? regularSessionReadTfMs(rungMs, settings, chartTfMs) : rungMs };
105
+ }
32
106
  // ─── Markets and their regular session ───────────────────────────────────────
33
107
  /**
34
108
  * A US stock market: a Polygon listing code (marketKind.util `checkIsPolygon`: POLYGON, US_STOCKS, NYSE, NASDAQ,
@@ -85,18 +159,20 @@ export function marketHasRegularWindow(exchange, symbol) {
85
159
  }
86
160
  // ─── The chart's session and an overlay's ────────────────────────────────────
87
161
  /**
88
- * The regular session THIS chart draws at `chartTfMs` (milliseconds), for overlay purposes; intraday only:
89
- * 'cme' exactly when rth-session.util `isChartRthActive(exchange, symbol, sessionType, chartTfMs)`.
162
+ * The regular session THIS chart draws at `chartTfMs` (milliseconds), for overlay purposes:
163
+ * 'cme' exactly when rth-session.util `isChartRthActive(exchange, symbol, sessionType, chartTfMs)` (intraday).
90
164
  * 'us-equity' when the candles' own gate holds, us-equities-session.util
91
- * `isEquityRegularSessionGated(exchange, sessionType, chartTfMs)` (a Polygon listing whose word is not
92
- * an active 'extended'), at an intraday `chartTfMs`. A chart opened on a tape venue (NASDAQ_TAPE) has
93
- * no candle session handling, so it answers null, as it rides today.
94
- * null otherwise: an ETH or extended chart, a daily or longer interval, a label instead of milliseconds.
165
+ * `isEquityRegularSessionGated(exchange, sessionType, chartTfMs)` (the candle fetch's REGULAR: a Polygon
166
+ * listing whose word is not an active 'extended', and every daily and longer bar), at a width its order
167
+ * flow can follow (`isUsEquityRegularOrderFlowIntervalMs`: 3D cannot). A chart opened on a tape venue
168
+ * (NASDAQ_TAPE) has no candle session handling, so it answers null, as it rides today.
169
+ * null otherwise: an ETH or extended intraday chart, a CME daily chart, 3D, a label instead of milliseconds.
95
170
  */
96
171
  export function chartRegularSessionKind(exchange, symbol, sessionType, chartTfMs) {
97
172
  if (isChartRthActive(exchange, symbol, sessionType, chartTfMs))
98
173
  return 'cme';
99
- if (isIntradayIntervalMs(chartTfMs) && isEquityRegularSessionGated(exchange, sessionType, chartTfMs)) {
174
+ if (isUsEquityRegularOrderFlowIntervalMs(chartTfMs) &&
175
+ isEquityRegularSessionGated(exchange, sessionType, chartTfMs)) {
100
176
  return 'us-equity';
101
177
  }
102
178
  return null;
@@ -121,19 +197,23 @@ bag) {
121
197
  * CME exactly rth-session.util `isRthSessionHoursActive(settings, chartTfMs, chartRegularKind === 'cme')`:
122
198
  * an explicit 'rth' stays active on any chart (a stock, crypto or ETH chart included), 'eth' never
123
199
  * is, and the 'chart' default follows a CME RTH chart only.
124
- * US stock active exactly while the chart draws the US equities regular session at an intraday `chartTfMs`.
125
- * Stock overlays always follow the chart: their session row is hidden, so a persisted 'rth' or 'eth'
126
- * carried over from a futures chart is ignored.
200
+ * US stock active exactly while the chart draws the US equities regular session and the overlay's read can be held
201
+ * to it (`isUsEquityRegularOrderFlowRead` at `readTfMs`: any intraday read; from a day up only a stock
202
+ * tape in coins, read per trading session; a USD or listing-code read at 1D keeps all hours, as 3D does).
203
+ * Stock overlays always follow the chart:
204
+ * their session row is hidden, so a persisted 'rth' or 'eth' carried over from a futures chart is ignored.
127
205
  * any other never active (no window to filter on).
128
206
  */
129
- export function isMarketSessionHoursActive(settings, chartTfMs, chartRegularKind) {
207
+ export function isMarketSessionHoursActive(settings, chartTfMs, chartRegularKind,
208
+ // The width the overlay's rows are read at when it is not the chart's (a developing profile's intraday rung).
209
+ readTfMs = chartTfMs) {
130
210
  if (!settings)
131
211
  return false;
132
212
  switch (marketSessionKind(settings.exchange, settings.symbol)) {
133
213
  case 'cme':
134
214
  return isRthSessionHoursActive(settings, chartTfMs, chartRegularKind === 'cme');
135
215
  case 'us-equity':
136
- return chartRegularKind === 'us-equity' && isIntradayIntervalMs(chartTfMs);
216
+ return chartRegularKind === 'us-equity' && isUsEquityRegularOrderFlowRead(settings, readTfMs);
137
217
  default:
138
218
  return false;
139
219
  }
@@ -133,13 +133,7 @@ export declare function checkIsForexCommodityOrFutures(exchange: string | undefi
133
133
  * bars. FE-internal code always sees the honest venue kind.
134
134
  */
135
135
  export declare function toTitanMarketKind(kind: VenueMarketKind): MarketKind;
136
- /**
137
- * True when TitanCharts must omit the dedicated 'volume' legend overlay:
138
- * economic series, forex/commodity venues, the crypto indices and the
139
- * quote-priced perpetual venues ship no per-bar volume. Governed CME futures
140
- * DO ship contracts volume on TRADE_AGG bars, so they keep it.
141
- */
142
- export declare function venueOmitsVolumeOverlay(exchange: string | undefined | null): boolean;
136
+ export declare function venueOmitsVolumeOverlay(exchange: string | undefined | null, symbol?: string | null): boolean;
143
137
  export declare function checkIsDex(exchange: string | undefined | null): boolean;
144
138
  /**
145
139
  * Economic series venue: FRED, the ECONOMICS catalog venue and the observation
@@ -1,6 +1,6 @@
1
1
  import { MARKET_CAPABILITIES, ONCHAIN_POOL_CAPABILITIES, } from '../../constants/marketCapabilities.constants.js';
2
2
  import { isBlkExchange } from '../blk-market.util.js';
3
- import { ECONOMIC_EXCHANGES, FRED_EXCHANGE } from '../../constants/economic.constants.js';
3
+ import { ECONOMIC_EXCHANGES, FRED_EXCHANGE, PUBLISHER_ONLY_EXCHANGES } from '../../constants/economic.constants.js';
4
4
  import { CRYPTO_INDEX_EXCHANGES } from './crypto-index.leaf.js';
5
5
  import { QUOTE_PERP_EXCHANGES } from './quote-perp.leaf.js';
6
6
  import { isCmeGoverned, normalizeExchangeCode } from './cme-realtime.util.js';
@@ -83,6 +83,8 @@ const EXCHANGE_TO_KIND = {
83
83
  // Economic series: FRED plus the ECONOMICS catalog venue and the observation
84
84
  // publishers (economic.constants.ts owns the list).
85
85
  ...Object.fromEntries(ECONOMIC_EXCHANGES.map((code) => [code, 'economic'])),
86
+ // A publisher with no market would otherwise default to a crypto venue with a book.
87
+ ...Object.fromEntries([...PUBLISHER_ONLY_EXCHANGES].map((code) => [code, 'economic'])),
86
88
  // Crypto-wide indices (CRYPTOCAP): value prints 24/7 with no trades,
87
89
  // volume or book behind them (crypto-index.leaf owns the list).
88
90
  ...Object.fromEntries(CRYPTO_INDEX_EXCHANGES.map((code) => [code, 'cryptoIndex'])),
@@ -311,13 +313,9 @@ export function toTitanMarketKind(kind) {
311
313
  return 'crypto';
312
314
  return kind;
313
315
  }
314
- /**
315
- * True when TitanCharts must omit the dedicated 'volume' legend overlay:
316
- * economic series, forex/commodity venues, the crypto indices and the
317
- * quote-priced perpetual venues ship no per-bar volume. Governed CME futures
318
- * DO ship contracts volume on TRADE_AGG bars, so they keep it.
319
- */
320
- export function venueOmitsVolumeOverlay(exchange) {
316
+ export function venueOmitsVolumeOverlay(exchange, symbol) {
317
+ if (isOmTargetPane({ exchange, symbol }))
318
+ return true;
321
319
  if (checkIsEconomic(exchange) || checkIsForexOrCommodity(exchange))
322
320
  return true;
323
321
  const kind = getMarketKind(exchange);
@@ -68,6 +68,23 @@ export interface BaseOhlcvPayload {
68
68
  tailBoot?: boolean;
69
69
  sided?: boolean;
70
70
  category?: number;
71
+ typedFold?: TypedFoldAsk;
72
+ }
73
+ /** The fold a custom size the app builds asks of the worker: types only, so the boot path carries none of it. */
74
+ export interface TypedFoldAsk {
75
+ /** The served interval the rows are read at (typed-width-source.leaf). */
76
+ sourceLabel: string;
77
+ /** The most source rows one custom bar holds. */
78
+ rowsPerBar: number;
79
+ /** The custom size's length. */
80
+ widthMs: number;
81
+ /** The chart's market, which names its grid (typed-width-grid.util): the fields of live-bucket.util `LiveBucketVenue`. */
82
+ venue: {
83
+ exchange?: unknown;
84
+ symbol?: unknown;
85
+ sessionType?: unknown;
86
+ transformations?: unknown;
87
+ };
71
88
  }
72
89
  /**
73
90
  * Payload for pure timestamp-mode fetching
@@ -2,7 +2,7 @@ import { Intervals } from '../../constants/interval.constants.js';
2
2
  import { intervalLabelForMs } from './interval-ladder.util.js';
3
3
  export const TARGET_EXCHANGE = 'OM';
4
4
  export const OM_MAIN_CADENCES = [60, 300, 900, 1800, 3600, 14400, 86400, 604800];
5
- const FEED_TARGET_SYMBOL = /^feed:(@[a-z0-9_-]+\/[a-z0-9][a-z0-9._-]{0,63})(?:#([^\s#]+))?$/;
5
+ const FEED_TARGET_SYMBOL = /^feed:([a-z0-9_-]+\/[a-z0-9][a-z0-9._-]{0,63})(?::([a-z][a-z0-9_]{0,23}))?$/;
6
6
  function parseOmTargetSymbol(symbol) {
7
7
  if (typeof symbol !== 'string')
8
8
  return null;
@@ -11,14 +11,16 @@ function parseOmTargetSymbol(symbol) {
11
11
  if (symbol.startsWith('panel:'))
12
12
  return { kind: 'panel', id: symbol.slice('panel:'.length) };
13
13
  const feed = FEED_TARGET_SYMBOL.exec(symbol);
14
- return feed ? { kind: 'feed', address: feed[1], column: feed[2] ?? '' } : null;
14
+ return feed ? { kind: 'feed', address: `@${feed[1]}`, column: feed[2] ?? '' } : null;
15
15
  }
16
16
  export function parseOmTarget(metadata) {
17
17
  return metadata?.exchange === TARGET_EXCHANGE ? parseOmTargetSymbol(metadata?.symbol) : null;
18
18
  }
19
19
  export function omTargetSymbol(target) {
20
- if (target.kind === 'feed')
21
- return target.column ? `feed:${target.address}#${target.column}` : `feed:${target.address}`;
20
+ if (target.kind === 'feed') {
21
+ const path = target.address.replace(/^@/, '');
22
+ return target.column ? `feed:${path}:${target.column}` : `feed:${path}`;
23
+ }
22
24
  return `${target.kind}:${target.id}`;
23
25
  }
24
26
  export function isOmTargetSymbol(symbol) {
@@ -28,13 +28,27 @@ export declare function resolvePriceDisplayPrecision(exchange: string | undefine
28
28
  export declare function pricePrecisionFromStep(step: number | undefined | null, mode?: 'axis' | 'step'): number;
29
29
  /**
30
30
  * The decimals the chart's MAIN price scale prints at (axis ticks, crosshair
31
- * pill, last-price pill, legend). An engine that holds the instrument tick
32
- * steps that axis on tick multiples and rounds the crosshair to the tick, so
33
- * the tick's own decimals are exact (ES 2, YM 0, ZN 6) and the axis look's
34
- * extra decimal would only print dust ("7784.250"). Without a tick the
35
- * axis-step rule stands. HIP-4's display decimals win either way.
31
+ * pill, last-price pill, legend) at Value Precision "Default". An engine that
32
+ * holds the instrument tick steps that axis on tick multiples and rounds the
33
+ * crosshair to the tick, so the tick's own decimals are exact (ES 2, YM 0,
34
+ * ZN 6) and the axis look's extra decimal would only print dust ("7784.250").
35
+ *
36
+ * Without an engine tick, the one market decimals resolver
37
+ * (market-price-text.util) answers in two parts, and only a TICK may lower the
38
+ * chart below its axis-step rule:
39
+ * - `tickDecimals`, a real tick's decimals (a crypto venue tick, a CME tick
40
+ * the engine does not hold): they decide, so BINANCE_FUTURES BTCUSDT (tick
41
+ * 0.1) reads 73686.1 on the legend, not 73686.10. The engine does not step
42
+ * this axis on that tick, so a step finer than it (a deep zoom) keeps the
43
+ * decimals the step itself needs, and neighbouring labels never collide;
44
+ * - `observedDecimals`, the most decimals the market's traded prices carried
45
+ * this session: they may only RAISE the axis-step rule. They can under-read
46
+ * (a first price at 73741.50 says 1 of a market that trades in cents), and
47
+ * the legend must never drop a digit of a real close.
48
+ * With neither, the axis-step rule stands. HIP-4's display decimals win every
49
+ * time.
36
50
  */
37
- export declare function resolveChartPricePrecision(exchange: string | undefined | null, axisStep: number | undefined | null, priceTick: number | undefined | null): number;
51
+ export declare function resolveChartPricePrecision(exchange: string | undefined | null, axisStep: number | undefined | null, priceTick: number | undefined | null, tickDecimals?: number | null, observedDecimals?: number | null): number;
38
52
  /** Profile levels use the resolved prediction grid; pending grids use venue display precision. */
39
53
  export declare function resolveProfilePricePrecision(exchange: string | undefined | null, blockSize: number | undefined | null, fallbackDigits?: number): number;
40
54
  export { formatPriceByMagnitude } from '../number-format.util.js';
@@ -46,17 +46,44 @@ export function pricePrecisionFromStep(step, mode = 'axis') {
46
46
  }
47
47
  /**
48
48
  * The decimals the chart's MAIN price scale prints at (axis ticks, crosshair
49
- * pill, last-price pill, legend). An engine that holds the instrument tick
50
- * steps that axis on tick multiples and rounds the crosshair to the tick, so
51
- * the tick's own decimals are exact (ES 2, YM 0, ZN 6) and the axis look's
52
- * extra decimal would only print dust ("7784.250"). Without a tick the
53
- * axis-step rule stands. HIP-4's display decimals win either way.
49
+ * pill, last-price pill, legend) at Value Precision "Default". An engine that
50
+ * holds the instrument tick steps that axis on tick multiples and rounds the
51
+ * crosshair to the tick, so the tick's own decimals are exact (ES 2, YM 0,
52
+ * ZN 6) and the axis look's extra decimal would only print dust ("7784.250").
53
+ *
54
+ * Without an engine tick, the one market decimals resolver
55
+ * (market-price-text.util) answers in two parts, and only a TICK may lower the
56
+ * chart below its axis-step rule:
57
+ * - `tickDecimals`, a real tick's decimals (a crypto venue tick, a CME tick
58
+ * the engine does not hold): they decide, so BINANCE_FUTURES BTCUSDT (tick
59
+ * 0.1) reads 73686.1 on the legend, not 73686.10. The engine does not step
60
+ * this axis on that tick, so a step finer than it (a deep zoom) keeps the
61
+ * decimals the step itself needs, and neighbouring labels never collide;
62
+ * - `observedDecimals`, the most decimals the market's traded prices carried
63
+ * this session: they may only RAISE the axis-step rule. They can under-read
64
+ * (a first price at 73741.50 says 1 of a market that trades in cents), and
65
+ * the legend must never drop a digit of a real close.
66
+ * With neither, the axis-step rule stands. HIP-4's display decimals win every
67
+ * time.
54
68
  */
55
- export function resolveChartPricePrecision(exchange, axisStep, priceTick) {
69
+ export function resolveChartPricePrecision(exchange, axisStep, priceTick, tickDecimals, observedDecimals) {
56
70
  const hasTick = typeof priceTick === 'number' && Number.isFinite(priceTick) && priceTick > 0;
57
- const venueDecimals = hasTick ? pricePrecisionFromStep(priceTick, 'step') : pricePrecisionFromStep(axisStep);
71
+ const tick = wholeDecimals(tickDecimals);
72
+ const venueDecimals = hasTick
73
+ ? pricePrecisionFromStep(priceTick, 'step')
74
+ : tick !== null
75
+ ? Math.max(tick, stepDecimals(axisStep))
76
+ : Math.max(wholeDecimals(observedDecimals) ?? 0, pricePrecisionFromStep(axisStep));
58
77
  return resolvePriceDisplayPrecision(exchange, venueDecimals);
59
78
  }
79
+ /** A decimals count the axis can print (0 to 10), else null. */
80
+ function wholeDecimals(decimals) {
81
+ return typeof decimals === 'number' && Number.isInteger(decimals) && decimals >= 0 ? Math.min(decimals, 10) : null;
82
+ }
83
+ /** The decimals an axis step needs to print distinct labels (none for a missing step). */
84
+ function stepDecimals(step) {
85
+ return typeof step === 'number' && Number.isFinite(step) && step > 0 ? pricePrecisionFromStep(step, 'step') : 0;
86
+ }
60
87
  /** Profile levels use the resolved prediction grid; pending grids use venue display precision. */
61
88
  export function resolveProfilePricePrecision(exchange, blockSize, fallbackDigits = 2) {
62
89
  if (!isPredictionExchangeName(exchange))
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A live volume-profile frame's stamp is the exclusive END of its fold window (seconds plus fixed32 nanoseconds). The
3
+ * one reader of that stamp for the footprint's live store and the wrun intake's session check, so a frame closing on
4
+ * the session's edge is judged by an instant inside its own window on both.
5
+ */
6
+ export interface ProfileFrameStampLike {
7
+ timestamp?: {
8
+ seconds?: unknown;
9
+ nanoseconds?: unknown;
10
+ } | null;
11
+ }
12
+ /** The END of a frame's fold window, epoch ms (absent fixed32 nanoseconds read as 0); null when unstamped. */
13
+ export declare function profileFrameWindowEndMs(aggregation: ProfileFrameStampLike | null | undefined): number | null;
14
+ /** The last instant inside a frame's window (its end minus 1 ms): a window closing on a boundary belongs before it. */
15
+ export declare function profileFrameLastInstantMs(aggregation: ProfileFrameStampLike | null | undefined): number | null;
@@ -0,0 +1,12 @@
1
+ /** The END of a frame's fold window, epoch ms (absent fixed32 nanoseconds read as 0); null when unstamped. */
2
+ export function profileFrameWindowEndMs(aggregation) {
3
+ const seconds = aggregation?.timestamp?.seconds;
4
+ if (seconds === undefined || seconds === null)
5
+ return null;
6
+ return Number(seconds) * 1000 + Math.floor((Number(aggregation?.timestamp?.nanoseconds ?? 0) || 0) / 1e6);
7
+ }
8
+ /** The last instant inside a frame's window (its end minus 1 ms): a window closing on a boundary belongs before it. */
9
+ export function profileFrameLastInstantMs(aggregation) {
10
+ const endMs = profileFrameWindowEndMs(aggregation);
11
+ return endMs === null ? null : endMs - 1;
12
+ }
@@ -162,7 +162,9 @@ export declare function isRthSessionHoursActive(settings: RthSessionSettingsLike
162
162
  * finer tier and refuses a trading-hour plan at a rolled width ("trading
163
163
  * hour sessions are not served at this interval"), and a 2m or 10m bucket
164
164
  * would straddle the 16:15 close anyway. Every result is a natively served
165
- * width (1m / 5m / 15m).
165
+ * width (1m / 5m / 15m). Width-only on purpose: a day-plus read that the
166
+ * gateway serves per trading session (a US stock tape) passes through
167
+ * market-session.util `regularSessionReadTfMs`, which knows the market.
166
168
  */
167
169
  export declare function rthEffectiveFetchTfMs(chartTfMs: number): number;
168
170
  /**
@@ -389,7 +389,9 @@ const RTH_EFFECTIVE_FETCH_MAX_TF_MS = Intervals.map_unit['15m'];
389
389
  * finer tier and refuses a trading-hour plan at a rolled width ("trading
390
390
  * hour sessions are not served at this interval"), and a 2m or 10m bucket
391
391
  * would straddle the 16:15 close anyway. Every result is a natively served
392
- * width (1m / 5m / 15m).
392
+ * width (1m / 5m / 15m). Width-only on purpose: a day-plus read that the
393
+ * gateway serves per trading session (a US stock tape) passes through
394
+ * market-session.util `regularSessionReadTfMs`, which knows the market.
393
395
  */
394
396
  export function rthEffectiveFetchTfMs(chartTfMs) {
395
397
  if (!Number.isFinite(chartTfMs) || chartTfMs <= 0)
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The session a script's trade-level data source reads on the chart it runs on: the one decision the source sender
3
+ * (titan-charts `acquireKScriptSourceData`, the request payload's `sessionHours` and the fetch ledger's tag), the
4
+ * workers and the live fold (the wrun intake: no app code calls the kScript data controls' live merge, the browser
5
+ * engine is retired) read, so a print or a profile frame is kept or dropped by the same rule on history and live.
6
+ *
7
+ * - `trades` (K_TRADES, Big Trades' tape): the candle's own session. A US stock chart whose candles are regular
8
+ * (us-equities-session.util `isEquityRegularSessionGated`: every daily and longer bar, an intraday chart not in
9
+ * extended hours) keeps a print only inside 09:30 to 16:00 New York; extended-hours intraday keeps every print.
10
+ * - `volume_profile` (K_VOLUME_PROFILE, Volume Bubbles' and Bar Statistics' per-bar ladder): the footprint's day-plus
11
+ * rule (footprint-rth-request.util): a stock tape read at 1D, 1W or a month on a regular chart reads the regular
12
+ * session per trading day. The gateway serves that read in coins only, so a dollar source reads coins and the worker
13
+ * prices each cell at its midpoint. Intraday widths and 3D read as before.
14
+ * Every other source, market and chart: no field, so its request and identities stay byte-identical.
15
+ */
16
+ import { SESSION_HOURS_RTH } from './rth-session.util.js';
17
+ /** The chart a source runs on, as its metadata or a wrun live market names it. */
18
+ export interface ScriptSourceChartLike {
19
+ exchange?: unknown;
20
+ symbol?: unknown;
21
+ sessionType?: unknown;
22
+ }
23
+ /** The market a source reads (its resolved exchange and symbol: a Trades chart's tape). */
24
+ export interface ScriptSourceMarketLike {
25
+ exchange?: unknown;
26
+ symbol?: unknown;
27
+ }
28
+ /** The K_TRADES tape's session on a chart of `chartTfMs`: 'rth' where the candle is regular and the tape a US stock's. */
29
+ export declare function tapeSourceSessionHours(chart: ScriptSourceChartLike | null | undefined, chartTfMs: unknown, source: ScriptSourceMarketLike | null | undefined): typeof SESSION_HOURS_RTH | undefined;
30
+ /** The K_VOLUME_PROFILE ladder's session at `readTfMs` on a chart of `chartTfMs`: 'rth' on a stock tape's day-plus read
31
+ * under a regular chart (the footprint's rule, judged in coins: the read the gateway holds to the session). */
32
+ export declare function volumeProfileSourceSessionHours(chart: ScriptSourceChartLike | null | undefined, chartTfMs: unknown, readTfMs: unknown, source: ScriptSourceMarketLike | null | undefined): typeof SESSION_HOURS_RTH | undefined;
33
+ /** The session field a kScript source type's request carries, or undefined for every type and chart that has none. */
34
+ export declare function scriptSourceSessionHours(kScriptType: string, chart: ScriptSourceChartLike | null | undefined, chartTfMs: unknown, readTfMs: unknown, source: ScriptSourceMarketLike | null | undefined): typeof SESSION_HOURS_RTH | undefined;
35
+ /** The fetch ledger's name for a source read: the session rides it, so a session-held read never dedupes against an
36
+ * all-hours one of the same window; a read with no session keeps its own name. */
37
+ export declare function scriptSourceLedgerName(sourceName: string, sessionHours: string | undefined): string;
38
+ /** Whether an instant on `exchange|symbol` belongs to a read of `sessionHours`: always on an all-hours read, inside the
39
+ * market's regular window on an 'rth' one. The one per-print and per-frame check of the history workers and live folds. */
40
+ export declare function isInScriptSourceSession(sessionHours: unknown, exchange: unknown, symbol: unknown, tsMs: number): boolean;
41
+ /** Whether a live ladder frame stamped `tsMs` folds on a chart of `chartTfMs`: a day-plus bar of a regular stock chart
42
+ * holds only frames inside the regular session, as its history read does; every other chart folds every frame. */
43
+ export declare function isVolumeProfileLiveFrameInSession(chart: ScriptSourceChartLike | null | undefined, chartTfMs: unknown, tsMs: number): boolean;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * The session a script's trade-level data source reads on the chart it runs on: the one decision the source sender
3
+ * (titan-charts `acquireKScriptSourceData`, the request payload's `sessionHours` and the fetch ledger's tag), the
4
+ * workers and the live fold (the wrun intake: no app code calls the kScript data controls' live merge, the browser
5
+ * engine is retired) read, so a print or a profile frame is kept or dropped by the same rule on history and live.
6
+ *
7
+ * - `trades` (K_TRADES, Big Trades' tape): the candle's own session. A US stock chart whose candles are regular
8
+ * (us-equities-session.util `isEquityRegularSessionGated`: every daily and longer bar, an intraday chart not in
9
+ * extended hours) keeps a print only inside 09:30 to 16:00 New York; extended-hours intraday keeps every print.
10
+ * - `volume_profile` (K_VOLUME_PROFILE, Volume Bubbles' and Bar Statistics' per-bar ladder): the footprint's day-plus
11
+ * rule (footprint-rth-request.util): a stock tape read at 1D, 1W or a month on a regular chart reads the regular
12
+ * session per trading day. The gateway serves that read in coins only, so a dollar source reads coins and the worker
13
+ * prices each cell at its midpoint. Intraday widths and 3D read as before.
14
+ * Every other source, market and chart: no field, so its request and identities stay byte-identical.
15
+ */
16
+ import { SESSION_HOURS_RTH } from './rth-session.util.js';
17
+ import { isEquityRegularSessionGated } from './us-equities-session.util.js';
18
+ import { chartRegularSessionKind, isMarketSessionHoursActive, isWithinMarketRegularWindow, marketSessionKind, sessionFilterJudgesTradeInstant, } from './market-session.util.js';
19
+ /** The K_TRADES tape's session on a chart of `chartTfMs`: 'rth' where the candle is regular and the tape a US stock's. */
20
+ export function tapeSourceSessionHours(chart, chartTfMs, source) {
21
+ if (!chart || !source || !isEquityRegularSessionGated(chart.exchange, chart.sessionType, chartTfMs))
22
+ return undefined;
23
+ return marketSessionKind(source.exchange, source.symbol) === 'us-equity' ? SESSION_HOURS_RTH : undefined;
24
+ }
25
+ /** The K_VOLUME_PROFILE ladder's session at `readTfMs` on a chart of `chartTfMs`: 'rth' on a stock tape's day-plus read
26
+ * under a regular chart (the footprint's rule, judged in coins: the read the gateway holds to the session). */
27
+ export function volumeProfileSourceSessionHours(chart, chartTfMs, readTfMs, source) {
28
+ if (!chart || !source || !sessionFilterJudgesTradeInstant(chartTfMs) || !sessionFilterJudgesTradeInstant(readTfMs)) {
29
+ return undefined;
30
+ }
31
+ const chartKind = chartRegularSessionKind(chart.exchange, chart.symbol, chart.sessionType, chartTfMs);
32
+ const read = { exchange: source.exchange, symbol: source.symbol };
33
+ return isMarketSessionHoursActive(read, chartTfMs, chartKind, readTfMs) ? SESSION_HOURS_RTH : undefined;
34
+ }
35
+ /** The session field a kScript source type's request carries, or undefined for every type and chart that has none. */
36
+ export function scriptSourceSessionHours(kScriptType, chart, chartTfMs, readTfMs, source) {
37
+ if (kScriptType === 'K_TRADES')
38
+ return tapeSourceSessionHours(chart, chartTfMs, source);
39
+ if (kScriptType === 'K_VOLUME_PROFILE')
40
+ return volumeProfileSourceSessionHours(chart, chartTfMs, readTfMs, source);
41
+ return undefined;
42
+ }
43
+ /** The fetch ledger's name for a source read: the session rides it, so a session-held read never dedupes against an
44
+ * all-hours one of the same window; a read with no session keeps its own name. */
45
+ export function scriptSourceLedgerName(sourceName, sessionHours) {
46
+ return sessionHours === undefined ? sourceName : `${sourceName}@th-${sessionHours}`;
47
+ }
48
+ /** Whether an instant on `exchange|symbol` belongs to a read of `sessionHours`: always on an all-hours read, inside the
49
+ * market's regular window on an 'rth' one. The one per-print and per-frame check of the history workers and live folds. */
50
+ export function isInScriptSourceSession(sessionHours, exchange, symbol, tsMs) {
51
+ return sessionHours !== SESSION_HOURS_RTH || isWithinMarketRegularWindow(exchange, symbol, tsMs);
52
+ }
53
+ /** Whether a live ladder frame stamped `tsMs` folds on a chart of `chartTfMs`: a day-plus bar of a regular stock chart
54
+ * holds only frames inside the regular session, as its history read does; every other chart folds every frame. */
55
+ export function isVolumeProfileLiveFrameInSession(chart, chartTfMs, tsMs) {
56
+ if (!chart || !sessionFilterJudgesTradeInstant(chartTfMs))
57
+ return true;
58
+ if (chartRegularSessionKind(chart.exchange, chart.symbol, chart.sessionType, chartTfMs) !== 'us-equity')
59
+ return true;
60
+ return isWithinMarketRegularWindow(chart.exchange, chart.symbol, tsMs);
61
+ }
@@ -0,0 +1,23 @@
1
+ import type { LiveBucketVenue } from './live-bucket.util.js';
2
+ /** The grid a custom size rides on a market. */
3
+ export type TypedGridKind = 'utc' | 'cme-session' | 'cme-regular' | 'equity-regular' | 'equity-extended' | 'options' | 'forex';
4
+ /**
5
+ * Which grid a custom size of `widthMs` rides on the chart's market. The order mirrors live-bucket.util
6
+ * `liveBucketGrid`: the chart's CME regular-hours switch first, then the regular-session stock gate, then the session
7
+ * lattice of the exchange. A US option (OPRA) rides its own 09:30 to 16:15 window. A stock tape
8
+ * venue (NASDAQ_TAPE) and the other listing codes the candle gate does not name ride the UTC grid, as their fixed
9
+ * sizes do today. A formula chart (`venue.transformations` with more than one leg) is refused upstream until the
10
+ * formula phase, so it is read here by its `exchange` alone.
11
+ */
12
+ export declare function typedGridKind(widthMs: number, venue: LiveBucketVenue | null | undefined): TypedGridKind;
13
+ /**
14
+ * The stamp of the custom bar that holds `tsMs`, or null when the market holds no bar there (outside its session).
15
+ * `tsMs` is an instant inside the bar or the stamp of a source row the bar is built from; both give the same stamp.
16
+ */
17
+ export declare function typedBarStartMs(tsMs: number, widthMs: number, venue: LiveBucketVenue | null | undefined): number | null;
18
+ /**
19
+ * The first instant the bar stamped `barMs` no longer takes rows: the next bar's open, or the session close when the
20
+ * bar is the session's short last one. The stock sessions model no early closes (ny-calendar.util has no half days),
21
+ * so an early close's last bar keeps its full-session end; its rows simply stop.
22
+ */
23
+ export declare function typedBarEndMs(barMs: number, widthMs: number, venue: LiveBucketVenue | null | undefined): number;