@orangecharts/wrun-chart-host 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/constants/economic.constants.d.ts +2 -0
- package/dist/constants/economic.constants.js +2 -0
- package/dist/constants/feature-flags.constants.d.ts +10 -0
- package/dist/constants/feature-flags.constants.js +52 -4
- package/dist/constants/feature-limits.constants.d.ts +72 -4
- package/dist/constants/feature-limits.constants.js +98 -20
- package/dist/constants/interval.constants.js +5 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +12 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.js +14 -0
- package/dist/constants/typed-width-fold.leaf.d.ts +50 -0
- package/dist/constants/typed-width-fold.leaf.js +99 -0
- package/dist/constants/typed-width-source.leaf.d.ts +24 -0
- package/dist/constants/typed-width-source.leaf.js +126 -0
- package/dist/constants/typed-width.leaf.d.ts +57 -0
- package/dist/constants/typed-width.leaf.js +78 -0
- package/dist/host-env.d.ts +10 -0
- package/dist/host-env.js +7 -0
- package/dist/host-ports.types.d.ts +11 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +28 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +63 -3
- package/dist/interfaces/wrun-runtime.interface.js +11 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
- package/dist/market-data/billing.interface.d.ts +12 -45
- package/dist/market-data/billing.interface.js +2 -2
- package/dist/replay/replayLadder.js +7 -4
- package/dist/settings-templates/footprint-rows.d.ts +6 -0
- package/dist/settings-templates/footprint-rows.js +6 -0
- package/dist/settings-templates/frvp-fields.js +14 -0
- package/dist/settings-templates/indicator-fields.js +31 -0
- package/dist/settings-templates/tool-tables.generated.js +19 -1
- package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
- package/dist/utility/chart/cache-alignment.util.d.ts +42 -0
- package/dist/utility/chart/cache-alignment.util.js +88 -18
- package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
- package/dist/utility/chart/calendar-interval.util.js +152 -4
- package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
- package/dist/utility/chart/candle-bar-end.util.js +17 -6
- package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
- package/dist/utility/chart/chart-time-domain.util.js +13 -4
- package/dist/utility/chart/feed-interval.util.d.ts +4 -2
- package/dist/utility/chart/feed-interval.util.js +5 -2
- package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
- package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
- package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
- package/dist/utility/chart/footprint-display-mode.util.js +5 -0
- package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
- package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
- package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
- package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
- package/dist/utility/chart/history-wall.util.d.ts +13 -2
- package/dist/utility/chart/history-wall.util.js +11 -4
- package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
- package/dist/utility/chart/interval-ladder.util.js +44 -4
- package/dist/utility/chart/interval-registry.util.d.ts +22 -1
- package/dist/utility/chart/interval-registry.util.js +50 -2
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
- package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
- package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
- package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
- package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
- package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
- package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
- package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
- package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
- package/dist/utility/chart/live-bucket.util.d.ts +29 -4
- package/dist/utility/chart/live-bucket.util.js +45 -12
- package/dist/utility/chart/market-session.util.d.ts +62 -10
- package/dist/utility/chart/market-session.util.js +93 -13
- package/dist/utility/chart/marketKind.util.d.ts +1 -7
- package/dist/utility/chart/marketKind.util.js +6 -8
- package/dist/utility/chart/mixed-mode.util.d.ts +17 -0
- package/dist/utility/chart/om-target.util.js +6 -4
- package/dist/utility/chart/price-precision.util.d.ts +20 -6
- package/dist/utility/chart/price-precision.util.js +34 -7
- package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
- package/dist/utility/chart/profile-frame-window.util.js +12 -0
- package/dist/utility/chart/rth-session.util.d.ts +3 -1
- package/dist/utility/chart/rth-session.util.js +3 -1
- package/dist/utility/chart/script-source-session.util.d.ts +43 -0
- package/dist/utility/chart/script-source-session.util.js +61 -0
- package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
- package/dist/utility/chart/typed-width-grid.util.js +203 -0
- package/dist/utility/common/transformations.util.d.ts +6 -0
- package/dist/utility/common/transformations.util.js +28 -4
- package/dist/utility/number-format.util.d.ts +14 -1
- package/dist/utility/number-format.util.js +22 -4
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +113 -0
- package/dist/utility/v2/v2-enums.leaf.js +3 -0
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +9 -3
- package/dist/utility/wrun/wrun-batched-marks.util.js +65 -17
- package/dist/utility/wrun/wrun-canvases.util.d.ts +4 -2
- package/dist/utility/wrun/wrun-canvases.util.js +7 -12
- package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
- package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
- package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-card-style.util.js +2 -2
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +8 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +13 -1
- package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
- package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
- package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
- package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
- package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
- package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
- package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
- package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
- package/dist/utility/wrun/wrun-frames.d.ts +1 -1
- package/dist/utility/wrun/wrun-frames.js +2 -2
- package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-handles.util.js +1 -1
- package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
- package/dist/utility/wrun/wrun-host.service.js +44 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
- package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
- package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
- package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
- package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
- package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
- package/dist/utility/wrun/wrun-live-tick.util.js +59 -4
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +3 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +15 -0
- package/dist/utility/wrun/wrun-overlay-run.util.js +274 -47
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-panel-mount.util.js +42 -13
- package/dist/utility/wrun/wrun-pin-venues.util.js +5 -1
- package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-refusal.util.js +102 -13
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
- package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
- package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
- package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
- package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
- package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
- package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
- package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
- package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
- package/dist/utility/wrun/wrun-style-words.util.js +46 -15
- package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
- package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
- package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
- package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
- package/dist/utility/wrun-display-name.util.d.ts +10 -0
- package/dist/utility/wrun-display-name.util.js +21 -0
- package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
- package/dist/utils/replay/replay-buffer-math.js +2 -0
- package/dist/workers/constants/socket-slots.d.ts +1 -1
- package/dist/workers/utils/time.worker.util.js +2 -2
- package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
- package/dist/workers/utils/volume-profile.worker.util.js +20 -0
- package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
- package/dist/workers/wrun/wrun-abi-host.js +82 -5
- package/dist/workers/wrun/wrun-engine-handler.js +53 -4
- package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
- package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
- package/package.json +11 -11
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a custom size's bars sit on a chart's own market: the one grid the app-built candles, their live merge and
|
|
3
|
+
* (later) the indicator folds read. The product rule: on a market with trading sessions a custom bar starts at the
|
|
4
|
+
* session open and counts from there, and the session's last bar is short; a market that trades round the clock
|
|
5
|
+
* counts from 00:00 UTC (the fixed grid the gateway already serves custom sizes on).
|
|
6
|
+
*
|
|
7
|
+
* The grids, by kind (`typedGridKind`, which reads a venue exactly as live-bucket.util `liveBucketGrid` does):
|
|
8
|
+
* 'utc' `fixedGridFloorMs` at every size (day and week sizes count from Monday 2000-01-03);
|
|
9
|
+
* 'cme-session' the CME session lattice at the custom width (17:00 Chicago, offset = the open modulo the
|
|
10
|
+
* width), held to the product's schedule, so the bar before the daily halt ends at the halt;
|
|
11
|
+
* 'cme-regular' anchored at the regular session's open, as the live bucket's 'rth-anchored' grid is;
|
|
12
|
+
* 'equity-regular' anchored at the 09:30 New York open, the session 09:30 to 16:00;
|
|
13
|
+
* 'equity-extended' anchored at 04:00 New York, the session 04:00 to 20:00 New York on weekdays;
|
|
14
|
+
* 'options' a US option (OPRA): anchored at 09:30 New York, the session 09:30 to 16:15 on weekdays for every
|
|
15
|
+
* root (the app's rule, src/utility/chart/us-options-session.util `US_OPTIONS_SESSION_WINDOW`);
|
|
16
|
+
* 'forex' the forex session lattice at the custom width (17:00 New York).
|
|
17
|
+
* Every size under a day divides 24 hours, so a session grid repeats each day from the open. Day and week sizes ride
|
|
18
|
+
* the 'utc' kind only in this phase: on every other kind `typedBarStartMs` answers null for them on purpose until the
|
|
19
|
+
* phase that groups trade dates lands.
|
|
20
|
+
*
|
|
21
|
+
* The session lattices are composed, never edited: session-lattice.util takes a profile, so a copy of the CME or forex
|
|
22
|
+
* profile whose `intradayLatticeMs` also admits the custom widths runs the gateway's own lattice math at them.
|
|
23
|
+
*
|
|
24
|
+
* LAZY: loaded the first time a chart goes on a custom size the app builds, on the page and in the data worker.
|
|
25
|
+
* No eager module may import this file (tests/perf/typed-width-rules-lazy-closure.spec.ts).
|
|
26
|
+
*/
|
|
27
|
+
import { TYPED_WIDTH_SECONDS } from '../../constants/typed-width.leaf.js';
|
|
28
|
+
import { fixedGridFloorDivMs, fixedGridFloorMs } from './calendar-interval.util.js';
|
|
29
|
+
import { checkIsPolygon, getMarketKind } from './marketKind.util.js';
|
|
30
|
+
import { isGovernedFuturesSymbolOpenAt } from './market-session-schedule.util.js';
|
|
31
|
+
import { chartRegularSessionKind, marketAnchoredBucketEndMs, marketAnchoredBucketStartMs } from './market-session.util.js';
|
|
32
|
+
import { nyCalendarDayAt } from './ny-calendar.util.js';
|
|
33
|
+
import { CME_SESSION_LATTICE, FOREX_SESSION_LATTICE, sessionLatticeBarEndMs, sessionLatticeBucketMs, sessionLatticeOf, } from './session-lattice.util.js';
|
|
34
|
+
import { isEquityRegularSessionGated, usEquityAnchoredBucketStartMs } from './us-equities-session.util.js';
|
|
35
|
+
const MINUTE_MS = 60_000;
|
|
36
|
+
const DAY_MS = 86_400_000;
|
|
37
|
+
/** The twelve custom widths under a day, in ms: the widths the composed lattices admit. */
|
|
38
|
+
const TYPED_INTRADAY_WIDTHS_MS = Object.values(TYPED_WIDTH_SECONDS)
|
|
39
|
+
.filter((seconds) => seconds < 86_400)
|
|
40
|
+
.map((seconds) => seconds * 1000);
|
|
41
|
+
/**
|
|
42
|
+
* Which grid a custom size of `widthMs` rides on the chart's market. The order mirrors live-bucket.util
|
|
43
|
+
* `liveBucketGrid`: the chart's CME regular-hours switch first, then the regular-session stock gate, then the session
|
|
44
|
+
* lattice of the exchange. A US option (OPRA) rides its own 09:30 to 16:15 window. A stock tape
|
|
45
|
+
* venue (NASDAQ_TAPE) and the other listing codes the candle gate does not name ride the UTC grid, as their fixed
|
|
46
|
+
* sizes do today. A formula chart (`venue.transformations` with more than one leg) is refused upstream until the
|
|
47
|
+
* formula phase, so it is read here by its `exchange` alone.
|
|
48
|
+
*/
|
|
49
|
+
export function typedGridKind(widthMs, venue) {
|
|
50
|
+
if (!venue)
|
|
51
|
+
return 'utc';
|
|
52
|
+
const { exchange, symbol, sessionType } = venue;
|
|
53
|
+
if (chartRegularSessionKind(exchange, symbol, sessionType, widthMs) === 'cme')
|
|
54
|
+
return 'cme-regular';
|
|
55
|
+
if (isEquityRegularSessionGated(exchange, sessionType, widthMs))
|
|
56
|
+
return 'equity-regular';
|
|
57
|
+
const code = typeof exchange === 'string' ? exchange : undefined;
|
|
58
|
+
if (getMarketKind(code) === 'options')
|
|
59
|
+
return 'options';
|
|
60
|
+
// A stock listing the regular gate let through: its extended-hours switch is on.
|
|
61
|
+
if (checkIsPolygon(code))
|
|
62
|
+
return 'equity-extended';
|
|
63
|
+
const lattice = sessionLatticeOf(exchange);
|
|
64
|
+
if (lattice === CME_SESSION_LATTICE)
|
|
65
|
+
return 'cme-session';
|
|
66
|
+
if (lattice === FOREX_SESSION_LATTICE)
|
|
67
|
+
return 'forex';
|
|
68
|
+
return 'utc';
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The session profile with the custom widths admitted to its intraday lattice. It keeps the profile's `id`, so it
|
|
72
|
+
* shares that profile's zone state in session-lattice.util: the formatter and the offset caches depend on the zone
|
|
73
|
+
* alone, and the bar-end cache is keyed by width and stamp, where the base profile answers every preset width the same
|
|
74
|
+
* and never reads a custom width (it refuses one before its cache).
|
|
75
|
+
*/
|
|
76
|
+
const composedProfiles = new Map();
|
|
77
|
+
function composedProfileOf(base) {
|
|
78
|
+
let profile = composedProfiles.get(base);
|
|
79
|
+
if (!profile) {
|
|
80
|
+
profile = Object.freeze({
|
|
81
|
+
...base,
|
|
82
|
+
intradayLatticeMs: new Set([...base.intradayLatticeMs, ...TYPED_INTRADAY_WIDTHS_MS]),
|
|
83
|
+
});
|
|
84
|
+
composedProfiles.set(base, profile);
|
|
85
|
+
}
|
|
86
|
+
return profile;
|
|
87
|
+
}
|
|
88
|
+
const latticeProfileOf = (kind) => composedProfileOf(kind === 'cme-session' ? CME_SESSION_LATTICE : FOREX_SESSION_LATTICE);
|
|
89
|
+
/** The bar holding `tsMs` on a grid of `widthMs` anchored at `openMs`: a session-anchored floor under a day. */
|
|
90
|
+
const anchoredStartMs = (openMs, tsMs, widthMs) => openMs + fixedGridFloorDivMs(tsMs - openMs, widthMs);
|
|
91
|
+
/** A US option's close after the stock close: 16:15 New York (us-options-session.util `LATE_CLOSE_MINUTES`). */
|
|
92
|
+
const OPTIONS_CLOSE_AFTER_STOCK_CLOSE_MS = 15 * MINUTE_MS;
|
|
93
|
+
/**
|
|
94
|
+
* The New York session holding `tsMs` on a weekday, or null outside it: 04:00 to 20:00 for an extended-hours stock,
|
|
95
|
+
* 09:30 to 16:15 for a US option (one window for every root, as the app's options rule draws its bars).
|
|
96
|
+
*/
|
|
97
|
+
function nySessionAt(tsMs, kind) {
|
|
98
|
+
const day = nyCalendarDayAt(tsMs);
|
|
99
|
+
if (day === null || !day.isTradeDate)
|
|
100
|
+
return null;
|
|
101
|
+
const options = kind === 'options';
|
|
102
|
+
const openMs = options ? day.regularOpenMs : day.preMarketOpenMs;
|
|
103
|
+
const closeMs = options ? day.regularCloseMs + OPTIONS_CLOSE_AFTER_STOCK_CLOSE_MS : day.postMarketCloseMs;
|
|
104
|
+
return tsMs < openMs || tsMs >= closeMs ? null : { openMs, closeMs };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The first instant in `[openMs, endMs)` the CME product no longer trades by its schedule, else `endMs`: the daily
|
|
108
|
+
* halt (16:00 Chicago) or the Friday close cuts the bar that holds it. A bar holds at most one such edge, on a whole
|
|
109
|
+
* minute, so a minute bisection finds it.
|
|
110
|
+
*/
|
|
111
|
+
function scheduleCloseWithinMs(symbol, openMs, endMs) {
|
|
112
|
+
if (isGovernedFuturesSymbolOpenAt(symbol, endMs - 1) || !isGovernedFuturesSymbolOpenAt(symbol, openMs))
|
|
113
|
+
return endMs;
|
|
114
|
+
let openAt = openMs;
|
|
115
|
+
let closedAt = endMs - 1;
|
|
116
|
+
while (closedAt - openAt > MINUTE_MS) {
|
|
117
|
+
const midMs = openAt + Math.max(1, Math.floor((closedAt - openAt) / (2 * MINUTE_MS))) * MINUTE_MS;
|
|
118
|
+
if (isGovernedFuturesSymbolOpenAt(symbol, midMs))
|
|
119
|
+
openAt = midMs;
|
|
120
|
+
else
|
|
121
|
+
closedAt = midMs;
|
|
122
|
+
}
|
|
123
|
+
return Math.min(openAt + MINUTE_MS, endMs);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The stamp of the custom bar that holds `tsMs`, or null when the market holds no bar there (outside its session).
|
|
127
|
+
* `tsMs` is an instant inside the bar or the stamp of a source row the bar is built from; both give the same stamp.
|
|
128
|
+
*/
|
|
129
|
+
export function typedBarStartMs(tsMs, widthMs, venue) {
|
|
130
|
+
if (!Number.isFinite(tsMs) || !(widthMs > 0))
|
|
131
|
+
return null;
|
|
132
|
+
const kind = typedGridKind(widthMs, venue);
|
|
133
|
+
if (kind === 'utc')
|
|
134
|
+
return fixedGridFloorMs(tsMs, widthMs);
|
|
135
|
+
// Day and week sizes on a session market wait for the trade-date phase; a width that does not divide a day has no
|
|
136
|
+
// daily repeat from the open.
|
|
137
|
+
if (!(widthMs < DAY_MS) || !Number.isInteger(DAY_MS / widthMs))
|
|
138
|
+
return null;
|
|
139
|
+
switch (kind) {
|
|
140
|
+
case 'cme-session': {
|
|
141
|
+
const profile = latticeProfileOf(kind);
|
|
142
|
+
const startMs = sessionLatticeBucketMs(profile, tsMs, widthMs);
|
|
143
|
+
if (startMs === null || isGovernedFuturesSymbolOpenAt(venue?.symbol, tsMs))
|
|
144
|
+
return startMs;
|
|
145
|
+
// The lattice keeps stamping through the halts; the product holds no bar while it does not trade. The one
|
|
146
|
+
// closed stretch that does belong to a bar runs from a stamp to a reopen INSIDE that bucket: an always-on root
|
|
147
|
+
// resumes at 04:00 Chicago on Saturday, off the lattice at eight sizes, so the bar that holds the reopen is
|
|
148
|
+
// stamped inside the halt. A read window that ends or starts in that stretch must find the bar. A reopen on a
|
|
149
|
+
// lattice edge (17:00 Chicago, every other root) leaves the whole halt without a bar.
|
|
150
|
+
const endMs = sessionLatticeBarEndMs(profile, startMs, widthMs) ?? startMs + widthMs;
|
|
151
|
+
return isGovernedFuturesSymbolOpenAt(venue?.symbol, endMs - 1) ? startMs : null;
|
|
152
|
+
}
|
|
153
|
+
case 'forex':
|
|
154
|
+
return sessionLatticeBucketMs(latticeProfileOf(kind), tsMs, widthMs);
|
|
155
|
+
case 'cme-regular': {
|
|
156
|
+
const startMs = marketAnchoredBucketStartMs(venue?.exchange, venue?.symbol, tsMs, widthMs);
|
|
157
|
+
// The regular window is a wall-clock filter on every calendar day: a bar exists only while the product trades.
|
|
158
|
+
return startMs !== null && isGovernedFuturesSymbolOpenAt(venue?.symbol, startMs) ? startMs : null;
|
|
159
|
+
}
|
|
160
|
+
case 'equity-regular':
|
|
161
|
+
return usEquityAnchoredBucketStartMs(tsMs, widthMs);
|
|
162
|
+
case 'equity-extended':
|
|
163
|
+
case 'options': {
|
|
164
|
+
const session = nySessionAt(tsMs, kind);
|
|
165
|
+
return session === null ? null : anchoredStartMs(session.openMs, tsMs, widthMs);
|
|
166
|
+
}
|
|
167
|
+
default:
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The first instant the bar stamped `barMs` no longer takes rows: the next bar's open, or the session close when the
|
|
173
|
+
* bar is the session's short last one. The stock sessions model no early closes (ny-calendar.util has no half days),
|
|
174
|
+
* so an early close's last bar keeps its full-session end; its rows simply stop.
|
|
175
|
+
*/
|
|
176
|
+
export function typedBarEndMs(barMs, widthMs, venue) {
|
|
177
|
+
const nominalEndMs = barMs + widthMs;
|
|
178
|
+
const kind = typedGridKind(widthMs, venue);
|
|
179
|
+
if (kind === 'utc' || !(widthMs < DAY_MS) || !Number.isFinite(barMs))
|
|
180
|
+
return nominalEndMs;
|
|
181
|
+
switch (kind) {
|
|
182
|
+
case 'cme-session': {
|
|
183
|
+
// The lattice end covers a fall-back night's longer bar; the schedule cuts the bar at the daily halt.
|
|
184
|
+
const latticeEndMs = sessionLatticeBarEndMs(latticeProfileOf(kind), barMs, widthMs) ?? nominalEndMs;
|
|
185
|
+
return scheduleCloseWithinMs(venue?.symbol, barMs, latticeEndMs);
|
|
186
|
+
}
|
|
187
|
+
case 'forex':
|
|
188
|
+
return sessionLatticeBarEndMs(latticeProfileOf(kind), barMs, widthMs) ?? nominalEndMs;
|
|
189
|
+
case 'cme-regular':
|
|
190
|
+
return marketAnchoredBucketEndMs(venue?.exchange, venue?.symbol, barMs, widthMs) ?? nominalEndMs;
|
|
191
|
+
case 'equity-regular': {
|
|
192
|
+
const day = nyCalendarDayAt(barMs);
|
|
193
|
+
return day === null ? nominalEndMs : Math.min(nominalEndMs, day.regularCloseMs);
|
|
194
|
+
}
|
|
195
|
+
case 'equity-extended':
|
|
196
|
+
case 'options': {
|
|
197
|
+
const session = nySessionAt(barMs, kind);
|
|
198
|
+
return session === null ? nominalEndMs : Math.min(nominalEndMs, session.closeMs);
|
|
199
|
+
}
|
|
200
|
+
default:
|
|
201
|
+
return nominalEndMs;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -121,6 +121,12 @@ export declare function reconcileSymbolWithTransformations(meta: {
|
|
|
121
121
|
chain?: string;
|
|
122
122
|
poolAddress?: string;
|
|
123
123
|
}): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* How many `EXCHANGE|SYMBOL` tokens `sanitizeTransformations` drops from this string: markets a saved layout loses
|
|
126
|
+
* on install. The install reports a non-zero count (chart.ts setCurrentWorkspace), because the loss is silent on
|
|
127
|
+
* screen: the chart opens on the legs that are left.
|
|
128
|
+
*/
|
|
129
|
+
export declare function droppedMarketLegCount(transformations: string): number;
|
|
124
130
|
export declare function sanitizeTransformations(transformations: string): string;
|
|
125
131
|
export declare function processDisplayExchangeSymbol(exchange: string, symbol: string): string;
|
|
126
132
|
/**
|
|
@@ -533,7 +533,13 @@ function transformMergedData(transformations, ovData, lastDataPoint, sameTimeSta
|
|
|
533
533
|
}
|
|
534
534
|
const VALID_NUMBER_RE = /^(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;
|
|
535
535
|
const VALID_EXCHANGE_RE = /^[a-zA-Z0-9_.]+$/;
|
|
536
|
-
|
|
536
|
+
// Every character a market's symbol holds, and nothing markup can use (this string skips the HTML strip,
|
|
537
|
+
// workspace-text-strip.util.ts). Letters and digits of any script (venues list non-Latin names), `_ . - : /`, and
|
|
538
|
+
// the marks of `GC1!` (continuous futures alias), `@107` (Hyperliquid spot) and `#12270` (Hyperliquid outcome
|
|
539
|
+
// market). A symbol outside this set is DROPPED from a saved formula on its next open and its layout file import is
|
|
540
|
+
// refused, so a venue's new mark is added here with a row in tests/utility/common/transformations-sanitize.util.spec.ts.
|
|
541
|
+
// Never whitespace, quotes, brackets or `< > & =`.
|
|
542
|
+
const VALID_SYMBOL_RE = /^[\p{L}\p{N}_.\-:/!@#]+$/u;
|
|
537
543
|
// StreamPoints CME option raw symbols are `<future> <C|P><strike>` (for
|
|
538
544
|
// example `E4DU6 C7740`). The space is part of the symbol, not a formula
|
|
539
545
|
// separator. Keep this deliberately narrower than VALID_SYMBOL_RE: arbitrary
|
|
@@ -638,10 +644,28 @@ export function reconcileSymbolWithTransformations(meta) {
|
|
|
638
644
|
meta.symbol = symbol;
|
|
639
645
|
return true;
|
|
640
646
|
}
|
|
647
|
+
// Parentheses padded with spaces so each is its own token; hyphens stay inside their symbol.
|
|
648
|
+
function transformationTokens(transformations) {
|
|
649
|
+
return transformations
|
|
650
|
+
.replace(/([()])/g, ' $1 ')
|
|
651
|
+
.split(/\s+/)
|
|
652
|
+
.filter(Boolean);
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* How many `EXCHANGE|SYMBOL` tokens `sanitizeTransformations` drops from this string: markets a saved layout loses
|
|
656
|
+
* on install. The install reports a non-zero count (chart.ts setCurrentWorkspace), because the loss is silent on
|
|
657
|
+
* screen: the chart opens on the legs that are left.
|
|
658
|
+
*/
|
|
659
|
+
export function droppedMarketLegCount(transformations) {
|
|
660
|
+
let dropped = 0;
|
|
661
|
+
for (const token of transformationTokens(transformations)) {
|
|
662
|
+
if (token.includes(delimiter) && !isValidTransformationToken(token))
|
|
663
|
+
dropped += 1;
|
|
664
|
+
}
|
|
665
|
+
return dropped;
|
|
666
|
+
}
|
|
641
667
|
export function sanitizeTransformations(transformations) {
|
|
642
|
-
|
|
643
|
-
const padded = transformations.replace(/([()])/g, ' $1 ');
|
|
644
|
-
const tokens = padded.split(/\s+/).filter(Boolean);
|
|
668
|
+
const tokens = transformationTokens(transformations);
|
|
645
669
|
// Keep valid expression tokens. A CME option leg immediately following an
|
|
646
670
|
// exchange|future token belongs to that same raw symbol, so rejoin it before
|
|
647
671
|
// hydration reconciliation compares transformations with metadata.symbol.
|
|
@@ -60,10 +60,22 @@ export declare function safeDivide(a: number, b: number): number;
|
|
|
60
60
|
export type PriceConvention = 'usEquity' | 'ladder';
|
|
61
61
|
/** The one price-decimals rule: a known tick decides, else a US stock prints 2 from $1 and 4 below, else null. */
|
|
62
62
|
export declare function conventionPriceDecimals(magnitude: number, convention: PriceConvention, tick: number | null | undefined): number | null;
|
|
63
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* The magnitude ladder: 1 to 5 decimals by size, and under 1 enough for three significant digits of `magnitude`. The
|
|
65
|
+
* last step of the one market decimals rule (market-price-text.util marketPriceDecimals): it decides only while
|
|
66
|
+
* nothing is known of the market (no tick, no convention, no price of its own seen this session). The only decimals
|
|
67
|
+
* ladder for a market price: tests/utility/chart/market-price-text.decimals.guard.spec.ts fails on a private one.
|
|
68
|
+
*/
|
|
69
|
+
export declare function priceLadderDecimals(magnitude: number): number;
|
|
70
|
+
/**
|
|
71
|
+
* The ticker's digits: the market's tick or convention, else the decimals the market is known to print at
|
|
72
|
+
* (`decimals`: its venue tick's or the decimals its own prices carry, market-price-text.util), else the magnitude
|
|
73
|
+
* ladder; surfaces ask market-price-text.util.
|
|
74
|
+
*/
|
|
64
75
|
export declare function formatPriceByMagnitude(value: number, convention: PriceConvention, opts?: {
|
|
65
76
|
reference?: number;
|
|
66
77
|
tick?: number | null;
|
|
78
|
+
decimals?: number | null;
|
|
67
79
|
}): string;
|
|
68
80
|
export declare function titlePriceDirection(curr: unknown, prev: unknown, lastGlyph?: string): string;
|
|
69
81
|
/**
|
|
@@ -75,6 +87,7 @@ export declare function titlePriceDirection(curr: unknown, prev: unknown, lastGl
|
|
|
75
87
|
*/
|
|
76
88
|
export declare function formatTitlePrice(price: number, convention: PriceConvention, opts?: {
|
|
77
89
|
tick?: number | null;
|
|
90
|
+
decimals?: number | null;
|
|
78
91
|
}): string;
|
|
79
92
|
/** The tab title's price and glyph per chart and market; `formatPrice` prints the market's text (no blind default). */
|
|
80
93
|
export declare function formatChartTitlePrice(price: number, tc: TitleChart, context: {
|
|
@@ -185,7 +185,15 @@ export function conventionPriceDecimals(magnitude, convention, tick) {
|
|
|
185
185
|
return null;
|
|
186
186
|
return Math.abs(magnitude) >= 1 ? US_EQUITY_DECIMALS_FROM_ONE_DOLLAR : US_EQUITY_DECIMALS_BELOW_ONE_DOLLAR;
|
|
187
187
|
}
|
|
188
|
-
/**
|
|
188
|
+
/**
|
|
189
|
+
* The magnitude ladder: 1 to 5 decimals by size, and under 1 enough for three significant digits of `magnitude`. The
|
|
190
|
+
* last step of the one market decimals rule (market-price-text.util marketPriceDecimals): it decides only while
|
|
191
|
+
* nothing is known of the market (no tick, no convention, no price of its own seen this session). The only decimals
|
|
192
|
+
* ladder for a market price: tests/utility/chart/market-price-text.decimals.guard.spec.ts fails on a private one.
|
|
193
|
+
*/
|
|
194
|
+
export function priceLadderDecimals(magnitude) {
|
|
195
|
+
return tickerLadderDecimals(magnitude, magnitude);
|
|
196
|
+
}
|
|
189
197
|
function tickerLadderDecimals(value, magnitude) {
|
|
190
198
|
const ladder = value >= 10000 ? 1 : value >= 1000 ? 2 : value >= 100 ? 3 : value >= 10 ? 4 : 5;
|
|
191
199
|
const floor = magnitude > 0 && magnitude < 1
|
|
@@ -193,12 +201,19 @@ function tickerLadderDecimals(value, magnitude) {
|
|
|
193
201
|
: 0;
|
|
194
202
|
return Math.max(ladder, floor);
|
|
195
203
|
}
|
|
196
|
-
/**
|
|
204
|
+
/** Decimals a caller knows for the market (a whole count in the price axis's range), else null. */
|
|
205
|
+
const knownDecimals = (decimals) => typeof decimals === 'number' && Number.isInteger(decimals) && decimals >= 0 && decimals <= MAX_TICKER_DECIMALS;
|
|
206
|
+
/**
|
|
207
|
+
* The ticker's digits: the market's tick or convention, else the decimals the market is known to print at
|
|
208
|
+
* (`decimals`: its venue tick's or the decimals its own prices carry, market-price-text.util), else the magnitude
|
|
209
|
+
* ladder; surfaces ask market-price-text.util.
|
|
210
|
+
*/
|
|
197
211
|
export function formatPriceByMagnitude(value, convention,
|
|
198
212
|
// `reference`: the price a difference belongs to, whose decimals it prints at.
|
|
199
213
|
opts = {}) {
|
|
200
214
|
const magnitude = Math.abs(opts.reference ?? value);
|
|
201
|
-
const decimals = conventionPriceDecimals(magnitude, convention, opts.tick) ??
|
|
215
|
+
const decimals = conventionPriceDecimals(magnitude, convention, opts.tick) ??
|
|
216
|
+
(knownDecimals(opts.decimals) ? opts.decimals : tickerLadderDecimals(value, magnitude));
|
|
202
217
|
return value >= 10000
|
|
203
218
|
? value.toLocaleString('en-US', { minimumFractionDigits: decimals, maximumFractionDigits: decimals })
|
|
204
219
|
: value.toFixed(decimals);
|
|
@@ -223,7 +238,10 @@ export function titlePriceDirection(curr, prev, lastGlyph = '') {
|
|
|
223
238
|
export function formatTitlePrice(price, convention, opts = {}) {
|
|
224
239
|
if (!Number.isFinite(price))
|
|
225
240
|
return '';
|
|
226
|
-
const [whole, fraction] = formatPriceByMagnitude(Math.abs(price), convention, {
|
|
241
|
+
const [whole, fraction] = formatPriceByMagnitude(Math.abs(price), convention, {
|
|
242
|
+
tick: opts.tick,
|
|
243
|
+
decimals: opts.decimals,
|
|
244
|
+
})
|
|
227
245
|
.replace(/,/g, '')
|
|
228
246
|
.split('.');
|
|
229
247
|
const grouped = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* normalizer every lane reads a diagnostics array through. A leaf with no app edge, so the wrun chart-host package's
|
|
6
6
|
* socket source and row builder read it (docs/features/kscript/wrun/wrun-chart-host.md, "Leaves").
|
|
7
7
|
*/
|
|
8
|
-
import type { RuntimeDiagnostic } from '../../interfaces/kscript-diagnostics.interface.js';
|
|
8
|
+
import type { RuntimeDiagnostic, WrunTrapReason } from '../../interfaces/kscript-diagnostics.interface.js';
|
|
9
|
+
import type { WrunTrapContext } from '../../interfaces/wrun-runtime.interface.js';
|
|
9
10
|
import type { WrunRefusal } from '../wrun/wrun-refusal.util.js';
|
|
10
11
|
/**
|
|
11
12
|
* A browser-run Indicator's AssemblyScript trap (`env.abort`: a throw, a std-lib bounds
|
|
@@ -82,6 +83,28 @@ export type WrunAnchorExport = 'init' | 'state' | 'finalize' | 'reset';
|
|
|
82
83
|
export declare function wrunRunFailureRuntimeDiagnostic(message: string, context?: {
|
|
83
84
|
outputNames?: readonly string[];
|
|
84
85
|
}): RuntimeDiagnostic | null;
|
|
86
|
+
/** What failed, in plain words: a std-lib check by name, the engine's `unreachable`, else the guest's own abort words,
|
|
87
|
+
* else that it called abort(); empty for a record no words name (another engine trap, a host refusal). */
|
|
88
|
+
export declare function wrunTrapWhat(trap: WrunTrapContext, translate: WrunTrapTranslate): string;
|
|
89
|
+
export declare const WRUN_TRAP_LOCALE_PREFIX = "scriptEditor.shellConsole.trap";
|
|
90
|
+
/** A translator (`i18n.global.t` compatible); the leaf has no app edge, so the caller passes it. */
|
|
91
|
+
export type WrunTrapTranslate = (key: string, params?: Record<string, unknown>) => string;
|
|
92
|
+
/** What failed, decided from the record alone (never from a message text). */
|
|
93
|
+
export declare function wrunTrapReasonOf(trap: WrunTrapContext): WrunTrapReason;
|
|
94
|
+
/** Where the trap happened: the bar (1-based, as the row's `barIndex`) and its time, or before the first bar. */
|
|
95
|
+
export declare function wrunTrapWhere(trap: WrunTrapContext, translate: WrunTrapTranslate): string;
|
|
96
|
+
/**
|
|
97
|
+
* The trap row built from the ABI host's record (`WrunTrapContext`, captured at the guest-call boundary): `code`,
|
|
98
|
+
* `stage` and `reason` are decided from the record first, then the words. An abort says what failed in plain words
|
|
99
|
+
* (a std-lib check by name, else the guest's own words, else that it called abort()) and on which bar, without the
|
|
100
|
+
* library path; the row keeps the line and column only when the abort names src/indicator.ts. An `unreachable` keeps
|
|
101
|
+
* today's memory sentence plus the bar. A host failure keeps today's row and words. Every row carries `barIndex`
|
|
102
|
+
* (1-based), `details.hostMessage` (the sandbox's words, untouched) and `details.trap`. Null for a record no row
|
|
103
|
+
* speaks for (another engine trap, a host refusal outside the run failure rows): today's surface.
|
|
104
|
+
*/
|
|
105
|
+
export declare function wrunTrapRuntimeDiagnostic(trap: WrunTrapContext, hostMessage: string, translate: WrunTrapTranslate, context?: {
|
|
106
|
+
outputNames?: readonly string[];
|
|
107
|
+
}): RuntimeDiagnostic | null;
|
|
85
108
|
export interface NormalizeRuntimeDiagnosticsOptions {
|
|
86
109
|
/**
|
|
87
110
|
* kScript currently emits RENDER_NO_PLOT when a script only produces drawings.
|
|
@@ -207,6 +207,119 @@ export function wrunRunFailureRuntimeDiagnostic(message, context = {}) {
|
|
|
207
207
|
}
|
|
208
208
|
return null;
|
|
209
209
|
}
|
|
210
|
+
/** The std-lib abort messages the row names in plain words (AssemblyScript's `~lib/util/error.ts`), read only from an
|
|
211
|
+
* abort whose path is the std lib: the author's own abort("Index out of range") stays the author's words. */
|
|
212
|
+
const WRUN_STD_LIB_ABORT_REASONS = {
|
|
213
|
+
'Index out of range': 'index-out-of-range',
|
|
214
|
+
'Key does not exist': 'key-not-found',
|
|
215
|
+
'Array is empty': 'array-empty',
|
|
216
|
+
};
|
|
217
|
+
/** The locale key of each reason the row names in plain words (`scriptEditor.shellConsole.trap.what.*`). */
|
|
218
|
+
const WRUN_TRAP_WHAT_KEYS = {
|
|
219
|
+
'index-out-of-range': 'indexOutOfRange',
|
|
220
|
+
'key-not-found': 'keyNotFound',
|
|
221
|
+
'array-empty': 'arrayEmpty',
|
|
222
|
+
unreachable: 'unreachable',
|
|
223
|
+
};
|
|
224
|
+
/** What failed, in plain words: a std-lib check by name, the engine's `unreachable`, else the guest's own abort words,
|
|
225
|
+
* else that it called abort(); empty for a record no words name (another engine trap, a host refusal). */
|
|
226
|
+
export function wrunTrapWhat(trap, translate) {
|
|
227
|
+
const reason = wrunTrapReasonOf(trap);
|
|
228
|
+
const whatKey = WRUN_TRAP_WHAT_KEYS[reason];
|
|
229
|
+
if (whatKey !== undefined)
|
|
230
|
+
return translate(`${WRUN_TRAP_LOCALE_PREFIX}.what.${whatKey}`);
|
|
231
|
+
if (trap.kind !== 'abort')
|
|
232
|
+
return '';
|
|
233
|
+
const words = trap.abort?.message?.trim().replace(/\.+$/, '') ?? '';
|
|
234
|
+
return words !== '' ? words : translate(`${WRUN_TRAP_LOCALE_PREFIX}.what.abort`);
|
|
235
|
+
}
|
|
236
|
+
export const WRUN_TRAP_LOCALE_PREFIX = 'scriptEditor.shellConsole.trap';
|
|
237
|
+
/** What failed, decided from the record alone (never from a message text). */
|
|
238
|
+
export function wrunTrapReasonOf(trap) {
|
|
239
|
+
if (trap.kind === 'abort') {
|
|
240
|
+
const path = trap.abort?.path ?? '';
|
|
241
|
+
const message = trap.abort?.message?.trim() ?? '';
|
|
242
|
+
return (path.startsWith('~lib/') ? WRUN_STD_LIB_ABORT_REASONS[message] : undefined) ?? 'abort';
|
|
243
|
+
}
|
|
244
|
+
if (trap.kind === 'native')
|
|
245
|
+
return WRUN_UNREACHABLE_TRAP_RE.test(trap.native?.message.trim() ?? '') ? 'unreachable' : 'native';
|
|
246
|
+
return 'host';
|
|
247
|
+
}
|
|
248
|
+
/** `2026-11-14 10:00` for an epoch-ms time (UTC: the sentence says so), the number itself for a time that is none. */
|
|
249
|
+
function wrunTrapBarTime(ts) {
|
|
250
|
+
if (!Number.isFinite(ts))
|
|
251
|
+
return String(ts);
|
|
252
|
+
const date = new Date(ts);
|
|
253
|
+
return Number.isNaN(date.getTime()) ? String(ts) : date.toISOString().slice(0, 16).replace('T', ' ');
|
|
254
|
+
}
|
|
255
|
+
/** Where the trap happened: the bar (1-based, as the row's `barIndex`) and its time, or before the first bar. */
|
|
256
|
+
export function wrunTrapWhere(trap, translate) {
|
|
257
|
+
return trap.bar
|
|
258
|
+
? translate(`${WRUN_TRAP_LOCALE_PREFIX}.onBar`, { bar: trap.bar.index + 1, time: wrunTrapBarTime(trap.bar.ts) })
|
|
259
|
+
: translate(`${WRUN_TRAP_LOCALE_PREFIX}.beforeBars`);
|
|
260
|
+
}
|
|
261
|
+
/** The fields every trap row carries: the 1-based bar (the normalizer drops a 0), the host's words and the record. */
|
|
262
|
+
function wrunTrapRowFields(trap, reason, hostMessage, libSite) {
|
|
263
|
+
const details = {
|
|
264
|
+
kind: trap.kind,
|
|
265
|
+
phase: trap.phase,
|
|
266
|
+
reason,
|
|
267
|
+
...(trap.bar ? { barTs: trap.bar.ts } : {}),
|
|
268
|
+
...(libSite !== undefined ? { libSite } : {}),
|
|
269
|
+
};
|
|
270
|
+
return {
|
|
271
|
+
...(trap.bar ? { barIndex: trap.bar.index + 1 } : {}),
|
|
272
|
+
details: { hostMessage: hostMessage.trim(), trap: details },
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The trap row built from the ABI host's record (`WrunTrapContext`, captured at the guest-call boundary): `code`,
|
|
277
|
+
* `stage` and `reason` are decided from the record first, then the words. An abort says what failed in plain words
|
|
278
|
+
* (a std-lib check by name, else the guest's own words, else that it called abort()) and on which bar, without the
|
|
279
|
+
* library path; the row keeps the line and column only when the abort names src/indicator.ts. An `unreachable` keeps
|
|
280
|
+
* today's memory sentence plus the bar. A host failure keeps today's row and words. Every row carries `barIndex`
|
|
281
|
+
* (1-based), `details.hostMessage` (the sandbox's words, untouched) and `details.trap`. Null for a record no row
|
|
282
|
+
* speaks for (another engine trap, a host refusal outside the run failure rows): today's surface.
|
|
283
|
+
*/
|
|
284
|
+
export function wrunTrapRuntimeDiagnostic(trap, hostMessage, translate, context = {}) {
|
|
285
|
+
const reason = wrunTrapReasonOf(trap);
|
|
286
|
+
if (trap.kind === 'abort') {
|
|
287
|
+
const abort = trap.abort ?? { message: null, path: null, line: 0, column: 0 };
|
|
288
|
+
const anchored = abort.path === WRUN_ABORT_ENTRY_FILE && abort.line > 0;
|
|
289
|
+
const words = abort.message?.trim().replace(/\.+$/, '') ?? '';
|
|
290
|
+
const kitClass = anchored ? undefined : WRUN_KIT_ABORT_CLASS.exec(words)?.groups?.name;
|
|
291
|
+
const libSite = abort.path !== null && abort.path !== WRUN_ABORT_ENTRY_FILE
|
|
292
|
+
? abort.line > 0
|
|
293
|
+
? `${abort.path}:${abort.line}:${abort.column}`
|
|
294
|
+
: abort.path
|
|
295
|
+
: undefined;
|
|
296
|
+
const what = wrunTrapWhat(trap, translate);
|
|
297
|
+
const fields = wrunTrapRowFields(trap, reason, hostMessage, libSite);
|
|
298
|
+
return {
|
|
299
|
+
stage: 'compute',
|
|
300
|
+
severity: 'error',
|
|
301
|
+
code: WRUN_ABORT_DIAGNOSTIC_CODE,
|
|
302
|
+
message: translate(`${WRUN_TRAP_LOCALE_PREFIX}.plain`, { what, where: wrunTrapWhere(trap, translate) }),
|
|
303
|
+
type: 'execution',
|
|
304
|
+
...(anchored ? { line: abort.line, ...(abort.column > 0 ? { column: abort.column } : {}) } : {}),
|
|
305
|
+
...(fields.barIndex !== undefined ? { barIndex: fields.barIndex } : {}),
|
|
306
|
+
details: { ...(kitClass !== undefined ? { anchorClass: kitClass } : {}), ...fields.details },
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
// Another engine trap keeps today's surface (no row).
|
|
310
|
+
if (reason === 'native')
|
|
311
|
+
return null;
|
|
312
|
+
const row = wrunRunFailureRuntimeDiagnostic(hostMessage, context);
|
|
313
|
+
if (row === null)
|
|
314
|
+
return null;
|
|
315
|
+
const fields = wrunTrapRowFields(trap, reason, hostMessage, undefined);
|
|
316
|
+
return {
|
|
317
|
+
...row,
|
|
318
|
+
...(reason === 'unreachable' ? { message: `${row.message} ${wrunTrapWhere(trap, translate)}` } : {}),
|
|
319
|
+
...(fields.barIndex !== undefined ? { barIndex: fields.barIndex } : {}),
|
|
320
|
+
details: { ...row.details, ...fields.details },
|
|
321
|
+
};
|
|
322
|
+
}
|
|
210
323
|
function isObject(value) {
|
|
211
324
|
return typeof value === 'object' && value !== null;
|
|
212
325
|
}
|
|
@@ -46,6 +46,7 @@ export const AssetClass = numericEnum({
|
|
|
46
46
|
ASSET_CLASS_INDEX: 7,
|
|
47
47
|
ASSET_CLASS_PREDICTION: 8,
|
|
48
48
|
ASSET_CLASS_ECONOMIC: 9,
|
|
49
|
+
ASSET_CLASS_FIXED_INCOME: 10,
|
|
49
50
|
});
|
|
50
51
|
export const Category = numericEnum({
|
|
51
52
|
UNKNOWN_CATEGORY: 0,
|
|
@@ -207,6 +208,8 @@ export const Exchange = numericEnum({
|
|
|
207
208
|
LIGHTER: 177,
|
|
208
209
|
VARIATIONAL: 178,
|
|
209
210
|
VARIATIONAL_SWAP: 179,
|
|
211
|
+
FRED: 180,
|
|
212
|
+
CFTC: 181,
|
|
210
213
|
});
|
|
211
214
|
export const Representation = numericEnum({
|
|
212
215
|
UNKNOWN_REPRESENTATION: 0,
|
|
@@ -66,6 +66,7 @@ import type { DisplayOffset } from '../chart/display-offset.leaf.js';
|
|
|
66
66
|
import { type WrunCellsCapSummary } from './wrun-cap-notice.util.js';
|
|
67
67
|
import { type WrunCanvasReadout } from './wrun-canvas-readout.util.js';
|
|
68
68
|
import { wrunCanvasMergeLive } from './wrun-canvases.util.js';
|
|
69
|
+
import './wrun-colour-tone.util.js';
|
|
69
70
|
import { type WrunColorTheme } from './wrun-style-words.util.js';
|
|
70
71
|
export { decodeWrunFlagMeta, decodeWrunMarkMeta, decodeWrunSpanMeta, formatWrunBatchedNumber, isWrunBatchedNumberFormat, WRUN_BATCHED_NUMBER_FORMATS, wrunBatchedReadoutText, wrunMarkQtyInUnits, WRUN_MARK_META_MAX_OFFSET_MS, type WrunBatchedNumberFormat, type WrunFlagMeta, type WrunMarkMeta, type WrunSpanMeta, } from './wrun-batched-readout.util.js';
|
|
71
72
|
export type { WrunBatchedHoverRecord } from './wrun-canvas-readout.util.js';
|
|
@@ -247,15 +248,20 @@ export declare function wrunBatchedMarksChildren(sheet: WrunBatchedSheet, output
|
|
|
247
248
|
* number decoded (a packed theme token through its word, the existing packed-colour decode for the
|
|
248
249
|
* rest); undefined when it is neither. */
|
|
249
250
|
export declare function resolveWrunBatchedColor(value: unknown, theme: WrunColorTheme): string | undefined;
|
|
251
|
+
/** The batched marks level a chart's engine draws (`tc.packHooks.batchedMarksLevel`, set by its batchedMarks pack):
|
|
252
|
+
* 0 when the chart carries none (an engine before the Big Trades looks round). */
|
|
253
|
+
export declare function wrunBatchedMarksLevelOf(tc: unknown): number;
|
|
250
254
|
/**
|
|
251
255
|
* Why the chart's engine cannot draw a batched child its kind's renderer draws, null when it can: the mount asks it
|
|
252
256
|
* once the engine gate passed the kind (the pack settled and registered, `hasPlotRenderer` the engine's own answer).
|
|
253
257
|
* A marks child whose look needs the dark pool round's engine (look 4, the `log` law, a `min_px` or `max_px` bound)
|
|
254
258
|
* on an engine without that release's `flags` renderer is refused by name ("Needs a newer chart"), as an unknown
|
|
255
|
-
* look is by the layout gate, never drawn as another look.
|
|
256
|
-
*
|
|
259
|
+
* look is by the layout gate, never drawn as another look. So is one that needs the Big Trades looks round's engine
|
|
260
|
+
* (look 5 Glass, look 6 Solid, or the size beside the mark, `text.place` 1) on an engine whose marks pack reads below
|
|
261
|
+
* level 2 (`marksLevel`, `wrunBatchedMarksLevelOf`; 0 when the caller passes none). A flags child is never judged
|
|
262
|
+
* here: the gate already asked the engine for its kind. The reason is diagnostic text, never copy.
|
|
257
263
|
*/
|
|
258
|
-
export declare function wrunBatchedEngineVerdict(child: Pick<WrunBatchedChildOverlay, 'kind' | 'settings'>, hasPlotRenderer: (type: string) => boolean): string | null;
|
|
264
|
+
export declare function wrunBatchedEngineVerdict(child: Pick<WrunBatchedChildOverlay, 'kind' | 'settings'>, hasPlotRenderer: (type: string) => boolean, marksLevel?: number): string | null;
|
|
259
265
|
export interface WrunBatchedChildConfig {
|
|
260
266
|
id: string;
|
|
261
267
|
plot: WrunBatchedMarksKind;
|