@orangecharts/wrun-chart-host 0.15.0 → 0.17.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/constants/economic.constants.d.ts +2 -0
- package/dist/constants/economic.constants.js +2 -0
- package/dist/constants/feature-flags.constants.d.ts +13 -5
- package/dist/constants/feature-flags.constants.js +76 -35
- package/dist/constants/feature-limits.constants.d.ts +72 -4
- package/dist/constants/feature-limits.constants.js +104 -24
- package/dist/constants/interval.constants.js +5 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +12 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.js +14 -0
- package/dist/constants/marketCapabilities.constants.d.ts +9 -0
- package/dist/constants/marketCapabilities.constants.js +39 -11
- package/dist/constants/typed-indicator-source.leaf.d.ts +7 -0
- package/dist/constants/typed-indicator-source.leaf.js +47 -0
- package/dist/constants/typed-session-history-venue.leaf.d.ts +7 -0
- package/dist/constants/typed-session-history-venue.leaf.js +9 -0
- package/dist/constants/typed-width-fold.leaf.d.ts +52 -0
- package/dist/constants/typed-width-fold.leaf.js +101 -0
- package/dist/constants/typed-width-source.leaf.d.ts +24 -0
- package/dist/constants/typed-width-source.leaf.js +126 -0
- package/dist/constants/typed-width.leaf.d.ts +57 -0
- package/dist/constants/typed-width.leaf.js +78 -0
- package/dist/host-env.d.ts +10 -0
- package/dist/host-env.js +7 -0
- package/dist/host-ports.types.d.ts +23 -17
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +35 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +66 -3
- package/dist/interfaces/wrun-runtime.interface.js +11 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
- package/dist/market-data/billing.interface.d.ts +12 -45
- package/dist/market-data/billing.interface.js +2 -2
- package/dist/replay/replayLadder.js +7 -4
- package/dist/settings-templates/footprint-rows.d.ts +6 -0
- package/dist/settings-templates/footprint-rows.js +6 -0
- package/dist/settings-templates/frvp-fields.js +14 -0
- package/dist/settings-templates/indicator-fields.js +36 -0
- package/dist/settings-templates/tool-tables.generated.js +19 -1
- package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
- package/dist/utility/chart/cache-alignment.util.d.ts +42 -0
- package/dist/utility/chart/cache-alignment.util.js +88 -18
- package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
- package/dist/utility/chart/calendar-interval.util.js +152 -4
- package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
- package/dist/utility/chart/candle-bar-end.util.js +17 -6
- package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
- package/dist/utility/chart/chart-time-domain.util.js +13 -4
- package/dist/utility/chart/feed-interval.util.d.ts +4 -2
- package/dist/utility/chart/feed-interval.util.js +5 -2
- package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
- package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
- package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
- package/dist/utility/chart/footprint-display-mode.util.js +5 -0
- package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
- package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
- package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
- package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
- package/dist/utility/chart/history-wall.util.d.ts +13 -2
- package/dist/utility/chart/history-wall.util.js +11 -4
- package/dist/utility/chart/index-mode-admission.util.js +9 -1
- package/dist/utility/chart/index-mode.util.d.ts +2 -2
- package/dist/utility/chart/index-mode.util.js +12 -6
- package/dist/utility/chart/index-otc.leaf.d.ts +37 -0
- package/dist/utility/chart/index-otc.leaf.js +68 -0
- package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
- package/dist/utility/chart/interval-ladder.util.js +44 -4
- package/dist/utility/chart/interval-registry.util.d.ts +22 -1
- package/dist/utility/chart/interval-registry.util.js +50 -2
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
- package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
- package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
- package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
- package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
- package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
- package/dist/utility/chart/kscript-provenance-keys.util.js +6 -0
- package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
- package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
- package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
- package/dist/utility/chart/live-bucket.util.d.ts +29 -4
- package/dist/utility/chart/live-bucket.util.js +45 -12
- package/dist/utility/chart/market-session-schedule.util.d.ts +19 -0
- package/dist/utility/chart/market-session-schedule.util.js +2 -1
- package/dist/utility/chart/market-session.util.d.ts +62 -10
- package/dist/utility/chart/market-session.util.js +93 -13
- package/dist/utility/chart/marketKind.util.d.ts +11 -12
- package/dist/utility/chart/marketKind.util.js +45 -13
- package/dist/utility/chart/mixed-mode.util.d.ts +18 -0
- package/dist/utility/chart/om-target.util.js +6 -4
- package/dist/utility/chart/price-precision.util.d.ts +20 -6
- package/dist/utility/chart/price-precision.util.js +34 -7
- package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
- package/dist/utility/chart/profile-frame-window.util.js +12 -0
- package/dist/utility/chart/rth-session.util.d.ts +3 -1
- package/dist/utility/chart/rth-session.util.js +3 -1
- package/dist/utility/chart/script-source-session.util.d.ts +43 -0
- package/dist/utility/chart/script-source-session.util.js +61 -0
- package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
- package/dist/utility/chart/typed-width-grid.util.js +203 -0
- package/dist/utility/common/transformations.util.d.ts +6 -0
- package/dist/utility/common/transformations.util.js +28 -4
- package/dist/utility/market-events/market-events.util.js +3 -0
- package/dist/utility/number-format.util.d.ts +14 -1
- package/dist/utility/number-format.util.js +22 -4
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +115 -0
- package/dist/utility/v2/v2-enums.leaf.js +5 -0
- package/dist/utility/wrun/sources/row-lanes/dark_pool.d.ts +2 -1
- package/dist/utility/wrun/sources/row-lanes/dark_pool.js +4 -3
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +13 -3
- package/dist/utility/wrun/wrun-batched-marks.util.js +96 -17
- package/dist/utility/wrun/wrun-canvases.util.d.ts +4 -2
- package/dist/utility/wrun/wrun-canvases.util.js +7 -12
- package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
- package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
- package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-card-style.util.js +2 -2
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +23 -8
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +24 -9
- package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
- package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
- package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
- package/dist/utility/wrun/wrun-cme-root-specs.util.d.ts +10 -6
- package/dist/utility/wrun/wrun-cme-root-specs.util.js +19 -13
- package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
- package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
- package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
- package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
- package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
- package/dist/utility/wrun/wrun-frames.d.ts +1 -1
- package/dist/utility/wrun/wrun-frames.js +2 -2
- package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-handles.util.js +1 -1
- package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
- package/dist/utility/wrun/wrun-host.service.js +44 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
- package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
- package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
- package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
- package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
- package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
- package/dist/utility/wrun/wrun-live-tick.util.js +64 -5
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +40 -6
- package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +2 -2
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +10 -8
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +3 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +3 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +17 -0
- package/dist/utility/wrun/wrun-overlay-run.util.js +318 -55
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-panel-mount.util.js +42 -13
- package/dist/utility/wrun/wrun-pin-venues.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-pin-venues.util.js +11 -4
- package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-refusal.util.js +102 -13
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
- package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
- package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
- package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
- package/dist/utility/wrun/wrun-run-health.util.js +1 -1
- package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
- package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
- package/dist/utility/wrun/wrun-session-composition.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-session-composition.util.js +3 -2
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
- package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
- package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
- package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
- package/dist/utility/wrun/wrun-style-words.util.js +46 -15
- package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
- package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
- package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
- package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
- package/dist/utility/wrun-display-name.util.d.ts +10 -0
- package/dist/utility/wrun-display-name.util.js +21 -0
- package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
- package/dist/utils/replay/replay-buffer-math.js +2 -0
- package/dist/workers/constants/socket-slots.d.ts +1 -1
- package/dist/workers/utils/time.worker.util.js +2 -2
- package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
- package/dist/workers/utils/volume-profile.worker.util.js +20 -0
- package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
- package/dist/workers/wrun/wrun-abi-host.js +82 -5
- package/dist/workers/wrun/wrun-engine-handler.js +53 -4
- package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
- package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
- package/package.json +11 -11
|
@@ -6,7 +6,55 @@
|
|
|
6
6
|
* that every row has a value for every tier.
|
|
7
7
|
*/
|
|
8
8
|
import { MAX_PANE_GRID_PANES } from './pane-grid.constants.js';
|
|
9
|
-
|
|
9
|
+
// Ordered low to high (free < plus < ultimate): index order is plan rank.
|
|
10
|
+
export const TIERS = ['free', 'plus', 'ultimate'];
|
|
11
|
+
/**
|
|
12
|
+
* THE raw plan name reader: the server's plan name (`plus_1m`, `plus_1y`, `ultimate_1m`, `ultimate_1y`, `free`,
|
|
13
|
+
* null, a quoted claim) collapsed to a Tier. `ultimate` or `ultimate_*` is tested before the plus test; every name
|
|
14
|
+
* it does not know is free, as before. Pure.
|
|
15
|
+
*/
|
|
16
|
+
export function tierOfPlanName(raw) {
|
|
17
|
+
const name = typeof raw === 'string' ? raw.replace(/^"|"$/g, '') : '';
|
|
18
|
+
if (name === 'ultimate' || name.startsWith('ultimate_'))
|
|
19
|
+
return 'ultimate';
|
|
20
|
+
return name.startsWith('plus') ? 'plus' : 'free';
|
|
21
|
+
}
|
|
22
|
+
/** The plan a staff or partner role bypass gates as (the top plan). */
|
|
23
|
+
export const ROLE_BYPASS_TIER = 'ultimate';
|
|
24
|
+
/** A paid plan is any plan that is not free (plus or ultimate). Pure. */
|
|
25
|
+
export function isPaidTier(tier) {
|
|
26
|
+
return tier !== 'free';
|
|
27
|
+
}
|
|
28
|
+
/** The plan one rank up (free to plus, plus to ultimate), or null on the top plan. For "what the next plan gives". Pure. */
|
|
29
|
+
export function nextTierUp(tier) {
|
|
30
|
+
return TIERS[TIERS.indexOf(tier) + 1] ?? null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The plan an upgrade prompt may offer from `tier` WITHOUT the price list, or null when it cannot know: free
|
|
34
|
+
* always gets Plus. Plus answers null because Ultimate is offered only while the price list sells it, and the
|
|
35
|
+
* start-up code cannot read that list; a Plus holder's prompt goes through the lazy decider
|
|
36
|
+
* (`utility/plan/ultimate-offer.lazy.ts`), which reads it. An Ultimate holder is never offered anything. Pure.
|
|
37
|
+
*/
|
|
38
|
+
export function upgradeOfferTier(tier) {
|
|
39
|
+
return tier === 'free' ? 'plus' : null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The cheap start-up test before a Plus holder's prompt loads the lazy decider: the count limit `key` is higher
|
|
43
|
+
* one plan up from `tier`, and a prompt may say so. Not the full rule (the decider also asks whether the higher
|
|
44
|
+
* plan is on sale and whether its number waits on server capacity); it only keeps the decider's chunk from loading
|
|
45
|
+
* for a limit that is not higher one plan up. Pure.
|
|
46
|
+
*/
|
|
47
|
+
export function countLimitRisesOneUp(key, tier) {
|
|
48
|
+
const up = nextTierUp(tier);
|
|
49
|
+
if (up === null)
|
|
50
|
+
return false;
|
|
51
|
+
// A paid holder's indicator wall is Make room's (a full chart opens it). Make room carries the offer itself (a Plus
|
|
52
|
+
// holder's quiet "Run it with Ultimate" row, while Ultimate is on sale), so no second prompt offers the next plan
|
|
53
|
+
// for indicators (docs/features/billing/upgrade-prompts.md).
|
|
54
|
+
if (key === 'indicatorsPerChart' && isPaidTier(tier))
|
|
55
|
+
return false;
|
|
56
|
+
return FEATURE_LIMITS[key][up] > FEATURE_LIMITS[key][tier];
|
|
57
|
+
}
|
|
10
58
|
/**
|
|
11
59
|
* Mirror of the TSDB gateway's per-tier reach wall
|
|
12
60
|
* (tsdb-gateway `charts/tsdb-gateway-read/values.ore.yaml`,
|
|
@@ -31,9 +79,11 @@ const PLUS_GATEWAY_MAX_BARS = {
|
|
|
31
79
|
};
|
|
32
80
|
// Free shares the Plus reach since tsdb-gateway cee00f2 ("read: give the free
|
|
33
81
|
// tier Plus bar limits", 2026-09-29): history depth is no longer a plan feature.
|
|
82
|
+
// Ultimate shares the Plus reach too.
|
|
34
83
|
export const GATEWAY_TIER_MAX_BARS = {
|
|
35
84
|
free: PLUS_GATEWAY_MAX_BARS,
|
|
36
85
|
plus: PLUS_GATEWAY_MAX_BARS,
|
|
86
|
+
ultimate: PLUS_GATEWAY_MAX_BARS,
|
|
37
87
|
};
|
|
38
88
|
/** The tier's gateway reach in bars at the interval actually sent (a GATEWAY_TIER_MAX_BARS read). Pure. */
|
|
39
89
|
export function gatewayTierMaxBars(tier, requestInterval) {
|
|
@@ -42,53 +92,60 @@ export function gatewayTierMaxBars(tier, requestInterval) {
|
|
|
42
92
|
}
|
|
43
93
|
export const FEATURE_LIMITS = {
|
|
44
94
|
// Count-based (soft-block at creation)
|
|
45
|
-
workspaces: { free: 10, plus: 50 },
|
|
46
|
-
|
|
95
|
+
workspaces: { free: 10, plus: 50, ultimate: 500 },
|
|
96
|
+
// The data-indicator budget. `indicatorBudgetScopeFor` says what a number spans: a paid plan's is per chart (Plus
|
|
97
|
+
// 10, Ultimate 40); Free's 3 is one total for the whole workspace under free tier v2. Ultimate carries a second
|
|
98
|
+
// budget on top, INDICATOR_WORKSPACE_CAP. orange-v2-backend, collab-service and the phone app hold this row too.
|
|
99
|
+
indicatorsPerChart: { free: 3, plus: 10, ultimate: 40 },
|
|
47
100
|
// Mirrors the orange-v2-backend gateway quota (src/utility/feature-gate.ts
|
|
48
101
|
// FEATURE_LIMITS.privateKScripts); change both together or the UI gate and
|
|
49
102
|
// the server 403 disagree.
|
|
50
|
-
privateKScripts: { free: 100, plus: 500 },
|
|
51
|
-
multicharts: { free: 1, plus: 16 },
|
|
103
|
+
privateKScripts: { free: 100, plus: 500, ultimate: 5000 },
|
|
104
|
+
multicharts: { free: 1, plus: 16, ultimate: 16 },
|
|
52
105
|
// TWO independent alert quotas, one per kind (alert-kind.util.ts is the
|
|
53
106
|
// rule): price alerts are the native raw-level series alerts (price, open
|
|
54
107
|
// interest, funding, liquidations and the other native templates, no user
|
|
55
108
|
// script to run); indicator alerts are user kScript, built-in indicator
|
|
56
109
|
// scripts and hosted Indicators. Mirrors orange-v2-backend
|
|
57
|
-
// src/utility/feature-gate.ts FEATURE_LIMITS.priceAlerts / .indicatorAlerts
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
110
|
+
// src/utility/feature-gate.ts FEATURE_LIMITS.priceAlerts / .indicatorAlerts,
|
|
111
|
+
// tharamine-user-service's plan table (KSCRIPT_ALERT_PLAN_POLICY in
|
|
112
|
+
// src/constants/kscript-alert-plan.constants.ts, the one that is enforced)
|
|
113
|
+
// and the phone app's copy (kiyotaka-frontend-app
|
|
114
|
+
// src/features/gating/constants/feature-limits.ts): change all four
|
|
115
|
+
// together or the UI gate and the server refusal disagree.
|
|
116
|
+
priceAlerts: { free: 200, plus: 500, ultimate: 1000 },
|
|
117
|
+
indicatorAlerts: { free: 5, plus: 50, ultimate: 250 },
|
|
118
|
+
widgetsPerLayout: { free: 3, plus: 10, ultimate: 40 },
|
|
119
|
+
publishedLayouts: { free: 10, plus: 50, ultimate: 50 },
|
|
65
120
|
// Domain clamps (limit access without counting created resources)
|
|
66
|
-
replayReachBars: { free: Infinity, plus: Infinity },
|
|
121
|
+
replayReachBars: { free: Infinity, plus: Infinity, ultimate: Infinity },
|
|
67
122
|
// Binary (hide / disable)
|
|
68
123
|
// 4K heatmaps are open to free since 2026-10-01 at the free row count
|
|
69
124
|
// (getOptimalMaxDepth), so free 4K loads no more rows than free HD. Depth
|
|
70
125
|
// is what stays Plus (fullOrderbookDepth). orange mirrors this row for the
|
|
71
126
|
// workspace create gate.
|
|
72
|
-
heatmap4K: { free: true, plus: true },
|
|
73
|
-
fullOrderbookDepth: { free: false, plus: true },
|
|
127
|
+
heatmap4K: { free: true, plus: true, ultimate: true },
|
|
128
|
+
fullOrderbookDepth: { free: false, plus: true, ultimate: true },
|
|
74
129
|
// Seconds rungs (1s 5s 15s 30s), tape mode and the replay tick lane are open
|
|
75
130
|
// to free since 2026-10-08 everywhere but CME: the crypto plane serves free
|
|
76
131
|
// tokens the per-second book (tsdb-gateway 16a17f1), the CME plane still
|
|
77
132
|
// refuses it. So this row gates CME markets only (isTierGatedSecondsInterval);
|
|
78
133
|
// orange mirrors it for workspace create.
|
|
79
|
-
oneSecondInterval: { free: false, plus: true },
|
|
134
|
+
oneSecondInterval: { free: false, plus: true, ultimate: true },
|
|
135
|
+
// Typed candle widths (typed-width.leaf, `20m`, `90m`): the gateway serves CUSTOM to paid tokens only.
|
|
136
|
+
typedIntervalWidths: { free: false, plus: true, ultimate: true },
|
|
80
137
|
// Market replay is open to free since 2026-09-29 (entry, reach and book
|
|
81
138
|
// layers, gated in useChartReplay.enter and the replay plan gate). The tick
|
|
82
139
|
// lane rides oneSecondInterval, so it is Plus on CME only.
|
|
83
|
-
marketReplay: { free: true, plus: true },
|
|
84
|
-
replayBookLayers: { free: true, plus: true },
|
|
85
|
-
topCallersMyList: { free: false, plus: true },
|
|
86
|
-
hyperliquidAddress: { free: false, plus: true },
|
|
140
|
+
marketReplay: { free: true, plus: true, ultimate: true },
|
|
141
|
+
replayBookLayers: { free: true, plus: true, ultimate: true },
|
|
142
|
+
topCallersMyList: { free: false, plus: true, ultimate: true },
|
|
143
|
+
hyperliquidAddress: { free: false, plus: true, ultimate: true },
|
|
87
144
|
// Pane merge (shared off-chart panes + stacked member axes) is open to every
|
|
88
145
|
// plan since 2026-11-03 (it was never meant to be Plus). The row still feeds
|
|
89
146
|
// the engine-side acceptance gate (settings.paneMergeEnabled), the merge
|
|
90
147
|
// click and the scale menu, so all three answer from here.
|
|
91
|
-
paneMerge: { free: true, plus: true },
|
|
148
|
+
paneMerge: { free: true, plus: true, ultimate: true },
|
|
92
149
|
// CME L3 order flow (Orders column, strong levels, detector events, MBO
|
|
93
150
|
// Blocks, chart level badges) is Plus-only. The surfaces gate on
|
|
94
151
|
// isL3Entitled(), which is hasFeature('cmeL3OrderFlow') → THIS row, behind
|
|
@@ -96,9 +153,18 @@ export const FEATURE_LIMITS = {
|
|
|
96
153
|
// rule itself lives in OPA's roles.rego, which the data plane evaluates
|
|
97
154
|
// from the signed claims. This row also names the feature for the shared
|
|
98
155
|
// upgrade dialog the L3 plus-gate dialog's CTA hands off to.
|
|
99
|
-
cmeL3OrderFlow: { free: false, plus: true },
|
|
156
|
+
cmeL3OrderFlow: { free: false, plus: true, ultimate: true },
|
|
100
157
|
};
|
|
101
158
|
export const DOMAIN_FEATURE_KEYS = ['replayReachBars'];
|
|
159
|
+
/**
|
|
160
|
+
* Two budgets: the most data-indicator slots a whole workspace holds on a plan that counts per chart. Ultimate
|
|
161
|
+
* counts 40 on each chart, as Plus counts 10, and no more than 80 across every chart of the workspace. Plus runs
|
|
162
|
+
* at most 60 at once (10 on each of the six charts of the largest layout that keeps a full budget), so the total
|
|
163
|
+
* stays above what any Plus workspace runs, and a wide layout cannot stack 40 on every chart. The app alone holds
|
|
164
|
+
* this total (the add gate and the load-time clamp); the servers judge a paid plan per chart. A plan without a row
|
|
165
|
+
* has no total.
|
|
166
|
+
*/
|
|
167
|
+
export const INDICATOR_WORKSPACE_CAP = { ultimate: 80 };
|
|
102
168
|
/**
|
|
103
169
|
* Free rows that change under free tier v2 (`isFreeTierV2On()`; Plus rows never change).
|
|
104
170
|
* 16 = MAX_PANE_GRID_PANES, the largest grid (4x4). The free data budget keeps
|
|
@@ -119,10 +185,23 @@ export function resolveCountLimit(key, tier, freeTierV2) {
|
|
|
119
185
|
}
|
|
120
186
|
return FEATURE_LIMITS[key][tier];
|
|
121
187
|
}
|
|
122
|
-
/**
|
|
188
|
+
/**
|
|
189
|
+
* THE scope decider over the GATING tier (role bypass = ultimate): Free's budget is ONE shared across every chart
|
|
190
|
+
* of the workspace while free tier v2 is on; a paid plan (Plus, Ultimate) counts per chart. Pure.
|
|
191
|
+
*/
|
|
123
192
|
export function indicatorBudgetScopeFor(gatingTier, freeTierV2) {
|
|
124
193
|
return freeTierV2 && gatingTier === 'free' ? 'layout' : 'chart';
|
|
125
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* THE workspace total read over the GATING tier: the second budget of a plan that counts per chart
|
|
197
|
+
* (INDICATOR_WORKSPACE_CAP), or null when the plan has none. A shared budget is its own total, so layout scope
|
|
198
|
+
* answers null. Pure.
|
|
199
|
+
*/
|
|
200
|
+
export function indicatorWorkspaceCapFor(gatingTier, freeTierV2) {
|
|
201
|
+
if (indicatorBudgetScopeFor(gatingTier, freeTierV2) !== 'chart')
|
|
202
|
+
return null;
|
|
203
|
+
return INDICATOR_WORKSPACE_CAP[gatingTier] ?? null;
|
|
204
|
+
}
|
|
126
205
|
/**
|
|
127
206
|
* English display labels for gated features, kept beside FEATURE_LIMITS so a
|
|
128
207
|
* new feature key forces a label in the same change (Record types enforce it).
|
|
@@ -147,6 +226,7 @@ export const BINARY_FEATURE_LABELS = {
|
|
|
147
226
|
heatmap4K: '4K Heatmap',
|
|
148
227
|
fullOrderbookDepth: 'Full Orderbook Depth',
|
|
149
228
|
oneSecondInterval: '1-Second Interval',
|
|
229
|
+
typedIntervalWidths: 'Typed Interval Widths',
|
|
150
230
|
marketReplay: 'Market Replay',
|
|
151
231
|
replayBookLayers: 'Book Replay',
|
|
152
232
|
topCallersMyList: 'Top Callers (My List)',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TYPED_WIDTH_SECONDS } from './typed-width.leaf.js';
|
|
1
2
|
export const Intervals = {
|
|
2
3
|
SECOND: 1000,
|
|
3
4
|
SECOND5: 5000,
|
|
@@ -85,6 +86,10 @@ export const Intervals = {
|
|
|
85
86
|
'3M': 7889400000, // 3 months (avg 91.3125 days) = 3 * 2629800000
|
|
86
87
|
'6M': 15778800000, // 6 months (avg 182.625 days) = 6 * 2629800000
|
|
87
88
|
'1Y': 31557600000, // 1 year (avg 365.25 days) = 12 * 2629800000
|
|
89
|
+
// Typed widths, read from typed-width.leaf (4m and 3h keep their place above): no ladder rung of their own, at
|
|
90
|
+
// most 20 stored candles a bar. 4w comes after the legacy 28-day '1mm', so a first-match scan of this table
|
|
91
|
+
// answers '1mm' for 28 days: read a length back through intervalLabelForMs instead.
|
|
92
|
+
...Object.fromEntries(Object.entries(TYPED_WIDTH_SECONDS).map(([label, seconds]) => [label, seconds * 1000])),
|
|
88
93
|
},
|
|
89
94
|
INTERVAL_ORDER: ['1s', '1m', '5m', '15m', '30m', '1h', '4h', '1d', '1w', '1M', '3M', '1Y'],
|
|
90
95
|
};
|
|
@@ -13,3 +13,15 @@ export interface IndicatorIntervalRestrictions {
|
|
|
13
13
|
export declare const ALLOWED_1S_INDICATORS: readonly string[];
|
|
14
14
|
export declare const KSCRIPT_DATA_INTERVAL_RESTRICTIONS: Readonly<IndicatorIntervalRestrictions>;
|
|
15
15
|
export declare const ROLLED_INTERVAL_RESTRICTED_KSCRIPT_DATA: readonly string[];
|
|
16
|
+
/**
|
|
17
|
+
* The indicator types a typed-width chart (typed-width.leaf) may fetch that the boot path itself names: the three
|
|
18
|
+
* computed in the browser from the chart's candles (VWAP's seed is a plain K_OHLCV candle read; a script's sources are
|
|
19
|
+
* each judged on their own, TYPED_WIDTH_ALLOWED_KSCRIPT_DATA), so their cached preview can paint before the rest of
|
|
20
|
+
* the app loads. Every other allowed type, and the cap on the widths that fold volume-profile rows, lives in the
|
|
21
|
+
* app's utility/chart/typed-width-indicator-rules.util, which loads with the indicator fetch pipeline: typed widths
|
|
22
|
+
* are opt-in, so their lists stay off the boot path. A type neither names is restricted;
|
|
23
|
+
* tests/utility/chart/typed-width-indicators.spec.ts names the restricted side and fails until a new indicator type
|
|
24
|
+
* is decided.
|
|
25
|
+
*/
|
|
26
|
+
export declare const TYPED_WIDTH_BOOT_INDICATORS: readonly string[];
|
|
27
|
+
export declare const TYPED_WIDTH_ALLOWED_KSCRIPT_DATA: readonly string[];
|
|
@@ -38,3 +38,17 @@ export const KSCRIPT_DATA_INTERVAL_RESTRICTIONS = {
|
|
|
38
38
|
// The kScript data twin rides the same ETF_PREMIUM_RATE_AGG request as the native indicator, which the gateway
|
|
39
39
|
// refuses at every rolled preset (indicator.constants.ts `ROLLED_INTERVAL_RESTRICTED_INDICATORS`).
|
|
40
40
|
export const ROLLED_INTERVAL_RESTRICTED_KSCRIPT_DATA = ['ETF_PREMIUM_RATE'];
|
|
41
|
+
/**
|
|
42
|
+
* The indicator types a typed-width chart (typed-width.leaf) may fetch that the boot path itself names: the three
|
|
43
|
+
* computed in the browser from the chart's candles (VWAP's seed is a plain K_OHLCV candle read; a script's sources are
|
|
44
|
+
* each judged on their own, TYPED_WIDTH_ALLOWED_KSCRIPT_DATA), so their cached preview can paint before the rest of
|
|
45
|
+
* the app loads. Every other allowed type, and the cap on the widths that fold volume-profile rows, lives in the
|
|
46
|
+
* app's utility/chart/typed-width-indicator-rules.util, which loads with the indicator fetch pipeline: typed widths
|
|
47
|
+
* are opt-in, so their lists stay off the boot path. A type neither names is restricted;
|
|
48
|
+
* tests/utility/chart/typed-width-indicators.spec.ts names the restricted side and fails until a new indicator type
|
|
49
|
+
* is decided.
|
|
50
|
+
*/
|
|
51
|
+
export const TYPED_WIDTH_BOOT_INDICATORS = ['VWAP', 'MA_RIBBON', 'TECHNICAL_SCRIPT'];
|
|
52
|
+
// The kScript and wrun data sources a typed-width chart may read: K_OHLCV is a plain candle read (its prediction
|
|
53
|
+
// gapfill never meets a typed width, which no prediction venue serves). Every other source is restricted.
|
|
54
|
+
export const TYPED_WIDTH_ALLOWED_KSCRIPT_DATA = ['OHLCV'];
|
|
@@ -76,6 +76,15 @@ export declare const OPRA_OPTIONS_CAPABILITIES: IMarketCapabilities;
|
|
|
76
76
|
* Fixed Range Volume Profile tool stand down. `getCapabilities` returns this for those exchanges.
|
|
77
77
|
*/
|
|
78
78
|
export declare const ONCHAIN_POOL_CAPABILITIES: IMarketCapabilities;
|
|
79
|
+
/**
|
|
80
|
+
* Exchanges whose order book we do not serve, whatever their market kind supports. `getCapabilities`
|
|
81
|
+
* answers `supportsOrderbook: false` for each, and the order book panes leave them out of their
|
|
82
|
+
* exchange pickers. Add an exchange here to turn every book surface off for it.
|
|
83
|
+
*
|
|
84
|
+
* BITGET: since 2026-10-15 Bitget sends the live book of its stock tokens only to accounts with a
|
|
85
|
+
* permission we do not hold, so the backend stopped collecting it.
|
|
86
|
+
*/
|
|
87
|
+
export declare const NO_ORDERBOOK_EXCHANGES: readonly string[];
|
|
79
88
|
export declare const MARKET_CAPABILITIES: Record<VenueMarketKind, IMarketCapabilities>;
|
|
80
89
|
/** Every market kind (the FE `'futures'` kind included). Derived from
|
|
81
90
|
* `MARKET_CAPABILITIES` so adding a new kind to the registry automatically
|
|
@@ -67,18 +67,28 @@ export const ONCHAIN_POOL_CAPABILITIES = {
|
|
|
67
67
|
supportsOrderbook: false,
|
|
68
68
|
alertSymbolMode: 'slug',
|
|
69
69
|
};
|
|
70
|
+
const CRYPTO_CAPABILITIES = {
|
|
71
|
+
barTimestamps: 'uniform',
|
|
72
|
+
fetchMode: 'period',
|
|
73
|
+
supportsVolumeStats: true,
|
|
74
|
+
supportsTradesFeed: true,
|
|
75
|
+
supportsMarketStats: true,
|
|
76
|
+
supportsFRVP: true,
|
|
77
|
+
supportsOrderbook: true,
|
|
78
|
+
alertSymbolMode: 'slug',
|
|
79
|
+
allowsCalendarIntervals: true,
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Exchanges whose order book we do not serve, whatever their market kind supports. `getCapabilities`
|
|
83
|
+
* answers `supportsOrderbook: false` for each, and the order book panes leave them out of their
|
|
84
|
+
* exchange pickers. Add an exchange here to turn every book surface off for it.
|
|
85
|
+
*
|
|
86
|
+
* BITGET: since 2026-10-15 Bitget sends the live book of its stock tokens only to accounts with a
|
|
87
|
+
* permission we do not hold, so the backend stopped collecting it.
|
|
88
|
+
*/
|
|
89
|
+
export const NO_ORDERBOOK_EXCHANGES = ['BITGET'];
|
|
70
90
|
export const MARKET_CAPABILITIES = {
|
|
71
|
-
crypto:
|
|
72
|
-
barTimestamps: 'uniform',
|
|
73
|
-
fetchMode: 'period',
|
|
74
|
-
supportsVolumeStats: true,
|
|
75
|
-
supportsTradesFeed: true,
|
|
76
|
-
supportsMarketStats: true,
|
|
77
|
-
supportsFRVP: true,
|
|
78
|
-
supportsOrderbook: true,
|
|
79
|
-
alertSymbolMode: 'slug',
|
|
80
|
-
allowsCalendarIntervals: true,
|
|
81
|
-
},
|
|
91
|
+
crypto: CRYPTO_CAPABILITIES,
|
|
82
92
|
hip3: {
|
|
83
93
|
barTimestamps: 'uniform',
|
|
84
94
|
fetchMode: 'period',
|
|
@@ -218,6 +228,24 @@ export const MARKET_CAPABILITIES = {
|
|
|
218
228
|
alertSymbolMode: 'slug',
|
|
219
229
|
allowsCalendarIntervals: true,
|
|
220
230
|
},
|
|
231
|
+
// Stock indices, the dollar and volatility indices and US Treasury yields
|
|
232
|
+
// (index-otc.leaf). Quote candles (TICKER_AGG) from 1m up with market closes
|
|
233
|
+
// and weekends between sessions, so the forex record's shape: irregular bars,
|
|
234
|
+
// count fetch, no trades, volume, book or profile. The licence allows alerts,
|
|
235
|
+
// but no alert engine lane is proven for the venue yet, so they stay closed
|
|
236
|
+
// (an armed one would save and never fire).
|
|
237
|
+
marketIndex: {
|
|
238
|
+
barTimestamps: 'irregular',
|
|
239
|
+
fetchMode: 'count',
|
|
240
|
+
supportsVolumeStats: false,
|
|
241
|
+
supportsTradesFeed: false,
|
|
242
|
+
supportsMarketStats: false,
|
|
243
|
+
supportsFRVP: false,
|
|
244
|
+
supportsOrderbook: false,
|
|
245
|
+
supportsAlerts: false,
|
|
246
|
+
alertSymbolMode: 'coin',
|
|
247
|
+
allowsCalendarIntervals: true,
|
|
248
|
+
},
|
|
221
249
|
};
|
|
222
250
|
// =============================================================================
|
|
223
251
|
// MarketKind shorthand sets — for `IIndicatorControl.marketKinds` declarations.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LiveBucketVenue } from '../utility/chart/live-bucket.util.js';
|
|
2
|
+
export interface TypedIndicatorSource {
|
|
3
|
+
label: string;
|
|
4
|
+
ms: number;
|
|
5
|
+
rowsPerBar: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function typedIndicatorSource(widthLabel: string, venue: LiveBucketVenue, sessionFiltered: boolean): TypedIndicatorSource | null;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stored size an indicator reads to build one custom bar on a session grid, and how many of its rows make a full
|
|
3
|
+
* bar. Every bar start and bar end on the four session kinds below falls on a whole row of the chosen size: the
|
|
4
|
+
* sessions open on a quarter hour (CME regular hours 08:30 Chicago, stocks 09:30 and 04:00 New York) or on the hour
|
|
5
|
+
* (CME full session 17:00 Chicago), so 1m, 5m and 15m rows always fit, and 1h rows fit only on the full-session lattice
|
|
6
|
+
* with no regular-hours filter on the rows.
|
|
7
|
+
*
|
|
8
|
+
* Null is a refusal: a label that is not a custom width under a day, or a grid kind the indicator folds do not serve
|
|
9
|
+
* (UTC, forex, options). A caller never falls back to another grid on null.
|
|
10
|
+
*
|
|
11
|
+
* LAZY: it reads the lazy grid file, so it is reached by `await import()` only (tests/perf/typed-width-rules-lazy-closure.spec.ts).
|
|
12
|
+
*/
|
|
13
|
+
import { typedWidthSeconds } from './typed-width.leaf.js';
|
|
14
|
+
import { typedGridKind } from '../utility/chart/typed-width-grid.util.js';
|
|
15
|
+
const MINUTE_MS = 60_000;
|
|
16
|
+
/** The source minutes for each custom width under a day, 3h aside (it depends on the grid). */
|
|
17
|
+
const SOURCE_MINUTES = {
|
|
18
|
+
'4m': 1,
|
|
19
|
+
'6m': 1,
|
|
20
|
+
'8m': 1,
|
|
21
|
+
'9m': 1,
|
|
22
|
+
'12m': 1,
|
|
23
|
+
'16m': 1,
|
|
24
|
+
'18m': 1,
|
|
25
|
+
'20m': 5,
|
|
26
|
+
'40m': 5,
|
|
27
|
+
'80m': 5,
|
|
28
|
+
'90m': 15,
|
|
29
|
+
};
|
|
30
|
+
const SESSION_KINDS = new Set(['cme-session', 'cme-regular', 'equity-regular', 'equity-extended']);
|
|
31
|
+
const SOURCE_LABELS = { 1: '1m', 5: '5m', 15: '15m', 60: '1h' };
|
|
32
|
+
export function typedIndicatorSource(widthLabel, venue, sessionFiltered) {
|
|
33
|
+
const seconds = typedWidthSeconds(widthLabel);
|
|
34
|
+
if (seconds === undefined || !(seconds < 86_400))
|
|
35
|
+
return null;
|
|
36
|
+
const widthMs = seconds * 1000;
|
|
37
|
+
const kind = typedGridKind(widthMs, venue);
|
|
38
|
+
if (!SESSION_KINDS.has(kind))
|
|
39
|
+
return null;
|
|
40
|
+
// 3h: hourly rows sit on :00, which only the full-session lattice (17:00 Chicago) keeps without a regular-hours
|
|
41
|
+
// filter; every other session opens on a quarter hour, so 12 rows of 15m.
|
|
42
|
+
const minutes = widthLabel === '3h' ? (kind === 'cme-session' && !sessionFiltered ? 60 : 15) : SOURCE_MINUTES[widthLabel];
|
|
43
|
+
if (minutes === undefined)
|
|
44
|
+
return null;
|
|
45
|
+
const ms = minutes * MINUTE_MS;
|
|
46
|
+
return { label: SOURCE_LABELS[minutes], ms, rowsPerBar: widthMs / ms };
|
|
47
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session venues whose custom sizes the gateway can build on the market's own session grid (the CME family: CME,
|
|
3
|
+
* CBOT, NYMEX, COMEX). One predicate for the page's server door (typed-history-door.util, lazy) and the data worker's
|
|
4
|
+
* doors (read-series, v2.worker.service, ohlcv.worker). Takes the exchange code or wire name. A leaf of its own so the
|
|
5
|
+
* boot leaf typed-width.leaf carries none of an opt-in feature (tests/perf/typed-width-rules-lazy-closure.spec.ts).
|
|
6
|
+
*/
|
|
7
|
+
export declare function isTypedSessionHistoryVenue(exchange: unknown): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session venues whose custom sizes the gateway can build on the market's own session grid (the CME family: CME,
|
|
3
|
+
* CBOT, NYMEX, COMEX). One predicate for the page's server door (typed-history-door.util, lazy) and the data worker's
|
|
4
|
+
* doors (read-series, v2.worker.service, ohlcv.worker). Takes the exchange code or wire name. A leaf of its own so the
|
|
5
|
+
* boot leaf typed-width.leaf carries none of an opt-in feature (tests/perf/typed-width-rules-lazy-closure.spec.ts).
|
|
6
|
+
*/
|
|
7
|
+
export function isTypedSessionHistoryVenue(exchange) {
|
|
8
|
+
return typeof exchange === 'string' && /^(CME|CBOT|NYMEX|COMEX)$/.test(exchange);
|
|
9
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** The coarsest stored candle size (seconds) that divides `seconds`; NaN when none does. */
|
|
2
|
+
export declare function storedBarSecondsDividing(seconds: number): number;
|
|
3
|
+
/**
|
|
4
|
+
* The stored interval label a typed width is built from: 4m to 18m '1m'; 20m, 40m and 80m '5m'; 90m '15m'; 3h '1h';
|
|
5
|
+
* the day widths '1d'; the week widths '1w'. Undefined for any other label.
|
|
6
|
+
*/
|
|
7
|
+
export declare function storedDivisorLabel(label: unknown): string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* The stored size (seconds) a typed width reads volume-profile rows at, or undefined when the label is not a typed
|
|
10
|
+
* width or the cap refuses it (`isTypedWidthProfileFoldAllowed`).
|
|
11
|
+
*/
|
|
12
|
+
export declare function typedWidthProfileSourceSeconds(label: unknown): number | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* The row interval (ms) a per-candle profile read asks for on a chart of `chartMs`: a typed width's stored size, and
|
|
15
|
+
* any other length unchanged. It maps every typed width, capped or not: the indicator verdict decides whether the read
|
|
16
|
+
* happens at all.
|
|
17
|
+
*/
|
|
18
|
+
export declare function profileRowMsForChart(chartMs: number): number;
|
|
19
|
+
/** True when a chart bar of `lengthMs` is a typed width (the footprint workers hold the chart length, not its label). */
|
|
20
|
+
export declare function isTypedWidthLengthMs(lengthMs: number): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The closed end of a typed read, in ms: the end of a window that closed before the server's now. The gateway's SQL
|
|
23
|
+
* includes a range's end (`bucket <= to`), so a closed window ending at T can bring back the stored row AT T. It does
|
|
24
|
+
* not always: a read the gateway slices into cache chunks and every leg of a continuous symbol are trimmed to
|
|
25
|
+
* `t < until`, so never count on that row (typed-candle-fold.worker.util `WIRE_END_PAD_MS`). On a typed width the row
|
|
26
|
+
* opens the NEXT typed bar, and the fold would turn it into a bar stamped T holding 1 of its k rows (a short sum, the
|
|
27
|
+
* first value instead of the last, the mean of one row). The next (newer) window starts at T and owns that bar whole,
|
|
28
|
+
* so the bar is dropped (`keepBarsBeforeClosedEnd`), which is right whether the row came back or not.
|
|
29
|
+
*
|
|
30
|
+
* `tf` is the chart's interval: a label (the line workers' `payload.tf`) or the bar length in ms (the footprint
|
|
31
|
+
* workers' `chartTfMs`). Both forms go through the one rule below.
|
|
32
|
+
*
|
|
33
|
+
* Undefined (nothing to drop) for:
|
|
34
|
+
* - an interval that is not a typed width, so regular intervals keep every row the wire sends;
|
|
35
|
+
* - a floating window (`fromSec` 0, the gateway's "latest period"), whose end moves with the server clock;
|
|
36
|
+
* - a window with no end (`periodSec` undefined);
|
|
37
|
+
* - a window that reaches the server's now (end at or after `nowSec`), which keeps its forming bar.
|
|
38
|
+
*
|
|
39
|
+
* `fromSec` and `periodSec` are the window as asked; flooring the start (`typedWindowSec`) does not move the end, so
|
|
40
|
+
* either the floored or the unfloored window gives the same answer. `nowSec` is the server's now (`serverNowMs()` in the
|
|
41
|
+
* caller), passed in so this helper stays pure.
|
|
42
|
+
*/
|
|
43
|
+
export declare function typedClosedEndMs(fromSec: number, periodSec: number | undefined, tf: string | number, nowSec: number): number | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The folded bars that start before a closed end (`typedClosedEndMs`), in the bars' own unit (`unit`, default
|
|
46
|
+
* `'ms'`; `closedEndMs` is always in ms). A bar's time is its first element unless `timeOf` reads it. With no closed end
|
|
47
|
+
* (a regular label, a floating window, a window that reaches now) it returns the SAME array, untouched.
|
|
48
|
+
*
|
|
49
|
+
* Apply it where the folded rows are final for the request: after the fold, and before anything that reads one bar to
|
|
50
|
+
* shape the next (`transformData`, a forward-fill, a resident merge) or posts the rows.
|
|
51
|
+
*/
|
|
52
|
+
export declare function keepBarsBeforeClosedEnd<T>(bars: T[], closedEndMs: number | undefined, unit?: 's' | 'ms', timeOf?: (bar: T) => number): T[];
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a typed width (typed-width.leaf) reads an indicator the gateway does not serve at CUSTOM: the app asks for rows at
|
|
3
|
+
* the stored candle size the width is built from and folds them into the chart's bars itself. This leaf names that
|
|
4
|
+
* stored size. The cap on the widths that may fold volume-profile rows is `isTypedWidthProfileFoldAllowed`
|
|
5
|
+
* (typed-width.leaf). Dependency-free and off the boot path: workers and lazily loaded modules import it.
|
|
6
|
+
*
|
|
7
|
+
* It is also the one home of the closed-end rule (`typedClosedEndMs`, `keepBarsBeforeClosedEnd`) that every typed
|
|
8
|
+
* fold applies, the line workers (through typed-width-fold.worker.util) and the footprint workers alike.
|
|
9
|
+
*/
|
|
10
|
+
import { isTypedWidth, isTypedWidthProfileFoldAllowed, STORED_BAR_SECONDS, TYPED_WIDTH_LABELS, TYPED_WIDTH_SECONDS, typedWidthSeconds, } from './typed-width.leaf.js';
|
|
11
|
+
/** The interval label of each stored candle size, by its length in seconds. */
|
|
12
|
+
const STORED_LABEL_BY_SECONDS = {
|
|
13
|
+
60: '1m',
|
|
14
|
+
300: '5m',
|
|
15
|
+
900: '15m',
|
|
16
|
+
3600: '1h',
|
|
17
|
+
14400: '4h',
|
|
18
|
+
86400: '1d',
|
|
19
|
+
604800: '1w',
|
|
20
|
+
};
|
|
21
|
+
/** The coarsest stored candle size (seconds) that divides `seconds`; NaN when none does. */
|
|
22
|
+
export function storedBarSecondsDividing(seconds) {
|
|
23
|
+
let stored = NaN;
|
|
24
|
+
for (const size of STORED_BAR_SECONDS)
|
|
25
|
+
if (seconds % size === 0)
|
|
26
|
+
stored = size;
|
|
27
|
+
return stored;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The stored interval label a typed width is built from: 4m to 18m '1m'; 20m, 40m and 80m '5m'; 90m '15m'; 3h '1h';
|
|
31
|
+
* the day widths '1d'; the week widths '1w'. Undefined for any other label.
|
|
32
|
+
*/
|
|
33
|
+
export function storedDivisorLabel(label) {
|
|
34
|
+
const seconds = typedWidthSeconds(label);
|
|
35
|
+
return seconds === undefined ? undefined : STORED_LABEL_BY_SECONDS[storedBarSecondsDividing(seconds)];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The stored size (seconds) a typed width reads volume-profile rows at, or undefined when the label is not a typed
|
|
39
|
+
* width or the cap refuses it (`isTypedWidthProfileFoldAllowed`).
|
|
40
|
+
*/
|
|
41
|
+
export function typedWidthProfileSourceSeconds(label) {
|
|
42
|
+
if (!isTypedWidthProfileFoldAllowed(label))
|
|
43
|
+
return undefined;
|
|
44
|
+
return storedBarSecondsDividing(typedWidthSeconds(label));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The row interval (ms) a per-candle profile read asks for on a chart of `chartMs`: a typed width's stored size, and
|
|
48
|
+
* any other length unchanged. It maps every typed width, capped or not: the indicator verdict decides whether the read
|
|
49
|
+
* happens at all.
|
|
50
|
+
*/
|
|
51
|
+
export function profileRowMsForChart(chartMs) {
|
|
52
|
+
return isTypedWidthLengthMs(chartMs) ? storedBarSecondsDividing(chartMs / 1000) * 1000 : chartMs;
|
|
53
|
+
}
|
|
54
|
+
/** True when a chart bar of `lengthMs` is a typed width (the footprint workers hold the chart length, not its label). */
|
|
55
|
+
export function isTypedWidthLengthMs(lengthMs) {
|
|
56
|
+
const seconds = lengthMs / 1000;
|
|
57
|
+
return TYPED_WIDTH_LABELS.some((label) => TYPED_WIDTH_SECONDS[label] === seconds);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The closed end of a typed read, in ms: the end of a window that closed before the server's now. The gateway's SQL
|
|
61
|
+
* includes a range's end (`bucket <= to`), so a closed window ending at T can bring back the stored row AT T. It does
|
|
62
|
+
* not always: a read the gateway slices into cache chunks and every leg of a continuous symbol are trimmed to
|
|
63
|
+
* `t < until`, so never count on that row (typed-candle-fold.worker.util `WIRE_END_PAD_MS`). On a typed width the row
|
|
64
|
+
* opens the NEXT typed bar, and the fold would turn it into a bar stamped T holding 1 of its k rows (a short sum, the
|
|
65
|
+
* first value instead of the last, the mean of one row). The next (newer) window starts at T and owns that bar whole,
|
|
66
|
+
* so the bar is dropped (`keepBarsBeforeClosedEnd`), which is right whether the row came back or not.
|
|
67
|
+
*
|
|
68
|
+
* `tf` is the chart's interval: a label (the line workers' `payload.tf`) or the bar length in ms (the footprint
|
|
69
|
+
* workers' `chartTfMs`). Both forms go through the one rule below.
|
|
70
|
+
*
|
|
71
|
+
* Undefined (nothing to drop) for:
|
|
72
|
+
* - an interval that is not a typed width, so regular intervals keep every row the wire sends;
|
|
73
|
+
* - a floating window (`fromSec` 0, the gateway's "latest period"), whose end moves with the server clock;
|
|
74
|
+
* - a window with no end (`periodSec` undefined);
|
|
75
|
+
* - a window that reaches the server's now (end at or after `nowSec`), which keeps its forming bar.
|
|
76
|
+
*
|
|
77
|
+
* `fromSec` and `periodSec` are the window as asked; flooring the start (`typedWindowSec`) does not move the end, so
|
|
78
|
+
* either the floored or the unfloored window gives the same answer. `nowSec` is the server's now (`serverNowMs()` in the
|
|
79
|
+
* caller), passed in so this helper stays pure.
|
|
80
|
+
*/
|
|
81
|
+
export function typedClosedEndMs(fromSec, periodSec, tf, nowSec) {
|
|
82
|
+
const typed = typeof tf === 'number' ? isTypedWidthLengthMs(tf) : isTypedWidth(tf);
|
|
83
|
+
if (!typed || !(fromSec > 0) || periodSec === undefined)
|
|
84
|
+
return undefined;
|
|
85
|
+
const endSec = fromSec + periodSec;
|
|
86
|
+
return endSec < nowSec ? endSec * 1000 : undefined;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The folded bars that start before a closed end (`typedClosedEndMs`), in the bars' own unit (`unit`, default
|
|
90
|
+
* `'ms'`; `closedEndMs` is always in ms). A bar's time is its first element unless `timeOf` reads it. With no closed end
|
|
91
|
+
* (a regular label, a floating window, a window that reaches now) it returns the SAME array, untouched.
|
|
92
|
+
*
|
|
93
|
+
* Apply it where the folded rows are final for the request: after the fold, and before anything that reads one bar to
|
|
94
|
+
* shape the next (`transformData`, a forward-fill, a resident merge) or posts the rows.
|
|
95
|
+
*/
|
|
96
|
+
export function keepBarsBeforeClosedEnd(bars, closedEndMs, unit = 'ms', timeOf = (bar) => bar[0]) {
|
|
97
|
+
if (closedEndMs === undefined)
|
|
98
|
+
return bars;
|
|
99
|
+
const end = unit === 's' ? closedEndMs / 1000 : closedEndMs;
|
|
100
|
+
return bars.filter((bar) => timeOf(bar) < end);
|
|
101
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LiveBucketVenue } from '../utility/chart/live-bucket.util.js';
|
|
2
|
+
import { type TypedGridKind } from '../utility/chart/typed-width-grid.util.js';
|
|
3
|
+
/** The served interval a custom size folds from, and the most of its rows one custom bar holds. */
|
|
4
|
+
export interface TypedWidthSource {
|
|
5
|
+
label: string;
|
|
6
|
+
rowsPerBar: number;
|
|
7
|
+
}
|
|
8
|
+
/** The most source rows one app-built custom bar may read. */
|
|
9
|
+
export declare const TYPED_SOURCE_MAX_ROWS = 20;
|
|
10
|
+
/** The candidate source intervals of a custom size, best first (deepest history, then fewest rows). */
|
|
11
|
+
export declare function typedWidthSourceCandidates(label: string): readonly string[];
|
|
12
|
+
/** The candidates of a custom size on one grid: the table less the ones whose bars straddle a custom edge there. */
|
|
13
|
+
export declare function typedWidthSourceCandidatesOn(label: string, kind: TypedGridKind): readonly string[];
|
|
14
|
+
/**
|
|
15
|
+
* The most rows of `sourceLabel` one bar of the custom size `label` holds on a grid: the width over the source length
|
|
16
|
+
* under a day; N for N days from 1d and for N weeks from 1w; for N weeks from 1d, 7N on the UTC grid (every day
|
|
17
|
+
* trades) and 5N on a session grid (a week holds five trade dates). NaN for a pair the table does not name.
|
|
18
|
+
*/
|
|
19
|
+
export declare function typedSourceRowsPerBar(label: string, sourceLabel: string, kind: TypedGridKind): number;
|
|
20
|
+
/**
|
|
21
|
+
* The source of the custom size `label` on the chart's market: the first candidate the chart serves (`servable`)
|
|
22
|
+
* that needs at most TYPED_SOURCE_MAX_ROWS rows a bar. Null when the market has no interval to build it from.
|
|
23
|
+
*/
|
|
24
|
+
export declare function typedWidthSource(label: string, venue: LiveBucketVenue | null | undefined, servable: (label: string) => boolean): TypedWidthSource | null;
|