@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.
Files changed (50) hide show
  1. package/README.md +11 -5
  2. package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +133 -0
  3. package/dist/constants/scriptEditor/builtin-script-snippets.js +451 -0
  4. package/dist/host-env.d.ts +8 -6
  5. package/dist/host-ports.types.d.ts +7 -22
  6. package/dist/index.d.ts +10 -0
  7. package/dist/index.js +10 -0
  8. package/dist/utility/chart/date-labelled-interval.leaf.d.ts +15 -0
  9. package/dist/utility/chart/date-labelled-interval.leaf.js +19 -0
  10. package/dist/utility/chart/indicator-run-interval.util.d.ts +130 -0
  11. package/dist/utility/chart/indicator-run-interval.util.js +268 -0
  12. package/dist/utility/chart/window-geometry.leaf.d.ts +119 -0
  13. package/dist/utility/chart/window-geometry.leaf.js +391 -0
  14. package/dist/utility/chart/window-owner.leaf.d.ts +19 -0
  15. package/dist/utility/chart/window-owner.leaf.js +24 -0
  16. package/dist/utility/html-escape.leaf.d.ts +11 -0
  17. package/dist/utility/html-escape.leaf.js +20 -0
  18. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +43 -15
  19. package/dist/utility/wrun/sources/lanes/option_daily.js +78 -20
  20. package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +14 -10
  21. package/dist/utility/wrun/sources/lanes/option_stats_10m.js +5 -4
  22. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +22 -3
  23. package/dist/utility/wrun/sources/opra-option-lanes.util.js +38 -7
  24. package/dist/utility/wrun/sources/registry.js +31 -1
  25. package/dist/utility/wrun/sources/row-lane-registry.js +5 -5
  26. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +49 -0
  27. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +74 -18
  28. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +49 -0
  29. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +57 -47
  30. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +36 -4
  31. package/dist/utility/wrun/sources/row-lanes/option_surface.js +6 -12
  32. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +37 -3
  33. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +128 -2
  34. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +233 -51
  35. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +0 -8
  36. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +26 -24
  37. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +85 -104
  38. package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +29 -10
  39. package/dist/utility/wrun/wrun-opra-stats.leaf.js +29 -10
  40. package/dist/utility/wrun/wrun-panel-mount.lazy.d.ts +10 -0
  41. package/dist/utility/wrun/wrun-panel-mount.lazy.js +68 -0
  42. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +377 -0
  43. package/dist/utility/wrun/wrun-panel-mount.util.js +2251 -0
  44. package/dist/utility/wrun/wrun-pause-dim.util.d.ts +52 -0
  45. package/dist/utility/wrun/wrun-pause-dim.util.js +153 -0
  46. package/dist/utility/wrun/wrun-plot-gate.types.d.ts +23 -0
  47. package/dist/utility/wrun/wrun-plot-gate.types.js +7 -0
  48. package/dist/utility/wrun/wrun-run-interval-projection.types.d.ts +14 -0
  49. package/dist/utility/wrun/wrun-run-interval-projection.types.js +1 -0
  50. 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 { refuseWrunPollInput } from './wrun-poll-lane.types.js';
4
- import { WRUN_ROW_LANE_ID_PREFIX, wrunLaneChainPlaneOf, } from './wrun-row-lane.types.js';
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 (its identity or facets refuse a chart
58
- * with no chain by name); any other lane wherever the chart is not index-mode. On a chart
59
- * that does not serve it an input declaring `missing: "empty"` is dropped (its blocks read EMPTY, a note names
60
- * the feed) and any other refuses by name, seeded feed-missing (paused); a governed lane off the plane for a known
61
- * reason (`opraPlaneStop`: the `opra` flag dark, an index chart) says that reason instead (`options-stopped`,
62
- * the note and the refusal alike). A governed lane declaring
63
- * `offPlane: 'empty'` is the exception off its plane: no wall, no refusal and no note, its identity, facets and
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
- * A chain lane's instance then meets its own plane's wall (`wrunRowLaneChainPlane`): the OPRA wall (met before the
69
- * chain is resolved on a chart whose options ride the OPRA plane), or the CME display wall (OpenMarket's own
70
- * packages only); a plain chain (a crypto venue) none.
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
- const opraPlane = chart.isOpraPlaneExchange?.(chart.exchange) === true;
80
- // Off the plane, the known reason the chart is off it (the flag, the router), read once.
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
- // A governed lane that reads empty off its plane (`offPlane`) meets no wall there: nothing it reads is OPRA's.
100
- const emptyOffPlane = lane.governed === 'opra' && lane.offPlane === 'empty' && !opraPlane;
101
- // A chain lane meets the OPRA wall before its chain is resolved where the chart's options ride the OPRA plane
102
- // (every chain it reads there is OPRA's), and is admitted on every chart.
103
- const chainLane = lane.chain !== undefined;
104
- if ((lane.governed === 'opra' && !emptyOffPlane) || (chainLane && opraPlane))
105
- assertWrunOpraLaneReadable(run, ctx);
106
- const admitted = chainLane || emptyOffPlane || (lane.governed === 'opra' ? opraPlane : !indexMode);
107
- if (!admitted) {
108
- // A governed lane on a chart whose options DO list on OPRA is off the plane for a known reason (the flag, the
109
- // router): the note and the refusal say that reason, never "this market has no such feed".
110
- const stop = lane.governed === 'opra' ? opraStop : undefined;
111
- const reason = stop !== undefined ? wrunOpraPlaneStopDetail(stop) : wrunRowLaneUnadmittedReason(lane);
112
- if (planned.source.missing === 'empty') {
113
- const details = `Input '${ctx.inputName}' (${ctx.sourceClass}) ${reason}; it declares missing: "empty", so it reads an empty block on every bar`;
114
- const entry = missing.get(lane.laneKey);
115
- if (entry === undefined) {
116
- missing.set(lane.laneKey, {
117
- inputNames: [planned.inputName],
118
- feed: lane.laneKey,
119
- variant: cryptoVenue === false ? 'crypto-only' : 'market',
120
- details,
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
- refuseWrunPollInput(ctx, reason, stop !== undefined
131
- ? wrunOptionsStopSeed(stop, { severity: 'paused' })
132
- : {
133
- cls: 'feed-missing',
134
- variant: cryptoVenue === false ? 'crypto-only' : 'market-paused',
135
- params: { feed: lane.laneKey },
136
- severity: 'paused',
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
- let identity = identities.get(lane.laneKey);
140
- if (identity === undefined) {
141
- identity = definedFields(await lane.identity?.(ctx));
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
- const exchange = lane.chain === undefined ? undefined : extras[lane.chain.exchangeField];
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 (`wrunLaneChainPlaneOf`); undefined for any other
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 lane.chain === undefined ? undefined : wrunLaneChainPlaneOf(wrunRowLaneChainExchange(lane, extras));
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
- const plane = wrunRowLaneChainPlane(lane, extras);
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. An OPRA chain names the plane and its routed tier (`wrunOpraLanePayloadFields`: Door C judges
226
- * it an OPRA ask, the legend names a delayed tier); a CME chain its routed tier alone (`servedTier`, so no source cache
227
- * serves one tier's rows to the other; the chart's own badge names the delay); a plain chain (a crypto venue) nothing.
228
- * Any other lane's payload as it is. `tierOf` is the routing's rule (governed-route.util `governedMarketDataTier`),
229
- * handed in so this module stays off the routing graph, and asked only for a governed exchange: it answers delayed
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
- const plane = wrunRowLaneChainPlane(lane, extras);
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 OPRA underlying statistics classes (UW-PARITY sources S5a `option_daily` and S5b `option_stats_10m`) as both
3
- * threads read them: the field list and its order (the lane row's columns after the stamp), each field's point field
4
- * on OPTION_UNDERLYING_STATS (kiyotaka-go `OptionUnderlyingStats`, protobuf-es names), the K types and the named
5
- * refusal. The lane files (main thread), the K control and its worker twin read this one table.
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` and the option-underlying-stats cjob, U7): one underlying per
8
- * bucket, read by coin with no symbol criterion, at DAY (a New York session date, stamped at that date's UTC
9
- * midnight, written after the close for every underlying with a chain) or TEN_MINUTES (every ten minutes of the
10
- * session, for the configured underlyings only: any other underlying answers no row, which is how the data plane
11
- * says it is not sampled). Volatilities in percentage points, exposures in USD, walls and levels as prices.
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 OPRA underlying statistics classes (UW-PARITY sources S5a `option_daily` and S5b `option_stats_10m`) as both
3
- * threads read them: the field list and its order (the lane row's columns after the stamp), each field's point field
4
- * on OPTION_UNDERLYING_STATS (kiyotaka-go `OptionUnderlyingStats`, protobuf-es names), the K types and the named
5
- * refusal. The lane files (main thread), the K control and its worker twin read this one table.
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` and the option-underlying-stats cjob, U7): one underlying per
8
- * bucket, read by coin with no symbol criterion, at DAY (a New York session date, stamped at that date's UTC
9
- * midnight, written after the close for every underlying with a chain) or TEN_MINUTES (every ten minutes of the
10
- * session, for the configured underlyings only: any other underlying answers no row, which is how the data plane
11
- * says it is not sampled). Volatilities in percentage points, exposures in USD, walls and levels as prices.
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
+ }