@orangecharts/wrun-chart-host 0.7.1 → 0.9.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 (210) hide show
  1. package/README.md +27 -4
  2. package/dist/constants/feature-flags.constants.d.ts +5 -0
  3. package/dist/constants/feature-flags.constants.js +32 -0
  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 +14 -0
  7. package/dist/constants/opra-compliance.constants.js +14 -0
  8. package/dist/constants/option-venues.constants.d.ts +29 -6
  9. package/dist/constants/option-venues.constants.js +19 -2
  10. package/dist/constants/venue-presets.constants.d.ts +17 -3
  11. package/dist/constants/venue-presets.constants.js +17 -3
  12. package/dist/host-env.d.ts +34 -4
  13. package/dist/host-env.js +21 -0
  14. package/dist/host-ports.types.d.ts +51 -3
  15. package/dist/index.d.ts +17 -0
  16. package/dist/index.js +17 -0
  17. package/dist/indicators/controls/tpo-session.util.d.ts +40 -11
  18. package/dist/indicators/controls/tpo-session.util.js +138 -14
  19. package/dist/interfaces/opra-realtime.interface.d.ts +13 -11
  20. package/dist/interfaces/opra-realtime.interface.js +10 -10
  21. package/dist/interfaces/option-instrument.interface.d.ts +6 -0
  22. package/dist/interfaces/wrun-runtime.interface.d.ts +34 -13
  23. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +57 -10
  24. package/dist/kscript-data/controls/live-trades-merge.util.js +85 -16
  25. package/dist/market-data/billing.interface.d.ts +138 -17
  26. package/dist/market-data/billing.interface.js +25 -8
  27. package/dist/market-data/venues/index.d.ts +3 -3
  28. package/dist/market-data/venues/opra.contract.copy.json +5 -3
  29. package/dist/market-data/venues/opra.d.ts +3 -3
  30. package/dist/market-data/venues/opra.js +5 -4
  31. package/dist/replay/replayLadder.js +3 -1
  32. package/dist/settings-templates/footprint-rows.d.ts +25 -0
  33. package/dist/settings-templates/footprint-rows.js +127 -0
  34. package/dist/settings-templates/form-rows.d.ts +56 -0
  35. package/dist/settings-templates/form-rows.js +19 -0
  36. package/dist/settings-templates/frvp-fields.js +14 -0
  37. package/dist/settings-templates/index.d.ts +10 -1
  38. package/dist/settings-templates/index.js +11 -2
  39. package/dist/settings-templates/indicator-fields.js +78 -0
  40. package/dist/settings-templates/tool-rules.d.ts +35 -9
  41. package/dist/settings-templates/tool-rules.js +42 -8
  42. package/dist/settings-templates/tool-tables.generated.js +13 -2
  43. package/dist/utility/chart/candle-volume-unit.leaf.d.ts +16 -0
  44. package/dist/utility/chart/candle-volume-unit.leaf.js +61 -0
  45. package/dist/utility/chart/crypto-index.leaf.d.ts +2 -2
  46. package/dist/utility/chart/crypto-index.leaf.js +2 -2
  47. package/dist/utility/chart/footprint-columns.util.d.ts +74 -0
  48. package/dist/utility/chart/footprint-columns.util.js +106 -0
  49. package/dist/utility/chart/footprint-display-mode.util.d.ts +40 -0
  50. package/dist/utility/chart/footprint-display-mode.util.js +62 -0
  51. package/dist/utility/chart/footprint-sierra-look.util.d.ts +2 -0
  52. package/dist/utility/chart/footprint-sierra-look.util.js +37 -0
  53. package/dist/utility/chart/index-mode-admission.util.js +9 -1
  54. package/dist/utility/chart/index-mode.util.d.ts +5 -2
  55. package/dist/utility/chart/index-mode.util.js +23 -13
  56. package/dist/utility/chart/kscript-venue-policy.util.d.ts +28 -21
  57. package/dist/utility/chart/kscript-venue-policy.util.js +34 -26
  58. package/dist/utility/chart/marketKind.util.d.ts +12 -10
  59. package/dist/utility/chart/marketKind.util.js +17 -7
  60. package/dist/utility/chart/om-panel-push-style.util.d.ts +7 -7
  61. package/dist/utility/chart/om-panel-push-style.util.js +17 -15
  62. package/dist/utility/chart/om-panel.util.d.ts +11 -0
  63. package/dist/utility/chart/om-panel.util.js +65 -6
  64. package/dist/utility/chart/profile-block-size.util.d.ts +16 -0
  65. package/dist/utility/chart/profile-block-size.util.js +7 -0
  66. package/dist/utility/chart/quote-perp.leaf.d.ts +17 -0
  67. package/dist/utility/chart/quote-perp.leaf.js +20 -0
  68. package/dist/utility/chart/window-geometry.leaf.d.ts +23 -1
  69. package/dist/utility/chart/window-geometry.leaf.js +78 -6
  70. package/dist/utility/chart/window-owner.leaf.d.ts +13 -0
  71. package/dist/utility/chart/window-owner.leaf.js +5 -0
  72. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -0
  73. package/dist/utility/chart/wrun-run-result.util.js +4 -1
  74. package/dist/utility/common/transformations.util.d.ts +7 -0
  75. package/dist/utility/common/transformations.util.js +11 -0
  76. package/dist/utility/options/cme-options-root.util.d.ts +25 -0
  77. package/dist/utility/options/cme-options-root.util.js +40 -0
  78. package/dist/utility/options/option-book.util.d.ts +27 -0
  79. package/dist/utility/options/option-book.util.js +76 -0
  80. package/dist/utility/options/option-trade-date.util.d.ts +50 -0
  81. package/dist/utility/options/option-trade-date.util.js +120 -0
  82. package/dist/utility/options/option-venue.util.d.ts +3 -3
  83. package/dist/utility/options/option-venue.util.js +3 -3
  84. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +1 -1
  85. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +2 -2
  86. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +2 -2
  87. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +5 -1
  88. package/dist/utility/wrun/sources/host-grid-landing.d.ts +4 -2
  89. package/dist/utility/wrun/sources/host-grid-landing.js +8 -0
  90. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +40 -4
  91. package/dist/utility/wrun/sources/lanes/options_flow.js +115 -18
  92. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +12 -9
  93. package/dist/utility/wrun/sources/opra-option-lanes.util.js +10 -7
  94. package/dist/utility/wrun/sources/row-lane-registry.js +10 -5
  95. package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
  96. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +3 -2
  97. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +30 -5
  98. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +9 -3
  99. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +13 -5
  100. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +25 -1
  101. package/dist/utility/wrun/sources/row-lanes/option_prints.js +161 -30
  102. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.d.ts +4 -0
  103. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +65 -0
  104. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +55 -1
  105. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +83 -2
  106. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +17 -1
  107. package/dist/utility/wrun/sources/row-lanes/option_surface.js +33 -2
  108. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +7 -1
  109. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +51 -5
  110. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +136 -3
  111. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +42 -0
  112. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +146 -0
  113. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +25 -5
  114. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +111 -20
  115. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +291 -48
  116. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +16 -3
  117. package/dist/utility/wrun/wrun-batched-marks.util.js +30 -19
  118. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +37 -9
  119. package/dist/utility/wrun/wrun-batched-readout.util.js +61 -15
  120. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -0
  121. package/dist/utility/wrun/wrun-cell-capacity.leaf.d.ts +66 -0
  122. package/dist/utility/wrun/wrun-cell-capacity.leaf.js +86 -0
  123. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +147 -9
  124. package/dist/utility/wrun/wrun-chart-market-facts.util.js +345 -11
  125. package/dist/utility/wrun/wrun-cloud-record.leaf.d.ts +27 -0
  126. package/dist/utility/wrun/wrun-cloud-record.leaf.js +71 -0
  127. package/dist/utility/wrun/wrun-cloud-record.util.d.ts +4 -21
  128. package/dist/utility/wrun/wrun-cloud-record.util.js +5 -65
  129. package/dist/utility/wrun/wrun-color-facts.util.d.ts +19 -9
  130. package/dist/utility/wrun/wrun-color-facts.util.js +24 -14
  131. package/dist/utility/wrun/wrun-color-settings.util.d.ts +22 -9
  132. package/dist/utility/wrun/wrun-color-settings.util.js +57 -23
  133. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.d.ts +17 -0
  134. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.js +9 -0
  135. package/dist/utility/wrun/wrun-download-meter.util.d.ts +92 -0
  136. package/dist/utility/wrun/wrun-download-meter.util.js +122 -0
  137. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +10 -3
  138. package/dist/utility/wrun/wrun-draft-overlay.util.js +63 -6
  139. package/dist/utility/wrun/wrun-frames.js +5 -5
  140. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
  141. package/dist/utility/wrun/wrun-hosted-wire-caps.js +11 -0
  142. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +33 -17
  143. package/dist/utility/wrun/wrun-hud-looks.util.js +30 -16
  144. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +29 -3
  145. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +33 -3
  146. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +8 -6
  147. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +8 -6
  148. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -2
  149. package/dist/utility/wrun/wrun-live-intake.util.d.ts +6 -2
  150. package/dist/utility/wrun/wrun-live-intake.util.js +136 -21
  151. package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -1
  152. package/dist/utility/wrun/wrun-live-tick.util.js +130 -44
  153. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.d.ts +53 -0
  154. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.js +162 -0
  155. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +224 -0
  156. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +342 -0
  157. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +88 -0
  158. package/dist/utility/wrun/wrun-market-size-defaults.util.js +471 -0
  159. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +43 -8
  160. package/dist/utility/wrun/wrun-opra-flow.leaf.js +37 -6
  161. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +51 -10
  162. package/dist/utility/wrun/wrun-option-contract-flow.util.js +85 -33
  163. package/dist/utility/wrun/wrun-option-prints.util.d.ts +172 -3
  164. package/dist/utility/wrun/wrun-option-prints.util.js +394 -17
  165. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +99 -0
  166. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +218 -0
  167. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +365 -0
  168. package/dist/utility/wrun/wrun-option-strike-flow.util.js +797 -0
  169. package/dist/utility/wrun/wrun-option-views.util.d.ts +231 -7
  170. package/dist/utility/wrun/wrun-option-views.util.js +643 -23
  171. package/dist/utility/wrun/wrun-options-chain.util.d.ts +6 -4
  172. package/dist/utility/wrun/wrun-options-chain.util.js +8 -5
  173. package/dist/utility/wrun/wrun-options-stop.util.d.ts +2 -1
  174. package/dist/utility/wrun/wrun-options-stop.util.js +3 -2
  175. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +3 -0
  176. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +31 -14
  177. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +22 -0
  178. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +9 -1
  179. package/dist/utility/wrun/wrun-overlay-recovery.util.js +32 -3
  180. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +7 -1
  181. package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
  182. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +34 -6
  183. package/dist/utility/wrun/wrun-overlay-run.util.js +527 -180
  184. package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +15 -0
  185. package/dist/utility/wrun/wrun-pack-widths.leaf.js +22 -0
  186. package/dist/utility/wrun/wrun-pack.util.d.ts +13 -8
  187. package/dist/utility/wrun/wrun-pack.util.js +38 -21
  188. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +4 -0
  189. package/dist/utility/wrun/wrun-panel-mount.util.js +62 -22
  190. package/dist/utility/wrun/wrun-panel-style.util.d.ts +41 -14
  191. package/dist/utility/wrun/wrun-panel-style.util.js +86 -26
  192. package/dist/utility/wrun/wrun-param-map.util.d.ts +7 -6
  193. package/dist/utility/wrun/wrun-param-map.util.js +8 -5
  194. package/dist/utility/wrun/wrun-param-values.util.d.ts +10 -2
  195. package/dist/utility/wrun/wrun-param-values.util.js +2 -0
  196. package/dist/utility/wrun/wrun-pin-spelling.util.js +19 -10
  197. package/dist/utility/wrun/wrun-prefix-lanes.util.js +2 -2
  198. package/dist/utility/wrun/wrun-refusal.util.js +17 -2
  199. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +20 -0
  200. package/dist/utility/wrun/wrun-script-inputs.util.js +43 -0
  201. package/dist/utility/wrun/wrun-source-rows.util.d.ts +4 -0
  202. package/dist/utility/wrun/wrun-source-rows.util.js +92 -40
  203. package/dist/utility/wrun/wrun-tape-source.util.d.ts +133 -48
  204. package/dist/utility/wrun/wrun-tape-source.util.js +205 -62
  205. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +7 -5
  206. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +8 -6
  207. package/dist/workers/utils/volume-profile.worker.util.d.ts +4 -1
  208. package/dist/workers/utils/volume-profile.worker.util.js +5 -2
  209. package/dist/workers/wrun/wrun-abi-host.js +3 -2
  210. package/package.json +11 -11
@@ -47,7 +47,10 @@
47
47
  * om WRUN_OPTION_FACT_FILLS, which only the chart's browser lane fills): the US
48
48
  * dollars one price unit times one size unit of an option on the chart's options
49
49
  * chain is worth, 100 on OPRA, the CME root's point value, 1 on a crypto chart,
50
- * else 0 (wrunChartOptionMultiplier).
50
+ * else 0 (wrunChartOptionMultiplier); and `market.dollar_multiplier()` (kit 0.95.0):
51
+ * the US dollars one size unit of the market's own trades at one price unit is
52
+ * worth, the market's proven dollar unit (wrunMarketDollarUnit: the CME
53
+ * registry's point value, NQ 20; 1 on a market quoted in dollars), else 0.
51
54
  *
52
55
  * The 0 rule: a fact the chart does not know is 0, never a guess. Main thread
53
56
  * only (the directory read goes through the markets service); the hosted lanes
@@ -74,12 +77,19 @@ export interface WrunOptionFacts {
74
77
  /** The US dollars one price unit times one size unit of an option on the chart's options chain is worth (0 none). */
75
78
  optionMultiplier: number;
76
79
  }
80
+ /** The trade value fact the host fill carries beside the five (kit 0.95.0, `market.dollar_multiplier()`). */
81
+ export interface WrunDollarFacts {
82
+ /** The US dollars one size unit of the market's own trades at one price unit is worth (0 while not proven). */
83
+ dollarMultiplier: number;
84
+ }
77
85
  /** The chart market the facts are of: the chart metadata's own fields. */
78
86
  export interface WrunFactsMarket {
79
87
  exchange?: unknown;
80
88
  symbol?: unknown;
81
89
  normalizedSymbol?: unknown;
82
90
  category?: unknown;
91
+ /** A continuous CME chart's lead contract as the chart stamped it (`ESZ6` under `ES1!`), when it did. */
92
+ resolvedContract?: unknown;
83
93
  }
84
94
  /** The directory row fields the facts read, duck-typed like om's (the wire
85
95
  * carries `assetClass` and `quoteAssetId` beside the declared type). */
@@ -106,6 +116,11 @@ export declare const CME_ROOT_SPECS: Readonly<Record<string, Readonly<CmeRootSpe
106
116
  * knowledge where om's answer is unknown. Pure.
107
117
  */
108
118
  export declare function wrunChartMarketFacts(market: WrunFactsMarket | undefined, row?: WrunMarketDirectoryRow): WrunMarketFacts;
119
+ /** The host_fill word of `market.dollar_multiplier()` (kit 0.95.0). */
120
+ export declare const WRUN_DOLLAR_MULTIPLIER_FILL = "dollar_multiplier";
121
+ /** A sheet reading `market.dollar_multiplier()` on a market whose dollar unit is not proven (wrunMarketDollarUnit):
122
+ * the run head's refusal by name, before any fetch (no trade could be valued). */
123
+ export declare const WRUN_DOLLAR_MULTIPLIER_UNPROVEN_CODE = "wrun_dollar_multiplier_unproven";
109
124
  /**
110
125
  * `market.option_multiplier()` of the chart market `market` (kit 0.87.0): the US dollars one price unit times one
111
126
  * size unit of an option on the chart's options chain is worth, so a package's premium is size x price x the fact.
@@ -132,11 +147,18 @@ export declare function wrunChartMarketFacts(market: WrunFactsMarket | undefined
132
147
  */
133
148
  export declare function wrunChartOptionMultiplier(market: WrunFactsMarket | undefined): number;
134
149
  /** True when the sheet declares one of the market's facts (a host-filled
135
- * param on `kind`, `point_value`, `zone`, `quote_is_usd`, `session_open` or
136
- * `option_multiplier`): the runs whose host fill carries the market's facts.
137
- * Only a sheet that declares a directory fact waits for the read
138
- * (wrunMarketFactsNeedDirectory). */
150
+ * param on `kind`, `point_value`, `zone`, `quote_is_usd`, `session_open`,
151
+ * `option_multiplier` or `dollar_multiplier`): the runs whose host fill
152
+ * carries the market's facts. Only a sheet that declares a directory fact
153
+ * waits for the read (wrunMarketFactsNeedDirectory). */
139
154
  export declare function wrunReadsMarketFacts(metadata: Pick<WrunIndicatorMetadata, 'params'> | undefined): boolean;
155
+ /** True when the sheet reads the market's dollar multiplier (a host-filled param on `dollar_multiplier`, kit
156
+ * 0.95.0): its run proves the market's dollar unit at its head before any fetch (wrun-overlay-run.util), so its
157
+ * module, its batched captions and its dollar tape read one number. */
158
+ export declare function wrunReadsDollarMultiplier(metadata: Pick<WrunIndicatorMetadata, 'params'> | undefined): boolean;
159
+ /** wrunReadsDollarMultiplier over an overlay's declared inputs (`settings.scriptInputs`), for a lane that holds no
160
+ * sheet (the cloud payload): a row under the fact's generated name. */
161
+ export declare function wrunDeclaresDollarMultiplier(declarations: unknown): boolean;
140
162
  /** True when the sheet declares a fact the directory row answers (`kind`,
141
163
  * `quote_is_usd`), or a `visible_by` list on a setting or an output, or a
142
164
  * `needed_by` list on an input source (wrunLaneDemandNeedsDirectory), that
@@ -245,9 +267,125 @@ export declare function warmWrunMarketFacts(market: WrunFactsMarket | undefined)
245
267
  * directory answered, failed recently, or is never asked for its venue. */
246
268
  export declare function wrunMarketFactsSettled(market: WrunFactsMarket | undefined): boolean;
247
269
  /** The facts the chart fills for `market` now (synchronous): the five over the
248
- * directory row once warmWrunMarketFacts settled it, else without one, and
249
- * the option multiplier of its options chain (wrunChartOptionMultiplier: the
250
- * venue tables alone, no read). */
251
- export declare function wrunMarketFactsFor(market: WrunFactsMarket | undefined): WrunMarketFacts & WrunOptionFacts;
270
+ * directory row once warmWrunMarketFacts settled it, else without one, the
271
+ * option multiplier of its options chain (wrunChartOptionMultiplier: the
272
+ * venue tables alone, no read) and the dollar multiplier of its own trades
273
+ * (wrunMarketDollarUnit over the reads warmWrunMarketDollarFacts settled; 0
274
+ * while it is not proven). */
275
+ export declare function wrunMarketFactsFor(market: WrunFactsMarket | undefined): WrunMarketFacts & WrunOptionFacts & WrunDollarFacts;
276
+ /**
277
+ * What the instrument registry (StreamRegistryMetadatas, the metadata service's `getSymbolMetadata`) proves about one
278
+ * market's prices on every wire it rides, so the chart prices a print by the server's own facts, never by a table of
279
+ * ours or a venue list:
280
+ *
281
+ * pointValue the US dollars one whole point of price is worth on one contract of a point-valued product: every CME
282
+ * Group future (ES 50, 6A 100,000, ZN 1,000, and per US cent on the cents-quoted grains: ZC 50, ZL
283
+ * 600), the number the large-print writer prices the table's copies with; null elsewhere. A
284
+ * point-valued product's stored amount is contracts and live-feed never multiplies it, so its COIN arm
285
+ * is contracts too.
286
+ * quote the quote asset its normalized symbol names (`BTC-USDT` quotes USDT).
287
+ *
288
+ * Never the record's `contractMultiplier` or `inverse`: a session that reads the catalog over /v3 (the production
289
+ * route, `METHOD.STREAM_REGISTRY_METADATAS` in workers/constants/gateway-routes.ts) gets a crypto row with no unit
290
+ * field at all (workers/v3/v3-instruments.ts `CRYPTO_CATALOG_TO_V2`: the /v3 CryptoInstrument carries none), so their
291
+ * absence proves nothing; measured 2026-10-22 on a logged-in page, where gate.io futures BTC_USDT read no multiplier
292
+ * that a guest's v2 read gives as 0.0001. The CME translation keeps the point value (`cmeRegistryV2`). A stored unit's
293
+ * dollars are the writer's own rows instead (`warmWrunMarketStoredUnit`). A continuous CME chart (`ES1!`) reads its
294
+ * lead contract's record: the continuous record carries the root's raw multiplier and no point value. Recorded in
295
+ * tests/fixtures/wrun/tape-dollar-units.json: every CME Group root the large-print table floors, its registry point
296
+ * value equal to the writer's quote amount per contract and point.
297
+ */
298
+ export interface WrunMarketTradeUnits {
299
+ pointValue: number | null;
300
+ quote: string | undefined;
301
+ }
302
+ /** The trade units of one registry record (a `getSymbolMetadata` answer), null for no record. Pure. */
303
+ export declare function wrunMarketTradeUnitsOf(record: Record<string, unknown> | null | undefined): WrunMarketTradeUnits | null;
304
+ /**
305
+ * Ask the instrument registry for `market`'s trade units: once per market for the session, a definite answer (the
306
+ * record's units, or none) kept; concurrent callers share one read; a failed read, or a continuous chart whose lead is
307
+ * not known yet, is asked again a minute later. A host whose metadata service reads no registry record
308
+ * (`getSymbolMetadata` unbound) settles none. Never rejects. The read is fresh (`{ fresh: true }`, as the option units
309
+ * read is): a cached record can predate the registry's point value fill.
310
+ */
311
+ export declare function warmWrunMarketTradeUnits(market: WrunFactsMarket | undefined): Promise<void>;
312
+ /** The registry's units of `market` once a read settled them: the units, null for no record, undefined while the
313
+ * registry can still answer (not asked yet, in flight, or a failed read that is retried). Synchronous. */
314
+ export declare function wrunMarketTradeUnitsNow(market: WrunFactsMarket | undefined): WrunMarketTradeUnits | null | undefined;
315
+ /** Warm everything a market's dollar unit and stored unit read (C-DOLLAR): the directory row (a crypto market's quote)
316
+ * and the instrument registry's units. Never rejects. */
317
+ export declare function warmWrunMarketDollarFacts(market: WrunFactsMarket | undefined): Promise<void>;
318
+ /** True when a read of `market`'s dollar unit now would wait on nothing (warmWrunMarketDollarFacts): the directory row
319
+ * (wrunMarketFactsSettled) and the registry's units each answered, failed recently, or are never asked. */
320
+ export declare function wrunMarketDollarFactsSettled(market: WrunFactsMarket | undefined): boolean;
321
+ /** What one price unit times one size unit is worth in US dollars on a market (`unit`), or why that cannot be proven:
322
+ * `point-value` (no point value: ICE, PLATTS, an option contract, a CME contract the registry holds none for) or
323
+ * `quote` (the market is quoted in something other than dollars, or its quote is not known), `transient` while a read
324
+ * can still answer it (the directory row, the registry record). */
325
+ export type WrunMarketDollarUnit = {
326
+ kind: 'dollars';
327
+ unit: number;
328
+ } | {
329
+ kind: 'unproven';
330
+ reason: 'point-value' | 'quote';
331
+ transient: boolean;
332
+ };
333
+ /**
334
+ * The US dollars one price unit times one live-feed COIN-arm size unit is worth on `market` (C-DOLLAR's unit value).
335
+ * ONE rule for every market, read off the server's facts and never off a venue list or a table of ours:
336
+ *
337
+ * - A CME Group contract counts contracts on the COIN arm (live-feed never multiplies a point-valued product), so its
338
+ * unit is the instrument registry's point value, in US dollars per point (`warmWrunMarketTradeUnits`: ES 50, 6A
339
+ * 100,000, a cents-quoted grain per cent, ZC 50 and ZL 600), the number the large-print writer prices the table's
340
+ * copies with. An option contract, or a contract the registry holds no point value for, cannot be priced.
341
+ * - Every other market counts its base asset on the COIN arm (live-feed applied each instrument's contract multiplier
342
+ * and its inverse flag), so its unit is the market facts' point value (1, `market.point_value()`; 0 on ICE and
343
+ * PLATTS, whose multipliers no one serves) on a market quoted in dollars (`wrunMarketQuoteInDollars`).
344
+ *
345
+ * A candle's volume times its close times the unit is that candle's dollar volume (the dollar default,
346
+ * wrun-market-size-defaults), and a live print's price times its COIN-arm size times the unit is the print's dollar
347
+ * value (the tape's live fold). A fact that cannot be proven is a named reason, never a guess; `transient` while a read
348
+ * can still answer it. Synchronous: the reads are taken once `warmWrunMarketDollarFacts` settled them.
349
+ */
350
+ export declare function wrunMarketDollarUnit(market: WrunFactsMarket | undefined): WrunMarketDollarUnit;
351
+ /** What one unit of a market's STORED trade amount is worth in US dollars (`perUnit`, at the price of the large print
352
+ * it was read off), or why that cannot be proven: the dollar unit's reasons, `rows` (no large print to read it off:
353
+ * none in the read's windows, or a host that reads no series). */
354
+ export type WrunMarketStoredUnitDollars = {
355
+ kind: 'dollars';
356
+ perUnit: number;
357
+ } | {
358
+ kind: 'unproven';
359
+ reason: 'point-value' | 'quote' | 'rows';
360
+ transient: boolean;
361
+ };
362
+ /**
363
+ * The large-print writer's dollars per STORED unit off a TRADE_LARGE answer (decoded series frames, the TRADES
364
+ * columns): `quoteAmount / amount` of the newest row whose both are finite and above zero, undefined when no row is.
365
+ * The writer prices each copy per instrument (contracts times the contract multiplier times the price on a linear
366
+ * market, the contract's dollar face on an inverse one, contracts times the price times the point value on CME), so the
367
+ * ratio is what one stored unit was worth at that print, on every venue, with no unit of ours. Pure.
368
+ */
369
+ export declare function wrunStoredUnitDollarsOfRows(frames: readonly unknown[]): number | undefined;
370
+ /**
371
+ * Read what one STORED unit of `market` is worth in dollars off the large-print writer's own rows: the market's newest
372
+ * TRADE_LARGE print (`wrunStoredUnitDollarsOfRows`), through the host's series read on the K_TRADES history's own wire
373
+ * (the chart's market, its wire venue as the K_TRADES worker spells it; TRADE_LARGE is a v2-only read, never the /v3
374
+ * catalog, whose crypto rows carry no unit): one row, newest first, over the table's week. Once per market for the
375
+ * session; concurrent callers share one read; a failed read is asked again a minute later. A host whose v2 service
376
+ * reads no series (`sendSeriesOneShot` unbound) settles none. Never rejects. Only a run head with a raw floor to carry
377
+ * asks it (wrun-market-size-defaults.util).
378
+ */
379
+ export declare function warmWrunMarketStoredUnit(market: WrunFactsMarket | undefined): Promise<void>;
380
+ /**
381
+ * The US dollars one unit of `market`'s STORED trade amount is worth (the large-print table's `amount`, the unit a
382
+ * 0.5.0 Big Trades Min size floored by: contracts of 0.0001 BTC on gate.io futures BTC_USDT, of 0.01 BTC on an OKX
383
+ * swap, $100 contracts on Binance delivery BTCUSD_PERP, contracts on CME): the writer's own price of one, read off the
384
+ * market's newest large print (`warmWrunMarketStoredUnit`), on a market whose dollar unit is proven (its quote
385
+ * amounts are dollars). ONE rule for every venue, linear, inverse and CME alike, no venue list and no multiplier of
386
+ * ours; a fact that cannot be proven is a named reason, `transient` while a read can still answer it. Synchronous over
387
+ * `warmWrunMarketDollarFacts` and `warmWrunMarketStoredUnit`.
388
+ */
389
+ export declare function wrunMarketStoredUnitDollars(market: WrunFactsMarket | undefined): WrunMarketStoredUnitDollars;
252
390
  /** Forget every kept answer (spec isolation). */
253
391
  export declare function clearWrunMarketFactsMemo(): void;
@@ -47,7 +47,10 @@
47
47
  * om WRUN_OPTION_FACT_FILLS, which only the chart's browser lane fills): the US
48
48
  * dollars one price unit times one size unit of an option on the chart's options
49
49
  * chain is worth, 100 on OPRA, the CME root's point value, 1 on a crypto chart,
50
- * else 0 (wrunChartOptionMultiplier).
50
+ * else 0 (wrunChartOptionMultiplier); and `market.dollar_multiplier()` (kit 0.95.0):
51
+ * the US dollars one size unit of the market's own trades at one price unit is
52
+ * worth, the market's proven dollar unit (wrunMarketDollarUnit: the CME
53
+ * registry's point value, NQ 20; 1 on a market quoted in dollars), else 0.
51
54
  *
52
55
  * The 0 rule: a fact the chart does not know is 0, never a guess. Main thread
53
56
  * only (the directory read goes through the markets service); the hosted lanes
@@ -56,11 +59,15 @@
56
59
  import { AssetClass, Category, Exchange } from '@orangecharts/orange-v2-pb-common';
57
60
  import { wrunChartHostEnv } from '../../host-env.js';
58
61
  import { isCmeGoverned } from '../chart/cme-realtime.util.js';
62
+ import { isContinuousSymbol } from '../chart/continuous-contracts.util.js';
59
63
  import { governedContractCoin } from '../chart/governed-contract-coin.util.js';
60
64
  import { checkIsEconomic, getMarketKind } from '../chart/marketKind.util.js';
61
65
  import { optionVenueForExchange, optionVenueForUnderlyingExchange } from '../options/option-venue.util.js';
62
66
  import { WRUN_LANE_CURRENCY_AUTO, WRUN_MARKET_FACT_FILLS, WRUN_MARKET_KINDS, WRUN_MARKET_QUOTE_IS_USD, WRUN_MARKET_SESSION_OPEN_CME, wrunLaneCurrency, wrunMarketSizeUnit, wrunMarketZoneCode, wrunCoinLegSource, wrunFollowsCoin, wrunRowVisibleHere, wrunVisibleByNeedsKind, } from './wrun-market-facts.util.js';
63
67
  import { isWrunLegStreamClass } from './wrun-leg-stream-classes.js';
68
+ import { isTradesDollarQuoteAsset } from '../../kscript-data/controls/live-trades-merge.util.js';
69
+ import { getExchangeFromSymbol } from '../../helpers/data.helpers.js';
70
+ import { bindWrunDollarUnitReader } from './wrun-dollar-unit-port.leaf.js';
64
71
  // ---------------------------------------------------------------------------
65
72
  // om's venue tables, mirrored (each names its om source): the chart must
66
73
  // answer every market om knows the way om does.
@@ -345,6 +352,11 @@ export function wrunChartMarketFacts(market, row) {
345
352
  const sessionOpen = cme ? WRUN_MARKET_SESSION_OPEN_CME : 0;
346
353
  return { kind: kindCode(kind), pointValue, zone, quoteIsUsd: quoteCode(quote), sessionOpen };
347
354
  }
355
+ /** The host_fill word of `market.dollar_multiplier()` (kit 0.95.0). */
356
+ export const WRUN_DOLLAR_MULTIPLIER_FILL = 'dollar_multiplier';
357
+ /** A sheet reading `market.dollar_multiplier()` on a market whose dollar unit is not proven (wrunMarketDollarUnit):
358
+ * the run head's refusal by name, before any fetch (no trade could be valued). */
359
+ export const WRUN_DOLLAR_MULTIPLIER_UNPROVEN_CODE = 'wrun_dollar_multiplier_unproven';
348
360
  /** An OPRA chain's multiplier: US listed options are priced per share and sized in contracts of 100 shares. */
349
361
  const OPRA_OPTION_MULTIPLIER = 100;
350
362
  /** A crypto chain's multiplier, on every venue: prices in US dollars per coin, sizes in coin. */
@@ -405,20 +417,37 @@ export function wrunChartOptionMultiplier(market) {
405
417
  return isCryptoChartVenue(venue) ? CRYPTO_OPTION_MULTIPLIER : 0;
406
418
  }
407
419
  /** The host_fill words whose values the host fill carries off the chart's market (wrunMarketFactsFor): the five
408
- * market facts and the option multiplier (om WRUN_OPTION_FACT_FILLS, a word of the kit's WrunParamHostFill since
409
- * 0.87.0, which the kit exports no runtime list for). */
420
+ * market facts, the option multiplier (om WRUN_OPTION_FACT_FILLS, a word of the kit's WrunParamHostFill since
421
+ * 0.87.0, which the kit exports no runtime list for) and the dollar multiplier (kit 0.95.0). */
410
422
  const WRUN_CHART_MARKET_FILLS = new Set([
411
423
  ...WRUN_MARKET_FACT_FILLS,
412
424
  'option_multiplier',
425
+ WRUN_DOLLAR_MULTIPLIER_FILL,
413
426
  ]);
414
427
  /** True when the sheet declares one of the market's facts (a host-filled
415
- * param on `kind`, `point_value`, `zone`, `quote_is_usd`, `session_open` or
416
- * `option_multiplier`): the runs whose host fill carries the market's facts.
417
- * Only a sheet that declares a directory fact waits for the read
418
- * (wrunMarketFactsNeedDirectory). */
428
+ * param on `kind`, `point_value`, `zone`, `quote_is_usd`, `session_open`,
429
+ * `option_multiplier` or `dollar_multiplier`): the runs whose host fill
430
+ * carries the market's facts. Only a sheet that declares a directory fact
431
+ * waits for the read (wrunMarketFactsNeedDirectory). */
419
432
  export function wrunReadsMarketFacts(metadata) {
420
433
  return (metadata?.params ?? []).some((param) => param.host_fill !== undefined && WRUN_CHART_MARKET_FILLS.has(param.host_fill));
421
434
  }
435
+ /** True when the sheet reads the market's dollar multiplier (a host-filled param on `dollar_multiplier`, kit
436
+ * 0.95.0): its run proves the market's dollar unit at its head before any fetch (wrun-overlay-run.util), so its
437
+ * module, its batched captions and its dollar tape read one number. */
438
+ export function wrunReadsDollarMultiplier(metadata) {
439
+ return (metadata?.params ?? []).some((param) => param.host_fill === WRUN_DOLLAR_MULTIPLIER_FILL);
440
+ }
441
+ /** The hidden param the kit generates for the dollar multiplier (`market_dollar_multiplier`). */
442
+ const WRUN_DOLLAR_MULTIPLIER_PARAM_NAME = `market_${WRUN_DOLLAR_MULTIPLIER_FILL}`;
443
+ /** wrunReadsDollarMultiplier over an overlay's declared inputs (`settings.scriptInputs`), for a lane that holds no
444
+ * sheet (the cloud payload): a row under the fact's generated name. */
445
+ export function wrunDeclaresDollarMultiplier(declarations) {
446
+ return (Array.isArray(declarations) &&
447
+ declarations.some((row) => row !== null &&
448
+ typeof row === 'object' &&
449
+ row.name === WRUN_DOLLAR_MULTIPLIER_PARAM_NAME));
450
+ }
422
451
  /** The facts the directory row answers: wrunChartMarketFacts reads the row for
423
452
  * `kind` (its asset class) and `quote_is_usd` (its quote) alone. The other
424
453
  * three are the venue tables' (`point_value` the CME root's or the venue's
@@ -715,17 +744,322 @@ export function wrunMarketFactsSettled(market) {
715
744
  return settledRows.has(key) || Date.now() < (retryAfter.get(key) ?? 0);
716
745
  }
717
746
  /** The facts the chart fills for `market` now (synchronous): the five over the
718
- * directory row once warmWrunMarketFacts settled it, else without one, and
719
- * the option multiplier of its options chain (wrunChartOptionMultiplier: the
720
- * venue tables alone, no read). */
747
+ * directory row once warmWrunMarketFacts settled it, else without one, the
748
+ * option multiplier of its options chain (wrunChartOptionMultiplier: the
749
+ * venue tables alone, no read) and the dollar multiplier of its own trades
750
+ * (wrunMarketDollarUnit over the reads warmWrunMarketDollarFacts settled; 0
751
+ * while it is not proven). */
721
752
  export function wrunMarketFactsFor(market) {
722
753
  const parts = marketKeyParts(market);
723
754
  const row = parts === undefined ? undefined : settledRows.get(directoryKey(parts.venue, parts.symbol));
724
- return { ...wrunChartMarketFacts(market, row ?? undefined), optionMultiplier: wrunChartOptionMultiplier(market) };
755
+ const dollars = wrunMarketDollarUnit(market);
756
+ return {
757
+ ...wrunChartMarketFacts(market, row ?? undefined),
758
+ optionMultiplier: wrunChartOptionMultiplier(market),
759
+ dollarMultiplier: dollars.kind === 'dollars' ? dollars.unit : 0,
760
+ };
761
+ }
762
+ /** A registry field that is a finite number above zero, else null (absent, zero, negative or unreadable). */
763
+ function positiveUnit(value) {
764
+ const number = typeof value === 'number' ? value : typeof value === 'string' ? Number(value) : Number.NaN;
765
+ return Number.isFinite(number) && number > 0 ? number : null;
766
+ }
767
+ /** The trade units of one registry record (a `getSymbolMetadata` answer), null for no record. Pure. */
768
+ export function wrunMarketTradeUnitsOf(record) {
769
+ if (!isRecordLike(record))
770
+ return null;
771
+ const normalized = upperText(record.normalizedSymbol);
772
+ return {
773
+ pointValue: positiveUnit(record.pointValue),
774
+ quote: normalized === undefined ? undefined : /^[A-Z0-9.]+-([A-Z0-9]+)$/.exec(normalized)?.[1],
775
+ };
776
+ }
777
+ function isRecordLike(value) {
778
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
779
+ }
780
+ /** The registry's units by market (the chart market's `venue\0SYMBOL`) for the session: a record's units, or null
781
+ * for a market the registry holds no record of (or a host that reads none). */
782
+ const settledUnits = new Map();
783
+ /** Registry reads in flight by market. */
784
+ const pendingUnits = new Map();
785
+ /** When a market whose read failed (or whose continuous lead was not known yet) may be asked again (epoch ms). */
786
+ const unitsRetryAfter = new Map();
787
+ /** A read that cannot settle yet: retried after the window (a failed read, a continuous chart's lead not known). */
788
+ class TradeUnitsUnsettled extends Error {
789
+ }
790
+ /** The instrument a market's prints are of: the chart's own symbol, or a continuous CME chart's lead contract (the
791
+ * chart's stamp, else the continuous contracts service's answer). Throws when a continuous chart's lead is not known
792
+ * yet (retried). */
793
+ async function wrunTradeUnitsInstrument(venue, symbol, resolvedContract) {
794
+ if (!isCmeFamily(venue) || !isContinuousSymbol(symbol))
795
+ return symbol;
796
+ const stamped = typeof resolvedContract === 'string' ? resolvedContract.trim() : '';
797
+ if (stamped !== '')
798
+ return stamped;
799
+ const { default: contracts } = await wrunChartHostEnv().market.loadContinuousContracts();
800
+ const lead = await contracts.getResolvedLead(venue, symbol);
801
+ if (lead === null || typeof lead.symbol !== 'string' || lead.symbol === '') {
802
+ throw new TradeUnitsUnsettled(`${venue}:${symbol}`);
803
+ }
804
+ return lead.symbol;
805
+ }
806
+ /**
807
+ * Ask the instrument registry for `market`'s trade units: once per market for the session, a definite answer (the
808
+ * record's units, or none) kept; concurrent callers share one read; a failed read, or a continuous chart whose lead is
809
+ * not known yet, is asked again a minute later. A host whose metadata service reads no registry record
810
+ * (`getSymbolMetadata` unbound) settles none. Never rejects. The read is fresh (`{ fresh: true }`, as the option units
811
+ * read is): a cached record can predate the registry's point value fill.
812
+ */
813
+ export function warmWrunMarketTradeUnits(market) {
814
+ const parts = marketKeyParts(market);
815
+ if (parts === undefined)
816
+ return Promise.resolve();
817
+ const key = directoryKey(parts.venue, parts.symbol);
818
+ if (settledUnits.has(key))
819
+ return Promise.resolve();
820
+ if (Date.now() < (unitsRetryAfter.get(key) ?? 0))
821
+ return Promise.resolve();
822
+ let read = pendingUnits.get(key);
823
+ if (read === undefined) {
824
+ read = (async () => {
825
+ const instrument = await wrunTradeUnitsInstrument(parts.venue, parts.symbol, market?.resolvedContract);
826
+ const { default: metadataService } = await wrunChartHostEnv().market.loadMetadataService();
827
+ if (typeof metadataService.getSymbolMetadata !== 'function')
828
+ return null;
829
+ return wrunMarketTradeUnitsOf(await metadataService.getSymbolMetadata(parts.venue, instrument, { fresh: true }));
830
+ })()
831
+ .then((units) => {
832
+ settledUnits.set(key, units);
833
+ unitsRetryAfter.delete(key);
834
+ })
835
+ .catch(() => {
836
+ unitsRetryAfter.set(key, Date.now() + DIRECTORY_RETRY_MS);
837
+ })
838
+ .finally(() => pendingUnits.delete(key));
839
+ pendingUnits.set(key, read);
840
+ }
841
+ return read;
842
+ }
843
+ /** The registry's units of `market` once a read settled them: the units, null for no record, undefined while the
844
+ * registry can still answer (not asked yet, in flight, or a failed read that is retried). Synchronous. */
845
+ export function wrunMarketTradeUnitsNow(market) {
846
+ const parts = marketKeyParts(market);
847
+ if (parts === undefined)
848
+ return null;
849
+ const key = directoryKey(parts.venue, parts.symbol);
850
+ return settledUnits.has(key) ? (settledUnits.get(key) ?? null) : undefined;
851
+ }
852
+ /** Warm everything a market's dollar unit and stored unit read (C-DOLLAR): the directory row (a crypto market's quote)
853
+ * and the instrument registry's units. Never rejects. */
854
+ export function warmWrunMarketDollarFacts(market) {
855
+ return Promise.all([warmWrunMarketFacts(market), warmWrunMarketTradeUnits(market)]).then(() => undefined);
856
+ }
857
+ /** True when a read of `market`'s dollar unit now would wait on nothing (warmWrunMarketDollarFacts): the directory row
858
+ * (wrunMarketFactsSettled) and the registry's units each answered, failed recently, or are never asked. */
859
+ export function wrunMarketDollarFactsSettled(market) {
860
+ if (!wrunMarketFactsSettled(market))
861
+ return false;
862
+ const parts = marketKeyParts(market);
863
+ if (parts === undefined)
864
+ return true;
865
+ const key = directoryKey(parts.venue, parts.symbol);
866
+ return settledUnits.has(key) || Date.now() < (unitsRetryAfter.get(key) ?? 0);
867
+ }
868
+ /** The quote asset a crypto venue's raw symbol spells after its separator (`BTC_USDT`, `BTC-USDT-SWAP`): positive
869
+ * evidence only (a tail that is no dollar asset, `BTC-PERPETUAL`, proves nothing). */
870
+ function separatedQuote(symbol) {
871
+ const parts = symbol.trim().toUpperCase().split(/[_-]/);
872
+ return parts.length >= 2 && parts[0] !== '' ? parts[1] : undefined;
873
+ }
874
+ /**
875
+ * Whether a market off the CME family is quoted in US dollars, a dollar stablecoin included (the gateway writer's
876
+ * pegged quotes, `isTradesDollarQuoteAsset`): US listings and POLYGON_INDICES yes; else the registry record's quote
877
+ * (its normalized symbol), then the directory row's quote, then the chart's own spelling of the pair
878
+ * (`spelledQuote`), then a raw symbol's separated quote when it is a dollar asset. Undefined when nothing says.
879
+ */
880
+ function wrunMarketQuoteInDollars(market, venue, row, units) {
881
+ if (US_LISTING_EXCHANGES.has(venue) || INDEX_EXCHANGES.has(venue))
882
+ return true;
883
+ if (units?.quote !== undefined)
884
+ return isTradesDollarQuoteAsset(units.quote);
885
+ const rowQuoteWord = row === undefined ? undefined : (upperText(row.quoteAssetId) ?? upperText(row.quoteCoinName));
886
+ if (rowQuoteWord !== undefined)
887
+ return isTradesDollarQuoteAsset(rowQuoteWord);
888
+ const spelled = spelledQuote(venue, market);
889
+ if (spelled !== undefined)
890
+ return isTradesDollarQuoteAsset(spelled);
891
+ const separated = typeof market.symbol === 'string' ? separatedQuote(market.symbol) : undefined;
892
+ return separated !== undefined && isTradesDollarQuoteAsset(separated) ? true : undefined;
893
+ }
894
+ /**
895
+ * The US dollars one price unit times one live-feed COIN-arm size unit is worth on `market` (C-DOLLAR's unit value).
896
+ * ONE rule for every market, read off the server's facts and never off a venue list or a table of ours:
897
+ *
898
+ * - A CME Group contract counts contracts on the COIN arm (live-feed never multiplies a point-valued product), so its
899
+ * unit is the instrument registry's point value, in US dollars per point (`warmWrunMarketTradeUnits`: ES 50, 6A
900
+ * 100,000, a cents-quoted grain per cent, ZC 50 and ZL 600), the number the large-print writer prices the table's
901
+ * copies with. An option contract, or a contract the registry holds no point value for, cannot be priced.
902
+ * - Every other market counts its base asset on the COIN arm (live-feed applied each instrument's contract multiplier
903
+ * and its inverse flag), so its unit is the market facts' point value (1, `market.point_value()`; 0 on ICE and
904
+ * PLATTS, whose multipliers no one serves) on a market quoted in dollars (`wrunMarketQuoteInDollars`).
905
+ *
906
+ * A candle's volume times its close times the unit is that candle's dollar volume (the dollar default,
907
+ * wrun-market-size-defaults), and a live print's price times its COIN-arm size times the unit is the print's dollar
908
+ * value (the tape's live fold). A fact that cannot be proven is a named reason, never a guess; `transient` while a read
909
+ * can still answer it. Synchronous: the reads are taken once `warmWrunMarketDollarFacts` settled them.
910
+ */
911
+ export function wrunMarketDollarUnit(market) {
912
+ const parts = marketKeyParts(market);
913
+ if (market === undefined || parts === undefined)
914
+ return { kind: 'unproven', reason: 'quote', transient: false };
915
+ const key = directoryKey(parts.venue, parts.symbol);
916
+ const units = wrunMarketTradeUnitsNow(market);
917
+ if (isCmeFamily(parts.venue)) {
918
+ if (isOptionContract(market.category))
919
+ return { kind: 'unproven', reason: 'point-value', transient: false };
920
+ if (units === undefined)
921
+ return { kind: 'unproven', reason: 'point-value', transient: true };
922
+ return units?.pointValue != null
923
+ ? { kind: 'dollars', unit: units.pointValue }
924
+ : { kind: 'unproven', reason: 'point-value', transient: false };
925
+ }
926
+ const row = settledRows.get(key) ?? undefined;
927
+ const { pointValue } = wrunChartMarketFacts(market, row);
928
+ if (!(Number.isFinite(pointValue) && pointValue > 0)) {
929
+ return { kind: 'unproven', reason: 'point-value', transient: false };
930
+ }
931
+ const dollars = wrunMarketQuoteInDollars(market, parts.venue, row, units);
932
+ if (dollars === true)
933
+ return { kind: 'dollars', unit: pointValue };
934
+ // Unknown while a read can still answer the quote (the registry record or the directory row: not asked yet, or a
935
+ // failed read that is retried); a quote an answer or the market's own spelling names is no dollar quote for good.
936
+ const answered = units !== undefined && (!directoryAnswers(parts.venue) || settledRows.has(key));
937
+ return { kind: 'unproven', reason: 'quote', transient: dollars === undefined && !answered };
938
+ }
939
+ /** The writer's dollars per stored unit by market for the session: a number, or null for a market with no large print
940
+ * in any window (or a host that reads no series). */
941
+ const settledStoredUnits = new Map();
942
+ /** Stored unit reads in flight by market. */
943
+ const pendingStoredUnits = new Map();
944
+ /** When a market whose stored unit read failed may be asked again (epoch ms). */
945
+ const storedUnitsRetryAfter = new Map();
946
+ /** How far back the newest large print is looked for: the large table's own retention (a week). The read asks one
947
+ * row, newest first, so a busy market answers one print, not a week of them (measured 2026-10-22: one row on
948
+ * BINANCE_FUTURES BTCUSDT, gate.io futures BTC_USDT and CME ESZ6 and ES1!). */
949
+ const STORED_UNIT_WINDOW_SEC = 7 * 86_400;
950
+ const STORED_UNIT_TIMEOUT_MS = 20_000;
951
+ /**
952
+ * The large-print writer's dollars per STORED unit off a TRADE_LARGE answer (decoded series frames, the TRADES
953
+ * columns): `quoteAmount / amount` of the newest row whose both are finite and above zero, undefined when no row is.
954
+ * The writer prices each copy per instrument (contracts times the contract multiplier times the price on a linear
955
+ * market, the contract's dollar face on an inverse one, contracts times the price times the point value on CME), so the
956
+ * ratio is what one stored unit was worth at that print, on every venue, with no unit of ours. Pure.
957
+ */
958
+ export function wrunStoredUnitDollarsOfRows(frames) {
959
+ let newestTs = Number.NEGATIVE_INFINITY;
960
+ let perUnit;
961
+ for (const frame of frames) {
962
+ const records = frame?.records;
963
+ const length = Number(records?.length);
964
+ if (records === undefined || !(length > 0) || !records.ts || !records.volume || !records.quoteAmount)
965
+ continue;
966
+ for (let at = 0; at < length; at += 1) {
967
+ const ts = Number(records.ts[at]);
968
+ const amount = Number(records.volume[at]);
969
+ const quote = Number(records.quoteAmount[at]);
970
+ if (!Number.isFinite(ts) || !(Number.isFinite(amount) && amount > 0) || !(Number.isFinite(quote) && quote > 0)) {
971
+ continue;
972
+ }
973
+ if (ts > newestTs) {
974
+ newestTs = ts;
975
+ perUnit = quote / amount;
976
+ }
977
+ }
978
+ }
979
+ return perUnit;
980
+ }
981
+ /**
982
+ * Read what one STORED unit of `market` is worth in dollars off the large-print writer's own rows: the market's newest
983
+ * TRADE_LARGE print (`wrunStoredUnitDollarsOfRows`), through the host's series read on the K_TRADES history's own wire
984
+ * (the chart's market, its wire venue as the K_TRADES worker spells it; TRADE_LARGE is a v2-only read, never the /v3
985
+ * catalog, whose crypto rows carry no unit): one row, newest first, over the table's week. Once per market for the
986
+ * session; concurrent callers share one read; a failed read is asked again a minute later. A host whose v2 service
987
+ * reads no series (`sendSeriesOneShot` unbound) settles none. Never rejects. Only a run head with a raw floor to carry
988
+ * asks it (wrun-market-size-defaults.util).
989
+ */
990
+ export function warmWrunMarketStoredUnit(market) {
991
+ const parts = marketKeyParts(market);
992
+ if (parts === undefined)
993
+ return Promise.resolve();
994
+ const key = directoryKey(parts.venue, parts.symbol);
995
+ if (settledStoredUnits.has(key))
996
+ return Promise.resolve();
997
+ if (Date.now() < (storedUnitsRetryAfter.get(key) ?? 0))
998
+ return Promise.resolve();
999
+ let read = pendingStoredUnits.get(key);
1000
+ if (read === undefined) {
1001
+ read = (async () => {
1002
+ const { default: v2 } = await wrunChartHostEnv().transport.loadV2Service();
1003
+ if (typeof v2.sendSeriesOneShot !== 'function')
1004
+ return null;
1005
+ const toUnixS = Math.floor(Date.now() / 1000);
1006
+ const descriptor = {
1007
+ domain: 'CRYPTO',
1008
+ metric: 'TRADES',
1009
+ ref: { exchange: getExchangeFromSymbol(parts.venue, parts.symbol), symbol: parts.symbol },
1010
+ window: { fromUnixS: toUnixS - STORED_UNIT_WINDOW_SEC, toUnixS },
1011
+ paging: { limit: 1, direction: 'DESC' },
1012
+ v2Only: { type: 'TRADE_LARGE' },
1013
+ };
1014
+ const frames = await v2.sendSeriesOneShot(descriptor, { timeoutMs: STORED_UNIT_TIMEOUT_MS });
1015
+ return wrunStoredUnitDollarsOfRows(frames) ?? null;
1016
+ })()
1017
+ .then((perUnit) => {
1018
+ settledStoredUnits.set(key, perUnit);
1019
+ storedUnitsRetryAfter.delete(key);
1020
+ })
1021
+ .catch(() => {
1022
+ storedUnitsRetryAfter.set(key, Date.now() + DIRECTORY_RETRY_MS);
1023
+ })
1024
+ .finally(() => pendingStoredUnits.delete(key));
1025
+ pendingStoredUnits.set(key, read);
1026
+ }
1027
+ return read;
1028
+ }
1029
+ /**
1030
+ * The US dollars one unit of `market`'s STORED trade amount is worth (the large-print table's `amount`, the unit a
1031
+ * 0.5.0 Big Trades Min size floored by: contracts of 0.0001 BTC on gate.io futures BTC_USDT, of 0.01 BTC on an OKX
1032
+ * swap, $100 contracts on Binance delivery BTCUSD_PERP, contracts on CME): the writer's own price of one, read off the
1033
+ * market's newest large print (`warmWrunMarketStoredUnit`), on a market whose dollar unit is proven (its quote
1034
+ * amounts are dollars). ONE rule for every venue, linear, inverse and CME alike, no venue list and no multiplier of
1035
+ * ours; a fact that cannot be proven is a named reason, `transient` while a read can still answer it. Synchronous over
1036
+ * `warmWrunMarketDollarFacts` and `warmWrunMarketStoredUnit`.
1037
+ */
1038
+ export function wrunMarketStoredUnitDollars(market) {
1039
+ const unit = wrunMarketDollarUnit(market);
1040
+ if (unit.kind === 'unproven')
1041
+ return unit;
1042
+ const parts = marketKeyParts(market);
1043
+ const key = parts === undefined ? undefined : directoryKey(parts.venue, parts.symbol);
1044
+ if (key === undefined || !settledStoredUnits.has(key))
1045
+ return { kind: 'unproven', reason: 'rows', transient: true };
1046
+ const perUnit = settledStoredUnits.get(key);
1047
+ return perUnit === null || perUnit === undefined
1048
+ ? { kind: 'unproven', reason: 'rows', transient: false }
1049
+ : { kind: 'dollars', perUnit };
725
1050
  }
726
1051
  /** Forget every kept answer (spec isolation). */
727
1052
  export function clearWrunMarketFactsMemo() {
728
1053
  settledRows.clear();
729
1054
  pendingRows.clear();
730
1055
  retryAfter.clear();
1056
+ settledUnits.clear();
1057
+ pendingUnits.clear();
1058
+ unitsRetryAfter.clear();
1059
+ settledStoredUnits.clear();
1060
+ pendingStoredUnits.clear();
1061
+ storedUnitsRetryAfter.clear();
731
1062
  }
1063
+ // The live intake reads the dollar unit through its port (wrun-dollar-unit-port.leaf), so this module stays off the
1064
+ // pre-candle closure live-feed loads the intake in.
1065
+ bindWrunDollarUnitReader({ unit: wrunMarketDollarUnit, warm: warmWrunMarketDollarFacts });
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The cloud record's migration on read (`wrunCloudRecordOf`) and the pane side a sheet declares (`wrunSheetPositionOf`),
3
+ * moved out of wrun-cloud-record.util, which re-exports both: the kScript venue policy reads the migration
4
+ * synchronously at every run door (titan-charts' dataFetch guard among them, so on the code parsed before the first
5
+ * candle), and the util stays off that path (tests/utility/wrun/wrun-door.closure.spec.ts). A near-leaf (the identity
6
+ * leaf only); the header of wrun-cloud-record.util says what each read is for.
7
+ */
8
+ /** A sheet's chart placement, the registry loader's `packagePosition` read loosely (a record's persisted
9
+ * copy may be trimmed or malformed, a cloud batch's sheet is the cloud's): a declared `overlay` wins; a
10
+ * strategy homes on price; a plotted, non-inset output on the `overlay` panel homes on price; otherwise
11
+ * the primary output's panel decides. */
12
+ export declare function wrunSheetPositionOf(sheet: unknown): 'onchart' | 'offchart';
13
+ /**
14
+ * A record persisted for the protected pipeline before lane parity wave 3, read as the cloud record
15
+ * it is (the migration on read): its wire identity becomes the registry identity (a marketplace mount
16
+ * carried none; one it carried stays, its pane side kept), the slug is the registry's, the row source
17
+ * the cloud's, and the protected flag goes. Every other key rides as persisted. The pane side is the
18
+ * one the record carried, else its persisted sheet's (wrunSheetPositionOf); a record with neither (a
19
+ * marketplace mount) leaves it undecided, so the control mounts it on the price pane and the first
20
+ * batch's delivered sheet decides it, instead of a side guessed here being persisted for good. What
21
+ * else a registry identity naming the same tuple carried (the source mode a mount with the version doc
22
+ * in hand stamped, read by wrunOverlayEditable) stays: a cloud row persisted during the rollout carries
23
+ * `wrunRef` too (wrun-cloud-row-compat.util), and one that reaches the chart past the store's entry (a
24
+ * collab add, a paste) is read here. Undefined for a record that carries no wire identity (nothing to
25
+ * read again).
26
+ */
27
+ export declare function wrunCloudRecordOf(settings: unknown): Record<string, unknown> | undefined;