@orangecharts/wrun-chart-host 0.7.0 → 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 -2
- 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 +11 -0
- package/dist/settings-templates/index.js +29 -6
- package/dist/settings-templates/indicator-fields.d.ts +2 -0
- package/dist/settings-templates/indicator-fields.js +78 -0
- package/dist/settings-templates/tool-rules.d.ts +40 -4
- package/dist/settings-templates/tool-rules.js +45 -4
- package/dist/settings-templates/tool-tables.generated.js +22 -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
|
@@ -15,9 +15,19 @@
|
|
|
15
15
|
* (`answer: 'fold'`: totals, boards, the curve) answers rows of another layout, which no reader of this host takes
|
|
16
16
|
* yet (the shared host's kit adapter reads class tuples only): such a view refuses by name before any read
|
|
17
17
|
* (`wrun_option_view_unread`), never an empty or misread block.
|
|
18
|
-
* - Hinted views (`hinted`: the window board, the smile and surface reads
|
|
18
|
+
* - Hinted views (`hinted`: the window board, the smile and surface reads, and the folds that read the close where a
|
|
19
|
+
* contract carries no underlying: exposure, strike_table, gex_curve, oi_board) cover every close within
|
|
19
20
|
* `WRUN_OPTION_VIEW_MARGIN_PCT` of the hint the ask carries, the chart's close at ask time; a run whose close left
|
|
20
|
-
* the band asks again before it reads (`wrunOptionViewHintCovers`, `wrunOptionViewHint`).
|
|
21
|
+
* the band asks again before it reads (`wrunOptionViewHintCovers`, `wrunOptionViewHint`). The gateway refuses a
|
|
22
|
+
* hinted view's ask without the hint. The table is the SDK's (`WRUN_OPTION_PAGE_VIEWS`, kit 0.90.0), pinned word
|
|
23
|
+
* for word by tests/utility/wrun/wrun-option-views.kit-pin.spec.ts.
|
|
24
|
+
* - The per-bar words (OPTLOAD-CHAIN-PLAN 6.2, 6.3 and 9): `pick` on `option_surface` ("nearest_days" or
|
|
25
|
+
* "tenor_bracket", the bar's newest 5m bucket picked to the tuples Skew History and Options Sentiment read) and
|
|
26
|
+
* `fold` "kit" on `option_strikes` (the bar's newest minute folded to one levels row and the strike rows Spot
|
|
27
|
+
* Exposures draws), their params read by the SDK's rules (`WRUN_OPTION_LANE_KNOBS`, `wrunOptionLaneAskOfSource`) and
|
|
28
|
+
* asked of the gateway in the lane's fields (`wrunOptionLaneAskFields`, the `OptionReadShape` G5 fields 40 to 51).
|
|
29
|
+
* The kit fold keeps its expiries with its own `nearest`: an `expiries` word other than "all" beside it is refused
|
|
30
|
+
* at declaration (kit 0.91.1, `WRUN_OPTION_STRIKES_KIT_EXPIRIES_TAKES`).
|
|
21
31
|
* - The ask's payload fields (`wrunOptionViewLaneFields`): `<prefix>Views`, the canonical text (`wrunOptionViewsText`:
|
|
22
32
|
* one spelling for one set of views and values, whatever the declaration order, so equal asks share one key and one
|
|
23
33
|
* read), `<prefix>SpotMarginPct` for a hinted set, and on `options_chain` the gateway's scope inputs
|
|
@@ -33,6 +43,7 @@ import { wrunChartHostEnv } from '../../host-env.js';
|
|
|
33
43
|
import { gateSessionHeldElsewhere } from '../v2/gate-session-latch.util.js';
|
|
34
44
|
import { refuseWrunPollInput } from './sources/wrun-poll-lane.types.js';
|
|
35
45
|
import { refuseWrunOptionKnob } from './wrun-option-knobs.util.js';
|
|
46
|
+
import { wrunPresentHasBit, wrunPresentIsPartial, wrunPresentWithPartial } from './wrun-present-bits.util.js';
|
|
36
47
|
import { wrunAuthorRuleSeed } from './wrun-refusal.util.js';
|
|
37
48
|
/** Every view word, in section 6.1's order. The worker names each by `OPTION_CHAIN_VIEW_<WORD>` (pb-common
|
|
38
49
|
* `OptionChainViewKind`; tests/utility/wrun/wrun-option-views.util.spec.ts pins every name). */
|
|
@@ -97,12 +108,14 @@ export const WRUN_OPTION_VIEWS = Object.freeze({
|
|
|
97
108
|
cls: 'options_chain',
|
|
98
109
|
params: { lens: 'lens', units: 'units', scope: 'scope', nearest: 'nearest', rate: 'rate' },
|
|
99
110
|
answer: 'fold',
|
|
111
|
+
hinted: true,
|
|
100
112
|
},
|
|
101
|
-
strike_table: { cls: 'options_chain', params: {}, answer: 'fold' },
|
|
113
|
+
strike_table: { cls: 'options_chain', params: {}, answer: 'fold', hinted: true },
|
|
102
114
|
gex_curve: {
|
|
103
115
|
cls: 'options_chain',
|
|
104
116
|
params: { grid_down: 'gridDown', grid_up: 'gridUp', points: 'points' },
|
|
105
117
|
answer: 'fold',
|
|
118
|
+
hinted: true,
|
|
106
119
|
},
|
|
107
120
|
});
|
|
108
121
|
/** The hint band each side of the hint, percent of it (section 12: 0.5% of the close). */
|
|
@@ -114,6 +127,10 @@ export const WRUN_OPTION_VIEW_UNREAD_CODE = 'wrun_option_view_unread';
|
|
|
114
127
|
/** The plan's refusal of one chain lane whose inputs read it through views and whole at once (one ask serves both
|
|
115
128
|
* never: B and a view of B are two answers). */
|
|
116
129
|
export const WRUN_OPTION_VIEWS_ONE_ASK_CODE = 'wrun_option_views_one_ask';
|
|
130
|
+
/** The plan's refusal of one chain lane whose view inputs declare different `expiries` words: the lane asks ONE block
|
|
131
|
+
* B of the gateway, built for one `nearestExpiries`, so an input of another word would read views of another B (the
|
|
132
|
+
* SDK asks each word apart; one acquisition per word would serve them). */
|
|
133
|
+
export const WRUN_OPTION_VIEWS_ONE_EXPIRIES_CODE = 'wrun_option_views_one_expiries';
|
|
117
134
|
/** A view's spec, or undefined for a word that names none. */
|
|
118
135
|
export function wrunOptionViewSpec(word) {
|
|
119
136
|
return typeof word === 'string' && Object.prototype.hasOwnProperty.call(WRUN_OPTION_VIEWS, word)
|
|
@@ -135,14 +152,23 @@ function wrunOptionViewWordsOf(cls) {
|
|
|
135
152
|
export const WRUN_OPTION_VIEW_KNOB = 'page_view';
|
|
136
153
|
export const WRUN_OPTION_VIEWS_KNOB = 'page_views';
|
|
137
154
|
/** Every view word an input source declares, in either knob, unvalidated (the paint seam and the stray-knob rule
|
|
138
|
-
* read which params the declared views take).
|
|
155
|
+
* read which params the declared views take; the tuple width reads whether one is a fold). A `page_views` that is
|
|
156
|
+
* no list reads as its one value, as the SDK's `wrunOptionViewWordsDeclared` reads it (its declaration refuses). */
|
|
139
157
|
export function wrunOptionViewWordsDeclared(source) {
|
|
140
158
|
const many = source[WRUN_OPTION_VIEWS_KNOB];
|
|
141
|
-
return [source[WRUN_OPTION_VIEW_KNOB], ...(Array.isArray(many) ? many : [])].filter((word) => word !== undefined);
|
|
159
|
+
return [source[WRUN_OPTION_VIEW_KNOB], ...(Array.isArray(many) ? many : [many])].filter((word) => word !== undefined);
|
|
142
160
|
}
|
|
143
|
-
/** The knob names every view the source declares takes as params
|
|
161
|
+
/** The knob names every view the source declares takes as params, and on a per-bar class the number params its
|
|
162
|
+
* declared word takes (a flag takes no setting: true or false only). */
|
|
144
163
|
export function wrunOptionViewParamKnobs(source) {
|
|
145
|
-
|
|
164
|
+
const knobs = new Set(wrunOptionViewWordsDeclared(source).flatMap((word) => Object.keys(wrunOptionViewSpec(word)?.params ?? {})));
|
|
165
|
+
const cls = wrunOptionLaneClassOf(source.source);
|
|
166
|
+
const word = cls === undefined ? undefined : source[WRUN_OPTION_LANE_WORDS[cls].knob];
|
|
167
|
+
const specs = typeof word === 'string' && cls !== undefined ? wrunOptionLaneKnobSpecs(cls, word) : {};
|
|
168
|
+
for (const [knob, spec] of Object.entries(specs))
|
|
169
|
+
if (spec.kind !== 'flag')
|
|
170
|
+
knobs.add(knob);
|
|
171
|
+
return knobs;
|
|
146
172
|
}
|
|
147
173
|
/** The input's declared view words (`page_view` or `page_views`), undefined when it declares neither. */
|
|
148
174
|
function declaredViewWords(source, ctx) {
|
|
@@ -332,6 +358,477 @@ export function wrunChartLastClose(rows) {
|
|
|
332
358
|
const close = Number(rows[rows.length - 1]?.[4]);
|
|
333
359
|
return Number.isFinite(close) && close > 0 ? close : undefined;
|
|
334
360
|
}
|
|
361
|
+
/** Each per-bar class's word knob and its words, in the SDK's order (`WRUN_OPTION_SURFACE_PICKS`,
|
|
362
|
+
* `WRUN_OPTION_STRIKES_FOLDS`). */
|
|
363
|
+
export const WRUN_OPTION_LANE_WORDS = Object.freeze({
|
|
364
|
+
option_surface: Object.freeze({ knob: 'pick', words: Object.freeze(['nearest_days', 'tenor_bracket']) }),
|
|
365
|
+
option_strikes: Object.freeze({ knob: 'fold', words: Object.freeze(['kit']) }),
|
|
366
|
+
});
|
|
367
|
+
const DAYS_SPEC = { kind: 'number', min: 0, max: 3650, above: true };
|
|
368
|
+
/** The per-bar words' knobs, by word, in the SDK's order (`WRUN_OPTION_LANE_KNOBS`, kit 0.90.0; the surface pick's
|
|
369
|
+
* `delta` 0 reads the 25 delta wings, 1 the 10 delta ones). tests/utility/wrun/wrun-option-views.kit-pin.spec.ts holds
|
|
370
|
+
* every spec equal to the installed kit's. */
|
|
371
|
+
export const WRUN_OPTION_LANE_KNOBS = Object.freeze({
|
|
372
|
+
nearest_days: Object.freeze({
|
|
373
|
+
days: Object.freeze({ ...DAYS_SPEC, what: 'the days to expiry the pick sits nearest' }),
|
|
374
|
+
delta: Object.freeze({
|
|
375
|
+
kind: 'whole',
|
|
376
|
+
codes: Object.freeze({ 0: '25 delta', 1: '10 delta' }),
|
|
377
|
+
what: 'the wings',
|
|
378
|
+
fallback: 0,
|
|
379
|
+
}),
|
|
380
|
+
}),
|
|
381
|
+
tenor_bracket: Object.freeze({
|
|
382
|
+
tenor: Object.freeze({ ...DAYS_SPEC, what: 'the tenor in days the two anchors bracket' }),
|
|
383
|
+
}),
|
|
384
|
+
kit: Object.freeze({
|
|
385
|
+
nearest: Object.freeze({
|
|
386
|
+
kind: 'whole',
|
|
387
|
+
min: 0,
|
|
388
|
+
max: 999,
|
|
389
|
+
what: 'the soonest expiries kept (0: every one)',
|
|
390
|
+
fallback: 0,
|
|
391
|
+
}),
|
|
392
|
+
window_pct: Object.freeze({
|
|
393
|
+
kind: 'number',
|
|
394
|
+
min: 0,
|
|
395
|
+
max: 100,
|
|
396
|
+
above: true,
|
|
397
|
+
what: "the map's window, percent of the kit's spot",
|
|
398
|
+
}),
|
|
399
|
+
lens: Object.freeze({
|
|
400
|
+
kind: 'whole',
|
|
401
|
+
codes: Object.freeze({ 0: 'gamma', 1: 'delta', 2: 'vega' }),
|
|
402
|
+
what: 'the lens',
|
|
403
|
+
fallback: 0,
|
|
404
|
+
}),
|
|
405
|
+
step_rows: Object.freeze({ kind: 'whole', min: 1, max: 1000, what: 'the strike steps each side kept' }),
|
|
406
|
+
carry: Object.freeze({ kind: 'flag', what: "the next bar's drawn strikes kept too", fallback: 0 }),
|
|
407
|
+
levels: Object.freeze({ kind: 'flag', what: 'one levels row per bar', fallback: 0 }),
|
|
408
|
+
}),
|
|
409
|
+
});
|
|
410
|
+
/** What `expiries` takes beside the strike kit fold (the SDK's `WRUN_OPTION_STRIKES_KIT_EXPIRIES_TAKES`, kit 0.91.1):
|
|
411
|
+
* the fold keeps its expiries with its own `nearest`, so any other word beside it is refused at declaration. */
|
|
412
|
+
export const WRUN_OPTION_STRIKES_KIT_EXPIRIES_TAKES = '"all" (or no expiries) beside fold "kit": the fold keeps its expiries with its own `nearest`';
|
|
413
|
+
/** A per-bar class, or undefined for a class that declares no per-bar word. */
|
|
414
|
+
export function wrunOptionLaneClassOf(sourceClass) {
|
|
415
|
+
return sourceClass === 'option_surface' || sourceClass === 'option_strikes' ? sourceClass : undefined;
|
|
416
|
+
}
|
|
417
|
+
/** One word's knobs on a per-bar class (empty for a word the class does not take). */
|
|
418
|
+
export function wrunOptionLaneKnobSpecs(cls, word) {
|
|
419
|
+
return WRUN_OPTION_LANE_WORDS[cls].words.includes(word) ? (WRUN_OPTION_LANE_KNOBS[word] ?? {}) : {};
|
|
420
|
+
}
|
|
421
|
+
/** Every param knob a per-bar class takes, over its words, each once, in table order (the SDK's
|
|
422
|
+
* `wrunOptionViewParamKnobsOf`). */
|
|
423
|
+
export function wrunOptionLaneParamKnobs(cls) {
|
|
424
|
+
const knobs = new Set();
|
|
425
|
+
for (const word of WRUN_OPTION_LANE_WORDS[cls].words) {
|
|
426
|
+
for (const knob of Object.keys(wrunOptionLaneKnobSpecs(cls, word)))
|
|
427
|
+
knobs.add(knob);
|
|
428
|
+
}
|
|
429
|
+
return [...knobs];
|
|
430
|
+
}
|
|
431
|
+
/** Whether a number is a legal value of a per-bar knob, a flag's 0 or 1 included (the SDK's
|
|
432
|
+
* `wrunOptionKnobSpecLegal`). */
|
|
433
|
+
export function wrunOptionKnobSpecLegal(spec, value) {
|
|
434
|
+
if (!Number.isFinite(value))
|
|
435
|
+
return false;
|
|
436
|
+
if (spec.kind === 'flag')
|
|
437
|
+
return value === 0 || value === 1;
|
|
438
|
+
if (spec.codes !== undefined)
|
|
439
|
+
return Object.prototype.hasOwnProperty.call(spec.codes, String(value));
|
|
440
|
+
if (spec.kind === 'whole' && !Number.isInteger(value))
|
|
441
|
+
return false;
|
|
442
|
+
if (spec.min !== undefined && (spec.above === true ? !(value > spec.min) : value < spec.min))
|
|
443
|
+
return false;
|
|
444
|
+
if (spec.max !== undefined && (spec.below === true ? !(value < spec.max) : value > spec.max))
|
|
445
|
+
return false;
|
|
446
|
+
return true;
|
|
447
|
+
}
|
|
448
|
+
/** What a per-bar knob takes, as a refusal spells it (the SDK's `wrunOptionKnobSpecTakes`). */
|
|
449
|
+
export function wrunOptionKnobSpecTakes(spec) {
|
|
450
|
+
if (spec.kind === 'flag')
|
|
451
|
+
return `true or false (${spec.what})`;
|
|
452
|
+
if (spec.codes !== undefined) {
|
|
453
|
+
const codes = Object.entries(spec.codes).map(([code, word]) => `${code} (${word})`);
|
|
454
|
+
return `${spec.what}: ${codes.join(', ')}, or "@<param>" naming a select setting whose picked value it reads`;
|
|
455
|
+
}
|
|
456
|
+
const lo = spec.min === undefined ? '' : `${spec.above === true ? 'above' : 'from'} ${spec.min}`;
|
|
457
|
+
const hi = spec.max === undefined ? '' : `${spec.below === true ? 'below' : 'up to'} ${spec.max}`;
|
|
458
|
+
const span = [lo, hi].filter((part) => part !== '').join(', ');
|
|
459
|
+
const kind = spec.kind === 'whole' ? 'a whole number' : spec.kind === 'time' ? 'an instant in epoch seconds' : 'a number';
|
|
460
|
+
return `${spec.what}, ${kind}${span === '' ? '' : ` ${span}`}, or "@<param>" naming a declared setting`;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* ONE reader of a per-bar class's knobs, the SDK's `wrunOptionViewAskOf` for `option_surface` and `option_strikes`
|
|
464
|
+
* (no handle option: a `"@<param>"` the paint seam did not replace is refused as any other value): the ask, or
|
|
465
|
+
* undefined when the input declares neither the word nor a param of it, or the first issue in the SDK's order (the
|
|
466
|
+
* word; each declared param in table order, taken by the word and legal on it; each required param; an `expiries` word
|
|
467
|
+
* other than "all" beside the kit fold, `WRUN_OPTION_STRIKES_KIT_EXPIRIES_TAKES`). Pure: the lane's facets refuse its
|
|
468
|
+
* issue by name (`wrunOptionLaneAskOfSource`), its per-input projection reads the ask.
|
|
469
|
+
*/
|
|
470
|
+
export function wrunOptionLaneAskOf(source) {
|
|
471
|
+
const cls = wrunOptionLaneClassOf(source.source);
|
|
472
|
+
if (cls === undefined)
|
|
473
|
+
return undefined;
|
|
474
|
+
const { knob: wordKnob, words: known } = WRUN_OPTION_LANE_WORDS[cls];
|
|
475
|
+
const paramKnobs = wrunOptionLaneParamKnobs(cls);
|
|
476
|
+
if (source[wordKnob] === undefined && paramKnobs.every((knob) => source[knob] === undefined))
|
|
477
|
+
return undefined;
|
|
478
|
+
const issues = [];
|
|
479
|
+
const declared = source[wordKnob];
|
|
480
|
+
const word = typeof declared === 'string' && known.includes(declared) ? declared : undefined;
|
|
481
|
+
if (word === undefined) {
|
|
482
|
+
issues.push({
|
|
483
|
+
knob: wordKnob,
|
|
484
|
+
value: declared ?? '(none)',
|
|
485
|
+
takes: `one of ${known.map((candidate) => `"${candidate}"`).join(', ')}`,
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
for (const knob of paramKnobs) {
|
|
489
|
+
const value = source[knob];
|
|
490
|
+
if (value === undefined)
|
|
491
|
+
continue;
|
|
492
|
+
const spec = word === undefined ? undefined : wrunOptionLaneKnobSpecs(cls, word)[knob];
|
|
493
|
+
if (spec === undefined) {
|
|
494
|
+
if (word !== undefined) {
|
|
495
|
+
const owners = known.filter((candidate) => wrunOptionLaneKnobSpecs(cls, candidate)[knob] !== undefined);
|
|
496
|
+
issues.push({ knob, value, takes: `a param of ${owners.map((owner) => `"${owner}"`).join(', ')} only` });
|
|
497
|
+
}
|
|
498
|
+
continue;
|
|
499
|
+
}
|
|
500
|
+
if (spec.kind === 'flag') {
|
|
501
|
+
if (typeof value !== 'boolean')
|
|
502
|
+
issues.push({ knob, value, takes: wrunOptionKnobSpecTakes(spec) });
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
if (typeof value !== 'number' || !wrunOptionKnobSpecLegal(spec, value)) {
|
|
506
|
+
issues.push({ knob, value, takes: `${wrunOptionKnobSpecTakes(spec)} (${word})` });
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
if (word !== undefined) {
|
|
510
|
+
for (const [knob, spec] of Object.entries(wrunOptionLaneKnobSpecs(cls, word))) {
|
|
511
|
+
if (spec.fallback === undefined && source[knob] === undefined) {
|
|
512
|
+
issues.push({ knob, value: '(none)', takes: `${wrunOptionKnobSpecTakes(spec)} (required by "${word}")` });
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
if (cls === 'option_strikes' && word === 'kit' && source.expiries !== undefined && source.expiries !== 'all') {
|
|
517
|
+
issues.push({ knob: 'expiries', value: source.expiries, takes: WRUN_OPTION_STRIKES_KIT_EXPIRIES_TAKES });
|
|
518
|
+
}
|
|
519
|
+
if (issues.length > 0 || word === undefined)
|
|
520
|
+
return { issue: issues[0] };
|
|
521
|
+
const params = {};
|
|
522
|
+
for (const [knob, spec] of Object.entries(wrunOptionLaneKnobSpecs(cls, word))) {
|
|
523
|
+
const value = source[knob];
|
|
524
|
+
if (typeof value === 'number')
|
|
525
|
+
params[knob] = value;
|
|
526
|
+
else if (typeof value === 'boolean')
|
|
527
|
+
params[knob] = value ? 1 : 0;
|
|
528
|
+
else if (spec.fallback !== undefined)
|
|
529
|
+
params[knob] = spec.fallback;
|
|
530
|
+
}
|
|
531
|
+
return { ask: { cls, word, params } };
|
|
532
|
+
}
|
|
533
|
+
/** An input's per-bar ask, its first issue refused by name (`wrun_option_knob_invalid`): undefined when it declares no
|
|
534
|
+
* per-bar knob (today's read). */
|
|
535
|
+
export function wrunOptionLaneAskOfSource(source, ctx) {
|
|
536
|
+
const read = wrunOptionLaneAskOf(source);
|
|
537
|
+
if (read === undefined)
|
|
538
|
+
return undefined;
|
|
539
|
+
if ('issue' in read)
|
|
540
|
+
return refuseWrunOptionKnob(ctx, read.issue.knob, read.issue.value, read.issue.takes);
|
|
541
|
+
return read.ask;
|
|
542
|
+
}
|
|
543
|
+
/** f64s per row of a view block (the page views' folds) and of the strike kit fold (the SDK's
|
|
544
|
+
* `WRUN_OPTION_VIEW_ROW_WIDTHS`): the layout, then the widest layout's fields. */
|
|
545
|
+
export const WRUN_OPTION_VIEW_ROW_WIDTHS = Object.freeze({
|
|
546
|
+
options_chain: 11,
|
|
547
|
+
option_contract_state: 16,
|
|
548
|
+
option_strikes: 14,
|
|
549
|
+
});
|
|
550
|
+
/** Column 0 of every strike kit fold row (the SDK's `WRUN_OPTION_STRIKES_KIT_LAYOUTS`). */
|
|
551
|
+
export const WRUN_OPTION_STRIKES_KIT_LAYOUTS = Object.freeze({ strike: 0, levels: 1 });
|
|
552
|
+
/** The column of a kit levels row that says the bar was refused (its newest minute held more rows than the input's
|
|
553
|
+
* `max_cells`): 1 refused, 0 served. */
|
|
554
|
+
export const WRUN_OPTION_STRIKES_KIT_REFUSED_COLUMN = 13;
|
|
555
|
+
/**
|
|
556
|
+
* The f64s per tuple one input's block carries (the SDK's `wrunOptionInputTupleWidth`, the one rule every host sizes
|
|
557
|
+
* by): a view block's row width when its words name a fold (a page view fold, the strike kit fold), else the class's
|
|
558
|
+
* own width. The words alone decide it, never a param, so a setting never resizes a block.
|
|
559
|
+
*/
|
|
560
|
+
export function wrunOptionInputTupleWidth(source, classWidth) {
|
|
561
|
+
const cls = source.source;
|
|
562
|
+
if (cls === 'option_strikes') {
|
|
563
|
+
return source[WRUN_OPTION_LANE_WORDS.option_strikes.knob] === 'kit'
|
|
564
|
+
? WRUN_OPTION_VIEW_ROW_WIDTHS.option_strikes
|
|
565
|
+
: classWidth;
|
|
566
|
+
}
|
|
567
|
+
if (cls !== 'options_chain' && cls !== 'option_contract_state')
|
|
568
|
+
return classWidth;
|
|
569
|
+
const folds = wrunOptionViewWordsDeclared(source).some((word) => {
|
|
570
|
+
const spec = wrunOptionViewSpec(word);
|
|
571
|
+
return spec?.cls === cls && spec.answer === 'fold';
|
|
572
|
+
});
|
|
573
|
+
return folds ? WRUN_OPTION_VIEW_ROW_WIDTHS[cls] : classWidth;
|
|
574
|
+
}
|
|
575
|
+
/** pb-common `OptionSurfacePick` by word (the gateway decodes numbers, never names). */
|
|
576
|
+
export const WRUN_OPTION_SURFACE_PICK_CODES = Object.freeze({
|
|
577
|
+
nearest_days: 1,
|
|
578
|
+
tenor_bracket: 2,
|
|
579
|
+
});
|
|
580
|
+
/** pb-common `StrikeMetric` by the kit fold's lens code (0 gamma, 1 delta, 2 vega): NET_GEX, DEX, VEX. */
|
|
581
|
+
export const WRUN_OPTION_STRIKES_KIT_METRICS = Object.freeze({ 0: 1, 1: 2, 2: 3 });
|
|
582
|
+
/**
|
|
583
|
+
* The `OptionReadShape` G5 fields (pb-common 12.72.0, fields 40 to 51) a per-bar ask names, as they ride the lane's
|
|
584
|
+
* payload and the gateway reads them (JSON names, enums as numbers):
|
|
585
|
+
* - the surface pick: `surfacePick` (1 nearest_days, 2 tenor_bracket) with `surfaceDays` and `surfaceDelta` (25 or
|
|
586
|
+
* 10, the wings) or `surfaceTenorDays`;
|
|
587
|
+
* - the strike kit fold: `strikeKitFold`, `strikeNearest`, `strikeKitWindowPct`, `strikeStepRows`, `strikeCarryNext`,
|
|
588
|
+
* `strikeLevels`, `strikeMaxCells` (the input's `max_cells`: a minute with more rows answers a refused levels row)
|
|
589
|
+
* and `strikeKitMetric` (the lens).
|
|
590
|
+
* The fields key the lane instance, so two inputs asking two picks are two reads, and an input declaring no word asks
|
|
591
|
+
* none of them (today's read).
|
|
592
|
+
*/
|
|
593
|
+
export function wrunOptionLaneAskFields(ask, facts = {}) {
|
|
594
|
+
const { params } = ask;
|
|
595
|
+
if (ask.cls === 'option_surface') {
|
|
596
|
+
return ask.word === 'nearest_days'
|
|
597
|
+
? {
|
|
598
|
+
surfacePick: WRUN_OPTION_SURFACE_PICK_CODES.nearest_days,
|
|
599
|
+
surfaceDays: params.days,
|
|
600
|
+
surfaceDelta: params.delta === 1 ? 10 : 25,
|
|
601
|
+
}
|
|
602
|
+
: { surfacePick: WRUN_OPTION_SURFACE_PICK_CODES.tenor_bracket, surfaceTenorDays: params.tenor };
|
|
603
|
+
}
|
|
604
|
+
return {
|
|
605
|
+
strikeKitFold: true,
|
|
606
|
+
strikeNearest: params.nearest,
|
|
607
|
+
strikeKitWindowPct: params.window_pct,
|
|
608
|
+
strikeStepRows: params.step_rows,
|
|
609
|
+
strikeCarryNext: params.carry === 1,
|
|
610
|
+
strikeLevels: params.levels === 1,
|
|
611
|
+
...(facts.maxCells !== undefined ? { strikeMaxCells: facts.maxCells } : {}),
|
|
612
|
+
strikeKitMetric: WRUN_OPTION_STRIKES_KIT_METRICS[params.lens] ?? WRUN_OPTION_STRIKES_KIT_METRICS[0],
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
/** The payload fields of a per-bar ask, by class (the K controls copy exactly these onto the request they build). */
|
|
616
|
+
const WRUN_OPTION_LANE_PAYLOAD_FIELDS = Object.freeze({
|
|
617
|
+
option_surface: Object.freeze(['surfacePick', 'surfaceDays', 'surfaceDelta', 'surfaceTenorDays']),
|
|
618
|
+
option_strikes: Object.freeze([
|
|
619
|
+
'strikeKitFold',
|
|
620
|
+
'strikeNearest',
|
|
621
|
+
'strikeKitWindowPct',
|
|
622
|
+
'strikeStepRows',
|
|
623
|
+
'strikeCarryNext',
|
|
624
|
+
'strikeLevels',
|
|
625
|
+
'strikeMaxCells',
|
|
626
|
+
'strikeKitMetric',
|
|
627
|
+
]),
|
|
628
|
+
});
|
|
629
|
+
/** A per-bar ask's fields of a payload, as they ride (a K control copies them onto the request it builds). */
|
|
630
|
+
export function wrunOptionLanePayloadFields(cls, payload) {
|
|
631
|
+
const fields = {};
|
|
632
|
+
for (const key of WRUN_OPTION_LANE_PAYLOAD_FIELDS[cls])
|
|
633
|
+
if (payload?.[key] !== undefined)
|
|
634
|
+
fields[key] = payload[key];
|
|
635
|
+
return fields;
|
|
636
|
+
}
|
|
637
|
+
function finiteOrUndefined(value) {
|
|
638
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
639
|
+
}
|
|
640
|
+
/** A payload's per-bar ask (the worker twins): its G5 fields, each of its own type, or undefined when it names no
|
|
641
|
+
* word of its class (`surfacePick` 1 or 2, `strikeKitFold` true). */
|
|
642
|
+
export function wrunOptionLaneAskOfPayload(cls, payload) {
|
|
643
|
+
if (cls === 'option_surface') {
|
|
644
|
+
const pick = payload.surfacePick;
|
|
645
|
+
if (pick !== WRUN_OPTION_SURFACE_PICK_CODES.nearest_days && pick !== WRUN_OPTION_SURFACE_PICK_CODES.tenor_bracket) {
|
|
646
|
+
return undefined;
|
|
647
|
+
}
|
|
648
|
+
const days = finiteOrUndefined(payload.surfaceDays);
|
|
649
|
+
const delta = finiteOrUndefined(payload.surfaceDelta);
|
|
650
|
+
const tenor = finiteOrUndefined(payload.surfaceTenorDays);
|
|
651
|
+
return {
|
|
652
|
+
surfacePick: pick,
|
|
653
|
+
...(pick === WRUN_OPTION_SURFACE_PICK_CODES.nearest_days && days !== undefined ? { surfaceDays: days } : {}),
|
|
654
|
+
...(pick === WRUN_OPTION_SURFACE_PICK_CODES.nearest_days && delta !== undefined ? { surfaceDelta: delta } : {}),
|
|
655
|
+
...(pick === WRUN_OPTION_SURFACE_PICK_CODES.tenor_bracket && tenor !== undefined
|
|
656
|
+
? { surfaceTenorDays: tenor }
|
|
657
|
+
: {}),
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
if (payload.strikeKitFold !== true)
|
|
661
|
+
return undefined;
|
|
662
|
+
const read = { strikeKitFold: true };
|
|
663
|
+
for (const key of [
|
|
664
|
+
'strikeNearest',
|
|
665
|
+
'strikeKitWindowPct',
|
|
666
|
+
'strikeStepRows',
|
|
667
|
+
'strikeMaxCells',
|
|
668
|
+
'strikeKitMetric',
|
|
669
|
+
]) {
|
|
670
|
+
const value = finiteOrUndefined(payload[key]);
|
|
671
|
+
if (value !== undefined)
|
|
672
|
+
read[key] = value;
|
|
673
|
+
}
|
|
674
|
+
read.strikeCarryNext = payload.strikeCarryNext === true;
|
|
675
|
+
read.strikeLevels = payload.strikeLevels === true;
|
|
676
|
+
return read;
|
|
677
|
+
}
|
|
678
|
+
/** The kit fold's params by knob (the SDK reference's names) off a payload's ask, the lens back to its code. */
|
|
679
|
+
export function wrunOptionStrikesKitParamsOf(read) {
|
|
680
|
+
const lens = Object.entries(WRUN_OPTION_STRIKES_KIT_METRICS).find(([, metric]) => metric === read.strikeKitMetric);
|
|
681
|
+
return {
|
|
682
|
+
nearest: read.strikeNearest ?? 0,
|
|
683
|
+
window_pct: read.strikeKitWindowPct ?? 0,
|
|
684
|
+
lens: lens === undefined ? 0 : Number(lens[0]),
|
|
685
|
+
step_rows: read.strikeStepRows ?? 48,
|
|
686
|
+
carry: read.strikeCarryNext === true ? 1 : 0,
|
|
687
|
+
levels: read.strikeLevels === true ? 1 : 0,
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
/** Whether a lane instance's acquisition asks a per-bar word (a pick or the kit fold): its rows are landed on the
|
|
691
|
+
* chart's bars by the gateway (or by the lane's own fallback by the same rules). */
|
|
692
|
+
export function wrunOptionLaneAcquisitionAsks(sourceClass, acquisition) {
|
|
693
|
+
const cls = wrunOptionLaneClassOf(sourceClass);
|
|
694
|
+
return cls !== undefined && wrunOptionLaneAskOfPayload(cls, acquisition) !== undefined;
|
|
695
|
+
}
|
|
696
|
+
/** Whether an instance's acquisition asks the kit fold with `carry`: each bar's rows then hold the strikes the NEXT bar
|
|
697
|
+
* with rows draws, and the gateway's carry stops at its read window, so a paged read must ask each older page through
|
|
698
|
+
* the newer page's first bar with rows (wrun-row-lanes.util `fetchWrunRowLaneRows`). */
|
|
699
|
+
export function wrunOptionLaneCarriesNext(sourceClass, acquisition) {
|
|
700
|
+
return sourceClass === 'option_strikes' && acquisition.strikeKitFold === true && acquisition.strikeCarryNext === true;
|
|
701
|
+
}
|
|
702
|
+
/** Whether one landed kit fold bar has rows the carry reads: any row, its levels row not the refusal (a refused bar
|
|
703
|
+
* keeps no strike, so the carry passes over it to the next bar). */
|
|
704
|
+
export function wrunOptionKitBarHasRows(tuples) {
|
|
705
|
+
if (tuples.length === 0)
|
|
706
|
+
return false;
|
|
707
|
+
return !tuples.some((tuple) => Array.isArray(tuple) &&
|
|
708
|
+
tuple[0] === WRUN_OPTION_STRIKES_KIT_LAYOUTS.levels &&
|
|
709
|
+
tuple[WRUN_OPTION_STRIKES_KIT_REFUSED_COLUMN] === 1);
|
|
710
|
+
}
|
|
711
|
+
/** The f64s per row an instance's rows carry, by its facets: the kit fold's rows on an instance asking it, else the
|
|
712
|
+
* class's own tuple (`classWidth`). */
|
|
713
|
+
export function wrunOptionLaneTupleWidth(sourceClass, acquisition, classWidth) {
|
|
714
|
+
return sourceClass === 'option_strikes' && acquisition.strikeKitFold === true
|
|
715
|
+
? WRUN_OPTION_VIEW_ROW_WIDTHS.option_strikes
|
|
716
|
+
: classWidth;
|
|
717
|
+
}
|
|
718
|
+
/** The rows a strike kit fold bar is projected to hold for the first paint: the levels row, the window's strikes
|
|
719
|
+
* within `step_rows` + 1 finest steps each side of the centre, the finest pair and the two edges. */
|
|
720
|
+
function wrunOptionStrikesKitBarRows(acquisition) {
|
|
721
|
+
const stepRows = finiteOrUndefined(acquisition.strikeStepRows) ?? 48;
|
|
722
|
+
return 1 + 2 * (Math.max(0, stepRows) + 1) + 1 + 4;
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* The row budget the first-paint slice sizes an instance asking a per-bar word by (wrun-row-lane-first-paint.util, the
|
|
726
|
+
* slice FE-STRIKE-LANE added; no second one): the answered row's cells and the rows one bar is projected to hold (a
|
|
727
|
+
* nearest_days pick 1, a tenor bracket 2, a kit fold bar its levels row and drawn strikes). Undefined for an instance
|
|
728
|
+
* that asks no per-bar word: its asks are today's, unsliced.
|
|
729
|
+
*/
|
|
730
|
+
export function wrunOptionLaneFirstPaintBudget(sourceClass, acquisition, classWidth) {
|
|
731
|
+
if (!wrunOptionLaneAcquisitionAsks(sourceClass, acquisition))
|
|
732
|
+
return undefined;
|
|
733
|
+
const cellsPerRow = wrunOptionLaneTupleWidth(sourceClass, acquisition, classWidth);
|
|
734
|
+
const rows = sourceClass === 'option_strikes'
|
|
735
|
+
? wrunOptionStrikesKitBarRows(acquisition)
|
|
736
|
+
: acquisition.surfacePick === WRUN_OPTION_SURFACE_PICK_CODES.tenor_bracket
|
|
737
|
+
? 2
|
|
738
|
+
: 1;
|
|
739
|
+
return { cellsPerRow, barRows: () => rows };
|
|
740
|
+
}
|
|
741
|
+
/** The option_surface tuple's width and its `present` bits: dte_days 1, iv_p25 4, iv_c25 5, iv_p10 6, iv_c10 7. */
|
|
742
|
+
const SURFACE_WIDTH = 9;
|
|
743
|
+
const SURFACE_BIT = Object.freeze({ dteDays: 1, ivP25: 4, ivC25: 5, ivP10: 6, ivC10: 7 });
|
|
744
|
+
/**
|
|
745
|
+
* One bar's option_surface block under a pick, the SDK's reference (`wrunOptionSurfacePick` and
|
|
746
|
+
* `wrunOptionSurfacePickBlock`, wrun-host/option-views.ts) on the bar's tuples:
|
|
747
|
+
* - `nearest_days` (Skew History): the tuple with dte_days served and at least 1 and both wings served at `delta` (0:
|
|
748
|
+
* iv_p25 and iv_c25, 1: iv_p10 and iv_c10), its dte nearest `days`, the earlier expiry on a tie (the first tuple on
|
|
749
|
+
* an exact one);
|
|
750
|
+
* - `tenor_bracket` (Options Sentiment's AVAR): the anchors (dte_days and both 25-delta wings served, dte above 0.5
|
|
751
|
+
* and both wings above 0) ordered by dte, ties in the block's order; the one before the first at or past `tenor`
|
|
752
|
+
* days and that one, or the first alone, or the last alone.
|
|
753
|
+
* The kept tuples ride in the block's order. A bar that held tuples and whose pick keeps none answers one all-zero
|
|
754
|
+
* tuple (a served bar still reads served); a partial bar's bit 14 rides the first tuple of the answer. Idempotent: a
|
|
755
|
+
* bar the gateway already picked picks to itself, so the gateway's answer and today's read land the same block.
|
|
756
|
+
*/
|
|
757
|
+
export function wrunOptionSurfacePickTuples(tuples, word, params) {
|
|
758
|
+
const blocks = tuples.filter((tuple) => tuple.length === SURFACE_WIDTH);
|
|
759
|
+
const present = (tuple) => tuple[SURFACE_WIDTH - 1];
|
|
760
|
+
const partial = blocks.some((tuple) => wrunPresentIsPartial(present(tuple)));
|
|
761
|
+
let kept = [];
|
|
762
|
+
if (word === 'nearest_days') {
|
|
763
|
+
const tenDelta = (params.delta ?? 0) === 1;
|
|
764
|
+
const putBit = tenDelta ? SURFACE_BIT.ivP10 : SURFACE_BIT.ivP25;
|
|
765
|
+
const callBit = tenDelta ? SURFACE_BIT.ivC10 : SURFACE_BIT.ivC25;
|
|
766
|
+
const targetDays = params.days ?? Number.NaN;
|
|
767
|
+
let best = -1;
|
|
768
|
+
let bestGap = Number.POSITIVE_INFINITY;
|
|
769
|
+
let bestExpiry = Number.POSITIVE_INFINITY;
|
|
770
|
+
blocks.forEach((tuple, at) => {
|
|
771
|
+
const mask = present(tuple);
|
|
772
|
+
if (!wrunPresentHasBit(mask, SURFACE_BIT.dteDays) ||
|
|
773
|
+
!wrunPresentHasBit(mask, putBit) ||
|
|
774
|
+
!wrunPresentHasBit(mask, callBit)) {
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
const dte = tuple[1];
|
|
778
|
+
if (!(dte >= 1.0))
|
|
779
|
+
return;
|
|
780
|
+
const gap = Math.abs(dte - targetDays);
|
|
781
|
+
const expiry = tuple[0];
|
|
782
|
+
if (gap < bestGap || (gap === bestGap && expiry < bestExpiry)) {
|
|
783
|
+
bestGap = gap;
|
|
784
|
+
bestExpiry = expiry;
|
|
785
|
+
best = at;
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
kept = best >= 0 ? [best] : [];
|
|
789
|
+
}
|
|
790
|
+
else if (word === 'tenor_bracket') {
|
|
791
|
+
const anchors = [];
|
|
792
|
+
blocks.forEach((tuple, at) => {
|
|
793
|
+
const mask = present(tuple);
|
|
794
|
+
if (!wrunPresentHasBit(mask, SURFACE_BIT.dteDays) ||
|
|
795
|
+
!wrunPresentHasBit(mask, SURFACE_BIT.ivP25) ||
|
|
796
|
+
!wrunPresentHasBit(mask, SURFACE_BIT.ivC25)) {
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
const days = tuple[1];
|
|
800
|
+
if (!(days > 0.5) || !(tuple[4] > 0.0) || !(tuple[5] > 0.0))
|
|
801
|
+
return;
|
|
802
|
+
let k = anchors.length;
|
|
803
|
+
anchors.push({ at, days });
|
|
804
|
+
while (k > 0 && anchors[k - 1].days > days) {
|
|
805
|
+
anchors[k] = anchors[k - 1];
|
|
806
|
+
k -= 1;
|
|
807
|
+
}
|
|
808
|
+
anchors[k] = { at, days };
|
|
809
|
+
});
|
|
810
|
+
if (anchors.length > 0) {
|
|
811
|
+
const years = (params.tenor ?? Number.NaN) / 365.0;
|
|
812
|
+
kept = [anchors[anchors.length - 1].at];
|
|
813
|
+
for (let k = 0; k < anchors.length; k += 1) {
|
|
814
|
+
if (years <= anchors[k].days / 365.0) {
|
|
815
|
+
kept = k === 0 ? [anchors[0].at] : [anchors[k - 1].at, anchors[k].at];
|
|
816
|
+
break;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
kept = [...new Set(kept)].sort((a, b) => a - b);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
else {
|
|
823
|
+
return blocks.map((tuple) => [...tuple]);
|
|
824
|
+
}
|
|
825
|
+
const out = kept.map((at) => [...blocks[at]]);
|
|
826
|
+
if (out.length === 0 && blocks.length > 0)
|
|
827
|
+
out.push(new Array(SURFACE_WIDTH).fill(0));
|
|
828
|
+
if (partial && out.length > 0)
|
|
829
|
+
out[0][SURFACE_WIDTH - 1] = wrunPresentWithPartial(present(out[0]));
|
|
830
|
+
return out;
|
|
831
|
+
}
|
|
335
832
|
/**
|
|
336
833
|
* The chart's chain on the OPRA plane by coin, held in place of the chain directory's answer (section 8, O1): the
|
|
337
834
|
* chain `wrunLaneOpraPlaneChain` reads for the chart's coin when the chart's options ride the OPRA plane (the
|
|
@@ -302,10 +302,12 @@ export type WrunOptionsChainTuple = [
|
|
|
302
302
|
multiplier: number,
|
|
303
303
|
vega: number
|
|
304
304
|
];
|
|
305
|
-
/** The worker's block: every instrument of the shared chain snapshot
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
305
|
+
/** The worker's block: every instrument of the shared chain snapshot's
|
|
306
|
+
* dominant book (C0, `filterDominantBooks`: the tuple carries no symbol, so
|
|
307
|
+
* the kit cannot tell `BTC-...` from `BTC_USDC-...` and every card would sum
|
|
308
|
+
* both) as a tuple, ordered by expiry, then strike, calls before puts, then
|
|
309
|
+
* symbol (deterministic whatever order the map holds), zero-OI contracts
|
|
310
|
+
* kept (the raw chain; a package decides what a zero means). */
|
|
309
311
|
export declare function wrunOptionsChainTuples(instruments: Iterable<OptionInstrumentSnapshot>): WrunOptionsChainTuple[];
|
|
310
312
|
/** A lane row `[ts, [tuple], ...]` (the K_OPTIONS_CHAIN worker's shape,
|
|
311
313
|
* nested like the volume-profile lane's) read back as tuples; a malformed
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { filterDominantBooks } from '../options/option-book.util.js';
|
|
1
2
|
/** f64s per contract tuple (the shared host's `WRUN_HOST_CELL_TUPLE_WIDTHS.options_chain`, the width
|
|
2
3
|
* the packer packs; wrun-source-words.kit-mirror.spec.ts pins it). */
|
|
3
4
|
export const WRUN_OPTIONS_CHAIN_TUPLE_WIDTH = 10;
|
|
@@ -453,12 +454,14 @@ export function wrunOptionsChainOneVenueRefusal(firstInputName, inputName) {
|
|
|
453
454
|
reason: 'one-venue',
|
|
454
455
|
};
|
|
455
456
|
}
|
|
456
|
-
/** The worker's block: every instrument of the shared chain snapshot
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
457
|
+
/** The worker's block: every instrument of the shared chain snapshot's
|
|
458
|
+
* dominant book (C0, `filterDominantBooks`: the tuple carries no symbol, so
|
|
459
|
+
* the kit cannot tell `BTC-...` from `BTC_USDC-...` and every card would sum
|
|
460
|
+
* both) as a tuple, ordered by expiry, then strike, calls before puts, then
|
|
461
|
+
* symbol (deterministic whatever order the map holds), zero-OI contracts
|
|
462
|
+
* kept (the raw chain; a package decides what a zero means). */
|
|
460
463
|
export function wrunOptionsChainTuples(instruments) {
|
|
461
|
-
const entries =
|
|
464
|
+
const entries = filterDominantBooks(instruments).filter((snap) => Number.isFinite(snap.strike) && snap.strike > 0 && Number.isFinite(snap.expiryMs));
|
|
462
465
|
entries.sort((a, b) => a.expiryMs - b.expiryMs ||
|
|
463
466
|
a.strike - b.strike ||
|
|
464
467
|
(a.side === b.side ? 0 : a.side === 'CALL' ? -1 : 1) ||
|
|
@@ -39,7 +39,8 @@ import { type WrunRefusalGatePlane } from './wrun-refusal.util.js';
|
|
|
39
39
|
* flag and the execution guard (the guarded engine calls), replay (only the
|
|
40
40
|
* replay lane's run draws over replay rows), the ONE fetch gate (`isIndicatorGatedForFetch`:
|
|
41
41
|
* mode or pane budget), a collapsed or pane-hidden pane for the
|
|
42
|
-
* loaded-range-refresh family only
|
|
42
|
+
* loaded-range-refresh family only (never a pane its window hid, which is
|
|
43
|
+
* the window's layout: isPaneHiddenByWindow), the CME display wall (the run head
|
|
43
44
|
* refuses it too; read here so a heal or a rung declines instead of spending
|
|
44
45
|
* a run), then the narrow deterministic latch for the waves and the heal
|
|
45
46
|
* (`failedDeterministicHold`). Null for an id with no driver, without loading
|
|
@@ -5,6 +5,7 @@ import { attachWrunRefusal } from './wrun-refusal.util.js';
|
|
|
5
5
|
import { onGateSessionLatchChange } from '../v2/gate-session-latch.util.js';
|
|
6
6
|
import { __resetWrunGatePlaneReadersForTests, forgetWrunGatePlaneReader, wrunGatePlaneReaders, } from './wrun-gate-plane-readers.util.js';
|
|
7
7
|
import { overlayExecutionGuardKey } from '../chart/overlay-execution-guard-key.leaf.js';
|
|
8
|
+
import { isPaneHiddenByWindow } from '../chart/window-owner.leaf.js';
|
|
8
9
|
import { LOCAL_ENGINE_SELF_HEAL_BASE_DELAY_MS, openLocalEngineSelfHealGate, recordLocalEngineSelfHealAttempt, } from '../chart/local-engine-self-heal-backoff.util.js';
|
|
9
10
|
import { KSCRIPT_SECONDARY_SOURCE_MAX_RECOVERY_ATTEMPTS, KSCRIPT_SECONDARY_SOURCE_RETRY_DELAYS_MS, } from '../chart/kscript-source-degrade.leaf.js';
|
|
10
11
|
import { __resetWrunLateReadsForTests, forgetWrunLateReads, onWrunLateReadSettled, wrunLateReadsAnswered, wrunLateReadsOut, } from './run-schedule/wrun-late-reads.util.js';
|
|
@@ -82,7 +83,8 @@ function loadWrunStoreSide() {
|
|
|
82
83
|
* flag and the execution guard (the guarded engine calls), replay (only the
|
|
83
84
|
* replay lane's run draws over replay rows), the ONE fetch gate (`isIndicatorGatedForFetch`:
|
|
84
85
|
* mode or pane budget), a collapsed or pane-hidden pane for the
|
|
85
|
-
* loaded-range-refresh family only
|
|
86
|
+
* loaded-range-refresh family only (never a pane its window hid, which is
|
|
87
|
+
* the window's layout: isPaneHiddenByWindow), the CME display wall (the run head
|
|
86
88
|
* refuses it too; read here so a heal or a rung declines instead of spending
|
|
87
89
|
* a run), then the narrow deterministic latch for the waves and the heal
|
|
88
90
|
* (`failedDeterministicHold`). Null for an id with no driver, without loading
|
|
@@ -121,8 +123,11 @@ candidate = {}) {
|
|
|
121
123
|
.find((candidate) => candidate?.id === indicatorId);
|
|
122
124
|
const metas = getTC(chartIndex)?.metadata;
|
|
123
125
|
const meta = metas?.find((entry) => entry?.id === indicatorId);
|
|
126
|
+
// A pane its window hid because the owner draws nothing there (window-geometry.leaf, C5) is the window's layout,
|
|
127
|
+
// not the reader's collapse: the owner's runs feed the window's tables, so they never hold on it.
|
|
128
|
+
const paneCollapsed = meta?.isPaneHidden === true && !isPaneHiddenByWindow(meta);
|
|
124
129
|
if (COLLAPSED_HOLD_REASONS.has(reason) &&
|
|
125
|
-
(overlay?.isBottomPaneCollapsed === true || overlay?.isPaneHidden === true ||
|
|
130
|
+
(overlay?.isBottomPaneCollapsed === true || overlay?.isPaneHidden === true || paneCollapsed)) {
|
|
126
131
|
return 'collapsed';
|
|
127
132
|
}
|
|
128
133
|
// The run head's reading: the workspace's exchange against the mounted
|