@orangecharts/wrun-chart-host 0.19.1 → 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 +1 -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 +29 -4
- package/dist/settings-templates/index.js +82 -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 -20
- package/dist/settings-templates/market-bound.js +229 -41
- 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
|
@@ -46,6 +46,13 @@ export declare function calendarBarStartMs(tsMs: number, months: number): number
|
|
|
46
46
|
export declare function fixedGridFloorMs(tsMs: number, intervalMs: number): number;
|
|
47
47
|
/** `fixedGridFloorMs` in the `Math.floor` form. The two forms differ before 1970, so a site keeps the form it had. */
|
|
48
48
|
export declare function fixedGridFloorDivMs(tsMs: number, intervalMs: number): number;
|
|
49
|
+
/**
|
|
50
|
+
* The start of the bar holding `tsMs` on the grid of a bar length known by one of its own bar opens (`onGridMs`): bars
|
|
51
|
+
* anchored on a session open (a regular-session stock's 14:30Z hours), which no fixed grid describes. The caller holds
|
|
52
|
+
* a real bar of that grid; a length with a fixed grid goes through `fixedGridFloorMs` and its siblings. Correct before
|
|
53
|
+
* `onGridMs`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function anchoredGridFloorMs(tsMs: number, intervalMs: number, onGridMs: number): number;
|
|
49
56
|
/** `fixedGridFloorDivMs` for a time and a bar length in seconds. */
|
|
50
57
|
export declare function fixedGridFloorDivSec(sec: number, intervalSec: number): number;
|
|
51
58
|
/**
|
|
@@ -92,6 +92,15 @@ export function fixedGridFloorDivMs(tsMs, intervalMs) {
|
|
|
92
92
|
return anchoredFloor(tsMs, intervalMs, TYPED_DAY_WEEK_GRID_ORIGIN_MS);
|
|
93
93
|
return Math.floor(tsMs / intervalMs) * intervalMs;
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* The start of the bar holding `tsMs` on the grid of a bar length known by one of its own bar opens (`onGridMs`): bars
|
|
97
|
+
* anchored on a session open (a regular-session stock's 14:30Z hours), which no fixed grid describes. The caller holds
|
|
98
|
+
* a real bar of that grid; a length with a fixed grid goes through `fixedGridFloorMs` and its siblings. Correct before
|
|
99
|
+
* `onGridMs`.
|
|
100
|
+
*/
|
|
101
|
+
export function anchoredGridFloorMs(tsMs, intervalMs, onGridMs) {
|
|
102
|
+
return anchoredFloor(tsMs, intervalMs, onGridMs);
|
|
103
|
+
}
|
|
95
104
|
/** `fixedGridFloorDivMs` for a time and a bar length in seconds. */
|
|
96
105
|
export function fixedGridFloorDivSec(sec, intervalSec) {
|
|
97
106
|
if (isTypedDayWeekMs(intervalSec * 1000))
|
|
@@ -7,6 +7,10 @@ export declare const DEX_EXCHANGES: readonly ["UNISWAP_V2", "UNISWAP_V3", "UNISW
|
|
|
7
7
|
export type PMSignalMarketType = 'crypto' | 'tradfi' | 'commodity';
|
|
8
8
|
export declare const PM_SIGNAL_COMMODITY_TOKEN_MAP: Record<string, string>;
|
|
9
9
|
export declare const PM_SIGNAL_TOKEN_MAP: Record<string, string>;
|
|
10
|
+
/** Every venue name the index-mode set holds (the composite's lists, both Polygon enum names). */
|
|
11
|
+
export declare const INDEX_MODE_EXCHANGE_NAMES: readonly string[];
|
|
12
|
+
/** The family of an index-mode venue: the list of the composite (INDEX_MODE_EXCHANGES) that holds it. */
|
|
13
|
+
export type IndexModeFamily = 'stocks' | 'pyth' | 'dex' | 'forex' | 'commodity' | 'index' | 'cme';
|
|
10
14
|
import { checkIsPolygon, checkIsPolymarket, checkIsEconomic, checkIsFred, checkIsForex, checkIsCommodity, checkIsFutures, checkIsForexOrCommodity, checkIsForexCommodityOrFutures, checkIsHip3, checkIsHip4, checkIsTradFi, checkIsDex } from './marketKind.util.js';
|
|
11
15
|
export { checkIsPolygon, checkIsPolymarket, checkIsEconomic, checkIsFred, checkIsForex, checkIsCommodity, checkIsFutures, checkIsForexOrCommodity, checkIsForexCommodityOrFutures, checkIsHip3, checkIsHip4, checkIsTradFi, checkIsDex, };
|
|
12
16
|
/**
|
|
@@ -52,6 +56,13 @@ export declare function checkIsEligiblePMSignalTicker(normalizedTicker: string):
|
|
|
52
56
|
* CBOT/NYMEX/COMEX-vs-CME behavioral split (see marketKind.util.ts).
|
|
53
57
|
*/
|
|
54
58
|
export declare function checkIsIndexMode(exchange: string | undefined): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The family of an index-mode venue (IndexModeFamily), undefined off index mode. A CME-governed venue that reads as
|
|
61
|
+
* index mode (the futures policy off, failing closed to commodity semantics) is `cme`. A venue the index-mode set
|
|
62
|
+
* holds outside every family list reads undefined: its readers decide nothing for it (the family guard in
|
|
63
|
+
* tests/utility/wrun/wrun-run-interval.util.spec.ts fails on one).
|
|
64
|
+
*/
|
|
65
|
+
export declare function indexModeFamilyOf(exchange: string | undefined): IndexModeFamily | undefined;
|
|
55
66
|
/** An index venue (`INDEX_VENUE_EXCHANGES`): quote series in many time zones, no US session grid. */
|
|
56
67
|
export declare function checkIsIndexVenue(exchange: string | undefined): boolean;
|
|
57
68
|
/**
|
|
@@ -107,6 +107,17 @@ const POLYGON_ENUM_NAMES = ['POLYGON', 'US_STOCKS'];
|
|
|
107
107
|
const INDEX_MODE_EXCHANGES_SET = new Set([...INDEX_MODE_EXCHANGES, ...POLYGON_ENUM_NAMES]);
|
|
108
108
|
const INDEX_VENUE_EXCHANGES_SET = new Set(INDEX_VENUE_EXCHANGES);
|
|
109
109
|
const EXCHANGES_BLOCKED_ON_1S_SET = new Set([...EXCHANGES_BLOCKED_ON_1S, ...POLYGON_ENUM_NAMES]);
|
|
110
|
+
/** Every venue name the index-mode set holds (the composite's lists, both Polygon enum names). */
|
|
111
|
+
export const INDEX_MODE_EXCHANGE_NAMES = [...INDEX_MODE_EXCHANGES_SET];
|
|
112
|
+
const familyEntries = (family, venues) => venues.map((venue) => [venue, family]);
|
|
113
|
+
const INDEX_MODE_FAMILY_BY_VENUE = new Map([
|
|
114
|
+
...familyEntries('stocks', [...POLYGON_EXCHANGES, ...POLYGON_ENUM_NAMES]),
|
|
115
|
+
...familyEntries('pyth', PYTH_EXCHANGES),
|
|
116
|
+
...familyEntries('dex', DEX_EXCHANGES),
|
|
117
|
+
...familyEntries('forex', FOREX_EXCHANGES),
|
|
118
|
+
...familyEntries('commodity', COMMODITY_EXCHANGES),
|
|
119
|
+
...familyEntries('index', INDEX_VENUE_EXCHANGES),
|
|
120
|
+
]);
|
|
110
121
|
const PM_SIGNAL_CRYPTO_SET = new Set(PM_SIGNAL_CRYPTO_SYMBOLS);
|
|
111
122
|
const PM_SIGNAL_TRADFI_SET = new Set(PM_SIGNAL_TRADFI_SYMBOLS.map((s) => s.toUpperCase()));
|
|
112
123
|
const PM_SIGNAL_COMMODITY_SET = new Set(PM_SIGNAL_COMMODITY_SYMBOLS.map((s) => s.toUpperCase()));
|
|
@@ -316,6 +327,19 @@ export function checkIsIndexMode(exchange) {
|
|
|
316
327
|
return true;
|
|
317
328
|
return checkIsExchangeInSet(exchange, INDEX_MODE_EXCHANGES_SET);
|
|
318
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* The family of an index-mode venue (IndexModeFamily), undefined off index mode. A CME-governed venue that reads as
|
|
332
|
+
* index mode (the futures policy off, failing closed to commodity semantics) is `cme`. A venue the index-mode set
|
|
333
|
+
* holds outside every family list reads undefined: its readers decide nothing for it (the family guard in
|
|
334
|
+
* tests/utility/wrun/wrun-run-interval.util.spec.ts fails on one).
|
|
335
|
+
*/
|
|
336
|
+
export function indexModeFamilyOf(exchange) {
|
|
337
|
+
if (!checkIsIndexMode(exchange))
|
|
338
|
+
return undefined;
|
|
339
|
+
if (isCmeGoverned(exchange))
|
|
340
|
+
return 'cme';
|
|
341
|
+
return exchange === undefined ? undefined : INDEX_MODE_FAMILY_BY_VENUE.get(exchange);
|
|
342
|
+
}
|
|
319
343
|
/** An index venue (`INDEX_VENUE_EXCHANGES`): quote series in many time zones, no US session grid. */
|
|
320
344
|
export function checkIsIndexVenue(exchange) {
|
|
321
345
|
return checkIsExchangeInSet(exchange, INDEX_VENUE_EXCHANGES_SET);
|
|
@@ -73,9 +73,13 @@ export interface RunBarSpan {
|
|
|
73
73
|
export declare function runBarSpan(stamp: number, run: RunBarCalendar): RunBarSpan;
|
|
74
74
|
/**
|
|
75
75
|
* The close of the run bar after the one stamped `stamp`: from there on a chart bar shows a run bar
|
|
76
|
-
* later than it.
|
|
77
|
-
*
|
|
78
|
-
*
|
|
76
|
+
* later than it. Off the lattice the next run bar is the run bucket, on `stamp`'s own phase, of the
|
|
77
|
+
* first chart bar (`chartTimes`, ascending) at or after `stamp`'s close: with no gap that is the
|
|
78
|
+
* bucket opening at the close (`stamp + 2 * intervalMs`, also the answer when no chart bar reaches
|
|
79
|
+
* the close), and after a session gap off the lattice (a stock's night or weekend, the index venue,
|
|
80
|
+
* forex below 4h) it is the bucket the chart resumes in, so the bars after the gap show `stamp`
|
|
81
|
+
* rather than nothing. On the session lattice a gap (the daily halt, a weekend, a holiday) holds no
|
|
82
|
+
* run bar, so the next one is the run bar of the first chart bar at or after its close: that chart
|
|
79
83
|
* bar's session bar when `stamp` is one, else the run bar it opens (a session reopens on a run
|
|
80
84
|
* bar's open, a regular-hours one included). Infinity when no chart bar reaches that close.
|
|
81
85
|
*/
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* template path until replay can serve run-interval candles clipped at the replay cursor.
|
|
13
13
|
*/
|
|
14
14
|
import { Intervals } from '../../constants/interval.constants.js';
|
|
15
|
+
import { anchoredGridFloorMs } from './calendar-interval.util.js';
|
|
15
16
|
import { CME_SESSION_LATTICE, sessionLatticeBarEndMs, sessionLatticeBarOpenMs, sessionLatticeBucketMs, sessionLatticeById, } from './session-lattice.util.js';
|
|
16
17
|
/**
|
|
17
18
|
* Built-ins whose `timeframe` input runs the engine at that interval: every built-in template with
|
|
@@ -147,16 +148,26 @@ function firstIndexAtOrAfter(times, time) {
|
|
|
147
148
|
}
|
|
148
149
|
/**
|
|
149
150
|
* The close of the run bar after the one stamped `stamp`: from there on a chart bar shows a run bar
|
|
150
|
-
* later than it.
|
|
151
|
-
*
|
|
152
|
-
*
|
|
151
|
+
* later than it. Off the lattice the next run bar is the run bucket, on `stamp`'s own phase, of the
|
|
152
|
+
* first chart bar (`chartTimes`, ascending) at or after `stamp`'s close: with no gap that is the
|
|
153
|
+
* bucket opening at the close (`stamp + 2 * intervalMs`, also the answer when no chart bar reaches
|
|
154
|
+
* the close), and after a session gap off the lattice (a stock's night or weekend, the index venue,
|
|
155
|
+
* forex below 4h) it is the bucket the chart resumes in, so the bars after the gap show `stamp`
|
|
156
|
+
* rather than nothing. On the session lattice a gap (the daily halt, a weekend, a holiday) holds no
|
|
157
|
+
* run bar, so the next one is the run bar of the first chart bar at or after its close: that chart
|
|
153
158
|
* bar's session bar when `stamp` is one, else the run bar it opens (a session reopens on a run
|
|
154
159
|
* bar's open, a regular-hours one included). Infinity when no chart bar reaches that close.
|
|
155
160
|
*/
|
|
156
161
|
export function nextRunBarCloseMs(stamp, chartTimes, run) {
|
|
157
162
|
const lattice = runLattice(run);
|
|
158
|
-
if (lattice === null)
|
|
159
|
-
|
|
163
|
+
if (lattice === null) {
|
|
164
|
+
const close = stamp + run.intervalMs;
|
|
165
|
+
const at = firstIndexAtOrAfter(chartTimes, close);
|
|
166
|
+
if (at === chartTimes.length)
|
|
167
|
+
return stamp + 2 * run.intervalMs;
|
|
168
|
+
// The run grid is known by its own bars only (a stock's hours open on the session's 14:30Z, not on the clock's).
|
|
169
|
+
return anchoredGridFloorMs(chartTimes[at], run.intervalMs, close) + run.intervalMs;
|
|
170
|
+
}
|
|
160
171
|
const sessionClose = sessionLatticeBarEndMs(lattice, stamp, run.intervalMs);
|
|
161
172
|
const at = firstIndexAtOrAfter(chartTimes, sessionClose ?? stamp + run.intervalMs);
|
|
162
173
|
if (at === chartTimes.length)
|
|
@@ -52,6 +52,8 @@ export declare function getGovernedFuturesScheduleStatus(nowMs: number): Governe
|
|
|
52
52
|
* listed; add a root only with that evidence (the NCI/MCI crypto-index pair is
|
|
53
53
|
* listed on exactly that evidence: order flow on 2026-08-22 13:15Z).
|
|
54
54
|
* The bar-grid parity fixture (src/fixtures/bar-grid-parity/typed-session.json) lists these roots.
|
|
55
|
+
* The list also decides who builds a custom size's candle history on these roots: the gateway builds none of them,
|
|
56
|
+
* so the app does, by rule and before any request (typed-history-door.util `typedHistoryFromServer`).
|
|
55
57
|
*/
|
|
56
58
|
export declare const CME_ALWAYS_ON_ROOTS: ReadonlySet<string>;
|
|
57
59
|
/** Futures root of a continuous (`BTC1!`), monthly (`BTCQ6`, `1OZV6`) or
|
|
@@ -154,6 +154,8 @@ export function getGovernedFuturesScheduleStatus(nowMs) {
|
|
|
154
154
|
* listed; add a root only with that evidence (the NCI/MCI crypto-index pair is
|
|
155
155
|
* listed on exactly that evidence: order flow on 2026-08-22 13:15Z).
|
|
156
156
|
* The bar-grid parity fixture (src/fixtures/bar-grid-parity/typed-session.json) lists these roots.
|
|
157
|
+
* The list also decides who builds a custom size's candle history on these roots: the gateway builds none of them,
|
|
158
|
+
* so the app does, by rule and before any request (typed-history-door.util `typedHistoryFromServer`).
|
|
157
159
|
*/
|
|
158
160
|
export const CME_ALWAYS_ON_ROOTS = new Set([
|
|
159
161
|
// Cryptocurrency futures + options: standard and micro, Bitcoin Friday weeklies.
|
|
@@ -15,5 +15,20 @@ export declare function isFiniteNumber(value: unknown): value is number;
|
|
|
15
15
|
* RUN_INTERVAL_WARMUP_BARS, at most RUN_INTERVAL_MAX_RUN_BARS. An unknown lookback reads the floor.
|
|
16
16
|
*/
|
|
17
17
|
export declare function runIntervalWarmupBars(lookbackBars: number | null | undefined): number;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* A warm-up start held at or after `MIN_REAL_CHART_TIME_MS`: a start at or below 0 reads down the wire as no window
|
|
20
|
+
* (the chart's own range at the chart's interval) or as now minus the period. A start past the floor is unchanged;
|
|
21
|
+
* one before it moves to the first edge of its own `stepMs` grid at or after the floor (the floor itself without a
|
|
22
|
+
* fixed step, a calendar bar's open).
|
|
23
|
+
*/
|
|
24
|
+
export declare function warmupStartAtFloorMs(startMs: number, stepMs?: number): number;
|
|
25
|
+
/** Open of the first warm-up run bar: `warmupBars` run bars below the run bar holding `chartFirstTs`, never before the floor. */
|
|
19
26
|
export declare function runIntervalWarmupStartTs(chartFirstTs: number, runMs: number, warmupBars: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Chart bars a selected timeframe rebuilt from the chart's bars needs: the warm-up in selected bars plus the partial
|
|
29
|
+
* first one the history may start inside, each `ceil(selected / chart)` chart bars long. The alert engine re-runs the
|
|
30
|
+
* template over its kept window on every bar, so the closed selected-timeframe history the template accumulates
|
|
31
|
+
* (htfHistory and friends) only ever spans that window (builtinAlertScript.util, alert-overlay-target.util); a wrun
|
|
32
|
+
* twin on the package's own path rebuilds its Timeframe the same way (wrunTwinChartLookbackBars).
|
|
33
|
+
*/
|
|
34
|
+
export declare function selectedTimeframeHistoryBars(warmup: number, timeframeMs: number, intervalMs: number): number;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* the chart-host package with the phase 2 closure. The old module re-exports it.
|
|
6
6
|
*/
|
|
7
7
|
import { LOCAL_TECHNICAL_SCRIPT_MAX_REPLAY_BARS } from './local-technical-script-range.leaf.js';
|
|
8
|
+
import { MIN_REAL_CHART_TIME_MS } from './chart-time-domain.util.js';
|
|
8
9
|
/** Floor of the warm-up fetched before the run bar holding the chart's first loaded bar, in run bars. */
|
|
9
10
|
export const RUN_INTERVAL_WARMUP_BARS = 300;
|
|
10
11
|
/**
|
|
@@ -29,7 +30,32 @@ export function runIntervalWarmupBars(lookbackBars) {
|
|
|
29
30
|
const scaled = Math.ceil(lookbackBars) * RUN_INTERVAL_WARMUP_BARS_PER_LOOKBACK_BAR;
|
|
30
31
|
return Math.min(RUN_INTERVAL_MAX_RUN_BARS, Math.max(RUN_INTERVAL_WARMUP_BARS, scaled));
|
|
31
32
|
}
|
|
32
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* A warm-up start held at or after `MIN_REAL_CHART_TIME_MS`: a start at or below 0 reads down the wire as no window
|
|
35
|
+
* (the chart's own range at the chart's interval) or as now minus the period. A start past the floor is unchanged;
|
|
36
|
+
* one before it moves to the first edge of its own `stepMs` grid at or after the floor (the floor itself without a
|
|
37
|
+
* fixed step, a calendar bar's open).
|
|
38
|
+
*/
|
|
39
|
+
export function warmupStartAtFloorMs(startMs, stepMs) {
|
|
40
|
+
if (!(startMs < MIN_REAL_CHART_TIME_MS))
|
|
41
|
+
return startMs;
|
|
42
|
+
if (stepMs === undefined || !(stepMs > 0))
|
|
43
|
+
return MIN_REAL_CHART_TIME_MS;
|
|
44
|
+
return startMs + Math.ceil((MIN_REAL_CHART_TIME_MS - startMs) / stepMs) * stepMs;
|
|
45
|
+
}
|
|
46
|
+
/** Open of the first warm-up run bar: `warmupBars` run bars below the run bar holding `chartFirstTs`, never before the floor. */
|
|
33
47
|
export function runIntervalWarmupStartTs(chartFirstTs, runMs, warmupBars) {
|
|
34
|
-
|
|
48
|
+
const chartRunBarOpen = Math.floor(chartFirstTs / runMs) * runMs;
|
|
49
|
+
// Never past the chart's own run bar: a chart stamped before the floor keeps its unfloored start.
|
|
50
|
+
return Math.min(chartRunBarOpen, warmupStartAtFloorMs(chartRunBarOpen - warmupBars * runMs, runMs));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Chart bars a selected timeframe rebuilt from the chart's bars needs: the warm-up in selected bars plus the partial
|
|
54
|
+
* first one the history may start inside, each `ceil(selected / chart)` chart bars long. The alert engine re-runs the
|
|
55
|
+
* template over its kept window on every bar, so the closed selected-timeframe history the template accumulates
|
|
56
|
+
* (htfHistory and friends) only ever spans that window (builtinAlertScript.util, alert-overlay-target.util); a wrun
|
|
57
|
+
* twin on the package's own path rebuilds its Timeframe the same way (wrunTwinChartLookbackBars).
|
|
58
|
+
*/
|
|
59
|
+
export function selectedTimeframeHistoryBars(warmup, timeframeMs, intervalMs) {
|
|
60
|
+
return (Math.ceil(warmup) + 1) * Math.ceil(timeframeMs / intervalMs);
|
|
35
61
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a chart market is ONE option contract, from its metadata alone, with no read: an OPRA-governed venue, an
|
|
3
|
+
* option category (a CME option, a crypto option the directory names), or a symbol a plain (crypto) option venue's
|
|
4
|
+
* grammar parses (a saved crypto option that carries no category). The venue's perpetual and its spot markets read
|
|
5
|
+
* false.
|
|
6
|
+
*
|
|
7
|
+
* The one rule two readers share: the market facts (`wrunChartOptionContract`, the `option_contract` host fill) and
|
|
8
|
+
* the Position drawing's sizing market (the app's sizing-market.util). A leaf on purpose: the sizing market is read
|
|
9
|
+
* before the first candle, and this keeps the market facts module off that path
|
|
10
|
+
* (tests/perf/pre-candle-budget.spec.ts).
|
|
11
|
+
*/
|
|
12
|
+
import { Category } from '@orangecharts/orange-v2-pb-common';
|
|
13
|
+
import { isOpraGoverned } from '../v2/opra-governed.util.js';
|
|
14
|
+
import { isPlainOptionContract } from './option-trade-units.util.js';
|
|
15
|
+
/** `exchange` is the venue code, uppercase; `category` is the chart metadata's (the enum number or its name). */
|
|
16
|
+
export function isOptionContractMarket(exchange, symbol, category) {
|
|
17
|
+
return (isOpraGoverned(exchange) ||
|
|
18
|
+
category === Category.OPTION ||
|
|
19
|
+
category === 'OPTION' ||
|
|
20
|
+
isPlainOptionContract(exchange, symbol));
|
|
21
|
+
}
|
|
@@ -176,13 +176,43 @@ export declare function resolveStoredOptionTrade(trade: {
|
|
|
176
176
|
export declare function liveOptionPrintPremium(price: number, coin: number, units: OptionTradeUnits | null | undefined): number | null;
|
|
177
177
|
/** A live print's premium in USD: on a coin book through the index at the print, else null ("cannot denominate"). */
|
|
178
178
|
export declare function liveOptionPrintUsdPremium(price: number, coin: number, units: OptionTradeUnits | null | undefined, indexPrice?: number): number | null;
|
|
179
|
+
/** The market a live amount was printed on: its own series' exchange and symbol (null: no market known). */
|
|
180
|
+
export type LiveAmountMarket = {
|
|
181
|
+
readonly exchange?: string | null;
|
|
182
|
+
readonly symbol?: string | null;
|
|
183
|
+
} | null;
|
|
179
184
|
/**
|
|
180
|
-
* The USD of an amount live-feed delivered on its COIN arm, on any market
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
185
|
+
* The USD of an amount live-feed delivered on its COIN arm, on any market. The market is required: a price distance
|
|
186
|
+
* or a price times an amount is money only with the contract's point value, and a caller that forgets the market
|
|
187
|
+
* prices a CME point at $1 (ES is $50 a point, MNQ $2).
|
|
188
|
+
* - A CME Group market (`wrunCmeDollarPointValue`): the amount is contracts, worth amount x price x the root's dollar
|
|
189
|
+
* point value; null where the table prices none (a grain, an option contract, a root off the table).
|
|
190
|
+
* - An option contract (`units` its trade units, answered or `OPTION_TRADE_UNITS_UNKNOWN`): the premium by the
|
|
191
|
+
* live-print rule, null while the units are unknown and on a coin-premium book.
|
|
192
|
+
* - Every other market (`units` null): price x amount.
|
|
193
|
+
* The one conversion a live merge needs to show a coin-arm amount in USD. A null is "no dollar figure": never draw or
|
|
194
|
+
* sum it as 0.
|
|
184
195
|
*/
|
|
185
|
-
export declare function liveAmountUsd(price: number, amount: number, units: OptionTradeUnits | null | undefined): number | null;
|
|
196
|
+
export declare function liveAmountUsd(price: number, amount: number, units: OptionTradeUnits | null | undefined, market: LiveAmountMarket): number | null;
|
|
197
|
+
/**
|
|
198
|
+
* The one unit a volume surface counts a market in (Market Stats Volume Flow, Volume Stats): dollars at `pointValue`
|
|
199
|
+
* dollars a point (1 off the CME family, the root's dollar point value on CME: ES 50), or contracts on a CME market
|
|
200
|
+
* whose dollars per point the table cannot prove (`wrunCmeDollarPointValue` null: a grain, an option contract, a root
|
|
201
|
+
* off the table). History and live accumulate in this same unit, and a contracts surface prints no `$`.
|
|
202
|
+
*/
|
|
203
|
+
export type MarketVolumeUnit = {
|
|
204
|
+
kind: 'dollars';
|
|
205
|
+
pointValue: number;
|
|
206
|
+
} | {
|
|
207
|
+
kind: 'contracts';
|
|
208
|
+
};
|
|
209
|
+
/** A market's volume unit (`MarketVolumeUnit`). */
|
|
210
|
+
export declare function marketVolumeUnit(market: LiveAmountMarket): MarketVolumeUnit;
|
|
211
|
+
/**
|
|
212
|
+
* A coin-arm live amount in its market's volume unit (`marketVolumeUnit`): the amount itself in contracts, else its
|
|
213
|
+
* USD (`liveAmountUsd`; null when it has none, an option whose units are unknown).
|
|
214
|
+
*/
|
|
215
|
+
export declare function liveAmountInMarketUnit(price: number, amount: number, units: OptionTradeUnits | null | undefined, market: LiveAmountMarket): number | null;
|
|
186
216
|
/** Every value one live print resolves to, by the live-print rules: its delivered amount is the coin size. */
|
|
187
217
|
export declare function resolveLiveOptionPrint(print: {
|
|
188
218
|
price: number;
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
import { Category } from '@orangecharts/orange-v2-pb-common';
|
|
69
69
|
import { parseOptionSymbol } from './option-symbol.util.js';
|
|
70
70
|
import { optionVenueForExchange } from './option-venue.util.js';
|
|
71
|
+
import { wrunCmeDollarPointValue } from '../wrun/wrun-cme-root-specs.util.js';
|
|
71
72
|
const positiveOrNull = (value) => {
|
|
72
73
|
const number = typeof value === 'number' ? value : typeof value === 'string' ? Number(value) : Number.NaN;
|
|
73
74
|
return Number.isFinite(number) && number > 0 ? number : null;
|
|
@@ -260,14 +261,39 @@ export function liveOptionPrintUsdPremium(price, coin, units, indexPrice) {
|
|
|
260
261
|
return index === null ? null : finiteOrNull(premium * index);
|
|
261
262
|
}
|
|
262
263
|
/**
|
|
263
|
-
* The USD of an amount live-feed delivered on its COIN arm, on any market
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
264
|
+
* The USD of an amount live-feed delivered on its COIN arm, on any market. The market is required: a price distance
|
|
265
|
+
* or a price times an amount is money only with the contract's point value, and a caller that forgets the market
|
|
266
|
+
* prices a CME point at $1 (ES is $50 a point, MNQ $2).
|
|
267
|
+
* - A CME Group market (`wrunCmeDollarPointValue`): the amount is contracts, worth amount x price x the root's dollar
|
|
268
|
+
* point value; null where the table prices none (a grain, an option contract, a root off the table).
|
|
269
|
+
* - An option contract (`units` its trade units, answered or `OPTION_TRADE_UNITS_UNKNOWN`): the premium by the
|
|
270
|
+
* live-print rule, null while the units are unknown and on a coin-premium book.
|
|
271
|
+
* - Every other market (`units` null): price x amount.
|
|
272
|
+
* The one conversion a live merge needs to show a coin-arm amount in USD. A null is "no dollar figure": never draw or
|
|
273
|
+
* sum it as 0.
|
|
267
274
|
*/
|
|
268
|
-
export function liveAmountUsd(price, amount, units) {
|
|
275
|
+
export function liveAmountUsd(price, amount, units, market) {
|
|
276
|
+
const pointValue = wrunCmeDollarPointValue(market);
|
|
277
|
+
if (pointValue !== undefined)
|
|
278
|
+
return pointValue === null ? null : price * amount * pointValue;
|
|
269
279
|
return units ? liveOptionPrintUsdPremium(price, amount, units) : price * amount;
|
|
270
280
|
}
|
|
281
|
+
/** A market's volume unit (`MarketVolumeUnit`). */
|
|
282
|
+
export function marketVolumeUnit(market) {
|
|
283
|
+
const pointValue = wrunCmeDollarPointValue(market);
|
|
284
|
+
if (pointValue === undefined)
|
|
285
|
+
return { kind: 'dollars', pointValue: 1 };
|
|
286
|
+
return pointValue === null ? { kind: 'contracts' } : { kind: 'dollars', pointValue };
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* A coin-arm live amount in its market's volume unit (`marketVolumeUnit`): the amount itself in contracts, else its
|
|
290
|
+
* USD (`liveAmountUsd`; null when it has none, an option whose units are unknown).
|
|
291
|
+
*/
|
|
292
|
+
export function liveAmountInMarketUnit(price, amount, units, market) {
|
|
293
|
+
if (marketVolumeUnit(market).kind === 'contracts')
|
|
294
|
+
return amount;
|
|
295
|
+
return liveAmountUsd(price, amount, units, market);
|
|
296
|
+
}
|
|
271
297
|
/** Every value one live print resolves to, by the live-print rules: its delivered amount is the coin size. */
|
|
272
298
|
export function resolveLiveOptionPrint(print, units, indexPrice) {
|
|
273
299
|
const coinSize = Number.isFinite(print.coin) ? print.coin : null;
|
|
@@ -73,8 +73,7 @@ import { governedContractCoin } from '../chart/governed-contract-coin.util.js';
|
|
|
73
73
|
import { PUBLISHER_ONLY_EXCHANGES } from '../../constants/economic.constants.js';
|
|
74
74
|
import { checkIsEconomic, getMarketKind } from '../chart/marketKind.util.js';
|
|
75
75
|
import { optionsMarketUnderlyingVenue, optionVenueForExchange } from '../options/option-venue.util.js';
|
|
76
|
-
import {
|
|
77
|
-
import { isOpraGoverned } from '../v2/opra-governed.util.js';
|
|
76
|
+
import { isOptionContractMarket } from '../options/option-contract-market.leaf.js';
|
|
78
77
|
import { WRUN_LANE_CURRENCY_AUTO, WRUN_MARKET_FACT_FILLS, WRUN_MARKET_KINDS, WRUN_MARKET_QUOTE_IS_USD, WRUN_MARKET_SESSION_OPEN_CME, WRUN_MARKET_SESSION_OPEN_FOREX, wrunLaneCurrency, wrunMarketSizeUnit, wrunMarketZoneCode, wrunCoinLegSource, wrunFollowsCoin, wrunRowVisibleHere, wrunVisibleByNeedsKind, wrunVisibleBySettingKeys, } from './wrun-market-facts.util.js';
|
|
79
78
|
import { wrunParamValuesFromSettings } from './wrun-param-values.util.js';
|
|
80
79
|
import { isWrunLegStreamClass } from './wrun-leg-stream-classes.js';
|
|
@@ -417,7 +416,8 @@ export function wrunChartOptionContract(market) {
|
|
|
417
416
|
if (market === undefined || venue === undefined)
|
|
418
417
|
return 0;
|
|
419
418
|
const symbol = typeof market.symbol === 'string' ? market.symbol : '';
|
|
420
|
-
|
|
419
|
+
// The one rule the Position drawing's sizing market reads too (option-contract-market.leaf).
|
|
420
|
+
return isOptionContractMarket(venue, symbol, market.category) ? 1 : 0;
|
|
421
421
|
}
|
|
422
422
|
/** The host_fill words whose values the host fill carries off the chart's market (wrunMarketFactsFor): the five
|
|
423
423
|
* market facts, the option multiplier (om WRUN_OPTION_FACT_FILLS, a word of the kit's WrunParamHostFill since
|
|
@@ -90,6 +90,7 @@
|
|
|
90
90
|
import type { WrunIndicatorMetadata, WrunMetadataParam, WrunParamStyleBinding } from '../../interfaces/wrun-runtime.interface.js';
|
|
91
91
|
import { type WrunVisibilityPrefix, type WrunVisibilitySheet } from './wrun-visibility-table.js';
|
|
92
92
|
import { type WrunRgba } from './wrun-color-facts.util.js';
|
|
93
|
+
import { wrunSelectOptionValue } from './wrun-row-scalars.leaf.js';
|
|
93
94
|
export { isWrunHeatmapSensitivityRowKey, isWrunHudLookRowKey, isWrunHudPlaceRowKey, isWrunHudViewerRowKey, isWrunStyleRowKey, isWrunViewerRowKey, packWrunColor, parseWrunColor, parseWrunHudViewerRowKey, WRUN_HUD_LOOK_ROW_PREFIX, WRUN_HUD_VIEWER_ROWS, WRUN_STYLE_ROW_PREFIX, wrunHudViewerRowKey, type WrunHudViewerRow, type WrunRgba, } from './wrun-color-facts.util.js';
|
|
94
95
|
declare const WRUN_LINE_STYLES: readonly ["solid", "dashed", "dotted"];
|
|
95
96
|
export type WrunLineStyle = (typeof WRUN_LINE_STYLES)[number];
|
|
@@ -114,19 +115,7 @@ export declare function wrunParamChoices(param: WrunMetadataParam): WrunParamCho
|
|
|
114
115
|
* undefined when it picks no choice. The ONE read of a select bound to a word knob (contract F's `underlying`): the
|
|
115
116
|
* planners' (derived-roots.util `resolveWrunUnderlyingSettingKnob`) and the painted sheet's (`laneWordWrites`). */
|
|
116
117
|
export declare function wrunSelectPickWord(param: WrunMetadataParam, value: number | undefined): string | undefined;
|
|
117
|
-
|
|
118
|
-
* A select setting resolved against the row's option strings and their
|
|
119
|
-
* labels: the ONE select read. The dialog's row codec, the run values, the
|
|
120
|
-
* cloud param map, the sheet's host pins and its style targets all read a
|
|
121
|
-
* persisted choice through it, so every lane agrees. A string that is an
|
|
122
|
-
* option is itself; an option label is its option; a number, or a numeric
|
|
123
|
-
* string, is the option whose string it is, else (an integer that names no
|
|
124
|
-
* option) the option at that index; anything else, an index past the
|
|
125
|
-
* options included (a choice persisted before the author dropped one), is
|
|
126
|
-
* undefined, and the reader keeps its declared default. A row without
|
|
127
|
-
* options passes the value through.
|
|
128
|
-
*/
|
|
129
|
-
export declare function wrunSelectOptionValue(options: ReadonlyArray<string>, labels: ReadonlyArray<string>, raw: unknown): string | undefined;
|
|
118
|
+
export { wrunSelectOptionValue };
|
|
130
119
|
/** A select PARAM's setting as its option value (the number init() and the
|
|
131
120
|
* sheet writes take), through the one select read over the param's choice
|
|
132
121
|
* set; undefined when the param declares no usable choice set (the number
|
|
@@ -98,6 +98,7 @@ import { WRUN_LEVELS_COLOR_PICKED_KEY } from './wrun-style-flags.util.js';
|
|
|
98
98
|
import { WRUN_OPTION_LANE_WORDS, WRUN_OPTION_VIEWS, wrunOptionViewParamKnobs } from './wrun-option-views.util.js';
|
|
99
99
|
import { findWrunVisibilityTarget, wrunVisibilitySectionOfPrefix, wrunVisibilityTargetAt, } from './wrun-visibility-table.js';
|
|
100
100
|
import { isWrunHudViewerRowKey, packWrunColor, parseWrunColor, parseWrunHudViewerRowKey, WRUN_HEATMAP_SENSITIVITY_ROW_RE, wrunHudViewerRowKey, } from './wrun-color-facts.util.js';
|
|
101
|
+
import { wrunSelectOptionValue } from './wrun-row-scalars.leaf.js';
|
|
101
102
|
// The key predicates and the colour parse are thin facts boot-path readers take without this
|
|
102
103
|
// module (wrun-color-facts.util); every name stays exported here for this module's readers.
|
|
103
104
|
export { isWrunHeatmapSensitivityRowKey, isWrunHudLookRowKey, isWrunHudPlaceRowKey, isWrunHudViewerRowKey, isWrunStyleRowKey, isWrunViewerRowKey, packWrunColor, parseWrunColor, parseWrunHudViewerRowKey, WRUN_HUD_LOOK_ROW_PREFIX, WRUN_HUD_VIEWER_ROWS, WRUN_STYLE_ROW_PREFIX, wrunHudViewerRowKey, } from './wrun-color-facts.util.js';
|
|
@@ -169,35 +170,8 @@ export function wrunSelectPickWord(param, value) {
|
|
|
169
170
|
const word = at < 0 ? undefined : Array.isArray(param.style_values) ? param.style_values[at] : choices?.[at]?.label;
|
|
170
171
|
return typeof word === 'string' ? word : undefined;
|
|
171
172
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
* labels: the ONE select read. The dialog's row codec, the run values, the
|
|
175
|
-
* cloud param map, the sheet's host pins and its style targets all read a
|
|
176
|
-
* persisted choice through it, so every lane agrees. A string that is an
|
|
177
|
-
* option is itself; an option label is its option; a number, or a numeric
|
|
178
|
-
* string, is the option whose string it is, else (an integer that names no
|
|
179
|
-
* option) the option at that index; anything else, an index past the
|
|
180
|
-
* options included (a choice persisted before the author dropped one), is
|
|
181
|
-
* undefined, and the reader keeps its declared default. A row without
|
|
182
|
-
* options passes the value through.
|
|
183
|
-
*/
|
|
184
|
-
export function wrunSelectOptionValue(options, labels, raw) {
|
|
185
|
-
if (typeof raw === 'string') {
|
|
186
|
-
if (options.length === 0 || options.includes(raw))
|
|
187
|
-
return raw;
|
|
188
|
-
const at = labels.indexOf(raw);
|
|
189
|
-
if (at >= 0 && options[at] !== undefined)
|
|
190
|
-
return options[at];
|
|
191
|
-
const numeric = raw.trim() === '' ? Number.NaN : Number(raw);
|
|
192
|
-
return Number.isFinite(numeric) ? wrunSelectOptionValue(options, labels, numeric) : undefined;
|
|
193
|
-
}
|
|
194
|
-
if (typeof raw !== 'number' || !Number.isFinite(raw))
|
|
195
|
-
return undefined;
|
|
196
|
-
const text = String(raw);
|
|
197
|
-
if (options.length === 0 || options.includes(text))
|
|
198
|
-
return text;
|
|
199
|
-
return Number.isInteger(raw) && options[raw] !== undefined ? options[raw] : undefined;
|
|
200
|
-
}
|
|
173
|
+
// The ONE select read lives in the import-free row scalars leaf (settings-templates reads it); re-exported here.
|
|
174
|
+
export { wrunSelectOptionValue };
|
|
201
175
|
/** A select PARAM's setting as its option value (the number init() and the
|
|
202
176
|
* sheet writes take), through the one select read over the param's choice
|
|
203
177
|
* set; undefined when the param declares no usable choice set (the number
|
|
@@ -15,7 +15,7 @@ export declare function wrunLaneWarmupBars(sheet: Pick<WrunIndicatorMetadata, 'p
|
|
|
15
15
|
* intervals back, or `bars` calendar bars on a 1M, 3M, 6M or 1Y chart (the kit's `evaluateFromMs`). Clock time, as the
|
|
16
16
|
* cloud counts it: a venue's closed hours inside the span hold no candle, so a session market evaluates fewer rows.
|
|
17
17
|
*/
|
|
18
|
-
export declare function wrunLaneWarmupFromMs(fromMs: number, bars: number, intervalMs: number): number;
|
|
18
|
+
export declare function wrunLaneWarmupFromMs(fromMs: number, bars: number, intervalMs: number, signedTime?: boolean): number;
|
|
19
19
|
/** A 24-hour day of one-minute bars (1,440) with slack: the lanes' asks widen by the head, so its reach is bounded. */
|
|
20
20
|
export declare const WRUN_TRADE_DATE_HEAD_CAP_BARS = 1500;
|
|
21
21
|
/** The open of the trade date holding `firstBarMs`, to the minute; undefined past the cap, where a head short of the open leaves the total partial. */
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
* which yet.
|
|
33
33
|
*/
|
|
34
34
|
import { calendarMonthsOfMs } from '../chart/calendar-interval.util.js';
|
|
35
|
+
import { warmupStartAtFloorMs } from '../chart/run-interval-warmup.leaf.js';
|
|
35
36
|
/** The planner's warm-up when the sheet declares no `warmup_bars` (the kit's default). */
|
|
36
37
|
const WRUN_LANE_WARMUP_DEFAULT_BARS = 2;
|
|
37
38
|
/** The largest param value the planner reads as a lookback (the kit's LOOKBACK_PARAM_CAP): a bigger number is a
|
|
@@ -118,15 +119,19 @@ export function wrunLaneWarmupBars(sheet, paramValues, cap) {
|
|
|
118
119
|
* intervals back, or `bars` calendar bars on a 1M, 3M, 6M or 1Y chart (the kit's `evaluateFromMs`). Clock time, as the
|
|
119
120
|
* cloud counts it: a venue's closed hours inside the span hold no candle, so a session market evaluates fewer rows.
|
|
120
121
|
*/
|
|
121
|
-
export function wrunLaneWarmupFromMs(fromMs, bars, intervalMs) {
|
|
122
|
+
export function wrunLaneWarmupFromMs(fromMs, bars, intervalMs, signedTime = false) {
|
|
122
123
|
if (!(bars > 0) || !(intervalMs > 0))
|
|
123
124
|
return fromMs;
|
|
124
125
|
const months = calendarMonthsOfMs(intervalMs);
|
|
126
|
+
// `signedTime`: the chart's candle lane reads a start before 1970 as an absolute time (an economic series, whose
|
|
127
|
+
// history reaches there), so the warm-up keeps its own start. Every other lane reads it as now minus the period.
|
|
128
|
+
// Never past the window's own start: a window opening before the floor keeps its unfloored warm-up.
|
|
129
|
+
const atFloor = (startMs, stepMs) => signedTime ? startMs : Math.min(fromMs, warmupStartAtFloorMs(startMs, stepMs));
|
|
125
130
|
if (months === null)
|
|
126
|
-
return fromMs - bars * intervalMs;
|
|
131
|
+
return atFloor(fromMs - bars * intervalMs, intervalMs);
|
|
127
132
|
const at = new Date(fromMs);
|
|
128
133
|
const month = at.getUTCMonth();
|
|
129
|
-
return Date.UTC(at.getUTCFullYear(), month - (month % months) - bars * months, 1);
|
|
134
|
+
return atFloor(Date.UTC(at.getUTCFullYear(), month - (month % months) - bars * months, 1));
|
|
130
135
|
}
|
|
131
136
|
/** A 24-hour day of one-minute bars (1,440) with slack: the lanes' asks widen by the head, so its reach is bounded. */
|
|
132
137
|
export const WRUN_TRADE_DATE_HEAD_CAP_BARS = 1500;
|
|
@@ -81,13 +81,13 @@ import { isInScriptSourceSession, isVolumeProfileLiveFrameInSession, tapeSourceS
|
|
|
81
81
|
import { parseWrunTapeHistory, wrunTapeHistoryOf } from './wrun-tape-source.util.js';
|
|
82
82
|
import { noteWrunCoinTapePrice } from './wrun-tape-coins.util.js';
|
|
83
83
|
import { wrunDollarUnitReader } from './wrun-dollar-unit-port.leaf.js';
|
|
84
|
-
import { wrunCmeDollarPointValue } from './wrun-cme-root-specs.util.js';
|
|
85
84
|
import { wrunChartHostEnv } from '../../host-env.js';
|
|
86
85
|
import { v2LiveTradePrintBelowFloor } from '../chart/kscript-live-coalesce.util.js';
|
|
87
86
|
import { bookLiveBucketMs, bookLiveBucketRows } from '../chart/book-live-bucket.util.js';
|
|
88
87
|
import { liveFeedSeriesMatchesChartStream } from '../chart/live-feed-series-match.leaf.js';
|
|
89
88
|
import { KSCRIPT_CURRENT_EXCHANGE_SENTINEL, KSCRIPT_CURRENT_SYMBOL_SENTINEL, } from '../chart/kscript-live-source-identity.util.js';
|
|
90
89
|
import { liveBucketStartMs, liveBucketVenueOf } from '../chart/live-bucket.util.js';
|
|
90
|
+
import { resolveEquityLiveTradeGate } from '../chart/us-equities-session.util.js';
|
|
91
91
|
import { hostBucketResolverFor, sourceRowHostBarResolverFor } from '../chart/host-bar-placement.util.js';
|
|
92
92
|
import { sourceRowsStraddleHostBars } from '../chart/index-host-tier.util.js';
|
|
93
93
|
import { wrunLaneServedOnMarket } from '../chart/index-mode-admission.util.js';
|
|
@@ -338,6 +338,15 @@ export function wrunLiveBucketTs(lane, tsMs, intervalMs, market) {
|
|
|
338
338
|
if (lane === 'book')
|
|
339
339
|
return bookLiveBucketMs(tsMs, intervalMs, bookVenueOf(market));
|
|
340
340
|
if (market && WRUN_SESSION_LATTICE_LANES.has(lane)) {
|
|
341
|
+
// The chart's own live gate first (resolveEquityLiveTradeGate): a stock's day or wider bar (the extended-hours
|
|
342
|
+
// chart's too) and a regular-session chart's bars take the cash session's prints only; liveBucketStartMs drops an
|
|
343
|
+
// off-session stamp only below a day (its 1D grid is the UTC floor, its 1W the Monday). A print is judged at its
|
|
344
|
+
// stamp; a profile frame is stamped at its window's end and judged by its own session check (the caller's
|
|
345
|
+
// isVolumeProfileLiveFrameInSession), so it is not judged here.
|
|
346
|
+
if (lane !== 'volume_profile' &&
|
|
347
|
+
resolveEquityLiveTradeGate(market.exchange, market.sessionType, tsMs, intervalMs).kind === 'outside') {
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
341
350
|
return liveBucketStartMs(tsMs, intervalMs, {
|
|
342
351
|
exchange: market.exchange,
|
|
343
352
|
symbol: market.symbol,
|
|
@@ -466,11 +475,9 @@ function coinArmUsd(point, price, amount) {
|
|
|
466
475
|
const series = isRecord(point.series) ? point.series : undefined;
|
|
467
476
|
const exchange = typeof series?.exchange === 'string' ? series.exchange : '';
|
|
468
477
|
const symbol = typeof series?.symbol === 'string' ? series.symbol : '';
|
|
469
|
-
// The coin arm counts contracts on a CME Group market:
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
return pointValue === null ? null : price * amount * pointValue;
|
|
473
|
-
return liveAmountUsd(price, amount, peekOptionTradeUnits({ exchange, symbol }));
|
|
478
|
+
// The coin arm counts contracts on a CME Group market: liveAmountUsd prices them by the root's point value, and a
|
|
479
|
+
// root with no point value gives no dollars (never close x contracts).
|
|
480
|
+
return liveAmountUsd(price, amount, peekOptionTradeUnits({ exchange, symbol }), { exchange, symbol });
|
|
474
481
|
}
|
|
475
482
|
/** K_BUY_SELL_VOLUME.mergeLiveDataPoint's reading of a TRADE_AGG point: the
|
|
476
483
|
* volume in coins, or its USD when the acquisition asked for USD (`coinArmUsd`:
|