@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
|
@@ -107,9 +107,9 @@ import { scheduleWrunLaneGroups } from './run-schedule/wrun-lane-groups.util.js'
|
|
|
107
107
|
import { serveWrunOwnCandles } from './run-schedule/wrun-own-candles.util.js';
|
|
108
108
|
import { wrunPollClassReadsChain, wrunRowClassReadsChain } from './run-schedule/wrun-gate-reader-warm.util.js';
|
|
109
109
|
import { wrunPollLaneByKey, wrunPollLanesOfClass } from './sources/registry.js';
|
|
110
|
-
import { wrunRowLaneByKey, wrunRowLaneOfClass } from './sources/row-lane-registry.js';
|
|
110
|
+
import { wrunRowLaneByKey, wrunRowLaneOfClass, wrunRowLanes } from './sources/row-lane-registry.js';
|
|
111
111
|
import { isWrunRowLaneId } from './sources/wrun-row-lane.types.js';
|
|
112
|
-
import { fetchWrunRowLaneRows, planWrunRowLanes, wrunRowLaneChainAsk, wrunRowLaneFetchOptions, wrunRowLaneInstanceReadsOpra, wrunRowLaneRequired, wrunRunSourceReachFromMs, } from './sources/wrun-row-lanes.util.js';
|
|
112
|
+
import { fetchWrunRowLaneRows, planWrunRowLanes, wrunRowLaneChainAsk, wrunRowLaneAddKey, wrunRowLaneFetchOptions, wrunRowLaneInstanceReadsOpra, wrunRowLaneRequired, wrunRowLanesReplayBounded, wrunRunSourceReachFromMs, } from './sources/wrun-row-lanes.util.js';
|
|
113
113
|
import { wrunOpraLanePayloadFields } from './wrun-opra-lane.util.js';
|
|
114
114
|
import { WRUN_LANE_REFUSED_SETTLE_REASON, wrunLaneRefusedCodeOf } from './wrun-lane-refusal.leaf.js';
|
|
115
115
|
import { TRADES_HISTORY_MAX_CELLS } from '../../kscript-data/controls/live-trades-merge.util.js';
|
|
@@ -118,7 +118,7 @@ import { liveBucketStartsInRange, liveBucketVenueOf } from '../chart/live-bucket
|
|
|
118
118
|
import { hostBucketResolverFor } from '../chart/host-bar-placement.util.js';
|
|
119
119
|
import { indexHostFetchTierMs, sourceRowsStraddleHostBars } from '../chart/index-host-tier.util.js';
|
|
120
120
|
import { isWrunPollLaneId, wrunPollCoinGateSeed, } from './sources/wrun-poll-lane.types.js';
|
|
121
|
-
import { fetchWrunPollLaneHostGridRows, planWrunPollLanes, wrunLaneRowsRequired, wrunPollLaneChainAsk, wrunPollLaneFetchFrom, wrunPollLaneFetchOptions, wrunPollLaneFetchTo, wrunPollLaneInstanceReadsOpra, wrunPollLaneRequired, wrunPollLaneValuelessInput, } from './sources/wrun-poll-lanes.util.js';
|
|
121
|
+
import { fetchWrunPollLaneHostGridRows, planWrunPollLanes, resolveWrunOptionSettingKnobs, wrunChainLaneContext, wrunLaneRowsRequired, wrunPollLaneChainAsk, wrunPollLaneFetchFrom, wrunPollLaneFetchOptions, wrunPollLaneFetchTo, wrunPollLaneInstanceReadsOpra, wrunPollLaneRequired, wrunPollLaneValuelessInput, } from './sources/wrun-poll-lanes.util.js';
|
|
122
122
|
import { wrunDailyLaneFetchFrom, wrunDailyLaneFetchTo } from './wrun-daily-lane.util.js';
|
|
123
123
|
import { assertWrunEtfFlowCoin, planWrunEtfFlowColumns, planWrunEtfFlowLane, resolveWrunEtfFlowTickers, WRUN_ETF_FLOW_INTERVAL_KEY, wrunEtfFlowAnswer, zipWrunEtfFlowRows, } from './wrun-etf-flow-lane.util.js';
|
|
124
124
|
import { planWrunOptionSummaryLane, WRUN_OPTION_SUMMARY_LANES, wrunOptionSummaryAskExtras, wrunOptionSummaryAskKey, zipWrunOptionSummaryRows, } from './wrun-option-summary-lane.util.js';
|
|
@@ -157,6 +157,8 @@ import { wrunSheetWithSettings, wrunVisibilityOwnedOutputs } from './wrun-color-
|
|
|
157
157
|
import { wrunSheetDrawsOnlyStatsStrip, wrunStatsStripSettings } from './wrun-stats-strip.util.js';
|
|
158
158
|
import { planWrunHeldLanes } from './wrun-held-lanes.util.js';
|
|
159
159
|
import { createWrunDownloadMeter, wrunDownloadAnswerSize, } from './wrun-download-meter.util.js';
|
|
160
|
+
import { createWrunLaneDownloadMeter, wrunDownloadKitInterval, wrunDownloadMarketOf, wrunDownloadPlanKeyOf, wrunDownloadPlanReadBytes, wrunRunDownloadMode, wrunRunDownloadReads, } from './wrun-download-plan.util.js';
|
|
161
|
+
import { FeatureFlag } from '../../constants/feature-flags.constants.js';
|
|
160
162
|
import { clearedColorCustomizationFlags } from '../chart/color-customization.leaf.js';
|
|
161
163
|
import { WRUN_LATEST_HISTORY_LENGTH } from './wrun-latest-history.leaf.js';
|
|
162
164
|
import { resolveChartPricePrecision } from '../chart/price-precision.util.js';
|
|
@@ -174,9 +176,10 @@ import { getMarketKind } from '../chart/marketKind.util.js';
|
|
|
174
176
|
import { isCmeGoverned } from '../chart/cme-realtime.util.js';
|
|
175
177
|
import { wrunBarSessionFactsResolver, wrunBarVenueOf } from '../chart/wrun-bar-session-facts.util.js';
|
|
176
178
|
import { wrunPresentIsPartial } from './wrun-present-bits.util.js';
|
|
177
|
-
import { assertWrunPinnedLegVenues, partitionWrunLegsByVenue, wrunLegFetchedRowReaders, wrunLegRidesNativeRows, wrunPinnedLegRefusalOf, wrunPinVenueVerdict, } from './wrun-pin-venues.util.js';
|
|
179
|
+
import { assertWrunPinnedLegVenues, partitionWrunLegsByVenue, wrunLegFetchedRowReaders, wrunLegRidesNativeRows, wrunPinMarketsOf, wrunPinnedLegRefusalOf, wrunPinVenueVerdict, } from './wrun-pin-venues.util.js';
|
|
178
180
|
import { annotateWrunErrorFailureRow, annotateWrunErrorIndicatorId, isWrunOverlayPausedError, isWrunQuarantinedError, isWrunWorkerPoisonError, WrunChartGoneError, WrunDeadlineError, WrunIntegrationError, WrunNoBarsError, WrunOverlayPausedError, WrunSourceDataUnavailableError, WrunVenueBlockedError, } from './wrun-registry-errors.util.js';
|
|
179
|
-
import { createKScriptVenueBlockedError, isKScriptDisplayBlockedOnExchange, isOfficialWrunOverlay, isOpraUserScriptRun, } from '../chart/kscript-venue-policy.util.js';
|
|
181
|
+
import { createKScriptVenueBlockedError, isKScriptDisplayBlockedOnExchange, isOfficialWrunOverlay, isOpraUserScriptCandidate, isOpraUserScriptRun, payloadTouchesOpraVenue, } from '../chart/kscript-venue-policy.util.js';
|
|
182
|
+
import { isOpraUserScriptsFlagOn } from '../chart/opra-user-scripts-gate.util.js';
|
|
180
183
|
import { governedMarketDataTier, governedOptionSummaryTier } from '../v2/governed-tier.leaf.js';
|
|
181
184
|
import { awaitWrunChildOverlays, mountWrunChildOverlays, prepareWrunHeatmapWindowLanding, WrunStaleLandingError, } from './wrun-panel-mount.util.js';
|
|
182
185
|
import { planWrunFormingPreRoll, planWrunIntrabarLegFetch, planWrunLegFetch, wrunClampedLegDiagnostics, wrunIntrabarServedNotes, wrunLegFetchReads, } from './wrun-leg-fetch.util.js';
|
|
@@ -185,6 +188,8 @@ import { resolveWrunTapeAcquisition, WRUN_TAPE_INTERVAL_UNSUPPORTED_CODE, WRUN_T
|
|
|
185
188
|
import { wrunChartSession, wrunLegCandleClose, wrunPrimaryRowBounds } from './wrun-leg-close.util.js';
|
|
186
189
|
import { isWrunRowSourceTransientError, wrunRowBatchDeliveredSheet, wrunRowSourceSettingsLeftBy, } from './wrun-row-source.js';
|
|
187
190
|
import { wrunOverlayOpraStamped } from './wrun-cloud-opra-stamp.util.js';
|
|
191
|
+
// The run's one options market (the row lanes' planner holds the module on this graph already).
|
|
192
|
+
import { decideWrunRunOptionsMarket, noteWrunRunOptionsMarket, wrunDecidedOptionsExchange, } from './derived-roots.util.js';
|
|
188
193
|
import { wrunRowSourceFor } from './wrun-row-source-factory.js';
|
|
189
194
|
import { __resetWrunSocketSessionLossesForTests, noteWrunSocketSessionLoss, wrunSocketSessionLossCause, wrunSocketSessionLossCount, } from './wrun-socket-session-losses.util.js';
|
|
190
195
|
import { isWrunRunMountOnChart, raiseWrunSandboxLoading, wrunRowBatchCellRows, } from './wrun-sandbox-row-source.js';
|
|
@@ -197,7 +202,7 @@ import { serverNowMs } from '../auth/server-clock.util.js';
|
|
|
197
202
|
import { aggregateOhlcvRows } from '../../utils/replay/replay-buffer-math.js';
|
|
198
203
|
import { isWrunReplayRunCurrent, noteWrunReplayRun, wrunReplayRunPlanOf, } from './wrun-replay-lane.util.js';
|
|
199
204
|
import { cutWrunReplayRowsAfterApply } from './wrun-replay-rows.util.js';
|
|
200
|
-
import {
|
|
205
|
+
import { builtinPortOf } from './wrun-builtin-twin.util.js';
|
|
201
206
|
import { WRUN_HISTORY_WARMUP_MAX_BARS, wrunDeclaredWarmupBars, wrunDeclaredWarmupEndTs, wrunHistoryWarmupBars, } from './wrun-declared-warmup.util.js';
|
|
202
207
|
import { wrunLaneWarmupBars, wrunLaneWarmupFromMs } from './wrun-lane-warmup.util.js';
|
|
203
208
|
import { orderWrunFirstRunHistory } from './wrun-first-run-depth.util.js';
|
|
@@ -454,20 +459,43 @@ export async function runWrunOverlayOnChart(target) {
|
|
|
454
459
|
chartMetadata,
|
|
455
460
|
});
|
|
456
461
|
const provenance = meta.settings;
|
|
457
|
-
//
|
|
458
|
-
//
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
//
|
|
462
|
+
// The run's console provenance, captured before anything computes (`computed.opra`): a run on an OPRA contract
|
|
463
|
+
// chart reads OPRA candles whatever its lanes read.
|
|
464
|
+
if (payloadTouchesOpraVenue(chartExchange))
|
|
465
|
+
computed.opra = true;
|
|
466
|
+
// A run reading options decides its ONE options market here (derived-roots.util `decideWrunRunOptionsMarket`):
|
|
467
|
+
// where the options list on OPRA (a stock, an OPRA contract, a known stock twin) or the overlay's last read was
|
|
468
|
+
// OPRA's (its provenance stamp), it waits, bounded, for the `opra` flag the plane and its stop reasons are judged
|
|
469
|
+
// by (FE-REASON-CHIPS review): a restore can run before the map hydrates, and unhydrated, the map would read the
|
|
470
|
+
// plane closed and the lanes "not on your account". Under a lit flag (or the stamp) it waits, bounded, for the
|
|
471
|
+
// chart's stock twin answer, so a twin restored before its answer reads its stock's OPRA chain; then the market,
|
|
472
|
+
// its plane and its stop are read once, and every planner, the options chain lane, the download plan and the host
|
|
473
|
+
// fill of this run read that decision (a run never mixes planes; a later twin answer reruns it).
|
|
462
474
|
const readsOpraOptions = target.metadata.inputs.some((input) => target.metadata.inputSources[input.name]?.source === 'options_chain') ||
|
|
463
475
|
wrunSheetReadsOpraLane(target.metadata);
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
476
|
+
// A run the `opra-user-scripts` flag may open the OPRA plane to (a browser run the viewer wrote or added) waits,
|
|
477
|
+
// bounded, for the flag map before an OPRA wall reads it, where one stands ahead: on an OPRA contract chart (the
|
|
478
|
+
// display wall), or where the run's options decision rides the OPRA plane (the chain wall: a US stock or ETF
|
|
479
|
+
// chart, a stock twin). A restore can run before the map hydrates, and an unhydrated map reads closed. The wait
|
|
480
|
+
// starts beside the options decision (both ride the one flag fetch); every other run never waits on the map.
|
|
481
|
+
const userScriptsHydration = isOpraUserScriptCandidate(provenance) && (payloadTouchesOpraVenue(chartExchange) || readsOpraOptions)
|
|
482
|
+
? wrunChartHostEnv()
|
|
483
|
+
.market.loadOptionsGate()
|
|
484
|
+
.then(async (gate) => {
|
|
485
|
+
await gate.awaitOpraUserScriptsFlagHydration();
|
|
486
|
+
return gate;
|
|
487
|
+
})
|
|
488
|
+
.catch(() => undefined)
|
|
489
|
+
: undefined;
|
|
490
|
+
const options = readsOpraOptions
|
|
491
|
+
? await decideWrunRunOptionsMarket(chartMetadata, wrunOverlayOpraStamped(meta))
|
|
492
|
+
: undefined;
|
|
493
|
+
if (userScriptsHydration !== undefined && (payloadTouchesOpraVenue(chartExchange) || options?.plane === 'opra')) {
|
|
494
|
+
const gate = await userScriptsHydration;
|
|
495
|
+
// The bound ran out with the flag still dark: the walls refuse this run now, and a flag that lands later judges
|
|
496
|
+
// the walled user-script overlays again (web: opra-options-gate.util `armOpraUserScriptsRejudge`).
|
|
497
|
+
if (!isOpraUserScriptsFlagOn())
|
|
498
|
+
gate?.armOpraUserScriptsRejudge?.();
|
|
471
499
|
}
|
|
472
500
|
if (isKScriptDisplayBlockedOnExchange(chartExchange, provenance)) {
|
|
473
501
|
throw new WrunVenueBlockedError(createKScriptVenueBlockedError(String(chartExchange)).message);
|
|
@@ -541,7 +569,7 @@ export async function runWrunOverlayOnChart(target) {
|
|
|
541
569
|
}
|
|
542
570
|
}
|
|
543
571
|
else {
|
|
544
|
-
await computeWrunOverlayOverLiveContext(marketTarget, (runTarget) => computeAndIntegrateWrunOverlay(runTarget, tc, meta, refusal, computed, { chartIndex: target.chartIndex, mountEpoch, tc }, { chartMetadata, isCurrent, official, opraUserScripts }));
|
|
572
|
+
await computeWrunOverlayOverLiveContext(marketTarget, (runTarget) => computeAndIntegrateWrunOverlay(runTarget, tc, meta, refusal, computed, { chartIndex: target.chartIndex, mountEpoch, tc }, { chartMetadata, isCurrent, official, opraUserScripts, ...(options !== undefined ? { options } : {}) }));
|
|
545
573
|
}
|
|
546
574
|
integrated = true;
|
|
547
575
|
computed.stage = 'applied';
|
|
@@ -627,6 +655,7 @@ export async function runWrunOverlayOnChart(target) {
|
|
|
627
655
|
else {
|
|
628
656
|
await surfaceWrunRunFailureOnLegend(target.chartIndex, target.indicatorId, error, {
|
|
629
657
|
outputNames,
|
|
658
|
+
opra: computed.opra === true,
|
|
630
659
|
refusalContext: refusal.ctx,
|
|
631
660
|
token: refusalAttempt,
|
|
632
661
|
isCurrent,
|
|
@@ -811,8 +840,9 @@ export async function surfaceWrunRunFailureOnLegend(chartIndex, indicatorId, err
|
|
|
811
840
|
const trap = wrunRuntimeTrapDiagnostic(error, context);
|
|
812
841
|
if (trap && WRUN_RUN_FAILURE_ROW_CODES.has(trap.code)) {
|
|
813
842
|
// The write waits on the store's module, so the rejection can outrun it: it rides the error, and the
|
|
814
|
-
// editor's Run awaits it before it reads the row (wrunErrorFailureRowWritten).
|
|
815
|
-
|
|
843
|
+
// editor's Run awaits it before it reads the row (wrunErrorFailureRowWritten). The author's abort text can
|
|
844
|
+
// carry what the run computed: a run over OPRA data marks the row (every console export strips it).
|
|
845
|
+
const written = publishWrunRuntimeTrapDiagnostic(chartIndex, indicatorId, context.opra === true ? { ...trap, opra: true } : trap);
|
|
816
846
|
annotateWrunErrorFailureRow(error, written);
|
|
817
847
|
await written;
|
|
818
848
|
if (isCurrent())
|
|
@@ -947,6 +977,12 @@ const WRUN_CRYPTO_VENUE_KINDS = new Set(['crypto', 'dex', 'hip3', 'hip4']);
|
|
|
947
977
|
/** Whether a sheet reads, or may read, an OPRA source lane: a poll lane's `opra`, a row lane's `governed: 'opra'`, a
|
|
948
978
|
* chain lane of either kind (its chain lists on OPRA on a US stock or OPRA contract chart). The run head's flag wait,
|
|
949
979
|
* the OPRA-plane predicate a lane's admission and wall read, and the OPRA provenance writer follow it. */
|
|
980
|
+
/** Whether a pin names a market on the OPRA plane: any market its `exchange|symbol` names (a literal pin is one). */
|
|
981
|
+
function wrunPinReadsOpra(market) {
|
|
982
|
+
if (market === undefined)
|
|
983
|
+
return false;
|
|
984
|
+
return wrunPinMarketsOf(market.exchange ?? '', market.symbol ?? '').some((leg) => payloadTouchesOpraVenue(leg.exchange));
|
|
985
|
+
}
|
|
950
986
|
function wrunSheetReadsOpraLane(metadata) {
|
|
951
987
|
return wrunPollPlanReadsChain(metadata) || wrunRowPlanReadsChain(metadata);
|
|
952
988
|
}
|
|
@@ -989,17 +1025,20 @@ function mergeWrunLanePlans(a, b) {
|
|
|
989
1025
|
};
|
|
990
1026
|
}
|
|
991
1027
|
/** The OPRA-plane predicate an OPRA lane's admission reads (`governedOptionPlane(metadata) === 'opra'`: a US stock or
|
|
992
|
-
* ETF chart under either venue spelling while the `opra` flag is lit, an OPRA contract chart
|
|
993
|
-
* known reason a chart whose options list on OPRA is off the plane
|
|
994
|
-
* the plane router's `chart-kind`), which the planners' notes and
|
|
995
|
-
*
|
|
996
|
-
|
|
1028
|
+
* ETF chart under either venue spelling while the `opra` flag is lit, an OPRA contract chart, a stock twin reading its
|
|
1029
|
+
* stock's chain) and, beside it, the known reason a chart whose options list on OPRA is off the plane
|
|
1030
|
+
* (`opraOptionPlaneStop`: the flag check's `flag-off`, the plane router's `chart-kind`), which the planners' notes and
|
|
1031
|
+
* refusals say instead of "no such feed here". Both judge a market by its exchange and symbol: the run's own chart
|
|
1032
|
+
* market reads the run's one decision (`options`, the head's), never the seam again, and any other market is judged
|
|
1033
|
+
* through the gate. Loaded only when the sheet reads such a lane (the gate module reaches the flag store). */
|
|
1034
|
+
async function wrunOpraPlaneFacts(metadata, options) {
|
|
997
1035
|
if (!wrunSheetReadsOpraLane(metadata))
|
|
998
1036
|
return undefined;
|
|
999
1037
|
const { governedOptionPlane, opraOptionPlaneStop } = await wrunChartHostEnv().market.loadOptionsGate();
|
|
1038
|
+
const decided = (exchange, symbol) => options !== undefined && (options.chart.exchange ?? '') === exchange && (options.chart.symbol ?? '') === symbol;
|
|
1000
1039
|
return {
|
|
1001
|
-
isOpraPlaneExchange: (exchange) => governedOptionPlane({ exchange }) === 'opra',
|
|
1002
|
-
opraPlaneStop: (exchange) => opraOptionPlaneStop({ exchange }),
|
|
1040
|
+
isOpraPlaneExchange: (exchange, symbol) => decided(exchange, symbol) ? options?.plane === 'opra' : governedOptionPlane({ exchange, symbol }) === 'opra',
|
|
1041
|
+
opraPlaneStop: (exchange, symbol) => decided(exchange, symbol) ? options?.opraStop : opraOptionPlaneStop({ exchange, symbol }),
|
|
1003
1042
|
};
|
|
1004
1043
|
}
|
|
1005
1044
|
export function isWrunCryptoVenueExchange(exchange) {
|
|
@@ -1118,13 +1157,257 @@ function wrunSeededRefusal(seed, details, ctx, stamp) {
|
|
|
1118
1157
|
const raised = attachWrunRefusal(new Error(details), seed);
|
|
1119
1158
|
return wrunRefusalFor(stamp === undefined ? raised : stampWrunRefusalTelemetry(raised, stamp), ctx);
|
|
1120
1159
|
}
|
|
1121
|
-
/**
|
|
1122
|
-
*
|
|
1160
|
+
/** A row lane's read its row budget cut (`onBudgetCut`, wrun-row-lanes.util): the newest bars that fit read whole,
|
|
1161
|
+
* the older ones partial, so the run drew fewer bars of that lane than the chart shows. */
|
|
1162
|
+
export const WRUN_ROW_BUDGET_CUT_CODE = 'WRUN_ROW_BUDGET_CUT';
|
|
1163
|
+
/** The rows the run seam owns for its row budget cuts: replaced by every full run, cleared by a run that cut nothing. */
|
|
1164
|
+
export const WRUN_ROW_BUDGET_ROW_CODES = new Set([WRUN_ROW_BUDGET_CUT_CODE]);
|
|
1165
|
+
/** The legend's localized sentence of a cut over its facts (`{ n }`, the bars kept, its plural choice). */
|
|
1166
|
+
export const WRUN_ROW_BUDGET_CUT_NOTE_KEY = 'wrun.rowBudget.cut';
|
|
1167
|
+
/**
|
|
1168
|
+
* The legend note rows of a run's row budget cuts, one per row lane instance its budget cut: warnings in the run-owned
|
|
1169
|
+
* set `WRUN_ROW_BUDGET_ROW_CODES`, `message` the technical words (Copy details, the console), `details` the facts the
|
|
1170
|
+
* legend's sentence reads (`WRUN_ROW_BUDGET_CUT_NOTE_KEY`: `{ n }`) beside the lane and the cut. A note, never a
|
|
1171
|
+
* refusal: the run drew its newest bars, and without it a package that drew 30 bars of a long chart (Strike
|
|
1172
|
+
* Footprint) said nothing about why. Empty for no cut, which is what clears the rows of an earlier run.
|
|
1173
|
+
*/
|
|
1174
|
+
export function wrunRowBudgetCutDiagnostics(cuts) {
|
|
1175
|
+
return [...cuts].map((cut) => ({
|
|
1176
|
+
stage: 'compute',
|
|
1177
|
+
severity: 'warning',
|
|
1178
|
+
code: WRUN_ROW_BUDGET_CUT_CODE,
|
|
1179
|
+
type: 'execution',
|
|
1180
|
+
message: `Row lane '${cut.laneKey}' kept the newest ${cut.keptBars} bars inside its read budget (${cut.maxRows} rows); ` +
|
|
1181
|
+
`${cut.cutBars} older bars read partial, with no cells`,
|
|
1182
|
+
details: {
|
|
1183
|
+
feed: cut.laneKey,
|
|
1184
|
+
n: cut.keptBars,
|
|
1185
|
+
cutBars: cut.cutBars,
|
|
1186
|
+
maxRows: cut.maxRows,
|
|
1187
|
+
...(cut.keptFromTs !== undefined ? { keptFromTs: cut.keptFromTs } : {}),
|
|
1188
|
+
},
|
|
1189
|
+
}));
|
|
1190
|
+
}
|
|
1191
|
+
/** The indicator download budget's two chips (OPTLOAD W3 R2), the source chip family's run-owned codes
|
|
1192
|
+
* (kscript-source-degrade.util `FE_SOURCE_TRIMMED_CODE`, `FE_SOURCE_HEAVY_CODE`, spelled here because the package
|
|
1193
|
+
* names no web module; tests/utility/wrun/wrun-overlay-run.download-budget.spec.ts pins them equal): replaced by every
|
|
1194
|
+
* full run, cleared by a run that kept its budget. */
|
|
1195
|
+
export const WRUN_DOWNLOAD_TRIMMED_CODE = 'FE_SOURCE_TRIMMED';
|
|
1196
|
+
export const WRUN_DOWNLOAD_HEAVY_CODE = 'FE_SOURCE_HEAVY';
|
|
1197
|
+
export const WRUN_DOWNLOAD_BUDGET_ROW_CODES = new Set([
|
|
1198
|
+
WRUN_DOWNLOAD_TRIMMED_CODE,
|
|
1199
|
+
WRUN_DOWNLOAD_HEAVY_CODE,
|
|
1200
|
+
]);
|
|
1201
|
+
/** Bytes as the download chips write them, 1,000,000 a MB: "1 MB", "1.2 MB", "17 MB". */
|
|
1202
|
+
export function wrunDownloadMbText(bytes) {
|
|
1203
|
+
const mb = Math.max(0, bytes) / 1_000_000;
|
|
1204
|
+
const text = mb >= 10 ? String(Math.round(mb)) : String(Math.round(mb * 10) / 10);
|
|
1205
|
+
return `${text} MB`;
|
|
1206
|
+
}
|
|
1207
|
+
/** A bar's stamp as the trimmed chip names it, on the UTC clock: "2026-10-22 14:00 UTC". */
|
|
1208
|
+
function wrunDownloadDateText(ts) {
|
|
1209
|
+
const iso = new Date(ts).toISOString();
|
|
1210
|
+
return `${iso.slice(0, 10)} ${iso.slice(11, 16)} UTC`;
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* The download budget's legend rows of one full run (R2), info rows in the run-owned set
|
|
1214
|
+
* `WRUN_DOWNLOAD_BUDGET_ROW_CODES`, still text in the source chip family's coverage group (never a spinner, never a
|
|
1215
|
+
* toast; runtime-diagnostics.util words them from `details`, the feeds by `feedKeys` where a lane has feed words):
|
|
1216
|
+
* - `FE_SOURCE_TRIMMED` ("Newest bars only"), when the budget cut a read: the feeds it cut, the oldest bar all of them
|
|
1217
|
+
* still read (`date`, `keptFromTs`: the newest of the cuts' oldest kept bars) and the budget;
|
|
1218
|
+
* - `FE_SOURCE_HEAVY` ("Large download"), when the run downloaded more than its budget and cut nothing (one snapshot):
|
|
1219
|
+
* the feed that downloaded the most, the size and the budget.
|
|
1220
|
+
* Empty with the flag off, or for a run that kept its budget: what clears an earlier run's rows.
|
|
1221
|
+
*/
|
|
1222
|
+
export function wrunDownloadBudgetDiagnostics(args) {
|
|
1223
|
+
if (!args.on)
|
|
1224
|
+
return [];
|
|
1225
|
+
const cuts = [...args.cuts].filter((cut) => cut.budget === 'download' && cut.cutBars > 0);
|
|
1226
|
+
const feedFacts = (feeds) => ({
|
|
1227
|
+
feeds: feeds.map((feed) => feed.label).join(', '),
|
|
1228
|
+
feedKeys: feeds.map((feed) => feed.key ?? feed.label),
|
|
1229
|
+
});
|
|
1230
|
+
if (cuts.length > 0) {
|
|
1231
|
+
const named = new Map(cuts.map((cut) => [cut.laneKey, args.feedOf(cut.laneKey)]));
|
|
1232
|
+
const facts = feedFacts([...named.values()]);
|
|
1233
|
+
const kept = cuts.flatMap((cut) => (cut.keptFromTs !== undefined ? [cut.keptFromTs] : []));
|
|
1234
|
+
const keptFromTs = kept.length > 0 ? Math.max(...kept) : undefined;
|
|
1235
|
+
const cutBars = cuts.reduce((sum, cut) => sum + cut.cutBars, 0);
|
|
1236
|
+
const budgetText = wrunDownloadMbText(args.summary?.budgetBytes ?? 1_000_000);
|
|
1237
|
+
return [
|
|
1238
|
+
{
|
|
1239
|
+
stage: 'fetch',
|
|
1240
|
+
severity: 'info',
|
|
1241
|
+
code: WRUN_DOWNLOAD_TRIMMED_CODE,
|
|
1242
|
+
type: 'execution',
|
|
1243
|
+
message: `${facts.feeds}: ${cutBars} older bars were not loaded` +
|
|
1244
|
+
(keptFromTs !== undefined ? ` (before ${wrunDownloadDateText(keptFromTs)})` : '') +
|
|
1245
|
+
`; loading them would download more than the ${budgetText} one indicator may`,
|
|
1246
|
+
details: {
|
|
1247
|
+
...facts,
|
|
1248
|
+
budget: budgetText,
|
|
1249
|
+
cutBars,
|
|
1250
|
+
...(keptFromTs !== undefined ? { keptFromTs, date: wrunDownloadDateText(keptFromTs) } : {}),
|
|
1251
|
+
},
|
|
1252
|
+
},
|
|
1253
|
+
];
|
|
1254
|
+
}
|
|
1255
|
+
const summary = args.summary;
|
|
1256
|
+
if (summary === undefined || !summary.over)
|
|
1257
|
+
return [];
|
|
1258
|
+
const facts = feedFacts([args.feedOf(summary.topSource ?? '')]);
|
|
1259
|
+
const size = wrunDownloadMbText(summary.bytes);
|
|
1260
|
+
const budgetText = wrunDownloadMbText(summary.budgetBytes);
|
|
1261
|
+
return [
|
|
1262
|
+
{
|
|
1263
|
+
stage: 'fetch',
|
|
1264
|
+
severity: 'info',
|
|
1265
|
+
code: WRUN_DOWNLOAD_HEAVY_CODE,
|
|
1266
|
+
type: 'execution',
|
|
1267
|
+
message: `${facts.feeds} downloaded ${size}, more than the ${budgetText} one indicator should`,
|
|
1268
|
+
details: { ...facts, size, budget: budgetText, bytes: summary.bytes },
|
|
1269
|
+
},
|
|
1270
|
+
];
|
|
1271
|
+
}
|
|
1272
|
+
/** A feed as the download chips name it: a row lane's (by its key, or the K type it asks) label and feed words (the i18n
|
|
1273
|
+
* key the legend says it in), else the source type in words ("orderbook", "volume profile"). */
|
|
1274
|
+
function wrunDownloadFeedOf(laneKeyOrType) {
|
|
1275
|
+
const lane = wrunRowLaneByKey(laneKeyOrType) ?? wrunRowLanes().find((row) => row.kType === laneKeyOrType);
|
|
1276
|
+
if (lane !== undefined)
|
|
1277
|
+
return { label: lane.label, ...(lane.feedWords !== undefined ? { key: lane.feedWords } : {}) };
|
|
1278
|
+
return { label: laneKeyOrType === '' ? 'sources' : laneKeyOrType.replace(/_/g, ' ') };
|
|
1279
|
+
}
|
|
1280
|
+
/** Whether the download budget's cut is on (`FeatureFlag.WrunDownloadBudgetCut`); a host whose flag store is not up
|
|
1281
|
+
* reads off. */
|
|
1282
|
+
export function wrunDownloadBudgetCutOn() {
|
|
1283
|
+
try {
|
|
1284
|
+
return wrunChartHostEnv().user.isFeatureOn(FeatureFlag.WrunDownloadBudgetCut);
|
|
1285
|
+
}
|
|
1286
|
+
catch {
|
|
1287
|
+
return false;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
/** The chart's own celled classes (the row builder's, not a row lane's): history reads the plan shares the budget with,
|
|
1291
|
+
* asked whole for now (the order-flow templates keep their named exceptions; docs/features/kscript/wrun/
|
|
1292
|
+
* wrun-browser-runtime.md, "The download budget"). */
|
|
1293
|
+
const WRUN_DOWNLOAD_BUILTIN_HISTORY_CLASSES = new Set([
|
|
1294
|
+
'book',
|
|
1295
|
+
'volume_profile',
|
|
1296
|
+
'tape',
|
|
1297
|
+
'intrabar',
|
|
1298
|
+
'trade_volume_by_size',
|
|
1299
|
+
]);
|
|
1300
|
+
/**
|
|
1301
|
+
* The run's download plan before any fetch (R2, wrun-download-plan.util): the reads of every input the market demands,
|
|
1302
|
+
* priced with the kit's rule on the run's window and market; a read whose lane forecasts a browser fold
|
|
1303
|
+
* (`WrunRowLaneDescriptor.download.forecastBytes`, FE-FOLD-CAP) priced at the fold's contract rows beside its declared
|
|
1304
|
+
* read, against the chain the chart's options list on (a CME chart's own exchange, the OPRA plane's on a US stock or
|
|
1305
|
+
* ETF chart and on a stock twin reading its stock's chain, a crypto venue's plain chain): the run head's one decision
|
|
1306
|
+
* (`options`) when it holds one, else the chart market judged through the gate. A forecast a refusal stops (an input
|
|
1307
|
+
* refused by name) prices nothing: the plan refuses it by name later.
|
|
1308
|
+
*/
|
|
1309
|
+
async function planWrunRunDownload(args) {
|
|
1310
|
+
const { metadata, window, chart } = args;
|
|
1311
|
+
const inputs = [...metadata.inputs]
|
|
1312
|
+
.sort((a, b) => a.index - b.index)
|
|
1313
|
+
.filter((input) => {
|
|
1314
|
+
const source = metadata.inputSources[input.name];
|
|
1315
|
+
return source !== undefined && source.undemanded !== true && source.source !== 'time';
|
|
1316
|
+
});
|
|
1317
|
+
const reads = wrunRunDownloadReads(metadata, { fromMs: window.fromMs, toMs: window.toMs, intervalMs: window.intervalMs }, inputs.map((input) => input.name), (name) => args.paramValues[name]);
|
|
1318
|
+
const market = wrunDownloadMarketOf({ cme: chart.cme, indexMode: chart.indexMode });
|
|
1319
|
+
const priceWindow = { intervalMs: window.intervalMs, market };
|
|
1320
|
+
// The chain the chart's options list on, for a lane's fold forecast (read once, only when a lane forecasts).
|
|
1321
|
+
let chain;
|
|
1322
|
+
const chainOf = () => {
|
|
1323
|
+
chain ??= (async () => {
|
|
1324
|
+
if (chart.cme)
|
|
1325
|
+
return { chainExchange: chart.exchange, servedTier: governedMarketDataTier(chart.exchange) };
|
|
1326
|
+
const plane = args.options !== undefined
|
|
1327
|
+
? args.options.plane
|
|
1328
|
+
: (await wrunChartHostEnv().market.loadOptionsGate()).governedOptionPlane({
|
|
1329
|
+
exchange: chart.exchange,
|
|
1330
|
+
symbol: chart.symbol,
|
|
1331
|
+
coin: chart.coin,
|
|
1332
|
+
});
|
|
1333
|
+
if (plane === 'opra')
|
|
1334
|
+
return { chainExchange: 'OPRA', servedTier: governedMarketDataTier('OPRA') };
|
|
1335
|
+
return chart.indexMode ? undefined : { chainExchange: chart.exchange };
|
|
1336
|
+
})();
|
|
1337
|
+
return chain;
|
|
1338
|
+
};
|
|
1339
|
+
const params = metadata.params ?? [];
|
|
1340
|
+
const planReads = [];
|
|
1341
|
+
for (const read of reads) {
|
|
1342
|
+
const lane = wrunRowLaneOfClass(read.class);
|
|
1343
|
+
const history = lane !== undefined ? lane.landing.kind !== 'latest' : WRUN_DOWNLOAD_BUILTIN_HISTORY_CLASSES.has(read.class);
|
|
1344
|
+
let projectedBytes;
|
|
1345
|
+
const forecast = lane?.download?.forecastBytes;
|
|
1346
|
+
const inputName = read.inputs[0];
|
|
1347
|
+
const source = inputName === undefined ? undefined : metadata.inputSources[inputName];
|
|
1348
|
+
if (forecast !== undefined && lane !== undefined && source !== undefined && inputName !== undefined) {
|
|
1349
|
+
try {
|
|
1350
|
+
const found = await chainOf();
|
|
1351
|
+
if (found !== undefined) {
|
|
1352
|
+
const chartCtx = {
|
|
1353
|
+
coin: chart.coin,
|
|
1354
|
+
exchange: chart.exchange,
|
|
1355
|
+
symbol: chart.symbol,
|
|
1356
|
+
...(chart.category !== undefined ? { category: chart.category } : {}),
|
|
1357
|
+
intervalMs: window.intervalMs,
|
|
1358
|
+
inputName,
|
|
1359
|
+
sourceClass: lane.sourceClass,
|
|
1360
|
+
indexMode: chart.indexMode,
|
|
1361
|
+
cryptoVenue: isWrunCryptoVenueExchange(chart.exchange),
|
|
1362
|
+
official: args.facts.official,
|
|
1363
|
+
opraUserScripts: args.facts.opraUserScripts,
|
|
1364
|
+
};
|
|
1365
|
+
// A chain lane forecasts the chain its plan reads, under the run's one decision (a twin's stock by its ticker).
|
|
1366
|
+
const ctx = lane.chain !== undefined ? wrunChainLaneContext(chartCtx, args.options) : chartCtx;
|
|
1367
|
+
const resolved = resolveWrunOptionSettingKnobs(ctx, source, params, args.paramValues);
|
|
1368
|
+
const folded = await forecast(resolved, ctx, {
|
|
1369
|
+
chainExchange: found.chainExchange,
|
|
1370
|
+
coin: ctx.coin,
|
|
1371
|
+
...(found.servedTier !== undefined ? { servedTier: found.servedTier } : {}),
|
|
1372
|
+
barOpens: window.barOpens,
|
|
1373
|
+
intervalMs: window.intervalMs,
|
|
1374
|
+
barGrid: window.barGrid,
|
|
1375
|
+
nowMs: window.nowMs,
|
|
1376
|
+
});
|
|
1377
|
+
if (folded !== undefined && folded > 0)
|
|
1378
|
+
projectedBytes = wrunDownloadPlanReadBytes(read, priceWindow) + folded;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
catch {
|
|
1382
|
+
// A knob refused by name prices nothing here: the lane's plan refuses the input by name.
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
planReads.push({ ...read, history, ...(projectedBytes !== undefined ? { projectedBytes } : {}) });
|
|
1386
|
+
}
|
|
1387
|
+
const mode = wrunRunDownloadMode(planReads, { bars: args.windowBars, ...priceWindow });
|
|
1388
|
+
const keyOfInput = new Map();
|
|
1389
|
+
const barRows = new Map();
|
|
1390
|
+
const interval = wrunDownloadKitInterval(window.intervalMs);
|
|
1391
|
+
for (const read of planReads) {
|
|
1392
|
+
const key = wrunDownloadPlanKeyOf(read);
|
|
1393
|
+
for (const name of read.inputs)
|
|
1394
|
+
keyOfInput.set(name, key);
|
|
1395
|
+
const cost = wrunChartHostEnv().sharedHost().wrunDownloadReadCost(read, market, interval);
|
|
1396
|
+
const rows = cost.readsPerBar * cost.rowsPerRead;
|
|
1397
|
+
if (Number.isFinite(rows) && rows > 0)
|
|
1398
|
+
barRows.set(key, rows);
|
|
1399
|
+
}
|
|
1400
|
+
return { mode, keyOfInput, barRows };
|
|
1401
|
+
}
|
|
1402
|
+
/** The note rows a run owns (its legs, its health, its skipped draw calls, its respelled pins, its row budget cuts, its
|
|
1403
|
+
* download budget's chips): a failed run drops them with its verdict. */
|
|
1123
1404
|
const WRUN_REFUSAL_NOTE_ROW_CODES = new Set([
|
|
1124
1405
|
...WRUN_LEG_ROW_CODES,
|
|
1125
1406
|
...WRUN_RUN_HEALTH_ROW_CODES,
|
|
1126
1407
|
...WRUN_DRAW_SKIPPED_ROW_CODES,
|
|
1127
1408
|
...WRUN_PIN_ROW_CODES,
|
|
1409
|
+
...WRUN_ROW_BUDGET_ROW_CODES,
|
|
1410
|
+
...WRUN_DOWNLOAD_BUDGET_ROW_CODES,
|
|
1128
1411
|
]);
|
|
1129
1412
|
/** Whether an output shows on the chart as the settings paint it: the Style page's Visible row,
|
|
1130
1413
|
* else the sheet's `visible`, the sheet alone for an output a boolean param owns (`owned`); a
|
|
@@ -1868,6 +2151,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
1868
2151
|
if (module === null) {
|
|
1869
2152
|
throw new Error(`wrun overlay '${passTarget.indicatorId}': its row source holds no module for the browser lanes`);
|
|
1870
2153
|
}
|
|
2154
|
+
// The browser computes this run under the head's one options market: the facts read beside it follow that decision.
|
|
2155
|
+
if (head.options !== undefined)
|
|
2156
|
+
noteWrunRunOptionsMarket(head.chartMetadata, head.options);
|
|
1871
2157
|
await orderWrunFirstRunHistoryIfOwed(passTarget, tc, meta, head.chartMetadata, head.isCurrent);
|
|
1872
2158
|
// The browser lanes read the overlay's own settings, never the record the source holds: a patch it
|
|
1873
2159
|
// holds carries the same values (the pass derives it from them), and a paint-only save since it
|
|
@@ -2332,8 +2618,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
2332
2618
|
// The run's OPRA facts reach every lane's plan (`ctx.official`, `ctx.opraUserScripts`): an OPRA lane is refused
|
|
2333
2619
|
// by name before its plan for a run that may not read the plane (`mayReadOpra`, opra-official-only:<class>).
|
|
2334
2620
|
// The OPRA-plane predicate an OPRA lane is admitted by (loaded only when the sheet reads one).
|
|
2335
|
-
const opraPlaneFacts = wrunOpraPlaneFacts(target.metadata);
|
|
2621
|
+
const opraPlaneFacts = wrunOpraPlaneFacts(target.metadata, head.options);
|
|
2336
2622
|
const opraFacts = { official: head.official, opraUserScripts: head.opraUserScripts };
|
|
2623
|
+
// Every chain lane plans under the head's one decision: its plane, and a stock twin's lane market (`head.options`).
|
|
2624
|
+
const runOptions = head.options;
|
|
2337
2625
|
// The overlay's current setting values, read once for both planners: an option knob naming a setting
|
|
2338
2626
|
// (`min_premium: "@floor"`) asks with the setting's value, and a settings change re-plans with the new one
|
|
2339
2627
|
// (wrun-poll-lanes.util `resolveWrunOptionSettingKnobs`, before a poll lane's plan and a row lane's facets).
|
|
@@ -2349,7 +2637,12 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
2349
2637
|
symbol: pickText(chartMetadata?.symbol),
|
|
2350
2638
|
category: chartMetadata?.category,
|
|
2351
2639
|
intervalMs: clock.intervalMs,
|
|
2352
|
-
}, checkIsIndexMode, isWrunCryptoVenueExchange, {
|
|
2640
|
+
}, checkIsIndexMode, isWrunCryptoVenueExchange, {
|
|
2641
|
+
...opraFacts,
|
|
2642
|
+
...(opraPlane !== undefined ? opraPlane : {}),
|
|
2643
|
+
paramValues: laneParamValues,
|
|
2644
|
+
...(runOptions !== undefined ? { options: runOptions } : {}),
|
|
2645
|
+
}));
|
|
2353
2646
|
};
|
|
2354
2647
|
// The row lanes' plan (sources/row-lane-registry.ts: one celled descriptor per class), before any of its fetches,
|
|
2355
2648
|
// beside the poll lanes': the OPRA wall, the chart's admission (a governed OPRA lane where the chart's
|
|
@@ -2374,7 +2667,11 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
2374
2667
|
isCryptoVenueExchange: isWrunCryptoVenueExchange,
|
|
2375
2668
|
isOpraPlaneExchange: opraPlane?.isOpraPlaneExchange,
|
|
2376
2669
|
opraPlaneStop: opraPlane?.opraPlaneStop,
|
|
2377
|
-
}, {
|
|
2670
|
+
}, {
|
|
2671
|
+
...opraFacts,
|
|
2672
|
+
paramValues: laneParamValues,
|
|
2673
|
+
...(runOptions !== undefined ? { options: runOptions } : {}),
|
|
2674
|
+
}));
|
|
2378
2675
|
};
|
|
2379
2676
|
const pollPlannedLocal = planPollLanes(false);
|
|
2380
2677
|
const rowPlannedLocal = planRowLanes(false);
|
|
@@ -2387,7 +2684,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
2387
2684
|
// The options_chain lane's identity (wrunOptionsChainLaneExtrasFor), decided before its own fetch like every plan:
|
|
2388
2685
|
// a refusal by name fails the run, never reads as a degraded lane.
|
|
2389
2686
|
const optionsChainPlanned = declaredClasses.has('options_chain')
|
|
2390
|
-
? wrunOptionsChainLaneExtrasFor(target.metadata, chartMetadata, head.official, head.opraUserScripts)
|
|
2687
|
+
? wrunOptionsChainLaneExtrasFor(target.metadata, chartMetadata, head.official, head.opraUserScripts, laneParamValues, head.options)
|
|
2391
2688
|
: Promise.resolve(undefined);
|
|
2392
2689
|
// The OPRA provenance the native options overlays carry (`settings.metaExchange`, the field the chart read
|
|
2393
2690
|
// withholds an overlay by and the tier moves refetch it by, options-overlay-provenance.util): every OPRA lane
|
|
@@ -2524,6 +2821,13 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
2524
2821
|
// bars (a grid leg, a trades leg) and opens a live session at the chart's newest bar: a leg's row still forming
|
|
2525
2822
|
// past that bar lands in it. A replay, a clamped window and a run with no live session have none: their last bar
|
|
2526
2823
|
// is closed.
|
|
2824
|
+
// A leg pinned to the OPRA plane (an option contract's candles or its trades: a run the flag opened the plane to may
|
|
2825
|
+
// pin one, and the dataFetch door admits it) reads OPRA data like the chart's own market would: the run's console
|
|
2826
|
+
// provenance from here (`computed.opra`), before anything computes. A soft-refused trades leg is never asked.
|
|
2827
|
+
if (legs.some((leg) => wrunPinReadsOpra(leg.market)) ||
|
|
2828
|
+
tradeLegLanes.some((lane) => !softRefusedTradeLegs.has(lane) && wrunPinReadsOpra(wrunTradesLegOf(lane)))) {
|
|
2829
|
+
computed.opra = true;
|
|
2830
|
+
}
|
|
2527
2831
|
const formingBarTs = live && replay === undefined && wrunLandsLegsOnBars(legs, tradeLegLanes)
|
|
2528
2832
|
? await wrunFormingBarTsOf(target.chartIndex, clock.intervalMs, chartMetadata)
|
|
2529
2833
|
: null;
|
|
@@ -2540,6 +2844,91 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
2540
2844
|
// A replay run's lanes reach the window's end (the replay's forward runway, as the kScript
|
|
2541
2845
|
// engine's sources do), so its steps read them without a fetch; its bars stop at the cutoff.
|
|
2542
2846
|
const to = replay ? Math.max(chartLastTs, replay.toMs) : chartLastTs;
|
|
2847
|
+
// The download budget's plan (OPTLOAD W3 R2 and FE-FOLD-CAP, `planWrunRunDownload`), behind
|
|
2848
|
+
// `wrun-download-budget-cut` and decided before any lane fetch (`fetchLane` and the row lanes wait on it): at or under
|
|
2849
|
+
// the run's budget the run is whole, today's asks; over it, each history read takes its share and asks its newest
|
|
2850
|
+
// slice first (`rowLaneDownloadOf`). Off, a replay, or a plan that cannot price the sheet: whole, and nothing waits.
|
|
2851
|
+
const downloadBudgetCut = wrunDownloadBudgetCutOn() && replay === undefined;
|
|
2852
|
+
const downloadPlanned = downloadBudgetCut
|
|
2853
|
+
? (async () => {
|
|
2854
|
+
const barGrid = liveBucketVenueOf(chartMetadata);
|
|
2855
|
+
return planWrunRunDownload({
|
|
2856
|
+
metadata: target.metadata,
|
|
2857
|
+
window: {
|
|
2858
|
+
fromMs: from,
|
|
2859
|
+
toMs: barEndMs(to, clock.intervalMs),
|
|
2860
|
+
intervalMs: clock.intervalMs,
|
|
2861
|
+
barOpens: liveBucketStartsInRange(from, to, clock.intervalMs, barGrid),
|
|
2862
|
+
barGrid,
|
|
2863
|
+
nowMs: clock.nowMs,
|
|
2864
|
+
},
|
|
2865
|
+
// The meter's window: the run's budget is the meter's.
|
|
2866
|
+
windowBars: download.summary().windowBars,
|
|
2867
|
+
chart: {
|
|
2868
|
+
exchange: chartExchange ?? '',
|
|
2869
|
+
coin: chartCoin,
|
|
2870
|
+
symbol: chartSymbol,
|
|
2871
|
+
...(typeof chartCategory === 'number' ? { category: chartCategory } : {}),
|
|
2872
|
+
cme: isCmeGoverned(chartExchange),
|
|
2873
|
+
indexMode: checkIsIndexMode(chartExchange ?? ''),
|
|
2874
|
+
},
|
|
2875
|
+
paramValues: laneParamValues,
|
|
2876
|
+
facts: { official: head.official, opraUserScripts: head.opraUserScripts },
|
|
2877
|
+
...(head.options !== undefined ? { options: head.options } : {}),
|
|
2878
|
+
});
|
|
2879
|
+
})().then((plan) => {
|
|
2880
|
+
if (plan.mode.mode === 'budgeted')
|
|
2881
|
+
download.noteBudget({ budgeted: true });
|
|
2882
|
+
if (wrunChartHostEnv().diagnostics.debugEnabled()) {
|
|
2883
|
+
wrunChartHostEnv().diagnostics.debug('wrun-download-plan', {
|
|
2884
|
+
chartIndex: target.chartIndex,
|
|
2885
|
+
indicatorId: target.indicatorId,
|
|
2886
|
+
mode: plan.mode.mode,
|
|
2887
|
+
projectedBytes: Math.round(plan.mode.projectedBytes),
|
|
2888
|
+
budgetBytes: download.budgetBytes,
|
|
2889
|
+
...(plan.mode.mode === 'budgeted' ? { shares: Object.fromEntries(plan.mode.shares) } : {}),
|
|
2890
|
+
});
|
|
2891
|
+
}
|
|
2892
|
+
return plan;
|
|
2893
|
+
}, (error) => {
|
|
2894
|
+
// The plan is advisory: a sheet it cannot price runs whole, as with the flag off.
|
|
2895
|
+
if (wrunChartHostEnv().diagnostics.debugEnabled()) {
|
|
2896
|
+
wrunChartHostEnv().diagnostics.debug('wrun-download-plan-failed', {
|
|
2897
|
+
chartIndex: target.chartIndex,
|
|
2898
|
+
indicatorId: target.indicatorId,
|
|
2899
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2900
|
+
});
|
|
2901
|
+
}
|
|
2902
|
+
return undefined;
|
|
2903
|
+
})
|
|
2904
|
+
: undefined;
|
|
2905
|
+
// A budgeted run's hold on one row lane instance (wrun-row-lanes.util `WrunRowLaneDownload`): the shares of the
|
|
2906
|
+
// inputs it serves, the rows a bar they declare, the lane's fold cap and the read's own meter beside the run's.
|
|
2907
|
+
const rowLaneDownloadOf = (instance, plan) => {
|
|
2908
|
+
if (plan === undefined || plan.mode.mode !== 'budgeted')
|
|
2909
|
+
return undefined;
|
|
2910
|
+
const lane = wrunRowLaneByKey(instance.laneKey);
|
|
2911
|
+
if (lane === undefined || lane.landing.kind === 'latest')
|
|
2912
|
+
return undefined;
|
|
2913
|
+
const keys = new Set(instance.inputIndexes.flatMap((index) => {
|
|
2914
|
+
const key = plan.keyOfInput.get(inputNameAt(index));
|
|
2915
|
+
return key === undefined ? [] : [key];
|
|
2916
|
+
}));
|
|
2917
|
+
if (keys.size === 0)
|
|
2918
|
+
return undefined;
|
|
2919
|
+
let share = 0;
|
|
2920
|
+
let barRows = 0;
|
|
2921
|
+
for (const key of keys) {
|
|
2922
|
+
share += plan.mode.shares.get(key) ?? 0;
|
|
2923
|
+
barRows = Math.max(barRows, plan.barRows.get(key) ?? 0);
|
|
2924
|
+
}
|
|
2925
|
+
return {
|
|
2926
|
+
share,
|
|
2927
|
+
meter: createWrunLaneDownloadMeter(download),
|
|
2928
|
+
...(barRows > 0 ? { declaredBarRows: barRows } : {}),
|
|
2929
|
+
...(lane.download?.fold !== undefined ? { fold: lane.download.fold } : {}),
|
|
2930
|
+
};
|
|
2931
|
+
};
|
|
2543
2932
|
// The lanes the demanded classes read: a trades input asking `currency: "USD"` reads the buy/sell
|
|
2544
2933
|
// lane asked in dollars (`trades_usd`), any other the coin lane (`trades`), so a sheet with a
|
|
2545
2934
|
// units setting fetches each unit it declares, once.
|
|
@@ -2654,6 +3043,10 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
2654
3043
|
// intrabar leg's closes one chart bar past the last row (the forming
|
|
2655
3044
|
// row's finer bars).
|
|
2656
3045
|
fromTs = from, toTs = to) => {
|
|
3046
|
+
// No ask leaves before the download budget's plan decided the run's mode (R2; absent with the flag off).
|
|
3047
|
+
if (downloadPlanned !== undefined)
|
|
3048
|
+
await downloadPlanned;
|
|
3049
|
+
const meter = fetchOptions?.meter ?? download;
|
|
2657
3050
|
const payload = { symbol: 'currentSymbol', exchange: 'currentExchange', ...payloadExtras };
|
|
2658
3051
|
const lane = wrunLiveLaneOfFetchKey(key);
|
|
2659
3052
|
if (lane !== undefined)
|
|
@@ -2682,7 +3075,7 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
2682
3075
|
: null;
|
|
2683
3076
|
if (own !== null) {
|
|
2684
3077
|
// The chart's own rows answer the ask: it downloaded nothing.
|
|
2685
|
-
|
|
3078
|
+
meter.charge({
|
|
2686
3079
|
key: `${target.fetchKey}-${key}`,
|
|
2687
3080
|
kType: type,
|
|
2688
3081
|
verdict: {
|
|
@@ -2712,15 +3105,15 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
2712
3105
|
// A run at another interval: a source naming no interval of its own rides the run interval
|
|
2713
3106
|
// (the kScript engine's rule, runIntervalForSource), one naming its own keeps it.
|
|
2714
3107
|
run && fetchOptions?.interval === undefined
|
|
2715
|
-
? { ...fetchOptions, interval: run.interval, ...sendNotices, meter
|
|
2716
|
-
: { ...fetchOptions, ...sendNotices, meter
|
|
3108
|
+
? { ...fetchOptions, interval: run.interval, ...sendNotices, meter }
|
|
3109
|
+
: { ...fetchOptions, ...sendNotices, meter });
|
|
2717
3110
|
const label = `wrun source fetch '${type}' for '${target.fetchKey}'`;
|
|
2718
3111
|
const fetched = await (request === undefined
|
|
2719
3112
|
? withWrunDeadline(asked, WRUN_SOURCE_FETCH_DEADLINE_MS, label)
|
|
2720
3113
|
: raceWrunSendDeadline(asked, request.bound, label));
|
|
2721
3114
|
// A relay feed's own fetch rides no chart transport and no stamp measures it: its rows are charged their cell bytes.
|
|
2722
3115
|
if (fetchOptions?.ownFetch) {
|
|
2723
|
-
|
|
3116
|
+
meter.charge({ key: `${target.fetchKey}-${key}`, kType: type, ...wrunDownloadAnswerSize(fetched) });
|
|
2724
3117
|
}
|
|
2725
3118
|
// Packed-lane SUCCESS arrives as the packed transport object (only the
|
|
2726
3119
|
// kScript engine worker consumes it un-unpacked); unpack it here, or a
|
|
@@ -3229,6 +3622,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
3229
3622
|
// Each row lane that drew its first slice alone, by the slice's first bar: the live session's reconcile never lands
|
|
3230
3623
|
// rows before it until the fill (`rowLaneFilling`, wrun-live-tick.util `mergeWrunReconcileAnswer`).
|
|
3231
3624
|
const firstSliceFrom = new Map();
|
|
3625
|
+
// Each row lane instance's read its row budget cut (the latest read's, by instance id): the integrate publishes one
|
|
3626
|
+
// legend note per cut (`wrunRowBudgetCutDiagnostics`).
|
|
3627
|
+
const rowBudgetCuts = new Map();
|
|
3232
3628
|
// A first slice's shape in the debug ring (`wrun-row-lane-first-slice`): where the slice starts, how many bars it drew
|
|
3233
3629
|
// from data and how many it holds back as partial until the fill.
|
|
3234
3630
|
const ringFirstSlice = (lane, rows, sliceFromTs) => {
|
|
@@ -3260,27 +3656,79 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
3260
3656
|
: wrunRowLaneChainAsk(lane, instance.extras, governedMarketDataTier);
|
|
3261
3657
|
const laneFetch = lane.fetch;
|
|
3262
3658
|
const tradeDateOf = chartTradeDateOf();
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3659
|
+
// A budgeted run's hold on the read (R2): its share, its slice's declared rows, its fold cap and its own meter.
|
|
3660
|
+
const laneDownload = downloadPlanned === undefined ? undefined : rowLaneDownloadOf(instance, await downloadPlanned);
|
|
3661
|
+
const rows = await fetchWrunRowLaneRows(lane, extras,
|
|
3662
|
+
// A replay run's per-bar lanes end at the replay's cursor (wrun-row-lanes.util `replayCursorMs`).
|
|
3663
|
+
{
|
|
3664
|
+
...hostGridWindow(),
|
|
3665
|
+
...(tradeDateOf !== undefined ? { tradeDateOf } : {}),
|
|
3666
|
+
...(replay !== undefined ? { replayCursorMs: replay.cutoffTs } : {}),
|
|
3667
|
+
}, { fromTs: from, toTs: to }, async (askExtras, fromTs, toTs, whole) => {
|
|
3668
|
+
// The ask's completion for the read's memo (wrun-row-lanes.util `ask`): the chart fetch's verdict, heard on the
|
|
3669
|
+
// download charge it makes at its answer (the read's meter, always bound); none heard is not whole. A lane's own
|
|
3670
|
+
// fetch rides no chart transport (no synthetic completion): its answer is whole once it resolved.
|
|
3671
|
+
let heard;
|
|
3672
|
+
const own = { answered: false };
|
|
3673
|
+
const meter = laneDownload?.meter ?? download;
|
|
3674
|
+
const verdictMeter = {
|
|
3675
|
+
charge: (charge) => {
|
|
3676
|
+
if (charge.verdict !== undefined)
|
|
3677
|
+
heard = charge.verdict;
|
|
3678
|
+
meter.charge(charge);
|
|
3282
3679
|
},
|
|
3283
|
-
}
|
|
3680
|
+
};
|
|
3681
|
+
const rows = (await fetchLane(lane.kType, instance.key, laneFetch
|
|
3682
|
+
? {
|
|
3683
|
+
ownFetch: async (askFrom, askTo) => {
|
|
3684
|
+
const answered = (await laneFetch({
|
|
3685
|
+
extras: askExtras,
|
|
3686
|
+
fromTs: askFrom,
|
|
3687
|
+
toTs: askTo,
|
|
3688
|
+
intervalMs: clock.intervalMs,
|
|
3689
|
+
}));
|
|
3690
|
+
own.answered = true;
|
|
3691
|
+
return answered;
|
|
3692
|
+
},
|
|
3693
|
+
meter: verdictMeter,
|
|
3694
|
+
}
|
|
3695
|
+
: { ...wrunRowLaneFetchOptions(lane), meter: verdictMeter }, { ...askExtras }, fromTs, toTs)) ?? [];
|
|
3696
|
+
whole?.(own.answered || wrunSourceVerdictWhole(heard));
|
|
3697
|
+
return rows;
|
|
3698
|
+
}, {
|
|
3699
|
+
onBudgetCut: (cut) => {
|
|
3700
|
+
rowBudgetCuts.set(instance.key, cut);
|
|
3701
|
+
// The download budget's cut rides the add's attempt (the bars it left unread, the bytes the run spent so far),
|
|
3702
|
+
// and leaves the warm-up evidence unsettled: an output empty over the bars it left unread is no reason to
|
|
3703
|
+
// buy older candles.
|
|
3704
|
+
if (cut.budget === 'download') {
|
|
3705
|
+
download.noteBudget({ cutBars: cut.cutBars, plannedBytes: download.spentBytes() });
|
|
3706
|
+
unsettledLanes.add(instance.key);
|
|
3707
|
+
}
|
|
3708
|
+
},
|
|
3709
|
+
...(laneDownload !== undefined ? { download: laneDownload } : {}),
|
|
3710
|
+
// One download budget per add (wrun-row-lane-add-memo.util): a budgeted run leaves the add a memo of what it
|
|
3711
|
+
// landed and cut, a later run of the add (a loaded-range refresh) reuses it, a whole run drops it.
|
|
3712
|
+
...(downloadBudgetCut
|
|
3713
|
+
? {
|
|
3714
|
+
addMemo: {
|
|
3715
|
+
key: wrunRowLaneAddKey(target.chartIndex, target.indicatorId, instance.key),
|
|
3716
|
+
role: 'run',
|
|
3717
|
+
},
|
|
3718
|
+
}
|
|
3719
|
+
: {}),
|
|
3720
|
+
// The slice's own rows always hold one with data (an empty slice has no early answer), so a lane that must
|
|
3721
|
+
// answer rows never paints off an empty one.
|
|
3722
|
+
...(tradeDateOf === undefined || early === undefined || !firstSlicePaint
|
|
3723
|
+
? {}
|
|
3724
|
+
: {
|
|
3725
|
+
onFirstSlice: (sliceRows, sliceFromTs) => {
|
|
3726
|
+
firstSliceFrom.set(instance.key, sliceFromTs);
|
|
3727
|
+
ringFirstSlice(instance.key, sliceRows, sliceFromTs);
|
|
3728
|
+
early(sliceRows);
|
|
3729
|
+
},
|
|
3730
|
+
}),
|
|
3731
|
+
});
|
|
3284
3732
|
const laneRows = rows;
|
|
3285
3733
|
return wrunRowLaneRequired(target.metadata, instance)
|
|
3286
3734
|
? requireDegradableRows(lane.kType, lane.label, laneRows, instance.key)
|
|
@@ -3722,6 +4170,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
3722
4170
|
const readsOpraPlane = optionsChainExtras?.chainVenue === 'opra' ||
|
|
3723
4171
|
pollLanes.some(pollInstanceReadsOpra) ||
|
|
3724
4172
|
rowLanes.some(rowInstanceReadsOpra);
|
|
4173
|
+
// The plan reads the OPRA plane: the run's console provenance, set before the module computes (`computed.opra`).
|
|
4174
|
+
if (readsOpraPlane)
|
|
4175
|
+
computed.opra = true;
|
|
3725
4176
|
const writeOpraProvenance = await opraProvenanceWriter;
|
|
3726
4177
|
// A degrade entry of a lane this run does not dispatch is settled now: a trades leg the coin switch moved, or a lane
|
|
3727
4178
|
// a setting gate, a unit pick, `needed_by` or the capability rule dropped. No later run of this sheet asks that lane
|
|
@@ -4091,7 +4542,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
4091
4542
|
await marketFactsReady;
|
|
4092
4543
|
if (earningsFactsReady !== undefined)
|
|
4093
4544
|
await earningsFactsReady;
|
|
4094
|
-
const hostFill = wrunHostFillContextFor(tc, chartMetadata?.exchange, clock.intervalMs,
|
|
4545
|
+
const hostFill = wrunHostFillContextFor(tc, chartMetadata?.exchange, clock.intervalMs,
|
|
4546
|
+
// The option multiplier follows the chain this run reads (the head's one options market).
|
|
4547
|
+
wrunReadsMarketFacts(target.metadata) ? wrunRunFactsMarket(chartMetadata, head.options) : undefined, wrunReadsEarningsFacts(target.metadata) ? chartMetadata : undefined);
|
|
4095
4548
|
// The generation this run computes with (C1): the params, the init args and the text settings
|
|
4096
4549
|
// are read under it in this synchronous block, after the lanes fetched.
|
|
4097
4550
|
computed.generation = kScriptSettingsRevision(view.settings);
|
|
@@ -4277,6 +4730,11 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
4277
4730
|
// The pin step's notes and respelled pins: the integrate publishes the notes and lays the pins on its paint.
|
|
4278
4731
|
pinNotes,
|
|
4279
4732
|
respelledPins,
|
|
4733
|
+
// The row budget's cuts of this run's row lane reads: the integrate publishes one note per cut (the download
|
|
4734
|
+
// budget's, `budget: 'download'`, as the trimmed chip).
|
|
4735
|
+
rowBudgetCuts,
|
|
4736
|
+
// The download budget's cut was on for this run (R2): the integrate publishes its chips.
|
|
4737
|
+
downloadBudgetCut,
|
|
4280
4738
|
};
|
|
4281
4739
|
}
|
|
4282
4740
|
/** The refusal seed of an ask its row source merged nothing from (`WrunRowSourceTransientError`): the run
|
|
@@ -4884,7 +5342,7 @@ async function computeAndIntegrateWrunOverlay(runTarget, tc, meta, refusal, comp
|
|
|
4884
5342
|
// reads the landed rows, as everything after it does.
|
|
4885
5343
|
answered: (rows) => {
|
|
4886
5344
|
const ran = host.prepared;
|
|
4887
|
-
return publishWrunDebugOutput(runTarget.chartIndex, runTarget.indicatorId, ran.request.metadata, wrunSandboxLandedRows(ran, rows));
|
|
5345
|
+
return publishWrunDebugOutput(runTarget.chartIndex, runTarget.indicatorId, ran.request.metadata, wrunSandboxLandedRows(ran, rows), { opra: computed.opra === true });
|
|
4888
5346
|
},
|
|
4889
5347
|
};
|
|
4890
5348
|
const record = wrunRowSourceRecordOf(runTarget.metadata, meta);
|
|
@@ -4923,7 +5381,7 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
|
|
|
4923
5381
|
await integrateWrunRowSourceBatch(runTarget, tc, meta, refusal, computed, owner, head, ask, batch);
|
|
4924
5382
|
return;
|
|
4925
5383
|
}
|
|
4926
|
-
const { acquisitionByLane, writeOpraProvenance, readsOpraPlane, bookRows, buySellVolumeRows, buySellVolumeUsdRows, chartExchange, chartFirstTs, chartInterval, chartIntervalMs, chartMetadata, chartNames, chartRows, clampedLegs, clock, computeIdentity, computeSourceRows, cryptoVenue, degraded, emptyLegs, etfFlowRows, evaluatedCandles, fetchedRunBars, fillingFrom, fillingLanes, formingPreRoll, from, fundingRateRows, generationAtStart, hasGoodResult, hasIntrabarLegs, hasLiveCandleLegs, hasPinnedLegs, headWarm, heldCoverage, impliedVolatilityRows, initArgs, intrabarRows, laneHead, laneRun, legs, liquidationRows, live, loadedRows, marketIdentity, missingFeeds, ohlcvRows, openInterestRows, optionsChainRows, paramValues, pinnedCandleRows, pinnedLiveCandleRows, planGeneration, pollLaneRows, pollLanes, rowLaneRows, rowLanes, projection, reason, replay, replayChartRows, replayHeadRows, retainedRowsCap, retainedWindow, rows, run, runBars, runBlockRowsCap, runKey, runRowsPlan, skewRows, strategy, tapeRows, target, textParams, to, tradeLegRows, tradeVolumeBySizeRows, twinAtChart, unservedLanes, unservedLegs, unservedTradeLegs, unsettledLanes, volumeProfileRows, warmupBarsNow, warmupHead, warmupMiss, warmupWall, window, headsDeferred, epoch: generation, pinNotes, respelledPins, } = prepared;
|
|
5384
|
+
const { acquisitionByLane, writeOpraProvenance, readsOpraPlane, bookRows, buySellVolumeRows, buySellVolumeUsdRows, chartExchange, chartFirstTs, chartInterval, chartIntervalMs, chartMetadata, chartNames, chartRows, clampedLegs, clock, computeIdentity, computeSourceRows, cryptoVenue, degraded, emptyLegs, etfFlowRows, evaluatedCandles, fetchedRunBars, fillingFrom, fillingLanes, formingPreRoll, from, fundingRateRows, generationAtStart, hasGoodResult, hasIntrabarLegs, hasLiveCandleLegs, hasPinnedLegs, headWarm, heldCoverage, impliedVolatilityRows, initArgs, intrabarRows, laneHead, laneRun, legs, liquidationRows, live, loadedRows, marketIdentity, missingFeeds, ohlcvRows, openInterestRows, optionsChainRows, paramValues, pinnedCandleRows, pinnedLiveCandleRows, planGeneration, pollLaneRows, pollLanes, rowLaneRows, rowLanes, projection, reason, replay, replayChartRows, replayHeadRows, retainedRowsCap, retainedWindow, rows, run, runBars, runBlockRowsCap, runKey, runRowsPlan, skewRows, strategy, tapeRows, target, textParams, to, tradeLegRows, tradeVolumeBySizeRows, twinAtChart, unservedLanes, unservedLegs, unservedTradeLegs, unsettledLanes, volumeProfileRows, warmupBarsNow, warmupHead, warmupMiss, warmupWall, window, headsDeferred, epoch: generation, pinNotes, respelledPins, rowBudgetCuts, downloadBudgetCut, } = prepared;
|
|
4927
5385
|
// The filling chip (`fillingLanes`, a first-slice picture): raised right before the integrate, lowered if the run
|
|
4928
5386
|
// fails after it.
|
|
4929
5387
|
const fillingGuardKey = overlayExecutionGuardKey(target.chartIndex, target.indicatorId);
|
|
@@ -5107,7 +5565,12 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
|
|
|
5107
5565
|
// lower-pane children mounted): nested output visibility from the sheet
|
|
5108
5566
|
// and the Style page, and the latest-values snapshot the HUD, the legend
|
|
5109
5567
|
// and the hover inspector read.
|
|
5110
|
-
presentWrunIntegration(target.chartIndex, target.indicatorId, sheetNow, meta.settings, outputRows, tc, initArgs, chartNames, run
|
|
5568
|
+
presentWrunIntegration(target.chartIndex, target.indicatorId, sheetNow, meta.settings, outputRows, tc, initArgs, chartNames, run, 'run',
|
|
5569
|
+
// The result the chart shows: applied, or skipped as rendering equal to the mount. Any other skip (a transient
|
|
5570
|
+
// empty answer, nothing to paint) and a sparse run the mounted rows outranked keep the previous picture.
|
|
5571
|
+
integration.applied || (route.action === 'skip' && route.reason === 'render-equal')
|
|
5572
|
+
? { emptyTargets: runResult.emptyTargets, partial: window?.partial === true }
|
|
5573
|
+
: undefined);
|
|
5111
5574
|
await publishWrunStrategyRunResult(target.chartIndex, target.indicatorId, runResult, { tc, meta });
|
|
5112
5575
|
// A run that drew nothing says so: every bar warm-up, or a line NaN on every ready bar,
|
|
5113
5576
|
// used to print the green check over an empty pane. Published on EVERY run (WRUN-REFUSALS
|
|
@@ -5147,6 +5610,19 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
|
|
|
5147
5610
|
...wrunEmptyLegDiagnostics(emptyLegs, refusal.ctx),
|
|
5148
5611
|
...wrunFeedMissingDiagnostics([...missingFeeds, ...(watched.silentOutputs.length > 0 ? emptySeries : [])], refusal.ctx),
|
|
5149
5612
|
]);
|
|
5613
|
+
// A row lane's read its budget cut says so: one note per cut ("Older bars cut by the read budget: showing the
|
|
5614
|
+
// newest N bars"), replaced by every full run and cleared by a run that cut nothing. A read the download budget cut
|
|
5615
|
+
// instead says so through the trimmed chip below (the smaller cut wins, one note per read).
|
|
5616
|
+
const budgetCuts = [...rowBudgetCuts.values()];
|
|
5617
|
+
await publishWrunOwnedDiagnostics(target.chartIndex, target.indicatorId, WRUN_ROW_BUDGET_ROW_CODES, wrunRowBudgetCutDiagnostics(budgetCuts.filter((cut) => cut.budget !== 'download')));
|
|
5618
|
+
// The download budget's chip (R2, behind its flag): "Newest bars only" when it cut a read, "Large download" when
|
|
5619
|
+
// the run passed its budget with nothing to cut; replaced by every full run and cleared by one that kept it.
|
|
5620
|
+
await publishWrunOwnedDiagnostics(target.chartIndex, target.indicatorId, WRUN_DOWNLOAD_BUDGET_ROW_CODES, wrunDownloadBudgetDiagnostics({
|
|
5621
|
+
on: downloadBudgetCut,
|
|
5622
|
+
cuts: budgetCuts,
|
|
5623
|
+
summary: computed.download?.summary(),
|
|
5624
|
+
feedOf: wrunDownloadFeedOf,
|
|
5625
|
+
}));
|
|
5150
5626
|
// A pinned market the run respelled says so (one note per spelling, the saved value unchanged), replaced by
|
|
5151
5627
|
// every run and cleared by a run that respelled nothing.
|
|
5152
5628
|
await publishWrunOwnedDiagnostics(target.chartIndex, target.indicatorId, WRUN_PIN_ROW_CODES, wrunPinRespelledDiagnostics(pinNotes));
|
|
@@ -5197,12 +5673,16 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
|
|
|
5197
5673
|
// asking its tail while the source ladder owns the window.
|
|
5198
5674
|
const degradedLanes = new Set(degraded.map((entry) => entry.lane));
|
|
5199
5675
|
const coveredThroughTs = {};
|
|
5676
|
+
// A replay run read its flow and snapshot row lanes through its cursor (wrun-row-lanes.util `replayCursorMs`):
|
|
5677
|
+
// their coverage is the cursor, and each replay step extends them from there (wrun-live-tick.util).
|
|
5678
|
+
const replayBound = replay === undefined ? undefined : wrunRowLanesReplayBounded(rowLanes);
|
|
5200
5679
|
for (const lane of Object.keys(acquisitionByLane)) {
|
|
5201
5680
|
if (degradedLanes.has(lane))
|
|
5202
5681
|
continue;
|
|
5203
5682
|
// A held lane keeps its session's watermark (the reconcile re-asks from there).
|
|
5204
5683
|
const heldThrough = heldCoverage[lane];
|
|
5205
|
-
|
|
5684
|
+
const laneTo = replay !== undefined && replayBound?.has(lane) === true ? Math.min(to, replay.cutoffTs) : to;
|
|
5685
|
+
coveredThroughTs[lane] = heldThrough !== undefined ? Math.min(heldThrough, laneTo) : laneTo;
|
|
5206
5686
|
}
|
|
5207
5687
|
// A leg's coverage is the clock the run fetched under: every candle
|
|
5208
5688
|
// closed by then is in the buffer (the forming one is dropped).
|
|
@@ -5210,6 +5690,8 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
|
|
|
5210
5690
|
const liveContext = {
|
|
5211
5691
|
chartIndex: target.chartIndex,
|
|
5212
5692
|
indicatorId: target.indicatorId,
|
|
5693
|
+
// The run's console provenance: every debug line the session's ticks and reseeds publish states it.
|
|
5694
|
+
...(computed.opra === true ? { opraRead: true } : {}),
|
|
5213
5695
|
// The current paint (above): the ticks and the reseeds keep the look.
|
|
5214
5696
|
metadata: sheetNow,
|
|
5215
5697
|
title: target.title,
|
|
@@ -5221,6 +5703,10 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
|
|
|
5221
5703
|
fetchKey: target.fetchKey,
|
|
5222
5704
|
outputRows,
|
|
5223
5705
|
computeIdentity,
|
|
5706
|
+
// The version this run executed and the settings revision it computed with: the switch's stand-in capture
|
|
5707
|
+
// stores the picture only under that pin and while the row still carries that revision.
|
|
5708
|
+
version: target.version,
|
|
5709
|
+
settingsRevision: computed.generation,
|
|
5224
5710
|
draft,
|
|
5225
5711
|
runHealthWarned,
|
|
5226
5712
|
marketIdentity,
|
|
@@ -5480,7 +5966,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
|
|
|
5480
5966
|
return;
|
|
5481
5967
|
}
|
|
5482
5968
|
await publishWrunCanvasNotices(target.chartIndex, target.indicatorId, refined);
|
|
5483
|
-
presentWrunIntegration(target.chartIndex, target.indicatorId, sheetAtRefine, mounted.settings, outputRows, chart, initArgs, chartNames, run
|
|
5969
|
+
presentWrunIntegration(target.chartIndex, target.indicatorId, sheetAtRefine, mounted.settings, outputRows, chart, initArgs, chartNames, run,
|
|
5970
|
+
// A later refine of this run's rows: a full run refused since keeps its snapshot.
|
|
5971
|
+
'republish', { emptyTargets: refined.emptyTargets, partial: window?.partial === true });
|
|
5484
5972
|
},
|
|
5485
5973
|
};
|
|
5486
5974
|
scheduleWrunTpoBlockRefine(request);
|
|
@@ -5768,6 +6256,16 @@ async function persistWrunSourceDecidedSide(chartIndex, tc, indicatorId, meta, s
|
|
|
5768
6256
|
console.warn(`[wrun] the side of '${indicatorId}' was not persisted on its record:`, error);
|
|
5769
6257
|
}
|
|
5770
6258
|
}
|
|
6259
|
+
/** The receipt a cloud batch's legend word reads (contract opra-server-lanes C4): the receipt of the rows the batch was
|
|
6260
|
+
* computed from, only while the batch carries the OPRA mark (a result without it is a re-plan off OPRA: no word). */
|
|
6261
|
+
function wrunBatchOpraServed(batch) {
|
|
6262
|
+
return batch.opra === true ? batch.opraServed : undefined;
|
|
6263
|
+
}
|
|
6264
|
+
/** The context field a Cloud session installs with: its receipt (`wrunBatchOpraServed`), or none. */
|
|
6265
|
+
function withWrunCloudOpraServed(batch) {
|
|
6266
|
+
const served = wrunBatchOpraServed(batch);
|
|
6267
|
+
return served !== undefined ? { cloudOpraServed: { ...served } } : {};
|
|
6268
|
+
}
|
|
5771
6269
|
/**
|
|
5772
6270
|
* A batch no browser lane prepared (contract C7: the socket row source's, which the cloud
|
|
5773
6271
|
* computed) integrates from the batch and the chart alone, through the steps every batch takes:
|
|
@@ -5836,7 +6334,9 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
|
|
|
5836
6334
|
const delivered = wrunRowBatchDeliveredSheet(batch.sheet ?? runTarget.metadata, batch.refusals, sectionKinds);
|
|
5837
6335
|
if (wrunReadsMarketFacts(delivered))
|
|
5838
6336
|
await warmWrunMarketFacts(chartMetadata);
|
|
5839
|
-
const hostFill = wrunHostFillContextFor(tc, chartExchange, chartIntervalMs,
|
|
6337
|
+
const hostFill = wrunHostFillContextFor(tc, chartExchange, chartIntervalMs,
|
|
6338
|
+
// No browser lane prepared this batch (contract C7): the cloud computed it off the chart's own market's facts.
|
|
6339
|
+
wrunReadsMarketFacts(delivered) ? wrunCloudFactsMarket(chartMetadata) : undefined);
|
|
5840
6340
|
const chartNames = await resolveWrunChartNames(chartIndex);
|
|
5841
6341
|
const canvasFill = wrunCanvasFillWithSessionBlock(await wrunCanvasHostFillFor(delivered, chartMetadata), delivered, indicatorId, chartMetadata);
|
|
5842
6342
|
const identityLeft = await wrunRunIdentityLeft(chartIndex, tc, meta, marketIdentity);
|
|
@@ -5861,6 +6361,9 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
|
|
|
5861
6361
|
if (batch.opra === true && !(writeOpraProvenance?.(true) === true && wrunOverlayOpraStamped(meta))) {
|
|
5862
6362
|
throw new WrunChartGoneError(`wrun overlay '${indicatorId}' left its chart before its OPRA provenance was stamped (superseded)`);
|
|
5863
6363
|
}
|
|
6364
|
+
// The cloud read OPRA for these rows (its mark): the run's console provenance from here (`computed.opra`).
|
|
6365
|
+
if (batch.opra === true)
|
|
6366
|
+
computed.opra = true;
|
|
5864
6367
|
const heldContext = getWrunOverlayLiveContext(indicatorId);
|
|
5865
6368
|
const window = runTarget.window;
|
|
5866
6369
|
nextWrunCanvasRunSerial(indicatorId);
|
|
@@ -5879,6 +6382,10 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
|
|
|
5879
6382
|
fills: runTarget.fills,
|
|
5880
6383
|
candles: runTarget.candles,
|
|
5881
6384
|
chartNames,
|
|
6385
|
+
// The legend's served word is the receipt of the rows the cloud computed this batch from (contract
|
|
6386
|
+
// opra-server-lanes C4), as a browser run's is its acquisition records': none for a batch without the mark (a
|
|
6387
|
+
// re-plan off OPRA clears it) or naming no tier, never the account's tier.
|
|
6388
|
+
legendNote: wrunOverlayLegendNote(meta.settings, undefined, undefined, wrunBatchOpraServed(batch)),
|
|
5882
6389
|
// The market's size unit (an output its `visible_by` leaves out here mounts nothing) and its dollar unit, as on
|
|
5883
6390
|
// the own run.
|
|
5884
6391
|
...wrunResultMarketUnits(chartMetadata),
|
|
@@ -5931,16 +6438,21 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
|
|
|
5931
6438
|
// The stamp stands until a later result can clear it.
|
|
5932
6439
|
}
|
|
5933
6440
|
}
|
|
5934
|
-
presentWrunIntegration(chartIndex, indicatorId, sheetNow, meta.settings, outputRows, tc, wrunSourceInitArgsOf(sheetNow, paramValues), chartNames, null
|
|
6441
|
+
presentWrunIntegration(chartIndex, indicatorId, sheetNow, meta.settings, outputRows, tc, wrunSourceInitArgsOf(sheetNow, paramValues), chartNames, null, 'run',
|
|
6442
|
+
// The picture the chart shows, as on the browser lane (integrateWrunRunAsk).
|
|
6443
|
+
integration.applied || (route.action === 'skip' && route.reason === 'render-equal')
|
|
6444
|
+
? { emptyTargets: runResult.emptyTargets, partial: window?.partial === true }
|
|
6445
|
+
: undefined);
|
|
5935
6446
|
await publishWrunStrategyRunResult(chartIndex, indicatorId, runResult, { tc, meta });
|
|
5936
|
-
await publishWrunDebugOutput(chartIndex, indicatorId, sheetNow, outputRows);
|
|
6447
|
+
await publishWrunDebugOutput(chartIndex, indicatorId, sheetNow, outputRows, { opra: computed.opra === true });
|
|
5937
6448
|
const draft = isWrunDraftOverlaySettings(meta.settings);
|
|
5938
6449
|
const { health } = wrunChartRunHealth(sheetNow, meta.settings, outputRows, false, wrunChartSizeUnit(chartMetadata));
|
|
5939
6450
|
const runHealthWarned = await publishWrunRunHealth(chartIndex, indicatorId, wrunRunHealthRowsFor(health, draft, wrunNothingReadyRefusal(health, refusal.ctx)));
|
|
5940
|
-
// A run computed elsewhere served every leg it read: no leg note of an earlier run stands,
|
|
5941
|
-
//
|
|
6451
|
+
// A run computed elsewhere served every leg it read: no leg note of an earlier run stands, no pin note this
|
|
6452
|
+
// lane respelled (the cloud resolves its own pins), and no row budget cut of a browser read.
|
|
5942
6453
|
await publishWrunUnservedLegDiagnostics(chartIndex, indicatorId, []);
|
|
5943
6454
|
await publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_PIN_ROW_CODES, []);
|
|
6455
|
+
await publishWrunOwnedDiagnostics(chartIndex, indicatorId, WRUN_ROW_BUDGET_ROW_CODES, []);
|
|
5944
6456
|
const indicatorName = typeof delivered.name === 'string' ? delivered.name : '';
|
|
5945
6457
|
await publishWrunSourceVerdict(chartIndex, indicatorId, meta, batch, indicatorName);
|
|
5946
6458
|
await publishWrunCanvasNotices(chartIndex, indicatorId, runResult);
|
|
@@ -6028,6 +6540,8 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
|
|
|
6028
6540
|
fetchKey: runTarget.fetchKey,
|
|
6029
6541
|
outputRows: sessionRows,
|
|
6030
6542
|
computeIdentity,
|
|
6543
|
+
version: runTarget.version,
|
|
6544
|
+
settingsRevision: computed.generation,
|
|
6031
6545
|
draft,
|
|
6032
6546
|
runHealthWarned,
|
|
6033
6547
|
marketIdentity,
|
|
@@ -6037,6 +6551,10 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
|
|
|
6037
6551
|
generation: nextWrunOverlayLiveGeneration(indicatorId),
|
|
6038
6552
|
intervalMs: chartIntervalMs,
|
|
6039
6553
|
acquisition: {},
|
|
6554
|
+
// The receipt the session holds now (its newest answer's): every tick's legend word reads it.
|
|
6555
|
+
...withWrunCloudOpraServed(session ?? batch),
|
|
6556
|
+
// The run's console provenance: every debug line the session's ticks publish states it.
|
|
6557
|
+
...(computed.opra === true ? { opraRead: true } : {}),
|
|
6040
6558
|
carrySeed: emptyWrunInputCarry(),
|
|
6041
6559
|
fedBuckets: {},
|
|
6042
6560
|
pushEligible: false,
|
|
@@ -6273,7 +6791,7 @@ function askWrunWarmupBackfillIfOwed(args) {
|
|
|
6273
6791
|
ringDetails.unsettledLanes = [...unsettledLanes];
|
|
6274
6792
|
const { sheet, paramValues, runRows, intervalMs } = args.declaredWarmup;
|
|
6275
6793
|
const creditedBars = args.declaredWarmup.creditedBars ?? 0;
|
|
6276
|
-
const declaredWarmupBars =
|
|
6794
|
+
const declaredWarmupBars = builtinPortOf(meta.settings) === undefined ? wrunDeclaredWarmupBars(sheet, paramValues) : null;
|
|
6277
6795
|
if (declaredWarmupBars !== null)
|
|
6278
6796
|
ringDetails.declaredWarmupBars = declaredWarmupBars;
|
|
6279
6797
|
if (declaredWarmupBars !== null && creditedBars > 0)
|
|
@@ -7296,8 +7814,10 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
|
|
|
7296
7814
|
noteWrunLiveIntakeEvent(indicatorId, { kind: 'reseed' });
|
|
7297
7815
|
noteWrunLiveIntakeEvent(indicatorId, { kind: 'session-start', live: wrunLiveOf(outputRows) });
|
|
7298
7816
|
// The committed rows' debug log, published with the rows (a failed
|
|
7299
|
-
// render below owes a repaint, not a console rewrite).
|
|
7300
|
-
await publishWrunDebugOutput(context.chartIndex, indicatorId, context.metadata, outputRows
|
|
7817
|
+
// render below owes a repaint, not a console rewrite), under the session's own provenance.
|
|
7818
|
+
await publishWrunDebugOutput(context.chartIndex, indicatorId, context.metadata, outputRows, {
|
|
7819
|
+
opra: context.opraRead === true,
|
|
7820
|
+
});
|
|
7301
7821
|
try {
|
|
7302
7822
|
// The canvas fill (G1) for the session's market; a mirror entry that aged
|
|
7303
7823
|
// out keeps the block the session was drawn with (same market, same grid).
|
|
@@ -7350,7 +7870,7 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
|
|
|
7350
7870
|
cutWrunReplayRowsAfterApply(tc, indicatorId);
|
|
7351
7871
|
}
|
|
7352
7872
|
rememberWrunSessionCanvasFill(context, canvasFill);
|
|
7353
|
-
presentWrunIntegration(context.chartIndex, indicatorId, context.metadata, meta.settings, outputRows, tc, context.sessionSeed?.initArgs, chartNames, runSession?.run);
|
|
7873
|
+
presentWrunIntegration(context.chartIndex, indicatorId, context.metadata, meta.settings, outputRows, tc, context.sessionSeed?.initArgs, chartNames, runSession?.run, 'run', { emptyTargets: runResult.emptyTargets, partial: clamped !== undefined });
|
|
7354
7874
|
// The committed result's canvas notices replace the published ones (none clears them).
|
|
7355
7875
|
await publishWrunSessionCanvasNotices(context, runResult);
|
|
7356
7876
|
// The session's retained range on the "Cells capped" row (design 5); a clamped window's session keeps it.
|
|
@@ -7716,6 +8236,11 @@ function wrunUnservedLaneReason(type, exchange, coin, service) {
|
|
|
7716
8236
|
return (`the ${type} source lane answers nothing on ${market} (a quote-priced perpetual market serves its quote ` +
|
|
7717
8237
|
'candles, funding and open interest only)');
|
|
7718
8238
|
}
|
|
8239
|
+
// The kind table's US equity row (index-mode-admission.util): a stock print has no aggressor side.
|
|
8240
|
+
if (getMarketKind(exchange) === 'tradfi') {
|
|
8241
|
+
return (`the ${type} source lane answers nothing on ${market} (a US equity market's prints carry no aggressor ` +
|
|
8242
|
+
'side, so it serves no buy/sell volume)');
|
|
8243
|
+
}
|
|
7719
8244
|
return (`the ${type} source lane answers nothing on ${market} (a forex or commodity market serves no volume ` +
|
|
7720
8245
|
'profile, buy/sell volume, order book, implied volatility or skew)');
|
|
7721
8246
|
case 'coin':
|
|
@@ -7861,29 +8386,43 @@ function wrunOptionsChainExtrasGoverned(extras) {
|
|
|
7861
8386
|
* today's scope itself only for an answer that is not B's rows. A crypto
|
|
7862
8387
|
* chain keeps its plain reader (OPTLOAD W3 decision 1): its payload is
|
|
7863
8388
|
* today's, byte for byte.
|
|
8389
|
+
*
|
|
8390
|
+
* Contract F: an input whose `underlying` names another root (a setting
|
|
8391
|
+
* naming one read through `paramValues`) reads that root's chain instead
|
|
8392
|
+
* (derived-roots.util `wrunUnderlyingOptionsChainDecision`), its identity
|
|
8393
|
+
* naming the root (`chainUnderlying`).
|
|
8394
|
+
*
|
|
8395
|
+
* A stock twin (`options`, the run head's one decision, derived-roots.util
|
|
8396
|
+
* `decideWrunRunOptionsMarket`): its chain is its stock's, held on the OPRA
|
|
8397
|
+
* plane by the twin's ticker (the lane market, `options.lane`) and decided
|
|
8398
|
+
* over the twin's stock (`auto` reads OPRA, and so meets the OPRA wall for a
|
|
8399
|
+
* user script; a pinned crypto word still reads that venue's chain of the
|
|
8400
|
+
* coin). Without a decision the chart's own market reads exactly as before.
|
|
7864
8401
|
*/
|
|
7865
|
-
async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official, opraUserScripts) {
|
|
7866
|
-
const [{ decideWrunLaneChainIdentity, resolveWrunChartChain }, { hasDeribitOptions }, { resolveWrunOptionsChainCryptoVenues }, { WRUN_OPTION_VIEWS_ONE_ASK_CODE, WRUN_OPTION_VIEWS_ONE_EXPIRIES_CODE, wrunHeldOpraPlaneChain, wrunOptionsChainImplicitViewFields, wrunOptionViewLaneFields, wrunOptionViewsOfSource, wrunOptionViewsUnion, },] = await Promise.all([
|
|
8402
|
+
async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official, opraUserScripts, paramValues, options) {
|
|
8403
|
+
const [{ decideWrunLaneChainIdentity, resolveWrunChartChain }, { hasDeribitOptions }, { resolveWrunOptionsChainCryptoVenues }, { WRUN_OPTION_VIEWS_ONE_ASK_CODE, WRUN_OPTION_VIEWS_ONE_EXPIRIES_CODE, wrunHeldOpraPlaneChain, wrunOptionsChainImplicitViewFields, wrunOptionViewLaneFields, wrunOptionViewsOfSource, wrunOptionViewsUnion, }, { wrunUnderlyingOptionsChainDecision },] = await Promise.all([
|
|
7867
8404
|
import('./sources/opra-option-lanes.util.js'),
|
|
7868
8405
|
wrunChartHostEnv().market.loadDeribitOptions(),
|
|
7869
8406
|
wrunChartHostEnv().market.loadOptionsChainVenues(),
|
|
7870
8407
|
import('./wrun-option-views.util.js'),
|
|
8408
|
+
import('./derived-roots.util.js'),
|
|
7871
8409
|
]);
|
|
7872
8410
|
const market = chartMetadata;
|
|
7873
8411
|
const pick = (value) => (typeof value === 'string' ? value : undefined);
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
coin:
|
|
7878
|
-
|
|
8412
|
+
// The market the chain is read as: a stock twin's lane market (its stock on the OPRA plane), else the chart's own.
|
|
8413
|
+
const lane = options?.lane;
|
|
8414
|
+
const chartMarket = lane !== undefined
|
|
8415
|
+
? { exchange: lane.exchange, symbol: lane.symbol, coin: lane.coin }
|
|
8416
|
+
: { exchange: pick(market?.exchange) ?? '', symbol: pick(market?.symbol) ?? '', coin: pick(market?.coin) ?? '' };
|
|
7879
8417
|
// The chart's chain by the ONE resolution every chain class reads (opra-option-lanes.util `resolveWrunChartChain`,
|
|
7880
|
-
// over the chart's own metadata, its category included: `option_surface` reads the same one
|
|
7881
|
-
//
|
|
7882
|
-
// is the decision's evidence for `cme-directory`
|
|
7883
|
-
//
|
|
7884
|
-
// plane's own by coin, read off the plane itself
|
|
7885
|
-
|
|
7886
|
-
const
|
|
8418
|
+
// over the chart's own metadata, its category included: `option_surface` reads the same one, and over the run's one
|
|
8419
|
+
// options market when the head decided it). A chain directory's own failure on a chart its plane governs (CME
|
|
8420
|
+
// futures; a US stock, ETF or OPRA contract chart under the opra flag) is the decision's evidence for `cme-directory`
|
|
8421
|
+
// or `opra-directory` (a service that did not answer, Retry), never a guess at another chain; any other resolver
|
|
8422
|
+
// failure fails the run as before. On the OPRA plane the chain is the plane's own by coin, read off the plane itself
|
|
8423
|
+
// (O1): no directory read stands before the lane's ask. The plane verdict is the head's when it decided one.
|
|
8424
|
+
const held = await wrunHeldOpraPlaneChain(chartMarket.exchange, chartMarket.coin, options !== undefined ? options.plane === 'opra' : undefined, chartMarket.symbol);
|
|
8425
|
+
const chain = held ?? (await resolveWrunChartChain(chartMetadata, options));
|
|
7887
8426
|
const { chartSource } = chain;
|
|
7888
8427
|
const marketLabel = `${pick(market?.exchange) ?? 'currentExchange'}/${pick(market?.symbol) ?? 'currentSymbol'}`;
|
|
7889
8428
|
const chainInputs = metadata.inputs.filter((input) => metadata.inputSources[input.name]?.source === 'options_chain');
|
|
@@ -7894,20 +8433,16 @@ async function wrunOptionsChainLaneExtrasFor(metadata, chartMetadata, official,
|
|
|
7894
8433
|
.filter(isWrunOptionsChainCryptoVenueWord)),
|
|
7895
8434
|
],
|
|
7896
8435
|
chartSource,
|
|
7897
|
-
|
|
8436
|
+
// A stock twin's crypto venue words ask the listing for its stock's ticker (the lane market's coin).
|
|
8437
|
+
chartCoin: lane?.coin ?? pick(market?.coin),
|
|
7898
8438
|
});
|
|
7899
8439
|
let resolved;
|
|
7900
8440
|
for (const input of chainInputs) {
|
|
7901
8441
|
const source = metadata.inputSources[input.name];
|
|
8442
|
+
const who = { ...chartMarket, inputName: input.name, official, opraUserScripts, marketLabel };
|
|
7902
8443
|
// The ONE venue decision every chain class reads (`decideWrunLaneChainIdentity`), so a package reading
|
|
7903
|
-
// `option_surface` beside the chain reads one venue.
|
|
7904
|
-
const decision = decideWrunLaneChainIdentity({ chain, cryptoVenues, deribitListed: hasDeribitOptions }, source.venue,
|
|
7905
|
-
...chartMarket,
|
|
7906
|
-
inputName: input.name,
|
|
7907
|
-
official,
|
|
7908
|
-
opraUserScripts,
|
|
7909
|
-
marketLabel,
|
|
7910
|
-
});
|
|
8444
|
+
// `option_surface` beside the chain reads one venue; over another root's chain for an `underlying` root.
|
|
8445
|
+
const decision = (await wrunUnderlyingOptionsChainDecision(source, who, metadata.params ?? [], paramValues, chain)) ?? decideWrunLaneChainIdentity({ chain, cryptoVenues, deribitListed: hasDeribitOptions }, source.venue, who);
|
|
7911
8446
|
// The decision's reason picks the record's seed (WRUN-REFUSALS U3a step 6).
|
|
7912
8447
|
if (!decision.ok)
|
|
7913
8448
|
throw wrunOptionsChainRefusalError(decision);
|
|
@@ -8132,12 +8667,42 @@ function wrunInferredMainTick(tc) {
|
|
|
8132
8667
|
* a price unit: it only picks the axis precision here. With `market` (the
|
|
8133
8668
|
* chart metadata), the market's facts ride too (`kind`, `pointValue`, `zone`,
|
|
8134
8669
|
* `quoteIsUsd`, `sessionOpen`: wrunMarketFactsFor, over the directory row a
|
|
8135
|
-
* run of a package declaring `kind` or `quote_is_usd` awaited first)
|
|
8670
|
+
* run of a package declaring `kind` or `quote_is_usd` awaited first), the
|
|
8671
|
+
* option multiplier read off the market whose options the chart reads: the
|
|
8672
|
+
* market's own `optionsExchange` when the caller names it (a run's one
|
|
8673
|
+
* decision), else the one the latest run on that chart market decided
|
|
8674
|
+
* (derived-roots.util `wrunDecidedOptionsExchange`: a stock twin reading its
|
|
8675
|
+
* stock's OPRA chain reads 100 on its live ticks too). With
|
|
8136
8676
|
* `earnings` (the chart metadata, passed for a sheet that declares an
|
|
8137
8677
|
* earnings fact), the issuer's earnings facts ride too (`earningsNextMs`,
|
|
8138
8678
|
* `earningsPrevMs`, `earningsSession`: wrunEarningsFactsFor, over the earnings
|
|
8139
8679
|
* window a run of such a package warmed first).
|
|
8140
8680
|
*/
|
|
8681
|
+
/** A facts market with the exchange its options read (`WrunFactsMarket.optionsExchange`): the caller's when it names
|
|
8682
|
+
* one, else the latest run's decision on that chart market (`wrunDecidedOptionsExchange`), else none (its own). */
|
|
8683
|
+
function wrunFactsMarketWithOptions(market) {
|
|
8684
|
+
if (market.optionsExchange !== undefined)
|
|
8685
|
+
return market;
|
|
8686
|
+
const optionsExchange = wrunDecidedOptionsExchange(market);
|
|
8687
|
+
return optionsExchange === undefined ? market : { ...market, optionsExchange };
|
|
8688
|
+
}
|
|
8689
|
+
/** The chart metadata as the facts read it beside the run's one options market (the head's decision): the exchange the
|
|
8690
|
+
* chart's options read rides along, so `market.option_multiplier()` follows the chain the run reads. */
|
|
8691
|
+
function wrunRunFactsMarket(chartMetadata, options) {
|
|
8692
|
+
const optionsExchange = options?.market.exchange;
|
|
8693
|
+
return chartMetadata === undefined || typeof optionsExchange !== 'string'
|
|
8694
|
+
? chartMetadata
|
|
8695
|
+
: { ...chartMetadata, optionsExchange };
|
|
8696
|
+
}
|
|
8697
|
+
/** The chart metadata as a batch the cloud computed reads its facts (`integrateWrunRowSourceBatch`): the chart's own
|
|
8698
|
+
* market's, named outright so no browser run's decision on the chart stands in (`wrunDecidedOptionsExchange`). The
|
|
8699
|
+
* server resolves the chain of the chart market it is sent (follow-up: the backend's stock twin rule). */
|
|
8700
|
+
export function wrunCloudFactsMarket(chartMetadata) {
|
|
8701
|
+
const exchange = chartMetadata?.exchange;
|
|
8702
|
+
return chartMetadata === undefined || typeof exchange !== 'string'
|
|
8703
|
+
? chartMetadata
|
|
8704
|
+
: { ...chartMetadata, optionsExchange: exchange };
|
|
8705
|
+
}
|
|
8141
8706
|
export function wrunHostFillContextFor(tc, chartExchange, intervalMs, market, earnings) {
|
|
8142
8707
|
const engine = tc;
|
|
8143
8708
|
let engineTick;
|
|
@@ -8156,7 +8721,7 @@ export function wrunHostFillContextFor(tc, chartExchange, intervalMs, market, ea
|
|
|
8156
8721
|
...(tickSize !== undefined ? { tickSize } : {}),
|
|
8157
8722
|
pricePrecision,
|
|
8158
8723
|
...wrunChartContextHostFill(tc, intervalMs),
|
|
8159
|
-
...(market !== undefined ? wrunMarketFactsFor(market) : {}),
|
|
8724
|
+
...(market !== undefined ? wrunMarketFactsFor(wrunFactsMarketWithOptions(market)) : {}),
|
|
8160
8725
|
// The issuer's earnings facts: the browser run's alone (a hosted lane's host fill never carries them).
|
|
8161
8726
|
...(earnings !== undefined ? wrunEarningsFactsFor(earnings) : {}),
|
|
8162
8727
|
};
|
|
@@ -8232,16 +8797,35 @@ export function wrunOutputRowsOnChartBars(outputRows, chart, run) {
|
|
|
8232
8797
|
}
|
|
8233
8798
|
return shown;
|
|
8234
8799
|
}
|
|
8800
|
+
/**
|
|
8801
|
+
* The Style targets the latest-values snapshot names as drawing nothing (WrunLatestSnapshot.emptyTargets, the Style
|
|
8802
|
+
* page's silent lines): the applied result's own, judged over the whole loaded range. A result computed over a
|
|
8803
|
+
* window of it (`partial`) speaks for that window only, and the mount keeps its rows outside, so it can clear a
|
|
8804
|
+
* target (values in the window) but never mark one: the previous snapshot's targets it still finds empty. A
|
|
8805
|
+
* republish that built no result (`applied` absent) carries the previous snapshot's forward.
|
|
8806
|
+
*/
|
|
8807
|
+
export function wrunSnapshotEmptyTargets(previous, applied) {
|
|
8808
|
+
if (applied === undefined)
|
|
8809
|
+
return [...(previous ?? [])];
|
|
8810
|
+
const judged = applied.emptyTargets ?? [];
|
|
8811
|
+
if (applied.partial !== true)
|
|
8812
|
+
return [...judged];
|
|
8813
|
+
const kept = new Set(previous ?? []);
|
|
8814
|
+
return judged.filter((target) => kept.has(target));
|
|
8815
|
+
}
|
|
8235
8816
|
/**
|
|
8236
8817
|
* What follows every successful integrate, the full run's, the reseed's and
|
|
8237
8818
|
* the tick's (after the lower-pane children mounted): the nested output
|
|
8238
8819
|
* visibility the sheet (`visible: false`) and the Style page's Visible rows
|
|
8239
8820
|
* ask for (U9's `applyWrunOutputVisibility`, parent and children), and the
|
|
8240
8821
|
* latest-values snapshot the HUD layer, the legend and the hover inspector
|
|
8241
|
-
* read (`publishWrunLatestValues
|
|
8242
|
-
*
|
|
8243
|
-
*
|
|
8244
|
-
*
|
|
8822
|
+
* read (`publishWrunLatestValues`; a republish leaves a refused full run's
|
|
8823
|
+
* snapshot as it is, `WrunLatestPublishOrigin`) with the applied result's
|
|
8824
|
+
* `emptyTargets` (the Style page dims those lines), then the Indicator store's
|
|
8825
|
+
* seen note for a registry Indicator (`noteWrunRegistryRun`: once a page and
|
|
8826
|
+
* day, the maker's private reach; both row sources pass here). Presentation
|
|
8827
|
+
* only: a failure here is logged, never a second failure over a run that
|
|
8828
|
+
* rendered.
|
|
8245
8829
|
*/
|
|
8246
8830
|
export function presentWrunIntegration(chartIndex, indicatorId, metadata, settings, outputRows, chart, initArgs,
|
|
8247
8831
|
// The chart names the run's text was integrated with (the session's own):
|
|
@@ -8250,7 +8834,10 @@ chartNames,
|
|
|
8250
8834
|
// The run's stamp when it ran at another interval than the chart: the
|
|
8251
8835
|
// snapshot reads the chart's newest bar as the projection shows it (the
|
|
8252
8836
|
// run bar before the forming one, with wait for close on).
|
|
8253
|
-
runInterval
|
|
8837
|
+
runInterval, origin = 'run',
|
|
8838
|
+
// What the integrate applied, for the snapshot's `emptyTargets` (wrunSnapshotEmptyTargets): absent for a
|
|
8839
|
+
// republish that built no result (a landed pan page).
|
|
8840
|
+
applied) {
|
|
8254
8841
|
try {
|
|
8255
8842
|
// Guarded like the tick lane's seams: a node spec that mocks the adapter
|
|
8256
8843
|
// module partially leaves the export out (production always has it).
|
|
@@ -8262,13 +8849,22 @@ runInterval) {
|
|
|
8262
8849
|
console.warn(`[wrun] output visibility failed for '${indicatorId}' (chart ${chartIndex}):`, error);
|
|
8263
8850
|
}
|
|
8264
8851
|
try {
|
|
8265
|
-
const
|
|
8266
|
-
// A
|
|
8267
|
-
//
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8852
|
+
const shown = wrunChartHostEnv().chart.latestSnapshot(chartIndex, indicatorId);
|
|
8853
|
+
// A refused full run's snapshot stands until a verdict that supersedes it publishes (a full run, a reseed):
|
|
8854
|
+
// a republish would bring back the numbers of the computation the refusal superseded.
|
|
8855
|
+
if (origin === 'run' || shown?.refused === undefined) {
|
|
8856
|
+
const snapshot = wrunLatestSnapshotOf(metadata, runInterval ? wrunOutputRowsOnChartBars(outputRows, chart, runInterval) : outputRows, chartNames);
|
|
8857
|
+
// A tick republish carries the run's init args forward (the args a tick evaluates with are the
|
|
8858
|
+
// session seed's, unchanged since the last full run or reseed).
|
|
8859
|
+
const carried = initArgs ?? shown?.initArgs;
|
|
8860
|
+
if (carried)
|
|
8861
|
+
snapshot.initArgs = [...carried];
|
|
8862
|
+
// The Style targets the chart shows nothing for: the Style page dims their lines.
|
|
8863
|
+
const empty = wrunSnapshotEmptyTargets(shown?.emptyTargets, applied);
|
|
8864
|
+
if (empty.length > 0)
|
|
8865
|
+
snapshot.emptyTargets = empty;
|
|
8866
|
+
wrunChartHostEnv().chart.publishLatestValues(chartIndex, indicatorId, snapshot);
|
|
8867
|
+
}
|
|
8272
8868
|
}
|
|
8273
8869
|
catch (error) {
|
|
8274
8870
|
console.warn(`[wrun] latest values publish failed for '${indicatorId}' (chart ${chartIndex}):`, error);
|
|
@@ -8524,7 +9120,9 @@ async function reintegrateWrunSessionCanvases(indicatorId, context, fill, curren
|
|
|
8524
9120
|
await publishWrunSessionCanvasNotices(context, runResult);
|
|
8525
9121
|
if (getWrunOverlayLiveContext(indicatorId) !== context)
|
|
8526
9122
|
return;
|
|
8527
|
-
presentWrunIntegration(context.chartIndex, indicatorId, context.metadata, meta.settings, context.outputRows, tc, context.sessionSeed?.initArgs, chartNames, runSession?.run
|
|
9123
|
+
presentWrunIntegration(context.chartIndex, indicatorId, context.metadata, meta.settings, context.outputRows, tc, context.sessionSeed?.initArgs, chartNames, runSession?.run,
|
|
9124
|
+
// The session's rows again: a full run refused since keeps its snapshot.
|
|
9125
|
+
'republish', { emptyTargets: runResult.emptyTargets, partial: clamped !== undefined });
|
|
8528
9126
|
context.paintedThroughTs = context.lastRowTs;
|
|
8529
9127
|
context.repaintOwed = false;
|
|
8530
9128
|
}
|
|
@@ -8625,11 +9223,11 @@ export async function publishWrunStrategyRunResult(chartIndex, indicatorId, runR
|
|
|
8625
9223
|
* lines were ever written for it and there is nothing to clear, and the
|
|
8626
9224
|
* store stays out of every run of a package without a debug log. The store
|
|
8627
9225
|
* is loaded lazily like the strategy publish. */
|
|
8628
|
-
async function publishWrunDebugOutput(chartIndex, indicatorId, metadata, rows) {
|
|
9226
|
+
async function publishWrunDebugOutput(chartIndex, indicatorId, metadata, rows, provenance) {
|
|
8629
9227
|
if (wrunDebugSlotIndex(metadata) === undefined)
|
|
8630
9228
|
return;
|
|
8631
9229
|
const { useChartStore } = await wrunChartHostEnv().chart.loadChartStore();
|
|
8632
|
-
useChartStore().setIndicatorPrintOutputs(chartIndex, indicatorId, selectWrunDebugLines(metadata, rows));
|
|
9230
|
+
useChartStore().setIndicatorPrintOutputs(chartIndex, indicatorId, selectWrunDebugLines(metadata, rows), provenance);
|
|
8633
9231
|
}
|
|
8634
9232
|
/**
|
|
8635
9233
|
* A sheet with colour settings: the overlay palette (the collapsed-legend
|
|
@@ -8796,6 +9394,25 @@ function wrunMountMemoOf(meta) {
|
|
|
8796
9394
|
}
|
|
8797
9395
|
return memo;
|
|
8798
9396
|
}
|
|
9397
|
+
/**
|
|
9398
|
+
* The result a mounted overlay shows now, as it was built, with the window it was computed over (the
|
|
9399
|
+
* workspace switch's stand-in capture stores it, kscript-standin-switch.util): the live tick's last
|
|
9400
|
+
* applied build (`liveApplied`), else the result this lane's last full integrate applied while its
|
|
9401
|
+
* rows are still the ones mounted (the mount memo: a tick's whole integrate, a blank or a stand-in
|
|
9402
|
+
* replaces them), else undefined. While a repaint is owed the chart lags the session, so nothing on
|
|
9403
|
+
* it is known to show: undefined. Nothing is rebuilt or patched here.
|
|
9404
|
+
*/
|
|
9405
|
+
export function wrunMountedRunResultOf(indicatorId, meta) {
|
|
9406
|
+
const context = getWrunOverlayLiveContext(indicatorId);
|
|
9407
|
+
if (context?.repaintOwed)
|
|
9408
|
+
return undefined;
|
|
9409
|
+
if (context?.liveApplied)
|
|
9410
|
+
return { runResult: context.liveApplied.result, window: context.window };
|
|
9411
|
+
const memo = wrunMountMemos.get(meta);
|
|
9412
|
+
if (memo?.lastResult === undefined || memo.lastRows !== meta.rawData)
|
|
9413
|
+
return undefined;
|
|
9414
|
+
return { runResult: memo.lastResult, window: memo.lastWindow };
|
|
9415
|
+
}
|
|
8799
9416
|
/** The result renders equal to the one this lane applied last, and that one is still what the
|
|
8800
9417
|
* overlay shows: the same window recomputed (a page lands its children's rows inside it, so another
|
|
8801
9418
|
* window is never the same apply), the parent equal (`kscriptRunResultsRenderEqual`: rows, drawings,
|
|
@@ -11892,7 +12509,9 @@ async function followWrunPrefixLanded(runTarget, tc, meta, prepared, refusal) {
|
|
|
11892
12509
|
const { chartIndex, indicatorId } = runTarget;
|
|
11893
12510
|
const { context, sheetNow } = prepared;
|
|
11894
12511
|
markWrunOverlayComputeSucceeded(indicatorId);
|
|
11895
|
-
presentWrunIntegration(chartIndex, indicatorId, sheetNow, meta.settings, context.outputRows, tc, context.sessionSeed?.initArgs, wrunSessionChartNamesOf(context), null
|
|
12512
|
+
presentWrunIntegration(chartIndex, indicatorId, sheetNow, meta.settings, context.outputRows, tc, context.sessionSeed?.initArgs, wrunSessionChartNamesOf(context), null,
|
|
12513
|
+
// The session's rows with older bars: a full run refused since keeps its snapshot.
|
|
12514
|
+
'republish');
|
|
11896
12515
|
try {
|
|
11897
12516
|
const health = wrunSessionRunHealth(context, meta.settings, context.outputRows);
|
|
11898
12517
|
context.runHealthWarned = await publishWrunRunHealth(chartIndex, indicatorId, wrunRunHealthRowsFor(health, context.draft === true, wrunNothingReadyRefusal(health, refusal.ctx)));
|