@orangecharts/wrun-chart-host 0.10.0 → 0.11.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/feature-flags.constants.d.ts +9 -0
- package/dist/constants/feature-flags.constants.js +67 -4
- package/dist/constants/governed-exchanges.constants.d.ts +12 -0
- package/dist/constants/governed-exchanges.constants.js +16 -0
- package/dist/constants/option-venues.constants.d.ts +2 -2
- package/dist/host-env.d.ts +1 -9
- package/dist/host-ports.types.d.ts +36 -7
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/dist/interfaces/cancel-reason.interface.d.ts +1 -1
- package/dist/interfaces/cme-realtime.interface.d.ts +16 -9
- package/dist/interfaces/cme-realtime.interface.js +6 -3
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +1 -5
- package/dist/interfaces/prediction-market.interface.d.ts +7 -0
- package/dist/interfaces/stocks-realtime.interface.d.ts +57 -0
- package/dist/interfaces/stocks-realtime.interface.js +32 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +48 -117
- package/dist/kscript-data/controls/live-trades-merge.util.js +97 -207
- package/dist/market-data/billing.interface.d.ts +86 -12
- package/dist/market-data/billing.interface.js +23 -4
- package/dist/market-data/venue.d.ts +65 -2
- package/dist/market-data/venues/index.d.ts +135 -5
- package/dist/market-data/venues/index.js +2 -1
- package/dist/market-data/venues/opra.contract.copy.json +3 -2
- package/dist/market-data/venues/opra.d.ts +2 -2
- package/dist/market-data/venues/opra.js +5 -2
- package/dist/market-data/venues/stocks.contract.copy.json +64 -0
- package/dist/market-data/venues/stocks.d.ts +130 -0
- package/dist/market-data/venues/stocks.js +117 -0
- package/dist/settings-templates/footprint-rows.js +35 -2
- package/dist/settings-templates/form-rows.d.ts +2 -1
- package/dist/settings-templates/indicator-fields.js +34 -4
- package/dist/settings-templates/tool-rules.d.ts +12 -5
- package/dist/settings-templates/tool-rules.js +11 -5
- package/dist/settings-templates/tool-tables.generated.js +4 -0
- package/dist/utility/chart/cme-cache-context.util.d.ts +5 -3
- package/dist/utility/chart/cme-cache-context.util.js +10 -6
- package/dist/utility/chart/cme-realtime.util.js +10 -0
- package/dist/utility/chart/cme-user-scripts-gate.util.d.ts +83 -0
- package/dist/utility/chart/cme-user-scripts-gate.util.js +142 -0
- package/dist/utility/chart/effective-chart-session.util.d.ts +14 -0
- package/dist/utility/chart/effective-chart-session.util.js +39 -0
- package/dist/utility/chart/host-bar-placement.util.d.ts +28 -0
- package/dist/utility/chart/host-bar-placement.util.js +170 -30
- package/dist/utility/chart/index-host-tier.util.d.ts +3 -1
- package/dist/utility/chart/index-host-tier.util.js +7 -2
- package/dist/utility/chart/index-mode-admission.util.js +25 -11
- package/dist/utility/chart/kscript-apply-fingerprint.util.js +1 -1
- package/dist/utility/chart/kscript-live-coalesce.util.d.ts +6 -9
- package/dist/utility/chart/kscript-live-coalesce.util.js +8 -9
- package/dist/utility/chart/kscript-live-source-identity.util.d.ts +9 -0
- package/dist/utility/chart/kscript-live-source-identity.util.js +10 -1
- package/dist/utility/chart/kscript-provenance-keys.util.js +7 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +115 -21
- package/dist/utility/chart/kscript-venue-policy.util.js +194 -40
- package/dist/utility/chart/live-bucket.util.d.ts +24 -8
- package/dist/utility/chart/live-bucket.util.js +85 -27
- package/dist/utility/chart/marketKind.util.js +5 -0
- package/dist/utility/chart/mixed-mode.util.d.ts +7 -0
- package/dist/utility/chart/mixed-mode.util.js +14 -0
- package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +11 -16
- package/dist/utility/chart/opra-user-scripts-gate.util.js +12 -28
- package/dist/utility/chart/rth-session.util.d.ts +9 -8
- package/dist/utility/chart/rth-session.util.js +23 -20
- package/dist/utility/chart/trading-day.util.d.ts +17 -0
- package/dist/utility/chart/trading-day.util.js +59 -0
- package/dist/utility/chart/window-owner.leaf.d.ts +23 -2
- package/dist/utility/chart/window-owner.leaf.js +45 -3
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +33 -15
- package/dist/utility/chart/wrun-bar-session-facts.util.js +70 -20
- package/dist/utility/intl-locale.util.js +5 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
- package/dist/utility/v2/gate-plane.util.d.ts +12 -3
- package/dist/utility/v2/gate-plane.util.js +30 -4
- package/dist/utility/v2/gate-session-latch.util.js +1 -1
- package/dist/utility/v2/stocks-governed.util.d.ts +16 -0
- package/dist/utility/v2/stocks-governed.util.js +34 -0
- package/dist/utility/wrun/derived-roots.leaf.d.ts +13 -0
- package/dist/utility/wrun/derived-roots.leaf.js +27 -0
- package/dist/utility/wrun/derived-roots.util.d.ts +1 -9
- package/dist/utility/wrun/derived-roots.util.js +3 -23
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +4 -3
- package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +24 -3
- package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +46 -10
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +2 -0
- package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +63 -16
- package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +58 -14
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +34 -11
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +106 -30
- package/dist/utility/wrun/wrun-browser-sources.leaf.js +1 -2
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +7 -4
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +12 -8
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-color-settings.util.js +33 -0
- package/dist/utility/wrun/wrun-handles.util.d.ts +7 -3
- package/dist/utility/wrun/wrun-handles.util.js +9 -8
- package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +68 -0
- package/dist/utility/wrun/wrun-input-requirements.leaf.js +163 -7
- package/dist/utility/wrun/wrun-leg-close.util.d.ts +59 -23
- package/dist/utility/wrun/wrun-leg-close.util.js +186 -28
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +26 -12
- package/dist/utility/wrun/wrun-live-intake.util.js +219 -155
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +9 -5
- package/dist/utility/wrun/wrun-live-tick.util.js +130 -94
- package/dist/utility/wrun/wrun-market-facts.util.d.ts +13 -3
- package/dist/utility/wrun/wrun-market-facts.util.js +13 -3
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +20 -10
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +10 -5
- package/dist/utility/wrun/wrun-option-book-rows.util.d.ts +56 -0
- package/dist/utility/wrun/wrun-option-book-rows.util.js +96 -0
- package/dist/utility/wrun/wrun-option-views.util.d.ts +281 -20
- package/dist/utility/wrun/wrun-option-views.util.js +391 -50
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-options-chain.util.js +2 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +15 -2
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +13 -3
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +3 -1
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +60 -11
- package/dist/utility/wrun/wrun-overlay-run.util.js +529 -113
- package/dist/utility/wrun/wrun-panel-mount.util.js +51 -6
- package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +15 -2
- package/dist/utility/wrun/wrun-pin-spelling.util.js +27 -3
- package/dist/utility/wrun/wrun-refusal.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-refusal.util.js +22 -0
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +26 -0
- package/dist/utility/wrun/wrun-registry-errors.util.js +34 -0
- package/dist/utility/wrun/wrun-replay-lane.util.js +3 -2
- package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +20 -6
- package/dist/utility/wrun/wrun-run-interval-session.util.js +22 -7
- package/dist/utility/wrun/wrun-run-interval.util.d.ts +39 -7
- package/dist/utility/wrun/wrun-run-interval.util.js +49 -9
- package/dist/utility/wrun/wrun-socket-row-source.js +7 -2
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +29 -22
- package/dist/utility/wrun/wrun-source-rows.util.js +62 -41
- package/dist/utility/wrun/wrun-tape-per-order.util.js +1 -20
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +17 -9
- package/dist/utility/wrun/wrun-tape-source.util.js +20 -12
- package/dist/workers/constants/socket-slots.d.ts +91 -6
- package/dist/workers/constants/socket-slots.js +85 -6
- package/package.json +11 -11
- package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +0 -56
- package/dist/kscript-data/controls/live-trades-order-gate.util.js +0 -107
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import { getExchangeFromSymbol } from '../../helpers/data.helpers.js';
|
|
19
19
|
import { extractTokensFromTransformations } from '../common/transformations.util.js';
|
|
20
20
|
import { checkIsIndexMode, checkIsPolygon } from './index-mode.util.js';
|
|
21
|
+
import { chartIntervalToMs, hasRthWindow, isChartRthActive } from './rth-session.util.js';
|
|
21
22
|
// ============================================================================
|
|
22
23
|
// CONSTANTS
|
|
23
24
|
// ============================================================================
|
|
@@ -50,6 +51,13 @@ export const INDEX_FETCH_EXTRA_BAR = 1;
|
|
|
50
51
|
* - Mixed timestamp-first: Main token is crypto, others include stocks (BTC + NVDA)
|
|
51
52
|
* - Mixed index-first: Main token is stock, others include crypto (NVDA + BTC)
|
|
52
53
|
*
|
|
54
|
+
* **Per-token sessions** (`tokenSessionTypes`, the worker resolves each leg's `tradingHour` from its entry, else the
|
|
55
|
+
* chart's `sessionType`): a Polygon leg rides the chart's session (regular unless extended); a leg with an RTH window
|
|
56
|
+
* that is not the chart's own market takes the comparison-leg rule (chart-rth.util `kOhlcvSessionPayloadFields`):
|
|
57
|
+
* 'regular' only while the CHART is RTH-active (`isChartRthActive` at the chart interval), else 'extended'. A crypto or
|
|
58
|
+
* equities chart stamps a meaningless 'regular' it has no control to change, which must never filter a CME leg of its
|
|
59
|
+
* formula to the cash session; the chart's own market reads the chart's session as before.
|
|
60
|
+
*
|
|
53
61
|
* @param metadata - Chart metadata containing transformations and session settings
|
|
54
62
|
* @param transformations - Expression string (e.g., "BINANCE|BTCUSDT + POLYGON|NVDA")
|
|
55
63
|
* @returns Context object with token modes, session types, and mixed-mode flags
|
|
@@ -58,6 +66,7 @@ export function buildMixedModeContext(metadata, transformations) {
|
|
|
58
66
|
const tokens = extractTokensFromTransformations(transformations);
|
|
59
67
|
const tokenSessionTypes = {};
|
|
60
68
|
const tokenExchanges = {};
|
|
69
|
+
let chartRthActive;
|
|
61
70
|
const tokenModes = tokens.map((token) => {
|
|
62
71
|
const resolvedExchange = getExchangeFromSymbol(token.exchange ?? '', token.symbol ?? '');
|
|
63
72
|
const isIndex = checkIsIndexMode(resolvedExchange);
|
|
@@ -67,6 +76,11 @@ export function buildMixedModeContext(metadata, transformations) {
|
|
|
67
76
|
const resolvedSessionType = metadata.sessionType ?? 'regular';
|
|
68
77
|
tokenSessionTypes[token.token] = resolvedSessionType;
|
|
69
78
|
}
|
|
79
|
+
else if (hasRthWindow(token.symbol, resolvedExchange) &&
|
|
80
|
+
!(resolvedExchange === metadata?.exchange && token.symbol === metadata?.symbol)) {
|
|
81
|
+
chartRthActive ??= isChartRthActive(metadata?.exchange, metadata?.symbol, metadata?.sessionType, chartIntervalToMs(metadata?.interval));
|
|
82
|
+
tokenSessionTypes[token.token] = chartRthActive ? 'regular' : 'extended';
|
|
83
|
+
}
|
|
70
84
|
return {
|
|
71
85
|
tokenKey: token.token,
|
|
72
86
|
isIndex,
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `opra-user-scripts`
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* and internal `kiyo.flag-overrides` lens reaches the walls before the map lands and through a failed fetch, exactly
|
|
9
|
-
* as it reaches `opraUserScriptsEnabled` (opra-options-gate.util) and the editor's Run wall: the walls and the
|
|
10
|
-
* surfaces never disagree, and a restore that skipped the hydration wait on an override judges by that override. In
|
|
11
|
-
* any context neither reached (a worker, a guest-less spec), the gate reads closed: fail dark, today's wall.
|
|
2
|
+
* The `opra-user-scripts` gate as the venue policy reads it (kscript-venue-policy.util, the one decider of the
|
|
3
|
+
* governed walls). LAUNCHED 2026-10-27 (Kyle: ship it directly): the OPRA licence covers user-authored scripting,
|
|
4
|
+
* so the gate answers open on every build, in every context (the main thread, a worker, a spec). The runtime flag
|
|
5
|
+
* record `opra-user-scripts` is retired: the feature-flags store still calls the two setters below after it is
|
|
6
|
+
* created and after every fetch, and they keep nothing, so a flipped record changes nothing. Rollback is a revert of
|
|
7
|
+
* this file and opra-options-gate.util, picked to production.
|
|
12
8
|
*/
|
|
13
|
-
/**
|
|
14
|
-
export declare function publishOpraUserScriptsFlag(
|
|
15
|
-
/**
|
|
16
|
-
export declare function setOpraUserScriptsFlagFallback(
|
|
17
|
-
/** Whether
|
|
18
|
-
* when neither can tell. */
|
|
9
|
+
/** Retired: the feature-flags store's publish after a fetch; the gate keeps no reader. */
|
|
10
|
+
export declare function publishOpraUserScriptsFlag(_next: (() => boolean) | null): void;
|
|
11
|
+
/** Retired: the feature-flags store's override-aware fallback; the gate keeps no reader. */
|
|
12
|
+
export declare function setOpraUserScriptsFlagFallback(_next: (() => boolean) | null): void;
|
|
13
|
+
/** Whether a user run may read the OPRA plane at the viewer's tier: always, since the launch. */
|
|
19
14
|
export declare function isOpraUserScriptsFlagOn(): boolean;
|
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `opra-user-scripts`
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* and internal `kiyo.flag-overrides` lens reaches the walls before the map lands and through a failed fetch, exactly
|
|
9
|
-
* as it reaches `opraUserScriptsEnabled` (opra-options-gate.util) and the editor's Run wall: the walls and the
|
|
10
|
-
* surfaces never disagree, and a restore that skipped the hydration wait on an override judges by that override. In
|
|
11
|
-
* any context neither reached (a worker, a guest-less spec), the gate reads closed: fail dark, today's wall.
|
|
2
|
+
* The `opra-user-scripts` gate as the venue policy reads it (kscript-venue-policy.util, the one decider of the
|
|
3
|
+
* governed walls). LAUNCHED 2026-10-27 (Kyle: ship it directly): the OPRA licence covers user-authored scripting,
|
|
4
|
+
* so the gate answers open on every build, in every context (the main thread, a worker, a spec). The runtime flag
|
|
5
|
+
* record `opra-user-scripts` is retired: the feature-flags store still calls the two setters below after it is
|
|
6
|
+
* created and after every fetch, and they keep nothing, so a flipped record changes nothing. Rollback is a revert of
|
|
7
|
+
* this file and opra-options-gate.util, picked to production.
|
|
12
8
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
export function
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
/** Called by the feature-flags store when it is created: its override-aware `isOn`, read until a fetch publishes. */
|
|
20
|
-
export function setOpraUserScriptsFlagFallback(next) {
|
|
21
|
-
fallback = next;
|
|
22
|
-
}
|
|
23
|
-
/** Whether the `opra-user-scripts` flag is on for this session: the published answer, else the store's own; closed
|
|
24
|
-
* when neither can tell. */
|
|
9
|
+
/** Retired: the feature-flags store's publish after a fetch; the gate keeps no reader. */
|
|
10
|
+
export function publishOpraUserScriptsFlag(_next) { }
|
|
11
|
+
/** Retired: the feature-flags store's override-aware fallback; the gate keeps no reader. */
|
|
12
|
+
export function setOpraUserScriptsFlagFallback(_next) { }
|
|
13
|
+
/** Whether a user run may read the OPRA plane at the viewer's tier: always, since the launch. */
|
|
25
14
|
export function isOpraUserScriptsFlagOn() {
|
|
26
|
-
|
|
27
|
-
return (published ?? fallback)?.() === true;
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
15
|
+
return true;
|
|
32
16
|
}
|
|
@@ -28,14 +28,15 @@ export declare function futuresRootOf(symbol: unknown): string | null;
|
|
|
28
28
|
*/
|
|
29
29
|
export declare function getRthWindowForSymbol(symbol: unknown): Readonly<RthWindow> | null;
|
|
30
30
|
/**
|
|
31
|
-
* The RTH window the
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
31
|
+
* The RTH window the script-facing session facts read for a symbol (wrun
|
|
32
|
+
* `time.session`, wrun-bar-session-facts.util): the root's own window, the one
|
|
33
|
+
* every chart gate reads (`getRthWindowForSymbol`: 09:00 to 14:30 New York on
|
|
34
|
+
* the NYMEX energy roots, 09:30 to 16:15 on every other mapped root), so an
|
|
35
|
+
* indicator's session reads the bars the chart's RTH mode keeps. The shared
|
|
36
|
+
* host's venue layer (om session-facts-venues.ts) reads the same windows and
|
|
37
|
+
* the WRUN-SESSIONS C3 golden pins them, so the browser and cloud runs agree.
|
|
38
|
+
* The kScript engine's uniform table (the platform window on every root) is
|
|
39
|
+
* being retired and binds nothing. Null for an unmapped root.
|
|
39
40
|
*/
|
|
40
41
|
export declare function engineRthWindowForSymbol(symbol: unknown): Readonly<RthWindow> | null;
|
|
41
42
|
export declare const SESSION_HOURS_ETH: "eth";
|
|
@@ -18,19 +18,21 @@
|
|
|
18
18
|
* rows through `isWithinRthWindow`, the live-feed service gates merges).
|
|
19
19
|
*
|
|
20
20
|
* The ROOT SET mirrors the engine's venue-sessions module
|
|
21
|
-
* (`@orangecharts/kscript` `dist/kscript/venue-sessions.d.ts`)
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* is
|
|
21
|
+
* (`@orangecharts/kscript` `dist/kscript/venue-sessions.d.ts`) and the shared
|
|
22
|
+
* host's venue layer (om `packages/sdk/src/wrun-host/session-facts-venues.ts`
|
|
23
|
+
* `RTH_ROOT_EXCHANGES`, the same root to listing-exchange table): when a root
|
|
24
|
+
* is added to one, add it to the others in the same wave. The published
|
|
25
|
+
* engine package ships ONLY the .d.ts for that subpath (the implementation is
|
|
26
|
+
* bundled and mangled inside `dist/kscript-engine.js` and not re-exported
|
|
25
27
|
* from the main entry), so the runtime import cannot resolve; `futuresRootOf`
|
|
26
28
|
* below is a verbatim mirror of the engine source. The WINDOWS follow the
|
|
27
|
-
* wire, not the engine: the engine table (3.0.94)
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
29
|
+
* wire, not the engine: the engine table (3.0.94) gives the NYMEX energy
|
|
30
|
+
* roots the uniform 09:30-16:15 window, and that table is being retired, so it
|
|
31
|
+
* binds nothing here. Every reader takes the root's own window from this
|
|
32
|
+
* table: the chart's gates (`getRthWindowForSymbol`) and the script-facing
|
|
33
|
+
* session facts (`engineRthWindowForSymbol`, wrun `time.session`), the energy
|
|
34
|
+
* pit session on NYMEX included, and the shared host's venue layer reads the
|
|
35
|
+
* same windows, so a browser run and a cloud run of one indicator agree.
|
|
34
36
|
*/
|
|
35
37
|
import dayjs from 'dayjs';
|
|
36
38
|
import timezone from 'dayjs/plugin/timezone.js';
|
|
@@ -190,17 +192,18 @@ export function getRthWindowForSymbol(symbol) {
|
|
|
190
192
|
return root ? (RTH_WINDOW_BY_ROOT.get(root) ?? null) : null;
|
|
191
193
|
}
|
|
192
194
|
/**
|
|
193
|
-
* The RTH window the
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
195
|
+
* The RTH window the script-facing session facts read for a symbol (wrun
|
|
196
|
+
* `time.session`, wrun-bar-session-facts.util): the root's own window, the one
|
|
197
|
+
* every chart gate reads (`getRthWindowForSymbol`: 09:00 to 14:30 New York on
|
|
198
|
+
* the NYMEX energy roots, 09:30 to 16:15 on every other mapped root), so an
|
|
199
|
+
* indicator's session reads the bars the chart's RTH mode keeps. The shared
|
|
200
|
+
* host's venue layer (om session-facts-venues.ts) reads the same windows and
|
|
201
|
+
* the WRUN-SESSIONS C3 golden pins them, so the browser and cloud runs agree.
|
|
202
|
+
* The kScript engine's uniform table (the platform window on every root) is
|
|
203
|
+
* being retired and binds nothing. Null for an unmapped root.
|
|
201
204
|
*/
|
|
202
205
|
export function engineRthWindowForSymbol(symbol) {
|
|
203
|
-
return getRthWindowForSymbol(symbol)
|
|
206
|
+
return getRthWindowForSymbol(symbol);
|
|
204
207
|
}
|
|
205
208
|
/** Root of a `<ROOT>1!` continuous symbol, mirroring the engine's fallback. */
|
|
206
209
|
function continuousRthRootOf(symbol) {
|
|
@@ -61,6 +61,23 @@ export type TradingDayPeriod = 'Session' | 'Week' | 'Month' | 'Year';
|
|
|
61
61
|
* at the reopen print, with no venue holiday knowledge needed.
|
|
62
62
|
*/
|
|
63
63
|
export declare function getTradingDayPeriodStartSec(timestampSec: number, period: TradingDayPeriod, anchor: TradingDayAnchor): number;
|
|
64
|
+
/** The calendar units a session period can run on trading dates. */
|
|
65
|
+
export type TradingPeriodUnit = 'week' | 'month';
|
|
66
|
+
/**
|
|
67
|
+
* The open (ms) of the `count`-unit calendar period holding the TRADING date
|
|
68
|
+
* of `tsMs`: weeks on the ISO Monday lattice, months from January 1970 (so 3
|
|
69
|
+
* is the calendar quarter and 12 the year), grouped as titan groups them
|
|
70
|
+
* (utils/tradingDay.ts calendarGroupIndex), opening with the trading day
|
|
71
|
+
* labeled by the period's first calendar date (Sunday 17:00 America/Chicago
|
|
72
|
+
* for a CME Monday). Titan's `tradingPeriodStartMs`, the grid a session
|
|
73
|
+
* profile folds its weekly and monthly cells on under `calendarPeriodAnchor:
|
|
74
|
+
* 'tradingDay'` (src/renderers/profile/sessionGrid.ts); the fetch-head decider
|
|
75
|
+
* and the history trim mirror it here. `getTradingDayPeriodStartSec` is the
|
|
76
|
+
* same rule for one week, one month and one year, in seconds.
|
|
77
|
+
*/
|
|
78
|
+
export declare function tradingPeriodStartMs(tsMs: number, anchor: TradingDayAnchor, unit: TradingPeriodUnit, count: number): number;
|
|
79
|
+
/** The first period open strictly after `tsMs` (the end of the period holding it). */
|
|
80
|
+
export declare function nextTradingPeriodStartMs(tsMs: number, anchor: TradingDayAnchor, unit: TradingPeriodUnit, count: number): number;
|
|
64
81
|
/**
|
|
65
82
|
* The TPO custom-time-range projection of an anchor, or undefined when the
|
|
66
83
|
* anchor is absent, invalid, or has no wire-expressible projection. The CME
|
|
@@ -289,6 +289,65 @@ export function getTradingDayPeriodStartSec(timestampSec, period, anchor) {
|
|
|
289
289
|
const openDate = anchor.openMinutes >= 720 ? shiftCalendarDate(firstTradeDate, -1) : firstTradeDate;
|
|
290
290
|
return wallInstantMs(anchor.timeZone, openDate, anchor.openMinutes) / 1000;
|
|
291
291
|
}
|
|
292
|
+
/** 1970-01-01 (date index 0) is a Thursday: the Monday before it is index -3 (titan's lattice). */
|
|
293
|
+
const MONDAY_EPOCH_OFFSET_DAYS = 3;
|
|
294
|
+
const PERIOD_DAY_MS = 86_400_000;
|
|
295
|
+
function dateIndexOf(date) {
|
|
296
|
+
return Math.round(Date.UTC(date.y, date.m - 1, date.d) / PERIOD_DAY_MS);
|
|
297
|
+
}
|
|
298
|
+
function calendarDateOfIndex(index) {
|
|
299
|
+
const date = new Date(index * PERIOD_DAY_MS);
|
|
300
|
+
return { y: date.getUTCFullYear(), m: date.getUTCMonth() + 1, d: date.getUTCDate() };
|
|
301
|
+
}
|
|
302
|
+
/** titan's calendarGroupIndex for weeks (ISO weeks from Monday 1969-12-29) and months (from January 1970). */
|
|
303
|
+
function calendarGroupIndexOf(dateIndex, unit, count) {
|
|
304
|
+
const n = count >= 1 ? Math.floor(count) : 1;
|
|
305
|
+
if (unit === 'month') {
|
|
306
|
+
const date = new Date(dateIndex * PERIOD_DAY_MS);
|
|
307
|
+
return Math.floor(((date.getUTCFullYear() - 1970) * 12 + date.getUTCMonth()) / n);
|
|
308
|
+
}
|
|
309
|
+
return Math.floor(Math.floor((dateIndex + MONDAY_EPOCH_OFFSET_DAYS) / 7) / n);
|
|
310
|
+
}
|
|
311
|
+
/** titan's calendarGroupFirstDateIndex: the first date index of a calendar group. */
|
|
312
|
+
function calendarGroupFirstDateIndexOf(groupIndex, unit, count) {
|
|
313
|
+
const n = count >= 1 ? Math.floor(count) : 1;
|
|
314
|
+
if (unit === 'month') {
|
|
315
|
+
const monthIndex = groupIndex * n;
|
|
316
|
+
const year = 1970 + Math.floor(monthIndex / 12);
|
|
317
|
+
return Math.round(Date.UTC(year, monthIndex - (year - 1970) * 12, 1) / PERIOD_DAY_MS);
|
|
318
|
+
}
|
|
319
|
+
return groupIndex * n * 7 - MONDAY_EPOCH_OFFSET_DAYS;
|
|
320
|
+
}
|
|
321
|
+
/** The open (ms) of the trading day labeled by `date`: evening opens label the next date, so they open the day before. */
|
|
322
|
+
function tradingDateOpenMs(date, anchor) {
|
|
323
|
+
const openDate = anchor.openMinutes >= 720 ? shiftCalendarDate(date, -1) : date;
|
|
324
|
+
return wallInstantMs(anchor.timeZone, openDate, anchor.openMinutes);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* The open (ms) of the `count`-unit calendar period holding the TRADING date
|
|
328
|
+
* of `tsMs`: weeks on the ISO Monday lattice, months from January 1970 (so 3
|
|
329
|
+
* is the calendar quarter and 12 the year), grouped as titan groups them
|
|
330
|
+
* (utils/tradingDay.ts calendarGroupIndex), opening with the trading day
|
|
331
|
+
* labeled by the period's first calendar date (Sunday 17:00 America/Chicago
|
|
332
|
+
* for a CME Monday). Titan's `tradingPeriodStartMs`, the grid a session
|
|
333
|
+
* profile folds its weekly and monthly cells on under `calendarPeriodAnchor:
|
|
334
|
+
* 'tradingDay'` (src/renderers/profile/sessionGrid.ts); the fetch-head decider
|
|
335
|
+
* and the history trim mirror it here. `getTradingDayPeriodStartSec` is the
|
|
336
|
+
* same rule for one week, one month and one year, in seconds.
|
|
337
|
+
*/
|
|
338
|
+
export function tradingPeriodStartMs(tsMs, anchor, unit, count) {
|
|
339
|
+
if (!Number.isFinite(tsMs))
|
|
340
|
+
return Number.NaN;
|
|
341
|
+
const group = calendarGroupIndexOf(dateIndexOf(tradingDateOf(tsMs, anchor)), unit, count);
|
|
342
|
+
return tradingDateOpenMs(calendarDateOfIndex(calendarGroupFirstDateIndexOf(group, unit, count)), anchor);
|
|
343
|
+
}
|
|
344
|
+
/** The first period open strictly after `tsMs` (the end of the period holding it). */
|
|
345
|
+
export function nextTradingPeriodStartMs(tsMs, anchor, unit, count) {
|
|
346
|
+
if (!Number.isFinite(tsMs))
|
|
347
|
+
return Number.NaN;
|
|
348
|
+
const group = calendarGroupIndexOf(dateIndexOf(tradingDateOf(tsMs, anchor)), unit, count) + 1;
|
|
349
|
+
return tradingDateOpenMs(calendarDateOfIndex(calendarGroupFirstDateIndexOf(group, unit, count)), anchor);
|
|
350
|
+
}
|
|
292
351
|
/**
|
|
293
352
|
* The TPO custom-time-range projection of an anchor, or undefined when the
|
|
294
353
|
* anchor is absent, invalid, or has no wire-expressible projection. The CME
|
|
@@ -10,12 +10,33 @@ export declare const WRUN_WINDOW_SETTING = "wrunWindow";
|
|
|
10
10
|
* the flag is.
|
|
11
11
|
*/
|
|
12
12
|
export declare const WRUN_WINDOW_SPLIT_SETTING = "wrunWindowSplit";
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* The built-in Indicators that own a window the way a wrun Indicator does, by indicator type: the nine of the Options
|
|
15
|
+
* panel (NATIVE-WINDOW, 2026-10-28). Another built-in joins by adding its type here; every seam reads this one list.
|
|
16
|
+
*/
|
|
17
|
+
export declare const WINDOW_NATIVE_OWNER_TYPES: ReadonlySet<string>;
|
|
18
|
+
/**
|
|
19
|
+
* An overlay as the window rules read it: its id, its type and its settings bag. A workspace row names its Indicator
|
|
20
|
+
* by `type` (its settings hold no `ovType`: an identity key no row keeps); an engine meta by `settings.ovType` (its
|
|
21
|
+
* `type` is the side).
|
|
22
|
+
*/
|
|
14
23
|
export type WindowOwnerOverlay = {
|
|
15
24
|
id?: unknown;
|
|
25
|
+
type?: unknown;
|
|
16
26
|
settings?: Record<string, unknown> | null;
|
|
17
27
|
} | null | undefined;
|
|
18
|
-
/**
|
|
28
|
+
/** The type of a built-in of WINDOW_NATIVE_OWNER_TYPES: a row's `type`, else an engine meta's `settings.ovType`. */
|
|
29
|
+
export declare function windowNativeTypeOf(overlay: WindowOwnerOverlay): string | undefined;
|
|
30
|
+
/** Whether an overlay is a built-in that can own a window (WINDOW_NATIVE_OWNER_TYPES). */
|
|
31
|
+
export declare function isWindowNativeOverlay(overlay: WindowOwnerOverlay): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether a document row can own a window, flagged or not: a saved wrun Indicator (registry or hosted: an editor
|
|
34
|
+
* draft has no row, draft-window.util) or a built-in of WINDOW_NATIVE_OWNER_TYPES. The doors that offer or open a
|
|
35
|
+
* window and the flag writer read it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function canOwnWindow(overlay: WindowOwnerOverlay): boolean;
|
|
38
|
+
/** A wrun Indicator overlay (registry, draft or hosted lane) or a built-in of WINDOW_NATIVE_OWNER_TYPES that carries
|
|
39
|
+
* the owner flag. */
|
|
19
40
|
export declare function isWrunWindowOwner(overlay: WindowOwnerOverlay): boolean;
|
|
20
41
|
/**
|
|
21
42
|
* An engine meta as the window's pane mark reads it. The window geometry (window-geometry.leaf, C5) hides an owner's
|
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
* window contract) as a leaf with no app import: the owner flag's settings key, the saved split's settings key and
|
|
4
4
|
* the owner test. The child mount (wrun-panel-mount.util) and the window geometry leaf read them, and they move into
|
|
5
5
|
* the wrun chart-host package, which the cell readers' reactive draft windows (draft-window.util) may not reach.
|
|
6
|
+
*
|
|
7
|
+
* Two kinds of Indicator can own a window: a wrun Indicator (the feature's name: the flag key stays `wrunWindow`), and
|
|
8
|
+
* a built-in of WINDOW_NATIVE_OWNER_TYPES. Every window seam (the owner test, the doors, the flag writer, the content
|
|
9
|
+
* and name reads) asks this rule, never wrun identity alone.
|
|
6
10
|
*/
|
|
7
|
-
import { isWrunPackageOverlaySettings } from '../wrun/wrun-overlay-identity.util.js';
|
|
11
|
+
import { isWrunPackageOverlaySettings, isWrunSavedPackageOverlaySettings } from '../wrun/wrun-overlay-identity.util.js';
|
|
8
12
|
/** The owner flag's settings key (persisted: `settingsToSave`, indicator.constants). */
|
|
9
13
|
export const WRUN_WINDOW_SETTING = 'wrunWindow';
|
|
10
14
|
/**
|
|
@@ -17,10 +21,48 @@ export const WRUN_WINDOW_SETTING = 'wrunWindow';
|
|
|
17
21
|
* the flag is.
|
|
18
22
|
*/
|
|
19
23
|
export const WRUN_WINDOW_SPLIT_SETTING = 'wrunWindowSplit';
|
|
20
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* The built-in Indicators that own a window the way a wrun Indicator does, by indicator type: the nine of the Options
|
|
26
|
+
* panel (NATIVE-WINDOW, 2026-10-28). Another built-in joins by adding its type here; every seam reads this one list.
|
|
27
|
+
*/
|
|
28
|
+
export const WINDOW_NATIVE_OWNER_TYPES = new Set([
|
|
29
|
+
'OPTIONS_GEX',
|
|
30
|
+
'OPTIONS_HEATMAP',
|
|
31
|
+
'OPTIONS_FLOW',
|
|
32
|
+
'OPTIONS_GEX_CURVE',
|
|
33
|
+
'OPTIONS_FLOW_PULSE',
|
|
34
|
+
'OPTIONS_FLOW_EXPIRY',
|
|
35
|
+
'BINANCE_PUT_CALL_RATIO',
|
|
36
|
+
'IMPLIED_VOLATILITY_TICKER',
|
|
37
|
+
'VOLATILITY_INDEX',
|
|
38
|
+
]);
|
|
39
|
+
/** The type of a built-in of WINDOW_NATIVE_OWNER_TYPES: a row's `type`, else an engine meta's `settings.ovType`. */
|
|
40
|
+
export function windowNativeTypeOf(overlay) {
|
|
41
|
+
for (const type of [overlay?.type, overlay?.settings?.ovType]) {
|
|
42
|
+
if (typeof type === 'string' && WINDOW_NATIVE_OWNER_TYPES.has(type))
|
|
43
|
+
return type;
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
/** Whether an overlay is a built-in that can own a window (WINDOW_NATIVE_OWNER_TYPES). */
|
|
48
|
+
export function isWindowNativeOverlay(overlay) {
|
|
49
|
+
return windowNativeTypeOf(overlay) !== undefined;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Whether a document row can own a window, flagged or not: a saved wrun Indicator (registry or hosted: an editor
|
|
53
|
+
* draft has no row, draft-window.util) or a built-in of WINDOW_NATIVE_OWNER_TYPES. The doors that offer or open a
|
|
54
|
+
* window and the flag writer read it.
|
|
55
|
+
*/
|
|
56
|
+
export function canOwnWindow(overlay) {
|
|
57
|
+
return isWrunSavedPackageOverlaySettings(overlay?.settings) || isWindowNativeOverlay(overlay);
|
|
58
|
+
}
|
|
59
|
+
/** A wrun Indicator overlay (registry, draft or hosted lane) or a built-in of WINDOW_NATIVE_OWNER_TYPES that carries
|
|
60
|
+
* the owner flag. */
|
|
21
61
|
export function isWrunWindowOwner(overlay) {
|
|
22
62
|
const settings = overlay?.settings;
|
|
23
|
-
return !!settings &&
|
|
63
|
+
return (!!settings &&
|
|
64
|
+
settings[WRUN_WINDOW_SETTING] === true &&
|
|
65
|
+
(isWrunPackageOverlaySettings(settings) || isWindowNativeOverlay(overlay)));
|
|
24
66
|
}
|
|
25
67
|
/** Whether a meta's pane is hidden by its window (above) and not by the reader: a gate that holds a collapsed pane's
|
|
26
68
|
* runs lets this owner run, since its runs feed the window's tables (wrun-overlay-recovery.util). */
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* C3): `time.trade_date` and `time.session`. Both are facts of the bar's
|
|
4
4
|
* market (exchange, symbol), its interval and its open time ONLY, never of
|
|
5
5
|
* the chart's RTH / extended mode, and every hour comes from the chart's own
|
|
6
|
-
* session definitions, the RTH window
|
|
7
|
-
* NYMEX below).
|
|
6
|
+
* session definitions, the RTH window the root's own (see NYMEX below).
|
|
8
7
|
*
|
|
9
8
|
* Calendar bars (an interval of one day or longer: 1D, 3D, 1W, 1M) read the
|
|
10
9
|
* UTC date of their open stamp and 1 on every market: the chart stamps them
|
|
@@ -16,27 +15,44 @@
|
|
|
16
15
|
* alias): the chart's CME trade date, `cmeSessionBucketMs(t, 1d)`, so the
|
|
17
16
|
* 17:00 Chicago open belongs to the NEXT date;
|
|
18
17
|
* - US equities (`getMarketKind` 'tradfi'): the New York calendar date;
|
|
19
|
-
* -
|
|
18
|
+
* - forex (`getMarketKind` 'forex': FX_OTC, POLYGON_FX): the New York
|
|
19
|
+
* trade date, which opens at 17:00 New York (the forex day runs 17:00 to
|
|
20
|
+
* 17:00 New York, 21:00Z in summer and 22:00Z in winter), so a bar from
|
|
21
|
+
* 17:00 New York on belongs to the NEXT date and Sunday 17:00 New York
|
|
22
|
+
* opens Monday's; the same minute `market.session_open()` fills
|
|
23
|
+
* (WRUN_MARKET_SESSION_OPEN_FOREX);
|
|
24
|
+
* - everything else (crypto, HIP-3, Polymarket, ...): the UTC date.
|
|
20
25
|
* - session, 1 regular, 2 pre-market, 3 after-hours, 0 closed:
|
|
21
26
|
* - US equities: `resolveUsEquitySessionPhase`;
|
|
22
27
|
* - CME family: 0 while the weekly schedule says closed
|
|
23
28
|
* (`getGovernedFuturesScheduleStatusForSymbol`, which carries the 24/7
|
|
24
|
-
* roots); else 1 inside the
|
|
25
|
-
* (`engineRthWindowForSymbol`, 09:30 to 16:15 New York
|
|
26
|
-
*
|
|
27
|
-
* trade date's RTH window and 3 after
|
|
28
|
-
*
|
|
29
|
+
* roots); else 1 inside the root's RTH window
|
|
30
|
+
* (`engineRthWindowForSymbol`, the chart's own: 09:30 to 16:15 New York,
|
|
31
|
+
* 09:00 to 14:30 on the NYMEX energy roots; a root without a window is
|
|
32
|
+
* regular all session), 2 before its trade date's RTH window and 3 after
|
|
33
|
+
* it;
|
|
34
|
+
* - forex and everything else: 1 (forex has no phases; its closed hours
|
|
35
|
+
* print no bars).
|
|
36
|
+
*
|
|
37
|
+
* The chart's own trading-day anchor (trading-day.util `getTradingDayAnchor`,
|
|
38
|
+
* the gate TPO, VWAP, the session dividers and the previous close read) does
|
|
39
|
+
* not carry the forex day yet: like US equities, forex keeps the display day
|
|
40
|
+
* there until that gate gains a New York 17:00 anchor in its own change, so
|
|
41
|
+
* a forex Indicator's trade date rolls at 17:00 New York while the chart's
|
|
42
|
+
* native dividers still roll at midnight.
|
|
29
43
|
*
|
|
30
44
|
* The golden vectors every other host (kscript-alerts, kscript-backend, om)
|
|
31
45
|
* tests against are generated from this module:
|
|
32
46
|
* src/fixtures/wrun-session-facts/golden.json.
|
|
33
47
|
*
|
|
34
|
-
* NYMEX: the
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
48
|
+
* NYMEX: the facts follow the energy pit session, 09:00 to 14:30 New York, the
|
|
49
|
+
* window the chart judges RTH on there (rth-session.util
|
|
50
|
+
* `rthWindowForExchange`, the gateway's REGULAR window), so an indicator's
|
|
51
|
+
* `time.session` reads regular on exactly the bars an RTH chart keeps. The
|
|
52
|
+
* shared host's venue layer (om session-facts-venues.ts) reads the same
|
|
53
|
+
* windows and the golden pins them, so the browser and cloud runs of one
|
|
54
|
+
* indicator agree; the kScript engine's uniform 09:30 to 16:15 table is being
|
|
55
|
+
* retired and binds nothing.
|
|
40
56
|
*
|
|
41
57
|
* Cost: the definitions run at microseconds a call (the equities phase reads
|
|
42
58
|
* dayjs timezone parts, about 30 us), so a 50k-bar run cannot afford one per
|
|
@@ -48,6 +64,8 @@
|
|
|
48
64
|
* Chicago hours (16:00 and 17:00, the Saturday 02:00 to 04:00 window);
|
|
49
65
|
* - the equities phase per New York (weekday, half hour): its boundaries are
|
|
50
66
|
* 04:00, 09:30, 16:00 and 20:00;
|
|
67
|
+
* - the forex trade date per New York (date, hour): its one boundary is the
|
|
68
|
+
* whole hour 17:00;
|
|
51
69
|
* - the CME RTH window per (window, trade date).
|
|
52
70
|
* Both zones sit a whole number of hours off UTC, so a reader also keeps its
|
|
53
71
|
* last answer per UTC hour (CME: the trade date and the schedule bit) or half
|
|
@@ -88,7 +106,7 @@ export interface WrunBarVenue {
|
|
|
88
106
|
barGrid?: LiveBucketVenue;
|
|
89
107
|
}
|
|
90
108
|
/** Which C3 rule a market follows. */
|
|
91
|
-
export type WrunBarFactsMarket = 'cme' | 'us_equities' | 'utc';
|
|
109
|
+
export type WrunBarFactsMarket = 'cme' | 'us_equities' | 'forex' | 'utc';
|
|
92
110
|
export declare function wrunBarFactsMarketOf(exchange: string): WrunBarFactsMarket;
|
|
93
111
|
/**
|
|
94
112
|
* The venue of chart metadata (or a live context's market) at the series'
|