@orangecharts/wrun-chart-host 0.9.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 (252) hide show
  1. package/README.md +2 -0
  2. package/dist/constants/feature-flags.constants.d.ts +15 -1
  3. package/dist/constants/feature-flags.constants.js +130 -24
  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/opra-compliance.constants.d.ts +3 -2
  7. package/dist/constants/opra-compliance.constants.js +3 -2
  8. package/dist/constants/option-venues.constants.d.ts +2 -2
  9. package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +26 -0
  10. package/dist/constants/scriptEditor/builtin-script-snippets.js +6 -0
  11. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +15 -0
  12. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +17 -0
  13. package/dist/constants/venue-presets.constants.d.ts +20 -20
  14. package/dist/constants/venue-presets.constants.js +24 -26
  15. package/dist/host-env.d.ts +21 -5
  16. package/dist/host-env.js +6 -0
  17. package/dist/host-ports.types.d.ts +102 -19
  18. package/dist/index.d.ts +18 -0
  19. package/dist/index.js +18 -0
  20. package/dist/interfaces/cancel-reason.interface.d.ts +1 -1
  21. package/dist/interfaces/cme-realtime.interface.d.ts +16 -9
  22. package/dist/interfaces/cme-realtime.interface.js +6 -3
  23. package/dist/interfaces/kscript-diagnostics.interface.d.ts +12 -0
  24. package/dist/interfaces/opra-realtime.interface.d.ts +1 -5
  25. package/dist/interfaces/prediction-market.interface.d.ts +7 -0
  26. package/dist/interfaces/replay.interface.d.ts +8 -0
  27. package/dist/interfaces/stocks-realtime.interface.d.ts +57 -0
  28. package/dist/interfaces/stocks-realtime.interface.js +32 -0
  29. package/dist/interfaces/wrun-runtime.interface.d.ts +18 -2
  30. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +62 -94
  31. package/dist/kscript-data/controls/live-trades-merge.util.js +106 -171
  32. package/dist/market-data/billing.interface.d.ts +174 -36
  33. package/dist/market-data/billing.interface.js +58 -8
  34. package/dist/market-data/venue.d.ts +152 -7
  35. package/dist/market-data/venues/cme.contract.copy.json +66 -0
  36. package/dist/market-data/venues/cme.d.ts +126 -0
  37. package/dist/market-data/venues/cme.js +133 -0
  38. package/dist/market-data/venues/index.d.ts +294 -7
  39. package/dist/market-data/venues/index.js +49 -6
  40. package/dist/market-data/venues/opra.contract.copy.json +3 -2
  41. package/dist/market-data/venues/opra.d.ts +2 -2
  42. package/dist/market-data/venues/opra.js +5 -2
  43. package/dist/market-data/venues/stocks.contract.copy.json +64 -0
  44. package/dist/market-data/venues/stocks.d.ts +130 -0
  45. package/dist/market-data/venues/stocks.js +117 -0
  46. package/dist/settings-templates/footprint-rows.js +35 -2
  47. package/dist/settings-templates/form-rows.d.ts +2 -1
  48. package/dist/settings-templates/index.js +7 -3
  49. package/dist/settings-templates/indicator-fields.d.ts +5 -4
  50. package/dist/settings-templates/indicator-fields.js +79 -10
  51. package/dist/settings-templates/tool-rules.d.ts +32 -15
  52. package/dist/settings-templates/tool-rules.js +33 -11
  53. package/dist/settings-templates/tool-tables.generated.js +95 -31
  54. package/dist/utility/chart/book-live-bucket.util.d.ts +15 -0
  55. package/dist/utility/chart/book-live-bucket.util.js +47 -0
  56. package/dist/utility/chart/cme-cache-context.util.d.ts +5 -3
  57. package/dist/utility/chart/cme-cache-context.util.js +10 -6
  58. package/dist/utility/chart/cme-realtime.util.js +10 -0
  59. package/dist/utility/chart/cme-user-scripts-gate.util.d.ts +83 -0
  60. package/dist/utility/chart/cme-user-scripts-gate.util.js +142 -0
  61. package/dist/utility/chart/effective-chart-session.util.d.ts +14 -0
  62. package/dist/utility/chart/effective-chart-session.util.js +39 -0
  63. package/dist/utility/chart/host-bar-placement.util.d.ts +28 -0
  64. package/dist/utility/chart/host-bar-placement.util.js +170 -30
  65. package/dist/utility/chart/index-host-tier.util.d.ts +3 -1
  66. package/dist/utility/chart/index-host-tier.util.js +7 -2
  67. package/dist/utility/chart/index-mode-admission.util.js +30 -3
  68. package/dist/utility/chart/kscript-apply-fingerprint.util.js +1 -1
  69. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +35 -11
  70. package/dist/utility/chart/kscript-drawing-safe-area.util.js +145 -35
  71. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +9 -7
  72. package/dist/utility/chart/kscript-live-coalesce.util.js +13 -8
  73. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +9 -0
  74. package/dist/utility/chart/kscript-live-source-identity.util.js +10 -1
  75. package/dist/utility/chart/kscript-provenance-keys.util.js +13 -0
  76. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +5 -1
  77. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +32 -2
  78. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +45 -0
  79. package/dist/utility/chart/kscript-venue-policy.util.d.ts +156 -43
  80. package/dist/utility/chart/kscript-venue-policy.util.js +249 -59
  81. package/dist/utility/chart/live-bucket.util.d.ts +24 -8
  82. package/dist/utility/chart/live-bucket.util.js +85 -27
  83. package/dist/utility/chart/market-session-schedule.util.d.ts +10 -0
  84. package/dist/utility/chart/market-session-schedule.util.js +16 -0
  85. package/dist/utility/chart/marketKind.util.js +5 -0
  86. package/dist/utility/chart/mixed-mode.util.d.ts +7 -0
  87. package/dist/utility/chart/mixed-mode.util.js +14 -0
  88. package/dist/utility/chart/opra-read-access.leaf.d.ts +5 -3
  89. package/dist/utility/chart/opra-read-access.leaf.js +5 -3
  90. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +11 -16
  91. package/dist/utility/chart/opra-user-scripts-gate.util.js +12 -28
  92. package/dist/utility/chart/rth-session.util.d.ts +12 -10
  93. package/dist/utility/chart/rth-session.util.js +25 -21
  94. package/dist/utility/chart/trading-day.util.d.ts +17 -0
  95. package/dist/utility/chart/trading-day.util.js +59 -0
  96. package/dist/utility/chart/window-geometry.leaf.d.ts +8 -0
  97. package/dist/utility/chart/window-geometry.leaf.js +22 -6
  98. package/dist/utility/chart/window-owner.leaf.d.ts +23 -2
  99. package/dist/utility/chart/window-owner.leaf.js +45 -3
  100. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +33 -15
  101. package/dist/utility/chart/wrun-bar-session-facts.util.js +70 -20
  102. package/dist/utility/chart/wrun-run-result.util.d.ts +12 -0
  103. package/dist/utility/chart/wrun-run-result.util.js +141 -6
  104. package/dist/utility/intl-locale.util.js +5 -0
  105. package/dist/utility/options/option-bar-anchor.util.d.ts +145 -0
  106. package/dist/utility/options/option-bar-anchor.util.js +340 -0
  107. package/dist/utility/options/option-venue.util.d.ts +18 -0
  108. package/dist/utility/options/option-venue.util.js +27 -0
  109. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +4 -0
  110. package/dist/utility/v2/gate-plane.util.d.ts +12 -3
  111. package/dist/utility/v2/gate-plane.util.js +30 -4
  112. package/dist/utility/v2/gate-session-latch.util.js +1 -1
  113. package/dist/utility/v2/stocks-governed.util.d.ts +16 -0
  114. package/dist/utility/v2/stocks-governed.util.js +34 -0
  115. package/dist/utility/wrun/derived-roots.leaf.d.ts +13 -0
  116. package/dist/utility/wrun/derived-roots.leaf.js +27 -0
  117. package/dist/utility/wrun/derived-roots.util.d.ts +205 -0
  118. package/dist/utility/wrun/derived-roots.util.js +451 -0
  119. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +43 -7
  120. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +89 -19
  121. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +9 -4
  122. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +47 -6
  123. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -2
  124. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -2
  125. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +24 -3
  126. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +46 -10
  127. package/dist/utility/wrun/sources/lanes/option_daily.js +5 -2
  128. package/dist/utility/wrun/sources/lanes/options_flow.js +5 -2
  129. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +64 -19
  130. package/dist/utility/wrun/sources/opra-option-lanes.util.js +105 -35
  131. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +2 -1
  132. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +2 -1
  133. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +3 -0
  134. package/dist/utility/wrun/sources/row-lanes/option_prints.js +19 -4
  135. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +17 -4
  136. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +52 -13
  137. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +88 -19
  138. package/dist/utility/wrun/sources/row-lanes/option_surface.js +2 -1
  139. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -0
  140. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +24 -9
  141. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +41 -10
  142. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +111 -0
  143. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +133 -0
  144. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +15 -3
  145. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +22 -3
  146. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +31 -0
  147. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +197 -13
  148. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +761 -27
  149. package/dist/utility/wrun/wrun-browser-sources.leaf.js +1 -2
  150. package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +12 -0
  151. package/dist/utility/wrun/wrun-builtin-twin.util.js +21 -0
  152. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +60 -16
  153. package/dist/utility/wrun/wrun-chart-market-facts.util.js +113 -61
  154. package/dist/utility/wrun/wrun-color-settings.util.d.ts +9 -0
  155. package/dist/utility/wrun/wrun-color-settings.util.js +33 -0
  156. package/dist/utility/wrun/wrun-download-meter.util.d.ts +15 -0
  157. package/dist/utility/wrun/wrun-download-meter.util.js +14 -2
  158. package/dist/utility/wrun/wrun-download-plan.util.d.ts +99 -0
  159. package/dist/utility/wrun/wrun-download-plan.util.js +118 -0
  160. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +11 -3
  161. package/dist/utility/wrun/wrun-draft-legend-note.util.js +26 -4
  162. package/dist/utility/wrun/wrun-frames.d.ts +27 -6
  163. package/dist/utility/wrun/wrun-frames.js +73 -10
  164. package/dist/utility/wrun/wrun-handles.util.d.ts +7 -3
  165. package/dist/utility/wrun/wrun-handles.util.js +9 -8
  166. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +7 -1
  167. package/dist/utility/wrun/wrun-hosted-wire.util.js +12 -2
  168. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +18 -4
  169. package/dist/utility/wrun/wrun-hud-looks.util.js +45 -13
  170. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +68 -0
  171. package/dist/utility/wrun/wrun-input-requirements.leaf.js +163 -7
  172. package/dist/utility/wrun/wrun-latest-snapshot.d.ts +11 -0
  173. package/dist/utility/wrun/wrun-leg-close.util.d.ts +59 -23
  174. package/dist/utility/wrun/wrun-leg-close.util.js +186 -28
  175. package/dist/utility/wrun/wrun-live-intake.util.d.ts +35 -15
  176. package/dist/utility/wrun/wrun-live-intake.util.js +243 -126
  177. package/dist/utility/wrun/wrun-live-tick.util.d.ts +13 -5
  178. package/dist/utility/wrun/wrun-live-tick.util.js +279 -99
  179. package/dist/utility/wrun/wrun-market-facts.util.d.ts +13 -3
  180. package/dist/utility/wrun/wrun-market-facts.util.js +13 -3
  181. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +60 -11
  182. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +70 -5
  183. package/dist/utility/wrun/wrun-market-size-defaults.util.js +31 -5
  184. package/dist/utility/wrun/wrun-opra-lane.util.d.ts +17 -4
  185. package/dist/utility/wrun/wrun-opra-lane.util.js +6 -4
  186. package/dist/utility/wrun/wrun-option-book-rows.util.d.ts +56 -0
  187. package/dist/utility/wrun/wrun-option-book-rows.util.js +96 -0
  188. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.d.ts +31 -0
  189. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.js +119 -0
  190. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +23 -6
  191. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +47 -11
  192. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +86 -19
  193. package/dist/utility/wrun/wrun-option-strike-flow.util.js +168 -62
  194. package/dist/utility/wrun/wrun-option-views.util.d.ts +323 -28
  195. package/dist/utility/wrun/wrun-option-views.util.js +484 -71
  196. package/dist/utility/wrun/wrun-options-chain.util.d.ts +3 -3
  197. package/dist/utility/wrun/wrun-options-chain.util.js +2 -0
  198. package/dist/utility/wrun/wrun-output-style.util.d.ts +6 -2
  199. package/dist/utility/wrun/wrun-output-style.util.js +20 -2
  200. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +32 -2
  201. package/dist/utility/wrun/wrun-overlay-drivers.util.js +13 -3
  202. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +10 -1
  203. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +52 -4
  204. package/dist/utility/wrun/wrun-overlay-recovery.util.js +3 -1
  205. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +160 -42
  206. package/dist/utility/wrun/wrun-overlay-run.util.js +1244 -209
  207. package/dist/utility/wrun/wrun-pane-format.util.d.ts +2 -1
  208. package/dist/utility/wrun/wrun-pane-format.util.js +7 -3
  209. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +9 -0
  210. package/dist/utility/wrun/wrun-panel-mount.util.js +114 -19
  211. package/dist/utility/wrun/wrun-panel-style.util.d.ts +10 -9
  212. package/dist/utility/wrun/wrun-panel-style.util.js +58 -9
  213. package/dist/utility/wrun/wrun-param-map.util.d.ts +14 -11
  214. package/dist/utility/wrun/wrun-param-map.util.js +10 -5
  215. package/dist/utility/wrun/wrun-param-values.util.d.ts +14 -4
  216. package/dist/utility/wrun/wrun-param-values.util.js +4 -0
  217. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +15 -2
  218. package/dist/utility/wrun/wrun-pin-spelling.util.js +39 -14
  219. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +50 -0
  220. package/dist/utility/wrun/wrun-refusal-surface.util.js +68 -0
  221. package/dist/utility/wrun/wrun-refusal.util.d.ts +3 -2
  222. package/dist/utility/wrun/wrun-refusal.util.js +22 -0
  223. package/dist/utility/wrun/wrun-refused-latest.util.d.ts +10 -0
  224. package/dist/utility/wrun/wrun-refused-latest.util.js +12 -0
  225. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +26 -0
  226. package/dist/utility/wrun/wrun-registry-errors.util.js +34 -0
  227. package/dist/utility/wrun/wrun-replay-lane.util.js +3 -2
  228. package/dist/utility/wrun/wrun-row-source.d.ts +11 -0
  229. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +20 -6
  230. package/dist/utility/wrun/wrun-run-interval-session.util.js +22 -7
  231. package/dist/utility/wrun/wrun-run-interval.util.d.ts +43 -9
  232. package/dist/utility/wrun/wrun-run-interval.util.js +58 -15
  233. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +45 -1
  234. package/dist/utility/wrun/wrun-script-inputs.util.js +112 -4
  235. package/dist/utility/wrun/wrun-setting-words.util.d.ts +7 -3
  236. package/dist/utility/wrun/wrun-setting-words.util.js +13 -5
  237. package/dist/utility/wrun/wrun-socket-row-source.d.ts +27 -2
  238. package/dist/utility/wrun/wrun-socket-row-source.js +118 -8
  239. package/dist/utility/wrun/wrun-source-rows.util.d.ts +29 -18
  240. package/dist/utility/wrun/wrun-source-rows.util.js +61 -27
  241. package/dist/utility/wrun/wrun-style-words.util.js +6 -4
  242. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +3 -2
  243. package/dist/utility/wrun/wrun-table-chrome.util.js +19 -11
  244. package/dist/utility/wrun/wrun-tape-per-order.util.d.ts +2 -0
  245. package/dist/utility/wrun/wrun-tape-per-order.util.js +7 -0
  246. package/dist/utility/wrun/wrun-tape-source.util.d.ts +17 -9
  247. package/dist/utility/wrun/wrun-tape-source.util.js +20 -12
  248. package/dist/utils/replay/replay-buffer-math.d.ts +53 -2
  249. package/dist/utils/replay/replay-buffer-math.js +227 -20
  250. package/dist/workers/constants/socket-slots.d.ts +91 -6
  251. package/dist/workers/constants/socket-slots.js +85 -6
  252. package/package.json +5 -5
@@ -23,18 +23,14 @@
23
23
  * - liquidations: K_LIQUIDATIONS (additive per side; the increment is amount x price, USD like
24
24
  * the lane's history ask, or the amount in coins when the acquisition asked for coins);
25
25
  * - tape: K_TRADES's live fold (`mergeLiveTradesDataPoint`, the leaf the control and the history
26
- * worker share): one `[offsetMs, price, size, side]` cell per raw print appended to its bar's
27
- * row, the side from the series envelope, prints below the acquisition's `minSize` rejected,
28
- * the bar the worker keys (a week on its Monday, the CME lattice on its venues), a delayed
29
- * print for a bar older than the newest row never appending an out-of-order row, a live bar
30
- * capped at 20k prints (the bucket reported as capped, which the tick refuses by name); prints
31
- * below the floor are dropped at the enqueue too, so a busy tape never crowds a qualifying print
32
- * out of the queue (the kScript fan-out's rule). The floor includes the large-print table's own
33
- * (`tradesBelowLargeFloor`: a dollar-quoted print under 10,000 notional, a CME Group print under
34
- * its root's contracts floor), so no print appears live that the next reconcile cannot answer. A
35
- * print the queue cap drops leaves its bar short: the
36
- * drain marks the bucket for the reconcile (`tape-lost`) when the table can restore it, else the
37
- * tick refuses the bucket by name (`tapeLostBuckets`);
26
+ * worker share): one cell per TRADE_LARGE row, one order each, never a raw TRADE print (`ignored:other-channel`),
27
+ * each print in the host bar holding its instant where the chart's bars leave the tape's own grid
28
+ * (`wrunTapeHostBarResolver`, the cell placement its history gets);
29
+ * - a push lane the run asked on another market than the chart's (its acquisition names it: the run market, a US
30
+ * stock Trades chart's ticker on its consolidated tape, for the tape, trades and profile lanes) takes its rows from
31
+ * that market alone (`pinnedLaneMarketOf`), admitted at the fan-out and the enqueue; every other market's frame,
32
+ * the chart's included, is foreign to it. The session, the bar grid and the units stay the chart's: the folds key
33
+ * the chart's bars and a tape's floors read the chart's market (`wrunTapeLaneHostBarOf` places a print over both);
38
34
  * - a row lane fed live by COIN (`WrunRowLaneDescriptor.liveByCoin`, sources/row-lane-registry.ts): a
39
35
  * point of the frame's script source is admitted when its coin (the lane's `coinOf`, else the series'
40
36
  * coin) is the coin the instance was asked for (its acquisition's `coin`: the chart's underlying),
@@ -44,9 +40,14 @@
44
40
  * - funding: K_FUNDING_RATE (last-wins, normalized to 1h, percent);
45
41
  * - volume_profile: K_VOLUME_PROFILE_AGG (delta fold on the lattice, needs a
46
42
  * fetched base row, quote guard);
47
- * - book: K_ORDERBOOK.buildLiveDataRows for raw frames (an exact bar
48
- * boundary belongs to the PREVIOUS bar, `roundObTimestamp`); rows marked
49
- * `bucketed: true` (the heatmap rider's projection) are taken as-is;
43
+ * - book: K_ORDERBOOK.buildLiveDataRows for raw frames, keyed on the chart
44
+ * market's bar (`bookLiveBucketMs`: an exact bar boundary belongs to the
45
+ * PREVIOUS bar, on the CME session lattice on a CME Group market); rows
46
+ * marked `bucketed: true` (the heatmap rider's projection, keyed by the same
47
+ * rule) are taken as-is; the fold then lands each keyed row on the host bar
48
+ * the chart's history puts it in (`wrunBookRowHostBarResolver`: a CME chart
49
+ * in RTH above 30m opens its bars on the 09:30 New York anchor, off the
50
+ * book's own hours), the latest snapshot per bar winning;
50
51
  * - a foreign GRID leg (a pinned market's rows at the chart interval, the
51
52
  * G4 round-3 contract): K_OHLCV.mergeLiveDataPoint over that market's
52
53
  * candle frames (`mergeLiveOhlcvDataPoint`: high/low widen, close
@@ -73,16 +74,20 @@ import { findMonday, getDecimalPlaces } from '../chart/titan-constants.pin.js';
73
74
  import { Intervals } from '../../constants/interval.constants.js';
74
75
  import { FUNDING_INTERVAL_MAP } from '../../constants/overlay-data.constants.js';
75
76
  import { mergeLiveOhlcvDataPoint } from '../../kscript-data/controls/live-ohlcv-merge.util.js';
76
- import { mergeLiveTradesDataPoint, readLiveTradePrint, tradesBarStartMs, tradesBelowLargeFloor, tradesLargeHistoryAnswers, tradesTapeCellSize, tradesTapeFloorValuesPrints, } from '../../kscript-data/controls/live-trades-merge.util.js';
77
+ import { liveTradeOfPoint, mergeLiveTradesDataPoint, readLiveTradePrint, tradesBarStartMs, tradesTapeCellSize, tradesTapeFloorValuesPrints, } from '../../kscript-data/controls/live-trades-merge.util.js';
77
78
  import { liveAmountUsd, peekOptionTradeUnits } from '../options/option-trade-units.util.js';
78
79
  import { parseWrunTapeHistory, wrunTapeHistoryOf } from './wrun-tape-source.util.js';
79
80
  import { wrunDollarUnitReader } from './wrun-dollar-unit-port.leaf.js';
80
81
  import { wrunChartHostEnv } from '../../host-env.js';
81
82
  import { v2LiveTradePrintBelowFloor } from '../chart/kscript-live-coalesce.util.js';
82
- import { roundObTimestamp } from '../common/data-processing.util.js';
83
+ import { bookLiveBucketMs, bookLiveBucketRows } from '../chart/book-live-bucket.util.js';
83
84
  import { liveFeedSeriesMatchesChartStream } from '../chart/live-feed-series-match.leaf.js';
85
+ import { KSCRIPT_CURRENT_EXCHANGE_SENTINEL, KSCRIPT_CURRENT_SYMBOL_SENTINEL, } from '../chart/kscript-live-source-identity.util.js';
84
86
  import { liveBucketStartMs, liveBucketVenueOf } from '../chart/live-bucket.util.js';
85
- import { hostBucketResolverFor } from '../chart/host-bar-placement.util.js';
87
+ import { hostBucketResolverFor, sourceRowHostBarResolverFor } from '../chart/host-bar-placement.util.js';
88
+ import { sourceRowsStraddleHostBars } from '../chart/index-host-tier.util.js';
89
+ import { wrunLaneServedOnMarket } from '../chart/index-mode-admission.util.js';
90
+ import { serverNowMs } from '../auth/server-clock.util.js';
86
91
  import { wrunRowLaneByKey } from './sources/row-lane-registry.js';
87
92
  import { wrunHostBarOf } from './wrun-tier-grid.util.js';
88
93
  import { barStartMs } from '../chart/calendar-interval.util.js';
@@ -92,9 +97,7 @@ import { getProfileBucketHeight, normalizeTicksPerBar } from '../../workers/util
92
97
  import { WRUN_RUN_INTERVAL_ROWS_KEY, wrunRunIntervalSessionOf, } from './wrun-run-interval-session.util.js';
93
98
  import { isWrunLegStreamClass } from './wrun-leg-stream-classes.js';
94
99
  import { isWrunTradesLegLane, wrunTradesLegOf, } from './wrun-trades-lane.util.js';
95
- /** The fan-out's script source name of a frame -> the lane it feeds. The `trades` SOURCE (K_TRADES,
96
- * the raw TRADE channel) feeds the `tape` lane; the `trades` LANE (the package's per-bar volume
97
- * by side) is fed by the `buy_sell_volume` source (K_BUY_SELL_VOLUME, TRADE_AGG). */
100
+ /** The `trades` SOURCE (K_TRADES) feeds the `tape` lane; the `trades` LANE is fed by `buy_sell_volume` (TRADE_AGG). */
98
101
  export const WRUN_LIVE_LANE_OF_SCRIPT_SOURCE = {
99
102
  ohlcv: 'ohlcv',
100
103
  buy_sell_volume: 'trades',
@@ -303,7 +306,8 @@ const WRUN_SESSION_LATTICE_LANES = new Set([
303
306
  * open (a week bucket is its Monday, the main path's `findMonday`; a month,
304
307
  * quarter, half or year bucket its UTC calendar boundary), except
305
308
  * the book, whose snapshots are stamped at the observation and an exact
306
- * boundary belongs to the PREVIOUS bar (`roundObTimestamp`, the rule the
309
+ * boundary belongs to the PREVIOUS bar, on the CME session lattice its
310
+ * history rides on a CME Group `market` (`bookLiveBucketMs`, the rule the
307
311
  * K_ORDERBOOK lane and the rider projection apply), and a session-lattice
308
312
  * lane on a `market`, which keys the bar its fetched rows have through the
309
313
  * chart's one live boundary rule (`liveBucketStartMs`: the Chicago session
@@ -315,7 +319,7 @@ const WRUN_SESSION_LATTICE_LANES = new Set([
315
319
  * market passes no venue, so nothing else starts anchoring. */
316
320
  export function wrunLiveBucketTs(lane, tsMs, intervalMs, market) {
317
321
  if (lane === 'book')
318
- return roundObTimestamp(tsMs, intervalMs);
322
+ return bookLiveBucketMs(tsMs, intervalMs, bookVenueOf(market));
319
323
  if (market && WRUN_SESSION_LATTICE_LANES.has(lane)) {
320
324
  return liveBucketStartMs(tsMs, intervalMs, {
321
325
  exchange: market.exchange,
@@ -625,43 +629,113 @@ export function foldWrunLegCandleRows(base, points, intervalMs, market) {
625
629
  return null;
626
630
  return foldResult(mergeLaneRows(base, replaced, added), touched);
627
631
  }
628
- /** K_ORDERBOOK.buildLiveDataRows over a raw frame: replay bursts floor
629
- * every row (copied), a live snapshot floors its one row (copied); a
630
- * bucketed row (`ArrayLike<number>`) is taken as-is. Frames without a
631
- * book payload yield nothing. */
632
- export function wrunLiveBookRows(point, intervalMs) {
632
+ /** The venue a book row is keyed for: the lane's market (the chart's own), or none. */
633
+ function bookVenueOf(market) {
634
+ return market ? { exchange: market.exchange, symbol: market.symbol } : null;
635
+ }
636
+ /**
637
+ * The two grids a chart-own lane's live rows are placed between (`hostBar`, the chart's bars; `row`, the lane's own
638
+ * wire bars), or undefined where its history keeps the lane's own bars, so the fold keeps its key. The lane's ask
639
+ * leaves session-blind (`kScriptSourceRowVenue`'s rule for every K lane but K_OHLCV: the book, the tape), so its wire
640
+ * answers the full session's bars (the :00 hours, the Chicago lattice); titan-charts dataFetch lands that history in
641
+ * the chart's bars (STEP 4 and its packed book lane) exactly where those rows straddle the chart's bars
642
+ * (`sourceRowsStraddleHostBars`): a CME chart in RTH above 30m opens its bars on the 09:30 New York anchor (13:30Z
643
+ * hours in EDT). A lane the chart's fetch serves nothing on (`wrunLaneServedOnMarket`: a stock's or a forex market's
644
+ * book) has no history row to meet, and keeps its key too.
645
+ */
646
+ function wrunLaneHostGridsOf(type, intervalMs, market,
647
+ // The market the lane's rows come from (the run market: a Trades chart's tape) when it is not the chart's own.
648
+ rowMarket = market) {
649
+ if (!market || !rowMarket || !(intervalMs > 0))
650
+ return undefined;
651
+ if (!wrunLaneServedOnMarket({ type, exchange: rowMarket.exchange }))
652
+ return undefined;
653
+ const hostBar = liveBucketVenueOf(market);
654
+ const row = liveBucketVenueOf({ exchange: rowMarket.exchange, symbol: rowMarket.symbol, sessionType: 'extended' });
655
+ return sourceRowsStraddleHostBars(intervalMs, hostBar, intervalMs, row) ? { hostBar, row } : undefined;
656
+ }
657
+ /**
658
+ * The host bar a keyed book row lands on (`wrunLiveBookRows`' key: the snapshot's own bar, its row's open), judged
659
+ * at `nowMs`: the bar the chart's history puts that row in, through the live doors' resolver
660
+ * (`sourceRowHostBarResolverFor`: the bar holding the row's last instant once the chart printed it, before that the
661
+ * forming bar holding its open; none, null, for a row closing past the session's close). On ES1! in RTH at 1h a
662
+ * 14:10Z snapshot (the 14:00Z row) lands in the forming 13:30Z bar and a 15:05Z one (the 15:00Z row) in the 14:30Z
663
+ * bar. Undefined where the history keeps the book's own bars (`wrunLaneHostGridsOf`: 30m and finer, ETH, a day and
664
+ * longer, a 24/7 market, a market served no book): every key is its own bar.
665
+ */
666
+ export function wrunBookRowHostBarResolver(intervalMs, market) {
667
+ const grids = wrunLaneHostGridsOf('orderbook', intervalMs, market);
668
+ return grids && sourceRowHostBarResolverFor(intervalMs, grids.hostBar, intervalMs, grids.row);
669
+ }
670
+ /**
671
+ * The host bar a tape print lands in: the bar holding its own instant (the cell placement its history gets,
672
+ * `placeRowsInHostBars` with `cells`), null where no chart bar holds it. Undefined where the chart's bars are the
673
+ * tape's own (`wrunLaneHostGridsOf`): the print keeps the bar its own grid names (`tradesBarStartMs`).
674
+ */
675
+ export function wrunTapeHostBarResolver(intervalMs, market, rowMarket = market) {
676
+ const grids = wrunLaneHostGridsOf('trades', intervalMs, market, rowMarket);
677
+ return grids && hostBucketResolverFor(intervalMs, grids.hostBar);
678
+ }
679
+ /** The bar a tape print folds into (`wrunTapeHostBarResolver`'s host bar, else its own grid's): the fold, the queue's
680
+ * loss marks and the reconcile's drops key a print here, so they name one bar. Null: no chart bar holds it. */
681
+ function wrunTapePrintBarTs(print, intervalMs, hostBarOf) {
682
+ return hostBarOf === undefined ? tradesBarStartMs(print.tsMs, intervalMs, print.exchange) : hostBarOf(print.tsMs);
683
+ }
684
+ /** A copy of a book row stamped on `barTs` (the row handed in, a rider's included, is never written). */
685
+ function bookRowStampedOn(row, barTs) {
686
+ const copy = Float64Array.from(row);
687
+ copy[0] = barTs;
688
+ return copy;
689
+ }
690
+ /** K_ORDERBOOK.buildLiveDataRows over a raw frame: replay bursts key
691
+ * every row (copied), a live snapshot keys its one row (copied), each on
692
+ * `market`'s bar (`bookLiveBucketMs`: the session lattice on a CME Group
693
+ * market); a bucketed row (`ArrayLike<number>`) is taken as-is. Frames
694
+ * without a book payload yield nothing. */
695
+ export function wrunLiveBookRows(point, intervalMs, market) {
633
696
  if (typeof point.length === 'number' && !isRecord(point.series)) {
634
697
  const row = point;
635
698
  return Number.isFinite(Number(row[0])) ? [row] : [];
636
699
  }
637
700
  const frame = point;
701
+ const venue = bookVenueOf(market);
638
702
  if (frame.series?.isReplay) {
639
- const rows = (frame.float64Arrays ?? []).map((source) => {
640
- const copy = Float64Array.from(source);
641
- if (copy.length > 0)
642
- copy[0] = roundObTimestamp(copy[0], intervalMs);
643
- return copy;
644
- });
645
- return rows.filter((row) => row.length > 0).sort((a, b) => a[0] - b[0]);
703
+ return bookLiveBucketRows((frame.float64Arrays ?? []), intervalMs, venue)
704
+ .filter((row) => row.length > 0)
705
+ .sort((a, b) => a[0] - b[0]);
646
706
  }
647
707
  if (!frame.blockBookSnapshot)
648
708
  return [];
649
709
  const copy = Float64Array.from(frame.blockBookSnapshot);
650
710
  if (copy.length === 0)
651
711
  return [];
652
- copy[0] = roundObTimestamp(copy[0], intervalMs);
712
+ copy[0] = bookLiveBucketMs(copy[0], intervalMs, venue);
653
713
  return [copy];
654
714
  }
655
- function foldBook(base, points, intervalMs) {
715
+ function foldBook(base, points, intervalMs, market) {
656
716
  const indexByTs = new Map();
657
717
  for (let at = 0; at < base.length; at += 1)
658
718
  indexByTs.set(Number(base[at][0]), at);
659
719
  const replaced = new Map();
660
720
  const added = new Map();
661
721
  const touched = new Set();
722
+ // Each keyed row lands on the host bar the chart's history puts it in (judged now, once per fold), and a bar keeps
723
+ // the latest snapshot it holds: a row of an earlier key never replaces a later one there, a later point of the same
724
+ // key does (the replay-then-live order, a live snapshot of the bucket winning).
725
+ const barOf = wrunBookRowHostBarResolver(intervalMs, market);
726
+ const nowMs = barOf === undefined ? 0 : serverNowMs();
727
+ const keyOnBar = new Map();
662
728
  for (const point of points) {
663
- for (const row of wrunLiveBookRows(point, intervalMs)) {
664
- const bucket = Number(row[0]);
729
+ for (const keyed of wrunLiveBookRows(point, intervalMs, market)) {
730
+ const key = Number(keyed[0]);
731
+ const bucket = barOf === undefined ? key : barOf(key, nowMs);
732
+ // No chart bar holds the row (it closes past the session's close): nothing to fold.
733
+ if (bucket === null)
734
+ continue;
735
+ if ((keyOnBar.get(bucket) ?? Number.NEGATIVE_INFINITY) > key)
736
+ continue;
737
+ keyOnBar.set(bucket, key);
738
+ const row = bucket === key ? keyed : bookRowStampedOn(keyed, bucket);
665
739
  if (indexByTs.has(bucket))
666
740
  replaced.set(bucket, row);
667
741
  else
@@ -811,26 +885,30 @@ function foldVolumeProfile(base, points, intervalMs, acquisition, market) {
811
885
  return null;
812
886
  return foldResult(mergeLaneRows(base, replaced, added), touched);
813
887
  }
814
- /** The tape fold: K_TRADES's live fold per raw print (`mergeLiveTradesDataPoint`), each point onto
815
- * the rows as folded so far, under the acquisition's floor (`wrunTapeLiveFloorOf`: its `minSize`,
816
- * or its dollar `minValue`, where each cell's size is the print's dollar value). The leaf answers a
817
- * NEW container with the touched row new and every other row shared, or null for a rejected print
818
- * (the rows stand); the touched bucket is the newest row (a fold never writes behind it). A bucket
819
- * the fold capped (its newest 20k prints kept, the oldest dropped) is reported: its row is
820
- * truncated, and a block is never truncated, so the tick refuses it by name where the kScript lane
821
- * only warns. On the large lane the large-print table's floor applies too (`largeFloor`, the
822
- * chart's market for a frame that names none). */
823
- function foldTape(base, points, intervalMs, acquisition, market) {
888
+ /** Reports the buckets it capped: a block is never served truncated, so the tick refuses them by name. */
889
+ function foldTape(base, points, intervalMs, acquisition, market, rowMarket) {
824
890
  let rows = base;
825
891
  const touched = new Set();
826
892
  const capped = new Set();
827
- const largeFloor = acquisition.large === true ? largeFloorMarketOf(market ?? {}) : undefined;
828
893
  const floor = wrunTapeLiveFloorOf(acquisition, market);
894
+ const large = acquisition.large === true;
895
+ // A print lands in the host bar holding its instant where the chart's bars leave the tape's own grid.
896
+ const hostBarOf = wrunTapeHostBarResolver(intervalMs, market, rowMarket ?? market);
829
897
  for (const point of points) {
830
898
  let cappedNow = false;
899
+ let barTs;
900
+ if (hostBarOf !== undefined) {
901
+ const print = readLiveTradePrint(point, large);
902
+ const bar = print === null ? null : wrunTapePrintBarTs(print, intervalMs, hostBarOf);
903
+ // No print to fold (the fold reads none either), or no chart bar holding it: nothing to fold.
904
+ if (bar === null)
905
+ continue;
906
+ barTs = bar;
907
+ }
831
908
  const next = mergeLiveTradesDataPoint(rows, point, intervalMs, {
832
909
  ...floor,
833
- largeFloor,
910
+ large,
911
+ ...(barTs !== undefined ? { barTs } : {}),
834
912
  onCapped: () => {
835
913
  cappedNow = true;
836
914
  },
@@ -852,10 +930,15 @@ function foldTape(base, points, intervalMs, acquisition, market) {
852
930
  * touched buckets and the earliest of them, or null when nothing folded.
853
931
  * Never mutates `rows` or any point. `acquisition` is the SAME payload the
854
932
  * history fetch used for the lane, so the fold's units equal the lane's;
855
- * `market` is the market that fetch resolved to (the chart's own), so the
856
- * fold keys the bars its rows have (wrunLiveBucketTs).
933
+ * `market` is the market that fetch resolved to (the chart's own, with the
934
+ * chart's session), so the fold keys the bars its rows have (wrunLiveBucketTs),
935
+ * and lands the book and the tape on the chart's bars where their history is
936
+ * placed there (`wrunBookRowHostBarResolver`, judged at the server clock's now,
937
+ * and `wrunTapeHostBarResolver`).
857
938
  */
858
- export function foldWrunLaneRows(lane, rows, points, intervalMs, acquisition, market) {
939
+ export function foldWrunLaneRows(lane, rows, points, intervalMs, acquisition, market,
940
+ // The market the lane's rows come from when it is not the chart's (the tape lane's host bars read both).
941
+ rowMarket) {
859
942
  if (points.length === 0)
860
943
  return null;
861
944
  if (!Number.isFinite(intervalMs) || intervalMs <= 0)
@@ -872,12 +955,12 @@ export function foldWrunLaneRows(lane, rows, points, intervalMs, acquisition, ma
872
955
  case 'funding':
873
956
  return foldFunding(base, points, intervalMs);
874
957
  case 'book':
875
- return foldBook(base, points, intervalMs);
958
+ return foldBook(base, points, intervalMs, market);
876
959
  case 'volume_profile':
877
960
  return foldVolumeProfile(base, points, intervalMs, acquisition, market);
878
961
  case 'tape':
879
962
  // The print's own envelope names its venue (the CME lattice reads it), never the chart's.
880
- return foldTape(base, points, intervalMs, acquisition, market);
963
+ return foldTape(base, points, intervalMs, acquisition, market, rowMarket);
881
964
  default: {
882
965
  // A trades leg folds as its quote's own lane, on its market; the poll lanes have no live fold.
883
966
  const leg = wrunTradesLegOf(lane);
@@ -916,16 +999,38 @@ function isForeignFrame(context, frame) {
916
999
  return false;
917
1000
  return !liveFeedSeriesMatchesChartStream({ exchange: frame.incomingExchange, symbol: frame.incomingSymbol }, { ...market, ...context.market });
918
1001
  }
919
- /** The market the large-print floor judges a chart's tape prints on: its identity and, on an option
920
- * contract of a plain option venue, its registry trade units as answered (`peekOptionTradeUnits`;
921
- * the K_TRADES control starts the read with the acquisition), so the floor reads the premium the
922
- * resolver prices. Until the read answers, the units price nothing and no print passes the floor. */
923
- function largeFloorMarketOf(market) {
924
- const { exchange, symbol } = market;
1002
+ /** True when the frame carries a full series identity that is not `market`'s (the same alias-aware matcher). */
1003
+ function isForeignToMarket(market, frame) {
1004
+ if (!frame.incomingExchange || !frame.incomingSymbol)
1005
+ return false;
1006
+ return !liveFeedSeriesMatchesChartStream({ exchange: frame.incomingExchange, symbol: frame.incomingSymbol }, market);
1007
+ }
1008
+ /** The market a lane's acquisition names when it is not the chart's own (the run market: a Trades chart's tape). */
1009
+ function pinnedLaneMarketOf(context, lane) {
1010
+ const exchange = context.acquisition[lane]?.exchange;
1011
+ const symbol = context.acquisition[lane]?.symbol;
925
1012
  if (typeof exchange !== 'string' || typeof symbol !== 'string')
926
- return market;
927
- const optionUnits = peekOptionTradeUnits({ exchange, symbol });
928
- return optionUnits ? { ...market, optionUnits } : market;
1013
+ return undefined;
1014
+ if (exchange === KSCRIPT_CURRENT_EXCHANGE_SENTINEL || symbol === KSCRIPT_CURRENT_SYMBOL_SENTINEL)
1015
+ return undefined;
1016
+ const pinned = { exchange, symbol };
1017
+ const chart = chartMarketOf(context);
1018
+ return chart && liveFeedSeriesMatchesChartStream(pinned, { ...chart, ...context.market }) ? undefined : pinned;
1019
+ }
1020
+ /** Every market a push lane's acquisition names beside the chart's own, once each (the fan-out admits their frames). */
1021
+ function pinnedLaneMarketsOf(context) {
1022
+ const markets = new Map();
1023
+ for (const lane of WRUN_PUSH_LANES) {
1024
+ const pinned = pinnedLaneMarketOf(context, lane);
1025
+ if (pinned)
1026
+ markets.set(`${pinned.exchange}|${pinned.symbol}`, pinned);
1027
+ }
1028
+ return [...markets.values()];
1029
+ }
1030
+ /** The host bar a tape print lands in: the chart's bars (its session and grid) over the rows of the lane's market. */
1031
+ function wrunTapeLaneHostBarOf(context, intervalMs) {
1032
+ const chart = chartMarketOf(context);
1033
+ return wrunTapeHostBarResolver(intervalMs, chart, pinnedLaneMarketOf(context, 'tape') ?? chart);
929
1034
  }
930
1035
  /** The market facts' dollar unit reader through its port (wrun-dollar-unit-port.leaf): live-feed loads this module
931
1036
  * before the first candle, and the facts module stays out of that closure. A dollar tape's full run loads the facts
@@ -999,7 +1104,7 @@ function noteWrunTapeUnvalued(indicatorId, context) {
999
1104
  }
1000
1105
  /** A live print a dollar tape could not value (its unit not proven yet): it never folds, and its bar is owed the
1001
1106
  * print, exactly like a print the queue cap dropped (`pushAdditive`): the drain has the reconcile restore the bar
1002
- * from the large-print table where it holds the market (`tape-lost`), else the tick refuses the bar by name
1107
+ * from the large-print table on a tape with a history (`tape-lost`), else the tick refuses the bar by name
1003
1108
  * (`tapeLostBuckets`). A unit that no read can ever prove by now (a later answer: no point value, a quote that is no
1004
1109
  * dollar) values no print of the session again, so its bar is refused by name at once, never re-asked on every drain
1005
1110
  * (the Resume's full run then refuses the tape by name, `wrun_tape_value_unproven`). A block is never served short
@@ -1010,8 +1115,11 @@ function wrunTapePrintUnvalued(intake, context, intervalMs, data) {
1010
1115
  const print = readLiveTradePrint(data);
1011
1116
  if (print === null)
1012
1117
  return;
1013
- const bucket = tradesBarStartMs(print.tsMs, intervalMs, print.exchange);
1014
- const market = context.market;
1118
+ const market = chartMarketOf(context);
1119
+ const bucket = wrunTapePrintBarTs(print, intervalMs, wrunTapeLaneHostBarOf(context, intervalMs));
1120
+ // No chart bar holds the print: no bar is owed it.
1121
+ if (bucket === null)
1122
+ return;
1015
1123
  const unit = typeof market?.exchange === 'string' && typeof market.symbol === 'string'
1016
1124
  ? wrunLiveDollarUnitReader()?.unit(market)
1017
1125
  : undefined;
@@ -1020,22 +1128,7 @@ function wrunTapePrintUnvalued(intake, context, intervalMs, data) {
1020
1128
  else
1021
1129
  intake.tapeLost.add(bucket);
1022
1130
  }
1023
- /** The large-print table's floor at the tape enqueue (the fold applies it again): on the large
1024
- * lane, a print under the table's floor (`tradesBelowLargeFloor`: a dollar-quoted market's notional,
1025
- * a CME Group root's contracts, an option book's premium; the frame's envelope names the market,
1026
- * else the chart's). */
1027
- function wrunTapePrintBelowLargeFloor(context, data) {
1028
- if (context.acquisition.tape?.large !== true)
1029
- return false;
1030
- const print = readLiveTradePrint(data);
1031
- return (print !== null && tradesBelowLargeFloor(print, context.market ? largeFloorMarketOf(context.market) : undefined));
1032
- }
1033
- /** Whether a reconcile can restore the tape prints the queue cap dropped: the large lane with a
1034
- * history to re-ask (not the live edge, history "0") on a market the re-ask answers under the
1035
- * acquisition's floor (`tradesLargeHistoryAnswers`, the lane rule `tradesLaneLimits` the request
1036
- * builder reads: the table on a dollar quote, the raw tape on a CME Group root the table skips under
1037
- * a size floor and never under a dollar floor, which that lane serves no history to; a context that
1038
- * names no normalized symbol is assumed held). */
1131
+ /** Every live row is also in the large-print table, so any large tape with a history can restore dropped rows. */
1039
1132
  function wrunTapeLostRestorable(context) {
1040
1133
  const acquisition = context.acquisition.tape;
1041
1134
  if (acquisition?.large !== true)
@@ -1048,21 +1141,25 @@ function wrunTapeLostRestorable(context) {
1048
1141
  catch {
1049
1142
  // The full run validated the history; a malformed record reads as the live edge.
1050
1143
  }
1051
- return historySec > 0 && tradesLargeHistoryAnswers(context.market ?? {}, { minValue: acquisition.minValue });
1144
+ return historySec > 0;
1052
1145
  }
1053
- function pushAdditive(intake, lane, point) {
1146
+ function pushAdditive(intake, lane, point, tapeContext) {
1054
1147
  let queue = intake.additive[lane];
1055
1148
  if (!queue) {
1056
1149
  queue = { points: [], head: 0 };
1057
1150
  intake.additive[lane] = queue;
1058
1151
  }
1059
1152
  const dropped = pushBoundedQueue(intake, queue, point);
1060
- // A tape print the cap dropped leaves its bar's block a print short: its bucket is owed a repair
1061
- // (the drain marks it for the reconcile, or the tick refuses it by name).
1153
+ // A tape print the cap dropped leaves its bar's block a print short: its bucket (the bar the fold keys it on,
1154
+ // `wrunTapePrintBarTs` over the lane's market) is owed a repair (the drain marks it for the reconcile, or the tick
1155
+ // refuses it by name).
1062
1156
  if (lane === 'tape' && dropped !== undefined && intake.intervalMs > 0) {
1063
1157
  const print = readLiveTradePrint(dropped);
1064
- if (print !== null)
1065
- intake.tapeLost.add(tradesBarStartMs(print.tsMs, intake.intervalMs, print.exchange));
1158
+ const bucket = print === null
1159
+ ? null
1160
+ : wrunTapePrintBarTs(print, intake.intervalMs, tapeContext && wrunTapeLaneHostBarOf(tapeContext, intake.intervalMs));
1161
+ if (bucket !== null)
1162
+ intake.tapeLost.add(bucket);
1066
1163
  }
1067
1164
  }
1068
1165
  function pushLegPoint(intake, fetchKey, point) {
@@ -1198,6 +1295,8 @@ export function wrunLiveFrameMarketAdmitted(indicatorId, series) {
1198
1295
  incomingSymbol: series.symbol,
1199
1296
  };
1200
1297
  return (!isForeignFrame(context, frame) ||
1298
+ // A lane the run asked on another market (the run market) takes that market's frames (the enqueue judges the lane).
1299
+ pinnedLaneMarketsOf(context).some((pinned) => !isForeignToMarket(pinned, frame)) ||
1201
1300
  gridLegKeysForFrame(context, frame).length > 0 ||
1202
1301
  tradesLegLanesForFrame(context, frame).length > 0 ||
1203
1302
  // A row lane fed by coin takes every contract of its coin (a coin-scoped channel), foreign or not.
@@ -1282,7 +1381,14 @@ export function enqueueWrunLiveFrame(a) {
1282
1381
  return 'queued';
1283
1382
  }
1284
1383
  const lane = WRUN_LIVE_LANE_OF_SCRIPT_SOURCE[a.frame.scriptSource];
1285
- const foreign = isForeignFrame(context, a.frame);
1384
+ // Each push lane takes the frames of the market its acquisition names (the run market), else the chart's own.
1385
+ const candidates = lane !== undefined && lane !== 'ohlcv' && WRUN_PUSH_LANES.has(lane) ? frameLanesOf(context, lane) : [];
1386
+ const takers = candidates.filter((fedLane) => {
1387
+ const pinned = pinnedLaneMarketOf(context, fedLane);
1388
+ return pinned ? !isForeignToMarket(pinned, a.frame) : !isForeignFrame(context, a.frame);
1389
+ });
1390
+ // A frame no lane could take is judged against the chart's market, as before.
1391
+ const foreign = candidates.length > 0 ? takers.length === 0 : isForeignFrame(context, a.frame);
1286
1392
  // A candle frame of a declared grid leg's market is that leg's (a pinned
1287
1393
  // market's feed, subscribed for it): admitted by the leg, never by the
1288
1394
  // chart. Every other foreign frame is refused.
@@ -1316,9 +1422,7 @@ export function enqueueWrunLiveFrame(a) {
1316
1422
  }
1317
1423
  if (!context.pushEligible)
1318
1424
  return noteVerdict(a.indicatorId, 'ignored:ineligible', context);
1319
- const fed = WRUN_PUSH_LANES.has(lane)
1320
- ? [...(foreign ? [] : frameLanesOf(context, lane)), ...tradeLegs]
1321
- : [];
1425
+ const fed = WRUN_PUSH_LANES.has(lane) ? [...takers, ...tradeLegs] : [];
1322
1426
  if (fed.length === 0)
1323
1427
  return noteVerdict(a.indicatorId, 'ignored:undeclared', context);
1324
1428
  const intervalMs = context.intervalMs;
@@ -1335,8 +1439,10 @@ export function enqueueWrunLiveFrame(a) {
1335
1439
  else {
1336
1440
  const replay = isRecord(data) && isRecord(data.series) && data.series.isReplay === true;
1337
1441
  const slot = replay ? intake.bookReplay : intake.bookLive;
1338
- for (const row of wrunLiveBookRows(data, intervalMs))
1442
+ // Keyed on the chart market's bar, as the drain folds every lane (`chartMarketOf`).
1443
+ for (const row of wrunLiveBookRows(data, intervalMs, chartMarketOf(context))) {
1339
1444
  slot.set(Number(row[0]), row);
1445
+ }
1340
1446
  }
1341
1447
  }
1342
1448
  else if (lane === 'funding') {
@@ -1346,19 +1452,15 @@ export function enqueueWrunLiveFrame(a) {
1346
1452
  intake.funding.set(bucket, a.frame.data);
1347
1453
  }
1348
1454
  else if (lane === 'tape') {
1349
- // Every raw print that reaches the lane is a tape frame, the ones the floors turn away included:
1350
- // the count is the live leg's own signal, and a floor that turns most of a busy tape away (a 1
1351
- // BTC floor on a perp) must never read as a dead feed. `ignored:below-floor` counts the turned
1352
- // away ones, `queued` what remains.
1455
+ // The router hands every trades source both channels: a print of the other one never counts or takes a slot.
1456
+ const large = context.acquisition.tape?.large === true;
1457
+ if (liveTradeOfPoint(a.frame.data, large) === undefined && liveTradeOfPoint(a.frame.data, !large) !== undefined) {
1458
+ return noteVerdict(a.indicatorId, 'ignored:other-channel', context);
1459
+ }
1460
+ // Counts rows the floor turns away too: a floor that drops most of a busy tape must not read as a dead feed.
1353
1461
  intake.stats.frames.tape = (intake.stats.frames.tape ?? 0) + 1;
1354
- // The tape's own floor (`tradesTapeCellSize`, the rule the fold applies again): a print below the
1355
- // acquisition's minSize, or one whose dollar value is below its minValue, can never fold, so it
1356
- // never takes a slot a qualifying print needs in the capped queue. A dollar tape that cannot value
1357
- // a print at all (C-DOLLAR: no proven dollar unit) folds none, recorded once by name. The
1358
- // large-print table's own floor too: a print under it (a dollar-quoted market's notional, a CME
1359
- // Group root's contracts) would fold live and vanish when the next reconcile answers the bucket
1360
- // from the table.
1361
- const floor = wrunTapeLiveFloorOf(context.acquisition.tape, context.market);
1462
+ // Floors at the door as the fold does, so a row that can never fold never crowds a qualifying one out of the queue.
1463
+ const floor = wrunTapeLiveFloorOf(context.acquisition.tape, chartMarketOf(context));
1362
1464
  if (!tradesTapeFloorValuesPrints(floor)) {
1363
1465
  noteWrunTapeUnvalued(a.indicatorId, context);
1364
1466
  wrunTapePrintUnvalued(intake, context, intervalMs, a.frame.data);
@@ -1366,16 +1468,15 @@ export function enqueueWrunLiveFrame(a) {
1366
1468
  }
1367
1469
  // A frame the fold cannot read as a print (no side, a bad stamp) is judged by its raw amount under a
1368
1470
  // size floor, as it always was, and never folds under a dollar floor.
1369
- const print = readLiveTradePrint(a.frame.data);
1471
+ const print = readLiveTradePrint(a.frame.data, large);
1370
1472
  const minSize = Number(floor.minSize);
1371
1473
  const belowTapeFloor = print === null
1372
1474
  ? floor.minValue !== undefined ||
1373
1475
  v2LiveTradePrintBelowFloor(a.frame.data, Number.isFinite(minSize) ? minSize : 0)
1374
1476
  : tradesTapeCellSize(print, floor) === null;
1375
- if (belowTapeFloor || wrunTapePrintBelowLargeFloor(context, a.frame.data)) {
1477
+ if (belowTapeFloor)
1376
1478
  return noteVerdict(a.indicatorId, 'ignored:below-floor', context);
1377
- }
1378
- pushAdditive(intake, 'tape', a.frame.data);
1479
+ pushAdditive(intake, 'tape', a.frame.data, context);
1379
1480
  return 'queued';
1380
1481
  }
1381
1482
  else {
@@ -1511,13 +1612,15 @@ export function drainWrunLiveIntake(ctx) {
1511
1612
  intake.funding = new Map();
1512
1613
  }
1513
1614
  let dirtyFromTs = null;
1514
- // Every lane fetched the chart's own market; a grid leg its own.
1615
+ // Every lane folds on the chart's own bars (a grid leg on its own), its rows from its acquisition's market.
1515
1616
  const chartMarket = chartMarketOf(ctx);
1516
1617
  for (const [lane, points] of batches) {
1517
1618
  // A trades leg folds on its own grid at its own tier (the interval its history was asked at), as its history
1518
1619
  // rows sit; every other lane at the chart's interval.
1519
1620
  const foldIntervalMs = laneFoldIntervalMs(ctx, lane, ctx.intervalMs);
1520
- const folded = foldWrunLaneRows(lane, laneRowsOf(ctx, lane), points, foldIntervalMs, ctx.acquisition[lane] ?? {}, isWrunTradesLegLane(lane) ? tradesLegBucketMarket(ctx, lane) : chartMarket);
1621
+ const folded = foldWrunLaneRows(lane, laneRowsOf(ctx, lane), points, foldIntervalMs, ctx.acquisition[lane] ?? {}, isWrunTradesLegLane(lane) ? tradesLegBucketMarket(ctx, lane) : chartMarket,
1622
+ // The lane's rows came from the run market: the tape's host bars read it over the chart's bars.
1623
+ pinnedLaneMarketOf(ctx, lane) ?? chartMarket);
1521
1624
  result.points[lane] = points.length;
1522
1625
  if (!folded)
1523
1626
  continue;
@@ -1543,11 +1646,7 @@ export function drainWrunLiveIntake(ctx) {
1543
1646
  }
1544
1647
  }
1545
1648
  if (intake.tapeLost.size > 0) {
1546
- // Tape prints the queue cap dropped: their bars' blocks are short. When the large-print table
1547
- // holds what the live floors keep, the buckets stay fed (the reconcile window reaches back to
1548
- // them) and `tape-lost` re-asks them before this drain computes: the answer's union restores
1549
- // the prints. A live-edge tape (history "0") or a market the table never holds has nothing to
1550
- // restore them from: the tick refuses the bucket by name instead (`tapeLostBuckets`).
1649
+ // Dropped rows leave their bars short: re-asked (`tape-lost`) before this drain computes, else refused by name.
1551
1650
  const lost = [...intake.tapeLost].sort((x, y) => x - y);
1552
1651
  intake.tapeLost = new Set();
1553
1652
  result.tapeLost = lost;
@@ -1598,8 +1697,10 @@ export function drainWrunLiveIntake(ctx) {
1598
1697
  // when that bar is committed, from that bar. A row no chart bar holds (off the chart's session) revises none.
1599
1698
  const legMs = legRecord?.tierMs ?? legRecord?.legMs ?? ctx.intervalMs;
1600
1699
  const barOf = hostBucketResolverFor(ctx.intervalMs, liveBucketVenueOf(ctx.market));
1700
+ // The leg's own grid: a session's stub row lasts to its close (wrunLegRowHostBar's `rowVenue`).
1701
+ const legVenue = legMarketOfKey(ctx, key);
1601
1702
  for (const bucket of folded.touched) {
1602
- const bar = wrunLegRowHostBar(bucket, legMs, barOf);
1703
+ const bar = wrunLegRowHostBar(bucket, legMs, barOf, legVenue);
1603
1704
  if (bar !== null && bar < ctx.lastRowTs && (dirtyFromTs === null || bar < dirtyFromTs))
1604
1705
  dirtyFromTs = bar;
1605
1706
  }
@@ -1743,11 +1844,26 @@ export function dropWrunLiveQueuedBuckets(indicatorId, lane, buckets) {
1743
1844
  const drop = new Set(buckets);
1744
1845
  let dropped = 0;
1745
1846
  if (lane === 'book') {
1746
- for (const bucket of drop) {
1747
- if (intake.bookLive.delete(bucket))
1748
- dropped += 1;
1749
- if (intake.bookReplay.delete(bucket))
1750
- dropped += 1;
1847
+ // A queued row is keyed on its own bar and folds onto the host bar the chart's history puts it in
1848
+ // (`wrunBookRowHostBarResolver`), the bar an answer names: the row a covered bar would take is dropped.
1849
+ const bookContext = getWrunOverlayLiveContext(indicatorId);
1850
+ const barOf = bookContext ? wrunBookRowHostBarResolver(intake.intervalMs, chartMarketOf(bookContext)) : undefined;
1851
+ if (barOf === undefined) {
1852
+ for (const bucket of drop) {
1853
+ if (intake.bookLive.delete(bucket))
1854
+ dropped += 1;
1855
+ if (intake.bookReplay.delete(bucket))
1856
+ dropped += 1;
1857
+ }
1858
+ return dropped;
1859
+ }
1860
+ const nowMs = serverNowMs();
1861
+ for (const slot of [intake.bookLive, intake.bookReplay]) {
1862
+ for (const key of [...slot.keys()]) {
1863
+ const bar = barOf(key, nowMs);
1864
+ if (bar !== null && drop.has(bar) && slot.delete(key))
1865
+ dropped += 1;
1866
+ }
1751
1867
  }
1752
1868
  return dropped;
1753
1869
  }
@@ -1800,11 +1916,12 @@ export function dropWrunLiveQueuedBuckets(indicatorId, lane, buckets) {
1800
1916
  const market = context ? (leg ? tradesLegBucketMarket(context, lane) : chartMarketOf(context)) : null;
1801
1917
  const bucketLane = leg ? wrunTradesLegOf(lane).lane : lane;
1802
1918
  const bucketIntervalMs = context ? laneFoldIntervalMs(context, lane, intake.intervalMs) : intake.intervalMs;
1919
+ const tapeHostBarOf = lane === 'tape' && context ? wrunTapeLaneHostBarOf(context, intake.intervalMs) : undefined;
1803
1920
  const bucketOf = (point) => {
1804
1921
  if (lane === 'tape') {
1805
- // A raw print's stamp and venue as the tape fold reads them (seconds plus nanoseconds).
1922
+ // A print's stamp and venue as the tape fold reads them (seconds plus nanoseconds), on the bar the fold keys.
1806
1923
  const print = readLiveTradePrint(point);
1807
- return print === null ? null : tradesBarStartMs(print.tsMs, intake.intervalMs, print.exchange);
1924
+ return print === null ? null : wrunTapePrintBarTs(print, intake.intervalMs, tapeHostBarOf);
1808
1925
  }
1809
1926
  if (!isRecord(point))
1810
1927
  return null;