@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,15 +1,50 @@
1
1
  import { WRUN_MARKET_SIZE_UNITS } from './wrun-market-facts.util.js';
2
+ /**
3
+ * Big Trades' Min size in contracts on a CME Group market whose prints are judged per aggressor order, by product root:
4
+ * 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
5
+ * 652 orders an hour and ES 5,827). A root the table lacks reads `WRUN_CME_ROOT_MIN_CONTRACTS_OTHER`.
6
+ */
7
+ export const WRUN_CME_ROOT_MIN_CONTRACTS = Object.freeze({
8
+ NQ: 50,
9
+ ES: 200,
10
+ MNQ: 200,
11
+ MES: 200,
12
+ RTY: 50,
13
+ YM: 20,
14
+ CL: 50,
15
+ GC: 50,
16
+ '6E': 50,
17
+ ZN: 500,
18
+ });
19
+ /** The contracts floor of a CME root the table does not list: the package's 10. */
20
+ export const WRUN_CME_ROOT_MIN_CONTRACTS_OTHER = 10;
2
21
  /**
3
22
  * The params whose default follows the market, by package name, then param name (the sheet's own names). A built-in
4
- * twin whose sheet binds a param to a trade size floor lists it here or in the guard's exemptions with a reason
23
+ * twin whose sheet binds a param to a trade floor lists it here or in the guard's exemptions with a reason
5
24
  * (tests/utility/wrun/wrun-market-size-defaults.twins.spec.ts walks every proven twin's frozen sheet).
6
25
  */
7
26
  export const WRUN_MARKET_SCALED_PARAMS = Object.freeze({
8
27
  '@om-core/big-trades': Object.freeze({
9
- // The tape's floor (its `min_size` facet names it) and the bubbles' size unit: 0.01% of a day's base volume.
28
+ // 0.5.0, the coin rule: the tape's raw floor (its `min_size` facet names it) and the bubbles' size unit.
10
29
  min_size: Object.freeze({ kind: 'daily-volume', share: 0.0001 }),
11
- // The Whale buy and Whale sell signals' threshold, in Min size's unit: ten times its market default.
30
+ // 0.5.0: the Whale buy and Whale sell signals' threshold, in Min size's unit: ten times its market default.
12
31
  whale_size: Object.freeze({ kind: 'times', param: 'min_size', factor: 10 }),
32
+ // 0.6.0, the dollar rule: the tape's dollar floor (its `min_value` facet names it), 0.01% of a day's dollar volume.
33
+ min_value: Object.freeze({ kind: 'daily-dollar-volume', share: 0.0001, carriesFrom: 'min_size' }),
34
+ // 0.6.0: the whale threshold in dollars, ten times Min value's market default.
35
+ whale_value: Object.freeze({ kind: 'times', param: 'min_value', factor: 10, carriesFrom: 'whale_size' }),
36
+ // 0.7.0: Size shown as reads Contracts or coins (1) on a chart that counts contracts, the package's Dollars (0)
37
+ // elsewhere.
38
+ size_shown_as: Object.freeze({ kind: 'contracts-option', option: 1 }),
39
+ // 0.8.0, the contracts rule: Min size by the CME product root where prints are judged per order, the package's
40
+ // flat 10 where they are judged per fill.
41
+ min_contracts: Object.freeze({
42
+ kind: 'cme-root-contracts',
43
+ table: WRUN_CME_ROOT_MIN_CONTRACTS,
44
+ other: WRUN_CME_ROOT_MIN_CONTRACTS_OTHER,
45
+ }),
46
+ // 0.8.0: the whale threshold in contracts, ten times Min size's (the package's 100 per fill).
47
+ whale_contracts: Object.freeze({ kind: 'times', param: 'min_contracts', factor: 10 }),
13
48
  }),
14
49
  });
15
50
  /** The scaled params of a package, or undefined for a package that scales none. */
@@ -18,23 +53,62 @@ export function wrunMarketScaledParamsOf(packageName) {
18
53
  return undefined;
19
54
  return WRUN_MARKET_SCALED_PARAMS[packageName];
20
55
  }
56
+ /** The scaled rules a sheet declares params for (a version of the package declares its own: 0.5.0 the coin rule,
57
+ * 0.6.0 the dollar rule, 0.7.0 and 0.8.0 the option rule beside it), or undefined when it declares none. */
58
+ export function wrunMarketScaledRulesOfSheet(rules, paramNames) {
59
+ if (rules === undefined)
60
+ return undefined;
61
+ const declared = new Set(paramNames);
62
+ const kept = {};
63
+ for (const [name, rule] of Object.entries(rules))
64
+ if (declared.has(name))
65
+ kept[name] = rule;
66
+ return Object.keys(kept).length > 0 ? kept : undefined;
67
+ }
68
+ /** Whether a rule belongs to the contracts family: a root contracts rule, or a multiple of one of `rules`. */
69
+ function isWrunContractsRule(rule, rules) {
70
+ if (rule.kind === 'cme-root-contracts')
71
+ return true;
72
+ return rule.kind === 'times' && rules[rule.param]?.kind === 'cme-root-contracts';
73
+ }
74
+ /** The scaled rules split into their families (`WrunMarketScaledFamilies`): every option rule to `options`, every
75
+ * contracts rule and multiple of one to `contracts`, every other rule to `volume`. */
76
+ export function wrunMarketScaledFamilies(rules) {
77
+ const volume = {};
78
+ const options = {};
79
+ const contracts = {};
80
+ for (const [name, rule] of Object.entries(rules)) {
81
+ if (rule.kind === 'contracts-option')
82
+ options[name] = rule;
83
+ else if (isWrunContractsRule(rule, rules))
84
+ contracts[name] = rule;
85
+ else
86
+ volume[name] = rule;
87
+ }
88
+ return {
89
+ ...(Object.keys(volume).length > 0 ? { volume } : {}),
90
+ ...(Object.keys(options).length > 0 ? { options } : {}),
91
+ ...(Object.keys(contracts).length > 0 ? { contracts } : {}),
92
+ };
93
+ }
21
94
  const HOUR_MS = 3_600_000;
22
95
  const DAY_MS = 86_400_000;
23
- /** The candle row's volume column (`[ts, open, high, low, close, volume]`, the chart's main series rows). */
96
+ /** The candle row's close and volume columns (`[ts, open, high, low, close, volume]`, the chart's main series rows). */
97
+ const CLOSE_COLUMN = 4;
24
98
  const VOLUME_COLUMN = 5;
25
99
  /** `market.size_unit()`'s codes (the kit's table, wrun-market-facts.util). */
26
100
  const UNKNOWN_SIZE_UNIT = WRUN_MARKET_SIZE_UNITS.indexOf('unknown');
27
101
  const COINS_SIZE_UNIT = WRUN_MARKET_SIZE_UNITS.indexOf('coins');
28
102
  const CONTRACTS_SIZE_UNIT = WRUN_MARKET_SIZE_UNITS.indexOf('contracts');
29
103
  /**
30
- * A market's daily volume in its candles' unit, from the chart's own candles (ascending, the newest the forming
31
- * one, which is left out: its volume is partial): the closed candles opening in the 24 hours before the newest one's
32
- * open, summed and scaled to a day by the span they cover (a fine chart loads less than a day: 500 one-minute candles
33
- * count 499 minutes; a gap where nothing traded counts as covered time with no volume). One closed candle longer than
34
- * a day (1W, 1M) is prorated by its length, the gap to the next open held to `intervalMs`. Undefined when the closed
35
- * candles cover under an hour or hold no volume.
104
+ * A candle-volume measure per day, from the chart's own candles (ascending, the newest the forming one, which is left
105
+ * out: its volume is partial): `barValue` of the closed candles opening in the 24 hours before the newest one's open,
106
+ * summed and scaled to a day by the span they cover (a fine chart loads less than a day: 500 one-minute candles count
107
+ * 499 minutes; a gap where nothing traded counts as covered time with no volume). One closed candle longer than a day
108
+ * (1W, 1M) is prorated by its length, the gap to the next open held to `intervalMs`. Undefined when the closed candles
109
+ * cover under an hour or hold no volume.
36
110
  */
37
- export function wrunDailyCandleVolume(rows, intervalMs) {
111
+ function wrunDailyCandleSum(rows, intervalMs, barValue) {
38
112
  const last = rows.length - 1;
39
113
  if (last < 1)
40
114
  return undefined;
@@ -45,7 +119,7 @@ export function wrunDailyCandleVolume(rows, intervalMs) {
45
119
  const barMs = intervalMs !== undefined && Number.isFinite(intervalMs) && intervalMs > 0 ? intervalMs : Infinity;
46
120
  const lastSpan = Math.min(newestOpen - lastClosedOpen, barMs);
47
121
  if (lastSpan > DAY_MS) {
48
- const volume = Number(rows[last - 1][VOLUME_COLUMN]);
122
+ const volume = barValue(rows[last - 1]);
49
123
  return Number.isFinite(volume) && volume > 0 ? (volume * DAY_MS) / lastSpan : undefined;
50
124
  }
51
125
  const windowStart = newestOpen - DAY_MS;
@@ -53,7 +127,7 @@ export function wrunDailyCandleVolume(rows, intervalMs) {
53
127
  for (let at = last - 1; at >= 0; at -= 1) {
54
128
  if (!(Number(rows[at][0]) >= windowStart))
55
129
  break;
56
- const bar = Number(rows[at][VOLUME_COLUMN]);
130
+ const bar = barValue(rows[at]);
57
131
  if (Number.isFinite(bar) && bar > 0)
58
132
  volume += bar;
59
133
  }
@@ -62,6 +136,19 @@ export function wrunDailyCandleVolume(rows, intervalMs) {
62
136
  return undefined;
63
137
  return (volume * DAY_MS) / covered;
64
138
  }
139
+ /** A market's daily volume in its candles' unit (the coin rule's volume), `wrunDailyCandleSum` of each candle's
140
+ * volume. */
141
+ export function wrunDailyCandleVolume(rows, intervalMs) {
142
+ return wrunDailyCandleSum(rows, intervalMs, (row) => Number(row[VOLUME_COLUMN]));
143
+ }
144
+ /** A market's daily dollar volume (the dollar rule's volume): `wrunDailyCandleSum` of each candle's volume x its close
145
+ * x `dollarUnit` (the US dollars one price unit times one candle-volume unit is worth). Undefined for a unit that is
146
+ * not finite and above zero. */
147
+ export function wrunDailyCandleDollarVolume(rows, dollarUnit, intervalMs) {
148
+ if (!(Number.isFinite(dollarUnit) && dollarUnit > 0))
149
+ return undefined;
150
+ return wrunDailyCandleSum(rows, intervalMs, (row) => Number(row[VOLUME_COLUMN]) * Number(row[CLOSE_COLUMN]) * dollarUnit);
151
+ }
65
152
  /**
66
153
  * 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
67
154
  * a clean decimal; undefined for a value that is not finite and above zero.
@@ -77,21 +164,25 @@ export function wrunNiceFloor(value) {
77
164
  return Number((step * scale).toPrecision(1));
78
165
  }
79
166
  /**
80
- * Each scaled param's default on a market trading `dailyVolume` base units a day: the daily-volume rules first, then
81
- * the multiples of them. Undefined when the volume yields no default (not finite and above zero).
167
+ * Each scaled param's default on a market trading `dailyVolume` base units a day and `dailyDollarVolume` dollars a
168
+ * day: the volume rules first (each reads its own family's volume), then the multiples of them. Undefined when a rule's
169
+ * volume yields no default (absent, or not finite and above zero). An option rule is no volume rule and gets nothing
170
+ * here (its default is `wrunMarketOptionVerdict`'s).
82
171
  */
83
- export function wrunMarketScaledDefaults(rules, dailyVolume) {
172
+ export function wrunMarketScaledDefaults(rules, dailyVolume, dailyDollarVolume) {
84
173
  const defaults = {};
85
174
  for (const [name, rule] of Object.entries(rules)) {
86
- if (rule.kind !== 'daily-volume')
175
+ if (rule.kind !== 'daily-volume' && rule.kind !== 'daily-dollar-volume')
87
176
  continue;
88
- const value = wrunNiceFloor(dailyVolume * rule.share);
177
+ const volume = rule.kind === 'daily-volume' ? dailyVolume : dailyDollarVolume;
178
+ const value = volume === undefined ? undefined : wrunNiceFloor(volume * rule.share);
89
179
  if (value === undefined)
90
180
  return undefined;
91
181
  defaults[name] = value;
92
182
  }
93
183
  for (const [name, rule] of Object.entries(rules)) {
94
- if (rule.kind !== 'times')
184
+ // A multiple of a contracts rule is the contracts family's (`wrunMarketContractsVerdict`), never a volume default.
185
+ if (rule.kind !== 'times' || isWrunContractsRule(rule, rules))
95
186
  continue;
96
187
  const base = defaults[rule.param];
97
188
  if (base === undefined)
@@ -100,8 +191,29 @@ export function wrunMarketScaledDefaults(rules, dailyVolume) {
100
191
  }
101
192
  return defaults;
102
193
  }
103
- /** The verdict of a market's facts on a package's scaled params (`rules`). */
104
- export function wrunMarketSizeVerdict(rules, facts) {
194
+ /** Whether a set of rules is the dollar family's (a dollar volume rule, or a multiple of one). */
195
+ function readsDollarVolume(rules) {
196
+ return Object.values(rules).some((rule) => rule.kind === 'daily-dollar-volume');
197
+ }
198
+ /** Whether a set of rules is the coin family's. */
199
+ function readsCoinVolume(rules) {
200
+ return Object.values(rules).some((rule) => rule.kind === 'daily-volume');
201
+ }
202
+ /** The dollar rule's verdict: the candles' dollar volume over the market's proven dollar unit. Reads no venue: the unit
203
+ * is the market facts', and every other input is the chart's own candles. */
204
+ function wrunDollarVerdict(rules, facts) {
205
+ const unit = facts.dollarUnit;
206
+ if (unit === undefined)
207
+ return { kind: 'package', reason: 'candle-unit' };
208
+ if (unit.kind === 'unproven') {
209
+ return unit.transient ? { kind: 'skip', reason: 'quote' } : { kind: 'package', reason: unit.reason };
210
+ }
211
+ const daily = wrunDailyCandleDollarVolume(facts.rows, unit.unit, facts.intervalMs);
212
+ const defaults = daily === undefined ? undefined : wrunMarketScaledDefaults(rules, undefined, daily);
213
+ return defaults === undefined ? { kind: 'skip', reason: 'cover' } : { kind: 'market', defaults };
214
+ }
215
+ /** The coin rule's verdict (unchanged since 0.5.0's round): the candles' base volume on a coin market. */
216
+ function wrunCoinVerdict(rules, facts) {
105
217
  if (facts.sizeUnit === CONTRACTS_SIZE_UNIT)
106
218
  return { kind: 'package', reason: 'contracts' };
107
219
  if (facts.sizeUnit === UNKNOWN_SIZE_UNIT)
@@ -114,8 +226,130 @@ export function wrunMarketSizeVerdict(rules, facts) {
114
226
  const defaults = daily === undefined ? undefined : wrunMarketScaledDefaults(rules, daily);
115
227
  return defaults === undefined ? { kind: 'skip', reason: 'cover' } : { kind: 'market', defaults };
116
228
  }
117
- /** A number row's value held to its bounds, or undefined for one that is not finite. */
229
+ /** The verdict of a market's facts on a package's VOLUME rules (`allRules`, one volume family: a sheet declares one,
230
+ * and the head passes `wrunMarketScaledFamilies(...).volume`; an option rule among them is left out, never read as a
231
+ * dollar rule). A set holding both volume families reads the dollar rule only when the coin rule agrees to move (a
232
+ * mixed set is no shipped sheet's; the stricter verdict wins). */
233
+ export function wrunMarketSizeVerdict(allRules, facts) {
234
+ const rules = wrunMarketScaledFamilies(allRules).volume ?? {};
235
+ const dollar = readsDollarVolume(rules);
236
+ const coin = readsCoinVolume(rules);
237
+ if (dollar && !coin)
238
+ return wrunDollarVerdict(rules, facts);
239
+ if (coin && !dollar)
240
+ return wrunCoinVerdict(rules, facts);
241
+ const coinVerdict = wrunCoinVerdict(wrunRulesOfFamily(rules, 'daily-volume'), facts);
242
+ if (coinVerdict.kind !== 'market')
243
+ return coinVerdict;
244
+ const dollarVerdict = wrunDollarVerdict(wrunRulesOfFamily(rules, 'daily-dollar-volume'), facts);
245
+ if (dollarVerdict.kind !== 'market')
246
+ return dollarVerdict;
247
+ return { kind: 'market', defaults: { ...coinVerdict.defaults, ...dollarVerdict.defaults } };
248
+ }
249
+ /**
250
+ * The verdict of a market's facts on a package's OPTION rules (`contracts-option`, the head passes
251
+ * `wrunMarketScaledFamilies(...).options`). It reads no candles: on a chart that counts contracts (`sizeUnit`) whose
252
+ * dollar unit is proven, each rule's option (`market`); the package's own defaults on facts that never change for the
253
+ * market (`package`: a formula chart, `candle-unit`; a dollar unit that can never be proven, its reason; any other size
254
+ * unit, `size-unit`); nothing while the dollar unit can still be proven (`skip`, `quote`), so it is never a skip for
255
+ * good and a record never keeps another market's option.
256
+ */
257
+ export function wrunMarketOptionVerdict(rules, facts) {
258
+ const unit = facts.dollarUnit;
259
+ if (unit === undefined)
260
+ return { kind: 'package', reason: 'candle-unit' };
261
+ if (unit.kind === 'unproven') {
262
+ return unit.transient ? { kind: 'skip', reason: 'quote' } : { kind: 'package', reason: unit.reason };
263
+ }
264
+ if (facts.sizeUnit !== CONTRACTS_SIZE_UNIT)
265
+ return { kind: 'package', reason: 'size-unit' };
266
+ const defaults = {};
267
+ for (const [name, rule] of Object.entries(rules)) {
268
+ if (rule.kind === 'contracts-option')
269
+ defaults[name] = rule.option;
270
+ }
271
+ return { kind: 'market', defaults };
272
+ }
273
+ /**
274
+ * The verdict of a market's facts on a package's CONTRACTS rules (the head passes `wrunMarketScaledFamilies(...).
275
+ * contracts`). It reads no candles: where prints are judged per order, each root contracts rule's row for the root
276
+ * (its `other` for a root the table lacks) and each multiple of one (`market`); where they are judged per fill, the
277
+ * package's own defaults (`package`, `per-fill`), so a record never keeps a per-order default once the plane is off.
278
+ */
279
+ export function wrunMarketContractsVerdict(rules, facts) {
280
+ if (!facts.perOrder)
281
+ return { kind: 'package', reason: 'per-fill' };
282
+ const defaults = {};
283
+ for (const [name, rule] of Object.entries(rules)) {
284
+ if (rule.kind !== 'cme-root-contracts')
285
+ continue;
286
+ const root = facts.root;
287
+ defaults[name] = root !== undefined && Object.hasOwn(rule.table, root) ? rule.table[root] : rule.other;
288
+ }
289
+ for (const [name, rule] of Object.entries(rules)) {
290
+ if (rule.kind !== 'times' || defaults[rule.param] === undefined)
291
+ continue;
292
+ defaults[name] = Number((defaults[rule.param] * rule.factor).toPrecision(12));
293
+ }
294
+ return { kind: 'market', defaults };
295
+ }
296
+ /** The rules of one family: its volume rules and the multiples of them. */
297
+ function wrunRulesOfFamily(rules, family) {
298
+ const kept = {};
299
+ for (const [name, rule] of Object.entries(rules)) {
300
+ if (rule.kind === family)
301
+ kept[name] = rule;
302
+ }
303
+ for (const [name, rule] of Object.entries(rules)) {
304
+ if (rule.kind === 'times' && Object.hasOwn(kept, rule.param))
305
+ kept[name] = rule;
306
+ }
307
+ return kept;
308
+ }
309
+ /** The significant figures a carried value keeps (`wrunCarriedDollarValue`): at most 0.5% off its exact price. */
310
+ const CARRIED_VALUE_SIGNIFICANT_FIGURES = 3;
311
+ /**
312
+ * 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)
313
+ * priced in dollars once, for the dollar param that took its place: `raw` STORED units (the unit 0.5.0 floored by:
314
+ * contracts on gate.io futures and OKX swaps, USD contracts on an inverse market, contracts on CME) x the dollars one
315
+ * stored unit is worth at the market's price (`perStoredUnit`, `WrunMarketSizeStoredUnit`), held to 3 significant
316
+ * figures, the nearest. A user's own number is never moved on the market defaults' 1, 2 or 5 ladder (`wrunNiceFloor`):
317
+ * that floor cut 5 NQ contracts ($3,002,125) to $2,000,000, about 3.3 contracts, and 60,000 gate.io contracts
318
+ * ($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:
319
+ * 60,000 gate.io BTC_USDT contracts are 6 BTC, about $504,000, never 60,000 x the price. Undefined when either fact is
320
+ * not finite and above zero, or their product is not (the carry then waits, never guesses).
321
+ */
322
+ export function wrunCarriedDollarValue(raw, perStoredUnit) {
323
+ const value = Number(raw);
324
+ if (!Number.isFinite(value) || value <= 0)
325
+ return undefined;
326
+ if (!Number.isFinite(perStoredUnit) || perStoredUnit <= 0)
327
+ return undefined;
328
+ const dollars = value * perStoredUnit;
329
+ if (!Number.isFinite(dollars) || dollars <= 0)
330
+ return undefined;
331
+ return Number(dollars.toPrecision(CARRIED_VALUE_SIGNIFICANT_FIGURES));
332
+ }
333
+ /**
334
+ * Whether a carry keeps the raw value under its old name after pricing it (BT-CME stopgap S0): on a market that counts
335
+ * contracts (`sizeUnit`, `wrunChartSizeUnit` contracts: the CME family) the raw value IS the market's own unit, the
336
+ * contract count a futures trader set, and the version that floors such a market in contracts restores it exactly, so
337
+ * it stays stored (its dollar row's `carriedValue` mark keeps it from pricing twice). Everywhere else the raw value is
338
+ * a venue's stored unit no later version reads, and the carry clears it.
339
+ */
340
+ export function wrunCarryKeepsRawValue(sizeUnit) {
341
+ return sizeUnit === CONTRACTS_SIZE_UNIT;
342
+ }
343
+ /** A market default as its row holds it: a number row's value held to its bounds (undefined for one that is not
344
+ * finite); a select row's option string when `String(value)` is one of the row's options ("0", "1"), the row's own
345
+ * spelling, else undefined. */
118
346
  export function wrunMarketDefaultWithinRow(row, value) {
347
+ if (row.type === 'select') {
348
+ if (typeof value !== 'number' && typeof value !== 'string')
349
+ return undefined;
350
+ const option = String(value);
351
+ return (row.options ?? []).includes(option) ? option : undefined;
352
+ }
119
353
  if (typeof value !== 'number' || !Number.isFinite(value))
120
354
  return undefined;
121
355
  const { min, max } = row.constraints ?? {};
@@ -129,8 +363,10 @@ export function wrunMarketDefaultWithinRow(row, value) {
129
363
  * `rows` (the rows a sheet builds, `buildWrunScriptInputs`) with the market defaults a record holds: each scaled
130
364
  * param's row takes the default its row in `held` (the record's own `scriptInputs`) carries, the one the run head last
131
365
  * moved it to, so a rebuild of the rows from the sheet (a delivered sheet's reconcile, a pin move) never moves a market
132
- * default back to the sheet's, and a value at it never reads as changed. A held default that is not a number within
133
- * the row's bounds stays the sheet's. The same array when nothing moves.
366
+ * default back to the sheet's, and a value at it never reads as changed; and the carried value its held row marks
367
+ * (`carriedValue`, C-DOLLAR's carry), so a rebuild never turns a carried value into one the market defaults move. A
368
+ * 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
369
+ * offer (a select keeps the option it names, in its own spelling). The same array when nothing moves.
134
370
  */
135
371
  export function wrunRowsKeepingMarketDefaults(rows, held, packageName) {
136
372
  const rules = wrunMarketScaledParamsOf(packageName);
@@ -138,22 +374,29 @@ export function wrunRowsKeepingMarketDefaults(rows, held, packageName) {
138
374
  return rows;
139
375
  let moved = false;
140
376
  const kept = rows.map((row) => {
141
- if (!Object.hasOwn(rules, row.name) || !isWrunMarketScaledRow(row))
377
+ if (!Object.hasOwn(rules, row.name) || !isWrunMarketScaledRow(row, rules[row.name]))
142
378
  return row;
143
379
  const own = held.find((candidate) => candidate !== null && typeof candidate === 'object' && candidate.name === row.name);
144
- const value = own?.defaultValue;
145
- if (typeof value !== 'number' || wrunMarketDefaultWithinRow(row, value) !== value)
146
- return row;
147
- if (value === row.defaultValue)
380
+ const value = own?.defaultValue === undefined ? undefined : wrunMarketDefaultWithinRow(row, own.defaultValue);
381
+ // A number within its row's bounds only (one held off them stays the sheet's); a select's option, as it spells it.
382
+ const keepsDefault = value !== undefined && (row.type === 'select' || value === own?.defaultValue) && value !== row.defaultValue;
383
+ const carried = own?.carriedValue;
384
+ const keepsCarried = typeof carried === 'number' && Number.isFinite(carried) && carried !== row.carriedValue;
385
+ if (!keepsDefault && !keepsCarried)
148
386
  return row;
149
387
  moved = true;
150
- return { ...row, defaultValue: value };
388
+ return {
389
+ ...row,
390
+ ...(keepsDefault && value !== undefined ? { defaultValue: value } : {}),
391
+ ...(keepsCarried ? { carriedValue: carried } : {}),
392
+ };
151
393
  });
152
394
  return moved ? kept : rows;
153
395
  }
154
- /** The row kinds a scaled param is: a number, int or price row (they store the same finite number). */
396
+ /** The row kinds a volume rule's param is: a number, int or price row (they store the same finite number). */
155
397
  const WRUN_MARKET_SCALED_ROW_TYPES = new Set(['number', 'int', 'price']);
156
- /** Whether a settings row can hold a market default (a number kind; a sheet that retyped the param keeps its own). */
157
- export function isWrunMarketScaledRow(row) {
158
- return WRUN_MARKET_SCALED_ROW_TYPES.has(row.type);
398
+ /** Whether a settings row can hold the market default of `rule`: a select for an option rule (`contracts-option`), a
399
+ * number kind for every other rule and for no rule given; a sheet that retyped the param keeps its own. */
400
+ export function isWrunMarketScaledRow(row, rule) {
401
+ return rule?.kind === 'contracts-option' ? row.type === 'select' : WRUN_MARKET_SCALED_ROW_TYPES.has(row.type);
159
402
  }
@@ -1,20 +1,64 @@
1
1
  import type { WrunIndicatorMetadata } from '../../interfaces/wrun-runtime.interface.js';
2
+ import { type WrunMarketScaledRule, type WrunMarketSizeStoredUnit } from './wrun-market-size-defaults.leaf.js';
3
+ import { type WrunScriptInputDeclaration } from './wrun-script-inputs.util.js';
4
+ /**
5
+ * Whether a market-scaled row holds a value the user chose (the market defaults never move it): a value off its row's
6
+ * default (the settings panel's reset test, `wrunRowValuesEqual` over `wrunRowValue`), or the value a carry priced into
7
+ * it (`carriedValue`, C-DOLLAR), which counts as chosen even where it equals the row's default: a 0.5.0 Min size of
8
+ * 5,000 Binance delivery contracts of $100 carries $500,000, the sheet's default, and must not follow the next market's
9
+ * default. Pure.
10
+ */
11
+ export declare function wrunMarketScaledRowChanged(record: Readonly<Record<string, unknown>>, row: WrunScriptInputDeclaration): boolean;
2
12
  /**
3
13
  * The patch that moves a record (`settings`: its `scriptInputs` rows and each value flat under its row's name) to a
4
- * market's `defaults`: every scaled row whose value reads as its default (never changed) takes the market's default
5
- * (held to the row's bounds), value and `defaultValue` together. A changed value keeps both: the changed mark is the
6
- * value against its own row's default, so a default moved under a kept value would read the value as never changed on
7
- * the first market whose default equals it, and the next market would move it (SOL 200, then ETH whose default is
8
- * 200, then SOL reset it to 1000). Its reset goes to the default of the market where the user changed it, a save
9
- * whose run head then moves the unchanged value on. Undefined when the record already reads the defaults. Pure.
14
+ * market's `defaults`: every scaled row whose value the user never chose (`wrunMarketScaledRowChanged`) takes the
15
+ * market's default (held to the row's bounds, a select's as the option it names), value and `defaultValue` together.
16
+ * `rules` are the rules the defaults were read by: a select row moves under an option rule only (without them, number
17
+ * rows only, the volume families' kind). A changed value keeps both: the
18
+ * changed mark is the value against its own row's default, so a default moved under a kept value would read the value
19
+ * as never changed on the first market whose default equals it, and the next market would move it (SOL 200, then ETH
20
+ * whose default is 200, then SOL reset it to 1000). Its reset goes to the default of the market where the user changed
21
+ * it, a save whose run head then moves the unchanged value on. A carried value (`carriedValue`) is a changed one too,
22
+ * whatever its row's default. Undefined when the record already reads the defaults. Pure.
23
+ */
24
+ export declare function wrunMarketSizeSettingsPatch(settings: unknown, defaults: Readonly<Record<string, number>>, rules?: Readonly<Record<string, WrunMarketScaledRule>>): Record<string, unknown> | undefined;
25
+ /** A pending carry: a dollar param (`to`) and the raw-unit value an older version's param (`from`) left for it. */
26
+ interface WrunPendingDollarCarry {
27
+ to: string;
28
+ from: string;
29
+ raw: number;
30
+ }
31
+ /** The carries a record holds for the scaled rules its sheet declares: a rule's `carriesFrom` name held flat on the
32
+ * record with a finite positive value while the sheet no longer declares it (the pin move left it there), and while
33
+ * the dollar row holds no carried mark: a carry prices once, so a raw value kept under its old name (a market that
34
+ * counts contracts, `wrunCarryKeepsRawValue`) never prices again, after a reload, a market switch or a reset alike
35
+ * (a reset writes values, never the rows, so the mark stays). */
36
+ export declare function wrunPendingDollarCarries(settings: unknown, rules: Readonly<Record<string, WrunMarketScaledRule>>, sheetParams: ReadonlySet<string>): WrunPendingDollarCarry[];
37
+ /**
38
+ * The patch that prices a record's pending carries once (C-DOLLAR's saved values): each carry's raw value in STORED
39
+ * units x the dollars one stored unit is worth at the market's price (`stored`, wrun-chart-market-facts.util
40
+ * `wrunMarketStoredUnitDollars`), held to 3 significant figures (`wrunCarriedDollarValue`) and to the dollar row's
41
+ * bounds, written flat under the dollar param, and the dollar row marked with it (`carriedValue`: a changed value
42
+ * whatever its row's default, `wrunMarketScaledRowChanged`; its row's default stays). The old name is cleared, except
43
+ * on a market that counts contracts (`sizeUnit`, `wrunCarryKeepsRawValue`), where it stays stored: the version that
44
+ * floors such a market in contracts restores the count exactly, and the mark keeps it from pricing twice (so a carry
45
+ * that keeps its old name and finds no dollar row to mark writes nothing yet). A stored unit that can never be proven
46
+ * (`unproven`, not transient: no large print of the market in the table's week, a quote that is no dollar, a CME
47
+ * contract with no point value) writes no value (the market's dollar default applies) and clears the old name, except
48
+ * on a market that counts contracts; a transient one writes nothing (the next run asks again). `sizeUnit` is required
49
+ * of every caller (undefined where the market's is not known: the old name is cleared), so the engine copy and the
50
+ * workspace row are always carried by one rule. Undefined when nothing moves. Pure.
10
51
  */
11
- export declare function wrunMarketSizeSettingsPatch(settings: unknown, defaults: Readonly<Record<string, number>>): Record<string, unknown> | undefined;
52
+ export declare function wrunDollarCarryPatch(settings: unknown, pending: readonly WrunPendingDollarCarry[], stored: WrunMarketSizeStoredUnit | undefined, sizeUnit: number | undefined): Record<string, unknown> | undefined;
12
53
  /** The chart market the run computes for, as the head reads it. */
13
54
  interface WrunMarketSizeChart {
14
55
  exchange?: unknown;
15
56
  symbol?: unknown;
16
57
  interval?: unknown;
17
58
  transformations?: unknown;
59
+ normalizedSymbol?: unknown;
60
+ category?: unknown;
61
+ resolvedContract?: unknown;
18
62
  }
19
63
  /**
20
64
  * Move an overlay's record to its chart market's scaled defaults (above), at the head of a full run, before the