@orangecharts/wrun-chart-host 0.19.0 → 0.20.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 (55) hide show
  1. package/README.md +2 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +1 -0
  4. package/dist/settings-templates/frvp-fields.js +9 -3
  5. package/dist/settings-templates/index.d.ts +36 -3
  6. package/dist/settings-templates/index.js +111 -27
  7. package/dist/settings-templates/indicator-fields.d.ts +11 -0
  8. package/dist/settings-templates/indicator-fields.js +5 -4
  9. package/dist/settings-templates/market-bound.d.ts +93 -19
  10. package/dist/settings-templates/market-bound.js +235 -30
  11. package/dist/settings-templates/tool-rules.d.ts +197 -18
  12. package/dist/settings-templates/tool-rules.js +98 -4
  13. package/dist/settings-templates/tool-tables.generated.d.ts +2 -0
  14. package/dist/settings-templates/tool-tables.generated.js +194 -11
  15. package/dist/utility/chart/calendar-interval.util.d.ts +7 -0
  16. package/dist/utility/chart/calendar-interval.util.js +9 -0
  17. package/dist/utility/chart/index-mode.util.d.ts +11 -0
  18. package/dist/utility/chart/index-mode.util.js +24 -0
  19. package/dist/utility/chart/indicator-run-interval.util.d.ts +7 -3
  20. package/dist/utility/chart/indicator-run-interval.util.js +16 -5
  21. package/dist/utility/chart/market-session-schedule.util.d.ts +2 -0
  22. package/dist/utility/chart/market-session-schedule.util.js +2 -0
  23. package/dist/utility/chart/run-interval-warmup.leaf.d.ts +16 -1
  24. package/dist/utility/chart/run-interval-warmup.leaf.js +28 -2
  25. package/dist/utility/options/option-contract-market.leaf.d.ts +2 -0
  26. package/dist/utility/options/option-contract-market.leaf.js +21 -0
  27. package/dist/utility/options/option-trade-units.util.d.ts +35 -5
  28. package/dist/utility/options/option-trade-units.util.js +31 -5
  29. package/dist/utility/wrun/wrun-chart-market-facts.util.js +3 -3
  30. package/dist/utility/wrun/wrun-color-settings.util.d.ts +2 -13
  31. package/dist/utility/wrun/wrun-color-settings.util.js +3 -29
  32. package/dist/utility/wrun/wrun-lane-warmup.util.d.ts +1 -1
  33. package/dist/utility/wrun/wrun-lane-warmup.util.js +8 -3
  34. package/dist/utility/wrun/wrun-live-intake.util.js +13 -6
  35. package/dist/utility/wrun/wrun-live-tick.util.js +35 -18
  36. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +34 -1
  37. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +57 -0
  38. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +76 -13
  39. package/dist/utility/wrun/wrun-market-size-defaults.util.js +286 -45
  40. package/dist/utility/wrun/wrun-market-size-rank.leaf.d.ts +75 -0
  41. package/dist/utility/wrun/wrun-market-size-rank.leaf.js +154 -0
  42. package/dist/utility/wrun/wrun-overlay-run.util.js +124 -21
  43. package/dist/utility/wrun/wrun-param-values.util.d.ts +2 -1
  44. package/dist/utility/wrun/wrun-param-values.util.js +3 -9
  45. package/dist/utility/wrun/wrun-row-scalars.leaf.d.ts +30 -0
  46. package/dist/utility/wrun/wrun-row-scalars.leaf.js +73 -0
  47. package/dist/utility/wrun/wrun-run-health.util.d.ts +24 -2
  48. package/dist/utility/wrun/wrun-run-health.util.js +39 -7
  49. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +18 -0
  50. package/dist/utility/wrun/wrun-run-interval-session.util.js +25 -0
  51. package/dist/utility/wrun/wrun-run-interval.util.d.ts +52 -5
  52. package/dist/utility/wrun/wrun-run-interval.util.js +88 -7
  53. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +4 -7
  54. package/dist/utility/wrun/wrun-script-inputs.util.js +6 -33
  55. package/package.json +1 -1
@@ -92,6 +92,24 @@ export declare function wrunRunIntervalCoverageKey(run: Pick<OverlayRunInterval,
92
92
  * its session open (a CME trade date is stamped after its own evening bars, and its forming bar
93
93
  * passes from that open on). The same array when every row passes. */
94
94
  export declare function wrunRunIntervalRowsThrough(run: RunBarCalendar, rows: ReadonlyArray<ArrayLike<number>>, lastChartTs: number): ArrayLike<number>[];
95
+ /**
96
+ * The median gap between the stamps of rows answered to a run ask when it is under 0.75 of the run interval (the rows
97
+ * are finer than the run asked: another interval's candles), else null. Missing bars, closed sessions, weekends and
98
+ * session lattices only widen gaps, so they never trip it; fewer than 3 rows prove nothing.
99
+ */
100
+ export declare function wrunRunIntervalRowsFinerThanRun(run: Pick<OverlayRunInterval, 'intervalMs'>, rows: ReadonlyArray<ArrayLike<number>>): number | null;
101
+ /**
102
+ * The one door a fetched answer takes into a session's run bars, on the full run and on the live re-ask alike: the rows
103
+ * cut at the chart's newest bar (`wrunRunIntervalRowsThrough`), or `finerGapMs` when they are another interval's candles
104
+ * (`wrunRunIntervalRowsFinerThanRun`). A refused answer is never merged and never computed on.
105
+ */
106
+ export declare function wrunRunIntervalAnswer(run: RunBarCalendar & Pick<OverlayRunInterval, 'intervalMs'>, rows: ReadonlyArray<ArrayLike<number>>, lastChartTs: number): {
107
+ rows: ArrayLike<number>[];
108
+ finerGapMs?: undefined;
109
+ } | {
110
+ rows?: undefined;
111
+ finerGapMs: number;
112
+ };
95
113
  /**
96
114
  * The run bars a session computes over at the chart's newest bar. Wait for close on: the closed
97
115
  * ones only (a run bar closes once the chart shows a bar at or past its close), so every output the
@@ -75,6 +75,31 @@ export function wrunRunIntervalRowsThrough(run, rows, lastChartTs) {
75
75
  end -= 1;
76
76
  return end === rows.length ? rows : rows.slice(0, end);
77
77
  }
78
+ /**
79
+ * The median gap between the stamps of rows answered to a run ask when it is under 0.75 of the run interval (the rows
80
+ * are finer than the run asked: another interval's candles), else null. Missing bars, closed sessions, weekends and
81
+ * session lattices only widen gaps, so they never trip it; fewer than 3 rows prove nothing.
82
+ */
83
+ export function wrunRunIntervalRowsFinerThanRun(run, rows) {
84
+ if (rows.length < 3 || !(run.intervalMs > 0))
85
+ return null;
86
+ const gaps = [];
87
+ for (let at = 1; at < rows.length; at += 1)
88
+ gaps.push(Number(rows[at][0]) - Number(rows[at - 1][0]));
89
+ gaps.sort((a, b) => a - b);
90
+ const mid = gaps.length >> 1;
91
+ const median = gaps.length % 2 === 1 ? gaps[mid] : (gaps[mid - 1] + gaps[mid]) / 2;
92
+ return median < 0.75 * run.intervalMs ? median : null;
93
+ }
94
+ /**
95
+ * The one door a fetched answer takes into a session's run bars, on the full run and on the live re-ask alike: the rows
96
+ * cut at the chart's newest bar (`wrunRunIntervalRowsThrough`), or `finerGapMs` when they are another interval's candles
97
+ * (`wrunRunIntervalRowsFinerThanRun`). A refused answer is never merged and never computed on.
98
+ */
99
+ export function wrunRunIntervalAnswer(run, rows, lastChartTs) {
100
+ const finerGapMs = wrunRunIntervalRowsFinerThanRun(run, rows);
101
+ return finerGapMs === null ? { rows: wrunRunIntervalRowsThrough(run, rows, lastChartTs) } : { finerGapMs };
102
+ }
78
103
  /**
79
104
  * The run bars a session computes over at the chart's newest bar. Wait for close on: the closed
80
105
  * ones only (a run bar closes once the chart shows a bar at or past its close), so every output the
@@ -1,4 +1,5 @@
1
1
  import { type OverlayRunInterval } from '../chart/indicator-run-interval.util.js';
2
+ import { liveBucketVenueOf } from '../chart/live-bucket.util.js';
2
3
  /** The chart's session fields a replaying chart's session market reads (isWrunRunIntervalSessionMarket). */
3
4
  export interface WrunChartSessionFields {
4
5
  symbol?: unknown;
@@ -33,6 +34,21 @@ export declare const WRUN_RUN_INTERVAL_TWINS: Readonly<Record<string, (settings:
33
34
  * own bars hands it to the warm-up ask as the declared lookback (local-kscript-warmup-backfill-ask.util).
34
35
  */
35
36
  export declare function wrunTwinLookbackBars(settings: unknown): number | null;
37
+ /**
38
+ * A proven twin's lookback in bars of the CHART, for the readers that size the chart's own history from it (the
39
+ * warm-up page decider): wrunTwinLookbackBars counts Timeframe bars, which a run at the Timeframe reads as its own
40
+ * bars, but where the package keeps its own path (`run` null: replay, a formula chart, a prediction market, an
41
+ * index-mode venue that keeps it) it rebuilds a coarser Timeframe from the chart's bars, so each Timeframe bar costs
42
+ * `ceil(timeframe / chart)` of them, plus the partial first one (selectedTimeframeHistoryBars, the alert bake's same
43
+ * count): a 20 SMA at 1W on a 1h chart needs 3,528 chart bars, never 20. A Timeframe at or below the chart's is the
44
+ * chart's own: the lookback as is. Null for an overlay with no twin lookback. The readers keep their own caps.
45
+ */
46
+ export declare function wrunTwinChartLookbackBars(settings: unknown, chartInterval: unknown, run: Pick<OverlayRunInterval, 'intervalMs'> | null): number | null;
47
+ /** A proven twin's own Timeframe when it is coarser than `interval` (a key or ms), with the lookback its settings need
48
+ * in Timeframe bars (wrunTwinLookbackBars); undefined for any other overlay or selection. */
49
+ export declare function wrunTwinCoarserTimeframe(settings: unknown, interval: unknown): (Pick<OverlayRunInterval, 'interval' | 'intervalMs'> & {
50
+ lookbackBars: number;
51
+ }) | undefined;
36
52
  /** A wrun overlay's run interval: the kScript shape plus the warm-up its settings need, in run bars. */
37
53
  export interface WrunRunInterval extends OverlayRunInterval {
38
54
  warmupBars: number;
@@ -42,10 +58,16 @@ export interface WrunRunIntervalInput {
42
58
  settings: unknown;
43
59
  /** The chart's interval, as a key ("5m") or milliseconds. */
44
60
  chartInterval: unknown;
45
- /** Market replay keeps the package's own path, except on a session market (`sessionMarket`). */
61
+ /** Market replay keeps the package's own path, except on a session market (`sessionMarket`) off index mode. */
46
62
  replay?: boolean;
47
- /** An index-mode chart (forex, equities, DEX) keeps the package's own path. */
63
+ /**
64
+ * An index-mode chart (stocks, forex, the index venue, DEX pools, the commodity venues): it keeps the package's own
65
+ * path in market replay, a session market too (forex rides a session lattice), and live unless `indexModeRunPath`.
66
+ * Read both from the venue with wrunIndexModeInput.
67
+ */
48
68
  indexMode?: boolean;
69
+ /** An index-mode chart of a family that runs at its interval live (wrunIndexModeKeepsPackagePath false). */
70
+ indexModeRunPath?: boolean;
49
71
  /**
50
72
  * A market whose run bars one candle ask at the chart's venue and symbol cannot reproduce keeps the
51
73
  * package's own path: a formula chart (several legs) or a prediction market (event-sparse candles
@@ -78,13 +100,27 @@ export declare function wrunTimeframeLabel(settings: unknown): string | undefine
78
100
  export declare function wrunTimeframeIsChartOrFiner(settings: unknown, chartInterval: unknown): boolean;
79
101
  /** Whether a twin waits for the selected bar to close (the param defaults on). */
80
102
  export declare function wrunWaitsForClose(settings: unknown): boolean;
103
+ /**
104
+ * Whether an index-mode chart keeps the package's own path for a coarser Timeframe live (the package rebuilds the
105
+ * Timeframe from the chart's loaded bars): every index-mode venue outside the measured families
106
+ * (WRUN_RUN_PATH_INDEX_MODE_FAMILIES). Not measured, so not moved: a DEX pool's candle ask needs its pool identity
107
+ * (a pool address and a chain), which one ask at the chart's venue and symbol does not carry, and no commodity venue
108
+ * chart (`ICE`, `LBMA`, a CME-governed venue failing closed to commodity) could be mounted on the rig. A venue the
109
+ * index-mode set holds outside every family keeps it too until someone decides (indexModeFamilyOf undefined).
110
+ * Where it holds, the history loader counts the twin's lookback in chart bars (wrunTwinChartLookbackBars).
111
+ */
112
+ export declare function wrunIndexModeKeepsPackagePath(exchange: string | undefined): boolean;
113
+ /** The index-mode fields of a run-interval input for the chart's venue: the one place they are read. */
114
+ export declare function wrunIndexModeInput(exchange: string | undefined): Pick<WrunRunIntervalInput, 'indexMode' | 'indexModeRunPath'>;
81
115
  /**
82
116
  * The interval a wrun overlay's package runs at when it is coarser than the chart's, else null (the
83
117
  * package runs on the chart's bars, as before): a proven twin listed in WRUN_RUN_INTERVAL_TWINS,
84
- * off index mode and the markets one candle ask cannot serve (`unsupportedMarket`), live or in
85
- * replay on a session market (`sessionMarket`, the live run's bars), whose timeframe selects an
118
+ * off the markets one candle ask cannot serve (`unsupportedMarket`) and the index-mode venues that keep
119
+ * the package's own path (`indexModeRunPath` false: wrunIndexModeKeepsPackagePath), live or in
120
+ * replay on a session market (`sessionMarket`, the live run's bars) off index mode, whose timeframe selects an
86
121
  * interval coarser than the chart. A selection at or below the chart's interval is the chart's own
87
- * (wrunTimeframeIsChartOrFiner).
122
+ * (wrunTimeframeIsChartOrFiner). Market replay on any index-mode chart keeps the package's own path, as it always
123
+ * did: forex rides a session lattice, but its replay was never moved or measured.
88
124
  */
89
125
  export declare function resolveWrunRunInterval(input: WrunRunIntervalInput): WrunRunInterval | null;
90
126
  /** Whether one candle ask at the chart's venue and symbol cannot stand in for the chart's own series
@@ -124,6 +160,17 @@ export declare function overlayWrunRunInterval(chartIndex: number, overlay: {
124
160
  export declare function liveOverlayWrunRunInterval(overlay: {
125
161
  settings?: unknown;
126
162
  } | null | undefined, chartInterval: unknown, chartExchange?: string | null, chartTransformations?: string | null, chartMarket?: WrunChartSessionFields | null): WrunRunInterval | null;
163
+ /**
164
+ * Whether the chart venue's own bars at `intervalMs` open anywhere off the clock grid (`fixedGridFloorMs`), as the
165
+ * single grid authority places them (`liveBucketStartMs`) over the week before `nowMs`: a regular-session stock's
166
+ * 1h and 4h bars anchored on the session open, forex's 4h bars on the 17:00 New York lattice. The kit's resampler
167
+ * keys a Timeframe under a day as floor(t / width) on the clock (sdk/resample.ts), so where this holds, an alert
168
+ * that rebuilds the Timeframe from chart bars computes on other candles than a run at the interval draws
169
+ * (alert-overlay-target `timeframe-candles`). A grid that is one fixed lattice of the interval (liveBucketBarsOnUtcLattice)
170
+ * answers without the walk; else one probe per bar length finds every bar, since each probe lands in one. `nowMs`
171
+ * defaults to the server clock; specs pin it.
172
+ */
173
+ export declare function wrunRunBarsOffClockGrid(intervalMs: number, chart: Parameters<typeof liveBucketVenueOf>[0], nowMs?: number): boolean;
127
174
  /**
128
175
  * The settings a run at another interval sends the package: the twin's `timeframe` forced to its
129
176
  * chart option, on a copy. Only the values the package computes with (the init args); the
@@ -38,10 +38,13 @@
38
38
  import { wrunChartHostEnv } from '../../host-env.js';
39
39
  import { runIntervalOfTimeframeLabel, timeframeIsChartOrFiner, } from '../chart/indicator-run-interval.util.js';
40
40
  import { sessionLatticeOf } from '../chart/session-lattice.util.js';
41
- import { checkIsIndexMode } from '../chart/index-mode.util.js';
41
+ import { fixedGridFloorMs } from '../chart/calendar-interval.util.js';
42
+ import { liveBucketBarsOnUtcLattice, liveBucketStartMs, liveBucketVenueOf } from '../chart/live-bucket.util.js';
43
+ import { serverNowMs } from '../auth/server-clock.util.js';
44
+ import { checkIsIndexMode, indexModeFamilyOf } from '../chart/index-mode.util.js';
42
45
  import { chartIntervalToMs } from '../chart/rth-session.util.js';
43
46
  import { isRunIntervalUnservableMarket } from '../chart/run-interval-unservable.leaf.js';
44
- import { runIntervalWarmupBars } from '../chart/run-interval-warmup.leaf.js';
47
+ import { runIntervalWarmupBars, selectedTimeframeHistoryBars } from '../chart/run-interval-warmup.leaf.js';
45
48
  import { builtinPortOf } from './wrun-builtin-twin.util.js';
46
49
  import { wrunBarsSessionFiltered } from './wrun-run-interval-session.util.js';
47
50
  /** The param a twin selects its timeframe with, and the one that says whether to wait for closes. */
@@ -122,6 +125,32 @@ export function wrunTwinLookbackBars(settings) {
122
125
  const lookback = twin ? WRUN_RUN_INTERVAL_TWINS[twin] : undefined;
123
126
  return lookback ? lookback(settings) : null;
124
127
  }
128
+ /**
129
+ * A proven twin's lookback in bars of the CHART, for the readers that size the chart's own history from it (the
130
+ * warm-up page decider): wrunTwinLookbackBars counts Timeframe bars, which a run at the Timeframe reads as its own
131
+ * bars, but where the package keeps its own path (`run` null: replay, a formula chart, a prediction market, an
132
+ * index-mode venue that keeps it) it rebuilds a coarser Timeframe from the chart's bars, so each Timeframe bar costs
133
+ * `ceil(timeframe / chart)` of them, plus the partial first one (selectedTimeframeHistoryBars, the alert bake's same
134
+ * count): a 20 SMA at 1W on a 1h chart needs 3,528 chart bars, never 20. A Timeframe at or below the chart's is the
135
+ * chart's own: the lookback as is. Null for an overlay with no twin lookback. The readers keep their own caps.
136
+ */
137
+ export function wrunTwinChartLookbackBars(settings, chartInterval, run) {
138
+ const lookback = wrunTwinLookbackBars(settings);
139
+ if (lookback === null || run !== null)
140
+ return lookback;
141
+ const timeframe = wrunTwinCoarserTimeframe(settings, chartInterval);
142
+ const chartMs = chartIntervalToMs(chartInterval);
143
+ if (!timeframe || chartMs === undefined || !(chartMs > 0))
144
+ return lookback;
145
+ return selectedTimeframeHistoryBars(lookback, timeframe.intervalMs, chartMs);
146
+ }
147
+ /** A proven twin's own Timeframe when it is coarser than `interval` (a key or ms), with the lookback its settings need
148
+ * in Timeframe bars (wrunTwinLookbackBars); undefined for any other overlay or selection. */
149
+ export function wrunTwinCoarserTimeframe(settings, interval) {
150
+ const lookbackBars = wrunTwinLookbackBars(settings);
151
+ const timeframe = lookbackBars === null ? null : runIntervalOfTimeframeLabel(wrunTimeframeLabel(settings), interval);
152
+ return timeframe && lookbackBars !== null ? { ...timeframe, lookbackBars } : undefined;
153
+ }
125
154
  /** The label of the timeframe option a twin's settings select: through its persisted select's
126
155
  * `optionLabels`, else the twins' fixed list. Undefined when unreadable. */
127
156
  export function wrunTimeframeLabel(settings) {
@@ -163,16 +192,46 @@ export function wrunWaitsForClose(settings) {
163
192
  const value = settings && typeof settings === 'object' ? settings[WRUN_WAIT_FOR_CLOSE_PARAM] : undefined;
164
193
  return !(value === false || value === 0 || value === '0' || value === 'false');
165
194
  }
195
+ /** The index-mode families whose charts run a twin at its interval live: each measured on a real chart, every finer
196
+ * chart's newest bar equal to the reference chart's own (2026-11-18, INT): US stocks (`POLYGON`, SPY and AAPL),
197
+ * forex (`FX_OTC` EUR/USD) and the index venue (`INDICES_OTC` US500). */
198
+ const WRUN_RUN_PATH_INDEX_MODE_FAMILIES = new Set(['stocks', 'forex', 'index']);
199
+ /**
200
+ * Whether an index-mode chart keeps the package's own path for a coarser Timeframe live (the package rebuilds the
201
+ * Timeframe from the chart's loaded bars): every index-mode venue outside the measured families
202
+ * (WRUN_RUN_PATH_INDEX_MODE_FAMILIES). Not measured, so not moved: a DEX pool's candle ask needs its pool identity
203
+ * (a pool address and a chain), which one ask at the chart's venue and symbol does not carry, and no commodity venue
204
+ * chart (`ICE`, `LBMA`, a CME-governed venue failing closed to commodity) could be mounted on the rig. A venue the
205
+ * index-mode set holds outside every family keeps it too until someone decides (indexModeFamilyOf undefined).
206
+ * Where it holds, the history loader counts the twin's lookback in chart bars (wrunTwinChartLookbackBars).
207
+ */
208
+ export function wrunIndexModeKeepsPackagePath(exchange) {
209
+ if (!checkIsIndexMode(exchange))
210
+ return false;
211
+ const family = indexModeFamilyOf(exchange);
212
+ return family === undefined || !WRUN_RUN_PATH_INDEX_MODE_FAMILIES.has(family);
213
+ }
214
+ /** The index-mode fields of a run-interval input for the chart's venue: the one place they are read. */
215
+ export function wrunIndexModeInput(exchange) {
216
+ const indexMode = checkIsIndexMode(exchange);
217
+ return { indexMode, indexModeRunPath: indexMode && !wrunIndexModeKeepsPackagePath(exchange) };
218
+ }
166
219
  /**
167
220
  * The interval a wrun overlay's package runs at when it is coarser than the chart's, else null (the
168
221
  * package runs on the chart's bars, as before): a proven twin listed in WRUN_RUN_INTERVAL_TWINS,
169
- * off index mode and the markets one candle ask cannot serve (`unsupportedMarket`), live or in
170
- * replay on a session market (`sessionMarket`, the live run's bars), whose timeframe selects an
222
+ * off the markets one candle ask cannot serve (`unsupportedMarket`) and the index-mode venues that keep
223
+ * the package's own path (`indexModeRunPath` false: wrunIndexModeKeepsPackagePath), live or in
224
+ * replay on a session market (`sessionMarket`, the live run's bars) off index mode, whose timeframe selects an
171
225
  * interval coarser than the chart. A selection at or below the chart's interval is the chart's own
172
- * (wrunTimeframeIsChartOrFiner).
226
+ * (wrunTimeframeIsChartOrFiner). Market replay on any index-mode chart keeps the package's own path, as it always
227
+ * did: forex rides a session lattice, but its replay was never moved or measured.
173
228
  */
174
229
  export function resolveWrunRunInterval(input) {
175
- if (input.indexMode || input.unsupportedMarket || (input.replay && !input.sessionMarket))
230
+ if (input.unsupportedMarket)
231
+ return null;
232
+ if (input.indexMode && (input.replay || !input.indexModeRunPath))
233
+ return null;
234
+ if (input.replay && !input.sessionMarket)
176
235
  return null;
177
236
  const lookbackBars = wrunTwinLookbackBars(input.settings);
178
237
  if (lookbackBars === null)
@@ -235,13 +294,35 @@ function overlayRunIntervalUnder(replay, overlay, chartInterval, chartExchange,
235
294
  settings,
236
295
  chartInterval,
237
296
  replay,
238
- indexMode: checkIsIndexMode(venue),
297
+ ...wrunIndexModeInput(venue),
239
298
  unsupportedMarket: isWrunRunIntervalUnsupportedMarket(venue, chartTransformations),
240
299
  sessionMarket: isWrunRunIntervalSessionMarket(venue, chartMarket, chartInterval),
241
300
  });
242
301
  const lattice = run ? sessionLatticeOf(venue) : null;
243
302
  return run && lattice !== null ? { ...run, sessionLattice: true, sessionLatticeId: lattice.id } : run;
244
303
  }
304
+ const CLOCK_GRID_PROBE_SPAN_MS = 7 * 86_400_000;
305
+ /**
306
+ * Whether the chart venue's own bars at `intervalMs` open anywhere off the clock grid (`fixedGridFloorMs`), as the
307
+ * single grid authority places them (`liveBucketStartMs`) over the week before `nowMs`: a regular-session stock's
308
+ * 1h and 4h bars anchored on the session open, forex's 4h bars on the 17:00 New York lattice. The kit's resampler
309
+ * keys a Timeframe under a day as floor(t / width) on the clock (sdk/resample.ts), so where this holds, an alert
310
+ * that rebuilds the Timeframe from chart bars computes on other candles than a run at the interval draws
311
+ * (alert-overlay-target `timeframe-candles`). A grid that is one fixed lattice of the interval (liveBucketBarsOnUtcLattice)
312
+ * answers without the walk; else one probe per bar length finds every bar, since each probe lands in one. `nowMs`
313
+ * defaults to the server clock; specs pin it.
314
+ */
315
+ export function wrunRunBarsOffClockGrid(intervalMs, chart, nowMs = serverNowMs()) {
316
+ const venue = liveBucketVenueOf(chart);
317
+ if (liveBucketBarsOnUtcLattice(intervalMs, venue))
318
+ return false;
319
+ for (let tsMs = nowMs - CLOCK_GRID_PROBE_SPAN_MS; tsMs <= nowMs; tsMs += intervalMs) {
320
+ const start = liveBucketStartMs(tsMs, intervalMs, venue);
321
+ if (start !== null && fixedGridFloorMs(start, intervalMs) !== start)
322
+ return true;
323
+ }
324
+ return false;
325
+ }
245
326
  /**
246
327
  * The settings a run at another interval sends the package: the twin's `timeframe` forced to its
247
328
  * chart option, on a copy. Only the values the package computes with (the init args); the
@@ -112,6 +112,8 @@
112
112
  import type { WrunIndicatorMetadata, WrunMetadataParam, WrunParamHost, WrunParamType, WrunPreset, WrunVisibleBy } from '../../interfaces/wrun-runtime.interface.js';
113
113
  import { type WrunVisibilitySheet, type WrunVisibilityTarget } from './wrun-visibility-table.js';
114
114
  import { type WrunWordsShape } from './wrun-setting-words.util.js';
115
+ import { wrunMarketScaledRowChanged } from './wrun-market-size-defaults.leaf.js';
116
+ import { wrunRowValuesEqual, wrunValuesEqual } from './wrun-row-scalars.leaf.js';
115
117
  export { wrunParamChoices, type WrunParamChoice } from './wrun-color-settings.util.js';
116
118
  /** The page every param before the first `page()` (and every ungrouped
117
119
  * param of a sheet without `layout`) lands on. */
@@ -444,6 +446,7 @@ export declare function coerceWrunRowValue(row: WrunScriptInputDeclaration, raw:
444
446
  * The run head's market-scaled defaults (wrun-market-size-defaults.util) read
445
447
  * a row through it too, so "unchanged" there is the reset icon's own test. */
446
448
  export declare function wrunRowValue(settings: Readonly<Record<string, unknown>>, row: WrunScriptInputDeclaration): unknown;
449
+ export { wrunMarketScaledRowChanged };
447
450
  /**
448
451
  * A `when` gate read apart (a param's or a layout section's, the typed-inputs key; the clause forms joined the
449
452
  * bare name on 2026-10-25 with the om SDK, settings no-op audit SC4): `"<param>"` holds while the param's value is
@@ -479,13 +482,7 @@ export declare function wrunWhenGateNumber(gate: WrunScriptInputDeclaration | un
479
482
  * panel cannot explain hides a live control, which is the class this grammar exists to end.
480
483
  */
481
484
  export declare function wrunWhenActive(settings: Readonly<Record<string, unknown>>, when: unknown, gateOf: (name: string) => WrunScriptInputDeclaration | undefined): boolean;
482
- /** Equality the way the run reads values back: a toggle as 1/0, a select's
483
- * numeric string as its number, a colour array element by element. */
484
- export declare function wrunValuesEqual(a: unknown, b: unknown): boolean;
485
- /** Equality for one row's value: a text row compares its words exactly (a
486
- * typed "20" is not the number 20, "Abc" is not "abc"); every other kind
487
- * the way the run reads values back ({@link wrunValuesEqual}). */
488
- export declare function wrunRowValuesEqual(row: WrunScriptInputDeclaration, a: unknown, b: unknown): boolean;
485
+ export { wrunRowValuesEqual, wrunValuesEqual };
489
486
  /**
490
487
  * A preset's values in the dialog's storage types (frozen contract, plan
491
488
  * 1.2): a toggle a boolean, a select its numeric option string (a label or
@@ -121,6 +121,8 @@ import { wrunStyleNameOf, wrunStyleSlotNames, wrunStyleTitle } from './wrun-styl
121
121
  import { wrunRowVisibleHere, wrunVisibleBySettingKeys } from './wrun-market-facts.util.js';
122
122
  import { bitmaskValue, finiteNumber, nonEmptyString, numericValue, toggleValue, wrunMultiLabels, wrunTimeValue, } from './wrun-param-values.util.js';
123
123
  import { wrunLegendLiteral, wrunTextParamCap, wrunTextParamDefault, wrunTextValueWithinCap, } from './wrun-text-params.util.js';
124
+ import { wrunMarketScaledRowChanged } from './wrun-market-size-defaults.leaf.js';
125
+ import { wrunRowValuesEqual, wrunValuesEqual } from './wrun-row-scalars.leaf.js';
124
126
  // The choice set and the one select read live beside the other settings
125
127
  // readers (wrun-color-settings.util, the sheet seam's module); the builders
126
128
  // here and their callers keep importing them from this module.
@@ -1990,6 +1992,8 @@ export function wrunRowValue(settings, row) {
1990
1992
  const fit = stored === undefined || stored === null ? undefined : coerceWrunRowValue(row, stored);
1991
1993
  return fit ?? row.defaultValue;
1992
1994
  }
1995
+ // The run head's "typed" test lives in the market size leaf (settings-templates reads it); re-exported here.
1996
+ export { wrunMarketScaledRowChanged };
1993
1997
  /** A param name inside a clause: no whitespace, no operator character (a sheet name never holds one). */
1994
1998
  const WHEN_PARAM = '[^\\s!=,]+';
1995
1999
  const WHEN_FALSY_RE = new RegExp(`^!\\s*(${WHEN_PARAM})$`);
@@ -2088,39 +2092,8 @@ export function wrunWhenActive(settings, when, gateOf) {
2088
2092
  return clause.values[0] !== number;
2089
2093
  return clause.values.includes(number);
2090
2094
  }
2091
- function normalizeRowScalar(value) {
2092
- if (typeof value === 'boolean')
2093
- return value ? 1 : 0;
2094
- if (typeof value === 'string') {
2095
- const trimmed = value.trim();
2096
- if (trimmed !== '' && Number.isFinite(Number(trimmed)))
2097
- return Number(trimmed);
2098
- return value;
2099
- }
2100
- return value;
2101
- }
2102
- /** Equality the way the run reads values back: a toggle as 1/0, a select's
2103
- * numeric string as its number, a colour array element by element. */
2104
- export function wrunValuesEqual(a, b) {
2105
- if (Array.isArray(a) || Array.isArray(b)) {
2106
- if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length)
2107
- return false;
2108
- return a.every((item, index) => wrunValuesEqual(item, b[index]));
2109
- }
2110
- const left = normalizeRowScalar(a);
2111
- const right = normalizeRowScalar(b);
2112
- if (typeof left === 'string' && typeof right === 'string')
2113
- return left.toLowerCase() === right.toLowerCase();
2114
- return left === right;
2115
- }
2116
- /** Equality for one row's value: a text row compares its words exactly (a
2117
- * typed "20" is not the number 20, "Abc" is not "abc"); every other kind
2118
- * the way the run reads values back ({@link wrunValuesEqual}). */
2119
- export function wrunRowValuesEqual(row, a, b) {
2120
- if (row.type === 'text')
2121
- return String(a ?? '') === String(b ?? '');
2122
- return wrunValuesEqual(a, b);
2123
- }
2095
+ // The value equality lives in the import-free row scalars leaf (settings-templates reads it); re-exported here.
2096
+ export { wrunRowValuesEqual, wrunValuesEqual };
2124
2097
  /** A `colors` style row's value: exactly its declared swatches, element i
2125
2098
  * the stored colour (a colour setting or a theme token) else the swatch's
2126
2099
  * default, so no swatch shifts; a stored list with no usable element is no
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orangecharts/wrun-chart-host",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "The wrun chart-host layer shared by the kiyotaka web app and the mobile app: the wrun result reader and painter model, cut from the web app (its reference implementation).",
5
5
  "type": "module",
6
6
  "files": [