@orangecharts/wrun-chart-host 0.7.1 → 0.8.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.
- package/README.md +25 -3
- package/dist/constants/feature-flags.constants.d.ts +1 -0
- package/dist/constants/feature-flags.constants.js +5 -0
- package/dist/constants/option-venues.constants.d.ts +18 -0
- package/dist/constants/option-venues.constants.js +14 -0
- package/dist/constants/venue-presets.constants.d.ts +17 -3
- package/dist/constants/venue-presets.constants.js +17 -3
- package/dist/host-env.d.ts +24 -0
- package/dist/host-env.js +21 -0
- package/dist/host-ports.types.d.ts +12 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/indicators/controls/tpo-session.util.d.ts +40 -11
- package/dist/indicators/controls/tpo-session.util.js +138 -14
- package/dist/interfaces/option-instrument.interface.d.ts +6 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +4 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +4 -0
- package/dist/settings-templates/footprint-rows.d.ts +25 -0
- package/dist/settings-templates/footprint-rows.js +127 -0
- package/dist/settings-templates/form-rows.d.ts +56 -0
- package/dist/settings-templates/form-rows.js +19 -0
- package/dist/settings-templates/frvp-fields.js +14 -0
- package/dist/settings-templates/index.d.ts +10 -1
- package/dist/settings-templates/index.js +11 -2
- package/dist/settings-templates/indicator-fields.js +78 -0
- package/dist/settings-templates/tool-rules.d.ts +35 -9
- package/dist/settings-templates/tool-rules.js +42 -8
- package/dist/settings-templates/tool-tables.generated.js +13 -2
- package/dist/utility/chart/candle-volume-unit.leaf.d.ts +16 -0
- package/dist/utility/chart/candle-volume-unit.leaf.js +61 -0
- package/dist/utility/chart/footprint-columns.util.d.ts +74 -0
- package/dist/utility/chart/footprint-columns.util.js +106 -0
- package/dist/utility/chart/footprint-display-mode.util.d.ts +40 -0
- package/dist/utility/chart/footprint-display-mode.util.js +62 -0
- package/dist/utility/chart/footprint-sierra-look.util.d.ts +2 -0
- package/dist/utility/chart/footprint-sierra-look.util.js +37 -0
- package/dist/utility/chart/kscript-venue-policy.util.js +4 -2
- package/dist/utility/chart/om-panel.util.d.ts +11 -0
- package/dist/utility/chart/om-panel.util.js +59 -0
- package/dist/utility/chart/window-geometry.leaf.d.ts +23 -1
- package/dist/utility/chart/window-geometry.leaf.js +78 -6
- package/dist/utility/chart/window-owner.leaf.d.ts +13 -0
- package/dist/utility/chart/window-owner.leaf.js +5 -0
- package/dist/utility/options/cme-options-root.util.d.ts +25 -0
- package/dist/utility/options/cme-options-root.util.js +40 -0
- package/dist/utility/options/option-book.util.d.ts +27 -0
- package/dist/utility/options/option-book.util.js +76 -0
- package/dist/utility/options/option-trade-date.util.d.ts +50 -0
- package/dist/utility/options/option-trade-date.util.js +120 -0
- package/dist/utility/wrun/sources/host-grid-landing.d.ts +4 -2
- package/dist/utility/wrun/sources/host-grid-landing.js +8 -0
- package/dist/utility/wrun/sources/lanes/options_flow.d.ts +40 -4
- package/dist/utility/wrun/sources/lanes/options_flow.js +115 -18
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +12 -9
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +10 -7
- package/dist/utility/wrun/sources/row-lane-registry.js +9 -5
- package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +3 -2
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +30 -5
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +14 -1
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +100 -23
- package/dist/utility/wrun/sources/row-lanes/option_strike_flow.d.ts +4 -0
- package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +65 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +47 -1
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +71 -2
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +14 -1
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +30 -2
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +7 -1
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +45 -5
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +115 -3
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +10 -0
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +57 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +60 -6
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +160 -23
- package/dist/utility/wrun/wrun-cloud-record.leaf.d.ts +27 -0
- package/dist/utility/wrun/wrun-cloud-record.leaf.js +71 -0
- package/dist/utility/wrun/wrun-cloud-record.util.d.ts +4 -21
- package/dist/utility/wrun/wrun-cloud-record.util.js +5 -65
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +7 -5
- package/dist/utility/wrun/wrun-color-settings.util.js +26 -11
- package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +4 -2
- package/dist/utility/wrun/wrun-draft-overlay.util.js +40 -3
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +1 -1
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +4 -0
- package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +29 -3
- package/dist/utility/wrun/wrun-lane-refusal.leaf.js +33 -3
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -1
- package/dist/utility/wrun/wrun-live-tick.util.js +39 -6
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +106 -0
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +159 -0
- package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +44 -0
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +213 -0
- package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +43 -8
- package/dist/utility/wrun/wrun-opra-flow.leaf.js +37 -6
- package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +51 -10
- package/dist/utility/wrun/wrun-option-contract-flow.util.js +85 -33
- package/dist/utility/wrun/wrun-option-prints.util.d.ts +133 -3
- package/dist/utility/wrun/wrun-option-prints.util.js +318 -8
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +96 -0
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +215 -0
- package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +342 -0
- package/dist/utility/wrun/wrun-option-strike-flow.util.js +742 -0
- package/dist/utility/wrun/wrun-option-views.util.d.ts +183 -3
- package/dist/utility/wrun/wrun-option-views.util.js +504 -7
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +6 -4
- package/dist/utility/wrun/wrun-options-chain.util.js +8 -5
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +7 -2
- package/dist/utility/wrun/wrun-overlay-run.util.js +120 -18
- package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +15 -0
- package/dist/utility/wrun/wrun-pack-widths.leaf.js +22 -0
- package/dist/utility/wrun/wrun-pack.util.d.ts +9 -8
- package/dist/utility/wrun/wrun-pack.util.js +21 -15
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +62 -22
- package/dist/utility/wrun/wrun-panel-style.util.d.ts +17 -2
- package/dist/utility/wrun/wrun-panel-style.util.js +47 -9
- package/dist/utility/wrun/wrun-pin-spelling.util.js +19 -10
- package/dist/utility/wrun/wrun-refusal.util.js +7 -1
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +13 -0
- package/dist/utility/wrun/wrun-script-inputs.util.js +43 -0
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-tape-source.util.js +18 -0
- package/package.json +3 -3
|
@@ -0,0 +1,215 @@
|
|
|
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
|
+
/** An `expiries` word as this class reads it (absent is "all"), or undefined for a word outside them. */
|
|
62
|
+
export function wrunOptionStrikeFlowExpiriesOf(value) {
|
|
63
|
+
if (value === undefined || value === 'all')
|
|
64
|
+
return { kind: 'all' };
|
|
65
|
+
if (value === '0dte')
|
|
66
|
+
return { kind: '0dte' };
|
|
67
|
+
if (value === 'after_today')
|
|
68
|
+
return { kind: 'after_today' };
|
|
69
|
+
if (typeof value !== 'string')
|
|
70
|
+
return undefined;
|
|
71
|
+
const match = NEAREST_RE.exec(value);
|
|
72
|
+
return match ? { kind: 'nearest', count: Number(match[1]) } : undefined;
|
|
73
|
+
}
|
|
74
|
+
function positiveOf(value) {
|
|
75
|
+
return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : undefined;
|
|
76
|
+
}
|
|
77
|
+
/** The knobs an acquisition (an instance's payload) names, a field that is not valid read absent. */
|
|
78
|
+
export function wrunOptionStrikeFlowPayloadKnobsOf(payload) {
|
|
79
|
+
const group = WRUN_OPTION_STRIKE_FLOW_GROUPS.includes(payload?.group)
|
|
80
|
+
? payload?.group
|
|
81
|
+
: 'strike';
|
|
82
|
+
const expiries = wrunOptionStrikeFlowExpiriesOf(payload?.expiries);
|
|
83
|
+
const rows = payload?.strikeRows;
|
|
84
|
+
const strikeWindowPct = positiveOf(payload?.strikeWindowPct);
|
|
85
|
+
const minVolume = positiveOf(payload?.minVolume);
|
|
86
|
+
return {
|
|
87
|
+
group,
|
|
88
|
+
...(expiries !== undefined && expiries.kind !== 'all' && typeof payload?.expiries === 'string'
|
|
89
|
+
? { expiries: payload.expiries }
|
|
90
|
+
: {}),
|
|
91
|
+
...(strikeWindowPct !== undefined ? { strikeWindowPct } : {}),
|
|
92
|
+
...(typeof rows === 'number' && Number.isInteger(rows) && rows >= 1 ? { strikeRows: rows } : {}),
|
|
93
|
+
...(payload?.splitDte === true ? { splitDte: true } : {}),
|
|
94
|
+
...(payload?.foldTypes === true ? { foldTypes: true } : {}),
|
|
95
|
+
...(payload?.span === 'session' ? { span: 'session' } : {}),
|
|
96
|
+
...(payload?.history === 'today' ? { history: 'today' } : {}),
|
|
97
|
+
...(minVolume !== undefined ? { minVolume } : {}),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** The span the class is served over for one acquisition: `expiry_strike`'s 30-minute view keeps 30 days; every other
|
|
101
|
+
* group's tiers say it alone. */
|
|
102
|
+
export function wrunOptionStrikeFlowHorizon(extras, nowMs) {
|
|
103
|
+
if (extras.group !== 'expiry_strike' || !Number.isFinite(nowMs))
|
|
104
|
+
return undefined;
|
|
105
|
+
const reach = WRUN_OPTION_STRIKE_FLOW_TIERS.expiry_strike.at(-1)?.retentionMs;
|
|
106
|
+
if (reach === undefined)
|
|
107
|
+
return undefined;
|
|
108
|
+
return { servedFromMs: nowMs - reach, completeFromMs: nowMs - reach };
|
|
109
|
+
}
|
|
110
|
+
/** The tuples one SPY bar of a group holds (one 30-minute session of 13 bars measured 2026-10-19): STRIKE 357 (471 with
|
|
111
|
+
* the 0DTE split), EXPIRY 75, the per-(expiry, strike) rows 2,326; 33 traded expiries. Any bar width, every chain. */
|
|
112
|
+
export const WRUN_OPTION_STRIKE_FLOW_BAR_TUPLES = Object.freeze({
|
|
113
|
+
strike: 357,
|
|
114
|
+
strikeSplit: 471,
|
|
115
|
+
expiry: 75,
|
|
116
|
+
expiryStrike: 2_326,
|
|
117
|
+
expiries: 33,
|
|
118
|
+
});
|
|
119
|
+
/** The tuples a bar of one acquisition is projected to hold, from its knobs over SPY's measured bars. */
|
|
120
|
+
export function wrunOptionStrikeFlowTuplesPerBar(acquisition) {
|
|
121
|
+
const knobs = wrunOptionStrikeFlowPayloadKnobsOf(acquisition);
|
|
122
|
+
const T = WRUN_OPTION_STRIKE_FLOW_BAR_TUPLES;
|
|
123
|
+
const sides = knobs.foldTypes ? 1 : 2;
|
|
124
|
+
const parts = knobs.splitDte ? 2 : 1;
|
|
125
|
+
const nearest = wrunOptionStrikeFlowExpiriesOf(knobs.expiries);
|
|
126
|
+
const expiryShare = nearest?.kind === 'nearest' ? Math.min(1, nearest.count / T.expiries) : 1;
|
|
127
|
+
const windowShare = knobs.strikeWindowPct !== undefined ? Math.min(1, knobs.strikeWindowPct / 25) : 1;
|
|
128
|
+
switch (knobs.group) {
|
|
129
|
+
case 'expiry':
|
|
130
|
+
return Math.ceil(T.expiry * expiryShare);
|
|
131
|
+
case 'expiry_strike': {
|
|
132
|
+
const cells = T.expiryStrike * expiryShare * windowShare;
|
|
133
|
+
const rows = knobs.strikeRows !== undefined ? knobs.strikeRows * 2 * Math.ceil(T.expiries * expiryShare) : Infinity;
|
|
134
|
+
return Math.ceil(Math.min(cells, rows));
|
|
135
|
+
}
|
|
136
|
+
default: {
|
|
137
|
+
const all = ((knobs.splitDte ? T.strikeSplit : T.strike) * sides) / 2;
|
|
138
|
+
const rows = knobs.strikeRows !== undefined ? knobs.strikeRows * sides * parts : Infinity;
|
|
139
|
+
return Math.ceil(Math.min(all * windowShare, rows));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/** The rows one host bar is projected to read (the lane's row budget): its projected tuples, none for a bar before
|
|
144
|
+
* today's first instant as the acquisition names it under `history` "today" (it reads nothing;
|
|
145
|
+
* wrun-option-contract-flow.util `wrunOptionFlowBarBeforeToday`, never dated off `nowMs`). */
|
|
146
|
+
export function wrunOptionStrikeFlowBarRows(bar, _nowMs, acquisition) {
|
|
147
|
+
if (wrunOptionFlowBarBeforeToday(bar, acquisition))
|
|
148
|
+
return 0;
|
|
149
|
+
return wrunOptionStrikeFlowTuplesPerBar(acquisition);
|
|
150
|
+
}
|
|
151
|
+
/** 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
|
|
152
|
+
* is. A cell of another shape, and a tuple holding a value that is not finite, is skipped. */
|
|
153
|
+
export function wrunOptionStrikeFlowTuplesOfRow(row) {
|
|
154
|
+
const tuples = [];
|
|
155
|
+
const take = (source, offset) => {
|
|
156
|
+
const tuple = new Array(WRUN_OPTION_STRIKE_FLOW_WIDTH);
|
|
157
|
+
for (let column = 0; column < WRUN_OPTION_STRIKE_FLOW_WIDTH; column += 1) {
|
|
158
|
+
const value = source[offset + column];
|
|
159
|
+
if (!Number.isFinite(value))
|
|
160
|
+
return;
|
|
161
|
+
tuple[column] = value;
|
|
162
|
+
}
|
|
163
|
+
tuples.push(tuple);
|
|
164
|
+
};
|
|
165
|
+
for (let index = 1; index < row.length; index += 1) {
|
|
166
|
+
const cell = row[index];
|
|
167
|
+
if (cell instanceof Float64Array && cell.length % WRUN_OPTION_STRIKE_FLOW_WIDTH === 0) {
|
|
168
|
+
for (let offset = 0; offset < cell.length; offset += WRUN_OPTION_STRIKE_FLOW_WIDTH)
|
|
169
|
+
take(cell, offset);
|
|
170
|
+
}
|
|
171
|
+
else if (Array.isArray(cell) && cell.length === WRUN_OPTION_STRIKE_FLOW_WIDTH) {
|
|
172
|
+
take(cell, 0);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return tuples;
|
|
176
|
+
}
|
|
177
|
+
/** The canonical order of a bar's tuples: expiry, strike, calls before puts (folded last), then the 0DTE part first. */
|
|
178
|
+
export function compareWrunOptionStrikeFlowTuples(a, b) {
|
|
179
|
+
const C = WRUN_OPTION_STRIKE_FLOW_COLUMN;
|
|
180
|
+
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]);
|
|
181
|
+
}
|
|
182
|
+
/** 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
|
|
183
|
+
* merged key by key (expiry, strike, side, class: values summed, a partial mark kept), a partial marker kept as the
|
|
184
|
+
* bar's marker. Sorted canonically. */
|
|
185
|
+
export function foldWrunOptionStrikeFlowBar(rows) {
|
|
186
|
+
const C = WRUN_OPTION_STRIKE_FLOW_COLUMN;
|
|
187
|
+
const byKey = new Map();
|
|
188
|
+
let marker;
|
|
189
|
+
for (const row of rows) {
|
|
190
|
+
for (const tuple of wrunOptionStrikeFlowTuplesOfRow(row)) {
|
|
191
|
+
const partial = wrunPresentIsPartial(tuple[C.present]);
|
|
192
|
+
if (partial && tuple.slice(0, C.present).every((value) => value === 0)) {
|
|
193
|
+
marker = tuple;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const key = `${tuple[C.expiry]}|${tuple[C.strike]}|${tuple[C.side]}|${tuple[C.dteClass]}`;
|
|
197
|
+
const held = byKey.get(key);
|
|
198
|
+
if (held === undefined) {
|
|
199
|
+
byKey.set(key, [...tuple]);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
for (let column = C.volAsk; column < C.present; column += 1)
|
|
203
|
+
held[column] += tuple[column];
|
|
204
|
+
if (partial)
|
|
205
|
+
held[C.present] = wrunPresentWithPartial(held[C.present]);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const tuples = [...byKey.values()].sort(compareWrunOptionStrikeFlowTuples);
|
|
209
|
+
if (marker === undefined)
|
|
210
|
+
return tuples;
|
|
211
|
+
if (tuples.length === 0)
|
|
212
|
+
return [marker];
|
|
213
|
+
tuples[0][C.present] = wrunPresentWithPartial(tuples[0][C.present]);
|
|
214
|
+
return tuples;
|
|
215
|
+
}
|
|
@@ -0,0 +1,342 @@
|
|
|
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
|
+
/** The trade-date group a bucket stamped `ts` sums into under the gateway's session (contract 3.4): on RTH the New York
|
|
132
|
+
* date's 09:30 open for a bucket inside the cash session (null outside it), on UTC the UTC date's 00:00Z. */
|
|
133
|
+
export declare function wrunOptionFlowSessionStampMs(ts: number, barAnchor: number): number | null;
|
|
134
|
+
/**
|
|
135
|
+
* The stamp of the group a bucket stamped `ts` sums into, on the browser's side of a grouping (the fold's): the
|
|
136
|
+
* gateway's bar or session rule (`bars`, `session`), the chart's own bar, or a trade date of the clock stamped at its
|
|
137
|
+
* first instant (`host` with a session span); null for a bucket no group holds (off the cash session on RTH).
|
|
138
|
+
*/
|
|
139
|
+
export declare function wrunOptionFlowGroupStampMs(ts: number, grouping: WrunOptionFlowGrouping, bars: {
|
|
140
|
+
barMs: number | undefined;
|
|
141
|
+
barGrid: LiveBucketVenue | undefined;
|
|
142
|
+
clock: OptionTradeDateClockRule;
|
|
143
|
+
}): number | null;
|
|
144
|
+
/**
|
|
145
|
+
* The window a session grouping reads: from the first instant of the trade date holding `fromMs` to the first instant
|
|
146
|
+
* of the trade date after the one holding `toMs - 1` (whole sessions, so a session's row sums every bucket of it
|
|
147
|
+
* whichever asked bars hold it), on the clock (the New York date for an RTH session: its midnights sit outside the
|
|
148
|
+
* cash session, a boundary the gateway takes).
|
|
149
|
+
*/
|
|
150
|
+
export declare function wrunOptionFlowSessionWindow(fromMs: number, toMs: number, clock: OptionTradeDateClockRule): {
|
|
151
|
+
fromMs: number;
|
|
152
|
+
toMs: number;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* The part of an ask `[fromMs, toMs)` that `history` "today" reads (both flow classes' worker twins): from the first
|
|
156
|
+
* host bar ending after today's first instant, else from that instant on the tier's grid, to the ask's end. Today's
|
|
157
|
+
* first instant is the request's (`todayFromMs`, wrun-option-contract-flow.util `WRUN_OPTION_FLOW_TODAY_FIELD`): the
|
|
158
|
+
* trade date of the chart's newest bar on the chain's venue clock, which the K control names off the chart's bars
|
|
159
|
+
* (option-flow-bars.util `optionFlowTodayFields`), so a weekend, a holiday or a morning before the first print reads
|
|
160
|
+
* the last session the chart shows. Null when the ask holds nothing of today (an ask of older bars: quiet), and when
|
|
161
|
+
* the request names no today: no clock stands in for the chart's bars (a server clock reads Saturday on a Saturday).
|
|
162
|
+
*/
|
|
163
|
+
export declare function wrunOptionFlowTodayWindow(args: {
|
|
164
|
+
fromMs: number;
|
|
165
|
+
toMs: number;
|
|
166
|
+
todayFromMs: number | undefined;
|
|
167
|
+
tierMs: number;
|
|
168
|
+
barMs: number | undefined;
|
|
169
|
+
barGrid: LiveBucketVenue | undefined;
|
|
170
|
+
}): {
|
|
171
|
+
fromMs: number;
|
|
172
|
+
toMs: number;
|
|
173
|
+
} | null;
|
|
174
|
+
/** The `optionRead` of a grouped read (pb-common `OptionReadShape`, contract 2.2: JSON names, enums as numbers). */
|
|
175
|
+
export interface WrunOptionFlowReadShape {
|
|
176
|
+
barSeconds?: number;
|
|
177
|
+
barAnchor?: number;
|
|
178
|
+
span?: number;
|
|
179
|
+
expiryClass?: number;
|
|
180
|
+
nearestExpiries?: number;
|
|
181
|
+
strikeWindowPct?: number;
|
|
182
|
+
strikeRows?: number;
|
|
183
|
+
minVolume?: number;
|
|
184
|
+
splitDte?: boolean;
|
|
185
|
+
foldTypes?: boolean;
|
|
186
|
+
minBarPremium?: number;
|
|
187
|
+
}
|
|
188
|
+
/** The grouping's own fields: its bars, or its session on its anchor. */
|
|
189
|
+
export declare function wrunOptionFlowGroupingShape(grouping: Extract<WrunOptionFlowGrouping, {
|
|
190
|
+
kind: 'bars' | 'session';
|
|
191
|
+
}>): WrunOptionFlowReadShape;
|
|
192
|
+
/** The `expiryClass` an `expiries` word asks (0DTE or after today), else none. */
|
|
193
|
+
export declare function wrunOptionFlowExpiryClassOf(expiries: string | undefined): number | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* The `optionRead` of a grouped strike flow read (contract 3.1 and 6.4): the grouping, the expiry class, and the knobs
|
|
196
|
+
* the group's scope takes (STRIKE: the window, the strike rows, the volume floor, the split, the fold; EXPIRY: the
|
|
197
|
+
* nearest expiries and the volume floor; EXPIRY_STRIKE: the nearest expiries, the window, the strike rows and the
|
|
198
|
+
* volume floor). The planner refuses every other combination by name, so each field the read names is taken.
|
|
199
|
+
*/
|
|
200
|
+
export declare function wrunOptionStrikeFlowOptionRead(knobs: WrunOptionStrikeFlowKnobs, grouping: Extract<WrunOptionFlowGrouping, {
|
|
201
|
+
kind: 'bars' | 'session';
|
|
202
|
+
}>): WrunOptionFlowReadShape;
|
|
203
|
+
/** The tiers the gateway groups a CONTRACT read at (contract 6.3: the contract tiers at 1m and 5m, the per-contract
|
|
204
|
+
* 30-minute view); an ask at any other tier (the hour, the day) is read as today. */
|
|
205
|
+
export declare const WRUN_OPTION_CONTRACT_GROUPED_TIERS: readonly string[];
|
|
206
|
+
/** The per-contract 30-minute view a session-span CONTRACT read asks (contract 6.3: `option_print_agg_bar_30m`, kept 30
|
|
207
|
+
* days). */
|
|
208
|
+
export declare const WRUN_OPTION_CONTRACT_SESSION_TIER: Readonly<WrunBackendTier>;
|
|
209
|
+
/** The 30-minute tier of a strike flow group: its coarsest (kept, or 30 days on `expiry_strike`). */
|
|
210
|
+
export declare function wrunOptionStrikeFlowSessionTierOf(group: WrunOptionStrikeFlowGroup): WrunBackendTier;
|
|
211
|
+
/**
|
|
212
|
+
* The tier a grouped read asks (contract 6.8: "span session reads 30m"). A session grouping reads `sessionTier`, the
|
|
213
|
+
* 30-minute view that holds each session whole at the fewest rows (one SPY session, contract section 1: STRIKE 6,564
|
|
214
|
+
* rows at 30m against 23,271 at 5m; CONTRACT 30,239 against 76,740), where that view still holds the window's start
|
|
215
|
+
* (`retentionMs` back from `nowMs`). Any other grouping, and a window older than the view keeps, reads the ask's own
|
|
216
|
+
* tier. A session row is stamped by its anchor whatever tier sums it, so it lands where the ask's tier's would.
|
|
217
|
+
*/
|
|
218
|
+
export declare function wrunOptionFlowGroupedTier(grouping: WrunOptionFlowGrouping, askTier: WrunBackendTier, sessionTier: WrunBackendTier, fromMs: number, nowMs: number): WrunBackendTier;
|
|
219
|
+
/**
|
|
220
|
+
* The `optionRead` of a grouped CONTRACT read (contract 3.1 and 6.4: steps 1, 2 and the premium floor of 7): the
|
|
221
|
+
* grouping, the 0DTE class of `expiries` "0dte", and `minBarPremium` from `min_premium` (a contract's group premium, the
|
|
222
|
+
* four sides' sum). Every other knob of `option_contract_flow` stays the fold's, as today.
|
|
223
|
+
*/
|
|
224
|
+
export declare function wrunOptionContractFlowOptionRead(acquisition: {
|
|
225
|
+
expiries?: string;
|
|
226
|
+
minPremium?: number;
|
|
227
|
+
}, grouping: Extract<WrunOptionFlowGrouping, {
|
|
228
|
+
kind: 'bars' | 'session';
|
|
229
|
+
}>): WrunOptionFlowReadShape;
|
|
230
|
+
/**
|
|
231
|
+
* Whether a CONTRACT row is a "0dte" row on today's read of `option_contract_flow` (the grouped read classes rows
|
|
232
|
+
* itself): its expiry falls on the trade date of its bucket on its chain's venue clock (option-trade-date.util, the data
|
|
233
|
+
* plane's `option_venue_clocks`), read at the bucket's middle so a UTC day bucket reads its own session's date.
|
|
234
|
+
*/
|
|
235
|
+
export declare function wrunOptionContractFlowRowIsZeroDte(row: WrunOptionContractFlowRow, tierMs: number, chain: OptionTradeDateChain): boolean;
|
|
236
|
+
/** Why a grouped row was dropped (counted, never a made-up value). */
|
|
237
|
+
export type WrunOptionStrikeFlowDrop = 'time' | 'scope' | 'value';
|
|
238
|
+
/** One grouped row's columns as the worker reads them (NaN or absent: unset). */
|
|
239
|
+
export interface WrunOptionStrikeFlowGroupedRecord {
|
|
240
|
+
scope?: number;
|
|
241
|
+
strike?: number;
|
|
242
|
+
expiryMs?: number;
|
|
243
|
+
optionType?: number;
|
|
244
|
+
dteBucket?: number;
|
|
245
|
+
volAsk?: number;
|
|
246
|
+
volBid?: number;
|
|
247
|
+
volMid?: number;
|
|
248
|
+
volNone?: number;
|
|
249
|
+
volAboveAsk?: number;
|
|
250
|
+
volBelowBid?: number;
|
|
251
|
+
premAsk?: number;
|
|
252
|
+
premBid?: number;
|
|
253
|
+
premMid?: number;
|
|
254
|
+
premNone?: number;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* One grouped STRIKE, EXPIRY or EXPIRY_STRIKE row as the class's tuple (contract 6.5): `expiry_ms` 0 on a strike row,
|
|
258
|
+
* `strike` 0 on an expiry row, `side_cp` from the series' option type (0 with `fold_types`), `dte_class` from
|
|
259
|
+
* `dte_bucket` (ZERO 1, AFTER_ZERO 2, unset 0), every unset value 0. A row of another scope is dropped.
|
|
260
|
+
*/
|
|
261
|
+
export declare function wrunOptionStrikeFlowTupleOf(record: WrunOptionStrikeFlowGroupedRecord, group: WrunOptionStrikeFlowGroup): number[] | WrunOptionStrikeFlowDrop;
|
|
262
|
+
/** One CONTRACT row of a bucket as the fold reads it: its bucket, its contract and its sums (absent sums are 0). */
|
|
263
|
+
export interface WrunOptionStrikeFlowContractRow {
|
|
264
|
+
bucketMs: number;
|
|
265
|
+
expiryMs: number;
|
|
266
|
+
strike: number;
|
|
267
|
+
/** +1 a call, -1 a put. */
|
|
268
|
+
side: number;
|
|
269
|
+
volAsk: number;
|
|
270
|
+
volBid: number;
|
|
271
|
+
volMid: number;
|
|
272
|
+
volNone: number;
|
|
273
|
+
volAboveAsk: number;
|
|
274
|
+
volBelowBid: number;
|
|
275
|
+
premAsk: number;
|
|
276
|
+
premBid: number;
|
|
277
|
+
premMid: number;
|
|
278
|
+
premNone: number;
|
|
279
|
+
/** Contracts traded (`sum_size`): the volume floor's measure. */
|
|
280
|
+
sumSize: number;
|
|
281
|
+
/** Underlying price x contracts over the prints that carried one, and those contracts: the spot's sums. */
|
|
282
|
+
sumSpotSize: number;
|
|
283
|
+
sizePriced: number;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* 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
|
|
287
|
+
* gateway's own (tsdb-gateway `option_print_agg_group.go`):
|
|
288
|
+
* 1. the expiry class per row: 0DTE when the contract expires on the trade date of the row's bucket (its middle) on the
|
|
289
|
+
* chain's venue clock (`zero`, computed by the caller: `wrunOptionStrikeFlowZeroDte`); `expiries` "0dte" keeps those,
|
|
290
|
+
* "after_today" the others;
|
|
291
|
+
* 2. the sums per key: (side, strike, class) for the strike group, (side, expiry) for the expiry group, (side, strike,
|
|
292
|
+
* expiry) for both;
|
|
293
|
+
* 3. the spot: the group's sum_spot_size over its size_priced (every kept row: all strikes, expiries and sides), unset
|
|
294
|
+
* when nothing was priced;
|
|
295
|
+
* 4. `nearest:N` (expiry and expiry_strike): the N smallest distinct expiries of the group;
|
|
296
|
+
* 5. `strike_window_pct` (strike and expiry_strike): the strikes within that many percent of the spot;
|
|
297
|
+
* 6. `strike_rows` R: the R distinct strikes nearest the spot after the window (ties: the lower strike); 5 and 6
|
|
298
|
+
* skipped when the spot is unset or not above 0;
|
|
299
|
+
* 7. `min_volume`: a key's contracts at least the floor (on the strike group the side's strike over both classes);
|
|
300
|
+
* 8. the shape: `split_dte` one row per class part, else the parts summed; `fold_types` one row per strike, calls and
|
|
301
|
+
* puts summed with the put's sides crossed (the bullish side in the ask columns).
|
|
302
|
+
* Sorted by expiry, strike, side (calls first), class.
|
|
303
|
+
*/
|
|
304
|
+
export declare function foldWrunOptionStrikeFlowGroup(rows: ReadonlyArray<WrunOptionStrikeFlowContractRow & {
|
|
305
|
+
zero: boolean;
|
|
306
|
+
}>, knobs: WrunOptionStrikeFlowKnobs): number[][];
|
|
307
|
+
/** Whether a CONTRACT row is a 0DTE row: its expiry trades on the trade date of its bucket's middle (a UTC day bucket
|
|
308
|
+
* reads its own session's date) on the chain's venue clock. */
|
|
309
|
+
export declare function wrunOptionStrikeFlowZeroDte(row: Pick<WrunOptionStrikeFlowContractRow, 'bucketMs' | 'expiryMs'>, tierMs: number, clock: OptionTradeDateClockRule): boolean;
|
|
310
|
+
/** One contract-tier read of the fold: a tier and its span. */
|
|
311
|
+
export type WrunOptionStrikeFlowFoldRead = WrunTierSegment;
|
|
312
|
+
/**
|
|
313
|
+
* Today's ask for one strike flow ask's host bars, before any fetch, as the `option_contract_flow` lane plans its own
|
|
314
|
+
* (the read the class is folded from while the gateway does not group it): each bar's coarsest contract tier that fits,
|
|
315
|
+
* retains and already serves it (`WRUN_OPTION_PRINT_AGG_TIERS`, the bars' session grid), and the NEWEST bars whose
|
|
316
|
+
* projected contract rows (`wrunOptionContractFlowBarRows`, the chain's plane) fit the source answer budget, counted
|
|
317
|
+
* from the clock: the bars after the ask (a later ask's) are counted first, so every ask of one window keeps the same
|
|
318
|
+
* bars. A newest bar that cannot fit alone is skipped (a forming day read from minutes); from the first bar that fits,
|
|
319
|
+
* a bar that would pass the budget stops the walk. The kept bars are read per run of one tier (`reads`); every asked
|
|
320
|
+
* bar outside them is partial. `newerBarOpens` are the host bars after the ask, up to the clock.
|
|
321
|
+
*/
|
|
322
|
+
export declare function wrunOptionStrikeFlowFoldPlan(args: {
|
|
323
|
+
barOpens: readonly number[];
|
|
324
|
+
newerBarOpens: readonly number[];
|
|
325
|
+
barMs: number;
|
|
326
|
+
barGrid: LiveBucketVenue | undefined;
|
|
327
|
+
nowMs: number;
|
|
328
|
+
acquisition: Readonly<Record<string, unknown>>;
|
|
329
|
+
}): {
|
|
330
|
+
reads: WrunOptionStrikeFlowFoldRead[];
|
|
331
|
+
partialBars: number[];
|
|
332
|
+
keptFromMs: number;
|
|
333
|
+
keptToMs: number;
|
|
334
|
+
};
|
|
335
|
+
/** The host bars `[fromMs, toMs)` holds on the chart's grid, ascending (`liveBucketStartsInRange` over the grid). */
|
|
336
|
+
export declare function wrunOptionFlowHostBars(fromMs: number, toMs: number, barMs: number, barGrid: LiveBucketVenue | undefined): number[];
|
|
337
|
+
/** A stamp's tuples packed as the worker hands them over: one Float64Array of `count x WIDTH` values. */
|
|
338
|
+
export declare function packWrunOptionStrikeFlowTuples(tuples: ReadonlyArray<ArrayLike<number>>): Float64Array;
|
|
339
|
+
/** The marker of a partial bar holding no tuple (every value 0, bit 14 of `present`). */
|
|
340
|
+
export declare function wrunOptionStrikeFlowPartialMarker(): number[];
|
|
341
|
+
/** The bytes one answered tuple weighs in every estimate of a source answer. */
|
|
342
|
+
export declare const WRUN_OPTION_STRIKE_FLOW_TUPLE_BYTES: number;
|