@orangecharts/wrun-chart-host 0.3.0 → 0.4.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 +11 -5
- package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +133 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.js +451 -0
- package/dist/host-env.d.ts +8 -6
- package/dist/host-ports.types.d.ts +7 -22
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/utility/chart/date-labelled-interval.leaf.d.ts +15 -0
- package/dist/utility/chart/date-labelled-interval.leaf.js +19 -0
- package/dist/utility/chart/indicator-run-interval.util.d.ts +130 -0
- package/dist/utility/chart/indicator-run-interval.util.js +268 -0
- package/dist/utility/chart/window-geometry.leaf.d.ts +119 -0
- package/dist/utility/chart/window-geometry.leaf.js +391 -0
- package/dist/utility/chart/window-owner.leaf.d.ts +19 -0
- package/dist/utility/chart/window-owner.leaf.js +24 -0
- package/dist/utility/html-escape.leaf.d.ts +11 -0
- package/dist/utility/html-escape.leaf.js +20 -0
- package/dist/utility/wrun/sources/lanes/option_daily.d.ts +43 -15
- package/dist/utility/wrun/sources/lanes/option_daily.js +78 -20
- package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +14 -10
- package/dist/utility/wrun/sources/lanes/option_stats_10m.js +5 -4
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +22 -3
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +38 -7
- package/dist/utility/wrun/sources/registry.js +31 -1
- package/dist/utility/wrun/sources/row-lane-registry.js +5 -5
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +49 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +74 -18
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +49 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +57 -47
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +36 -4
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +6 -12
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +37 -3
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +128 -2
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +233 -51
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +0 -8
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +26 -24
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +85 -104
- package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +29 -10
- package/dist/utility/wrun/wrun-opra-stats.leaf.js +29 -10
- package/dist/utility/wrun/wrun-panel-mount.lazy.d.ts +10 -0
- package/dist/utility/wrun/wrun-panel-mount.lazy.js +68 -0
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +377 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +2251 -0
- package/dist/utility/wrun/wrun-pause-dim.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-pause-dim.util.js +153 -0
- package/dist/utility/wrun/wrun-plot-gate.types.d.ts +23 -0
- package/dist/utility/wrun/wrun-plot-gate.types.js +7 -0
- package/dist/utility/wrun/wrun-run-interval-projection.types.d.ts +14 -0
- package/dist/utility/wrun/wrun-run-interval-projection.types.js +1 -0
- package/package.json +1 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { wrunRowLaneByKey, wrunRowLaneOfClass, wrunRowLanes } from './row-lane-registry.js';
|
|
2
|
-
import { stableJson, wrunOpraPlaneStopDetail } from './wrun-poll-lanes.util.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { assertWrunOpraLaneReadable, wrunOpraLanePayloadFields } from '../wrun-opra-lane.util.js';
|
|
6
|
-
import { wrunOptionsStopSeed } from '../wrun-refusal.util.js';
|
|
2
|
+
import { assertWrunLaneChainPlaneReadable, stableJson, wrunChainLaneStop, wrunChartOpraPlane, wrunLaneNoChainRefusal, wrunOpraPlaneStopDetail, wrunPollLaneChainAsk, wrunPollLaneChainExchange, wrunPollLaneChainGovernedExchange, wrunPollLaneChainPlane, wrunUnservedLaneInput, } from './wrun-poll-lanes.util.js';
|
|
3
|
+
import { WRUN_ROW_LANE_ID_PREFIX, } from './wrun-row-lane.types.js';
|
|
4
|
+
import { assertWrunOpraLaneReadable } from '../wrun-opra-lane.util.js';
|
|
7
5
|
import { wrunPartialMarkerTuple, wrunPresentIsPartial, wrunTuplesMarkedPartial } from '../wrun-present-bits.util.js';
|
|
8
6
|
import { wrunCellRowsWithPartialBars, wrunHostGridAsks, wrunHostGridFallbackAsks, wrunHostGridFetchTo, wrunLandCellRowsOnHostBars, } from '../wrun-tier-grid.util.js';
|
|
9
7
|
/**
|
|
@@ -40,34 +38,54 @@ export function wrunRowLaneInstanceKey(laneKey, extras) {
|
|
|
40
38
|
const named = Object.keys(extras).some((key) => extras[key] !== undefined);
|
|
41
39
|
return `${WRUN_ROW_LANE_ID_PREFIX}${laneKey}${named ? stableJson(extras) : ''}`;
|
|
42
40
|
}
|
|
41
|
+
/** The fill a celled input reads on every bar of a feed the chart does not serve (`missing: "empty"`). */
|
|
42
|
+
const WRUN_ROW_LANE_UNSERVED_FILLS = Object.freeze(['empty']);
|
|
43
43
|
/** Why a row lane is not served on a chart, as its refusal says it. */
|
|
44
44
|
function wrunRowLaneUnadmittedReason(lane) {
|
|
45
45
|
return lane.governed === 'opra'
|
|
46
46
|
? "is not served on this chart: it reads US options data, which a US stock or ETF chart (its underlying's options) and an OPRA option contract chart serve"
|
|
47
47
|
: "is not served on this chart: it reads the chart's own market, and a stock, forex, commodity or DEX chart serves candles and time";
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Why a row lane that is no chain lane is not served on the chart, or undefined: a governed OPRA lane (after the OPRA
|
|
51
|
+
* wall, on any chart) off the plane (the stop's words when a known stop keeps the chart's options off it), any other
|
|
52
|
+
* lane on an index-mode chart.
|
|
53
|
+
*/
|
|
54
|
+
function wrunRowLaneUnserved(lane, plane, indexMode, run, ctx) {
|
|
55
|
+
if (lane.governed === 'opra') {
|
|
56
|
+
assertWrunOpraLaneReadable(run, ctx);
|
|
57
|
+
if (plane.onPlane)
|
|
58
|
+
return undefined;
|
|
59
|
+
return plane.stop !== undefined
|
|
60
|
+
? { words: wrunOpraPlaneStopDetail(plane.stop), stop: plane.stop }
|
|
61
|
+
: { words: wrunRowLaneUnadmittedReason(lane) };
|
|
62
|
+
}
|
|
63
|
+
return indexMode ? { words: wrunRowLaneUnadmittedReason(lane) } : undefined;
|
|
64
|
+
}
|
|
49
65
|
/**
|
|
50
66
|
* The run's plan against the chart, before any fetch, every input of a row-lane class in declaration order (the
|
|
51
67
|
* first refusal by name wins):
|
|
52
68
|
* 0. an input the market leaves undemanded (its `needed_by` leaves the market out, wrunSheetWithLaneDemand) is planned
|
|
53
69
|
* nowhere: no wall, no admission, no acquisition, no note; the row builder reads its empty block on every bar;
|
|
54
70
|
* 1. the OPRA wall: an input of a `governed: 'opra'` lane is refused for a run that may not read OPRA
|
|
55
|
-
* (`opra-official-only:<class>`, `mayReadOpra` over `run`; absent reads closed)
|
|
71
|
+
* (`opra-official-only:<class>`, `mayReadOpra` over `run`; absent reads closed), and so is an input of a chain lane
|
|
72
|
+
* on a chart whose options list on OPRA (riding the plane or stopped off it), before its chain is resolved;
|
|
56
73
|
* 2. the admission: a governed OPRA lane is served where the chart's options ride the OPRA plane
|
|
57
|
-
* (`isOpraPlaneExchange`) and nowhere else; a chain lane on every chart
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* the
|
|
63
|
-
*
|
|
64
|
-
* acquisition rule judged as anywhere, and then no instance (every input reads its empty block);
|
|
74
|
+
* (`isOpraPlaneExchange`) and nowhere else; a chain lane on every chart no known stop keeps its options off the
|
|
75
|
+
* plane on (`wrunChainLaneStop`, the chain poll lanes' one rule: no chain is resolved past the stop); any other lane
|
|
76
|
+
* wherever the chart is not index-mode. An input the chart does not serve meets the one rule both planners keep
|
|
77
|
+
* (wrun-poll-lanes.util `wrunUnservedLaneInput`): declaring `missing: "empty"` it is dropped (its blocks read EMPTY,
|
|
78
|
+
* a note names the feed), any other refuses by name, seeded feed-missing (paused); a lane off the plane for a known
|
|
79
|
+
* reason (`opraPlaneStop`: the `opra` flag dark, an index chart) says that reason instead (`options-stopped`, the
|
|
80
|
+
* note and the refusal alike);
|
|
65
81
|
* 3. the lane's identity, once per lane (the first admitted input's context names a refusal), then the input's
|
|
66
82
|
* facets (awaited, in declaration order); the instance is the identity and the facets together. A lane with
|
|
67
|
-
* `acquisitions: 'one'` refuses a second input whose acquisition differs (one fetch, one live fold per package).
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
83
|
+
* `acquisitions: 'one'` refuses a second input whose acquisition differs (one fetch, one live fold per package). A
|
|
84
|
+
* chart with no option chain (an identity or facets refusal seeded `no-options` / `chain`, `wrunLaneNoChainRefusal`:
|
|
85
|
+
* a LINK perp, a forex pair) does not serve the feed either: the same one rule, its note naming the feed with the
|
|
86
|
+
* chain decision's words, its refusal the decision's own. A chain lane's instance then meets its own plane's wall
|
|
87
|
+
* (`assertWrunLaneChainPlaneReadable`, the one rule a chain poll lane meets too): OPRA's, or the CME display wall
|
|
88
|
+
* (OpenMarket's own packages only); a plain chain (a crypto venue) none.
|
|
71
89
|
*/
|
|
72
90
|
export async function planWrunRowLanes(metadata, chart, run) {
|
|
73
91
|
const instances = new Map();
|
|
@@ -76,9 +94,8 @@ export async function planWrunRowLanes(metadata, chart, run) {
|
|
|
76
94
|
const firstOf = new Map();
|
|
77
95
|
const indexMode = chart.isIndexModeExchange?.(chart.exchange) === true;
|
|
78
96
|
const cryptoVenue = chart.isCryptoVenueExchange?.(chart.exchange);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const opraStop = opraPlane ? undefined : chart.opraPlaneStop?.(chart.exchange);
|
|
97
|
+
// The chart's OPRA plane facts, read once, as the poll lanes' planner reads them (`wrunChartOpraPlane`).
|
|
98
|
+
const plane = wrunChartOpraPlane(chart.exchange, chart);
|
|
82
99
|
for (const planned of planWrunRowLaneInputs(metadata)) {
|
|
83
100
|
if (planned.source.undemanded === true)
|
|
84
101
|
continue;
|
|
@@ -96,55 +113,42 @@ export async function planWrunRowLanes(metadata, chart, run) {
|
|
|
96
113
|
official: run?.official === true,
|
|
97
114
|
opraUserScripts: run?.opraUserScripts === true,
|
|
98
115
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
...(stop !== undefined ? { stop } : {}),
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
entry.inputNames.push(planned.inputName);
|
|
126
|
-
entry.details = `${entry.details}\n${details}`;
|
|
127
|
-
}
|
|
128
|
-
continue;
|
|
116
|
+
const unserved = {
|
|
117
|
+
inputName: planned.inputName,
|
|
118
|
+
sourceClass: lane.sourceClass,
|
|
119
|
+
feed: lane.laneKey,
|
|
120
|
+
missing: planned.source.missing,
|
|
121
|
+
};
|
|
122
|
+
// A chain lane meets the OPRA wall where the chart's options list on OPRA, and stops before its chain is resolved
|
|
123
|
+
// where a known stop keeps them off the plane (`wrunChainLaneStop`, the chain poll lanes' one rule). Any other lane
|
|
124
|
+
// is admitted by its plane or the chart's mode.
|
|
125
|
+
const why = lane.chain !== undefined
|
|
126
|
+
? wrunChainLaneStop(plane, run, ctx)
|
|
127
|
+
: wrunRowLaneUnserved(lane, plane, indexMode, run, ctx);
|
|
128
|
+
if (why !== undefined) {
|
|
129
|
+
wrunUnservedLaneInput(missing, unserved, WRUN_ROW_LANE_UNSERVED_FILLS, why, cryptoVenue);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
let extras;
|
|
133
|
+
try {
|
|
134
|
+
let identity = identities.get(lane.laneKey);
|
|
135
|
+
if (identity === undefined) {
|
|
136
|
+
identity = definedFields(await lane.identity?.(ctx));
|
|
137
|
+
identities.set(lane.laneKey, identity);
|
|
129
138
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
extras = { ...identity, ...definedFields(await lane.facets?.(planned.source, ctx)) };
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
// A chart with no option chain does not serve the feed (`wrunLaneNoChainRefusal`): the same one rule.
|
|
143
|
+
if (!wrunLaneNoChainRefusal(error))
|
|
144
|
+
throw error;
|
|
145
|
+
wrunUnservedLaneInput(missing, unserved, WRUN_ROW_LANE_UNSERVED_FILLS, { noChain: error }, cryptoVenue);
|
|
146
|
+
continue;
|
|
138
147
|
}
|
|
139
|
-
|
|
140
|
-
if (
|
|
141
|
-
|
|
142
|
-
identities.set(lane.laneKey, identity);
|
|
148
|
+
// A chain instance meets its own plane's wall, by the exchange its chain lists on (the poll lanes' one rule).
|
|
149
|
+
if (lane.chain !== undefined) {
|
|
150
|
+
assertWrunLaneChainPlaneReadable(wrunRowLaneChainPlane(lane, extras), wrunRowLaneChainExchange(lane, extras), run, ctx);
|
|
143
151
|
}
|
|
144
|
-
const extras = { ...identity, ...definedFields(await lane.facets?.(planned.source, ctx)) };
|
|
145
|
-
// A chain instance meets its own plane's wall, by the exchange its chain lists on.
|
|
146
|
-
if (chainLane)
|
|
147
|
-
assertWrunRowChainPlaneReadable(lane, extras, run, ctx);
|
|
148
152
|
const key = wrunRowLaneInstanceKey(lane.laneKey, extras);
|
|
149
153
|
const first = firstOf.get(lane.laneKey);
|
|
150
154
|
if (lane.acquisitions === 'one' && first !== undefined && first.key !== key) {
|
|
@@ -153,9 +157,6 @@ export async function planWrunRowLanes(metadata, chart, run) {
|
|
|
153
157
|
}
|
|
154
158
|
if (first === undefined)
|
|
155
159
|
firstOf.set(lane.laneKey, { key, inputName: planned.inputName });
|
|
156
|
-
// Off its plane such a lane plans no instance: the row builder reads the input's empty block on every bar.
|
|
157
|
-
if (emptyOffPlane)
|
|
158
|
-
continue;
|
|
159
160
|
let instance = instances.get(key);
|
|
160
161
|
if (instance === undefined) {
|
|
161
162
|
instance = { key, sourceClass: lane.sourceClass, laneKey: lane.laneKey, extras, inputIndexes: [] };
|
|
@@ -172,30 +173,15 @@ function definedFields(fields) {
|
|
|
172
173
|
out[key] = value;
|
|
173
174
|
return out;
|
|
174
175
|
}
|
|
175
|
-
/** The record seed of the CME display wall on a chain lane's CME instance (the display wall's own record). */
|
|
176
|
-
const WRUN_CME_WALL_SEED = Object.freeze({ cls: 'cme-wall' });
|
|
177
|
-
/** A chain instance against its own plane's wall (`planWrunRowLanes` step 3): an OPRA chain the OPRA wall
|
|
178
|
-
* (`mayReadOpra`), a CME chain the CME display wall (OpenMarket's own packages only, the run door's rule on a CME
|
|
179
|
-
* chart, kscript-venue-policy.util; the `opra-user-scripts` flag never opens it), a plain chain none. */
|
|
180
|
-
function assertWrunRowChainPlaneReadable(lane, extras, run, ctx) {
|
|
181
|
-
const plane = wrunRowLaneChainPlane(lane, extras);
|
|
182
|
-
if (plane === 'opra')
|
|
183
|
-
assertWrunOpraLaneReadable(run, ctx);
|
|
184
|
-
if (plane === 'cme' && run?.official !== true) {
|
|
185
|
-
refuseWrunPollInput(ctx, `reads CME options data (${wrunRowLaneChainExchange(lane, extras)}), which is open to OpenMarket's own ` +
|
|
186
|
-
'Indicators only: a package you wrote or added from the community cannot read it yet', WRUN_CME_WALL_SEED);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
176
|
/** The exchange a chain-lane instance's chain lists on (the payload field its `chain` names); '' for any other lane
|
|
190
|
-
* or a payload naming none. */
|
|
177
|
+
* or a payload naming none. The chain poll lanes' one rule (`wrunPollLaneChainExchange`: the mark is the same). */
|
|
191
178
|
export function wrunRowLaneChainExchange(lane, extras) {
|
|
192
|
-
|
|
193
|
-
return typeof exchange === 'string' ? exchange : '';
|
|
179
|
+
return wrunPollLaneChainExchange(lane, extras);
|
|
194
180
|
}
|
|
195
|
-
/** The plane a chain-lane instance reads, by its chain's exchange (`
|
|
196
|
-
* lane (its plane, if any, is its descriptor's `governed`). */
|
|
181
|
+
/** The plane a chain-lane instance reads, by its chain's exchange (`wrunPollLaneChainPlane`, the chain poll lanes' one
|
|
182
|
+
* rule over `wrunLaneChainPlaneOf`); undefined for any other lane (its plane, if any, is its descriptor's `governed`). */
|
|
197
183
|
export function wrunRowLaneChainPlane(lane, extras) {
|
|
198
|
-
return
|
|
184
|
+
return wrunPollLaneChainPlane(lane, extras);
|
|
199
185
|
}
|
|
200
186
|
/** Whether one row-lane instance reads the OPRA plane (the provenance stamp follows it): every instance of a governed
|
|
201
187
|
* lane, a chain lane's whose chain lists on OPRA. */
|
|
@@ -204,10 +190,9 @@ export function wrunRowLaneInstanceReadsOpra(lane, extras) {
|
|
|
204
190
|
}
|
|
205
191
|
/** The governed exchange a chain-lane instance reads beside its chart's own market (the exchange its served access,
|
|
206
192
|
* and so its delayed window, is read under): its chain's when a gate governs it (OPRA, a CME Group exchange); null
|
|
207
|
-
* for a plain chain and for any other lane. */
|
|
193
|
+
* for a plain chain and for any other lane. The chain poll lanes' one rule (`wrunPollLaneChainGovernedExchange`). */
|
|
208
194
|
export function wrunRowLaneChainGovernedExchange(lane, extras) {
|
|
209
|
-
|
|
210
|
-
return plane === 'opra' || plane === 'cme' ? wrunRowLaneChainExchange(lane, extras) : null;
|
|
195
|
+
return wrunPollLaneChainGovernedExchange(lane, extras);
|
|
211
196
|
}
|
|
212
197
|
/** The first row-lane instance of a session whose acquisition moved since the run planned it (its lane's
|
|
213
198
|
* `acquisitionMoved` over the run's record of it, else over the instance's payload), or undefined: the live tick
|
|
@@ -222,19 +207,15 @@ export function wrunRowLaneMovedInstance(instances, acquisition) {
|
|
|
222
207
|
}
|
|
223
208
|
/**
|
|
224
209
|
* A chain instance's ask (the full run's and the reconcile's, re-read on every ask): its payload with the fields its
|
|
225
|
-
* plane names beside it
|
|
226
|
-
* it an OPRA ask, the legend names a delayed tier); a CME chain its routed tier alone
|
|
227
|
-
* serves one tier's rows to the other; the chart's own badge names the delay); a
|
|
228
|
-
* Any other lane's payload as it is. `tierOf` is the routing's rule
|
|
229
|
-
* handed in so this module stays off the routing graph, and asked only
|
|
230
|
-
* for any exchange no gate governs.
|
|
210
|
+
* plane names beside it, by the chain poll lanes' one rule (`wrunPollLaneChainAsk`): an OPRA chain names the plane and
|
|
211
|
+
* its routed tier (Door C judges it an OPRA ask, the legend names a delayed tier); a CME chain its routed tier alone
|
|
212
|
+
* (`servedTier`, so no source cache serves one tier's rows to the other; the chart's own badge names the delay); a
|
|
213
|
+
* plain chain (a crypto venue) nothing. Any other lane's payload as it is. `tierOf` is the routing's rule
|
|
214
|
+
* (governed-route.util `governedMarketDataTier`), handed in so this module stays off the routing graph, and asked only
|
|
215
|
+
* for a governed exchange: it answers delayed for any exchange no gate governs.
|
|
231
216
|
*/
|
|
232
217
|
export function wrunRowLaneChainAsk(lane, extras, tierOf) {
|
|
233
|
-
|
|
234
|
-
if (plane !== 'opra' && plane !== 'cme')
|
|
235
|
-
return extras;
|
|
236
|
-
const servedTier = tierOf(wrunRowLaneChainExchange(lane, extras));
|
|
237
|
-
return plane === 'opra' ? { ...extras, ...wrunOpraLanePayloadFields(servedTier) } : { ...extras, servedTier };
|
|
218
|
+
return wrunPollLaneChainAsk(lane, extras, tierOf);
|
|
238
219
|
}
|
|
239
220
|
/** How an empty answer reads for a lane: quiet (present EMPTY blocks) or degrading (a state lane's). */
|
|
240
221
|
export function wrunRowLaneEmptyAnswer(lane) {
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
3
|
-
* threads read them: the field list and its order (the lane row's columns after
|
|
4
|
-
* on OPTION_UNDERLYING_STATS (kiyotaka-go `OptionUnderlyingStats`, protobuf-es
|
|
5
|
-
* refusal. The lane files (main thread), the K
|
|
2
|
+
* The underlying options statistics classes (UW-PARITY sources S5a `option_daily` and S5b `option_stats_10m`, on every
|
|
3
|
+
* chain since OPTIONS-PORT P5) as both threads read them: the field list and its order (the lane row's columns after
|
|
4
|
+
* the stamp), each field's point field on OPTION_UNDERLYING_STATS (kiyotaka-go `OptionUnderlyingStats`, protobuf-es
|
|
5
|
+
* names), the K types, the acquisition's chain fields and the named refusal. The lane files (main thread), the K
|
|
6
|
+
* control and its worker twin read this one table.
|
|
6
7
|
*
|
|
7
|
-
* The rows (tsdb-gateway `option_underlying_stats.go
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* says it is not sampled).
|
|
8
|
+
* The rows (tsdb-gateway `option_underlying_stats.go`, the option-underlying-stats cjob): one book per bucket, a
|
|
9
|
+
* row's symbol its book, filed by the chain's exchange and underlying (the OPRA ticker, the CME futures contract, a
|
|
10
|
+
* crypto venue's root coin), at DAY (a session date stamped at its UTC midnight: OPRA's New York session written
|
|
11
|
+
* after the close, a crypto venue's UTC day, a CME settlement) or TEN_MINUTES (for the underlyings the plane samples:
|
|
12
|
+
* any other answers no row, which is how the data plane says it is not sampled). A one-book read names the exchange,
|
|
13
|
+
* the underlying and the book; an OPRA read names no book, as it always has (contract C1).
|
|
14
|
+
*
|
|
15
|
+
* Units (contract C3): volatilities in percentage points, exposures in USD, walls and levels as prices; volume and
|
|
16
|
+
* open interest in coin on a crypto chain and in contracts on OPRA and CME; premium in USD, and no value on a crypto
|
|
17
|
+
* or CME chain until their print rows exist (the row leaves it unset, which reads as no value).
|
|
12
18
|
*
|
|
13
19
|
* Import-free: a lane file stays light at module load and the worker twin reads it too.
|
|
14
20
|
*/
|
|
15
21
|
/** The fields, in the kit's order (om `WRUN_OPTION_STATS_FIELDS`); field i is lane row column i + 1. `coin` is the
|
|
16
|
-
* underlying as a symbol code (`encodeSymbol`), the rest the row's own values. */
|
|
22
|
+
* chain's underlying as a symbol code (`encodeSymbol`), the rest the row's own values. */
|
|
17
23
|
export declare const WRUN_OPTION_STATS_FIELDS: readonly ["coin", "underlying_price", "atm_iv_1d", "atm_iv_5d", "atm_iv_7d", "atm_iv_14d", "atm_iv_30d", "atm_iv_60d", "atm_iv_90d", "atm_iv_180d", "atm_iv_365d", "rr25_30d", "call_volume", "put_volume", "call_premium", "put_premium", "call_oi", "put_oi", "net_gex", "net_dex", "net_vex", "net_charm", "net_vanna", "front_net_gex", "call_wall", "put_wall", "gamma_flip", "gamma_magnet", "max_pain_front", "implied_move_front", "n_contracts"];
|
|
18
24
|
export type WrunOptionStatsField = (typeof WRUN_OPTION_STATS_FIELDS)[number];
|
|
19
25
|
/** Each value field's point field (the series module's decoded column); `coin` is the read's own underlying. */
|
|
@@ -28,3 +34,16 @@ export declare const WRUN_OPTION_STATS_KTYPES: Readonly<Record<WrunOptionStatsGr
|
|
|
28
34
|
export declare const WRUN_OPTION_STATS_INTERVALS: Readonly<Record<WrunOptionStatsGrain, string>>;
|
|
29
35
|
/** The named refusal of an underlying the data plane samples no ten-minute rows for (U7's configured list). */
|
|
30
36
|
export declare const WRUN_NOT_IN_10M_UNIVERSE_CODE = "not-in-10m-universe";
|
|
37
|
+
/**
|
|
38
|
+
* The fields a stats acquisition names its chain in (the lane's plan, the K control's settings), beside `coin` (the
|
|
39
|
+
* chain's underlying, the key its plane files the rows under):
|
|
40
|
+
* - `statsExchange`: the exchange the chain lists on, on every plane (the instance's plane follows it, and the read
|
|
41
|
+
* names it as its venue);
|
|
42
|
+
* - `statsBook`: the ONE book a one-book read names (the row symbol), on every plane but OPRA, whose read stays by
|
|
43
|
+
* coin with no symbol (contract C1);
|
|
44
|
+
* - `statsContinuous`: the continuous alias a CME chain was read off (its lead contract is `coin`; a roll moves the
|
|
45
|
+
* acquisition).
|
|
46
|
+
*/
|
|
47
|
+
export declare const WRUN_OPTION_STATS_EXCHANGE_FIELD = "statsExchange";
|
|
48
|
+
export declare const WRUN_OPTION_STATS_BOOK_FIELD = "statsBook";
|
|
49
|
+
export declare const WRUN_OPTION_STATS_CONTINUOUS_FIELD = "statsContinuous";
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
3
|
-
* threads read them: the field list and its order (the lane row's columns after
|
|
4
|
-
* on OPTION_UNDERLYING_STATS (kiyotaka-go `OptionUnderlyingStats`, protobuf-es
|
|
5
|
-
* refusal. The lane files (main thread), the K
|
|
2
|
+
* The underlying options statistics classes (UW-PARITY sources S5a `option_daily` and S5b `option_stats_10m`, on every
|
|
3
|
+
* chain since OPTIONS-PORT P5) as both threads read them: the field list and its order (the lane row's columns after
|
|
4
|
+
* the stamp), each field's point field on OPTION_UNDERLYING_STATS (kiyotaka-go `OptionUnderlyingStats`, protobuf-es
|
|
5
|
+
* names), the K types, the acquisition's chain fields and the named refusal. The lane files (main thread), the K
|
|
6
|
+
* control and its worker twin read this one table.
|
|
6
7
|
*
|
|
7
|
-
* The rows (tsdb-gateway `option_underlying_stats.go
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* says it is not sampled).
|
|
8
|
+
* The rows (tsdb-gateway `option_underlying_stats.go`, the option-underlying-stats cjob): one book per bucket, a
|
|
9
|
+
* row's symbol its book, filed by the chain's exchange and underlying (the OPRA ticker, the CME futures contract, a
|
|
10
|
+
* crypto venue's root coin), at DAY (a session date stamped at its UTC midnight: OPRA's New York session written
|
|
11
|
+
* after the close, a crypto venue's UTC day, a CME settlement) or TEN_MINUTES (for the underlyings the plane samples:
|
|
12
|
+
* any other answers no row, which is how the data plane says it is not sampled). A one-book read names the exchange,
|
|
13
|
+
* the underlying and the book; an OPRA read names no book, as it always has (contract C1).
|
|
14
|
+
*
|
|
15
|
+
* Units (contract C3): volatilities in percentage points, exposures in USD, walls and levels as prices; volume and
|
|
16
|
+
* open interest in coin on a crypto chain and in contracts on OPRA and CME; premium in USD, and no value on a crypto
|
|
17
|
+
* or CME chain until their print rows exist (the row leaves it unset, which reads as no value).
|
|
12
18
|
*
|
|
13
19
|
* Import-free: a lane file stays light at module load and the worker twin reads it too.
|
|
14
20
|
*/
|
|
15
21
|
/** The fields, in the kit's order (om `WRUN_OPTION_STATS_FIELDS`); field i is lane row column i + 1. `coin` is the
|
|
16
|
-
* underlying as a symbol code (`encodeSymbol`), the rest the row's own values. */
|
|
22
|
+
* chain's underlying as a symbol code (`encodeSymbol`), the rest the row's own values. */
|
|
17
23
|
export const WRUN_OPTION_STATS_FIELDS = Object.freeze([
|
|
18
24
|
'coin',
|
|
19
25
|
'underlying_price',
|
|
@@ -94,3 +100,16 @@ export const WRUN_OPTION_STATS_INTERVALS = Object.freeze({
|
|
|
94
100
|
});
|
|
95
101
|
/** The named refusal of an underlying the data plane samples no ten-minute rows for (U7's configured list). */
|
|
96
102
|
export const WRUN_NOT_IN_10M_UNIVERSE_CODE = 'not-in-10m-universe';
|
|
103
|
+
/**
|
|
104
|
+
* The fields a stats acquisition names its chain in (the lane's plan, the K control's settings), beside `coin` (the
|
|
105
|
+
* chain's underlying, the key its plane files the rows under):
|
|
106
|
+
* - `statsExchange`: the exchange the chain lists on, on every plane (the instance's plane follows it, and the read
|
|
107
|
+
* names it as its venue);
|
|
108
|
+
* - `statsBook`: the ONE book a one-book read names (the row symbol), on every plane but OPRA, whose read stays by
|
|
109
|
+
* coin with no symbol (contract C1);
|
|
110
|
+
* - `statsContinuous`: the continuous alias a CME chain was read off (its lead contract is `coin`; a roll moves the
|
|
111
|
+
* acquisition).
|
|
112
|
+
*/
|
|
113
|
+
export const WRUN_OPTION_STATS_EXCHANGE_FIELD = 'statsExchange';
|
|
114
|
+
export const WRUN_OPTION_STATS_BOOK_FIELD = 'statsBook';
|
|
115
|
+
export const WRUN_OPTION_STATS_CONTINUOUS_FIELD = 'statsContinuous';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WrunChildOverlayChart } from './wrun-panel-mount.util.js';
|
|
2
|
+
export type WrunPanelMountRuntime = Pick<typeof import('./wrun-panel-mount.util.js'), 'retranslateWrunChildOverlays'> & Partial<Pick<typeof import('./wrun-panel-mount.util.js'), 'cutWrunBatchedChildRecords'>>;
|
|
3
|
+
/** Hand the child mount over: it calls this as it evaluates. */
|
|
4
|
+
export declare function bindWrunPanelMountRuntime(loaded: WrunPanelMountRuntime): void;
|
|
5
|
+
/** `retranslateWrunChildOverlays` (the child mount): nothing to do without a child on the chart. */
|
|
6
|
+
export declare function retranslateWrunChildOverlays(tc: WrunChildOverlayChart): void;
|
|
7
|
+
/** `cutWrunBatchedChildRecords` (the child mount): the replay cut of a batched child's mount record. A
|
|
8
|
+
* child mount not bound yet holds no record (it owns them and binds as it evaluates), so the cut has
|
|
9
|
+
* nothing to cut and no import is made. */
|
|
10
|
+
export declare function cutWrunBatchedChildRecords(tc: WrunChildOverlayChart, overlayId: string, fromTs: number, toTs: number): string[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The boot graph's side of the wrun child mount (`wrun-panel-mount.util`): the timezone sync
|
|
3
|
+
* (timezone-sync.util) retranslates every chart's mounted wrun children through here, so the child
|
|
4
|
+
* mount, the panel translator and the run-result adapter behind it stay out of the pre-candle
|
|
5
|
+
* closure (docs/features/kscript/wrun/wrun-browser-runtime.md, "Boot doors").
|
|
6
|
+
*
|
|
7
|
+
* The door's contract:
|
|
8
|
+
* - The child mount in hand: the call goes straight to it in the caller's turn. The child mount
|
|
9
|
+
* binds itself as it evaluates (`bindWrunPanelMountRuntime`): it owns the map of mounted
|
|
10
|
+
* children, so a chart can hold none before it evaluates, and every lane that mounts one (the
|
|
11
|
+
* loaders' run pass, the hosted lanes) evaluates it first.
|
|
12
|
+
* - Not mine: no child overlay id (`<parent>::<kind>:<name>`, wrun-child-overlay-id.util) on the
|
|
13
|
+
* chart's metadata, no import. A flag-off session and every kScript chart stay here.
|
|
14
|
+
* - A child id before the child mount (a registrant that skipped it): the child mount loads once
|
|
15
|
+
* and the retranslate runs once when it lands, never rejecting; the children relabel then.
|
|
16
|
+
* Ring `wrun-panel-mount-late`.
|
|
17
|
+
*/
|
|
18
|
+
import { wrunChartHostEnv } from '../../host-env.js';
|
|
19
|
+
import { wrunChildOverlayParentId } from './wrun-child-overlay-id.util.js';
|
|
20
|
+
let runtime;
|
|
21
|
+
let loading;
|
|
22
|
+
/** Hand the child mount over: it calls this as it evaluates. */
|
|
23
|
+
export function bindWrunPanelMountRuntime(loaded) {
|
|
24
|
+
runtime = loaded;
|
|
25
|
+
}
|
|
26
|
+
function loadWrunPanelMountRuntime() {
|
|
27
|
+
if (runtime)
|
|
28
|
+
return Promise.resolve(runtime);
|
|
29
|
+
// The mount's host ports load beside it (chart.loadPanelMountPorts): its retranslate reads them.
|
|
30
|
+
loading ??= Promise.all([import('./wrun-panel-mount.util.js'), wrunChartHostEnv().chart.loadPanelMountPorts()]).then(([loaded]) => {
|
|
31
|
+
runtime ??= loaded;
|
|
32
|
+
return runtime;
|
|
33
|
+
}, (error) => {
|
|
34
|
+
loading = undefined;
|
|
35
|
+
throw error;
|
|
36
|
+
});
|
|
37
|
+
return loading;
|
|
38
|
+
}
|
|
39
|
+
/** True when the chart's metadata holds a wrun child overlay. */
|
|
40
|
+
function chartHoldsWrunChild(tc) {
|
|
41
|
+
const metadata = tc?.metadata;
|
|
42
|
+
if (!Array.isArray(metadata))
|
|
43
|
+
return false;
|
|
44
|
+
return metadata.some((meta) => typeof meta?.id === 'string' && wrunChildOverlayParentId(meta.id) !== null);
|
|
45
|
+
}
|
|
46
|
+
/** `retranslateWrunChildOverlays` (the child mount): nothing to do without a child on the chart. */
|
|
47
|
+
export function retranslateWrunChildOverlays(tc) {
|
|
48
|
+
if (runtime) {
|
|
49
|
+
runtime.retranslateWrunChildOverlays(tc);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (!chartHoldsWrunChild(tc))
|
|
53
|
+
return;
|
|
54
|
+
if (wrunChartHostEnv().diagnostics.debugEnabled()) {
|
|
55
|
+
wrunChartHostEnv().diagnostics.debug('wrun-panel-mount-late', { entry: 'retranslate' });
|
|
56
|
+
}
|
|
57
|
+
void loadWrunPanelMountRuntime()
|
|
58
|
+
.then((loaded) => loaded.retranslateWrunChildOverlays(tc))
|
|
59
|
+
.catch((error) => {
|
|
60
|
+
console.warn("[wrun] child mount unavailable for 'retranslate':", error);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** `cutWrunBatchedChildRecords` (the child mount): the replay cut of a batched child's mount record. A
|
|
64
|
+
* child mount not bound yet holds no record (it owns them and binds as it evaluates), so the cut has
|
|
65
|
+
* nothing to cut and no import is made. */
|
|
66
|
+
export function cutWrunBatchedChildRecords(tc, overlayId, fromTs, toTs) {
|
|
67
|
+
return runtime?.cutWrunBatchedChildRecords?.(tc, overlayId, fromTs, toTs) ?? [];
|
|
68
|
+
}
|