@orangecharts/wrun-chart-host 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -3
- package/dist/constants/feature-flags.constants.d.ts +1 -0
- package/dist/constants/feature-flags.constants.js +5 -0
- package/dist/constants/option-venues.constants.d.ts +18 -0
- package/dist/constants/option-venues.constants.js +14 -0
- package/dist/constants/venue-presets.constants.d.ts +17 -3
- package/dist/constants/venue-presets.constants.js +17 -3
- package/dist/host-env.d.ts +24 -0
- package/dist/host-env.js +21 -0
- package/dist/host-ports.types.d.ts +12 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/indicators/controls/tpo-session.util.d.ts +40 -11
- package/dist/indicators/controls/tpo-session.util.js +138 -14
- package/dist/interfaces/option-instrument.interface.d.ts +6 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +4 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +4 -0
- package/dist/settings-templates/footprint-rows.d.ts +25 -0
- package/dist/settings-templates/footprint-rows.js +127 -0
- package/dist/settings-templates/form-rows.d.ts +56 -0
- package/dist/settings-templates/form-rows.js +19 -0
- package/dist/settings-templates/frvp-fields.js +14 -0
- package/dist/settings-templates/index.d.ts +10 -1
- package/dist/settings-templates/index.js +11 -2
- package/dist/settings-templates/indicator-fields.js +78 -0
- package/dist/settings-templates/tool-rules.d.ts +35 -9
- package/dist/settings-templates/tool-rules.js +42 -8
- package/dist/settings-templates/tool-tables.generated.js +13 -2
- package/dist/utility/chart/candle-volume-unit.leaf.d.ts +16 -0
- package/dist/utility/chart/candle-volume-unit.leaf.js +61 -0
- package/dist/utility/chart/footprint-columns.util.d.ts +74 -0
- package/dist/utility/chart/footprint-columns.util.js +106 -0
- package/dist/utility/chart/footprint-display-mode.util.d.ts +40 -0
- package/dist/utility/chart/footprint-display-mode.util.js +62 -0
- package/dist/utility/chart/footprint-sierra-look.util.d.ts +2 -0
- package/dist/utility/chart/footprint-sierra-look.util.js +37 -0
- package/dist/utility/chart/kscript-venue-policy.util.js +4 -2
- package/dist/utility/chart/om-panel.util.d.ts +11 -0
- package/dist/utility/chart/om-panel.util.js +59 -0
- package/dist/utility/chart/window-geometry.leaf.d.ts +23 -1
- package/dist/utility/chart/window-geometry.leaf.js +78 -6
- package/dist/utility/chart/window-owner.leaf.d.ts +13 -0
- package/dist/utility/chart/window-owner.leaf.js +5 -0
- package/dist/utility/options/cme-options-root.util.d.ts +25 -0
- package/dist/utility/options/cme-options-root.util.js +40 -0
- package/dist/utility/options/option-book.util.d.ts +27 -0
- package/dist/utility/options/option-book.util.js +76 -0
- package/dist/utility/options/option-trade-date.util.d.ts +50 -0
- package/dist/utility/options/option-trade-date.util.js +120 -0
- package/dist/utility/wrun/sources/host-grid-landing.d.ts +4 -2
- package/dist/utility/wrun/sources/host-grid-landing.js +8 -0
- package/dist/utility/wrun/sources/lanes/options_flow.d.ts +40 -4
- package/dist/utility/wrun/sources/lanes/options_flow.js +115 -18
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +12 -9
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +10 -7
- package/dist/utility/wrun/sources/row-lane-registry.js +9 -5
- package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +3 -2
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +30 -5
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +14 -1
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +100 -23
- package/dist/utility/wrun/sources/row-lanes/option_strike_flow.d.ts +4 -0
- package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +65 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +47 -1
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +71 -2
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +14 -1
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +30 -2
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +7 -1
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +45 -5
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +115 -3
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +10 -0
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +57 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +60 -6
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +160 -23
- package/dist/utility/wrun/wrun-cloud-record.leaf.d.ts +27 -0
- package/dist/utility/wrun/wrun-cloud-record.leaf.js +71 -0
- package/dist/utility/wrun/wrun-cloud-record.util.d.ts +4 -21
- package/dist/utility/wrun/wrun-cloud-record.util.js +5 -65
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +7 -5
- package/dist/utility/wrun/wrun-color-settings.util.js +26 -11
- package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +4 -2
- package/dist/utility/wrun/wrun-draft-overlay.util.js +40 -3
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +1 -1
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +4 -0
- package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +29 -3
- package/dist/utility/wrun/wrun-lane-refusal.leaf.js +33 -3
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -1
- package/dist/utility/wrun/wrun-live-tick.util.js +39 -6
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +106 -0
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +159 -0
- package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +44 -0
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +213 -0
- package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +43 -8
- package/dist/utility/wrun/wrun-opra-flow.leaf.js +37 -6
- package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +51 -10
- package/dist/utility/wrun/wrun-option-contract-flow.util.js +85 -33
- package/dist/utility/wrun/wrun-option-prints.util.d.ts +133 -3
- package/dist/utility/wrun/wrun-option-prints.util.js +318 -8
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +96 -0
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +215 -0
- package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +342 -0
- package/dist/utility/wrun/wrun-option-strike-flow.util.js +742 -0
- package/dist/utility/wrun/wrun-option-views.util.d.ts +183 -3
- package/dist/utility/wrun/wrun-option-views.util.js +504 -7
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +6 -4
- package/dist/utility/wrun/wrun-options-chain.util.js +8 -5
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +7 -2
- package/dist/utility/wrun/wrun-overlay-run.util.js +120 -18
- package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +15 -0
- package/dist/utility/wrun/wrun-pack-widths.leaf.js +22 -0
- package/dist/utility/wrun/wrun-pack.util.d.ts +9 -8
- package/dist/utility/wrun/wrun-pack.util.js +21 -15
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +62 -22
- package/dist/utility/wrun/wrun-panel-style.util.d.ts +17 -2
- package/dist/utility/wrun/wrun-panel-style.util.js +47 -9
- package/dist/utility/wrun/wrun-pin-spelling.util.js +19 -10
- package/dist/utility/wrun/wrun-refusal.util.js +7 -1
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +13 -0
- package/dist/utility/wrun/wrun-script-inputs.util.js +43 -0
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-tape-source.util.js +18 -0
- package/package.json +3 -3
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The trade date an option row is dated on, on its venue family's clock: the ONE place the app dates an option print,
|
|
3
|
+
* bucket or expiry into a trade date. The clocks are the data plane's `option_venue_clocks` table, carried on the venue
|
|
4
|
+
* config (option-venues.constants `OptionVenue.tradeDateClock`), so no code here names a venue; a venue with no clock
|
|
5
|
+
* dates by the UTC date. Pure and worker-safe. docs/features/kscript/wrun/wrun-browser-runtime.md, "The venue-family
|
|
6
|
+
* trade-date clock".
|
|
7
|
+
*/
|
|
8
|
+
import { OPTION_VENUES, } from '../../constants/option-venues.constants.js';
|
|
9
|
+
import { zoneWallMsAt, zoneWallToUtcMs } from '../chart/ny-calendar.util.js';
|
|
10
|
+
const HOUR_MS = 3_600_000;
|
|
11
|
+
const DAY_MS = 86_400_000;
|
|
12
|
+
const UTC_ZONE = 'UTC';
|
|
13
|
+
/** The UTC date, the clock of a venue the table does not list. */
|
|
14
|
+
const UTC_CLOCK = Object.freeze({ zone: UTC_ZONE, rule: { offsetHours: 0 } });
|
|
15
|
+
/** Each venue clock by exchange name (upper case), read off the venue config once. */
|
|
16
|
+
const CLOCKS_BY_EXCHANGE = new Map(OPTION_VENUES.flatMap((venue) => venue.tradeDateClock === undefined
|
|
17
|
+
? []
|
|
18
|
+
: venue.exchanges.map((exchange) => [exchange.toUpperCase(), venue.tradeDateClock])));
|
|
19
|
+
/** A root family's coin pattern: the root, a month code, one or two year digits (the data plane's own). */
|
|
20
|
+
const rootPatterns = new Map();
|
|
21
|
+
function rootPatternOf(roots) {
|
|
22
|
+
const key = roots.join('|');
|
|
23
|
+
let pattern = rootPatterns.get(key);
|
|
24
|
+
if (pattern === undefined) {
|
|
25
|
+
pattern = new RegExp(`^(${key})[FGHJKMNQUVXZ][0-9]{1,2}$`);
|
|
26
|
+
rootPatterns.set(key, pattern);
|
|
27
|
+
}
|
|
28
|
+
return pattern;
|
|
29
|
+
}
|
|
30
|
+
/** The rules decided per chain (a fold dates every row of one chain by the same rule). */
|
|
31
|
+
const rulesByChain = new Map();
|
|
32
|
+
const RULES_KEPT = 256;
|
|
33
|
+
/**
|
|
34
|
+
* The clock a chain's rows date by: a root family's rule when the coin is one of its roots' futures on its exchanges,
|
|
35
|
+
* else the venue's clock, else the UTC date.
|
|
36
|
+
*/
|
|
37
|
+
export function optionTradeDateClockOf(chain) {
|
|
38
|
+
const exchange = (chain.exchange ?? '').toUpperCase();
|
|
39
|
+
const coin = (chain.coin ?? '').toUpperCase();
|
|
40
|
+
const key = `${exchange}|${coin}`;
|
|
41
|
+
const held = rulesByChain.get(key);
|
|
42
|
+
if (held !== undefined)
|
|
43
|
+
return held;
|
|
44
|
+
const clock = CLOCKS_BY_EXCHANGE.get(exchange);
|
|
45
|
+
let decided = UTC_CLOCK;
|
|
46
|
+
if (clock !== undefined) {
|
|
47
|
+
const family = clock.rootFamilies?.find((candidate) => candidate.exchanges.some((name) => name.toUpperCase() === exchange) &&
|
|
48
|
+
rootPatternOf(candidate.roots).test(coin));
|
|
49
|
+
decided = { zone: clock.zone, rule: family?.rule ?? clock.rule };
|
|
50
|
+
}
|
|
51
|
+
if (rulesByChain.size >= RULES_KEPT)
|
|
52
|
+
rulesByChain.clear();
|
|
53
|
+
rulesByChain.set(key, decided);
|
|
54
|
+
return decided;
|
|
55
|
+
}
|
|
56
|
+
/** Days since the epoch, Monday-based weekday: 0 Monday .. 6 Sunday (1970-01-01, day 0, was a Thursday). */
|
|
57
|
+
function isoWeekday(day) {
|
|
58
|
+
return (((day + 3) % 7) + 7) % 7;
|
|
59
|
+
}
|
|
60
|
+
/** The wall clock of `zone` at an instant, a UTC-shaped epoch; NaN outside the instants the zone clock serves. */
|
|
61
|
+
function wallMsOf(zone, instantMs) {
|
|
62
|
+
return zone === UTC_ZONE ? instantMs : zoneWallMsAt(zone, instantMs);
|
|
63
|
+
}
|
|
64
|
+
/** The trade date an instant falls on under one clock rule, in days since the epoch (NaN for an instant it cannot
|
|
65
|
+
* read). */
|
|
66
|
+
export function optionTradeDayByClock(clock, instantMs) {
|
|
67
|
+
if (!Number.isFinite(instantMs))
|
|
68
|
+
return Number.NaN;
|
|
69
|
+
const wall = wallMsOf(clock.zone, instantMs);
|
|
70
|
+
if (!Number.isFinite(wall))
|
|
71
|
+
return Number.NaN;
|
|
72
|
+
const day = Math.floor((wall + clock.rule.offsetHours * HOUR_MS) / DAY_MS);
|
|
73
|
+
if (clock.rule.weekendsToMonday !== true)
|
|
74
|
+
return day;
|
|
75
|
+
const weekday = isoWeekday(day);
|
|
76
|
+
return weekday === 5 ? day + 2 : weekday === 6 ? day + 1 : day;
|
|
77
|
+
}
|
|
78
|
+
/** The trade date an instant falls on for a chain's rows, in days since the epoch (`optionTradeDateClockOf`). */
|
|
79
|
+
export function optionTradeDay(chain, instantMs) {
|
|
80
|
+
return optionTradeDayByClock(optionTradeDateClockOf(chain), instantMs);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The first instant of a trade date under one clock rule (the instant the date starts: 00:00 New York on OPRA, 17:00
|
|
84
|
+
* Chicago the evening before on a CME Group exchange, 16:00 Chicago on the Friday before a CME crypto Monday), or NaN
|
|
85
|
+
* for a date no instant falls on (a Saturday or a Sunday under `weekendsToMonday`).
|
|
86
|
+
*/
|
|
87
|
+
export function optionTradeDayStartMsByClock(clock, day) {
|
|
88
|
+
if (!Number.isFinite(day))
|
|
89
|
+
return Number.NaN;
|
|
90
|
+
let firstLocalDay = day;
|
|
91
|
+
if (clock.rule.weekendsToMonday === true) {
|
|
92
|
+
const weekday = isoWeekday(day);
|
|
93
|
+
if (weekday === 5 || weekday === 6)
|
|
94
|
+
return Number.NaN;
|
|
95
|
+
if (weekday === 0)
|
|
96
|
+
firstLocalDay = day - 2;
|
|
97
|
+
}
|
|
98
|
+
const wall = firstLocalDay * DAY_MS - clock.rule.offsetHours * HOUR_MS;
|
|
99
|
+
return clock.zone === UTC_ZONE ? wall : zoneWallToUtcMs(clock.zone, wall);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The first instant of `history` "today" under one clock rule: the trade date of the NEWEST BAR the chart holds (the
|
|
103
|
+
* newest bar a lane plans for), read at the bar's middle as a bucket is (a calendar bar stamped 00:00Z reads its own
|
|
104
|
+
* date). Never a clock's date: on a weekend, a holiday (the table models none, the chart's bars do) or a morning before
|
|
105
|
+
* the session's first print, the chart's newest bar is the last session's, so "today" is that session. It takes a
|
|
106
|
+
* bar, never an instant, so a clock cannot be handed to it. NaN for a bar it cannot date.
|
|
107
|
+
*/
|
|
108
|
+
export function optionTodayStartMsByClock(clock, newestBar) {
|
|
109
|
+
const { openMs, endMs } = newestBar;
|
|
110
|
+
if (!Number.isFinite(openMs))
|
|
111
|
+
return Number.NaN;
|
|
112
|
+
const span = Number.isFinite(endMs) && endMs > openMs ? endMs - openMs : 0;
|
|
113
|
+
return optionTradeDayStartMsByClock(clock, optionTradeDayByClock(clock, openMs + Math.floor(span / 2)));
|
|
114
|
+
}
|
|
115
|
+
/** Whether an expiry trades on the trade date of an instant (a bucket's) for a chain's rows: the 0DTE class. */
|
|
116
|
+
export function optionExpiresOnTradeDay(chain, expiryMs, instantMs) {
|
|
117
|
+
const clock = optionTradeDateClockOf(chain);
|
|
118
|
+
const expiryDay = optionTradeDayByClock(clock, expiryMs);
|
|
119
|
+
return Number.isFinite(expiryDay) && expiryDay === optionTradeDayByClock(clock, instantMs);
|
|
120
|
+
}
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
* The registry check of a host-grid landing (UW-PARITY rule 9), shared by the poll-lane registry (`barGrid` on a
|
|
3
3
|
* `nativeRows` lane) and the row-lane registry (a flow or snapshot row lane's `landing`): a flow or a snapshot, and
|
|
4
4
|
* its backend tiers, each a key of its own, a positive whole width in ms, a positive retention or none and a positive
|
|
5
|
-
* served lag or none
|
|
5
|
+
* served lag or none; a tier choice, when the grid names one, the finest or the coarsest, the coarsest on a flow with
|
|
6
|
+
* tiers only (a snapshot's newest sealed row is its tier's own, and with no tiers there is nothing to choose).
|
|
6
7
|
*
|
|
7
8
|
* A LEAF on purpose (type imports only): both registries read it at module load, and the row-lane registry stays off
|
|
8
9
|
* the poll-lane registry's import graph (a module reading row lanes never loads the poll lanes' files).
|
|
9
10
|
*/
|
|
10
|
-
import type { WrunBackendTier, WrunTierLanding } from '../wrun-tier-grid.util.js';
|
|
11
|
+
import type { WrunBackendTier, WrunTierChoice, WrunTierLanding } from '../wrun-tier-grid.util.js';
|
|
11
12
|
/** Refuse a malformed host-grid landing by name (a programming error, never a user's). */
|
|
12
13
|
export declare function assertWrunHostGridLanding(who: string, grid: {
|
|
13
14
|
landing: WrunTierLanding;
|
|
14
15
|
tiers?: readonly WrunBackendTier[];
|
|
16
|
+
tierChoice?: WrunTierChoice;
|
|
15
17
|
}): void;
|
|
@@ -3,6 +3,14 @@ export function assertWrunHostGridLanding(who, grid) {
|
|
|
3
3
|
if (grid.landing !== 'flow' && grid.landing !== 'snapshot') {
|
|
4
4
|
throw new Error(`${who}: barGrid landing is 'flow' or 'snapshot'`);
|
|
5
5
|
}
|
|
6
|
+
if (grid.tierChoice !== undefined) {
|
|
7
|
+
if (grid.tierChoice !== 'finest' && grid.tierChoice !== 'coarsest') {
|
|
8
|
+
throw new Error(`${who}: barGrid tierChoice is 'finest', 'coarsest' or absent`);
|
|
9
|
+
}
|
|
10
|
+
if (grid.tierChoice === 'coarsest' && (grid.landing !== 'flow' || grid.tiers === undefined)) {
|
|
11
|
+
throw new Error(`${who}: the coarsest tier choice needs a flow with tiers (a bar summed alike from any tier)`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
6
14
|
if (grid.tiers === undefined)
|
|
7
15
|
return;
|
|
8
16
|
if (!Array.isArray(grid.tiers) || grid.tiers.length === 0) {
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* It reads OPTION_PRINT_AGG flow scope rows (wrun-opra-flow.leaf: which rows each ask names) through the
|
|
8
8
|
* `K_OPTION_PRINT_AGG_SCOPE` control and its worker twin, which sums a bucket's matching rows into the 32 fields
|
|
9
9
|
* (`foldWrunOptionsFlowRows`); this lane lands the buckets on the chart's bars under the tier rule (rule 9: 1m kept 7
|
|
10
|
-
* days, 5m kept 30, 1d kept
|
|
10
|
+
* days, 5m kept 30, 1d kept; OPTLOAD-READ-CONTRACT 5.4: the COARSEST that fits the bar, still holds it and already
|
|
11
|
+
* serves it, `tierChoice`, so a closed hourly bar reads 5m buckets and the forming one 1m; a stock chart's 09:30 New
|
|
12
|
+
* York bars, an
|
|
11
13
|
* OPRA contract chart's and a crypto chart's UTC ones, a CME chart's intraday ones on their stamps; a CME bar of a day
|
|
12
14
|
* or longer over its Globex session, from the 17:00 Chicago open before its 00:00Z stamp, which no UTC day bucket fits:
|
|
13
15
|
* such a bar older than the 5m tier reads its fill, never a misdated day), summed per bar. A bar no tier holds any more
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
* alone for a guest, as every other chain class reads the gate), `equity`, `etf`, `index` (MARKET rows of that US
|
|
31
33
|
* issue type: OPRA only), `venue` (OPRA: VENUE rows of the `venue` knob's exchange; crypto: COIN rows of the chart's
|
|
32
34
|
* coin on that venue, every book, a venue the gate keeps dark refused `flag-off` as the chain decision refuses it;
|
|
33
|
-
* CME, one venue: none);
|
|
35
|
+
* CME, one venue: none), `prints` (PRINTS rows of the chain's underlying on every plane, every book);
|
|
34
36
|
* - `dte`: `all` (the default), `0dte`, `week` (1 to 7 days), `month` (8 to 35), `later`;
|
|
35
37
|
* - `moneyness`: `all` (the default), `otm`, `itm`;
|
|
36
38
|
* - `venue`: scope `venue` only, required there: on OPRA an exchange's ISO MIC (`XCBO`), read by its Databento
|
|
@@ -38,11 +40,22 @@
|
|
|
38
40
|
* (`OKEX_OPTIONS`, the venue table's). That scope serves `call_prem_total`, `put_prem_total`,
|
|
39
41
|
* `call_contracts_total`, `put_contracts_total` and `prints` alone, with no `dte` or `moneyness` split;
|
|
40
42
|
* - `book`: scope `ticker` only: `auto` (the default, the chain's default book) or one series of the chain, decided
|
|
41
|
-
* when the run plans; a crypto chain's ask names it, an OPRA or CME chain's one book is its underlying
|
|
43
|
+
* when the run plans; a crypto chain's ask names it, an OPRA or CME chain's one book is its underlying;
|
|
44
|
+
* - `min_premium` and `max_dte`: scope `prints` only (OPTLOAD G4, kit 0.89.0): the premium floor in USD (required, above
|
|
45
|
+
* 0) and the most days to expiry (whole, 0 to 3,650; 0 keeps every expiry) of the chart underlying's prints the scope
|
|
46
|
+
* sums per bar, on every plane (the chain's exchange and underlying, every book). A knob may name a setting (an
|
|
47
|
+
* author's `"@floor"`, the sheet's `"floor"`): the planner reads its current value before this plan (wrun-poll-lanes
|
|
48
|
+
* `resolveWrunOptionSettingKnobs`), so a settings change re-plans and re-asks; a name no value reached is refused
|
|
49
|
+
* by name. Its history is the print tables' reach (`horizon`: 3 days raw, the large table past 25,000 USD up to the
|
|
50
|
+
* gateway's bar limit); older bars read the fill.
|
|
42
51
|
* A scope the chart's plane does not serve (a US issue type off OPRA, `venue` on CME, a venue word of another plane) is
|
|
43
52
|
* refused with `wrunLaneUnservedScopeSeed`'s seed, so the planner drops an input that declared a fill with the market's
|
|
44
53
|
* note, as on a chart with no option chain (the options chain's `no-chain`, a LINK perp).
|
|
45
54
|
*
|
|
55
|
+
* OPTLOAD (OPTLOAD-READ-CONTRACT section 5): the worker twin asks the gateway for one row per chart bar per option type
|
|
56
|
+
* of the asked split (`optionRead`: the bar, its anchor, the split) and packs the frames, and falls back to today's ask
|
|
57
|
+
* for the session when the gateway refuses `optionRead` by name; the fold, the landing and every answer stay the same.
|
|
58
|
+
*
|
|
46
59
|
* Before the protocol package names OPTION_PRINT_AGG, every input refuses by name before any fetch
|
|
47
60
|
* (`protocol-pending:OPTION_PRINT_AGG`). The gateway's scope reads stay behind its `read.option_print_scopes`
|
|
48
61
|
* switch: while it is off, the worker twin answers the refusal by name (`option-scope-reads-off`) and the run
|
|
@@ -50,12 +63,35 @@
|
|
|
50
63
|
*/
|
|
51
64
|
import { type WrunPollLane } from '../wrun-poll-lane.types.js';
|
|
52
65
|
import type { WrunBackendTier } from '../../wrun-tier-grid.util.js';
|
|
66
|
+
import type { WrunRowLaneHorizon } from '../wrun-row-lane.types.js';
|
|
53
67
|
/** The lane key (the refusal record's feed words, `wrun.refusal.feed.optionsFlow`). */
|
|
54
68
|
export declare const WRUN_OPTIONS_FLOW_LANE_KEY = "options_flow";
|
|
55
69
|
/** The tiers a bar is read from (rule 9, ADDENDUM-2 B3, the cme plane's scope families and ore's alike: C7-1; the VENUE
|
|
56
70
|
* family keeps no 5m tier, so a 5m ask of it the gateway rolls up from its 1m rows, which a bar older than 7 days no
|
|
57
|
-
* longer has: that bar reads its fill).
|
|
71
|
+
* longer has: that bar reads its fill).
|
|
72
|
+
* `servedLagMs` (OPTLOAD-READ-CONTRACT 5.4, read by the lane's coarsest tier choice): how long after a bar ends a
|
|
73
|
+
* coarser tier serves it. The 5m tier waits out the delayed window's lag, as the contract tiers do (the 15-minute
|
|
74
|
+
* OPRA delay plus the governed route's 120 s: a delayed read's end never falls inside a 5m bucket the reader serves
|
|
75
|
+
* whole); the day tier is refreshed only by `option-print-flow-slow` (hourly at :45, 4 hours back, once the day has
|
|
76
|
+
* ended), so it serves a day 6 hours after it ends. */
|
|
58
77
|
export declare const WRUN_OPTIONS_FLOW_TIERS: readonly WrunBackendTier[];
|
|
78
|
+
/**
|
|
79
|
+
* The print tables scope `prints` sums (OPTLOAD-READ-CONTRACT 7.2 and 7.4, the same pick as `option_prints`):
|
|
80
|
+
* `option_print_large` (90 days) once the floor reaches the large premium, else the raw `option_print` (3 days), never
|
|
81
|
+
* past the gateway's bar limit on a minute read (15,000 minutes); the clock margin keeps a bar at the edge out. The
|
|
82
|
+
* values are wrun-option-prints.util's (its module loads the venue table, which this lane reads lazily), pinned equal by
|
|
83
|
+
* the lane's spec.
|
|
84
|
+
*/
|
|
85
|
+
export declare const WRUN_OPTIONS_FLOW_PRINT_TABLES: Readonly<{
|
|
86
|
+
largeMinPremium: 25000;
|
|
87
|
+
rawRetentionMs: number;
|
|
88
|
+
largeRetentionMs: number;
|
|
89
|
+
barLimitMs: number;
|
|
90
|
+
clockMarginMs: number;
|
|
91
|
+
}>;
|
|
92
|
+
/** The span scope `prints` is served over at the clock (the lane's `horizon`): from the table its floor reads, within
|
|
93
|
+
* the bar limit; every other scope's history is its tiers' (none). */
|
|
94
|
+
export declare function wrunOptionsFlowHorizon(extras: Readonly<Record<string, unknown>>, nowMs: number): WrunRowLaneHorizon | undefined;
|
|
59
95
|
/**
|
|
60
96
|
* The Databento publisher id the data plane names each `venue` word by (the VENUE rows' `venue`, the request's
|
|
61
97
|
* `VENUE:<id>`). The words are ISO MIC codes, Databento's OPRA.PILLAR publisher suffixes (`OPRA.PILLAR.XCBO`): the
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* It reads OPTION_PRINT_AGG flow scope rows (wrun-opra-flow.leaf: which rows each ask names) through the
|
|
8
8
|
* `K_OPTION_PRINT_AGG_SCOPE` control and its worker twin, which sums a bucket's matching rows into the 32 fields
|
|
9
9
|
* (`foldWrunOptionsFlowRows`); this lane lands the buckets on the chart's bars under the tier rule (rule 9: 1m kept 7
|
|
10
|
-
* days, 5m kept 30, 1d kept
|
|
10
|
+
* days, 5m kept 30, 1d kept; OPTLOAD-READ-CONTRACT 5.4: the COARSEST that fits the bar, still holds it and already
|
|
11
|
+
* serves it, `tierChoice`, so a closed hourly bar reads 5m buckets and the forming one 1m; a stock chart's 09:30 New
|
|
12
|
+
* York bars, an
|
|
11
13
|
* OPRA contract chart's and a crypto chart's UTC ones, a CME chart's intraday ones on their stamps; a CME bar of a day
|
|
12
14
|
* or longer over its Globex session, from the 17:00 Chicago open before its 00:00Z stamp, which no UTC day bucket fits:
|
|
13
15
|
* such a bar older than the 5m tier reads its fill, never a misdated day), summed per bar. A bar no tier holds any more
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
* alone for a guest, as every other chain class reads the gate), `equity`, `etf`, `index` (MARKET rows of that US
|
|
31
33
|
* issue type: OPRA only), `venue` (OPRA: VENUE rows of the `venue` knob's exchange; crypto: COIN rows of the chart's
|
|
32
34
|
* coin on that venue, every book, a venue the gate keeps dark refused `flag-off` as the chain decision refuses it;
|
|
33
|
-
* CME, one venue: none);
|
|
35
|
+
* CME, one venue: none), `prints` (PRINTS rows of the chain's underlying on every plane, every book);
|
|
34
36
|
* - `dte`: `all` (the default), `0dte`, `week` (1 to 7 days), `month` (8 to 35), `later`;
|
|
35
37
|
* - `moneyness`: `all` (the default), `otm`, `itm`;
|
|
36
38
|
* - `venue`: scope `venue` only, required there: on OPRA an exchange's ISO MIC (`XCBO`), read by its Databento
|
|
@@ -38,11 +40,22 @@
|
|
|
38
40
|
* (`OKEX_OPTIONS`, the venue table's). That scope serves `call_prem_total`, `put_prem_total`,
|
|
39
41
|
* `call_contracts_total`, `put_contracts_total` and `prints` alone, with no `dte` or `moneyness` split;
|
|
40
42
|
* - `book`: scope `ticker` only: `auto` (the default, the chain's default book) or one series of the chain, decided
|
|
41
|
-
* when the run plans; a crypto chain's ask names it, an OPRA or CME chain's one book is its underlying
|
|
43
|
+
* when the run plans; a crypto chain's ask names it, an OPRA or CME chain's one book is its underlying;
|
|
44
|
+
* - `min_premium` and `max_dte`: scope `prints` only (OPTLOAD G4, kit 0.89.0): the premium floor in USD (required, above
|
|
45
|
+
* 0) and the most days to expiry (whole, 0 to 3,650; 0 keeps every expiry) of the chart underlying's prints the scope
|
|
46
|
+
* sums per bar, on every plane (the chain's exchange and underlying, every book). A knob may name a setting (an
|
|
47
|
+
* author's `"@floor"`, the sheet's `"floor"`): the planner reads its current value before this plan (wrun-poll-lanes
|
|
48
|
+
* `resolveWrunOptionSettingKnobs`), so a settings change re-plans and re-asks; a name no value reached is refused
|
|
49
|
+
* by name. Its history is the print tables' reach (`horizon`: 3 days raw, the large table past 25,000 USD up to the
|
|
50
|
+
* gateway's bar limit); older bars read the fill.
|
|
42
51
|
* A scope the chart's plane does not serve (a US issue type off OPRA, `venue` on CME, a venue word of another plane) is
|
|
43
52
|
* refused with `wrunLaneUnservedScopeSeed`'s seed, so the planner drops an input that declared a fill with the market's
|
|
44
53
|
* note, as on a chart with no option chain (the options chain's `no-chain`, a LINK perp).
|
|
45
54
|
*
|
|
55
|
+
* OPTLOAD (OPTLOAD-READ-CONTRACT section 5): the worker twin asks the gateway for one row per chart bar per option type
|
|
56
|
+
* of the asked split (`optionRead`: the bar, its anchor, the split) and packs the frames, and falls back to today's ask
|
|
57
|
+
* for the session when the gateway refuses `optionRead` by name; the fold, the landing and every answer stay the same.
|
|
58
|
+
*
|
|
46
59
|
* Before the protocol package names OPTION_PRINT_AGG, every input refuses by name before any fetch
|
|
47
60
|
* (`protocol-pending:OPTION_PRINT_AGG`). The gateway's scope reads stay behind its `read.option_print_scopes`
|
|
48
61
|
* switch: while it is off, the worker twin answers the refusal by name (`option-scope-reads-off`) and the run
|
|
@@ -51,19 +64,56 @@
|
|
|
51
64
|
import { refuseWrunPollInput, WRUN_POLL_AUTHOR_GATE_SEED, } from '../wrun-poll-lane.types.js';
|
|
52
65
|
import { decideWrunLaneChain, resolveWrunLaneChainChart, wrunLaneChainLeadMoved, wrunLaneChainRefusalError, wrunLaneOpraPlaneChain, } from '../opra-option-lanes.util.js';
|
|
53
66
|
import { wrunOptionsChainFlagOffRefusal, wrunOptionsChainGatedVenueName } from '../../wrun-options-chain.util.js';
|
|
54
|
-
import { WRUN_OPTION_PRINT_AGG_SCOPE_KTYPE, WRUN_OPTION_SCOPE_READS_OFF_CODE, WRUN_OPTIONS_FLOW_BOOK_FIELD, WRUN_OPTIONS_FLOW_CONTINUOUS_FIELD, WRUN_OPTIONS_FLOW_DTE, WRUN_OPTIONS_FLOW_EXCHANGE_FIELD, WRUN_OPTIONS_FLOW_FIELDS, WRUN_OPTIONS_FLOW_MONEYNESS, WRUN_OPTIONS_FLOW_OPRA_SCOPES, WRUN_OPTIONS_FLOW_SCOPES, WRUN_OPTIONS_FLOW_TIER_MS, WRUN_OPTIONS_FLOW_TYPE, WRUN_OPTIONS_FLOW_VENUE_FIELDS, WRUN_OPTIONS_FLOW_VENUE_RE, WRUN_OPTIONS_FLOW_VENUES_FIELD, } from '../../wrun-opra-flow.leaf.js';
|
|
67
|
+
import { WRUN_OPTION_PRINT_AGG_SCOPE_KTYPE, WRUN_OPTION_SCOPE_READS_OFF_CODE, WRUN_OPTIONS_FLOW_BOOK_FIELD, WRUN_OPTIONS_FLOW_CONTINUOUS_FIELD, WRUN_OPTIONS_FLOW_DTE, WRUN_OPTIONS_FLOW_EXCHANGE_FIELD, WRUN_OPTIONS_FLOW_FIELDS, WRUN_OPTIONS_FLOW_MAX_DTE_DAYS, WRUN_OPTIONS_FLOW_MONEYNESS, WRUN_OPTIONS_FLOW_OPRA_SCOPES, WRUN_OPTIONS_FLOW_PRINTS_UNSERVED_CODE, WRUN_OPTIONS_FLOW_SCOPES, WRUN_OPTIONS_FLOW_TIER_MS, WRUN_OPTIONS_FLOW_TYPE, WRUN_OPTIONS_FLOW_VENUE_FIELDS, WRUN_OPTIONS_FLOW_VENUE_RE, WRUN_OPTIONS_FLOW_VENUES_FIELD, } from '../../wrun-opra-flow.leaf.js';
|
|
55
68
|
import { assertWrunProtocolType, wrunProtocolPendingSeed } from '../../wrun-protocol-pending.util.js';
|
|
56
69
|
/** The lane key (the refusal record's feed words, `wrun.refusal.feed.optionsFlow`). */
|
|
57
70
|
export const WRUN_OPTIONS_FLOW_LANE_KEY = 'options_flow';
|
|
71
|
+
const MINUTE = 60_000;
|
|
72
|
+
const HOUR = 60 * MINUTE;
|
|
58
73
|
const DAY = 86_400_000;
|
|
59
74
|
/** The tiers a bar is read from (rule 9, ADDENDUM-2 B3, the cme plane's scope families and ore's alike: C7-1; the VENUE
|
|
60
75
|
* family keeps no 5m tier, so a 5m ask of it the gateway rolls up from its 1m rows, which a bar older than 7 days no
|
|
61
|
-
* longer has: that bar reads its fill).
|
|
76
|
+
* longer has: that bar reads its fill).
|
|
77
|
+
* `servedLagMs` (OPTLOAD-READ-CONTRACT 5.4, read by the lane's coarsest tier choice): how long after a bar ends a
|
|
78
|
+
* coarser tier serves it. The 5m tier waits out the delayed window's lag, as the contract tiers do (the 15-minute
|
|
79
|
+
* OPRA delay plus the governed route's 120 s: a delayed read's end never falls inside a 5m bucket the reader serves
|
|
80
|
+
* whole); the day tier is refreshed only by `option-print-flow-slow` (hourly at :45, 4 hours back, once the day has
|
|
81
|
+
* ended), so it serves a day 6 hours after it ends. */
|
|
62
82
|
export const WRUN_OPTIONS_FLOW_TIERS = Object.freeze([
|
|
63
83
|
{ key: '1m', ms: WRUN_OPTIONS_FLOW_TIER_MS['1m'], retentionMs: 7 * DAY },
|
|
64
|
-
{ key: '5m', ms: WRUN_OPTIONS_FLOW_TIER_MS['5m'], retentionMs: 30 * DAY },
|
|
65
|
-
{ key: '1d', ms: WRUN_OPTIONS_FLOW_TIER_MS['1d'] },
|
|
84
|
+
{ key: '5m', ms: WRUN_OPTIONS_FLOW_TIER_MS['5m'], retentionMs: 30 * DAY, servedLagMs: 17 * MINUTE },
|
|
85
|
+
{ key: '1d', ms: WRUN_OPTIONS_FLOW_TIER_MS['1d'], servedLagMs: 6 * HOUR },
|
|
66
86
|
]);
|
|
87
|
+
/**
|
|
88
|
+
* The print tables scope `prints` sums (OPTLOAD-READ-CONTRACT 7.2 and 7.4, the same pick as `option_prints`):
|
|
89
|
+
* `option_print_large` (90 days) once the floor reaches the large premium, else the raw `option_print` (3 days), never
|
|
90
|
+
* past the gateway's bar limit on a minute read (15,000 minutes); the clock margin keeps a bar at the edge out. The
|
|
91
|
+
* values are wrun-option-prints.util's (its module loads the venue table, which this lane reads lazily), pinned equal by
|
|
92
|
+
* the lane's spec.
|
|
93
|
+
*/
|
|
94
|
+
export const WRUN_OPTIONS_FLOW_PRINT_TABLES = Object.freeze({
|
|
95
|
+
largeMinPremium: 25_000,
|
|
96
|
+
rawRetentionMs: 3 * DAY,
|
|
97
|
+
largeRetentionMs: 90 * DAY,
|
|
98
|
+
barLimitMs: 15_000 * MINUTE,
|
|
99
|
+
clockMarginMs: 10 * MINUTE,
|
|
100
|
+
});
|
|
101
|
+
/** The span scope `prints` is served over at the clock (the lane's `horizon`): from the table its floor reads, within
|
|
102
|
+
* the bar limit; every other scope's history is its tiers' (none). */
|
|
103
|
+
export function wrunOptionsFlowHorizon(extras, nowMs) {
|
|
104
|
+
const minPremium = extras.minPremium;
|
|
105
|
+
if (extras.scope !== 'prints' || typeof minPremium !== 'number' || !(minPremium > 0) || !Number.isFinite(nowMs)) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
const tables = WRUN_OPTIONS_FLOW_PRINT_TABLES;
|
|
109
|
+
const reach = minPremium >= tables.largeMinPremium ? tables.largeRetentionMs : tables.rawRetentionMs;
|
|
110
|
+
const historyFrom = nowMs - reach;
|
|
111
|
+
const barLimitFrom = nowMs - tables.barLimitMs + tables.clockMarginMs;
|
|
112
|
+
return {
|
|
113
|
+
servedFromMs: Math.max(historyFrom, barLimitFrom),
|
|
114
|
+
completeFromMs: Math.max(historyFrom + tables.clockMarginMs, barLimitFrom),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
67
117
|
/**
|
|
68
118
|
* The Databento publisher id the data plane names each `venue` word by (the VENUE rows' `venue`, the request's
|
|
69
119
|
* `VENUE:<id>`). The words are ISO MIC codes, Databento's OPRA.PILLAR publisher suffixes (`OPRA.PILLAR.XCBO`): the
|
|
@@ -128,6 +178,40 @@ function venueScopeWord(source, ctx, dte, moneyness) {
|
|
|
128
178
|
}
|
|
129
179
|
return venue;
|
|
130
180
|
}
|
|
181
|
+
/** The knobs scope `prints` alone reads (om `WRUN_OPTION_PARAM_KNOBS.options_flow`). */
|
|
182
|
+
const PRINTS_KNOBS = Object.freeze(['min_premium', 'max_dte']);
|
|
183
|
+
/**
|
|
184
|
+
* Scope `prints`' floors (om `printsScope`): `min_premium` a premium in USD above 0 (required), `max_dte` whole days
|
|
185
|
+
* from 0 to 3,650 (0 or absent keeps every expiry, so it rides no field). A knob naming a setting arrives as the
|
|
186
|
+
* setting's current value (the planner's `resolveWrunOptionSettingKnobs`); a name still here is one no setting value
|
|
187
|
+
* reached the plan for, refused by name. Beside any other scope either knob is refused by name.
|
|
188
|
+
*/
|
|
189
|
+
function printsKnobs(source, ctx, scope) {
|
|
190
|
+
if (scope !== 'prints') {
|
|
191
|
+
for (const knob of PRINTS_KNOBS) {
|
|
192
|
+
if (source[knob] === undefined)
|
|
193
|
+
continue;
|
|
194
|
+
return refuseWrunPollInput(ctx, `declares ${knob} '${String(source[knob])}' beside scope "${scope}": ${knob} is read under scope "prints" ` +
|
|
195
|
+
'only (options-flow-prints-knob)', WRUN_POLL_AUTHOR_GATE_SEED);
|
|
196
|
+
}
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
const refuseKnob = (knob, value, rule) => refuseWrunPollInput(ctx, typeof value === 'string'
|
|
200
|
+
? `binds ${knob} to the setting '${value}', and no value of it reached this plan: ${knob} is ${rule} ` +
|
|
201
|
+
'(options-flow-prints-knob)'
|
|
202
|
+
: `declares ${knob} '${String(value)}' under scope "prints": ${rule} (options-flow-prints-knob)`, WRUN_POLL_AUTHOR_GATE_SEED);
|
|
203
|
+
const floor = source.min_premium;
|
|
204
|
+
if (typeof floor !== 'number' || !Number.isFinite(floor) || floor <= 0) {
|
|
205
|
+
return refuseKnob('min_premium', floor, 'the smallest premium a summed print keeps, in USD above 0 (required)');
|
|
206
|
+
}
|
|
207
|
+
const days = source.max_dte;
|
|
208
|
+
if (days === undefined)
|
|
209
|
+
return { minPremium: floor };
|
|
210
|
+
if (typeof days !== 'number' || !Number.isInteger(days) || days < 0 || days > WRUN_OPTIONS_FLOW_MAX_DTE_DAYS) {
|
|
211
|
+
return refuseKnob('max_dte', days, `whole days to expiry from 0 to ${WRUN_OPTIONS_FLOW_MAX_DTE_DAYS}`);
|
|
212
|
+
}
|
|
213
|
+
return days > 0 ? { minPremium: floor, maxDte: days } : { minPremium: floor };
|
|
214
|
+
}
|
|
131
215
|
/** The chart each run's plan resolved for the flow lane, by the plan's scope (`WrunPollLaneContext.runScope`): every
|
|
132
216
|
* input of one run reads one resolution (one chain, one `auto` book), and the next run resolves afresh. */
|
|
133
217
|
const flowCharts = new WeakMap();
|
|
@@ -174,19 +258,23 @@ function refuseUnmappedVenue(ctx, venue) {
|
|
|
174
258
|
/**
|
|
175
259
|
* What one input reads on the chain its run decided (the acquisition's fields beside `scope`, `dte` and `moneyness`),
|
|
176
260
|
* the scope table per plane (R7c C7-2): always the chain's exchange (`flowExchange`, the lane's chain mark); a read of
|
|
177
|
-
* one underlying its coin; a crypto ticker its ONE book (`flowBook`), a CME ticker off a continuous alias
|
|
178
|
-
* (`flowContinuous`);
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
261
|
+
* one underlying its coin; a crypto ticker its ONE book (`flowBook`), a CME ticker or prints read off a continuous alias
|
|
262
|
+
* the alias (`flowContinuous`); scope `prints` the underlying's prints on the chain's exchange, every book; a crypto
|
|
263
|
+
* scope across venues its venues (`flowVenues`), the ones the crypto-options gate leaves open to the chart (`gateOn`,
|
|
264
|
+
* the run's resolved chart's: every crypto venue for a signed-in session, Deribit alone for a guest, as every other
|
|
265
|
+
* chain class reads them), a gated `venue` word refused as the chain decision refuses one (`flag-off`); an OPRA venue its
|
|
266
|
+
* publisher id. A scope the plane does not serve refuses with the unserved-scope seed.
|
|
182
267
|
*/
|
|
183
268
|
async function flowReadOf(scope, venue, chain, gateOn, ctx) {
|
|
184
269
|
const exchange = { [WRUN_OPTIONS_FLOW_EXCHANGE_FIELD]: chain.exchange };
|
|
185
270
|
const coin = chain.underlying.toUpperCase();
|
|
186
271
|
const lists = `this chart's options list on ${chain.exchange}`;
|
|
187
|
-
if (scope === 'ticker') {
|
|
188
|
-
if (chain.plane === 'plain')
|
|
189
|
-
return
|
|
272
|
+
if (scope === 'ticker' || scope === 'prints') {
|
|
273
|
+
if (chain.plane === 'plain') {
|
|
274
|
+
return scope === 'ticker'
|
|
275
|
+
? { coin, ...exchange, [WRUN_OPTIONS_FLOW_BOOK_FIELD]: chain.book.toUpperCase() }
|
|
276
|
+
: { coin, ...exchange };
|
|
277
|
+
}
|
|
190
278
|
const continuous = chain.continuous !== undefined ? { [WRUN_OPTIONS_FLOW_CONTINUOUS_FIELD]: chain.continuous } : {};
|
|
191
279
|
return { coin, ...exchange, ...continuous };
|
|
192
280
|
}
|
|
@@ -256,7 +344,8 @@ async function planWrunOptionsFlow(source, ctx) {
|
|
|
256
344
|
return refuseWrunPollInput(ctx, `declares book '${String(source.book)}' beside scope "${scope}": a book names the one series of scope ` +
|
|
257
345
|
'"ticker" only, every other scope reads every book (options-flow-book-scope)', WRUN_POLL_AUTHOR_GATE_SEED);
|
|
258
346
|
}
|
|
259
|
-
|
|
347
|
+
const prints = printsKnobs(source, ctx, scope);
|
|
348
|
+
if ((scope === 'ticker' || scope === 'prints') && ctx.coin.trim() === '') {
|
|
260
349
|
return refuseWrunPollInput(ctx, "reads the options flow of the chart's underlying, and this chart names none", {
|
|
261
350
|
cls: 'feed-missing',
|
|
262
351
|
variant: 'market-paused',
|
|
@@ -266,7 +355,13 @@ async function planWrunOptionsFlow(source, ctx) {
|
|
|
266
355
|
await assertWrunProtocolType(ctx, WRUN_OPTIONS_FLOW_TYPE, WRUN_OPTIONS_FLOW_LANE_KEY);
|
|
267
356
|
const chart = await flowChartOf(ctx);
|
|
268
357
|
const chain = await decideWrunLaneChain(chart, { book: scope === 'ticker' ? source.book : undefined }, ctx);
|
|
269
|
-
return {
|
|
358
|
+
return {
|
|
359
|
+
scope,
|
|
360
|
+
...(await flowReadOf(scope, venue, chain, chart.cryptoVenues.enabled, ctx)),
|
|
361
|
+
dte,
|
|
362
|
+
moneyness,
|
|
363
|
+
...prints,
|
|
364
|
+
};
|
|
270
365
|
}
|
|
271
366
|
/** Whether an acquisition no longer names the chain the lane would plan now (D12): a CME ticker read off a continuous
|
|
272
367
|
* alias whose lead future rolled since the run planned it (`wrunLaneChainLeadMoved`). A live session holding it
|
|
@@ -283,10 +378,12 @@ export const lane = {
|
|
|
283
378
|
join: 'bar',
|
|
284
379
|
label: 'Options flow',
|
|
285
380
|
nativeRows: true,
|
|
286
|
-
barGrid: { landing: 'flow', tiers: WRUN_OPTIONS_FLOW_TIERS },
|
|
381
|
+
barGrid: { landing: 'flow', tiers: WRUN_OPTIONS_FLOW_TIERS, tierChoice: 'coarsest' },
|
|
382
|
+
horizon: wrunOptionsFlowHorizon,
|
|
287
383
|
chain: { exchangeField: WRUN_OPTIONS_FLOW_EXCHANGE_FIELD },
|
|
288
384
|
acquisitionMoved: wrunOptionsFlowAcquisitionMoved,
|
|
289
385
|
refusedAnswers: {
|
|
290
386
|
[WRUN_OPTION_SCOPE_READS_OFF_CODE]: { cls: 'service-no-answer', variant: 'switched-off' },
|
|
387
|
+
[WRUN_OPTIONS_FLOW_PRINTS_UNSERVED_CODE]: { cls: 'service-no-answer', variant: 'switched-off' },
|
|
291
388
|
},
|
|
292
389
|
};
|
|
@@ -77,7 +77,8 @@ export interface WrunLaneChain {
|
|
|
77
77
|
/** The ONE book read, a series name upper case, decided when the run plans: the input's pinned series, or for
|
|
78
78
|
* `auto` the chain's default book (`WrunLaneChainChart.autoBook`). Never `auto`, never picked per answer. */
|
|
79
79
|
book: string;
|
|
80
|
-
/** A CME chain read off a continuous chart: the alias (`ES1!`) whose lead `underlying` is
|
|
80
|
+
/** A CME chain read off a continuous chart: the alias (`ES1!`) whose lead `underlying` is (for MES1!, MESF's
|
|
81
|
+
* contract of that lead: `cmeOptionsContract`). */
|
|
81
82
|
continuous?: string;
|
|
82
83
|
}
|
|
83
84
|
/** A decided chain before its book: what the default book is resolved for. */
|
|
@@ -91,8 +92,8 @@ export interface WrunLaneChainChart {
|
|
|
91
92
|
deribitListed: (coin: string) => boolean;
|
|
92
93
|
/** The exchange a plain venue word's chain lists on (the venue table's first exchange of its row). */
|
|
93
94
|
venueExchange: (word: string) => string | undefined;
|
|
94
|
-
/** A CME chart whose chain underlies a continuous alias: the alias and the contract leading it now
|
|
95
|
-
* lead could not be resolved). */
|
|
95
|
+
/** A CME chart whose chain underlies a continuous alias: the alias and the contract leading it now, MESF's for
|
|
96
|
+
* MES1! (null: the lead could not be resolved). */
|
|
96
97
|
cmeLead?: {
|
|
97
98
|
alias: string;
|
|
98
99
|
contract: string | null;
|
|
@@ -126,8 +127,9 @@ export declare const WRUN_OPTION_CHART_UNRESOLVED_CODE = "wrun_option_chart_unre
|
|
|
126
127
|
* continuous lead resolver): the chart's chain (`resolveWrunLaneChartChain`, the options chain lane's own, or the
|
|
127
128
|
* chain the caller already holds, `held`: the OPRA plane's own by coin, `wrunLaneOpraPlaneChain`), the crypto venue
|
|
128
129
|
* words (`resolveWrunLaneCryptoVenues`), for a CME chain on a continuous alias the contract leading it now
|
|
129
|
-
* (option-chain.service `resolveChainContract`, the roll rule the terminal identity admits the alias by
|
|
130
|
-
* decided chain's default book (`resolveWrunLaneChainAutoBook`, asked once per chain for
|
|
130
|
+
* (option-chain.service `resolveChainContract`, the roll rule the terminal identity admits the alias by; MES1!'s as
|
|
131
|
+
* MESF's contract), and each decided chain's default book (`resolveWrunLaneChainAutoBook`, asked once per chain for
|
|
132
|
+
* this chart).
|
|
131
133
|
*/
|
|
132
134
|
export declare function resolveWrunLaneChainChart(ctx: Pick<WrunPollLaneContext, 'exchange' | 'symbol' | 'coin' | 'category'>, held?: WrunLaneChartChain): Promise<WrunLaneChainChart>;
|
|
133
135
|
/**
|
|
@@ -190,10 +192,11 @@ export declare function wrunLaneChainRefusalSeed(refusal: Pick<WrunOptionsChainR
|
|
|
190
192
|
export declare function wrunLaneChainRefusalError(refusal: WrunOptionsChainRefusal, sourceClass: string): Error;
|
|
191
193
|
/**
|
|
192
194
|
* Whether a chain read off a continuous alias no longer names the contract leading it (D12): the lead resolver's last
|
|
193
|
-
* answer (`peekRegisteredContinuousLead`) for the alias on the chain's exchange
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
195
|
+
* answer (`peekRegisteredContinuousLead`) for the alias on the chain's exchange, as the contract its options list on
|
|
196
|
+
* (`cmeOptionsContract`: MES1!'s lead MESZ6 was planned as MESFZ6), names another contract than the one the run
|
|
197
|
+
* planned. A chain lane's `acquisitionMoved` reads it over its own acquisition fields, so a live session holding the
|
|
198
|
+
* old contract's rows rebuilds instead of joining the next contract's tail to them. A read off no alias, and a lead
|
|
199
|
+
* not resolved yet, moved nothing.
|
|
197
200
|
*/
|
|
198
201
|
export declare function wrunLaneChainLeadMoved(exchange: unknown, alias: unknown, planned: unknown): boolean;
|
|
199
202
|
/** Refuse a knob the class does not take, by name (om's sheet refusal for a stray knob). */
|
|
@@ -22,6 +22,7 @@ import { wrunChartHostEnv } from '../../../host-env.js';
|
|
|
22
22
|
import { OPRA_GOVERNED_EXCHANGES } from '../../../constants/governed-exchanges.constants.js';
|
|
23
23
|
import { isCmeGoverned } from '../../chart/cme-realtime.util.js';
|
|
24
24
|
import { peekRegisteredContinuousLead } from '../../chart/continuous-contracts.util.js';
|
|
25
|
+
import { cmeOptionsContract } from '../../options/cme-options-root.util.js';
|
|
25
26
|
import { refuseWrunPollInput, WRUN_LANE_KNOB_INVALID_CODE } from './wrun-poll-lane.types.js';
|
|
26
27
|
import { wrunLaneChainPlaneOf } from './wrun-row-lane.types.js';
|
|
27
28
|
import { decideWrunOptionsChainIdentity, WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_IDS, WRUN_OPTIONS_CHAIN_ONE_VENUE_CODE, WRUN_OPTIONS_CHAIN_UNAVAILABLE_CODE, WRUN_OPTIONS_CHAIN_VENUE_CODE, } from '../wrun-options-chain.util.js';
|
|
@@ -220,8 +221,9 @@ export const WRUN_OPTION_CHART_UNRESOLVED_CODE = 'wrun_option_chart_unresolved';
|
|
|
220
221
|
* continuous lead resolver): the chart's chain (`resolveWrunLaneChartChain`, the options chain lane's own, or the
|
|
221
222
|
* chain the caller already holds, `held`: the OPRA plane's own by coin, `wrunLaneOpraPlaneChain`), the crypto venue
|
|
222
223
|
* words (`resolveWrunLaneCryptoVenues`), for a CME chain on a continuous alias the contract leading it now
|
|
223
|
-
* (option-chain.service `resolveChainContract`, the roll rule the terminal identity admits the alias by
|
|
224
|
-
* decided chain's default book (`resolveWrunLaneChainAutoBook`, asked once per chain for
|
|
224
|
+
* (option-chain.service `resolveChainContract`, the roll rule the terminal identity admits the alias by; MES1!'s as
|
|
225
|
+
* MESF's contract), and each decided chain's default book (`resolveWrunLaneChainAutoBook`, asked once per chain for
|
|
226
|
+
* this chart).
|
|
225
227
|
*/
|
|
226
228
|
export async function resolveWrunLaneChainChart(ctx, held) {
|
|
227
229
|
const chain = held ?? (await resolveWrunLaneChartChain(ctx));
|
|
@@ -413,16 +415,17 @@ export function wrunLaneChainRefusalError(refusal, sourceClass) {
|
|
|
413
415
|
}
|
|
414
416
|
/**
|
|
415
417
|
* Whether a chain read off a continuous alias no longer names the contract leading it (D12): the lead resolver's last
|
|
416
|
-
* answer (`peekRegisteredContinuousLead`) for the alias on the chain's exchange
|
|
417
|
-
*
|
|
418
|
-
*
|
|
419
|
-
*
|
|
418
|
+
* answer (`peekRegisteredContinuousLead`) for the alias on the chain's exchange, as the contract its options list on
|
|
419
|
+
* (`cmeOptionsContract`: MES1!'s lead MESZ6 was planned as MESFZ6), names another contract than the one the run
|
|
420
|
+
* planned. A chain lane's `acquisitionMoved` reads it over its own acquisition fields, so a live session holding the
|
|
421
|
+
* old contract's rows rebuilds instead of joining the next contract's tail to them. A read off no alias, and a lead
|
|
422
|
+
* not resolved yet, moved nothing.
|
|
420
423
|
*/
|
|
421
424
|
export function wrunLaneChainLeadMoved(exchange, alias, planned) {
|
|
422
425
|
if (typeof alias !== 'string' || alias === '' || typeof exchange !== 'string')
|
|
423
426
|
return false;
|
|
424
427
|
const lead = peekRegisteredContinuousLead(exchange, alias)?.symbol;
|
|
425
|
-
return typeof lead === 'string' && lead !== '' && lead !== planned;
|
|
428
|
+
return typeof lead === 'string' && lead !== '' && cmeOptionsContract(lead) !== planned;
|
|
426
429
|
}
|
|
427
430
|
/** The seed of a knob the author fixes in the code: a failed run, its words in the details. */
|
|
428
431
|
const WRUN_LANE_KNOB_SEED = Object.freeze(wrunAuthorRuleSeed(WRUN_LANE_KNOB_INVALID_CODE));
|
|
@@ -22,8 +22,10 @@
|
|
|
22
22
|
* whole registry for a spec. The folder ships EMPTY of lanes until a class lands (UW-PARITY units U10b, U11).
|
|
23
23
|
*
|
|
24
24
|
* LIGHT on purpose: it never imports the poll-lane registry (whose index loads every poll lane's file), so a module
|
|
25
|
-
* reading row lanes (the requirement table, the
|
|
26
|
-
*
|
|
25
|
+
* reading row lanes (the requirement table, the live intake) loads no poll lane; nor the packer (`wrun-pack.util`,
|
|
26
|
+
* off the boot path): the lanes' tuple widths go through the widths leaf the packer reads (`wrun-pack-widths.leaf`).
|
|
27
|
+
* The poll-lane registry binds itself as this one's peer when it loads (`bindWrunRowLanePollPeers`), and each refuses
|
|
28
|
+
* a class or a key the other holds.
|
|
27
29
|
*/
|
|
28
30
|
// First: the row lane modules evaluate before this module's other imports, the order the bundler glob gave them.
|
|
29
31
|
import { WRUN_ROW_LANE_MODULES } from './row-lanes/index.js';
|
|
@@ -31,7 +33,9 @@ import { WRUN_LANE_CHAIN_PLANES } from './wrun-row-lane.types.js';
|
|
|
31
33
|
import { assertWrunHostGridLanding } from './host-grid-landing.js';
|
|
32
34
|
import { WRUN_BROWSER_BUILTIN_SOURCE_CLASSES, wrunPollLaneClassOfFile } from '../wrun-browser-sources.leaf.js';
|
|
33
35
|
import { registerWrunRefusalFeedKeys } from '../wrun-refusal.util.js';
|
|
34
|
-
|
|
36
|
+
// The widths leaf, never the packer: this registry rides the boot path (the live intake reads row lanes) and the
|
|
37
|
+
// packer does not (tests/utility/wrun/wrun-door.closure.spec.ts); the packer reads the table this registers.
|
|
38
|
+
import { registerWrunRowLaneTupleWidths } from '../wrun-pack-widths.leaf.js';
|
|
35
39
|
const WRUN_ROW_LANE_KEY_RE = /^[a-z][a-z0-9_]*$/;
|
|
36
40
|
let pollPeers = () => ({ classes: [], keys: [] });
|
|
37
41
|
/** The poll-lane registry's binding, at its load: the lanes a row lane must not share a class or a key with. */
|
|
@@ -198,8 +202,8 @@ export function wrunRowLanesOfModules(modules) {
|
|
|
198
202
|
function indexWrunRowLanes(lanes) {
|
|
199
203
|
// A lane's own feed words, so a refusal record naming it reads them (no shared table row).
|
|
200
204
|
registerWrunRefusalFeedKeys(Object.fromEntries(lanes.flatMap((lane) => (lane.feedWords !== undefined ? [[lane.laneKey, lane.feedWords]] : []))));
|
|
201
|
-
// A lane's tuple width, so the packer counts its max_cells in the lane's tuples
|
|
202
|
-
//
|
|
205
|
+
// A lane's tuple width, so the packer counts its max_cells in the lane's tuples: registered in the widths leaf the
|
|
206
|
+
// packer reads at pack time (the packer never imports this registry, and this registry never loads the packer).
|
|
203
207
|
registerWrunRowLaneTupleWidths(Object.fromEntries(lanes.map((lane) => [lane.sourceClass, lane.width])));
|
|
204
208
|
return {
|
|
205
209
|
lanes,
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as lane_option_contract_flow from './option_contract_flow.js';
|
|
2
2
|
import * as lane_option_contract_state from './option_contract_state.js';
|
|
3
3
|
import * as lane_option_prints from './option_prints.js';
|
|
4
|
+
import * as lane_option_strike_flow from './option_strike_flow.js';
|
|
4
5
|
import * as lane_option_strikes from './option_strikes.js';
|
|
5
6
|
import * as lane_option_surface from './option_surface.js';
|
|
6
7
|
export const WRUN_ROW_LANE_MODULES = {
|
|
7
8
|
'./row-lanes/option_contract_flow.ts': lane_option_contract_flow,
|
|
8
9
|
'./row-lanes/option_contract_state.ts': lane_option_contract_state,
|
|
9
10
|
'./row-lanes/option_prints.ts': lane_option_prints,
|
|
11
|
+
'./row-lanes/option_strike_flow.ts': lane_option_strike_flow,
|
|
10
12
|
'./row-lanes/option_strikes.ts': lane_option_strikes,
|
|
11
13
|
'./row-lanes/option_surface.ts': lane_option_surface,
|
|
12
14
|
};
|
|
@@ -10,12 +10,13 @@
|
|
|
10
10
|
* provenance stamp, the routed tier), CME's on a CME futures chart (a continuous chart reads its lead contract, and a
|
|
11
11
|
* live session rebuilds once the lead rolls: `acquisitionMoved`), none on a crypto chain. A chart with no option chain
|
|
12
12
|
* is refused by the decision's own name (`no-options` / `chain`), which a declared `missing: "empty"` drops with a
|
|
13
|
-
* note.
|
|
13
|
+
* note. On the OPRA plane the chain is the plane's own by coin (G5 O1: no chain directory read).
|
|
14
14
|
* - The acquisition names the chain: `coin` (the chain's underlying, the key its plane files the rows under),
|
|
15
15
|
* `flowExchange` (its plane follows it), `flowBook` for a book other than the underlying's own series (ONE book per
|
|
16
16
|
* input, D11: the worker keeps that book's rows) and `flowContinuous` for a CME chain read off a continuous alias.
|
|
17
17
|
* - Facets (om's facet list and words): `venue` and `book` (the chain classes' words), `expiries`, `strike_window_pct`
|
|
18
|
-
* and `min_volume` (above 0, in the chain's size unit: contracts on OPRA and CME, coin on a crypto chain),
|
|
18
|
+
* and `min_volume` (above 0, in the chain's size unit: contracts on OPRA and CME, coin on a crypto chain), and
|
|
19
|
+
* `span`, `history` and `min_premium` (OPTLOAD, kit 0.89.0; never `min_premium` beside `strike_window_pct`), each
|
|
19
20
|
* refused by name outside its words (`wrun_option_knob_invalid`); `max_cells` required (the static plan's rule).
|
|
20
21
|
* - Tiers: 1m kept 7 days, 5m 30, 1h and 1d kept. The fold is tier-invariant (the backend rolls every tier up from
|
|
21
22
|
* the 1m one: sums, the strike window's contract-weighted underlying among them, the newest last price and the
|