@orangecharts/wrun-chart-host 0.15.0 → 0.17.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 (202) hide show
  1. package/README.md +2 -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 +13 -5
  5. package/dist/constants/feature-flags.constants.js +76 -35
  6. package/dist/constants/feature-limits.constants.d.ts +72 -4
  7. package/dist/constants/feature-limits.constants.js +104 -24
  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/marketCapabilities.constants.d.ts +9 -0
  12. package/dist/constants/marketCapabilities.constants.js +39 -11
  13. package/dist/constants/typed-indicator-source.leaf.d.ts +7 -0
  14. package/dist/constants/typed-indicator-source.leaf.js +47 -0
  15. package/dist/constants/typed-session-history-venue.leaf.d.ts +7 -0
  16. package/dist/constants/typed-session-history-venue.leaf.js +9 -0
  17. package/dist/constants/typed-width-fold.leaf.d.ts +52 -0
  18. package/dist/constants/typed-width-fold.leaf.js +101 -0
  19. package/dist/constants/typed-width-source.leaf.d.ts +24 -0
  20. package/dist/constants/typed-width-source.leaf.js +126 -0
  21. package/dist/constants/typed-width.leaf.d.ts +57 -0
  22. package/dist/constants/typed-width.leaf.js +78 -0
  23. package/dist/host-env.d.ts +10 -0
  24. package/dist/host-env.js +7 -0
  25. package/dist/host-ports.types.d.ts +23 -17
  26. package/dist/index.d.ts +4 -0
  27. package/dist/index.js +4 -0
  28. package/dist/interfaces/kscript-diagnostics.interface.d.ts +35 -0
  29. package/dist/interfaces/wrun-runtime.interface.d.ts +66 -3
  30. package/dist/interfaces/wrun-runtime.interface.js +11 -0
  31. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
  32. package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
  33. package/dist/market-data/billing.interface.d.ts +12 -45
  34. package/dist/market-data/billing.interface.js +2 -2
  35. package/dist/replay/replayLadder.js +7 -4
  36. package/dist/settings-templates/footprint-rows.d.ts +6 -0
  37. package/dist/settings-templates/footprint-rows.js +6 -0
  38. package/dist/settings-templates/frvp-fields.js +14 -0
  39. package/dist/settings-templates/indicator-fields.js +36 -0
  40. package/dist/settings-templates/tool-tables.generated.js +19 -1
  41. package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
  42. package/dist/utility/chart/cache-alignment.util.d.ts +42 -0
  43. package/dist/utility/chart/cache-alignment.util.js +88 -18
  44. package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
  45. package/dist/utility/chart/calendar-interval.util.js +152 -4
  46. package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
  47. package/dist/utility/chart/candle-bar-end.util.js +17 -6
  48. package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
  49. package/dist/utility/chart/chart-time-domain.util.js +13 -4
  50. package/dist/utility/chart/feed-interval.util.d.ts +4 -2
  51. package/dist/utility/chart/feed-interval.util.js +5 -2
  52. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
  53. package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
  54. package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
  55. package/dist/utility/chart/footprint-display-mode.util.js +5 -0
  56. package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
  57. package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
  58. package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
  59. package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
  60. package/dist/utility/chart/history-wall.util.d.ts +13 -2
  61. package/dist/utility/chart/history-wall.util.js +11 -4
  62. package/dist/utility/chart/index-mode-admission.util.js +9 -1
  63. package/dist/utility/chart/index-mode.util.d.ts +2 -2
  64. package/dist/utility/chart/index-mode.util.js +12 -6
  65. package/dist/utility/chart/index-otc.leaf.d.ts +37 -0
  66. package/dist/utility/chart/index-otc.leaf.js +68 -0
  67. package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
  68. package/dist/utility/chart/interval-ladder.util.js +44 -4
  69. package/dist/utility/chart/interval-registry.util.d.ts +22 -1
  70. package/dist/utility/chart/interval-registry.util.js +50 -2
  71. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
  72. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
  73. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
  74. package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
  75. package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
  76. package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
  77. package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
  78. package/dist/utility/chart/kscript-provenance-keys.util.js +6 -0
  79. package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
  80. package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
  81. package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
  82. package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
  83. package/dist/utility/chart/live-bucket.util.d.ts +29 -4
  84. package/dist/utility/chart/live-bucket.util.js +45 -12
  85. package/dist/utility/chart/market-session-schedule.util.d.ts +19 -0
  86. package/dist/utility/chart/market-session-schedule.util.js +2 -1
  87. package/dist/utility/chart/market-session.util.d.ts +62 -10
  88. package/dist/utility/chart/market-session.util.js +93 -13
  89. package/dist/utility/chart/marketKind.util.d.ts +11 -12
  90. package/dist/utility/chart/marketKind.util.js +45 -13
  91. package/dist/utility/chart/mixed-mode.util.d.ts +18 -0
  92. package/dist/utility/chart/om-target.util.js +6 -4
  93. package/dist/utility/chart/price-precision.util.d.ts +20 -6
  94. package/dist/utility/chart/price-precision.util.js +34 -7
  95. package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
  96. package/dist/utility/chart/profile-frame-window.util.js +12 -0
  97. package/dist/utility/chart/rth-session.util.d.ts +3 -1
  98. package/dist/utility/chart/rth-session.util.js +3 -1
  99. package/dist/utility/chart/script-source-session.util.d.ts +43 -0
  100. package/dist/utility/chart/script-source-session.util.js +61 -0
  101. package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
  102. package/dist/utility/chart/typed-width-grid.util.js +203 -0
  103. package/dist/utility/common/transformations.util.d.ts +6 -0
  104. package/dist/utility/common/transformations.util.js +28 -4
  105. package/dist/utility/market-events/market-events.util.js +3 -0
  106. package/dist/utility/number-format.util.d.ts +14 -1
  107. package/dist/utility/number-format.util.js +22 -4
  108. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
  109. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +115 -0
  110. package/dist/utility/v2/v2-enums.leaf.js +5 -0
  111. package/dist/utility/wrun/sources/row-lanes/dark_pool.d.ts +2 -1
  112. package/dist/utility/wrun/sources/row-lanes/dark_pool.js +4 -3
  113. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +13 -3
  114. package/dist/utility/wrun/wrun-batched-marks.util.js +96 -17
  115. package/dist/utility/wrun/wrun-canvases.util.d.ts +4 -2
  116. package/dist/utility/wrun/wrun-canvases.util.js +7 -12
  117. package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
  118. package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
  119. package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
  120. package/dist/utility/wrun/wrun-card-style.util.js +2 -2
  121. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +23 -8
  122. package/dist/utility/wrun/wrun-chart-market-facts.util.js +24 -9
  123. package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
  124. package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
  125. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
  126. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
  127. package/dist/utility/wrun/wrun-cme-root-specs.util.d.ts +10 -6
  128. package/dist/utility/wrun/wrun-cme-root-specs.util.js +19 -13
  129. package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
  130. package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
  131. package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
  132. package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
  133. package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
  134. package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
  135. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
  136. package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
  137. package/dist/utility/wrun/wrun-frames.d.ts +1 -1
  138. package/dist/utility/wrun/wrun-frames.js +2 -2
  139. package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
  140. package/dist/utility/wrun/wrun-handles.util.js +1 -1
  141. package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
  142. package/dist/utility/wrun/wrun-host.service.js +44 -2
  143. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
  144. package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
  145. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
  146. package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
  147. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
  148. package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
  149. package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
  150. package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
  151. package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
  152. package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
  153. package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
  154. package/dist/utility/wrun/wrun-live-tick.util.js +64 -5
  155. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +40 -6
  156. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +2 -2
  157. package/dist/utility/wrun/wrun-market-size-defaults.util.js +10 -8
  158. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +3 -0
  159. package/dist/utility/wrun/wrun-overlay-drivers.util.js +3 -0
  160. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +17 -0
  161. package/dist/utility/wrun/wrun-overlay-run.util.js +318 -55
  162. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +1 -1
  163. package/dist/utility/wrun/wrun-panel-mount.util.js +42 -13
  164. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +3 -2
  165. package/dist/utility/wrun/wrun-pin-venues.util.js +11 -4
  166. package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
  167. package/dist/utility/wrun/wrun-refusal.util.js +102 -13
  168. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
  169. package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
  170. package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
  171. package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
  172. package/dist/utility/wrun/wrun-run-health.util.js +1 -1
  173. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
  174. package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
  175. package/dist/utility/wrun/wrun-session-composition.util.d.ts +3 -2
  176. package/dist/utility/wrun/wrun-session-composition.util.js +3 -2
  177. package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
  178. package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
  179. package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
  180. package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
  181. package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
  182. package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
  183. package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
  184. package/dist/utility/wrun/wrun-style-words.util.js +46 -15
  185. package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
  186. package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
  187. package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
  188. package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
  189. package/dist/utility/wrun-display-name.util.d.ts +10 -0
  190. package/dist/utility/wrun-display-name.util.js +21 -0
  191. package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
  192. package/dist/utils/replay/replay-buffer-math.js +2 -0
  193. package/dist/workers/constants/socket-slots.d.ts +1 -1
  194. package/dist/workers/utils/time.worker.util.js +2 -2
  195. package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
  196. package/dist/workers/utils/volume-profile.worker.util.js +20 -0
  197. package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
  198. package/dist/workers/wrun/wrun-abi-host.js +82 -5
  199. package/dist/workers/wrun/wrun-engine-handler.js +53 -4
  200. package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
  201. package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
  202. package/package.json +11 -11
@@ -25,7 +25,12 @@
25
25
  * 5. a session-lattice venue on its own lattice (session-lattice.util: the CME
26
26
  * family from 2m to 12h, 1d, 3d; forex from 4h up), the profile the
27
27
  * gateway rolls that venue up on;
28
- * 6. everything else: the UTC floor.
28
+ * 6. everything else: the UTC floor (for a typed day or week length, the
29
+ * fixed grid from Monday 2000-01-03: calendar-interval.util).
30
+ * A custom width under a day (typed-width.leaf) is never bucket exact: on a CME regular-hours chart it rides 3, on a
31
+ * regular-session stock 4, on CME full session, forex, an extended-hours stock and a US option the lazy session grid
32
+ * through `typedSessionGrid` (null while the slot is empty), and everywhere else 6. A walk over the length table sets
33
+ * `lengthRow` on the venue and reads such a width as any other length (the session feed's reach).
29
34
  * Null means the frame has no bucket (off-session under 3 or 4): the chart
30
35
  * holds no bar there, so drop it. At 30m and finer the session grids share
31
36
  * the UTC floor's lattice, never its bars: a regular-session chart holds none
@@ -34,9 +39,9 @@
34
39
  import { findMonday, TimeIntervalConstant } from './titan-constants.pin.js';
35
40
  import { CME_SESSION_LATTICE, isSessionLatticeIntervalMs, sessionLatticeBarEndMs, sessionLatticeBarOpenMs, sessionLatticeBucketMs, sessionLatticeOf, } from './session-lattice.util.js';
36
41
  import { Intervals } from '../../constants/interval.constants.js';
37
- import { calendarBarStartMs, calendarMonthsOfMs } from './calendar-interval.util.js';
42
+ import { calendarBarStartMs, calendarMonthsOfMs, fixedGridFloorMs } from './calendar-interval.util.js';
38
43
  import { formulaCalendarPlan, formulaLegExchange } from './formula-calendar.util.js';
39
- import { checkIsEconomic } from './marketKind.util.js';
44
+ import { checkIsEconomic, checkIsPolygon, getMarketKind } from './marketKind.util.js';
40
45
  import { extractTokensFromTransformations, parsedTransformations } from '../common/transformations.util.js';
41
46
  import { isGovernedFuturesSymbolOpenAt } from './market-session-schedule.util.js';
42
47
  import { chartRegularSessionKind, isWithinMarketRegularWindow, marketAnchoredBucketStartMs, } from './market-session.util.js';
@@ -57,6 +62,22 @@ export function liveBucketVenueOf(metadata) {
57
62
  ...(typeof metadata?.transformations === 'string' && { transformations: metadata.transformations }),
58
63
  };
59
64
  }
65
+ /**
66
+ * The session grid of a custom size (typed-width-grid.util `typedBarStartMs`), set once per realm by the lazy file
67
+ * that builds such a chart's candles (the page: typed-fold-ask.util; the data worker: its fold kit). Empty until
68
+ * then, and a grid that asks it answers null: the frame has no bucket, never another grid's.
69
+ */
70
+ export const typedSessionGrid = {};
71
+ /**
72
+ * The twelve custom widths under a day, in ms: typed-width.leaf's labels under a day, written out in minutes because
73
+ * importing the leaf here costs boot bytes (the pre-candle budget). Never a bucket-exact width on a session grid.
74
+ * tests/utility/chart/live-bucket.util.typed-session.spec.ts fails when this list and the leaf differ.
75
+ */
76
+ const TYPED_INTRADAY_MS = new Set([4, 6, 8, 9, 12, 16, 18, 20, 40, 80, 90, 180].map((minutes) => minutes * 60_000));
77
+ /** Whether the live bucket at `intervalMs` depends on the venue, so a writer must pass it (a custom width always does). */
78
+ export function liveBucketReadsVenue(intervalMs) {
79
+ return !isRthBucketExactIntervalMs(intervalMs) || TYPED_INTRADAY_MS.has(intervalMs);
80
+ }
60
81
  /** A formula's lattice: a profile, null for a formula off every lattice, undefined for a plain expression. */
61
82
  const formulaLatticeByExpression = new Map();
62
83
  const FORMULA_CACHE_MAX = 256;
@@ -115,7 +136,7 @@ export function plainBucketStartMs(tsMs, intervalMs) {
115
136
  const months = calendarMonthsOfMs(intervalMs);
116
137
  if (months !== null)
117
138
  return calendarBarStartMs(tsMs, months);
118
- return intervalMs === TimeIntervalConstant.week ? findMonday(tsMs) : tsMs - (tsMs % intervalMs);
139
+ return intervalMs === TimeIntervalConstant.week ? findMonday(tsMs) : fixedGridFloorMs(tsMs, intervalMs);
119
140
  }
120
141
  /** The venue's lattice at an interval the gateway rolls it up on, else null. */
121
142
  function venueLatticeAt(intervalMs, venue) {
@@ -161,8 +182,9 @@ function liveBucketGrid(intervalMs, venue) {
161
182
  return 'utc-floor';
162
183
  // The 30m bucket-exact widths share the UTC floor's lattice, not its bars: a session-gated chart holds a
163
184
  // bar there only inside its session, so the grid asks the session every time (a lattice that coincides is
164
- // no off-session drop).
165
- const exact = isRthBucketExactIntervalMs(intervalMs);
185
+ // no off-session drop). A custom width under a day counts from the session open instead, so it is never exact.
186
+ const typed = !venue.lengthRow && TYPED_INTRADAY_MS.has(intervalMs);
187
+ const exact = !typed && isRthBucketExactIntervalMs(intervalMs);
166
188
  // The equities grids below also serve a stock's daily-and-longer bars, which the intraday chart kind never names.
167
189
  if (chartRegularSessionKind(venue.exchange, venue.symbol, venue.sessionType, intervalMs) === 'cme') {
168
190
  return exact ? 'rth-floor' : 'rth-anchored';
@@ -170,17 +192,22 @@ function liveBucketGrid(intervalMs, venue) {
170
192
  if (isEquityRegularSessionGated(venue.exchange, venue.sessionType, intervalMs)) {
171
193
  if (exact)
172
194
  return 'equity-floor';
173
- if (isFootprintRthFoldTfMs(intervalMs))
195
+ if (typed || isFootprintRthFoldTfMs(intervalMs))
174
196
  return 'equity-anchored';
175
197
  if (intervalMs === THREE_DAYS_MS)
176
198
  return 'equity-session-group';
177
199
  }
200
+ // A custom width on the other session markets the app builds it on (typed-width-grid.util `typedGridKind`: CME full
201
+ // session, forex, a stock with extended hours on, a US option) rides the lazy grid through the slot.
202
+ const ex = venue.exchange;
203
+ if (typed && (sessionLatticeOf(ex) || checkIsPolygon(ex) || getMarketKind(ex) === 'options'))
204
+ return 'typed-session';
178
205
  if (!exact && venueLatticeAt(intervalMs, venue) !== null)
179
206
  return 'session-lattice';
180
207
  return 'utc-floor';
181
208
  }
182
- /** The UTC floor of `tsMs`, the 30m bucket-exact grids' lattice. */
183
- const utcFloorMs = (tsMs, intervalMs) => tsMs - (tsMs % intervalMs);
209
+ /** The UTC floor of `tsMs`, the 30m bucket-exact grids' lattice; a typed day or week length's anchored floor. */
210
+ const utcFloorMs = (tsMs, intervalMs) => fixedGridFloorMs(tsMs, intervalMs);
184
211
  /** A chart-RTH bucket starting at `startMs` exists only while the product trades by its schedule (an RTH window
185
212
  * is a wall-clock filter with bounds on every calendar day; ES holds no Saturday bar, an always-on root does). */
186
213
  function rthBucketOrNull(symbol, startMs) {
@@ -212,6 +239,8 @@ function bucketStartOnGrid(grid, tsMs, intervalMs, venue) {
212
239
  }
213
240
  case 'equity-session-group':
214
241
  return usEquitySessionGridBucketStartMs(tsMs);
242
+ case 'typed-session':
243
+ return typedSessionGrid.startMs?.(tsMs, intervalMs, venue) ?? null;
215
244
  default:
216
245
  return utcFloorMs(tsMs, intervalMs);
217
246
  }
@@ -231,9 +260,13 @@ export function liveBucketBarsAreLabels(intervalMs, venue) {
231
260
  return grid === 'equity-session-group' || (grid === 'session-lattice' && intervalMs >= ONE_DAY_MS);
232
261
  }
233
262
  /**
234
- * Whether the venue's bars at `intervalMs` open on the UTC interval lattice (the UTC floor, `findMonday`, a session's 30m
235
- * and finer floor). False on a session lattice, where bars follow the trading calendar: anchored at the session's open
236
- * (a stock or a chart-RTH product from 45m to 12h, a session-lattice venue) or labels (`liveBucketBarsAreLabels`).
263
+ * Whether the venue's bars at `intervalMs` open on one fixed lattice of the interval, every bar one length after the
264
+ * last with one phase: the UTC floor, `findMonday`, a session's 30m and finer floor, and a typed day or week length's
265
+ * grid from Monday 2000-01-03 (`fixedGridFloorMs`), which is fixed but not epoch-aligned. Its one reader
266
+ * (wrun-source-rows `wrunChartRowsOffIntervalGrid`) counts phases of the interval, which a fixed lattice of any
267
+ * origin passes with one. False on a session lattice, where bars follow the trading calendar: anchored at the
268
+ * session's open (a stock or a chart-RTH product from 45m to 12h, a session-lattice venue) or labels
269
+ * (`liveBucketBarsAreLabels`).
237
270
  */
238
271
  export function liveBucketBarsOnUtcLattice(intervalMs, venue) {
239
272
  const grid = liveBucketGrid(intervalMs, venue);
@@ -35,6 +35,25 @@ export interface GovernedFuturesScheduleStatus {
35
35
  /** Closed iff inside the weekend halt (Fri 16:00 -> Sun 17:00) or a Mon-Thu daily halt. */
36
36
  export declare function isGovernedFuturesScheduleOpen(nowMs: number): boolean;
37
37
  export declare function getGovernedFuturesScheduleStatus(nowMs: number): GovernedFuturesScheduleStatus;
38
+ /**
39
+ * CME moves products onto 24/7 trading one product at a time, not venue-wide:
40
+ * cryptocurrency futures and options (standard + micro, plus the Bitcoin
41
+ * Friday weeklies) since 2026-05-29, the 1-Ounce Gold future since
42
+ * 2026-07-24; the 10-barrel WTI contract is announced for 2026-08-30. Spot-
43
+ * quoted futures are excluded by CME and stay on the weekly cycle. For these
44
+ * roots the Globex cycle above is wrong on its face (the 2026-08-22 report:
45
+ * BTC1! "Closed" on a Saturday while its book streamed): their only scheduled
46
+ * halt is the Saturday 02:00-04:00 CT maintenance window. The weekday
47
+ * 16:00-16:02 CT two-minute window is deliberately ignored: too short to
48
+ * announce, and a "Closed" flash every afternoon would be noise.
49
+ *
50
+ * Static on purpose, like the cycle itself (a constant, not a maintained
51
+ * dataset). Roots were checked against a Saturday L3/book feed before being
52
+ * listed; add a root only with that evidence (the NCI/MCI crypto-index pair is
53
+ * listed on exactly that evidence: order flow on 2026-08-22 13:15Z).
54
+ * The bar-grid parity fixture (src/fixtures/bar-grid-parity/typed-session.json) lists these roots.
55
+ */
56
+ export declare const CME_ALWAYS_ON_ROOTS: ReadonlySet<string>;
38
57
  /** Futures root of a continuous (`BTC1!`), monthly (`BTCQ6`, `1OZV6`) or
39
58
  * weekly (`BFFQ628`) CME symbol; null when the symbol has no such shape. */
40
59
  export declare function cmeFuturesRootOf(symbol: unknown): string | null;
@@ -153,8 +153,9 @@ export function getGovernedFuturesScheduleStatus(nowMs) {
153
153
  * dataset). Roots were checked against a Saturday L3/book feed before being
154
154
  * listed; add a root only with that evidence (the NCI/MCI crypto-index pair is
155
155
  * listed on exactly that evidence: order flow on 2026-08-22 13:15Z).
156
+ * The bar-grid parity fixture (src/fixtures/bar-grid-parity/typed-session.json) lists these roots.
156
157
  */
157
- const CME_ALWAYS_ON_ROOTS = new Set([
158
+ export const CME_ALWAYS_ON_ROOTS = new Set([
158
159
  // Cryptocurrency futures + options: standard and micro, Bitcoin Friday weeklies.
159
160
  'BTC',
160
161
  'MBT',
@@ -27,6 +27,54 @@
27
27
  */
28
28
  import { type RthWindow, type SessionDayWindow } from './rth-session.util.js';
29
29
  export type MarketSessionKind = 'cme' | 'us-equity';
30
+ /**
31
+ * The day-and-longer widths whose US stock tape order flow (VOLUME_PROFILE_AGG) the gateway serves under the regular
32
+ * session, by label: its tradfi profile family reads DAY, WEEK and the calendar widths per trading session, and refuses
33
+ * THREE_DAYS (tsdb-gateway volume_profile_tradfi.go `tradfiVPProfile`). Every day-plus label the app offers has a row
34
+ * (tests/utility/chart/order-flow-session.interval-rule.spec.ts).
35
+ */
36
+ export declare const US_EQUITY_DAY_PLUS_REGULAR_ORDER_FLOW: Readonly<Record<string, boolean>>;
37
+ /** 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. */
38
+ export declare function isUsEquityRegularOrderFlowIntervalMs(tfMs: unknown): boolean;
39
+ /** 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. */
40
+ export declare function sessionFilterJudgesTradeInstant(tfMs: unknown): boolean;
41
+ /** The fields of an order-flow read that pick the gateway reader: its market and its unit (`currency`, 'USD' or coins). */
42
+ export interface OrderFlowReadLike {
43
+ exchange?: unknown;
44
+ symbol?: unknown;
45
+ currency?: unknown;
46
+ }
47
+ /**
48
+ * Whether the gateway reads this stock order flow per trading session at `tfMs` (a day-plus chart width or span rung),
49
+ * so a REGULAR read keeps its midnight-stamped rows. tsdb-gateway `tradfiVPProfile` serves only a stock tape
50
+ * (kiyotaka-go venue `ProfileFor`), at DAY, WEEK and the calendar widths (`US_EQUITY_DAY_PLUS_REGULAR_ORDER_FLOW`), and
51
+ * excludes a USD-normalized read, a coin sum and a custom time range; no session-active VP read sends the last two.
52
+ * Anywhere else the fallback keeps a REGULAR bucket by its start, so every day row would be dropped.
53
+ */
54
+ export declare function readsUsEquitySessionPerTradingDay(read: OrderFlowReadLike | null | undefined, tfMs: unknown): boolean;
55
+ /** 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. */
56
+ export declare function isUsEquityRegularOrderFlowRead(read: OrderFlowReadLike | null | undefined, readTfMs: unknown): boolean;
57
+ /**
58
+ * The wire width of a session-filtered order-flow read at `tfMs` (the chart width, or a fixed or developing profile's
59
+ * span rung) on a chart of `chartTfMs` (the read's own width when it is the chart's): the width itself where the
60
+ * gateway reads it per trading session AND the chart is day-plus, else the at-most-15m effective width (rth-session.util
61
+ * `rthEffectiveFetchTfMs`, on whose grid the opens and closes sit). A day row is stamped at midnight, so on an intraday
62
+ * chart it would lose a box's intraday edges: there a rung reads exactly as before the day-plus rule. The one width
63
+ * every fetch, row grid, live fold and cache identity of a session-active profile reads, so they cannot disagree.
64
+ */
65
+ export declare function regularSessionReadTfMs(tfMs: number, read: OrderFlowReadLike | null | undefined, chartTfMs?: unknown): number;
66
+ /**
67
+ * Whether an overlay that reads at its own width `readTfMs` (a fixed or developing profile's span rung, or its live
68
+ * fold grid) is session-active on a chart of `chartTfMs`. Below a day the chart decides, exactly as before the day-plus
69
+ * rule; from a day up the read itself must be holdable to the regular session (`isUsEquityRegularOrderFlowRead`): an
70
+ * intraday read, or a per-session one.
71
+ */
72
+ export declare function isMarketSessionReadActive(settings: Parameters<typeof isMarketSessionHoursActive>[0], chartTfMs: unknown, chartRegularKind: MarketSessionKind | null, readTfMs: unknown): boolean;
73
+ /** 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. */
74
+ export declare function rungSessionRead(settings: Parameters<typeof isMarketSessionHoursActive>[0], chartTfMs: number, chartRegularKind: MarketSessionKind | null, rungMs: number): {
75
+ active: boolean;
76
+ readTfMs: number;
77
+ };
30
78
  /**
31
79
  * A US stock market: a Polygon listing code (marketKind.util `checkIsPolygon`: POLYGON, US_STOCKS, NYSE, NASDAQ,
32
80
  * CBOE) or a stocks tape code (stocks-governed.util `isStocksTapeGoverned`: NYSE_TAPE, NYSE_ARCA_TAPE,
@@ -46,13 +94,14 @@ export declare function marketSessionKind(exchange: unknown, symbol: unknown): M
46
94
  export declare function marketRegularWindow(exchange: unknown, symbol: unknown): Readonly<RthWindow> | null;
47
95
  export declare function marketHasRegularWindow(exchange: unknown, symbol: unknown): boolean;
48
96
  /**
49
- * The regular session THIS chart draws at `chartTfMs` (milliseconds), for overlay purposes; intraday only:
50
- * 'cme' exactly when rth-session.util `isChartRthActive(exchange, symbol, sessionType, chartTfMs)`.
97
+ * The regular session THIS chart draws at `chartTfMs` (milliseconds), for overlay purposes:
98
+ * 'cme' exactly when rth-session.util `isChartRthActive(exchange, symbol, sessionType, chartTfMs)` (intraday).
51
99
  * 'us-equity' when the candles' own gate holds, us-equities-session.util
52
- * `isEquityRegularSessionGated(exchange, sessionType, chartTfMs)` (a Polygon listing whose word is not
53
- * an active 'extended'), at an intraday `chartTfMs`. A chart opened on a tape venue (NASDAQ_TAPE) has
54
- * no candle session handling, so it answers null, as it rides today.
55
- * null otherwise: an ETH or extended chart, a daily or longer interval, a label instead of milliseconds.
100
+ * `isEquityRegularSessionGated(exchange, sessionType, chartTfMs)` (the candle fetch's REGULAR: a Polygon
101
+ * listing whose word is not an active 'extended', and every daily and longer bar), at a width its order
102
+ * flow can follow (`isUsEquityRegularOrderFlowIntervalMs`: 3D cannot). A chart opened on a tape venue
103
+ * (NASDAQ_TAPE) has no candle session handling, so it answers null, as it rides today.
104
+ * null otherwise: an ETH or extended intraday chart, a CME daily chart, 3D, a label instead of milliseconds.
56
105
  */
57
106
  export declare function chartRegularSessionKind(exchange: unknown, symbol: unknown, sessionType: unknown, chartTfMs: unknown): MarketSessionKind | null;
58
107
  /**
@@ -71,16 +120,19 @@ export declare function chartRegularKindFromCacheBag(bag: Readonly<Record<string
71
120
  * CME exactly rth-session.util `isRthSessionHoursActive(settings, chartTfMs, chartRegularKind === 'cme')`:
72
121
  * an explicit 'rth' stays active on any chart (a stock, crypto or ETH chart included), 'eth' never
73
122
  * is, and the 'chart' default follows a CME RTH chart only.
74
- * US stock active exactly while the chart draws the US equities regular session at an intraday `chartTfMs`.
75
- * Stock overlays always follow the chart: their session row is hidden, so a persisted 'rth' or 'eth'
76
- * carried over from a futures chart is ignored.
123
+ * US stock active exactly while the chart draws the US equities regular session and the overlay's read can be held
124
+ * to it (`isUsEquityRegularOrderFlowRead` at `readTfMs`: any intraday read; from a day up only a stock
125
+ * tape in coins, read per trading session; a USD or listing-code read at 1D keeps all hours, as 3D does).
126
+ * Stock overlays always follow the chart:
127
+ * their session row is hidden, so a persisted 'rth' or 'eth' carried over from a futures chart is ignored.
77
128
  * any other never active (no window to filter on).
78
129
  */
79
130
  export declare function isMarketSessionHoursActive(settings: {
80
131
  sessionHours?: unknown;
81
132
  symbol?: unknown;
82
133
  exchange?: unknown;
83
- } | null | undefined, chartTfMs: unknown, chartRegularKind: MarketSessionKind | null): boolean;
134
+ currency?: unknown;
135
+ } | null | undefined, chartTfMs: unknown, chartRegularKind: MarketSessionKind | null, readTfMs?: unknown): boolean;
84
136
  /**
85
137
  * `isWithinRthWindow`: whether `tsMs` sits in the market's `[open, close)` session. Fails OPEN with no window (a
86
138
  * market without a regular session keeps every row), false for a non-finite instant on a market with one.
@@ -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
  }
@@ -7,11 +7,13 @@ import { type OmTargetMetadata } from './om-target.util.js';
7
7
  * prediction markets (`'hip4'`), economic series (`'economic'`: FRED and
8
8
  * the ECONOMICS catalog publishers, which the engine still knows as `'fred'`),
9
9
  * the crypto-wide indices (`'cryptoIndex'`: CRYPTOCAP's BTC.D, TOTAL, ...)
10
- * and the perpetual venues that publish quotes, never trades (`'quotePerp'`:
11
- * Variational, quote-perp.leaf). TitanCharts does not know these kinds;
12
- * anything handed into the engine narrows through `toTitanMarketKind`.
10
+ * the perpetual venues that publish quotes, never trades (`'quotePerp'`:
11
+ * Variational, quote-perp.leaf) and the index and yield venue (`'marketIndex'`:
12
+ * stock indices, the dollar and volatility indices and US Treasury yields,
13
+ * index-otc.leaf). TitanCharts does not know these kinds; anything handed
14
+ * into the engine narrows through `toTitanMarketKind`.
13
15
  */
14
- export type VenueMarketKind = Exclude<MarketKind, 'fred'> | 'economic' | 'futures' | 'hip4' | 'options' | 'cryptoIndex' | 'quotePerp';
16
+ export type VenueMarketKind = Exclude<MarketKind, 'fred'> | 'economic' | 'futures' | 'hip4' | 'options' | 'cryptoIndex' | 'quotePerp' | 'marketIndex';
15
17
  /** Which wire path serves an economic series (see `economicSource`). */
16
18
  export type EconomicSource = 'fred' | 'observation';
17
19
  /**
@@ -130,16 +132,13 @@ export declare function checkIsForexCommodityOrFutures(exchange: string | undefi
130
132
  * price move, every 5 s per coin) onto uniform bars from 1m up, the crypto
131
133
  * treatment's own shape, gap policy included. `'quotePerp'` maps to
132
134
  * `'crypto'` too: its perpetuals quote around the clock onto uniform minute
133
- * bars. FE-internal code always sees the honest venue kind.
135
+ * bars. `'marketIndex'` maps to `'forex'`: its instruments quote in
136
+ * sessions with closes and weekends onto irregular bars, the forex treatment's
137
+ * shape, and the engine has no index kind. FE-internal code always sees the
138
+ * honest venue kind.
134
139
  */
135
140
  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;
141
+ export declare function venueOmitsVolumeOverlay(exchange: string | undefined | null, symbol?: string | null): boolean;
143
142
  export declare function checkIsDex(exchange: string | undefined | null): boolean;
144
143
  /**
145
144
  * Economic series venue: FRED, the ECONOMICS catalog venue and the observation
@@ -1,8 +1,9 @@
1
- import { MARKET_CAPABILITIES, ONCHAIN_POOL_CAPABILITIES, } from '../../constants/marketCapabilities.constants.js';
1
+ import { MARKET_CAPABILITIES, NO_ORDERBOOK_EXCHANGES, 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
+ import { INDEX_OTC_EXCHANGES } from './index-otc.leaf.js';
6
7
  import { isCmeGoverned, normalizeExchangeCode } from './cme-realtime.util.js';
7
8
  import { isGovernedPlaneExchange } from '../v2/gate-plane.util.js';
8
9
  import { isOmTargetPane } from './om-target.util.js';
@@ -83,6 +84,8 @@ const EXCHANGE_TO_KIND = {
83
84
  // Economic series: FRED plus the ECONOMICS catalog venue and the observation
84
85
  // publishers (economic.constants.ts owns the list).
85
86
  ...Object.fromEntries(ECONOMIC_EXCHANGES.map((code) => [code, 'economic'])),
87
+ // A publisher with no market would otherwise default to a crypto venue with a book.
88
+ ...Object.fromEntries([...PUBLISHER_ONLY_EXCHANGES].map((code) => [code, 'economic'])),
86
89
  // Crypto-wide indices (CRYPTOCAP): value prints 24/7 with no trades,
87
90
  // volume or book behind them (crypto-index.leaf owns the list).
88
91
  ...Object.fromEntries(CRYPTO_INDEX_EXCHANGES.map((code) => [code, 'cryptoIndex'])),
@@ -91,6 +94,11 @@ const EXCHANGE_TO_KIND = {
91
94
  // (quote-perp.leaf owns the list). Unlisted, they read as crypto and ask for
92
95
  // trades the gateway never serves them.
93
96
  ...Object.fromEntries(QUOTE_PERP_EXCHANGES.map((code) => [code, 'quotePerp'])),
97
+ // Stock indices, the dollar and volatility indices and US Treasury yields:
98
+ // TICKER candles and prints with market closes and weekends, no trades,
99
+ // volume or book (index-otc.leaf owns the list). Unlisted, they read as
100
+ // crypto and ask for trades the gateway never serves them.
101
+ ...Object.fromEntries(INDEX_OTC_EXCHANGES.map((code) => [code, 'marketIndex'])),
94
102
  // Polymarket
95
103
  POLYMARKET: 'polymarket',
96
104
  // Hip3 (Hyperliquid synthetic derivatives)
@@ -203,7 +211,14 @@ export function isSessionBoundMarketKind(exchange) {
203
211
  /** Kind-level form of the session-bound split, for call sites that already
204
212
  * hold a resolved `VenueMarketKind` (one set, never re-declared). */
205
213
  export function isSessionBoundKind(kind) {
206
- return kind === 'futures' || kind === 'options' || kind === 'commodity' || kind === 'tradfi' || kind === 'forex';
214
+ // The index and yield venue closes like forex (market closes, weekends), so
215
+ // an old cached bar there is the market's current state too.
216
+ return (kind === 'futures' ||
217
+ kind === 'options' ||
218
+ kind === 'commodity' ||
219
+ kind === 'tradfi' ||
220
+ kind === 'forex' ||
221
+ kind === 'marketIndex');
207
222
  }
208
223
  /**
209
224
  * Venues that trade around the clock (crypto spot and perps, on-chain pools,
@@ -218,6 +233,16 @@ export function isContinuousTradingKind(kind) {
218
233
  export function isContinuousTradingVenue(exchange) {
219
234
  return isContinuousTradingKind(getMarketKind(exchange));
220
235
  }
236
+ // One bookless copy per kind's capabilities, so a caller comparing by identity sees a stable object.
237
+ const booklessCapabilities = new Map();
238
+ function withoutOrderbook(capabilities) {
239
+ let bookless = booklessCapabilities.get(capabilities);
240
+ if (!bookless) {
241
+ bookless = { ...capabilities, supportsOrderbook: false };
242
+ booklessCapabilities.set(capabilities, bookless);
243
+ }
244
+ return bookless;
245
+ }
221
246
  export function getCapabilities(exchange) {
222
247
  // On-chain pools keep the crypto kind (every kind-keyed path treats them as
223
248
  // crypto) but not its book and profile surfaces: blk serves neither.
@@ -225,7 +250,13 @@ export function getCapabilities(exchange) {
225
250
  return ONCHAIN_POOL_CAPABILITIES;
226
251
  // The registry carries every VenueMarketKind (its 'futures' entry IS
227
252
  // CME_FUTURES_CAPABILITIES), so the kind lookup needs no special case.
228
- return MARKET_CAPABILITIES[getMarketKind(exchange)];
253
+ const capabilities = MARKET_CAPABILITIES[getMarketKind(exchange)];
254
+ // An exchange on the no-book list keeps its kind and every other surface.
255
+ const code = normalizeExchangeCode(exchange);
256
+ if (capabilities.supportsOrderbook && code !== null && NO_ORDERBOOK_EXCHANGES.includes(code)) {
257
+ return withoutOrderbook(capabilities);
258
+ }
259
+ return capabilities;
229
260
  }
230
261
  /**
231
262
  * Whether an interval switch must re-run every mounted indicator's
@@ -298,7 +329,10 @@ export function checkIsForexCommodityOrFutures(exchange) {
298
329
  * price move, every 5 s per coin) onto uniform bars from 1m up, the crypto
299
330
  * treatment's own shape, gap policy included. `'quotePerp'` maps to
300
331
  * `'crypto'` too: its perpetuals quote around the clock onto uniform minute
301
- * bars. FE-internal code always sees the honest venue kind.
332
+ * bars. `'marketIndex'` maps to `'forex'`: its instruments quote in
333
+ * sessions with closes and weekends onto irregular bars, the forex treatment's
334
+ * shape, and the engine has no index kind. FE-internal code always sees the
335
+ * honest venue kind.
302
336
  */
303
337
  export function toTitanMarketKind(kind) {
304
338
  if (kind === 'futures' || kind === 'options')
@@ -309,19 +343,17 @@ export function toTitanMarketKind(kind) {
309
343
  return 'fred';
310
344
  if (kind === 'cryptoIndex' || kind === 'quotePerp')
311
345
  return 'crypto';
346
+ if (kind === 'marketIndex')
347
+ return 'forex';
312
348
  return kind;
313
349
  }
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) {
350
+ export function venueOmitsVolumeOverlay(exchange, symbol) {
351
+ if (isOmTargetPane({ exchange, symbol }))
352
+ return true;
321
353
  if (checkIsEconomic(exchange) || checkIsForexOrCommodity(exchange))
322
354
  return true;
323
355
  const kind = getMarketKind(exchange);
324
- return kind === 'cryptoIndex' || kind === 'quotePerp';
356
+ return kind === 'cryptoIndex' || kind === 'quotePerp' || kind === 'marketIndex';
325
357
  }
326
358
  export function checkIsDex(exchange) {
327
359
  return getMarketKind(exchange) === 'dex';
@@ -68,6 +68,24 @@ export interface BaseOhlcvPayload {
68
68
  tailBoot?: boolean;
69
69
  sided?: boolean;
70
70
  category?: number;
71
+ typedFold?: TypedFoldAsk;
72
+ typedHistory?: 'server';
73
+ }
74
+ /** The fold a custom size the app builds asks of the worker: types only, so the boot path carries none of it. */
75
+ export interface TypedFoldAsk {
76
+ /** The served interval the rows are read at (typed-width-source.leaf). */
77
+ sourceLabel: string;
78
+ /** The most source rows one custom bar holds. */
79
+ rowsPerBar: number;
80
+ /** The custom size's length. */
81
+ widthMs: number;
82
+ /** The chart's market, which names its grid (typed-width-grid.util): the fields of live-bucket.util `LiveBucketVenue`. */
83
+ venue: {
84
+ exchange?: unknown;
85
+ symbol?: unknown;
86
+ sessionType?: unknown;
87
+ transformations?: unknown;
88
+ };
71
89
  }
72
90
  /**
73
91
  * 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) {