@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,451 @@
1
+ /**
2
+ * kScript snippet helpers shared by every built-in template: the classic input set (source,
3
+ * timeframe, waitForClose), the candle and price series they read, the colour slot reader and the
4
+ * oscillator level / smoothing blocks. `technicalIndicatorScripts.constants.ts` (the classic
5
+ * built-ins) and `staples/*.constants.ts` (the TradingView staples) assemble their templates from
6
+ * these, so every built-in reads its inputs, candles and levels the same way. This module is
7
+ * i18n-free on purpose: the staple modules import it while the catalog module imports them, and a
8
+ * template module must never import the catalog.
9
+ */
10
+ /** Extra closed bars the oscillator smoothing (OSCILLATOR_SMOOTHING_INPUTS) adds to its oscillator's warm-up. */
11
+ export function oscillatorSmoothingWarmup(inputs) {
12
+ return inputs.str('smoothingType') === 'None' ? 0 : inputs.num('smoothingLength') - 1;
13
+ }
14
+ export const CLASSIC_TIMEFRAME_INPUTS = `var timeframe = input(name="timeframe", type="select", defaultValue="chart", options=["chart", "5m", "15m", "30m", "1h", "4h", "1D", "1W"]);
15
+ var waitForClose = input(name="waitForClose", type="boolean", defaultValue=true);`;
16
+ export const CLASSIC_PRICE_INPUTS = `var source = input(name="source", type="select", defaultValue="close", options=["close", "open", "high", "low"]);
17
+ ${CLASSIC_TIMEFRAME_INPUTS}`;
18
+ // field() auto-indexes a timeseries variable in 3.0.87. Passing the deduplicated
19
+ // source call directly retains its series value for the dynamic field selector.
20
+ export const CLASSIC_PRICE_SERIES = `timeseries data = ohlcv(symbol=currentSymbol, exchange=currentExchange);
21
+ timeseries price = timeframe == "chart" ? field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source) : htf(field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source), timeframe, {mode: waitForClose ? "confirmed" : "developing"});`;
22
+ // A conditional timeseries initializer stores one scalar unless given a row.
23
+ // Retain all candle fields and bypass HTF validation entirely in chart mode.
24
+ // Chart mode builds the row from the declared source's own fields: re-calling
25
+ // ohlcv() inside the initializer repeats a source lookup on every bar (quadratic,
26
+ // about 20 s at 10k bars) and candleValues(chartData) reads shifted rows.
27
+ export const CLASSIC_CANDLE_ROW = `func candleValues(bars) {
28
+ return [bars.open, bars.high, bars.low, bars.close, bars.volume];
29
+ }`;
30
+ export const CLASSIC_CANDLE_SERIES = `${CLASSIC_CANDLE_ROW}
31
+ timeseries chartData = ohlcv(symbol=currentSymbol, exchange=currentExchange);
32
+ timeseries data = timeframe == "chart" ? [chartData.open, chartData.high, chartData.low, chartData.close, chartData.volume] : candleValues(htf(chartData, timeframe, {mode: waitForClose ? "confirmed" : "developing"}));`;
33
+ // OHLCV-only builtins retain high/low/volume and use the selected price as close.
34
+ // The default close selection therefore preserves their existing formulas.
35
+ export const CLASSIC_SELECTED_CANDLES = `${CLASSIC_PRICE_SERIES}
36
+ ${CLASSIC_CANDLE_ROW}
37
+ timeseries candles = timeframe == "chart" ? [data.open, data.high, data.low, data.close, data.volume] : candleValues(htf(data, timeframe, {mode: waitForClose ? "confirmed" : "developing"}));
38
+ timeseries selectedCandles = [candles.open, candles.high, candles.low, price, candles.volume];`;
39
+ /**
40
+ * Reads slot `index` of a script's `colors` input as saved, alpha included. The chart completes
41
+ * every saved palette to the built-in's full slot list before a run (completeBuiltinPalette in
42
+ * builtin-script-theme-palette.util), so the first-slot fallback only covers a caller that hands a
43
+ * shorter one. Both branches read the input, so they share its colour type, which plot colour
44
+ * arrays require (a string-literal fallback needed an opacity() wrap, and opacity() forced full
45
+ * alpha and read most colour names as grey).
46
+ */
47
+ export function colorSlot(index) {
48
+ return `(colors.length > ${index} ? colors[${index}] : colors[0])`;
49
+ }
50
+ /** Level inputs shared by the bounded oscillators. */
51
+ export function oscillatorLevelInputs(overbought, oversold) {
52
+ return `var overbought = input(name="overbought", type="number", defaultValue=${overbought}, label="Overbought", group="Levels");
53
+ var oversold = input(name="oversold", type="number", defaultValue=${oversold}, label="Oversold", group="Levels");
54
+ var showZone = input(name="showZone", type="boolean", defaultValue=true, label="Zone", group="Levels");
55
+ var colorExtremes = input(name="colorExtremes", type="boolean", defaultValue=true, label="Color Extremes", group="Levels");`;
56
+ }
57
+ /** Colour slot of the oscillator line on a bar: 0 inside the levels, 1 overbought, 2 oversold. */
58
+ export function oscillatorExtremeIndex(value) {
59
+ return `colorExtremes ? (${value} > overbought ? 1 : ${value} < oversold ? 2 : 0) : 0`;
60
+ }
61
+ /**
62
+ * Dashed overbought / oversold levels, a dotted midline, and the zone between them shaded in the
63
+ * oscillator's own colour. The zone is a box drawn on the last bar from the first bar to well past
64
+ * the last one: drawings carry no alert output and no legend entry, and the last-bar box rolls back
65
+ * and redraws on live ticks.
66
+ */
67
+ export function oscillatorLevelsScript(zoneColor, midline) {
68
+ return `
69
+ // levels
70
+ var levelColor = opacity("#787B86", 70);
71
+ hline(value=overbought, color=levelColor, width=1, lineStyle="dashed");
72
+ hline(value=${midline}, color=levelColor, width=1, lineStyle="dotted");
73
+ hline(value=oversold, color=levelColor, width=1, lineStyle="dashed");
74
+ persist zoneStart = na;
75
+ if (isna(zoneStart)) {
76
+ zoneStart = data.time;
77
+ }
78
+ if (showZone && isLastBar && barIndex > 0) {
79
+ // The alpha rides in the fill colour: the chart's box renderer takes no separate fill opacity.
80
+ box.new(zoneStart, overbought, data.time[0] + 500 * (data.time[0] - data.time[1]), oversold, {fillColor: opacity(${zoneColor}, 6), borderWidth: 0});
81
+ }`;
82
+ }
83
+ export const OSCILLATOR_SMOOTHING_INPUTS = `var smoothingType = input(name="smoothingType", type="select", defaultValue="None", options=["None", "SMA", "SMA + Bollinger Bands", "EMA", "RMA", "WMA", "VWMA"], group="Smoothing");
84
+ var smoothingLength = input(name="smoothingLength", type="number", defaultValue=14, constraints={min: 1, step: 1}, group="Smoothing");
85
+ var bbStdDev = input(name="bbStdDev", type="number", defaultValue=2, constraints={min: 0, step: 0.1}, group="Smoothing");`;
86
+ export function oscillatorSmoothingScript(value, label, width, color) {
87
+ return `
88
+ // Retain oscillator history and the selected timeframe's volume for VWMA.
89
+ timeseries smoothingVolume = timeframe == "chart" ? data.volume : htf(data, timeframe, {mode: waitForClose ? "confirmed" : "developing"}).volume;
90
+ timeseries smoothingData = [${value}, ${value}, ${value}, ${value}, smoothingVolume];
91
+ if (smoothingType != "None") {
92
+ var smoothed = na;
93
+ if (smoothingType == "SMA" || smoothingType == "SMA + Bollinger Bands") {
94
+ smoothed = sma(source=smoothingData.close, period=smoothingLength);
95
+ } else if (smoothingType == "EMA") {
96
+ smoothed = ema(source=smoothingData.close, period=smoothingLength);
97
+ } else if (smoothingType == "RMA") {
98
+ smoothed = rma(source=smoothingData.close, period=smoothingLength);
99
+ } else if (smoothingType == "WMA") {
100
+ smoothed = wma(source=smoothingData.close, period=smoothingLength);
101
+ } else if (smoothingType == "VWMA") {
102
+ smoothed = vwma(source=smoothingData.close, period=smoothingLength);
103
+ }
104
+ plotLine(value=smoothed, width=${width}, colors=[${color}], smooth=smooth, label=["${label}"], desc=["${label}"]);
105
+ if (smoothingType == "SMA + Bollinger Bands") {
106
+ var deviation = bbStdDev * stdev(source=smoothingData.close, period=smoothingLength);
107
+ plotLine(value=smoothed + deviation, width=${width}, colors=[opacity(${color}, 45)], smooth=smooth, label=["Smoothing Upper Band"], desc=["Smoothing Upper Band"]);
108
+ plotLine(value=smoothed - deviation, width=${width}, colors=[opacity(${color}, 45)], smooth=smooth, label=["Smoothing Lower Band"], desc=["Smoothing Lower Band"]);
109
+ }
110
+ }`;
111
+ }
112
+ /*
113
+ * Selected-timeframe math (2026-10).
114
+ *
115
+ * `htf()` returns one row per CHART bar (each selected-timeframe value repeated), and every TA
116
+ * builtin windows over chart rows, so `sma(source=htf(...), period=9)` at 15m on a 1m chart
117
+ * averaged nine chart bars, mostly the same repeated 15m close. The blocks below keep a history of
118
+ * CLOSED selected-timeframe bars in persist state and run the math on it, plus the forming bar when
119
+ * waitForClose is off. Chart mode keeps the builtins untouched: a converted template behaves
120
+ * exactly as before on "chart". Everything the blocks declare starts with `htf`; `data`, `price`,
121
+ * `chartData` and `selectedCandles` keep their chart-mode meaning.
122
+ *
123
+ * A window indicator converts with one branch per output:
124
+ *
125
+ * ${CLASSIC_PRICE_INPUTS}
126
+ * ${HTF_PRICE_SERIES}
127
+ * ${htfHistory('htfPrices', 'htfClosedPrice', 'period')}
128
+ * var output = timeframe == "chart" ? sma(source=price, period=period) : htfAverage(${htfWindow('htfPrices', 'htfFormingPrice')}, period);
129
+ *
130
+ * A recursive one (EMA, RMA, Wilder) keeps its state with htfSmoothedState and reads the name:
131
+ *
132
+ * ${htfSmoothedState('htfEma', 'ema', 'htfClosedPrice', 'htfFormingPrice', 'period')}
133
+ * var output = timeframe == "chart" ? ema(source=price, period=period) : htfEma;
134
+ *
135
+ * Candle templates use HTF_CANDLE_SERIES and read htfClosedCandle.high[0] and friends (see the RSI
136
+ * and ATR templates in tests/constants/scriptEditor/htf-parity.spec.ts for a Wilder chain and a
137
+ * true range over closed candles). Per-bar work is linear: one push per closed bar, one pass over
138
+ * the window per read, and no htf() call outside init.
139
+ *
140
+ * Limits: htf() only sees loaded chart bars, so `period` closed selected-timeframe bars must sit
141
+ * inside the loaded history before a value appears (RSI(14) at 1h on a 1m chart needs 900+ bars).
142
+ * 1D / 1W use "the closed candle changed" as the boundary (their buckets follow the venue session on
143
+ * CME), so two identical consecutive daily candles would merge.
144
+ */
145
+ /**
146
+ * Window and step functions over a history array (oldest first). The window functions read the
147
+ * LAST `p` entries and return na unless all of them are finite, like the strict builtins (sma, wma,
148
+ * stdev, highest, lowest); htfSum skips na and accepts a short window, like sum(). The step
149
+ * functions mirror the engine's seeding (the plain average of the first `p` finite values) and its
150
+ * exact update arithmetic, so a converted template matches the builtin bit for bit.
151
+ */
152
+ export const HTF_WINDOW_FUNCS = `func htfAverage(values, p) {
153
+ if (values.length < p) {
154
+ return na;
155
+ }
156
+ var total = 0;
157
+ for (var k = values.length - p; k < values.length; k = k + 1) {
158
+ if (isna(values[k])) {
159
+ return na;
160
+ }
161
+ total = total + values[k];
162
+ }
163
+ return total / p;
164
+ }
165
+ func htfWeightedAverage(values, p) {
166
+ if (values.length < p) {
167
+ return na;
168
+ }
169
+ var total = 0;
170
+ var start = values.length - p;
171
+ for (var k = 0; k < p; k = k + 1) {
172
+ if (isna(values[start + k])) {
173
+ return na;
174
+ }
175
+ total = total + values[start + k] * (k + 1);
176
+ }
177
+ return total / (p * (p + 1) / 2);
178
+ }
179
+ func htfVolumeWeightedAverage(values, volumes, p) {
180
+ if (values.length < p || volumes.length < p) {
181
+ return na;
182
+ }
183
+ var numerator = 0;
184
+ var denominator = 0;
185
+ for (var k = 0; k < p; k = k + 1) {
186
+ var value = values[values.length - p + k];
187
+ var volume = volumes[volumes.length - p + k];
188
+ if (isna(value) || isna(volume)) {
189
+ return na;
190
+ }
191
+ numerator = numerator + value * volume;
192
+ denominator = denominator + volume;
193
+ }
194
+ return denominator == 0 ? na : numerator / denominator;
195
+ }
196
+ func htfStdev(values, p) {
197
+ var mean = htfAverage(values, p);
198
+ if (isna(mean)) {
199
+ return na;
200
+ }
201
+ var squares = 0;
202
+ for (var k = values.length - p; k < values.length; k = k + 1) {
203
+ var diff = values[k] - mean;
204
+ squares = squares + diff * diff;
205
+ }
206
+ return sqrt(squares / p);
207
+ }
208
+ func htfHighest(values, p) {
209
+ if (values.length < p) {
210
+ return na;
211
+ }
212
+ var best = na;
213
+ for (var k = values.length - p; k < values.length; k = k + 1) {
214
+ if (isna(values[k])) {
215
+ return na;
216
+ }
217
+ if (isna(best) || values[k] > best) {
218
+ best = values[k];
219
+ }
220
+ }
221
+ return best;
222
+ }
223
+ func htfLowest(values, p) {
224
+ if (values.length < p) {
225
+ return na;
226
+ }
227
+ var best = na;
228
+ for (var k = values.length - p; k < values.length; k = k + 1) {
229
+ if (isna(values[k])) {
230
+ return na;
231
+ }
232
+ if (isna(best) || values[k] < best) {
233
+ best = values[k];
234
+ }
235
+ }
236
+ return best;
237
+ }
238
+ func htfHighestOffset(values, p) {
239
+ if (values.length < p) {
240
+ return na;
241
+ }
242
+ var best = na;
243
+ var at = 0;
244
+ for (var k = values.length - p; k < values.length; k = k + 1) {
245
+ if (isna(values[k])) {
246
+ return na;
247
+ }
248
+ if (isna(best) || values[k] >= best) {
249
+ best = values[k];
250
+ at = k;
251
+ }
252
+ }
253
+ return at - (values.length - 1);
254
+ }
255
+ func htfLowestOffset(values, p) {
256
+ if (values.length < p) {
257
+ return na;
258
+ }
259
+ var best = na;
260
+ var at = 0;
261
+ for (var k = values.length - p; k < values.length; k = k + 1) {
262
+ if (isna(values[k])) {
263
+ return na;
264
+ }
265
+ if (isna(best) || values[k] <= best) {
266
+ best = values[k];
267
+ at = k;
268
+ }
269
+ }
270
+ return at - (values.length - 1);
271
+ }
272
+ func htfSum(values, p) {
273
+ var total = 0;
274
+ for (var k = max(0, values.length - p); k < values.length; k = k + 1) {
275
+ if (!isna(values[k])) {
276
+ total = total + values[k];
277
+ }
278
+ }
279
+ return total;
280
+ }
281
+ func htfValueBack(values, n) {
282
+ return values.length > n ? values[values.length - 1 - n] : na;
283
+ }
284
+ func htfEmaNext(previous, count, seedSum, value, p) {
285
+ if (isna(value) || count + 1 < p) {
286
+ return na;
287
+ }
288
+ if (count + 1 == p) {
289
+ return (seedSum + value) / p;
290
+ }
291
+ var alpha = 2 / (p + 1);
292
+ return value * alpha + previous * (1 - alpha);
293
+ }
294
+ func htfRmaNext(previous, count, seedSum, value, p) {
295
+ if (isna(value) || count + 1 < p) {
296
+ return na;
297
+ }
298
+ if (count + 1 == p) {
299
+ return (seedSum + value) / p;
300
+ }
301
+ return (previous * (p - 1) + value) / p;
302
+ }
303
+ func htfRsiOf(gain, loss) {
304
+ if (isna(gain) || isna(loss)) {
305
+ return na;
306
+ }
307
+ return loss == 0 ? 100 : 100 - 100 / (1 + gain / loss);
308
+ }`;
309
+ /**
310
+ * The selected timeframe's closed and forming candles, materialized ONCE at init (a direct htf()
311
+ * of the source runs in init; the "1Y" placeholder only keeps the calls valid in chart mode, which
312
+ * never reads them), and `htfClosed`: true on the chart bar right after a selected-timeframe bar
313
+ * closed. Rolling tokens compare the engine's own epoch-floor bucket of consecutive chart bars;
314
+ * calendar tokens (1D / 1W) fall back to "the closed candle changed". Requires the `timeframe`
315
+ * input (CLASSIC_TIMEFRAME_INPUTS).
316
+ */
317
+ export const HTF_SELECTED_TIMEFRAME = `${HTF_WINDOW_FUNCS}
318
+ timeseries htfBars = ohlcv(symbol=currentSymbol, exchange=currentExchange);
319
+ timeseries htfClosedCandle = htf(htfBars, timeframe == "chart" ? "1Y" : timeframe);
320
+ timeseries htfFormingCandle = htf(htfBars, timeframe == "chart" ? "1Y" : timeframe, {mode: "developing"});
321
+ var htfMs = timeframe == "1m" ? 60000 : timeframe == "3m" ? 180000 : timeframe == "5m" ? 300000 : timeframe == "15m" ? 900000 : timeframe == "30m" ? 1800000 : timeframe == "1h" ? 3600000 : timeframe == "2h" ? 7200000 : timeframe == "4h" ? 14400000 : timeframe == "6h" ? 21600000 : timeframe == "8h" ? 28800000 : timeframe == "12h" ? 43200000 : 0;
322
+ var htfBucketChanged = htfMs > 0 && barIndex > 0 && floor(htfBars.time[0] / htfMs) != floor(htfBars.time[1] / htfMs);
323
+ var htfCandleChanged = isna(htfClosedCandle.close[1]) || htfClosedCandle.close[0] != htfClosedCandle.close[1] || htfClosedCandle.open[0] != htfClosedCandle.open[1] || htfClosedCandle.high[0] != htfClosedCandle.high[1] || htfClosedCandle.low[0] != htfClosedCandle.low[1] || htfClosedCandle.volume[0] != htfClosedCandle.volume[1];
324
+ var htfClosed = timeframe != "chart" && !isna(htfClosedCandle.close[0]) && (htfMs > 0 ? htfBucketChanged : htfCandleChanged);`;
325
+ /**
326
+ * Candle templates: `data` is the chart's own candles in every mode (chart mode reads it exactly as
327
+ * CLASSIC_CANDLE_SERIES did), and the selected timeframe is read from htfClosedCandle /
328
+ * htfFormingCandle (`.high[0]`, `.volume[0]`, ...). Replaces CLASSIC_CANDLE_SERIES.
329
+ */
330
+ export const HTF_CANDLE_SERIES = `timeseries chartData = ohlcv(symbol=currentSymbol, exchange=currentExchange);
331
+ timeseries data = [chartData.open, chartData.high, chartData.low, chartData.close, chartData.volume];
332
+ ${HTF_SELECTED_TIMEFRAME}`;
333
+ /**
334
+ * Price templates: `data` and `price` as CLASSIC_PRICE_SERIES declares them in chart mode, plus
335
+ * the selected price read from the SELECTED candle (open / high / low / close of the closed and of
336
+ * the forming selected-timeframe bar). Requires CLASSIC_PRICE_INPUTS. Replaces CLASSIC_PRICE_SERIES.
337
+ */
338
+ export const HTF_PRICE_SERIES = `timeseries data = ohlcv(symbol=currentSymbol, exchange=currentExchange);
339
+ timeseries price = field(ohlcv(symbol=currentSymbol, exchange=currentExchange), source);
340
+ ${HTF_SELECTED_TIMEFRAME}
341
+ var htfClosedPrice = source == "open" ? htfClosedCandle.open[0] : source == "high" ? htfClosedCandle.high[0] : source == "low" ? htfClosedCandle.low[0] : htfClosedCandle.close[0];
342
+ var htfFormingPrice = source == "open" ? htfFormingCandle.open[0] : source == "high" ? htfFormingCandle.high[0] : source == "low" ? htfFormingCandle.low[0] : htfFormingCandle.close[0];`;
343
+ /**
344
+ * OHLCV templates that use the selected price as close: `selectedCandles` as CLASSIC_SELECTED_CANDLES
345
+ * declares it in chart mode; the selected timeframe reads htfClosedCandle / htfFormingCandle with
346
+ * htfClosedPrice / htfFormingPrice as the close. Replaces CLASSIC_SELECTED_CANDLES.
347
+ */
348
+ export const HTF_SELECTED_CANDLES = `${HTF_PRICE_SERIES}
349
+ timeseries selectedCandles = [data.open, data.high, data.low, price, data.volume];`;
350
+ /**
351
+ * A persist history of `closedValue`, appended once per closed selected-timeframe bar (na values
352
+ * are skipped, so a derived value's warm-up leaves no hole) and capped at `cap` entries, oldest
353
+ * first. `cap` is a kScript expression (`period`, `period + 1`, `slowPeriod`). An offset history
354
+ * passes `keepNa`: one entry per closed bar, na included, so `htfValueBack(history, offset)` counts
355
+ * selected-timeframe bars like `series[offset]` and an undefined value stays undefined instead of
356
+ * repeating the bar before it.
357
+ */
358
+ export function htfHistory(name, closedValue, cap, keepNa = false) {
359
+ return `persist ${name} = [];
360
+ if (htfClosed${keepNa ? '' : ` && !isna(${closedValue})`}) {
361
+ ${name}.push(${closedValue});
362
+ if (${name}.length > ${cap}) {
363
+ ${name}.shift();
364
+ }
365
+ }`;
366
+ }
367
+ /**
368
+ * The values a window reads: the closed history alone when waitForClose is on, the history plus
369
+ * `formingValue` (the forming selected-timeframe bar) when it is off.
370
+ */
371
+ export function htfWindow(history, formingValue) {
372
+ return `(waitForClose ? ${history} : ${history}.concat([${formingValue}]))`;
373
+ }
374
+ /**
375
+ * Recursive smoothing (EMA or RMA / Wilder) over closed selected-timeframe values. Declares the
376
+ * persist state (`<name>Closed`, `<name>Count`, `<name>Seed`), steps it once per closed bar with
377
+ * `closedValue`, and declares `var <name>`: the committed value when waitForClose is on, otherwise
378
+ * a provisional step with `formingValue` that is never committed. `closedValue` must be finite once
379
+ * it starts (leading na only), like the builtins' own seeding. Chain them by feeding one state's
380
+ * `<name>Closed` / `<name>` into the next (MACD's signal line, ATR from a true range).
381
+ */
382
+ export function htfSmoothedState(name, kind, closedValue, formingValue, period) {
383
+ const next = kind === 'ema' ? 'htfEmaNext' : 'htfRmaNext';
384
+ return `persist ${name}Closed = na;
385
+ persist ${name}Count = 0;
386
+ persist ${name}Seed = 0;
387
+ if (htfClosed && !isna(${closedValue})) {
388
+ ${name}Closed = ${next}(${name}Closed, ${name}Count, ${name}Seed, ${closedValue}, ${period});
389
+ ${name}Seed = ${name}Seed + ${closedValue};
390
+ ${name}Count = ${name}Count + 1;
391
+ }
392
+ var ${name} = waitForClose ? ${name}Closed : ${next}(${name}Closed, ${name}Count, ${name}Seed, ${formingValue}, ${period});`;
393
+ }
394
+ /**
395
+ * oscillatorSmoothingScript for a converted oscillator: chart mode smooths `value` with the
396
+ * builtins exactly as before; the selected timeframe smooths the oscillator's own closed values
397
+ * (`closedValue`, read on the bar a selected-timeframe bar closed) plus `formingValue` when
398
+ * waitForClose is off, weighted by the selected timeframe's volume for VWMA. Requires
399
+ * OSCILLATOR_SMOOTHING_INPUTS and one of the HTF_*_SERIES blocks.
400
+ */
401
+ export function htfOscillatorSmoothingScript(value, closedValue, formingValue, label, width, color) {
402
+ return `
403
+ // Retain oscillator history; the selected timeframe keeps its own closed values and volumes.
404
+ timeseries smoothingData = [${value}, ${value}, ${value}, ${value}, data.volume];
405
+ persist htfSmoothValues = [];
406
+ persist htfSmoothVolumes = [];
407
+ if (htfClosed && !isna(${closedValue})) {
408
+ htfSmoothValues.push(${closedValue});
409
+ htfSmoothVolumes.push(htfClosedCandle.volume[0]);
410
+ if (htfSmoothValues.length > smoothingLength) {
411
+ htfSmoothValues.shift();
412
+ htfSmoothVolumes.shift();
413
+ }
414
+ }
415
+ var htfSmoothWindow = ${htfWindow('htfSmoothValues', formingValue)};
416
+ var htfSmoothVolumeWindow = ${htfWindow('htfSmoothVolumes', 'htfFormingCandle.volume[0]')};
417
+ ${htfSmoothedState('htfSmoothEma', 'ema', closedValue, formingValue, 'smoothingLength')}
418
+ ${htfSmoothedState('htfSmoothRma', 'rma', closedValue, formingValue, 'smoothingLength')}
419
+ if (smoothingType != "None") {
420
+ var smoothed = na;
421
+ if (timeframe != "chart") {
422
+ if (smoothingType == "SMA" || smoothingType == "SMA + Bollinger Bands") {
423
+ smoothed = htfAverage(htfSmoothWindow, smoothingLength);
424
+ } else if (smoothingType == "EMA") {
425
+ smoothed = htfSmoothEma;
426
+ } else if (smoothingType == "RMA") {
427
+ smoothed = htfSmoothRma;
428
+ } else if (smoothingType == "WMA") {
429
+ smoothed = htfWeightedAverage(htfSmoothWindow, smoothingLength);
430
+ } else if (smoothingType == "VWMA") {
431
+ smoothed = htfVolumeWeightedAverage(htfSmoothWindow, htfSmoothVolumeWindow, smoothingLength);
432
+ }
433
+ } else if (smoothingType == "SMA" || smoothingType == "SMA + Bollinger Bands") {
434
+ smoothed = sma(source=smoothingData.close, period=smoothingLength);
435
+ } else if (smoothingType == "EMA") {
436
+ smoothed = ema(source=smoothingData.close, period=smoothingLength);
437
+ } else if (smoothingType == "RMA") {
438
+ smoothed = rma(source=smoothingData.close, period=smoothingLength);
439
+ } else if (smoothingType == "WMA") {
440
+ smoothed = wma(source=smoothingData.close, period=smoothingLength);
441
+ } else if (smoothingType == "VWMA") {
442
+ smoothed = vwma(source=smoothingData.close, period=smoothingLength);
443
+ }
444
+ plotLine(value=smoothed, width=${width}, colors=[${color}], smooth=smooth, label=["${label}"], desc=["${label}"]);
445
+ if (smoothingType == "SMA + Bollinger Bands") {
446
+ var deviation = bbStdDev * (timeframe == "chart" ? stdev(source=smoothingData.close, period=smoothingLength) : htfStdev(htfSmoothWindow, smoothingLength));
447
+ plotLine(value=smoothed + deviation, width=${width}, colors=[opacity(${color}, 45)], smooth=smooth, label=["Smoothing Upper Band"], desc=["Smoothing Upper Band"]);
448
+ plotLine(value=smoothed - deviation, width=${width}, colors=[opacity(${color}, 45)], smooth=smooth, label=["Smoothing Lower Band"], desc=["Smoothing Lower Band"]);
449
+ }
450
+ }`;
451
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The two catalog venue groups behind the Spot and Perps presets of the multi-venue indicators, each venue with
3
+ * the quote its catalog pair is synthesized from. ONE source of truth for both readers: the predefined catalog
4
+ * (`store/common.ts` fetchPredefinedSymbolsByCoinAndType) builds its pairs from these maps, and the venue-choice
5
+ * resolver (`venue-legs.util` presetVenues) names their venues, in this order.
6
+ */
7
+ export declare const SPOT_PRESET_VENUE_QUOTES: Readonly<Record<string, string>>;
8
+ export declare const PERP_PRESET_VENUE_QUOTES: Readonly<Record<string, string>>;
9
+ /** The catalog venue groups by preset. */
10
+ export declare const PRESET_VENUE_QUOTES: Readonly<Record<'SPOT' | 'PERP', Readonly<Record<string, string>>>>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The two catalog venue groups behind the Spot and Perps presets of the multi-venue indicators, each venue with
3
+ * the quote its catalog pair is synthesized from. ONE source of truth for both readers: the predefined catalog
4
+ * (`store/common.ts` fetchPredefinedSymbolsByCoinAndType) builds its pairs from these maps, and the venue-choice
5
+ * resolver (`venue-legs.util` presetVenues) names their venues, in this order.
6
+ */
7
+ export const SPOT_PRESET_VENUE_QUOTES = Object.freeze({
8
+ BINANCE: 'USDT',
9
+ COINBASE: '-USD',
10
+ BYBIT_SPOT: 'USDT',
11
+ OKEX: '-USDT',
12
+ BITSTAMP: 'USD',
13
+ });
14
+ export const PERP_PRESET_VENUE_QUOTES = Object.freeze({
15
+ BINANCE_FUTURES: 'USDT',
16
+ BYBIT: 'USDT',
17
+ });
18
+ /** The catalog venue groups by preset. */
19
+ export const PRESET_VENUE_QUOTES = Object.freeze({
20
+ SPOT: SPOT_PRESET_VENUE_QUOTES,
21
+ PERP: PERP_PRESET_VENUE_QUOTES,
22
+ });
@@ -0,0 +1,68 @@
1
+ export declare enum EInterval {
2
+ ONE_SECOND = "1s",
3
+ ONE_MINUTE = "1m",
4
+ FIVE_MINUTES = "5m",
5
+ FIFTEEN_MINUTES = "15m",
6
+ THIRTY_MINUTES = "30m",
7
+ ONE_HOUR = "1h",
8
+ FOUR_HOURS = "4h",
9
+ ONE_DAY = "1d",
10
+ ONE_WEEK = "1w",
11
+ ONE_MONTH = "1M",
12
+ THREE_MONTHS = "3M",
13
+ ONE_YEAR = "1Y"
14
+ }
15
+ export declare enum EChartType {
16
+ OHLCV = "TRADE_AGG",
17
+ TICKER = "TICKER_AGG",
18
+ SWAP = "SWAP",
19
+ OI = "OPEN_INTEREST_AGG",
20
+ FUNDING = "FUNDING_RATE_AGG",
21
+ LIQ = "LIQUIDATION_AGG",
22
+ PREDICTED_FUNDING = "PREDICTED_FUNDING_AGG",
23
+ LONG_SHORT_RATIO = "LONG_SHORT_RATIO_AGG",
24
+ LONG_SHORT_RATIO_POSITION = "LONG_SHORT_RATIO_POSITION",
25
+ VOLUME_RATIO = "VOLUME_RATIO",
26
+ SPOT_MARGIN_SIZE = "SPOT_MARGIN_SIZE",
27
+ SPOT_MARGIN_RATE = "SPOT_MARGIN_RATE",
28
+ SPOT_MARGIN_RATE_AGG = "SPOT_MARGIN_RATE_AGG",
29
+ BINANCE_SPOT_MARGIN_RATE_AGG = "BINANCE_SPOT_MARGIN_RATE_AGG",
30
+ CORRELATION_BETA = "CORRELATION_BETA",
31
+ DELTA_FUNDING_OI = "DELTA_FUNDING_OI",
32
+ DEFI_OPTIONS_VAULT = "DEFI_OPTIONS_VAULT",
33
+ DEFI_OPTIONS_VAULT_AGG = "DEFI_OPTIONS_VAULT_AGG",
34
+ DEFI_OPTIONS_VAULT_OPEN_INTEREST = "DEFI_OPTIONS_VAULT_OPEN_INTEREST",
35
+ DEFI_OPTIONS_VAULT_OPEN_INTEREST_AGG = "DEFI_OPTIONS_VAULT_OPEN_INTEREST_AGG",
36
+ BUY_SELL_VOLUME_RATIO = "BUY_SELL_VOLUME_RATIO",
37
+ AGGREGATED_DAILY_VOLUME = "AGGREGATED_DAILY_VOLUME",
38
+ AGGREGATED_DAILY_VOLUME_AGG = "AGGREGATED_DAILY_VOLUME_AGG",
39
+ AGGREGATED_OPEN_INTEREST = "AGGREGATED_OPEN_INTEREST",
40
+ AGGREGATED_OPEN_INTEREST_AGG = "AGGREGATED_OPEN_INTEREST_AGG",
41
+ MARKETCAP = "MARKETCAP",
42
+ MARKETCAP_AGG = "MARKETCAP_AGG",
43
+ TURNOVER_RATIO = "TURNOVER_RATIO",
44
+ DOV_STRIKE_PRICE_GRADIENT = "DOV_STRIKE_PRICE_GRADIENT",
45
+ GROUPED_TRADE_VOLUME_AGG = "GROUPED_TRADE_VOLUME_AGG",
46
+ GROUPED_OPEN_INTEREST_AGG = "GROUPED_OPEN_INTEREST_AGG",
47
+ OPTIONS_HEATMAP = "OPTIONS_HEATMAP",
48
+ OPTIONS_GEX = "OPTIONS_GEX",
49
+ OPTIONS_FLOW = "OPTIONS_FLOW",
50
+ OPTIONS_DASHBOARD = "OPTIONS_DASHBOARD",
51
+ OPTIONS_GEX_CURVE = "OPTIONS_GEX_CURVE",
52
+ OPTIONS_IV_SMILE = "OPTIONS_IV_SMILE",
53
+ OPTIONS_TERM_STRUCTURE = "OPTIONS_TERM_STRUCTURE",
54
+ OPTIONS_SURFACE = "OPTIONS_SURFACE",
55
+ OPTIONS_IMPLIED_MOVE = "OPTIONS_IMPLIED_MOVE",
56
+ OPTIONS_VOL_MATRIX = "OPTIONS_VOL_MATRIX",
57
+ OPTIONS_FLOW_EXPIRY = "OPTIONS_FLOW_EXPIRY",
58
+ OPTIONS_FLOW_PULSE = "OPTIONS_FLOW_PULSE",
59
+ ORDERBOOK_HEATMAP = "ORDERBOOK_HEATMAP",
60
+ AGGREGATED_ORDERBOOK_HEATMAP = "AGGREGATED_ORDERBOOK_HEATMAP",
61
+ OPTION_OPEN_INTEREST_AGG = "OPTION_OPEN_INTEREST_AGG",
62
+ TWAP_RATE = "TWAP_RATE",
63
+ TWAP_RATE_AGG = "TWAP_RATE_AGG",
64
+ TWAP_RATE_DASHBOARD = "TWAP_RATE_DASHBOARD",
65
+ OPTION_SUMMARY = "OPTION_SUMMARY",
66
+ ORDERBOOK = "BLOCK_BOOK_SNAPSHOT",
67
+ FRED_OBSERVATION = "FRED_OBSERVATION"
68
+ }
@@ -0,0 +1,70 @@
1
+ export var EInterval;
2
+ (function (EInterval) {
3
+ EInterval["ONE_SECOND"] = "1s";
4
+ EInterval["ONE_MINUTE"] = "1m";
5
+ EInterval["FIVE_MINUTES"] = "5m";
6
+ EInterval["FIFTEEN_MINUTES"] = "15m";
7
+ EInterval["THIRTY_MINUTES"] = "30m";
8
+ EInterval["ONE_HOUR"] = "1h";
9
+ EInterval["FOUR_HOURS"] = "4h";
10
+ EInterval["ONE_DAY"] = "1d";
11
+ EInterval["ONE_WEEK"] = "1w";
12
+ EInterval["ONE_MONTH"] = "1M";
13
+ EInterval["THREE_MONTHS"] = "3M";
14
+ EInterval["ONE_YEAR"] = "1Y";
15
+ })(EInterval || (EInterval = {}));
16
+ export var EChartType;
17
+ (function (EChartType) {
18
+ EChartType["OHLCV"] = "TRADE_AGG";
19
+ EChartType["TICKER"] = "TICKER_AGG";
20
+ EChartType["SWAP"] = "SWAP";
21
+ EChartType["OI"] = "OPEN_INTEREST_AGG";
22
+ EChartType["FUNDING"] = "FUNDING_RATE_AGG";
23
+ EChartType["LIQ"] = "LIQUIDATION_AGG";
24
+ EChartType["PREDICTED_FUNDING"] = "PREDICTED_FUNDING_AGG";
25
+ EChartType["LONG_SHORT_RATIO"] = "LONG_SHORT_RATIO_AGG";
26
+ EChartType["LONG_SHORT_RATIO_POSITION"] = "LONG_SHORT_RATIO_POSITION";
27
+ EChartType["VOLUME_RATIO"] = "VOLUME_RATIO";
28
+ EChartType["SPOT_MARGIN_SIZE"] = "SPOT_MARGIN_SIZE";
29
+ EChartType["SPOT_MARGIN_RATE"] = "SPOT_MARGIN_RATE";
30
+ EChartType["SPOT_MARGIN_RATE_AGG"] = "SPOT_MARGIN_RATE_AGG";
31
+ EChartType["BINANCE_SPOT_MARGIN_RATE_AGG"] = "BINANCE_SPOT_MARGIN_RATE_AGG";
32
+ EChartType["CORRELATION_BETA"] = "CORRELATION_BETA";
33
+ EChartType["DELTA_FUNDING_OI"] = "DELTA_FUNDING_OI";
34
+ EChartType["DEFI_OPTIONS_VAULT"] = "DEFI_OPTIONS_VAULT";
35
+ EChartType["DEFI_OPTIONS_VAULT_AGG"] = "DEFI_OPTIONS_VAULT_AGG";
36
+ EChartType["DEFI_OPTIONS_VAULT_OPEN_INTEREST"] = "DEFI_OPTIONS_VAULT_OPEN_INTEREST";
37
+ EChartType["DEFI_OPTIONS_VAULT_OPEN_INTEREST_AGG"] = "DEFI_OPTIONS_VAULT_OPEN_INTEREST_AGG";
38
+ EChartType["BUY_SELL_VOLUME_RATIO"] = "BUY_SELL_VOLUME_RATIO";
39
+ EChartType["AGGREGATED_DAILY_VOLUME"] = "AGGREGATED_DAILY_VOLUME";
40
+ EChartType["AGGREGATED_DAILY_VOLUME_AGG"] = "AGGREGATED_DAILY_VOLUME_AGG";
41
+ EChartType["AGGREGATED_OPEN_INTEREST"] = "AGGREGATED_OPEN_INTEREST";
42
+ EChartType["AGGREGATED_OPEN_INTEREST_AGG"] = "AGGREGATED_OPEN_INTEREST_AGG";
43
+ EChartType["MARKETCAP"] = "MARKETCAP";
44
+ EChartType["MARKETCAP_AGG"] = "MARKETCAP_AGG";
45
+ EChartType["TURNOVER_RATIO"] = "TURNOVER_RATIO";
46
+ EChartType["DOV_STRIKE_PRICE_GRADIENT"] = "DOV_STRIKE_PRICE_GRADIENT";
47
+ EChartType["GROUPED_TRADE_VOLUME_AGG"] = "GROUPED_TRADE_VOLUME_AGG";
48
+ EChartType["GROUPED_OPEN_INTEREST_AGG"] = "GROUPED_OPEN_INTEREST_AGG";
49
+ EChartType["OPTIONS_HEATMAP"] = "OPTIONS_HEATMAP";
50
+ EChartType["OPTIONS_GEX"] = "OPTIONS_GEX";
51
+ EChartType["OPTIONS_FLOW"] = "OPTIONS_FLOW";
52
+ EChartType["OPTIONS_DASHBOARD"] = "OPTIONS_DASHBOARD";
53
+ EChartType["OPTIONS_GEX_CURVE"] = "OPTIONS_GEX_CURVE";
54
+ EChartType["OPTIONS_IV_SMILE"] = "OPTIONS_IV_SMILE";
55
+ EChartType["OPTIONS_TERM_STRUCTURE"] = "OPTIONS_TERM_STRUCTURE";
56
+ EChartType["OPTIONS_SURFACE"] = "OPTIONS_SURFACE";
57
+ EChartType["OPTIONS_IMPLIED_MOVE"] = "OPTIONS_IMPLIED_MOVE";
58
+ EChartType["OPTIONS_VOL_MATRIX"] = "OPTIONS_VOL_MATRIX";
59
+ EChartType["OPTIONS_FLOW_EXPIRY"] = "OPTIONS_FLOW_EXPIRY";
60
+ EChartType["OPTIONS_FLOW_PULSE"] = "OPTIONS_FLOW_PULSE";
61
+ EChartType["ORDERBOOK_HEATMAP"] = "ORDERBOOK_HEATMAP";
62
+ EChartType["AGGREGATED_ORDERBOOK_HEATMAP"] = "AGGREGATED_ORDERBOOK_HEATMAP";
63
+ EChartType["OPTION_OPEN_INTEREST_AGG"] = "OPTION_OPEN_INTEREST_AGG";
64
+ EChartType["TWAP_RATE"] = "TWAP_RATE";
65
+ EChartType["TWAP_RATE_AGG"] = "TWAP_RATE_AGG";
66
+ EChartType["TWAP_RATE_DASHBOARD"] = "TWAP_RATE_DASHBOARD";
67
+ EChartType["OPTION_SUMMARY"] = "OPTION_SUMMARY";
68
+ EChartType["ORDERBOOK"] = "BLOCK_BOOK_SNAPSHOT";
69
+ EChartType["FRED_OBSERVATION"] = "FRED_OBSERVATION";
70
+ })(EChartType || (EChartType = {}));
@@ -0,0 +1,2 @@
1
+ export declare const divideValues: (first: number, second: number) => number;
2
+ export declare const getExchangeFromSymbol: (uiExchange: string, symbol: string, ovType?: string) => string;
@@ -0,0 +1,14 @@
1
+ import { NoExchangeOverlays } from '../constants/overlay-data.constants.js';
2
+ export const divideValues = (first, second) => !first || !second ? null : first / second;
3
+ // uiExchange is the exchange displayed in the UI for a symbol. BINANCE_FUTURES also displays BINANCE_DELIVERY symbols.
4
+ export const getExchangeFromSymbol = (uiExchange, symbol, ovType) => {
5
+ if (symbol && uiExchange === 'BINANCE_FUTURES' && symbol.includes('USD_'))
6
+ return 'BINANCE_DELIVERY';
7
+ if (ovType) {
8
+ if (ovType === 'AGGREGATED_DAILY_VOLUME')
9
+ return '*';
10
+ if (NoExchangeOverlays.includes(ovType))
11
+ return '*';
12
+ }
13
+ return uiExchange;
14
+ };