@orangecharts/wrun-chart-host 0.3.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 (362) hide show
  1. package/README.md +23 -6
  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/builtin-script-snippets.d.ts +133 -0
  11. package/dist/constants/scriptEditor/builtin-script-snippets.js +451 -0
  12. package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +168 -0
  13. package/dist/constants/scriptEditor/cme-official-scripts.constants.js +398 -0
  14. package/dist/constants/scriptEditor/converted-script-id.leaf.d.ts +8 -0
  15. package/dist/constants/scriptEditor/converted-script-id.leaf.js +10 -0
  16. package/dist/constants/scriptEditor/execution.constants.d.ts +4 -0
  17. package/dist/constants/scriptEditor/execution.constants.js +14 -0
  18. package/dist/constants/wrun-prefix-safe.constants.d.ts +23 -0
  19. package/dist/constants/wrun-prefix-safe.constants.js +26 -0
  20. package/dist/host-env.d.ts +321 -24
  21. package/dist/host-env.js +15 -0
  22. package/dist/host-ports.types.d.ts +857 -35
  23. package/dist/index.d.ts +149 -2
  24. package/dist/index.js +149 -2
  25. package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +31 -0
  26. package/dist/instances/script-engine-worker-ohlcv-transfer.js +164 -0
  27. package/dist/interfaces/market-event.interface.d.ts +231 -0
  28. package/dist/interfaces/market-event.interface.js +15 -0
  29. package/dist/interfaces/opra-realtime.interface.d.ts +70 -134
  30. package/dist/interfaces/opra-realtime.interface.js +34 -59
  31. package/dist/interfaces/replay.interface.d.ts +285 -0
  32. package/dist/interfaces/replay.interface.js +1 -0
  33. package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +1 -0
  34. package/dist/kscript-data/controls/live-ohlcv-merge.util.js +93 -0
  35. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +5 -1
  36. package/dist/kscript-data/controls/live-trades-merge.util.js +2 -2
  37. package/dist/market-data/billing.interface.d.ts +219 -0
  38. package/dist/market-data/billing.interface.js +58 -0
  39. package/dist/market-data/venue-governed.util.d.ts +2 -0
  40. package/dist/market-data/venue-governed.util.js +10 -0
  41. package/dist/market-data/venue.d.ts +122 -0
  42. package/dist/market-data/venue.js +1 -0
  43. package/dist/market-data/venues/index.d.ts +97 -0
  44. package/dist/market-data/venues/index.js +33 -0
  45. package/dist/market-data/venues/opra.contract.copy.json +35 -0
  46. package/dist/market-data/venues/opra.d.ts +70 -0
  47. package/dist/market-data/venues/opra.js +74 -0
  48. package/dist/replay/replayIndicatorRows.d.ts +31 -0
  49. package/dist/replay/replayIndicatorRows.js +117 -0
  50. package/dist/replay/replayLadder.d.ts +85 -0
  51. package/dist/replay/replayLadder.js +388 -0
  52. package/dist/utility/auth/server-clock.util.d.ts +81 -0
  53. package/dist/utility/auth/server-clock.util.js +238 -0
  54. package/dist/utility/chart/builtin-identity.util.d.ts +18 -0
  55. package/dist/utility/chart/builtin-identity.util.js +51 -0
  56. package/dist/utility/chart/cache-alignment.util.d.ts +454 -0
  57. package/dist/utility/chart/cache-alignment.util.js +926 -0
  58. package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +15 -0
  59. package/dist/utility/chart/chart-data-fetch-generation.util.js +22 -0
  60. package/dist/utility/chart/chart-mount-epoch.util.d.ts +5 -0
  61. package/dist/utility/chart/chart-mount-epoch.util.js +29 -0
  62. package/dist/utility/chart/chart-time-domain.util.d.ts +12 -0
  63. package/dist/utility/chart/chart-time-domain.util.js +23 -0
  64. package/dist/utility/chart/color-customization.leaf.d.ts +10 -0
  65. package/dist/utility/chart/color-customization.leaf.js +16 -0
  66. package/dist/utility/chart/date-labelled-interval.leaf.d.ts +15 -0
  67. package/dist/utility/chart/date-labelled-interval.leaf.js +19 -0
  68. package/dist/utility/chart/footprint-tick-grid.util.d.ts +106 -0
  69. package/dist/utility/chart/footprint-tick-grid.util.js +167 -0
  70. package/dist/utility/chart/gesture-timing.leaf.d.ts +29 -0
  71. package/dist/utility/chart/gesture-timing.leaf.js +29 -0
  72. package/dist/utility/chart/governed-contract-coin.util.d.ts +22 -0
  73. package/dist/utility/chart/governed-contract-coin.util.js +39 -0
  74. package/dist/utility/chart/host-bar-placement.util.d.ts +107 -0
  75. package/dist/utility/chart/host-bar-placement.util.js +447 -0
  76. package/dist/utility/chart/index-host-tier.util.d.ts +31 -0
  77. package/dist/utility/chart/index-host-tier.util.js +118 -0
  78. package/dist/utility/chart/index-mode-admission.util.d.ts +34 -0
  79. package/dist/utility/chart/index-mode-admission.util.js +67 -0
  80. package/dist/utility/chart/indicator-error-message.util.d.ts +35 -0
  81. package/dist/utility/chart/indicator-error-message.util.js +44 -0
  82. package/dist/utility/chart/indicator-run-interval.util.d.ts +130 -0
  83. package/dist/utility/chart/indicator-run-interval.util.js +268 -0
  84. package/dist/utility/chart/kscript-apply-fingerprint.util.d.ts +65 -0
  85. package/dist/utility/chart/kscript-apply-fingerprint.util.js +357 -0
  86. package/dist/utility/chart/kscript-chart-flush.leaf.d.ts +22 -0
  87. package/dist/utility/chart/kscript-chart-flush.leaf.js +13 -0
  88. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +6 -0
  89. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +27 -0
  90. package/dist/utility/chart/kscript-integration-decision.leaf.d.ts +89 -0
  91. package/dist/utility/chart/kscript-integration-decision.leaf.js +80 -0
  92. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +76 -0
  93. package/dist/utility/chart/kscript-live-coalesce.util.js +156 -0
  94. package/dist/utility/chart/kscript-live-rest-pace.util.d.ts +34 -0
  95. package/dist/utility/chart/kscript-live-rest-pace.util.js +134 -0
  96. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +98 -0
  97. package/dist/utility/chart/kscript-live-source-identity.util.js +121 -0
  98. package/dist/utility/chart/kscript-mounted-plot-set.leaf.d.ts +48 -0
  99. package/dist/utility/chart/kscript-mounted-plot-set.leaf.js +145 -0
  100. package/dist/utility/chart/kscript-perf-tracker.util.d.ts +243 -0
  101. package/dist/utility/chart/kscript-perf-tracker.util.js +522 -0
  102. package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +43 -0
  103. package/dist/utility/chart/kscript-run-interval-projection.util.js +471 -0
  104. package/dist/utility/chart/kscript-run-result-equality.util.d.ts +38 -0
  105. package/dist/utility/chart/kscript-run-result-equality.util.js +89 -0
  106. package/dist/utility/chart/kscript-settings-revision.leaf.d.ts +2 -0
  107. package/dist/utility/chart/kscript-settings-revision.leaf.js +12 -0
  108. package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +63 -0
  109. package/dist/utility/chart/kscript-source-degrade.leaf.js +68 -0
  110. package/dist/utility/chart/kscript-source-retention.util.d.ts +134 -0
  111. package/dist/utility/chart/kscript-source-retention.util.js +218 -0
  112. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +57 -0
  113. package/dist/utility/chart/kscript-standin-identity.leaf.js +61 -0
  114. package/dist/utility/chart/kscript-titancharts-preparation.util.d.ts +15 -0
  115. package/dist/utility/chart/kscript-titancharts-preparation.util.js +376 -0
  116. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +9 -0
  117. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +130 -0
  118. package/dist/utility/chart/kscript-venue-policy.util.d.ts +217 -0
  119. package/dist/utility/chart/kscript-venue-policy.util.js +324 -0
  120. package/dist/utility/chart/live-cadence.util.d.ts +38 -0
  121. package/dist/utility/chart/live-cadence.util.js +37 -0
  122. package/dist/utility/chart/live-feed-series-match.leaf.d.ts +13 -0
  123. package/dist/utility/chart/live-feed-series-match.leaf.js +21 -0
  124. package/dist/utility/chart/local-engine-self-heal-backoff.util.d.ts +46 -0
  125. package/dist/utility/chart/local-engine-self-heal-backoff.util.js +46 -0
  126. package/dist/utility/chart/local-engine-uninit.leaf.d.ts +21 -0
  127. package/dist/utility/chart/local-engine-uninit.leaf.js +22 -0
  128. package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +62 -0
  129. package/dist/utility/chart/local-kscript-source-revalidation.util.js +123 -0
  130. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +214 -0
  131. package/dist/utility/chart/local-kscript-warmup-depth.util.js +376 -0
  132. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.d.ts +85 -0
  133. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.js +197 -0
  134. package/dist/utility/chart/local-technical-script-range.leaf.d.ts +72 -0
  135. package/dist/utility/chart/local-technical-script-range.leaf.js +126 -0
  136. package/dist/utility/chart/mixed-mode.util.d.ts +167 -0
  137. package/dist/utility/chart/mixed-mode.util.js +139 -0
  138. package/dist/utility/chart/ohlcv-row-readiness.util.d.ts +36 -0
  139. package/dist/utility/chart/ohlcv-row-readiness.util.js +90 -0
  140. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +19 -0
  141. package/dist/utility/chart/opra-user-scripts-gate.util.js +32 -0
  142. package/dist/utility/chart/overlay-execution-guard-key.leaf.d.ts +8 -0
  143. package/dist/utility/chart/overlay-execution-guard-key.leaf.js +10 -0
  144. package/dist/utility/chart/price-precision.util.d.ts +40 -0
  145. package/dist/utility/chart/price-precision.util.js +70 -0
  146. package/dist/utility/chart/profile-block-size.util.d.ts +64 -0
  147. package/dist/utility/chart/profile-block-size.util.js +141 -0
  148. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.d.ts +11 -0
  149. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.js +29 -0
  150. package/dist/utility/chart/protected-kscript-empty-output.util.d.ts +28 -0
  151. package/dist/utility/chart/protected-kscript-empty-output.util.js +84 -0
  152. package/dist/utility/chart/run-interval-unservable.leaf.d.ts +9 -0
  153. package/dist/utility/chart/run-interval-unservable.leaf.js +20 -0
  154. package/dist/utility/chart/run-interval-warmup.leaf.d.ts +19 -0
  155. package/dist/utility/chart/run-interval-warmup.leaf.js +35 -0
  156. package/dist/utility/chart/titan-constants.pin.d.ts +9 -5
  157. package/dist/utility/chart/titan-constants.pin.js +18 -5
  158. package/dist/utility/chart/warmup-backfill-retry.leaf.d.ts +9 -0
  159. package/dist/utility/chart/warmup-backfill-retry.leaf.js +9 -0
  160. package/dist/utility/chart/window-geometry.leaf.d.ts +119 -0
  161. package/dist/utility/chart/window-geometry.leaf.js +391 -0
  162. package/dist/utility/chart/window-owner.leaf.d.ts +19 -0
  163. package/dist/utility/chart/window-owner.leaf.js +24 -0
  164. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +11 -2
  165. package/dist/utility/chart/wrun-bar-session-facts.util.js +10 -3
  166. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -1
  167. package/dist/utility/chart/wrun-run-result.util.js +20 -14
  168. package/dist/utility/common/data-processing.util.d.ts +138 -0
  169. package/dist/utility/common/data-processing.util.js +346 -0
  170. package/dist/utility/common/visible-timeout.util.d.ts +13 -4
  171. package/dist/utility/common/visible-timeout.util.js +23 -8
  172. package/dist/utility/exchange-format.leaf.d.ts +1 -0
  173. package/dist/utility/exchange-format.leaf.js +47 -0
  174. package/dist/utility/html-escape.leaf.d.ts +11 -0
  175. package/dist/utility/html-escape.leaf.js +20 -0
  176. package/dist/utility/market-events/earnings-scope.util.d.ts +60 -0
  177. package/dist/utility/market-events/earnings-scope.util.js +92 -0
  178. package/dist/utility/market-events/market-events.util.d.ts +147 -0
  179. package/dist/utility/market-events/market-events.util.js +392 -0
  180. package/dist/utility/market-events/zoned-clock.util.d.ts +1 -0
  181. package/dist/utility/market-events/zoned-clock.util.js +11 -0
  182. package/dist/utility/options/option-venue-disclosure.util.d.ts +43 -0
  183. package/dist/utility/options/option-venue-disclosure.util.js +56 -0
  184. package/dist/utility/scriptEditor/package-semver.util.d.ts +51 -0
  185. package/dist/utility/scriptEditor/package-semver.util.js +120 -0
  186. package/dist/utility/scriptEditor/temp-script-id.util.d.ts +18 -0
  187. package/dist/utility/scriptEditor/temp-script-id.util.js +25 -0
  188. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.d.ts +20 -0
  189. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.js +81 -0
  190. package/dist/utility/v2/governed-tier.leaf.d.ts +103 -0
  191. package/dist/utility/v2/governed-tier.leaf.js +113 -0
  192. package/dist/utility/watchlist/import/import-request.leaf.d.ts +10 -0
  193. package/dist/utility/watchlist/import/import-request.leaf.js +10 -0
  194. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +43 -15
  195. package/dist/utility/wrun/sources/lanes/option_daily.js +78 -20
  196. package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +14 -10
  197. package/dist/utility/wrun/sources/lanes/option_stats_10m.js +5 -4
  198. package/dist/utility/wrun/sources/lanes/series.js +2 -2
  199. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +22 -3
  200. package/dist/utility/wrun/sources/opra-option-lanes.util.js +38 -7
  201. package/dist/utility/wrun/sources/registry.js +31 -1
  202. package/dist/utility/wrun/sources/row-lane-registry.js +5 -5
  203. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +49 -0
  204. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +75 -20
  205. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +49 -0
  206. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +57 -47
  207. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +36 -4
  208. package/dist/utility/wrun/sources/row-lanes/option_surface.js +6 -12
  209. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +37 -3
  210. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +128 -2
  211. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +233 -51
  212. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +0 -8
  213. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +26 -24
  214. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +85 -104
  215. package/dist/utility/wrun/wrun-alert-outputs.registry.d.ts +166 -0
  216. package/dist/utility/wrun/wrun-alert-outputs.registry.js +219 -0
  217. package/dist/utility/wrun/wrun-bar-count.util.d.ts +83 -0
  218. package/dist/utility/wrun/wrun-bar-count.util.js +259 -0
  219. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +84 -0
  220. package/dist/utility/wrun/wrun-chart-context-names.util.js +186 -0
  221. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +253 -0
  222. package/dist/utility/wrun/wrun-chart-market-facts.util.js +731 -0
  223. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.d.ts +28 -0
  224. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.js +45 -0
  225. package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +18 -0
  226. package/dist/utility/wrun/wrun-coin-lane-live.util.js +47 -0
  227. package/dist/utility/wrun/wrun-deadline.util.js +2 -1
  228. package/dist/utility/wrun/wrun-debug-output.util.d.ts +39 -0
  229. package/dist/utility/wrun/wrun-debug-output.util.js +63 -0
  230. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +113 -0
  231. package/dist/utility/wrun/wrun-declared-warmup.util.js +181 -0
  232. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +43 -0
  233. package/dist/utility/wrun/wrun-draft-legend-note.util.js +158 -0
  234. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +181 -0
  235. package/dist/utility/wrun/wrun-draft-overlay.util.js +357 -0
  236. package/dist/utility/wrun/wrun-draw-skipped.leaf.d.ts +16 -0
  237. package/dist/utility/wrun/wrun-draw-skipped.leaf.js +16 -0
  238. package/dist/utility/wrun/wrun-earnings-facts.util.d.ts +42 -0
  239. package/dist/utility/wrun/wrun-earnings-facts.util.js +131 -0
  240. package/dist/utility/wrun/wrun-first-run-depth.util.d.ts +32 -0
  241. package/dist/utility/wrun/wrun-first-run-depth.util.js +118 -0
  242. package/dist/utility/wrun/wrun-gate-plane-readers.util.d.ts +24 -0
  243. package/dist/utility/wrun/wrun-gate-plane-readers.util.js +31 -0
  244. package/dist/utility/wrun/wrun-held-lanes.util.d.ts +32 -0
  245. package/dist/utility/wrun/wrun-held-lanes.util.js +94 -0
  246. package/dist/utility/wrun/wrun-host-visible-clock.util.d.ts +2 -0
  247. package/dist/utility/wrun/wrun-host-visible-clock.util.js +17 -0
  248. package/dist/utility/wrun/wrun-host.service.d.ts +266 -0
  249. package/dist/utility/wrun/wrun-host.service.js +655 -0
  250. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +33 -0
  251. package/dist/utility/wrun/wrun-inert-legend.util.js +125 -0
  252. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +155 -0
  253. package/dist/utility/wrun/wrun-input-requirements.leaf.js +450 -0
  254. package/dist/utility/wrun/wrun-integration-route.util.d.ts +51 -0
  255. package/dist/utility/wrun/wrun-integration-route.util.js +59 -0
  256. package/dist/utility/wrun/wrun-latest-history.leaf.d.ts +8 -0
  257. package/dist/utility/wrun/wrun-latest-history.leaf.js +8 -0
  258. package/dist/utility/wrun/wrun-legend-hover.lazy.d.ts +12 -0
  259. package/dist/utility/wrun/wrun-legend-hover.lazy.js +96 -0
  260. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +21 -0
  261. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +21 -0
  262. package/dist/utility/wrun/wrun-live-hidden-hold.util.d.ts +23 -0
  263. package/dist/utility/wrun/wrun-live-hidden-hold.util.js +13 -0
  264. package/dist/utility/wrun/wrun-live-intake.util.d.ts +374 -0
  265. package/dist/utility/wrun/wrun-live-intake.util.js +2027 -0
  266. package/dist/utility/wrun/wrun-live-patch.util.d.ts +116 -0
  267. package/dist/utility/wrun/wrun-live-patch.util.js +523 -0
  268. package/dist/utility/wrun/wrun-live-tick.util.d.ts +619 -0
  269. package/dist/utility/wrun/wrun-live-tick.util.js +4974 -0
  270. package/dist/utility/wrun/wrun-loading-owner.util.d.ts +58 -0
  271. package/dist/utility/wrun/wrun-loading-owner.util.js +89 -0
  272. package/dist/utility/wrun/wrun-official-scope.leaf.d.ts +29 -0
  273. package/dist/utility/wrun/wrun-official-scope.leaf.js +36 -0
  274. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +27 -0
  275. package/dist/utility/wrun/wrun-oi-lane.util.js +42 -0
  276. package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +29 -10
  277. package/dist/utility/wrun/wrun-opra-stats.leaf.js +29 -10
  278. package/dist/utility/wrun/wrun-options-stop.util.d.ts +52 -0
  279. package/dist/utility/wrun/wrun-options-stop.util.js +123 -0
  280. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +719 -0
  281. package/dist/utility/wrun/wrun-overlay-drivers.util.js +1180 -0
  282. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +50 -0
  283. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +131 -0
  284. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +118 -0
  285. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +466 -0
  286. package/dist/utility/wrun/wrun-overlay-metadata.util.d.ts +45 -0
  287. package/dist/utility/wrun/wrun-overlay-metadata.util.js +112 -0
  288. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +114 -0
  289. package/dist/utility/wrun/wrun-overlay-recovery.util.js +971 -0
  290. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +858 -0
  291. package/dist/utility/wrun/wrun-overlay-run.util.js +11013 -0
  292. package/dist/utility/wrun/wrun-panel-mount.lazy.d.ts +10 -0
  293. package/dist/utility/wrun/wrun-panel-mount.lazy.js +68 -0
  294. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +392 -0
  295. package/dist/utility/wrun/wrun-panel-mount.util.js +2346 -0
  296. package/dist/utility/wrun/wrun-param-map.util.d.ts +19 -4
  297. package/dist/utility/wrun/wrun-param-map.util.js +40 -47
  298. package/dist/utility/wrun/wrun-param-values.util.d.ts +9 -3
  299. package/dist/utility/wrun/wrun-param-values.util.js +5 -5
  300. package/dist/utility/wrun/wrun-pause-dim.util.d.ts +52 -0
  301. package/dist/utility/wrun/wrun-pause-dim.util.js +153 -0
  302. package/dist/utility/wrun/wrun-plot-gate.types.d.ts +23 -0
  303. package/dist/utility/wrun/wrun-plot-gate.types.js +7 -0
  304. package/dist/utility/wrun/wrun-prefix-cohort.util.d.ts +93 -0
  305. package/dist/utility/wrun/wrun-prefix-cohort.util.js +484 -0
  306. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +114 -0
  307. package/dist/utility/wrun/wrun-prefix-lanes.util.js +486 -0
  308. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +317 -0
  309. package/dist/utility/wrun/wrun-prefix-proof.util.js +630 -0
  310. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +73 -0
  311. package/dist/utility/wrun/wrun-refusal-surface.util.js +380 -0
  312. package/dist/utility/wrun/wrun-refusal-text.util.d.ts +15 -0
  313. package/dist/utility/wrun/wrun-refusal-text.util.js +40 -0
  314. package/dist/utility/wrun/wrun-replay-lane.util.d.ts +139 -0
  315. package/dist/utility/wrun/wrun-replay-lane.util.js +520 -0
  316. package/dist/utility/wrun/wrun-replay-rows.util.d.ts +21 -0
  317. package/dist/utility/wrun/wrun-replay-rows.util.js +172 -0
  318. package/dist/utility/wrun/wrun-row-source-factory.d.ts +53 -0
  319. package/dist/utility/wrun/wrun-row-source-factory.js +435 -0
  320. package/dist/utility/wrun/wrun-run-cells.util.d.ts +36 -0
  321. package/dist/utility/wrun/wrun-run-cells.util.js +46 -0
  322. package/dist/utility/wrun/wrun-run-interval-projection.types.d.ts +14 -0
  323. package/dist/utility/wrun/wrun-run-interval-projection.types.js +1 -0
  324. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +133 -0
  325. package/dist/utility/wrun/wrun-run-interval-session.util.js +121 -0
  326. package/dist/utility/wrun/wrun-run-interval.util.d.ts +98 -0
  327. package/dist/utility/wrun/wrun-run-interval.util.js +207 -0
  328. package/dist/utility/wrun/wrun-run-retained.util.d.ts +122 -0
  329. package/dist/utility/wrun/wrun-run-retained.util.js +255 -0
  330. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +184 -0
  331. package/dist/utility/wrun/wrun-sandbox-row-source.js +444 -0
  332. package/dist/utility/wrun/wrun-script-inputs.util.js +4 -4
  333. package/dist/utility/wrun/wrun-series-stream.util.d.ts +86 -0
  334. package/dist/utility/wrun/wrun-series-stream.util.js +537 -0
  335. package/dist/utility/wrun/wrun-sheet-remembered.util.d.ts +21 -0
  336. package/dist/utility/wrun/wrun-sheet-remembered.util.js +36 -0
  337. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.d.ts +7 -0
  338. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.js +12 -0
  339. package/dist/utility/wrun/wrun-socket-row-source.js +4 -2
  340. package/dist/utility/wrun/wrun-source-rows.util.d.ts +175 -3
  341. package/dist/utility/wrun/wrun-source-rows.util.js +294 -8
  342. package/dist/utility/wrun/wrun-stats-strip.util.d.ts +46 -0
  343. package/dist/utility/wrun/wrun-stats-strip.util.js +87 -0
  344. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +163 -0
  345. package/dist/utility/wrun/wrun-table-chrome.util.js +557 -0
  346. package/dist/utility/wrun/wrun-text-params.util.d.ts +11 -6
  347. package/dist/utility/wrun/wrun-text-params.util.js +19 -30
  348. package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +64 -0
  349. package/dist/utility/wrun/wrun-transient-rerun.util.js +317 -0
  350. package/dist/utility/wrun/wrun-twin-lookback.util.d.ts +10 -0
  351. package/dist/utility/wrun/wrun-twin-lookback.util.js +43 -0
  352. package/dist/utility/wrun/wrun-warmup-head-store.util.d.ts +41 -0
  353. package/dist/utility/wrun/wrun-warmup-head-store.util.js +120 -0
  354. package/dist/utility/wrun-alert-params.leaf.d.ts +24 -0
  355. package/dist/utility/wrun-alert-params.leaf.js +24 -0
  356. package/dist/utils/replay/replay-buffer-math.d.ts +148 -0
  357. package/dist/utils/replay/replay-buffer-math.js +684 -0
  358. package/dist/workers/wrun/wrun-abi-host.d.ts +190 -0
  359. package/dist/workers/wrun/wrun-abi-host.js +1201 -0
  360. package/dist/workers/wrun/wrun-engine-handler.d.ts +37 -0
  361. package/dist/workers/wrun/wrun-engine-handler.js +211 -0
  362. package/package.json +3 -3
@@ -0,0 +1,451 @@
1
+ /**
2
+ * kScript snippet helpers shared by every built-in template: the classic input set (source,
3
+ * timeframe, waitForClose), the candle and price series they read, the colour slot reader and the
4
+ * oscillator level / smoothing blocks. `technicalIndicatorScripts.constants.ts` (the classic
5
+ * built-ins) and `staples/*.constants.ts` (the TradingView staples) assemble their templates from
6
+ * these, so every built-in reads its inputs, candles and levels the same way. This module is
7
+ * i18n-free on purpose: the staple modules import it while the catalog module imports them, and a
8
+ * template module must never import the catalog.
9
+ */
10
+ /** Extra closed bars the oscillator smoothing (OSCILLATOR_SMOOTHING_INPUTS) adds to its oscillator's warm-up. */
11
+ export function oscillatorSmoothingWarmup(inputs) {
12
+ return inputs.str('smoothingType') === 'None' ? 0 : inputs.num('smoothingLength') - 1;
13
+ }
14
+ export const CLASSIC_TIMEFRAME_INPUTS = `var timeframe = input(name="timeframe", type="select", defaultValue="chart", options=["chart", "5m", "15m", "30m", "1h", "4h", "1D", "1W"]);
15
+ var waitForClose = input(name="waitForClose", type="boolean", defaultValue=true);`;
16
+ export const CLASSIC_PRICE_INPUTS = `var source = input(name="source", type="select", defaultValue="close", options=["close", "open", "high", "low"]);
17
+ ${CLASSIC_TIMEFRAME_INPUTS}`;
18
+ // field() auto-indexes a timeseries variable in 3.0.87. Passing the deduplicated
19
+ // source call directly retains its series value for the dynamic field selector.
20
+ export const CLASSIC_PRICE_SERIES = `timeseries data = ohlcv(symbol=currentSymbol, exchange=currentExchange);
21
+ timeseries price = timeframe == "chart" ? field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source) : htf(field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source), timeframe, {mode: waitForClose ? "confirmed" : "developing"});`;
22
+ // A conditional timeseries initializer stores one scalar unless given a row.
23
+ // Retain all candle fields and bypass HTF validation entirely in chart mode.
24
+ // Chart mode builds the row from the declared source's own fields: re-calling
25
+ // ohlcv() inside the initializer repeats a source lookup on every bar (quadratic,
26
+ // about 20 s at 10k bars) and candleValues(chartData) reads shifted rows.
27
+ export const CLASSIC_CANDLE_ROW = `func candleValues(bars) {
28
+ return [bars.open, bars.high, bars.low, bars.close, bars.volume];
29
+ }`;
30
+ export const CLASSIC_CANDLE_SERIES = `${CLASSIC_CANDLE_ROW}
31
+ timeseries chartData = ohlcv(symbol=currentSymbol, exchange=currentExchange);
32
+ timeseries data = timeframe == "chart" ? [chartData.open, chartData.high, chartData.low, chartData.close, chartData.volume] : candleValues(htf(chartData, timeframe, {mode: waitForClose ? "confirmed" : "developing"}));`;
33
+ // OHLCV-only builtins retain high/low/volume and use the selected price as close.
34
+ // The default close selection therefore preserves their existing formulas.
35
+ export const CLASSIC_SELECTED_CANDLES = `${CLASSIC_PRICE_SERIES}
36
+ ${CLASSIC_CANDLE_ROW}
37
+ timeseries candles = timeframe == "chart" ? [data.open, data.high, data.low, data.close, data.volume] : candleValues(htf(data, timeframe, {mode: waitForClose ? "confirmed" : "developing"}));
38
+ timeseries selectedCandles = [candles.open, candles.high, candles.low, price, candles.volume];`;
39
+ /**
40
+ * Reads slot `index` of a script's `colors` input as saved, alpha included. The chart completes
41
+ * every saved palette to the built-in's full slot list before a run (completeBuiltinPalette in
42
+ * builtin-script-theme-palette.util), so the first-slot fallback only covers a caller that hands a
43
+ * shorter one. Both branches read the input, so they share its colour type, which plot colour
44
+ * arrays require (a string-literal fallback needed an opacity() wrap, and opacity() forced full
45
+ * alpha and read most colour names as grey).
46
+ */
47
+ export function colorSlot(index) {
48
+ return `(colors.length > ${index} ? colors[${index}] : colors[0])`;
49
+ }
50
+ /** Level inputs shared by the bounded oscillators. */
51
+ export function oscillatorLevelInputs(overbought, oversold) {
52
+ return `var overbought = input(name="overbought", type="number", defaultValue=${overbought}, label="Overbought", group="Levels");
53
+ var oversold = input(name="oversold", type="number", defaultValue=${oversold}, label="Oversold", group="Levels");
54
+ var showZone = input(name="showZone", type="boolean", defaultValue=true, label="Zone", group="Levels");
55
+ var colorExtremes = input(name="colorExtremes", type="boolean", defaultValue=true, label="Color Extremes", group="Levels");`;
56
+ }
57
+ /** Colour slot of the oscillator line on a bar: 0 inside the levels, 1 overbought, 2 oversold. */
58
+ export function oscillatorExtremeIndex(value) {
59
+ return `colorExtremes ? (${value} > overbought ? 1 : ${value} < oversold ? 2 : 0) : 0`;
60
+ }
61
+ /**
62
+ * Dashed overbought / oversold levels, a dotted midline, and the zone between them shaded in the
63
+ * oscillator's own colour. The zone is a box drawn on the last bar from the first bar to well past
64
+ * the last one: drawings carry no alert output and no legend entry, and the last-bar box rolls back
65
+ * and redraws on live ticks.
66
+ */
67
+ export function oscillatorLevelsScript(zoneColor, midline) {
68
+ return `
69
+ // levels
70
+ var levelColor = opacity("#787B86", 70);
71
+ hline(value=overbought, color=levelColor, width=1, lineStyle="dashed");
72
+ hline(value=${midline}, color=levelColor, width=1, lineStyle="dotted");
73
+ hline(value=oversold, color=levelColor, width=1, lineStyle="dashed");
74
+ persist zoneStart = na;
75
+ if (isna(zoneStart)) {
76
+ zoneStart = data.time;
77
+ }
78
+ if (showZone && isLastBar && barIndex > 0) {
79
+ // The alpha rides in the fill colour: the chart's box renderer takes no separate fill opacity.
80
+ box.new(zoneStart, overbought, data.time[0] + 500 * (data.time[0] - data.time[1]), oversold, {fillColor: opacity(${zoneColor}, 6), borderWidth: 0});
81
+ }`;
82
+ }
83
+ export const OSCILLATOR_SMOOTHING_INPUTS = `var smoothingType = input(name="smoothingType", type="select", defaultValue="None", options=["None", "SMA", "SMA + Bollinger Bands", "EMA", "RMA", "WMA", "VWMA"], group="Smoothing");
84
+ var smoothingLength = input(name="smoothingLength", type="number", defaultValue=14, constraints={min: 1, step: 1}, group="Smoothing");
85
+ var bbStdDev = input(name="bbStdDev", type="number", defaultValue=2, constraints={min: 0, step: 0.1}, group="Smoothing");`;
86
+ export function oscillatorSmoothingScript(value, label, width, color) {
87
+ return `
88
+ // Retain oscillator history and the selected timeframe's volume for VWMA.
89
+ timeseries smoothingVolume = timeframe == "chart" ? data.volume : htf(data, timeframe, {mode: waitForClose ? "confirmed" : "developing"}).volume;
90
+ timeseries smoothingData = [${value}, ${value}, ${value}, ${value}, smoothingVolume];
91
+ if (smoothingType != "None") {
92
+ var smoothed = na;
93
+ if (smoothingType == "SMA" || smoothingType == "SMA + Bollinger Bands") {
94
+ smoothed = sma(source=smoothingData.close, period=smoothingLength);
95
+ } else if (smoothingType == "EMA") {
96
+ smoothed = ema(source=smoothingData.close, period=smoothingLength);
97
+ } else if (smoothingType == "RMA") {
98
+ smoothed = rma(source=smoothingData.close, period=smoothingLength);
99
+ } else if (smoothingType == "WMA") {
100
+ smoothed = wma(source=smoothingData.close, period=smoothingLength);
101
+ } else if (smoothingType == "VWMA") {
102
+ smoothed = vwma(source=smoothingData.close, period=smoothingLength);
103
+ }
104
+ plotLine(value=smoothed, width=${width}, colors=[${color}], smooth=smooth, label=["${label}"], desc=["${label}"]);
105
+ if (smoothingType == "SMA + Bollinger Bands") {
106
+ var deviation = bbStdDev * stdev(source=smoothingData.close, period=smoothingLength);
107
+ plotLine(value=smoothed + deviation, width=${width}, colors=[opacity(${color}, 45)], smooth=smooth, label=["Smoothing Upper Band"], desc=["Smoothing Upper Band"]);
108
+ plotLine(value=smoothed - deviation, width=${width}, colors=[opacity(${color}, 45)], smooth=smooth, label=["Smoothing Lower Band"], desc=["Smoothing Lower Band"]);
109
+ }
110
+ }`;
111
+ }
112
+ /*
113
+ * Selected-timeframe math (2026-10).
114
+ *
115
+ * `htf()` returns one row per CHART bar (each selected-timeframe value repeated), and every TA
116
+ * builtin windows over chart rows, so `sma(source=htf(...), period=9)` at 15m on a 1m chart
117
+ * averaged nine chart bars, mostly the same repeated 15m close. The blocks below keep a history of
118
+ * CLOSED selected-timeframe bars in persist state and run the math on it, plus the forming bar when
119
+ * waitForClose is off. Chart mode keeps the builtins untouched: a converted template behaves
120
+ * exactly as before on "chart". Everything the blocks declare starts with `htf`; `data`, `price`,
121
+ * `chartData` and `selectedCandles` keep their chart-mode meaning.
122
+ *
123
+ * A window indicator converts with one branch per output:
124
+ *
125
+ * ${CLASSIC_PRICE_INPUTS}
126
+ * ${HTF_PRICE_SERIES}
127
+ * ${htfHistory('htfPrices', 'htfClosedPrice', 'period')}
128
+ * var output = timeframe == "chart" ? sma(source=price, period=period) : htfAverage(${htfWindow('htfPrices', 'htfFormingPrice')}, period);
129
+ *
130
+ * A recursive one (EMA, RMA, Wilder) keeps its state with htfSmoothedState and reads the name:
131
+ *
132
+ * ${htfSmoothedState('htfEma', 'ema', 'htfClosedPrice', 'htfFormingPrice', 'period')}
133
+ * var output = timeframe == "chart" ? ema(source=price, period=period) : htfEma;
134
+ *
135
+ * Candle templates use HTF_CANDLE_SERIES and read htfClosedCandle.high[0] and friends (see the RSI
136
+ * and ATR templates in tests/constants/scriptEditor/htf-parity.spec.ts for a Wilder chain and a
137
+ * true range over closed candles). Per-bar work is linear: one push per closed bar, one pass over
138
+ * the window per read, and no htf() call outside init.
139
+ *
140
+ * Limits: htf() only sees loaded chart bars, so `period` closed selected-timeframe bars must sit
141
+ * inside the loaded history before a value appears (RSI(14) at 1h on a 1m chart needs 900+ bars).
142
+ * 1D / 1W use "the closed candle changed" as the boundary (their buckets follow the venue session on
143
+ * CME), so two identical consecutive daily candles would merge.
144
+ */
145
+ /**
146
+ * Window and step functions over a history array (oldest first). The window functions read the
147
+ * LAST `p` entries and return na unless all of them are finite, like the strict builtins (sma, wma,
148
+ * stdev, highest, lowest); htfSum skips na and accepts a short window, like sum(). The step
149
+ * functions mirror the engine's seeding (the plain average of the first `p` finite values) and its
150
+ * exact update arithmetic, so a converted template matches the builtin bit for bit.
151
+ */
152
+ export const HTF_WINDOW_FUNCS = `func htfAverage(values, p) {
153
+ if (values.length < p) {
154
+ return na;
155
+ }
156
+ var total = 0;
157
+ for (var k = values.length - p; k < values.length; k = k + 1) {
158
+ if (isna(values[k])) {
159
+ return na;
160
+ }
161
+ total = total + values[k];
162
+ }
163
+ return total / p;
164
+ }
165
+ func htfWeightedAverage(values, p) {
166
+ if (values.length < p) {
167
+ return na;
168
+ }
169
+ var total = 0;
170
+ var start = values.length - p;
171
+ for (var k = 0; k < p; k = k + 1) {
172
+ if (isna(values[start + k])) {
173
+ return na;
174
+ }
175
+ total = total + values[start + k] * (k + 1);
176
+ }
177
+ return total / (p * (p + 1) / 2);
178
+ }
179
+ func htfVolumeWeightedAverage(values, volumes, p) {
180
+ if (values.length < p || volumes.length < p) {
181
+ return na;
182
+ }
183
+ var numerator = 0;
184
+ var denominator = 0;
185
+ for (var k = 0; k < p; k = k + 1) {
186
+ var value = values[values.length - p + k];
187
+ var volume = volumes[volumes.length - p + k];
188
+ if (isna(value) || isna(volume)) {
189
+ return na;
190
+ }
191
+ numerator = numerator + value * volume;
192
+ denominator = denominator + volume;
193
+ }
194
+ return denominator == 0 ? na : numerator / denominator;
195
+ }
196
+ func htfStdev(values, p) {
197
+ var mean = htfAverage(values, p);
198
+ if (isna(mean)) {
199
+ return na;
200
+ }
201
+ var squares = 0;
202
+ for (var k = values.length - p; k < values.length; k = k + 1) {
203
+ var diff = values[k] - mean;
204
+ squares = squares + diff * diff;
205
+ }
206
+ return sqrt(squares / p);
207
+ }
208
+ func htfHighest(values, p) {
209
+ if (values.length < p) {
210
+ return na;
211
+ }
212
+ var best = na;
213
+ for (var k = values.length - p; k < values.length; k = k + 1) {
214
+ if (isna(values[k])) {
215
+ return na;
216
+ }
217
+ if (isna(best) || values[k] > best) {
218
+ best = values[k];
219
+ }
220
+ }
221
+ return best;
222
+ }
223
+ func htfLowest(values, p) {
224
+ if (values.length < p) {
225
+ return na;
226
+ }
227
+ var best = na;
228
+ for (var k = values.length - p; k < values.length; k = k + 1) {
229
+ if (isna(values[k])) {
230
+ return na;
231
+ }
232
+ if (isna(best) || values[k] < best) {
233
+ best = values[k];
234
+ }
235
+ }
236
+ return best;
237
+ }
238
+ func htfHighestOffset(values, p) {
239
+ if (values.length < p) {
240
+ return na;
241
+ }
242
+ var best = na;
243
+ var at = 0;
244
+ for (var k = values.length - p; k < values.length; k = k + 1) {
245
+ if (isna(values[k])) {
246
+ return na;
247
+ }
248
+ if (isna(best) || values[k] >= best) {
249
+ best = values[k];
250
+ at = k;
251
+ }
252
+ }
253
+ return at - (values.length - 1);
254
+ }
255
+ func htfLowestOffset(values, p) {
256
+ if (values.length < p) {
257
+ return na;
258
+ }
259
+ var best = na;
260
+ var at = 0;
261
+ for (var k = values.length - p; k < values.length; k = k + 1) {
262
+ if (isna(values[k])) {
263
+ return na;
264
+ }
265
+ if (isna(best) || values[k] <= best) {
266
+ best = values[k];
267
+ at = k;
268
+ }
269
+ }
270
+ return at - (values.length - 1);
271
+ }
272
+ func htfSum(values, p) {
273
+ var total = 0;
274
+ for (var k = max(0, values.length - p); k < values.length; k = k + 1) {
275
+ if (!isna(values[k])) {
276
+ total = total + values[k];
277
+ }
278
+ }
279
+ return total;
280
+ }
281
+ func htfValueBack(values, n) {
282
+ return values.length > n ? values[values.length - 1 - n] : na;
283
+ }
284
+ func htfEmaNext(previous, count, seedSum, value, p) {
285
+ if (isna(value) || count + 1 < p) {
286
+ return na;
287
+ }
288
+ if (count + 1 == p) {
289
+ return (seedSum + value) / p;
290
+ }
291
+ var alpha = 2 / (p + 1);
292
+ return value * alpha + previous * (1 - alpha);
293
+ }
294
+ func htfRmaNext(previous, count, seedSum, value, p) {
295
+ if (isna(value) || count + 1 < p) {
296
+ return na;
297
+ }
298
+ if (count + 1 == p) {
299
+ return (seedSum + value) / p;
300
+ }
301
+ return (previous * (p - 1) + value) / p;
302
+ }
303
+ func htfRsiOf(gain, loss) {
304
+ if (isna(gain) || isna(loss)) {
305
+ return na;
306
+ }
307
+ return loss == 0 ? 100 : 100 - 100 / (1 + gain / loss);
308
+ }`;
309
+ /**
310
+ * The selected timeframe's closed and forming candles, materialized ONCE at init (a direct htf()
311
+ * of the source runs in init; the "1Y" placeholder only keeps the calls valid in chart mode, which
312
+ * never reads them), and `htfClosed`: true on the chart bar right after a selected-timeframe bar
313
+ * closed. Rolling tokens compare the engine's own epoch-floor bucket of consecutive chart bars;
314
+ * calendar tokens (1D / 1W) fall back to "the closed candle changed". Requires the `timeframe`
315
+ * input (CLASSIC_TIMEFRAME_INPUTS).
316
+ */
317
+ export const HTF_SELECTED_TIMEFRAME = `${HTF_WINDOW_FUNCS}
318
+ timeseries htfBars = ohlcv(symbol=currentSymbol, exchange=currentExchange);
319
+ timeseries htfClosedCandle = htf(htfBars, timeframe == "chart" ? "1Y" : timeframe);
320
+ timeseries htfFormingCandle = htf(htfBars, timeframe == "chart" ? "1Y" : timeframe, {mode: "developing"});
321
+ var htfMs = timeframe == "1m" ? 60000 : timeframe == "3m" ? 180000 : timeframe == "5m" ? 300000 : timeframe == "15m" ? 900000 : timeframe == "30m" ? 1800000 : timeframe == "1h" ? 3600000 : timeframe == "2h" ? 7200000 : timeframe == "4h" ? 14400000 : timeframe == "6h" ? 21600000 : timeframe == "8h" ? 28800000 : timeframe == "12h" ? 43200000 : 0;
322
+ var htfBucketChanged = htfMs > 0 && barIndex > 0 && floor(htfBars.time[0] / htfMs) != floor(htfBars.time[1] / htfMs);
323
+ var htfCandleChanged = isna(htfClosedCandle.close[1]) || htfClosedCandle.close[0] != htfClosedCandle.close[1] || htfClosedCandle.open[0] != htfClosedCandle.open[1] || htfClosedCandle.high[0] != htfClosedCandle.high[1] || htfClosedCandle.low[0] != htfClosedCandle.low[1] || htfClosedCandle.volume[0] != htfClosedCandle.volume[1];
324
+ var htfClosed = timeframe != "chart" && !isna(htfClosedCandle.close[0]) && (htfMs > 0 ? htfBucketChanged : htfCandleChanged);`;
325
+ /**
326
+ * Candle templates: `data` is the chart's own candles in every mode (chart mode reads it exactly as
327
+ * CLASSIC_CANDLE_SERIES did), and the selected timeframe is read from htfClosedCandle /
328
+ * htfFormingCandle (`.high[0]`, `.volume[0]`, ...). Replaces CLASSIC_CANDLE_SERIES.
329
+ */
330
+ export const HTF_CANDLE_SERIES = `timeseries chartData = ohlcv(symbol=currentSymbol, exchange=currentExchange);
331
+ timeseries data = [chartData.open, chartData.high, chartData.low, chartData.close, chartData.volume];
332
+ ${HTF_SELECTED_TIMEFRAME}`;
333
+ /**
334
+ * Price templates: `data` and `price` as CLASSIC_PRICE_SERIES declares them in chart mode, plus
335
+ * the selected price read from the SELECTED candle (open / high / low / close of the closed and of
336
+ * the forming selected-timeframe bar). Requires CLASSIC_PRICE_INPUTS. Replaces CLASSIC_PRICE_SERIES.
337
+ */
338
+ export const HTF_PRICE_SERIES = `timeseries data = ohlcv(symbol=currentSymbol, exchange=currentExchange);
339
+ timeseries price = field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source);
340
+ ${HTF_SELECTED_TIMEFRAME}
341
+ var htfClosedPrice = source == "open" ? htfClosedCandle.open[0] : source == "high" ? htfClosedCandle.high[0] : source == "low" ? htfClosedCandle.low[0] : htfClosedCandle.close[0];
342
+ var htfFormingPrice = source == "open" ? htfFormingCandle.open[0] : source == "high" ? htfFormingCandle.high[0] : source == "low" ? htfFormingCandle.low[0] : htfFormingCandle.close[0];`;
343
+ /**
344
+ * OHLCV templates that use the selected price as close: `selectedCandles` as CLASSIC_SELECTED_CANDLES
345
+ * declares it in chart mode; the selected timeframe reads htfClosedCandle / htfFormingCandle with
346
+ * htfClosedPrice / htfFormingPrice as the close. Replaces CLASSIC_SELECTED_CANDLES.
347
+ */
348
+ export const HTF_SELECTED_CANDLES = `${HTF_PRICE_SERIES}
349
+ timeseries selectedCandles = [data.open, data.high, data.low, price, data.volume];`;
350
+ /**
351
+ * A persist history of `closedValue`, appended once per closed selected-timeframe bar (na values
352
+ * are skipped, so a derived value's warm-up leaves no hole) and capped at `cap` entries, oldest
353
+ * first. `cap` is a kScript expression (`period`, `period + 1`, `slowPeriod`). An offset history
354
+ * passes `keepNa`: one entry per closed bar, na included, so `htfValueBack(history, offset)` counts
355
+ * selected-timeframe bars like `series[offset]` and an undefined value stays undefined instead of
356
+ * repeating the bar before it.
357
+ */
358
+ export function htfHistory(name, closedValue, cap, keepNa = false) {
359
+ return `persist ${name} = [];
360
+ if (htfClosed${keepNa ? '' : ` && !isna(${closedValue})`}) {
361
+ ${name}.push(${closedValue});
362
+ if (${name}.length > ${cap}) {
363
+ ${name}.shift();
364
+ }
365
+ }`;
366
+ }
367
+ /**
368
+ * The values a window reads: the closed history alone when waitForClose is on, the history plus
369
+ * `formingValue` (the forming selected-timeframe bar) when it is off.
370
+ */
371
+ export function htfWindow(history, formingValue) {
372
+ return `(waitForClose ? ${history} : ${history}.concat([${formingValue}]))`;
373
+ }
374
+ /**
375
+ * Recursive smoothing (EMA or RMA / Wilder) over closed selected-timeframe values. Declares the
376
+ * persist state (`<name>Closed`, `<name>Count`, `<name>Seed`), steps it once per closed bar with
377
+ * `closedValue`, and declares `var <name>`: the committed value when waitForClose is on, otherwise
378
+ * a provisional step with `formingValue` that is never committed. `closedValue` must be finite once
379
+ * it starts (leading na only), like the builtins' own seeding. Chain them by feeding one state's
380
+ * `<name>Closed` / `<name>` into the next (MACD's signal line, ATR from a true range).
381
+ */
382
+ export function htfSmoothedState(name, kind, closedValue, formingValue, period) {
383
+ const next = kind === 'ema' ? 'htfEmaNext' : 'htfRmaNext';
384
+ return `persist ${name}Closed = na;
385
+ persist ${name}Count = 0;
386
+ persist ${name}Seed = 0;
387
+ if (htfClosed && !isna(${closedValue})) {
388
+ ${name}Closed = ${next}(${name}Closed, ${name}Count, ${name}Seed, ${closedValue}, ${period});
389
+ ${name}Seed = ${name}Seed + ${closedValue};
390
+ ${name}Count = ${name}Count + 1;
391
+ }
392
+ var ${name} = waitForClose ? ${name}Closed : ${next}(${name}Closed, ${name}Count, ${name}Seed, ${formingValue}, ${period});`;
393
+ }
394
+ /**
395
+ * oscillatorSmoothingScript for a converted oscillator: chart mode smooths `value` with the
396
+ * builtins exactly as before; the selected timeframe smooths the oscillator's own closed values
397
+ * (`closedValue`, read on the bar a selected-timeframe bar closed) plus `formingValue` when
398
+ * waitForClose is off, weighted by the selected timeframe's volume for VWMA. Requires
399
+ * OSCILLATOR_SMOOTHING_INPUTS and one of the HTF_*_SERIES blocks.
400
+ */
401
+ export function htfOscillatorSmoothingScript(value, closedValue, formingValue, label, width, color) {
402
+ return `
403
+ // Retain oscillator history; the selected timeframe keeps its own closed values and volumes.
404
+ timeseries smoothingData = [${value}, ${value}, ${value}, ${value}, data.volume];
405
+ persist htfSmoothValues = [];
406
+ persist htfSmoothVolumes = [];
407
+ if (htfClosed && !isna(${closedValue})) {
408
+ htfSmoothValues.push(${closedValue});
409
+ htfSmoothVolumes.push(htfClosedCandle.volume[0]);
410
+ if (htfSmoothValues.length > smoothingLength) {
411
+ htfSmoothValues.shift();
412
+ htfSmoothVolumes.shift();
413
+ }
414
+ }
415
+ var htfSmoothWindow = ${htfWindow('htfSmoothValues', formingValue)};
416
+ var htfSmoothVolumeWindow = ${htfWindow('htfSmoothVolumes', 'htfFormingCandle.volume[0]')};
417
+ ${htfSmoothedState('htfSmoothEma', 'ema', closedValue, formingValue, 'smoothingLength')}
418
+ ${htfSmoothedState('htfSmoothRma', 'rma', closedValue, formingValue, 'smoothingLength')}
419
+ if (smoothingType != "None") {
420
+ var smoothed = na;
421
+ if (timeframe != "chart") {
422
+ if (smoothingType == "SMA" || smoothingType == "SMA + Bollinger Bands") {
423
+ smoothed = htfAverage(htfSmoothWindow, smoothingLength);
424
+ } else if (smoothingType == "EMA") {
425
+ smoothed = htfSmoothEma;
426
+ } else if (smoothingType == "RMA") {
427
+ smoothed = htfSmoothRma;
428
+ } else if (smoothingType == "WMA") {
429
+ smoothed = htfWeightedAverage(htfSmoothWindow, smoothingLength);
430
+ } else if (smoothingType == "VWMA") {
431
+ smoothed = htfVolumeWeightedAverage(htfSmoothWindow, htfSmoothVolumeWindow, smoothingLength);
432
+ }
433
+ } else if (smoothingType == "SMA" || smoothingType == "SMA + Bollinger Bands") {
434
+ smoothed = sma(source=smoothingData.close, period=smoothingLength);
435
+ } else if (smoothingType == "EMA") {
436
+ smoothed = ema(source=smoothingData.close, period=smoothingLength);
437
+ } else if (smoothingType == "RMA") {
438
+ smoothed = rma(source=smoothingData.close, period=smoothingLength);
439
+ } else if (smoothingType == "WMA") {
440
+ smoothed = wma(source=smoothingData.close, period=smoothingLength);
441
+ } else if (smoothingType == "VWMA") {
442
+ smoothed = vwma(source=smoothingData.close, period=smoothingLength);
443
+ }
444
+ plotLine(value=smoothed, width=${width}, colors=[${color}], smooth=smooth, label=["${label}"], desc=["${label}"]);
445
+ if (smoothingType == "SMA + Bollinger Bands") {
446
+ var deviation = bbStdDev * (timeframe == "chart" ? stdev(source=smoothingData.close, period=smoothingLength) : htfStdev(htfSmoothWindow, smoothingLength));
447
+ plotLine(value=smoothed + deviation, width=${width}, colors=[opacity(${color}, 45)], smooth=smooth, label=["Smoothing Upper Band"], desc=["Smoothing Upper Band"]);
448
+ plotLine(value=smoothed - deviation, width=${width}, colors=[opacity(${color}, 45)], smooth=smooth, label=["Smoothing Lower Band"], desc=["Smoothing Lower Band"]);
449
+ }
450
+ }`;
451
+ }
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Official kScript curation for governed CME futures.
3
+ *
4
+ * Native official catalog rows (script_id === registry type: VWAP,
5
+ * ORDERBOOK_HEATMAP, ...) ride the native availability gates
6
+ * (cme-indicator-availability.util) and never consult this file. This file
7
+ * classifies OFFICIAL SCRIPT rows only: the technical-indicator pack
8
+ * (registry subTypes riding TECHNICAL_SCRIPT, e.g. RSI, Volume Bubbles) and
9
+ * backend-doc officials (catalog rows with a mongo script_id and no registry
10
+ * presence, e.g. Order Book Pressure), matched by EXACT identity only.
11
+ *
12
+ * Adjudicated 2026-07-28 (Kyle): allowed = Volume Bubbles and Order Book
13
+ * Pressure, pinned by EXACT identity only. Title-slug matching was removed
14
+ * the same day: titles are author-controlled, so a slug both enabled a
15
+ * community lookalike in the picker and could never be a safe basis for the
16
+ * venue wall. Anchored VWAP and Key Levels were parked until their docs
17
+ * republished with open code, and re-enabled 2026-07-29 (see the allow-list
18
+ * comment).
19
+ * The classic TA pack was held "coming soon" while the engine's
20
+ * continuous-grid timeline produced NaN defects across CME session gaps
21
+ * (recursive builtins poisoned permanently after a gap, windowed ones holed
22
+ * after every nightly break). Flipped to allowed 2026-07-29 against the
23
+ * sparse-timeline engine (3.0.72): every pack script is run over a
24
+ * session-gapped timeline by tests/constants/scriptEditor/
25
+ * cme-ta-pack-sparse-timeline.spec.ts, which must stay green across engine
26
+ * bumps or the pack returns here. Everything else
27
+ * official (funding / OI / liquidation / spot-vs-perp flow concepts) is
28
+ * crypto-only on CME and reads "not available".
29
+ *
30
+ * Community scripts are deliberately OUT of scope: user-script blocking on
31
+ * governed venues is the kScript venue-policy wall (MR !4881), keyed on run
32
+ * provenance, not this curation. A proper server-side per-venue field on the
33
+ * catalog doc would obsolete the id pinning here.
34
+ */
35
+ export type CmeOfficialScriptVerdict = 'allowed' | 'coming-soon' | 'blocked';
36
+ /**
37
+ * The 2026-09-02 indicator-library batch (56 openmarket catalog docs: volatility,
38
+ * statistics, technical, market-analysis and volume-profile families), enabled on
39
+ * governed CME 2026-09-07 (Kyle). Venue-safe by construction: every pinned source
40
+ * reads only the chart's own symbol/exchange OHLCV (two through htf()), no
41
+ * crypto-fixed source, no second venue. The four library docs that pull a second
42
+ * symbol with crypto/equity defaults (Cointegration Spread, Sharpe Ratio,
43
+ * Ascending Base, and Correlation Coefficient since 2026-10-13 by Kyle's call:
44
+ * its default comparison is Binance ETHUSDT, which a governed chart cannot
45
+ * fetch, so both forms drew blank there) stay fail-closed. The VERBATIM published sources are pinned
46
+ * under src/fixtures/cme-official-library/ and adjudicated on the session-gapped
47
+ * timeline by tests/constants/scriptEditor/cme-official-library-sparse-timeline.spec.ts,
48
+ * which cross-pins this list against that manifest: an id cannot sit here without
49
+ * a pinned source, and a republish that changes an executable line must be
50
+ * re-adjudicated there before the id keeps its place. Spread into BOTH lists
51
+ * below: the picker curation (venue-appropriate) and the first-party wall
52
+ * (governed-data access), the same standing the launch docs hold.
53
+ */
54
+ export declare const CME_OFFICIAL_LIBRARY_DOC_IDS: readonly string[];
55
+ /**
56
+ * Registry subTypes / catalog script_ids allowed on CME today (exact identities only).
57
+ *
58
+ * Anchored VWAP and Key Levels re-enabled 2026-07-29 after Kyle republished both docs with
59
+ * OPEN code (client-side first-party run; wire-verified delivered source). Their catalog rows
60
+ * surface on CME once the docs' catalog `source` flips to 'official' (the governed picker
61
+ * queries officials only); until then they are runnable-but-unlisted there.
62
+ */
63
+ export declare const CME_ALLOWED_OFFICIAL_SCRIPT_KEYS: readonly string[];
64
+ /**
65
+ * Officials queued behind a known blocker (empty since the TA pack un-Soon;
66
+ * kept so the next queued official has a home and the resolver keeps its
67
+ * three-verdict shape).
68
+ */
69
+ export declare const CME_COMING_SOON_OFFICIAL_SCRIPT_KEYS: readonly string[];
70
+ /**
71
+ * Bundled templates deliberately held OFF governed CME: they read 'blocked'
72
+ * through the fail-closed default (the picker says "not available", never
73
+ * "Soon"), and this list exists so the curation spec can tell a deliberate
74
+ * hold from a template nobody classified.
75
+ * - ZIGZAG: draws lines and labels only, so the sparse-timeline proof (which
76
+ * asserts plotted series) cannot adjudicate it yet.
77
+ * - PIVOT_POINTS: its pivots come from UTC calendar periods (1D / 1W / 1M
78
+ * backings), which do not line up with CME trading sessions.
79
+ */
80
+ export declare const CME_HELD_OFFICIAL_SCRIPT_KEYS: readonly string[];
81
+ /**
82
+ * The built-ins whose PROVEN wrun twin (wrun-twins.json `proven`) is also proven on a governed CME
83
+ * chart: on CME a new add of one of them mounts the twin at its pin, as on every other venue
84
+ * (provenBuiltInTwin, wrun-twins.util), and a twin carried onto CME (a symbol switch, a restore, a
85
+ * paste or copy) keeps drawing (isKScriptDisplayBlockedOnExchange). Every other built-in keeps its
86
+ * kScript template on CME, and its twin stays walled there. Each key is a CME-allowed built-in
87
+ * (CME_ALLOWED_OFFICIAL_SCRIPT_KEYS) with a proven pin; the roster spec holds both.
88
+ *
89
+ * Proven 2026-10-11 on CME ES1! against the template, twin and template mounted through the
90
+ * Indicators dialog: the parity sweep's data, dialog and host layers at 1h and its data layer at 1D
91
+ * and 1W, every finding the same as the pair's crypto proof (ADX's extra Price line is the
92
+ * template's fill drawn at its colour index, price 0, which its lower pane shows on ES), and the
93
+ * coarser Timeframes at the chart interval's values (WRUN-QA-1005/returns/CME-WRUN.md). VOLUME_BAR
94
+ * and BAR_STATISTICS joined 2026-10-13 once their twins (0.3.3, 0.1.2) read the kit's size units
95
+ * (market.size_unit(), market.notional(): crypto bit-identical, Coin mode equal to the template on
96
+ * CME, USD mode priced with the point value, the crypto-only rows closed; SESSION-evidence/units-*.md).
97
+ * BIG_TRADES joined the same day by Kyle's rule: its twin counts prints in native size like the
98
+ * template (a live-session proof waits for a rig that carries the CME trade tape). VOLUME_BUBBLES joined
99
+ * 2026-10-13 with 0.2.4: its profile lane reads `currency: "Auto"` (the host picks the contract profile on a
100
+ * contracts market), floors in 1K contracts and drops the "$" there: 227,435/227,435 bubbles equal to the
101
+ * template on ES facts (SESSION-evidence/units-p-bubbles.md). Every CME-allowed built-in routes on CME now.
102
+ */
103
+ export declare const CME_PROVEN_TWIN_BUILTIN_KEYS: readonly string[];
104
+ /** Whether a shipped built-in's proven twin may route and draw on a governed CME chart
105
+ * (CME_PROVEN_TWIN_BUILTIN_KEYS). */
106
+ export declare function isCmeProvenTwinBuiltIn(builtInKey: string): boolean;
107
+ /**
108
+ * The official kScript DOCS (Mongo-id catalog rows, never a shipped built-in) whose wrun port is also proven on a
109
+ * governed CME chart: on CME such a doc lists once, as its port, and every Add of it mounts the package, as on every
110
+ * other venue (officialDocPort, wrun-official-doc-port.util). Every other doc keeps its kScript record on CME. Each id
111
+ * is a CME-allowed doc (CME_ALLOWED_OFFICIAL_SCRIPT_KEYS) with a roster row (wrun-twins.json); the roster spec holds
112
+ * both. A port carried onto CME (a symbol switch, a restore, a paste or copy) is not walled by this list: official
113
+ * packages are venue-approved as a class (isKScriptDisplayBlockedOnExchange, the 2026-09-30 exemption).
114
+ *
115
+ * Proven 2026-10-11 on CME ES1! against the kScript doc, both mounted on the same chart: the parity sweep's data,
116
+ * dialog and host layers at 1h and, for the session and calendar docs, its data layer at 1D and 1W, every finding
117
+ * judged against the doc's crypto proof and a same-build crypto control (WRUN-QA-1005/returns/CME-DOCS.md). Every
118
+ * CME-allowed doc with a port routes here since 2026-10-13. Timeframe Matrix joined last, once its port took the
119
+ * newest 18 candles by count and the kit host handed over the session's final higher-timeframe candle (0.1.3,
120
+ * kit 0.68.1): 18 candles in every panel with the doc's change badges on a live and a closed-market run
121
+ * (SESSION-evidence/units-tfm.md). Kelly Criterion joined 2026-10-13: its one
122
+ * hourly difference is the doc's band edge placed inside closed hours (218/218 boxes, 437/437 cells agree).
123
+ * Correlation Coefficient is fail-closed on CME in both forms since 2026-10-13 (CME_OFFICIAL_LIBRARY_DOC_IDS).
124
+ * Anchored VWAP joined 2026-10-13 once its port 0.1.8 anchored the day at the venue trade-day open
125
+ * (market.session_open(), kit 0.65.0; hosted runs admit it since contracts 5.24.0): 394/394 daily cells equal to
126
+ * the doc on CME ES1! (SESSION-evidence/p1-lane.md). Thirteen docs whose kScript doc places box and line edges inside the daily break and the weekend (its edge
127
+ * arithmetic counts closed hours as bars) route by Kyle's decision of 2026-10-12: the port draws on the traded bars and
128
+ * finds the same patterns (SESSION-evidence/p-prep.md). Structure Shift Sweeps and Wave Extensions joined 2026-10-12
129
+ * once their ports read the chart interval from the host instead of latching it from the first two bars (0.2.1 / 0.2.2),
130
+ * re-proven on CME ES1! at 1h and 1D against the same control. Equal Highs/Lows FVG Breakouts joined the same day by
131
+ * Kyle's rule: where the two forms differ because the kScript doc is the defective one, the port routes. Five docs whose
132
+ * only CME-side difference was a chart switch acting on one form (All intervals, Hide weekends, Price line,
133
+ * Interpolation) route by the same decision; the dead switches are tracked apart from the route.
134
+ */
135
+ export declare const CME_PROVEN_TWIN_DOC_IDS: readonly string[];
136
+ /** Whether an official kScript doc's port may route on a governed CME chart (CME_PROVEN_TWIN_DOC_IDS). */
137
+ export declare function isCmeProvenTwinDoc(scriptId: string): boolean;
138
+ /**
139
+ * Classify one official script for CME. `keys` are the entry's stable
140
+ * identities (registry subType, officialType, catalog script_id). Display
141
+ * titles are deliberately NOT an input: they are author-controlled, so a
142
+ * community lookalike named after an allowed official must never classify as
143
+ * allowed. Fail-closed: an unrecognized official reads 'blocked', so a newly
144
+ * published official ships CME-disabled until deliberately added here.
145
+ */
146
+ export declare function classifyOfficialScriptForCme(ref: {
147
+ keys?: readonly (string | undefined)[];
148
+ }): CmeOfficialScriptVerdict;
149
+ /**
150
+ * Official catalog-doc ids the venue-policy wall treats as FIRST PARTY for governed data.
151
+ * Deliberately a SEPARATE list from CME_ALLOWED_OFFICIAL_SCRIPT_KEYS: the picker list answers
152
+ * "is this indicator venue-appropriate on CME?", this one answers "is this code first-party?"
153
+ * — membership here mints governed-data access at EVERY door (fetch, payload guard, engine
154
+ * policy, layout/suite, alerts), so an id must only be added for docs authored by the official
155
+ * account. Registry subTypes (e.g. VOLUME_BUBBLES) never belong here; they are first-party via
156
+ * TECHNICAL_INDICATOR_SCRIPT_KEY_SET already.
157
+ */
158
+ export declare const CME_FIRST_PARTY_OFFICIAL_DOC_IDS: readonly string[];
159
+ /**
160
+ * Whether a run's `customScriptId` names a first-party official doc. The venue-policy wall
161
+ * consults this so a curated official passes the governed-data doors even when a mount's
162
+ * provenance breadcrumbs (scriptSource / transient scriptData) have not landed on the overlay
163
+ * settings yet — the shipped Order Book Pressure failure: Door F admitted the add, then the
164
+ * first fetch hit Door D before any stamp existed and suppressed the run as a user script.
165
+ * Spoof surface is unchanged: the id names WHICH DOC runs, and forks/lookalikes carry their
166
+ * own ids.
167
+ */
168
+ export declare function isCmeFirstPartyOfficialDocId(key: unknown): boolean;