@orangecharts/wrun-chart-host 0.10.0 → 0.11.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 +1 -0
- package/dist/constants/feature-flags.constants.d.ts +9 -0
- package/dist/constants/feature-flags.constants.js +67 -4
- package/dist/constants/governed-exchanges.constants.d.ts +12 -0
- package/dist/constants/governed-exchanges.constants.js +16 -0
- package/dist/constants/option-venues.constants.d.ts +2 -2
- package/dist/host-env.d.ts +1 -9
- package/dist/host-ports.types.d.ts +36 -7
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/dist/interfaces/cancel-reason.interface.d.ts +1 -1
- package/dist/interfaces/cme-realtime.interface.d.ts +16 -9
- package/dist/interfaces/cme-realtime.interface.js +6 -3
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +1 -5
- package/dist/interfaces/prediction-market.interface.d.ts +7 -0
- package/dist/interfaces/stocks-realtime.interface.d.ts +57 -0
- package/dist/interfaces/stocks-realtime.interface.js +32 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +48 -117
- package/dist/kscript-data/controls/live-trades-merge.util.js +97 -207
- package/dist/market-data/billing.interface.d.ts +86 -12
- package/dist/market-data/billing.interface.js +23 -4
- package/dist/market-data/venue.d.ts +65 -2
- package/dist/market-data/venues/index.d.ts +135 -5
- package/dist/market-data/venues/index.js +2 -1
- package/dist/market-data/venues/opra.contract.copy.json +3 -2
- package/dist/market-data/venues/opra.d.ts +2 -2
- package/dist/market-data/venues/opra.js +5 -2
- package/dist/market-data/venues/stocks.contract.copy.json +64 -0
- package/dist/market-data/venues/stocks.d.ts +130 -0
- package/dist/market-data/venues/stocks.js +117 -0
- package/dist/settings-templates/footprint-rows.js +35 -2
- package/dist/settings-templates/form-rows.d.ts +2 -1
- package/dist/settings-templates/indicator-fields.js +34 -4
- package/dist/settings-templates/tool-rules.d.ts +12 -5
- package/dist/settings-templates/tool-rules.js +11 -5
- package/dist/settings-templates/tool-tables.generated.js +4 -0
- package/dist/utility/chart/cme-cache-context.util.d.ts +5 -3
- package/dist/utility/chart/cme-cache-context.util.js +10 -6
- package/dist/utility/chart/cme-realtime.util.js +10 -0
- package/dist/utility/chart/cme-user-scripts-gate.util.d.ts +83 -0
- package/dist/utility/chart/cme-user-scripts-gate.util.js +142 -0
- package/dist/utility/chart/effective-chart-session.util.d.ts +14 -0
- package/dist/utility/chart/effective-chart-session.util.js +39 -0
- package/dist/utility/chart/host-bar-placement.util.d.ts +28 -0
- package/dist/utility/chart/host-bar-placement.util.js +170 -30
- package/dist/utility/chart/index-host-tier.util.d.ts +3 -1
- package/dist/utility/chart/index-host-tier.util.js +7 -2
- package/dist/utility/chart/index-mode-admission.util.js +25 -11
- package/dist/utility/chart/kscript-apply-fingerprint.util.js +1 -1
- package/dist/utility/chart/kscript-live-coalesce.util.d.ts +6 -9
- package/dist/utility/chart/kscript-live-coalesce.util.js +8 -9
- package/dist/utility/chart/kscript-live-source-identity.util.d.ts +9 -0
- package/dist/utility/chart/kscript-live-source-identity.util.js +10 -1
- package/dist/utility/chart/kscript-provenance-keys.util.js +7 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +115 -21
- package/dist/utility/chart/kscript-venue-policy.util.js +194 -40
- package/dist/utility/chart/live-bucket.util.d.ts +24 -8
- package/dist/utility/chart/live-bucket.util.js +85 -27
- package/dist/utility/chart/marketKind.util.js +5 -0
- package/dist/utility/chart/mixed-mode.util.d.ts +7 -0
- package/dist/utility/chart/mixed-mode.util.js +14 -0
- package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +11 -16
- package/dist/utility/chart/opra-user-scripts-gate.util.js +12 -28
- package/dist/utility/chart/rth-session.util.d.ts +9 -8
- package/dist/utility/chart/rth-session.util.js +23 -20
- package/dist/utility/chart/trading-day.util.d.ts +17 -0
- package/dist/utility/chart/trading-day.util.js +59 -0
- package/dist/utility/chart/window-owner.leaf.d.ts +23 -2
- package/dist/utility/chart/window-owner.leaf.js +45 -3
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +33 -15
- package/dist/utility/chart/wrun-bar-session-facts.util.js +70 -20
- package/dist/utility/intl-locale.util.js +5 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
- package/dist/utility/v2/gate-plane.util.d.ts +12 -3
- package/dist/utility/v2/gate-plane.util.js +30 -4
- package/dist/utility/v2/gate-session-latch.util.js +1 -1
- package/dist/utility/v2/stocks-governed.util.d.ts +16 -0
- package/dist/utility/v2/stocks-governed.util.js +34 -0
- package/dist/utility/wrun/derived-roots.leaf.d.ts +13 -0
- package/dist/utility/wrun/derived-roots.leaf.js +27 -0
- package/dist/utility/wrun/derived-roots.util.d.ts +1 -9
- package/dist/utility/wrun/derived-roots.util.js +3 -23
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +4 -3
- package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +24 -3
- package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +46 -10
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +2 -0
- package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +63 -16
- package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +58 -14
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +34 -11
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +106 -30
- package/dist/utility/wrun/wrun-browser-sources.leaf.js +1 -2
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +7 -4
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +12 -8
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-color-settings.util.js +33 -0
- package/dist/utility/wrun/wrun-handles.util.d.ts +7 -3
- package/dist/utility/wrun/wrun-handles.util.js +9 -8
- package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +68 -0
- package/dist/utility/wrun/wrun-input-requirements.leaf.js +163 -7
- package/dist/utility/wrun/wrun-leg-close.util.d.ts +59 -23
- package/dist/utility/wrun/wrun-leg-close.util.js +186 -28
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +26 -12
- package/dist/utility/wrun/wrun-live-intake.util.js +219 -155
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +9 -5
- package/dist/utility/wrun/wrun-live-tick.util.js +130 -94
- package/dist/utility/wrun/wrun-market-facts.util.d.ts +13 -3
- package/dist/utility/wrun/wrun-market-facts.util.js +13 -3
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +20 -10
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +10 -5
- package/dist/utility/wrun/wrun-option-book-rows.util.d.ts +56 -0
- package/dist/utility/wrun/wrun-option-book-rows.util.js +96 -0
- package/dist/utility/wrun/wrun-option-views.util.d.ts +281 -20
- package/dist/utility/wrun/wrun-option-views.util.js +391 -50
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-options-chain.util.js +2 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +15 -2
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +13 -3
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +3 -1
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +60 -11
- package/dist/utility/wrun/wrun-overlay-run.util.js +529 -113
- package/dist/utility/wrun/wrun-panel-mount.util.js +51 -6
- package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +15 -2
- package/dist/utility/wrun/wrun-pin-spelling.util.js +27 -3
- package/dist/utility/wrun/wrun-refusal.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-refusal.util.js +22 -0
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +26 -0
- package/dist/utility/wrun/wrun-registry-errors.util.js +34 -0
- package/dist/utility/wrun/wrun-replay-lane.util.js +3 -2
- package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +20 -6
- package/dist/utility/wrun/wrun-run-interval-session.util.js +22 -7
- package/dist/utility/wrun/wrun-run-interval.util.d.ts +39 -7
- package/dist/utility/wrun/wrun-run-interval.util.js +49 -9
- package/dist/utility/wrun/wrun-socket-row-source.js +7 -2
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +29 -22
- package/dist/utility/wrun/wrun-source-rows.util.js +62 -41
- package/dist/utility/wrun/wrun-tape-per-order.util.js +1 -20
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +17 -9
- package/dist/utility/wrun/wrun-tape-source.util.js +20 -12
- package/dist/workers/constants/socket-slots.d.ts +91 -6
- package/dist/workers/constants/socket-slots.js +85 -6
- package/package.json +11 -11
- package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +0 -56
- package/dist/kscript-data/controls/live-trades-order-gate.util.js +0 -107
|
@@ -15,11 +15,19 @@
|
|
|
15
15
|
* code is unchanged reads it as it reads B: it reaches the package as the class's own block. A fold
|
|
16
16
|
* (`answer: 'fold'`: totals, boards, the curve) answers rows of another layout, so an input naming one reads a view
|
|
17
17
|
* block (`wrunOptionInputTupleWidth`: its projections' tuples as `[0, ...tuple]`, then each fold's rows as
|
|
18
|
-
* `[layout, ...cells]`, every row padded to the class's `WRUN_OPTION_VIEW_ROW_WIDTHS
|
|
19
|
-
* option_contract_state's folds (Top Contracts' totals)
|
|
20
|
-
* options_chain
|
|
21
|
-
* the
|
|
22
|
-
* misread block.
|
|
18
|
+
* `[layout, ...cells]`, every row padded to the input's row width: the class's `WRUN_OPTION_VIEW_ROW_WIDTHS`, or a
|
|
19
|
+
* declared book fold's own when wider). This host reads option_contract_state's folds (Top Contracts' totals) and
|
|
20
|
+
* options_chain's book folds (below); a view it does not read yet (`wrunOptionViewUnread`: an options_chain fold of
|
|
21
|
+
* the block, which reads the chart's close, and a state view that follows the chart's close, which the state lane
|
|
22
|
+
* does not send) refuses by name before any read (`wrun_option_view_unread`), never an empty or misread block.
|
|
23
|
+
* - The book folds (D-DEDUPE phase 1b; the kit's `WRUN_OPTION_BOOK_VIEWS`, scaffold 105): options_chain's words also
|
|
24
|
+
* name the data plane's folds of the chain page's whole book (`numbers`, `vol_term`, `smile`, `surface`,
|
|
25
|
+
* `strike_profile`), the finished numbers the built-in options panes draw. Their knobs are judged by the kit's rules
|
|
26
|
+
* before any read (`wrunOptionBookViewIssue`), their ask carries each view's declared params alone (no live bar, no
|
|
27
|
+
* hint, no expiries word, no max-contracts size: `wrunOptionViewsReadBlock`), and their answer is laid out as the
|
|
28
|
+
* view block by the kit's reader (`wrunOptionBookViewRows`: one book stamp row, then each fold's rows, at the
|
|
29
|
+
* input's width). The worker reads them through the built-in panes' view state, so a package, a pane and the panel
|
|
30
|
+
* head asking the same folds share one read.
|
|
23
31
|
* - Hinted views (`hinted`: the window board, the smile and surface reads, and the folds that read the close where a
|
|
24
32
|
* contract carries no underlying: exposure, strike_table, gex_curve, oi_board) cover every close within
|
|
25
33
|
* `WRUN_OPTION_VIEW_MARGIN_PCT` of the hint the ask carries, the chart's close at ask time; a run whose close left
|
|
@@ -54,9 +62,10 @@ import { gateSessionHeldElsewhere } from '../v2/gate-session-latch.util.js';
|
|
|
54
62
|
import { refuseWrunPollInput } from './sources/wrun-poll-lane.types.js';
|
|
55
63
|
import { refuseWrunOptionKnob } from './wrun-option-knobs.util.js';
|
|
56
64
|
import { wrunPresentHasBit, wrunPresentIsPartial, wrunPresentWithPartial } from './wrun-present-bits.util.js';
|
|
57
|
-
import { wrunAuthorRuleSeed } from './wrun-refusal.util.js';
|
|
58
|
-
/** Every view word, in section 6.1's order
|
|
59
|
-
* `
|
|
65
|
+
import { attachWrunRefusal, wrunAuthorRuleSeed } from './wrun-refusal.util.js';
|
|
66
|
+
/** Every view word of the block, in section 6.1's order (the book folds follow on options_chain,
|
|
67
|
+
* `WRUN_OPTION_BOOK_VIEWS`). The worker names each by `OPTION_CHAIN_VIEW_<WORD>` (pb-common `OptionChainViewKind`;
|
|
68
|
+
* tests/utility/wrun/wrun-option-views.util.spec.ts pins every name). */
|
|
60
69
|
export const WRUN_OPTION_VIEWS = Object.freeze({
|
|
61
70
|
whole: { cls: 'options_chain', params: {}, answer: 'tuples' },
|
|
62
71
|
clock: { cls: 'options_chain', params: {}, answer: 'tuples' },
|
|
@@ -141,27 +150,34 @@ export const WRUN_OPTION_VIEWS_ONE_ASK_CODE = 'wrun_option_views_one_ask';
|
|
|
141
150
|
* B of the gateway, built for one `nearestExpiries`, so an input of another word would read views of another B (the
|
|
142
151
|
* SDK asks each word apart; one acquisition per word would serve them). */
|
|
143
152
|
export const WRUN_OPTION_VIEWS_ONE_EXPIRIES_CODE = 'wrun_option_views_one_expiries';
|
|
144
|
-
/** A view's spec, or undefined for a word
|
|
153
|
+
/** A view's spec, a view of the block or a book fold (the kit's `wrunOptionPageViewSpec`), or undefined for a word
|
|
154
|
+
* that names none. */
|
|
145
155
|
export function wrunOptionViewSpec(word) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
156
|
+
if (typeof word === 'string' && Object.prototype.hasOwnProperty.call(WRUN_OPTION_VIEWS, word)) {
|
|
157
|
+
return WRUN_OPTION_VIEWS[word];
|
|
158
|
+
}
|
|
159
|
+
return wrunOptionBookViewSpec(word);
|
|
149
160
|
}
|
|
150
161
|
/**
|
|
151
162
|
* What this host reads of each class's views (web: the `k-options-chain` and `k-option-contract-state` workers and
|
|
152
|
-
* their lanes): `folds`, whether the twin reads a fold's rows (option_contract_state's twin reads the
|
|
153
|
-
* entries as the view block, `optionsChainViewRows`; options_chain's
|
|
163
|
+
* their lanes): `folds`, whether the twin reads a fold of the block's rows (option_contract_state's twin reads the
|
|
164
|
+
* answer's fold entries as the view block, `optionsChainViewRows`; options_chain's folds of the block read the chart's
|
|
165
|
+
* close where a contract carries no underlying, and its twin reads none of them); `books`, whether it reads the book
|
|
166
|
+
* folds' rows (options_chain's twin lays them out as the view block, `wrunOptionBookViewRows`); `hint`, whether the
|
|
154
167
|
* lane sends a hinted view the chart's close (`chainSpotHint`; the state lane sends none, and the gateway and the kit
|
|
155
168
|
* refuse a hinted view without it).
|
|
156
169
|
*/
|
|
157
170
|
const WRUN_OPTION_VIEW_HOST_READS = Object.freeze({
|
|
158
|
-
options_chain: Object.freeze({ folds: false, hint: true }),
|
|
159
|
-
option_contract_state: Object.freeze({ folds: true, hint: false }),
|
|
171
|
+
options_chain: Object.freeze({ folds: false, books: true, hint: true }),
|
|
172
|
+
option_contract_state: Object.freeze({ folds: true, books: false, hint: false }),
|
|
160
173
|
});
|
|
161
174
|
/** Why this host does not read a view yet, in a refusal's words, or undefined when it reads it (every projection,
|
|
162
|
-
* option_contract_state's folds but `oi_board`, which follows the chart's close). */
|
|
175
|
+
* options_chain's book folds, option_contract_state's folds but `oi_board`, which follows the chart's close). */
|
|
163
176
|
export function wrunOptionViewUnread(spec) {
|
|
164
177
|
const reads = WRUN_OPTION_VIEW_HOST_READS[spec.cls];
|
|
178
|
+
if (spec.book === true) {
|
|
179
|
+
return reads.books ? undefined : `it is a book fold, whose rows no ${spec.cls} reader of this host takes`;
|
|
180
|
+
}
|
|
165
181
|
if (spec.answer === 'fold' && !reads.folds) {
|
|
166
182
|
return `its answer is a fold, whose rows no ${spec.cls} reader of this host takes yet`;
|
|
167
183
|
}
|
|
@@ -170,12 +186,17 @@ export function wrunOptionViewUnread(spec) {
|
|
|
170
186
|
}
|
|
171
187
|
return undefined;
|
|
172
188
|
}
|
|
189
|
+
/** Every word of one class in its table's order (the kit's `wrunOptionViewWords`): on options_chain the views of the
|
|
190
|
+
* block, then the book folds. */
|
|
191
|
+
function wrunOptionPageViewWordsOf(cls) {
|
|
192
|
+
const block = Object.keys(WRUN_OPTION_VIEWS).filter((word) => WRUN_OPTION_VIEWS[word].cls === cls);
|
|
193
|
+
return cls === 'options_chain' ? [...block, ...WRUN_OPTION_BOOK_VIEW_WORDS] : block;
|
|
194
|
+
}
|
|
173
195
|
/** The words of one class, spelled for a refusal. */
|
|
174
196
|
function wrunOptionViewWordsOf(cls) {
|
|
175
|
-
|
|
176
|
-
.
|
|
177
|
-
.
|
|
178
|
-
return `one of ${words.join(', ')}`;
|
|
197
|
+
return `one of ${wrunOptionPageViewWordsOf(cls)
|
|
198
|
+
.map((word) => `"${word}"`)
|
|
199
|
+
.join(', ')}`;
|
|
179
200
|
}
|
|
180
201
|
/**
|
|
181
202
|
* The knobs an input names its views in: `page_view` (one word) or `page_views` (a list), the chain page's views
|
|
@@ -223,7 +244,11 @@ function declaredViewWords(source, ctx) {
|
|
|
223
244
|
* An input's views, validated (main thread, after the paint seam): undefined when it declares none (today's path),
|
|
224
245
|
* else the views in canonical order (`canonicalViews`). Refuses by name a word that names no view of the input's
|
|
225
246
|
* class, a view this host does not read yet (`wrunOptionViewUnread`), and a param that is no finite number (a
|
|
226
|
-
* `"@<param>"` the sheet declares no param of stays a string here).
|
|
247
|
+
* `"@<param>"` the sheet declares no param of stays a string here). An input naming a book fold has every word judged
|
|
248
|
+
* first, then its book knobs by the kit's rules (`wrunOptionBookViewIssue`: a value outside what a knob takes on a
|
|
249
|
+
* declared word, a book knob no declared word takes, `nearest` beside `days`, an `expiries` word other than "all"),
|
|
250
|
+
* each refused by its knob (`wrun_option_knob_invalid`) with the kit's words; an input of views of the block alone
|
|
251
|
+
* is read word by word, as before.
|
|
227
252
|
*/
|
|
228
253
|
export function wrunOptionViewsOfSource(input, ctx, cls) {
|
|
229
254
|
// A sheet's input source, read by knob name (its knobs are open: the class's own and each view's params).
|
|
@@ -231,23 +256,35 @@ export function wrunOptionViewsOfSource(input, ctx, cls) {
|
|
|
231
256
|
const words = declaredViewWords(source, ctx);
|
|
232
257
|
if (words === undefined)
|
|
233
258
|
return undefined;
|
|
234
|
-
const
|
|
235
|
-
|
|
259
|
+
const wordKnob = source[WRUN_OPTION_VIEW_KNOB] !== undefined ? WRUN_OPTION_VIEW_KNOB : WRUN_OPTION_VIEWS_KNOB;
|
|
260
|
+
const specOf = (word) => {
|
|
236
261
|
const spec = wrunOptionViewSpec(word);
|
|
237
|
-
const knob = source[WRUN_OPTION_VIEW_KNOB] !== undefined ? WRUN_OPTION_VIEW_KNOB : WRUN_OPTION_VIEWS_KNOB;
|
|
238
262
|
if (spec === undefined || spec.cls !== cls) {
|
|
239
|
-
return refuseWrunOptionKnob(ctx,
|
|
263
|
+
return refuseWrunOptionKnob(ctx, wordKnob, word, wrunOptionViewWordsOf(cls));
|
|
240
264
|
}
|
|
241
265
|
const unread = wrunOptionViewUnread(spec);
|
|
242
266
|
if (unread !== undefined) {
|
|
243
|
-
return refuseWrunPollInput(ctx, `reads ${cls} with ${
|
|
244
|
-
'view or read the block whole', wrunAuthorRuleSeed(WRUN_OPTION_VIEW_UNREAD_CODE));
|
|
267
|
+
return refuseWrunPollInput(ctx, `reads ${cls} with ${wordKnob} "${String(word)}" (${WRUN_OPTION_VIEW_UNREAD_CODE}): ${unread}; declare ` +
|
|
268
|
+
'another view or read the block whole', wrunAuthorRuleSeed(WRUN_OPTION_VIEW_UNREAD_CODE));
|
|
245
269
|
}
|
|
270
|
+
return spec;
|
|
271
|
+
};
|
|
272
|
+
if (words.some(wrunOptionPageViewIsBook)) {
|
|
273
|
+
for (const word of words)
|
|
274
|
+
specOf(word);
|
|
275
|
+
const issue = wrunOptionBookViewIssue(source, words);
|
|
276
|
+
if (issue !== undefined)
|
|
277
|
+
return refuseWrunOptionKnob(ctx, issue.knob, issue.value, issue.takes);
|
|
278
|
+
}
|
|
279
|
+
const views = [];
|
|
280
|
+
for (const word of words) {
|
|
281
|
+
const spec = specOf(word);
|
|
246
282
|
const params = {};
|
|
247
283
|
for (const [knob, wire] of Object.entries(spec.params)) {
|
|
248
284
|
const value = source[knob];
|
|
249
285
|
if (value === undefined)
|
|
250
286
|
continue;
|
|
287
|
+
// A book fold's knob reached here judged already: a number its knob takes on every declared word.
|
|
251
288
|
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
252
289
|
return refuseWrunOptionKnob(ctx, knob, value, `a finite number, or "@<param>" naming a number param the sheet declares (view "${String(word)}")`);
|
|
253
290
|
}
|
|
@@ -267,9 +304,35 @@ function canonicalViews(views) {
|
|
|
267
304
|
}
|
|
268
305
|
return [...byText.entries()].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)).map(([, view]) => view);
|
|
269
306
|
}
|
|
270
|
-
/** The
|
|
307
|
+
/** The most views one ask names: the data plane's `MaxViews` (it refuses an ask naming more). */
|
|
308
|
+
export const WRUN_OPTION_VIEWS_MAX_PER_ASK = 16;
|
|
309
|
+
/** The plan's refusal of one lane whose inputs' views make an ask of more views than the data plane answers. */
|
|
310
|
+
export const WRUN_OPTION_VIEWS_TOO_MANY_CODE = 'wrun_option_views_too_many';
|
|
311
|
+
/** The plan's refusal of one options_chain lane whose view inputs read a book fold and different views: the lane asks
|
|
312
|
+
* their union ONCE, and a book fold's rows name no input, so each input would read every other input's book rows (two
|
|
313
|
+
* `numbers` asks' scope and expiry rows twice over), and an input narrower than the union's widest word would read
|
|
314
|
+
* none of them (an input's reader keeps the rows of its own width alone). */
|
|
315
|
+
export const WRUN_OPTION_BOOK_VIEWS_ONE_ASK_CODE = 'wrun_option_book_views_one_ask';
|
|
316
|
+
/**
|
|
317
|
+
* The union of several inputs' views, canonical: the views one lane asks for every input it serves. Refused by name
|
|
318
|
+
* before any read: inputs that read a book fold and different views (`WRUN_OPTION_BOOK_VIEWS_ONE_ASK_CODE`; one input
|
|
319
|
+
* may name several words), and a union of more views than one ask may name (`WRUN_OPTION_VIEWS_MAX_PER_ASK`). One
|
|
320
|
+
* input's views never pass the cap (each word once).
|
|
321
|
+
*/
|
|
271
322
|
export function wrunOptionViewsUnion(sets) {
|
|
272
|
-
|
|
323
|
+
const texts = new Set(sets.map((views) => wrunOptionViewsText(views)));
|
|
324
|
+
if (texts.size > 1 && sets.some((views) => views.some((view) => wrunOptionPageViewIsBook(view.view)))) {
|
|
325
|
+
throw attachWrunRefusal(new Error(`options_chain inputs of one lane read a book fold and different views (${WRUN_OPTION_BOOK_VIEWS_ONE_ASK_CODE}): ` +
|
|
326
|
+
"the lane asks their views once, and a book fold's rows name no input; declare the book folds and the " +
|
|
327
|
+
'views beside them on one input (an input may name several words), or the same views on every view input'), wrunAuthorRuleSeed(WRUN_OPTION_BOOK_VIEWS_ONE_ASK_CODE));
|
|
328
|
+
}
|
|
329
|
+
const union = canonicalViews(sets.flat());
|
|
330
|
+
if (union.length > WRUN_OPTION_VIEWS_MAX_PER_ASK) {
|
|
331
|
+
throw attachWrunRefusal(new Error(`the inputs' views make one ask of ${union.length} views (${WRUN_OPTION_VIEWS_TOO_MANY_CODE}): the market ` +
|
|
332
|
+
`data server answers at most ${WRUN_OPTION_VIEWS_MAX_PER_ASK} views an ask; declare fewer views, or fewer ` +
|
|
333
|
+
'values of one view across the inputs'), wrunAuthorRuleSeed(WRUN_OPTION_VIEWS_TOO_MANY_CODE));
|
|
334
|
+
}
|
|
335
|
+
return union;
|
|
273
336
|
}
|
|
274
337
|
/** The canonical text of a set of views (the payload's `<prefix>Views`). */
|
|
275
338
|
export function wrunOptionViewsText(views) {
|
|
@@ -322,16 +385,17 @@ const WRUN_OPTION_VIEW_PREFIX = Object.freeze({
|
|
|
322
385
|
options_chain: 'chain',
|
|
323
386
|
option_contract_state: 'state',
|
|
324
387
|
});
|
|
325
|
-
/** A view ask's payload fields (see the module doc).
|
|
388
|
+
/** A view ask's payload fields (see the module doc). The gateway's scope inputs size B: an options_chain ask naming
|
|
389
|
+
* book folds alone reads no B, so it carries neither (`wrunOptionViewsReadBlock`), nor the hint margin (no book fold
|
|
390
|
+
* is hinted); a mixed ask keeps them for the views of the block. */
|
|
326
391
|
export function wrunOptionViewLaneFields(cls, views, scope = {}) {
|
|
327
392
|
const prefix = WRUN_OPTION_VIEW_PREFIX[cls];
|
|
393
|
+
const sizesBlock = cls === 'options_chain' && wrunOptionViewsReadBlock(views);
|
|
328
394
|
return {
|
|
329
395
|
[`${prefix}Views`]: wrunOptionViewsText(views),
|
|
330
396
|
...(wrunOptionViewsHinted(views) ? { [`${prefix}SpotMarginPct`]: WRUN_OPTION_VIEW_MARGIN_PCT } : {}),
|
|
331
|
-
...(
|
|
332
|
-
|
|
333
|
-
: {}),
|
|
334
|
-
...(cls === 'options_chain' && scope.maxContracts !== undefined ? { chainMaxContracts: scope.maxContracts } : {}),
|
|
397
|
+
...(sizesBlock && scope.nearestExpiries !== undefined ? { chainNearestExpiries: scope.nearestExpiries } : {}),
|
|
398
|
+
...(sizesBlock && scope.maxContracts !== undefined ? { chainMaxContracts: scope.maxContracts } : {}),
|
|
335
399
|
};
|
|
336
400
|
}
|
|
337
401
|
/** The view fields of a payload, as they ride (a K control copies them onto the request it builds). */
|
|
@@ -411,10 +475,12 @@ export function wrunOptionViewAskFieldsOf(cls, payload) {
|
|
|
411
475
|
const hinted = wrunOptionViewsHinted(views);
|
|
412
476
|
const spotHint = hinted ? positiveNumber(payload[`${prefix}SpotHint`]) : undefined;
|
|
413
477
|
const spotMarginPct = hinted ? positiveNumber(payload[`${prefix}SpotMarginPct`]) : undefined;
|
|
478
|
+
// B's facts ride an ask that reads B: book folds alone read the page's book, keyed as the built-in panes key them.
|
|
479
|
+
const sizesBlock = wrunOptionViewsReadBlock(views);
|
|
414
480
|
return {
|
|
415
481
|
views,
|
|
416
|
-
...(nearestExpiries !== undefined ? { nearestExpiries } : {}),
|
|
417
|
-
...(maxContracts !== undefined ? { maxContracts } : {}),
|
|
482
|
+
...(sizesBlock && nearestExpiries !== undefined ? { nearestExpiries } : {}),
|
|
483
|
+
...(sizesBlock && maxContracts !== undefined ? { maxContracts } : {}),
|
|
418
484
|
...(spotHint !== undefined ? { spotHint } : {}),
|
|
419
485
|
...(spotHint !== undefined && spotMarginPct !== undefined ? { spotMarginPct } : {}),
|
|
420
486
|
};
|
|
@@ -520,7 +586,7 @@ export function wrunOptionLaneParamKnobs(cls) {
|
|
|
520
586
|
}
|
|
521
587
|
return [...knobs];
|
|
522
588
|
}
|
|
523
|
-
/** Whether a number is a legal value of a per-bar knob, a flag's 0 or 1 included (the SDK's
|
|
589
|
+
/** Whether a number is a legal value of a per-bar or book fold knob, a flag's 0 or 1 included (the SDK's
|
|
524
590
|
* `wrunOptionKnobSpecLegal`). */
|
|
525
591
|
export function wrunOptionKnobSpecLegal(spec, value) {
|
|
526
592
|
if (!Number.isFinite(value))
|
|
@@ -529,6 +595,8 @@ export function wrunOptionKnobSpecLegal(spec, value) {
|
|
|
529
595
|
return value === 0 || value === 1;
|
|
530
596
|
if (spec.codes !== undefined)
|
|
531
597
|
return Object.prototype.hasOwnProperty.call(spec.codes, String(value));
|
|
598
|
+
if (spec.zero === true && value === 0)
|
|
599
|
+
return true;
|
|
532
600
|
if (spec.kind === 'whole' && !Number.isInteger(value))
|
|
533
601
|
return false;
|
|
534
602
|
if (spec.min !== undefined && (spec.above === true ? !(value > spec.min) : value < spec.min))
|
|
@@ -537,7 +605,7 @@ export function wrunOptionKnobSpecLegal(spec, value) {
|
|
|
537
605
|
return false;
|
|
538
606
|
return true;
|
|
539
607
|
}
|
|
540
|
-
/** What a per-bar knob takes, as a refusal spells it (the SDK's `wrunOptionKnobSpecTakes`). */
|
|
608
|
+
/** What a per-bar or book fold knob takes, as a refusal spells it (the SDK's `wrunOptionKnobSpecTakes`). */
|
|
541
609
|
export function wrunOptionKnobSpecTakes(spec) {
|
|
542
610
|
if (spec.kind === 'flag')
|
|
543
611
|
return `true or false (${spec.what})`;
|
|
@@ -549,7 +617,8 @@ export function wrunOptionKnobSpecTakes(spec) {
|
|
|
549
617
|
const hi = spec.max === undefined ? '' : `${spec.below === true ? 'below' : 'up to'} ${spec.max}`;
|
|
550
618
|
const span = [lo, hi].filter((part) => part !== '').join(', ');
|
|
551
619
|
const kind = spec.kind === 'whole' ? 'a whole number' : spec.kind === 'time' ? 'an instant in epoch seconds' : 'a number';
|
|
552
|
-
|
|
620
|
+
const zero = spec.zero === true ? '0 or ' : '';
|
|
621
|
+
return `${spec.what}, ${zero}${kind}${span === '' ? '' : ` ${span}`}, or "@<param>" naming a declared setting`;
|
|
553
622
|
}
|
|
554
623
|
/**
|
|
555
624
|
* ONE reader of a per-bar class's knobs, the SDK's `wrunOptionViewAskOf` for `option_surface` and `option_strikes`
|
|
@@ -636,6 +705,239 @@ export function wrunOptionLaneAskOfSource(source, ctx) {
|
|
|
636
705
|
return refuseWrunOptionKnob(ctx, read.issue.knob, read.issue.value, read.issue.takes);
|
|
637
706
|
return read.ask;
|
|
638
707
|
}
|
|
708
|
+
/** A book fold's scope: the nearest live expiries (0, its default, every one). */
|
|
709
|
+
const BOOK_NEAREST = Object.freeze({
|
|
710
|
+
kind: 'whole',
|
|
711
|
+
min: 0,
|
|
712
|
+
max: 64,
|
|
713
|
+
what: 'the nearest live expiries (0: every one)',
|
|
714
|
+
});
|
|
715
|
+
/** A book fold's scope: the live expiries whose stamp is at most this many days after the book's instant. */
|
|
716
|
+
const BOOK_DAYS = Object.freeze({
|
|
717
|
+
...DAYS_SPEC,
|
|
718
|
+
what: 'the live expiries whose stamp is at most this many days away',
|
|
719
|
+
});
|
|
720
|
+
/** A smile's or a surface's strike window about S0. */
|
|
721
|
+
const BOOK_WINDOW = Object.freeze({
|
|
722
|
+
kind: 'number',
|
|
723
|
+
min: 0,
|
|
724
|
+
max: 100,
|
|
725
|
+
above: true,
|
|
726
|
+
what: "the strikes within this percent of S0 (the book's spot) each side",
|
|
727
|
+
});
|
|
728
|
+
/** Every book fold, in kind order (the kit's `WRUN_OPTION_BOOK_VIEWS`): the wire's kind is OPTION_CHAIN_VIEW_<WORD>
|
|
729
|
+
* (numbers 20, vol_term 22, smile 23, surface 24, strike_profile 25). Their words follow the views of the block on
|
|
730
|
+
* options_chain. */
|
|
731
|
+
export const WRUN_OPTION_BOOK_VIEWS = Object.freeze({
|
|
732
|
+
numbers: {
|
|
733
|
+
cls: 'options_chain',
|
|
734
|
+
answer: 'fold',
|
|
735
|
+
book: true,
|
|
736
|
+
kind: 20,
|
|
737
|
+
params: { nearest: 'nearest', days: 'days' },
|
|
738
|
+
knobs: { nearest: BOOK_NEAREST, days: BOOK_DAYS },
|
|
739
|
+
defaults: { nearest: 0, days: 0 },
|
|
740
|
+
layouts: ['numbers'],
|
|
741
|
+
},
|
|
742
|
+
vol_term: {
|
|
743
|
+
cls: 'options_chain',
|
|
744
|
+
answer: 'fold',
|
|
745
|
+
book: true,
|
|
746
|
+
kind: 22,
|
|
747
|
+
params: {},
|
|
748
|
+
knobs: {},
|
|
749
|
+
defaults: {},
|
|
750
|
+
layouts: ['vol_term'],
|
|
751
|
+
},
|
|
752
|
+
smile: {
|
|
753
|
+
cls: 'options_chain',
|
|
754
|
+
answer: 'fold',
|
|
755
|
+
book: true,
|
|
756
|
+
kind: 23,
|
|
757
|
+
params: { count: 'count', window_pct: 'windowPct' },
|
|
758
|
+
knobs: {
|
|
759
|
+
count: Object.freeze({
|
|
760
|
+
kind: 'whole',
|
|
761
|
+
min: 1,
|
|
762
|
+
max: 3,
|
|
763
|
+
what: "the smile's series (the expiries nearest today, 7 and 30 days out, the first N)",
|
|
764
|
+
}),
|
|
765
|
+
window_pct: BOOK_WINDOW,
|
|
766
|
+
},
|
|
767
|
+
defaults: { count: 3, windowPct: 40 },
|
|
768
|
+
layouts: ['smile_series', 'smile_point'],
|
|
769
|
+
},
|
|
770
|
+
surface: {
|
|
771
|
+
cls: 'options_chain',
|
|
772
|
+
answer: 'fold',
|
|
773
|
+
book: true,
|
|
774
|
+
kind: 24,
|
|
775
|
+
params: { lens: 'lens', window_pct: 'windowPct', columns: 'columns', rows: 'rows' },
|
|
776
|
+
knobs: {
|
|
777
|
+
lens: Object.freeze({
|
|
778
|
+
kind: 'whole',
|
|
779
|
+
codes: Object.freeze({ 0: 'gex', 1: 'oi', 2: 'iv', 3: 'dex', 4: 'vex' }),
|
|
780
|
+
what: 'the lens',
|
|
781
|
+
}),
|
|
782
|
+
window_pct: BOOK_WINDOW,
|
|
783
|
+
columns: Object.freeze({ kind: 'whole', min: 1, max: 16, what: 'the expiry columns' }),
|
|
784
|
+
rows: Object.freeze({ kind: 'whole', min: 1, max: 64, what: 'the strike rows' }),
|
|
785
|
+
},
|
|
786
|
+
defaults: { lens: 0, windowPct: 20, columns: 8, rows: 21 },
|
|
787
|
+
layouts: ['surface_cell'],
|
|
788
|
+
},
|
|
789
|
+
strike_profile: {
|
|
790
|
+
cls: 'options_chain',
|
|
791
|
+
answer: 'fold',
|
|
792
|
+
book: true,
|
|
793
|
+
kind: 25,
|
|
794
|
+
params: {
|
|
795
|
+
nearest: 'nearest',
|
|
796
|
+
days: 'days',
|
|
797
|
+
window_pct: 'windowPct',
|
|
798
|
+
strikes: 'strikes',
|
|
799
|
+
points: 'points',
|
|
800
|
+
half_pct: 'halfPct',
|
|
801
|
+
},
|
|
802
|
+
knobs: {
|
|
803
|
+
nearest: BOOK_NEAREST,
|
|
804
|
+
days: BOOK_DAYS,
|
|
805
|
+
window_pct: Object.freeze({
|
|
806
|
+
kind: 'number',
|
|
807
|
+
min: 0,
|
|
808
|
+
max: 100,
|
|
809
|
+
what: 'the strike rows within this percent of S0 (0: every strike)',
|
|
810
|
+
}),
|
|
811
|
+
strikes: Object.freeze({
|
|
812
|
+
kind: 'whole',
|
|
813
|
+
codes: Object.freeze({ 0: 'no strike rows', 1: 'a row a strike' }),
|
|
814
|
+
what: 'the strike rows',
|
|
815
|
+
}),
|
|
816
|
+
points: Object.freeze({ kind: 'whole', min: 2, max: 1000, zero: true, what: "the curve's points (0: no curve)" }),
|
|
817
|
+
half_pct: Object.freeze({
|
|
818
|
+
kind: 'number',
|
|
819
|
+
min: 0,
|
|
820
|
+
max: 50,
|
|
821
|
+
above: true,
|
|
822
|
+
what: "the curve's reach, a percent of S0 each side",
|
|
823
|
+
}),
|
|
824
|
+
},
|
|
825
|
+
defaults: { nearest: 0, days: 0, windowPct: 0, strikes: 1, points: 0, halfPct: 15 },
|
|
826
|
+
layouts: ['profile_strike', 'profile_levels', 'profile_point'],
|
|
827
|
+
},
|
|
828
|
+
});
|
|
829
|
+
/** The book folds' words, in kind order. */
|
|
830
|
+
export const WRUN_OPTION_BOOK_VIEW_WORDS = Object.freeze(Object.keys(WRUN_OPTION_BOOK_VIEWS));
|
|
831
|
+
/** f64s per view block row of each book word (the kit's `WRUN_OPTION_BOOK_VIEW_ROW_WIDTHS`): the layout column, then
|
|
832
|
+
* the wider of its widest layout and the book stamp (ten cells, riding every book answer). An input's rows are the
|
|
833
|
+
* widest of its words (`wrunOptionViewWordsRowWidth`), never narrower than the class's view row. */
|
|
834
|
+
export const WRUN_OPTION_BOOK_VIEW_ROW_WIDTHS = Object.freeze({
|
|
835
|
+
numbers: 12,
|
|
836
|
+
vol_term: 16,
|
|
837
|
+
smile: 11,
|
|
838
|
+
surface: 11,
|
|
839
|
+
strike_profile: 13,
|
|
840
|
+
});
|
|
841
|
+
/** What options_chain's `expiries` takes beside a book fold (the kit's `WRUN_OPTION_BOOK_EXPIRIES_TAKES`): its default
|
|
842
|
+
* alone. A book fold reads the whole book, so any other word would be dropped unseen. */
|
|
843
|
+
export const WRUN_OPTION_BOOK_EXPIRIES_TAKES = '"all" (or no expiries) beside a book fold (numbers, vol_term, smile, surface, strike_profile): it reads the whole book; a fold\'s own nearest or days scopes it';
|
|
844
|
+
/** What a book fold's `days` takes beside `nearest` on a word that takes both (the kit's
|
|
845
|
+
* `WRUN_OPTION_BOOK_SCOPE_TAKES`): nothing (the data plane refuses two scopes). */
|
|
846
|
+
export const WRUN_OPTION_BOOK_SCOPE_TAKES = 'one scope of a book fold\'s expiries, "nearest" or "days", never both';
|
|
847
|
+
/** The knobs a view of the block shares with a book fold on options_chain, as that view takes them (the kit's
|
|
848
|
+
* `WRUN_OPTION_PAGE_VIEW_KNOBS` rows): a shared knob takes one value for every declared word and must be legal on
|
|
849
|
+
* each (`wrunOptionBookViewIssue`), so `nearest` 0 refuses beside `exposure`, `lens` 5 and 6 beside `surface`, and
|
|
850
|
+
* `points` 0 beside `horizon_otm` and `gex_curve`. */
|
|
851
|
+
export const WRUN_OPTION_BOOK_SHARED_KNOBS = Object.freeze({
|
|
852
|
+
horizon_otm: Object.freeze({
|
|
853
|
+
points: Object.freeze({ kind: 'whole', min: 2, max: 1000, what: "the grid's strikes" }),
|
|
854
|
+
}),
|
|
855
|
+
exposure: Object.freeze({
|
|
856
|
+
lens: Object.freeze({
|
|
857
|
+
kind: 'whole',
|
|
858
|
+
codes: Object.freeze({ 0: 'gamma', 1: 'delta', 2: 'vanna', 3: 'charm', 4: 'vega', 5: 'iv_x_oi', 6: 'oi' }),
|
|
859
|
+
what: 'the lens',
|
|
860
|
+
}),
|
|
861
|
+
nearest: Object.freeze({ kind: 'whole', min: 1, max: 64, what: 'the nearest expiries counted' }),
|
|
862
|
+
}),
|
|
863
|
+
gex_curve: Object.freeze({
|
|
864
|
+
points: Object.freeze({ kind: 'whole', min: 2, max: 1000, what: "the grid's spots" }),
|
|
865
|
+
}),
|
|
866
|
+
});
|
|
867
|
+
/** A book fold's spec, or undefined for a word that names none. */
|
|
868
|
+
export function wrunOptionBookViewSpec(word) {
|
|
869
|
+
return typeof word === 'string' && Object.prototype.hasOwnProperty.call(WRUN_OPTION_BOOK_VIEWS, word)
|
|
870
|
+
? WRUN_OPTION_BOOK_VIEWS[word]
|
|
871
|
+
: undefined;
|
|
872
|
+
}
|
|
873
|
+
/** Whether a word names a book fold. */
|
|
874
|
+
export function wrunOptionPageViewIsBook(word) {
|
|
875
|
+
return wrunOptionBookViewSpec(word) !== undefined;
|
|
876
|
+
}
|
|
877
|
+
/** Whether an ask's views read the block B (the kit's `wrunOptionViewsReadBlock`): any view but a book fold. Only such
|
|
878
|
+
* an ask carries B's facts (the live bar's open on each view of B, the expiries word and the max-contracts size B is
|
|
879
|
+
* shaped by, the spot hint of a hinted view); an ask naming book folds alone carries each view's kind and its own
|
|
880
|
+
* params, nothing else. */
|
|
881
|
+
export function wrunOptionViewsReadBlock(views) {
|
|
882
|
+
return views.some(({ view }) => !wrunOptionPageViewIsBook(view));
|
|
883
|
+
}
|
|
884
|
+
/** Whether a word of options_chain takes a knob: a book fold its own knobs, a view of the block its params. */
|
|
885
|
+
function chainWordTakes(word, knob) {
|
|
886
|
+
const book = wrunOptionBookViewSpec(word);
|
|
887
|
+
if (book !== undefined)
|
|
888
|
+
return Object.prototype.hasOwnProperty.call(book.knobs, knob);
|
|
889
|
+
const spec = wrunOptionViewSpec(word);
|
|
890
|
+
return spec?.cls === 'options_chain' && Object.prototype.hasOwnProperty.call(spec.params, knob);
|
|
891
|
+
}
|
|
892
|
+
/** The book knobs in the kit's order (`wrunOptionViewParamKnobsOf("options_chain")`: each word's knobs in the class's
|
|
893
|
+
* word order, the views of the block first, each knob once): the order their issues are judged in. */
|
|
894
|
+
const WRUN_OPTION_BOOK_KNOB_ORDER = Object.freeze(wrunOptionPageViewWordsOf('options_chain')
|
|
895
|
+
.flatMap((word) => Object.keys(wrunOptionBookViewSpec(word)?.knobs ?? wrunOptionViewSpec(word)?.params ?? {}))
|
|
896
|
+
.filter((knob, at, knobs) => knobs.indexOf(knob) === at)
|
|
897
|
+
.filter((knob) => WRUN_OPTION_BOOK_VIEW_WORDS.some((word) => chainWordTakes(word, knob))));
|
|
898
|
+
/**
|
|
899
|
+
* The first issue of an options_chain input's book knobs, the kit's rules (`wrunOptionViewAskOf`) in its order, or
|
|
900
|
+
* undefined (also for words naming no book fold: an input of views of the block alone keeps its reads): each declared
|
|
901
|
+
* knob a book fold takes, legal on every declared word that takes it (a book fold's own spec, a view of the block's
|
|
902
|
+
* shared one, `WRUN_OPTION_BOOK_SHARED_KNOBS`), else refused with what it takes there and the word; such a knob beside
|
|
903
|
+
* no declared word that takes it (`a param of "<word>" only`); `nearest` beside `days` on a word that takes both
|
|
904
|
+
* (`WRUN_OPTION_BOOK_SCOPE_TAKES`); the class's `expiries` other than "all" (`WRUN_OPTION_BOOK_EXPIRIES_TAKES`). A
|
|
905
|
+
* view of the block's own knobs are the kit planner's where the rows are built.
|
|
906
|
+
*/
|
|
907
|
+
export function wrunOptionBookViewIssue(source, words) {
|
|
908
|
+
const books = words.filter(wrunOptionPageViewIsBook);
|
|
909
|
+
if (books.length === 0)
|
|
910
|
+
return undefined;
|
|
911
|
+
for (const knob of WRUN_OPTION_BOOK_KNOB_ORDER) {
|
|
912
|
+
const value = source[knob];
|
|
913
|
+
if (value === undefined)
|
|
914
|
+
continue;
|
|
915
|
+
const takers = words.filter((word) => chainWordTakes(word, knob));
|
|
916
|
+
if (takers.length === 0) {
|
|
917
|
+
const owners = wrunOptionPageViewWordsOf('options_chain').filter((word) => chainWordTakes(word, knob));
|
|
918
|
+
return { knob, value, takes: `a param of ${owners.map((owner) => `"${owner}"`).join(', ')} only` };
|
|
919
|
+
}
|
|
920
|
+
for (const word of takers) {
|
|
921
|
+
const spec = wrunOptionBookViewSpec(word)?.knobs[knob] ?? WRUN_OPTION_BOOK_SHARED_KNOBS[word]?.[knob];
|
|
922
|
+
if (spec === undefined)
|
|
923
|
+
continue;
|
|
924
|
+
if (typeof value !== 'number' || !wrunOptionKnobSpecLegal(spec, value)) {
|
|
925
|
+
return { knob, value, takes: `${wrunOptionKnobSpecTakes(spec)} (${word})` };
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
const scoped = books.find((word) => {
|
|
930
|
+
const { knobs } = WRUN_OPTION_BOOK_VIEWS[word];
|
|
931
|
+
return (Object.prototype.hasOwnProperty.call(knobs, 'nearest') && Object.prototype.hasOwnProperty.call(knobs, 'days'));
|
|
932
|
+
});
|
|
933
|
+
if (scoped !== undefined && source.nearest !== undefined && source.days !== undefined) {
|
|
934
|
+
return { knob: 'days', value: source.days, takes: `${WRUN_OPTION_BOOK_SCOPE_TAKES} (${scoped})` };
|
|
935
|
+
}
|
|
936
|
+
if (source.expiries !== undefined && source.expiries !== 'all') {
|
|
937
|
+
return { knob: 'expiries', value: source.expiries, takes: WRUN_OPTION_BOOK_EXPIRIES_TAKES };
|
|
938
|
+
}
|
|
939
|
+
return undefined;
|
|
940
|
+
}
|
|
639
941
|
/** f64s per row of a view block (the page views' folds) and of the strike kit fold (the SDK's
|
|
640
942
|
* `WRUN_OPTION_VIEW_ROW_WIDTHS`): the layout, then the widest layout's fields. */
|
|
641
943
|
export const WRUN_OPTION_VIEW_ROW_WIDTHS = Object.freeze({
|
|
@@ -686,19 +988,57 @@ export function wrunOptionStrikesVelocityWindows(value) {
|
|
|
686
988
|
export function wrunOptionStrikesVelocityWidth(classWidth, windows) {
|
|
687
989
|
return classWidth + WRUN_OPTION_STRIKES_VELOCITY_LISTS.length * windows.length;
|
|
688
990
|
}
|
|
689
|
-
/** Whether
|
|
690
|
-
|
|
991
|
+
/** Whether a class's words name a fold (the kit's `wrunOptionViewWordsFold`): the strike kit fold, or a page view fold
|
|
992
|
+
* of the class (a fold of the block or a book fold); its block is then a view block. */
|
|
993
|
+
function wrunOptionViewWordsFold(sourceClass, words) {
|
|
994
|
+
if (sourceClass === 'option_strikes')
|
|
995
|
+
return words.includes('kit');
|
|
996
|
+
if (sourceClass === 'option_surface')
|
|
997
|
+
return false;
|
|
691
998
|
return words.some((word) => {
|
|
692
999
|
const spec = wrunOptionViewSpec(word);
|
|
693
|
-
return spec?.cls ===
|
|
1000
|
+
return spec?.cls === sourceClass && spec.answer === 'fold';
|
|
694
1001
|
});
|
|
695
1002
|
}
|
|
1003
|
+
/**
|
|
1004
|
+
* The f64s per row of a block whose words are `words` (the kit's `wrunOptionViewWordsRowWidth`, each a word of the
|
|
1005
|
+
* class or not): the class's own width (`classWidth`) when no word names a fold; else the widest row a declared word
|
|
1006
|
+
* answers, the class's view row (`WRUN_OPTION_VIEW_ROW_WIDTHS`) widened to a declared book fold's own
|
|
1007
|
+
* (`WRUN_OPTION_BOOK_VIEW_ROW_WIDTHS`). The words alone decide it, never a param, so a setting never resizes a block:
|
|
1008
|
+
* the one rule an input's width (`wrunOptionInputTupleWidth`) and an instance's (`wrunOptionLaneTupleWidth`) read.
|
|
1009
|
+
*/
|
|
1010
|
+
export function wrunOptionViewWordsRowWidth(sourceClass, words, classWidth) {
|
|
1011
|
+
if (sourceClass === 'option_surface' || !wrunOptionViewWordsFold(sourceClass, words))
|
|
1012
|
+
return classWidth;
|
|
1013
|
+
let width = WRUN_OPTION_VIEW_ROW_WIDTHS[sourceClass];
|
|
1014
|
+
if (sourceClass !== 'options_chain')
|
|
1015
|
+
return width;
|
|
1016
|
+
for (const word of words) {
|
|
1017
|
+
if (wrunOptionPageViewIsBook(word))
|
|
1018
|
+
width = Math.max(width, WRUN_OPTION_BOOK_VIEW_ROW_WIDTHS[word]);
|
|
1019
|
+
}
|
|
1020
|
+
return width;
|
|
1021
|
+
}
|
|
1022
|
+
/** The f64s per row a class's view block may take, ascending (the kit's `wrunOptionViewRowWidthsOf`): its view row,
|
|
1023
|
+
* and on options_chain each book fold's own (never the class's tuple width). A host tells a view block from class
|
|
1024
|
+
* tuples by the width alone (the kit's `wrunCellBlockIsViewRows`). */
|
|
1025
|
+
export function wrunOptionViewRowWidthsOf(sourceClass) {
|
|
1026
|
+
if (sourceClass === 'option_surface')
|
|
1027
|
+
return [];
|
|
1028
|
+
const widths = new Set([WRUN_OPTION_VIEW_ROW_WIDTHS[sourceClass]]);
|
|
1029
|
+
if (sourceClass === 'options_chain') {
|
|
1030
|
+
for (const width of Object.values(WRUN_OPTION_BOOK_VIEW_ROW_WIDTHS))
|
|
1031
|
+
widths.add(width);
|
|
1032
|
+
}
|
|
1033
|
+
return [...widths].sort((a, b) => a - b);
|
|
1034
|
+
}
|
|
696
1035
|
/**
|
|
697
1036
|
* The f64s per tuple one input's block carries (the SDK's `wrunOptionInputTupleWidth`, the one rule every host sizes
|
|
698
|
-
* by): a view block's row width when its words name a fold (a page view fold,
|
|
699
|
-
* and its velocity lists when an `option_strikes`
|
|
700
|
-
* the kit sizes it so from the om schema's knob on,
|
|
701
|
-
* width. The words alone decide it, never a param, so a
|
|
1037
|
+
* by): a view block's row width when its words name a fold (`wrunOptionViewWordsRowWidth`: a page view fold, a book
|
|
1038
|
+
* fold's own width when wider, the strike kit fold), the class's tuple and its velocity lists when an `option_strikes`
|
|
1039
|
+
* input names `velocity_windows` (`wrunOptionStrikesVelocityWidth`; the kit sizes it so from the om schema's knob on,
|
|
1040
|
+
* `WRUN_OPTION_STRIKES_VELOCITY_SERVED`), else the class's own width. The words alone decide it, never a param, so a
|
|
1041
|
+
* setting never resizes a block.
|
|
702
1042
|
*/
|
|
703
1043
|
export function wrunOptionInputTupleWidth(source, classWidth) {
|
|
704
1044
|
const cls = source.source;
|
|
@@ -710,7 +1050,7 @@ export function wrunOptionInputTupleWidth(source, classWidth) {
|
|
|
710
1050
|
}
|
|
711
1051
|
if (cls !== 'options_chain' && cls !== 'option_contract_state')
|
|
712
1052
|
return classWidth;
|
|
713
|
-
return
|
|
1053
|
+
return wrunOptionViewWordsRowWidth(cls, wrunOptionViewWordsDeclared(source), classWidth);
|
|
714
1054
|
}
|
|
715
1055
|
/** pb-common `OptionSurfacePick` by word (the gateway decodes numbers, never names). */
|
|
716
1056
|
export const WRUN_OPTION_SURFACE_PICK_CODES = Object.freeze({
|
|
@@ -864,7 +1204,8 @@ export function wrunOptionKitBarHasRows(tuples) {
|
|
|
864
1204
|
* `wrunOptionInputTupleWidth`: the views ride the instance's key, so every input it serves shares its width): the kit
|
|
865
1205
|
* fold's rows on an instance asking it, the class's tuple and its velocity lists on an `option_strikes` instance asking
|
|
866
1206
|
* velocity windows (`WRUN_OPTION_STRIKES_VELOCITY_FIELD`), a view block's rows on one whose views (`<prefix>Views`) name
|
|
867
|
-
* a fold of its class (Top Contracts' totals
|
|
1207
|
+
* a fold of its class (Top Contracts' totals; a book fold, at the widest of its words,
|
|
1208
|
+
* `wrunOptionViewWordsRowWidth`), else the class's own tuple (`classWidth`).
|
|
868
1209
|
*/
|
|
869
1210
|
export function wrunOptionLaneTupleWidth(sourceClass, acquisition, classWidth) {
|
|
870
1211
|
if (sourceClass === 'option_strikes') {
|
|
@@ -876,7 +1217,7 @@ export function wrunOptionLaneTupleWidth(sourceClass, acquisition, classWidth) {
|
|
|
876
1217
|
if (sourceClass !== 'options_chain' && sourceClass !== 'option_contract_state')
|
|
877
1218
|
return classWidth;
|
|
878
1219
|
const text = acquisition[`${WRUN_OPTION_VIEW_PREFIX[sourceClass]}Views`];
|
|
879
|
-
return
|
|
1220
|
+
return wrunOptionViewWordsRowWidth(sourceClass, viewWordsOfText(text), classWidth);
|
|
880
1221
|
}
|
|
881
1222
|
/** The view words a `<prefix>Views` text names, unvalidated (the width reads the words alone, as the SDK's
|
|
882
1223
|
* `wrunAskTupleWidth` does); none for a text that is no list of views. */
|
|
@@ -2,7 +2,7 @@ import type { OptionInstrumentSnapshot } from '../../interfaces/option-instrumen
|
|
|
2
2
|
import type { OptionSource } from '../options/option-venue.util.js';
|
|
3
3
|
import type { OpraOptionPlaneStop } from '../../host-ports.types.js';
|
|
4
4
|
import type { WrunOptionsStopReason } from './wrun-refusal.util.js';
|
|
5
|
-
import type { GateProvider } from '../../workers/constants/socket-slots.js';
|
|
5
|
+
import type { GateProvider, OptionsGateProvider } from '../../workers/constants/socket-slots.js';
|
|
6
6
|
import type { OptionsChainScope } from '../../interfaces/options-chain-scope.interface.js';
|
|
7
7
|
/** f64s per contract tuple (the shared host's `WRUN_HOST_CELL_TUPLE_WIDTHS.options_chain`, the width
|
|
8
8
|
* the packer packs; wrun-source-words.kit-mirror.spec.ts pins it). */
|
|
@@ -64,7 +64,7 @@ export type WrunOptionsChainServedTier = 'realtime' | 'delayed';
|
|
|
64
64
|
* `governedOptionSummaryTier` on the main thread's served-access mirror when the lane resolves the
|
|
65
65
|
* read; absent: delayed, the tier every read is safe on). */
|
|
66
66
|
export interface WrunGovernedOptionsChainIdentity {
|
|
67
|
-
venue:
|
|
67
|
+
venue: OptionsGateProvider;
|
|
68
68
|
exchange: string;
|
|
69
69
|
underlying: string;
|
|
70
70
|
scope?: OptionsChainScope;
|
|
@@ -145,7 +145,7 @@ export declare function wrunOptionsChainLaneScope(inputs: ReadonlyArray<{
|
|
|
145
145
|
* an OPRA option contract chart): `cme` is the one plane with a venue word of
|
|
146
146
|
* its own, and `auto` reads OPRA for an OpenMarket package only. */
|
|
147
147
|
export type WrunOptionsChartSource = {
|
|
148
|
-
venue:
|
|
148
|
+
venue: OptionsGateProvider;
|
|
149
149
|
exchange: string;
|
|
150
150
|
underlying: string;
|
|
151
151
|
} | {
|
|
@@ -292,6 +292,8 @@ export function wrunOptionsChainFlagOffRefusal(args) {
|
|
|
292
292
|
const WRUN_OPTIONS_CHAIN_DIRECTORY_NAMES = Object.freeze({
|
|
293
293
|
cme: 'CME',
|
|
294
294
|
opra: 'US',
|
|
295
|
+
// The stocks tape has no chain directory (a US stock's options are OPRA's); named for the Record's totality only.
|
|
296
|
+
stocks: 'US stocks',
|
|
295
297
|
});
|
|
296
298
|
/**
|
|
297
299
|
* The `venue` knob against the chart, decided in ONE place for the run lane,
|