@orangecharts/wrun-chart-host 0.19.0 → 0.20.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 +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/settings-templates/frvp-fields.js +9 -3
- package/dist/settings-templates/index.d.ts +36 -3
- package/dist/settings-templates/index.js +111 -27
- package/dist/settings-templates/indicator-fields.d.ts +11 -0
- package/dist/settings-templates/indicator-fields.js +5 -4
- package/dist/settings-templates/market-bound.d.ts +93 -19
- package/dist/settings-templates/market-bound.js +235 -30
- package/dist/settings-templates/tool-rules.d.ts +197 -18
- package/dist/settings-templates/tool-rules.js +98 -4
- package/dist/settings-templates/tool-tables.generated.d.ts +2 -0
- package/dist/settings-templates/tool-tables.generated.js +194 -11
- package/dist/utility/chart/calendar-interval.util.d.ts +7 -0
- package/dist/utility/chart/calendar-interval.util.js +9 -0
- package/dist/utility/chart/index-mode.util.d.ts +11 -0
- package/dist/utility/chart/index-mode.util.js +24 -0
- package/dist/utility/chart/indicator-run-interval.util.d.ts +7 -3
- package/dist/utility/chart/indicator-run-interval.util.js +16 -5
- package/dist/utility/chart/market-session-schedule.util.d.ts +2 -0
- package/dist/utility/chart/market-session-schedule.util.js +2 -0
- package/dist/utility/chart/run-interval-warmup.leaf.d.ts +16 -1
- package/dist/utility/chart/run-interval-warmup.leaf.js +28 -2
- package/dist/utility/options/option-contract-market.leaf.d.ts +2 -0
- package/dist/utility/options/option-contract-market.leaf.js +21 -0
- package/dist/utility/options/option-trade-units.util.d.ts +35 -5
- package/dist/utility/options/option-trade-units.util.js +31 -5
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +3 -3
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +2 -13
- package/dist/utility/wrun/wrun-color-settings.util.js +3 -29
- package/dist/utility/wrun/wrun-lane-warmup.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-lane-warmup.util.js +8 -3
- package/dist/utility/wrun/wrun-live-intake.util.js +13 -6
- package/dist/utility/wrun/wrun-live-tick.util.js +35 -18
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +34 -1
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +57 -0
- package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +76 -13
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +286 -45
- package/dist/utility/wrun/wrun-market-size-rank.leaf.d.ts +75 -0
- package/dist/utility/wrun/wrun-market-size-rank.leaf.js +154 -0
- package/dist/utility/wrun/wrun-overlay-run.util.js +124 -21
- package/dist/utility/wrun/wrun-param-values.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-param-values.util.js +3 -9
- package/dist/utility/wrun/wrun-row-scalars.leaf.d.ts +30 -0
- package/dist/utility/wrun/wrun-row-scalars.leaf.js +73 -0
- package/dist/utility/wrun/wrun-run-health.util.d.ts +24 -2
- package/dist/utility/wrun/wrun-run-health.util.js +39 -7
- package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-run-interval-session.util.js +25 -0
- package/dist/utility/wrun/wrun-run-interval.util.d.ts +52 -5
- package/dist/utility/wrun/wrun-run-interval.util.js +88 -7
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +4 -7
- package/dist/utility/wrun/wrun-script-inputs.util.js +6 -33
- package/package.json +1 -1
|
@@ -119,7 +119,7 @@ import { wrunLaneFetchSignal } from './sources/wrun-lane-fetch-abort.util.js';
|
|
|
119
119
|
import { wrunHostBarSpansWithin } from './wrun-tier-grid.util.js';
|
|
120
120
|
import { wrunOpraLanePayloadFields } from './wrun-opra-lane.util.js';
|
|
121
121
|
import { markWrunLaneRefusedHold, WRUN_LANE_REFUSALS, WRUN_LANE_REFUSED_SETTLE_REASON, WRUN_NO_ORDER_BOOK_CODE, wrunLaneRefusedCodeOf, wrunLaneRefusedHoldCodeOf, } from './wrun-lane-refusal.leaf.js';
|
|
122
|
-
import { SOURCE_HISTORY_AS_OF_FIELD, TRADES_HISTORY_MAX_CELLS, } from '../../kscript-data/controls/live-trades-merge.util.js';
|
|
122
|
+
import { SOURCE_HISTORY_AS_OF_FIELD, TRADES_HISTORY_MAX_CELLS, tradesLaneLimits, tradesServedStartMs, } from '../../kscript-data/controls/live-trades-merge.util.js';
|
|
123
123
|
import { warmWrunEarningsFacts, wrunEarningsFactsFor, wrunReadsEarningsFacts, } from './wrun-earnings-facts.util.js';
|
|
124
124
|
import { liveBucketStartsInRange, liveBucketVenueOf } from '../chart/live-bucket.util.js';
|
|
125
125
|
import { indexHostFetchTierMs } from '../chart/index-host-tier.util.js';
|
|
@@ -130,7 +130,7 @@ import { wrunDailyLaneFetchFrom, wrunDailyLaneFetchTo } from './wrun-daily-lane.
|
|
|
130
130
|
import { assertWrunEtfFlowCoin, planWrunEtfFlowColumns, planWrunEtfFlowLane, resolveWrunEtfFlowTickers, WRUN_ETF_FLOW_INTERVAL_KEY, wrunEtfFlowAnswer, zipWrunEtfFlowRows, } from './wrun-etf-flow-lane.util.js';
|
|
131
131
|
import { planWrunOptionSummaryLane, WRUN_OPTION_SUMMARY_LANES, wrunOptionSummaryAskExtras, wrunOptionSummaryAskKey, zipWrunOptionSummaryRows, } from './wrun-option-summary-lane.util.js';
|
|
132
132
|
import { selectWrunDebugLines, wrunDebugSlotIndex } from './wrun-debug-output.util.js';
|
|
133
|
-
import { isWrunDraftOverlaySettings, wrunRegistryRefOf } from './wrun-overlay-identity.util.js';
|
|
133
|
+
import { isWrunDraftOverlaySettings, wrunRegistryRefOf, wrunRowSourceKindOf } from './wrun-overlay-identity.util.js';
|
|
134
134
|
import { isWrunAppLayerOverlaySettings } from './wrun-app-layer.leaf.js';
|
|
135
135
|
import { wrunHostedParamsOf, wrunSheetParamsFromDeclarations } from './wrun-param-map.util.js';
|
|
136
136
|
import { WRUN_SYMBOL_TEXT_SERVER_CAP } from './wrun-hosted-wire-caps.js';
|
|
@@ -151,7 +151,7 @@ import { substituteWrunChartNames, wrunChartContextHostFill, wrunChartIntervalMs
|
|
|
151
151
|
import { forgetWrunMarketReadFailures, warmWrunMarketDollarFacts, warmWrunMarketFacts, wrunChartSizeUnit, wrunLaneDemandNeedsDirectory, wrunMarketDollarReadFailure, wrunMarketDollarUnit, wrunMarketReadMark, wrunMarketFactsFor, wrunMarketFactsNeedDirectory, wrunReadsDollarMultiplier, wrunReadsMarketFacts, wrunStrategyPointValue, wrunCoinLegsOf, wrunCoinLegVenues, wrunSheetWithCoinLegs, wrunSheetWithLaneCurrencies, wrunSheetWithLaneDemand, wrunSheetWithLaneGate, WRUN_DOLLAR_MULTIPLIER_FILL, WRUN_DOLLAR_MULTIPLIER_UNPROVEN_CODE, } from './wrun-chart-market-facts.util.js';
|
|
152
152
|
import { wrunFollowsCoin, wrunInputGateOn, wrunRowVisibleHere } from './wrun-market-facts.util.js';
|
|
153
153
|
import { wrunRowsKeepingMarketDefaults } from './wrun-market-size-defaults.leaf.js';
|
|
154
|
-
import { reconcileWrunMarketSizeDefaults } from './wrun-market-size-defaults.util.js';
|
|
154
|
+
import { reconcileWrunMarketSizeDefaults, wrunMarketSizeRankOf, } from './wrun-market-size-defaults.util.js';
|
|
155
155
|
import { rememberWrunSessionChartNames, resolveWrunChartNames, wrunSessionChartNamesOf, } from './wrun-chart-context-names.util.js';
|
|
156
156
|
import { assertWrunBrowserSources, getWrunBrowserHost, } from './wrun-host.service.js';
|
|
157
157
|
import { applyWrunInertLegendState } from './wrun-inert-legend.util.js';
|
|
@@ -185,7 +185,7 @@ import { checkIsCryptoIndex } from '../chart/crypto-index.leaf.js';
|
|
|
185
185
|
import { checkIsQuotePerp } from '../chart/quote-perp.leaf.js';
|
|
186
186
|
import { buildMixedModeContext, getFirstTokenMode } from '../chart/mixed-mode.util.js';
|
|
187
187
|
import { inferPriceTickFromRows } from '../chart/footprint-band.util.js';
|
|
188
|
-
import { getMarketKind } from '../chart/marketKind.util.js';
|
|
188
|
+
import { checkIsEconomic, getMarketKind } from '../chart/marketKind.util.js';
|
|
189
189
|
import { isCmeGoverned } from '../chart/cme-realtime.util.js';
|
|
190
190
|
import { wrunBarSessionFactsResolver, wrunBarVenueOf } from '../chart/wrun-bar-session-facts.util.js';
|
|
191
191
|
import { wrunPresentIsPartial } from './wrun-present-bits.util.js';
|
|
@@ -203,7 +203,7 @@ import { barEndMs, isCalendarIntervalLabel } from '../chart/calendar-interval.ut
|
|
|
203
203
|
import { wrunCandlesLowAcross, wrunCoinTapeDayAsk, wrunCoinTapeWindow, wrunHeldCoinTapePriceLow, wrunPricedCoinTape, wrunTapeReadIdentity, WRUN_TAPE_COINS_DAY_INTERVAL, WRUN_TAPE_COINS_DAY_MS, } from './wrun-tape-coins.util.js';
|
|
204
204
|
import { normalizeTransformations, selfTransformationToken, transformationsTouchVenue, } from '../common/transformations.util.js';
|
|
205
205
|
import { checkIsIndexOtc } from '../chart/index-otc.leaf.js';
|
|
206
|
-
import { resolveWrunTapeAcquisition, WRUN_TAPE_COINS_UNPRICED_CODE, WRUN_TAPE_INTERVAL_UNSUPPORTED_CODE, WRUN_TAPE_TOO_MANY_TRADES_CODE, WRUN_TAPE_VALUE_UNPROVEN_CODE, wrunTapeAcquisitionFloor, wrunTapeFloorOf, wrunTapeFloorSettingWords, wrunTapeFloorSettings, wrunTapeFloorWords, wrunTapeLaneExtras, } from './wrun-tape-source.util.js';
|
|
206
|
+
import { resolveWrunTapeAcquisition, WRUN_TAPE_COINS_UNPRICED_CODE, WRUN_TAPE_INTERVAL_UNSUPPORTED_CODE, WRUN_TAPE_TOO_MANY_TRADES_CODE, WRUN_TAPE_VALUE_UNPROVEN_CODE, wrunTapeAcquisitionFloor, wrunTapeFloorOf, wrunTapeFloorSettingWords, wrunTapeFloorSettings, wrunTapeFloorWords, wrunTapeFloorParamOf, wrunTapeLaneExtras, } from './wrun-tape-source.util.js';
|
|
207
207
|
import { wrunChartSession, wrunLegCandleClose, wrunPrimaryRowBounds } from './wrun-leg-close.util.js';
|
|
208
208
|
import { isWrunRowSourceTransientError, wrunRowBatchDeliveredSheet, wrunRowSourceSettingsLeftBy, } from './wrun-row-source.js';
|
|
209
209
|
import { wrunOverlayOpraStamped } from './wrun-cloud-opra-stamp.util.js';
|
|
@@ -228,8 +228,8 @@ import { WRUN_HISTORY_WARMUP_MAX_BARS, wrunDeclaredWarmupBars, wrunDeclaredWarmu
|
|
|
228
228
|
import { wrunLaneWarmupBars, wrunLaneWarmupFromMs, wrunTradeDateAnchorActive, wrunTradeDateHeadFromMs, } from './wrun-lane-warmup.util.js';
|
|
229
229
|
import { orderWrunFirstRunHistory } from './wrun-first-run-depth.util.js';
|
|
230
230
|
import { wrunTwinOriginalLookbackBars, wrunTwinTradeDateAnchor } from './wrun-twin-lookback.util.js';
|
|
231
|
-
import { overlayWrunRunInterval, wrunSettingsForRunInterval, wrunTimeframeIsChartOrFiner,
|
|
232
|
-
import { planWrunRunIntervalRows, rememberWrunRunIntervalSession, wrunRunIntervalComputeRows, wrunRunIntervalCoverageKey, wrunRunIntervalProjectionOf,
|
|
231
|
+
import { overlayWrunRunInterval, wrunSettingsForRunInterval, wrunTimeframeIsChartOrFiner, wrunTwinChartLookbackBars, wrunTwinCoarserTimeframe, } from './wrun-run-interval.util.js';
|
|
232
|
+
import { planWrunRunIntervalRows, rememberWrunRunIntervalSession, wrunRunIntervalComputeRows, wrunRunIntervalCoverageKey, wrunRunIntervalProjectionOf, wrunRunIntervalAnswer, wrunRunIntervalSentRow, wrunRunIntervalSessionOf, } from './wrun-run-interval-session.util.js';
|
|
233
233
|
import { isWrunBandedBookSource } from './wrun-book-bands.leaf.js';
|
|
234
234
|
import { attachWrunLive, wrunLiveOf, wrunTrapOf, } from '../../interfaces/wrun-runtime.interface.js';
|
|
235
235
|
import { normalizeRuntimeDiagnostics, shouldNoticeWrunRefusal, WRUN_RUN_FAILURE_ROW_CODES, WRUN_RUN_TIMEOUT_CODE, WRUN_ABORT_DIAGNOSTIC_CODE, WRUN_UNREACHABLE_TRAP_CODE, wrunAbortRuntimeDiagnostic, wrunRunFailureRuntimeDiagnostic, wrunTrapRuntimeDiagnostic, } from '../scriptEditor/wrun-runtime-diagnostics.leaf.js';
|
|
@@ -457,6 +457,9 @@ export async function runWrunOverlayOnChart(target) {
|
|
|
457
457
|
// The market this run computes for (C4), set once the head read it: with the data generation and
|
|
458
458
|
// the compute revision above, what a failure is judged against (wrunRunSupersededReason).
|
|
459
459
|
let market;
|
|
460
|
+
// The head's market size ticket (a browser-computed run of a package with ranked tape floors): its row write waits
|
|
461
|
+
// for the rank step, and the `finally` below commits the base when the run never reached it.
|
|
462
|
+
let marketSizeTicket;
|
|
460
463
|
enterWrunRefusalRun(guardKey);
|
|
461
464
|
// A settings save, a switch or a new mount starts the overlay's prefix history over (C1 v3).
|
|
462
465
|
if (target.reason !== undefined && WRUN_PREFIX_REFUSAL_RESETS.has(target.reason)) {
|
|
@@ -714,8 +717,11 @@ export async function runWrunOverlayOnChart(target) {
|
|
|
714
717
|
// (C4's identity and reader), proven after each of its awaits. Full runs only: a pan page computes beside the rows
|
|
715
718
|
// and the live session the full run drew at its floor, and a move here would draw the page at another one (no
|
|
716
719
|
// save follows `updateSettings`, so nothing would rerun the rest).
|
|
720
|
+
// A record whose rows this browser computes (the sandbox source, `wrunRowSourceKindOf`) ranks its untouched tape
|
|
721
|
+
// floors over the rows its tape answers (the ticket: the row write waits for the rank step); a record the server
|
|
722
|
+
// computes (`wrunRunTarget: 'cloud'`, the socket source) never reaches the browser lanes and keeps the head's write.
|
|
717
723
|
if (prefixWindow === undefined) {
|
|
718
|
-
await reconcileWrunMarketSizeDefaults({
|
|
724
|
+
marketSizeTicket = await reconcileWrunMarketSizeDefaults({
|
|
719
725
|
chartIndex: target.chartIndex,
|
|
720
726
|
indicatorId: target.indicatorId,
|
|
721
727
|
tc,
|
|
@@ -723,6 +729,9 @@ export async function runWrunOverlayOnChart(target) {
|
|
|
723
729
|
sheet: target.metadata,
|
|
724
730
|
market,
|
|
725
731
|
isCurrent,
|
|
732
|
+
...(wrunRowSourceKindOf(meta.settings) === 'sandbox'
|
|
733
|
+
? { ranks: true, replay: target.reason === 'replay' }
|
|
734
|
+
: {}),
|
|
726
735
|
});
|
|
727
736
|
}
|
|
728
737
|
// The coin legs (kit 0.77.0, `follow: "coin"`) this run reads, resolved on the chart's coin by
|
|
@@ -762,6 +771,7 @@ export async function runWrunOverlayOnChart(target) {
|
|
|
762
771
|
cmeUserScripts,
|
|
763
772
|
marketReadsSince,
|
|
764
773
|
...(options !== undefined ? { options } : {}),
|
|
774
|
+
...(marketSizeTicket !== undefined ? { marketSize: marketSizeTicket } : {}),
|
|
765
775
|
}));
|
|
766
776
|
}
|
|
767
777
|
integrated = true;
|
|
@@ -873,6 +883,10 @@ export async function runWrunOverlayOnChart(target) {
|
|
|
873
883
|
}
|
|
874
884
|
finally {
|
|
875
885
|
leaveWrunRefusalRun(guardKey);
|
|
886
|
+
// The base lands on the row when the run never ranked (a refused or held tape, a partial window, an error, a memo
|
|
887
|
+
// hit): idempotent after the rank step's commit, and it never rejects, so the run's own error stands.
|
|
888
|
+
if (marketSizeTicket !== undefined)
|
|
889
|
+
await marketSizeTicket.commit();
|
|
876
890
|
}
|
|
877
891
|
}
|
|
878
892
|
/** Whether the attempt a run resolved at its start is still the overlay's live one: the executor
|
|
@@ -2300,6 +2314,11 @@ function wrunNothingDrawnKey(chartIndex, indicatorId) {
|
|
|
2300
2314
|
const WRUN_NOTHING_DRAWN_LEG_RULE = {
|
|
2301
2315
|
intervalOf: wrunPinnedIntervalOf,
|
|
2302
2316
|
floor: WRUN_COARSER_LEG_WARMUP_CANDLES,
|
|
2317
|
+
// A built-in twin's own Timeframe coarser than its run: the package rebuilds it from the chart's bars.
|
|
2318
|
+
twinTimeframe: (settings, runIntervalMs) => {
|
|
2319
|
+
const timeframe = wrunTwinCoarserTimeframe(settings, runIntervalMs);
|
|
2320
|
+
return timeframe && { key: timeframe.interval, ms: timeframe.intervalMs, lookback: timeframe.lookbackBars };
|
|
2321
|
+
},
|
|
2303
2322
|
};
|
|
2304
2323
|
/**
|
|
2305
2324
|
* The viewer's nothing-drawn note (wrun-run-health.util, FB27) after a full run, a reseed, an adoption or a landed
|
|
@@ -2791,7 +2810,13 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
2791
2810
|
// from the run's current param values (the values init() receives, so the lane asks at the
|
|
2792
2811
|
// param's current value) and `history` validated; then the lane's interval policy (C4) against
|
|
2793
2812
|
// the chart. Every refusal lands here by name, before any fetch.
|
|
2794
|
-
|
|
2813
|
+
// An untouched ranked floor is asked at its base whatever the engine copy holds (the ranked memo's value on a later
|
|
2814
|
+
// run of the session): every full run's payload is the same, so the held tape, the session's pin, the trades worker's
|
|
2815
|
+
// cap and the live fold all read the one acquisition (`WrunMarketSizeTicket.askFloors`).
|
|
2816
|
+
const tape = resolveWrunTapeAcquisition(target.metadata, {
|
|
2817
|
+
...wrunParamValuesFromSettings(target.metadata, view.settings),
|
|
2818
|
+
...(head.marketSize?.askFloors(view.settings) ?? {}),
|
|
2819
|
+
});
|
|
2795
2820
|
if (tape !== undefined) {
|
|
2796
2821
|
await assertWrunTapeServedOnInterval(target.metadata, tape.inputNames[0], typeof chartMetadata?.interval === 'string' ? chartMetadata.interval : '');
|
|
2797
2822
|
}
|
|
@@ -3146,7 +3171,9 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
3146
3171
|
? wrunTradeDateHeadFromMs(chartFirstTs, chartIntervalMs, (atMs) => tradeDateFacts(atMs).tradeDateSec)
|
|
3147
3172
|
: undefined;
|
|
3148
3173
|
const laneWarmupFromTs = laneWarmupRequest !== null
|
|
3149
|
-
? Math.min(wrunLaneWarmupFromMs(chartFirstTs, laneWarmupBars, chartIntervalMs
|
|
3174
|
+
? Math.min(wrunLaneWarmupFromMs(chartFirstTs, laneWarmupBars, chartIntervalMs,
|
|
3175
|
+
// The head rides the chart's main candle request, which reads an economic series' signed start as absolute.
|
|
3176
|
+
checkIsEconomic(laneWarmupRequest.identity.exchange)), tradeDateHeadFromTs ?? Number.POSITIVE_INFINITY)
|
|
3150
3177
|
: undefined;
|
|
3151
3178
|
const laneHeadArgs = laneWarmupRequest !== null && laneWarmupFromTs !== undefined
|
|
3152
3179
|
? {
|
|
@@ -4551,14 +4578,31 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
4551
4578
|
// interval over the window (the warm-up start through the chart's newest bar), its forming bar
|
|
4552
4579
|
// KEPT in the session's buffer (live-folded like the chart's own forming bar, computed with wait
|
|
4553
4580
|
// for close off), cut at the chart's newest bar (an answer may already hold the next bucket).
|
|
4581
|
+
// Rows finer than the run interval (another interval's candles) are refused like a run ask with no answer: a
|
|
4582
|
+
// package computing over them draws wrong values at the right places.
|
|
4583
|
+
const runRowsSeed = {
|
|
4584
|
+
cls: 'service-no-answer',
|
|
4585
|
+
variant: 'lane',
|
|
4586
|
+
params: { feed: 'ohlcv' },
|
|
4587
|
+
...(chartMarket !== undefined ? { market: chartMarket } : {}),
|
|
4588
|
+
severity: 'paused',
|
|
4589
|
+
};
|
|
4554
4590
|
const runRowsPromise = run && runRowsPlan?.held === undefined
|
|
4555
|
-
? lanesKnown.then(() => fetchRequiredLane('ohlcv', `main-${run.interval}`, `${run.interval} candle`, {
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4591
|
+
? lanesKnown.then(() => fetchRequiredLane('ohlcv', `main-${run.interval}`, `${run.interval} candle`, runRowsSeed, undefined, { interval: run.interval }, from, to).then((rows) => {
|
|
4592
|
+
const answer = wrunRunIntervalAnswer(run, rows, to);
|
|
4593
|
+
if (answer.rows !== undefined)
|
|
4594
|
+
return answer.rows;
|
|
4595
|
+
wrunChartHostEnv().diagnostics.debug('wrun-run-interval-rows-finer', {
|
|
4596
|
+
chartIndex: target.chartIndex,
|
|
4597
|
+
indicatorId: target.indicatorId,
|
|
4598
|
+
ask: 'full-run',
|
|
4599
|
+
askedInterval: run.interval,
|
|
4600
|
+
askedIntervalMs: run.intervalMs,
|
|
4601
|
+
medianGapMs: answer.finerGapMs,
|
|
4602
|
+
rows: rows.length,
|
|
4603
|
+
});
|
|
4604
|
+
return refuseLaneUnavailable('ohlcv', `${run.interval} candle`, 'answered rows finer than its interval', runRowsSeed);
|
|
4605
|
+
}))
|
|
4562
4606
|
: undefined;
|
|
4563
4607
|
runRowsPromise?.catch(() => undefined);
|
|
4564
4608
|
// The degrade registry the legend chips derive from (kScript's, keyed by the
|
|
@@ -4678,6 +4722,8 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
4678
4722
|
};
|
|
4679
4723
|
// The tape's ask: a coins floor priced over its window, every other floor as resolved.
|
|
4680
4724
|
const tapeAsked = tape?.minCoins !== undefined ? await priceWrunCoinTape(tape) : tape;
|
|
4725
|
+
// The tape fetch's wire verdict (the rank step's whole-answer test, `wrunSourceVerdictWhole`).
|
|
4726
|
+
let tapeVerdict;
|
|
4681
4727
|
const laneThunks = {
|
|
4682
4728
|
// The chart's own lanes of the book, oi, liquidations and funding classes: asked when an input reads the chart's
|
|
4683
4729
|
// own market (a pinned input reads its own lane, `pinnedLanes` below).
|
|
@@ -4763,8 +4809,14 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
4763
4809
|
// acquisition: the live fold's floor (a dollar floor with the market's `valuePerUnit`, the
|
|
4764
4810
|
// market facts' dollar unit, so a live print is priced in the history's unit, never guessed)
|
|
4765
4811
|
// and the reconcile's re-ask.
|
|
4812
|
+
// The chart's fetch reports whether it answered the tape whole (`tapeVerdict`): the rank step ranks only a whole
|
|
4813
|
+
// answer, never a declined or cut one, nor one the held buffer served (no verdict).
|
|
4766
4814
|
tape: tapeAsked !== undefined
|
|
4767
|
-
? async () => (await fetchLane('trades', 'tp',
|
|
4815
|
+
? async () => (await fetchLane('trades', 'tp', {
|
|
4816
|
+
onSourceVerdict: (heard) => {
|
|
4817
|
+
tapeVerdict = heard;
|
|
4818
|
+
},
|
|
4819
|
+
}, {
|
|
4768
4820
|
...wrunTapeLaneExtras(tapeAsked, tapeValuePerUnit),
|
|
4769
4821
|
...tapeAsOfAsk,
|
|
4770
4822
|
})) ?? []
|
|
@@ -5240,6 +5292,48 @@ async function prepareWrunSandboxRun(passTarget, tc, meta, refusal, computed, ow
|
|
|
5240
5292
|
const namedRecord = named !== undefined ? refusal.degraded?.find(({ lane }) => lane === named.lane)?.refusal : undefined;
|
|
5241
5293
|
throw namedRecord !== undefined ? annotateWrunErrorRefusal(hold, namedRecord) : hold;
|
|
5242
5294
|
}
|
|
5295
|
+
// The rank step ("the head decides, the row write waits for the rows", wrun-market-size-defaults.util): an untouched
|
|
5296
|
+
// ranked floor, asked at its base, takes the size of the Nth biggest order the tape's rows hold inside the candles
|
|
5297
|
+
// the tape covers, committed once (engine copy, workspace row, one persist) before the params are read below, so
|
|
5298
|
+
// this run computes with it. Only over rows that are the whole truth at the base: a run that still stands, the whole
|
|
5299
|
+
// loaded window (never a pan page's part), and a tape that answered fresh rows (not degraded, not still filling, not
|
|
5300
|
+
// a settings save's held session rows). Every other run commits the base at its end (`runWrunOverlayOnChart`).
|
|
5301
|
+
const marketSize = head.marketSize;
|
|
5302
|
+
const tapeOutcome = laneRun.outcomes.find(({ lane }) => lane === 'tape')?.outcome;
|
|
5303
|
+
if (marketSize !== undefined &&
|
|
5304
|
+
tapeAsked !== undefined &&
|
|
5305
|
+
runStands &&
|
|
5306
|
+
window?.partial !== true &&
|
|
5307
|
+
tapeOutcome?.kind === 'rows' &&
|
|
5308
|
+
tapeOutcome.filling !== true &&
|
|
5309
|
+
wrunSourceVerdictWhole(tapeVerdict) &&
|
|
5310
|
+
!degraded.some(({ lane }) => lane === 'tape') &&
|
|
5311
|
+
heldCoverage.tape === undefined) {
|
|
5312
|
+
// The first stamp the tape ask served (K_TRADES's own rule over the payload it sent: its history counted back from
|
|
5313
|
+
// the ask's as-of, the large lane's retention and bar limit, the window's start): the declared history is often
|
|
5314
|
+
// shorter than the loaded candles (7 days of a 500-candle 1h chart covers 168).
|
|
5315
|
+
const tapeLane = tradesLaneLimits(true, { minValue: tapeAsked.minValue });
|
|
5316
|
+
const servedFromMs = tradesServedStartMs(serverNowMs(), Math.min(tapeAsked.historySeconds, tapeLane.historyCapSec), chartIntervalMs, {
|
|
5317
|
+
windowFromMs: from,
|
|
5318
|
+
...(replay !== undefined ? { windowEndMs: to } : {}),
|
|
5319
|
+
retentionSec: tapeLane.retentionSec,
|
|
5320
|
+
...(tapeLane.barLimitSec !== undefined ? { barLimitSec: tapeLane.barLimitSec } : {}),
|
|
5321
|
+
exchange: chartExchange,
|
|
5322
|
+
historyAsOfMs: replayPresentMs ?? tapeAsOfAsk[SOURCE_HISTORY_AS_OF_FIELD],
|
|
5323
|
+
});
|
|
5324
|
+
const tapeSource = target.metadata.inputSources[tapeAsked.inputNames[0]];
|
|
5325
|
+
const ranked = wrunMarketSizeRankOf({
|
|
5326
|
+
ticket: marketSize,
|
|
5327
|
+
floorParam: tapeSource === undefined ? undefined : wrunTapeFloorParamOf(tapeSource),
|
|
5328
|
+
rows: tapeRows,
|
|
5329
|
+
chartRows,
|
|
5330
|
+
chartIntervalMs,
|
|
5331
|
+
servedFromMs,
|
|
5332
|
+
...(tapeValuePerUnit !== undefined ? { valuePerUnit: tapeValuePerUnit } : {}),
|
|
5333
|
+
});
|
|
5334
|
+
if (ranked !== undefined)
|
|
5335
|
+
await marketSize.commit(ranked);
|
|
5336
|
+
}
|
|
5243
5337
|
// The exact warm-up session's head, asked beside the lanes above: a head that cannot be had runs the existing
|
|
5244
5338
|
// cold path unchanged and records no warmth. A deferred head (draw first) is not awaited: the run is cold now
|
|
5245
5339
|
// (`warmup-deferred`) and the rerun the head owes the overlay makes it warm.
|
|
@@ -6561,7 +6655,9 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
|
|
|
6561
6655
|
},
|
|
6562
6656
|
// A twin of an original whose declaration a sheet cannot express (a calendar span) reads
|
|
6563
6657
|
// the original's lookback, folded at the chart interval as the kScript lane folds it.
|
|
6564
|
-
|
|
6658
|
+
// A proven twin's lookback in chart bars: a coarser Timeframe the package rebuilds from them costs its span.
|
|
6659
|
+
lookbackBars: wrunTwinChartLookbackBars(meta.settings, chartIntervalMs, run) ??
|
|
6660
|
+
(await wrunTwinOriginalLookbackBars(meta.settings, chartIntervalMs)),
|
|
6565
6661
|
unsettledLanes,
|
|
6566
6662
|
planGeneration,
|
|
6567
6663
|
// Where the history the run read begins: every lane it asked and every leg, from the bar its lanes asked from.
|
|
@@ -6629,6 +6725,7 @@ async function integrateWrunRunAsk(runTarget, tc, meta, refusal, computed, owner
|
|
|
6629
6725
|
rows: outputRows,
|
|
6630
6726
|
drawings: wrunHandlesOf(outputRows)?.length,
|
|
6631
6727
|
runIntervalMs: run ? run.intervalMs : chartIntervalMs,
|
|
6728
|
+
settings: meta.settings,
|
|
6632
6729
|
}, () => refusal.ctx, {
|
|
6633
6730
|
// A raise the warm-up verdict holds lands on this run's mount only, never a same-id remount's.
|
|
6634
6731
|
isCurrent: () => isWrunRunMountOnChart(target.chartIndex, { tc, meta }),
|
|
@@ -7592,6 +7689,7 @@ async function integrateWrunRowSourceBatch(asked, tc, meta, refusal, computed, o
|
|
|
7592
7689
|
rows: outputRows,
|
|
7593
7690
|
drawings: wrunHandlesOf(outputRows)?.length,
|
|
7594
7691
|
runIntervalMs: chartIntervalMs,
|
|
7692
|
+
settings: meta.settings,
|
|
7595
7693
|
}, () => refusal.ctx, { isCurrent: () => isWrunRunMountOnChart(chartIndex, { tc, meta }) });
|
|
7596
7694
|
}
|
|
7597
7695
|
// A run computed elsewhere served every leg it read: no leg note of an earlier run stands, no pin note this
|
|
@@ -7921,7 +8019,7 @@ function wrunWarmupEvidenceOutputs(runResult) {
|
|
|
7921
8019
|
* run that follows asks for itself. A page asked just before that goes out only if the chart
|
|
7922
8020
|
* still stands when the lazily loaded loader dispatches it.
|
|
7923
8021
|
* The evidence: the continuous outputs as drawn (wrunWarmupEvidenceOutputs), a proven twin's
|
|
7924
|
-
* lookback (
|
|
8022
|
+
* lookback in chart bars (wrunTwinChartLookbackBars), else the declared lookback of the kScript original a twin ports
|
|
7925
8023
|
* when the roster carries it and the mounted version holds it (a calendar span no sheet can declare:
|
|
7926
8024
|
* wrunTwinOriginalLookbackBars, Anchored VWAP's 366 days), null for any other Indicator, every lane resolved
|
|
7927
8025
|
* (`unsettledLanes` empty) and the chart's first bar as the window the run computed over. Any other
|
|
@@ -9517,6 +9615,7 @@ export async function reseedWrunOverlayFromBuffers(indicatorId, reason, options
|
|
|
9517
9615
|
rows: outputRows,
|
|
9518
9616
|
drawings: wrunHandlesOf(outputRows)?.length,
|
|
9519
9617
|
runIntervalMs: runSession?.run?.intervalMs ?? context.intervalMs,
|
|
9618
|
+
settings: meta.settings,
|
|
9520
9619
|
}, async () => wrunRefusalContextFor({
|
|
9521
9620
|
title: context.title,
|
|
9522
9621
|
metadata: context.metadata,
|
|
@@ -11336,6 +11435,7 @@ export async function adoptWrunParkedLiveSession(parked, target) {
|
|
|
11336
11435
|
rows: context.outputRows,
|
|
11337
11436
|
drawings: wrunHandlesOf(context.outputRows)?.length,
|
|
11338
11437
|
runIntervalMs: wrunRunIntervalSessionOf(context)?.run.intervalMs ?? context.intervalMs,
|
|
11438
|
+
settings: meta.settings,
|
|
11339
11439
|
}, async () => wrunRefusalContextFor({
|
|
11340
11440
|
title: context.title,
|
|
11341
11441
|
metadata: context.metadata,
|
|
@@ -15113,6 +15213,7 @@ async function followWrunPrefixLanded(runTarget, tc, meta, prepared, refusal) {
|
|
|
15113
15213
|
rows: context.outputRows,
|
|
15114
15214
|
drawings: wrunHandlesOf(context.outputRows)?.length,
|
|
15115
15215
|
runIntervalMs: context.intervalMs,
|
|
15216
|
+
settings: meta.settings,
|
|
15116
15217
|
}, () => refusal.ctx, { warmup: warmupPage, isCurrent: () => isWrunRunMountOnChart(chartIndex, { tc, meta }) });
|
|
15117
15218
|
const chartInterval = typeof prepared.chartMetadata?.interval === 'string' ? prepared.chartMetadata.interval : '';
|
|
15118
15219
|
askWrunWarmupBackfillIfOwed({
|
|
@@ -15133,7 +15234,9 @@ async function followWrunPrefixLanded(runTarget, tc, meta, prepared, refusal) {
|
|
|
15133
15234
|
// The landed page's own head ran under these settings: it credits the declaration like the session's.
|
|
15134
15235
|
creditedBars: prepared.warmup?.head.length ?? 0,
|
|
15135
15236
|
},
|
|
15136
|
-
|
|
15237
|
+
// A session on the chart's own bars (`run: null`): a proven twin's lookback in chart bars.
|
|
15238
|
+
lookbackBars: wrunTwinChartLookbackBars(meta.settings, context.intervalMs, null) ??
|
|
15239
|
+
(await wrunTwinOriginalLookbackBars(meta.settings, context.intervalMs)),
|
|
15137
15240
|
unsettledLanes: new Set(),
|
|
15138
15241
|
planGeneration: prepared.planGeneration,
|
|
15139
15242
|
// Where the history the session read begins: every lane its acquisitions name and every leg, from its first row.
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* the boot path already holds.
|
|
6
6
|
*/
|
|
7
7
|
import type { WrunIndicatorMetadata, WrunMetadataParam, WrunParamHostFill } from '../../interfaces/wrun-runtime.interface.js';
|
|
8
|
+
import { numericValue } from './wrun-row-scalars.leaf.js';
|
|
8
9
|
/** The host_fill words the chart fills: the pinned kit's (WrunParamHostFill) and each word read ahead of the pin
|
|
9
10
|
* while the kit that declares it is built. A sheet a newer SDK compiled carries such a word at run time though the
|
|
10
11
|
* pinned type lacks it; once a pin carries it the union adds nothing and the word leaves
|
|
@@ -77,7 +78,7 @@ export declare function wrunMultiLabels(param: WrunMetadataParam): string[];
|
|
|
77
78
|
* (UTC), or any ISO instant; undefined when unusable. */
|
|
78
79
|
export declare function wrunTimeValue(raw: unknown): number | undefined;
|
|
79
80
|
export declare function toggleValue(raw: unknown): boolean | undefined;
|
|
80
|
-
export
|
|
81
|
+
export { numericValue };
|
|
81
82
|
/** A bitmask from a number, a numeric string, or a list of bit indexes
|
|
82
83
|
* (arithmetic: a mask may outgrow 32-bit bitwise ops). */
|
|
83
84
|
export declare function bitmaskValue(raw: unknown): number | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isWrunColorParam, isWrunStyleParam, wrunColorArrayMembers, wrunColorParamPacked, wrunParamChoices, wrunSelectParamValue, } from './wrun-color-settings.util.js';
|
|
2
2
|
import { wrunTextByteLength, wrunTextParamValue } from './wrun-text-params.util.js';
|
|
3
|
+
import { numericValue } from './wrun-row-scalars.leaf.js';
|
|
3
4
|
export function nonEmptyString(value) {
|
|
4
5
|
return typeof value === 'string' && value.trim() !== '' ? value : undefined;
|
|
5
6
|
}
|
|
@@ -72,15 +73,8 @@ export function toggleValue(raw) {
|
|
|
72
73
|
}
|
|
73
74
|
return undefined;
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return Number.isFinite(raw) ? raw : undefined;
|
|
78
|
-
if (typeof raw === 'string' && raw.trim() !== '') {
|
|
79
|
-
const value = Number(raw);
|
|
80
|
-
return Number.isFinite(value) ? value : undefined;
|
|
81
|
-
}
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
76
|
+
// In the import-free row scalars leaf (settings-templates reads it without this module); re-exported here.
|
|
77
|
+
export { numericValue };
|
|
84
78
|
/** A bitmask from a number, a numeric string, or a list of bit indexes
|
|
85
79
|
* (arithmetic: a mask may outgrow 32-bit bitwise ops). */
|
|
86
80
|
export function bitmaskValue(raw) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The row scalars every settings reader shares: a number setting's read (`numericValue`), the ONE select read
|
|
3
|
+
* (`wrunSelectOptionValue`) and the value equality the run reads values back by (`wrunValuesEqual`,
|
|
4
|
+
* `wrunRowValuesEqual`). Import-free (a type import only), so the settings templates entry and the phone's bundle read
|
|
5
|
+
* them without the script inputs module; that module, wrun-param-values.util and wrun-color-settings.util re-export
|
|
6
|
+
* them, so there is one copy of each.
|
|
7
|
+
*/
|
|
8
|
+
import type { WrunScriptInputDeclaration } from './wrun-script-inputs.util.js';
|
|
9
|
+
/** A number setting's value: a finite number, or a numeric string read as one; else undefined. */
|
|
10
|
+
export declare function numericValue(raw: unknown): number | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* A select setting resolved against the row's option strings and their
|
|
13
|
+
* labels: the ONE select read. The dialog's row codec, the run values, the
|
|
14
|
+
* cloud param map, the sheet's host pins and its style targets all read a
|
|
15
|
+
* persisted choice through it, so every lane agrees. A string that is an
|
|
16
|
+
* option is itself; an option label is its option; a number, or a numeric
|
|
17
|
+
* string, is the option whose string it is, else (an integer that names no
|
|
18
|
+
* option) the option at that index; anything else, an index past the
|
|
19
|
+
* options included (a choice persisted before the author dropped one), is
|
|
20
|
+
* undefined, and the reader keeps its declared default. A row without
|
|
21
|
+
* options passes the value through.
|
|
22
|
+
*/
|
|
23
|
+
export declare function wrunSelectOptionValue(options: ReadonlyArray<string>, labels: ReadonlyArray<string>, raw: unknown): string | undefined;
|
|
24
|
+
/** Equality the way the run reads values back: a toggle as 1/0, a select's
|
|
25
|
+
* numeric string as its number, a colour array element by element. */
|
|
26
|
+
export declare function wrunValuesEqual(a: unknown, b: unknown): boolean;
|
|
27
|
+
/** Equality for one row's value: a text row compares its words exactly (a
|
|
28
|
+
* typed "20" is not the number 20, "Abc" is not "abc"); every other kind
|
|
29
|
+
* the way the run reads values back ({@link wrunValuesEqual}). */
|
|
30
|
+
export declare function wrunRowValuesEqual(row: WrunScriptInputDeclaration, a: unknown, b: unknown): boolean;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** A number setting's value: a finite number, or a numeric string read as one; else undefined. */
|
|
2
|
+
export function numericValue(raw) {
|
|
3
|
+
if (typeof raw === 'number')
|
|
4
|
+
return Number.isFinite(raw) ? raw : undefined;
|
|
5
|
+
if (typeof raw === 'string' && raw.trim() !== '') {
|
|
6
|
+
const value = Number(raw);
|
|
7
|
+
return Number.isFinite(value) ? value : undefined;
|
|
8
|
+
}
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A select setting resolved against the row's option strings and their
|
|
13
|
+
* labels: the ONE select read. The dialog's row codec, the run values, the
|
|
14
|
+
* cloud param map, the sheet's host pins and its style targets all read a
|
|
15
|
+
* persisted choice through it, so every lane agrees. A string that is an
|
|
16
|
+
* option is itself; an option label is its option; a number, or a numeric
|
|
17
|
+
* string, is the option whose string it is, else (an integer that names no
|
|
18
|
+
* option) the option at that index; anything else, an index past the
|
|
19
|
+
* options included (a choice persisted before the author dropped one), is
|
|
20
|
+
* undefined, and the reader keeps its declared default. A row without
|
|
21
|
+
* options passes the value through.
|
|
22
|
+
*/
|
|
23
|
+
export function wrunSelectOptionValue(options, labels, raw) {
|
|
24
|
+
if (typeof raw === 'string') {
|
|
25
|
+
if (options.length === 0 || options.includes(raw))
|
|
26
|
+
return raw;
|
|
27
|
+
const at = labels.indexOf(raw);
|
|
28
|
+
if (at >= 0 && options[at] !== undefined)
|
|
29
|
+
return options[at];
|
|
30
|
+
const numeric = raw.trim() === '' ? Number.NaN : Number(raw);
|
|
31
|
+
return Number.isFinite(numeric) ? wrunSelectOptionValue(options, labels, numeric) : undefined;
|
|
32
|
+
}
|
|
33
|
+
if (typeof raw !== 'number' || !Number.isFinite(raw))
|
|
34
|
+
return undefined;
|
|
35
|
+
const text = String(raw);
|
|
36
|
+
if (options.length === 0 || options.includes(text))
|
|
37
|
+
return text;
|
|
38
|
+
return Number.isInteger(raw) && options[raw] !== undefined ? options[raw] : undefined;
|
|
39
|
+
}
|
|
40
|
+
/** A stored scalar as equality reads it: a toggle as 1/0, a numeric string as its number. */
|
|
41
|
+
function normalizeRowScalar(value) {
|
|
42
|
+
if (typeof value === 'boolean')
|
|
43
|
+
return value ? 1 : 0;
|
|
44
|
+
if (typeof value === 'string') {
|
|
45
|
+
const trimmed = value.trim();
|
|
46
|
+
if (trimmed !== '' && Number.isFinite(Number(trimmed)))
|
|
47
|
+
return Number(trimmed);
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
/** Equality the way the run reads values back: a toggle as 1/0, a select's
|
|
53
|
+
* numeric string as its number, a colour array element by element. */
|
|
54
|
+
export function wrunValuesEqual(a, b) {
|
|
55
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
56
|
+
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length)
|
|
57
|
+
return false;
|
|
58
|
+
return a.every((item, index) => wrunValuesEqual(item, b[index]));
|
|
59
|
+
}
|
|
60
|
+
const left = normalizeRowScalar(a);
|
|
61
|
+
const right = normalizeRowScalar(b);
|
|
62
|
+
if (typeof left === 'string' && typeof right === 'string')
|
|
63
|
+
return left.toLowerCase() === right.toLowerCase();
|
|
64
|
+
return left === right;
|
|
65
|
+
}
|
|
66
|
+
/** Equality for one row's value: a text row compares its words exactly (a
|
|
67
|
+
* typed "20" is not the number 20, "Abc" is not "abc"); every other kind
|
|
68
|
+
* the way the run reads values back ({@link wrunValuesEqual}). */
|
|
69
|
+
export function wrunRowValuesEqual(row, a, b) {
|
|
70
|
+
if (row.type === 'text')
|
|
71
|
+
return String(a ?? '') === String(b ?? '');
|
|
72
|
+
return wrunValuesEqual(a, b);
|
|
73
|
+
}
|
|
@@ -167,8 +167,8 @@ export declare function wrunNothingReadyRefusal(health: WrunRunHealth, ctx: Wrun
|
|
|
167
167
|
* a viewer saw a legend row over an empty chart (ZigZag on 1m forex, a band that reads volume on quote candles, a
|
|
168
168
|
* 50-week average on a 1h chart). The note says it once, quietly (the `nothing-ready` record's `drawn` variant, a
|
|
169
169
|
* note: no toast), and says the cause instead when the run knows it (`reach`: a scalar input pinned to a coarser
|
|
170
|
-
* interval, whatever its `bars`,
|
|
171
|
-
* spans). Its own owned set beside the health rows:
|
|
170
|
+
* interval, whatever its `bars`, a candles stream with no `bars`, or a built-in twin's own Timeframe the package rebuilds
|
|
171
|
+
* from the chart's bars, sees only the few candles the loaded history spans). Its own owned set beside the health rows:
|
|
172
172
|
* the live tick re-reads those (a viewer keeps only the nothing-ready row there), so this note is raised by a full
|
|
173
173
|
* run, a reseed, an adoption and a landed page, and lowered by any integrate that draws, a tick's included
|
|
174
174
|
* (wrun-overlay-run.util `presentWrunIntegration`).
|
|
@@ -197,6 +197,11 @@ export interface WrunShortLegReach {
|
|
|
197
197
|
/** The input is a leg stream (`candles`, `oi_candles`, `volume_profile_candles`) with no `bars`, which declaring them
|
|
198
198
|
* would deepen; absent for a scalar pin, which reads one candle a row whatever its `bars`. */
|
|
199
199
|
stream?: true;
|
|
200
|
+
/** The leg is a built-in twin's own Timeframe, which the package rebuilds from the chart's bars (its run stays on the
|
|
201
|
+
* chart's bars), and `lookback` of its candles settle a value. */
|
|
202
|
+
timeframe?: {
|
|
203
|
+
lookback: number;
|
|
204
|
+
};
|
|
200
205
|
}
|
|
201
206
|
/** The interval pin vocabulary and the reach a coarser leg should have (the run seam's: wrun-pinned-interval.util,
|
|
202
207
|
* and the leg fetch's warm-up floor for a coarser leg). */
|
|
@@ -206,6 +211,13 @@ export interface WrunLegReachRule {
|
|
|
206
211
|
ms: number;
|
|
207
212
|
} | undefined;
|
|
208
213
|
floor: number;
|
|
214
|
+
/** A built-in twin's own Timeframe as its settings select it (key, ms) when coarser than the run's interval, and the
|
|
215
|
+
* lookback a value needs in its bars; undefined for an overlay with none. */
|
|
216
|
+
twinTimeframe?(settings: unknown, runIntervalMs: number): {
|
|
217
|
+
key: string;
|
|
218
|
+
ms: number;
|
|
219
|
+
lookback: number;
|
|
220
|
+
} | undefined;
|
|
209
221
|
}
|
|
210
222
|
/**
|
|
211
223
|
* The short reach behind an empty run, when the run has one: an input pinned to an interval coarser than the run's
|
|
@@ -217,6 +229,14 @@ export interface WrunLegReachRule {
|
|
|
217
229
|
* that far back). The coarsest such input names the cause; undefined for none.
|
|
218
230
|
*/
|
|
219
231
|
export declare function wrunShortLegReach(metadata: Partial<Pick<WrunIndicatorMetadata, 'inputSources'>>, rows: ReadonlyArray<WrunOutputRow>, runIntervalMs: number | undefined, rule: WrunLegReachRule): WrunShortLegReach | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* The short reach of a built-in twin's own Timeframe behind an empty run: a Timeframe coarser than the run's interval
|
|
234
|
+
* (the package rebuilds it from the chart's bars: replay, a formula chart, a prediction market, an index-mode venue
|
|
235
|
+
* that keeps the package's own path) whose candles over the rows (the buckets the rows fall in, the forming one
|
|
236
|
+
* included) number fewer than the lookback a value needs. A run AT the Timeframe never reads short here (its interval is the Timeframe's). Undefined
|
|
237
|
+
* for none.
|
|
238
|
+
*/
|
|
239
|
+
export declare function wrunTwinTimeframeReach(settings: unknown, rows: ReadonlyArray<WrunOutputRow>, runIntervalMs: number | undefined, rule: Pick<WrunLegReachRule, 'twinTimeframe'>): WrunShortLegReach | undefined;
|
|
220
240
|
/** What a seam knows about a run that the viewer's note reads. */
|
|
221
241
|
export interface WrunNothingDrawnRun {
|
|
222
242
|
/** An editor draft: its own all-NaN rows speak to its author, so it never gets the note. */
|
|
@@ -232,6 +252,8 @@ export interface WrunNothingDrawnRun {
|
|
|
232
252
|
/** The interval the run computed on, ms, and the leg rule its reach is read with. */
|
|
233
253
|
runIntervalMs?: number;
|
|
234
254
|
legs?: WrunLegReachRule;
|
|
255
|
+
/** The overlay's settings: a built-in twin's own Timeframe is a leg its reach reads (wrunTwinTimeframeReach). */
|
|
256
|
+
settings?: unknown;
|
|
235
257
|
}
|
|
236
258
|
/** The note a settled viewer run owes: null when it owes none (a draft, a run that drew, a run with no ready bar), else
|
|
237
259
|
* the cause when the run knows it. Undefined for a run that is not settled: the note stands as it is. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { plainBucketStartMs } from '../chart/live-bucket.util.js';
|
|
1
2
|
import { wrunLegendName } from '../chart/wrun-legend-name.util.js';
|
|
2
3
|
import { isWrunLegStreamClass } from './wrun-leg-stream-classes.js';
|
|
3
4
|
import { wrunOutputWords } from './wrun-output-words.util.js';
|
|
@@ -288,8 +289,8 @@ export function wrunNothingReadyRefusal(health, ctx) {
|
|
|
288
289
|
* a viewer saw a legend row over an empty chart (ZigZag on 1m forex, a band that reads volume on quote candles, a
|
|
289
290
|
* 50-week average on a 1h chart). The note says it once, quietly (the `nothing-ready` record's `drawn` variant, a
|
|
290
291
|
* note: no toast), and says the cause instead when the run knows it (`reach`: a scalar input pinned to a coarser
|
|
291
|
-
* interval, whatever its `bars`,
|
|
292
|
-
* spans). Its own owned set beside the health rows:
|
|
292
|
+
* interval, whatever its `bars`, a candles stream with no `bars`, or a built-in twin's own Timeframe the package rebuilds
|
|
293
|
+
* from the chart's bars, sees only the few candles the loaded history spans). Its own owned set beside the health rows:
|
|
293
294
|
* the live tick re-reads those (a viewer keeps only the nothing-ready row there), so this note is raised by a full
|
|
294
295
|
* run, a reseed, an adoption and a landed page, and lowered by any integrate that draws, a tick's included
|
|
295
296
|
* (wrun-overlay-run.util `presentWrunIntegration`).
|
|
@@ -433,6 +434,30 @@ export function wrunShortLegReach(metadata, rows, runIntervalMs, rule) {
|
|
|
433
434
|
}
|
|
434
435
|
return short?.reach;
|
|
435
436
|
}
|
|
437
|
+
/**
|
|
438
|
+
* The short reach of a built-in twin's own Timeframe behind an empty run: a Timeframe coarser than the run's interval
|
|
439
|
+
* (the package rebuilds it from the chart's bars: replay, a formula chart, a prediction market, an index-mode venue
|
|
440
|
+
* that keeps the package's own path) whose candles over the rows (the buckets the rows fall in, the forming one
|
|
441
|
+
* included) number fewer than the lookback a value needs. A run AT the Timeframe never reads short here (its interval is the Timeframe's). Undefined
|
|
442
|
+
* for none.
|
|
443
|
+
*/
|
|
444
|
+
export function wrunTwinTimeframeReach(settings, rows, runIntervalMs, rule) {
|
|
445
|
+
if (!(typeof runIntervalMs === 'number' && runIntervalMs > 0) || rows.length === 0)
|
|
446
|
+
return undefined;
|
|
447
|
+
const timeframe = rule.twinTimeframe?.(settings, runIntervalMs);
|
|
448
|
+
if (timeframe === undefined || timeframe.ms <= runIntervalMs || !(timeframe.lookback > 0))
|
|
449
|
+
return undefined;
|
|
450
|
+
// The candles the package rebuilds: one per bucket a row falls in (the kit's resample rule: 5m to 4h on the epoch
|
|
451
|
+
// floor, 1D the UTC day, 1W the Monday week, which plainBucketStartMs keys the same way off the CME lattice, where
|
|
452
|
+
// a twin runs at its interval). A gap holds no bucket, so elapsed time over-counts on a market with sessions.
|
|
453
|
+
const buckets = new Set();
|
|
454
|
+
for (const row of rows)
|
|
455
|
+
buckets.add(plainBucketStartMs(row.ts, timeframe.ms));
|
|
456
|
+
const bars = buckets.size;
|
|
457
|
+
return bars < timeframe.lookback
|
|
458
|
+
? { interval: timeframe.key, bars, timeframe: { lookback: timeframe.lookback } }
|
|
459
|
+
: undefined;
|
|
460
|
+
}
|
|
436
461
|
/** The note a settled viewer run owes: null when it owes none (a draft, a run that drew, a run with no ready bar), else
|
|
437
462
|
* the cause when the run knows it. Undefined for a run that is not settled: the note stands as it is. */
|
|
438
463
|
export function wrunViewerNothingDrawn(run) {
|
|
@@ -442,7 +467,11 @@ export function wrunViewerNothingDrawn(run) {
|
|
|
442
467
|
return undefined;
|
|
443
468
|
if (!wrunRunDrewNothing(run.metadata, run.rows, run.drawings))
|
|
444
469
|
return null;
|
|
445
|
-
|
|
470
|
+
// A twin's own Timeframe too short for its lookback is the cause on its own: nothing it reads could draw.
|
|
471
|
+
const reach = run.legs
|
|
472
|
+
? (wrunTwinTimeframeReach(run.settings, run.rows, run.runIntervalMs, run.legs) ??
|
|
473
|
+
wrunShortLegReach(run.metadata, run.rows, run.runIntervalMs, run.legs))
|
|
474
|
+
: undefined;
|
|
446
475
|
return reach !== undefined ? { reach } : {};
|
|
447
476
|
}
|
|
448
477
|
/** The note row of a verdict (none for null): the `nothing-ready` record's `drawn` variant, or `reach` naming the
|
|
@@ -454,10 +483,13 @@ export function wrunNothingDrawnDiagnostics(verdict, ctx) {
|
|
|
454
483
|
// The technical words name the cause each kind has: a stream's missing `bars`, or a scalar pin's one candle a bar.
|
|
455
484
|
const cause = reach === undefined
|
|
456
485
|
? ''
|
|
457
|
-
: reach.
|
|
458
|
-
? ` Its ${reach.interval}
|
|
459
|
-
|
|
460
|
-
|
|
486
|
+
: reach.timeframe !== undefined
|
|
487
|
+
? ` Its Timeframe ${reach.interval} is rebuilt from the chart's bars, which hold ${reach.bars} ${reach.interval}` +
|
|
488
|
+
` candles here, and a value needs ${reach.timeframe.lookback}.`
|
|
489
|
+
: reach.stream
|
|
490
|
+
? ` Its ${reach.interval} input declares no bars, so it reaches ${reach.bars} ${reach.interval} candles here.`
|
|
491
|
+
: ` Its ${reach.interval} input is a scalar pin, which reads one ${reach.interval} candle a bar whatever its` +
|
|
492
|
+
` bars, so it reaches ${reach.bars} ${reach.interval} candles here.`;
|
|
461
493
|
const message = 'Nothing was drawn: no plotted value is finite on any ready bar of the loaded window and the run made no drawing.' +
|
|
462
494
|
cause;
|
|
463
495
|
const seed = reach !== undefined
|