@orangecharts/wrun-chart-host 0.6.0 → 0.7.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.
- package/README.md +14 -5
- package/dist/constants/marketCapabilities.constants.d.ts +5 -0
- package/dist/constants/marketCapabilities.constants.js +16 -0
- package/dist/host-ports.types.d.ts +35 -3
- package/dist/index.d.ts +11 -1
- package/dist/index.js +11 -1
- package/dist/indicators/controls/tpo-session.util.js +42 -18
- package/dist/market-data/billing.interface.d.ts +2 -1
- package/dist/settings-templates/index.d.ts +2 -0
- package/dist/settings-templates/index.js +19 -5
- package/dist/settings-templates/indicator-fields.d.ts +2 -0
- package/dist/settings-templates/indicator-fields.js +10 -0
- package/dist/settings-templates/tool-rules.d.ts +12 -2
- package/dist/settings-templates/tool-rules.js +9 -2
- package/dist/settings-templates/tool-tables.generated.js +9 -0
- package/dist/utility/chart/crypto-index.leaf.d.ts +16 -0
- package/dist/utility/chart/crypto-index.leaf.js +19 -0
- package/dist/utility/chart/index-mode-admission.util.js +9 -1
- package/dist/utility/chart/index-mode.util.d.ts +11 -5
- package/dist/utility/chart/index-mode.util.js +22 -10
- package/dist/utility/chart/kscript-source-answer-budget.leaf.d.ts +36 -0
- package/dist/utility/chart/kscript-source-answer-budget.leaf.js +39 -0
- package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +38 -1
- package/dist/utility/chart/kscript-source-degrade.leaf.js +39 -1
- package/dist/utility/chart/live-bucket.util.d.ts +2 -1
- package/dist/utility/chart/live-bucket.util.js +47 -15
- package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +15 -1
- package/dist/utility/chart/local-kscript-warmup-depth.util.js +9 -0
- package/dist/utility/chart/market-session-schedule.util.d.ts +3 -1
- package/dist/utility/chart/market-session-schedule.util.js +24 -2
- package/dist/utility/chart/marketKind.util.d.ts +12 -7
- package/dist/utility/chart/marketKind.util.js +15 -5
- package/dist/utility/chart/ny-calendar.util.d.ts +104 -0
- package/dist/utility/chart/ny-calendar.util.js +346 -0
- package/dist/utility/chart/om-panel.util.d.ts +14 -2
- package/dist/utility/chart/om-panel.util.js +108 -40
- package/dist/utility/chart/rth-session.util.d.ts +10 -7
- package/dist/utility/chart/rth-session.util.js +17 -22
- package/dist/utility/chart/trading-day.util.js +90 -18
- package/dist/utility/chart/us-equities-session.util.js +20 -67
- package/dist/utility/chart/wrun-bar-session-facts.util.js +14 -1
- package/dist/utility/common/time.util.d.ts +7 -1
- package/dist/utility/common/time.util.js +11 -41
- package/dist/utility/number-format.util.d.ts +17 -7
- package/dist/utility/number-format.util.js +18 -8
- package/dist/utility/options/option-symbol.util.js +13 -2
- package/dist/utility/symbol-selection/contract-expiry.util.js +9 -1
- package/dist/utility/watchlist/import/import-request.leaf.d.ts +4 -1
- package/dist/utility/watchlist/import/import-request.leaf.js +5 -2
- package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +25 -4
- package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +62 -4
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +19 -0
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +57 -0
- package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +23 -0
- package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +90 -0
- package/dist/utility/wrun/run-schedule/wrun-lane-groups.util.d.ts +39 -0
- package/dist/utility/wrun/run-schedule/wrun-lane-groups.util.js +60 -0
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +77 -0
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +195 -0
- package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +56 -0
- package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +70 -0
- package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +53 -0
- package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +239 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +16 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.js +14 -0
- package/dist/utility/wrun/sources/lanes/options_flow.d.ts +43 -18
- package/dist/utility/wrun/sources/lanes/options_flow.js +209 -72
- package/dist/utility/wrun/sources/lanes/token_supply.js +5 -31
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +3 -18
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +12 -57
- package/dist/utility/wrun/sources/row-lane-registry.d.ts +1 -1
- package/dist/utility/wrun/sources/row-lane-registry.js +22 -8
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +61 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +103 -8
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +5 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +24 -12
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +55 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +95 -18
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +15 -1
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +23 -8
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +11 -11
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +14 -2
- package/dist/utility/wrun/sources/wrun-poll-lane.types.js +6 -3
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +43 -8
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +77 -11
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +31 -16
- package/dist/utility/wrun/sources/wrun-row-lane.types.js +2 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +52 -12
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +110 -46
- package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +10 -0
- package/dist/utility/wrun/wrun-browser-sources.leaf.js +12 -0
- package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-coin-lane-live.util.js +53 -18
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +6 -0
- package/dist/utility/wrun/wrun-color-settings.util.js +45 -0
- package/dist/utility/wrun/wrun-draft-overlay.util.js +14 -8
- package/dist/utility/wrun/wrun-failure-cause.d.ts +1 -1
- package/dist/utility/wrun/wrun-failure-cause.js +14 -0
- package/dist/utility/wrun/wrun-frames.js +6 -2
- package/dist/utility/wrun/wrun-host.service.d.ts +26 -18
- package/dist/utility/wrun/wrun-host.service.js +49 -52
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +1 -1
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +2 -0
- package/dist/utility/wrun/wrun-input-requirements.leaf.js +7 -4
- package/dist/utility/wrun/wrun-kit-run-tables.util.d.ts +24 -0
- package/dist/utility/wrun/wrun-kit-run-tables.util.js +87 -0
- package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +2 -1
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +8 -2
- package/dist/utility/wrun/wrun-live-tick.util.js +35 -16
- package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +40 -13
- package/dist/utility/wrun/wrun-opra-flow.leaf.js +39 -12
- package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +70 -21
- package/dist/utility/wrun/wrun-option-contract-flow.util.js +257 -112
- package/dist/utility/wrun/wrun-option-prints.util.d.ts +62 -22
- package/dist/utility/wrun/wrun-option-prints.util.js +148 -46
- package/dist/utility/wrun/wrun-option-views.util.d.ts +262 -0
- package/dist/utility/wrun/wrun-option-views.util.js +356 -0
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +23 -2
- package/dist/utility/wrun/wrun-options-chain.util.js +37 -3
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +18 -3
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +32 -7
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +9 -3
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +146 -18
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +50 -6
- package/dist/utility/wrun/wrun-overlay-run.util.js +816 -243
- package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +5 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.js +28 -12
- package/dist/utility/wrun/wrun-pin-venues.util.js +4 -6
- package/dist/utility/wrun/wrun-present-bits.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-present-bits.util.js +39 -0
- package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-refusal-surface.util.js +5 -4
- package/dist/utility/wrun/wrun-refusal.util.d.ts +66 -6
- package/dist/utility/wrun/wrun-refusal.util.js +335 -40
- package/dist/utility/wrun/wrun-source-rows.util.js +11 -0
- package/dist/utility/wrun/wrun-tier-grid.util.d.ts +28 -3
- package/dist/utility/wrun/wrun-tier-grid.util.js +79 -19
- package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +14 -3
- package/dist/utility/wrun/wrun-transient-rerun.util.js +33 -8
- package/package.json +5 -5
- package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +0 -12
- package/dist/utility/wrun/wrun-opra-underlying.util.js +0 -1
|
@@ -115,8 +115,20 @@ function spark(value) {
|
|
|
115
115
|
function colorStops(value) {
|
|
116
116
|
return Array.isArray(value) && value.length >= 2 && value.length <= 8 && value.every(color);
|
|
117
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* A reading the module could not compute: `null`, the spelling the kit's frame writer gives every number that is
|
|
120
|
+
* not finite (`fb_num` / `fb_f64`, JSON's gap), so a contract with no quote yet, a session with no prior one or an
|
|
121
|
+
* average still short of its window writes it. A cell whose reading can be drawn as nothing takes it: a bars, line or
|
|
122
|
+
* heatmap value (a gap), a table cell (an empty cell), a tile's value (the engine's "-"). A cell that places a mark by
|
|
123
|
+
* its number (a key, a scatter point's x and y, a pie slice's size, a histogram bin's count) needs the number, and a
|
|
124
|
+
* row missing it still refuses the frame, alike on every host (the frozen wrun-4 corpus, "invalid panel cells reuse
|
|
125
|
+
* set_panel refusal").
|
|
126
|
+
*/
|
|
127
|
+
function missingReading(value) {
|
|
128
|
+
return value === null;
|
|
129
|
+
}
|
|
118
130
|
function valueCell(value) {
|
|
119
|
-
return value
|
|
131
|
+
return missingReading(value) || finite(value);
|
|
120
132
|
}
|
|
121
133
|
/** A bars value cell: a number, a gap, or `{ value, color? }` (SC19). */
|
|
122
134
|
function barCell(value) {
|
|
@@ -135,9 +147,10 @@ function rowKey(value, x) {
|
|
|
135
147
|
return finite(value);
|
|
136
148
|
return finite(value) && Number.isSafeInteger(value);
|
|
137
149
|
}
|
|
138
|
-
/** A table cell: text, a number, or a styled cell whose spans
|
|
150
|
+
/** A table cell: text, a number, a missing reading (`null`, drawn as an empty cell), or a styled cell whose spans
|
|
151
|
+
* stay inside the grid (SC35). */
|
|
139
152
|
function tableCell(value, grid) {
|
|
140
|
-
if (typeof value === 'string' || finite(value))
|
|
153
|
+
if (missingReading(value) || typeof value === 'string' || finite(value))
|
|
141
154
|
return true;
|
|
142
155
|
if (!isRecord(value) || Object.keys(value).some((key) => !CELL_KEYS.has(key)))
|
|
143
156
|
return false;
|
|
@@ -158,50 +171,93 @@ function tableCell(value, grid) {
|
|
|
158
171
|
(nonnegativeInteger(value.font_size) && value.font_size >= 6 && value.font_size <= 64)) &&
|
|
159
172
|
(value.font_weight === undefined || (typeof value.font_weight === 'string' && FONT_WEIGHTS.has(value.font_weight))));
|
|
160
173
|
}
|
|
161
|
-
|
|
174
|
+
/** What a row key must be under each `x` word, as a refusal names it. */
|
|
175
|
+
const KEY_WORDS = {
|
|
176
|
+
category: 'a string',
|
|
177
|
+
time: 'a whole number >= 0',
|
|
178
|
+
number: 'a finite number',
|
|
179
|
+
index: 'a whole number',
|
|
180
|
+
};
|
|
181
|
+
/** The first cell from `from` on that `ok` refuses, named, else undefined. */
|
|
182
|
+
function refusedCell(row, from, ok, what) {
|
|
183
|
+
for (let at = from; at < row.length; at += 1)
|
|
184
|
+
if (!ok(row[at], at))
|
|
185
|
+
return `cell ${at} is not ${what}`;
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
/** The cell count a kind takes, named when the row holds another. */
|
|
189
|
+
function widthProblem(row, min, max, what) {
|
|
190
|
+
if (row.length >= min && row.length <= max)
|
|
191
|
+
return undefined;
|
|
192
|
+
return `the row holds ${row.length} cells, ${what} takes ${min === max ? min : `${min} to ${max}`}`;
|
|
193
|
+
}
|
|
194
|
+
/** Why one frame row breaks the row grammar (one grammar on both lanes), or undefined when it holds; the first
|
|
195
|
+
* broken rule wins. A missing reading (`missingReading`) is no break in a cell that only shows a number. */
|
|
196
|
+
function panelRowProblem(row, panel, rowIndex, rowCount) {
|
|
162
197
|
if (!Array.isArray(row))
|
|
163
|
-
return
|
|
198
|
+
return 'the row is not an array';
|
|
164
199
|
switch (panel.kind) {
|
|
165
200
|
case 'bars':
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
201
|
+
case 'line': {
|
|
202
|
+
const width = panel.series.length + 1;
|
|
203
|
+
const wrongWidth = widthProblem(row, width, width, 'the key with one value per series');
|
|
204
|
+
if (wrongWidth !== undefined)
|
|
205
|
+
return wrongWidth;
|
|
206
|
+
if (!rowKey(row[0], panel.x))
|
|
207
|
+
return `the key is not ${KEY_WORDS[panel.x]}`;
|
|
208
|
+
return panel.kind === 'bars'
|
|
209
|
+
? refusedCell(row, 1, barCell, 'a number, null or { value, color }')
|
|
210
|
+
: refusedCell(row, 1, valueCell, 'a number or null');
|
|
211
|
+
}
|
|
169
212
|
case 'scatter':
|
|
170
|
-
return (row
|
|
171
|
-
row.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
finite(row[
|
|
175
|
-
(row
|
|
176
|
-
(row.length <
|
|
177
|
-
(row.length <
|
|
213
|
+
return (widthProblem(row, 3, 6, 'a point') ??
|
|
214
|
+
(typeof row[0] === 'string' || rowKey(row[0], panel.x === 'number' ? 'number' : 'index')
|
|
215
|
+
? undefined
|
|
216
|
+
: `the key is not a string or ${KEY_WORDS[panel.x === 'number' ? 'number' : 'index']}`) ??
|
|
217
|
+
(finite(row[1]) ? undefined : 'x (cell 1) is not a finite number') ??
|
|
218
|
+
(finite(row[2]) ? undefined : 'y (cell 2) is not a finite number') ??
|
|
219
|
+
(row.length < 4 || (finite(row[3]) && row[3] >= 0) ? undefined : 'the size (cell 3) is not a number >= 0') ??
|
|
220
|
+
(row.length < 5 || color(row[4]) ? undefined : 'the colour (cell 4) is not a colour word') ??
|
|
221
|
+
(row.length < 6 || typeof row[5] === 'string' ? undefined : 'the label (cell 5) is not a string'));
|
|
178
222
|
case 'histogram':
|
|
179
|
-
return row
|
|
223
|
+
return (widthProblem(row, 2, 2, 'a bin') ??
|
|
224
|
+
(typeof row[0] === 'string' ? undefined : 'the label (cell 0) is not a string') ??
|
|
225
|
+
(finite(row[1]) ? undefined : 'the count (cell 1) is not a finite number'));
|
|
180
226
|
case 'pie':
|
|
181
|
-
return (row
|
|
182
|
-
row
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
(row.length < 3 || color(row[2])));
|
|
227
|
+
return (widthProblem(row, 2, 3, 'a slice') ??
|
|
228
|
+
(typeof row[0] === 'string' ? undefined : 'the name (cell 0) is not a string') ??
|
|
229
|
+
(finite(row[1]) ? undefined : 'the value (cell 1) is not a finite number') ??
|
|
230
|
+
(row.length < 3 || color(row[2]) ? undefined : 'the colour (cell 2) is not a colour word'));
|
|
186
231
|
case 'heatmap':
|
|
187
|
-
return (row
|
|
188
|
-
rowKey(row[0], panel.x)
|
|
189
|
-
(typeof row[1] === 'string' || (finite(row[1]) && Number.isSafeInteger(row[1]))
|
|
190
|
-
|
|
232
|
+
return (widthProblem(row, 3, 3, 'a cell') ??
|
|
233
|
+
(rowKey(row[0], panel.x) ? undefined : `the x key (cell 0) is not ${KEY_WORDS[panel.x]}`) ??
|
|
234
|
+
(typeof row[1] === 'string' || (finite(row[1]) && Number.isSafeInteger(row[1]))
|
|
235
|
+
? undefined
|
|
236
|
+
: 'the y key (cell 1) is not a string or a whole number') ??
|
|
237
|
+
(valueCell(row[2]) ? undefined : 'the value (cell 2) is not a number or null'));
|
|
191
238
|
case 'table': {
|
|
192
239
|
const columns = panel.series.length;
|
|
193
|
-
return (row
|
|
194
|
-
row
|
|
240
|
+
return (widthProblem(row, columns, columns, 'one cell per series') ??
|
|
241
|
+
refusedCell(row, 0, (cell, column) => tableCell(cell, { columns, rows: rowCount, row: rowIndex, column }), 'a table cell (text, a number, null or a styled cell inside the grid)'));
|
|
195
242
|
}
|
|
196
243
|
case 'tiles':
|
|
197
|
-
return (row
|
|
198
|
-
row
|
|
199
|
-
typeof row[
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
(row.length <
|
|
203
|
-
|
|
204
|
-
|
|
244
|
+
return (widthProblem(row, 2, 6, 'a tile') ??
|
|
245
|
+
(typeof row[0] === 'string' ? undefined : 'the label (cell 0) is not a string') ??
|
|
246
|
+
(missingReading(row[1]) || (typeof row[1] === 'string' && row[1].length <= 64) || finite(row[1])
|
|
247
|
+
? undefined
|
|
248
|
+
: 'the value (cell 1) is not text of 64 characters at most, a number or null') ??
|
|
249
|
+
(row.length < 3 || row[2] === null || typeof row[2] === 'string'
|
|
250
|
+
? undefined
|
|
251
|
+
: 'the caption (cell 2) is not a string or null') ??
|
|
252
|
+
(row.length < 4 || row[3] === null || color(row[3])
|
|
253
|
+
? undefined
|
|
254
|
+
: 'the colour (cell 3) is not a colour word or null') ??
|
|
255
|
+
(row.length < 5 || row[4] === null || spark(row[4])
|
|
256
|
+
? undefined
|
|
257
|
+
: 'the spark (cell 4) is not 64 finite numbers at most or null') ??
|
|
258
|
+
(row.length < 6 || (typeof row[5] === 'string' && VALUE_FORMATS.has(row[5]))
|
|
259
|
+
? undefined
|
|
260
|
+
: 'the format (cell 5) is not a value format word'));
|
|
205
261
|
}
|
|
206
262
|
}
|
|
207
263
|
function panelRowCap(kind) {
|
|
@@ -229,7 +285,11 @@ function copyCell(cell) {
|
|
|
229
285
|
* frame's style words are checked here (value, kind, `#rrggbb[aa]` colours)
|
|
230
286
|
* and a bad one is refused by name (`invalid panel.<word>`); a wrun
|
|
231
287
|
* declaration's were checked by the kit, except the app's own bar words. A
|
|
232
|
-
* word outside the list is refused on both lanes.
|
|
288
|
+
* word outside the list is refused on both lanes. A row that breaks the row
|
|
289
|
+
* grammar refuses the frame, never a truncation (the frozen wrun-4 rule, alike
|
|
290
|
+
* on every host), and the refusal names the row's index and why (`row`); a
|
|
291
|
+
* missing reading in a cell that only shows a number is that cell's gap,
|
|
292
|
+
* never a break (`missingReading`). */
|
|
233
293
|
export function parseSetPanelData(value, options = {}) {
|
|
234
294
|
const wrun = options.lane === 'wrun';
|
|
235
295
|
if (!isRecord(value))
|
|
@@ -311,8 +371,11 @@ export function parseSetPanelData(value, options = {}) {
|
|
|
311
371
|
const rows = value.rows;
|
|
312
372
|
if (rows.length > panelRowCap(panel.kind))
|
|
313
373
|
return { ok: false, rejectReason: 'too many rows' };
|
|
314
|
-
|
|
315
|
-
|
|
374
|
+
for (let index = 0; index < rows.length; index += 1) {
|
|
375
|
+
const reason = panelRowProblem(rows[index], panel, index, rows.length);
|
|
376
|
+
if (reason !== undefined)
|
|
377
|
+
return { ok: false, rejectReason: 'invalid panel row', row: { index, reason } };
|
|
378
|
+
}
|
|
316
379
|
let source;
|
|
317
380
|
if (value.source !== undefined) {
|
|
318
381
|
if (!isRecord(value.source))
|
|
@@ -378,10 +441,14 @@ function numberSpec(entry) {
|
|
|
378
441
|
* A number, or a styled cell's `value`, prints through the column's format,
|
|
379
442
|
* else the table's (SC40); no format keeps the raw print. A styled cell's
|
|
380
443
|
* own background, text look, alignment and spans map onto the T2 table keys
|
|
381
|
-
* (SC14 SC22 SC35); a cell without an alignment takes its column's.
|
|
444
|
+
* (SC14 SC22 SC35); a cell without an alignment takes its column's. A missing
|
|
445
|
+
* reading (`null`) is an empty cell. */
|
|
382
446
|
export function engineTableCell(cell, column = {}, ctx = {}) {
|
|
383
447
|
const spec = column.spec ?? ctx.tableSpec;
|
|
384
448
|
const print = (value) => spec === undefined ? String(value) : formatWrunNumber(value, { ...spec, priceDigits: ctx.priceDigits });
|
|
449
|
+
// A missing reading is an empty cell (the engine's own "" for null, spelled out for every engine pin).
|
|
450
|
+
if (cell === null)
|
|
451
|
+
return '';
|
|
385
452
|
const style = boundWrunPanelStyle();
|
|
386
453
|
const paneColor = (word) => style.wrunPaneColor(word, ctx.theme);
|
|
387
454
|
if (typeof cell === 'number') {
|
|
@@ -724,6 +791,7 @@ export function translatePanelToEngine(frame, ctx = {}) {
|
|
|
724
791
|
...(panel.columns !== undefined ? { columns: panel.columns } : {}),
|
|
725
792
|
fontFamily,
|
|
726
793
|
};
|
|
794
|
+
// A missing reading (null) rides as is: the engine prints its own "-" for a tile without a value.
|
|
727
795
|
const result = finish('tiles', rows.map((row, index) => [index, row[1]]), settings);
|
|
728
796
|
mergeSettings(result.settings, style.wrunTilesStyle(panel, rows, ctx));
|
|
729
797
|
return result;
|
|
@@ -332,13 +332,16 @@ export declare function rthSessionBucketsPerDay(window: Readonly<RthWindow>, tfM
|
|
|
332
332
|
* noon are DST-safe: US transitions run at 02:00 and the two yearly shifts
|
|
333
333
|
* cancel, so the cursor stays inside 11:00-13:00 local), skips Saturday and
|
|
334
334
|
* Sunday, and accumulates per-day bucket counts until `barCount` is covered;
|
|
335
|
-
* the span then reaches that day's terminal bucket. The
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
* (
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
335
|
+
* the span then reaches that day's terminal bucket. The cursor's days are
|
|
336
|
+
* consecutive, so their weekdays follow from the end day's by arithmetic and
|
|
337
|
+
* the walk reads only the per-day memo, never a timezone conversion per day
|
|
338
|
+
* (each lazy-load round asks it again). The count is treated as session
|
|
339
|
+
* CAPACITY, which is an upper bound on rows actually present, so callers
|
|
340
|
+
* sizing a fetch window should pad with `RTH_SPAN_DENSITY_MARGIN` (holidays,
|
|
341
|
+
* early closes and thin contracts under-fill their slots, which would
|
|
342
|
+
* otherwise make every window land short). Returns null when the symbol
|
|
343
|
+
* resolves no RTH window or inputs are invalid (callers keep the naive
|
|
344
|
+
* translation).
|
|
342
345
|
*/
|
|
343
346
|
export declare function rthSessionWallSpanForBarsMs(symbol: unknown, tfMs: number, barCount: number, endMs: number): number | null;
|
|
344
347
|
/**
|
|
@@ -38,6 +38,7 @@ import utc from 'dayjs/plugin/utc.js';
|
|
|
38
38
|
import { Intervals } from '../../constants/interval.constants.js';
|
|
39
39
|
import { isCmeGoverned, normalizeExchangeCode } from './cme-realtime.util.js';
|
|
40
40
|
import { intervalLabelForMs, isSubMinuteInterval, standardIntervalMsAtOrBelow } from './interval-registry.util.js';
|
|
41
|
+
// No reading here goes through dayjs any more; the plugins stay registered for importers that rely on it.
|
|
41
42
|
dayjs.extend(utc);
|
|
42
43
|
dayjs.extend(timezone);
|
|
43
44
|
/**
|
|
@@ -539,6 +540,7 @@ function rthDayBoundsFor(window, tsMs) {
|
|
|
539
540
|
closeMs: zoneWallToUtcMs(zone, wall.year, wall.month, wall.day, window.closeMinutes),
|
|
540
541
|
dayStartMs: zoneWallToUtcMs(zone, wall.year, wall.month, wall.day, 0),
|
|
541
542
|
dayEndMs: zoneWallToUtcMs(zone, next.getUTCFullYear(), next.getUTCMonth() + 1, next.getUTCDate(), 0),
|
|
543
|
+
weekday: (next.getUTCDay() + 6) % 7,
|
|
542
544
|
};
|
|
543
545
|
}
|
|
544
546
|
catch {
|
|
@@ -841,13 +843,16 @@ export function rthSessionBucketsPerDay(window, tfMs) {
|
|
|
841
843
|
* noon are DST-safe: US transitions run at 02:00 and the two yearly shifts
|
|
842
844
|
* cancel, so the cursor stays inside 11:00-13:00 local), skips Saturday and
|
|
843
845
|
* Sunday, and accumulates per-day bucket counts until `barCount` is covered;
|
|
844
|
-
* the span then reaches that day's terminal bucket. The
|
|
845
|
-
*
|
|
846
|
-
*
|
|
847
|
-
* (
|
|
848
|
-
*
|
|
849
|
-
*
|
|
850
|
-
*
|
|
846
|
+
* the span then reaches that day's terminal bucket. The cursor's days are
|
|
847
|
+
* consecutive, so their weekdays follow from the end day's by arithmetic and
|
|
848
|
+
* the walk reads only the per-day memo, never a timezone conversion per day
|
|
849
|
+
* (each lazy-load round asks it again). The count is treated as session
|
|
850
|
+
* CAPACITY, which is an upper bound on rows actually present, so callers
|
|
851
|
+
* sizing a fetch window should pad with `RTH_SPAN_DENSITY_MARGIN` (holidays,
|
|
852
|
+
* early closes and thin contracts under-fill their slots, which would
|
|
853
|
+
* otherwise make every window land short). Returns null when the symbol
|
|
854
|
+
* resolves no RTH window or inputs are invalid (callers keep the naive
|
|
855
|
+
* translation).
|
|
851
856
|
*/
|
|
852
857
|
export function rthSessionWallSpanForBarsMs(symbol, tfMs, barCount, endMs) {
|
|
853
858
|
const window = getRthWindowForSymbol(symbol);
|
|
@@ -860,28 +865,18 @@ export function rthSessionWallSpanForBarsMs(symbol, tfMs, barCount, endMs) {
|
|
|
860
865
|
if (!Number.isFinite(barCount) || barCount <= 0)
|
|
861
866
|
return null;
|
|
862
867
|
const perDay = rthSessionBucketsPerDay(window, tfMs);
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
}
|
|
867
|
-
catch {
|
|
868
|
+
// The venue-local day holding `endMs` (null on a zone failure, or an instant that is not a date).
|
|
869
|
+
const endDay = rthDayBoundsFor(window, endMs);
|
|
870
|
+
if (!endDay)
|
|
868
871
|
return null;
|
|
869
|
-
|
|
870
|
-
let cursorMs = zonedEnd.startOf('day').add(12, 'hour').valueOf();
|
|
872
|
+
let cursorMs = endDay.dayStartMs + 12 * 60 * 60 * 1000;
|
|
871
873
|
let remaining = Math.ceil(barCount);
|
|
872
874
|
// Trading days needed, inflated for weekends (7/5) plus holiday margin;
|
|
873
875
|
// hard-bounds the walk for any degenerate input.
|
|
874
876
|
const maxDays = Math.min(1000, Math.ceil((remaining / perDay) * 1.4) + 14);
|
|
875
877
|
let terminalStartMs = null;
|
|
876
878
|
for (let i = 0; i < maxDays; i++) {
|
|
877
|
-
|
|
878
|
-
try {
|
|
879
|
-
day = dayjs(cursorMs).tz(window.timeZone);
|
|
880
|
-
}
|
|
881
|
-
catch {
|
|
882
|
-
break;
|
|
883
|
-
}
|
|
884
|
-
const dow = day.day();
|
|
879
|
+
const dow = (endDay.weekday + 7 - (i % 7)) % 7;
|
|
885
880
|
if (dow !== 0 && dow !== 6) {
|
|
886
881
|
const bounds = rthDayBoundsFor(window, cursorMs);
|
|
887
882
|
if (bounds && bounds.openMs < endMs) {
|
|
@@ -98,13 +98,82 @@ export function getTradingDayAnchor(exchange) {
|
|
|
98
98
|
return US_OPTIONS_TRADING_DAY_ANCHOR;
|
|
99
99
|
return undefined;
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
const
|
|
101
|
+
/** One wall-clock reader per zone (titan src/utils/tradingDay.ts's formatter); null for a zone Intl rejects. */
|
|
102
|
+
const wallClockFormatters = new Map();
|
|
103
|
+
function wallClockFormatter(timeZone) {
|
|
104
|
+
let formatter = wallClockFormatters.get(timeZone);
|
|
105
|
+
if (formatter === undefined) {
|
|
106
|
+
try {
|
|
107
|
+
formatter = new Intl.DateTimeFormat('en-US', {
|
|
108
|
+
timeZone,
|
|
109
|
+
year: 'numeric',
|
|
110
|
+
month: '2-digit',
|
|
111
|
+
day: '2-digit',
|
|
112
|
+
hour: '2-digit',
|
|
113
|
+
minute: '2-digit',
|
|
114
|
+
second: '2-digit',
|
|
115
|
+
// h23 avoids the hour-24 midnight some engines emit for h24.
|
|
116
|
+
hourCycle: 'h23',
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
formatter = null;
|
|
121
|
+
}
|
|
122
|
+
wallClockFormatters.set(timeZone, formatter);
|
|
123
|
+
}
|
|
124
|
+
return formatter;
|
|
125
|
+
}
|
|
126
|
+
/** The wall clock at `tsMs` in the formatter's zone, as ms since the epoch read as if UTC (titan's wallClockMs). */
|
|
127
|
+
function wallClockMs(formatter, tsMs) {
|
|
128
|
+
let year = 0;
|
|
129
|
+
let month = 1;
|
|
130
|
+
let day = 1;
|
|
131
|
+
let hour = 0;
|
|
132
|
+
let minute = 0;
|
|
133
|
+
let second = 0;
|
|
134
|
+
for (const part of formatter.formatToParts(tsMs)) {
|
|
135
|
+
if (part.type === 'year')
|
|
136
|
+
year = Number(part.value);
|
|
137
|
+
else if (part.type === 'month')
|
|
138
|
+
month = Number(part.value);
|
|
139
|
+
else if (part.type === 'day')
|
|
140
|
+
day = Number(part.value);
|
|
141
|
+
else if (part.type === 'hour')
|
|
142
|
+
hour = Number(part.value);
|
|
143
|
+
else if (part.type === 'minute')
|
|
144
|
+
minute = Number(part.value);
|
|
145
|
+
else if (part.type === 'second')
|
|
146
|
+
second = Number(part.value);
|
|
147
|
+
}
|
|
148
|
+
return Date.UTC(year, month - 1, day, hour, minute, second) + (((tsMs % 1000) + 1000) % 1000);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The instant whose wall clock reads `targetWallMs` (ms read as if UTC): titan's
|
|
152
|
+
* own fixed-point solve (tradingDay.ts instantForWall), started from the zone's
|
|
153
|
+
* offset at the wall reading itself and corrected twice. Every wall time that
|
|
154
|
+
* exists converges; a wall time the zone repeats (the fall-back hour) or skips
|
|
155
|
+
* (the spring-forward gap) lands on the neighbor titan's buckets open at.
|
|
156
|
+
* dayjs.tz, which this replaced, guessed from the zone's offset at the device's
|
|
157
|
+
* NOW: a custom window opening 01:30 America/New_York on 2026-11-01 opened at
|
|
158
|
+
* 05:30Z in summer and 06:30Z in winter, while titan opens it at 05:30Z, so a
|
|
159
|
+
* winter tab's fetch head and history trim skipped that hour.
|
|
160
|
+
*/
|
|
161
|
+
function instantForWall(formatter, targetWallMs) {
|
|
162
|
+
let instant = targetWallMs - (wallClockMs(formatter, targetWallMs) - targetWallMs);
|
|
163
|
+
for (let pass = 0; pass < 2; pass++) {
|
|
164
|
+
const wall = wallClockMs(formatter, instant);
|
|
165
|
+
if (wall === targetWallMs)
|
|
166
|
+
break;
|
|
167
|
+
instant += targetWallMs - wall;
|
|
168
|
+
}
|
|
169
|
+
return instant;
|
|
170
|
+
}
|
|
103
171
|
/**
|
|
104
172
|
* The instant whose wall clock in `timeZone` reads `minutes` past midnight on
|
|
105
|
-
* the y-m-d calendar date
|
|
106
|
-
*
|
|
107
|
-
* midnight
|
|
173
|
+
* the y-m-d calendar date, solved as titan solves it (instantForWall), so the
|
|
174
|
+
* FE mirror opens every day where titan does, DST edges included: counting real
|
|
175
|
+
* minutes from midnight would drift by the offset delta on 23h/25h transition
|
|
176
|
+
* days. A zone this runtime's Intl rejects reads the wall time as UTC. Memoized
|
|
108
177
|
* because period-floor consumers walk thousands of bar timestamps while the
|
|
109
178
|
* instant only changes once per calendar date; bounded, cleared wholesale on
|
|
110
179
|
* overflow (recomputation is cheap).
|
|
@@ -115,13 +184,9 @@ function wallInstantMs(timeZone, date, minutes) {
|
|
|
115
184
|
const key = `${timeZone}|${minutes}|${date.y}-${date.m}-${date.d}`;
|
|
116
185
|
let ms = wallInstantCache.get(key);
|
|
117
186
|
if (ms === undefined) {
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
catch {
|
|
123
|
-
ms = dayjs.utc(wall).valueOf();
|
|
124
|
-
}
|
|
187
|
+
const targetWallMs = Date.UTC(date.y, date.m - 1, date.d, Math.floor(minutes / 60), minutes % 60);
|
|
188
|
+
const formatter = wallClockFormatter(timeZone);
|
|
189
|
+
ms = formatter ? instantForWall(formatter, targetWallMs) : targetWallMs;
|
|
125
190
|
if (wallInstantCache.size >= WALL_INSTANT_CACHE_MAX)
|
|
126
191
|
wallInstantCache.clear();
|
|
127
192
|
wallInstantCache.set(key, ms);
|
|
@@ -167,12 +232,19 @@ export function tradingDayStartMs(tsMs, anchor) {
|
|
|
167
232
|
return cached.openMs;
|
|
168
233
|
const date = venueDateOf(tsMs, anchor.timeZone);
|
|
169
234
|
const todayOpen = wallInstantMs(anchor.timeZone, date, anchor.openMinutes);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
// Opens are strictly increasing, exactly one per calendar date
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
|
|
235
|
+
let openDate = tsMs >= todayOpen ? date : shiftCalendarDate(date, -1);
|
|
236
|
+
let openMs = tsMs >= todayOpen ? todayOpen : wallInstantMs(anchor.timeZone, openDate, anchor.openMinutes);
|
|
237
|
+
// Opens are strictly increasing, exactly one per calendar date, so the span
|
|
238
|
+
// [openMs, nextOpenMs) maps every contained instant to openMs. Titan's own
|
|
239
|
+
// defensive step: an open inside a transition gap can solve to its pre-gap
|
|
240
|
+
// neighbor, early enough that the NEXT calendar date's open precedes tsMs,
|
|
241
|
+
// and then that open is the day holding tsMs.
|
|
242
|
+
let nextOpenMs = wallInstantMs(anchor.timeZone, shiftCalendarDate(openDate, 1), anchor.openMinutes);
|
|
243
|
+
if (tsMs >= todayOpen && nextOpenMs <= tsMs) {
|
|
244
|
+
openDate = shiftCalendarDate(openDate, 1);
|
|
245
|
+
openMs = nextOpenMs;
|
|
246
|
+
nextOpenMs = wallInstantMs(anchor.timeZone, shiftCalendarDate(openDate, 1), anchor.openMinutes);
|
|
247
|
+
}
|
|
176
248
|
tradingDayWindowByAnchor.set(anchorKey, { openMs, nextOpenMs });
|
|
177
249
|
return openMs;
|
|
178
250
|
}
|
|
@@ -19,20 +19,18 @@
|
|
|
19
19
|
* regular 09:30 -> 16:00
|
|
20
20
|
* after 16:00 -> 20:00
|
|
21
21
|
* closed everything else, and weekends
|
|
22
|
+
* Every per-row answer here reads the New York calendar (ny-calendar.util):
|
|
23
|
+
* one timezone lookup per date, integer compares per row.
|
|
22
24
|
*
|
|
23
25
|
* Worker-safe: no Vue / store / i18n imports (the bars cache and the workers
|
|
24
26
|
* import the row filter).
|
|
25
27
|
*/
|
|
26
|
-
import dayjs from 'dayjs';
|
|
27
|
-
import timezone from 'dayjs/plugin/timezone.js';
|
|
28
|
-
import utc from 'dayjs/plugin/utc.js';
|
|
29
28
|
import { checkIsPolygon } from './marketKind.util.js';
|
|
29
|
+
import { NY_REGULAR_CLOSE_MINUTES, NY_REGULAR_OPEN_MINUTES, NY_TIME_ZONE, nyCalendarDay, nyCalendarDayAt, nyNextRegularOpenAfterMs, nyRegularSessionOpenMs, } from './ny-calendar.util.js';
|
|
30
30
|
import { isFootprintRthFoldTfMs, isRthBucketExactIntervalMs, sessionWindowsInRange, } from './rth-session.util.js';
|
|
31
31
|
import { sessionGridStartMs } from './cme-session-bucket.util.js';
|
|
32
32
|
import { checkUSMarketHours } from '../common/time.util.js';
|
|
33
|
-
|
|
34
|
-
dayjs.extend(timezone);
|
|
35
|
-
export const US_EQUITIES_TIME_ZONE = 'America/New_York';
|
|
33
|
+
export const US_EQUITIES_TIME_ZONE = NY_TIME_ZONE;
|
|
36
34
|
/**
|
|
37
35
|
* Switch for the equities extended-hours session. On (since 2026-10-02):
|
|
38
36
|
* Polygon's consolidated minute bars are back on exchange 92 and carry the
|
|
@@ -50,9 +48,10 @@ export const usEquitiesSessionConfig = { extendedHoursEnabled: true };
|
|
|
50
48
|
export function isEquityExtendedSession(sessionType) {
|
|
51
49
|
return usEquitiesSessionConfig.extendedHoursEnabled && sessionType === 'extended';
|
|
52
50
|
}
|
|
53
|
-
/** Minutes after local midnight, matching `checkUSMarketHours
|
|
54
|
-
const REGULAR_OPEN_MINUTES =
|
|
55
|
-
const REGULAR_CLOSE_MINUTES =
|
|
51
|
+
/** Minutes after local midnight, matching `checkUSMarketHours` (both read the New York calendar's edges). */
|
|
52
|
+
const REGULAR_OPEN_MINUTES = NY_REGULAR_OPEN_MINUTES;
|
|
53
|
+
const REGULAR_CLOSE_MINUTES = NY_REGULAR_CLOSE_MINUTES;
|
|
54
|
+
const DAY_MS = 86_400_000;
|
|
56
55
|
/**
|
|
57
56
|
* The regular cash session as a window object, for the shared zone-day walks
|
|
58
57
|
* in rth-session.util (one frozen constant so their per-window memo holds).
|
|
@@ -123,19 +122,9 @@ export function filterUsEquityRegularSessionBars(bars, intervalMs) {
|
|
|
123
122
|
export function usEquityAnchoredBucketStartMs(tsMs, intervalMs) {
|
|
124
123
|
if (!Number.isFinite(tsMs) || !Number.isFinite(intervalMs) || intervalMs <= 0)
|
|
125
124
|
return null;
|
|
126
|
-
|
|
125
|
+
const openMs = nyRegularSessionOpenMs(tsMs);
|
|
126
|
+
if (openMs === null)
|
|
127
127
|
return null;
|
|
128
|
-
let date;
|
|
129
|
-
try {
|
|
130
|
-
date = dayjs(tsMs).tz(US_EQUITIES_TIME_ZONE).format('YYYY-MM-DD');
|
|
131
|
-
}
|
|
132
|
-
catch {
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
const open = nyWallInstant(date, REGULAR_OPEN_MINUTES);
|
|
136
|
-
if (open === null)
|
|
137
|
-
return null;
|
|
138
|
-
const openMs = open.valueOf();
|
|
139
128
|
return openMs + Math.floor((tsMs - openMs) / intervalMs) * intervalMs;
|
|
140
129
|
}
|
|
141
130
|
/**
|
|
@@ -182,10 +171,11 @@ export function usEquityChangeReferenceClose(sessionBars, price, regularGated) {
|
|
|
182
171
|
const latest = bars[bars.length - 1];
|
|
183
172
|
if (!latest)
|
|
184
173
|
return null;
|
|
185
|
-
|
|
186
|
-
|
|
174
|
+
// The 16:00 New York close on the bar's UTC date.
|
|
175
|
+
const latestDay = nyCalendarDay(Math.floor(Math.trunc(latest[0]) / DAY_MS));
|
|
176
|
+
if (latestDay === null)
|
|
187
177
|
return null;
|
|
188
|
-
const latestCloseMs =
|
|
178
|
+
const latestCloseMs = latestDay.regularCloseMs;
|
|
189
179
|
let priceIsLater = price.atMs > latestCloseMs;
|
|
190
180
|
if (regularGated) {
|
|
191
181
|
const nextOpenMs = getUsEquitiesScheduleStatus(latestCloseMs).nextOpenMs;
|
|
@@ -197,25 +187,6 @@ export function usEquityChangeReferenceClose(sessionBars, price, regularGated) {
|
|
|
197
187
|
return bars.length >= 2 ? bars[bars.length - 2][4] : null;
|
|
198
188
|
}
|
|
199
189
|
// ─── Weekly schedule ─────────────────────────────────────────────────────────
|
|
200
|
-
/** New York wall-clock instant on `date` ('YYYY-MM-DD'); null on tz failure. */
|
|
201
|
-
function nyWallInstant(date, minutes) {
|
|
202
|
-
const hours = String(Math.floor(minutes / 60)).padStart(2, '0');
|
|
203
|
-
const mins = String(minutes % 60).padStart(2, '0');
|
|
204
|
-
try {
|
|
205
|
-
return dayjs.tz(`${date} ${hours}:${mins}`, US_EQUITIES_TIME_ZONE);
|
|
206
|
-
}
|
|
207
|
-
catch {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
/** Calendar-date arithmetic on the date string only: no DST involvement. */
|
|
212
|
-
function nextDate(date) {
|
|
213
|
-
return dayjs.utc(date).add(1, 'day').format('YYYY-MM-DD');
|
|
214
|
-
}
|
|
215
|
-
function isWeekday(date) {
|
|
216
|
-
const day = dayjs.utc(date).day();
|
|
217
|
-
return day >= 1 && day <= 5;
|
|
218
|
-
}
|
|
219
190
|
/**
|
|
220
191
|
* The static weekly cycle, evaluated at `nowMs`. Like the governed-futures
|
|
221
192
|
* schedule this is deliberately NOT a holiday calendar: on an exchange
|
|
@@ -223,29 +194,11 @@ function isWeekday(date) {
|
|
|
223
194
|
*/
|
|
224
195
|
export function getUsEquitiesScheduleStatus(nowMs) {
|
|
225
196
|
const phase = resolveUsEquitySessionPhase(nowMs);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
date = dayjs(nowMs).tz(US_EQUITIES_TIME_ZONE).format('YYYY-MM-DD');
|
|
229
|
-
}
|
|
230
|
-
catch {
|
|
197
|
+
const day = nyCalendarDayAt(nowMs);
|
|
198
|
+
if (day === null)
|
|
231
199
|
return { open: phase === 'regular', phase, nextOpenMs: null, nextCloseMs: null };
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
// Next weekday open strictly after now: today (pre-market) or the next
|
|
238
|
-
// trading day. Eight days covers any weekend from either side.
|
|
239
|
-
let candidate = date;
|
|
240
|
-
for (let i = 0; i < 8; i += 1) {
|
|
241
|
-
if (isWeekday(candidate)) {
|
|
242
|
-
const open = nyWallInstant(candidate, REGULAR_OPEN_MINUTES);
|
|
243
|
-
if (open === null)
|
|
244
|
-
return { open: false, phase, nextOpenMs: null, nextCloseMs: null };
|
|
245
|
-
if (open.valueOf() > nowMs)
|
|
246
|
-
return { open: false, phase, nextOpenMs: open.valueOf(), nextCloseMs: null };
|
|
247
|
-
}
|
|
248
|
-
candidate = nextDate(candidate);
|
|
249
|
-
}
|
|
250
|
-
return { open: false, phase, nextOpenMs: null, nextCloseMs: null };
|
|
200
|
+
if (phase === 'regular')
|
|
201
|
+
return { open: true, phase, nextOpenMs: null, nextCloseMs: day.regularCloseMs };
|
|
202
|
+
// Next weekday open strictly after now: today (pre-market) or the next trading day.
|
|
203
|
+
return { open: false, phase, nextOpenMs: nyNextRegularOpenAfterMs(nowMs), nextCloseMs: null };
|
|
251
204
|
}
|
|
@@ -63,6 +63,7 @@ import { cmeSessionBucketMs } from './cme-session-bucket.util.js';
|
|
|
63
63
|
import { isCmeGoverned } from './cme-realtime.util.js';
|
|
64
64
|
import { liveBucketVenueOf } from './live-bucket.util.js';
|
|
65
65
|
import { getMarketKind } from './marketKind.util.js';
|
|
66
|
+
import { zoneOffsetMsAt } from './ny-calendar.util.js';
|
|
66
67
|
import { getGovernedFuturesScheduleStatusForSymbol, GOVERNED_FUTURES_TIME_ZONE, isCmeAlwaysOnSymbol, } from './market-session-schedule.util.js';
|
|
67
68
|
import { engineRthWindowForSymbol, sessionWindowsInRange, } from './rth-session.util.js';
|
|
68
69
|
import { resolveUsEquitySessionPhase, US_EQUITIES_TIME_ZONE, } from './us-equities-session.util.js';
|
|
@@ -118,6 +119,7 @@ const floorTo = (value, step) => value - (((value % step) + step) % step);
|
|
|
118
119
|
const ZONE_DAYS_MAX = 4096;
|
|
119
120
|
function zoneClock(zone) {
|
|
120
121
|
return {
|
|
122
|
+
zone,
|
|
121
123
|
formatter: new Intl.DateTimeFormat('en-US', {
|
|
122
124
|
timeZone: zone,
|
|
123
125
|
hourCycle: 'h23',
|
|
@@ -134,8 +136,19 @@ function zoneClock(zone) {
|
|
|
134
136
|
}
|
|
135
137
|
const newYorkClock = zoneClock(US_EQUITIES_TIME_ZONE);
|
|
136
138
|
const chicagoClock = zoneClock(GOVERNED_FUTURES_TIME_ZONE);
|
|
137
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* The wall clock `tMs` reads in the zone, as if it were UTC (whole seconds): one Intl reading per
|
|
141
|
+
* UTC day (the zone clock in ny-calendar.util), so a day-lookup miss and a DST day's per-bar offset
|
|
142
|
+
* cost no Intl call.
|
|
143
|
+
*/
|
|
138
144
|
function wallAsUtcMs(clock, tMs) {
|
|
145
|
+
const offsetMs = zoneOffsetMsAt(clock.zone, tMs);
|
|
146
|
+
if (Number.isNaN(offsetMs))
|
|
147
|
+
return readWallAsUtcMs(clock, tMs);
|
|
148
|
+
return Math.floor(Math.trunc(tMs) / 1000) * 1000 + offsetMs;
|
|
149
|
+
}
|
|
150
|
+
/** The wall clock read from Intl: for the instants the zone clock does not serve (it throws for a non-date). */
|
|
151
|
+
function readWallAsUtcMs(clock, tMs) {
|
|
139
152
|
let year = 1970;
|
|
140
153
|
let month = 1;
|
|
141
154
|
let day = 1;
|
|
@@ -85,7 +85,13 @@ export declare const isPollingFetchPayload: (payload: {
|
|
|
85
85
|
tf?: string;
|
|
86
86
|
} | null | undefined) => boolean;
|
|
87
87
|
/**
|
|
88
|
-
* Check if a given timestamp is within regular US market hours (9:30 AM - 4:00 PM ET)
|
|
88
|
+
* Check if a given timestamp is within regular US market hours (9:30 AM - 4:00 PM ET), on the
|
|
89
|
+
* weekday cycle in New York time: pre-market 4:00 AM - 9:30 AM, after-hours 4:00 PM - 8:00 PM,
|
|
90
|
+
* closed otherwise and all weekend (holidays are not modelled).
|
|
91
|
+
*
|
|
92
|
+
* Per-row callers (every landed stock bar) pay integer compares: the New York calendar
|
|
93
|
+
* (ny-calendar.util) resolves each date's session edges once. A non-number input keeps its old
|
|
94
|
+
* dayjs reading (`undefined` is now, a Date or a date string is its instant).
|
|
89
95
|
* @param timestampMs - Timestamp in milliseconds
|
|
90
96
|
* @returns Object containing:
|
|
91
97
|
* - isRegularHours: true if within regular hours (9:30 AM - 4:00 PM ET)
|