@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
@@ -1,23 +1,59 @@
1
1
  /**
2
- * The run head's market-scaled size defaults (the rule and the table: wrun-market-size-defaults.leaf). A package that
3
- * scales a param (Big Trades' Min size and Whale size) has its record moved to the chart market's defaults at the head
4
- * of every full run, before the tape is resolved, so the run, the settings panel's value, the reset icon and its
5
- * target, and the alert arm all read the one record:
2
+ * The run head's market-scaled size defaults (the rules and the table: wrun-market-size-defaults.leaf). A package that
3
+ * scales a param (Big Trades' Min value and Whale value, 0.5.0's Min size and Whale size) has its record moved to the
4
+ * chart market's defaults at the head of every full run, before the tape is resolved, so the run, the settings panel's
5
+ * value, the reset icon and its target, and the alert arm all read the one record:
6
6
  *
7
- * - The market's defaults are resolved once per mount and market (a page session's switch back to a market reads what
8
- * it read there the first time), so a value never flaps inside a session: the chart's own candles give the daily
9
- * base volume on a coin market whose candles are in base coins (the directory row places the coin, so a cold page
10
- * waits for it once); a market whose facts never yield one (contracts, shares, candles in another unit, a formula
11
- * chart, keyed apart from its market) reads the package's declared defaults, so the record never keeps the last
12
- * coin market's; a size unit not known yet or too few candles resolves nothing (the record stays, the next run asks
13
- * again).
7
+ * - The rules are the family the sheet declares (`wrunMarketScaledRulesOfSheet`: 0.6.0's dollar rule, 0.5.0's coin
8
+ * rule). The market's defaults are resolved once per mount, market and family (a page session's switch back to a
9
+ * market reads what it read there the first time), so a value never flaps inside a session: the chart's own candles
10
+ * give the daily volume, in dollars through the market's dollar unit (`wrunMarketDollarUnit`, the market facts, never
11
+ * a venue list) or in base coins on a coin market whose candles are in base coins (the directory row places the coin
12
+ * and names the quote, so a cold page waits for it once); a market whose facts never yield one (no point value, a
13
+ * quote that is no dollar, a formula chart keyed apart from its market; for the coin rule contracts, shares, candles
14
+ * in another unit) reads the package's declared defaults, so the record never keeps the last market's; a fact not
15
+ * known yet or too few candles resolves nothing (the record stays, the next run asks again).
14
16
  * - A row moves while the user never changed it (the value reads as the row's default, the settings panel's reset
15
17
  * test, `wrunRowValuesEqual` over `wrunRowValue`): its value and its `defaultValue` together. A changed value keeps
16
18
  * both, so it reads as changed on every market after it; its reset goes to the default of the market where it was
17
19
  * changed, and the run head of the save the reset is moves the now unchanged value to this market's.
20
+ * - The carry (C-DOLLAR's saved values): a raw-unit value the user changed on 0.5.0 (Min size, Whale size) rides the
21
+ * record under its old name after the pin move (wrun-twin-pin-move.util WRUN_PIN_CARRY_DOLLAR_CONVERSIONS), and the
22
+ * first head that proves what one STORED unit is worth there prices it once into the dollar param that took its
23
+ * place (raw stored units x the dollars per stored unit, the large-print writer's own price of one off the market's
24
+ * newest TRADE_LARGE print: wrun-chart-market-facts.util `wrunMarketStoredUnitDollars`; held to 3 significant
25
+ * figures, `wrunCarriedDollarValue`). The dollar row marks the carried value (`carriedValue`), so it counts as
26
+ * changed on this market and every one after it, even where it equals the row's default
27
+ * (`wrunMarketScaledRowChanged`), and a carry is pending only while its dollar row holds no mark, so it prices once.
28
+ * On a market that counts contracts (the CME family, `wrunCarryKeepsRawValue`) the old name stays stored, the
29
+ * contract count the version that floors CME in contracts restores exactly; everywhere else it is cleared. A market
30
+ * whose stored unit can never be proven writes no value (the market's dollar default applies) and drops the carry,
31
+ * the ring naming the market (`wrun-market-size-carry-dropped`), except on a market that counts contracts, where the
32
+ * raw value stays under its old name (`wrun-market-size-carry-kept`); one a read can still prove keeps it under its
33
+ * old name for the next run.
18
34
  * - The engine copy takes the patch (titan merges it at once, so the run reads it) and the workspace row its own, with
19
35
  * one reconcile persist (no gesture, no undo entry), the delivered sheet's reconcile's pattern
20
36
  * (wrun-overlay-run.util `reconcileWrunSourceRecord`, which keeps the moved defaults when it rebuilds the rows).
37
+ * - The option family (r11, Big Trades 0.7.0's Size shown as, `contracts-option`): split off the volume rules
38
+ * (`wrunMarketScaledFamilies`) and resolved in the same warm block with its own verdict
39
+ * (`wrunMarketOptionVerdict`, no candles read) and its own memo key (`<market>#options`), so a volume rule that
40
+ * waits on its candles never holds the option back, nor the option the volume rules. Its select row moves while
41
+ * untouched like a number row (value and default together, in the row's own spelling), and the two families'
42
+ * defaults merge into one move patch.
43
+ * - The contracts carry (BT-CME, wrun-market-size-contract-carry.leaf, by param name): on a market that counts
44
+ * contracts, a 0.5.x count still the user's latest word (the dollar row unmarked, or still at its carried mark: S0
45
+ * kept the old name there) moves to Min size or Whale size exactly; else a changed dollar value (0.6.x or 0.7.x, a
46
+ * carried one included) counts `ceil(value / dollars per contract)` at the stored-unit price; the contracts row is
47
+ * marked, the old name cleared, the dollar row back to untouched (the market's dollar default then moves it). It runs
48
+ * before the dollar carry and takes its own raw names, so the dollar carry never prices them; ring
49
+ * `wrun-market-size-contract-carry`.
50
+ * - The contracts family (BT-ORDER-FLOOR, Big Trades 0.8.0's Min size and Whale size in contracts, `cme-root-contracts`
51
+ * and its multiple): split off like the option family, resolved after the warm block with its own verdict
52
+ * (`wrunMarketContractsVerdict`, no candles read), memo key (`<market>#contracts`) and ring line
53
+ * (`wrun-market-size-contracts-defaults`). Where the per-order switch holds for the chart market (`wrunTapePerOrder`:
54
+ * its tape judged per aggressor order) an untouched Min size moves to its product root's floor (NQ 50, ES 200, any other
55
+ * root 10) and Whale size to ten times that; where prints are judged per fill, both stay at (or return to) the
56
+ * package's flat 10 and 100. The contracts carry runs first, so a carried count is a changed value the move keeps.
21
57
  *
22
58
  * Advisory: it never fails the run.
23
59
  */
@@ -25,25 +61,48 @@ import { wrunChartHostEnv } from '../../host-env.js';
25
61
  import { candleVolumeIsBaseCoins } from '../chart/candle-volume-unit.leaf.js';
26
62
  import { normalizeTransformations, selfTransformationToken } from '../common/transformations.util.js';
27
63
  import { wrunChartIntervalMsOf } from './wrun-chart-context.util.js';
28
- import { warmWrunMarketFacts, wrunChartSizeUnit } from './wrun-chart-market-facts.util.js';
29
- import { isWrunMarketScaledRow, wrunMarketDefaultWithinRow, wrunMarketScaledParamsOf, wrunMarketSizeVerdict, } from './wrun-market-size-defaults.leaf.js';
64
+ import { warmWrunMarketDollarFacts, warmWrunMarketStoredUnit, wrunChartSizeUnit, wrunMarketDollarUnit, wrunMarketStoredUnitDollars, } from './wrun-chart-market-facts.util.js';
65
+ import { tradesCmeProductRoot } from '../../kscript-data/controls/live-trades-merge.util.js';
66
+ import { isWrunMarketScaledRow, wrunCarriedDollarValue, wrunCarryKeepsRawValue, wrunMarketContractsVerdict, wrunMarketDefaultWithinRow, wrunMarketOptionVerdict, wrunMarketScaledFamilies, wrunMarketScaledParamsOf, wrunMarketScaledRulesOfSheet, wrunMarketSizeVerdict, } from './wrun-market-size-defaults.leaf.js';
67
+ import { WRUN_CONTRACT_CARRY_PENDING, wrunContractCarryPatch, wrunContractCarrySettles, wrunPendingContractCarries, } from './wrun-market-size-contract-carry.leaf.js';
30
68
  import { wrunChartMarketIdentity } from './wrun-overlay-drivers.util.js';
31
69
  import { wrunRegistryRefOf } from './wrun-overlay-identity.util.js';
70
+ import { wrunTapePerOrder } from './wrun-tape-per-order.util.js';
32
71
  import { wrunRowValue, wrunRowValuesEqual, wrunValuesEqual, } from './wrun-script-inputs.util.js';
33
72
  import { wrunChartCandleRows } from './wrun-source-rows.util.js';
34
73
  function isRecord(value) {
35
74
  return value !== null && typeof value === 'object' && !Array.isArray(value);
36
75
  }
76
+ /** A record with a patch merged over it (a carry's), the record itself as an object when there is none. */
77
+ function withPatch(settings, patch) {
78
+ return { ...(isRecord(settings) ? settings : {}), ...(patch ?? {}) };
79
+ }
80
+ /**
81
+ * Whether a market-scaled row holds a value the user chose (the market defaults never move it): a value off its row's
82
+ * default (the settings panel's reset test, `wrunRowValuesEqual` over `wrunRowValue`), or the value a carry priced into
83
+ * it (`carriedValue`, C-DOLLAR), which counts as chosen even where it equals the row's default: a 0.5.0 Min size of
84
+ * 5,000 Binance delivery contracts of $100 carries $500,000, the sheet's default, and must not follow the next market's
85
+ * default. Pure.
86
+ */
87
+ export function wrunMarketScaledRowChanged(record, row) {
88
+ const value = wrunRowValue(record, row);
89
+ if (!wrunRowValuesEqual(row, value, row.defaultValue))
90
+ return true;
91
+ return typeof row.carriedValue === 'number' && wrunRowValuesEqual(row, value, row.carriedValue);
92
+ }
37
93
  /**
38
94
  * The patch that moves a record (`settings`: its `scriptInputs` rows and each value flat under its row's name) to a
39
- * market's `defaults`: every scaled row whose value reads as its default (never changed) takes the market's default
40
- * (held to the row's bounds), value and `defaultValue` together. A changed value keeps both: the changed mark is the
41
- * value against its own row's default, so a default moved under a kept value would read the value as never changed on
42
- * the first market whose default equals it, and the next market would move it (SOL 200, then ETH whose default is
43
- * 200, then SOL reset it to 1000). Its reset goes to the default of the market where the user changed it, a save
44
- * whose run head then moves the unchanged value on. Undefined when the record already reads the defaults. Pure.
95
+ * market's `defaults`: every scaled row whose value the user never chose (`wrunMarketScaledRowChanged`) takes the
96
+ * market's default (held to the row's bounds, a select's as the option it names), value and `defaultValue` together.
97
+ * `rules` are the rules the defaults were read by: a select row moves under an option rule only (without them, number
98
+ * rows only, the volume families' kind). A changed value keeps both: the
99
+ * changed mark is the value against its own row's default, so a default moved under a kept value would read the value
100
+ * as never changed on the first market whose default equals it, and the next market would move it (SOL 200, then ETH
101
+ * whose default is 200, then SOL reset it to 1000). Its reset goes to the default of the market where the user changed
102
+ * it, a save whose run head then moves the unchanged value on. A carried value (`carriedValue`) is a changed one too,
103
+ * whatever its row's default. Undefined when the record already reads the defaults. Pure.
45
104
  */
46
- export function wrunMarketSizeSettingsPatch(settings, defaults) {
105
+ export function wrunMarketSizeSettingsPatch(settings, defaults, rules) {
47
106
  const record = isRecord(settings) ? settings : {};
48
107
  if (!Array.isArray(record.scriptInputs))
49
108
  return undefined;
@@ -53,12 +112,12 @@ export function wrunMarketSizeSettingsPatch(settings, defaults) {
53
112
  if (!isRecord(held) || typeof held.name !== 'string' || !Object.hasOwn(defaults, held.name))
54
113
  return held;
55
114
  const row = held;
56
- if (!isWrunMarketScaledRow(row))
115
+ if (!isWrunMarketScaledRow(row, rules?.[row.name]))
57
116
  return held;
58
117
  const target = wrunMarketDefaultWithinRow(row, defaults[row.name]);
59
118
  if (target === undefined)
60
119
  return held;
61
- if (!wrunRowValuesEqual(row, wrunRowValue(record, row), row.defaultValue))
120
+ if (wrunMarketScaledRowChanged(record, row))
62
121
  return held;
63
122
  if (!wrunValuesEqual(record[row.name], target))
64
123
  patch[row.name] = target;
@@ -71,8 +130,86 @@ export function wrunMarketSizeSettingsPatch(settings, defaults) {
71
130
  patch.scriptInputs = scriptInputs;
72
131
  return Object.keys(patch).length > 0 ? patch : undefined;
73
132
  }
133
+ /** Whether a record's dollar row `name` holds a carried mark (`carriedValue`: a carry already priced into it). */
134
+ function wrunRowHoldsCarriedMark(record, name) {
135
+ const rows = Array.isArray(record.scriptInputs) ? record.scriptInputs : [];
136
+ return rows.some((row) => isRecord(row) && row.name === name && typeof row.carriedValue === 'number' && Number.isFinite(row.carriedValue));
137
+ }
138
+ /** The carries a record holds for the scaled rules its sheet declares: a rule's `carriesFrom` name held flat on the
139
+ * record with a finite positive value while the sheet no longer declares it (the pin move left it there), and while
140
+ * the dollar row holds no carried mark: a carry prices once, so a raw value kept under its old name (a market that
141
+ * counts contracts, `wrunCarryKeepsRawValue`) never prices again, after a reload, a market switch or a reset alike
142
+ * (a reset writes values, never the rows, so the mark stays). */
143
+ export function wrunPendingDollarCarries(settings, rules, sheetParams) {
144
+ const record = isRecord(settings) ? settings : {};
145
+ const pending = [];
146
+ for (const [to, rule] of Object.entries(rules)) {
147
+ if (rule.kind === 'daily-volume' || rule.carriesFrom === undefined)
148
+ continue;
149
+ const from = rule.carriesFrom;
150
+ if (sheetParams.has(from) || !Object.hasOwn(record, from) || wrunRowHoldsCarriedMark(record, to))
151
+ continue;
152
+ const raw = record[from];
153
+ if (typeof raw === 'number' && Number.isFinite(raw) && raw > 0)
154
+ pending.push({ to, from, raw });
155
+ }
156
+ return pending;
157
+ }
158
+ /**
159
+ * The patch that prices a record's pending carries once (C-DOLLAR's saved values): each carry's raw value in STORED
160
+ * units x the dollars one stored unit is worth at the market's price (`stored`, wrun-chart-market-facts.util
161
+ * `wrunMarketStoredUnitDollars`), held to 3 significant figures (`wrunCarriedDollarValue`) and to the dollar row's
162
+ * bounds, written flat under the dollar param, and the dollar row marked with it (`carriedValue`: a changed value
163
+ * whatever its row's default, `wrunMarketScaledRowChanged`; its row's default stays). The old name is cleared, except
164
+ * on a market that counts contracts (`sizeUnit`, `wrunCarryKeepsRawValue`), where it stays stored: the version that
165
+ * floors such a market in contracts restores the count exactly, and the mark keeps it from pricing twice (so a carry
166
+ * that keeps its old name and finds no dollar row to mark writes nothing yet). A stored unit that can never be proven
167
+ * (`unproven`, not transient: no large print of the market in the table's week, a quote that is no dollar, a CME
168
+ * contract with no point value) writes no value (the market's dollar default applies) and clears the old name, except
169
+ * on a market that counts contracts; a transient one writes nothing (the next run asks again). `sizeUnit` is required
170
+ * of every caller (undefined where the market's is not known: the old name is cleared), so the engine copy and the
171
+ * workspace row are always carried by one rule. Undefined when nothing moves. Pure.
172
+ */
173
+ export function wrunDollarCarryPatch(settings, pending, stored, sizeUnit) {
174
+ if (pending.length === 0 || stored === undefined)
175
+ return undefined;
176
+ const record = isRecord(settings) ? settings : {};
177
+ const rows = Array.isArray(record.scriptInputs) ? record.scriptInputs : [];
178
+ const keepsRawValue = wrunCarryKeepsRawValue(sizeUnit);
179
+ const patch = {};
180
+ const carried = new Map();
181
+ for (const carry of pending) {
182
+ if (stored.kind === 'unproven') {
183
+ if (!stored.transient && !keepsRawValue)
184
+ patch[carry.from] = undefined;
185
+ continue;
186
+ }
187
+ const priced = wrunCarriedDollarValue(carry.raw, stored.perUnit);
188
+ if (priced === undefined)
189
+ continue;
190
+ const row = rows.find((candidate) => isRecord(candidate) && candidate.name === carry.to);
191
+ // A kept raw value prices once only under its row's mark: no row to mark, no carry yet.
192
+ if (row === undefined && keepsRawValue)
193
+ continue;
194
+ const value = row === undefined ? priced : wrunMarketDefaultWithinRow(row, priced);
195
+ // A dollar row holds a number (a sheet that retyped it carries nothing).
196
+ if (typeof value !== 'number')
197
+ continue;
198
+ patch[carry.to] = value;
199
+ if (!keepsRawValue)
200
+ patch[carry.from] = undefined;
201
+ carried.set(carry.to, value);
202
+ }
203
+ if (carried.size > 0 && rows.length > 0) {
204
+ patch.scriptInputs = rows.map((row) => isRecord(row) && typeof row.name === 'string' && carried.has(row.name)
205
+ ? { ...row, carriedValue: carried.get(row.name) }
206
+ : row);
207
+ }
208
+ return Object.keys(patch).length > 0 ? patch : undefined;
209
+ }
74
210
  /** Each mount's resolved defaults, by market (`exchange|symbol`, and a formula chart's formula after it: its candles
75
- * are no market's, so it reads the package's defaults where its market reads its own): the engine meta is the mount. */
211
+ * are no market's, so it reads the package's defaults where its market reads its own) and the scaled params the sheet
212
+ * declares (a version that moves families reads its own): the engine meta is the mount. */
76
213
  const wrunMarketSizeDefaultsByMount = new WeakMap();
77
214
  /** The scaled params' defaults a sheet declares (the package's own: a `package` verdict's). */
78
215
  function wrunDeclaredDefaults(sheet, names) {
@@ -86,6 +223,14 @@ function wrunDeclaredDefaults(sheet, names) {
86
223
  return defaults;
87
224
  }
88
225
  const WRUN_MARKET_SIZE_UNPROVEN = Object.freeze({ kind: 'skip', reason: 'unproven' });
226
+ /** The facts of a head that could not prove its reads the keyed market's: every declared family skips, nothing to
227
+ * price a carry with. */
228
+ function wrunMarketSizeUnprovenFacts(families) {
229
+ return {
230
+ ...(families.volume !== undefined ? { verdict: WRUN_MARKET_SIZE_UNPROVEN } : {}),
231
+ ...(families.options !== undefined ? { optionVerdict: WRUN_MARKET_SIZE_UNPROVEN } : {}),
232
+ };
233
+ }
89
234
  /**
90
235
  * Move an overlay's record to its chart market's scaled defaults (above), at the head of a full run, before the
91
236
  * lanes read the settings. Resolves once the engine copy reads the defaults (the persist is the routing's own); a
@@ -101,9 +246,13 @@ const WRUN_MARKET_SIZE_UNPROVEN = Object.freeze({ kind: 'skip', reason: 'unprove
101
246
  */
102
247
  export async function reconcileWrunMarketSizeDefaults(args) {
103
248
  const { chartIndex, indicatorId, tc, meta, sheet, market, isCurrent } = args;
104
- const rules = wrunMarketScaledParamsOf(wrunRegistryRefOf(meta.settings)?.package);
249
+ const sheetParams = new Set((sheet.params ?? []).map((param) => param.name));
250
+ const packageName = wrunRegistryRefOf(meta.settings)?.package;
251
+ const rules = wrunMarketScaledRulesOfSheet(wrunMarketScaledParamsOf(packageName), sheetParams);
105
252
  if (rules === undefined)
106
253
  return;
254
+ // The volume rules and the option rules resolve apart: each its own verdict, memo key and ring line.
255
+ const families = wrunMarketScaledFamilies(rules);
107
256
  const keyed = () => isCurrent() && wrunChartMarketIdentity(market.read()) === market.identity;
108
257
  try {
109
258
  if (!keyed())
@@ -115,21 +264,41 @@ export async function reconcileWrunMarketSizeDefaults(args) {
115
264
  return;
116
265
  const transformations = typeof chartMetadata?.transformations === 'string' ? chartMetadata.transformations : '';
117
266
  const formula = wrunChartFormulaOf(exchange, symbol, transformations);
118
- const key = formula === undefined ? `${exchange}|${symbol}` : `${exchange}|${symbol}|${formula}`;
267
+ const family = families.volume === undefined ? undefined : Object.keys(families.volume).sort().join(',');
268
+ const marketKey = formula === undefined ? `${exchange}|${symbol}` : `${exchange}|${symbol}|${formula}`;
269
+ const volumeKey = family === undefined ? undefined : `${marketKey}#${family}`;
270
+ const optionKey = families.options === undefined ? undefined : `${marketKey}#options`;
271
+ const contractsKey = families.contracts === undefined ? undefined : `${marketKey}#contracts`;
119
272
  let resolved = wrunMarketSizeDefaultsByMount.get(meta);
120
- let defaults = resolved?.get(key);
121
- if (defaults === undefined) {
122
- // A crypto market's coin unit is the directory row's (its asset class): asked once per market for the session,
123
- // never rejects; a contracts market answers from its own facts and waits on nothing. The data loading module
124
- // says whose candles the chart holds; a host that cannot load it proves nothing.
125
- const [, dataFetching] = await Promise.all([
126
- warmWrunMarketFacts(chartMetadata),
273
+ let volumeDefaults = volumeKey === undefined ? undefined : resolved?.get(volumeKey);
274
+ let optionDefaults = optionKey === undefined ? undefined : resolved?.get(optionKey);
275
+ let contractsDefaults = contractsKey === undefined ? undefined : resolved?.get(contractsKey);
276
+ const volumeOwed = volumeKey !== undefined && volumeDefaults === undefined;
277
+ const optionsOwed = optionKey !== undefined && optionDefaults === undefined;
278
+ const contractsOwed = contractsKey !== undefined && contractsDefaults === undefined;
279
+ // The contracts carry (BT-CME, wrun-market-size-contract-carry.leaf): on a market that counts contracts (its size
280
+ // unit never waits on a read) a saved count or a changed dollar value moves into the contracts params of a sheet
281
+ // declaring them, by name. The raw counts it takes are its own: the dollar carry never prices one of them.
282
+ const chartSizeUnit = wrunChartSizeUnit(chartMetadata);
283
+ const contractPending = wrunPendingContractCarries(meta.settings, packageName, sheetParams, chartSizeUnit);
284
+ const pending = wrunPendingDollarCarries(meta.settings, rules, sheetParams).filter((carry) => !contractPending.some((entry) => entry.raw === carry.from));
285
+ const pricesContracts = contractPending.some((entry) => entry.from === 'dollars');
286
+ let headFacts;
287
+ if (volumeOwed || optionsOwed || pending.length > 0 || contractPending.length > 0) {
288
+ // A crypto market's coin unit and quote are the directory row's (its asset class, its quote), a CME contract's
289
+ // point value the instrument registry's, and only with a raw floor to carry or a dollar value to count in
290
+ // contracts, what one stored unit is worth (the large-print writer's own rows): each asked once per market for
291
+ // the session, never rejects. The data loading module says whose candles the chart holds; a host that cannot
292
+ // load it proves nothing.
293
+ const [, , dataFetching] = await Promise.all([
294
+ warmWrunMarketDollarFacts(chartMetadata),
295
+ pending.length > 0 || pricesContracts ? warmWrunMarketStoredUnit(chartMetadata) : undefined,
127
296
  Promise.resolve()
128
297
  .then(() => wrunChartHostEnv().chart.loadDataFetching())
129
298
  .catch(() => undefined),
130
299
  ]);
131
- const verdict = keyed()
132
- ? wrunMarketSizeVerdictNow(rules, {
300
+ headFacts = keyed()
301
+ ? wrunMarketSizeFactsNow(families, {
133
302
  tc,
134
303
  chartMetadata: market.read() ?? undefined,
135
304
  identity: market.identity,
@@ -138,31 +307,113 @@ export async function reconcileWrunMarketSizeDefaults(args) {
138
307
  exchange,
139
308
  symbol,
140
309
  })
141
- : WRUN_MARKET_SIZE_UNPROVEN;
310
+ : wrunMarketSizeUnprovenFacts(families);
311
+ }
312
+ /** Keep one family's resolution: its ring line, and its defaults unless it skipped (a fact that can still change,
313
+ * or one not proven the keyed market's: nothing kept, nothing moves, the next run asks again). */
314
+ const resolve = (key, verdict, familyRules, event, familyName) => {
142
315
  if (wrunChartHostEnv().diagnostics.debugEnabled()) {
143
- wrunChartHostEnv().diagnostics.debug('wrun-market-size-defaults', {
316
+ wrunChartHostEnv().diagnostics.debug(event, {
144
317
  chartIndex,
145
318
  indicatorId,
146
- market: key,
319
+ market: marketKey,
320
+ family: familyName,
147
321
  verdict: verdict.kind,
148
322
  ...(verdict.kind !== 'market' ? { reason: verdict.reason } : {}),
149
323
  ...(verdict.kind === 'market' ? { defaults: verdict.defaults } : {}),
150
324
  });
151
325
  }
152
- // A fact that can still change (a unit not known yet, too few candles) or that could not be proven the keyed
153
- // market's: nothing kept, nothing moves, the next run asks again.
154
326
  if (verdict.kind === 'skip')
155
- return;
156
- defaults = verdict.kind === 'market' ? verdict.defaults : wrunDeclaredDefaults(sheet, Object.keys(rules));
327
+ return undefined;
328
+ const kept = verdict.kind === 'market' ? verdict.defaults : wrunDeclaredDefaults(sheet, Object.keys(familyRules ?? {}));
157
329
  if (resolved === undefined) {
158
330
  resolved = new Map();
159
331
  wrunMarketSizeDefaultsByMount.set(meta, resolved);
160
332
  }
161
- resolved.set(key, defaults);
333
+ resolved.set(key, kept);
334
+ return kept;
335
+ };
336
+ if (volumeOwed && volumeKey !== undefined && family !== undefined && headFacts?.verdict !== undefined) {
337
+ volumeDefaults = resolve(volumeKey, headFacts.verdict, families.volume, 'wrun-market-size-defaults', family);
338
+ }
339
+ if (optionsOwed && optionKey !== undefined && headFacts?.optionVerdict !== undefined) {
340
+ optionDefaults = resolve(optionKey, headFacts.optionVerdict, families.options, 'wrun-market-size-option-defaults', 'options');
341
+ }
342
+ // The contracts family reads no candles and waits on no read: the chart market's root and whether the per-order
343
+ // switch holds for it, read now that the chart is proven still on the keyed market (a switch during the warm block
344
+ // returns below, before anything is kept).
345
+ if (contractsOwed && contractsKey !== undefined && families.contracts !== undefined && keyed()) {
346
+ const now = market.read() ?? undefined;
347
+ const verdict = wrunMarketContractsVerdict(families.contracts, {
348
+ perOrder: wrunTapePerOrder(now?.exchange),
349
+ root: tradesCmeProductRoot({
350
+ exchange: now?.exchange,
351
+ normalizedSymbol: now?.normalizedSymbol,
352
+ symbol: now?.symbol,
353
+ }),
354
+ });
355
+ contractsDefaults = resolve(contractsKey, verdict, families.contracts, 'wrun-market-size-contracts-defaults', 'contracts');
162
356
  }
163
357
  if (!keyed())
164
358
  return;
165
- const enginePatch = wrunMarketSizeSettingsPatch(meta.settings, defaults);
359
+ // The carries first (each value a marked changed one, `carriedValue`, so the move below keeps it): the contracts
360
+ // carry, then the dollar carry over what it left; then the market's defaults, both families' in one patch.
361
+ const storedUnit = headFacts?.storedUnit;
362
+ const sizeUnit = headFacts?.sizeUnit;
363
+ const defaults = volumeDefaults === undefined && optionDefaults === undefined && contractsDefaults === undefined
364
+ ? undefined
365
+ : { ...(volumeDefaults ?? {}), ...(optionDefaults ?? {}), ...(contractsDefaults ?? {}) };
366
+ // What one contract is worth: the large-print writer's own price of one stored unit (a CME contract).
367
+ const perContract = storedUnit?.kind === 'dollars' ? storedUnit.perUnit : undefined;
368
+ const contractCarry = wrunContractCarryPatch(meta.settings, contractPending, perContract);
369
+ if (contractCarry !== undefined && wrunChartHostEnv().diagnostics.debugEnabled()) {
370
+ wrunChartHostEnv().diagnostics.debug('wrun-market-size-contract-carry', {
371
+ chartIndex,
372
+ indicatorId,
373
+ market: marketKey,
374
+ carried: contractPending.map((entry) => ({ to: entry.to, from: entry.from })),
375
+ patch: contractCarry,
376
+ });
377
+ }
378
+ // A migration's stamp settles on the version's first head on any market (review of !10790, finding A): cleared
379
+ // beside the carries it ran, so a later switch to a market that counts contracts never converts a dollar value.
380
+ const settled = wrunContractCarrySettles(meta.settings, packageName, sheetParams, chartSizeUnit, contractPending, perContract)
381
+ ? { [WRUN_CONTRACT_CARRY_PENDING]: undefined }
382
+ : undefined;
383
+ if (settled !== undefined && wrunChartHostEnv().diagnostics.debugEnabled()) {
384
+ wrunChartHostEnv().diagnostics.debug('wrun-market-size-contract-carry-settled', {
385
+ chartIndex,
386
+ indicatorId,
387
+ market: marketKey,
388
+ carried: contractCarry !== undefined,
389
+ });
390
+ }
391
+ const carry = wrunDollarCarryPatch(withPatch(meta.settings, contractCarry), pending, storedUnit, sizeUnit);
392
+ const unpriced = pending.length > 0 && storedUnit?.kind === 'unproven' && !storedUnit.transient ? storedUnit : undefined;
393
+ if (wrunChartHostEnv().diagnostics.debugEnabled() && (carry !== undefined || unpriced !== undefined)) {
394
+ // A carry the market can never price is dropped by name (the market's dollar default applies), or kept by name
395
+ // on a market that counts contracts: the ring says which market and why, so a user's Min size is never silent.
396
+ const event = unpriced === undefined
397
+ ? 'wrun-market-size-carry'
398
+ : wrunCarryKeepsRawValue(sizeUnit)
399
+ ? 'wrun-market-size-carry-kept'
400
+ : 'wrun-market-size-carry-dropped';
401
+ wrunChartHostEnv().diagnostics.debug(event, {
402
+ chartIndex,
403
+ indicatorId,
404
+ market: marketKey,
405
+ carried: Object.fromEntries(pending.map((entry) => [entry.from, entry.raw])),
406
+ ...(unpriced !== undefined ? { reason: unpriced.reason } : { patch: carry }),
407
+ });
408
+ }
409
+ const settingsOf = (settings) => ({
410
+ ...withPatch(settings, contractCarry),
411
+ ...(carry ?? {}),
412
+ });
413
+ const movePatch = defaults === undefined ? undefined : wrunMarketSizeSettingsPatch(settingsOf(meta.settings), defaults, rules);
414
+ const enginePatch = settled === undefined && contractCarry === undefined && carry === undefined && movePatch === undefined
415
+ ? undefined
416
+ : { ...(settled ?? {}), ...(contractCarry ?? {}), ...(carry ?? {}), ...(movePatch ?? {}) };
166
417
  if (enginePatch === undefined)
167
418
  return;
168
419
  const chart = tc;
@@ -175,10 +426,18 @@ export async function reconcileWrunMarketSizeDefaults(args) {
175
426
  return;
176
427
  const document = resolveChart(chartIndex);
177
428
  const row = [...(document?.onchart ?? []), ...(document?.offchart ?? [])].find((candidate) => candidate?.id === indicatorId);
178
- const rowPatch = row === undefined ? undefined : wrunMarketSizeSettingsPatch(row.settings, defaults);
179
- if (row === undefined || rowPatch === undefined)
429
+ if (row === undefined)
430
+ return;
431
+ const rowContractCarry = contractCarry === undefined ? undefined : wrunContractCarryPatch(row.settings, contractPending, perContract);
432
+ const rowCarry = carry === undefined
433
+ ? undefined
434
+ : wrunDollarCarryPatch(withPatch(row.settings, rowContractCarry), pending, storedUnit, sizeUnit);
435
+ const rowSettings = { ...withPatch(row.settings, rowContractCarry), ...(rowCarry ?? {}) };
436
+ const rowMove = defaults === undefined ? undefined : wrunMarketSizeSettingsPatch(rowSettings, defaults, rules);
437
+ if (settled === undefined && rowContractCarry === undefined && rowCarry === undefined && rowMove === undefined) {
180
438
  return;
181
- row.settings = { ...(row.settings ?? {}), ...rowPatch };
439
+ }
440
+ row.settings = { ...rowSettings, ...(rowMove ?? {}), ...(settled ?? {}) };
182
441
  persistChart(chartIndex, 'reconcile');
183
442
  }
184
443
  catch (error) {
@@ -194,20 +453,45 @@ function wrunChartFormulaOf(exchange, symbol, transformations) {
194
453
  : formula;
195
454
  }
196
455
  /**
197
- * The verdict of the keyed market's facts, read in the caller's task once the chart is proven on that market: the
198
- * size unit once the directory placed it, the venue's candle volume unit (`ownCandles`: a formula chart's candles are
199
- * no market's), and the chart's own candles while they were loaded for the keyed market (`loaded`, the loaded-main
200
- * identity, names its `identity`). Candles loaded for another market are never read: the verdict that would read them
201
- * reads `unproven` (the candles not yet the market's own, never its own too few).
456
+ * The facts of the keyed market, read in the caller's task once the chart is proven on that market: the size unit once
457
+ * the directory placed it, the venue's candle volume unit (`ownCandles`: a formula chart's candles are no market's),
458
+ * the market's dollar unit (the market facts, `wrunMarketDollarUnit`), and the chart's own candles while they were
459
+ * loaded for the keyed market (`loaded`, the loaded-main identity, names its `identity`). Candles loaded for another
460
+ * market are never read: the volume verdict that would read them reads `unproven` (the candles not yet the market's
461
+ * own, never its own too few), and no carry prices with them. The option verdict reads no candles, so it stands then.
202
462
  */
203
- function wrunMarketSizeVerdictNow(rules, facts) {
463
+ function wrunMarketSizeFactsNow(families, facts) {
204
464
  const rowsOwn = facts.loaded !== null && wrunChartMarketIdentity(facts.loaded) === facts.identity;
205
- const verdict = wrunMarketSizeVerdict(rules, {
465
+ const rows = rowsOwn && families.volume !== undefined
466
+ ? wrunChartCandleRows(facts.tc)
467
+ : [];
468
+ // A formula chart's candles are no market's: its dollar volume is no market's either, so the dollar rule reads the
469
+ // package's defaults there (`candle-unit`, as the coin rule does), and a pending carry waits for a run on the
470
+ // market's own candles (a formula's close is no price of the market's prints).
471
+ const dollarUnit = facts.ownCandles
472
+ ? wrunMarketDollarUnit(facts.chartMetadata)
473
+ : { kind: 'unproven', reason: 'quote', transient: true };
474
+ const sizeFacts = {
206
475
  sizeUnit: wrunChartSizeUnit(facts.chartMetadata),
207
476
  candleVolumeInCoins: facts.ownCandles && candleVolumeIsBaseCoins(facts.exchange, facts.symbol),
208
- rows: rowsOwn ? wrunChartCandleRows(facts.tc) : [],
477
+ ...(facts.ownCandles ? { dollarUnit } : {}),
478
+ rows,
209
479
  intervalMs: wrunChartIntervalMsOf(facts.chartMetadata?.interval),
210
- });
480
+ };
481
+ const optionVerdict = families.options === undefined ? undefined : wrunMarketOptionVerdict(families.options, sizeFacts);
482
+ const options = optionVerdict === undefined ? {} : { optionVerdict };
483
+ if (families.volume === undefined)
484
+ return options;
485
+ const verdict = wrunMarketSizeVerdict(families.volume, sizeFacts);
211
486
  // Only the verdict that reads the candles meets the rows held back, and no rows read as too few candles.
212
- return !rowsOwn && verdict.kind === 'skip' && verdict.reason === 'cover' ? WRUN_MARKET_SIZE_UNPROVEN : verdict;
487
+ if (!rowsOwn && verdict.kind === 'skip' && verdict.reason === 'cover') {
488
+ return { verdict: WRUN_MARKET_SIZE_UNPROVEN, ...options };
489
+ }
490
+ // What a carried raw floor's stored unit is worth here: the large-print writer's own price of one (a formula chart
491
+ // is no market's: its carry waits for a run on the market's own chart), and the size unit that says whether the
492
+ // carry keeps the raw value under its old name.
493
+ const storedUnit = facts.ownCandles
494
+ ? wrunMarketStoredUnitDollars(facts.chartMetadata)
495
+ : { kind: 'unproven', reason: 'quote', transient: true };
496
+ return { verdict, ...options, storedUnit, sizeUnit: sizeFacts.sizeUnit };
213
497
  }
@@ -4,13 +4,15 @@
4
4
  * `governed: 'opra'`): written once here, read by both planners, the run pass and the live tick.
5
5
  *
6
6
  * - WHO may read: `mayReadOpra` (opra-read-access.leaf: an official package always, a draft or community
7
- * package only while the `opra-user-scripts` flag opened the plane to it). Any other run is refused by
8
- * name before any fetch, `opra-official-only:<class>`, seeded as the wall on US options data (the
9
- * options chain's own record, `cme-wall` / `opra`).
7
+ * package only while the `opra-user-scripts` flag opened the plane to it, the OPRA licence covering
8
+ * user-authored scripting, Kyle 2026-10-27). Any other run is refused by name before any fetch,
9
+ * `opra-official-only:<class>`, seeded as the wall on US options data (the options chain's own record,
10
+ * `cme-wall` / `opra`).
10
11
  * - The ASK: an OPRA lane's payload names the plane it reads (`wrunPlane: 'opra'`, which Door C judges as
11
12
  * an OPRA ask whatever the payload's exchange) and the tier the read is routed to (`servedTier`,
12
13
  * governed-route.util `governedMarketDataTier`, re-read on every ask), so no source cache serves one
13
- * tier's rows to the other and the legend names the tier the rows rode.
14
+ * tier's rows to the other and the legend names the tier the rows rode. The tier is the viewer's (the
15
+ * gate's tier frame for the session), whoever wrote the package.
14
16
  * - PROVENANCE: a run that asks such a lane stamps the overlay's OPRA provenance before its first fetch
15
17
  * and sheds it once a result read off another source replaced the rows (wrun-overlay-run.util).
16
18
  *
@@ -22,6 +24,17 @@ import { type WrunRefusalSeed } from './wrun-refusal.util.js';
22
24
  export declare const WRUN_OPRA_OFFICIAL_ONLY_CODE = "opra-official-only";
23
25
  /** The routed tier an OPRA lane's ask names. */
24
26
  export type WrunOpraServedTier = 'realtime' | 'delayed';
27
+ /**
28
+ * The receipt of the OPRA rows a hosted (Cloud) frame was computed from (contract opra-server-lanes C4: the frame's
29
+ * `output.wrunOpraTier` and `output.wrunOpraDelaySeconds` beside its `wrunOpra` mark): the tier the gate served the
30
+ * run's owner and that tier's delay. A frame with the mark and no tier names none: its tier is unknown, and the
31
+ * legend then names no tier at all (the account's tier is never put in its place).
32
+ */
33
+ export interface WrunOpraServedReceipt {
34
+ tier: WrunOpraServedTier;
35
+ /** Seconds behind real time (0 for real-time); absent when the frame named no figure. */
36
+ delaySeconds?: number;
37
+ }
25
38
  /** The named refusal of an OPRA lane a run may not read: `opra-official-only:<class>`. */
26
39
  export declare function wrunOpraOfficialOnlyCode(sourceClass: string): string;
27
40
  /** The record seed of that refusal: the wall on US options data (the options chain's own). */
@@ -4,13 +4,15 @@
4
4
  * `governed: 'opra'`): written once here, read by both planners, the run pass and the live tick.
5
5
  *
6
6
  * - WHO may read: `mayReadOpra` (opra-read-access.leaf: an official package always, a draft or community
7
- * package only while the `opra-user-scripts` flag opened the plane to it). Any other run is refused by
8
- * name before any fetch, `opra-official-only:<class>`, seeded as the wall on US options data (the
9
- * options chain's own record, `cme-wall` / `opra`).
7
+ * package only while the `opra-user-scripts` flag opened the plane to it, the OPRA licence covering
8
+ * user-authored scripting, Kyle 2026-10-27). Any other run is refused by name before any fetch,
9
+ * `opra-official-only:<class>`, seeded as the wall on US options data (the options chain's own record,
10
+ * `cme-wall` / `opra`).
10
11
  * - The ASK: an OPRA lane's payload names the plane it reads (`wrunPlane: 'opra'`, which Door C judges as
11
12
  * an OPRA ask whatever the payload's exchange) and the tier the read is routed to (`servedTier`,
12
13
  * governed-route.util `governedMarketDataTier`, re-read on every ask), so no source cache serves one
13
- * tier's rows to the other and the legend names the tier the rows rode.
14
+ * tier's rows to the other and the legend names the tier the rows rode. The tier is the viewer's (the
15
+ * gate's tier frame for the session), whoever wrote the package.
14
16
  * - PROVENANCE: a run that asks such a lane stamps the overlay's OPRA provenance before its first fetch
15
17
  * and sheds it once a result read off another source replaced the rows (wrun-overlay-run.util).
16
18
  *