@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
@@ -25,7 +25,7 @@ import { peekRegisteredContinuousLead } from '../../chart/continuous-contracts.u
25
25
  import { cmeOptionsContract } from '../../options/cme-options-root.util.js';
26
26
  import { refuseWrunPollInput, WRUN_LANE_KNOB_INVALID_CODE } from './wrun-poll-lane.types.js';
27
27
  import { wrunLaneChainPlaneOf } from './wrun-row-lane.types.js';
28
- import { decideWrunOptionsChainIdentity, WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_IDS, WRUN_OPTIONS_CHAIN_ONE_VENUE_CODE, WRUN_OPTIONS_CHAIN_UNAVAILABLE_CODE, WRUN_OPTIONS_CHAIN_VENUE_CODE, } from '../wrun-options-chain.util.js';
28
+ import { decideWrunOptionsChainIdentity, isWrunOptionsChainCryptoVenueWord, WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_IDS, WRUN_OPTIONS_CHAIN_ONE_VENUE_CODE, WRUN_OPTIONS_CHAIN_UNAVAILABLE_CODE, WRUN_OPTIONS_CHAIN_VENUE_CODE, } from '../wrun-options-chain.util.js';
29
29
  import { refuseWrunOptionKnob } from '../wrun-option-knobs.util.js';
30
30
  import { attachWrunRefusal, wrunAuthorRuleSeed, wrunOptionsStopSeed } from '../wrun-refusal.util.js';
31
31
  import { gateSessionHeldElsewhere } from '../../v2/gate-session-latch.util.js';
@@ -33,71 +33,118 @@ import { gateSessionHeldElsewhere } from '../../v2/gate-session-latch.util.js';
33
33
  export function wrunLaneChartKey(ctx) {
34
34
  return `${ctx.exchange}|${ctx.symbol}|${ctx.coin}`;
35
35
  }
36
+ /** A chart's metadata as the options decisions take it: its market, coin and category (`ChartOptionsMarketRef`). */
37
+ function wrunChainChartMarketOf(metadata) {
38
+ return {
39
+ exchange: typeof metadata?.exchange === 'string' ? metadata.exchange : undefined,
40
+ symbol: typeof metadata?.symbol === 'string' ? metadata.symbol : undefined,
41
+ ...(typeof metadata?.coin === 'string' ? { coin: metadata.coin } : {}),
42
+ ...(metadata?.category !== undefined ? { category: metadata.category } : {}),
43
+ };
44
+ }
36
45
  /**
37
46
  * Resolve the chart's chain (lazy imports: the resolver reaches the chain directory service): the ONE resolution every
38
47
  * chain class reads, the options chain lane's (over the chart's own metadata) and each row lane's
39
- * (`resolveWrunLaneChartChain`, over its context's market and category). The chart's options controls' resolver
40
- * (`resolveOptionsChartSource`: an option contract chart on a crypto venue reads its own contract's chain), and a chain
41
- * directory's own failure on a chart its plane governs (a CME futures chart, a chart on the OPRA plane) as that plane's
42
- * evidence; any other resolver failure fails the run. Off every plane, the chart's stop reason rides along
43
- * (`opraStop`, opra-options-gate.util `opraOptionPlaneStop`: the `opra` flag dark, an index chart), so every chain
44
- * decision over the chart says why it reads no US chain. On a plane another screen holds the session of, nothing is
45
- * read (`heldElsewhere`): the chain stops by that name at once.
48
+ * (`resolveWrunLaneChartChain`, over its context's market and category). First the swap: the market whose options the
49
+ * chart reads, `decision.market` when the caller holds the run's one decision (derived-roots.util
50
+ * `decideWrunRunOptionsMarket`), else the options seam now (the gate port's `chartOptionsMarket`): a stock twin's US
51
+ * stock while the `opra` flag is lit (its chain is the stock's OPRA chain, read exactly as a stock chart's, and names
52
+ * the twin, `stockTwinOf`), the chart's own market otherwise (its metadata read as before, its category included). The
53
+ * chart's options controls' resolver (`resolveOptionsChartSource`: an option contract chart on a crypto venue reads its
54
+ * own contract's chain), and a chain directory's own failure on a chart its plane governs (a CME futures chart, a chart
55
+ * on the OPRA plane) as that plane's evidence; any other resolver failure fails the run. Off every plane, the chart's
56
+ * stop reason rides along (`opraStop`, opra-options-gate.util `opraOptionPlaneStop`: the `opra` flag dark, an index
57
+ * chart), so every chain decision over the chart says why it reads no US chain. On a plane another screen holds the
58
+ * session of, nothing is read (`heldElsewhere`): the chain stops by that name at once. With a decision the plane and
59
+ * the stop are the decision's, frozen when the run's head took it, and the resolver is handed that plane (a twin
60
+ * answer or a flag landing since never moves the run's chain onto another plane); without one each is read now, over
61
+ * the market (exchange and symbol), never the venue alone.
46
62
  */
47
- export async function resolveWrunChartChain(metadata) {
48
- const [{ resolveOptionsChartSource }, { governedOptionPlane, opraOptionPlaneStop }] = await Promise.all([
63
+ export async function resolveWrunChartChain(metadata, decision) {
64
+ const [{ resolveOptionsChartSource }, gate] = await Promise.all([
49
65
  wrunChartHostEnv().market.loadOptionsChartSource(),
50
66
  wrunChartHostEnv().market.loadOptionsGate(),
51
67
  ]);
52
- const exchange = typeof metadata?.exchange === 'string' ? metadata.exchange : undefined;
68
+ const { governedOptionPlane, opraOptionPlaneStop } = gate;
69
+ const resolve = resolveOptionsChartSource;
70
+ const chart = wrunChainChartMarketOf(metadata);
71
+ const decided = decision?.market ?? gate.chartOptionsMarket?.(chart) ?? chart;
72
+ const twinOf = decided.twinOf;
73
+ // A twin's stock is judged and read as a stock chart is (its market alone); every other chart by its own market, its
74
+ // metadata read as before.
75
+ const market = twinOf === undefined ? chart : decided;
76
+ const source = twinOf === undefined ? metadata : { exchange: market.exchange, symbol: market.symbol, coin: market.coin };
77
+ const named = (chain) => twinOf === undefined ? chain : { ...chain, stockTwinOf: { exchange: twinOf.exchange, symbol: twinOf.symbol } };
78
+ const exchange = typeof market.exchange === 'string' ? market.exchange : undefined;
79
+ // The plane and the stop: the run's frozen decision when the caller holds one, else read now.
80
+ const planeOf = () => (decision !== undefined ? decision.plane : governedOptionPlane(market));
81
+ const stopOf = () => (decision !== undefined ? decision.opraStop : opraOptionPlaneStop(market));
53
82
  // Another screen holds the session of the plane this chart's chain lists on (gate-session-latch.util): its reader
54
83
  // dials nothing until the take-back, so a directory read would wait out its budget. None is sent. The chart's plane
55
84
  // is read only while a latch is held, so every other resolution reads exactly as before.
56
85
  if (gateSessionHeldElsewhere('cme') || gateSessionHeldElsewhere('opra')) {
57
- const plane = governedOptionPlane({ exchange });
86
+ const plane = planeOf();
58
87
  if (plane !== null && gateSessionHeldElsewhere(plane))
59
- return { heldElsewhere: plane };
88
+ return named({ heldElsewhere: plane });
60
89
  }
61
90
  let chartSource;
62
91
  try {
63
- chartSource = (await resolveOptionsChartSource(metadata));
92
+ // The decided plane rides to the resolver, so it never decides again; without a decision it reads its own now.
93
+ chartSource = (decision !== undefined ? await resolve(source, decision.plane) : await resolve(source));
64
94
  }
65
95
  catch (error) {
66
96
  if (isCmeGoverned(exchange))
67
97
  return { directoryFailed: 'cme' };
68
- if (governedOptionPlane({ exchange }) === 'opra')
69
- return { directoryFailed: 'opra' };
98
+ if (planeOf() === 'opra')
99
+ return named({ directoryFailed: 'opra' });
70
100
  // A chart whose options list on OPRA but ride no plane stops for a known reason (the flag, the router): that
71
101
  // reason decides without a chain, whatever the fallback resolver threw.
72
- const opraStop = opraOptionPlaneStop({ exchange });
102
+ const opraStop = stopOf();
73
103
  if (opraStop !== undefined)
74
- return { opraStop };
104
+ return named({ opraStop });
75
105
  throw error;
76
106
  }
77
107
  // A chain on a gate plane stopped nothing. Off every plane, the known reason a chart whose options list on OPRA
78
108
  // rides none (the flag, the router) is decided beside the chain the resolver fell back to: that fallback (the coin's
79
109
  // Deribit chain) reads "no option chain", which is not why.
80
110
  if (chartSource.venue === 'opra' || chartSource.venue === 'cme')
81
- return { chartSource };
82
- const opraStop = opraOptionPlaneStop({ exchange });
83
- return { chartSource, ...(opraStop !== undefined ? { opraStop } : {}) };
111
+ return named({ chartSource });
112
+ const opraStop = stopOf();
113
+ return named({ chartSource, ...(opraStop !== undefined ? { opraStop } : {}) });
84
114
  }
85
- /** Resolve the chart's chain for a lane: `resolveWrunChartChain` over the lane context's market and category. */
115
+ /** Resolve the chart's chain for a lane: `resolveWrunChartChain` over the lane context's market and category. In a
116
+ * run's plan the context IS the run's one options market (the planner swapped a stock twin's chain lanes onto its
117
+ * stock, derived-roots.util `wrunUnderlyingLaneContext`) and carries the run's decision (`optionsDecision`): the chain
118
+ * resolves under that decision's plane, never the seam's or the flag's of now. Outside a plan (no decision) both are
119
+ * read now. */
86
120
  export function resolveWrunLaneChartChain(ctx) {
87
- return resolveWrunChartChain({
121
+ const metadata = {
88
122
  exchange: ctx.exchange,
89
123
  symbol: ctx.symbol,
90
124
  coin: ctx.coin,
91
125
  ...(typeof ctx.category === 'number' ? { category: ctx.category } : {}),
126
+ };
127
+ const decided = ctx.optionsDecision;
128
+ if (decided === undefined)
129
+ return resolveWrunChartChain(metadata);
130
+ return resolveWrunChartChain(metadata, {
131
+ market: { ...metadata, ...(ctx.stockTwinOf !== undefined ? { twinOf: ctx.stockTwinOf } : {}) },
132
+ plane: decided.plane,
133
+ ...(decided.opraStop !== undefined ? { opraStop: decided.opraStop } : {}),
92
134
  });
93
135
  }
94
136
  /** The crypto venue words a chain decision reads on this chart: on the OPRA plane no crypto venue lists a US
95
- * stock's options (the words refuse by the flag alone, no listing asked); anywhere else the run's own resolver
96
- * over every crypto word (the listing is asked once per coin, and only with the crypto-options gate on). */
97
- export async function resolveWrunLaneCryptoVenues(chain, chartCoin) {
137
+ * stock's options (the words refuse by the flag alone, no listing asked), unless the chain is a stock twin's
138
+ * (`stockTwinOf`: the chart trades on a crypto venue, and a word naming one reads that venue's chain of the coin, so a
139
+ * script pinning `bybit` keeps Bybit's); anywhere else the run's own resolver over the crypto words among `venues`
140
+ * (every crypto word when absent; the listing is asked once per coin, and only for a crypto word with the
141
+ * crypto-options gate on: `[]` reads the gate and the coin alone). */
142
+ export async function resolveWrunLaneCryptoVenues(chain, chartCoin, venues) {
98
143
  const { resolveWrunOptionsChainCryptoVenues } = await wrunChartHostEnv().market.loadOptionsChainVenues();
99
- const words = Object.keys(WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_IDS);
100
- const onOpraPlane = chain.chartSource?.venue === 'opra' || chain.directoryFailed === 'opra' || chain.heldElsewhere === 'opra';
144
+ const asked = venues ?? Object.keys(WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_IDS);
145
+ const words = asked.filter((word) => typeof word === 'string' && isWrunOptionsChainCryptoVenueWord(word));
146
+ const onOpraPlane = chain.stockTwinOf === undefined &&
147
+ (chain.chartSource?.venue === 'opra' || chain.directoryFailed === 'opra' || chain.heldElsewhere === 'opra');
101
148
  const resolved = await resolveWrunOptionsChainCryptoVenues({
102
149
  words: onOpraPlane ? [] : words,
103
150
  chartSource: chain.chartSource,
@@ -223,12 +270,19 @@ export const WRUN_OPTION_CHART_UNRESOLVED_CODE = 'wrun_option_chart_unresolved';
223
270
  * words (`resolveWrunLaneCryptoVenues`), for a CME chain on a continuous alias the contract leading it now
224
271
  * (option-chain.service `resolveChainContract`, the roll rule the terminal identity admits the alias by; MES1!'s as
225
272
  * MESF's contract), and each decided chain's default book (`resolveWrunLaneChainAutoBook`, asked once per chain for
226
- * this chart).
273
+ * this chart). The crypto venue listing is asked here for every crypto word, or on demand (`options`).
227
274
  */
228
- export async function resolveWrunLaneChainChart(ctx, held) {
229
- const chain = held ?? (await resolveWrunLaneChartChain(ctx));
275
+ export async function resolveWrunLaneChainChart(ctx, held, options) {
276
+ const resolved = held ?? (await resolveWrunLaneChartChain(ctx));
277
+ // A stock twin's lane context names the chart market it stands in for: its chain names it too, held or resolved, so
278
+ // its crypto venue words still read their venues' chains (`resolveWrunLaneCryptoVenues`).
279
+ const twinOf = ctx.stockTwinOf;
280
+ const chain = twinOf !== undefined && resolved.stockTwinOf === undefined
281
+ ? { ...resolved, stockTwinOf: { exchange: twinOf.exchange, symbol: twinOf.symbol } }
282
+ : resolved;
283
+ const onDemand = options?.cryptoListingOnDemand === true;
230
284
  const [cryptoVenues, { hasDeribitOptions }, { OPTION_VENUES }] = await Promise.all([
231
- resolveWrunLaneCryptoVenues(chain, ctx.coin),
285
+ resolveWrunLaneCryptoVenues(chain, ctx.coin, onDemand ? [] : undefined),
232
286
  wrunChartHostEnv().market.loadDeribitOptions(),
233
287
  import('../../../constants/option-venues.constants.js'),
234
288
  ]);
@@ -247,9 +301,11 @@ export async function resolveWrunLaneChainChart(ctx, held) {
247
301
  cmeLead = { alias: source.underlying, contract };
248
302
  }
249
303
  const autoBooks = new Map();
304
+ let listed;
250
305
  return {
251
306
  chain,
252
307
  cryptoVenues,
308
+ ...(onDemand ? { cryptoVenuesOnDemand: () => (listed ??= resolveWrunLaneCryptoVenues(chain, ctx.coin)) } : {}),
253
309
  deribitListed: hasDeribitOptions,
254
310
  venueExchange: (word) => plainVenueOf(word)?.exchanges[0],
255
311
  ...(cmeLead !== undefined ? { cmeLead } : {}),
@@ -273,9 +329,13 @@ export async function resolveWrunLaneChainChart(ctx, held) {
273
329
  * failing, refuses nothing before the read (an empty answer, and the empty-answer rule speaks). The venue and book words
274
330
  * are still decided over it (`decideWrunLaneChain`), with no read either.
275
331
  */
276
- export function wrunLaneOpraPlaneChain(coin) {
332
+ export function wrunLaneOpraPlaneChain(coin, stockTwinOf) {
277
333
  return {
278
334
  chartSource: { venue: 'opra', exchange: OPRA_GOVERNED_EXCHANGES[0], underlying: coin.trim().toUpperCase() },
335
+ // A stock twin's chain by its ticker (`coin`) names the chart market it stands in for (`stockTwinOf`).
336
+ ...(stockTwinOf !== undefined
337
+ ? { stockTwinOf: { exchange: stockTwinOf.exchange, symbol: stockTwinOf.symbol } }
338
+ : {}),
279
339
  };
280
340
  }
281
341
  /**
@@ -286,6 +346,12 @@ export function wrunLaneOpraPlaneChain(coin) {
286
346
  * flag, the listing, the directory and the OPRA wall by name). A refusal comes back as the decision's own.
287
347
  */
288
348
  export function decideWrunLaneChainIdentity(chart, venue, who) {
349
+ // A chart whose listing is asked on demand holds none yet: a crypto word read over the gate and the coin alone would
350
+ // refuse a venue that lists the coin.
351
+ if (chart.cryptoVenuesOnDemand !== undefined && isWrunOptionsChainCryptoVenueWord(String(venue))) {
352
+ throw new Error(`[wrun] input '${who.inputName}': venue "${String(venue)}" over a chart whose crypto venue listing is asked on ` +
353
+ 'demand is decided through decideWrunLaneChain');
354
+ }
289
355
  return decideWrunOptionsChainIdentity({
290
356
  venue: venue === undefined ? undefined : String(venue),
291
357
  chartSource: chart.chain.chartSource,
@@ -318,10 +384,14 @@ export function wrunLaneChainBook(value, ctx) {
318
384
  * exchange, the underlying the plane files the series under (a CME continuous alias read as the contract leading it
319
385
  * now), the coin and the book. Refuses by name with the options chain's own reasons and seeds (a coin no venue lists:
320
386
  * `no-chain`), a continuous CME chart whose lead cannot be resolved (`cme-unresolved`, Retry), and a book outside its
321
- * words.
387
+ * words. A crypto word over a chart whose listing is asked on demand asks it here, once per chart.
322
388
  */
323
389
  export async function decideWrunLaneChain(chart, knobs, ctx) {
324
- const decision = decideWrunLaneChainIdentity(chart, knobs.venue, ctx);
390
+ const { cryptoVenuesOnDemand, ...resolved } = chart;
391
+ const listed = cryptoVenuesOnDemand !== undefined && isWrunOptionsChainCryptoVenueWord(String(knobs.venue))
392
+ ? { ...resolved, cryptoVenues: await cryptoVenuesOnDemand() }
393
+ : chart;
394
+ const decision = decideWrunLaneChainIdentity(listed, knobs.venue, ctx);
325
395
  if (!decision.ok)
326
396
  throw wrunLaneChainRefusalError(decision, ctx.sourceClass);
327
397
  const book = wrunLaneChainBook(knobs.book, ctx);
@@ -33,8 +33,9 @@ import { WRUN_LANE_CHAIN_PLANES } from './wrun-row-lane.types.js';
33
33
  import { assertWrunHostGridLanding } from './host-grid-landing.js';
34
34
  import { WRUN_BROWSER_BUILTIN_SOURCE_CLASSES, wrunPollLaneClassOfFile } from '../wrun-browser-sources.leaf.js';
35
35
  import { registerWrunRefusalFeedKeys } from '../wrun-refusal.util.js';
36
- // The widths leaf, never the packer: this registry rides the boot path (the live intake reads row lanes) and the
37
- // packer does not (tests/utility/wrun/wrun-door.closure.spec.ts); the packer reads the table this registers.
36
+ // The widths leaf, never the packer: this registry rides the boot path (the requirement leaf reads row lanes for the
37
+ // chart store) and the packer does not (tests/utility/wrun/wrun-door.closure.spec.ts); the packer reads the table this
38
+ // registers.
38
39
  import { registerWrunRowLaneTupleWidths } from '../wrun-pack-widths.leaf.js';
39
40
  const WRUN_ROW_LANE_KEY_RE = /^[a-z][a-z0-9_]*$/;
40
41
  let pollPeers = () => ({ classes: [], keys: [] });
@@ -144,7 +144,8 @@ export const rowLane = {
144
144
  acquisitionMoved: wrunOptionContractFlowAcquisitionMoved,
145
145
  identity: async (ctx) => {
146
146
  const held = await wrunHeldOpraPlaneChain(ctx.exchange, ctx.coin, ctx.opraPlane);
147
- rememberFlowChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx, held));
147
+ // Every input decides through decideWrunLaneChain: the crypto venue listing waits for a crypto venue word.
148
+ rememberFlowChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx, held, { cryptoListingOnDemand: true }));
148
149
  },
149
150
  facets: contractFlowFacets,
150
151
  landing: {
@@ -28,9 +28,15 @@
28
28
  * the one venue decision names for the word, in `options_chain`'s words; absent reads `auto`, the chain
29
29
  * `options_chain`'s `auto` reads on the same chart); `max_cells` is required (the static plan) and a block over it
30
30
  * refuses the run, never truncated. A market pin and the knobs of the other options classes are refused by name.
31
- * - Views (OPTLOAD G5, wrun-option-views.util): `page_view` or `page_views` reads a projection of the class's block B
32
- * in place of B whole (`stateViews`; a view's own params, `min_volume` included, ride as flat knobs). The worker asks
33
- * the gateway for them in ONE chain summary read; a gateway without the views refuses them by name.
31
+ * - Views (OPTLOAD G5, wrun-option-views.util): `page_view` or `page_views` reads a view of the class's block B in
32
+ * place of B whole (`stateViews`; a view's own params, `min_volume` included, ride as flat knobs): a projection as
33
+ * the class's own block, and with a fold (Top Contracts' totals) the view block of 16-value rows
34
+ * (`wrunOptionInputTupleWidth`). The worker asks the gateway for them in ONE chain summary read, and projects them
35
+ * itself on a crypto chain, whose plain reader serves none; a governed gateway without the views refuses them by
36
+ * name. An input that declares no view reads B whole through the implicit view (OPTLOAD W3 FE-STATE,
37
+ * `stateViews: "whole"`, `wrunOptionStateImplicitViewFields`): the gateway's WHOLE view of B, ONE chain summary
38
+ * read with no expiry directory and no registry read, B's 13-value tuples in B's order; a crypto chain keeps its
39
+ * plain reader, and an answer that is not B's rows is read by today's path (the worker twin).
34
40
  * - On the OPRA plane the chain is the plane's own by coin (section 8, O1: `wrunHeldOpraPlaneChain`): no chain
35
41
  * directory is read before the lane's first ask.
36
42
  *
@@ -28,9 +28,15 @@
28
28
  * the one venue decision names for the word, in `options_chain`'s words; absent reads `auto`, the chain
29
29
  * `options_chain`'s `auto` reads on the same chart); `max_cells` is required (the static plan) and a block over it
30
30
  * refuses the run, never truncated. A market pin and the knobs of the other options classes are refused by name.
31
- * - Views (OPTLOAD G5, wrun-option-views.util): `page_view` or `page_views` reads a projection of the class's block B
32
- * in place of B whole (`stateViews`; a view's own params, `min_volume` included, ride as flat knobs). The worker asks
33
- * the gateway for them in ONE chain summary read; a gateway without the views refuses them by name.
31
+ * - Views (OPTLOAD G5, wrun-option-views.util): `page_view` or `page_views` reads a view of the class's block B in
32
+ * place of B whole (`stateViews`; a view's own params, `min_volume` included, ride as flat knobs): a projection as
33
+ * the class's own block, and with a fold (Top Contracts' totals) the view block of 16-value rows
34
+ * (`wrunOptionInputTupleWidth`). The worker asks the gateway for them in ONE chain summary read, and projects them
35
+ * itself on a crypto chain, whose plain reader serves none; a governed gateway without the views refuses them by
36
+ * name. An input that declares no view reads B whole through the implicit view (OPTLOAD W3 FE-STATE,
37
+ * `stateViews: "whole"`, `wrunOptionStateImplicitViewFields`): the gateway's WHOLE view of B, ONE chain summary
38
+ * read with no expiry directory and no registry read, B's 13-value tuples in B's order; a crypto chain keeps its
39
+ * plain reader, and an answer that is not B's rows is read by today's path (the worker twin).
34
40
  * - On the OPRA plane the chain is the plane's own by coin (section 8, O1: `wrunHeldOpraPlaneChain`): no chain
35
41
  * directory is read before the lane's first ask.
36
42
  *
@@ -40,7 +46,7 @@ import { decideWrunLaneChain, refuseWrunLaneStrayKnob, resolveWrunLaneChainChart
40
46
  import { refuseWrunPollInput } from '../wrun-poll-lane.types.js';
41
47
  import { wrunOptionExpiriesKnob, wrunOptionExpiriesText, wrunOptionStrikeWindowKnob, } from '../../wrun-option-knobs.util.js';
42
48
  import { wrunAuthorRuleSeed } from '../../wrun-refusal.util.js';
43
- import { wrunHeldOpraPlaneChain, wrunOptionViewLaneFields, wrunOptionViewParamKnobs, wrunOptionViewsOfSource, } from '../../wrun-option-views.util.js';
49
+ import { wrunHeldOpraPlaneChain, wrunOptionStateImplicitViewFields, wrunOptionViewLaneFields, wrunOptionViewParamKnobs, wrunOptionViewsOfSource, } from '../../wrun-option-views.util.js';
44
50
  /** f64s per tuple (the source contract's width, the `present` mask included). */
45
51
  export const WRUN_OPTION_CONTRACT_STATE_WIDTH = 13;
46
52
  /** om's code for a market pin on the OPRA classes. */
@@ -106,7 +112,8 @@ export const rowLane = {
106
112
  identity: async (ctx) => {
107
113
  // On the OPRA plane the chain is the plane's own by coin: no chain directory is read (O1).
108
114
  const held = await wrunHeldOpraPlaneChain(ctx.exchange, ctx.coin, ctx.opraPlane);
109
- rememberStateChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx, held));
115
+ // Every input decides through decideWrunLaneChain: the crypto venue listing waits for a crypto venue word.
116
+ rememberStateChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx, held, { cryptoListingOnDemand: true }));
110
117
  },
111
118
  facets: async (source, ctx) => {
112
119
  // A knob a declared view takes is that view's param, never another class's stray knob.
@@ -131,7 +138,9 @@ export const rowLane = {
131
138
  ...wrunOptionContractStateExtras(chain),
132
139
  stateExpiries: wrunOptionExpiriesText(expiries),
133
140
  ...(strikeWindowPct !== undefined ? { stateStrikeWindowPct: strikeWindowPct } : {}),
134
- ...(views !== undefined ? wrunOptionViewLaneFields('option_contract_state', views) : {}),
141
+ ...(views !== undefined
142
+ ? wrunOptionViewLaneFields('option_contract_state', views)
143
+ : wrunOptionStateImplicitViewFields()),
135
144
  };
136
145
  },
137
146
  };
@@ -11,6 +11,9 @@
11
11
  * live session rebuilds once the lead rolls: `acquisitionMoved`), none on a crypto chain. A chart with no option chain
12
12
  * is refused by the decision's own name (`no-options` / `chain`), which a declared `missing: "empty"` drops with a
13
13
  * note.
14
+ * - On the OPRA plane the chain is held by coin (`wrunHeldOpraPlaneChain`): no chain directory read before the first
15
+ * ask, but for an input naming an expiry facet (`max_dte`, `expiries`). The crypto venue listing is asked only for a
16
+ * crypto venue word (`cryptoListingOnDemand`): a CME chain asks none.
14
17
  * - The acquisition names the chain: `coin` (the chain's underlying, the key its plane files prints under),
15
18
  * `printExchange` (its plane follows it), `printBook` for a book other than the underlying's own series (ONE book per
16
19
  * input, D11: the worker and the live fold keep that book's prints) and `printContinuous` for a CME chain read off a
@@ -37,6 +40,15 @@
37
40
  * offset on its host bar.
38
41
  * - Projection, per input: `expiries: "nearest:N"` keeps the bar's N nearest expiries; `overflow: "largest"` cuts a
39
42
  * bar over the input's own `max_cells` to its largest premiums (om's packer rule, bit 14 on the first kept print).
43
+ * Beside `newest` N the cut is the union (the SDK's frozen contract): a window-level pass (`cellsWindow`) finds the
44
+ * window's N newest over every bar the instance holds, by time then print key, and each bar keeps its `max_cells`
45
+ * largest and its prints among them (`wrunLargestOrNewestOptionPrints`), at most `max_cells` + N, the packer's
46
+ * capacity for the input. The union answer, today's whole download and either one with live prints folded in project
47
+ * the same cells, bit 14 included, and every run projects again, so a live print moves the cut. `newest_tail_ms`
48
+ * beside "largest" is refused by name (`wrun_option_prints_tail_largest`): the capacity must stay bounded. The union
49
+ * needs a module whose buffer holds it (the input's `capacity`, the sheet's own: a build at kit scaffold 97 writes
50
+ * `max_cells + newest` there, wrun-cell-capacity.leaf `wrunSheetCellBlockTuples`); a sheet naming no capacity (any
51
+ * module built before) reads `max_cells`, so its bars keep their largest alone, as before the union.
40
52
  * - Live by coin, on the planes whose OPTION_PRINT producer streams (`chainPlanes`: OPRA and CME): the coin channel of
41
53
  * the instance's chain (`K_OPTION_PRINT` subscribes the chain's exchange and underlying, on a governed exchange at a
42
54
  * real-time routed tier only: wrun-coin-lane-live.util) feeds every print of the underlying; the fold keeps the
@@ -56,6 +68,8 @@ import { type WrunLaneChain } from '../opra-option-lanes.util.js';
56
68
  import type { WrunRowLaneDescriptor } from '../wrun-row-lane.types.js';
57
69
  /** om's refusal name of a missing floor. */
58
70
  export declare const WRUN_OPTION_PRINTS_MIN_PREMIUM_REQUIRED_CODE = "wrun_option_prints_min_premium_required";
71
+ /** om's refusal name of a tail beside `overflow: "largest"` (the union's capacity is `max_cells` + `newest`). */
72
+ export declare const WRUN_OPTION_PRINTS_TAIL_LARGEST_CODE = "wrun_option_prints_tail_largest";
59
73
  /** Test seam: forget every resolved chart. */
60
74
  export declare function __resetWrunPrintsChartsForTests(): void;
61
75
  /**
@@ -11,6 +11,9 @@
11
11
  * live session rebuilds once the lead rolls: `acquisitionMoved`), none on a crypto chain. A chart with no option chain
12
12
  * is refused by the decision's own name (`no-options` / `chain`), which a declared `missing: "empty"` drops with a
13
13
  * note.
14
+ * - On the OPRA plane the chain is held by coin (`wrunHeldOpraPlaneChain`): no chain directory read before the first
15
+ * ask, but for an input naming an expiry facet (`max_dte`, `expiries`). The crypto venue listing is asked only for a
16
+ * crypto venue word (`cryptoListingOnDemand`): a CME chain asks none.
14
17
  * - The acquisition names the chain: `coin` (the chain's underlying, the key its plane files prints under),
15
18
  * `printExchange` (its plane follows it), `printBook` for a book other than the underlying's own series (ONE book per
16
19
  * input, D11: the worker and the live fold keep that book's prints) and `printContinuous` for a CME chain read off a
@@ -37,6 +40,15 @@
37
40
  * offset on its host bar.
38
41
  * - Projection, per input: `expiries: "nearest:N"` keeps the bar's N nearest expiries; `overflow: "largest"` cuts a
39
42
  * bar over the input's own `max_cells` to its largest premiums (om's packer rule, bit 14 on the first kept print).
43
+ * Beside `newest` N the cut is the union (the SDK's frozen contract): a window-level pass (`cellsWindow`) finds the
44
+ * window's N newest over every bar the instance holds, by time then print key, and each bar keeps its `max_cells`
45
+ * largest and its prints among them (`wrunLargestOrNewestOptionPrints`), at most `max_cells` + N, the packer's
46
+ * capacity for the input. The union answer, today's whole download and either one with live prints folded in project
47
+ * the same cells, bit 14 included, and every run projects again, so a live print moves the cut. `newest_tail_ms`
48
+ * beside "largest" is refused by name (`wrun_option_prints_tail_largest`): the capacity must stay bounded. The union
49
+ * needs a module whose buffer holds it (the input's `capacity`, the sheet's own: a build at kit scaffold 97 writes
50
+ * `max_cells + newest` there, wrun-cell-capacity.leaf `wrunSheetCellBlockTuples`); a sheet naming no capacity (any
51
+ * module built before) reads `max_cells`, so its bars keep their largest alone, as before the union.
40
52
  * - Live by coin, on the planes whose OPTION_PRINT producer streams (`chainPlanes`: OPRA and CME): the coin channel of
41
53
  * the instance's chain (`K_OPTION_PRINT` subscribes the chain's exchange and underlying, on a governed exchange at a
42
54
  * real-time routed tier only: wrun-coin-lane-live.util) feeds every print of the underlying; the fold keeps the
@@ -55,16 +67,17 @@
55
67
  import { decideWrunLaneChain, resolveWrunLaneChainChart, WRUN_OPTION_CHART_UNRESOLVED_CODE, wrunLaneChainLeadMoved, wrunLaneChartKey, } from '../opra-option-lanes.util.js';
56
68
  import { refuseWrunPollInput, WRUN_POLL_AUTHOR_GATE_SEED } from '../wrun-poll-lane.types.js';
57
69
  import { refuseWrunOptionKnob, wrunNearestExpiryTuples, wrunOptionExpiriesKnob, wrunOptionExpiriesOf, wrunOptionExpiriesWord, } from '../../wrun-option-knobs.util.js';
58
- import { compareWrunOptionPrintsInTimeOrder, forEachWrunOptionPrintTuple, isWrunOptionPrintMarker, isWrunOptionPrintTuple, WRUN_OPTION_MAX_DTE_DAYS, WRUN_OPTION_PRINT_COLUMN, WRUN_OPTION_PRINT_SIDES, WRUN_OPTION_PRINTS_BOOK_FIELD, WRUN_OPTION_PRINTS_CONTINUOUS_FIELD, WRUN_OPTION_PRINTS_EXCHANGE_FIELD, WRUN_OPTION_PRINTS_HISTORY, WRUN_OPTION_PRINTS_MONEYNESS, WRUN_OPTION_PRINTS_NEWEST_MAX, WRUN_OPTION_PRINTS_NEWEST_TAIL_MAX_MS, WRUN_OPTION_PRINTS_OVERFLOW, WRUN_OPTION_PRINTS_TYPES, WRUN_OPTION_PRINTS_WIDTH, wrunLargestPremiumPrints, wrunNewestOptionPrintRows, wrunOptionPrintKept, wrunOptionPrintOf, wrunOptionPrintsAcquisitionOf, wrunOptionPrintsHorizon, wrunOptionPrintsInTimeOrder, wrunOptionPrintTimeMs, } from '../../wrun-option-prints.util.js';
70
+ import { compareWrunOptionPrintsInTimeOrder, forEachWrunOptionPrintTuple, isWrunOptionPrintMarker, isWrunOptionPrintTuple, WRUN_OPTION_MAX_DTE_DAYS, WRUN_OPTION_PRINT_COLUMN, WRUN_OPTION_PRINT_SIDES, WRUN_OPTION_PRINTS_BOOK_FIELD, WRUN_OPTION_PRINTS_CONTINUOUS_FIELD, WRUN_OPTION_PRINTS_EXCHANGE_FIELD, WRUN_OPTION_PRINTS_HISTORY, WRUN_OPTION_PRINTS_MONEYNESS, WRUN_OPTION_PRINTS_NEWEST_MAX, WRUN_OPTION_PRINTS_NEWEST_TAIL_MAX_MS, WRUN_OPTION_PRINTS_OVERFLOW, WRUN_OPTION_PRINTS_TYPES, WRUN_OPTION_PRINTS_WIDTH, wrunLargestOrNewestOptionPrints, wrunLargestPremiumPrints, wrunNewestOptionPrintBound, wrunNewestOptionPrintRows, wrunOptionPrintKept, wrunOptionPrintOf, wrunOptionPrintsAcquisitionOf, wrunOptionPrintsHorizon, wrunOptionPrintsInTimeOrder, wrunOptionPrintTimeMs, } from '../../wrun-option-prints.util.js';
59
71
  import { wrunPartialMarkerTuple, wrunPresentIsPartial, wrunTuplesMarkedPartial } from '../../wrun-present-bits.util.js';
60
72
  import { wrunAuthorRuleSeed } from '../../wrun-refusal.util.js';
61
73
  import { wrunHostBarOf } from '../../wrun-tier-grid.util.js';
74
+ import { wrunHeldOpraPlaneChain } from '../../wrun-option-views.util.js';
62
75
  /** The lane's key, its feed in a refusal record. */
63
76
  const LANE_KEY = 'option_prints';
64
77
  /** om's refusal name of a missing floor. */
65
78
  export const WRUN_OPTION_PRINTS_MIN_PREMIUM_REQUIRED_CODE = 'wrun_option_prints_min_premium_required';
66
- /** What `identity` resolved for a chart (the one chain resolver's chart), read back by `facets`. Keyed by the chart
67
- * market; the newest entries kept. */
79
+ /** om's refusal name of a tail beside `overflow: "largest"` (the union's capacity is `max_cells` + `newest`). */
80
+ export const WRUN_OPTION_PRINTS_TAIL_LARGEST_CODE = 'wrun_option_prints_tail_largest';
68
81
  const PRINTS_CHARTS_KEPT = 16;
69
82
  const printsCharts = new Map();
70
83
  function rememberPrintsChart(key, chart) {
@@ -119,7 +132,8 @@ function wordKnob(source, ctx, knob, words) {
119
132
  }
120
133
  /**
121
134
  * One input's cuts and filters as acquisition fields (om `optionCellFacets`' print knobs, each absent at its default so
122
- * a sheet declaring none keeps its acquisition): `newest`, `newestTailMs` (beside `newest` only), `types`, `sides`
135
+ * a sheet declaring none keeps its acquisition): `newest`, `newestTailMs` (beside `newest` only, never beside
136
+ * `overflow: "largest"`: `wrun_option_prints_tail_largest`), `types`, `sides`
123
137
  * (om's facet spelling: the words in om's order joined by commas; none or all four is every side), `moneyness`,
124
138
  * `maxDte`, and under `overflow: "largest"` the per-bar cut `largestPerBar` (`laneMaxCells` + 1). Each refused by name
125
139
  * outside its words (`wrun_option_knob_invalid`).
@@ -130,6 +144,11 @@ function optionPrintsCutFacets(source, ctx, overflow, laneMaxCells) {
130
144
  if (tail !== undefined && newest === undefined) {
131
145
  refuseWrunOptionKnob(ctx, 'newest_tail_ms', tail, 'a tail beside newest only (declare newest, 1 and up)');
132
146
  }
147
+ if (tail !== undefined && overflow === 'largest') {
148
+ refuseWrunPollInput(ctx, `declares newest_tail_ms beside overflow "largest" (${WRUN_OPTION_PRINTS_TAIL_LARGEST_CODE}): each bar holds its ` +
149
+ 'max_cells largest and its prints among the newest, at most max_cells plus newest, a bound a tail would lift; ' +
150
+ 'declare the tail or the largest prints, not both', WRUN_POLL_AUTHOR_GATE_SEED);
151
+ }
133
152
  const types = wordKnob(source, ctx, 'types', WRUN_OPTION_PRINTS_TYPES);
134
153
  const moneyness = wordKnob(source, ctx, 'moneyness', WRUN_OPTION_PRINTS_MONEYNESS);
135
154
  const maxDte = countKnob(source, ctx, 'max_dte', WRUN_OPTION_MAX_DTE_DAYS, 'the days to expiry kept at most');
@@ -183,7 +202,10 @@ async function optionPrintsFacets(source, ctx) {
183
202
  }
184
203
  const expiries = wrunOptionExpiriesWord(wrunOptionExpiriesKnob(source, ctx));
185
204
  const cuts = optionPrintsCutFacets(source, ctx, overflow, facts.laneMaxCells);
186
- const chart = printsCharts.get(wrunLaneChartKey(ctx));
205
+ const resolved = printsCharts.get(wrunLaneChartKey(ctx));
206
+ const chart = resolved?.directory !== undefined && (source.max_dte !== undefined || source.expiries !== undefined)
207
+ ? await resolved.directory()
208
+ : resolved?.chart;
187
209
  if (chart === undefined) {
188
210
  return refuseWrunPollInput(ctx, 'could not resolve the chart market for its options chain: Run again', wrunAuthorRuleSeed(WRUN_OPTION_CHART_UNRESOLVED_CODE));
189
211
  }
@@ -300,18 +322,54 @@ function reconcileOptionPrints(held, answer) {
300
322
  return [row[0], ...mergeBarPrints(answered, kept)];
301
323
  });
302
324
  }
303
- /** One input's projection of a bar: its N nearest expiries, then its own bound under `overflow: "largest"`. */
304
- function projectOptionPrints(tuples, input) {
305
- const source = input.source;
325
+ /** One input's prints of a bar before any cut: its N nearest expiries, in time order. */
326
+ function inputOptionPrints(tuples, source) {
306
327
  const ordered = wrunOptionPrintsInTimeOrder(tuples);
307
328
  const expiries = wrunOptionExpiriesOf(source.expiries);
308
- const kept = expiries?.kind === 'nearest'
329
+ return expiries?.kind === 'nearest'
309
330
  ? wrunNearestExpiryTuples(ordered, expiries.count, WRUN_OPTION_PRINT_COLUMN.expiry)
310
331
  : ordered;
311
- if (source.overflow === 'largest' && input.maxCells !== undefined) {
312
- return wrunLargestPremiumPrints(kept, input.maxCells);
332
+ }
333
+ /** The window's newest N an input's bars are unioned with: its `newest` (1 and up) under `overflow: "largest"` with a
334
+ * bound of its own (`max_cells`), in a module whose buffer holds the union (`capacity` at least `max_cells` + N: the
335
+ * sheet's own, wrun-cell-capacity.leaf `wrunSheetCellBlockTuples`); undefined for any other input (its bars cut to
336
+ * their largest, or not at all), and for a sheet naming no such capacity (a module built before kit scaffold 97, or
337
+ * before 96 with a `max_cells` buffer), which keeps the cut before the union: each bar's `max_cells` largest. */
338
+ function unionNewestOf(input) {
339
+ const source = input.source;
340
+ const newest = source.newest;
341
+ return source.overflow === 'largest' &&
342
+ input.maxCells !== undefined &&
343
+ typeof newest === 'number' &&
344
+ Number.isInteger(newest) &&
345
+ newest >= 1 &&
346
+ input.capacity !== undefined &&
347
+ input.capacity >= input.maxCells + newest
348
+ ? newest
349
+ : undefined;
350
+ }
351
+ /** The window-level pass an input reads (`cellsWindow`), for an input reading the union alone: the bound of the
352
+ * window's newest cut over every bar the instance holds, each bar read as the input reads it (its nearest expiries),
353
+ * undefined for a window holding fewer than its `newest` prints (every print is newest). */
354
+ function optionPrintsWindow(input) {
355
+ const newest = unionNewestOf(input);
356
+ if (newest === undefined)
357
+ return undefined;
358
+ const source = input.source;
359
+ return (bars) => wrunNewestOptionPrintBound(bars.map((bar) => ({ openMs: bar.openMs, tuples: inputOptionPrints(bar.tuples, source) })), newest);
360
+ }
361
+ /** One input's projection of a bar: its N nearest expiries, then its own bound under `overflow: "largest"`: its
362
+ * largest alone, or beside `newest` its largest unioned with its prints inside the window's newest cut (`bar`, the
363
+ * window-level pass's bound; a caller that ran no pass reads the largest alone). */
364
+ function projectOptionPrints(tuples, input, bar) {
365
+ const source = input.source;
366
+ const kept = inputOptionPrints(tuples, source);
367
+ if (source.overflow !== 'largest' || input.maxCells === undefined)
368
+ return kept;
369
+ if (bar !== undefined && unionNewestOf(input) !== undefined) {
370
+ return wrunLargestOrNewestOptionPrints(kept, bar.openMs, input.maxCells, bar.window);
313
371
  }
314
- return kept;
372
+ return wrunLargestPremiumPrints(kept, input.maxCells);
315
373
  }
316
374
  export const rowLane = {
317
375
  sourceClass: 'option_prints',
@@ -323,7 +381,17 @@ export const rowLane = {
323
381
  chain: { exchangeField: WRUN_OPTION_PRINTS_EXCHANGE_FIELD },
324
382
  acquisitionMoved: wrunOptionPrintsAcquisitionMoved,
325
383
  identity: async (ctx) => {
326
- rememberPrintsChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx));
384
+ // On the OPRA plane the chain is the plane's own by coin, as `option_contract_state` holds it: no chain directory
385
+ // read before the first ask. The listing is asked only for an input naming a crypto venue.
386
+ const held = await wrunHeldOpraPlaneChain(ctx.exchange, ctx.coin, ctx.opraPlane);
387
+ const options = { cryptoListingOnDemand: true };
388
+ let directory;
389
+ rememberPrintsChart(wrunLaneChartKey(ctx), {
390
+ chart: await resolveWrunLaneChainChart(ctx, held, options),
391
+ ...(held !== undefined
392
+ ? { directory: () => (directory ??= resolveWrunLaneChainChart(ctx, undefined, options)) }
393
+ : {}),
394
+ });
327
395
  },
328
396
  facets: optionPrintsFacets,
329
397
  acquisitions: 'one',
@@ -331,6 +399,7 @@ export const rowLane = {
331
399
  horizon: wrunOptionPrintsHorizon,
332
400
  emptyAnswer: 'quiet',
333
401
  cells: projectOptionPrints,
402
+ cellsWindow: optionPrintsWindow,
334
403
  liveByCoin: {
335
404
  scriptSource: 'option_print',
336
405
  // The planes whose OPTION_PRINT producer streams live (a crypto chain's prints are derived each minute: history).
@@ -9,8 +9,8 @@
9
9
  */
10
10
  import { decideWrunLaneChain, resolveWrunLaneChainChart, WRUN_OPTION_CHART_UNRESOLVED_CODE, wrunLaneChartKey, } from '../opra-option-lanes.util.js';
11
11
  import { refuseWrunPollInput } from '../wrun-poll-lane.types.js';
12
- import { WRUN_OPTION_CONTRACT_FLOW_EXCHANGE_FIELD } from '../../wrun-option-contract-flow.util.js';
13
- import { foldWrunOptionStrikeFlowBar, WRUN_OPTION_STRIKE_FLOW_CLASS, WRUN_OPTION_STRIKE_FLOW_TIERS, WRUN_OPTION_STRIKE_FLOW_WIDTH, wrunOptionStrikeFlowBarRows, wrunOptionStrikeFlowHorizon, } from '../../wrun-option-strike-flow-lane.util.js';
12
+ import { WRUN_OPTION_CONTRACT_FLOW_EXCHANGE_FIELD, WRUN_OPTION_CONTRACT_FLOW_RAW_WIDTH, } from '../../wrun-option-contract-flow.util.js';
13
+ import { foldWrunOptionStrikeFlowBar, WRUN_OPTION_STRIKE_FLOW_CLASS, WRUN_OPTION_STRIKE_FLOW_FOLD_BUDGET_FIELD, WRUN_OPTION_STRIKE_FLOW_TIERS, WRUN_OPTION_STRIKE_FLOW_WIDTH, wrunOptionStrikeFlowBarRows, wrunOptionStrikeFlowHorizon, wrunOptionStrikeFlowMaxCellsField, } from '../../wrun-option-strike-flow-lane.util.js';
14
14
  import { wrunOptionContractFlowAcquisitionMoved, wrunOptionContractFlowExtras } from './option_contract_flow.js';
15
15
  import { wrunHeldOpraPlaneChain } from '../../wrun-option-views.util.js';
16
16
  import { wrunAuthorRuleSeed } from '../../wrun-refusal.util.js';
@@ -28,7 +28,7 @@ export function __resetWrunStrikeFlowChartsForTests() {
28
28
  strikeCharts.clear();
29
29
  }
30
30
  /** One input's facets: its knobs (om's rules, refused by name), then its chain, named in `option_contract_flow`'s
31
- * fields. */
31
+ * fields, and the package's bound on a bar where it is under the knobs' projection (`maxCells`). */
32
32
  async function strikeFlowFacets(source, ctx) {
33
33
  const { wrunOptionStrikeFlowKnobsOf } = await import('../../wrun-option-strike-flow.util.js');
34
34
  const knobs = wrunOptionStrikeFlowKnobsOf(source, ctx);
@@ -37,7 +37,16 @@ async function strikeFlowFacets(source, ctx) {
37
37
  return refuseWrunPollInput(ctx, 'could not resolve the chart market for its options chain: Run again', wrunAuthorRuleSeed(WRUN_OPTION_CHART_UNRESOLVED_CODE));
38
38
  }
39
39
  const chain = await decideWrunLaneChain(chart, { venue: source.venue, book: source.book }, ctx);
40
- return { ...wrunOptionContractFlowExtras(chain), ...knobs };
40
+ const extras = { ...wrunOptionContractFlowExtras(chain), ...knobs };
41
+ const { laneMaxCells } = ctx;
42
+ return { ...extras, ...wrunOptionStrikeFlowMaxCellsField(extras, laneMaxCells) };
43
+ }
44
+ /** FE-FOLD-CAP (OPTLOAD W3, R2's projection): the bytes a read of one input is forecast to download where the worker
45
+ * folds it from the chain's contract rows in the browser (wrun-option-strike-flow-forecast.util, loaded here only on a
46
+ * run with the download budget's flag on). */
47
+ async function strikeFlowForecastBytes(source, ctx, chart) {
48
+ const { wrunOptionStrikeFlowForecastBytes } = await import('../../wrun-option-strike-flow-forecast.util.js');
49
+ return wrunOptionStrikeFlowForecastBytes(source, ctx, chart);
41
50
  }
42
51
  export const rowLane = {
43
52
  sourceClass: WRUN_OPTION_STRIKE_FLOW_CLASS,
@@ -62,4 +71,8 @@ export const rowLane = {
62
71
  horizon: wrunOptionStrikeFlowHorizon,
63
72
  rowBudget: { cellsPerRow: WRUN_OPTION_STRIKE_FLOW_WIDTH, barRows: wrunOptionStrikeFlowBarRows },
64
73
  emptyAnswer: 'quiet',
74
+ download: {
75
+ forecastBytes: strikeFlowForecastBytes,
76
+ fold: { field: WRUN_OPTION_STRIKE_FLOW_FOLD_BUDGET_FIELD, cellsPerRow: WRUN_OPTION_CONTRACT_FLOW_RAW_WIDTH },
77
+ },
65
78
  };