@orangecharts/wrun-chart-host 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/README.md +27 -4
  2. package/dist/constants/feature-flags.constants.d.ts +5 -0
  3. package/dist/constants/feature-flags.constants.js +32 -0
  4. package/dist/constants/marketCapabilities.constants.d.ts +14 -9
  5. package/dist/constants/marketCapabilities.constants.js +36 -13
  6. package/dist/constants/opra-compliance.constants.d.ts +14 -0
  7. package/dist/constants/opra-compliance.constants.js +14 -0
  8. package/dist/constants/option-venues.constants.d.ts +29 -6
  9. package/dist/constants/option-venues.constants.js +19 -2
  10. package/dist/constants/venue-presets.constants.d.ts +17 -3
  11. package/dist/constants/venue-presets.constants.js +17 -3
  12. package/dist/host-env.d.ts +34 -4
  13. package/dist/host-env.js +21 -0
  14. package/dist/host-ports.types.d.ts +51 -3
  15. package/dist/index.d.ts +17 -0
  16. package/dist/index.js +17 -0
  17. package/dist/indicators/controls/tpo-session.util.d.ts +40 -11
  18. package/dist/indicators/controls/tpo-session.util.js +138 -14
  19. package/dist/interfaces/opra-realtime.interface.d.ts +13 -11
  20. package/dist/interfaces/opra-realtime.interface.js +10 -10
  21. package/dist/interfaces/option-instrument.interface.d.ts +6 -0
  22. package/dist/interfaces/wrun-runtime.interface.d.ts +34 -13
  23. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +57 -10
  24. package/dist/kscript-data/controls/live-trades-merge.util.js +85 -16
  25. package/dist/market-data/billing.interface.d.ts +138 -17
  26. package/dist/market-data/billing.interface.js +25 -8
  27. package/dist/market-data/venues/index.d.ts +3 -3
  28. package/dist/market-data/venues/opra.contract.copy.json +5 -3
  29. package/dist/market-data/venues/opra.d.ts +3 -3
  30. package/dist/market-data/venues/opra.js +5 -4
  31. package/dist/replay/replayLadder.js +3 -1
  32. package/dist/settings-templates/footprint-rows.d.ts +25 -0
  33. package/dist/settings-templates/footprint-rows.js +127 -0
  34. package/dist/settings-templates/form-rows.d.ts +56 -0
  35. package/dist/settings-templates/form-rows.js +19 -0
  36. package/dist/settings-templates/frvp-fields.js +14 -0
  37. package/dist/settings-templates/index.d.ts +10 -1
  38. package/dist/settings-templates/index.js +11 -2
  39. package/dist/settings-templates/indicator-fields.js +78 -0
  40. package/dist/settings-templates/tool-rules.d.ts +35 -9
  41. package/dist/settings-templates/tool-rules.js +42 -8
  42. package/dist/settings-templates/tool-tables.generated.js +13 -2
  43. package/dist/utility/chart/candle-volume-unit.leaf.d.ts +16 -0
  44. package/dist/utility/chart/candle-volume-unit.leaf.js +61 -0
  45. package/dist/utility/chart/crypto-index.leaf.d.ts +2 -2
  46. package/dist/utility/chart/crypto-index.leaf.js +2 -2
  47. package/dist/utility/chart/footprint-columns.util.d.ts +74 -0
  48. package/dist/utility/chart/footprint-columns.util.js +106 -0
  49. package/dist/utility/chart/footprint-display-mode.util.d.ts +40 -0
  50. package/dist/utility/chart/footprint-display-mode.util.js +62 -0
  51. package/dist/utility/chart/footprint-sierra-look.util.d.ts +2 -0
  52. package/dist/utility/chart/footprint-sierra-look.util.js +37 -0
  53. package/dist/utility/chart/index-mode-admission.util.js +9 -1
  54. package/dist/utility/chart/index-mode.util.d.ts +5 -2
  55. package/dist/utility/chart/index-mode.util.js +23 -13
  56. package/dist/utility/chart/kscript-venue-policy.util.d.ts +28 -21
  57. package/dist/utility/chart/kscript-venue-policy.util.js +34 -26
  58. package/dist/utility/chart/marketKind.util.d.ts +12 -10
  59. package/dist/utility/chart/marketKind.util.js +17 -7
  60. package/dist/utility/chart/om-panel-push-style.util.d.ts +7 -7
  61. package/dist/utility/chart/om-panel-push-style.util.js +17 -15
  62. package/dist/utility/chart/om-panel.util.d.ts +11 -0
  63. package/dist/utility/chart/om-panel.util.js +65 -6
  64. package/dist/utility/chart/profile-block-size.util.d.ts +16 -0
  65. package/dist/utility/chart/profile-block-size.util.js +7 -0
  66. package/dist/utility/chart/quote-perp.leaf.d.ts +17 -0
  67. package/dist/utility/chart/quote-perp.leaf.js +20 -0
  68. package/dist/utility/chart/window-geometry.leaf.d.ts +23 -1
  69. package/dist/utility/chart/window-geometry.leaf.js +78 -6
  70. package/dist/utility/chart/window-owner.leaf.d.ts +13 -0
  71. package/dist/utility/chart/window-owner.leaf.js +5 -0
  72. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -0
  73. package/dist/utility/chart/wrun-run-result.util.js +4 -1
  74. package/dist/utility/common/transformations.util.d.ts +7 -0
  75. package/dist/utility/common/transformations.util.js +11 -0
  76. package/dist/utility/options/cme-options-root.util.d.ts +25 -0
  77. package/dist/utility/options/cme-options-root.util.js +40 -0
  78. package/dist/utility/options/option-book.util.d.ts +27 -0
  79. package/dist/utility/options/option-book.util.js +76 -0
  80. package/dist/utility/options/option-trade-date.util.d.ts +50 -0
  81. package/dist/utility/options/option-trade-date.util.js +120 -0
  82. package/dist/utility/options/option-venue.util.d.ts +3 -3
  83. package/dist/utility/options/option-venue.util.js +3 -3
  84. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +1 -1
  85. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +2 -2
  86. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +2 -2
  87. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +5 -1
  88. package/dist/utility/wrun/sources/host-grid-landing.d.ts +4 -2
  89. package/dist/utility/wrun/sources/host-grid-landing.js +8 -0
  90. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +40 -4
  91. package/dist/utility/wrun/sources/lanes/options_flow.js +115 -18
  92. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +12 -9
  93. package/dist/utility/wrun/sources/opra-option-lanes.util.js +10 -7
  94. package/dist/utility/wrun/sources/row-lane-registry.js +10 -5
  95. package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
  96. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +3 -2
  97. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +30 -5
  98. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +9 -3
  99. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +13 -5
  100. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +25 -1
  101. package/dist/utility/wrun/sources/row-lanes/option_prints.js +161 -30
  102. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.d.ts +4 -0
  103. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +65 -0
  104. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +55 -1
  105. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +83 -2
  106. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +17 -1
  107. package/dist/utility/wrun/sources/row-lanes/option_surface.js +33 -2
  108. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +7 -1
  109. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +51 -5
  110. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +136 -3
  111. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +42 -0
  112. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +146 -0
  113. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +25 -5
  114. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +111 -20
  115. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +291 -48
  116. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +16 -3
  117. package/dist/utility/wrun/wrun-batched-marks.util.js +30 -19
  118. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +37 -9
  119. package/dist/utility/wrun/wrun-batched-readout.util.js +61 -15
  120. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -0
  121. package/dist/utility/wrun/wrun-cell-capacity.leaf.d.ts +66 -0
  122. package/dist/utility/wrun/wrun-cell-capacity.leaf.js +86 -0
  123. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +147 -9
  124. package/dist/utility/wrun/wrun-chart-market-facts.util.js +345 -11
  125. package/dist/utility/wrun/wrun-cloud-record.leaf.d.ts +27 -0
  126. package/dist/utility/wrun/wrun-cloud-record.leaf.js +71 -0
  127. package/dist/utility/wrun/wrun-cloud-record.util.d.ts +4 -21
  128. package/dist/utility/wrun/wrun-cloud-record.util.js +5 -65
  129. package/dist/utility/wrun/wrun-color-facts.util.d.ts +19 -9
  130. package/dist/utility/wrun/wrun-color-facts.util.js +24 -14
  131. package/dist/utility/wrun/wrun-color-settings.util.d.ts +22 -9
  132. package/dist/utility/wrun/wrun-color-settings.util.js +57 -23
  133. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.d.ts +17 -0
  134. package/dist/utility/wrun/wrun-dollar-unit-port.leaf.js +9 -0
  135. package/dist/utility/wrun/wrun-download-meter.util.d.ts +92 -0
  136. package/dist/utility/wrun/wrun-download-meter.util.js +122 -0
  137. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +10 -3
  138. package/dist/utility/wrun/wrun-draft-overlay.util.js +63 -6
  139. package/dist/utility/wrun/wrun-frames.js +5 -5
  140. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
  141. package/dist/utility/wrun/wrun-hosted-wire-caps.js +11 -0
  142. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +33 -17
  143. package/dist/utility/wrun/wrun-hud-looks.util.js +30 -16
  144. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +29 -3
  145. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +33 -3
  146. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +8 -6
  147. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +8 -6
  148. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -2
  149. package/dist/utility/wrun/wrun-live-intake.util.d.ts +6 -2
  150. package/dist/utility/wrun/wrun-live-intake.util.js +136 -21
  151. package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -1
  152. package/dist/utility/wrun/wrun-live-tick.util.js +130 -44
  153. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.d.ts +53 -0
  154. package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.js +162 -0
  155. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +224 -0
  156. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +342 -0
  157. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +88 -0
  158. package/dist/utility/wrun/wrun-market-size-defaults.util.js +471 -0
  159. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +43 -8
  160. package/dist/utility/wrun/wrun-opra-flow.leaf.js +37 -6
  161. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +51 -10
  162. package/dist/utility/wrun/wrun-option-contract-flow.util.js +85 -33
  163. package/dist/utility/wrun/wrun-option-prints.util.d.ts +172 -3
  164. package/dist/utility/wrun/wrun-option-prints.util.js +394 -17
  165. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +99 -0
  166. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +218 -0
  167. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +365 -0
  168. package/dist/utility/wrun/wrun-option-strike-flow.util.js +797 -0
  169. package/dist/utility/wrun/wrun-option-views.util.d.ts +231 -7
  170. package/dist/utility/wrun/wrun-option-views.util.js +643 -23
  171. package/dist/utility/wrun/wrun-options-chain.util.d.ts +6 -4
  172. package/dist/utility/wrun/wrun-options-chain.util.js +8 -5
  173. package/dist/utility/wrun/wrun-options-stop.util.d.ts +2 -1
  174. package/dist/utility/wrun/wrun-options-stop.util.js +3 -2
  175. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +3 -0
  176. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +31 -14
  177. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +22 -0
  178. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +9 -1
  179. package/dist/utility/wrun/wrun-overlay-recovery.util.js +32 -3
  180. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +7 -1
  181. package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
  182. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +34 -6
  183. package/dist/utility/wrun/wrun-overlay-run.util.js +527 -180
  184. package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +15 -0
  185. package/dist/utility/wrun/wrun-pack-widths.leaf.js +22 -0
  186. package/dist/utility/wrun/wrun-pack.util.d.ts +13 -8
  187. package/dist/utility/wrun/wrun-pack.util.js +38 -21
  188. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +4 -0
  189. package/dist/utility/wrun/wrun-panel-mount.util.js +62 -22
  190. package/dist/utility/wrun/wrun-panel-style.util.d.ts +41 -14
  191. package/dist/utility/wrun/wrun-panel-style.util.js +86 -26
  192. package/dist/utility/wrun/wrun-param-map.util.d.ts +7 -6
  193. package/dist/utility/wrun/wrun-param-map.util.js +8 -5
  194. package/dist/utility/wrun/wrun-param-values.util.d.ts +10 -2
  195. package/dist/utility/wrun/wrun-param-values.util.js +2 -0
  196. package/dist/utility/wrun/wrun-pin-spelling.util.js +19 -10
  197. package/dist/utility/wrun/wrun-prefix-lanes.util.js +2 -2
  198. package/dist/utility/wrun/wrun-refusal.util.js +17 -2
  199. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +20 -0
  200. package/dist/utility/wrun/wrun-script-inputs.util.js +43 -0
  201. package/dist/utility/wrun/wrun-source-rows.util.d.ts +4 -0
  202. package/dist/utility/wrun/wrun-source-rows.util.js +92 -40
  203. package/dist/utility/wrun/wrun-tape-source.util.d.ts +133 -48
  204. package/dist/utility/wrun/wrun-tape-source.util.js +205 -62
  205. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +7 -5
  206. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +8 -6
  207. package/dist/workers/utils/volume-profile.worker.util.d.ts +4 -1
  208. package/dist/workers/utils/volume-profile.worker.util.js +5 -2
  209. package/dist/workers/wrun/wrun-abi-host.js +3 -2
  210. package/package.json +11 -11
@@ -27,11 +27,25 @@
27
27
  * decided when the run plans and named in the acquisition, `auto` the chain's default book over the series its
28
28
  * directory lists, opra-option-lanes.util `resolveWrunLaneChainAutoBook`; an answer never picks it) and `max_cells`
29
29
  * (a block over it refuses the run); a market pin and the other options classes' knobs refuse by name.
30
+ * - `pick` (OPTLOAD G5, kit 0.90.0; wrun-option-views.util): "nearest_days" (`days`, `delta`) or "tenor_bracket"
31
+ * (`tenor`), each param a number (a setting's value once the paint seam wrote it), refused by the SDK's rules by
32
+ * name (`wrun_option_knob_invalid`). Each bar's block is the pick of its landed bucket (`wrunOptionSurfacePickTuples`,
33
+ * the SDK's reference), so the template reads the one or two tuples it reads today. The pick's fields ride the
34
+ * acquisition (`surfacePick` and its params, with the run's bar span), so the worker asks OPTION_SURFACE grouped to
35
+ * the chart's bars with the pick applied there (`optionRead`: the gateway lands each bar on its newest sealed 5m
36
+ * bucket, as this lane lands it), or, where the chart's bars are no grouping the gateway draws (an RTH CME chart's
37
+ * 13:30Z hours, a daily bar), in the widest UTC groups that nest inside them (OPTLOAD W3 SURF-NEST: a few rows a bar,
38
+ * each its group's newest sealed bucket picked; this lane lands each bar on its newest row), and reads today's
39
+ * buckets while the gateway refuses the read; the pick applied on the page to a bar the gateway picked picks the
40
+ * same tuples. An input without `pick` asks and lands as before.
41
+ * - O1 (OPTLOAD G5): on the OPRA plane the chain is the plane's own by coin (`wrunHeldOpraPlaneChain`), no chain
42
+ * directory read.
30
43
  *
31
44
  * LIGHT at module load: pb-common and the chain resolver are imported inside `identity`.
32
45
  */
33
46
  import { decideWrunLaneChain, refuseWrunLaneStrayKnob, resolveWrunLaneChainChart, WRUN_OPTION_CHART_UNRESOLVED_CODE, wrunLaneChainLeadMoved, wrunLaneChainPlaneOf, wrunLaneChartKey, } from '../opra-option-lanes.util.js';
34
47
  import { refuseWrunPollInput } from '../wrun-poll-lane.types.js';
48
+ import { wrunHeldOpraPlaneChain, wrunOptionLaneAskFields, wrunOptionLaneAskOf, wrunOptionLaneAskOfSource, wrunOptionSurfacePickTuples, } from '../../wrun-option-views.util.js';
35
49
  import { assertWrunProtocolType } from '../../wrun-protocol-pending.util.js';
36
50
  import { wrunAuthorRuleSeed } from '../../wrun-refusal.util.js';
37
51
  const MINUTE_MS = 60_000;
@@ -113,6 +127,14 @@ export function wrunOptionSurfaceReadsSettlements(acquisition) {
113
127
  const exchange = acquisition[WRUN_OPTION_SURFACE_EXCHANGE_FIELD];
114
128
  return wrunLaneChainPlaneOf(typeof exchange === 'string' ? exchange : '') === 'cme';
115
129
  }
130
+ /** One input's block on one bar: the pick of the bar's tuples when the input declares `pick` (the SDK's reference,
131
+ * idempotent on a bar the gateway picked), else the tuples as they are. */
132
+ export function wrunOptionSurfaceCells(tuples, input) {
133
+ const read = wrunOptionLaneAskOf(input.source);
134
+ return read !== undefined && 'ask' in read
135
+ ? wrunOptionSurfacePickTuples(tuples, read.ask.word, read.ask.params)
136
+ : tuples;
137
+ }
116
138
  export const rowLane = {
117
139
  sourceClass: 'option_surface',
118
140
  laneKey: 'option_surface',
@@ -125,7 +147,9 @@ export const rowLane = {
125
147
  acquisitionMoved: wrunOptionSurfaceAcquisitionMoved,
126
148
  identity: async (ctx) => {
127
149
  await assertWrunProtocolType(ctx, WRUN_OPTION_SURFACE_TYPE, 'option_surface');
128
- rememberSurfaceChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx));
150
+ // O1: on the OPRA plane the chain is the plane's own by coin, no chain directory read.
151
+ const held = await wrunHeldOpraPlaneChain(ctx.exchange, ctx.coin, ctx.opraPlane);
152
+ rememberSurfaceChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx, held));
129
153
  },
130
154
  facets: async (source, ctx) => {
131
155
  for (const [knob, owners] of STRAY_KNOBS) {
@@ -135,10 +159,17 @@ export const rowLane = {
135
159
  if (source.symbol !== undefined || source.exchange !== undefined) {
136
160
  refuseWrunPollInput(ctx, "pins option_surface cells to a fixed market (wrun_option_market_pinned); it reads the chart's own underlying, so drop the symbol and exchange pin", wrunAuthorRuleSeed('wrun_option_market_pinned'));
137
161
  }
162
+ // The pick and its params, by the SDK's rules, before any chain read.
163
+ const pick = wrunOptionLaneAskOfSource(source, ctx);
138
164
  const chart = surfaceCharts.get(wrunLaneChartKey(ctx));
139
165
  if (chart === undefined) {
140
166
  return refuseWrunPollInput(ctx, 'could not resolve the chart market for its options chain: Run again', wrunAuthorRuleSeed(WRUN_OPTION_CHART_UNRESOLVED_CODE));
141
167
  }
142
- return wrunOptionSurfaceExtras(await decideWrunLaneChain(chart, { venue: source.venue, book: source.book }, ctx));
168
+ const extras = wrunOptionSurfaceExtras(await decideWrunLaneChain(chart, { venue: source.venue, book: source.book }, ctx));
169
+ // A pick asks the gateway to land and pick each of the run's bars: its fields and the run's bar span.
170
+ return pick === undefined
171
+ ? extras
172
+ : { ...extras, ...wrunOptionLaneAskFields(pick), hostIntervalMs: ctx.intervalMs };
143
173
  },
174
+ cells: wrunOptionSurfaceCells,
144
175
  };
@@ -41,7 +41,7 @@
41
41
  import type { WrunInputSource } from '../../../interfaces/wrun-runtime.interface.js';
42
42
  import type { WrunDailyLanding } from '../wrun-daily-lane.util.js';
43
43
  import { type WrunRefusalSeed } from '../wrun-refusal.util.js';
44
- import type { WrunBackendTier, WrunTierLanding } from '../wrun-tier-grid.util.js';
44
+ import type { WrunBackendTier, WrunTierChoice, WrunTierLanding } from '../wrun-tier-grid.util.js';
45
45
  import type { WrunRowLaneChain, WrunRowLaneHorizon } from './wrun-row-lane.types.js';
46
46
  /** An input's declaration as a lane reads it: the typed fields, and any knob the sheet carries
47
47
  * that the interface does not name yet (`asset`, `publisher`, `series`, ...), as `unknown`. */
@@ -115,10 +115,16 @@ export type WrunPollLaneJoin = 'bar' | {
115
115
  * the asks under the tier rule: each bar is read from the finest tier that fits it and still retains it, one
116
116
  * ask per run of bars on a tier, the tier's key in the ask's payload (`tier`); a bar no tier retains reads
117
117
  * no row (the input's `missing` policy). Absent: one ask, the rows as the control answers them.
118
+ * `tierChoice: 'coarsest'` (a flow with tiers only) reads each bar from the coarsest fitting tier that retains it and
119
+ * already serves it (each tier's `servedLagMs`: a bar that closed inside a coarser tier's lag, the forming one among
120
+ * them, reads the next finer tier) instead of the finest: for a lane whose landing sums the same per-bar values from
121
+ * any tier, so a coarse bar reads fewer buckets (the row lanes' rule, wrun-tier-grid.util `wrunBarTiers`). Absent: the
122
+ * finest (rule 9), as every lane that names none.
118
123
  */
119
124
  export interface WrunPollLaneBarGrid {
120
125
  landing: WrunTierLanding;
121
126
  tiers?: readonly WrunBackendTier[];
127
+ tierChoice?: WrunTierChoice;
122
128
  }
123
129
  /** What `plan` returns: the payload fields beyond the current-market placeholders (`symbol:
124
130
  * 'currentSymbol'`, `exchange: 'currentExchange'`), or nothing when the placeholders are the
@@ -34,13 +34,16 @@
34
34
  * OPRA plane facts (`wrunChartOpraPlane`), a chain lane's OPRA wall and stop before its chain is resolved
35
35
  * (`wrunChainLaneStop`), a lane's refusal that the chart has no option chain (`wrunLaneNoChainRefusal`), and what an
36
36
  * input the chart does not serve does (`wrunUnservedLaneInput`: a declared fill drops it with a note, any other
37
- * refuses by name).
37
+ * refuses by name); an option knob naming a setting read as its current value (`resolveWrunOptionSettingKnobs`, over
38
+ * the one table `WRUN_OPTION_SETTING_KNOBS`, every kind of knob the kit binds: no lane reads a setting itself).
39
+ * - a host-grid lane's asks (`fetchWrunPollLaneHostGridRows`): its tier rule, the finest fitting tier or, for a lane
40
+ * naming `tierChoice: 'coarsest'`, the coarsest that already serves the bar.
38
41
  */
39
- import type { WrunIndicatorMetadata, WrunInputSource } from '../../../interfaces/wrun-runtime.interface.js';
42
+ import type { WrunIndicatorMetadata, WrunInputSource, WrunMetadataParam } from '../../../interfaces/wrun-runtime.interface.js';
40
43
  import type { OpraReadFacts } from '../../chart/opra-read-access.leaf.js';
41
44
  import type { OpraOptionPlaneStop } from '../../../host-ports.types.js';
42
45
  import { type WrunRefusalSeed } from '../wrun-refusal.util.js';
43
- import { type WrunPollLane, type WrunPollLaneContext, type WrunPollLaneId, type WrunPollLaneInstance } from './wrun-poll-lane.types.js';
46
+ import { type WrunPollLane, type WrunPollLaneContext, type WrunPollLaneId, type WrunPollLaneInstance, type WrunPollLaneSource } from './wrun-poll-lane.types.js';
44
47
  import { type WrunLaneChainPlane, type WrunRowLaneHorizon } from './wrun-row-lane.types.js';
45
48
  import type { WrunMissingFeed } from '../wrun-run-health.util.js';
46
49
  import type { LiveBucketVenue } from '../../chart/live-bucket.util.js';
@@ -82,7 +85,44 @@ export interface WrunPollLaneRunFacts extends OpraReadFacts {
82
85
  * `opraOptionPlaneStop`: the flag check's `flag-off`, the plane router's `chart-kind`); absent, the market's own
83
86
  * words ("no such feed here"). */
84
87
  opraPlaneStop?: (exchange: string) => OpraOptionPlaneStop | undefined;
88
+ /** The run's current setting values by name (wrun-param-values.util `wrunParamValuesFromSettings` over the
89
+ * overlay's settings): what an option knob naming a setting reads (`resolveWrunOptionSettingKnobs`). Absent, no
90
+ * knob's setting is read, and a lane refuses a name it cannot read by name. */
91
+ paramValues?: Readonly<Record<string, number>>;
85
92
  }
93
+ /**
94
+ * The kind of value a setting-bound option knob takes (om kit `WrunOptionParamKnobKind`): `number` a number, int or
95
+ * price setting's number; `word` the word of a select's picked option (its `style_values` entry when the select
96
+ * declares them, else its label), one of the knob's words; `list` the labels of a multi's picked options, each one of
97
+ * the knob's words, in the words' order.
98
+ */
99
+ export type WrunOptionSettingKnobKind = 'number' | 'word' | 'list';
100
+ /**
101
+ * The option knobs a setting may stand for, by source class, with the kind each takes (om kit 0.96.0
102
+ * `WRUN_OPTION_PARAM_KNOBS`, row for row): ONE table for both planners, read before a poll lane's `plan` and a row lane's
103
+ * `facets` (`resolveWrunOptionSettingKnobs`), so no lane reads a setting itself. The sheet records the setting's NAME in
104
+ * the knob (an author's `min_premium: "@floor"` compiles to `"floor"`), and every host reads that setting's current
105
+ * value on each run, so a settings change re-plans the input and its ask carries the new value: no rebuild.
106
+ * tests/utility/wrun/sources/wrun-row-lanes.setting-knobs.spec.ts holds every row of a class the browser serves equal to
107
+ * the kit's.
108
+ */
109
+ export declare const WRUN_OPTION_SETTING_KNOBS: Readonly<Record<string, Readonly<Record<string, WrunOptionSettingKnobKind>>>>;
110
+ /** The words a word or list knob takes from a setting (om `wrunOptionKnobWords`): the print classes' `types`,
111
+ * `moneyness` and `sides` (wrun-option-prints.util), and option_strike_flow's `expiries` (the words a setting picks);
112
+ * none for any other knob. */
113
+ export declare function wrunOptionSettingKnobWords(knob: string): readonly string[];
114
+ /**
115
+ * One input's source with every option knob that names a setting read as the setting's current value (om
116
+ * `resolveOptionParamKnobs`, the SDK host's rule, over the class's row of `WRUN_OPTION_SETTING_KNOBS`): a number knob
117
+ * takes a number, int or price setting's number; a word knob (`types`, `moneyness`, option_strike_flow's `expiries`)
118
+ * the word of a select's picked option, its `style_values` entry when the select declares them, else its label, one of
119
+ * its words; a list knob (`sides`) the labels of a multi's picked options, in the words' order. The name
120
+ * 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
121
+ * picking its words, else the input is refused by name (`wrun_option_knob_invalid`). A literal (a number, a list, a word
122
+ * 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
123
+ * class with no such knob is its own source, untouched, so every other lane plans exactly as before.
124
+ */
125
+ export declare function resolveWrunOptionSettingKnobs(ctx: Pick<WrunPollLaneContext, 'inputName' | 'sourceClass'>, source: WrunPollLaneSource, params: readonly WrunMetadataParam[], values: Readonly<Record<string, number>> | undefined): WrunPollLaneSource;
86
126
  /** The technical words of an OPRA lane a known stop keeps off the chart (Copy details), by the stop's reason. */
87
127
  export declare function wrunOpraPlaneStopDetail(stop: OpraOptionPlaneStop): string;
88
128
  /** The chart's OPRA plane facts as both planners read them, once per plan (`wrunChartOpraPlane`). */
@@ -233,6 +273,10 @@ export type WrunPollLanePlanResult = WrunPollLanePlan & WrunPollLaneInstance[];
233
273
  * nowhere, before all of the above: no wall, no admission, no `plan`, no fetch, no note; the row builder reads its
234
274
  * fill on every bar.
235
275
  *
276
+ * An option knob naming a setting (`min_premium: "floor"`, an author's `"@floor"`) reads the setting's current value
277
+ * (`run.paramValues`) before the lane's `plan` judges it (`resolveWrunOptionSettingKnobs`, the SDK host's rule): the
278
+ * instance's extras carry the value, so a settings change re-plans the input and re-asks with it.
279
+ *
236
280
  * The predicates are injected (the run pass hands the chart's own `checkIsIndexMode` and its
237
281
  * crypto-venue rule), so this module, which the row builder imports, stays off those modules'
238
282
  * import graphs; without one no chart reads as index-mode, and without the other the venue is
@@ -370,8 +414,10 @@ export declare function wrunHostGridAsksWithinHorizon(plan: {
370
414
  /**
371
415
  * A lane's rows over a chart window, landed on the host bars when it is a host-grid lane (`barGrid`): its asks
372
416
  * under the tier rule (`wrunHostGridAsks` over the window's host bars: one per run of bars on a tier, the
373
- * tier's key in its extras as `tier`), cut to the lane's `horizon` for the acquisition (`wrunHostGridAsksWithinHorizon`:
374
- * the bars its source no longer holds ask nothing and read the input's `missing` policy), each answer landed by the
417
+ * tier's key in its extras as `tier`; each bar's tier the finest fitting one that retains it, or the coarsest that
418
+ * already serves it for a lane naming `tierChoice: 'coarsest'`), cut to the lane's `horizon` for the acquisition
419
+ * (`wrunHostGridAsksWithinHorizon`: the bars its source no longer holds ask nothing and read the input's `missing`
420
+ * policy), each answer landed by the
375
421
  * lane's landing (`wrunLandScalarRowsOnHostBars`: a flow summed per bar, a snapshot's newest sealed row, sealed by its
376
422
  * ask's tier), ascending. A bar no tier retains asks nothing and reads no row. A flow sums every bucket inside its bar,
377
423
  * so its plan reads the window's bar grid as its session grid (wrun-tier-grid.util `wrunCmeSessionBarSpan`): a CME
@@ -1,3 +1,8 @@
1
+ import { wrunParamChoices } from '../wrun-color-settings.util.js';
2
+ import { refuseWrunOptionKnob } from '../wrun-option-knobs.util.js';
3
+ import { wrunOptionPrintKnobWords } from '../wrun-option-prints.util.js';
4
+ import { WRUN_OPTION_STRIKE_FLOW_CLASS, WRUN_OPTION_STRIKE_FLOW_EXPIRIES_WORDS, wrunOptionStrikeFlowExpiriesOf, } from '../wrun-option-strike-flow-lane.util.js';
5
+ import { wrunMultiLabels } from '../wrun-param-values.util.js';
1
6
  import { wrunOptionsStopSeed, wrunRefusalSeedOf } from '../wrun-refusal.util.js';
2
7
  import { wrunPollLaneByKey, wrunPollLaneGlobalClasses, wrunPollLanes, wrunPollLanesOfClass } from './registry.js';
3
8
  import { refuseWrunPollInput, WRUN_POLL_LANE_ID_PREFIX, } from './wrun-poll-lane.types.js';
@@ -85,6 +90,124 @@ function wrunPollLaneNativeRowsClasses() {
85
90
  function wrunPollLaneServedOnIndexMode(lane) {
86
91
  return lane.global === true || lane.nativeRows === true;
87
92
  }
93
+ /**
94
+ * The option knobs a setting may stand for, by source class, with the kind each takes (om kit 0.96.0
95
+ * `WRUN_OPTION_PARAM_KNOBS`, row for row): ONE table for both planners, read before a poll lane's `plan` and a row lane's
96
+ * `facets` (`resolveWrunOptionSettingKnobs`), so no lane reads a setting itself. The sheet records the setting's NAME in
97
+ * the knob (an author's `min_premium: "@floor"` compiles to `"floor"`), and every host reads that setting's current
98
+ * value on each run, so a settings change re-plans the input and its ask carries the new value: no rebuild.
99
+ * tests/utility/wrun/sources/wrun-row-lanes.setting-knobs.spec.ts holds every row of a class the browser serves equal to
100
+ * the kit's.
101
+ */
102
+ export const WRUN_OPTION_SETTING_KNOBS = Object.freeze({
103
+ options_flow: Object.freeze({ min_premium: 'number', max_dte: 'number' }),
104
+ option_contract_flow: Object.freeze({ min_premium: 'number' }),
105
+ option_strike_flow: Object.freeze({ strike_rows: 'number', expiries: 'word' }),
106
+ option_prints: Object.freeze({
107
+ min_premium: 'number',
108
+ types: 'word',
109
+ sides: 'list',
110
+ moneyness: 'word',
111
+ max_dte: 'number',
112
+ newest_tail_ms: 'number',
113
+ }),
114
+ });
115
+ /** The setting types a number knob reads (om `resolveOptionParamKnobs`: a number, int or price setting). */
116
+ const WRUN_NUMBER_SETTING_TYPES = new Set(['number', 'int', 'price']);
117
+ /** The words a word or list knob takes from a setting (om `wrunOptionKnobWords`): the print classes' `types`,
118
+ * `moneyness` and `sides` (wrun-option-prints.util), and option_strike_flow's `expiries` (the words a setting picks);
119
+ * none for any other knob. */
120
+ export function wrunOptionSettingKnobWords(knob) {
121
+ return knob === 'expiries' ? WRUN_OPTION_STRIKE_FLOW_EXPIRIES_WORDS : wrunOptionPrintKnobWords(knob);
122
+ }
123
+ /** Whether a word knob's value is the knob's own literal, never a setting's name (om `wrunOptionKnobLiteral`): a word
124
+ * the knob takes, and on option_strike_flow's `expiries` any word the class reads ("nearest:N" too, the literal
125
+ * Strike Breakdown declares). A literal is a literal even beside a setting of that name. */
126
+ function wrunOptionKnobLiteral(sourceClass, knob, value) {
127
+ if (knob === 'expiries' && sourceClass === WRUN_OPTION_STRIKE_FLOW_CLASS) {
128
+ return wrunOptionStrikeFlowExpiriesOf(value) !== undefined;
129
+ }
130
+ return wrunOptionSettingKnobWords(knob).includes(value);
131
+ }
132
+ /** What a knob of each kind takes beside a setting's name, as its refusal spells it. */
133
+ function wrunSettingKnobLiteralWords(kind, words) {
134
+ if (kind === 'number')
135
+ return 'a number';
136
+ return kind === 'word' ? `one of ${words.join(', ')}` : `a list of ${words.join(', ')}`;
137
+ }
138
+ /** The setting a knob of each kind reads its value from, as its refusal spells it. */
139
+ const WRUN_SETTING_KNOB_SETTINGS = Object.freeze({
140
+ number: 'a number, int or price setting',
141
+ word: 'a select setting whose picked option is one of them (its style_values word, else its label)',
142
+ list: 'a multi setting whose picked options are labelled with them',
143
+ });
144
+ /** The literal a setting stands for on a knob of `kind` at the run's `value`, or why it stands for none. */
145
+ function wrunSettingKnobLiteral(kind, words, param, value) {
146
+ const type = param.type ?? 'number';
147
+ if (kind === 'number')
148
+ return WRUN_NUMBER_SETTING_TYPES.has(type) ? { literal: value } : { why: `is a ${type} setting` };
149
+ if (kind === 'word') {
150
+ if (type !== 'select')
151
+ return { why: `is a ${type} setting` };
152
+ // THE select read's choices (a select's options, labelled by `option_labels`), the picked one by its value; its
153
+ // word the `style_values` entry at the pick's place when the select declares them (kit 0.96.0: the dialog keeps
154
+ // its own labels), else its label (om `selectWord`).
155
+ const choices = wrunParamChoices(param);
156
+ const at = choices?.findIndex((choice) => choice.value === value) ?? -1;
157
+ const word = at < 0 ? undefined : Array.isArray(param.style_values) ? param.style_values[at] : choices?.[at]?.label;
158
+ return typeof word === 'string' && words.includes(word) ? { literal: word } : { why: `picks '${word ?? value}'` };
159
+ }
160
+ if (type !== 'multi')
161
+ return { why: `is a ${type} setting` };
162
+ if (!Number.isInteger(value) || value < 0)
163
+ return { why: `picks ${value}` };
164
+ const picked = wrunMultiLabels(param).filter((_, bit) => Math.floor(value / 2 ** bit) % 2 === 1);
165
+ if (!picked.every((label) => words.includes(label))) {
166
+ return { why: `picks ${picked.map((label) => `'${label}'`).join(', ')}` };
167
+ }
168
+ return { literal: words.filter((word) => picked.includes(word)) };
169
+ }
170
+ /**
171
+ * One input's source with every option knob that names a setting read as the setting's current value (om
172
+ * `resolveOptionParamKnobs`, the SDK host's rule, over the class's row of `WRUN_OPTION_SETTING_KNOBS`): a number knob
173
+ * takes a number, int or price setting's number; a word knob (`types`, `moneyness`, option_strike_flow's `expiries`)
174
+ * the word of a select's picked option, its `style_values` entry when the select declares them, else its label, one of
175
+ * its words; a list knob (`sides`) the labels of a multi's picked options, in the words' order. The name
176
+ * 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
177
+ * picking its words, else the input is refused by name (`wrun_option_knob_invalid`). A literal (a number, a list, a word
178
+ * 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
179
+ * class with no such knob is its own source, untouched, so every other lane plans exactly as before.
180
+ */
181
+ export function resolveWrunOptionSettingKnobs(ctx, source, params, values) {
182
+ const knobs = Object.prototype.hasOwnProperty.call(WRUN_OPTION_SETTING_KNOBS, ctx.sourceClass)
183
+ ? WRUN_OPTION_SETTING_KNOBS[ctx.sourceClass]
184
+ : undefined;
185
+ if (knobs === undefined || values === undefined)
186
+ return source;
187
+ let resolved;
188
+ for (const [knob, kind] of Object.entries(knobs)) {
189
+ const name = source[knob];
190
+ if (typeof name !== 'string')
191
+ continue;
192
+ const words = wrunOptionSettingKnobWords(knob);
193
+ // A word knob's own word is a literal, never a setting's name.
194
+ if (kind === 'word' && wrunOptionKnobLiteral(ctx.sourceClass, knob, name))
195
+ continue;
196
+ const literalWords = wrunSettingKnobLiteralWords(kind, words);
197
+ const param = params.find((candidate) => candidate.name === name);
198
+ const value = Object.prototype.hasOwnProperty.call(values, name) ? values[name] : undefined;
199
+ if (param === undefined || param.style !== undefined || typeof value !== 'number' || !Number.isFinite(value)) {
200
+ return refuseWrunOptionKnob(ctx, knob, name, `${literalWords} or the name of a compute setting of the sheet, and '${name}' is no such setting`);
201
+ }
202
+ const read = wrunSettingKnobLiteral(kind, words, param, value);
203
+ if ('why' in read) {
204
+ return refuseWrunOptionKnob(ctx, knob, name, `${literalWords} or the name of ${WRUN_SETTING_KNOB_SETTINGS[kind]}, and '${name}' ${read.why}`);
205
+ }
206
+ resolved ??= { ...source };
207
+ resolved[knob] = read.literal;
208
+ }
209
+ return resolved === undefined ? source : resolved;
210
+ }
88
211
  /** Why an `opra` lane is not served on a chart whose options ride no OPRA plane, as its refusal says it. */
89
212
  const WRUN_POLL_OPRA_UNADMITTED_REASON = "is not served on this chart: it reads US options data, which a US stock or ETF chart (its underlying's options) and an OPRA option contract chart serve";
90
213
  /** The technical words of an OPRA lane a known stop keeps off the chart (Copy details), by the stop's reason. */
@@ -277,6 +400,10 @@ function wrunPollLanePlanResult(lanes, missingFeeds) {
277
400
  * nowhere, before all of the above: no wall, no admission, no `plan`, no fetch, no note; the row builder reads its
278
401
  * fill on every bar.
279
402
  *
403
+ * An option knob naming a setting (`min_premium: "floor"`, an author's `"@floor"`) reads the setting's current value
404
+ * (`run.paramValues`) before the lane's `plan` judges it (`resolveWrunOptionSettingKnobs`, the SDK host's rule): the
405
+ * instance's extras carry the value, so a settings change re-plans the input and re-asks with it.
406
+ *
280
407
  * The predicates are injected (the run pass hands the chart's own `checkIsIndexMode` and its
281
408
  * crypto-venue rule), so this module, which the row builder imports, stays off those modules'
282
409
  * import graphs; without one no chart reads as index-mode, and without the other the venue is
@@ -335,7 +462,10 @@ export async function planWrunPollLanes(metadata, chart, isIndexModeExchange = (
335
462
  }
336
463
  let answered;
337
464
  try {
338
- answered = await planned.lane.plan(planned.source, ctx);
465
+ // An option knob naming a setting reads the setting's current value before the lane judges it (om
466
+ // `resolveOptionParamKnobs`): the instance's extras carry the value, so a settings change re-plans and re-asks.
467
+ const source = resolveWrunOptionSettingKnobs(ctx, planned.source, metadata.params ?? [], run?.paramValues);
468
+ answered = await planned.lane.plan(source, ctx);
339
469
  }
340
470
  catch (error) {
341
471
  // A chart with no option chain does not serve the feed (`wrunLaneNoChainRefusal`), nor one whose options plane
@@ -602,8 +732,10 @@ export function wrunHostGridAsksWithinHorizon(plan, window, horizon, sessionGrid
602
732
  /**
603
733
  * A lane's rows over a chart window, landed on the host bars when it is a host-grid lane (`barGrid`): its asks
604
734
  * under the tier rule (`wrunHostGridAsks` over the window's host bars: one per run of bars on a tier, the
605
- * tier's key in its extras as `tier`), cut to the lane's `horizon` for the acquisition (`wrunHostGridAsksWithinHorizon`:
606
- * the bars its source no longer holds ask nothing and read the input's `missing` policy), each answer landed by the
735
+ * tier's key in its extras as `tier`; each bar's tier the finest fitting one that retains it, or the coarsest that
736
+ * already serves it for a lane naming `tierChoice: 'coarsest'`), cut to the lane's `horizon` for the acquisition
737
+ * (`wrunHostGridAsksWithinHorizon`: the bars its source no longer holds ask nothing and read the input's `missing`
738
+ * policy), each answer landed by the
607
739
  * lane's landing (`wrunLandScalarRowsOnHostBars`: a flow summed per bar, a snapshot's newest sealed row, sealed by its
608
740
  * ask's tier), ascending. A bar no tier retains asks nothing and reads no row. A flow sums every bucket inside its bar,
609
741
  * so its plan reads the window's bar grid as its session grid (wrun-tier-grid.util `wrunCmeSessionBarSpan`): a CME
@@ -621,6 +753,7 @@ export async function fetchWrunPollLaneHostGridRows(lane, extras, window, fallba
621
753
  barOpens: window.barOpens,
622
754
  intervalMs: window.intervalMs,
623
755
  nowMs: window.nowMs,
756
+ ...(grid.tierChoice !== undefined ? { choice: grid.tierChoice } : {}),
624
757
  ...(sessionGrid !== undefined ? { sessionGrid } : {}),
625
758
  }), window, lane.horizon?.(extras, window.nowMs), sessionGrid);
626
759
  const answers = await Promise.all(asks.map(async (gridAsk) => {
@@ -0,0 +1,42 @@
1
+ import type { LiveBucketVenue } from '../../chart/live-bucket.util.js';
2
+ import type { WrunRowLaneRowBudget } from './wrun-row-lane.types.js';
3
+ import type { WrunRowLaneWindow } from './wrun-row-lanes.util.js';
4
+ import { type WrunHostGridAsk } from '../wrun-tier-grid.util.js';
5
+ /** The most host bars a row lane's first ask covers (OPTLOAD first paint: the newest 30 bars first). */
6
+ export declare const WRUN_ROW_LANE_FIRST_PAINT_BARS = 30;
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
+ export declare const WRUN_ROW_LANE_FIRST_PAINT_BYTES: number;
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 (Strike Footprint's expiry_strike rows, Interval Flow's contracts at 1h)
11
+ * draws nothing early: one bar, forming most of a session, is no first picture to check, and Strike Footprint learns
12
+ * its strike step over the whole run, so that bar could read another value once the older bars land. */
13
+ export declare const WRUN_ROW_LANE_FIRST_SLICE_MIN_BARS = 2;
14
+ /** A host-grid ask plan split for first paint: the slice's asks (`first`), the older parts newest first (`older`, empty
15
+ * when the slice holds the plan whole), where the slice starts (its first bar's open; set only when it split) and
16
+ * whether its cut falls on a trade date's first bar (`sessions` asked and met; set only then). */
17
+ export interface WrunRowLaneFirstPaintSplit {
18
+ first: WrunHostGridAsk[];
19
+ older: WrunHostGridAsk[];
20
+ sliceFromMs?: number;
21
+ sessionAligned?: true;
22
+ }
23
+ /**
24
+ * A host-grid ask plan split for first paint (see the module doc). `sessions` (the chart's trade date of a bar, on
25
+ * 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
26
+ * holds whole sessions (`sessionAligned`); when every slice bar shares that trade date (a session longer than the
27
+ * slice: a 5m chart inside its day) the split is the plain one, unaligned, and nothing draws before the whole answer.
28
+ */
29
+ 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;
30
+ /** A host-grid ask plan ordered for first paint (see the module doc): the slice's asks, then the older ones. */
31
+ 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[];
32
+ /**
33
+ * The bars a first slice's early answer holds back as partial (bit 14), ascending, or undefined when the slice has no
34
+ * early answer (wrun-row-lanes.util `fetchWrunRowLaneRows`, `onFirstSlice`): every bar the older asks cover that the
35
+ * lane's projection reads rows for (`budget.barRows` under the acquisition the asks were budgeted under). A bar it
36
+ * projects at none (a day before today under `history` "today") reads nothing in the whole answer either, so it stays
37
+ * quiet. Undefined unless the split's cut falls on a trade date's first bar (`sessionAligned`: the slice holds whole
38
+ * sessions, so a slice bar reads in the first picture what it reads in the whole answer for any package whose state
39
+ * starts again on each trade date), when the slice holds fewer than `WRUN_ROW_LANE_FIRST_SLICE_MIN_BARS` bars, or
40
+ * when no older bar is projected to hold rows (nothing to wait for).
41
+ */
42
+ 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;
@@ -0,0 +1,146 @@
1
+ /**
2
+ * The first-paint slice of a row lane with a row budget (OPTLOAD-READ-CONTRACT FE-STRIKE-LANE; the per-strike and
3
+ * per-contract flow lanes): the NEWEST asked bars, at most `WRUN_ROW_LANE_FIRST_PAINT_BARS` and only as many as the
4
+ * lane's projection (`barRows` x `cellsPerRow` x 8 bytes) fits `WRUN_ROW_LANE_FIRST_PAINT_BYTES` (the newest bar at
5
+ * least), are asked on their own and FIRST; the asks are cut at that slice's first bar (never inside a bar) and the older
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
+ * with no row budget, and a plan the slice holds whole, keep their plan. wrun-row-lanes.util `fetchWrunRowLaneRows`
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`).
15
+ */
16
+ import { KSCRIPT_SOURCE_CELL_BYTES } from '../../chart/kscript-source-answer-budget.leaf.js';
17
+ import { wrunHostBarSpanOf } from '../wrun-tier-grid.util.js';
18
+ /** The most host bars a row lane's first ask covers (OPTLOAD first paint: the newest 30 bars first). */
19
+ export const WRUN_ROW_LANE_FIRST_PAINT_BARS = 30;
20
+ /** The most bytes a row lane's first ask is projected to answer (OPTLOAD first paint: 0.25 MB, at 8 bytes a cell). */
21
+ export const WRUN_ROW_LANE_FIRST_PAINT_BYTES = 256 * 1024;
22
+ /** The fewest bars a first slice holds to draw before the older bars land: a closed bar beside the newest. A lane
23
+ * whose budget leaves the newest bar alone (Strike Footprint's expiry_strike rows, Interval Flow's contracts at 1h)
24
+ * draws nothing early: one bar, forming most of a session, is no first picture to check, and Strike Footprint learns
25
+ * its strike step over the whole run, so that bar could read another value once the older bars land. */
26
+ export const WRUN_ROW_LANE_FIRST_SLICE_MIN_BARS = 2;
27
+ /**
28
+ * A host-grid ask plan split for first paint (see the module doc). `sessions` (the chart's trade date of a bar, on
29
+ * 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
30
+ * holds whole sessions (`sessionAligned`); when every slice bar shares that trade date (a session longer than the
31
+ * slice: a 5m chart inside its day) the split is the plain one, unaligned, and nothing draws before the whole answer.
32
+ */
33
+ export function wrunRowLaneFirstPaintSplit(asks, window, budget, acquisition = {}, sessionGrid, sessions) {
34
+ if (budget === undefined || asks.length === 0)
35
+ return { first: [...asks], older: [] };
36
+ const asked = [];
37
+ for (const ask of asks) {
38
+ for (const stampMs of window.barOpens) {
39
+ const span = wrunHostBarSpanOf(stampMs, window.intervalMs, sessionGrid);
40
+ if (span.fromMs < ask.fromMs || span.fromMs >= ask.toMs)
41
+ continue;
42
+ asked.push({ fromMs: span.fromMs, toMs: span.toMs, tier: ask.tier });
43
+ }
44
+ }
45
+ asked.sort((a, b) => b.fromMs - a.fromMs);
46
+ let bytes = 0;
47
+ let sliceFrom = Number.POSITIVE_INFINITY;
48
+ for (let at = 0; at < asked.length && at < WRUN_ROW_LANE_FIRST_PAINT_BARS; at += 1) {
49
+ const bar = asked[at];
50
+ const projected = budget.barRows({ openMs: bar.fromMs, endMs: bar.toMs, tier: bar.tier }, window.nowMs, acquisition);
51
+ const barRows = Number.isFinite(projected) && projected > 0 ? projected : 0;
52
+ const barBytes = barRows * budget.cellsPerRow * KSCRIPT_SOURCE_CELL_BYTES;
53
+ if (at > 0 && bytes + barBytes > WRUN_ROW_LANE_FIRST_PAINT_BYTES)
54
+ break;
55
+ bytes += barBytes;
56
+ sliceFrom = bar.fromMs;
57
+ }
58
+ if (!Number.isFinite(sliceFrom) || asked.every((bar) => bar.fromMs >= sliceFrom)) {
59
+ return { first: [...asks], older: [] };
60
+ }
61
+ const aligned = sessions === undefined ? undefined : sessionAlignedCut(sliceFrom, window, sessions, sessionGrid);
62
+ return {
63
+ ...cutAsks(asks, aligned ?? sliceFrom),
64
+ sliceFromMs: aligned ?? sliceFrom,
65
+ ...(aligned !== undefined ? { sessionAligned: true } : {}),
66
+ };
67
+ }
68
+ /** The asks cut at `sliceFrom` (never inside a bar): the slice's in their order, the older ones newest first. */
69
+ function cutAsks(asks, sliceFrom) {
70
+ const first = [];
71
+ const older = [];
72
+ for (const ask of asks) {
73
+ if (ask.fromMs >= sliceFrom)
74
+ first.push(ask);
75
+ else if (ask.toMs <= sliceFrom)
76
+ older.push(ask);
77
+ else {
78
+ older.push({ ...ask, toMs: sliceFrom });
79
+ first.push({ ...ask, fromMs: sliceFrom });
80
+ }
81
+ }
82
+ return { first, older: older.sort((a, b) => b.fromMs - a.fromMs) };
83
+ }
84
+ /** The slice's start moved to the first slice bar of another trade date than the bar before the cut; undefined when
85
+ * no such bar exists, or a trade date cannot be read (NaN). */
86
+ function sessionAlignedCut(sliceFrom, window, sessions, sessionGrid) {
87
+ let before;
88
+ const slice = [];
89
+ for (const stampMs of window.barOpens) {
90
+ const span = wrunHostBarSpanOf(stampMs, window.intervalMs, sessionGrid);
91
+ if (span.fromMs >= sliceFrom)
92
+ slice.push({ stampMs, fromMs: span.fromMs });
93
+ else if (before === undefined || stampMs > before)
94
+ before = stampMs;
95
+ }
96
+ if (before === undefined)
97
+ return sliceFrom;
98
+ const cutDate = sessions(before);
99
+ if (!Number.isFinite(cutDate))
100
+ return undefined;
101
+ let start;
102
+ for (const bar of slice) {
103
+ const date = sessions(bar.stampMs);
104
+ if (!Number.isFinite(date))
105
+ return undefined;
106
+ if (date !== cutDate && (start === undefined || bar.fromMs < start))
107
+ start = bar.fromMs;
108
+ }
109
+ return start;
110
+ }
111
+ /** A host-grid ask plan ordered for first paint (see the module doc): the slice's asks, then the older ones. */
112
+ export function wrunRowLaneFirstPaintAsks(asks, window, budget, acquisition = {}, sessionGrid) {
113
+ const { first, older } = wrunRowLaneFirstPaintSplit(asks, window, budget, acquisition, sessionGrid);
114
+ return [...first, ...older];
115
+ }
116
+ /**
117
+ * The bars a first slice's early answer holds back as partial (bit 14), ascending, or undefined when the slice has no
118
+ * early answer (wrun-row-lanes.util `fetchWrunRowLaneRows`, `onFirstSlice`): every bar the older asks cover that the
119
+ * lane's projection reads rows for (`budget.barRows` under the acquisition the asks were budgeted under). A bar it
120
+ * projects at none (a day before today under `history` "today") reads nothing in the whole answer either, so it stays
121
+ * quiet. Undefined unless the split's cut falls on a trade date's first bar (`sessionAligned`: the slice holds whole
122
+ * sessions, so a slice bar reads in the first picture what it reads in the whole answer for any package whose state
123
+ * starts again on each trade date), when the slice holds fewer than `WRUN_ROW_LANE_FIRST_SLICE_MIN_BARS` bars, or
124
+ * when no older bar is projected to hold rows (nothing to wait for).
125
+ */
126
+ export function wrunRowLaneFirstSliceHeldBars(split, window, budget, acquisition = {}, sessionGrid) {
127
+ const { sliceFromMs } = split;
128
+ if (split.sessionAligned !== true || sliceFromMs === undefined || split.older.length === 0)
129
+ return undefined;
130
+ const held = [];
131
+ let sliceBars = 0;
132
+ for (const stampMs of window.barOpens) {
133
+ const span = wrunHostBarSpanOf(stampMs, window.intervalMs, sessionGrid);
134
+ if (span.fromMs >= sliceFromMs) {
135
+ sliceBars += 1;
136
+ continue;
137
+ }
138
+ const ask = split.older.find((candidate) => span.fromMs >= candidate.fromMs && span.fromMs < candidate.toMs);
139
+ if (ask === undefined)
140
+ continue;
141
+ const projected = budget.barRows({ openMs: span.fromMs, endMs: span.toMs, tier: ask.tier }, window.nowMs, acquisition);
142
+ if (Number.isFinite(projected) && projected > 0)
143
+ held.push(stampMs);
144
+ }
145
+ return held.length === 0 || sliceBars < WRUN_ROW_LANE_FIRST_SLICE_MIN_BARS ? undefined : held.sort((a, b) => a - b);
146
+ }
@@ -250,9 +250,14 @@ 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>>>;
@@ -260,12 +265,27 @@ export interface WrunRowLaneDescriptor {
260
265
  * instance); absent: a poll lane (the reconcile re-asks it). */
261
266
  liveByCoin?: WrunRowLaneLiveByCoin;
262
267
  }
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). */
268
+ /** The input a lane's per-input projection (`cells`) reads: its name, its declaration, its `max_cells` (the row
269
+ * builder hands it from the static plan) and the most tuples a bar's block may hold in the run's module (`capacity`:
270
+ * the sheet's `capacity ?? max_cells`, a print union's `max_cells + newest` only where the module's capacity holds
271
+ * it, the bound the packer refuses past: wrun-cell-capacity.leaf `wrunSheetCellBlockTuples`, from the static plan).
272
+ * Absent `capacity` reads `maxCells`. */
265
273
  export interface WrunRowLaneCellInput {
266
274
  name: string;
267
275
  source: WrunInputSource;
268
276
  maxCells?: number;
277
+ capacity?: number;
278
+ }
279
+ /** One bar as a lane's window-level pass reads it (`cellsWindow`): its open and its exact tuples. */
280
+ export interface WrunRowLaneCellBar {
281
+ openMs: number;
282
+ tuples: ReadonlyArray<ReadonlyArray<number>>;
283
+ }
284
+ /** 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
285
+ * answer over the whole window (`cellsWindow`). */
286
+ export interface WrunRowLaneCellBarContext {
287
+ openMs: number;
288
+ window: unknown;
269
289
  }
270
290
  /** What a row-lane file may export: one lane, several, or both. */
271
291
  export interface WrunRowLaneModule {