@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,205 @@
1
+ /**
2
+ * Footprint display bands are CENTERED on their price level.
3
+ *
4
+ * The server (and the live bucketing) reports volume AT a grid price: the
5
+ * profile row for a bar's high is the high itself. Rendering that price as
6
+ * the band's BOTTOM edge draws the high row's cell entirely above the wick
7
+ * (and the low row flush-inside), because boundary trades always sit exactly
8
+ * on the grid. Centering matches the TPO renderer's convention
9
+ * (price - tickSize / 2) and keeps the extreme rows straddling the wick tips.
10
+ *
11
+ * Coarse cells (render height > tick, i.e. barHeightMultiplier >= 2) hold the
12
+ * fine levels [rung, rung + cellHeight). Their band is the union of those
13
+ * levels' centered bands: [rung - tick/2, rung + cellHeight - tick/2]. The
14
+ * offset is half a TICK, not half the cell: shifting by cellHeight/2 (the
15
+ * pre-2026-08 behavior) parked every coarse cell half a row below where its
16
+ * volume traded, so the top cell could end below the bar's high while the
17
+ * bottom cell overhung the low. Cells keep the full grid width, which keeps
18
+ * adjacent cells contiguous and titan's row-LOD merge stable.
19
+ *
20
+ * Both producers of footprint buckets use this with the settings tick: the
21
+ * worker's historical fetch and the live delta merge (for a row with no cell
22
+ * to copy its phase from). Neither keys on the resulting priceLow: cells are
23
+ * identified by their integer row index (footprint-cell-identity.util), so a
24
+ * tick that differs between the two in the last bit moves a cell's drawing
25
+ * by at most half a tick and can never split it into two.
26
+ *
27
+ * The tick is the ANCHOR tick (`resolveFootprintAnchorTick`): the exchange
28
+ * price tick inferred from the chart's own candles, clamped to each row's own
29
+ * height. The minimum block is NOT the tick on every venue: the
30
+ * gateway serves Binance BTCUSDT profiles in 3.0 buckets keyed by the bucket
31
+ * LOW (trades at 78533.8 land in row 78531), so a half-BLOCK offset drew every
32
+ * cell 1.5 too low and the row holding the candle low sat entirely under the
33
+ * wick (field case 2026-09-11). Where block == tick (CME after the exchange-tick
34
+ * move, prediction cents) the anchor is the block and nothing changes.
35
+ *
36
+ * Centering is the LAST step of the fetch pipeline, at the render bar height:
37
+ * everything upstream floors priceLow onto a zero-based grid, so a half-shifted
38
+ * low lands a rung low and regroups the cells. Changing this anchoring changes
39
+ * the cached-row format: bump INDICATOR_CACHE_CONFIG.SCHEMA_VERSION with it.
40
+ */
41
+ // Local, DOM-free decimal counter (titan's getDecimalPlaces touches `location`
42
+ // at module init, which breaks node specs importing this util). Exponent-aware:
43
+ // micro ticks stringify as "1e-7", and treating that as 0 decimals would round
44
+ // the half-tick offset away entirely on micro-priced symbols.
45
+ export function decimalPlaces(value) {
46
+ if (!Number.isFinite(value))
47
+ return 0;
48
+ const text = String(value);
49
+ const eIndex = text.indexOf('e') !== -1 ? text.indexOf('e') : text.indexOf('E');
50
+ if (eIndex === -1) {
51
+ const dot = text.indexOf('.');
52
+ return dot === -1 ? 0 : text.length - dot - 1;
53
+ }
54
+ const mantissa = text.slice(0, eIndex);
55
+ const exponent = Number(text.slice(eIndex + 1));
56
+ const dot = mantissa.indexOf('.');
57
+ const mantissaDecimals = dot === -1 ? 0 : mantissa.length - dot - 1;
58
+ return Math.max(0, mantissaDecimals - exponent);
59
+ }
60
+ export function centeredFootprintBand(gridPrice, bandHeight, tickSize) {
61
+ // The half-shift offset rides the TICK grid. Normalize a missing or invalid
62
+ // tick (undefined, null, 0, NaN) to the band height HERE, never at the call
63
+ // sites: a JS default parameter does not fire for null, and `null / 2` would
64
+ // silently bottom-anchor the band while every other producer stays centered.
65
+ // A tick coarser than the band (a thin-sample inference, or a catalog block
66
+ // finer than the served rows) clamps to the band: the offset never exceeds
67
+ // half a row, and a row that IS one tick tall stays centered on its level.
68
+ // The clamp target is the band snapped to 9 significant digits: the worker
69
+ // passes the raw settings product (0.05 * 6 = 0.30000000000000004) and the
70
+ // live merge a toPrecision(9)-snapped span, and a precision read off the
71
+ // noisy double would round the two producers' priceHigh onto different digits.
72
+ const bandTick = Number(bandHeight.toPrecision(9));
73
+ const tick = typeof tickSize === 'number' && Number.isFinite(tickSize) && tickSize > 0 ? Math.min(tickSize, bandTick) : bandTick;
74
+ // Half of a k-decimal tick needs at most k+1 decimals, and the rung itself
75
+ // needs the band's decimals: a served block that is not a tick multiple
76
+ // (Binance ZECUSDT 0.0375 on a 0.01 tick) keys rungs at 4 decimals, and a
77
+ // tick-only precision of 3 rounded every other rung a half thousandth off
78
+ // (2026-09-12 "0/1 overlapping" report). The band snapped to 9 significant
79
+ // digits (bandTick), never the raw float-noisy product
80
+ // (0.05 * 6 = 0.30000000000000004), keeps the precision identical for the
81
+ // worker and the live merge. The cap is 15, not 12: a 12-decimal micro
82
+ // block (Binance PUMPUSDT 9.84375e-7) needs 13 for its half offset
83
+ // (2026-09-14 field case). 15 decimals stay inside double precision for
84
+ // every price under 1, and blocks with fewer decimals never reach the cap.
85
+ const precision = Math.min(15, Math.max(decimalPlaces(tick) + 1, decimalPlaces(bandTick) + 1));
86
+ const low = Number((gridPrice - tick / 2).toFixed(precision));
87
+ const high = Number((low + bandHeight).toFixed(precision));
88
+ return [low, high];
89
+ }
90
+ /** Candle rows sampled for the tick inference (main rawData: [ts, o, h, l, c, ...]). */
91
+ export const PRICE_TICK_INFERENCE_ROWS = 2000;
92
+ /**
93
+ * Rows a sample needs before its lattice is trusted as the tick: a chart
94
+ * that just switched interval or symbol holds a handful of bars, whose few
95
+ * prices can sit many ticks apart (a 2-bar BTC sample read 1.2 for a 0.1 tick).
96
+ * A coarse estimate from a thin sample is only cosmetic and self-healing: the
97
+ * adoption re-runs when a grown sample reveals a finer tick.
98
+ */
99
+ const PRICE_TICK_INFERENCE_MIN_ROWS = 12;
100
+ function positiveFinite(value) {
101
+ return typeof value === 'number' && Number.isFinite(value) && value > 0;
102
+ }
103
+ /** Decimal places past which a sample has no decimal lattice the inference can trust. */
104
+ const PRICE_TICK_MAX_DECIMALS = 15;
105
+ /**
106
+ * Significant digits a price keeps before its decimals are counted: a price
107
+ * computed on the client (a fold, a ratio, a spec's `78533.8 + i * 0.1`)
108
+ * carries float noise past the 15th digit (78533.90000000001) that would
109
+ * read as an 11-decimal lattice. No traded price needs more than 12.
110
+ */
111
+ const PRICE_TICK_SIGNIFICANT_DIGITS = 12;
112
+ /**
113
+ * The finest tick a real lattice has relative to its price (BRK.A trades
114
+ * 0.01 at 700,000: 1.4e-8). A GCD finer than this is the 12-digit read of a
115
+ * series with no lattice at all (split-adjusted 250 / 3), not a tick.
116
+ */
117
+ const PRICE_TICK_MIN_RELATIVE = 1e-10;
118
+ function greatestCommonDivisor(a, b) {
119
+ while (b)
120
+ [a, b] = [b, a % b];
121
+ return a;
122
+ }
123
+ /**
124
+ * The exchange price tick as the chart's own candles reveal it: the greatest
125
+ * common divisor of every OHLC value's distance to the first, computed in
126
+ * whole units of the sample's decimal places and returned as a clean decimal.
127
+ * No metadata carries a per-symbol tick, and the profile block catalog is not
128
+ * one (Binance BTCUSDT: block 3.0, tick 0.1). Every traded price is a tick
129
+ * multiple, so the estimate can only ever be the tick or a multiple of it (a
130
+ * thin sample), never finer.
131
+ *
132
+ * Integer arithmetic, not the smallest float gap: at 85,000 a 0.01 gap
133
+ * subtracts to 0.0099999999947 and snapping it to 9 significant digits kept
134
+ * the dust (0.00999999999 on Coinbase BTC-USD, Binance BTCUSDT spot, BRK.A;
135
+ * 0.000999999999 on a 0.001-tick ETH book). Each price is read at
136
+ * PRICE_TICK_SIGNIFICANT_DIGITS so client-side float noise is not a lattice.
137
+ * Null below `minRows` rows, until two distinct prices exist, or when the
138
+ * sample has no decimal lattice (more than PRICE_TICK_MAX_DECIMALS places:
139
+ * AMM-priced tokens, split-adjusted stocks) or its whole units overflow safe
140
+ * integers: the caller then keeps the block anchor instead of a garbage tick.
141
+ */
142
+ export function inferPriceTickFromRows(rows, maxRows = PRICE_TICK_INFERENCE_ROWS, minRows = PRICE_TICK_INFERENCE_MIN_ROWS) {
143
+ if (!rows || !(rows.length >= Math.max(1, minRows)))
144
+ return null;
145
+ const prices = [];
146
+ let decimals = 0;
147
+ const start = Math.max(0, rows.length - maxRows);
148
+ for (let i = start; i < rows.length; i++) {
149
+ const row = rows[i];
150
+ if (!Array.isArray(row))
151
+ continue;
152
+ for (let j = 1; j <= 4 && j < row.length; j++) {
153
+ const value = row[j];
154
+ if (!positiveFinite(value))
155
+ continue;
156
+ const price = Number(value.toPrecision(PRICE_TICK_SIGNIFICANT_DIGITS));
157
+ prices.push(price);
158
+ decimals = Math.max(decimals, decimalPlaces(price));
159
+ }
160
+ }
161
+ if (prices.length < 2 || decimals > PRICE_TICK_MAX_DECIMALS)
162
+ return null;
163
+ const scale = 10 ** decimals;
164
+ const origin = Math.round(prices[0] * scale);
165
+ if (!Number.isSafeInteger(origin))
166
+ return null;
167
+ let units = 0;
168
+ let maxPrice = 0;
169
+ for (const price of prices) {
170
+ const scaled = Math.round(price * scale);
171
+ if (!Number.isSafeInteger(scaled))
172
+ return null;
173
+ units = greatestCommonDivisor(units, Math.abs(scaled - origin));
174
+ if (price > maxPrice)
175
+ maxPrice = price;
176
+ }
177
+ if (!(units > 0))
178
+ return null;
179
+ const tick = Number((units / scale).toFixed(decimals));
180
+ return tick >= maxPrice * PRICE_TICK_MIN_RELATIVE ? tick : null;
181
+ }
182
+ /**
183
+ * The tick both footprint producers anchor on: the inferred exchange tick when
184
+ * one is known, else the overlay's minimum block (the pre-existing convention,
185
+ * exact where the served block IS the tick). `centeredFootprintBand` clamps
186
+ * it to each row's own height, so a tick coarser than a row (a thin sample,
187
+ * or a catalog block finer than the served rows) can never widen the offset
188
+ * past half that row. An unusable block with no tick yields undefined so the
189
+ * band keeps its half-height fallback.
190
+ */
191
+ export function resolveFootprintAnchorTick(minimumBarHeight, priceTick) {
192
+ if (positiveFinite(priceTick))
193
+ return priceTick;
194
+ return positiveFinite(minimumBarHeight) ? minimumBarHeight : undefined;
195
+ }
196
+ /** Rebuilds rather than mutates: the buckets may be the caller's own accumulator arrays. */
197
+ export function centerFootprintRows(rows, bandHeight, tickSize) {
198
+ return rows.map((row) => {
199
+ const centered = row.slice(1).map((bucket) => {
200
+ const [low, high] = centeredFootprintBand(bucket[0], bandHeight, tickSize);
201
+ return [low, high, ...bucket.slice(2)];
202
+ });
203
+ return [row[0], ...centered];
204
+ });
205
+ }
@@ -0,0 +1,82 @@
1
+ type Cell = number[];
2
+ /**
3
+ * Grid index of a price on a zero-based grid of height `step`, floored with
4
+ * the live fold's dust tolerance: an on-grid price can divide a hair below
5
+ * its multiple (2.377 / 0.001 = 2376.9999999999995) and a plain floor drops
6
+ * it one row. Every footprint fold uses this, so a boundary trade lands on
7
+ * the same row in the fetch rebucket, the RTH fold and the live lane.
8
+ */
9
+ export declare function floorFootprintGridIndex(price: number, step: number): number;
10
+ /** Row index of a bottom-anchored grid level (a live delta's gridLow, k * step). */
11
+ export declare function footprintGridIndex(gridLow: number, step: number): number;
12
+ /** Row index of a centered footprint cell [low, high): its midpoint sits in [k, k + 0.5) rows. */
13
+ export declare function footprintCellIndex(cell: ArrayLike<number>, step: number): number;
14
+ /** A row's grid height: its first cell's decimal height (`cellStep`), or null without a cell. */
15
+ export declare function footprintRowStep(row: ArrayLike<unknown> | null | undefined): number | null;
16
+ export declare function sameFootprintStep(a: number, b: number): boolean;
17
+ /**
18
+ * Whether two rows of one bar sit on one lattice: the same grid height and,
19
+ * when both carry at least two cells, at least one shared row index. Two
20
+ * snapshots of one bar always share the rows they both saw trade; rows with
21
+ * the same height but no common row are shifted copies (the 2026-09-14
22
+ * PUMPUSDT rows one block apart, each totaling 3,718,492, would union to
23
+ * twice that). Anchors and float dust never change an index, so rows
24
+ * centered on 0.01 and on 0.00999999999, or on the tick and on the block,
25
+ * share their rows here. Rows with fewer than two cells give too little
26
+ * evidence and stay mergeable.
27
+ */
28
+ export declare function footprintRowsShareLattice(a: ArrayLike<unknown>, b: ArrayLike<unknown>): boolean;
29
+ export interface FootprintLiveDeltaMerge {
30
+ /** The bar's cells, ascending. */
31
+ cells: Cell[];
32
+ /** Deltas merged on the row's own grid. */
33
+ applied: number;
34
+ /** Deltas on a finer grid folded up into the row's grid. */
35
+ folded: number;
36
+ /** Deltas on a coarser or non-dividing grid: dropped, the next snapshot owns their volume. */
37
+ rejected: number;
38
+ /** Held cells that shared an index and collapsed into one. */
39
+ collapsed: number;
40
+ }
41
+ export interface FootprintLiveDeltaMergeOptions {
42
+ /**
43
+ * Whether `baseRow` is THIS bar's row and its volumes are the accumulation
44
+ * base. False for a new bar (the base is the previous bar's row, kept for
45
+ * its geometry only) and for an absolute row, which replaces the bar.
46
+ */
47
+ seedVolumes: boolean;
48
+ /** Geometry for a cell when the row has no template cell on the same grid: the settings-anchored band. */
49
+ seedBand: (gridLow: number, step: number) => [number, number];
50
+ }
51
+ /**
52
+ * The add door: fold live deltas (bottom-anchored grid cells
53
+ * [gridLow, gridHigh, buy, sell, (buyCount, sellCount)]) into a bar.
54
+ *
55
+ * The bar keeps ONE grid. When the deltas accumulate into this bar's held
56
+ * row, that row's grid decides: a delta on a finer grid that divides it folds
57
+ * up and any other grid is rejected, so a row can never hold cells of two
58
+ * heights. A new bar or an absolute row (nothing held to accumulate into)
59
+ * takes the deltas' own grid, as before. New cells copy the phase of a
60
+ * template cell on the same grid (this bar's, else the previous bar's), and
61
+ * only a row with no such template falls back to `seedBand`.
62
+ */
63
+ export declare function mergeFootprintLiveDeltas(baseRow: ArrayLike<unknown> | null | undefined, deltas: ReadonlyArray<ArrayLike<number>>, options: FootprintLiveDeltaMergeOptions): FootprintLiveDeltaMerge;
64
+ export interface FootprintSnapshotCellsMerge {
65
+ cells: Cell[];
66
+ /** Indices where the snapshot raised the held value (buy or sell). */
67
+ raisedCells: number;
68
+ /** Indices where the held value stayed above the snapshot. */
69
+ keptCells: number;
70
+ /** False when the grids differ and the snapshot was taken wholesale. */
71
+ sharedGrid: boolean;
72
+ }
73
+ /**
74
+ * The max door: a fetched snapshot over a held row of the same bar. Per-index
75
+ * max, in the FETCHED row's geometry (held-only cells translated onto it), so
76
+ * the merged row has one phase whatever anchors the two sides were centered
77
+ * on. Rows on different grids cannot share a per-index max: the snapshot is
78
+ * taken wholesale (`sharedGrid: false`), the same rule the callers' lattice
79
+ * gate applies.
80
+ */
81
+ export declare function mergeFootprintSnapshotCells(heldRow: ArrayLike<unknown>, fetchedRow: ArrayLike<unknown>): FootprintSnapshotCellsMerge;
82
+ export {};
@@ -0,0 +1,346 @@
1
+ /**
2
+ * Footprint cell identity: the ONE rule every footprint row write uses to
3
+ * decide "same cell".
4
+ *
5
+ * A cell is its INTEGER row index on its row's own grid, never a price float.
6
+ * Every producer keys rows on a zero-based grid of height `step` (the server
7
+ * buckets, the worker rebucket, the live fold), and the fetch pipeline then
8
+ * centers each cell by half an anchor tick t in (0, step]
9
+ * (`centeredFootprintBand`): low = k * step - t / 2. The midpoint therefore
10
+ * sits in [k, k + 0.5) rows whatever tick, precision or float dust drew it,
11
+ * so `floor(mid / step + 0.25)` recovers k with a quarter-row margin on both
12
+ * sides. A bottom-anchored grid level (a live delta) is k * step itself.
13
+ *
14
+ * Why not the price: the worker and the live merge each derived priceLow on
15
+ * their own and matched it by exact double equality. Any input that made the
16
+ * two derivations disagree in the last bit (an inferred tick of
17
+ * 0.00999999999 read back as 0.01, a cache paint keyed on an older anchor, a
18
+ * replay seed keyed on the settings anchor) opened a second cell in the same
19
+ * row, and the poll floors (a 1e-9 tolerant gate followed by an exact-key
20
+ * union) kept it and double counted its volume (2026-10-04, Coinbase BTC-USD
21
+ * 1h: two cells in the forming bar's live row). With an integer identity a
22
+ * wrong anchor can move a cell's drawing by at most half a tick, never split
23
+ * it.
24
+ *
25
+ * Merge modes (the doors):
26
+ * - add (`mergeFootprintLiveDeltas`): live deltas into a held row. A delta on
27
+ * a finer grid that divides the row folds up with the live fold's own dust
28
+ * tolerance; a coarser or non-dividing delta is DROPPED and counted (the
29
+ * next poll owns that volume), never drawn on a second lattice.
30
+ * - max (`mergeFootprintSnapshotCells`): a fetched snapshot over a held row.
31
+ * Per-index max, and the merged row takes the FETCHED row's geometry (one
32
+ * phase per row); held-only cells are translated onto it.
33
+ * Cells inside one row that share an index (rows persisted before this
34
+ * identity, or any producer slip) are pieces of that row and collapse by sum.
35
+ */
36
+ import { decimalPlaces } from './footprint-band.util.js';
37
+ /** Relative tolerance under which two row heights are the same grid. */
38
+ const STEP_TOLERANCE = 1e-6;
39
+ /** The live fold's division-dust tolerance (aggregated-volume-profile-storage.service). */
40
+ const GRID_FLOOR_DUST = 8 * Number.EPSILON;
41
+ /** A cell with finite numeric bounds (numeric strings included) and a positive height. */
42
+ function isCell(value) {
43
+ if (!Array.isArray(value) || value.length < 2)
44
+ return false;
45
+ const low = Number(value[0]);
46
+ const high = Number(value[1]);
47
+ return Number.isFinite(low) && Number.isFinite(high) && high > low;
48
+ }
49
+ /**
50
+ * Grid index of a price on a zero-based grid of height `step`, floored with
51
+ * the live fold's dust tolerance: an on-grid price can divide a hair below
52
+ * its multiple (2.377 / 0.001 = 2376.9999999999995) and a plain floor drops
53
+ * it one row. Every footprint fold uses this, so a boundary trade lands on
54
+ * the same row in the fetch rebucket, the RTH fold and the live lane.
55
+ */
56
+ export function floorFootprintGridIndex(price, step) {
57
+ const quotient = price / step;
58
+ return Math.floor(quotient + GRID_FLOOR_DUST * Math.max(1, Math.abs(quotient)));
59
+ }
60
+ /** Row index of a bottom-anchored grid level (a live delta's gridLow, k * step). */
61
+ export function footprintGridIndex(gridLow, step) {
62
+ return Math.round(gridLow / step);
63
+ }
64
+ /** Row index of a centered footprint cell [low, high): its midpoint sits in [k, k + 0.5) rows. */
65
+ export function footprintCellIndex(cell, step) {
66
+ return Math.floor((Number(cell[0]) + Number(cell[1])) / 2 / step + 0.25);
67
+ }
68
+ /** Significant digits a cell bound keeps before its decimals are counted (float noise sits past the 15th). */
69
+ const BOUND_SIGNIFICANT_DIGITS = 12;
70
+ /**
71
+ * A cell's grid height as the decimal its bounds carry: the difference of the
72
+ * bounds read at 12 significant digits, rounded to their decimal places. The
73
+ * raw subtraction carries the bounds' float dust, and an index is the price
74
+ * over the height, so the dust grows with the price: at 600,000 a 0.01 cell
75
+ * subtracts to 0.0099999998929 (still 0.00999999989 at 9 significant digits),
76
+ * which moves the index by more than a row.
77
+ */
78
+ function cellStep(low, high) {
79
+ const lo = Number(low.toPrecision(BOUND_SIGNIFICANT_DIGITS));
80
+ const hi = Number(high.toPrecision(BOUND_SIGNIFICANT_DIGITS));
81
+ const decimals = Math.min(15, Math.max(decimalPlaces(lo), decimalPlaces(hi)));
82
+ const step = Number((hi - lo).toFixed(decimals));
83
+ return step > 0 ? step : high - low;
84
+ }
85
+ /** A row's grid height: its first cell's decimal height (`cellStep`), or null without a cell. */
86
+ export function footprintRowStep(row) {
87
+ if (!row)
88
+ return null;
89
+ for (let i = 1; i < row.length; i++) {
90
+ const cell = row[i];
91
+ if (isCell(cell))
92
+ return cellStep(Number(cell[0]), Number(cell[1]));
93
+ }
94
+ return null;
95
+ }
96
+ export function sameFootprintStep(a, b) {
97
+ return Math.abs(a - b) <= Math.max(Math.abs(a), Math.abs(b)) * STEP_TOLERANCE;
98
+ }
99
+ /** A delta grid `h` fits a row of height `step` when it is the same grid or a finer one that divides it. */
100
+ function deltaFitsRow(h, step) {
101
+ if (sameFootprintStep(h, step))
102
+ return true;
103
+ if (!(h < step))
104
+ return false;
105
+ const ratio = step / h;
106
+ return Math.abs(ratio - Math.round(ratio)) <= ratio * STEP_TOLERANCE;
107
+ }
108
+ function rowIndices(row, step) {
109
+ const indices = new Set();
110
+ for (let i = 1; i < row.length; i++) {
111
+ const cell = row[i];
112
+ if (isCell(cell))
113
+ indices.add(footprintCellIndex(cell, step));
114
+ }
115
+ return indices;
116
+ }
117
+ /**
118
+ * Whether two rows of one bar sit on one lattice: the same grid height and,
119
+ * when both carry at least two cells, at least one shared row index. Two
120
+ * snapshots of one bar always share the rows they both saw trade; rows with
121
+ * the same height but no common row are shifted copies (the 2026-09-14
122
+ * PUMPUSDT rows one block apart, each totaling 3,718,492, would union to
123
+ * twice that). Anchors and float dust never change an index, so rows
124
+ * centered on 0.01 and on 0.00999999999, or on the tick and on the block,
125
+ * share their rows here. Rows with fewer than two cells give too little
126
+ * evidence and stay mergeable.
127
+ */
128
+ export function footprintRowsShareLattice(a, b) {
129
+ const stepA = footprintRowStep(a);
130
+ const stepB = footprintRowStep(b);
131
+ if (stepA === null || stepB === null)
132
+ return true;
133
+ if (!sameFootprintStep(stepA, stepB))
134
+ return false;
135
+ const indicesA = rowIndices(a, stepB);
136
+ const indicesB = rowIndices(b, stepB);
137
+ if (indicesA.size < 2 || indicesB.size < 2)
138
+ return true;
139
+ for (const index of indicesA)
140
+ if (indicesB.has(index))
141
+ return true;
142
+ return false;
143
+ }
144
+ /**
145
+ * Geometry for row `index` on the template cell's lattice: shifted by whole
146
+ * rows and rounded to the template's own decimals, so a new cell is
147
+ * bit-identical to what the producer of the template would have keyed there.
148
+ */
149
+ function translateCell(template, templateIndex, index, step) {
150
+ const low = Number(template[0]);
151
+ const high = Number(template[1]);
152
+ const shift = (index - templateIndex) * step;
153
+ const decimals = Math.min(15, Math.max(decimalPlaces(low), decimalPlaces(high)));
154
+ return [Number((low + shift).toFixed(decimals)), Number((high + shift).toFixed(decimals))];
155
+ }
156
+ function addVolumes(target, source) {
157
+ target[2] = Math.max(0, (Number(target[2]) || 0) + (Number(source[2]) || 0));
158
+ target[3] = Math.max(0, (Number(target[3]) || 0) + (Number(source[3]) || 0));
159
+ if (source.length > 4 || target.length > 4) {
160
+ target[4] = Math.max(0, (Number(target[4]) || 0) + (Number(source[4]) || 0));
161
+ target[5] = Math.max(0, (Number(target[5]) || 0) + (Number(source[5]) || 0));
162
+ }
163
+ }
164
+ /** Cells by index; cells of one row that share an index collapse by sum. */
165
+ function indexCells(row, step) {
166
+ const cells = new Map();
167
+ let collapsed = 0;
168
+ for (let i = 1; i < row.length; i++) {
169
+ const cell = row[i];
170
+ if (!isCell(cell))
171
+ continue;
172
+ const index = footprintCellIndex(cell, step);
173
+ const existing = cells.get(index);
174
+ if (existing) {
175
+ addVolumes(existing, cell);
176
+ collapsed++;
177
+ }
178
+ else {
179
+ cells.set(index, cell.slice());
180
+ }
181
+ }
182
+ return { cells, collapsed };
183
+ }
184
+ function sortedByIndex(cells) {
185
+ return Array.from(cells.entries())
186
+ .sort((a, b) => a[0] - b[0])
187
+ .map(([, cell]) => cell);
188
+ }
189
+ /**
190
+ * The add door: fold live deltas (bottom-anchored grid cells
191
+ * [gridLow, gridHigh, buy, sell, (buyCount, sellCount)]) into a bar.
192
+ *
193
+ * The bar keeps ONE grid. When the deltas accumulate into this bar's held
194
+ * row, that row's grid decides: a delta on a finer grid that divides it folds
195
+ * up and any other grid is rejected, so a row can never hold cells of two
196
+ * heights. A new bar or an absolute row (nothing held to accumulate into)
197
+ * takes the deltas' own grid, as before. New cells copy the phase of a
198
+ * template cell on the same grid (this bar's, else the previous bar's), and
199
+ * only a row with no such template falls back to `seedBand`.
200
+ */
201
+ export function mergeFootprintLiveDeltas(baseRow, deltas, options) {
202
+ const baseStep = footprintRowStep(baseRow);
203
+ let deltaStep = null;
204
+ for (const delta of deltas) {
205
+ if (isCell(delta)) {
206
+ deltaStep = cellStep(Number(delta[0]), Number(delta[1]));
207
+ break;
208
+ }
209
+ }
210
+ // Folding onto another grid is only for accumulating into this bar's held
211
+ // row: a new or absolute row is replaced by the deltas on their own grid
212
+ // (a previous or cached row on a coarser grid must not coarsen it).
213
+ const step = options.seedVolumes && baseStep !== null ? baseStep : deltaStep;
214
+ let byIndex = new Map();
215
+ let collapsed = 0;
216
+ let template = null;
217
+ let templateIndex = 0;
218
+ if (baseRow && step !== null && baseStep !== null && sameFootprintStep(baseStep, step)) {
219
+ for (let i = 1; i < baseRow.length; i++) {
220
+ const cell = baseRow[i];
221
+ if (isCell(cell)) {
222
+ template = cell;
223
+ templateIndex = footprintCellIndex(cell, step);
224
+ break;
225
+ }
226
+ }
227
+ if (options.seedVolumes) {
228
+ const indexed = indexCells(baseRow, step);
229
+ byIndex = indexed.cells;
230
+ collapsed = indexed.collapsed;
231
+ }
232
+ }
233
+ let applied = 0;
234
+ let folded = 0;
235
+ let rejected = 0;
236
+ for (const delta of deltas) {
237
+ if (!isCell(delta) || step === null) {
238
+ rejected++;
239
+ continue;
240
+ }
241
+ const gridLow = Number(delta[0]);
242
+ const height = cellStep(gridLow, Number(delta[1]));
243
+ let index;
244
+ if (sameFootprintStep(height, step)) {
245
+ index = footprintGridIndex(gridLow, step);
246
+ applied++;
247
+ }
248
+ else if (deltaFitsRow(height, step)) {
249
+ index = floorFootprintGridIndex(gridLow, step);
250
+ folded++;
251
+ }
252
+ else {
253
+ rejected++;
254
+ continue;
255
+ }
256
+ const existing = byIndex.get(index);
257
+ if (existing) {
258
+ addVolumes(existing, delta);
259
+ continue;
260
+ }
261
+ const [low, high] = template
262
+ ? translateCell(template, templateIndex, index, step)
263
+ : sameFootprintStep(height, step)
264
+ ? options.seedBand(gridLow, height)
265
+ : options.seedBand(index * step, step);
266
+ const cell = [low, high, Math.max(0, Number(delta[2]) || 0), Math.max(0, Number(delta[3]) || 0)];
267
+ if (delta.length > 4)
268
+ cell.push(Math.max(0, Number(delta[4]) || 0), Math.max(0, Number(delta[5]) || 0));
269
+ byIndex.set(index, cell);
270
+ if (!template) {
271
+ template = cell;
272
+ templateIndex = index;
273
+ }
274
+ }
275
+ return { cells: sortedByIndex(byIndex), applied, folded, rejected, collapsed };
276
+ }
277
+ function cellVolume(cell) {
278
+ if (!cell)
279
+ return 0;
280
+ return (Number(cell[2]) || 0) + (Number(cell[3]) || 0);
281
+ }
282
+ function maxCell(held, fetched, geometry) {
283
+ const buy = Math.max(Number(held?.[2]) || 0, Number(fetched[2]) || 0);
284
+ const sell = Math.max(Number(held?.[3]) || 0, Number(fetched[3]) || 0);
285
+ const carriesCounts = (held?.length ?? 0) > 4 || fetched.length > 4;
286
+ if (!carriesCounts)
287
+ return [geometry[0], geometry[1], buy, sell];
288
+ return [
289
+ geometry[0],
290
+ geometry[1],
291
+ buy,
292
+ sell,
293
+ Math.max(Number(held?.[4]) || 0, Number(fetched[4]) || 0),
294
+ Math.max(Number(held?.[5]) || 0, Number(fetched[5]) || 0),
295
+ ];
296
+ }
297
+ /**
298
+ * The max door: a fetched snapshot over a held row of the same bar. Per-index
299
+ * max, in the FETCHED row's geometry (held-only cells translated onto it), so
300
+ * the merged row has one phase whatever anchors the two sides were centered
301
+ * on. Rows on different grids cannot share a per-index max: the snapshot is
302
+ * taken wholesale (`sharedGrid: false`), the same rule the callers' lattice
303
+ * gate applies.
304
+ */
305
+ export function mergeFootprintSnapshotCells(heldRow, fetchedRow) {
306
+ const fetchedStep = footprintRowStep(fetchedRow);
307
+ const heldStep = footprintRowStep(heldRow);
308
+ const step = fetchedStep ?? heldStep;
309
+ if (step === null)
310
+ return { cells: [], raisedCells: 0, keptCells: 0, sharedGrid: true };
311
+ const sharedGrid = fetchedStep === null || heldStep === null || sameFootprintStep(fetchedStep, heldStep);
312
+ const fetched = fetchedStep === null ? new Map() : indexCells(fetchedRow, step).cells;
313
+ const held = !sharedGrid || heldStep === null ? new Map() : indexCells(heldRow, step).cells;
314
+ let template = null;
315
+ let templateIndex = 0;
316
+ for (const [index, cell] of fetched) {
317
+ if (template === null || index < templateIndex) {
318
+ template = cell;
319
+ templateIndex = index;
320
+ }
321
+ }
322
+ const merged = new Map();
323
+ let raisedCells = 0;
324
+ let keptCells = 0;
325
+ const indices = new Set([...fetched.keys(), ...held.keys()]);
326
+ for (const index of indices) {
327
+ const fetchedCell = fetched.get(index);
328
+ const heldCell = held.get(index);
329
+ const fetchedVolume = cellVolume(fetchedCell);
330
+ const heldVolume = cellVolume(heldCell);
331
+ if (fetchedVolume > heldVolume)
332
+ raisedCells++;
333
+ else if (heldVolume > fetchedVolume)
334
+ keptCells++;
335
+ if (fetchedCell) {
336
+ merged.set(index, maxCell(heldCell, fetchedCell, [Number(fetchedCell[0]), Number(fetchedCell[1])]));
337
+ }
338
+ else if (heldCell) {
339
+ const geometry = template
340
+ ? translateCell(template, templateIndex, index, step)
341
+ : [Number(heldCell[0]), Number(heldCell[1])];
342
+ merged.set(index, maxCell(undefined, heldCell, geometry));
343
+ }
344
+ }
345
+ return { cells: sortedByIndex(merged), raisedCells, keptCells, sharedGrid };
346
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Which legs of a formula share a calendar, for the symbol guard and for the history worker (so this module stays
3
+ * worker-safe: legacy listing venues are healed by the guard on top, never here).
4
+ */
5
+ /** Wire identity of one leg: display suffixes and spaced display names canonicalized. */
6
+ export declare function formulaLegExchange(exchange?: string, symbol?: string): string;
7
+ /** Each leg's wire venue on a formula (more than one part); empty for a plain symbol. */
8
+ export declare function formulaLegExchanges(transformations?: string): string[];
9
+ /**
10
+ * The calendar a leg trades on, or null for legs every formula already combines (crypto, HIP-3, CME futures,
11
+ * prediction markets, economic series). The null class is a compatibility class, not one calendar: CME closes on
12
+ * weekends while crypto does not, and those legs still join on exact stamps. A group also pins the fetch mode, so an
13
+ * index-mode leg never pairs with a timestamp-mode twin of the same kind.
14
+ */
15
+ export declare function formulaLegGroup(exchange: string): string | null;
16
+ export interface FormulaCalendarPlan {
17
+ /** The token whose bars are the timeline: the first leg that is not an economic series. */
18
+ anchor: string;
19
+ /** Market legs on another calendar than the anchor, read at their last close as of each anchor bar. */
20
+ carried: ReadonlySet<string>;
21
+ }
22
+ /**
23
+ * How a formula whose legs trade on different calendars lines up, or null when every leg shares one (BTC / ETH,
24
+ * SPY / GLD, BTC / M2): those join on exact stamps, as they always have. Economic series never set the timeline
25
+ * (`carryEconomicSeries` reads them as of the market legs' bars), so the anchor is the first market leg.
26
+ */
27
+ export declare function formulaCalendarPlan(transformations?: string): FormulaCalendarPlan | null;