@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
@@ -15,19 +15,36 @@
15
15
  * - a COIN or MARKET row is keyed by option type, `dte_bucket` (1 the print's trade date, 2 one to seven days, 3 eight
16
16
  * to thirty-five, 4 later; 0 a print past its expiry) and `moneyness` (+1 out of the money, -1 in the money, unset
17
17
  * without an underlying price); a VENUE row by option type and issue type. Side is never a dimension: every row
18
- * splits its totals by side in its `_ask`, `_bid`, `_mid` and `_none` columns (off OPRA the taker's side: no mid).
18
+ * splits its totals by side in its `_ask`, `_bid`, `_mid` and `_none` columns (off OPRA the taker's side: no mid);
19
+ * - PRINTS rows of one underlying (`PRINTS`, the coin beside it; OPTLOAD G4): its prints at or above the ask's premium
20
+ * floor and within its `max_dte`, summed per bar and option type in the COIN columns.
21
+ *
22
+ * OPTLOAD (OPTLOAD-READ-CONTRACT sections 5 and 7): the gateway groups the rows to the chart's bar, filters the split
23
+ * and folds the dimensions (`DataRequest.optionRead`), so an answer is one row per (bar, option type) of the asked split;
24
+ * the worker half builds that shape (option-print-agg-scope.worker.util `wrunOptionsFlowReadShape`).
19
25
  *
20
26
  * Import-free: a lane file stays light at module load and the worker twin reads it too.
21
27
  */
22
- /** The fields, in the kit's order (om `WRUN_OPTIONS_FLOW_FIELDS`); field i is lane row column i + 1. */
23
- export declare const WRUN_OPTIONS_FLOW_FIELDS: readonly ["call_prem_ask", "call_prem_bid", "call_prem_mid", "call_prem_none", "put_prem_ask", "put_prem_bid", "put_prem_mid", "put_prem_none", "call_prem_total", "put_prem_total", "call_contracts_ask", "call_contracts_bid", "call_contracts_mid", "call_contracts_none", "put_contracts_ask", "put_contracts_bid", "put_contracts_mid", "put_contracts_none", "call_contracts_total", "put_contracts_total", "net_call_prem", "net_put_prem", "net_call_prem_capped", "net_put_prem_capped", "share_delta_ask", "share_delta_bid", "vega_ask", "vega_bid", "prints", "vol_above_ask", "vol_below_bid", "n_priced"];
28
+ /** The fields, in the kit's order (om `WRUN_OPTIONS_FLOW_FIELDS`, kit 0.89.0); field i is lane row column i + 1. The
29
+ * last four split the contracts printed outside the quote by option type (appended, so every earlier field keeps its
30
+ * column; 0 off OPRA, as `vol_above_ask` is). */
31
+ export declare const WRUN_OPTIONS_FLOW_FIELDS: readonly ["call_prem_ask", "call_prem_bid", "call_prem_mid", "call_prem_none", "put_prem_ask", "put_prem_bid", "put_prem_mid", "put_prem_none", "call_prem_total", "put_prem_total", "call_contracts_ask", "call_contracts_bid", "call_contracts_mid", "call_contracts_none", "put_contracts_ask", "put_contracts_bid", "put_contracts_mid", "put_contracts_none", "call_contracts_total", "put_contracts_total", "net_call_prem", "net_put_prem", "net_call_prem_capped", "net_put_prem_capped", "share_delta_ask", "share_delta_bid", "vega_ask", "vega_bid", "prints", "vol_above_ask", "vol_below_bid", "n_priced", "call_contracts_above_ask", "call_contracts_below_bid", "put_contracts_above_ask", "put_contracts_below_bid"];
24
32
  export type WrunOptionsFlowField = (typeof WRUN_OPTIONS_FLOW_FIELDS)[number];
25
33
  /** The fields scope `venue` serves (om `WRUN_OPTIONS_FLOW_VENUE_FIELDS`): the venue rows carry premium by side,
26
34
  * prints and the contracts' sum, no side, DTE or moneyness split. */
27
35
  export declare const WRUN_OPTIONS_FLOW_VENUE_FIELDS: readonly WrunOptionsFlowField[];
28
- /** `scope` (om `WRUN_OPTIONS_FLOW_SCOPES`); an absent knob reads `ticker`. */
29
- export declare const WRUN_OPTIONS_FLOW_SCOPES: readonly ["ticker", "market", "equity", "etf", "index", "venue"];
36
+ /** `scope` (om `WRUN_OPTIONS_FLOW_SCOPES`, kit 0.89.0); an absent knob reads `ticker`. `prints` (OPTLOAD G4) sums the
37
+ * chart underlying's prints at or above `min_premium` (required there) and within `max_dte`. */
38
+ export declare const WRUN_OPTIONS_FLOW_SCOPES: readonly ["ticker", "market", "equity", "etf", "index", "venue", "prints"];
30
39
  export type WrunOptionsFlowScope = (typeof WRUN_OPTIONS_FLOW_SCOPES)[number];
40
+ /** The raw-symbol word of scope `prints` (the gateway's PRINTS scope, the coin beside it). */
41
+ export declare const WRUN_OPTIONS_FLOW_PRINTS_WORD = "PRINTS";
42
+ /** Scope `prints`' `max_dte`: whole days to expiry, 0 to 3,650 (0, like an absent knob, keeps every expiry; om
43
+ * `WRUN_OPTION_MAX_DTE_DAYS`). */
44
+ export declare const WRUN_OPTIONS_FLOW_MAX_DTE_DAYS = 3650;
45
+ /** The named refusal of a scope `prints` read the gateway does not serve yet (it refused the read's `optionRead` by
46
+ * name): a prints read has no ungrouped ask to fall back to. */
47
+ export declare const WRUN_OPTIONS_FLOW_PRINTS_UNSERVED_CODE = "options-flow-prints-unserved";
31
48
  /** The scopes US listed options alone serve (an issue type of the US market, R7c C7-2): unserved off the OPRA plane. */
32
49
  export declare const WRUN_OPTIONS_FLOW_OPRA_SCOPES: readonly WrunOptionsFlowScope[];
33
50
  /** `dte` (om `WRUN_OPTIONS_FLOW_DTE`); an absent knob reads `all`. */
@@ -67,12 +84,22 @@ export declare const WRUN_OPTIONS_FLOW_EXCHANGE_FIELD = "flowExchange";
67
84
  export declare const WRUN_OPTIONS_FLOW_BOOK_FIELD = "flowBook";
68
85
  export declare const WRUN_OPTIONS_FLOW_VENUES_FIELD = "flowVenues";
69
86
  export declare const WRUN_OPTIONS_FLOW_CONTINUOUS_FIELD = "flowContinuous";
87
+ /** The chart's bar grid as an ask carries it (`liveBucketVenueOf` over the chart's metadata, plain strings): where the
88
+ * host bars a grouped read sums to open and close (a regular-session stock chart's 09:30 New York bars, a CME chart's
89
+ * session lattice, the UTC floor elsewhere). */
90
+ export interface WrunOptionsFlowBarGrid {
91
+ exchange?: string;
92
+ symbol?: string;
93
+ sessionType?: string;
94
+ transformations?: string;
95
+ }
70
96
  /** One acquisition: the payload the lane's plan answers and the K control forwards (plus the tier it is asked at). */
71
97
  export interface WrunOptionsFlowAsk {
72
98
  scope: WrunOptionsFlowScope;
73
99
  /** The exchange the chart's chain lists on (pb-common `Exchange` name): the read's venue unless `venues` names them. */
74
100
  exchange: string;
75
- /** A COIN read's underlying, upper case: every ticker read's, a crypto scope across venues' (the chart's coin). */
101
+ /** A COIN read's underlying, upper case: every ticker read's, a prints read's, a crypto scope across venues' (the
102
+ * chart's coin). */
76
103
  coin?: string;
77
104
  /** A crypto ticker read's ONE book (a series name, upper case), read as `COIN:<book>`; absent: every book. */
78
105
  book?: string;
@@ -80,13 +107,21 @@ export interface WrunOptionsFlowAsk {
80
107
  venues?: readonly string[];
81
108
  /** Scope `venue` on OPRA: the venue's Databento publisher id. */
82
109
  venueId?: number;
110
+ /** Scope `prints`: the premium floor in USD, above 0 (the gateway's `minQuoteAmount`). */
111
+ minPremium?: number;
112
+ /** Scope `prints`: the most days to expiry a summed print has, 1 to 3,650 (absent: every expiry). */
113
+ maxDte?: number;
83
114
  dte: WrunOptionsFlowDte;
84
115
  moneyness: WrunOptionsFlowMoneyness;
85
116
  tier: WrunOptionsFlowTier;
117
+ /** The host chart's bar span in ms (the run's interval): the bar a grouped read sums its rows to. */
118
+ barMs?: number;
119
+ /** The host chart's bar grid (absent: unknown, so the read is not grouped to the bar). */
120
+ barGrid?: WrunOptionsFlowBarGrid;
86
121
  }
87
122
  /** Whether an ask reads VENUE rows (scope `venue` on OPRA, by publisher id: no side, DTE or moneyness split); a crypto
88
123
  * scope `venue` reads its venue's COIN rows. */
89
124
  export declare function wrunOptionsFlowReadsVenueRows(ask: Pick<WrunOptionsFlowAsk, 'scope' | 'coin'>): boolean;
90
- /** The raw symbol an ask's read names: `COIN` for a read of one underlying (`COIN:<book>` when it names its ONE book),
91
- * `VENUE:<publisher id>` for an OPRA venue, else the scope's MARKET word. */
125
+ /** The raw symbol an ask's read names: `PRINTS` for scope `prints`, `COIN` for a read of one underlying (`COIN:<book>`
126
+ * when it names its ONE book), `VENUE:<publisher id>` for an OPRA venue, else the scope's MARKET word. */
92
127
  export declare function wrunOptionsFlowScopeSymbol(ask: Pick<WrunOptionsFlowAsk, 'scope' | 'coin' | 'book' | 'venueId'>): string;
@@ -15,11 +15,19 @@
15
15
  * - a COIN or MARKET row is keyed by option type, `dte_bucket` (1 the print's trade date, 2 one to seven days, 3 eight
16
16
  * to thirty-five, 4 later; 0 a print past its expiry) and `moneyness` (+1 out of the money, -1 in the money, unset
17
17
  * without an underlying price); a VENUE row by option type and issue type. Side is never a dimension: every row
18
- * splits its totals by side in its `_ask`, `_bid`, `_mid` and `_none` columns (off OPRA the taker's side: no mid).
18
+ * splits its totals by side in its `_ask`, `_bid`, `_mid` and `_none` columns (off OPRA the taker's side: no mid);
19
+ * - PRINTS rows of one underlying (`PRINTS`, the coin beside it; OPTLOAD G4): its prints at or above the ask's premium
20
+ * floor and within its `max_dte`, summed per bar and option type in the COIN columns.
21
+ *
22
+ * OPTLOAD (OPTLOAD-READ-CONTRACT sections 5 and 7): the gateway groups the rows to the chart's bar, filters the split
23
+ * and folds the dimensions (`DataRequest.optionRead`), so an answer is one row per (bar, option type) of the asked split;
24
+ * the worker half builds that shape (option-print-agg-scope.worker.util `wrunOptionsFlowReadShape`).
19
25
  *
20
26
  * Import-free: a lane file stays light at module load and the worker twin reads it too.
21
27
  */
22
- /** The fields, in the kit's order (om `WRUN_OPTIONS_FLOW_FIELDS`); field i is lane row column i + 1. */
28
+ /** The fields, in the kit's order (om `WRUN_OPTIONS_FLOW_FIELDS`, kit 0.89.0); field i is lane row column i + 1. The
29
+ * last four split the contracts printed outside the quote by option type (appended, so every earlier field keeps its
30
+ * column; 0 off OPRA, as `vol_above_ask` is). */
23
31
  export const WRUN_OPTIONS_FLOW_FIELDS = Object.freeze([
24
32
  'call_prem_ask',
25
33
  'call_prem_bid',
@@ -53,6 +61,10 @@ export const WRUN_OPTIONS_FLOW_FIELDS = Object.freeze([
53
61
  'vol_above_ask',
54
62
  'vol_below_bid',
55
63
  'n_priced',
64
+ 'call_contracts_above_ask',
65
+ 'call_contracts_below_bid',
66
+ 'put_contracts_above_ask',
67
+ 'put_contracts_below_bid',
56
68
  ]);
57
69
  /** The fields scope `venue` serves (om `WRUN_OPTIONS_FLOW_VENUE_FIELDS`): the venue rows carry premium by side,
58
70
  * prints and the contracts' sum, no side, DTE or moneyness split. */
@@ -63,8 +75,25 @@ export const WRUN_OPTIONS_FLOW_VENUE_FIELDS = Object.freeze([
63
75
  'put_contracts_total',
64
76
  'prints',
65
77
  ]);
66
- /** `scope` (om `WRUN_OPTIONS_FLOW_SCOPES`); an absent knob reads `ticker`. */
67
- export const WRUN_OPTIONS_FLOW_SCOPES = Object.freeze(['ticker', 'market', 'equity', 'etf', 'index', 'venue']);
78
+ /** `scope` (om `WRUN_OPTIONS_FLOW_SCOPES`, kit 0.89.0); an absent knob reads `ticker`. `prints` (OPTLOAD G4) sums the
79
+ * chart underlying's prints at or above `min_premium` (required there) and within `max_dte`. */
80
+ export const WRUN_OPTIONS_FLOW_SCOPES = Object.freeze([
81
+ 'ticker',
82
+ 'market',
83
+ 'equity',
84
+ 'etf',
85
+ 'index',
86
+ 'venue',
87
+ 'prints',
88
+ ]);
89
+ /** The raw-symbol word of scope `prints` (the gateway's PRINTS scope, the coin beside it). */
90
+ export const WRUN_OPTIONS_FLOW_PRINTS_WORD = 'PRINTS';
91
+ /** Scope `prints`' `max_dte`: whole days to expiry, 0 to 3,650 (0, like an absent knob, keeps every expiry; om
92
+ * `WRUN_OPTION_MAX_DTE_DAYS`). */
93
+ export const WRUN_OPTIONS_FLOW_MAX_DTE_DAYS = 3_650;
94
+ /** The named refusal of a scope `prints` read the gateway does not serve yet (it refused the read's `optionRead` by
95
+ * name): a prints read has no ungrouped ask to fall back to. */
96
+ export const WRUN_OPTIONS_FLOW_PRINTS_UNSERVED_CODE = 'options-flow-prints-unserved';
68
97
  /** The scopes US listed options alone serve (an issue type of the US market, R7c C7-2): unserved off the OPRA plane. */
69
98
  export const WRUN_OPTIONS_FLOW_OPRA_SCOPES = Object.freeze(['equity', 'etf', 'index']);
70
99
  /** `dte` (om `WRUN_OPTIONS_FLOW_DTE`); an absent knob reads `all`. */
@@ -110,9 +139,11 @@ export const WRUN_OPTIONS_FLOW_CONTINUOUS_FIELD = 'flowContinuous';
110
139
  export function wrunOptionsFlowReadsVenueRows(ask) {
111
140
  return ask.scope === 'venue' && ask.coin === undefined;
112
141
  }
113
- /** The raw symbol an ask's read names: `COIN` for a read of one underlying (`COIN:<book>` when it names its ONE book),
114
- * `VENUE:<publisher id>` for an OPRA venue, else the scope's MARKET word. */
142
+ /** The raw symbol an ask's read names: `PRINTS` for scope `prints`, `COIN` for a read of one underlying (`COIN:<book>`
143
+ * when it names its ONE book), `VENUE:<publisher id>` for an OPRA venue, else the scope's MARKET word. */
115
144
  export function wrunOptionsFlowScopeSymbol(ask) {
145
+ if (ask.scope === 'prints')
146
+ return WRUN_OPTIONS_FLOW_PRINTS_WORD;
116
147
  if (ask.scope === 'ticker' || ask.coin !== undefined)
117
148
  return ask.book !== undefined ? `COIN:${ask.book}` : 'COIN';
118
149
  if (ask.scope === 'venue')
@@ -123,6 +123,27 @@ export declare function packWrunOptionContractFlowRaws(raws: ReadonlyArray<Reado
123
123
  export declare const WRUN_OPTION_CONTRACT_FLOW_EXCHANGE_FIELD = "flowExchange";
124
124
  export declare const WRUN_OPTION_CONTRACT_FLOW_BOOK_FIELD = "flowBook";
125
125
  export declare const WRUN_OPTION_CONTRACT_FLOW_CONTINUOUS_FIELD = "flowContinuous";
126
+ /**
127
+ * `history` "today"'s field on a flow request (both flow classes, under one name): the first instant of today, the
128
+ * trade date of the chart's newest bar on the chain's venue clock (option-trade-date.util `optionTodayStartMsByClock`),
129
+ * named by the K control off the chart's bars (option-flow-bars.util `optionFlowTodayFields`), never off a clock. The
130
+ * worker twins read it (wrun-option-strike-flow.util `wrunOptionFlowTodayWindow`); a "today" request naming none
131
+ * reads nothing.
132
+ */
133
+ export declare const WRUN_OPTION_FLOW_TODAY_FIELD = "todayFromMs";
134
+ /** Today's first instant a request or an acquisition names (`WRUN_OPTION_FLOW_TODAY_FIELD`), else undefined. */
135
+ export declare function wrunOptionFlowTodayFromOf(record: Readonly<Record<string, unknown>> | null | undefined): number | undefined;
136
+ /**
137
+ * Whether a bar reads nothing under `history` "today", so a row budget projects it at no rows (both flow lanes'
138
+ * `rowBudget.barRows`, and the strike flow fold's plan): it ends at or before today's first instant as the acquisition
139
+ * names it (`WRUN_OPTION_FLOW_TODAY_FIELD`). An acquisition naming no today (the host's plan hands its projection no
140
+ * newest bar to date today by) holds no such bar: today is never dated off a clock, so a bar of the newest trade date
141
+ * the chart holds is never projected at nothing. An older bar is then projected like any other and may be left
142
+ * partial where the budget stops; it reads nothing either way.
143
+ */
144
+ export declare function wrunOptionFlowBarBeforeToday(bar: {
145
+ endMs: number;
146
+ }, acquisition: Readonly<Record<string, unknown>>): boolean;
126
147
  /** The acquisition an `option_contract_flow` instance asks with. */
127
148
  export interface WrunOptionContractFlowAcquisition {
128
149
  /** The chain's underlying, upper case: the key its plane files the rows under (the OPRA ticker, a crypto venue's
@@ -136,6 +157,14 @@ export interface WrunOptionContractFlowAcquisition {
136
157
  expiries?: string;
137
158
  strikeWindowPct?: number;
138
159
  minVolume?: number;
160
+ /** A contract's group premium floor (USD, the four sides' sum), "session" (a row set per trade date) and "today" (the
161
+ * newest trade date only): the worker twin's (OPTLOAD, kit 0.89.0). */
162
+ minPremium?: number;
163
+ span?: 'session';
164
+ history?: 'today';
165
+ /** Today's first instant as the request names it (`WRUN_OPTION_FLOW_TODAY_FIELD`: the K control's, off the chart's
166
+ * newest bar); an instance's own payload names none. */
167
+ todayFromMs?: number;
139
168
  /** The tier key of the ask (a fold reads the ask's own). */
140
169
  tier?: string;
141
170
  }
@@ -166,26 +195,38 @@ export interface WrunOptionContractFlowRow {
166
195
  * and counted.
167
196
  */
168
197
  export declare function wrunOptionContractFlowRowOf(point: Readonly<Record<string, unknown>> | null | undefined, series: Readonly<Record<string, unknown>> | null | undefined): WrunOptionContractFlowRow | WrunOptionContractFlowDrop;
169
- /**
170
- * Whether a contract row is a "0dte" row: its expiry falls on the trade date of its bucket, on the clock of the chain's
171
- * market (`tradeDay`, the trade date an instant falls on in days: the worker hands the chain summary's one rule,
172
- * option-contract-state.worker.util `optionChainTradeDay` over the chain's exchange: OPRA's New York date, a CME Group
173
- * exchange's Globex session date, a crypto venue's UTC date), read at the bucket's middle so a UTC day bucket reads its
174
- * own session's date.
175
- */
176
- export declare function wrunOptionContractFlowRowIsZeroDte(row: WrunOptionContractFlowRow, tierMs: number, tradeDay: (instantMs: number) => number): boolean;
177
198
  /** The raw tuples a bucket row holds (a packed block counts each of its tuples). */
178
199
  export declare function wrunOptionContractFlowRawCount(row: ReadonlyArray<unknown>): number;
200
+ /** One contract's sums over a group, its joined flags, and its newest last price's and IV's buckets. */
201
+ export interface WrunOptionContractFlowContractSum {
202
+ raw: number[];
203
+ flags: number;
204
+ /** The bucket of the last print price kept. */
205
+ lastAt: number;
206
+ ivAt: number;
207
+ }
208
+ /** Each contract's sums over raw tuples taken in bucket order (the backend's rollup): the fold's, and the worker twin's
209
+ * when it groups a read itself. `add` answers the contract's key, `spot` the tuples' contract-weighted underlying,
210
+ * `raws` each contract's summed raw tuple. */
211
+ export interface WrunOptionContractFlowSums {
212
+ add(at: number, source: ArrayLike<number>, offset: number): string;
213
+ spot(): number | undefined;
214
+ raws(): number[][];
215
+ sums(): WrunOptionContractFlowContractSum[];
216
+ }
217
+ /** A new accumulator of per-contract sums (`WrunOptionContractFlowSums`). */
218
+ export declare function wrunOptionContractFlowSums(): WrunOptionContractFlowSums;
179
219
  /**
180
220
  * One host bar's contract tuples from its buckets' raw rows (in bucket order), under the acquisition's knobs:
181
221
  * - every contract's sums over the bar, its last price from its newest bucket and its IV from its newest bucket that
182
- * had one;
222
+ * had one (`wrunOptionContractFlowSums`);
183
223
  * - `expiries: "nearest:N"`: the contracts of the bar's N nearest expiries (among every contract that traded);
184
224
  * - `strike_window_pct`: the strikes within that many percent of the bar's underlying, its contract-weighted price
185
225
  * over the bar's prints that carried one (sum_spot_size / size_priced over every contract row of the bar: the same
186
226
  * from any tier and any row order; a bar no priced print reached keeps every strike, there being nothing to judge
187
227
  * by);
188
228
  * - `min_volume`: a contract whose bar total contracts (`sum_size`) is below it is dropped.
189
- * Sorted by root, expiry, strike, then side.
229
+ * (`min_premium` and a session span are the worker twin's, before any row lands.) Sorted by root, expiry, strike, then
230
+ * side.
190
231
  */
191
232
  export declare function foldWrunOptionContractFlowBar(rows: ReadonlyArray<ReadonlyArray<unknown>>, acquisition: Readonly<Record<string, unknown>>): number[][];
@@ -35,6 +35,9 @@
35
35
  * to back, each the bucket's sums for one contract (`WRUN_OPTION_CONTRACT_FLOW_RAW_WIDTH` values;
36
36
  * `packWrunOptionContractFlowRaws`), handed to the page by transfer; the lane's per-bar fold reads the blocks in place
37
37
  * (a plain raw tuple reads the same), sums them per contract and applies the knobs that need the whole bar.
38
+ *
39
+ * OPTLOAD (kit 0.89.0): `span`, `history` and `min_premium`, read by the worker twin's grouped CONTRACT read and its
40
+ * fallback (wrun-option-strike-flow.util, off the boot path; docs/features/kscript/wrun/wrun-browser-runtime.md).
38
41
  */
39
42
  import { newYorkDayNumber, newYorkInstantMs } from '../options/option-symbol.util.js';
40
43
  import { KSCRIPT_SOURCE_ANSWER_CEILING_BYTES, kScriptSourceAnswerRows, } from '../chart/kscript-source-answer-budget.leaf.js';
@@ -213,7 +216,12 @@ const WRUN_OPTION_CONTRACT_FLOW_PROJECTIONS = Object.freeze({
213
216
  * No tier: none.
214
217
  */
215
218
  export function wrunOptionContractFlowBarRows(bar, nowMs, acquisition) {
216
- const plane = wrunLaneChainPlaneOf(wrunOptionContractFlowAcquisitionOf(acquisition).exchange);
219
+ const knobs = wrunOptionContractFlowAcquisitionOf(acquisition);
220
+ // `history` "today": a bar before today's first instant as the acquisition names it reads nothing, so it costs the
221
+ // budget nothing (never dated off `nowMs`: `wrunOptionFlowBarBeforeToday`).
222
+ if (wrunOptionFlowBarBeforeToday(bar, acquisition))
223
+ return 0;
224
+ const plane = wrunLaneChainPlaneOf(knobs.exchange);
217
225
  const projection = WRUN_OPTION_CONTRACT_FLOW_PROJECTIONS[plane];
218
226
  const perDay = bar.tier === undefined ? undefined : projection.dayRows[bar.tier.key];
219
227
  if (perDay === undefined)
@@ -277,14 +285,43 @@ const RAW_FLAG = Object.freeze({ shareDeltaAsk: 1, shareDeltaBid: 2, ivLast: 4 }
277
285
  export const WRUN_OPTION_CONTRACT_FLOW_EXCHANGE_FIELD = 'flowExchange';
278
286
  export const WRUN_OPTION_CONTRACT_FLOW_BOOK_FIELD = 'flowBook';
279
287
  export const WRUN_OPTION_CONTRACT_FLOW_CONTINUOUS_FIELD = 'flowContinuous';
288
+ /**
289
+ * `history` "today"'s field on a flow request (both flow classes, under one name): the first instant of today, the
290
+ * trade date of the chart's newest bar on the chain's venue clock (option-trade-date.util `optionTodayStartMsByClock`),
291
+ * named by the K control off the chart's bars (option-flow-bars.util `optionFlowTodayFields`), never off a clock. The
292
+ * worker twins read it (wrun-option-strike-flow.util `wrunOptionFlowTodayWindow`); a "today" request naming none
293
+ * reads nothing.
294
+ */
295
+ export const WRUN_OPTION_FLOW_TODAY_FIELD = 'todayFromMs';
296
+ /** Today's first instant a request or an acquisition names (`WRUN_OPTION_FLOW_TODAY_FIELD`), else undefined. */
297
+ export function wrunOptionFlowTodayFromOf(record) {
298
+ const value = record?.[WRUN_OPTION_FLOW_TODAY_FIELD];
299
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
300
+ }
301
+ /**
302
+ * Whether a bar reads nothing under `history` "today", so a row budget projects it at no rows (both flow lanes'
303
+ * `rowBudget.barRows`, and the strike flow fold's plan): it ends at or before today's first instant as the acquisition
304
+ * names it (`WRUN_OPTION_FLOW_TODAY_FIELD`). An acquisition naming no today (the host's plan hands its projection no
305
+ * newest bar to date today by) holds no such bar: today is never dated off a clock, so a bar of the newest trade date
306
+ * the chart holds is never projected at nothing. An older bar is then projected like any other and may be left
307
+ * partial where the budget stops; it reads nothing either way.
308
+ */
309
+ export function wrunOptionFlowBarBeforeToday(bar, acquisition) {
310
+ if (acquisition.history !== 'today')
311
+ return false;
312
+ const todayFromMs = wrunOptionFlowTodayFromOf(acquisition);
313
+ return todayFromMs !== undefined && bar.endMs <= todayFromMs;
314
+ }
280
315
  /** An instance's payload as its acquisition (knob fields that are not valid read absent). */
281
316
  export function wrunOptionContractFlowAcquisitionOf(extras) {
282
317
  const positive = (value) => typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : undefined;
283
318
  const upper = (value) => (typeof value === 'string' ? value.trim().toUpperCase() : '');
284
319
  const strikeWindowPct = positive(extras?.strikeWindowPct);
285
320
  const minVolume = positive(extras?.minVolume);
321
+ const minPremium = positive(extras?.minPremium);
286
322
  const coin = upper(extras?.coin);
287
323
  const book = upper(extras?.[WRUN_OPTION_CONTRACT_FLOW_BOOK_FIELD]);
324
+ const todayFromMs = wrunOptionFlowTodayFromOf(extras);
288
325
  return {
289
326
  coin,
290
327
  exchange: upper(extras?.[WRUN_OPTION_CONTRACT_FLOW_EXCHANGE_FIELD]),
@@ -292,6 +329,10 @@ export function wrunOptionContractFlowAcquisitionOf(extras) {
292
329
  ...(typeof extras?.expiries === 'string' ? { expiries: extras.expiries } : {}),
293
330
  ...(strikeWindowPct !== undefined ? { strikeWindowPct } : {}),
294
331
  ...(minVolume !== undefined ? { minVolume } : {}),
332
+ ...(minPremium !== undefined ? { minPremium } : {}),
333
+ ...(extras?.span === 'session' ? { span: 'session' } : {}),
334
+ ...(extras?.history === 'today' ? { history: 'today' } : {}),
335
+ ...(extras?.history === 'today' && todayFromMs !== undefined ? { todayFromMs } : {}),
295
336
  ...(typeof extras?.tier === 'string' ? { tier: extras.tier } : {}),
296
337
  };
297
338
  }
@@ -416,17 +457,6 @@ export function wrunOptionContractFlowRowOf(point, series) {
416
457
  ],
417
458
  };
418
459
  }
419
- /**
420
- * Whether a contract row is a "0dte" row: its expiry falls on the trade date of its bucket, on the clock of the chain's
421
- * market (`tradeDay`, the trade date an instant falls on in days: the worker hands the chain summary's one rule,
422
- * option-contract-state.worker.util `optionChainTradeDay` over the chain's exchange: OPRA's New York date, a CME Group
423
- * exchange's Globex session date, a crypto venue's UTC date), read at the bucket's middle so a UTC day bucket reads its
424
- * own session's date.
425
- */
426
- export function wrunOptionContractFlowRowIsZeroDte(row, tierMs, tradeDay) {
427
- const middle = row.bucketMs + Math.floor(Math.max(0, tierMs) / 2);
428
- return tradeDay(middle) === tradeDay(row.raw[WRUN_OPTION_CONTRACT_FLOW_RAW.expiry]);
429
- }
430
460
  /** Whether a cell is a raw contract tuple: exactly the raw width of finite numbers. */
431
461
  function isRawTuple(cell) {
432
462
  return (Array.isArray(cell) &&
@@ -470,7 +500,8 @@ export function wrunOptionContractFlowRawCount(row) {
470
500
  });
471
501
  return count;
472
502
  }
473
- /** The raw columns a contract's bar sums add up (the rest are its identity, its newest price or IV, its flags). */
503
+ /** The raw columns a contract's sums add up (the rest are its identity, its newest price or IV, its flags), the spot's
504
+ * two sums among them. */
474
505
  const SUMMED_RAW_COLUMNS = [
475
506
  WRUN_OPTION_CONTRACT_FLOW_RAW.volAsk,
476
507
  WRUN_OPTION_CONTRACT_FLOW_RAW.volBid,
@@ -482,30 +513,19 @@ const SUMMED_RAW_COLUMNS = [
482
513
  WRUN_OPTION_CONTRACT_FLOW_RAW.shareDeltaBid,
483
514
  WRUN_OPTION_CONTRACT_FLOW_RAW.sumPxSize,
484
515
  WRUN_OPTION_CONTRACT_FLOW_RAW.sumSize,
516
+ WRUN_OPTION_CONTRACT_FLOW_RAW.sumSpotSize,
485
517
  WRUN_OPTION_CONTRACT_FLOW_RAW.volAboveAsk,
486
518
  WRUN_OPTION_CONTRACT_FLOW_RAW.volBelowBid,
519
+ WRUN_OPTION_CONTRACT_FLOW_RAW.sizePriced,
487
520
  ];
488
- /**
489
- * One host bar's contract tuples from its buckets' raw rows (in bucket order), under the acquisition's knobs:
490
- * - every contract's sums over the bar, its last price from its newest bucket and its IV from its newest bucket that
491
- * had one;
492
- * - `expiries: "nearest:N"`: the contracts of the bar's N nearest expiries (among every contract that traded);
493
- * - `strike_window_pct`: the strikes within that many percent of the bar's underlying, its contract-weighted price
494
- * over the bar's prints that carried one (sum_spot_size / size_priced over every contract row of the bar: the same
495
- * from any tier and any row order; a bar no priced print reached keeps every strike, there being nothing to judge
496
- * by);
497
- * - `min_volume`: a contract whose bar total contracts (`sum_size`) is below it is dropped.
498
- * Sorted by root, expiry, strike, then side.
499
- */
500
- export function foldWrunOptionContractFlowBar(rows, acquisition) {
501
- const knobs = wrunOptionContractFlowAcquisitionOf(acquisition);
521
+ /** A new accumulator of per-contract sums (`WrunOptionContractFlowSums`). */
522
+ export function wrunOptionContractFlowSums() {
502
523
  const R = WRUN_OPTION_CONTRACT_FLOW_RAW;
503
524
  const byContract = new Map();
504
525
  let spotSize = 0;
505
526
  let sizePriced = 0;
506
- for (const row of rows) {
507
- const at = Number(row[0]);
508
- forEachWrunOptionContractFlowRaw(row, (source, offset) => {
527
+ return {
528
+ add(at, source, offset) {
509
529
  const flags = source[offset + R.flags];
510
530
  spotSize += source[offset + R.sumSpotSize];
511
531
  sizePriced += source[offset + R.sizePriced];
@@ -521,7 +541,7 @@ export function foldWrunOptionContractFlowBar(rows, acquisition) {
521
541
  lastAt: at,
522
542
  ivAt: (flags & RAW_FLAG.ivLast) !== 0 ? at : Number.NEGATIVE_INFINITY,
523
543
  });
524
- return;
544
+ return key;
525
545
  }
526
546
  for (const column of SUMMED_RAW_COLUMNS)
527
547
  sum.raw[column] += source[offset + column];
@@ -535,16 +555,48 @@ export function foldWrunOptionContractFlowBar(rows, acquisition) {
535
555
  sum.ivAt = at;
536
556
  sum.flags |= RAW_FLAG.ivLast;
537
557
  }
558
+ return key;
559
+ },
560
+ spot: () => (sizePriced > 0 ? spotSize / sizePriced : undefined),
561
+ raws: () => [...byContract.values()].map((sum) => {
562
+ const raw = [...sum.raw];
563
+ raw[R.flags] = sum.flags;
564
+ return raw;
565
+ }),
566
+ sums: () => [...byContract.values()],
567
+ };
568
+ }
569
+ /**
570
+ * One host bar's contract tuples from its buckets' raw rows (in bucket order), under the acquisition's knobs:
571
+ * - every contract's sums over the bar, its last price from its newest bucket and its IV from its newest bucket that
572
+ * had one (`wrunOptionContractFlowSums`);
573
+ * - `expiries: "nearest:N"`: the contracts of the bar's N nearest expiries (among every contract that traded);
574
+ * - `strike_window_pct`: the strikes within that many percent of the bar's underlying, its contract-weighted price
575
+ * over the bar's prints that carried one (sum_spot_size / size_priced over every contract row of the bar: the same
576
+ * from any tier and any row order; a bar no priced print reached keeps every strike, there being nothing to judge
577
+ * by);
578
+ * - `min_volume`: a contract whose bar total contracts (`sum_size`) is below it is dropped.
579
+ * (`min_premium` and a session span are the worker twin's, before any row lands.) Sorted by root, expiry, strike, then
580
+ * side.
581
+ */
582
+ export function foldWrunOptionContractFlowBar(rows, acquisition) {
583
+ const knobs = wrunOptionContractFlowAcquisitionOf(acquisition);
584
+ const R = WRUN_OPTION_CONTRACT_FLOW_RAW;
585
+ const accumulator = wrunOptionContractFlowSums();
586
+ for (const row of rows) {
587
+ const at = Number(row[0]);
588
+ forEachWrunOptionContractFlowRaw(row, (source, offset) => {
589
+ accumulator.add(at, source, offset);
538
590
  });
539
591
  }
540
- let sums = [...byContract.values()];
592
+ let sums = accumulator.sums();
541
593
  const expiries = wrunOptionExpiriesOf(knobs.expiries);
542
594
  if (expiries?.kind === 'nearest') {
543
595
  const kept = new Set(wrunNearestExpiryTuples(sums.map((sum) => sum.raw), expiries.count, R.expiry));
544
596
  sums = sums.filter((sum) => kept.has(sum.raw));
545
597
  }
546
598
  const pct = knobs.strikeWindowPct;
547
- const spot = sizePriced > 0 ? spotSize / sizePriced : undefined;
599
+ const spot = accumulator.spot();
548
600
  if (pct !== undefined && spot !== undefined && spot > 0) {
549
601
  const reach = (spot * pct) / 100;
550
602
  sums = sums.filter((sum) => Math.abs(sum.raw[R.strike] - spot) <= reach);