@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,134 @@
1
+ /**
2
+ * Binary-search membership test for a timestamp in an ascending time series.
3
+ * Time-series rows commit sorted (mergeTimeSeries output, worker chunks), so a
4
+ * scan-free lookup stays cheap on the per-tick live path.
5
+ */
6
+ export declare function sortedTimeSeriesHasTimestamp(rows: number[][] | undefined, timestamp: number): boolean;
7
+ export declare function liveTickFitsContiguousTail(tickTimestamp: number, rows: number[][] | undefined, intervalMs: number | undefined, thresholdMultiplier?: number): boolean;
8
+ export type MergeFastPath = 'append' | 'prepend' | 'legacy';
9
+ /** Test-only oracle: which branch the last mergeTimeSeries call took.
10
+ * Output equality cannot prove a fast path executed; this can. Written at
11
+ * EVERY exit ('bypass' for custom extractors and the non-array guard) so a
12
+ * spec can never read a stale value from an unrelated earlier call. */
13
+ export declare const __mergeFastPathStats: {
14
+ lastPath: MergeFastPath | "none" | "bypass";
15
+ };
16
+ /**
17
+ * Classifier for mergeTimeSeries' concat fast paths, exported so the
18
+ * property spec can assert eligibility (the executed branch is proven via
19
+ * __mergeFastPathStats). A fast path requires BOTH arrays proven finite and
20
+ * strictly ascending and the batches disjoint at the boundary; equal
21
+ * boundary timestamps, overlap, duplicates inside either array, non-finite
22
+ * rows, or an empty side all take the legacy Map rebuild, whose replacement
23
+ * and filtering semantics stay authoritative.
24
+ */
25
+ export declare function classifyMergeFastPath<T>(srcTimeSeries: T[], newDataToBeMerged: T[], timeExtractor: (point: T) => number): MergeFastPath;
26
+ /**
27
+ * True when rows are ascending (non-strict) by row[0] AND every row[0] is a
28
+ * primitive non-NaN number. The apply body's scan-or-sort uses this: a
29
+ * stable sort of an already-ascending numeric array is an order no-op, so
30
+ * skipping it changes nothing observable. Non-number or NaN first elements
31
+ * report false so the sort still runs, preserving today's behavior for
32
+ * malformed rows exactly (including comparator throws: throw parity).
33
+ */
34
+ export declare function isAscendingByFirstElement(rows: ReadonlyArray<ReadonlyArray<number>>): boolean;
35
+ /**
36
+ * Merge two time series arrays. The incoming series wins duplicate timestamps.
37
+ * @param {Array} srcTimeSeries Source Time Series array to which the new data should be appended
38
+ * @param {Array} newDataToBeMerged New time series data to be added to the src time series
39
+ * @param {Function} timeExtractor Callback that returns time when each time series item is passed. Default (point) => point[0] // 0th index being time
40
+ * @returns {Array} Merged time series array
41
+ */
42
+ export declare function mergeTimeSeries<T>(srcTimeSeries: T[], newDataToBeMerged: T[], timeExtractor?: (point: T) => number): T[];
43
+ /**
44
+ * Re-append live-built rows after a fresh primary response replaces the
45
+ * chart's rows. Any current row strictly newer than the fresh response's last
46
+ * row can only have come from the live feed or a poll that landed while the
47
+ * primary fetch was in flight: a cache-painted row always predates the fresh
48
+ * response tail. So this can extend a replace with live data but can never
49
+ * resurrect stale cached rows.
50
+ *
51
+ * That reasoning only holds when the current rows belong to the SAME request
52
+ * identity as the fresh reply. During a symbol switch the mounted rows can
53
+ * still be the OLD symbol's while the reply is the new one's; a 24/7 crypto
54
+ * series is "newer" than a session-gapped CME reply's tail every weekend, so
55
+ * the re-append would resurrect foreign bars and keep the old symbol's last
56
+ * price painting on the new chart. Callers that can compare identities pass
57
+ * `currentRowsMatchFreshIdentity: false` to drop the foreign tail instead of
58
+ * re-appending it (data-loading.md invariant 8, identity clause).
59
+ */
60
+ export declare function mergeFreshWithLiveTail<T>(freshRows: T[], currentRows: T[], timeExtractor?: (point: T) => number, options?: {
61
+ currentRowsMatchFreshIdentity?: boolean;
62
+ }): T[];
63
+ /** HH:MM:SS — mirrors priceScaleShaderLayer.formatHoursMinutesSeconds */
64
+ export declare function formatHoursMinutesSeconds(ms: number): string;
65
+ /**
66
+ * Calculate the polling period based on the interval and number of candles. For polling period, it defaults to 2 candles.
67
+ * @param interval - The time interval for the candles (e.g., '1m', '5m', '1h')
68
+ * @param numberOfCandles - The number of candles to consider for the polling period. Defaults to 2.
69
+ * @returns the period, for example, for '1m' interval and 2 candles, it returns 120 (2 minutes in seconds).
70
+ */
71
+ export declare const calculatePollingPeriod: (interval: string, numberOfCandles?: number) => number;
72
+ /**
73
+ * Is this fetch payload a steady-state poll cycle? The explicit `isPolling`
74
+ * marker (stamped by fetchIndicatorData for poll-lane dispatches) is
75
+ * authoritative: overlays with a PollingPeriods floor above the interval-based
76
+ * window (e.g. the 10-minute ETF cycle) never match the 2x-interval heuristic,
77
+ * which made every such poll raise the pane loader. The heuristic stays as the
78
+ * fallback for lanes that predate the marker.
79
+ */
80
+ export declare const isPollingFetchPayload: (payload: {
81
+ isPolling?: boolean;
82
+ from?: number;
83
+ period?: number;
84
+ interval?: string;
85
+ tf?: string;
86
+ } | null | undefined) => boolean;
87
+ /**
88
+ * Check if a given timestamp is within regular US market hours (9:30 AM - 4:00 PM ET)
89
+ * @param timestampMs - Timestamp in milliseconds
90
+ * @returns Object containing:
91
+ * - isRegularHours: true if within regular hours (9:30 AM - 4:00 PM ET)
92
+ * - sessionType: 'pre' | 'regular' | 'after' | 'closed'
93
+ */
94
+ export declare function checkUSMarketHours(timestampMs: number): {
95
+ isRegularHours: boolean;
96
+ sessionType: 'pre' | 'regular' | 'after' | 'closed';
97
+ };
98
+ export type ETParts = {
99
+ year: number;
100
+ month: number;
101
+ day: number;
102
+ weekday: number;
103
+ };
104
+ /**
105
+ * Project an instant onto the ET calendar. Uses Intl.DateTimeFormat directly
106
+ * (not dayjs) because consumers want discrete year/month/day/weekday fields
107
+ * for slug building and arithmetic, not a formatted string.
108
+ */
109
+ export declare function getETParts(now?: Date): ETParts;
110
+ /**
111
+ * Add or subtract whole days on an ET-derived calendar. Anchors at UTC noon
112
+ * to stay clear of DST edges, shifts, then re-projects — cheaper than
113
+ * implementing calendar arithmetic ourselves.
114
+ */
115
+ export declare function shiftETDay(base: ETParts, deltaDays: number): ETParts;
116
+ /**
117
+ * Stable "ET day" key. Two instants in the same ET calendar day produce the
118
+ * same string across any local timezone — use for rollover detection.
119
+ */
120
+ export declare function getETDayKey(now?: Date): string;
121
+ /** Stable ET-month key (e.g. "2026-3" for April). */
122
+ export declare function getETMonthKey(now?: Date): string;
123
+ /** Stable ET-week key anchored on Monday (matches PM weekly slug windows). */
124
+ export declare function getETWeekKey(now?: Date): string;
125
+ /**
126
+ * Merge two index-based time series arrays where the first element is a timestamp
127
+ * but the data is accessed by array index rather than timestamp lookup
128
+ * @param srcIndexSeries - The existing data array
129
+ * @param newDataToBeMerged - The new data to merge
130
+ * @param sortDirection - 1 for loading past data (prepend), 2 for loading future data (append)
131
+ * @param timeExtractor - Function to extract timestamp from data point
132
+ * @returns Merged array maintaining chronological order
133
+ */
134
+ export declare function mergeIndexSeries<T>(srcIndexSeries: T[], newDataToBeMerged: T[], sortDirection?: 1 | 2, timeExtractor?: (point: any) => any): T[];
@@ -0,0 +1,428 @@
1
+ import dayjs from 'dayjs';
2
+ import isArray from 'lodash-es/isArray.js';
3
+ import Utc from 'dayjs/plugin/utc.js';
4
+ import Timezone from 'dayjs/plugin/timezone.js';
5
+ import IsoWeek from 'dayjs/plugin/isoWeek.js';
6
+ import QuarterOfYear from 'dayjs/plugin/quarterOfYear.js';
7
+ import { Intervals } from '../../constants/interval.constants.js';
8
+ dayjs.extend(Utc);
9
+ dayjs.extend(Timezone);
10
+ dayjs.extend(IsoWeek);
11
+ dayjs.extend(QuarterOfYear);
12
+ const defaultPointTime = (point) => Number(point?.[0]);
13
+ function normalizedTimeSeries(rows, timeExtractor) {
14
+ const byTimestamp = new Map();
15
+ for (const row of rows) {
16
+ const timestamp = timeExtractor(row);
17
+ if (!Number.isFinite(timestamp))
18
+ continue;
19
+ byTimestamp.set(timestamp, row);
20
+ }
21
+ return Array.from(byTimestamp.entries())
22
+ .sort((a, b) => a[0] - b[0])
23
+ .map(([, row]) => row);
24
+ }
25
+ function isStrictlyIncreasingTimeSeries(rows, timeExtractor) {
26
+ let previous = Number.NEGATIVE_INFINITY;
27
+ for (const row of rows) {
28
+ const timestamp = timeExtractor(row);
29
+ if (!Number.isFinite(timestamp) || timestamp <= previous)
30
+ return false;
31
+ previous = timestamp;
32
+ }
33
+ return true;
34
+ }
35
+ /**
36
+ * Binary-search membership test for a timestamp in an ascending time series.
37
+ * Time-series rows commit sorted (mergeTimeSeries output, worker chunks), so a
38
+ * scan-free lookup stays cheap on the per-tick live path.
39
+ */
40
+ export function sortedTimeSeriesHasTimestamp(rows, timestamp) {
41
+ if (!rows?.length || !Number.isFinite(timestamp))
42
+ return false;
43
+ let lo = 0;
44
+ let hi = rows.length - 1;
45
+ while (lo <= hi) {
46
+ const mid = (lo + hi) >>> 1;
47
+ const midTs = rows[mid]?.[0];
48
+ if (!Number.isFinite(midTs))
49
+ return rows.some((row) => row?.[0] === timestamp);
50
+ if (midTs === timestamp)
51
+ return true;
52
+ if (midTs < timestamp)
53
+ lo = mid + 1;
54
+ else
55
+ hi = mid - 1;
56
+ }
57
+ return false;
58
+ }
59
+ export function liveTickFitsContiguousTail(tickTimestamp, rows, intervalMs, thresholdMultiplier = 1.5) {
60
+ if (!Number.isFinite(tickTimestamp))
61
+ return false;
62
+ const lastTs = rows?.[rows.length - 1]?.[0];
63
+ if (lastTs === undefined || !Number.isFinite(lastTs))
64
+ return false;
65
+ if (!Number.isFinite(intervalMs) || !intervalMs || intervalMs <= 0)
66
+ return false;
67
+ return tickTimestamp <= lastTs + intervalMs * thresholdMultiplier;
68
+ }
69
+ /** Test-only oracle: which branch the last mergeTimeSeries call took.
70
+ * Output equality cannot prove a fast path executed; this can. Written at
71
+ * EVERY exit ('bypass' for custom extractors and the non-array guard) so a
72
+ * spec can never read a stale value from an unrelated earlier call. */
73
+ export const __mergeFastPathStats = { lastPath: 'none' };
74
+ /** One pass: finite + strictly ascending, with boundaries captured so the
75
+ * classifier never re-extracts (an accessor-bearing row must not observe
76
+ * extra reads relative to a plain scan). */
77
+ function scanStrictlyAscendingFinite(rows, timeExtractor) {
78
+ let prev = Number.NEGATIVE_INFINITY;
79
+ let first = Number.NaN;
80
+ for (let i = 0; i < rows.length; i++) {
81
+ const timestamp = timeExtractor(rows[i]);
82
+ if (typeof timestamp !== 'number' || !Number.isFinite(timestamp) || timestamp <= prev) {
83
+ return { ok: false, first: Number.NaN, last: Number.NaN };
84
+ }
85
+ if (i === 0)
86
+ first = timestamp;
87
+ prev = timestamp;
88
+ }
89
+ return { ok: true, first, last: prev };
90
+ }
91
+ /**
92
+ * Classifier for mergeTimeSeries' concat fast paths, exported so the
93
+ * property spec can assert eligibility (the executed branch is proven via
94
+ * __mergeFastPathStats). A fast path requires BOTH arrays proven finite and
95
+ * strictly ascending and the batches disjoint at the boundary; equal
96
+ * boundary timestamps, overlap, duplicates inside either array, non-finite
97
+ * rows, or an empty side all take the legacy Map rebuild, whose replacement
98
+ * and filtering semantics stay authoritative.
99
+ */
100
+ export function classifyMergeFastPath(srcTimeSeries, newDataToBeMerged, timeExtractor) {
101
+ if (srcTimeSeries.length === 0 || newDataToBeMerged.length === 0)
102
+ return 'legacy';
103
+ // Cheap disqualification FIRST. The dominant live shape (forming-bar
104
+ // updates merging an equal-tail row every tick) can never concat, and it
105
+ // must not pay a full source walk just to find that out: scan only the
106
+ // small incoming batch, read the source BOUNDARIES in O(1), and pay the
107
+ // full source ascending proof only when a concat is still possible.
108
+ // (A NaN/non-number boundary makes both comparisons false: legacy.)
109
+ const next = scanStrictlyAscendingFinite(newDataToBeMerged, timeExtractor);
110
+ if (!next.ok)
111
+ return 'legacy';
112
+ const srcFirst = timeExtractor(srcTimeSeries[0]);
113
+ const srcLast = timeExtractor(srcTimeSeries[srcTimeSeries.length - 1]);
114
+ if (next.first > srcLast) {
115
+ return scanStrictlyAscendingFinite(srcTimeSeries, timeExtractor).ok ? 'append' : 'legacy';
116
+ }
117
+ if (next.last < srcFirst) {
118
+ return scanStrictlyAscendingFinite(srcTimeSeries, timeExtractor).ok ? 'prepend' : 'legacy';
119
+ }
120
+ return 'legacy';
121
+ }
122
+ /** Plain-Array concatenation by indexed copy: immune to overridden concat,
123
+ * Symbol.isConcatSpreadable, and array-species tricks on exotic inputs. */
124
+ function concatPlain(head, tail) {
125
+ const out = new Array(head.length + tail.length);
126
+ for (let i = 0; i < head.length; i++)
127
+ out[i] = head[i];
128
+ for (let i = 0; i < tail.length; i++)
129
+ out[head.length + i] = tail[i];
130
+ return out;
131
+ }
132
+ /**
133
+ * True when rows are ascending (non-strict) by row[0] AND every row[0] is a
134
+ * primitive non-NaN number. The apply body's scan-or-sort uses this: a
135
+ * stable sort of an already-ascending numeric array is an order no-op, so
136
+ * skipping it changes nothing observable. Non-number or NaN first elements
137
+ * report false so the sort still runs, preserving today's behavior for
138
+ * malformed rows exactly (including comparator throws: throw parity).
139
+ */
140
+ export function isAscendingByFirstElement(rows) {
141
+ let prev = Number.NEGATIVE_INFINITY;
142
+ for (let i = 0; i < rows.length; i++) {
143
+ // Optional chaining: a nullish row or hole must report "unsorted" (the
144
+ // sort runs and tolerates it, as it always did), never throw here.
145
+ const value = rows[i]?.[0];
146
+ if (typeof value !== 'number' || Number.isNaN(value))
147
+ return false;
148
+ if (value < prev)
149
+ return false;
150
+ prev = value;
151
+ }
152
+ return true;
153
+ }
154
+ /**
155
+ * Merge two time series arrays. The incoming series wins duplicate timestamps.
156
+ * @param {Array} srcTimeSeries Source Time Series array to which the new data should be appended
157
+ * @param {Array} newDataToBeMerged New time series data to be added to the src time series
158
+ * @param {Function} timeExtractor Callback that returns time when each time series item is passed. Default (point) => point[0] // 0th index being time
159
+ * @returns {Array} Merged time series array
160
+ */
161
+ export function mergeTimeSeries(srcTimeSeries, newDataToBeMerged, timeExtractor = defaultPointTime) {
162
+ if (!isArray(srcTimeSeries) || !isArray(newDataToBeMerged)) {
163
+ __mergeFastPathStats.lastPath = 'bypass';
164
+ return srcTimeSeries;
165
+ }
166
+ // O(N) concat fast paths for the dominant delivery shapes (poll tails,
167
+ // lazy backfills): no Map, no sort, one outer-array allocation. Guarded by
168
+ // scanning BOTH arrays: the mounted series is NOT assumed sorted (kScript
169
+ // replace paths can install unsorted or non-finite rows). Custom
170
+ // extractors bypass classification so their observable call pattern stays
171
+ // exactly the legacy one.
172
+ if (timeExtractor === defaultPointTime) {
173
+ const fastPath = classifyMergeFastPath(srcTimeSeries, newDataToBeMerged, timeExtractor);
174
+ __mergeFastPathStats.lastPath = fastPath;
175
+ if (fastPath === 'append')
176
+ return concatPlain(srcTimeSeries, newDataToBeMerged);
177
+ if (fastPath === 'prepend')
178
+ return concatPlain(newDataToBeMerged, srcTimeSeries);
179
+ }
180
+ else {
181
+ __mergeFastPathStats.lastPath = 'bypass';
182
+ }
183
+ const byTimestamp = new Map();
184
+ for (const row of srcTimeSeries) {
185
+ const timestamp = timeExtractor(row);
186
+ if (Number.isFinite(timestamp))
187
+ byTimestamp.set(timestamp, row);
188
+ }
189
+ for (const row of newDataToBeMerged) {
190
+ const timestamp = timeExtractor(row);
191
+ if (Number.isFinite(timestamp))
192
+ byTimestamp.set(timestamp, row);
193
+ }
194
+ return Array.from(byTimestamp.entries())
195
+ .sort((a, b) => a[0] - b[0])
196
+ .map(([, row]) => row);
197
+ }
198
+ /**
199
+ * Re-append live-built rows after a fresh primary response replaces the
200
+ * chart's rows. Any current row strictly newer than the fresh response's last
201
+ * row can only have come from the live feed or a poll that landed while the
202
+ * primary fetch was in flight: a cache-painted row always predates the fresh
203
+ * response tail. So this can extend a replace with live data but can never
204
+ * resurrect stale cached rows.
205
+ *
206
+ * That reasoning only holds when the current rows belong to the SAME request
207
+ * identity as the fresh reply. During a symbol switch the mounted rows can
208
+ * still be the OLD symbol's while the reply is the new one's; a 24/7 crypto
209
+ * series is "newer" than a session-gapped CME reply's tail every weekend, so
210
+ * the re-append would resurrect foreign bars and keep the old symbol's last
211
+ * price painting on the new chart. Callers that can compare identities pass
212
+ * `currentRowsMatchFreshIdentity: false` to drop the foreign tail instead of
213
+ * re-appending it (data-loading.md invariant 8, identity clause).
214
+ */
215
+ export function mergeFreshWithLiveTail(freshRows, currentRows, timeExtractor = defaultPointTime, options = {}) {
216
+ if (!isArray(freshRows) || !freshRows.length)
217
+ return freshRows;
218
+ if (!isArray(currentRows) || !currentRows.length)
219
+ return freshRows;
220
+ if (options.currentRowsMatchFreshIdentity === false)
221
+ return freshRows;
222
+ const normalizedFresh = isStrictlyIncreasingTimeSeries(freshRows, timeExtractor)
223
+ ? freshRows
224
+ : normalizedTimeSeries(freshRows, timeExtractor);
225
+ const freshEndTime = timeExtractor(normalizedFresh[normalizedFresh.length - 1]);
226
+ if (!Number.isFinite(freshEndTime))
227
+ return normalizedFresh;
228
+ const liveTail = normalizedTimeSeries(currentRows.filter((row) => timeExtractor(row) > freshEndTime), timeExtractor);
229
+ if (!liveTail.length)
230
+ return normalizedFresh;
231
+ return normalizedFresh.concat(liveTail);
232
+ }
233
+ /** HH:MM:SS — mirrors priceScaleShaderLayer.formatHoursMinutesSeconds */
234
+ export function formatHoursMinutesSeconds(ms) {
235
+ const total = Math.max(0, Math.floor(ms / 1000));
236
+ const hours = Math.floor(total / 3600);
237
+ const minutes = Math.floor((total % 3600) / 60);
238
+ const seconds = total % 60;
239
+ const pad = (n) => n.toString().padStart(2, '0');
240
+ return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
241
+ }
242
+ /**
243
+ * Calculate the polling period based on the interval and number of candles. For polling period, it defaults to 2 candles.
244
+ * @param interval - The time interval for the candles (e.g., '1m', '5m', '1h')
245
+ * @param numberOfCandles - The number of candles to consider for the polling period. Defaults to 2.
246
+ * @returns the period, for example, for '1m' interval and 2 candles, it returns 120 (2 minutes in seconds).
247
+ */
248
+ export const calculatePollingPeriod = (interval, numberOfCandles = 2) => {
249
+ const validInterval = (Intervals.map_unit[interval] ?? Intervals.map_unit['1m']) / 1000; // Convert to seconds
250
+ return validInterval * numberOfCandles;
251
+ };
252
+ /**
253
+ * Is this fetch payload a steady-state poll cycle? The explicit `isPolling`
254
+ * marker (stamped by fetchIndicatorData for poll-lane dispatches) is
255
+ * authoritative: overlays with a PollingPeriods floor above the interval-based
256
+ * window (e.g. the 10-minute ETF cycle) never match the 2x-interval heuristic,
257
+ * which made every such poll raise the pane loader. The heuristic stays as the
258
+ * fallback for lanes that predate the marker.
259
+ */
260
+ export const isPollingFetchPayload = (payload) => payload?.isPolling === true ||
261
+ (payload?.from === 0 && payload?.period === calculatePollingPeriod(payload?.interval ?? payload?.tf ?? ''));
262
+ /**
263
+ * US Market hours constants (in US/Eastern timezone)
264
+ * Regular trading: 9:30 AM - 4:00 PM ET
265
+ * Pre-market: 4:00 AM - 9:30 AM ET
266
+ * After-hours: 4:00 PM - 8:00 PM ET
267
+ */
268
+ const US_MARKET_HOURS = {
269
+ PRE_MARKET_START: { hour: 4, minute: 0 }, // 4:00 AM ET
270
+ REGULAR_START: { hour: 9, minute: 30 }, // 9:30 AM ET
271
+ REGULAR_END: { hour: 16, minute: 0 }, // 4:00 PM ET
272
+ AFTER_HOURS_END: { hour: 20, minute: 0 }, // 8:00 PM ET
273
+ };
274
+ /**
275
+ * Check if a given timestamp is within regular US market hours (9:30 AM - 4:00 PM ET)
276
+ * @param timestampMs - Timestamp in milliseconds
277
+ * @returns Object containing:
278
+ * - isRegularHours: true if within regular hours (9:30 AM - 4:00 PM ET)
279
+ * - sessionType: 'pre' | 'regular' | 'after' | 'closed'
280
+ */
281
+ export function checkUSMarketHours(timestampMs) {
282
+ // Convert timestamp to US/Eastern timezone
283
+ const etTime = dayjs(timestampMs).tz('America/New_York');
284
+ const dayOfWeek = etTime.day(); // 0 = Sunday, 6 = Saturday
285
+ // Check if it's a weekend
286
+ if (dayOfWeek === 0 || dayOfWeek === 6) {
287
+ return { isRegularHours: false, sessionType: 'closed' };
288
+ }
289
+ const hour = etTime.hour();
290
+ const minute = etTime.minute();
291
+ const timeInMinutes = hour * 60 + minute;
292
+ // Calculate time boundaries in minutes since midnight
293
+ const preMarketStart = US_MARKET_HOURS.PRE_MARKET_START.hour * 60 + US_MARKET_HOURS.PRE_MARKET_START.minute;
294
+ const regularStart = US_MARKET_HOURS.REGULAR_START.hour * 60 + US_MARKET_HOURS.REGULAR_START.minute;
295
+ const regularEnd = US_MARKET_HOURS.REGULAR_END.hour * 60 + US_MARKET_HOURS.REGULAR_END.minute;
296
+ const afterHoursEnd = US_MARKET_HOURS.AFTER_HOURS_END.hour * 60 + US_MARKET_HOURS.AFTER_HOURS_END.minute;
297
+ // Determine session type
298
+ if (timeInMinutes >= regularStart && timeInMinutes < regularEnd) {
299
+ return { isRegularHours: true, sessionType: 'regular' };
300
+ }
301
+ else if (timeInMinutes >= preMarketStart && timeInMinutes < regularStart) {
302
+ return { isRegularHours: false, sessionType: 'pre' };
303
+ }
304
+ else if (timeInMinutes >= regularEnd && timeInMinutes < afterHoursEnd) {
305
+ return { isRegularHours: false, sessionType: 'after' };
306
+ }
307
+ else {
308
+ return { isRegularHours: false, sessionType: 'closed' };
309
+ }
310
+ }
311
+ // ─── ET calendar helpers ─────────────────────────────────────────────────
312
+ // Used for anything that needs to reason about "the current ET calendar day"
313
+ // independent of the user's local timezone — e.g. building slugs for
314
+ // markets/schedules that settle in ET, or detecting ET-day rollover.
315
+ const ET_TIMEZONE = 'America/New_York';
316
+ const WEEKDAY_INDEX = {
317
+ Sun: 0,
318
+ Mon: 1,
319
+ Tue: 2,
320
+ Wed: 3,
321
+ Thu: 4,
322
+ Fri: 5,
323
+ Sat: 6,
324
+ };
325
+ /**
326
+ * Project an instant onto the ET calendar. Uses Intl.DateTimeFormat directly
327
+ * (not dayjs) because consumers want discrete year/month/day/weekday fields
328
+ * for slug building and arithmetic, not a formatted string.
329
+ */
330
+ export function getETParts(now = new Date()) {
331
+ const parts = new Intl.DateTimeFormat('en-US', {
332
+ timeZone: ET_TIMEZONE,
333
+ year: 'numeric',
334
+ month: 'numeric',
335
+ day: 'numeric',
336
+ weekday: 'short',
337
+ }).formatToParts(now);
338
+ let year = 0;
339
+ let month = 0;
340
+ let day = 0;
341
+ let weekday = 0;
342
+ for (const p of parts) {
343
+ if (p.type === 'year')
344
+ year = parseInt(p.value, 10);
345
+ else if (p.type === 'month')
346
+ month = parseInt(p.value, 10) - 1;
347
+ else if (p.type === 'day')
348
+ day = parseInt(p.value, 10);
349
+ else if (p.type === 'weekday')
350
+ weekday = WEEKDAY_INDEX[p.value] ?? 0;
351
+ }
352
+ return { year, month, day, weekday };
353
+ }
354
+ /**
355
+ * Add or subtract whole days on an ET-derived calendar. Anchors at UTC noon
356
+ * to stay clear of DST edges, shifts, then re-projects — cheaper than
357
+ * implementing calendar arithmetic ourselves.
358
+ */
359
+ export function shiftETDay(base, deltaDays) {
360
+ const anchor = new Date(Date.UTC(base.year, base.month, base.day, 12, 0, 0));
361
+ anchor.setUTCDate(anchor.getUTCDate() + deltaDays);
362
+ return getETParts(anchor);
363
+ }
364
+ /**
365
+ * Stable "ET day" key. Two instants in the same ET calendar day produce the
366
+ * same string across any local timezone — use for rollover detection.
367
+ */
368
+ export function getETDayKey(now = new Date()) {
369
+ const { year, month, day } = getETParts(now);
370
+ return `${year}-${month}-${day}`;
371
+ }
372
+ /** Stable ET-month key (e.g. "2026-3" for April). */
373
+ export function getETMonthKey(now = new Date()) {
374
+ const { year, month } = getETParts(now);
375
+ return `${year}-${month}`;
376
+ }
377
+ /** Stable ET-week key anchored on Monday (matches PM weekly slug windows). */
378
+ export function getETWeekKey(now = new Date()) {
379
+ const parts = getETParts(now);
380
+ const diffToMonday = parts.weekday === 0 ? -6 : 1 - parts.weekday;
381
+ const monday = shiftETDay(parts, diffToMonday);
382
+ return `W-${monday.year}-${monday.month}-${monday.day}`;
383
+ }
384
+ /**
385
+ * Merge two index-based time series arrays where the first element is a timestamp
386
+ * but the data is accessed by array index rather than timestamp lookup
387
+ * @param srcIndexSeries - The existing data array
388
+ * @param newDataToBeMerged - The new data to merge
389
+ * @param sortDirection - 1 for loading past data (prepend), 2 for loading future data (append)
390
+ * @param timeExtractor - Function to extract timestamp from data point
391
+ * @returns Merged array maintaining chronological order
392
+ */
393
+ export function mergeIndexSeries(srcIndexSeries, newDataToBeMerged, sortDirection = 2, timeExtractor = (point) => point?.[0]) {
394
+ if (!isArray(srcIndexSeries) || !isArray(newDataToBeMerged))
395
+ return srcIndexSeries;
396
+ // Handle empty cases
397
+ if (!srcIndexSeries.length && !newDataToBeMerged.length)
398
+ return [];
399
+ if (!srcIndexSeries.length && newDataToBeMerged.length)
400
+ return newDataToBeMerged;
401
+ if (!newDataToBeMerged.length && srcIndexSeries.length)
402
+ return srcIndexSeries;
403
+ // Create a map of existing timestamps to avoid duplicates
404
+ const existingTimestamps = new Set(srcIndexSeries.map((item) => timeExtractor(item)));
405
+ // Filter out duplicates from new data, keeping only unique timestamps
406
+ const newUniqueData = newDataToBeMerged.filter((item) => {
407
+ const timestamp = timeExtractor(item);
408
+ return timestamp && !existingTimestamps.has(timestamp);
409
+ });
410
+ if (newUniqueData.length === 0)
411
+ return srcIndexSeries;
412
+ let mergedArray;
413
+ if (sortDirection === 1) {
414
+ // Loading past data - prepend new data to the beginning
415
+ mergedArray = [...newUniqueData, ...srcIndexSeries];
416
+ }
417
+ else {
418
+ // Loading future data - append new data to the end
419
+ mergedArray = [...srcIndexSeries, ...newUniqueData];
420
+ }
421
+ // Sort by timestamp to ensure chronological order
422
+ mergedArray.sort((a, b) => {
423
+ const timeA = timeExtractor(a);
424
+ const timeB = timeExtractor(b);
425
+ return timeA - timeB;
426
+ });
427
+ return mergedArray;
428
+ }