@orangecharts/wrun-chart-host 0.10.0 → 0.11.1

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 (152) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/feature-flags.constants.d.ts +9 -0
  3. package/dist/constants/feature-flags.constants.js +67 -4
  4. package/dist/constants/governed-exchanges.constants.d.ts +12 -0
  5. package/dist/constants/governed-exchanges.constants.js +16 -0
  6. package/dist/constants/option-venues.constants.d.ts +2 -2
  7. package/dist/host-env.d.ts +1 -9
  8. package/dist/host-ports.types.d.ts +36 -7
  9. package/dist/index.d.ts +7 -1
  10. package/dist/index.js +7 -1
  11. package/dist/indicators/controls/tpo-session.util.d.ts +36 -13
  12. package/dist/indicators/controls/tpo-session.util.js +217 -236
  13. package/dist/interfaces/cancel-reason.interface.d.ts +1 -1
  14. package/dist/interfaces/cme-realtime.interface.d.ts +16 -9
  15. package/dist/interfaces/cme-realtime.interface.js +6 -3
  16. package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
  17. package/dist/interfaces/opra-realtime.interface.d.ts +1 -5
  18. package/dist/interfaces/prediction-market.interface.d.ts +7 -0
  19. package/dist/interfaces/stocks-realtime.interface.d.ts +57 -0
  20. package/dist/interfaces/stocks-realtime.interface.js +32 -0
  21. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +48 -117
  22. package/dist/kscript-data/controls/live-trades-merge.util.js +97 -207
  23. package/dist/market-data/billing.interface.d.ts +86 -12
  24. package/dist/market-data/billing.interface.js +23 -4
  25. package/dist/market-data/venue.d.ts +65 -2
  26. package/dist/market-data/venues/index.d.ts +135 -5
  27. package/dist/market-data/venues/index.js +2 -1
  28. package/dist/market-data/venues/opra.contract.copy.json +3 -2
  29. package/dist/market-data/venues/opra.d.ts +2 -2
  30. package/dist/market-data/venues/opra.js +5 -2
  31. package/dist/market-data/venues/stocks.contract.copy.json +64 -0
  32. package/dist/market-data/venues/stocks.d.ts +130 -0
  33. package/dist/market-data/venues/stocks.js +117 -0
  34. package/dist/settings-templates/footprint-rows.js +35 -2
  35. package/dist/settings-templates/form-rows.d.ts +2 -1
  36. package/dist/settings-templates/indicator-fields.js +34 -4
  37. package/dist/settings-templates/tool-rules.d.ts +12 -5
  38. package/dist/settings-templates/tool-rules.js +11 -5
  39. package/dist/settings-templates/tool-tables.generated.js +4 -0
  40. package/dist/utility/chart/cme-cache-context.util.d.ts +5 -3
  41. package/dist/utility/chart/cme-cache-context.util.js +10 -6
  42. package/dist/utility/chart/cme-realtime.util.js +10 -0
  43. package/dist/utility/chart/cme-user-scripts-gate.util.d.ts +83 -0
  44. package/dist/utility/chart/cme-user-scripts-gate.util.js +142 -0
  45. package/dist/utility/chart/effective-chart-session.util.d.ts +14 -0
  46. package/dist/utility/chart/effective-chart-session.util.js +39 -0
  47. package/dist/utility/chart/host-bar-placement.util.d.ts +28 -0
  48. package/dist/utility/chart/host-bar-placement.util.js +170 -30
  49. package/dist/utility/chart/index-host-tier.util.d.ts +3 -1
  50. package/dist/utility/chart/index-host-tier.util.js +7 -2
  51. package/dist/utility/chart/index-mode-admission.util.js +25 -11
  52. package/dist/utility/chart/kscript-apply-fingerprint.util.js +1 -1
  53. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +6 -9
  54. package/dist/utility/chart/kscript-live-coalesce.util.js +8 -9
  55. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +9 -0
  56. package/dist/utility/chart/kscript-live-source-identity.util.js +10 -1
  57. package/dist/utility/chart/kscript-provenance-keys.util.js +7 -0
  58. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
  59. package/dist/utility/chart/kscript-venue-policy.util.d.ts +115 -21
  60. package/dist/utility/chart/kscript-venue-policy.util.js +194 -40
  61. package/dist/utility/chart/live-bucket.util.d.ts +24 -8
  62. package/dist/utility/chart/live-bucket.util.js +85 -27
  63. package/dist/utility/chart/market-sessions.util.d.ts +83 -0
  64. package/dist/utility/chart/market-sessions.util.js +220 -0
  65. package/dist/utility/chart/marketKind.util.js +5 -0
  66. package/dist/utility/chart/mixed-mode.util.d.ts +7 -0
  67. package/dist/utility/chart/mixed-mode.util.js +14 -0
  68. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +11 -16
  69. package/dist/utility/chart/opra-user-scripts-gate.util.js +12 -28
  70. package/dist/utility/chart/rth-session.util.d.ts +9 -8
  71. package/dist/utility/chart/rth-session.util.js +23 -20
  72. package/dist/utility/chart/session-interval.util.d.ts +2 -1
  73. package/dist/utility/chart/session-interval.util.js +1 -3
  74. package/dist/utility/chart/trading-day.util.d.ts +17 -0
  75. package/dist/utility/chart/trading-day.util.js +59 -0
  76. package/dist/utility/chart/window-owner.leaf.d.ts +23 -2
  77. package/dist/utility/chart/window-owner.leaf.js +45 -3
  78. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +33 -15
  79. package/dist/utility/chart/wrun-bar-session-facts.util.js +70 -20
  80. package/dist/utility/intl-locale.util.js +5 -0
  81. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
  82. package/dist/utility/v2/gate-plane.util.d.ts +12 -3
  83. package/dist/utility/v2/gate-plane.util.js +30 -4
  84. package/dist/utility/v2/gate-session-latch.util.js +1 -1
  85. package/dist/utility/v2/stocks-governed.util.d.ts +16 -0
  86. package/dist/utility/v2/stocks-governed.util.js +34 -0
  87. package/dist/utility/wrun/derived-roots.leaf.d.ts +13 -0
  88. package/dist/utility/wrun/derived-roots.leaf.js +27 -0
  89. package/dist/utility/wrun/derived-roots.util.d.ts +1 -9
  90. package/dist/utility/wrun/derived-roots.util.js +3 -23
  91. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +4 -3
  92. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +24 -3
  93. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +46 -10
  94. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +2 -0
  95. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +63 -16
  96. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +58 -14
  97. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +34 -11
  98. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +106 -30
  99. package/dist/utility/wrun/wrun-browser-sources.leaf.js +1 -2
  100. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +7 -4
  101. package/dist/utility/wrun/wrun-chart-market-facts.util.js +12 -8
  102. package/dist/utility/wrun/wrun-color-settings.util.d.ts +9 -0
  103. package/dist/utility/wrun/wrun-color-settings.util.js +33 -0
  104. package/dist/utility/wrun/wrun-handles.util.d.ts +7 -3
  105. package/dist/utility/wrun/wrun-handles.util.js +9 -8
  106. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +68 -0
  107. package/dist/utility/wrun/wrun-input-requirements.leaf.js +163 -7
  108. package/dist/utility/wrun/wrun-leg-close.util.d.ts +59 -23
  109. package/dist/utility/wrun/wrun-leg-close.util.js +186 -28
  110. package/dist/utility/wrun/wrun-live-intake.util.d.ts +26 -12
  111. package/dist/utility/wrun/wrun-live-intake.util.js +219 -155
  112. package/dist/utility/wrun/wrun-live-tick.util.d.ts +9 -5
  113. package/dist/utility/wrun/wrun-live-tick.util.js +130 -94
  114. package/dist/utility/wrun/wrun-market-facts.util.d.ts +13 -3
  115. package/dist/utility/wrun/wrun-market-facts.util.js +13 -3
  116. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +20 -10
  117. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +10 -5
  118. package/dist/utility/wrun/wrun-option-book-rows.util.d.ts +56 -0
  119. package/dist/utility/wrun/wrun-option-book-rows.util.js +96 -0
  120. package/dist/utility/wrun/wrun-option-views.util.d.ts +281 -20
  121. package/dist/utility/wrun/wrun-option-views.util.js +391 -50
  122. package/dist/utility/wrun/wrun-options-chain.util.d.ts +3 -3
  123. package/dist/utility/wrun/wrun-options-chain.util.js +2 -0
  124. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +15 -2
  125. package/dist/utility/wrun/wrun-overlay-drivers.util.js +13 -3
  126. package/dist/utility/wrun/wrun-overlay-recovery.util.js +3 -1
  127. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +60 -11
  128. package/dist/utility/wrun/wrun-overlay-run.util.js +529 -113
  129. package/dist/utility/wrun/wrun-panel-mount.util.js +51 -6
  130. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +15 -2
  131. package/dist/utility/wrun/wrun-pin-spelling.util.js +27 -3
  132. package/dist/utility/wrun/wrun-refusal.util.d.ts +3 -2
  133. package/dist/utility/wrun/wrun-refusal.util.js +22 -0
  134. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +26 -0
  135. package/dist/utility/wrun/wrun-registry-errors.util.js +34 -0
  136. package/dist/utility/wrun/wrun-replay-lane.util.js +3 -2
  137. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +20 -6
  138. package/dist/utility/wrun/wrun-run-interval-session.util.js +22 -7
  139. package/dist/utility/wrun/wrun-run-interval.util.d.ts +39 -7
  140. package/dist/utility/wrun/wrun-run-interval.util.js +49 -9
  141. package/dist/utility/wrun/wrun-socket-row-source.js +7 -2
  142. package/dist/utility/wrun/wrun-source-rows.util.d.ts +29 -22
  143. package/dist/utility/wrun/wrun-source-rows.util.js +62 -41
  144. package/dist/utility/wrun/wrun-tape-per-order.util.js +1 -20
  145. package/dist/utility/wrun/wrun-tape-source.util.d.ts +17 -9
  146. package/dist/utility/wrun/wrun-tape-source.util.js +20 -12
  147. package/dist/utility/wrun/wrun-volume-profile.util.js +37 -29
  148. package/dist/workers/constants/socket-slots.d.ts +91 -6
  149. package/dist/workers/constants/socket-slots.js +85 -6
  150. package/package.json +5 -5
  151. package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +0 -56
  152. package/dist/kscript-data/controls/live-trades-order-gate.util.js +0 -107
@@ -289,6 +289,65 @@ export function getTradingDayPeriodStartSec(timestampSec, period, anchor) {
289
289
  const openDate = anchor.openMinutes >= 720 ? shiftCalendarDate(firstTradeDate, -1) : firstTradeDate;
290
290
  return wallInstantMs(anchor.timeZone, openDate, anchor.openMinutes) / 1000;
291
291
  }
292
+ /** 1970-01-01 (date index 0) is a Thursday: the Monday before it is index -3 (titan's lattice). */
293
+ const MONDAY_EPOCH_OFFSET_DAYS = 3;
294
+ const PERIOD_DAY_MS = 86_400_000;
295
+ function dateIndexOf(date) {
296
+ return Math.round(Date.UTC(date.y, date.m - 1, date.d) / PERIOD_DAY_MS);
297
+ }
298
+ function calendarDateOfIndex(index) {
299
+ const date = new Date(index * PERIOD_DAY_MS);
300
+ return { y: date.getUTCFullYear(), m: date.getUTCMonth() + 1, d: date.getUTCDate() };
301
+ }
302
+ /** titan's calendarGroupIndex for weeks (ISO weeks from Monday 1969-12-29) and months (from January 1970). */
303
+ function calendarGroupIndexOf(dateIndex, unit, count) {
304
+ const n = count >= 1 ? Math.floor(count) : 1;
305
+ if (unit === 'month') {
306
+ const date = new Date(dateIndex * PERIOD_DAY_MS);
307
+ return Math.floor(((date.getUTCFullYear() - 1970) * 12 + date.getUTCMonth()) / n);
308
+ }
309
+ return Math.floor(Math.floor((dateIndex + MONDAY_EPOCH_OFFSET_DAYS) / 7) / n);
310
+ }
311
+ /** titan's calendarGroupFirstDateIndex: the first date index of a calendar group. */
312
+ function calendarGroupFirstDateIndexOf(groupIndex, unit, count) {
313
+ const n = count >= 1 ? Math.floor(count) : 1;
314
+ if (unit === 'month') {
315
+ const monthIndex = groupIndex * n;
316
+ const year = 1970 + Math.floor(monthIndex / 12);
317
+ return Math.round(Date.UTC(year, monthIndex - (year - 1970) * 12, 1) / PERIOD_DAY_MS);
318
+ }
319
+ return groupIndex * n * 7 - MONDAY_EPOCH_OFFSET_DAYS;
320
+ }
321
+ /** The open (ms) of the trading day labeled by `date`: evening opens label the next date, so they open the day before. */
322
+ function tradingDateOpenMs(date, anchor) {
323
+ const openDate = anchor.openMinutes >= 720 ? shiftCalendarDate(date, -1) : date;
324
+ return wallInstantMs(anchor.timeZone, openDate, anchor.openMinutes);
325
+ }
326
+ /**
327
+ * The open (ms) of the `count`-unit calendar period holding the TRADING date
328
+ * of `tsMs`: weeks on the ISO Monday lattice, months from January 1970 (so 3
329
+ * is the calendar quarter and 12 the year), grouped as titan groups them
330
+ * (utils/tradingDay.ts calendarGroupIndex), opening with the trading day
331
+ * labeled by the period's first calendar date (Sunday 17:00 America/Chicago
332
+ * for a CME Monday). Titan's `tradingPeriodStartMs`, the grid a session
333
+ * profile folds its weekly and monthly cells on under `calendarPeriodAnchor:
334
+ * 'tradingDay'` (src/renderers/profile/sessionGrid.ts); the fetch-head decider
335
+ * and the history trim mirror it here. `getTradingDayPeriodStartSec` is the
336
+ * same rule for one week, one month and one year, in seconds.
337
+ */
338
+ export function tradingPeriodStartMs(tsMs, anchor, unit, count) {
339
+ if (!Number.isFinite(tsMs))
340
+ return Number.NaN;
341
+ const group = calendarGroupIndexOf(dateIndexOf(tradingDateOf(tsMs, anchor)), unit, count);
342
+ return tradingDateOpenMs(calendarDateOfIndex(calendarGroupFirstDateIndexOf(group, unit, count)), anchor);
343
+ }
344
+ /** The first period open strictly after `tsMs` (the end of the period holding it). */
345
+ export function nextTradingPeriodStartMs(tsMs, anchor, unit, count) {
346
+ if (!Number.isFinite(tsMs))
347
+ return Number.NaN;
348
+ const group = calendarGroupIndexOf(dateIndexOf(tradingDateOf(tsMs, anchor)), unit, count) + 1;
349
+ return tradingDateOpenMs(calendarDateOfIndex(calendarGroupFirstDateIndexOf(group, unit, count)), anchor);
350
+ }
292
351
  /**
293
352
  * The TPO custom-time-range projection of an anchor, or undefined when the
294
353
  * anchor is absent, invalid, or has no wire-expressible projection. The CME
@@ -10,12 +10,33 @@ export declare const WRUN_WINDOW_SETTING = "wrunWindow";
10
10
  * the flag is.
11
11
  */
12
12
  export declare const WRUN_WINDOW_SPLIT_SETTING = "wrunWindowSplit";
13
- /** An overlay as the window rules read it: its id and its settings bag. */
13
+ /**
14
+ * The built-in Indicators that own a window the way a wrun Indicator does, by indicator type: the nine of the Options
15
+ * panel (NATIVE-WINDOW, 2026-10-28). Another built-in joins by adding its type here; every seam reads this one list.
16
+ */
17
+ export declare const WINDOW_NATIVE_OWNER_TYPES: ReadonlySet<string>;
18
+ /**
19
+ * An overlay as the window rules read it: its id, its type and its settings bag. A workspace row names its Indicator
20
+ * by `type` (its settings hold no `ovType`: an identity key no row keeps); an engine meta by `settings.ovType` (its
21
+ * `type` is the side).
22
+ */
14
23
  export type WindowOwnerOverlay = {
15
24
  id?: unknown;
25
+ type?: unknown;
16
26
  settings?: Record<string, unknown> | null;
17
27
  } | null | undefined;
18
- /** A wrun Indicator overlay (registry, draft or hosted lane) that carries the owner flag. */
28
+ /** The type of a built-in of WINDOW_NATIVE_OWNER_TYPES: a row's `type`, else an engine meta's `settings.ovType`. */
29
+ export declare function windowNativeTypeOf(overlay: WindowOwnerOverlay): string | undefined;
30
+ /** Whether an overlay is a built-in that can own a window (WINDOW_NATIVE_OWNER_TYPES). */
31
+ export declare function isWindowNativeOverlay(overlay: WindowOwnerOverlay): boolean;
32
+ /**
33
+ * Whether a document row can own a window, flagged or not: a saved wrun Indicator (registry or hosted: an editor
34
+ * draft has no row, draft-window.util) or a built-in of WINDOW_NATIVE_OWNER_TYPES. The doors that offer or open a
35
+ * window and the flag writer read it.
36
+ */
37
+ export declare function canOwnWindow(overlay: WindowOwnerOverlay): boolean;
38
+ /** A wrun Indicator overlay (registry, draft or hosted lane) or a built-in of WINDOW_NATIVE_OWNER_TYPES that carries
39
+ * the owner flag. */
19
40
  export declare function isWrunWindowOwner(overlay: WindowOwnerOverlay): boolean;
20
41
  /**
21
42
  * An engine meta as the window's pane mark reads it. The window geometry (window-geometry.leaf, C5) hides an owner's
@@ -3,8 +3,12 @@
3
3
  * window contract) as a leaf with no app import: the owner flag's settings key, the saved split's settings key and
4
4
  * the owner test. The child mount (wrun-panel-mount.util) and the window geometry leaf read them, and they move into
5
5
  * the wrun chart-host package, which the cell readers' reactive draft windows (draft-window.util) may not reach.
6
+ *
7
+ * Two kinds of Indicator can own a window: a wrun Indicator (the feature's name: the flag key stays `wrunWindow`), and
8
+ * a built-in of WINDOW_NATIVE_OWNER_TYPES. Every window seam (the owner test, the doors, the flag writer, the content
9
+ * and name reads) asks this rule, never wrun identity alone.
6
10
  */
7
- import { isWrunPackageOverlaySettings } from '../wrun/wrun-overlay-identity.util.js';
11
+ import { isWrunPackageOverlaySettings, isWrunSavedPackageOverlaySettings } from '../wrun/wrun-overlay-identity.util.js';
8
12
  /** The owner flag's settings key (persisted: `settingsToSave`, indicator.constants). */
9
13
  export const WRUN_WINDOW_SETTING = 'wrunWindow';
10
14
  /**
@@ -17,10 +21,48 @@ export const WRUN_WINDOW_SETTING = 'wrunWindow';
17
21
  * the flag is.
18
22
  */
19
23
  export const WRUN_WINDOW_SPLIT_SETTING = 'wrunWindowSplit';
20
- /** A wrun Indicator overlay (registry, draft or hosted lane) that carries the owner flag. */
24
+ /**
25
+ * The built-in Indicators that own a window the way a wrun Indicator does, by indicator type: the nine of the Options
26
+ * panel (NATIVE-WINDOW, 2026-10-28). Another built-in joins by adding its type here; every seam reads this one list.
27
+ */
28
+ export const WINDOW_NATIVE_OWNER_TYPES = new Set([
29
+ 'OPTIONS_GEX',
30
+ 'OPTIONS_HEATMAP',
31
+ 'OPTIONS_FLOW',
32
+ 'OPTIONS_GEX_CURVE',
33
+ 'OPTIONS_FLOW_PULSE',
34
+ 'OPTIONS_FLOW_EXPIRY',
35
+ 'BINANCE_PUT_CALL_RATIO',
36
+ 'IMPLIED_VOLATILITY_TICKER',
37
+ 'VOLATILITY_INDEX',
38
+ ]);
39
+ /** The type of a built-in of WINDOW_NATIVE_OWNER_TYPES: a row's `type`, else an engine meta's `settings.ovType`. */
40
+ export function windowNativeTypeOf(overlay) {
41
+ for (const type of [overlay?.type, overlay?.settings?.ovType]) {
42
+ if (typeof type === 'string' && WINDOW_NATIVE_OWNER_TYPES.has(type))
43
+ return type;
44
+ }
45
+ return undefined;
46
+ }
47
+ /** Whether an overlay is a built-in that can own a window (WINDOW_NATIVE_OWNER_TYPES). */
48
+ export function isWindowNativeOverlay(overlay) {
49
+ return windowNativeTypeOf(overlay) !== undefined;
50
+ }
51
+ /**
52
+ * Whether a document row can own a window, flagged or not: a saved wrun Indicator (registry or hosted: an editor
53
+ * draft has no row, draft-window.util) or a built-in of WINDOW_NATIVE_OWNER_TYPES. The doors that offer or open a
54
+ * window and the flag writer read it.
55
+ */
56
+ export function canOwnWindow(overlay) {
57
+ return isWrunSavedPackageOverlaySettings(overlay?.settings) || isWindowNativeOverlay(overlay);
58
+ }
59
+ /** A wrun Indicator overlay (registry, draft or hosted lane) or a built-in of WINDOW_NATIVE_OWNER_TYPES that carries
60
+ * the owner flag. */
21
61
  export function isWrunWindowOwner(overlay) {
22
62
  const settings = overlay?.settings;
23
- return !!settings && settings[WRUN_WINDOW_SETTING] === true && isWrunPackageOverlaySettings(settings);
63
+ return (!!settings &&
64
+ settings[WRUN_WINDOW_SETTING] === true &&
65
+ (isWrunPackageOverlaySettings(settings) || isWindowNativeOverlay(overlay)));
24
66
  }
25
67
  /** Whether a meta's pane is hidden by its window (above) and not by the reader: a gate that holds a collapsed pane's
26
68
  * runs lets this owner run, since its runs feed the window's tables (wrun-overlay-recovery.util). */
@@ -3,8 +3,7 @@
3
3
  * C3): `time.trade_date` and `time.session`. Both are facts of the bar's
4
4
  * market (exchange, symbol), its interval and its open time ONLY, never of
5
5
  * the chart's RTH / extended mode, and every hour comes from the chart's own
6
- * session definitions, the RTH window from the kScript engine's table (see
7
- * NYMEX below).
6
+ * session definitions, the RTH window the root's own (see NYMEX below).
8
7
  *
9
8
  * Calendar bars (an interval of one day or longer: 1D, 3D, 1W, 1M) read the
10
9
  * UTC date of their open stamp and 1 on every market: the chart stamps them
@@ -16,27 +15,44 @@
16
15
  * alias): the chart's CME trade date, `cmeSessionBucketMs(t, 1d)`, so the
17
16
  * 17:00 Chicago open belongs to the NEXT date;
18
17
  * - US equities (`getMarketKind` 'tradfi'): the New York calendar date;
19
- * - everything else (crypto, forex, HIP-3, Polymarket, ...): the UTC date.
18
+ * - forex (`getMarketKind` 'forex': FX_OTC, POLYGON_FX): the New York
19
+ * trade date, which opens at 17:00 New York (the forex day runs 17:00 to
20
+ * 17:00 New York, 21:00Z in summer and 22:00Z in winter), so a bar from
21
+ * 17:00 New York on belongs to the NEXT date and Sunday 17:00 New York
22
+ * opens Monday's; the same minute `market.session_open()` fills
23
+ * (WRUN_MARKET_SESSION_OPEN_FOREX);
24
+ * - everything else (crypto, HIP-3, Polymarket, ...): the UTC date.
20
25
  * - session, 1 regular, 2 pre-market, 3 after-hours, 0 closed:
21
26
  * - US equities: `resolveUsEquitySessionPhase`;
22
27
  * - CME family: 0 while the weekly schedule says closed
23
28
  * (`getGovernedFuturesScheduleStatusForSymbol`, which carries the 24/7
24
- * roots); else 1 inside the engine's RTH window
25
- * (`engineRthWindowForSymbol`, 09:30 to 16:15 New York on every mapped
26
- * root; a root without a window is regular all session), 2 before its
27
- * trade date's RTH window and 3 after it;
28
- * - everything else: 1.
29
+ * roots); else 1 inside the root's RTH window
30
+ * (`engineRthWindowForSymbol`, the chart's own: 09:30 to 16:15 New York,
31
+ * 09:00 to 14:30 on the NYMEX energy roots; a root without a window is
32
+ * regular all session), 2 before its trade date's RTH window and 3 after
33
+ * it;
34
+ * - forex and everything else: 1 (forex has no phases; its closed hours
35
+ * print no bars).
36
+ *
37
+ * The chart's own trading-day anchor (trading-day.util `getTradingDayAnchor`,
38
+ * the gate TPO, VWAP, the session dividers and the previous close read) does
39
+ * not carry the forex day yet: like US equities, forex keeps the display day
40
+ * there until that gate gains a New York 17:00 anchor in its own change, so
41
+ * a forex Indicator's trade date rolls at 17:00 New York while the chart's
42
+ * native dividers still roll at midnight.
29
43
  *
30
44
  * The golden vectors every other host (kscript-alerts, kscript-backend, om)
31
45
  * tests against are generated from this module:
32
46
  * src/fixtures/wrun-session-facts/golden.json.
33
47
  *
34
- * NYMEX: the chart judges RTH there on the energy pit session, 09:00 to 14:30
35
- * New York (rth-session.util `rthWindowForExchange`, the gateway's REGULAR
36
- * window), but wrun and kScript session facts on NYMEX follow the kScript
37
- * engine's table, 09:30 to 16:15, until a coordinated change moves the
38
- * engine, the golden and the cloud lanes together. Moving this browser lane
39
- * alone would split the browser and cloud runs of the same indicator.
48
+ * NYMEX: the facts follow the energy pit session, 09:00 to 14:30 New York, the
49
+ * window the chart judges RTH on there (rth-session.util
50
+ * `rthWindowForExchange`, the gateway's REGULAR window), so an indicator's
51
+ * `time.session` reads regular on exactly the bars an RTH chart keeps. The
52
+ * shared host's venue layer (om session-facts-venues.ts) reads the same
53
+ * windows and the golden pins them, so the browser and cloud runs of one
54
+ * indicator agree; the kScript engine's uniform 09:30 to 16:15 table is being
55
+ * retired and binds nothing.
40
56
  *
41
57
  * Cost: the definitions run at microseconds a call (the equities phase reads
42
58
  * dayjs timezone parts, about 30 us), so a 50k-bar run cannot afford one per
@@ -48,6 +64,8 @@
48
64
  * Chicago hours (16:00 and 17:00, the Saturday 02:00 to 04:00 window);
49
65
  * - the equities phase per New York (weekday, half hour): its boundaries are
50
66
  * 04:00, 09:30, 16:00 and 20:00;
67
+ * - the forex trade date per New York (date, hour): its one boundary is the
68
+ * whole hour 17:00;
51
69
  * - the CME RTH window per (window, trade date).
52
70
  * Both zones sit a whole number of hours off UTC, so a reader also keeps its
53
71
  * last answer per UTC hour (CME: the trade date and the schedule bit) or half
@@ -88,7 +106,7 @@ export interface WrunBarVenue {
88
106
  barGrid?: LiveBucketVenue;
89
107
  }
90
108
  /** Which C3 rule a market follows. */
91
- export type WrunBarFactsMarket = 'cme' | 'us_equities' | 'utc';
109
+ export type WrunBarFactsMarket = 'cme' | 'us_equities' | 'forex' | 'utc';
92
110
  export declare function wrunBarFactsMarketOf(exchange: string): WrunBarFactsMarket;
93
111
  /**
94
112
  * The venue of chart metadata (or a live context's market) at the series'
@@ -3,8 +3,7 @@
3
3
  * C3): `time.trade_date` and `time.session`. Both are facts of the bar's
4
4
  * market (exchange, symbol), its interval and its open time ONLY, never of
5
5
  * the chart's RTH / extended mode, and every hour comes from the chart's own
6
- * session definitions, the RTH window from the kScript engine's table (see
7
- * NYMEX below).
6
+ * session definitions, the RTH window the root's own (see NYMEX below).
8
7
  *
9
8
  * Calendar bars (an interval of one day or longer: 1D, 3D, 1W, 1M) read the
10
9
  * UTC date of their open stamp and 1 on every market: the chart stamps them
@@ -16,27 +15,44 @@
16
15
  * alias): the chart's CME trade date, `cmeSessionBucketMs(t, 1d)`, so the
17
16
  * 17:00 Chicago open belongs to the NEXT date;
18
17
  * - US equities (`getMarketKind` 'tradfi'): the New York calendar date;
19
- * - everything else (crypto, forex, HIP-3, Polymarket, ...): the UTC date.
18
+ * - forex (`getMarketKind` 'forex': FX_OTC, POLYGON_FX): the New York
19
+ * trade date, which opens at 17:00 New York (the forex day runs 17:00 to
20
+ * 17:00 New York, 21:00Z in summer and 22:00Z in winter), so a bar from
21
+ * 17:00 New York on belongs to the NEXT date and Sunday 17:00 New York
22
+ * opens Monday's; the same minute `market.session_open()` fills
23
+ * (WRUN_MARKET_SESSION_OPEN_FOREX);
24
+ * - everything else (crypto, HIP-3, Polymarket, ...): the UTC date.
20
25
  * - session, 1 regular, 2 pre-market, 3 after-hours, 0 closed:
21
26
  * - US equities: `resolveUsEquitySessionPhase`;
22
27
  * - CME family: 0 while the weekly schedule says closed
23
28
  * (`getGovernedFuturesScheduleStatusForSymbol`, which carries the 24/7
24
- * roots); else 1 inside the engine's RTH window
25
- * (`engineRthWindowForSymbol`, 09:30 to 16:15 New York on every mapped
26
- * root; a root without a window is regular all session), 2 before its
27
- * trade date's RTH window and 3 after it;
28
- * - everything else: 1.
29
+ * roots); else 1 inside the root's RTH window
30
+ * (`engineRthWindowForSymbol`, the chart's own: 09:30 to 16:15 New York,
31
+ * 09:00 to 14:30 on the NYMEX energy roots; a root without a window is
32
+ * regular all session), 2 before its trade date's RTH window and 3 after
33
+ * it;
34
+ * - forex and everything else: 1 (forex has no phases; its closed hours
35
+ * print no bars).
36
+ *
37
+ * The chart's own trading-day anchor (trading-day.util `getTradingDayAnchor`,
38
+ * the gate TPO, VWAP, the session dividers and the previous close read) does
39
+ * not carry the forex day yet: like US equities, forex keeps the display day
40
+ * there until that gate gains a New York 17:00 anchor in its own change, so
41
+ * a forex Indicator's trade date rolls at 17:00 New York while the chart's
42
+ * native dividers still roll at midnight.
29
43
  *
30
44
  * The golden vectors every other host (kscript-alerts, kscript-backend, om)
31
45
  * tests against are generated from this module:
32
46
  * src/fixtures/wrun-session-facts/golden.json.
33
47
  *
34
- * NYMEX: the chart judges RTH there on the energy pit session, 09:00 to 14:30
35
- * New York (rth-session.util `rthWindowForExchange`, the gateway's REGULAR
36
- * window), but wrun and kScript session facts on NYMEX follow the kScript
37
- * engine's table, 09:30 to 16:15, until a coordinated change moves the
38
- * engine, the golden and the cloud lanes together. Moving this browser lane
39
- * alone would split the browser and cloud runs of the same indicator.
48
+ * NYMEX: the facts follow the energy pit session, 09:00 to 14:30 New York, the
49
+ * window the chart judges RTH on there (rth-session.util
50
+ * `rthWindowForExchange`, the gateway's REGULAR window), so an indicator's
51
+ * `time.session` reads regular on exactly the bars an RTH chart keeps. The
52
+ * shared host's venue layer (om session-facts-venues.ts) reads the same
53
+ * windows and the golden pins them, so the browser and cloud runs of one
54
+ * indicator agree; the kScript engine's uniform 09:30 to 16:15 table is being
55
+ * retired and binds nothing.
40
56
  *
41
57
  * Cost: the definitions run at microseconds a call (the equities phase reads
42
58
  * dayjs timezone parts, about 30 us), so a 50k-bar run cannot afford one per
@@ -48,6 +64,8 @@
48
64
  * Chicago hours (16:00 and 17:00, the Saturday 02:00 to 04:00 window);
49
65
  * - the equities phase per New York (weekday, half hour): its boundaries are
50
66
  * 04:00, 09:30, 16:00 and 20:00;
67
+ * - the forex trade date per New York (date, hour): its one boundary is the
68
+ * whole hour 17:00;
51
69
  * - the CME RTH window per (window, trade date).
52
70
  * Both zones sit a whole number of hours off UTC, so a reader also keeps its
53
71
  * last answer per UTC hour (CME: the trade date and the schedule bit) or half
@@ -59,6 +77,7 @@
59
77
  * Worker-safe: imports only the chart's session utils (no Vue, store, i18n).
60
78
  */
61
79
  import { Intervals } from '../../constants/interval.constants.js';
80
+ import { WRUN_MARKET_SESSION_OPEN_FOREX } from '../wrun/wrun-market-facts.util.js';
62
81
  import { cmeSessionBucketMs } from './cme-session-bucket.util.js';
63
82
  import { isCmeGoverned } from './cme-realtime.util.js';
64
83
  import { liveBucketVenueOf } from './live-bucket.util.js';
@@ -82,7 +101,12 @@ export const WRUN_BAR_SESSION = Object.freeze({
82
101
  export function wrunBarFactsMarketOf(exchange) {
83
102
  if (isCmeGoverned(exchange))
84
103
  return 'cme';
85
- return getMarketKind(exchange) === 'tradfi' ? 'us_equities' : 'utc';
104
+ const kind = getMarketKind(exchange);
105
+ if (kind === 'tradfi')
106
+ return 'us_equities';
107
+ if (kind === 'forex')
108
+ return 'forex';
109
+ return 'utc';
86
110
  }
87
111
  /**
88
112
  * The venue of chart metadata (or a live context's market) at the series'
@@ -257,6 +281,29 @@ function usEquityFactsResolver() {
257
281
  return answer;
258
282
  };
259
283
  }
284
+ // ─── Forex ───────────────────────────────────────────────────────────────────
285
+ /** The forex trade day opens at 17:00 New York: the minute `market.session_open()` fills, as ms. */
286
+ const FOREX_OPEN_MS = WRUN_MARKET_SESSION_OPEN_FOREX * MINUTE_MS;
287
+ function forexFactsResolver() {
288
+ // New York's offset is whole hours and the 17:00 cut sits on the hour, so one UTC hour is one
289
+ // New York (date, hour): one answer for every bar inside it. A bar from 17:00 on belongs to the
290
+ // next date (Sunday 17:00 opens Monday's trade date); every bar is regular.
291
+ let slotMs = Number.NaN;
292
+ let answer = NO_FACTS;
293
+ return (tMs) => {
294
+ const barSlotMs = floorTo(tMs, HOUR_MS);
295
+ if (barSlotMs !== slotMs) {
296
+ const day = zoneDayOf(newYorkClock, tMs);
297
+ const evening = wallSinceMidnightMs(newYorkClock, day, tMs) >= FOREX_OPEN_MS;
298
+ answer = Object.freeze({
299
+ tradeDateSec: (day.dateMs + (evening ? DAY_MS : 0)) / 1000,
300
+ session: WRUN_BAR_SESSION.regular,
301
+ });
302
+ slotMs = barSlotMs;
303
+ }
304
+ return answer;
305
+ };
306
+ }
260
307
  // ─── CME family ──────────────────────────────────────────────────────────────
261
308
  const HOURS_PER_DAY = 24;
262
309
  /** The schedule's open bit per Chicago (weekday, hour), one table per schedule; -1 = not read yet. */
@@ -279,9 +326,10 @@ const TRADE_DATE_WINDOWS_MAX = 4096;
279
326
  const rthWindowByTradeDate = new WeakMap();
280
327
  /**
281
328
  * The RTH window of the CME trade date `tradeDateMs` (00:00Z label): the
282
- * calendar-day window whose open carries that trade date. The 09:30 to 16:15
283
- * New York window sits inside one trade date (the 17:00 Chicago roll is
284
- * after its close), so exactly one window qualifies.
329
+ * calendar-day window whose open carries that trade date. Every root's window
330
+ * (09:30 to 16:15 New York, 09:00 to 14:30 on NYMEX) sits inside one trade
331
+ * date (the 17:00 Chicago roll is after its close), so exactly one window
332
+ * qualifies.
285
333
  */
286
334
  function rthWindowOfTradeDate(window, tradeDateMs) {
287
335
  let byTradeDate = rthWindowByTradeDate.get(window);
@@ -330,7 +378,7 @@ function cmeFactsResolver(symbol) {
330
378
  rth = rthWindowOfTradeDate(window, tradeDateMs);
331
379
  rthTradeDateMs = tradeDateMs;
332
380
  }
333
- // No window on the trade date is unreachable with the uniform window; read it like a root without one.
381
+ // No window on the trade date is unreachable with these windows; read it like a root without one.
334
382
  if (rth === null || (tMs >= rth.openMs && tMs < rth.closeMs))
335
383
  return answers[WRUN_BAR_SESSION.regular];
336
384
  return answers[tMs < rth.openMs ? WRUN_BAR_SESSION.premarket : WRUN_BAR_SESSION.afterHours];
@@ -365,7 +413,9 @@ export function wrunBarSessionFactsResolver(venue) {
365
413
  ? cmeFactsResolver(venue.symbol)
366
414
  : market === 'us_equities'
367
415
  ? usEquityFactsResolver()
368
- : utcFactsResolver();
416
+ : market === 'forex'
417
+ ? forexFactsResolver()
418
+ : utcFactsResolver();
369
419
  return (barOpenMs) => (Number.isFinite(barOpenMs) ? facts(barOpenMs) : NO_FACTS);
370
420
  }
371
421
  /** One bar's facts (a one-off read; hot loops bind `wrunBarSessionFactsResolver` once). */
@@ -8,6 +8,11 @@ const INTL_LOCALES = {
8
8
  hi: 'hi-IN',
9
9
  es: 'es-ES',
10
10
  tr: 'tr-TR',
11
+ pt: 'pt-BR',
12
+ fr: 'fr-FR',
13
+ de: 'de-DE',
14
+ it: 'it-IT',
15
+ pl: 'pl-PL',
11
16
  };
12
17
  const INTL_TAGS = new Set(Object.values(INTL_LOCALES));
13
18
  /** The Intl tag for an app locale code. Idempotent: a value that already is an Intl tag passes through. */
@@ -272,6 +272,8 @@ export function normalizeRuntimeDiagnostics(value, options = {}) {
272
272
  details: isObject(raw.details) ? { ...raw.details } : undefined,
273
273
  // The row's OPRA mark (computed over OPRA data) survives every normalization: the store's choke point included.
274
274
  ...(raw.opra === true ? { opra: true } : {}),
275
+ // The CME mark (computed over CME data) the same way.
276
+ ...(raw.cme === true ? { cme: true } : {}),
275
277
  },
276
278
  ];
277
279
  });
@@ -1,15 +1,22 @@
1
1
  import type { GateProvider } from '../../workers/constants/socket-slots.js';
2
2
  import { isOpraGoverned } from './opra-governed.util.js';
3
+ import { isStocksTapeGoverned } from './stocks-governed.util.js';
3
4
  export interface GatePlane {
4
5
  provider: GateProvider;
5
6
  /** UPPERCASE exchange codes the plane governs. */
6
7
  exchanges: readonly string[];
7
8
  /** The delayed tier's nominal delay, used until the tier frame reports `delay_seconds`. */
8
9
  delayedDefaultSeconds: number;
9
- /** What a logged-out reader request gets: the CME Surface A snapshot, or nothing (OPRA has no snapshot). */
10
- guestReaderTransport: 'surfaceA' | 'none';
10
+ /**
11
+ * What a logged-out visitor gets: the CME Surface A snapshot for reader kinds (`surfaceA`), nothing (`none`: OPRA
12
+ * has no snapshot and its gate takes a session JWT only), or the gate itself (`gate`: the stocks gate admits the
13
+ * guest token on its delayed tiers, reader and feed kinds alike, and registers nothing for it).
14
+ */
15
+ guestReaderTransport: 'surfaceA' | 'none' | 'gate';
11
16
  /** The plane relays order-book types (OPRA is top of book only; its feed publishes none). */
12
17
  servesBooks: boolean;
18
+ /** The gate serves StreamMarketStats; flip per plane once its gate does, with the stats planner routing to it. */
19
+ servesMarketStats: boolean;
13
20
  /** The gate mounts /v3 reader tiers beside /v2 (OPRA: not mounted). */
14
21
  hasV3Tiers: boolean;
15
22
  /**
@@ -21,9 +28,11 @@ export interface GatePlane {
21
28
  mixedWithPublic: 'ungoverned' | 'refuse';
22
29
  }
23
30
  export declare const GATE_PLANES: Readonly<Record<GateProvider, GatePlane>>;
24
- export { isOpraGoverned };
31
+ export { isOpraGoverned, isStocksTapeGoverned };
25
32
  /** The gate plane one exchange code belongs to, or null when no gate governs it. */
26
33
  export declare function gateProviderForExchange(exchange: string | undefined | null): GateProvider | null;
34
+ /** The plane of an exchange whose gate serves no StreamMarketStats (no stats request may name it), else null. */
35
+ export declare function marketStatsUnservedPlane(exchange?: string | null): GateProvider | null;
27
36
  /** One exchange member of a request payload as an UPPERCASE code: a name, or a pb-common enum number. */
28
37
  export declare function exchangeCodeOf(member: unknown): string | null;
29
38
  /**
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * The entitlement-gate planes: which gate serves an exchange, and the per-plane
3
- * facts routing needs (delayed default, guest treatment, books). CME and OPRA
4
- * speak the same gate protocol on different hosts, licences and kick channels.
3
+ * facts routing needs (delayed default, guest treatment, books). CME, OPRA and
4
+ * the US stocks tape speak the same gate protocol on different hosts, licences
5
+ * and kick channels.
5
6
  *
6
7
  * Worker-safe and store-free (imports the interfaces, the slot table and the
7
8
  * CME predicate only), so the worker send path and the main-thread services
@@ -11,8 +12,10 @@
11
12
  import { Exchange } from '@orangecharts/orange-v2-pb-common';
12
13
  import { CME_GOVERNED_EXCHANGES } from '../../interfaces/cme-realtime.interface.js';
13
14
  import { OPRA_DELAY_MINUTES, OPRA_GOVERNED_EXCHANGES } from '../../interfaces/opra-realtime.interface.js';
15
+ import { STOCKS_DELAY_SECONDS, STOCKS_GOVERNED_EXCHANGES } from '../../interfaces/stocks-realtime.interface.js';
14
16
  import { CME_DELAY_MINUTES, isCmeGoverned, normalizeExchangeCode } from '../chart/cme-realtime.util.js';
15
17
  import { isOpraGoverned } from './opra-governed.util.js';
18
+ import { isStocksTapeGoverned } from './stocks-governed.util.js';
16
19
  export const GATE_PLANES = {
17
20
  cme: {
18
21
  provider: 'cme',
@@ -20,6 +23,7 @@ export const GATE_PLANES = {
20
23
  delayedDefaultSeconds: CME_DELAY_MINUTES * 60,
21
24
  guestReaderTransport: 'surfaceA',
22
25
  servesBooks: true,
26
+ servesMarketStats: false,
23
27
  hasV3Tiers: true,
24
28
  mixedWithPublic: 'ungoverned',
25
29
  },
@@ -29,20 +33,42 @@ export const GATE_PLANES = {
29
33
  delayedDefaultSeconds: OPRA_DELAY_MINUTES * 60,
30
34
  guestReaderTransport: 'none',
31
35
  servesBooks: false,
36
+ servesMarketStats: false,
37
+ hasV3Tiers: false,
38
+ mixedWithPublic: 'refuse',
39
+ },
40
+ // The US stocks tape: trades only (no books), no /v3 mount, 15 min + 5 s behind for everyone without the add-on, a
41
+ // guest dials the delayed tiers with the guest token. Tape rows live on the cme cluster only, so a request mixing a
42
+ // tape with an ungoverned venue is refused rather than answered silently empty by the public reader.
43
+ stocks: {
44
+ provider: 'stocks',
45
+ exchanges: STOCKS_GOVERNED_EXCHANGES,
46
+ delayedDefaultSeconds: STOCKS_DELAY_SECONDS,
47
+ guestReaderTransport: 'gate',
48
+ servesBooks: false,
49
+ servesMarketStats: false,
32
50
  hasV3Tiers: false,
33
51
  mixedWithPublic: 'refuse',
34
52
  },
35
53
  };
36
- // The OPRA check is the pure leaf's (opra-governed.util); its importers keep this path.
37
- export { isOpraGoverned };
54
+ // The OPRA and stocks checks are the pure leaves' (opra-governed.util, stocks-governed.util); their importers keep
55
+ // this path.
56
+ export { isOpraGoverned, isStocksTapeGoverned };
38
57
  /** The gate plane one exchange code belongs to, or null when no gate governs it. */
39
58
  export function gateProviderForExchange(exchange) {
40
59
  if (isCmeGoverned(exchange))
41
60
  return 'cme';
42
61
  if (isOpraGoverned(exchange))
43
62
  return 'opra';
63
+ if (isStocksTapeGoverned(exchange))
64
+ return 'stocks';
44
65
  return null;
45
66
  }
67
+ /** The plane of an exchange whose gate serves no StreamMarketStats (no stats request may name it), else null. */
68
+ export function marketStatsUnservedPlane(exchange) {
69
+ const provider = gateProviderForExchange(exchange);
70
+ return provider !== null && !GATE_PLANES[provider].servesMarketStats ? provider : null;
71
+ }
46
72
  /** One exchange member of a request payload as an UPPERCASE code: a name, or a pb-common enum number. */
47
73
  export function exchangeCodeOf(member) {
48
74
  if (typeof member === 'number')
@@ -1,4 +1,4 @@
1
- const heldElsewhere = { cme: false, opra: false };
1
+ const heldElsewhere = { cme: false, opra: false, stocks: false };
2
2
  const listeners = new Set();
3
3
  /** The owner's edge: `true` once a contested kick latched the plane, `false` once this tab took the session back.
4
4
  * Listeners hear a change only, each in turn; one that throws never stops the next. */
@@ -0,0 +1,16 @@
1
+ import type { StocksTapeListingVenue } from '../../interfaces/stocks-realtime.interface.js';
2
+ export declare function isStocksTapeGoverned(exchange: string | undefined | null): boolean;
3
+ /**
4
+ * The name a request carries on the wire for an exchange: a tape code becomes its listing venue (the `Exchange` enum
5
+ * member the stocks gate keys the tape by, `NASDAQ_TAPE` -> `NASDAQ`); any other code is itself. The one translation
6
+ * for requests, applied where an exchange name becomes its enum id (the worker's request args, the series request
7
+ * builder, the markets request builder) and to the channels a stocks live-feed slot sends. Typed to keep the caller's
8
+ * exchange type: the wire names are members of the `Exchange` names a typed channel or request carries.
9
+ */
10
+ export declare function stocksTapeWireExchange<E extends string>(exchange: E): E | StocksTapeListingVenue;
11
+ /**
12
+ * The tape code of a wire name that arrived on a stocks slot (`NASDAQ` -> `NASDAQ_TAPE`); any other name is itself.
13
+ * Applied to frames and registry rows from the stocks gate ALONE: on the public reader and the crypto feed `NASDAQ` is
14
+ * a listing venue of the free lane, never a tape.
15
+ */
16
+ export declare function stocksTapeCodeOfWire(exchange: string): string;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Whether an exchange is governed by the US stocks entitlement gate (one of the three SIP tapes, by the app's tape
3
+ * codes `NYSE_TAPE`, `NYSE_ARCA_TAPE`, `NASDAQ_TAPE`): a pure leaf beside `opra-governed.util`, read by the gate plane
4
+ * table, the live-feed channel classifier, the kScript venue policy and the alert door without the socket-slot table.
5
+ * The plain listing-venue codes (`NYSE`, `NASDAQ`) are NOT governed: they are the free lane's display venues
6
+ * (interfaces/stocks-realtime.interface.ts tells why). The governed codes are the package's byte copy of the stocks
7
+ * interface's list (pinned equal to it by tests/packages/wrun-chart-host/narrowed-constants.spec.ts).
8
+ */
9
+ import { normalizeExchangeCode } from '../chart/cme-realtime.util.js';
10
+ import { STOCKS_GOVERNED_EXCHANGES, STOCKS_TAPE_WIRE_EXCHANGE } from '../../constants/governed-exchanges.constants.js';
11
+ const STOCKS_GOVERNED_EXCHANGE_SET = new Set(STOCKS_GOVERNED_EXCHANGES);
12
+ const TAPE_CODE_OF_WIRE = new Map(Object.entries(STOCKS_TAPE_WIRE_EXCHANGE).map(([code, wire]) => [wire, code]));
13
+ export function isStocksTapeGoverned(exchange) {
14
+ const code = normalizeExchangeCode(exchange);
15
+ return code !== null && STOCKS_GOVERNED_EXCHANGE_SET.has(code);
16
+ }
17
+ /**
18
+ * The name a request carries on the wire for an exchange: a tape code becomes its listing venue (the `Exchange` enum
19
+ * member the stocks gate keys the tape by, `NASDAQ_TAPE` -> `NASDAQ`); any other code is itself. The one translation
20
+ * for requests, applied where an exchange name becomes its enum id (the worker's request args, the series request
21
+ * builder, the markets request builder) and to the channels a stocks live-feed slot sends. Typed to keep the caller's
22
+ * exchange type: the wire names are members of the `Exchange` names a typed channel or request carries.
23
+ */
24
+ export function stocksTapeWireExchange(exchange) {
25
+ return STOCKS_TAPE_WIRE_EXCHANGE[exchange.toUpperCase()] ?? exchange;
26
+ }
27
+ /**
28
+ * The tape code of a wire name that arrived on a stocks slot (`NASDAQ` -> `NASDAQ_TAPE`); any other name is itself.
29
+ * Applied to frames and registry rows from the stocks gate ALONE: on the public reader and the crypto feed `NASDAQ` is
30
+ * a listing venue of the free lane, never a tape.
31
+ */
32
+ export function stocksTapeCodeOfWire(exchange) {
33
+ return TAPE_CODE_OF_WIRE.get(exchange.toUpperCase()) ?? exchange;
34
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The derived-roots table, a leaf with no imports: the wrun `underlying` knob (derived-roots.util) and the built-in
3
+ * options overlays' Chain row (utility/options/options-derived-root.util in the web app) read the same rows.
4
+ */
5
+ /**
6
+ * Contract F's mapping table (the kit's DERIVED_ROOTS in options.ts, row for row): a chart root and the roots whose
7
+ * chains its derived levels read, the first one the default (`defaultDerivedRoot`).
8
+ */
9
+ export declare const WRUN_DERIVED_ROOTS: Readonly<Record<string, readonly string[]>>;
10
+ /** The roots the table maps `chartRoot` to, the default first; none for a root off the table. */
11
+ export declare function wrunDerivedRootsOf(chartRoot: string): readonly string[];
12
+ /** The root `underlying: "derived"` reads on a chart of `chartRoot`: the table's first, undefined off the table. */
13
+ export declare function defaultDerivedRoot(chartRoot: string): string | undefined;