@orangecharts/wrun-chart-host 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/constants/feature-flags.constants.d.ts +9 -0
- package/dist/constants/feature-flags.constants.js +67 -4
- package/dist/constants/governed-exchanges.constants.d.ts +12 -0
- package/dist/constants/governed-exchanges.constants.js +16 -0
- package/dist/constants/option-venues.constants.d.ts +2 -2
- package/dist/host-env.d.ts +1 -9
- package/dist/host-ports.types.d.ts +36 -7
- package/dist/index.d.ts +7 -1
- package/dist/index.js +7 -1
- package/dist/indicators/controls/tpo-session.util.d.ts +36 -13
- package/dist/indicators/controls/tpo-session.util.js +217 -236
- package/dist/interfaces/cancel-reason.interface.d.ts +1 -1
- package/dist/interfaces/cme-realtime.interface.d.ts +16 -9
- package/dist/interfaces/cme-realtime.interface.js +6 -3
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +1 -5
- package/dist/interfaces/prediction-market.interface.d.ts +7 -0
- package/dist/interfaces/stocks-realtime.interface.d.ts +57 -0
- package/dist/interfaces/stocks-realtime.interface.js +32 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +48 -117
- package/dist/kscript-data/controls/live-trades-merge.util.js +97 -207
- package/dist/market-data/billing.interface.d.ts +86 -12
- package/dist/market-data/billing.interface.js +23 -4
- package/dist/market-data/venue.d.ts +65 -2
- package/dist/market-data/venues/index.d.ts +135 -5
- package/dist/market-data/venues/index.js +2 -1
- package/dist/market-data/venues/opra.contract.copy.json +3 -2
- package/dist/market-data/venues/opra.d.ts +2 -2
- package/dist/market-data/venues/opra.js +5 -2
- package/dist/market-data/venues/stocks.contract.copy.json +64 -0
- package/dist/market-data/venues/stocks.d.ts +130 -0
- package/dist/market-data/venues/stocks.js +117 -0
- package/dist/settings-templates/footprint-rows.js +35 -2
- package/dist/settings-templates/form-rows.d.ts +2 -1
- package/dist/settings-templates/indicator-fields.js +34 -4
- package/dist/settings-templates/tool-rules.d.ts +12 -5
- package/dist/settings-templates/tool-rules.js +11 -5
- package/dist/settings-templates/tool-tables.generated.js +4 -0
- package/dist/utility/chart/cme-cache-context.util.d.ts +5 -3
- package/dist/utility/chart/cme-cache-context.util.js +10 -6
- package/dist/utility/chart/cme-realtime.util.js +10 -0
- package/dist/utility/chart/cme-user-scripts-gate.util.d.ts +83 -0
- package/dist/utility/chart/cme-user-scripts-gate.util.js +142 -0
- package/dist/utility/chart/effective-chart-session.util.d.ts +14 -0
- package/dist/utility/chart/effective-chart-session.util.js +39 -0
- package/dist/utility/chart/host-bar-placement.util.d.ts +28 -0
- package/dist/utility/chart/host-bar-placement.util.js +170 -30
- package/dist/utility/chart/index-host-tier.util.d.ts +3 -1
- package/dist/utility/chart/index-host-tier.util.js +7 -2
- package/dist/utility/chart/index-mode-admission.util.js +25 -11
- package/dist/utility/chart/kscript-apply-fingerprint.util.js +1 -1
- package/dist/utility/chart/kscript-live-coalesce.util.d.ts +6 -9
- package/dist/utility/chart/kscript-live-coalesce.util.js +8 -9
- package/dist/utility/chart/kscript-live-source-identity.util.d.ts +9 -0
- package/dist/utility/chart/kscript-live-source-identity.util.js +10 -1
- package/dist/utility/chart/kscript-provenance-keys.util.js +7 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +115 -21
- package/dist/utility/chart/kscript-venue-policy.util.js +194 -40
- package/dist/utility/chart/live-bucket.util.d.ts +24 -8
- package/dist/utility/chart/live-bucket.util.js +85 -27
- package/dist/utility/chart/market-sessions.util.d.ts +83 -0
- package/dist/utility/chart/market-sessions.util.js +220 -0
- package/dist/utility/chart/marketKind.util.js +5 -0
- package/dist/utility/chart/mixed-mode.util.d.ts +7 -0
- package/dist/utility/chart/mixed-mode.util.js +14 -0
- package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +11 -16
- package/dist/utility/chart/opra-user-scripts-gate.util.js +12 -28
- package/dist/utility/chart/rth-session.util.d.ts +9 -8
- package/dist/utility/chart/rth-session.util.js +23 -20
- package/dist/utility/chart/session-interval.util.d.ts +2 -1
- package/dist/utility/chart/session-interval.util.js +1 -3
- package/dist/utility/chart/trading-day.util.d.ts +17 -0
- package/dist/utility/chart/trading-day.util.js +59 -0
- package/dist/utility/chart/window-owner.leaf.d.ts +23 -2
- package/dist/utility/chart/window-owner.leaf.js +45 -3
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +33 -15
- package/dist/utility/chart/wrun-bar-session-facts.util.js +70 -20
- package/dist/utility/intl-locale.util.js +5 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
- package/dist/utility/v2/gate-plane.util.d.ts +12 -3
- package/dist/utility/v2/gate-plane.util.js +30 -4
- package/dist/utility/v2/gate-session-latch.util.js +1 -1
- package/dist/utility/v2/stocks-governed.util.d.ts +16 -0
- package/dist/utility/v2/stocks-governed.util.js +34 -0
- package/dist/utility/wrun/derived-roots.leaf.d.ts +13 -0
- package/dist/utility/wrun/derived-roots.leaf.js +27 -0
- package/dist/utility/wrun/derived-roots.util.d.ts +1 -9
- package/dist/utility/wrun/derived-roots.util.js +3 -23
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +4 -3
- package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +24 -3
- package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +46 -10
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +2 -0
- package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +63 -16
- package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +58 -14
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +34 -11
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +106 -30
- package/dist/utility/wrun/wrun-browser-sources.leaf.js +1 -2
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +7 -4
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +12 -8
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-color-settings.util.js +33 -0
- package/dist/utility/wrun/wrun-handles.util.d.ts +7 -3
- package/dist/utility/wrun/wrun-handles.util.js +9 -8
- package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +68 -0
- package/dist/utility/wrun/wrun-input-requirements.leaf.js +163 -7
- package/dist/utility/wrun/wrun-leg-close.util.d.ts +59 -23
- package/dist/utility/wrun/wrun-leg-close.util.js +186 -28
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +26 -12
- package/dist/utility/wrun/wrun-live-intake.util.js +219 -155
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +9 -5
- package/dist/utility/wrun/wrun-live-tick.util.js +130 -94
- package/dist/utility/wrun/wrun-market-facts.util.d.ts +13 -3
- package/dist/utility/wrun/wrun-market-facts.util.js +13 -3
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +20 -10
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +10 -5
- package/dist/utility/wrun/wrun-option-book-rows.util.d.ts +56 -0
- package/dist/utility/wrun/wrun-option-book-rows.util.js +96 -0
- package/dist/utility/wrun/wrun-option-views.util.d.ts +281 -20
- package/dist/utility/wrun/wrun-option-views.util.js +391 -50
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-options-chain.util.js +2 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +15 -2
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +13 -3
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +3 -1
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +60 -11
- package/dist/utility/wrun/wrun-overlay-run.util.js +529 -113
- package/dist/utility/wrun/wrun-panel-mount.util.js +51 -6
- package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +15 -2
- package/dist/utility/wrun/wrun-pin-spelling.util.js +27 -3
- package/dist/utility/wrun/wrun-refusal.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-refusal.util.js +22 -0
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +26 -0
- package/dist/utility/wrun/wrun-registry-errors.util.js +34 -0
- package/dist/utility/wrun/wrun-replay-lane.util.js +3 -2
- package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +20 -6
- package/dist/utility/wrun/wrun-run-interval-session.util.js +22 -7
- package/dist/utility/wrun/wrun-run-interval.util.d.ts +39 -7
- package/dist/utility/wrun/wrun-run-interval.util.js +49 -9
- package/dist/utility/wrun/wrun-socket-row-source.js +7 -2
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +29 -22
- package/dist/utility/wrun/wrun-source-rows.util.js +62 -41
- package/dist/utility/wrun/wrun-tape-per-order.util.js +1 -20
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +17 -9
- package/dist/utility/wrun/wrun-tape-source.util.js +20 -12
- package/dist/utility/wrun/wrun-volume-profile.util.js +37 -29
- package/dist/workers/constants/socket-slots.d.ts +91 -6
- package/dist/workers/constants/socket-slots.js +85 -6
- package/package.json +5 -5
- package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +0 -56
- package/dist/kscript-data/controls/live-trades-order-gate.util.js +0 -107
|
@@ -345,15 +345,19 @@ export declare function requestWrunOverlayLiveDrain(indicatorId: string): void;
|
|
|
345
345
|
* (`drainWrunLiveTick`) until it gets past the gate.
|
|
346
346
|
*/
|
|
347
347
|
export declare function rearmWrunLiveTickDrain(chartIndex: number, indicatorId: string): void;
|
|
348
|
+
export declare function holdWrunLiveTicks(on: boolean): void;
|
|
348
349
|
/** The next moment any pinned leg of the context closes (the earliest over
|
|
349
350
|
* the legs), null without legs: `floor(now / L) * L + L` for a fixed span,
|
|
350
351
|
* and for a WEEK leg the Monday-anchored week (`findMonday`, the main
|
|
351
352
|
* path's and the intake's week bucket), never the epoch week (a Thursday);
|
|
352
|
-
* a leg on the
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
353
|
+
* a leg on the chart's RTH grid closes where its RTH bar holding now does
|
|
354
|
+
* (`wrunLegBarCloseAt`: a 4h bar anchored at the 09:30 New York open, the
|
|
355
|
+
* session's stub at the 16:15 close, off the session the next session's
|
|
356
|
+
* first bar), a leg on the CME session lattice where its venue's bar
|
|
357
|
+
* holding now does (a 3d group at the next group's open), a leg on a US
|
|
358
|
+
* listing with the session (the daily at 16:00 New York), read once its
|
|
359
|
+
* venue's rows hold the whole candle (`wrunLegCloseSettleMs`: a stock's
|
|
360
|
+
* minutes after its close). */
|
|
357
361
|
export declare function wrunNextPinnedCloseTs(context: WrunOverlayLiveContext, nowMs: number): number | null;
|
|
358
362
|
/**
|
|
359
363
|
* One drain: fold the queue, take the gap marks, compare the closed candles,
|
|
@@ -216,12 +216,12 @@ import { withWrunOverlayExecutionMeasure } from './wrun-overlay-lifecycle.util.j
|
|
|
216
216
|
import { cutWrunReplayRows, cutWrunReplayRowsAfterApply } from './wrun-replay-rows.util.js';
|
|
217
217
|
import { healWrunOverlayIfIdle, requestWrunCasualtyRebuilds } from './wrun-overlay-recovery.util.js';
|
|
218
218
|
import { isWrunQuarantinedError, isWrunWorkerPoisonError, WrunIntegrationError, } from './wrun-registry-errors.util.js';
|
|
219
|
-
import { wrunLegBarCloseAt, wrunLegCandleClose, wrunLegCloseSettleMs, wrunLegCandleOpen, wrunPrimaryRowBounds, wrunPrimaryRowHoldingMs, wrunChartSession, } from './wrun-leg-close.util.js';
|
|
219
|
+
import { wrunLegBarCloseAt, wrunLegCandleClose, wrunLegCloseSettleMs, wrunLegCandleOpen, wrunLegRidesRth, wrunPrimaryRowBounds, wrunPrimaryRowHoldingMs, wrunChartSession, } from './wrun-leg-close.util.js';
|
|
220
220
|
import { wrunLiveReconcileMaySound } from './wrun-signal-sound-reasons.leaf.js';
|
|
221
221
|
import { wrunCanvasChildId, wrunCellRowsOf } from './wrun-canvases.util.js';
|
|
222
222
|
import { readWrunBatchedSections, wrunBatchedChildId, wrunSheetHasBatchedMarks } from './wrun-batched-marks.util.js';
|
|
223
223
|
import { isWrunStyleTargetHidden } from './wrun-color-settings.util.js';
|
|
224
|
-
import { buildWrunOverlayRunResult, closedLegCandles, forgetWrunOverlayCanvasState, openLegCandles, wrunLegReadsFormingOpen, wrunLegReadsLiveCandleOnly, cutWrunOddsLegRows, placeWrunResultTables, presentWrunIntegration, publishWrunRunHealth, publishWrunSessionCanvasNotices, recordWrunHostBuildMs, reseedWrunOverlayFromBuffers, wrunCanvasHostFillFor, wrunChartPriceDigits,
|
|
224
|
+
import { buildWrunOverlayRunResult, closedLegCandles, forgetWrunOverlayCanvasState, openLegCandles, wrunLegReadsFormingOpen, wrunLegReadsLiveCandleOnly, cutWrunOddsLegRows, placeWrunResultTables, presentWrunIntegration, publishWrunRunHealth, publishWrunSessionCanvasNotices, recordWrunHostBuildMs, reseedWrunOverlayFromBuffers, wrunCandleAskSource, wrunCanvasHostFillFor, wrunChartPriceDigits, wrunHostFillContextFor, wrunLegFetchType, wrunLegPayloadExtras, wrunIntegratedRowsView, wrunSessionCanvasFillOf, wrunSessionPinnedSheet, wrunSessionRespelledSheet, wrunResultMarketUnits, wrunSessionRunHealth, } from './wrun-overlay-run.util.js';
|
|
225
225
|
import { forgetWrunCanvasCache } from './wrun-canvas-cache.util.js';
|
|
226
226
|
import { wrunLegNativeRowsOption } from './wrun-pin-venues.util.js';
|
|
227
227
|
import { wrunSessionChartNamesOf } from './wrun-chart-context-names.util.js';
|
|
@@ -234,7 +234,7 @@ import { attachWrunRefusal, serializeWrunRefusal, wrunOverlayEditable, wrunRefus
|
|
|
234
234
|
import { noteWrunRunRetained, trimWrunRunDrawings } from './wrun-cap-notice.util.js';
|
|
235
235
|
import { evictWrunRetainedOutputRows, ringWrunRunRetained, trimWrunRetainedCanvasLanes, wrunRetainedCanvasSources, wrunStrategyOnRows, } from './wrun-run-retained.util.js';
|
|
236
236
|
import { projectWrunRefusal, retractWrunRefusal, wrunRefusalRetractionCount } from './wrun-refusal-surface.util.js';
|
|
237
|
-
import { advanceWrunInputCarry, buildWrunInputTailRows, planWrunPinnedWires, wrunDeclaredSourceLanes, wrunDemandedSourceClass, wrunFormingBucketStart, wrunAskWirePieces, wrunChartIntervalKeyOf, wrunPinnedLegTierMs, wrunSourceVerdictWhole, wrunLaneAcquisitionIntervalMs, wrunLegRowHostBar, wrunPinnedLegFetchSuffix, wrunTradeLegIntervals, wrunWireRowPieces, wrunChartCandleRows, wrunChartCandleRowsWithin, } from './wrun-source-rows.util.js';
|
|
237
|
+
import { advanceWrunInputCarry, buildWrunInputTailRows, planWrunPinnedWires, wrunDeclaredSourceLanes, wrunDemandedSourceClass, wrunFormingBucketStart, wrunAskWirePieces, wrunChartIntervalKeyOf, wrunPinnedLegTierMs, wrunSourceVerdictWhole, wrunLaneAcquisitionIntervalMs, wrunLegRowHostBar, wrunLegRowVenue, wrunPinnedLegFetchSuffix, wrunTradeLegIntervals, wrunWireRowPieces, wrunChartCandleRows, wrunChartCandleRowsWithin, } from './wrun-source-rows.util.js';
|
|
238
238
|
import { isWrunTradesLegLane, WRUN_TRADES_LANES, wrunTradesLegExtras } from './wrun-trades-lane.util.js';
|
|
239
239
|
import { drainWrunLiveIntake, dropWrunLiveQueuedBuckets, dropWrunLiveQueuedLegBuckets, enqueueWrunLiveFrame, markWrunLiveGap, noteWrunLiveIntakeEvent, setWrunLiveDrainRequester, takeWrunLiveGaps, wrunLaneAnswerCoversBucket, wrunLiveBucketTs, wrunLiveIntakeBacklogDue, wrunLiveIntakeStats, WRUN_LIVE_LANE_OF_SCRIPT_SOURCE, } from './wrun-live-intake.util.js';
|
|
240
240
|
import { stampWrunLiveFrameOpra } from './wrun-cloud-opra-stamp.util.js';
|
|
@@ -805,6 +805,10 @@ export function scheduleWrunOverlayLiveTick(chartIndex, indicatorId, matchedSour
|
|
|
805
805
|
export function requestWrunOverlayLiveDrain(indicatorId) {
|
|
806
806
|
registerWrunLiveTickSeams();
|
|
807
807
|
registerWrunLiveTickHostSeams();
|
|
808
|
+
// The settings oracle's freeze (holdWrunLiveTicks): the request, its heal and rebuild branches too, is dropped; the
|
|
809
|
+
// gap marks it woke for stay for the next drain.
|
|
810
|
+
if (wrunLiveHeld)
|
|
811
|
+
return;
|
|
808
812
|
const context = getWrunOverlayLiveContext(indicatorId);
|
|
809
813
|
if (!context)
|
|
810
814
|
return;
|
|
@@ -1034,6 +1038,9 @@ function nextWrunTickDelayMs(state) {
|
|
|
1034
1038
|
/** The overlay's cadence floor now (live-cadence.util decides): the adaptive/at-rest/hidden tiering
|
|
1035
1039
|
* over the interval-scaled floor. Non-finite: the hidden hold. */
|
|
1036
1040
|
function wrunLiveCadenceFloorMs(state, now) {
|
|
1041
|
+
// The settings oracle's freeze (holdWrunLiveTicks) holds every drain as on a hidden page, the Sounds tab's too.
|
|
1042
|
+
if (wrunLiveHeld)
|
|
1043
|
+
return Number.POSITIVE_INFINITY;
|
|
1037
1044
|
const lastPanAt = wrunChartHostEnv().chart.lastPanAt(state.chartIndex);
|
|
1038
1045
|
const hidden = wrunChartHostEnv().clock.pageHidden();
|
|
1039
1046
|
return resolveV2LiveEffectiveMinIntervalMs({
|
|
@@ -1208,6 +1215,22 @@ function snapWrunLiveTicksOnReturn() {
|
|
|
1208
1215
|
wrunChartHostEnv().diagnostics.debug('wrun-live-hidden-drain', { overlays: held, runs });
|
|
1209
1216
|
}
|
|
1210
1217
|
}
|
|
1218
|
+
// The settings oracle's freeze (window.__kiyoSettingsOracle.holdLive, through qa/settings-oracle-live-hold): while it
|
|
1219
|
+
// is on every drain holds as on a hidden page and a bare drain request is dropped, its gap marks kept. Nothing held is
|
|
1220
|
+
// replayed: the release resumes the normal cadence, the return snap on a visible page and, on a hidden one, each held
|
|
1221
|
+
// overlay re-armed on its own cadence (where the page's hidden pace holds, it holds again under that hold).
|
|
1222
|
+
let wrunLiveHeld = false;
|
|
1223
|
+
export function holdWrunLiveTicks(on) {
|
|
1224
|
+
if (on === wrunLiveHeld)
|
|
1225
|
+
return;
|
|
1226
|
+
wrunLiveHeld = on;
|
|
1227
|
+
if (on)
|
|
1228
|
+
return;
|
|
1229
|
+
if (wrunChartHostEnv().clock.pageHidden())
|
|
1230
|
+
releaseWrunLiveHiddenHolds();
|
|
1231
|
+
else
|
|
1232
|
+
snapWrunLiveTicksOnReturn();
|
|
1233
|
+
}
|
|
1211
1234
|
// The switch turned off (`__kiyoSetLiveHiddenPace(false)`): every held drain
|
|
1212
1235
|
// goes back to today's cadence at once (the 2 s floor while still hidden).
|
|
1213
1236
|
function releaseWrunLiveHiddenHolds() {
|
|
@@ -1275,12 +1298,19 @@ function dropWrunPinnedCloseTimer(indicatorId) {
|
|
|
1275
1298
|
* the legs), null without legs: `floor(now / L) * L + L` for a fixed span,
|
|
1276
1299
|
* and for a WEEK leg the Monday-anchored week (`findMonday`, the main
|
|
1277
1300
|
* path's and the intake's week bucket), never the epoch week (a Thursday);
|
|
1278
|
-
* a leg on the
|
|
1279
|
-
*
|
|
1280
|
-
*
|
|
1281
|
-
*
|
|
1282
|
-
*
|
|
1301
|
+
* a leg on the chart's RTH grid closes where its RTH bar holding now does
|
|
1302
|
+
* (`wrunLegBarCloseAt`: a 4h bar anchored at the 09:30 New York open, the
|
|
1303
|
+
* session's stub at the 16:15 close, off the session the next session's
|
|
1304
|
+
* first bar), a leg on the CME session lattice where its venue's bar
|
|
1305
|
+
* holding now does (a 3d group at the next group's open), a leg on a US
|
|
1306
|
+
* listing with the session (the daily at 16:00 New York), read once its
|
|
1307
|
+
* venue's rows hold the whole candle (`wrunLegCloseSettleMs`: a stock's
|
|
1308
|
+
* minutes after its close). */
|
|
1283
1309
|
export function wrunNextPinnedCloseTs(context, nowMs) {
|
|
1310
|
+
return wrunNextPinnedClose(context, nowMs)?.closeAtMs ?? null;
|
|
1311
|
+
}
|
|
1312
|
+
/** The pinned leg that closes first and its close (`wrunNextPinnedCloseTs`), null without legs. */
|
|
1313
|
+
function wrunNextPinnedClose(context, nowMs) {
|
|
1284
1314
|
let next = null;
|
|
1285
1315
|
for (const leg of context.pinnedLegs ?? []) {
|
|
1286
1316
|
// A grid leg closes with every chart bar (the roll and the lane
|
|
@@ -1288,23 +1318,43 @@ export function wrunNextPinnedCloseTs(context, nowMs) {
|
|
|
1288
1318
|
// close) arm the timer.
|
|
1289
1319
|
if (!(leg.legMs > 0) || leg.kind === 'grid')
|
|
1290
1320
|
continue;
|
|
1291
|
-
const
|
|
1292
|
-
if (next === null ||
|
|
1293
|
-
next =
|
|
1321
|
+
const closeAtMs = wrunPinnedLegCloseAt(leg, context, nowMs);
|
|
1322
|
+
if (next === null || closeAtMs < next.closeAtMs)
|
|
1323
|
+
next = { leg, closeAtMs };
|
|
1294
1324
|
}
|
|
1295
1325
|
return next;
|
|
1296
1326
|
}
|
|
1327
|
+
/** The `wrun-leg-close-planned` debug ring event (contract C4): the leg close a new `pinned-close` timer is
|
|
1328
|
+
* armed at, and whether the chart's RTH rule answered it (`anchored`: the leg rides the chart's RTH grid,
|
|
1329
|
+
* `wrunLegRidesRth`) rather than the CME lattice, a stock's session or the plain grid. */
|
|
1330
|
+
function noteWrunLegClosePlanned(context, planned) {
|
|
1331
|
+
const { diagnostics } = wrunChartHostEnv();
|
|
1332
|
+
if (!diagnostics.debugEnabled())
|
|
1333
|
+
return;
|
|
1334
|
+
const market = context.market;
|
|
1335
|
+
diagnostics.debug('wrun-leg-close-planned', {
|
|
1336
|
+
chartIndex: context.chartIndex,
|
|
1337
|
+
indicatorId: context.indicatorId,
|
|
1338
|
+
legMs: planned.leg.legMs,
|
|
1339
|
+
closeAtMs: planned.closeAtMs,
|
|
1340
|
+
anchored: wrunLegRidesRth(planned.leg, market?.exchange, market?.sessionType, market?.symbol, context.intervalMs),
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1297
1343
|
/** When the leg candle holding `atMs` reads settled: its close (`floor(at / L) * L + L` for a
|
|
1298
|
-
* fixed span, the Monday-anchored week for a WEEK leg, the
|
|
1299
|
-
* or a US listing's session close: `wrunLegBarCloseAt`, on
|
|
1300
|
-
* the
|
|
1301
|
-
*
|
|
1302
|
-
* the
|
|
1303
|
-
|
|
1344
|
+
* fixed span, the Monday-anchored week for a WEEK leg, the RTH bar on the chart's RTH grid, the
|
|
1345
|
+
* venue's bar on the CME session lattice or a US listing's session close: `wrunLegBarCloseAt`, on
|
|
1346
|
+
* the bars the session the chart rides keys: its session word, symbol and interval) plus the time
|
|
1347
|
+
* its venue's rows take to hold the whole candle (`wrunLegCloseSettleMs`: 0 but for a stock, read
|
|
1348
|
+
* on the chart's word as the listing's fetch reads it), so a candle still settling at `atMs`
|
|
1349
|
+
* answers its own moment. The pinned-close timer and the routine poll's coverage check read the
|
|
1350
|
+
* same moment; the cuts keep the close itself. */
|
|
1351
|
+
function wrunPinnedLegCloseAt(leg, context, atMs) {
|
|
1352
|
+
const { market } = context;
|
|
1304
1353
|
const settleMs = wrunLegCloseSettleMs(leg, market?.exchange, market?.sessionType);
|
|
1305
1354
|
const fromMs = atMs - settleMs;
|
|
1306
1355
|
const open = leg.legMs === Intervals.WEEK ? findMonday(fromMs) : Math.floor(fromMs / leg.legMs) * leg.legMs;
|
|
1307
|
-
|
|
1356
|
+
const closeMs = wrunLegBarCloseAt(leg, market?.exchange, fromMs, market?.sessionType, market?.symbol, context.intervalMs);
|
|
1357
|
+
return (closeMs ?? open + leg.legMs) + settleMs;
|
|
1308
1358
|
}
|
|
1309
1359
|
/**
|
|
1310
1360
|
* Whether a routine poll can leave a period leg alone (TEMPLATE-QA E40): its coverage already
|
|
@@ -1321,7 +1371,7 @@ function wrunPeriodLegSettled(context, leg, nowMs) {
|
|
|
1321
1371
|
if (!Number.isFinite(leg.coveredThroughTs))
|
|
1322
1372
|
return false;
|
|
1323
1373
|
const settledFrom = leg.coveredThroughTs - WRUN_LIVE_PINNED_CLOSE_GRACE_MS;
|
|
1324
|
-
return wrunPinnedLegCloseAt(leg, context
|
|
1374
|
+
return wrunPinnedLegCloseAt(leg, context, settledFrom) + WRUN_LIVE_PINNED_CLOSE_GRACE_MS > nowMs;
|
|
1325
1375
|
}
|
|
1326
1376
|
/**
|
|
1327
1377
|
* Arm (or keep) the overlay's `pinned-close` timer at the earliest leg's
|
|
@@ -1339,12 +1389,12 @@ function armWrunPinnedCloseTimer(context) {
|
|
|
1339
1389
|
const { indicatorId } = context;
|
|
1340
1390
|
// The legs close on the server's grid: the next close and the delay to it read the server clock.
|
|
1341
1391
|
const nowMs = serverNowMs();
|
|
1342
|
-
const
|
|
1343
|
-
if (
|
|
1392
|
+
const planned = wrunNextPinnedClose(context, nowMs);
|
|
1393
|
+
if (planned === null) {
|
|
1344
1394
|
dropWrunPinnedCloseTimer(indicatorId);
|
|
1345
1395
|
return;
|
|
1346
1396
|
}
|
|
1347
|
-
const dueAt =
|
|
1397
|
+
const dueAt = planned.closeAtMs + WRUN_LIVE_PINNED_CLOSE_GRACE_MS;
|
|
1348
1398
|
const armed = pinnedCloseTimers.get(indicatorId);
|
|
1349
1399
|
if (armed !== undefined) {
|
|
1350
1400
|
if (armed.dueAt <= dueAt)
|
|
@@ -1360,6 +1410,7 @@ function armWrunPinnedCloseTimer(context) {
|
|
|
1360
1410
|
markWrunLiveGap(indicatorId, 'pinned-close');
|
|
1361
1411
|
}, Math.max(0, dueAt - nowMs));
|
|
1362
1412
|
pinnedCloseTimers.set(indicatorId, { timer, dueAt });
|
|
1413
|
+
noteWrunLegClosePlanned(context, planned);
|
|
1363
1414
|
}
|
|
1364
1415
|
// ---------------------------------------------------------------------------
|
|
1365
1416
|
// The drain body.
|
|
@@ -2948,7 +2999,10 @@ function laneSourcesOf(context, ohlcvRows) {
|
|
|
2948
2999
|
// The session the run was computed under, as the full run and the reseed hand the builder: its
|
|
2949
3000
|
// session calendar answers at the tail clock's interval (the legs' candle closes and opens, the
|
|
2950
3001
|
// session rows' bounds).
|
|
2951
|
-
session: wrunChartSession(context.market?.exchange, context.market?.sessionType
|
|
3002
|
+
session: wrunChartSession(context.market?.exchange, context.market?.sessionType, {
|
|
3003
|
+
symbol: context.market?.symbol,
|
|
3004
|
+
interval: intervalMs,
|
|
3005
|
+
}),
|
|
2952
3006
|
// The market the session runs on, at the tail clock's interval: a new live bar reads its own
|
|
2953
3007
|
// `time.trade_date` / `time.session`, and a grid leg lands on its bar grid (`barGrid`).
|
|
2954
3008
|
venue: wrunBarVenueOf(context.market, intervalMs),
|
|
@@ -3125,7 +3179,12 @@ lastMainTs) {
|
|
|
3125
3179
|
? barEndMs(lastMainTs, leg.legMs) - 1
|
|
3126
3180
|
: lastMainTs;
|
|
3127
3181
|
const fetched = (leg.odds ? cutWrunOddsLegRows(outcome.value, oddsCutTs) : outcome.value);
|
|
3128
|
-
const legCloseMs = leg.kind === 'grid'
|
|
3182
|
+
const legCloseMs = leg.kind === 'grid'
|
|
3183
|
+
? undefined
|
|
3184
|
+
: wrunLegCandleClose(leg, context.market?.exchange, context.market?.sessionType, {
|
|
3185
|
+
symbol: context.market?.symbol,
|
|
3186
|
+
interval: context.intervalMs,
|
|
3187
|
+
});
|
|
3129
3188
|
// A leg a `candles` input reads with view "forming_open": the opens it showed before this
|
|
3130
3189
|
// answer, so a candle it shows anew can revise the committed rows the candle holds.
|
|
3131
3190
|
const shownBefore = formingOpenLegs.has(leg.fetchKey) ? wrunLegShownOpens(context, leg.fetchKey) : undefined;
|
|
@@ -3226,7 +3285,10 @@ function wrunFormingOpenRevisedFromTs(context, leg, before) {
|
|
|
3226
3285
|
if (intervalMs === 0)
|
|
3227
3286
|
return null;
|
|
3228
3287
|
const exchange = context.market?.exchange;
|
|
3229
|
-
const closeMs = wrunLegCandleClose(leg, exchange, context.market?.sessionType
|
|
3288
|
+
const closeMs = wrunLegCandleClose(leg, exchange, context.market?.sessionType, {
|
|
3289
|
+
symbol: context.market?.symbol,
|
|
3290
|
+
interval: context.intervalMs,
|
|
3291
|
+
});
|
|
3230
3292
|
const openMs = wrunLegCandleOpen(leg, exchange);
|
|
3231
3293
|
const after = wrunLegShownOpens(context, leg.fetchKey);
|
|
3232
3294
|
let earliest = Number.POSITIVE_INFINITY;
|
|
@@ -3247,7 +3309,7 @@ function wrunFormingOpenRevisedFromTs(context, leg, before) {
|
|
|
3247
3309
|
changed(stamp);
|
|
3248
3310
|
if (!Number.isFinite(earliest))
|
|
3249
3311
|
return null;
|
|
3250
|
-
const row = Math.max(context.firstRowTs, Math.min(wrunFormingBucketStart(earliest, intervalMs), wrunPrimaryRowHoldingMs(exchange, intervalMs, earliest) ?? Number.POSITIVE_INFINITY));
|
|
3312
|
+
const row = Math.max(context.firstRowTs, Math.min(wrunFormingBucketStart(earliest, intervalMs), wrunPrimaryRowHoldingMs(exchange, intervalMs, earliest, context.market) ?? Number.POSITIVE_INFINITY));
|
|
3251
3313
|
return row < context.lastRowTs ? row : null;
|
|
3252
3314
|
}
|
|
3253
3315
|
/** The fetch keys of the period legs every reading of which is a `candles` input's live candle
|
|
@@ -3457,14 +3519,15 @@ async function fetchWrunPollLaneReconcile(context, ledger, laneId, fromTs, toTs,
|
|
|
3457
3519
|
return askOnce(extras, askFromTs, askToTs);
|
|
3458
3520
|
}
|
|
3459
3521
|
/** A reconcile window's host bars, `[fromTs, toTs)`, on the session's bar grid (the chart's market: a
|
|
3460
|
-
* regular-session stock chart's 09:30-anchored bars, the UTC floor elsewhere)
|
|
3522
|
+
* regular-session stock chart's 09:30-anchored bars, the UTC floor elsewhere), at the server's now: the tier rule and
|
|
3523
|
+
* the add memo's final lag compare it with the gateway's bars (a device clock ahead would read a bar final early). */
|
|
3461
3524
|
function wrunReconcileHostGridWindow(context, fromTs, toTs) {
|
|
3462
3525
|
const barGrid = liveBucketVenueOf(context.market);
|
|
3463
3526
|
return {
|
|
3464
3527
|
barOpens: liveBucketStartsInRange(fromTs, toTs - 1, context.intervalMs, barGrid),
|
|
3465
3528
|
intervalMs: context.intervalMs,
|
|
3466
3529
|
barGrid,
|
|
3467
|
-
nowMs:
|
|
3530
|
+
nowMs: serverNowMs(),
|
|
3468
3531
|
};
|
|
3469
3532
|
}
|
|
3470
3533
|
/** A row lane instance's reconcile (`utility/wrun/sources/row-lane-registry.ts`): its lane's asks over the
|
|
@@ -3518,13 +3581,10 @@ async function fetchWrunRowLaneReconcile(context, ledger, laneId, fromTs, toTs,
|
|
|
3518
3581
|
whole?.(wrunSourceVerdictWhole(heard));
|
|
3519
3582
|
return answer;
|
|
3520
3583
|
}, {
|
|
3521
|
-
// One
|
|
3522
|
-
// add's
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
addMemo: { key: wrunRowLaneAddKey(context.chartIndex, context.indicatorId, laneId), role: 'live' },
|
|
3526
|
-
}
|
|
3527
|
-
: {}),
|
|
3584
|
+
// One record per add (wrun-row-lane-add-memo.util), whatever the budget: the live start and every reconcile reuse
|
|
3585
|
+
// the bars the add's reads landed whole and final, keep what a budgeted run cut partial, and ask only the rest (a
|
|
3586
|
+
// new bar, a bar still forming). A replay step's read keeps its own memo (`replayCursorMs`).
|
|
3587
|
+
addMemo: { key: wrunRowLaneAddKey(context.chartIndex, context.indicatorId, laneId), role: 'live' },
|
|
3528
3588
|
...(replay !== undefined ? { onUnconfirmed: replay.onUnconfirmed } : {}),
|
|
3529
3589
|
});
|
|
3530
3590
|
return rows;
|
|
@@ -3649,8 +3709,18 @@ async function fetchWrunReconcileLeg(context, ledger, leg, meta) {
|
|
|
3649
3709
|
// record that names none.
|
|
3650
3710
|
const native = leg.nativeRows === true ? { nativeRows: true } : wrunLegNativeRowsOption(leg, context.market?.exchange);
|
|
3651
3711
|
const fetchType = wrunLegFetchType(leg);
|
|
3712
|
+
// An own-market candle leg (intrabar, candles, the run bars) re-asks where the chart's rows came from, as runs do.
|
|
3713
|
+
const candleAsk = fetchType === 'ohlcv' && leg.market === undefined && leg.odds !== true
|
|
3714
|
+
? wrunCandleAskSource(wrunChartHostEnv().chart.chartStore().mergedAllCharts[context.chartIndex]?.metadata, meta.settings)
|
|
3715
|
+
: undefined;
|
|
3716
|
+
const candleSourceExtras = candleAsk?.source && !candleAsk.walled ? { candleSource: candleAsk.source } : undefined;
|
|
3652
3717
|
const ask = async (fromTs, toTs, options, onSourceVerdict) => {
|
|
3653
|
-
const fetched = await withWrunDeadline(wrunChartHostEnv().transport.fetchSource(context.chartIndex, fetchType, {
|
|
3718
|
+
const fetched = await withWrunDeadline(wrunChartHostEnv().transport.fetchSource(context.chartIndex, fetchType, {
|
|
3719
|
+
symbol: 'currentSymbol',
|
|
3720
|
+
exchange: 'currentExchange',
|
|
3721
|
+
...candleSourceExtras,
|
|
3722
|
+
...wrunLegPayloadExtras(leg),
|
|
3723
|
+
}, fromTs, toTs, meta, `${context.fetchKey}-live-${suffix}`, false, {
|
|
3654
3724
|
silentLegend: true,
|
|
3655
3725
|
...options,
|
|
3656
3726
|
...(onSourceVerdict !== undefined ? { onSourceVerdict } : {}),
|
|
@@ -3703,7 +3773,7 @@ function mergeWrunLegAnswer(context, leg, answer, askedAtMs) {
|
|
|
3703
3773
|
record.coveredThroughTs = Math.max(record.coveredThroughTs, askedAtMs);
|
|
3704
3774
|
if (leg.kind === 'grid' && leg.legMs > 0) {
|
|
3705
3775
|
// A grid leg's revised row revises the chart bar it lands in, once that bar is committed (before the forming row).
|
|
3706
|
-
const revisedBar = wrunLegRevisedBarTs(context, before, merged, leg.fromTs, leg.tierMs ?? leg.legMs, context.lastRowTs);
|
|
3776
|
+
const revisedBar = wrunLegRevisedBarTs(context, before, merged, leg.fromTs, leg.tierMs ?? leg.legMs, context.lastRowTs, wrunLegRowVenue(record?.market, liveBucketVenueOf(context.market)));
|
|
3707
3777
|
return { served, revisedFromTs: revisedBar === null ? null : Math.max(context.firstRowTs, revisedBar) };
|
|
3708
3778
|
}
|
|
3709
3779
|
const exchange = context.market?.exchange;
|
|
@@ -3718,12 +3788,17 @@ function mergeWrunLegAnswer(context, leg, answer, askedAtMs) {
|
|
|
3718
3788
|
// February). A leg whose venue closes its bars off open + L (a CME session
|
|
3719
3789
|
// bar) is judged by its own closes: the newest open among them that closed
|
|
3720
3790
|
// by then.
|
|
3721
|
-
const closeMs = leg.kind === 'grid'
|
|
3791
|
+
const closeMs = leg.kind === 'grid'
|
|
3792
|
+
? undefined
|
|
3793
|
+
: wrunLegCandleClose(leg, exchange, context.market?.sessionType, {
|
|
3794
|
+
symbol: context.market?.symbol,
|
|
3795
|
+
interval: context.intervalMs,
|
|
3796
|
+
});
|
|
3722
3797
|
const committedCloseMs = leg.kind === 'grid' || intervalMs === 0
|
|
3723
3798
|
? context.lastRowTs
|
|
3724
3799
|
: Math.min(context.lastRowTs, wrunChartHostEnv()
|
|
3725
3800
|
.sharedHost()
|
|
3726
|
-
.wrunLegRowBoundsMs(context.lastRowTs, intervalMs, wrunPrimaryRowBounds(exchange, intervalMs)).openMs);
|
|
3801
|
+
.wrunLegRowBoundsMs(context.lastRowTs, intervalMs, wrunPrimaryRowBounds(exchange, intervalMs, context.market)).openMs);
|
|
3727
3802
|
const committedBound = closeMs === undefined
|
|
3728
3803
|
? prevBarStartMs(committedCloseMs, leg.legMs)
|
|
3729
3804
|
: newestOpenClosedBy(merged, before, leg.legMs, closeMs, committedCloseMs);
|
|
@@ -3736,7 +3811,7 @@ function mergeWrunLegAnswer(context, leg, answer, askedAtMs) {
|
|
|
3736
3811
|
// (its close less P on a plain grid). On the CME lattice the row holding
|
|
3737
3812
|
// the instant (the calendar that labels the rows) can come first: a 3d row
|
|
3738
3813
|
// spanning a weekend, a fall-back Sunday bar an hour long.
|
|
3739
|
-
const holdingMs = (instantMs) => wrunPrimaryRowHoldingMs(exchange, intervalMs, instantMs) ?? Number.POSITIVE_INFINITY;
|
|
3814
|
+
const holdingMs = (instantMs) => wrunPrimaryRowHoldingMs(exchange, intervalMs, instantMs, context.market) ?? Number.POSITIVE_INFINITY;
|
|
3740
3815
|
const closeAtMs = wrunChartHostEnv().sharedHost().wrunLegCandleCloseMs(changed, leg.legMs, closeMs);
|
|
3741
3816
|
const revisedRow = leg.kind === 'intrabar' && intervalMs > 0
|
|
3742
3817
|
? Math.min(wrunFormingBucketStart(changed, intervalMs), holdingMs(changed))
|
|
@@ -3869,10 +3944,7 @@ servedStartMs) {
|
|
|
3869
3944
|
// OPENED before the served start (its open, not its key: a CME daily-class bucket's 00:00Z key
|
|
3870
3945
|
// runs ahead of its 17:00 Chicago open) is partial: the answer holds only its later prints, so
|
|
3871
3946
|
// it is dropped from the answer and read like a bucket before the horizon (the fed row stands,
|
|
3872
|
-
// never a revised closed bar). An answered bucket
|
|
3873
|
-
// the union of the held row and the answer (`wrunTapeAnswerUnion`), and an unanswered held
|
|
3874
|
-
// bucket stays, since the table holds no print of a quote it does not price and the live floors
|
|
3875
|
-
// can still keep a print it lacks.
|
|
3947
|
+
// never a revised closed bar). An answered bucket keeps held orders the answer lacks: a live row can beat its table copy.
|
|
3876
3948
|
const answer = lane === 'tape'
|
|
3877
3949
|
? wrunTapeAnswerUnion(servedStartMs === undefined
|
|
3878
3950
|
? answerRows
|
|
@@ -4080,28 +4152,11 @@ function wrunTapeAnswerWithoutPartialHead(answer, servedStartMs, intervalMs, exc
|
|
|
4080
4152
|
return answer;
|
|
4081
4153
|
return answer.filter((row) => Number(row[0]) !== horizonTs);
|
|
4082
4154
|
}
|
|
4083
|
-
/**
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
return `${cell[0]}|${cell[1]}|${cell[3]}`;
|
|
4155
|
+
/** Stamp offset and side: the key the collector groups an order's fills by. */
|
|
4156
|
+
function wrunTapeOrderKey(cell) {
|
|
4157
|
+
return `${cell[0]}|${cell[3]}`;
|
|
4087
4158
|
}
|
|
4088
|
-
/**
|
|
4089
|
-
* A tape answer folded over the held rows: each answered bucket with a held row becomes the union
|
|
4090
|
-
* of both rows' prints, a multiset union by print (a print the two share is kept once, two equal
|
|
4091
|
-
* prints of one row stay two), in time order with the answer's prints first among equal offsets.
|
|
4092
|
-
* A reconcile only ever adds prints to a bar: the large-print table holds no print of a quote it
|
|
4093
|
-
* does not price, and the live floors can still keep a print it lacks (a contract's notional, a
|
|
4094
|
-
* print the writer had not committed when the ask landed), so a print shown live never vanishes
|
|
4095
|
-
* on the next poll.
|
|
4096
|
-
*
|
|
4097
|
-
* A print is the same print in both rows when its stamp, price and side are equal and its size agrees within float
|
|
4098
|
-
* rounding (`laneValuesEqual`, the session's own noise rule): two hosts compute one print's size, and under a dollar
|
|
4099
|
-
* floor (C-DOLLAR) they compute it differently, the gateway's writer on the stored row (an inverse contract's dollar
|
|
4100
|
-
* face), this browser as price x the live-feed COIN-arm size x the market's dollar unit: Binance delivery BTCUSD_PERP
|
|
4101
|
-
* trade 1160180465 (2026-10-22, tests/fixtures/wrun/tape-live-history-pairs.json) is $179,300 stored and
|
|
4102
|
-
* 84,428.9 x 2.12368039853652 = 179299.99999999997 live. Two equal prints still stay two: each held print matches one
|
|
4103
|
-
* answer print at most.
|
|
4104
|
-
*/
|
|
4159
|
+
/** Merges by order, never by price or size, which can print differently live and from the table; held-only orders stay. */
|
|
4105
4160
|
function wrunTapeAnswerUnion(answer, held) {
|
|
4106
4161
|
if (held.length === 0)
|
|
4107
4162
|
return answer;
|
|
@@ -4112,29 +4167,9 @@ function wrunTapeAnswerUnion(answer, held) {
|
|
|
4112
4167
|
const previous = heldByTs.get(Number(row[0]));
|
|
4113
4168
|
if (previous === undefined || previous.length <= 1)
|
|
4114
4169
|
return row;
|
|
4115
|
-
|
|
4116
|
-
const
|
|
4117
|
-
const
|
|
4118
|
-
for (let at = 1; at < row.length; at += 1) {
|
|
4119
|
-
const cell = row[at];
|
|
4120
|
-
cells.push(cell);
|
|
4121
|
-
const key = wrunTapePrintPlaceKey(cell);
|
|
4122
|
-
const sizes = unmatched.get(key);
|
|
4123
|
-
if (sizes === undefined)
|
|
4124
|
-
unmatched.set(key, [cell[2]]);
|
|
4125
|
-
else
|
|
4126
|
-
sizes.push(cell[2]);
|
|
4127
|
-
}
|
|
4128
|
-
const extra = [];
|
|
4129
|
-
for (let at = 1; at < previous.length; at += 1) {
|
|
4130
|
-
const cell = previous[at];
|
|
4131
|
-
const sizes = unmatched.get(wrunTapePrintPlaceKey(cell));
|
|
4132
|
-
const match = sizes === undefined ? -1 : sizes.findIndex((size) => laneValuesEqual(size, cell[2]));
|
|
4133
|
-
if (match >= 0)
|
|
4134
|
-
sizes?.splice(match, 1);
|
|
4135
|
-
else
|
|
4136
|
-
extra.push(cell);
|
|
4137
|
-
}
|
|
4170
|
+
const cells = Array.from(row).slice(1);
|
|
4171
|
+
const answered = new Set(cells.map(wrunTapeOrderKey));
|
|
4172
|
+
const extra = Array.from(previous).slice(1).filter((cell) => !answered.has(wrunTapeOrderKey(cell)));
|
|
4138
4173
|
if (extra.length === 0)
|
|
4139
4174
|
return row;
|
|
4140
4175
|
// A stable sort: the answer's prints keep their order and lead every held print of their offset.
|
|
@@ -4156,9 +4191,9 @@ function wrunTapeServedStartMs(context, windowFromTs, nowMs) {
|
|
|
4156
4191
|
// The full run validated the history; a malformed record reads as the live edge.
|
|
4157
4192
|
}
|
|
4158
4193
|
// The lane the ask rode (tradesLaneLimits, the control's own rule, under the acquisition's floor): the table's
|
|
4159
|
-
// retention and bar limit, the raw tape's two-hour seed
|
|
4160
|
-
//
|
|
4161
|
-
const lane = tradesLaneLimits(context.acquisition.tape?.large === true,
|
|
4194
|
+
// retention and bar limit on a large acquisition, else the raw tape's two-hour seed, or no history at all for a
|
|
4195
|
+
// dollar floor there.
|
|
4196
|
+
const lane = tradesLaneLimits(context.acquisition.tape?.large === true, {
|
|
4162
4197
|
minValue: context.acquisition.tape?.minValue,
|
|
4163
4198
|
});
|
|
4164
4199
|
return tradesServedStartMs(nowMs, Math.min(historySec, lane.historyCapSec), context.intervalMs, {
|
|
@@ -4202,11 +4237,11 @@ function laneWindowRevisedFromTs(before, after, fromTs, endTs) {
|
|
|
4202
4237
|
* row builder lands a grid or trades leg there (`wrunLegRowsOnHostBars`). A row no chart bar holds (off the chart's
|
|
4203
4238
|
* session) revises none, and a row's own stamp is never the answer (a 24/7 hour under a stock's 13:30 bar).
|
|
4204
4239
|
*/
|
|
4205
|
-
function wrunLegRevisedBarTs(context, before, merged, fromTs, legMs, beforeTs) {
|
|
4240
|
+
function wrunLegRevisedBarTs(context, before, merged, fromTs, legMs, beforeTs, rowVenue) {
|
|
4206
4241
|
const barOf = hostBucketResolverFor(context.intervalMs, liveBucketVenueOf(context.market));
|
|
4207
4242
|
let revisedBar = null;
|
|
4208
4243
|
for (const ts of laneWindowRevisedStamps(before, merged, fromTs, Number.POSITIVE_INFINITY)) {
|
|
4209
|
-
const bar = wrunLegRowHostBar(ts, legMs, barOf);
|
|
4244
|
+
const bar = wrunLegRowHostBar(ts, legMs, barOf, rowVenue);
|
|
4210
4245
|
if (bar !== null && bar < beforeTs)
|
|
4211
4246
|
revisedBar = minTs(revisedBar, bar);
|
|
4212
4247
|
}
|
|
@@ -5060,7 +5095,7 @@ function publishWrunDebugTick(context, outputRows) {
|
|
|
5060
5095
|
return;
|
|
5061
5096
|
const store = wrunChartHostEnv().chart.chartStore();
|
|
5062
5097
|
// The session's own console provenance (the run that installed it), never the chart's market now.
|
|
5063
|
-
store.setIndicatorPrintOutputs(context.chartIndex, context.indicatorId, selectWrunDebugLines(context.metadata, outputRows), { opra: context.opraRead === true });
|
|
5098
|
+
store.setIndicatorPrintOutputs(context.chartIndex, context.indicatorId, selectWrunDebugLines(context.metadata, outputRows), { opra: context.opraRead === true, ...(context.cmeRead === true ? { cme: true } : {}) });
|
|
5064
5099
|
}
|
|
5065
5100
|
export function __resetWrunLiveTickForTests() {
|
|
5066
5101
|
for (const state of tickStates.values()) {
|
|
@@ -5076,6 +5111,7 @@ export function __resetWrunLiveTickForTests() {
|
|
|
5076
5111
|
for (const armed of graceEndWakes.values())
|
|
5077
5112
|
clearTimeout(armed.timer);
|
|
5078
5113
|
graceEndWakes.clear();
|
|
5114
|
+
wrunLiveHeld = false;
|
|
5079
5115
|
}
|
|
5080
5116
|
/** Spec probe: the due time of the overlay's armed `pinned-close` timer, null when none. */
|
|
5081
5117
|
export function wrunPinnedCloseTimerDueAt(indicatorId) {
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
* The one rule every fact keeps: a host that does not know a fact writes 0.
|
|
19
19
|
* For the kind, the point value and the quote that 0 reads "unknown"; for the
|
|
20
20
|
* zone it is index 0, UTC, the clock every 24/7 market keeps; for the session
|
|
21
|
-
* open it is midnight, the trade day of every market off the CME family
|
|
21
|
+
* open it is midnight, the trade day of every market off the CME family and
|
|
22
|
+
* forex.
|
|
22
23
|
*/
|
|
23
24
|
import type { WrunMarketFactFill, WrunMarketKind, WrunMarketQuoteIsUsd, WrunSourceBlendField, WrunSourceFieldWord } from '@orangecharts/indicator-kit';
|
|
24
25
|
export type { WrunSourceBlendField, WrunSourceFieldWord } from '@orangecharts/indicator-kit';
|
|
@@ -31,9 +32,18 @@ export type WrunMarketFactWord = WrunMarketFactFill | 'session_open';
|
|
|
31
32
|
export declare const WRUN_MARKET_FACT_FILLS: readonly WrunMarketFactWord[];
|
|
32
33
|
/** `market.session_open()` on the CME family: its trade day opens at minute
|
|
33
34
|
* 1020 (17:00) on the Chicago clock, the evening before the date it is stamped
|
|
34
|
-
* with (the lattice of wrun-run-interval-session.util).
|
|
35
|
-
*
|
|
35
|
+
* with (the lattice of wrun-run-interval-session.util). Forex opens at the
|
|
36
|
+
* same minute on the New York clock (WRUN_MARKET_SESSION_OPEN_FOREX); every
|
|
37
|
+
* other market reads 0, midnight. The kit's WRUN_MARKET_SESSION_OPEN_CME from
|
|
38
|
+
* 0.65.0. */
|
|
36
39
|
export declare const WRUN_MARKET_SESSION_OPEN_CME = 1020;
|
|
40
|
+
/** `market.session_open()` on forex (FX_OTC, POLYGON_FX): the forex day runs
|
|
41
|
+
* 17:00 to 17:00 New York (21:00Z in summer, 22:00Z in winter), so its trade
|
|
42
|
+
* day opens at minute 1020 on the New York clock, the evening before the date
|
|
43
|
+
* it is stamped with, and Sunday 17:00 New York opens Monday's trade date.
|
|
44
|
+
* The same evening-open rule as the CME family; the kit's
|
|
45
|
+
* WRUN_MARKET_SESSION_OPEN_FOREX once the chart pins a kit that exports it. */
|
|
46
|
+
export declare const WRUN_MARKET_SESSION_OPEN_FOREX = 1020;
|
|
37
47
|
/** `market.kind()` codes: the code is the index (append-only). 0 is a market
|
|
38
48
|
* the host does not know, or none of these kinds (a prediction market, an
|
|
39
49
|
* energy or grain contract). A futures contract reports what it trades. */
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
* The one rule every fact keeps: a host that does not know a fact writes 0.
|
|
19
19
|
* For the kind, the point value and the quote that 0 reads "unknown"; for the
|
|
20
20
|
* zone it is index 0, UTC, the clock every 24/7 market keeps; for the session
|
|
21
|
-
* open it is midnight, the trade day of every market off the CME family
|
|
21
|
+
* open it is midnight, the trade day of every market off the CME family and
|
|
22
|
+
* forex.
|
|
22
23
|
*/
|
|
23
24
|
/** The host_fill words of the five market facts, in declaration order
|
|
24
25
|
* (append-only): `market.<word>()` declares the hidden param `market_<word>`. */
|
|
@@ -31,9 +32,18 @@ export const WRUN_MARKET_FACT_FILLS = Object.freeze([
|
|
|
31
32
|
]);
|
|
32
33
|
/** `market.session_open()` on the CME family: its trade day opens at minute
|
|
33
34
|
* 1020 (17:00) on the Chicago clock, the evening before the date it is stamped
|
|
34
|
-
* with (the lattice of wrun-run-interval-session.util).
|
|
35
|
-
*
|
|
35
|
+
* with (the lattice of wrun-run-interval-session.util). Forex opens at the
|
|
36
|
+
* same minute on the New York clock (WRUN_MARKET_SESSION_OPEN_FOREX); every
|
|
37
|
+
* other market reads 0, midnight. The kit's WRUN_MARKET_SESSION_OPEN_CME from
|
|
38
|
+
* 0.65.0. */
|
|
36
39
|
export const WRUN_MARKET_SESSION_OPEN_CME = 1020;
|
|
40
|
+
/** `market.session_open()` on forex (FX_OTC, POLYGON_FX): the forex day runs
|
|
41
|
+
* 17:00 to 17:00 New York (21:00Z in summer, 22:00Z in winter), so its trade
|
|
42
|
+
* day opens at minute 1020 on the New York clock, the evening before the date
|
|
43
|
+
* it is stamped with, and Sunday 17:00 New York opens Monday's trade date.
|
|
44
|
+
* The same evening-open rule as the CME family; the kit's
|
|
45
|
+
* WRUN_MARKET_SESSION_OPEN_FOREX once the chart pins a kit that exports it. */
|
|
46
|
+
export const WRUN_MARKET_SESSION_OPEN_FOREX = 1020;
|
|
37
47
|
/** `market.kind()` codes: the code is the index (append-only). 0 is a market
|
|
38
48
|
* the host does not know, or none of these kinds (a prediction market, an
|
|
39
49
|
* energy or grain contract). A futures contract reports what it trades. */
|
|
@@ -32,8 +32,12 @@
|
|
|
32
32
|
* NQ), 10 for a root the table lacks, and Whale size to ten times that. Why: an order is one trade, so a flat 10 draws a
|
|
33
33
|
* different density on every root; at 10, NQ showed 652 orders an hour and ES 5,827 on Friday 2026-10-23's open hour,
|
|
34
34
|
* and each table row is the smallest 1, 2 or 5 floor with at most 30 orders an hour there. Where prints are still judged
|
|
35
|
-
* per fill (the switch off,
|
|
36
|
-
*
|
|
35
|
+
* per fill (the switch off, any venue but the CME Group's, or a root the large-print table does not hold, whose tape
|
|
36
|
+
* rides the raw TRADE fills: live-trades-merge.util `tradesLargeServesCmeRoot`), the package's flat 10 and 100 stand
|
|
37
|
+
* (the rule's `package` verdict, reason `per-fill`), so a record a per-order session moved returns to them: a floor
|
|
38
|
+
* measured on orders never judges single fills (COMEX:MGC1! on 2026-10-29, a root the table does not hold: the largest
|
|
39
|
+
* fill in two hours was 21 contracts, so GC's 50 would have drawn nothing, while 10 kept 79 fills, about 40 an hour).
|
|
40
|
+
* Untouched rows only, as every rule.
|
|
37
41
|
*
|
|
38
42
|
* A run reads only the family its sheet declares (`wrunMarketScaledRulesOfSheet`). A market whose closed candles cover
|
|
39
43
|
* under an hour moves nothing: the next run asks again.
|
|
@@ -46,7 +50,8 @@
|
|
|
46
50
|
* (`wrunMarketScaledFamilies`): each family has its own verdict and memo, so a volume rule waiting on its candles never
|
|
47
51
|
* holds the option back.
|
|
48
52
|
*
|
|
49
|
-
* Pure: the specs and the phone app read the same rules.
|
|
53
|
+
* Pure: the specs and the phone app read the same rules. It reads the import-free size unit table and the tape rules'
|
|
54
|
+
* one served-root rule (live-trades-merge.util, a store-free leaf the history worker shares).
|
|
50
55
|
*/
|
|
51
56
|
import type { WrunScriptInputDeclaration } from './wrun-script-inputs.util.js';
|
|
52
57
|
/** How a market-scaled param's default follows the market. */
|
|
@@ -79,8 +84,9 @@ export type WrunMarketScaledRule =
|
|
|
79
84
|
readonly carriesFrom?: never;
|
|
80
85
|
}
|
|
81
86
|
/** A contracts floor by the CME product root (the contracts rule, `wrunMarketContractsVerdict`): the root's row of
|
|
82
|
-
* `table`, `other` for a root it lacks, where the
|
|
83
|
-
* prints are judged per fill
|
|
87
|
+
* `table`, `other` for a root it lacks, where the root's tape is the large-print table's per-order rows; the
|
|
88
|
+
* package's default where prints are judged per fill (the switch off, or a root the table does not hold). Never a
|
|
89
|
+
* value carried from an older version (the contracts carry has its own rules). */
|
|
84
90
|
| {
|
|
85
91
|
readonly kind: 'cme-root-contracts';
|
|
86
92
|
readonly table: Readonly<Record<string, number>>;
|
|
@@ -90,7 +96,8 @@ export type WrunMarketScaledRule =
|
|
|
90
96
|
/**
|
|
91
97
|
* Big Trades' Min size in contracts on a CME Group market whose prints are judged per aggressor order, by product root:
|
|
92
98
|
* the smallest 1, 2 or 5 floor with at most 30 orders an hour on Friday 2026-10-23's open hour (at a flat 10, NQ showed
|
|
93
|
-
* 652 orders an hour and ES 5,827). A root the table lacks reads `WRUN_CME_ROOT_MIN_CONTRACTS_OTHER
|
|
99
|
+
* 652 orders an hour and ES 5,827). A root the table lacks reads `WRUN_CME_ROOT_MIN_CONTRACTS_OTHER` where the
|
|
100
|
+
* large-print table holds it; a root the large-print table does not hold is judged per fill (`wrunMarketContractsVerdict`).
|
|
94
101
|
*/
|
|
95
102
|
export declare const WRUN_CME_ROOT_MIN_CONTRACTS: Readonly<Record<string, number>>;
|
|
96
103
|
/** The contracts floor of a CME root the table does not list: the package's 10. */
|
|
@@ -172,7 +179,7 @@ export type WrunMarketSizeVerdict =
|
|
|
172
179
|
* tape (`candle-unit`: contracts on an inverse or an OKX swap, a formula chart's candles, which are no market's). The
|
|
173
180
|
* dollar rule: no point value (`point-value`: ICE, PLATTS, a CME root off the table), a quote that is no dollar
|
|
174
181
|
* (`quote`: KRW, a coin), a formula chart (`candle-unit`). The contracts rule: prints judged per fill (`per-fill`:
|
|
175
|
-
* the per-order switch off,
|
|
182
|
+
* the per-order switch off, a venue it never holds for, or a CME root the large-print table does not hold). */
|
|
176
183
|
| {
|
|
177
184
|
kind: 'package';
|
|
178
185
|
reason: 'contracts' | 'size-unit' | 'candle-unit' | 'point-value' | 'quote' | 'per-fill';
|
|
@@ -208,9 +215,12 @@ export interface WrunMarketContractsFacts {
|
|
|
208
215
|
}
|
|
209
216
|
/**
|
|
210
217
|
* The verdict of a market's facts on a package's CONTRACTS rules (the head passes `wrunMarketScaledFamilies(...).
|
|
211
|
-
* contracts`). It reads no candles: where prints are judged per order
|
|
212
|
-
*
|
|
213
|
-
*
|
|
218
|
+
* contracts`). It reads no candles: where prints are judged per order (the switch holds and the large-print table
|
|
219
|
+
* holds the root, `tradesLargeServesCmeRoot`: its tape reads the collector's one row per order), each root contracts
|
|
220
|
+
* rule's row for the root (its `other` for a root the table lacks) and each multiple of one (`market`); where they are
|
|
221
|
+
* judged per fill (the switch off, or a root the large-print table does not hold, whose tape rides the raw fills), the
|
|
222
|
+
* package's own defaults (`package`, `per-fill`), so a record never keeps a per-order default once its tape is no
|
|
223
|
+
* longer judged per order.
|
|
214
224
|
*/
|
|
215
225
|
export declare function wrunMarketContractsVerdict(rules: Readonly<Record<string, WrunMarketScaledRule>>, facts: WrunMarketContractsFacts): WrunMarketSizeVerdict;
|
|
216
226
|
/** What one unit of a market's STORED trade amount is worth in US dollars (wrun-chart-market-facts.util
|