@orangecharts/wrun-chart-host 0.2.0 → 0.4.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 (342) hide show
  1. package/README.md +22 -8
  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/scriptEditor/builtin-script-snippets.d.ts +133 -0
  23. package/dist/constants/scriptEditor/builtin-script-snippets.js +451 -0
  24. package/dist/constants/venue-presets.constants.d.ts +10 -0
  25. package/dist/constants/venue-presets.constants.js +22 -0
  26. package/dist/enums/chart.enum.d.ts +68 -0
  27. package/dist/enums/chart.enum.js +70 -0
  28. package/dist/helpers/data.helpers.d.ts +2 -0
  29. package/dist/helpers/data.helpers.js +14 -0
  30. package/dist/host-env.d.ts +163 -5
  31. package/dist/host-ports.types.d.ts +431 -0
  32. package/dist/host-ports.types.js +1 -0
  33. package/dist/index.d.ts +138 -0
  34. package/dist/index.js +138 -0
  35. package/dist/indicators/controls/technical-script/technical-script-input-rendering.d.ts +86 -0
  36. package/dist/indicators/controls/technical-script/technical-script-input-rendering.js +179 -0
  37. package/dist/interfaces/asset-venue.interface.d.ts +91 -0
  38. package/dist/interfaces/asset-venue.interface.js +1 -0
  39. package/dist/interfaces/cancel-reason.interface.d.ts +24 -0
  40. package/dist/interfaces/cancel-reason.interface.js +2 -0
  41. package/dist/interfaces/catalog-display.interface.d.ts +3 -0
  42. package/dist/interfaces/catalog-display.interface.js +1 -0
  43. package/dist/interfaces/cme-realtime.interface.d.ts +251 -0
  44. package/dist/interfaces/cme-realtime.interface.js +46 -0
  45. package/dist/interfaces/feed.interface.d.ts +80 -0
  46. package/dist/interfaces/feed.interface.js +7 -0
  47. package/dist/interfaces/market-kind.interface.d.ts +8 -0
  48. package/dist/interfaces/market-kind.interface.js +1 -0
  49. package/dist/interfaces/opra-realtime.interface.d.ts +224 -0
  50. package/dist/interfaces/opra-realtime.interface.js +105 -0
  51. package/dist/interfaces/option-instrument.interface.d.ts +32 -0
  52. package/dist/interfaces/option-instrument.interface.js +1 -0
  53. package/dist/interfaces/options-chain-scope.interface.d.ts +29 -0
  54. package/dist/interfaces/options-chain-scope.interface.js +7 -0
  55. package/dist/interfaces/prediction-market.interface.d.ts +88 -0
  56. package/dist/interfaces/prediction-market.interface.js +8 -0
  57. package/dist/interfaces/wrun-runtime.interface.d.ts +5 -0
  58. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +185 -0
  59. package/dist/kscript-data/controls/live-trades-merge.util.js +357 -0
  60. package/dist/settings-templates/frvp-fields.d.ts +27 -0
  61. package/dist/settings-templates/frvp-fields.js +108 -0
  62. package/dist/settings-templates/index.d.ts +119 -0
  63. package/dist/settings-templates/index.js +442 -0
  64. package/dist/settings-templates/indicator-fields.d.ts +56 -0
  65. package/dist/settings-templates/indicator-fields.js +793 -0
  66. package/dist/settings-templates/tool-rules.d.ts +59 -0
  67. package/dist/settings-templates/tool-rules.js +49 -0
  68. package/dist/settings-templates/tool-tables.generated.d.ts +2 -0
  69. package/dist/settings-templates/tool-tables.generated.js +1668 -0
  70. package/dist/utility/blk-market.util.d.ts +5 -0
  71. package/dist/utility/blk-market.util.js +12 -0
  72. package/dist/utility/chart/chart-load-phase.util.d.ts +32 -0
  73. package/dist/utility/chart/chart-load-phase.util.js +78 -0
  74. package/dist/utility/chart/cme-cache-context.util.d.ts +108 -0
  75. package/dist/utility/chart/cme-cache-context.util.js +166 -0
  76. package/dist/utility/chart/cme-session-bucket.util.d.ts +82 -0
  77. package/dist/utility/chart/cme-session-bucket.util.js +343 -0
  78. package/dist/utility/chart/cme-trade-calendar.util.d.ts +26 -0
  79. package/dist/utility/chart/cme-trade-calendar.util.js +147 -0
  80. package/dist/utility/chart/continuous-contracts.util.d.ts +138 -0
  81. package/dist/utility/chart/continuous-contracts.util.js +374 -0
  82. package/dist/utility/chart/date-labelled-interval.leaf.d.ts +15 -0
  83. package/dist/utility/chart/date-labelled-interval.leaf.js +19 -0
  84. package/dist/utility/chart/feed-interval.util.d.ts +119 -0
  85. package/dist/utility/chart/feed-interval.util.js +321 -0
  86. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +110 -0
  87. package/dist/utility/chart/fetch-dedupe-policy.util.js +407 -0
  88. package/dist/utility/chart/footprint-band.util.d.ts +76 -0
  89. package/dist/utility/chart/footprint-band.util.js +205 -0
  90. package/dist/utility/chart/footprint-cell-identity.util.d.ts +82 -0
  91. package/dist/utility/chart/footprint-cell-identity.util.js +346 -0
  92. package/dist/utility/chart/formula-calendar.util.d.ts +27 -0
  93. package/dist/utility/chart/formula-calendar.util.js +59 -0
  94. package/dist/utility/chart/history-wall.util.d.ts +67 -0
  95. package/dist/utility/chart/history-wall.util.js +87 -0
  96. package/dist/utility/chart/index-mode.util.d.ts +66 -0
  97. package/dist/utility/chart/index-mode.util.js +360 -0
  98. package/dist/utility/chart/indicator-coverage-planner.util.d.ts +217 -0
  99. package/dist/utility/chart/indicator-coverage-planner.util.js +443 -0
  100. package/dist/utility/chart/indicator-coverage-state.util.d.ts +33 -0
  101. package/dist/utility/chart/indicator-coverage-state.util.js +110 -0
  102. package/dist/utility/chart/indicator-gap-detector.util.d.ts +127 -0
  103. package/dist/utility/chart/indicator-gap-detector.util.js +260 -0
  104. package/dist/utility/chart/indicator-gap-repair.util.d.ts +88 -0
  105. package/dist/utility/chart/indicator-gap-repair.util.js +177 -0
  106. package/dist/utility/chart/indicator-inflight-registry.util.d.ts +26 -0
  107. package/dist/utility/chart/indicator-inflight-registry.util.js +254 -0
  108. package/dist/utility/chart/indicator-run-interval.util.d.ts +130 -0
  109. package/dist/utility/chart/indicator-run-interval.util.js +268 -0
  110. package/dist/utility/chart/interval-registry.util.d.ts +23 -0
  111. package/dist/utility/chart/interval-registry.util.js +83 -0
  112. package/dist/utility/chart/kscript-main-grid-stages.util.d.ts +21 -0
  113. package/dist/utility/chart/kscript-main-grid-stages.util.js +332 -0
  114. package/dist/utility/chart/legacy-exchange.leaf.d.ts +11 -0
  115. package/dist/utility/chart/legacy-exchange.leaf.js +43 -0
  116. package/dist/utility/chart/live-bucket.util.d.ts +66 -0
  117. package/dist/utility/chart/live-bucket.util.js +165 -0
  118. package/dist/utility/chart/market-session-schedule.util.d.ts +91 -0
  119. package/dist/utility/chart/market-session-schedule.util.js +337 -0
  120. package/dist/utility/chart/marketKind.util.d.ts +181 -0
  121. package/dist/utility/chart/marketKind.util.js +371 -0
  122. package/dist/utility/chart/opra-read-access.leaf.d.ts +26 -0
  123. package/dist/utility/chart/opra-read-access.leaf.js +25 -0
  124. package/dist/utility/chart/prediction-identity.util.d.ts +159 -0
  125. package/dist/utility/chart/prediction-identity.util.js +236 -0
  126. package/dist/utility/chart/rth-session.util.d.ts +352 -0
  127. package/dist/utility/chart/rth-session.util.js +926 -0
  128. package/dist/utility/chart/titan-constants.pin.d.ts +43 -0
  129. package/dist/utility/chart/titan-constants.pin.js +50 -0
  130. package/dist/utility/chart/us-equities-session.util.d.ts +127 -0
  131. package/dist/utility/chart/us-equities-session.util.js +251 -0
  132. package/dist/utility/chart/window-geometry.leaf.d.ts +119 -0
  133. package/dist/utility/chart/window-geometry.leaf.js +391 -0
  134. package/dist/utility/chart/window-owner.leaf.d.ts +19 -0
  135. package/dist/utility/chart/window-owner.leaf.js +24 -0
  136. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +100 -0
  137. package/dist/utility/chart/wrun-bar-session-facts.util.js +354 -0
  138. package/dist/utility/chart/wrun-wire-ref.util.d.ts +23 -0
  139. package/dist/utility/chart/wrun-wire-ref.util.js +16 -0
  140. package/dist/utility/common/safe-math-eval.d.ts +18 -0
  141. package/dist/utility/common/safe-math-eval.js +160 -0
  142. package/dist/utility/common/time.util.d.ts +134 -0
  143. package/dist/utility/common/time.util.js +428 -0
  144. package/dist/utility/common/transformations.util.d.ts +126 -0
  145. package/dist/utility/common/transformations.util.js +711 -0
  146. package/dist/utility/common/visible-timeout.util.d.ts +17 -0
  147. package/dist/utility/common/visible-timeout.util.js +75 -0
  148. package/dist/utility/exchange-normalization.util.d.ts +8 -0
  149. package/dist/utility/exchange-normalization.util.js +32 -0
  150. package/dist/utility/html-escape.leaf.d.ts +11 -0
  151. package/dist/utility/html-escape.leaf.js +20 -0
  152. package/dist/utility/intl-locale.util.d.ts +2 -0
  153. package/dist/utility/intl-locale.util.js +28 -0
  154. package/dist/utility/number-format.util.d.ts +14 -1
  155. package/dist/utility/number-format.util.js +50 -19
  156. package/dist/utility/options/option-symbol.util.d.ts +28 -0
  157. package/dist/utility/options/option-symbol.util.js +176 -0
  158. package/dist/utility/options/option-trade-units.util.d.ts +190 -0
  159. package/dist/utility/options/option-trade-units.util.js +283 -0
  160. package/dist/utility/options/option-venue.util.d.ts +75 -0
  161. package/dist/utility/options/option-venue.util.js +85 -0
  162. package/dist/utility/pool-symbol.leaf.d.ts +34 -0
  163. package/dist/utility/pool-symbol.leaf.js +95 -0
  164. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +109 -0
  165. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +302 -0
  166. package/dist/utility/symbol-selection/contract-expiry.util.d.ts +39 -0
  167. package/dist/utility/symbol-selection/contract-expiry.util.js +111 -0
  168. package/dist/utility/v2/gate-plane.util.d.ts +58 -0
  169. package/dist/utility/v2/gate-plane.util.js +99 -0
  170. package/dist/utility/v2/gate-session-latch.util.d.ts +22 -0
  171. package/dist/utility/v2/gate-session-latch.util.js +34 -0
  172. package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +76 -0
  173. package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +221 -0
  174. package/dist/utility/wrun/sources/host-grid-landing.d.ts +15 -0
  175. package/dist/utility/wrun/sources/host-grid-landing.js +26 -0
  176. package/dist/utility/wrun/sources/lanes/bitfinex_funding.d.ts +27 -0
  177. package/dist/utility/wrun/sources/lanes/bitfinex_funding.js +85 -0
  178. package/dist/utility/wrun/sources/lanes/economic.d.ts +27 -0
  179. package/dist/utility/wrun/sources/lanes/economic.js +79 -0
  180. package/dist/utility/wrun/sources/lanes/etf_holdings.d.ts +35 -0
  181. package/dist/utility/wrun/sources/lanes/etf_holdings.js +165 -0
  182. package/dist/utility/wrun/sources/lanes/etf_premium.d.ts +19 -0
  183. package/dist/utility/wrun/sources/lanes/etf_premium.js +114 -0
  184. package/dist/utility/wrun/sources/lanes/ethena_positions.d.ts +30 -0
  185. package/dist/utility/wrun/sources/lanes/ethena_positions.js +51 -0
  186. package/dist/utility/wrun/sources/lanes/index.d.ts +2 -0
  187. package/dist/utility/wrun/sources/lanes/index.js +32 -0
  188. package/dist/utility/wrun/sources/lanes/long_short_ratio.d.ts +17 -0
  189. package/dist/utility/wrun/sources/lanes/long_short_ratio.js +47 -0
  190. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +58 -0
  191. package/dist/utility/wrun/sources/lanes/option_daily.js +111 -0
  192. package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +27 -0
  193. package/dist/utility/wrun/sources/lanes/option_stats_10m.js +21 -0
  194. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +50 -0
  195. package/dist/utility/wrun/sources/lanes/options_flow.js +155 -0
  196. package/dist/utility/wrun/sources/lanes/options_oi.d.ts +29 -0
  197. package/dist/utility/wrun/sources/lanes/options_oi.js +59 -0
  198. package/dist/utility/wrun/sources/lanes/options_volume.d.ts +38 -0
  199. package/dist/utility/wrun/sources/lanes/options_volume.js +63 -0
  200. package/dist/utility/wrun/sources/lanes/series.d.ts +67 -0
  201. package/dist/utility/wrun/sources/lanes/series.js +321 -0
  202. package/dist/utility/wrun/sources/lanes/token_supply.d.ts +30 -0
  203. package/dist/utility/wrun/sources/lanes/token_supply.js +145 -0
  204. package/dist/utility/wrun/sources/lanes/treasury_balance.d.ts +25 -0
  205. package/dist/utility/wrun/sources/lanes/treasury_balance.js +47 -0
  206. package/dist/utility/wrun/sources/lanes/volatility_index.d.ts +21 -0
  207. package/dist/utility/wrun/sources/lanes/volatility_index.js +11 -0
  208. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +215 -0
  209. package/dist/utility/wrun/sources/opra-option-lanes.util.js +477 -0
  210. package/dist/utility/wrun/sources/registry.d.ts +21 -0
  211. package/dist/utility/wrun/sources/registry.js +237 -0
  212. package/dist/utility/wrun/sources/row-lane-registry.d.ts +28 -0
  213. package/dist/utility/wrun/sources/row-lane-registry.js +230 -0
  214. package/dist/utility/wrun/sources/row-lanes/index.d.ts +2 -0
  215. package/dist/utility/wrun/sources/row-lanes/index.js +12 -0
  216. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +2 -0
  217. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +38 -0
  218. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +55 -0
  219. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +126 -0
  220. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +4 -0
  221. package/dist/utility/wrun/sources/row-lanes/option_prints.js +191 -0
  222. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +62 -0
  223. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +147 -0
  224. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +70 -0
  225. package/dist/utility/wrun/sources/row-lanes/option_surface.js +144 -0
  226. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +309 -0
  227. package/dist/utility/wrun/sources/wrun-poll-lane.types.js +26 -0
  228. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +350 -0
  229. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +576 -0
  230. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +275 -0
  231. package/dist/utility/wrun/sources/wrun-row-lane.types.js +16 -0
  232. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +207 -0
  233. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +450 -0
  234. package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +28 -0
  235. package/dist/utility/wrun/wrun-browser-sources.leaf.js +66 -0
  236. package/dist/utility/wrun/wrun-cloud-record.util.d.ts +65 -0
  237. package/dist/utility/wrun/wrun-cloud-record.util.js +121 -0
  238. package/dist/utility/wrun/wrun-daily-lane.util.d.ts +95 -0
  239. package/dist/utility/wrun/wrun-daily-lane.util.js +297 -0
  240. package/dist/utility/wrun/wrun-deadline.util.d.ts +52 -0
  241. package/dist/utility/wrun/wrun-deadline.util.js +82 -0
  242. package/dist/utility/wrun/wrun-etf-flow-lane.util.d.ts +94 -0
  243. package/dist/utility/wrun/wrun-etf-flow-lane.util.js +224 -0
  244. package/dist/utility/wrun/wrun-etf-funds.util.d.ts +82 -0
  245. package/dist/utility/wrun/wrun-etf-funds.util.js +242 -0
  246. package/dist/utility/wrun/wrun-frames.d.ts +20 -1
  247. package/dist/utility/wrun/wrun-frames.js +103 -49
  248. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
  249. package/dist/utility/wrun/wrun-hosted-wire-caps.js +27 -0
  250. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +22 -0
  251. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +32 -0
  252. package/dist/utility/wrun/wrun-lane-warmup.util.d.ts +18 -0
  253. package/dist/utility/wrun/wrun-lane-warmup.util.js +112 -0
  254. package/dist/utility/wrun/wrun-leg-close.util.d.ts +57 -0
  255. package/dist/utility/wrun/wrun-leg-close.util.js +187 -0
  256. package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +144 -0
  257. package/dist/utility/wrun/wrun-leg-fetch.util.js +212 -0
  258. package/dist/utility/wrun/wrun-leg-stream-classes.d.ts +73 -0
  259. package/dist/utility/wrun/wrun-leg-stream-classes.js +86 -0
  260. package/dist/utility/wrun/wrun-levels-child.util.d.ts +101 -6
  261. package/dist/utility/wrun/wrun-levels-child.util.js +335 -157
  262. package/dist/utility/wrun/wrun-memory-clamp.util.d.ts +33 -0
  263. package/dist/utility/wrun/wrun-memory-clamp.util.js +146 -0
  264. package/dist/utility/wrun/wrun-odds-template-market.util.d.ts +51 -0
  265. package/dist/utility/wrun/wrun-odds-template-market.util.js +251 -0
  266. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +65 -0
  267. package/dist/utility/wrun/wrun-opra-flow.leaf.js +94 -0
  268. package/dist/utility/wrun/wrun-opra-lane.util.d.ts +47 -0
  269. package/dist/utility/wrun/wrun-opra-lane.util.js +58 -0
  270. package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +49 -0
  271. package/dist/utility/wrun/wrun-opra-stats.leaf.js +115 -0
  272. package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +12 -0
  273. package/dist/utility/wrun/wrun-opra-underlying.util.js +1 -0
  274. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +142 -0
  275. package/dist/utility/wrun/wrun-option-contract-flow.util.js +451 -0
  276. package/dist/utility/wrun/wrun-option-knobs.util.d.ts +43 -0
  277. package/dist/utility/wrun/wrun-option-knobs.util.js +81 -0
  278. package/dist/utility/wrun/wrun-option-prints.util.d.ts +144 -0
  279. package/dist/utility/wrun/wrun-option-prints.util.js +356 -0
  280. package/dist/utility/wrun/wrun-option-summary-lane.util.d.ts +102 -0
  281. package/dist/utility/wrun/wrun-option-summary-lane.util.js +143 -0
  282. package/dist/utility/wrun/wrun-options-chain.util.d.ts +308 -0
  283. package/dist/utility/wrun/wrun-options-chain.util.js +502 -0
  284. package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +9 -4
  285. package/dist/utility/wrun/wrun-overlay-identity.util.js +16 -6
  286. package/dist/utility/wrun/wrun-panel-mount.lazy.d.ts +10 -0
  287. package/dist/utility/wrun/wrun-panel-mount.lazy.js +68 -0
  288. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +377 -0
  289. package/dist/utility/wrun/wrun-panel-mount.util.js +2251 -0
  290. package/dist/utility/wrun/wrun-param-map.util.d.ts +298 -0
  291. package/dist/utility/wrun/wrun-param-map.util.js +581 -0
  292. package/dist/utility/wrun/wrun-pause-dim.util.d.ts +52 -0
  293. package/dist/utility/wrun/wrun-pause-dim.util.js +153 -0
  294. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +149 -0
  295. package/dist/utility/wrun/wrun-pin-spelling.util.js +523 -0
  296. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +116 -0
  297. package/dist/utility/wrun/wrun-pin-venues.util.js +320 -0
  298. package/dist/utility/wrun/wrun-pinned-interval.util.d.ts +20 -0
  299. package/dist/utility/wrun/wrun-pinned-interval.util.js +47 -0
  300. package/dist/utility/wrun/wrun-plot-gate.types.d.ts +23 -0
  301. package/dist/utility/wrun/wrun-plot-gate.types.js +7 -0
  302. package/dist/utility/wrun/wrun-present-bits.util.d.ts +37 -0
  303. package/dist/utility/wrun/wrun-present-bits.util.js +73 -0
  304. package/dist/utility/wrun/wrun-protocol-pending.util.d.ts +33 -0
  305. package/dist/utility/wrun/wrun-protocol-pending.util.js +57 -0
  306. package/dist/utility/wrun/wrun-refusal.util.d.ts +41 -1
  307. package/dist/utility/wrun/wrun-refusal.util.js +69 -2
  308. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +1 -14
  309. package/dist/utility/wrun/wrun-registry-errors.util.js +0 -16
  310. package/dist/utility/wrun/wrun-row-source.d.ts +158 -0
  311. package/dist/utility/wrun/wrun-row-source.js +75 -0
  312. package/dist/utility/wrun/wrun-run-health.util.d.ts +155 -0
  313. package/dist/utility/wrun/wrun-run-health.util.js +273 -0
  314. package/dist/utility/wrun/wrun-run-interval-projection.types.d.ts +14 -0
  315. package/dist/utility/wrun/wrun-run-interval-projection.types.js +1 -0
  316. package/dist/utility/wrun/wrun-socket-row-source.d.ts +439 -0
  317. package/dist/utility/wrun/wrun-socket-row-source.js +1689 -0
  318. package/dist/utility/wrun/wrun-socket-session-losses.util.d.ts +18 -0
  319. package/dist/utility/wrun/wrun-socket-session-losses.util.js +25 -0
  320. package/dist/utility/wrun/wrun-source-rows.util.d.ts +911 -0
  321. package/dist/utility/wrun/wrun-source-rows.util.js +2597 -0
  322. package/dist/utility/wrun/wrun-tape-source.util.d.ts +82 -0
  323. package/dist/utility/wrun/wrun-tape-source.util.js +151 -0
  324. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +137 -0
  325. package/dist/utility/wrun/wrun-tier-grid.util.js +279 -0
  326. package/dist/utility/wrun/wrun-trades-lane.util.d.ts +52 -0
  327. package/dist/utility/wrun/wrun-trades-lane.util.js +58 -0
  328. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +41 -0
  329. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +66 -0
  330. package/dist/utility/wrun-display-name.util.d.ts +33 -0
  331. package/dist/utility/wrun-display-name.util.js +64 -0
  332. package/dist/workers/constants/kscript-transport-codes.d.ts +15 -0
  333. package/dist/workers/constants/kscript-transport-codes.js +15 -0
  334. package/dist/workers/constants/socket-slots.d.ts +574 -0
  335. package/dist/workers/constants/socket-slots.js +539 -0
  336. package/dist/workers/utils/number.worker.util.d.ts +5 -0
  337. package/dist/workers/utils/number.worker.util.js +10 -0
  338. package/dist/workers/utils/time.worker.util.d.ts +12 -0
  339. package/dist/workers/utils/time.worker.util.js +24 -0
  340. package/dist/workers/utils/volume-profile.worker.util.d.ts +200 -0
  341. package/dist/workers/utils/volume-profile.worker.util.js +631 -0
  342. package/package.json +10 -4
@@ -0,0 +1,187 @@
1
+ /**
2
+ * When a pinned leg's candle closes on the chart, when it starts trading, and where the chart's own
3
+ * rows run. The rule is the shared host's session calendar (`@orangecharts/indicator-kit/host`,
4
+ * session-calendar.ts, om #1907): the browser's own rule moved into the package (Amendment 11,
5
+ * browser wins), so it lives once and both chart hosts run it. The row builder takes its answers
6
+ * for a whole plan (`wrunSessionClock`, through `WrunChartSourceRows.session`); this module hands
7
+ * the same rule leg by leg to the browser paths that read a leg outside the aligner: the run pass's
8
+ * closed-candle cut and intrabar head, the live tick's cuts, revision checks, wake and coverage.
9
+ * Each wrapper composes the package's exports and holds no calendar of its own:
10
+ *
11
+ * - The CME session lattice (`isCmeSessionLatticeExchange`, `isCmeSessionLatticeIntervalMs`): a
12
+ * leg whose venue (its pinned exchange, else the chart's) the gateway builds on it closes each
13
+ * candle at `cmeSessionBarEndMs` (a 3d group at the 17:00 Chicago open after its last trade date,
14
+ * a fall-back Sunday bar an hour late), or at open plus the span for a stamp the lattice books no
15
+ * row to (a regular-hours leg's 09:30 New York bar); a daily, 3d or weekly candle stamped at its
16
+ * trade date trades from the session open before it (`cmeSessionBarOpenMs`), and a primary row
17
+ * there runs from that open to its bar end.
18
+ * - A US listing (`wrunCalendarOfVenue` "us_equities": NYSE, NASDAQ, CBOE, POLYGON) on a
19
+ * regular-session chart: a candle closes with its session (`wrunMarketLegCandleClose` on a New
20
+ * York stock: the daily at 16:00 New York, the week with its last session), read on the gateway's
21
+ * fixed 09:30 to 16:00 window (`regularWindowClose`: an NYSE early close keeps its after-hours
22
+ * prints until 16:00, so its candle closes there, never before its last print). An
23
+ * extended-hours chart fetches every print, so every leg there keeps open plus the span.
24
+ * - Every other leg (US_STOCKS among them, for now) keeps the leg core's open plus the span.
25
+ *
26
+ * What the browser still owns: the chart's session word (`wrunChartSessionType`: regular unless the
27
+ * chart runs its extended session, never unstated), a calendar row's bounds on every market (1M 3M
28
+ * 6M 1Y, `wrunCalendarRowBounds`, and the calendar bar holding an instant), and the live tick's
29
+ * timing: the gateway's rows hold a stock candle whole only minutes after its close (Polygon's
30
+ * minute bars land after their minute, the closing auction joins the session's last minute once
31
+ * the 16:00 bar has landed), so the live tick re-asks a stock leg `WRUN_US_EQUITIES_CLOSE_SETTLE_MS`
32
+ * after a close (`wrunLegCloseSettleMs`), and the pinned-close timer wakes at the close of the leg's
33
+ * bar holding now on the chart's live boundary rule (`wrunLegBarCloseAt`).
34
+ *
35
+ * Synchronous: every wrapper reads the loaded shared host (`wrunChartHostEnv().sharedHost()`), which each own-run
36
+ * entry loads before its first use.
37
+ */
38
+ import { barStartMs, isCalendarIntervalMs } from '../chart/calendar-interval.util.js';
39
+ import { liveBucketStartMs } from '../chart/live-bucket.util.js';
40
+ import { isEquityExtendedSession } from '../chart/us-equities-session.util.js';
41
+ import { wrunChartHostEnv } from '../../host-env.js';
42
+ import { wrunCalendarRowBounds } from './wrun-source-rows.util.js';
43
+ const DAY_MS = 86_400_000;
44
+ /** How long after a US listing's candle closes the gateway's rows hold all of it: its candles are
45
+ * built from Polygon's minute bars, which land after their minute ends, and the closing auction
46
+ * joins the session's last minute only once the 16:00 bar has landed, after 16:01 New York
47
+ * (docs/features/data/rth-eth-sessions.md, "Closing auction"). The live tick re-asks a stock leg
48
+ * this long after a close, so the confirmed read takes the whole candle. */
49
+ export const WRUN_US_EQUITIES_CLOSE_SETTLE_MS = 180_000;
50
+ /** The venue a leg's bars come from: its pinned exchange, else the chart's. */
51
+ function legExchangeOf(leg, chartExchange) {
52
+ return leg.market?.exchange ?? chartExchange;
53
+ }
54
+ /** The session the chart fetches a US listing's candles on, as the shared host's session calendar
55
+ * reads it: 'extended' only while the chart runs its extended session (`isEquityExtendedSession`,
56
+ * the fetch's own decider), else 'regular', an unset session included (the browser never leaves it
57
+ * unstated; the package reads an unstated session as open plus the span). */
58
+ export function wrunChartSessionType(sessionType) {
59
+ return isEquityExtendedSession(sessionType) ? 'extended' : 'regular';
60
+ }
61
+ /** The chart's session as the row builder reads it (`WrunChartSourceRows.session`): the chart's
62
+ * exchange and the session word of its `sessionType`. */
63
+ export function wrunChartSession(exchange, sessionType) {
64
+ return { ...(exchange !== undefined ? { exchange } : {}), sessionType: wrunChartSessionType(sessionType) };
65
+ }
66
+ /** Whether the gateway builds this leg's bars on the CME session lattice. */
67
+ export function wrunLegRidesCmeSession(leg, chartExchange) {
68
+ const host = wrunChartHostEnv().sharedHost();
69
+ return (host.isCmeSessionLatticeExchange(legExchangeOf(leg, chartExchange)) && host.isCmeSessionLatticeIntervalMs(leg.legMs));
70
+ }
71
+ /** A US listing's candle close on a regular-session chart (the module doc): undefined on an
72
+ * extended-hours chart and on every other venue. */
73
+ function stockLegCandleClose(leg, chartExchange, sessionType) {
74
+ if (!(Number.isFinite(leg.legMs) && leg.legMs > 0) || wrunChartSessionType(sessionType) !== 'regular') {
75
+ return undefined;
76
+ }
77
+ const host = wrunChartHostEnv().sharedHost();
78
+ if (host.wrunCalendarOfVenue(legExchangeOf(leg, chartExchange)) !== 'us_equities')
79
+ return undefined;
80
+ const stock = { kind: host.WRUN_MARKET_KIND_STOCK, zone: host.WRUN_MARKET_ZONE_NEW_YORK };
81
+ const close = host.wrunMarketLegCandleClose(stock, leg.legMs);
82
+ return close === undefined ? undefined : host.regularWindowClose(close, leg.legMs);
83
+ }
84
+ /** How long after a close the leg's venue holds the whole candle (the module doc): a US listing's
85
+ * `WRUN_US_EQUITIES_CLOSE_SETTLE_MS` where its candles close with the session, 0 for every other
86
+ * leg (its live feed seals a candle at its close). */
87
+ export function wrunLegCloseSettleMs(leg, chartExchange, sessionType) {
88
+ return stockLegCandleClose(leg, chartExchange, sessionType) === undefined ? 0 : WRUN_US_EQUITIES_CLOSE_SETTLE_MS;
89
+ }
90
+ /** The leg's candle closes for the leg core (`closeMs`): the CME session lattice's, else a US
91
+ * listing's session closes on a regular-session chart (the chart's `sessionType`); undefined where
92
+ * they are open plus the span. */
93
+ export function wrunLegCandleClose(leg, chartExchange, sessionType) {
94
+ if (!wrunLegRidesCmeSession(leg, chartExchange))
95
+ return stockLegCandleClose(leg, chartExchange, sessionType);
96
+ const { legMs } = leg;
97
+ const { cmeSessionBarEndMs } = wrunChartHostEnv().sharedHost();
98
+ return (openMs) => cmeSessionBarEndMs(openMs, legMs) ?? openMs + legMs;
99
+ }
100
+ /** When the lattice bar stamped `stampMs` starts trading: its session open, or the stamp for a
101
+ * stamp the lattice does not book. */
102
+ function sessionOpenMs(host, stampMs, intervalMs) {
103
+ return host.cmeSessionBucketMs(stampMs, intervalMs) === stampMs
104
+ ? (host.cmeSessionBarOpenMs(stampMs, intervalMs) ?? stampMs)
105
+ : stampMs;
106
+ }
107
+ /** The leg's candle opens for the leg core (`candleOpenMs`), undefined where a candle trades from
108
+ * its stamp: a CME daily, 3d or weekly candle stamped at its trade date trades from the session
109
+ * open before it. */
110
+ export function wrunLegCandleOpen(leg, chartExchange) {
111
+ if (!wrunLegRidesCmeSession(leg, chartExchange))
112
+ return undefined;
113
+ const { legMs } = leg;
114
+ const host = wrunChartHostEnv().sharedHost();
115
+ return (stampMs) => sessionOpenMs(host, stampMs, legMs);
116
+ }
117
+ /** The chart's primary row bounds for the leg core (`rowBounds`), undefined where a row spans
118
+ * [label, label + P): a calendar row (1M 3M 6M 1Y, any market) runs from its label to its calendar
119
+ * end (`wrunCalendarRowBounds`); a row of a market the gateway builds on the CME session lattice,
120
+ * at a lattice interval, runs from its session open to its bar end (a daily row labelled Sep 30
121
+ * runs from Sep 29 22:00Z to Sep 30 22:00Z under daylight time; the Tuesday after Labor Day from
122
+ * the Sunday open). A label the lattice does not book keeps [label, label + P). The row builder
123
+ * reads the same answer through `wrunSessionClock`. */
124
+ export function wrunPrimaryRowBounds(chartExchange, intervalMs) {
125
+ const calendar = wrunCalendarRowBounds(intervalMs);
126
+ if (calendar !== undefined)
127
+ return calendar;
128
+ if (!wrunLegRidesCmeSession({ legMs: intervalMs }, chartExchange))
129
+ return undefined;
130
+ const host = wrunChartHostEnv().sharedHost();
131
+ return (rowOpenMs) => {
132
+ const closeMs = host.cmeSessionBarEndMs(rowOpenMs, intervalMs);
133
+ if (closeMs === null)
134
+ return { openMs: rowOpenMs, closeMs: rowOpenMs + intervalMs };
135
+ return { openMs: Math.min(rowOpenMs, sessionOpenMs(host, rowOpenMs, intervalMs)), closeMs };
136
+ };
137
+ }
138
+ /** The label of the primary row holding `instantMs` where a calendar labels the rows: its calendar
139
+ * bar on a calendar chart (March 10 is the March 1 row), the row whose session holds it on the CME
140
+ * session lattice; undefined elsewhere, where the caller keeps its own grid. */
141
+ export function wrunPrimaryRowHoldingMs(chartExchange, intervalMs, instantMs) {
142
+ if (isCalendarIntervalMs(intervalMs))
143
+ return barStartMs(instantMs, intervalMs);
144
+ if (!wrunLegRidesCmeSession({ legMs: intervalMs }, chartExchange))
145
+ return undefined;
146
+ return wrunChartHostEnv().sharedHost().cmeSessionBucketMs(instantMs, intervalMs) ?? undefined;
147
+ }
148
+ /** The open of the first US equities session after `instantMs` (the NYSE calendar the stock
149
+ * close reads), undefined when none opens within a week. */
150
+ function nextUsEquitiesOpenMs(instantMs) {
151
+ for (let day = 0; day <= 7; day += 1) {
152
+ const session = wrunChartHostEnv()
153
+ .sharedHost()
154
+ .wrunUsEquitiesSession(instantMs + day * DAY_MS);
155
+ if (session !== null && session.openMs > instantMs)
156
+ return session.openMs;
157
+ }
158
+ return undefined;
159
+ }
160
+ /** The close of the leg's bar holding `nowMs` where its venue closes bars off the plain grid,
161
+ * undefined elsewhere or once that bar has closed (the caller keeps its own grid, a wake no later
162
+ * than the next close): on the CME session lattice the lattice bar's end; on a US listing on a
163
+ * regular-session chart (the chart's `sessionType`) the stock's close (`wrunLegCandleClose`) of
164
+ * the candle the chart's live boundary rule keys now to (`liveBucketStartMs`: the trade date for a
165
+ * day, the Monday for a week, the 09:30 New York lattice from 45m to 12h), and off the session on
166
+ * that lattice the first candle of the next session. */
167
+ export function wrunLegBarCloseAt(leg, chartExchange, nowMs, sessionType) {
168
+ const host = wrunChartHostEnv().sharedHost();
169
+ if (wrunLegRidesCmeSession(leg, chartExchange)) {
170
+ const barMs = host.cmeSessionBucketMs(nowMs, leg.legMs);
171
+ const endMs = barMs === null ? null : host.cmeSessionBarEndMs(barMs, leg.legMs);
172
+ return endMs !== null && endMs > nowMs ? endMs : undefined;
173
+ }
174
+ const close = stockLegCandleClose(leg, chartExchange, sessionType);
175
+ if (close === undefined)
176
+ return undefined;
177
+ const venue = { exchange: legExchangeOf(leg, chartExchange), sessionType };
178
+ let stampMs = liveBucketStartMs(nowMs, leg.legMs, venue);
179
+ if (stampMs === null) {
180
+ const openMs = nextUsEquitiesOpenMs(nowMs);
181
+ stampMs = openMs === undefined ? null : liveBucketStartMs(openMs, leg.legMs, venue);
182
+ }
183
+ if (stampMs === null)
184
+ return undefined;
185
+ const endMs = host.wrunLegCandleCloseMs(stampMs, leg.legMs, close);
186
+ return endMs > nowMs ? endMs : undefined;
187
+ }
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Where the chart fetches an interval-pinned leg from, through the shared host's leg core
3
+ * (`@orangecharts/indicator-kit/host` through the seam, the om SDK's wrun-legs.ts): never re-derived
4
+ * here.
5
+ *
6
+ * - A candle leg (a period leg's scalar views, a `candles` stream) asks from the earliest start
7
+ * its readings plan, `wrunLegFetchStart` per input over the window's head and the run's clock:
8
+ * two leg spans before the head on a leg coarser than the chart, one on an equal or finer
9
+ * leg, N more for view `offset` N, and `bars` deepening it from the leg bucket holding now; a
10
+ * `candles` input read with view "forming" (the live candle) asks two leg spans before the
11
+ * bucket holding now (`candles_forming`), one read with view "forming_open" (the open of the
12
+ * candle holding each row) one leg span before the head's leg bucket (`candles_forming_open`),
13
+ * both through now.
14
+ * - A candle leg coarser than the chart also asks a warm-up floor, `WRUN_COARSER_LEG_WARMUP_CANDLES`
15
+ * leg candles before the head (a 1h or 4h leg on a 1m chart otherwise holds only the few
16
+ * candles of the chart's own window), cut silently at the history wall: the floor is the
17
+ * chart's depth, never an input's ask, so it adds no legend note and the readings' own ask
18
+ * (`askedFromTs`, the om daemon's rule) is unchanged. A leg read only by streams (a `candles`,
19
+ * `oi_candles` or `volume_profile_candles` backlog, the live candle of view "forming", the open
20
+ * of view "forming_open") reads no candle before its readings' ask and asks no floor: a profile
21
+ * stream's candles carry whole row sets.
22
+ * - The chart's history wall (the TSDB gateway's per-interval reach, `historyReachMs`: 15,000
23
+ * bars at most intervals, 25,000 at 1h and 50,000 at 30m, now minus that many leg spans) clamps
24
+ * each ask through `wrunServedLegStart`: the leg is asked from the first whole candle at or
25
+ * after the wall, a run is never refused for depth, and an input that asked for more history
26
+ * than the wall serves gets the core's note as a legend warning row.
27
+ * - An own-market `forming` view's pre-roll: the primary rows from the head's leg bucket open
28
+ * (`wrunLegFetchStart` reading "forming", the om daemon's primary fetch rule) up to the head,
29
+ * folded into the head's bucket so the first rows read the whole bucket, not NaN.
30
+ *
31
+ * Pure (no store, no fetch): the run pass calls it before any lane fetch, and the leg corpus
32
+ * replay drives it with the corpus's own clocks.
33
+ */
34
+ import type { RuntimeDiagnostic } from '../../interfaces/kscript-diagnostics.interface.js';
35
+ import type { WrunIndicatorMetadata } from '../../interfaces/wrun-runtime.interface.js';
36
+ import type { WrunLegReading } from '@orangecharts/indicator-kit/host';
37
+ import { type WrunSharedHostModule } from '../../host-env.js';
38
+ import type { WrunAlignClock, WrunPinnedLeg, WrunPinnedWire } from './wrun-source-rows.util.js';
39
+ /** One input's reading of a candle leg: what the leg is fetched for. */
40
+ export interface WrunLegFetchRead {
41
+ inputName: string;
42
+ reading: WrunLegReading;
43
+ bars?: number;
44
+ offset?: number;
45
+ }
46
+ /** A leg ask the history wall cut: the input, the leg and the core's note naming the served
47
+ * start. */
48
+ export interface WrunClampedLeg {
49
+ inputName: string;
50
+ intervalKey: string;
51
+ note: string;
52
+ }
53
+ export interface WrunLegFetchPlan {
54
+ /** Where the readings ask from, before the wall (the earliest `wrunLegFetchStart`). */
55
+ askedFromTs: number;
56
+ /** Where the leg is fetched from: the earliest served start over the readings and the
57
+ * warm-up floor. */
58
+ fromTs: number;
59
+ /** The readings the wall cut, each with its note. */
60
+ clamped: WrunClampedLeg[];
61
+ /** The warm-up floor's served start on a leg coarser than the chart (absent on an equal or
62
+ * finer leg, an odds leg, or a leg read for its live candle alone). */
63
+ warmUpFromTs?: number;
64
+ /** An intrabar plan the wall cuts: where the wall serves the leg from (the ask itself goes out
65
+ * whole, `planWrunIntrabarLegFetch`); absent when the wall cuts nothing. */
66
+ wallFromTs?: number;
67
+ }
68
+ /** The leg candles a candle leg coarser than the chart asks before the window's head: a reading
69
+ * seeded on the first candle it sees (an EMA over 1h closes on a 1m chart, whose window holds
70
+ * about ten of them) then starts from history instead of the head (A23). The wall still cuts
71
+ * it, silently. */
72
+ export declare const WRUN_COARSER_LEG_WARMUP_CANDLES = 200;
73
+ /** The chart's history wall for a leg asked at its own interval: now minus the gateway's reach
74
+ * at that interval. The free row is the reach every viewer has (free and plus share one row
75
+ * since tsdb-gateway cee00f2), so the clamp never asks past what a viewer is served. */
76
+ export declare function wrunChartLegReachMs(intervalKey: string, nowMs: number): number;
77
+ /** The chart's clamp of one leg ask (`wrunServedLegStart`, the core's): where to ask, whether
78
+ * the wall cut candles off the plan, and the note naming the served start. `reachMs` defaults
79
+ * to the chart's gateway wall at the leg's interval. */
80
+ export declare function wrunChartLegServedStart(input: {
81
+ inputName: string;
82
+ leg: Pick<WrunPinnedLeg, 'intervalKey' | 'legMs'>;
83
+ nowMs: number;
84
+ askedStartMs: number;
85
+ reachMs?: number;
86
+ }): ReturnType<WrunSharedHostModule['wrunServedLegStart']>;
87
+ /** The readings of a candle leg (`kind` absent: a period leg's scalar views, the `candles`
88
+ * streams and the live-candle readings it serves), in input order. An own-market `forming`
89
+ * view folds the primary rows, whose head bucket the pre-roll fetch covers
90
+ * (`planWrunFormingPreRoll`); the leg's own series keeps the confirmed two-span pre-roll for it
91
+ * (the om daemon's rule). */
92
+ export declare function wrunLegFetchReads(metadata: WrunIndicatorMetadata, leg: WrunPinnedLeg, wires: ReadonlyMap<number, WrunPinnedWire>): WrunLegFetchRead[];
93
+ /** A candle leg's fetch window start: every reading's `wrunLegFetchStart` over the head and the
94
+ * clock, each clamped at the wall (`wrunServedLegStart`), the earliest served start asked; on a
95
+ * leg coarser than the chart, no later than the warm-up floor (`WRUN_COARSER_LEG_WARMUP_CANDLES`
96
+ * leg candles before the head, cut at the wall without a note). An odds leg keeps its readings'
97
+ * ask (its fetch seeds and gap-fills the market's own history), and so does a leg every reading of
98
+ * which is a stream's (a `candles` or lane stream backlog, the live candle alone, the open of the
99
+ * candle holding each row): a stream reads nothing before its own ask. `reachMs` defaults to the chart's gateway
100
+ * wall at the leg's interval. */
101
+ export declare function planWrunLegFetch(input: {
102
+ leg: Pick<WrunPinnedLeg, 'intervalKey' | 'legMs'> & Partial<Pick<WrunPinnedLeg, 'odds'>>;
103
+ reads: readonly WrunLegFetchRead[];
104
+ clock: WrunAlignClock;
105
+ headMs: number;
106
+ reachMs?: number;
107
+ }): WrunLegFetchPlan;
108
+ /** An intrabar leg's fetch, kScript's ltf() rule: the chart's window whole from its head (an
109
+ * exact slice of each row needs no pre-roll), never clamped before the ask. The engine asks an
110
+ * ltf() source over the window it runs and the gateway trims a request straddling the viewer's
111
+ * history wall to the entitled suffix, so the twin asks that same request: the same chunking (a
112
+ * window past KSCRIPT_SOURCE_CHUNK_MAX_PIECES goes out as one request, the original's shape,
113
+ * where a pre-clamp at the free wall left ~60 pieces that outlived the source deadline) and the
114
+ * history the viewer is entitled to (all of it on an account the wall does not cut). The wall's
115
+ * notes are planned here (`clamped`, the core's words; `wallFromTs`, where the wall serves from)
116
+ * and stand only when the answer starts at the wall (`wrunIntrabarServedNotes`). */
117
+ export declare function planWrunIntrabarLegFetch(input: {
118
+ leg: Pick<WrunPinnedLeg, 'intervalKey' | 'legMs' | 'inputIndexes'>;
119
+ metadata: WrunIndicatorMetadata;
120
+ clock: WrunAlignClock;
121
+ headMs: number;
122
+ reachMs?: number;
123
+ }): WrunLegFetchPlan;
124
+ /** The wall notes an intrabar ask keeps once answered (`planWrunIntrabarLegFetch`): the ask went
125
+ * out whole, so a note stands only when the answer starts at the wall the plan named (its first
126
+ * closed candle opens no earlier than `wallFromTs` less the slack), or answered nothing; an
127
+ * answer reaching past the wall (an account it does not cut) keeps none, as kScript's original
128
+ * says nothing there. */
129
+ export declare function wrunIntrabarServedNotes(plan: Pick<WrunLegFetchPlan, 'clamped' | 'wallFromTs'>, closedRows: ReadonlyArray<ArrayLike<number>>, legMs: number): WrunClampedLeg[];
130
+ /** The own-market `forming` pre-roll's ask: the earliest head bucket open over the views
131
+ * (`wrunLegFetchStart` reading "forming"), or undefined when nothing needs one (no such view,
132
+ * or every head bucket opens at the head). Undefined too when that bucket opens behind the
133
+ * wall (`reachMs`, default the chart's gateway wall at the chart interval): a bucket the
134
+ * gateway cannot serve whole stays NaN until a pan-back, never folded partial. */
135
+ export declare function planWrunFormingPreRoll(input: {
136
+ wires: ReadonlyMap<number, WrunPinnedWire>;
137
+ clock: WrunAlignClock;
138
+ headMs: number;
139
+ chartIntervalKey: string;
140
+ reachMs?: number;
141
+ }): number | undefined;
142
+ /** One warning row per input whose leg ask the history wall cut: the core's note (asked N
143
+ * candles from a date; history served from a date), the run drawn from what was served. */
144
+ export declare function wrunClampedLegDiagnostics(legs: ReadonlyArray<WrunClampedLeg>): RuntimeDiagnostic[];
@@ -0,0 +1,212 @@
1
+ import { historyReachMs } from '../chart/history-wall.util.js';
2
+ import { wrunChartHostEnv } from '../../host-env.js';
3
+ import { WRUN_LEG_HISTORY_CLAMPED_CODE } from './wrun-run-health.util.js';
4
+ /** The leg candles a candle leg coarser than the chart asks before the window's head: a reading
5
+ * seeded on the first candle it sees (an EMA over 1h closes on a 1m chart, whose window holds
6
+ * about ten of them) then starts from history instead of the head (A23). The wall still cuts
7
+ * it, silently. */
8
+ export const WRUN_COARSER_LEG_WARMUP_CANDLES = 200;
9
+ /** The chart's history wall for a leg asked at its own interval: now minus the gateway's reach
10
+ * at that interval. The free row is the reach every viewer has (free and plus share one row
11
+ * since tsdb-gateway cee00f2), so the clamp never asks past what a viewer is served. */
12
+ export function wrunChartLegReachMs(intervalKey, nowMs) {
13
+ return nowMs - historyReachMs('free', intervalKey);
14
+ }
15
+ /** The chart's clamp of one leg ask (`wrunServedLegStart`, the core's): where to ask, whether
16
+ * the wall cut candles off the plan, and the note naming the served start. `reachMs` defaults
17
+ * to the chart's gateway wall at the leg's interval. */
18
+ export function wrunChartLegServedStart(input) {
19
+ return wrunChartHostEnv()
20
+ .sharedHost()
21
+ .wrunServedLegStart({
22
+ inputName: input.inputName,
23
+ legMs: input.leg.legMs,
24
+ nowMs: input.nowMs,
25
+ askedStartMs: input.askedStartMs,
26
+ reachMs: input.reachMs ?? wrunChartLegReachMs(input.leg.intervalKey, input.nowMs),
27
+ });
28
+ }
29
+ /** The readings of a candle leg (`kind` absent: a period leg's scalar views, the `candles`
30
+ * streams and the live-candle readings it serves), in input order. An own-market `forming`
31
+ * view folds the primary rows, whose head bucket the pre-roll fetch covers
32
+ * (`planWrunFormingPreRoll`); the leg's own series keeps the confirmed two-span pre-roll for it
33
+ * (the om daemon's rule). */
34
+ export function wrunLegFetchReads(metadata, leg, wires) {
35
+ const reads = [];
36
+ const nameOf = (index) => metadata.inputs.find((input) => input.index === index)?.name ?? String(index);
37
+ for (const index of [...leg.inputIndexes].sort((a, b) => a - b)) {
38
+ const wire = wires.get(index);
39
+ if (wire === undefined)
40
+ continue;
41
+ if (wire.kind === 'candles' && wire.leg.fetchKey === leg.fetchKey) {
42
+ // The live candle (view "forming") asks only around the bucket holding now; the holding
43
+ // candle's open (view "forming_open") from the candle holding the head; the stream asks for
44
+ // its backlog. All read the leg's one fetch.
45
+ reads.push(wire.forming === true
46
+ ? { inputName: nameOf(index), reading: 'candles_forming' }
47
+ : wire.formingOpen === true
48
+ ? { inputName: nameOf(index), reading: 'candles_forming_open' }
49
+ : { inputName: nameOf(index), reading: 'candles', ...(wire.bars !== undefined ? { bars: wire.bars } : {}) });
50
+ }
51
+ else if (wire.kind === 'forming' && wire.leg.fetchKey === leg.fetchKey) {
52
+ reads.push({ inputName: nameOf(index), reading: 'confirmed' });
53
+ }
54
+ else if (wire.kind === 'period' && wire.leg.fetchKey === leg.fetchKey) {
55
+ const bars = wire.source.bars;
56
+ reads.push({
57
+ inputName: nameOf(index),
58
+ reading: wire.view,
59
+ ...(bars !== undefined ? { bars } : {}),
60
+ ...(wire.view === 'offset' ? { offset: wire.offset } : {}),
61
+ });
62
+ }
63
+ }
64
+ return reads;
65
+ }
66
+ /** A stream's reading (a `candles`, `oi_candles` or `volume_profile_candles` input: its backlog, the live candle, the
67
+ * open of the candle holding each row): it reads nothing before its own ask. */
68
+ function isStreamReading(read) {
69
+ return read.reading === 'candles' || read.reading === 'candles_forming' || read.reading === 'candles_forming_open';
70
+ }
71
+ /** A candle leg's fetch window start: every reading's `wrunLegFetchStart` over the head and the
72
+ * clock, each clamped at the wall (`wrunServedLegStart`), the earliest served start asked; on a
73
+ * leg coarser than the chart, no later than the warm-up floor (`WRUN_COARSER_LEG_WARMUP_CANDLES`
74
+ * leg candles before the head, cut at the wall without a note). An odds leg keeps its readings'
75
+ * ask (its fetch seeds and gap-fills the market's own history), and so does a leg every reading of
76
+ * which is a stream's (a `candles` or lane stream backlog, the live candle alone, the open of the
77
+ * candle holding each row): a stream reads nothing before its own ask. `reachMs` defaults to the chart's gateway
78
+ * wall at the leg's interval. */
79
+ export function planWrunLegFetch(input) {
80
+ const { leg, clock, headMs } = input;
81
+ const reachMs = input.reachMs ?? wrunChartLegReachMs(leg.intervalKey, clock.nowMs);
82
+ let askedFromTs = Number.POSITIVE_INFINITY;
83
+ let fromTs = Number.POSITIVE_INFINITY;
84
+ const clamped = [];
85
+ // Every planned candle leg has a reading; a bare leg asks like a confirmed view.
86
+ const reads = input.reads.length > 0 ? input.reads : [{ inputName: leg.intervalKey, reading: 'confirmed' }];
87
+ for (const read of reads) {
88
+ const askedStartMs = wrunChartHostEnv().sharedHost().wrunLegFetchStart({
89
+ reading: read.reading,
90
+ legMs: leg.legMs,
91
+ primaryMs: clock.intervalMs,
92
+ headMs,
93
+ nowMs: clock.nowMs,
94
+ bars: read.bars,
95
+ offset: read.offset,
96
+ });
97
+ const served = wrunChartLegServedStart({
98
+ inputName: read.inputName,
99
+ leg,
100
+ nowMs: clock.nowMs,
101
+ askedStartMs,
102
+ reachMs,
103
+ });
104
+ askedFromTs = Math.min(askedFromTs, askedStartMs);
105
+ fromTs = Math.min(fromTs, served.startMs);
106
+ if (served.note !== null)
107
+ clamped.push({ inputName: read.inputName, intervalKey: leg.intervalKey, note: served.note });
108
+ }
109
+ // A stream reads only what its own reading asks (a backlog from wrunLegFetchStart, the live candle, the forming
110
+ // open), so a leg every reading of which is a stream's asks no warm-up: a profile stream's candles carry whole row
111
+ // sets, and a floor it never delivers would hold thousands of rows for the session.
112
+ const warmsUp = leg.legMs > clock.intervalMs && leg.odds !== true && reads.some((read) => !isStreamReading(read));
113
+ if (!warmsUp)
114
+ return { askedFromTs, fromTs, clamped };
115
+ // The floor is served like any ask (the first whole candle at or after the wall), its note
116
+ // dropped: an input never asked for it, so the legend says nothing when the wall cuts it.
117
+ const warmUpFromTs = wrunChartLegServedStart({
118
+ inputName: leg.intervalKey,
119
+ leg,
120
+ nowMs: clock.nowMs,
121
+ askedStartMs: headMs - WRUN_COARSER_LEG_WARMUP_CANDLES * leg.legMs,
122
+ reachMs,
123
+ }).startMs;
124
+ return { askedFromTs, fromTs: Math.min(fromTs, warmUpFromTs), clamped, warmUpFromTs };
125
+ }
126
+ /** An intrabar leg's fetch, kScript's ltf() rule: the chart's window whole from its head (an
127
+ * exact slice of each row needs no pre-roll), never clamped before the ask. The engine asks an
128
+ * ltf() source over the window it runs and the gateway trims a request straddling the viewer's
129
+ * history wall to the entitled suffix, so the twin asks that same request: the same chunking (a
130
+ * window past KSCRIPT_SOURCE_CHUNK_MAX_PIECES goes out as one request, the original's shape,
131
+ * where a pre-clamp at the free wall left ~60 pieces that outlived the source deadline) and the
132
+ * history the viewer is entitled to (all of it on an account the wall does not cut). The wall's
133
+ * notes are planned here (`clamped`, the core's words; `wallFromTs`, where the wall serves from)
134
+ * and stand only when the answer starts at the wall (`wrunIntrabarServedNotes`). */
135
+ export function planWrunIntrabarLegFetch(input) {
136
+ const { leg, clock, headMs } = input;
137
+ const reachMs = input.reachMs ?? wrunChartLegReachMs(leg.intervalKey, clock.nowMs);
138
+ let wallFromTs;
139
+ const clamped = [];
140
+ // Every input on the leg asks the same head, so each served start is the same instant; each
141
+ // input the wall cut gets its own note.
142
+ for (const index of [...leg.inputIndexes].sort((a, b) => a - b)) {
143
+ const inputName = input.metadata.inputs.find((candidate) => candidate.index === index)?.name ?? String(index);
144
+ const served = wrunChartLegServedStart({ inputName, leg, nowMs: clock.nowMs, askedStartMs: headMs, reachMs });
145
+ if (served.note === null)
146
+ continue;
147
+ wallFromTs = served.startMs;
148
+ clamped.push({ inputName, intervalKey: leg.intervalKey, note: served.note });
149
+ }
150
+ return { askedFromTs: headMs, fromTs: headMs, clamped, ...(wallFromTs !== undefined ? { wallFromTs } : {}) };
151
+ }
152
+ /** How far before the planned wall an answer may start and still be the wall's cut: the gateway
153
+ * measures its wall from its own request time, so its trimmed edge lands a few candles either
154
+ * side of the planned one (the slack history-wall.util reads a plan wall with: three bars plus a
155
+ * minute of clock drift). */
156
+ const WRUN_INTRABAR_WALL_SLACK_CANDLES = 3;
157
+ const WRUN_INTRABAR_WALL_DRIFT_MS = 60_000;
158
+ /** The wall notes an intrabar ask keeps once answered (`planWrunIntrabarLegFetch`): the ask went
159
+ * out whole, so a note stands only when the answer starts at the wall the plan named (its first
160
+ * closed candle opens no earlier than `wallFromTs` less the slack), or answered nothing; an
161
+ * answer reaching past the wall (an account it does not cut) keeps none, as kScript's original
162
+ * says nothing there. */
163
+ export function wrunIntrabarServedNotes(plan, closedRows, legMs) {
164
+ if (plan.clamped.length === 0 || plan.wallFromTs === undefined)
165
+ return [];
166
+ let firstOpenMs = Number.POSITIVE_INFINITY;
167
+ for (const row of closedRows) {
168
+ const openMs = Number(row[0]);
169
+ if (Number.isFinite(openMs) && openMs < firstOpenMs)
170
+ firstOpenMs = openMs;
171
+ }
172
+ const slackMs = WRUN_INTRABAR_WALL_SLACK_CANDLES * legMs + WRUN_INTRABAR_WALL_DRIFT_MS;
173
+ return firstOpenMs >= plan.wallFromTs - slackMs ? [...plan.clamped] : [];
174
+ }
175
+ /** The own-market `forming` pre-roll's ask: the earliest head bucket open over the views
176
+ * (`wrunLegFetchStart` reading "forming"), or undefined when nothing needs one (no such view,
177
+ * or every head bucket opens at the head). Undefined too when that bucket opens behind the
178
+ * wall (`reachMs`, default the chart's gateway wall at the chart interval): a bucket the
179
+ * gateway cannot serve whole stays NaN until a pan-back, never folded partial. */
180
+ export function planWrunFormingPreRoll(input) {
181
+ const { clock, headMs } = input;
182
+ let fromTs = Number.POSITIVE_INFINITY;
183
+ for (const wire of input.wires.values()) {
184
+ if (wire.kind !== 'forming' || wire.gridLeg !== undefined)
185
+ continue;
186
+ fromTs = Math.min(fromTs, wrunChartHostEnv().sharedHost().wrunLegFetchStart({
187
+ reading: 'forming',
188
+ legMs: wire.legMs,
189
+ primaryMs: clock.intervalMs,
190
+ headMs,
191
+ nowMs: clock.nowMs,
192
+ }));
193
+ }
194
+ if (!(fromTs < headMs))
195
+ return undefined;
196
+ const reachMs = input.reachMs ?? wrunChartLegReachMs(input.chartIntervalKey, clock.nowMs);
197
+ return fromTs >= reachMs ? fromTs : undefined;
198
+ }
199
+ /** One warning row per input whose leg ask the history wall cut: the core's note (asked N
200
+ * candles from a date; history served from a date), the run drawn from what was served. */
201
+ export function wrunClampedLegDiagnostics(legs) {
202
+ return legs.map((leg) => ({
203
+ stage: 'compute',
204
+ severity: 'warning',
205
+ code: WRUN_LEG_HISTORY_CLAMPED_CODE,
206
+ type: 'execution',
207
+ // The leg core's note verbatim: the same words the om daemon puts on its rows.
208
+ message: leg.note,
209
+ suggestedFix: `The chart's data reaches no further back at ${leg.intervalKey}: read fewer candles (a smaller bars), or treat the periods before the served start as absent.`,
210
+ details: { input: leg.inputName, interval: leg.intervalKey, note: leg.note },
211
+ }));
212
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * The leg STREAM classes: the celled classes that deliver one leg's CLOSED candles of an interval as a
3
+ * cell stream (the shared host's leg stream, `WrunCandleStream` and the kit's per-class row mappers: the
4
+ * backlog on the first delivered row, as far back as `bars`, then the candles admitted since, never a
5
+ * forming candle, never truncated). One row per class; every reader of "is this a leg stream" reads this
6
+ * table, so a fourth stream class is one row here.
7
+ *
8
+ * - `candles`: the leg's price candles, `[offset_ms, open, high, low, close, volume]`, over the chart's
9
+ * candle lane (`ohlcv`); the one class with views ("forming", "forming_open").
10
+ * - `oi_candles`: the leg's open-interest candles, `[offset_ms, open, high, low, close]`, over the
11
+ * `open_interest` lane, in the market's native units (coins or contracts) unless the input names
12
+ * `currency: "USD"`.
13
+ * - `volume_profile_candles`: one closed candle's price rows, `[offset_ms, low, high, buy, sell]` per row
14
+ * (the rows of one candle share `offset_ms`, ascending by price), over the `volume_profile` lane at the
15
+ * input's `ticks_per_bar` and `currency` (coins unless "USD"); `max_cells` is required (a block's size is
16
+ * rows per candle times the candles it carries, which the editor cannot know).
17
+ *
18
+ * The tuple widths are the shared host's (`WRUN_HOST_CELL_TUPLE_WIDTHS`), never copied here.
19
+ *
20
+ * A LEAF on purpose: no imports, erasable TypeScript only, so the socket worker and the Node scripts can
21
+ * read it. The two script-run leaves that cannot import (`wrun-browser-sources.leaf.ts`,
22
+ * `wrun-template-refusal.ts`) and the chart-host package (`wrun-refusal.util.ts` LEG_CLASSES) hand-copy the
23
+ * names; `tests/utility/wrun/wrun-leg-stream-classes.spec.ts` holds every copy and every special case to
24
+ * this table, and the table to the installed kit's leg-clocked celled classes.
25
+ * See docs/features/kscript/wrun/wrun-browser-runtime.md ("Leg history").
26
+ */
27
+ /** A leg stream class word, as a sheet's `source` spells it. */
28
+ export type WrunLegStreamClassName = 'candles' | 'oi_candles' | 'volume_profile_candles';
29
+ /** A leg stream class that reads a lane other than the chart's candles (its own fetch type and knobs). */
30
+ export type WrunLaneStreamClassName = Exclude<WrunLegStreamClassName, 'candles'>;
31
+ /** One stream class: the lane its leg rides and the words its refusals use. */
32
+ export interface WrunLegStreamClass {
33
+ /** The chart fetch type (the kScript data control `dataFetch` asks) the leg is fetched through. */
34
+ readonly fetchType: 'ohlcv' | 'open_interest' | 'volume_profile';
35
+ /** The gateway data type that fetch reads (the requirement row's market fact). */
36
+ readonly gatewayType: string;
37
+ /** What one candle of the leg is, in a label or a refusal ("Pinned 1h <noun>"). */
38
+ readonly noun: string;
39
+ /** The views the class takes beside the stream of closed candles (none but candles' two). */
40
+ readonly views: readonly string[];
41
+ /** The lane words the class takes beyond the stream's own knobs (interval, bars, max_cells, a whole
42
+ * market pin, chart_interval_below). */
43
+ readonly laneWords: ReadonlyArray<'currency' | 'ticks_per_bar'>;
44
+ /** The quote a leg reads when the input names no `currency` (a class without the word reads its lane's
45
+ * only quote). */
46
+ readonly defaultCurrency?: 'USD' | 'Coin';
47
+ /** `max_cells` must be declared: no editor fill can size a block of this class. */
48
+ readonly maxCellsRequired: boolean;
49
+ }
50
+ /** Every leg stream class, keyed by its word. */
51
+ export declare const WRUN_LEG_STREAM_CLASSES: Readonly<Record<WrunLegStreamClassName, WrunLegStreamClass>>;
52
+ /** The stream class words, in the table's order. */
53
+ export declare const WRUN_LEG_STREAM_CLASS_NAMES: readonly WrunLegStreamClassName[];
54
+ /** Whether a source class word is a leg stream class. */
55
+ export declare function isWrunLegStreamClass(value: unknown): value is WrunLegStreamClassName;
56
+ /** Whether a source class word is a leg stream class over a lane of its own (not the chart's candles). */
57
+ export declare function isWrunLaneStreamClass(value: unknown): value is WrunLaneStreamClassName;
58
+ /** The lane identity of one lane-stream leg: the class and the lane words its fetch carries (one fetch
59
+ * per class, market, interval and identity; two inputs with the same identity share it). */
60
+ export interface WrunLegStreamLane {
61
+ class: WrunLaneStreamClassName;
62
+ /** The quote the lane is asked in: "USD" (dollars) or "Coin" (the market's native units). */
63
+ currency: 'USD' | 'Coin';
64
+ /** `volume_profile_candles` only: the price ticks one row spans (1..500, normalized). */
65
+ ticksPerBar?: number;
66
+ }
67
+ /** A lane stream's quote: "USD" only when the input says so, else the class's default. */
68
+ export declare function wrunLegStreamCurrency(streamClass: WrunLaneStreamClassName, currency: unknown): 'USD' | 'Coin';
69
+ /** The fetch-key words a lane stream adds to its leg's key: the class, then its lane identity. */
70
+ export declare function wrunLegStreamKeyWords(lane: WrunLegStreamLane): string;
71
+ /** The payload words a lane stream's fetch carries (the kScript data control's settings: `currency` for
72
+ * the open-interest and volume-profile controls, `ticksPerBar` for the profile's). */
73
+ export declare function wrunLegStreamPayloadWords(lane: WrunLegStreamLane): Record<string, unknown>;