@orangecharts/wrun-chart-host 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/feature-flags.constants.d.ts +9 -0
  3. package/dist/constants/feature-flags.constants.js +67 -4
  4. package/dist/constants/governed-exchanges.constants.d.ts +12 -0
  5. package/dist/constants/governed-exchanges.constants.js +16 -0
  6. package/dist/constants/option-venues.constants.d.ts +2 -2
  7. package/dist/host-env.d.ts +1 -9
  8. package/dist/host-ports.types.d.ts +36 -7
  9. package/dist/index.d.ts +7 -1
  10. package/dist/index.js +7 -1
  11. package/dist/indicators/controls/tpo-session.util.d.ts +36 -13
  12. package/dist/indicators/controls/tpo-session.util.js +217 -236
  13. package/dist/interfaces/cancel-reason.interface.d.ts +1 -1
  14. package/dist/interfaces/cme-realtime.interface.d.ts +16 -9
  15. package/dist/interfaces/cme-realtime.interface.js +6 -3
  16. package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
  17. package/dist/interfaces/opra-realtime.interface.d.ts +1 -5
  18. package/dist/interfaces/prediction-market.interface.d.ts +7 -0
  19. package/dist/interfaces/stocks-realtime.interface.d.ts +57 -0
  20. package/dist/interfaces/stocks-realtime.interface.js +32 -0
  21. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +48 -117
  22. package/dist/kscript-data/controls/live-trades-merge.util.js +97 -207
  23. package/dist/market-data/billing.interface.d.ts +86 -12
  24. package/dist/market-data/billing.interface.js +23 -4
  25. package/dist/market-data/venue.d.ts +65 -2
  26. package/dist/market-data/venues/index.d.ts +135 -5
  27. package/dist/market-data/venues/index.js +2 -1
  28. package/dist/market-data/venues/opra.contract.copy.json +3 -2
  29. package/dist/market-data/venues/opra.d.ts +2 -2
  30. package/dist/market-data/venues/opra.js +5 -2
  31. package/dist/market-data/venues/stocks.contract.copy.json +64 -0
  32. package/dist/market-data/venues/stocks.d.ts +130 -0
  33. package/dist/market-data/venues/stocks.js +117 -0
  34. package/dist/settings-templates/footprint-rows.js +35 -2
  35. package/dist/settings-templates/form-rows.d.ts +2 -1
  36. package/dist/settings-templates/indicator-fields.js +34 -4
  37. package/dist/settings-templates/tool-rules.d.ts +12 -5
  38. package/dist/settings-templates/tool-rules.js +11 -5
  39. package/dist/settings-templates/tool-tables.generated.js +4 -0
  40. package/dist/utility/chart/cme-cache-context.util.d.ts +5 -3
  41. package/dist/utility/chart/cme-cache-context.util.js +10 -6
  42. package/dist/utility/chart/cme-realtime.util.js +10 -0
  43. package/dist/utility/chart/cme-user-scripts-gate.util.d.ts +83 -0
  44. package/dist/utility/chart/cme-user-scripts-gate.util.js +142 -0
  45. package/dist/utility/chart/effective-chart-session.util.d.ts +14 -0
  46. package/dist/utility/chart/effective-chart-session.util.js +39 -0
  47. package/dist/utility/chart/host-bar-placement.util.d.ts +28 -0
  48. package/dist/utility/chart/host-bar-placement.util.js +170 -30
  49. package/dist/utility/chart/index-host-tier.util.d.ts +3 -1
  50. package/dist/utility/chart/index-host-tier.util.js +7 -2
  51. package/dist/utility/chart/index-mode-admission.util.js +25 -11
  52. package/dist/utility/chart/kscript-apply-fingerprint.util.js +1 -1
  53. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +6 -9
  54. package/dist/utility/chart/kscript-live-coalesce.util.js +8 -9
  55. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +9 -0
  56. package/dist/utility/chart/kscript-live-source-identity.util.js +10 -1
  57. package/dist/utility/chart/kscript-provenance-keys.util.js +7 -0
  58. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
  59. package/dist/utility/chart/kscript-venue-policy.util.d.ts +115 -21
  60. package/dist/utility/chart/kscript-venue-policy.util.js +194 -40
  61. package/dist/utility/chart/live-bucket.util.d.ts +24 -8
  62. package/dist/utility/chart/live-bucket.util.js +85 -27
  63. package/dist/utility/chart/market-sessions.util.d.ts +83 -0
  64. package/dist/utility/chart/market-sessions.util.js +220 -0
  65. package/dist/utility/chart/marketKind.util.js +5 -0
  66. package/dist/utility/chart/mixed-mode.util.d.ts +7 -0
  67. package/dist/utility/chart/mixed-mode.util.js +14 -0
  68. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +11 -16
  69. package/dist/utility/chart/opra-user-scripts-gate.util.js +12 -28
  70. package/dist/utility/chart/rth-session.util.d.ts +9 -8
  71. package/dist/utility/chart/rth-session.util.js +23 -20
  72. package/dist/utility/chart/session-interval.util.d.ts +2 -1
  73. package/dist/utility/chart/session-interval.util.js +1 -3
  74. package/dist/utility/chart/trading-day.util.d.ts +17 -0
  75. package/dist/utility/chart/trading-day.util.js +59 -0
  76. package/dist/utility/chart/window-owner.leaf.d.ts +23 -2
  77. package/dist/utility/chart/window-owner.leaf.js +45 -3
  78. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +33 -15
  79. package/dist/utility/chart/wrun-bar-session-facts.util.js +70 -20
  80. package/dist/utility/intl-locale.util.js +5 -0
  81. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
  82. package/dist/utility/v2/gate-plane.util.d.ts +12 -3
  83. package/dist/utility/v2/gate-plane.util.js +30 -4
  84. package/dist/utility/v2/gate-session-latch.util.js +1 -1
  85. package/dist/utility/v2/stocks-governed.util.d.ts +16 -0
  86. package/dist/utility/v2/stocks-governed.util.js +34 -0
  87. package/dist/utility/wrun/derived-roots.leaf.d.ts +13 -0
  88. package/dist/utility/wrun/derived-roots.leaf.js +27 -0
  89. package/dist/utility/wrun/derived-roots.util.d.ts +1 -9
  90. package/dist/utility/wrun/derived-roots.util.js +3 -23
  91. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +4 -3
  92. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +24 -3
  93. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +46 -10
  94. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +2 -0
  95. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +63 -16
  96. package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +58 -14
  97. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +34 -11
  98. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +106 -30
  99. package/dist/utility/wrun/wrun-browser-sources.leaf.js +1 -2
  100. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +7 -4
  101. package/dist/utility/wrun/wrun-chart-market-facts.util.js +12 -8
  102. package/dist/utility/wrun/wrun-color-settings.util.d.ts +9 -0
  103. package/dist/utility/wrun/wrun-color-settings.util.js +33 -0
  104. package/dist/utility/wrun/wrun-handles.util.d.ts +7 -3
  105. package/dist/utility/wrun/wrun-handles.util.js +9 -8
  106. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +68 -0
  107. package/dist/utility/wrun/wrun-input-requirements.leaf.js +163 -7
  108. package/dist/utility/wrun/wrun-leg-close.util.d.ts +59 -23
  109. package/dist/utility/wrun/wrun-leg-close.util.js +186 -28
  110. package/dist/utility/wrun/wrun-live-intake.util.d.ts +26 -12
  111. package/dist/utility/wrun/wrun-live-intake.util.js +219 -155
  112. package/dist/utility/wrun/wrun-live-tick.util.d.ts +9 -5
  113. package/dist/utility/wrun/wrun-live-tick.util.js +130 -94
  114. package/dist/utility/wrun/wrun-market-facts.util.d.ts +13 -3
  115. package/dist/utility/wrun/wrun-market-facts.util.js +13 -3
  116. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +20 -10
  117. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +10 -5
  118. package/dist/utility/wrun/wrun-option-book-rows.util.d.ts +56 -0
  119. package/dist/utility/wrun/wrun-option-book-rows.util.js +96 -0
  120. package/dist/utility/wrun/wrun-option-views.util.d.ts +281 -20
  121. package/dist/utility/wrun/wrun-option-views.util.js +391 -50
  122. package/dist/utility/wrun/wrun-options-chain.util.d.ts +3 -3
  123. package/dist/utility/wrun/wrun-options-chain.util.js +2 -0
  124. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +15 -2
  125. package/dist/utility/wrun/wrun-overlay-drivers.util.js +13 -3
  126. package/dist/utility/wrun/wrun-overlay-recovery.util.js +3 -1
  127. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +60 -11
  128. package/dist/utility/wrun/wrun-overlay-run.util.js +529 -113
  129. package/dist/utility/wrun/wrun-panel-mount.util.js +51 -6
  130. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +15 -2
  131. package/dist/utility/wrun/wrun-pin-spelling.util.js +27 -3
  132. package/dist/utility/wrun/wrun-refusal.util.d.ts +3 -2
  133. package/dist/utility/wrun/wrun-refusal.util.js +22 -0
  134. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +26 -0
  135. package/dist/utility/wrun/wrun-registry-errors.util.js +34 -0
  136. package/dist/utility/wrun/wrun-replay-lane.util.js +3 -2
  137. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +20 -6
  138. package/dist/utility/wrun/wrun-run-interval-session.util.js +22 -7
  139. package/dist/utility/wrun/wrun-run-interval.util.d.ts +39 -7
  140. package/dist/utility/wrun/wrun-run-interval.util.js +49 -9
  141. package/dist/utility/wrun/wrun-socket-row-source.js +7 -2
  142. package/dist/utility/wrun/wrun-source-rows.util.d.ts +29 -22
  143. package/dist/utility/wrun/wrun-source-rows.util.js +62 -41
  144. package/dist/utility/wrun/wrun-tape-per-order.util.js +1 -20
  145. package/dist/utility/wrun/wrun-tape-source.util.d.ts +17 -9
  146. package/dist/utility/wrun/wrun-tape-source.util.js +20 -12
  147. package/dist/utility/wrun/wrun-volume-profile.util.js +37 -29
  148. package/dist/workers/constants/socket-slots.d.ts +91 -6
  149. package/dist/workers/constants/socket-slots.js +85 -6
  150. package/package.json +5 -5
  151. package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +0 -56
  152. package/dist/kscript-data/controls/live-trades-order-gate.util.js +0 -107
@@ -0,0 +1,83 @@
1
+ /** A session's hours on its own clock. */
2
+ export interface MarketSessionWindow {
3
+ /** IANA zone the hours are written in. */
4
+ readonly timeZone: string;
5
+ /** Open, minutes after local midnight. */
6
+ readonly openMinutes: number;
7
+ /** Close, minutes after local midnight; at or below the open when the session crosses local midnight. */
8
+ readonly closeMinutes: number;
9
+ }
10
+ export type MarketSessionId = 'asia' | 'london' | 'newYork' | 'asiaFull' | 'londonFull' | 'newYorkFull';
11
+ export declare const MARKET_SESSIONS: Readonly<Record<MarketSessionId, MarketSessionWindow>>;
12
+ /** The window a stored session name means, or null for a name that is not a market session. */
13
+ export declare function marketSessionNamed(name: unknown): MarketSessionWindow | null;
14
+ /** The regions a session profile's Session dropdown stores (the Session VP family, Delta, the metric profiles). */
15
+ export declare const PROFILE_REGION_SESSION_TYPES: readonly ["US", "EU", "Asia"];
16
+ export type ProfileRegionSessionType = (typeof PROFILE_REGION_SESSION_TYPES)[number];
17
+ export declare function isProfileRegionSessionType(value: unknown): value is ProfileRegionSessionType;
18
+ /** The Session dropdown's day split (Session VP, Agg SVP): Asia, London, New York and after hours, a profile each. */
19
+ export declare const SESSION_SPLIT_TYPE = "Sessions";
20
+ export declare function isSessionSplitType(sessionType: unknown): boolean;
21
+ /** The longest chart bar the split draws on: a 1h bar straddles the 09:30 New York open. */
22
+ export declare const SESSION_SPLIT_MAX_CHART_MS: number;
23
+ export declare function isSessionSplitApplicable(chartIntervalMs: unknown): boolean;
24
+ /** A session type that brings its own hours (a region, the split): the Session start and Custom hours do not act. */
25
+ export declare function isMarketSessionType(sessionType: unknown): boolean;
26
+ /** A session profile's daily window as titan reads it (`customSessionWindow`): minutes after midnight on its zone. */
27
+ export interface SessionProfileDailyWindow {
28
+ timeZone: string;
29
+ startMinutes: number;
30
+ endMinutes: number;
31
+ }
32
+ /**
33
+ * A region's session profile keys: one profile a day inside the region's own window, which titan resolves on the
34
+ * region's clock each day. Null off the regions, and on a daily or longer chart, where a bar holds the whole session.
35
+ */
36
+ export declare function profileRegionSessionKeys(sessionType: unknown, chartIntervalMs: unknown): {
37
+ session: number;
38
+ customSessionWindow: SessionProfileDailyWindow;
39
+ } | null;
40
+ export type MarketSplitSliceId = 'asia' | 'london' | 'newYork' | 'afterHours';
41
+ export interface MarketSplitSlice {
42
+ readonly id: MarketSplitSliceId;
43
+ /** Start, minutes after midnight on the split's clock. */
44
+ readonly startMinutes: number;
45
+ /** End, minutes after midnight on the split's clock; below the start when the slice crosses midnight. */
46
+ readonly endMinutes: number;
47
+ }
48
+ export interface MarketSessionSplit {
49
+ /** The one IANA zone every slice is written in. */
50
+ readonly timeZone: string;
51
+ /** The slices in day order, each starting where the one before ends. */
52
+ readonly slices: readonly MarketSplitSlice[];
53
+ }
54
+ /**
55
+ * The day split into its sessions on ONE clock, New York, so the slices tile every day with no gap and no overlap
56
+ * whatever the clocks do: each slice ends where the next one opens. Asia opens with the CME Globex day at 18:00,
57
+ * London at 03:00 (08:00 in London, except in the weeks a year when the US and UK change clocks on different dates),
58
+ * New York at the 09:30 open, and after hours runs from the 16:00 close to the next Globex open. These are the
59
+ * America/New_York defaults of TradingView's "Three-Session Volume Profile" script. The London slice ends at the
60
+ * New York open, so it is shorter than the London session above.
61
+ */
62
+ export declare const MARKET_SESSION_SPLIT: MarketSessionSplit;
63
+ /** 'HH:MM' for minutes after local midnight: the clock text the wire and the dialogs use. */
64
+ export declare function sessionClockText(minutes: number): string;
65
+ /**
66
+ * The instant a window edge means on `timeZone`'s clock: the FIRST instant whose wall clock reads `wallMs` (a
67
+ * UTC-shaped epoch) or later. On an ordinary day that is the instant itself. A wall time that a fall-back change
68
+ * repeats is its first occurrence, and a wall time that a spring-forward change skips is the change itself: 02:30 New
69
+ * York on 2026-03-08 is 07:00Z, and 01:30 London on 2026-03-29 is 01:00Z. The gateway's local-minute filter reads a
70
+ * window the same way, so a session opens and closes where the served rows do. UTC reads as itself. NaN where the
71
+ * zone clock serves no reading.
72
+ */
73
+ export declare function zoneWallEdgeToUtcMs(timeZone: string, wallMs: number): number;
74
+ /**
75
+ * The session [open, close) as UTC instants on the local calendar day `localDayMs` (that day's midnight as a
76
+ * UTC-shaped epoch on the session's own clock). A close at or below the open lands on the next local day. Each edge
77
+ * is read on its own date with zoneWallEdgeToUtcMs, so a clock change moves the instant and keeps the wall hours, and
78
+ * an edge in a skipped or repeated hour lands where the gateway's filter puts it. NaN where the zone clock serves no
79
+ * reading.
80
+ */
81
+ export declare function marketSessionInstantsOn(session: MarketSessionWindow, localDayMs: number): readonly [number, number];
82
+ /** The [open, close) of the latest session opened at or before `tsMs` (forming or last closed); null if unreadable. */
83
+ export declare function marketSessionAtOrBefore(session: MarketSessionWindow, tsMs: number): readonly [number, number] | null;
@@ -0,0 +1,220 @@
1
+ /**
2
+ * The named trading sessions, written once. Every reader resolves a session's hours from here when it uses them and
3
+ * never keeps a copy: the Session Volume Profile family (Session VP, Aggregated Session VP, Delta, Open Interest and
4
+ * Liquidation profiles), TPO, Cumulative Returns by Session, session shading and wrun.
5
+ *
6
+ * Each session sits on its own city's clock (an IANA zone), so a name means the same hours in every indicator and
7
+ * daylight saving moves the session with its city. The mistake this ends: hours written as a fixed UTC window, or
8
+ * copied into another table or a saved setting, drift apart and ignore daylight saving. titan's fixed-UTC table put
9
+ * the US session at 08:30-15:00 New York every winter, and TPO's own table gave Asia, London and New York other
10
+ * hours again.
11
+ *
12
+ * Worker-safe: no Vue, store, i18n or dayjs imports.
13
+ */
14
+ import { zoneWallMsAt, zoneWallToUtcMs } from './ny-calendar.util.js';
15
+ const MINUTE_MS = 60_000;
16
+ const MINUTES_PER_DAY = 24 * 60;
17
+ const DAY_MS = MINUTES_PER_DAY * MINUTE_MS;
18
+ function sessionWindow(timeZone, openMinutes, closeMinutes) {
19
+ return Object.freeze({ timeZone, openMinutes, closeMinutes });
20
+ }
21
+ export const MARKET_SESSIONS = Object.freeze({
22
+ /** Asia: Tokyo hours with the pre-open, 08:00-15:00 Asia/Tokyo (23:00-06:00 UTC all year: Japan keeps no DST). */
23
+ asia: sessionWindow('Asia/Tokyo', 8 * 60, 15 * 60),
24
+ /** London: 08:00-16:00 Europe/London. */
25
+ london: sessionWindow('Europe/London', 8 * 60, 16 * 60),
26
+ /** New York: the cash session, 09:30-16:00 America/New_York. */
27
+ newYork: sessionWindow('America/New_York', 9 * 60 + 30, 16 * 60),
28
+ /** TPO's full Asia session, the forex Tokyo hours: 09:00-18:00 Asia/Tokyo. */
29
+ asiaFull: sessionWindow('Asia/Tokyo', 9 * 60, 18 * 60),
30
+ /** TPO's full London session, the forex London hours: 08:00-17:00 Europe/London. */
31
+ londonFull: sessionWindow('Europe/London', 8 * 60, 17 * 60),
32
+ /** TPO's full New York session, the forex New York hours: 08:00-17:00 America/New_York. */
33
+ newYorkFull: sessionWindow('America/New_York', 8 * 60, 17 * 60),
34
+ });
35
+ /**
36
+ * Every name a reader stores for a session, to its one window: the profiles' regions ('US', 'EU', 'Asia'),
37
+ * Cumulative Returns by Session's 'APAC', and TPO's trading-hour presets. A stored name stays as it was saved; only
38
+ * its hours come from here.
39
+ */
40
+ const SESSION_NAMES = Object.freeze({
41
+ US: 'newYork',
42
+ EU: 'london',
43
+ Asia: 'asia',
44
+ APAC: 'asia',
45
+ London: 'london',
46
+ 'New York': 'newYork',
47
+ 'Asia Full': 'asiaFull',
48
+ 'London Full': 'londonFull',
49
+ 'New York Full': 'newYorkFull',
50
+ });
51
+ /** The window a stored session name means, or null for a name that is not a market session. */
52
+ export function marketSessionNamed(name) {
53
+ if (typeof name !== 'string' || !Object.prototype.hasOwnProperty.call(SESSION_NAMES, name))
54
+ return null;
55
+ return MARKET_SESSIONS[SESSION_NAMES[name]];
56
+ }
57
+ /** The regions a session profile's Session dropdown stores (the Session VP family, Delta, the metric profiles). */
58
+ export const PROFILE_REGION_SESSION_TYPES = Object.freeze(['US', 'EU', 'Asia']);
59
+ export function isProfileRegionSessionType(value) {
60
+ return typeof value === 'string' && PROFILE_REGION_SESSION_TYPES.includes(value);
61
+ }
62
+ /** The Session dropdown's day split (Session VP, Agg SVP): Asia, London, New York and after hours, a profile each. */
63
+ export const SESSION_SPLIT_TYPE = 'Sessions';
64
+ export function isSessionSplitType(sessionType) {
65
+ return sessionType === SESSION_SPLIT_TYPE;
66
+ }
67
+ /** The longest chart bar the split draws on: a 1h bar straddles the 09:30 New York open. */
68
+ export const SESSION_SPLIT_MAX_CHART_MS = 30 * 60_000;
69
+ export function isSessionSplitApplicable(chartIntervalMs) {
70
+ return typeof chartIntervalMs === 'number' && chartIntervalMs > 0 && chartIntervalMs <= SESSION_SPLIT_MAX_CHART_MS;
71
+ }
72
+ /** A session type that brings its own hours (a region, the split): the Session start and Custom hours do not act. */
73
+ export function isMarketSessionType(sessionType) {
74
+ return isProfileRegionSessionType(sessionType) || isSessionSplitType(sessionType);
75
+ }
76
+ /**
77
+ * A region's session profile keys: one profile a day inside the region's own window, which titan resolves on the
78
+ * region's clock each day. Null off the regions, and on a daily or longer chart, where a bar holds the whole session.
79
+ */
80
+ export function profileRegionSessionKeys(sessionType, chartIntervalMs) {
81
+ if (!isProfileRegionSessionType(sessionType))
82
+ return null;
83
+ if (typeof chartIntervalMs !== 'number' || !(chartIntervalMs > 0) || chartIntervalMs >= DAY_MS)
84
+ return null;
85
+ const window = MARKET_SESSIONS[SESSION_NAMES[sessionType]];
86
+ return {
87
+ session: DAY_MS,
88
+ customSessionWindow: {
89
+ timeZone: window.timeZone,
90
+ startMinutes: window.openMinutes,
91
+ endMinutes: window.closeMinutes,
92
+ },
93
+ };
94
+ }
95
+ function splitSlice(id, startMinutes, endMinutes) {
96
+ return Object.freeze({ id, startMinutes, endMinutes });
97
+ }
98
+ /**
99
+ * The day split into its sessions on ONE clock, New York, so the slices tile every day with no gap and no overlap
100
+ * whatever the clocks do: each slice ends where the next one opens. Asia opens with the CME Globex day at 18:00,
101
+ * London at 03:00 (08:00 in London, except in the weeks a year when the US and UK change clocks on different dates),
102
+ * New York at the 09:30 open, and after hours runs from the 16:00 close to the next Globex open. These are the
103
+ * America/New_York defaults of TradingView's "Three-Session Volume Profile" script. The London slice ends at the
104
+ * New York open, so it is shorter than the London session above.
105
+ */
106
+ export const MARKET_SESSION_SPLIT = Object.freeze({
107
+ timeZone: 'America/New_York',
108
+ slices: Object.freeze([
109
+ splitSlice('asia', 18 * 60, 3 * 60),
110
+ splitSlice('london', 3 * 60, 9 * 60 + 30),
111
+ splitSlice('newYork', 9 * 60 + 30, 16 * 60),
112
+ splitSlice('afterHours', 16 * 60, 18 * 60),
113
+ ]),
114
+ });
115
+ /** 'HH:MM' for minutes after local midnight: the clock text the wire and the dialogs use. */
116
+ export function sessionClockText(minutes) {
117
+ const wrapped = ((Math.round(minutes) % MINUTES_PER_DAY) + MINUTES_PER_DAY) % MINUTES_PER_DAY;
118
+ const hours = Math.floor(wrapped / 60);
119
+ const mins = wrapped % 60;
120
+ return `${String(hours).padStart(2, '0')}:${String(mins).padStart(2, '0')}`;
121
+ }
122
+ /** How far a clock change moves the wall clock in every zone the session readers use (New York, Chicago, London). */
123
+ const CLOCK_CHANGE_MS = 60 * MINUTE_MS;
124
+ /**
125
+ * Every clock change in those zones moves the clock between 01:00 and 03:00 local (01:00 to 02:00 in London, 02:00 to
126
+ * 03:00 or back to 01:00 in New York and Chicago), so only a wall time in [01:00, 03:00) can be skipped or repeated.
127
+ * Any other edge is the solver's one reading, with no further clock reads.
128
+ */
129
+ const CHANGE_HOURS_START_MINUTES = 60;
130
+ const CHANGE_HOURS_END_MINUTES = 3 * 60;
131
+ function wallReadingAt(timeZone, ms) {
132
+ try {
133
+ return zoneWallMsAt(timeZone, ms);
134
+ }
135
+ catch {
136
+ return Number.NaN;
137
+ }
138
+ }
139
+ function solvedInstant(timeZone, wallMs) {
140
+ try {
141
+ return zoneWallToUtcMs(timeZone, wallMs);
142
+ }
143
+ catch {
144
+ return Number.NaN;
145
+ }
146
+ }
147
+ /**
148
+ * The instant a window edge means on `timeZone`'s clock: the FIRST instant whose wall clock reads `wallMs` (a
149
+ * UTC-shaped epoch) or later. On an ordinary day that is the instant itself. A wall time that a fall-back change
150
+ * repeats is its first occurrence, and a wall time that a spring-forward change skips is the change itself: 02:30 New
151
+ * York on 2026-03-08 is 07:00Z, and 01:30 London on 2026-03-29 is 01:00Z. The gateway's local-minute filter reads a
152
+ * window the same way, so a session opens and closes where the served rows do. UTC reads as itself. NaN where the
153
+ * zone clock serves no reading.
154
+ */
155
+ export function zoneWallEdgeToUtcMs(timeZone, wallMs) {
156
+ if (timeZone === 'UTC')
157
+ return wallMs;
158
+ const ms = solvedInstant(timeZone, wallMs);
159
+ if (!Number.isFinite(ms))
160
+ return Number.NaN;
161
+ const minuteOfDay = (((wallMs % DAY_MS) + DAY_MS) % DAY_MS) / MINUTE_MS;
162
+ if (minuteOfDay < CHANGE_HOURS_START_MINUTES || minuteOfDay >= CHANGE_HOURS_END_MINUTES)
163
+ return ms;
164
+ const readMs = wallReadingAt(timeZone, ms);
165
+ if (!Number.isFinite(readMs))
166
+ return Number.NaN;
167
+ if (readMs === wallMs) {
168
+ // A repeated wall time: the solver can hand back its later occurrence. One change earlier reads the same wall
169
+ // time only when the clock fell back in between, and that earlier instant is the first occurrence.
170
+ const earlier = ms - CLOCK_CHANGE_MS;
171
+ return wallReadingAt(timeZone, earlier) === wallMs ? earlier : ms;
172
+ }
173
+ // A skipped wall time: `ms` reads on one side of the jump, and one gap away the clock reads on the other. The first
174
+ // whole minute reading at or past the wall time is the change itself (changes fall on whole minutes).
175
+ let low = readMs < wallMs ? ms : ms - (readMs - wallMs);
176
+ let high = readMs < wallMs ? ms + (wallMs - readMs) : ms;
177
+ if (!(wallReadingAt(timeZone, high) >= wallMs) || wallReadingAt(timeZone, low) >= wallMs)
178
+ return ms;
179
+ while (high - low > MINUTE_MS) {
180
+ const mid = low + Math.floor((high - low) / (2 * MINUTE_MS)) * MINUTE_MS;
181
+ if (wallReadingAt(timeZone, mid) >= wallMs)
182
+ high = mid;
183
+ else
184
+ low = mid;
185
+ }
186
+ return high;
187
+ }
188
+ /**
189
+ * The session [open, close) as UTC instants on the local calendar day `localDayMs` (that day's midnight as a
190
+ * UTC-shaped epoch on the session's own clock). A close at or below the open lands on the next local day. Each edge
191
+ * is read on its own date with zoneWallEdgeToUtcMs, so a clock change moves the instant and keeps the wall hours, and
192
+ * an edge in a skipped or repeated hour lands where the gateway's filter puts it. NaN where the zone clock serves no
193
+ * reading.
194
+ */
195
+ export function marketSessionInstantsOn(session, localDayMs) {
196
+ const closeDayMs = session.closeMinutes <= session.openMinutes ? localDayMs + DAY_MS : localDayMs;
197
+ return [
198
+ zoneWallEdgeToUtcMs(session.timeZone, localDayMs + session.openMinutes * MINUTE_MS),
199
+ zoneWallEdgeToUtcMs(session.timeZone, closeDayMs + session.closeMinutes * MINUTE_MS),
200
+ ];
201
+ }
202
+ /** The [open, close) of the latest session opened at or before `tsMs` (forming or last closed); null if unreadable. */
203
+ export function marketSessionAtOrBefore(session, tsMs) {
204
+ try {
205
+ const wallMs = zoneWallMsAt(session.timeZone, tsMs);
206
+ if (!Number.isFinite(wallMs))
207
+ return null;
208
+ const localDayMs = Math.floor(wallMs / DAY_MS) * DAY_MS;
209
+ // A session that opens later in this local day than `tsMs` is the day before's; two back reaches one over midnight.
210
+ for (const back of [0, 1, 2]) {
211
+ const instants = marketSessionInstantsOn(session, localDayMs - back * DAY_MS);
212
+ if (Number.isFinite(instants[0]) && Number.isFinite(instants[1]) && instants[0] <= tsMs)
213
+ return instants;
214
+ }
215
+ }
216
+ catch {
217
+ // Intl's RangeError for a zone this runtime cannot read: no session.
218
+ }
219
+ return null;
220
+ }
@@ -38,6 +38,11 @@ const EXCHANGE_TO_KIND = {
38
38
  NASDAQ_PHILADELPHIA: 'tradfi',
39
39
  NASDAQ_PSX: 'tradfi',
40
40
  NASDAQ_INT: 'tradfi',
41
+ // The US consolidated tape's three SIP tapes, by the app's tape codes (stocks-realtime.interface.ts): the same
42
+ // listings as the free lane, delayed, through the stocks entitlement gate.
43
+ NYSE_TAPE: 'tradfi',
44
+ NYSE_ARCA_TAPE: 'tradfi',
45
+ NASDAQ_TAPE: 'tradfi',
41
46
  CBOE: 'tradfi',
42
47
  CBOE_EDGA: 'tradfi',
43
48
  CBOE_EDGX: 'tradfi',
@@ -123,6 +123,13 @@ export declare const INDEX_FETCH_EXTRA_BAR = 1;
123
123
  * - Mixed timestamp-first: Main token is crypto, others include stocks (BTC + NVDA)
124
124
  * - Mixed index-first: Main token is stock, others include crypto (NVDA + BTC)
125
125
  *
126
+ * **Per-token sessions** (`tokenSessionTypes`, the worker resolves each leg's `tradingHour` from its entry, else the
127
+ * chart's `sessionType`): a Polygon leg rides the chart's session (regular unless extended); a leg with an RTH window
128
+ * that is not the chart's own market takes the comparison-leg rule (chart-rth.util `kOhlcvSessionPayloadFields`):
129
+ * 'regular' only while the CHART is RTH-active (`isChartRthActive` at the chart interval), else 'extended'. A crypto or
130
+ * equities chart stamps a meaningless 'regular' it has no control to change, which must never filter a CME leg of its
131
+ * formula to the cash session; the chart's own market reads the chart's session as before.
132
+ *
126
133
  * @param metadata - Chart metadata containing transformations and session settings
127
134
  * @param transformations - Expression string (e.g., "BINANCE|BTCUSDT + POLYGON|NVDA")
128
135
  * @returns Context object with token modes, session types, and mixed-mode flags
@@ -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` runtime flag as the venue policy reads it (kscript-venue-policy.util, the one decider of
3
- * the governed walls). Dependency-free on purpose, the shape of exchange-visibility.util and telemetryGates: the
4
- * venue policy stays worker-safe and store-free, so the feature-flags store hands it readers instead.
5
- *
6
- * Two readers, one answer: the store registers its override-aware `isOn` as the fallback when it is created, and
7
- * publishes its reader again after every successful fetch. Until a fetch publishes, the fallback answers, so the dev
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
- /** Called by the feature-flags store after a successful fetch (and by tests); null unpublishes. */
14
- export declare function publishOpraUserScriptsFlag(next: (() => boolean) | null): void;
15
- /** Called by the feature-flags store when it is created: its override-aware `isOn`, read until a fetch publishes. */
16
- export declare function setOpraUserScriptsFlagFallback(next: (() => boolean) | null): void;
17
- /** Whether the `opra-user-scripts` flag is on for this session: the published answer, else the store's own; closed
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` runtime flag as the venue policy reads it (kscript-venue-policy.util, the one decider of
3
- * the governed walls). Dependency-free on purpose, the shape of exchange-visibility.util and telemetryGates: the
4
- * venue policy stays worker-safe and store-free, so the feature-flags store hands it readers instead.
5
- *
6
- * Two readers, one answer: the store registers its override-aware `isOn` as the fallback when it is created, and
7
- * publishes its reader again after every successful fetch. Until a fetch publishes, the fallback answers, so the dev
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
- let published = null;
14
- let fallback = null;
15
- /** Called by the feature-flags store after a successful fetch (and by tests); null unpublishes. */
16
- export function publishOpraUserScriptsFlag(next) {
17
- published = next;
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
- try {
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 kScript engine's venue-sessions table gives a symbol:
32
- * the platform window for every mapped root, NYMEX included (engine 3.0.94).
33
- * Script-facing session facts read this one (wrun `time.session`,
34
- * wrun-bar-session-facts.util), so a browser run of an indicator agrees with
35
- * its cloud run and with the engine's `inSession` / `vwap(session="rth")`;
36
- * every chart gate reads `getRthWindowForSymbol`. It moves to the exchange
37
- * windows only in a coordinated change of the engine, the WRUN-SESSIONS C3
38
- * golden and the cloud lanes. Null for an unmapped root.
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`): when a root
22
- * is added there, add it here in the same wave (and vice versa). The
23
- * published package ships ONLY the .d.ts for that subpath (the implementation
24
- * is bundled and mangled inside `dist/kscript-engine.js` and not re-exported
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) still gives the NYMEX
28
- * energy roots the uniform 09:30-16:15 window, so `inSession(session="rth")`
29
- * and `vwap(session="rth")` on those roots disagree with the chart until the
30
- * engine adopts the energy window; the wrun session facts stay on the
31
- * engine's table through `engineRthWindowForSymbol` so browser and cloud runs
32
- * agree. Swap these exports for re-exports of the engine subpath once a
33
- * release emits the module as importable JS and carries the same windows.
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 kScript engine's venue-sessions table gives a symbol:
194
- * the platform window for every mapped root, NYMEX included (engine 3.0.94).
195
- * Script-facing session facts read this one (wrun `time.session`,
196
- * wrun-bar-session-facts.util), so a browser run of an indicator agrees with
197
- * its cloud run and with the engine's `inSession` / `vwap(session="rth")`;
198
- * every chart gate reads `getRthWindowForSymbol`. It moves to the exchange
199
- * windows only in a coordinated change of the engine, the WRUN-SESSIONS C3
200
- * golden and the cloud lanes. Null for an unmapped root.
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) === null ? null : CME_PLATFORM_RTH;
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) {
@@ -1 +1,2 @@
1
- export declare function getSessionInterval(sessionType: string, chartInterval: string): number | string;
1
+ /** Always ms: a named session (a region, the day split) is a day; its hours ride its window (sessionWindowKeysFor). */
2
+ export declare function getSessionInterval(sessionType: string, chartInterval: string): number;
@@ -16,10 +16,8 @@ const SESSION_INTERVALS = {
16
16
  '3M': { Footprint: Intervals.MONTH3, Targeted: Intervals.MONTH3, Wide: Intervals.MONTH3 },
17
17
  '1Y': { Footprint: Intervals.YEAR, Targeted: Intervals.YEAR, Wide: Intervals.YEAR },
18
18
  };
19
+ /** Always ms: a named session (a region, the day split) is a day; its hours ride its window (sessionWindowKeysFor). */
19
20
  export function getSessionInterval(sessionType, chartInterval) {
20
- if (['US', 'EU', 'Asia'].includes(sessionType)) {
21
- return sessionType;
22
- }
23
21
  // A preset or an extended rung reads the row of its standard at or below
24
22
  // (10m -> 5m, 30s -> 1s, 6M -> 3M), floored at its own bar: a session never
25
23
  // splits a bar, so Footprint (one profile per chart bar) keeps the chart's
@@ -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