@orangecharts/wrun-chart-host 0.1.0 → 0.3.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 (337) hide show
  1. package/README.md +39 -6
  2. package/dist/constants/common.constants.d.ts +15 -0
  3. package/dist/constants/common.constants.js +23 -0
  4. package/dist/constants/data-source.constants.d.ts +1 -0
  5. package/dist/constants/data-source.constants.js +1 -0
  6. package/dist/constants/economic.constants.d.ts +39 -0
  7. package/dist/constants/economic.constants.js +77 -0
  8. package/dist/constants/etf-covered-coins.constants.d.ts +1 -0
  9. package/dist/constants/etf-covered-coins.constants.js +9 -0
  10. package/dist/constants/feature-flags.constants.d.ts +60 -0
  11. package/dist/constants/feature-flags.constants.js +308 -0
  12. package/dist/constants/feature-limits.constants.d.ts +134 -0
  13. package/dist/constants/feature-limits.constants.js +155 -0
  14. package/dist/constants/marketCapabilities.constants.d.ts +87 -0
  15. package/dist/constants/marketCapabilities.constants.js +213 -0
  16. package/dist/constants/option-venues.constants.d.ts +100 -0
  17. package/dist/constants/option-venues.constants.js +167 -0
  18. package/dist/constants/overlay-data.constants.d.ts +53 -0
  19. package/dist/constants/overlay-data.constants.js +80 -0
  20. package/dist/constants/pane-grid.constants.d.ts +15 -0
  21. package/dist/constants/pane-grid.constants.js +17 -0
  22. package/dist/constants/venue-presets.constants.d.ts +10 -0
  23. package/dist/constants/venue-presets.constants.js +22 -0
  24. package/dist/enums/chart.enum.d.ts +68 -0
  25. package/dist/enums/chart.enum.js +70 -0
  26. package/dist/helpers/data.helpers.d.ts +2 -0
  27. package/dist/helpers/data.helpers.js +14 -0
  28. package/dist/host-env.d.ts +161 -5
  29. package/dist/host-ports.types.d.ts +446 -0
  30. package/dist/host-ports.types.js +1 -0
  31. package/dist/index.d.ts +131 -0
  32. package/dist/index.js +131 -0
  33. package/dist/indicators/controls/technical-script/technical-script-input-rendering.d.ts +86 -0
  34. package/dist/indicators/controls/technical-script/technical-script-input-rendering.js +179 -0
  35. package/dist/interfaces/asset-venue.interface.d.ts +91 -0
  36. package/dist/interfaces/asset-venue.interface.js +1 -0
  37. package/dist/interfaces/cancel-reason.interface.d.ts +24 -0
  38. package/dist/interfaces/cancel-reason.interface.js +2 -0
  39. package/dist/interfaces/catalog-display.interface.d.ts +3 -0
  40. package/dist/interfaces/catalog-display.interface.js +1 -0
  41. package/dist/interfaces/cme-realtime.interface.d.ts +251 -0
  42. package/dist/interfaces/cme-realtime.interface.js +46 -0
  43. package/dist/interfaces/feed.interface.d.ts +80 -0
  44. package/dist/interfaces/feed.interface.js +7 -0
  45. package/dist/interfaces/market-kind.interface.d.ts +8 -0
  46. package/dist/interfaces/market-kind.interface.js +1 -0
  47. package/dist/interfaces/opra-realtime.interface.d.ts +224 -0
  48. package/dist/interfaces/opra-realtime.interface.js +105 -0
  49. package/dist/interfaces/option-instrument.interface.d.ts +32 -0
  50. package/dist/interfaces/option-instrument.interface.js +1 -0
  51. package/dist/interfaces/options-chain-scope.interface.d.ts +29 -0
  52. package/dist/interfaces/options-chain-scope.interface.js +7 -0
  53. package/dist/interfaces/prediction-market.interface.d.ts +88 -0
  54. package/dist/interfaces/prediction-market.interface.js +8 -0
  55. package/dist/interfaces/wrun-runtime.interface.d.ts +5 -0
  56. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +185 -0
  57. package/dist/kscript-data/controls/live-trades-merge.util.js +357 -0
  58. package/dist/settings-templates/frvp-fields.d.ts +27 -0
  59. package/dist/settings-templates/frvp-fields.js +108 -0
  60. package/dist/settings-templates/index.d.ts +119 -0
  61. package/dist/settings-templates/index.js +442 -0
  62. package/dist/settings-templates/indicator-fields.d.ts +56 -0
  63. package/dist/settings-templates/indicator-fields.js +793 -0
  64. package/dist/settings-templates/tool-rules.d.ts +59 -0
  65. package/dist/settings-templates/tool-rules.js +49 -0
  66. package/dist/settings-templates/tool-tables.generated.d.ts +2 -0
  67. package/dist/settings-templates/tool-tables.generated.js +1668 -0
  68. package/dist/utility/blk-market.util.d.ts +5 -0
  69. package/dist/utility/blk-market.util.js +12 -0
  70. package/dist/utility/chart/chart-load-phase.util.d.ts +32 -0
  71. package/dist/utility/chart/chart-load-phase.util.js +78 -0
  72. package/dist/utility/chart/cme-cache-context.util.d.ts +108 -0
  73. package/dist/utility/chart/cme-cache-context.util.js +166 -0
  74. package/dist/utility/chart/cme-session-bucket.util.d.ts +82 -0
  75. package/dist/utility/chart/cme-session-bucket.util.js +343 -0
  76. package/dist/utility/chart/cme-trade-calendar.util.d.ts +26 -0
  77. package/dist/utility/chart/cme-trade-calendar.util.js +147 -0
  78. package/dist/utility/chart/continuous-contracts.util.d.ts +138 -0
  79. package/dist/utility/chart/continuous-contracts.util.js +374 -0
  80. package/dist/utility/chart/feed-interval.util.d.ts +119 -0
  81. package/dist/utility/chart/feed-interval.util.js +321 -0
  82. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +110 -0
  83. package/dist/utility/chart/fetch-dedupe-policy.util.js +407 -0
  84. package/dist/utility/chart/footprint-band.util.d.ts +76 -0
  85. package/dist/utility/chart/footprint-band.util.js +205 -0
  86. package/dist/utility/chart/footprint-cell-identity.util.d.ts +82 -0
  87. package/dist/utility/chart/footprint-cell-identity.util.js +346 -0
  88. package/dist/utility/chart/formula-calendar.util.d.ts +27 -0
  89. package/dist/utility/chart/formula-calendar.util.js +59 -0
  90. package/dist/utility/chart/history-wall.util.d.ts +67 -0
  91. package/dist/utility/chart/history-wall.util.js +87 -0
  92. package/dist/utility/chart/index-mode.util.d.ts +66 -0
  93. package/dist/utility/chart/index-mode.util.js +360 -0
  94. package/dist/utility/chart/indicator-coverage-planner.util.d.ts +217 -0
  95. package/dist/utility/chart/indicator-coverage-planner.util.js +443 -0
  96. package/dist/utility/chart/indicator-coverage-state.util.d.ts +33 -0
  97. package/dist/utility/chart/indicator-coverage-state.util.js +110 -0
  98. package/dist/utility/chart/indicator-gap-detector.util.d.ts +127 -0
  99. package/dist/utility/chart/indicator-gap-detector.util.js +260 -0
  100. package/dist/utility/chart/indicator-gap-repair.util.d.ts +88 -0
  101. package/dist/utility/chart/indicator-gap-repair.util.js +177 -0
  102. package/dist/utility/chart/indicator-inflight-registry.util.d.ts +26 -0
  103. package/dist/utility/chart/indicator-inflight-registry.util.js +254 -0
  104. package/dist/utility/chart/interval-registry.util.d.ts +23 -0
  105. package/dist/utility/chart/interval-registry.util.js +83 -0
  106. package/dist/utility/chart/kscript-main-grid-stages.util.d.ts +21 -0
  107. package/dist/utility/chart/kscript-main-grid-stages.util.js +332 -0
  108. package/dist/utility/chart/legacy-exchange.leaf.d.ts +11 -0
  109. package/dist/utility/chart/legacy-exchange.leaf.js +43 -0
  110. package/dist/utility/chart/live-bucket.util.d.ts +66 -0
  111. package/dist/utility/chart/live-bucket.util.js +165 -0
  112. package/dist/utility/chart/market-session-schedule.util.d.ts +91 -0
  113. package/dist/utility/chart/market-session-schedule.util.js +337 -0
  114. package/dist/utility/chart/marketKind.util.d.ts +181 -0
  115. package/dist/utility/chart/marketKind.util.js +371 -0
  116. package/dist/utility/chart/om-panel.util.js +6 -0
  117. package/dist/utility/chart/om-widget.util.d.ts +4 -0
  118. package/dist/utility/chart/opra-read-access.leaf.d.ts +26 -0
  119. package/dist/utility/chart/opra-read-access.leaf.js +25 -0
  120. package/dist/utility/chart/prediction-identity.util.d.ts +159 -0
  121. package/dist/utility/chart/prediction-identity.util.js +236 -0
  122. package/dist/utility/chart/rth-session.util.d.ts +352 -0
  123. package/dist/utility/chart/rth-session.util.js +926 -0
  124. package/dist/utility/chart/titan-constants.pin.d.ts +43 -0
  125. package/dist/utility/chart/titan-constants.pin.js +50 -0
  126. package/dist/utility/chart/us-equities-session.util.d.ts +127 -0
  127. package/dist/utility/chart/us-equities-session.util.js +251 -0
  128. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +100 -0
  129. package/dist/utility/chart/wrun-bar-session-facts.util.js +354 -0
  130. package/dist/utility/chart/wrun-run-result.util.js +10 -0
  131. package/dist/utility/chart/wrun-wire-ref.util.d.ts +23 -0
  132. package/dist/utility/chart/wrun-wire-ref.util.js +16 -0
  133. package/dist/utility/common/safe-math-eval.d.ts +18 -0
  134. package/dist/utility/common/safe-math-eval.js +160 -0
  135. package/dist/utility/common/time.util.d.ts +134 -0
  136. package/dist/utility/common/time.util.js +428 -0
  137. package/dist/utility/common/transformations.util.d.ts +126 -0
  138. package/dist/utility/common/transformations.util.js +711 -0
  139. package/dist/utility/common/visible-timeout.util.d.ts +17 -0
  140. package/dist/utility/common/visible-timeout.util.js +75 -0
  141. package/dist/utility/exchange-normalization.util.d.ts +8 -0
  142. package/dist/utility/exchange-normalization.util.js +32 -0
  143. package/dist/utility/intl-locale.util.d.ts +2 -0
  144. package/dist/utility/intl-locale.util.js +28 -0
  145. package/dist/utility/number-format.util.d.ts +14 -1
  146. package/dist/utility/number-format.util.js +50 -19
  147. package/dist/utility/options/option-symbol.util.d.ts +28 -0
  148. package/dist/utility/options/option-symbol.util.js +176 -0
  149. package/dist/utility/options/option-trade-units.util.d.ts +190 -0
  150. package/dist/utility/options/option-trade-units.util.js +283 -0
  151. package/dist/utility/options/option-venue.util.d.ts +75 -0
  152. package/dist/utility/options/option-venue.util.js +85 -0
  153. package/dist/utility/pool-symbol.leaf.d.ts +34 -0
  154. package/dist/utility/pool-symbol.leaf.js +95 -0
  155. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +109 -0
  156. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +302 -0
  157. package/dist/utility/symbol-selection/contract-expiry.util.d.ts +39 -0
  158. package/dist/utility/symbol-selection/contract-expiry.util.js +111 -0
  159. package/dist/utility/v2/gate-plane.util.d.ts +58 -0
  160. package/dist/utility/v2/gate-plane.util.js +99 -0
  161. package/dist/utility/v2/gate-session-latch.util.d.ts +22 -0
  162. package/dist/utility/v2/gate-session-latch.util.js +34 -0
  163. package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +76 -0
  164. package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +221 -0
  165. package/dist/utility/wrun/sources/host-grid-landing.d.ts +15 -0
  166. package/dist/utility/wrun/sources/host-grid-landing.js +26 -0
  167. package/dist/utility/wrun/sources/lanes/bitfinex_funding.d.ts +27 -0
  168. package/dist/utility/wrun/sources/lanes/bitfinex_funding.js +85 -0
  169. package/dist/utility/wrun/sources/lanes/economic.d.ts +27 -0
  170. package/dist/utility/wrun/sources/lanes/economic.js +79 -0
  171. package/dist/utility/wrun/sources/lanes/etf_holdings.d.ts +35 -0
  172. package/dist/utility/wrun/sources/lanes/etf_holdings.js +165 -0
  173. package/dist/utility/wrun/sources/lanes/etf_premium.d.ts +19 -0
  174. package/dist/utility/wrun/sources/lanes/etf_premium.js +114 -0
  175. package/dist/utility/wrun/sources/lanes/ethena_positions.d.ts +30 -0
  176. package/dist/utility/wrun/sources/lanes/ethena_positions.js +51 -0
  177. package/dist/utility/wrun/sources/lanes/index.d.ts +2 -0
  178. package/dist/utility/wrun/sources/lanes/index.js +32 -0
  179. package/dist/utility/wrun/sources/lanes/long_short_ratio.d.ts +17 -0
  180. package/dist/utility/wrun/sources/lanes/long_short_ratio.js +47 -0
  181. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +30 -0
  182. package/dist/utility/wrun/sources/lanes/option_daily.js +53 -0
  183. package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +23 -0
  184. package/dist/utility/wrun/sources/lanes/option_stats_10m.js +20 -0
  185. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +50 -0
  186. package/dist/utility/wrun/sources/lanes/options_flow.js +155 -0
  187. package/dist/utility/wrun/sources/lanes/options_oi.d.ts +29 -0
  188. package/dist/utility/wrun/sources/lanes/options_oi.js +59 -0
  189. package/dist/utility/wrun/sources/lanes/options_volume.d.ts +38 -0
  190. package/dist/utility/wrun/sources/lanes/options_volume.js +63 -0
  191. package/dist/utility/wrun/sources/lanes/series.d.ts +67 -0
  192. package/dist/utility/wrun/sources/lanes/series.js +321 -0
  193. package/dist/utility/wrun/sources/lanes/token_supply.d.ts +30 -0
  194. package/dist/utility/wrun/sources/lanes/token_supply.js +145 -0
  195. package/dist/utility/wrun/sources/lanes/treasury_balance.d.ts +25 -0
  196. package/dist/utility/wrun/sources/lanes/treasury_balance.js +47 -0
  197. package/dist/utility/wrun/sources/lanes/volatility_index.d.ts +21 -0
  198. package/dist/utility/wrun/sources/lanes/volatility_index.js +11 -0
  199. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +196 -0
  200. package/dist/utility/wrun/sources/opra-option-lanes.util.js +446 -0
  201. package/dist/utility/wrun/sources/registry.d.ts +21 -0
  202. package/dist/utility/wrun/sources/registry.js +207 -0
  203. package/dist/utility/wrun/sources/row-lane-registry.d.ts +28 -0
  204. package/dist/utility/wrun/sources/row-lane-registry.js +230 -0
  205. package/dist/utility/wrun/sources/row-lanes/index.d.ts +2 -0
  206. package/dist/utility/wrun/sources/row-lanes/index.js +12 -0
  207. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +2 -0
  208. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +38 -0
  209. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +6 -0
  210. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +70 -0
  211. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +4 -0
  212. package/dist/utility/wrun/sources/row-lanes/option_prints.js +191 -0
  213. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +13 -0
  214. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +137 -0
  215. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +38 -0
  216. package/dist/utility/wrun/sources/row-lanes/option_surface.js +150 -0
  217. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +275 -0
  218. package/dist/utility/wrun/sources/wrun-poll-lane.types.js +26 -0
  219. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +224 -0
  220. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +394 -0
  221. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +283 -0
  222. package/dist/utility/wrun/sources/wrun-row-lane.types.js +16 -0
  223. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +205 -0
  224. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +469 -0
  225. package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +28 -0
  226. package/dist/utility/wrun/wrun-browser-sources.leaf.js +66 -0
  227. package/dist/utility/wrun/wrun-cloud-record.util.d.ts +65 -0
  228. package/dist/utility/wrun/wrun-cloud-record.util.js +121 -0
  229. package/dist/utility/wrun/wrun-color-settings.util.js +1 -1
  230. package/dist/utility/wrun/wrun-daily-lane.util.d.ts +95 -0
  231. package/dist/utility/wrun/wrun-daily-lane.util.js +297 -0
  232. package/dist/utility/wrun/wrun-deadline.util.d.ts +52 -0
  233. package/dist/utility/wrun/wrun-deadline.util.js +82 -0
  234. package/dist/utility/wrun/wrun-etf-flow-lane.util.d.ts +94 -0
  235. package/dist/utility/wrun/wrun-etf-flow-lane.util.js +224 -0
  236. package/dist/utility/wrun/wrun-etf-funds.util.d.ts +82 -0
  237. package/dist/utility/wrun/wrun-etf-funds.util.js +242 -0
  238. package/dist/utility/wrun/wrun-failure-cause.d.ts +39 -0
  239. package/dist/utility/wrun/wrun-failure-cause.js +94 -0
  240. package/dist/utility/wrun/wrun-frames.d.ts +28 -3
  241. package/dist/utility/wrun/wrun-frames.js +132 -52
  242. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +167 -4
  243. package/dist/utility/wrun/wrun-hosted-wire-caps.js +47 -2
  244. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +5 -2
  245. package/dist/utility/wrun/wrun-hosted-wire.util.js +4 -2
  246. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +22 -0
  247. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +32 -0
  248. package/dist/utility/wrun/wrun-lane-warmup.util.d.ts +18 -0
  249. package/dist/utility/wrun/wrun-lane-warmup.util.js +112 -0
  250. package/dist/utility/wrun/wrun-leg-close.util.d.ts +57 -0
  251. package/dist/utility/wrun/wrun-leg-close.util.js +187 -0
  252. package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +144 -0
  253. package/dist/utility/wrun/wrun-leg-fetch.util.js +212 -0
  254. package/dist/utility/wrun/wrun-leg-stream-classes.d.ts +73 -0
  255. package/dist/utility/wrun/wrun-leg-stream-classes.js +86 -0
  256. package/dist/utility/wrun/wrun-levels-child.util.d.ts +101 -6
  257. package/dist/utility/wrun/wrun-levels-child.util.js +335 -157
  258. package/dist/utility/wrun/wrun-memory-clamp.util.d.ts +33 -0
  259. package/dist/utility/wrun/wrun-memory-clamp.util.js +146 -0
  260. package/dist/utility/wrun/wrun-odds-template-market.util.d.ts +51 -0
  261. package/dist/utility/wrun/wrun-odds-template-market.util.js +251 -0
  262. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +65 -0
  263. package/dist/utility/wrun/wrun-opra-flow.leaf.js +94 -0
  264. package/dist/utility/wrun/wrun-opra-lane.util.d.ts +47 -0
  265. package/dist/utility/wrun/wrun-opra-lane.util.js +58 -0
  266. package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +30 -0
  267. package/dist/utility/wrun/wrun-opra-stats.leaf.js +96 -0
  268. package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +12 -0
  269. package/dist/utility/wrun/wrun-opra-underlying.util.js +1 -0
  270. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +142 -0
  271. package/dist/utility/wrun/wrun-option-contract-flow.util.js +451 -0
  272. package/dist/utility/wrun/wrun-option-knobs.util.d.ts +43 -0
  273. package/dist/utility/wrun/wrun-option-knobs.util.js +81 -0
  274. package/dist/utility/wrun/wrun-option-prints.util.d.ts +144 -0
  275. package/dist/utility/wrun/wrun-option-prints.util.js +356 -0
  276. package/dist/utility/wrun/wrun-option-summary-lane.util.d.ts +102 -0
  277. package/dist/utility/wrun/wrun-option-summary-lane.util.js +143 -0
  278. package/dist/utility/wrun/wrun-options-chain.util.d.ts +308 -0
  279. package/dist/utility/wrun/wrun-options-chain.util.js +502 -0
  280. package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +9 -4
  281. package/dist/utility/wrun/wrun-overlay-identity.util.js +16 -6
  282. package/dist/utility/wrun/wrun-pack.util.d.ts +6 -2
  283. package/dist/utility/wrun/wrun-pack.util.js +13 -3
  284. package/dist/utility/wrun/wrun-param-map.util.d.ts +298 -0
  285. package/dist/utility/wrun/wrun-param-map.util.js +581 -0
  286. package/dist/utility/wrun/wrun-param-values.util.d.ts +8 -0
  287. package/dist/utility/wrun/wrun-param-values.util.js +8 -0
  288. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +149 -0
  289. package/dist/utility/wrun/wrun-pin-spelling.util.js +523 -0
  290. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +116 -0
  291. package/dist/utility/wrun/wrun-pin-venues.util.js +320 -0
  292. package/dist/utility/wrun/wrun-pinned-interval.util.d.ts +20 -0
  293. package/dist/utility/wrun/wrun-pinned-interval.util.js +47 -0
  294. package/dist/utility/wrun/wrun-present-bits.util.d.ts +37 -0
  295. package/dist/utility/wrun/wrun-present-bits.util.js +73 -0
  296. package/dist/utility/wrun/wrun-protocol-pending.util.d.ts +33 -0
  297. package/dist/utility/wrun/wrun-protocol-pending.util.js +57 -0
  298. package/dist/utility/wrun/wrun-refusal.util.d.ts +95 -7
  299. package/dist/utility/wrun/wrun-refusal.util.js +314 -18
  300. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +1 -14
  301. package/dist/utility/wrun/wrun-registry-errors.util.js +0 -16
  302. package/dist/utility/wrun/wrun-render-select.util.js +1 -0
  303. package/dist/utility/wrun/wrun-row-market.util.d.ts +29 -0
  304. package/dist/utility/wrun/wrun-row-market.util.js +92 -0
  305. package/dist/utility/wrun/wrun-row-source.d.ts +158 -0
  306. package/dist/utility/wrun/wrun-row-source.js +75 -0
  307. package/dist/utility/wrun/wrun-run-health.util.d.ts +155 -0
  308. package/dist/utility/wrun/wrun-run-health.util.js +273 -0
  309. package/dist/utility/wrun/wrun-socket-row-source.d.ts +439 -0
  310. package/dist/utility/wrun/wrun-socket-row-source.js +1689 -0
  311. package/dist/utility/wrun/wrun-socket-session-losses.util.d.ts +18 -0
  312. package/dist/utility/wrun/wrun-socket-session-losses.util.js +25 -0
  313. package/dist/utility/wrun/wrun-source-rows.util.d.ts +911 -0
  314. package/dist/utility/wrun/wrun-source-rows.util.js +2597 -0
  315. package/dist/utility/wrun/wrun-symbol-code.util.d.ts +32 -0
  316. package/dist/utility/wrun/wrun-symbol-code.util.js +56 -0
  317. package/dist/utility/wrun/wrun-tape-source.util.d.ts +82 -0
  318. package/dist/utility/wrun/wrun-tape-source.util.js +151 -0
  319. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +137 -0
  320. package/dist/utility/wrun/wrun-tier-grid.util.js +279 -0
  321. package/dist/utility/wrun/wrun-trades-lane.util.d.ts +52 -0
  322. package/dist/utility/wrun/wrun-trades-lane.util.js +58 -0
  323. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +41 -0
  324. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +66 -0
  325. package/dist/utility/wrun-display-name.util.d.ts +33 -0
  326. package/dist/utility/wrun-display-name.util.js +64 -0
  327. package/dist/workers/constants/kscript-transport-codes.d.ts +15 -0
  328. package/dist/workers/constants/kscript-transport-codes.js +15 -0
  329. package/dist/workers/constants/socket-slots.d.ts +574 -0
  330. package/dist/workers/constants/socket-slots.js +539 -0
  331. package/dist/workers/utils/number.worker.util.d.ts +5 -0
  332. package/dist/workers/utils/number.worker.util.js +10 -0
  333. package/dist/workers/utils/time.worker.util.d.ts +12 -0
  334. package/dist/workers/utils/time.worker.util.js +24 -0
  335. package/dist/workers/utils/volume-profile.worker.util.d.ts +200 -0
  336. package/dist/workers/utils/volume-profile.worker.util.js +631 -0
  337. package/package.json +10 -4
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Byte-for-byte copies of the three titan constants package-bound code reads (`@orangecharts/titan-charts-next/constants`
3
+ * `findMonday`, `TimeIntervalConstant`, `MIN_GRID_HEIGHT_ALLOWED`), in a leaf with no import: the extraction walker
4
+ * refuses every titan edge (scripts/wrun-chart-host-extract.mjs), so a module that moves into the chart-host package
5
+ * reads these instead of the engine's. tests/utility/chart/titan-constants.pin.spec.ts compares them with the installed
6
+ * engine's (values and 200 sampled timestamps), and src/utility/wrun/wrun-chart-host-type-pins.ts pins their types.
7
+ */
8
+ /** The UTC midnight of the Monday that starts the week holding `unixTimeStamp` (ms). */
9
+ export declare function findMonday(unixTimeStamp: number): number;
10
+ /** The engine's interval lengths in ms (its month and year are 30 and 360 days). */
11
+ export declare const TimeIntervalConstant: {
12
+ millisecond: number;
13
+ milliseconds500: number;
14
+ second: number;
15
+ seconds5: number;
16
+ seconds10: number;
17
+ seconds15: number;
18
+ seconds30: number;
19
+ minute: number;
20
+ minutes5: number;
21
+ minutes10: number;
22
+ minutes15: number;
23
+ minutes30: number;
24
+ hour: number;
25
+ hours2: number;
26
+ hours4: number;
27
+ hours8: number;
28
+ hours12: number;
29
+ day: number;
30
+ days3: number;
31
+ week: number;
32
+ weeks2: number;
33
+ weeks4: number;
34
+ month: number;
35
+ months3: number;
36
+ months6: number;
37
+ months8: number;
38
+ year: number;
39
+ years2: number;
40
+ years5: number;
41
+ };
42
+ /** The smallest grid height share a pane may take (the engine's split floor). */
43
+ export declare const MIN_GRID_HEIGHT_ALLOWED = 0.13;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Byte-for-byte copies of the three titan constants package-bound code reads (`@orangecharts/titan-charts-next/constants`
3
+ * `findMonday`, `TimeIntervalConstant`, `MIN_GRID_HEIGHT_ALLOWED`), in a leaf with no import: the extraction walker
4
+ * refuses every titan edge (scripts/wrun-chart-host-extract.mjs), so a module that moves into the chart-host package
5
+ * reads these instead of the engine's. tests/utility/chart/titan-constants.pin.spec.ts compares them with the installed
6
+ * engine's (values and 200 sampled timestamps), and src/utility/wrun/wrun-chart-host-type-pins.ts pins their types.
7
+ */
8
+ /** The UTC midnight of the Monday that starts the week holding `unixTimeStamp` (ms). */
9
+ export function findMonday(unixTimeStamp) {
10
+ const date = new Date(unixTimeStamp);
11
+ const day = date.getUTCDay();
12
+ const mondayDate = date.getUTCDate() - day + (day === 0 ? -6 : 1);
13
+ const monday = new Date(date.setUTCDate(mondayDate));
14
+ monday.setUTCHours(0, 0, 0, 0);
15
+ return new Date(monday).valueOf();
16
+ }
17
+ /** The engine's interval lengths in ms (its month and year are 30 and 360 days). */
18
+ export const TimeIntervalConstant = {
19
+ millisecond: 1,
20
+ milliseconds500: 500,
21
+ second: 1000,
22
+ seconds5: 5000,
23
+ seconds10: 10000,
24
+ seconds15: 15000,
25
+ seconds30: 30000,
26
+ minute: 60000,
27
+ minutes5: 300000,
28
+ minutes10: 600000,
29
+ minutes15: 900000,
30
+ minutes30: 1800000,
31
+ hour: 3600000,
32
+ hours2: 7200000,
33
+ hours4: 14400000,
34
+ hours8: 28800000,
35
+ hours12: 43200000,
36
+ day: 86400000,
37
+ days3: 259200000,
38
+ week: 604800000,
39
+ weeks2: 1209600000,
40
+ weeks4: 2419200000,
41
+ month: 2592000000,
42
+ months3: 7776000000,
43
+ months6: 15552000000,
44
+ months8: 20736000000,
45
+ year: 31104000000,
46
+ years2: 62208000000,
47
+ years5: 155520000000,
48
+ };
49
+ /** The smallest grid height share a pane may take (the engine's split floor). */
50
+ export const MIN_GRID_HEIGHT_ALLOWED = 0.13;
@@ -0,0 +1,127 @@
1
+ import { type RthWindow, type SessionDayWindow } from './rth-session.util.js';
2
+ export declare const US_EQUITIES_TIME_ZONE = "America/New_York";
3
+ /**
4
+ * Switch for the equities extended-hours session. On (since 2026-10-02):
5
+ * Polygon's consolidated minute bars are back on exchange 92 and carry the
6
+ * whole 04:00 to 20:00 New York day, so a workspace that opted into
7
+ * `sessionType: 'extended'` gets every print and the Regular/Extended control
8
+ * shows on equities charts; unset stays regular. Off pins every equities
9
+ * chart to the regular session: a persisted `sessionType: 'extended'` reads
10
+ * as regular everywhere (fetch filter, live lanes, bars cache) and the
11
+ * control hides, while the persisted value is left untouched. It was off from
12
+ * 2026-09-16 (Kyle: "disable ETH until a fuller feed") while the feed was
13
+ * EQUS.MINI, whose extended-hours minutes were a scatter of prints.
14
+ */
15
+ export declare const usEquitiesSessionConfig: {
16
+ extendedHoursEnabled: boolean;
17
+ };
18
+ /** The workspace opted into extended hours AND the option is enabled. */
19
+ export declare function isEquityExtendedSession(sessionType: unknown): boolean;
20
+ /**
21
+ * The regular cash session as a window object, for the shared zone-day walks
22
+ * in rth-session.util (one frozen constant so their per-window memo holds).
23
+ */
24
+ export declare const US_EQUITIES_REGULAR_WINDOW: Readonly<RthWindow>;
25
+ /**
26
+ * Every calendar day's regular-session window `[09:30, 16:00)` New York that
27
+ * touches `[fromMs, toMs]`, weekends included (calendar-based, like the
28
+ * governed-futures walk; consumers act on bars, and none trade then).
29
+ */
30
+ export declare function usEquityRegularWindowsInRange(fromMs: number, toMs: number): SessionDayWindow[];
31
+ export type UsEquitySessionPhase = 'pre' | 'regular' | 'after' | 'closed';
32
+ export interface UsEquitiesScheduleStatus {
33
+ /** True inside the regular cash session (09:30-16:00 New York, Mon-Fri). */
34
+ open: boolean;
35
+ phase: UsEquitySessionPhase;
36
+ /** Next regular-session open strictly after `nowMs`; null only on tz failure. */
37
+ nextOpenMs: number | null;
38
+ /** Today's regular close while open; null while closed. */
39
+ nextCloseMs: number | null;
40
+ }
41
+ export declare function resolveUsEquitySessionPhase(tsMs: number): UsEquitySessionPhase;
42
+ /**
43
+ * A regular-session chart on a Polygon venue: the default (unset or 'regular')
44
+ * gates to the cash session; 'extended' opts into every print only while the
45
+ * extended-hours option is enabled (`usEquitiesSessionConfig`). Mirrors the
46
+ * `tradingHour` derivation in candle-trading-hour.util so the wire filter and
47
+ * the client-side doors agree.
48
+ */
49
+ export declare function isEquityRegularSessionGated(exchange: unknown, sessionType: unknown): boolean;
50
+ /**
51
+ * Whether a bar with open time `tsMs` belongs on a regular-session equities
52
+ * chart at `intervalMs`. Intraday buckets up to 30m sit on the session grid
53
+ * (09:30 New York is on the 30m grid), so membership is the bucket start's
54
+ * phase. Above 30m (45m to 12h) the gateway serves session-ANCHORED buckets
55
+ * (13:30Z hourly bars in EDT), so a row belongs only if it sits on that lattice: a
56
+ * UTC-aligned 13:00Z row (an extended-hours fetch of an older build, or a
57
+ * workspace that used to opt into extended hours) is foreign and would
58
+ * interleave with the anchored bars. Every other coarse interval keeps the
59
+ * UTC lattice and passes through, as do bars whose interval is unknown.
60
+ */
61
+ export declare function isUsEquityRegularSessionBarMs(tsMs: number, intervalMs: number | undefined): boolean;
62
+ /** Drop the rows of `bars` ([ts, o, h, l, c, v, ...]) that do not belong on the regular-session chart. */
63
+ export declare function filterUsEquityRegularSessionBars(bars: number[][], intervalMs: number | undefined): number[][];
64
+ /**
65
+ * Session-anchored bucket start for a regular-session equities chart on the
66
+ * intervals the gateway serves session-anchored (45m to 12h, rth-session.util
67
+ * `isFootprintRthFoldTfMs`; the caller applies that gate): those buckets are
68
+ * anchored at the 09:30 New York open (an hourly bar starts 13:30Z in EDT,
69
+ * not 13:00Z), so live ticks must key onto the same lattice or they split
70
+ * the forming bar off-phase. Null when the instant sits outside the cash
71
+ * session (no fetched bucket exists for it). Mirrors rth-session.util
72
+ * `rthAnchoredBucketStartMs`.
73
+ */
74
+ export declare function usEquityAnchoredBucketStartMs(tsMs: number, intervalMs: number): number | null;
75
+ /**
76
+ * The 3d bar a regular-session equities tick belongs to: the gateway groups
77
+ * the daily session bars three trade dates at a time (`sessionGridStart`,
78
+ * weekdays from 2000-01-03), so a Friday and the Monday after share a bar.
79
+ * The regular session sits inside one UTC day, so its date is the UTC date.
80
+ * Null outside the cash session, like the intraday anchor.
81
+ */
82
+ export declare function usEquitySessionGridBucketStartMs(tsMs: number): number | null;
83
+ export type EquityLiveTradeGate =
84
+ /** Not a gated chart (non-Polygon venue, or the workspace opted into extended hours). */
85
+ {
86
+ kind: 'pass';
87
+ }
88
+ /** Regular-session print on a regular-session chart: apply it, clear any extended-hours label. */
89
+ | {
90
+ kind: 'regular';
91
+ }
92
+ /** Print outside the cash session on a regular-session chart: label the price, append nothing. */
93
+ | {
94
+ kind: 'outside';
95
+ phase: Exclude<UsEquitySessionPhase, 'regular'>;
96
+ };
97
+ /** The live-lane decision for one trade print at `tsMs`. */
98
+ export declare function resolveEquityLiveTradeGate(exchange: unknown, sessionType: unknown, tsMs: number): EquityLiveTradeGate;
99
+ /**
100
+ * The close a stock's change is measured against, TradingView's way: the
101
+ * previous regular session's close while the price belongs to the latest
102
+ * session the daily bars hold, else that latest session's close (the price is
103
+ * later than its 16:00 close: after hours, the next pre-market, or a session
104
+ * the bars do not hold yet). `sessionBars` are regular-session daily bars
105
+ * `[ts, open, high, low, close, ...]`, each labeled inside its trade date's
106
+ * UTC day (the session sits inside it). `price` is the chart's last bar: its
107
+ * open time, its end capped at now, and its close.
108
+ *
109
+ * An extended-hours chart's price is as recent as the bar's end. A
110
+ * regular-session chart's price is its last bar's close, never later than
111
+ * that bar's session close: a bar that opened after the latest close belongs
112
+ * to a newer session, and a bar spanning several sessions (3D, 1W, 1M) does
113
+ * once the next session has opened and the price has moved off the latest
114
+ * close (the daily bars can lag an open by a poll; an exchange holiday moves
115
+ * nothing). Null when the bars hold no earlier session to measure against.
116
+ */
117
+ export declare function usEquityChangeReferenceClose(sessionBars: readonly number[][], price: {
118
+ barMs: number;
119
+ atMs: number;
120
+ close: number;
121
+ }, regularGated: boolean): number | null;
122
+ /**
123
+ * The static weekly cycle, evaluated at `nowMs`. Like the governed-futures
124
+ * schedule this is deliberately NOT a holiday calendar: on an exchange
125
+ * holiday it reads "open" with no bars printing, which is a known v1 gap.
126
+ */
127
+ export declare function getUsEquitiesScheduleStatus(nowMs: number): UsEquitiesScheduleStatus;
@@ -0,0 +1,251 @@
1
+ /**
2
+ * US equities (Polygon-served venues: NYSE / NASDAQ / CBOE) session
3
+ * discipline for the regular-session chart, the single decider every surface
4
+ * rides: which live prints reach a regular-session chart, which cached bars
5
+ * paint on it, and what the market-status note says outside the cash session.
6
+ *
7
+ * Why this exists: from 2026-09-14 to 2026-10-02 the equities trade feed was
8
+ * Databento EQUS.MINI, a minority-venue blend whose pre-market and after-hours
9
+ * minutes were sparse, so any extended-hours row that reached a
10
+ * regular-session chart drew as an isolated dot. Polygon's consolidated feed
11
+ * is back since, and the doors stay closed: history fetches carry
12
+ * `tradingHour = REGULAR` for these venues, this module gates the live lanes
13
+ * and the bars cache, and it drives the "Pre-market / After-hours / Closed"
14
+ * state so the chart reads as a closed market instead of a broken one.
15
+ *
16
+ * Session phases (America/New_York, DST-aware, weekdays only; holidays are
17
+ * NOT modelled, the same v1 scope as the governed-futures weekly schedule):
18
+ * pre 04:00 -> 09:30
19
+ * regular 09:30 -> 16:00
20
+ * after 16:00 -> 20:00
21
+ * closed everything else, and weekends
22
+ *
23
+ * Worker-safe: no Vue / store / i18n imports (the bars cache and the workers
24
+ * import the row filter).
25
+ */
26
+ import dayjs from 'dayjs';
27
+ import timezone from 'dayjs/plugin/timezone.js';
28
+ import utc from 'dayjs/plugin/utc.js';
29
+ import { checkIsPolygon } from './marketKind.util.js';
30
+ import { isFootprintRthFoldTfMs, isRthBucketExactIntervalMs, sessionWindowsInRange, } from './rth-session.util.js';
31
+ import { sessionGridStartMs } from './cme-session-bucket.util.js';
32
+ import { checkUSMarketHours } from '../common/time.util.js';
33
+ dayjs.extend(utc);
34
+ dayjs.extend(timezone);
35
+ export const US_EQUITIES_TIME_ZONE = 'America/New_York';
36
+ /**
37
+ * Switch for the equities extended-hours session. On (since 2026-10-02):
38
+ * Polygon's consolidated minute bars are back on exchange 92 and carry the
39
+ * whole 04:00 to 20:00 New York day, so a workspace that opted into
40
+ * `sessionType: 'extended'` gets every print and the Regular/Extended control
41
+ * shows on equities charts; unset stays regular. Off pins every equities
42
+ * chart to the regular session: a persisted `sessionType: 'extended'` reads
43
+ * as regular everywhere (fetch filter, live lanes, bars cache) and the
44
+ * control hides, while the persisted value is left untouched. It was off from
45
+ * 2026-09-16 (Kyle: "disable ETH until a fuller feed") while the feed was
46
+ * EQUS.MINI, whose extended-hours minutes were a scatter of prints.
47
+ */
48
+ export const usEquitiesSessionConfig = { extendedHoursEnabled: true };
49
+ /** The workspace opted into extended hours AND the option is enabled. */
50
+ export function isEquityExtendedSession(sessionType) {
51
+ return usEquitiesSessionConfig.extendedHoursEnabled && sessionType === 'extended';
52
+ }
53
+ /** Minutes after local midnight, matching `checkUSMarketHours`. */
54
+ const REGULAR_OPEN_MINUTES = 9 * 60 + 30;
55
+ const REGULAR_CLOSE_MINUTES = 16 * 60;
56
+ /**
57
+ * The regular cash session as a window object, for the shared zone-day walks
58
+ * in rth-session.util (one frozen constant so their per-window memo holds).
59
+ */
60
+ export const US_EQUITIES_REGULAR_WINDOW = Object.freeze({
61
+ timeZone: US_EQUITIES_TIME_ZONE,
62
+ openMinutes: REGULAR_OPEN_MINUTES,
63
+ closeMinutes: REGULAR_CLOSE_MINUTES,
64
+ });
65
+ /**
66
+ * Every calendar day's regular-session window `[09:30, 16:00)` New York that
67
+ * touches `[fromMs, toMs]`, weekends included (calendar-based, like the
68
+ * governed-futures walk; consumers act on bars, and none trade then).
69
+ */
70
+ export function usEquityRegularWindowsInRange(fromMs, toMs) {
71
+ return sessionWindowsInRange(US_EQUITIES_REGULAR_WINDOW, fromMs, toMs);
72
+ }
73
+ export function resolveUsEquitySessionPhase(tsMs) {
74
+ return checkUSMarketHours(tsMs).sessionType;
75
+ }
76
+ /**
77
+ * A regular-session chart on a Polygon venue: the default (unset or 'regular')
78
+ * gates to the cash session; 'extended' opts into every print only while the
79
+ * extended-hours option is enabled (`usEquitiesSessionConfig`). Mirrors the
80
+ * `tradingHour` derivation in candle-trading-hour.util so the wire filter and
81
+ * the client-side doors agree.
82
+ */
83
+ export function isEquityRegularSessionGated(exchange, sessionType) {
84
+ const exchangeCode = typeof exchange === 'string' ? exchange : undefined;
85
+ return checkIsPolygon(exchangeCode) && !isEquityExtendedSession(sessionType);
86
+ }
87
+ /**
88
+ * Whether a bar with open time `tsMs` belongs on a regular-session equities
89
+ * chart at `intervalMs`. Intraday buckets up to 30m sit on the session grid
90
+ * (09:30 New York is on the 30m grid), so membership is the bucket start's
91
+ * phase. Above 30m (45m to 12h) the gateway serves session-ANCHORED buckets
92
+ * (13:30Z hourly bars in EDT), so a row belongs only if it sits on that lattice: a
93
+ * UTC-aligned 13:00Z row (an extended-hours fetch of an older build, or a
94
+ * workspace that used to opt into extended hours) is foreign and would
95
+ * interleave with the anchored bars. Every other coarse interval keeps the
96
+ * UTC lattice and passes through, as do bars whose interval is unknown.
97
+ */
98
+ export function isUsEquityRegularSessionBarMs(tsMs, intervalMs) {
99
+ if (isRthBucketExactIntervalMs(intervalMs))
100
+ return resolveUsEquitySessionPhase(tsMs) === 'regular';
101
+ if (typeof intervalMs === 'number' && isFootprintRthFoldTfMs(intervalMs)) {
102
+ return usEquityAnchoredBucketStartMs(tsMs, intervalMs) === tsMs;
103
+ }
104
+ return true;
105
+ }
106
+ /** Drop the rows of `bars` ([ts, o, h, l, c, v, ...]) that do not belong on the regular-session chart. */
107
+ export function filterUsEquityRegularSessionBars(bars, intervalMs) {
108
+ const filtered = typeof intervalMs === 'number' && (isRthBucketExactIntervalMs(intervalMs) || isFootprintRthFoldTfMs(intervalMs));
109
+ if (!filtered)
110
+ return bars;
111
+ return bars.filter((bar) => typeof bar?.[0] === 'number' && isUsEquityRegularSessionBarMs(bar[0], intervalMs));
112
+ }
113
+ /**
114
+ * Session-anchored bucket start for a regular-session equities chart on the
115
+ * intervals the gateway serves session-anchored (45m to 12h, rth-session.util
116
+ * `isFootprintRthFoldTfMs`; the caller applies that gate): those buckets are
117
+ * anchored at the 09:30 New York open (an hourly bar starts 13:30Z in EDT,
118
+ * not 13:00Z), so live ticks must key onto the same lattice or they split
119
+ * the forming bar off-phase. Null when the instant sits outside the cash
120
+ * session (no fetched bucket exists for it). Mirrors rth-session.util
121
+ * `rthAnchoredBucketStartMs`.
122
+ */
123
+ export function usEquityAnchoredBucketStartMs(tsMs, intervalMs) {
124
+ if (!Number.isFinite(tsMs) || !Number.isFinite(intervalMs) || intervalMs <= 0)
125
+ return null;
126
+ if (resolveUsEquitySessionPhase(tsMs) !== 'regular')
127
+ return null;
128
+ let date;
129
+ try {
130
+ date = dayjs(tsMs).tz(US_EQUITIES_TIME_ZONE).format('YYYY-MM-DD');
131
+ }
132
+ catch {
133
+ return null;
134
+ }
135
+ const open = nyWallInstant(date, REGULAR_OPEN_MINUTES);
136
+ if (open === null)
137
+ return null;
138
+ const openMs = open.valueOf();
139
+ return openMs + Math.floor((tsMs - openMs) / intervalMs) * intervalMs;
140
+ }
141
+ /**
142
+ * The 3d bar a regular-session equities tick belongs to: the gateway groups
143
+ * the daily session bars three trade dates at a time (`sessionGridStart`,
144
+ * weekdays from 2000-01-03), so a Friday and the Monday after share a bar.
145
+ * The regular session sits inside one UTC day, so its date is the UTC date.
146
+ * Null outside the cash session, like the intraday anchor.
147
+ */
148
+ export function usEquitySessionGridBucketStartMs(tsMs) {
149
+ if (!Number.isFinite(tsMs) || resolveUsEquitySessionPhase(tsMs) !== 'regular')
150
+ return null;
151
+ return sessionGridStartMs(tsMs - (tsMs % 86_400_000));
152
+ }
153
+ /** The live-lane decision for one trade print at `tsMs`. */
154
+ export function resolveEquityLiveTradeGate(exchange, sessionType, tsMs) {
155
+ if (!isEquityRegularSessionGated(exchange, sessionType))
156
+ return { kind: 'pass' };
157
+ const phase = resolveUsEquitySessionPhase(tsMs);
158
+ return phase === 'regular' ? { kind: 'regular' } : { kind: 'outside', phase };
159
+ }
160
+ /**
161
+ * The close a stock's change is measured against, TradingView's way: the
162
+ * previous regular session's close while the price belongs to the latest
163
+ * session the daily bars hold, else that latest session's close (the price is
164
+ * later than its 16:00 close: after hours, the next pre-market, or a session
165
+ * the bars do not hold yet). `sessionBars` are regular-session daily bars
166
+ * `[ts, open, high, low, close, ...]`, each labeled inside its trade date's
167
+ * UTC day (the session sits inside it). `price` is the chart's last bar: its
168
+ * open time, its end capped at now, and its close.
169
+ *
170
+ * An extended-hours chart's price is as recent as the bar's end. A
171
+ * regular-session chart's price is its last bar's close, never later than
172
+ * that bar's session close: a bar that opened after the latest close belongs
173
+ * to a newer session, and a bar spanning several sessions (3D, 1W, 1M) does
174
+ * once the next session has opened and the price has moved off the latest
175
+ * close (the daily bars can lag an open by a poll; an exchange holiday moves
176
+ * nothing). Null when the bars hold no earlier session to measure against.
177
+ */
178
+ export function usEquityChangeReferenceClose(sessionBars, price, regularGated) {
179
+ const bars = sessionBars
180
+ .filter((bar) => Number.isFinite(bar?.[0]) && Number.isFinite(bar?.[4]) && bar[4] > 0)
181
+ .sort((a, b) => a[0] - b[0]);
182
+ const latest = bars[bars.length - 1];
183
+ if (!latest)
184
+ return null;
185
+ const latestClose = nyWallInstant(dayjs.utc(latest[0]).format('YYYY-MM-DD'), REGULAR_CLOSE_MINUTES);
186
+ if (latestClose === null)
187
+ return null;
188
+ const latestCloseMs = latestClose.valueOf();
189
+ let priceIsLater = price.atMs > latestCloseMs;
190
+ if (regularGated) {
191
+ const nextOpenMs = getUsEquitiesScheduleStatus(latestCloseMs).nextOpenMs;
192
+ priceIsLater =
193
+ price.barMs >= latestCloseMs || (nextOpenMs !== null && price.atMs >= nextOpenMs && price.close !== latest[4]);
194
+ }
195
+ if (priceIsLater)
196
+ return latest[4];
197
+ return bars.length >= 2 ? bars[bars.length - 2][4] : null;
198
+ }
199
+ // ─── Weekly schedule ─────────────────────────────────────────────────────────
200
+ /** New York wall-clock instant on `date` ('YYYY-MM-DD'); null on tz failure. */
201
+ function nyWallInstant(date, minutes) {
202
+ const hours = String(Math.floor(minutes / 60)).padStart(2, '0');
203
+ const mins = String(minutes % 60).padStart(2, '0');
204
+ try {
205
+ return dayjs.tz(`${date} ${hours}:${mins}`, US_EQUITIES_TIME_ZONE);
206
+ }
207
+ catch {
208
+ return null;
209
+ }
210
+ }
211
+ /** Calendar-date arithmetic on the date string only: no DST involvement. */
212
+ function nextDate(date) {
213
+ return dayjs.utc(date).add(1, 'day').format('YYYY-MM-DD');
214
+ }
215
+ function isWeekday(date) {
216
+ const day = dayjs.utc(date).day();
217
+ return day >= 1 && day <= 5;
218
+ }
219
+ /**
220
+ * The static weekly cycle, evaluated at `nowMs`. Like the governed-futures
221
+ * schedule this is deliberately NOT a holiday calendar: on an exchange
222
+ * holiday it reads "open" with no bars printing, which is a known v1 gap.
223
+ */
224
+ export function getUsEquitiesScheduleStatus(nowMs) {
225
+ const phase = resolveUsEquitySessionPhase(nowMs);
226
+ let date;
227
+ try {
228
+ date = dayjs(nowMs).tz(US_EQUITIES_TIME_ZONE).format('YYYY-MM-DD');
229
+ }
230
+ catch {
231
+ return { open: phase === 'regular', phase, nextOpenMs: null, nextCloseMs: null };
232
+ }
233
+ if (phase === 'regular') {
234
+ const close = nyWallInstant(date, REGULAR_CLOSE_MINUTES);
235
+ return { open: true, phase, nextOpenMs: null, nextCloseMs: close ? close.valueOf() : null };
236
+ }
237
+ // Next weekday open strictly after now: today (pre-market) or the next
238
+ // trading day. Eight days covers any weekend from either side.
239
+ let candidate = date;
240
+ for (let i = 0; i < 8; i += 1) {
241
+ if (isWeekday(candidate)) {
242
+ const open = nyWallInstant(candidate, REGULAR_OPEN_MINUTES);
243
+ if (open === null)
244
+ return { open: false, phase, nextOpenMs: null, nextCloseMs: null };
245
+ if (open.valueOf() > nowMs)
246
+ return { open: false, phase, nextOpenMs: open.valueOf(), nextCloseMs: null };
247
+ }
248
+ candidate = nextDate(candidate);
249
+ }
250
+ return { open: false, phase, nextOpenMs: null, nextCloseMs: null };
251
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * The market facts a wrun indicator reads per bar (WRUN-SESSIONS contract
3
+ * C3): `time.trade_date` and `time.session`. Both are facts of the bar's
4
+ * market (exchange, symbol), its interval and its open time ONLY, never of
5
+ * the chart's RTH / extended mode, and every hour comes from the chart's own
6
+ * session definitions, the RTH window from the kScript engine's table (see
7
+ * NYMEX below).
8
+ *
9
+ * Calendar bars (an interval of one day or longer: 1D, 3D, 1W, 1M) read the
10
+ * UTC date of their open stamp and 1 on every market: the chart stamps them
11
+ * at 00:00 UTC of their trade date, an instant the intraday rules below would
12
+ * read as the previous New York evening (amendment 10-01). Intraday bars:
13
+ *
14
+ * - trade date, epoch SECONDS at 00:00 UTC of the bar's exchange trade date:
15
+ * - CME family (`isCmeGoverned`: CME, CBOT, NYMEX, COMEX and the GLOBEX
16
+ * alias): the chart's CME trade date, `cmeSessionBucketMs(t, 1d)`, so the
17
+ * 17:00 Chicago open belongs to the NEXT date;
18
+ * - US equities (`getMarketKind` 'tradfi'): the New York calendar date;
19
+ * - everything else (crypto, forex, HIP-3, Polymarket, ...): the UTC date.
20
+ * - session, 1 regular, 2 pre-market, 3 after-hours, 0 closed:
21
+ * - US equities: `resolveUsEquitySessionPhase`;
22
+ * - CME family: 0 while the weekly schedule says closed
23
+ * (`getGovernedFuturesScheduleStatusForSymbol`, which carries the 24/7
24
+ * roots); else 1 inside the engine's RTH window
25
+ * (`engineRthWindowForSymbol`, 09:30 to 16:15 New York on every mapped
26
+ * root; a root without a window is regular all session), 2 before its
27
+ * trade date's RTH window and 3 after it;
28
+ * - everything else: 1.
29
+ *
30
+ * The golden vectors every other host (kscript-alerts, kscript-backend, om)
31
+ * tests against are generated from this module:
32
+ * src/fixtures/wrun-session-facts/golden.json.
33
+ *
34
+ * NYMEX: the chart judges RTH there on the energy pit session, 09:00 to 14:30
35
+ * New York (rth-session.util `rthWindowForExchange`, the gateway's REGULAR
36
+ * window), but wrun and kScript session facts on NYMEX follow the kScript
37
+ * engine's table, 09:30 to 16:15, until a coordinated change moves the
38
+ * engine, the golden and the cloud lanes together. Moving this browser lane
39
+ * alone would split the browser and cloud runs of the same indicator.
40
+ *
41
+ * Cost: the definitions run at microseconds a call (the equities phase reads
42
+ * dayjs timezone parts, about 30 us), so a 50k-bar run cannot afford one per
43
+ * bar. Each is memoized on the grain it is constant on, always evaluated at
44
+ * the START of that grain so a result never depends on call order:
45
+ * - the venue-zone calendar day (Intl parts, host-independent: the dayjs
46
+ * drift caveat in rth-session.util never applies), once per local day;
47
+ * - the CME schedule per Chicago (weekday, hour): its boundaries are whole
48
+ * Chicago hours (16:00 and 17:00, the Saturday 02:00 to 04:00 window);
49
+ * - the equities phase per New York (weekday, half hour): its boundaries are
50
+ * 04:00, 09:30, 16:00 and 20:00;
51
+ * - the CME RTH window per (window, trade date).
52
+ * Both zones sit a whole number of hours off UTC, so a reader also keeps its
53
+ * last answer per UTC hour (CME: the trade date and the schedule bit) or half
54
+ * hour (equities), and a sorted walk pays the lookups once per grain, not per
55
+ * bar. The spec walks every minute of both 2026 DST weeks against the
56
+ * definitions themselves, so a boundary moved off those grains fails there,
57
+ * not in the field, and measures 50k one-minute bars from a cold module.
58
+ *
59
+ * Worker-safe: imports only the chart's session utils (no Vue, store, i18n).
60
+ */
61
+ /** The `time.session` codes (contract C3). */
62
+ export declare const WRUN_BAR_SESSION: Readonly<{
63
+ readonly closed: 0;
64
+ readonly regular: 1;
65
+ readonly premarket: 2;
66
+ readonly afterHours: 3;
67
+ }>;
68
+ export type WrunBarSession = (typeof WRUN_BAR_SESSION)[keyof typeof WRUN_BAR_SESSION];
69
+ export interface WrunBarSessionFacts {
70
+ /** Epoch seconds at 00:00 UTC of the bar's exchange trade date (NaN for a non-finite bar time). */
71
+ tradeDateSec: number;
72
+ /** A `WRUN_BAR_SESSION` code (NaN for a non-finite bar time). */
73
+ session: number;
74
+ }
75
+ /** The series the facts are read for: the chart's own main series, its market and its bar interval. */
76
+ export interface WrunBarVenue {
77
+ exchange: string;
78
+ symbol: string;
79
+ /** The series' bar interval (ms); one day or longer reads the calendar-bar rule. */
80
+ intervalMs: number;
81
+ }
82
+ /** Which C3 rule a market follows. */
83
+ export type WrunBarFactsMarket = 'cme' | 'us_equities' | 'utc';
84
+ export declare function wrunBarFactsMarketOf(exchange: string): WrunBarFactsMarket;
85
+ /**
86
+ * The venue of chart metadata (or a live context's market) at the series'
87
+ * bar interval: undefined unless exchange and symbol are non-empty strings and
88
+ * the interval is a positive number.
89
+ */
90
+ export declare function wrunBarVenueOf(market: unknown, intervalMs: number): WrunBarVenue | undefined;
91
+ /**
92
+ * The facts reader for one series: its rule is decided once (a calendar bar
93
+ * reads its stamp's UTC date on every market, an intraday bar its market's
94
+ * rule), then every call reads one bar open time (UTC ms). The row builders
95
+ * bind one per build and call it per row. The answer objects are shared and
96
+ * frozen.
97
+ */
98
+ export declare function wrunBarSessionFactsResolver(venue: WrunBarVenue): (barOpenMs: number) => WrunBarSessionFacts;
99
+ /** One bar's facts (a one-off read; hot loops bind `wrunBarSessionFactsResolver` once). */
100
+ export declare function wrunBarSessionFacts(venue: WrunBarVenue, barOpenMs: number): WrunBarSessionFacts;