@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
@@ -0,0 +1,218 @@
1
+ /**
2
+ * The main-thread part of the `option_strike_flow` class (OPTLOAD G3): what its row lane reads before and after a fetch,
3
+ * on the boot path with every row lane (`sources/row-lanes/index.ts` imports them all). The tuple's shape, the groups,
4
+ * the knob words both flow lanes read, the tiers, the horizon, the row budget's projection and the per-bar fold. The
5
+ * rules the K control and the worker twin read (the acquisition, the groupings, `optionRead`, section 6.4's fold, the
6
+ * fold's read plan) are wrun-option-strike-flow.util's, which re-exports this module and stays off the boot path
7
+ * (tests/utility/wrun/sources/option_strike_flow.boot-path.spec.ts). The class: docs/features/kscript/wrun/
8
+ * wrun-browser-runtime.md.
9
+ */
10
+ import { wrunOptionFlowBarBeforeToday } from './wrun-option-contract-flow.util.js';
11
+ import { wrunPresentIsPartial, wrunPresentWithPartial } from './wrun-present-bits.util.js';
12
+ const MINUTE_MS = 60_000;
13
+ const DAY_MS = 86_400_000;
14
+ /** The class, its lane key and its K type word (om `WRUN_OPTION_FETCH_TYPES.option_strike_flow`). */
15
+ export const WRUN_OPTION_STRIKE_FLOW_CLASS = 'option_strike_flow';
16
+ /** f64s per tuple, the `present` mask included (om `WRUN_OPTION_TUPLE_WIDTHS.option_strike_flow`). */
17
+ export const WRUN_OPTION_STRIKE_FLOW_WIDTH = 15;
18
+ /** The tuple's columns (om `WRUN_OPTION_CELL_COLUMNS.option_strike_flow`). */
19
+ export const WRUN_OPTION_STRIKE_FLOW_COLUMN = Object.freeze({
20
+ expiry: 0,
21
+ strike: 1,
22
+ side: 2,
23
+ dteClass: 3,
24
+ volAsk: 4,
25
+ volBid: 5,
26
+ volMid: 6,
27
+ volNone: 7,
28
+ volAboveAsk: 8,
29
+ volBelowBid: 9,
30
+ premAsk: 10,
31
+ premBid: 11,
32
+ premMid: 12,
33
+ premNone: 13,
34
+ present: 14,
35
+ });
36
+ /** `group` (om `WRUN_OPTION_STRIKE_FLOW_GROUPS`, required). */
37
+ export const WRUN_OPTION_STRIKE_FLOW_GROUPS = Object.freeze(['strike', 'expiry', 'expiry_strike']);
38
+ /** `span` and `history` on the grouped flow classes (om `WRUN_OPTION_FLOW_SPANS`, `WRUN_OPTION_FLOW_HISTORY`). */
39
+ export const WRUN_OPTION_FLOW_SPANS = Object.freeze(['bar', 'session']);
40
+ export const WRUN_OPTION_FLOW_HISTORY = Object.freeze(['window', 'today']);
41
+ /** The tiers each group is served at (om `WRUN_OPTION_STRIKE_FLOW_TIERS`, contract 6.3): 1m 7 days, 5m 30, 30m kept
42
+ * (30 days on `expiry_strike`, the lane's horizon). Every tier serves the forming bar. */
43
+ export const WRUN_OPTION_STRIKE_FLOW_TIERS = Object.freeze({
44
+ strike: Object.freeze([
45
+ { key: '1m', ms: MINUTE_MS, retentionMs: 7 * DAY_MS },
46
+ { key: '5m', ms: 5 * MINUTE_MS, retentionMs: 30 * DAY_MS },
47
+ { key: '30m', ms: 30 * MINUTE_MS },
48
+ ]),
49
+ expiry: Object.freeze([
50
+ { key: '1m', ms: MINUTE_MS, retentionMs: 7 * DAY_MS },
51
+ { key: '5m', ms: 5 * MINUTE_MS, retentionMs: 30 * DAY_MS },
52
+ { key: '30m', ms: 30 * MINUTE_MS },
53
+ ]),
54
+ expiry_strike: Object.freeze([
55
+ { key: '1m', ms: MINUTE_MS, retentionMs: 7 * DAY_MS },
56
+ { key: '5m', ms: 5 * MINUTE_MS, retentionMs: 30 * DAY_MS },
57
+ { key: '30m', ms: 30 * MINUTE_MS, retentionMs: 30 * DAY_MS },
58
+ ]),
59
+ });
60
+ const NEAREST_RE = /^nearest:([1-9]\d{0,2})$/;
61
+ /** The `expiries` words a setting picks (om `WRUN_OPTION_STRIKE_FLOW_EXPIRIES_WORDS`, kit 0.96.0: a select whose
62
+ * `style_values` are these words): every word but "nearest:N", whose count no choice carries. */
63
+ export const WRUN_OPTION_STRIKE_FLOW_EXPIRIES_WORDS = Object.freeze(['all', '0dte', 'after_today']);
64
+ /** An `expiries` word as this class reads it (absent is "all"), or undefined for a word outside them. */
65
+ export function wrunOptionStrikeFlowExpiriesOf(value) {
66
+ if (value === undefined || value === 'all')
67
+ return { kind: 'all' };
68
+ if (value === '0dte')
69
+ return { kind: '0dte' };
70
+ if (value === 'after_today')
71
+ return { kind: 'after_today' };
72
+ if (typeof value !== 'string')
73
+ return undefined;
74
+ const match = NEAREST_RE.exec(value);
75
+ return match ? { kind: 'nearest', count: Number(match[1]) } : undefined;
76
+ }
77
+ function positiveOf(value) {
78
+ return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : undefined;
79
+ }
80
+ /** The knobs an acquisition (an instance's payload) names, a field that is not valid read absent. */
81
+ export function wrunOptionStrikeFlowPayloadKnobsOf(payload) {
82
+ const group = WRUN_OPTION_STRIKE_FLOW_GROUPS.includes(payload?.group)
83
+ ? payload?.group
84
+ : 'strike';
85
+ const expiries = wrunOptionStrikeFlowExpiriesOf(payload?.expiries);
86
+ const rows = payload?.strikeRows;
87
+ const strikeWindowPct = positiveOf(payload?.strikeWindowPct);
88
+ const minVolume = positiveOf(payload?.minVolume);
89
+ return {
90
+ group,
91
+ ...(expiries !== undefined && expiries.kind !== 'all' && typeof payload?.expiries === 'string'
92
+ ? { expiries: payload.expiries }
93
+ : {}),
94
+ ...(strikeWindowPct !== undefined ? { strikeWindowPct } : {}),
95
+ ...(typeof rows === 'number' && Number.isInteger(rows) && rows >= 1 ? { strikeRows: rows } : {}),
96
+ ...(payload?.splitDte === true ? { splitDte: true } : {}),
97
+ ...(payload?.foldTypes === true ? { foldTypes: true } : {}),
98
+ ...(payload?.span === 'session' ? { span: 'session' } : {}),
99
+ ...(payload?.history === 'today' ? { history: 'today' } : {}),
100
+ ...(minVolume !== undefined ? { minVolume } : {}),
101
+ };
102
+ }
103
+ /** The span the class is served over for one acquisition: `expiry_strike`'s 30-minute view keeps 30 days; every other
104
+ * group's tiers say it alone. */
105
+ export function wrunOptionStrikeFlowHorizon(extras, nowMs) {
106
+ if (extras.group !== 'expiry_strike' || !Number.isFinite(nowMs))
107
+ return undefined;
108
+ const reach = WRUN_OPTION_STRIKE_FLOW_TIERS.expiry_strike.at(-1)?.retentionMs;
109
+ if (reach === undefined)
110
+ return undefined;
111
+ return { servedFromMs: nowMs - reach, completeFromMs: nowMs - reach };
112
+ }
113
+ /** The tuples one SPY bar of a group holds (one 30-minute session of 13 bars measured 2026-10-19): STRIKE 357 (471 with
114
+ * the 0DTE split), EXPIRY 75, the per-(expiry, strike) rows 2,326; 33 traded expiries. Any bar width, every chain. */
115
+ export const WRUN_OPTION_STRIKE_FLOW_BAR_TUPLES = Object.freeze({
116
+ strike: 357,
117
+ strikeSplit: 471,
118
+ expiry: 75,
119
+ expiryStrike: 2_326,
120
+ expiries: 33,
121
+ });
122
+ /** The tuples a bar of one acquisition is projected to hold, from its knobs over SPY's measured bars. */
123
+ export function wrunOptionStrikeFlowTuplesPerBar(acquisition) {
124
+ const knobs = wrunOptionStrikeFlowPayloadKnobsOf(acquisition);
125
+ const T = WRUN_OPTION_STRIKE_FLOW_BAR_TUPLES;
126
+ const sides = knobs.foldTypes ? 1 : 2;
127
+ const parts = knobs.splitDte ? 2 : 1;
128
+ const nearest = wrunOptionStrikeFlowExpiriesOf(knobs.expiries);
129
+ const expiryShare = nearest?.kind === 'nearest' ? Math.min(1, nearest.count / T.expiries) : 1;
130
+ const windowShare = knobs.strikeWindowPct !== undefined ? Math.min(1, knobs.strikeWindowPct / 25) : 1;
131
+ switch (knobs.group) {
132
+ case 'expiry':
133
+ return Math.ceil(T.expiry * expiryShare);
134
+ case 'expiry_strike': {
135
+ const cells = T.expiryStrike * expiryShare * windowShare;
136
+ const rows = knobs.strikeRows !== undefined ? knobs.strikeRows * 2 * Math.ceil(T.expiries * expiryShare) : Infinity;
137
+ return Math.ceil(Math.min(cells, rows));
138
+ }
139
+ default: {
140
+ const all = ((knobs.splitDte ? T.strikeSplit : T.strike) * sides) / 2;
141
+ const rows = knobs.strikeRows !== undefined ? knobs.strikeRows * sides * parts : Infinity;
142
+ return Math.ceil(Math.min(all * windowShare, rows));
143
+ }
144
+ }
145
+ }
146
+ /** The rows one host bar is projected to read (the lane's row budget): its projected tuples, none for a bar before
147
+ * today's first instant as the acquisition names it under `history` "today" (it reads nothing;
148
+ * wrun-option-contract-flow.util `wrunOptionFlowBarBeforeToday`, never dated off `nowMs`). */
149
+ export function wrunOptionStrikeFlowBarRows(bar, _nowMs, acquisition) {
150
+ if (wrunOptionFlowBarBeforeToday(bar, acquisition))
151
+ return 0;
152
+ return wrunOptionStrikeFlowTuplesPerBar(acquisition);
153
+ }
154
+ /** Every finite tuple a host bar row's cells hold, in order: a packed block's tuples back to back, a plain tuple as it
155
+ * is. A cell of another shape, and a tuple holding a value that is not finite, is skipped. */
156
+ export function wrunOptionStrikeFlowTuplesOfRow(row) {
157
+ const tuples = [];
158
+ const take = (source, offset) => {
159
+ const tuple = new Array(WRUN_OPTION_STRIKE_FLOW_WIDTH);
160
+ for (let column = 0; column < WRUN_OPTION_STRIKE_FLOW_WIDTH; column += 1) {
161
+ const value = source[offset + column];
162
+ if (!Number.isFinite(value))
163
+ return;
164
+ tuple[column] = value;
165
+ }
166
+ tuples.push(tuple);
167
+ };
168
+ for (let index = 1; index < row.length; index += 1) {
169
+ const cell = row[index];
170
+ if (cell instanceof Float64Array && cell.length % WRUN_OPTION_STRIKE_FLOW_WIDTH === 0) {
171
+ for (let offset = 0; offset < cell.length; offset += WRUN_OPTION_STRIKE_FLOW_WIDTH)
172
+ take(cell, offset);
173
+ }
174
+ else if (Array.isArray(cell) && cell.length === WRUN_OPTION_STRIKE_FLOW_WIDTH) {
175
+ take(cell, 0);
176
+ }
177
+ }
178
+ return tuples;
179
+ }
180
+ /** The canonical order of a bar's tuples: expiry, strike, calls before puts (folded last), then the 0DTE part first. */
181
+ export function compareWrunOptionStrikeFlowTuples(a, b) {
182
+ const C = WRUN_OPTION_STRIKE_FLOW_COLUMN;
183
+ return (a[C.expiry] - b[C.expiry] || a[C.strike] - b[C.strike] || b[C.side] - a[C.side] || a[C.dteClass] - b[C.dteClass]);
184
+ }
185
+ /** One host bar's tuples from its rows (the lane's fold): a grouped bar's tuples as they are, several rows of one bar
186
+ * merged key by key (expiry, strike, side, class: values summed, a partial mark kept), a partial marker kept as the
187
+ * bar's marker. Sorted canonically. */
188
+ export function foldWrunOptionStrikeFlowBar(rows) {
189
+ const C = WRUN_OPTION_STRIKE_FLOW_COLUMN;
190
+ const byKey = new Map();
191
+ let marker;
192
+ for (const row of rows) {
193
+ for (const tuple of wrunOptionStrikeFlowTuplesOfRow(row)) {
194
+ const partial = wrunPresentIsPartial(tuple[C.present]);
195
+ if (partial && tuple.slice(0, C.present).every((value) => value === 0)) {
196
+ marker = tuple;
197
+ continue;
198
+ }
199
+ const key = `${tuple[C.expiry]}|${tuple[C.strike]}|${tuple[C.side]}|${tuple[C.dteClass]}`;
200
+ const held = byKey.get(key);
201
+ if (held === undefined) {
202
+ byKey.set(key, [...tuple]);
203
+ continue;
204
+ }
205
+ for (let column = C.volAsk; column < C.present; column += 1)
206
+ held[column] += tuple[column];
207
+ if (partial)
208
+ held[C.present] = wrunPresentWithPartial(held[C.present]);
209
+ }
210
+ }
211
+ const tuples = [...byKey.values()].sort(compareWrunOptionStrikeFlowTuples);
212
+ if (marker === undefined)
213
+ return tuples;
214
+ if (tuples.length === 0)
215
+ return [marker];
216
+ tuples[0][C.present] = wrunPresentWithPartial(tuples[0][C.present]);
217
+ return tuples;
218
+ }
@@ -0,0 +1,365 @@
1
+ import { type LiveBucketVenue } from '../chart/live-bucket.util.js';
2
+ import { type OptionTradeDateChain, type OptionTradeDateClockRule } from '../options/option-trade-date.util.js';
3
+ import { type WrunOptionContractFlowRow } from './wrun-option-contract-flow.util.js';
4
+ import { type WrunOptionStrikeFlowGroup, type WrunOptionStrikeFlowKnobs } from './wrun-option-strike-flow-lane.util.js';
5
+ import { type WrunBackendTier, type WrunTierSegment } from './wrun-tier-grid.util.js';
6
+ export * from './wrun-option-strike-flow-lane.util.js';
7
+ /** The tuple's columns by name, in om's order (`WRUN_OPTION_CELL_COLUMNS.option_strike_flow`). */
8
+ export declare const WRUN_OPTION_STRIKE_FLOW_COLUMNS: readonly ["expiry_ms", "strike", "side_cp", "dte_class", "vol_ask", "vol_bid", "vol_mid", "vol_none", "vol_above_ask", "vol_below_bid", "prem_ask", "prem_bid", "prem_mid", "prem_none", "present"];
9
+ /** `dte_class`: 0 not split, 1 the 0DTE part, 2 the expiries after the trade date. */
10
+ export declare const WRUN_OPTION_STRIKE_FLOW_DTE_CLASS: Readonly<{
11
+ readonly whole: 0;
12
+ readonly zero: 1;
13
+ readonly later: 2;
14
+ }>;
15
+ /** `strike_rows`: 1 to 200 (om `WRUN_OPTION_STRIKE_ROWS_MAX`). */
16
+ export declare const WRUN_OPTION_STRIKE_ROWS_MAX = 200;
17
+ /** The scope word of each group (pb-common `OptionPrintAggScope` STRIKE 5, EXPIRY 6, EXPIRY_STRIKE 7). */
18
+ export declare const WRUN_OPTION_STRIKE_FLOW_SCOPE: Readonly<Record<WrunOptionStrikeFlowGroup, {
19
+ word: string;
20
+ id: number;
21
+ }>>;
22
+ /** pb-common enums the request names by number (the gateway decodes JSON with encoding/json): `BarAnchor`, `BarSpan`,
23
+ * `OptionExpiryClass`, `OptionDteBucket`, `OptionType`. */
24
+ export declare const WRUN_OPTION_READ_ENUM: Readonly<{
25
+ readonly anchorUtc: 0;
26
+ readonly anchorUsEquityRth: 1;
27
+ readonly spanSession: 1;
28
+ readonly expiryZeroDte: 1;
29
+ readonly expiryAfterToday: 2;
30
+ readonly dteZero: 1;
31
+ readonly dteAfterZero: 5;
32
+ readonly put: 1;
33
+ readonly call: 2;
34
+ }>;
35
+ /** The tier a key names among the class's tiers, or undefined. */
36
+ export declare function wrunOptionStrikeFlowTierOf(key: unknown): WrunBackendTier | undefined;
37
+ /**
38
+ * One input's knobs, validated as om's planner validates them (in its order), each refused by name
39
+ * (`wrun_option_knob_invalid`): `expiries`, `strike_window_pct`, `min_volume`, `span`, `history`, then `group`
40
+ * (required) and the knobs one group alone takes (`strike_window_pct` and `strike_rows` the strike and expiry_strike
41
+ * groups, `split_dte` and `fold_types` the strike group, "nearest:N" never the strike group), `strike_rows` (1 to 200),
42
+ * `split_dte` and `fold_types` (true or false). A knob that names a setting arrives as the setting's value (the
43
+ * planner's `resolveWrunOptionSettingKnobs`); a name still here is refused like any other value.
44
+ */
45
+ export declare function wrunOptionStrikeFlowKnobsOf(source: Readonly<Record<string, unknown>>, ctx: {
46
+ inputName: string;
47
+ sourceClass: string;
48
+ }): WrunOptionStrikeFlowKnobs;
49
+ /** The chart's bar grid as an ask carries it (live-bucket.util `liveBucketVenueOf`'s fields, plain strings): where the
50
+ * host bars a grouped read sums to open and close. */
51
+ export interface WrunOptionFlowBarGrid {
52
+ exchange?: string;
53
+ symbol?: string;
54
+ sessionType?: string;
55
+ transformations?: string;
56
+ }
57
+ /** The fields an ask names its bars in: the run's bar span (ms) and the chart's bar grid. */
58
+ export declare const WRUN_OPTION_FLOW_BAR_MS_FIELD = "barMs";
59
+ export declare const WRUN_OPTION_FLOW_BAR_GRID_FIELD = "barGrid";
60
+ /** The acquisition an `option_strike_flow` instance asks with (and the ask's tier and bars). */
61
+ export interface WrunOptionStrikeFlowAcquisition extends WrunOptionStrikeFlowKnobs {
62
+ /** The chain's underlying, upper case. */
63
+ coin: string;
64
+ /** The exchange the chain lists on, upper case ('' when the payload names none). */
65
+ exchange: string;
66
+ /** The ONE book read, upper case: the payload's, else the underlying's own series. */
67
+ book: string;
68
+ /** The tier key of the ask. */
69
+ tier?: string;
70
+ barMs?: number;
71
+ barGrid?: WrunOptionFlowBarGrid;
72
+ /** Today's first instant as the request names it under `history` "today" (wrun-option-contract-flow.util
73
+ * `WRUN_OPTION_FLOW_TODAY_FIELD`: the K control's, off the chart's newest bar). */
74
+ todayFromMs?: number;
75
+ }
76
+ /** The bars an ask names (both flow classes' K controls send them, option-flow-bars.util): the run's bar span and the
77
+ * chart's bar grid, each absent when the ask carries none. */
78
+ export declare function wrunOptionFlowBarsOf(payload: Readonly<Record<string, unknown>> | null | undefined): {
79
+ barMs?: number;
80
+ barGrid?: WrunOptionFlowBarGrid;
81
+ };
82
+ /** A payload as its acquisition (knob fields that are not valid read absent). */
83
+ export declare function wrunOptionStrikeFlowAcquisitionOf(payload: Readonly<Record<string, unknown>> | null | undefined): WrunOptionStrikeFlowAcquisition;
84
+ /** Whether a payload is an `option_strike_flow` lane ask the K control serves: a coin, a group, one of the class's tiers
85
+ * and a chain whose OPRA stamp holds (the print classes' one rule); any other caller is declined, fail closed. */
86
+ export declare function isWrunOptionStrikeFlowAsk(payload: Readonly<Record<string, unknown>> | null | undefined): boolean;
87
+ /** The chain an acquisition's rows are dated on (option-trade-date.util). */
88
+ export declare function wrunOptionFlowClockOf(acquisition: {
89
+ exchange: string;
90
+ coin: string;
91
+ }): OptionTradeDateClockRule;
92
+ /**
93
+ * How a read's rows group, on the gateway's bar rule (contract 3.2 and 3.4) or the chart's own landing:
94
+ * - `bars`: `barSeconds` on an anchor (UTC: `ts - ts % B`; US_EQUITY_RTH: the 09:30 New York lattice, buckets outside
95
+ * the cash session dropped), exactly the chart's bars;
96
+ * - `session`: one group per trade date: on a New York clock the regular session's (RTH buckets only, stamped at its
97
+ * 09:30 open), on a UTC clock the UTC date's (stamped 00:00Z);
98
+ * - `host`: the chart's own bars (`wrunHostBarOf`) or, with a session span on a clock the gateway draws no session
99
+ * for (a CME Globex trade date), the clock's trade dates stamped at each date's first instant: groups the gateway
100
+ * cannot draw, so they are folded in the browser.
101
+ */
102
+ export type WrunOptionFlowGrouping = {
103
+ kind: 'bars';
104
+ barSeconds: number;
105
+ barAnchor: number;
106
+ } | {
107
+ kind: 'session';
108
+ barAnchor: number;
109
+ } | {
110
+ kind: 'host';
111
+ session: boolean;
112
+ };
113
+ /**
114
+ * The grouping of one ask's window `[fromMs, toMs)` at a tier: a session span groups by trade date (the gateway's
115
+ * session where the clock has one), else a chart bar of a day reads its trade date's session where that session lands
116
+ * on it (a daily bar holding one New York regular session, the cash session's buckets alone, or one UTC date), else the
117
+ * chart's bars when the gateway's bars are exactly them (every tier bucket of the window lands on the host bar the
118
+ * gateway's bar opens on: the UTC floor, or the 09:30 New York lattice of a regular-session stock chart's 45m to 12h
119
+ * bars, the tier dividing 30 minutes, a bucket outside the cash session reaching no bar on either side), else the
120
+ * chart's own bars, folded in the browser.
121
+ */
122
+ export declare function wrunOptionFlowGrouping(args: {
123
+ barMs: number | undefined;
124
+ barGrid: LiveBucketVenue | undefined;
125
+ tierMs: number;
126
+ fromMs: number;
127
+ toMs: number;
128
+ session: boolean;
129
+ clock: OptionTradeDateClockRule;
130
+ }): WrunOptionFlowGrouping;
131
+ /**
132
+ * The widest UTC groups a read of `[fromMs, toMs)` at a tier may be summed or picked to so that its answer lands on the
133
+ * chart exactly as the tier's buckets do, where the chart's bars themselves are no grouping the gateway draws (an RTH
134
+ * CME chart's hourly bars open at 13:30Z; a daily bar takes no session pick): the widest whole-minute width that divides
135
+ * a day, divides the host bar (or a day, for a bar of a day or longer), is a multiple of the tier and is a day only on
136
+ * the DAY tier, the window on its boundaries, such that every tier bucket's group opens on a bucket that lands on the
137
+ * bucket's own host bar (`wrunHostBarOf` over the chart's bar grid), or both on none (a Globex night on an RTH chart).
138
+ * One row per group, a few per host bar, never a row that straddles two host bars or a session's edge, so a consumer
139
+ * that lands each host bar on its newest group row lands it where today's buckets land it. Undefined when no width
140
+ * holds or the window cannot be walked (off the tier's grid, more than `NESTED_PROOF_MAX_BUCKETS` buckets). The one
141
+ * proof `options_flow` and the per-bar pick read (option-print-agg-scope.worker.util `wrunOptionsFlowBars`,
142
+ * option-strikes.worker.util `optionLaneBarGrouping`); `wrunOptionFlowGrouping` is the exact decider beside it.
143
+ */
144
+ export declare function wrunOptionNestedUtcBars(args: {
145
+ barMs: number | undefined;
146
+ barGrid: LiveBucketVenue | null | undefined;
147
+ tierMs: number;
148
+ fromMs: number;
149
+ toMs: number;
150
+ }): {
151
+ barSeconds: number;
152
+ barAnchor: number;
153
+ } | undefined;
154
+ /** The trade-date group a bucket stamped `ts` sums into under the gateway's session (contract 3.4): on RTH the New York
155
+ * date's 09:30 open for a bucket inside the cash session (null outside it), on UTC the UTC date's 00:00Z. */
156
+ export declare function wrunOptionFlowSessionStampMs(ts: number, barAnchor: number): number | null;
157
+ /**
158
+ * The stamp of the group a bucket stamped `ts` sums into, on the browser's side of a grouping (the fold's): the
159
+ * gateway's bar or session rule (`bars`, `session`), the chart's own bar, or a trade date of the clock stamped at its
160
+ * first instant (`host` with a session span); null for a bucket no group holds (off the cash session on RTH).
161
+ */
162
+ export declare function wrunOptionFlowGroupStampMs(ts: number, grouping: WrunOptionFlowGrouping, bars: {
163
+ barMs: number | undefined;
164
+ barGrid: LiveBucketVenue | undefined;
165
+ clock: OptionTradeDateClockRule;
166
+ }): number | null;
167
+ /**
168
+ * The window a session grouping reads: from the first instant of the trade date holding `fromMs` to the first instant
169
+ * of the trade date after the one holding `toMs - 1` (whole sessions, so a session's row sums every bucket of it
170
+ * whichever asked bars hold it), on the clock (the New York date for an RTH session: its midnights sit outside the
171
+ * cash session, a boundary the gateway takes).
172
+ */
173
+ export declare function wrunOptionFlowSessionWindow(fromMs: number, toMs: number, clock: OptionTradeDateClockRule): {
174
+ fromMs: number;
175
+ toMs: number;
176
+ };
177
+ /**
178
+ * The part of an ask `[fromMs, toMs)` that `history` "today" reads (both flow classes' worker twins): from the first
179
+ * host bar ending after today's first instant, else from that instant on the tier's grid, to the ask's end. Today's
180
+ * first instant is the request's (`todayFromMs`, wrun-option-contract-flow.util `WRUN_OPTION_FLOW_TODAY_FIELD`): the
181
+ * trade date of the chart's newest bar on the chain's venue clock, which the K control names off the chart's bars
182
+ * (option-flow-bars.util `optionFlowTodayFields`), so a weekend, a holiday or a morning before the first print reads
183
+ * the last session the chart shows. Null when the ask holds nothing of today (an ask of older bars: quiet), and when
184
+ * the request names no today: no clock stands in for the chart's bars (a server clock reads Saturday on a Saturday).
185
+ */
186
+ export declare function wrunOptionFlowTodayWindow(args: {
187
+ fromMs: number;
188
+ toMs: number;
189
+ todayFromMs: number | undefined;
190
+ tierMs: number;
191
+ barMs: number | undefined;
192
+ barGrid: LiveBucketVenue | undefined;
193
+ }): {
194
+ fromMs: number;
195
+ toMs: number;
196
+ } | null;
197
+ /** The `optionRead` of a grouped read (pb-common `OptionReadShape`, contract 2.2: JSON names, enums as numbers). */
198
+ export interface WrunOptionFlowReadShape {
199
+ barSeconds?: number;
200
+ barAnchor?: number;
201
+ span?: number;
202
+ expiryClass?: number;
203
+ nearestExpiries?: number;
204
+ strikeWindowPct?: number;
205
+ strikeRows?: number;
206
+ minVolume?: number;
207
+ splitDte?: boolean;
208
+ foldTypes?: boolean;
209
+ minBarPremium?: number;
210
+ }
211
+ /** The grouping's own fields: its bars, or its session on its anchor. */
212
+ export declare function wrunOptionFlowGroupingShape(grouping: Extract<WrunOptionFlowGrouping, {
213
+ kind: 'bars' | 'session';
214
+ }>): WrunOptionFlowReadShape;
215
+ /** The `expiryClass` an `expiries` word asks (0DTE or after today), else none. */
216
+ export declare function wrunOptionFlowExpiryClassOf(expiries: string | undefined): number | undefined;
217
+ /**
218
+ * The `optionRead` of a grouped strike flow read (contract 3.1 and 6.4): the grouping, the expiry class, and the knobs
219
+ * the group's scope takes (STRIKE: the window, the strike rows, the volume floor, the split, the fold; EXPIRY: the
220
+ * nearest expiries and the volume floor; EXPIRY_STRIKE: the nearest expiries, the window, the strike rows and the
221
+ * volume floor). The planner refuses every other combination by name, so each field the read names is taken.
222
+ */
223
+ export declare function wrunOptionStrikeFlowOptionRead(knobs: WrunOptionStrikeFlowKnobs, grouping: Extract<WrunOptionFlowGrouping, {
224
+ kind: 'bars' | 'session';
225
+ }>): WrunOptionFlowReadShape;
226
+ /** The tiers the gateway groups a CONTRACT read at (contract 6.3: the contract tiers at 1m and 5m, the per-contract
227
+ * 30-minute view); an ask at any other tier (the hour, the day) is read as today. */
228
+ export declare const WRUN_OPTION_CONTRACT_GROUPED_TIERS: readonly string[];
229
+ /** The per-contract 30-minute view a session-span CONTRACT read asks (contract 6.3: `option_print_agg_bar_30m`, kept 30
230
+ * days). */
231
+ export declare const WRUN_OPTION_CONTRACT_SESSION_TIER: Readonly<WrunBackendTier>;
232
+ /** The 30-minute tier of a strike flow group: its coarsest (kept, or 30 days on `expiry_strike`). */
233
+ export declare function wrunOptionStrikeFlowSessionTierOf(group: WrunOptionStrikeFlowGroup): WrunBackendTier;
234
+ /**
235
+ * The tier a grouped read asks (contract 6.8: "span session reads 30m"). A session grouping reads `sessionTier`, the
236
+ * 30-minute view that holds each session whole at the fewest rows (one SPY session, contract section 1: STRIKE 6,564
237
+ * rows at 30m against 23,271 at 5m; CONTRACT 30,239 against 76,740), where that view still holds the window's start
238
+ * (`retentionMs` back from `nowMs`). Any other grouping, and a window older than the view keeps, reads the ask's own
239
+ * tier. A session row is stamped by its anchor whatever tier sums it, so it lands where the ask's tier's would.
240
+ */
241
+ export declare function wrunOptionFlowGroupedTier(grouping: WrunOptionFlowGrouping, askTier: WrunBackendTier, sessionTier: WrunBackendTier, fromMs: number, nowMs: number): WrunBackendTier;
242
+ /**
243
+ * The `optionRead` of a grouped CONTRACT read (contract 3.1 and 6.4: steps 1, 2 and the premium floor of 7): the
244
+ * grouping, the 0DTE class of `expiries` "0dte", and `minBarPremium` from `min_premium` (a contract's group premium, the
245
+ * four sides' sum). Every other knob of `option_contract_flow` stays the fold's, as today.
246
+ */
247
+ export declare function wrunOptionContractFlowOptionRead(acquisition: {
248
+ expiries?: string;
249
+ minPremium?: number;
250
+ }, grouping: Extract<WrunOptionFlowGrouping, {
251
+ kind: 'bars' | 'session';
252
+ }>): WrunOptionFlowReadShape;
253
+ /**
254
+ * Whether a CONTRACT row is a "0dte" row on today's read of `option_contract_flow` (the grouped read classes rows
255
+ * itself): its expiry falls on the trade date of its bucket on its chain's venue clock (option-trade-date.util, the data
256
+ * plane's `option_venue_clocks`), read at the bucket's middle so a UTC day bucket reads its own session's date.
257
+ */
258
+ export declare function wrunOptionContractFlowRowIsZeroDte(row: WrunOptionContractFlowRow, tierMs: number, chain: OptionTradeDateChain): boolean;
259
+ /** Why a grouped row was dropped (counted, never a made-up value). */
260
+ export type WrunOptionStrikeFlowDrop = 'time' | 'scope' | 'value';
261
+ /** One grouped row's columns as the worker reads them (NaN or absent: unset). */
262
+ export interface WrunOptionStrikeFlowGroupedRecord {
263
+ scope?: number;
264
+ strike?: number;
265
+ expiryMs?: number;
266
+ optionType?: number;
267
+ dteBucket?: number;
268
+ volAsk?: number;
269
+ volBid?: number;
270
+ volMid?: number;
271
+ volNone?: number;
272
+ volAboveAsk?: number;
273
+ volBelowBid?: number;
274
+ premAsk?: number;
275
+ premBid?: number;
276
+ premMid?: number;
277
+ premNone?: number;
278
+ }
279
+ /**
280
+ * One grouped STRIKE, EXPIRY or EXPIRY_STRIKE row as the class's tuple (contract 6.5): `expiry_ms` 0 on a strike row,
281
+ * `strike` 0 on an expiry row, `side_cp` from the series' option type (0 with `fold_types`), `dte_class` from
282
+ * `dte_bucket` (ZERO 1, AFTER_ZERO 2, unset 0), every unset value 0. A row of another scope is dropped.
283
+ */
284
+ export declare function wrunOptionStrikeFlowTupleOf(record: WrunOptionStrikeFlowGroupedRecord, group: WrunOptionStrikeFlowGroup): number[] | WrunOptionStrikeFlowDrop;
285
+ /** One CONTRACT row of a bucket as the fold reads it: its bucket, its contract and its sums (absent sums are 0). */
286
+ export interface WrunOptionStrikeFlowContractRow {
287
+ bucketMs: number;
288
+ expiryMs: number;
289
+ strike: number;
290
+ /** +1 a call, -1 a put. */
291
+ side: number;
292
+ volAsk: number;
293
+ volBid: number;
294
+ volMid: number;
295
+ volNone: number;
296
+ volAboveAsk: number;
297
+ volBelowBid: number;
298
+ premAsk: number;
299
+ premBid: number;
300
+ premMid: number;
301
+ premNone: number;
302
+ /** Contracts traded (`sum_size`): the volume floor's measure. */
303
+ sumSize: number;
304
+ /** Underlying price x contracts over the prints that carried one, and those contracts: the spot's sums. */
305
+ sumSpotSize: number;
306
+ sizePriced: number;
307
+ }
308
+ /**
309
+ * One group's tuples (a chart bar's or a trade date's) from its CONTRACT rows, by section 6.4's rules in order, the
310
+ * gateway's own (tsdb-gateway `option_print_agg_group.go`):
311
+ * 1. the expiry class per row: 0DTE when the contract expires on the trade date of the row's bucket (its middle) on the
312
+ * chain's venue clock (`zero`, computed by the caller: `wrunOptionStrikeFlowZeroDte`); `expiries` "0dte" keeps those,
313
+ * "after_today" the others;
314
+ * 2. the sums per key: (side, strike, class) for the strike group, (side, expiry) for the expiry group, (side, strike,
315
+ * expiry) for both;
316
+ * 3. the spot: the group's sum_spot_size over its size_priced (every kept row: all strikes, expiries and sides), unset
317
+ * when nothing was priced;
318
+ * 4. `nearest:N` (expiry and expiry_strike): the N smallest distinct expiries of the group;
319
+ * 5. `strike_window_pct` (strike and expiry_strike): the strikes within that many percent of the spot;
320
+ * 6. `strike_rows` R: the R distinct strikes nearest the spot after the window (ties: the lower strike); 5 and 6
321
+ * skipped when the spot is unset or not above 0;
322
+ * 7. `min_volume`: a key's contracts at least the floor (on the strike group the side's strike over both classes);
323
+ * 8. the shape: `split_dte` one row per class part, else the parts summed; `fold_types` one row per strike, calls and
324
+ * puts summed with the put's sides crossed (the bullish side in the ask columns).
325
+ * Sorted by expiry, strike, side (calls first), class.
326
+ */
327
+ export declare function foldWrunOptionStrikeFlowGroup(rows: ReadonlyArray<WrunOptionStrikeFlowContractRow & {
328
+ zero: boolean;
329
+ }>, knobs: WrunOptionStrikeFlowKnobs): number[][];
330
+ /** Whether a CONTRACT row is a 0DTE row: its expiry trades on the trade date of its bucket's middle (a UTC day bucket
331
+ * reads its own session's date) on the chain's venue clock. */
332
+ export declare function wrunOptionStrikeFlowZeroDte(row: Pick<WrunOptionStrikeFlowContractRow, 'bucketMs' | 'expiryMs'>, tierMs: number, clock: OptionTradeDateClockRule): boolean;
333
+ /** One contract-tier read of the fold: a tier and its span. */
334
+ export type WrunOptionStrikeFlowFoldRead = WrunTierSegment;
335
+ /**
336
+ * Today's ask for one strike flow ask's host bars, before any fetch, as the `option_contract_flow` lane plans its own
337
+ * (the read the class is folded from while the gateway does not group it): each bar's coarsest contract tier that fits,
338
+ * retains and already serves it (`WRUN_OPTION_PRINT_AGG_TIERS`, the bars' session grid), and the NEWEST bars whose
339
+ * projected contract rows (`wrunOptionContractFlowBarRows`, the chain's plane) fit the source answer budget, counted
340
+ * from the clock: the bars after the ask (a later ask's) are counted first, so every ask of one window keeps the same
341
+ * bars. A newest bar that cannot fit alone is skipped (a forming day read from minutes); from the first bar that fits,
342
+ * a bar that would pass the budget stops the walk. The kept bars are read per run of one tier (`reads`); every asked
343
+ * bar outside them is partial. `newerBarOpens` are the host bars after the ask, up to the clock.
344
+ */
345
+ export declare function wrunOptionStrikeFlowFoldPlan(args: {
346
+ barOpens: readonly number[];
347
+ newerBarOpens: readonly number[];
348
+ barMs: number;
349
+ barGrid: LiveBucketVenue | undefined;
350
+ nowMs: number;
351
+ acquisition: Readonly<Record<string, unknown>>;
352
+ }): {
353
+ reads: WrunOptionStrikeFlowFoldRead[];
354
+ partialBars: number[];
355
+ keptFromMs: number;
356
+ keptToMs: number;
357
+ };
358
+ /** The host bars `[fromMs, toMs)` holds on the chart's grid, ascending (`liveBucketStartsInRange` over the grid). */
359
+ export declare function wrunOptionFlowHostBars(fromMs: number, toMs: number, barMs: number, barGrid: LiveBucketVenue | undefined): number[];
360
+ /** A stamp's tuples packed as the worker hands them over: one Float64Array of `count x WIDTH` values. */
361
+ export declare function packWrunOptionStrikeFlowTuples(tuples: ReadonlyArray<ArrayLike<number>>): Float64Array;
362
+ /** The marker of a partial bar holding no tuple (every value 0, bit 14 of `present`). */
363
+ export declare function wrunOptionStrikeFlowPartialMarker(): number[];
364
+ /** The bytes one answered tuple weighs in every estimate of a source answer. */
365
+ export declare const WRUN_OPTION_STRIKE_FLOW_TUPLE_BYTES: number;