@orangecharts/wrun-chart-host 0.9.0 → 0.11.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 (252) hide show
  1. package/README.md +2 -0
  2. package/dist/constants/feature-flags.constants.d.ts +15 -1
  3. package/dist/constants/feature-flags.constants.js +130 -24
  4. package/dist/constants/governed-exchanges.constants.d.ts +12 -0
  5. package/dist/constants/governed-exchanges.constants.js +16 -0
  6. package/dist/constants/opra-compliance.constants.d.ts +3 -2
  7. package/dist/constants/opra-compliance.constants.js +3 -2
  8. package/dist/constants/option-venues.constants.d.ts +2 -2
  9. package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +26 -0
  10. package/dist/constants/scriptEditor/builtin-script-snippets.js +6 -0
  11. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +15 -0
  12. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +17 -0
  13. package/dist/constants/venue-presets.constants.d.ts +20 -20
  14. package/dist/constants/venue-presets.constants.js +24 -26
  15. package/dist/host-env.d.ts +21 -5
  16. package/dist/host-env.js +6 -0
  17. package/dist/host-ports.types.d.ts +102 -19
  18. package/dist/index.d.ts +18 -0
  19. package/dist/index.js +18 -0
  20. package/dist/interfaces/cancel-reason.interface.d.ts +1 -1
  21. package/dist/interfaces/cme-realtime.interface.d.ts +16 -9
  22. package/dist/interfaces/cme-realtime.interface.js +6 -3
  23. package/dist/interfaces/kscript-diagnostics.interface.d.ts +12 -0
  24. package/dist/interfaces/opra-realtime.interface.d.ts +1 -5
  25. package/dist/interfaces/prediction-market.interface.d.ts +7 -0
  26. package/dist/interfaces/replay.interface.d.ts +8 -0
  27. package/dist/interfaces/stocks-realtime.interface.d.ts +57 -0
  28. package/dist/interfaces/stocks-realtime.interface.js +32 -0
  29. package/dist/interfaces/wrun-runtime.interface.d.ts +18 -2
  30. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +62 -94
  31. package/dist/kscript-data/controls/live-trades-merge.util.js +106 -171
  32. package/dist/market-data/billing.interface.d.ts +174 -36
  33. package/dist/market-data/billing.interface.js +58 -8
  34. package/dist/market-data/venue.d.ts +152 -7
  35. package/dist/market-data/venues/cme.contract.copy.json +66 -0
  36. package/dist/market-data/venues/cme.d.ts +126 -0
  37. package/dist/market-data/venues/cme.js +133 -0
  38. package/dist/market-data/venues/index.d.ts +294 -7
  39. package/dist/market-data/venues/index.js +49 -6
  40. package/dist/market-data/venues/opra.contract.copy.json +3 -2
  41. package/dist/market-data/venues/opra.d.ts +2 -2
  42. package/dist/market-data/venues/opra.js +5 -2
  43. package/dist/market-data/venues/stocks.contract.copy.json +64 -0
  44. package/dist/market-data/venues/stocks.d.ts +130 -0
  45. package/dist/market-data/venues/stocks.js +117 -0
  46. package/dist/settings-templates/footprint-rows.js +35 -2
  47. package/dist/settings-templates/form-rows.d.ts +2 -1
  48. package/dist/settings-templates/index.js +7 -3
  49. package/dist/settings-templates/indicator-fields.d.ts +5 -4
  50. package/dist/settings-templates/indicator-fields.js +79 -10
  51. package/dist/settings-templates/tool-rules.d.ts +32 -15
  52. package/dist/settings-templates/tool-rules.js +33 -11
  53. package/dist/settings-templates/tool-tables.generated.js +95 -31
  54. package/dist/utility/chart/book-live-bucket.util.d.ts +15 -0
  55. package/dist/utility/chart/book-live-bucket.util.js +47 -0
  56. package/dist/utility/chart/cme-cache-context.util.d.ts +5 -3
  57. package/dist/utility/chart/cme-cache-context.util.js +10 -6
  58. package/dist/utility/chart/cme-realtime.util.js +10 -0
  59. package/dist/utility/chart/cme-user-scripts-gate.util.d.ts +83 -0
  60. package/dist/utility/chart/cme-user-scripts-gate.util.js +142 -0
  61. package/dist/utility/chart/effective-chart-session.util.d.ts +14 -0
  62. package/dist/utility/chart/effective-chart-session.util.js +39 -0
  63. package/dist/utility/chart/host-bar-placement.util.d.ts +28 -0
  64. package/dist/utility/chart/host-bar-placement.util.js +170 -30
  65. package/dist/utility/chart/index-host-tier.util.d.ts +3 -1
  66. package/dist/utility/chart/index-host-tier.util.js +7 -2
  67. package/dist/utility/chart/index-mode-admission.util.js +30 -3
  68. package/dist/utility/chart/kscript-apply-fingerprint.util.js +1 -1
  69. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +35 -11
  70. package/dist/utility/chart/kscript-drawing-safe-area.util.js +145 -35
  71. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +9 -7
  72. package/dist/utility/chart/kscript-live-coalesce.util.js +13 -8
  73. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +9 -0
  74. package/dist/utility/chart/kscript-live-source-identity.util.js +10 -1
  75. package/dist/utility/chart/kscript-provenance-keys.util.js +13 -0
  76. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +5 -1
  77. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +32 -2
  78. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +45 -0
  79. package/dist/utility/chart/kscript-venue-policy.util.d.ts +156 -43
  80. package/dist/utility/chart/kscript-venue-policy.util.js +249 -59
  81. package/dist/utility/chart/live-bucket.util.d.ts +24 -8
  82. package/dist/utility/chart/live-bucket.util.js +85 -27
  83. package/dist/utility/chart/market-session-schedule.util.d.ts +10 -0
  84. package/dist/utility/chart/market-session-schedule.util.js +16 -0
  85. package/dist/utility/chart/marketKind.util.js +5 -0
  86. package/dist/utility/chart/mixed-mode.util.d.ts +7 -0
  87. package/dist/utility/chart/mixed-mode.util.js +14 -0
  88. package/dist/utility/chart/opra-read-access.leaf.d.ts +5 -3
  89. package/dist/utility/chart/opra-read-access.leaf.js +5 -3
  90. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +11 -16
  91. package/dist/utility/chart/opra-user-scripts-gate.util.js +12 -28
  92. package/dist/utility/chart/rth-session.util.d.ts +12 -10
  93. package/dist/utility/chart/rth-session.util.js +25 -21
  94. package/dist/utility/chart/trading-day.util.d.ts +17 -0
  95. package/dist/utility/chart/trading-day.util.js +59 -0
  96. package/dist/utility/chart/window-geometry.leaf.d.ts +8 -0
  97. package/dist/utility/chart/window-geometry.leaf.js +22 -6
  98. package/dist/utility/chart/window-owner.leaf.d.ts +23 -2
  99. package/dist/utility/chart/window-owner.leaf.js +45 -3
  100. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +33 -15
  101. package/dist/utility/chart/wrun-bar-session-facts.util.js +70 -20
  102. package/dist/utility/chart/wrun-run-result.util.d.ts +12 -0
  103. package/dist/utility/chart/wrun-run-result.util.js +141 -6
  104. package/dist/utility/intl-locale.util.js +5 -0
  105. package/dist/utility/options/option-bar-anchor.util.d.ts +145 -0
  106. package/dist/utility/options/option-bar-anchor.util.js +340 -0
  107. package/dist/utility/options/option-venue.util.d.ts +18 -0
  108. package/dist/utility/options/option-venue.util.js +27 -0
  109. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +4 -0
  110. package/dist/utility/v2/gate-plane.util.d.ts +12 -3
  111. package/dist/utility/v2/gate-plane.util.js +30 -4
  112. package/dist/utility/v2/gate-session-latch.util.js +1 -1
  113. package/dist/utility/v2/stocks-governed.util.d.ts +16 -0
  114. package/dist/utility/v2/stocks-governed.util.js +34 -0
  115. package/dist/utility/wrun/derived-roots.leaf.d.ts +13 -0
  116. package/dist/utility/wrun/derived-roots.leaf.js +27 -0
  117. package/dist/utility/wrun/derived-roots.util.d.ts +205 -0
  118. package/dist/utility/wrun/derived-roots.util.js +451 -0
  119. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +43 -7
  120. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +89 -19
  121. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +9 -4
  122. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +47 -6
  123. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -2
  124. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -2
  125. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +24 -3
  126. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +46 -10
  127. package/dist/utility/wrun/sources/lanes/option_daily.js +5 -2
  128. package/dist/utility/wrun/sources/lanes/options_flow.js +5 -2
  129. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +64 -19
  130. package/dist/utility/wrun/sources/opra-option-lanes.util.js +105 -35
  131. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +2 -1
  132. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +2 -1
  133. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +3 -0
  134. package/dist/utility/wrun/sources/row-lanes/option_prints.js +19 -4
  135. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +17 -4
  136. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +52 -13
  137. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +88 -19
  138. package/dist/utility/wrun/sources/row-lanes/option_surface.js +2 -1
  139. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -0
  140. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +24 -9
  141. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +41 -10
  142. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +111 -0
  143. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +133 -0
  144. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +15 -3
  145. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +22 -3
  146. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +31 -0
  147. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +197 -13
  148. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +761 -27
  149. package/dist/utility/wrun/wrun-browser-sources.leaf.js +1 -2
  150. package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +12 -0
  151. package/dist/utility/wrun/wrun-builtin-twin.util.js +21 -0
  152. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +60 -16
  153. package/dist/utility/wrun/wrun-chart-market-facts.util.js +113 -61
  154. package/dist/utility/wrun/wrun-color-settings.util.d.ts +9 -0
  155. package/dist/utility/wrun/wrun-color-settings.util.js +33 -0
  156. package/dist/utility/wrun/wrun-download-meter.util.d.ts +15 -0
  157. package/dist/utility/wrun/wrun-download-meter.util.js +14 -2
  158. package/dist/utility/wrun/wrun-download-plan.util.d.ts +99 -0
  159. package/dist/utility/wrun/wrun-download-plan.util.js +118 -0
  160. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +11 -3
  161. package/dist/utility/wrun/wrun-draft-legend-note.util.js +26 -4
  162. package/dist/utility/wrun/wrun-frames.d.ts +27 -6
  163. package/dist/utility/wrun/wrun-frames.js +73 -10
  164. package/dist/utility/wrun/wrun-handles.util.d.ts +7 -3
  165. package/dist/utility/wrun/wrun-handles.util.js +9 -8
  166. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +7 -1
  167. package/dist/utility/wrun/wrun-hosted-wire.util.js +12 -2
  168. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +18 -4
  169. package/dist/utility/wrun/wrun-hud-looks.util.js +45 -13
  170. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +68 -0
  171. package/dist/utility/wrun/wrun-input-requirements.leaf.js +163 -7
  172. package/dist/utility/wrun/wrun-latest-snapshot.d.ts +11 -0
  173. package/dist/utility/wrun/wrun-leg-close.util.d.ts +59 -23
  174. package/dist/utility/wrun/wrun-leg-close.util.js +186 -28
  175. package/dist/utility/wrun/wrun-live-intake.util.d.ts +35 -15
  176. package/dist/utility/wrun/wrun-live-intake.util.js +243 -126
  177. package/dist/utility/wrun/wrun-live-tick.util.d.ts +13 -5
  178. package/dist/utility/wrun/wrun-live-tick.util.js +279 -99
  179. package/dist/utility/wrun/wrun-market-facts.util.d.ts +13 -3
  180. package/dist/utility/wrun/wrun-market-facts.util.js +13 -3
  181. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +60 -11
  182. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +70 -5
  183. package/dist/utility/wrun/wrun-market-size-defaults.util.js +31 -5
  184. package/dist/utility/wrun/wrun-opra-lane.util.d.ts +17 -4
  185. package/dist/utility/wrun/wrun-opra-lane.util.js +6 -4
  186. package/dist/utility/wrun/wrun-option-book-rows.util.d.ts +56 -0
  187. package/dist/utility/wrun/wrun-option-book-rows.util.js +96 -0
  188. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.d.ts +31 -0
  189. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.js +119 -0
  190. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +23 -6
  191. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +47 -11
  192. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +86 -19
  193. package/dist/utility/wrun/wrun-option-strike-flow.util.js +168 -62
  194. package/dist/utility/wrun/wrun-option-views.util.d.ts +323 -28
  195. package/dist/utility/wrun/wrun-option-views.util.js +484 -71
  196. package/dist/utility/wrun/wrun-options-chain.util.d.ts +3 -3
  197. package/dist/utility/wrun/wrun-options-chain.util.js +2 -0
  198. package/dist/utility/wrun/wrun-output-style.util.d.ts +6 -2
  199. package/dist/utility/wrun/wrun-output-style.util.js +20 -2
  200. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +32 -2
  201. package/dist/utility/wrun/wrun-overlay-drivers.util.js +13 -3
  202. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +10 -1
  203. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +52 -4
  204. package/dist/utility/wrun/wrun-overlay-recovery.util.js +3 -1
  205. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +160 -42
  206. package/dist/utility/wrun/wrun-overlay-run.util.js +1244 -209
  207. package/dist/utility/wrun/wrun-pane-format.util.d.ts +2 -1
  208. package/dist/utility/wrun/wrun-pane-format.util.js +7 -3
  209. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +9 -0
  210. package/dist/utility/wrun/wrun-panel-mount.util.js +114 -19
  211. package/dist/utility/wrun/wrun-panel-style.util.d.ts +10 -9
  212. package/dist/utility/wrun/wrun-panel-style.util.js +58 -9
  213. package/dist/utility/wrun/wrun-param-map.util.d.ts +14 -11
  214. package/dist/utility/wrun/wrun-param-map.util.js +10 -5
  215. package/dist/utility/wrun/wrun-param-values.util.d.ts +14 -4
  216. package/dist/utility/wrun/wrun-param-values.util.js +4 -0
  217. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +15 -2
  218. package/dist/utility/wrun/wrun-pin-spelling.util.js +39 -14
  219. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +50 -0
  220. package/dist/utility/wrun/wrun-refusal-surface.util.js +68 -0
  221. package/dist/utility/wrun/wrun-refusal.util.d.ts +3 -2
  222. package/dist/utility/wrun/wrun-refusal.util.js +22 -0
  223. package/dist/utility/wrun/wrun-refused-latest.util.d.ts +10 -0
  224. package/dist/utility/wrun/wrun-refused-latest.util.js +12 -0
  225. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +26 -0
  226. package/dist/utility/wrun/wrun-registry-errors.util.js +34 -0
  227. package/dist/utility/wrun/wrun-replay-lane.util.js +3 -2
  228. package/dist/utility/wrun/wrun-row-source.d.ts +11 -0
  229. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +20 -6
  230. package/dist/utility/wrun/wrun-run-interval-session.util.js +22 -7
  231. package/dist/utility/wrun/wrun-run-interval.util.d.ts +43 -9
  232. package/dist/utility/wrun/wrun-run-interval.util.js +58 -15
  233. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +45 -1
  234. package/dist/utility/wrun/wrun-script-inputs.util.js +112 -4
  235. package/dist/utility/wrun/wrun-setting-words.util.d.ts +7 -3
  236. package/dist/utility/wrun/wrun-setting-words.util.js +13 -5
  237. package/dist/utility/wrun/wrun-socket-row-source.d.ts +27 -2
  238. package/dist/utility/wrun/wrun-socket-row-source.js +118 -8
  239. package/dist/utility/wrun/wrun-source-rows.util.d.ts +29 -18
  240. package/dist/utility/wrun/wrun-source-rows.util.js +61 -27
  241. package/dist/utility/wrun/wrun-style-words.util.js +6 -4
  242. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +3 -2
  243. package/dist/utility/wrun/wrun-table-chrome.util.js +19 -11
  244. package/dist/utility/wrun/wrun-tape-per-order.util.d.ts +2 -0
  245. package/dist/utility/wrun/wrun-tape-per-order.util.js +7 -0
  246. package/dist/utility/wrun/wrun-tape-source.util.d.ts +17 -9
  247. package/dist/utility/wrun/wrun-tape-source.util.js +20 -12
  248. package/dist/utils/replay/replay-buffer-math.d.ts +53 -2
  249. package/dist/utils/replay/replay-buffer-math.js +227 -20
  250. package/dist/workers/constants/socket-slots.d.ts +91 -6
  251. package/dist/workers/constants/socket-slots.js +85 -6
  252. package/package.json +5 -5
@@ -6,14 +6,21 @@
6
6
  * - the intent warm of a surface whose open suspects an options add is coming (round 2: the Indicators dialog's open,
7
7
  * the Options panel's), `warmWrunChartGateReaderOnIntent`: the same reader, dialed only when no other tab of this
8
8
  * browser holds it for this identity and tier (the transport's lease, V2Service `warmGateReaderOnIntent`), so an
9
- * open never takes another tab's session.
9
+ * open never takes another tab's session;
10
+ * - the add's own dial of an ADMITTED native options add (web: chart.add-indicator's admission), so its handshake
11
+ * overlaps the rest of the mount: `dialWrunChartGateReaderForAdd`, unguarded like the package door's, since the add
12
+ * contests the session exactly as its first read would.
10
13
  *
11
- * The plane is the one the run's planner judges the chart by (`governedOptionPlane`: OPRA on a US stock or ETF chart,
12
- * CME on a CME futures chart, under the account's option venue gates), read once the `opra` flag is known when that
13
- * flag decides the chart's options (bounded, the run head's own wait), so an unhydrated flag map never reads as a chart
14
- * off the plane. Light at module load (the env and the plane's exchange): a surface's open loads no lane registry.
14
+ * The plane is the one the run's planner judges the chart by: the run head's own decision
15
+ * (`decideWrunChartOptionsMarket`, which the run head reads too), over the market whose options the chart reads (the
16
+ * options seam, the gate port's `chartOptionsMarket`: a stock twin's US stock while the `opra` flag is lit) and its
17
+ * plane (`governedOptionPlane`: OPRA on a US stock or ETF chart, CME on a CME futures chart, under the account's option
18
+ * venue gates), read once the `opra` flag is known when that flag decides the chart's options and once a twin's answer
19
+ * is in (both bounded), so an unhydrated flag map never reads as a chart off the plane. Light at module load (the env,
20
+ * the flag words and the plane's exchange): a surface's open loads no lane registry.
15
21
  */
16
22
  import { wrunChartHostEnv } from '../../../host-env.js';
23
+ import { FeatureFlag } from '../../../constants/feature-flags.constants.js';
17
24
  import { OPRA_GOVERNED_EXCHANGES } from '../../../interfaces/opra-realtime.interface.js';
18
25
  /**
19
26
  * The exchange a gate plane's lane reads name, the one the transport routes them by: an OPRA lane asks by the plane's
@@ -23,35 +30,98 @@ import { OPRA_GOVERNED_EXCHANGES } from '../../../interfaces/opra-realtime.inter
23
30
  export function wrunGateReadExchangeOf(plane, chartExchange) {
24
31
  return plane === 'opra' ? OPRA_GOVERNED_EXCHANGES[0] : chartExchange;
25
32
  }
26
- /** The exchange the reads of a chart's options route by on their gate plane (see the module comment), or null for a
27
- * chart whose options ride no plane. Rejects only when the options gate cannot load. */
28
- export async function wrunChartGateReadExchange(chartExchange) {
33
+ /** The `opra` flag lit for this account, as the host's flag store reads it now (false where none is up). */
34
+ function opraFlagLit() {
35
+ try {
36
+ return wrunChartHostEnv().user.isFeatureOn(FeatureFlag.Opra);
37
+ }
38
+ catch {
39
+ return false;
40
+ }
41
+ }
42
+ /** A door's chart as a market reference: an exchange alone names no market. */
43
+ function gateReaderChartRef(chart) {
44
+ return typeof chart === 'string' ? { exchange: chart, symbol: undefined } : chart;
45
+ }
46
+ /**
47
+ * The market whose options a chart reads, its plane and its stop, decided ONCE (a run's head reads it, and both gate
48
+ * reader warms): the flag map first where the `opra` flag decides the chart's options (`opraFlagDecidesChartOptions`: a
49
+ * US stock, an OPRA contract or index chart, a known stock twin) or where `stamped` says the overlay read OPRA before,
50
+ * bounded (`awaitOpraFlagHydration`); then, under a lit flag or a stamp only, the chart's stock twin answer, bounded
51
+ * (the gate port's `awaitStockTwin`, which answers at once for a known answer and a market that cannot be a twin); then
52
+ * the market (the gate port's `chartOptionsMarket`), its plane and its stop in one synchronous step, so the three read
53
+ * one state of the seam. A host that binds neither twin port reads every chart's options off its own market. Rejects
54
+ * only when the options gate cannot load.
55
+ */
56
+ export async function decideWrunChartOptionsMarket(chart, stamped = false) {
29
57
  const gate = await wrunChartHostEnv().market.loadOptionsGate();
30
- if (gate.opraFlagDecidesChartOptions({ exchange: chartExchange }))
58
+ if (stamped || gate.opraFlagDecidesChartOptions(chart))
31
59
  await gate.awaitOpraFlagHydration();
32
- const plane = gate.governedOptionPlane({ exchange: chartExchange });
33
- return plane === null ? null : wrunGateReadExchangeOf(plane, chartExchange);
60
+ if (gate.awaitStockTwin !== undefined && (stamped || opraFlagLit()))
61
+ await gate.awaitStockTwin(chart);
62
+ const market = gate.chartOptionsMarket?.(chart) ?? chart;
63
+ const plane = gate.governedOptionPlane(market);
64
+ const opraStop = plane === null ? gate.opraOptionPlaneStop(market) : undefined;
65
+ return { chart, market, plane, ...(opraStop !== undefined ? { opraStop } : {}) };
66
+ }
67
+ /** The exchange the reads of a chart's options route by on their gate plane (see the module comment), or null for a
68
+ * chart whose options ride no plane. Rejects only when the options gate cannot load. */
69
+ export async function wrunChartGateReadExchange(chart) {
70
+ const decided = await decideWrunChartOptionsMarket(gateReaderChartRef(chart));
71
+ const exchange = decided.market.exchange;
72
+ return decided.plane === null || typeof exchange !== 'string'
73
+ ? null
74
+ : wrunGateReadExchangeOf(decided.plane, exchange);
34
75
  }
35
76
  /**
36
77
  * Warm the gate reader the chart's options are read on, for a surface whose open suspects an options add is coming:
37
78
  * dialed through the transport only when no other tab of this browser holds that reader for this identity and tier,
38
79
  * once per reader's life (a reader this tab already dials or holds is left alone), and under every guard of a dial (a
39
- * guest, a terms wall, a refusal). A reader no read ever uses is released by the transport's idle sweep. Resolves with
40
- * what it did (`no-plane` for a chart whose options ride no gate plane, `failed` when a load or a port failed); never
41
- * rejects.
80
+ * guest, a terms wall, a refusal). `kind` names the reads it readies the reader for (the slot they ride: `candles` by
81
+ * default, `metadata` for the one-shot reads a native options add makes first). A reader no read ever uses is released
82
+ * by the transport's idle sweep. Resolves with what it did (`no-plane` for a chart whose options ride no gate plane,
83
+ * `failed` when a load or a port failed); never rejects.
42
84
  */
43
- export async function warmWrunChartGateReaderOnIntent(chartExchange, surface) {
85
+ export async function warmWrunChartGateReaderOnIntent(chart, surface, kind = 'candles') {
44
86
  try {
45
- if (typeof chartExchange !== 'string' || chartExchange === '')
87
+ if (chart === null || chart === undefined)
46
88
  return 'no-plane';
47
- const exchange = await wrunChartGateReadExchange(chartExchange);
48
- if (exchange === null)
89
+ const exchange = gateReaderChartRef(chart).exchange;
90
+ if (typeof exchange !== 'string' || exchange === '')
91
+ return 'no-plane';
92
+ const readExchange = await wrunChartGateReadExchange(chart);
93
+ if (readExchange === null)
49
94
  return 'no-plane';
50
95
  const { default: v2 } = await wrunChartHostEnv().transport.loadV2Service();
51
- return await v2.warmGateReaderOnIntent(exchange, surface);
96
+ return await v2.warmGateReaderOnIntent(readExchange, surface, kind);
52
97
  }
53
98
  catch {
54
99
  // Advice: the add's own door warm, and its first ask, dial for themselves.
55
100
  return 'failed';
56
101
  }
57
102
  }
103
+ /**
104
+ * The add's own dial of the reader a chart's options data reads ride (V2Service `warmGateReaderFor`: the `candles`
105
+ * slot at the served tier, under every guard of an on-demand dial but no lease, since the add contests another tab's
106
+ * session exactly as its first read would). For an add the host has ADMITTED (web: chart.add-indicator, after its
107
+ * slot, duplicate and lock gates), never for an intent: a refused add must dial nothing. A chart whose options ride no
108
+ * plane dials nothing. `chart` is the chart's market (an exchange alone names no market: a stock twin is not seen
109
+ * there, and its venue's own plane is dialed). Resolves once the dial was asked for; never rejects.
110
+ */
111
+ export async function dialWrunChartGateReaderForAdd(chart) {
112
+ try {
113
+ if (chart === null || chart === undefined)
114
+ return;
115
+ const chartExchange = gateReaderChartRef(chart).exchange;
116
+ if (typeof chartExchange !== 'string' || chartExchange === '')
117
+ return;
118
+ const exchange = await wrunChartGateReadExchange(chart);
119
+ if (exchange === null)
120
+ return;
121
+ const { default: v2 } = await wrunChartHostEnv().transport.loadV2Service();
122
+ v2.warmGateReaderFor(exchange);
123
+ }
124
+ catch {
125
+ // Advice: the add's first read dials the reader for itself.
126
+ }
127
+ }
@@ -1,5 +1,6 @@
1
1
  import type { WrunGateReaderIntentSurface } from '../../../host-ports.types.js';
2
2
  import type { WrunIndicatorMetadata } from '../../../interfaces/wrun-runtime.interface.js';
3
+ import { type WrunGateReaderChart } from './wrun-chart-gate-reader.util.js';
3
4
  /** Whether a poll source class's plan reads the chart's options chain: an OPRA lane resolves the chain's underlying, a
4
5
  * chain lane the chain itself (sources/opra-option-lanes.util), one summary read on the network. The run's lanes known
5
6
  * without it never wait for that plan (`prepareWrunSandboxRun`), and its reads ride the chain's plane. */
@@ -15,9 +16,13 @@ export declare function wrunSheetReadsGatePlane(metadata: Pick<WrunIndicatorMeta
15
16
  /**
16
17
  * Dial the gate reader a sheet's lanes read on this chart, and start the chunk loads their plans await (see the module
17
18
  * comment). The plane and its exchange are the chart's (`wrunChartGateReadExchange`, the decision the intent warm of a
18
- * surface's open shares: the plane the run's planner judges the chart by, read once the `opra` flag is known when that
19
- * flag decides the chart's options). `intent`: no add was asked yet (a row's settled intent), so the dial asks the
19
+ * surface's open shares: the plane the run's planner judges the chart by, over the market whose options the chart reads,
20
+ * a stock twin's US stock under a lit `opra` flag included, read once the `opra` flag is known when that flag decides
21
+ * the chart's options). `chart` is the chart's market (an exchange alone names no market: a stock twin is not seen
22
+ * there, and its venue's own plane is warmed). `intent`: no add was asked yet (a row's settled intent), so the dial asks the
20
23
  * transport's lease-guarded warm (`warmGateReaderOnIntent`) and never takes another tab's session; without it the dial
21
- * is the add's own (`warmGateReaderFor`). Resolves once the dial was asked for, or nothing was to warm.
24
+ * is the add's own (`warmGateReaderFor`), and the door notes the account's options read. On the CME plane the door
25
+ * starts the optionable directory beside the dial, whichever door it is. Resolves once the dial was asked for, or
26
+ * nothing was to warm.
22
27
  */
23
- export declare function warmWrunSheetGateReaders(metadata: Pick<WrunIndicatorMetadata, 'inputs' | 'inputSources'> | null | undefined, chartExchange: string | null | undefined, intent?: WrunGateReaderIntentSurface): Promise<void>;
28
+ export declare function warmWrunSheetGateReaders(metadata: Pick<WrunIndicatorMetadata, 'inputs' | 'inputSources'> | null | undefined, chart: WrunGateReaderChart | null | undefined, intent?: WrunGateReaderIntentSurface): Promise<void>;
@@ -23,8 +23,15 @@
23
23
  * A door with no add asked yet (round 2: a row's settled intent, `surface` `add-intent`) dials through the transport's
24
24
  * intent warm instead, which never takes the session of another tab of the browser reading that reader
25
25
  * (V2Service `warmGateReaderOnIntent`); an add's own doors contest it as the add always did.
26
+ *
27
+ * OPTLOAD W3: on a CME chart the door also starts the optionable directory a chain lane's identity awaits after the
28
+ * plan (two serial StreamMarkets pages on a cold page, 1.5 to 3.8 s from the plan to the first options ask on INT, ES1!
29
+ * 1h), for any account: the plan's read then joins it, or finds its snapshot. And the add's own door notes that this
30
+ * account reads options on the chart's gate plane, the stamp the next chart load prepares that access by (web:
31
+ * utility/options/chart-options-access.util); a row's intent notes nothing.
26
32
  */
27
33
  import { wrunChartHostEnv } from '../../../host-env.js';
34
+ import { gateProviderForExchange } from '../../v2/gate-plane.util.js';
28
35
  import { wrunPollLanesOfClass } from '../sources/registry.js';
29
36
  import { wrunRowLaneOfClass } from '../sources/row-lane-registry.js';
30
37
  import { wrunChartGateReadExchange } from './wrun-chart-gate-reader.util.js';
@@ -53,17 +60,46 @@ export function wrunSourceClassReadsGatePlane(sourceClass) {
53
60
  export function wrunSheetReadsGatePlane(metadata) {
54
61
  return (metadata.inputs ?? []).some((input) => wrunSourceClassReadsGatePlane(metadata.inputSources?.[input.name]?.source));
55
62
  }
63
+ /** The add door's options stamp (the provenance port's `noteGatePlaneOptionsRead`, optional): advice, never awaited. */
64
+ function noteWrunDoorOptionsRead(env) {
65
+ try {
66
+ void env.chart
67
+ .loadOptionsOverlayProvenance()
68
+ .then((provenance) => provenance.noteGatePlaneOptionsRead?.())
69
+ .catch(() => undefined);
70
+ }
71
+ catch {
72
+ // A host without the port keeps no stamp: the next chart load prepares nothing ahead, as before.
73
+ }
74
+ }
75
+ /** Start the CME optionable directory read (the market port's `prewarmOptionableDirectory`, optional): advice. */
76
+ function startWrunCmeOptionableDirectory(env) {
77
+ try {
78
+ void env.market
79
+ .loadOptionChainService()
80
+ .then(({ default: service }) => service.prewarmOptionableDirectory?.())
81
+ .catch(() => undefined);
82
+ }
83
+ catch {
84
+ // The plan reads the directory itself, as before.
85
+ }
86
+ }
56
87
  /**
57
88
  * Dial the gate reader a sheet's lanes read on this chart, and start the chunk loads their plans await (see the module
58
89
  * comment). The plane and its exchange are the chart's (`wrunChartGateReadExchange`, the decision the intent warm of a
59
- * surface's open shares: the plane the run's planner judges the chart by, read once the `opra` flag is known when that
60
- * flag decides the chart's options). `intent`: no add was asked yet (a row's settled intent), so the dial asks the
90
+ * surface's open shares: the plane the run's planner judges the chart by, over the market whose options the chart reads,
91
+ * a stock twin's US stock under a lit `opra` flag included, read once the `opra` flag is known when that flag decides
92
+ * the chart's options). `chart` is the chart's market (an exchange alone names no market: a stock twin is not seen
93
+ * there, and its venue's own plane is warmed). `intent`: no add was asked yet (a row's settled intent), so the dial asks the
61
94
  * transport's lease-guarded warm (`warmGateReaderOnIntent`) and never takes another tab's session; without it the dial
62
- * is the add's own (`warmGateReaderFor`). Resolves once the dial was asked for, or nothing was to warm.
95
+ * is the add's own (`warmGateReaderFor`), and the door notes the account's options read. On the CME plane the door
96
+ * starts the optionable directory beside the dial, whichever door it is. Resolves once the dial was asked for, or
97
+ * nothing was to warm.
63
98
  */
64
- export async function warmWrunSheetGateReaders(metadata, chartExchange, intent) {
99
+ export async function warmWrunSheetGateReaders(metadata, chart, intent) {
65
100
  try {
66
- if (!metadata || typeof chartExchange !== 'string' || chartExchange === '')
101
+ const chartExchange = typeof chart === 'string' ? chart : chart?.exchange;
102
+ if (!metadata || !chart || typeof chartExchange !== 'string' || chartExchange === '')
67
103
  return;
68
104
  if (!wrunSheetReadsGatePlane(metadata))
69
105
  return;
@@ -75,9 +111,14 @@ export async function warmWrunSheetGateReaders(metadata, chartExchange, intent)
75
111
  env.market.loadDeribitOptions(),
76
112
  env.market.loadOptionsChartSource(),
77
113
  ]);
78
- const exchange = await wrunChartGateReadExchange(chartExchange);
114
+ const exchange = await wrunChartGateReadExchange(chart);
79
115
  if (exchange === null)
80
116
  return;
117
+ if (intent === undefined)
118
+ noteWrunDoorOptionsRead(env);
119
+ // The reader the reads ride names the plane (the transport's own routing rule): only a CME chain reads the directory.
120
+ if (gateProviderForExchange(exchange) === 'cme')
121
+ startWrunCmeOptionableDirectory(env);
81
122
  const { default: v2 } = await env.transport.loadV2Service();
82
123
  if (intent === undefined)
83
124
  v2.warmGateReaderFor(exchange);
@@ -19,8 +19,10 @@
19
19
  *
20
20
  * A read that never answers is bounded by the fetch's own deadline (wrun-deadline.util
21
21
  * `WRUN_SOURCE_FETCH_DEADLINE_MS`, 45 s from its send) and by the transport's watchdog: it then fails, leaves this
22
- * registry, and the next rung asks the wire. The degrade budget is a paint deadline, never a stall verdict: those two
23
- * are. A read is taken once (a run that joined it notes it again if its own budget runs out first), a failed read and
22
+ * registry, and the next rung asks the wire. A read whose gate socket stops delivering is asked again by the
23
+ * transport itself, on a fresh socket, before any budget here runs out (the worker's gate reader stall watch,
24
+ * reader-stall-watch.worker.util), so a joined read is never one left on a dead socket. The degrade budget is a paint
25
+ * deadline, never a stall verdict: those are the transport's. A read is taken once (a run that joined it notes it again if its own budget runs out first), a failed read and
24
26
  * an answered one past `WRUN_LATE_READ_ADOPT_MS` are dropped, and every read of an overlay goes with it (teardown,
25
27
  * suspend: `forgetWrunLateReads`). Pure module state: nothing here reads the host env.
26
28
  */
@@ -19,8 +19,10 @@
19
19
  *
20
20
  * A read that never answers is bounded by the fetch's own deadline (wrun-deadline.util
21
21
  * `WRUN_SOURCE_FETCH_DEADLINE_MS`, 45 s from its send) and by the transport's watchdog: it then fails, leaves this
22
- * registry, and the next rung asks the wire. The degrade budget is a paint deadline, never a stall verdict: those two
23
- * are. A read is taken once (a run that joined it notes it again if its own budget runs out first), a failed read and
22
+ * registry, and the next rung asks the wire. A read whose gate socket stops delivering is asked again by the
23
+ * transport itself, on a fresh socket, before any budget here runs out (the worker's gate reader stall watch,
24
+ * reader-stall-watch.worker.util), so a joined read is never one left on a dead socket. The degrade budget is a paint
25
+ * deadline, never a stall verdict: those are the transport's. A read is taken once (a run that joined it notes it again if its own budget runs out first), a failed read and
24
26
  * an answered one past `WRUN_LATE_READ_ADOPT_MS` are dropped, and every read of an overlay goes with it (teardown,
25
27
  * suspend: `forgetWrunLateReads`). Pure module state: nothing here reads the host env.
26
28
  */
@@ -11,8 +11,9 @@
11
11
  *
12
12
  * The rule (`serveWrunOwnCandles`), judged before the ask leaves:
13
13
  * - the ask: the candle lane (`ohlcv`), naming no other market (no payload extras but the chart's own exchange and
14
- * symbol), at the chart's interval (no interval option, or the chart's), never a replay run's (its window reaches
15
- * the replay's forward runway, past the rows the chart shows);
14
+ * symbol, and the `candleSource` the chart's rows came from when they came from another market: a US stock Trades
15
+ * chart's tape), at the chart's interval (no interval option, or the chart's), never a replay run's (its window
16
+ * reaches the replay's forward runway, past the rows the chart shows);
16
17
  * - the window `[fromTs, toTs]` (the end an inclusive bar, as the chart's fetch reads it) held whole by the chart's
17
18
  * bars (`held`: the chart's rows, copied, so the lane's buffer never shares the forming bar the live feed rewrites);
18
19
  * anything else is null and the wire answers the window whole, exactly as before: a window opening before the
@@ -28,7 +29,8 @@
28
29
  export interface WrunOwnCandlesAsk {
29
30
  /** The fetch type of the ask (`ohlcv` is the candle lane). */
30
31
  type: string;
31
- /** The payload extras of the ask beyond the current-market placeholders (a pinned market's exchange and symbol). */
32
+ /** The payload extras of the ask beyond the current-market placeholders (a pinned market's exchange and symbol, the
33
+ * `candleSource` its rows are read from). */
32
34
  payloadExtras?: Readonly<Record<string, unknown>>;
33
35
  /** The interval the ask rides (undefined: the chart's own). */
34
36
  interval?: string;
@@ -52,5 +54,24 @@ export type WrunOwnCandlesServe = {
52
54
  kind: 'held';
53
55
  rows: number[][];
54
56
  } | null;
57
+ /** A chart as the host's candle-source reader reads it: its metadata object, whose other fields the host may read. */
58
+ export type WrunMainCandleChart = {
59
+ exchange?: unknown;
60
+ symbol?: unknown;
61
+ };
62
+ /** The market a chart's main series is read from when it is not the chart's own (web: a US stock chart's tape). */
63
+ export type WrunMainCandleSourceReader = (chart: WrunMainCandleChart) => {
64
+ exchange: string;
65
+ symbol: string;
66
+ } | null;
67
+ /** The host's reader, one per realm (null removes it): without one every chart's rows are its own market's. */
68
+ export declare function registerWrunMainCandleSource(reader: WrunMainCandleSourceReader | null): void;
69
+ /** The market a chart's own rows came from when it is another than the chart's; undefined when the reader threw. */
70
+ export declare function wrunMainCandleSourceOf(chart: WrunMainCandleChart | null | undefined): {
71
+ exchange: string;
72
+ symbol: string;
73
+ } | null | undefined;
74
+ /** The venue a script wall judges for the chart's own candles: the market its rows came from, else its exchange. */
75
+ export declare function wrunChartCandleVenue(chart: WrunMainCandleChart | null | undefined): unknown;
55
76
  /** The chart's own candles for an ask of the chart's series at its interval (the module note), or null. */
56
77
  export declare function serveWrunOwnCandles(ask: WrunOwnCandlesAsk): WrunOwnCandlesServe;
@@ -11,8 +11,9 @@
11
11
  *
12
12
  * The rule (`serveWrunOwnCandles`), judged before the ask leaves:
13
13
  * - the ask: the candle lane (`ohlcv`), naming no other market (no payload extras but the chart's own exchange and
14
- * symbol), at the chart's interval (no interval option, or the chart's), never a replay run's (its window reaches
15
- * the replay's forward runway, past the rows the chart shows);
14
+ * symbol, and the `candleSource` the chart's rows came from when they came from another market: a US stock Trades
15
+ * chart's tape), at the chart's interval (no interval option, or the chart's), never a replay run's (its window
16
+ * reaches the replay's forward runway, past the rows the chart shows);
16
17
  * - the window `[fromTs, toTs]` (the end an inclusive bar, as the chart's fetch reads it) held whole by the chart's
17
18
  * bars (`held`: the chart's rows, copied, so the lane's buffer never shares the forming bar the live feed rewrites);
18
19
  * anything else is null and the wire answers the window whole, exactly as before: a window opening before the
@@ -25,21 +26,54 @@
25
26
  * lane of a run asks through). The call-site census (tests/utility/wrun/run-schedule/wrun-own-candles.census.spec.ts)
26
27
  * fails a new source fetch door in the package that this rule does not stand in front of.
27
28
  */
28
- /** Whether an ask names the chart's own market: no market extras, or exactly the chart's exchange and symbol. */
29
- function asksChartMarket(ask) {
30
- const extras = ask.payloadExtras;
31
- if (extras === undefined)
32
- return true;
33
- for (const [key, value] of Object.entries(extras)) {
29
+ let mainCandleSourceReader = null;
30
+ /** The host's reader, one per realm (null removes it): without one every chart's rows are its own market's. */
31
+ export function registerWrunMainCandleSource(reader) {
32
+ mainCandleSourceReader = reader;
33
+ }
34
+ /** The market a chart's own rows came from when it is another than the chart's; undefined when the reader threw. */
35
+ export function wrunMainCandleSourceOf(chart) {
36
+ if (mainCandleSourceReader === null || !chart)
37
+ return null;
38
+ try {
39
+ return mainCandleSourceReader(chart);
40
+ }
41
+ catch {
42
+ return undefined;
43
+ }
44
+ }
45
+ /** The venue a script wall judges for the chart's own candles: the market its rows came from, else its exchange. */
46
+ export function wrunChartCandleVenue(chart) {
47
+ return wrunMainCandleSourceOf(chart)?.exchange ?? chart?.exchange;
48
+ }
49
+ /** The candle source an ask's extras name (`candleSource`, the market its rows are read from), else null. */
50
+ function askedCandleSource(value) {
51
+ if (typeof value !== 'object' || value === null)
52
+ return null;
53
+ const { exchange, symbol } = value;
54
+ return typeof exchange === 'string' && typeof symbol === 'string' ? { exchange, symbol } : null;
55
+ }
56
+ /** Whether an ask names the chart's own series read where its rows came from (`rowsSource`, null: the chart's own). */
57
+ function asksRowsMarket(ask, rowsSource) {
58
+ let source = null;
59
+ for (const [key, value] of Object.entries(ask.payloadExtras ?? {})) {
34
60
  if (value === undefined)
35
61
  continue;
36
62
  if (key === 'exchange' && value === ask.chart.exchange)
37
63
  continue;
38
64
  if (key === 'symbol' && value === ask.chart.symbol)
39
65
  continue;
66
+ if (key === 'candleSource') {
67
+ source = askedCandleSource(value);
68
+ if (source !== null)
69
+ continue;
70
+ }
40
71
  return false;
41
72
  }
42
- return true;
73
+ // An ask naming no source wants the chart's own market's bars: tape rows are never served for it, nor the reverse.
74
+ return source === null
75
+ ? rowsSource === null
76
+ : rowsSource !== null && source.exchange === rowsSource.exchange && source.symbol === rowsSource.symbol;
43
77
  }
44
78
  /** The chart's own candles for an ask of the chart's series at its interval (the module note), or null. */
45
79
  export function serveWrunOwnCandles(ask) {
@@ -47,7 +81,9 @@ export function serveWrunOwnCandles(ask) {
47
81
  return null;
48
82
  if (ask.interval !== undefined && ask.interval !== ask.chart.interval)
49
83
  return null;
50
- if (!asksChartMarket(ask))
84
+ // A reader that threw reads unknown, so the wire answers; else the ask must name the market the rows came from.
85
+ const rowsSource = wrunMainCandleSourceOf(ask.chart);
86
+ if (rowsSource === undefined || !asksRowsMarket(ask, rowsSource))
51
87
  return null;
52
88
  const { rows, intervalMs } = ask.chart;
53
89
  if (rows.length === 0 || !(intervalMs > 0) || !(ask.toTs >= ask.fromTs))
@@ -42,9 +42,12 @@ export const WRUN_OPTION_DAILY_LOOKBACK_DAYS = 7;
42
42
  * resolves afresh (a rolled lead, a listing that changed). */
43
43
  const statsCharts = new WeakMap();
44
44
  /** The chart the statistics lanes decide their chain over: on the OPRA plane the plane's own chain by coin (no chain
45
- * directory read: `wrunLaneOpraPlaneChain`), off it the chart's chain as the one resolver resolves it. */
45
+ * directory read: `wrunLaneOpraPlaneChain`), off it the chart's chain as the one resolver resolves it. Both lanes
46
+ * decide through decideWrunLaneChain, so the crypto venue listing waits for a crypto venue word. */
46
47
  function resolveStatsChart(ctx) {
47
- return resolveWrunLaneChainChart(ctx, ctx.opraPlane === true ? wrunLaneOpraPlaneChain(ctx.coin) : undefined);
48
+ return resolveWrunLaneChainChart(ctx, ctx.opraPlane === true ? wrunLaneOpraPlaneChain(ctx.coin) : undefined, {
49
+ cryptoListingOnDemand: true,
50
+ });
48
51
  }
49
52
  function statsChartOf(ctx) {
50
53
  const scope = ctx.runScope;
@@ -216,9 +216,12 @@ function printsKnobs(source, ctx, scope) {
216
216
  * input of one run reads one resolution (one chain, one `auto` book), and the next run resolves afresh. */
217
217
  const flowCharts = new WeakMap();
218
218
  /** The chart the lane decides its chain over: on the OPRA plane the plane's own chain by coin (no chain directory
219
- * read: `wrunLaneOpraPlaneChain`), off it the chart's chain as the one resolver resolves it. */
219
+ * read: `wrunLaneOpraPlaneChain`), off it the chart's chain as the one resolver resolves it. The lane decides through
220
+ * decideWrunLaneChain, so the crypto venue listing waits for a crypto venue word (`cryptoListingOnDemand`). */
220
221
  function flowChartOf(ctx) {
221
- const resolve = () => resolveWrunLaneChainChart(ctx, ctx.opraPlane === true ? wrunLaneOpraPlaneChain(ctx.coin) : undefined);
222
+ const resolve = () => resolveWrunLaneChainChart(ctx, ctx.opraPlane === true ? wrunLaneOpraPlaneChain(ctx.coin) : undefined, {
223
+ cryptoListingOnDemand: true,
224
+ });
222
225
  const scope = ctx.runScope;
223
226
  if (scope === undefined)
224
227
  return resolve();
@@ -3,7 +3,7 @@ import { type WrunPollLaneContext } from './wrun-poll-lane.types.js';
3
3
  import { wrunLaneChainPlaneOf, type WrunLaneChainPlane } from './wrun-row-lane.types.js';
4
4
  import { type WrunOptionsChainCryptoVenues, type WrunOptionsChainDecision, type WrunOptionsChainRefusal, type WrunOptionsChartSource } from '../wrun-options-chain.util.js';
5
5
  import { type WrunRefusalSeed } from '../wrun-refusal.util.js';
6
- import type { OpraOptionPlaneStop } from '../../../host-ports.types.js';
6
+ import type { OpraOptionPlaneStop, WrunChartOptionsMarket } from '../../../host-ports.types.js';
7
7
  type LaneCtx = Pick<WrunPollLaneContext, 'inputName' | 'sourceClass' | 'coin' | 'exchange' | 'symbol'>;
8
8
  /** The chart market a lane resolves its chain for, keyed (one resolution per chart per run). */
9
9
  export declare function wrunLaneChartKey(ctx: Pick<WrunPollLaneContext, 'exchange' | 'symbol' | 'coin'>): string;
@@ -20,6 +20,13 @@ export interface WrunLaneChartChain {
20
20
  * directory read was sent (its reader dials nothing until the take-back, so the read would wait out its budget),
21
21
  * and every chain decision over the chart stops with `session-elsewhere` on that plane. */
22
22
  heldElsewhere?: GateProvider;
23
+ /** The chain is a stock twin's stock chain (the options seam read the chart's US stock while the `opra` flag is lit):
24
+ * the chart market it stands in for. The chart trades on a crypto or HIP-3 venue, so its crypto venue words still
25
+ * read their venues' chains of the coin (`resolveWrunLaneCryptoVenues`). */
26
+ stockTwinOf?: {
27
+ exchange: string;
28
+ symbol: string;
29
+ };
23
30
  }
24
31
  /** The chart's metadata as the chain resolution reads it: its market and category (pb-common `Category`). */
25
32
  export interface WrunChainChartMetadata {
@@ -28,24 +35,46 @@ export interface WrunChainChartMetadata {
28
35
  coin?: unknown;
29
36
  category?: unknown;
30
37
  }
38
+ /** A run's one options decision as the chain resolution reads it (derived-roots.util `decideWrunRunOptionsMarket`, or
39
+ * a chain lane's context, `optionsDecision`): the market whose options the chart reads, the gate plane they ride, and
40
+ * off every plane the known stop. */
41
+ export interface WrunChartChainDecision {
42
+ market: WrunChartOptionsMarket;
43
+ plane: GateProvider | null;
44
+ opraStop?: OpraOptionPlaneStop;
45
+ }
31
46
  /**
32
47
  * Resolve the chart's chain (lazy imports: the resolver reaches the chain directory service): the ONE resolution every
33
48
  * chain class reads, the options chain lane's (over the chart's own metadata) and each row lane's
34
- * (`resolveWrunLaneChartChain`, over its context's market and category). The chart's options controls' resolver
35
- * (`resolveOptionsChartSource`: an option contract chart on a crypto venue reads its own contract's chain), and a chain
36
- * directory's own failure on a chart its plane governs (a CME futures chart, a chart on the OPRA plane) as that plane's
37
- * evidence; any other resolver failure fails the run. Off every plane, the chart's stop reason rides along
38
- * (`opraStop`, opra-options-gate.util `opraOptionPlaneStop`: the `opra` flag dark, an index chart), so every chain
39
- * decision over the chart says why it reads no US chain. On a plane another screen holds the session of, nothing is
40
- * read (`heldElsewhere`): the chain stops by that name at once.
49
+ * (`resolveWrunLaneChartChain`, over its context's market and category). First the swap: the market whose options the
50
+ * chart reads, `decision.market` when the caller holds the run's one decision (derived-roots.util
51
+ * `decideWrunRunOptionsMarket`), else the options seam now (the gate port's `chartOptionsMarket`): a stock twin's US
52
+ * stock while the `opra` flag is lit (its chain is the stock's OPRA chain, read exactly as a stock chart's, and names
53
+ * the twin, `stockTwinOf`), the chart's own market otherwise (its metadata read as before, its category included). The
54
+ * chart's options controls' resolver (`resolveOptionsChartSource`: an option contract chart on a crypto venue reads its
55
+ * own contract's chain), and a chain directory's own failure on a chart its plane governs (a CME futures chart, a chart
56
+ * on the OPRA plane) as that plane's evidence; any other resolver failure fails the run. Off every plane, the chart's
57
+ * stop reason rides along (`opraStop`, opra-options-gate.util `opraOptionPlaneStop`: the `opra` flag dark, an index
58
+ * chart), so every chain decision over the chart says why it reads no US chain. On a plane another screen holds the
59
+ * session of, nothing is read (`heldElsewhere`): the chain stops by that name at once. With a decision the plane and
60
+ * the stop are the decision's, frozen when the run's head took it, and the resolver is handed that plane (a twin
61
+ * answer or a flag landing since never moves the run's chain onto another plane); without one each is read now, over
62
+ * the market (exchange and symbol), never the venue alone.
41
63
  */
42
- export declare function resolveWrunChartChain(metadata: WrunChainChartMetadata | undefined): Promise<WrunLaneChartChain>;
43
- /** Resolve the chart's chain for a lane: `resolveWrunChartChain` over the lane context's market and category. */
44
- export declare function resolveWrunLaneChartChain(ctx: Pick<WrunPollLaneContext, 'exchange' | 'symbol' | 'coin' | 'category'>): Promise<WrunLaneChartChain>;
64
+ export declare function resolveWrunChartChain(metadata: WrunChainChartMetadata | undefined, decision?: WrunChartChainDecision): Promise<WrunLaneChartChain>;
65
+ /** Resolve the chart's chain for a lane: `resolveWrunChartChain` over the lane context's market and category. In a
66
+ * run's plan the context IS the run's one options market (the planner swapped a stock twin's chain lanes onto its
67
+ * stock, derived-roots.util `wrunUnderlyingLaneContext`) and carries the run's decision (`optionsDecision`): the chain
68
+ * resolves under that decision's plane, never the seam's or the flag's of now. Outside a plan (no decision) both are
69
+ * read now. */
70
+ export declare function resolveWrunLaneChartChain(ctx: Pick<WrunPollLaneContext, 'exchange' | 'symbol' | 'coin' | 'category' | 'stockTwinOf' | 'optionsDecision'>): Promise<WrunLaneChartChain>;
45
71
  /** The crypto venue words a chain decision reads on this chart: on the OPRA plane no crypto venue lists a US
46
- * stock's options (the words refuse by the flag alone, no listing asked); anywhere else the run's own resolver
47
- * over every crypto word (the listing is asked once per coin, and only with the crypto-options gate on). */
48
- export declare function resolveWrunLaneCryptoVenues(chain: WrunLaneChartChain, chartCoin: string): Promise<WrunOptionsChainCryptoVenues>;
72
+ * stock's options (the words refuse by the flag alone, no listing asked), unless the chain is a stock twin's
73
+ * (`stockTwinOf`: the chart trades on a crypto venue, and a word naming one reads that venue's chain of the coin, so a
74
+ * script pinning `bybit` keeps Bybit's); anywhere else the run's own resolver over the crypto words among `venues`
75
+ * (every crypto word when absent; the listing is asked once per coin, and only for a crypto word with the
76
+ * crypto-options gate on: `[]` reads the gate and the coin alone). */
77
+ export declare function resolveWrunLaneCryptoVenues(chain: WrunLaneChartChain, chartCoin: string, venues?: readonly unknown[]): Promise<WrunOptionsChainCryptoVenues>;
49
78
  export { wrunLaneChainPlaneOf, type WrunLaneChainPlane };
50
79
  /** The `book` knob's default word: the series named after the chain's coin, else the first series in series order,
51
80
  * resolved to that one series when the run plans (`decideWrunLaneChain`), never per answer. */
@@ -89,6 +118,9 @@ export type WrunLaneChainOfBook = Omit<WrunLaneChain, 'book'>;
89
118
  export interface WrunLaneChainChart {
90
119
  chain: WrunLaneChartChain;
91
120
  cryptoVenues: WrunOptionsChainCryptoVenues;
121
+ /** A chart resolved with its listing on demand (`WrunLaneChainChartOptions`): the listing, asked once, when a
122
+ * decision first names a crypto venue word (`decideWrunLaneChain`); `cryptoVenues` holds the gate and the coin. */
123
+ cryptoVenuesOnDemand?: () => Promise<WrunOptionsChainCryptoVenues>;
92
124
  deribitListed: (coin: string) => boolean;
93
125
  /** The exchange a plain venue word's chain lists on (the venue table's first exchange of its row). */
94
126
  venueExchange: (word: string) => string | undefined;
@@ -101,6 +133,16 @@ export interface WrunLaneChainChart {
101
133
  /** The book `auto` reads on a decided chain (`resolveWrunLaneChainAutoBook`), asked once per chain per run. */
102
134
  autoBook: (chain: WrunLaneChainOfBook) => Promise<string>;
103
135
  }
136
+ /** How a chart is resolved for a lane (`resolveWrunLaneChainChart`). */
137
+ export interface WrunLaneChainChartOptions {
138
+ /**
139
+ * Ask the crypto venue listing only when an input's venue word names a crypto venue (`decideWrunLaneChain` asks it),
140
+ * so an `auto`, `cme` or `deribit` decision reads none: a CME chain asks no listing before its read. For a lane that
141
+ * decides every input through `decideWrunLaneChain`: the synchronous `decideWrunLaneChainIdentity` cannot ask, and
142
+ * refuses a crypto word over such a chart. Absent: every crypto word's listing, asked when the chart resolves.
143
+ */
144
+ cryptoListingOnDemand?: boolean;
145
+ }
104
146
  /**
105
147
  * The book `auto` reads on a decided chain (D11), resolved when the run plans, from the chain's own listing and never
106
148
  * from the rows an answer holds, so every ask of one instance (each tier segment, the coarser tier's fallback, each
@@ -129,9 +171,9 @@ export declare const WRUN_OPTION_CHART_UNRESOLVED_CODE = "wrun_option_chart_unre
129
171
  * words (`resolveWrunLaneCryptoVenues`), for a CME chain on a continuous alias the contract leading it now
130
172
  * (option-chain.service `resolveChainContract`, the roll rule the terminal identity admits the alias by; MES1!'s as
131
173
  * MESF's contract), and each decided chain's default book (`resolveWrunLaneChainAutoBook`, asked once per chain for
132
- * this chart).
174
+ * this chart). The crypto venue listing is asked here for every crypto word, or on demand (`options`).
133
175
  */
134
- export declare function resolveWrunLaneChainChart(ctx: Pick<WrunPollLaneContext, 'exchange' | 'symbol' | 'coin' | 'category'>, held?: WrunLaneChartChain): Promise<WrunLaneChainChart>;
176
+ export declare function resolveWrunLaneChainChart(ctx: Pick<WrunPollLaneContext, 'exchange' | 'symbol' | 'coin' | 'category' | 'stockTwinOf' | 'optionsDecision'>, held?: WrunLaneChartChain, options?: WrunLaneChainChartOptions): Promise<WrunLaneChainChart>;
135
177
  /**
136
178
  * The chart's chain on the OPRA plane, read off the plane itself: OPRA's chain of the chart's own underlying (its coin,
137
179
  * upper case: a stock or ETF chart's ticker, an OPRA contract chart's underlying), on the plane's one exchange (the
@@ -141,7 +183,10 @@ export declare function resolveWrunLaneChainChart(ctx: Pick<WrunPollLaneContext,
141
183
  * failing, refuses nothing before the read (an empty answer, and the empty-answer rule speaks). The venue and book words
142
184
  * are still decided over it (`decideWrunLaneChain`), with no read either.
143
185
  */
144
- export declare function wrunLaneOpraPlaneChain(coin: string): WrunLaneChartChain;
186
+ export declare function wrunLaneOpraPlaneChain(coin: string, stockTwinOf?: {
187
+ exchange: string;
188
+ symbol: string;
189
+ }): WrunLaneChartChain;
145
190
  /** Who a venue decision is for: the input, the chart market (and the label a refusal names it by, `EXCHANGE/SYMBOL`
146
191
  * by default) and the run's OPRA facts. */
147
192
  export interface WrunLaneChainDecider {
@@ -160,7 +205,7 @@ export interface WrunLaneChainDecider {
160
205
  * chain, else the first venue whose listing names the coin; a pinned word that venue's chain; the `crypto-options`
161
206
  * flag, the listing, the directory and the OPRA wall by name). A refusal comes back as the decision's own.
162
207
  */
163
- export declare function decideWrunLaneChainIdentity(chart: Pick<WrunLaneChainChart, 'chain' | 'cryptoVenues' | 'deribitListed'>, venue: unknown, who: WrunLaneChainDecider): WrunOptionsChainDecision;
208
+ export declare function decideWrunLaneChainIdentity(chart: Pick<WrunLaneChainChart, 'chain' | 'cryptoVenues' | 'deribitListed' | 'cryptoVenuesOnDemand'>, venue: unknown, who: WrunLaneChainDecider): WrunOptionsChainDecision;
164
209
  /** The input's `book`, validated: `auto` (absent too) or one series name upper case, else a refusal by name
165
210
  * (`wrun_option_knob_invalid`, om's one name for an options knob outside its words). */
166
211
  export declare function wrunLaneChainBook(value: unknown, ctx: {
@@ -175,7 +220,7 @@ export declare function wrunLaneChainBook(value: unknown, ctx: {
175
220
  * exchange, the underlying the plane files the series under (a CME continuous alias read as the contract leading it
176
221
  * now), the coin and the book. Refuses by name with the options chain's own reasons and seeds (a coin no venue lists:
177
222
  * `no-chain`), a continuous CME chart whose lead cannot be resolved (`cme-unresolved`, Retry), and a book outside its
178
- * words.
223
+ * words. A crypto word over a chart whose listing is asked on demand asks it here, once per chart.
179
224
  */
180
225
  export declare function decideWrunLaneChain(chart: WrunLaneChainChart, knobs: {
181
226
  venue?: unknown;