@orangecharts/wrun-chart-host 0.8.0 → 0.10.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 (246) hide show
  1. package/README.md +3 -1
  2. package/dist/constants/feature-flags.constants.d.ts +9 -0
  3. package/dist/constants/feature-flags.constants.js +86 -16
  4. package/dist/constants/marketCapabilities.constants.d.ts +14 -9
  5. package/dist/constants/marketCapabilities.constants.js +36 -13
  6. package/dist/constants/opra-compliance.constants.d.ts +15 -0
  7. package/dist/constants/opra-compliance.constants.js +15 -0
  8. package/dist/constants/option-venues.constants.d.ts +11 -6
  9. package/dist/constants/option-venues.constants.js +5 -2
  10. package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +26 -0
  11. package/dist/constants/scriptEditor/builtin-script-snippets.js +6 -0
  12. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +15 -0
  13. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +17 -0
  14. package/dist/constants/venue-presets.constants.d.ts +20 -20
  15. package/dist/constants/venue-presets.constants.js +24 -26
  16. package/dist/host-env.d.ts +39 -9
  17. package/dist/host-env.js +6 -0
  18. package/dist/host-ports.types.d.ts +108 -18
  19. package/dist/index.d.ts +14 -0
  20. package/dist/index.js +14 -0
  21. package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
  22. package/dist/interfaces/opra-realtime.interface.d.ts +13 -11
  23. package/dist/interfaces/opra-realtime.interface.js +10 -10
  24. package/dist/interfaces/replay.interface.d.ts +8 -0
  25. package/dist/interfaces/wrun-runtime.interface.d.ts +52 -15
  26. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +94 -14
  27. package/dist/kscript-data/controls/live-trades-merge.util.js +132 -22
  28. package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +56 -0
  29. package/dist/kscript-data/controls/live-trades-order-gate.util.js +107 -0
  30. package/dist/market-data/billing.interface.d.ts +227 -42
  31. package/dist/market-data/billing.interface.js +60 -12
  32. package/dist/market-data/venue.d.ts +88 -6
  33. package/dist/market-data/venues/cme.contract.copy.json +66 -0
  34. package/dist/market-data/venues/cme.d.ts +126 -0
  35. package/dist/market-data/venues/cme.js +133 -0
  36. package/dist/market-data/venues/index.d.ts +165 -8
  37. package/dist/market-data/venues/index.js +48 -6
  38. package/dist/market-data/venues/opra.contract.copy.json +5 -3
  39. package/dist/market-data/venues/opra.d.ts +3 -3
  40. package/dist/market-data/venues/opra.js +5 -4
  41. package/dist/replay/replayLadder.js +3 -1
  42. package/dist/settings-templates/index.js +7 -3
  43. package/dist/settings-templates/indicator-fields.d.ts +5 -4
  44. package/dist/settings-templates/indicator-fields.js +45 -6
  45. package/dist/settings-templates/tool-rules.d.ts +27 -17
  46. package/dist/settings-templates/tool-rules.js +27 -11
  47. package/dist/settings-templates/tool-tables.generated.js +91 -31
  48. package/dist/utility/chart/book-live-bucket.util.d.ts +15 -0
  49. package/dist/utility/chart/book-live-bucket.util.js +47 -0
  50. package/dist/utility/chart/crypto-index.leaf.d.ts +2 -2
  51. package/dist/utility/chart/crypto-index.leaf.js +2 -2
  52. package/dist/utility/chart/index-mode-admission.util.js +24 -3
  53. package/dist/utility/chart/index-mode.util.d.ts +5 -2
  54. package/dist/utility/chart/index-mode.util.js +23 -13
  55. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +35 -11
  56. package/dist/utility/chart/kscript-drawing-safe-area.util.js +145 -35
  57. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +7 -2
  58. package/dist/utility/chart/kscript-live-coalesce.util.js +9 -3
  59. package/dist/utility/chart/kscript-provenance-keys.util.js +6 -0
  60. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
  61. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +32 -2
  62. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +45 -0
  63. package/dist/utility/chart/kscript-venue-policy.util.d.ts +53 -27
  64. package/dist/utility/chart/kscript-venue-policy.util.js +74 -32
  65. package/dist/utility/chart/market-session-schedule.util.d.ts +10 -0
  66. package/dist/utility/chart/market-session-schedule.util.js +16 -0
  67. package/dist/utility/chart/marketKind.util.d.ts +12 -10
  68. package/dist/utility/chart/marketKind.util.js +17 -7
  69. package/dist/utility/chart/om-panel-push-style.util.d.ts +7 -7
  70. package/dist/utility/chart/om-panel-push-style.util.js +17 -15
  71. package/dist/utility/chart/om-panel.util.js +6 -6
  72. package/dist/utility/chart/opra-read-access.leaf.d.ts +5 -3
  73. package/dist/utility/chart/opra-read-access.leaf.js +5 -3
  74. package/dist/utility/chart/profile-block-size.util.d.ts +16 -0
  75. package/dist/utility/chart/profile-block-size.util.js +7 -0
  76. package/dist/utility/chart/quote-perp.leaf.d.ts +17 -0
  77. package/dist/utility/chart/quote-perp.leaf.js +20 -0
  78. package/dist/utility/chart/rth-session.util.d.ts +3 -2
  79. package/dist/utility/chart/rth-session.util.js +2 -1
  80. package/dist/utility/chart/window-geometry.leaf.d.ts +8 -0
  81. package/dist/utility/chart/window-geometry.leaf.js +22 -6
  82. package/dist/utility/chart/wrun-run-result.util.d.ts +17 -0
  83. package/dist/utility/chart/wrun-run-result.util.js +145 -7
  84. package/dist/utility/common/transformations.util.d.ts +7 -0
  85. package/dist/utility/common/transformations.util.js +11 -0
  86. package/dist/utility/options/option-bar-anchor.util.d.ts +145 -0
  87. package/dist/utility/options/option-bar-anchor.util.js +340 -0
  88. package/dist/utility/options/option-venue.util.d.ts +21 -3
  89. package/dist/utility/options/option-venue.util.js +30 -3
  90. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
  91. package/dist/utility/wrun/derived-roots.util.d.ts +213 -0
  92. package/dist/utility/wrun/derived-roots.util.js +471 -0
  93. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +41 -6
  94. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +89 -19
  95. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +9 -4
  96. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +47 -6
  97. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +5 -3
  98. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +6 -4
  99. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +2 -2
  100. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +5 -1
  101. package/dist/utility/wrun/sources/lanes/option_daily.js +5 -2
  102. package/dist/utility/wrun/sources/lanes/options_flow.js +5 -2
  103. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +64 -19
  104. package/dist/utility/wrun/sources/opra-option-lanes.util.js +105 -35
  105. package/dist/utility/wrun/sources/row-lane-registry.js +3 -2
  106. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +2 -1
  107. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +9 -3
  108. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +15 -6
  109. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +14 -0
  110. package/dist/utility/wrun/sources/row-lanes/option_prints.js +82 -13
  111. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +17 -4
  112. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +55 -8
  113. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +95 -14
  114. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +5 -2
  115. package/dist/utility/wrun/sources/row-lanes/option_surface.js +7 -3
  116. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -0
  117. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +35 -14
  118. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +70 -20
  119. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +64 -0
  120. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +89 -0
  121. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +45 -1
  122. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +114 -6
  123. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +56 -5
  124. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +224 -26
  125. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +822 -58
  126. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +16 -3
  127. package/dist/utility/wrun/wrun-batched-marks.util.js +30 -19
  128. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +37 -9
  129. package/dist/utility/wrun/wrun-batched-readout.util.js +61 -15
  130. package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +12 -0
  131. package/dist/utility/wrun/wrun-builtin-twin.util.js +21 -0
  132. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -0
  133. package/dist/utility/wrun/wrun-cell-capacity.leaf.d.ts +66 -0
  134. package/dist/utility/wrun/wrun-cell-capacity.leaf.js +86 -0
  135. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +192 -13
  136. package/dist/utility/wrun/wrun-chart-market-facts.util.js +437 -55
  137. package/dist/utility/wrun/wrun-color-facts.util.d.ts +19 -9
  138. package/dist/utility/wrun/wrun-color-facts.util.js +24 -14
  139. package/dist/utility/wrun/wrun-color-settings.util.d.ts +15 -4
  140. package/dist/utility/wrun/wrun-color-settings.util.js +31 -12
  141. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.d.ts +17 -0
  142. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.js +9 -0
  143. package/dist/utility/wrun/wrun-download-meter.util.d.ts +107 -0
  144. package/dist/utility/wrun/wrun-download-meter.util.js +134 -0
  145. package/dist/utility/wrun/wrun-download-plan.util.d.ts +99 -0
  146. package/dist/utility/wrun/wrun-download-plan.util.js +118 -0
  147. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +11 -3
  148. package/dist/utility/wrun/wrun-draft-legend-note.util.js +26 -4
  149. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +6 -1
  150. package/dist/utility/wrun/wrun-draft-overlay.util.js +23 -3
  151. package/dist/utility/wrun/wrun-frames.d.ts +27 -6
  152. package/dist/utility/wrun/wrun-frames.js +78 -15
  153. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
  154. package/dist/utility/wrun/wrun-hosted-wire-caps.js +7 -0
  155. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +7 -1
  156. package/dist/utility/wrun/wrun-hosted-wire.util.js +12 -2
  157. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +51 -21
  158. package/dist/utility/wrun/wrun-hud-looks.util.js +74 -28
  159. package/dist/utility/wrun/wrun-latest-snapshot.d.ts +11 -0
  160. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +8 -6
  161. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +8 -6
  162. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -2
  163. package/dist/utility/wrun/wrun-live-intake.util.d.ts +19 -9
  164. package/dist/utility/wrun/wrun-live-intake.util.js +213 -45
  165. package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -0
  166. package/dist/utility/wrun/wrun-live-tick.util.js +246 -49
  167. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.d.ts +53 -0
  168. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.js +162 -0
  169. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +205 -48
  170. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +277 -34
  171. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +51 -7
  172. package/dist/utility/wrun/wrun-market-size-defaults.util.js +340 -56
  173. package/dist/utility/wrun/wrun-opra-lane.util.d.ts +17 -4
  174. package/dist/utility/wrun/wrun-opra-lane.util.js +6 -4
  175. package/dist/utility/wrun/wrun-option-prints.util.d.ts +41 -2
  176. package/dist/utility/wrun/wrun-option-prints.util.js +80 -13
  177. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.d.ts +31 -0
  178. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.js +119 -0
  179. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +26 -6
  180. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +50 -11
  181. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +109 -19
  182. package/dist/utility/wrun/wrun-option-strike-flow.util.js +222 -61
  183. package/dist/utility/wrun/wrun-option-views.util.d.ts +96 -18
  184. package/dist/utility/wrun/wrun-option-views.util.js +246 -51
  185. package/dist/utility/wrun/wrun-options-stop.util.d.ts +2 -1
  186. package/dist/utility/wrun/wrun-options-stop.util.js +3 -2
  187. package/dist/utility/wrun/wrun-output-style.util.d.ts +6 -2
  188. package/dist/utility/wrun/wrun-output-style.util.js +20 -2
  189. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +20 -0
  190. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +31 -14
  191. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +22 -0
  192. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +10 -1
  193. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +52 -4
  194. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +7 -0
  195. package/dist/utility/wrun/wrun-overlay-recovery.util.js +25 -1
  196. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +7 -1
  197. package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
  198. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +134 -37
  199. package/dist/utility/wrun/wrun-overlay-run.util.js +1118 -254
  200. package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +4 -4
  201. package/dist/utility/wrun/wrun-pack-widths.leaf.js +4 -4
  202. package/dist/utility/wrun/wrun-pack.util.d.ts +7 -3
  203. package/dist/utility/wrun/wrun-pack.util.js +20 -9
  204. package/dist/utility/wrun/wrun-pane-format.util.d.ts +2 -1
  205. package/dist/utility/wrun/wrun-pane-format.util.js +7 -3
  206. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +9 -0
  207. package/dist/utility/wrun/wrun-panel-mount.util.js +63 -13
  208. package/dist/utility/wrun/wrun-panel-style.util.d.ts +37 -24
  209. package/dist/utility/wrun/wrun-panel-style.util.js +100 -29
  210. package/dist/utility/wrun/wrun-param-map.util.d.ts +15 -11
  211. package/dist/utility/wrun/wrun-param-map.util.js +13 -5
  212. package/dist/utility/wrun/wrun-param-values.util.d.ts +21 -3
  213. package/dist/utility/wrun/wrun-param-values.util.js +6 -0
  214. package/dist/utility/wrun/wrun-pin-spelling.util.js +12 -11
  215. package/dist/utility/wrun/wrun-prefix-lanes.util.js +2 -2
  216. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +50 -0
  217. package/dist/utility/wrun/wrun-refusal-surface.util.js +68 -0
  218. package/dist/utility/wrun/wrun-refusal.util.js +10 -1
  219. package/dist/utility/wrun/wrun-refused-latest.util.d.ts +10 -0
  220. package/dist/utility/wrun/wrun-refused-latest.util.js +12 -0
  221. package/dist/utility/wrun/wrun-row-source.d.ts +11 -0
  222. package/dist/utility/wrun/wrun-run-interval.util.d.ts +4 -2
  223. package/dist/utility/wrun/wrun-run-interval.util.js +9 -6
  224. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +52 -1
  225. package/dist/utility/wrun/wrun-script-inputs.util.js +112 -4
  226. package/dist/utility/wrun/wrun-setting-words.util.d.ts +7 -3
  227. package/dist/utility/wrun/wrun-setting-words.util.js +13 -5
  228. package/dist/utility/wrun/wrun-socket-row-source.d.ts +27 -2
  229. package/dist/utility/wrun/wrun-socket-row-source.js +113 -8
  230. package/dist/utility/wrun/wrun-source-rows.util.d.ts +9 -1
  231. package/dist/utility/wrun/wrun-source-rows.util.js +108 -43
  232. package/dist/utility/wrun/wrun-style-words.util.js +6 -4
  233. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +3 -2
  234. package/dist/utility/wrun/wrun-table-chrome.util.js +19 -11
  235. package/dist/utility/wrun/wrun-tape-per-order.util.d.ts +2 -0
  236. package/dist/utility/wrun/wrun-tape-per-order.util.js +26 -0
  237. package/dist/utility/wrun/wrun-tape-source.util.d.ts +126 -50
  238. package/dist/utility/wrun/wrun-tape-source.util.js +193 -68
  239. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +7 -5
  240. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +8 -6
  241. package/dist/utils/replay/replay-buffer-math.d.ts +53 -2
  242. package/dist/utils/replay/replay-buffer-math.js +227 -20
  243. package/dist/workers/utils/volume-profile.worker.util.d.ts +4 -1
  244. package/dist/workers/utils/volume-profile.worker.util.js +5 -2
  245. package/dist/workers/wrun/wrun-abi-host.js +3 -2
  246. package/package.json +5 -5
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The ONE switch of the per-order floor (BT-ORDER-FLOOR): whether a tape on a venue is judged per aggressor ORDER. One
3
+ * aggressor order on a CME Group venue fills as many small fills on one exchange stamp and side; Big Trades' "Combine
4
+ * fills: One order" and the kScript trades template add them back into one trade, so a floor applied to each fill
5
+ * before they arrive drops the fills of a big order one by one (the 147-contract NQZ6 buy of 2026-10-23 14:31:54Z, 45
6
+ * fills of 1 to 17 lots, drew as its two 17-lot fills).
7
+ *
8
+ * True, everything moves together: the K_TRADES control asks the history read's per-order floor (the payload's
9
+ * `perOrder`: the worker sends `minAmountPerOrder` on both lanes and keeps every row), the live raw TRADE prints pass
10
+ * the order gate (live-trades-order-gate.util) at the wrun intake's enqueue and the kScript fan-out instead of a floor
11
+ * per fill, the fold judges no single fill, the row builder hands the cell adapter the tape ask without its floor, and
12
+ * Big Trades' contracts floor defaults by the product root (wrun-market-size-defaults.leaf). False: every one of them
13
+ * exactly as before (the per-fill floors, the floored ask, the package's 10 and 100). The switch flips in the same roll
14
+ * as the gateway cutover, so a user never sees half of it (history per order beside live per fill).
15
+ *
16
+ * It holds when the venue is one the gateway judges per order (live-trades-merge.util `tradesFloorPerOrder`: the CME
17
+ * Group venues) and the host says the switch is on (`WrunChartHostEnv.tapePerOrder`: web's build flag
18
+ * VITE_WRUN_TAPE_PER_ORDER, off by default). When the instrument registry names the plane (`largeTradePerOrder` beside
19
+ * `largeTradeMinContracts`), its answer replaces the host flag here, and nowhere else.
20
+ */
21
+ import { wrunHostTapePerOrder } from '../../host-env.js';
22
+ import { tradesFloorPerOrder } from '../../kscript-data/controls/live-trades-merge.util.js';
23
+ /** Whether a tape on `exchange` is judged per aggressor order (above). */
24
+ export function wrunTapePerOrder(exchange) {
25
+ return tradesFloorPerOrder(exchange) && wrunHostTapePerOrder();
26
+ }
@@ -1,37 +1,59 @@
1
1
  /**
2
- * The `tape` input source's browser-side contract (WRUN-BIG-TRADES-PLAN C1): how a package's
3
- * `inputSources.<name> = { source: "tape", min_size, history }` becomes the ONE acquisition the
4
- * K_TRADES large lane fetches and the live intake folds. Pure: no store, no chart, no fetch; the
5
- * run pass calls it at its head, before any lane fetch, so every refusal here lands by name and
6
- * at zero fetches.
2
+ * The `tape` input source's browser-side contract (WRUN-BIG-TRADES-PLAN C1, and C-DOLLAR for the dollar floor): how a
3
+ * package's `inputSources.<name> = { source: "tape", min_size | min_value, history }` becomes the ONE acquisition the
4
+ * K_TRADES large lane fetches and the live intake folds. Pure: no store, no chart, no fetch; the run pass calls it at
5
+ * its head, before any lane fetch, so every refusal here lands by name and at zero fetches.
7
6
  *
8
- * - `min_size: number | string`. A number literal is the smallest print size served (base units:
9
- * contracts on futures, coins on crypto). A string names a declared numeric `param`, resolved
10
- * from the run's CURRENT param values (`wrunParamValuesFromSettings`, the values `init()`
11
- * receives, so a settings edit moves the threshold with the module). The resolved value must be
12
- * finite and above zero, else the run refuses `wrun_tape_min_size_invalid` naming the input and
13
- * the param. `min_size` rides the wire as the gateway's `minAmount` (the K_TRADES worker), so an
14
- * unfiltered tape is never requested. The table's own floor ($10k quote on USD-quoted markets)
15
- * is a fact a package cannot lower: a `min_size` below it is served at the floor (documented,
16
- * never enforced here).
17
- * - `history: "0" | <duration>`: `"0"` (the default) is the live edge only; a duration
18
- * `^\d+(s|m|h|d)$` seeds that much history from TRADE_LARGE, at most `WRUN_TAPE_HISTORY_MAX_SEC`
19
- * (30 days); a zero-length spelling ("0m") is the live edge too. Anything else refuses
20
- * `wrun_tape_history_invalid`. The lane serves `min(history, the chart's loaded window)`, and no
21
- * more than the gateway's bar limit lets it today (`WRUN_TAPE_HISTORY_SERVED_MAX_SEC`: 15,000
22
- * one-minute points, about 10.4 days; k-trades.control.ts opens the ask at the first bar after it),
23
- * so the acquisition's `historySeconds` is the history served, capped there; `history` stays the
24
- * declared spelling the K_TRADES payload carries.
25
- * - Every tape input of a package must be celled (`cellType: "array"`) and resolve to the SAME
26
- * `min_size` and `history`: the browser lane serves one tape acquisition per package (one
27
- * K_TRADES fetch, one live fold), and silently serving a second input at the first input's
28
- * threshold would be a wrong-but-plausible block. Two inputs that differ refuse by name.
29
- * The om daemon shares the vocabulary (`wrun_tape_min_size_invalid`, `wrun_tape_history_invalid`).
7
+ * - A tape declares exactly ONE floor, `min_size` or `min_value`; both or neither refuses `wrun_tape_floor_invalid`
8
+ * naming the input. Each is a number literal or a string naming a declared numeric `param`, resolved from the run's
9
+ * CURRENT param values (`wrunParamValuesFromSettings`, the values `init()` receives, so a settings edit moves the
10
+ * floor with the module). The resolved value must be finite and above zero, else the run refuses by the floor's own
11
+ * code (`wrun_tape_min_size_invalid`, `wrun_tape_min_value_invalid`) naming the input and the param.
12
+ * - `min_size` is the smallest print size served in the venue's RAW STORED unit (coins on Binance, contracts on
13
+ * gate.io futures and OKX swaps, USD contracts on inverse venues, lots on CME). It rides the wire as the gateway's
14
+ * `minAmount` (the K_TRADES worker), and a cell's `size` is the raw amount. It keeps @om-core/big-trades 0.5.0
15
+ * running byte for byte; a raw floor means a different thing on every venue whose unit differs, which is why the
16
+ * dollar floor exists.
17
+ * - `min_value` is the smallest print served by its value in US dollars. It rides the wire as the gateway's
18
+ * `minQuoteAmount` (never beside a `minAmount`), and a cell's `size` is then the print's dollar value (the gateway's
19
+ * `quoteAmount` for a history row, the market's dollar unit times price times size for a live print,
20
+ * live-trades-merge.util `tradesTapeCellSize`), so a package compares and draws in the same unit as its floor. The
21
+ * cell layout is unchanged (`[tsOffsetMs, price, size, side]`).
22
+ * - The table's own floor ($10k quote on USD-quoted markets, a contracts floor per CME Group root) is a fact a package
23
+ * cannot lower: a floor below it is served at the table's floor (documented, never enforced here).
24
+ * - `history: "0" | <duration>`: `"0"` (the default) is the live edge only; a duration `^\d+(s|m|h|d)$` seeds that much
25
+ * history from TRADE_LARGE, at most `WRUN_TAPE_HISTORY_MAX_SEC` (30 days); a zero-length spelling ("0m") is the live
26
+ * edge too. Anything else refuses `wrun_tape_history_invalid`. The lane serves `min(history, the chart's loaded
27
+ * window)`, and no more than the gateway's bar limit lets it today (`WRUN_TAPE_HISTORY_SERVED_MAX_SEC`: 15,000
28
+ * one-minute points, about 10.4 days; k-trades.control.ts opens the ask at the first bar after it), so the
29
+ * acquisition's `historySeconds` is the history served, capped there; `history` stays the declared spelling the
30
+ * K_TRADES payload carries.
31
+ * - Every tape input the run ASKS must be celled (`cellType: "array"`) and resolve to the SAME floor (facet and
32
+ * value) and `history`: the browser lane serves one tape acquisition per package (one K_TRADES fetch, one live
33
+ * fold), and silently serving a second input at the first input's floor would be a wrong-but-plausible block. Two
34
+ * asked inputs that differ refuse by name.
35
+ * - A tape the chart's market does not ask (kit 0.95.0: its `needed_by` leaves the market's size unit out, so the run's
36
+ * sheet on the market marks it `undemanded`, wrunSheetWithLaneDemand) is no part of the acquisition: no floor, no
37
+ * history, no refusal and no setting words read it (`isWrunAskedTapeSource`), and every row reads zero cells for it
38
+ * (the row builder's empty block). Big Trades 0.8.0 floors CME in contracts (`min_size` on `tape_contracts`, asked
39
+ * on size unit 3) and every other market in dollars (`min_value` on `tape`, asked on 0, 1 and 2): one acquisition
40
+ * on every market, two floors in the sheet.
41
+ * The om daemon shares the vocabulary (`wrun_tape_floor_invalid`, `wrun_tape_min_size_invalid`,
42
+ * `wrun_tape_min_value_invalid`, `wrun_tape_history_invalid`).
30
43
  */
31
44
  import type { WrunIndicatorMetadata, WrunInputSource } from '../../interfaces/wrun-runtime.interface.js';
32
- /** A tape `min_size` that resolves to nothing servable (absent, a param the package does not
33
- * declare, non-finite or not above zero). */
45
+ /** A tape `min_size` that resolves to nothing servable (a param the package does not declare, non-finite or not
46
+ * above zero). */
34
47
  export declare const WRUN_TAPE_MIN_SIZE_INVALID_CODE = "wrun_tape_min_size_invalid";
48
+ /** A tape `min_value` that resolves to nothing servable (a param the package does not declare, non-finite or not
49
+ * above zero): C-DOLLAR's refusal, naming the input and the param. */
50
+ export declare const WRUN_TAPE_MIN_VALUE_INVALID_CODE = "wrun_tape_min_value_invalid";
51
+ /** A tape input declaring both floors or neither (C-DOLLAR): a tape serves exactly one floor. */
52
+ export declare const WRUN_TAPE_FLOOR_INVALID_CODE = "wrun_tape_floor_invalid";
53
+ /** A dollar tape (C-DOLLAR's `min_value`) on a market whose dollar unit no read can ever prove (a quote that is no
54
+ * dollar, a venue or a contract with no point value): none of its prints could be valued, so the run refuses it by
55
+ * name before any fetch. The om daemon's code for the same refusal (packages/sdk wrun-host refusals). */
56
+ export declare const WRUN_TAPE_VALUE_UNPROVEN_CODE = "wrun_tape_value_unproven";
35
57
  /** A tape `history` outside the contract ("0" or `^\d+(s|m|h|d)$` at most 30 days). */
36
58
  export declare const WRUN_TAPE_HISTORY_INVALID_CODE = "wrun_tape_history_invalid";
37
59
  /** A tape input on a chart interval the lane does not serve (a one-second or any sub-minute chart, a
@@ -50,42 +72,96 @@ export declare const WRUN_TAPE_HISTORY_MAX_SEC = 2592000;
50
72
  * unaggregated read (TRADES_LARGE_BAR_LIMIT_SEC, about 10.4 days). A longer declared history (up to
51
73
  * the 30-day contract) is served from that horizon. */
52
74
  export declare const WRUN_TAPE_HISTORY_SERVED_MAX_SEC: number;
53
- /** The one tape acquisition a package resolves to: the K_TRADES payload extras the history fetch
54
- * and the reconcile ride (`minSize` in base units, `history` as declared), plus the inputs it
55
- * serves. */
56
- export interface WrunTapeAcquisition {
57
- minSize: number;
75
+ /** The two floor facets a tape input may declare, exactly one of them. */
76
+ export type WrunTapeFloorFacet = 'min_size' | 'min_value';
77
+ interface WrunTapeAcquisitionBase {
58
78
  history: string;
59
79
  /** The history served, in seconds: the declared one, capped at WRUN_TAPE_HISTORY_SERVED_MAX_SEC. */
60
80
  historySeconds: number;
61
81
  /** The tape inputs, by name, in declaration order. */
62
82
  inputNames: string[];
63
83
  }
84
+ /** The one tape acquisition a package resolves to: the K_TRADES payload extras the history fetch and the reconcile
85
+ * ride (exactly one floor: `minSize` in the raw stored unit, or `minValue` in US dollars; `history` as declared),
86
+ * plus the inputs it serves. */
87
+ export type WrunTapeAcquisition = WrunTapeAcquisitionBase & ({
88
+ minSize: number;
89
+ minValue?: undefined;
90
+ } | {
91
+ minValue: number;
92
+ minSize?: undefined;
93
+ });
94
+ /** Whether an input source is a tape the run asks: a `tape` source the run's sheet on the chart's market did not mark
95
+ * `undemanded` (wrunSheetWithLaneDemand, kit 0.95.0's `needed_by` on a secondary tape). THE predicate every reader
96
+ * of the package's tapes takes (the acquisition, its floor settings and words, the plan's floor params, the live
97
+ * refusals): an unasked tape has no lane, and its rows read zero cells. */
98
+ export declare function isWrunAskedTapeSource<Source extends Pick<WrunInputSource, 'source' | 'undemanded'>>(source: Source | null | undefined): source is Source & {
99
+ source: 'tape';
100
+ };
64
101
  /** The declared `history` as the lane reads it: "0" when absent. */
65
102
  export declare function wrunTapeHistoryOf(source: Pick<WrunInputSource, 'history'>): string;
66
103
  /** The seconds a valid tape history declares (0 for the live edge), or a refusal by name. */
67
104
  export declare function parseWrunTapeHistory(metadata: Pick<WrunIndicatorMetadata, 'id'>, inputName: string, history: string): number;
68
- /** The smallest print size a tape input serves: the literal, or the named param's current value;
69
- * refused by name when it is not finite and above zero (an unfiltered tape is the one request the
70
- * lane never makes). */
105
+ /** The floor facet a tape source declares when it declares exactly one, else undefined (both, or neither). */
106
+ export declare function wrunTapeFloorFacetOf(source: Pick<WrunInputSource, 'min_size' | 'min_value'>): WrunTapeFloorFacet | undefined;
107
+ /** The name of the param a tape source's floor reads (its one floor facet's string), else undefined (a literal floor,
108
+ * or a source declaring both floors or neither). */
109
+ export declare function wrunTapeFloorParamOf(source: Pick<WrunInputSource, 'min_size' | 'min_value'>): string | undefined;
110
+ /** The smallest print size a tape input serves (raw stored units): the literal, or the named param's current value;
111
+ * refused by name (`wrun_tape_min_size_invalid`) when it is not finite and above zero. */
71
112
  export declare function resolveWrunTapeMinSize(metadata: Pick<WrunIndicatorMetadata, 'id' | 'params'>, inputName: string, source: Pick<WrunInputSource, 'min_size'>, paramValues: Readonly<Record<string, number>>): number;
113
+ /** The smallest print value a tape input serves (US dollars): the literal, or the named param's current value;
114
+ * refused by name (`wrun_tape_min_value_invalid`, naming the input and the param) when it is not finite and above
115
+ * zero. */
116
+ export declare function resolveWrunTapeMinValue(metadata: Pick<WrunIndicatorMetadata, 'id' | 'params'>, inputName: string, source: Pick<WrunInputSource, 'min_value'>, paramValues: Readonly<Record<string, number>>): number;
117
+ /** A tape input's one floor, by its facet: refused `wrun_tape_floor_invalid` naming the input when it declares both
118
+ * floors or neither, else by the facet's own code when the value is not servable. */
119
+ export declare function resolveWrunTapeFloor(metadata: Pick<WrunIndicatorMetadata, 'id' | 'params'>, inputName: string, source: Pick<WrunInputSource, 'min_size' | 'min_value'>, paramValues: Readonly<Record<string, number>>): {
120
+ facet: WrunTapeFloorFacet;
121
+ value: number;
122
+ };
123
+ /** The floor an acquisition asks at, in its own unit (raw stored units under `min_size`, dollars under `min_value`). */
124
+ export declare function wrunTapeFloorOf(tape: Pick<WrunTapeAcquisition, 'minSize' | 'minValue'>): number;
125
+ /** The words a refusal states an acquisition's floor in: the raw number under `min_size`, a US dollar amount under
126
+ * `min_value` (`$500,000`). */
127
+ export declare function wrunTapeFloorWords(tape: Pick<WrunTapeAcquisition, 'minSize' | 'minValue'> | undefined): string;
72
128
  /**
73
- * Resolve every declared tape input against the run's param values into the package's one tape
74
- * acquisition, refusing by name before any fetch; undefined when the package declares no tape
75
- * input.
129
+ * Resolve every tape input the run asks (`isWrunAskedTapeSource`: the run's sheet on the chart's market, its
130
+ * unasked tapes marked) against the run's param values into the package's one tape acquisition, refusing by name
131
+ * before any fetch; undefined when the package asks no tape input here.
76
132
  */
77
133
  export declare function resolveWrunTapeAcquisition(metadata: Pick<WrunIndicatorMetadata, 'id' | 'params' | 'inputs' | 'inputSources'>, paramValues: Readonly<Record<string, number>>): WrunTapeAcquisition | undefined;
78
- /** The words of the setting a tape's floor reads: the label (else the name) of the param its first tape input's
79
- * `min_size` names, or `min_size` itself for a literal floor (a source edit raises it). */
134
+ /** The words of the setting a tape's floor reads: the label (else the name) of the param its first asked tape input's
135
+ * floor (`min_size` or `min_value`) names, or the floor facet itself for a literal floor (a source edit raises it).
136
+ * An unasked tape's floor is no setting the chart's tape reads (Big Trades 0.8.0 on CME names Min size, the contracts
137
+ * floor, never Min value). */
80
138
  export declare function wrunTapeFloorSettingWords(metadata: Pick<WrunIndicatorMetadata, 'params' | 'inputSources'>): string;
81
139
  /**
82
140
  * The settings a row build hands the shared host's plan for a param-bound floor
83
- * (`WrunChartSourceRows.settings`): the floor the lane's acquisition was asked at, under the name
84
- * of every param a tape input's `min_size` names. The host resolves that floor itself from the
85
- * settings it is handed (its planTapeFloors), so the plan's tape ask carries the floor the run
86
- * resolved from the overlay's current settings (`resolveWrunTapeAcquisition`): a full run hands its
87
- * acquisition's floor, a live build its session's (`context.acquisition.tape`), so a tail, a carry
88
- * advance or a reseed plans the ask its full run planned whatever the settings say meanwhile (a
89
- * refused settings run keeps the session). Undefined without a finite floor or a bound param.
141
+ * (`WrunChartSourceRows.settings`): the floor the lane's acquisition was asked at (`wrunTapeFloorOf`, in its own
142
+ * unit), under the name of every param a tape input's floor (`min_size` or `min_value`) names. The host resolves that
143
+ * floor itself from the settings it is handed (its planTapeFloors; a `min_value` tape is planned as the kit's floor
144
+ * facet over the dollar cells, wrun-source-rows.util `wrunPlannedSheet`), so the plan's tape ask carries the floor the
145
+ * run resolved from the overlay's current settings (`resolveWrunTapeAcquisition`): a full run hands its acquisition's
146
+ * floor, a live build its session's (`context.acquisition.tape`), so a tail, a carry advance or a reseed plans the ask
147
+ * its full run planned whatever the settings say meanwhile (a refused settings run keeps the session). An unasked
148
+ * tape's param is left out: its floor is in another unit, and the plan reads no cells for it. Undefined without a
149
+ * finite floor or a bound param.
150
+ */
151
+ export declare function wrunTapeFloorSettings(metadata: Pick<WrunIndicatorMetadata, 'inputSources'>, floorValue: unknown): Record<string, number> | undefined;
152
+ /** The floor a recorded tape acquisition (a K_TRADES payload: the full run's `fetchLane` extras, the live context's
153
+ * `acquisition.tape`) asks at, in its own unit: `minValue` when it floors by dollars, else `minSize`. */
154
+ export declare function wrunTapeAcquisitionFloor(acquisition: {
155
+ minSize?: unknown;
156
+ minValue?: unknown;
157
+ } | undefined): unknown;
158
+ /**
159
+ * The K_TRADES payload extras of a tape acquisition (the run pass's `fetchLane('trades', 'tp', ...)`, which the run
160
+ * records as the lane's acquisition: the history fetch, the reconcile's re-ask and the live fold read the SAME
161
+ * payload): the large lane, the declared history and the one floor. A dollar floor also carries `valuePerUnit`, the US
162
+ * dollars one price unit times one size unit of a live print is worth on the chart's market (the run head's
163
+ * `wrunMarketDollarUnit`); without it no live print can be priced and none folds (the history rows carry the gateway's
164
+ * own dollar value). A raw floor carries exactly what it always did, so 0.5.0's payload is unchanged.
90
165
  */
91
- export declare function wrunTapeFloorSettings(metadata: Pick<WrunIndicatorMetadata, 'inputSources'>, minSize: unknown): Record<string, number> | undefined;
166
+ export declare function wrunTapeLaneExtras(tape: WrunTapeAcquisition, valuePerUnit: number | undefined): Record<string, unknown>;
167
+ export {};
@@ -1,37 +1,59 @@
1
1
  /**
2
- * The `tape` input source's browser-side contract (WRUN-BIG-TRADES-PLAN C1): how a package's
3
- * `inputSources.<name> = { source: "tape", min_size, history }` becomes the ONE acquisition the
4
- * K_TRADES large lane fetches and the live intake folds. Pure: no store, no chart, no fetch; the
5
- * run pass calls it at its head, before any lane fetch, so every refusal here lands by name and
6
- * at zero fetches.
2
+ * The `tape` input source's browser-side contract (WRUN-BIG-TRADES-PLAN C1, and C-DOLLAR for the dollar floor): how a
3
+ * package's `inputSources.<name> = { source: "tape", min_size | min_value, history }` becomes the ONE acquisition the
4
+ * K_TRADES large lane fetches and the live intake folds. Pure: no store, no chart, no fetch; the run pass calls it at
5
+ * its head, before any lane fetch, so every refusal here lands by name and at zero fetches.
7
6
  *
8
- * - `min_size: number | string`. A number literal is the smallest print size served (base units:
9
- * contracts on futures, coins on crypto). A string names a declared numeric `param`, resolved
10
- * from the run's CURRENT param values (`wrunParamValuesFromSettings`, the values `init()`
11
- * receives, so a settings edit moves the threshold with the module). The resolved value must be
12
- * finite and above zero, else the run refuses `wrun_tape_min_size_invalid` naming the input and
13
- * the param. `min_size` rides the wire as the gateway's `minAmount` (the K_TRADES worker), so an
14
- * unfiltered tape is never requested. The table's own floor ($10k quote on USD-quoted markets)
15
- * is a fact a package cannot lower: a `min_size` below it is served at the floor (documented,
16
- * never enforced here).
17
- * - `history: "0" | <duration>`: `"0"` (the default) is the live edge only; a duration
18
- * `^\d+(s|m|h|d)$` seeds that much history from TRADE_LARGE, at most `WRUN_TAPE_HISTORY_MAX_SEC`
19
- * (30 days); a zero-length spelling ("0m") is the live edge too. Anything else refuses
20
- * `wrun_tape_history_invalid`. The lane serves `min(history, the chart's loaded window)`, and no
21
- * more than the gateway's bar limit lets it today (`WRUN_TAPE_HISTORY_SERVED_MAX_SEC`: 15,000
22
- * one-minute points, about 10.4 days; k-trades.control.ts opens the ask at the first bar after it),
23
- * so the acquisition's `historySeconds` is the history served, capped there; `history` stays the
24
- * declared spelling the K_TRADES payload carries.
25
- * - Every tape input of a package must be celled (`cellType: "array"`) and resolve to the SAME
26
- * `min_size` and `history`: the browser lane serves one tape acquisition per package (one
27
- * K_TRADES fetch, one live fold), and silently serving a second input at the first input's
28
- * threshold would be a wrong-but-plausible block. Two inputs that differ refuse by name.
29
- * The om daemon shares the vocabulary (`wrun_tape_min_size_invalid`, `wrun_tape_history_invalid`).
7
+ * - A tape declares exactly ONE floor, `min_size` or `min_value`; both or neither refuses `wrun_tape_floor_invalid`
8
+ * naming the input. Each is a number literal or a string naming a declared numeric `param`, resolved from the run's
9
+ * CURRENT param values (`wrunParamValuesFromSettings`, the values `init()` receives, so a settings edit moves the
10
+ * floor with the module). The resolved value must be finite and above zero, else the run refuses by the floor's own
11
+ * code (`wrun_tape_min_size_invalid`, `wrun_tape_min_value_invalid`) naming the input and the param.
12
+ * - `min_size` is the smallest print size served in the venue's RAW STORED unit (coins on Binance, contracts on
13
+ * gate.io futures and OKX swaps, USD contracts on inverse venues, lots on CME). It rides the wire as the gateway's
14
+ * `minAmount` (the K_TRADES worker), and a cell's `size` is the raw amount. It keeps @om-core/big-trades 0.5.0
15
+ * running byte for byte; a raw floor means a different thing on every venue whose unit differs, which is why the
16
+ * dollar floor exists.
17
+ * - `min_value` is the smallest print served by its value in US dollars. It rides the wire as the gateway's
18
+ * `minQuoteAmount` (never beside a `minAmount`), and a cell's `size` is then the print's dollar value (the gateway's
19
+ * `quoteAmount` for a history row, the market's dollar unit times price times size for a live print,
20
+ * live-trades-merge.util `tradesTapeCellSize`), so a package compares and draws in the same unit as its floor. The
21
+ * cell layout is unchanged (`[tsOffsetMs, price, size, side]`).
22
+ * - The table's own floor ($10k quote on USD-quoted markets, a contracts floor per CME Group root) is a fact a package
23
+ * cannot lower: a floor below it is served at the table's floor (documented, never enforced here).
24
+ * - `history: "0" | <duration>`: `"0"` (the default) is the live edge only; a duration `^\d+(s|m|h|d)$` seeds that much
25
+ * history from TRADE_LARGE, at most `WRUN_TAPE_HISTORY_MAX_SEC` (30 days); a zero-length spelling ("0m") is the live
26
+ * edge too. Anything else refuses `wrun_tape_history_invalid`. The lane serves `min(history, the chart's loaded
27
+ * window)`, and no more than the gateway's bar limit lets it today (`WRUN_TAPE_HISTORY_SERVED_MAX_SEC`: 15,000
28
+ * one-minute points, about 10.4 days; k-trades.control.ts opens the ask at the first bar after it), so the
29
+ * acquisition's `historySeconds` is the history served, capped there; `history` stays the declared spelling the
30
+ * K_TRADES payload carries.
31
+ * - Every tape input the run ASKS must be celled (`cellType: "array"`) and resolve to the SAME floor (facet and
32
+ * value) and `history`: the browser lane serves one tape acquisition per package (one K_TRADES fetch, one live
33
+ * fold), and silently serving a second input at the first input's floor would be a wrong-but-plausible block. Two
34
+ * asked inputs that differ refuse by name.
35
+ * - A tape the chart's market does not ask (kit 0.95.0: its `needed_by` leaves the market's size unit out, so the run's
36
+ * sheet on the market marks it `undemanded`, wrunSheetWithLaneDemand) is no part of the acquisition: no floor, no
37
+ * history, no refusal and no setting words read it (`isWrunAskedTapeSource`), and every row reads zero cells for it
38
+ * (the row builder's empty block). Big Trades 0.8.0 floors CME in contracts (`min_size` on `tape_contracts`, asked
39
+ * on size unit 3) and every other market in dollars (`min_value` on `tape`, asked on 0, 1 and 2): one acquisition
40
+ * on every market, two floors in the sheet.
41
+ * The om daemon shares the vocabulary (`wrun_tape_floor_invalid`, `wrun_tape_min_size_invalid`,
42
+ * `wrun_tape_min_value_invalid`, `wrun_tape_history_invalid`).
30
43
  */
31
44
  import { TRADES_LARGE_BAR_LIMIT_SEC } from '../../kscript-data/controls/live-trades-merge.util.js';
32
- /** A tape `min_size` that resolves to nothing servable (absent, a param the package does not
33
- * declare, non-finite or not above zero). */
45
+ /** A tape `min_size` that resolves to nothing servable (a param the package does not declare, non-finite or not
46
+ * above zero). */
34
47
  export const WRUN_TAPE_MIN_SIZE_INVALID_CODE = 'wrun_tape_min_size_invalid';
48
+ /** A tape `min_value` that resolves to nothing servable (a param the package does not declare, non-finite or not
49
+ * above zero): C-DOLLAR's refusal, naming the input and the param. */
50
+ export const WRUN_TAPE_MIN_VALUE_INVALID_CODE = 'wrun_tape_min_value_invalid';
51
+ /** A tape input declaring both floors or neither (C-DOLLAR): a tape serves exactly one floor. */
52
+ export const WRUN_TAPE_FLOOR_INVALID_CODE = 'wrun_tape_floor_invalid';
53
+ /** A dollar tape (C-DOLLAR's `min_value`) on a market whose dollar unit no read can ever prove (a quote that is no
54
+ * dollar, a venue or a contract with no point value): none of its prints could be valued, so the run refuses it by
55
+ * name before any fetch. The om daemon's code for the same refusal (packages/sdk wrun-host refusals). */
56
+ export const WRUN_TAPE_VALUE_UNPROVEN_CODE = 'wrun_tape_value_unproven';
35
57
  /** A tape `history` outside the contract ("0" or `^\d+(s|m|h|d)$` at most 30 days). */
36
58
  export const WRUN_TAPE_HISTORY_INVALID_CODE = 'wrun_tape_history_invalid';
37
59
  /** A tape input on a chart interval the lane does not serve (a one-second or any sub-minute chart, a
@@ -52,6 +74,19 @@ export const WRUN_TAPE_HISTORY_MAX_SEC = 2_592_000;
52
74
  export const WRUN_TAPE_HISTORY_SERVED_MAX_SEC = TRADES_LARGE_BAR_LIMIT_SEC;
53
75
  const WRUN_TAPE_HISTORY_PATTERN = /^(\d+)(s|m|h|d)$/;
54
76
  const WRUN_TAPE_HISTORY_UNIT_SEC = { s: 1, m: 60, h: 3600, d: 86_400 };
77
+ const WRUN_TAPE_FLOOR_FACETS = ['min_size', 'min_value'];
78
+ /** Each floor facet's refusal code and the words a refusal uses for what it floors. */
79
+ const WRUN_TAPE_FLOOR_RULES = {
80
+ min_size: { code: WRUN_TAPE_MIN_SIZE_INVALID_CODE, what: 'size' },
81
+ min_value: { code: WRUN_TAPE_MIN_VALUE_INVALID_CODE, what: 'value' },
82
+ };
83
+ /** Whether an input source is a tape the run asks: a `tape` source the run's sheet on the chart's market did not mark
84
+ * `undemanded` (wrunSheetWithLaneDemand, kit 0.95.0's `needed_by` on a secondary tape). THE predicate every reader
85
+ * of the package's tapes takes (the acquisition, its floor settings and words, the plan's floor params, the live
86
+ * refusals): an unasked tape has no lane, and its rows read zero cells. */
87
+ export function isWrunAskedTapeSource(source) {
88
+ return source?.source === 'tape' && source.undemanded !== true;
89
+ }
55
90
  /** The declared `history` as the lane reads it: "0" when absent. */
56
91
  export function wrunTapeHistoryOf(source) {
57
92
  return source.history === undefined ? '0' : String(source.history);
@@ -72,47 +107,95 @@ export function parseWrunTapeHistory(metadata, inputName, history) {
72
107
  }
73
108
  return seconds;
74
109
  }
75
- /** The smallest print size a tape input serves: the literal, or the named param's current value;
76
- * refused by name when it is not finite and above zero (an unfiltered tape is the one request the
77
- * lane never makes). */
78
- export function resolveWrunTapeMinSize(metadata, inputName, source, paramValues) {
79
- const declared = source.min_size;
110
+ /** The floor facet a tape source declares when it declares exactly one, else undefined (both, or neither). */
111
+ export function wrunTapeFloorFacetOf(source) {
112
+ const declared = WRUN_TAPE_FLOOR_FACETS.filter((facet) => source[facet] !== undefined);
113
+ return declared.length === 1 ? declared[0] : undefined;
114
+ }
115
+ /** The name of the param a tape source's floor reads (its one floor facet's string), else undefined (a literal floor,
116
+ * or a source declaring both floors or neither). */
117
+ export function wrunTapeFloorParamOf(source) {
118
+ const facet = wrunTapeFloorFacetOf(source);
119
+ const declared = facet === undefined ? undefined : source[facet];
120
+ return typeof declared === 'string' ? declared : undefined;
121
+ }
122
+ /** The value of one floor facet: the literal, or the named param's current value; refused by the facet's own code
123
+ * when it is not finite and above zero (an unfiltered tape is the one request the lane never makes). */
124
+ function resolveWrunTapeFloorFacet(metadata, inputName, facet, declared, paramValues) {
125
+ const { code, what } = WRUN_TAPE_FLOOR_RULES[facet];
80
126
  const refuse = (detail) => {
81
- throw new Error(`WRUN ${metadata.id}: input '${inputName}' (tape) ${detail} (${WRUN_TAPE_MIN_SIZE_INVALID_CODE})`);
127
+ throw new Error(`WRUN ${metadata.id}: input '${inputName}' (tape) ${detail} (${code})`);
82
128
  };
83
129
  if (typeof declared === 'string') {
84
130
  if (!metadata.params.some((param) => param.name === declared)) {
85
- return refuse(`binds min_size to param '${declared}', which the package does not declare: min_size is a positive ` +
131
+ return refuse(`binds ${facet} to param '${declared}', which the package does not declare: ${facet} is a positive ` +
86
132
  'number or the name of a numeric param');
87
133
  }
88
134
  const value = Number(paramValues[declared]);
89
135
  if (!Number.isFinite(value) || value <= 0) {
90
- return refuse(`binds min_size to param '${declared}', which is ${String(paramValues[declared])}: the smallest print ` +
91
- 'size must be finite and above zero');
136
+ return refuse(`binds ${facet} to param '${declared}', which is ${String(paramValues[declared])}: the smallest print ` +
137
+ `${what} must be finite and above zero`);
92
138
  }
93
139
  return value;
94
140
  }
95
141
  if (declared === undefined) {
96
- return refuse('declares no min_size: the smallest print size to serve is required (a positive number or the name of a ' +
142
+ return refuse(`declares no ${facet}: the smallest print ${what} to serve is required (a positive number or the name of a ` +
97
143
  'numeric param)');
98
144
  }
99
145
  const value = Number(declared);
100
146
  if (typeof declared !== 'number' || !Number.isFinite(value) || value <= 0) {
101
- return refuse(`declares min_size ${JSON.stringify(declared)}: the smallest print size must be finite and above zero`);
147
+ return refuse(`declares ${facet} ${JSON.stringify(declared)}: the smallest print ${what} must be finite and above zero`);
102
148
  }
103
149
  return value;
104
150
  }
151
+ /** The smallest print size a tape input serves (raw stored units): the literal, or the named param's current value;
152
+ * refused by name (`wrun_tape_min_size_invalid`) when it is not finite and above zero. */
153
+ export function resolveWrunTapeMinSize(metadata, inputName, source, paramValues) {
154
+ return resolveWrunTapeFloorFacet(metadata, inputName, 'min_size', source.min_size, paramValues);
155
+ }
156
+ /** The smallest print value a tape input serves (US dollars): the literal, or the named param's current value;
157
+ * refused by name (`wrun_tape_min_value_invalid`, naming the input and the param) when it is not finite and above
158
+ * zero. */
159
+ export function resolveWrunTapeMinValue(metadata, inputName, source, paramValues) {
160
+ return resolveWrunTapeFloorFacet(metadata, inputName, 'min_value', source.min_value, paramValues);
161
+ }
162
+ /** A tape input's one floor, by its facet: refused `wrun_tape_floor_invalid` naming the input when it declares both
163
+ * floors or neither, else by the facet's own code when the value is not servable. */
164
+ export function resolveWrunTapeFloor(metadata, inputName, source, paramValues) {
165
+ const facet = wrunTapeFloorFacetOf(source);
166
+ if (facet === undefined) {
167
+ const both = source.min_size !== undefined && source.min_value !== undefined;
168
+ throw new Error(`WRUN ${metadata.id}: input '${inputName}' (tape) declares ${both ? 'both min_size and min_value' : 'no floor'} ` +
169
+ `(${WRUN_TAPE_FLOOR_INVALID_CODE}): a tape takes exactly one floor, min_size (the raw stored unit) or ` +
170
+ 'min_value (US dollars)');
171
+ }
172
+ return { facet, value: resolveWrunTapeFloorFacet(metadata, inputName, facet, source[facet], paramValues) };
173
+ }
174
+ /** The floor an acquisition asks at, in its own unit (raw stored units under `min_size`, dollars under `min_value`). */
175
+ export function wrunTapeFloorOf(tape) {
176
+ return (tape.minValue ?? tape.minSize);
177
+ }
178
+ /** The words a refusal states an acquisition's floor in: the raw number under `min_size`, a US dollar amount under
179
+ * `min_value` (`$500,000`). */
180
+ export function wrunTapeFloorWords(tape) {
181
+ if (tape === undefined)
182
+ return '0';
183
+ if (tape.minValue === undefined)
184
+ return String(tape.minSize ?? 0);
185
+ return `$${tape.minValue.toLocaleString('en-US', { maximumFractionDigits: 2 })}`;
186
+ }
105
187
  /**
106
- * Resolve every declared tape input against the run's param values into the package's one tape
107
- * acquisition, refusing by name before any fetch; undefined when the package declares no tape
108
- * input.
188
+ * Resolve every tape input the run asks (`isWrunAskedTapeSource`: the run's sheet on the chart's market, its
189
+ * unasked tapes marked) against the run's param values into the package's one tape acquisition, refusing by name
190
+ * before any fetch; undefined when the package asks no tape input here.
109
191
  */
110
192
  export function resolveWrunTapeAcquisition(metadata, paramValues) {
111
193
  let acquisition;
194
+ let first;
112
195
  const inputs = [...metadata.inputs].sort((a, b) => a.index - b.index);
113
196
  for (const input of inputs) {
114
197
  const source = metadata.inputSources[input.name];
115
- if (!source || source.source !== 'tape')
198
+ if (!isWrunAskedTapeSource(source))
116
199
  continue;
117
200
  const name = input.name;
118
201
  if (input.cellType !== 'array') {
@@ -120,50 +203,92 @@ export function resolveWrunTapeAcquisition(metadata, paramValues) {
120
203
  }
121
204
  const history = wrunTapeHistoryOf(source);
122
205
  const historySeconds = Math.min(parseWrunTapeHistory(metadata, name, history), WRUN_TAPE_HISTORY_SERVED_MAX_SEC);
123
- const minSize = resolveWrunTapeMinSize(metadata, name, source, paramValues);
124
- if (acquisition === undefined) {
125
- acquisition = { minSize, history, historySeconds, inputNames: [name] };
206
+ const floor = resolveWrunTapeFloor(metadata, name, source, paramValues);
207
+ if (acquisition === undefined || first === undefined) {
208
+ first = floor;
209
+ acquisition =
210
+ floor.facet === 'min_size'
211
+ ? { minSize: floor.value, history, historySeconds, inputNames: [name] }
212
+ : { minValue: floor.value, history, historySeconds, inputNames: [name] };
126
213
  continue;
127
214
  }
128
- if (acquisition.minSize !== minSize || acquisition.historySeconds !== historySeconds) {
129
- throw new Error(`WRUN ${metadata.id}: input '${name}' (tape) resolves to min_size ${minSize} and history '${history}', but ` +
130
- `input '${acquisition.inputNames[0]}' resolves to min_size ${acquisition.minSize} and history ` +
215
+ if (first.facet !== floor.facet || first.value !== floor.value || acquisition.historySeconds !== historySeconds) {
216
+ throw new Error(`WRUN ${metadata.id}: input '${name}' (tape) resolves to ${floor.facet} ${floor.value} and history '${history}', ` +
217
+ `but input '${acquisition.inputNames[0]}' resolves to ${first.facet} ${first.value} and history ` +
131
218
  `'${acquisition.history}': the browser lane serves one tape acquisition per package`);
132
219
  }
133
220
  acquisition.inputNames.push(name);
134
221
  }
135
222
  return acquisition;
136
223
  }
137
- /** The words of the setting a tape's floor reads: the label (else the name) of the param its first tape input's
138
- * `min_size` names, or `min_size` itself for a literal floor (a source edit raises it). */
224
+ /** The words of the setting a tape's floor reads: the label (else the name) of the param its first asked tape input's
225
+ * floor (`min_size` or `min_value`) names, or the floor facet itself for a literal floor (a source edit raises it).
226
+ * An unasked tape's floor is no setting the chart's tape reads (Big Trades 0.8.0 on CME names Min size, the contracts
227
+ * floor, never Min value). */
139
228
  export function wrunTapeFloorSettingWords(metadata) {
229
+ let literal;
140
230
  for (const source of Object.values(metadata.inputSources)) {
141
- if (source?.source !== 'tape' || typeof source.min_size !== 'string')
231
+ if (!isWrunAskedTapeSource(source))
232
+ continue;
233
+ const paramName = wrunTapeFloorParamOf(source);
234
+ if (paramName === undefined) {
235
+ literal ??= wrunTapeFloorFacetOf(source);
142
236
  continue;
143
- const param = metadata.params.find((candidate) => candidate.name === source.min_size);
237
+ }
238
+ const param = metadata.params.find((candidate) => candidate.name === paramName);
144
239
  const label = typeof param?.label === 'string' ? param.label.trim() : '';
145
- return label !== '' ? label : source.min_size;
240
+ return label !== '' ? label : paramName;
146
241
  }
147
- return 'min_size';
242
+ return literal ?? 'min_size';
148
243
  }
149
244
  /**
150
245
  * The settings a row build hands the shared host's plan for a param-bound floor
151
- * (`WrunChartSourceRows.settings`): the floor the lane's acquisition was asked at, under the name
152
- * of every param a tape input's `min_size` names. The host resolves that floor itself from the
153
- * settings it is handed (its planTapeFloors), so the plan's tape ask carries the floor the run
154
- * resolved from the overlay's current settings (`resolveWrunTapeAcquisition`): a full run hands its
155
- * acquisition's floor, a live build its session's (`context.acquisition.tape`), so a tail, a carry
156
- * advance or a reseed plans the ask its full run planned whatever the settings say meanwhile (a
157
- * refused settings run keeps the session). Undefined without a finite floor or a bound param.
246
+ * (`WrunChartSourceRows.settings`): the floor the lane's acquisition was asked at (`wrunTapeFloorOf`, in its own
247
+ * unit), under the name of every param a tape input's floor (`min_size` or `min_value`) names. The host resolves that
248
+ * floor itself from the settings it is handed (its planTapeFloors; a `min_value` tape is planned as the kit's floor
249
+ * facet over the dollar cells, wrun-source-rows.util `wrunPlannedSheet`), so the plan's tape ask carries the floor the
250
+ * run resolved from the overlay's current settings (`resolveWrunTapeAcquisition`): a full run hands its acquisition's
251
+ * floor, a live build its session's (`context.acquisition.tape`), so a tail, a carry advance or a reseed plans the ask
252
+ * its full run planned whatever the settings say meanwhile (a refused settings run keeps the session). An unasked
253
+ * tape's param is left out: its floor is in another unit, and the plan reads no cells for it. Undefined without a
254
+ * finite floor or a bound param.
158
255
  */
159
- export function wrunTapeFloorSettings(metadata, minSize) {
160
- const floor = Number(minSize);
161
- if (minSize === undefined || minSize === null || !Number.isFinite(floor))
256
+ export function wrunTapeFloorSettings(metadata, floorValue) {
257
+ const floor = Number(floorValue);
258
+ if (floorValue === undefined || floorValue === null || !Number.isFinite(floor))
162
259
  return undefined;
163
260
  let settings;
164
261
  for (const source of Object.values(metadata.inputSources)) {
165
- if (source?.source === 'tape' && typeof source.min_size === 'string')
166
- (settings ??= {})[source.min_size] = floor;
262
+ if (!isWrunAskedTapeSource(source))
263
+ continue;
264
+ const paramName = wrunTapeFloorParamOf(source);
265
+ if (paramName !== undefined)
266
+ (settings ??= {})[paramName] = floor;
167
267
  }
168
268
  return settings;
169
269
  }
270
+ /** The floor a recorded tape acquisition (a K_TRADES payload: the full run's `fetchLane` extras, the live context's
271
+ * `acquisition.tape`) asks at, in its own unit: `minValue` when it floors by dollars, else `minSize`. */
272
+ export function wrunTapeAcquisitionFloor(acquisition) {
273
+ if (acquisition === undefined)
274
+ return undefined;
275
+ return acquisition.minValue !== undefined ? acquisition.minValue : acquisition.minSize;
276
+ }
277
+ /**
278
+ * The K_TRADES payload extras of a tape acquisition (the run pass's `fetchLane('trades', 'tp', ...)`, which the run
279
+ * records as the lane's acquisition: the history fetch, the reconcile's re-ask and the live fold read the SAME
280
+ * payload): the large lane, the declared history and the one floor. A dollar floor also carries `valuePerUnit`, the US
281
+ * dollars one price unit times one size unit of a live print is worth on the chart's market (the run head's
282
+ * `wrunMarketDollarUnit`); without it no live print can be priced and none folds (the history rows carry the gateway's
283
+ * own dollar value). A raw floor carries exactly what it always did, so 0.5.0's payload is unchanged.
284
+ */
285
+ export function wrunTapeLaneExtras(tape, valuePerUnit) {
286
+ if (tape.minValue === undefined)
287
+ return { minSize: tape.minSize, history: tape.history, large: true };
288
+ return {
289
+ minValue: tape.minValue,
290
+ ...(valuePerUnit !== undefined && Number.isFinite(valuePerUnit) && valuePerUnit > 0 ? { valuePerUnit } : {}),
291
+ history: tape.history,
292
+ large: true,
293
+ };
294
+ }