@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,59 @@
1
+ import { getExchangeFromSymbol } from '../../helpers/data.helpers.js';
2
+ import { extractTokensFromTransformations, parsedTransformations } from '../common/transformations.util.js';
3
+ import { formatDisplayToExchange } from '../exchange-normalization.util.js';
4
+ import { checkIsIndexMode } from './index-mode.util.js';
5
+ import { checkIsDex, checkIsEconomic, getMarketKind } from './marketKind.util.js';
6
+ /**
7
+ * Which legs of a formula share a calendar, for the symbol guard and for the history worker (so this module stays
8
+ * worker-safe: legacy listing venues are healed by the guard on top, never here).
9
+ */
10
+ /** Wire identity of one leg: display suffixes and spaced display names canonicalized. */
11
+ export function formulaLegExchange(exchange, symbol) {
12
+ const resolved = getExchangeFromSymbol(exchange || '', symbol || '') || exchange || '';
13
+ return formatDisplayToExchange(resolved.trim()).replace(/\s+/g, '_').toUpperCase();
14
+ }
15
+ /** Each leg's wire venue on a formula (more than one part); empty for a plain symbol. */
16
+ export function formulaLegExchanges(transformations) {
17
+ if (!transformations || parsedTransformations(transformations).length <= 1)
18
+ return [];
19
+ return extractTokensFromTransformations(transformations).map((token) => formulaLegExchange(token.exchange, token.symbol));
20
+ }
21
+ /**
22
+ * The calendar a leg trades on, or null for legs every formula already combines (crypto, HIP-3, CME futures,
23
+ * prediction markets, economic series). The null class is a compatibility class, not one calendar: CME closes on
24
+ * weekends while crypto does not, and those legs still join on exact stamps. A group also pins the fetch mode, so an
25
+ * index-mode leg never pairs with a timestamp-mode twin of the same kind.
26
+ */
27
+ export function formulaLegGroup(exchange) {
28
+ const kind = getMarketKind(exchange);
29
+ if (kind === 'dex' || checkIsDex(exchange))
30
+ return 'dex';
31
+ const mode = checkIsIndexMode(exchange) ? 'index' : 'timestamp';
32
+ if (kind === 'tradfi')
33
+ return `stocks:${mode}`;
34
+ if (kind === 'forex')
35
+ return `forex:${mode}`;
36
+ if (kind === 'commodity')
37
+ return `commodity:${exchange}:${mode}`;
38
+ return mode === 'index' ? `venue:${exchange}` : null;
39
+ }
40
+ /**
41
+ * How a formula whose legs trade on different calendars lines up, or null when every leg shares one (BTC / ETH,
42
+ * SPY / GLD, BTC / M2): those join on exact stamps, as they always have. Economic series never set the timeline
43
+ * (`carryEconomicSeries` reads them as of the market legs' bars), so the anchor is the first market leg.
44
+ */
45
+ export function formulaCalendarPlan(transformations) {
46
+ if (!transformations)
47
+ return null;
48
+ const legs = extractTokensFromTransformations(transformations).map((token) => {
49
+ const exchange = formulaLegExchange(token.exchange, token.symbol);
50
+ return { token: token.token, economic: checkIsEconomic(exchange), group: formulaLegGroup(exchange) };
51
+ });
52
+ if (new Set(legs.map((leg) => leg.group)).size <= 1)
53
+ return null;
54
+ const anchor = legs.find((leg) => !leg.economic);
55
+ if (!anchor)
56
+ return null;
57
+ const carried = legs.filter((leg) => !leg.economic && leg.group !== anchor.group).map((leg) => leg.token);
58
+ return { anchor: anchor.token, carried: new Set(carried) };
59
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * History wall classification: why a chart ran out of older candles.
3
+ *
4
+ * The tsdb-gateway enforces each tier's reach as a rolling window measured
5
+ * from request time (internal/gateway/reader/kiyo_plus_validation.go):
6
+ * maxSince = requestTime - maxBars x requestInterval. A period window
7
+ * straddling maxSince is trimmed silently and a window entirely older is
8
+ * refused ("bar limit exceeded", bar-limit-error.util). A trimmed edge
9
+ * therefore sits at or just after maxSince at request time, and the wall only
10
+ * moves newer as time passes. An oldest loaded candle within slack of
11
+ * `now - maxBars x requestInterval` is the viewer's plan wall; a newer one is
12
+ * where the market's data begins (a listing start), which no plan changes.
13
+ *
14
+ * Count requests (count-mode venues: tradfi, forex, commodity, dex) are never
15
+ * trimmed: the gateway serves any anchor at or newer than maxSince in full and
16
+ * refuses an older one. Their call sites pass the kind they know instead of
17
+ * asking this edge test.
18
+ *
19
+ * Deliberately store-free: the caller supplies the tier, the edge, the market
20
+ * traits and the clock (history-cap.util owns the store reads).
21
+ */
22
+ import { type Tier } from '../../constants/feature-limits.constants.js';
23
+ /**
24
+ * `plan-wall`: the viewer's own tier wall stopped the data. `data-start`: the
25
+ * market has no older data, or the target lies behind the Plus wall, which no
26
+ * tier reaches.
27
+ */
28
+ export type HistoryWallKind = 'plan-wall' | 'data-start';
29
+ /**
30
+ * The interval the gateway is actually asked for when the main chart shows
31
+ * `chartInterval`. fetchMainData sends the chart label (`options.requestInterval
32
+ * ?? metadata.interval`; the lazy path never overrides it) and the OHLCV worker
33
+ * maps it with `grpcIntervalOf(interval)`
34
+ * (workers/indicators/controls/ohlcv.worker.ts): the twelve native labels and
35
+ * the custom ones go out as themselves ('3M' as QUARTER, '3m' as
36
+ * THREE_MINUTES), and any other label ('5s' to '30s', '1mm') falls back to
37
+ * AggregationInterval.MINUTE. The gateway measures the wall in that interval,
38
+ * so the chart label would put the wall far too deep.
39
+ */
40
+ export declare function gatewayRequestIntervalFor(chartInterval: string): string;
41
+ /** How far back the tier's gateway window reaches at this chart interval, in ms. */
42
+ export declare function historyReachMs(tier: Tier, chartInterval: string): number;
43
+ export interface HistoryWallInput {
44
+ /** The oldest loaded main candle (ms). */
45
+ edgeMs: number;
46
+ /** The interval actually sent to the gateway (gatewayRequestIntervalFor), in ms. */
47
+ requestIntervalMs: number;
48
+ /** The viewer's tier reach in bars at that request interval. */
49
+ tierMaxBars: number;
50
+ nowMs: number;
51
+ /** The market closes (isSessionBoundMarketKind): a wall can fall on a weekend or a holiday. */
52
+ sessionBound: boolean;
53
+ /** The wire omits tradeless buckets (mayServeLegitimatelySparseHistory): the first trade can land after the wall. */
54
+ sparseHistory: boolean;
55
+ }
56
+ /** `plan-wall` iff the edge sits at (or behind) the viewer's tier wall, within slack. */
57
+ export declare function classifyHistoryWall({ edgeMs, requestIntervalMs, tierMaxBars, nowMs, sessionBound, sparseHistory, }: HistoryWallInput): HistoryWallKind;
58
+ export type HistoryReachUnit = 'hours' | 'days' | 'months' | 'years';
59
+ /**
60
+ * A reach in the words the plan copy uses: hours under a day, days under 60
61
+ * days, months under 24 months, else years, rounded to the nearest whole unit
62
+ * (208 days reads 7 months, 1,042 days reads 3 years).
63
+ */
64
+ export declare function describeHistoryReach(reachMs: number): {
65
+ unit: HistoryReachUnit;
66
+ count: number;
67
+ };
@@ -0,0 +1,87 @@
1
+ /**
2
+ * History wall classification: why a chart ran out of older candles.
3
+ *
4
+ * The tsdb-gateway enforces each tier's reach as a rolling window measured
5
+ * from request time (internal/gateway/reader/kiyo_plus_validation.go):
6
+ * maxSince = requestTime - maxBars x requestInterval. A period window
7
+ * straddling maxSince is trimmed silently and a window entirely older is
8
+ * refused ("bar limit exceeded", bar-limit-error.util). A trimmed edge
9
+ * therefore sits at or just after maxSince at request time, and the wall only
10
+ * moves newer as time passes. An oldest loaded candle within slack of
11
+ * `now - maxBars x requestInterval` is the viewer's plan wall; a newer one is
12
+ * where the market's data begins (a listing start), which no plan changes.
13
+ *
14
+ * Count requests (count-mode venues: tradfi, forex, commodity, dex) are never
15
+ * trimmed: the gateway serves any anchor at or newer than maxSince in full and
16
+ * refuses an older one. Their call sites pass the kind they know instead of
17
+ * asking this edge test.
18
+ *
19
+ * Deliberately store-free: the caller supplies the tier, the edge, the market
20
+ * traits and the clock (history-cap.util owns the store reads).
21
+ */
22
+ import { Intervals } from '../../constants/interval.constants.js';
23
+ import { lookupGrpcInterval } from './interval-registry.util.js';
24
+ import { gatewayTierMaxBars } from '../../constants/feature-limits.constants.js';
25
+ const HOUR_MS = 3_600_000;
26
+ const DAY_MS = 86_400_000;
27
+ /** Bars past the computed wall that still read as the wall: the trimmed edge lands up to one bar in. */
28
+ const PLAN_WALL_SLACK_BARS = 3;
29
+ /** Drift between the browser clock and the gateway's request time. */
30
+ const PLAN_WALL_DRIFT_MS = 60_000;
31
+ /** Session-bound markets (CME, tradfi, forex, commodity): the first bar after the wall can land a closure later. */
32
+ const SESSION_GAP_SLACK_MS = 4 * DAY_MS;
33
+ /**
34
+ * Sparse-history markets (the wire returns only traded buckets and the chart
35
+ * pads the gaps): a thin market's first trade after the wall can land hours
36
+ * past it. Twelve hours covers an overnight lull; a longer silence reads as a
37
+ * listing start.
38
+ */
39
+ const NO_TRADE_GAP_SLACK_MS = 12 * HOUR_MS;
40
+ /**
41
+ * The closure and no-trade allowances together never cover more than this
42
+ * share of the tier reach, so a listing start in the newest three quarters
43
+ * of the window always reads as a data start (at 1m the free reach is only
44
+ * about 3.5 days, less than the four-day closure allowance).
45
+ */
46
+ const GAP_SLACK_MAX_REACH_SHARE = 0.25;
47
+ /**
48
+ * The interval the gateway is actually asked for when the main chart shows
49
+ * `chartInterval`. fetchMainData sends the chart label (`options.requestInterval
50
+ * ?? metadata.interval`; the lazy path never overrides it) and the OHLCV worker
51
+ * maps it with `grpcIntervalOf(interval)`
52
+ * (workers/indicators/controls/ohlcv.worker.ts): the twelve native labels and
53
+ * the custom ones go out as themselves ('3M' as QUARTER, '3m' as
54
+ * THREE_MINUTES), and any other label ('5s' to '30s', '1mm') falls back to
55
+ * AggregationInterval.MINUTE. The gateway measures the wall in that interval,
56
+ * so the chart label would put the wall far too deep.
57
+ */
58
+ export function gatewayRequestIntervalFor(chartInterval) {
59
+ return lookupGrpcInterval(chartInterval) !== undefined ? chartInterval : '1m';
60
+ }
61
+ /** How far back the tier's gateway window reaches at this chart interval, in ms. */
62
+ export function historyReachMs(tier, chartInterval) {
63
+ const requestInterval = gatewayRequestIntervalFor(chartInterval);
64
+ return gatewayTierMaxBars(tier, requestInterval) * Intervals.map_unit[requestInterval];
65
+ }
66
+ /** `plan-wall` iff the edge sits at (or behind) the viewer's tier wall, within slack. */
67
+ export function classifyHistoryWall({ edgeMs, requestIntervalMs, tierMaxBars, nowMs, sessionBound, sparseHistory, }) {
68
+ const reachMs = tierMaxBars * requestIntervalMs;
69
+ const gapSlackMs = Math.min((sessionBound ? SESSION_GAP_SLACK_MS : 0) + (sparseHistory ? NO_TRADE_GAP_SLACK_MS : 0), reachMs * GAP_SLACK_MAX_REACH_SHARE);
70
+ const slackMs = PLAN_WALL_SLACK_BARS * requestIntervalMs + PLAN_WALL_DRIFT_MS + gapSlackMs;
71
+ return edgeMs <= nowMs - reachMs + slackMs ? 'plan-wall' : 'data-start';
72
+ }
73
+ /**
74
+ * A reach in the words the plan copy uses: hours under a day, days under 60
75
+ * days, months under 24 months, else years, rounded to the nearest whole unit
76
+ * (208 days reads 7 months, 1,042 days reads 3 years).
77
+ */
78
+ export function describeHistoryReach(reachMs) {
79
+ if (reachMs < DAY_MS)
80
+ return { unit: 'hours', count: Math.max(1, Math.round(reachMs / HOUR_MS)) };
81
+ if (reachMs < 60 * DAY_MS)
82
+ return { unit: 'days', count: Math.round(reachMs / DAY_MS) };
83
+ const months = reachMs / Intervals.MONTH;
84
+ if (months < 24)
85
+ return { unit: 'months', count: Math.round(months) };
86
+ return { unit: 'years', count: Math.round(reachMs / Intervals.YEAR) };
87
+ }
@@ -0,0 +1,66 @@
1
+ export declare const POLYGON_EXCHANGES: readonly ["NYSE", "NASDAQ", "CBOE"];
2
+ export declare const PREDICTION_MARKET_EXCHANGES: readonly ["POLYMARKET", "HYPERLIQUID_HIP4"];
3
+ export declare const PYTH_EXCHANGES: never[];
4
+ export declare const INDEX_VENUE_EXCHANGES: readonly ["POLYGON_INDICES"];
5
+ export declare const TRADFI_EXCHANGES: readonly [...never[], "NYSE", "NASDAQ", "CBOE"];
6
+ export declare const DEX_EXCHANGES: readonly ["UNISWAP_V2", "UNISWAP_V3", "UNISWAP_V4", "SUSHISWAP_V2", "SUSHISWAP_V3", "SHIBASWAP", "PANCAKESWAP_V2", "PANCAKESWAP_V3", "FRAXSWAP", "SOLIDLY", "SOLIDLY_V3"];
7
+ export type PMSignalMarketType = 'crypto' | 'tradfi' | 'commodity';
8
+ export declare const PM_SIGNAL_COMMODITY_TOKEN_MAP: Record<string, string>;
9
+ export declare const PM_SIGNAL_TOKEN_MAP: Record<string, string>;
10
+ import { checkIsPolygon, checkIsPolymarket, checkIsEconomic, checkIsFred, checkIsForex, checkIsCommodity, checkIsFutures, checkIsForexOrCommodity, checkIsForexCommodityOrFutures, checkIsHip3, checkIsHip4, checkIsTradFi, checkIsDex } from './marketKind.util.js';
11
+ export { checkIsPolygon, checkIsPolymarket, checkIsEconomic, checkIsFred, checkIsForex, checkIsCommodity, checkIsFutures, checkIsForexOrCommodity, checkIsForexCommodityOrFutures, checkIsHip3, checkIsHip4, checkIsTradFi, checkIsDex, };
12
+ /**
13
+ * Polymarket ∪ HIP-4, and a STRICT superset of `checkIsPolymarket` — matching
14
+ * its case-insensitivity, not just its membership. Every venue gate widened
15
+ * from `checkIsPolymarket` to this one relies on the superset relation holding:
16
+ * an exact-match version would drop a lowercase venue string out of the deny
17
+ * and back through the permissive tail, which is the exact bug class the
18
+ * widening exists to close.
19
+ *
20
+ * Kept as a set lookup rather than `checkIsPolymarket(x) || checkIsHip4(x)` so
21
+ * this module gains no runtime dependency on `marketKind.util` — 32 specs mock
22
+ * that module partially and would break on the import.
23
+ */
24
+ export declare function checkIsPredictionMarket(exchange: string | undefined | null): boolean;
25
+ export declare function extractBaseTicker(symbol: string): string;
26
+ /**
27
+ * Resolve a chart symbol to its canonical crypto signal ticker (uppercase),
28
+ * or null if it doesn't map to one. Mirrors the normalization in
29
+ * `getPMSignalMarketType` so slug builders stay in sync with eligibility.
30
+ */
31
+ export declare function getPMSignalCryptoTicker(symbol: string | undefined, normalizedSymbol?: string | undefined): string | null;
32
+ /**
33
+ * Resolve a chart symbol to its canonical TradFi ticker (uppercase), or null
34
+ * if it doesn't map to one. Mirrors the normalization in
35
+ * `getPMSignalMarketType` so slug builders stay in sync with eligibility.
36
+ */
37
+ export declare function getPMSignalTradFiTicker(symbol: string | undefined, normalizedSymbol?: string | undefined): string | null;
38
+ export declare function getPMSignalMarketType(symbol: string | undefined, exchange?: string | undefined, normalizedSymbol?: string | undefined): PMSignalMarketType | null;
39
+ export declare function checkIsPMSignalMarket(symbol: string | undefined, exchange?: string | undefined, normalizedSymbol?: string | undefined): boolean;
40
+ /** Exchange-less eligibility check on a `normalizeSymbolForCache` output. */
41
+ export declare function checkIsEligiblePMSignalTicker(normalizedTicker: string): boolean;
42
+ /**
43
+ * True for markets with irregular bar timestamps + count-based fetch
44
+ * (tradfi, forex, commodity, dex). New code should consult the
45
+ * capability registry — `getCapabilities(ex).barTimestamps === 'irregular'`
46
+ * for viewport-coord decisions and `=== 'count'` for fetch shape.
47
+ *
48
+ * CME-governed exchanges under the futures policy ride the V2 period-fetch
49
+ * pipeline (TRADE data, 1s available), so the set-backed predicates here
50
+ * carve them out explicitly (the sets predate the governed codes and cannot
51
+ * ride the flag-dependent kind); this is the other half of eliminating the
52
+ * CBOT/NYMEX/COMEX-vs-CME behavioral split (see marketKind.util.ts).
53
+ */
54
+ export declare function checkIsIndexMode(exchange: string | undefined): boolean;
55
+ /** An index venue (`INDEX_VENUE_EXCHANGES`): a quote series on the US session grid. */
56
+ export declare function checkIsIndexVenue(exchange: string | undefined): boolean;
57
+ /**
58
+ * Exchanges that use TICKER/TICKER_AGG data type instead of TRADE (forex,
59
+ * commodity, the index venues). Governed CME needs no carve-out here: the
60
+ * flag-dependent kind already classifies it futures (TRADE data) with the
61
+ * release gate on and commodity (TICKER, fail-closed) with it off; both
62
+ * states are pinned by cme-futures-capability.spec.ts.
63
+ */
64
+ export declare function checkIsTickerDataType(exchange: string | undefined): boolean;
65
+ export declare function checkIsBlockedOn1s(exchange: string | undefined): boolean;
66
+ export declare function getMarketType(exchange: string): string;
@@ -0,0 +1,360 @@
1
+ import { formatDisplayToExchange } from '../exchange-normalization.util.js';
2
+ import { PREDICTION_MARKET_EXCHANGE_NAMES } from './prediction-identity.util.js';
3
+ // ============================================================================
4
+ // EXCHANGE CONSTANTS
5
+ // ============================================================================
6
+ export const POLYGON_EXCHANGES = [
7
+ 'NYSE',
8
+ 'NASDAQ',
9
+ 'CBOE',
10
+ // 'FINRA',
11
+ // 'LTSE',
12
+ // 'IEX',
13
+ // 'MIAX_PEARL',
14
+ // 'MEMBERS_EXCHANGE',
15
+ // 'OTC_EQUITY_SECURITY',
16
+ ];
17
+ // Sourced from the worker-safe identity leaf so a venue is added in one place.
18
+ export const PREDICTION_MARKET_EXCHANGES = [...PREDICTION_MARKET_EXCHANGE_NAMES];
19
+ export const PYTH_EXCHANGES = []; //['PYTH_NETWORK'] as const;
20
+ const FOREX_EXCHANGES = ['FX_OTC'];
21
+ const COMMODITY_EXCHANGES = ['CBOT', 'ICE', 'NYMEX', 'LBMA', 'PLATTS', 'COMEX', 'LME'];
22
+ // Index venues: Polygon's index series (SPX, NDX, VIX, DJI ...), quote series on the US session
23
+ // grid served as TICKER_AGG candles (OHLC from the index values, volume 0), like forex. The
24
+ // gateway holds them out of the directory today; the wrun pin policy names them unserved until
25
+ // it lists them (wrun-pin-venues.util), and this is the venue set that policy reads.
26
+ export const INDEX_VENUE_EXCHANGES = ['POLYGON_INDICES'];
27
+ export const TRADFI_EXCHANGES = [...PYTH_EXCHANGES, ...POLYGON_EXCHANGES];
28
+ export const DEX_EXCHANGES = [
29
+ 'UNISWAP_V2',
30
+ 'UNISWAP_V3',
31
+ 'UNISWAP_V4',
32
+ 'SUSHISWAP_V2',
33
+ 'SUSHISWAP_V3',
34
+ 'SHIBASWAP',
35
+ 'PANCAKESWAP_V2',
36
+ 'PANCAKESWAP_V3',
37
+ 'FRAXSWAP',
38
+ 'SOLIDLY',
39
+ 'SOLIDLY_V3',
40
+ ];
41
+ // ============================================================================
42
+ // COMPOSITE CONSTANTS
43
+ // ============================================================================
44
+ const INDEX_MODE_EXCHANGES = [
45
+ ...TRADFI_EXCHANGES,
46
+ ...DEX_EXCHANGES,
47
+ ...FOREX_EXCHANGES,
48
+ ...COMMODITY_EXCHANGES,
49
+ ...INDEX_VENUE_EXCHANGES,
50
+ ];
51
+ // Exchanges that don't support 1s interval (index mode + prediction + forex + commodity).
52
+ // Prediction venues poll a price rather than printing trades, so none of them can
53
+ // host a 1s bar — the list tracks the venue SET, not Polymarket alone.
54
+ const EXCHANGES_BLOCKED_ON_1S = [...INDEX_MODE_EXCHANGES, ...PREDICTION_MARKET_EXCHANGE_NAMES];
55
+ const PM_SIGNAL_CRYPTO_SYMBOLS = ['BTC', 'ETH', 'SOL', 'XRP'];
56
+ const PM_SIGNAL_TRADFI_SYMBOLS = [
57
+ 'TSLA',
58
+ 'AAPL',
59
+ 'GOOGL',
60
+ 'NVDA',
61
+ 'META',
62
+ 'AMZN',
63
+ 'NFLX',
64
+ 'MSFT',
65
+ 'COIN',
66
+ 'HOOD',
67
+ 'PLTR',
68
+ 'ABNB',
69
+ 'RKLB',
70
+ 'OPEN',
71
+ 'SPY',
72
+ 'QQQ',
73
+ 'EWY',
74
+ ];
75
+ const PM_SIGNAL_COMMODITY_SYMBOLS = ['WTI', 'NG', 'XAUUSD', 'XAGUSD'];
76
+ // Maps commodity chart symbols (slash-stripped, uppercased) to Polymarket slug token names
77
+ export const PM_SIGNAL_COMMODITY_TOKEN_MAP = {
78
+ WTIUSD: 'wti',
79
+ NGUSD: 'ng',
80
+ XAUUSD: 'xauusd',
81
+ XAGUSD: 'xagusd',
82
+ };
83
+ // Maps chart symbol prefix to Polymarket slug token name (crypto only)
84
+ export const PM_SIGNAL_TOKEN_MAP = {
85
+ BTC: 'bitcoin',
86
+ ETH: 'ethereum',
87
+ SOL: 'solana',
88
+ XRP: 'xrp',
89
+ };
90
+ // ============================================================================
91
+ // SETS
92
+ // ============================================================================
93
+ // Sets backing the predicates still defined in this file
94
+ // (`checkIsPredictionMarket`, `checkIsIndexMode`, `checkIsBlockedOn1s`).
95
+ // Single-kind classification (`checkIsTradFi` etc.) lives in
96
+ // `marketKind.util.ts:EXCHANGE_TO_KIND`.
97
+ const PREDICTION_MARKET_EXCHANGES_SET = new Set(PREDICTION_MARKET_EXCHANGES);
98
+ // Polygon equities are one venue under two enum names (id 92): `POLYGON`, and `US_STOCKS`, the name protobuf JSON
99
+ // emits (a chart written outside the app, a restored or collab workspace, can carry it), so both are index mode.
100
+ const POLYGON_ENUM_NAMES = ['POLYGON', 'US_STOCKS'];
101
+ const INDEX_MODE_EXCHANGES_SET = new Set([...INDEX_MODE_EXCHANGES, ...POLYGON_ENUM_NAMES]);
102
+ const INDEX_VENUE_EXCHANGES_SET = new Set(INDEX_VENUE_EXCHANGES);
103
+ const EXCHANGES_BLOCKED_ON_1S_SET = new Set([...EXCHANGES_BLOCKED_ON_1S, ...POLYGON_ENUM_NAMES]);
104
+ const PM_SIGNAL_CRYPTO_SET = new Set(PM_SIGNAL_CRYPTO_SYMBOLS);
105
+ const PM_SIGNAL_TRADFI_SET = new Set(PM_SIGNAL_TRADFI_SYMBOLS.map((s) => s.toUpperCase()));
106
+ const PM_SIGNAL_COMMODITY_SET = new Set(PM_SIGNAL_COMMODITY_SYMBOLS.map((s) => s.toUpperCase()));
107
+ // ============================================================================
108
+ // SINGLE-EXCHANGE CHECK FUNCTIONS
109
+ // ============================================================================
110
+ //
111
+ // Single-kind `checkIs*` predicates re-export from `./marketKind.util.ts`
112
+ // — that file owns the canonical `EXCHANGE_TO_KIND` table. New code should
113
+ // prefer `getMarketKind(ex) === 'X'` reads (or `getCapabilities(ex)` for
114
+ // feature flags). `checkIsPredictionMarket` (defined below) doesn't have a
115
+ // `MarketKind` 1:1 mapping and uses a local set.
116
+ function checkIsExchangeInSet(exchange, set) {
117
+ if (!exchange)
118
+ return false;
119
+ return set.has(exchange);
120
+ }
121
+ import { checkIsPolygon, checkIsPolymarket, checkIsEconomic, checkIsFred, checkIsForex, checkIsCommodity, checkIsFutures, checkIsForexOrCommodity, checkIsForexCommodityOrFutures, checkIsHip3, checkIsHip4, checkIsTradFi, checkIsDex, isCmeFuturesPolicyActive, } from './marketKind.util.js';
122
+ import { isCmeGoverned } from './cme-realtime.util.js';
123
+ import { isOpraGoverned } from '../v2/gate-plane.util.js';
124
+ export { checkIsPolygon, checkIsPolymarket, checkIsEconomic, checkIsFred, checkIsForex, checkIsCommodity, checkIsFutures, checkIsForexOrCommodity, checkIsForexCommodityOrFutures, checkIsHip3, checkIsHip4, checkIsTradFi, checkIsDex, };
125
+ /**
126
+ * Polymarket ∪ HIP-4, and a STRICT superset of `checkIsPolymarket` — matching
127
+ * its case-insensitivity, not just its membership. Every venue gate widened
128
+ * from `checkIsPolymarket` to this one relies on the superset relation holding:
129
+ * an exact-match version would drop a lowercase venue string out of the deny
130
+ * and back through the permissive tail, which is the exact bug class the
131
+ * widening exists to close.
132
+ *
133
+ * Kept as a set lookup rather than `checkIsPolymarket(x) || checkIsHip4(x)` so
134
+ * this module gains no runtime dependency on `marketKind.util` — 32 specs mock
135
+ * that module partially and would break on the import.
136
+ */
137
+ export function checkIsPredictionMarket(exchange) {
138
+ return !!exchange && PREDICTION_MARKET_EXCHANGES_SET.has(exchange.toUpperCase());
139
+ }
140
+ export function extractBaseTicker(symbol) {
141
+ return symbol.split('/')[0];
142
+ }
143
+ const PM_SIGNAL_USD_LIKE_QUOTES = new Set(['USD', 'USDT', 'USDC', 'USDE', 'BUSD', 'DAI']);
144
+ const PM_SIGNAL_PERP_SUFFIXES = ['-PERPETUAL', '_PERPETUAL', '-PERP', '_PERP', '-SWAP', '_SWAP'];
145
+ function stripPerpSuffix(upperSymbol) {
146
+ for (const suffix of PM_SIGNAL_PERP_SUFFIXES) {
147
+ if (upperSymbol.endsWith(suffix))
148
+ return upperSymbol.slice(0, -suffix.length);
149
+ }
150
+ return upperSymbol;
151
+ }
152
+ function isUsdLikeQuote(upperSymbol) {
153
+ const slashIdx = upperSymbol.indexOf('/');
154
+ if (slashIdx >= 0) {
155
+ return PM_SIGNAL_USD_LIKE_QUOTES.has(upperSymbol.slice(slashIdx + 1));
156
+ }
157
+ // "BTC-USD" (Hyperliquid/OKX) — dash-separated joined form.
158
+ const dashIdx = upperSymbol.lastIndexOf('-');
159
+ if (dashIdx >= 0) {
160
+ return PM_SIGNAL_USD_LIKE_QUOTES.has(upperSymbol.slice(dashIdx + 1));
161
+ }
162
+ // Fully joined form (e.g. "XAUUSD", "BTCUSDT"): check common trailing quote lengths.
163
+ return PM_SIGNAL_USD_LIKE_QUOTES.has(upperSymbol.slice(-3)) || PM_SIGNAL_USD_LIKE_QUOTES.has(upperSymbol.slice(-4));
164
+ }
165
+ /**
166
+ * Try the symbol against the TradFi ticker set, accounting for slash-form
167
+ * ("TSLA/USD"), bare ticker ("TSLA"), and joined-form quote suffixes
168
+ * ("TSLAUSDT" after `stripPerpSuffix` from "TSLAUSDT-PERP"). Returns the
169
+ * canonical TradFi ticker (uppercase) or null when no candidate matches.
170
+ *
171
+ * `upper` is expected to already be uppercased and have any perp suffix
172
+ * stripped — see callers in this file.
173
+ */
174
+ function matchTradFiTicker(upper, baseTicker) {
175
+ const candidates = new Set([upper, baseTicker]);
176
+ for (const quote of PM_SIGNAL_USD_LIKE_QUOTES) {
177
+ if (upper.endsWith(quote) && upper.length > quote.length) {
178
+ candidates.add(upper.slice(0, -quote.length));
179
+ }
180
+ }
181
+ for (const candidate of candidates) {
182
+ if (PM_SIGNAL_TRADFI_SET.has(candidate))
183
+ return candidate;
184
+ }
185
+ return null;
186
+ }
187
+ /**
188
+ * Try the symbol against the crypto signal set with EXACT candidates only:
189
+ * slash form ("BTC/USD"), dash form ("BTC-USD", Hyperliquid/OKX), joined-form
190
+ * quote suffixes ("BTCUSDT"), and the bare ticker. Substring matching
191
+ * misclassified tokens merely containing BTC/ETH/SOL/XRP (WBTC, ETHFI,
192
+ * SOLO, ...). Returns the canonical crypto ticker (uppercase) or null.
193
+ */
194
+ function matchCryptoTicker(upper, baseTicker) {
195
+ const candidates = new Set([upper, baseTicker]);
196
+ const dashIdx = upper.lastIndexOf('-');
197
+ if (dashIdx > 0) {
198
+ candidates.add(upper.slice(0, dashIdx));
199
+ }
200
+ for (const quote of PM_SIGNAL_USD_LIKE_QUOTES) {
201
+ if (upper.endsWith(quote) && upper.length > quote.length) {
202
+ candidates.add(upper.slice(0, -quote.length));
203
+ }
204
+ }
205
+ for (const candidate of candidates) {
206
+ if (PM_SIGNAL_CRYPTO_SET.has(candidate))
207
+ return candidate;
208
+ }
209
+ return null;
210
+ }
211
+ /**
212
+ * Resolve a chart symbol to its canonical crypto signal ticker (uppercase),
213
+ * or null if it doesn't map to one. Mirrors the normalization in
214
+ * `getPMSignalMarketType` so slug builders stay in sync with eligibility.
215
+ */
216
+ export function getPMSignalCryptoTicker(symbol, normalizedSymbol) {
217
+ if (!symbol)
218
+ return null;
219
+ const symbolHasQuote = symbol.includes('/') || symbol.includes('-');
220
+ const rawUpper = (!symbolHasQuote && normalizedSymbol ? normalizedSymbol.replace('-', '/') : symbol).toUpperCase();
221
+ const upper = stripPerpSuffix(rawUpper);
222
+ return matchCryptoTicker(upper, extractBaseTicker(upper));
223
+ }
224
+ /**
225
+ * Resolve a chart symbol to its canonical TradFi ticker (uppercase), or null
226
+ * if it doesn't map to one. Mirrors the normalization in
227
+ * `getPMSignalMarketType` so slug builders stay in sync with eligibility.
228
+ */
229
+ export function getPMSignalTradFiTicker(symbol, normalizedSymbol) {
230
+ if (!symbol)
231
+ return null;
232
+ const symbolHasQuote = symbol.includes('/') || symbol.includes('-');
233
+ const rawUpper = (!symbolHasQuote && normalizedSymbol ? normalizedSymbol.replace('-', '/') : symbol).toUpperCase();
234
+ const upper = stripPerpSuffix(rawUpper);
235
+ return matchTradFiTicker(upper, extractBaseTicker(upper));
236
+ }
237
+ export function getPMSignalMarketType(symbol, exchange, normalizedSymbol) {
238
+ if (!symbol)
239
+ return null;
240
+ // Only use normalizedSymbol when `symbol` has no quote (Hyperliquid raw coin).
241
+ // Otherwise a stale normalizedSymbol (sync-update race on symbol switch) can
242
+ // misclassify e.g. SPY/USD as crypto via leftover "BTC-USD".
243
+ const symbolHasQuote = symbol.includes('/') || symbol.includes('-');
244
+ const rawUpper = (!symbolHasQuote && normalizedSymbol ? normalizedSymbol.replace('-', '/') : symbol).toUpperCase();
245
+ // Perps track the spot index for the signal's purposes — classify as spot.
246
+ const upper = stripPerpSuffix(rawUpper);
247
+ // All branches require a USD-like quote — Polymarket only has USD-denominated
248
+ // signal markets, so non-USD pairs (BTC/JPY, BTC/KRW, …) must not show the pill.
249
+ if (!isUsdLikeQuote(upper))
250
+ return null;
251
+ // TradFi symbols use "TICKER/USD" format — extract the base ticker for Set lookup
252
+ const baseTicker = extractBaseTicker(upper);
253
+ // Crypto: exact base-ticker match against BTC/ETH/SOL/XRP across all symbol
254
+ // forms (no exchange check, preserves existing behavior)
255
+ if (matchCryptoTicker(upper, baseTicker))
256
+ return 'crypto';
257
+ // TradFi: try slash-form ("TSLA/USD" → "TSLA") and joined-perp form
258
+ // ("TSLAUSDT-PERP" → after stripPerpSuffix "TSLAUSDT" → "TSLA") against the
259
+ // TradFi ticker set. The exchange gate is intentionally permissive — a TSLA
260
+ // perp on Bybit/HIP3 tracks the same underlying as TSLA on Polygon, so it
261
+ // gets the same signals. Polymarket exchanges are filtered out by callers.
262
+ if (matchTradFiTicker(upper, baseTicker))
263
+ return 'tradfi';
264
+ // Commodity: symbols may be "XAU/USD" (slash-separated) or "XAUUSD" (joined)
265
+ // Try both the base ticker ("XAU") and the slash-stripped full symbol ("XAUUSD")
266
+ const joinedSymbol = upper.replace('/', '');
267
+ if (checkIsCommodity(exchange) &&
268
+ (PM_SIGNAL_COMMODITY_SET.has(baseTicker) || PM_SIGNAL_COMMODITY_SET.has(joinedSymbol)))
269
+ return 'commodity';
270
+ return null;
271
+ }
272
+ export function checkIsPMSignalMarket(symbol, exchange, normalizedSymbol) {
273
+ return getPMSignalMarketType(symbol, exchange, normalizedSymbol) !== null;
274
+ }
275
+ /** Exchange-less eligibility check on a `normalizeSymbolForCache` output. */
276
+ export function checkIsEligiblePMSignalTicker(normalizedTicker) {
277
+ if (!normalizedTicker)
278
+ return false;
279
+ const upper = normalizedTicker.toUpperCase();
280
+ if (PM_SIGNAL_CRYPTO_SYMBOLS.includes(upper))
281
+ return true;
282
+ if (PM_SIGNAL_TRADFI_SET.has(upper))
283
+ return true;
284
+ if (PM_SIGNAL_COMMODITY_SET.has(upper))
285
+ return true;
286
+ return false;
287
+ }
288
+ // ============================================================================
289
+ // COMPOSITE CHECK FUNCTIONS
290
+ // ============================================================================
291
+ /**
292
+ * True for markets with irregular bar timestamps + count-based fetch
293
+ * (tradfi, forex, commodity, dex). New code should consult the
294
+ * capability registry — `getCapabilities(ex).barTimestamps === 'irregular'`
295
+ * for viewport-coord decisions and `=== 'count'` for fetch shape.
296
+ *
297
+ * CME-governed exchanges under the futures policy ride the V2 period-fetch
298
+ * pipeline (TRADE data, 1s available), so the set-backed predicates here
299
+ * carve them out explicitly (the sets predate the governed codes and cannot
300
+ * ride the flag-dependent kind); this is the other half of eliminating the
301
+ * CBOT/NYMEX/COMEX-vs-CME behavioral split (see marketKind.util.ts).
302
+ */
303
+ export function checkIsIndexMode(exchange) {
304
+ if (isCmeFuturesPolicyActive(exchange))
305
+ return false;
306
+ // Flag-off governed venues fail CLOSED to commodity semantics (the bare
307
+ // 'CME' code predates the historical commodity sets; without this a
308
+ // rollback re-inverted it to crypto fetch shapes).
309
+ if (isCmeGoverned(exchange))
310
+ return true;
311
+ return checkIsExchangeInSet(exchange, INDEX_MODE_EXCHANGES_SET);
312
+ }
313
+ /** An index venue (`INDEX_VENUE_EXCHANGES`): a quote series on the US session grid. */
314
+ export function checkIsIndexVenue(exchange) {
315
+ return checkIsExchangeInSet(exchange, INDEX_VENUE_EXCHANGES_SET);
316
+ }
317
+ /**
318
+ * Exchanges that use TICKER/TICKER_AGG data type instead of TRADE (forex,
319
+ * commodity, the index venues). Governed CME needs no carve-out here: the
320
+ * flag-dependent kind already classifies it futures (TRADE data) with the
321
+ * release gate on and commodity (TICKER, fail-closed) with it off; both
322
+ * states are pinned by cme-futures-capability.spec.ts.
323
+ */
324
+ export function checkIsTickerDataType(exchange) {
325
+ return checkIsForex(exchange) || checkIsCommodity(exchange) || checkIsIndexVenue(exchange);
326
+ }
327
+ export function checkIsBlockedOn1s(exchange) {
328
+ if (isCmeFuturesPolicyActive(exchange))
329
+ return false;
330
+ if (isCmeGoverned(exchange))
331
+ return true;
332
+ // US options (OPRA): the gate serves minute bars and coarser, so no
333
+ // sub-minute rung (1s 5s 15s 30s) is ever servable on a contract.
334
+ if (isOpraGoverned(exchange))
335
+ return true;
336
+ return checkIsExchangeInSet(exchange, EXCHANGES_BLOCKED_ON_1S_SET);
337
+ }
338
+ export function getMarketType(exchange) {
339
+ const actual = formatDisplayToExchange(exchange);
340
+ // US equity and index options (OPRA contracts): their own bucket, never
341
+ // the crypto default a missing row would read as.
342
+ if (isOpraGoverned(actual))
343
+ return 'options';
344
+ if (checkIsPolygon(actual))
345
+ return 'equities';
346
+ if (checkIsForex(actual))
347
+ return 'forex';
348
+ // Kyle-approved flip (2026-07-28): governed venues file as 'futures' while
349
+ // the release gate is on. Downstream category resolvers place that bucket
350
+ // with the crypto asset bucket, exactly where non-governed FUTURE
351
+ // instruments already live (surfaced by the cme intent tab and the Futures
352
+ // instrument filter). Gate off they fail closed to 'commodities'.
353
+ if (checkIsFutures(actual))
354
+ return 'futures';
355
+ if (checkIsCommodity(actual))
356
+ return 'commodities';
357
+ if (checkIsHip3(actual))
358
+ return 'hip-3';
359
+ return 'crypto';
360
+ }