@orangecharts/wrun-chart-host 0.9.0 → 0.11.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/feature-flags.constants.d.ts +15 -1
- package/dist/constants/feature-flags.constants.js +130 -24
- package/dist/constants/governed-exchanges.constants.d.ts +12 -0
- package/dist/constants/governed-exchanges.constants.js +16 -0
- package/dist/constants/opra-compliance.constants.d.ts +3 -2
- package/dist/constants/opra-compliance.constants.js +3 -2
- package/dist/constants/option-venues.constants.d.ts +2 -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 +21 -5
- package/dist/host-env.js +6 -0
- package/dist/host-ports.types.d.ts +102 -19
- package/dist/index.d.ts +18 -0
- package/dist/index.js +18 -0
- package/dist/interfaces/cancel-reason.interface.d.ts +1 -1
- package/dist/interfaces/cme-realtime.interface.d.ts +16 -9
- package/dist/interfaces/cme-realtime.interface.js +6 -3
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +12 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +1 -5
- package/dist/interfaces/prediction-market.interface.d.ts +7 -0
- package/dist/interfaces/replay.interface.d.ts +8 -0
- package/dist/interfaces/stocks-realtime.interface.d.ts +57 -0
- package/dist/interfaces/stocks-realtime.interface.js +32 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +18 -2
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +62 -94
- package/dist/kscript-data/controls/live-trades-merge.util.js +106 -171
- package/dist/market-data/billing.interface.d.ts +174 -36
- package/dist/market-data/billing.interface.js +58 -8
- package/dist/market-data/venue.d.ts +152 -7
- 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 +294 -7
- package/dist/market-data/venues/index.js +49 -6
- package/dist/market-data/venues/opra.contract.copy.json +3 -2
- package/dist/market-data/venues/opra.d.ts +2 -2
- package/dist/market-data/venues/opra.js +5 -2
- package/dist/market-data/venues/stocks.contract.copy.json +64 -0
- package/dist/market-data/venues/stocks.d.ts +130 -0
- package/dist/market-data/venues/stocks.js +117 -0
- package/dist/settings-templates/footprint-rows.js +35 -2
- package/dist/settings-templates/form-rows.d.ts +2 -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 +79 -10
- package/dist/settings-templates/tool-rules.d.ts +32 -15
- package/dist/settings-templates/tool-rules.js +33 -11
- package/dist/settings-templates/tool-tables.generated.js +95 -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/cme-cache-context.util.d.ts +5 -3
- package/dist/utility/chart/cme-cache-context.util.js +10 -6
- package/dist/utility/chart/cme-realtime.util.js +10 -0
- package/dist/utility/chart/cme-user-scripts-gate.util.d.ts +83 -0
- package/dist/utility/chart/cme-user-scripts-gate.util.js +142 -0
- package/dist/utility/chart/effective-chart-session.util.d.ts +14 -0
- package/dist/utility/chart/effective-chart-session.util.js +39 -0
- package/dist/utility/chart/host-bar-placement.util.d.ts +28 -0
- package/dist/utility/chart/host-bar-placement.util.js +170 -30
- package/dist/utility/chart/index-host-tier.util.d.ts +3 -1
- package/dist/utility/chart/index-host-tier.util.js +7 -2
- package/dist/utility/chart/index-mode-admission.util.js +30 -3
- package/dist/utility/chart/kscript-apply-fingerprint.util.js +1 -1
- 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 +9 -7
- package/dist/utility/chart/kscript-live-coalesce.util.js +13 -8
- package/dist/utility/chart/kscript-live-source-identity.util.d.ts +9 -0
- package/dist/utility/chart/kscript-live-source-identity.util.js +10 -1
- package/dist/utility/chart/kscript-provenance-keys.util.js +13 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +5 -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 +156 -43
- package/dist/utility/chart/kscript-venue-policy.util.js +249 -59
- package/dist/utility/chart/live-bucket.util.d.ts +24 -8
- package/dist/utility/chart/live-bucket.util.js +85 -27
- 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.js +5 -0
- package/dist/utility/chart/mixed-mode.util.d.ts +7 -0
- package/dist/utility/chart/mixed-mode.util.js +14 -0
- package/dist/utility/chart/opra-read-access.leaf.d.ts +5 -3
- package/dist/utility/chart/opra-read-access.leaf.js +5 -3
- package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +11 -16
- package/dist/utility/chart/opra-user-scripts-gate.util.js +12 -28
- package/dist/utility/chart/rth-session.util.d.ts +12 -10
- package/dist/utility/chart/rth-session.util.js +25 -21
- package/dist/utility/chart/trading-day.util.d.ts +17 -0
- package/dist/utility/chart/trading-day.util.js +59 -0
- 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/window-owner.leaf.d.ts +23 -2
- package/dist/utility/chart/window-owner.leaf.js +45 -3
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +33 -15
- package/dist/utility/chart/wrun-bar-session-facts.util.js +70 -20
- package/dist/utility/chart/wrun-run-result.util.d.ts +12 -0
- package/dist/utility/chart/wrun-run-result.util.js +141 -6
- package/dist/utility/intl-locale.util.js +5 -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 +18 -0
- package/dist/utility/options/option-venue.util.js +27 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +4 -0
- package/dist/utility/v2/gate-plane.util.d.ts +12 -3
- package/dist/utility/v2/gate-plane.util.js +30 -4
- package/dist/utility/v2/gate-session-latch.util.js +1 -1
- package/dist/utility/v2/stocks-governed.util.d.ts +16 -0
- package/dist/utility/v2/stocks-governed.util.js +34 -0
- package/dist/utility/wrun/derived-roots.leaf.d.ts +13 -0
- package/dist/utility/wrun/derived-roots.leaf.js +27 -0
- package/dist/utility/wrun/derived-roots.util.d.ts +205 -0
- package/dist/utility/wrun/derived-roots.util.js +451 -0
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +43 -7
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +89 -19
- package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +9 -4
- package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +47 -6
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -2
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -2
- package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +24 -3
- package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +46 -10
- package/dist/utility/wrun/sources/lanes/option_daily.js +5 -2
- package/dist/utility/wrun/sources/lanes/options_flow.js +5 -2
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +64 -19
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +105 -35
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +2 -1
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +2 -1
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +3 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +19 -4
- package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +17 -4
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +52 -13
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +88 -19
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +2 -1
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +24 -9
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +41 -10
- package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.d.ts +111 -0
- package/dist/utility/wrun/sources/wrun-row-lane-add-memo.util.js +133 -0
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +15 -3
- package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +22 -3
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +31 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +197 -13
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +761 -27
- package/dist/utility/wrun/wrun-browser-sources.leaf.js +1 -2
- package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +12 -0
- package/dist/utility/wrun/wrun-builtin-twin.util.js +21 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +60 -16
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +113 -61
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-color-settings.util.js +33 -0
- package/dist/utility/wrun/wrun-download-meter.util.d.ts +15 -0
- package/dist/utility/wrun/wrun-download-meter.util.js +14 -2
- package/dist/utility/wrun/wrun-download-plan.util.d.ts +99 -0
- package/dist/utility/wrun/wrun-download-plan.util.js +118 -0
- package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +11 -3
- package/dist/utility/wrun/wrun-draft-legend-note.util.js +26 -4
- package/dist/utility/wrun/wrun-frames.d.ts +27 -6
- package/dist/utility/wrun/wrun-frames.js +73 -10
- package/dist/utility/wrun/wrun-handles.util.d.ts +7 -3
- package/dist/utility/wrun/wrun-handles.util.js +9 -8
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +7 -1
- package/dist/utility/wrun/wrun-hosted-wire.util.js +12 -2
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +18 -4
- package/dist/utility/wrun/wrun-hud-looks.util.js +45 -13
- package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +68 -0
- package/dist/utility/wrun/wrun-input-requirements.leaf.js +163 -7
- package/dist/utility/wrun/wrun-latest-snapshot.d.ts +11 -0
- package/dist/utility/wrun/wrun-leg-close.util.d.ts +59 -23
- package/dist/utility/wrun/wrun-leg-close.util.js +186 -28
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +35 -15
- package/dist/utility/wrun/wrun-live-intake.util.js +243 -126
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +13 -5
- package/dist/utility/wrun/wrun-live-tick.util.js +279 -99
- package/dist/utility/wrun/wrun-market-facts.util.d.ts +13 -3
- package/dist/utility/wrun/wrun-market-facts.util.js +13 -3
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +60 -11
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +70 -5
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +31 -5
- package/dist/utility/wrun/wrun-opra-lane.util.d.ts +17 -4
- package/dist/utility/wrun/wrun-opra-lane.util.js +6 -4
- package/dist/utility/wrun/wrun-option-book-rows.util.d.ts +56 -0
- package/dist/utility/wrun/wrun-option-book-rows.util.js +96 -0
- package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.d.ts +31 -0
- package/dist/utility/wrun/wrun-option-strike-flow-forecast.util.js +119 -0
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +23 -6
- package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +47 -11
- package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +86 -19
- package/dist/utility/wrun/wrun-option-strike-flow.util.js +168 -62
- package/dist/utility/wrun/wrun-option-views.util.d.ts +323 -28
- package/dist/utility/wrun/wrun-option-views.util.js +484 -71
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-options-chain.util.js +2 -0
- 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 +32 -2
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +13 -3
- 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.js +3 -1
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +160 -42
- package/dist/utility/wrun/wrun-overlay-run.util.js +1244 -209
- 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 +114 -19
- package/dist/utility/wrun/wrun-panel-style.util.d.ts +10 -9
- package/dist/utility/wrun/wrun-panel-style.util.js +58 -9
- package/dist/utility/wrun/wrun-param-map.util.d.ts +14 -11
- package/dist/utility/wrun/wrun-param-map.util.js +10 -5
- package/dist/utility/wrun/wrun-param-values.util.d.ts +14 -4
- package/dist/utility/wrun/wrun-param-values.util.js +4 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +15 -2
- package/dist/utility/wrun/wrun-pin-spelling.util.js +39 -14
- 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.d.ts +3 -2
- package/dist/utility/wrun/wrun-refusal.util.js +22 -0
- package/dist/utility/wrun/wrun-refused-latest.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-refused-latest.util.js +12 -0
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +26 -0
- package/dist/utility/wrun/wrun-registry-errors.util.js +34 -0
- package/dist/utility/wrun/wrun-replay-lane.util.js +3 -2
- package/dist/utility/wrun/wrun-row-source.d.ts +11 -0
- package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +20 -6
- package/dist/utility/wrun/wrun-run-interval-session.util.js +22 -7
- package/dist/utility/wrun/wrun-run-interval.util.d.ts +43 -9
- package/dist/utility/wrun/wrun-run-interval.util.js +58 -15
- package/dist/utility/wrun/wrun-script-inputs.util.d.ts +45 -1
- package/dist/utility/wrun/wrun-script-inputs.util.js +112 -4
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +7 -3
- package/dist/utility/wrun/wrun-setting-words.util.js +13 -5
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +27 -2
- package/dist/utility/wrun/wrun-socket-row-source.js +118 -8
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +29 -18
- package/dist/utility/wrun/wrun-source-rows.util.js +61 -27
- 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 +7 -0
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +17 -9
- package/dist/utility/wrun/wrun-tape-source.util.js +20 -12
- package/dist/utils/replay/replay-buffer-math.d.ts +53 -2
- package/dist/utils/replay/replay-buffer-math.js +227 -20
- package/dist/workers/constants/socket-slots.d.ts +91 -6
- package/dist/workers/constants/socket-slots.js +85 -6
- package/package.json +5 -5
|
@@ -7,53 +7,37 @@ export declare const TRADES_HISTORY_MAX_CELLS = 300000;
|
|
|
7
7
|
/** The raw TRADE table's retention (about two days): a seeded history ask never reaches behind
|
|
8
8
|
* it (older windows answer nothing and cost the gateway a scan over cold chunks). */
|
|
9
9
|
export declare const TRADES_RETENTION_SEC: number;
|
|
10
|
-
/** The `trade_large` table's retention
|
|
11
|
-
* USD-quoted markets, copied from TRADE and kept 90 days): the large lane's horizon. */
|
|
10
|
+
/** The `trade_large` table's retention: the large lane's horizon. */
|
|
12
11
|
export declare const TRADES_LARGE_RETENTION_SEC: number;
|
|
13
12
|
/** tsdb-gateway's bar limit on the large lane (validateKiyoPlusBar, kiyo_plus_validation.go): an
|
|
14
13
|
* unaggregated read (TRADE_LARGE included) is estimated at one point per minute, and a tier user's
|
|
15
14
|
* window opening before now minus the tier's default max_bar_limit (15,000 on every tier of ore
|
|
16
15
|
* and cme) is trimmed to it without a word. About 10.4 days: the lane's real history horizon. */
|
|
17
16
|
export declare const TRADES_LARGE_BAR_LIMIT_SEC: number;
|
|
18
|
-
/** tsdb-gateway's trade_large floor (`write.large_trade_min_quote_amount`, default 10,000): a print
|
|
19
|
-
* is copied into the table when its quote amount reaches it. */
|
|
20
|
-
export declare const TRADES_LARGE_MIN_QUOTE_AMOUNT = 10000;
|
|
21
|
-
/** tsdb-gateway's trade_large floors on the CME Group venues (`write.large_trade_cme_contract_floors`
|
|
22
|
-
* in charts/tsdb-gateway/values.cme.yaml since !2239, 2026-10-14, which replaces the writer's code
|
|
23
|
-
* defaults wholesale): contracts per product root, the copy's quote amount priced with the root's
|
|
24
|
-
* point value. A root the list lacks is never copied: the writer skips it, and its large acquisition
|
|
25
|
-
* reads the raw tape's two hours instead (tradesLaneLimits). So a root the server floors and this
|
|
26
|
-
* map lacks draws two hours where the table holds days (Discord #557-saturn: 6E after !2239). A copy
|
|
27
|
-
* of the server's list until the floor rides the symbol metadata the chart already loads; then this
|
|
28
|
-
* map goes. Until then it changes in the same round as the values file. */
|
|
29
|
-
export declare const TRADES_LARGE_CME_CONTRACT_FLOORS: Readonly<Record<string, number>>;
|
|
30
17
|
/** A raw-tape acquisition's seed cap: a longer window over the raw TRADE table costs the gateway a
|
|
31
18
|
* scan over cold chunks (measured 18-30 s, or a server-side internal error, for ten days). */
|
|
32
19
|
export declare const TRADES_MAX_HISTORY_SEC: number;
|
|
33
|
-
/**
|
|
34
|
-
*
|
|
20
|
+
/**
|
|
21
|
+
* The CME Group product roots the collector copies into the large-print table (TRADE_LARGE): the keys of its contracts
|
|
22
|
+
* floor list (streamd charts/streamd/values.cme.yaml `large_trade.contract_floors`, the 33 roots tsdb-gateway's
|
|
23
|
+
* values.cme.yaml listed as `write.large_trade_cme_contract_floors` before the rule moved to the collector). The
|
|
24
|
+
* collector copies no print of a root off the list (it only counts them, `streamd_large_trade_skipped_points_total`),
|
|
25
|
+
* so the table answers such a market empty, history and live:
|
|
26
|
+
* COMEX:MGC1! 1m on 2026-10-29 read 0 prints of any size over six hours of the table while the raw tape held 79 prints
|
|
27
|
+
* of 10 contracts or more in two hours (#feedback-stream 2149). A copy of the collector's list until the instrument
|
|
28
|
+
* registry names the served floor per root; recorded with each root's newest TRADE_LARGE row in
|
|
29
|
+
* tests/fixtures/wrun/tape-dollar-units.json, whose spec holds the two equal: they change in the same round as the
|
|
30
|
+
* collector's list.
|
|
31
|
+
*/
|
|
32
|
+
export declare const TRADES_LARGE_CME_ROOTS: ReadonlySet<string>;
|
|
33
|
+
/** A tape's market: the frame's venue else the chart's, and the normalized symbol, else the raw one (`ES1!`). */
|
|
35
34
|
export interface TradesLargeMarket {
|
|
36
35
|
exchange?: unknown;
|
|
37
36
|
normalizedSymbol?: unknown;
|
|
38
37
|
symbol?: unknown;
|
|
39
|
-
/** An option book's registry trade units (`optionTradeUnitsOf` of its registry record): its live
|
|
40
|
-
* prints are floored on the premium the resolver's live-print rule reads (`tradePrintNotional`),
|
|
41
|
-
* never on price x size. */
|
|
42
|
-
optionUnits?: OptionTradeUnits | null;
|
|
43
38
|
}
|
|
44
|
-
/** The
|
|
45
|
-
* writer's `largeCMEPoints`), notional on a market quoted in dollars (`largeDollarPoints`). */
|
|
46
|
-
export type TradesLargeFloor = {
|
|
47
|
-
kind: 'contracts';
|
|
48
|
-
min: number;
|
|
49
|
-
} | {
|
|
50
|
-
kind: 'notional';
|
|
51
|
-
min: number;
|
|
52
|
-
};
|
|
53
|
-
/** The tape lane an acquisition rides on a market (`tradesLaneLimits`). */
|
|
39
|
+
/** The tape lane an acquisition rides (`tradesLaneLimits`). */
|
|
54
40
|
export interface TradesLaneLimits {
|
|
55
|
-
/** The history reads the TRADE_LARGE table: a `large` acquisition on a market the table holds. */
|
|
56
|
-
readsLargeTable: boolean;
|
|
57
41
|
/** The seed cap: the table's retention on the large lane, two hours on the raw tape, and 0 (the live edge only)
|
|
58
42
|
* for a dollar floor on the raw tape, whose rows no writer priced in dollars. Every reader of the tape's served
|
|
59
43
|
* history reads this cap: the request builder, the reconcile's served start and the queue loss's repair. */
|
|
@@ -82,10 +66,8 @@ export interface TradesTapeFloor {
|
|
|
82
66
|
optionUnits?: OptionTradeUnits | null;
|
|
83
67
|
}
|
|
84
68
|
export interface LiveTradesMergeOptions extends TradesTapeFloor {
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
* folds, so no live print appears that the next reconcile cannot answer. */
|
|
88
|
-
largeFloor?: TradesLargeMarket;
|
|
69
|
+
/** Fold only TRADE_LARGE rows (the large lane), else only raw TRADE prints: the router hands every trades source both. */
|
|
70
|
+
large?: boolean;
|
|
89
71
|
/** Called when the fold trimmed the live bar to the cap (the oldest prints dropped), so the
|
|
90
72
|
* caller can warn once (the kScript lane) or refuse the bar by name (the wrun lane). */
|
|
91
73
|
onCapped?: (cap: number) => void;
|
|
@@ -94,7 +76,7 @@ export interface LiveTradesMergeOptions extends TradesTapeFloor {
|
|
|
94
76
|
* (`tradesBarStartMs`); the cell's offset is measured from its open. Absent: the lane's own bar. */
|
|
95
77
|
barTs?: number;
|
|
96
78
|
}
|
|
97
|
-
/** One
|
|
79
|
+
/** One live print as the fold reads it: a raw TRADE fill, or a TRADE_LARGE row (one order). */
|
|
98
80
|
export interface LiveTradePrint {
|
|
99
81
|
tsMs: number;
|
|
100
82
|
price: number;
|
|
@@ -107,6 +89,18 @@ export interface LiveTradePrint {
|
|
|
107
89
|
/** The series envelope's normalized symbol (`BTC-USDT`), when the frame names one. */
|
|
108
90
|
normalizedSymbol?: string;
|
|
109
91
|
}
|
|
92
|
+
interface LiveTradeWire {
|
|
93
|
+
price?: unknown;
|
|
94
|
+
amount?: unknown;
|
|
95
|
+
quoteAmount?: unknown;
|
|
96
|
+
timestamp?: {
|
|
97
|
+
seconds?: unknown;
|
|
98
|
+
nanoseconds?: unknown;
|
|
99
|
+
nanos?: unknown;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** Every reader of a live amount reads here, so a floor never reads one channel's case while the fold reads the other. */
|
|
103
|
+
export declare function liveTradeOfPoint(point: unknown, large?: boolean): LiveTradeWire | undefined;
|
|
110
104
|
/**
|
|
111
105
|
* The chart bar a print at `tsMs` lands in, keyed the way the chart's candles of that market are:
|
|
112
106
|
* the CME Group session lattice at 4h, 1d and 1w on a CME venue (the gateway's
|
|
@@ -152,17 +146,9 @@ export declare function tradesServedStartMs(nowMs: number, historySec: number, i
|
|
|
152
146
|
barLimitSec?: number;
|
|
153
147
|
exchange?: unknown;
|
|
154
148
|
}): number;
|
|
155
|
-
/**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
export declare function readLiveTradePrint(newPoint: unknown): LiveTradePrint | null;
|
|
159
|
-
/** Whether the large-print table floors a market's prints by notional: its normalized symbol's
|
|
160
|
-
* quote (the second field, the gateway writer's `quoteAsset`: `BTC-USDT` quotes USDT) is USD or a
|
|
161
|
-
* dollar stablecoin. Any other quote (KRW, a coin) is never copied: the table holds none of its
|
|
162
|
-
* prints at all. */
|
|
163
|
-
export declare function tradesLargeQuotedInDollars(normalizedSymbol: unknown): boolean;
|
|
164
|
-
/** Whether a quote asset's amounts are US dollars: USD or a dollar stablecoin (the gateway writer's
|
|
165
|
-
* `peggedUSDQuotes`, the list the large-print table copies by). */
|
|
149
|
+
/** Null for a point the fold rejects, another channel's included; without `large`, either channel (stamp readers). */
|
|
150
|
+
export declare function readLiveTradePrint(newPoint: unknown, large?: boolean): LiveTradePrint | null;
|
|
151
|
+
/** Whether a quote asset's amounts are US dollars (`TRADES_LARGE_USD_QUOTES`). */
|
|
166
152
|
export declare function isTradesDollarQuoteAsset(asset: unknown): boolean;
|
|
167
153
|
/**
|
|
168
154
|
* The size a live print's cell carries on a tape, or null when the print does not reach the tape's floor: the ONE
|
|
@@ -181,56 +167,38 @@ export declare function tradesTapeCellSize(print: Pick<LiveTradePrint, 'price' |
|
|
|
181
167
|
/** Whether a tape floor can value a live print at all: a raw floor always can; a dollar floor needs the market's
|
|
182
168
|
* `valuePerUnit` or an option book's units. The live intake records a dollar tape that cannot, by name. */
|
|
183
169
|
export declare function tradesTapeFloorValuesPrints(floor: TradesTapeFloor): boolean;
|
|
184
|
-
/** A live print's notional: its quote amount when the frame carries one, else price x size. On an option
|
|
185
|
-
* book (`optionUnits`) the premium in the book's own currency by the resolver's live-print rule
|
|
186
|
-
* (option-trade-units.util `liveOptionPrintPremium`): a live print's size arrives in coin, live-feed having
|
|
187
|
-
* applied the contract multiplier, so the premium is price x size x point value / multiplier on a USD book
|
|
188
|
-
* and price x size on a coin book, the value the writer's floor reads once quote amounts follow the same
|
|
189
|
-
* rule; NaN when the units cannot say, which never reaches a floor. An option price is a premium, so
|
|
190
|
-
* neither price x size nor a frame's quote amount (a contract-multiplied figure on Binance and OKX coin
|
|
191
|
-
* books before that rule) is the notional there. Live prints only: a history row (the gateway's raw
|
|
192
|
-
* TRADE, stored units) never floors here. */
|
|
193
|
-
export declare function tradePrintNotional(print: Pick<LiveTradePrint, 'price' | 'size' | 'quoteAmount'>, optionUnits?: OptionTradeUnits | null): number;
|
|
194
170
|
/** A CME Group market's product root: the normalized symbol's first field (the gateway normalizer
|
|
195
171
|
* builds `<root>-USD`), else the raw symbol's root (`6AZ6` is 6A, the continuous `ES1!` is ES, a
|
|
196
172
|
* bare root is itself); undefined without either. */
|
|
197
173
|
export declare function tradesCmeProductRoot(market: TradesLargeMarket): string | undefined;
|
|
198
|
-
/**
|
|
199
|
-
*
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
174
|
+
/** Whether the collector copies a CME Group product root into the large-print table (`TRADES_LARGE_CME_ROOTS`); false
|
|
175
|
+
* for an unknown root. */
|
|
176
|
+
export declare function tradesLargeServesCmeRoot(root: unknown): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Whether the large-print table holds a market's big trades, the ONE rule of the tape lane a market rides
|
|
179
|
+
* (`tradesLaneLimits`): on a CME Group venue only a product root the collector copies (`tradesLargeServesCmeRoot`, the
|
|
180
|
+
* root `tradesCmeProductRoot` reads: `MGC1!`, `MGCZ6` and `MGC-USD` are MGC, which it does not); every other market
|
|
181
|
+
* is the collector's dollar rule's, which copies every print of at least $10k quote on a dollar-quoted market (a
|
|
182
|
+
* dollar tape on any other quote is refused by name before any fetch, `wrun_tape_value_unproven`). A tape on a market
|
|
183
|
+
* the table does not hold rides the raw tape, never the empty table.
|
|
184
|
+
*/
|
|
185
|
+
export declare function tradesLargeServesMarket(market: TradesLargeMarket): boolean;
|
|
186
|
+
/** The venues whose TRADE_LARGE read honors `minAmountPerOrder`; no other read may name it (a v2-only field leaves /v3). */
|
|
187
|
+
export declare function tradesFloorPerOrder(exchange: unknown): boolean;
|
|
203
188
|
/** Whether a tape floor is a dollar floor (C-DOLLAR's `minValue`, finite and above zero). */
|
|
204
189
|
export declare function tradesTapeFloorIsDollars(floor: Pick<TradesTapeFloor, 'minValue'>): boolean;
|
|
205
|
-
/** The tape lane an acquisition rides
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
export declare function tradesLaneLimits(large: boolean,
|
|
217
|
-
/**
|
|
218
|
-
* restoring what the queue cap dropped): the table on a market it holds, the raw tape on a CME
|
|
219
|
-
* Group root it skips under a size floor; never a lane that serves no history under the floor
|
|
220
|
-
* (`tradesLaneLimits`: a dollar floor on the raw tape), never a market quoted outside dollars. A
|
|
221
|
-
* market naming no normalized symbol is assumed held. */
|
|
222
|
-
export declare function tradesLargeHistoryAnswers(market: TradesLargeMarket, floor?: Pick<TradesTapeFloor, 'minValue'>): boolean;
|
|
223
|
-
/** True for a live print the large-print table never holds on a market it floors: a dollar-quoted
|
|
224
|
-
* print whose notional is under TRADES_LARGE_MIN_QUOTE_AMOUNT (the gateway copies a print whose
|
|
225
|
-
* quote amount reaches the floor), a CME Group print of fewer contracts than its root's floor (the
|
|
226
|
-
* frame's quote amount is price x contracts, no point value, so it never counts there). On an option
|
|
227
|
-
* book (`market.optionUnits`) the notional is the premium the resolver reads (`tradePrintNotional`),
|
|
228
|
-
* and a print it cannot price is under the floor. The print's
|
|
229
|
-
* envelope names the market, else `market`. A market the table never holds is never floored here:
|
|
230
|
-
* its lane reads the raw tape (a CME root without a floor) or the table answers it empty (a KRW or
|
|
231
|
-
* coin quote), and in both the live prints fold. */
|
|
232
|
-
export declare function tradesBelowLargeFloor(print: LiveTradePrint, market?: TradesLargeMarket): boolean;
|
|
233
|
-
/** Fold one raw TRADE point onto the tape rows: the NEW rows array (the touched row a new array,
|
|
234
|
-
* every other row shared by reference), or null when the point is rejected (the caller keeps
|
|
235
|
-
* its rows). The print lands in the bar `options.barTs` names, else in its own bar on the lane's grid. */
|
|
190
|
+
/** The tape lane an acquisition rides: the large lane (the table's retention, the gateway's bar
|
|
191
|
+
* limit, the declared history) when it asks `large`, else the raw tape (a two-hour seed inside the
|
|
192
|
+
* raw table's retention). Big trades read the large-print table wherever it holds the market
|
|
193
|
+
* (`tradesLargeServesMarket`, which decides `large` where the acquisition is built): raw trade is kept
|
|
194
|
+
* about two days, so a longer chart would show its small prints on the newest bars alone. A CME root
|
|
195
|
+
* the collector does not copy rides the raw tape (its two hours and the raw live channel, every fill
|
|
196
|
+
* judged on its own) instead of an empty table that draws nothing. A dollar floor (`floor.minValue`)
|
|
197
|
+
* on the raw tape reads no history at all (`historyCapSec` 0, the live edge): the raw tape's quote
|
|
198
|
+
* amounts are priced by no writer rule (a backfill gap is NULL), so its rows are no proven dollars.
|
|
199
|
+
* The ONE rule of a tape's served history: the request builder, the reconcile's served start and the
|
|
200
|
+
* queue loss's repair all read it with the acquisition's floor. */
|
|
201
|
+
export declare function tradesLaneLimits(large: boolean, floor?: Pick<TradesTapeFloor, 'minValue'>): TradesLaneLimits;
|
|
202
|
+
/** Answers NEW rows (the touched row new, the rest shared), or null to keep them: the handed rows are shared snapshots. */
|
|
236
203
|
export declare function mergeLiveTradesDataPoint(lastDataPoint: ReadonlyArray<ArrayLike<unknown>>, newPoint: unknown, intervalMs: number, options?: LiveTradesMergeOptions): LiveTradesRow[] | null;
|
|
204
|
+
export {};
|
|
@@ -5,24 +5,12 @@
|
|
|
5
5
|
// seeded history ask on the same bar and fold live prints by the same rules,
|
|
6
6
|
// so the lanes can never drift.
|
|
7
7
|
//
|
|
8
|
-
// The
|
|
9
|
-
// finite positive amount, a finite price and a wire timestamp; a print below
|
|
10
|
-
// the acquisition's floor is rejected (`tradesTapeCellSize`: its `minSize` in
|
|
11
|
-
// raw units, or its `minValue` in dollars, C-DOLLAR, where the cell's size is
|
|
12
|
-
// then the print's dollar value), and on the large lane a print the
|
|
13
|
-
// large-print table never holds (`tradesBelowLargeFloor`: a dollar-quoted
|
|
14
|
-
// market's print under the notional floor, a CME Group print under its
|
|
15
|
-
// product root's contracts floor); the print lands in the chart bar
|
|
16
|
-
// holding it (`tradesBarStartMs`); a delayed print for a bar older than the
|
|
17
|
-
// newest row never appends an out-of-order row; a live bar keeps its newest
|
|
18
|
-
// LIVE_MAX_CELLS_PER_BAR prints (the oldest are dropped and the caller is told
|
|
19
|
-
// through `onCapped`); the fold never mutates the rows or the cells it is
|
|
20
|
-
// handed (the touched row is a new array in a new container).
|
|
8
|
+
// The large lane folds the collector's TRADE_LARGE rows (one per order), any other tape raw TRADE fills: never mix them.
|
|
21
9
|
import { Intervals } from '../../constants/interval.constants.js';
|
|
22
10
|
import { barEndMs, barStartMs } from '../../utility/chart/calendar-interval.util.js';
|
|
23
11
|
import { cmeSessionBarEndMs, cmeSessionBarOpenMs, cmeSessionBucketMs, isCmeSessionLatticeExchange, isCmeSessionLatticeIntervalMs, } from '../../utility/chart/cme-session-bucket.util.js';
|
|
24
12
|
import { findMonday } from '../../workers/utils/time.worker.util.js';
|
|
25
|
-
import {
|
|
13
|
+
import { liveOptionPrintUsdPremium } from '../../utility/options/option-trade-units.util.js';
|
|
26
14
|
export const LIVE_MAX_CELLS_PER_BAR = 20_000;
|
|
27
15
|
/** The most prints one history ask reads (the history worker's cap, mirroring the historical service's
|
|
28
16
|
* HIST_TRADES_MAX_CELLS): past it the ask fails loudly instead of truncating the tape, and the wrun tape's refusal
|
|
@@ -31,8 +19,7 @@ export const TRADES_HISTORY_MAX_CELLS = 300_000;
|
|
|
31
19
|
/** The raw TRADE table's retention (about two days): a seeded history ask never reaches behind
|
|
32
20
|
* it (older windows answer nothing and cost the gateway a scan over cold chunks). */
|
|
33
21
|
export const TRADES_RETENTION_SEC = 2 * 24 * 3600;
|
|
34
|
-
/** The `trade_large` table's retention
|
|
35
|
-
* USD-quoted markets, copied from TRADE and kept 90 days): the large lane's horizon. */
|
|
22
|
+
/** The `trade_large` table's retention: the large lane's horizon. */
|
|
36
23
|
export const TRADES_LARGE_RETENTION_SEC = 90 * 24 * 3600;
|
|
37
24
|
/** tsdb-gateway's bar limit on the large lane (validateKiyoPlusBar, kiyo_plus_validation.go): an
|
|
38
25
|
* unaggregated read (TRADE_LARGE included) is estimated at one point per minute, and a tier user's
|
|
@@ -43,13 +30,7 @@ export const TRADES_LARGE_BAR_LIMIT_SEC = 15_000 * 60;
|
|
|
43
30
|
* lands, later than this one (the worker queue, the wire, a slow client clock), and a horizon that
|
|
44
31
|
* moved past the ask's first bar would cut that bar in two again. */
|
|
45
32
|
const TRADES_LARGE_BAR_LIMIT_MARGIN_SEC = 600;
|
|
46
|
-
/**
|
|
47
|
-
* is copied into the table when its quote amount reaches it. */
|
|
48
|
-
export const TRADES_LARGE_MIN_QUOTE_AMOUNT = 10_000;
|
|
49
|
-
/** The quote assets whose quote amount is dollars (the gateway writer's `peggedUSDQuotes`): only the
|
|
50
|
-
* prints of a market quoted in one of these are copied into trade_large, every other quote never. The
|
|
51
|
-
* dollar rule of a market's value (wrun-chart-market-facts.util `wrunMarketDollarUnit`) reads the same
|
|
52
|
-
* list (`isTradesDollarQuoteAsset`). */
|
|
33
|
+
/** A copy of the collector's `peggedUSDQuotes`, which the dollar-unit rule reads too: keep the two lists identical. */
|
|
53
34
|
const TRADES_LARGE_USD_QUOTES = new Set([
|
|
54
35
|
'USD',
|
|
55
36
|
'USDT',
|
|
@@ -64,60 +45,73 @@ const TRADES_LARGE_USD_QUOTES = new Set([
|
|
|
64
45
|
'TUSD',
|
|
65
46
|
'RLUSD',
|
|
66
47
|
]);
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
|
|
48
|
+
/** A raw-tape acquisition's seed cap: a longer window over the raw TRADE table costs the gateway a
|
|
49
|
+
* scan over cold chunks (measured 18-30 s, or a server-side internal error, for ten days). */
|
|
50
|
+
export const TRADES_MAX_HISTORY_SEC = 2 * 3600;
|
|
51
|
+
/** A CME Group contract code: the product root, a delivery month letter, one or two year digits. */
|
|
52
|
+
const CME_CONTRACT_CODE = /^([A-Z0-9]+?)[FGHJKMNQUVXZ]\d{1,2}$/;
|
|
53
|
+
/**
|
|
54
|
+
* The CME Group product roots the collector copies into the large-print table (TRADE_LARGE): the keys of its contracts
|
|
55
|
+
* floor list (streamd charts/streamd/values.cme.yaml `large_trade.contract_floors`, the 33 roots tsdb-gateway's
|
|
56
|
+
* values.cme.yaml listed as `write.large_trade_cme_contract_floors` before the rule moved to the collector). The
|
|
57
|
+
* collector copies no print of a root off the list (it only counts them, `streamd_large_trade_skipped_points_total`),
|
|
58
|
+
* so the table answers such a market empty, history and live:
|
|
59
|
+
* COMEX:MGC1! 1m on 2026-10-29 read 0 prints of any size over six hours of the table while the raw tape held 79 prints
|
|
60
|
+
* of 10 contracts or more in two hours (#feedback-stream 2149). A copy of the collector's list until the instrument
|
|
61
|
+
* registry names the served floor per root; recorded with each root's newest TRADE_LARGE row in
|
|
62
|
+
* tests/fixtures/wrun/tape-dollar-units.json, whose spec holds the two equal: they change in the same round as the
|
|
63
|
+
* collector's list.
|
|
64
|
+
*/
|
|
65
|
+
export const TRADES_LARGE_CME_ROOTS = new Set([
|
|
76
66
|
// Equity index
|
|
77
|
-
ES
|
|
78
|
-
NQ
|
|
79
|
-
YM
|
|
80
|
-
RTY
|
|
81
|
-
MES
|
|
82
|
-
MNQ
|
|
67
|
+
'ES',
|
|
68
|
+
'NQ',
|
|
69
|
+
'YM',
|
|
70
|
+
'RTY',
|
|
71
|
+
'MES',
|
|
72
|
+
'MNQ',
|
|
83
73
|
// Energy and metals
|
|
84
|
-
CL
|
|
85
|
-
NG
|
|
86
|
-
GC
|
|
87
|
-
SI
|
|
88
|
-
HG
|
|
74
|
+
'CL',
|
|
75
|
+
'NG',
|
|
76
|
+
'GC',
|
|
77
|
+
'SI',
|
|
78
|
+
'HG',
|
|
89
79
|
// FX
|
|
90
|
-
'6A'
|
|
91
|
-
'6B'
|
|
92
|
-
'6C'
|
|
93
|
-
'6E'
|
|
94
|
-
'6J'
|
|
95
|
-
'6S'
|
|
96
|
-
'6N'
|
|
97
|
-
'6M'
|
|
80
|
+
'6A',
|
|
81
|
+
'6B',
|
|
82
|
+
'6C',
|
|
83
|
+
'6E',
|
|
84
|
+
'6J',
|
|
85
|
+
'6S',
|
|
86
|
+
'6N',
|
|
87
|
+
'6M',
|
|
98
88
|
// Rates
|
|
99
|
-
ZN
|
|
100
|
-
ZF
|
|
101
|
-
ZT
|
|
102
|
-
TN
|
|
103
|
-
ZB
|
|
104
|
-
UB
|
|
89
|
+
'ZN',
|
|
90
|
+
'ZF',
|
|
91
|
+
'ZT',
|
|
92
|
+
'TN',
|
|
93
|
+
'ZB',
|
|
94
|
+
'UB',
|
|
105
95
|
// Grains
|
|
106
|
-
ZC
|
|
107
|
-
ZS
|
|
108
|
-
ZM
|
|
109
|
-
ZL
|
|
110
|
-
ZW
|
|
96
|
+
'ZC',
|
|
97
|
+
'ZS',
|
|
98
|
+
'ZM',
|
|
99
|
+
'ZL',
|
|
100
|
+
'ZW',
|
|
111
101
|
// Crypto
|
|
112
|
-
BTC
|
|
113
|
-
MBT
|
|
114
|
-
ETH
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
102
|
+
'BTC',
|
|
103
|
+
'MBT',
|
|
104
|
+
'ETH',
|
|
105
|
+
]);
|
|
106
|
+
/** Every reader of a live amount reads here, so a floor never reads one channel's case while the fold reads the other. */
|
|
107
|
+
export function liveTradeOfPoint(point, large) {
|
|
108
|
+
if (!point || typeof point !== 'object')
|
|
109
|
+
return undefined;
|
|
110
|
+
const { trade, tradeLarge } = point;
|
|
111
|
+
if (large === undefined)
|
|
112
|
+
return trade ?? tradeLarge;
|
|
113
|
+
return large ? tradeLarge : trade;
|
|
114
|
+
}
|
|
121
115
|
/**
|
|
122
116
|
* The chart bar a print at `tsMs` lands in, keyed the way the chart's candles of that market are:
|
|
123
117
|
* the CME Group session lattice at 4h, 1d and 1w on a CME venue (the gateway's
|
|
@@ -197,14 +191,12 @@ export function tradesServedStartMs(nowMs, historySec, intervalMs, options = {})
|
|
|
197
191
|
? Number.NEGATIVE_INFINITY
|
|
198
192
|
: tradesBarLimitStartMs(nowMs, options.barLimitSec, intervalMs, options.exchange));
|
|
199
193
|
}
|
|
200
|
-
/**
|
|
201
|
-
|
|
202
|
-
* or non-finite size, a bad price or stamp). */
|
|
203
|
-
export function readLiveTradePrint(newPoint) {
|
|
194
|
+
/** Null for a point the fold rejects, another channel's included; without `large`, either channel (stamp readers). */
|
|
195
|
+
export function readLiveTradePrint(newPoint, large) {
|
|
204
196
|
if (!newPoint || typeof newPoint !== 'object')
|
|
205
197
|
return null;
|
|
206
198
|
const point = newPoint;
|
|
207
|
-
const trade = point
|
|
199
|
+
const trade = liveTradeOfPoint(point, large);
|
|
208
200
|
const side = point.series?.side === 'BUY' ? 1 : point.series?.side === 'SELL' ? -1 : 0;
|
|
209
201
|
const size = Number(trade?.amount);
|
|
210
202
|
const price = Number(trade?.price);
|
|
@@ -229,18 +221,7 @@ export function readLiveTradePrint(newPoint) {
|
|
|
229
221
|
...(typeof normalizedSymbol === 'string' && normalizedSymbol !== '' ? { normalizedSymbol } : {}),
|
|
230
222
|
};
|
|
231
223
|
}
|
|
232
|
-
/** Whether
|
|
233
|
-
* quote (the second field, the gateway writer's `quoteAsset`: `BTC-USDT` quotes USDT) is USD or a
|
|
234
|
-
* dollar stablecoin. Any other quote (KRW, a coin) is never copied: the table holds none of its
|
|
235
|
-
* prints at all. */
|
|
236
|
-
export function tradesLargeQuotedInDollars(normalizedSymbol) {
|
|
237
|
-
if (typeof normalizedSymbol !== 'string')
|
|
238
|
-
return false;
|
|
239
|
-
const quote = normalizedSymbol.split('-')[1];
|
|
240
|
-
return quote !== undefined && TRADES_LARGE_USD_QUOTES.has(quote);
|
|
241
|
-
}
|
|
242
|
-
/** Whether a quote asset's amounts are US dollars: USD or a dollar stablecoin (the gateway writer's
|
|
243
|
-
* `peggedUSDQuotes`, the list the large-print table copies by). */
|
|
224
|
+
/** Whether a quote asset's amounts are US dollars (`TRADES_LARGE_USD_QUOTES`). */
|
|
244
225
|
export function isTradesDollarQuoteAsset(asset) {
|
|
245
226
|
return typeof asset === 'string' && TRADES_LARGE_USD_QUOTES.has(asset.trim().toUpperCase());
|
|
246
227
|
}
|
|
@@ -268,7 +249,7 @@ export function tradesTapeCellSize(print, floor) {
|
|
|
268
249
|
const unit = Number(floor.valuePerUnit);
|
|
269
250
|
value = Number.isFinite(unit) && unit > 0 ? print.price * print.size * unit : null;
|
|
270
251
|
}
|
|
271
|
-
return value !== null && Number.isFinite(value) && value >= minValue ? value : null;
|
|
252
|
+
return value !== null && Number.isFinite(value) && value > 0 && value >= minValue ? value : null;
|
|
272
253
|
}
|
|
273
254
|
const minSize = Number(floor.minSize);
|
|
274
255
|
return Number.isFinite(minSize) && minSize > 0 && print.size < minSize ? null : print.size;
|
|
@@ -283,20 +264,6 @@ export function tradesTapeFloorValuesPrints(floor) {
|
|
|
283
264
|
const unit = Number(floor.valuePerUnit);
|
|
284
265
|
return Number.isFinite(unit) && unit > 0;
|
|
285
266
|
}
|
|
286
|
-
/** A live print's notional: its quote amount when the frame carries one, else price x size. On an option
|
|
287
|
-
* book (`optionUnits`) the premium in the book's own currency by the resolver's live-print rule
|
|
288
|
-
* (option-trade-units.util `liveOptionPrintPremium`): a live print's size arrives in coin, live-feed having
|
|
289
|
-
* applied the contract multiplier, so the premium is price x size x point value / multiplier on a USD book
|
|
290
|
-
* and price x size on a coin book, the value the writer's floor reads once quote amounts follow the same
|
|
291
|
-
* rule; NaN when the units cannot say, which never reaches a floor. An option price is a premium, so
|
|
292
|
-
* neither price x size nor a frame's quote amount (a contract-multiplied figure on Binance and OKX coin
|
|
293
|
-
* books before that rule) is the notional there. Live prints only: a history row (the gateway's raw
|
|
294
|
-
* TRADE, stored units) never floors here. */
|
|
295
|
-
export function tradePrintNotional(print, optionUnits) {
|
|
296
|
-
if (optionUnits)
|
|
297
|
-
return liveOptionPrintPremium(print.price, print.size, optionUnits) ?? Number.NaN;
|
|
298
|
-
return print.quoteAmount ?? print.price * print.size;
|
|
299
|
-
}
|
|
300
267
|
/** A CME Group market's product root: the normalized symbol's first field (the gateway normalizer
|
|
301
268
|
* builds `<root>-USD`), else the raw symbol's root (`6AZ6` is 6A, the continuous `ES1!` is ES, a
|
|
302
269
|
* bare root is itself); undefined without either. */
|
|
@@ -313,99 +280,67 @@ export function tradesCmeProductRoot(market) {
|
|
|
313
280
|
return symbol.slice(0, -2) || undefined;
|
|
314
281
|
return CME_CONTRACT_CODE.exec(symbol)?.[1] ?? symbol;
|
|
315
282
|
}
|
|
316
|
-
/**
|
|
317
|
-
*
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
283
|
+
/** Whether the collector copies a CME Group product root into the large-print table (`TRADES_LARGE_CME_ROOTS`); false
|
|
284
|
+
* for an unknown root. */
|
|
285
|
+
export function tradesLargeServesCmeRoot(root) {
|
|
286
|
+
return typeof root === 'string' && TRADES_LARGE_CME_ROOTS.has(root.trim().toUpperCase());
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Whether the large-print table holds a market's big trades, the ONE rule of the tape lane a market rides
|
|
290
|
+
* (`tradesLaneLimits`): on a CME Group venue only a product root the collector copies (`tradesLargeServesCmeRoot`, the
|
|
291
|
+
* root `tradesCmeProductRoot` reads: `MGC1!`, `MGCZ6` and `MGC-USD` are MGC, which it does not); every other market
|
|
292
|
+
* is the collector's dollar rule's, which copies every print of at least $10k quote on a dollar-quoted market (a
|
|
293
|
+
* dollar tape on any other quote is refused by name before any fetch, `wrun_tape_value_unproven`). A tape on a market
|
|
294
|
+
* the table does not hold rides the raw tape, never the empty table.
|
|
295
|
+
*/
|
|
296
|
+
export function tradesLargeServesMarket(market) {
|
|
297
|
+
if (!isCmeSessionLatticeExchange(market.exchange))
|
|
298
|
+
return true;
|
|
299
|
+
return tradesLargeServesCmeRoot(tradesCmeProductRoot(market));
|
|
300
|
+
}
|
|
301
|
+
/** The venues whose TRADE_LARGE read honors `minAmountPerOrder`; no other read may name it (a v2-only field leaves /v3). */
|
|
302
|
+
export function tradesFloorPerOrder(exchange) {
|
|
303
|
+
return isCmeSessionLatticeExchange(exchange);
|
|
329
304
|
}
|
|
330
305
|
/** Whether a tape floor is a dollar floor (C-DOLLAR's `minValue`, finite and above zero). */
|
|
331
306
|
export function tradesTapeFloorIsDollars(floor) {
|
|
332
307
|
const minValue = Number(floor.minValue);
|
|
333
308
|
return Number.isFinite(minValue) && minValue > 0;
|
|
334
309
|
}
|
|
335
|
-
/** The tape lane an acquisition rides
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
export function tradesLaneLimits(large,
|
|
347
|
-
|
|
348
|
-
if (readsLargeTable) {
|
|
310
|
+
/** The tape lane an acquisition rides: the large lane (the table's retention, the gateway's bar
|
|
311
|
+
* limit, the declared history) when it asks `large`, else the raw tape (a two-hour seed inside the
|
|
312
|
+
* raw table's retention). Big trades read the large-print table wherever it holds the market
|
|
313
|
+
* (`tradesLargeServesMarket`, which decides `large` where the acquisition is built): raw trade is kept
|
|
314
|
+
* about two days, so a longer chart would show its small prints on the newest bars alone. A CME root
|
|
315
|
+
* the collector does not copy rides the raw tape (its two hours and the raw live channel, every fill
|
|
316
|
+
* judged on its own) instead of an empty table that draws nothing. A dollar floor (`floor.minValue`)
|
|
317
|
+
* on the raw tape reads no history at all (`historyCapSec` 0, the live edge): the raw tape's quote
|
|
318
|
+
* amounts are priced by no writer rule (a backfill gap is NULL), so its rows are no proven dollars.
|
|
319
|
+
* The ONE rule of a tape's served history: the request builder, the reconcile's served start and the
|
|
320
|
+
* queue loss's repair all read it with the acquisition's floor. */
|
|
321
|
+
export function tradesLaneLimits(large, floor = {}) {
|
|
322
|
+
if (large) {
|
|
349
323
|
return {
|
|
350
|
-
readsLargeTable,
|
|
351
324
|
historyCapSec: TRADES_LARGE_RETENTION_SEC,
|
|
352
325
|
retentionSec: TRADES_LARGE_RETENTION_SEC,
|
|
353
326
|
barLimitSec: TRADES_LARGE_BAR_LIMIT_SEC,
|
|
354
327
|
};
|
|
355
328
|
}
|
|
356
329
|
return {
|
|
357
|
-
readsLargeTable,
|
|
358
330
|
historyCapSec: tradesTapeFloorIsDollars(floor) ? 0 : TRADES_MAX_HISTORY_SEC,
|
|
359
331
|
retentionSec: TRADES_RETENTION_SEC,
|
|
360
332
|
};
|
|
361
333
|
}
|
|
362
|
-
/**
|
|
363
|
-
* restoring what the queue cap dropped): the table on a market it holds, the raw tape on a CME
|
|
364
|
-
* Group root it skips under a size floor; never a lane that serves no history under the floor
|
|
365
|
-
* (`tradesLaneLimits`: a dollar floor on the raw tape), never a market quoted outside dollars. A
|
|
366
|
-
* market naming no normalized symbol is assumed held. */
|
|
367
|
-
export function tradesLargeHistoryAnswers(market, floor = {}) {
|
|
368
|
-
if (!(tradesLaneLimits(true, market, floor).historyCapSec > 0))
|
|
369
|
-
return false;
|
|
370
|
-
if (isCmeSessionLatticeExchange(market.exchange))
|
|
371
|
-
return true;
|
|
372
|
-
return market.normalizedSymbol === undefined || tradesLargeQuotedInDollars(market.normalizedSymbol);
|
|
373
|
-
}
|
|
374
|
-
/** True for a live print the large-print table never holds on a market it floors: a dollar-quoted
|
|
375
|
-
* print whose notional is under TRADES_LARGE_MIN_QUOTE_AMOUNT (the gateway copies a print whose
|
|
376
|
-
* quote amount reaches the floor), a CME Group print of fewer contracts than its root's floor (the
|
|
377
|
-
* frame's quote amount is price x contracts, no point value, so it never counts there). On an option
|
|
378
|
-
* book (`market.optionUnits`) the notional is the premium the resolver reads (`tradePrintNotional`),
|
|
379
|
-
* and a print it cannot price is under the floor. The print's
|
|
380
|
-
* envelope names the market, else `market`. A market the table never holds is never floored here:
|
|
381
|
-
* its lane reads the raw tape (a CME root without a floor) or the table answers it empty (a KRW or
|
|
382
|
-
* coin quote), and in both the live prints fold. */
|
|
383
|
-
export function tradesBelowLargeFloor(print, market) {
|
|
384
|
-
const floor = tradesLargeFloorOfMarket({
|
|
385
|
-
exchange: print.exchange ?? market?.exchange,
|
|
386
|
-
normalizedSymbol: print.normalizedSymbol ?? market?.normalizedSymbol,
|
|
387
|
-
symbol: market?.symbol,
|
|
388
|
-
});
|
|
389
|
-
if (floor === null)
|
|
390
|
-
return false;
|
|
391
|
-
if (floor.kind === 'contracts')
|
|
392
|
-
return print.size < floor.min;
|
|
393
|
-
return !(tradePrintNotional(print, market?.optionUnits) >= floor.min);
|
|
394
|
-
}
|
|
395
|
-
/** Fold one raw TRADE point onto the tape rows: the NEW rows array (the touched row a new array,
|
|
396
|
-
* every other row shared by reference), or null when the point is rejected (the caller keeps
|
|
397
|
-
* its rows). The print lands in the bar `options.barTs` names, else in its own bar on the lane's grid. */
|
|
334
|
+
/** Answers NEW rows (the touched row new, the rest shared), or null to keep them: the handed rows are shared snapshots. */
|
|
398
335
|
export function mergeLiveTradesDataPoint(lastDataPoint, newPoint, intervalMs, options = {}) {
|
|
399
336
|
if (!Number.isFinite(intervalMs) || intervalMs <= 0)
|
|
400
337
|
return null;
|
|
401
|
-
const print = readLiveTradePrint(newPoint);
|
|
338
|
+
const print = readLiveTradePrint(newPoint, options.large === true);
|
|
402
339
|
if (print === null)
|
|
403
340
|
return null;
|
|
404
341
|
const size = tradesTapeCellSize(print, options);
|
|
405
342
|
if (size === null)
|
|
406
343
|
return null;
|
|
407
|
-
if (options.largeFloor !== undefined && tradesBelowLargeFloor(print, options.largeFloor))
|
|
408
|
-
return null;
|
|
409
344
|
const barTs = options.barTs ?? tradesBarStartMs(print.tsMs, intervalMs, print.exchange);
|
|
410
345
|
const rows = lastDataPoint;
|
|
411
346
|
const last = rows.length > 0 ? rows[rows.length - 1] : undefined;
|