@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
@@ -18,6 +18,7 @@ import { Intervals } from '../../constants/interval.constants.js';
18
18
  import { barEndMs, barStartMs } from '../chart/calendar-interval.util.js';
19
19
  import { intervalLabelForMs } from '../chart/interval-ladder.util.js';
20
20
  import { profileRowMultiplier } from '../chart/profile-row-height.util.js';
21
+ import { marketSessionAtOrBefore, marketSessionNamed, profileRegionSessionKeys, } from '../chart/market-sessions.util.js';
21
22
  import { getSessionInterval } from '../chart/session-interval.util.js';
22
23
  import { parseWrunThemeToken, wrunFontFamilyCss, wrunThemeTokenScaleAlpha } from './wrun-style-words.util.js';
23
24
  /** The sheet's mode words to the engine's display modes; "delta" is the
@@ -85,24 +86,27 @@ function intervalLabelOf(intervalMs) {
85
86
  }
86
87
  return best ?? '1d';
87
88
  }
88
- /** The engine's `session` setting for a session word: "auto" is the native
89
- * Targeted mapping for the chart interval, a length word its milliseconds,
90
- * a region word the engine's region name. */
91
- function sessionSettingOf(word, intervalLabel) {
92
- switch (word ?? 'auto') {
93
- case 'auto':
94
- return getSessionInterval('Targeted', intervalLabel);
95
- case 'us':
96
- return 'US';
97
- case 'eu':
98
- return 'EU';
99
- case 'asia':
100
- return 'Asia';
101
- default: {
102
- const length = Intervals.map_unit[word];
103
- return typeof length === 'number' ? length : getSessionInterval('Targeted', intervalLabel);
104
- }
89
+ /** The sheet's region words, to the region names the native session profiles store. */
90
+ const WRUN_REGION_SESSION_TYPES = {
91
+ us: 'US',
92
+ eu: 'EU',
93
+ asia: 'Asia',
94
+ };
95
+ /** The engine's session keys: "auto" the native Targeted mapping, a length word its ms, a region word its own day. */
96
+ function sessionKeysOf(word, intervalLabel, intervalMs) {
97
+ const value = word ?? 'auto';
98
+ const region = Object.prototype.hasOwnProperty.call(WRUN_REGION_SESSION_TYPES, value)
99
+ ? WRUN_REGION_SESSION_TYPES[value]
100
+ : undefined;
101
+ if (region !== undefined) {
102
+ // Never the region's name: titan reads a name off its fixed-UTC table, an hour off every winter.
103
+ const keys = profileRegionSessionKeys(region, intervalMs);
104
+ return keys ? { ...keys, region } : { session: getSessionInterval(region, intervalLabel) };
105
105
  }
106
+ if (value === 'auto')
107
+ return { session: getSessionInterval('Targeted', intervalLabel) };
108
+ const length = Intervals.map_unit[value];
109
+ return { session: typeof length === 'number' ? length : getSessionInterval('Targeted', intervalLabel) };
106
110
  }
107
111
  /** A colour word at a fraction of its own alpha: a token keeps its word
108
112
  * (`theme.text/14`), a hex colour becomes `rgba(r, g, b, a)`; any other
@@ -148,13 +152,13 @@ function newestCloseMs(ctx, rows) {
148
152
  return newest === undefined ? undefined : barEndMs(newest, ctx.intervalMs);
149
153
  }
150
154
  /** The rows of the session holding the newest bar (span "developing"): the
151
- * window of the session length (a region session reads as a day) that
152
- * contains the newest row's timestamp. A month, quarter, half-year or year
153
- * session is its calendar bar (`barStartMs` to `barEndMs`): the epoch floor
154
- * of the average length opened the March 2026 session on January 31 10:30
155
- * and handed it February's row too. */
156
- function developingRows(rows, session) {
157
- const sessionMs = typeof session === 'number' && session > 0 ? session : Intervals.DAY;
155
+ * window of the session length that contains the newest row's timestamp, or
156
+ * for a region its own session (the latest one opened by the newest row). A
157
+ * month, quarter, half-year or year session is its calendar bar (`barStartMs`
158
+ * to `barEndMs`): the epoch floor of the average length opened the March 2026
159
+ * session on January 31 10:30 and handed it February's row too. */
160
+ function developingRows(rows, keys) {
161
+ const sessionMs = keys.session > 0 ? keys.session : Intervals.DAY;
158
162
  let newest;
159
163
  for (const row of rows) {
160
164
  const ts = rowTs(row);
@@ -163,8 +167,10 @@ function developingRows(rows, session) {
163
167
  }
164
168
  if (newest === undefined)
165
169
  return [];
166
- const start = barStartMs(newest, sessionMs);
167
- const end = barEndMs(start, sessionMs);
170
+ const regionWindow = keys.region !== undefined ? marketSessionNamed(keys.region) : null;
171
+ const regionSession = regionWindow ? marketSessionAtOrBefore(regionWindow, newest) : null;
172
+ const start = regionSession ? regionSession[0] : barStartMs(newest, sessionMs);
173
+ const end = regionSession ? regionSession[1] : barEndMs(start, sessionMs);
168
174
  return rows.filter((row) => {
169
175
  const ts = rowTs(row);
170
176
  return ts !== undefined && ts >= start && ts < end;
@@ -185,7 +191,7 @@ export function wrunVolumeProfileChild(profile, cellRows, ctx) {
185
191
  return null;
186
192
  const span = profile.span ?? 'session';
187
193
  const intervalLabel = intervalLabelOf(ctx.intervalMs);
188
- const session = sessionSettingOf(profile.session, intervalLabel);
194
+ const sessionKeys = sessionKeysOf(profile.session, intervalLabel, ctx.intervalMs);
189
195
  let data;
190
196
  const anchor = {};
191
197
  switch (span) {
@@ -208,7 +214,7 @@ export function wrunVolumeProfileChild(profile, cellRows, ctx) {
208
214
  break;
209
215
  }
210
216
  case 'developing':
211
- data = developingRows(rows, session);
217
+ data = developingRows(rows, sessionKeys);
212
218
  anchor.profileWindow = 'data';
213
219
  anchor.lineBounds = 'profile';
214
220
  break;
@@ -218,7 +224,9 @@ export function wrunVolumeProfileChild(profile, cellRows, ctx) {
218
224
  default:
219
225
  data = [...rows];
220
226
  anchor.variant = 'session';
221
- anchor.session = session;
227
+ anchor.session = sessionKeys.session;
228
+ if (sessionKeys.customSessionWindow)
229
+ anchor.customSessionWindow = sessionKeys.customSessionWindow;
222
230
  }
223
231
  const bucketWidth = bucketWidthOf(rows);
224
232
  const rowHeight = profile.row_height ?? 'auto';
@@ -16,7 +16,7 @@
16
16
  */
17
17
  export type SlotFamily = 'reader' | 'livefeed' | 'alert' | 'parking';
18
18
  /** `v3`: the /v3 gateway, kept apart so the core v2 pair's ping, probe and reconnect paths never see it. */
19
- export type SlotProvider = 'core' | 'cme' | 'opra' | 'v3' | 'blk';
19
+ export type SlotProvider = 'core' | 'cme' | 'opra' | 'stocks' | 'v3' | 'blk';
20
20
  /** Timing tier for governed slots; null = untiered (core sockets / legacy `?tier=`). */
21
21
  type SlotTier = 'realtime' | 'delayed' | null;
22
22
  /** Connect-time auth style: an on-open `public/authenticate` frame, or none (reader RPC-level). */
@@ -39,8 +39,8 @@ export type SlotWorkerKeepalive = 'alertPing' | 'gatePing' | 'readerIdlePing' |
39
39
  * an owner instead.
40
40
  */
41
41
  type SlotMainThreadKeepalive = 'v2PingPong' | 'liveFeedService' | 'alertService' | null;
42
- /** The two CME gate base URLs (contract C1: tier is a path over these, not a new env var). */
43
- type SlotUrlKey = 'CME_V2_WEB_SOCKET' | 'CME_LIVE_FEED_URL' | 'OPRA_V2_WEB_SOCKET' | 'OPRA_LIVE_FEED_URL' | 'BLK_V2_WEB_SOCKET' | 'BLK_LIVE_FEED_URL' | null;
42
+ /** The gate base URLs, two per plane (contract C1: tier is a path over these, not a new env var). */
43
+ type SlotUrlKey = 'CME_V2_WEB_SOCKET' | 'CME_LIVE_FEED_URL' | 'OPRA_V2_WEB_SOCKET' | 'OPRA_LIVE_FEED_URL' | 'STOCKS_V2_WEB_SOCKET' | 'STOCKS_LIVE_FEED_URL' | 'BLK_V2_WEB_SOCKET' | 'BLK_LIVE_FEED_URL' | null;
44
44
  type SlotPathPrefix = '/live/' | '/delayed/' | '';
45
45
  export interface SlotSpec {
46
46
  /** Inbound handler + registry family. `parking` = a GOING_AWAY handover target, never opened directly. */
@@ -386,6 +386,66 @@ export declare const SOCKET_SLOTS: {
386
386
  readonly connectable: true;
387
387
  readonly wire: "v2";
388
388
  };
389
+ readonly stocksV2Realtime: {
390
+ readonly family: "reader";
391
+ readonly provider: "stocks";
392
+ readonly tier: "realtime";
393
+ readonly auth: "frame";
394
+ readonly sendsTierFrame: true;
395
+ readonly subscribeParams: null;
396
+ readonly workerKeepalive: "gatePing";
397
+ readonly mainThreadKeepalive: null;
398
+ readonly parkingSlot: null;
399
+ readonly urlKey: "STOCKS_V2_WEB_SOCKET";
400
+ readonly pathPrefix: "/live/";
401
+ readonly connectable: true;
402
+ readonly wire: "v2";
403
+ };
404
+ readonly stocksV2Delayed: {
405
+ readonly family: "reader";
406
+ readonly provider: "stocks";
407
+ readonly tier: "delayed";
408
+ readonly auth: "frame";
409
+ readonly sendsTierFrame: true;
410
+ readonly subscribeParams: null;
411
+ readonly workerKeepalive: "gatePing";
412
+ readonly mainThreadKeepalive: null;
413
+ readonly parkingSlot: null;
414
+ readonly urlKey: "STOCKS_V2_WEB_SOCKET";
415
+ readonly pathPrefix: "/delayed/";
416
+ readonly connectable: true;
417
+ readonly wire: "v2";
418
+ };
419
+ readonly stocksLiveFeedRealtime: {
420
+ readonly family: "livefeed";
421
+ readonly provider: "stocks";
422
+ readonly tier: "realtime";
423
+ readonly auth: "frame";
424
+ readonly sendsTierFrame: true;
425
+ readonly subscribeParams: "brotliV2";
426
+ readonly workerKeepalive: "gatePing";
427
+ readonly mainThreadKeepalive: null;
428
+ readonly parkingSlot: null;
429
+ readonly urlKey: "STOCKS_LIVE_FEED_URL";
430
+ readonly pathPrefix: "/live/";
431
+ readonly connectable: true;
432
+ readonly wire: "v2";
433
+ };
434
+ readonly stocksLiveFeedDelayed: {
435
+ readonly family: "livefeed";
436
+ readonly provider: "stocks";
437
+ readonly tier: "delayed";
438
+ readonly auth: "frame";
439
+ readonly sendsTierFrame: true;
440
+ readonly subscribeParams: "brotliV2";
441
+ readonly workerKeepalive: "gatePing";
442
+ readonly mainThreadKeepalive: null;
443
+ readonly parkingSlot: null;
444
+ readonly urlKey: "STOCKS_LIVE_FEED_URL";
445
+ readonly pathPrefix: "/delayed/";
446
+ readonly connectable: true;
447
+ readonly wire: "v2";
448
+ };
389
449
  readonly kscriptAlert: {
390
450
  readonly family: "alert";
391
451
  readonly provider: "core";
@@ -507,13 +567,28 @@ export declare function isPlainReaderSlot(wsType: string): wsType is 'v2';
507
567
  export declare function isBlkReaderSlot(wsType: string): wsType is 'blkV2';
508
568
  export declare function isCmeReaderSlot(wsType: string): wsType is CmeReaderSlotId;
509
569
  export declare function isCmeLivefeedSlot(wsType: string): wsType is CmeLivefeedSlotId;
510
- export type GateProvider = 'cme' | 'opra';
570
+ export type GateProvider = 'cme' | 'opra' | 'stocks';
571
+ /** Every gate plane, in the order the planes shipped: the one list a per-plane loop or table reads. */
572
+ export declare const GATE_PROVIDERS: readonly GateProvider[];
573
+ /** Whether a provider id names a gate plane (`GateProvider`), as a type guard over any string. */
574
+ export declare function isGateProvider(provider: unknown): provider is GateProvider;
575
+ /**
576
+ * The gate planes that list option chains (CME Group options on the CME gate, US listed options on the OPRA gate).
577
+ * The stocks tape carries trades alone: an options identity, fold class or chain directory never names it, so the
578
+ * options code keys on this narrower union and a `GateProvider` reaches it through `isOptionsGateProvider`.
579
+ */
580
+ export type OptionsGateProvider = Extract<GateProvider, 'cme' | 'opra'>;
581
+ export declare function isOptionsGateProvider(provider: unknown): provider is OptionsGateProvider;
511
582
  export type OpraReaderSlotId = SlotIdOfFamilyAndProvider<'reader', 'opra'>;
512
583
  export type OpraLivefeedSlotId = SlotIdOfFamilyAndProvider<'livefeed', 'opra'>;
513
- export type GateReaderSlotId = CmeReaderSlotId | OpraReaderSlotId;
514
- export type GateLivefeedSlotId = CmeLivefeedSlotId | OpraLivefeedSlotId;
584
+ export type StocksReaderSlotId = SlotIdOfFamilyAndProvider<'reader', 'stocks'>;
585
+ export type StocksLivefeedSlotId = SlotIdOfFamilyAndProvider<'livefeed', 'stocks'>;
586
+ export type GateReaderSlotId = CmeReaderSlotId | OpraReaderSlotId | StocksReaderSlotId;
587
+ export type GateLivefeedSlotId = CmeLivefeedSlotId | OpraLivefeedSlotId | StocksLivefeedSlotId;
515
588
  export declare const OPRA_READER_SLOT_IDS: readonly SlotIdOfFamilyAndProvider<"reader", "opra">[];
516
589
  export declare const OPRA_LIVEFEED_SLOT_IDS: readonly SlotIdOfFamilyAndProvider<"livefeed", "opra">[];
590
+ export declare const STOCKS_READER_SLOT_IDS: readonly SlotIdOfFamilyAndProvider<"reader", "stocks">[];
591
+ export declare const STOCKS_LIVEFEED_SLOT_IDS: readonly SlotIdOfFamilyAndProvider<"livefeed", "stocks">[];
517
592
  export declare const GATE_READER_SLOT_IDS_BY_PROVIDER: Record<GateProvider, readonly GateReaderSlotId[]>;
518
593
  export declare const GATE_LIVEFEED_SLOT_IDS_BY_PROVIDER: Record<GateProvider, readonly GateLivefeedSlotId[]>;
519
594
  /** Every gate plane's reader tiers, for the plane-neutral sweeps (sleep heal, idle release). */
@@ -546,6 +621,16 @@ declare const GATE_SLOT_BY_PROVIDER_FAMILY_TIER: {
546
621
  readonly delayed: "opraLiveFeedDelayed";
547
622
  };
548
623
  };
624
+ readonly stocks: {
625
+ readonly reader: {
626
+ readonly realtime: "stocksV2Realtime";
627
+ readonly delayed: "stocksV2Delayed";
628
+ };
629
+ readonly livefeed: {
630
+ readonly realtime: "stocksLiveFeedRealtime";
631
+ readonly delayed: "stocksLiveFeedDelayed";
632
+ };
633
+ };
549
634
  };
550
635
  export declare function gateSlotForTier<P extends GateProvider, F extends 'reader' | 'livefeed', T extends CmeTier>(provider: P, family: F, tier: T): (typeof GATE_SLOT_BY_PROVIDER_FAMILY_TIER)[P][F][T];
551
636
  /** The gate plane a slot belongs to, or null for the core, v3 and blk slots. */
@@ -350,6 +350,70 @@ export const SOCKET_SLOTS = {
350
350
  connectable: true,
351
351
  wire: 'v2',
352
352
  },
353
+ // The US stocks entitlement gate (the consolidated tape: NYSE, NYSE_ARCA and NASDAQ, the three SIP tapes on the
354
+ // cme cluster): the same path-based tiers, tier frame, device-scoped auth and kick model as the CME and OPRA gates,
355
+ // on its own base URLs and kick channel. No /v3 twins (the stocks gate mounts none) and no book types (the tape
356
+ // carries trades only). A logged-out visitor dials its delayed tiers with the guest token (GATE_PLANES.stocks).
357
+ stocksV2Realtime: {
358
+ family: 'reader',
359
+ provider: 'stocks',
360
+ tier: 'realtime',
361
+ auth: 'frame',
362
+ sendsTierFrame: true,
363
+ subscribeParams: null,
364
+ workerKeepalive: 'gatePing',
365
+ mainThreadKeepalive: null,
366
+ parkingSlot: null,
367
+ urlKey: 'STOCKS_V2_WEB_SOCKET',
368
+ pathPrefix: '/live/',
369
+ connectable: true,
370
+ wire: 'v2',
371
+ },
372
+ stocksV2Delayed: {
373
+ family: 'reader',
374
+ provider: 'stocks',
375
+ tier: 'delayed',
376
+ auth: 'frame',
377
+ sendsTierFrame: true,
378
+ subscribeParams: null,
379
+ workerKeepalive: 'gatePing',
380
+ mainThreadKeepalive: null,
381
+ parkingSlot: null,
382
+ urlKey: 'STOCKS_V2_WEB_SOCKET',
383
+ pathPrefix: '/delayed/',
384
+ connectable: true,
385
+ wire: 'v2',
386
+ },
387
+ stocksLiveFeedRealtime: {
388
+ family: 'livefeed',
389
+ provider: 'stocks',
390
+ tier: 'realtime',
391
+ auth: 'frame',
392
+ sendsTierFrame: true,
393
+ subscribeParams: 'brotliV2',
394
+ workerKeepalive: 'gatePing',
395
+ mainThreadKeepalive: null,
396
+ parkingSlot: null,
397
+ urlKey: 'STOCKS_LIVE_FEED_URL',
398
+ pathPrefix: '/live/',
399
+ connectable: true,
400
+ wire: 'v2',
401
+ },
402
+ stocksLiveFeedDelayed: {
403
+ family: 'livefeed',
404
+ provider: 'stocks',
405
+ tier: 'delayed',
406
+ auth: 'frame',
407
+ sendsTierFrame: true,
408
+ subscribeParams: 'brotliV2',
409
+ workerKeepalive: 'gatePing',
410
+ mainThreadKeepalive: null,
411
+ parkingSlot: null,
412
+ urlKey: 'STOCKS_LIVE_FEED_URL',
413
+ pathPrefix: '/delayed/',
414
+ connectable: true,
415
+ wire: 'v2',
416
+ },
353
417
  kscriptAlert: {
354
418
  family: 'alert',
355
419
  provider: 'core',
@@ -460,23 +524,34 @@ export function isCmeReaderSlot(wsType) {
460
524
  export function isCmeLivefeedSlot(wsType) {
461
525
  return CME_LIVEFEED_SLOT_SET.has(wsType);
462
526
  }
527
+ /** Every gate plane, in the order the planes shipped: the one list a per-plane loop or table reads. */
528
+ export const GATE_PROVIDERS = ['cme', 'opra', 'stocks'];
529
+ const GATE_PROVIDER_SET = new Set(GATE_PROVIDERS);
530
+ /** Whether a provider id names a gate plane (`GateProvider`), as a type guard over any string. */
531
+ export function isGateProvider(provider) {
532
+ return typeof provider === 'string' && GATE_PROVIDER_SET.has(provider);
533
+ }
534
+ export function isOptionsGateProvider(provider) {
535
+ return provider === 'cme' || provider === 'opra';
536
+ }
463
537
  export const OPRA_READER_SLOT_IDS = slotIdsOfFamilyAndProvider('reader', 'opra');
464
538
  export const OPRA_LIVEFEED_SLOT_IDS = slotIdsOfFamilyAndProvider('livefeed', 'opra');
539
+ export const STOCKS_READER_SLOT_IDS = slotIdsOfFamilyAndProvider('reader', 'stocks');
540
+ export const STOCKS_LIVEFEED_SLOT_IDS = slotIdsOfFamilyAndProvider('livefeed', 'stocks');
465
541
  export const GATE_READER_SLOT_IDS_BY_PROVIDER = {
466
542
  cme: CME_READER_SLOT_IDS,
467
543
  opra: OPRA_READER_SLOT_IDS,
544
+ stocks: STOCKS_READER_SLOT_IDS,
468
545
  };
469
546
  export const GATE_LIVEFEED_SLOT_IDS_BY_PROVIDER = {
470
547
  cme: CME_LIVEFEED_SLOT_IDS,
471
548
  opra: OPRA_LIVEFEED_SLOT_IDS,
549
+ stocks: STOCKS_LIVEFEED_SLOT_IDS,
472
550
  };
473
551
  /** Every gate plane's reader tiers, for the plane-neutral sweeps (sleep heal, idle release). */
474
- export const GATE_READER_SLOT_IDS = [...CME_READER_SLOT_IDS, ...OPRA_READER_SLOT_IDS];
552
+ export const GATE_READER_SLOT_IDS = GATE_PROVIDERS.flatMap((provider) => GATE_READER_SLOT_IDS_BY_PROVIDER[provider]);
475
553
  /** Every gate plane's live-feed tiers, for the plane-neutral sweeps. */
476
- export const GATE_LIVEFEED_SLOT_IDS = [
477
- ...CME_LIVEFEED_SLOT_IDS,
478
- ...OPRA_LIVEFEED_SLOT_IDS,
479
- ];
554
+ export const GATE_LIVEFEED_SLOT_IDS = GATE_PROVIDERS.flatMap((provider) => GATE_LIVEFEED_SLOT_IDS_BY_PROVIDER[provider]);
480
555
  /**
481
556
  * The gate slot serving each (provider, family, tier). `satisfies` makes the
482
557
  * compiler reject a plane missing a tier pairing, so a new provider cannot
@@ -488,6 +563,10 @@ const GATE_SLOT_BY_PROVIDER_FAMILY_TIER = {
488
563
  reader: { realtime: 'opraV2Realtime', delayed: 'opraV2Delayed' },
489
564
  livefeed: { realtime: 'opraLiveFeedRealtime', delayed: 'opraLiveFeedDelayed' },
490
565
  },
566
+ stocks: {
567
+ reader: { realtime: 'stocksV2Realtime', delayed: 'stocksV2Delayed' },
568
+ livefeed: { realtime: 'stocksLiveFeedRealtime', delayed: 'stocksLiveFeedDelayed' },
569
+ },
491
570
  };
492
571
  export function gateSlotForTier(provider, family, tier) {
493
572
  return GATE_SLOT_BY_PROVIDER_FAMILY_TIER[provider][family][tier];
@@ -497,7 +576,7 @@ export function gateProviderOf(wsType) {
497
576
  if (!(wsType in SOCKET_SLOTS))
498
577
  return null;
499
578
  const provider = SOCKET_SLOTS[wsType].provider;
500
- return provider === 'cme' || provider === 'opra' ? provider : null;
579
+ return isGateProvider(provider) ? provider : null;
501
580
  }
502
581
  export function isGateReaderSlot(wsType) {
503
582
  return gateProviderOf(wsType) !== null && SOCKET_SLOTS[wsType].family === 'reader';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orangecharts/wrun-chart-host",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "description": "The wrun chart-host layer shared by the kiyotaka web app and the mobile app: the wrun result reader and painter model, cut from the web app (its reference implementation).",
5
5
  "type": "module",
6
6
  "files": [
@@ -28,14 +28,14 @@
28
28
  "typecheck": "tsc -p tsconfig.json --noEmit"
29
29
  },
30
30
  "peerDependencies": {
31
- "@orangecharts/indicator-kit": "0.103.1",
32
- "@orangecharts/orange-v2-pb-common": "12.78.0",
31
+ "@orangecharts/indicator-kit": "0.106.5",
32
+ "@orangecharts/orange-v2-pb-common": "12.79.0",
33
33
  "dayjs": "1.11.23",
34
34
  "lodash-es": "4.18.1"
35
35
  },
36
36
  "devDependencies": {
37
- "@orangecharts/indicator-kit": "0.103.1",
38
- "@orangecharts/orange-v2-pb-common": "12.78.0",
37
+ "@orangecharts/indicator-kit": "0.106.5",
38
+ "@orangecharts/orange-v2-pb-common": "12.79.0",
39
39
  "@types/lodash-es": "4.17.12",
40
40
  "dayjs": "1.11.23",
41
41
  "lodash-es": "4.18.1",
@@ -1,56 +0,0 @@
1
- /**
2
- * The order gate of a per-order tape's live prints (BT-ORDER-FLOOR): the ONE rule the wrun intake's tape enqueue and the
3
- * kScript fan-out of a `trades` source both apply, before their capped queues.
4
- *
5
- * Where the per-order switch holds (wrun-tape-per-order.util `wrunTapePerOrder`) a CME Group tape keeps its raw TRADE
6
- * live channel and its floor judges ORDERS, as the gateway's per-order history read does. Consecutive same-side prints
7
- * whose millisecond stamps sit within TRADES_ORDER_JOIN_MS of the print before form one order (Big Trades' "Combine
8
- * fills: One order" rule, the kScript template's `joins`). The order is judged when a print of the other side or a
9
- * later stamp arrives, or after TRADES_ORDER_HOLD_MS of quiet, so the last order of a quiet stretch is never held. It is
10
- * judged by its total in the floor's unit (contracts under `minSize`, dollars under `minValue`, each print valued by
11
- * `tradesTapeCellSize`): at or above the floor EVERY fill is admitted, so the package's combine sees them all; below it
12
- * the order is dropped whole. A per-fill floor there drew a 147-contract NQZ6 buy of 45 fills as its two 17-lot fills.
13
- *
14
- * The gateway keys an order by its exact exchange stamp and side, the gate by the package's combine group: the group
15
- * holds every such order, so an admitted fill belongs to an order the per-order history at the same floor answers,
16
- * except when two same-side orders within 1 ms each fall short of the floor and only their sum reaches it (the package
17
- * draws them as one trade; the reconcile, which only adds prints to a bar, keeps them).
18
- *
19
- * Pure but for its hold timer: no store, no chart, worker-safe.
20
- */
21
- import { type LiveTradePrint, type TradesTapeFloor } from './live-trades-merge.util.js';
22
- /** The widest gap between two consecutive fills of one order, ms (the package's "One order" combine). */
23
- export declare const TRADES_ORDER_JOIN_MS = 1;
24
- /** How long the forming order waits for another fill before it is judged, ms. */
25
- export declare const TRADES_ORDER_HOLD_MS = 50;
26
- /** Where the gate's verdicts go: every fill of an order at or above the floor, or of one below it, in arrival order. */
27
- export interface TradesOrderGateHooks<T> {
28
- admit(items: readonly T[]): void;
29
- drop(items: readonly T[]): void;
30
- }
31
- /** The floor a tape floor sets on an order's total, in the unit `tradesTapeCellSize` values a print in; 0 for none. */
32
- export declare function tradesOrderGateThreshold(floor: TradesTapeFloor): number;
33
- /** One tape's order gate (above): `push` each live print with the item the caller admits; `flush` judges the forming
34
- * order now; `dispose` forgets it (a teardown, a new generation). */
35
- export declare class TradesOrderGate<T> {
36
- private readonly hooks;
37
- private items;
38
- private side;
39
- private lastTsMs;
40
- private total;
41
- private threshold;
42
- private timer;
43
- constructor(hooks: TradesOrderGateHooks<T>);
44
- /** The fills of the forming order, not judged yet. */
45
- get held(): number;
46
- /** Take one live print (`print`, read by `readLiveTradePrint`) under the tape's floor. A print the floor cannot value
47
- * (a dollar floor without a unit, an option print its units cannot price) is dropped alone; with no floor the print
48
- * is admitted at once, after the forming order. */
49
- push(item: T, print: Pick<LiveTradePrint, 'tsMs' | 'price' | 'size' | 'side'>, floor: TradesTapeFloor): void;
50
- /** Judge the forming order now: every fill admitted when its total reaches the floor, else every fill dropped. */
51
- flush(): void;
52
- /** Forget the forming order without a verdict. */
53
- dispose(): void;
54
- private arm;
55
- private clearTimer;
56
- }
@@ -1,107 +0,0 @@
1
- /**
2
- * The order gate of a per-order tape's live prints (BT-ORDER-FLOOR): the ONE rule the wrun intake's tape enqueue and the
3
- * kScript fan-out of a `trades` source both apply, before their capped queues.
4
- *
5
- * Where the per-order switch holds (wrun-tape-per-order.util `wrunTapePerOrder`) a CME Group tape keeps its raw TRADE
6
- * live channel and its floor judges ORDERS, as the gateway's per-order history read does. Consecutive same-side prints
7
- * whose millisecond stamps sit within TRADES_ORDER_JOIN_MS of the print before form one order (Big Trades' "Combine
8
- * fills: One order" rule, the kScript template's `joins`). The order is judged when a print of the other side or a
9
- * later stamp arrives, or after TRADES_ORDER_HOLD_MS of quiet, so the last order of a quiet stretch is never held. It is
10
- * judged by its total in the floor's unit (contracts under `minSize`, dollars under `minValue`, each print valued by
11
- * `tradesTapeCellSize`): at or above the floor EVERY fill is admitted, so the package's combine sees them all; below it
12
- * the order is dropped whole. A per-fill floor there drew a 147-contract NQZ6 buy of 45 fills as its two 17-lot fills.
13
- *
14
- * The gateway keys an order by its exact exchange stamp and side, the gate by the package's combine group: the group
15
- * holds every such order, so an admitted fill belongs to an order the per-order history at the same floor answers,
16
- * except when two same-side orders within 1 ms each fall short of the floor and only their sum reaches it (the package
17
- * draws them as one trade; the reconcile, which only adds prints to a bar, keeps them).
18
- *
19
- * Pure but for its hold timer: no store, no chart, worker-safe.
20
- */
21
- import { tradesTapeCellSize, tradesTapeFloorIsDollars, } from './live-trades-merge.util.js';
22
- /** The widest gap between two consecutive fills of one order, ms (the package's "One order" combine). */
23
- export const TRADES_ORDER_JOIN_MS = 1;
24
- /** How long the forming order waits for another fill before it is judged, ms. */
25
- export const TRADES_ORDER_HOLD_MS = 50;
26
- /** The floor a tape floor sets on an order's total, in the unit `tradesTapeCellSize` values a print in; 0 for none. */
27
- export function tradesOrderGateThreshold(floor) {
28
- const threshold = Number(tradesTapeFloorIsDollars(floor) ? floor.minValue : floor.minSize);
29
- return Number.isFinite(threshold) && threshold > 0 ? threshold : 0;
30
- }
31
- /** One tape's order gate (above): `push` each live print with the item the caller admits; `flush` judges the forming
32
- * order now; `dispose` forgets it (a teardown, a new generation). */
33
- export class TradesOrderGate {
34
- hooks;
35
- items = [];
36
- side = 0;
37
- lastTsMs = Number.NaN;
38
- total = 0;
39
- threshold = 0;
40
- timer;
41
- constructor(hooks) {
42
- this.hooks = hooks;
43
- }
44
- /** The fills of the forming order, not judged yet. */
45
- get held() {
46
- return this.items.length;
47
- }
48
- /** Take one live print (`print`, read by `readLiveTradePrint`) under the tape's floor. A print the floor cannot value
49
- * (a dollar floor without a unit, an option print its units cannot price) is dropped alone; with no floor the print
50
- * is admitted at once, after the forming order. */
51
- push(item, print, floor) {
52
- const value = tradesTapeCellSize(print, { ...floor, perOrder: true });
53
- if (value === null) {
54
- this.hooks.drop([item]);
55
- return;
56
- }
57
- const threshold = tradesOrderGateThreshold(floor);
58
- if (threshold === 0) {
59
- this.flush();
60
- this.hooks.admit([item]);
61
- return;
62
- }
63
- const joins = this.items.length > 0 && print.side === this.side && Math.abs(print.tsMs - this.lastTsMs) <= TRADES_ORDER_JOIN_MS;
64
- if (!joins) {
65
- this.flush();
66
- this.side = print.side;
67
- this.total = 0;
68
- }
69
- this.items.push(item);
70
- this.total += value;
71
- this.lastTsMs = print.tsMs;
72
- this.threshold = threshold;
73
- this.arm();
74
- }
75
- /** Judge the forming order now: every fill admitted when its total reaches the floor, else every fill dropped. */
76
- flush() {
77
- this.clearTimer();
78
- if (this.items.length === 0)
79
- return;
80
- const items = this.items;
81
- const admitted = this.total >= this.threshold;
82
- this.items = [];
83
- this.total = 0;
84
- if (admitted)
85
- this.hooks.admit(items);
86
- else
87
- this.hooks.drop(items);
88
- }
89
- /** Forget the forming order without a verdict. */
90
- dispose() {
91
- this.clearTimer();
92
- this.items = [];
93
- this.total = 0;
94
- }
95
- arm() {
96
- this.clearTimer();
97
- this.timer = setTimeout(() => {
98
- this.timer = undefined;
99
- this.flush();
100
- }, TRADES_ORDER_HOLD_MS);
101
- }
102
- clearTimer() {
103
- if (this.timer !== undefined)
104
- clearTimeout(this.timer);
105
- this.timer = undefined;
106
- }
107
- }