@orangecharts/wrun-chart-host 0.4.0 β†’ 0.6.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 (331) hide show
  1. package/README.md +17 -5
  2. package/dist/constants/exchange-names.leaf.d.ts +8 -0
  3. package/dist/constants/exchange-names.leaf.js +101 -0
  4. package/dist/constants/feature-flags.constants.js +7 -2
  5. package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +15 -0
  6. package/dist/constants/kscript-data-interval-restrictions.constants.js +40 -0
  7. package/dist/constants/opra-compliance.constants.d.ts +19 -0
  8. package/dist/constants/opra-compliance.constants.js +19 -0
  9. package/dist/constants/replay-ladder.leaf.d.ts +30 -0
  10. package/dist/constants/replay-ladder.leaf.js +99 -0
  11. package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +168 -0
  12. package/dist/constants/scriptEditor/cme-official-scripts.constants.js +398 -0
  13. package/dist/constants/scriptEditor/converted-script-id.leaf.d.ts +8 -0
  14. package/dist/constants/scriptEditor/converted-script-id.leaf.js +10 -0
  15. package/dist/constants/scriptEditor/execution.constants.d.ts +4 -0
  16. package/dist/constants/scriptEditor/execution.constants.js +14 -0
  17. package/dist/constants/wrun-prefix-safe.constants.d.ts +23 -0
  18. package/dist/constants/wrun-prefix-safe.constants.js +26 -0
  19. package/dist/host-env.d.ts +301 -22
  20. package/dist/host-env.js +15 -0
  21. package/dist/host-ports.types.d.ts +853 -29
  22. package/dist/index.d.ts +140 -2
  23. package/dist/index.js +140 -2
  24. package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +31 -0
  25. package/dist/instances/script-engine-worker-ohlcv-transfer.js +164 -0
  26. package/dist/interfaces/market-event.interface.d.ts +231 -0
  27. package/dist/interfaces/market-event.interface.js +15 -0
  28. package/dist/interfaces/opra-realtime.interface.d.ts +70 -134
  29. package/dist/interfaces/opra-realtime.interface.js +34 -59
  30. package/dist/interfaces/replay.interface.d.ts +285 -0
  31. package/dist/interfaces/replay.interface.js +1 -0
  32. package/dist/interfaces/wrun-runtime.interface.d.ts +88 -13
  33. package/dist/interfaces/wrun-runtime.interface.js +17 -3
  34. package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +1 -0
  35. package/dist/kscript-data/controls/live-ohlcv-merge.util.js +93 -0
  36. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +5 -1
  37. package/dist/kscript-data/controls/live-trades-merge.util.js +2 -2
  38. package/dist/market-data/billing.interface.d.ts +219 -0
  39. package/dist/market-data/billing.interface.js +58 -0
  40. package/dist/market-data/venue-governed.util.d.ts +2 -0
  41. package/dist/market-data/venue-governed.util.js +10 -0
  42. package/dist/market-data/venue.d.ts +122 -0
  43. package/dist/market-data/venue.js +1 -0
  44. package/dist/market-data/venues/index.d.ts +97 -0
  45. package/dist/market-data/venues/index.js +33 -0
  46. package/dist/market-data/venues/opra.contract.copy.json +35 -0
  47. package/dist/market-data/venues/opra.d.ts +70 -0
  48. package/dist/market-data/venues/opra.js +74 -0
  49. package/dist/replay/replayIndicatorRows.d.ts +31 -0
  50. package/dist/replay/replayIndicatorRows.js +117 -0
  51. package/dist/replay/replayLadder.d.ts +85 -0
  52. package/dist/replay/replayLadder.js +388 -0
  53. package/dist/utility/auth/server-clock.util.d.ts +81 -0
  54. package/dist/utility/auth/server-clock.util.js +238 -0
  55. package/dist/utility/chart/builtin-identity.util.d.ts +18 -0
  56. package/dist/utility/chart/builtin-identity.util.js +51 -0
  57. package/dist/utility/chart/cache-alignment.util.d.ts +454 -0
  58. package/dist/utility/chart/cache-alignment.util.js +926 -0
  59. package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +15 -0
  60. package/dist/utility/chart/chart-data-fetch-generation.util.js +22 -0
  61. package/dist/utility/chart/chart-mount-epoch.util.d.ts +17 -0
  62. package/dist/utility/chart/chart-mount-epoch.util.js +61 -0
  63. package/dist/utility/chart/chart-time-domain.util.d.ts +12 -0
  64. package/dist/utility/chart/chart-time-domain.util.js +23 -0
  65. package/dist/utility/chart/color-customization.leaf.d.ts +10 -0
  66. package/dist/utility/chart/color-customization.leaf.js +16 -0
  67. package/dist/utility/chart/footprint-tick-grid.util.d.ts +106 -0
  68. package/dist/utility/chart/footprint-tick-grid.util.js +167 -0
  69. package/dist/utility/chart/gesture-timing.leaf.d.ts +29 -0
  70. package/dist/utility/chart/gesture-timing.leaf.js +29 -0
  71. package/dist/utility/chart/governed-contract-coin.util.d.ts +22 -0
  72. package/dist/utility/chart/governed-contract-coin.util.js +39 -0
  73. package/dist/utility/chart/host-bar-placement.util.d.ts +107 -0
  74. package/dist/utility/chart/host-bar-placement.util.js +447 -0
  75. package/dist/utility/chart/index-host-tier.util.d.ts +31 -0
  76. package/dist/utility/chart/index-host-tier.util.js +118 -0
  77. package/dist/utility/chart/index-mode-admission.util.d.ts +34 -0
  78. package/dist/utility/chart/index-mode-admission.util.js +67 -0
  79. package/dist/utility/chart/indicator-error-message.util.d.ts +35 -0
  80. package/dist/utility/chart/indicator-error-message.util.js +44 -0
  81. package/dist/utility/chart/kscript-apply-fingerprint.util.d.ts +65 -0
  82. package/dist/utility/chart/kscript-apply-fingerprint.util.js +357 -0
  83. package/dist/utility/chart/kscript-chart-flush.leaf.d.ts +22 -0
  84. package/dist/utility/chart/kscript-chart-flush.leaf.js +13 -0
  85. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +6 -0
  86. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +27 -0
  87. package/dist/utility/chart/kscript-integration-decision.leaf.d.ts +89 -0
  88. package/dist/utility/chart/kscript-integration-decision.leaf.js +80 -0
  89. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +76 -0
  90. package/dist/utility/chart/kscript-live-coalesce.util.js +156 -0
  91. package/dist/utility/chart/kscript-live-rest-pace.util.d.ts +34 -0
  92. package/dist/utility/chart/kscript-live-rest-pace.util.js +134 -0
  93. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +98 -0
  94. package/dist/utility/chart/kscript-live-source-identity.util.js +121 -0
  95. package/dist/utility/chart/kscript-mounted-plot-set.leaf.d.ts +48 -0
  96. package/dist/utility/chart/kscript-mounted-plot-set.leaf.js +145 -0
  97. package/dist/utility/chart/kscript-perf-tracker.util.d.ts +243 -0
  98. package/dist/utility/chart/kscript-perf-tracker.util.js +522 -0
  99. package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +43 -0
  100. package/dist/utility/chart/kscript-run-interval-projection.util.js +471 -0
  101. package/dist/utility/chart/kscript-run-result-equality.util.d.ts +38 -0
  102. package/dist/utility/chart/kscript-run-result-equality.util.js +89 -0
  103. package/dist/utility/chart/kscript-settings-revision.leaf.d.ts +2 -0
  104. package/dist/utility/chart/kscript-settings-revision.leaf.js +12 -0
  105. package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +63 -0
  106. package/dist/utility/chart/kscript-source-degrade.leaf.js +68 -0
  107. package/dist/utility/chart/kscript-source-retention.util.d.ts +134 -0
  108. package/dist/utility/chart/kscript-source-retention.util.js +218 -0
  109. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +57 -0
  110. package/dist/utility/chart/kscript-standin-identity.leaf.js +61 -0
  111. package/dist/utility/chart/kscript-titancharts-preparation.util.d.ts +15 -0
  112. package/dist/utility/chart/kscript-titancharts-preparation.util.js +376 -0
  113. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +9 -0
  114. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +130 -0
  115. package/dist/utility/chart/kscript-venue-policy.util.d.ts +217 -0
  116. package/dist/utility/chart/kscript-venue-policy.util.js +324 -0
  117. package/dist/utility/chart/live-cadence.util.d.ts +38 -0
  118. package/dist/utility/chart/live-cadence.util.js +37 -0
  119. package/dist/utility/chart/live-feed-series-match.leaf.d.ts +13 -0
  120. package/dist/utility/chart/live-feed-series-match.leaf.js +21 -0
  121. package/dist/utility/chart/local-engine-self-heal-backoff.util.d.ts +46 -0
  122. package/dist/utility/chart/local-engine-self-heal-backoff.util.js +46 -0
  123. package/dist/utility/chart/local-engine-uninit.leaf.d.ts +21 -0
  124. package/dist/utility/chart/local-engine-uninit.leaf.js +22 -0
  125. package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +62 -0
  126. package/dist/utility/chart/local-kscript-source-revalidation.util.js +123 -0
  127. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +214 -0
  128. package/dist/utility/chart/local-kscript-warmup-depth.util.js +376 -0
  129. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.d.ts +85 -0
  130. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.js +197 -0
  131. package/dist/utility/chart/local-technical-script-range.leaf.d.ts +72 -0
  132. package/dist/utility/chart/local-technical-script-range.leaf.js +126 -0
  133. package/dist/utility/chart/mixed-mode.util.d.ts +167 -0
  134. package/dist/utility/chart/mixed-mode.util.js +139 -0
  135. package/dist/utility/chart/ohlcv-row-readiness.util.d.ts +36 -0
  136. package/dist/utility/chart/ohlcv-row-readiness.util.js +90 -0
  137. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +19 -0
  138. package/dist/utility/chart/opra-user-scripts-gate.util.js +32 -0
  139. package/dist/utility/chart/overlay-execution-guard-key.leaf.d.ts +8 -0
  140. package/dist/utility/chart/overlay-execution-guard-key.leaf.js +10 -0
  141. package/dist/utility/chart/price-precision.util.d.ts +40 -0
  142. package/dist/utility/chart/price-precision.util.js +70 -0
  143. package/dist/utility/chart/profile-block-size.util.d.ts +64 -0
  144. package/dist/utility/chart/profile-block-size.util.js +141 -0
  145. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.d.ts +11 -0
  146. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.js +29 -0
  147. package/dist/utility/chart/protected-kscript-empty-output.util.d.ts +28 -0
  148. package/dist/utility/chart/protected-kscript-empty-output.util.js +84 -0
  149. package/dist/utility/chart/run-interval-unservable.leaf.d.ts +9 -0
  150. package/dist/utility/chart/run-interval-unservable.leaf.js +20 -0
  151. package/dist/utility/chart/run-interval-warmup.leaf.d.ts +19 -0
  152. package/dist/utility/chart/run-interval-warmup.leaf.js +35 -0
  153. package/dist/utility/chart/titan-constants.pin.d.ts +9 -5
  154. package/dist/utility/chart/titan-constants.pin.js +18 -5
  155. package/dist/utility/chart/warmup-backfill-retry.leaf.d.ts +9 -0
  156. package/dist/utility/chart/warmup-backfill-retry.leaf.js +9 -0
  157. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +11 -2
  158. package/dist/utility/chart/wrun-bar-session-facts.util.js +10 -3
  159. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -1
  160. package/dist/utility/chart/wrun-run-result.util.js +20 -14
  161. package/dist/utility/common/data-processing.util.d.ts +138 -0
  162. package/dist/utility/common/data-processing.util.js +346 -0
  163. package/dist/utility/common/visible-timeout.util.d.ts +13 -4
  164. package/dist/utility/common/visible-timeout.util.js +23 -8
  165. package/dist/utility/exchange-format.leaf.d.ts +1 -0
  166. package/dist/utility/exchange-format.leaf.js +47 -0
  167. package/dist/utility/market-events/earnings-scope.util.d.ts +60 -0
  168. package/dist/utility/market-events/earnings-scope.util.js +92 -0
  169. package/dist/utility/market-events/market-events.util.d.ts +147 -0
  170. package/dist/utility/market-events/market-events.util.js +392 -0
  171. package/dist/utility/market-events/zoned-clock.util.d.ts +1 -0
  172. package/dist/utility/market-events/zoned-clock.util.js +11 -0
  173. package/dist/utility/options/option-venue-disclosure.util.d.ts +43 -0
  174. package/dist/utility/options/option-venue-disclosure.util.js +56 -0
  175. package/dist/utility/scriptEditor/package-semver.util.d.ts +51 -0
  176. package/dist/utility/scriptEditor/package-semver.util.js +120 -0
  177. package/dist/utility/scriptEditor/temp-script-id.util.d.ts +18 -0
  178. package/dist/utility/scriptEditor/temp-script-id.util.js +25 -0
  179. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.d.ts +20 -0
  180. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.js +81 -0
  181. package/dist/utility/v2/governed-tier.leaf.d.ts +103 -0
  182. package/dist/utility/v2/governed-tier.leaf.js +113 -0
  183. package/dist/utility/watchlist/import/import-request.leaf.d.ts +10 -0
  184. package/dist/utility/watchlist/import/import-request.leaf.js +10 -0
  185. package/dist/utility/wrun/sources/lanes/series.js +2 -2
  186. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +4 -4
  187. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +5 -6
  188. package/dist/utility/wrun/wrun-alert-outputs.registry.d.ts +166 -0
  189. package/dist/utility/wrun/wrun-alert-outputs.registry.js +219 -0
  190. package/dist/utility/wrun/wrun-bar-count.util.d.ts +94 -0
  191. package/dist/utility/wrun/wrun-bar-count.util.js +274 -0
  192. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +84 -0
  193. package/dist/utility/wrun/wrun-chart-context-names.util.js +186 -0
  194. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +253 -0
  195. package/dist/utility/wrun/wrun-chart-market-facts.util.js +731 -0
  196. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.d.ts +28 -0
  197. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.js +45 -0
  198. package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +18 -0
  199. package/dist/utility/wrun/wrun-coin-lane-live.util.js +47 -0
  200. package/dist/utility/wrun/wrun-deadline.util.js +2 -1
  201. package/dist/utility/wrun/wrun-debug-output.util.d.ts +39 -0
  202. package/dist/utility/wrun/wrun-debug-output.util.js +63 -0
  203. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +113 -0
  204. package/dist/utility/wrun/wrun-declared-warmup.util.js +181 -0
  205. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +43 -0
  206. package/dist/utility/wrun/wrun-draft-legend-note.util.js +158 -0
  207. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +181 -0
  208. package/dist/utility/wrun/wrun-draft-overlay.util.js +357 -0
  209. package/dist/utility/wrun/wrun-draw-skipped.leaf.d.ts +16 -0
  210. package/dist/utility/wrun/wrun-draw-skipped.leaf.js +16 -0
  211. package/dist/utility/wrun/wrun-earnings-facts.util.d.ts +42 -0
  212. package/dist/utility/wrun/wrun-earnings-facts.util.js +131 -0
  213. package/dist/utility/wrun/wrun-first-run-depth.util.d.ts +32 -0
  214. package/dist/utility/wrun/wrun-first-run-depth.util.js +118 -0
  215. package/dist/utility/wrun/wrun-gate-plane-readers.util.d.ts +24 -0
  216. package/dist/utility/wrun/wrun-gate-plane-readers.util.js +31 -0
  217. package/dist/utility/wrun/wrun-held-lanes.util.d.ts +32 -0
  218. package/dist/utility/wrun/wrun-held-lanes.util.js +94 -0
  219. package/dist/utility/wrun/wrun-host-visible-clock.util.d.ts +2 -0
  220. package/dist/utility/wrun/wrun-host-visible-clock.util.js +17 -0
  221. package/dist/utility/wrun/wrun-host.service.d.ts +330 -0
  222. package/dist/utility/wrun/wrun-host.service.js +855 -0
  223. package/dist/utility/wrun/wrun-hover.util.d.ts +3 -0
  224. package/dist/utility/wrun/wrun-hover.util.js +25 -4
  225. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +33 -0
  226. package/dist/utility/wrun/wrun-inert-legend.util.js +125 -0
  227. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +155 -0
  228. package/dist/utility/wrun/wrun-input-requirements.leaf.js +450 -0
  229. package/dist/utility/wrun/wrun-integration-route.util.d.ts +51 -0
  230. package/dist/utility/wrun/wrun-integration-route.util.js +59 -0
  231. package/dist/utility/wrun/wrun-latest-history.leaf.d.ts +8 -0
  232. package/dist/utility/wrun/wrun-latest-history.leaf.js +8 -0
  233. package/dist/utility/wrun/wrun-legend-hover.lazy.d.ts +12 -0
  234. package/dist/utility/wrun/wrun-legend-hover.lazy.js +96 -0
  235. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +21 -0
  236. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +21 -0
  237. package/dist/utility/wrun/wrun-live-hidden-hold.util.d.ts +23 -0
  238. package/dist/utility/wrun/wrun-live-hidden-hold.util.js +13 -0
  239. package/dist/utility/wrun/wrun-live-intake.util.d.ts +374 -0
  240. package/dist/utility/wrun/wrun-live-intake.util.js +2027 -0
  241. package/dist/utility/wrun/wrun-live-patch.util.d.ts +116 -0
  242. package/dist/utility/wrun/wrun-live-patch.util.js +523 -0
  243. package/dist/utility/wrun/wrun-live-tick.util.d.ts +619 -0
  244. package/dist/utility/wrun/wrun-live-tick.util.js +4974 -0
  245. package/dist/utility/wrun/wrun-loading-owner.util.d.ts +58 -0
  246. package/dist/utility/wrun/wrun-loading-owner.util.js +89 -0
  247. package/dist/utility/wrun/wrun-official-scope.leaf.d.ts +29 -0
  248. package/dist/utility/wrun/wrun-official-scope.leaf.js +36 -0
  249. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +27 -0
  250. package/dist/utility/wrun/wrun-oi-lane.util.js +42 -0
  251. package/dist/utility/wrun/wrun-options-stop.util.d.ts +52 -0
  252. package/dist/utility/wrun/wrun-options-stop.util.js +123 -0
  253. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +719 -0
  254. package/dist/utility/wrun/wrun-overlay-drivers.util.js +1180 -0
  255. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +50 -0
  256. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +131 -0
  257. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +118 -0
  258. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +466 -0
  259. package/dist/utility/wrun/wrun-overlay-metadata.util.d.ts +45 -0
  260. package/dist/utility/wrun/wrun-overlay-metadata.util.js +112 -0
  261. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +114 -0
  262. package/dist/utility/wrun/wrun-overlay-recovery.util.js +971 -0
  263. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +858 -0
  264. package/dist/utility/wrun/wrun-overlay-run.util.js +11013 -0
  265. package/dist/utility/wrun/wrun-pack.util.d.ts +2 -1
  266. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +24 -9
  267. package/dist/utility/wrun/wrun-panel-mount.util.js +138 -43
  268. package/dist/utility/wrun/wrun-param-map.util.d.ts +19 -4
  269. package/dist/utility/wrun/wrun-param-map.util.js +40 -47
  270. package/dist/utility/wrun/wrun-param-values.util.d.ts +9 -3
  271. package/dist/utility/wrun/wrun-param-values.util.js +5 -5
  272. package/dist/utility/wrun/wrun-prefix-cohort.util.d.ts +93 -0
  273. package/dist/utility/wrun/wrun-prefix-cohort.util.js +484 -0
  274. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +114 -0
  275. package/dist/utility/wrun/wrun-prefix-lanes.util.js +486 -0
  276. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +317 -0
  277. package/dist/utility/wrun/wrun-prefix-proof.util.js +630 -0
  278. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +73 -0
  279. package/dist/utility/wrun/wrun-refusal-surface.util.js +380 -0
  280. package/dist/utility/wrun/wrun-refusal-text.util.d.ts +15 -0
  281. package/dist/utility/wrun/wrun-refusal-text.util.js +40 -0
  282. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
  283. package/dist/utility/wrun/wrun-replay-lane.util.d.ts +139 -0
  284. package/dist/utility/wrun/wrun-replay-lane.util.js +520 -0
  285. package/dist/utility/wrun/wrun-replay-rows.util.d.ts +21 -0
  286. package/dist/utility/wrun/wrun-replay-rows.util.js +172 -0
  287. package/dist/utility/wrun/wrun-row-source-factory.d.ts +53 -0
  288. package/dist/utility/wrun/wrun-row-source-factory.js +435 -0
  289. package/dist/utility/wrun/wrun-run-cells.util.d.ts +36 -0
  290. package/dist/utility/wrun/wrun-run-cells.util.js +46 -0
  291. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +133 -0
  292. package/dist/utility/wrun/wrun-run-interval-session.util.js +121 -0
  293. package/dist/utility/wrun/wrun-run-interval.util.d.ts +98 -0
  294. package/dist/utility/wrun/wrun-run-interval.util.js +207 -0
  295. package/dist/utility/wrun/wrun-run-retained.util.d.ts +122 -0
  296. package/dist/utility/wrun/wrun-run-retained.util.js +255 -0
  297. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +184 -0
  298. package/dist/utility/wrun/wrun-sandbox-row-source.js +444 -0
  299. package/dist/utility/wrun/wrun-script-inputs.util.js +4 -4
  300. package/dist/utility/wrun/wrun-series-stream.util.d.ts +86 -0
  301. package/dist/utility/wrun/wrun-series-stream.util.js +537 -0
  302. package/dist/utility/wrun/wrun-sha256.leaf.d.ts +13 -0
  303. package/dist/utility/wrun/wrun-sha256.leaf.js +84 -0
  304. package/dist/utility/wrun/wrun-sheet-remembered.util.d.ts +21 -0
  305. package/dist/utility/wrun/wrun-sheet-remembered.util.js +36 -0
  306. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.d.ts +7 -0
  307. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.js +12 -0
  308. package/dist/utility/wrun/wrun-socket-row-source.js +4 -2
  309. package/dist/utility/wrun/wrun-source-rows.util.d.ts +175 -3
  310. package/dist/utility/wrun/wrun-source-rows.util.js +294 -8
  311. package/dist/utility/wrun/wrun-stats-strip.util.d.ts +46 -0
  312. package/dist/utility/wrun/wrun-stats-strip.util.js +87 -0
  313. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +163 -0
  314. package/dist/utility/wrun/wrun-table-chrome.util.js +557 -0
  315. package/dist/utility/wrun/wrun-text-params.util.d.ts +11 -6
  316. package/dist/utility/wrun/wrun-text-params.util.js +19 -30
  317. package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +64 -0
  318. package/dist/utility/wrun/wrun-transient-rerun.util.js +317 -0
  319. package/dist/utility/wrun/wrun-twin-lookback.util.d.ts +10 -0
  320. package/dist/utility/wrun/wrun-twin-lookback.util.js +43 -0
  321. package/dist/utility/wrun/wrun-warmup-head-store.util.d.ts +41 -0
  322. package/dist/utility/wrun/wrun-warmup-head-store.util.js +120 -0
  323. package/dist/utility/wrun-alert-params.leaf.d.ts +24 -0
  324. package/dist/utility/wrun-alert-params.leaf.js +24 -0
  325. package/dist/utils/replay/replay-buffer-math.d.ts +148 -0
  326. package/dist/utils/replay/replay-buffer-math.js +684 -0
  327. package/dist/workers/wrun/wrun-abi-host.d.ts +203 -0
  328. package/dist/workers/wrun/wrun-abi-host.js +1220 -0
  329. package/dist/workers/wrun/wrun-engine-handler.d.ts +20 -0
  330. package/dist/workers/wrun/wrun-engine-handler.js +380 -0
  331. package/package.json +3 -3
@@ -0,0 +1,93 @@
1
+ const LIVE_OHLC_EXTREME_RATIO = 0.05;
2
+ const LIVE_OHLC_RANGE_MULTIPLIER = 3;
3
+ function finiteNumber(value) {
4
+ if (typeof value === 'string' && value.trim() === '')
5
+ return undefined;
6
+ const n = Number(value);
7
+ return Number.isFinite(n) ? n : undefined;
8
+ }
9
+ function positiveFiniteNumber(value) {
10
+ const n = finiteNumber(value);
11
+ return n !== undefined && n > 0 ? n : 0;
12
+ }
13
+ function referencePrice(rows, targetIndex, close) {
14
+ const target = targetIndex >= 0 ? rows[targetIndex] : undefined;
15
+ const previous = targetIndex >= 0 ? rows[targetIndex - 1] : rows[rows.length - 1];
16
+ return finiteNumber(target?.[4]) ?? finiteNumber(previous?.[4]) ?? close;
17
+ }
18
+ function liveOhlcTolerance(basePrice, bodyRange, existingRange) {
19
+ const priceBand = Math.abs(basePrice) * LIVE_OHLC_EXTREME_RATIO;
20
+ return Math.max(priceBand, Math.abs(bodyRange) * LIVE_OHLC_RANGE_MULTIPLIER, Math.abs(existingRange) * LIVE_OHLC_RANGE_MULTIPLIER);
21
+ }
22
+ function shouldUseLiveExtreme(value, boundary, tolerance, side) {
23
+ if (value === undefined)
24
+ return false;
25
+ if (side === 'high')
26
+ return value <= boundary + tolerance;
27
+ return value >= boundary - tolerance;
28
+ }
29
+ function maybeLogSanitizedLiveOhlc(reason, raw, sanitized) {
30
+ if (typeof window === 'undefined' || !window.__KS_DIAG)
31
+ return;
32
+ console.warn('[K_OHLCV] sanitized live OHLCV point', { reason, raw, sanitized });
33
+ }
34
+ export function mergeLiveOhlcvDataPoint(lastData, data, normalizedTime) {
35
+ const close = finiteNumber(data?.close);
36
+ if (!data || close === undefined || !Number.isFinite(normalizedTime)) {
37
+ return lastData;
38
+ }
39
+ const targetIndex = lastData.findIndex((point) => Array.isArray(point) && point[0] === normalizedTime);
40
+ const existingPoint = targetIndex >= 0 ? lastData[targetIndex] : undefined;
41
+ const refPrice = referencePrice(lastData, targetIndex, close);
42
+ const rawOpen = finiteNumber(data.open);
43
+ const rawHigh = finiteNumber(data.high);
44
+ const rawLow = finiteNumber(data.low);
45
+ const newVolume = positiveFiniteNumber(data.volume);
46
+ const refTolerance = liveOhlcTolerance(refPrice, Math.abs(close - refPrice), 0);
47
+ const newOpen = rawOpen !== undefined &&
48
+ rawOpen >= Math.min(close, refPrice) - refTolerance &&
49
+ rawOpen <= Math.max(close, refPrice) + refTolerance
50
+ ? rawOpen
51
+ : close;
52
+ const existingHigh = finiteNumber(existingPoint?.[2]);
53
+ const existingLow = finiteNumber(existingPoint?.[3]);
54
+ const baseHigh = Math.max(existingHigh ?? -Infinity, newOpen, close);
55
+ const baseLow = Math.min(existingLow ?? Infinity, newOpen, close);
56
+ const existingRange = existingHigh !== undefined && existingLow !== undefined ? Math.max(0, existingHigh - existingLow) : 0;
57
+ const tolerance = liveOhlcTolerance(close, Math.abs(close - newOpen), existingRange);
58
+ const newHigh = rawHigh !== undefined && shouldUseLiveExtreme(rawHigh, baseHigh, tolerance, 'high')
59
+ ? Math.max(rawHigh, baseHigh)
60
+ : baseHigh;
61
+ const newLow = rawLow !== undefined && shouldUseLiveExtreme(rawLow, baseLow, tolerance, 'low')
62
+ ? Math.min(rawLow, baseLow)
63
+ : baseLow;
64
+ if (rawOpen !== newOpen || rawHigh !== newHigh || rawLow !== newLow) {
65
+ maybeLogSanitizedLiveOhlc('implausible live OHLC field', data, [
66
+ normalizedTime,
67
+ newOpen,
68
+ newHigh,
69
+ newLow,
70
+ close,
71
+ newVolume,
72
+ ]);
73
+ }
74
+ // Pure like the buy-sell-volume / liquidations merges: never write into the
75
+ // caller's container. Live folds seed from the engine proxy's CACHED rows by
76
+ // reference; an in-place write leaks folded increments into the cache, and a
77
+ // re-fold of the same batch (multi-variant fallback re-apply) then counts
78
+ // them twice β€” the forming bar's volume overshot the candle until the next
79
+ // authoritative run.
80
+ if (targetIndex === -1) {
81
+ return [...lastData, [normalizedTime, newOpen, newHigh, newLow, close, newVolume]];
82
+ }
83
+ const next = [...lastData];
84
+ next[targetIndex] = [
85
+ normalizedTime,
86
+ existingPoint[1],
87
+ Math.max(existingHigh ?? newHigh, newHigh),
88
+ Math.min(existingLow ?? newLow, newLow),
89
+ close,
90
+ positiveFiniteNumber(existingPoint[5]) + newVolume,
91
+ ];
92
+ return next;
93
+ }
@@ -69,6 +69,10 @@ export interface LiveTradesMergeOptions {
69
69
  /** Called when the fold trimmed the live bar to the cap (the oldest prints dropped), so the
70
70
  * caller can warn once (the kScript lane) or refuse the bar by name (the wrun lane). */
71
71
  onCapped?: (cap: number) => void;
72
+ /** The bar the print folds into, when the caller names one (a dispatcher's host bar: an index-mode chart's own
73
+ * bar holding the print, `kScriptLiveHintedBucketMs`) in place of the bar the print keys on the lane's own grid
74
+ * (`tradesBarStartMs`); the cell's offset is measured from its open. Absent: the lane's own bar. */
75
+ barTs?: number;
72
76
  }
73
77
  /** One raw TRADE print as the fold reads it. */
74
78
  export interface LiveTradePrint {
@@ -181,5 +185,5 @@ export declare function tradesLargeHistoryAnswers(market: TradesLargeMarket): bo
181
185
  export declare function tradesBelowLargeFloor(print: LiveTradePrint, market?: TradesLargeMarket): boolean;
182
186
  /** Fold one raw TRADE point onto the tape rows: the NEW rows array (the touched row a new array,
183
187
  * every other row shared by reference), or null when the point is rejected (the caller keeps
184
- * its rows). */
188
+ * its rows). The print lands in the bar `options.barTs` names, else in its own bar on the lane's grid. */
185
189
  export declare function mergeLiveTradesDataPoint(lastDataPoint: ReadonlyArray<ArrayLike<unknown>>, newPoint: unknown, intervalMs: number, options?: LiveTradesMergeOptions): LiveTradesRow[] | null;
@@ -325,7 +325,7 @@ export function tradesBelowLargeFloor(print, market) {
325
325
  }
326
326
  /** Fold one raw TRADE point onto the tape rows: the NEW rows array (the touched row a new array,
327
327
  * every other row shared by reference), or null when the point is rejected (the caller keeps
328
- * its rows). */
328
+ * its rows). The print lands in the bar `options.barTs` names, else in its own bar on the lane's grid. */
329
329
  export function mergeLiveTradesDataPoint(lastDataPoint, newPoint, intervalMs, options = {}) {
330
330
  if (!Number.isFinite(intervalMs) || intervalMs <= 0)
331
331
  return null;
@@ -337,7 +337,7 @@ export function mergeLiveTradesDataPoint(lastDataPoint, newPoint, intervalMs, op
337
337
  return null;
338
338
  if (options.largeFloor !== undefined && tradesBelowLargeFloor(print, options.largeFloor))
339
339
  return null;
340
- const barTs = tradesBarStartMs(print.tsMs, intervalMs, print.exchange);
340
+ const barTs = options.barTs ?? tradesBarStartMs(print.tsMs, intervalMs, print.exchange);
341
341
  const rows = lastDataPoint;
342
342
  const last = rows.length > 0 ? rows[rows.length - 1] : undefined;
343
343
  // A delayed closed-bar print must not append an out-of-order row.
@@ -0,0 +1,219 @@
1
+ /**
2
+ * The venue-generic subscription contract (docs/features/market-data/plane.md): the wire DTOs every venue's
3
+ * `<basePath>/*` routes speak (OPRA's `/opra/*`, the frozen contract they were cut from), the normalized domain the
4
+ * store and the dialogs consume, the qualification and agreement predicates (each takes the venue card whose values it
5
+ * judges), the transport-free error and the repository boundary. The service maps the wire into these shapes in one
6
+ * place (src/services/market-data.service.ts). Nothing here names a venue. Worker-safe: types, one error class and pure
7
+ * helpers.
8
+ *
9
+ * Differences from CME are deliberate: one product per venue, no depth, a professional declaration refused (recorded,
10
+ * never re-priced), an EXPLICIT agreement acceptance (never inferred from a grant or a subscription), and pay first:
11
+ * the declaration and the agreement bind real-time ACCESS, not the payment, so checkout needs neither and the server
12
+ * serves real-time only once the account is both paid and qualified (delayed otherwise).
13
+ */
14
+ import type { CancelFeedback } from '../interfaces/cancel-reason.interface.js';
15
+ import type { MarketDataBillingInterval, MarketDataClassification, MarketDataVenue } from './venue.js';
16
+ /**
17
+ * POST <basePath>/attestation request body (201 for both classifications). The server derives the classification from
18
+ * `answers` and refuses a body whose `classification` disagrees, so the client sends the one
19
+ * `isMarketDataNonProfessional` reads from the same answers.
20
+ */
21
+ export interface MarketDataAttestationDto {
22
+ classification: MarketDataClassification;
23
+ /** Keyed by stable machine question ids, never translated question text. */
24
+ answers: Record<string, unknown>;
25
+ legalName: string;
26
+ employer?: string;
27
+ occupation?: string;
28
+ /** ISO 3166-1 alpha-2, uppercase (one of ISO_COUNTRY_CODES). */
29
+ country: string;
30
+ /** One line, as the subscriber typed it, trimmed. */
31
+ address: string;
32
+ /** The venue's form version (`venue.questionnaire.formVersion`). */
33
+ formVersion: string;
34
+ }
35
+ export interface MarketDataAttestationRecordDto {
36
+ id: number;
37
+ classification: MarketDataClassification;
38
+ attestedAt: string;
39
+ formVersion: string;
40
+ /**
41
+ * ISO end of the declaration's validity (a year after it was made). Additive: a server that names none leaves the
42
+ * record without a client-side expiry, and the checkout's refusal stays the authority.
43
+ */
44
+ expiresAt?: string;
45
+ }
46
+ /** GET <basePath>/attestation -> 200 body. */
47
+ export interface GetMarketDataAttestationResponseDto {
48
+ attestation: MarketDataAttestationRecordDto | null;
49
+ }
50
+ /** POST <basePath>/checkout request body. */
51
+ export interface MarketDataCheckoutDto {
52
+ interval: MarketDataBillingInterval;
53
+ locale?: string;
54
+ }
55
+ /**
56
+ * POST <basePath>/checkout -> 200: a Stripe redirect, or a refusal. 'professional_unavailable' is terminal (the UI
57
+ * shows "not available"). Pay first, the server no longer answers 'attestation_required' or 'agreement_required'; they
58
+ * stay in the union and are handled defensively (the flow routes into that step).
59
+ */
60
+ export type MarketDataCheckoutResponseDto = {
61
+ url: string;
62
+ } | {
63
+ refused: MarketDataPurchaseRefusalCode;
64
+ };
65
+ export type MarketDataPurchaseRefusalCode = 'professional_unavailable' | 'agreement_required' | 'attestation_required';
66
+ /**
67
+ * Why the server set a subscription to end at its period end on its own: 'unqualified', the account is paid but has
68
+ * not completed the subscriber questions and the agreement.
69
+ */
70
+ export type MarketDataSubscriptionHold = 'unqualified';
71
+ /** Subscription as served by GET <basePath>/subscription. */
72
+ export interface MarketDataSubscriptionDto {
73
+ interval: MarketDataBillingInterval;
74
+ /** ISO timestamp of the current period end. */
75
+ renewsAt: string;
76
+ /** Ends at `renewsAt`: the subscriber's own cancel, or the server's hold (`hold`). */
77
+ pendingCancellation: boolean;
78
+ priceUsd: number;
79
+ /**
80
+ * The server's hold: 'unqualified' while a paid account lacks its subscriber status, so the subscription ends at
81
+ * `renewsAt` unless the subscriber completes it, and resumes once it does (a resume cannot lift it). Null for the
82
+ * subscriber's own cancel or none: completing the status never reverses that cancel.
83
+ */
84
+ hold: MarketDataSubscriptionHold | null;
85
+ }
86
+ export interface GetMarketDataSubscriptionResponseDto {
87
+ subscription: MarketDataSubscriptionDto | null;
88
+ }
89
+ /**
90
+ * GET <basePath>/data-terms -> 200; POST <basePath>/data-terms -> 201. Acceptance is an explicit record of the
91
+ * agreement version the user accepted; a grant or a subscription never implies it.
92
+ */
93
+ export interface MarketDataDataTermsDto {
94
+ accepted: boolean;
95
+ agreementVersion: string;
96
+ acceptedAt?: string;
97
+ }
98
+ /** What a professional declaration did to the account's subscription, as the server reports it. */
99
+ export interface MarketDataAttestationWithdrawal {
100
+ subscriptionCancelled: boolean;
101
+ refunded: boolean;
102
+ }
103
+ /** POST <basePath>/attestation -> 201 body; `withdrawal` only for a professional declaration. */
104
+ export interface SubmitMarketDataAttestationResponseDto {
105
+ attestationId: number;
106
+ withdrawal?: MarketDataAttestationWithdrawal;
107
+ }
108
+ /** The submit's answer in the domain: the record id, and what a professional declaration withdrew (else null). */
109
+ export interface MarketDataAttestationSubmitResult {
110
+ attestationId: number;
111
+ withdrawal: MarketDataAttestationWithdrawal | null;
112
+ }
113
+ /** POST <basePath>/data-terms request body: the agreement version the subscriber was shown and accepted. */
114
+ export interface AcceptMarketDataDataTermsDto {
115
+ agreementVersion: string;
116
+ }
117
+ /** POST <basePath>/subscription/cancel and DELETE <basePath>/subscription/cancel -> 200 body. */
118
+ export interface MarketDataCancelResponseDto {
119
+ message?: string;
120
+ }
121
+ /**
122
+ * POST <basePath>/register (no body) -> 201 body, sent only once the gate confirmed the free registration (delayed
123
+ * data); 403 for a suspended account. Idempotent on the server.
124
+ */
125
+ export interface MarketDataRegisterResponseDto {
126
+ registered: boolean;
127
+ }
128
+ /** The register's answer in the domain: it resolves only on the confirmed registration (anything else throws). */
129
+ export interface MarketDataRegistration {
130
+ registered: true;
131
+ }
132
+ export type MarketDataAttestation = MarketDataAttestationRecordDto;
133
+ export type MarketDataSubscription = MarketDataSubscriptionDto;
134
+ /** The explicit agreement record: accepted, for which version, and when. */
135
+ export interface MarketDataAgreement {
136
+ accepted: boolean;
137
+ agreementVersion: string;
138
+ acceptedAt: string | null;
139
+ }
140
+ /** A form's answers, keyed by the venue's question ids. A missing answer never qualifies. */
141
+ export type MarketDataQualificationAnswers = Partial<Record<string, boolean>>;
142
+ /** Every question of the venue's questionnaire answered with its qualifying answer. */
143
+ export declare function isMarketDataNonProfessional(venue: MarketDataVenue, answers: MarketDataQualificationAnswers): boolean;
144
+ /**
145
+ * A declaration on the venue's current form (a new question set means a new declaration) whose validity has not ended
146
+ * at `now`, either classification. The client owns expiry: `now` is the caller's clock (the store's last evaluation),
147
+ * never an implied Date.now(). A record without `expiresAt` never expires here; one whose `expiresAt` does not parse
148
+ * reads expired (ask again rather than trust it).
149
+ */
150
+ export declare function isMarketDataAttestationLive(venue: MarketDataVenue, attestation: MarketDataAttestation | null | undefined, now: number): boolean;
151
+ /** A non-professional declaration on the current form, still valid at `now`: the account may buy real-time. */
152
+ export declare function isMarketDataAttestationCurrent(venue: MarketDataVenue, attestation: MarketDataAttestation | null | undefined, now: number): boolean;
153
+ /** A professional declaration on the current form, still valid at `now`: real-time is not sold to the account. */
154
+ export declare function isMarketDataProfessionalDeclaration(venue: MarketDataVenue, attestation: MarketDataAttestation | null | undefined, now: number): boolean;
155
+ /**
156
+ * The expiry (ISO, as served) a still-current non-professional declaration must be renewed by, once `now` is inside
157
+ * the venue's renewal window before it; null otherwise (no expiry named, further off, or already lapsed).
158
+ */
159
+ export declare function marketDataAttestationRenewBy(venue: MarketDataVenue, attestation: MarketDataAttestation | null | undefined, now: number): string | null;
160
+ /** An acceptance counts only for the agreement version the venue presents, never for an older text. */
161
+ export declare function isMarketDataAgreementCurrent(venue: MarketDataVenue, agreement: MarketDataAgreement | null | undefined): boolean;
162
+ /**
163
+ * Normalized checkout outcome. 'redirect' = leave for Stripe. 'refused' = the server declined (or the store answered a
164
+ * professional account itself); 'professional_unavailable' is terminal, never a re-price. 'busy' = a checkout is
165
+ * already in flight, or the guest wall took the click.
166
+ */
167
+ export type MarketDataCheckoutResult = {
168
+ kind: 'redirect';
169
+ url: string;
170
+ } | {
171
+ kind: 'refused';
172
+ code: MarketDataPurchaseRefusalCode;
173
+ } | {
174
+ kind: 'busy';
175
+ };
176
+ /**
177
+ * Transport-free failure surface for the billing calls. Unlike CME, a 403 is NOT an attestation gate (refusals ride the
178
+ * 200 checkout body), so it never routes back into the declaration: it is a route the account may not use (the
179
+ * register's suspended account included). 'invoice_owed' is the tagged 409 while Stripe still collects an invoice.
180
+ */
181
+ export type MarketDataBillingErrorKind = 'conflict' | 'invoice_owed' | 'unauthorized' | 'forbidden' | 'network' | 'aborted' | 'server';
182
+ export declare class MarketDataBillingError extends Error {
183
+ readonly kind: MarketDataBillingErrorKind;
184
+ readonly status: number | null;
185
+ /** Raw backend message: diagnostic content only, never primary UI copy. */
186
+ readonly diagnosticMessage: string | null;
187
+ /** Stripe's hosted invoice on an 'invoice_owed' refusal; null otherwise. */
188
+ readonly invoiceUrl: string | null;
189
+ constructor(kind: MarketDataBillingErrorKind, options?: {
190
+ status?: number | null;
191
+ diagnosticMessage?: string | null;
192
+ invoiceUrl?: string | null;
193
+ });
194
+ }
195
+ /** A venue's live repository boundary (src/services/market-data.service.ts; specs substitute it per venue). */
196
+ export interface MarketDataBillingRepository {
197
+ getAttestation(signal?: AbortSignal): Promise<MarketDataAttestation | null>;
198
+ submitAttestation(body: MarketDataAttestationDto, signal?: AbortSignal): Promise<MarketDataAttestationSubmitResult>;
199
+ getSubscription(signal?: AbortSignal): Promise<MarketDataSubscription | null>;
200
+ /** Never resolves 'busy' (that is the store's own answer); a refusal resolves, a failure throws. */
201
+ checkout(body: MarketDataCheckoutDto, options: {
202
+ idempotencyId: string;
203
+ signal?: AbortSignal;
204
+ }): Promise<Exclude<MarketDataCheckoutResult, {
205
+ kind: 'busy';
206
+ }>>;
207
+ /** Cancels at period end (one classification is sold, so there is no immediate switch-cancel), with the reason. */
208
+ cancelSubscription(signal?: AbortSignal, feedback?: CancelFeedback): Promise<{
209
+ message: string | null;
210
+ }>;
211
+ retractCancellation(signal?: AbortSignal): Promise<{
212
+ message: string | null;
213
+ }>;
214
+ getDataTerms(signal?: AbortSignal): Promise<MarketDataAgreement>;
215
+ acceptDataTerms(agreementVersion: string, signal?: AbortSignal): Promise<MarketDataAgreement>;
216
+ /** The free registration: resolves only on the confirmed 201 `{ registered: true }`; a failure throws (a 403 is
217
+ * 'forbidden'). */
218
+ register(signal?: AbortSignal): Promise<MarketDataRegistration>;
219
+ }
@@ -0,0 +1,58 @@
1
+ const DAY_MS = 86_400_000;
2
+ /** Every question of the venue's questionnaire answered with its qualifying answer. */
3
+ export function isMarketDataNonProfessional(venue, answers) {
4
+ return venue.questionnaire.questions.every((question) => answers[question.id] === question.qualifying);
5
+ }
6
+ /**
7
+ * A declaration on the venue's current form (a new question set means a new declaration) whose validity has not ended
8
+ * at `now`, either classification. The client owns expiry: `now` is the caller's clock (the store's last evaluation),
9
+ * never an implied Date.now(). A record without `expiresAt` never expires here; one whose `expiresAt` does not parse
10
+ * reads expired (ask again rather than trust it).
11
+ */
12
+ export function isMarketDataAttestationLive(venue, attestation, now) {
13
+ if (!attestation || attestation.formVersion !== venue.questionnaire.formVersion)
14
+ return false;
15
+ if (attestation.expiresAt === undefined)
16
+ return true;
17
+ const ends = Date.parse(attestation.expiresAt);
18
+ return Number.isFinite(ends) && now < ends;
19
+ }
20
+ /** A non-professional declaration on the current form, still valid at `now`: the account may buy real-time. */
21
+ export function isMarketDataAttestationCurrent(venue, attestation, now) {
22
+ return attestation?.classification === 'non_professional' && isMarketDataAttestationLive(venue, attestation, now);
23
+ }
24
+ /** A professional declaration on the current form, still valid at `now`: real-time is not sold to the account. */
25
+ export function isMarketDataProfessionalDeclaration(venue, attestation, now) {
26
+ return attestation?.classification === 'professional' && isMarketDataAttestationLive(venue, attestation, now);
27
+ }
28
+ /**
29
+ * The expiry (ISO, as served) a still-current non-professional declaration must be renewed by, once `now` is inside
30
+ * the venue's renewal window before it; null otherwise (no expiry named, further off, or already lapsed).
31
+ */
32
+ export function marketDataAttestationRenewBy(venue, attestation, now) {
33
+ if (!isMarketDataAttestationCurrent(venue, attestation, now) || attestation?.expiresAt === undefined)
34
+ return null;
35
+ return Date.parse(attestation.expiresAt) - now <= venue.questionnaire.renewalWindowDays * DAY_MS
36
+ ? attestation.expiresAt
37
+ : null;
38
+ }
39
+ /** An acceptance counts only for the agreement version the venue presents, never for an older text. */
40
+ export function isMarketDataAgreementCurrent(venue, agreement) {
41
+ return agreement?.accepted === true && agreement.agreementVersion === venue.agreement.version;
42
+ }
43
+ export class MarketDataBillingError extends Error {
44
+ kind;
45
+ status;
46
+ /** Raw backend message: diagnostic content only, never primary UI copy. */
47
+ diagnosticMessage;
48
+ /** Stripe's hosted invoice on an 'invoice_owed' refusal; null otherwise. */
49
+ invoiceUrl;
50
+ constructor(kind, options) {
51
+ super(`market data billing error: ${kind}`);
52
+ this.name = 'MarketDataBillingError';
53
+ this.kind = kind;
54
+ this.status = options?.status ?? null;
55
+ this.diagnosticMessage = options?.diagnosticMessage ?? null;
56
+ this.invoiceUrl = options?.invoiceUrl ?? null;
57
+ }
58
+ }
@@ -0,0 +1,2 @@
1
+ import type { MarketDataVenue } from './venue.js';
2
+ export declare function isVenueGoverned(venue: Pick<MarketDataVenue, 'productGroups'>, exchange: string | null | undefined): boolean;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Whether a market-data venue governs an exchange: its normalized code is one of the venue's product groups. For OPRA
3
+ * this is `isOpraGoverned` (utility/v2/opra-governed.util.ts), the same normalization over the same codes (the OPRA
4
+ * card's product groups are the governed list, pinned equal by the card's contract spec).
5
+ */
6
+ import { normalizeExchangeCode } from '../utility/chart/cme-realtime.util.js';
7
+ export function isVenueGoverned(venue, exchange) {
8
+ const code = normalizeExchangeCode(exchange);
9
+ return code !== null && venue.productGroups.includes(code);
10
+ }
@@ -0,0 +1,122 @@
1
+ /**
2
+ * The frontend market-data venue descriptor: ONE checked-in card per exchange deal
3
+ * (docs/features/market-data/plane.md). The venue-generic subscription flow reads every venue fact from it, never a
4
+ * venue literal: the store and its repository (`useMarketDataStore`, `createMarketDataService`: the base path, the form
5
+ * and agreement versions, the product a checkout sells), the takeover dialogs (`MarketData*`: the plan card, the
6
+ * questionnaire's ids and groups, the agreement link, the delay), the payment return (the catalog items and the price)
7
+ * and the openers (the flag).
8
+ *
9
+ * The card mirrors the backend's descriptor (orange `src/market-data/venues/<venue>.ts`) for what the frontend shows or
10
+ * sends, and the gate's release values for the product groups and the delay. Two contract copies carry one revision
11
+ * string: the backend's contract export, a byte copy checked in beside each card (`<venue>.contract.copy.json`), and
12
+ * the gate's release mirror, copied beside the card's parity spec, which pins the card against both
13
+ * (tests/packages/wrun-chart-host/market-data/venues/opra.contract.spec.ts, `gate-mirror.copy.yaml` beside it).
14
+ *
15
+ * What stays per-venue CODE, never a field here: the questionnaire's wording (a content module keyed by venue,
16
+ * src/components/dialogs/market-data/questionnaires/), the agreement text and the legal disclosure strings (OPRA's
17
+ * delay notice lives once, in src/constants/opra-compliance.constants.ts). Worker-safe: types and data only.
18
+ */
19
+ import type { FeatureFlagKey } from '../constants/feature-flags.constants.js';
20
+ /** The two declarations a subscriber can make; each product names which of them may hold it. */
21
+ export type MarketDataClassification = 'non_professional' | 'professional';
22
+ /** The intervals a product can renew on. */
23
+ export type MarketDataBillingInterval = '1m' | '1y';
24
+ /** The identity fields a declaration can carry (the attestation body's wire names). */
25
+ export type MarketDataIdentityField = 'legalName' | 'employer' | 'occupation' | 'country' | 'address';
26
+ /** One product a venue sells: a catalog line and the gate plan it grants. */
27
+ export interface MarketDataProduct {
28
+ /** The catalog name: the Stripe line item a checkout sells and a payment return names (`opra_rt_1m`). */
29
+ readonly name: string;
30
+ /** The gate plan the product grants (`p1`). */
31
+ readonly plan: string;
32
+ /** The declarations that may hold it. */
33
+ readonly classifications: readonly MarketDataClassification[];
34
+ readonly interval: MarketDataBillingInterval;
35
+ /** The catalog price, display only: once a subscription exists, the server's price is authoritative. */
36
+ readonly priceUsd: number;
37
+ }
38
+ /** One qualification question: a stable machine id (the record's key, never translated text), its qualifying answer. */
39
+ export interface MarketDataQuestion {
40
+ readonly id: string;
41
+ readonly qualifying: boolean;
42
+ }
43
+ /** Questions the form asks as one ("Do any of these apply to you?"), by id, in order; the record keeps every answer. */
44
+ export interface MarketDataQuestionGroup {
45
+ readonly id: string;
46
+ readonly questions: readonly string[];
47
+ }
48
+ export interface MarketDataQuestionnaire {
49
+ /** A record on any other version reads as no declaration: the subscriber declares again. */
50
+ readonly formVersion: string;
51
+ /** Every answer must match its qualifying answer; anything else is a professional declaration. */
52
+ readonly questions: readonly MarketDataQuestion[];
53
+ /** The questions the form asks as a group; every other question stands alone, in the questions' order. */
54
+ readonly groups: readonly MarketDataQuestionGroup[];
55
+ /** The identity fields the declaration requires, in the wire order. */
56
+ readonly identityFields: readonly MarketDataIdentityField[];
57
+ /** The server's bound on each identity field, trimmed. */
58
+ readonly identityLimits: Readonly<Record<MarketDataIdentityField, number>>;
59
+ /** How long a declaration stays valid (the server serves the record's `expiresAt`). */
60
+ readonly validityDays: number;
61
+ /** How long before the expiry the management page asks for the renewal. */
62
+ readonly renewalWindowDays: number;
63
+ }
64
+ /** The venue's subscriber agreement: an explicit, versioned acceptance, never inferred from a grant or a payment. */
65
+ export interface MarketDataAgreementPolicy {
66
+ /** Bump on ANY change to the text the dialog shows or links: a new version is a new acceptance. */
67
+ readonly version: string;
68
+ /** Where the agreement step links for the venue's own subscriber terms. */
69
+ readonly url: string;
70
+ /** Whether delayed display needs the acceptance too (false: the agreement binds real time only). */
71
+ readonly delayedRequiresAcceptance: boolean;
72
+ }
73
+ /** The product terms the plan card shows as written (never translated, like the CME bundle names). */
74
+ export interface MarketDataPlanCard {
75
+ readonly name: string;
76
+ readonly level: string;
77
+ readonly market: string;
78
+ readonly region: string;
79
+ }
80
+ /**
81
+ * The surfaces that carry a venue's delay disclosure wherever its delayed data shows (docs/features/search/
82
+ * option-chain-browser.md, "Delay and disclosure"; tests/structure/opra-delay-notice-surfaces.spec.ts holds the rule).
83
+ */
84
+ export type MarketDataDisclosureSurface = 'chain-page-subtitle' | 'chain-price-pill' | 'chain-table-marker' | 'chain-strike-preview' | 'chain-index-notice' | 'flow-tape' | 'terminal-options-tab' | 'options-overlay-legends' | 'indicator-legend-notes' | 'contract-chart-delay-chip' | 'contract-chart-delay-card' | 'chart-source-line' | 'watchlist-panel' | 'watchlist-cell-tooltip' | 'board' | 'purchase-live-price';
85
+ export interface MarketDataVenue {
86
+ /** The venue key (`opra`): the registry, the store, the openers, the testids and the payment product name it. */
87
+ readonly key: string;
88
+ readonly displayName: string;
89
+ /** The gate's product groups (the exchange codes the venue governs), the gate values' copy. */
90
+ readonly productGroups: readonly string[];
91
+ /** The venue's API base path (`/opra`; a new venue mounts at `/market-data/<venue>`). */
92
+ readonly basePath: string;
93
+ /** What the venue sells; the purchase flow sells the first (one plan). */
94
+ readonly products: readonly MarketDataProduct[];
95
+ readonly planCard: MarketDataPlanCard;
96
+ /** The prefix of every Stripe line item of the venue: a return carrying it is the venue's, valid or malformed. */
97
+ readonly paymentItemPrefix: string;
98
+ /** 'refuse': a professional declaration is recorded and ends the purchase in "not available", never a re-price. */
99
+ readonly professionalPolicy: 'refuse' | 'sell';
100
+ /** 'refuse': no role is consulted, an internal account buys like any other and the server's refusal stands. */
101
+ readonly internalRolePolicy: 'refuse' | 'dev';
102
+ /** The checkout needs neither the declaration nor the agreement: they bind real-time access, not the payment. */
103
+ readonly payFirst: boolean;
104
+ readonly questionnaire: MarketDataQuestionnaire;
105
+ readonly agreement: MarketDataAgreementPolicy;
106
+ /** The delayed tier's nominal delay (the gate's delayed window). */
107
+ readonly delayMinutes: number;
108
+ /** 'verbatim': a legally exact English phrase (a compliance constant); 'translated': the venue's locale copy. */
109
+ readonly disclosure: {
110
+ readonly kind: 'translated' | 'verbatim';
111
+ };
112
+ /** The frontend flag the venue's doors ride (a no-op while it is dark); null for none. */
113
+ readonly flagKey: FeatureFlagKey | null;
114
+ /** The locale namespace every string of the venue lives under (OPRA keeps `opraRealtimeData`). */
115
+ readonly i18nNamespace: string;
116
+ /** The Pinia id of the venue's purchase store. */
117
+ readonly storeId: string;
118
+ /** Where the venue's delay disclosure must show. */
119
+ readonly surfaces: readonly MarketDataDisclosureSurface[];
120
+ /** The revision of the contract copies the card is pinned against (one string in every copy). */
121
+ readonly contractRevision: string;
122
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,97 @@
1
+ /**
2
+ * The market-data venue registry: every venue card the frontend serves (docs/features/market-data/plane.md). A new
3
+ * exchange deal adds its card here; the purchase flow, the payment return and the openers find a venue by its key or
4
+ * by a payment line item, never by a venue literal. The finders over an explicit list (`findVenueBy*`) are the same
5
+ * rules the bound finders apply to the registry, for a spec that serves a venue of its own beside the registered ones.
6
+ */
7
+ import type { MarketDataVenue } from '../venue.js';
8
+ export declare const MARKET_DATA_VENUES: readonly [{
9
+ readonly key: "opra";
10
+ readonly displayName: "OPRA";
11
+ readonly productGroups: readonly ["OPRA"];
12
+ readonly basePath: "/opra";
13
+ readonly products: readonly [{
14
+ readonly name: "opra_rt_1m";
15
+ readonly plan: "p1";
16
+ readonly classifications: readonly ["non_professional"];
17
+ readonly interval: "1m";
18
+ readonly priceUsd: 4.95;
19
+ }];
20
+ readonly planCard: {
21
+ readonly name: "OPRA real-time";
22
+ readonly level: "TOP OF BOOK";
23
+ readonly market: "OPRA";
24
+ readonly region: "πŸ‡ΊπŸ‡Έ USA";
25
+ };
26
+ readonly paymentItemPrefix: "opra_";
27
+ readonly professionalPolicy: "refuse";
28
+ readonly internalRolePolicy: "refuse";
29
+ readonly payFirst: true;
30
+ readonly questionnaire: {
31
+ readonly formVersion: "opra-v2";
32
+ readonly questions: readonly [{
33
+ readonly id: "natural_person";
34
+ readonly qualifying: true;
35
+ }, {
36
+ readonly id: "personal_use_only";
37
+ readonly qualifying: true;
38
+ }, {
39
+ readonly id: "securities_registered";
40
+ readonly qualifying: false;
41
+ }, {
42
+ readonly id: "investment_adviser";
43
+ readonly qualifying: false;
44
+ }, {
45
+ readonly id: "exempt_institution_role";
46
+ readonly qualifying: false;
47
+ }];
48
+ readonly groups: readonly [{
49
+ readonly id: "professional-group";
50
+ readonly questions: readonly ["securities_registered", "investment_adviser", "exempt_institution_role"];
51
+ }];
52
+ readonly identityFields: readonly ["legalName", "employer", "occupation", "country", "address"];
53
+ readonly identityLimits: {
54
+ readonly legalName: 200;
55
+ readonly employer: 200;
56
+ readonly occupation: 200;
57
+ readonly country: 2;
58
+ readonly address: 300;
59
+ };
60
+ readonly validityDays: 365;
61
+ readonly renewalWindowDays: 30;
62
+ };
63
+ readonly agreement: {
64
+ readonly version: "opra-subscriber-2026-10";
65
+ readonly url: "https://www.opraplan.com/";
66
+ readonly delayedRequiresAcceptance: false;
67
+ };
68
+ readonly delayMinutes: 15;
69
+ readonly disclosure: {
70
+ readonly kind: "verbatim";
71
+ };
72
+ readonly flagKey: "opra";
73
+ readonly i18nNamespace: "opraRealtimeData";
74
+ readonly storeId: "opraRealtime";
75
+ readonly surfaces: readonly ["chain-page-subtitle", "chain-price-pill", "chain-table-marker", "chain-strike-preview", "chain-index-notice", "flow-tape", "terminal-options-tab", "options-overlay-legends", "indicator-legend-notes", "contract-chart-delay-chip", "contract-chart-delay-card", "chart-source-line", "watchlist-panel", "watchlist-cell-tooltip", "board", "purchase-live-price"];
76
+ readonly contractRevision: "2026-10-20.1";
77
+ }];
78
+ /** A registered venue's key. */
79
+ export type MarketDataVenueKey = (typeof MARKET_DATA_VENUES)[number]['key'];
80
+ /** A registered venue: the descriptor, its key narrowed to the registered keys. */
81
+ export type RegisteredMarketDataVenue = MarketDataVenue & {
82
+ readonly key: MarketDataVenueKey;
83
+ };
84
+ /** The venue in `venues` with this key, or null. */
85
+ export declare function findVenueByKey<V extends MarketDataVenue>(venues: readonly V[], key: unknown): V | null;
86
+ /**
87
+ * The venue in `venues` a payment line item belongs to: the venue selling that product, else the venue whose catalog
88
+ * prefix the item carries (a malformed or retired item of a venue stays that venue's, never another product's); null
89
+ * for an item no venue names.
90
+ */
91
+ export declare function findVenueByPaymentProduct<V extends MarketDataVenue>(venues: readonly V[], item: unknown): V | null;
92
+ /** The registered venue with this key, or null. */
93
+ export declare function venueByKey(key: unknown): RegisteredMarketDataVenue | null;
94
+ /** The registered venue with this key; a key no card has throws (a programming error, never an account's state). */
95
+ export declare function requireVenueByKey(key: unknown): RegisteredMarketDataVenue;
96
+ /** The registered venue a payment line item belongs to (`findVenueByPaymentProduct` over the registry), or null. */
97
+ export declare function venueByPaymentProduct(item: unknown): RegisteredMarketDataVenue | null;