@orangecharts/wrun-chart-host 0.9.0 → 0.10.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/feature-flags.constants.d.ts +6 -1
- package/dist/constants/feature-flags.constants.js +67 -24
- package/dist/constants/opra-compliance.constants.d.ts +3 -2
- package/dist/constants/opra-compliance.constants.js +3 -2
- package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +26 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.js +6 -0
- package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +15 -0
- package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +17 -0
- package/dist/constants/venue-presets.constants.d.ts +20 -20
- package/dist/constants/venue-presets.constants.js +24 -26
- package/dist/host-env.d.ts +29 -5
- package/dist/host-env.js +6 -0
- package/dist/host-ports.types.d.ts +69 -15
- package/dist/index.d.ts +13 -0
- package/dist/index.js +13 -0
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
- package/dist/interfaces/replay.interface.d.ts +8 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +18 -2
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +41 -4
- package/dist/kscript-data/controls/live-trades-merge.util.js +52 -7
- package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +56 -0
- package/dist/kscript-data/controls/live-trades-order-gate.util.js +107 -0
- package/dist/market-data/billing.interface.d.ts +95 -31
- package/dist/market-data/billing.interface.js +36 -5
- package/dist/market-data/venue.d.ts +88 -6
- package/dist/market-data/venues/cme.contract.copy.json +66 -0
- package/dist/market-data/venues/cme.d.ts +126 -0
- package/dist/market-data/venues/cme.js +133 -0
- package/dist/market-data/venues/index.d.ts +162 -5
- package/dist/market-data/venues/index.js +48 -6
- package/dist/settings-templates/index.js +7 -3
- package/dist/settings-templates/indicator-fields.d.ts +5 -4
- package/dist/settings-templates/indicator-fields.js +45 -6
- package/dist/settings-templates/tool-rules.d.ts +27 -17
- package/dist/settings-templates/tool-rules.js +27 -11
- package/dist/settings-templates/tool-tables.generated.js +91 -31
- package/dist/utility/chart/book-live-bucket.util.d.ts +15 -0
- package/dist/utility/chart/book-live-bucket.util.js +47 -0
- package/dist/utility/chart/index-mode-admission.util.js +15 -2
- package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +35 -11
- package/dist/utility/chart/kscript-drawing-safe-area.util.js +145 -35
- package/dist/utility/chart/kscript-live-coalesce.util.d.ts +7 -2
- package/dist/utility/chart/kscript-live-coalesce.util.js +9 -3
- package/dist/utility/chart/kscript-provenance-keys.util.js +6 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
- package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +32 -2
- package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +45 -0
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +54 -35
- package/dist/utility/chart/kscript-venue-policy.util.js +78 -42
- package/dist/utility/chart/market-session-schedule.util.d.ts +10 -0
- package/dist/utility/chart/market-session-schedule.util.js +16 -0
- package/dist/utility/chart/opra-read-access.leaf.d.ts +5 -3
- package/dist/utility/chart/opra-read-access.leaf.js +5 -3
- package/dist/utility/chart/rth-session.util.d.ts +3 -2
- package/dist/utility/chart/rth-session.util.js +2 -1
- package/dist/utility/chart/window-geometry.leaf.d.ts +8 -0
- package/dist/utility/chart/window-geometry.leaf.js +22 -6
- package/dist/utility/chart/wrun-run-result.util.d.ts +12 -0
- package/dist/utility/chart/wrun-run-result.util.js +141 -6
- package/dist/utility/options/option-bar-anchor.util.d.ts +145 -0
- package/dist/utility/options/option-bar-anchor.util.js +340 -0
- package/dist/utility/options/option-venue.util.d.ts +18 -0
- package/dist/utility/options/option-venue.util.js +27 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
- package/dist/utility/wrun/derived-roots.util.d.ts +213 -0
- package/dist/utility/wrun/derived-roots.util.js +471 -0
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +41 -6
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +89 -19
- package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +9 -4
- package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +47 -6
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -2
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -2
- package/dist/utility/wrun/sources/lanes/option_daily.js +5 -2
- package/dist/utility/wrun/sources/lanes/options_flow.js +5 -2
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +64 -19
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +105 -35
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +2 -1
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +2 -1
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +3 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +19 -4
- package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +17 -4
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +52 -13
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +88 -19
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +2 -1
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +24 -9
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +39 -10
- package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +64 -0
- package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +89 -0
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +15 -3
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +22 -3
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +31 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +174 -13
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +685 -27
- package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +12 -0
- package/dist/utility/wrun/wrun-builtin-twin.util.js +21 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +53 -12
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +101 -53
- package/dist/utility/wrun/wrun-download-meter.util.d.ts +15 -0
- package/dist/utility/wrun/wrun-download-meter.util.js +14 -2
- package/dist/utility/wrun/wrun-download-plan.util.d.ts +99 -0
- package/dist/utility/wrun/wrun-download-plan.util.js +118 -0
- package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +11 -3
- package/dist/utility/wrun/wrun-draft-legend-note.util.js +26 -4
- package/dist/utility/wrun/wrun-frames.d.ts +27 -6
- package/dist/utility/wrun/wrun-frames.js +73 -10
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +7 -1
- package/dist/utility/wrun/wrun-hosted-wire.util.js +12 -2
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +18 -4
- package/dist/utility/wrun/wrun-hud-looks.util.js +45 -13
- package/dist/utility/wrun/wrun-latest-snapshot.d.ts +11 -0
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +13 -7
- package/dist/utility/wrun/wrun-live-intake.util.js +82 -29
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-live-tick.util.js +158 -14
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +49 -10
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +65 -5
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +31 -5
- package/dist/utility/wrun/wrun-opra-lane.util.d.ts +17 -4
- package/dist/utility/wrun/wrun-opra-lane.util.js +6 -4
- package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.d.ts +31 -0
- package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.js +119 -0
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +23 -6
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +47 -11
- package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +86 -19
- package/dist/utility/wrun/wrun-option-strike-flow.util.js +168 -62
- package/dist/utility/wrun/wrun-option-views.util.d.ts +47 -13
- package/dist/utility/wrun/wrun-option-views.util.js +98 -26
- package/dist/utility/wrun/wrun-output-style.util.d.ts +6 -2
- package/dist/utility/wrun/wrun-output-style.util.js +20 -2
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +17 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +10 -1
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +52 -4
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +100 -31
- package/dist/utility/wrun/wrun-overlay-run.util.js +733 -114
- package/dist/utility/wrun/wrun-pane-format.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-pane-format.util.js +7 -3
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +63 -13
- package/dist/utility/wrun/wrun-panel-style.util.d.ts +10 -9
- package/dist/utility/wrun/wrun-panel-style.util.js +58 -9
- package/dist/utility/wrun/wrun-param-map.util.d.ts +14 -11
- package/dist/utility/wrun/wrun-param-map.util.js +10 -5
- package/dist/utility/wrun/wrun-param-values.util.d.ts +14 -4
- package/dist/utility/wrun/wrun-param-values.util.js +4 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.js +12 -11
- package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +50 -0
- package/dist/utility/wrun/wrun-refusal-surface.util.js +68 -0
- package/dist/utility/wrun/wrun-refused-latest.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-refused-latest.util.js +12 -0
- package/dist/utility/wrun/wrun-row-source.d.ts +11 -0
- package/dist/utility/wrun/wrun-run-interval.util.d.ts +4 -2
- package/dist/utility/wrun/wrun-run-interval.util.js +9 -6
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +45 -1
- package/dist/utility/wrun/wrun-script-inputs.util.js +112 -4
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +7 -3
- package/dist/utility/wrun/wrun-setting-words.util.js +13 -5
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +27 -2
- package/dist/utility/wrun/wrun-socket-row-source.js +113 -8
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +5 -1
- package/dist/utility/wrun/wrun-source-rows.util.js +16 -3
- package/dist/utility/wrun/wrun-style-words.util.js +6 -4
- package/dist/utility/wrun/wrun-table-chrome.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-table-chrome.util.js +19 -11
- package/dist/utility/wrun/wrun-tape-per-order.util.d.ts +2 -0
- package/dist/utility/wrun/wrun-tape-per-order.util.js +26 -0
- package/dist/utils/replay/replay-buffer-math.d.ts +53 -2
- package/dist/utils/replay/replay-buffer-math.js +227 -20
- package/package.json +11 -11
|
@@ -16,4 +16,15 @@ export interface WrunLatestSnapshot {
|
|
|
16
16
|
/** The init() arguments the run computed with, one per sheet param in sheet order (the
|
|
17
17
|
* rig's proof that a dialog edit reached the module). Absent on a tick republish. */
|
|
18
18
|
initArgs?: number[];
|
|
19
|
+
/** A full run the host refused by name (a lane unserved on this market, a budget, a plan): the card shows this
|
|
20
|
+
* sentence instead of its tiles. Absent on a served run. `reason` is the refusal row's key, `sentence` the
|
|
21
|
+
* user-facing chip text. */
|
|
22
|
+
refused?: {
|
|
23
|
+
reason: string;
|
|
24
|
+
sentence: string;
|
|
25
|
+
};
|
|
26
|
+
/** The Style targets the applied run drew nothing for (the run result's `emptyTargets`): the Style page draws
|
|
27
|
+
* their lines dimmed with the reason (WrunLayoutPanel). A republish that built no result (a landed pan page)
|
|
28
|
+
* carries the last one's forward. Absent when every judged target drew. */
|
|
29
|
+
emptyTargets?: string[];
|
|
19
30
|
}
|
|
@@ -43,7 +43,7 @@ export interface WrunLiveFrame {
|
|
|
43
43
|
/** The frame's coin (its series' underlying), when the fan-out names it: a row lane fed by coin admits by it
|
|
44
44
|
* (else the point's own `series.coin`). */
|
|
45
45
|
incomingCoin?: string;
|
|
46
|
-
/** Rider rows already
|
|
46
|
+
/** Rider rows already keyed on their bar (`bookLiveBucketRows`): never re-bucket. */
|
|
47
47
|
bucketed?: boolean;
|
|
48
48
|
}
|
|
49
49
|
export type WrunLiveIntakeVerdict = 'queued' | 'ignored:no-context' | 'ignored:foreign' | 'ignored:undeclared' | 'ignored:replaying' | 'ignored:ineligible' | 'ignored:generation'
|
|
@@ -54,6 +54,10 @@ export type WrunLiveIntakeVerdict = 'queued' | 'ignored:no-context' | 'ignored:f
|
|
|
54
54
|
* prove: no live print is valued by a guess, so none folds (the history still serves the gateway's
|
|
55
55
|
* own dollar values). */
|
|
56
56
|
| 'ignored:value-unproven'
|
|
57
|
+
/** A print of a per-order tape held by its order gate (`wrunTapePerOrder`, live-trades-order-gate.util):
|
|
58
|
+
* queued with every fill of its order once the order is judged at or above the floor (the gate wakes
|
|
59
|
+
* the drain then), turned away whole, each fill `ignored:below-floor`, when it falls short. */
|
|
60
|
+
| 'held'
|
|
57
61
|
/** The tick's own verdict: the overlay is paused or its execution guard tripped. */
|
|
58
62
|
| 'ignored:paused';
|
|
59
63
|
/** `pinned-close`: a pinned coarser leg's candle closed (armed by the tick
|
|
@@ -174,7 +178,8 @@ export type WrunLiveBucketMarket = {
|
|
|
174
178
|
* open (a week bucket is its Monday, the main path's `findMonday`; a month,
|
|
175
179
|
* quarter, half or year bucket its UTC calendar boundary), except
|
|
176
180
|
* the book, whose snapshots are stamped at the observation and an exact
|
|
177
|
-
* boundary belongs to the PREVIOUS bar
|
|
181
|
+
* boundary belongs to the PREVIOUS bar, on the CME session lattice its
|
|
182
|
+
* history rides on a CME Group `market` (`bookLiveBucketMs`, the rule the
|
|
178
183
|
* K_ORDERBOOK lane and the rider projection apply), and a session-lattice
|
|
179
184
|
* lane on a `market`, which keys the bar its fetched rows have through the
|
|
180
185
|
* chart's one live boundary rule (`liveBucketStartMs`: the Chicago session
|
|
@@ -217,11 +222,12 @@ export declare function wrunLiveOhlcvPoint(point: unknown): {
|
|
|
217
222
|
* leg on the session lattice). Never mutates its inputs.
|
|
218
223
|
*/
|
|
219
224
|
export declare function foldWrunLegCandleRows(base: ReadonlyArray<ArrayLike<number>>, points: readonly unknown[], intervalMs: number, market?: WrunLiveBucketMarket | null): FoldResult | null;
|
|
220
|
-
/** K_ORDERBOOK.buildLiveDataRows over a raw frame: replay bursts
|
|
221
|
-
* every row (copied), a live snapshot
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
|
|
225
|
+
/** K_ORDERBOOK.buildLiveDataRows over a raw frame: replay bursts key
|
|
226
|
+
* every row (copied), a live snapshot keys its one row (copied), each on
|
|
227
|
+
* `market`'s bar (`bookLiveBucketMs`: the session lattice on a CME Group
|
|
228
|
+
* market); a bucketed row (`ArrayLike<number>`) is taken as-is. Frames
|
|
229
|
+
* without a book payload yield nothing. */
|
|
230
|
+
export declare function wrunLiveBookRows(point: WrunLiveBookPoint, intervalMs: number, market: WrunLiveBucketMarket | null | undefined): ArrayLike<number>[];
|
|
225
231
|
/**
|
|
226
232
|
* Fold queued points into a lane's rows under the lane's kScript fold rule.
|
|
227
233
|
* Returns the NEW rows array (untouched rows shared, touched rows new), the
|
|
@@ -32,6 +32,12 @@
|
|
|
32
32
|
* out of the queue (the kScript fan-out's rule). The floor includes the large-print table's own
|
|
33
33
|
* (`tradesBelowLargeFloor`: a dollar-quoted print under 10,000 notional, a CME Group print under
|
|
34
34
|
* its root's contracts floor), so no print appears live that the next reconcile cannot answer. A
|
|
35
|
+
* tape judged per aggressor order (`wrunTapePerOrder`: a CME Group venue under the per-order
|
|
36
|
+
* switch) judges no single fill at the enqueue or the fold: its order gate
|
|
37
|
+
* (live-trades-order-gate.util) holds the forming order of its raw prints and queues every fill of an
|
|
38
|
+
* order at or above the acquisition's floor, the order the per-order reconcile answers, and turns an
|
|
39
|
+
* order below it away whole, so the package adds a big order's fills back into one trade (a floor per
|
|
40
|
+
* fill drew a 147-contract NQZ6 buy of 45 fills as its two 17-lot fills). A
|
|
35
41
|
* print the queue cap drops leaves its bar short: the
|
|
36
42
|
* drain marks the bucket for the reconcile (`tape-lost`) when the table can restore it, else the
|
|
37
43
|
* tick refuses the bucket by name (`tapeLostBuckets`);
|
|
@@ -44,9 +50,11 @@
|
|
|
44
50
|
* - funding: K_FUNDING_RATE (last-wins, normalized to 1h, percent);
|
|
45
51
|
* - volume_profile: K_VOLUME_PROFILE_AGG (delta fold on the lattice, needs a
|
|
46
52
|
* fetched base row, quote guard);
|
|
47
|
-
* - book: K_ORDERBOOK.buildLiveDataRows for raw frames
|
|
48
|
-
*
|
|
49
|
-
*
|
|
53
|
+
* - book: K_ORDERBOOK.buildLiveDataRows for raw frames, keyed on the chart
|
|
54
|
+
* market's bar (`bookLiveBucketMs`: an exact bar boundary belongs to the
|
|
55
|
+
* PREVIOUS bar, on the CME session lattice on a CME Group market); rows
|
|
56
|
+
* marked `bucketed: true` (the heatmap rider's projection, keyed by the same
|
|
57
|
+
* rule) are taken as-is;
|
|
50
58
|
* - a foreign GRID leg (a pinned market's rows at the chart interval, the
|
|
51
59
|
* G4 round-3 contract): K_OHLCV.mergeLiveDataPoint over that market's
|
|
52
60
|
* candle frames (`mergeLiveOhlcvDataPoint`: high/low widen, close
|
|
@@ -76,10 +84,12 @@ import { mergeLiveOhlcvDataPoint } from '../../kscript-data/controls/live-ohlcv-
|
|
|
76
84
|
import { mergeLiveTradesDataPoint, readLiveTradePrint, tradesBarStartMs, tradesBelowLargeFloor, tradesLargeHistoryAnswers, tradesTapeCellSize, tradesTapeFloorValuesPrints, } from '../../kscript-data/controls/live-trades-merge.util.js';
|
|
77
85
|
import { liveAmountUsd, peekOptionTradeUnits } from '../options/option-trade-units.util.js';
|
|
78
86
|
import { parseWrunTapeHistory, wrunTapeHistoryOf } from './wrun-tape-source.util.js';
|
|
87
|
+
import { wrunTapePerOrder } from './wrun-tape-per-order.util.js';
|
|
88
|
+
import { TradesOrderGate } from '../../kscript-data/controls/live-trades-order-gate.util.js';
|
|
79
89
|
import { wrunDollarUnitReader } from './wrun-dollar-unit-port.leaf.js';
|
|
80
90
|
import { wrunChartHostEnv } from '../../host-env.js';
|
|
81
91
|
import { v2LiveTradePrintBelowFloor } from '../chart/kscript-live-coalesce.util.js';
|
|
82
|
-
import {
|
|
92
|
+
import { bookLiveBucketMs, bookLiveBucketRows } from '../chart/book-live-bucket.util.js';
|
|
83
93
|
import { liveFeedSeriesMatchesChartStream } from '../chart/live-feed-series-match.leaf.js';
|
|
84
94
|
import { liveBucketStartMs, liveBucketVenueOf } from '../chart/live-bucket.util.js';
|
|
85
95
|
import { hostBucketResolverFor } from '../chart/host-bar-placement.util.js';
|
|
@@ -201,8 +211,10 @@ function intakeFor(indicatorId, chartIndex, intervalMs, generation) {
|
|
|
201
211
|
function discardQueuesForGeneration(intake, generation) {
|
|
202
212
|
const pending = pendingCount(intake);
|
|
203
213
|
intake.additive = {};
|
|
204
|
-
// The fresh full run's fetch holds the prints the cap dropped: nothing is owed for them.
|
|
214
|
+
// The fresh full run's fetch holds the prints the cap dropped: nothing is owed for them, nor for an order still held.
|
|
205
215
|
intake.tapeLost = new Set();
|
|
216
|
+
intake.tapeGate?.dispose();
|
|
217
|
+
intake.tapeGate = undefined;
|
|
206
218
|
intake.bookLive = new Map();
|
|
207
219
|
intake.bookReplay = new Map();
|
|
208
220
|
intake.funding = new Map();
|
|
@@ -303,7 +315,8 @@ const WRUN_SESSION_LATTICE_LANES = new Set([
|
|
|
303
315
|
* open (a week bucket is its Monday, the main path's `findMonday`; a month,
|
|
304
316
|
* quarter, half or year bucket its UTC calendar boundary), except
|
|
305
317
|
* the book, whose snapshots are stamped at the observation and an exact
|
|
306
|
-
* boundary belongs to the PREVIOUS bar
|
|
318
|
+
* boundary belongs to the PREVIOUS bar, on the CME session lattice its
|
|
319
|
+
* history rides on a CME Group `market` (`bookLiveBucketMs`, the rule the
|
|
307
320
|
* K_ORDERBOOK lane and the rider projection apply), and a session-lattice
|
|
308
321
|
* lane on a `market`, which keys the bar its fetched rows have through the
|
|
309
322
|
* chart's one live boundary rule (`liveBucketStartMs`: the Chicago session
|
|
@@ -315,7 +328,7 @@ const WRUN_SESSION_LATTICE_LANES = new Set([
|
|
|
315
328
|
* market passes no venue, so nothing else starts anchoring. */
|
|
316
329
|
export function wrunLiveBucketTs(lane, tsMs, intervalMs, market) {
|
|
317
330
|
if (lane === 'book')
|
|
318
|
-
return
|
|
331
|
+
return bookLiveBucketMs(tsMs, intervalMs, bookVenueOf(market));
|
|
319
332
|
if (market && WRUN_SESSION_LATTICE_LANES.has(lane)) {
|
|
320
333
|
return liveBucketStartMs(tsMs, intervalMs, {
|
|
321
334
|
exchange: market.exchange,
|
|
@@ -625,34 +638,36 @@ export function foldWrunLegCandleRows(base, points, intervalMs, market) {
|
|
|
625
638
|
return null;
|
|
626
639
|
return foldResult(mergeLaneRows(base, replaced, added), touched);
|
|
627
640
|
}
|
|
628
|
-
/**
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
641
|
+
/** The venue a book row is keyed for: the lane's market (the chart's own), or none. */
|
|
642
|
+
function bookVenueOf(market) {
|
|
643
|
+
return market ? { exchange: market.exchange, symbol: market.symbol } : null;
|
|
644
|
+
}
|
|
645
|
+
/** K_ORDERBOOK.buildLiveDataRows over a raw frame: replay bursts key
|
|
646
|
+
* every row (copied), a live snapshot keys its one row (copied), each on
|
|
647
|
+
* `market`'s bar (`bookLiveBucketMs`: the session lattice on a CME Group
|
|
648
|
+
* market); a bucketed row (`ArrayLike<number>`) is taken as-is. Frames
|
|
649
|
+
* without a book payload yield nothing. */
|
|
650
|
+
export function wrunLiveBookRows(point, intervalMs, market) {
|
|
633
651
|
if (typeof point.length === 'number' && !isRecord(point.series)) {
|
|
634
652
|
const row = point;
|
|
635
653
|
return Number.isFinite(Number(row[0])) ? [row] : [];
|
|
636
654
|
}
|
|
637
655
|
const frame = point;
|
|
656
|
+
const venue = bookVenueOf(market);
|
|
638
657
|
if (frame.series?.isReplay) {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
copy[0] = roundObTimestamp(copy[0], intervalMs);
|
|
643
|
-
return copy;
|
|
644
|
-
});
|
|
645
|
-
return rows.filter((row) => row.length > 0).sort((a, b) => a[0] - b[0]);
|
|
658
|
+
return bookLiveBucketRows((frame.float64Arrays ?? []), intervalMs, venue)
|
|
659
|
+
.filter((row) => row.length > 0)
|
|
660
|
+
.sort((a, b) => a[0] - b[0]);
|
|
646
661
|
}
|
|
647
662
|
if (!frame.blockBookSnapshot)
|
|
648
663
|
return [];
|
|
649
664
|
const copy = Float64Array.from(frame.blockBookSnapshot);
|
|
650
665
|
if (copy.length === 0)
|
|
651
666
|
return [];
|
|
652
|
-
copy[0] =
|
|
667
|
+
copy[0] = bookLiveBucketMs(copy[0], intervalMs, venue);
|
|
653
668
|
return [copy];
|
|
654
669
|
}
|
|
655
|
-
function foldBook(base, points, intervalMs) {
|
|
670
|
+
function foldBook(base, points, intervalMs, market) {
|
|
656
671
|
const indexByTs = new Map();
|
|
657
672
|
for (let at = 0; at < base.length; at += 1)
|
|
658
673
|
indexByTs.set(Number(base[at][0]), at);
|
|
@@ -660,7 +675,7 @@ function foldBook(base, points, intervalMs) {
|
|
|
660
675
|
const added = new Map();
|
|
661
676
|
const touched = new Set();
|
|
662
677
|
for (const point of points) {
|
|
663
|
-
for (const row of wrunLiveBookRows(point, intervalMs)) {
|
|
678
|
+
for (const row of wrunLiveBookRows(point, intervalMs, market)) {
|
|
664
679
|
const bucket = Number(row[0]);
|
|
665
680
|
if (indexByTs.has(bucket))
|
|
666
681
|
replaced.set(bucket, row);
|
|
@@ -872,7 +887,7 @@ export function foldWrunLaneRows(lane, rows, points, intervalMs, acquisition, ma
|
|
|
872
887
|
case 'funding':
|
|
873
888
|
return foldFunding(base, points, intervalMs);
|
|
874
889
|
case 'book':
|
|
875
|
-
return foldBook(base, points, intervalMs);
|
|
890
|
+
return foldBook(base, points, intervalMs, market);
|
|
876
891
|
case 'volume_profile':
|
|
877
892
|
return foldVolumeProfile(base, points, intervalMs, acquisition, market);
|
|
878
893
|
case 'tape':
|
|
@@ -960,16 +975,19 @@ function wrunTapeLiveValuePerUnit(market) {
|
|
|
960
975
|
* market's `valuePerUnit` the full run priced (C-DOLLAR), else the one the market facts prove now
|
|
961
976
|
* (`wrunTapeLiveValuePerUnit`: never a transient unknown frozen for the session) and, on an option contract of a
|
|
962
977
|
* plain option venue, the registry trade units as answered (a dollar floor values an option print by its USD
|
|
963
|
-
* premium).
|
|
978
|
+
* premium). On a tape whose live prints arrive judged per aggressor order (`wrunTapePerOrder`, the chart market's
|
|
979
|
+
* venue: the tape's frames are its market's) the floor is marked `perOrder`: the shared rules then judge no fill by
|
|
980
|
+
* it, nor by the large-print table's floor. */
|
|
964
981
|
function wrunTapeLiveFloorOf(acquisition, market) {
|
|
965
|
-
const
|
|
982
|
+
const perOrder = wrunTapePerOrder(market?.exchange) ? { perOrder: true } : {};
|
|
983
|
+
const floor = { minSize: acquisition?.minSize, ...perOrder };
|
|
966
984
|
if (acquisition?.minValue === undefined)
|
|
967
985
|
return floor;
|
|
968
986
|
const { exchange, symbol } = market ?? {};
|
|
969
987
|
const optionUnits = typeof exchange === 'string' && typeof symbol === 'string' ? peekOptionTradeUnits({ exchange, symbol }) : null;
|
|
970
988
|
const frozen = Number(acquisition.valuePerUnit);
|
|
971
989
|
const valuePerUnit = Number.isFinite(frozen) && frozen > 0 ? frozen : optionUnits ? undefined : wrunTapeLiveValuePerUnit(market);
|
|
972
|
-
const priced = { minValue: acquisition.minValue, valuePerUnit };
|
|
990
|
+
const priced = { minValue: acquisition.minValue, valuePerUnit, ...perOrder };
|
|
973
991
|
return optionUnits ? { ...priced, optionUnits } : priced;
|
|
974
992
|
}
|
|
975
993
|
/** The dollar tapes the intake recorded as unable to value a live print (no `valuePerUnit` yet), by overlay, so the
|
|
@@ -1020,6 +1038,29 @@ function wrunTapePrintUnvalued(intake, context, intervalMs, data) {
|
|
|
1020
1038
|
else
|
|
1021
1039
|
intake.tapeLost.add(bucket);
|
|
1022
1040
|
}
|
|
1041
|
+
/** A per-order tape's order gate (live-trades-order-gate.util), made on the tape's first held print: an order at or
|
|
1042
|
+
* above the acquisition's floor queues every fill and wakes the drain (the hold timer judges an order with no frame
|
|
1043
|
+
* to arm one); an order below it is turned away whole, each fill counted `ignored:below-floor`. A gate whose intake
|
|
1044
|
+
* is gone (a teardown, a reset) queues nothing. */
|
|
1045
|
+
function wrunTapeOrderGateOf(intake, indicatorId) {
|
|
1046
|
+
if (intake.tapeGate !== undefined)
|
|
1047
|
+
return intake.tapeGate;
|
|
1048
|
+
const gate = new TradesOrderGate({
|
|
1049
|
+
admit: (points) => {
|
|
1050
|
+
if (intakes.get(indicatorId) !== intake || intake.tapeGate !== gate)
|
|
1051
|
+
return;
|
|
1052
|
+
for (const point of points)
|
|
1053
|
+
pushAdditive(intake, 'tape', point);
|
|
1054
|
+
drainRequester?.(indicatorId);
|
|
1055
|
+
},
|
|
1056
|
+
drop: (points) => {
|
|
1057
|
+
const ignored = intake.stats.ignored;
|
|
1058
|
+
ignored['ignored:below-floor'] = (ignored['ignored:below-floor'] ?? 0) + points.length;
|
|
1059
|
+
},
|
|
1060
|
+
});
|
|
1061
|
+
intake.tapeGate = gate;
|
|
1062
|
+
return gate;
|
|
1063
|
+
}
|
|
1023
1064
|
/** The large-print table's floor at the tape enqueue (the fold applies it again): on the large
|
|
1024
1065
|
* lane, a print under the table's floor (`tradesBelowLargeFloor`: a dollar-quoted market's notional,
|
|
1025
1066
|
* a CME Group root's contracts, an option book's premium; the frame's envelope names the market,
|
|
@@ -1335,8 +1376,10 @@ export function enqueueWrunLiveFrame(a) {
|
|
|
1335
1376
|
else {
|
|
1336
1377
|
const replay = isRecord(data) && isRecord(data.series) && data.series.isReplay === true;
|
|
1337
1378
|
const slot = replay ? intake.bookReplay : intake.bookLive;
|
|
1338
|
-
|
|
1379
|
+
// Keyed on the chart market's bar, as the drain folds every lane (`chartMarketOf`).
|
|
1380
|
+
for (const row of wrunLiveBookRows(data, intervalMs, chartMarketOf(context))) {
|
|
1339
1381
|
slot.set(Number(row[0]), row);
|
|
1382
|
+
}
|
|
1340
1383
|
}
|
|
1341
1384
|
}
|
|
1342
1385
|
else if (lane === 'funding') {
|
|
@@ -1357,7 +1400,8 @@ export function enqueueWrunLiveFrame(a) {
|
|
|
1357
1400
|
// a print at all (C-DOLLAR: no proven dollar unit) folds none, recorded once by name. The
|
|
1358
1401
|
// large-print table's own floor too: a print under it (a dollar-quoted market's notional, a CME
|
|
1359
1402
|
// Group root's contracts) would fold live and vanish when the next reconcile answers the bucket
|
|
1360
|
-
// from the table.
|
|
1403
|
+
// from the table. A per-order tape (`floor.perOrder`) judges neither on one fill: its order gate does
|
|
1404
|
+
// (below), and the per-order reconcile answers every fill of an order the gate admits.
|
|
1361
1405
|
const floor = wrunTapeLiveFloorOf(context.acquisition.tape, context.market);
|
|
1362
1406
|
if (!tradesTapeFloorValuesPrints(floor)) {
|
|
1363
1407
|
noteWrunTapeUnvalued(a.indicatorId, context);
|
|
@@ -1367,12 +1411,18 @@ export function enqueueWrunLiveFrame(a) {
|
|
|
1367
1411
|
// A frame the fold cannot read as a print (no side, a bad stamp) is judged by its raw amount under a
|
|
1368
1412
|
// size floor, as it always was, and never folds under a dollar floor.
|
|
1369
1413
|
const print = readLiveTradePrint(a.frame.data);
|
|
1414
|
+
// A per-order tape's print joins the forming order (the order gate, live-trades-order-gate.util): it takes a queue
|
|
1415
|
+
// slot only with every fill of an order at or above the floor, judged when the order ends or its hold runs out.
|
|
1416
|
+
if (floor.perOrder === true && print !== null) {
|
|
1417
|
+
wrunTapeOrderGateOf(intake, a.indicatorId).push(a.frame.data, print, floor);
|
|
1418
|
+
return 'held';
|
|
1419
|
+
}
|
|
1370
1420
|
const minSize = Number(floor.minSize);
|
|
1371
1421
|
const belowTapeFloor = print === null
|
|
1372
1422
|
? floor.minValue !== undefined ||
|
|
1373
1423
|
v2LiveTradePrintBelowFloor(a.frame.data, Number.isFinite(minSize) ? minSize : 0)
|
|
1374
1424
|
: tradesTapeCellSize(print, floor) === null;
|
|
1375
|
-
if (belowTapeFloor || wrunTapePrintBelowLargeFloor(context, a.frame.data)) {
|
|
1425
|
+
if (belowTapeFloor || (floor.perOrder !== true && wrunTapePrintBelowLargeFloor(context, a.frame.data))) {
|
|
1376
1426
|
return noteVerdict(a.indicatorId, 'ignored:below-floor', context);
|
|
1377
1427
|
}
|
|
1378
1428
|
pushAdditive(intake, 'tape', a.frame.data);
|
|
@@ -1884,6 +1934,7 @@ export function takeWrunLiveGaps(indicatorId) {
|
|
|
1884
1934
|
/** Queues, gaps and stats of one overlay: registered on the drivers'
|
|
1885
1935
|
* teardown hook at import time. */
|
|
1886
1936
|
export function disposeWrunLiveIntake(indicatorId) {
|
|
1937
|
+
intakes.get(indicatorId)?.tapeGate?.dispose();
|
|
1887
1938
|
intakes.delete(indicatorId);
|
|
1888
1939
|
wrunTapeUnvaluedNoted.delete(indicatorId);
|
|
1889
1940
|
}
|
|
@@ -2125,6 +2176,8 @@ export function wrunLiveContextSnapshot(indicatorId) {
|
|
|
2125
2176
|
};
|
|
2126
2177
|
}
|
|
2127
2178
|
export function __resetWrunLiveIntakeForTests() {
|
|
2179
|
+
for (const intake of intakes.values())
|
|
2180
|
+
intake.tapeGate?.dispose();
|
|
2128
2181
|
intakes.clear();
|
|
2129
2182
|
wrunTapeUnvaluedNoted.clear();
|
|
2130
2183
|
drainRequester = null;
|
|
@@ -163,6 +163,7 @@
|
|
|
163
163
|
* frame folded since the last one as one tail.
|
|
164
164
|
*/
|
|
165
165
|
import { type WrunPollLaneId } from './sources/wrun-poll-lane.types.js';
|
|
166
|
+
import { type WrunOpraServedReceipt } from './wrun-opra-lane.util.js';
|
|
166
167
|
import { type WrunOverlayLiveContext } from './wrun-overlay-drivers.util.js';
|
|
167
168
|
import { type WrunCellRows } from './wrun-canvases.util.js';
|
|
168
169
|
import { type WrunRunIntervalSession } from './wrun-run-interval-session.util.js';
|
|
@@ -286,6 +287,9 @@ export interface WrunSourceFedSession {
|
|
|
286
287
|
/** The run pass installed `context` for a session its row source feeds (above), with the verdict its batch carried
|
|
287
288
|
* and the pass's seams for the verdicts its frames carry (`session`; without one a frame publishes none). */
|
|
288
289
|
export declare function markWrunSourceFedLiveContext(context: WrunOverlayLiveContext, session?: WrunSourceFedSession): void;
|
|
290
|
+
/** A Cloud session's receipt from here on (`WrunOverlayLiveContext.cloudOpraServed`): the receipt an answer with the
|
|
291
|
+
* OPRA mark named for its rows, or none when it named no tier. */
|
|
292
|
+
export declare function noteWrunCloudOpraServed(context: WrunOverlayLiveContext, served: WrunOpraServedReceipt | undefined): void;
|
|
289
293
|
/** Whether a row source feeds `context` from elsewhere (its drain integrates the source's frames only). */
|
|
290
294
|
export declare function isWrunSourceFedLiveContext(context: WrunOverlayLiveContext | undefined): boolean;
|
|
291
295
|
/**
|
|
@@ -193,7 +193,7 @@ import { wrunPollLaneByKey } from './sources/registry.js';
|
|
|
193
193
|
import { isWrunPollLaneId } from './sources/wrun-poll-lane.types.js';
|
|
194
194
|
import { wrunRowLaneByKey } from './sources/row-lane-registry.js';
|
|
195
195
|
import { isWrunRowLaneId } from './sources/wrun-row-lane.types.js';
|
|
196
|
-
import { fetchWrunRowLaneRows, wrunRowLaneChainAsk, wrunRowLaneChainGovernedExchange, wrunRowLaneFetchOptions, wrunRowLaneMovedInstance, } from './sources/wrun-row-lanes.util.js';
|
|
196
|
+
import { fetchWrunRowLaneRows, mergeWrunReplayRowLaneRows, wrunReplayRowLaneExtensions, wrunRowLaneAddKey, wrunRowLaneChainAsk, wrunRowLaneChainGovernedExchange, wrunRowLaneFetchOptions, wrunRowLaneMovedInstance, } from './sources/wrun-row-lanes.util.js';
|
|
197
197
|
import { wrunOpraLanePayloadAt } from './wrun-opra-lane.util.js';
|
|
198
198
|
import { drainWrunPollLaneLiveRows, setWrunPollLaneLiveDrainRequester, wrunPollLaneLiveOwed, wrunPollLaneLiveUp, } from './wrun-series-stream.util.js';
|
|
199
199
|
import { fetchWrunPollLaneHostGridRows, wrunPollLaneChainAsk, wrunPollLaneChainGovernedExchange, wrunPollLaneFetchOptions, wrunPollLaneMovedInstance, wrunPollLaneReconcileFrom, wrunPollLaneReconcileTo, } from './sources/wrun-poll-lanes.util.js';
|
|
@@ -213,7 +213,7 @@ import { isWrunBatchedChildRefused, mountWrunChildOverlays } from './wrun-panel-
|
|
|
213
213
|
import { getWrunBrowserHost, wrunLiveOf, WrunLiveOrderError, WrunLiveSessionLostError, } from './wrun-host.service.js';
|
|
214
214
|
import { getWrunOverlayLiveContext, isWrunOverlayRerunInFlight, onWrunOverlayLiveTeardown, rerunWrunOverlayForChartWave, setWrunChartRowsIdentityReader, setWrunLiveSheetReader, suspendWrunOverlayLiveSession, teardownWrunOverlay, withWrunOverlaySessionLock, wrunChartMarketIdentity, } from './wrun-overlay-drivers.util.js';
|
|
215
215
|
import { withWrunOverlayExecutionMeasure } from './wrun-overlay-lifecycle.util.js';
|
|
216
|
-
import { cutWrunReplayRowsAfterApply } from './wrun-replay-rows.util.js';
|
|
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
219
|
import { wrunLegBarCloseAt, wrunLegCandleClose, wrunLegCloseSettleMs, wrunLegCandleOpen, wrunPrimaryRowBounds, wrunPrimaryRowHoldingMs, wrunChartSession, } from './wrun-leg-close.util.js';
|
|
@@ -221,7 +221,7 @@ 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, wrunHostFillContextFor, wrunLegFetchType, wrunLegPayloadExtras, wrunIntegratedRowsView, wrunSessionCanvasFillOf, wrunSessionPinnedSheet, wrunSessionRespelledSheet, wrunResultMarketUnits, wrunSessionRunHealth, } from './wrun-overlay-run.util.js';
|
|
224
|
+
import { buildWrunOverlayRunResult, closedLegCandles, forgetWrunOverlayCanvasState, openLegCandles, wrunLegReadsFormingOpen, wrunLegReadsLiveCandleOnly, cutWrunOddsLegRows, placeWrunResultTables, presentWrunIntegration, publishWrunRunHealth, publishWrunSessionCanvasNotices, recordWrunHostBuildMs, reseedWrunOverlayFromBuffers, wrunCanvasHostFillFor, wrunChartPriceDigits, wrunDownloadBudgetCutOn, 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';
|
|
@@ -238,7 +238,7 @@ import { advanceWrunInputCarry, buildWrunInputTailRows, planWrunPinnedWires, wru
|
|
|
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';
|
|
241
|
-
import { createWrunDownloadMeter } from './wrun-download-meter.util.js';
|
|
241
|
+
import { createWrunDownloadMeter, } from './wrun-download-meter.util.js';
|
|
242
242
|
/** Book frames are full snapshots and book runs are the heavy case: same 1s
|
|
243
243
|
* floor the kScript coalescer applies to orderbook-sourced scripts. */
|
|
244
244
|
const WRUN_BOOK_LIVE_UPDATE_MIN_MS = 1_000;
|
|
@@ -546,6 +546,14 @@ export function markWrunSourceFedLiveContext(context, session) {
|
|
|
546
546
|
diagnostics: session.diagnostics !== undefined ? wrunSourceVerdictKey(session.diagnostics) : undefined,
|
|
547
547
|
});
|
|
548
548
|
}
|
|
549
|
+
/** A Cloud session's receipt from here on (`WrunOverlayLiveContext.cloudOpraServed`): the receipt an answer with the
|
|
550
|
+
* OPRA mark named for its rows, or none when it named no tier. */
|
|
551
|
+
export function noteWrunCloudOpraServed(context, served) {
|
|
552
|
+
if (served === undefined)
|
|
553
|
+
delete context.cloudOpraServed;
|
|
554
|
+
else
|
|
555
|
+
context.cloudOpraServed = { ...served };
|
|
556
|
+
}
|
|
549
557
|
/** Whether a row source feeds `context` from elsewhere (its drain integrates the source's frames only). */
|
|
550
558
|
export function isWrunSourceFedLiveContext(context) {
|
|
551
559
|
return context !== undefined && wrunSourceFedContexts.has(context);
|
|
@@ -588,12 +596,49 @@ export function queueWrunSourceLiveFrame(context, frame, cellRowsOf) {
|
|
|
588
596
|
if (getWrunOverlayLiveContext(context.indicatorId) !== context || context.replay)
|
|
589
597
|
return;
|
|
590
598
|
const queued = queuedSourceFrames.get(context);
|
|
599
|
+
// A move of the served tier never folds into the rows of the tier before it: the source drops its session on one
|
|
600
|
+
// (`servedTierMoved`), and a frame naming another tier than the rows the session holds reseeds it the same way.
|
|
601
|
+
if (frame.servedTierMoved === true || wrunFrameMovesServedTier(context, queued?.frame, frame)) {
|
|
602
|
+
reseedWrunSourceSessionAtServedTier(context);
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
591
605
|
// The verdict is weighed against the one the drain reaches next: the queued frames', else the session's.
|
|
592
606
|
if (!wrunRowFrameDraws(frame) && !wrunSourceVerdictMoves(context, frame, queued?.frame))
|
|
593
607
|
return;
|
|
594
608
|
queuedSourceFrames.set(context, { frame: queued ? coalesceWrunRowFrames(queued.frame, frame) : frame, cellRowsOf });
|
|
595
609
|
armWrunLiveDrain(context, false);
|
|
596
610
|
}
|
|
611
|
+
/**
|
|
612
|
+
* The cloud served the session's OPRA rows at another tier than the rows the overlay shows (its source's transition,
|
|
613
|
+
* `WrunRowFrame.servedTierMoved`: the source dropped every row it held). Nothing drawn at the old tier stays: the
|
|
614
|
+
* frames queued for the session go, the overlay's rows come off the chart (the parent, its nested plots and its child
|
|
615
|
+
* panes), its live session ends with the source it held (the driver stays: `suspendWrunOverlayLiveSession`, the
|
|
616
|
+
* primitive the browser lane's downgrade discard ends a session with), and a rebuild creates a fresh session at the
|
|
617
|
+
* tier the cloud serves now, whose result names its receipt to the legend. A downgraded viewer never keeps real-time
|
|
618
|
+
* rows under a delayed word, and an upgraded one never keeps delayed rows under none.
|
|
619
|
+
*/
|
|
620
|
+
/** Whether a frame names another served tier than the rows its session holds: the newest receipt queued for it, else
|
|
621
|
+
* the session's own (`cloudOpraServed`). A frame or a session that names no tier moves nothing. */
|
|
622
|
+
function wrunFrameMovesServedTier(context, queued, frame) {
|
|
623
|
+
const tier = frame.opra === true ? frame.opraServed?.tier : undefined;
|
|
624
|
+
if (tier === undefined)
|
|
625
|
+
return false;
|
|
626
|
+
const held = (queued?.opra === true ? queued.opraServed?.tier : undefined) ?? context.cloudOpraServed?.tier;
|
|
627
|
+
return held !== undefined && held !== tier;
|
|
628
|
+
}
|
|
629
|
+
function reseedWrunSourceSessionAtServedTier(context) {
|
|
630
|
+
const { chartIndex, indicatorId } = context;
|
|
631
|
+
queuedSourceFrames.delete(context);
|
|
632
|
+
try {
|
|
633
|
+
cutWrunReplayRows(wrunChartHostEnv().chart.instance(chartIndex), indicatorId, Number.NEGATIVE_INFINITY);
|
|
634
|
+
}
|
|
635
|
+
catch (error) {
|
|
636
|
+
console.warn(`[wrun] the served-tier reseed could not take '${indicatorId}' off the chart:`, error);
|
|
637
|
+
}
|
|
638
|
+
suspendWrunOverlayLiveSession(indicatorId);
|
|
639
|
+
noteWrunLiveIntakeEvent(indicatorId, { kind: 'rebuild' });
|
|
640
|
+
void rerunWrunOverlayForChartWave(indicatorId, { reason: 'live-rebuild' })?.catch(() => undefined);
|
|
641
|
+
}
|
|
597
642
|
/**
|
|
598
643
|
* The frames queued for `replaced`, a session the pass replaced with `context` over the same row source, go to
|
|
599
644
|
* `context` when both stand for the same calculation (`WrunSourceFedSession.generation`: a page of the held source):
|
|
@@ -680,8 +725,16 @@ function coalesceWrunRowFrames(held, next) {
|
|
|
680
725
|
: {}),
|
|
681
726
|
// The cloud's OPRA mark survives the fold: either frame's stamps the overlay before the tail lands.
|
|
682
727
|
...(next.opra === true || held.opra === true ? { opra: true } : {}),
|
|
728
|
+
// The receipt of the newest frame that carried the mark (its rows are the newest): its tier, or none.
|
|
729
|
+
...coalescedOpraServed(held, next),
|
|
683
730
|
};
|
|
684
731
|
}
|
|
732
|
+
/** The receipt a fold of two frames carries: the newer frame's when it carried the OPRA mark (none when it named no
|
|
733
|
+
* tier), else the held frame's (a frame without the mark says nothing of OPRA). */
|
|
734
|
+
function coalescedOpraServed(held, next) {
|
|
735
|
+
const served = next.opra === true ? next.opraServed : held.opraServed;
|
|
736
|
+
return served !== undefined ? { opraServed: served } : {};
|
|
737
|
+
}
|
|
685
738
|
/** A frame's handle records with their bar stamps moved by `offset` rows. */
|
|
686
739
|
function rebaseWrunFrameHandles(handles, offset) {
|
|
687
740
|
return handles.map((record) => ({
|
|
@@ -1581,6 +1634,11 @@ export async function advanceWrunReplaySession(indicatorId, ohlcvRows) {
|
|
|
1581
1634
|
if (wrunSourceFedContexts.has(context))
|
|
1582
1635
|
return 'skipped';
|
|
1583
1636
|
const newestTs = Number(ohlcvRows[ohlcvRows.length - 1][0]);
|
|
1637
|
+
// The session's flow and snapshot row lanes reach the step's cursor first (SKYLIT-PARITY L6a): the tail, and a
|
|
1638
|
+
// bar-count reseed, read the bars the step reveals off their buffers. One the session cannot extend reopens it.
|
|
1639
|
+
const owed = wrunReplayRowLaneExtensions(context.rowLanes, context.coveredThroughTs, newestTs);
|
|
1640
|
+
if (owed.length > 0 && !(await extendWrunReplayRowLanes(context, owed, newestTs)))
|
|
1641
|
+
return 'skipped';
|
|
1584
1642
|
if (wrunLiveContextReadsBarCount(context) && newestTs > context.lastRowTs)
|
|
1585
1643
|
return 'reseed';
|
|
1586
1644
|
const ledger = ledgerFor(indicatorId);
|
|
@@ -1613,6 +1671,51 @@ export async function advanceWrunReplaySession(indicatorId, ohlcvRows) {
|
|
|
1613
1671
|
ledger.inFlight = false;
|
|
1614
1672
|
}
|
|
1615
1673
|
}
|
|
1674
|
+
/**
|
|
1675
|
+
* A replay session's flow and snapshot row lanes extended to a step's cursor (SKYLIT-PARITY L6a): the replay run read
|
|
1676
|
+
* each through its cursor (wrun-row-lanes.util `replayCursorMs`), so the bars a step reveals are asked now, at the
|
|
1677
|
+
* step's cursor, from the bar after each lane's coverage (`wrunReplayRowLaneExtensions`; the lane's replay memo answers
|
|
1678
|
+
* the bars it already landed), merged into the lane's buffer (`mergeWrunReplayRowLaneRows`), and its coverage moves to
|
|
1679
|
+
* the cursor. The step then computes them as it computes every other lane's: the replay record's coverage stays its
|
|
1680
|
+
* window's end, so no step reopens the session for its row lanes. False when an ask failed or was not confirmed whole
|
|
1681
|
+
* (no memo keeps its bars, so the reopened run asks them again), when another drain holds the session, or when the
|
|
1682
|
+
* session moved meanwhile: the step reopens the session then.
|
|
1683
|
+
*/
|
|
1684
|
+
async function extendWrunReplayRowLanes(context, owed, cursorTs) {
|
|
1685
|
+
const ledger = ledgerFor(context.indicatorId);
|
|
1686
|
+
if (ledger.inFlight)
|
|
1687
|
+
return false;
|
|
1688
|
+
const tc = wrunChartHostEnv().chart.instance(context.chartIndex);
|
|
1689
|
+
const meta = tc?.metadata?.find((candidate) => candidate.id === context.indicatorId);
|
|
1690
|
+
if (meta === undefined)
|
|
1691
|
+
return false;
|
|
1692
|
+
const generation = context.generation;
|
|
1693
|
+
ledger.inFlight = true;
|
|
1694
|
+
try {
|
|
1695
|
+
for (const { key, fromTs } of owed) {
|
|
1696
|
+
const heard = { confirmed: true };
|
|
1697
|
+
const rows = await fetchWrunRowLaneReconcile(context, ledger, key, fromTs, cursorTs + 1, meta, {
|
|
1698
|
+
cursorMs: cursorTs,
|
|
1699
|
+
onUnconfirmed: () => {
|
|
1700
|
+
heard.confirmed = false;
|
|
1701
|
+
},
|
|
1702
|
+
});
|
|
1703
|
+
if (!wrunLiveContextCurrent(context, generation) || !heard.confirmed)
|
|
1704
|
+
return false;
|
|
1705
|
+
const merged = mergeWrunReplayRowLaneRows(context.rowLaneRows?.[key], rows);
|
|
1706
|
+
setLaneRows(context, key, merged);
|
|
1707
|
+
context.coveredThroughTs[key] = cursorTs;
|
|
1708
|
+
}
|
|
1709
|
+
return true;
|
|
1710
|
+
}
|
|
1711
|
+
catch (error) {
|
|
1712
|
+
console.warn(`[wrun] replay row lane extension failed for '${context.indicatorId}':`, error);
|
|
1713
|
+
return false;
|
|
1714
|
+
}
|
|
1715
|
+
finally {
|
|
1716
|
+
ledger.inFlight = false;
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1616
1719
|
/**
|
|
1617
1720
|
* A socket row source's live frames (WRUN-PARITY-PLAN C7, plan row 18), the drain's integrate of every
|
|
1618
1721
|
* frame folded since the last one (`queueWrunSourceLiveFrame`): the bars the cloud moved enter the live
|
|
@@ -1671,6 +1774,13 @@ export async function integrateWrunOverlayLiveFrame(indicatorId, frame, cellRows
|
|
|
1671
1774
|
return;
|
|
1672
1775
|
if (!wrunLiveTickEligible(context, generation))
|
|
1673
1776
|
return;
|
|
1777
|
+
// A frame with the mark names the receipt of the rows it carries (contract opra-server-lanes C4): the legend's
|
|
1778
|
+
// served word follows it from this tick on, and a frame naming no tier leaves none (never the account's tier).
|
|
1779
|
+
// The session reads OPRA from here: its debug lines state it (the console provenance).
|
|
1780
|
+
if (frame.opra === true) {
|
|
1781
|
+
noteWrunCloudOpraServed(context, frame.opraServed);
|
|
1782
|
+
context.opraRead = true;
|
|
1783
|
+
}
|
|
1674
1784
|
// The verdict first: a refusal set that moved cuts the sheet again, so the integrate below builds without
|
|
1675
1785
|
// a family the source now leaves out (and with one it serves again).
|
|
1676
1786
|
const recut = await landWrunSourceFrameVerdict(context, meta, frame);
|
|
@@ -2314,8 +2424,9 @@ async function integrateWrunLiveTail(tail) {
|
|
|
2314
2424
|
// ran with, so a tick never flips a `{{label}}` back to the declared ones.
|
|
2315
2425
|
texts: wrunTextParamValuesFromSettings(context.metadata, meta.settings),
|
|
2316
2426
|
// And the legend note (wrun-draft-legend-note.util: the draft's word, an OPRA chain's served
|
|
2317
|
-
// tier off the session's chain acquisition), so a tick
|
|
2318
|
-
|
|
2427
|
+
// tier off the session's chain acquisition, a Cloud session's off its newest frame's receipt), so a tick
|
|
2428
|
+
// never drops it.
|
|
2429
|
+
legendNote: wrunOverlayLegendNote(meta.settings, context.acquisition.options_chain, context.acquisition, context.cloudOpraServed),
|
|
2319
2430
|
position: context.position,
|
|
2320
2431
|
axis: context.axis,
|
|
2321
2432
|
colors: context.colors,
|
|
@@ -2419,7 +2530,12 @@ async function integrateWrunLiveTail(tail) {
|
|
|
2419
2530
|
// The presentation every integrate owes (the full run's twin): the
|
|
2420
2531
|
// nested visibility a full adapter re-apply or a child remount reset,
|
|
2421
2532
|
// and the latest-values snapshot the HUD follows per tick.
|
|
2422
|
-
presentWrunIntegration(context.chartIndex, indicatorId, context.metadata, meta.settings, outputRows, tc, context.sessionSeed?.initArgs, wrunSessionChartNamesOf(context), runSession?.run
|
|
2533
|
+
presentWrunIntegration(context.chartIndex, indicatorId, context.metadata, meta.settings, outputRows, tc, context.sessionSeed?.initArgs, wrunSessionChartNamesOf(context), runSession?.run,
|
|
2534
|
+
// A tick carries the session's rows on: a full run refused since keeps its snapshot, so the
|
|
2535
|
+
// numbers it superseded never come back under its chip.
|
|
2536
|
+
'republish',
|
|
2537
|
+
// The build the chart now shows (applied, or found unchanged against it); a clamped session's covers its window.
|
|
2538
|
+
{ emptyTargets: runResult.emptyTargets, partial: context.window?.partial === true });
|
|
2423
2539
|
context.paintedThroughTs = newestTs;
|
|
2424
2540
|
context.repaintOwed = false;
|
|
2425
2541
|
// The retained range an eviction moved, on the "Cells capped" row (design 5).
|
|
@@ -3244,7 +3360,7 @@ async function askWrunReconcileSourceAnswer(context, ledger, ask, meta) {
|
|
|
3244
3360
|
...(ask.interval === undefined ? wrunReconcileRunIntervalOption(context) : { interval: ask.interval }),
|
|
3245
3361
|
...(ask.nativeRows === true ? { nativeRows: true } : {}),
|
|
3246
3362
|
...(ask.endExclusive === true ? { endExclusive: true } : {}),
|
|
3247
|
-
meter: wrunLiveDownloadMeter(context),
|
|
3363
|
+
meter: ask.meter ?? wrunLiveDownloadMeter(context),
|
|
3248
3364
|
}), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun live reconcile fetch '${ask.type}' (${ask.key}) for '${context.fetchKey}'`);
|
|
3249
3365
|
return Array.isArray(fetched) ? fetched : null;
|
|
3250
3366
|
}
|
|
@@ -3357,8 +3473,11 @@ function wrunReconcileHostGridWindow(context, fromTs, toTs) {
|
|
|
3357
3473
|
* or snapshot lane's under the tier rule on the window's host bars and landed on them, a latest lane's once; through
|
|
3358
3474
|
* its own fetch when it has one, deadline-raced like the chart's. The window opens where the lane's reconcile does
|
|
3359
3475
|
* (`wrunReconcileLaneWindowFrom`: a governed lane's reaches past its plane's embargo). An instance the context does
|
|
3360
|
-
* not hold, or whose lane left the registry, answers empty (which keeps every cached row).
|
|
3361
|
-
|
|
3476
|
+
* not hold, or whose lane left the registry, answers empty (which keeps every cached row). Each ask hands the chart
|
|
3477
|
+
* fetch's verdict, heard on the download charge it makes at its answer, to the read's memo (wrun-row-lanes.util
|
|
3478
|
+
* `ask`). A replay step's read (`replay`, SKYLIT-PARITY L6a) names the replay's cursor (the read keeps its replay
|
|
3479
|
+
* memo, never the add's) and hears the bars no ask confirmed. */
|
|
3480
|
+
async function fetchWrunRowLaneReconcile(context, ledger, laneId, fromTs, toTs, meta, replay) {
|
|
3362
3481
|
const instance = context.rowLanes?.find((candidate) => candidate.key === laneId);
|
|
3363
3482
|
const lane = instance === undefined ? undefined : wrunRowLaneByKey(instance.laneKey);
|
|
3364
3483
|
if (instance === undefined || lane === undefined)
|
|
@@ -3370,19 +3489,43 @@ async function fetchWrunRowLaneReconcile(context, ledger, laneId, fromTs, toTs,
|
|
|
3370
3489
|
: wrunRowLaneChainAsk(lane, recorded, governedMarketDataTier);
|
|
3371
3490
|
const laneFetch = lane.fetch;
|
|
3372
3491
|
const laneFromTs = wrunReconcileLaneWindowFrom(context, laneId, fromTs, toTs);
|
|
3373
|
-
const
|
|
3492
|
+
const window = wrunReconcileHostGridWindow(context, laneFromTs, toTs);
|
|
3493
|
+
const rows = await fetchWrunRowLaneRows(lane, extras, replay === undefined ? window : { ...window, replayCursorMs: replay.cursorMs }, { fromTs: laneFromTs, toTs }, async (askExtras, from, to, whole) => {
|
|
3374
3494
|
if (laneFetch !== undefined) {
|
|
3375
3495
|
ledger.stats.fetches += 1;
|
|
3376
|
-
|
|
3496
|
+
const own = await withWrunDeadline(laneFetch({ extras: askExtras, fromTs: from, toTs: to, intervalMs: context.intervalMs }), WRUN_SOURCE_FETCH_DEADLINE_MS, `wrun live reconcile fetch '${lane.kType}' (${instance.key}) for '${context.fetchKey}'`);
|
|
3497
|
+
// A lane's own fetch rides no chart transport (no synthetic completion): its answer is whole once it resolved.
|
|
3498
|
+
whole?.(true);
|
|
3499
|
+
return own;
|
|
3377
3500
|
}
|
|
3378
|
-
|
|
3501
|
+
let heard;
|
|
3502
|
+
const sessionMeter = wrunLiveDownloadMeter(context);
|
|
3503
|
+
const answer = (await askWrunReconcileSource(context, ledger, {
|
|
3379
3504
|
type: lane.kType,
|
|
3380
3505
|
key: instance.key,
|
|
3381
3506
|
payload: { symbol: 'currentSymbol', exchange: 'currentExchange', ...askExtras },
|
|
3382
3507
|
fromTs: from,
|
|
3383
3508
|
toTs: to,
|
|
3384
3509
|
...(wrunRowLaneFetchOptions(lane) ?? {}),
|
|
3510
|
+
meter: {
|
|
3511
|
+
charge: (charge) => {
|
|
3512
|
+
if (charge.verdict !== undefined)
|
|
3513
|
+
heard = charge.verdict;
|
|
3514
|
+
sessionMeter.charge(charge);
|
|
3515
|
+
},
|
|
3516
|
+
},
|
|
3385
3517
|
}, meta));
|
|
3518
|
+
whole?.(wrunSourceVerdictWhole(heard));
|
|
3519
|
+
return answer;
|
|
3520
|
+
}, {
|
|
3521
|
+
// One download budget per add (wrun-row-lane-add-memo.util): the live start and every reconcile reuse what the
|
|
3522
|
+
// add's budgeted run landed, keep what it cut partial, and ask only the rest (a new bar, a bar still forming).
|
|
3523
|
+
...(wrunDownloadBudgetCutOn()
|
|
3524
|
+
? {
|
|
3525
|
+
addMemo: { key: wrunRowLaneAddKey(context.chartIndex, context.indicatorId, laneId), role: 'live' },
|
|
3526
|
+
}
|
|
3527
|
+
: {}),
|
|
3528
|
+
...(replay !== undefined ? { onUnconfirmed: replay.onUnconfirmed } : {}),
|
|
3386
3529
|
});
|
|
3387
3530
|
return rows;
|
|
3388
3531
|
}
|
|
@@ -4916,7 +5059,8 @@ function publishWrunDebugTick(context, outputRows) {
|
|
|
4916
5059
|
if (wrunDebugSlotIndex(context.metadata) === undefined)
|
|
4917
5060
|
return;
|
|
4918
5061
|
const store = wrunChartHostEnv().chart.chartStore();
|
|
4919
|
-
|
|
5062
|
+
// 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 });
|
|
4920
5064
|
}
|
|
4921
5065
|
export function __resetWrunLiveTickForTests() {
|
|
4922
5066
|
for (const state of tickStates.values()) {
|