@orangecharts/wrun-chart-host 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/constants/economic.constants.d.ts +2 -0
- package/dist/constants/economic.constants.js +2 -0
- package/dist/constants/feature-flags.constants.d.ts +11 -0
- package/dist/constants/feature-flags.constants.js +56 -4
- package/dist/constants/feature-limits.constants.d.ts +72 -4
- package/dist/constants/feature-limits.constants.js +98 -20
- package/dist/constants/interval.constants.js +5 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +12 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.js +14 -0
- package/dist/constants/typed-width-fold.leaf.d.ts +50 -0
- package/dist/constants/typed-width-fold.leaf.js +99 -0
- package/dist/constants/typed-width-source.leaf.d.ts +24 -0
- package/dist/constants/typed-width-source.leaf.js +126 -0
- package/dist/constants/typed-width.leaf.d.ts +57 -0
- package/dist/constants/typed-width.leaf.js +78 -0
- package/dist/host-env.d.ts +24 -0
- package/dist/host-env.js +22 -0
- package/dist/host-ports.types.d.ts +11 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +28 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +107 -4
- package/dist/interfaces/wrun-runtime.interface.js +11 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
- package/dist/market-data/billing.interface.d.ts +12 -45
- package/dist/market-data/billing.interface.js +2 -2
- package/dist/market-data/venues/index.d.ts +2 -2
- package/dist/market-data/venues/opra.js +3 -3
- package/dist/market-data/venues/stocks.contract.copy.json +3 -2
- package/dist/market-data/venues/stocks.d.ts +2 -2
- package/dist/market-data/venues/stocks.js +10 -9
- package/dist/replay/replayLadder.js +7 -4
- package/dist/settings-templates/footprint-rows.d.ts +6 -0
- package/dist/settings-templates/footprint-rows.js +6 -0
- package/dist/settings-templates/frvp-fields.js +14 -0
- package/dist/settings-templates/indicator-fields.js +46 -0
- package/dist/settings-templates/tool-tables.generated.js +19 -1
- package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
- package/dist/utility/chart/cache-alignment.util.d.ts +65 -0
- package/dist/utility/chart/cache-alignment.util.js +124 -24
- package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
- package/dist/utility/chart/calendar-interval.util.js +152 -4
- package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
- package/dist/utility/chart/candle-bar-end.util.js +17 -6
- package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
- package/dist/utility/chart/chart-time-domain.util.js +13 -4
- package/dist/utility/chart/feed-interval.util.d.ts +4 -2
- package/dist/utility/chart/feed-interval.util.js +5 -2
- package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
- package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
- package/dist/utility/chart/footprint-band.util.d.ts +21 -5
- package/dist/utility/chart/footprint-band.util.js +53 -14
- package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
- package/dist/utility/chart/footprint-display-mode.util.js +5 -0
- package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
- package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
- package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
- package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
- package/dist/utility/chart/history-wall.util.d.ts +13 -2
- package/dist/utility/chart/history-wall.util.js +11 -4
- package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
- package/dist/utility/chart/interval-ladder.util.js +44 -4
- package/dist/utility/chart/interval-registry.util.d.ts +22 -1
- package/dist/utility/chart/interval-registry.util.js +50 -2
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
- package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
- package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
- package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
- package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
- package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
- package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
- package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
- package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
- package/dist/utility/chart/live-bucket.util.d.ts +29 -4
- package/dist/utility/chart/live-bucket.util.js +45 -12
- package/dist/utility/chart/market-session.util.d.ts +62 -10
- package/dist/utility/chart/market-session.util.js +93 -13
- package/dist/utility/chart/marketKind.util.d.ts +1 -7
- package/dist/utility/chart/marketKind.util.js +6 -8
- package/dist/utility/chart/mixed-mode.util.d.ts +17 -0
- package/dist/utility/chart/om-target.util.js +6 -4
- package/dist/utility/chart/price-precision.util.d.ts +20 -6
- package/dist/utility/chart/price-precision.util.js +34 -7
- package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
- package/dist/utility/chart/profile-frame-window.util.js +12 -0
- package/dist/utility/chart/rth-session.util.d.ts +3 -1
- package/dist/utility/chart/rth-session.util.js +3 -1
- package/dist/utility/chart/script-source-session.util.d.ts +43 -0
- package/dist/utility/chart/script-source-session.util.js +61 -0
- package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
- package/dist/utility/chart/typed-width-grid.util.js +203 -0
- package/dist/utility/chart/wrun-run-result.util.d.ts +9 -1
- package/dist/utility/chart/wrun-run-result.util.js +8 -2
- package/dist/utility/common/transformations.util.d.ts +6 -0
- package/dist/utility/common/transformations.util.js +28 -4
- package/dist/utility/number-format.util.d.ts +14 -1
- package/dist/utility/number-format.util.js +22 -4
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +113 -0
- package/dist/utility/v2/v2-enums.leaf.js +3 -0
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +15 -5
- package/dist/utility/wrun/wrun-batched-marks.util.js +70 -20
- package/dist/utility/wrun/wrun-canvases.util.d.ts +28 -9
- package/dist/utility/wrun/wrun-canvases.util.js +99 -39
- package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
- package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
- package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-card-style.util.js +2 -2
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +8 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +13 -1
- package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
- package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
- package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
- package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
- package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
- package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
- package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
- package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
- package/dist/utility/wrun/wrun-frames.d.ts +1 -1
- package/dist/utility/wrun/wrun-frames.js +2 -2
- package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-handles.util.js +1 -1
- package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
- package/dist/utility/wrun/wrun-host.service.js +44 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
- package/dist/utility/wrun/wrun-hover.util.d.ts +8 -2
- package/dist/utility/wrun/wrun-hover.util.js +24 -13
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
- package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
- package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
- package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
- package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
- package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
- package/dist/utility/wrun/wrun-live-tick.util.js +81 -19
- package/dist/utility/wrun/wrun-output-words.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-output-words.util.js +51 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +41 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +35 -0
- package/dist/utility/wrun/wrun-overlay-result.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +23 -2
- package/dist/utility/wrun/wrun-overlay-run.util.js +305 -51
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +10 -2
- package/dist/utility/wrun/wrun-panel-mount.util.js +144 -18
- package/dist/utility/wrun/wrun-pin-venues.util.js +5 -1
- package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-refusal.util.js +102 -13
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
- package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
- package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
- package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
- package/dist/utility/wrun/wrun-run-health.util.d.ts +6 -3
- package/dist/utility/wrun/wrun-run-health.util.js +5 -2
- package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
- package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +25 -8
- package/dist/utility/wrun/wrun-script-inputs.util.js +145 -45
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
- package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
- package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
- package/dist/utility/wrun/wrun-style-names.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-style-names.util.js +74 -0
- package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
- package/dist/utility/wrun/wrun-style-words.util.js +46 -15
- package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
- package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
- package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
- package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
- package/dist/utility/wrun-display-name.util.d.ts +10 -0
- package/dist/utility/wrun-display-name.util.js +21 -0
- package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
- package/dist/utils/replay/replay-buffer-math.js +2 -0
- package/dist/workers/constants/socket-slots.d.ts +1 -1
- package/dist/workers/utils/time.worker.util.js +2 -2
- package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
- package/dist/workers/utils/volume-profile.worker.util.js +20 -0
- package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
- package/dist/workers/wrun/wrun-abi-host.js +82 -5
- package/dist/workers/wrun/wrun-engine-handler.js +53 -4
- package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
- package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
- package/package.json +11 -11
|
@@ -25,7 +25,12 @@
|
|
|
25
25
|
* 5. a session-lattice venue on its own lattice (session-lattice.util: the CME
|
|
26
26
|
* family from 2m to 12h, 1d, 3d; forex from 4h up), the profile the
|
|
27
27
|
* gateway rolls that venue up on;
|
|
28
|
-
* 6. everything else: the UTC floor
|
|
28
|
+
* 6. everything else: the UTC floor (for a typed day or week length, the
|
|
29
|
+
* fixed grid from Monday 2000-01-03: calendar-interval.util).
|
|
30
|
+
* A custom width under a day (typed-width.leaf) is never bucket exact: on a CME regular-hours chart it rides 3, on a
|
|
31
|
+
* regular-session stock 4, on CME full session, forex, an extended-hours stock and a US option the lazy session grid
|
|
32
|
+
* through `typedSessionGrid` (null while the slot is empty), and everywhere else 6. A walk over the length table sets
|
|
33
|
+
* `lengthRow` on the venue and reads such a width as any other length (the session feed's reach).
|
|
29
34
|
* Null means the frame has no bucket (off-session under 3 or 4): the chart
|
|
30
35
|
* holds no bar there, so drop it. At 30m and finer the session grids share
|
|
31
36
|
* the UTC floor's lattice, never its bars: a regular-session chart holds none
|
|
@@ -34,9 +39,9 @@
|
|
|
34
39
|
import { findMonday, TimeIntervalConstant } from './titan-constants.pin.js';
|
|
35
40
|
import { CME_SESSION_LATTICE, isSessionLatticeIntervalMs, sessionLatticeBarEndMs, sessionLatticeBarOpenMs, sessionLatticeBucketMs, sessionLatticeOf, } from './session-lattice.util.js';
|
|
36
41
|
import { Intervals } from '../../constants/interval.constants.js';
|
|
37
|
-
import { calendarBarStartMs, calendarMonthsOfMs } from './calendar-interval.util.js';
|
|
42
|
+
import { calendarBarStartMs, calendarMonthsOfMs, fixedGridFloorMs } from './calendar-interval.util.js';
|
|
38
43
|
import { formulaCalendarPlan, formulaLegExchange } from './formula-calendar.util.js';
|
|
39
|
-
import { checkIsEconomic } from './marketKind.util.js';
|
|
44
|
+
import { checkIsEconomic, checkIsPolygon, getMarketKind } from './marketKind.util.js';
|
|
40
45
|
import { extractTokensFromTransformations, parsedTransformations } from '../common/transformations.util.js';
|
|
41
46
|
import { isGovernedFuturesSymbolOpenAt } from './market-session-schedule.util.js';
|
|
42
47
|
import { chartRegularSessionKind, isWithinMarketRegularWindow, marketAnchoredBucketStartMs, } from './market-session.util.js';
|
|
@@ -57,6 +62,22 @@ export function liveBucketVenueOf(metadata) {
|
|
|
57
62
|
...(typeof metadata?.transformations === 'string' && { transformations: metadata.transformations }),
|
|
58
63
|
};
|
|
59
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* The session grid of a custom size (typed-width-grid.util `typedBarStartMs`), set once per realm by the lazy file
|
|
67
|
+
* that builds such a chart's candles (the page: typed-fold-ask.util; the data worker: its fold kit). Empty until
|
|
68
|
+
* then, and a grid that asks it answers null: the frame has no bucket, never another grid's.
|
|
69
|
+
*/
|
|
70
|
+
export const typedSessionGrid = {};
|
|
71
|
+
/**
|
|
72
|
+
* The twelve custom widths under a day, in ms: typed-width.leaf's labels under a day, written out in minutes because
|
|
73
|
+
* importing the leaf here costs boot bytes (the pre-candle budget). Never a bucket-exact width on a session grid.
|
|
74
|
+
* tests/utility/chart/live-bucket.util.typed-session.spec.ts fails when this list and the leaf differ.
|
|
75
|
+
*/
|
|
76
|
+
const TYPED_INTRADAY_MS = new Set([4, 6, 8, 9, 12, 16, 18, 20, 40, 80, 90, 180].map((minutes) => minutes * 60_000));
|
|
77
|
+
/** Whether the live bucket at `intervalMs` depends on the venue, so a writer must pass it (a custom width always does). */
|
|
78
|
+
export function liveBucketReadsVenue(intervalMs) {
|
|
79
|
+
return !isRthBucketExactIntervalMs(intervalMs) || TYPED_INTRADAY_MS.has(intervalMs);
|
|
80
|
+
}
|
|
60
81
|
/** A formula's lattice: a profile, null for a formula off every lattice, undefined for a plain expression. */
|
|
61
82
|
const formulaLatticeByExpression = new Map();
|
|
62
83
|
const FORMULA_CACHE_MAX = 256;
|
|
@@ -115,7 +136,7 @@ export function plainBucketStartMs(tsMs, intervalMs) {
|
|
|
115
136
|
const months = calendarMonthsOfMs(intervalMs);
|
|
116
137
|
if (months !== null)
|
|
117
138
|
return calendarBarStartMs(tsMs, months);
|
|
118
|
-
return intervalMs === TimeIntervalConstant.week ? findMonday(tsMs) :
|
|
139
|
+
return intervalMs === TimeIntervalConstant.week ? findMonday(tsMs) : fixedGridFloorMs(tsMs, intervalMs);
|
|
119
140
|
}
|
|
120
141
|
/** The venue's lattice at an interval the gateway rolls it up on, else null. */
|
|
121
142
|
function venueLatticeAt(intervalMs, venue) {
|
|
@@ -161,8 +182,9 @@ function liveBucketGrid(intervalMs, venue) {
|
|
|
161
182
|
return 'utc-floor';
|
|
162
183
|
// The 30m bucket-exact widths share the UTC floor's lattice, not its bars: a session-gated chart holds a
|
|
163
184
|
// bar there only inside its session, so the grid asks the session every time (a lattice that coincides is
|
|
164
|
-
// no off-session drop).
|
|
165
|
-
const
|
|
185
|
+
// no off-session drop). A custom width under a day counts from the session open instead, so it is never exact.
|
|
186
|
+
const typed = !venue.lengthRow && TYPED_INTRADAY_MS.has(intervalMs);
|
|
187
|
+
const exact = !typed && isRthBucketExactIntervalMs(intervalMs);
|
|
166
188
|
// The equities grids below also serve a stock's daily-and-longer bars, which the intraday chart kind never names.
|
|
167
189
|
if (chartRegularSessionKind(venue.exchange, venue.symbol, venue.sessionType, intervalMs) === 'cme') {
|
|
168
190
|
return exact ? 'rth-floor' : 'rth-anchored';
|
|
@@ -170,17 +192,22 @@ function liveBucketGrid(intervalMs, venue) {
|
|
|
170
192
|
if (isEquityRegularSessionGated(venue.exchange, venue.sessionType, intervalMs)) {
|
|
171
193
|
if (exact)
|
|
172
194
|
return 'equity-floor';
|
|
173
|
-
if (isFootprintRthFoldTfMs(intervalMs))
|
|
195
|
+
if (typed || isFootprintRthFoldTfMs(intervalMs))
|
|
174
196
|
return 'equity-anchored';
|
|
175
197
|
if (intervalMs === THREE_DAYS_MS)
|
|
176
198
|
return 'equity-session-group';
|
|
177
199
|
}
|
|
200
|
+
// A custom width on the other session markets the app builds it on (typed-width-grid.util `typedGridKind`: CME full
|
|
201
|
+
// session, forex, a stock with extended hours on, a US option) rides the lazy grid through the slot.
|
|
202
|
+
const ex = venue.exchange;
|
|
203
|
+
if (typed && (sessionLatticeOf(ex) || checkIsPolygon(ex) || getMarketKind(ex) === 'options'))
|
|
204
|
+
return 'typed-session';
|
|
178
205
|
if (!exact && venueLatticeAt(intervalMs, venue) !== null)
|
|
179
206
|
return 'session-lattice';
|
|
180
207
|
return 'utc-floor';
|
|
181
208
|
}
|
|
182
|
-
/** The UTC floor of `tsMs`, the 30m bucket-exact grids' lattice. */
|
|
183
|
-
const utcFloorMs = (tsMs, intervalMs) =>
|
|
209
|
+
/** The UTC floor of `tsMs`, the 30m bucket-exact grids' lattice; a typed day or week length's anchored floor. */
|
|
210
|
+
const utcFloorMs = (tsMs, intervalMs) => fixedGridFloorMs(tsMs, intervalMs);
|
|
184
211
|
/** A chart-RTH bucket starting at `startMs` exists only while the product trades by its schedule (an RTH window
|
|
185
212
|
* is a wall-clock filter with bounds on every calendar day; ES holds no Saturday bar, an always-on root does). */
|
|
186
213
|
function rthBucketOrNull(symbol, startMs) {
|
|
@@ -212,6 +239,8 @@ function bucketStartOnGrid(grid, tsMs, intervalMs, venue) {
|
|
|
212
239
|
}
|
|
213
240
|
case 'equity-session-group':
|
|
214
241
|
return usEquitySessionGridBucketStartMs(tsMs);
|
|
242
|
+
case 'typed-session':
|
|
243
|
+
return typedSessionGrid.startMs?.(tsMs, intervalMs, venue) ?? null;
|
|
215
244
|
default:
|
|
216
245
|
return utcFloorMs(tsMs, intervalMs);
|
|
217
246
|
}
|
|
@@ -231,9 +260,13 @@ export function liveBucketBarsAreLabels(intervalMs, venue) {
|
|
|
231
260
|
return grid === 'equity-session-group' || (grid === 'session-lattice' && intervalMs >= ONE_DAY_MS);
|
|
232
261
|
}
|
|
233
262
|
/**
|
|
234
|
-
* Whether the venue's bars at `intervalMs` open on
|
|
235
|
-
*
|
|
236
|
-
*
|
|
263
|
+
* Whether the venue's bars at `intervalMs` open on one fixed lattice of the interval, every bar one length after the
|
|
264
|
+
* last with one phase: the UTC floor, `findMonday`, a session's 30m and finer floor, and a typed day or week length's
|
|
265
|
+
* grid from Monday 2000-01-03 (`fixedGridFloorMs`), which is fixed but not epoch-aligned. Its one reader
|
|
266
|
+
* (wrun-source-rows `wrunChartRowsOffIntervalGrid`) counts phases of the interval, which a fixed lattice of any
|
|
267
|
+
* origin passes with one. False on a session lattice, where bars follow the trading calendar: anchored at the
|
|
268
|
+
* session's open (a stock or a chart-RTH product from 45m to 12h, a session-lattice venue) or labels
|
|
269
|
+
* (`liveBucketBarsAreLabels`).
|
|
237
270
|
*/
|
|
238
271
|
export function liveBucketBarsOnUtcLattice(intervalMs, venue) {
|
|
239
272
|
const grid = liveBucketGrid(intervalMs, venue);
|
|
@@ -27,6 +27,54 @@
|
|
|
27
27
|
*/
|
|
28
28
|
import { type RthWindow, type SessionDayWindow } from './rth-session.util.js';
|
|
29
29
|
export type MarketSessionKind = 'cme' | 'us-equity';
|
|
30
|
+
/**
|
|
31
|
+
* The day-and-longer widths whose US stock tape order flow (VOLUME_PROFILE_AGG) the gateway serves under the regular
|
|
32
|
+
* session, by label: its tradfi profile family reads DAY, WEEK and the calendar widths per trading session, and refuses
|
|
33
|
+
* THREE_DAYS (tsdb-gateway volume_profile_tradfi.go `tradfiVPProfile`). Every day-plus label the app offers has a row
|
|
34
|
+
* (tests/utility/chart/order-flow-session.interval-rule.spec.ts).
|
|
35
|
+
*/
|
|
36
|
+
export declare const US_EQUITY_DAY_PLUS_REGULAR_ORDER_FLOW: Readonly<Record<string, boolean>>;
|
|
37
|
+
/** Whether a US stock's order flow can be read under the regular session at `tfMs` (milliseconds): every intraday width, and the day-plus rows the gateway serves. */
|
|
38
|
+
export declare function isUsEquityRegularOrderFlowIntervalMs(tfMs: unknown): boolean;
|
|
39
|
+
/** A day or longer bar starts at midnight, outside every session, so its key cannot judge a trade: a session filter there reads each trade's own instant. */
|
|
40
|
+
export declare function sessionFilterJudgesTradeInstant(tfMs: unknown): boolean;
|
|
41
|
+
/** The fields of an order-flow read that pick the gateway reader: its market and its unit (`currency`, 'USD' or coins). */
|
|
42
|
+
export interface OrderFlowReadLike {
|
|
43
|
+
exchange?: unknown;
|
|
44
|
+
symbol?: unknown;
|
|
45
|
+
currency?: unknown;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Whether the gateway reads this stock order flow per trading session at `tfMs` (a day-plus chart width or span rung),
|
|
49
|
+
* so a REGULAR read keeps its midnight-stamped rows. tsdb-gateway `tradfiVPProfile` serves only a stock tape
|
|
50
|
+
* (kiyotaka-go venue `ProfileFor`), at DAY, WEEK and the calendar widths (`US_EQUITY_DAY_PLUS_REGULAR_ORDER_FLOW`), and
|
|
51
|
+
* excludes a USD-normalized read, a coin sum and a custom time range; no session-active VP read sends the last two.
|
|
52
|
+
* Anywhere else the fallback keeps a REGULAR bucket by its start, so every day row would be dropped.
|
|
53
|
+
*/
|
|
54
|
+
export declare function readsUsEquitySessionPerTradingDay(read: OrderFlowReadLike | null | undefined, tfMs: unknown): boolean;
|
|
55
|
+
/** Whether a stock order-flow read at `readTfMs` can be held to the regular session: by bucket start below a day, else per trading session. */
|
|
56
|
+
export declare function isUsEquityRegularOrderFlowRead(read: OrderFlowReadLike | null | undefined, readTfMs: unknown): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* The wire width of a session-filtered order-flow read at `tfMs` (the chart width, or a fixed or developing profile's
|
|
59
|
+
* span rung) on a chart of `chartTfMs` (the read's own width when it is the chart's): the width itself where the
|
|
60
|
+
* gateway reads it per trading session AND the chart is day-plus, else the at-most-15m effective width (rth-session.util
|
|
61
|
+
* `rthEffectiveFetchTfMs`, on whose grid the opens and closes sit). A day row is stamped at midnight, so on an intraday
|
|
62
|
+
* chart it would lose a box's intraday edges: there a rung reads exactly as before the day-plus rule. The one width
|
|
63
|
+
* every fetch, row grid, live fold and cache identity of a session-active profile reads, so they cannot disagree.
|
|
64
|
+
*/
|
|
65
|
+
export declare function regularSessionReadTfMs(tfMs: number, read: OrderFlowReadLike | null | undefined, chartTfMs?: unknown): number;
|
|
66
|
+
/**
|
|
67
|
+
* Whether an overlay that reads at its own width `readTfMs` (a fixed or developing profile's span rung, or its live
|
|
68
|
+
* fold grid) is session-active on a chart of `chartTfMs`. Below a day the chart decides, exactly as before the day-plus
|
|
69
|
+
* rule; from a day up the read itself must be holdable to the regular session (`isUsEquityRegularOrderFlowRead`): an
|
|
70
|
+
* intraday read, or a per-session one.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isMarketSessionReadActive(settings: Parameters<typeof isMarketSessionHoursActive>[0], chartTfMs: unknown, chartRegularKind: MarketSessionKind | null, readTfMs: unknown): boolean;
|
|
73
|
+
/** A span-rung profile's whole session read (FRVP, DSP): whether it is session-active, and the width its rows are read, gridded and folded at. */
|
|
74
|
+
export declare function rungSessionRead(settings: Parameters<typeof isMarketSessionHoursActive>[0], chartTfMs: number, chartRegularKind: MarketSessionKind | null, rungMs: number): {
|
|
75
|
+
active: boolean;
|
|
76
|
+
readTfMs: number;
|
|
77
|
+
};
|
|
30
78
|
/**
|
|
31
79
|
* A US stock market: a Polygon listing code (marketKind.util `checkIsPolygon`: POLYGON, US_STOCKS, NYSE, NASDAQ,
|
|
32
80
|
* CBOE) or a stocks tape code (stocks-governed.util `isStocksTapeGoverned`: NYSE_TAPE, NYSE_ARCA_TAPE,
|
|
@@ -46,13 +94,14 @@ export declare function marketSessionKind(exchange: unknown, symbol: unknown): M
|
|
|
46
94
|
export declare function marketRegularWindow(exchange: unknown, symbol: unknown): Readonly<RthWindow> | null;
|
|
47
95
|
export declare function marketHasRegularWindow(exchange: unknown, symbol: unknown): boolean;
|
|
48
96
|
/**
|
|
49
|
-
* The regular session THIS chart draws at `chartTfMs` (milliseconds), for overlay purposes
|
|
50
|
-
* 'cme' exactly when rth-session.util `isChartRthActive(exchange, symbol, sessionType, chartTfMs)
|
|
97
|
+
* The regular session THIS chart draws at `chartTfMs` (milliseconds), for overlay purposes:
|
|
98
|
+
* 'cme' exactly when rth-session.util `isChartRthActive(exchange, symbol, sessionType, chartTfMs)` (intraday).
|
|
51
99
|
* 'us-equity' when the candles' own gate holds, us-equities-session.util
|
|
52
|
-
* `isEquityRegularSessionGated(exchange, sessionType, chartTfMs)` (
|
|
53
|
-
* an active 'extended'
|
|
54
|
-
*
|
|
55
|
-
*
|
|
100
|
+
* `isEquityRegularSessionGated(exchange, sessionType, chartTfMs)` (the candle fetch's REGULAR: a Polygon
|
|
101
|
+
* listing whose word is not an active 'extended', and every daily and longer bar), at a width its order
|
|
102
|
+
* flow can follow (`isUsEquityRegularOrderFlowIntervalMs`: 3D cannot). A chart opened on a tape venue
|
|
103
|
+
* (NASDAQ_TAPE) has no candle session handling, so it answers null, as it rides today.
|
|
104
|
+
* null otherwise: an ETH or extended intraday chart, a CME daily chart, 3D, a label instead of milliseconds.
|
|
56
105
|
*/
|
|
57
106
|
export declare function chartRegularSessionKind(exchange: unknown, symbol: unknown, sessionType: unknown, chartTfMs: unknown): MarketSessionKind | null;
|
|
58
107
|
/**
|
|
@@ -71,16 +120,19 @@ export declare function chartRegularKindFromCacheBag(bag: Readonly<Record<string
|
|
|
71
120
|
* CME exactly rth-session.util `isRthSessionHoursActive(settings, chartTfMs, chartRegularKind === 'cme')`:
|
|
72
121
|
* an explicit 'rth' stays active on any chart (a stock, crypto or ETH chart included), 'eth' never
|
|
73
122
|
* is, and the 'chart' default follows a CME RTH chart only.
|
|
74
|
-
* US stock active exactly while the chart draws the US equities regular session
|
|
75
|
-
*
|
|
76
|
-
*
|
|
123
|
+
* US stock active exactly while the chart draws the US equities regular session and the overlay's read can be held
|
|
124
|
+
* to it (`isUsEquityRegularOrderFlowRead` at `readTfMs`: any intraday read; from a day up only a stock
|
|
125
|
+
* tape in coins, read per trading session; a USD or listing-code read at 1D keeps all hours, as 3D does).
|
|
126
|
+
* Stock overlays always follow the chart:
|
|
127
|
+
* their session row is hidden, so a persisted 'rth' or 'eth' carried over from a futures chart is ignored.
|
|
77
128
|
* any other never active (no window to filter on).
|
|
78
129
|
*/
|
|
79
130
|
export declare function isMarketSessionHoursActive(settings: {
|
|
80
131
|
sessionHours?: unknown;
|
|
81
132
|
symbol?: unknown;
|
|
82
133
|
exchange?: unknown;
|
|
83
|
-
|
|
134
|
+
currency?: unknown;
|
|
135
|
+
} | null | undefined, chartTfMs: unknown, chartRegularKind: MarketSessionKind | null, readTfMs?: unknown): boolean;
|
|
84
136
|
/**
|
|
85
137
|
* `isWithinRthWindow`: whether `tsMs` sits in the market's `[open, close)` session. Fails OPEN with no window (a
|
|
86
138
|
* market without a regular session keeps every row), false for a non-finite instant on a market with one.
|
|
@@ -25,10 +25,84 @@
|
|
|
25
25
|
*
|
|
26
26
|
* Worker-safe: no Vue, store or i18n imports (workers and the live-feed gates call these per row and per frame).
|
|
27
27
|
*/
|
|
28
|
-
import { footprintFoldBucketEndMs, getRthWindowForSymbol, hasRthWindow, isChartRthActive, isIntradayIntervalMs, isRthSessionHoursActive, isWithinRthWindow, latestRthSessionBoundsAtOrBefore, rthAnchoredBucketEndMs, rthAnchoredBucketStartMs, rthBucketOverlapsSessionMs, rthSessionCloseMs, rthSessionOpenMs, rthWindowsInRange, sessionDayBoundsFor, } from './rth-session.util.js';
|
|
28
|
+
import { footprintFoldBucketEndMs, getRthWindowForSymbol, hasRthWindow, isChartRthActive, isIntradayIntervalMs, isRthSessionHoursActive, isWithinRthWindow, latestRthSessionBoundsAtOrBefore, rthAnchoredBucketEndMs, rthAnchoredBucketStartMs, rthBucketOverlapsSessionMs, rthEffectiveFetchTfMs, rthSessionCloseMs, rthSessionOpenMs, rthWindowsInRange, sessionDayBoundsFor, } from './rth-session.util.js';
|
|
29
29
|
import { isEquityRegularSessionGated, US_EQUITIES_REGULAR_WINDOW, usEquityRegularWindowsInRange, } from './us-equities-session.util.js';
|
|
30
30
|
import { checkIsPolygon } from './marketKind.util.js';
|
|
31
|
+
import { intervalLabelForMs } from './interval-registry.util.js';
|
|
31
32
|
import { isStocksTapeGoverned } from '../v2/stocks-governed.util.js';
|
|
33
|
+
/**
|
|
34
|
+
* The day-and-longer widths whose US stock tape order flow (VOLUME_PROFILE_AGG) the gateway serves under the regular
|
|
35
|
+
* session, by label: its tradfi profile family reads DAY, WEEK and the calendar widths per trading session, and refuses
|
|
36
|
+
* THREE_DAYS (tsdb-gateway volume_profile_tradfi.go `tradfiVPProfile`). Every day-plus label the app offers has a row
|
|
37
|
+
* (tests/utility/chart/order-flow-session.interval-rule.spec.ts).
|
|
38
|
+
*/
|
|
39
|
+
export const US_EQUITY_DAY_PLUS_REGULAR_ORDER_FLOW = Object.freeze({
|
|
40
|
+
'1d': true,
|
|
41
|
+
'3d': false,
|
|
42
|
+
'1w': true,
|
|
43
|
+
'1M': true,
|
|
44
|
+
'3M': true,
|
|
45
|
+
'6M': true,
|
|
46
|
+
'1Y': true,
|
|
47
|
+
});
|
|
48
|
+
/** Whether a US stock's order flow can be read under the regular session at `tfMs` (milliseconds): every intraday width, and the day-plus rows the gateway serves. */
|
|
49
|
+
export function isUsEquityRegularOrderFlowIntervalMs(tfMs) {
|
|
50
|
+
if (isIntradayIntervalMs(tfMs))
|
|
51
|
+
return true;
|
|
52
|
+
if (typeof tfMs !== 'number' || !(tfMs > 0))
|
|
53
|
+
return false;
|
|
54
|
+
const label = intervalLabelForMs(tfMs);
|
|
55
|
+
return label !== undefined && US_EQUITY_DAY_PLUS_REGULAR_ORDER_FLOW[label] === true;
|
|
56
|
+
}
|
|
57
|
+
/** A day or longer bar starts at midnight, outside every session, so its key cannot judge a trade: a session filter there reads each trade's own instant. */
|
|
58
|
+
export function sessionFilterJudgesTradeInstant(tfMs) {
|
|
59
|
+
return typeof tfMs === 'number' && tfMs > 0 && !isIntradayIntervalMs(tfMs);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Whether the gateway reads this stock order flow per trading session at `tfMs` (a day-plus chart width or span rung),
|
|
63
|
+
* so a REGULAR read keeps its midnight-stamped rows. tsdb-gateway `tradfiVPProfile` serves only a stock tape
|
|
64
|
+
* (kiyotaka-go venue `ProfileFor`), at DAY, WEEK and the calendar widths (`US_EQUITY_DAY_PLUS_REGULAR_ORDER_FLOW`), and
|
|
65
|
+
* excludes a USD-normalized read, a coin sum and a custom time range; no session-active VP read sends the last two.
|
|
66
|
+
* Anywhere else the fallback keeps a REGULAR bucket by its start, so every day row would be dropped.
|
|
67
|
+
*/
|
|
68
|
+
export function readsUsEquitySessionPerTradingDay(read, tfMs) {
|
|
69
|
+
if (!read || !sessionFilterJudgesTradeInstant(tfMs) || !isUsEquityRegularOrderFlowIntervalMs(tfMs))
|
|
70
|
+
return false;
|
|
71
|
+
if (typeof read.exchange !== 'string' || !isStocksTapeGoverned(read.exchange))
|
|
72
|
+
return false;
|
|
73
|
+
return read.currency !== 'USD';
|
|
74
|
+
}
|
|
75
|
+
/** Whether a stock order-flow read at `readTfMs` can be held to the regular session: by bucket start below a day, else per trading session. */
|
|
76
|
+
export function isUsEquityRegularOrderFlowRead(read, readTfMs) {
|
|
77
|
+
return isIntradayIntervalMs(readTfMs) || readsUsEquitySessionPerTradingDay(read, readTfMs);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The wire width of a session-filtered order-flow read at `tfMs` (the chart width, or a fixed or developing profile's
|
|
81
|
+
* span rung) on a chart of `chartTfMs` (the read's own width when it is the chart's): the width itself where the
|
|
82
|
+
* gateway reads it per trading session AND the chart is day-plus, else the at-most-15m effective width (rth-session.util
|
|
83
|
+
* `rthEffectiveFetchTfMs`, on whose grid the opens and closes sit). A day row is stamped at midnight, so on an intraday
|
|
84
|
+
* chart it would lose a box's intraday edges: there a rung reads exactly as before the day-plus rule. The one width
|
|
85
|
+
* every fetch, row grid, live fold and cache identity of a session-active profile reads, so they cannot disagree.
|
|
86
|
+
*/
|
|
87
|
+
export function regularSessionReadTfMs(tfMs, read, chartTfMs = tfMs) {
|
|
88
|
+
return sessionFilterJudgesTradeInstant(chartTfMs) && readsUsEquitySessionPerTradingDay(read, tfMs)
|
|
89
|
+
? tfMs
|
|
90
|
+
: rthEffectiveFetchTfMs(tfMs);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Whether an overlay that reads at its own width `readTfMs` (a fixed or developing profile's span rung, or its live
|
|
94
|
+
* fold grid) is session-active on a chart of `chartTfMs`. Below a day the chart decides, exactly as before the day-plus
|
|
95
|
+
* rule; from a day up the read itself must be holdable to the regular session (`isUsEquityRegularOrderFlowRead`): an
|
|
96
|
+
* intraday read, or a per-session one.
|
|
97
|
+
*/
|
|
98
|
+
export function isMarketSessionReadActive(settings, chartTfMs, chartRegularKind, readTfMs) {
|
|
99
|
+
return isMarketSessionHoursActive(settings, chartTfMs, chartRegularKind, sessionFilterJudgesTradeInstant(chartTfMs) ? readTfMs : chartTfMs);
|
|
100
|
+
}
|
|
101
|
+
/** A span-rung profile's whole session read (FRVP, DSP): whether it is session-active, and the width its rows are read, gridded and folded at. */
|
|
102
|
+
export function rungSessionRead(settings, chartTfMs, chartRegularKind, rungMs) {
|
|
103
|
+
const active = isMarketSessionReadActive(settings, chartTfMs, chartRegularKind, rungMs);
|
|
104
|
+
return { active, readTfMs: active ? regularSessionReadTfMs(rungMs, settings, chartTfMs) : rungMs };
|
|
105
|
+
}
|
|
32
106
|
// ─── Markets and their regular session ───────────────────────────────────────
|
|
33
107
|
/**
|
|
34
108
|
* A US stock market: a Polygon listing code (marketKind.util `checkIsPolygon`: POLYGON, US_STOCKS, NYSE, NASDAQ,
|
|
@@ -85,18 +159,20 @@ export function marketHasRegularWindow(exchange, symbol) {
|
|
|
85
159
|
}
|
|
86
160
|
// ─── The chart's session and an overlay's ────────────────────────────────────
|
|
87
161
|
/**
|
|
88
|
-
* The regular session THIS chart draws at `chartTfMs` (milliseconds), for overlay purposes
|
|
89
|
-
* 'cme' exactly when rth-session.util `isChartRthActive(exchange, symbol, sessionType, chartTfMs)
|
|
162
|
+
* The regular session THIS chart draws at `chartTfMs` (milliseconds), for overlay purposes:
|
|
163
|
+
* 'cme' exactly when rth-session.util `isChartRthActive(exchange, symbol, sessionType, chartTfMs)` (intraday).
|
|
90
164
|
* 'us-equity' when the candles' own gate holds, us-equities-session.util
|
|
91
|
-
* `isEquityRegularSessionGated(exchange, sessionType, chartTfMs)` (
|
|
92
|
-
* an active 'extended'
|
|
93
|
-
*
|
|
94
|
-
*
|
|
165
|
+
* `isEquityRegularSessionGated(exchange, sessionType, chartTfMs)` (the candle fetch's REGULAR: a Polygon
|
|
166
|
+
* listing whose word is not an active 'extended', and every daily and longer bar), at a width its order
|
|
167
|
+
* flow can follow (`isUsEquityRegularOrderFlowIntervalMs`: 3D cannot). A chart opened on a tape venue
|
|
168
|
+
* (NASDAQ_TAPE) has no candle session handling, so it answers null, as it rides today.
|
|
169
|
+
* null otherwise: an ETH or extended intraday chart, a CME daily chart, 3D, a label instead of milliseconds.
|
|
95
170
|
*/
|
|
96
171
|
export function chartRegularSessionKind(exchange, symbol, sessionType, chartTfMs) {
|
|
97
172
|
if (isChartRthActive(exchange, symbol, sessionType, chartTfMs))
|
|
98
173
|
return 'cme';
|
|
99
|
-
if (
|
|
174
|
+
if (isUsEquityRegularOrderFlowIntervalMs(chartTfMs) &&
|
|
175
|
+
isEquityRegularSessionGated(exchange, sessionType, chartTfMs)) {
|
|
100
176
|
return 'us-equity';
|
|
101
177
|
}
|
|
102
178
|
return null;
|
|
@@ -121,19 +197,23 @@ bag) {
|
|
|
121
197
|
* CME exactly rth-session.util `isRthSessionHoursActive(settings, chartTfMs, chartRegularKind === 'cme')`:
|
|
122
198
|
* an explicit 'rth' stays active on any chart (a stock, crypto or ETH chart included), 'eth' never
|
|
123
199
|
* is, and the 'chart' default follows a CME RTH chart only.
|
|
124
|
-
* US stock active exactly while the chart draws the US equities regular session
|
|
125
|
-
*
|
|
126
|
-
*
|
|
200
|
+
* US stock active exactly while the chart draws the US equities regular session and the overlay's read can be held
|
|
201
|
+
* to it (`isUsEquityRegularOrderFlowRead` at `readTfMs`: any intraday read; from a day up only a stock
|
|
202
|
+
* tape in coins, read per trading session; a USD or listing-code read at 1D keeps all hours, as 3D does).
|
|
203
|
+
* Stock overlays always follow the chart:
|
|
204
|
+
* their session row is hidden, so a persisted 'rth' or 'eth' carried over from a futures chart is ignored.
|
|
127
205
|
* any other never active (no window to filter on).
|
|
128
206
|
*/
|
|
129
|
-
export function isMarketSessionHoursActive(settings, chartTfMs, chartRegularKind
|
|
207
|
+
export function isMarketSessionHoursActive(settings, chartTfMs, chartRegularKind,
|
|
208
|
+
// The width the overlay's rows are read at when it is not the chart's (a developing profile's intraday rung).
|
|
209
|
+
readTfMs = chartTfMs) {
|
|
130
210
|
if (!settings)
|
|
131
211
|
return false;
|
|
132
212
|
switch (marketSessionKind(settings.exchange, settings.symbol)) {
|
|
133
213
|
case 'cme':
|
|
134
214
|
return isRthSessionHoursActive(settings, chartTfMs, chartRegularKind === 'cme');
|
|
135
215
|
case 'us-equity':
|
|
136
|
-
return chartRegularKind === 'us-equity' &&
|
|
216
|
+
return chartRegularKind === 'us-equity' && isUsEquityRegularOrderFlowRead(settings, readTfMs);
|
|
137
217
|
default:
|
|
138
218
|
return false;
|
|
139
219
|
}
|
|
@@ -133,13 +133,7 @@ export declare function checkIsForexCommodityOrFutures(exchange: string | undefi
|
|
|
133
133
|
* bars. FE-internal code always sees the honest venue kind.
|
|
134
134
|
*/
|
|
135
135
|
export declare function toTitanMarketKind(kind: VenueMarketKind): MarketKind;
|
|
136
|
-
|
|
137
|
-
* True when TitanCharts must omit the dedicated 'volume' legend overlay:
|
|
138
|
-
* economic series, forex/commodity venues, the crypto indices and the
|
|
139
|
-
* quote-priced perpetual venues ship no per-bar volume. Governed CME futures
|
|
140
|
-
* DO ship contracts volume on TRADE_AGG bars, so they keep it.
|
|
141
|
-
*/
|
|
142
|
-
export declare function venueOmitsVolumeOverlay(exchange: string | undefined | null): boolean;
|
|
136
|
+
export declare function venueOmitsVolumeOverlay(exchange: string | undefined | null, symbol?: string | null): boolean;
|
|
143
137
|
export declare function checkIsDex(exchange: string | undefined | null): boolean;
|
|
144
138
|
/**
|
|
145
139
|
* Economic series venue: FRED, the ECONOMICS catalog venue and the observation
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MARKET_CAPABILITIES, ONCHAIN_POOL_CAPABILITIES, } from '../../constants/marketCapabilities.constants.js';
|
|
2
2
|
import { isBlkExchange } from '../blk-market.util.js';
|
|
3
|
-
import { ECONOMIC_EXCHANGES, FRED_EXCHANGE } from '../../constants/economic.constants.js';
|
|
3
|
+
import { ECONOMIC_EXCHANGES, FRED_EXCHANGE, PUBLISHER_ONLY_EXCHANGES } from '../../constants/economic.constants.js';
|
|
4
4
|
import { CRYPTO_INDEX_EXCHANGES } from './crypto-index.leaf.js';
|
|
5
5
|
import { QUOTE_PERP_EXCHANGES } from './quote-perp.leaf.js';
|
|
6
6
|
import { isCmeGoverned, normalizeExchangeCode } from './cme-realtime.util.js';
|
|
@@ -83,6 +83,8 @@ const EXCHANGE_TO_KIND = {
|
|
|
83
83
|
// Economic series: FRED plus the ECONOMICS catalog venue and the observation
|
|
84
84
|
// publishers (economic.constants.ts owns the list).
|
|
85
85
|
...Object.fromEntries(ECONOMIC_EXCHANGES.map((code) => [code, 'economic'])),
|
|
86
|
+
// A publisher with no market would otherwise default to a crypto venue with a book.
|
|
87
|
+
...Object.fromEntries([...PUBLISHER_ONLY_EXCHANGES].map((code) => [code, 'economic'])),
|
|
86
88
|
// Crypto-wide indices (CRYPTOCAP): value prints 24/7 with no trades,
|
|
87
89
|
// volume or book behind them (crypto-index.leaf owns the list).
|
|
88
90
|
...Object.fromEntries(CRYPTO_INDEX_EXCHANGES.map((code) => [code, 'cryptoIndex'])),
|
|
@@ -311,13 +313,9 @@ export function toTitanMarketKind(kind) {
|
|
|
311
313
|
return 'crypto';
|
|
312
314
|
return kind;
|
|
313
315
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
* quote-priced perpetual venues ship no per-bar volume. Governed CME futures
|
|
318
|
-
* DO ship contracts volume on TRADE_AGG bars, so they keep it.
|
|
319
|
-
*/
|
|
320
|
-
export function venueOmitsVolumeOverlay(exchange) {
|
|
316
|
+
export function venueOmitsVolumeOverlay(exchange, symbol) {
|
|
317
|
+
if (isOmTargetPane({ exchange, symbol }))
|
|
318
|
+
return true;
|
|
321
319
|
if (checkIsEconomic(exchange) || checkIsForexOrCommodity(exchange))
|
|
322
320
|
return true;
|
|
323
321
|
const kind = getMarketKind(exchange);
|
|
@@ -68,6 +68,23 @@ export interface BaseOhlcvPayload {
|
|
|
68
68
|
tailBoot?: boolean;
|
|
69
69
|
sided?: boolean;
|
|
70
70
|
category?: number;
|
|
71
|
+
typedFold?: TypedFoldAsk;
|
|
72
|
+
}
|
|
73
|
+
/** The fold a custom size the app builds asks of the worker: types only, so the boot path carries none of it. */
|
|
74
|
+
export interface TypedFoldAsk {
|
|
75
|
+
/** The served interval the rows are read at (typed-width-source.leaf). */
|
|
76
|
+
sourceLabel: string;
|
|
77
|
+
/** The most source rows one custom bar holds. */
|
|
78
|
+
rowsPerBar: number;
|
|
79
|
+
/** The custom size's length. */
|
|
80
|
+
widthMs: number;
|
|
81
|
+
/** The chart's market, which names its grid (typed-width-grid.util): the fields of live-bucket.util `LiveBucketVenue`. */
|
|
82
|
+
venue: {
|
|
83
|
+
exchange?: unknown;
|
|
84
|
+
symbol?: unknown;
|
|
85
|
+
sessionType?: unknown;
|
|
86
|
+
transformations?: unknown;
|
|
87
|
+
};
|
|
71
88
|
}
|
|
72
89
|
/**
|
|
73
90
|
* Payload for pure timestamp-mode fetching
|
|
@@ -2,7 +2,7 @@ import { Intervals } from '../../constants/interval.constants.js';
|
|
|
2
2
|
import { intervalLabelForMs } from './interval-ladder.util.js';
|
|
3
3
|
export const TARGET_EXCHANGE = 'OM';
|
|
4
4
|
export const OM_MAIN_CADENCES = [60, 300, 900, 1800, 3600, 14400, 86400, 604800];
|
|
5
|
-
const FEED_TARGET_SYMBOL = /^feed:(
|
|
5
|
+
const FEED_TARGET_SYMBOL = /^feed:([a-z0-9_-]+\/[a-z0-9][a-z0-9._-]{0,63})(?::([a-z][a-z0-9_]{0,23}))?$/;
|
|
6
6
|
function parseOmTargetSymbol(symbol) {
|
|
7
7
|
if (typeof symbol !== 'string')
|
|
8
8
|
return null;
|
|
@@ -11,14 +11,16 @@ function parseOmTargetSymbol(symbol) {
|
|
|
11
11
|
if (symbol.startsWith('panel:'))
|
|
12
12
|
return { kind: 'panel', id: symbol.slice('panel:'.length) };
|
|
13
13
|
const feed = FEED_TARGET_SYMBOL.exec(symbol);
|
|
14
|
-
return feed ? { kind: 'feed', address: feed[1]
|
|
14
|
+
return feed ? { kind: 'feed', address: `@${feed[1]}`, column: feed[2] ?? '' } : null;
|
|
15
15
|
}
|
|
16
16
|
export function parseOmTarget(metadata) {
|
|
17
17
|
return metadata?.exchange === TARGET_EXCHANGE ? parseOmTargetSymbol(metadata?.symbol) : null;
|
|
18
18
|
}
|
|
19
19
|
export function omTargetSymbol(target) {
|
|
20
|
-
if (target.kind === 'feed')
|
|
21
|
-
|
|
20
|
+
if (target.kind === 'feed') {
|
|
21
|
+
const path = target.address.replace(/^@/, '');
|
|
22
|
+
return target.column ? `feed:${path}:${target.column}` : `feed:${path}`;
|
|
23
|
+
}
|
|
22
24
|
return `${target.kind}:${target.id}`;
|
|
23
25
|
}
|
|
24
26
|
export function isOmTargetSymbol(symbol) {
|
|
@@ -28,13 +28,27 @@ export declare function resolvePriceDisplayPrecision(exchange: string | undefine
|
|
|
28
28
|
export declare function pricePrecisionFromStep(step: number | undefined | null, mode?: 'axis' | 'step'): number;
|
|
29
29
|
/**
|
|
30
30
|
* The decimals the chart's MAIN price scale prints at (axis ticks, crosshair
|
|
31
|
-
* pill, last-price pill, legend). An engine that
|
|
32
|
-
* steps that axis on tick multiples and rounds the
|
|
33
|
-
* the tick's own decimals are exact (ES 2, YM 0,
|
|
34
|
-
* extra decimal would only print dust ("7784.250").
|
|
35
|
-
*
|
|
31
|
+
* pill, last-price pill, legend) at Value Precision "Default". An engine that
|
|
32
|
+
* holds the instrument tick steps that axis on tick multiples and rounds the
|
|
33
|
+
* crosshair to the tick, so the tick's own decimals are exact (ES 2, YM 0,
|
|
34
|
+
* ZN 6) and the axis look's extra decimal would only print dust ("7784.250").
|
|
35
|
+
*
|
|
36
|
+
* Without an engine tick, the one market decimals resolver
|
|
37
|
+
* (market-price-text.util) answers in two parts, and only a TICK may lower the
|
|
38
|
+
* chart below its axis-step rule:
|
|
39
|
+
* - `tickDecimals`, a real tick's decimals (a crypto venue tick, a CME tick
|
|
40
|
+
* the engine does not hold): they decide, so BINANCE_FUTURES BTCUSDT (tick
|
|
41
|
+
* 0.1) reads 73686.1 on the legend, not 73686.10. The engine does not step
|
|
42
|
+
* this axis on that tick, so a step finer than it (a deep zoom) keeps the
|
|
43
|
+
* decimals the step itself needs, and neighbouring labels never collide;
|
|
44
|
+
* - `observedDecimals`, the most decimals the market's traded prices carried
|
|
45
|
+
* this session: they may only RAISE the axis-step rule. They can under-read
|
|
46
|
+
* (a first price at 73741.50 says 1 of a market that trades in cents), and
|
|
47
|
+
* the legend must never drop a digit of a real close.
|
|
48
|
+
* With neither, the axis-step rule stands. HIP-4's display decimals win every
|
|
49
|
+
* time.
|
|
36
50
|
*/
|
|
37
|
-
export declare function resolveChartPricePrecision(exchange: string | undefined | null, axisStep: number | undefined | null, priceTick: number | undefined | null): number;
|
|
51
|
+
export declare function resolveChartPricePrecision(exchange: string | undefined | null, axisStep: number | undefined | null, priceTick: number | undefined | null, tickDecimals?: number | null, observedDecimals?: number | null): number;
|
|
38
52
|
/** Profile levels use the resolved prediction grid; pending grids use venue display precision. */
|
|
39
53
|
export declare function resolveProfilePricePrecision(exchange: string | undefined | null, blockSize: number | undefined | null, fallbackDigits?: number): number;
|
|
40
54
|
export { formatPriceByMagnitude } from '../number-format.util.js';
|
|
@@ -46,17 +46,44 @@ export function pricePrecisionFromStep(step, mode = 'axis') {
|
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* The decimals the chart's MAIN price scale prints at (axis ticks, crosshair
|
|
49
|
-
* pill, last-price pill, legend). An engine that
|
|
50
|
-
* steps that axis on tick multiples and rounds the
|
|
51
|
-
* the tick's own decimals are exact (ES 2, YM 0,
|
|
52
|
-
* extra decimal would only print dust ("7784.250").
|
|
53
|
-
*
|
|
49
|
+
* pill, last-price pill, legend) at Value Precision "Default". An engine that
|
|
50
|
+
* holds the instrument tick steps that axis on tick multiples and rounds the
|
|
51
|
+
* crosshair to the tick, so the tick's own decimals are exact (ES 2, YM 0,
|
|
52
|
+
* ZN 6) and the axis look's extra decimal would only print dust ("7784.250").
|
|
53
|
+
*
|
|
54
|
+
* Without an engine tick, the one market decimals resolver
|
|
55
|
+
* (market-price-text.util) answers in two parts, and only a TICK may lower the
|
|
56
|
+
* chart below its axis-step rule:
|
|
57
|
+
* - `tickDecimals`, a real tick's decimals (a crypto venue tick, a CME tick
|
|
58
|
+
* the engine does not hold): they decide, so BINANCE_FUTURES BTCUSDT (tick
|
|
59
|
+
* 0.1) reads 73686.1 on the legend, not 73686.10. The engine does not step
|
|
60
|
+
* this axis on that tick, so a step finer than it (a deep zoom) keeps the
|
|
61
|
+
* decimals the step itself needs, and neighbouring labels never collide;
|
|
62
|
+
* - `observedDecimals`, the most decimals the market's traded prices carried
|
|
63
|
+
* this session: they may only RAISE the axis-step rule. They can under-read
|
|
64
|
+
* (a first price at 73741.50 says 1 of a market that trades in cents), and
|
|
65
|
+
* the legend must never drop a digit of a real close.
|
|
66
|
+
* With neither, the axis-step rule stands. HIP-4's display decimals win every
|
|
67
|
+
* time.
|
|
54
68
|
*/
|
|
55
|
-
export function resolveChartPricePrecision(exchange, axisStep, priceTick) {
|
|
69
|
+
export function resolveChartPricePrecision(exchange, axisStep, priceTick, tickDecimals, observedDecimals) {
|
|
56
70
|
const hasTick = typeof priceTick === 'number' && Number.isFinite(priceTick) && priceTick > 0;
|
|
57
|
-
const
|
|
71
|
+
const tick = wholeDecimals(tickDecimals);
|
|
72
|
+
const venueDecimals = hasTick
|
|
73
|
+
? pricePrecisionFromStep(priceTick, 'step')
|
|
74
|
+
: tick !== null
|
|
75
|
+
? Math.max(tick, stepDecimals(axisStep))
|
|
76
|
+
: Math.max(wholeDecimals(observedDecimals) ?? 0, pricePrecisionFromStep(axisStep));
|
|
58
77
|
return resolvePriceDisplayPrecision(exchange, venueDecimals);
|
|
59
78
|
}
|
|
79
|
+
/** A decimals count the axis can print (0 to 10), else null. */
|
|
80
|
+
function wholeDecimals(decimals) {
|
|
81
|
+
return typeof decimals === 'number' && Number.isInteger(decimals) && decimals >= 0 ? Math.min(decimals, 10) : null;
|
|
82
|
+
}
|
|
83
|
+
/** The decimals an axis step needs to print distinct labels (none for a missing step). */
|
|
84
|
+
function stepDecimals(step) {
|
|
85
|
+
return typeof step === 'number' && Number.isFinite(step) && step > 0 ? pricePrecisionFromStep(step, 'step') : 0;
|
|
86
|
+
}
|
|
60
87
|
/** Profile levels use the resolved prediction grid; pending grids use venue display precision. */
|
|
61
88
|
export function resolveProfilePricePrecision(exchange, blockSize, fallbackDigits = 2) {
|
|
62
89
|
if (!isPredictionExchangeName(exchange))
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A live volume-profile frame's stamp is the exclusive END of its fold window (seconds plus fixed32 nanoseconds). The
|
|
3
|
+
* one reader of that stamp for the footprint's live store and the wrun intake's session check, so a frame closing on
|
|
4
|
+
* the session's edge is judged by an instant inside its own window on both.
|
|
5
|
+
*/
|
|
6
|
+
export interface ProfileFrameStampLike {
|
|
7
|
+
timestamp?: {
|
|
8
|
+
seconds?: unknown;
|
|
9
|
+
nanoseconds?: unknown;
|
|
10
|
+
} | null;
|
|
11
|
+
}
|
|
12
|
+
/** The END of a frame's fold window, epoch ms (absent fixed32 nanoseconds read as 0); null when unstamped. */
|
|
13
|
+
export declare function profileFrameWindowEndMs(aggregation: ProfileFrameStampLike | null | undefined): number | null;
|
|
14
|
+
/** The last instant inside a frame's window (its end minus 1 ms): a window closing on a boundary belongs before it. */
|
|
15
|
+
export declare function profileFrameLastInstantMs(aggregation: ProfileFrameStampLike | null | undefined): number | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The END of a frame's fold window, epoch ms (absent fixed32 nanoseconds read as 0); null when unstamped. */
|
|
2
|
+
export function profileFrameWindowEndMs(aggregation) {
|
|
3
|
+
const seconds = aggregation?.timestamp?.seconds;
|
|
4
|
+
if (seconds === undefined || seconds === null)
|
|
5
|
+
return null;
|
|
6
|
+
return Number(seconds) * 1000 + Math.floor((Number(aggregation?.timestamp?.nanoseconds ?? 0) || 0) / 1e6);
|
|
7
|
+
}
|
|
8
|
+
/** The last instant inside a frame's window (its end minus 1 ms): a window closing on a boundary belongs before it. */
|
|
9
|
+
export function profileFrameLastInstantMs(aggregation) {
|
|
10
|
+
const endMs = profileFrameWindowEndMs(aggregation);
|
|
11
|
+
return endMs === null ? null : endMs - 1;
|
|
12
|
+
}
|
|
@@ -162,7 +162,9 @@ export declare function isRthSessionHoursActive(settings: RthSessionSettingsLike
|
|
|
162
162
|
* finer tier and refuses a trading-hour plan at a rolled width ("trading
|
|
163
163
|
* hour sessions are not served at this interval"), and a 2m or 10m bucket
|
|
164
164
|
* would straddle the 16:15 close anyway. Every result is a natively served
|
|
165
|
-
* width (1m / 5m / 15m).
|
|
165
|
+
* width (1m / 5m / 15m). Width-only on purpose: a day-plus read that the
|
|
166
|
+
* gateway serves per trading session (a US stock tape) passes through
|
|
167
|
+
* market-session.util `regularSessionReadTfMs`, which knows the market.
|
|
166
168
|
*/
|
|
167
169
|
export declare function rthEffectiveFetchTfMs(chartTfMs: number): number;
|
|
168
170
|
/**
|
|
@@ -389,7 +389,9 @@ const RTH_EFFECTIVE_FETCH_MAX_TF_MS = Intervals.map_unit['15m'];
|
|
|
389
389
|
* finer tier and refuses a trading-hour plan at a rolled width ("trading
|
|
390
390
|
* hour sessions are not served at this interval"), and a 2m or 10m bucket
|
|
391
391
|
* would straddle the 16:15 close anyway. Every result is a natively served
|
|
392
|
-
* width (1m / 5m / 15m).
|
|
392
|
+
* width (1m / 5m / 15m). Width-only on purpose: a day-plus read that the
|
|
393
|
+
* gateway serves per trading session (a US stock tape) passes through
|
|
394
|
+
* market-session.util `regularSessionReadTfMs`, which knows the market.
|
|
393
395
|
*/
|
|
394
396
|
export function rthEffectiveFetchTfMs(chartTfMs) {
|
|
395
397
|
if (!Number.isFinite(chartTfMs) || chartTfMs <= 0)
|