@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,36 +1,92 @@
1
1
  /**
2
- * The `option_daily` lane (UW-PARITY source S5a): the chart underlying's daily options statistics (US listed options,
3
- * OPRA) as 31 scalars, a daily join (`input("iv30", option_daily.atm_iv_30d, { missing: "nan" })`): the underlying as
2
+ * The `option_daily` lane (UW-PARITY source S5a, OPTIONS-PORT P5): the daily options statistics of the chart's options
3
+ * chain as 31 scalars, a daily join (`input("iv30", option_daily.atm_iv_30d, { missing: "nan" })`): the underlying as
4
4
  * a symbol code, its price, the at-the-money IV at nine tenors, the 30-day 25-delta risk reversal, call and put
5
5
  * volume, premium and open interest, the net exposures, the walls, the gamma flip and magnet, the front expiry's max
6
- * pain and implied move, and the contracts counted (wrun-opra-stats.leaf).
6
+ * pain and implied move, and the contracts counted (wrun-opra-stats.leaf, its units per plane).
7
7
  *
8
- * It reads OPTION_UNDERLYING_STATS DAY rows by coin through `K_OPTION_UNDERLYING_STATS_DAY` (om's fetch type
9
- * `option_underlying_stats_day`) and its worker twin. A DAY row is stamped at its New York session date's UTC
10
- * midnight and written after that session's close, so the daily `last` landing lands it on the first chart bar of
11
- * that UTC day and carries it across the day; the day before's row stands until the session's row is written
12
- * (`lookbackDays` 7 keeps it in the ask after a holiday weekend). Not `global`: it follows the chart's underlying,
13
- * read on the OPRA plane's native-rows path (`nativeRows` with a daily join), so the index-mode stock chart serves it.
8
+ * It reads OPTION_UNDERLYING_STATS DAY rows through `K_OPTION_UNDERLYING_STATS_DAY` (om's fetch type
9
+ * `option_underlying_stats_day`) and its worker twin. A DAY row is stamped at its session date's UTC midnight and
10
+ * written after that session closes, so the daily `last` landing lands it on the first chart bar of that UTC day and
11
+ * carries it across the day; the day before's row stands until the session's row is written (`lookbackDays` 7 keeps
12
+ * it in the ask after a holiday weekend).
13
+ *
14
+ * A CHAIN lane (`chain`): the chain is the one chain resolver's (opra-option-lanes.util `resolveWrunLaneChainChart`
15
+ * then `decideWrunLaneChain`, the decision `options_chain` and `option_surface` read), per input, and its plane is per
16
+ * instance: OPRA's rules on a US stock or OPRA contract chart, CME's on a CME futures chart (a continuous chart reads
17
+ * its lead contract, and a live session rebuilds once the lead rolls: `acquisitionMoved`), none on a crypto chain. On
18
+ * the OPRA plane (`ctx.opraPlane`, the planner's verdict) the chain is the plane's own by coin
19
+ * (`wrunLaneOpraPlaneChain`): the read goes by coin with no chain directory read, as it always went, so a stock listing
20
+ * no options or a directory that does not answer refuses nothing before the read. Each input reads ONE book, decided
21
+ * when the run plans (`auto`: the chain's default book) and named in the acquisition off OPRA. It rides the
22
+ * native-rows path on every plane (`nativeRows`), so the index-mode stock chart serves it too.
14
23
  *
15
24
  * Refused by name before any fetch: `opra-official-only:option_daily` for a package that may not read US options, a
16
- * chart that names no underlying, and `protocol-pending:OPTION_UNDERLYING_STATS` until the protocol release. An
17
- * underlying with no row in the window answers empty: the empty-answer rule speaks for it.
25
+ * chart that names no underlying, `protocol-pending:OPTION_UNDERLYING_STATS` until the protocol release, a chart whose
26
+ * options a known stop keeps off the OPRA plane (`options-stopped`), a chart with no option chain (the options chain's
27
+ * `no-chain`), the CME display wall for a package that is not OpenMarket's own and a venue or book outside its words.
28
+ * The planner drops an input that declared `missing: "nan"` or `"zero"` instead of the stop's and the no-chain refusal
29
+ * (a note names the feed). An underlying with no row in the window answers empty: the empty-answer rule speaks for it.
18
30
  */
19
31
  import { refuseWrunPollInput, } from '../wrun-poll-lane.types.js';
20
- import { WRUN_OPTION_STATS_FIELDS, WRUN_OPTION_STATS_KTYPES, WRUN_OPTION_STATS_TYPE } from '../../wrun-opra-stats.leaf.js';
32
+ import { decideWrunLaneChain, resolveWrunLaneChainChart, wrunLaneChainLeadMoved, wrunLaneOpraPlaneChain, } from '../opra-option-lanes.util.js';
33
+ import { WRUN_OPTION_STATS_BOOK_FIELD, WRUN_OPTION_STATS_CONTINUOUS_FIELD, WRUN_OPTION_STATS_EXCHANGE_FIELD, WRUN_OPTION_STATS_FIELDS, WRUN_OPTION_STATS_KTYPES, WRUN_OPTION_STATS_TYPE, } from '../../wrun-opra-stats.leaf.js';
21
34
  import { assertWrunProtocolType } from '../../wrun-protocol-pending.util.js';
22
35
  /** The lane key (the refusal record's feed words, `wrun.refusal.feed.optionDaily`). */
23
36
  export const WRUN_OPTION_DAILY_LANE_KEY = 'option_daily';
24
37
  /** The days before the chart window the ask opens: a session's row is written after its close, so the newest row
25
38
  * standing at the window's head can be a few days old (a weekend, a holiday). */
26
39
  export const WRUN_OPTION_DAILY_LOOKBACK_DAYS = 7;
40
+ /** The chart each run's plan resolved for the statistics lanes, by the plan's scope (`WrunPollLaneContext.runScope`):
41
+ * every input of one run, of either class, reads one resolution (one chain, one `auto` book), and the next run
42
+ * resolves afresh (a rolled lead, a listing that changed). */
43
+ const statsCharts = new WeakMap();
44
+ /** The chart the statistics lanes decide their chain over: on the OPRA plane the plane's own chain by coin (no chain
45
+ * directory read: `wrunLaneOpraPlaneChain`), off it the chart's chain as the one resolver resolves it. */
46
+ function resolveStatsChart(ctx) {
47
+ return resolveWrunLaneChainChart(ctx, ctx.opraPlane === true ? wrunLaneOpraPlaneChain(ctx.coin) : undefined);
48
+ }
49
+ function statsChartOf(ctx) {
50
+ const scope = ctx.runScope;
51
+ if (scope === undefined)
52
+ return resolveStatsChart(ctx);
53
+ let chart = statsCharts.get(scope);
54
+ if (chart === undefined) {
55
+ chart = resolveStatsChart(ctx);
56
+ statsCharts.set(scope, chart);
57
+ }
58
+ return chart;
59
+ }
60
+ /**
61
+ * An input's acquisition, the chain it reads as the ask's fields (the acquisition key: the class, the plane its
62
+ * exchange names, the exchange, the underlying, the book and the grain): `coin`, the chain's underlying (the OPRA
63
+ * ticker, the CME futures contract, a crypto venue's root coin: the key the plane files its rows under), and
64
+ * `statsExchange` always; `statsBook`, the ONE book the run decided, on every plane but OPRA (an OPRA read stays by
65
+ * coin with no symbol: contract C1); `statsContinuous` for a CME chain read off a continuous alias
66
+ * (`wrunOptionStatsAcquisitionMoved` reads it).
67
+ */
68
+ export function wrunOptionStatsExtras(chain) {
69
+ return {
70
+ coin: chain.underlying.toUpperCase(),
71
+ [WRUN_OPTION_STATS_EXCHANGE_FIELD]: chain.exchange,
72
+ ...(chain.plane !== 'opra' ? { [WRUN_OPTION_STATS_BOOK_FIELD]: chain.book.toUpperCase() } : {}),
73
+ ...(chain.continuous !== undefined ? { [WRUN_OPTION_STATS_CONTINUOUS_FIELD]: chain.continuous } : {}),
74
+ };
75
+ }
76
+ /** Whether an acquisition no longer names the chain the lane would plan now (D12): a CME chain read off a continuous
77
+ * alias whose lead contract rolled since the run planned it (`wrunLaneChainLeadMoved`). A live session holding it
78
+ * rebuilds, so no ask, cache or buffer joins the old contract's statistics to the new one's. */
79
+ export function wrunOptionStatsAcquisitionMoved(acquisition) {
80
+ return wrunLaneChainLeadMoved(acquisition[WRUN_OPTION_STATS_EXCHANGE_FIELD], acquisition[WRUN_OPTION_STATS_CONTINUOUS_FIELD], acquisition.coin);
81
+ }
27
82
  /**
28
- * One input against the chart: its underlying (the chart's coin, upper case), then the protocol gate. Shared with
29
- * `option_stats_10m`, which reads the same underlying at ten minutes.
83
+ * One input against the chart: a chart that names no underlying refused by name, the protocol gate, then the chain
84
+ * (the run's one resolution of the chart, `statsChartOf`: on the OPRA plane the plane's own by coin, no directory read)
85
+ * and the input's `venue` and `book` decided by the one chain resolver; its refusals are the options chain's own.
86
+ * Shared with `option_stats_10m`, which reads the same chain at ten minutes.
30
87
  */
31
- export async function planWrunOptionStatsInput(ctx, feed, series) {
32
- const coin = ctx.coin.trim().toUpperCase();
33
- if (coin === '') {
88
+ export async function planWrunOptionStatsInput(source, ctx, feed, series) {
89
+ if (ctx.coin.trim() === '') {
34
90
  return refuseWrunPollInput(ctx, `reads the ${series} of the chart's underlying, and this chart names none`, {
35
91
  cls: 'feed-missing',
36
92
  variant: 'market-paused',
@@ -38,16 +94,18 @@ export async function planWrunOptionStatsInput(ctx, feed, series) {
38
94
  });
39
95
  }
40
96
  await assertWrunProtocolType(ctx, WRUN_OPTION_STATS_TYPE, feed);
41
- return { coin };
97
+ const chain = await decideWrunLaneChain(await statsChartOf(ctx), { venue: source.venue, book: source.book }, ctx);
98
+ return wrunOptionStatsExtras(chain);
42
99
  }
43
100
  export const lane = {
44
101
  sourceClass: 'option_daily',
45
102
  laneKey: WRUN_OPTION_DAILY_LANE_KEY,
46
103
  kType: WRUN_OPTION_STATS_KTYPES.day,
47
104
  fields: Object.freeze(Object.fromEntries(WRUN_OPTION_STATS_FIELDS.map((field, at) => [field, at + 1]))),
48
- plan: (_source, ctx) => planWrunOptionStatsInput(ctx, WRUN_OPTION_DAILY_LANE_KEY, 'daily options statistics'),
105
+ plan: (source, ctx) => planWrunOptionStatsInput(source, ctx, WRUN_OPTION_DAILY_LANE_KEY, 'daily options statistics'),
49
106
  join: { kind: 'daily', landing: 'last', lookbackDays: WRUN_OPTION_DAILY_LOOKBACK_DAYS },
50
107
  label: 'Daily options statistics',
51
108
  nativeRows: true,
52
- opra: true,
109
+ chain: { exchangeField: WRUN_OPTION_STATS_EXCHANGE_FIELD },
110
+ acquisitionMoved: wrunOptionStatsAcquisitionMoved,
53
111
  };
@@ -1,21 +1,25 @@
1
1
  /**
2
- * The `option_stats_10m` lane (UW-PARITY source S5b): the chart underlying's options statistics every ten minutes, the
3
- * same 31 scalars as `option_daily` (wrun-opra-stats.leaf), each ten-minute row on the chart bar holding it
4
- * (`input("gex", option_stats_10m.net_gex, { missing: "carry" })`).
2
+ * The `option_stats_10m` lane (UW-PARITY source S5b, OPTIONS-PORT P5): the options statistics of the chart's options
3
+ * chain every ten minutes, the same 31 scalars as `option_daily` (wrun-opra-stats.leaf), each ten-minute row on the
4
+ * chart bar holding it (`input("gex", option_stats_10m.net_gex, { missing: "carry" })`).
5
5
  *
6
- * It reads OPTION_UNDERLYING_STATS TEN_MINUTES rows by coin through `K_OPTION_UNDERLYING_STATS_10M` (om's fetch type
6
+ * It reads OPTION_UNDERLYING_STATS TEN_MINUTES rows through `K_OPTION_UNDERLYING_STATS_10M` (om's fetch type
7
7
  * `option_underlying_stats_10m`) and its worker twin, at ten minutes whatever the chart's interval (`interval`), and
8
8
  * lands them on the chart's bars (`nativeRows` + `barGrid` snapshot, no tiers: a ten-minute row is the chain as it
9
9
  * stood at its stamp, so it lands on the bar holding that stamp, and a bar holding several reads the newest): an
10
10
  * as-of join, since a bar between two rows reads the input's `missing` policy (`carry` holds the last row). A stock
11
- * chart's 09:30 New York bars and an OPRA contract chart's UTC bars alike.
11
+ * chart's 09:30 New York bars, a crypto chart's and an OPRA contract chart's UTC bars alike.
12
12
  *
13
- * Only a configured list of underlyings has ten-minute rows (U7). The chart never mirrors that list: the worker twin
14
- * decides from the data plane's answer (an empty window, then one probe of the last week) and answers the refusal by
15
- * name, `not-in-10m-universe`, which degrades the lane once as the `feed-missing` / `not-sampled` record below.
13
+ * A CHAIN lane like `option_daily` (`planWrunOptionStatsInput`): the chart's chain on whichever plane it lists on (on
14
+ * the OPRA plane its own by coin, with no chain directory read), one book per input, a plane per instance, a continuous
15
+ * CME chart's lead contract (`acquisitionMoved`).
16
16
  *
17
- * Refused by name before any fetch: `opra-official-only:option_stats_10m`, a chart naming no underlying, and
18
- * `protocol-pending:OPTION_UNDERLYING_STATS` until the protocol release.
17
+ * Only some underlyings have ten-minute rows (U7). The chart never mirrors that list: the worker twin decides from
18
+ * the data plane's answer (an empty window, then one probe of the last week) and answers the refusal by name,
19
+ * `not-in-10m-universe`, which degrades the lane once as the `feed-missing` / `not-sampled` record below.
20
+ *
21
+ * Refused by name before any fetch: `opra-official-only:option_stats_10m`, a chart naming no underlying,
22
+ * `protocol-pending:OPTION_UNDERLYING_STATS` until the protocol release, and the chain's own refusals.
19
23
  */
20
24
  import type { WrunPollLane } from '../wrun-poll-lane.types.js';
21
25
  /** The lane key (the refusal record's feed words, `wrun.refusal.feed.optionStats10m`). */
@@ -1,5 +1,5 @@
1
- import { planWrunOptionStatsInput } from './option_daily.js';
2
- import { WRUN_NOT_IN_10M_UNIVERSE_CODE, WRUN_OPTION_STATS_FIELDS, WRUN_OPTION_STATS_INTERVALS, WRUN_OPTION_STATS_KTYPES, } from '../../wrun-opra-stats.leaf.js';
1
+ import { planWrunOptionStatsInput, wrunOptionStatsAcquisitionMoved } from './option_daily.js';
2
+ import { WRUN_NOT_IN_10M_UNIVERSE_CODE, WRUN_OPTION_STATS_EXCHANGE_FIELD, WRUN_OPTION_STATS_FIELDS, WRUN_OPTION_STATS_INTERVALS, WRUN_OPTION_STATS_KTYPES, } from '../../wrun-opra-stats.leaf.js';
3
3
  /** The lane key (the refusal record's feed words, `wrun.refusal.feed.optionStats10m`). */
4
4
  export const WRUN_OPTION_STATS_10M_LANE_KEY = 'option_stats_10m';
5
5
  export const lane = {
@@ -7,13 +7,14 @@ export const lane = {
7
7
  laneKey: WRUN_OPTION_STATS_10M_LANE_KEY,
8
8
  kType: WRUN_OPTION_STATS_KTYPES['10m'],
9
9
  fields: Object.freeze(Object.fromEntries(WRUN_OPTION_STATS_FIELDS.map((field, at) => [field, at + 1]))),
10
- plan: (_source, ctx) => planWrunOptionStatsInput(ctx, WRUN_OPTION_STATS_10M_LANE_KEY, '10-minute options statistics'),
10
+ plan: (source, ctx) => planWrunOptionStatsInput(source, ctx, WRUN_OPTION_STATS_10M_LANE_KEY, '10-minute options statistics'),
11
11
  join: 'bar',
12
12
  interval: WRUN_OPTION_STATS_INTERVALS['10m'],
13
13
  label: '10-minute options statistics',
14
14
  nativeRows: true,
15
15
  barGrid: { landing: 'snapshot' },
16
- opra: true,
16
+ chain: { exchangeField: WRUN_OPTION_STATS_EXCHANGE_FIELD },
17
+ acquisitionMoved: wrunOptionStatsAcquisitionMoved,
17
18
  refusedAnswers: {
18
19
  [WRUN_NOT_IN_10M_UNIVERSE_CODE]: { cls: 'feed-missing', variant: 'not-sampled' },
19
20
  },
@@ -138,12 +138,23 @@ export interface WrunLaneChainChart {
138
138
  export declare function resolveWrunLaneChainAutoBook(chain: WrunLaneChainOfBook): Promise<string>;
139
139
  /**
140
140
  * Resolve the chart for the one chain resolver (lazy imports: the chain directory, the venue listing and table, the
141
- * continuous lead resolver): the chart's chain (`resolveWrunLaneChartChain`, the options chain lane's own), the crypto
142
- * venue words (`resolveWrunLaneCryptoVenues`), for a CME chain on a continuous alias the contract leading it now
141
+ * continuous lead resolver): the chart's chain (`resolveWrunLaneChartChain`, the options chain lane's own, or the
142
+ * chain the caller already holds, `held`: the OPRA plane's own by coin, `wrunLaneOpraPlaneChain`), the crypto venue
143
+ * words (`resolveWrunLaneCryptoVenues`), for a CME chain on a continuous alias the contract leading it now
143
144
  * (option-chain.service `resolveChainContract`, the roll rule the terminal identity admits the alias by), and each
144
145
  * decided chain's default book (`resolveWrunLaneChainAutoBook`, asked once per chain for this chart).
145
146
  */
146
- export declare function resolveWrunLaneChainChart(ctx: Pick<WrunPollLaneContext, 'exchange' | 'symbol' | 'coin' | 'category'>): Promise<WrunLaneChainChart>;
147
+ export declare function resolveWrunLaneChainChart(ctx: Pick<WrunPollLaneContext, 'exchange' | 'symbol' | 'coin' | 'category'>, held?: WrunLaneChartChain): Promise<WrunLaneChainChart>;
148
+ /**
149
+ * The chart's chain on the OPRA plane, read off the plane itself: OPRA's chain of the chart's own underlying (its coin,
150
+ * upper case: a stock or ETF chart's ticker, an OPRA contract chart's underlying), on the plane's one exchange (the
151
+ * governed set's, never a literal). For a lane that reads by coin there (`option_daily`, `option_stats_10m`: their OPRA
152
+ * reads went by coin before the chain resolver, and stay byte-identical), handed to `resolveWrunLaneChainChart` in
153
+ * place of the chain directory's answer: no directory is read, so a stock listing no options, or a directory slow or
154
+ * failing, refuses nothing before the read (an empty answer, and the empty-answer rule speaks). The venue and book words
155
+ * are still decided over it (`decideWrunLaneChain`), with no read either.
156
+ */
157
+ export declare function wrunLaneOpraPlaneChain(coin: string): WrunLaneChartChain;
147
158
  /** Who a venue decision is for: the input, the chart market (and the label a refusal names it by, `EXCHANGE/SYMBOL`
148
159
  * by default) and the run's OPRA facts. */
149
160
  export interface WrunLaneChainDecider {
@@ -192,5 +203,13 @@ export declare function wrunLaneChainRefusalSeed(refusal: Pick<WrunOptionsChainR
192
203
  /** A refused chain decision as the error a lane refuses with: the decision's technical words with the input's class
193
204
  * in place of `options_chain` (om names the class it reads), and its record's seed. */
194
205
  export declare function wrunLaneChainRefusalError(refusal: WrunOptionsChainRefusal, sourceClass: string): Error;
206
+ /**
207
+ * Whether a chain read off a continuous alias no longer names the contract leading it (D12): the lead resolver's last
208
+ * answer (`peekRegisteredContinuousLead`) for the alias on the chain's exchange names another contract than the one
209
+ * the run planned. A chain lane's `acquisitionMoved` reads it over its own acquisition fields, so a live session
210
+ * holding the old contract's rows rebuilds instead of joining the next contract's tail to them. A read off no alias,
211
+ * and a lead not resolved yet, moved nothing.
212
+ */
213
+ export declare function wrunLaneChainLeadMoved(exchange: unknown, alias: unknown, planned: unknown): boolean;
195
214
  /** Refuse a knob the class does not take, by name (om's sheet refusal for a stray knob). */
196
215
  export declare function refuseWrunLaneStrayKnob(ctx: Pick<WrunPollLaneContext, 'inputName' | 'sourceClass'>, knob: string, owners: string): never;
@@ -6,9 +6,10 @@
6
6
  * book), the knob words of the options classes and their refusals by name.
7
7
  *
8
8
  * ONE venue decision for every chain class: the options chain lane (wrun-overlay-run.util
9
- * `wrunOptionsChainLaneExtrasFor`) and the chain row lanes resolve the chart's chain through the same function
10
- * (`resolveWrunChartChain`, over the chart's market and category) and decide a venue word through the same one
11
- * (`decideWrunLaneChainIdentity`), so a package reading `options_chain` and `option_surface` never mixes venues.
9
+ * `wrunOptionsChainLaneExtrasFor`), the chain row lanes and the chain poll lanes (`option_daily`, `option_stats_10m`
10
+ * under `./lanes/`, OPTIONS-PORT P5) resolve the chart's chain through the same function (`resolveWrunChartChain`, over
11
+ * the chart's market and category) and decide a venue word through the same one (`decideWrunLaneChainIdentity`), so a
12
+ * package reading `options_chain`, `option_surface` and `option_daily` never mixes venues.
12
13
  *
13
14
  * The OPRA-only lanes keep their own wrappers over the same chart resolution (`resolveWrunLaneOpraChain`,
14
15
  * `resolveWrunOpraLaneUnderlying`) with their words unchanged, until they read the one resolver too.
@@ -19,7 +20,9 @@
19
20
  * inside the async helpers.
20
21
  */
21
22
  import { wrunChartHostEnv } from '../../../host-env.js';
23
+ import { OPRA_GOVERNED_EXCHANGES } from '../../../constants/governed-exchanges.constants.js';
22
24
  import { isCmeGoverned } from '../../chart/cme-realtime.util.js';
25
+ import { peekRegisteredContinuousLead } from '../../chart/continuous-contracts.util.js';
23
26
  import { refuseWrunPollInput } from './wrun-poll-lane.types.js';
24
27
  import { wrunLaneChainPlaneOf } from './wrun-row-lane.types.js';
25
28
  import { decideWrunOptionsChainIdentity, WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_IDS, WRUN_OPTIONS_CHAIN_UNAVAILABLE_CODE, } from '../wrun-options-chain.util.js';
@@ -259,13 +262,14 @@ async function readWrunLaneChainSeries(exchangeName, underlying) {
259
262
  }
260
263
  /**
261
264
  * Resolve the chart for the one chain resolver (lazy imports: the chain directory, the venue listing and table, the
262
- * continuous lead resolver): the chart's chain (`resolveWrunLaneChartChain`, the options chain lane's own), the crypto
263
- * venue words (`resolveWrunLaneCryptoVenues`), for a CME chain on a continuous alias the contract leading it now
265
+ * continuous lead resolver): the chart's chain (`resolveWrunLaneChartChain`, the options chain lane's own, or the
266
+ * chain the caller already holds, `held`: the OPRA plane's own by coin, `wrunLaneOpraPlaneChain`), the crypto venue
267
+ * words (`resolveWrunLaneCryptoVenues`), for a CME chain on a continuous alias the contract leading it now
264
268
  * (option-chain.service `resolveChainContract`, the roll rule the terminal identity admits the alias by), and each
265
269
  * decided chain's default book (`resolveWrunLaneChainAutoBook`, asked once per chain for this chart).
266
270
  */
267
- export async function resolveWrunLaneChainChart(ctx) {
268
- const chain = await resolveWrunLaneChartChain(ctx);
271
+ export async function resolveWrunLaneChainChart(ctx, held) {
272
+ const chain = held ?? (await resolveWrunLaneChartChain(ctx));
269
273
  const [cryptoVenues, { hasDeribitOptions }, { OPTION_VENUES }] = await Promise.all([
270
274
  resolveWrunLaneCryptoVenues(chain, ctx.coin),
271
275
  wrunChartHostEnv().market.loadDeribitOptions(),
@@ -303,6 +307,20 @@ export async function resolveWrunLaneChainChart(ctx) {
303
307
  },
304
308
  };
305
309
  }
310
+ /**
311
+ * The chart's chain on the OPRA plane, read off the plane itself: OPRA's chain of the chart's own underlying (its coin,
312
+ * upper case: a stock or ETF chart's ticker, an OPRA contract chart's underlying), on the plane's one exchange (the
313
+ * governed set's, never a literal). For a lane that reads by coin there (`option_daily`, `option_stats_10m`: their OPRA
314
+ * reads went by coin before the chain resolver, and stay byte-identical), handed to `resolveWrunLaneChainChart` in
315
+ * place of the chain directory's answer: no directory is read, so a stock listing no options, or a directory slow or
316
+ * failing, refuses nothing before the read (an empty answer, and the empty-answer rule speaks). The venue and book words
317
+ * are still decided over it (`decideWrunLaneChain`), with no read either.
318
+ */
319
+ export function wrunLaneOpraPlaneChain(coin) {
320
+ return {
321
+ chartSource: { venue: 'opra', exchange: OPRA_GOVERNED_EXCHANGES[0], underlying: coin.trim().toUpperCase() },
322
+ };
323
+ }
306
324
  /**
307
325
  * The ONE venue decision of every chain class (the options chain lane, `option_surface`): one input's `venue` word
308
326
  * against the chart's resolved chain, by the options chain decision (`decideWrunOptionsChainIdentity`: `auto` reads
@@ -438,6 +456,19 @@ export function wrunLaneChainRefusalSeed(refusal) {
438
456
  export function wrunLaneChainRefusalError(refusal, sourceClass) {
439
457
  return attachWrunRefusal(new Error(refusal.message.replace('reads options_chain cells', `reads ${sourceClass} cells`)), wrunLaneChainRefusalSeed(refusal));
440
458
  }
459
+ /**
460
+ * Whether a chain read off a continuous alias no longer names the contract leading it (D12): the lead resolver's last
461
+ * answer (`peekRegisteredContinuousLead`) for the alias on the chain's exchange names another contract than the one
462
+ * the run planned. A chain lane's `acquisitionMoved` reads it over its own acquisition fields, so a live session
463
+ * holding the old contract's rows rebuilds instead of joining the next contract's tail to them. A read off no alias,
464
+ * and a lead not resolved yet, moved nothing.
465
+ */
466
+ export function wrunLaneChainLeadMoved(exchange, alias, planned) {
467
+ if (typeof alias !== 'string' || alias === '' || typeof exchange !== 'string')
468
+ return false;
469
+ const lead = peekRegisteredContinuousLead(exchange, alias)?.symbol;
470
+ return typeof lead === 'string' && lead !== '' && lead !== planned;
471
+ }
441
472
  /** The seed of a knob the author fixes in the code: a failed run, its words in the details. */
442
473
  const WRUN_LANE_KNOB_SEED = Object.freeze({ cls: 'run-failed', variant: 'generic' });
443
474
  /** Refuse a knob the class does not take, by name (om's sheet refusal for a stray knob). */
@@ -20,7 +20,10 @@
20
20
  * charts too) is no `global` one and rides no own fetch; per bar it declares its host-grid landing (`barGrid`: a
21
21
  * flow or a snapshot, its backend tiers each a positive width and retention), daily it keeps the daily landing
22
22
  * (by UTC day, no `barGrid`);
23
- * - `opra` is true or absent.
23
+ * - `opra` is true or absent;
24
+ * - a `chain` lane (the row lanes' mark) names the payload field its chain's exchange rides in, rides the native-rows
25
+ * path (`nativeRows`: its rows are its chain's), and declares no `opra` (its plane is each instance's), no `global`,
26
+ * no own `fetch` and no `live` channel (it is polled); `acquisitionMoved` is a function or absent.
24
27
  *
25
28
  * The consumers read the lookups below at call time, so the one test hook
26
29
  * (`__setWrunPollLanesForTest`) swaps the whole registry for a spec.
@@ -95,8 +98,35 @@ function assertWrunPollLanes(lanes) {
95
98
  throw new Error(`${who}: a global lane joins daily (its rows land by UTC day on any chart grid, a session chart's included)`);
96
99
  }
97
100
  assertWrunPollLaneHostGrid(who, lane);
101
+ assertWrunPollChainLane(who, lane);
98
102
  }
99
103
  }
104
+ /** A chain lane's rules (`chain`, the row lanes' mark): it names the payload field its chain's exchange rides in,
105
+ * rides the native-rows path, and keeps no per-descriptor plane (`opra`), no subject of its own (`global`), no own
106
+ * fetch and no live channel; a moved-acquisition check is a function or absent, on any lane. */
107
+ function assertWrunPollChainLane(who, lane) {
108
+ if (lane.acquisitionMoved !== undefined && typeof lane.acquisitionMoved !== 'function') {
109
+ throw new Error(`${who}: acquisitionMoved is a function or absent`);
110
+ }
111
+ const chain = lane.chain;
112
+ if (chain === undefined)
113
+ return;
114
+ if (chain === null ||
115
+ typeof chain !== 'object' ||
116
+ typeof chain.exchangeField !== 'string' ||
117
+ chain.exchangeField === '') {
118
+ throw new Error(`${who}: chain is { exchangeField: the payload field its chain's exchange rides in } or absent`);
119
+ }
120
+ if (lane.opra !== undefined)
121
+ throw new Error(`${who}: a chain lane's plane is each instance's: no opra`);
122
+ if (lane.global !== undefined)
123
+ throw new Error(`${who}: a chain lane reads the chart's chain, never its own subject`);
124
+ if (lane.nativeRows !== true) {
125
+ throw new Error(`${who}: a chain lane rides the native-rows path (declare nativeRows: its rows are its chain's)`);
126
+ }
127
+ if (lane.live !== undefined)
128
+ throw new Error(`${who}: a chain lane is polled, never fed by a live channel`);
129
+ }
100
130
  /** The per-bar native-rows rules of one lane (`nativeRows`, `barGrid`) and its `opra` mark. */
101
131
  function assertWrunPollLaneHostGrid(who, lane) {
102
132
  if (lane.opra !== undefined && lane.opra !== true)
@@ -15,7 +15,7 @@
15
15
  * absent; a `liveByCoin` lane names its script source and its stamp and fold functions, and is no `latest` one;
16
16
  * a `rowBudget` names a whole row cap and a projection, on a flow or snapshot that carries a present mask;
17
17
  * - a `chain` lane names its exchange field, resolves its chain in its identity or facets, and declares no
18
- * `governed`, no `offPlane` and no `liveByCoin` (its plane is each instance's).
18
+ * `governed` and no `liveByCoin` (its plane is each instance's).
19
19
  *
20
20
  * The consumers read the lookups below at call time, so the one test hook (`__setWrunRowLanesForTest`) swaps the
21
21
  * whole registry for a spec. The folder ships EMPTY of lanes until a class lands (UW-PARITY units U10b, U11).
@@ -43,8 +43,8 @@ function nonEmptyText(value) {
43
43
  return typeof value === 'string' && value !== '';
44
44
  }
45
45
  /** A chain lane's rules (`chain`): it names the payload field its chain's exchange rides in, resolves that chain in
46
- * its identity or facets, and keeps no per-descriptor plane (`governed`, `offPlane`) and no live channel by coin
47
- * (one plane's channel). */
46
+ * its identity or facets, and keeps no per-descriptor plane (`governed`) and no live channel by coin (one plane's
47
+ * channel). */
48
48
  function assertWrunRowChainLane(who, lane) {
49
49
  const chain = lane.chain;
50
50
  if (chain === undefined)
@@ -52,8 +52,8 @@ function assertWrunRowChainLane(who, lane) {
52
52
  if (chain === null || typeof chain !== 'object' || !nonEmptyText(chain.exchangeField)) {
53
53
  throw new Error(`${who}: chain is { exchangeField: the payload field its chain's exchange rides in } or absent`);
54
54
  }
55
- if (lane.governed !== undefined || lane.offPlane !== undefined) {
56
- throw new Error(`${who}: a chain lane's plane is each instance's: no governed, no offPlane`);
55
+ if (lane.governed !== undefined) {
56
+ throw new Error(`${who}: a chain lane's plane is each instance's: no governed`);
57
57
  }
58
58
  if (lane.identity === undefined && lane.facets === undefined) {
59
59
  throw new Error(`${who}: a chain lane resolves its chain in its identity or facets`);
@@ -1,6 +1,55 @@
1
+ /**
2
+ * `option_contract_state`: the chain summary of every contract of the chart's options chain with the prior session's
3
+ * close and the prior open interest, on the LIVE bar only (UW-PARITY S7, `contracts/sources.md`), on every chain the
4
+ * chain summary serves (OPTIONS-PORT P5: OPRA, CME, the crypto venues).
5
+ *
6
+ * - Tuple, width 13: `[root_code, expiry_ms, side_cp, strike, bid, ask, last, prev_close, theta, volume_day, oi, oi_prev,
7
+ * present]`; bits 4 to 11 of `present` say which of bid through oi_prev were served (0 with the bit clear otherwise).
8
+ * `prev_close` and `oi_prev` are kiyotaka-go !62's chain fields (`prevClose`, `openInterestPrev`, decoded since
9
+ * pb-common 12.68.0); a summary that leaves one out reads 0 with its bit clear. There is no protocol-pending refusal
10
+ * for this class.
11
+ * - Units (OPTIONS-PORT C3): sizes (`volume_day`, `oi`, `oi_prev`) in coin on a crypto chain, contracts on OPRA and
12
+ * CME; prices (`bid`, `ask`, `last`, `prev_close`) in USD per underlying unit on every venue (the worker converts a
13
+ * coin-quoted book's, and serves one absent when the price it converts by is unknown).
14
+ * - Backend: the chain summary of the chain's exchange and underlying, as an acquisition of its own
15
+ * (`K_OPTION_CHAIN_SUMMARY`: a package reading `options_chain` too reads the chain twice, separately). On OPRA and
16
+ * CME the governed `StreamOptionChainSummary` read the options chain lane reads (the worker's chain store,
17
+ * `ensureFreshChain`); on a crypto chain the plain read (the worker's plain chain summary util). The K type is om's
18
+ * fetch type for the class (`option_chain_summary`).
19
+ * - Landing `latest`: the newest chain snapshot is the live row's block, every other row an empty one (read it on
20
+ * `bar.isLast()`), like `options_chain`; an empty chain degrades like every state lane.
21
+ * - A CHAIN lane (`chain`): the chain is the one chain resolver's (opra-option-lanes.util `decideWrunLaneChain`), per
22
+ * input, and its plane is per instance: OPRA's rules on a US stock or OPRA contract chart (unchanged: the wall, the
23
+ * provenance stamp, the routed tier), CME's on a CME futures chart (a continuous chart reads its lead contract, and a
24
+ * live session rebuilds once the lead rolls: `acquisitionMoved`), none on a crypto chain. ONE book per input (D11),
25
+ * named in the acquisition (`stateBook`) unless it is the underlying's own series; the worker keeps its contracts.
26
+ * - Knobs (acquisition facets): `expiries` ("all", "nearest:N" or "0dte", the chain's market's own trade date) and
27
+ * `strike_window_pct` (above 0, at most 100), `book` (`auto` or one series name); `max_cells` is required (the static
28
+ * plan) and a block over it refuses the run, never truncated. A market pin and the knobs of the other options classes
29
+ * are refused by name (`venue` among them until om's kit declares it for this class: the chain is `auto`'s, the one
30
+ * `options_chain`'s `auto` reads on the same chart).
31
+ *
32
+ * LIGHT at module load: the chain resolver's directory, listing and lead reads run inside `identity` and `facets`.
33
+ */
34
+ import { type WrunLaneChain } from '../opra-option-lanes.util.js';
1
35
  import type { WrunRowLaneDescriptor } from '../wrun-row-lane.types.js';
2
36
  /** f64s per tuple (the source contract's width, the `present` mask included). */
3
37
  export declare const WRUN_OPTION_CONTRACT_STATE_WIDTH = 13;
4
38
  /** om's code for a market pin on the OPRA classes. */
5
39
  export declare const WRUN_OPTION_MARKET_PINNED_CODE = "wrun_option_market_pinned";
40
+ /** The payload field an instance names its chain's exchange in (its plane follows it). */
41
+ export declare const WRUN_OPTION_CONTRACT_STATE_EXCHANGE_FIELD = "stateExchange";
42
+ /** Test seam: forget every resolved chart. */
43
+ export declare function __resetWrunContractStateChartsForTests(): void;
44
+ /**
45
+ * An input's chain as the ask's fields (the acquisition key: the class, the plane its exchange names, the exchange,
46
+ * the underlying, the book): `stateExchange` and `stateUnderlying` always (an OPRA chain's exactly as before),
47
+ * `stateBook` for a book other than the underlying's own series (Deribit's BTC_USDC, OKX's BTC-USD), and
48
+ * `stateContinuous` for a CME chain read off a continuous alias (`wrunOptionContractStateAcquisitionMoved` reads it).
49
+ */
50
+ export declare function wrunOptionContractStateExtras(chain: WrunLaneChain): Record<string, unknown>;
51
+ /** Whether an acquisition no longer names the contract the lane would plan now (D12): a CME chain read off a
52
+ * continuous alias whose lead rolled since the run planned it (`wrunLaneChainLeadMoved`). A live session holding it
53
+ * rebuilds, so the live bar never reads the old contract's chain under the new one's name. */
54
+ export declare function wrunOptionContractStateAcquisitionMoved(acquisition: Readonly<Record<string, unknown>>): boolean;
6
55
  export declare const rowLane: WrunRowLaneDescriptor;
@@ -1,33 +1,45 @@
1
1
  /**
2
- * `option_contract_state`: the chain summary of every contract of the chart's underlying with the prior session's close
3
- * and the prior open interest, on the LIVE bar only (UW-PARITY S7, `contracts/sources.md`).
2
+ * `option_contract_state`: the chain summary of every contract of the chart's options chain with the prior session's
3
+ * close and the prior open interest, on the LIVE bar only (UW-PARITY S7, `contracts/sources.md`), on every chain the
4
+ * chain summary serves (OPTIONS-PORT P5: OPRA, CME, the crypto venues).
4
5
  *
5
6
  * - Tuple, width 13: `[root_code, expiry_ms, side_cp, strike, bid, ask, last, prev_close, theta, volume_day, oi, oi_prev,
6
7
  * present]`; bits 4 to 11 of `present` say which of bid through oi_prev were served (0 with the bit clear otherwise).
7
8
  * `prev_close` and `oi_prev` are kiyotaka-go !62's chain fields (`prevClose`, `openInterestPrev`, decoded since
8
9
  * pb-common 12.68.0); a summary that leaves one out reads 0 with its bit clear. There is no protocol-pending refusal
9
10
  * for this class.
10
- * - Backend: the governed `StreamOptionChainSummary` read the options chain lane reads (the worker's chain store,
11
- * `ensureFreshChain`), as an acquisition of its own (`K_OPTION_CHAIN_SUMMARY`: a package reading `options_chain` too
12
- * reads the chain twice, separately; the hand-wired chain lane is untouched). The K type is om's fetch type for the
13
- * class (`option_chain_summary`).
11
+ * - Units (OPTIONS-PORT C3): sizes (`volume_day`, `oi`, `oi_prev`) in coin on a crypto chain, contracts on OPRA and
12
+ * CME; prices (`bid`, `ask`, `last`, `prev_close`) in USD per underlying unit on every venue (the worker converts a
13
+ * coin-quoted book's, and serves one absent when the price it converts by is unknown).
14
+ * - Backend: the chain summary of the chain's exchange and underlying, as an acquisition of its own
15
+ * (`K_OPTION_CHAIN_SUMMARY`: a package reading `options_chain` too reads the chain twice, separately). On OPRA and
16
+ * CME the governed `StreamOptionChainSummary` read the options chain lane reads (the worker's chain store,
17
+ * `ensureFreshChain`); on a crypto chain the plain read (the worker's plain chain summary util). The K type is om's
18
+ * fetch type for the class (`option_chain_summary`).
14
19
  * - Landing `latest`: the newest chain snapshot is the live row's block, every other row an empty one (read it on
15
20
  * `bar.isLast()`), like `options_chain`; an empty chain degrades like every state lane.
16
- * - Knobs (acquisition facets): `expiries` ("all", "nearest:N" or "0dte") and `strike_window_pct` (above 0, at most 100);
17
- * `max_cells` is required (the static plan) and a block over it refuses the run, never truncated. A market pin and
18
- * the knobs of the other options classes are refused by name.
19
- * - Governed by OPRA: served where the chart's options ride the OPRA plane (a US stock or ETF chart, an OPRA contract
20
- * chart), the wall for a run that may not read OPRA, the provenance stamp and the routed tier (U10a's rules).
21
+ * - A CHAIN lane (`chain`): the chain is the one chain resolver's (opra-option-lanes.util `decideWrunLaneChain`), per
22
+ * input, and its plane is per instance: OPRA's rules on a US stock or OPRA contract chart (unchanged: the wall, the
23
+ * provenance stamp, the routed tier), CME's on a CME futures chart (a continuous chart reads its lead contract, and a
24
+ * live session rebuilds once the lead rolls: `acquisitionMoved`), none on a crypto chain. ONE book per input (D11),
25
+ * named in the acquisition (`stateBook`) unless it is the underlying's own series; the worker keeps its contracts.
26
+ * - Knobs (acquisition facets): `expiries` ("all", "nearest:N" or "0dte", the chain's market's own trade date) and
27
+ * `strike_window_pct` (above 0, at most 100), `book` (`auto` or one series name); `max_cells` is required (the static
28
+ * plan) and a block over it refuses the run, never truncated. A market pin and the knobs of the other options classes
29
+ * are refused by name (`venue` among them until om's kit declares it for this class: the chain is `auto`'s, the one
30
+ * `options_chain`'s `auto` reads on the same chart).
21
31
  *
22
- * LIGHT at module load: the chain resolver is imported inside `identity`.
32
+ * LIGHT at module load: the chain resolver's directory, listing and lead reads run inside `identity` and `facets`.
23
33
  */
24
- import { refuseWrunLaneStrayKnob, resolveWrunLaneOpraChain } from '../opra-option-lanes.util.js';
34
+ import { decideWrunLaneChain, refuseWrunLaneStrayKnob, resolveWrunLaneChainChart, wrunLaneChainLeadMoved, wrunLaneChartKey, } from '../opra-option-lanes.util.js';
25
35
  import { refuseWrunPollInput } from '../wrun-poll-lane.types.js';
26
36
  import { wrunOptionExpiriesKnob, wrunOptionExpiriesText, wrunOptionStrikeWindowKnob, } from '../../wrun-option-knobs.util.js';
27
37
  /** f64s per tuple (the source contract's width, the `present` mask included). */
28
38
  export const WRUN_OPTION_CONTRACT_STATE_WIDTH = 13;
29
39
  /** om's code for a market pin on the OPRA classes. */
30
40
  export const WRUN_OPTION_MARKET_PINNED_CODE = 'wrun_option_market_pinned';
41
+ /** The payload field an instance names its chain's exchange in (its plane follows it). */
42
+ export const WRUN_OPTION_CONTRACT_STATE_EXCHANGE_FIELD = 'stateExchange';
31
43
  /** The knobs of the other options classes, each refused here by name. */
32
44
  const STRAY_KNOBS = [
33
45
  ['venue', "'options_chain', 'option_strikes', 'option_surface', 'options_oi' and 'options_volume'"],
@@ -37,6 +49,41 @@ const STRAY_KNOBS = [
37
49
  ['overflow', "'option_prints' celled"],
38
50
  ['min_volume', "'option_contract_flow' celled"],
39
51
  ];
52
+ /** What `identity` resolved for a chart (the one chain resolver's chart), read back by `facets`. Keyed by the chart
53
+ * market; the newest entries kept. */
54
+ const STATE_CHARTS_KEPT = 16;
55
+ const stateCharts = new Map();
56
+ function rememberStateChart(key, chart) {
57
+ stateCharts.delete(key);
58
+ stateCharts.set(key, chart);
59
+ while (stateCharts.size > STATE_CHARTS_KEPT)
60
+ stateCharts.delete(stateCharts.keys().next().value);
61
+ }
62
+ /** Test seam: forget every resolved chart. */
63
+ export function __resetWrunContractStateChartsForTests() {
64
+ stateCharts.clear();
65
+ }
66
+ /**
67
+ * An input's chain as the ask's fields (the acquisition key: the class, the plane its exchange names, the exchange,
68
+ * the underlying, the book): `stateExchange` and `stateUnderlying` always (an OPRA chain's exactly as before),
69
+ * `stateBook` for a book other than the underlying's own series (Deribit's BTC_USDC, OKX's BTC-USD), and
70
+ * `stateContinuous` for a CME chain read off a continuous alias (`wrunOptionContractStateAcquisitionMoved` reads it).
71
+ */
72
+ export function wrunOptionContractStateExtras(chain) {
73
+ const book = chain.book.toUpperCase();
74
+ return {
75
+ [WRUN_OPTION_CONTRACT_STATE_EXCHANGE_FIELD]: chain.exchange,
76
+ stateUnderlying: chain.underlying,
77
+ ...(book !== chain.underlying.toUpperCase() ? { stateBook: book } : {}),
78
+ ...(chain.continuous !== undefined ? { stateContinuous: chain.continuous } : {}),
79
+ };
80
+ }
81
+ /** Whether an acquisition no longer names the contract the lane would plan now (D12): a CME chain read off a
82
+ * continuous alias whose lead rolled since the run planned it (`wrunLaneChainLeadMoved`). A live session holding it
83
+ * rebuilds, so the live bar never reads the old contract's chain under the new one's name. */
84
+ export function wrunOptionContractStateAcquisitionMoved(acquisition) {
85
+ return wrunLaneChainLeadMoved(acquisition[WRUN_OPTION_CONTRACT_STATE_EXCHANGE_FIELD], acquisition.stateContinuous, acquisition.stateUnderlying);
86
+ }
40
87
  export const rowLane = {
41
88
  sourceClass: 'option_contract_state',
42
89
  laneKey: 'option_contract_state',
@@ -45,13 +92,13 @@ export const rowLane = {
45
92
  label: 'Option contract quotes',
46
93
  feedWords: 'wrun.refusal.feed.optionContractState',
47
94
  width: WRUN_OPTION_CONTRACT_STATE_WIDTH,
48
- governed: 'opra',
95
+ chain: { exchangeField: WRUN_OPTION_CONTRACT_STATE_EXCHANGE_FIELD },
49
96
  landing: { kind: 'latest' },
97
+ acquisitionMoved: wrunOptionContractStateAcquisitionMoved,
50
98
  identity: async (ctx) => {
51
- const chain = await resolveWrunLaneOpraChain(ctx);
52
- return { stateExchange: chain.exchange, stateUnderlying: chain.underlying };
99
+ rememberStateChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx));
53
100
  },
54
- facets: (source, ctx) => {
101
+ facets: async (source, ctx) => {
55
102
  for (const [knob, owners] of STRAY_KNOBS) {
56
103
  if (source[knob] !== undefined)
57
104
  refuseWrunLaneStrayKnob(ctx, knob, owners);
@@ -59,10 +106,19 @@ export const rowLane = {
59
106
  if (source.symbol !== undefined || source.exchange !== undefined) {
60
107
  refuseWrunPollInput(ctx, `pins option_contract_state cells to a fixed market (${WRUN_OPTION_MARKET_PINNED_CODE}); it reads the chart's own underlying, so drop the symbol and exchange pin`, { cls: 'run-failed', variant: 'generic' });
61
108
  }
62
- // om's knob words and its one refusal name (`wrun_option_knob_invalid`), as every OPRA class refuses them.
109
+ // om's knob words and its one refusal name (`wrun_option_knob_invalid`), as every options class refuses them.
63
110
  const expiries = wrunOptionExpiriesKnob(source, ctx);
64
111
  const strikeWindowPct = wrunOptionStrikeWindowKnob(source, ctx);
112
+ const chart = stateCharts.get(wrunLaneChartKey(ctx));
113
+ if (chart === undefined) {
114
+ return refuseWrunPollInput(ctx, 'could not resolve the chart market for its options chain: Run again', {
115
+ cls: 'run-failed',
116
+ variant: 'generic',
117
+ });
118
+ }
119
+ const chain = await decideWrunLaneChain(chart, { venue: source.venue, book: source.book }, ctx);
65
120
  return {
121
+ ...wrunOptionContractStateExtras(chain),
66
122
  stateExpiries: wrunOptionExpiriesText(expiries),
67
123
  ...(strikeWindowPct !== undefined ? { stateStrikeWindowPct: strikeWindowPct } : {}),
68
124
  };