@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
@@ -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.0",
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": [
@@ -22,23 +22,23 @@
22
22
  "default": "./dist/*.js"
23
23
  }
24
24
  },
25
- "scripts": {
26
- "build": "node scripts/generate-tool-tables.mjs && rm -rf dist && tsc -p tsconfig.build.json && node scripts/esm-dist.mjs dist",
27
- "consumer-check": "node scripts/consumer-check.mjs",
28
- "typecheck": "tsc -p tsconfig.json --noEmit"
29
- },
30
25
  "peerDependencies": {
31
- "@orangecharts/indicator-kit": "0.103.1",
32
- "@orangecharts/orange-v2-pb-common": "12.78.0",
26
+ "@orangecharts/indicator-kit": "0.106.5",
27
+ "@orangecharts/orange-v2-pb-common": "12.79.0",
33
28
  "dayjs": "1.11.23",
34
29
  "lodash-es": "4.18.1"
35
30
  },
36
31
  "devDependencies": {
37
- "@orangecharts/indicator-kit": "0.103.1",
38
- "@orangecharts/orange-v2-pb-common": "12.78.0",
32
+ "@orangecharts/indicator-kit": "0.106.5",
33
+ "@orangecharts/orange-v2-pb-common": "12.79.0",
39
34
  "@types/lodash-es": "4.17.12",
40
35
  "dayjs": "1.11.23",
41
36
  "lodash-es": "4.18.1",
42
37
  "typescript": "5.9.3"
38
+ },
39
+ "scripts": {
40
+ "build": "node scripts/generate-tool-tables.mjs && rm -rf dist && tsc -p tsconfig.build.json && node scripts/esm-dist.mjs dist",
41
+ "consumer-check": "node scripts/consumer-check.mjs",
42
+ "typecheck": "tsc -p tsconfig.json --noEmit"
43
43
  }
44
- }
44
+ }
@@ -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
- }