@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,162 @@
1
+ import { WRUN_MARKET_SIZE_UNITS } from './wrun-market-facts.util.js';
2
+ /** The contracts carries by package, by param name (never by version: every saved version moves the same way).
3
+ * tests/utility/wrun/wrun-market-size-contract-carry.leaf.spec.ts holds each row to the 0.8.0 sheet and its dollar
4
+ * rule. */
5
+ export const WRUN_CONTRACT_CARRIES = Object.freeze({
6
+ '@om-core/big-trades': Object.freeze([
7
+ Object.freeze({ to: 'min_contracts', raw: 'min_size', dollars: 'min_value' }),
8
+ Object.freeze({ to: 'whale_contracts', raw: 'whale_size', dollars: 'whale_value' }),
9
+ ]),
10
+ });
11
+ /** The record's stamp of a pending migration carry (above): `true` from the pin move until a run head settles it. */
12
+ export const WRUN_CONTRACT_CARRY_PENDING = 'wrunContractCarryPending';
13
+ /** `market.size_unit()`'s contracts code (the kit's table, wrun-market-facts.util). */
14
+ const CONTRACTS_SIZE_UNIT = WRUN_MARKET_SIZE_UNITS.indexOf('contracts');
15
+ /** The float noise a dollar value priced from a whole count carries (7 x $584,875 read back as 6.9999999999). */
16
+ const CONTRACTS_EPSILON = 1e-9;
17
+ function isRecord(value) {
18
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
19
+ }
20
+ function positive(value) {
21
+ const number = typeof value === 'number' ? value : typeof value === 'string' && value.trim() !== '' ? Number(value) : NaN;
22
+ return Number.isFinite(number) && number > 0 ? number : undefined;
23
+ }
24
+ function rowNamed(record, name) {
25
+ const rows = Array.isArray(record.scriptInputs) ? record.scriptInputs : [];
26
+ return rows.find((row) => isRecord(row) && row.name === name);
27
+ }
28
+ /** Whether a number row reads untouched: its value is its row default and it holds no carried mark (the settings
29
+ * panel's reset test on a plain number row: the value absent reads the default). */
30
+ function untouched(record, row) {
31
+ if (row === undefined || typeof row.carriedValue === 'number')
32
+ return false;
33
+ const value = record[row.name];
34
+ return value === undefined || value === null || Number(value) === Number(row.defaultValue);
35
+ }
36
+ /**
37
+ * The smallest whole contract count at or above `dollars` at `perContract` dollars a contract: `ceil(dollars /
38
+ * perContract)`, the float noise of a count priced back taken off first (6.9999999999 is 7, never 8). Undefined when
39
+ * either is not finite and above zero (the carry waits, never guesses).
40
+ */
41
+ export function wrunCarriedContracts(dollars, perContract) {
42
+ const value = positive(dollars);
43
+ if (value === undefined || !Number.isFinite(perContract) || perContract <= 0)
44
+ return undefined;
45
+ const count = Math.ceil(value / perContract - CONTRACTS_EPSILON);
46
+ return Number.isFinite(count) && count >= 1 ? count : 1;
47
+ }
48
+ /**
49
+ * The contracts carries a record (`settings`: its `scriptInputs` rows and each value flat under its row's name) holds
50
+ * for a sheet declaring `sheetParams`, on a market of size unit `sizeUnit`, in table order: none off contracts, none
51
+ * for a contracts param the sheet does not declare or the user already set (or a carry marked). Pure.
52
+ */
53
+ export function wrunPendingContractCarries(settings, packageName, sheetParams, sizeUnit) {
54
+ if (sizeUnit !== CONTRACTS_SIZE_UNIT || packageName === undefined)
55
+ return [];
56
+ if (!Object.hasOwn(WRUN_CONTRACT_CARRIES, packageName))
57
+ return [];
58
+ const record = isRecord(settings) ? settings : {};
59
+ const pending = [];
60
+ for (const rule of WRUN_CONTRACT_CARRIES[packageName]) {
61
+ if (!sheetParams.has(rule.to) || !untouched(record, rowNamed(record, rule.to)))
62
+ continue;
63
+ const dollarsRow = rowNamed(record, rule.dollars);
64
+ const mark = typeof dollarsRow?.carriedValue === 'number' ? dollarsRow.carriedValue : undefined;
65
+ const dollars = Number(record[rule.dollars]);
66
+ // The raw count is the user's latest word while the dollar row was never priced from it, or still reads the value
67
+ // that carry priced (an edit since is newer).
68
+ const count = sheetParams.has(rule.raw) ? undefined : positive(record[rule.raw]);
69
+ if (count !== undefined && (mark === undefined || dollars === mark)) {
70
+ pending.push({ ...rule, from: 'raw', count });
71
+ continue;
72
+ }
73
+ // A changed dollar value (the settings panel's test: off its row default, or the value a carry marked), on a
74
+ // migration's first head alone: a record never stamped converts no dollar value.
75
+ const changed = record[WRUN_CONTRACT_CARRY_PENDING] === true &&
76
+ dollarsRow !== undefined &&
77
+ positive(dollars) !== undefined &&
78
+ (dollars !== Number(dollarsRow.defaultValue) || (mark !== undefined && dollars === mark));
79
+ if (changed)
80
+ pending.push({ ...rule, from: 'dollars', value: dollars });
81
+ else if (count !== undefined)
82
+ pending.push({ ...rule, from: 'stale' });
83
+ }
84
+ return pending;
85
+ }
86
+ /**
87
+ * Whether the run head settles the record's migration stamp now (`WRUN_CONTRACT_CARRY_PENDING` cleared on the engine
88
+ * copy and the workspace row): a stamped record, on a sheet declaring its package's contracts params (the version the
89
+ * stamp moved it to), at once on a market that does not count contracts (nothing converts there, and nothing may later),
90
+ * and on one that does once no dollar carry of `pending` waits on its price (`perContract` unproven: the next run asks
91
+ * again). Pure.
92
+ */
93
+ export function wrunContractCarrySettles(settings, packageName, sheetParams, sizeUnit, pending, perContract) {
94
+ const record = isRecord(settings) ? settings : {};
95
+ if (record[WRUN_CONTRACT_CARRY_PENDING] !== true || packageName === undefined)
96
+ return false;
97
+ if (!Object.hasOwn(WRUN_CONTRACT_CARRIES, packageName))
98
+ return false;
99
+ if (!WRUN_CONTRACT_CARRIES[packageName].some((rule) => sheetParams.has(rule.to)))
100
+ return false;
101
+ if (sizeUnit !== CONTRACTS_SIZE_UNIT)
102
+ return true;
103
+ return !pending.some((carry) => carry.from === 'dollars' &&
104
+ (perContract === undefined || wrunCarriedContracts(carry.value, perContract) === undefined));
105
+ }
106
+ /**
107
+ * The patch that carries a record's pending contracts carries once (above): each contracts value (a raw count as it
108
+ * is, a dollar value at `perContract` dollars a contract, `wrunCarriedContracts`), held to its row's bounds, written
109
+ * flat under the contracts param with its row marked (`carriedValue`); the old name cleared; the dollar row back to
110
+ * untouched (its row default, its mark dropped). A dollar carry with no proven `perContract` writes nothing (the next
111
+ * run asks again). Undefined when nothing moves. Pure.
112
+ */
113
+ export function wrunContractCarryPatch(settings, pending, perContract) {
114
+ if (pending.length === 0)
115
+ return undefined;
116
+ const record = isRecord(settings) ? settings : {};
117
+ const patch = {};
118
+ const carried = new Map();
119
+ const reset = new Set();
120
+ for (const carry of pending) {
121
+ if (carry.from === 'stale') {
122
+ // The user's later dollar choice replaced the count: the old name goes, nothing carries.
123
+ patch[carry.raw] = undefined;
124
+ continue;
125
+ }
126
+ const counted = carry.from === 'raw'
127
+ ? carry.count
128
+ : perContract === undefined
129
+ ? undefined
130
+ : wrunCarriedContracts(carry.value, perContract);
131
+ if (counted === undefined)
132
+ continue;
133
+ const row = rowNamed(record, carry.to);
134
+ const min = typeof row?.constraints?.min === 'number' ? row.constraints.min : undefined;
135
+ const max = typeof row?.constraints?.max === 'number' ? row.constraints.max : undefined;
136
+ const value = min !== undefined && counted < min ? min : max !== undefined && counted > max ? max : counted;
137
+ patch[carry.to] = value;
138
+ if (Object.hasOwn(record, carry.raw))
139
+ patch[carry.raw] = undefined;
140
+ const dollarsRow = rowNamed(record, carry.dollars);
141
+ if (dollarsRow !== undefined)
142
+ patch[carry.dollars] = dollarsRow.defaultValue;
143
+ carried.set(carry.to, value);
144
+ reset.add(carry.dollars);
145
+ }
146
+ if (carried.size === 0)
147
+ return Object.keys(patch).length > 0 ? patch : undefined;
148
+ if (Array.isArray(record.scriptInputs)) {
149
+ patch.scriptInputs = record.scriptInputs.map((row) => {
150
+ if (!isRecord(row) || typeof row.name !== 'string')
151
+ return row;
152
+ if (carried.has(row.name))
153
+ return { ...row, carriedValue: carried.get(row.name) };
154
+ if (reset.has(row.name) && Object.hasOwn(row, 'carriedValue')) {
155
+ const { carriedValue: _mark, ...rest } = row;
156
+ return rest;
157
+ }
158
+ return row;
159
+ });
160
+ }
161
+ return patch;
162
+ }
@@ -1,106 +1,263 @@
1
1
  /**
2
- * The size thresholds a built-in package declares in trade units (coins on crypto, contracts on futures) as ONE
3
- * number for every market. Big Trades' Min size 10 was tuned on BTC, where 10 BTC is about $830k; on a market whose
4
- * coin is worth a sliver of BTC the same number keeps a whole tape: 10 ETH (about $24k) kept 487,132 prints over its
5
- * seven days of BINANCE_FUTURES ETHUSDT, past the trades worker's 300,000-print cap, so every attempt failed. A
6
- * threshold that means "big" follows the market instead: the table below names the params that do (keyed by package
7
- * and param name, never by a label, a hint or a pattern), and this leaf holds the rule; the run head applies it once
8
- * per mount and market (wrun-market-size-defaults.util).
2
+ * The size thresholds a built-in package declares as ONE number for every market, made to follow the market. Big
3
+ * Trades 0.5.0 floors its tape by Min size in each venue's raw stored unit (coins on Binance, contracts on gate.io
4
+ * futures), tuned on BTC, where 10 BTC is about $830k; on a market whose coin is worth a sliver of BTC the same number
5
+ * keeps a whole tape: 10 ETH (about $24k) kept 487,132 prints over its seven days of BINANCE_FUTURES ETHUSDT, past the
6
+ * trades worker's 300,000-print cap, so every attempt failed. A threshold that means "big" follows the market instead:
7
+ * the table below names the params that do (keyed by package and param name, never by a label, a hint or a pattern),
8
+ * and this leaf holds the rules; the run head applies them once per mount and market (wrun-market-size-defaults.util).
9
9
  *
10
- * The rule (product decision 2026-10-21): on a market whose size unit is coins and whose candle volume is in base
11
- * coins, Min size defaults to 0.01% of the market's daily base volume rounded down to 1, 2 or 5 times a power of ten
12
- * (`wrunNiceFloor`, below 1 too), and Whale size to ten times that, so BTC keeps 10 and 100 (131.7K BTC a day) while
13
- * ETH reads 200 and 2000 (3.13M ETH). The daily volume comes from the chart's own candles (`wrunDailyCandleVolume`).
14
- * A market whose facts never yield a market default reads the package's defaults, so a record never keeps the last
15
- * coin market's scaled one there: sized in contracts (CME, every contract market), placed by the directory in another
16
- * unit (shares), or candles in another unit than the tape (an inverse or OKX swap, a formula chart). A market whose
17
- * size unit is not known yet and a chart whose closed candles cover under an hour move nothing: the next run asks
18
- * again.
10
+ * Two rule families, one per unit a package floors in:
19
11
  *
20
- * Pure: the specs and the phone app read the same rule. Its one import is the import-free size unit table.
12
+ * - The DOLLAR rule (C-DOLLAR, Big Trades 0.6.0's Min value and Whale value, the floor every new package uses): the
13
+ * default is 0.01% of the market's daily DOLLAR volume, read from the chart's own candles (each candle's volume x
14
+ * its close x the market's dollar unit, `wrunDailyCandleDollarVolume`), rounded down to 1, 2 or 5 times a power of
15
+ * ten (`wrunNiceFloor`), and Whale value ten times that. The dollar unit is the market facts' (`market.point_value()`
16
+ * on a market quoted in dollars, wrun-chart-market-facts.util `wrunMarketDollarUnit`): 1 where a candle counts coins
17
+ * or shares, the CME root's point value where it counts contracts. ONE rule for every market: the verdict reads the
18
+ * candles and the unit, and never a venue list (a spec walks every venue the pb-common enum names). A market whose
19
+ * unit cannot be proven reads the package's defaults with a named reason (no point value, a quote that is no dollar),
20
+ * or moves nothing while the directory can still name its quote.
21
+ * - The COIN rule (Big Trades 0.5.0's Min size and Whale size, kept so a published 0.5.0 runs exactly as it did): on a
22
+ * market whose size unit is coins and whose candle volume is in base coins, Min size defaults to 0.01% of the daily
23
+ * base volume, rounded the same way, and Whale size to ten times that, so BTC keeps 10 and 100 (131.7K BTC a day)
24
+ * while ETH reads 200 and 2000 (3.13M ETH). Its facts are a venue's raw unit, so a market whose facts never yield a
25
+ * coin default reads the package's defaults: sized in contracts, placed by the directory in another unit (shares), or
26
+ * candles in another unit than the tape (candle-volume-unit.leaf). This is the raw-unit class the dollar rule ends.
27
+ *
28
+ * The CONTRACTS rule (BT-ORDER-FLOOR, Big Trades 0.8.0's Min size and Whale size on a market that counts contracts,
29
+ * `min_contracts` and `whale_contracts`, the floor of its `tape_contracts` input): where the per-order switch holds for
30
+ * a CME Group market (its tape judged per aggressor order; the head reads `wrunTapePerOrder`), Min size defaults by the
31
+ * product root (`WRUN_CME_ROOT_MIN_CONTRACTS`, the root `tradesCmeProductRoot` reads: `NQ1!`, `NQZ6` and `NQ-USD` are
32
+ * NQ), 10 for a root the table lacks, and Whale size to ten times that. Why: an order is one trade, so a flat 10 draws a
33
+ * different density on every root; at 10, NQ showed 652 orders an hour and ES 5,827 on Friday 2026-10-23's open hour,
34
+ * and each table row is the smallest 1, 2 or 5 floor with at most 30 orders an hour there. Where prints are still judged
35
+ * per fill (the switch off, or any venue but the CME Group's), the package's flat 10 and 100 stand (the rule's `package`
36
+ * verdict, reason `per-fill`), so a record a per-order session moved returns to them. Untouched rows only, as every rule.
37
+ *
38
+ * A run reads only the family its sheet declares (`wrunMarketScaledRulesOfSheet`). A market whose closed candles cover
39
+ * under an hour moves nothing: the next run asks again.
40
+ *
41
+ * Beside the volume rules, the OPTION rule (r11, Big Trades 0.7.0's Size shown as, `contracts-option`): a select whose
42
+ * default follows what the chart counts. On a chart that counts contracts (`wrunChartSizeUnit` contracts) whose dollar
43
+ * unit is proven, the rule's option (Contracts or coins: the bubble reads 25 NQ contracts, not $12M); everywhere else
44
+ * the package's own (Dollars). It reads no candles, and skips only while the dollar unit can still be proven, so it
45
+ * never keeps another market's option for good. The run head splits it off the volume rules first
46
+ * (`wrunMarketScaledFamilies`): each family has its own verdict and memo, so a volume rule waiting on its candles never
47
+ * holds the option back.
48
+ *
49
+ * Pure: the specs and the phone app read the same rules. Its one import is the import-free size unit table.
21
50
  */
22
51
  import type { WrunScriptInputDeclaration } from './wrun-script-inputs.util.js';
23
52
  /** How a market-scaled param's default follows the market. */
24
53
  export type WrunMarketScaledRule =
25
- /** A share of the market's daily base volume, rounded down to 1, 2 or 5 times a power of ten. */
54
+ /** A share of the market's daily base volume (the coin rule), rounded down to 1, 2 or 5 times a power of ten. */
26
55
  {
27
56
  readonly kind: 'daily-volume';
28
57
  readonly share: number;
29
58
  }
59
+ /** A share of the market's daily dollar volume (the dollar rule, C-DOLLAR), rounded the same way. `carriesFrom` names
60
+ * the raw-unit param a saved record of an older version held in its place: a value the user changed there is priced
61
+ * into this one once (the pin move keeps it pending, the run head prices it, `wrunCarriedDollarValue`). */
62
+ | {
63
+ readonly kind: 'daily-dollar-volume';
64
+ readonly share: number;
65
+ readonly carriesFrom?: string;
66
+ }
30
67
  /** A multiple of another scaled param's market default (resolved after the ones read off the volume). */
31
68
  | {
32
69
  readonly kind: 'times';
33
70
  readonly param: string;
34
71
  readonly factor: number;
72
+ readonly carriesFrom?: string;
73
+ }
74
+ /** A select's option where the chart counts contracts and its dollar unit is proven, the package's own default
75
+ * everywhere else (`wrunMarketOptionVerdict`). An option is never a value carried from an older version. */
76
+ | {
77
+ readonly kind: 'contracts-option';
78
+ readonly option: number;
79
+ readonly carriesFrom?: never;
80
+ }
81
+ /** A contracts floor by the CME product root (the contracts rule, `wrunMarketContractsVerdict`): the root's row of
82
+ * `table`, `other` for a root it lacks, where the live plane serves per-order prints; the package's default where
83
+ * prints are judged per fill. Never a value carried from an older version (the contracts carry has its own rules). */
84
+ | {
85
+ readonly kind: 'cme-root-contracts';
86
+ readonly table: Readonly<Record<string, number>>;
87
+ readonly other: number;
88
+ readonly carriesFrom?: never;
35
89
  };
90
+ /**
91
+ * Big Trades' Min size in contracts on a CME Group market whose prints are judged per aggressor order, by product root:
92
+ * the smallest 1, 2 or 5 floor with at most 30 orders an hour on Friday 2026-10-23's open hour (at a flat 10, NQ showed
93
+ * 652 orders an hour and ES 5,827). A root the table lacks reads `WRUN_CME_ROOT_MIN_CONTRACTS_OTHER`.
94
+ */
95
+ export declare const WRUN_CME_ROOT_MIN_CONTRACTS: Readonly<Record<string, number>>;
96
+ /** The contracts floor of a CME root the table does not list: the package's 10. */
97
+ export declare const WRUN_CME_ROOT_MIN_CONTRACTS_OTHER = 10;
36
98
  /**
37
99
  * The params whose default follows the market, by package name, then param name (the sheet's own names). A built-in
38
- * twin whose sheet binds a param to a trade size floor lists it here or in the guard's exemptions with a reason
100
+ * twin whose sheet binds a param to a trade floor lists it here or in the guard's exemptions with a reason
39
101
  * (tests/utility/wrun/wrun-market-size-defaults.twins.spec.ts walks every proven twin's frozen sheet).
40
102
  */
41
103
  export declare const WRUN_MARKET_SCALED_PARAMS: Readonly<Record<string, Readonly<Record<string, WrunMarketScaledRule>>>>;
42
104
  /** The scaled params of a package, or undefined for a package that scales none. */
43
105
  export declare function wrunMarketScaledParamsOf(packageName: string | undefined): Readonly<Record<string, WrunMarketScaledRule>> | undefined;
44
- /**
45
- * A market's daily volume in its candles' unit, from the chart's own candles (ascending, the newest the forming
46
- * one, which is left out: its volume is partial): the closed candles opening in the 24 hours before the newest one's
47
- * open, summed and scaled to a day by the span they cover (a fine chart loads less than a day: 500 one-minute candles
48
- * count 499 minutes; a gap where nothing traded counts as covered time with no volume). One closed candle longer than
49
- * a day (1W, 1M) is prorated by its length, the gap to the next open held to `intervalMs`. Undefined when the closed
50
- * candles cover under an hour or hold no volume.
51
- */
106
+ /** The scaled rules a sheet declares params for (a version of the package declares its own: 0.5.0 the coin rule,
107
+ * 0.6.0 the dollar rule, 0.7.0 and 0.8.0 the option rule beside it), or undefined when it declares none. */
108
+ export declare function wrunMarketScaledRulesOfSheet(rules: Readonly<Record<string, WrunMarketScaledRule>> | undefined, paramNames: Iterable<string>): Readonly<Record<string, WrunMarketScaledRule>> | undefined;
109
+ /** A package's scaled rules split by family: the VOLUME rules (`daily-volume`, `daily-dollar-volume` and the
110
+ * multiples of them, read off the candles), the OPTION rules (`contracts-option`, read off the market's units) and the
111
+ * CONTRACTS rules (`cme-root-contracts` and the multiples of them, read off the product root and the live plane). The
112
+ * run head reads each family with its own verdict and memo; a family the rules leave empty is absent. */
113
+ export interface WrunMarketScaledFamilies {
114
+ volume?: Readonly<Record<string, WrunMarketScaledRule>>;
115
+ options?: Readonly<Record<string, WrunMarketScaledRule>>;
116
+ contracts?: Readonly<Record<string, WrunMarketScaledRule>>;
117
+ }
118
+ /** The scaled rules split into their families (`WrunMarketScaledFamilies`): every option rule to `options`, every
119
+ * contracts rule and multiple of one to `contracts`, every other rule to `volume`. */
120
+ export declare function wrunMarketScaledFamilies(rules: Readonly<Record<string, WrunMarketScaledRule>>): WrunMarketScaledFamilies;
121
+ /** A market's daily volume in its candles' unit (the coin rule's volume), `wrunDailyCandleSum` of each candle's
122
+ * volume. */
52
123
  export declare function wrunDailyCandleVolume(rows: ReadonlyArray<ArrayLike<number>>, intervalMs?: number): number | undefined;
124
+ /** A market's daily dollar volume (the dollar rule's volume): `wrunDailyCandleSum` of each candle's volume x its close
125
+ * x `dollarUnit` (the US dollars one price unit times one candle-volume unit is worth). Undefined for a unit that is
126
+ * not finite and above zero. */
127
+ export declare function wrunDailyCandleDollarVolume(rows: ReadonlyArray<ArrayLike<number>>, dollarUnit: number, intervalMs?: number): number | undefined;
53
128
  /**
54
129
  * The largest 1, 2 or 5 times a power of ten at or below `value` (5,000,000, 200, 10, then 0.5, 0.2, 0.1 below 1), as
55
130
  * a clean decimal; undefined for a value that is not finite and above zero.
56
131
  */
57
132
  export declare function wrunNiceFloor(value: number): number | undefined;
58
133
  /**
59
- * Each scaled param's default on a market trading `dailyVolume` base units a day: the daily-volume rules first, then
60
- * the multiples of them. Undefined when the volume yields no default (not finite and above zero).
134
+ * Each scaled param's default on a market trading `dailyVolume` base units a day and `dailyDollarVolume` dollars a
135
+ * day: the volume rules first (each reads its own family's volume), then the multiples of them. Undefined when a rule's
136
+ * volume yields no default (absent, or not finite and above zero). An option rule is no volume rule and gets nothing
137
+ * here (its default is `wrunMarketOptionVerdict`'s).
61
138
  */
62
- export declare function wrunMarketScaledDefaults(rules: Readonly<Record<string, WrunMarketScaledRule>>, dailyVolume: number): Record<string, number> | undefined;
63
- /** The market facts the rule reads: the size unit (`wrunChartSizeUnit`), whether the candles' volume is in base
64
- * coins (the venue's unit profile, candle-volume-unit.leaf), the chart's own candle rows and its bar length. */
139
+ export declare function wrunMarketScaledDefaults(rules: Readonly<Record<string, WrunMarketScaledRule>>, dailyVolume: number | undefined, dailyDollarVolume?: number): Record<string, number> | undefined;
140
+ /** The dollar unit a market's facts prove (wrun-chart-market-facts.util `wrunMarketDollarUnit`, read by the head): the
141
+ * US dollars one price unit times one size unit is worth, or why it cannot be proven. */
142
+ export type WrunMarketSizeDollarUnit = {
143
+ kind: 'dollars';
144
+ unit: number;
145
+ } | {
146
+ kind: 'unproven';
147
+ reason: 'point-value' | 'quote';
148
+ transient: boolean;
149
+ };
150
+ /** The market facts the rules read: the size unit (`wrunChartSizeUnit`) and whether the candles' volume is in base
151
+ * coins (the venue's unit profile, candle-volume-unit.leaf) for the coin rule; the market's dollar unit for the dollar
152
+ * rule; the chart's own candle rows and its bar length for both. */
65
153
  export interface WrunMarketSizeFacts {
66
154
  sizeUnit: number;
67
155
  candleVolumeInCoins: boolean;
156
+ /** The dollar rule's unit; absent on a chart whose candles are no market's (a formula chart), which reads the
157
+ * package's defaults (`candle-unit`). */
158
+ dollarUnit?: WrunMarketSizeDollarUnit;
68
159
  rows: ReadonlyArray<ArrayLike<number>>;
69
160
  intervalMs?: number;
70
161
  }
71
162
  /** What a market's facts make of the scaled params' defaults. */
72
163
  export type WrunMarketSizeVerdict =
73
- /** The market's own defaults: a coin market whose candles say how much it trades a day. */
164
+ /** The market's own defaults: a market whose candles say how much it trades a day, in the rules' unit. */
74
165
  {
75
166
  kind: 'market';
76
167
  defaults: Record<string, number>;
77
168
  }
78
169
  /** The package's declared defaults, on facts that never change for the market, so a record moves back to them
79
- * instead of keeping another market's scaled default: sized in contracts (`contracts`: CME, every contract
80
- * market), placed by the directory in another unit (`size-unit`: shares), candles in another unit than the tape
81
- * (`candle-unit`: contracts on an inverse or an OKX swap, a formula chart's candles, which are no market's). */
170
+ * instead of keeping another market's scaled default. The coin rule: sized in contracts (`contracts`: CME, every
171
+ * contract market), placed by the directory in another unit (`size-unit`: shares), candles in another unit than the
172
+ * tape (`candle-unit`: contracts on an inverse or an OKX swap, a formula chart's candles, which are no market's). The
173
+ * dollar rule: no point value (`point-value`: ICE, PLATTS, a CME root off the table), a quote that is no dollar
174
+ * (`quote`: KRW, a coin), a formula chart (`candle-unit`). The contracts rule: prints judged per fill (`per-fill`:
175
+ * the per-order switch off, or a venue it never holds for). */
82
176
  | {
83
177
  kind: 'package';
84
- reason: 'contracts' | 'size-unit' | 'candle-unit';
178
+ reason: 'contracts' | 'size-unit' | 'candle-unit' | 'point-value' | 'quote' | 'per-fill';
85
179
  }
86
180
  /** Nothing moves yet (the record keeps what it holds, and the next run asks again), on facts that can still change:
87
- * a size unit not known yet (`size-unit`: the directory has not placed the market, or its lookup failed), closed
88
- * candles covering under an hour or holding no volume (`cover`). */
181
+ * a size unit not known yet (`size-unit`: the directory has not placed the market, or its lookup failed), a dollar
182
+ * quote the directory can still name (`quote`), closed candles covering under an hour or holding no volume
183
+ * (`cover`). */
89
184
  | {
90
185
  kind: 'skip';
91
- reason: 'size-unit' | 'cover';
186
+ reason: 'size-unit' | 'quote' | 'cover';
92
187
  };
93
- /** The verdict of a market's facts on a package's scaled params (`rules`). */
94
- export declare function wrunMarketSizeVerdict(rules: Readonly<Record<string, WrunMarketScaledRule>>, facts: WrunMarketSizeFacts): WrunMarketSizeVerdict;
95
- /** A number row's value held to its bounds, or undefined for one that is not finite. */
96
- export declare function wrunMarketDefaultWithinRow(row: Pick<WrunScriptInputDeclaration, 'constraints'>, value: unknown): number | undefined;
188
+ /** The verdict of a market's facts on a package's VOLUME rules (`allRules`, one volume family: a sheet declares one,
189
+ * and the head passes `wrunMarketScaledFamilies(...).volume`; an option rule among them is left out, never read as a
190
+ * dollar rule). A set holding both volume families reads the dollar rule only when the coin rule agrees to move (a
191
+ * mixed set is no shipped sheet's; the stricter verdict wins). */
192
+ export declare function wrunMarketSizeVerdict(allRules: Readonly<Record<string, WrunMarketScaledRule>>, facts: WrunMarketSizeFacts): WrunMarketSizeVerdict;
193
+ /**
194
+ * The verdict of a market's facts on a package's OPTION rules (`contracts-option`, the head passes
195
+ * `wrunMarketScaledFamilies(...).options`). It reads no candles: on a chart that counts contracts (`sizeUnit`) whose
196
+ * dollar unit is proven, each rule's option (`market`); the package's own defaults on facts that never change for the
197
+ * market (`package`: a formula chart, `candle-unit`; a dollar unit that can never be proven, its reason; any other size
198
+ * unit, `size-unit`); nothing while the dollar unit can still be proven (`skip`, `quote`), so it is never a skip for
199
+ * good and a record never keeps another market's option.
200
+ */
201
+ export declare function wrunMarketOptionVerdict(rules: Readonly<Record<string, WrunMarketScaledRule>>, facts: WrunMarketSizeFacts): WrunMarketSizeVerdict;
202
+ /** The facts the contracts rule reads, both the head's (wrun-market-size-defaults.util): whether the per-order switch
203
+ * holds for the chart market (`wrunTapePerOrder`: a CME Group venue and the host's `tapePerOrder`), and its CME product
204
+ * root (live-trades-merge.util `tradesCmeProductRoot`, the root the large floor reads). */
205
+ export interface WrunMarketContractsFacts {
206
+ perOrder: boolean;
207
+ root: string | undefined;
208
+ }
209
+ /**
210
+ * The verdict of a market's facts on a package's CONTRACTS rules (the head passes `wrunMarketScaledFamilies(...).
211
+ * contracts`). It reads no candles: where prints are judged per order, each root contracts rule's row for the root
212
+ * (its `other` for a root the table lacks) and each multiple of one (`market`); where they are judged per fill, the
213
+ * package's own defaults (`package`, `per-fill`), so a record never keeps a per-order default once the plane is off.
214
+ */
215
+ export declare function wrunMarketContractsVerdict(rules: Readonly<Record<string, WrunMarketScaledRule>>, facts: WrunMarketContractsFacts): WrunMarketSizeVerdict;
216
+ /** What one unit of a market's STORED trade amount is worth in US dollars (wrun-chart-market-facts.util
217
+ * `wrunMarketStoredUnitDollars`, read by the head: the large-print writer's own price of one, off the market's newest
218
+ * TRADE_LARGE print), or why that cannot be proven (`transient` while a read can still answer it). */
219
+ export type WrunMarketSizeStoredUnit = {
220
+ kind: 'dollars';
221
+ perUnit: number;
222
+ } | {
223
+ kind: 'unproven';
224
+ reason: string;
225
+ transient: boolean;
226
+ };
227
+ /**
228
+ * A raw-unit value the user changed on an older version (C-DOLLAR's carry: Big Trades 0.5.0's Min size or Whale size)
229
+ * priced in dollars once, for the dollar param that took its place: `raw` STORED units (the unit 0.5.0 floored by:
230
+ * contracts on gate.io futures and OKX swaps, USD contracts on an inverse market, contracts on CME) x the dollars one
231
+ * stored unit is worth at the market's price (`perStoredUnit`, `WrunMarketSizeStoredUnit`), held to 3 significant
232
+ * figures, the nearest. A user's own number is never moved on the market defaults' 1, 2 or 5 ladder (`wrunNiceFloor`):
233
+ * that floor cut 5 NQ contracts ($3,002,125) to $2,000,000, about 3.3 contracts, and 60,000 gate.io contracts
234
+ * ($495,078) to $200,000; held to 3 figures they carry $3,000,000 and $495,000. A raw floor is never priced as coins:
235
+ * 60,000 gate.io BTC_USDT contracts are 6 BTC, about $504,000, never 60,000 x the price. Undefined when either fact is
236
+ * not finite and above zero, or their product is not (the carry then waits, never guesses).
237
+ */
238
+ export declare function wrunCarriedDollarValue(raw: unknown, perStoredUnit: number): number | undefined;
239
+ /**
240
+ * Whether a carry keeps the raw value under its old name after pricing it (BT-CME stopgap S0): on a market that counts
241
+ * contracts (`sizeUnit`, `wrunChartSizeUnit` contracts: the CME family) the raw value IS the market's own unit, the
242
+ * contract count a futures trader set, and the version that floors such a market in contracts restores it exactly, so
243
+ * it stays stored (its dollar row's `carriedValue` mark keeps it from pricing twice). Everywhere else the raw value is
244
+ * a venue's stored unit no later version reads, and the carry clears it.
245
+ */
246
+ export declare function wrunCarryKeepsRawValue(sizeUnit: number | undefined): boolean;
247
+ /** A market default as its row holds it: a number row's value held to its bounds (undefined for one that is not
248
+ * finite); a select row's option string when `String(value)` is one of the row's options ("0", "1"), the row's own
249
+ * spelling, else undefined. */
250
+ export declare function wrunMarketDefaultWithinRow(row: Pick<WrunScriptInputDeclaration, 'type' | 'constraints' | 'options'>, value: unknown): number | string | undefined;
97
251
  /**
98
252
  * `rows` (the rows a sheet builds, `buildWrunScriptInputs`) with the market defaults a record holds: each scaled
99
253
  * param's row takes the default its row in `held` (the record's own `scriptInputs`) carries, the one the run head last
100
254
  * moved it to, so a rebuild of the rows from the sheet (a delivered sheet's reconcile, a pin move) never moves a market
101
- * default back to the sheet's, and a value at it never reads as changed. A held default that is not a number within
102
- * the row's bounds stays the sheet's. The same array when nothing moves.
255
+ * default back to the sheet's, and a value at it never reads as changed; and the carried value its held row marks
256
+ * (`carriedValue`, C-DOLLAR's carry), so a rebuild never turns a carried value into one the market defaults move. A
257
+ * held default that is not a number within the row's bounds stays the sheet's, and so does one a select row does not
258
+ * offer (a select keeps the option it names, in its own spelling). The same array when nothing moves.
103
259
  */
104
260
  export declare function wrunRowsKeepingMarketDefaults(rows: WrunScriptInputDeclaration[], held: unknown, packageName: string | undefined): WrunScriptInputDeclaration[];
105
- /** Whether a settings row can hold a market default (a number kind; a sheet that retyped the param keeps its own). */
106
- export declare function isWrunMarketScaledRow(row: Pick<WrunScriptInputDeclaration, 'type'>): boolean;
261
+ /** Whether a settings row can hold the market default of `rule`: a select for an option rule (`contracts-option`), a
262
+ * number kind for every other rule and for no rule given; a sheet that retyped the param keeps its own. */
263
+ export declare function isWrunMarketScaledRow(row: Pick<WrunScriptInputDeclaration, 'type'>, rule?: WrunMarketScaledRule): boolean;