@orangecharts/wrun-chart-host 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/README.md +3 -1
  2. package/dist/constants/feature-flags.constants.d.ts +9 -0
  3. package/dist/constants/feature-flags.constants.js +86 -16
  4. package/dist/constants/marketCapabilities.constants.d.ts +14 -9
  5. package/dist/constants/marketCapabilities.constants.js +36 -13
  6. package/dist/constants/opra-compliance.constants.d.ts +15 -0
  7. package/dist/constants/opra-compliance.constants.js +15 -0
  8. package/dist/constants/option-venues.constants.d.ts +11 -6
  9. package/dist/constants/option-venues.constants.js +5 -2
  10. package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +26 -0
  11. package/dist/constants/scriptEditor/builtin-script-snippets.js +6 -0
  12. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +15 -0
  13. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +17 -0
  14. package/dist/constants/venue-presets.constants.d.ts +20 -20
  15. package/dist/constants/venue-presets.constants.js +24 -26
  16. package/dist/host-env.d.ts +39 -9
  17. package/dist/host-env.js +6 -0
  18. package/dist/host-ports.types.d.ts +108 -18
  19. package/dist/index.d.ts +14 -0
  20. package/dist/index.js +14 -0
  21. package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
  22. package/dist/interfaces/opra-realtime.interface.d.ts +13 -11
  23. package/dist/interfaces/opra-realtime.interface.js +10 -10
  24. package/dist/interfaces/replay.interface.d.ts +8 -0
  25. package/dist/interfaces/wrun-runtime.interface.d.ts +52 -15
  26. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +94 -14
  27. package/dist/kscript-data/controls/live-trades-merge.util.js +132 -22
  28. package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +56 -0
  29. package/dist/kscript-data/controls/live-trades-order-gate.util.js +107 -0
  30. package/dist/market-data/billing.interface.d.ts +227 -42
  31. package/dist/market-data/billing.interface.js +60 -12
  32. package/dist/market-data/venue.d.ts +88 -6
  33. package/dist/market-data/venues/cme.contract.copy.json +66 -0
  34. package/dist/market-data/venues/cme.d.ts +126 -0
  35. package/dist/market-data/venues/cme.js +133 -0
  36. package/dist/market-data/venues/index.d.ts +165 -8
  37. package/dist/market-data/venues/index.js +48 -6
  38. package/dist/market-data/venues/opra.contract.copy.json +5 -3
  39. package/dist/market-data/venues/opra.d.ts +3 -3
  40. package/dist/market-data/venues/opra.js +5 -4
  41. package/dist/replay/replayLadder.js +3 -1
  42. package/dist/settings-templates/index.js +7 -3
  43. package/dist/settings-templates/indicator-fields.d.ts +5 -4
  44. package/dist/settings-templates/indicator-fields.js +45 -6
  45. package/dist/settings-templates/tool-rules.d.ts +27 -17
  46. package/dist/settings-templates/tool-rules.js +27 -11
  47. package/dist/settings-templates/tool-tables.generated.js +91 -31
  48. package/dist/utility/chart/book-live-bucket.util.d.ts +15 -0
  49. package/dist/utility/chart/book-live-bucket.util.js +47 -0
  50. package/dist/utility/chart/crypto-index.leaf.d.ts +2 -2
  51. package/dist/utility/chart/crypto-index.leaf.js +2 -2
  52. package/dist/utility/chart/index-mode-admission.util.js +24 -3
  53. package/dist/utility/chart/index-mode.util.d.ts +5 -2
  54. package/dist/utility/chart/index-mode.util.js +23 -13
  55. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +35 -11
  56. package/dist/utility/chart/kscript-drawing-safe-area.util.js +145 -35
  57. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +7 -2
  58. package/dist/utility/chart/kscript-live-coalesce.util.js +9 -3
  59. package/dist/utility/chart/kscript-provenance-keys.util.js +6 -0
  60. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
  61. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +32 -2
  62. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +45 -0
  63. package/dist/utility/chart/kscript-venue-policy.util.d.ts +53 -27
  64. package/dist/utility/chart/kscript-venue-policy.util.js +74 -32
  65. package/dist/utility/chart/market-session-schedule.util.d.ts +10 -0
  66. package/dist/utility/chart/market-session-schedule.util.js +16 -0
  67. package/dist/utility/chart/marketKind.util.d.ts +12 -10
  68. package/dist/utility/chart/marketKind.util.js +17 -7
  69. package/dist/utility/chart/om-panel-push-style.util.d.ts +7 -7
  70. package/dist/utility/chart/om-panel-push-style.util.js +17 -15
  71. package/dist/utility/chart/om-panel.util.js +6 -6
  72. package/dist/utility/chart/opra-read-access.leaf.d.ts +5 -3
  73. package/dist/utility/chart/opra-read-access.leaf.js +5 -3
  74. package/dist/utility/chart/profile-block-size.util.d.ts +16 -0
  75. package/dist/utility/chart/profile-block-size.util.js +7 -0
  76. package/dist/utility/chart/quote-perp.leaf.d.ts +17 -0
  77. package/dist/utility/chart/quote-perp.leaf.js +20 -0
  78. package/dist/utility/chart/rth-session.util.d.ts +3 -2
  79. package/dist/utility/chart/rth-session.util.js +2 -1
  80. package/dist/utility/chart/window-geometry.leaf.d.ts +8 -0
  81. package/dist/utility/chart/window-geometry.leaf.js +22 -6
  82. package/dist/utility/chart/wrun-run-result.util.d.ts +17 -0
  83. package/dist/utility/chart/wrun-run-result.util.js +145 -7
  84. package/dist/utility/common/transformations.util.d.ts +7 -0
  85. package/dist/utility/common/transformations.util.js +11 -0
  86. package/dist/utility/options/option-bar-anchor.util.d.ts +145 -0
  87. package/dist/utility/options/option-bar-anchor.util.js +340 -0
  88. package/dist/utility/options/option-venue.util.d.ts +21 -3
  89. package/dist/utility/options/option-venue.util.js +30 -3
  90. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
  91. package/dist/utility/wrun/derived-roots.util.d.ts +213 -0
  92. package/dist/utility/wrun/derived-roots.util.js +471 -0
  93. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +41 -6
  94. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +89 -19
  95. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +9 -4
  96. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +47 -6
  97. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +5 -3
  98. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +6 -4
  99. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +2 -2
  100. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +5 -1
  101. package/dist/utility/wrun/sources/lanes/option_daily.js +5 -2
  102. package/dist/utility/wrun/sources/lanes/options_flow.js +5 -2
  103. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +64 -19
  104. package/dist/utility/wrun/sources/opra-option-lanes.util.js +105 -35
  105. package/dist/utility/wrun/sources/row-lane-registry.js +3 -2
  106. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +2 -1
  107. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +9 -3
  108. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +15 -6
  109. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +14 -0
  110. package/dist/utility/wrun/sources/row-lanes/option_prints.js +82 -13
  111. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +17 -4
  112. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +55 -8
  113. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +95 -14
  114. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +5 -2
  115. package/dist/utility/wrun/sources/row-lanes/option_surface.js +7 -3
  116. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -0
  117. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +35 -14
  118. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +70 -20
  119. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +64 -0
  120. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +89 -0
  121. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +45 -1
  122. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +114 -6
  123. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +56 -5
  124. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +224 -26
  125. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +822 -58
  126. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +16 -3
  127. package/dist/utility/wrun/wrun-batched-marks.util.js +30 -19
  128. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +37 -9
  129. package/dist/utility/wrun/wrun-batched-readout.util.js +61 -15
  130. package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +12 -0
  131. package/dist/utility/wrun/wrun-builtin-twin.util.js +21 -0
  132. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -0
  133. package/dist/utility/wrun/wrun-cell-capacity.leaf.d.ts +66 -0
  134. package/dist/utility/wrun/wrun-cell-capacity.leaf.js +86 -0
  135. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +192 -13
  136. package/dist/utility/wrun/wrun-chart-market-facts.util.js +437 -55
  137. package/dist/utility/wrun/wrun-color-facts.util.d.ts +19 -9
  138. package/dist/utility/wrun/wrun-color-facts.util.js +24 -14
  139. package/dist/utility/wrun/wrun-color-settings.util.d.ts +15 -4
  140. package/dist/utility/wrun/wrun-color-settings.util.js +31 -12
  141. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.d.ts +17 -0
  142. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.js +9 -0
  143. package/dist/utility/wrun/wrun-download-meter.util.d.ts +107 -0
  144. package/dist/utility/wrun/wrun-download-meter.util.js +134 -0
  145. package/dist/utility/wrun/wrun-download-plan.util.d.ts +99 -0
  146. package/dist/utility/wrun/wrun-download-plan.util.js +118 -0
  147. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +11 -3
  148. package/dist/utility/wrun/wrun-draft-legend-note.util.js +26 -4
  149. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +6 -1
  150. package/dist/utility/wrun/wrun-draft-overlay.util.js +23 -3
  151. package/dist/utility/wrun/wrun-frames.d.ts +27 -6
  152. package/dist/utility/wrun/wrun-frames.js +78 -15
  153. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
  154. package/dist/utility/wrun/wrun-hosted-wire-caps.js +7 -0
  155. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +7 -1
  156. package/dist/utility/wrun/wrun-hosted-wire.util.js +12 -2
  157. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +51 -21
  158. package/dist/utility/wrun/wrun-hud-looks.util.js +74 -28
  159. package/dist/utility/wrun/wrun-latest-snapshot.d.ts +11 -0
  160. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +8 -6
  161. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +8 -6
  162. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -2
  163. package/dist/utility/wrun/wrun-live-intake.util.d.ts +19 -9
  164. package/dist/utility/wrun/wrun-live-intake.util.js +213 -45
  165. package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -0
  166. package/dist/utility/wrun/wrun-live-tick.util.js +246 -49
  167. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.d.ts +53 -0
  168. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.js +162 -0
  169. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +205 -48
  170. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +277 -34
  171. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +51 -7
  172. package/dist/utility/wrun/wrun-market-size-defaults.util.js +340 -56
  173. package/dist/utility/wrun/wrun-opra-lane.util.d.ts +17 -4
  174. package/dist/utility/wrun/wrun-opra-lane.util.js +6 -4
  175. package/dist/utility/wrun/wrun-option-prints.util.d.ts +41 -2
  176. package/dist/utility/wrun/wrun-option-prints.util.js +80 -13
  177. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.d.ts +31 -0
  178. package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.js +119 -0
  179. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +26 -6
  180. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +50 -11
  181. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +109 -19
  182. package/dist/utility/wrun/wrun-option-strike-flow.util.js +222 -61
  183. package/dist/utility/wrun/wrun-option-views.util.d.ts +96 -18
  184. package/dist/utility/wrun/wrun-option-views.util.js +246 -51
  185. package/dist/utility/wrun/wrun-options-stop.util.d.ts +2 -1
  186. package/dist/utility/wrun/wrun-options-stop.util.js +3 -2
  187. package/dist/utility/wrun/wrun-output-style.util.d.ts +6 -2
  188. package/dist/utility/wrun/wrun-output-style.util.js +20 -2
  189. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +20 -0
  190. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +31 -14
  191. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +22 -0
  192. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +10 -1
  193. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +52 -4
  194. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +7 -0
  195. package/dist/utility/wrun/wrun-overlay-recovery.util.js +25 -1
  196. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +7 -1
  197. package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
  198. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +134 -37
  199. package/dist/utility/wrun/wrun-overlay-run.util.js +1118 -254
  200. package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +4 -4
  201. package/dist/utility/wrun/wrun-pack-widths.leaf.js +4 -4
  202. package/dist/utility/wrun/wrun-pack.util.d.ts +7 -3
  203. package/dist/utility/wrun/wrun-pack.util.js +20 -9
  204. package/dist/utility/wrun/wrun-pane-format.util.d.ts +2 -1
  205. package/dist/utility/wrun/wrun-pane-format.util.js +7 -3
  206. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +9 -0
  207. package/dist/utility/wrun/wrun-panel-mount.util.js +63 -13
  208. package/dist/utility/wrun/wrun-panel-style.util.d.ts +37 -24
  209. package/dist/utility/wrun/wrun-panel-style.util.js +100 -29
  210. package/dist/utility/wrun/wrun-param-map.util.d.ts +15 -11
  211. package/dist/utility/wrun/wrun-param-map.util.js +13 -5
  212. package/dist/utility/wrun/wrun-param-values.util.d.ts +21 -3
  213. package/dist/utility/wrun/wrun-param-values.util.js +6 -0
  214. package/dist/utility/wrun/wrun-pin-spelling.util.js +12 -11
  215. package/dist/utility/wrun/wrun-prefix-lanes.util.js +2 -2
  216. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +50 -0
  217. package/dist/utility/wrun/wrun-refusal-surface.util.js +68 -0
  218. package/dist/utility/wrun/wrun-refusal.util.js +10 -1
  219. package/dist/utility/wrun/wrun-refused-latest.util.d.ts +10 -0
  220. package/dist/utility/wrun/wrun-refused-latest.util.js +12 -0
  221. package/dist/utility/wrun/wrun-row-source.d.ts +11 -0
  222. package/dist/utility/wrun/wrun-run-interval.util.d.ts +4 -2
  223. package/dist/utility/wrun/wrun-run-interval.util.js +9 -6
  224. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +52 -1
  225. package/dist/utility/wrun/wrun-script-inputs.util.js +112 -4
  226. package/dist/utility/wrun/wrun-setting-words.util.d.ts +7 -3
  227. package/dist/utility/wrun/wrun-setting-words.util.js +13 -5
  228. package/dist/utility/wrun/wrun-socket-row-source.d.ts +27 -2
  229. package/dist/utility/wrun/wrun-socket-row-source.js +113 -8
  230. package/dist/utility/wrun/wrun-source-rows.util.d.ts +9 -1
  231. package/dist/utility/wrun/wrun-source-rows.util.js +108 -43
  232. package/dist/utility/wrun/wrun-style-words.util.js +6 -4
  233. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +3 -2
  234. package/dist/utility/wrun/wrun-table-chrome.util.js +19 -11
  235. package/dist/utility/wrun/wrun-tape-per-order.util.d.ts +2 -0
  236. package/dist/utility/wrun/wrun-tape-per-order.util.js +26 -0
  237. package/dist/utility/wrun/wrun-tape-source.util.d.ts +126 -50
  238. package/dist/utility/wrun/wrun-tape-source.util.js +193 -68
  239. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +7 -5
  240. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +8 -6
  241. package/dist/utils/replay/replay-buffer-math.d.ts +53 -2
  242. package/dist/utils/replay/replay-buffer-math.js +227 -20
  243. package/dist/workers/utils/volume-profile.worker.util.d.ts +4 -1
  244. package/dist/workers/utils/volume-profile.worker.util.js +5 -2
  245. package/dist/workers/wrun/wrun-abi-host.js +3 -2
  246. package/package.json +5 -5
@@ -1,6 +1,9 @@
1
+ import { wrunUnderlyingLaneContext } from '../derived-roots.util.js';
1
2
  import { wrunParamChoices } from '../wrun-color-settings.util.js';
3
+ import { isWrunOptionsChainCryptoVenueWord } from '../wrun-options-chain.util.js';
2
4
  import { refuseWrunOptionKnob } from '../wrun-option-knobs.util.js';
3
5
  import { wrunOptionPrintKnobWords } from '../wrun-option-prints.util.js';
6
+ import { WRUN_OPTION_STRIKE_FLOW_CLASS, WRUN_OPTION_STRIKE_FLOW_EXPIRIES_WORDS, wrunOptionStrikeFlowExpiriesOf, } from '../wrun-option-strike-flow-lane.util.js';
4
7
  import { wrunMultiLabels } from '../wrun-param-values.util.js';
5
8
  import { wrunOptionsStopSeed, wrunRefusalSeedOf } from '../wrun-refusal.util.js';
6
9
  import { wrunPollLaneByKey, wrunPollLaneGlobalClasses, wrunPollLanes, wrunPollLanesOfClass } from './registry.js';
@@ -90,7 +93,7 @@ function wrunPollLaneServedOnIndexMode(lane) {
90
93
  return lane.global === true || lane.nativeRows === true;
91
94
  }
92
95
  /**
93
- * The option knobs a setting may stand for, by source class, with the kind each takes (om kit 0.89.0
96
+ * The option knobs a setting may stand for, by source class, with the kind each takes (om kit 0.96.0
94
97
  * `WRUN_OPTION_PARAM_KNOBS`, row for row): ONE table for both planners, read before a poll lane's `plan` and a row lane's
95
98
  * `facets` (`resolveWrunOptionSettingKnobs`), so no lane reads a setting itself. The sheet records the setting's NAME in
96
99
  * the knob (an author's `min_premium: "@floor"` compiles to `"floor"`), and every host reads that setting's current
@@ -101,7 +104,7 @@ function wrunPollLaneServedOnIndexMode(lane) {
101
104
  export const WRUN_OPTION_SETTING_KNOBS = Object.freeze({
102
105
  options_flow: Object.freeze({ min_premium: 'number', max_dte: 'number' }),
103
106
  option_contract_flow: Object.freeze({ min_premium: 'number' }),
104
- option_strike_flow: Object.freeze({ strike_rows: 'number' }),
107
+ option_strike_flow: Object.freeze({ strike_rows: 'number', expiries: 'word' }),
105
108
  option_prints: Object.freeze({
106
109
  min_premium: 'number',
107
110
  types: 'word',
@@ -113,6 +116,21 @@ export const WRUN_OPTION_SETTING_KNOBS = Object.freeze({
113
116
  });
114
117
  /** The setting types a number knob reads (om `resolveOptionParamKnobs`: a number, int or price setting). */
115
118
  const WRUN_NUMBER_SETTING_TYPES = new Set(['number', 'int', 'price']);
119
+ /** The words a word or list knob takes from a setting (om `wrunOptionKnobWords`): the print classes' `types`,
120
+ * `moneyness` and `sides` (wrun-option-prints.util), and option_strike_flow's `expiries` (the words a setting picks);
121
+ * none for any other knob. */
122
+ export function wrunOptionSettingKnobWords(knob) {
123
+ return knob === 'expiries' ? WRUN_OPTION_STRIKE_FLOW_EXPIRIES_WORDS : wrunOptionPrintKnobWords(knob);
124
+ }
125
+ /** Whether a word knob's value is the knob's own literal, never a setting's name (om `wrunOptionKnobLiteral`): a word
126
+ * the knob takes, and on option_strike_flow's `expiries` any word the class reads ("nearest:N" too, the literal
127
+ * Strike Breakdown declares). A literal is a literal even beside a setting of that name. */
128
+ function wrunOptionKnobLiteral(sourceClass, knob, value) {
129
+ if (knob === 'expiries' && sourceClass === WRUN_OPTION_STRIKE_FLOW_CLASS) {
130
+ return wrunOptionStrikeFlowExpiriesOf(value) !== undefined;
131
+ }
132
+ return wrunOptionSettingKnobWords(knob).includes(value);
133
+ }
116
134
  /** What a knob of each kind takes beside a setting's name, as its refusal spells it. */
117
135
  function wrunSettingKnobLiteralWords(kind, words) {
118
136
  if (kind === 'number')
@@ -122,7 +140,7 @@ function wrunSettingKnobLiteralWords(kind, words) {
122
140
  /** The setting a knob of each kind reads its value from, as its refusal spells it. */
123
141
  const WRUN_SETTING_KNOB_SETTINGS = Object.freeze({
124
142
  number: 'a number, int or price setting',
125
- word: 'a select setting whose picked option is labelled with one of them',
143
+ word: 'a select setting whose picked option is one of them (its style_values word, else its label)',
126
144
  list: 'a multi setting whose picked options are labelled with them',
127
145
  });
128
146
  /** The literal a setting stands for on a knob of `kind` at the run's `value`, or why it stands for none. */
@@ -133,9 +151,13 @@ function wrunSettingKnobLiteral(kind, words, param, value) {
133
151
  if (kind === 'word') {
134
152
  if (type !== 'select')
135
153
  return { why: `is a ${type} setting` };
136
- // THE select read's choices (a select's options, labelled by `option_labels`), the picked one by its value.
137
- const label = wrunParamChoices(param)?.find((choice) => choice.value === value)?.label;
138
- return label !== undefined && words.includes(label) ? { literal: label } : { why: `picks '${label ?? value}'` };
154
+ // THE select read's choices (a select's options, labelled by `option_labels`), the picked one by its value; its
155
+ // word the `style_values` entry at the pick's place when the select declares them (kit 0.96.0: the dialog keeps
156
+ // its own labels), else its label (om `selectWord`).
157
+ const choices = wrunParamChoices(param);
158
+ const at = choices?.findIndex((choice) => choice.value === value) ?? -1;
159
+ const word = at < 0 ? undefined : Array.isArray(param.style_values) ? param.style_values[at] : choices?.[at]?.label;
160
+ return typeof word === 'string' && words.includes(word) ? { literal: word } : { why: `picks '${word ?? value}'` };
139
161
  }
140
162
  if (type !== 'multi')
141
163
  return { why: `is a ${type} setting` };
@@ -150,8 +172,9 @@ function wrunSettingKnobLiteral(kind, words, param, value) {
150
172
  /**
151
173
  * One input's source with every option knob that names a setting read as the setting's current value (om
152
174
  * `resolveOptionParamKnobs`, the SDK host's rule, over the class's row of `WRUN_OPTION_SETTING_KNOBS`): a number knob
153
- * takes a number, int or price setting's number; a word knob (`types`, `moneyness`) the label of a select's picked
154
- * option, one of its words; a list knob (`sides`) the labels of a multi's picked options, in the words' order. The name
175
+ * takes a number, int or price setting's number; a word knob (`types`, `moneyness`, option_strike_flow's `expiries`)
176
+ * the word of a select's picked option, its `style_values` entry when the select declares them, else its label, one of
177
+ * its words; a list knob (`sides`) the labels of a multi's picked options, in the words' order. The name
155
178
  * must be a compute setting of the sheet (a style knob is none) with a value this run read, of the knob's kind and
156
179
  * picking its words, else the input is refused by name (`wrun_option_knob_invalid`). A literal (a number, a list, a word
157
180
  * of the knob's own) is left as it is (its lane judges it), and so is every input when the run read no setting values; a
@@ -168,9 +191,9 @@ export function resolveWrunOptionSettingKnobs(ctx, source, params, values) {
168
191
  const name = source[knob];
169
192
  if (typeof name !== 'string')
170
193
  continue;
171
- const words = wrunOptionPrintKnobWords(knob);
194
+ const words = wrunOptionSettingKnobWords(knob);
172
195
  // A word knob's own word is a literal, never a setting's name.
173
- if (kind === 'word' && words.includes(name))
196
+ if (kind === 'word' && wrunOptionKnobLiteral(ctx.sourceClass, knob, name))
174
197
  continue;
175
198
  const literalWords = wrunSettingKnobLiteralWords(kind, words);
176
199
  const param = params.find((candidate) => candidate.name === name);
@@ -195,14 +218,35 @@ export function wrunOpraPlaneStopDetail(stop) {
195
218
  ? 'is not served for this account yet: the opra flag is off, so no US options data is read on any chart'
196
219
  : 'is not served on this chart: an index chart does not ride the OPRA plane yet, so no US options data is read for it';
197
220
  }
198
- /** The chart's OPRA plane facts, off the predicates the run injects (`isOpraPlaneExchange`: absent, no chart rides
199
- * the plane; `opraPlaneStop`, asked only off the plane). */
200
- export function wrunChartOpraPlane(exchange, facts) {
201
- if (facts?.isOpraPlaneExchange?.(exchange) === true)
221
+ /** The chart's OPRA plane facts, off the predicates the run injects over the chart's market, exchange and symbol
222
+ * (`isOpraPlaneExchange`: absent, no chart rides the plane; `opraPlaneStop`, asked only off the plane). */
223
+ export function wrunChartOpraPlane(chart, facts) {
224
+ if (facts?.isOpraPlaneExchange?.(chart.exchange, chart.symbol) === true)
202
225
  return { onPlane: true };
203
- const stop = facts?.opraPlaneStop?.(exchange);
226
+ const stop = facts?.opraPlaneStop?.(chart.exchange, chart.symbol);
204
227
  return stop !== undefined ? { onPlane: false, stop } : { onPlane: false };
205
228
  }
229
+ /**
230
+ * A chain lane input's context under the run's one options decision (`options`), both planners' one rule: on the chart
231
+ * the decision was taken for, the decision rides along (`optionsDecision`: the plane the input's chain resolves under,
232
+ * never decided again) and a stock twin's lane market stands in place of the chart's (`wrunUnderlyingLaneContext`, the
233
+ * swap an `underlying` root's input reads). A context with no decision, or one of another chart market (a switch since
234
+ * the head: the run is superseded), is left as it is.
235
+ */
236
+ export function wrunChainLaneContext(ctx, options) {
237
+ if (options === undefined)
238
+ return ctx;
239
+ if ((options.chart.exchange ?? '') !== ctx.exchange || (options.chart.symbol ?? '') !== ctx.symbol)
240
+ return ctx;
241
+ const decided = {
242
+ ...ctx,
243
+ optionsDecision: {
244
+ plane: options.plane,
245
+ ...(options.opraStop !== undefined ? { opraStop: options.opraStop } : {}),
246
+ },
247
+ };
248
+ return options.lane === undefined ? decided : wrunUnderlyingLaneContext(decided, options.lane);
249
+ }
206
250
  /** The fills a scalar input reads on every bar of a feed the chart does not serve (`missing: "nan"` or `"zero"`). */
207
251
  const WRUN_POLL_LANE_UNSERVED_FILLS = Object.freeze(['nan', 'zero']);
208
252
  /**
@@ -292,8 +336,11 @@ export function wrunLaneUnservedScopeRefusal(error) {
292
336
  * stop. Undefined: the lane resolves its chain (its instance then meets its own plane's wall,
293
337
  * `assertWrunLaneChainPlaneReadable`).
294
338
  */
295
- export function wrunChainLaneStop(plane, run, ctx) {
296
- if (plane.onPlane || plane.stop !== undefined)
339
+ export function wrunChainLaneStop(plane, run, ctx, venue) {
340
+ // A stock twin's input pinning a crypto venue reads that venue's chain of the coin, never OPRA's: no OPRA wall stands
341
+ // before it (its instance meets its own plane's wall, `assertWrunLaneChainPlaneReadable`).
342
+ const twinCryptoVenue = ctx.stockTwinOf !== undefined && typeof venue === 'string' && isWrunOptionsChainCryptoVenueWord(venue);
343
+ if ((plane.onPlane || plane.stop !== undefined) && !twinCryptoVenue)
297
344
  assertWrunOpraLaneReadable(run, ctx);
298
345
  return plane.stop === undefined ? undefined : { words: wrunOpraPlaneStopDetail(plane.stop), stop: plane.stop };
299
346
  }
@@ -397,7 +444,7 @@ export async function planWrunPollLanes(metadata, chart, isIndexModeExchange = (
397
444
  const category = typeof chart.category === 'number' ? { category: chart.category } : {};
398
445
  // The chart's OPRA plane facts, read once (`wrunChartOpraPlane`, the row lanes' planner reads them the same way):
399
446
  // whether its options ride the plane, and off it the known reason a chart whose options list on OPRA rides none.
400
- const plane = wrunChartOpraPlane(chart.exchange, run);
447
+ const plane = wrunChartOpraPlane(chart, run);
401
448
  // One object per plan: the inputs of this run share a chain lane's resolutions by it.
402
449
  const runScope = {};
403
450
  for (const planned of planWrunPollLaneInputs(metadata)) {
@@ -422,6 +469,9 @@ export async function planWrunPollLanes(metadata, chart, isIndexModeExchange = (
422
469
  : {}),
423
470
  ...(chainLane ? { runScope, opraPlane: plane.onPlane } : {}),
424
471
  };
472
+ // A chain lane reads the run's one options market: a stock twin's stock in place of the chart's
473
+ // (`wrunChainLaneContext`); every other lane, and every chain lane of any other chart, the chart's own context.
474
+ const laneCtx = chainLane ? wrunChainLaneContext(ctx, run?.options) : ctx;
425
475
  const unserved = {
426
476
  inputName: planned.inputName,
427
477
  sourceClass: planned.lane.sourceClass,
@@ -433,7 +483,7 @@ export async function planWrunPollLanes(metadata, chart, isIndexModeExchange = (
433
483
  // served by its own plane and the chart's mode. An input the chart does not serve meets the one rule both planners
434
484
  // keep (`wrunUnservedLaneInput`: a declared fill drops it with a note, any other refuses by name).
435
485
  const why = chainLane
436
- ? wrunChainLaneStop(plane, run, ctx)
486
+ ? wrunChainLaneStop(plane, run, laneCtx, planned.source.venue)
437
487
  : wrunPollLaneUnserved(planned.lane, plane, indexModeChart, run, ctx);
438
488
  if (why !== undefined) {
439
489
  wrunUnservedLaneInput(missing, unserved, WRUN_POLL_LANE_UNSERVED_FILLS, why, cryptoVenue);
@@ -444,7 +494,7 @@ export async function planWrunPollLanes(metadata, chart, isIndexModeExchange = (
444
494
  // An option knob naming a setting reads the setting's current value before the lane judges it (om
445
495
  // `resolveOptionParamKnobs`): the instance's extras carry the value, so a settings change re-plans and re-asks.
446
496
  const source = resolveWrunOptionSettingKnobs(ctx, planned.source, metadata.params ?? [], run?.paramValues);
447
- answered = await planned.lane.plan(source, ctx);
497
+ answered = await planned.lane.plan(source, laneCtx);
448
498
  }
449
499
  catch (error) {
450
500
  // A chart with no option chain does not serve the feed (`wrunLaneNoChainRefusal`), nor one whose options plane
@@ -0,0 +1,64 @@
1
+ /**
2
+ * One download budget per ADD (OPTLOAD W3, after R2 and FE-FOLD-CAP; wrun-row-lanes.util `fetchWrunRowLaneRows`
3
+ * `addMemo`). A budgeted read of one row lane instance of a mounted indicator leaves a memo: the bars it landed whole
4
+ * and final with their rows, the bars its budget cut, and what it downloaded within which share. Every later read of the
5
+ * same add (the run's loaded-range refresh, the live start, each live reconcile) reuses the landed bars, keeps the cut
6
+ * bars partial and asks only the bars the memo does not hold (a new bar at the head, a bar still forming), so the add
7
+ * spends its budget once, not once a read. INT 2026-10-23, Premium by Strike 0.3.0 on ES1! 1h: the refresh run, the
8
+ * live start and a live reconcile each folded the same 3 newest bars again, 1.21 MB a read.
9
+ *
10
+ * Off the boot path: wrun-row-lanes.util loads it only for a read that names an add.
11
+ */
12
+ import type { LiveBucketVenue } from '../../chart/live-bucket.util.js';
13
+ import { type WrunHostGridAsk } from '../wrun-tier-grid.util.js';
14
+ /** A landed bar is final once it ended this long before the read: a delayed route serves a bar's last buckets up to 15
15
+ * minutes after its close, so a bar closer to the clock is asked again by the add's next read. */
16
+ export declare const WRUN_ROW_LANE_FINAL_LAG_MS: number;
17
+ /** What the add's reads of one row lane instance hold (`wrunRowLaneAddMemoAfter`). */
18
+ export interface WrunRowLaneAddMemo {
19
+ /** The lane, its acquisition without any per-ask field, and the bar span: a read printing another reads another add
20
+ * (a setting, the market or the interval moved) and replaces the memo. */
21
+ readonly fingerprint: string;
22
+ /** The bars read whole and final, each with its landed row (undefined: the bar answered nothing, an empty bar). */
23
+ readonly landed: ReadonlyMap<number, ReadonlyArray<unknown> | undefined>;
24
+ /** The bars the add's budget left partial: never asked again by the add. */
25
+ readonly cut: ReadonlySet<number>;
26
+ /** What the add's budgeted reads downloaded, and the share they read within (a later run reads what is left). */
27
+ readonly spentBytes: number;
28
+ readonly shareBytes: number;
29
+ }
30
+ /** The add's memo, or undefined when it holds none or one of another fingerprint (dropped then). */
31
+ export declare function wrunRowLaneAddMemoOf(key: string, fingerprint: string): WrunRowLaneAddMemo | undefined;
32
+ export declare function rememberWrunRowLaneAdd(key: string, memo: WrunRowLaneAddMemo): void;
33
+ /** A whole run of the add (its plan fits the budget again): the add reads its window whole, no memo after it. */
34
+ export declare function forgetWrunRowLaneAdd(key: string): void;
35
+ /** Test seam: forget every memo. */
36
+ export declare function __resetWrunRowLaneAddMemosForTests(): void;
37
+ /** The asks over the bars `keep` keeps: each ask cut into the runs of its kept bars (a bar belongs to the ask its span
38
+ * opens in), the tier kept; a run reaching the ask's last bar keeps the ask's own end. */
39
+ export declare function wrunRowLaneAsksOverBars(asks: readonly WrunHostGridAsk[], keep: (stampMs: number) => boolean, window: {
40
+ barOpens: readonly number[];
41
+ intervalMs: number;
42
+ }, sessionGrid: LiveBucketVenue | null | undefined): WrunHostGridAsk[];
43
+ /**
44
+ * The add's memo after one of its reads: every bar the read asked that landed whole (not partial for the read, no
45
+ * partial mark on its row) and final (ended `WRUN_ROW_LANE_FINAL_LAG_MS` before the read's clock) joins the landed bars
46
+ * and leaves the cut; every bar the read's budget cut joins the cut unless it is landed; a budgeted read adds what it
47
+ * downloaded and names its share (a live read adds nothing: the add's budget is its runs').
48
+ */
49
+ export declare function wrunRowLaneAddMemoAfter(args: {
50
+ previous: WrunRowLaneAddMemo | undefined;
51
+ fingerprint: string;
52
+ window: {
53
+ intervalMs: number;
54
+ nowMs: number;
55
+ };
56
+ sessionGrid: LiveBucketVenue | null | undefined;
57
+ askedBars: Iterable<number>;
58
+ landedRows: ReadonlyMap<number, ReadonlyArray<unknown>>;
59
+ partialBars: ReadonlySet<number>;
60
+ marked: (row: ReadonlyArray<unknown>) => boolean;
61
+ cutBars: Iterable<number>;
62
+ spentBytes: number;
63
+ shareBytes: number | undefined;
64
+ }): WrunRowLaneAddMemo;
@@ -0,0 +1,89 @@
1
+ import { wrunHostBarSpanOf } from '../wrun-tier-grid.util.js';
2
+ const MINUTE_MS = 60_000;
3
+ /** A landed bar is final once it ended this long before the read: a delayed route serves a bar's last buckets up to 15
4
+ * minutes after its close, so a bar closer to the clock is asked again by the add's next read. */
5
+ export const WRUN_ROW_LANE_FINAL_LAG_MS = 20 * MINUTE_MS;
6
+ /** The memos kept, the oldest dropped first: one for each budgeted row lane instance of a mounted indicator. */
7
+ const MEMOS_KEPT = 32;
8
+ const memos = new Map();
9
+ /** The add's memo, or undefined when it holds none or one of another fingerprint (dropped then). */
10
+ export function wrunRowLaneAddMemoOf(key, fingerprint) {
11
+ const memo = memos.get(key);
12
+ if (memo === undefined)
13
+ return undefined;
14
+ if (memo.fingerprint !== fingerprint) {
15
+ memos.delete(key);
16
+ return undefined;
17
+ }
18
+ return memo;
19
+ }
20
+ export function rememberWrunRowLaneAdd(key, memo) {
21
+ memos.delete(key);
22
+ memos.set(key, memo);
23
+ while (memos.size > MEMOS_KEPT)
24
+ memos.delete(memos.keys().next().value);
25
+ }
26
+ /** A whole run of the add (its plan fits the budget again): the add reads its window whole, no memo after it. */
27
+ export function forgetWrunRowLaneAdd(key) {
28
+ memos.delete(key);
29
+ }
30
+ /** Test seam: forget every memo. */
31
+ export function __resetWrunRowLaneAddMemosForTests() {
32
+ memos.clear();
33
+ }
34
+ /** The asks over the bars `keep` keeps: each ask cut into the runs of its kept bars (a bar belongs to the ask its span
35
+ * opens in), the tier kept; a run reaching the ask's last bar keeps the ask's own end. */
36
+ export function wrunRowLaneAsksOverBars(asks, keep, window, sessionGrid) {
37
+ const out = [];
38
+ for (const ask of asks) {
39
+ const bars = window.barOpens.filter((stampMs) => {
40
+ const { fromMs } = wrunHostBarSpanOf(stampMs, window.intervalMs, sessionGrid);
41
+ return fromMs >= ask.fromMs && fromMs < ask.toMs;
42
+ });
43
+ let runFrom;
44
+ for (let at = 0; at < bars.length; at += 1) {
45
+ const span = wrunHostBarSpanOf(bars[at], window.intervalMs, sessionGrid);
46
+ if (keep(bars[at])) {
47
+ if (runFrom === undefined)
48
+ runFrom = span.fromMs;
49
+ if (at === bars.length - 1)
50
+ out.push({ ...ask, fromMs: runFrom, toMs: ask.toMs });
51
+ continue;
52
+ }
53
+ if (runFrom !== undefined)
54
+ out.push({ ...ask, fromMs: runFrom, toMs: span.fromMs });
55
+ runFrom = undefined;
56
+ }
57
+ }
58
+ return out;
59
+ }
60
+ /**
61
+ * The add's memo after one of its reads: every bar the read asked that landed whole (not partial for the read, no
62
+ * partial mark on its row) and final (ended `WRUN_ROW_LANE_FINAL_LAG_MS` before the read's clock) joins the landed bars
63
+ * and leaves the cut; every bar the read's budget cut joins the cut unless it is landed; a budgeted read adds what it
64
+ * downloaded and names its share (a live read adds nothing: the add's budget is its runs').
65
+ */
66
+ export function wrunRowLaneAddMemoAfter(args) {
67
+ const landed = new Map(args.previous?.landed ?? []);
68
+ const cut = new Set(args.previous?.cut ?? []);
69
+ const finalBefore = args.window.nowMs - WRUN_ROW_LANE_FINAL_LAG_MS;
70
+ for (const stampMs of args.askedBars) {
71
+ const row = args.landedRows.get(stampMs);
72
+ const whole = !args.partialBars.has(stampMs) && (row === undefined || !args.marked(row));
73
+ const { toMs } = wrunHostBarSpanOf(stampMs, args.window.intervalMs, args.sessionGrid);
74
+ if (!whole || toMs > finalBefore)
75
+ continue;
76
+ landed.set(stampMs, row);
77
+ cut.delete(stampMs);
78
+ }
79
+ for (const stampMs of args.cutBars)
80
+ if (!landed.has(stampMs))
81
+ cut.add(stampMs);
82
+ return {
83
+ fingerprint: args.fingerprint,
84
+ landed,
85
+ cut,
86
+ spentBytes: (args.previous?.spentBytes ?? 0) + Math.max(0, args.spentBytes),
87
+ shareBytes: args.shareBytes ?? args.previous?.shareBytes ?? 0,
88
+ };
89
+ }
@@ -6,5 +6,49 @@ import { type WrunHostGridAsk } from '../wrun-tier-grid.util.js';
6
6
  export declare const WRUN_ROW_LANE_FIRST_PAINT_BARS = 30;
7
7
  /** The most bytes a row lane's first ask is projected to answer (OPTLOAD first paint: 0.25 MB, at 8 bytes a cell). */
8
8
  export declare const WRUN_ROW_LANE_FIRST_PAINT_BYTES: number;
9
- /** A host-grid ask plan ordered for first paint (see the module doc). */
9
+ /** The fewest bars a first slice holds to draw before the older bars land: a closed bar beside the newest. A lane
10
+ * whose budget leaves the newest bar alone (Interval Flow's contracts at 1h) draws nothing early: one bar, forming
11
+ * most of a session, is no first picture to check. Strike Footprint never draws early
12
+ * (`wrunRowLaneDrawsFirstSlice`). */
13
+ export declare const WRUN_ROW_LANE_FIRST_SLICE_MIN_BARS = 2;
14
+ /**
15
+ * Whether an instance's first slice may draw before its older bars land (wrun-row-lanes.util `onFirstSlice`): never
16
+ * Strike Footprint's per-(expiry, strike) rows (`option_strike_flow`'s `expiry_strike` group), whatever the slice
17
+ * holds. It learns its strike step over the whole run, so a slice bar could read another value once the older bars
18
+ * land. Its projection alone kept it out (one bar filled the slice) until the projection followed the bar's width: a
19
+ * 5-minute slice holds five of its bars.
20
+ */
21
+ export declare function wrunRowLaneDrawsFirstSlice(sourceClass: string, acquisition: Readonly<Record<string, unknown>>): boolean;
22
+ /** A host-grid ask plan split for first paint: the slice's asks (`first`), the older parts newest first (`older`, empty
23
+ * when the slice holds the plan whole), where the slice starts (its first bar's open; set only when it split) and
24
+ * whether its cut falls on a trade date's first bar (`sessions` asked and met; set only then). */
25
+ export interface WrunRowLaneFirstPaintSplit {
26
+ first: WrunHostGridAsk[];
27
+ older: WrunHostGridAsk[];
28
+ sliceFromMs?: number;
29
+ sessionAligned?: true;
30
+ }
31
+ /**
32
+ * A host-grid ask plan split for first paint (see the module doc). `sessions` (the chart's trade date of a bar, on
33
+ * every run that reads one) moves the cut forward to the first slice bar of another trade date than the bar before the cut, so the slice
34
+ * holds whole sessions (`sessionAligned`); when every slice bar shares that trade date (a session longer than the
35
+ * slice: a 5m chart inside its day) the split is the plain one, unaligned, and nothing draws before the whole answer.
36
+ */
37
+ export declare function wrunRowLaneFirstPaintSplit(asks: readonly WrunHostGridAsk[], window: Pick<WrunRowLaneWindow, 'barOpens' | 'intervalMs' | 'nowMs'>, budget: WrunRowLaneRowBudget | undefined, acquisition?: Readonly<Record<string, unknown>>, sessionGrid?: LiveBucketVenue | null, sessions?: (barOpenMs: number) => number): WrunRowLaneFirstPaintSplit;
38
+ /** A host-grid ask plan cut at `sliceFromMs` (never inside a bar): the slice's asks and the older ones, newest first;
39
+ * the plan whole as the slice when no ask opens before it. A budgeted read of a whole session per row slices on its
40
+ * newest session's first bar (wrun-row-lanes.util `landWithinDownloadShare`, OPTLOAD W3 R2). */
41
+ export declare function wrunRowLaneSplitAt(asks: readonly WrunHostGridAsk[], sliceFromMs: number): WrunRowLaneFirstPaintSplit;
42
+ /** A host-grid ask plan ordered for first paint (see the module doc): the slice's asks, then the older ones. */
10
43
  export declare function wrunRowLaneFirstPaintAsks(asks: readonly WrunHostGridAsk[], window: Pick<WrunRowLaneWindow, 'barOpens' | 'intervalMs' | 'nowMs'>, budget: WrunRowLaneRowBudget | undefined, acquisition?: Readonly<Record<string, unknown>>, sessionGrid?: LiveBucketVenue | null): WrunHostGridAsk[];
44
+ /**
45
+ * The bars a first slice's early answer holds back as partial (bit 14), ascending, or undefined when the slice has no
46
+ * early answer (wrun-row-lanes.util `fetchWrunRowLaneRows`, `onFirstSlice`): every bar the older asks cover that the
47
+ * lane's projection reads rows for (`budget.barRows` under the acquisition the asks were budgeted under). A bar it
48
+ * projects at none (a day before today under `history` "today") reads nothing in the whole answer either, so it stays
49
+ * quiet. Undefined unless the split's cut falls on a trade date's first bar (`sessionAligned`: the slice holds whole
50
+ * sessions, so a slice bar reads in the first picture what it reads in the whole answer for any package whose state
51
+ * starts again on each trade date), when the slice holds fewer than `WRUN_ROW_LANE_FIRST_SLICE_MIN_BARS` bars, or
52
+ * when no older bar is projected to hold rows (nothing to wait for).
53
+ */
54
+ export declare function wrunRowLaneFirstSliceHeldBars(split: Pick<WrunRowLaneFirstPaintSplit, 'older' | 'sliceFromMs' | 'sessionAligned'>, window: Pick<WrunRowLaneWindow, 'barOpens' | 'intervalMs' | 'nowMs'>, budget: WrunRowLaneRowBudget, acquisition?: Readonly<Record<string, unknown>>, sessionGrid?: LiveBucketVenue | null): number[] | undefined;
@@ -6,17 +6,44 @@
6
6
  * parts follow, newest first. The asks cover the same bars at the same tiers, so the landed rows are the same. A lane
7
7
  * with no row budget, and a plan the slice holds whole, keep their plan. wrun-row-lanes.util `fetchWrunRowLaneRows`
8
8
  * loads this module for a row-budget lane only, so it stays off the boot path (tests/utility/wrun/wrun-door.closure).
9
+ *
10
+ * Where the chart reads trade dates (`sessions`, its `time.trade_date`) the cut falls on a trade date's first bar on
11
+ * every run, so the slice holds whole sessions and a first paint asks the windows every later run asks. A full run's
12
+ * first paint draws that slice before the older asks land (`fetchWrunRowLaneRows` `onFirstSlice`): a package whose
13
+ * state starts again on each trade date reads every slice bar as the whole answer does, and the older bars read
14
+ * partial until the whole answer fills them in (`wrunRowLaneFirstSliceHeldBars`).
9
15
  */
10
16
  import { KSCRIPT_SOURCE_CELL_BYTES } from '../../chart/kscript-source-answer-budget.leaf.js';
11
17
  import { wrunHostBarSpanOf } from '../wrun-tier-grid.util.js';
18
+ import { WRUN_OPTION_STRIKE_FLOW_CLASS } from '../wrun-option-strike-flow-lane.util.js';
12
19
  /** The most host bars a row lane's first ask covers (OPTLOAD first paint: the newest 30 bars first). */
13
20
  export const WRUN_ROW_LANE_FIRST_PAINT_BARS = 30;
14
21
  /** The most bytes a row lane's first ask is projected to answer (OPTLOAD first paint: 0.25 MB, at 8 bytes a cell). */
15
22
  export const WRUN_ROW_LANE_FIRST_PAINT_BYTES = 256 * 1024;
16
- /** A host-grid ask plan ordered for first paint (see the module doc). */
17
- export function wrunRowLaneFirstPaintAsks(asks, window, budget, acquisition = {}, sessionGrid) {
23
+ /** The fewest bars a first slice holds to draw before the older bars land: a closed bar beside the newest. A lane
24
+ * whose budget leaves the newest bar alone (Interval Flow's contracts at 1h) draws nothing early: one bar, forming
25
+ * most of a session, is no first picture to check. Strike Footprint never draws early
26
+ * (`wrunRowLaneDrawsFirstSlice`). */
27
+ export const WRUN_ROW_LANE_FIRST_SLICE_MIN_BARS = 2;
28
+ /**
29
+ * Whether an instance's first slice may draw before its older bars land (wrun-row-lanes.util `onFirstSlice`): never
30
+ * Strike Footprint's per-(expiry, strike) rows (`option_strike_flow`'s `expiry_strike` group), whatever the slice
31
+ * holds. It learns its strike step over the whole run, so a slice bar could read another value once the older bars
32
+ * land. Its projection alone kept it out (one bar filled the slice) until the projection followed the bar's width: a
33
+ * 5-minute slice holds five of its bars.
34
+ */
35
+ export function wrunRowLaneDrawsFirstSlice(sourceClass, acquisition) {
36
+ return sourceClass !== WRUN_OPTION_STRIKE_FLOW_CLASS || acquisition.group !== 'expiry_strike';
37
+ }
38
+ /**
39
+ * A host-grid ask plan split for first paint (see the module doc). `sessions` (the chart's trade date of a bar, on
40
+ * every run that reads one) moves the cut forward to the first slice bar of another trade date than the bar before the cut, so the slice
41
+ * holds whole sessions (`sessionAligned`); when every slice bar shares that trade date (a session longer than the
42
+ * slice: a 5m chart inside its day) the split is the plain one, unaligned, and nothing draws before the whole answer.
43
+ */
44
+ export function wrunRowLaneFirstPaintSplit(asks, window, budget, acquisition = {}, sessionGrid, sessions) {
18
45
  if (budget === undefined || asks.length === 0)
19
- return [...asks];
46
+ return { first: [...asks], older: [] };
20
47
  const asked = [];
21
48
  for (const ask of asks) {
22
49
  for (const stampMs of window.barOpens) {
@@ -39,8 +66,26 @@ export function wrunRowLaneFirstPaintAsks(asks, window, budget, acquisition = {}
39
66
  bytes += barBytes;
40
67
  sliceFrom = bar.fromMs;
41
68
  }
42
- if (!Number.isFinite(sliceFrom) || asked.every((bar) => bar.fromMs >= sliceFrom))
43
- return [...asks];
69
+ if (!Number.isFinite(sliceFrom) || asked.every((bar) => bar.fromMs >= sliceFrom)) {
70
+ return { first: [...asks], older: [] };
71
+ }
72
+ const aligned = sessions === undefined ? undefined : sessionAlignedCut(sliceFrom, window, sessions, sessionGrid);
73
+ return {
74
+ ...cutAsks(asks, aligned ?? sliceFrom),
75
+ sliceFromMs: aligned ?? sliceFrom,
76
+ ...(aligned !== undefined ? { sessionAligned: true } : {}),
77
+ };
78
+ }
79
+ /** A host-grid ask plan cut at `sliceFromMs` (never inside a bar): the slice's asks and the older ones, newest first;
80
+ * the plan whole as the slice when no ask opens before it. A budgeted read of a whole session per row slices on its
81
+ * newest session's first bar (wrun-row-lanes.util `landWithinDownloadShare`, OPTLOAD W3 R2). */
82
+ export function wrunRowLaneSplitAt(asks, sliceFromMs) {
83
+ if (asks.every((ask) => ask.fromMs >= sliceFromMs))
84
+ return { first: [...asks], older: [] };
85
+ return { ...cutAsks(asks, sliceFromMs), sliceFromMs };
86
+ }
87
+ /** The asks cut at `sliceFrom` (never inside a bar): the slice's in their order, the older ones newest first. */
88
+ function cutAsks(asks, sliceFrom) {
44
89
  const first = [];
45
90
  const older = [];
46
91
  for (const ask of asks) {
@@ -53,5 +98,68 @@ export function wrunRowLaneFirstPaintAsks(asks, window, budget, acquisition = {}
53
98
  first.push({ ...ask, fromMs: sliceFrom });
54
99
  }
55
100
  }
56
- return [...first, ...older.sort((a, b) => b.fromMs - a.fromMs)];
101
+ return { first, older: older.sort((a, b) => b.fromMs - a.fromMs) };
102
+ }
103
+ /** The slice's start moved to the first slice bar of another trade date than the bar before the cut; undefined when
104
+ * no such bar exists, or a trade date cannot be read (NaN). */
105
+ function sessionAlignedCut(sliceFrom, window, sessions, sessionGrid) {
106
+ let before;
107
+ const slice = [];
108
+ for (const stampMs of window.barOpens) {
109
+ const span = wrunHostBarSpanOf(stampMs, window.intervalMs, sessionGrid);
110
+ if (span.fromMs >= sliceFrom)
111
+ slice.push({ stampMs, fromMs: span.fromMs });
112
+ else if (before === undefined || stampMs > before)
113
+ before = stampMs;
114
+ }
115
+ if (before === undefined)
116
+ return sliceFrom;
117
+ const cutDate = sessions(before);
118
+ if (!Number.isFinite(cutDate))
119
+ return undefined;
120
+ let start;
121
+ for (const bar of slice) {
122
+ const date = sessions(bar.stampMs);
123
+ if (!Number.isFinite(date))
124
+ return undefined;
125
+ if (date !== cutDate && (start === undefined || bar.fromMs < start))
126
+ start = bar.fromMs;
127
+ }
128
+ return start;
129
+ }
130
+ /** A host-grid ask plan ordered for first paint (see the module doc): the slice's asks, then the older ones. */
131
+ export function wrunRowLaneFirstPaintAsks(asks, window, budget, acquisition = {}, sessionGrid) {
132
+ const { first, older } = wrunRowLaneFirstPaintSplit(asks, window, budget, acquisition, sessionGrid);
133
+ return [...first, ...older];
134
+ }
135
+ /**
136
+ * The bars a first slice's early answer holds back as partial (bit 14), ascending, or undefined when the slice has no
137
+ * early answer (wrun-row-lanes.util `fetchWrunRowLaneRows`, `onFirstSlice`): every bar the older asks cover that the
138
+ * lane's projection reads rows for (`budget.barRows` under the acquisition the asks were budgeted under). A bar it
139
+ * projects at none (a day before today under `history` "today") reads nothing in the whole answer either, so it stays
140
+ * quiet. Undefined unless the split's cut falls on a trade date's first bar (`sessionAligned`: the slice holds whole
141
+ * sessions, so a slice bar reads in the first picture what it reads in the whole answer for any package whose state
142
+ * starts again on each trade date), when the slice holds fewer than `WRUN_ROW_LANE_FIRST_SLICE_MIN_BARS` bars, or
143
+ * when no older bar is projected to hold rows (nothing to wait for).
144
+ */
145
+ export function wrunRowLaneFirstSliceHeldBars(split, window, budget, acquisition = {}, sessionGrid) {
146
+ const { sliceFromMs } = split;
147
+ if (split.sessionAligned !== true || sliceFromMs === undefined || split.older.length === 0)
148
+ return undefined;
149
+ const held = [];
150
+ let sliceBars = 0;
151
+ for (const stampMs of window.barOpens) {
152
+ const span = wrunHostBarSpanOf(stampMs, window.intervalMs, sessionGrid);
153
+ if (span.fromMs >= sliceFromMs) {
154
+ sliceBars += 1;
155
+ continue;
156
+ }
157
+ const ask = split.older.find((candidate) => span.fromMs >= candidate.fromMs && span.fromMs < candidate.toMs);
158
+ if (ask === undefined)
159
+ continue;
160
+ const projected = budget.barRows({ openMs: span.fromMs, endMs: span.toMs, tier: ask.tier }, window.nowMs, acquisition);
161
+ if (Number.isFinite(projected) && projected > 0)
162
+ held.push(stampMs);
163
+ }
164
+ return held.length === 0 || sliceBars < WRUN_ROW_LANE_FIRST_SLICE_MIN_BARS ? undefined : held.sort((a, b) => a - b);
57
165
  }
@@ -250,22 +250,73 @@ export interface WrunRowLaneDescriptor {
250
250
  */
251
251
  presentMask?: false;
252
252
  /** One input's projection of a bar's tuples (its own `expiries` word over a lane two inputs share, a field
253
- * selection, a cut to the input's own `max_cells`): applied per input per bar, never refetching. Absent: the
254
- * bar's tuples as they are. */
255
- cells?: (tuples: ReadonlyArray<ReadonlyArray<number>>, input: WrunRowLaneCellInput) => ReadonlyArray<ReadonlyArray<number>>;
253
+ * selection, a cut to the input's own `max_cells`): applied per input per bar, never refetching. `bar` names the
254
+ * bar's open and what `cellsWindow` answered, on a lane that declares one. Absent: the bar's tuples as they are. */
255
+ cells?: (tuples: ReadonlyArray<ReadonlyArray<number>>, input: WrunRowLaneCellInput, bar?: WrunRowLaneCellBarContext) => ReadonlyArray<ReadonlyArray<number>>;
256
+ /** The window-level pass an input reads before its per-bar projection, or undefined (absent too) when `cells` reads
257
+ * each bar alone: read once over every bar the instance holds (each bar's open and its exact tuples), its answer
258
+ * handed to `cells` on every bar (`option_prints`' union: the window's newest cut, which each bar's largest prints
259
+ * are unioned with). An input that reads none costs no more than before. */
260
+ cellsWindow?: (input: WrunRowLaneCellInput) => ((bars: ReadonlyArray<WrunRowLaneCellBar>) => unknown) | undefined;
256
261
  /** The lane's OWN fetch in place of the chart's (a series no K control serves): the poll lanes' ask shape,
257
262
  * answered as rows `[ts, tuple, ...]` at the asked tier, ascending. */
258
263
  fetch?: (ask: WrunPollLaneFetchAsk) => Promise<ReadonlyArray<ReadonlyArray<unknown>>>;
259
264
  /** Live points by coin (see `WrunRowLaneLiveByCoin`: a governed lane's plane, a chain lane's own chain per
260
265
  * instance); absent: a poll lane (the reconcile re-asks it). */
261
266
  liveByCoin?: WrunRowLaneLiveByCoin;
267
+ /** How the indicator download budget prices and caps a read the lane downloads more for than its declaration says
268
+ * (OPTLOAD W3 R2 and FE-FOLD-CAP, `WrunRowLaneDownloadFacts`); absent: the kit's projection of the declared read. */
269
+ download?: WrunRowLaneDownloadFacts;
262
270
  }
263
- /** The input a lane's per-input projection (`cells`) reads: its name, its declaration and the most tuples a bar of
264
- * it may hold (`max_cells`, the bound the packer refuses past; the row builder hands it from the static plan). */
271
+ /** The chart a lane's download forecast reads before any fetch (`WrunRowLaneDownloadFacts.forecastBytes`): the chain the
272
+ * chart's options list on as the chain lanes resolve it (its exchange and underlying), the tier its reads are routed to
273
+ * on a governed exchange, and the run's window of host bars. */
274
+ export interface WrunRowLaneDownloadChart {
275
+ chainExchange: string;
276
+ coin: string;
277
+ servedTier?: 'realtime' | 'delayed';
278
+ barOpens: readonly number[];
279
+ intervalMs: number;
280
+ barGrid?: LiveBucketVenue | null;
281
+ nowMs: number;
282
+ }
283
+ /**
284
+ * A lane's own words to the download budget (OPTLOAD W3 R2, FE-FOLD-CAP; wrun-download-plan.util):
285
+ * - `forecastBytes`: what a read of one input (its declaration, setting-bound knobs already read) is forecast to
286
+ * download over the run's window before any fetch, where it downloads more than its declaration says (a read the
287
+ * lane folds from the chain's contract rows in the browser), or undefined when the kit's projection holds. Loaded
288
+ * lazily: the lane file stays light;
289
+ * - `fold`: the ask field the lane's browser fold reads its contract-row cap from, and one folded row's cells, so a
290
+ * budgeted read spends the indicator's budget, not the source answer's.
291
+ */
292
+ export interface WrunRowLaneDownloadFacts {
293
+ forecastBytes?: (source: WrunRowLaneSource, ctx: WrunRowLaneContext, chart: WrunRowLaneDownloadChart) => Promise<number | undefined>;
294
+ fold?: {
295
+ field: string;
296
+ cellsPerRow: number;
297
+ };
298
+ }
299
+ /** The input a lane's per-input projection (`cells`) reads: its name, its declaration, its `max_cells` (the row
300
+ * builder hands it from the static plan) and the most tuples a bar's block may hold in the run's module (`capacity`:
301
+ * the sheet's `capacity ?? max_cells`, a print union's `max_cells + newest` only where the module's capacity holds
302
+ * it, the bound the packer refuses past: wrun-cell-capacity.leaf `wrunSheetCellBlockTuples`, from the static plan).
303
+ * Absent `capacity` reads `maxCells`. */
265
304
  export interface WrunRowLaneCellInput {
266
305
  name: string;
267
306
  source: WrunInputSource;
268
307
  maxCells?: number;
308
+ capacity?: number;
309
+ }
310
+ /** One bar as a lane's window-level pass reads it (`cellsWindow`): its open and its exact tuples. */
311
+ export interface WrunRowLaneCellBar {
312
+ openMs: number;
313
+ tuples: ReadonlyArray<ReadonlyArray<number>>;
314
+ }
315
+ /** What a bar's projection reads beside its tuples on a lane with a window-level pass: the bar's open and the pass's
316
+ * answer over the whole window (`cellsWindow`). */
317
+ export interface WrunRowLaneCellBarContext {
318
+ openMs: number;
319
+ window: unknown;
269
320
  }
270
321
  /** What a row-lane file may export: one lane, several, or both. */
271
322
  export interface WrunRowLaneModule {