@orangecharts/wrun-chart-host 0.10.0 → 0.11.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 (145) 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 +6 -1
  10. package/dist/index.js +6 -1
  11. package/dist/interfaces/cancel-reason.interface.d.ts +1 -1
  12. package/dist/interfaces/cme-realtime.interface.d.ts +16 -9
  13. package/dist/interfaces/cme-realtime.interface.js +6 -3
  14. package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
  15. package/dist/interfaces/opra-realtime.interface.d.ts +1 -5
  16. package/dist/interfaces/prediction-market.interface.d.ts +7 -0
  17. package/dist/interfaces/stocks-realtime.interface.d.ts +57 -0
  18. package/dist/interfaces/stocks-realtime.interface.js +32 -0
  19. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +48 -117
  20. package/dist/kscript-data/controls/live-trades-merge.util.js +97 -207
  21. package/dist/market-data/billing.interface.d.ts +86 -12
  22. package/dist/market-data/billing.interface.js +23 -4
  23. package/dist/market-data/venue.d.ts +65 -2
  24. package/dist/market-data/venues/index.d.ts +135 -5
  25. package/dist/market-data/venues/index.js +2 -1
  26. package/dist/market-data/venues/opra.contract.copy.json +3 -2
  27. package/dist/market-data/venues/opra.d.ts +2 -2
  28. package/dist/market-data/venues/opra.js +5 -2
  29. package/dist/market-data/venues/stocks.contract.copy.json +64 -0
  30. package/dist/market-data/venues/stocks.d.ts +130 -0
  31. package/dist/market-data/venues/stocks.js +117 -0
  32. package/dist/settings-templates/footprint-rows.js +35 -2
  33. package/dist/settings-templates/form-rows.d.ts +2 -1
  34. package/dist/settings-templates/indicator-fields.js +34 -4
  35. package/dist/settings-templates/tool-rules.d.ts +12 -5
  36. package/dist/settings-templates/tool-rules.js +11 -5
  37. package/dist/settings-templates/tool-tables.generated.js +4 -0
  38. package/dist/utility/chart/cme-cache-context.util.d.ts +5 -3
  39. package/dist/utility/chart/cme-cache-context.util.js +10 -6
  40. package/dist/utility/chart/cme-realtime.util.js +10 -0
  41. package/dist/utility/chart/cme-user-scripts-gate.util.d.ts +83 -0
  42. package/dist/utility/chart/cme-user-scripts-gate.util.js +142 -0
  43. package/dist/utility/chart/effective-chart-session.util.d.ts +14 -0
  44. package/dist/utility/chart/effective-chart-session.util.js +39 -0
  45. package/dist/utility/chart/host-bar-placement.util.d.ts +28 -0
  46. package/dist/utility/chart/host-bar-placement.util.js +170 -30
  47. package/dist/utility/chart/index-host-tier.util.d.ts +3 -1
  48. package/dist/utility/chart/index-host-tier.util.js +7 -2
  49. package/dist/utility/chart/index-mode-admission.util.js +25 -11
  50. package/dist/utility/chart/kscript-apply-fingerprint.util.js +1 -1
  51. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +6 -9
  52. package/dist/utility/chart/kscript-live-coalesce.util.js +8 -9
  53. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +9 -0
  54. package/dist/utility/chart/kscript-live-source-identity.util.js +10 -1
  55. package/dist/utility/chart/kscript-provenance-keys.util.js +7 -0
  56. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
  57. package/dist/utility/chart/kscript-venue-policy.util.d.ts +115 -21
  58. package/dist/utility/chart/kscript-venue-policy.util.js +194 -40
  59. package/dist/utility/chart/live-bucket.util.d.ts +24 -8
  60. package/dist/utility/chart/live-bucket.util.js +85 -27
  61. package/dist/utility/chart/marketKind.util.js +5 -0
  62. package/dist/utility/chart/mixed-mode.util.d.ts +7 -0
  63. package/dist/utility/chart/mixed-mode.util.js +14 -0
  64. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +11 -16
  65. package/dist/utility/chart/opra-user-scripts-gate.util.js +12 -28
  66. package/dist/utility/chart/rth-session.util.d.ts +9 -8
  67. package/dist/utility/chart/rth-session.util.js +23 -20
  68. package/dist/utility/chart/trading-day.util.d.ts +17 -0
  69. package/dist/utility/chart/trading-day.util.js +59 -0
  70. package/dist/utility/chart/window-owner.leaf.d.ts +23 -2
  71. package/dist/utility/chart/window-owner.leaf.js +45 -3
  72. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +33 -15
  73. package/dist/utility/chart/wrun-bar-session-facts.util.js +70 -20
  74. package/dist/utility/intl-locale.util.js +5 -0
  75. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
  76. package/dist/utility/v2/gate-plane.util.d.ts +12 -3
  77. package/dist/utility/v2/gate-plane.util.js +30 -4
  78. package/dist/utility/v2/gate-session-latch.util.js +1 -1
  79. package/dist/utility/v2/stocks-governed.util.d.ts +16 -0
  80. package/dist/utility/v2/stocks-governed.util.js +34 -0
  81. package/dist/utility/wrun/derived-roots.leaf.d.ts +13 -0
  82. package/dist/utility/wrun/derived-roots.leaf.js +27 -0
  83. package/dist/utility/wrun/derived-roots.util.d.ts +1 -9
  84. package/dist/utility/wrun/derived-roots.util.js +3 -23
  85. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +4 -3
  86. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +24 -3
  87. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +46 -10
  88. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +2 -0
  89. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +63 -16
  90. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +58 -14
  91. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +34 -11
  92. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +106 -30
  93. package/dist/utility/wrun/wrun-browser-sources.leaf.js +1 -2
  94. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +7 -4
  95. package/dist/utility/wrun/wrun-chart-market-facts.util.js +12 -8
  96. package/dist/utility/wrun/wrun-color-settings.util.d.ts +9 -0
  97. package/dist/utility/wrun/wrun-color-settings.util.js +33 -0
  98. package/dist/utility/wrun/wrun-handles.util.d.ts +7 -3
  99. package/dist/utility/wrun/wrun-handles.util.js +9 -8
  100. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +68 -0
  101. package/dist/utility/wrun/wrun-input-requirements.leaf.js +163 -7
  102. package/dist/utility/wrun/wrun-leg-close.util.d.ts +59 -23
  103. package/dist/utility/wrun/wrun-leg-close.util.js +186 -28
  104. package/dist/utility/wrun/wrun-live-intake.util.d.ts +26 -12
  105. package/dist/utility/wrun/wrun-live-intake.util.js +219 -155
  106. package/dist/utility/wrun/wrun-live-tick.util.d.ts +9 -5
  107. package/dist/utility/wrun/wrun-live-tick.util.js +130 -94
  108. package/dist/utility/wrun/wrun-market-facts.util.d.ts +13 -3
  109. package/dist/utility/wrun/wrun-market-facts.util.js +13 -3
  110. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +20 -10
  111. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +10 -5
  112. package/dist/utility/wrun/wrun-option-book-rows.util.d.ts +56 -0
  113. package/dist/utility/wrun/wrun-option-book-rows.util.js +96 -0
  114. package/dist/utility/wrun/wrun-option-views.util.d.ts +281 -20
  115. package/dist/utility/wrun/wrun-option-views.util.js +391 -50
  116. package/dist/utility/wrun/wrun-options-chain.util.d.ts +3 -3
  117. package/dist/utility/wrun/wrun-options-chain.util.js +2 -0
  118. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +15 -2
  119. package/dist/utility/wrun/wrun-overlay-drivers.util.js +13 -3
  120. package/dist/utility/wrun/wrun-overlay-recovery.util.js +3 -1
  121. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +60 -11
  122. package/dist/utility/wrun/wrun-overlay-run.util.js +529 -113
  123. package/dist/utility/wrun/wrun-panel-mount.util.js +51 -6
  124. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +15 -2
  125. package/dist/utility/wrun/wrun-pin-spelling.util.js +27 -3
  126. package/dist/utility/wrun/wrun-refusal.util.d.ts +3 -2
  127. package/dist/utility/wrun/wrun-refusal.util.js +22 -0
  128. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +26 -0
  129. package/dist/utility/wrun/wrun-registry-errors.util.js +34 -0
  130. package/dist/utility/wrun/wrun-replay-lane.util.js +3 -2
  131. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +20 -6
  132. package/dist/utility/wrun/wrun-run-interval-session.util.js +22 -7
  133. package/dist/utility/wrun/wrun-run-interval.util.d.ts +39 -7
  134. package/dist/utility/wrun/wrun-run-interval.util.js +49 -9
  135. package/dist/utility/wrun/wrun-socket-row-source.js +7 -2
  136. package/dist/utility/wrun/wrun-source-rows.util.d.ts +29 -22
  137. package/dist/utility/wrun/wrun-source-rows.util.js +62 -41
  138. package/dist/utility/wrun/wrun-tape-per-order.util.js +1 -20
  139. package/dist/utility/wrun/wrun-tape-source.util.d.ts +17 -9
  140. package/dist/utility/wrun/wrun-tape-source.util.js +20 -12
  141. package/dist/workers/constants/socket-slots.d.ts +91 -6
  142. package/dist/workers/constants/socket-slots.js +85 -6
  143. package/package.json +11 -11
  144. package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +0 -56
  145. package/dist/kscript-data/controls/live-trades-order-gate.util.js +0 -107
@@ -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;
@@ -0,0 +1,27 @@
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 const WRUN_DERIVED_ROOTS = Object.freeze({
10
+ ES: Object.freeze(['SPX', 'SPY']),
11
+ NQ: Object.freeze(['NDX', 'QQQ']),
12
+ GC: Object.freeze(['GLD']),
13
+ SI: Object.freeze(['SLV']),
14
+ YM: Object.freeze(['DIA']),
15
+ RTY: Object.freeze(['IWM']),
16
+ SPY: Object.freeze(['SPX']),
17
+ QQQ: Object.freeze(['NDX']),
18
+ });
19
+ /** The roots the table maps `chartRoot` to, the default first; none for a root off the table. */
20
+ export function wrunDerivedRootsOf(chartRoot) {
21
+ const key = chartRoot.trim().toUpperCase();
22
+ return Object.prototype.hasOwnProperty.call(WRUN_DERIVED_ROOTS, key) ? WRUN_DERIVED_ROOTS[key] : [];
23
+ }
24
+ /** The root `underlying: "derived"` reads on a chart of `chartRoot`: the table's first, undefined off the table. */
25
+ export function defaultDerivedRoot(chartRoot) {
26
+ return wrunDerivedRootsOf(chartRoot)[0];
27
+ }
@@ -5,15 +5,7 @@ import { type WrunChartOptionsMarketDecision } from './run-schedule/wrun-chart-g
5
5
  import type { WrunLaneChainDecider, WrunLaneChartChain } from './sources/opra-option-lanes.util.js';
6
6
  import type { WrunPollLaneContext } from './sources/wrun-poll-lane.types.js';
7
7
  import { type WrunOptionsChainCryptoVenueWord, type WrunOptionsChainDecision } from './wrun-options-chain.util.js';
8
- /**
9
- * Contract F's mapping table (the kit's DERIVED_ROOTS in options.ts, row for row): a chart root and the roots whose
10
- * chains its derived levels read, the first one the default (`defaultDerivedRoot`).
11
- */
12
- export declare const WRUN_DERIVED_ROOTS: Readonly<Record<string, readonly string[]>>;
13
- /** The roots the table maps `chartRoot` to, the default first; none for a root off the table. */
14
- export declare function wrunDerivedRootsOf(chartRoot: string): readonly string[];
15
- /** The root `underlying: "derived"` reads on a chart of `chartRoot`: the table's first, undefined off the table. */
16
- export declare function defaultDerivedRoot(chartRoot: string): string | undefined;
8
+ export { WRUN_DERIVED_ROOTS, defaultDerivedRoot, wrunDerivedRootsOf } from './derived-roots.leaf.js';
17
9
  /** The knob's name on a source. */
18
10
  export declare const WRUN_UNDERLYING_KNOB = "underlying";
19
11
  /** The knob's default word: the chart's own chain. */
@@ -49,29 +49,9 @@ import { wrunParamChoices } from './wrun-color-settings.util.js';
49
49
  import { WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_IDS, } from './wrun-options-chain.util.js';
50
50
  import { refuseWrunOptionKnob } from './wrun-option-knobs.util.js';
51
51
  import { attachWrunRefusal } from './wrun-refusal.util.js';
52
- /**
53
- * Contract F's mapping table (the kit's DERIVED_ROOTS in options.ts, row for row): a chart root and the roots whose
54
- * chains its derived levels read, the first one the default (`defaultDerivedRoot`).
55
- */
56
- export const WRUN_DERIVED_ROOTS = Object.freeze({
57
- ES: Object.freeze(['SPX', 'SPY']),
58
- NQ: Object.freeze(['NDX', 'QQQ']),
59
- GC: Object.freeze(['GLD']),
60
- SI: Object.freeze(['SLV']),
61
- YM: Object.freeze(['DIA']),
62
- RTY: Object.freeze(['IWM']),
63
- SPY: Object.freeze(['SPX']),
64
- QQQ: Object.freeze(['NDX']),
65
- });
66
- /** The roots the table maps `chartRoot` to, the default first; none for a root off the table. */
67
- export function wrunDerivedRootsOf(chartRoot) {
68
- const key = chartRoot.trim().toUpperCase();
69
- return Object.prototype.hasOwnProperty.call(WRUN_DERIVED_ROOTS, key) ? WRUN_DERIVED_ROOTS[key] : [];
70
- }
71
- /** The root `underlying: "derived"` reads on a chart of `chartRoot`: the table's first, undefined off the table. */
72
- export function defaultDerivedRoot(chartRoot) {
73
- return wrunDerivedRootsOf(chartRoot)[0];
74
- }
52
+ import { WRUN_DERIVED_ROOTS, defaultDerivedRoot } from './derived-roots.leaf.js';
53
+ // The table is the leaf's (derived-roots.leaf), so a reader of the rows alone never loads this module's graph.
54
+ export { WRUN_DERIVED_ROOTS, defaultDerivedRoot, wrunDerivedRootsOf } from './derived-roots.leaf.js';
75
55
  /** The knob's name on a source. */
76
56
  export const WRUN_UNDERLYING_KNOB = 'underlying';
77
57
  /** The knob's default word: the chart's own chain. */
@@ -1,10 +1,11 @@
1
- import type { OpraOptionPlaneStop, WrunChartOptionsMarket, WrunChartOptionsMarketRef, WrunGateProvider, WrunGateReaderIntentSurface, WrunGateReaderIntentWarm, WrunGateReaderReadKind } from '../../../host-ports.types.js';
1
+ import type { OptionsGateProvider } from '../../../workers/constants/socket-slots.js';
2
+ import type { OpraOptionPlaneStop, WrunChartOptionsMarket, WrunChartOptionsMarketRef, WrunGateReaderIntentSurface, WrunOptionsGateProvider, WrunGateReaderIntentWarm, WrunGateReaderReadKind } from '../../../host-ports.types.js';
2
3
  /**
3
4
  * The exchange a gate plane's lane reads name, the one the transport routes them by: an OPRA lane asks by the plane's
4
5
  * own exchange whatever the chart's venue spelling (`wrunLaneOpraPlaneChain`, the stats lanes' `statsExchange`), a CME
5
6
  * chain lane by the chart's own CME exchange.
6
7
  */
7
- export declare function wrunGateReadExchangeOf(plane: 'cme' | 'opra', chartExchange: string): string;
8
+ export declare function wrunGateReadExchangeOf(plane: OptionsGateProvider, chartExchange: string): string;
8
9
  /** A chart market as a door names it: the market itself, or, from a door that holds the exchange alone, the exchange
9
10
  * (no market named: a stock twin is never seen there, its venue's own options are read). */
10
11
  export type WrunGateReaderChart = WrunChartOptionsMarketRef | string;
@@ -15,7 +16,7 @@ export interface WrunChartOptionsMarketDecision {
15
16
  /** The market whose options the chart reads: the chart's own, or a stock twin's US stock (`twinOf` names the chart). */
16
17
  market: WrunChartOptionsMarket;
17
18
  /** The gate plane those options ride (`governedOptionPlane` over `market`), null for none. */
18
- plane: WrunGateProvider | null;
19
+ plane: WrunOptionsGateProvider | null;
19
20
  /** Off every plane, the known reason options that list on OPRA ride none (`opraOptionPlaneStop` over `market`). */
20
21
  opraStop?: OpraOptionPlaneStop;
21
22
  }
@@ -11,8 +11,9 @@
11
11
  *
12
12
  * The rule (`serveWrunOwnCandles`), judged before the ask leaves:
13
13
  * - the ask: the candle lane (`ohlcv`), naming no other market (no payload extras but the chart's own exchange and
14
- * symbol), at the chart's interval (no interval option, or the chart's), never a replay run's (its window reaches
15
- * the replay's forward runway, past the rows the chart shows);
14
+ * symbol, and the `candleSource` the chart's rows came from when they came from another market: a US stock Trades
15
+ * chart's tape), at the chart's interval (no interval option, or the chart's), never a replay run's (its window
16
+ * reaches the replay's forward runway, past the rows the chart shows);
16
17
  * - the window `[fromTs, toTs]` (the end an inclusive bar, as the chart's fetch reads it) held whole by the chart's
17
18
  * bars (`held`: the chart's rows, copied, so the lane's buffer never shares the forming bar the live feed rewrites);
18
19
  * anything else is null and the wire answers the window whole, exactly as before: a window opening before the
@@ -28,7 +29,8 @@
28
29
  export interface WrunOwnCandlesAsk {
29
30
  /** The fetch type of the ask (`ohlcv` is the candle lane). */
30
31
  type: string;
31
- /** The payload extras of the ask beyond the current-market placeholders (a pinned market's exchange and symbol). */
32
+ /** The payload extras of the ask beyond the current-market placeholders (a pinned market's exchange and symbol, the
33
+ * `candleSource` its rows are read from). */
32
34
  payloadExtras?: Readonly<Record<string, unknown>>;
33
35
  /** The interval the ask rides (undefined: the chart's own). */
34
36
  interval?: string;
@@ -52,5 +54,24 @@ export type WrunOwnCandlesServe = {
52
54
  kind: 'held';
53
55
  rows: number[][];
54
56
  } | null;
57
+ /** A chart as the host's candle-source reader reads it: its metadata object, whose other fields the host may read. */
58
+ export type WrunMainCandleChart = {
59
+ exchange?: unknown;
60
+ symbol?: unknown;
61
+ };
62
+ /** The market a chart's main series is read from when it is not the chart's own (web: a US stock chart's tape). */
63
+ export type WrunMainCandleSourceReader = (chart: WrunMainCandleChart) => {
64
+ exchange: string;
65
+ symbol: string;
66
+ } | null;
67
+ /** The host's reader, one per realm (null removes it): without one every chart's rows are its own market's. */
68
+ export declare function registerWrunMainCandleSource(reader: WrunMainCandleSourceReader | null): void;
69
+ /** The market a chart's own rows came from when it is another than the chart's; undefined when the reader threw. */
70
+ export declare function wrunMainCandleSourceOf(chart: WrunMainCandleChart | null | undefined): {
71
+ exchange: string;
72
+ symbol: string;
73
+ } | null | undefined;
74
+ /** The venue a script wall judges for the chart's own candles: the market its rows came from, else its exchange. */
75
+ export declare function wrunChartCandleVenue(chart: WrunMainCandleChart | null | undefined): unknown;
55
76
  /** The chart's own candles for an ask of the chart's series at its interval (the module note), or null. */
56
77
  export declare function serveWrunOwnCandles(ask: WrunOwnCandlesAsk): WrunOwnCandlesServe;
@@ -11,8 +11,9 @@
11
11
  *
12
12
  * The rule (`serveWrunOwnCandles`), judged before the ask leaves:
13
13
  * - the ask: the candle lane (`ohlcv`), naming no other market (no payload extras but the chart's own exchange and
14
- * symbol), at the chart's interval (no interval option, or the chart's), never a replay run's (its window reaches
15
- * the replay's forward runway, past the rows the chart shows);
14
+ * symbol, and the `candleSource` the chart's rows came from when they came from another market: a US stock Trades
15
+ * chart's tape), at the chart's interval (no interval option, or the chart's), never a replay run's (its window
16
+ * reaches the replay's forward runway, past the rows the chart shows);
16
17
  * - the window `[fromTs, toTs]` (the end an inclusive bar, as the chart's fetch reads it) held whole by the chart's
17
18
  * bars (`held`: the chart's rows, copied, so the lane's buffer never shares the forming bar the live feed rewrites);
18
19
  * anything else is null and the wire answers the window whole, exactly as before: a window opening before the
@@ -25,21 +26,54 @@
25
26
  * lane of a run asks through). The call-site census (tests/utility/wrun/run-schedule/wrun-own-candles.census.spec.ts)
26
27
  * fails a new source fetch door in the package that this rule does not stand in front of.
27
28
  */
28
- /** Whether an ask names the chart's own market: no market extras, or exactly the chart's exchange and symbol. */
29
- function asksChartMarket(ask) {
30
- const extras = ask.payloadExtras;
31
- if (extras === undefined)
32
- return true;
33
- for (const [key, value] of Object.entries(extras)) {
29
+ let mainCandleSourceReader = null;
30
+ /** The host's reader, one per realm (null removes it): without one every chart's rows are its own market's. */
31
+ export function registerWrunMainCandleSource(reader) {
32
+ mainCandleSourceReader = reader;
33
+ }
34
+ /** The market a chart's own rows came from when it is another than the chart's; undefined when the reader threw. */
35
+ export function wrunMainCandleSourceOf(chart) {
36
+ if (mainCandleSourceReader === null || !chart)
37
+ return null;
38
+ try {
39
+ return mainCandleSourceReader(chart);
40
+ }
41
+ catch {
42
+ return undefined;
43
+ }
44
+ }
45
+ /** The venue a script wall judges for the chart's own candles: the market its rows came from, else its exchange. */
46
+ export function wrunChartCandleVenue(chart) {
47
+ return wrunMainCandleSourceOf(chart)?.exchange ?? chart?.exchange;
48
+ }
49
+ /** The candle source an ask's extras name (`candleSource`, the market its rows are read from), else null. */
50
+ function askedCandleSource(value) {
51
+ if (typeof value !== 'object' || value === null)
52
+ return null;
53
+ const { exchange, symbol } = value;
54
+ return typeof exchange === 'string' && typeof symbol === 'string' ? { exchange, symbol } : null;
55
+ }
56
+ /** Whether an ask names the chart's own series read where its rows came from (`rowsSource`, null: the chart's own). */
57
+ function asksRowsMarket(ask, rowsSource) {
58
+ let source = null;
59
+ for (const [key, value] of Object.entries(ask.payloadExtras ?? {})) {
34
60
  if (value === undefined)
35
61
  continue;
36
62
  if (key === 'exchange' && value === ask.chart.exchange)
37
63
  continue;
38
64
  if (key === 'symbol' && value === ask.chart.symbol)
39
65
  continue;
66
+ if (key === 'candleSource') {
67
+ source = askedCandleSource(value);
68
+ if (source !== null)
69
+ continue;
70
+ }
40
71
  return false;
41
72
  }
42
- return true;
73
+ // An ask naming no source wants the chart's own market's bars: tape rows are never served for it, nor the reverse.
74
+ return source === null
75
+ ? rowsSource === null
76
+ : rowsSource !== null && source.exchange === rowsSource.exchange && source.symbol === rowsSource.symbol;
43
77
  }
44
78
  /** The chart's own candles for an ask of the chart's series at its interval (the module note), or null. */
45
79
  export function serveWrunOwnCandles(ask) {
@@ -47,7 +81,9 @@ export function serveWrunOwnCandles(ask) {
47
81
  return null;
48
82
  if (ask.interval !== undefined && ask.interval !== ask.chart.interval)
49
83
  return null;
50
- if (!asksChartMarket(ask))
84
+ // A reader that threw reads unknown, so the wire answers; else the ask must name the market the rows came from.
85
+ const rowsSource = wrunMainCandleSourceOf(ask.chart);
86
+ if (rowsSource === undefined || !asksRowsMarket(ask, rowsSource))
51
87
  return null;
52
88
  const { rows, intervalMs } = ask.chart;
53
89
  if (rows.length === 0 || !(intervalMs > 0) || !(ask.toTs >= ask.fromTs))
@@ -548,6 +548,8 @@ const WRUN_CME_WALL_SEED = Object.freeze({ cls: 'cme-wall' });
548
548
  export function assertWrunLaneChainPlaneReadable(plane, exchange, run, ctx) {
549
549
  if (plane === 'opra')
550
550
  assertWrunOpraLaneReadable(run, ctx);
551
+ // OpenMarket's own packages only, whatever the `cme-user-scripts` gate says: the gate opens CME chart studies (the
552
+ // chart's own futures data), never CME options data (no implied expansion to CME options in this release).
551
553
  if (plane === 'cme' && run?.official !== true) {
552
554
  refuseWrunPollInput(ctx, `reads CME options data (${exchange}), which is open to OpenMarket's own Indicators only: a package you wrote ` +
553
555
  'or added from the community cannot read it yet', WRUN_CME_WALL_SEED);