@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
@@ -46,8 +46,15 @@
46
46
  * Beside the five the host fill carries `market.option_multiplier()` (kit 0.87.0,
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
- * chain is worth, 100 on OPRA, the CME root's point value, 1 on a crypto chart,
50
- * else 0 (wrunChartOptionMultiplier).
49
+ * chain is worth, 100 on OPRA (a stock twin reading its stock's OPRA chain too:
50
+ * the `optionsExchange` fact), the CME root's point value, 1 on a crypto chart,
51
+ * else 0 (wrunChartOptionMultiplier); `market.dollar_multiplier()` (kit 0.95.0):
52
+ * the US dollars one size unit of the market's own trades at one price unit is
53
+ * worth, the market's proven dollar unit (wrunMarketDollarUnit: the CME
54
+ * registry's point value, NQ 20; 1 on a market quoted in dollars), else 0; and
55
+ * `market.option_contract()` (C5, a kit word by 0.102.0): 1 when the chart's
56
+ * market is one option contract (an OPRA contract, a CME or crypto option), else
57
+ * 0 (wrunChartOptionContract), so no recipe guesses it from price distance.
51
58
  *
52
59
  * The 0 rule: a fact the chart does not know is 0, never a guess. Main thread
53
60
  * only (the directory read goes through the markets service); the hosted lanes
@@ -56,11 +63,17 @@
56
63
  import { AssetClass, Category, Exchange } from '@orangecharts/orange-v2-pb-common';
57
64
  import { wrunChartHostEnv } from '../../host-env.js';
58
65
  import { isCmeGoverned } from '../chart/cme-realtime.util.js';
66
+ import { isContinuousSymbol } from '../chart/continuous-contracts.util.js';
59
67
  import { governedContractCoin } from '../chart/governed-contract-coin.util.js';
60
68
  import { checkIsEconomic, getMarketKind } from '../chart/marketKind.util.js';
61
- import { optionVenueForExchange, optionVenueForUnderlyingExchange } from '../options/option-venue.util.js';
69
+ import { optionsMarketUnderlyingVenue, optionVenueForExchange } from '../options/option-venue.util.js';
70
+ import { isPlainOptionContract } from '../options/option-trade-units.util.js';
71
+ import { isOpraGoverned } from '../v2/opra-governed.util.js';
62
72
  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
73
  import { isWrunLegStreamClass } from './wrun-leg-stream-classes.js';
74
+ import { isTradesDollarQuoteAsset } from '../../kscript-data/controls/live-trades-merge.util.js';
75
+ import { getExchangeFromSymbol } from '../../helpers/data.helpers.js';
76
+ import { bindWrunDollarUnitReader } from './wrun-dollar-unit-port.leaf.js';
64
77
  // ---------------------------------------------------------------------------
65
78
  // om's venue tables, mirrored (each names its om source): the chart must
66
79
  // answer every market om knows the way om does.
@@ -167,54 +180,59 @@ const UNKNOWN_MULTIPLIER_EXCHANGES = new Set(['ICE', 'PLATTS']);
167
180
  /** Read-only outside this module: the paper venue reads each contract's point value from it. */
168
181
  export const CME_ROOT_SPECS = {
169
182
  // Equity index futures, quoted in index points: the dollar multiplier.
170
- ES: { kind: 'index', pointValue: 50, quote: 'usd' }, // $50 x S&P 500: equities/sp/e-mini-sandp500
171
- MES: { kind: 'index', pointValue: 5, quote: 'usd' }, // $5 x S&P 500: equities/sp/micro-e-mini-sandp-500
172
- NQ: { kind: 'index', pointValue: 20, quote: 'usd' }, // $20 x Nasdaq-100: equities/nasdaq/e-mini-nasdaq-100
173
- MNQ: { kind: 'index', pointValue: 2, quote: 'usd' }, // $2 x Nasdaq-100: equities/nasdaq/micro-e-mini-nasdaq-100
174
- RTY: { kind: 'index', pointValue: 50, quote: 'usd' }, // $50 x Russell 2000: equities/russell/e-mini-russell-2000
175
- M2K: { kind: 'index', pointValue: 5, quote: 'usd' }, // $5 x Russell 2000: equities/russell/micro-e-mini-russell-2000
176
- YM: { kind: 'index', pointValue: 5, quote: 'usd' }, // $5 x DJIA: equities/dow-jones/e-mini-dow
177
- MYM: { kind: 'index', pointValue: 0.5, quote: 'usd' }, // $0.50 x DJIA: equities/dow-jones/micro-e-mini-dow
183
+ ES: { kind: 'index', pointValue: 50, quote: 'usd', exchange: 'CME' }, // $50 x S&P 500: equities/sp/e-mini-sandp500
184
+ MES: { kind: 'index', pointValue: 5, quote: 'usd', exchange: 'CME' }, // $5 x S&P 500: equities/sp/micro-e-mini-sandp-500
185
+ NQ: { kind: 'index', pointValue: 20, quote: 'usd', exchange: 'CME' }, // $20 x Nasdaq-100: equities/nasdaq/e-mini-nasdaq-100
186
+ MNQ: { kind: 'index', pointValue: 2, quote: 'usd', exchange: 'CME' }, // $2 x Nasdaq-100: equities/nasdaq/micro-e-mini-nasdaq-100
187
+ RTY: { kind: 'index', pointValue: 50, quote: 'usd', exchange: 'CME' }, // $50 x Russell 2000: equities/russell/e-mini-russell-2000
188
+ M2K: { kind: 'index', pointValue: 5, quote: 'usd', exchange: 'CME' }, // $5 x Russell 2000: equities/russell/micro-e-mini-russell-2000
189
+ YM: { kind: 'index', pointValue: 5, quote: 'usd', exchange: 'CBOT' }, // $5 x DJIA: equities/dow-jones/e-mini-dow
190
+ MYM: { kind: 'index', pointValue: 0.5, quote: 'usd', exchange: 'CBOT' }, // $0.50 x DJIA: equities/dow-jones/micro-e-mini-dow
178
191
  // FX futures, quoted in US dollars per unit of the foreign currency (6J per yen, 0.00xxxx).
179
- '6E': { kind: 'forex', pointValue: 125_000, quote: 'usd' }, // 125,000 euro: fx/g10/euro-fx
180
- '6B': { kind: 'forex', pointValue: 62_500, quote: 'usd' }, // 62,500 pounds: fx/g10/british-pound
181
- '6J': { kind: 'forex', pointValue: 12_500_000, quote: 'usd' }, // 12,500,000 yen: fx/g10/japanese-yen
182
- '6C': { kind: 'forex', pointValue: 100_000, quote: 'usd' }, // 100,000 CAD: fx/g10/canadian-dollar
192
+ '6E': { kind: 'forex', pointValue: 125_000, quote: 'usd', exchange: 'CME' }, // 125,000 euro: fx/g10/euro-fx
193
+ '6B': { kind: 'forex', pointValue: 62_500, quote: 'usd', exchange: 'CME' }, // 62,500 pounds: fx/g10/british-pound
194
+ '6J': { kind: 'forex', pointValue: 12_500_000, quote: 'usd', exchange: 'CME' }, // 12,500,000 yen: fx/g10/japanese-yen
195
+ '6C': { kind: 'forex', pointValue: 100_000, quote: 'usd', exchange: 'CME' }, // 100,000 CAD: fx/g10/canadian-dollar
183
196
  // US Treasury futures, quoted in points of par (100): the face value / 100 per point.
184
- ZT: { kind: 'unknown', pointValue: 2_000, quote: 'usd' }, // $200,000 face: interest-rates/us-treasury/2-year-us-treasury-note
185
- ZF: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/5-year-us-treasury-note
186
- ZN: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/10-year-us-treasury-note
187
- TN: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/ultra-10-year-us-treasury-note
188
- ZB: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/30-year-us-treasury-bond
189
- UB: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // $100,000 face: interest-rates/us-treasury/ultra-t-bond
197
+ ZT: { kind: 'unknown', pointValue: 2_000, quote: 'usd', exchange: 'CBOT' }, // $200,000 face: interest-rates/us-treasury/2-year-us-treasury-note
198
+ ZF: { kind: 'unknown', pointValue: 1_000, quote: 'usd', exchange: 'CBOT' }, // $100,000 face: interest-rates/us-treasury/5-year-us-treasury-note
199
+ ZN: { kind: 'unknown', pointValue: 1_000, quote: 'usd', exchange: 'CBOT' }, // $100,000 face: interest-rates/us-treasury/10-year-us-treasury-note
200
+ TN: { kind: 'unknown', pointValue: 1_000, quote: 'usd', exchange: 'CBOT' }, // $100,000 face: interest-rates/us-treasury/ultra-10-year-us-treasury-note
201
+ ZB: { kind: 'unknown', pointValue: 1_000, quote: 'usd', exchange: 'CBOT' }, // $100,000 face: interest-rates/us-treasury/30-year-us-treasury-bond
202
+ UB: { kind: 'unknown', pointValue: 1_000, quote: 'usd', exchange: 'CBOT' }, // $100,000 face: interest-rates/us-treasury/ultra-t-bond
190
203
  // Energy (NYMEX), quoted in US dollars per unit of the commodity.
191
- CL: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // 1,000 barrels: energy/crude-oil/light-sweet-crude
192
- MCL: { kind: 'unknown', pointValue: 100, quote: 'usd' }, // 100 barrels: energy/crude-oil/micro-wti-crude-oil
193
- NG: { kind: 'unknown', pointValue: 10_000, quote: 'usd' }, // 10,000 MMBtu: energy/natural-gas/natural-gas
194
- RB: { kind: 'unknown', pointValue: 42_000, quote: 'usd' }, // 42,000 gallons: energy/refined-products/rbob-gasoline
195
- HO: { kind: 'unknown', pointValue: 42_000, quote: 'usd' }, // 42,000 gallons: energy/refined-products/heating-oil
196
- BZ: { kind: 'unknown', pointValue: 1_000, quote: 'usd' }, // 1,000 barrels: energy/crude-oil/brent-crude-oil-last-day
204
+ CL: { kind: 'unknown', pointValue: 1_000, quote: 'usd', exchange: 'NYMEX' }, // 1,000 barrels: energy/crude-oil/light-sweet-crude
205
+ MCL: { kind: 'unknown', pointValue: 100, quote: 'usd', exchange: 'NYMEX' }, // 100 barrels: energy/crude-oil/micro-wti-crude-oil
206
+ NG: { kind: 'unknown', pointValue: 10_000, quote: 'usd', exchange: 'NYMEX' }, // 10,000 MMBtu: energy/natural-gas/natural-gas
207
+ RB: { kind: 'unknown', pointValue: 42_000, quote: 'usd', exchange: 'NYMEX' }, // 42,000 gallons: energy/refined-products/rbob-gasoline
208
+ HO: { kind: 'unknown', pointValue: 42_000, quote: 'usd', exchange: 'NYMEX' }, // 42,000 gallons: energy/refined-products/heating-oil
209
+ BZ: { kind: 'unknown', pointValue: 1_000, quote: 'usd', exchange: 'NYMEX' }, // 1,000 barrels: energy/crude-oil/brent-crude-oil-last-day
197
210
  // Metals (COMEX), quoted in US dollars per troy ounce (copper per pound).
198
- GC: { kind: 'metal', pointValue: 100, quote: 'usd' }, // 100 troy ounces: metals/precious/gold
199
- MGC: { kind: 'metal', pointValue: 10, quote: 'usd' }, // 10 troy ounces: metals/precious/e-micro-gold
200
- SI: { kind: 'metal', pointValue: 5_000, quote: 'usd' }, // 5,000 troy ounces: metals/precious/silver
201
- SIL: { kind: 'metal', pointValue: 1_000, quote: 'usd' }, // 1,000 troy ounces: metals/precious/1000-oz-silver
202
- HG: { kind: 'metal', pointValue: 25_000, quote: 'usd' }, // 25,000 pounds: metals/base/copper
203
- MHG: { kind: 'metal', pointValue: 2_500, quote: 'usd' }, // 2,500 pounds: metals/base/micro-copper
211
+ GC: { kind: 'metal', pointValue: 100, quote: 'usd', exchange: 'COMEX' }, // 100 troy ounces: metals/precious/gold
212
+ MGC: { kind: 'metal', pointValue: 10, quote: 'usd', exchange: 'COMEX' }, // 10 troy ounces: metals/precious/e-micro-gold
213
+ SI: { kind: 'metal', pointValue: 5_000, quote: 'usd', exchange: 'COMEX' }, // 5,000 troy ounces: metals/precious/silver
214
+ SIL: { kind: 'metal', pointValue: 1_000, quote: 'usd', exchange: 'COMEX' }, // 1,000 troy ounces: metals/precious/1000-oz-silver
215
+ HG: { kind: 'metal', pointValue: 25_000, quote: 'usd', exchange: 'COMEX' }, // 25,000 pounds: metals/base/copper
216
+ MHG: { kind: 'metal', pointValue: 2_500, quote: 'usd', exchange: 'COMEX' }, // 2,500 pounds: metals/base/micro-copper
204
217
  // Grains (CBOT), quoted in US cents per bushel (soybean oil per pound), the unit the chart
205
218
  // draws (corn near 460): a whole point is one cent, worth the contract size in cents, and
206
219
  // the quote is US cents, not dollars (Pine reads `syminfo.currency` "USX" there).
207
- ZC: { kind: 'unknown', pointValue: 5_000, quote: 'other' }, // 5,000 bushels: agriculture/grains/corn
208
- ZW: { kind: 'unknown', pointValue: 5_000, quote: 'other' }, // 5,000 bushels: agriculture/grains/wheat
209
- KE: { kind: 'unknown', pointValue: 5_000, quote: 'other' }, // 5,000 bushels: agriculture/grains/kc-wheat
210
- ZS: { kind: 'unknown', pointValue: 5_000, quote: 'other' }, // 5,000 bushels: agriculture/oilseeds/soybean
211
- ZL: { kind: 'unknown', pointValue: 60_000, quote: 'other' }, // 60,000 pounds: agriculture/oilseeds/soybean-oil
220
+ ZC: { kind: 'unknown', pointValue: 5_000, quote: 'other', exchange: 'CBOT' }, // 5,000 bushels: agriculture/grains/corn
221
+ ZW: { kind: 'unknown', pointValue: 5_000, quote: 'other', exchange: 'CBOT' }, // 5,000 bushels: agriculture/grains/wheat
222
+ KE: { kind: 'unknown', pointValue: 5_000, quote: 'other', exchange: 'CBOT' }, // 5,000 bushels: agriculture/grains/kc-wheat
223
+ ZS: { kind: 'unknown', pointValue: 5_000, quote: 'other', exchange: 'CBOT' }, // 5,000 bushels: agriculture/oilseeds/soybean
224
+ ZL: { kind: 'unknown', pointValue: 60_000, quote: 'other', exchange: 'CBOT' }, // 60,000 pounds: agriculture/oilseeds/soybean-oil
212
225
  // Cryptocurrency futures (CME), quoted in US dollars per coin.
213
- BTC: { kind: 'crypto', pointValue: 5, quote: 'usd' }, // 5 bitcoin: cryptocurrencies/bitcoin/bitcoin
214
- MBT: { kind: 'crypto', pointValue: 0.1, quote: 'usd' }, // 0.1 bitcoin: cryptocurrencies/bitcoin/micro-bitcoin
215
- ETH: { kind: 'crypto', pointValue: 50, quote: 'usd' }, // 50 ether: cryptocurrencies/ether/ether
216
- MET: { kind: 'crypto', pointValue: 0.1, quote: 'usd' }, // 0.1 ether: cryptocurrencies/ether/micro-ether
226
+ BTC: { kind: 'crypto', pointValue: 5, quote: 'usd', exchange: 'CME' }, // 5 bitcoin: cryptocurrencies/bitcoin/bitcoin
227
+ MBT: { kind: 'crypto', pointValue: 0.1, quote: 'usd', exchange: 'CME' }, // 0.1 bitcoin: cryptocurrencies/bitcoin/micro-bitcoin
228
+ ETH: { kind: 'crypto', pointValue: 50, quote: 'usd', exchange: 'CME' }, // 50 ether: cryptocurrencies/ether/ether
229
+ MET: { kind: 'crypto', pointValue: 0.1, quote: 'usd', exchange: 'CME' }, // 0.1 ether: cryptocurrencies/ether/micro-ether
217
230
  };
231
+ /** The CME Group exchange a futures root lists on (`CME_ROOT_SPECS`), or undefined for a root off the table. */
232
+ export function wrunCmeRootExchange(root) {
233
+ const key = root.trim().toUpperCase();
234
+ return Object.prototype.hasOwnProperty.call(CME_ROOT_SPECS, key) ? CME_ROOT_SPECS[key].exchange : undefined;
235
+ }
218
236
  // ---------------------------------------------------------------------------
219
237
  // The facts of one market
220
238
  // ---------------------------------------------------------------------------
@@ -345,6 +363,11 @@ export function wrunChartMarketFacts(market, row) {
345
363
  const sessionOpen = cme ? WRUN_MARKET_SESSION_OPEN_CME : 0;
346
364
  return { kind: kindCode(kind), pointValue, zone, quoteIsUsd: quoteCode(quote), sessionOpen };
347
365
  }
366
+ /** The host_fill word of `market.dollar_multiplier()` (kit 0.95.0). */
367
+ export const WRUN_DOLLAR_MULTIPLIER_FILL = 'dollar_multiplier';
368
+ /** A sheet reading `market.dollar_multiplier()` on a market whose dollar unit is not proven (wrunMarketDollarUnit):
369
+ * the run head's refusal by name, before any fetch (no trade could be valued). */
370
+ export const WRUN_DOLLAR_MULTIPLIER_UNPROVEN_CODE = 'wrun_dollar_multiplier_unproven';
348
371
  /** An OPRA chain's multiplier: US listed options are priced per share and sized in contracts of 100 shares. */
349
372
  const OPRA_OPTION_MULTIPLIER = 100;
350
373
  /** A crypto chain's multiplier, on every venue: prices in US dollars per coin, sizes in coin. */
@@ -377,8 +400,9 @@ function cmeChainRootSpec(market) {
377
400
  * CME a CME-governed chart reads the chain of its own root: the root's point value (CME_ROOT_SPECS, ES 50,
378
401
  * NQ 20) when the root is quoted in US dollars; a root off the table, or quoted in another unit (a CBOT
379
402
  * grain quotes US cents), is 0.
380
- * OPRA a chart whose options list on OPRA (the venue table: an OPRA contract chart, a US stock or ETF chart):
381
- * 100.
403
+ * OPRA a chart whose options list on OPRA (the venue table over the options seam's market, `optionsExchange`
404
+ * else the chart's own: an OPRA contract chart, a US stock or ETF chart, a stock twin while the opra flag
405
+ * is lit): 100.
382
406
  * crypto a chart on a crypto exchange, whichever venue and category (isCryptoChartVenue): its chain, when it has
383
407
  * one, is a crypto chain (its own option venue's, the coin's Deribit chain, or another crypto venue's that
384
408
  * lists the coin), priced in dollars per coin on every venue: 1. A crypto chart with no chain serves no
@@ -399,26 +423,76 @@ export function wrunChartOptionMultiplier(market) {
399
423
  const spec = cmeChainRootSpec(market);
400
424
  return spec?.quote === 'usd' ? spec.pointValue : 0;
401
425
  }
402
- const options = optionVenueForExchange(venue) ?? optionVenueForUnderlyingExchange(venue);
426
+ // The family of the chain the chart reads: the options seam's market's (a stock twin's US stock) when the host named
427
+ // it, else the chart's own.
428
+ const optionsVenue = upperText(market.optionsExchange) ?? venue;
429
+ const options = optionVenueForExchange(optionsVenue) ?? optionsMarketUnderlyingVenue({ exchange: optionsVenue });
403
430
  if (options?.plane === 'opra')
404
431
  return OPRA_OPTION_MULTIPLIER;
405
432
  return isCryptoChartVenue(venue) ? CRYPTO_OPTION_MULTIPLIER : 0;
406
433
  }
434
+ /** The host_fill word of `market.option_contract()` (C5), a WrunParamHostFill word of the kit the chart pins
435
+ * (0.102.0). The host fills the hidden param `market_option_contract` by this word, never by a slot, so a package
436
+ * compiled without the word keeps every init slot and no scaffold bump is needed. */
437
+ export const WRUN_OPTION_CONTRACT_FILL = 'option_contract';
438
+ /**
439
+ * `market.option_contract()` of the chart market `market` (C5): 1 when the chart is one option contract, else 0. A
440
+ * recipe that marks the underlying's prices (Option Prints) reads it to draw no marks on a contract's own price axis,
441
+ * instead of guessing from price distance. The add door's identity (cme-option-indicator-availability.util
442
+ * isOptionContractChart, which the option-contract indicator refusals read), widened to the crypto option venues:
443
+ *
444
+ * OPRA every chart on the OPRA venue is one contract, a document saved without its category included.
445
+ * CME a chart whose category is OPTION (`ESZ6 C6000`): the category tells the contract from the future on the
446
+ * same venue (ESZ6, ES1!).
447
+ * crypto a chart whose category is OPTION, or one on a plain option venue whose symbol the venue's grammar parses
448
+ * (isPlainOptionContract: Deribit `BTC-25DEC26-100000-C`), so a contract saved without its category still
449
+ * reads 1 and the venue's perpetual (`BTC-PERPETUAL`) reads 0.
450
+ * else 0: a stock or ETF (SPY/USD, an options underlying), a future, a perpetual, spot, forex, an index, an
451
+ * economic series, a prediction market, an unknown venue, no market.
452
+ *
453
+ * The chart metadata alone decides, synchronously and with no read, like the option multiplier. Pure.
454
+ */
455
+ export function wrunChartOptionContract(market) {
456
+ const venue = upperText(market?.exchange);
457
+ if (market === undefined || venue === undefined)
458
+ return 0;
459
+ const symbol = typeof market.symbol === 'string' ? market.symbol : '';
460
+ return isOpraGoverned(venue) || isOptionContract(market.category) || isPlainOptionContract(venue, symbol) ? 1 : 0;
461
+ }
407
462
  /** 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). */
463
+ * market facts, the option multiplier (om WRUN_OPTION_FACT_FILLS, a word of the kit's WrunParamHostFill since
464
+ * 0.87.0, which the kit exports no runtime list for), the dollar multiplier (kit 0.95.0) and the option contract
465
+ * (C5). They ride beside the five and never join WRUN_MARKET_FACT_FILLS, which mirrors the kit's own five. */
410
466
  const WRUN_CHART_MARKET_FILLS = new Set([
411
467
  ...WRUN_MARKET_FACT_FILLS,
412
468
  'option_multiplier',
469
+ WRUN_DOLLAR_MULTIPLIER_FILL,
470
+ WRUN_OPTION_CONTRACT_FILL,
413
471
  ]);
414
472
  /** 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). */
473
+ * param on `kind`, `point_value`, `zone`, `quote_is_usd`, `session_open`,
474
+ * `option_multiplier`, `dollar_multiplier` or `option_contract`): the runs
475
+ * whose host fill carries the market's facts. Only a sheet that declares a
476
+ * directory fact waits for the read (wrunMarketFactsNeedDirectory). */
419
477
  export function wrunReadsMarketFacts(metadata) {
420
478
  return (metadata?.params ?? []).some((param) => param.host_fill !== undefined && WRUN_CHART_MARKET_FILLS.has(param.host_fill));
421
479
  }
480
+ /** True when the sheet reads the market's dollar multiplier (a host-filled param on `dollar_multiplier`, kit
481
+ * 0.95.0): its run proves the market's dollar unit at its head before any fetch (wrun-overlay-run.util), so its
482
+ * module, its batched captions and its dollar tape read one number. */
483
+ export function wrunReadsDollarMultiplier(metadata) {
484
+ return (metadata?.params ?? []).some((param) => param.host_fill === WRUN_DOLLAR_MULTIPLIER_FILL);
485
+ }
486
+ /** The hidden param the kit generates for the dollar multiplier (`market_dollar_multiplier`). */
487
+ const WRUN_DOLLAR_MULTIPLIER_PARAM_NAME = `market_${WRUN_DOLLAR_MULTIPLIER_FILL}`;
488
+ /** wrunReadsDollarMultiplier over an overlay's declared inputs (`settings.scriptInputs`), for a lane that holds no
489
+ * sheet (the cloud payload): a row under the fact's generated name. */
490
+ export function wrunDeclaresDollarMultiplier(declarations) {
491
+ return (Array.isArray(declarations) &&
492
+ declarations.some((row) => row !== null &&
493
+ typeof row === 'object' &&
494
+ row.name === WRUN_DOLLAR_MULTIPLIER_PARAM_NAME));
495
+ }
422
496
  /** The facts the directory row answers: wrunChartMarketFacts reads the row for
423
497
  * `kind` (its asset class) and `quote_is_usd` (its quote) alone. The other
424
498
  * three are the venue tables' (`point_value` the CME root's or the venue's
@@ -715,17 +789,325 @@ export function wrunMarketFactsSettled(market) {
715
789
  return settledRows.has(key) || Date.now() < (retryAfter.get(key) ?? 0);
716
790
  }
717
791
  /** 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). */
792
+ * directory row once warmWrunMarketFacts settled it, else without one, the
793
+ * option multiplier of its options chain (wrunChartOptionMultiplier: the
794
+ * venue tables alone, no read), whether it is one option contract
795
+ * (wrunChartOptionContract: its metadata alone, no read) and the dollar
796
+ * multiplier of its own trades (wrunMarketDollarUnit over the reads
797
+ * warmWrunMarketDollarFacts settled; 0 while it is not proven). Every word is
798
+ * written on every market, 0 included, so the block keeps one shape. */
721
799
  export function wrunMarketFactsFor(market) {
722
800
  const parts = marketKeyParts(market);
723
801
  const row = parts === undefined ? undefined : settledRows.get(directoryKey(parts.venue, parts.symbol));
724
- return { ...wrunChartMarketFacts(market, row ?? undefined), optionMultiplier: wrunChartOptionMultiplier(market) };
802
+ const dollars = wrunMarketDollarUnit(market);
803
+ return {
804
+ ...wrunChartMarketFacts(market, row ?? undefined),
805
+ optionMultiplier: wrunChartOptionMultiplier(market),
806
+ optionContract: wrunChartOptionContract(market),
807
+ dollarMultiplier: dollars.kind === 'dollars' ? dollars.unit : 0,
808
+ };
809
+ }
810
+ /** A registry field that is a finite number above zero, else null (absent, zero, negative or unreadable). */
811
+ function positiveUnit(value) {
812
+ const number = typeof value === 'number' ? value : typeof value === 'string' ? Number(value) : Number.NaN;
813
+ return Number.isFinite(number) && number > 0 ? number : null;
814
+ }
815
+ /** The trade units of one registry record (a `getSymbolMetadata` answer), null for no record. Pure. */
816
+ export function wrunMarketTradeUnitsOf(record) {
817
+ if (!isRecordLike(record))
818
+ return null;
819
+ const normalized = upperText(record.normalizedSymbol);
820
+ return {
821
+ pointValue: positiveUnit(record.pointValue),
822
+ quote: normalized === undefined ? undefined : /^[A-Z0-9.]+-([A-Z0-9]+)$/.exec(normalized)?.[1],
823
+ };
824
+ }
825
+ function isRecordLike(value) {
826
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
827
+ }
828
+ /** The registry's units by market (the chart market's `venue\0SYMBOL`) for the session: a record's units, or null
829
+ * for a market the registry holds no record of (or a host that reads none). */
830
+ const settledUnits = new Map();
831
+ /** Registry reads in flight by market. */
832
+ const pendingUnits = new Map();
833
+ /** When a market whose read failed (or whose continuous lead was not known yet) may be asked again (epoch ms). */
834
+ const unitsRetryAfter = new Map();
835
+ /** A read that cannot settle yet: retried after the window (a failed read, a continuous chart's lead not known). */
836
+ class TradeUnitsUnsettled extends Error {
837
+ }
838
+ /** The instrument a market's prints are of: the chart's own symbol, or a continuous CME chart's lead contract (the
839
+ * chart's stamp, else the continuous contracts service's answer). Throws when a continuous chart's lead is not known
840
+ * yet (retried). */
841
+ async function wrunTradeUnitsInstrument(venue, symbol, resolvedContract) {
842
+ if (!isCmeFamily(venue) || !isContinuousSymbol(symbol))
843
+ return symbol;
844
+ const stamped = typeof resolvedContract === 'string' ? resolvedContract.trim() : '';
845
+ if (stamped !== '')
846
+ return stamped;
847
+ const { default: contracts } = await wrunChartHostEnv().market.loadContinuousContracts();
848
+ const lead = await contracts.getResolvedLead(venue, symbol);
849
+ if (lead === null || typeof lead.symbol !== 'string' || lead.symbol === '') {
850
+ throw new TradeUnitsUnsettled(`${venue}:${symbol}`);
851
+ }
852
+ return lead.symbol;
853
+ }
854
+ /**
855
+ * Ask the instrument registry for `market`'s trade units: once per market for the session, a definite answer (the
856
+ * record's units, or none) kept; concurrent callers share one read; a failed read, or a continuous chart whose lead is
857
+ * not known yet, is asked again a minute later. A host whose metadata service reads no registry record
858
+ * (`getSymbolMetadata` unbound) settles none. Never rejects. The read is fresh (`{ fresh: true }`, as the option units
859
+ * read is): a cached record can predate the registry's point value fill.
860
+ */
861
+ export function warmWrunMarketTradeUnits(market) {
862
+ const parts = marketKeyParts(market);
863
+ if (parts === undefined)
864
+ return Promise.resolve();
865
+ const key = directoryKey(parts.venue, parts.symbol);
866
+ if (settledUnits.has(key))
867
+ return Promise.resolve();
868
+ if (Date.now() < (unitsRetryAfter.get(key) ?? 0))
869
+ return Promise.resolve();
870
+ let read = pendingUnits.get(key);
871
+ if (read === undefined) {
872
+ read = (async () => {
873
+ const instrument = await wrunTradeUnitsInstrument(parts.venue, parts.symbol, market?.resolvedContract);
874
+ const { default: metadataService } = await wrunChartHostEnv().market.loadMetadataService();
875
+ if (typeof metadataService.getSymbolMetadata !== 'function')
876
+ return null;
877
+ return wrunMarketTradeUnitsOf(await metadataService.getSymbolMetadata(parts.venue, instrument, { fresh: true }));
878
+ })()
879
+ .then((units) => {
880
+ settledUnits.set(key, units);
881
+ unitsRetryAfter.delete(key);
882
+ })
883
+ .catch(() => {
884
+ unitsRetryAfter.set(key, Date.now() + DIRECTORY_RETRY_MS);
885
+ })
886
+ .finally(() => pendingUnits.delete(key));
887
+ pendingUnits.set(key, read);
888
+ }
889
+ return read;
890
+ }
891
+ /** The registry's units of `market` once a read settled them: the units, null for no record, undefined while the
892
+ * registry can still answer (not asked yet, in flight, or a failed read that is retried). Synchronous. */
893
+ export function wrunMarketTradeUnitsNow(market) {
894
+ const parts = marketKeyParts(market);
895
+ if (parts === undefined)
896
+ return null;
897
+ const key = directoryKey(parts.venue, parts.symbol);
898
+ return settledUnits.has(key) ? (settledUnits.get(key) ?? null) : undefined;
899
+ }
900
+ /** Warm everything a market's dollar unit and stored unit read (C-DOLLAR): the directory row (a crypto market's quote)
901
+ * and the instrument registry's units. Never rejects. */
902
+ export function warmWrunMarketDollarFacts(market) {
903
+ return Promise.all([warmWrunMarketFacts(market), warmWrunMarketTradeUnits(market)]).then(() => undefined);
904
+ }
905
+ /** True when a read of `market`'s dollar unit now would wait on nothing (warmWrunMarketDollarFacts): the directory row
906
+ * (wrunMarketFactsSettled) and the registry's units each answered, failed recently, or are never asked. */
907
+ export function wrunMarketDollarFactsSettled(market) {
908
+ if (!wrunMarketFactsSettled(market))
909
+ return false;
910
+ const parts = marketKeyParts(market);
911
+ if (parts === undefined)
912
+ return true;
913
+ const key = directoryKey(parts.venue, parts.symbol);
914
+ return settledUnits.has(key) || Date.now() < (unitsRetryAfter.get(key) ?? 0);
915
+ }
916
+ /** The quote asset a crypto venue's raw symbol spells after its separator (`BTC_USDT`, `BTC-USDT-SWAP`): positive
917
+ * evidence only (a tail that is no dollar asset, `BTC-PERPETUAL`, proves nothing). */
918
+ function separatedQuote(symbol) {
919
+ const parts = symbol.trim().toUpperCase().split(/[_-]/);
920
+ return parts.length >= 2 && parts[0] !== '' ? parts[1] : undefined;
921
+ }
922
+ /**
923
+ * Whether a market off the CME family is quoted in US dollars, a dollar stablecoin included (the gateway writer's
924
+ * pegged quotes, `isTradesDollarQuoteAsset`): US listings and POLYGON_INDICES yes; else the registry record's quote
925
+ * (its normalized symbol), then the directory row's quote, then the chart's own spelling of the pair
926
+ * (`spelledQuote`), then a raw symbol's separated quote when it is a dollar asset. Undefined when nothing says.
927
+ */
928
+ function wrunMarketQuoteInDollars(market, venue, row, units) {
929
+ if (US_LISTING_EXCHANGES.has(venue) || INDEX_EXCHANGES.has(venue))
930
+ return true;
931
+ if (units?.quote !== undefined)
932
+ return isTradesDollarQuoteAsset(units.quote);
933
+ const rowQuoteWord = row === undefined ? undefined : (upperText(row.quoteAssetId) ?? upperText(row.quoteCoinName));
934
+ if (rowQuoteWord !== undefined)
935
+ return isTradesDollarQuoteAsset(rowQuoteWord);
936
+ const spelled = spelledQuote(venue, market);
937
+ if (spelled !== undefined)
938
+ return isTradesDollarQuoteAsset(spelled);
939
+ const separated = typeof market.symbol === 'string' ? separatedQuote(market.symbol) : undefined;
940
+ return separated !== undefined && isTradesDollarQuoteAsset(separated) ? true : undefined;
941
+ }
942
+ /**
943
+ * The US dollars one price unit times one live-feed COIN-arm size unit is worth on `market` (C-DOLLAR's unit value).
944
+ * ONE rule for every market, read off the server's facts and never off a venue list or a table of ours:
945
+ *
946
+ * - A CME Group contract counts contracts on the COIN arm (live-feed never multiplies a point-valued product), so its
947
+ * unit is the instrument registry's point value, in US dollars per point (`warmWrunMarketTradeUnits`: ES 50, 6A
948
+ * 100,000, a cents-quoted grain per cent, ZC 50 and ZL 600), the number the large-print writer prices the table's
949
+ * copies with. An option contract, or a contract the registry holds no point value for, cannot be priced.
950
+ * - Every other market counts its base asset on the COIN arm (live-feed applied each instrument's contract multiplier
951
+ * and its inverse flag), so its unit is the market facts' point value (1, `market.point_value()`; 0 on ICE and
952
+ * PLATTS, whose multipliers no one serves) on a market quoted in dollars (`wrunMarketQuoteInDollars`).
953
+ *
954
+ * A candle's volume times its close times the unit is that candle's dollar volume (the dollar default,
955
+ * wrun-market-size-defaults), and a live print's price times its COIN-arm size times the unit is the print's dollar
956
+ * value (the tape's live fold). A fact that cannot be proven is a named reason, never a guess; `transient` while a read
957
+ * can still answer it. Synchronous: the reads are taken once `warmWrunMarketDollarFacts` settled them.
958
+ */
959
+ export function wrunMarketDollarUnit(market) {
960
+ const parts = marketKeyParts(market);
961
+ if (market === undefined || parts === undefined)
962
+ return { kind: 'unproven', reason: 'quote', transient: false };
963
+ const key = directoryKey(parts.venue, parts.symbol);
964
+ const units = wrunMarketTradeUnitsNow(market);
965
+ if (isCmeFamily(parts.venue)) {
966
+ if (isOptionContract(market.category))
967
+ return { kind: 'unproven', reason: 'point-value', transient: false };
968
+ if (units === undefined)
969
+ return { kind: 'unproven', reason: 'point-value', transient: true };
970
+ return units?.pointValue != null
971
+ ? { kind: 'dollars', unit: units.pointValue }
972
+ : { kind: 'unproven', reason: 'point-value', transient: false };
973
+ }
974
+ const row = settledRows.get(key) ?? undefined;
975
+ const { pointValue } = wrunChartMarketFacts(market, row);
976
+ if (!(Number.isFinite(pointValue) && pointValue > 0)) {
977
+ return { kind: 'unproven', reason: 'point-value', transient: false };
978
+ }
979
+ const dollars = wrunMarketQuoteInDollars(market, parts.venue, row, units);
980
+ if (dollars === true)
981
+ return { kind: 'dollars', unit: pointValue };
982
+ // Unknown while a read can still answer the quote (the registry record or the directory row: not asked yet, or a
983
+ // failed read that is retried); a quote an answer or the market's own spelling names is no dollar quote for good.
984
+ const answered = units !== undefined && (!directoryAnswers(parts.venue) || settledRows.has(key));
985
+ return { kind: 'unproven', reason: 'quote', transient: dollars === undefined && !answered };
986
+ }
987
+ /** The writer's dollars per stored unit by market for the session: a number, or null for a market with no large print
988
+ * in any window (or a host that reads no series). */
989
+ const settledStoredUnits = new Map();
990
+ /** Stored unit reads in flight by market. */
991
+ const pendingStoredUnits = new Map();
992
+ /** When a market whose stored unit read failed may be asked again (epoch ms). */
993
+ const storedUnitsRetryAfter = new Map();
994
+ /** How far back the newest large print is looked for: the large table's own retention (a week). The read asks one
995
+ * row, newest first, so a busy market answers one print, not a week of them (measured 2026-10-22: one row on
996
+ * BINANCE_FUTURES BTCUSDT, gate.io futures BTC_USDT and CME ESZ6 and ES1!). */
997
+ const STORED_UNIT_WINDOW_SEC = 7 * 86_400;
998
+ const STORED_UNIT_TIMEOUT_MS = 20_000;
999
+ /**
1000
+ * The large-print writer's dollars per STORED unit off a TRADE_LARGE answer (decoded series frames, the TRADES
1001
+ * columns): `quoteAmount / amount` of the newest row whose both are finite and above zero, undefined when no row is.
1002
+ * The writer prices each copy per instrument (contracts times the contract multiplier times the price on a linear
1003
+ * market, the contract's dollar face on an inverse one, contracts times the price times the point value on CME), so the
1004
+ * ratio is what one stored unit was worth at that print, on every venue, with no unit of ours. Pure.
1005
+ */
1006
+ export function wrunStoredUnitDollarsOfRows(frames) {
1007
+ let newestTs = Number.NEGATIVE_INFINITY;
1008
+ let perUnit;
1009
+ for (const frame of frames) {
1010
+ const records = frame?.records;
1011
+ const length = Number(records?.length);
1012
+ if (records === undefined || !(length > 0) || !records.ts || !records.volume || !records.quoteAmount)
1013
+ continue;
1014
+ for (let at = 0; at < length; at += 1) {
1015
+ const ts = Number(records.ts[at]);
1016
+ const amount = Number(records.volume[at]);
1017
+ const quote = Number(records.quoteAmount[at]);
1018
+ if (!Number.isFinite(ts) || !(Number.isFinite(amount) && amount > 0) || !(Number.isFinite(quote) && quote > 0)) {
1019
+ continue;
1020
+ }
1021
+ if (ts > newestTs) {
1022
+ newestTs = ts;
1023
+ perUnit = quote / amount;
1024
+ }
1025
+ }
1026
+ }
1027
+ return perUnit;
1028
+ }
1029
+ /**
1030
+ * Read what one STORED unit of `market` is worth in dollars off the large-print writer's own rows: the market's newest
1031
+ * TRADE_LARGE print (`wrunStoredUnitDollarsOfRows`), through the host's series read on the K_TRADES history's own wire
1032
+ * (the chart's market, its wire venue as the K_TRADES worker spells it; TRADE_LARGE is a v2-only read, never the /v3
1033
+ * catalog, whose crypto rows carry no unit): one row, newest first, over the table's week. Once per market for the
1034
+ * session; concurrent callers share one read; a failed read is asked again a minute later. A host whose v2 service
1035
+ * reads no series (`sendSeriesOneShot` unbound) settles none. Never rejects. Only a run head with a raw floor to carry
1036
+ * asks it (wrun-market-size-defaults.util).
1037
+ */
1038
+ export function warmWrunMarketStoredUnit(market) {
1039
+ const parts = marketKeyParts(market);
1040
+ if (parts === undefined)
1041
+ return Promise.resolve();
1042
+ const key = directoryKey(parts.venue, parts.symbol);
1043
+ if (settledStoredUnits.has(key))
1044
+ return Promise.resolve();
1045
+ if (Date.now() < (storedUnitsRetryAfter.get(key) ?? 0))
1046
+ return Promise.resolve();
1047
+ let read = pendingStoredUnits.get(key);
1048
+ if (read === undefined) {
1049
+ read = (async () => {
1050
+ const { default: v2 } = await wrunChartHostEnv().transport.loadV2Service();
1051
+ if (typeof v2.sendSeriesOneShot !== 'function')
1052
+ return null;
1053
+ const toUnixS = Math.floor(Date.now() / 1000);
1054
+ const descriptor = {
1055
+ domain: 'CRYPTO',
1056
+ metric: 'TRADES',
1057
+ ref: { exchange: getExchangeFromSymbol(parts.venue, parts.symbol), symbol: parts.symbol },
1058
+ window: { fromUnixS: toUnixS - STORED_UNIT_WINDOW_SEC, toUnixS },
1059
+ paging: { limit: 1, direction: 'DESC' },
1060
+ v2Only: { type: 'TRADE_LARGE' },
1061
+ };
1062
+ const frames = await v2.sendSeriesOneShot(descriptor, { timeoutMs: STORED_UNIT_TIMEOUT_MS });
1063
+ return wrunStoredUnitDollarsOfRows(frames) ?? null;
1064
+ })()
1065
+ .then((perUnit) => {
1066
+ settledStoredUnits.set(key, perUnit);
1067
+ storedUnitsRetryAfter.delete(key);
1068
+ })
1069
+ .catch(() => {
1070
+ storedUnitsRetryAfter.set(key, Date.now() + DIRECTORY_RETRY_MS);
1071
+ })
1072
+ .finally(() => pendingStoredUnits.delete(key));
1073
+ pendingStoredUnits.set(key, read);
1074
+ }
1075
+ return read;
1076
+ }
1077
+ /**
1078
+ * The US dollars one unit of `market`'s STORED trade amount is worth (the large-print table's `amount`, the unit a
1079
+ * 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
1080
+ * swap, $100 contracts on Binance delivery BTCUSD_PERP, contracts on CME): the writer's own price of one, read off the
1081
+ * market's newest large print (`warmWrunMarketStoredUnit`), on a market whose dollar unit is proven (its quote
1082
+ * amounts are dollars). ONE rule for every venue, linear, inverse and CME alike, no venue list and no multiplier of
1083
+ * ours; a fact that cannot be proven is a named reason, `transient` while a read can still answer it. Synchronous over
1084
+ * `warmWrunMarketDollarFacts` and `warmWrunMarketStoredUnit`.
1085
+ */
1086
+ export function wrunMarketStoredUnitDollars(market) {
1087
+ const unit = wrunMarketDollarUnit(market);
1088
+ if (unit.kind === 'unproven')
1089
+ return unit;
1090
+ const parts = marketKeyParts(market);
1091
+ const key = parts === undefined ? undefined : directoryKey(parts.venue, parts.symbol);
1092
+ if (key === undefined || !settledStoredUnits.has(key))
1093
+ return { kind: 'unproven', reason: 'rows', transient: true };
1094
+ const perUnit = settledStoredUnits.get(key);
1095
+ return perUnit === null || perUnit === undefined
1096
+ ? { kind: 'unproven', reason: 'rows', transient: false }
1097
+ : { kind: 'dollars', perUnit };
725
1098
  }
726
1099
  /** Forget every kept answer (spec isolation). */
727
1100
  export function clearWrunMarketFactsMemo() {
728
1101
  settledRows.clear();
729
1102
  pendingRows.clear();
730
1103
  retryAfter.clear();
1104
+ settledUnits.clear();
1105
+ pendingUnits.clear();
1106
+ unitsRetryAfter.clear();
1107
+ settledStoredUnits.clear();
1108
+ pendingStoredUnits.clear();
1109
+ storedUnitsRetryAfter.clear();
731
1110
  }
1111
+ // The live intake reads the dollar unit through its port (wrun-dollar-unit-port.leaf), so this module stays off the
1112
+ // pre-candle closure live-feed loads the intake in.
1113
+ bindWrunDollarUnitReader({ unit: wrunMarketDollarUnit, warm: warmWrunMarketDollarFacts });
@@ -10,24 +10,34 @@ export interface WrunRgba {
10
10
  * renderer, heatmap, profile or levels declaration (C1, parseWrunStyleTarget). */
11
11
  export declare const WRUN_STYLE_ROW_PREFIX = "__style__";
12
12
  /** True for a Style page row key (never a sheet param, never sent to a host):
13
- * an output property row or a viewer row (a HUD's Look pick or place, a
14
- * heatmap's Sensitivity). */
13
+ * an output property row or a viewer row (a HUD's rows, a heatmap's
14
+ * Sensitivity). */
15
15
  export declare function isWrunStyleRowKey(key: string): boolean;
16
- /** The Style page row key of a HUD's Look pick (g3 addendum LK09):
17
- * `hud:<name>:look`, a viewer setting stored on the overlay beside the
18
- * per-output style rows, never written into the sheet. */
16
+ /** A HUD's viewer rows, `hud:<name>:<row>`: the Look pick (g3 addendum LK09),
17
+ * the place (the card moved by its title) and the dismissable HUD's collapsed
18
+ * and shown flags (C3), stored on the overlay beside the per-output style
19
+ * rows and never written into the sheet. The one list the key builder and
20
+ * every reader derive from: a row added here persists with the workspace row,
21
+ * rides a template and a twin conversion, and saves without a rerun. */
22
+ export declare const WRUN_HUD_VIEWER_ROWS: readonly ["look", "place", "collapsed", "shown"];
23
+ export type WrunHudViewerRow = (typeof WRUN_HUD_VIEWER_ROWS)[number];
19
24
  export declare const WRUN_HUD_LOOK_ROW_PREFIX = "hud:";
20
- export declare const WRUN_HUD_LOOK_ROW_RE: RegExp;
25
+ export declare function wrunHudViewerRowKey(name: string, row: WrunHudViewerRow): string;
26
+ /** A HUD viewer row key read back: its HUD and its row; undefined for any other key. */
27
+ export declare function parseWrunHudViewerRowKey(key: string): {
28
+ name: string;
29
+ row: WrunHudViewerRow;
30
+ } | undefined;
21
31
  export declare function isWrunHudLookRowKey(key: string): boolean;
22
32
  export declare function isWrunHudPlaceRowKey(key: string): boolean;
23
- /** A HUD's viewer rows (the Look pick and the place): overlay settings that persist by key. */
33
+ /** A HUD's viewer rows (WRUN_HUD_VIEWER_ROWS): overlay settings that persist by key. */
24
34
  export declare function isWrunHudViewerRowKey(key: string): boolean;
25
35
  /** The viewer's Sensitivity for one heatmap (`heatmap:<name>:sensitivity`,
26
36
  * wrunHeatmapSensitivityRowKey), stored on the overlay beside the HUD rows. */
27
37
  export declare const WRUN_HEATMAP_SENSITIVITY_ROW_RE: RegExp;
28
38
  export declare function isWrunHeatmapSensitivityRowKey(key: string): boolean;
29
- /** Every viewer row of a browser-run Indicator (a HUD's Look pick and place, a
30
- * heatmap's Sensitivity, a child the reader hid on its own legend row):
39
+ /** Every viewer row of a browser-run Indicator (a HUD's rows, a heatmap's
40
+ * Sensitivity, a child the reader hid on its own legend row):
31
41
  * overlay settings that persist by key and are never a sheet param, an alert
32
42
  * param or a host param. */
33
43
  export declare function isWrunViewerRowKey(key: string): boolean;