@orangecharts/wrun-chart-host 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/constants/economic.constants.d.ts +2 -0
- package/dist/constants/economic.constants.js +2 -0
- package/dist/constants/feature-flags.constants.d.ts +11 -0
- package/dist/constants/feature-flags.constants.js +56 -4
- package/dist/constants/feature-limits.constants.d.ts +72 -4
- package/dist/constants/feature-limits.constants.js +98 -20
- package/dist/constants/interval.constants.js +5 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +12 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.js +14 -0
- package/dist/constants/typed-width-fold.leaf.d.ts +50 -0
- package/dist/constants/typed-width-fold.leaf.js +99 -0
- package/dist/constants/typed-width-source.leaf.d.ts +24 -0
- package/dist/constants/typed-width-source.leaf.js +126 -0
- package/dist/constants/typed-width.leaf.d.ts +57 -0
- package/dist/constants/typed-width.leaf.js +78 -0
- package/dist/host-env.d.ts +24 -0
- package/dist/host-env.js +22 -0
- package/dist/host-ports.types.d.ts +11 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +28 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +107 -4
- package/dist/interfaces/wrun-runtime.interface.js +11 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
- package/dist/market-data/billing.interface.d.ts +12 -45
- package/dist/market-data/billing.interface.js +2 -2
- package/dist/market-data/venues/index.d.ts +2 -2
- package/dist/market-data/venues/opra.js +3 -3
- package/dist/market-data/venues/stocks.contract.copy.json +3 -2
- package/dist/market-data/venues/stocks.d.ts +2 -2
- package/dist/market-data/venues/stocks.js +10 -9
- package/dist/replay/replayLadder.js +7 -4
- package/dist/settings-templates/footprint-rows.d.ts +6 -0
- package/dist/settings-templates/footprint-rows.js +6 -0
- package/dist/settings-templates/frvp-fields.js +14 -0
- package/dist/settings-templates/indicator-fields.js +46 -0
- package/dist/settings-templates/tool-tables.generated.js +19 -1
- package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
- package/dist/utility/chart/cache-alignment.util.d.ts +65 -0
- package/dist/utility/chart/cache-alignment.util.js +124 -24
- package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
- package/dist/utility/chart/calendar-interval.util.js +152 -4
- package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
- package/dist/utility/chart/candle-bar-end.util.js +17 -6
- package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
- package/dist/utility/chart/chart-time-domain.util.js +13 -4
- package/dist/utility/chart/feed-interval.util.d.ts +4 -2
- package/dist/utility/chart/feed-interval.util.js +5 -2
- package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
- package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
- package/dist/utility/chart/footprint-band.util.d.ts +21 -5
- package/dist/utility/chart/footprint-band.util.js +53 -14
- package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
- package/dist/utility/chart/footprint-display-mode.util.js +5 -0
- package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
- package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
- package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
- package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
- package/dist/utility/chart/history-wall.util.d.ts +13 -2
- package/dist/utility/chart/history-wall.util.js +11 -4
- package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
- package/dist/utility/chart/interval-ladder.util.js +44 -4
- package/dist/utility/chart/interval-registry.util.d.ts +22 -1
- package/dist/utility/chart/interval-registry.util.js +50 -2
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
- package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
- package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
- package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
- package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
- package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
- package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
- package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
- package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
- package/dist/utility/chart/live-bucket.util.d.ts +29 -4
- package/dist/utility/chart/live-bucket.util.js +45 -12
- package/dist/utility/chart/market-session.util.d.ts +62 -10
- package/dist/utility/chart/market-session.util.js +93 -13
- package/dist/utility/chart/marketKind.util.d.ts +1 -7
- package/dist/utility/chart/marketKind.util.js +6 -8
- package/dist/utility/chart/mixed-mode.util.d.ts +17 -0
- package/dist/utility/chart/om-target.util.js +6 -4
- package/dist/utility/chart/price-precision.util.d.ts +20 -6
- package/dist/utility/chart/price-precision.util.js +34 -7
- package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
- package/dist/utility/chart/profile-frame-window.util.js +12 -0
- package/dist/utility/chart/rth-session.util.d.ts +3 -1
- package/dist/utility/chart/rth-session.util.js +3 -1
- package/dist/utility/chart/script-source-session.util.d.ts +43 -0
- package/dist/utility/chart/script-source-session.util.js +61 -0
- package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
- package/dist/utility/chart/typed-width-grid.util.js +203 -0
- package/dist/utility/chart/wrun-run-result.util.d.ts +9 -1
- package/dist/utility/chart/wrun-run-result.util.js +8 -2
- package/dist/utility/common/transformations.util.d.ts +6 -0
- package/dist/utility/common/transformations.util.js +28 -4
- package/dist/utility/number-format.util.d.ts +14 -1
- package/dist/utility/number-format.util.js +22 -4
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +113 -0
- package/dist/utility/v2/v2-enums.leaf.js +3 -0
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +15 -5
- package/dist/utility/wrun/wrun-batched-marks.util.js +70 -20
- package/dist/utility/wrun/wrun-canvases.util.d.ts +28 -9
- package/dist/utility/wrun/wrun-canvases.util.js +99 -39
- package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
- package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
- package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-card-style.util.js +2 -2
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +8 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +13 -1
- package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
- package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
- package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
- package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
- package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
- package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
- package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
- package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
- package/dist/utility/wrun/wrun-frames.d.ts +1 -1
- package/dist/utility/wrun/wrun-frames.js +2 -2
- package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-handles.util.js +1 -1
- package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
- package/dist/utility/wrun/wrun-host.service.js +44 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
- package/dist/utility/wrun/wrun-hover.util.d.ts +8 -2
- package/dist/utility/wrun/wrun-hover.util.js +24 -13
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
- package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
- package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
- package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
- package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
- package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
- package/dist/utility/wrun/wrun-live-tick.util.js +81 -19
- package/dist/utility/wrun/wrun-output-words.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-output-words.util.js +51 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +41 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +35 -0
- package/dist/utility/wrun/wrun-overlay-result.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +23 -2
- package/dist/utility/wrun/wrun-overlay-run.util.js +305 -51
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +10 -2
- package/dist/utility/wrun/wrun-panel-mount.util.js +144 -18
- package/dist/utility/wrun/wrun-pin-venues.util.js +5 -1
- package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-refusal.util.js +102 -13
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
- package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
- package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
- package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
- package/dist/utility/wrun/wrun-run-health.util.d.ts +6 -3
- package/dist/utility/wrun/wrun-run-health.util.js +5 -2
- package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
- package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +25 -8
- package/dist/utility/wrun/wrun-script-inputs.util.js +145 -45
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
- package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
- package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
- package/dist/utility/wrun/wrun-style-names.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-style-names.util.js +74 -0
- package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
- package/dist/utility/wrun/wrun-style-words.util.js +46 -15
- package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
- package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
- package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
- package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
- package/dist/utility/wrun-display-name.util.d.ts +10 -0
- package/dist/utility/wrun-display-name.util.js +21 -0
- package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
- package/dist/utils/replay/replay-buffer-math.js +2 -0
- package/dist/workers/constants/socket-slots.d.ts +1 -1
- package/dist/workers/utils/time.worker.util.js +2 -2
- package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
- package/dist/workers/utils/volume-profile.worker.util.js +20 -0
- package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
- package/dist/workers/wrun/wrun-abi-host.js +82 -5
- package/dist/workers/wrun/wrun-engine-handler.js +53 -4
- package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
- package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
- package/package.json +11 -11
|
@@ -7,9 +7,16 @@
|
|
|
7
7
|
* function.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
10
|
+
* True for exactly the 35 typed day and week bar lengths: whole days 2 to 20 but 3 (the `3d` rung) and 7 (`1w`), and
|
|
11
|
+
* whole weeks 2 to 20. By arithmetic, no table. calendar-interval.util re-exports it; it lives in this leaf so the bar
|
|
12
|
+
* close below reads it without an import.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isTypedDayWeekMs(ms: number): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* When the bar that opens at `tsMs` closes. Sub-month grids and the typed day
|
|
17
|
+
* and week sizes (4w to 20w are 28 days or longer) are fixed-length; month,
|
|
18
|
+
* quarter and year bars follow the calendar (a 31-day month outlives the
|
|
19
|
+
* average-month `intervalMs` the chart carries, and a 28 or 30 day month ends
|
|
20
|
+
* before it). Every other length of 28 days or longer keeps the calendar rule.
|
|
14
21
|
*/
|
|
15
22
|
export declare function candleBarEndMs(tsMs: number, intervalMs: number): number;
|
|
@@ -6,16 +6,27 @@
|
|
|
6
6
|
* daily-lane helper (`wrun-daily-lane.util`, on the row builder's import graph) share this one
|
|
7
7
|
* function.
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
9
|
+
const DAY_MS = 86_400_000;
|
|
10
|
+
const MONTH_CLASS_MS = 28 * DAY_MS;
|
|
10
11
|
const AVERAGE_MONTH_MS = 2_629_800_000;
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
|
|
13
|
+
* True for exactly the 35 typed day and week bar lengths: whole days 2 to 20 but 3 (the `3d` rung) and 7 (`1w`), and
|
|
14
|
+
* whole weeks 2 to 20. By arithmetic, no table. calendar-interval.util re-exports it; it lives in this leaf so the bar
|
|
15
|
+
* close below reads it without an import.
|
|
16
|
+
*/
|
|
17
|
+
export function isTypedDayWeekMs(ms) {
|
|
18
|
+
const days = ms / DAY_MS;
|
|
19
|
+
return Number.isInteger(days) && (days % 7 ? days >= 2 && days <= 20 && days !== 3 : days >= 14 && days <= 140);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* When the bar that opens at `tsMs` closes. Sub-month grids and the typed day
|
|
23
|
+
* and week sizes (4w to 20w are 28 days or longer) are fixed-length; month,
|
|
24
|
+
* quarter and year bars follow the calendar (a 31-day month outlives the
|
|
25
|
+
* average-month `intervalMs` the chart carries, and a 28 or 30 day month ends
|
|
26
|
+
* before it). Every other length of 28 days or longer keeps the calendar rule.
|
|
16
27
|
*/
|
|
17
28
|
export function candleBarEndMs(tsMs, intervalMs) {
|
|
18
|
-
if (!(intervalMs >= MONTH_CLASS_MS))
|
|
29
|
+
if (!(intervalMs >= MONTH_CLASS_MS) || isTypedDayWeekMs(intervalMs))
|
|
19
30
|
return tsMs + intervalMs;
|
|
20
31
|
const months = Math.max(1, Math.round(intervalMs / AVERAGE_MONTH_MS));
|
|
21
32
|
const d = new Date(tsMs);
|
|
@@ -8,5 +8,8 @@ export declare function isRealChartTimeRangeMs(start: unknown, end: unknown): st
|
|
|
8
8
|
* calendar bar's open, January 1) while it still ends after it. Undefined for every other window:
|
|
9
9
|
* a real one keeps its start, and anything else stays the caller's refusal (on a fixed interval a
|
|
10
10
|
* pre-1971 start is a placeholder or index-domain range, never a real chart's).
|
|
11
|
+
*
|
|
12
|
+
* A typed day or week chart (2d to 20w) clamps the same way to its own window floor, Monday 2000-01-03
|
|
13
|
+
* (`TYPED_DAY_WEEK_GRID_ORIGIN_MS`, a bar open of every such size): 80 bars of 20w reach back to 1996.
|
|
11
14
|
*/
|
|
12
15
|
export declare function calendarRangeStartAtFloorMs(interval: unknown, start: unknown, end: unknown): number | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isCalendarIntervalLabel } from './calendar-interval.util.js';
|
|
1
|
+
import { isCalendarIntervalLabel, isTypedDayWeekMs, TYPED_DAY_WEEK_GRID_ORIGIN_MS } from './calendar-interval.util.js';
|
|
2
|
+
import { typedWidthSeconds } from '../../constants/typed-width.leaf.js';
|
|
2
3
|
export const MIN_REAL_CHART_TIME_MS = Date.UTC(1971, 0, 1);
|
|
3
4
|
export function isRealChartTimestampMs(value) {
|
|
4
5
|
return typeof value === 'number' && Number.isFinite(value) && value >= MIN_REAL_CHART_TIME_MS;
|
|
@@ -13,11 +14,19 @@ export function isRealChartTimeRangeMs(start, end) {
|
|
|
13
14
|
* calendar bar's open, January 1) while it still ends after it. Undefined for every other window:
|
|
14
15
|
* a real one keeps its start, and anything else stays the caller's refusal (on a fixed interval a
|
|
15
16
|
* pre-1971 start is a placeholder or index-domain range, never a real chart's).
|
|
17
|
+
*
|
|
18
|
+
* A typed day or week chart (2d to 20w) clamps the same way to its own window floor, Monday 2000-01-03
|
|
19
|
+
* (`TYPED_DAY_WEEK_GRID_ORIGIN_MS`, a bar open of every such size): 80 bars of 20w reach back to 1996.
|
|
16
20
|
*/
|
|
17
21
|
export function calendarRangeStartAtFloorMs(interval, start, end) {
|
|
18
|
-
|
|
22
|
+
const floorMs = isCalendarIntervalLabel(interval)
|
|
23
|
+
? MIN_REAL_CHART_TIME_MS
|
|
24
|
+
: isTypedDayWeekMs((typedWidthSeconds(interval) ?? 0) * 1000)
|
|
25
|
+
? TYPED_DAY_WEEK_GRID_ORIGIN_MS
|
|
26
|
+
: undefined;
|
|
27
|
+
if (floorMs === undefined)
|
|
19
28
|
return undefined;
|
|
20
|
-
if (typeof start !== 'number' || !Number.isFinite(start) || start >=
|
|
29
|
+
if (typeof start !== 'number' || !Number.isFinite(start) || start >= floorMs)
|
|
21
30
|
return undefined;
|
|
22
|
-
return isRealChartTimeRangeMs(
|
|
31
|
+
return isRealChartTimeRangeMs(floorMs, end) ? floorMs : undefined;
|
|
23
32
|
}
|
|
@@ -5,7 +5,7 @@ export declare const FEED_BAR_INTERVALS_S: readonly [60, 300, 900, 1800, 3600, 1
|
|
|
5
5
|
export declare const FEED_POLL_FLOOR_S = 10;
|
|
6
6
|
/** Bars of history a first read reaches back when the chart's candles have not landed yet. */
|
|
7
7
|
export declare const FEED_DEFAULT_LOOKBACK_BARS = 1000;
|
|
8
|
-
export type FeedPlot = 'line' | 'candles';
|
|
8
|
+
export type FeedPlot = 'line' | 'bars' | 'candles';
|
|
9
9
|
export type FeedRequest = {
|
|
10
10
|
kind: 'rows';
|
|
11
11
|
} | {
|
|
@@ -22,6 +22,8 @@ export declare function feedPollPeriodMs(cadenceS: number): number;
|
|
|
22
22
|
/**
|
|
23
23
|
* The UTC bucket a timestamp falls in, seconds: the relay's regroup, `floor(ts / interval_s)`,
|
|
24
24
|
* except that weeks start Monday 00:00 UTC as the relay's (and the chart's weekly candles) do.
|
|
25
|
+
* The relay owns this grid: `interval_s` is always one of `FEED_BAR_INTERVALS_S` (1w at most),
|
|
26
|
+
* so a typed day or week chart regroups on the relay's 1d or 1w and never on its own grid.
|
|
25
27
|
*/
|
|
26
28
|
export declare function feedBucketStartSec(tsSec: number, intervalS: number): number;
|
|
27
29
|
/** An exact-interval feed on a chart of another interval: it draws nothing there. */
|
|
@@ -36,7 +38,7 @@ export declare function chooseFeedPlan(cadenceS: number, chartIntervalMs: number
|
|
|
36
38
|
export declare function feedCadenceHintApplies(cadenceS: number, chartIntervalMs: number, exactInterval?: boolean | null): boolean;
|
|
37
39
|
/** A span of seconds as a chart interval label: `1m`, `15m`, `1h`, `4h`, `1d`, `1w`; whole seconds otherwise. */
|
|
38
40
|
export declare function feedIntervalLabel(seconds: number): string;
|
|
39
|
-
/** The chart interval a cadence switches to (a
|
|
41
|
+
/** The chart interval a cadence switches to (a fixed rung with its wire interval: never a typed width), or null. */
|
|
40
42
|
export declare function feedChartIntervalFor(cadenceS: number): string | null;
|
|
41
43
|
/** The chart's own interval as a label (`1m`, `4h`, `1d`), from its milliseconds. */
|
|
42
44
|
export declare function feedChartIntervalLabel(chartIntervalMs: number): string;
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
* reading folds into a bar only for a value combining by `last`.
|
|
34
34
|
*/
|
|
35
35
|
import { Intervals } from '../../constants/interval.constants.js';
|
|
36
|
+
import { lookupGrpcInterval } from './interval-registry.util.js';
|
|
36
37
|
/** C2: the intervals the relay regroups bars on, ascending. */
|
|
37
38
|
export const FEED_BAR_INTERVALS_S = [60, 300, 900, 1_800, 3_600, 14_400, 86_400, 604_800];
|
|
38
39
|
/** C4 poll: never more often than this. */
|
|
@@ -76,6 +77,8 @@ const FIRST_MONDAY_S = 4 * 86_400;
|
|
|
76
77
|
/**
|
|
77
78
|
* The UTC bucket a timestamp falls in, seconds: the relay's regroup, `floor(ts / interval_s)`,
|
|
78
79
|
* except that weeks start Monday 00:00 UTC as the relay's (and the chart's weekly candles) do.
|
|
80
|
+
* The relay owns this grid: `interval_s` is always one of `FEED_BAR_INTERVALS_S` (1w at most),
|
|
81
|
+
* so a typed day or week chart regroups on the relay's 1d or 1w and never on its own grid.
|
|
79
82
|
*/
|
|
80
83
|
export function feedBucketStartSec(tsSec, intervalS) {
|
|
81
84
|
if (intervalS > 0 && intervalS % WEEK_S === 0) {
|
|
@@ -113,13 +116,13 @@ export function feedIntervalLabel(seconds) {
|
|
|
113
116
|
return `${span / 60}m`;
|
|
114
117
|
return `${span}s`;
|
|
115
118
|
}
|
|
116
|
-
/** The chart interval a cadence switches to (a
|
|
119
|
+
/** The chart interval a cadence switches to (a fixed rung with its wire interval: never a typed width), or null. */
|
|
117
120
|
export function feedChartIntervalFor(cadenceS) {
|
|
118
121
|
if (!(cadenceS > 0))
|
|
119
122
|
return null;
|
|
120
123
|
const label = feedIntervalLabel(cadenceS);
|
|
121
124
|
const units = Intervals.map_unit;
|
|
122
|
-
return units[label] === cadenceS * 1_000 ? label : null;
|
|
125
|
+
return units[label] === cadenceS * 1_000 && lookupGrpcInterval(label) !== undefined ? label : null;
|
|
123
126
|
}
|
|
124
127
|
/** The chart's own interval as a label (`1m`, `4h`, `1d`), from its milliseconds. */
|
|
125
128
|
export function feedChartIntervalLabel(chartIntervalMs) {
|
|
@@ -101,10 +101,12 @@ export interface FetchDedupeIntent {
|
|
|
101
101
|
isTapeSvpSeed?: boolean;
|
|
102
102
|
/** The Footprint panel's own lane (footprint-panel-lane.service.ts): snapshot windows into the panel's store. */
|
|
103
103
|
isFootprintPanel?: boolean;
|
|
104
|
+
/** The footprint pieces lane (footprint-row-pieces-lane.service.ts): piece reads into the engine's side table. */
|
|
105
|
+
isFootprintRowPieces?: boolean;
|
|
104
106
|
/** A split-family child whose span IS the parent's registered pre-split span (the owner span). */
|
|
105
107
|
isSplitFamilyOwnerChild?: boolean;
|
|
106
108
|
}
|
|
107
|
-
export type FetchDedupePolicyName = 'MAIN_COALESCE' | 'MAIN_POLL_BYPASS' | 'MAIN_HISTORICAL_BYPASS' | 'MAIN_RETRY_BYPASS' | 'IND_SKIP_DUPLICATE' | 'IND_REPAIR_REFRESH' | 'IND_LAZY_PAGE' | 'IND_POLL_BYPASS' | 'HEATMAP_CACHE_ONLY_BYPASS' | 'IND_RETRY_BYPASS' | 'IND_SPLIT_FAMILY_OWNER_CHILD' | 'IND_REPLAY_LANE_BYPASS' | 'IND_SEAM_TOPUP' | 'KSCRIPT_SOURCE_DEDUPE' | 'DOM_REPLAY_WINDOW' | 'TAPE_SVP_SEED' | 'FOOTPRINT_PANEL';
|
|
109
|
+
export type FetchDedupePolicyName = 'MAIN_COALESCE' | 'MAIN_POLL_BYPASS' | 'MAIN_HISTORICAL_BYPASS' | 'MAIN_RETRY_BYPASS' | 'IND_SKIP_DUPLICATE' | 'IND_REPAIR_REFRESH' | 'IND_LAZY_PAGE' | 'IND_POLL_BYPASS' | 'HEATMAP_CACHE_ONLY_BYPASS' | 'IND_RETRY_BYPASS' | 'IND_SPLIT_FAMILY_OWNER_CHILD' | 'IND_REPLAY_LANE_BYPASS' | 'IND_SEAM_TOPUP' | 'KSCRIPT_SOURCE_DEDUPE' | 'DOM_REPLAY_WINDOW' | 'TAPE_SVP_SEED' | 'FOOTPRINT_PANEL' | 'FOOTPRINT_ROW_PIECES';
|
|
108
110
|
export interface FetchDedupePolicy {
|
|
109
111
|
name: FetchDedupePolicyName;
|
|
110
112
|
onPendingTwin: 'await' | 'skip' | 'ignore';
|
|
@@ -317,6 +317,21 @@ const POLICIES = {
|
|
|
317
317
|
'laundered completion never records an empty; the known-empty and doomed-range guard classes never gate it ' +
|
|
318
318
|
'because the lane owns emptiness itself.',
|
|
319
319
|
},
|
|
320
|
+
FOOTPRINT_ROW_PIECES: {
|
|
321
|
+
name: 'FOOTPRINT_ROW_PIECES',
|
|
322
|
+
onPendingTwin: 'ignore',
|
|
323
|
+
onRecentCompletion: 'ignore',
|
|
324
|
+
registersPending: false,
|
|
325
|
+
onDeliveredAnswer: 'send',
|
|
326
|
+
why: 'Footprint pieces lane fetches (footprint-row-pieces-lane.service.ts, FOOTPRINT-ROW-SPLIT) run only the ' +
|
|
327
|
+
'"Split rows by" piece reads (a finer interval, or one read per listing) under a fresh synthetic ovId per ' +
|
|
328
|
+
"request and deliver side table entries into the engine's pieces table, never an overlay's rows, so like the " +
|
|
329
|
+
'footprint panel lane they neither consult nor write the production ledger. Duplicate control is the lane: ' +
|
|
330
|
+
'one read at a time per overlay, a queue of merged candle ranges (tail, visible, rest), a 20 s tail tick, and ' +
|
|
331
|
+
'a generation that drops every answer for a superseded split, market, row setting or mount; idle with no ' +
|
|
332
|
+
'split. Every request reads its transport outcome, so a laundered completion never commits an empty, and the ' +
|
|
333
|
+
'known-empty and doomed-range guard classes never gate it because the lane owns its served range itself.',
|
|
334
|
+
},
|
|
320
335
|
};
|
|
321
336
|
/** Branch precedence mirrors the historical guard-site code order exactly. */
|
|
322
337
|
export function resolveFetchDedupePolicy(intent) {
|
|
@@ -340,6 +355,8 @@ export function resolveFetchDedupePolicy(intent) {
|
|
|
340
355
|
return POLICIES.TAPE_SVP_SEED;
|
|
341
356
|
if (intent.isFootprintPanel)
|
|
342
357
|
return POLICIES.FOOTPRINT_PANEL;
|
|
358
|
+
if (intent.isFootprintRowPieces)
|
|
359
|
+
return POLICIES.FOOTPRINT_ROW_PIECES;
|
|
343
360
|
if (intent.isPolling)
|
|
344
361
|
return POLICIES.IND_POLL_BYPASS;
|
|
345
362
|
if (intent.heatmapCacheOnly)
|
|
@@ -439,7 +456,7 @@ export function isEngineQueueHoldEnabled(readExplicitlyOff) {
|
|
|
439
456
|
* to: a hedge or blank-boot retry exists to escape a possibly wedged twin
|
|
440
457
|
* (MAIN_RETRY_BYPASS, IND_RETRY_BYPASS), a historical-mode fetch replaces
|
|
441
458
|
* the dataset under explicit identity stamps, and the replay, DOM-replay,
|
|
442
|
-
* tape-seed, footprint-panel and cache-only lanes deliver through collectors
|
|
459
|
+
* tape-seed, footprint-panel, footprint-pieces and cache-only lanes deliver through collectors
|
|
443
460
|
* that never paint the chart. Everything else (coalesce, polls, repair, split
|
|
444
461
|
* children, the seam top-up, engine sources) may share one wire request
|
|
445
462
|
* across panes.
|
|
@@ -453,6 +470,7 @@ const UNSHAREABLE_FETCH_DEDUPE_POLICIES = new Set([
|
|
|
453
470
|
'DOM_REPLAY_WINDOW',
|
|
454
471
|
'TAPE_SVP_SEED',
|
|
455
472
|
'FOOTPRINT_PANEL',
|
|
473
|
+
'FOOTPRINT_ROW_PIECES',
|
|
456
474
|
]);
|
|
457
475
|
export function isShareableFetchDedupePolicy(policy) {
|
|
458
476
|
const name = typeof policy === 'string' ? policy : policy.name;
|
|
@@ -42,14 +42,30 @@ export declare function decimalPlaces(value: number): number;
|
|
|
42
42
|
export declare function centeredFootprintBand(gridPrice: number, bandHeight: number, tickSize?: number | null): [number, number];
|
|
43
43
|
/** Candle rows sampled for the tick inference (main rawData: [ts, o, h, l, c, ...]). */
|
|
44
44
|
export declare const PRICE_TICK_INFERENCE_ROWS = 2000;
|
|
45
|
+
/**
|
|
46
|
+
* Share of a sample's distinct prices that may sit on a finer decimal place
|
|
47
|
+
* than the lattice the inference returns. A lattice puts at least half of its
|
|
48
|
+
* prices on its own decimal place (the odd multiples of 0.25, 0.05 and 1/64
|
|
49
|
+
* all end there), while prints off an exchange's lattice are rare: on a US
|
|
50
|
+
* stock tape the sub-penny and six-decimal executions (price improvement,
|
|
51
|
+
* midpoint and TRF prints) are a few per thousand. A GCD read over such
|
|
52
|
+
* prints is the decimal resolution of the odd print, not a tick, and it
|
|
53
|
+
* shrank as the sample grew: AAPL on the NASDAQ tape read 0.000004 at 252
|
|
54
|
+
* bars and 0.000001 at 500 (2026-11-05), the anchor keyed on it never
|
|
55
|
+
* settled, and every footprint board the cache held under one value was lost
|
|
56
|
+
* under the next. Prints finer than the lattice's place are set aside before
|
|
57
|
+
* the GCD; a thin sample (under 20 distinct prices) sets nothing aside.
|
|
58
|
+
*/
|
|
59
|
+
export declare const PRICE_TICK_OUTLIER_SHARE = 0.05;
|
|
45
60
|
/**
|
|
46
61
|
* The exchange price tick as the chart's own candles reveal it: the greatest
|
|
47
62
|
* common divisor of every OHLC value's distance to the first, computed in
|
|
48
|
-
* whole units of the
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
63
|
+
* whole units of the lattice's decimal place (`latticeDecimalPlaces`: the
|
|
64
|
+
* rare prints finer than it, PRICE_TICK_OUTLIER_SHARE, are set aside) and
|
|
65
|
+
* returned as a clean decimal. No metadata carries a per-symbol tick, and the
|
|
66
|
+
* profile block catalog is not one (Binance BTCUSDT: block 3.0, tick 0.1).
|
|
67
|
+
* Every traded price is a tick multiple, so the estimate can only ever be the
|
|
68
|
+
* tick or a multiple of it (a thin sample), never finer.
|
|
53
69
|
*
|
|
54
70
|
* Integer arithmetic, not the smallest float gap: at 85,000 a 0.01 gap
|
|
55
71
|
* subtracts to 0.0099999999947 and snapping it to 9 significant digits kept
|
|
@@ -115,19 +115,53 @@ const PRICE_TICK_SIGNIFICANT_DIGITS = 12;
|
|
|
115
115
|
* series with no lattice at all (split-adjusted 250 / 3), not a tick.
|
|
116
116
|
*/
|
|
117
117
|
const PRICE_TICK_MIN_RELATIVE = 1e-10;
|
|
118
|
+
/**
|
|
119
|
+
* Share of a sample's distinct prices that may sit on a finer decimal place
|
|
120
|
+
* than the lattice the inference returns. A lattice puts at least half of its
|
|
121
|
+
* prices on its own decimal place (the odd multiples of 0.25, 0.05 and 1/64
|
|
122
|
+
* all end there), while prints off an exchange's lattice are rare: on a US
|
|
123
|
+
* stock tape the sub-penny and six-decimal executions (price improvement,
|
|
124
|
+
* midpoint and TRF prints) are a few per thousand. A GCD read over such
|
|
125
|
+
* prints is the decimal resolution of the odd print, not a tick, and it
|
|
126
|
+
* shrank as the sample grew: AAPL on the NASDAQ tape read 0.000004 at 252
|
|
127
|
+
* bars and 0.000001 at 500 (2026-11-05), the anchor keyed on it never
|
|
128
|
+
* settled, and every footprint board the cache held under one value was lost
|
|
129
|
+
* under the next. Prints finer than the lattice's place are set aside before
|
|
130
|
+
* the GCD; a thin sample (under 20 distinct prices) sets nothing aside.
|
|
131
|
+
*/
|
|
132
|
+
export const PRICE_TICK_OUTLIER_SHARE = 0.05;
|
|
118
133
|
function greatestCommonDivisor(a, b) {
|
|
119
134
|
while (b)
|
|
120
135
|
[a, b] = [b, a % b];
|
|
121
136
|
return a;
|
|
122
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* The decimal place the sample's lattice sits on: the coarsest place that
|
|
140
|
+
* leaves no more than PRICE_TICK_OUTLIER_SHARE of the distinct prices on a
|
|
141
|
+
* finer one. Null when even PRICE_TICK_MAX_DECIMALS leaves more (the series
|
|
142
|
+
* has no decimal lattice: AMM-priced tokens, split-adjusted stocks).
|
|
143
|
+
*/
|
|
144
|
+
function latticeDecimalPlaces(placesByPrice) {
|
|
145
|
+
const finerThan = new Array(PRICE_TICK_MAX_DECIMALS + 1).fill(0);
|
|
146
|
+
for (const places of placesByPrice.values()) {
|
|
147
|
+
for (let k = 0; k < places && k <= PRICE_TICK_MAX_DECIMALS; k++)
|
|
148
|
+
finerThan[k] += 1;
|
|
149
|
+
}
|
|
150
|
+
const allowed = Math.floor(placesByPrice.size * PRICE_TICK_OUTLIER_SHARE);
|
|
151
|
+
for (let k = 0; k <= PRICE_TICK_MAX_DECIMALS; k++)
|
|
152
|
+
if (finerThan[k] <= allowed)
|
|
153
|
+
return k;
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
123
156
|
/**
|
|
124
157
|
* The exchange price tick as the chart's own candles reveal it: the greatest
|
|
125
158
|
* common divisor of every OHLC value's distance to the first, computed in
|
|
126
|
-
* whole units of the
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
159
|
+
* whole units of the lattice's decimal place (`latticeDecimalPlaces`: the
|
|
160
|
+
* rare prints finer than it, PRICE_TICK_OUTLIER_SHARE, are set aside) and
|
|
161
|
+
* returned as a clean decimal. No metadata carries a per-symbol tick, and the
|
|
162
|
+
* profile block catalog is not one (Binance BTCUSDT: block 3.0, tick 0.1).
|
|
163
|
+
* Every traded price is a tick multiple, so the estimate can only ever be the
|
|
164
|
+
* tick or a multiple of it (a thin sample), never finer.
|
|
131
165
|
*
|
|
132
166
|
* Integer arithmetic, not the smallest float gap: at 85,000 a 0.01 gap
|
|
133
167
|
* subtracts to 0.0099999999947 and snapping it to 9 significant digits kept
|
|
@@ -142,8 +176,8 @@ function greatestCommonDivisor(a, b) {
|
|
|
142
176
|
export function inferPriceTickFromRows(rows, maxRows = PRICE_TICK_INFERENCE_ROWS, minRows = PRICE_TICK_INFERENCE_MIN_ROWS) {
|
|
143
177
|
if (!rows || !(rows.length >= Math.max(1, minRows)))
|
|
144
178
|
return null;
|
|
145
|
-
|
|
146
|
-
|
|
179
|
+
// Distinct prices in row order with their decimal places: a repeated price moves no GCD and no share.
|
|
180
|
+
const placesByPrice = new Map();
|
|
147
181
|
const start = Math.max(0, rows.length - maxRows);
|
|
148
182
|
for (let i = start; i < rows.length; i++) {
|
|
149
183
|
const row = rows[i];
|
|
@@ -154,22 +188,27 @@ export function inferPriceTickFromRows(rows, maxRows = PRICE_TICK_INFERENCE_ROWS
|
|
|
154
188
|
if (!positiveFinite(value))
|
|
155
189
|
continue;
|
|
156
190
|
const price = Number(value.toPrecision(PRICE_TICK_SIGNIFICANT_DIGITS));
|
|
157
|
-
|
|
158
|
-
|
|
191
|
+
if (!placesByPrice.has(price))
|
|
192
|
+
placesByPrice.set(price, decimalPlaces(price));
|
|
159
193
|
}
|
|
160
194
|
}
|
|
161
|
-
if (
|
|
195
|
+
if (placesByPrice.size < 2)
|
|
162
196
|
return null;
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
if (!Number.isSafeInteger(origin))
|
|
197
|
+
const decimals = latticeDecimalPlaces(placesByPrice);
|
|
198
|
+
if (decimals === null)
|
|
166
199
|
return null;
|
|
200
|
+
const scale = 10 ** decimals;
|
|
201
|
+
let origin = null;
|
|
167
202
|
let units = 0;
|
|
168
203
|
let maxPrice = 0;
|
|
169
|
-
for (const price of
|
|
204
|
+
for (const [price, places] of placesByPrice) {
|
|
205
|
+
if (places > decimals)
|
|
206
|
+
continue;
|
|
170
207
|
const scaled = Math.round(price * scale);
|
|
171
208
|
if (!Number.isSafeInteger(scaled))
|
|
172
209
|
return null;
|
|
210
|
+
if (origin === null)
|
|
211
|
+
origin = scaled;
|
|
173
212
|
units = greatestCommonDivisor(units, Math.abs(scaled - origin));
|
|
174
213
|
if (price > maxPrice)
|
|
175
214
|
maxPrice = price;
|
|
@@ -24,6 +24,7 @@ type DisplayModeModel = {
|
|
|
24
24
|
barWidth?: unknown;
|
|
25
25
|
stickToLeft?: unknown;
|
|
26
26
|
clusterCellMetric?: unknown;
|
|
27
|
+
rowSplit?: unknown;
|
|
27
28
|
};
|
|
28
29
|
/**
|
|
29
30
|
* The display mode a form shows for a model, as the Volume Footprint dialog reads it: a cell-grid mode as it is, and the
|
|
@@ -35,6 +36,7 @@ export declare function footprintDisplayModeShown(model: DisplayModeModel): stri
|
|
|
35
36
|
* The model on `displayMode`, as both footprint dialogs write a display mode pick: the legacy delta flag only for the
|
|
36
37
|
* stacked delta mode, the bar width of the mode's family, the cells anchored left, and on a cell grid the cluster cell
|
|
37
38
|
* metric's default (the columns layout is one of titan's cluster-grid family: its bid x ask column reads the metric).
|
|
39
|
+
* A mode other than Total sets a saved Split rows by (`rowSplit`) back to none, as web's dialogs do.
|
|
38
40
|
*/
|
|
39
41
|
export declare function withFootprintDisplayMode<T extends DisplayModeModel>(model: T, displayMode: string): T;
|
|
40
42
|
export {};
|
|
@@ -45,6 +45,7 @@ export function footprintDisplayModeShown(model) {
|
|
|
45
45
|
* The model on `displayMode`, as both footprint dialogs write a display mode pick: the legacy delta flag only for the
|
|
46
46
|
* stacked delta mode, the bar width of the mode's family, the cells anchored left, and on a cell grid the cluster cell
|
|
47
47
|
* metric's default (the columns layout is one of titan's cluster-grid family: its bid x ask column reads the metric).
|
|
48
|
+
* A mode other than Total sets a saved Split rows by (`rowSplit`) back to none, as web's dialogs do.
|
|
48
49
|
*/
|
|
49
50
|
export function withFootprintDisplayMode(model, displayMode) {
|
|
50
51
|
const cellGrid = isClusterGridProfileDisplayMode(displayMode) || displayMode === FOOTPRINT_COLUMNS_DISPLAY_MODE;
|
|
@@ -58,5 +59,9 @@ export function withFootprintDisplayMode(model, displayMode) {
|
|
|
58
59
|
};
|
|
59
60
|
if (cellGrid && !next.clusterCellMetric)
|
|
60
61
|
next.clusterCellMetric = 'delta';
|
|
62
|
+
// Split rows by draws under Total alone: any other mode sets a saved split back to none, so a workspace shared with
|
|
63
|
+
// web never holds a split under another mode. The row itself is web-only for now (footprint-rows.ts).
|
|
64
|
+
if (displayMode !== 'stacked-bar' && model.rowSplit !== undefined)
|
|
65
|
+
next.rowSplit = 'none';
|
|
61
66
|
return next;
|
|
62
67
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The governed-lanes cutover switch as the venue policy reads it (kscript-venue-policy.util, the one decider of the
|
|
3
|
+
* governed walls). One runtime flag per licensed plane (`cme-lanes`, `opra-lanes`, `stocks-lanes`); while a plane's
|
|
4
|
+
* flag is lit, that plane opens to the server lanes too: the hosted (Cloud) runs, the protected scripts, strategy
|
|
5
|
+
* testing and every alert kind. While it is dark (the default), the plane reads exactly as it did before the cutover.
|
|
6
|
+
*
|
|
7
|
+
* Store-free on purpose, the shape of the `cme-user-scripts` gate leaf (cme-user-scripts-gate.util): the venue policy
|
|
8
|
+
* stays worker-safe, so the main thread hands it a reader instead. Its one import is the fallback reader's seat
|
|
9
|
+
* (governed-lanes-reader-seat, itself dependency-free), which the flags store fills with its override-aware `isOn`
|
|
10
|
+
* when it is evaluated, so the dev and internal `kiyo.flag-overrides` lens reaches the walls exactly as it reaches
|
|
11
|
+
* every surface reading `isOn`. A published reader (a spec's, or a host that hands one) answers over the seat's.
|
|
12
|
+
*
|
|
13
|
+
* Fail closed everywhere: no reader (a worker, a spec without a store), a reader that throws, a reader that answers
|
|
14
|
+
* anything but `true`, an unloaded or guest map (the store's `isOn` reads those false) and a plane this module does
|
|
15
|
+
* not name all read dark. The flags never open a lane on their own: each plane's own decision still holds (the CME
|
|
16
|
+
* plane keeps the `cme-user-scripts` gate: the flag, sign-in and the CME data terms).
|
|
17
|
+
*/
|
|
18
|
+
/** A licensed plane the cutover opens to the server lanes. */
|
|
19
|
+
export type GovernedLanePlane = 'cme' | 'opra' | 'stocks';
|
|
20
|
+
/** Every governed lane plane, in the order the planes shipped. */
|
|
21
|
+
export declare const GOVERNED_LANE_PLANES: readonly GovernedLanePlane[];
|
|
22
|
+
/** Reads one plane's lanes flag: `true` only when that plane's cutover flag is lit. */
|
|
23
|
+
export type GovernedLanesFlagReader = (plane: GovernedLanePlane) => boolean;
|
|
24
|
+
/** A reader that answers over the fallback seat's (a spec's, or a host that hands one); null unpublishes. */
|
|
25
|
+
export declare function publishGovernedLanesFlags(next: GovernedLanesFlagReader | null): void;
|
|
26
|
+
/** Fill or empty the fallback reader's seat (the flags store fills it itself, by the seat's own module). */
|
|
27
|
+
export declare function setGovernedLanesFlagsFallback(next: GovernedLanesFlagReader | null): void;
|
|
28
|
+
/** The token a server-lane CME run captures before it asks (frozen: a holder cannot move it forward). */
|
|
29
|
+
export declare function captureCmeLanesFence(): {
|
|
30
|
+
fence: number;
|
|
31
|
+
};
|
|
32
|
+
/** Move the fence on: every server-lane CME run captured before is no longer current. Returns the new fence. */
|
|
33
|
+
export declare function bumpCmeLanesFence(): number;
|
|
34
|
+
/** The fence now (specs and the debug ring read it). */
|
|
35
|
+
export declare function cmeLanesFenceNow(): number;
|
|
36
|
+
/** Whether a captured fence token is current; a missing or malformed token is not. */
|
|
37
|
+
export declare function isCmeLanesFenceCurrent(token: {
|
|
38
|
+
fence: number;
|
|
39
|
+
} | null | undefined): boolean;
|
|
40
|
+
/** Whether a value names a governed lane plane. */
|
|
41
|
+
export declare function isGovernedLanePlane(plane: unknown): plane is GovernedLanePlane;
|
|
42
|
+
/**
|
|
43
|
+
* True only when the plane's cutover flag is lit. Fails closed: no reader published, flags not loaded, guest map, or
|
|
44
|
+
* an unknown plane all read false. Worker-safe.
|
|
45
|
+
*/
|
|
46
|
+
export declare function governedLanesOpen(plane: GovernedLanePlane): boolean;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The governed-lanes cutover switch as the venue policy reads it (kscript-venue-policy.util, the one decider of the
|
|
3
|
+
* governed walls). One runtime flag per licensed plane (`cme-lanes`, `opra-lanes`, `stocks-lanes`); while a plane's
|
|
4
|
+
* flag is lit, that plane opens to the server lanes too: the hosted (Cloud) runs, the protected scripts, strategy
|
|
5
|
+
* testing and every alert kind. While it is dark (the default), the plane reads exactly as it did before the cutover.
|
|
6
|
+
*
|
|
7
|
+
* Store-free on purpose, the shape of the `cme-user-scripts` gate leaf (cme-user-scripts-gate.util): the venue policy
|
|
8
|
+
* stays worker-safe, so the main thread hands it a reader instead. Its one import is the fallback reader's seat
|
|
9
|
+
* (governed-lanes-reader-seat, itself dependency-free), which the flags store fills with its override-aware `isOn`
|
|
10
|
+
* when it is evaluated, so the dev and internal `kiyo.flag-overrides` lens reaches the walls exactly as it reaches
|
|
11
|
+
* every surface reading `isOn`. A published reader (a spec's, or a host that hands one) answers over the seat's.
|
|
12
|
+
*
|
|
13
|
+
* Fail closed everywhere: no reader (a worker, a spec without a store), a reader that throws, a reader that answers
|
|
14
|
+
* anything but `true`, an unloaded or guest map (the store's `isOn` reads those false) and a plane this module does
|
|
15
|
+
* not name all read dark. The flags never open a lane on their own: each plane's own decision still holds (the CME
|
|
16
|
+
* plane keeps the `cme-user-scripts` gate: the flag, sign-in and the CME data terms).
|
|
17
|
+
*/
|
|
18
|
+
import { governedLanesFallbackSeat } from './governed-lanes-reader-seat.js';
|
|
19
|
+
/** Every governed lane plane, in the order the planes shipped. */
|
|
20
|
+
export const GOVERNED_LANE_PLANES = Object.freeze(['cme', 'opra', 'stocks']);
|
|
21
|
+
let published = null;
|
|
22
|
+
/** A reader that answers over the fallback seat's (a spec's, or a host that hands one); null unpublishes. */
|
|
23
|
+
export function publishGovernedLanesFlags(next) {
|
|
24
|
+
published = next;
|
|
25
|
+
}
|
|
26
|
+
/** Fill or empty the fallback reader's seat (the flags store fills it itself, by the seat's own module). */
|
|
27
|
+
export function setGovernedLanesFlagsFallback(next) {
|
|
28
|
+
governedLanesFallbackSeat.reader = next;
|
|
29
|
+
}
|
|
30
|
+
// ── The CME lanes fence (2026-11-11) ────────────────────────────────────────────────────────────────────────────────
|
|
31
|
+
//
|
|
32
|
+
// A server-lane user run reading CME (a Cloud record or a protected script on a CME chart, or whose effective sheet pins
|
|
33
|
+
// a CME market) captures this fence at its head; the `cme-lanes` flag going dark moves it (the CME user-study lifecycle,
|
|
34
|
+
// `bumpCmeLanesFence`). Apart from the CME authorisation epoch on purpose: a lanes move must drop an in-flight
|
|
35
|
+
// server-lane CME answer (even one no stamp shows yet) and never a browser run's, which the flag does not govern.
|
|
36
|
+
let cmeLanesFence = 0;
|
|
37
|
+
/** The token a server-lane CME run captures before it asks (frozen: a holder cannot move it forward). */
|
|
38
|
+
export function captureCmeLanesFence() {
|
|
39
|
+
return Object.freeze({ fence: cmeLanesFence });
|
|
40
|
+
}
|
|
41
|
+
/** Move the fence on: every server-lane CME run captured before is no longer current. Returns the new fence. */
|
|
42
|
+
export function bumpCmeLanesFence() {
|
|
43
|
+
cmeLanesFence += 1;
|
|
44
|
+
return cmeLanesFence;
|
|
45
|
+
}
|
|
46
|
+
/** The fence now (specs and the debug ring read it). */
|
|
47
|
+
export function cmeLanesFenceNow() {
|
|
48
|
+
return cmeLanesFence;
|
|
49
|
+
}
|
|
50
|
+
/** Whether a captured fence token is current; a missing or malformed token is not. */
|
|
51
|
+
export function isCmeLanesFenceCurrent(token) {
|
|
52
|
+
return typeof token?.fence === 'number' && token.fence === cmeLanesFence;
|
|
53
|
+
}
|
|
54
|
+
/** Whether a value names a governed lane plane. */
|
|
55
|
+
export function isGovernedLanePlane(plane) {
|
|
56
|
+
return plane === 'cme' || plane === 'opra' || plane === 'stocks';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* True only when the plane's cutover flag is lit. Fails closed: no reader published, flags not loaded, guest map, or
|
|
60
|
+
* an unknown plane all read false. Worker-safe.
|
|
61
|
+
*/
|
|
62
|
+
export function governedLanesOpen(plane) {
|
|
63
|
+
if (!isGovernedLanePlane(plane))
|
|
64
|
+
return false;
|
|
65
|
+
try {
|
|
66
|
+
return (published ?? governedLanesFallbackSeat.reader)?.(plane) === true;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The seat of the governed-lanes fallback reader: governed-lanes-gate.util reads it and the flags store fills it. It
|
|
3
|
+
* is alone in its own module because the store ships in the boot entry, which has no bytes to spare
|
|
4
|
+
* (entry-size-guard): the store imports this seat, never the gate.
|
|
5
|
+
*
|
|
6
|
+
* The store fills it when it is evaluated, never later. A surface that read the gate before a reader sat here would
|
|
7
|
+
* have tracked nothing reactive, and would never see a lanes flag land.
|
|
8
|
+
*
|
|
9
|
+
* Dependency-free (zero imports), so the gate stays worker-safe: in a worker nothing fills the seat and every lane
|
|
10
|
+
* reads dark.
|
|
11
|
+
*/
|
|
12
|
+
export declare const governedLanesFallbackSeat: {
|
|
13
|
+
reader: ((plane: 'cme' | 'opra' | 'stocks') => boolean) | null;
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The seat of the governed-lanes fallback reader: governed-lanes-gate.util reads it and the flags store fills it. It
|
|
3
|
+
* is alone in its own module because the store ships in the boot entry, which has no bytes to spare
|
|
4
|
+
* (entry-size-guard): the store imports this seat, never the gate.
|
|
5
|
+
*
|
|
6
|
+
* The store fills it when it is evaluated, never later. A surface that read the gate before a reader sat here would
|
|
7
|
+
* have tracked nothing reactive, and would never see a lanes flag land.
|
|
8
|
+
*
|
|
9
|
+
* Dependency-free (zero imports), so the gate stays worker-safe: in a worker nothing fills the seat and every lane
|
|
10
|
+
* reads dark.
|
|
11
|
+
*/
|
|
12
|
+
export const governedLanesFallbackSeat = {
|
|
13
|
+
reader: null,
|
|
14
|
+
};
|
|
@@ -33,9 +33,15 @@ export type HistoryWallKind = 'plan-wall' | 'data-start';
|
|
|
33
33
|
* maps it with `grpcIntervalOf(interval)`
|
|
34
34
|
* (workers/indicators/controls/ohlcv.worker.ts): the twelve native labels and
|
|
35
35
|
* the custom ones go out as themselves ('3M' as QUARTER, '3m' as
|
|
36
|
-
* THREE_MINUTES),
|
|
36
|
+
* THREE_MINUTES), a typed width (4m to 3h, 2d to 20w) goes out as CUSTOM with
|
|
37
|
+
* its own bar length, which the gateway counts the wall in (its own bars), so
|
|
38
|
+
* it answers as itself; any other label ('5s' to '30s', '1mm') falls back to
|
|
37
39
|
* AggregationInterval.MINUTE. The gateway measures the wall in that interval,
|
|
38
40
|
* so the chart label would put the wall far too deep.
|
|
41
|
+
*
|
|
42
|
+
* A custom size the app builds asks its SOURCE instead (18m from 3m), which this store-free package cannot know: a
|
|
43
|
+
* web caller with a chart passes the app's `gatewayWallInterval(interval, chart)` (retention-validation.util) here,
|
|
44
|
+
* never the chart's label (tests/structure/history-wall-readers.spec.ts).
|
|
39
45
|
*/
|
|
40
46
|
export declare function gatewayRequestIntervalFor(chartInterval: string): string;
|
|
41
47
|
/** How far back the tier's gateway window reaches at this chart interval, in ms. */
|
|
@@ -52,9 +58,14 @@ export interface HistoryWallInput {
|
|
|
52
58
|
sessionBound: boolean;
|
|
53
59
|
/** The wire omits tradeless buckets (mayServeLegitimatelySparseHistory): the first trade can land after the wall. */
|
|
54
60
|
sparseHistory: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* A custom size the app builds from the interval asked: its bar length. The fold keeps whole bars only, so the
|
|
63
|
+
* oldest one opens up to one such bar past the wall. Absent for every chart the gateway answers at its own label.
|
|
64
|
+
*/
|
|
65
|
+
foldedBarMs?: number;
|
|
55
66
|
}
|
|
56
67
|
/** `plan-wall` iff the edge sits at (or behind) the viewer's tier wall, within slack. */
|
|
57
|
-
export declare function classifyHistoryWall({ edgeMs, requestIntervalMs, tierMaxBars, nowMs, sessionBound, sparseHistory, }: HistoryWallInput): HistoryWallKind;
|
|
68
|
+
export declare function classifyHistoryWall({ edgeMs, requestIntervalMs, tierMaxBars, nowMs, sessionBound, sparseHistory, foldedBarMs, }: HistoryWallInput): HistoryWallKind;
|
|
58
69
|
export type HistoryReachUnit = 'hours' | 'days' | 'months' | 'years';
|
|
59
70
|
/**
|
|
60
71
|
* A reach in the words the plan copy uses: hours under a day, days under 60
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { Intervals } from '../../constants/interval.constants.js';
|
|
23
23
|
import { lookupGrpcInterval } from './interval-registry.util.js';
|
|
24
|
+
import { isTypedWidth } from '../../constants/typed-width.leaf.js';
|
|
24
25
|
import { gatewayTierMaxBars } from '../../constants/feature-limits.constants.js';
|
|
25
26
|
const HOUR_MS = 3_600_000;
|
|
26
27
|
const DAY_MS = 86_400_000;
|
|
@@ -51,12 +52,18 @@ const GAP_SLACK_MAX_REACH_SHARE = 0.25;
|
|
|
51
52
|
* maps it with `grpcIntervalOf(interval)`
|
|
52
53
|
* (workers/indicators/controls/ohlcv.worker.ts): the twelve native labels and
|
|
53
54
|
* the custom ones go out as themselves ('3M' as QUARTER, '3m' as
|
|
54
|
-
* THREE_MINUTES),
|
|
55
|
+
* THREE_MINUTES), a typed width (4m to 3h, 2d to 20w) goes out as CUSTOM with
|
|
56
|
+
* its own bar length, which the gateway counts the wall in (its own bars), so
|
|
57
|
+
* it answers as itself; any other label ('5s' to '30s', '1mm') falls back to
|
|
55
58
|
* AggregationInterval.MINUTE. The gateway measures the wall in that interval,
|
|
56
59
|
* so the chart label would put the wall far too deep.
|
|
60
|
+
*
|
|
61
|
+
* A custom size the app builds asks its SOURCE instead (18m from 3m), which this store-free package cannot know: a
|
|
62
|
+
* web caller with a chart passes the app's `gatewayWallInterval(interval, chart)` (retention-validation.util) here,
|
|
63
|
+
* never the chart's label (tests/structure/history-wall-readers.spec.ts).
|
|
57
64
|
*/
|
|
58
65
|
export function gatewayRequestIntervalFor(chartInterval) {
|
|
59
|
-
return lookupGrpcInterval(chartInterval) !== undefined ? chartInterval : '1m';
|
|
66
|
+
return lookupGrpcInterval(chartInterval) !== undefined || isTypedWidth(chartInterval) ? chartInterval : '1m';
|
|
60
67
|
}
|
|
61
68
|
/** How far back the tier's gateway window reaches at this chart interval, in ms. */
|
|
62
69
|
export function historyReachMs(tier, chartInterval) {
|
|
@@ -64,10 +71,10 @@ export function historyReachMs(tier, chartInterval) {
|
|
|
64
71
|
return gatewayTierMaxBars(tier, requestInterval) * Intervals.map_unit[requestInterval];
|
|
65
72
|
}
|
|
66
73
|
/** `plan-wall` iff the edge sits at (or behind) the viewer's tier wall, within slack. */
|
|
67
|
-
export function classifyHistoryWall({ edgeMs, requestIntervalMs, tierMaxBars, nowMs, sessionBound, sparseHistory, }) {
|
|
74
|
+
export function classifyHistoryWall({ edgeMs, requestIntervalMs, tierMaxBars, nowMs, sessionBound, sparseHistory, foldedBarMs = 0, }) {
|
|
68
75
|
const reachMs = tierMaxBars * requestIntervalMs;
|
|
69
76
|
const gapSlackMs = Math.min((sessionBound ? SESSION_GAP_SLACK_MS : 0) + (sparseHistory ? NO_TRADE_GAP_SLACK_MS : 0), reachMs * GAP_SLACK_MAX_REACH_SHARE);
|
|
70
|
-
const slackMs = PLAN_WALL_SLACK_BARS * requestIntervalMs + PLAN_WALL_DRIFT_MS + gapSlackMs;
|
|
77
|
+
const slackMs = PLAN_WALL_SLACK_BARS * requestIntervalMs + foldedBarMs + PLAN_WALL_DRIFT_MS + gapSlackMs;
|
|
71
78
|
return edgeMs <= nowMs - reachMs + slackMs ? 'plan-wall' : 'data-start';
|
|
72
79
|
}
|
|
73
80
|
/**
|