@orangecharts/wrun-chart-host 0.4.0 → 0.5.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 (322) hide show
  1. package/README.md +15 -4
  2. package/dist/constants/exchange-names.leaf.d.ts +8 -0
  3. package/dist/constants/exchange-names.leaf.js +101 -0
  4. package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +15 -0
  5. package/dist/constants/kscript-data-interval-restrictions.constants.js +40 -0
  6. package/dist/constants/opra-compliance.constants.d.ts +19 -0
  7. package/dist/constants/opra-compliance.constants.js +19 -0
  8. package/dist/constants/replay-ladder.leaf.d.ts +30 -0
  9. package/dist/constants/replay-ladder.leaf.js +99 -0
  10. package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +168 -0
  11. package/dist/constants/scriptEditor/cme-official-scripts.constants.js +398 -0
  12. package/dist/constants/scriptEditor/converted-script-id.leaf.d.ts +8 -0
  13. package/dist/constants/scriptEditor/converted-script-id.leaf.js +10 -0
  14. package/dist/constants/scriptEditor/execution.constants.d.ts +4 -0
  15. package/dist/constants/scriptEditor/execution.constants.js +14 -0
  16. package/dist/constants/wrun-prefix-safe.constants.d.ts +23 -0
  17. package/dist/constants/wrun-prefix-safe.constants.js +26 -0
  18. package/dist/host-env.d.ts +313 -18
  19. package/dist/host-env.js +15 -0
  20. package/dist/host-ports.types.d.ts +853 -16
  21. package/dist/index.d.ts +139 -2
  22. package/dist/index.js +139 -2
  23. package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +31 -0
  24. package/dist/instances/script-engine-worker-ohlcv-transfer.js +164 -0
  25. package/dist/interfaces/market-event.interface.d.ts +231 -0
  26. package/dist/interfaces/market-event.interface.js +15 -0
  27. package/dist/interfaces/opra-realtime.interface.d.ts +70 -134
  28. package/dist/interfaces/opra-realtime.interface.js +34 -59
  29. package/dist/interfaces/replay.interface.d.ts +285 -0
  30. package/dist/interfaces/replay.interface.js +1 -0
  31. package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +1 -0
  32. package/dist/kscript-data/controls/live-ohlcv-merge.util.js +93 -0
  33. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +5 -1
  34. package/dist/kscript-data/controls/live-trades-merge.util.js +2 -2
  35. package/dist/market-data/billing.interface.d.ts +219 -0
  36. package/dist/market-data/billing.interface.js +58 -0
  37. package/dist/market-data/venue-governed.util.d.ts +2 -0
  38. package/dist/market-data/venue-governed.util.js +10 -0
  39. package/dist/market-data/venue.d.ts +122 -0
  40. package/dist/market-data/venue.js +1 -0
  41. package/dist/market-data/venues/index.d.ts +97 -0
  42. package/dist/market-data/venues/index.js +33 -0
  43. package/dist/market-data/venues/opra.contract.copy.json +35 -0
  44. package/dist/market-data/venues/opra.d.ts +70 -0
  45. package/dist/market-data/venues/opra.js +74 -0
  46. package/dist/replay/replayIndicatorRows.d.ts +31 -0
  47. package/dist/replay/replayIndicatorRows.js +117 -0
  48. package/dist/replay/replayLadder.d.ts +85 -0
  49. package/dist/replay/replayLadder.js +388 -0
  50. package/dist/utility/auth/server-clock.util.d.ts +81 -0
  51. package/dist/utility/auth/server-clock.util.js +238 -0
  52. package/dist/utility/chart/builtin-identity.util.d.ts +18 -0
  53. package/dist/utility/chart/builtin-identity.util.js +51 -0
  54. package/dist/utility/chart/cache-alignment.util.d.ts +454 -0
  55. package/dist/utility/chart/cache-alignment.util.js +926 -0
  56. package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +15 -0
  57. package/dist/utility/chart/chart-data-fetch-generation.util.js +22 -0
  58. package/dist/utility/chart/chart-mount-epoch.util.d.ts +5 -0
  59. package/dist/utility/chart/chart-mount-epoch.util.js +29 -0
  60. package/dist/utility/chart/chart-time-domain.util.d.ts +12 -0
  61. package/dist/utility/chart/chart-time-domain.util.js +23 -0
  62. package/dist/utility/chart/color-customization.leaf.d.ts +10 -0
  63. package/dist/utility/chart/color-customization.leaf.js +16 -0
  64. package/dist/utility/chart/footprint-tick-grid.util.d.ts +106 -0
  65. package/dist/utility/chart/footprint-tick-grid.util.js +167 -0
  66. package/dist/utility/chart/gesture-timing.leaf.d.ts +29 -0
  67. package/dist/utility/chart/gesture-timing.leaf.js +29 -0
  68. package/dist/utility/chart/governed-contract-coin.util.d.ts +22 -0
  69. package/dist/utility/chart/governed-contract-coin.util.js +39 -0
  70. package/dist/utility/chart/host-bar-placement.util.d.ts +107 -0
  71. package/dist/utility/chart/host-bar-placement.util.js +447 -0
  72. package/dist/utility/chart/index-host-tier.util.d.ts +31 -0
  73. package/dist/utility/chart/index-host-tier.util.js +118 -0
  74. package/dist/utility/chart/index-mode-admission.util.d.ts +34 -0
  75. package/dist/utility/chart/index-mode-admission.util.js +67 -0
  76. package/dist/utility/chart/indicator-error-message.util.d.ts +35 -0
  77. package/dist/utility/chart/indicator-error-message.util.js +44 -0
  78. package/dist/utility/chart/kscript-apply-fingerprint.util.d.ts +65 -0
  79. package/dist/utility/chart/kscript-apply-fingerprint.util.js +357 -0
  80. package/dist/utility/chart/kscript-chart-flush.leaf.d.ts +22 -0
  81. package/dist/utility/chart/kscript-chart-flush.leaf.js +13 -0
  82. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +6 -0
  83. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +27 -0
  84. package/dist/utility/chart/kscript-integration-decision.leaf.d.ts +89 -0
  85. package/dist/utility/chart/kscript-integration-decision.leaf.js +80 -0
  86. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +76 -0
  87. package/dist/utility/chart/kscript-live-coalesce.util.js +156 -0
  88. package/dist/utility/chart/kscript-live-rest-pace.util.d.ts +34 -0
  89. package/dist/utility/chart/kscript-live-rest-pace.util.js +134 -0
  90. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +98 -0
  91. package/dist/utility/chart/kscript-live-source-identity.util.js +121 -0
  92. package/dist/utility/chart/kscript-mounted-plot-set.leaf.d.ts +48 -0
  93. package/dist/utility/chart/kscript-mounted-plot-set.leaf.js +145 -0
  94. package/dist/utility/chart/kscript-perf-tracker.util.d.ts +243 -0
  95. package/dist/utility/chart/kscript-perf-tracker.util.js +522 -0
  96. package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +43 -0
  97. package/dist/utility/chart/kscript-run-interval-projection.util.js +471 -0
  98. package/dist/utility/chart/kscript-run-result-equality.util.d.ts +38 -0
  99. package/dist/utility/chart/kscript-run-result-equality.util.js +89 -0
  100. package/dist/utility/chart/kscript-settings-revision.leaf.d.ts +2 -0
  101. package/dist/utility/chart/kscript-settings-revision.leaf.js +12 -0
  102. package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +63 -0
  103. package/dist/utility/chart/kscript-source-degrade.leaf.js +68 -0
  104. package/dist/utility/chart/kscript-source-retention.util.d.ts +134 -0
  105. package/dist/utility/chart/kscript-source-retention.util.js +218 -0
  106. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +57 -0
  107. package/dist/utility/chart/kscript-standin-identity.leaf.js +61 -0
  108. package/dist/utility/chart/kscript-titancharts-preparation.util.d.ts +15 -0
  109. package/dist/utility/chart/kscript-titancharts-preparation.util.js +376 -0
  110. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +9 -0
  111. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +130 -0
  112. package/dist/utility/chart/kscript-venue-policy.util.d.ts +217 -0
  113. package/dist/utility/chart/kscript-venue-policy.util.js +324 -0
  114. package/dist/utility/chart/live-cadence.util.d.ts +38 -0
  115. package/dist/utility/chart/live-cadence.util.js +37 -0
  116. package/dist/utility/chart/live-feed-series-match.leaf.d.ts +13 -0
  117. package/dist/utility/chart/live-feed-series-match.leaf.js +21 -0
  118. package/dist/utility/chart/local-engine-self-heal-backoff.util.d.ts +46 -0
  119. package/dist/utility/chart/local-engine-self-heal-backoff.util.js +46 -0
  120. package/dist/utility/chart/local-engine-uninit.leaf.d.ts +21 -0
  121. package/dist/utility/chart/local-engine-uninit.leaf.js +22 -0
  122. package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +62 -0
  123. package/dist/utility/chart/local-kscript-source-revalidation.util.js +123 -0
  124. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +214 -0
  125. package/dist/utility/chart/local-kscript-warmup-depth.util.js +376 -0
  126. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.d.ts +85 -0
  127. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.js +197 -0
  128. package/dist/utility/chart/local-technical-script-range.leaf.d.ts +72 -0
  129. package/dist/utility/chart/local-technical-script-range.leaf.js +126 -0
  130. package/dist/utility/chart/mixed-mode.util.d.ts +167 -0
  131. package/dist/utility/chart/mixed-mode.util.js +139 -0
  132. package/dist/utility/chart/ohlcv-row-readiness.util.d.ts +36 -0
  133. package/dist/utility/chart/ohlcv-row-readiness.util.js +90 -0
  134. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +19 -0
  135. package/dist/utility/chart/opra-user-scripts-gate.util.js +32 -0
  136. package/dist/utility/chart/overlay-execution-guard-key.leaf.d.ts +8 -0
  137. package/dist/utility/chart/overlay-execution-guard-key.leaf.js +10 -0
  138. package/dist/utility/chart/price-precision.util.d.ts +40 -0
  139. package/dist/utility/chart/price-precision.util.js +70 -0
  140. package/dist/utility/chart/profile-block-size.util.d.ts +64 -0
  141. package/dist/utility/chart/profile-block-size.util.js +141 -0
  142. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.d.ts +11 -0
  143. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.js +29 -0
  144. package/dist/utility/chart/protected-kscript-empty-output.util.d.ts +28 -0
  145. package/dist/utility/chart/protected-kscript-empty-output.util.js +84 -0
  146. package/dist/utility/chart/run-interval-unservable.leaf.d.ts +9 -0
  147. package/dist/utility/chart/run-interval-unservable.leaf.js +20 -0
  148. package/dist/utility/chart/run-interval-warmup.leaf.d.ts +19 -0
  149. package/dist/utility/chart/run-interval-warmup.leaf.js +35 -0
  150. package/dist/utility/chart/titan-constants.pin.d.ts +9 -5
  151. package/dist/utility/chart/titan-constants.pin.js +18 -5
  152. package/dist/utility/chart/warmup-backfill-retry.leaf.d.ts +9 -0
  153. package/dist/utility/chart/warmup-backfill-retry.leaf.js +9 -0
  154. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +11 -2
  155. package/dist/utility/chart/wrun-bar-session-facts.util.js +10 -3
  156. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -1
  157. package/dist/utility/chart/wrun-run-result.util.js +20 -14
  158. package/dist/utility/common/data-processing.util.d.ts +138 -0
  159. package/dist/utility/common/data-processing.util.js +346 -0
  160. package/dist/utility/common/visible-timeout.util.d.ts +13 -4
  161. package/dist/utility/common/visible-timeout.util.js +23 -8
  162. package/dist/utility/exchange-format.leaf.d.ts +1 -0
  163. package/dist/utility/exchange-format.leaf.js +47 -0
  164. package/dist/utility/market-events/earnings-scope.util.d.ts +60 -0
  165. package/dist/utility/market-events/earnings-scope.util.js +92 -0
  166. package/dist/utility/market-events/market-events.util.d.ts +147 -0
  167. package/dist/utility/market-events/market-events.util.js +392 -0
  168. package/dist/utility/market-events/zoned-clock.util.d.ts +1 -0
  169. package/dist/utility/market-events/zoned-clock.util.js +11 -0
  170. package/dist/utility/options/option-venue-disclosure.util.d.ts +43 -0
  171. package/dist/utility/options/option-venue-disclosure.util.js +56 -0
  172. package/dist/utility/scriptEditor/package-semver.util.d.ts +51 -0
  173. package/dist/utility/scriptEditor/package-semver.util.js +120 -0
  174. package/dist/utility/scriptEditor/temp-script-id.util.d.ts +18 -0
  175. package/dist/utility/scriptEditor/temp-script-id.util.js +25 -0
  176. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.d.ts +20 -0
  177. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.js +81 -0
  178. package/dist/utility/v2/governed-tier.leaf.d.ts +103 -0
  179. package/dist/utility/v2/governed-tier.leaf.js +113 -0
  180. package/dist/utility/watchlist/import/import-request.leaf.d.ts +10 -0
  181. package/dist/utility/watchlist/import/import-request.leaf.js +10 -0
  182. package/dist/utility/wrun/sources/lanes/series.js +2 -2
  183. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +4 -4
  184. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +5 -6
  185. package/dist/utility/wrun/wrun-alert-outputs.registry.d.ts +166 -0
  186. package/dist/utility/wrun/wrun-alert-outputs.registry.js +219 -0
  187. package/dist/utility/wrun/wrun-bar-count.util.d.ts +83 -0
  188. package/dist/utility/wrun/wrun-bar-count.util.js +259 -0
  189. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +84 -0
  190. package/dist/utility/wrun/wrun-chart-context-names.util.js +186 -0
  191. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +253 -0
  192. package/dist/utility/wrun/wrun-chart-market-facts.util.js +731 -0
  193. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.d.ts +28 -0
  194. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.js +45 -0
  195. package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +18 -0
  196. package/dist/utility/wrun/wrun-coin-lane-live.util.js +47 -0
  197. package/dist/utility/wrun/wrun-deadline.util.js +2 -1
  198. package/dist/utility/wrun/wrun-debug-output.util.d.ts +39 -0
  199. package/dist/utility/wrun/wrun-debug-output.util.js +63 -0
  200. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +113 -0
  201. package/dist/utility/wrun/wrun-declared-warmup.util.js +181 -0
  202. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +43 -0
  203. package/dist/utility/wrun/wrun-draft-legend-note.util.js +158 -0
  204. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +181 -0
  205. package/dist/utility/wrun/wrun-draft-overlay.util.js +357 -0
  206. package/dist/utility/wrun/wrun-draw-skipped.leaf.d.ts +16 -0
  207. package/dist/utility/wrun/wrun-draw-skipped.leaf.js +16 -0
  208. package/dist/utility/wrun/wrun-earnings-facts.util.d.ts +42 -0
  209. package/dist/utility/wrun/wrun-earnings-facts.util.js +131 -0
  210. package/dist/utility/wrun/wrun-first-run-depth.util.d.ts +32 -0
  211. package/dist/utility/wrun/wrun-first-run-depth.util.js +118 -0
  212. package/dist/utility/wrun/wrun-gate-plane-readers.util.d.ts +24 -0
  213. package/dist/utility/wrun/wrun-gate-plane-readers.util.js +31 -0
  214. package/dist/utility/wrun/wrun-held-lanes.util.d.ts +32 -0
  215. package/dist/utility/wrun/wrun-held-lanes.util.js +94 -0
  216. package/dist/utility/wrun/wrun-host-visible-clock.util.d.ts +2 -0
  217. package/dist/utility/wrun/wrun-host-visible-clock.util.js +17 -0
  218. package/dist/utility/wrun/wrun-host.service.d.ts +266 -0
  219. package/dist/utility/wrun/wrun-host.service.js +655 -0
  220. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +33 -0
  221. package/dist/utility/wrun/wrun-inert-legend.util.js +125 -0
  222. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +155 -0
  223. package/dist/utility/wrun/wrun-input-requirements.leaf.js +450 -0
  224. package/dist/utility/wrun/wrun-integration-route.util.d.ts +51 -0
  225. package/dist/utility/wrun/wrun-integration-route.util.js +59 -0
  226. package/dist/utility/wrun/wrun-latest-history.leaf.d.ts +8 -0
  227. package/dist/utility/wrun/wrun-latest-history.leaf.js +8 -0
  228. package/dist/utility/wrun/wrun-legend-hover.lazy.d.ts +12 -0
  229. package/dist/utility/wrun/wrun-legend-hover.lazy.js +96 -0
  230. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +21 -0
  231. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +21 -0
  232. package/dist/utility/wrun/wrun-live-hidden-hold.util.d.ts +23 -0
  233. package/dist/utility/wrun/wrun-live-hidden-hold.util.js +13 -0
  234. package/dist/utility/wrun/wrun-live-intake.util.d.ts +374 -0
  235. package/dist/utility/wrun/wrun-live-intake.util.js +2027 -0
  236. package/dist/utility/wrun/wrun-live-patch.util.d.ts +116 -0
  237. package/dist/utility/wrun/wrun-live-patch.util.js +523 -0
  238. package/dist/utility/wrun/wrun-live-tick.util.d.ts +619 -0
  239. package/dist/utility/wrun/wrun-live-tick.util.js +4974 -0
  240. package/dist/utility/wrun/wrun-loading-owner.util.d.ts +58 -0
  241. package/dist/utility/wrun/wrun-loading-owner.util.js +89 -0
  242. package/dist/utility/wrun/wrun-official-scope.leaf.d.ts +29 -0
  243. package/dist/utility/wrun/wrun-official-scope.leaf.js +36 -0
  244. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +27 -0
  245. package/dist/utility/wrun/wrun-oi-lane.util.js +42 -0
  246. package/dist/utility/wrun/wrun-options-stop.util.d.ts +52 -0
  247. package/dist/utility/wrun/wrun-options-stop.util.js +123 -0
  248. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +719 -0
  249. package/dist/utility/wrun/wrun-overlay-drivers.util.js +1180 -0
  250. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +50 -0
  251. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +131 -0
  252. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +118 -0
  253. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +466 -0
  254. package/dist/utility/wrun/wrun-overlay-metadata.util.d.ts +45 -0
  255. package/dist/utility/wrun/wrun-overlay-metadata.util.js +112 -0
  256. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +114 -0
  257. package/dist/utility/wrun/wrun-overlay-recovery.util.js +971 -0
  258. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +858 -0
  259. package/dist/utility/wrun/wrun-overlay-run.util.js +11013 -0
  260. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +24 -9
  261. package/dist/utility/wrun/wrun-panel-mount.util.js +138 -43
  262. package/dist/utility/wrun/wrun-param-map.util.d.ts +19 -4
  263. package/dist/utility/wrun/wrun-param-map.util.js +40 -47
  264. package/dist/utility/wrun/wrun-param-values.util.d.ts +9 -3
  265. package/dist/utility/wrun/wrun-param-values.util.js +5 -5
  266. package/dist/utility/wrun/wrun-prefix-cohort.util.d.ts +93 -0
  267. package/dist/utility/wrun/wrun-prefix-cohort.util.js +484 -0
  268. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +114 -0
  269. package/dist/utility/wrun/wrun-prefix-lanes.util.js +486 -0
  270. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +317 -0
  271. package/dist/utility/wrun/wrun-prefix-proof.util.js +630 -0
  272. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +73 -0
  273. package/dist/utility/wrun/wrun-refusal-surface.util.js +380 -0
  274. package/dist/utility/wrun/wrun-refusal-text.util.d.ts +15 -0
  275. package/dist/utility/wrun/wrun-refusal-text.util.js +40 -0
  276. package/dist/utility/wrun/wrun-replay-lane.util.d.ts +139 -0
  277. package/dist/utility/wrun/wrun-replay-lane.util.js +520 -0
  278. package/dist/utility/wrun/wrun-replay-rows.util.d.ts +21 -0
  279. package/dist/utility/wrun/wrun-replay-rows.util.js +172 -0
  280. package/dist/utility/wrun/wrun-row-source-factory.d.ts +53 -0
  281. package/dist/utility/wrun/wrun-row-source-factory.js +435 -0
  282. package/dist/utility/wrun/wrun-run-cells.util.d.ts +36 -0
  283. package/dist/utility/wrun/wrun-run-cells.util.js +46 -0
  284. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +133 -0
  285. package/dist/utility/wrun/wrun-run-interval-session.util.js +121 -0
  286. package/dist/utility/wrun/wrun-run-interval.util.d.ts +98 -0
  287. package/dist/utility/wrun/wrun-run-interval.util.js +207 -0
  288. package/dist/utility/wrun/wrun-run-retained.util.d.ts +122 -0
  289. package/dist/utility/wrun/wrun-run-retained.util.js +255 -0
  290. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +184 -0
  291. package/dist/utility/wrun/wrun-sandbox-row-source.js +444 -0
  292. package/dist/utility/wrun/wrun-script-inputs.util.js +4 -4
  293. package/dist/utility/wrun/wrun-series-stream.util.d.ts +86 -0
  294. package/dist/utility/wrun/wrun-series-stream.util.js +537 -0
  295. package/dist/utility/wrun/wrun-sheet-remembered.util.d.ts +21 -0
  296. package/dist/utility/wrun/wrun-sheet-remembered.util.js +36 -0
  297. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.d.ts +7 -0
  298. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.js +12 -0
  299. package/dist/utility/wrun/wrun-socket-row-source.js +4 -2
  300. package/dist/utility/wrun/wrun-source-rows.util.d.ts +175 -3
  301. package/dist/utility/wrun/wrun-source-rows.util.js +294 -8
  302. package/dist/utility/wrun/wrun-stats-strip.util.d.ts +46 -0
  303. package/dist/utility/wrun/wrun-stats-strip.util.js +87 -0
  304. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +163 -0
  305. package/dist/utility/wrun/wrun-table-chrome.util.js +557 -0
  306. package/dist/utility/wrun/wrun-text-params.util.d.ts +11 -6
  307. package/dist/utility/wrun/wrun-text-params.util.js +19 -30
  308. package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +64 -0
  309. package/dist/utility/wrun/wrun-transient-rerun.util.js +317 -0
  310. package/dist/utility/wrun/wrun-twin-lookback.util.d.ts +10 -0
  311. package/dist/utility/wrun/wrun-twin-lookback.util.js +43 -0
  312. package/dist/utility/wrun/wrun-warmup-head-store.util.d.ts +41 -0
  313. package/dist/utility/wrun/wrun-warmup-head-store.util.js +120 -0
  314. package/dist/utility/wrun-alert-params.leaf.d.ts +24 -0
  315. package/dist/utility/wrun-alert-params.leaf.js +24 -0
  316. package/dist/utils/replay/replay-buffer-math.d.ts +148 -0
  317. package/dist/utils/replay/replay-buffer-math.js +684 -0
  318. package/dist/workers/wrun/wrun-abi-host.d.ts +190 -0
  319. package/dist/workers/wrun/wrun-abi-host.js +1201 -0
  320. package/dist/workers/wrun/wrun-engine-handler.d.ts +37 -0
  321. package/dist/workers/wrun/wrun-engine-handler.js +211 -0
  322. package/package.json +3 -3
@@ -342,14 +342,16 @@
342
342
  * tail build gives the same answer.
343
343
  */
344
344
  import { type WrunPinnedInterval } from './wrun-pinned-interval.util.js';
345
+ import type { LiveBucketVenue } from '../chart/live-bucket.util.js';
345
346
  import { type WrunBarVenue } from '../chart/wrun-bar-session-facts.util.js';
346
347
  import type { WrunIndicatorMetadata, WrunInputSource, WrunInputView, WrunMetadataParam } from '../../interfaces/wrun-runtime.interface.js';
347
348
  import type { WrunInputCarry as WrunHostInputCarry, WrunLegRowBounds } from '@orangecharts/indicator-kit/host';
348
349
  import type { WrunPollLaneInstance } from './sources/wrun-poll-lane.types.js';
349
350
  import type { WrunRowLaneInstance } from './sources/wrun-row-lane.types.js';
351
+ import { type WrunTradesLane } from './wrun-trades-lane.util.js';
350
352
  import { type WrunSourceBlendField } from './wrun-market-facts.util.js';
351
353
  import type { WrunInputRow } from './wrun-pack.util.js';
352
- import { type WrunLegStreamLane } from './wrun-leg-stream-classes.js';
354
+ import { type WrunLaneStreamClassName, type WrunLegStreamLane } from './wrun-leg-stream-classes.js';
353
355
  /** True for the derived ohlcv fields, the blends hl2 / hlc3 / ohlc4 / hlcc4
354
356
  * (the `param.source` menu's words no candle stores, WRUN-GAPS-1005): any
355
357
  * ohlcv input may read one, as its declared field, a source default or a
@@ -456,9 +458,14 @@ export interface WrunChartSourceRows {
456
458
  * read by the trades inputs that ask `currency: "USD"` (wrunSourceLane
457
459
  * `trades_usd`); optional when none does. */
458
460
  buySellVolumeUsdRows?: ReadonlyArray<ArrayLike<number>>;
459
- /** The trades leg lanes (kit 0.77.0) by leg lane id, [ts, buy, sell] on the leg's market; a leg
460
- * never asked holds none (its inputs read their fill). */
461
+ /** The trades leg lanes (kit 0.77.0) by leg lane id, [ts, buy, sell] on the leg's market at its own interval
462
+ * (`tradeLegIntervals`) and on its own bar grid; a leg never asked holds none (its inputs read their fill). The
463
+ * builder lands each row in the chart bar holding it (`wrunLegRowsOnHostBars`, summed per bar) before the join. */
461
464
  tradeLegRows?: Readonly<Record<string, ReadonlyArray<ArrayLike<number>>>>;
465
+ /** The interval (ms) each trades leg lane's rows ride, by leg lane id: the tier that fits the chart's bars (the
466
+ * lane's acquisition, `wrunLaneAcquisitionIntervalMs`), so every row nests inside one chart bar; a lane without
467
+ * one rides the chart's interval. */
468
+ tradeLegIntervals?: Readonly<Record<string, number>>;
462
469
  /** kScript open_interest lane rows [ts, open, high, low, close]; optional
463
470
  * when no `oi` input is declared. */
464
471
  openInterestRows?: ReadonlyArray<ArrayLike<number>>;
@@ -570,6 +577,15 @@ export interface WrunChartSourceRows {
570
577
  fromTs: number;
571
578
  rows: ReadonlyArray<ArrayLike<number>>;
572
579
  };
580
+ /** The span of the rows a grid leg asked at a tier rides (`WrunPinnedLeg.tierMs`), by the leg's fetch key: the
581
+ * builder lands that leg's rows with it (`wrunLegRowsOnHostBars`), never the leg's own interval. */
582
+ pinnedLegTierMs?: Readonly<Record<string, number>>;
583
+ /** The chart's forming bar while the chart is live: the bar holding the server clock's now on the chart's bar
584
+ * grid (`liveBucketStartMs` over `venue.barGrid`). A grid leg's row still forming past the chart's newest bar
585
+ * lands in the bar holding its open when that bar is this one, so the forming bar reads the leg's latest
586
+ * value (`wrunLegRowsOnHostBars`). Absent or null (a historical chart, a build no live session runs):
587
+ * such a row lands nowhere. */
588
+ formingBarTs?: number | null;
573
589
  /** The chart's series (exchange, symbol and bar interval) the
574
590
  * `time.trade_date` and `time.session` inputs read their facts for
575
591
  * (contract C3, never the chart's RTH/extended mode); required when
@@ -677,7 +693,22 @@ export interface WrunPinnedLeg {
677
693
  * candle leg and every distinct lane identity on the same market and interval is a leg of its own.
678
694
  * Absent: a candle leg (the chart's candle lane). */
679
695
  stream?: WrunLegStreamLane;
696
+ /** Set by the full run on a leg it asked on dataFetch's native-rows path (the leg's rows at their own stamps, never
697
+ * placed on the chart's bars by the fetch): a leg on an index-mode market or chart (`wrunLegRidesNativeRows`), and
698
+ * every leg whose rows straddle the chart's bars, which the row builder places itself (`wrunLegRowsOnHostBars`).
699
+ * The live session's reconcile asks the leg the same way, so its history, its reconciles and its live folds all
700
+ * carry the leg's own stamps. */
701
+ nativeRows?: true;
702
+ /** Set by the full run on a GRID leg asked at a tier finer than the chart's interval (`indexHostFetchTierMs` over
703
+ * the chart's grid and the leg's): its own bars at the chart's interval do not nest in the chart's bars (a 24/7
704
+ * market's 12h bars end at 12:00 and 24:00 UTC, outside every 13:30 to 20:00 UTC session bar of a stock's 12h
705
+ * chart), while its tier rows do. The row builder folds them into the bars holding them by the leg's merge
706
+ * (`pinnedLegTierMs`, `WRUN_LEG_ROW_HOST_MERGE`), so each bar reads the leg's own candle over the bar's span with
707
+ * no look-ahead; the live session folds the leg's frames and asks its reconciles at the same tier. */
708
+ tierMs?: number;
680
709
  }
710
+ /** The tier each grid leg asked at a tier rides (`WrunPinnedLeg.tierMs`), by fetch key: `pinnedLegTierMs`. */
711
+ export declare function wrunPinnedLegTierMs(legs: ReadonlyArray<Pick<WrunPinnedLeg, 'fetchKey' | 'tierMs'>> | undefined): Record<string, number>;
681
712
  /** The fetch-key suffix a leg rides under a caller's prefix: the interval
682
713
  * alone for an own-market period leg (the round-2 shape), the market
683
714
  * appended for a foreign leg, `grid-` / `intrabar-` prefixed by kind,
@@ -794,6 +825,147 @@ export type WrunPinnedWire = {
794
825
  /** View `offset` only: the closed buckets back from the held one (1..500). */
795
826
  offset?: number;
796
827
  };
828
+ /** A leg's row shape, by the lane its rows ride: the chart's candle lane (`ohlcv`: every candle leg, a period, grid
829
+ * or intrabar leg or a `candles` stream), an odds market's candles (`odds`), a lane stream's own lane
830
+ * (`oi_candles`, `volume_profile_candles`) or a trades leg's buy/sell lane (`trades`, `trades_usd`). */
831
+ export type WrunLegRowClass = 'ohlcv' | 'odds' | WrunLaneStreamClassName | WrunTradesLane;
832
+ /**
833
+ * How one chart bar merges the rows of a leg on another bar grid that land in it (`placeRowsInHostBars`), by the
834
+ * leg's row shape: OHLC rows open on the first, span the extremes, close on the last and sum the volume
835
+ * (`candle`); additive rows sum (`flow`); celled rows keep the bar's last row whole (`level`: the flow merge sums
836
+ * numeric columns and has no cell merge). One entry per row class the source layer knows: a class without one
837
+ * fails the typecheck, and wrun-source-rows.grid-legs.spec.ts holds the table to the stream classes and the trades
838
+ * lanes.
839
+ */
840
+ export declare const WRUN_LEG_ROW_HOST_MERGE: Readonly<{
841
+ readonly ohlcv: "candle";
842
+ readonly odds: "candle";
843
+ readonly oi_candles: "candle";
844
+ readonly volume_profile_candles: "level";
845
+ readonly trades: "flow";
846
+ readonly trades_usd: "flow";
847
+ }>;
848
+ /** A pinned leg's row class (`WRUN_LEG_ROW_HOST_MERGE`). */
849
+ export declare function wrunLegRowClassOf(leg: Pick<WrunPinnedLeg, 'odds' | 'stream'>): WrunLegRowClass;
850
+ /**
851
+ * The rows each pinned wire's reader is handed (`wrunHostRunOf`): `host-bars` for a reader the shared host joins on
852
+ * the chart's own rows by timestamp (its exact cursor: a grid leg read row for row), so the leg's rows are first
853
+ * placed in the chart bars that hold them (`wrunLegRowsOnHostBars`), and a leg on another bar grid (a 24/7
854
+ * market's :00 hours under a stock's 09:30-anchored bars) lands; `native` for a reader that meets the chart's rows
855
+ * by a candle's close or its bucket (the confirmed cursor, the forming fold, the candles stream, the intrabar
856
+ * slicer) and reads the leg's own rows; `none` for a wire that reads no leg. A wire kind without an entry fails the
857
+ * typecheck: a new reader says which rows it joins before it reads one.
858
+ */
859
+ export declare const WRUN_PINNED_WIRE_ROWS: Readonly<{
860
+ readonly own_period: "none";
861
+ readonly period: "native";
862
+ readonly forming: "native";
863
+ readonly grid: "host-bars";
864
+ readonly intrabar: "native";
865
+ readonly candles: "native";
866
+ readonly typed: "none";
867
+ }>;
868
+ /** A leg's rows as `wrunLegRowsOnHostBars` lands them: their own span (the leg's interval, a trades leg's tier) and
869
+ * their row class (`WRUN_LEG_ROW_HOST_MERGE`: how one chart bar merges them). */
870
+ export interface WrunLegRowsSpan {
871
+ legMs: number;
872
+ rowClass: WrunLegRowClass;
873
+ }
874
+ /** The interval (ms) a lane's acquisition was asked at (its `interval` word, the payload field the K control asks
875
+ * by), undefined when it names none: a trades leg's tier (`WrunChartSourceRows.tradeLegIntervals`). */
876
+ export declare function wrunLaneAcquisitionIntervalMs(acquisition: Readonly<Record<string, unknown>> | undefined): number | undefined;
877
+ /** Each trades leg lane's row interval (ms) by its acquisition (`wrunLaneAcquisitionIntervalMs`: the tier its ask
878
+ * named, else the interval the fetch stamped on it): `WrunChartSourceRows.tradeLegIntervals`. */
879
+ export declare function wrunTradeLegIntervals(acquisition: Readonly<Record<string, Readonly<Record<string, unknown>> | undefined>>): Record<string, number>;
880
+ /** The backend's cache bucket, in rows of the asked interval: one wire ask of a tiered lane holds at most this many
881
+ * (`wrunWireRowPieces`), the overlays' tiered asks' rule. */
882
+ export declare const WRUN_WIRE_PIECE_ROWS = 250;
883
+ /**
884
+ * `[fromMs, toMs)` as the wire asks of a lane asked at `rowMs` (a trades leg's tier finer than the chart's bars),
885
+ * sized in the rows the wire returns: one piece when the span holds at most `WRUN_WIRE_PIECE_ROWS` rows, else
886
+ * ascending pieces of at most that many, each inner edge on the tier's bucket grid (a multiple of
887
+ * `WRUN_WIRE_PIECE_ROWS * rowMs` from the epoch, so a piece is one backend cache bucket), the first and last
888
+ * partial and the span never widened. A 12h stock chart's window is about a year: at 30m that is 17,520 rows of a
889
+ * 24/7 venue, and asked whole the gateway fails it.
890
+ */
891
+ export declare function wrunWireRowPieces(fromMs: number, toMs: number, rowMs: number): Array<{
892
+ fromMs: number;
893
+ toMs: number;
894
+ }>;
895
+ /** One piece's answer (`wrunAskWirePieces`): its rows, and whether the chart's fetch answered the piece whole
896
+ * (`wrunSourceVerdictWhole`). */
897
+ export interface WrunWirePieceAnswer<Row> {
898
+ rows: ReadonlyArray<Row>;
899
+ whole: boolean;
900
+ }
901
+ /**
902
+ * Whether the chart's fetch answered an ask whole, by the verdict it reports (`onSourceVerdict`): a genuine
903
+ * end-of-stream over the whole window (`complete`), or a row-cache hit (that cache keeps only such answers). A
904
+ * synthetic completion (a kicked session, a connection that could not open), a trimmed or refused window, and an ask
905
+ * that reported no verdict at all are not whole: their rows (none, or the ones collected so far) look like data.
906
+ */
907
+ export declare function wrunSourceVerdictWhole(verdict: {
908
+ complete: boolean;
909
+ source: string;
910
+ } | undefined): boolean;
911
+ /** A window asked in pieces whose piece the chart's fetch did not answer whole (`wrunAskWirePieces`): nothing of the
912
+ * window commits, since that piece's missing rows would read as quiet bars, and to a reconcile as absence. */
913
+ export declare class WrunWirePiecesIncomplete extends Error {
914
+ readonly fromMs: number;
915
+ readonly toMs: number;
916
+ constructor(fromMs: number, toMs: number);
917
+ }
918
+ /**
919
+ * A window's rows asked in its pieces (`wrunWireRowPieces`), newest first (the bars at the chart's right edge, as the
920
+ * overlays' tiered families run) and at most three on the wire at once, as one ascending answer: a row two pieces
921
+ * both answer (the fetch pads a piece's end by one row) is kept once, the later piece's. The pieces are one family
922
+ * with one commit: a piece that fails, or that the fetch did not answer whole (`WrunWirePiecesIncomplete`), fails the
923
+ * whole ask and no further piece is asked, since a window missing a piece reads that piece's bars as quiet (and a
924
+ * reconcile reads them as absence, dropping rows it holds). One piece is the one ask's answer as it came: no piece
925
+ * of it can be missing in the middle. `abandoned` (the lane's budget ran out, its run no longer waits on it) asks no
926
+ * further piece; the pieces already out finish into the fetch's cache.
927
+ */
928
+ export declare function wrunAskWirePieces<Row extends ArrayLike<unknown>>(pieces: ReadonlyArray<{
929
+ fromMs: number;
930
+ toMs: number;
931
+ }>, ask: (fromMs: number, toMs: number) => Promise<WrunWirePieceAnswer<Row>>, abandoned?: AbortSignal): Promise<Row[]>;
932
+ /** The chart's bars a grid leg's rows land on (`wrunLegRowsOnHostBars`). */
933
+ export interface WrunHostBarGrid {
934
+ /** The opens of the rows the build evaluates, ascending: the chart's own, or the dense grid a primary rides. */
935
+ opens: readonly number[];
936
+ /** The chart's bar span (the run's interval). */
937
+ intervalMs: number;
938
+ /** The chart's bar grid (`WrunBarVenue.barGrid`, `liveBucketVenueOf(metadata)`); absent: the UTC floor. */
939
+ barGrid?: LiveBucketVenue | null;
940
+ /** The chart's forming bar while it is live (`WrunChartSourceRows.formingBarTs`), else null. */
941
+ formingBarTs?: number | null;
942
+ }
943
+ /**
944
+ * The chart bar a grid leg's row stamped `rowTs` lands in, for one row and with no forming bar
945
+ * (`wrunLegRowsOnHostBars`'s rule for a closed row): its own stamp when that opens a chart bar, else the bar
946
+ * holding its last instant (by its open on a calendar span); null when no bar holds it (off the chart's
947
+ * session). `barOf` is the chart's bucket function at its own interval (`hostBucketResolverFor` over its bar
948
+ * grid). The live session reads it to tell which committed bar a revised leg row reaches.
949
+ */
950
+ export declare function wrunLegRowHostBar(rowTs: number, legMs: number, barOf: (tsMs: number) => number | null): number | null;
951
+ /**
952
+ * A grid leg's rows as the shared host's exact cursor reads them (`WRUN_PINNED_WIRE_ROWS`): each row in the chart
953
+ * bar holding its LAST instant (`placeRowsInHostBars` over the leg's own span, merged by the leg's row shape,
954
+ * `WRUN_LEG_ROW_HOST_MERGE`), so a leg on another bar grid lands on the chart's bars with no look-ahead. A closed
955
+ * chart bar holds only the rows that closed inside it: a 24/7 hour [14:00, 15:00) New York lands in a stock's 14:30
956
+ * bar and the 15:30 stub holds the [15:00, 16:00) hour; a stock's [13:30Z, 14:30Z) hour lands in a 24/7 chart's
957
+ * 14:00Z bar. A row still forming past the chart's newest bar lands in the bar holding its open when that bar is
958
+ * the chart's forming one (`formingBarTs`, a live chart's), else nowhere. A leg on the chart's own grid comes back
959
+ * as the same rows (the same array when every row is on a chart bar's open). The rows that closed before the first
960
+ * chart bar stay in front as they are: no bar holds them, and the last of them is the seed an odds leg carries a
961
+ * wire with before its first observation. A calendar span has no fixed length to find a row's last instant with:
962
+ * such a row lands in the bar holding its open.
963
+ *
964
+ * `afterTs` (a tail build's or a carry advance's carry `throughTs`): the pass reads the rows after it alone, so
965
+ * only the bars after it are landed, from the rows that can reach them (a live tick never lands the whole
966
+ * window again).
967
+ */
968
+ export declare function wrunLegRowsOnHostBars(rows: ReadonlyArray<ArrayLike<number>>, host: WrunHostBarGrid, leg: WrunLegRowsSpan, afterTs?: number): ReadonlyArray<ArrayLike<number>>;
797
969
  /**
798
970
  * Classify every declared pin against the chart BEFORE any fetch: the legs
799
971
  * a run must fetch (one per market + interval: period legs at the pinned
@@ -347,12 +347,13 @@ import { Intervals } from '../../constants/interval.constants.js';
347
347
  import { barEndMs, calendarBarStartMs, calendarLongestBarMs, calendarMonthsOfMs, isCalendarIntervalMs, } from '../chart/calendar-interval.util.js';
348
348
  import { WRUN_PINNED_INTERVALS, wrunPinnedIntervalOf } from './wrun-pinned-interval.util.js';
349
349
  import { realMainRows } from '../chart/indicator-gap-detector.util.js';
350
+ import { placeRowsInHostBars } from '../chart/host-bar-placement.util.js';
350
351
  import { findMonday } from '../chart/titan-constants.pin.js';
351
352
  import { wrunBarSessionFactsResolver, } from '../chart/wrun-bar-session-facts.util.js';
352
353
  import { wrunSettingRefusedMessage } from '../scriptEditor/wrun-runtime-diagnostics.leaf.js';
353
354
  import { attachWrunRefusal, wrunPinFinerSeed } from './wrun-refusal.util.js';
354
355
  import { planWrunRowLaneInputs, wrunRowLaneCellRows } from './sources/wrun-row-lanes.util.js';
355
- import { wrunTradesLaneOf, wrunTradesLegLaneOf } from './wrun-trades-lane.util.js';
356
+ import { wrunTradesLaneOf, wrunTradesLegLaneOf, wrunTradesLegOf } from './wrun-trades-lane.util.js';
356
357
  import { planWrunPollLaneInputs } from './sources/wrun-poll-lanes.util.js';
357
358
  import { planWrunEtfFlowColumns } from './wrun-etf-flow-lane.util.js';
358
359
  import { planWrunOptionSummaryLane } from './wrun-option-summary-lane.util.js';
@@ -682,6 +683,14 @@ export function wrunPinnedLegFetchKey(source, intervalKey, odds = false) {
682
683
  const key = `pinned|${source.exchange ?? 'currentExchange'}|${source.symbol ?? 'currentSymbol'}|${intervalKey}`;
683
684
  return odds ? `${key}|odds` : key;
684
685
  }
686
+ /** The tier each grid leg asked at a tier rides (`WrunPinnedLeg.tierMs`), by fetch key: `pinnedLegTierMs`. */
687
+ export function wrunPinnedLegTierMs(legs) {
688
+ const tiers = {};
689
+ for (const leg of legs ?? [])
690
+ if (leg.tierMs !== undefined && leg.tierMs > 0)
691
+ tiers[leg.fetchKey] = leg.tierMs;
692
+ return tiers;
693
+ }
685
694
  /** The fetch-key suffix a leg rides under a caller's prefix: the interval
686
695
  * alone for an own-market period leg (the round-2 shape), the market
687
696
  * appended for a foreign leg, `grid-` / `intrabar-` prefixed by kind,
@@ -696,6 +705,227 @@ export function wrunPinnedLegFetchSuffix(leg) {
696
705
  const stream = leg.stream !== undefined ? `-${wrunLegStreamKeyWords(leg.stream).replace(/\|/g, '-')}` : '';
697
706
  return `${kind}${leg.intervalKey}${market}${leg.odds === true ? '-odds' : ''}${stream}`;
698
707
  }
708
+ /**
709
+ * How one chart bar merges the rows of a leg on another bar grid that land in it (`placeRowsInHostBars`), by the
710
+ * leg's row shape: OHLC rows open on the first, span the extremes, close on the last and sum the volume
711
+ * (`candle`); additive rows sum (`flow`); celled rows keep the bar's last row whole (`level`: the flow merge sums
712
+ * numeric columns and has no cell merge). One entry per row class the source layer knows: a class without one
713
+ * fails the typecheck, and wrun-source-rows.grid-legs.spec.ts holds the table to the stream classes and the trades
714
+ * lanes.
715
+ */
716
+ export const WRUN_LEG_ROW_HOST_MERGE = Object.freeze({
717
+ ohlcv: 'candle',
718
+ odds: 'candle',
719
+ oi_candles: 'candle',
720
+ volume_profile_candles: 'level',
721
+ trades: 'flow',
722
+ trades_usd: 'flow',
723
+ });
724
+ /** A pinned leg's row class (`WRUN_LEG_ROW_HOST_MERGE`). */
725
+ export function wrunLegRowClassOf(leg) {
726
+ return leg.stream?.class ?? (leg.odds === true ? 'odds' : 'ohlcv');
727
+ }
728
+ /**
729
+ * The rows each pinned wire's reader is handed (`wrunHostRunOf`): `host-bars` for a reader the shared host joins on
730
+ * the chart's own rows by timestamp (its exact cursor: a grid leg read row for row), so the leg's rows are first
731
+ * placed in the chart bars that hold them (`wrunLegRowsOnHostBars`), and a leg on another bar grid (a 24/7
732
+ * market's :00 hours under a stock's 09:30-anchored bars) lands; `native` for a reader that meets the chart's rows
733
+ * by a candle's close or its bucket (the confirmed cursor, the forming fold, the candles stream, the intrabar
734
+ * slicer) and reads the leg's own rows; `none` for a wire that reads no leg. A wire kind without an entry fails the
735
+ * typecheck: a new reader says which rows it joins before it reads one.
736
+ */
737
+ export const WRUN_PINNED_WIRE_ROWS = Object.freeze({
738
+ own_period: 'none',
739
+ period: 'native',
740
+ forming: 'native',
741
+ grid: 'host-bars',
742
+ intrabar: 'native',
743
+ candles: 'native',
744
+ typed: 'none',
745
+ });
746
+ /** The interval (ms) a lane's acquisition was asked at (its `interval` word, the payload field the K control asks
747
+ * by), undefined when it names none: a trades leg's tier (`WrunChartSourceRows.tradeLegIntervals`). */
748
+ export function wrunLaneAcquisitionIntervalMs(acquisition) {
749
+ const word = acquisition?.interval;
750
+ const ms = typeof word === 'string' ? Intervals.map_unit[word] : undefined;
751
+ return typeof ms === 'number' && ms > 0 ? ms : undefined;
752
+ }
753
+ /** Each trades leg lane's row interval (ms) by its acquisition (`wrunLaneAcquisitionIntervalMs`: the tier its ask
754
+ * named, else the interval the fetch stamped on it): `WrunChartSourceRows.tradeLegIntervals`. */
755
+ export function wrunTradeLegIntervals(acquisition) {
756
+ const intervals = {};
757
+ for (const [lane, record] of Object.entries(acquisition)) {
758
+ if (wrunTradesLegOf(lane) === undefined)
759
+ continue;
760
+ const ms = wrunLaneAcquisitionIntervalMs(record);
761
+ if (ms !== undefined)
762
+ intervals[lane] = ms;
763
+ }
764
+ return intervals;
765
+ }
766
+ /** The backend's cache bucket, in rows of the asked interval: one wire ask of a tiered lane holds at most this many
767
+ * (`wrunWireRowPieces`), the overlays' tiered asks' rule. */
768
+ export const WRUN_WIRE_PIECE_ROWS = 250;
769
+ /**
770
+ * `[fromMs, toMs)` as the wire asks of a lane asked at `rowMs` (a trades leg's tier finer than the chart's bars),
771
+ * sized in the rows the wire returns: one piece when the span holds at most `WRUN_WIRE_PIECE_ROWS` rows, else
772
+ * ascending pieces of at most that many, each inner edge on the tier's bucket grid (a multiple of
773
+ * `WRUN_WIRE_PIECE_ROWS * rowMs` from the epoch, so a piece is one backend cache bucket), the first and last
774
+ * partial and the span never widened. A 12h stock chart's window is about a year: at 30m that is 17,520 rows of a
775
+ * 24/7 venue, and asked whole the gateway fails it.
776
+ */
777
+ export function wrunWireRowPieces(fromMs, toMs, rowMs) {
778
+ const bucketMs = WRUN_WIRE_PIECE_ROWS * rowMs;
779
+ if (!Number.isFinite(fromMs) || !Number.isFinite(toMs) || !(rowMs > 0) || toMs - fromMs <= bucketMs) {
780
+ return [{ fromMs, toMs }];
781
+ }
782
+ const pieces = [];
783
+ for (let at = fromMs; at < toMs;) {
784
+ const edge = Math.min(toMs, Math.floor(at / bucketMs) * bucketMs + bucketMs);
785
+ pieces.push({ fromMs: at, toMs: edge });
786
+ at = edge;
787
+ }
788
+ return pieces;
789
+ }
790
+ /** Pieces of one window on the wire at once (`wrunAskWirePieces`): the kScript source chunks' three. */
791
+ const WRUN_WIRE_PIECES_IN_FLIGHT = 3;
792
+ /**
793
+ * Whether the chart's fetch answered an ask whole, by the verdict it reports (`onSourceVerdict`): a genuine
794
+ * end-of-stream over the whole window (`complete`), or a row-cache hit (that cache keeps only such answers). A
795
+ * synthetic completion (a kicked session, a connection that could not open), a trimmed or refused window, and an ask
796
+ * that reported no verdict at all are not whole: their rows (none, or the ones collected so far) look like data.
797
+ */
798
+ export function wrunSourceVerdictWhole(verdict) {
799
+ return verdict !== undefined && (verdict.complete || verdict.source === 'row-cache');
800
+ }
801
+ /** A window asked in pieces whose piece the chart's fetch did not answer whole (`wrunAskWirePieces`): nothing of the
802
+ * window commits, since that piece's missing rows would read as quiet bars, and to a reconcile as absence. */
803
+ export class WrunWirePiecesIncomplete extends Error {
804
+ fromMs;
805
+ toMs;
806
+ constructor(fromMs, toMs) {
807
+ super(`the window's piece [${new Date(fromMs).toISOString()}, ${new Date(toMs).toISOString()}) was not answered whole`);
808
+ this.name = 'WrunWirePiecesIncomplete';
809
+ this.fromMs = fromMs;
810
+ this.toMs = toMs;
811
+ }
812
+ }
813
+ /**
814
+ * A window's rows asked in its pieces (`wrunWireRowPieces`), newest first (the bars at the chart's right edge, as the
815
+ * overlays' tiered families run) and at most three on the wire at once, as one ascending answer: a row two pieces
816
+ * both answer (the fetch pads a piece's end by one row) is kept once, the later piece's. The pieces are one family
817
+ * with one commit: a piece that fails, or that the fetch did not answer whole (`WrunWirePiecesIncomplete`), fails the
818
+ * whole ask and no further piece is asked, since a window missing a piece reads that piece's bars as quiet (and a
819
+ * reconcile reads them as absence, dropping rows it holds). One piece is the one ask's answer as it came: no piece
820
+ * of it can be missing in the middle. `abandoned` (the lane's budget ran out, its run no longer waits on it) asks no
821
+ * further piece; the pieces already out finish into the fetch's cache.
822
+ */
823
+ export async function wrunAskWirePieces(pieces, ask, abandoned) {
824
+ const stopIfAbandoned = () => {
825
+ if (abandoned?.aborted)
826
+ throw abandoned.reason ?? new Error('the window was abandoned');
827
+ };
828
+ if (pieces.length === 1) {
829
+ stopIfAbandoned();
830
+ return [...(await ask(pieces[0].fromMs, pieces[0].toMs)).rows];
831
+ }
832
+ const answers = [];
833
+ const newestFirst = pieces.map((_, at) => at).reverse();
834
+ let next = 0;
835
+ let failed = false;
836
+ const lane = async () => {
837
+ while (!failed && next < newestFirst.length) {
838
+ const at = newestFirst[next];
839
+ next += 1;
840
+ try {
841
+ stopIfAbandoned();
842
+ const answer = await ask(pieces[at].fromMs, pieces[at].toMs);
843
+ if (!answer.whole)
844
+ throw new WrunWirePiecesIncomplete(pieces[at].fromMs, pieces[at].toMs);
845
+ answers[at] = answer.rows;
846
+ }
847
+ catch (error) {
848
+ failed = true;
849
+ throw error;
850
+ }
851
+ }
852
+ };
853
+ await Promise.all(Array.from({ length: Math.min(WRUN_WIRE_PIECES_IN_FLIGHT, pieces.length) }, lane));
854
+ const byTs = new Map();
855
+ for (const answer of answers)
856
+ for (const row of answer)
857
+ byTs.set(Number(row[0]), row);
858
+ return [...byTs.entries()].sort((a, b) => a[0] - b[0]).map(([, row]) => row);
859
+ }
860
+ /**
861
+ * The chart bar a grid leg's row stamped `rowTs` lands in, for one row and with no forming bar
862
+ * (`wrunLegRowsOnHostBars`'s rule for a closed row): its own stamp when that opens a chart bar, else the bar
863
+ * holding its last instant (by its open on a calendar span); null when no bar holds it (off the chart's
864
+ * session). `barOf` is the chart's bucket function at its own interval (`hostBucketResolverFor` over its bar
865
+ * grid). The live session reads it to tell which committed bar a revised leg row reaches.
866
+ */
867
+ export function wrunLegRowHostBar(rowTs, legMs, barOf) {
868
+ if (!Number.isFinite(rowTs))
869
+ return null;
870
+ const open = barOf(rowTs);
871
+ if (open === rowTs || !(legMs > 0) || isCalendarIntervalMs(legMs))
872
+ return open;
873
+ return barOf(rowTs + legMs - 1);
874
+ }
875
+ /** The index of the first of ascending `values` above `ms` (`values.length` when none is). */
876
+ function firstValueAbove(values, ms) {
877
+ let low = 0;
878
+ let high = values.length;
879
+ while (low < high) {
880
+ const mid = (low + high) >>> 1;
881
+ if (values[mid] <= ms)
882
+ low = mid + 1;
883
+ else
884
+ high = mid;
885
+ }
886
+ return low;
887
+ }
888
+ /**
889
+ * A grid leg's rows as the shared host's exact cursor reads them (`WRUN_PINNED_WIRE_ROWS`): each row in the chart
890
+ * bar holding its LAST instant (`placeRowsInHostBars` over the leg's own span, merged by the leg's row shape,
891
+ * `WRUN_LEG_ROW_HOST_MERGE`), so a leg on another bar grid lands on the chart's bars with no look-ahead. A closed
892
+ * chart bar holds only the rows that closed inside it: a 24/7 hour [14:00, 15:00) New York lands in a stock's 14:30
893
+ * bar and the 15:30 stub holds the [15:00, 16:00) hour; a stock's [13:30Z, 14:30Z) hour lands in a 24/7 chart's
894
+ * 14:00Z bar. A row still forming past the chart's newest bar lands in the bar holding its open when that bar is
895
+ * the chart's forming one (`formingBarTs`, a live chart's), else nowhere. A leg on the chart's own grid comes back
896
+ * as the same rows (the same array when every row is on a chart bar's open). The rows that closed before the first
897
+ * chart bar stay in front as they are: no bar holds them, and the last of them is the seed an odds leg carries a
898
+ * wire with before its first observation. A calendar span has no fixed length to find a row's last instant with:
899
+ * such a row lands in the bar holding its open.
900
+ *
901
+ * `afterTs` (a tail build's or a carry advance's carry `throughTs`): the pass reads the rows after it alone, so
902
+ * only the bars after it are landed, from the rows that can reach them (a live tick never lands the whole
903
+ * window again).
904
+ */
905
+ export function wrunLegRowsOnHostBars(rows, host, leg, afterTs) {
906
+ const { opens, intervalMs } = host;
907
+ if (rows.length === 0 || opens.length === 0 || !(intervalMs > 0))
908
+ return rows;
909
+ const spanMs = leg.legMs > 0 && !isCalendarIntervalMs(leg.legMs) ? leg.legMs : undefined;
910
+ // A row reaches the bar opening at `open` when its last instant does: stamped after `open - span`.
911
+ const reach = spanMs ?? 1;
912
+ let lead = 0;
913
+ while (lead < rows.length && wrunRowTs(rows[lead]) <= opens[0] - reach)
914
+ lead += 1;
915
+ const from = afterTs === undefined || !Number.isFinite(afterTs) ? 0 : firstValueAbove(opens, afterTs);
916
+ if (from >= opens.length)
917
+ return rows.slice(0, lead);
918
+ let placedFrom = lead;
919
+ if (from > 0) {
920
+ const floor = Math.max(opens[from] - reach, opens[from - 1]);
921
+ placedFrom = Math.max(lead, wrunLastRowAtOrBefore(rows, floor) + 1);
922
+ }
923
+ const placed = placeRowsInHostBars((placedFrom === 0 ? rows : rows.slice(placedFrom)), { mainRows: (from === 0 ? opens : opens.slice(from)).map((open) => [open]), intervalMs, venue: host.barGrid }, WRUN_LEG_ROW_HOST_MERGE[leg.rowClass], undefined, spanMs === undefined ? undefined : { rowSpanMs: spanMs, formingBarTs: host.formingBarTs ?? null });
924
+ if (lead === 0 && placedFrom === 0 && placed.length === rows.length && placed.every((row, at) => row === rows[at])) {
925
+ return rows;
926
+ }
927
+ return lead === 0 ? placed : [...rows.slice(0, lead), ...placed];
928
+ }
699
929
  const WRUN_INPUT_VIEWS = new Set([
700
930
  'confirmed',
701
931
  'forming',
@@ -2196,6 +2426,54 @@ function wrunHostRunOf(metadata, sources, clock, cellsAfterTs) {
2196
2426
  }
2197
2427
  return rows;
2198
2428
  };
2429
+ // The chart's bars a grid leg lands on: the rows the shared host evaluates (the chart's own, or the dense grid
2430
+ // a nan or zero primary rides, every bar of the chart's phase), on the chart's bar grid.
2431
+ let hostBars;
2432
+ const hostBarGrid = () => {
2433
+ if (hostBars === undefined) {
2434
+ const primary = planned.wires[0];
2435
+ const dense = primary?.kind === 'scalar' && primary.densify === true && primary.unserved !== true;
2436
+ const opens = [];
2437
+ if (dense)
2438
+ for (let open = firstTs; open <= lastTs; open += intervalMs)
2439
+ opens.push(open);
2440
+ hostBars = {
2441
+ opens: dense ? opens : gridTs,
2442
+ intervalMs,
2443
+ barGrid: sources.venue?.barGrid ?? null,
2444
+ formingBarTs: sources.formingBarTs ?? null,
2445
+ };
2446
+ }
2447
+ return hostBars;
2448
+ };
2449
+ // A leg's rows in the chart bars holding them, for the readers that join the chart's rows by timestamp
2450
+ // (`WRUN_PINNED_WIRE_ROWS`); a tail lands the bars after its carry alone.
2451
+ const hostBarLegRows = new Map();
2452
+ const pinnedRowsOf = (kind, leg) => {
2453
+ if (WRUN_PINNED_WIRE_ROWS[kind] !== 'host-bars')
2454
+ return legRowsOf(leg);
2455
+ let rows = hostBarLegRows.get(leg.fetchKey);
2456
+ if (rows === undefined) {
2457
+ rows = wrunLegRowsOnHostBars(legRowsOf(leg), hostBarGrid(), { legMs: sources.pinnedLegTierMs?.[leg.fetchKey] ?? leg.legMs, rowClass: wrunLegRowClassOf(leg) }, cellsAfterTs);
2458
+ hostBarLegRows.set(leg.fetchKey, rows);
2459
+ }
2460
+ return rows;
2461
+ };
2462
+ // The foreign forming folds by input: each reads its grid leg's own rows on a key of its own, apart from a grid
2463
+ // read of the same market (the same ask), which reads them landed on the chart's bars.
2464
+ const foldKeys = new Map();
2465
+ // A trades leg's rows (its market's buy and sell volume at its own tier, on its own grid), landed on the chart's
2466
+ // bars and summed per bar, as the join reads them: the history and the live fold ride the leg's grid alike.
2467
+ const tradeLegLanded = new Map();
2468
+ const tradeLegRowsOf = (lane) => {
2469
+ let rows = tradeLegLanded.get(lane);
2470
+ if (rows === undefined) {
2471
+ const leg = wrunTradesLegOf(lane);
2472
+ rows = wrunLegRowsOnHostBars(sources.tradeLegRows?.[lane] ?? [], hostBarGrid(), { legMs: sources.tradeLegIntervals?.[lane] ?? intervalMs, rowClass: leg?.lane ?? 'trades' }, cellsAfterTs);
2473
+ tradeLegLanded.set(lane, rows);
2474
+ }
2475
+ return rows;
2476
+ };
2199
2477
  // An intrabar leg's candles as this build reads them: past the carry (`cellsAfterTs`) a tail
2200
2478
  // reads blocks only from the bounds of the carry's own row on (later rows open no earlier), so
2201
2479
  // the candles from there on, behind the newest candle closed by now that opens before them (the
@@ -2277,14 +2555,17 @@ function wrunHostRunOf(metadata, sources, clock, cellsAfterTs) {
2277
2555
  softRefused.add(wire.inputIndex);
2278
2556
  switch (pinned.kind) {
2279
2557
  case 'period':
2280
- offer(key, legRowsOf(pinned.leg));
2558
+ offer(key, pinnedRowsOf(pinned.kind, pinned.leg));
2281
2559
  break;
2282
2560
  case 'grid':
2283
- offer(key, legRowsOf(pinned.gridLeg));
2561
+ offer(key, pinnedRowsOf(pinned.kind, pinned.gridLeg));
2284
2562
  break;
2285
2563
  case 'forming':
2286
- if (pinned.gridLeg !== undefined)
2287
- offer(key, legRowsOf(pinned.gridLeg));
2564
+ if (pinned.gridLeg !== undefined) {
2565
+ const fold = `${key}|fold`;
2566
+ foldKeys.set(wire.inputIndex, fold);
2567
+ offer(fold, pinnedRowsOf(pinned.kind, pinned.gridLeg));
2568
+ }
2288
2569
  break;
2289
2570
  case 'typed':
2290
2571
  offer(key, pinned.lane === 'funding' ? sources.fundingRateRows : sources.openInterestRows);
@@ -2304,11 +2585,11 @@ function wrunHostRunOf(metadata, sources, clock, cellsAfterTs) {
2304
2585
  // reader): the leg's lane rows adapted once, by the stream's own ask (its span and facets).
2305
2586
  if (!cellAnswers.has(own)) {
2306
2587
  const ask = askByKey.get(key);
2307
- cellAnswers.set(own, ask === undefined ? [] : wrunLegStreamCellRows(host, ask, legRowsOf(pinned.leg)));
2588
+ cellAnswers.set(own, ask === undefined ? [] : wrunLegStreamCellRows(host, ask, pinnedRowsOf(pinned.kind, pinned.leg)));
2308
2589
  }
2309
2590
  break;
2310
2591
  }
2311
- offer(own, pinned.kind === 'intrabar' ? intrabarRowsOf(pinned.leg, closeMs) : legRowsOf(pinned.leg));
2592
+ offer(own, pinned.kind === 'intrabar' ? intrabarRowsOf(pinned.leg, closeMs) : pinnedRowsOf(pinned.kind, pinned.leg));
2312
2593
  break;
2313
2594
  }
2314
2595
  default:
@@ -2347,7 +2628,9 @@ function wrunHostRunOf(metadata, sources, clock, cellsAfterTs) {
2347
2628
  ? sources.buySellVolumeUsdRows
2348
2629
  : lane === 'trades'
2349
2630
  ? sources.buySellVolumeRows
2350
- : ((lane === undefined ? undefined : sources.tradeLegRows?.[lane]) ?? []));
2631
+ : lane === undefined
2632
+ ? []
2633
+ : tradeLegRowsOf(lane));
2351
2634
  columns.set(wire.inputIndex, source.side === 'SELL' ? 2 : 1);
2352
2635
  // A pin on a venue not served to scripts yet is never asked: its fill, as a candle pin's.
2353
2636
  if (source.exchange !== undefined && wrunPinVenueVerdict(source.exchange) === 'unserved') {
@@ -2418,6 +2701,9 @@ function wrunHostRunOf(metadata, sources, clock, cellsAfterTs) {
2418
2701
  if (undemanded.has(wire.inputIndex - shift) && wire.ownPeriod !== true) {
2419
2702
  return { ...wire, unserved: true };
2420
2703
  }
2704
+ const fold = foldKeys.get(wire.inputIndex);
2705
+ if (fold !== undefined)
2706
+ return { ...wire, fetchKey: fold };
2421
2707
  const lane = laneWires.get(wire.inputIndex);
2422
2708
  if (lane !== undefined) {
2423
2709
  // The lane read: the lane's rows, its column, its join (the stand-in's ask is never read; a
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The stats strip's look on a wrun sheet (om `stats_strip`: `grading`,
3
+ * `label_side`, `theme`, in the words of the shared host's WRUN_STATS_STRIP_WORDS)
4
+ * as the overlay settings titan's strip reads. The strip reads three
5
+ * Display settings off the overlay by name, `statsGrading`, `statsLabelSide`
6
+ * and `statsTheme` (titan statsStripRenderer.ts, through normalizeGradingBasis,
7
+ * resolveStatsLabelSide and normalizeStatsTheme), which a kScript overlay
8
+ * holds as the Bar Statistics template's Display inputs, each its option
9
+ * label. A sheet paints its strip keys through `style_targets` from a select
10
+ * (`style_values` over the words), so the sheet as the settings paint it
11
+ * (wrunSheetWithSettings) holds the current look, and the full run stamps it
12
+ * on the overlay under those three names, in the template's labels: a twin's
13
+ * strip reads exactly what its built-in's reads.
14
+ */
15
+ import { type WrunSharedHostModule } from '../../host-env.js';
16
+ import type { WrunIndicatorMetadata } from '../../interfaces/wrun-runtime.interface.js';
17
+ /** A key of the strip's look: the kit's `WrunStatsStripKey`, read off the shared host the env hands. */
18
+ type WrunStatsStripKey = keyof WrunSharedHostModule['WRUN_STATS_STRIP_WORDS'];
19
+ /** The overlay setting titan's strip reads for each sheet key. */
20
+ export declare const WRUN_STATS_STRIP_SETTING_KEYS: Readonly<Record<WrunStatsStripKey, string>>;
21
+ /** Each word as the Bar Statistics template's option label (its Display
22
+ * inputs' options, in the words' order): the string the built-in's overlay
23
+ * holds and titan's normalizers read. */
24
+ export declare const WRUN_STATS_STRIP_SETTING_LABELS: {
25
+ readonly [K in WrunStatsStripKey]: Readonly<Record<WrunSharedHostModule['WRUN_STATS_STRIP_WORDS'][K][number], string>>;
26
+ };
27
+ /**
28
+ * The strip settings a sheet paints: one titan setting per key its
29
+ * `stats_strip` holds, in the template's label. Undefined when the sheet
30
+ * declares no strip look (nothing is stamped, the strip keeps its own
31
+ * defaults). A key holding anything but one of its words, or an unknown key,
32
+ * refuses by name (the om sheet check's rule, held at the host too).
33
+ */
34
+ export declare function wrunStatsStripSettings(sheet: Pick<WrunIndicatorMetadata, 'id' | 'stats_strip'>): Record<string, string> | undefined;
35
+ /**
36
+ * Whether a sheet's whole look is a stats strip: every renderer a `stats_row` (at least one), and
37
+ * every output data-only (`plot: ""`), so the strip is all the chart draws of it (a mark, a label
38
+ * or a plotted line beside the rows makes another look). Two twin rules read it. The palette:
39
+ * titan's strip reads the overlay palette (`settings.colors`) as its "Candle colors" theme pair,
40
+ * so such a sheet's palette is the theme's, as on the built-in's template, never its colour
41
+ * settings, which paint their own rows through their style targets (wrun-overlay-run.util
42
+ * syncWrunRunOverlayPalette). The legend: such a twin prints its built-in's one readout off the
43
+ * container row, the strip's first row, as the template does (the technical-script control).
44
+ */
45
+ export declare function wrunSheetDrawsOnlyStatsStrip(sheet: Pick<WrunIndicatorMetadata, 'outputs' | 'renderers'>): boolean;
46
+ export {};