@orangecharts/wrun-chart-host 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/constants/feature-flags.constants.d.ts +9 -0
- package/dist/constants/feature-flags.constants.js +86 -16
- package/dist/constants/marketCapabilities.constants.d.ts +14 -9
- package/dist/constants/marketCapabilities.constants.js +36 -13
- package/dist/constants/opra-compliance.constants.d.ts +15 -0
- package/dist/constants/opra-compliance.constants.js +15 -0
- package/dist/constants/option-venues.constants.d.ts +11 -6
- package/dist/constants/option-venues.constants.js +5 -2
- package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +26 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.js +6 -0
- package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +15 -0
- package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +17 -0
- package/dist/constants/venue-presets.constants.d.ts +20 -20
- package/dist/constants/venue-presets.constants.js +24 -26
- package/dist/host-env.d.ts +39 -9
- package/dist/host-env.js +6 -0
- package/dist/host-ports.types.d.ts +108 -18
- package/dist/index.d.ts +14 -0
- package/dist/index.js +14 -0
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +6 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +13 -11
- package/dist/interfaces/opra-realtime.interface.js +10 -10
- package/dist/interfaces/replay.interface.d.ts +8 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +52 -15
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +94 -14
- package/dist/kscript-data/controls/live-trades-merge.util.js +132 -22
- package/dist/kscript-data/controls/live-trades-order-gate.util.d.ts +56 -0
- package/dist/kscript-data/controls/live-trades-order-gate.util.js +107 -0
- package/dist/market-data/billing.interface.d.ts +227 -42
- package/dist/market-data/billing.interface.js +60 -12
- package/dist/market-data/venue.d.ts +88 -6
- package/dist/market-data/venues/cme.contract.copy.json +66 -0
- package/dist/market-data/venues/cme.d.ts +126 -0
- package/dist/market-data/venues/cme.js +133 -0
- package/dist/market-data/venues/index.d.ts +165 -8
- package/dist/market-data/venues/index.js +48 -6
- package/dist/market-data/venues/opra.contract.copy.json +5 -3
- package/dist/market-data/venues/opra.d.ts +3 -3
- package/dist/market-data/venues/opra.js +5 -4
- package/dist/replay/replayLadder.js +3 -1
- package/dist/settings-templates/index.js +7 -3
- package/dist/settings-templates/indicator-fields.d.ts +5 -4
- package/dist/settings-templates/indicator-fields.js +45 -6
- package/dist/settings-templates/tool-rules.d.ts +27 -17
- package/dist/settings-templates/tool-rules.js +27 -11
- package/dist/settings-templates/tool-tables.generated.js +91 -31
- package/dist/utility/chart/book-live-bucket.util.d.ts +15 -0
- package/dist/utility/chart/book-live-bucket.util.js +47 -0
- package/dist/utility/chart/crypto-index.leaf.d.ts +2 -2
- package/dist/utility/chart/crypto-index.leaf.js +2 -2
- package/dist/utility/chart/index-mode-admission.util.js +24 -3
- package/dist/utility/chart/index-mode.util.d.ts +5 -2
- package/dist/utility/chart/index-mode.util.js +23 -13
- package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +35 -11
- package/dist/utility/chart/kscript-drawing-safe-area.util.js +145 -35
- package/dist/utility/chart/kscript-live-coalesce.util.d.ts +7 -2
- package/dist/utility/chart/kscript-live-coalesce.util.js +9 -3
- package/dist/utility/chart/kscript-provenance-keys.util.js +6 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +3 -1
- package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +32 -2
- package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +45 -0
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +53 -27
- package/dist/utility/chart/kscript-venue-policy.util.js +74 -32
- package/dist/utility/chart/market-session-schedule.util.d.ts +10 -0
- package/dist/utility/chart/market-session-schedule.util.js +16 -0
- package/dist/utility/chart/marketKind.util.d.ts +12 -10
- package/dist/utility/chart/marketKind.util.js +17 -7
- package/dist/utility/chart/om-panel-push-style.util.d.ts +7 -7
- package/dist/utility/chart/om-panel-push-style.util.js +17 -15
- package/dist/utility/chart/om-panel.util.js +6 -6
- package/dist/utility/chart/opra-read-access.leaf.d.ts +5 -3
- package/dist/utility/chart/opra-read-access.leaf.js +5 -3
- package/dist/utility/chart/profile-block-size.util.d.ts +16 -0
- package/dist/utility/chart/profile-block-size.util.js +7 -0
- package/dist/utility/chart/quote-perp.leaf.d.ts +17 -0
- package/dist/utility/chart/quote-perp.leaf.js +20 -0
- package/dist/utility/chart/rth-session.util.d.ts +3 -2
- package/dist/utility/chart/rth-session.util.js +2 -1
- package/dist/utility/chart/window-geometry.leaf.d.ts +8 -0
- package/dist/utility/chart/window-geometry.leaf.js +22 -6
- package/dist/utility/chart/wrun-run-result.util.d.ts +17 -0
- package/dist/utility/chart/wrun-run-result.util.js +145 -7
- package/dist/utility/common/transformations.util.d.ts +7 -0
- package/dist/utility/common/transformations.util.js +11 -0
- package/dist/utility/options/option-bar-anchor.util.d.ts +145 -0
- package/dist/utility/options/option-bar-anchor.util.js +340 -0
- package/dist/utility/options/option-venue.util.d.ts +21 -3
- package/dist/utility/options/option-venue.util.js +30 -3
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +2 -0
- package/dist/utility/wrun/derived-roots.util.d.ts +213 -0
- package/dist/utility/wrun/derived-roots.util.js +471 -0
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +41 -6
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +89 -19
- package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +9 -4
- package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +47 -6
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +5 -3
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +6 -4
- package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +2 -2
- package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +5 -1
- package/dist/utility/wrun/sources/lanes/option_daily.js +5 -2
- package/dist/utility/wrun/sources/lanes/options_flow.js +5 -2
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +64 -19
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +105 -35
- package/dist/utility/wrun/sources/row-lane-registry.js +3 -2
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +2 -1
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +9 -3
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +15 -6
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +14 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +82 -13
- package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +17 -4
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +55 -8
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +95 -14
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +5 -2
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +7 -3
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +35 -14
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +70 -20
- package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +64 -0
- package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +89 -0
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +45 -1
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +114 -6
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +56 -5
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +224 -26
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +822 -58
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +16 -3
- package/dist/utility/wrun/wrun-batched-marks.util.js +30 -19
- package/dist/utility/wrun/wrun-batched-readout.util.d.ts +37 -9
- package/dist/utility/wrun/wrun-batched-readout.util.js +61 -15
- package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +12 -0
- package/dist/utility/wrun/wrun-builtin-twin.util.js +21 -0
- package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-cell-capacity.leaf.d.ts +66 -0
- package/dist/utility/wrun/wrun-cell-capacity.leaf.js +86 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +192 -13
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +437 -55
- package/dist/utility/wrun/wrun-color-facts.util.d.ts +19 -9
- package/dist/utility/wrun/wrun-color-facts.util.js +24 -14
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +15 -4
- package/dist/utility/wrun/wrun-color-settings.util.js +31 -12
- package/dist/utility/wrun/wrun-dollar-unit-port.leaf.d.ts +17 -0
- package/dist/utility/wrun/wrun-dollar-unit-port.leaf.js +9 -0
- package/dist/utility/wrun/wrun-download-meter.util.d.ts +107 -0
- package/dist/utility/wrun/wrun-download-meter.util.js +134 -0
- package/dist/utility/wrun/wrun-download-plan.util.d.ts +99 -0
- package/dist/utility/wrun/wrun-download-plan.util.js +118 -0
- package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +11 -3
- package/dist/utility/wrun/wrun-draft-legend-note.util.js +26 -4
- package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-draft-overlay.util.js +23 -3
- package/dist/utility/wrun/wrun-frames.d.ts +27 -6
- package/dist/utility/wrun/wrun-frames.js +78 -15
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +7 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +7 -1
- package/dist/utility/wrun/wrun-hosted-wire.util.js +12 -2
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +51 -21
- package/dist/utility/wrun/wrun-hud-looks.util.js +74 -28
- package/dist/utility/wrun/wrun-latest-snapshot.d.ts +11 -0
- package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +8 -6
- package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +8 -6
- package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -2
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +19 -9
- package/dist/utility/wrun/wrun-live-intake.util.js +213 -45
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-live-tick.util.js +246 -49
- package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.d.ts +53 -0
- package/dist/utility/wrun/wrun-market-size-contract-carry.leaf.js +162 -0
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +205 -48
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +277 -34
- package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +51 -7
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +340 -56
- package/dist/utility/wrun/wrun-opra-lane.util.d.ts +17 -4
- package/dist/utility/wrun/wrun-opra-lane.util.js +6 -4
- package/dist/utility/wrun/wrun-option-prints.util.d.ts +41 -2
- package/dist/utility/wrun/wrun-option-prints.util.js +80 -13
- package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.d.ts +31 -0
- package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.js +119 -0
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +26 -6
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +50 -11
- package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +109 -19
- package/dist/utility/wrun/wrun-option-strike-flow.util.js +222 -61
- package/dist/utility/wrun/wrun-option-views.util.d.ts +96 -18
- package/dist/utility/wrun/wrun-option-views.util.js +246 -51
- package/dist/utility/wrun/wrun-options-stop.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-options-stop.util.js +3 -2
- package/dist/utility/wrun/wrun-output-style.util.d.ts +6 -2
- package/dist/utility/wrun/wrun-output-style.util.js +20 -2
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +20 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +31 -14
- package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +22 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +10 -1
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +52 -4
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +7 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +25 -1
- package/dist/utility/wrun/wrun-overlay-result.util.d.ts +7 -1
- package/dist/utility/wrun/wrun-overlay-result.util.js +2 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +134 -37
- package/dist/utility/wrun/wrun-overlay-run.util.js +1118 -254
- package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +4 -4
- package/dist/utility/wrun/wrun-pack-widths.leaf.js +4 -4
- package/dist/utility/wrun/wrun-pack.util.d.ts +7 -3
- package/dist/utility/wrun/wrun-pack.util.js +20 -9
- package/dist/utility/wrun/wrun-pane-format.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-pane-format.util.js +7 -3
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +63 -13
- package/dist/utility/wrun/wrun-panel-style.util.d.ts +37 -24
- package/dist/utility/wrun/wrun-panel-style.util.js +100 -29
- package/dist/utility/wrun/wrun-param-map.util.d.ts +15 -11
- package/dist/utility/wrun/wrun-param-map.util.js +13 -5
- package/dist/utility/wrun/wrun-param-values.util.d.ts +21 -3
- package/dist/utility/wrun/wrun-param-values.util.js +6 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.js +12 -11
- package/dist/utility/wrun/wrun-prefix-lanes.util.js +2 -2
- package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +50 -0
- package/dist/utility/wrun/wrun-refusal-surface.util.js +68 -0
- package/dist/utility/wrun/wrun-refusal.util.js +10 -1
- package/dist/utility/wrun/wrun-refused-latest.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-refused-latest.util.js +12 -0
- package/dist/utility/wrun/wrun-row-source.d.ts +11 -0
- package/dist/utility/wrun/wrun-run-interval.util.d.ts +4 -2
- package/dist/utility/wrun/wrun-run-interval.util.js +9 -6
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +52 -1
- package/dist/utility/wrun/wrun-script-inputs.util.js +112 -4
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +7 -3
- package/dist/utility/wrun/wrun-setting-words.util.js +13 -5
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +27 -2
- package/dist/utility/wrun/wrun-socket-row-source.js +113 -8
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +9 -1
- package/dist/utility/wrun/wrun-source-rows.util.js +108 -43
- package/dist/utility/wrun/wrun-style-words.util.js +6 -4
- package/dist/utility/wrun/wrun-table-chrome.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-table-chrome.util.js +19 -11
- package/dist/utility/wrun/wrun-tape-per-order.util.d.ts +2 -0
- package/dist/utility/wrun/wrun-tape-per-order.util.js +26 -0
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +126 -50
- package/dist/utility/wrun/wrun-tape-source.util.js +193 -68
- package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +7 -5
- package/dist/utility/wrun/wrun-volume-profile-lane.util.js +8 -6
- package/dist/utils/replay/replay-buffer-math.d.ts +53 -2
- package/dist/utils/replay/replay-buffer-math.js +227 -20
- package/dist/workers/utils/volume-profile.worker.util.d.ts +4 -1
- package/dist/workers/utils/volume-profile.worker.util.js +5 -2
- package/dist/workers/wrun/wrun-abi-host.js +3 -2
- package/package.json +5 -5
|
@@ -13,27 +13,37 @@ import { isWrunChildHiddenRowKey } from './wrun-child-overlay-id.util.js';
|
|
|
13
13
|
* renderer, heatmap, profile or levels declaration (C1, parseWrunStyleTarget). */
|
|
14
14
|
export const WRUN_STYLE_ROW_PREFIX = '__style__';
|
|
15
15
|
/** True for a Style page row key (never a sheet param, never sent to a host):
|
|
16
|
-
* an output property row or a viewer row (a HUD's
|
|
17
|
-
*
|
|
16
|
+
* an output property row or a viewer row (a HUD's rows, a heatmap's
|
|
17
|
+
* Sensitivity). */
|
|
18
18
|
export function isWrunStyleRowKey(key) {
|
|
19
19
|
return key.startsWith(WRUN_STYLE_ROW_PREFIX) || isWrunViewerRowKey(key);
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
/** A HUD's viewer rows, `hud:<name>:<row>`: the Look pick (g3 addendum LK09),
|
|
22
|
+
* the place (the card moved by its title) and the dismissable HUD's collapsed
|
|
23
|
+
* and shown flags (C3), stored on the overlay beside the per-output style
|
|
24
|
+
* rows and never written into the sheet. The one list the key builder and
|
|
25
|
+
* every reader derive from: a row added here persists with the workspace row,
|
|
26
|
+
* rides a template and a twin conversion, and saves without a rerun. */
|
|
27
|
+
export const WRUN_HUD_VIEWER_ROWS = ['look', 'place', 'collapsed', 'shown'];
|
|
24
28
|
export const WRUN_HUD_LOOK_ROW_PREFIX = 'hud:';
|
|
25
|
-
|
|
29
|
+
const WRUN_HUD_VIEWER_ROW_RE = new RegExp(`^hud:(.+):(${WRUN_HUD_VIEWER_ROWS.join('|')})$`);
|
|
30
|
+
export function wrunHudViewerRowKey(name, row) {
|
|
31
|
+
return `${WRUN_HUD_LOOK_ROW_PREFIX}${name}:${row}`;
|
|
32
|
+
}
|
|
33
|
+
/** A HUD viewer row key read back: its HUD and its row; undefined for any other key. */
|
|
34
|
+
export function parseWrunHudViewerRowKey(key) {
|
|
35
|
+
const match = WRUN_HUD_VIEWER_ROW_RE.exec(key);
|
|
36
|
+
return match ? { name: match[1], row: match[2] } : undefined;
|
|
37
|
+
}
|
|
26
38
|
export function isWrunHudLookRowKey(key) {
|
|
27
|
-
return
|
|
39
|
+
return parseWrunHudViewerRowKey(key)?.row === 'look';
|
|
28
40
|
}
|
|
29
|
-
/** The viewer's own place for one HUD (`hud:<name>:place`, wrunHudPlaceRowKey). */
|
|
30
|
-
const WRUN_HUD_PLACE_ROW_RE = /^hud:(.+):place$/;
|
|
31
41
|
export function isWrunHudPlaceRowKey(key) {
|
|
32
|
-
return
|
|
42
|
+
return parseWrunHudViewerRowKey(key)?.row === 'place';
|
|
33
43
|
}
|
|
34
|
-
/** A HUD's viewer rows (
|
|
44
|
+
/** A HUD's viewer rows (WRUN_HUD_VIEWER_ROWS): overlay settings that persist by key. */
|
|
35
45
|
export function isWrunHudViewerRowKey(key) {
|
|
36
|
-
return
|
|
46
|
+
return WRUN_HUD_VIEWER_ROW_RE.test(key);
|
|
37
47
|
}
|
|
38
48
|
/** The viewer's Sensitivity for one heatmap (`heatmap:<name>:sensitivity`,
|
|
39
49
|
* wrunHeatmapSensitivityRowKey), stored on the overlay beside the HUD rows. */
|
|
@@ -41,8 +51,8 @@ export const WRUN_HEATMAP_SENSITIVITY_ROW_RE = /^heatmap:(.+):sensitivity$/;
|
|
|
41
51
|
export function isWrunHeatmapSensitivityRowKey(key) {
|
|
42
52
|
return WRUN_HEATMAP_SENSITIVITY_ROW_RE.test(key);
|
|
43
53
|
}
|
|
44
|
-
/** Every viewer row of a browser-run Indicator (a HUD's
|
|
45
|
-
*
|
|
54
|
+
/** Every viewer row of a browser-run Indicator (a HUD's rows, a heatmap's
|
|
55
|
+
* Sensitivity, a child the reader hid on its own legend row):
|
|
46
56
|
* overlay settings that persist by key and are never a sheet param, an alert
|
|
47
57
|
* param or a host param. */
|
|
48
58
|
export function isWrunViewerRowKey(key) {
|
|
@@ -90,7 +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
|
-
export { isWrunHeatmapSensitivityRowKey, isWrunHudLookRowKey, isWrunHudPlaceRowKey, isWrunHudViewerRowKey, isWrunStyleRowKey, isWrunViewerRowKey, packWrunColor, parseWrunColor, WRUN_HUD_LOOK_ROW_PREFIX, WRUN_STYLE_ROW_PREFIX, type WrunRgba, } from './wrun-color-facts.util.js';
|
|
93
|
+
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
94
|
declare const WRUN_LINE_STYLES: readonly ["solid", "dashed", "dotted"];
|
|
95
95
|
export type WrunLineStyle = (typeof WRUN_LINE_STYLES)[number];
|
|
96
96
|
/** The frozen `param.source` field list (plan 1.7, the kit's
|
|
@@ -156,6 +156,7 @@ export declare function parseWrunStyleTarget(target: string): {
|
|
|
156
156
|
* `visible: false`): it mounts nothing, the stats-row rule. Absent or true
|
|
157
157
|
* draws. */
|
|
158
158
|
export declare function isWrunStyleTargetHidden(declaration: unknown): boolean;
|
|
159
|
+
/** A HUD's Look row (`hud:<name>:look`; every HUD viewer row's key and reader in wrun-color-facts.util). */
|
|
159
160
|
export declare function wrunHudLookRowKey(name: string): string;
|
|
160
161
|
/** A HUD Look row key read back: the HUD it belongs to. */
|
|
161
162
|
export declare function parseWrunHudLookRowKey(key: string): {
|
|
@@ -192,15 +193,25 @@ export declare function wrunHeatmapSensitivitySetting(settings: unknown, name: s
|
|
|
192
193
|
/** True when a save moves the Sensitivity any heatmap draws with (a value set,
|
|
193
194
|
* changed or cleared, read as wrunHeatmapSensitivitySetting reads it). */
|
|
194
195
|
export declare function wrunHeatmapSensitivityChanged(prev: unknown, next: unknown): boolean;
|
|
195
|
-
/** A save whose every change is a HUD's viewer row (its Look pick, its place
|
|
196
|
-
* card reads, so no run, canvas paint or legend row depends on them.
|
|
197
|
-
* sends; its keys are compared with the overlay's current settings (`current`). */
|
|
196
|
+
/** A save whose every change is a HUD's viewer row (its Look pick, its place, its collapsed or shown
|
|
197
|
+
* flag): rows only the FE-drawn card reads, so no run, canvas paint or legend row depends on them.
|
|
198
|
+
* `patch` is what the save sends; its keys are compared with the overlay's current settings (`current`). */
|
|
198
199
|
export declare function onlyWrunHudViewerRowsChanged(current: unknown, patch: unknown): boolean;
|
|
199
200
|
/** A stored place read back; anything malformed reads as "where the script puts it". */
|
|
200
201
|
export declare function parseWrunHudPlace(raw: unknown): WrunHudPlaceSetting | undefined;
|
|
201
202
|
export declare function formatWrunHudPlace(place: WrunHudPlaceSetting): string;
|
|
202
203
|
/** The viewer's place for one HUD under the overlay's settings, or undefined (the script's place). */
|
|
203
204
|
export declare function wrunHudPlaceSetting(settings: unknown, name: string): WrunHudPlaceSetting | undefined;
|
|
205
|
+
/** The dismissable HUD (C3): the viewer folds one card to its chip (`hud:<name>:collapsed`, true) or hides
|
|
206
|
+
* it (`hud:<name>:shown`, false; the Style page's Show row brings it back), viewer rows of the one list
|
|
207
|
+
* (WRUN_HUD_VIEWER_ROWS). Each holds a boolean; absent, null or anything else reads as unset: an expanded
|
|
208
|
+
* card that is shown. */
|
|
209
|
+
export declare function wrunHudCollapsedRowKey(name: string): string;
|
|
210
|
+
export declare function wrunHudShownRowKey(name: string): string;
|
|
211
|
+
/** The viewer's collapsed flag for one HUD under the overlay's settings: the stored boolean, or undefined (expanded). */
|
|
212
|
+
export declare function wrunHudCollapsedSetting(settings: unknown, name: string): boolean | undefined;
|
|
213
|
+
/** The viewer's shown flag for one HUD under the overlay's settings: the stored boolean, or undefined (shown). */
|
|
214
|
+
export declare function wrunHudShownSetting(settings: unknown, name: string): boolean | undefined;
|
|
204
215
|
/** A packed colour (the `color_packed_by` wire) as the engine's own
|
|
205
216
|
* `rgba(r, g, b, a)` spelling. A non-finite, negative, fractional or
|
|
206
217
|
* out-of-range value (alpha thousandths past 1000) decodes to no colour. */
|
|
@@ -95,10 +95,10 @@ import { bindWrunColorSettings } from './wrun-color-settings.lazy.js';
|
|
|
95
95
|
import { WRUN_LEVELS_COLOR_PICKED_KEY } from './wrun-style-flags.util.js';
|
|
96
96
|
import { WRUN_OPTION_LANE_WORDS, WRUN_OPTION_VIEWS, wrunOptionViewParamKnobs } from './wrun-option-views.util.js';
|
|
97
97
|
import { findWrunVisibilityTarget, wrunVisibilitySectionOfPrefix, wrunVisibilityTargetAt, } from './wrun-visibility-table.js';
|
|
98
|
-
import { isWrunHudViewerRowKey, packWrunColor, parseWrunColor,
|
|
98
|
+
import { isWrunHudViewerRowKey, packWrunColor, parseWrunColor, parseWrunHudViewerRowKey, WRUN_HEATMAP_SENSITIVITY_ROW_RE, wrunHudViewerRowKey, } from './wrun-color-facts.util.js';
|
|
99
99
|
// The key predicates and the colour parse are thin facts boot-path readers take without this
|
|
100
100
|
// module (wrun-color-facts.util); every name stays exported here for this module's readers.
|
|
101
|
-
export { isWrunHeatmapSensitivityRowKey, isWrunHudLookRowKey, isWrunHudPlaceRowKey, isWrunHudViewerRowKey, isWrunStyleRowKey, isWrunViewerRowKey, packWrunColor, parseWrunColor, WRUN_HUD_LOOK_ROW_PREFIX, WRUN_STYLE_ROW_PREFIX, } from './wrun-color-facts.util.js';
|
|
101
|
+
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';
|
|
102
102
|
/** The largest packed colour (rgb 0xffffff, alpha 1000 thousandths), below
|
|
103
103
|
* 2^34 and so exact in f64. */
|
|
104
104
|
const WRUN_PACKED_COLOR_MAX = 0xffffff * 1024 + 1000;
|
|
@@ -227,15 +227,14 @@ export function parseWrunStyleTarget(target) {
|
|
|
227
227
|
export function isWrunStyleTargetHidden(declaration) {
|
|
228
228
|
return isRecord(declaration) && declaration.visible === false;
|
|
229
229
|
}
|
|
230
|
-
/** A HUD's Look row (`hud:<name>:look
|
|
231
|
-
const WRUN_HUD_LOOK_ROW_SUFFIX = ':look';
|
|
230
|
+
/** A HUD's Look row (`hud:<name>:look`; every HUD viewer row's key and reader in wrun-color-facts.util). */
|
|
232
231
|
export function wrunHudLookRowKey(name) {
|
|
233
|
-
return
|
|
232
|
+
return wrunHudViewerRowKey(name, 'look');
|
|
234
233
|
}
|
|
235
234
|
/** A HUD Look row key read back: the HUD it belongs to. */
|
|
236
235
|
export function parseWrunHudLookRowKey(key) {
|
|
237
|
-
const
|
|
238
|
-
return
|
|
236
|
+
const parsed = parseWrunHudViewerRowKey(key);
|
|
237
|
+
return parsed?.row === 'look' ? { name: parsed.name } : undefined;
|
|
239
238
|
}
|
|
240
239
|
/** The viewer's Look pick for one HUD under the overlay's settings: the
|
|
241
240
|
* stored word, or undefined for "As made" (absent, empty, not a string).
|
|
@@ -252,7 +251,6 @@ export function wrunHudLookSetting(settings, name) {
|
|
|
252
251
|
* offset convention). `at` is when the move was made, so in a place shared
|
|
253
252
|
* with other cards the latest move sits outermost. Absent = where the script
|
|
254
253
|
* puts it. */
|
|
255
|
-
const WRUN_HUD_PLACE_ROW_SUFFIX = ':place';
|
|
256
254
|
const WRUN_HUD_PLACE_VALUE_RE = /^([a-z_]+)@(\d{1,16})(?::(-?\d{1,6}),(-?\d{1,6}))?$/;
|
|
257
255
|
const WRUN_HUD_PLACE_ANCHORS = [
|
|
258
256
|
'top_left',
|
|
@@ -266,7 +264,7 @@ const WRUN_HUD_PLACE_ANCHORS = [
|
|
|
266
264
|
'bottom_right',
|
|
267
265
|
];
|
|
268
266
|
export function wrunHudPlaceRowKey(name) {
|
|
269
|
-
return
|
|
267
|
+
return wrunHudViewerRowKey(name, 'place');
|
|
270
268
|
}
|
|
271
269
|
/** The viewer's Sensitivity for one heatmap (`heatmap:<name>:sensitivity`):
|
|
272
270
|
* a 0..100 slider position on the options heatmap's Subtle..Vivid map
|
|
@@ -304,9 +302,9 @@ export function wrunHeatmapSensitivityChanged(prev, next) {
|
|
|
304
302
|
}
|
|
305
303
|
return false;
|
|
306
304
|
}
|
|
307
|
-
/** A save whose every change is a HUD's viewer row (its Look pick, its place
|
|
308
|
-
* card reads, so no run, canvas paint or legend row depends on them.
|
|
309
|
-
* sends; its keys are compared with the overlay's current settings (`current`). */
|
|
305
|
+
/** A save whose every change is a HUD's viewer row (its Look pick, its place, its collapsed or shown
|
|
306
|
+
* flag): rows only the FE-drawn card reads, so no run, canvas paint or legend row depends on them.
|
|
307
|
+
* `patch` is what the save sends; its keys are compared with the overlay's current settings (`current`). */
|
|
310
308
|
export function onlyWrunHudViewerRowsChanged(current, patch) {
|
|
311
309
|
const before = flatSettings(current) ?? {};
|
|
312
310
|
const sent = flatSettings(patch) ?? {};
|
|
@@ -343,6 +341,27 @@ export function formatWrunHudPlace(place) {
|
|
|
343
341
|
export function wrunHudPlaceSetting(settings, name) {
|
|
344
342
|
return parseWrunHudPlace(flatSettings(settings)?.[wrunHudPlaceRowKey(name)]);
|
|
345
343
|
}
|
|
344
|
+
/** The dismissable HUD (C3): the viewer folds one card to its chip (`hud:<name>:collapsed`, true) or hides
|
|
345
|
+
* it (`hud:<name>:shown`, false; the Style page's Show row brings it back), viewer rows of the one list
|
|
346
|
+
* (WRUN_HUD_VIEWER_ROWS). Each holds a boolean; absent, null or anything else reads as unset: an expanded
|
|
347
|
+
* card that is shown. */
|
|
348
|
+
export function wrunHudCollapsedRowKey(name) {
|
|
349
|
+
return wrunHudViewerRowKey(name, 'collapsed');
|
|
350
|
+
}
|
|
351
|
+
export function wrunHudShownRowKey(name) {
|
|
352
|
+
return wrunHudViewerRowKey(name, 'shown');
|
|
353
|
+
}
|
|
354
|
+
function storedBoolean(raw) {
|
|
355
|
+
return typeof raw === 'boolean' ? raw : undefined;
|
|
356
|
+
}
|
|
357
|
+
/** The viewer's collapsed flag for one HUD under the overlay's settings: the stored boolean, or undefined (expanded). */
|
|
358
|
+
export function wrunHudCollapsedSetting(settings, name) {
|
|
359
|
+
return storedBoolean(flatSettings(settings)?.[wrunHudCollapsedRowKey(name)]);
|
|
360
|
+
}
|
|
361
|
+
/** The viewer's shown flag for one HUD under the overlay's settings: the stored boolean, or undefined (shown). */
|
|
362
|
+
export function wrunHudShownSetting(settings, name) {
|
|
363
|
+
return storedBoolean(flatSettings(settings)?.[wrunHudShownRowKey(name)]);
|
|
364
|
+
}
|
|
346
365
|
function isRecord(value) {
|
|
347
366
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
348
367
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The market facts' dollar unit reader as a port (C-DOLLAR). wrun-chart-market-facts.util binds it when it loads, so
|
|
3
|
+
* the live intake, which live-feed loads before the first candle, reads a market's dollar unit without the facts module
|
|
4
|
+
* in that closure (tests/perf/pre-candle-budget.spec.ts weighs it). A dollar tape's live session always follows its
|
|
5
|
+
* full run, which loads the facts module, so the reader is bound by then; unbound reads as not known yet.
|
|
6
|
+
*/
|
|
7
|
+
import type { WrunFactsMarket, WrunMarketDollarUnit } from './wrun-chart-market-facts.util.js';
|
|
8
|
+
export interface WrunDollarUnitReader {
|
|
9
|
+
/** The market's dollar unit (`wrunMarketDollarUnit`), synchronous over the reads `warm` settles. */
|
|
10
|
+
unit(market: WrunFactsMarket): WrunMarketDollarUnit;
|
|
11
|
+
/** Ask the reads the unit needs again (`warmWrunMarketDollarFacts`); never rejects. */
|
|
12
|
+
warm(market: WrunFactsMarket): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/** Bind the reader: the facts module, once, when it loads. */
|
|
15
|
+
export declare function bindWrunDollarUnitReader(reader: WrunDollarUnitReader): void;
|
|
16
|
+
/** The bound reader, or undefined before the facts module loaded. */
|
|
17
|
+
export declare function wrunDollarUnitReader(): WrunDollarUnitReader | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
let bound;
|
|
2
|
+
/** Bind the reader: the facts module, once, when it loads. */
|
|
3
|
+
export function bindWrunDollarUnitReader(reader) {
|
|
4
|
+
bound = reader;
|
|
5
|
+
}
|
|
6
|
+
/** The bound reader, or undefined before the facts module loaded. */
|
|
7
|
+
export function wrunDollarUnitReader() {
|
|
8
|
+
return bound;
|
|
9
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The download meter (OPTLOAD wave 3, unit R1; UW-PARITY/reports/OPTLOAD-W3/guard-design.md section 3): what one
|
|
3
|
+
* indicator run downloads, counted from the worker's own wire count, never from the rows the page received. The run
|
|
4
|
+
* sees rows after the worker reduced them (Spot Exposures on SPY 1h: 28 bars of strike rows on the page, 17.67 MB on
|
|
5
|
+
* the wire, every minute snapshot of each bar read and all but the newest dropped), so a meter of the page's rows
|
|
6
|
+
* would miss it about 60 times over.
|
|
7
|
+
*
|
|
8
|
+
* - The unit is the wire byte the worker stamped on the FETCH_DATA's completion (`WrunSourceFetchVerdict.wireBytes`),
|
|
9
|
+
* for the asker that owned the request: a follower of a shared request, a cache and the chart's own rows carry 0.
|
|
10
|
+
* - An answer no stamp measures (a host that cannot count, the packed book worker, a relay feed's own fetch) is
|
|
11
|
+
* charged its cell bytes (8 per value, the source answer budget's unit), and the summary says so
|
|
12
|
+
* (`measure: 'cells'`).
|
|
13
|
+
* - Every byte a run asks goes through `transport.fetchSource`, whose options require a meter: a new call site without
|
|
14
|
+
* one does not typecheck. The web transport charges it once per call. The reads a run makes around the transport
|
|
15
|
+
* charge it at their own call: the warm-up heads (the chart's main candle request), a relay feed's own fetch, the
|
|
16
|
+
* chart's own candles.
|
|
17
|
+
* - A run's budget is 1 MB per 252 bars of its window, never under 1 MB, the kit's rule (`@openmarket/sdk/wrun-host`
|
|
18
|
+
* download-budget.ts) at the chart's real window.
|
|
19
|
+
*
|
|
20
|
+
* Telemetry only in R1: nothing reads the meter to change an ask; a full run hands its summary to the add's attempt
|
|
21
|
+
* (`downloadBytes` on `wrun-indicator`), the live session counts its reconciles on its own meter.
|
|
22
|
+
*
|
|
23
|
+
* R2 (the download budget's cut, behind `wrun-download-budget-cut`): a run whose projection passes its budget notes
|
|
24
|
+
* it (`noteBudget`: `budgeted`, the bars its reads left unread, the bytes it planned), and each history read it cuts
|
|
25
|
+
* keeps its own tally beside the run's meter (wrun-download-plan.util `createWrunLaneDownloadMeter`, off the boot
|
|
26
|
+
* path), so the read's newest slice measures its own wire bytes while the other reads download beside it.
|
|
27
|
+
*/
|
|
28
|
+
import type { WrunSourceFetchVerdict } from '../../host-ports.types.js';
|
|
29
|
+
/** One indicator add may download at most this many bytes at the standard window (the kit's
|
|
30
|
+
* `WRUN_INDICATOR_DOWNLOAD_BUDGET_BYTES`; a spec pins the two equal). */
|
|
31
|
+
export declare const WRUN_INDICATOR_DOWNLOAD_BUDGET_BYTES = 1000000;
|
|
32
|
+
/** The chart's standard loaded window at an add, in bars (the kit's `WRUN_DOWNLOAD_STANDARD_BARS`; the same spec pins
|
|
33
|
+
* the two equal). */
|
|
34
|
+
export declare const WRUN_DOWNLOAD_STANDARD_BARS = 252;
|
|
35
|
+
/** A run's budget: 1 MB per 252 bars of its window, never under 1 MB, so a template under budget at 252 bars stays
|
|
36
|
+
* under on a wider chart (its cost per bar does not change). Whole bytes. */
|
|
37
|
+
export declare function wrunRunDownloadBudgetBytes(windowBars: number): number;
|
|
38
|
+
/** What an ask hands the meter: the host's transport charges every call it answers, a run its own reads. */
|
|
39
|
+
export interface WrunDownloadMeterPort {
|
|
40
|
+
charge(charge: WrunDownloadCharge): void;
|
|
41
|
+
}
|
|
42
|
+
/** One answered ask: its fetch key and K type, its verdict (with the wire the asker downloaded when the host stamps
|
|
43
|
+
* it), and the rows it answered with their cell bytes (`wrunDownloadAnswerSize`). */
|
|
44
|
+
export interface WrunDownloadCharge {
|
|
45
|
+
key: string;
|
|
46
|
+
kType: string;
|
|
47
|
+
verdict?: WrunSourceFetchVerdict;
|
|
48
|
+
cellBytes: number;
|
|
49
|
+
rows: number;
|
|
50
|
+
}
|
|
51
|
+
/** A run's download, as the add's attempt reports it (analytics-taxonomy, `downloadBytes` and its siblings). */
|
|
52
|
+
export interface WrunDownloadSummary {
|
|
53
|
+
/** Wire bytes, with the cell bytes of every answer no stamp measured. */
|
|
54
|
+
bytes: number;
|
|
55
|
+
/** `cells` once any answer was charged its cell bytes. */
|
|
56
|
+
measure: 'wire' | 'cells';
|
|
57
|
+
cellBytes: number;
|
|
58
|
+
rows: number;
|
|
59
|
+
frames: number;
|
|
60
|
+
asks: number;
|
|
61
|
+
/** Asks a stamp measured at 0 bytes: a cache, the chart's own rows, a follower of another ask's request. */
|
|
62
|
+
cachedAsks: number;
|
|
63
|
+
windowBars: number;
|
|
64
|
+
budgetBytes: number;
|
|
65
|
+
over: boolean;
|
|
66
|
+
/** R2: the run planned a newest-first cut, and the bars it left unread. Always false and 0 in R1. */
|
|
67
|
+
budgeted: boolean;
|
|
68
|
+
cutBars: number;
|
|
69
|
+
/** The K type that downloaded the most, when any downloaded a byte. */
|
|
70
|
+
topSource?: string;
|
|
71
|
+
/** R2: a first slice's bytes plus the older asks still out, projected. */
|
|
72
|
+
plannedBytes?: number;
|
|
73
|
+
}
|
|
74
|
+
/** What a run notes of its budget (R2): it planned a cut (`budgeted`), the bars a read left unread (summed over the
|
|
75
|
+
* notes), and the bytes the run planned (its slices' bytes and the older asks it sends, projected; the last note
|
|
76
|
+
* wins). */
|
|
77
|
+
export interface WrunDownloadBudgetNote {
|
|
78
|
+
budgeted?: true;
|
|
79
|
+
cutBars?: number;
|
|
80
|
+
plannedBytes?: number;
|
|
81
|
+
}
|
|
82
|
+
export interface WrunDownloadMeter extends WrunDownloadMeterPort {
|
|
83
|
+
readonly budgetBytes: number;
|
|
84
|
+
spentBytes(): number;
|
|
85
|
+
remainingBytes(): number;
|
|
86
|
+
/** R2: the run's budget facts for the summary (`budgeted`, `cutBars`, `plannedBytes`). */
|
|
87
|
+
noteBudget(note: WrunDownloadBudgetNote): void;
|
|
88
|
+
summary(): WrunDownloadSummary;
|
|
89
|
+
}
|
|
90
|
+
export declare function createWrunDownloadMeter(windowBars: number): WrunDownloadMeter;
|
|
91
|
+
/**
|
|
92
|
+
* Hands a fetch its download meter beside its options, never inside them: a host's port binds the call's meter to the
|
|
93
|
+
* options object it passes on, and the fetch reads it back (`wrunDownloadMeterOf`). Web's dataFetch takes it this way,
|
|
94
|
+
* so every call keeps the arguments it always had (run specs pin them whole). The binding dies with the object.
|
|
95
|
+
*/
|
|
96
|
+
export declare function bindWrunDownloadMeter<T extends object>(options: T, meter: WrunDownloadMeterPort): T;
|
|
97
|
+
/** The meter bound beside a fetch's options object, if a port bound one. */
|
|
98
|
+
export declare function wrunDownloadMeterOf(options: object): WrunDownloadMeterPort | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* The rows an answer holds and their cell bytes, by the row cache's estimate (`estimateKScriptSourceRowsBytes`): 8 a
|
|
101
|
+
* value, a celled row's nested cells by their count, a typed array by its bytes; a packed answer (the kScript
|
|
102
|
+
* engine's packed OHLCV transfer) by its rows and its buffer. Anything else (a declined ask's null) holds none.
|
|
103
|
+
*/
|
|
104
|
+
export declare function wrunDownloadAnswerSize(answer: unknown): {
|
|
105
|
+
cellBytes: number;
|
|
106
|
+
rows: number;
|
|
107
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { isPackedOhlcvRows } from '../../instances/script-engine-worker-ohlcv-transfer.js';
|
|
2
|
+
import { KSCRIPT_SOURCE_CELL_BYTES } from '../chart/kscript-source-answer-budget.leaf.js';
|
|
3
|
+
/** One indicator add may download at most this many bytes at the standard window (the kit's
|
|
4
|
+
* `WRUN_INDICATOR_DOWNLOAD_BUDGET_BYTES`; a spec pins the two equal). */
|
|
5
|
+
export const WRUN_INDICATOR_DOWNLOAD_BUDGET_BYTES = 1_000_000;
|
|
6
|
+
/** The chart's standard loaded window at an add, in bars (the kit's `WRUN_DOWNLOAD_STANDARD_BARS`; the same spec pins
|
|
7
|
+
* the two equal). */
|
|
8
|
+
export const WRUN_DOWNLOAD_STANDARD_BARS = 252;
|
|
9
|
+
/** A run's budget: 1 MB per 252 bars of its window, never under 1 MB, so a template under budget at 252 bars stays
|
|
10
|
+
* under on a wider chart (its cost per bar does not change). Whole bytes. */
|
|
11
|
+
export function wrunRunDownloadBudgetBytes(windowBars) {
|
|
12
|
+
const bars = Number.isFinite(windowBars) && windowBars > 0 ? windowBars : 0;
|
|
13
|
+
return Math.round(WRUN_INDICATOR_DOWNLOAD_BUDGET_BYTES * Math.max(1, bars / WRUN_DOWNLOAD_STANDARD_BARS));
|
|
14
|
+
}
|
|
15
|
+
function countOf(value) {
|
|
16
|
+
return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : 0;
|
|
17
|
+
}
|
|
18
|
+
export function createWrunDownloadMeter(windowBars) {
|
|
19
|
+
const bars = Number.isFinite(windowBars) && windowBars > 0 ? Math.round(windowBars) : 0;
|
|
20
|
+
const budgetBytes = wrunRunDownloadBudgetBytes(bars);
|
|
21
|
+
let bytes = 0;
|
|
22
|
+
let cellBytes = 0;
|
|
23
|
+
let rows = 0;
|
|
24
|
+
let frames = 0;
|
|
25
|
+
let asks = 0;
|
|
26
|
+
let cachedAsks = 0;
|
|
27
|
+
let measure = 'wire';
|
|
28
|
+
let budgeted = false;
|
|
29
|
+
let cutBars = 0;
|
|
30
|
+
let plannedBytes;
|
|
31
|
+
const bytesByKType = new Map();
|
|
32
|
+
return {
|
|
33
|
+
budgetBytes,
|
|
34
|
+
noteBudget(note) {
|
|
35
|
+
if (note.budgeted === true)
|
|
36
|
+
budgeted = true;
|
|
37
|
+
cutBars += countOf(note.cutBars);
|
|
38
|
+
if (note.plannedBytes !== undefined && Number.isFinite(note.plannedBytes)) {
|
|
39
|
+
plannedBytes = Math.max(0, Math.round(note.plannedBytes));
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
charge(charge) {
|
|
43
|
+
asks += 1;
|
|
44
|
+
cellBytes += countOf(charge.cellBytes);
|
|
45
|
+
rows += countOf(charge.rows);
|
|
46
|
+
const wire = charge.verdict?.wireBytes;
|
|
47
|
+
let spent;
|
|
48
|
+
if (typeof wire === 'number' && Number.isFinite(wire) && wire >= 0) {
|
|
49
|
+
spent = wire;
|
|
50
|
+
frames += countOf(charge.verdict?.wireFrames);
|
|
51
|
+
if (spent === 0)
|
|
52
|
+
cachedAsks += 1;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// No stamp measured this answer: its cell bytes stand in for its wire, and the summary says so.
|
|
56
|
+
spent = countOf(charge.cellBytes);
|
|
57
|
+
measure = 'cells';
|
|
58
|
+
}
|
|
59
|
+
bytes += spent;
|
|
60
|
+
if (spent > 0)
|
|
61
|
+
bytesByKType.set(charge.kType, (bytesByKType.get(charge.kType) ?? 0) + spent);
|
|
62
|
+
},
|
|
63
|
+
spentBytes: () => bytes,
|
|
64
|
+
remainingBytes: () => Math.max(0, budgetBytes - bytes),
|
|
65
|
+
summary() {
|
|
66
|
+
let topSource;
|
|
67
|
+
let topBytes = 0;
|
|
68
|
+
for (const [kType, spent] of bytesByKType) {
|
|
69
|
+
if (spent > topBytes) {
|
|
70
|
+
topSource = kType;
|
|
71
|
+
topBytes = spent;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
bytes,
|
|
76
|
+
measure,
|
|
77
|
+
cellBytes,
|
|
78
|
+
rows,
|
|
79
|
+
frames,
|
|
80
|
+
asks,
|
|
81
|
+
cachedAsks,
|
|
82
|
+
windowBars: bars,
|
|
83
|
+
budgetBytes,
|
|
84
|
+
over: bytes > budgetBytes,
|
|
85
|
+
budgeted,
|
|
86
|
+
cutBars,
|
|
87
|
+
...(topSource !== undefined ? { topSource } : {}),
|
|
88
|
+
...(plannedBytes !== undefined ? { plannedBytes } : {}),
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** The meters bound beside a fetch's options object (`bindWrunDownloadMeter`). */
|
|
94
|
+
const metersByOptions = new WeakMap();
|
|
95
|
+
/**
|
|
96
|
+
* Hands a fetch its download meter beside its options, never inside them: a host's port binds the call's meter to the
|
|
97
|
+
* options object it passes on, and the fetch reads it back (`wrunDownloadMeterOf`). Web's dataFetch takes it this way,
|
|
98
|
+
* so every call keeps the arguments it always had (run specs pin them whole). The binding dies with the object.
|
|
99
|
+
*/
|
|
100
|
+
export function bindWrunDownloadMeter(options, meter) {
|
|
101
|
+
metersByOptions.set(options, meter);
|
|
102
|
+
return options;
|
|
103
|
+
}
|
|
104
|
+
/** The meter bound beside a fetch's options object, if a port bound one. */
|
|
105
|
+
export function wrunDownloadMeterOf(options) {
|
|
106
|
+
return metersByOptions.get(options);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The rows an answer holds and their cell bytes, by the row cache's estimate (`estimateKScriptSourceRowsBytes`): 8 a
|
|
110
|
+
* value, a celled row's nested cells by their count, a typed array by its bytes; a packed answer (the kScript
|
|
111
|
+
* engine's packed OHLCV transfer) by its rows and its buffer. Anything else (a declined ask's null) holds none.
|
|
112
|
+
*/
|
|
113
|
+
export function wrunDownloadAnswerSize(answer) {
|
|
114
|
+
if (isPackedOhlcvRows(answer))
|
|
115
|
+
return { cellBytes: answer.buffer.byteLength, rows: answer.rows };
|
|
116
|
+
if (!Array.isArray(answer))
|
|
117
|
+
return { cellBytes: 0, rows: 0 };
|
|
118
|
+
let cellBytes = 0;
|
|
119
|
+
for (const row of answer) {
|
|
120
|
+
if (ArrayBuffer.isView(row)) {
|
|
121
|
+
cellBytes += row.byteLength;
|
|
122
|
+
}
|
|
123
|
+
else if (Array.isArray(row)) {
|
|
124
|
+
for (const cell of row) {
|
|
125
|
+
cellBytes += Array.isArray(cell)
|
|
126
|
+
? cell.length * KSCRIPT_SOURCE_CELL_BYTES
|
|
127
|
+
: ArrayBuffer.isView(cell)
|
|
128
|
+
? cell.byteLength
|
|
129
|
+
: KSCRIPT_SOURCE_CELL_BYTES;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return { cellBytes, rows: answer.length };
|
|
134
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The download budget's plan (OPTLOAD wave 3, unit R2; UW-PARITY/reports/OPTLOAD-W3/guard-design.md sections 3.3 and
|
|
3
|
+
* 3.7): before any fetch, a run prices its reads with the kit's rule (`wrunDownloadReadCost`, the class table the
|
|
4
|
+
* publish gate charges) on its real window and market, and so decides its mode (`wrunRunDownloadMode`):
|
|
5
|
+
* - at or under the run's budget (1 MB per 252 bars, `wrunRunDownloadBudgetBytes`): WHOLE, today's asks unchanged, the
|
|
6
|
+
* meter only counts;
|
|
7
|
+
* - over it: BUDGETED. Snapshot and scalar reads reserve their projected bytes and are never cut; the history reads (a
|
|
8
|
+
* row lane with a flow or snapshot landing, the chart's own celled classes) share what is left in proportion to their
|
|
9
|
+
* projections. Each asks its newest slice first and alone whatever its share (it draws at least its newest bar), then
|
|
10
|
+
* the newest older bars its share fits by the slice's own wire bytes, and no others (wrun-row-lanes.util
|
|
11
|
+
* `fetchWrunRowLaneRows` `download`).
|
|
12
|
+
*
|
|
13
|
+
* The reads are the sheet's own (`wrunRunDownloadReads`: the kit's declared reads of every input the market demands,
|
|
14
|
+
* its setting-bound knobs at the run's values). A read whose lane downloads more than it declares carries the lane's own
|
|
15
|
+
* projection (`projectedBytes`, FE-FOLD-CAP: a strike flow read the lane will fold from the chain's contract rows),
|
|
16
|
+
* which replaces the kit's. The kit prices a 1h and a 5m window; a run on another interval is priced at the nearer one
|
|
17
|
+
* over its own bars (`wrunDownloadKitInterval`), so the rule holds exactly on the windows it is defined on and
|
|
18
|
+
* approximately elsewhere, where the meter still counts every byte.
|
|
19
|
+
*
|
|
20
|
+
* Behind the flag `wrun-download-budget-cut` (the run reads it): off, every run is whole.
|
|
21
|
+
*/
|
|
22
|
+
import type { WrunDownloadInputCost, WrunDownloadInterval, WrunDownloadMarket, WrunDownloadReadFacts } from '@orangecharts/indicator-kit/host';
|
|
23
|
+
import type { WrunIndicatorMetadata } from '../../interfaces/wrun-runtime.interface.js';
|
|
24
|
+
import { type WrunDownloadMeterPort } from './wrun-download-meter.util.js';
|
|
25
|
+
/** One read's tally beside the run's meter (`createWrunLaneDownloadMeter`): what its own asks downloaded. */
|
|
26
|
+
export interface WrunLaneDownloadMeter extends WrunDownloadMeterPort {
|
|
27
|
+
/** Bytes the read's asks downloaded: the wire a stamp measured, else the answer's cell bytes. */
|
|
28
|
+
spentBytes(): number;
|
|
29
|
+
/** The read's asks, and those a stamp measured at 0 bytes (a cache, a follower of another ask's request). */
|
|
30
|
+
asks(): number;
|
|
31
|
+
cachedAsks(): number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A read's own meter: every charge goes on to the run's meter unchanged (the run's summary counts every read once) and
|
|
35
|
+
* into the read's tally, so a budgeted read learns what its newest slice downloaded while the run's other reads
|
|
36
|
+
* download beside it (wrun-row-lanes.util `fetchWrunRowLaneRows` `download`).
|
|
37
|
+
*/
|
|
38
|
+
export declare function createWrunLaneDownloadMeter(run: WrunDownloadMeterPort): WrunLaneDownloadMeter;
|
|
39
|
+
/** The market shapes the kit prices (`WRUN_DOWNLOAD_MARKETS`). */
|
|
40
|
+
export type WrunDownloadPlanMarket = WrunDownloadMarket;
|
|
41
|
+
/** The kit's window nearest a chart's bar (`wrunDownloadReadCost` prices '1h' and '5m' alone). */
|
|
42
|
+
export declare function wrunDownloadKitInterval(intervalMs: number): WrunDownloadInterval;
|
|
43
|
+
/** A chart's market shape as the kit prices it: a CME Group exchange `cme`, a session market (a stock, an ETF, an index
|
|
44
|
+
* mode chart) `us-stock`, every other (a crypto venue, 24/7) `crypto`. */
|
|
45
|
+
export declare function wrunDownloadMarketOf(chart: {
|
|
46
|
+
cme: boolean;
|
|
47
|
+
indexMode: boolean;
|
|
48
|
+
}): WrunDownloadPlanMarket;
|
|
49
|
+
/** One read of a run as the plan prices it: the kit's facts, and the run's own words for it. */
|
|
50
|
+
export interface WrunDownloadPlanRead extends WrunDownloadReadFacts {
|
|
51
|
+
/** The run's name for the read (a row lane instance's id, a built-in lane's): the shares are keyed by it. Absent: the
|
|
52
|
+
* read's inputs, joined. */
|
|
53
|
+
key?: string;
|
|
54
|
+
/** A read the run can cut by bars (a history read). Absent or false: a snapshot or scalar read, reserved. */
|
|
55
|
+
history?: boolean;
|
|
56
|
+
/** The lane's own projection where the read downloads more than it declares (FE-FOLD-CAP), replacing the kit's. */
|
|
57
|
+
projectedBytes?: number;
|
|
58
|
+
}
|
|
59
|
+
/** The run's window as the plan prices it: its bars (the budget's), its bar and its market shape. */
|
|
60
|
+
export interface WrunDownloadPlanWindow {
|
|
61
|
+
bars: number;
|
|
62
|
+
intervalMs: number;
|
|
63
|
+
market: WrunDownloadPlanMarket;
|
|
64
|
+
}
|
|
65
|
+
export type WrunDownloadMode = {
|
|
66
|
+
mode: 'whole';
|
|
67
|
+
projectedBytes: number;
|
|
68
|
+
} | {
|
|
69
|
+
mode: 'budgeted';
|
|
70
|
+
projectedBytes: number;
|
|
71
|
+
budgetBytes: number;
|
|
72
|
+
shares: ReadonlyMap<string, number>;
|
|
73
|
+
};
|
|
74
|
+
/** One read's worst case on the run's window (the kit's `wrunDownloadReadCost`, by default through the shared host). */
|
|
75
|
+
export type WrunDownloadPrice = (read: WrunDownloadReadFacts, market: WrunDownloadMarket, interval: WrunDownloadInterval) => WrunDownloadInputCost;
|
|
76
|
+
/** The key a read's share is filed under. */
|
|
77
|
+
export declare function wrunDownloadPlanKeyOf(read: Pick<WrunDownloadPlanRead, 'key' | 'inputs'>): string;
|
|
78
|
+
/** A read's projected bytes on the window: the lane's own projection where it carries one, else the kit's. */
|
|
79
|
+
export declare function wrunDownloadPlanReadBytes(read: WrunDownloadPlanRead, window: Pick<WrunDownloadPlanWindow, 'intervalMs' | 'market'>, price?: WrunDownloadPrice): number;
|
|
80
|
+
/**
|
|
81
|
+
* The run's mode, before any fetch: WHOLE when the reads' projection is at or under the run's budget, else BUDGETED
|
|
82
|
+
* with each history read's share of what the reserved reads leave, in proportion to its projection (a read the run
|
|
83
|
+
* cannot cut, a snapshot or a scalar read, keeps its projection and is never cut). A read's share never holds it to
|
|
84
|
+
* nothing: it asks its newest slice whatever the share (the lane's rule), so a share is what its older bars may spend.
|
|
85
|
+
*/
|
|
86
|
+
export declare function wrunRunDownloadMode(reads: readonly WrunDownloadPlanRead[], window: WrunDownloadPlanWindow, price?: WrunDownloadPrice): WrunDownloadMode;
|
|
87
|
+
/**
|
|
88
|
+
* The sheet's reads as the kit charges them (`wrunDownloadPlanReads`, the declared-read half: every input it is handed
|
|
89
|
+
* is a read the plan left unasked, so each is charged from its declaration over the window), one per class and knob set
|
|
90
|
+
* with the inputs it serves: its knobs (a view, a fold, `history`, the strike knobs), its setting-bound knobs at the
|
|
91
|
+
* run's values (`settingOf`), its cap a bar (the input's capacity) and its width. `inputs` names the inputs the run
|
|
92
|
+
* reads (an input the market leaves undemanded is no read); the window is the run's, warm-up included
|
|
93
|
+
* (`[fromMs, toMs)`, at its bar). The chart's own candles are no read of the run (its rows answer them).
|
|
94
|
+
*/
|
|
95
|
+
export declare function wrunRunDownloadReads(sheet: WrunIndicatorMetadata, window: {
|
|
96
|
+
fromMs: number;
|
|
97
|
+
toMs: number;
|
|
98
|
+
intervalMs: number;
|
|
99
|
+
}, inputs: readonly string[], settingOf?: (name: string) => number | undefined): WrunDownloadReadFacts[];
|