@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
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import { Intervals } from '../../constants/interval.constants.js';
13
13
  import { wrunLaneServiceOnMarket } from '../chart/index-mode-admission.util.js';
14
+ import { isPredictionExchangeName } from '../chart/prediction-identity.util.js';
14
15
  import { wrunFollowsCoin } from './wrun-market-facts.util.js';
15
16
  import { WRUN_OPTION_SUMMARY_LANES } from './wrun-option-summary-lane.util.js';
16
17
  import { wrunRowLaneClasses, wrunRowLaneOfClass } from './sources/row-lane-registry.js';
@@ -29,8 +30,7 @@ export const CHART_MARKET_GATEWAY_TYPES = Object.freeze({
29
30
  oi: 'OPEN_INTEREST_AGG',
30
31
  volume_profile: 'VOLUME_PROFILE_AGG',
31
32
  trade_volume_by_size: 'TRADE_VOLUME_BY_SIZE_AGG',
32
- // The tape's live prints ride the raw TRADE channel (its history reads TRADE_LARGE, a copy of the
33
- // same prints): the markets that list raw trades.
33
+ // Listed by TRADE: the registrar lists no TRADE_LARGE twin, though the tape reads TRADE_LARGE rows.
34
34
  tape: 'TRADE',
35
35
  liquidations: 'LIQUIDATION_AGG',
36
36
  funding: 'FUNDING_RATE_AGG',
@@ -255,7 +255,8 @@ export function wrunInputRequirements(effectiveSheet) {
255
255
  // undemanded input nowhere, so it keeps `needed_by`).
256
256
  const neededBy = source?.needed_by?.size_unit;
257
257
  const keepsNeededBy = row.kind !== 'pinned' && (row.kind !== 'options' || row.sourceClass !== undefined);
258
- const shape = Array.isArray(neededBy) && keepsNeededBy ? { ...row, neededBy } : row;
258
+ const demanded = Array.isArray(neededBy) && keepsNeededBy ? { ...row, neededBy } : row;
259
+ const shape = source !== undefined && wrunFollowsCoin(source) ? { ...demanded, followsCoin: true } : demanded;
259
260
  const key = JSON.stringify(shape);
260
261
  // Whether the input is optional rides beside the shape, never in it: inputs that need the same
261
262
  // thing share one requirement whatever fills they declare.
@@ -277,6 +278,55 @@ export function wrunInputRequirements(effectiveSheet) {
277
278
  return [...byKey.values()];
278
279
  }
279
280
  // ---------------------------------------------------------------------------
281
+ // The prediction-market wall
282
+ // ---------------------------------------------------------------------------
283
+ /**
284
+ * Whether a requirement reads by the chart's coin: the options chain and every chain lane (`options`: the chain
285
+ * decision reads the coin's chain on a market that is no options venue), every provider lane (`provider`: its coin
286
+ * list, the Deribit coin set or the chart's coin itself) and every coin leg (`followsCoin`: the coin's market on
287
+ * another venue). Every other input reads the chart market's own series, a pinned market, a governed plane or
288
+ * nothing of the market.
289
+ */
290
+ export function wrunRequirementReadsChartCoin(req) {
291
+ return req.kind === 'options' || req.kind === 'provider' || req.followsCoin === true;
292
+ }
293
+ /**
294
+ * The prediction-market wall (Kyle 2026-10-29: options indicators on a Polymarket chart make no sense). A prediction
295
+ * market's price is the odds of an outcome, and the coin its chart carries is no asset that price follows: the symbol
296
+ * pipeline's coin match places no series key and answers BTC (symbol-resolve.util `getCoin`), and an event about a coin
297
+ * names that coin. An input read by the chart's coin (`wrunRequirementReadsChartCoin`) would draw another market's
298
+ * options, volatility or flows under the odds, so every prediction venue (`isPredictionExchangeName`: Polymarket,
299
+ * HIP4) refuses it whatever fill it declares: a wall like the CME and OPRA ones, since the fill would stand in for a
300
+ * series the market can never have. Whether the market reads the input at all (`needed_by`, a `when` setting) is the
301
+ * caller's to settle first. The picker's verdict and the works-on list (wrun-input-requirements.util) and the run's
302
+ * head (`wrunPredictionMarketWalledInput`) read this one rule.
303
+ */
304
+ export function wrunPredictionMarketWalls(req, exchange) {
305
+ return wrunRequirementReadsChartCoin(req) && isPredictionExchangeName(exchange);
306
+ }
307
+ /**
308
+ * The first input of a sheet the prediction-market wall refuses on `exchange` (`wrunPredictionMarketWalls`), with its
309
+ * source class, in input order. Undefined off a prediction venue, or when no input the market demands reads by the
310
+ * chart's coin: the sheet is the one the run reads there (its settings applied and its lane demand at the market's size
311
+ * unit, so a `when` setting that is off or a `needed_by` leaving the unit out marks the input `undemanded`).
312
+ */
313
+ export function wrunPredictionMarketWalledInput(sheet, exchange) {
314
+ if (!isPredictionExchangeName(exchange))
315
+ return undefined;
316
+ for (const req of wrunInputRequirements(sheet)) {
317
+ if (!wrunPredictionMarketWalls(req, exchange))
318
+ continue;
319
+ for (const name of req.inputs) {
320
+ const source = sheet.inputSources?.[name];
321
+ if (source?.undemanded === true)
322
+ continue;
323
+ const sourceClass = source?.source ?? sheet.inputs.find((input) => input.name === name)?.source;
324
+ return { name, sourceClass: typeof sourceClass === 'string' ? sourceClass : '' };
325
+ }
326
+ }
327
+ return undefined;
328
+ }
329
+ // ---------------------------------------------------------------------------
280
330
  // The run's admission (the capability rule, WRUN-REFUSALS U3a step 5)
281
331
  // ---------------------------------------------------------------------------
282
332
  /**
@@ -418,6 +468,10 @@ export function wrunUnservedLanes(sheet, market, opts = {}) {
418
468
  ...verdict,
419
469
  inputNames: readers.map((input) => input.name),
420
470
  ...(legMarket !== undefined ? { market: legMarket } : {}),
471
+ // The refusal's words name the market the lane was judged on, never the stored one it never read.
472
+ ...(legMarket === undefined && on.exchange !== market.exchange && on.exchange !== undefined
473
+ ? { judgedExchange: on.exchange }
474
+ : {}),
421
475
  ...(holding !== undefined ? { holding: { name: holding.name, celled: holding.cellType === 'array' } } : {}),
422
476
  });
423
477
  };
@@ -426,18 +480,20 @@ export function wrunUnservedLanes(sheet, market, opts = {}) {
426
480
  const source = sheet.inputSources[input.name];
427
481
  return source?.source === lane && source.undemanded !== true;
428
482
  });
483
+ // A class on the chart's own market is judged on the run market (a Trades chart's tape), never the stored one.
484
+ const own = wrunRunMarketOn(lane, market, opts.runMarket);
429
485
  if (lane !== 'trades' && !isWrunLaneStreamClass(lane)) {
430
- judge(lane, readers, market);
486
+ judge(lane, readers, own);
431
487
  continue;
432
488
  }
433
489
  // A pinned trades input (and a lane stream pinned to another market) is judged on its leg's market; an
434
490
  // unresolved coin leg or a half pin nowhere (the row builder refuses it by name).
435
- const own = [];
491
+ const ownReaders = [];
436
492
  const legs = new Map();
437
493
  for (const input of readers) {
438
494
  const { exchange, symbol, ...source } = sheet.inputSources[input.name];
439
495
  if (exchange === undefined && symbol === undefined && !wrunFollowsCoin(source))
440
- own.push(input);
496
+ ownReaders.push(input);
441
497
  else if (typeof exchange === 'string' && typeof symbol === 'string') {
442
498
  const key = `${exchange}|${symbol}`;
443
499
  const leg = legs.get(key) ?? { market: { exchange, symbol }, readers: [] };
@@ -445,9 +501,109 @@ export function wrunUnservedLanes(sheet, market, opts = {}) {
445
501
  legs.set(key, leg);
446
502
  }
447
503
  }
448
- judge(lane, own, market);
504
+ judge(lane, ownReaders, own);
449
505
  for (const leg of legs.values())
450
506
  judge(lane, leg.readers, { exchange: leg.market.exchange, coin: market.coin }, leg.market);
451
507
  }
452
508
  return unserved;
453
509
  }
510
+ /** Every lane class declares its read here: a class left out reads the stored market by accident (the guard spec). */
511
+ export const WRUN_RUN_MARKET_READS = Object.freeze({
512
+ // Built from the chart's trades, so asked where they print (the decider awaited once, before the capability rule).
513
+ trades: 'run-market',
514
+ volume_profile: 'run-market',
515
+ trade_volume_by_size: 'run-market',
516
+ tape: 'run-market',
517
+ volume_profile_candles: 'run-market',
518
+ // The chart's candles: the rows' own market in the series ref alone, synchronous, so the shape stays the chart's.
519
+ ohlcv: 'candle-source',
520
+ candles: 'candle-source',
521
+ intrabar: 'candle-source',
522
+ // The chart's own market, judged on the run market (no tape serves them, so a Trades chart drops them by its facts).
523
+ book: 'chart-market',
524
+ oi: 'chart-market',
525
+ oi_candles: 'chart-market',
526
+ liquidations: 'chart-market',
527
+ funding: 'chart-market',
528
+ long_short_ratio: 'chart-market',
529
+ // A pinned market, a provider or coin series, an options chain or the bar clock: no chart market to move.
530
+ odds: 'none',
531
+ time: 'none',
532
+ implied_volatility: 'none',
533
+ skew: 'none',
534
+ etf_flow: 'none',
535
+ options_chain: 'none',
536
+ bitfinex_funding: 'none',
537
+ economic: 'none',
538
+ etf_holdings: 'none',
539
+ etf_premium: 'none',
540
+ ethena_positions: 'none',
541
+ option_daily: 'none',
542
+ option_stats_10m: 'none',
543
+ options_flow: 'none',
544
+ options_oi: 'none',
545
+ options_volume: 'none',
546
+ series: 'none',
547
+ token_supply: 'none',
548
+ treasury_balance: 'none',
549
+ volatility_index: 'none',
550
+ option_contract_flow: 'none',
551
+ option_contract_state: 'none',
552
+ option_prints: 'none',
553
+ option_strike_flow: 'none',
554
+ option_strikes: 'none',
555
+ option_surface: 'none',
556
+ });
557
+ /** A lane class's read, undefined for a class the table does not name. */
558
+ export function wrunRunMarketReadOfClass(sourceClass) {
559
+ return typeof sourceClass === 'string' && Object.hasOwn(WRUN_RUN_MARKET_READS, sourceClass)
560
+ ? WRUN_RUN_MARKET_READS[sourceClass]
561
+ : undefined;
562
+ }
563
+ /** The chart fetch type a class asks its chart-market rows through, undefined when it asks none of its own. */
564
+ export function wrunRunMarketFetchTypeOf(sourceClass) {
565
+ if (isWrunLegStreamClass(sourceClass))
566
+ return WRUN_LEG_STREAM_CLASSES[sourceClass].fetchType;
567
+ if (sourceClass === 'ohlcv' || sourceClass === 'intrabar')
568
+ return 'ohlcv';
569
+ return WRUN_ADMISSION_LANES.get(sourceClass);
570
+ }
571
+ /** The read of each fetch type, built once from the class table (the guard spec holds its classes to one read). */
572
+ const WRUN_RUN_MARKET_READ_BY_FETCH_TYPE = new Map(Object.entries(WRUN_RUN_MARKET_READS).flatMap(([sourceClass, read]) => {
573
+ const fetchType = wrunRunMarketFetchTypeOf(sourceClass);
574
+ return fetchType === undefined ? [] : [[fetchType, read]];
575
+ }));
576
+ /** How an ask of a fetch type reads the run market (`fetchLane` decides by its type); an unlisted type stays put. */
577
+ export function wrunRunMarketReadOfFetchType(type) {
578
+ return WRUN_RUN_MARKET_READ_BY_FETCH_TYPE.get(type) ?? 'chart-market';
579
+ }
580
+ /** The market a class reading the chart's own market is judged on: the run market, which then names its facts. */
581
+ export function wrunRunMarketOn(sourceClass, market, runMarket) {
582
+ const read = WRUN_RUN_MARKET_READS[sourceClass];
583
+ return runMarket && (read === 'run-market' || read === 'chart-market')
584
+ ? { exchange: runMarket.exchange, coin: market.coin }
585
+ : market;
586
+ }
587
+ /** Whether a sheet reads the run market: a demanded input of a run-market class on the chart's own market. */
588
+ export function wrunSheetReadsRunMarket(sheet) {
589
+ return sheet.inputs.some((input) => {
590
+ const source = sheet.inputSources[input.name];
591
+ if (source === undefined || source.undemanded === true)
592
+ return false;
593
+ if (wrunRunMarketReadOfClass(source.source) !== 'run-market')
594
+ return false;
595
+ return source.exchange === undefined && source.symbol === undefined && !wrunFollowsCoin(source);
596
+ });
597
+ }
598
+ /** Whether a source reads the run market: a run-market type on the chart's own market (history pin and live map). */
599
+ export function wrunSourceReadsRunMarket(type, payload, chart) {
600
+ if (wrunRunMarketReadOfFetchType(type.toLowerCase()) !== 'run-market')
601
+ return false;
602
+ // The engine's current-market placeholders name the chart's own market.
603
+ const exchange = payload.exchange === 'currentExchange' || payload.exchange === undefined ? chart?.exchange : payload.exchange;
604
+ const symbol = payload.symbol === 'currentSymbol' ? chart?.symbol : payload.symbol;
605
+ return (typeof exchange === 'string' &&
606
+ exchange === chart?.exchange &&
607
+ typeof symbol === 'string' &&
608
+ symbol === chart?.symbol);
609
+ }
@@ -11,47 +11,83 @@ export interface WrunLegCloseLeg {
11
11
  legMs: number;
12
12
  market?: {
13
13
  exchange?: string;
14
+ symbol?: string;
14
15
  } | undefined;
15
16
  }
17
+ /** The chart a row or a session read takes: its symbol and its raw `sessionType` (the chart metadata's, never the
18
+ * stated `wrunChartSessionType`: an unset session is the full session on a future). */
19
+ export interface WrunChartRthSession {
20
+ symbol?: unknown;
21
+ sessionType?: unknown;
22
+ }
16
23
  /** The session the chart fetches a US listing's candles on, as the shared host's session calendar
17
24
  * reads it: 'extended' only while the chart runs its extended session (`isEquityExtendedSession`,
18
25
  * the fetch's own decider), else 'regular', an unset session included (the browser never leaves it
19
26
  * unstated; the package reads an unstated session as open plus the span). */
20
27
  export declare function wrunChartSessionType(sessionType: unknown): 'regular' | 'extended';
21
- /** The chart's session as the row builder reads it (`WrunChartSourceRows.session`): the chart's
22
- * exchange and the session word of its `sessionType`. */
23
- export declare function wrunChartSession(exchange: string | undefined, sessionType: unknown): WrunChartSession;
28
+ /** The chart a session read takes beside its persisted `sessionType`: its symbol and its interval (the chart's
29
+ * interval label or milliseconds), with which the session the chart rides is read (`wrunChartSession`). */
30
+ export interface WrunSessionChart {
31
+ symbol?: unknown;
32
+ interval?: unknown;
33
+ }
34
+ /** The chart's session as the row builder reads it (`WrunChartSourceRows.session`): the chart's exchange, its
35
+ * symbol (`chart`, when the caller has it) and the session the chart rides. On a market with an RTH window (a
36
+ * future, found by the symbol) that is the effective word at the chart's interval (`effectiveChartSessionType`):
37
+ * 'regular' only while the chart rides RTH there, an unset word the full session, so the shared host's session
38
+ * calendar reads RTH rows and RTH legs only on a chart that rides RTH. Such a chart still fetches a pinned US
39
+ * listing on its persisted word (`kOhlcvSessionPayloadFields` reads it for a Polygon source: unset or 'regular'
40
+ * is the listing's regular hours), so where the two words differ the session carries that one too
41
+ * (`listingSessionType`, `wrunChartSessionType`). Every other market, and a call without a symbol, keeps
42
+ * `wrunChartSessionType`: on a stock the word is the extended-hours flag. */
43
+ export declare function wrunChartSession(exchange: string | undefined, sessionType: unknown, chart?: WrunSessionChart): WrunChartSession;
24
44
  /** Whether the gateway builds this leg's bars on the CME session lattice. */
25
45
  export declare function wrunLegRidesCmeSession(leg: WrunLegCloseLeg, chartExchange: string | undefined): boolean;
46
+ /** Whether a leg's bars ride the chart's RTH grid (the module doc), read on the session the chart rides at
47
+ * `chartInterval` (the chart's interval label or milliseconds; absent, the leg's own interval stands for it): its
48
+ * pinned-close timer reads the RTH bars, never the lattice's or the plain grid's. */
49
+ export declare function wrunLegRidesRth(leg: WrunLegCloseLeg, chartExchange: string | undefined, sessionType?: unknown, chartSymbol?: unknown, chartInterval?: unknown): boolean;
26
50
  /** How long after a close the leg's venue holds the whole candle (the module doc): a US listing's
27
51
  * `WRUN_US_EQUITIES_CLOSE_SETTLE_MS` where its candles close with the session, 0 for every other
28
52
  * leg (its live feed seals a candle at its close). */
29
53
  export declare function wrunLegCloseSettleMs(leg: WrunLegCloseLeg, chartExchange: string | undefined, sessionType?: unknown): number;
30
- /** The leg's candle closes for the leg core (`closeMs`): the CME session lattice's, else a US
31
- * listing's session closes on a regular-session chart (the chart's `sessionType`); undefined where
32
- * they are open plus the span. */
33
- export declare function wrunLegCandleClose(leg: WrunLegCloseLeg, chartExchange: string | undefined, sessionType?: unknown): WrunLegCandleClose | undefined;
54
+ /** The leg's candle closes for the leg core (`closeMs`): on a leg riding the chart's RTH grid (`chart`, its symbol
55
+ * and interval: the session the chart rides, `wrunChartSession`, the module doc) a candle stamped at an RTH bar's
56
+ * open closes at that bar's end, the session's stub at the session close (a 4h candle opening 17:30Z closes 20:15Z,
57
+ * an hourly one opening 19:30Z at 20:15Z); every other stamp, and every other leg, the CME session lattice's,
58
+ * else a US listing's session closes on a regular-session chart (the chart's `sessionType`); undefined where they
59
+ * are open plus the span. */
60
+ export declare function wrunLegCandleClose(leg: WrunLegCloseLeg, chartExchange: string | undefined, sessionType?: unknown, chart?: WrunSessionChart): WrunLegCandleClose | undefined;
34
61
  /** The leg's candle opens for the leg core (`candleOpenMs`), undefined where a candle trades from
35
62
  * its stamp: a CME daily, 3d or weekly candle stamped at its trade date trades from the session
36
- * open before it. */
63
+ * open before it. Every intraday candle, an RTH leg's among them, trades from its stamp. */
37
64
  export declare function wrunLegCandleOpen(leg: WrunLegCloseLeg, chartExchange: string | undefined): WrunLegCandleOpen | undefined;
38
65
  /** The chart's primary row bounds for the leg core (`rowBounds`), undefined where a row spans
39
66
  * [label, label + P): a calendar row (1M 3M 6M 1Y, any market) runs from its label to its calendar
40
- * end (`wrunCalendarRowBounds`); a row of a market the gateway builds on the CME session lattice,
41
- * at a lattice interval, runs from its session open to its bar end (a daily row labelled Sep 30
42
- * runs from Sep 29 22:00Z to Sep 30 22:00Z under daylight time; the Tuesday after Labor Day from
43
- * the Sunday open). A label the lattice does not book keeps [label, label + P). The row builder
44
- * reads the same answer through `wrunSessionClock`. */
45
- export declare function wrunPrimaryRowBounds(chartExchange: string | undefined, intervalMs: number): WrunLegRowBounds | undefined;
67
+ * end (`wrunCalendarRowBounds`); a row of a chart riding RTH (`chart`: its symbol and raw session)
68
+ * runs from its RTH bar's open to that bar's end, the session's stub to the session close (a 6h row
69
+ * opening 19:30Z ends 20:15Z, not 01:30Z; a 15m row opening 13:30Z ends 13:45Z); a row of a market
70
+ * the gateway builds on the CME session lattice, at a lattice interval, runs from its session open
71
+ * to its bar end (a daily row labelled Sep 30 runs from Sep 29 22:00Z to Sep 30 22:00Z under
72
+ * daylight time; the Tuesday after Labor Day from the Sunday open). A label neither grid books keeps
73
+ * [label, label + P). The row builder reads the same answer through `wrunSessionClock`. */
74
+ export declare function wrunPrimaryRowBounds(chartExchange: string | undefined, intervalMs: number, chart?: WrunChartRthSession): WrunLegRowBounds | undefined;
46
75
  /** The label of the primary row holding `instantMs` where a calendar labels the rows: its calendar
47
- * bar on a calendar chart (March 10 is the March 1 row), the row whose session holds it on the CME
48
- * session lattice; undefined elsewhere, where the caller keeps its own grid. */
49
- export declare function wrunPrimaryRowHoldingMs(chartExchange: string | undefined, intervalMs: number, instantMs: number): number | undefined;
76
+ * bar on a calendar chart (March 10 is the March 1 row), the RTH bar holding it on a chart riding
77
+ * RTH (`chart`; 14:10Z is the 13:30Z hourly row, never the 14:00Z UTC hour), the row whose session
78
+ * holds it on the CME session lattice; undefined elsewhere and off an RTH session, where the caller
79
+ * keeps its own grid. */
80
+ export declare function wrunPrimaryRowHoldingMs(chartExchange: string | undefined, intervalMs: number, instantMs: number, chart?: WrunChartRthSession): number | undefined;
50
81
  /** The close of the leg's bar holding `nowMs` where its venue closes bars off the plain grid,
51
82
  * undefined elsewhere or once that bar has closed (the caller keeps its own grid, a wake no later
52
- * than the next close): on the CME session lattice the lattice bar's end; on a US listing on a
53
- * regular-session chart (the chart's `sessionType`) the stock's close (`wrunLegCandleClose`) of
54
- * the candle the chart's live boundary rule keys now to (`liveBucketStartMs`: the trade date for a
55
- * day, the Monday for a week, the 09:30 New York lattice from 45m to 12h), and off the session on
56
- * that lattice the first candle of the next session. */
57
- export declare function wrunLegBarCloseAt(leg: WrunLegCloseLeg, chartExchange: string | undefined, nowMs: number, sessionType?: unknown): number | undefined;
83
+ * than the next close): on a leg riding the chart's RTH grid (the session the chart rides, read on
84
+ * its `sessionType`, `chartSymbol` and `chartInterval` as `wrunLegRidesRth` reads them: a daily
85
+ * chart that keeps 'regular' rides the full session, so its intraday legs keep their own closes;
86
+ * the module doc) the RTH bar's end (a 4h leg at 15:00Z closes 17:30Z, at 18:00Z
87
+ * the stub's 20:15Z; an hourly leg at 14:10Z closes 14:30Z), and off the session the end of the
88
+ * next session's first bar; on the CME session lattice the lattice bar's end; on a US listing on a
89
+ * regular-session chart the stock's close (`wrunLegCandleClose`) of the candle the chart's live
90
+ * boundary rule keys now to (`liveBucketStartMs`: the trade date for a day, the Monday for a week,
91
+ * the 09:30 New York lattice from 45m to 12h), and off the session on that lattice the first candle
92
+ * of the next session. */
93
+ export declare function wrunLegBarCloseAt(leg: WrunLegCloseLeg, chartExchange: string | undefined, nowMs: number, sessionType?: unknown, chartSymbol?: unknown, chartInterval?: unknown): number | undefined;